a2a-source-edit: write agent.py

This commit is contained in:
a2a-cloud
2026-07-13 03:17:31 +00:00
parent 2ca22e2586
commit 4656d152c0

View File

@@ -702,12 +702,16 @@ async def _write_workspace_text(ctx: RunContext[NoAuth], path: str, text: str, m
if len(data) > MAX_TEXT_BYTES * 4:
raise ValueError("artifact exceeds bounded text size")
ws = ctx.workspace
if hasattr(ws, "write_bytes"):
ws.write_bytes(clean, data) # type: ignore[attr-defined]
if hasattr(ws, "is_writable_output") and ws.is_writable_output(clean): # type: ignore[attr-defined]
if hasattr(ws, "write_bytes"):
ws.write_bytes(clean, data) # type: ignore[attr-defined]
else:
view = await ws.open_view(purpose=f"write {clean}", hints=[clean], max_files=1, mode=WorkspaceMode.READ_WRITE_OVERLAY, reason="Persist integration engineering output under outputs/integrations")
await view.write(clean, data)
else:
view = await ws.open_view(purpose=f"write {clean}", hints=[clean], max_files=1, mode=WorkspaceMode.READ_WRITE_OVERLAY, reason="Persist integration engineering output under outputs/integrations")
await view.write(clean, data)
ref = await ctx.write_artifact(clean.split("/")[-1], data, mime_type)
raise PermissionError("workspace grant does not allow writes under outputs/integrations")
artifact_name = clean.replace("/", "__")
ref = await ctx.write_artifact(artifact_name, data, mime_type)
await ctx.emit_artifact(ref)
return ArtifactRecord(path=clean, sha256=hashlib.sha256(data).hexdigest(), size_bytes=len(data), mime_type=mime_type)