@sixb/core 0.2.3 → 0.2.4

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.
Files changed (122) hide show
  1. package/dist/actions/index.js +12 -12
  2. package/dist/agents/cancel.d.ts +1 -1
  3. package/dist/agents/cancel.d.ts.map +1 -1
  4. package/dist/agents/child-question.d.ts +35 -2
  5. package/dist/agents/child-question.d.ts.map +1 -1
  6. package/dist/agents/execution.d.ts +1 -1
  7. package/dist/agents/ids.d.ts +2 -0
  8. package/dist/agents/ids.d.ts.map +1 -1
  9. package/dist/agents/index.d.ts +3 -3
  10. package/dist/agents/index.d.ts.map +1 -1
  11. package/dist/agents/index.js +23 -15
  12. package/dist/agents/index.js.map +1 -1
  13. package/dist/agents/model-loop.d.ts.map +1 -1
  14. package/dist/agents/run-session-children.d.ts +9 -0
  15. package/dist/agents/run-session-children.d.ts.map +1 -1
  16. package/dist/agents/run-session-http.d.ts.map +1 -1
  17. package/dist/agents/run-session-serve.d.ts.map +1 -1
  18. package/dist/agents/tool-files.d.ts +1 -1
  19. package/dist/agents/tool-files.d.ts.map +1 -1
  20. package/dist/agents/tool-input-coercion.d.ts +20 -0
  21. package/dist/agents/tool-input-coercion.d.ts.map +1 -0
  22. package/dist/agents/validation.d.ts +1 -1
  23. package/dist/agents/validation.d.ts.map +1 -1
  24. package/dist/artifacts/frames/index.js +1 -1
  25. package/dist/artifacts/frames/protocol.d.ts +53 -2
  26. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  27. package/dist/artifacts/frames/runtime.d.ts +8 -1
  28. package/dist/artifacts/frames/runtime.d.ts.map +1 -1
  29. package/dist/artifacts/index.d.ts +1 -1
  30. package/dist/artifacts/index.d.ts.map +1 -1
  31. package/dist/artifacts/index.js +27 -1
  32. package/dist/artifacts/index.js.map +3 -3
  33. package/dist/artifacts/live/server.js +7 -7
  34. package/dist/artifacts/publish/index.js +6 -6
  35. package/dist/bootstrap/index.js +17 -17
  36. package/dist/{chunk-k66rp2hr.js → chunk-2bn6813a.js} +1 -1
  37. package/dist/{chunk-m7b9q5dk.js → chunk-3z1vxzcm.js} +1 -1
  38. package/dist/{chunk-qafng88v.js → chunk-6ef4esq4.js} +1 -1
  39. package/dist/{chunk-38yvdqzd.js → chunk-7kpqntgw.js} +1 -1
  40. package/dist/{chunk-tqa68kj7.js → chunk-8bns0y68.js} +2 -2
  41. package/dist/chunk-8t2ynwg0.js.map +1 -1
  42. package/dist/chunk-az95tsh3.js.map +2 -2
  43. package/dist/{chunk-4j0sagwv.js → chunk-evj5jxz3.js} +1 -1
  44. package/dist/{chunk-z0t4p2sk.js → chunk-gxwy4c3s.js} +41 -11
  45. package/dist/{chunk-z0t4p2sk.js.map → chunk-gxwy4c3s.js.map} +8 -8
  46. package/dist/{chunk-qds484t8.js → chunk-hvbvq7p4.js} +202 -12
  47. package/dist/chunk-hvbvq7p4.js.map +18 -0
  48. package/dist/{chunk-26qet7wh.js → chunk-msyevpp3.js} +1 -1
  49. package/dist/chunk-n4zzaf6q.js.map +1 -1
  50. package/dist/{chunk-s5n9617r.js → chunk-p8pgnq8d.js} +3 -3
  51. package/dist/{chunk-kv0kvknv.js → chunk-r9rtavg9.js} +2 -2
  52. package/dist/{chunk-bkmnd7zq.js → chunk-rsrc7vtw.js} +9 -9
  53. package/dist/{chunk-8p7bze4c.js → chunk-rsxb14an.js} +1 -1
  54. package/dist/{chunk-e9w4mgdh.js → chunk-rtm1jq00.js} +162 -17
  55. package/dist/{chunk-e9w4mgdh.js.map → chunk-rtm1jq00.js.map} +8 -7
  56. package/dist/{chunk-7z5rkf0m.js → chunk-t0s7b3d1.js} +4 -3
  57. package/dist/{chunk-7z5rkf0m.js.map → chunk-t0s7b3d1.js.map} +3 -3
  58. package/dist/{chunk-hkaa807g.js → chunk-td26wjr5.js} +1 -1
  59. package/dist/{chunk-6gtxshcc.js → chunk-vepea5c3.js} +3 -3
  60. package/dist/{chunk-2by73sm2.js → chunk-w1wq7gfr.js} +1 -1
  61. package/dist/{chunk-w9s23r24.js → chunk-yy914zfr.js} +3 -3
  62. package/dist/execution/agent.js +12 -12
  63. package/dist/execution/primitive.js +12 -12
  64. package/dist/execution/request.js +12 -12
  65. package/dist/index.js +19 -19
  66. package/dist/materializer/index.js +3 -3
  67. package/dist/models/execution/index.js +3 -3
  68. package/dist/models/language-model.d.ts +6 -0
  69. package/dist/models/language-model.d.ts.map +1 -1
  70. package/dist/models/tools.d.ts +2 -0
  71. package/dist/models/tools.d.ts.map +1 -1
  72. package/dist/objects/index.js +12 -12
  73. package/dist/objects/query/index.js +3 -3
  74. package/dist/pipelines/index.js +3 -3
  75. package/dist/projections/internal.js +2 -2
  76. package/dist/runtime/internal.js +7 -7
  77. package/dist/shares/internal.js +2 -2
  78. package/dist/storage/agents/provider.js +1 -1
  79. package/dist/storage/agents/types.d.ts +1 -1
  80. package/dist/storage/agents/types.d.ts.map +1 -1
  81. package/dist/storage/index.js +2 -2
  82. package/dist/syncs/index.js +4 -4
  83. package/dist/testing/index.js +19 -19
  84. package/dist/webhooks/internal.js +2 -2
  85. package/dist/workflows/index.js +15 -15
  86. package/package.json +1 -1
  87. package/src/agents/approval-outcome.ts +2 -2
  88. package/src/agents/cancel.ts +2 -2
  89. package/src/agents/child-question.ts +76 -8
  90. package/src/agents/execution.ts +1 -1
  91. package/src/agents/ids.ts +4 -1
  92. package/src/agents/index.ts +9 -2
  93. package/src/agents/model-loop.ts +3 -1
  94. package/src/agents/run-session-children.ts +33 -0
  95. package/src/agents/run-session-http.ts +1 -0
  96. package/src/agents/run-session-serve.ts +1 -0
  97. package/src/agents/tool-files.ts +1 -1
  98. package/src/agents/tool-input-coercion.ts +140 -0
  99. package/src/agents/validation.ts +11 -3
  100. package/src/artifacts/frames/protocol.ts +84 -2
  101. package/src/artifacts/frames/runtime.ts +296 -13
  102. package/src/artifacts/index.ts +3 -0
  103. package/src/http/api-routes.ts +1 -1
  104. package/src/models/language-model.ts +6 -0
  105. package/src/models/tools.ts +2 -0
  106. package/src/storage/agents/types.ts +1 -1
  107. package/dist/chunk-qds484t8.js.map +0 -18
  108. /package/dist/{chunk-k66rp2hr.js.map → chunk-2bn6813a.js.map} +0 -0
  109. /package/dist/{chunk-m7b9q5dk.js.map → chunk-3z1vxzcm.js.map} +0 -0
  110. /package/dist/{chunk-qafng88v.js.map → chunk-6ef4esq4.js.map} +0 -0
  111. /package/dist/{chunk-38yvdqzd.js.map → chunk-7kpqntgw.js.map} +0 -0
  112. /package/dist/{chunk-tqa68kj7.js.map → chunk-8bns0y68.js.map} +0 -0
  113. /package/dist/{chunk-4j0sagwv.js.map → chunk-evj5jxz3.js.map} +0 -0
  114. /package/dist/{chunk-26qet7wh.js.map → chunk-msyevpp3.js.map} +0 -0
  115. /package/dist/{chunk-s5n9617r.js.map → chunk-p8pgnq8d.js.map} +0 -0
  116. /package/dist/{chunk-kv0kvknv.js.map → chunk-r9rtavg9.js.map} +0 -0
  117. /package/dist/{chunk-bkmnd7zq.js.map → chunk-rsrc7vtw.js.map} +0 -0
  118. /package/dist/{chunk-8p7bze4c.js.map → chunk-rsxb14an.js.map} +0 -0
  119. /package/dist/{chunk-hkaa807g.js.map → chunk-td26wjr5.js.map} +0 -0
  120. /package/dist/{chunk-6gtxshcc.js.map → chunk-vepea5c3.js.map} +0 -0
  121. /package/dist/{chunk-2by73sm2.js.map → chunk-w1wq7gfr.js.map} +0 -0
  122. /package/dist/{chunk-w9s23r24.js.map → chunk-yy914zfr.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  defineSync2,
4
4
  resolveSyncConnectorSources2,
5
5
  isSyncDefinition2
6
- } from "../chunk-hkaa807g.js";
6
+ } from "../chunk-td26wjr5.js";
7
7
  import"../chunk-t24yktqr.js";
