feat: keep what agents deliver and serve it at signed links (ADR-0004)

The Orchestration engine keeps every completed agent Execution it relays,
by tenant, Customer case and Execution, and serves its record and files at
signed, expiring links. A KAB workflow step, which takes one output per
step, is given one JSON document of links (`deliver: links`); other callers
still get each file, and what they are given is kept either way.

- store.py, links.py, delivery.py, serving.py; the relay keeps and links
- the card declares `deliver`, `sources` and an output schema
- image: STORE_DIR on a /data volume; PUBLIC_URL and LINK_SECRET settings
- option 1's tests replaced by tests of the links document

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 20:05:47 +01:00
parent ce5e2f20cd
commit 6d32bc696d
17 changed files with 1235 additions and 205 deletions

View File

@@ -81,6 +81,42 @@ def build_card(
)
_LINK = {"type": ["string", "null"], "format": "uri"}
# The document of links a caller asking for links is given (ADR-0004).
OUTPUT_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "completed, completed_with_warnings, or stopped when a "
"sequence did not run to its end.",
},
"work": {"type": "string", "description": "The work that was done."},
"customer_case": {"type": "string"},
"execution_id": {
"type": "string",
"description": "The last agent's Execution.",
},
"record": {**_LINK, "description": "The last Execution's record and links."},
"guide": {**_LINK, "description": "The last agent's guide."},
"files": {
"type": "object",
"description": "A signed link to each file the last agent delivered.",
},
"latest": {
**_LINK,
"description": "The newest completed Execution of this work.",
},
"case": {**_LINK, "description": "Every Execution kept for the Customer case."},
"results": {
"type": "object",
"description": "Each agent's Execution, how it ended and its links, by its work.",
},
"not_started": {"type": "array", "items": {"type": "string"}},
},
}
def input_contract(
agents: Sequence[Agent], sequences: Sequence[AgentSequence] = ()
) -> dict[str, Any]:
@@ -115,6 +151,22 @@ def input_contract(
"uiFieldType": "textarea",
"description": "The spec to start from, as a YAML or JSON document.",
},
"sources": {
"type": "object",
"description": (
"Files to start from, by name, such as an earlier step's "
"`files`: another agent's delivered work."
),
},
"deliver": {
"type": "string",
"enum": ["links", "files"],
"description": (
"links: one document of signed links to what the agents "
"delivered, kept here (a platform step is given this). "
"files: each file as the agent sent it."
),
},
"pre_approved": {
"type": "boolean",
"default": True,
@@ -126,6 +178,7 @@ def input_contract(
},
"required": [WORK, "customer_case"],
},
"outputSchema": OUTPUT_SCHEMA,
}