@jangts/agent-core 0.3.6 → 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 (214) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +5 -5
  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 +4 -2
  7. package/development/docs/api/README.md +2 -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/reference.en.md +508 -410
  23. package/development/docs/api/reference.md +508 -410
  24. package/development/docs/api/support.en.md +55 -9
  25. package/development/docs/api/support.md +53 -7
  26. package/development/docs/api/types.en.md +35 -1
  27. package/development/docs/api/types.md +43 -0
  28. package/development/docs/basic-usage.en.md +1 -1
  29. package/development/docs/basic-usage.md +1 -1
  30. package/development/docs/create-app.en.md +1 -1
  31. package/development/docs/examples/registration/associated.mjs +8 -0
  32. package/development/docs/examples/registration/independent.mjs +20 -0
  33. package/development/docs/examples/registration/protocol.mjs +48 -0
  34. package/development/docs/examples/registration/run.mjs +47 -0
  35. package/development/docs/examples/registration/tools.mjs +75 -0
  36. package/development/docs/examples/registration/workflow.mjs +109 -0
  37. package/development/docs/flows/knowledge-maintenance.en.md +1 -1
  38. package/development/docs/materials.en.md +1 -1
  39. package/development/docs/mechanisms.en.md +2 -2
  40. package/development/docs/mechanisms.md +1 -1
  41. package/development/docs/operations.en.md +1 -1
  42. package/development/docs/records.en.md +1 -1
  43. package/development/docs/registration.en.md +4 -4
  44. package/development/docs/registration.md +2 -2
  45. package/development/skills/agent-core-app/SKILL.md +4 -4
  46. package/development/skills/agent-core-app/templates/node-ts/README.md.tpl +1 -1
  47. package/development/skills/agent-core-app/templates/node-ts/src/catalog.ts.tpl +2 -2
  48. package/development/skills/agent-core-app/templates/node-ts/test/app.test.mjs.tpl +1 -1
  49. package/dist/cjs/capabilities/index.js +5 -12
  50. package/dist/cjs/capabilities/model.js +56 -12
  51. package/dist/cjs/capabilities/tool-conditions.js +65 -0
  52. package/dist/cjs/capabilities/tool-runtime.js +10 -3
  53. package/dist/cjs/context/audit.js +5 -8
  54. package/dist/cjs/context/index.js +3 -4
  55. package/dist/cjs/index.js +21 -17
  56. package/dist/cjs/kits/answering/tasks.js +5 -5
  57. package/dist/cjs/kits/domains/catalog.js +113 -0
  58. package/dist/cjs/kits/domains/index.js +20 -0
  59. package/dist/cjs/kits/{intents → domains}/registry.js +77 -31
  60. package/dist/cjs/kits/{intents → domains}/scopes.js +21 -21
  61. package/dist/cjs/kits/index.js +14 -13
  62. package/dist/cjs/kits/presentation/formats.js +110 -0
  63. package/dist/cjs/kits/presentation/index.js +10 -5
  64. package/dist/cjs/kits/reflection.js +2 -2
  65. package/dist/cjs/kits/text-blocks.js +101 -0
  66. package/dist/cjs/kits/tools.js +246 -158
  67. package/dist/cjs/model/index.js +2 -6
  68. package/dist/cjs/model/interactions/calls.js +61 -0
  69. package/dist/cjs/model/interactions/json-object.js +11 -11
  70. package/dist/cjs/model/interactions/native-functions.js +17 -23
  71. package/dist/cjs/model/message-diagnostics.js +13 -3
  72. package/dist/cjs/model/options.js +2 -0
  73. package/dist/cjs/model/preparation.js +39 -6
  74. package/dist/cjs/model/runner.js +14 -0
  75. package/dist/cjs/model/selection-transport.js +4 -4
  76. package/dist/cjs/model/token-budget.js +3 -0
  77. package/dist/cjs/model/transports.js +3 -2
  78. package/dist/cjs/structs/index.js +7 -6
  79. package/dist/cjs/structs/kits/presentation/formats.js +2 -0
  80. package/dist/cjs/structs/kits/text-blocks.js +11 -0
  81. package/dist/cjs/structs/model/session.js +11 -0
  82. package/dist/cjs/structs/support/associations.js +2 -0
  83. package/dist/cjs/support/associations.js +79 -0
  84. package/dist/cjs/support/context/snapshot.js +11 -1
  85. package/dist/cjs/support/decorators/index.js +45 -3
  86. package/dist/cjs/support/index.js +1 -0
  87. package/dist/cjs/support/model/capabilities.js +35 -5
  88. package/dist/cjs/support/model/chat-completions.js +11 -2
  89. package/dist/cjs/support/model/completion/calls.js +10 -56
  90. package/dist/cjs/support/model/preview-rules.js +11 -11
  91. package/dist/cjs/support/model/reply-preview.js +3 -3
  92. package/dist/cjs/support/model/session.js +152 -0
  93. package/dist/cjs/support/model/stage-transport.js +8 -8
  94. package/dist/cjs/support/model/transports.js +5 -2
  95. package/dist/cjs/support/tools.js +42 -17
  96. package/dist/esm/capabilities/index.d.ts +5 -10
  97. package/dist/esm/capabilities/index.js +5 -9
  98. package/dist/esm/capabilities/model.d.ts +17 -13
  99. package/dist/esm/capabilities/model.js +54 -10
  100. package/dist/esm/capabilities/tool-conditions.d.ts +9 -0
  101. package/dist/esm/capabilities/tool-conditions.js +59 -0
  102. package/dist/esm/capabilities/tool-runtime.js +10 -3
  103. package/dist/esm/capabilities/tools.d.ts +3 -3
  104. package/dist/esm/context/audit.js +5 -8
  105. package/dist/esm/context/index.d.ts +3 -4
  106. package/dist/esm/context/index.js +3 -4
  107. package/dist/esm/index.d.ts +19 -13
  108. package/dist/esm/index.js +18 -15
  109. package/dist/esm/kits/answering/tasks.d.ts +6 -6
  110. package/dist/esm/kits/answering/tasks.js +5 -5
  111. package/dist/esm/kits/domains/catalog.d.ts +42 -0
  112. package/dist/esm/kits/domains/catalog.js +110 -0
  113. package/dist/esm/kits/domains/index.d.ts +4 -0
  114. package/dist/esm/kits/domains/index.js +4 -0
  115. package/dist/esm/kits/domains/registry.d.ts +100 -0
  116. package/dist/esm/kits/{intents → domains}/registry.js +77 -31
  117. package/dist/esm/kits/{intents → domains}/scopes.d.ts +18 -18
  118. package/dist/esm/kits/{intents → domains}/scopes.js +21 -21
  119. package/dist/esm/kits/index.d.ts +6 -5
  120. package/dist/esm/kits/index.js +6 -5
  121. package/dist/esm/kits/presentation/formats.d.ts +42 -0
  122. package/dist/esm/kits/presentation/formats.js +105 -0
  123. package/dist/esm/kits/presentation/index.d.ts +14 -5
  124. package/dist/esm/kits/presentation/index.js +10 -5
  125. package/dist/esm/kits/reflection.js +3 -3
  126. package/dist/esm/kits/text-blocks.d.ts +24 -0
  127. package/dist/esm/kits/text-blocks.js +97 -0
  128. package/dist/esm/kits/tools.d.ts +69 -52
  129. package/dist/esm/kits/tools.js +246 -158
  130. package/dist/esm/model/index.d.ts +2 -6
  131. package/dist/esm/model/index.js +2 -6
  132. package/dist/esm/model/interactions/calls.d.ts +40 -0
  133. package/dist/esm/model/interactions/calls.js +58 -0
  134. package/dist/esm/model/interactions/json-object.js +11 -11
  135. package/dist/esm/model/interactions/native-functions.js +17 -23
  136. package/dist/esm/model/message-diagnostics.d.ts +6 -5
  137. package/dist/esm/model/message-diagnostics.js +13 -3
  138. package/dist/esm/model/options.js +2 -0
  139. package/dist/esm/model/preparation.js +39 -6
  140. package/dist/esm/model/runner.js +14 -0
  141. package/dist/esm/model/selection-transport.js +4 -4
  142. package/dist/esm/model/token-budget.js +3 -0
  143. package/dist/esm/model/transports.d.ts +2 -1
  144. package/dist/esm/model/transports.js +3 -2
  145. package/dist/esm/structs/capabilities/invocation.d.ts +1 -1
  146. package/dist/esm/structs/capabilities/model.d.ts +42 -11
  147. package/dist/esm/structs/capabilities/tools.d.ts +9 -4
  148. package/dist/esm/structs/common.d.ts +1 -1
  149. package/dist/esm/structs/index.d.ts +7 -6
  150. package/dist/esm/structs/index.js +7 -6
  151. package/dist/esm/structs/kits/answering/tasks.d.ts +2 -2
  152. package/dist/esm/structs/kits/{intents → domains}/catalog.d.ts +20 -20
  153. package/dist/esm/structs/kits/{intents → domains}/registry.d.ts +24 -21
  154. package/dist/esm/structs/kits/{intents → domains}/scopes.d.ts +9 -9
  155. package/dist/esm/structs/kits/presentation/formats.d.ts +42 -0
  156. package/dist/esm/structs/kits/presentation/formats.js +1 -0
  157. package/dist/esm/structs/kits/text-blocks.d.ts +25 -0
  158. package/dist/esm/structs/kits/text-blocks.js +10 -0
  159. package/dist/esm/structs/kits/tools.d.ts +82 -83
  160. package/dist/esm/structs/model/interactions.d.ts +18 -11
  161. package/dist/esm/structs/model/messages.d.ts +34 -2
  162. package/dist/esm/structs/model/runtime.d.ts +7 -0
  163. package/dist/esm/structs/model/session.d.ts +29 -0
  164. package/dist/esm/structs/model/session.js +10 -0
  165. package/dist/esm/structs/support/associations.d.ts +22 -0
  166. package/dist/esm/structs/support/associations.js +1 -0
  167. package/dist/esm/structs/support/model/interactions.d.ts +2 -2
  168. package/dist/esm/structs/support/model/messages.d.ts +6 -13
  169. package/dist/esm/structs/support/tools.d.ts +23 -23
  170. package/dist/esm/support/associations.d.ts +26 -0
  171. package/dist/esm/support/associations.js +76 -0
  172. package/dist/esm/support/context/snapshot.js +11 -1
  173. package/dist/esm/support/decorators/index.d.ts +13 -2
  174. package/dist/esm/support/decorators/index.js +40 -3
  175. package/dist/esm/support/decorators/pool.d.ts +6 -5
  176. package/dist/esm/support/decorators/types.d.ts +3 -1
  177. package/dist/esm/support/index.d.ts +1 -0
  178. package/dist/esm/support/index.js +1 -0
  179. package/dist/esm/support/model/capabilities.d.ts +8 -3
  180. package/dist/esm/support/model/capabilities.js +35 -5
  181. package/dist/esm/support/model/chat-completions.js +11 -2
  182. package/dist/esm/support/model/completion/calls.d.ts +6 -34
  183. package/dist/esm/support/model/completion/calls.js +8 -55
  184. package/dist/esm/support/model/index.d.ts +1 -1
  185. package/dist/esm/support/model/preview-rules.d.ts +13 -8
  186. package/dist/esm/support/model/preview-rules.js +11 -11
  187. package/dist/esm/support/model/reply-preview.d.ts +2 -2
  188. package/dist/esm/support/model/reply-preview.js +3 -3
  189. package/dist/esm/support/model/session.d.ts +61 -0
  190. package/dist/esm/support/model/session.js +148 -0
  191. package/dist/esm/support/model/stage-transport.d.ts +1 -1
  192. package/dist/esm/support/model/stage-transport.js +9 -9
  193. package/dist/esm/support/model/transports.d.ts +2 -0
  194. package/dist/esm/support/model/transports.js +2 -1
  195. package/dist/esm/support/tools.d.ts +11 -3
  196. package/dist/esm/support/tools.js +43 -18
  197. package/dist/esm/utils/catalog.d.ts +1 -1
  198. package/package.json +20 -6
  199. package/dist/cjs/execution/index.js +0 -30
  200. package/dist/cjs/kits/intents/catalog.js +0 -82
  201. package/dist/cjs/kits/intents/index.js +0 -35
  202. package/dist/esm/execution/index.d.ts +0 -11
  203. package/dist/esm/execution/index.js +0 -11
  204. package/dist/esm/kits/intents/catalog.d.ts +0 -39
  205. package/dist/esm/kits/intents/catalog.js +0 -79
  206. package/dist/esm/kits/intents/index.d.ts +0 -22
  207. package/dist/esm/kits/intents/index.js +0 -18
  208. package/dist/esm/kits/intents/registry.d.ts +0 -88
  209. /package/dist/cjs/structs/kits/{intents → domains}/catalog.js +0 -0
  210. /package/dist/cjs/structs/kits/{intents → domains}/registry.js +0 -0
  211. /package/dist/cjs/structs/kits/{intents → domains}/scopes.js +0 -0
  212. /package/dist/esm/structs/kits/{intents → domains}/catalog.js +0 -0
  213. /package/dist/esm/structs/kits/{intents → domains}/registry.js +0 -0
  214. /package/dist/esm/structs/kits/{intents → domains}/scopes.js +0 -0
