@hosty-sdk/app 0.50.0 → 0.52.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.
@@ -52,11 +52,14 @@ export const AGENT_SCHEMAS = {
52
52
  object({ ...baseControl, command: { const: "park" }, decisionId: id, decisionRevision: revision, reason: text(8192) }, [...Object.keys(baseControl), "command", "decisionId", "decisionRevision"]),
53
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
54
  object({ ...baseControl, command: { const: "reconcile" }, stopped: { const: true }, evidence: text(8192) }, [...Object.keys(baseControl), "command", "stopped"]),
55
+ object({ ...baseControl, command: { const: "retire" } }),
55
56
  object({ ...baseControl, command: { const: "liveConfigure" }, mcp: ref("McpSelection") }),
56
57
  object({ ...baseControl, command: { const: "mcpPolicy" }, mcp: ref("McpSelection") }),
57
58
  object({ ...baseControl, command: { const: "predictions" }, enabled: boolean }),
58
59
  ] },
59
60
  Source: object({ agentId: id, parentAgentId: id, parentToolCallId: id }, ["agentId"]),
61
+ ChildAgent: object({ agentId: id, parentAgentId: id, parentToolCallId: id, state: { enum: terminalStates }, stopConfirmed: boolean,
62
+ prompt: { type: "string", maxLength: 65536 }, response: { type: "string", maxLength: 65536 }, promptTruncated: boolean, responseTruncated: boolean }, ["agentId", "state"], true),
60
63
  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
64
  questions: list(object({ id, text: text(65536), header: text(1024), allowText: boolean, multiple: boolean, required: boolean,
62
65
  options: list(object({ id, label: text(8192), description: text(8192), preview: text(65536) }, ["id", "label"]), 128) }, ["id", "text"]), 128) }, ["id", "revision", "kind", "delivery"], true),
@@ -68,7 +71,7 @@ export const AGENT_SCHEMAS = {
68
71
  state: { enum: terminalStates }, phase: { enum: phases }, stopConfirmed: boolean, freshness: { enum: ["current", "last_known", "unavailable"] }, observedAt: { type: "string", format: "date-time" },
69
72
  configurationRevision: revision, lastSequence: sequence, cursor: text(8192), pending: list(ref("PendingDecision"), 256),
70
73
  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),
74
+ agents: list(ref("ChildAgent"), 1024),
72
75
  selection: object({ requested: ref("Selection"), effective: ref("Selection") }), admissionRef: text(),
73
76
  coverage: object({ messages: { enum: ["complete", "truncated"] }, tools: { enum: ["complete", "truncated"] }, decisions: { enum: ["complete", "truncated"] } }, ["messages", "tools"]),
74
77
  executionUsage: object({ sequence, activeMs: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER }, unknown: boolean }),
@@ -107,9 +110,10 @@ AGENT_SCHEMAS.Event = { ...object({ schemaVersion: { const: "agent-event.1" }, r
107
110
  : name.startsWith("decision.") ? object({ decisionId: id, decision: ref("PendingDecision") }, ["decisionId"], true)
108
111
  : name === "control.updated" ? object({ requestId: uuid, receipt: ref("ControlReceipt") }, ["requestId"], true)
109
112
  : name === "session.bound" ? object({ sessionId: id }, ["sessionId"], true)
110
- : name === "context.updated" ? object({ usage: { type: ["object", "null"], additionalProperties: true } }, ["usage"], true)
111
- : name === "extension" ? object({ namespace: text(), required: { const: false }, payload: {} }, ["namespace"], true)
112
- : { type: "object", additionalProperties: true } } } })),
113
+ : name === "agent.updated" ? object({ agent: ref("ChildAgent") }, [], true)
114
+ : name === "context.updated" ? object({ usage: { type: ["object", "null"], additionalProperties: true } }, ["usage"], true)
115
+ : name === "extension" ? object({ namespace: text(), required: { const: false }, payload: {} }, ["namespace"], true)
116
+ : { type: "object", additionalProperties: true } } } })),
113
117
  };
114
118
  const page = (key, item) => object({ [key]: list(ref(item), 100), nextCursor: { type: ["string", "null"], maxLength: 8192 } });
115
119
  AGENT_SCHEMAS.SessionPage = page("sessions", "Session");
@@ -160,7 +164,7 @@ export const AGENT_OPENAPI = {
160
164
  responses: { ...errors, "200": { description: "Persisted agent event stream.", content: { "text/event-stream": { schema: { type: "string" }, "x-event-schema": ref("Event") } } } } } },