8
8
  import"../chunk-b9qfh2ya.js";
9
9
  import"../chunk-yv8hv4wq.js";
@@ -11,14 +11,14 @@ import {
11
11
  SyncValidationError2,
12
12
  SyncRunDispatcher2,
13
13
  requestSyncRun2
14
- } from "../chunk-m7b9q5dk.js";
14
+ } from "../chunk-3z1vxzcm.js";
15
15
  import"../chunk-wa05txmk.js";
16
16
  import"../chunk-3hzhcfsv.js";
17
17
  import"../chunk-8tqnsx3q.js";
18
18
  import"../chunk-czct88ht.js";
19
19
  import"../chunk-d9xbwh3h.js";
20
20
  import"../chunk-wx7smkn2.js";
21
- import"../chunk-2by73sm2.js";
21
+ import"../chunk-w1wq7gfr.js";
22
22
  import"../chunk-22d3qg4x.js";
23
23
  import"../chunk-5rqqp8cr.js";
24
24
  import"../chunk-186k5yz3.js";
@@ -36,7 +36,7 @@ import"../chunk-e0hnbb1m.js";
36
36
  import"../chunk-x0v3jd47.js";
37
37
  import"../chunk-g2ph4873.js";
38
38
  import"../chunk-mbsbxarb.js";
