@orkestrel/toolbox 0.0.6 → 0.0.7
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.
- package/dist/src/core/index.cjs +77 -209
- package/dist/src/core/index.d.cts +34 -94
- package/dist/src/core/index.d.ts +34 -94
- package/dist/src/core/index.js +78 -209
- package/dist/src/server/index.cjs +13 -11
- package/dist/src/server/index.js +14 -12
- package/package.json +14 -13
- package/dist/src/core/index.cjs.map +0 -1
- package/dist/src/core/index.js.map +0 -1
- package/dist/src/server/index.cjs.map +0 -1
- package/dist/src/server/index.js.map +0 -1
|
@@ -21,7 +21,6 @@ import { ObjectShape } from '@orkestrel/contract';
|
|
|
21
21
|
import { OptionalShape } from '@orkestrel/contract';
|
|
22
22
|
import { OrderDirection } from '@orkestrel/database';
|
|
23
23
|
import { PrimaryMap } from '@orkestrel/database';
|
|
24
|
-
import { PromptType } from '@orkestrel/terminal';
|
|
25
24
|
import { QueryInput } from '@orkestrel/database';
|
|
26
25
|
import { RelationErrorCode } from '@orkestrel/relation';
|
|
27
26
|
import { RelationManagerInterface } from '@orkestrel/relation';
|
|
@@ -214,7 +213,7 @@ export declare const ANSWER_TOOL_NAME = "answer";
|
|
|
214
213
|
* for the full teaching description; the full text stays retrievable via
|
|
215
214
|
* {@link import('./factories.js').createDescribeTool}.
|
|
216
215
|
*/
|
|
217
|
-
export declare const ANSWER_TOOL_SUMMARY = "List
|
|
216
|
+
export declare const ANSWER_TOOL_SUMMARY = "List forms addressed to this terminal, or answer one by id with a values record. Call describe('answer') for the required fields.";
|
|
218
217
|
|
|
219
218
|
/**
|
|
220
219
|
* Options for {@link import('./factories.js').createAnswerTool} — the live
|
|
@@ -222,9 +221,9 @@ export declare const ANSWER_TOOL_SUMMARY = "List prompts addressed to this termi
|
|
|
222
221
|
* terminal name `to`, and the advertised tool overrides.
|
|
223
222
|
*
|
|
224
223
|
* @remarks
|
|
225
|
-
* - `manager` — the terminal manager whose `pending(to)` / `answer(to, id,
|
|
226
|
-
* handler calls — `pending` lists the
|
|
227
|
-
* one by `id`. A failed `answer` (`
|
|
224
|
+
* - `manager` — the terminal manager whose `pending(to)` / `answer(to, id, values)` the tool's
|
|
225
|
+
* handler calls — `pending` lists the forms currently addressed to `to`, `answer` resolves
|
|
226
|
+
* one by `id`. A failed `answer` (`TerminalAnswerError`) re-surfaces as a typed
|
|
228
227
|
* `ANSWER` {@link import('./errors.js').ToolboxError}.
|
|
229
228
|
* - `to` — the terminal identity this tool lists / answers prompts FOR.
|
|
230
229
|
* - `name` / `description` — advertised tool overrides; default to
|
|
@@ -239,22 +238,19 @@ export declare interface AnswerToolOptions {
|
|
|
239
238
|
|
|
240
239
|
/**
|
|
241
240
|
* The shape of {@link import('./factories.js').createAnswerTool}'s call arguments — discriminated
|
|
242
|
-
* by `operation`: `'pending'` lists the
|
|
243
|
-
* resolves one by `id` with a `
|
|
241
|
+
* by `operation`: `'pending'` lists the forms addressed to this tool's terminal, while `'answer'`
|
|
242
|
+
* resolves one by `id` with a complete `values` record.
|
|
244
243
|
*
|
|
245
244
|
* @remarks
|
|
246
|
-
* `
|
|
247
|
-
*
|
|
248
|
-
* `unionShape(stringShape(), booleanShape(), arrayShape(stringShape()))` expresses that
|
|
249
|
-
* union directly, so `value` is typed as the full `string | boolean | readonly string[]` union
|
|
250
|
-
* here (no lossy string-only fallback needed).
|
|
245
|
+
* `values` is first bounded to exact JSON. The handler then narrows it with the originating Form
|
|
246
|
+
* package's `isFormValues` guard before the terminal manager applies it to the parked live form.
|
|
251
247
|
*/
|
|
252
248
|
export declare const answerToolShape: UnionShape<readonly [ ObjectShape<{
|
|
253
249
|
operation: LiteralShape<readonly ["pending"]>;
|
|
254
250
|
}, false>, ObjectShape<{
|
|
255
251
|
operation: LiteralShape<readonly ["answer"]>;
|
|
256
252
|
id: StringShape;
|
|
257
|
-
|
|
253
|
+
values: JSONShape;
|
|
258
254
|
}, false>]>;
|
|
259
255
|
|
|
260
256
|
/**
|
|
@@ -288,28 +284,6 @@ export declare function clampQuery(query: QueryInput | undefined, cap: number):
|
|
|
288
284
|
limit: number;
|
|
289
285
|
}>;
|
|
290
286
|
|
|
291
|
-
/**
|
|
292
|
-
* Normalize an LLM-supplied answer `value` to the type {@link PromptType} `form` expects, so a
|
|
293
|
-
* caller that only ever emits strings can still answer a typed prompt.
|
|
294
|
-
*
|
|
295
|
-
* @remarks
|
|
296
|
-
* `'confirm'` coerces to a `boolean` — a `boolean` passes through, and the strings `'true'` /
|
|
297
|
-
* `'false'` (case-insensitively) map to it; any other string is truthy-coerced via
|
|
298
|
-
* `Boolean(value)`. `'checkbox'` coerces to `readonly string[]` — an array passes through
|
|
299
|
-
* (stringifying each entry), a comma-separated string splits + trims into one, and any other
|
|
300
|
-
* single (non-comma) string becomes a one-item array. Every other form (`'input'` / `'password'`
|
|
301
|
-
* / `'select'` / `'editor'`) coerces to a plain `string` — a string passes through verbatim; a
|
|
302
|
-
* non-string, non-object scalar (`number` / `boolean`) stringifies via `String(value)`; an
|
|
303
|
-
* object or array (no lossless string form) falls back to `''` rather than serializing garbage.
|
|
304
|
-
* Pure and total — never throws.
|
|
305
|
-
*
|
|
306
|
-
* @param form - The {@link PromptType} the answer is being coerced FOR
|
|
307
|
-
* @param value - The raw, LLM-supplied answer value
|
|
308
|
-
* @returns The coerced answer — `boolean` for `'confirm'`, `readonly string[]` for `'checkbox'`,
|
|
309
|
-
* `string` otherwise
|
|
310
|
-
*/
|
|
311
|
-
export declare function coerceAnswer(form: PromptType, value: unknown): string | boolean | readonly string[];
|
|
312
|
-
|
|
313
287
|
/** One column's declared type — a primitive shorthand, or `integer` for a whole-number `number`. */
|
|
314
288
|
export declare type ColumnKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
315
289
|
|
|
@@ -464,24 +438,22 @@ export declare function createAgentFunction(agent: AgentInterface, options?: Age
|
|
|
464
438
|
export declare function createAgentTool(registry: AgentRegistryInterface, options?: AgentToolOptions): ToolInterface;
|
|
465
439
|
|
|
466
440
|
/**
|
|
467
|
-
* Build an LLM-callable answer tool — the ANSWER side of the terminal seam. Lists the
|
|
441
|
+
* Build an LLM-callable answer tool — the ANSWER side of the terminal seam. Lists the forms
|
|
468
442
|
* currently addressed to {@link import('./types.js').AnswerToolOptions.to}, or answers one of
|
|
469
443
|
* them by id.
|
|
470
444
|
*
|
|
471
445
|
* @remarks
|
|
472
446
|
* The universal tool-handler contract (AGENTS §14): validates the call args against
|
|
473
447
|
* {@link import('./shapers.js').answerToolShape} (discriminated by `operation`). `'pending'`
|
|
474
|
-
* returns a compact list (`{ id, from,
|
|
475
|
-
* `
|
|
476
|
-
*
|
|
477
|
-
* normalizes the model-supplied `value` to the prompt's own form
|
|
478
|
-
* ({@link import('./helpers.js').coerceAnswer}), and applies it via
|
|
448
|
+
* returns a compact list (`{ id, from, schema }`) of every form currently addressed to `to`.
|
|
449
|
+
* `'answer'` looks the form up by `id`, narrows the supplied `values` through `@orkestrel/form`,
|
|
450
|
+
* and applies it via
|
|
479
451
|
* `TerminalManagerInterface.answer` — a rejected / unknown / unresolvable outcome
|
|
480
452
|
* (`TerminalAnswerResult.error`) re-surfaces as a typed `ANSWER` `ToolboxError`; success returns
|
|
481
453
|
* `{ answered: id }`. `to` is FIXED at construction
|
|
482
454
|
* ({@link import('./types.js').AnswerToolOptions.to}) — never read from the model-supplied args —
|
|
483
455
|
* so a model cannot spoof which terminal it is answering for. Concurrent answerers racing on one
|
|
484
|
-
* endpoint are FIRST-WRITE-WINS — a late answer to an already-settled
|
|
456
|
+
* endpoint are FIRST-WRITE-WINS — a late answer to an already-settled form returns a typed
|
|
485
457
|
* `ANSWER` `ToolboxError` (surfaced as a 422 over HTTP).
|
|
486
458
|
*
|
|
487
459
|
* @param options - The live manager, the fixed `to` identity, and advertised overrides (see
|
|
@@ -498,7 +470,7 @@ export declare function createAgentTool(registry: AgentRegistryInterface, option
|
|
|
498
470
|
* manager.add('reviewer')
|
|
499
471
|
* const tool = createAnswerTool({ manager, to: 'reviewer' })
|
|
500
472
|
* const tools = createToolManager()
|
|
501
|
-
* tools.add(tool) // the reviewer terminal can now list/answer
|
|
473
|
+
* tools.add(tool) // the reviewer terminal can now list/answer forms addressed to it
|
|
502
474
|
* ```
|
|
503
475
|
*/
|
|
504
476
|
export declare function createAnswerTool(options: AnswerToolOptions): ToolInterface;
|
|
@@ -782,19 +754,18 @@ export declare function createInferTool(options?: InferToolOptions): ToolInterfa
|
|
|
782
754
|
export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
|
|
783
755
|
|
|
784
756
|
/**
|
|
785
|
-
* Build an LLM-callable
|
|
786
|
-
*
|
|
787
|
-
* returning the resolved answer value.
|
|
757
|
+
* Build an LLM-callable form tool — the ASK side of the terminal seam. Asks
|
|
758
|
+
* a multi-field form and BLOCKS until it answers, returning the resolved values record.
|
|
788
759
|
*
|
|
789
760
|
* @remarks
|
|
790
761
|
* The universal tool-handler contract (AGENTS §14): validates the call args against
|
|
791
|
-
* {@link import('./shapers.js').promptToolShape},
|
|
792
|
-
*
|
|
793
|
-
*
|
|
762
|
+
* {@link import('./shapers.js').promptToolShape}, parses the call's schema through
|
|
763
|
+
* `@orkestrel/form`, constructs the live form, and passes it to `TerminalManagerInterface.ask`.
|
|
764
|
+
* `from` is FIXED at construction
|
|
794
765
|
* ({@link import('./types.js').PromptToolOptions.from}) — never read from the model-supplied
|
|
795
|
-
* args — so a model cannot spoof which terminal is asking. A
|
|
766
|
+
* args — so a model cannot spoof which terminal is asking. A form CYCLE rejects with
|
|
796
767
|
* `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
|
|
797
|
-
* {@link import('./errors.js').ToolboxError}; an expired
|
|
768
|
+
* {@link import('./errors.js').ToolboxError}; an expired form re-surfaces as `EXPIRE`; an
|
|
798
769
|
* unknown `to` (or any other `TerminalError`) re-surfaces as `TOOL`, naming the unknown terminal
|
|
799
770
|
* plus the known ones (`manager.terminals()`).
|
|
800
771
|
*
|
|
@@ -1811,7 +1782,7 @@ export declare const phaseDraftShape: ObjectShape<{
|
|
|
1811
1782
|
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
1812
1783
|
}, false>;
|
|
1813
1784
|
|
|
1814
|
-
/** The full
|
|
1785
|
+
/** The full form protocol {@link import('./factories.js').createPromptTool} advertises. */
|
|
1815
1786
|
export declare const PROMPT_TOOL_DESCRIPTION: string;
|
|
1816
1787
|
|
|
1817
1788
|
/**
|
|
@@ -1827,7 +1798,7 @@ export declare const PROMPT_TOOL_NAME = "ask";
|
|
|
1827
1798
|
* for the full teaching description; the full text stays retrievable via
|
|
1828
1799
|
* {@link import('./factories.js').createDescribeTool}.
|
|
1829
1800
|
*/
|
|
1830
|
-
export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a
|
|
1801
|
+
export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a multi-field form and BLOCK until it answers; the call resolves with the values record. Call describe('ask') for the schema.";
|
|
1831
1802
|
|
|
1832
1803
|
/**
|
|
1833
1804
|
* Options for {@link import('./factories.js').createPromptTool} — the live
|
|
@@ -1835,12 +1806,12 @@ export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a question and
|
|
|
1835
1806
|
* `from`, and the advertised tool overrides.
|
|
1836
1807
|
*
|
|
1837
1808
|
* @remarks
|
|
1838
|
-
* - `manager` — the terminal manager whose `ask(from, to, form
|
|
1839
|
-
*
|
|
1809
|
+
* - `manager` — the terminal manager whose `ask(from, to, form)` the tool's handler calls with a
|
|
1810
|
+
* live `@orkestrel/form` form; BLOCKS the calling agent turn until the addressed terminal answers (or the ask
|
|
1840
1811
|
* rejects — a cycle throws `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
|
|
1841
1812
|
* {@link import('./errors.js').ToolboxError}; an expired prompt re-surfaces as `EXPIRE`).
|
|
1842
1813
|
* - `from` — the terminal identity this tool asks AS; the model supplies the `to` target and the
|
|
1843
|
-
*
|
|
1814
|
+
* complete form schema per call.
|
|
1844
1815
|
* - `name` / `description` — advertised tool overrides; default to
|
|
1845
1816
|
* {@link import('./constants.js').PROMPT_TOOL_NAME} / {@link import('./constants.js').PROMPT_TOOL_DESCRIPTION}.
|
|
1846
1817
|
*/
|
|
@@ -1852,47 +1823,16 @@ export declare interface PromptToolOptions {
|
|
|
1852
1823
|
}
|
|
1853
1824
|
|
|
1854
1825
|
/**
|
|
1855
|
-
* The shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to`
|
|
1856
|
-
* terminal identity
|
|
1857
|
-
* forms to ask), `message`, an optional `timeout` override, and every per-form optional field
|
|
1858
|
-
* FLATTENED onto one object (mirrors `workspaceToolShape`'s flat-arm style, but a single shared
|
|
1859
|
-
* shape rather than a discriminated union — `form` alone does not vary the REQUIRED fields, only
|
|
1860
|
-
* which of the optional ones apply, so a flat shape stays faithful without duplicating `to` /
|
|
1861
|
-
* `message` / `timeout` across six near-identical arms).
|
|
1826
|
+
* The shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to` names the
|
|
1827
|
+
* terminal identity and `schema` carries the complete multi-field form document.
|
|
1862
1828
|
*
|
|
1863
1829
|
* @remarks
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
* contract layer cannot vary a field's type by a sibling field's value, so `default` stays a
|
|
1867
|
-
* string and the handler coerces per form); `mask` backs `'password'`; `min` / `max` backs
|
|
1868
|
-
* `'checkbox'`; `validate` (declarative only) backs the four text-shaped forms
|
|
1869
|
-
* (`'input'` / `'password'` / `'confirm'` / `'editor'`).
|
|
1830
|
+
* The contract first requires exact JSON. The handler then delegates schema parsing and semantic
|
|
1831
|
+
* validation to `@orkestrel/form`'s `parseForm`, so Toolbox does not duplicate the form schema.
|
|
1870
1832
|
*/
|
|
1871
1833
|
export declare const promptToolShape: ObjectShape<{
|
|
1872
1834
|
to: StringShape;
|
|
1873
|
-
|
|
1874
|
-
message: StringShape;
|
|
1875
|
-
default: OptionalShape<StringShape>;
|
|
1876
|
-
choices: OptionalShape<ArrayShape<ObjectShape<{
|
|
1877
|
-
name: StringShape;
|
|
1878
|
-
value: StringShape;
|
|
1879
|
-
description: OptionalShape<StringShape>;
|
|
1880
|
-
}, boolean | ContractShape>>>;
|
|
1881
|
-
mask: OptionalShape<StringShape>;
|
|
1882
|
-
min: OptionalShape<NumberShape>;
|
|
1883
|
-
max: OptionalShape<NumberShape>;
|
|
1884
|
-
validate: OptionalShape<ObjectShape<{
|
|
1885
|
-
required: OptionalShape<BooleanShape>;
|
|
1886
|
-
minimum: OptionalShape<NumberShape>;
|
|
1887
|
-
maximum: OptionalShape<NumberShape>;
|
|
1888
|
-
pattern: OptionalShape<StringShape>;
|
|
1889
|
-
email: OptionalShape<BooleanShape>;
|
|
1890
|
-
url: OptionalShape<BooleanShape>;
|
|
1891
|
-
numeric: OptionalShape<BooleanShape>;
|
|
1892
|
-
integer: OptionalShape<BooleanShape>;
|
|
1893
|
-
alphanumeric: OptionalShape<BooleanShape>;
|
|
1894
|
-
}, boolean | ContractShape>>;
|
|
1895
|
-
timeout: OptionalShape<NumberShape>;
|
|
1835
|
+
schema: JSONShape;
|
|
1896
1836
|
}, false>;
|
|
1897
1837
|
|
|
1898
1838
|
/**
|
|
@@ -2160,8 +2100,8 @@ export declare const taskDraftShape: ObjectShape<{
|
|
|
2160
2100
|
* value returns `undefined`, telling the caller this mapper does not apply (rethrow / handle
|
|
2161
2101
|
* otherwise). For a genuine `TerminalError`, `'DEADLOCK'` maps to `'DEADLOCK'`, `'EXPIRE'` maps
|
|
2162
2102
|
* to `'EXPIRE'`, and every other {@link import('@orkestrel/terminal').TerminalErrorCode}
|
|
2163
|
-
* (`'TARGET'`, `'CANCEL'`, `'DRIVER'`) maps to the generic `'TOOL'`
|
|
2164
|
-
* classifies — the factory performs the actual throw.
|
|
2103
|
+
* (`'TARGET'`, `'LIMIT'`, `'CANCEL'`, `'DRIVER'`, `'DESTROYED'`) maps to the generic `'TOOL'`
|
|
2104
|
+
* code. The mapper only classifies — the factory performs the actual throw.
|
|
2165
2105
|
*
|
|
2166
2106
|
* @param error - The value caught from a terminal-manager operation (`ask` / `answer` / …)
|
|
2167
2107
|
* @returns The mapped {@link ToolboxErrorCode}, or `undefined` if `error` is not a `TerminalError`
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ import { ObjectShape } from '@orkestrel/contract';
|
|
|
21
21
|
import { OptionalShape } from '@orkestrel/contract';
|
|
22
22
|
import { OrderDirection } from '@orkestrel/database';
|
|
23
23
|
import { PrimaryMap } from '@orkestrel/database';
|
|
24
|
-
import { PromptType } from '@orkestrel/terminal';
|
|
25
24
|
import { QueryInput } from '@orkestrel/database';
|
|
26
25
|
import { RelationErrorCode } from '@orkestrel/relation';
|
|
27
26
|
import { RelationManagerInterface } from '@orkestrel/relation';
|
|
@@ -214,7 +213,7 @@ export declare const ANSWER_TOOL_NAME = "answer";
|
|
|
214
213
|
* for the full teaching description; the full text stays retrievable via
|
|
215
214
|
* {@link import('./factories.js').createDescribeTool}.
|
|
216
215
|
*/
|
|
217
|
-
export declare const ANSWER_TOOL_SUMMARY = "List
|
|
216
|
+
export declare const ANSWER_TOOL_SUMMARY = "List forms addressed to this terminal, or answer one by id with a values record. Call describe('answer') for the required fields.";
|
|
218
217
|
|
|
219
218
|
/**
|
|
220
219
|
* Options for {@link import('./factories.js').createAnswerTool} — the live
|
|
@@ -222,9 +221,9 @@ export declare const ANSWER_TOOL_SUMMARY = "List prompts addressed to this termi
|
|
|
222
221
|
* terminal name `to`, and the advertised tool overrides.
|
|
223
222
|
*
|
|
224
223
|
* @remarks
|
|
225
|
-
* - `manager` — the terminal manager whose `pending(to)` / `answer(to, id,
|
|
226
|
-
* handler calls — `pending` lists the
|
|
227
|
-
* one by `id`. A failed `answer` (`
|
|
224
|
+
* - `manager` — the terminal manager whose `pending(to)` / `answer(to, id, values)` the tool's
|
|
225
|
+
* handler calls — `pending` lists the forms currently addressed to `to`, `answer` resolves
|
|
226
|
+
* one by `id`. A failed `answer` (`TerminalAnswerError`) re-surfaces as a typed
|
|
228
227
|
* `ANSWER` {@link import('./errors.js').ToolboxError}.
|
|
229
228
|
* - `to` — the terminal identity this tool lists / answers prompts FOR.
|
|
230
229
|
* - `name` / `description` — advertised tool overrides; default to
|
|
@@ -239,22 +238,19 @@ export declare interface AnswerToolOptions {
|
|
|
239
238
|
|
|
240
239
|
/**
|
|
241
240
|
* The shape of {@link import('./factories.js').createAnswerTool}'s call arguments — discriminated
|
|
242
|
-
* by `operation`: `'pending'` lists the
|
|
243
|
-
* resolves one by `id` with a `
|
|
241
|
+
* by `operation`: `'pending'` lists the forms addressed to this tool's terminal, while `'answer'`
|
|
242
|
+
* resolves one by `id` with a complete `values` record.
|
|
244
243
|
*
|
|
245
244
|
* @remarks
|
|
246
|
-
* `
|
|
247
|
-
*
|
|
248
|
-
* `unionShape(stringShape(), booleanShape(), arrayShape(stringShape()))` expresses that
|
|
249
|
-
* union directly, so `value` is typed as the full `string | boolean | readonly string[]` union
|
|
250
|
-
* here (no lossy string-only fallback needed).
|
|
245
|
+
* `values` is first bounded to exact JSON. The handler then narrows it with the originating Form
|
|
246
|
+
* package's `isFormValues` guard before the terminal manager applies it to the parked live form.
|
|
251
247
|
*/
|
|
252
248
|
export declare const answerToolShape: UnionShape<readonly [ ObjectShape<{
|
|
253
249
|
operation: LiteralShape<readonly ["pending"]>;
|
|
254
250
|
}, false>, ObjectShape<{
|
|
255
251
|
operation: LiteralShape<readonly ["answer"]>;
|
|
256
252
|
id: StringShape;
|
|
257
|
-
|
|
253
|
+
values: JSONShape;
|
|
258
254
|
}, false>]>;
|
|
259
255
|
|
|
260
256
|
/**
|
|
@@ -288,28 +284,6 @@ export declare function clampQuery(query: QueryInput | undefined, cap: number):
|
|
|
288
284
|
limit: number;
|
|
289
285
|
}>;
|
|
290
286
|
|
|
291
|
-
/**
|
|
292
|
-
* Normalize an LLM-supplied answer `value` to the type {@link PromptType} `form` expects, so a
|
|
293
|
-
* caller that only ever emits strings can still answer a typed prompt.
|
|
294
|
-
*
|
|
295
|
-
* @remarks
|
|
296
|
-
* `'confirm'` coerces to a `boolean` — a `boolean` passes through, and the strings `'true'` /
|
|
297
|
-
* `'false'` (case-insensitively) map to it; any other string is truthy-coerced via
|
|
298
|
-
* `Boolean(value)`. `'checkbox'` coerces to `readonly string[]` — an array passes through
|
|
299
|
-
* (stringifying each entry), a comma-separated string splits + trims into one, and any other
|
|
300
|
-
* single (non-comma) string becomes a one-item array. Every other form (`'input'` / `'password'`
|
|
301
|
-
* / `'select'` / `'editor'`) coerces to a plain `string` — a string passes through verbatim; a
|
|
302
|
-
* non-string, non-object scalar (`number` / `boolean`) stringifies via `String(value)`; an
|
|
303
|
-
* object or array (no lossless string form) falls back to `''` rather than serializing garbage.
|
|
304
|
-
* Pure and total — never throws.
|
|
305
|
-
*
|
|
306
|
-
* @param form - The {@link PromptType} the answer is being coerced FOR
|
|
307
|
-
* @param value - The raw, LLM-supplied answer value
|
|
308
|
-
* @returns The coerced answer — `boolean` for `'confirm'`, `readonly string[]` for `'checkbox'`,
|
|
309
|
-
* `string` otherwise
|
|
310
|
-
*/
|
|
311
|
-
export declare function coerceAnswer(form: PromptType, value: unknown): string | boolean | readonly string[];
|
|
312
|
-
|
|
313
287
|
/** One column's declared type — a primitive shorthand, or `integer` for a whole-number `number`. */
|
|
314
288
|
export declare type ColumnKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
315
289
|
|
|
@@ -464,24 +438,22 @@ export declare function createAgentFunction(agent: AgentInterface, options?: Age
|
|
|
464
438
|
export declare function createAgentTool(registry: AgentRegistryInterface, options?: AgentToolOptions): ToolInterface;
|
|
465
439
|
|
|
466
440
|
/**
|
|
467
|
-
* Build an LLM-callable answer tool — the ANSWER side of the terminal seam. Lists the
|
|
441
|
+
* Build an LLM-callable answer tool — the ANSWER side of the terminal seam. Lists the forms
|
|
468
442
|
* currently addressed to {@link import('./types.js').AnswerToolOptions.to}, or answers one of
|
|
469
443
|
* them by id.
|
|
470
444
|
*
|
|
471
445
|
* @remarks
|
|
472
446
|
* The universal tool-handler contract (AGENTS §14): validates the call args against
|
|
473
447
|
* {@link import('./shapers.js').answerToolShape} (discriminated by `operation`). `'pending'`
|
|
474
|
-
* returns a compact list (`{ id, from,
|
|
475
|
-
* `
|
|
476
|
-
*
|
|
477
|
-
* normalizes the model-supplied `value` to the prompt's own form
|
|
478
|
-
* ({@link import('./helpers.js').coerceAnswer}), and applies it via
|
|
448
|
+
* returns a compact list (`{ id, from, schema }`) of every form currently addressed to `to`.
|
|
449
|
+
* `'answer'` looks the form up by `id`, narrows the supplied `values` through `@orkestrel/form`,
|
|
450
|
+
* and applies it via
|
|
479
451
|
* `TerminalManagerInterface.answer` — a rejected / unknown / unresolvable outcome
|
|
480
452
|
* (`TerminalAnswerResult.error`) re-surfaces as a typed `ANSWER` `ToolboxError`; success returns
|
|
481
453
|
* `{ answered: id }`. `to` is FIXED at construction
|
|
482
454
|
* ({@link import('./types.js').AnswerToolOptions.to}) — never read from the model-supplied args —
|
|
483
455
|
* so a model cannot spoof which terminal it is answering for. Concurrent answerers racing on one
|
|
484
|
-
* endpoint are FIRST-WRITE-WINS — a late answer to an already-settled
|
|
456
|
+
* endpoint are FIRST-WRITE-WINS — a late answer to an already-settled form returns a typed
|
|
485
457
|
* `ANSWER` `ToolboxError` (surfaced as a 422 over HTTP).
|
|
486
458
|
*
|
|
487
459
|
* @param options - The live manager, the fixed `to` identity, and advertised overrides (see
|
|
@@ -498,7 +470,7 @@ export declare function createAgentTool(registry: AgentRegistryInterface, option
|
|
|
498
470
|
* manager.add('reviewer')
|
|
499
471
|
* const tool = createAnswerTool({ manager, to: 'reviewer' })
|
|
500
472
|
* const tools = createToolManager()
|
|
501
|
-
* tools.add(tool) // the reviewer terminal can now list/answer
|
|
473
|
+
* tools.add(tool) // the reviewer terminal can now list/answer forms addressed to it
|
|
502
474
|
* ```
|
|
503
475
|
*/
|
|
504
476
|
export declare function createAnswerTool(options: AnswerToolOptions): ToolInterface;
|
|
@@ -782,19 +754,18 @@ export declare function createInferTool(options?: InferToolOptions): ToolInterfa
|
|
|
782
754
|
export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
|
|
783
755
|
|
|
784
756
|
/**
|
|
785
|
-
* Build an LLM-callable
|
|
786
|
-
*
|
|
787
|
-
* returning the resolved answer value.
|
|
757
|
+
* Build an LLM-callable form tool — the ASK side of the terminal seam. Asks
|
|
758
|
+
* a multi-field form and BLOCKS until it answers, returning the resolved values record.
|
|
788
759
|
*
|
|
789
760
|
* @remarks
|
|
790
761
|
* The universal tool-handler contract (AGENTS §14): validates the call args against
|
|
791
|
-
* {@link import('./shapers.js').promptToolShape},
|
|
792
|
-
*
|
|
793
|
-
*
|
|
762
|
+
* {@link import('./shapers.js').promptToolShape}, parses the call's schema through
|
|
763
|
+
* `@orkestrel/form`, constructs the live form, and passes it to `TerminalManagerInterface.ask`.
|
|
764
|
+
* `from` is FIXED at construction
|
|
794
765
|
* ({@link import('./types.js').PromptToolOptions.from}) — never read from the model-supplied
|
|
795
|
-
* args — so a model cannot spoof which terminal is asking. A
|
|
766
|
+
* args — so a model cannot spoof which terminal is asking. A form CYCLE rejects with
|
|
796
767
|
* `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
|
|
797
|
-
* {@link import('./errors.js').ToolboxError}; an expired
|
|
768
|
+
* {@link import('./errors.js').ToolboxError}; an expired form re-surfaces as `EXPIRE`; an
|
|
798
769
|
* unknown `to` (or any other `TerminalError`) re-surfaces as `TOOL`, naming the unknown terminal
|
|
799
770
|
* plus the known ones (`manager.terminals()`).
|
|
800
771
|
*
|
|
@@ -1811,7 +1782,7 @@ export declare const phaseDraftShape: ObjectShape<{
|
|
|
1811
1782
|
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
1812
1783
|
}, false>;
|
|
1813
1784
|
|
|
1814
|
-
/** The full
|
|
1785
|
+
/** The full form protocol {@link import('./factories.js').createPromptTool} advertises. */
|
|
1815
1786
|
export declare const PROMPT_TOOL_DESCRIPTION: string;
|
|
1816
1787
|
|
|
1817
1788
|
/**
|
|
@@ -1827,7 +1798,7 @@ export declare const PROMPT_TOOL_NAME = "ask";
|
|
|
1827
1798
|
* for the full teaching description; the full text stays retrievable via
|
|
1828
1799
|
* {@link import('./factories.js').createDescribeTool}.
|
|
1829
1800
|
*/
|
|
1830
|
-
export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a
|
|
1801
|
+
export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a multi-field form and BLOCK until it answers; the call resolves with the values record. Call describe('ask') for the schema.";
|
|
1831
1802
|
|
|
1832
1803
|
/**
|
|
1833
1804
|
* Options for {@link import('./factories.js').createPromptTool} — the live
|
|
@@ -1835,12 +1806,12 @@ export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a question and
|
|
|
1835
1806
|
* `from`, and the advertised tool overrides.
|
|
1836
1807
|
*
|
|
1837
1808
|
* @remarks
|
|
1838
|
-
* - `manager` — the terminal manager whose `ask(from, to, form
|
|
1839
|
-
*
|
|
1809
|
+
* - `manager` — the terminal manager whose `ask(from, to, form)` the tool's handler calls with a
|
|
1810
|
+
* live `@orkestrel/form` form; BLOCKS the calling agent turn until the addressed terminal answers (or the ask
|
|
1840
1811
|
* rejects — a cycle throws `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
|
|
1841
1812
|
* {@link import('./errors.js').ToolboxError}; an expired prompt re-surfaces as `EXPIRE`).
|
|
1842
1813
|
* - `from` — the terminal identity this tool asks AS; the model supplies the `to` target and the
|
|
1843
|
-
*
|
|
1814
|
+
* complete form schema per call.
|
|
1844
1815
|
* - `name` / `description` — advertised tool overrides; default to
|
|
1845
1816
|
* {@link import('./constants.js').PROMPT_TOOL_NAME} / {@link import('./constants.js').PROMPT_TOOL_DESCRIPTION}.
|
|
1846
1817
|
*/
|
|
@@ -1852,47 +1823,16 @@ export declare interface PromptToolOptions {
|
|
|
1852
1823
|
}
|
|
1853
1824
|
|
|
1854
1825
|
/**
|
|
1855
|
-
* The shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to`
|
|
1856
|
-
* terminal identity
|
|
1857
|
-
* forms to ask), `message`, an optional `timeout` override, and every per-form optional field
|
|
1858
|
-
* FLATTENED onto one object (mirrors `workspaceToolShape`'s flat-arm style, but a single shared
|
|
1859
|
-
* shape rather than a discriminated union — `form` alone does not vary the REQUIRED fields, only
|
|
1860
|
-
* which of the optional ones apply, so a flat shape stays faithful without duplicating `to` /
|
|
1861
|
-
* `message` / `timeout` across six near-identical arms).
|
|
1826
|
+
* The shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to` names the
|
|
1827
|
+
* terminal identity and `schema` carries the complete multi-field form document.
|
|
1862
1828
|
*
|
|
1863
1829
|
* @remarks
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
* contract layer cannot vary a field's type by a sibling field's value, so `default` stays a
|
|
1867
|
-
* string and the handler coerces per form); `mask` backs `'password'`; `min` / `max` backs
|
|
1868
|
-
* `'checkbox'`; `validate` (declarative only) backs the four text-shaped forms
|
|
1869
|
-
* (`'input'` / `'password'` / `'confirm'` / `'editor'`).
|
|
1830
|
+
* The contract first requires exact JSON. The handler then delegates schema parsing and semantic
|
|
1831
|
+
* validation to `@orkestrel/form`'s `parseForm`, so Toolbox does not duplicate the form schema.
|
|
1870
1832
|
*/
|
|
1871
1833
|
export declare const promptToolShape: ObjectShape<{
|
|
1872
1834
|
to: StringShape;
|
|
1873
|
-
|
|
1874
|
-
message: StringShape;
|
|
1875
|
-
default: OptionalShape<StringShape>;
|
|
1876
|
-
choices: OptionalShape<ArrayShape<ObjectShape<{
|
|
1877
|
-
name: StringShape;
|
|
1878
|
-
value: StringShape;
|
|
1879
|
-
description: OptionalShape<StringShape>;
|
|
1880
|
-
}, boolean | ContractShape>>>;
|
|
1881
|
-
mask: OptionalShape<StringShape>;
|
|
1882
|
-
min: OptionalShape<NumberShape>;
|
|
1883
|
-
max: OptionalShape<NumberShape>;
|
|
1884
|
-
validate: OptionalShape<ObjectShape<{
|
|
1885
|
-
required: OptionalShape<BooleanShape>;
|
|
1886
|
-
minimum: OptionalShape<NumberShape>;
|
|
1887
|
-
maximum: OptionalShape<NumberShape>;
|
|
1888
|
-
pattern: OptionalShape<StringShape>;
|
|
1889
|
-
email: OptionalShape<BooleanShape>;
|
|
1890
|
-
url: OptionalShape<BooleanShape>;
|
|
1891
|
-
numeric: OptionalShape<BooleanShape>;
|
|
1892
|
-
integer: OptionalShape<BooleanShape>;
|
|
1893
|
-
alphanumeric: OptionalShape<BooleanShape>;
|
|
1894
|
-
}, boolean | ContractShape>>;
|
|
1895
|
-
timeout: OptionalShape<NumberShape>;
|
|
1835
|
+
schema: JSONShape;
|
|
1896
1836
|
}, false>;
|
|
1897
1837
|
|
|
1898
1838
|
/**
|
|
@@ -2160,8 +2100,8 @@ export declare const taskDraftShape: ObjectShape<{
|
|
|
2160
2100
|
* value returns `undefined`, telling the caller this mapper does not apply (rethrow / handle
|
|
2161
2101
|
* otherwise). For a genuine `TerminalError`, `'DEADLOCK'` maps to `'DEADLOCK'`, `'EXPIRE'` maps
|
|
2162
2102
|
* to `'EXPIRE'`, and every other {@link import('@orkestrel/terminal').TerminalErrorCode}
|
|
2163
|
-
* (`'TARGET'`, `'CANCEL'`, `'DRIVER'`) maps to the generic `'TOOL'`
|
|
2164
|
-
* classifies — the factory performs the actual throw.
|
|
2103
|
+
* (`'TARGET'`, `'LIMIT'`, `'CANCEL'`, `'DRIVER'`, `'DESTROYED'`) maps to the generic `'TOOL'`
|
|
2104
|
+
* code. The mapper only classifies — the factory performs the actual throw.
|
|
2165
2105
|
*
|
|
2166
2106
|
* @param error - The value caught from a terminal-manager operation (`ask` / `answer` / …)
|
|
2167
2107
|
* @returns The mapped {@link ToolboxErrorCode}, or `undefined` if `error` is not a `TerminalError`
|