@hosty-sdk/app 0.47.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-client.d.ts +102 -0
- package/dist/agent-client.js +500 -0
- package/dist/agent-schemas.d.ts +6 -0
- package/dist/agent-schemas.js +150 -0
- package/dist/agent-server.d.ts +63 -0
- package/dist/agent-server.js +605 -0
- package/dist/agent.d.ts +539 -0
- package/dist/agent.js +35 -0
- package/dist/providers-server.d.ts +6 -1
- package/dist/providers-server.js +18 -2
- package/dist/providers.d.ts +3 -1
- package/package.json +25 -8
- package/schemas/agent-event-v1.schema.json +2988 -0
- package/schemas/agent-v1.fixtures.json +166 -0
- package/schemas/agent-v1.openapi.json +5618 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
const ref = (name) => ({ $ref: `#/components/schemas/${name}` });
|
|
2
|
+
const text = (maxLength = 256) => ({ type: "string", minLength: 1, maxLength });
|
|
3
|
+
const id = { type: "string", pattern: "^[A-Za-z0-9_-]{1,256}$" };
|
|
4
|
+
const uuid = { type: "string", format: "uuid" };
|
|
5
|
+
const revision = { type: "string", pattern: "^[1-9][0-9]{0,39}$" };
|
|
6
|
+
const sequence = { type: "string", pattern: "^(0|[1-9][0-9]{0,39})$" };
|
|
7
|
+
const digest = { type: "string", pattern: "^[a-f0-9]{64}$" };
|
|
8
|
+
const boolean = { type: "boolean" };
|
|
9
|
+
const positive = { type: "integer", minimum: 1, maximum: Number.MAX_SAFE_INTEGER };
|
|
10
|
+
const nullableText = { type: ["string", "null"], maxLength: 256 };
|
|
11
|
+
const list = (items, maxItems = 128) => ({ type: "array", maxItems, items });
|
|
12
|
+
const unique = (items, maxItems = 128) => ({ ...list(items, maxItems), uniqueItems: true });
|
|
13
|
+
const object = (properties, required = Object.keys(properties), additionalProperties = false) => ({ type: "object", properties, required, additionalProperties });
|
|
14
|
+
const capability = unique({ ...text(), pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$" }, 128);
|
|
15
|
+
const refProperties = { appId: text(), installationId: text(), key: text() };
|
|
16
|
+
const baseControl = { requestId: uuid, expectedGeneration: uuid, expectedRevision: revision };
|
|
17
|
+
const terminalStates = ["queued", "running", "waiting_for_input", "succeeded", "failed", "cancelled", "unknown"];
|
|
18
|
+
const phases = ["preparing", "executing", "waiting", "finalizing", "cancelling", "parked", "interrupted", "terminal"];
|
|
19
|
+
const historyObservation = {
|
|
20
|
+
sessionId: id, runId: id, generation: uuid, principalId: text(512), userId: text(512),
|
|
21
|
+
item: { oneOf: [object({ kind: { const: "snapshot" }, snapshot: ref("RunSnapshot") }),
|
|
22
|
+
object({ kind: { const: "event" }, event: ref("Event"), cursor: text(8192) })] },
|
|
23
|
+
};
|
|
24
|
+
export const AGENT_SCHEMAS = {
|
|
25
|
+
ProviderRef: object(refProperties),
|
|
26
|
+
QualifiedRef: object({ provider: ref("ProviderRef"), id }),
|
|
27
|
+
Instruction: object({ id: text(128), text: { type: "string", maxLength: 262144 } }),
|
|
28
|
+
Skill: object({ skillId: digest, expectedDigest: digest }, ["skillId"]),
|
|
29
|
+
McpTarget: { oneOf: [object({ kind: { const: "core" } }), object({ kind: { const: "app" }, ...refProperties })] },
|
|
30
|
+
McpPolicy: object({ default: { enum: ["ask", "run"] }, autoAllowReadOnly: boolean, tools: { type: "object", maxProperties: 512, propertyNames: text(), additionalProperties: { oneOf: [object({ mode: { const: "run" }, definition: digest }), object({ mode: { enum: ["ask", "disabled"] } })] } } }, ["default"]),
|
|
31
|
+
McpSelection: object({ targets: list(object({ target: ref("McpTarget"), tools: unique(text(), 512), policy: ref("McpPolicy") }, ["target"]), 16), connections: list(object({ id, revision }), 16) }, []),
|
|
32
|
+
Configuration: object({ connection: object({ id, revision }), instructions: list(ref("Instruction"), 16),
|
|
33
|
+
systemPrompt: object({ mode: { const: "append" }, text: { type: "string", maxLength: 262144 } }), skills: list(ref("Skill"), 202),
|
|
34
|
+
nativeTools: { enum: ["provider_default", "none"] }, approvalMode: { enum: ["normal", "autonomous"] }, predictions: object({ enabled: boolean }), subagents: object({ enabled: boolean, maxConcurrency: { type: "integer", minimum: 1, maximum: 128 } }, ["enabled"]) }, ["connection"]),
|
|
35
|
+
SessionCreate: object({ configuration: ref("Configuration"), requiredCapabilities: capability,
|
|
36
|
+
correlation: object({ conversation: ref("QualifiedRef"), task: ref("QualifiedRef") }, []) }, ["configuration"]),
|
|
37
|
+
ConfigurationCreate: object({ requestId: uuid, expectedSessionRevision: revision, configuration: ref("Configuration"), requiredCapabilities: capability }, ["requestId", "expectedSessionRevision", "configuration"]),
|
|
38
|
+
Attachment: object({ owner: ref("ProviderRef"), id, digest, sizeBytes: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER }, mediaType: text(128), name: text() }, ["owner", "id", "digest", "sizeBytes", "mediaType"]),
|
|
39
|
+
AttachmentChunk: object({ digest, sizeBytes: { type: "integer", minimum: 0, maximum: 26214400 }, mediaType: text(128), name: text(), count: { type: "integer", minimum: 1, maximum: 50 }, data: { type: "string", maxLength: 699052, contentEncoding: "base64" } }, ["digest", "sizeBytes", "mediaType", "count", "data"]),
|
|
40
|
+
AttachmentChunkReceipt: object({ attachment: { oneOf: [ref("Attachment"), { type: "null" }] }, received: unique({ type: "integer", minimum: 0, maximum: 49 }, 50) }),
|
|
41
|
+
Resource: object({ kind: text(64), id, revision: text(), provider: ref("ProviderRef") }, ["kind", "id", "revision"]),
|
|
42
|
+
Selection: object({ model: nullableText, reasoningEffort: nullableText }),
|
|
43
|
+
RunInput: object({ expectedSessionRevision: revision, configurationRevision: revision, continuation: { enum: ["start", "resume"] },
|
|
44
|
+
input: { oneOf: [object({ text: text(1048576), attachments: list(ref("Attachment"), 20) }, ["text"]), object({ decisionResponseRef: object({ runId: id, requestId: uuid }) })] },
|
|
45
|
+
context: list(ref("Instruction"), 16), selection: ref("Selection"), resources: list(ref("Resource"), 16), mcp: ref("McpSelection"), requiredCapabilities: capability,
|
|
46
|
+
limits: object({ maxDurationMs: positive, maxOutputTokens: positive, maxToolCalls: positive }, []) }, ["expectedSessionRevision", "configurationRevision", "continuation", "input"]),
|
|
47
|
+
DecisionResponse: { oneOf: [object({ kind: { const: "approval" }, decision: { enum: ["allow", "deny"] }, message: { type: "string", maxLength: 65536 } }, ["kind", "decision"]),
|
|
48
|
+
object({ kind: { const: "question" }, answers: { type: "object", maxProperties: 128, propertyNames: id, additionalProperties: { oneOf: [{ type: "string", maxLength: 65536 }, list({ type: "string", maxLength: 65536 }, 128)] } } })] },
|
|
49
|
+
ResponseInput: object({ ...baseControl, decisionId: id, decisionRevision: revision, response: ref("DecisionResponse") }),
|
|
50
|
+
CancelInput: { oneOf: [object(baseControl), object({ requestId: uuid, fenceIfNotAdmitted: object({ sessionId: id, startDigest: digest }) })] },
|
|
51
|
+
ControlInput: { oneOf: [
|
|
52
|
+
object({ ...baseControl, command: { const: "park" }, decisionId: id, decisionRevision: revision, reason: text(8192) }, [...Object.keys(baseControl), "command", "decisionId", "decisionRevision"]),
|
|
53
|
+
object({ ...baseControl, command: { const: "barrier" }, barrierId: id, kind: { enum: ["task_adoption", "child_wait", "source_rebind", "limits", "human_input"] }, generation: revision, acknowledgedSequence: sequence, snapshot: text(8192) }, [...Object.keys(baseControl), "command", "barrierId", "kind", "generation", "acknowledgedSequence"]),
|
|
54
|
+
object({ ...baseControl, command: { const: "reconcile" }, stopped: { const: true }, evidence: text(8192) }, [...Object.keys(baseControl), "command", "stopped"]),
|
|
55
|
+
object({ ...baseControl, command: { const: "liveConfigure" }, mcp: ref("McpSelection") }),
|
|
56
|
+
object({ ...baseControl, command: { const: "mcpPolicy" }, mcp: ref("McpSelection") }),
|
|
57
|
+
object({ ...baseControl, command: { const: "predictions" }, enabled: boolean }),
|
|
58
|
+
] },
|
|
59
|
+
Source: object({ agentId: id, parentAgentId: id, parentToolCallId: id }, ["agentId"]),
|
|
60
|
+
PendingDecision: object({ id, revision, kind: { enum: ["approval", "question"] }, delivery: { enum: ["continue_run", "next_turn"] }, source: ref("Source"), title: text(65536), toolCallId: id, toolName: text(), input: {},
|
|
61
|
+
questions: list(object({ id, text: text(65536), header: text(1024), allowText: boolean, multiple: boolean, required: boolean,
|
|
62
|
+
options: list(object({ id, label: text(8192), description: text(8192), preview: text(65536) }, ["id", "label"]), 128) }, ["id", "text"]), 128) }, ["id", "revision", "kind", "delivery"], true),
|
|
63
|
+
Result: object({ status: { enum: ["succeeded", "failed", "cancelled"] }, messageId: id, text: { type: "string", maxLength: 1048576 }, value: {}, schemaValid: boolean, error: ref("ErrorDetail") }, ["status"], true),
|
|
64
|
+
Message: object({ id, source: ref("Source"), role: { enum: ["assistant", "user", "system"] }, text: { type: "string", maxLength: 1048576 }, state: { enum: ["streaming", "complete", "interrupted"] } }, ["id", "role", "text", "state"], true),
|
|
65
|
+
Tool: object({ id, source: ref("Source"), name: text(), input: {}, output: { type: "string", maxLength: 1048576 }, state: { enum: ["running", "completed", "failed", "cancelled", "unknown"] }, truncated: boolean,
|
|
66
|
+
command: object({ status: { enum: ["completed", "failed", "cancelled", "unknown"] }, exitCode: { type: "integer" }, durationMs: { type: "integer", minimum: 0 }, summary: text(65536) }, ["status"]) }, ["id", "name", "state"], true),
|
|
67
|
+
RunSnapshot: object({ ref: ref("QualifiedRef"), sessionId: id, generation: uuid, revision: sequence,
|
|
68
|
+
state: { enum: terminalStates }, phase: { enum: phases }, stopConfirmed: boolean, freshness: { enum: ["current", "last_known", "unavailable"] }, observedAt: { type: "string", format: "date-time" },
|
|
69
|
+
configurationRevision: revision, lastSequence: sequence, cursor: text(8192), pending: list(ref("PendingDecision"), 256),
|
|
70
|
+
effects: object({ certainty: { enum: ["known", "unknown"] }, unresolvedCallIds: unique(id, 1024) }), result: ref("Result"), messages: list(ref("Message"), 4096), tools: list(ref("Tool"), 4096),
|
|
71
|
+
agents: list(object({ agentId: id, parentAgentId: id, parentToolCallId: id, state: { enum: terminalStates }, stopConfirmed: boolean }, ["agentId", "state"], true), 1024),
|
|
72
|
+
selection: object({ requested: ref("Selection"), effective: ref("Selection") }), admissionRef: text(),
|
|
73
|
+
coverage: object({ messages: { enum: ["complete", "truncated"] }, tools: { enum: ["complete", "truncated"] }, decisions: { enum: ["complete", "truncated"] } }, ["messages", "tools"]),
|
|
74
|
+
executionUsage: object({ sequence, activeMs: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER }, unknown: boolean }),
|
|
75
|
+
latestContext: { ...object({ sequence: revision, usage: { type: ["object", "null"], additionalProperties: true } }),
|
|
76
|
+
description: "Latest root context.updated observation within the snapshot watermark; its canonical positive sequence is at most lastSequence. Null usage explicitly clears the observation. Absence means no retained observation. Payloads share the bounded snapshot/event JSON byte allowance." },
|
|
77
|
+
decisions: list(object({ decision: ref("PendingDecision"), state: { enum: ["pending", "resolved", "superseded", "unknown"] }, response: ref("DecisionResponse") }, ["decision", "state"]), 256),
|
|
78
|
+
pendingContinuations: list(object({ requestId: uuid, run: ref("QualifiedRef"), state: { enum: ["pending", "awaiting_authorization", "admitted", "superseded"] } }), 256) }, ["ref", "sessionId", "generation", "revision", "state", "phase", "stopConfirmed", "freshness", "observedAt", "configurationRevision", "lastSequence", "cursor", "pending", "effects"], true),
|
|
79
|
+
HistoryObservation: object(historyObservation),
|
|
80
|
+
HistoryPage: object({ observations: list(object({ ...historyObservation, cursor: text(8192) }), 100),
|
|
81
|
+
through: text(8192), nextCursor: { type: ["string", "null"] } }),
|
|
82
|
+
Session: object({ ref: ref("QualifiedRef"), revision, configurationRevision: revision, configurationDigest: digest,
|
|
83
|
+
nativeState: { enum: ["not_created", "available", "missing", "unavailable", "unknown"] }, activeRun: { oneOf: [ref("QualifiedRef"), { type: "null" }] },
|
|
84
|
+
resolvedSkills: list(object({ skillId: digest, digest }), 202), configuration: ref("Configuration"), correlation: object({ conversation: ref("QualifiedRef"), task: ref("QualifiedRef") }, []) }, ["ref", "revision", "configurationRevision", "configurationDigest", "nativeState", "activeRun", "resolvedSkills"], true),
|
|
85
|
+
ControlReceipt: object({ requestId: uuid, state: { enum: ["accepted", "applied", "rejected", "superseded", "unknown"] }, run: ref("QualifiedRef"), revision: sequence, generation: uuid, error: ref("ErrorDetail"),
|
|
86
|
+
continuation: object({ run: ref("QualifiedRef"), state: { enum: ["pending", "awaiting_authorization", "admitted", "superseded"] } }) }, ["requestId", "state", "run", "revision"], true),
|
|
87
|
+
ErrorDetail: object({ code: text(), message: { type: "string", maxLength: 8192 }, retryable: boolean, requestId: uuid, details: { type: "object", additionalProperties: true } }, ["code", "message", "retryable"], true),
|
|
88
|
+
Error: object({ error: ref("ErrorDetail") }),
|
|
89
|
+
Connection: object({ id, revision, name: text(), ready: boolean, reason: text(8192), capabilities: capability }, ["id", "revision", "name", "ready"], true),
|
|
90
|
+
ModelCatalog: object({ revision: text(256), models: list(object({ id: text(), name: text(), reasoningEfforts: list(nullableText), defaultReasoningEffort: nullableText, capabilities: capability, unavailableReason: text(8192) }, ["id", "reasoningEfforts"], true), 1000), defaultModel: nullableText, nextCursor: { type: ["string", "null"], maxLength: 8192 } }, ["revision", "models", "defaultModel"], true),
|
|
91
|
+
Capabilities: object({ version: { const: 1 }, eventVersions: unique(text(), 16), capabilities: capability,
|
|
92
|
+
limits: object({ maxCommandBytes: positive, maxEventBytes: positive, maxSnapshotBytes: positive, maxReplayBytes: positive, replayRetentionMs: positive, maxControls: positive, maxPageSize: positive, maxDurationMs: positive, maxSkillSnapshotBytes: positive, maxSkillSnapshotFiles: positive }, ["maxCommandBytes", "maxEventBytes", "maxSnapshotBytes", "maxReplayBytes", "replayRetentionMs", "maxControls", "maxPageSize"], true), configuration: object({ resumeCompatible: unique(text(), 32) }) }, ["version", "eventVersions", "capabilities", "limits", "configuration"], true),
|
|
93
|
+
};
|
|
94
|
+
const eventNames = ["run.updated", "session.bound", "selection.updated", "message.started", "message.delta", "message.completed", "tool.started", "tool.output", "tool.completed", "decision.requested", "decision.updated", "decision.resolved", "control.updated", "result.available", "usage.updated", "context.updated", "agent.updated", "warning", "extension"];
|
|
95
|
+
AGENT_SCHEMAS.Event = { ...object({ schemaVersion: { const: "agent-event.1" }, runId: id, generation: uuid, sequence: revision, revision: sequence,
|
|
96
|
+
occurredAt: { type: "string", format: "date-time" }, type: { enum: eventNames }, source: ref("Source"), data: { type: "object", additionalProperties: true } }),
|
|
97
|
+
allOf: eventNames.map(name => ({ if: { properties: { type: { const: name } } }, then: { properties: { data: name === "run.updated" ? object({ snapshot: ref("RunSnapshot") }, ["snapshot"], true)
|
|
98
|
+
: name.startsWith("message.") ? object({ messageId: id, text: { type: "string" } }, name === "message.delta" ? ["messageId", "text"] : ["messageId"], true)
|
|
99
|
+
: name.startsWith("tool.") ? object({ toolCallId: id, name: text(), output: { type: "string" } }, name === "tool.output" ? ["toolCallId", "output"] : ["toolCallId"], true)
|
|
100
|
+
: name.startsWith("decision.") ? object({ decisionId: id, decision: ref("PendingDecision") }, ["decisionId"], true)
|
|
101
|
+
: name === "control.updated" ? object({ requestId: uuid, receipt: ref("ControlReceipt") }, ["requestId"], true)
|
|
102
|
+
: name === "session.bound" ? object({ sessionId: id }, ["sessionId"], true)
|
|
103
|
+
: name === "context.updated" ? object({ usage: { type: ["object", "null"], additionalProperties: true } }, ["usage"], true)
|
|
104
|
+
: name === "extension" ? object({ namespace: text(), required: { const: false }, payload: {} }, ["namespace"], true)
|
|
105
|
+
: { type: "object", additionalProperties: true } } } })),
|
|
106
|
+
};
|
|
107
|
+
const page = (key, item) => object({ [key]: list(ref(item), 100), nextCursor: { type: ["string", "null"], maxLength: 8192 } });
|
|
108
|
+
AGENT_SCHEMAS.SessionPage = page("sessions", "Session");
|
|
109
|
+
AGENT_SCHEMAS.ConnectionPage = page("connections", "Connection");
|
|
110
|
+
AGENT_SCHEMAS.ConnectionUsage = object({ observedAt: { type: "string", format: "date-time" }, available: boolean, data: { type: "object", additionalProperties: true } }, ["observedAt", "available"], true);
|
|
111
|
+
const parameter = (name) => ({ name, in: "path", required: true, schema: id });
|
|
112
|
+
const errors = Object.fromEntries([400, 401, 403, 404, 409, 410, 413, 422, 429, 503].map(status => [String(status), { description: "Structured agent error; retryable never authorizes another mutation UUID.", content: { "application/json": { schema: ref("Error") } } }]));
|
|
113
|
+
function operation(operationId, response, input, pathParameters = [], statuses = [200]) {
|
|
114
|
+
return { operationId, security: [{ coreOperation: [] }], parameters: pathParameters.map(parameter), ...(input ? { requestBody: { required: true, content: { "application/json": { schema: ref(input) } } } } : {}),
|
|
115
|
+
responses: { ...errors, ...Object.fromEntries(statuses.map(status => [String(status), { description: "Authorized durable result.", headers: { "Cache-Control": { schema: { const: "no-store" } } }, content: { "application/json": { schema: ref(response) } } }])) } };
|
|
116
|
+
}
|
|
117
|
+
export const AGENT_OPENAPI = {
|
|
118
|
+
openapi: "3.1.0", info: { title: "Hosty Agent Execution API", version: "1.0.0", description: "Independent provider execution. Paths are relative to the current Core-declared interface base. Exact UTF-8 command bytes and stable mutation UUIDs are retained across retries. No Harness dependency or raw native session IDs." },
|
|
119
|
+
paths: {
|
|
120
|
+
"/history/events": { get: { operationId: "history.events", security: [{ installationHistory: [] }],
|
|
121
|
+
parameters: [{ name: "after", in: "query", schema: text(8192) }, { name: "through", in: "query", schema: text(8192) }, { name: "limit", in: "query", schema: { type: "integer", minimum: 1, maximum: 100 } }],
|
|
122
|
+
description: "Resumable, read-only installation history. Frames use event: observation with an opaque installation feed position in id. Commit each observation before saving this position.",
|
|
123
|
+
responses: { ...errors, "200": { description: "History for the authenticated consumer installation.", content: { "text/event-stream": { schema: { type: "string" }, "x-event-schema": ref("HistoryObservation") }, "application/json": { schema: ref("HistoryPage") } } } } } },
|
|
124
|
+
"/capabilities": { get: operation("capabilities", "Capabilities") },
|
|
125
|
+
"/connections": { get: operation("connections.list", "ConnectionPage") },
|
|
126
|
+
"/connections/{connectionId}/models": { get: operation("connections.models", "ModelCatalog", undefined, ["connectionId"]) },
|
|
127
|
+
"/connections/{connectionId}/usage": { get: { ...operation("connections.usage", "ConnectionUsage", undefined, ["connectionId"]), description: "Optional connections.usage capability." } },
|
|
128
|
+
"/attachments/{attachmentId}/chunks/{index}": { put: { ...operation("attachments.write", "AttachmentChunkReceipt", "AttachmentChunk", ["attachmentId", "index"], [200, 201]), description: "Stable upload UUID, zero-based chunk index. At most 512 KiB decoded per chunk and 25 MiB/file; exact retries are actor scoped. Final completion publishes an immutable provider-owned attachment reference." } },
|
|
129
|
+
"/sessions": { get: operation("sessions.list", "SessionPage") },
|
|
130
|
+
"/sessions/{sessionId}": { get: operation("sessions.read", "Session", undefined, ["sessionId"]), put: operation("sessions.create", "Session", "SessionCreate", ["sessionId"], [200, 201]) },
|
|
131
|
+
"/sessions/{sessionId}/configurations/{configurationId}": { put: operation("sessions.configure", "Session", "ConfigurationCreate", ["sessionId", "configurationId"], [200, 201]) },
|
|
132
|
+
"/sessions/{sessionId}/runs/{runId}": { put: operation("runs.start", "RunSnapshot", "RunInput", ["sessionId", "runId"], [200, 202]) },
|
|
133
|
+
"/runs/{runId}": { get: operation("runs.read", "RunSnapshot", undefined, ["runId"]) },
|
|
134
|
+
"/runs/{runId}/events": { get: { operationId: "runs.events", security: [{ coreOperation: [] }], parameters: [parameter("runId"), { name: "after", in: "query", schema: text(8192) }, { name: "Last-Event-ID", in: "header", schema: text(8192) }],
|
|
135
|
+
description: "At-least-once SSE. after and Last-Event-ID must agree. Persisted Event envelopes use event: agent and an opaque id cursor. 410 replay_expired requires installing a fresh atomic snapshot before following its cursor. Disconnect never cancels execution.",
|
|
136
|
+
responses: { ...errors, "200": { description: "Persisted agent event stream.", content: { "text/event-stream": { schema: { type: "string" }, "x-event-schema": ref("Event") } } } } } },
|
|
137
|
+
"/runs/{runId}/responses": { post: operation("runs.respond", "ControlReceipt", "ResponseInput", ["runId"], [200, 202]) },
|
|
138
|
+
"/runs/{runId}/cancel": { post: operation("runs.cancel", "ControlReceipt", "CancelInput", ["runId"], [200, 202]) },
|
|
139
|
+
"/runs/{runId}/controls": { post: { ...operation("runs.control", "ControlReceipt", "ControlInput", ["runId"], [200, 202]), description: "Optional controls require their advertised capabilities. Reconcile input is an attestation, never proof of actual native exit." } },
|
|
140
|
+
"/runs/{runId}/controls/{requestId}": { get: operation("runs.controls.read", "ControlReceipt", undefined, ["runId", "requestId"]) },
|
|
141
|
+
}, components: { securitySchemes: { installationHistory: { type: "http", scheme: "bearer", description: "Core-issued installation history credential." }, coreOperation: { type: "http", scheme: "bearer", description: "Fresh Core exact-operation credential, never the caller's service/user token." } }, schemas: AGENT_SCHEMAS },
|
|
142
|
+
};
|
|
143
|
+
function localRefs(value) {
|
|
144
|
+
if (Array.isArray(value))
|
|
145
|
+
return value.map(localRefs);
|
|
146
|
+
if (value && typeof value === "object")
|
|
147
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, key === "$ref" && typeof item === "string" ? item.replace("#/components/schemas/", "#/$defs/") : localRefs(item)]));
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
export const AGENT_EVENT_SCHEMA = { $schema: "https://json-schema.org/draft/2020-12/schema", $id: "urn:hosty:agent-event:1", $ref: "#/$defs/Event", $defs: localRefs(AGENT_SCHEMAS) };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type AgentAttachmentChunk, type AgentCancelInput, type AgentCapabilities, type AgentConfiguration, type AgentConfigurationCreate, type AgentControlReceipt, type AgentEvent, type AgentMcpSelection, type AgentOperation, type AgentPendingDecision, type AgentResponseInput, type AgentRunControlInput, type AgentRunInput, type AgentRunSnapshot, type AgentSession, type AgentSessionCreate } from "./agent.js";
|
|
2
|
+
export declare const AGENT_COMMAND_MAX_BYTES: number;
|
|
3
|
+
type AgentParsedBase = {
|
|
4
|
+
method: string;
|
|
5
|
+
path: string;
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
runId?: string;
|
|
8
|
+
requestId?: string;
|
|
9
|
+
connectionId?: string;
|
|
10
|
+
attachmentId?: string;
|
|
11
|
+
chunkIndex?: number;
|
|
12
|
+
query: {
|
|
13
|
+
cursor?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
after?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type AgentParsedRequest = AgentParsedBase & ({
|
|
19
|
+
operation: "sessions.create";
|
|
20
|
+
input: AgentSessionCreate;
|
|
21
|
+
} | {
|
|
22
|
+
operation: "sessions.configure";
|
|
23
|
+
input: AgentConfigurationCreate;
|
|
24
|
+
} | {
|
|
25
|
+
operation: "runs.start";
|
|
26
|
+
input: AgentRunInput;
|
|
27
|
+
} | {
|
|
28
|
+
operation: "runs.respond";
|
|
29
|
+
input: AgentResponseInput;
|
|
30
|
+
} | {
|
|
31
|
+
operation: "runs.cancel";
|
|
32
|
+
input: AgentCancelInput;
|
|
33
|
+
} | {
|
|
34
|
+
operation: "runs.control";
|
|
35
|
+
input: AgentRunControlInput;
|
|
36
|
+
} | {
|
|
37
|
+
operation: "attachments.write";
|
|
38
|
+
input: AgentAttachmentChunk;
|
|
39
|
+
} | {
|
|
40
|
+
operation: Exclude<AgentOperation, "sessions.create" | "sessions.configure" | "runs.start" | "runs.respond" | "runs.cancel" | "runs.control" | "attachments.write">;
|
|
41
|
+
input: undefined;
|
|
42
|
+
});
|
|
43
|
+
export declare function validateAgentMcpSelection(value: unknown): asserts value is AgentMcpSelection;
|
|
44
|
+
export declare function validateAgentConfiguration(value: unknown): asserts value is AgentConfiguration;
|
|
45
|
+
export declare function validateAgentAttachmentChunk(value: unknown, index?: number): asserts value is AgentAttachmentChunk;
|
|
46
|
+
export declare function validateAgentSessionCreate(value: unknown): asserts value is AgentSessionCreate;
|
|
47
|
+
export declare function validateAgentConfigurationCreate(value: unknown): asserts value is AgentConfigurationCreate;
|
|
48
|
+
export declare function validateAgentRunInput(value: unknown): asserts value is AgentRunInput;
|
|
49
|
+
export declare function validateAgentResponseInput(value: unknown): asserts value is AgentResponseInput;
|
|
50
|
+
export declare function validateAgentCancelInput(value: unknown): asserts value is AgentCancelInput;
|
|
51
|
+
/** This validates an attestation's shape only. Providers must independently confirm actual native exit. */
|
|
52
|
+
export declare function validateAgentRunControlInput(value: unknown): asserts value is AgentRunControlInput;
|
|
53
|
+
/** Validate the actual relative path and bytes before Core introspection. Never trust body identity fields. */
|
|
54
|
+
export declare function validateAgentRequest(method: string, path: string, body: string | Uint8Array, expectedOperation?: AgentOperation): AgentParsedRequest;
|
|
55
|
+
export declare function agentReplayCursor(after?: string | null, lastEventId?: string | null): string | undefined;
|
|
56
|
+
export declare function validateAgentPendingDecision(value: unknown): asserts value is AgentPendingDecision;
|
|
57
|
+
export declare function validateAgentRunSnapshot(value: unknown): asserts value is AgentRunSnapshot;
|
|
58
|
+
export declare function validateAgentEvent(value: unknown): asserts value is AgentEvent;
|
|
59
|
+
export declare function validateAgentCapabilities(value: unknown): asserts value is AgentCapabilities;
|
|
60
|
+
export declare function validateAgentSession(value: unknown): asserts value is AgentSession;
|
|
61
|
+
export declare function validateAgentControlReceipt(value: unknown): asserts value is AgentControlReceipt;
|
|
62
|
+
export declare function encodeAgentSseEvent(event: AgentEvent, cursor: string): string;
|
|
63
|
+
export {};
|