39
- import"../chunk-7z5rkf0m.js";
39
+ import"../chunk-t0s7b3d1.js";
40
40
  import"../chunk-zeykm8my.js";
41
41
  import"../chunk-xtztwpkh.js";
42
42
  import"../chunk-c4nrycdy.js";
@@ -50,7 +50,7 @@ import"../chunk-az95tsh3.js";
50
50
  import"../chunk-qttqe1ah.js";
51
51
  import {
52
52
  AgentStorageError2
53
- } from "../chunk-7z5rkf0m.js";
53
+ } from "../chunk-t0s7b3d1.js";
54
54
  import"../chunk-zeykm8my.js";
55
55
  import {
56
56
  aiLimitCalendarMonth2
@@ -90,7 +90,7 @@ import {
90
90
  WorkflowInterventionError2,
91
91
  InMemoryStorage2,
92
92
  migrateStorage2
93
- } from "../chunk-2by73sm2.js";
93
+ } from "../chunk-w1wq7gfr.js";
94
94
  import"../chunk-e0hnbb1m.js";
95
95
  import"../chunk-s7xqfxs9.js";
96
96
  import {
@@ -113,19 +113,19 @@ import {
113
113
  existsObjects2,
114
114
  facetObjects2,
115
115
  executeObjectQueryLinks2
116
- } from "../chunk-8p7bze4c.js";
117
- import"../chunk-26qet7wh.js";
116
+ } from "../chunk-rsxb14an.js";
117
+ import"../chunk-msyevpp3.js";
118
118
  import"../chunk-bz5bnjjt.js";
119
119
  import"../chunk-m2jerfef.js";
120
- import"../chunk-w9s23r24.js";
120
+ import"../chunk-yy914zfr.js";
121
121
  import"../chunk-a6fjkcne.js";
122
- import"../chunk-qds484t8.js";
122
+ import"../chunk-hvbvq7p4.js";
123
123
  import {
124
124
  bindModelExecutionAttempt,
125
125
  isBoundSixb
126
- } from "../chunk-e9w4mgdh.js";
126
+ } from "../chunk-rtm1jq00.js";
127
127
  import"../chunk-czct88ht.js";
128
- import"../chunk-6gtxshcc.js";
128
+ import"../chunk-vepea5c3.js";
129
129
  import"../chunk-48c1z8nj.js";
130
130
  import"../chunk-5qqmndhm.js";
131
131
  import"../chunk-sgx82nnt.js";
@@ -141,13 +141,13 @@ import {
141
141
  writeDataset2
142
142
  } from "../chunk-ppxf7gw2.js";
143
143
  import"../chunk-191jz8a6.js";
144
- import"../chunk-k66rp2hr.js";
144
+ import"../chunk-2bn6813a.js";
145
145
  import"../chunk-q9nkpr8k.js";
146
146
  import {
147
147
  ProjectionRegistry2,
148
148
  createLinkScopeFingerprint2,
149
149
  createOntologyMaterializer2
150
- } from "../chunk-4j0sagwv.js";
150
+ } from "../chunk-evj5jxz3.js";
151
151
  import"../chunk-1vg43g9q.js";
152
152
  import"../chunk-m427qgq0.js";
