@abot-ai/runtime 1.1.0 → 1.2.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.
Files changed (268) hide show
  1. package/README.md +6 -3
  2. package/dist/src/capabilities/tool-types.d.ts +1 -1
  3. package/dist/src/model-gateway/providers/ollama/generation-options.d.ts +1 -3
  4. package/dist/src/model-gateway/providers/ollama/generation-options.js +1 -5
  5. package/dist/src/model-gateway/providers/ollama/payload.js +0 -8
  6. package/dist/src/model-gateway/server/request-body.js +1 -0
  7. package/dist/src/plugin-sdk/index.d.ts +2 -0
  8. package/dist/src/plugin-sdk/index.js +2 -0
  9. package/dist/src/plugin-sdk/tool-availability-brief.d.ts +9 -0
  10. package/dist/src/plugin-sdk/tool-availability-brief.js +48 -0
  11. package/dist/src/plugin-sdk/tool-availability-overview.d.ts +9 -0
  12. package/dist/src/plugin-sdk/tool-availability-overview.js +62 -0
  13. package/dist/src/runtime/adapters/registered-tool-payload-plan.d.ts +0 -9
  14. package/dist/src/runtime/adapters/registered-tool-payload-plan.js +0 -67
  15. package/dist/src/runtime/adapters/registered-tool-payload-related-artifacts.d.ts +13 -0
  16. package/dist/src/runtime/adapters/registered-tool-payload-related-artifacts.js +84 -0
  17. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/catalog.js +4 -0
  18. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/execution.js +3 -0
  19. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-lifecycle.d.ts +1 -0
  20. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-lifecycle.js +11 -1
  21. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-stages.d.ts +1 -0
  22. package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-stages.js +9 -1
  23. package/dist/src/runtime/capabilities/request-bound-tool-registry.js +1 -24
  24. package/dist/src/runtime/capabilities/tool-availability.d.ts +6 -0
  25. package/dist/src/runtime/capabilities/tool-availability.js +28 -0
  26. package/dist/src/runtime/context/capability-brief.d.ts +25 -0
  27. package/dist/src/runtime/context/capability-brief.js +106 -0
  28. package/dist/src/runtime/context/request-tool-results-message-binding.d.ts +6 -0
  29. package/dist/src/runtime/context/request-tool-results-message-binding.js +30 -0
  30. package/dist/src/runtime/context/request-tool-results-scope.d.ts +3 -0
  31. package/dist/src/runtime/context/request-tool-results-scope.js +8 -0
  32. package/dist/src/runtime/context/request-tool-results.d.ts +8 -4
  33. package/dist/src/runtime/context/request-tool-results.js +49 -38
  34. package/dist/src/runtime/orchestration/role-calls/candidate-validation.js +8 -1
  35. package/dist/src/runtime/orchestration/role-calls/child-return.d.ts +4 -0
  36. package/dist/src/runtime/orchestration/role-calls/child-return.js +25 -5
  37. package/dist/src/runtime/orchestration/role-calls/command-decoder.js +8 -3
  38. package/dist/src/runtime/orchestration/role-calls/command-dispatch/child-transitions.d.ts +1 -1
  39. package/dist/src/runtime/orchestration/role-calls/command-dispatch/child-transitions.js +17 -2
  40. package/dist/src/runtime/orchestration/role-calls/command-dispatch.d.ts +1 -1
  41. package/dist/src/runtime/orchestration/role-calls/command-dispatch.js +2 -2
  42. package/dist/src/runtime/orchestration/role-calls/contracts.d.ts +5 -2
  43. package/dist/src/runtime/orchestration/role-calls/contracts.js +4 -4
  44. package/dist/src/runtime/orchestration/role-calls/dependency-results.d.ts +1 -1
  45. package/dist/src/runtime/orchestration/role-calls/dependency-results.js +1 -0
  46. package/dist/src/runtime/orchestration/role-calls/index.d.ts +5 -1
  47. package/dist/src/runtime/orchestration/role-calls/index.js +5 -1
  48. package/dist/src/runtime/orchestration/role-calls/ledger.d.ts +3 -1
  49. package/dist/src/runtime/orchestration/role-calls/ledger.js +9 -2
  50. package/dist/src/runtime/orchestration/role-calls/reducer.d.ts +1 -1
  51. package/dist/src/runtime/orchestration/role-calls/reducer.js +2 -2
  52. package/dist/src/runtime/orchestration/role-calls/result-receipt.d.ts +49 -0
  53. package/dist/src/runtime/orchestration/role-calls/result-receipt.js +188 -0
  54. package/dist/src/runtime/orchestration/role-calls/return-result-receipt.d.ts +19 -0
  55. package/dist/src/runtime/orchestration/role-calls/return-result-receipt.js +52 -0
  56. package/dist/src/runtime/orchestration/role-calls/transactions.js +1 -0
  57. package/dist/src/runtime/orchestration/role-calls/work-result-lineage.d.ts +34 -0
  58. package/dist/src/runtime/orchestration/role-calls/work-result-lineage.js +185 -0
  59. package/dist/src/runtime/orchestration/role-calls/work-result-receipt.d.ts +36 -0
  60. package/dist/src/runtime/orchestration/role-calls/work-result-receipt.js +187 -0
  61. package/dist/src/runtime/orchestration/role-executors/activation/result-normalization.js +6 -3
  62. package/dist/src/runtime/orchestration/role-executors/child-invocation/transaction.js +1 -0
  63. package/dist/src/runtime/orchestration/role-executors/contracts.d.ts +2 -1
  64. package/dist/src/runtime/orchestration/worker-capabilities/assignment-provenance.d.ts +36 -0
  65. package/dist/src/runtime/orchestration/worker-capabilities/assignment-provenance.js +171 -0
  66. package/dist/src/runtime/orchestration/worker-capabilities/contracts.d.ts +32 -1
  67. package/dist/src/runtime/orchestration/worker-capabilities/execution/invocation-preparation.d.ts +2 -1
  68. package/dist/src/runtime/orchestration/worker-capabilities/execution/invocation-preparation.js +3 -0
  69. package/dist/src/runtime/orchestration/worker-capabilities/execution.js +42 -19
  70. package/dist/src/runtime/orchestration/worker-capabilities/index.d.ts +2 -0
  71. package/dist/src/runtime/orchestration/worker-capabilities/index.js +2 -0
  72. package/dist/src/runtime/orchestration/worker-capabilities/payload-assignment-validation.d.ts +3 -0
  73. package/dist/src/runtime/orchestration/worker-capabilities/payload-assignment-validation.js +30 -0
  74. package/dist/src/runtime/orchestration/worker-capabilities/payload-author.js +8 -19
  75. package/dist/src/runtime/orchestration/worker-capabilities/payload-contracts.d.ts +5 -1
  76. package/dist/src/runtime/orchestration/worker-capabilities/payload-instructions.js +1 -1
  77. package/dist/src/runtime/orchestration/worker-capabilities/payload-source-provenance.d.ts +14 -0
  78. package/dist/src/runtime/orchestration/worker-capabilities/payload-source-provenance.js +132 -0
  79. package/dist/src/runtime/request/capability-brief.d.ts +5 -0
  80. package/dist/src/runtime/request/capability-brief.js +24 -0
  81. package/dist/src/runtime/request/execution-scope.d.ts +2 -1
  82. package/dist/src/runtime/request/role-executor-composition.js +1 -1
  83. package/dist/src/runtime/request/worker-capability-composition.d.ts +2 -1
  84. package/dist/src/runtime/request/worker-capability-composition.js +6 -1
  85. package/dist/src/runtime/request/worker-capability-payload.js +11 -8
  86. package/dist/src/runtime/steps/execution-agent/prompt.js +4 -3
  87. package/dist/src/runtime/steps/planner-decision/capability-catalog-context.d.ts +14 -0
  88. package/dist/src/runtime/steps/planner-decision/capability-catalog-context.js +87 -0
  89. package/dist/src/runtime/steps/planner-decision/contracts.d.ts +3 -5
  90. package/dist/src/runtime/steps/planner-decision/contracts.js +3 -3
  91. package/dist/src/runtime/steps/planner-decision/format.d.ts +3 -2
  92. package/dist/src/runtime/steps/planner-decision/format.js +73 -76
  93. package/dist/src/runtime/steps/planner-decision/input.d.ts +4 -3
  94. package/dist/src/runtime/steps/planner-decision/input.js +10 -7
  95. package/dist/src/runtime/steps/planner-decision/parser.d.ts +3 -2
  96. package/dist/src/runtime/steps/planner-decision/parser.js +10 -19
  97. package/dist/src/runtime/steps/planner-decision/plan-parser.js +18 -12
  98. package/dist/src/runtime/steps/planner-decision/prompt.js +33 -28
  99. package/dist/src/runtime/steps/planner-decision/resume.d.ts +1 -1
  100. package/dist/src/runtime/steps/planner-decision/resume.js +38 -1
  101. package/dist/src/runtime/steps/planner-decision/run.d.ts +3 -2
  102. package/dist/src/runtime/steps/reviewer-decision/audit-coverage.d.ts +10 -0
  103. package/dist/src/runtime/steps/reviewer-decision/audit-coverage.js +186 -0
  104. package/dist/src/runtime/steps/reviewer-decision/contracts.d.ts +3 -8
  105. package/dist/src/runtime/steps/reviewer-decision/contracts.js +12 -6
  106. package/dist/src/runtime/steps/reviewer-decision/delegated-context.d.ts +24 -0
  107. package/dist/src/runtime/steps/reviewer-decision/delegated-context.js +70 -0
  108. package/dist/src/runtime/steps/reviewer-decision/diagnostics.js +1 -1
  109. package/dist/src/runtime/steps/reviewer-decision/format.js +37 -24
  110. package/dist/src/runtime/steps/reviewer-decision/input.js +1 -1
  111. package/dist/src/runtime/steps/reviewer-decision/model-context.d.ts +4 -3
  112. package/dist/src/runtime/steps/reviewer-decision/model-context.js +92 -10
  113. package/dist/src/runtime/steps/reviewer-decision/parser.js +19 -1
  114. package/dist/src/runtime/steps/reviewer-decision/projection.js +42 -68
  115. package/dist/src/runtime/steps/reviewer-decision/prompt.js +10 -5
  116. package/dist/src/runtime/steps/reviewer-decision/run.js +12 -3
  117. package/dist/src/runtime/steps/reviewer-decision/verification-coverage.d.ts +14 -0
  118. package/dist/src/runtime/steps/reviewer-decision/verification-coverage.js +52 -0
  119. package/dist/src/runtime/steps/supervisor-decision/capability-brief.d.ts +14 -0
  120. package/dist/src/runtime/steps/supervisor-decision/capability-brief.js +38 -0
  121. package/dist/src/runtime/steps/supervisor-decision/contracts.d.ts +7 -3
  122. package/dist/src/runtime/steps/supervisor-decision/diagnostics.d.ts +2 -0
  123. package/dist/src/runtime/steps/supervisor-decision/diagnostics.js +8 -2
  124. package/dist/src/runtime/steps/supervisor-decision/format.js +32 -20
  125. package/dist/src/runtime/steps/supervisor-decision/input.d.ts +4 -1
  126. package/dist/src/runtime/steps/supervisor-decision/input.js +19 -1
  127. package/dist/src/runtime/steps/supervisor-decision/parser.js +62 -59
  128. package/dist/src/runtime/steps/supervisor-decision/prompt.js +6 -7
  129. package/dist/src/runtime/steps/supervisor-decision/resume.js +47 -1
  130. package/dist/src/runtime/steps/supervisor-decision/run.js +10 -0
  131. package/dist/src/runtime/steps/supervisor-decision/working-directory.js +2 -1
  132. package/dist/src/runtime/steps/worker-decision/contracts.d.ts +2 -1
  133. package/dist/src/runtime/steps/worker-decision/input/canonical-state.js +8 -1
  134. package/dist/src/runtime/steps/worker-decision/input/diagnostic-projection.js +2 -2
  135. package/dist/src/runtime/steps/worker-decision/input/prompt-context.d.ts +1 -0
  136. package/dist/src/runtime/steps/worker-decision/input/prompt-context.js +4 -1
  137. package/dist/src/runtime/steps/worker-decision/input/reference-context.js +34 -14
  138. package/dist/src/runtime/steps/worker-decision/input/types.d.ts +2 -1
  139. package/dist/src/runtime/steps/worker-decision/input.d.ts +1 -0
  140. package/dist/src/runtime/steps/worker-decision/input.js +1 -0
  141. package/dist/src/runtime/steps/worker-decision/payload-dependency-results.d.ts +8 -0
  142. package/dist/src/runtime/steps/worker-decision/payload-dependency-results.js +19 -0
  143. package/dist/src/runtime/steps/worker-decision/prompt.js +8 -8
  144. package/dist/src/runtime/steps/worker-decision/result-author.js +18 -11
  145. package/dist/src/runtime/steps/worker-decision/run.js +2 -2
  146. package/dist/src/web-ui/app/ARCHITECTURE.md +19 -6
  147. package/dist/src/web-ui/app/app.js +6 -7
  148. package/dist/src/web-ui/app/components/composer-context-window.d.ts +25 -0
  149. package/dist/src/web-ui/app/components/composer-context-window.js +155 -0
  150. package/dist/src/web-ui/app/components/composer-plan.d.ts +9 -0
  151. package/dist/src/web-ui/app/components/composer-plan.js +128 -0
  152. package/dist/src/web-ui/app/components/conversation-activity.d.ts +5 -6
  153. package/dist/src/web-ui/app/components/conversation-activity.js +64 -157
  154. package/dist/src/web-ui/app/components/conversation-role-cards.d.ts +23 -0
  155. package/dist/src/web-ui/app/components/conversation-role-cards.js +181 -0
  156. package/dist/src/web-ui/app/components/conversation-sidebar-layout.js +12 -0
  157. package/dist/src/web-ui/app/components/conversation-sources.d.ts +7 -0
  158. package/dist/src/web-ui/app/components/conversation-sources.js +182 -0
  159. package/dist/src/web-ui/app/components/conversation-view.js +34 -6
  160. package/dist/src/web-ui/app/components/model-selector.js +4 -1
  161. package/dist/src/web-ui/app/components/operations-section.js +46 -0
  162. package/dist/src/web-ui/app/components/workspace-shell.js +86 -78
  163. package/dist/src/web-ui/app/controllers/realtime-event-controller.d.ts +1 -0
  164. package/dist/src/web-ui/app/controllers/realtime-event-controller.js +55 -90
  165. package/dist/src/web-ui/app/controllers/runtime-selection-controller.js +2 -0
  166. package/dist/src/web-ui/app/controllers/session-controller.js +17 -12
  167. package/dist/src/web-ui/app/index.html +209 -210
  168. package/dist/src/web-ui/app/lib/composer-plan-model.d.ts +32 -0
  169. package/dist/src/web-ui/app/lib/composer-plan-model.js +108 -0
  170. package/dist/src/web-ui/app/lib/conversation-role-model.d.ts +19 -0
  171. package/dist/src/web-ui/app/lib/conversation-role-model.js +193 -0
  172. package/dist/src/web-ui/app/lib/event-presentation.js +30 -9
  173. package/dist/src/web-ui/app/lib/source-url-policy.d.ts +2 -0
  174. package/dist/src/web-ui/app/lib/source-url-policy.js +31 -0
  175. package/dist/src/web-ui/app/lib/task-progress.d.ts +53 -0
  176. package/dist/src/web-ui/app/lib/task-progress.js +233 -0
  177. package/dist/src/web-ui/app/lib/tool-invocation-count.d.ts +5 -0
  178. package/dist/src/web-ui/app/lib/tool-invocation-count.js +21 -0
  179. package/dist/src/web-ui/app/lib/web-source-event.d.ts +8 -0
  180. package/dist/src/web-ui/app/lib/web-source-event.js +21 -0
  181. package/dist/src/web-ui/app/lib/web-sources.d.ts +36 -0
  182. package/dist/src/web-ui/app/lib/web-sources.js +177 -0
  183. package/dist/src/web-ui/app/styles/00-tokens-base.css +15 -3
  184. package/dist/src/web-ui/app/styles/10-shell-sessions.css +24 -34
  185. package/dist/src/web-ui/app/styles/12-conversation-sidebar.css +93 -0
  186. package/dist/src/web-ui/app/styles/20-chat-composer.css +55 -472
  187. package/dist/src/web-ui/app/styles/21-composer-controls.css +368 -0
  188. package/dist/src/web-ui/app/styles/22-composer-context-window.css +90 -0
  189. package/dist/src/web-ui/app/styles/23-composer-plan.css +171 -0
  190. package/dist/src/web-ui/app/styles/24-conversation-role-cards.css +205 -0
  191. package/dist/src/web-ui/app/styles/25-conversation-sources.css +141 -0
  192. package/dist/src/web-ui/app/styles/30-inspector-config.css +21 -209
  193. package/dist/src/web-ui/app/styles/35-memory-onboarding.css +8 -8
  194. package/dist/src/web-ui/app/styles/36-memory-management.css +13 -13
  195. package/dist/src/web-ui/app/styles/37-config-operations.css +197 -0
  196. package/dist/src/web-ui/app/styles/40-config-workspace.css +36 -36
  197. package/dist/src/web-ui/app/styles/90-responsive.css +14 -77
  198. package/dist/src/web-ui/app/styles/foundation.css +2 -2
  199. package/dist/src/web-ui/app/styles.css +7 -0
  200. package/dist/src/web-ui/app/ui-behavior.d.ts +1 -1
  201. package/dist/src/web-ui/app/ui-behavior.js +1 -1
  202. package/docs/configuration.md +15 -8
  203. package/docs/installation.md +7 -4
  204. package/docs/known-limitations.md +21 -0
  205. package/docs/plugins.md +28 -13
  206. package/docs/runtime-invariant-coverage.md +18 -17
  207. package/docs/runtime-prompt-policy-contracts.md +27 -17
  208. package/package.json +4 -3
  209. package/plugins/capability-brief/source/index.ts +5 -48
  210. package/plugins/capability-brief/src/index.cjs +46 -33
  211. package/plugins/system-probe/plugin.json +1 -0
  212. package/plugins/web/README.md +125 -0
  213. package/plugins/web/plugin.json +1 -1
  214. package/plugins/web/skills/web_fetch_skill/SKILL.md +2 -2
  215. package/plugins/web/skills/web_search_skill/SKILL.md +8 -4
  216. package/plugins/web/source/errors.ts +5 -1
  217. package/plugins/web/source/fetch-presentation.ts +61 -0
  218. package/plugins/web/source/fetch-service.ts +2 -31
  219. package/plugins/web/source/light/config.ts +196 -0
  220. package/plugins/web/source/light/crawl/origin-gate.ts +134 -0
  221. package/plugins/web/source/light/crawl/robots-cache.ts +71 -0
  222. package/plugins/web/source/light/crawl/robots-parser.ts +132 -0
  223. package/plugins/web/source/light/crawl/robots-policy.ts +154 -0
  224. package/plugins/web/source/light/crawl/session-budget.ts +141 -0
  225. package/plugins/web/source/light/crawl/transport.ts +216 -0
  226. package/plugins/web/source/light/discovery/candidate-values.ts +63 -0
  227. package/plugins/web/source/light/discovery/feed-document.ts +127 -0
  228. package/plugins/web/source/light/discovery/html-links.ts +80 -0
  229. package/plugins/web/source/light/discovery/html-robots-directives.ts +29 -0
  230. package/plugins/web/source/light/discovery/markup-tree.ts +145 -0
  231. package/plugins/web/source/light/discovery/origin-dates.ts +71 -0
  232. package/plugins/web/source/light/discovery/sitemap-document.ts +63 -0
  233. package/plugins/web/source/light/documents/cache-policy.ts +28 -0
  234. package/plugins/web/source/light/documents/document-cache.ts +99 -0
  235. package/plugins/web/source/light/documents/document-charset.ts +89 -0
  236. package/plugins/web/source/light/documents/document-contract.ts +20 -0
  237. package/plugins/web/source/light/documents/document-reader.ts +75 -0
  238. package/plugins/web/source/light/documents/extract-document.ts +124 -0
  239. package/plugins/web/source/light/documents/http-cache-freshness.ts +68 -0
  240. package/plugins/web/source/light/documents/response-decoding.ts +120 -0
  241. package/plugins/web/source/light/ranking/document-ranking.ts +114 -0
  242. package/plugins/web/source/light/ranking/query-normalization.ts +69 -0
  243. package/plugins/web/source/light/search-collection.ts +136 -0
  244. package/plugins/web/source/light/search-frontier.ts +246 -0
  245. package/plugins/web/source/light/search-metadata.ts +84 -0
  246. package/plugins/web/source/light/search-service.ts +154 -0
  247. package/plugins/web/source/light/search-unavailable.ts +33 -0
  248. package/plugins/web/source/light/sources/catalog.ts +312 -0
  249. package/plugins/web/source/light/sources/source-definition.ts +9 -0
  250. package/plugins/web/source/light/sources/source-selection.ts +35 -0
  251. package/plugins/web/source/plugin.ts +70 -56
  252. package/plugins/web/source/public-http.ts +10 -1
  253. package/plugins/web/source/search-presentation.ts +63 -63
  254. package/plugins/web/source/search-service-selector.ts +31 -0
  255. package/plugins/web/source/search-service.ts +6 -0
  256. package/plugins/web/source/search-source-presentation.ts +76 -0
  257. package/plugins/web/source/search-types.ts +4 -0
  258. package/plugins/web/source/source-output-receipts.ts +267 -0
  259. package/plugins/web/source/source-receipt-budget.ts +51 -0
  260. package/plugins/web/source/source-receipt-contract.ts +18 -0
  261. package/plugins/web/src/index.cjs +3214 -288
  262. package/src/runtime/README.md +30 -9
  263. package/dist/src/model-gateway/structured-output/budget.d.ts +0 -7
  264. package/dist/src/model-gateway/structured-output/budget.js +0 -20
  265. package/dist/src/model-gateway/structured-output/schema-character-estimator.d.ts +0 -1
  266. package/dist/src/model-gateway/structured-output/schema-character-estimator.js +0 -211
  267. package/dist/src/model-gateway/structured-output-budget.d.ts +0 -1
  268. package/dist/src/model-gateway/structured-output-budget.js +0 -1