@@ -1,18 +1,16 @@
1
1
  /**
2
2
  * Aggregate public entry of `@jangts/agent-core`: Core runtime contracts, one `Support`
3
- * namespace with a few named Support helpers, and the declaration helpers of optional Kits.
3
+ * namespace, and the optional Kit declaration helpers.
4
4
  *
5
- * Layering. Core owns the runtime contracts Apps call (engine, model runner, capabilities,
6
- * context, diagnostics) and the handler contracts Core calls back into the App. Support only
7
- * supplies recommended implementations of those same contracts, so it is published as a single
8
- * namespace instead of a second dispatch layer. Kits are optional business libraries reached
9
- * through their own subpath entries; the Kit entries re-exported here are declaration helpers
10
- * and standalone modules, not additional Core guarantees. Shared utilities are re-exported
11
- * because they are needed alongside these contracts, and they carry no Agent semantics.
5
+ * Layering. Core owns the runtime contracts Apps call (engine, model runner, tools,
6
+ * context, diagnostics) and the handler contracts Core calls back into. Support supplies
7
+ * recommended implementations of those contracts. Kits are optional App-side libraries;
8
+ * they are available from this root convenience surface and from `/kits` / `/kits/*`
9
+ * subpaths. Importing a Kit is a choice, never a requirement.
12
10
  *
13
11
  * Exports are grouped by responsibility, not by dependency order. Deep subpath entries
14
12
  * (`/engine`, `/model`, `/tools`, `/context`, `/journal`, `/diagnostics`, `/kits/...`)
15
- * resolve to the same implementations, so this file is a convenience surface only.
13
+ * resolve to the same implementations.
16
14
  */
