@jangts/agent-core 0.3.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +33 -31
- package/development/docs/README.en.md +2 -2
- package/development/docs/acceptance.en.md +2 -2
- package/development/docs/agent-development.en.md +1 -1
- package/development/docs/api/README.en.md +6 -2
- package/development/docs/api/README.md +4 -0
- package/development/docs/api/configuration-in-workflow.en.md +403 -0
- package/development/docs/api/configuration-in-workflow.md +403 -0
- package/development/docs/api/core.en.md +7 -7
- package/development/docs/api/core.md +6 -6
- package/development/docs/api/decorators.en.md +20 -0
- package/development/docs/api/decorators.md +20 -0
- package/development/docs/api/examples.en.md +1 -1
- package/development/docs/api/examples.md +1 -1
- package/development/docs/api/kits.en.md +22 -4
- package/development/docs/api/kits.md +22 -4
- package/development/docs/api/knowledge-answering.en.md +4 -1
- package/development/docs/api/knowledge-answering.md +4 -1
- package/development/docs/api/mock.en.md +2 -0
- package/development/docs/api/mock.md +2 -0
- package/development/docs/api/observability.en.md +37 -11
- package/development/docs/api/observability.md +64 -11
- package/development/docs/api/reference.en.md +876 -657
- package/development/docs/api/reference.md +662 -508
- package/development/docs/api/support.en.md +55 -9
- package/development/docs/api/support.md +53 -7
- package/development/docs/api/types.en.md +36 -1
- package/development/docs/api/types.md +44 -0
- package/development/docs/api/workflow-views.en.md +64 -0
- package/development/docs/api/workflow-views.md +78 -0
- package/development/docs/api/workflow.en.md +6 -2
- package/development/docs/api/workflow.md +6 -2
- package/development/docs/basic-usage.en.md +1 -1
- package/development/docs/basic-usage.md +1 -1
- package/development/docs/create-app.en.md +1 -1
- package/development/docs/examples/registration/associated.mjs +8 -0
- package/development/docs/examples/registration/independent.mjs +20 -0
- package/development/docs/examples/registration/protocol.mjs +48 -0
- package/development/docs/examples/registration/run.mjs +47 -0
- package/development/docs/examples/registration/tools.mjs +75 -0
- package/development/docs/examples/registration/workflow.mjs +109 -0
- package/development/docs/flows/knowledge-maintenance.en.md +1 -1
- package/development/docs/materials.en.md +1 -1
- package/development/docs/mechanisms.en.md +2 -2
- package/development/docs/mechanisms.md +1 -1
- package/development/docs/operations.en.md +1 -1
- package/development/docs/records.en.md +1 -1
- package/development/docs/registration.en.md +4 -4
- package/development/docs/registration.md +2 -2
- package/development/skills/agent-core-app/SKILL.md +16 -4
- package/development/skills/agent-core-app/templates/node-ts/README.md.tpl +1 -1
- package/development/skills/agent-core-app/templates/node-ts/src/catalog.ts.tpl +2 -2
- package/development/skills/agent-core-app/templates/node-ts/test/app.test.mjs.tpl +1 -1
- package/dist/cjs/capabilities/index.js +5 -12
- package/dist/cjs/capabilities/invocation.js +21 -1
- package/dist/cjs/capabilities/model.js +56 -12
- package/dist/cjs/capabilities/tool-conditions.js +65 -0
- package/dist/cjs/capabilities/tool-runtime.js +18 -4
- package/dist/cjs/capabilities/tools.js +12 -17
- package/dist/cjs/context/audit.js +5 -8
- package/dist/cjs/context/index.js +3 -4
- package/dist/cjs/diagnostics/index.js +51 -3
- package/dist/cjs/diagnostics/native-sub-flow.js +106 -0
- package/dist/cjs/diagnostics/sub-flow.js +278 -32
- package/dist/cjs/execution/engine.js +3 -2
- package/dist/cjs/execution/events.js +5 -5
- package/dist/cjs/execution/reporting.js +18 -28
- package/dist/cjs/execution/workflow-chain.js +211 -0
- package/dist/cjs/execution/workflow-graph.js +72 -0
- package/dist/cjs/execution/workflow.js +34 -6
- package/dist/cjs/index.js +21 -17
- package/dist/cjs/kits/aggregation.js +17 -14
- package/dist/cjs/kits/answering/checks.js +2 -1
- package/dist/cjs/kits/answering/flow.js +24 -21
- package/dist/cjs/kits/answering/tasks.js +30 -25
- package/dist/cjs/kits/delivery.js +36 -24
- package/dist/cjs/kits/domains/catalog.js +113 -0
- package/dist/cjs/kits/domains/index.js +20 -0
- package/dist/cjs/kits/{intents → domains}/registry.js +77 -31
- package/dist/cjs/kits/{intents → domains}/scopes.js +21 -21
- package/dist/cjs/kits/index.js +14 -13
- package/dist/cjs/kits/knowledge/catalog.js +33 -30
- package/dist/cjs/kits/policies.js +3 -2
- package/dist/cjs/kits/presentation/formats.js +110 -0
- package/dist/cjs/kits/presentation/index.js +10 -5
- package/dist/cjs/kits/presentation/outputs.js +2 -1
- package/dist/cjs/kits/reflection.js +2 -2
- package/dist/cjs/kits/retrieval.js +7 -1
- package/dist/cjs/kits/text-blocks.js +101 -0
- package/dist/cjs/kits/tools.js +247 -158
- package/dist/cjs/model/decision-retry.js +2 -1
- package/dist/cjs/model/index.js +2 -6
- package/dist/cjs/model/interactions/calls.js +61 -0
- package/dist/cjs/model/interactions/json-object.js +11 -11
- package/dist/cjs/model/interactions/native-functions.js +17 -23
- package/dist/cjs/model/message-diagnostics.js +13 -3
- package/dist/cjs/model/options.js +2 -0
- package/dist/cjs/model/preparation.js +39 -6
- package/dist/cjs/model/runner.js +34 -5
- package/dist/cjs/model/selection-transport.js +4 -4
- package/dist/cjs/model/token-budget.js +3 -0
- package/dist/cjs/model/transports.js +3 -2
- package/dist/cjs/structs/index.js +7 -6
- package/dist/cjs/structs/kits/domains/scopes.js +2 -0
- package/dist/cjs/structs/kits/presentation/formats.js +2 -0
- package/dist/cjs/structs/kits/text-blocks.js +11 -0
- package/dist/cjs/structs/model/session.js +11 -0
- package/dist/cjs/structs/support/associations.js +2 -0
- package/dist/cjs/support/associations.js +79 -0
- package/dist/cjs/support/context/nodes.js +48 -45
- package/dist/cjs/support/context/processing.js +6 -3
- package/dist/cjs/support/context/snapshot.js +11 -1
- package/dist/cjs/support/decorators/index.js +45 -3
- package/dist/cjs/support/index.js +1 -0
- package/dist/cjs/support/model/capabilities.js +35 -5
- package/dist/cjs/support/model/chat-completions.js +11 -2
- package/dist/cjs/support/model/completion/calls.js +10 -56
- package/dist/cjs/support/model/preview-rules.js +11 -11
- package/dist/cjs/support/model/reply-preview.js +3 -3
- package/dist/cjs/support/model/session.js +152 -0
- package/dist/cjs/support/model/stage-transport.js +8 -8
- package/dist/cjs/support/model/transports.js +5 -2
- package/dist/cjs/support/tools.js +42 -17
- package/dist/cjs/utils/invocation.js +1 -0
- package/dist/esm/capabilities/index.d.ts +5 -10
- package/dist/esm/capabilities/index.js +5 -9
- package/dist/esm/capabilities/invocation.js +21 -1
- package/dist/esm/capabilities/model.d.ts +17 -13
- package/dist/esm/capabilities/model.js +54 -10
- package/dist/esm/capabilities/tool-conditions.d.ts +9 -0
- package/dist/esm/capabilities/tool-conditions.js +59 -0
- package/dist/esm/capabilities/tool-runtime.js +18 -4
- package/dist/esm/capabilities/tools.d.ts +3 -3
- package/dist/esm/capabilities/tools.js +12 -17
- package/dist/esm/context/audit.js +5 -8
- package/dist/esm/context/index.d.ts +3 -4
- package/dist/esm/context/index.js +3 -4
- package/dist/esm/diagnostics/index.d.ts +1 -0
- package/dist/esm/diagnostics/index.js +48 -2
- package/dist/esm/diagnostics/native-sub-flow.d.ts +94 -0
- package/dist/esm/diagnostics/native-sub-flow.js +101 -0
- package/dist/esm/diagnostics/sub-flow.d.ts +56 -4
- package/dist/esm/diagnostics/sub-flow.js +271 -32
- package/dist/esm/execution/engine.d.ts +1 -0
- package/dist/esm/execution/engine.js +3 -2
- package/dist/esm/execution/events.js +5 -5
- package/dist/esm/execution/reporting.d.ts +6 -12
- package/dist/esm/execution/reporting.js +19 -29
- package/dist/esm/execution/workflow-chain.d.ts +3 -0
- package/dist/esm/execution/workflow-chain.js +208 -0
- package/dist/esm/execution/workflow-graph.d.ts +7 -0
- package/dist/esm/execution/workflow-graph.js +68 -0
- package/dist/esm/execution/workflow.d.ts +6 -0
- package/dist/esm/execution/workflow.js +34 -6
- package/dist/esm/index.d.ts +19 -13
- package/dist/esm/index.js +18 -15
- package/dist/esm/kits/aggregation.d.ts +1 -1
- package/dist/esm/kits/aggregation.js +17 -14
- package/dist/esm/kits/answering/checks.js +2 -1
- package/dist/esm/kits/answering/flow.js +24 -21
- package/dist/esm/kits/answering/tasks.d.ts +6 -6
- package/dist/esm/kits/answering/tasks.js +30 -25
- package/dist/esm/kits/delivery.d.ts +0 -9
- package/dist/esm/kits/delivery.js +36 -24
- package/dist/esm/kits/domains/catalog.d.ts +42 -0
- package/dist/esm/kits/domains/catalog.js +110 -0
- package/dist/esm/kits/domains/index.d.ts +4 -0
- package/dist/esm/kits/domains/index.js +4 -0
- package/dist/esm/kits/domains/registry.d.ts +100 -0
- package/dist/esm/kits/{intents → domains}/registry.js +77 -31
- package/dist/esm/kits/{intents → domains}/scopes.d.ts +18 -18
- package/dist/esm/kits/{intents → domains}/scopes.js +21 -21
- package/dist/esm/kits/index.d.ts +6 -5
- package/dist/esm/kits/index.js +6 -5
- package/dist/esm/kits/knowledge/catalog.js +33 -30
- package/dist/esm/kits/policies.d.ts +1 -1
- package/dist/esm/kits/policies.js +3 -2
- package/dist/esm/kits/presentation/formats.d.ts +42 -0
- package/dist/esm/kits/presentation/formats.js +105 -0
- package/dist/esm/kits/presentation/index.d.ts +14 -5
- package/dist/esm/kits/presentation/index.js +10 -5
- package/dist/esm/kits/presentation/outputs.js +2 -1
- package/dist/esm/kits/reflection.js +3 -3
- package/dist/esm/kits/retrieval.js +7 -1
- package/dist/esm/kits/text-blocks.d.ts +24 -0
- package/dist/esm/kits/text-blocks.js +97 -0
- package/dist/esm/kits/tools.d.ts +69 -52
- package/dist/esm/kits/tools.js +247 -158
- package/dist/esm/model/decision-retry.d.ts +2 -0
- package/dist/esm/model/decision-retry.js +2 -1
- package/dist/esm/model/index.d.ts +2 -6
- package/dist/esm/model/index.js +2 -6
- package/dist/esm/model/interactions/calls.d.ts +40 -0
- package/dist/esm/model/interactions/calls.js +58 -0
- package/dist/esm/model/interactions/json-object.js +11 -11
- package/dist/esm/model/interactions/native-functions.js +17 -23
- package/dist/esm/model/message-diagnostics.d.ts +6 -5
- package/dist/esm/model/message-diagnostics.js +13 -3
- package/dist/esm/model/options.js +2 -0
- package/dist/esm/model/preparation.js +39 -6
- package/dist/esm/model/runner.d.ts +2 -0
- package/dist/esm/model/runner.js +34 -5
- package/dist/esm/model/selection-transport.js +4 -4
- package/dist/esm/model/token-budget.js +3 -0
- package/dist/esm/model/transports.d.ts +2 -1
- package/dist/esm/model/transports.js +3 -2
- package/dist/esm/structs/capabilities/invocation.d.ts +3 -1
- package/dist/esm/structs/capabilities/model.d.ts +42 -11
- package/dist/esm/structs/capabilities/tools.d.ts +16 -7
- package/dist/esm/structs/common.d.ts +3 -1
- package/dist/esm/structs/debug.d.ts +36 -20
- package/dist/esm/structs/execution/workflow-views.d.ts +123 -0
- package/dist/esm/structs/execution/workflow.d.ts +4 -3
- package/dist/esm/structs/index.d.ts +8 -6
- package/dist/esm/structs/index.js +7 -6
- package/dist/esm/structs/kits/answering/tasks.d.ts +2 -2
- package/dist/esm/structs/kits/{intents → domains}/catalog.d.ts +20 -20
- package/dist/esm/structs/kits/{intents → domains}/registry.d.ts +24 -21
- package/dist/esm/structs/kits/{intents → domains}/scopes.d.ts +9 -9
- package/dist/esm/structs/kits/domains/scopes.js +1 -0
- package/dist/esm/structs/kits/presentation/formats.d.ts +42 -0
- package/dist/esm/structs/kits/presentation/formats.js +1 -0
- package/dist/esm/structs/kits/text-blocks.d.ts +25 -0
- package/dist/esm/structs/kits/text-blocks.js +10 -0
- package/dist/esm/structs/kits/tools.d.ts +82 -83
- package/dist/esm/structs/model/interactions.d.ts +18 -11
- package/dist/esm/structs/model/messages.d.ts +34 -2
- package/dist/esm/structs/model/runtime.d.ts +9 -0
- package/dist/esm/structs/model/session.d.ts +29 -0
- package/dist/esm/structs/model/session.js +10 -0
- package/dist/esm/structs/support/associations.d.ts +22 -0
- package/dist/esm/structs/support/associations.js +1 -0
- package/dist/esm/structs/support/model/interactions.d.ts +2 -2
- package/dist/esm/structs/support/model/messages.d.ts +6 -13
- package/dist/esm/structs/support/tools.d.ts +23 -23
- package/dist/esm/support/associations.d.ts +26 -0
- package/dist/esm/support/associations.js +76 -0
- package/dist/esm/support/context/nodes.js +48 -45
- package/dist/esm/support/context/processing.js +6 -3
- package/dist/esm/support/context/snapshot.js +11 -1
- package/dist/esm/support/decorators/index.d.ts +13 -2
- package/dist/esm/support/decorators/index.js +40 -3
- package/dist/esm/support/decorators/pool.d.ts +6 -5
- package/dist/esm/support/decorators/types.d.ts +3 -1
- package/dist/esm/support/index.d.ts +1 -0
- package/dist/esm/support/index.js +1 -0
- package/dist/esm/support/model/capabilities.d.ts +8 -3
- package/dist/esm/support/model/capabilities.js +35 -5
- package/dist/esm/support/model/chat-completions.js +11 -2
- package/dist/esm/support/model/completion/calls.d.ts +6 -34
- package/dist/esm/support/model/completion/calls.js +8 -55
- package/dist/esm/support/model/index.d.ts +1 -1
- package/dist/esm/support/model/preview-rules.d.ts +13 -8
- package/dist/esm/support/model/preview-rules.js +11 -11
- package/dist/esm/support/model/reply-preview.d.ts +2 -2
- package/dist/esm/support/model/reply-preview.js +3 -3
- package/dist/esm/support/model/session.d.ts +61 -0
- package/dist/esm/support/model/session.js +148 -0
- package/dist/esm/support/model/stage-transport.d.ts +1 -1
- package/dist/esm/support/model/stage-transport.js +9 -9
- package/dist/esm/support/model/transports.d.ts +2 -0
- package/dist/esm/support/model/transports.js +2 -1
- package/dist/esm/support/tools.d.ts +11 -3
- package/dist/esm/support/tools.js +43 -18
- package/dist/esm/utils/catalog.d.ts +1 -1
- package/dist/esm/utils/invocation.d.ts +1 -0
- package/dist/esm/utils/invocation.js +1 -0
- package/package.json +20 -6
- package/dist/cjs/execution/index.js +0 -30
- package/dist/cjs/kits/intents/catalog.js +0 -82
- package/dist/cjs/kits/intents/index.js +0 -35
- package/dist/cjs/utils/debug.js +0 -30
- package/dist/esm/execution/index.d.ts +0 -11
- package/dist/esm/execution/index.js +0 -11
- package/dist/esm/kits/intents/catalog.d.ts +0 -39
- package/dist/esm/kits/intents/catalog.js +0 -79
- package/dist/esm/kits/intents/index.d.ts +0 -22
- package/dist/esm/kits/intents/index.js +0 -18
- package/dist/esm/kits/intents/registry.d.ts +0 -88
- package/dist/esm/utils/debug.d.ts +0 -27
- package/dist/esm/utils/debug.js +0 -27
- /package/dist/cjs/structs/{kits/intents/catalog.js → execution/workflow-views.js} +0 -0
- /package/dist/cjs/structs/kits/{intents/registry.js → domains/catalog.js} +0 -0
- /package/dist/cjs/structs/kits/{intents/scopes.js → domains/registry.js} +0 -0
- /package/dist/esm/structs/{kits/intents/catalog.js → execution/workflow-views.js} +0 -0
- /package/dist/esm/structs/kits/{intents/registry.js → domains/catalog.js} +0 -0
- /package/dist/esm/structs/kits/{intents/scopes.js → domains/registry.js} +0 -0
package/dist/esm/kits/tools.d.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import type { ToolInvocationRequest } from '../structs/capabilities/tools.js';
|
|
2
2
|
import type { ToolResult } from '../structs/invocation.js';
|
|
3
|
-
import type { ToolRuntimeTypes,
|
|
3
|
+
import type { ToolRuntimeTypes, Tool, ToolRegistration, RegisteredToolDefinition, ToolsOptions, ToolNormalizer, ToolFinalizer, ToolProtocol } from '../structs/kits/tools.js';
|
|
4
4
|
import type { ToolRegistryPorts } from '../structs/capabilities/tools.js';
|
|
5
5
|
import { ProtocolRegistry } from '../utils/protocol-registry.js';
|
|
6
6
|
/**
|
|
7
|
-
* Registered lifecycle
|
|
8
|
-
* configuration.
|
|
7
|
+
* Registered lifecycle hooks. Domain predicates and phase names are host configuration.
|
|
9
8
|
*/
|
|
10
|
-
type PreparedTool<Types extends ToolRuntimeTypes,
|
|
9
|
+
type PreparedTool<Types extends ToolRuntimeTypes, Declaration extends ToolRegistration<Types>> = RegisteredToolDefinition<Types, Declaration> & Tool<Types>;
|
|
11
10
|
/**
|
|
12
|
-
* Registry of tools whose lifecycle, protocols and contributions
|
|
11
|
+
* Registry of tools whose lifecycle, protocols and context contributions the App declares.
|
|
13
12
|
*
|
|
14
13
|
* Registration is only possible before `seal()`; afterwards the catalog is read-only, so a run
|
|
15
|
-
* cannot change which tools exist. Every
|
|
16
|
-
*
|
|
14
|
+
* cannot change which tools exist. Every hook is optional and is applied in registration order,
|
|
15
|
+
* which is why `registerAll` preserves iteration order.
|
|
17
16
|
*/
|
|
18
|
-
export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes,
|
|
17
|
+
export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Declaration extends ToolRegistration<Types> = ToolRegistration<Types>> {
|
|
19
18
|
private readonly tools;
|
|
20
19
|
private readonly registered;
|
|
21
20
|
private readonly sources;
|
|
21
|
+
/** Tools that own an invocation id; dispatch by decision next reads this index. */
|
|
22
22
|
private readonly invocations;
|
|
23
|
+
/** Tools that answer a delegate id; dispatch by node reads this index. */
|
|
24
|
+
private readonly delegateIndex;
|
|
23
25
|
private normalizer?;
|
|
24
26
|
private finalizer?;
|
|
25
27
|
private sealed;
|
|
@@ -30,11 +32,11 @@ export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Tool
|
|
|
30
32
|
/**
|
|
31
33
|
* @param options - Receiver, execution context, error wording, registration policy, protocol
|
|
32
34
|
* providers and optional journal/receipt ports; contract methods are bound to their owner.
|
|
33
|
-
* @throws TypeError When no `
|
|
35
|
+
* @throws TypeError When no `goalIds` provider is supplied.
|
|
34
36
|
*/
|
|
35
|
-
constructor(options:
|
|
37
|
+
constructor(options: ToolsOptions<Types, Declaration>);
|
|
36
38
|
/** Core tool events, forwarded unchanged. */
|
|
37
|
-
get events(): readonly Readonly<import("../index.js").ToolExecutionEvent<PreparedTool<Types,
|
|
39
|
+
get events(): readonly Readonly<import("../index.js").ToolExecutionEvent<PreparedTool<Types, Declaration>["kind"]>>[];
|
|
38
40
|
/** Swap the diagnostics sink for later invocations; the Core registry is updated as well. */
|
|
39
41
|
setDiagnostics(value: ToolRegistryPorts['diagnostics']): void;
|
|
40
42
|
/**
|
|
@@ -44,16 +46,19 @@ export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Tool
|
|
|
44
46
|
* hooks must return `void` synchronously, while the remaining handlers are checked for
|
|
45
47
|
* accidental thenables only.
|
|
46
48
|
*
|
|
47
|
-
* @param input - Tool definition with identity, audience, effect and its
|
|
49
|
+
* @param input - Tool definition with identity, audience, effect and its hooks.
|
|
48
50
|
* @returns This registry, for chaining.
|
|
49
51
|
* @throws A configured registration error for a sealed registry, invalid identity,
|
|
50
|
-
* description, audience, effect,
|
|
51
|
-
* incomplete
|
|
52
|
+
* description, audience, effect, goal ids, missing handlers, duplicate tool id,
|
|
53
|
+
* duplicate delegate id, incomplete lifecycle contract, protocol version mismatch or
|
|
54
|
+
* duplicate invocation id.
|
|
52
55
|
*/
|
|
53
|
-
register(input:
|
|
56
|
+
register(input: Declaration): this;
|
|
57
|
+
/** Validate one declaration in the fixed order documented by `register`. */
|
|
58
|
+
private assertRegistration;
|
|
54
59
|
private install;
|
|
55
60
|
/** Register every tool in iteration order. */
|
|
56
|
-
registerAll(tools: Iterable<
|
|
61
|
+
registerAll(tools: Iterable<Declaration>): this;
|
|
57
62
|
/**
|
|
58
63
|
* Invoke one Core tool by its already-validated request.
|
|
59
64
|
*
|
|
@@ -62,23 +67,25 @@ export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Tool
|
|
|
62
67
|
*/
|
|
63
68
|
invoke(request: ToolInvocationRequest): ToolResult<unknown>;
|
|
64
69
|
/** Registered tools in registration order. */
|
|
65
|
-
get definitions(): readonly
|
|
70
|
+
get definitions(): readonly RegisteredToolDefinition<Types, Declaration>[];
|
|
66
71
|
/** Registered tool ids, delegated to the Core registry. */
|
|
67
72
|
ids(): readonly string[];
|
|
68
73
|
/** Iterate `[id, tool]` pairs. */
|
|
69
|
-
entries(): IterableIterator<[string,
|
|
74
|
+
entries(): IterableIterator<[string, RegisteredToolDefinition<Types, Declaration>]>;
|
|
70
75
|
/** Registered tool for `id`, or `undefined` when it is absent. */
|
|
71
|
-
get(id: string):
|
|
76
|
+
get(id: string): RegisteredToolDefinition<Types, Declaration> | undefined;
|
|
72
77
|
/**
|
|
73
78
|
* Registered tool for `id`.
|
|
74
79
|
*
|
|
75
80
|
* @throws TypeError When the id is not registered.
|
|
76
81
|
*/
|
|
77
|
-
require(id: string):
|
|
82
|
+
require(id: string): RegisteredToolDefinition<Types, Declaration>;
|
|
78
83
|
/** Whether a tool id is registered. */
|
|
79
84
|
has(name: string): boolean;
|
|
80
85
|
/** Iterate the registered tools. */
|
|
81
|
-
values(): IterableIterator<
|
|
86
|
+
values(): IterableIterator<RegisteredToolDefinition<Types, Declaration>>;
|
|
87
|
+
/** Whether a delegate id is claimed by a registered tool. */
|
|
88
|
+
hasDelegate(id: string): boolean;
|
|
82
89
|
/**
|
|
83
90
|
* Install the single normalization handler.
|
|
84
91
|
*
|
|
@@ -101,30 +108,40 @@ export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Tool
|
|
|
101
108
|
*/
|
|
102
109
|
finish(receiver: Types['receiver'], decision: Types['decision'], context: Types['context']): Types['result'];
|
|
103
110
|
/**
|
|
104
|
-
*
|
|
111
|
+
* Run the invocation that answers one decision next.
|
|
112
|
+
*
|
|
113
|
+
* Delegation is the App's choice; this method only executes the tool that claimed the id, so a
|
|
114
|
+
* purely programmatic node, a model choice and a mixed pipeline all dispatch the same way.
|
|
105
115
|
*
|
|
106
116
|
* Diagnostics are swapped to the invocation's own sink for the duration of the call and
|
|
107
117
|
* restored afterwards, so nested tool calls report under the innermost scope.
|
|
108
118
|
*
|
|
109
|
-
* @param
|
|
119
|
+
* @param next - Decision next carrying the claimed delegate id in `type`.
|
|
110
120
|
* @param context - Execution context forwarded to Core's invocation executor.
|
|
111
|
-
* @throws A configured error when the
|
|
121
|
+
* @throws A configured error when the delegate is unknown or the tool is unavailable.
|
|
112
122
|
*/
|
|
113
|
-
call(
|
|
123
|
+
call(next: {
|
|
114
124
|
type: string;
|
|
115
125
|
}, context: Types['context']): void;
|
|
116
|
-
/** Output protocols plus one protocol per registered invocation
|
|
117
|
-
protocols(): ProtocolRegistry<ToolProtocol<
|
|
126
|
+
/** Output protocols plus one protocol per registered invocation. */
|
|
127
|
+
protocols(): ProtocolRegistry<ToolProtocol<Declaration>>;
|
|
118
128
|
/**
|
|
119
|
-
* Protocols exposed to the model: output protocols plus
|
|
129
|
+
* Protocols exposed to the model: output protocols plus invocations whose audience is `model` and
|
|
120
130
|
* which are currently available in `context`.
|
|
121
131
|
*/
|
|
122
|
-
modelProtocols(context: Types['context']): ProtocolRegistry<ToolProtocol<
|
|
123
|
-
/** Whether the protocol registered for this
|
|
124
|
-
isTerminal(
|
|
132
|
+
modelProtocols(context: Types['context']): ProtocolRegistry<ToolProtocol<Declaration>>;
|
|
133
|
+
/** Whether the protocol registered for this invocation is declared terminal. */
|
|
134
|
+
isTerminal(next: {
|
|
125
135
|
type: string;
|
|
126
136
|
}): boolean;
|
|
127
|
-
/**
|
|
137
|
+
/** `[invocationId, protocol]` pairs, optionally filtered by the owning tool. */
|
|
138
|
+
private invocationProtocols;
|
|
139
|
+
/**
|
|
140
|
+
* Run `inspect` for every registered tool in registration order.
|
|
141
|
+
*
|
|
142
|
+
* `inspect` belongs to the all-tools group, so the selected tool participates exactly once
|
|
143
|
+
* through the same loop rather than through a second selected-only pass.
|
|
144
|
+
*/
|
|
128
145
|
assertDecision(decision: Types['decision'], context: Types['context']): void;
|
|
129
146
|
/** Run the selected invocation's authorization hook, if any. */
|
|
130
147
|
authorize(decision: Types['decision'], context: Types['context']): void;
|
|
@@ -132,33 +149,33 @@ export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Tool
|
|
|
132
149
|
resume(decision: Types['decision'], context: Types['context']): boolean;
|
|
133
150
|
/** Let the selected invocation rewrite the decision on completion, if it declares a hook. */
|
|
134
151
|
complete(decision: Types['decision'], context: Types['context']): Types['decision'] | undefined;
|
|
135
|
-
/** Fold every
|
|
152
|
+
/** Fold every tool's context projection over the value, in registration order. */
|
|
136
153
|
projectContext(value: unknown): unknown;
|
|
137
|
-
/** Fold every
|
|
154
|
+
/** Fold every tool's visible-text transform over the text. */
|
|
138
155
|
visibleText(text: string, context: Types['context']): string;
|
|
139
|
-
/** Fold every
|
|
156
|
+
/** Fold every tool's review transform over the draft. */
|
|
140
157
|
reviewDraft(draft: unknown, context: Types['context']): unknown;
|
|
141
158
|
/** Collected recovery context values; `undefined` results are omitted. */
|
|
142
159
|
recoveryContext(context: Types['context']): unknown[];
|
|
143
160
|
/**
|
|
144
161
|
* The single output template that owns this delivery.
|
|
145
162
|
*
|
|
146
|
-
* @throws An error when more than one
|
|
147
|
-
*
|
|
163
|
+
* @throws An error when more than one tool claims composition, because delivery would
|
|
164
|
+
* otherwise depend on registration order.
|
|
148
165
|
*/
|
|
149
166
|
composition(context: Types['context']): Types['composition'] | undefined;
|
|
150
|
-
/** Run every
|
|
167
|
+
/** Run every tool's finalize hook for the given phase. */
|
|
151
168
|
finalize(decision: Types['decision'], context: Types['context'], phase: Types['phase']): void;
|
|
152
|
-
/** Whether any
|
|
169
|
+
/** Whether any tool permits the interaction to be missing. */
|
|
153
170
|
missingInteractionAllowed(decision: Types['decision'], context: Types['context']): boolean;
|
|
154
171
|
/** Task rules ordered by their declared `order`, joined into one prompt block. */
|
|
155
172
|
taskRules(context: Types['context']): string;
|
|
156
173
|
/** Model-context fragments for one placement, ordered by each field's `order`. */
|
|
157
174
|
contextFields(context: Types['context'], placement: Types['placement']): import("../index.js").ContextFragment[];
|
|
158
175
|
/** Merged model-context values for one placement; later fragments win per key. */
|
|
159
|
-
modelFields(context: Types['context'], placement: Types['placement']):
|
|
160
|
-
/** A
|
|
161
|
-
|
|
176
|
+
modelFields(context: Types['context'], placement: Types['placement']): Record<string, unknown>;
|
|
177
|
+
/** A tool may veto a goal by returning `false`; silence means support. */
|
|
178
|
+
supportsGoal(intentId: string, context: Types['context']): boolean;
|
|
162
179
|
/**
|
|
163
180
|
* Describe registered tools, optionally limited by audience and availability.
|
|
164
181
|
*
|
|
@@ -167,15 +184,15 @@ export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Tool
|
|
|
167
184
|
*
|
|
168
185
|
* @param audience - Audience to keep; omit to include every audience.
|
|
169
186
|
* @param context - Context for availability checks.
|
|
170
|
-
* @returns Plain metadata; `
|
|
187
|
+
* @returns Plain metadata; `goalIds: 'all'` is expanded to the current goal ids.
|
|
171
188
|
*/
|
|
172
189
|
describe(audience?: string, context?: Types['context']): {
|
|
173
|
-
id:
|
|
174
|
-
kind:
|
|
175
|
-
description:
|
|
176
|
-
audience:
|
|
177
|
-
effect:
|
|
178
|
-
|
|
190
|
+
id: Declaration['id'];
|
|
191
|
+
kind: Declaration['kind'];
|
|
192
|
+
description: Declaration['description'];
|
|
193
|
+
audience: Declaration['audience'];
|
|
194
|
+
effect: Declaration['effect'];
|
|
195
|
+
goalIds: string[];
|
|
179
196
|
}[];
|
|
180
197
|
/**
|
|
181
198
|
* Reinstall every registered tool, plus the finalizer and normalizer, into another registry.
|
|
@@ -183,12 +200,12 @@ export declare class ToolLifecycleRegistry<Types extends ToolRuntimeTypes, Tool
|
|
|
183
200
|
* The original definitions are reused rather than the compiled views, so the target applies
|
|
184
201
|
* its own policy checks and binding exactly as it would for a first registration.
|
|
185
202
|
*/
|
|
186
|
-
copyTo(target: ToolLifecycleRegistry<Types,
|
|
203
|
+
copyTo(target: ToolLifecycleRegistry<Types, Declaration>): void;
|
|
187
204
|
/** Freeze the registry: no further registration, normalizer or finalizer is accepted. */
|
|
188
205
|
seal(): this;
|
|
189
|
-
/** Tool that owns the invocation
|
|
206
|
+
/** Tool that owns the invocation id named by the decision, if any. */
|
|
190
207
|
private selected;
|
|
191
208
|
}
|
|
192
|
-
export type { ToolRuntimeTypes,
|
|
209
|
+
export type { ToolRuntimeTypes, Tool, ToolRegistration, RegisteredToolDefinition, ToolsOptions, Policy, LifecycleHooks, LifecycleProtocol, ToolModelField, ToolNormalizer, ToolFinalizer, ToolJournal, ToolProtocol, } from '../structs/kits/tools.js';
|
|
193
210
|
/** The lifecycle registry is the public `Tools` Kit entry point. */
|
|
194
211
|
export { ToolLifecycleRegistry as Tools };
|