@jangts/agent-core 0.3.5 → 0.5.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 (288) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +33 -31
  3. package/development/docs/README.en.md +2 -2
  4. package/development/docs/acceptance.en.md +2 -2
  5. package/development/docs/agent-development.en.md +1 -1
  6. package/development/docs/api/README.en.md +6 -2
  7. package/development/docs/api/README.md +4 -0
  8. package/development/docs/api/configuration-in-workflow.en.md +403 -0
  9. package/development/docs/api/configuration-in-workflow.md +403 -0
  10. package/development/docs/api/core.en.md +7 -7
  11. package/development/docs/api/core.md +6 -6
  12. package/development/docs/api/decorators.en.md +20 -0
  13. package/development/docs/api/decorators.md +20 -0
  14. package/development/docs/api/examples.en.md +1 -1
  15. package/development/docs/api/examples.md +1 -1
  16. package/development/docs/api/kits.en.md +22 -4
  17. package/development/docs/api/kits.md +22 -4
  18. package/development/docs/api/knowledge-answering.en.md +4 -1
  19. package/development/docs/api/knowledge-answering.md +4 -1
  20. package/development/docs/api/mock.en.md +2 -0
  21. package/development/docs/api/mock.md +2 -0
  22. package/development/docs/api/observability.en.md +37 -11
  23. package/development/docs/api/observability.md +64 -11
  24. package/development/docs/api/reference.en.md +876 -657
  25. package/development/docs/api/reference.md +662 -508
  26. package/development/docs/api/support.en.md +55 -9
  27. package/development/docs/api/support.md +53 -7
  28. package/development/docs/api/types.en.md +36 -1
  29. package/development/docs/api/types.md +44 -0
  30. package/development/docs/api/workflow-views.en.md +64 -0
  31. package/development/docs/api/workflow-views.md +78 -0
  32. package/development/docs/api/workflow.en.md +6 -2
  33. package/development/docs/api/workflow.md +6 -2
  34. package/development/docs/basic-usage.en.md +1 -1
  35. package/development/docs/basic-usage.md +1 -1
  36. package/development/docs/create-app.en.md +1 -1
  37. package/development/docs/examples/registration/associated.mjs +8 -0
  38. package/development/docs/examples/registration/independent.mjs +20 -0
  39. package/development/docs/examples/registration/protocol.mjs +48 -0
  40. package/development/docs/examples/registration/run.mjs +47 -0
  41. package/development/docs/examples/registration/tools.mjs +75 -0
  42. package/development/docs/examples/registration/workflow.mjs +109 -0
  43. package/development/docs/flows/knowledge-maintenance.en.md +1 -1
  44. package/development/docs/materials.en.md +1 -1
  45. package/development/docs/mechanisms.en.md +2 -2
  46. package/development/docs/mechanisms.md +1 -1
  47. package/development/docs/operations.en.md +1 -1
  48. package/development/docs/records.en.md +1 -1
  49. package/development/docs/registration.en.md +4 -4
  50. package/development/docs/registration.md +2 -2
  51. package/development/skills/agent-core-app/SKILL.md +16 -4
  52. package/development/skills/agent-core-app/templates/node-ts/README.md.tpl +1 -1
  53. package/development/skills/agent-core-app/templates/node-ts/src/catalog.ts.tpl +2 -2
  54. package/development/skills/agent-core-app/templates/node-ts/test/app.test.mjs.tpl +1 -1
  55. package/dist/cjs/capabilities/index.js +5 -12
  56. package/dist/cjs/capabilities/invocation.js +21 -1
  57. package/dist/cjs/capabilities/model.js +56 -12
  58. package/dist/cjs/capabilities/tool-conditions.js +65 -0
  59. package/dist/cjs/capabilities/tool-runtime.js +18 -4
  60. package/dist/cjs/capabilities/tools.js +12 -17
  61. package/dist/cjs/context/audit.js +5 -8
  62. package/dist/cjs/context/index.js +3 -4
  63. package/dist/cjs/diagnostics/index.js +51 -3
  64. package/dist/cjs/diagnostics/native-sub-flow.js +106 -0
  65. package/dist/cjs/diagnostics/sub-flow.js +278 -32
  66. package/dist/cjs/execution/engine.js +3 -2
  67. package/dist/cjs/execution/events.js +5 -5
  68. package/dist/cjs/execution/reporting.js +18 -28
  69. package/dist/cjs/execution/workflow-chain.js +211 -0
  70. package/dist/cjs/execution/workflow-graph.js +72 -0
  71. package/dist/cjs/execution/workflow.js +34 -6
  72. package/dist/cjs/index.js +21 -17
  73. package/dist/cjs/kits/aggregation.js +17 -14
  74. package/dist/cjs/kits/answering/checks.js +2 -1
  75. package/dist/cjs/kits/answering/flow.js +24 -21
  76. package/dist/cjs/kits/answering/tasks.js +30 -25
  77. package/dist/cjs/kits/delivery.js +36 -24
  78. package/dist/cjs/kits/domains/catalog.js +113 -0
  79. package/dist/cjs/kits/domains/index.js +20 -0
  80. package/dist/cjs/kits/{intents → domains}/registry.js +77 -31
  81. package/dist/cjs/kits/{intents → domains}/scopes.js +21 -21
  82. package/dist/cjs/kits/index.js +14 -13
  83. package/dist/cjs/kits/knowledge/catalog.js +33 -30
  84. package/dist/cjs/kits/policies.js +3 -2
  85. package/dist/cjs/kits/presentation/formats.js +110 -0
  86. package/dist/cjs/kits/presentation/index.js +10 -5
  87. package/dist/cjs/kits/presentation/outputs.js +2 -1
  88. package/dist/cjs/kits/reflection.js +2 -2
  89. package/dist/cjs/kits/retrieval.js +7 -1
  90. package/dist/cjs/kits/text-blocks.js +101 -0
  91. package/dist/cjs/kits/tools.js +247 -158
  92. package/dist/cjs/model/decision-retry.js +2 -1
  93. package/dist/cjs/model/index.js +2 -6
  94. package/dist/cjs/model/interactions/calls.js +61 -0
  95. package/dist/cjs/model/interactions/json-object.js +11 -11
  96. package/dist/cjs/model/interactions/native-functions.js +17 -23
  97. package/dist/cjs/model/message-diagnostics.js +13 -3
  98. package/dist/cjs/model/options.js +2 -0
  99. package/dist/cjs/model/preparation.js +39 -6
  100. package/dist/cjs/model/runner.js +34 -5
  101. package/dist/cjs/model/selection-transport.js +4 -4
  102. package/dist/cjs/model/token-budget.js +3 -0
  103. package/dist/cjs/model/transports.js +3 -2
  104. package/dist/cjs/structs/index.js +7 -6
  105. package/dist/cjs/structs/kits/domains/scopes.js +2 -0
  106. package/dist/cjs/structs/kits/presentation/formats.js +2 -0
  107. package/dist/cjs/structs/kits/text-blocks.js +11 -0
  108. package/dist/cjs/structs/model/session.js +11 -0
  109. package/dist/cjs/structs/support/associations.js +2 -0
  110. package/dist/cjs/support/associations.js +79 -0
  111. package/dist/cjs/support/context/nodes.js +48 -45
  112. package/dist/cjs/support/context/processing.js +6 -3
  113. package/dist/cjs/support/context/snapshot.js +11 -1
  114. package/dist/cjs/support/decorators/index.js +45 -3
  115. package/dist/cjs/support/index.js +1 -0
  116. package/dist/cjs/support/model/capabilities.js +35 -5
  117. package/dist/cjs/support/model/chat-completions.js +11 -2
  118. package/dist/cjs/support/model/completion/calls.js +10 -56
  119. package/dist/cjs/support/model/preview-rules.js +11 -11
  120. package/dist/cjs/support/model/reply-preview.js +3 -3
  121. package/dist/cjs/support/model/session.js +152 -0
  122. package/dist/cjs/support/model/stage-transport.js +8 -8
  123. package/dist/cjs/support/model/transports.js +5 -2
  124. package/dist/cjs/support/tools.js +42 -17
  125. package/dist/cjs/utils/invocation.js +1 -0
  126. package/dist/esm/capabilities/index.d.ts +5 -10
  127. package/dist/esm/capabilities/index.js +5 -9
  128. package/dist/esm/capabilities/invocation.js +21 -1
  129. package/dist/esm/capabilities/model.d.ts +17 -13
  130. package/dist/esm/capabilities/model.js +54 -10
  131. package/dist/esm/capabilities/tool-conditions.d.ts +9 -0
  132. package/dist/esm/capabilities/tool-conditions.js +59 -0
  133. package/dist/esm/capabilities/tool-runtime.js +18 -4
  134. package/dist/esm/capabilities/tools.d.ts +3 -3
  135. package/dist/esm/capabilities/tools.js +12 -17
  136. package/dist/esm/context/audit.js +5 -8
  137. package/dist/esm/context/index.d.ts +3 -4
  138. package/dist/esm/context/index.js +3 -4
  139. package/dist/esm/diagnostics/index.d.ts +1 -0
  140. package/dist/esm/diagnostics/index.js +48 -2
  141. package/dist/esm/diagnostics/native-sub-flow.d.ts +94 -0
  142. package/dist/esm/diagnostics/native-sub-flow.js +101 -0
  143. package/dist/esm/diagnostics/sub-flow.d.ts +56 -4
  144. package/dist/esm/diagnostics/sub-flow.js +271 -32
  145. package/dist/esm/execution/engine.d.ts +1 -0
  146. package/dist/esm/execution/engine.js +3 -2
  147. package/dist/esm/execution/events.js +5 -5
  148. package/dist/esm/execution/reporting.d.ts +6 -12
  149. package/dist/esm/execution/reporting.js +19 -29
  150. package/dist/esm/execution/workflow-chain.d.ts +3 -0
  151. package/dist/esm/execution/workflow-chain.js +208 -0
  152. package/dist/esm/execution/workflow-graph.d.ts +7 -0
  153. package/dist/esm/execution/workflow-graph.js +68 -0
  154. package/dist/esm/execution/workflow.d.ts +6 -0
  155. package/dist/esm/execution/workflow.js +34 -6
  156. package/dist/esm/index.d.ts +19 -13
  157. package/dist/esm/index.js +18 -15
  158. package/dist/esm/kits/aggregation.d.ts +1 -1
  159. package/dist/esm/kits/aggregation.js +17 -14
  160. package/dist/esm/kits/answering/checks.js +2 -1
  161. package/dist/esm/kits/answering/flow.js +24 -21
  162. package/dist/esm/kits/answering/tasks.d.ts +6 -6
  163. package/dist/esm/kits/answering/tasks.js +30 -25
  164. package/dist/esm/kits/delivery.d.ts +0 -9
  165. package/dist/esm/kits/delivery.js +36 -24
  166. package/dist/esm/kits/domains/catalog.d.ts +42 -0
  167. package/dist/esm/kits/domains/catalog.js +110 -0
  168. package/dist/esm/kits/domains/index.d.ts +4 -0
  169. package/dist/esm/kits/domains/index.js +4 -0
  170. package/dist/esm/kits/domains/registry.d.ts +100 -0
  171. package/dist/esm/kits/{intents → domains}/registry.js +77 -31
  172. package/dist/esm/kits/{intents → domains}/scopes.d.ts +18 -18
  173. package/dist/esm/kits/{intents → domains}/scopes.js +21 -21
  174. package/dist/esm/kits/index.d.ts +6 -5
  175. package/dist/esm/kits/index.js +6 -5
  176. package/dist/esm/kits/knowledge/catalog.js +33 -30
  177. package/dist/esm/kits/policies.d.ts +1 -1
  178. package/dist/esm/kits/policies.js +3 -2
  179. package/dist/esm/kits/presentation/formats.d.ts +42 -0
  180. package/dist/esm/kits/presentation/formats.js +105 -0
  181. package/dist/esm/kits/presentation/index.d.ts +14 -5
  182. package/dist/esm/kits/presentation/index.js +10 -5
  183. package/dist/esm/kits/presentation/outputs.js +2 -1
  184. package/dist/esm/kits/reflection.js +3 -3
  185. package/dist/esm/kits/retrieval.js +7 -1
  186. package/dist/esm/kits/text-blocks.d.ts +24 -0
  187. package/dist/esm/kits/text-blocks.js +97 -0
  188. package/dist/esm/kits/tools.d.ts +69 -52
  189. package/dist/esm/kits/tools.js +247 -158
  190. package/dist/esm/model/decision-retry.d.ts +2 -0
  191. package/dist/esm/model/decision-retry.js +2 -1
  192. package/dist/esm/model/index.d.ts +2 -6
  193. package/dist/esm/model/index.js +2 -6
  194. package/dist/esm/model/interactions/calls.d.ts +40 -0
  195. package/dist/esm/model/interactions/calls.js +58 -0
  196. package/dist/esm/model/interactions/json-object.js +11 -11
  197. package/dist/esm/model/interactions/native-functions.js +17 -23
  198. package/dist/esm/model/message-diagnostics.d.ts +6 -5
  199. package/dist/esm/model/message-diagnostics.js +13 -3
  200. package/dist/esm/model/options.js +2 -0
  201. package/dist/esm/model/preparation.js +39 -6
  202. package/dist/esm/model/runner.d.ts +2 -0
  203. package/dist/esm/model/runner.js +34 -5
  204. package/dist/esm/model/selection-transport.js +4 -4
  205. package/dist/esm/model/token-budget.js +3 -0
  206. package/dist/esm/model/transports.d.ts +2 -1
  207. package/dist/esm/model/transports.js +3 -2
  208. package/dist/esm/structs/capabilities/invocation.d.ts +3 -1
  209. package/dist/esm/structs/capabilities/model.d.ts +42 -11
  210. package/dist/esm/structs/capabilities/tools.d.ts +16 -7
  211. package/dist/esm/structs/common.d.ts +3 -1
  212. package/dist/esm/structs/debug.d.ts +36 -20
  213. package/dist/esm/structs/execution/workflow-views.d.ts +123 -0
  214. package/dist/esm/structs/execution/workflow.d.ts +4 -3
  215. package/dist/esm/structs/index.d.ts +8 -6
  216. package/dist/esm/structs/index.js +7 -6
  217. package/dist/esm/structs/kits/answering/tasks.d.ts +2 -2
  218. package/dist/esm/structs/kits/{intents → domains}/catalog.d.ts +20 -20
  219. package/dist/esm/structs/kits/{intents → domains}/registry.d.ts +24 -21
  220. package/dist/esm/structs/kits/{intents → domains}/scopes.d.ts +9 -9
  221. package/dist/esm/structs/kits/domains/scopes.js +1 -0
  222. package/dist/esm/structs/kits/presentation/formats.d.ts +42 -0
  223. package/dist/esm/structs/kits/presentation/formats.js +1 -0
  224. package/dist/esm/structs/kits/text-blocks.d.ts +25 -0
  225. package/dist/esm/structs/kits/text-blocks.js +10 -0
  226. package/dist/esm/structs/kits/tools.d.ts +82 -83
  227. package/dist/esm/structs/model/interactions.d.ts +18 -11
  228. package/dist/esm/structs/model/messages.d.ts +34 -2
  229. package/dist/esm/structs/model/runtime.d.ts +9 -0
  230. package/dist/esm/structs/model/session.d.ts +29 -0
  231. package/dist/esm/structs/model/session.js +10 -0
  232. package/dist/esm/structs/support/associations.d.ts +22 -0
  233. package/dist/esm/structs/support/associations.js +1 -0
  234. package/dist/esm/structs/support/model/interactions.d.ts +2 -2
  235. package/dist/esm/structs/support/model/messages.d.ts +6 -13
  236. package/dist/esm/structs/support/tools.d.ts +23 -23
  237. package/dist/esm/support/associations.d.ts +26 -0
  238. package/dist/esm/support/associations.js +76 -0
  239. package/dist/esm/support/context/nodes.js +48 -45
  240. package/dist/esm/support/context/processing.js +6 -3
  241. package/dist/esm/support/context/snapshot.js +11 -1
  242. package/dist/esm/support/decorators/index.d.ts +13 -2
  243. package/dist/esm/support/decorators/index.js +40 -3
  244. package/dist/esm/support/decorators/pool.d.ts +6 -5
  245. package/dist/esm/support/decorators/types.d.ts +3 -1
  246. package/dist/esm/support/index.d.ts +1 -0
  247. package/dist/esm/support/index.js +1 -0
  248. package/dist/esm/support/model/capabilities.d.ts +8 -3
  249. package/dist/esm/support/model/capabilities.js +35 -5
  250. package/dist/esm/support/model/chat-completions.js +11 -2
  251. package/dist/esm/support/model/completion/calls.d.ts +6 -34
  252. package/dist/esm/support/model/completion/calls.js +8 -55
  253. package/dist/esm/support/model/index.d.ts +1 -1
  254. package/dist/esm/support/model/preview-rules.d.ts +13 -8
  255. package/dist/esm/support/model/preview-rules.js +11 -11
  256. package/dist/esm/support/model/reply-preview.d.ts +2 -2
  257. package/dist/esm/support/model/reply-preview.js +3 -3
  258. package/dist/esm/support/model/session.d.ts +61 -0
  259. package/dist/esm/support/model/session.js +148 -0
  260. package/dist/esm/support/model/stage-transport.d.ts +1 -1
  261. package/dist/esm/support/model/stage-transport.js +9 -9
  262. package/dist/esm/support/model/transports.d.ts +2 -0
  263. package/dist/esm/support/model/transports.js +2 -1
  264. package/dist/esm/support/tools.d.ts +11 -3
  265. package/dist/esm/support/tools.js +43 -18
  266. package/dist/esm/utils/catalog.d.ts +1 -1
  267. package/dist/esm/utils/invocation.d.ts +1 -0
  268. package/dist/esm/utils/invocation.js +1 -0
  269. package/package.json +20 -6
  270. package/dist/cjs/execution/index.js +0 -30
  271. package/dist/cjs/kits/intents/catalog.js +0 -82
  272. package/dist/cjs/kits/intents/index.js +0 -35
  273. package/dist/cjs/utils/debug.js +0 -30
  274. package/dist/esm/execution/index.d.ts +0 -11
  275. package/dist/esm/execution/index.js +0 -11
  276. package/dist/esm/kits/intents/catalog.d.ts +0 -39
  277. package/dist/esm/kits/intents/catalog.js +0 -79
  278. package/dist/esm/kits/intents/index.d.ts +0 -22
  279. package/dist/esm/kits/intents/index.js +0 -18
  280. package/dist/esm/kits/intents/registry.d.ts +0 -88
  281. package/dist/esm/utils/debug.d.ts +0 -27
  282. package/dist/esm/utils/debug.js +0 -27
  283. /package/dist/cjs/structs/{kits/intents/catalog.js → execution/workflow-views.js} +0 -0
  284. /package/dist/cjs/structs/kits/{intents/registry.js → domains/catalog.js} +0 -0
  285. /package/dist/cjs/structs/kits/{intents/scopes.js → domains/registry.js} +0 -0
  286. /package/dist/esm/structs/{kits/intents/catalog.js → execution/workflow-views.js} +0 -0
  287. /package/dist/esm/structs/kits/{intents/registry.js → domains/catalog.js} +0 -0
  288. /package/dist/esm/structs/kits/{intents/scopes.js → domains/registry.js} +0 -0