17
15
  export * from './execution/engine.js';
18
16
  export { getErrorInfo } from './errors.js';
@@ -23,13 +21,21 @@ export * from './model/index.js';
23
21
  export * from './capabilities/index.js';
24
22
  export * from './context/fragments.js';
25
23
  export * from './context/journal.js';
26
- export { assembleFragments } from './context/assembly.js';
24
+ export * from './context/assembly.js';
27
25
  export * from './support/context/assembly.js';
28
26
  export { defineEvidenceChecklist, defineEvidenceProjection } from './kits/evidence.js';
29
27
  export type { EvidenceRequirement, EvidenceProvider, EvidenceProjectionDefinition, EvidenceProjectionProvider, } from './structs/kits/evidence.js';
28
+ export { defineCommand, commandSchema } from './kits/interaction/command.js';
29
+ export type { Command, CommandDefinition, ProtocolCheck, ProtocolField, ProtocolReason, ProtocolPredicate, ProtocolShape, RegisteredProtocol, } from './structs/kits/interaction.js';
30
+ export * from './kits/interaction/commands.js';
31
+ export * from './kits/interaction/transfer.js';
32
+ export * from './kits/interaction/handlers.js';
30
33
  export * from './kits/presentation/events.js';
31
34
  export * from './support/transport/index.js';
