a2a-source-edit: write agent.py
This commit is contained in:
17
agent.py
17
agent.py
@@ -12,7 +12,6 @@ import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime, timezone
|
||||
@@ -32,6 +31,8 @@ from a2a_pack import (
|
||||
Resources,
|
||||
RunContext,
|
||||
State,
|
||||
WorkspaceAccess,
|
||||
WorkspaceMode,
|
||||
)
|
||||
from a2a_pack.workspace import FileUpload, UploadedFile
|
||||
|
||||
@@ -130,6 +131,12 @@ class QuoteJudgeStudioV1(A2AAgent[QuoteJudgeStudioV1Config, PlatformUserAuth]):
|
||||
caller_pays_llm=False,
|
||||
notes="Deterministic local quote scoring; no LLM credential is required.",
|
||||
)
|
||||
workspace_access = WorkspaceAccess.dynamic(
|
||||
max_files=MAX_UPLOADS,
|
||||
allowed_modes=(WorkspaceMode.READ_ONLY,),
|
||||
require_reason=False,
|
||||
max_total_size_bytes=MAX_UPLOADS * MAX_UPLOAD_BYTES,
|
||||
)
|
||||
tools_used = ("postgres", "mcp")
|
||||
|
||||
@a2a.tool(
|
||||
@@ -305,13 +312,19 @@ class QuoteJudgeStudioV1(A2AAgent[QuoteJudgeStudioV1Config, PlatformUserAuth]):
|
||||
"comparison_id": _clean_comparison_id(comparison_id),
|
||||
}
|
||||
try:
|
||||
grant = await ctx.workspace.request_access(
|
||||
files=[document.path],
|
||||
mode=WorkspaceMode.READ_ONLY,
|
||||
reason="Parse the caller-uploaded quote file for comparison.",
|
||||
purpose="Read uploaded vendor quote file",
|
||||
)
|
||||
view = await ctx.workspace.open_view(
|
||||
purpose="Read uploaded vendor quote file",
|
||||
hints=[document.path],
|
||||
max_files=1,
|
||||
reason="Parse the caller-uploaded quote file for comparison.",
|
||||
)
|
||||
raw = await view.read(document.path)
|
||||
raw = await view.read(grant.files[0].path)
|
||||
except Exception:
|
||||
return {
|
||||
"ok": False,
|
||||
|
||||
Reference in New Issue
Block a user