153
153
  import {
@@ -164,28 +164,28 @@ import {
164
164
  InMemoryQueues2
165
165
  } from "../chunk-9nsjjd44.js";
166
166
  import"../chunk-r2psmn42.js";
167
- import"../chunk-hkaa807g.js";
167
+ import"../chunk-td26wjr5.js";
168
168
  import"../chunk-fe6r7yhg.js";
169
169
  import {
170
170
  projectAgentThreadModelContext2
171
- } from "../chunk-z0t4p2sk.js";
172
- import"../chunk-38yvdqzd.js";
171
+ } from "../chunk-gxwy4c3s.js";
172
+ import"../chunk-7kpqntgw.js";
173
173
  import"../chunk-de5sfbc3.js";
174
174
  import"../chunk-bc3y6gff.js";
175
175
  import"../chunk-8t2ynwg0.js";
176
176
  import {
177
177
  workflowAgentStepActorId2
178
- } from "../chunk-s5n9617r.js";
178
+ } from "../chunk-p8pgnq8d.js";
179
179
  import"../chunk-c69nj7se.js";
180
180
  import"../chunk-whbwf3np.js";
181
- import"../chunk-kv0kvknv.js";
181
+ import"../chunk-r9rtavg9.js";
182
182
  import {
183
183
  SixbHost2
184
- } from "../chunk-bkmnd7zq.js";
184
+ } from "../chunk-rsrc7vtw.js";
185
185
  import {
186
186
  findDatasetIngestRuntime2,
187
187
  getDatasetIngestRuntime2
188
- } from "../chunk-tqa68kj7.js";
188
+ } from "../chunk-8bns0y68.js";
189
189
  import"../chunk-sysnvjce.js";
190
190
  import"../chunk-3ba89vm7.js";
191
191
  import {
@@ -196,13 +196,13 @@ import {
196
196
  DatasetSequenceConflictError2
197
197
  } from "../chunk-dmnd9ea6.js";
198
198
  import"../chunk-7qe46788.js";
199
- import"../chunk-m7b9q5dk.js";
199
+ import"../chunk-3z1vxzcm.js";
200
200
  import"../chunk-n68vz95m.js";
201
201
  import {
202
202
  SandboxNotRunningError2
203
203
  } from "../chunk-rtdrm592.js";
204
204
  import"../chunk-3723kgba.js";
205
- import"../chunk-qafng88v.js";
205
+ import"../chunk-6ef4esq4.js";
206
206
  import"../chunk-3hzhcfsv.js";
207
207
  import {
208
208
  restoreTrustedPrimitiveExecutionScope
@@ -25,7 +25,7 @@ import"../chunk-zrvhsq7f.js";
25
25
  import"../chunk-5grk14e5.js";
26
26
  import"../chunk-az95tsh3.js";
27
27
  import"../chunk-qttqe1ah.js";
28
- import"../chunk-7z5rkf0m.js";
28
+ import"../chunk-t0s7b3d1.js";
29
29
  import"../chunk-zeykm8my.js";
30
30
  import"../chunk-c4nrycdy.js";
31
31
  import"../chunk-pk539cwv.js";
@@ -44,7 +44,7 @@ import"../chunk-cswhawa2.js";
44
44
  import {
45
45
  WEBHOOK_RUN_LEASE_MS2,
46
46
  canRetryWebhookRun2
47
- } from "../chunk-2by73sm2.js";
47
+ } from "../chunk-w1wq7gfr.js";
48
48
  import"../chunk-e0hnbb1m.js";
49
49
  import"../chunk-s7xqfxs9.js";
50
50
  import"../chunk-3sgvd10b.js";
@@ -8,15 +8,15 @@ import {
8
8
  defineWorkflow2,
9
9
  createWorkflowNodeFailure2,
10
10
  unwrapWorkflowNodeFailure2
11
- } from "../chunk-s5n9617r.js";
11
+ } from "../chunk-p8pgnq8d.js";
12
12
  import"../chunk-t24yktqr.js";
13
13
  import"../chunk-b9qfh2ya.js";
14
14
  import"../chunk-yv8hv4wq.js";
15
- import"../chunk-z0t4p2sk.js";
15
+ import"../chunk-gxwy4c3s.js";
16
16
  import"../chunk-de5sfbc3.js";
17
17
  import"../chunk-bc3y6gff.js";
18
18
  import"../chunk-8t2ynwg0.js";
19
- import"../chunk-38yvdqzd.js";
19
+ import"../chunk-7kpqntgw.js";
20
20
  import {
21
21
  WorkflowDefinitionError2,
22
22
  WorkflowValidationError2,
@@ -46,18 +46,18 @@ import {
46
46
  snapshotWorkflowActionInput2,
47
47
  WorkflowRunDispatcher2,
48
48
  requestWorkflowRun2
49
- } from "../chunk-e9w4mgdh.js";
50
- import"../chunk-m7b9q5dk.js";
49
+ } from "../chunk-rtm1jq00.js";
50
+ import"../chunk-3z1vxzcm.js";
51
51
  import"../chunk-wa05txmk.js";
52
52
  import"../chunk-n68vz95m.js";