@@ -5,18 +5,42 @@
5
5
  * host value. Registration snapshots the schema and pins the resolver, so a request can project a
6
6
  * sealed subset without cloning handlers.
7
7
  *
8
- * Exports: `ModelCapability`, `ModelCapabilityRegistration`, `RegisteredModelCapability`,
9
- * `ModelSelection`, `ModelCapabilitySource`, `ModelCapabilityCatalog`.
8
+ * Exports: `ModelTool`, `ModelToolRegistration`, `RegisteredModelTool`,
9
+ * `ModelSelection`, `ModelToolSource`, `ModelToolCatalog`.
10
10
  */
11
11
  import type { SchemaAdapter, ReadonlyCatalog } from '../common.js';
12
- /** One selectable model operation. */
13
- export interface ModelCapability<Input = unknown, Output = Input> {
12
+ /** A model proposal, not an authorization or execution receipt. */
13
+ export interface ToolProposal {
14
+ readonly toolId: string;
15
+ readonly input: unknown;
16
+ }
17
+ /** Read-only host data without changing explicit any/unknown erasure into an object constraint. */
18
+ export type ToolContext<Context> = unknown extends Context ? Context : Readonly<Context>;
19
+ /** Demand-facing hints attached to one Tool; no independent identity is created. */
20
+ export interface IntentOptions<Context> {
21
+ /** Optional demand-facing description; otherwise the tool description is reused. */
22
+ readonly description?: string;
23
+ /** Synchronous participation predicate. */
24
+ readonly when?: (context: ToolContext<Context>) => boolean;
25
+ /** Allowed continuation delegates, not an execution sequence. */
26
+ readonly delegates?: readonly string[];
27
+ }
28
+ /** Demand-discovery metadata; it has no identity independent of its tool. */
29
+ export type AsIntent<Context> = true | string | ((context: ToolContext<Context>) => boolean) | IntentOptions<Context>;
30
+ /** Activation is independent of participation in demand discovery. */
31
+ export type ToolCondition<Context> = boolean | ((context: ToolContext<Context>) => boolean);
32
+ /** Common selectable model interface; resolution proposes a value without business execution. */
33
+ export interface ModelTool<Input = unknown, Output = Input, Context = any> {
14
34
  /** Unique id within its registry; never blank. */
15
35
  readonly id: string;
16
36
  /** Model-visible description explaining when the capability applies. */
17
37
  readonly description: string;
18
38
  /** Schema describing the arguments; must be an object schema. */
19
39
  readonly inputSchema: SchemaAdapter<Input>;
40
+ /** Omitted means active. Authorization remains a separate execution boundary. */
41
+ readonly active?: ToolCondition<Context>;
42
+ /** Omitted means this tool is not advertised by withIntent(). */
43
+ readonly asIntent?: AsIntent<Context>;
20
44
  /**
21
45
  * Converts validated arguments into the value handed back to the caller.
22
46
  *
@@ -27,9 +51,11 @@ export interface ModelCapability<Input = unknown, Output = Input> {
27
51
  }>): Output;
28
52
  }
29
53
  /** Registration form: input typing is erased, output typing is preserved. */
30
- export type ModelCapabilityRegistration<Output = unknown> = ModelCapability<any, Output>;
54
+ export type ModelToolRegistration<Output = unknown> = Omit<ModelTool<any, Output>, 'resolve'> & {
55
+ readonly resolve?: ModelTool<any, Output>['resolve'];
56
+ };
31
57
  /** Frozen snapshot stored by a registry after schema validation. */
32
- export type RegisteredModelCapability<Output = unknown> = Readonly<ModelCapability<unknown, Output>>;
58
+ export type RegisteredModelTool<Output = unknown> = Readonly<ModelTool<unknown, Output>>;
33
59
  /** A model's chosen capability together with its parsed arguments. */
34
60
  export type ModelSelection = {
35
61
  /** Arguments exactly as produced by the model, before schema parsing. */
@@ -41,15 +67,20 @@ export type ModelSelection = {
41
67
  argumentChars: number;
42
68
  };
43
69
  /** Capability the selection resolved to. */
44
- readonly capabilityId: string;
70
+ readonly toolId: string;
45
71
  };
46
- /** Minimal source a stage needs: enumerate capabilities and resolve one selection. */
47
- export interface ModelCapabilitySource<Output = unknown> {
48
- values(): IterableIterator<RegisteredModelCapability<Output>>;
72
+ /** Minimal source a stage needs: enumerate tools and resolve one selection. */
73
+ export interface ModelToolSource<Output = unknown> {
74
+ values(): IterableIterator<RegisteredModelTool<Output>>;
49
75
  /** Resolves one selection; throws when the capability is absent from this source. */
50
76
  resolve(selection: ModelSelection, context: Readonly<{
51
77
  stageId: string;
52
78
  }>): Output;
53
79
  }
54
80
  /** A compiled entity catalog also supports the minimal stage source contract. */
55
- export type ModelCapabilityCatalog<Output = unknown> = ReadonlyCatalog<RegisteredModelCapability<Output>> & ModelCapabilitySource<Output>;
81
+ export type ModelToolCatalog<Output = unknown> = ReadonlyCatalog<RegisteredModelTool<Output>> & ModelToolSource<Output> & {
82
+ /** Explicit selection, optionally filtered against a host context. */
83
+ select(ids: readonly string[], context?: unknown): ModelToolCatalog<Output>;
84
+ /** Demand-facing active tools; no workflow node or invocation is implied. */
85
+ withIntent(context: unknown): ModelToolCatalog<Output>;
86
+ };
@@ -5,7 +5,7 @@
5
5
  * registry binds an App context, validates input/output at the boundary and produces receipts, so
6
6
  * individual tools never handle transportation, budget accounting or event emission.
7
7
  *
8
- * Exports: `ToolDefinition`, `ToolExecutionContext`, `ExecutableTool`, `RegisteredTool`,
8
+ * Exports: `ToolDefinition`, `ToolExecutionContext`, `ErasedTool`, `RegisteredTool`,
9
9
  * `ToolExecutionEvent`, `ToolRegistryPorts`, `ToolInvocationRequest`, `ToolRegistryOptions`.
10
10
  */
11
11
  import type { InvocationMetadata } from '../invocation.js';
@@ -13,8 +13,9 @@ import type { ExecutionContext, MaybePromise, OperationContext, SchemaAdapter }
13
13
  import type { DiagnosticContext } from '../diagnostics.js';
14
14
  import type { RegistrationProjection } from '../../utils/registration.js';
15
15
  import type { NodeReportingContext } from '../debug.js';
16
+ import type { ModelTool, ToolProposal } from './model.js';
16
17
  /** One registered tool, typed by its input, output, host context and id literal. */
17
- export interface ToolDefinition<Input = unknown, Output = unknown, App = unknown, Id extends string = string> {
18
+ export interface ExecutableTool<Input = unknown, Output = unknown, App = unknown, Id extends string = string> extends ModelTool<Input, ToolProposal, App> {
18
19
  /** Stable id; also the name the model calls. */
19
20
  readonly id: Id;
20
21
  /** Declared grouping used by registries and documentation; not an authorization boundary. */
@@ -27,13 +28,19 @@ export interface ToolDefinition<Input = unknown, Output = unknown, App = unknown
27
28
  authorize(input: Input, context: OperationContext<App>): MaybePromise<void>;
28
29
  /** Executes the already-authorized input; must not repeat authorization decisions. */
29
30
  execute(input: Input, context: OperationContext<App> & import('../debug.js').NodeReportingContext): MaybePromise<Output>;
30
- /** Optional reporting hook that turns the result into self-reported sub-steps. */
31
- debugSteps?(result: Output, context: import('../debug.js').NodeReportingContext): import('../debug.js').SubFlowLogger;
31
+ /** Optional result hook; writes through context.createSubFlowLogger() are recorded immediately. */
32
+ debugSteps?(result: Output, context: import('../debug.js').NodeReportingContext): void;
32
33
  /** Validates untrusted output (for example a cached replay) before it is returned. */
33
34
  parseOutput(value: unknown): Output;
34
35
  }
36
+ /** Configuration form; Support supplies the identity resolver when omitted. */
37
+ export type ToolDefinition<Input = unknown, Output = unknown, App = unknown, Id extends string = string> = Omit<ExecutableTool<Input, Output, App, Id>, 'resolve'> & {
38
+ readonly resolve?: ExecutableTool<Input, Output, App, Id>['resolve'];
39
+ };
35
40
  /** Execution facts handed to a tool for one invocation. */
36
41
  export interface ToolExecutionContext extends ExecutionContext, NodeReportingContext {
42
+ /** Delegate bound by Core to this actual invocation. */
43
+ readonly logger?: import('../debug.js').ScopedSubFlowLogger;
37
44
  /** Diagnostic scope of the invocation, when recording is enabled. */
38
45
  readonly diagnostics?: DiagnosticContext;
39
46
  /** Declared execution discipline; mirrors whether the registry accepted an async tool. */
@@ -44,18 +51,18 @@ export interface ToolExecutionContext extends ExecutionContext, NodeReportingCon
44
51
  readonly signal: AbortSignal;
45
52
  }
46
53
  /** Type-erased tool shape the registry executes after parsing at the boundary. */
47
- export interface ExecutableTool {
54
+ export interface ErasedTool {
48
55
  readonly id: string;
49
56
  readonly kind: string;
50
57
  /** Optional here because the erased view does not require model-facing prose. */
51
58
  readonly description?: string;
52
- readonly debugSteps?: (result: unknown, context: NodeReportingContext) => import('../debug.js').SubFlowLogger;
59
+ readonly debugSteps?: (result: unknown, context: NodeReportingContext) => void;
53
60
  parseInput(value: unknown): unknown;
54
61
  parseOutput(value: unknown): unknown;
55
62
  execute(input: unknown, context: ToolExecutionContext): unknown;
56
63
  }
57
64
  /** Registered snapshot: public data is retained, implementation helpers are not a contract. */
58
- export type RegisteredTool<Tool extends ExecutableTool = ExecutableTool> = RegistrationProjection<Tool, ExecutableTool>;
65
+ export type RegisteredTool<Tool extends ErasedTool = ErasedTool> = RegistrationProjection<Tool, ErasedTool>;
59
66
  /** Fact emitted when one tool call settles, correlated by `invocationId`. */
60
67
  export interface ToolExecutionEvent<Kind extends string = string> extends InvocationMetadata {
61
68
  toolId: string;
@@ -79,6 +86,8 @@ export interface ToolRegistryPorts {
79
86
  }
80
87
  /** One invocation request; the registry supplies signal and diagnostics when omitted. */
81
88
  export interface ToolInvocationRequest<Id extends string = string> {
89
+ /** Explicit recorder for this call, also available to its handler for deliberate use. */
90
+ readonly logger?: import('../debug.js').SubFlowLogger;
82
91
  readonly toolId: Id;
83
92
  /** Raw model arguments; parsed by the tool's input schema before authorization. */
84
93
  readonly input: unknown;
@@ -93,6 +93,8 @@ export interface ExecutionOptions {
93
93
  }
94
94
  /** Required execution facts available inside a running call. */
95
95
  export interface ExecutionContext {
96
+ /** Explicit optional recorder for this operation; never inferred from diagnostics. */
97
+ readonly logger?: import('./debug.js').SubFlowLog;
96
98
  /** Non-optional cancellation signal; never `undefined` once execution has started. */
97
99
  readonly signal: AbortSignal;
98
100
  /** Diagnostic scope of the enclosing call, when recording is enabled. */
@@ -105,7 +107,7 @@ export interface ExecutionContext {
105
107
  * it as opaque and must not depend on application-specific fields.
106
108
  */
107
109
  export interface OperationContext<App = unknown> extends ExecutionContext {
108
- readonly app: Readonly<App>;
110
+ readonly app: unknown extends App ? App : Readonly<App>;
109
111
  }
110
112
  /**
111
113
  * One search result.
@@ -55,12 +55,18 @@ export declare const reportedStepStatuses: readonly (keyof typeof reportedStepSt
55
55
  export type ReportedStepStatus = keyof typeof reportedStepStatusCatalog;
56
56
  /** One step as reported by a node; fields beyond identity are optional detail. */
57
57
  export interface ReportedStep {
58
- /** Step identity, unique within one node visit. */
58
+ /** App-defined business log type; never a write/fix operation enum. */
59
+ readonly type?: string;
60
+ /** Logical subnode grouping within this node visit; independent of individual log ids. */
61
+ readonly subnodeId?: string;
62
+ /** Log record identity, unique within one node visit; not a subnode id. */
59
63
  readonly stepId: string;
60
64
  /** Reported parent step, forming a tree; absent for a top-level step. */
61
65
  readonly parentStepId?: string;
62
66
  /** Self-reported reference only; never a workflow dispatch identity. */
63
67
  readonly relatedDefinitionId?: string;
68
+ /** Real model/tool invocation identity, kept separate from the node-local subnode id. */
69
+ readonly relatedInvocationId?: string;
64
70
  /** Short reported label. */
65
71
  readonly name: string;
66
72
  /** Reported step kind (for example a tool or model call); free-form and node-owned. */
@@ -88,7 +94,11 @@ export type SubFlowValue = null | boolean | number | string | readonly SubFlowVa
88
94
  export interface RecordedSubStep extends ReportedStep {
89
95
  /** Historical marker: only self-reported steps are recorded. */
90
96
  readonly origin: 'reported';
91
- /** One-based write order within the node visit. */
97
+ /** Append-only logging operation, separate from the App-owned business type. */
98
+ readonly operation?: 'write' | 'fix';
99
+ /** Original write record revised by this fix; fixes have their own stepId. */
100
+ readonly targetStepId?: string;
101
+ /** One-based append order within the node visit, including every fix. */
92
102
  readonly sequence: number;
93
103
  /** Optional only for historical records produced before the logger contract. */
94
104
  readonly createdAtMs?: number;
@@ -98,10 +108,14 @@ export interface RecordedSubStep extends ReportedStep {
98
108
  readonly payload?: Readonly<Record<string, SubFlowValue>>;
99
109
  }
100
110
  /** Input accepted by `write`; the logger assigns the step id and sequence. */
101
- export interface SubFlowStepInput extends Omit<ReportedStep, 'stepId'> {
111
+ export interface SubFlowStepInput extends Omit<ReportedStep, 'stepId' | 'kind'> {
112
+ /** Optional family classification; defaults to the custom type when omitted. */
113
+ readonly kind?: string;
102
114
  readonly payload?: Readonly<Record<string, SubFlowValue>>;
103
115
  }
104
- /** Fields a later `fix` may change on an already written step. */
116
+ /** Scoped writes cannot supply or override the identity bound by their delegate. */
117
+ export type ScopedSubFlowStepInput = Omit<SubFlowStepInput, 'subnodeId'>;
118
+ /** Explicit revision whitelist: identity, grouping and business type are never patchable. */
105
119
  export interface SubFlowStepFix {
106
120
  readonly status?: ReportedStepStatus;
107
121
  readonly usedModel?: boolean;
@@ -112,31 +126,34 @@ export interface SubFlowStepFix {
112
126
  /** Fill missing result fields; existing facts cannot be replaced. */
113
127
  readonly payload?: Readonly<Record<string, SubFlowValue>>;
114
128
  }
115
- declare const subFlowLoggerBrand: unique symbol;
116
- /** Execution-owned instance. Obtain it from the active node/tool context. */
117
- export interface SubFlowLogger {
118
- /** Brand makes structural lookalikes incompatible with the recorder's own instance. */
119
- readonly [subFlowLoggerBrand]: true;
120
- /** Appends one step and returns its assigned step id. */
121
- write(input: SubFlowStepInput): string;
122
- /** Applies a partial update; illegal status transitions and replacements are rejected. */
123
- fix(stepId: string, patch: SubFlowStepFix): void;
124
- /** Snapshot of the steps recorded so far, in write order. */
129
+ /** Common read/write surface for both independently implemented logger classes. */
130
+ export interface SubFlowLog {
131
+ write(input: ScopedSubFlowStepInput): string | -1;
132
+ fix(stepId: string | -1, patch: SubFlowStepFix): boolean;
133
+ /** Both logger classes return the same complete immutable ledger. */
125
134
  readAll(): readonly Readonly<RecordedSubStep>[];
126
135
  }
136
+ /** Nominal classes: only the full logger is accepted by native invocation requests. */
137
+ export type { SubFlowLogger, ScopedSubFlowLogger } from '../diagnostics/sub-flow.js';
138
+ import type { SubFlowLogger } from '../diagnostics/sub-flow.js';
127
139
  /** Reporting surface handed to a node or tool for the duration of one visit. */
128
140
  export interface NodeReportingContext {
129
141
  /** Reports progress for the active node; Core supplies the execution identity. */
130
142
  report(update: import('./execution/workflow.js').WorkflowNodeReport): void;
131
- /** One logger per node visit; repeated calls return the same instance. */
143
+ /** Bound to this context and owned by runtime; repeated calls in one visit return the same instance. */
132
144
  createSubFlowLogger(): SubFlowLogger;
133
145
  }
134
146
  /** Compact progress notification emitted for each accepted sub-step write or fix. */
135
147
  export interface SubStepProgress {
148
+ readonly relatedInvocationId?: string;
136
149
  readonly operation: 'write' | 'fix';
137
- /** Step the operation applied to. */
150
+ readonly type?: string;
151
+ readonly subnodeId?: string;
152
+ /** Original write record when this operation is a fix. */
153
+ readonly targetStepId?: string;
154
+ /** Unique id of this append-only record. */
138
155
  readonly stepId: string;
139
- /** Write sequence of that step within the node visit. */
156
+ /** Append sequence of this record within the node visit, including every fix. */
140
157
  readonly sequence: number;
141
158
  /** Revision after the operation; `write` starts at 1. */
142
159
  readonly revision: number;
@@ -151,7 +168,6 @@ export interface SubStepProgress {
151
168
  export interface DebugStepsOutput {
152
169
  /** Model use reported by this handler; omitted when unknown. */
153
170
  readonly usedModel?: boolean;
154
- /** Accessor invoked at emit time so recording can be skipped when disabled. */
155
- readonly subSteps?: () => SubFlowLogger | undefined;
171
+ /** Runtime-owned immutable snapshot, committed when a logger writes or fixes a step. */
172
+ readonly recordedSubSteps?: readonly Readonly<RecordedSubStep>[];
156
173
  }
157
- export {};
@@ -0,0 +1,123 @@
1
+ /** Serializable topology and observed execution contracts; layout belongs to consumers. */
2
+ import type { CoreDiagnosticRecord } from '../diagnostics.js';
3
+ import type { RecordedSubStep, SubFlowValue } from '../debug.js';
4
+ import type { WorkflowEvent } from './workflow.js';
5
+ /** Pure registered topology; routes sharing a target share an edge within one kind. */
6
+ export interface WorkflowGraph {
7
+ readonly schemaVersion: 1;
8
+ readonly workflowId: string;
9
+ readonly revision?: string;
10
+ readonly entryNodeId: string;
11
+ readonly nodes: readonly WorkflowGraphNode[];
12
+ readonly edges: readonly WorkflowGraphEdge[];
13
+ }
14
+ /** Node metadata and derived incident edges, without executable callbacks. */
15
+ export interface WorkflowGraphNode {
16
+ readonly id: string;
17
+ readonly name: string;
18
+ readonly description: string;
19
+ readonly order: number;
20
+ readonly startsRound: boolean;
21
+ readonly requires: readonly string[];
22
+ readonly provides: readonly string[];
23
+ readonly routes: readonly WorkflowGraphRoute[];
24
+ readonly incomingEdgeIds: readonly string[];
25
+ readonly outgoingEdgeIds: readonly string[];
26
+ }
27
+ /** Declaration order is retained even when multiple routes share a topology edge. */
28
+ export interface WorkflowGraphRoute {
29
+ readonly order: number;
30
+ readonly routeId?: string;
31
+ readonly description?: string;
32
+ readonly conditional: boolean;
33
+ readonly conditionId?: string;
34
+ readonly edgeId: string;
35
+ }
36
+ /** Completion has no target node; recovery edges remain distinct from normal edges. */
37
+ export interface WorkflowGraphEdge {
38
+ readonly id: string;
39
+ readonly kind: 'transition' | 'error' | 'complete';
40
+ readonly sourceNodeId: string;
41
+ readonly targetNodeId?: string;
42
+ readonly routeOrders: readonly number[];
43
+ readonly errorRouteId?: string;
44
+ }
45
+ /** Capture completeness is independent of whether diagnostic content was included. */
46
+ export interface WorkflowChainCoverage {
47
+ readonly complete: boolean | 'unknown';
48
+ readonly content: 'included' | 'omitted' | 'mixed' | 'unknown';
49
+ readonly issues: readonly {
50
+ readonly code: string;
51
+ readonly spanId?: string;
52
+ readonly eventId?: string;
53
+ readonly count?: number;
54
+ }[];
55
+ }
56
+ /** App resolves authorization, retention, pagination and storage paths before returning. */
57
+ export type WorkflowChainSource = (runId: string) => Promise<{
58
+ readonly events: readonly CoreDiagnosticRecord[];
59
+ readonly coverage: WorkflowChainCoverage;
60
+ }>;
61
+ /** Observed visits, never merged by static node id or synthesized from adjacency. */
62
+ export interface WorkflowChain {
63
+ readonly schemaVersion: 1;
64
+ readonly workflowId: string;
65
+ readonly runId: string;
66
+ readonly nodes: readonly WorkflowChainNode[];
67
+ readonly transitions: readonly WorkflowChainTransition[];
68
+ readonly coverage: WorkflowChainCoverage;
69
+ }
70
+ /** Historical subflow snapshots may omit recorder fields or descriptive content. */
71
+ export type WorkflowSubflowRecord = Omit<RecordedSubStep, 'name' | 'kind'> & {
72
+ readonly name?: string;
73
+ readonly kind?: string;
74
+ readonly sourceEventId?: string;
75
+ readonly producerSequence?: number;
76
+ };
77
+ /** A single node visit, with flat ordered subflow records including every independent fix. */
78
+ export interface WorkflowChainNode {
79
+ readonly spanId: string;
80
+ readonly nodeId: string;
81
+ readonly workflowInvocationId?: string;
82
+ readonly definitionRevision?: string;
83
+ readonly name?: string;
84
+ readonly description?: string;
85
+ readonly kind?: string;
86
+ readonly roundIndex?: number;
87
+ readonly firstEventSequence: number;
88
+ readonly lastEventSequence: number;
89
+ readonly enteredAtMs?: number;
90
+ readonly endedAtMs?: number;
91
+ readonly durationMs?: number;
92
+ readonly status: 'running' | 'success' | 'error' | 'cancelled' | 'unknown';
93
+ readonly usedModel?: boolean;
94
+ readonly events: readonly WorkflowChainNodeEvent[];
95
+ readonly subflow: readonly WorkflowSubflowRecord[];
96
+ }
97
+ /** Node-local lifecycle facts; payload remains subject to the source's content policy. */
98
+ export interface WorkflowChainNodeEvent {
99
+ readonly eventId: string;
100
+ readonly producerSequence: number;
101
+ readonly occurredAtMs: number;
102
+ readonly type: WorkflowEvent['type'] | 'progress';
103
+ readonly phase?: WorkflowEvent['phase'];
104
+ readonly routeId?: string;
105
+ readonly conditionId?: string;
106
+ readonly errorCode?: string;
107
+ readonly errorEventId?: string;
108
+ readonly payload?: SubFlowValue;
109
+ }
110
+ /** Actual handoff evidence; a target span does not prove its enter event was captured. */
111
+ export interface WorkflowChainTransition {
112
+ readonly eventId: string;
113
+ readonly producerSequence: number;
114
+ readonly occurredAtMs: number;
115
+ readonly type: 'transition' | 'complete';
116
+ readonly sourceSpanId: string;
117
+ readonly targetSpanId?: string;
118
+ readonly targetNodeId?: string;
119
+ readonly routeOrder?: number;
120
+ readonly routeId?: string;
121
+ readonly conditionId?: string;
122
+ readonly errorEventId?: string;
123
+ }
@@ -1,3 +1,4 @@
1
+ import type { WorkflowChainSource } from './workflow-views.js';
1
2
  /**
2
3
  * Workflow contract: a state graph whose nodes report their own use of model and tools.
3
4
  *
@@ -66,8 +67,6 @@ export interface WorkflowNodeReport {
66
67
  readonly usedModel?: boolean;
67
68
  /** App-defined progress detail; collected only when content logging is enabled. */
68
69
  readonly payload?: unknown;
69
- /** Logger owned by this visit, used to report sub-steps. */
70
- readonly subs?: import('../debug.js').SubFlowLogger;
71
70
  }
72
71
  /** One node of the graph. */
73
72
  export type WorkflowNode<State, Result, Runtime = undefined> = {
@@ -94,7 +93,7 @@ export type WorkflowNode<State, Result, Runtime = undefined> = {
94
93
  readonly requires?: readonly (keyof State & string)[];
95
94
  /** State keys this node is expected to produce; validated after `run`. */
96
95
  readonly provides?: readonly (keyof State & string)[];
97
- /** Candidate successors, evaluated in order. */
96
+ /** Candidate successors, evaluated in order. A getter must be pure; registration reads it once. */
98
97
  readonly routes: readonly WorkflowRoute<State, Result, Runtime>[];
99
98
  /** Return only changed fields. Core commits them after cancellation and output checks. */
100
99
  readonly run?: (state: Readonly<State>, context: WorkflowContext<Runtime>) => void | Partial<State> | Promise<void | Partial<State>>;
@@ -103,6 +102,8 @@ export type WorkflowNode<State, Result, Runtime = undefined> = {
103
102
  export type AgentWorkflowDefinition<State, Result, Runtime = undefined> = {
104
103
  /** Stable workflow id, also reported in every event. */
105
104
  readonly id: string;
105
+ /** App-owned authorized diagnostic reader; no global run storage is installed. */
106
+ readonly chainSource?: WorkflowChainSource;
106
107
  /** Definition revision; lets hosts distinguish executions of different graph versions. */
107
108
  readonly revision?: string;
108
109
  readonly nodes: readonly WorkflowNode<State, Result, Runtime>[];
@@ -2,9 +2,9 @@
2
2
  * Public entry of the structs layer.
3
3
  *
4
4
  * Structs are the shape-only half of agent-core: declarations and frozen constant catalogs that the
5
- * runtime modules (`capabilities`, `context`, `execution`, `model`, `kits`, `support`) both
6
- * implement and consume. Runtime classes declared here only describe shape or initialize fields,
7
- * so importing this barrel never starts execution.
5
+ * runtime modules (`tools`, `context`, `execution`, `model`, `kits`, `support`) both implement and
6
+ * consume. Runtime classes declared here only describe shape or initialize fields, so importing this
7
+ * barrel never starts execution.
8
8
  *
9
9
  * Exports: a curated re-export of the shared vocabulary, error classes, diagnostics/event
10
10
  * envelopes, model and workflow contracts, and the optional Kit protocol definitions.
@@ -19,6 +19,7 @@ export * from './model/interactions.js';
19
19
  export * from './context/journal.js';
20
20
  export * from './support/transport/json.js';
21
21
  export * from './model/messages.js';
22
+ export * from './model/session.js';
22
23
  export * from './model/runtime.js';
23
24
  export * from './support/model/provider.js';
24
25
  export * from './kits/interaction.js';
@@ -32,10 +33,10 @@ export * from './kits/evidence.js';
32
33
  export * from './kits/presentation/templates.js';
33
34
  export * from './kits/retrieval.js';
34
35
  export * from './kits/text-skills.js';
35
- export * from './kits/intents/registry.js';
36
- export * from './kits/intents/scopes.js';
36
+ export * from './kits/domains/registry.js';
37
+ export * from './kits/domains/scopes.js';
37
38
  export * from './kits/tools.js';
38
- export * from './kits/intents/catalog.js';
39
+ export * from './kits/domains/catalog.js';
39
40
  export * from './support/registration.js';
40
41
  export * from './diagnostics.js';
41
42
  export * from './support/context.js';
@@ -55,3 +56,4 @@ export type * from './invocation.js';
55
56
  export type * from './debug.js';
56
57
  export type * from './execution/events.js';
57
58
  export type * from './execution/cache.js';
59
+ export type * from './execution/workflow-views.js';
@@ -2,9 +2,9 @@
2
2
  * Public entry of the structs layer.
3
3
  *
4
4
  * Structs are the shape-only half of agent-core: declarations and frozen constant catalogs that the
5
- * runtime modules (`capabilities`, `context`, `execution`, `model`, `kits`, `support`) both
6
- * implement and consume. Runtime classes declared here only describe shape or initialize fields,
7
- * so importing this barrel never starts execution.
5
+ * runtime modules (`tools`, `context`, `execution`, `model`, `kits`, `support`) both implement and
6
+ * consume. Runtime classes declared here only describe shape or initialize fields, so importing this
7
+ * barrel never starts execution.
8
8
  *
9
9
  * Exports: a curated re-export of the shared vocabulary, error classes, diagnostics/event
10
10
  * envelopes, model and workflow contracts, and the optional Kit protocol definitions.
@@ -19,6 +19,7 @@ export * from './model/interactions.js';
19
19
  export * from './context/journal.js';
20
20
  export * from './support/transport/json.js';
21
21
  export * from './model/messages.js';
22
+ export * from './model/session.js';
22
23
  export * from './model/runtime.js';
23
24
  export * from './support/model/provider.js';
24
25
  export * from './kits/interaction.js';
@@ -32,10 +33,10 @@ export * from './kits/evidence.js';
32
33
  export * from './kits/presentation/templates.js';
33
34
  export * from './kits/retrieval.js';
34
35
  export * from './kits/text-skills.js';
35
- export * from './kits/intents/registry.js';
36
- export * from './kits/intents/scopes.js';
36
+ export * from './kits/domains/registry.js';
37
+ export * from './kits/domains/scopes.js';
37
38
  export * from './kits/tools.js';
38
- export * from './kits/intents/catalog.js';
39
+ export * from './kits/domains/catalog.js';
39
40
  export * from './support/registration.js';
40
41
  export * from './diagnostics.js';
41
42
  export * from './support/context.js';
@@ -16,8 +16,8 @@ export interface AnswerTaskDefinition<Input = unknown, Data = unknown> {
16
16
  readonly readerId: string;
17
17
  /** Output contract the answer must satisfy; must be registered. */
18
18
  readonly outputId: string;
19
- /** Intents this task serves; non-empty. */
20
- readonly intentIds: readonly string[];
19
+ /** Goals this task serves; non-empty. */
20
+ readonly goalIds: readonly string[];
21
21
  /** Optional scope narrowing the task. */
22
22
  readonly scopeId?: string;
23
23
  /** Checks applied to the produced value; every id must be registered. */
@@ -1,26 +1,26 @@
1
1
  /**
2
- * Agent catalog contract for the Intents Kit.
2
+ * Agent catalog contract for the Domain Tools Kit.
3
3
  *
4
4
  * Place in the package: an optional App-side projection that describes which intents, scopes and
5
5
  * tools are available to one request. The ports read the App's real registries, so no parallel
6
6
  * capability list exists; this module only declares what the catalog needs from them.
7
7
  *
8
- * Exports: `CatalogIntent`, `CatalogScope`, `CatalogTask`, `CatalogTool`, `DescribedTool`,
8
+ * Exports: `CatalogGoal`, `CatalogScope`, `CatalogTask`, `CatalogTool`, `DescribedTool`,
9
9
  * `AgentCatalogPorts`.
10
10
  */
11
- /** Intent as the catalog sees it: an id plus its declared steps. */
12
- export interface CatalogIntent<Id extends string = string> {
11
+ /** Goal as the catalog sees it: an id plus its declared delegates. */
12
+ export interface CatalogGoal<Id extends string = string> {
13
13
  readonly id: Id;
14
- readonly steps: readonly string[];
14
+ readonly delegates: readonly string[];
15
15
  }
16
16
  /** Scope as the catalog sees it: an id plus the tools it may use. */
17
17
  export interface CatalogScope {
18
18
  readonly id: string;
19
19
  readonly toolIds: readonly string[];
20
20
  }
21
- /** The task currently accepted for the request, used to narrow the catalog. */
21
+ /** The goal currently accepted for the request, used to narrow the catalog. */
22
22
  export interface CatalogTask<Id extends string = string> {
23
- readonly intentId: Id;
23
+ readonly goalId: Id;
24
24
  /** Selected scope; `null` or `undefined` means a scope has not been chosen yet. */
25
25
  readonly scopeId?: string | null;
26
26
  }
@@ -28,12 +28,12 @@ export interface CatalogTask<Id extends string = string> {
28
28
  export interface CatalogTool<App> {
29
29
  readonly id: string;
30
30
  /** Intent ids the tool serves, or `'all'` when it is always available. */
31
- readonly intentIds: 'all' | readonly string[];
31
+ readonly goalIds: 'all' | readonly string[];
32
32
  /** Returns whether the tool may run for this App state; absent means always available. */
33
- available?(app: App): boolean;
34
- /** Invocation step, when the tool participates in the step-based lifecycle. */
35
- readonly invocation?: {
36
- readonly step: string;
33
+ readonly active?: import('../../capabilities/model.js').ToolCondition<App>;
34
+ /** Invocation identity, when the tool participates in the lifecycle. */
35
+ readonly lifecycle?: {
36
+ readonly id?: string;
37
37
  };
38
38
  }
39
39
  /** Model- or host-facing description of one tool. */
@@ -43,15 +43,15 @@ export interface DescribedTool {
43
43
  readonly description: string;
44
44
  readonly audience: string;
45
45
  readonly effect: string;
46
- readonly intentIds: readonly string[];
46
+ readonly goalIds: readonly string[];
47
47
  }
48
48
  /** Ports the catalog reads from the App's registries. */
49
- export interface AgentCatalogPorts<App, Id extends string, Intent extends CatalogIntent<Id>, Scope extends CatalogScope> {
50
- /** All registered intent ids, before availability filtering. */
51
- intentIds(): readonly Id[];
52
- /** Registered intents, optionally narrowed to `ids`. */
53
- intents(ids?: readonly Id[]): readonly Intent[];
54
- /** Registered scopes for the given intent ids (all scopes when omitted). */
49
+ export interface AgentCatalogPorts<App, Id extends string, Intent extends CatalogGoal<Id>, Scope extends CatalogScope> {
50
+ /** All registered Tool ids, before availability filtering. */
51
+ goalIds(app: App): readonly Id[];
52
+ /** Registered domain Tools, optionally narrowed to `ids`. */
53
+ goals(ids?: readonly Id[]): readonly Intent[];
54
+ /** Registered scopes for the given Tool ids (all scopes when omitted). */
55
55
  scopes(ids?: readonly Id[]): readonly Scope[];
56
56
  /** When not `false`, the catalog is narrowed to `currentTask`; defaults to restriction on. */
57
57
  readonly restrictToTask?: boolean;
@@ -60,7 +60,7 @@ export interface AgentCatalogPorts<App, Id extends string, Intent extends Catalo
60
60
  readonly tools: {
61
61
  values(): Iterable<CatalogTool<App>>;
62
62
  has(id: string): boolean;
63
- supportsIntent(id: Id, app: App): boolean;
63
+ supportsGoal(id: Id, app: App): boolean;
64
64
  /** Describes tools for an audience (for example `'model'`); must be synchronous. */
65
65
  describe(audience?: string, app?: App): readonly DescribedTool[];
66
66
  };