161
165
  "/runs/{runId}/responses": { post: operation("runs.respond", "ControlReceipt", "ResponseInput", ["runId"], [200, 202]) },
162
166
  "/runs/{runId}/cancel": { post: operation("runs.cancel", "ControlReceipt", "CancelInput", ["runId"], [200, 202]) },
163
- "/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." } },
167
+ "/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. Retirement requires provider-owned evidence of native process exit. Its applied receipt records retirement of the exact run and preserves unresolved tool outcomes." } },
164
168
  "/runs/{runId}/controls/{requestId}": { get: operation("runs.controls.read", "ControlReceipt", undefined, ["runId", "requestId"]) },
165
169
  }, 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 },
166
170
  };
@@ -259,7 +259,7 @@ export function validateAgentCancelInput(value) {
259
259
  export function validateAgentRunControlInput(value) {
260
260
  if (!object(value))
261
261
  fail("An execution control is required.");
262
- const fields = { park: ["decisionId", "decisionRevision", "reason"], barrier: ["barrierId", "kind", "generation", "acknowledgedSequence", "snapshot"], reconcile: ["stopped", "evidence"], liveConfigure: ["mcp"], mcpPolicy: ["mcp"], predictions: ["enabled"] };
262
+ const fields = { park: ["decisionId", "decisionRevision", "reason"], barrier: ["barrierId", "kind", "generation", "acknowledgedSequence", "snapshot"], reconcile: ["stopped", "evidence"], retire: [], liveConfigure: ["mcp"], mcpPolicy: ["mcp"], predictions: ["enabled"] };
263
263
  if (typeof value.command !== "string" || !fields[value.command])
264
264
  fail("Unsupported execution control.", 422, "unsupported_capability");
265
265
  shape(value, ["requestId", "expectedGeneration", "expectedRevision", "command", ...fields[value.command]], "execution control");
@@ -420,6 +420,13 @@ function finiteJson(value, depth = 0, seen = new Set()) {
420
420
  function contextUsage(value) { return value === null || object(value) && finiteJson(value); }
421
421
  function source(value) { if (!object(value) || !opaque(value.agentId) || value.parentAgentId !== undefined && !opaque(value.parentAgentId) || value.parentToolCallId !== undefined && (!opaque(value.parentToolCallId) || !opaque(value.parentAgentId)))
422
422
  responseProblem("Invalid execution source."); }
423
+ function validateChildAgent(agent) {
424
+ source(agent);
425
+ if (!object(agent) || !["queued", "running", "waiting_for_input", "succeeded", "failed", "cancelled", "unknown"].includes(String(agent.state))
426
+ || [agent.stopConfirmed, agent.promptTruncated, agent.responseTruncated].some(flag => flag !== undefined && typeof flag !== "boolean")
427
+ || [agent.prompt, agent.response].some(text => text !== undefined && (typeof text !== "string" || text.length > 65536 && [...text].length > 65536)))
428
+ responseProblem("Invalid child agent observation.");
429
+ }
423
430
  export function validateAgentPendingDecision(value) {
424
431
  if (!object(value) || !opaque(value.id) || !decimal(value.revision) || !["approval", "question"].includes(String(value.kind)) || !["continue_run", "next_turn"].includes(String(value.delivery)))
425
432
  responseProblem("Invalid pending decision.");
@@ -509,11 +516,8 @@ export function validateAgentRunSnapshot(value) {
509
516
  }
510
517
  if (value.agents !== undefined) {
511
518
  array(value.agents, 1024, "agent inventory");
512
- for (const agent of value.agents) {
513
- source(agent);
514
- if (!object(agent) || !["queued", "running", "waiting_for_input", "succeeded", "failed", "cancelled", "unknown"].includes(String(agent.state)) || agent.stopConfirmed !== undefined && typeof agent.stopConfirmed !== "boolean")
515
- responseProblem("Invalid retained child agent state.");
516
- }
519
+ for (const agent of value.agents)
520
+ validateChildAgent(agent);
517
521
  }
518
522
  if (Buffer.byteLength(JSON.stringify(value)) > AGENT_COMMAND_MAX_BYTES)
519
523
  responseProblem("Snapshot byte allowance exceeded.");
@@ -544,6 +548,8 @@ export function validateAgentEvent(value) {
544
548
  responseProblem("Context events require nullable JSON observation data.");
545
549
  else if (value.type === "extension" && (!bounded(data.namespace, 256) || data.required === true))
546
550
  responseProblem("Extensions cannot carry required protocol semantics.");
551
+ if (value.type === "agent.updated" && data.agent !== undefined)
552
+ validateChildAgent(data.agent);
547
553
  if (data.decision !== undefined)
548
554
  validateAgentPendingDecision(data.decision);
549
555
  if (data.response !== undefined) {
package/dist/agent.d.ts CHANGED
@@ -22,6 +22,7 @@ export declare const AGENT_CAPABILITIES: {
22
22
  readonly park: "runs.park";
23
23
  readonly barrier: "runs.barrier";
24
24
  readonly reconcile: "runs.reconcile";
25
+ readonly retire: "runs.retire";
25
26
  readonly liveConfigure: "runs.live-configure";
26
27
  readonly predictions: "predictions";
27
28
  readonly connectionUsage: "connections.usage";
@@ -322,6 +323,11 @@ export type AgentRunSnapshot = {
322
323
  agents?: Array<AgentSource & {
323
324
  state: AgentRunState;
324
325
  stopConfirmed?: boolean;
326
+ /** Native assignment and final answer, when the provider can attribute them to this child. */
327
+ prompt?: string;
328
+ response?: string;
329
+ promptTruncated?: boolean;
330
+ responseTruncated?: boolean;
325
331
  }>;
326
332
  selection?: {
327
333
  requested: {
@@ -412,6 +418,10 @@ export type AgentRunControlInput = {
412
418
  command: "reconcile";
413
419
  stopped: true;
414
420
  evidence?: string;
421
+ }
422
+ /** Requires provider-owned exit evidence. Applied retirement preserves uncertain tool outcomes. */
423
+ | {
424
+ command: "retire";
415
425
  } | {
416
426
  command: "liveConfigure";
417
427
  mcp: AgentMcpSelection;
package/dist/agent.js CHANGED
@@ -7,7 +7,7 @@ export const AGENT_CAPABILITIES = {
7
7
  noNativeTools: "native-tools.none", skills: "skills.catalog", exclusiveSkills: "skills.exclusive-selection",
8
8
  coreMcp: "mcp.core", externalMcp: "mcp.external", modelChange: "model.change-on-resume",
9
9
  nextTurnDecisions: "decisions.next-turn", nativeSubagents: "subagents.native", park: "runs.park",
10
- barrier: "runs.barrier", reconcile: "runs.reconcile", liveConfigure: "runs.live-configure",
10
+ barrier: "runs.barrier", reconcile: "runs.reconcile", retire: "runs.retire", liveConfigure: "runs.live-configure",
11
11
  predictions: "predictions", connectionUsage: "connections.usage",
12
12
  approvalMode: "configuration.approval-mode",
13
13
  mcpPolicy: "mcp.policy-update", consumerWorkflow: "workflow.consumer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hosty-sdk/app",
3
- "version": "0.50.0",
3
+ "version": "0.52.0",
4
4
  "description": "Hosty app auth: session state machine, recovery bridge, Core revalidation, and the embedder responder.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -1008,6 +1008,33 @@
1008
1008
  ],
1009
1009
  "additionalProperties": false
1010
1010
  },
1011
+ {
1012
+ "type": "object",
1013
+ "properties": {
1014
+ "requestId": {
1015
+ "type": "string",
1016
+ "format": "uuid"
1017
+ },
1018
+ "expectedGeneration": {
1019
+ "type": "string",
1020
+ "format": "uuid"
1021
+ },
1022
+ "expectedRevision": {
1023
+ "type": "string",
1024
+ "pattern": "^[1-9][0-9]{0,39}$"
1025
+ },
1026
+ "command": {
1027
+ "const": "retire"
1028
+ }
1029
+ },
1030
+ "required": [
1031
+ "requestId",
1032
+ "expectedGeneration",
1033
+ "expectedRevision",
1034
+ "command"
1035
+ ],
1036
+ "additionalProperties": false
1037
+ },
1011
1038
  {
1012
1039
  "type": "object",
1013
1040
  "properties": {
@@ -1124,6 +1151,56 @@
1124
1151
  ],
1125
1152
  "additionalProperties": false
1126
1153
  },
1154
+ "ChildAgent": {
1155
+ "type": "object",
1156
+ "properties": {
1157
+ "agentId": {
1158
+ "type": "string",
1159
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1160
+ },
1161
+ "parentAgentId": {
1162
+ "type": "string",
1163
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1164
+ },
1165
+ "parentToolCallId": {
1166
+ "type": "string",
1167
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1168
+ },
1169
+ "state": {
1170
+ "enum": [
1171
+ "queued",
1172
+ "running",
1173
+ "waiting_for_input",
1174
+ "succeeded",
1175
+ "failed",
1176
+ "cancelled",
1177
+ "unknown"
1178
+ ]
1179
+ },
1180
+ "stopConfirmed": {
1181
+ "type": "boolean"
1182
+ },
1183
+ "prompt": {
1184
+ "type": "string",
1185
+ "maxLength": 65536
1186
+ },
1187
+ "response": {
1188
+ "type": "string",
1189
+ "maxLength": 65536
1190
+ },
1191
+ "promptTruncated": {
1192
+ "type": "boolean"
1193
+ },
1194
+ "responseTruncated": {
1195
+ "type": "boolean"
1196
+ }
1197
+ },
1198
+ "required": [
1199
+ "agentId",
1200
+ "state"
1201
+ ],
1202
+ "additionalProperties": true
1203
+ },
1127
1204
  "PendingDecision": {
1128
1205
  "type": "object",
1129
1206
  "properties": {
@@ -1502,40 +1579,7 @@
1502
1579
  "type": "array",
1503
1580
  "maxItems": 1024,
1504
1581
  "items": {
1505
- "type": "object",
1506
- "properties": {
1507
- "agentId": {
1508
- "type": "string",
1509
- "pattern": "^[A-Za-z0-9_-]{1,256}$"
1510
- },
1511
- "parentAgentId": {
1512
- "type": "string",
1513
- "pattern": "^[A-Za-z0-9_-]{1,256}$"
1514
- },
1515
- "parentToolCallId": {
1516
- "type": "string",
1517
- "pattern": "^[A-Za-z0-9_-]{1,256}$"
1518
- },
1519
- "state": {
1520
- "enum": [
1521
- "queued",
1522
- "running",
1523
- "waiting_for_input",
1524
- "succeeded",
1525
- "failed",
1526
- "cancelled",
1527
- "unknown"
1528
- ]
1529
- },
1530
- "stopConfirmed": {
1531
- "type": "boolean"
1532
- }
1533
- },
1534
- "required": [
1535
- "agentId",
1536
- "state"
1537
- ],
1538
- "additionalProperties": true
1582
+ "$ref": "#/$defs/ChildAgent"
1539
1583
  }
1540
1584
  },
1541
1585
  "selection": {
@@ -3155,6 +3199,12 @@
3155
3199
  "properties": {
3156
3200
  "data": {
3157
3201
  "type": "object",
3202
+ "properties": {
3203
+ "agent": {
3204
+ "$ref": "#/$defs/ChildAgent"
3205
+ }
3206
+ },
3207
+ "required": [],
3158
3208
  "additionalProperties": true
3159
3209
  }
3160
3210
  }
@@ -84,6 +84,16 @@
84
84
  "acknowledgedSequence": "8"
85
85
  }
86
86
  },
87
+ {
88
+ "method": "POST",
89
+ "path": "/runs/22222222-2222-4222-8222-222222222222/controls",
90
+ "body": {
91
+ "requestId": "44444444-4444-4444-8444-444444444444",
92
+ "expectedGeneration": "33333333-3333-4333-8333-333333333333",
93
+ "expectedRevision": "1",
94
+ "command": "retire"
95
+ }
96
+ },
87
97
  {
88
98
  "method": "PUT",
89
99
  "path": "/attachments/44444444-4444-4444-8444-444444444444/chunks/0",
@@ -161,6 +171,17 @@
161
171
  "output": "fabricated"
162
172
  }
163
173
  }
174
+ },
175
+ {
176
+ "method": "POST",
177
+ "path": "/runs/22222222-2222-4222-8222-222222222222/controls",
178
+ "body": {
179
+ "requestId": "44444444-4444-4444-8444-444444444444",
180
+ "expectedGeneration": "33333333-3333-4333-8333-333333333333",
181
+ "expectedRevision": "1",
182
+ "command": "retire",
183
+ "stopped": true
184
+ }
164
185
  }
165
186
  ]
166
187
  }
@@ -2945,7 +2945,7 @@
2945
2945
  }
2946
2946
  }
2947
2947
  },
2948
- "description": "Optional controls require their advertised capabilities. Reconcile input is an attestation, never proof of actual native exit."
2948
+ "description": "Optional controls require their advertised capabilities. Reconcile input is an attestation, never proof of actual native exit. Retirement requires provider-owned evidence of native process exit. Its applied receipt records retirement of the exact run and preserves unresolved tool outcomes."
2949
2949
  }
2950
2950
  },
2951
2951
  "/runs/{runId}/controls/{requestId}": {
@@ -4117,6 +4117,33 @@
4117
4117
  ],
4118
4118
  "additionalProperties": false
4119
4119
  },
