mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
Add save_deliverable_attachment for explicit document outbound, pass channel user_id into tool risk gating so write_file/run_command respect per-user allow_high settings, and document the workflow in channel-file-delivery skill. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from runtime.tools.public.save_deliverable_attachment_tool import save_deliverable_attachment_tool
|
|
|
|
|
|
def test_save_deliverable_attachment_registers_file(tmp_path, monkeypatch) -> None:
|
|
from svc.files.attachment_assets import AttachmentAssetStore
|
|
|
|
store = AttachmentAssetStore(root_dir=tmp_path / "att")
|
|
monkeypatch.setattr(
|
|
"runtime.tools.public.save_deliverable_attachment_tool.AttachmentAssetStore",
|
|
lambda root_dir=None: store if root_dir is None else AttachmentAssetStore(root_dir=root_dir),
|
|
)
|
|
monkeypatch.setattr(
|
|
"runtime.tools.public.save_deliverable_attachment_tool.resolve_workspace_path",
|
|
lambda raw: tmp_path / "report.txt",
|
|
)
|
|
report = tmp_path / "report.txt"
|
|
report.write_text("hello deliverable\n", encoding="utf-8")
|
|
|
|
spec = save_deliverable_attachment_tool()
|
|
out = spec.handler({"path": "report.txt"})
|
|
assert out.get("ok") is True
|
|
assert out.get("deliverable") is True
|
|
assert out.get("attachment_id")
|
|
assert out.get("mime") == "text/plain"
|
|
blob, meta = store.load_bytes(str(out["attachment_id"]))
|
|
assert blob is not None
|
|
assert blob.decode("utf-8").replace("\r\n", "\n") == "hello deliverable\n"
|
|
assert meta is not None
|