@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,8 +1,9 @@
1
1
  import { assertion } from '../../utils/synchronous.js';
2
2
  import { breakWhile } from '../../utils/rules.js';
3
3
  import { registrationData } from '../../utils/registration.js';
4
+ import { ModelToolRegistry } from '../../capabilities/model.js';
4
5
  /**
5
- * Intent semantics and allowed values are configuration; the registry owns their common lifecycle.
6
+ * Goal semantics and allowed values are configuration; the registry owns their common lifecycle.
6
7
  *
7
8
  * Registration order is preserved by `ids`, `definitions`, `values` and `entries`; once
8
9
  * `seal()` is called the set is final and further registration is rejected.
@@ -12,6 +13,7 @@ export class IntentRegistry {
12
13
  static create = createIntentRegistry;
13
14
  byId = new Map();
14
15
  sealed = false;
16
+ modelView;
15
17
  policy;
16
18
  /**
17
19
  * @param policy - Optional id pattern, vocabulary lists, error wording and assertion hook.
@@ -25,7 +27,7 @@ export class IntentRegistry {
25
27
  'targetModes',
26
28
  'contextTiers',
27
29
  'actions',
28
- 'steps',
30
+ 'delegates',
29
31
  'handoffValues',
30
32
  'tags',
31
33
  ];
@@ -47,16 +49,16 @@ export class IntentRegistry {
47
49
  });
48
50
  }
49
51
  /**
50
- * Validate, freeze and add one intent.
52
+ * Validate, freeze and add one domain Tool.
51
53
  *
52
54
  * Checks run in a fixed order — sealed, identity, context contract, auxiliary actions,
53
- * handoff, plan, steps — so the reported violation is stable when several rules fail.
55
+ * handoff, plan, delegates — so the reported violation is stable when several rules fail.
54
56
  *
55
- * @param input - Intent declaration; the App's own assertion receives this original object,
57
+ * @param input - Goal declaration; the App's own assertion receives this original object,
56
58
  * not the compiled copy, so helpers and prototype methods keep working.
57
59
  * @returns This registry, for chaining.
58
60
  * @throws A configured error for a sealed registry, invalid identity or vocabulary values,
59
- * empty/duplicate steps, or a duplicate intent id.
61
+ * empty/duplicate delegates, or a duplicate Tool id.
60
62
  */