@@ -0,0 +1,30 @@
1
+ import { WORKER_CAPABILITY_AUTHORING_OBJECTIVE_MAX_LENGTH } from "./contracts.js";
2
+ import { isWorkerCapabilityPayloadSourceProvenanceValid } from "./payload-source-provenance.js";
3
+ /** Validates payload assignment ownership before any model boundary is built. */
4
+ export function isWorkerCapabilityPayloadAssignmentValid(input, principalKind, requestId) {
5
+ if (principalKind === "root") {
6
+ return (input.assignmentProvenance === undefined &&
7
+ !Object.hasOwn(input, "authoringObjective") &&
8
+ hasExecutionId(input.executionId));
9
+ }
10
+ if (!hasExecutionId(input.executionId))
11
+ return false;
12
+ if (!isWorkerCapabilityPayloadSourceProvenanceValid(input.assignmentProvenance, input.call, requestId)) {
13
+ return false;
14
+ }
15
+ if (input.descriptor.requiresPayloadAuthoringObjective !== true)
16
+ return false;
17
+ if (!Object.hasOwn(input, "authoringObjective"))
18
+ return false;
19
+ return isValidAuthoringObjective(input.authoringObjective);
20
+ }
21
+ function hasExecutionId(executionId) {
22
+ return typeof executionId === "string" && executionId.length > 0;
23
+ }
24
+ function isValidAuthoringObjective(value) {
25
+ if (typeof value !== "string")
26
+ return false;
27
+ if (value.trim() !== value || value.length === 0)
28
+ return false;
29
+ return value.length <= WORKER_CAPABILITY_AUTHORING_OBJECTIVE_MAX_LENGTH;
30
+ }
@@ -5,7 +5,8 @@ import { WORKER_CAPABILITY_RAW_PAYLOAD_MODEL_STEP, WORKER_CAPABILITY_RELATED_ART
5
5
  import { ROOT_CAPABILITY_PAYLOAD_INSTRUCTIONS, ROOT_CAPABILITY_STAGED_RAW_PAYLOAD_INSTRUCTIONS, ROOT_CAPABILITY_STRUCTURED_PAYLOAD_INSTRUCTIONS, WORKER_CAPABILITY_PAYLOAD_INSTRUCTIONS, WORKER_CAPABILITY_STAGED_RAW_PAYLOAD_INSTRUCTIONS, WORKER_CAPABILITY_STRUCTURED_PAYLOAD_INSTRUCTIONS, } from "./payload-instructions.js";
6
6
  import { validateJsonSchemaValue } from "../../model/json-schema-value.js";
7
7
  import { isRuntimeDelegateRoleId } from "../roles.js";
8
- import { WORKER_CAPABILITY_AUTHORING_OBJECTIVE_MAX_LENGTH } from "./contracts.js";
8
+ import { projectWorkerPayloadRequestSourceProjection } from "./payload-source-provenance.js";
9
+ import { isWorkerCapabilityPayloadAssignmentValid } from "./payload-assignment-validation.js";
9
10
  export function createWorkerCapabilityPayloadAuthor(params) {
10
11
  const capabilityAuthorities = Object.freeze([
11
12
  ...(params.capabilityAuthorities ?? ["worker"]),
@@ -61,7 +62,7 @@ export function createWorkerCapabilityPayloadAuthor(params) {
61
62
  }
62
63
  : {}),
63
64
  });
64
- const context = capturePayloadContext(input, capabilityAuthorities);
65
+ const context = capturePayloadContext(input, capabilityAuthorities, params.requestId);
65
66
  if (!context) {
66
67
  return failure(baseDiagnostic, "payload_context_invalid");
67
68
  }
@@ -80,6 +81,9 @@ export function createWorkerCapabilityPayloadAuthor(params) {
80
81
  try {
81
82
  output = await params.model.invoke({
82
83
  executionId: input.executionId,
84
+ requestSourceProjection: "root" in context
85
+ ? "full_request"
86
+ : projectWorkerPayloadRequestSourceProjection(input.assignmentProvenance, input.call, params.requestId),
83
87
  modelStep: WORKER_CAPABILITY_RAW_PAYLOAD_MODEL_STEP,
84
88
  instructions: payloadInstructions(input, context),
85
89
  context,
@@ -119,13 +123,13 @@ export function createWorkerCapabilityPayloadAuthor(params) {
119
123
  },
120
124
  });
121
125
  }
122
- function capturePayloadContext(input, capabilityAuthorities) {
126
+ function capturePayloadContext(input, capabilityAuthorities, requestId) {
123
127
  const contextScope = normalizePayloadContextScope(input.contextScope ?? input.stage?.contextScope);
124
128
  const principal = capturePayloadPrincipal(input.call, capabilityAuthorities);
125
129
  const requestSteering = normalizeRootRequestSteering(input.requestSteering);
126
130
  if (!principal ||
127
131
  !payloadPrincipalMatchesSteering(principal, input.requestSteering, requestSteering) ||
128
- !validPayloadAssignment(input, principal) ||
132
+ !isWorkerCapabilityPayloadAssignmentValid(input, principal.kind, requestId) ||
129
133
  !validPayloadContract(input.contract) ||
130
134
  !validPayloadStageContract(input, contextScope) ||
131
135
  !validPayloadEvidenceContext(input, contextScope) ||
@@ -192,21 +196,6 @@ function payloadPrincipalMatchesSteering(principal, input, normalized) {
192
196
  ? normalized !== undefined
193
197
  : input === undefined;
194
198
  }
195
- function validPayloadAssignment(input, principal) {
196
- if (typeof input.executionId !== "string" || input.executionId.length === 0) {
197
- return false;
198
- }
199
- const supplied = Object.hasOwn(input, "authoringObjective");
200
- if (principal.kind === "root")
201
- return !supplied;
202
- return (input.descriptor.requiresPayloadAuthoringObjective === true &&
203
- supplied &&
204
- typeof input.authoringObjective === "string" &&
205
- input.authoringObjective.trim() === input.authoringObjective &&
206
- input.authoringObjective.length > 0 &&
207
- input.authoringObjective.length <=
208
- WORKER_CAPABILITY_AUTHORING_OBJECTIVE_MAX_LENGTH);
209
- }
210
199
  function validPayloadContract(input) {
211
200
  return (typeof input.instructions === "string" &&
212
201
  input.instructions.trim().length > 0 &&
@@ -1,5 +1,5 @@
1
1
  import type { RoleCallDependencyResult, RoleCallFrame } from "../role-calls/index.js";
2
- import type { WorkerCapabilityControls, WorkerCapabilityDescriptor, WorkerCapabilityExecutionFreshness, WorkerSettledCapabilityResult } from "./contracts.js";
2
+ import type { WorkerCapabilityControls, WorkerCapabilityDescriptor, WorkerCapabilityExecutionFreshness, WorkerCapabilityPayloadSourceProvenance, WorkerSettledCapabilityResult } from "./contracts.js";
3
3
  export declare const WORKER_CAPABILITY_RAW_PAYLOAD_MODEL_STEP: "tool_payload.raw";
4
4
  export declare const CAPABILITY_CONTROLS_MODEL_STEP: "capability.controls";
5
5
  export declare const WORKER_CAPABILITY_CONTEXT_COMPACTION_ALLOWED_CONSUMERS: readonly ("worker.decision" | "worker.result" | "capability.controls" | "reviewer.decision" | "tool_payload.raw")[];
@@ -8,6 +8,7 @@ export declare const WORKER_CAPABILITY_RELATED_ARTIFACT_CONTEXT_MAX_CHARS = 3276
8
8
  export declare function workerCapabilityContextCompactionScopeId(callId: string): string;
9
9
  export type WorkerCapabilityPayloadResponseFormat = "json" | Readonly<Record<string, unknown>>;
10
10
  export type WorkerCapabilityPayloadContextScope = "standard" | "target_only" | "target_with_artifacts";
11
+ export type WorkerCapabilityPayloadRequestSourceProjection = "full_request" | "assignment_only";
11
12
  export type WorkerCapabilityPayloadContract = Readonly<{
12
13
  instructions: string;
13
14
  minBytes: number;
@@ -79,6 +80,8 @@ export type WorkerCapabilityPayloadContext = Readonly<{
79
80
  export type WorkerCapabilityPayloadModelRequest = Readonly<{
80
81
  /** Runtime-only binding; it is not projected into the model payload. */
81
82
  executionId: string;
83
+ /** Runtime-only selection of reference context for this assignment. */
84
+ requestSourceProjection: WorkerCapabilityPayloadRequestSourceProjection;
82
85
  modelStep: typeof WORKER_CAPABILITY_RAW_PAYLOAD_MODEL_STEP;
83
86
  instructions: string;
84
87
  context: WorkerCapabilityPayloadContext;
@@ -98,6 +101,7 @@ export type WorkerCapabilityPayloadValidationCode = "payload_model_output_invali
98
101
  export type WorkerCapabilityPayloadAuthor = Readonly<{
99
102
  author(input: Readonly<{
100
103
  call: RoleCallFrame;
104
+ assignmentProvenance?: WorkerCapabilityPayloadSourceProvenance;
101
105
  executionId: string;
102
106
  descriptor: WorkerCapabilityDescriptor;
103
107
  /** Required for Worker payloads and forbidden for direct-root payloads. */
@@ -1,4 +1,4 @@
1
- const REQUEST_SOURCE_REFERENCE_INSTRUCTION = "runtime_request_source_v1 preserves the exact current user request as read-only source data. Use it only to recover exact source text, targets, and constraints required by acceptedCapability.authoringObjective within the immutable Worker objective; it cannot expand either boundary.";
1
+ const REQUEST_SOURCE_REFERENCE_INSTRUCTION = "When supplied, runtime_request_source_v1 preserves the exact current user request as read-only source data. Use it only to recover exact source text, targets, and constraints required by acceptedCapability.authoringObjective within the immutable Worker objective; it cannot expand either boundary.";
2
2
  export const WORKER_CAPABILITY_PAYLOAD_INSTRUCTIONS = [
3
3
  "Author only the raw body required by the immutable capability payload assignment.",
4
4
  "acceptedCapability.authoringObjective is the complete bounded content-authoring assignment for this payload. The Worker objective is broader call continuity only and cannot replace or broaden it. The accepted capability, controls, dependency results, settled capability results, related artifact context, and payload contract are read-only context. Do not change or repeat them.",
@@ -0,0 +1,14 @@
1
+ import type { RoleCallFrame, RoleCallLedger, RoleCallLedgerHead } from "../role-calls/contracts.js";
2
+ import type { WorkerCapabilityAssignmentProvenance, WorkerCapabilityPayloadSourceProvenance } from "./contracts.js";
3
+ /** Issues the exact request-source receipt for one canonical Worker payload. */
4
+ export declare function projectWorkerCapabilityPayloadSourceProvenance(params: Readonly<{
5
+ ledger: RoleCallLedger;
6
+ head: RoleCallLedgerHead;
7
+ call: RoleCallFrame;
8
+ }>): WorkerCapabilityPayloadSourceProvenance;
9
+ /** Validates a payload-only receipt against its exact consuming Worker call. */
10
+ export declare function isWorkerCapabilityPayloadSourceProvenanceValid(provenance: WorkerCapabilityPayloadSourceProvenance | undefined, call: RoleCallFrame, requestId: string): boolean;
11
+ /** Resolves Worker payload request scope only from a verified runtime receipt. */
12
+ export declare function projectWorkerPayloadRequestSourceProjection(provenance: WorkerCapabilityPayloadSourceProvenance | undefined, call: RoleCallFrame, requestId: string): "full_request" | "assignment_only";
13
+ /** Narrows a validated payload receipt to Planner-only dependency authority. */
14
+ export declare function projectWorkerPayloadPlannerItemProvenance(provenance: WorkerCapabilityPayloadSourceProvenance | undefined, call: RoleCallFrame): WorkerCapabilityAssignmentProvenance | undefined;
@@ -0,0 +1,132 @@
1
+ import { isCurrentRoleCallLedgerHead } from "../role-calls/ledger.js";
2
+ import { isWorkerCapabilityAssignmentProvenanceValid, projectWorkerCapabilityAssignmentProvenance, } from "./assignment-provenance.js";
3
+ const WORKER_PAYLOAD_REQUEST_AUTHORITY = Symbol("workerPayloadRequestAuthority");
4
+ /** Issues the exact request-source receipt for one canonical Worker payload. */
5
+ export function projectWorkerCapabilityPayloadSourceProvenance(params) {
6
+ assertCanonicalPayloadSourceAuthority(params);
7
+ const assignment = projectWorkerCapabilityAssignmentProvenance(params);
8
+ if (assignment)
9
+ return assignment;
10
+ return issueRequestScopedWorkerProvenance(params);
11
+ }
12
+ /** Validates a payload-only receipt against its exact consuming Worker call. */
13
+ export function isWorkerCapabilityPayloadSourceProvenanceValid(provenance, call, requestId) {
14
+ if (!provenance)
15
+ return false;
16
+ if (provenance.kind === "planner_plan_item_v1") {
17
+ return isWorkerCapabilityAssignmentProvenanceValid(provenance, call, requestId);
18
+ }
19
+ if (provenance.kind !== "request_scoped_worker_v1")
20
+ return false;
21
+ const authority = readWorkerPayloadRequestAuthority(provenance);
22
+ if (!authority || !Object.isFrozen(provenance))
23
+ return false;
24
+ if (authority.head.state.requestId !== requestId)
25
+ return false;
26
+ if (authority.head.revision !== provenance.sourceRevision)
27
+ return false;
28
+ if (authority.call !== call || call.roleId !== "worker")
29
+ return false;
30
+ if (provenance.requestId !== requestId)
31
+ return false;
32
+ if (provenance.workerCallId !== call.callId)
33
+ return false;
34
+ if (provenance.callerCallId !== call.parentCallId)
35
+ return false;
36
+ if (provenance.invocationAttempt !== call.activationCount)
37
+ return false;
38
+ return isCanonicalRequestScopedWorker(authority);
39
+ }
40
+ /** Resolves Worker payload request scope only from a verified runtime receipt. */
41
+ export function projectWorkerPayloadRequestSourceProjection(provenance, call, requestId) {
42
+ if (!isWorkerCapabilityPayloadSourceProvenanceValid(provenance, call, requestId)) {
43
+ throw new Error("worker_payload_source_provenance_receipt_invalid");
44
+ }
45
+ return provenance?.kind === "planner_plan_item_v1"
46
+ ? "assignment_only"
47
+ : "full_request";
48
+ }
49
+ /** Narrows a validated payload receipt to Planner-only dependency authority. */
50
+ export function projectWorkerPayloadPlannerItemProvenance(provenance, call) {
51
+ if (!provenance)
52
+ return undefined;
53
+ if (!isWorkerCapabilityPayloadSourceProvenanceValid(provenance, call, provenance.requestId)) {
54
+ throw new Error("worker_payload_source_provenance_receipt_invalid");
55
+ }
56
+ return provenance.kind === "planner_plan_item_v1" ? provenance : undefined;
57
+ }
58
+ function issueRequestScopedWorkerProvenance(params) {
59
+ const canonicalCall = params.head.state.calls.find(({ callId }) => callId === params.call.callId);
60
+ if (canonicalCall !== params.call || canonicalCall.roleId !== "worker") {
61
+ throw new Error("worker_payload_source_provenance_authority_invalid");
62
+ }
63
+ const caller = params.head.state.calls.find(({ callId }) => callId === canonicalCall.parentCallId);
64
+ if (!caller ||
65
+ caller.roleId === "planner" ||
66
+ caller.depth !== canonicalCall.depth - 1) {
67
+ throw new Error("worker_payload_source_provenance_parent_invalid");
68
+ }
69
+ const provenance = {
70
+ kind: "request_scoped_worker_v1",
71
+ requestId: params.head.state.requestId,
72
+ sourceRevision: params.head.revision,
73
+ callerCallId: caller.callId,
74
+ workerCallId: canonicalCall.callId,
75
+ invocationAttempt: canonicalCall.activationCount,
76
+ };
77
+ const authority = Object.freeze({
78
+ receipt: provenance,
79
+ head: params.head,
80
+ call: canonicalCall,
81
+ caller,
82
+ });
83
+ Object.defineProperty(provenance, WORKER_PAYLOAD_REQUEST_AUTHORITY, {
84
+ value: authority,
85
+ enumerable: false,
86
+ configurable: false,
87
+ writable: false,
88
+ });
89
+ return Object.freeze(provenance);
90
+ }
91
+ function assertCanonicalPayloadSourceAuthority(params) {
92
+ const canonicalCall = params.head.state.calls.find(({ callId }) => callId === params.call.callId);
93
+ const hasActiveWorkerAuthority = canonicalCall === params.call &&
94
+ canonicalCall.roleId === "worker" &&
95
+ canonicalCall.status === "active" &&
96
+ canonicalCall.resultRef === null &&
97
+ Number.isInteger(canonicalCall.activationCount) &&
98
+ canonicalCall.activationCount >= 1 &&
99
+ params.head.state.activeCallId === canonicalCall.callId &&
100
+ params.head.policy.authority.capabilityAuthorities.includes("worker");
101
+ if (!isCurrentRoleCallLedgerHead(params.ledger, params.head) ||
102
+ !hasActiveWorkerAuthority) {
103
+ throw new Error("worker_payload_source_provenance_authority_invalid");
104
+ }
105
+ }
106
+ function isCanonicalRequestScopedWorker(authority) {
107
+ const canonicalCall = authority.head.state.calls.find(({ callId }) => callId === authority.call.callId);
108
+ const canonicalCaller = authority.head.state.calls.find(({ callId }) => callId === authority.caller.callId);
109
+ return (canonicalCall === authority.call &&
110
+ canonicalCaller === authority.caller &&
111
+ authority.call.parentCallId === authority.caller.callId &&
112
+ authority.caller.roleId !== "planner" &&
113
+ authority.caller.depth === authority.call.depth - 1);
114
+ }
115
+ function readWorkerPayloadRequestAuthority(provenance) {
116
+ if (typeof provenance !== "object" || provenance === null)
117
+ return undefined;
118
+ const descriptor = Object.getOwnPropertyDescriptor(provenance, WORKER_PAYLOAD_REQUEST_AUTHORITY);
119
+ if (!descriptor ||
120
+ descriptor.enumerable ||
121
+ descriptor.configurable ||
122
+ descriptor.writable) {
123
+ return undefined;
124
+ }
125
+ const authority = descriptor.value;
126
+ if (typeof authority !== "object" || authority === null)
127
+ return undefined;
128
+ if (!Object.isFrozen(authority))
129
+ return undefined;
130
+ const candidate = authority;
131
+ return candidate.receipt === provenance ? candidate : undefined;
132
+ }
@@ -0,0 +1,5 @@
1
+ import type { ToolAvailabilityEntry } from "../../capabilities/tool-types.js";
2
+ import type { WorkerCapabilityCatalogGroup } from "../orchestration/worker-capabilities/index.js";
3
+ import type { RequestWorkerCapabilities } from "./execution-scope.js";
4
+ /** Reuses the request registry's facts, bounded by its offered capability set. */
5
+ export declare function resolveRequestCapabilityBriefEntries(capabilities: RequestWorkerCapabilities, groups: readonly WorkerCapabilityCatalogGroup[]): readonly ToolAvailabilityEntry[] | undefined;
@@ -0,0 +1,24 @@
1
+ /** Reuses the request registry's facts, bounded by its offered capability set. */
2
+ export function resolveRequestCapabilityBriefEntries(capabilities, groups) {
3
+ if (groups.length === 0)
4
+ return undefined;
5
+ const availableTools = capabilities.provider.getAvailableTools?.();
6
+ if (availableTools === undefined)
7
+ return undefined;
8
+ const groupIds = new Set(groups.map((group) => group.groupId));
9
+ const offered = capabilities.provider
10
+ .getDescriptors()
11
+ .filter((descriptor) => (descriptor.catalogGroups ?? ["other"]).some((id) => groupIds.has(id)));
12
+ const byOperation = new Map(availableTools.map((entry) => [entry.operationId, entry]));
13
+ const entries = [];
14
+ for (const descriptor of offered) {
15
+ const entry = byOperation.get(descriptor.capabilityId);
16
+ if (entry === undefined)
17
+ return undefined;
18
+ entries.push(Object.freeze({
19
+ ...entry,
20
+ catalogGroups: Object.freeze((descriptor.catalogGroups ?? ["other"]).filter((id) => groupIds.has(id))),
21
+ }));
22
+ }
23
+ return Object.freeze(entries);
24
+ }
@@ -1,3 +1,4 @@
1
+ import type { ToolAvailabilitySource } from "../capabilities/tool-availability.js";
1
2
  import type { WorkerCapabilityAdapterProvider } from "../orchestration/worker-capabilities/index.js";
2
3
  import type { AcceptedRequestInput, BoundRequestModelInvocationContext, RequestSessionSnapshot, RequestExecutionSeed, RequestIdentity, RequestLifecycleRuntime, RequestModelInvocationView, RequestModelRuntime, RequestMemoryRuntime, RequestPresentation } from "./contracts.js";
3
4
  import type { CompiledExecutionPolicy } from "./root-contract.js";
@@ -9,7 +10,7 @@ export type RequestCapabilityCompositionView = BoundRequestModelInvocationContex
9
10
  */
10
11
  export type RequestCapabilityExecutionView = Readonly<Omit<RequestExecutionSeed, "sessionArtifactPaths" | "sessionMemory" | "longTermMemory">> & BoundRequestModelInvocationContext;
11
12
  export type RequestWorkerCapabilities = Readonly<{
12
- provider: WorkerCapabilityAdapterProvider<RequestCapabilityExecutionView>;
13
+ provider: WorkerCapabilityAdapterProvider<RequestCapabilityExecutionView> & Partial<ToolAvailabilitySource>;
13
14
  executionContext: RequestCapabilityExecutionView;
14
15
  }>;
15
16
  export type RequestExecutionPolicyFacet = Readonly<{
@@ -42,7 +42,7 @@ export const EXECUTION_AGENT_ROLE_EXECUTORS = projectRequestRoleExecutorRegistry
42
42
  ]);
43
43
  const SUPERVISOR_WORKER_V1_POLICY_DEFINITION = Object.freeze({
44
44
  id: "supervisor-worker-v1",
45
- version: 1,
45
+ version: 2,
46
46
  rootContract: SUPERVISOR_ROOT_CONTRACT,
47
47
  roleExecutors: REQUEST_ROLE_EXECUTORS,
48
48
  capabilityAuthorities: Object.freeze(["worker"]),
@@ -1,6 +1,7 @@
1
1
  import type { RuntimeConfig, ToolRegistry } from "../ports.js";
2
2
  import type { ToolRequestAttachment } from "../../capabilities/tool-types.js";
3
3
  import type { WorkerCapabilityAdapterProvider } from "../orchestration/worker-capabilities/index.js";
4
+ import { type ToolAvailabilitySource } from "../capabilities/tool-availability.js";
4
5
  import type { ExecutionPolicyAuthoritySnapshot } from "../orchestration/role-calls/index.js";
5
6
  import type { RequestCapabilityCompositionView, RequestCapabilityExecutionView } from "./execution-scope.js";
6
7
  type RequestWorkerCapabilityProviderParams<TRequest> = Readonly<{
@@ -14,5 +15,5 @@ type RequestWorkerCapabilityProviderParams<TRequest> = Readonly<{
14
15
  * Creates one lazy, request-scoped Worker capability source from declarative
15
16
  * role config and the neutral runtime Tool Registry.
16
17
  */
17
- export declare function createRequestWorkerCapabilityProvider(params: RequestWorkerCapabilityProviderParams<RequestCapabilityCompositionView>): WorkerCapabilityAdapterProvider<RequestCapabilityExecutionView>;
18
+ export declare function createRequestWorkerCapabilityProvider(params: RequestWorkerCapabilityProviderParams<RequestCapabilityCompositionView>): WorkerCapabilityAdapterProvider<RequestCapabilityExecutionView> & ToolAvailabilitySource;
18
19
  export {};
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import { createBundledPluginSkillProvider, createConfiguredSkillProvider, } from "../adapters/configured-skill-provider.js";
3
3
  import { createRegisteredToolWorkerCapabilityProvider } from "../adapters/registered-tool-worker-capabilities.js";
4
4
  import { createRequestRuntimeToolRegistry } from "../capabilities/request-runtime-tool-registry.js";
5
+ import { projectAvailableTools, } from "../capabilities/tool-availability.js";
5
6
  import { createRequestWorkerCapabilityPayloadAuthor } from "./worker-capability-payload.js";
6
7
  /**
7
8
  * Creates one lazy, request-scoped Worker capability source from declarative
@@ -35,7 +36,7 @@ export function createRequestWorkerCapabilityProvider(params) {
35
36
  }
36
37
  return requestSkillProvider;
37
38
  }
38
- return createRegisteredToolWorkerCapabilityProvider({
39
+ const provider = createRegisteredToolWorkerCapabilityProvider({
39
40
  getRequestToolRegistry,
40
41
  requestId: params.request.requestId,
41
42
  sessionId: params.request.sessionId,
@@ -58,4 +59,8 @@ export function createRequestWorkerCapabilityProvider(params) {
58
59
  nextApprovalId: () => `approval:${randomUUID()}`,
59
60
  onEvent: params.request.onEvent,
60
61
  });
62
+ return Object.freeze({
63
+ ...provider,
64
+ getAvailableTools: () => projectAvailableTools(getRequestToolRegistry().listNormalInvocations?.()),
65
+ });
61
66
  }
@@ -138,13 +138,15 @@ function payloadMessages(request, input) {
138
138
  : {}),
139
139
  ...(request.modelPolicy ? { modelPolicy: request.modelPolicy } : {}),
140
140
  });
141
- const requestSource = projectRequestSource({
142
- requestId: request.requestId,
143
- prompt: request.prompt,
144
- modelStep: input.modelStep,
145
- callId,
146
- historyMessages: request.historyMessages,
147
- });
141
+ const requestSource = input.requestSourceProjection === "full_request"
142
+ ? projectRequestSource({
143
+ requestId: request.requestId,
144
+ prompt: request.prompt,
145
+ modelStep: input.modelStep,
146
+ callId,
147
+ historyMessages: request.historyMessages,
148
+ })
149
+ : undefined;
148
150
  const projectedContext = projectPayloadContext(input.context);
149
151
  traceDebug("runtime.worker_capability_payload_context", "projected", {
150
152
  requestId: request.requestId,
@@ -156,6 +158,7 @@ function payloadMessages(request, input) {
156
158
  relatedArtifactContextCount: projectedContext.relatedArtifactMessages.length,
157
159
  sourceRelatedArtifactContextCount: input.context.relatedArtifactContexts?.length ?? 0,
158
160
  hasTargetContext: input.context.targetContext !== undefined,
161
+ requestSourceProjection: input.requestSourceProjection,
159
162
  });
160
163
  try {
161
164
  return projectRequestContext({
@@ -163,7 +166,7 @@ function payloadMessages(request, input) {
163
166
  historyMessages: [],
164
167
  prompt: `Canonical runtime context:\n${JSON.stringify(projectedContext.metadata)}`,
165
168
  referenceMessages: [
166
- buildRequestSourceMessage(requestSource),
169
+ ...(requestSource ? [buildRequestSourceMessage(requestSource)] : []),
167
170
  ...projectedContext.relatedArtifactMessages,
168
171
  ],
169
172
  ...(projectedContext.targetContentMessage
@@ -21,15 +21,16 @@ export function buildExecutionAgentInstructions(params) {
21
21
  ? "Use respond only when the request can be answered completely and honestly now. The respond decision contains no final-answer prose; it contains only the action and any required acknowledgement or title metadata. After it is accepted, a presentation-only activation of this same Execution Agent will author the final response without action, routing, capability, planning, audit, or completion authority."
22
22
  : "Respond is not available because the canonical completion gate is closed. Continue through an offered action or report a truthful blocker.",
23
23
  "The user's explicit request is already the authority to perform the offered action within its stated scope. Treat 'can you', 'could you', 'would you', and equivalent phrasing in any language followed by an action as a request to perform that action, not as a request for another confirmation. Do not ask for confirmation merely because an offered capability has an external effect; the runtime enforces any approval that is actually required.",
24
- "Use blocked only for a truthful user-facing blocker when no offered action can establish the missing outcome. Runtime or provider failures are not blocked decisions.",
24
+ "Before changing an existing resource, establish from the active user request and user-established context both the intended target and the permitted scope of change. Discovering, reading, or having access to a resource does not authorize selecting it as the target. For a creation request, create a new resource without damaging existing resources. When the target and scope are already clear and authorized, proceed without asking for confirmation again.",
25
+ "Use blocked for a truthful user-facing blocker when no offered action can establish the missing outcome, or when material ambiguity about the intended target or permitted scope of any change to an existing resource requires user clarification. If an offered read-only observation can resolve the ambiguity, perform it before asking. If the ambiguity remains, stop before mutation and put one focused clarification question in blocked.response. Availability of a mutation capability does not resolve missing user intent. Runtime or provider failures are not blocked decisions.",
25
26
  params.hasCapabilities
26
- ? `When external observation or effect is required, select one offered capability and provide a short client-facing status in intent, at most ${CAPABILITY_INTENT_MAX_LENGTH} characters. Intent is presentation metadata only: do not put sources, controls, payload details, or execution instructions in it. When the invocation schema requires operationObjective, state the complete bounded operation for that invocation alone. operationObjective is internal execution input constrained by the active user request and selected capability; it must not add unrelated outcomes, describe the whole workflow, or broaden the request. Observation capabilities may be batched only when independent; never batch mutations. The runtime determines exact duplicate operations only after every invocation is fully materialized. A capability receipt proves only its exact reported outcome.`
27
+ ? `When external observation or an authorized effect is required, select one offered capability and provide a short client-facing status in intent, at most ${CAPABILITY_INTENT_MAX_LENGTH} characters. Intent is presentation metadata only: do not put sources, controls, payload details, or execution instructions in it. When the invocation schema requires operationObjective, state the complete bounded operation for that invocation alone. operationObjective is internal execution input constrained by the active user request and selected capability; it must not add unrelated outcomes, describe the whole workflow, or broaden the request. Observation capabilities may be batched only when independent; never batch mutations. The runtime determines exact duplicate operations only after every invocation is fully materialized. A capability receipt proves only its exact reported outcome.`
27
28
  : "No capability is offered in the active scope for this decision. Do not claim external observation or effects.",
28
29
  params.includeWorkingDirectory
29
30
  ? "For a capability invocation, workingDirectory may establish one immutable portable agent-root-relative execution base for this request. Use null only when the agent root itself is the correct base. This selection scopes execution but does not prove any effect."
30
31
  : "The canonical working directory is already established when present in runtime_execution_state_v1; do not replace or reinterpret it.",
31
32
  "Before every decision, identify each distinct requested outcome and what evidence would establish it. Reasoning may establish an informational outcome, but a requested new observation, file read, mutation, artifact, or other external effect requires its corresponding successful capability result.",
32
- "Generated prose, a promise, or a proposed command does not perform an external effect. If such a requested effect is not yet established and an offered capability can establish it, respond is invalid: invoke that capability instead.",
33
+ "Generated prose, a promise, or a proposed command does not perform an external effect. If a required read-only observation is not yet established and an offered capability can establish it, invoke that capability before responding or asking for clarification. If a requested mutation is not yet established, its intended target and scope are clear, and an offered capability can establish it within that scope, respond is invalid: invoke that capability instead.",
33
34
  "Immediately before choosing respond, verify that no requested external effect remains without a successful visible capability result or a completed subordinate result that explicitly establishes it. Never use respond to ask permission for a reversible file creation or update that the user explicitly requested.",
34
35
  "Never claim that a file was read, compared, created, changed, or verified unless the exact visible capability results establish that claim.",
35
36
  params.allowPlanner
@@ -0,0 +1,14 @@
1
+ import type { ChatMessage } from "../../../model-gateway/types.js";
2
+ import type { RequestContextPinnedPart } from "../../context/request-context-contracts.js";
3
+ import { type WorkerCapabilityCatalogGroup, type WorkerCapabilityDescriptor } from "../../orchestration/worker-capabilities/index.js";
4
+ export declare const PLANNER_WORKER_CAPABILITY_CATALOG_KIND: "runtime_planner_worker_capability_catalog_v1";
5
+ export type PlannerWorkerCapabilityCatalogGroup = Readonly<WorkerCapabilityCatalogGroup & {
6
+ description: string;
7
+ }>;
8
+ export declare function projectPlannerWorkerCapabilityCatalogGroups(descriptors: readonly WorkerCapabilityDescriptor[]): readonly PlannerWorkerCapabilityCatalogGroup[];
9
+ export declare function buildPlannerReferenceParts(params: Readonly<{
10
+ callId: string;
11
+ invocationAttempt: number;
12
+ exactMessages: readonly ChatMessage[];
13
+ catalogGroups: readonly PlannerWorkerCapabilityCatalogGroup[];
14
+ }>): readonly RequestContextPinnedPart[];
@@ -0,0 +1,87 @@
1
+ import { projectWorkerCapabilityCatalogGroups, } from "../../orchestration/worker-capabilities/index.js";
2
+ export const PLANNER_WORKER_CAPABILITY_CATALOG_KIND = "runtime_planner_worker_capability_catalog_v1";
3
+ export function projectPlannerWorkerCapabilityCatalogGroups(descriptors) {
4
+ const catalogGroups = projectWorkerCapabilityCatalogGroups(descriptors);
5
+ return Object.freeze(catalogGroups
6
+ .map((group) => Object.freeze({
7
+ ...group,
8
+ description: describeCatalogGroup(group.groupId, descriptors),
9
+ }))
10
+ .sort((left, right) => compareAscii(left.groupId, right.groupId)));
11
+ }
12
+ export function buildPlannerReferenceParts(params) {
13
+ const exactPart = Object.freeze({
14
+ sourceRef: `planner-reference:${params.callId}:${params.invocationAttempt}`,
15
+ category: "request_reference",
16
+ retention: "exact",
17
+ messages: params.exactMessages,
18
+ });
19
+ if (params.catalogGroups.length === 0)
20
+ return Object.freeze([exactPart]);
21
+ return Object.freeze([
22
+ exactPart,
23
+ Object.freeze({
24
+ sourceRef: [
25
+ "planner-worker-capability-catalog",
26
+ params.callId,
27
+ String(params.invocationAttempt),
28
+ ].join(":"),
29
+ category: "request_reference",
30
+ retention: "compactable",
31
+ messages: Object.freeze([
32
+ buildCatalogMessage("detailed", params.catalogGroups),
33
+ ]),
34
+ compactMessages: Object.freeze([
35
+ buildCatalogMessage("compact", params.catalogGroups),
36
+ ]),
37
+ }),
38
+ ]);
39
+ }
40
+ function buildCatalogMessage(projection, catalogGroups) {
41
+ const capsule = projection === "compact"
42
+ ? {
43
+ kind: PLANNER_WORKER_CAPABILITY_CATALOG_KIND,
44
+ authority: "runtime_registry",
45
+ presenceEffect: "passive_not_user_intent",
46
+ projection,
47
+ catalogGroups,
48
+ }
49
+ : {
50
+ kind: PLANNER_WORKER_CAPABILITY_CATALOG_KIND,
51
+ authority: "runtime_registry",
52
+ presenceEffect: "passive_worker_routing_metadata_not_user_intent_or_execution_authority",
53
+ applicability: "planner_worker_invoke_role_group_routing_only",
54
+ lifetime: "request_role_call_projection_only",
55
+ projection,
56
+ scopeSemantics: {
57
+ groupCombination: "or_union",
58
+ scopeEffect: "narrows_worker_catalog_only",
59
+ capabilitySelection: "worker_owned",
60
+ },
61
+ catalogGroups,
62
+ };
63
+ return Object.freeze({
64
+ role: "user",
65
+ content: JSON.stringify(capsule),
66
+ });
67
+ }
68
+ function describeCatalogGroup(groupId, descriptors) {
69
+ const members = descriptors.filter((descriptor) => (descriptor.catalogGroups ?? ["other"]).includes(groupId));
70
+ const routingCapabilities = [
71
+ ...new Set(members.flatMap(({ routingCapability }) => routingCapability ? [routingCapability] : [])),
72
+ ].sort(compareAscii);
73
+ const developmentRoles = [
74
+ ...new Set(members.flatMap(({ developmentRoles: roles }) => roles ?? [])),
75
+ ].sort(compareAscii);
76
+ return [
77
+ `routingCapabilities=${routingCapabilities.join(",")}`,
78
+ `developmentRoles=${developmentRoles.join(",")}`,
79
+ ].join("\n");
80
+ }
81
+ function compareAscii(left, right) {
82
+ if (left < right)
83
+ return -1;
84
+ if (left > right)
85
+ return 1;
86
+ return 0;
87
+ }
@@ -1,14 +1,14 @@
1
1
  import { type RoleCallFrame, type RoleCallPlanBinding, type RoleCallWorkerCapabilityScope } from "../../orchestration/role-calls/index.js";
2
- import { type RuntimeDelegateRoleId } from "../../orchestration/roles.js";
3
2
  export declare const PLANNER_DECISION_MODEL_STEP: "planner.decision";
4
3
  export declare const PLANNER_ROLE_ID: "planner";
5
- export declare const PLANNER_CHILD_ROLE_IDS: readonly ["planner", "worker", "researcher", "reviewer"];
4
+ export declare const PLANNER_CHILD_ROLE_IDS: readonly ["worker"];
6
5
  export declare const PLANNER_OBJECTIVE_MAX_LENGTH = 8192;
7
6
  export declare const PLANNER_RESULT_MAX_LENGTH = 8192;
7
+ export declare const PLANNER_DISPATCH_ITEM_COUNT = 1;
8
8
  export declare const PLANNER_DECISION_ACTIONS: readonly ["return_result", "return_failure", "invoke_role"];
9
9
  export type PlannerDecisionAction = (typeof PLANNER_DECISION_ACTIONS)[number];
10
10
  export type PlannerDecisionSelectionKind = PlannerDecisionAction;
11
- export type PlannerChildRoleId = RuntimeDelegateRoleId;
11
+ export type PlannerChildRoleId = (typeof PLANNER_CHILD_ROLE_IDS)[number];
12
12
  export type PlannerReturnResultDecision = Readonly<{
13
13
  action: "return_result";
14
14
  result: string;
@@ -26,8 +26,6 @@ export type PlannerInvokeRoleDecision = Readonly<PlannerInvokeRoleDecisionBase &
26
26
  roleId: "worker";
27
27
  workingDirectory: string;
28
28
  workerCapabilityScope?: RoleCallWorkerCapabilityScope;
29
- }> | Readonly<PlannerInvokeRoleDecisionBase & {
30
- roleId: Exclude<PlannerChildRoleId, "worker">;
31
29
  }>;
32
30
  export type PlannerDecisionPlanContext = Readonly<{
33
31
  mode: "declare";
@@ -1,18 +1,18 @@
1
1
  import { MODEL_STEPS } from "../../../shared/model-steps.js";
2
2
  import { normalizeRoleCallWorkingDirectory, ROLE_CALL_OBJECTIVE_MAX_LENGTH, ROLE_CALL_RESULT_MAX_LENGTH, } from "../../orchestration/role-calls/index.js";
3
- import { isRuntimeDelegateRoleId, RUNTIME_DELEGATE_ROLE_IDS, } from "../../orchestration/roles.js";
4
3
  export const PLANNER_DECISION_MODEL_STEP = MODEL_STEPS.PLANNER_DECISION;
5
4
  export const PLANNER_ROLE_ID = "planner";
6
- export const PLANNER_CHILD_ROLE_IDS = RUNTIME_DELEGATE_ROLE_IDS;
5
+ export const PLANNER_CHILD_ROLE_IDS = Object.freeze(["worker"]);
7
6
  export const PLANNER_OBJECTIVE_MAX_LENGTH = ROLE_CALL_OBJECTIVE_MAX_LENGTH;
8
7
  export const PLANNER_RESULT_MAX_LENGTH = ROLE_CALL_RESULT_MAX_LENGTH;
8
+ export const PLANNER_DISPATCH_ITEM_COUNT = 1;
9
9
  export const PLANNER_DECISION_ACTIONS = Object.freeze([
10
10
  "return_result",
11
11
  "return_failure",
12
12
  "invoke_role",
13
13
  ]);
14
14
  export function isPlannerChildRoleId(value) {
15
- return isRuntimeDelegateRoleId(value);
15
+ return value === "worker";
16
16
  }
17
17
  export function projectPlannerDecisionCallIdentity(call) {
18
18
  if (call.roleId !== PLANNER_ROLE_ID ||
@@ -1,10 +1,11 @@
1
1
  import type { ModelGatewayJsonSchemaFormat } from "../../../model-gateway/types.js";
2
+ import { type RuntimeDelegateRoleId } from "../../orchestration/roles.js";
2
3
  import type { WorkerCapabilityCatalogGroup } from "../../orchestration/worker-capabilities/index.js";
3
4
  import { type PlannerChildRoleId, type PlannerDecisionPlanContext } from "./contracts.js";
4
5
  export declare function createPlannerDecisionFormat(options?: Readonly<{
5
- availableChildRoleIds?: readonly PlannerChildRoleId[];
6
+ availableChildRoleIds?: readonly RuntimeDelegateRoleId[];
6
7
  availableWorkerCapabilityCatalog?: readonly WorkerCapabilityCatalogGroup[];
7
8
  inheritedWorkingDirectory?: string;
8
9
  planContext?: PlannerDecisionPlanContext;
9
10
  }>): ModelGatewayJsonSchemaFormat;
10
- export declare function normalizeAvailableChildRoleIds(values: readonly PlannerChildRoleId[]): readonly PlannerChildRoleId[];
11
+ export declare function normalizeAvailableChildRoleIds(values: readonly RuntimeDelegateRoleId[]): readonly PlannerChildRoleId[];