4120
+ {
4121
+ "type": "object",
4122
+ "properties": {
4123
+ "requestId": {
4124
+ "type": "string",
4125
+ "format": "uuid"
4126
+ },
4127
+ "expectedGeneration": {
4128
+ "type": "string",
4129
+ "format": "uuid"
4130
+ },
4131
+ "expectedRevision": {
4132
+ "type": "string",
4133
+ "pattern": "^[1-9][0-9]{0,39}$"
4134
+ },
4135
+ "command": {
4136
+ "const": "retire"
4137
+ }
4138
+ },
4139
+ "required": [
4140
+ "requestId",
4141
+ "expectedGeneration",
4142
+ "expectedRevision",
4143
+ "command"
4144
+ ],
4145
+ "additionalProperties": false
4146
+ },
4120
4147
  {
4121
4148
  "type": "object",
4122
4149
  "properties": {
@@ -4233,6 +4260,56 @@
4233
4260
  ],
4234
4261
  "additionalProperties": false
4235
4262
  },
4263
+ "ChildAgent": {
4264
+ "type": "object",
4265
+ "properties": {
4266
+ "agentId": {
4267
+ "type": "string",
4268
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
4269
+ },
4270
+ "parentAgentId": {
4271
+ "type": "string",
4272
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
4273
+ },
4274
+ "parentToolCallId": {
4275
+ "type": "string",
4276
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
4277
+ },
4278
+ "state": {
4279
+ "enum": [
4280
+ "queued",
4281
+ "running",
4282
+ "waiting_for_input",
4283
+ "succeeded",
4284
+ "failed",
4285
+ "cancelled",
4286
+ "unknown"
4287
+ ]
4288
+ },
4289
+ "stopConfirmed": {
4290
+ "type": "boolean"
4291
+ },
4292
+ "prompt": {
4293
+ "type": "string",
4294
+ "maxLength": 65536
4295
+ },
4296
+ "response": {
4297
+ "type": "string",
4298
+ "maxLength": 65536
4299
+ },
4300
+ "promptTruncated": {
4301
+ "type": "boolean"
4302
+ },
4303
+ "responseTruncated": {
4304
+ "type": "boolean"
4305
+ }
4306
+ },
4307
+ "required": [
4308
+ "agentId",
4309
+ "state"
4310
+ ],
4311
+ "additionalProperties": true
4312
+ },
4236
4313
  "PendingDecision": {
4237
4314
  "type": "object",
4238
4315
  "properties": {
@@ -4611,40 +4688,7 @@
4611
4688
  "type": "array",
4612
4689
  "maxItems": 1024,
4613
4690
  "items": {
4614
- "type": "object",
4615
- "properties": {
4616
- "agentId": {
4617
- "type": "string",
4618
- "pattern": "^[A-Za-z0-9_-]{1,256}$"
4619
- },
4620
- "parentAgentId": {
4621
- "type": "string",
4622
- "pattern": "^[A-Za-z0-9_-]{1,256}$"
4623
- },
4624
- "parentToolCallId": {
4625
- "type": "string",
4626
- "pattern": "^[A-Za-z0-9_-]{1,256}$"
4627
- },
4628
- "state": {
4629
- "enum": [
4630
- "queued",
4631
- "running",
4632
- "waiting_for_input",
4633
- "succeeded",
4634
- "failed",
4635
- "cancelled",
4636
- "unknown"
4637
- ]
4638
- },
4639
- "stopConfirmed": {
4640
- "type": "boolean"
4641
- }
4642
- },
4643
- "required": [
4644
- "agentId",
4645
- "state"
4646
- ],
4647
- "additionalProperties": true
4691
+ "$ref": "#/components/schemas/ChildAgent"
4648
4692
  }
4649
4693
  },
4650
4694
  "selection": {
@@ -6264,6 +6308,12 @@
6264
6308
  "properties": {
6265
6309
  "data": {
6266
6310
  "type": "object",
6311
+ "properties": {
6312
+ "agent": {
6313
+ "$ref": "#/components/schemas/ChildAgent"
6314
+ }
6315
+ },
6316
+ "required": [],
6267
6317
  "additionalProperties": true
6268
6318
  }
6269
6319
  }