32
35
  export * from './support/model/chat-completions.js';
36
+ export * from './support/model/compatible-provider.js';
37
+ export * from './support/model/transports.js';
38
+ export * from './support/model/interactions/index.js';
33
39
  export * from './utils/index.js';
34
40
  export * from './kits/presentation/templates.js';
35
41
  export { defineRetrieval } from './kits/retrieval.js';
@@ -37,11 +43,11 @@ export type * from './structs/kits/retrieval.js';
37
43
  export { defineTextSkillLoader } from './kits/text-skills.js';
38
44
  export type * from './structs/kits/text-skills.js';
39
45
  export * from './diagnostics/index.js';
40
- export * from './kits/intents/registry.js';
41
- export * from './kits/intents/scopes.js';
46
+ export * from './kits/domains/registry.js';
47
+ export * from './kits/domains/scopes.js';
42
48
  export { ToolLifecycleRegistry } from './kits/tools.js';
43
49
  export type * from './structs/kits/tools.js';
44
- export * from './kits/intents/catalog.js';
50
+ export * from './kits/domains/catalog.js';
45
51
  export * from './support/registration.js';
46
52
  export { defineCandidateSelection } from './kits/candidates.js';
47
53
  export type * from './structs/kits/candidates.js';
package/dist/esm/index.js CHANGED
@@ -1,18 +1,16 @@
1
1
  /**
2
2
  * Aggregate public entry of `@jangts/agent-core`: Core runtime contracts, one `Support`
3
- * namespace with a few named Support helpers, and the declaration helpers of optional Kits.
3
+ * namespace, and the optional Kit declaration helpers.
4
4
  *
5
- * Layering. Core owns the runtime contracts Apps call (engine, model runner, capabilities,
6
- * context, diagnostics) and the handler contracts Core calls back into the App. Support only
7
- * supplies recommended implementations of those same contracts, so it is published as a single
8
- * namespace instead of a second dispatch layer. Kits are optional business libraries reached
9
- * through their own subpath entries; the Kit entries re-exported here are declaration helpers
10
- * and standalone modules, not additional Core guarantees. Shared utilities are re-exported
11
- * because they are needed alongside these contracts, and they carry no Agent semantics.
5
+ * Layering. Core owns the runtime contracts Apps call (engine, model runner, tools,
6
+ * context, diagnostics) and the handler contracts Core calls back into. Support supplies
7
+ * recommended implementations of those contracts. Kits are optional App-side libraries;
8
+ * they are available from this root convenience surface and from `/kits` / `/kits/*`
9
+ * subpaths. Importing a Kit is a choice, never a requirement.
12
10
  *
13
11
  * Exports are grouped by responsibility, not by dependency order. Deep subpath entries
14
12
  * (`/engine`, `/model`, `/tools`, `/context`, `/journal`, `/diagnostics`, `/kits/...`)
15
- * resolve to the same implementations, so this file is a convenience surface only.
13
+ * resolve to the same implementations.
16
14
  */
17
15
  export * from './execution/engine.js';
18
16
  export { getErrorInfo } from './errors.js';
@@ -22,23 +20,28 @@ export * from './model/index.js';
22
20
  export * from './capabilities/index.js';
23
21
  export * from './context/fragments.js';
24
22
  export * from './context/journal.js';
25
- // Named re-export: the context barrel also forwards its Kit evidence helpers, which the
26
- // root surface publishes separately below.
27
- export { assembleFragments } from './context/assembly.js';
23
+ export * from './context/assembly.js';
28
24
  export * from './support/context/assembly.js';