53
- import"../chunk-6gtxshcc.js";
53
+ import"../chunk-vepea5c3.js";
54
54
  import"../chunk-rtdrm592.js";
55
- import"../chunk-4j0sagwv.js";
55
+ import"../chunk-evj5jxz3.js";
56
56
  import"../chunk-3723kgba.js";
57
- import"../chunk-k66rp2hr.js";
57
+ import"../chunk-2bn6813a.js";
58
58
  import"../chunk-q9nkpr8k.js";
59
59
  import"../chunk-5qqmndhm.js";
60
- import"../chunk-qafng88v.js";
60
+ import"../chunk-6ef4esq4.js";
61
61
  import"../chunk-3hzhcfsv.js";
62
62
  import"../chunk-8tqnsx3q.js";
63
63
  import"../chunk-1vg43g9q.js";
@@ -70,10 +70,10 @@ import"../chunk-ppxf7gw2.js";
70
70
  import"../chunk-w3t94hm6.js";
71
71
  import"../chunk-wx7smkn2.js";
72
72
  import"../chunk-m427qgq0.js";
73
- import"../chunk-w9s23r24.js";
74
- import"../chunk-26qet7wh.js";
75
- import"../chunk-8p7bze4c.js";
76
- import"../chunk-2by73sm2.js";
73
+ import"../chunk-yy914zfr.js";
74
+ import"../chunk-msyevpp3.js";
75
+ import"../chunk-rsxb14an.js";
76
+ import"../chunk-w1wq7gfr.js";
77
77
  import"../chunk-22d3qg4x.js";
78
78
  import"../chunk-5rqqp8cr.js";
79
79
  import"../chunk-186k5yz3.js";
@@ -91,7 +91,7 @@ import"../chunk-e0hnbb1m.js";
91
91
  import"../chunk-x0v3jd47.js";
92
92
  import"../chunk-g2ph4873.js";
93
93
  import"../chunk-mbsbxarb.js";
94
- import"../chunk-7z5rkf0m.js";
94
+ import"../chunk-t0s7b3d1.js";
95
95
  import"../chunk-zeykm8my.js";
96
96
  import"../chunk-xtztwpkh.js";
97
97
  import"../chunk-c4nrycdy.js";
@@ -117,7 +117,7 @@ import"../chunk-sgx82nnt.js";
117
117
  import"../chunk-48c1z8nj.js";
118
118
  import"../chunk-mvz89age.js";
119
119
  import"../chunk-6eqsgvxk.js";
120
- import"../chunk-qds484t8.js";
120
+ import"../chunk-hvbvq7p4.js";
121
121
  import"../chunk-a3faa34j.js";
122
122
  import"../chunk-wkv3h3q7.js";
123
123
  import"../chunk-a6fjkcne.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/core",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "The ontology-first runtime for Sixb — objects, links, telemetry, actions, and provider contracts",
5
5
  "keywords": [
6
6
  "sixb",
@@ -14,8 +14,8 @@ export function approvalOutcomeInstruction(part: AgentApprovalOutcomePart): stri
14
14
  ? text
15
15
  : `Your sub-agent '${part.caller.key}' made this request. ${text} ${
16
16
  part.caller.continues
17
- ? "It continues with this outcome, and wait_agent with its run id returns its answer."
18
- : "It does not continue: wait_agent with its run id returns how it ended, and you can spawn it again with a new key if its work is still needed."
17
+ ? "It continues with this outcome, and wait with its key returns its answer."
18
+ : "It does not continue: wait with its key returns how it ended, and you can spawn it again with a new key if its work is still needed."
19
19
  }`
20
20
  return `<sixb_approval id="${part.approvalId}" status="${part.status}">${body}</sixb_approval>`
21
21
  }