61
63
  register(input) {
62
64
  const id = input.id;
@@ -64,7 +66,7 @@ export class IntentRegistry {
64
66
  ...registrationData(input, [
65
67
  'id',
66
68
  'description',
67
- 'steps',
69
+ 'delegates',
68
70
  'scopePolicy',
69
71
  'targetPolicy',
70
72
  'contextTier',
@@ -74,7 +76,11 @@ export class IntentRegistry {
74
76
  ]),
75
77
  id,
76
78
  description: input.description,
77
- steps: input.steps,
79
+ delegates: (typeof input.asIntent === 'object' && input.asIntent !== null
80
+ ? input.asIntent.delegates
81
+ : undefined) ??
82
+ input.delegates ??
83
+ [],
78
84
  scopePolicy: input.scopePolicy,
79
85
  targetPolicy: input.targetPolicy,
80
86
  contextTier: input.contextTier,
@@ -83,7 +89,7 @@ export class IntentRegistry {
83
89
  preparedHandoff: input.preparedHandoff,
84
90
  };
85
91
  const policy = this.policy;
86
- const invalid = policy.errors?.invalid ?? 'Invalid intent definition';
92
+ const invalid = policy.errors?.invalid ?? 'Invalid intent Tool definition';
87
93
  const tags = policy.tags ?? [];
88
94
  const validName = (name) => {
89
95
  if (typeof name !== 'string' || !name.trim())
@@ -141,75 +147,112 @@ export class IntentRegistry {
141
147
  },
142
148
  {
143
149
  occur: [
144
- () => !definition.steps.length,
145
- () => definition.steps.some((step) => policy.steps !== undefined && !policy.steps.includes(step)),
146
- () => new Set(definition.steps).size !== definition.steps.length,
150
+ () => (input.delegates !== undefined ||
151
+ (typeof input.asIntent === 'object' &&
152
+ input.asIntent !== null &&
153
+ input.asIntent.delegates !== undefined)) &&
154
+ !definition.delegates.length,
155
+ () => definition.delegates.some((delegate) => policy.delegates !== undefined && !policy.delegates.includes(delegate)),
156
+ () => new Set(definition.delegates).size !== definition.delegates.length,
147
157
  ],
148
158
  error: invalid,
149
- tags: ['steps'],
159
+ tags: ['delegates'],
150
160
  },
151
161
  ], tags);
152
162
  // App assertions may use implementation helpers; never pass a compiled view as the source
153
163
  // instance.
154
164
  assertion(policy.assertDefinition?.(input), 'Registry definition assertions must return void synchronously');
155
- breakWhile(this.byId.has(definition.id), () => policy.errors?.duplicate?.(definition.id) ??
156
- new Error(`Duplicate intent: ${definition.id}`), [...tags, 'duplicate']);
165
+ breakWhile(this.byId.has(definition.id), () => policy.errors?.duplicate?.(definition.id) ?? new Error(`Duplicate tool: ${definition.id}`), [...tags, 'duplicate']);
157
166
  this.byId.set(definition.id, Object.freeze({
158
167
  ...definition,
159
- steps: Object.freeze([...definition.steps]),
168
+ ...new ModelToolRegistry([
169
+ {
170
+ id: input.id,
171
+ description: input.description,
172
+ active: typeof input.active === 'function' ? input.active.bind(input) : input.active,
173
+ asIntent: typeof input.asIntent === 'function' ? input.asIntent.bind(input) : input.asIntent,
174
+ inputSchema: input.inputSchema ?? {
175
+ jsonSchema: { type: 'object' },
176
+ parse(value) {
177
+ if (!value || typeof value !== 'object' || Array.isArray(value))
178
+ throw new TypeError('Tool input must be an object');
179
+ return value;
180
+ },
181
+ },
182
+ resolve: input.resolve?.bind(input) ?? ((value) => ({ toolId: id, input: value })),
183
+ },
184
+ ]).require(input.id),
185
+ delegates: Object.freeze([...definition.delegates]),
160
186
  ...(definition.auxiliaryActions
161
187
  ? { auxiliaryActions: Object.freeze([...definition.auxiliaryActions]) }
162
188
  : {}),
163
189
  }));
190
+ this.modelView = undefined;
164
191
  return this;
165
192
  }
166
- /** Register every intent in iteration order. */
193
+ /** Register every domain Tool in iteration order. */
167
194
  registerAll(definitions) {
168
195
  for (const definition of definitions)
169
196
  this.register(definition);
170
197
  return this;
171
198
  }
172
- /** Registered intent for `goal`, or `undefined` when it is absent. */
199
+ /** Registered domain Tool for `id`, or `undefined` when it is absent. */
173
200
  get(goal) {
174
201
  return this.byId.get(goal);
175
202
  }
176
- /** Whether an intent id is registered. */
203
+ /** Whether a Tool id is registered. */
177
204
  has(goal) {
178
205
  return this.byId.has(goal);
179
206
  }
180
- /** Registered intent ids in registration order. */
207
+ /** Registered Tool ids in registration order. */
181
208
  ids() {
182
209
  return Object.freeze([...this.byId.keys()]);
183
210
  }
184
- /** Registered intents in registration order. */
211
+ /** Registered goals in registration order. */
185
212
  get definitions() {
186
213
  return Object.freeze([...this.byId.values()]);
187
214
  }
188
- /** Iterate the registered intents. */
215
+ /** Iterate the registered goals. */
189
216
  values() {
190
217
  return this.byId.values();
191
218
  }
192
- /** Iterate `[id, intent]` pairs. */
219
+ /** Demand discovery uses tool metadata; domain fields remain attached to these same IDs. */
220
+ withIntent(context) {
221
+ return this.models().withIntent(context);
222
+ }
223
+ /** Resolve a grouped transport's selected Tool through that Tool's own parser and resolver. */
224
+ resolve(selection, context) {
225
+ return this.models().resolve(selection, context);
226
+ }
227
+ /** Explicit node selection uses the same immutable model projection. */
228
+ select(ids, ...context) {
229
+ return context.length ? this.models().select(ids, context[0]) : this.models().select(ids);
230
+ }
231
+ /** Cache only immutable declarations; request activation is evaluated by each projection. */
232
+ models() {
233
+ return (this.modelView ??= new ModelToolRegistry(this.byId.values()).seal());
234
+ }
235
+ /** Iterate `[id, tool]` pairs. */
193
236
  entries() {
194
237
  return this.byId.entries();
195
238
  }
196
239
  /**
197
- * Registered intent for `id`.
240
+ * Registered domain Tool for `id`.
198
241
  *
199
242
  * @throws TypeError When the id is not registered.
200
243
  */
201
244
  require(id) {
202
245
  const value = this.byId.get(id);
203
246
  if (!value)
204
- throw new TypeError(`Unknown intent: ${id}`);
247
+ throw new TypeError(`Unknown tool: ${id}`);
205
248
  return value;
206
249
  }
207
- /** Whether the intent declares this step; unknown intents allow nothing. */
208
- allows(goal, step) {
209
- return this.byId.get(goal)?.steps.includes(step) ?? false;
250
+ /** Whether the Tool declares this delegate; unknown goals allow nothing. */
251
+ allows(goal, delegate) {
252
+ return this.byId.get(goal)?.delegates.includes(delegate) ?? false;
210
253
  }
211
254
  /**
212
- * Copy the selected intents out of the registry.
255
+ * Copy the selected goals out of the registry.
213
256
  *
214
257
  * @param goals - Ids to include; the default is every registered id, in registry order.
215
258
  * @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
@@ -218,7 +261,10 @@ export class IntentRegistry {
218
261
  const selected = new Set(goals);
219
262
  return [...this.byId.values()]
220
263
  .filter((item) => selected.has(item.id))
221
- .map((item) => ({ ...item, steps: [...item.steps] }));
264
+ .map((item) => ({
265
+ ...item,
266
+ delegates: [...item.delegates],
267
+ }));
222
268
  }
223
269
  /** Finalize the registry; no registration is accepted afterwards. */
224
270
  seal() {
@@ -229,7 +275,7 @@ export class IntentRegistry {
229
275
  /**
230
276
  * Create and seal a complete catalog; use the constructor for incremental installation.
231
277
  *
232
- * @param definitions - Intent declarations registered in iteration order.
278
+ * @param definitions - Goal declarations registered in iteration order.
233
279
  * @param policy - Optional registry policy forwarded to the constructor.
234
280
  * @returns A sealed registry.
235
281
  * @throws A configured error for the first invalid or duplicate declaration.
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Intents Kit: an ordered, sealable registry of scope declarations and their aliases.
2
+ * Domain Tools Kit: an ordered, sealable registry of scope declarations and their aliases.
3
3
  *
4
- * Place in the package: part of the `intents` Kit. Categories, extra fields and intent
4
+ * Place in the package: part of the domain Tool Kit. Categories, extra fields and intent
5
5
  * acceptance policy are App configuration; this class owns validation, alias normalization,
6
6
  * relationship lookups and sealing.
7
7
  *
8
8
  * Exports: `ScopeRegistry`, `createScopeRegistry`, and the scope registry types.
9
9
  */
10
- import type { ScopeDefinition, ScopeDescription, ScopeRegistryPolicy, RegisteredScope, RegisteredScopeEvidence } from '../../structs/kits/intents/scopes.js';
10
+ import type { ScopeDefinition, ScopeDescription, ScopeRegistryPolicy, RegisteredScope, RegisteredScopeEvidence } from '../../structs/kits/domains/scopes.js';
11
11
  /**
12
12
  * Generic scope relationships; categories, intent policy and extra fields belong to the host.
13
13
  *
@@ -33,11 +33,11 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
33
33
  * Every name is checked for conflicts before any of them is stored, so a rejected scope
34
34
  * leaves no partial alias entry behind.
35
35
  *
36
- * @param input - Scope declaration; the raw object is retained for `acceptsIntent` overrides
36
+ * @param input - Scope declaration; the raw object is retained for `acceptsTool` overrides
37
37
  * while the compiled copy serves lookups.
38
38
  * @returns This registry, for chaining.
39
39
  * @throws A configured error for a sealed registry, an invalid name/description/category,
40
- * a missing required binding, duplicate intent ids or an already-claimed name.
40
+ * a missing required binding, duplicate Tool ids or an already-claimed name.
41
41
  */
42
42
  register(input: Definition): this;
43
43
  /** Register every scope in iteration order. */
@@ -45,9 +45,9 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
45
45
  /** Finalize the registry; no registration is accepted afterwards. */
46
46
  seal(): this;
47
47
  /** Registered scopes in registration order. */
48
- get definitions(): readonly Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
48
+ get definitions(): readonly Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "goalIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
49
49
  readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
50
- readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
50
+ readonly goalIds: [NonNullable<Definition["goalIds"]>] extends [never] ? readonly [] : NonNullable<Definition["goalIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["goalIds"]> : readonly string[];
51
51
  readonly queryScopeIds: [NonNullable<Definition["queryScopeIds"]>] extends [never] ? readonly [] : NonNullable<Definition["queryScopeIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["queryScopeIds"]> : readonly string[];
52
52
  readonly knowledgeTopicIds: [NonNullable<Definition["knowledgeTopicIds"]>] extends [never] ? readonly [] : NonNullable<Definition["knowledgeTopicIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["knowledgeTopicIds"]> : readonly string[];
53
53
  readonly aliases: [NonNullable<Definition["aliases"]>] extends [never] ? readonly [] : NonNullable<Definition["aliases"]> extends readonly string[] ? Readonly<readonly string[] & Definition["aliases"]> : readonly string[];
@@ -57,9 +57,9 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
57
57
  /** Registered scope ids in registration order; aliases are not included. */
58
58
  ids(): readonly string[];
59
59
  /** Iterate the registered scopes. */
60
- values(): MapIterator<Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
60
+ values(): MapIterator<Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "goalIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
61
61
  readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
62
- readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
62
+ readonly goalIds: [NonNullable<Definition["goalIds"]>] extends [never] ? readonly [] : NonNullable<Definition["goalIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["goalIds"]> : readonly string[];
63
63
  readonly queryScopeIds: [NonNullable<Definition["queryScopeIds"]>] extends [never] ? readonly [] : NonNullable<Definition["queryScopeIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["queryScopeIds"]> : readonly string[];
64
64
  readonly knowledgeTopicIds: [NonNullable<Definition["knowledgeTopicIds"]>] extends [never] ? readonly [] : NonNullable<Definition["knowledgeTopicIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["knowledgeTopicIds"]> : readonly string[];
65
65
  readonly aliases: [NonNullable<Definition["aliases"]>] extends [never] ? readonly [] : NonNullable<Definition["aliases"]> extends readonly string[] ? Readonly<readonly string[] & Definition["aliases"]> : readonly string[];
@@ -67,9 +67,9 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
67
67
  evidence: [NonNullable<Definition["evidence"]>] extends [never] ? readonly [] : NonNullable<Definition["evidence"]> extends readonly import("../evidence.js").EvidenceRequirement[] ? readonly import("../evidence.js").EvidenceRequirement[] & Definition["evidence"] extends infer T extends readonly import("../evidence.js").EvidenceRequirement[] ? { readonly [Index in keyof T]: Readonly<import("../../utils/registration.js").RegistrationData<T[Index]>>; } : never : readonly Readonly<import("../../utils/registration.js").RegistrationData<NonNullable<Definition["evidence"]>[number]>>[];
68
68
  }>>;
69
69
  /** Iterate `[id, scope]` pairs. */
70
- entries(): MapIterator<[string, Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
70
+ entries(): MapIterator<[string, Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "goalIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
71
71
  readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
72
- readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
72
+ readonly goalIds: [NonNullable<Definition["goalIds"]>] extends [never] ? readonly [] : NonNullable<Definition["goalIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["goalIds"]> : readonly string[];
73
73
  readonly queryScopeIds: [NonNullable<Definition["queryScopeIds"]>] extends [never] ? readonly [] : NonNullable<Definition["queryScopeIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["queryScopeIds"]> : readonly string[];
74
74
  readonly knowledgeTopicIds: [NonNullable<Definition["knowledgeTopicIds"]>] extends [never] ? readonly [] : NonNullable<Definition["knowledgeTopicIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["knowledgeTopicIds"]> : readonly string[];
75
75
  readonly aliases: [NonNullable<Definition["aliases"]>] extends [never] ? readonly [] : NonNullable<Definition["aliases"]> extends readonly string[] ? Readonly<readonly string[] & Definition["aliases"]> : readonly string[];
@@ -81,9 +81,9 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
81
81
  *
82
82
  * @throws TypeError When the name resolves to nothing.
83
83
  */
84
- require(id: string): Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
84
+ require(id: string): Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "goalIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
85
85
  readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
86
- readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
86
+ readonly goalIds: [NonNullable<Definition["goalIds"]>] extends [never] ? readonly [] : NonNullable<Definition["goalIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["goalIds"]> : readonly string[];
87
87
  readonly queryScopeIds: [NonNullable<Definition["queryScopeIds"]>] extends [never] ? readonly [] : NonNullable<Definition["queryScopeIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["queryScopeIds"]> : readonly string[];
88
88
  readonly knowledgeTopicIds: [NonNullable<Definition["knowledgeTopicIds"]>] extends [never] ? readonly [] : NonNullable<Definition["knowledgeTopicIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["knowledgeTopicIds"]> : readonly string[];
89
89
  readonly aliases: [NonNullable<Definition["aliases"]>] extends [never] ? readonly [] : NonNullable<Definition["aliases"]> extends readonly string[] ? Readonly<readonly string[] & Definition["aliases"]> : readonly string[];
@@ -99,10 +99,10 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
99
99
  /**
100
100
  * Whether a scope accepts an intent.
101
101
  *
102
- * The App may override the declared `intentIds` through `acceptsIntent`; without an
102
+ * The App may override the declared `goalIds` through `acceptsTool`; without an
103
103
  * override the membership check applies.
104
104
  */
105
- acceptsIntent(scope: string, goal: string): boolean;
105
+ acceptsTool(scope: string, goal: string): boolean;
106
106
  /** Whether the scope declares this query scope; a null scope accepts nothing. */
107
107
  acceptsQuery(scope: string | null, queryScope: string): boolean;
108
108
  /** Whether the scope belongs to the given App category. */
@@ -116,9 +116,9 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
116
116
  /** Declared context tier of one scope, if any. */
117
117
  contextTier(scope?: string | null): Definition['contextTier'] | undefined;
118
118
  /**
119
- * Copy the scopes that accept at least one of the given intents.
119
+ * Copy the scopes that accept at least one of the given goals.
120
120
  *
121
- * @param goals - Intent ids to filter by; omit to include every registered scope.
121
+ * @param goals - Goal ids to filter by; omit to include every registered scope.
122
122
  * @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
123
123
  */
124
124
  describe(goals?: readonly string[]): ScopeDescription<Definition>[];
@@ -132,4 +132,4 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
132
132
  * @throws A configured error for the first invalid or duplicate declaration.
133
133
  */
134
134
  export declare function createScopeRegistry<Definition extends ScopeDefinition>(definitions: Iterable<Definition>, policy?: ScopeRegistryPolicy<Definition>): ScopeRegistry<Definition>;
135
- export type { ScopeDefinition, ScopeDescription, ScopeRegistryPolicy, RegisteredScope, RegisteredScopeEvidence, } from '../../structs/kits/intents/scopes.js';
135
+ export type { ScopeDefinition, ScopeDescription, ScopeRegistryPolicy, RegisteredScope, RegisteredScopeEvidence, } from '../../structs/kits/domains/scopes.js';
@@ -31,7 +31,7 @@ export class ScopeRegistry {
31
31
  ...registrationData(policy, [
32
32
  'idPattern',
33
33
  'assertDefinition',
34
- 'acceptsIntent',
34
+ 'acceptsTool',
35
35
  'errors',
36
36
  ...listFields,
37
37
  ]),
@@ -43,7 +43,7 @@ export class ScopeRegistry {
43
43
  invalid: typeof invalid === 'function' ? invalid.bind(errorPorts) : invalid,
44
44
  }),
45
45
  assertDefinition: policy.assertDefinition?.bind(policy),
46
- acceptsIntent: policy.acceptsIntent?.bind(policy),
46
+ acceptsTool: policy.acceptsTool?.bind(policy),
47
47
  });
48
48
  }
49
49
  /**
@@ -52,11 +52,11 @@ export class ScopeRegistry {
52
52
  * Every name is checked for conflicts before any of them is stored, so a rejected scope
53
53
  * leaves no partial alias entry behind.
54
54
  *
55
- * @param input - Scope declaration; the raw object is retained for `acceptsIntent` overrides
55
+ * @param input - Scope declaration; the raw object is retained for `acceptsTool` overrides
56
56
  * while the compiled copy serves lookups.
57
57
  * @returns This registry, for chaining.
58
58
  * @throws A configured error for a sealed registry, an invalid name/description/category,
59
- * a missing required binding, duplicate intent ids or an already-claimed name.
59
+ * a missing required binding, duplicate Tool ids or an already-claimed name.
60
60
  */
61
61
  register(input) {
62
62
  const definition = {
@@ -64,7 +64,7 @@ export class ScopeRegistry {
64
64
  'id',
65
65
  'description',
66
66
  'category',
67
- 'intentIds',
67
+ 'goalIds',
68
68
  'queryScopeIds',
69
69
  'knowledgeTopicIds',
70
70
  'toolIds',
@@ -75,7 +75,7 @@ export class ScopeRegistry {
75
75
  id: input.id,
76
76
  description: input.description,
77
77
  category: input.category,
78
- intentIds: input.intentIds ?? [],
78
+ goalIds: input.goalIds ?? [],
79
79
  queryScopeIds: input.queryScopeIds ?? [],
80
80
  knowledgeTopicIds: input.knowledgeTopicIds ?? [],
81
81
  toolIds: input.toolIds ?? [],
@@ -110,9 +110,9 @@ export class ScopeRegistry {
110
110
  tags: ['identity'],
111
111
  },
112
112
  {
113
- occur: () => policy.requireIntents === true && !definition.intentIds.length,
113
+ occur: () => policy.requireGoals === true && !definition.goalIds.length,
114
114
  error: invalid,
115
- tags: ['intents', 'required'],
115
+ tags: ['goals', 'required'],
116
116
  },
117
117
  {
118
118
  occur: [
@@ -126,18 +126,18 @@ export class ScopeRegistry {
126
126
  },
127
127
  {
128
128
  occur: [
129
- () => definition.intentIds.some((intent) => typeof intent !== 'string'),
130
- () => new Set(definition.intentIds).size !== definition.intentIds.length,
129
+ () => definition.goalIds.some((intent) => typeof intent !== 'string'),
130
+ () => new Set(definition.goalIds).size !== definition.goalIds.length,
131
131
  ],
132
132
  error: invalid,
133
- tags: ['intents', 'values'],
133
+ tags: ['goals', 'values'],
134
134
  },
135
135
  ], tags);
136
136
  assertion(policy.assertDefinition?.(input), 'Registry definition assertions must return void synchronously');
137
137
  breakWhile(names.some((name) => this.byId.has(name) || this.aliases.has(name)), invalid, [...tags, 'duplicate']);
138
138
  const frozen = Object.freeze({
139
139
  ...definition,
140
- intentIds: Object.freeze([...definition.intentIds]),
140
+ goalIds: Object.freeze([...definition.goalIds]),
141
141
  toolIds: Object.freeze([...definition.toolIds]),
142
142
  queryScopeIds: Object.freeze([...definition.queryScopeIds]),
143
143
  knowledgeTopicIds: Object.freeze([...definition.knowledgeTopicIds]),
@@ -203,16 +203,16 @@ export class ScopeRegistry {
203
203
  /**
204
204
  * Whether a scope accepts an intent.
205
205
  *
206
- * The App may override the declared `intentIds` through `acceptsIntent`; without an
206
+ * The App may override the declared `goalIds` through `acceptsTool`; without an
207
207
  * override the membership check applies.
208
208
  */
209
- acceptsIntent(scope, goal) {
209
+ acceptsTool(scope, goal) {
210
210
  const definition = this.get(scope);
211
211
  if (!definition)
212
212
  return false;
213
- const ids = definition.intentIds;
214
- return this.policy.acceptsIntent
215
- ? booleanResult(this.policy.acceptsIntent(this.sources.get(this.normalize(scope)), goal), 'Scope intent predicates must return boolean synchronously')
213
+ const ids = definition.goalIds;
214
+ return this.policy.acceptsTool
215
+ ? booleanResult(this.policy.acceptsTool(this.sources.get(this.normalize(scope)), goal), 'Scope intent predicates must return boolean synchronously')
216
216
  : ids.includes(goal);
217
217
  }
218
218
  /** Whether the scope declares this query scope; a null scope accepts nothing. */
@@ -241,18 +241,18 @@ export class ScopeRegistry {
241
241
  return this.get(scope)?.contextTier;
242
242
  }
243
243
  /**
244
- * Copy the scopes that accept at least one of the given intents.
244
+ * Copy the scopes that accept at least one of the given goals.
245
245
  *
246
- * @param goals - Intent ids to filter by; omit to include every registered scope.
246
+ * @param goals - Goal ids to filter by; omit to include every registered scope.
247
247
  * @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
248
248
  */
249
249
  describe(goals) {
250
250
  const selected = goals ? new Set(goals) : undefined;
251
251
  return [...this.byId.values()]
252
- .filter((item) => !selected || item.intentIds.some((goal) => selected.has(goal)))
252
+ .filter((item) => !selected || item.goalIds.some((goal) => selected.has(goal)))
253
253
  .map((item) => ({
254
254
  ...item,
255
- intentIds: [...item.intentIds],
255
+ goalIds: [...item.goalIds],
256
256
  queryScopeIds: [...item.queryScopeIds],
257
257
  knowledgeTopicIds: [...item.knowledgeTopicIds],
258
258
  toolIds: [...item.toolIds],
@@ -5,13 +5,13 @@
5
5
  * path; this file only exists for callers that prefer one import for the whole set. Core
6
6
  * never imports from this directory, so nothing here becomes a runtime requirement.
7
7
  *
8
- * Exports: the Kit namespaces (`Interaction`, `Intents`, `Tools`, `Knowledge`, `Answering`,
8
+ * Exports: the Kit namespaces (`Interaction`, `Tools`, `Knowledge`, `Answering`,
9
9
  * `Presentation`, `Normalization`, `Delivery`, `Projection`, `Aggregation`, `Retrieval`,
10
- * `Evidence`, `Policies`, `Candidates`, `TextSkills`, `TextSearch`, `ModelCalls`,
11
- * `VectorSearch`) plus every Kit type. Individual Kit paths stay the default.
10
+ * `Evidence`, `Policies`, `Candidates`, `TextSkills`, `TextSearch`, `TextBlocks`,
11
+ * `ModelCalls`, `VectorSearch`) plus every Kit type. Individual Kit paths stay the default.
12
12
  */
13
13
  export { Interaction } from './interaction/index.js';
14
- export { Intents } from './intents/index.js';
14
+ export * from './domains/index.js';
15
15
  export { Tools } from './tools.js';
16
16
  export { Knowledge } from './knowledge/index.js';
17
17
  export { Answering } from './answering/index.js';
@@ -27,8 +27,9 @@ export { Candidates } from './candidates.js';
27
27
  export { TextSkills } from './text-skills.js';
28
28
  export { TextSearch } from './search.js';
29
29
  export * from './search.js';
30
+ export { TextBlocks } from './text-blocks.js';
31
+ export * from './text-blocks.js';
30
32
  export * from './interaction/index.js';
31
- export * from './intents/index.js';
32
33
  export * from './tools.js';
33
34
  export * from './knowledge/index.js';
34
35
  export * from './answering/index.js';
@@ -5,13 +5,13 @@
5
5
  * path; this file only exists for callers that prefer one import for the whole set. Core
6
6
  * never imports from this directory, so nothing here becomes a runtime requirement.
7
7
  *
8
- * Exports: the Kit namespaces (`Interaction`, `Intents`, `Tools`, `Knowledge`, `Answering`,
8
+ * Exports: the Kit namespaces (`Interaction`, `Tools`, `Knowledge`, `Answering`,
9
9
  * `Presentation`, `Normalization`, `Delivery`, `Projection`, `Aggregation`, `Retrieval`,
10
- * `Evidence`, `Policies`, `Candidates`, `TextSkills`, `TextSearch`, `ModelCalls`,
11
- * `VectorSearch`) plus every Kit type. Individual Kit paths stay the default.
10
+ * `Evidence`, `Policies`, `Candidates`, `TextSkills`, `TextSearch`, `TextBlocks`,
11
+ * `ModelCalls`, `VectorSearch`) plus every Kit type. Individual Kit paths stay the default.
12
12
  */
13
13
  export { Interaction } from './interaction/index.js';
14
- export { Intents } from './intents/index.js';
14
+ export * from './domains/index.js';
15
15
  export { Tools } from './tools.js';
16
16
  export { Knowledge } from './knowledge/index.js';
17
17
  export { Answering } from './answering/index.js';
@@ -27,9 +27,10 @@ export { Candidates } from './candidates.js';
27
27
  export { TextSkills } from './text-skills.js';
28
28
  export { TextSearch } from './search.js';
29
29
  export * from './search.js';
30
+ export { TextBlocks } from './text-blocks.js';
31
+ export * from './text-blocks.js';
30
32
  // Types remain available with either individual or explicit bulk imports.
31
33
  export * from './interaction/index.js';
32
- export * from './intents/index.js';
33
34
  export * from './tools.js';
34
35
  export * from './knowledge/index.js';
35
36
  export * from './answering/index.js';
@@ -0,0 +1,42 @@
1
+ import type { CompiledReplyFormat, ReplyFormatCheck, ReplyFormatOptions } from '../../structs/kits/presentation/formats.js';
2
+ /**
3
+ * Checks shared by text replies. Limits stay with the App template; only the comparison lives here.
4
+ */
5
+ export declare const replyFormatChecks: Readonly<{
6
+ /**
7
+ * Every bubble is non-empty and the total (primary text included) stays within the limit.
8
+ *
9
+ * @param totalLimit - Maximum bubble count including the primary text.
10
+ * @returns The reusable `bubbles` check.
11
+ */
12
+ bubbles(totalLimit: number): ReplyFormatCheck;
13
+ /**
14
+ * The joined reply stays within the app's text budget.
15
+ *
16
+ * @param maxChars - Maximum total characters across bubbles.
17
+ * @returns The reusable `text-budget` check.
18
+ */
19
+ textBudget(maxChars: number): ReplyFormatCheck;
20
+ }>;
21
+ /**
22
+ * Normalize a reply that has no declared format: drop blank bubbles and merge overflow into the
23
+ * last allowed one. Text content is preserved.
24
+ *
25
+ * @param bubbles - Primary text followed by follow-up bubbles.
26
+ * @param limit - Maximum number of bubbles to keep.
27
+ * @returns Non-empty bubbles within the limit.
28
+ */
29
+ export declare function mergeReplyBubbles(bubbles: readonly string[], limit: number): string[];
30
+ /**
31
+ * Compile reply formats so that checks run only for templates the current turn uses.
32
+ *
33
+ * @param options - Declared formats and the checks their ids refer to.
34
+ * @returns A frozen catalog with `resolve(context)`.
35
+ * @throws TypeError For duplicate or invalid ids, a format without checks, an unknown check id,
36
+ * or a non-function `when`/`accepts`.
37
+ */
38
+ export declare function defineReplyFormats<Context = unknown>(options: ReplyFormatOptions<Context>): Readonly<{
39
+ /** The template this turn uses, or `undefined` when it has no output-format requirement. */
40
+ resolve(context: Context): CompiledReplyFormat | undefined;
41
+ }>;
42
+ export type { CompiledReplyFormat, ReplyFormatCheck, ReplyFormatDefinition, ReplyFormatOptions, } from '../../structs/kits/presentation/formats.js';