29
25
  export { defineEvidenceChecklist, defineEvidenceProjection } from './kits/evidence.js';
26
+ export { defineCommand, commandSchema } from './kits/interaction/command.js';
27
+ export * from './kits/interaction/commands.js';
28
+ export * from './kits/interaction/transfer.js';
29
+ export * from './kits/interaction/handlers.js';
30
30
  export * from './kits/presentation/events.js';
31
31
  export * from './support/transport/index.js';
32
32
  export * from './support/model/chat-completions.js';
33
+ export * from './support/model/compatible-provider.js';
34
+ export * from './support/model/transports.js';
35
+ export * from './support/model/interactions/index.js';
33
36
  export * from './utils/index.js';
34
37
  export * from './kits/presentation/templates.js';
35
38
  export { defineRetrieval } from './kits/retrieval.js';
36
39
  export { defineTextSkillLoader } from './kits/text-skills.js';
37
40
  export * from './diagnostics/index.js';
38
- export * from './kits/intents/registry.js';
39
- export * from './kits/intents/scopes.js';
41
+ export * from './kits/domains/registry.js';
42
+ export * from './kits/domains/scopes.js';
40
43
  export { ToolLifecycleRegistry } from './kits/tools.js';
41
- export * from './kits/intents/catalog.js';
44
+ export * from './kits/domains/catalog.js';
42
45
  export * from './support/registration.js';
43
46
  export { defineCandidateSelection } from './kits/candidates.js';
44
47
  /** App-facing helpers and their types are consumed through the root Support namespace. */
@@ -36,7 +36,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
36
36
  readerId: string;
37
37
  outputId: string;
38
38
  scopeId: string | undefined;
39
- intentIds: readonly any[];
39
+ goalIds: readonly any[];
40
40
  checkIds: readonly any[];
41
41
  metadata: Data;
42
42
  }[];
@@ -64,7 +64,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
64
64
  readerId: string;
65
65
  outputId: string;
66
66
  scopeId: string | undefined;
67
- intentIds: readonly any[];
67
+ goalIds: readonly any[];
68
68
  checkIds: readonly any[];
69
69
  inputSchema: import("../../index.js").SchemaAdapter<Input>;
70
70
  metadata: Data;
@@ -76,7 +76,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
76
76
  readerId: string;
77
77
  outputId: string;
78
78
  scopeId: string | undefined;
79
- intentIds: readonly any[];
79
+ goalIds: readonly any[];
80
80
  checkIds: readonly any[];
81
81
  inputSchema: import("../../index.js").SchemaAdapter<Input>;
82
82
  metadata: Data;
@@ -87,7 +87,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
87
87
  readerId: string;
88
88
  outputId: string;
89
89
  scopeId: string | undefined;
90
- intentIds: readonly any[];
90
+ goalIds: readonly any[];
91
91
  checkIds: readonly any[];
92
92
  inputSchema: import("../../index.js").SchemaAdapter<Input>;
93
93
  metadata: Data;
@@ -99,7 +99,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
99
99
  readerId: string;
100
100
  outputId: string;
101
101
  scopeId: string | undefined;
102
- intentIds: readonly any[];
102
+ goalIds: readonly any[];
103
103
  checkIds: readonly any[];
104
104
  inputSchema: import("../../index.js").SchemaAdapter<Input>;
105
105
  metadata: Data;
@@ -110,7 +110,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
110
110
  readerId: string;
111
111
  outputId: string;
112
112
  scopeId: string | undefined;
113
- intentIds: readonly any[];
113
+ goalIds: readonly any[];
114
114
  checkIds: readonly any[];
115
115
  inputSchema: import("../../index.js").SchemaAdapter<Input>;
116
116
  metadata: Data;
@@ -51,10 +51,10 @@ export function defineAnswerTaskCatalog(definitions, ports) {
51
51
  !definition.description?.trim() ||
52
52
  !readers.has(definition.readerId) ||
53
53
  !outputs.has(definition.outputId) ||
54
- !Array.isArray(definition.intentIds) ||
55
- !definition.intentIds.length ||
56
- definition.intentIds.some((id) => typeof id !== 'string' || !id.trim()) ||
57
- new Set(definition.intentIds).size !== definition.intentIds.length ||
54
+ !Array.isArray(definition.goalIds) ||
55
+ !definition.goalIds.length ||
56
+ definition.goalIds.some((id) => typeof id !== 'string' || !id.trim()) ||
57
+ new Set(definition.goalIds).size !== definition.goalIds.length ||
58
58
  !Array.isArray(definition.checkIds) ||
59
59
  new Set(definition.checkIds).size !== definition.checkIds.length ||
60
60
  definition.checkIds.some((id) => !checkIds.includes(id)))