@@ -88,7 +88,7 @@ export async function requestAgentRunCancel(
88
88
  * attached its cancel subscription yet.
89
89
  */
90
90
  export async function cancelQueuedRun(
91
- runtime: SixbRuntimeContext,
91
+ runtime: Pick<SixbRuntimeContext, "projectId" | "broker">,
92
92
  storage: AgentStorage,
93
93
  run: AgentRunRecord
94
94
  ): Promise<
@@ -113,7 +113,7 @@ export async function cancelQueuedRun(
113
113
 
114
114
  /** The run is cancelled once stored; its stream learns it best-effort. */
115
115
  async function publishQueuedRunCancellation(
116
- runtime: SixbRuntimeContext,
116
+ runtime: Pick<SixbRuntimeContext, "broker">,
117
117
  run: AgentRunRecord
118
118
  ): Promise<void> {
119
119
  try {
@@ -1,4 +1,4 @@
1
- import { isJsonObject } from "../json"
1
+ import { isJsonObject, type JsonValue } from "../json"
2
2
  import type { AgentRunRecord } from "../storage/agents"
3
3
  import type { AgentMessage } from "./message"
4
4
 
@@ -8,6 +8,73 @@ export interface AgentChildQuestion {
8
8
  readonly text: string
9
9
  }
10
10
 
11
+ /** One question of an `ask` call: what it asks, and the answers it offers. */
12
+ export interface AgentQuestion {
13
+ readonly question: string
14
+ /** At most four; a typed answer is always possible beside them. */
15
+ readonly choices?: readonly string[]
16
+ /** Several of the choices may be picked. */
17
+ readonly multiple?: boolean
18
+ }
19
+
20
+ /** The most questions one `ask` holds, and the most choices one question offers. */
21
+ export const AGENT_QUESTION_LIMITS = { questions: 4, choices: 4 } as const
22
+
23
+ /**
24
+ * An `ask` call's questions as one text: what a sub-agent's parent reads of them, and how its
25
+ * thread names the question it paused on.
26
+ *
27
+ * ```text
28
+ * Which environment should I deploy to? (staging / production)
29
+ *
30
+ * 1. Which environment should I deploy to? (staging / production)
31
+ * 2. Which reports? (any of: daily / weekly)
32
+ * ```
33
+ */
34
+ export function agentQuestionsText(questions: readonly AgentQuestion[]): string {
35
+ const lines = questions.map((question) => {
36
+ const choices = question.choices?.length
37
+ ? ` (${question.multiple ? "any of: " : ""}${question.choices.join(" / ")})`
38
+ : ""
39
+ return `${question.question}${choices}`
40
+ })
41
+ return lines.length === 1
42
+ ? (lines[0] ?? "")
43
+ : lines.map((line, i) => `${i + 1}. ${line}`).join("\n")
44
+ }
45
+
46
+ /**
47
+ * The questions of an `ask` call's input, or of an `ask_parent` call's, which earlier threads hold:
48
+ * `{ question }` reads as one question. Undefined when the input names none.
49
+ */
50
+ export function agentQuestionsOf(
51
+ input: JsonValue | undefined
52
+ ): readonly AgentQuestion[] | undefined {
53
+ if (!isJsonObject(input)) return undefined
54
+ if (typeof input.question === "string") return [{ question: input.question.trim() }]
55
+ if (!Array.isArray(input.questions)) return undefined
56
+
57
+ const questions = input.questions.flatMap((value): AgentQuestion[] => {
58
+ if (!isJsonObject(value) || typeof value.question !== "string") return []
59
+ const choices = Array.isArray(value.choices)
60
+ ? value.choices.filter((choice): choice is string => typeof choice === "string")
61
+ : []
62
+ return [
63
+ {
64
+ question: value.question.trim(),
65
+ ...(choices.length > 0 ? { choices } : {}),
66
+ ...(value.multiple === true ? { multiple: true } : {}),
67
+ },
68
+ ]
69
+ })
70
+ return questions.length > 0 ? questions : undefined
71
+ }
72
+
73
+ /** The tools a sub-agent asks its parent with: `ask`, and `ask_parent`, which earlier threads hold. */
74
+ export function isChildAskTool(toolName: string): boolean {
75
+ return toolName === "ask" || toolName === "ask_parent"
76
+ }
77
+
11
78
  /**
12
79
  * Whether the child paused on its question when its turn ended: it continues once a later turn of
13
80
  * the conversation answers it under its key.
@@ -19,8 +86,8 @@ export function isAwaitingAnswerRun(run: AgentRunRecord | null | undefined): boo
19
86
  }
20
87
 
21
88
  /**
22
- * The question a run's messages paused on: its `ask_parent` call whose answer was deferred to a
23
- * later turn, which names the question's id.
89
+ * The question a run's messages paused on: its `ask` call whose answer was deferred to a later
90
+ * turn, which names the question's id.
24
91
  */
25
92
  export function deferredChildQuestion(
26
93
  messages: readonly Pick<AgentMessage, "parts">[]
@@ -29,18 +96,19 @@ export function deferredChildQuestion(
29
96
  .flatMap((message) => message.parts)
30
97
  .flatMap((part) =>
31
98
  part.type === "tool-call" &&
32
- part.toolName === "ask_parent" &&
99
+ isChildAskTool(part.toolName) &&
33
100
  part.state === "output-available" &&
34
101
  isJsonObject(part.output) &&
35
- part.output.status === "deferred" &&
36
- isJsonObject(part.input)
102
+ part.output.status === "deferred"
37
103
  ? [{ input: part.input, output: part.output }]
38
104
  : []
39
105
  )
40
106
  .at(-1)
41
107
  if (!asked) return undefined
42
108
 
43
- const { question: text } = asked.input
109
+ const questions = agentQuestionsOf(asked.input)
44
110
  const { question: id } = asked.output
45
- return typeof text === "string" && typeof id === "string" ? { id, text: text.trim() } : undefined
111
+ return questions && typeof id === "string"
112
+ ? { id, text: agentQuestionsText(questions) }
113
+ : undefined
46
114
  }
@@ -285,7 +285,7 @@ export interface AgentRunsRuntime {
285
285
  * this returns; a running one is still running, with the stop signal sent to its worker. A turn
286
286
  * paused for approval stays as it ended, with its held calls cancelled: it never resumes. A
287
287
  * sub-agent's run stops as its turn would: whoever asked for that turn, or the conversation's
288
- * owner, can, and its parent's `wait_agent` reads that it was stopped.
288
+ * owner, can, and its parent's `wait` reads that it was stopped.
289
289
  */
290
290
  cancel(runId: string): Promise<AgentRunView>
291
291
  /** A turn, or a sub-agent's run, read through its thread. */
package/src/agents/ids.ts CHANGED
@@ -22,9 +22,12 @@ export function createAgentRunId(): string {
22
22
  return `agt_run_${randomUUID()}`
23
23
  }
24
24
 
25
+ /** How every child's first run id starts: told apart from the key the Agent spawned it under. */
26
+ export const SUBAGENT_RUN_ID_PREFIX = "agt_run_child_"
27
+
25
28
  /** One stable child identity per parent-selected spawn key. */
26
29
  export function createSubagentRunId(parentRunId: string, spawnKey: string): string {
27
- return `agt_run_child_${spawnDigest(parentRunId, spawnKey)}`
30
+ return `${SUBAGENT_RUN_ID_PREFIX}${spawnDigest(parentRunId, spawnKey)}`
28
31
  }
29
32
 
30
33
  /**
@@ -59,8 +59,14 @@ export {
59
59
  } from "./authority"
60
60
  export { defineAgentTool } from "./builders"
61
61
  export { requestAgentRunCancel } from "./cancel"
62
- export type { AgentChildQuestion } from "./child-question"
63
- export { deferredChildQuestion, isAwaitingAnswerRun } from "./child-question"
62
+ export type { AgentChildQuestion, AgentQuestion } from "./child-question"
63
+ export {
64
+ AGENT_QUESTION_LIMITS,
65
+ agentQuestionsText,
66
+ deferredChildQuestion,
67
+ isAwaitingAnswerRun,
68
+ isChildAskTool,
69
+ } from "./child-question"
64
70
  export type {
65
71
  AgentContextEntryInput,
66
72
  AgentContextInput,
@@ -146,6 +152,7 @@ export {
146
152
  createSubagentExecutionId,
147
153
  createSubagentRunId,
148
154
  createSubagentThreadId,
155
+ SUBAGENT_RUN_ID_PREFIX,
149
156
  } from "./ids"
150
157
  export { AGENT_IMAGE_INPUT_TOKENS, AGENT_INLINE_IMAGE_LIMITS } from "./inline-images"
151
158
  export {
@@ -34,6 +34,7 @@ import type {
34
34
  } from "../models/messages"
35
35
  import type { ModelCallCost, ModelReportedCost } from "../models/pricing"
36
36
  import type { ModelOutput, ModelTool } from "../models/tools"
37
+ import { coerceToolInput } from "./tool-input-coercion"
37
38
 
38
39
  const MAX_PROVIDER_DATA_BYTES = 256 * 1024
39
40
  interface ModelLoopOptions {
@@ -177,6 +178,7 @@ export async function runModelLoop(
177
178
  name: tool.name,
178
179
  description: tool.description,
179
180
  inputSchema: tool.inputSchema,
181
+ ...(tool.strict ? { strict: true } : {}),
180
182
  }))
181
183
  let messages: readonly ModelMessage[] = [...input.messages]
182
184
  const steps: ModelStep[] = []
@@ -643,7 +645,7 @@ async function executeToolCall(
643
645
 
644
646
  let parsed: unknown
645
647
  try {
646
- parsed = tool.parseInput(part.input)
648
+ parsed = tool.parseInput(coerceToolInput(tool.inputSchema, part.input))
647
649
  } catch (error) {
648
650
  const errorText = error instanceof Error ? error.message : "Tool input validation failed."
649
651
  await onEvent?.({
@@ -1,3 +1,4 @@
1
+ import type { Broker } from "../broker"
1
2
  import { createInheritedAgentExecutionRecord } from "../execution/agent"
2
3
  import { ensureExecutionRecord } from "../execution/durable"
3
4
  import type { Storage } from "../storage"
@@ -13,6 +14,7 @@ import type {
13
14
  SubagentRunRecord,
14
15
  } from "../storage/agents"
15
16
  import { type AgentChildApprovalAwaiting, listChildApprovalsAwaiting } from "./approvals"
17
+ import { cancelQueuedRun, requestAgentRunCancel } from "./cancel"
16
18
  import { createSubagentExecutionId, createSubagentRunId, createSubagentThreadId } from "./ids"
17
19
  import { AgentRunRefusedError, fenced } from "./run-fence"
18
20
  import { listSubagentThreadRuns } from "./subagent-runs"
@@ -54,6 +56,12 @@ export interface AgentRunChildren {
54
56
  * so the turn can continue the child again. Refused once the turn no longer owns its run.
55
57
  */
56
58
  clearAttempt(input: { readonly threadId: string; readonly runId: string }): Promise<void>
59
+ /**
60
+ * Stop one of this turn's children: a queued one ends at once, a running one hears the cancel
61
+ * and ends at its next step. One that already ended is returned as it is. Refused for any run
62
+ * but this turn's own children.
63
+ */
64
+ cancel(runId: string): Promise<SubagentRunRecord>
57
65
  }
58
66
 
59
67
  /**
@@ -136,6 +144,8 @@ export function agentRunThreads(
136
144
  export interface AgentRunChildrenHost {
137
145
  readonly projectId: string
138
146
  readonly storage: Storage & { readonly agents: AgentStorage }
147
+ /** Where a cancel reaches the child's runner at once. */
148
+ readonly broker: Broker
139
149
  /** How many children one turn may have queued or running at once. */
140
150
  readonly maxActiveChildren?: number
141
151
  }
@@ -231,6 +241,24 @@ export function agentRunChildren(
231
241
  })
232
242
  )
233
243
  },
244
+ async cancel(runId) {
245
+ const child = await get(runId)
246
+ if (child?.kind !== "subagent" || child.parentRunId !== run.id) {
247
+ throw new AgentRunRefusedError(
248
+ `[Sixb] Agent run '${run.id}' stops only its own children, not '${runId}'.`
249
+ )
250
+ }
251
+ if (child.status === "queued") {
252
+ const queued = await cancelQueuedRun(host, agents, child)
253
+ if (queued.cancelled) return requireSubagent(queued.run)
254
+ // A worker started it meanwhile: it is stopped as a running one.
255
+ if (queued.run?.status !== "running") return requireSubagent(queued.run ?? child)
256
+ } else if (child.status !== "running") {
257
+ return child
258
+ }
259
+ await requestAgentRunCancel({ projectId, broker: host.broker, storage: agents }, child.id)
260
+ return child
261
+ },
234
262
  async clearAttempt({ threadId, runId }) {
235
263
  // Only an attempt that ended, of a child of this conversation, in that child's thread.
236
264
  const attempt = await get(runId)
@@ -256,6 +284,11 @@ export function agentRunChildren(
256
284
  }
257
285
  }
258
286
 
287
+ function requireSubagent(run: AgentRunRecord): SubagentRunRecord {
288
+ if (run.kind !== "subagent") throw new Error(`[Sixb] Agent run '${run.id}' changed kind.`)
289
+ return run
290
+ }
291
+
259
292
  function assertDelegable(
260
293
  run: AgentRunRecord,
261
294
  child: AgentChildDraft,
@@ -135,6 +135,7 @@ export function createHttpAgentRunSession<TRun extends AgentRunRecord>(
135
135
  activeCount: () => call("children.activeCount"),
136
136
  spawn: (draft) => call("children.spawn", [draft]),
137
137
  clearAttempt: (attempt) => call("children.clearAttempt", [attempt]),
138
+ cancel: (runId) => call("children.cancel", [runId]),
138
139
  },
139
140
  async renewLease(leaseExpiresAt) {
140
141
  try {
@@ -89,6 +89,7 @@ const OPERATIONS: Readonly<Record<string, Operation>> = {
89
89
  session.children.clearAttempt(
90
90
  input as Parameters<AgentRunSession["children"]["clearAttempt"]>[0]
91
91
  ),
92
+ "children.cancel": (session, [runId]) => session.children.cancel(runId as string),
92
93
  "threads.message": (session, [messageId]) => session.threads.message(messageId as string),
93
94
  "threads.messages": (session, [input]) =>
94
95
  session.threads.messages(input as Parameters<AgentRunSession["threads"]["messages"]>[0]),
@@ -14,7 +14,7 @@ import type { AgentToolFilePutInput } from "./types"
14
14
 
15
15
  /** Where a run's sandbox keeps its files, relative to its working directory. */
16
16
  export const SANDBOX_CONTEXT_DIRECTORY = ".sixb/agent"
17
- /** The most a file a tool stores, or one `view_file` reads, may hold: an artifact's file limit. */
17
+ /** The most a file a tool stores, or one `read` shows as itself, may hold: an artifact's file limit. */
18
18
  export const AGENT_FILE_MAX_BYTES = ARTIFACT_LIMITS.maxFileBytes
19
19
  const MAX_FILE_NAME_BYTES = 255
20
20
  const MAX_MEDIA_TYPE_LENGTH = 255