@@ -68,7 +68,7 @@ export function defineAnswerTaskCatalog(definitions, ports) {
68
68
  readerId: definition.readerId,
69
69
  outputId: definition.outputId,
70
70
  scopeId: definition.scopeId,
71
- intentIds: Object.freeze([...definition.intentIds]),
71
+ goalIds: Object.freeze([...definition.goalIds]),
72
72
  checkIds: Object.freeze([...definition.checkIds]),
73
73
  inputSchema: snapshotSchemaAdapter(definition.inputSchema),
74
74
  metadata,
@@ -0,0 +1,42 @@
1
+ import type { ModelTool } from '../../structs/capabilities/model.js';
2
+ import type { AgentCatalogPorts, CatalogGoal, CatalogScope } from '../../structs/kits/domains/catalog.js';
3
+ /**
4
+ * Compile a catalog projection over the App's live registries.
5
+ *
6
+ * The actual registries determine availability and relationships. No parallel capability list
7
+ * exists: `goalIds` filters by tool support, `modelCatalog` narrows to the currently accepted
8
+ * task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
9
+ *
10
+ * @param ports - Sources for Tool ids, goals, scopes, the current task, the tool registry
11
+ * and the `restrictToTask` switch.
12
+ * @returns A frozen projection with `goalIds`, `goalDelegates`, `goalCatalog`,
13
+ * `scopeCatalog` and `modelCatalog`.
14
+ * @throws TypeError When a supplied predicate does not return a boolean synchronously.
15
+ */
16
+ export declare function defineAgentCatalog<App, Id extends string, Goal extends CatalogGoal<Id>, Scope extends CatalogScope>(ports: AgentCatalogPorts<App, Id, Goal, Scope>): Readonly<{
17
+ goalIds: (app: App) => Id[];
18
+ goalDelegates: (app?: App) => Map<Id, string[]>;
19
+ goalCatalog: (app: App) => (Omit<Goal & Partial<ModelTool<unknown, unknown, App>>, "resolve" | "inputSchema" | "active" | "asIntent"> & {
20
+ delegates: string[];
21
+ scopeIds: string[];
22
+ toolIds: string[];
23
+ description?: string | undefined;
24
+ })[];
25
+ scopeCatalog: (app: App) => (Scope & {
26
+ toolIds: string[];
27
+ })[];
28
+ modelCatalog(app: App): {
29
+ availableGoalIds: (Goal & Partial<ModelTool<unknown, unknown, App>>)["id"][];
30
+ availableGoals: (Omit<Goal & Partial<ModelTool<unknown, unknown, App>>, "resolve" | "inputSchema" | "active" | "asIntent"> & {
31
+ delegates: string[];
32
+ scopeIds: string[];
33
+ toolIds: string[];
34
+ description?: string | undefined;
35
+ })[];
36
+ availableScopes: (Scope & {
37
+ toolIds: string[];
38
+ })[];
39
+ availableTools: import("./catalog.js").DescribedTool[];
40
+ };
41
+ }>;
42
+ export type * from '../../structs/kits/domains/catalog.js';
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Domain Tools Kit: project registered goals, scopes and tools into one task-facing catalog.
3
+ *
4
+ * Place in the package: part of the domain Tool Kit. It reads the actual registries supplied by
5
+ * the App instead of maintaining a parallel capability list, so an intent is only advertised
6
+ * when its tools, scopes and availability agree.
7
+ *
8
+ * Exports: `defineAgentCatalog`, and the catalog intent/scope/port types.
9
+ */
10
+ import { booleanResult } from '../../utils/synchronous.js';
11
+ import { toolActive } from '../../capabilities/tool-conditions.js';
12
+ /**
13
+ * Compile a catalog projection over the App's live registries.
14
+ *
15
+ * The actual registries determine availability and relationships. No parallel capability list
16
+ * exists: `goalIds` filters by tool support, `modelCatalog` narrows to the currently accepted
17
+ * task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
18
+ *
19
+ * @param ports - Sources for Tool ids, goals, scopes, the current task, the tool registry
20
+ * and the `restrictToTask` switch.
21
+ * @returns A frozen projection with `goalIds`, `goalDelegates`, `goalCatalog`,
22
+ * `scopeCatalog` and `modelCatalog`.
23
+ * @throws TypeError When a supplied predicate does not return a boolean synchronously.
24
+ */
25
+ export function defineAgentCatalog(ports) {
26
+ const ids = ports.goalIds.bind(ports), goals = ports.goals.bind(ports), scopes = ports.scopes.bind(ports), task = ports.currentTask.bind(ports);
27
+ const tools = {
28
+ values: ports.tools.values.bind(ports.tools),
29
+ has: ports.tools.has.bind(ports.tools),
30
+ supports: ports.tools.supportsGoal.bind(ports.tools),
31
+ describe: ports.tools.describe.bind(ports.tools),
32
+ };
33
+ const restrict = ports.restrictToTask !== false;
34
+ const boolean = (value) => booleanResult(value, 'Catalog predicates must be synchronous', 'Catalog predicates must return boolean');
35
+ /** Whether one goal is active and its demand metadata currently participates. */
36
+ const goalAvailable = (goal, app) => {
37
+ const tool = goal;
38
+ if (!toolActive(tool.active, app))
39
+ return false;
40
+ const metadata = tool.asIntent;
41
+ if (metadata === undefined || metadata === true || typeof metadata === 'string')
42
+ return true;
43
+ if (typeof metadata === 'function')
44
+ return toolActive(metadata, app);
45
+ return toolActive(metadata.when, app);
46
+ };
47
+ const goalIds = (app) => ids(app).filter((id) => boolean(tools.supports(id, app)));
48
+ const goalDelegates = (app) => new Map(goals().map((goal) => {
49
+ const metadata = goal.asIntent;
50
+ const explicit = typeof metadata === 'object' ? metadata.delegates : undefined;
51
+ return [
52
+ goal.id,
53
+ explicit
54
+ ? [...explicit]
55
+ : [
56
+ ...new Set([
57
+ ...goal.delegates,
58
+ ...[...tools.values()]
59
+ .filter((tool) => tool.lifecycle?.id &&
60
+ (app === undefined || toolActive(tool.active, app)) &&
61
+ (tool.goalIds === 'all' || tool.goalIds.includes(goal.id)))
62
+ .map((tool) => tool.lifecycle.id),
63
+ ]),
64
+ ],
65
+ ];
66
+ }));
67
+ const goalCatalog = (app) => {
68
+ const selected = goalIds(app), described = tools.describe('model', app), delegates = goalDelegates(app);
69
+ return goals(selected)
70
+ .filter((goal) => goalAvailable(goal, app))
71
+ .map((goal) => {
72
+ const { inputSchema: _schema, resolve: _resolve, active: _active, asIntent: _asIntent, ...metadata } = goal;
73
+ const demandDescription = typeof _asIntent === 'string'
74
+ ? _asIntent
75
+ : typeof _asIntent === 'object' && _asIntent !== null
76
+ ? _asIntent.description
77
+ : undefined;
78
+ return {
79
+ ...metadata,
80
+ ...(demandDescription ? { description: demandDescription } : {}),
81
+ delegates: delegates.get(goal.id) ?? [...goal.delegates],
82
+ scopeIds: scopes([goal.id]).map((scope) => scope.id),
83
+ toolIds: described
84
+ .filter((tool) => tool.goalIds.includes(goal.id))
85
+ .map((tool) => tool.id),
86
+ };
87
+ });
88
+ };
89
+ const scopeCatalog = (app) => scopes(goalCatalog(app).map((goal) => goal.id)).map((scope) => ({
90
+ ...scope,
91
+ toolIds: scope.toolIds.filter(tools.has),
92
+ }));
93
+ return Object.freeze({
94
+ goalIds,
95
+ goalDelegates,
96
+ goalCatalog,
97
+ scopeCatalog,
98
+ modelCatalog(app) {
99
+ const accepted = restrict ? task(app) : undefined, selected = goalIds(app).filter((id) => !accepted || id === accepted.goalId), available = goalCatalog(app).filter((intent) => selected.includes(intent.id));
100
+ return {
101
+ availableGoalIds: available.map((intent) => intent.id),
102
+ availableGoals: available.map((intent) => accepted ? { ...intent, scopeIds: accepted.scopeId ? [accepted.scopeId] : [] } : intent),
103
+ availableScopes: scopeCatalog(app).filter((scope) => !accepted || scope.id === accepted.scopeId),
104
+ availableTools: tools
105
+ .describe('model', app)
106
+ .filter((tool) => !accepted || tool.goalIds.includes(accepted.goalId)),
107
+ };
108
+ },
109
+ });
110
+ }
@@ -0,0 +1,4 @@
1
+ /** Optional domain Tool constraints, scope registries and task-facing projections. */
2
+ export * from './registry.js';
3
+ export * from './scopes.js';
4
+ export * from './catalog.js';
@@ -0,0 +1,4 @@
1
+ /** Optional domain Tool constraints, scope registries and task-facing projections. */
2
+ export * from './registry.js';
3
+ export * from './scopes.js';
4
+ export * from './catalog.js';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Domain Tools Kit: an ordered, sealable registry of domain Tool declarations.
3
+ *
4
+ * Place in the package: part of the domain Tool Kit. Goal semantics and the allowed vocabulary
5
+ * (scope modes, target modes, context tiers, delegates, actions) are App configuration; this class
6
+ * owns the common lifecycle — validation, ordering, duplicate detection and sealing.
7
+ *
8
+ * Exports: `IntentRegistry`, `createIntentRegistry`, and the domain Tool registry types.
9
+ */
10
+ import type { IntentTool, IntentToolRegistration, IntentDescription, IntentPolicy, IntentId, RegisteredIntent } from '../../structs/kits/domains/registry.js';
11
+ import { ModelToolRegistry } from '../../capabilities/model.js';
12
+ /**
13
+ * Goal semantics and allowed values are configuration; the registry owns their common lifecycle.
14
+ *
15
+ * Registration order is preserved by `ids`, `definitions`, `values` and `entries`; once
16
+ * `seal()` is called the set is final and further registration is rejected.
17
+ */
18
+ export declare class IntentRegistry<Definition extends IntentToolRegistration = IntentToolRegistration> {
19
+ /** Create and seal a complete catalog in one call. */
20
+ static readonly create: typeof createIntentRegistry;
21
+ private readonly byId;
22
+ private sealed;
23
+ private modelView?;
24
+ private readonly policy;
25
+ /**
26
+ * @param policy - Optional id pattern, vocabulary lists, error wording and assertion hook.
27
+ * Lists and the pattern are copied so later mutation of the input cannot weaken checks.
28
+ */
29
+ constructor(policy?: IntentPolicy<Definition>);
30
+ /**
31
+ * Validate, freeze and add one domain Tool.
32
+ *
33
+ * Checks run in a fixed order — sealed, identity, context contract, auxiliary actions,
34
+ * handoff, plan, delegates — so the reported violation is stable when several rules fail.
35
+ *
36
+ * @param input - Goal declaration; the App's own assertion receives this original object,
37
+ * not the compiled copy, so helpers and prototype methods keep working.
38
+ * @returns This registry, for chaining.
39
+ * @throws A configured error for a sealed registry, invalid identity or vocabulary values,
40
+ * empty/duplicate delegates, or a duplicate Tool id.
41
+ */
42
+ register(input: Definition): this;
43
+ /** Register every domain Tool in iteration order. */
44
+ registerAll(definitions: Iterable<Definition>): this;
45
+ /** Registered domain Tool for `id`, or `undefined` when it is absent. */
46
+ get(goal: string): RegisteredIntent<Definition> | undefined;
47
+ /** Whether a Tool id is registered. */
48
+ has(goal: string): boolean;
49
+ /** Registered Tool ids in registration order. */
50
+ ids(): readonly IntentId<Definition>[];
51
+ /** Registered goals in registration order. */
52
+ get definitions(): readonly RegisteredIntent<Definition>[];
53
+ /** Iterate the registered goals. */
54
+ values(): MapIterator<Readonly<Omit<Readonly<IntentTool & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & import("../../index.js").ModelTool<any, any, any> & { readonly [Key in keyof Pick<Definition, Extract<keyof Definition, "delegates" | "auxiliaryActions">>]: Readonly<Definition[Key]>; } & {
55
+ id: Definition["id"];
56
+ delegates: Readonly<NonNullable<Definition["delegates"]>>;
57
+ }>>;
58
+ /** Demand discovery uses tool metadata; domain fields remain attached to these same IDs. */
59
+ withIntent(context: unknown): ModelToolRegistry;
60
+ /** Resolve a grouped transport's selected Tool through that Tool's own parser and resolver. */
61
+ resolve(selection: import('../../structs/capabilities/model.js').ModelSelection, context: Readonly<{
62
+ stageId: string;
63
+ }>): unknown;
64
+ /** Explicit node selection uses the same immutable model projection. */
65
+ select(ids: readonly string[], ...context: [] | [unknown]): ModelToolRegistry;
66
+ /** Cache only immutable declarations; request activation is evaluated by each projection. */
67
+ private models;
68
+ /** Iterate `[id, tool]` pairs. */
69
+ entries(): MapIterator<[string, Readonly<Omit<Readonly<IntentTool & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & import("../../index.js").ModelTool<any, any, any> & { readonly [Key in keyof Pick<Definition, Extract<keyof Definition, "delegates" | "auxiliaryActions">>]: Readonly<Definition[Key]>; } & {
70
+ id: Definition["id"];
71
+ delegates: Readonly<NonNullable<Definition["delegates"]>>;
72
+ }>]>;
73
+ /**
74
+ * Registered domain Tool for `id`.
75
+ *
76
+ * @throws TypeError When the id is not registered.
77
+ */
78
+ require(id: string): RegisteredIntent<Definition>;
79
+ /** Whether the Tool declares this delegate; unknown goals allow nothing. */
80
+ allows(goal: string, delegate: string): boolean;
81
+ /**
82
+ * Copy the selected goals out of the registry.
83
+ *
84
+ * @param goals - Ids to include; the default is every registered id, in registry order.
85
+ * @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
86
+ */
87
+ describe(goals?: readonly string[]): IntentDescription<Definition>[];
88
+ /** Finalize the registry; no registration is accepted afterwards. */
89
+ seal(): this;
90
+ }
91
+ /**
92
+ * Create and seal a complete catalog; use the constructor for incremental installation.
93
+ *
94
+ * @param definitions - Goal declarations registered in iteration order.
95
+ * @param policy - Optional registry policy forwarded to the constructor.
96
+ * @returns A sealed registry.
97
+ * @throws A configured error for the first invalid or duplicate declaration.
98
+ */
99
+ export declare function createIntentRegistry<Definition extends IntentToolRegistration>(definitions: Iterable<Definition>, policy?: IntentPolicy<Definition>): IntentRegistry<Definition>;
100
+ export type { IntentTool, IntentToolRegistration, IntentDescription, IntentPolicy, IntentId, RegisteredIntent, } from '../../structs/kits/domains/registry.js';