@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { WorkflowNode, AgentWorkflowDefinition } from '../../structs/execution/workflow.js';
|
|
2
2
|
import type { ToolDefinition } from '../../structs/capabilities/tools.js';
|
|
3
|
+
import type { ModelTool } from '../../structs/capabilities/model.js';
|
|
3
4
|
import type { ContextFragmentConfig } from '../../structs/support/context.js';
|
|
4
5
|
/** Registration identity; ids are unique within one kind and namespace. */
|
|
5
6
|
export interface IdentifiedDefinition {
|
|
@@ -19,7 +20,7 @@ export declare function registerDefinition(kind: DefinitionKind, definition: Ide
|
|
|
19
20
|
/** Decorated nodes; ids are unique within each namespace. */
|
|
20
21
|
export declare const nodePool: DefinitionReader<WorkflowNode<any, any, any>>;
|
|
21
22
|
/** Decorated tools; namespaces isolate otherwise identical ids. */
|
|
22
|
-
export declare const toolPool: DefinitionReader<
|
|
23
|
+
export declare const toolPool: DefinitionReader<ModelTool<any, any, any> | ToolDefinition<any, any, any>>;
|
|
23
24
|
/** Decorated fragment configurations; use the original builder to assemble them. */
|
|
24
25
|
export declare const fragmentPool: DefinitionReader<ContextFragmentConfig<any>>;
|
|
25
26
|
/** Decorated workflow definitions; execution still belongs to the original Engine. */
|
|
@@ -29,7 +30,7 @@ export declare const agentPool: DefinitionReader<(Omit<import("../../index.js").
|
|
|
29
30
|
readonly branch?: import("../../index.js").AgentBranch;
|
|
30
31
|
readonly tools?: {
|
|
31
32
|
invoke: (request: import("../../index.js").ToolInvocationRequest) => Promise<import("../../index.js").ToolResult<unknown>>;
|
|
32
|
-
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").
|
|
33
|
+
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").ErasedTool>, "invokeAsync">;
|
|
33
34
|
} & {
|
|
34
35
|
model?: import("../../index.js").AgentModelBinding;
|
|
35
36
|
models?: never;
|
|
@@ -42,7 +43,7 @@ export declare const agentPool: DefinitionReader<(Omit<import("../../index.js").
|
|
|
42
43
|
readonly branch?: import("../../index.js").AgentBranch;
|
|
43
44
|
readonly tools?: {
|
|
44
45
|
invoke: (request: import("../../index.js").ToolInvocationRequest) => Promise<import("../../index.js").ToolResult<unknown>>;
|
|
45
|
-
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").
|
|
46
|
+
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").ErasedTool>, "invokeAsync">;
|
|
46
47
|
} & {
|
|
47
48
|
model?: string;
|
|
48
49
|
models: Readonly<Record<string, import("../../index.js").AgentModelBinding>>;
|
|
@@ -56,7 +57,7 @@ export declare const agentPool: DefinitionReader<(Omit<import("../../index.js").
|
|
|
56
57
|
readonly branch?: import("../../index.js").AgentBranch;
|
|
57
58
|
readonly tools?: {
|
|
58
59
|
invoke: (request: import("../../index.js").ToolInvocationRequest) => Promise<import("../../index.js").ToolResult<unknown>>;
|
|
59
|
-
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").
|
|
60
|
+
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").ErasedTool>, "invokeAsync">;
|
|
60
61
|
} & {
|
|
61
62
|
model?: import("../../index.js").AgentModelBinding;
|
|
62
63
|
models?: never;
|
|
@@ -70,7 +71,7 @@ export declare const agentPool: DefinitionReader<(Omit<import("../../index.js").
|
|
|
70
71
|
readonly branch?: import("../../index.js").AgentBranch;
|
|
71
72
|
readonly tools?: {
|
|
72
73
|
invoke: (request: import("../../index.js").ToolInvocationRequest) => Promise<import("../../index.js").ToolResult<unknown>>;
|
|
73
|
-
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").
|
|
74
|
+
} | Pick<import("../../index.js").ToolRegistry<import("../../index.js").ErasedTool>, "invokeAsync">;
|
|
74
75
|
} & {
|
|
75
76
|
model?: string;
|
|
76
77
|
models: Readonly<Record<string, import("../../index.js").AgentModelBinding>>;
|
|
@@ -11,7 +11,9 @@ import type { DefinitionBody } from './definition.js';
|
|
|
11
11
|
/** A node implementation; its public id is supplied by @node. */
|
|
12
12
|
export type Node<State, Result, App = undefined> = DefinitionBody<WorkflowNode<State, Result, App>>;
|
|
13
13
|
/** A tool implementation with the original schema, authorization and execution contracts. */
|
|
14
|
-
export type Tool<Input = unknown, Output = unknown, App = unknown> = DefinitionBody<ToolDefinition<Input, Output, App
|
|
14
|
+
export type Tool<Input = unknown, Output = unknown, App = unknown> = DefinitionBody<Omit<ToolDefinition<Input, Output, App>, 'asIntent'>> & {
|
|
15
|
+
readonly asIntent?: never;
|
|
16
|
+
};
|
|
15
17
|
/** A formatter and its original provenance, trust and budget configuration. */
|
|
16
18
|
export type Fragment<Input = unknown> = DefinitionBody<ContextFragmentConfig<Input>>;
|
|
17
19
|
/** A complete graph definition whose workflow id is supplied by @workflow. */
|
|
@@ -21,3 +21,4 @@ export type { ReplyPreviewRule, ReplyPreviewOptions } from './model/reply-previe
|
|
|
21
21
|
export * from './capabilities.js';
|
|
22
22
|
export { retryMultipleModelCalls } from '../model/decision-retry.js';
|
|
23
23
|
export type { RegistrationDefinition } from '../structs/support/registration.js';
|
|
24
|
+
export * from './associations.js';
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ModelToolRegistration, ModelToolCatalog } from '../../structs/capabilities/model.js';
|
|
2
|
+
import type { ToolProposal } from '../../structs/capabilities/model.js';
|
|
2
3
|
/** A sealed typed snapshot. Mutating the original list cannot widen its result contract. */
|
|
3
4
|
type CapabilityOutput<Definition> = Definition extends {
|
|
5
|
+
execute(...args: any[]): unknown;
|
|
6
|
+
} ? ToolProposal : Definition extends {
|
|
4
7
|
resolve(...args: any[]): infer Output;
|
|
5
|
-
} ? Output :
|
|
8
|
+
} ? Output : Definition extends {
|
|
9
|
+
inputSchema: import('../../structs/common.js').SchemaAdapter<infer Input>;
|
|
10
|
+
} ? Input : never;
|
|
6
11
|
/**
|
|
7
12
|
* Build a sealed capability catalog from typed declarations.
|
|
8
13
|
*
|
|
@@ -13,5 +18,5 @@ type CapabilityOutput<Definition> = Definition extends {
|
|
|
13
18
|
* unknown ID.
|
|
14
19
|
* @throws {Error} When a resolver is asynchronous.
|
|
15
20
|
*/
|
|
16
|
-
export declare function
|
|
21
|
+
export declare function defineModelTools<const Definitions extends readonly ModelToolRegistration[]>(definitions: Definitions): ModelToolCatalog<CapabilityOutput<Definitions[number]>>;
|
|
17
22
|
export {};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Model capability catalog: seal a typed declaration list into a reusable catalog.
|
|
3
3
|
*
|
|
4
4
|
* The catalog is a frozen snapshot, so mutating the original declaration list cannot widen the
|
|
5
|
-
* result type or add
|
|
5
|
+
* result type or add tools at runtime. Resolution stays inside Core's registry; Support only
|
|
6
6
|
* projects the declarations and their output type.
|
|
7
7
|
*
|
|
8
|
-
* Main export: `
|
|
8
|
+
* Main export: `defineModelTools`.
|
|
9
9
|
*/
|
|
10
10
|
import { readonlyCatalog } from '../../utils/catalog.js';
|
|
11
|
-
import {
|
|
11
|
+
import { ModelToolRegistry } from '../../capabilities/model.js';
|
|
12
12
|
/**
|
|
13
13
|
* Build a sealed capability catalog from typed declarations.
|
|
14
14
|
*
|
|
@@ -19,10 +19,40 @@ import { ModelCapabilityRegistry } from '../../capabilities/model.js';
|
|
|
19
19
|
* unknown ID.
|
|
20
20
|
* @throws {Error} When a resolver is asynchronous.
|
|
21
21
|
*/
|
|
22
|
-
export function
|
|
23
|
-
const registry = new
|
|
22
|
+
export function defineModelTools(definitions) {
|
|
23
|
+
const registry = new ModelToolRegistry(definitions.map(modelDefinition)).seal();
|
|
24
|
+
return project(registry);
|
|
25
|
+
}
|
|
26
|
+
/** Executable tools propose raw arguments; business parsing occurs once at execution. */
|
|
27
|
+
function modelDefinition(definition) {
|
|
28
|
+
const executable = definition;
|
|
29
|
+
if (typeof executable.execute !== 'function')
|
|
30
|
+
return definition;
|
|
31
|
+
if (typeof executable.authorize !== 'function' || typeof executable.parseOutput !== 'function')
|
|
32
|
+
throw new TypeError('Missing executable tool handler');
|
|
33
|
+
const id = definition.id;
|
|
34
|
+
return {
|
|
35
|
+
id,
|
|
36
|
+
description: definition.description,
|
|
37
|
+
active: typeof definition.active === 'function'
|
|
38
|
+
? definition.active.bind(definition)
|
|
39
|
+
: definition.active,
|
|
40
|
+
asIntent: typeof definition.asIntent === 'function'
|
|
41
|
+
? definition.asIntent.bind(definition)
|
|
42
|
+
: definition.asIntent,
|
|
43
|
+
inputSchema: {
|
|
44
|
+
jsonSchema: definition.inputSchema.jsonSchema,
|
|
45
|
+
parse: (input) => input,
|
|
46
|
+
},
|
|
47
|
+
resolve: (input) => ({ toolId: id, input }),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Project existing immutable entries without re-registering schemas or rebinding handlers. */
|
|
51
|
+
function project(registry) {
|
|
24
52
|
return Object.freeze({
|
|
25
53
|
...readonlyCatalog(registry.definitions, (id) => new TypeError(`Unknown model capability: ${id}`)),
|
|
26
54
|
resolve: (selection, stage) => registry.resolve(selection, stage),
|
|
55
|
+
select: (ids, ...context) => project(context.length ? registry.select(ids, context[0]) : registry.select(ids)),
|
|
56
|
+
withIntent: (context) => project(registry.withIntent(context)),
|
|
27
57
|
});
|
|
28
58
|
}
|
|
@@ -14,10 +14,19 @@ export function chatCompletionFunctionOptions(options) {
|
|
|
14
14
|
return {};
|
|
15
15
|
if (!options.functions.length)
|
|
16
16
|
throw new TypeError('Empty model function catalog');
|
|
17
|
+
if (options.toolChoice !== undefined &&
|
|
18
|
+
!['auto', 'required', 'none'].includes(options.toolChoice))
|
|
19
|
+
throw new TypeError('Invalid toolChoice');
|
|
20
|
+
if (options.parallelToolCalls !== undefined &&
|
|
21
|
+
options.parallelToolCalls !== 'omit' &&
|
|
22
|
+
typeof options.parallelToolCalls !== 'boolean')
|
|
23
|
+
throw new TypeError('Invalid parallelToolCalls');
|
|
17
24
|
return {
|
|
18
25
|
tools: options.functions.map((fn) => ({ type: 'function', function: fn })),
|
|
19
|
-
tool_choice: 'required',
|
|
20
|
-
|
|
26
|
+
tool_choice: options.toolChoice ?? 'required',
|
|
27
|
+
...(options.parallelToolCalls === 'omit'
|
|
28
|
+
? {}
|
|
29
|
+
: { parallel_tool_calls: options.parallelToolCalls ?? false }),
|
|
21
30
|
};
|
|
22
31
|
}
|
|
23
32
|
/**
|
|
@@ -1,40 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool-call delta aggregation.
|
|
2
|
+
* Tool-call delta aggregation, re-exported from Core.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The algorithm lives in `model/interactions/calls.ts` so session transports and
|
|
5
|
+
* completion policies share one implementation. This module keeps the existing
|
|
6
|
+
* Support import path stable.
|
|
7
7
|
*
|
|
8
8
|
* Exports: `AggregatedToolCall`, `ToolCallCollector`, `ToolCallFailure` and
|
|
9
9
|
* `createToolCallCollector`.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface AggregatedToolCall {
|
|
14
|
-
readonly index: number;
|
|
15
|
-
readonly id: string;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly arguments: string;
|
|
18
|
-
}
|
|
19
|
-
/** Report a protocol violation and stop; callers decide how the failure is classified. */
|
|
20
|
-
export type ToolCallFailure = (message: string) => never;
|
|
21
|
-
/** Aggregation entry point for streamed function-call deltas. */
|
|
22
|
-
export interface ToolCallCollector {
|
|
23
|
-
/** Feed one part; text parts are ignored and cannot satisfy or break a call. */
|
|
24
|
-
push(part: ModelPart): void;
|
|
25
|
-
/** Calls started so far, including incomplete ones, in index order. */
|
|
26
|
-
readonly calls: readonly AggregatedToolCall[];
|
|
27
|
-
/**
|
|
28
|
-
* Finalize the calls.
|
|
29
|
-
*
|
|
30
|
-
* @throws When any started call is still missing its ID or name.
|
|
31
|
-
*/
|
|
32
|
-
complete(): readonly AggregatedToolCall[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a collector for one response.
|
|
36
|
-
*
|
|
37
|
-
* @param fail - Protocol failure factory; defaults to the Core model protocol error.
|
|
38
|
-
* @returns A collector that keeps its own state and never shares it with another response.
|
|
39
|
-
*/
|
|
40
|
-
export declare function createToolCallCollector(fail?: ToolCallFailure): ToolCallCollector;
|
|
11
|
+
export { createToolCallCollector } from '../../../model/interactions/calls.js';
|
|
12
|
+
export type { AggregatedToolCall, ToolCallCollector, ToolCallFailure, } from '../../../model/interactions/calls.js';
|
|
@@ -1,58 +1,11 @@
|
|
|
1
|
-
import { modelProtocolError } from '../../../utils/model-protocol.js';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Tool-call delta aggregation, re-exported from Core.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The algorithm lives in `model/interactions/calls.ts` so session transports and
|
|
5
|
+
* completion policies share one implementation. This module keeps the existing
|
|
6
|
+
* Support import path stable.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `AggregatedToolCall`, `ToolCallCollector`, `ToolCallFailure` and
|
|
9
|
+
* `createToolCallCollector`.
|
|
7
10
|
*/
|
|
8
|
-
export
|
|
9
|
-
const pending = new Map();
|
|
10
|
-
const ids = new Set();
|
|
11
|
-
const calls = () => [...pending.entries()]
|
|
12
|
-
.sort(([left], [right]) => left - right)
|
|
13
|
-
.map(([index, call]) => ({ index, ...call }));
|
|
14
|
-
return {
|
|
15
|
-
push(part) {
|
|
16
|
-
if (typeof part === 'string')
|
|
17
|
-
return;
|
|
18
|
-
if (!part || typeof part !== 'object' || Array.isArray(part))
|
|
19
|
-
fail('Expected a native model call');
|
|
20
|
-
const { type, index, id, name, arguments: args } = part;
|
|
21
|
-
if (type !== 'function-call-delta')
|
|
22
|
-
fail('Expected a native model call');
|
|
23
|
-
if (!Number.isInteger(index) || index < 0)
|
|
24
|
-
fail('Invalid model call index');
|
|
25
|
-
if ((id !== undefined && (typeof id !== 'string' || !id)) ||
|
|
26
|
-
(name !== undefined && typeof name !== 'string') ||
|
|
27
|
-
(args !== undefined && typeof args !== 'string'))
|
|
28
|
-
fail('Invalid model call fields');
|
|
29
|
-
let call = pending.get(index);
|
|
30
|
-
if (!call) {
|
|
31
|
-
call = { id: '', name: '', arguments: '' };
|
|
32
|
-
pending.set(index, call);
|
|
33
|
-
}
|
|
34
|
-
if (id !== undefined) {
|
|
35
|
-
if (call.id && call.id !== id)
|
|
36
|
-
fail('Conflicting model call IDs');
|
|
37
|
-
if (!call.id) {
|
|
38
|
-
if (ids.has(id))
|
|
39
|
-
fail('Duplicate model call ID');
|
|
40
|
-
ids.add(id);
|
|
41
|
-
call.id = id;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
call.name += name ?? '';
|
|
45
|
-
call.arguments += args ?? '';
|
|
46
|
-
},
|
|
47
|
-
get calls() {
|
|
48
|
-
return calls();
|
|
49
|
-
},
|
|
50
|
-
complete() {
|
|
51
|
-
const completed = calls();
|
|
52
|
-
for (const call of completed)
|
|
53
|
-
if (!call.id || !call.name)
|
|
54
|
-
fail('Incomplete model call');
|
|
55
|
-
return completed;
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
11
|
+
export { createToolCallCollector } from '../../../model/interactions/calls.js';
|
|
@@ -22,7 +22,7 @@ export * from './capabilities.js';
|
|
|
22
22
|
export { createStageModelTransport } from './stage-transport.js';
|
|
23
23
|
export { createProviderObservationScope } from './observer.js';
|
|
24
24
|
export { createReplyPreviewRules } from './preview-rules.js';
|
|
25
|
-
export type {
|
|
25
|
+
export type { PreviewTool, ReplyPreviewTool, ReplyPreviewStage } from './preview-rules.js';
|
|
26
26
|
export { runChildren } from './children.js';
|
|
27
27
|
export type { ModelChildTask, ModelChildrenOptions } from './children.js';
|
|
28
28
|
export { createModelStrategy, modelBudgetStrategies } from './strategies.js';
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { JsonSchema } from '../../structs/common.js';
|
|
2
2
|
import type { ReplyPreviewRule } from './reply-preview.js';
|
|
3
|
+
import type { ModelTool } from '../../structs/capabilities/model.js';
|
|
4
|
+
/** A model tool with an explicit, presentation-only streaming preview contract. */
|
|
5
|
+
export interface PreviewTool<Input = unknown, Selection = Input, Context = any> extends ModelTool<Input, Selection, Context> {
|
|
6
|
+
readonly preview?: true | Omit<ReplyPreviewRule, 'stageId' | 'toolId'>;
|
|
7
|
+
}
|
|
3
8
|
/**
|
|
4
9
|
* Capability declaration used to derive preview rules.
|
|
5
10
|
*
|
|
6
11
|
* Omitted `preview` means the capability never previews, so previewing is an explicit opt-in.
|
|
7
12
|
*/
|
|
8
|
-
export interface
|
|
13
|
+
export interface ReplyPreviewTool {
|
|
9
14
|
/** Capability ID, which must equal the native function wire name used for transport. */
|
|
10
15
|
readonly id: string;
|
|
11
16
|
/** Input schema used to prove that preview and eligibility paths really exist. */
|
|
@@ -14,16 +19,16 @@ export interface ReplyPreviewCapability {
|
|
|
14
19
|
* Explicit preview opt-in: `true` uses the default text/bubble paths, an object narrows the
|
|
15
20
|
* paths and eligibility, and omission means the capability never previews.
|
|
16
21
|
*/
|
|
17
|
-
readonly preview?: true | Omit<ReplyPreviewRule, 'stageId' | '
|
|
22
|
+
readonly preview?: true | Omit<ReplyPreviewRule, 'stageId' | 'toolId'>;
|
|
18
23
|
}
|
|
19
|
-
/** Stage declaration: which
|
|
24
|
+
/** Stage declaration: which tools it exposes and whether it previews text or arguments. */
|
|
20
25
|
export interface ReplyPreviewStage {
|
|
21
26
|
/** Stage ID used by the workflow and transport projection. */
|
|
22
27
|
readonly id: string;
|
|
23
28
|
/** Capabilities exposed at this stage; must be unique and registered. */
|
|
24
|
-
readonly
|
|
25
|
-
/** `text` previews plain model text; `
|
|
26
|
-
readonly preview?: 'text' | '
|
|
29
|
+
readonly toolIds?: readonly string[];
|
|
30
|
+
/** `text` previews plain model text; `tools` previews opted-in capability arguments. */
|
|
31
|
+
readonly preview?: 'text' | 'tools';
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* Generate frozen preview rules from capability and stage declarations.
|
|
@@ -31,12 +36,12 @@ export interface ReplyPreviewStage {
|
|
|
31
36
|
* Capabilities without preview metadata are skipped even when their stage opts in. Default paths
|
|
32
37
|
* are `text` and `bubbles[*]`, each kept only when the capability schema declares it.
|
|
33
38
|
*
|
|
34
|
-
* @param options Stage declarations and the
|
|
39
|
+
* @param options Stage declarations and the tools they may reference.
|
|
35
40
|
* @returns Frozen rules in stage order, each with deep-frozen paths and eligibility.
|
|
36
41
|
* @throws {Error} When a capability or stage ID repeats, a stage references an unknown capability,
|
|
37
42
|
* a preview mode is unknown, or a preview path or eligibility field is absent from the schema.
|
|
38
43
|
*/
|
|
39
44
|
export declare function createReplyPreviewRules(options: {
|
|
40
45
|
readonly stages: readonly ReplyPreviewStage[];
|
|
41
|
-
readonly
|
|
46
|
+
readonly tools: readonly ReplyPreviewTool[];
|
|
42
47
|
}): readonly ReplyPreviewRule[];
|
|
@@ -80,29 +80,29 @@ function previewSnapshot(preview) {
|
|
|
80
80
|
* Capabilities without preview metadata are skipped even when their stage opts in. Default paths
|
|
81
81
|
* are `text` and `bubbles[*]`, each kept only when the capability schema declares it.
|
|
82
82
|
*
|
|
83
|
-
* @param options Stage declarations and the
|
|
83
|
+
* @param options Stage declarations and the tools they may reference.
|
|
84
84
|
* @returns Frozen rules in stage order, each with deep-frozen paths and eligibility.
|
|
85
85
|
* @throws {Error} When a capability or stage ID repeats, a stage references an unknown capability,
|
|
86
86
|
* a preview mode is unknown, or a preview path or eligibility field is absent from the schema.
|
|
87
87
|
*/
|
|
88
88
|
export function createReplyPreviewRules(options) {
|
|
89
|
-
const
|
|
90
|
-
for (const capability of options.
|
|
89
|
+
const tools = new Map();
|
|
90
|
+
for (const capability of options.tools) {
|
|
91
91
|
const id = capability.id;
|
|
92
|
-
breakWhile(!id ||
|
|
92
|
+
breakWhile(!id || tools.has(id), 'Duplicate preview capability declaration');
|
|
93
93
|
const preview = previewSnapshot(capability.preview);
|
|
94
94
|
// Validate and emit the same canonical snapshot, never reread App getters.
|
|
95
95
|
const jsonSchema = preview ? structuredClone(capability.jsonSchema) : {};
|
|
96
|
-
|
|
96
|
+
tools.set(id, { id, preview, jsonSchema });
|
|
97
97
|
}
|
|
98
98
|
const stages = new Set(), rules = [];
|
|
99
99
|
for (const stage of options.stages) {
|
|
100
|
-
const { id: stageId, preview,
|
|
100
|
+
const { id: stageId, preview, toolIds } = stage;
|
|
101
101
|
breakWhile(!stageId || stages.has(stageId), 'Duplicate preview stage declaration');
|
|
102
102
|
stages.add(stageId);
|
|
103
|
-
const ids =
|
|
104
|
-
breakWhile(new Set(ids).size !== ids.length || ids.some((id) => !
|
|
105
|
-
breakWhile(preview !== undefined && !['text', '
|
|
103
|
+
const ids = toolIds === undefined ? [] : stringList(toolIds, 'capability IDs');
|
|
104
|
+
breakWhile(new Set(ids).size !== ids.length || ids.some((id) => !tools.has(id)), 'Preview stage references an unknown capability');
|
|
105
|
+
breakWhile(preview !== undefined && !['text', 'tools'].includes(preview), 'Unknown preview stage mode');
|
|
106
106
|
if (!preview)
|
|
107
107
|
continue;
|
|
108
108
|
if (preview === 'text') {
|
|
@@ -111,7 +111,7 @@ export function createReplyPreviewRules(options) {
|
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
113
|
for (const id of ids) {
|
|
114
|
-
const capability =
|
|
114
|
+
const capability = tools.get(id);
|
|
115
115
|
if (!capability.preview)
|
|
116
116
|
continue;
|
|
117
117
|
const source = capability.preview === true ? {} : capability.preview;
|
|
@@ -127,7 +127,7 @@ export function createReplyPreviewRules(options) {
|
|
|
127
127
|
Object.freeze({ path: Object.freeze(when.path), values: Object.freeze(when.values) });
|
|
128
128
|
rules.push(Object.freeze({
|
|
129
129
|
stageId,
|
|
130
|
-
|
|
130
|
+
toolId: wireName(id),
|
|
131
131
|
paths: emittedPaths,
|
|
132
132
|
...(emittedWhen ? { when: emittedWhen } : {}),
|
|
133
133
|
}));
|
|
@@ -2,11 +2,11 @@ import type { ModelOutputEvent } from '../../structs/model/runtime.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* One projection rule: which stage/capability it matches and which prose fields may be shown.
|
|
4
4
|
*
|
|
5
|
-
* A rule without `
|
|
5
|
+
* A rule without `toolId` may only match a registered plain-text stage.
|
|
6
6
|
*/
|
|
7
7
|
export interface ReplyPreviewRule {
|
|
8
8
|
/** Native function wire name. Omit only for a registered plain-text stage. */
|
|
9
|
-
|
|
9
|
+
toolId?: string;
|
|
10
10
|
/** Restrict the rule to one stage; omitted matches any stage producing this capability. */
|
|
11
11
|
stageId?: string;
|
|
12
12
|
/** JSON paths to project, where `*` matches any array index; defaults to text/bubble paths. */
|
|
@@ -196,7 +196,7 @@ export function createReplyPreview(options) {
|
|
|
196
196
|
if (!Number.isSafeInteger(maxChars) || maxChars < 1)
|
|
197
197
|
throw new TypeError('Invalid reply preview budget');
|
|
198
198
|
const rules = options.rules.map((rule) => Object.freeze({
|
|
199
|
-
|
|
199
|
+
toolId: rule.toolId,
|
|
200
200
|
stageId: rule.stageId,
|
|
201
201
|
paths: rule.paths === undefined ? undefined : structuredClone(rule.paths),
|
|
202
202
|
when: rule.when === undefined ? undefined : structuredClone(rule.when),
|
|
@@ -258,7 +258,7 @@ export function createReplyPreview(options) {
|
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
260
|
if (typeof part === 'string') {
|
|
261
|
-
const rule = rules.find((rule) => !rule.
|
|
261
|
+
const rule = rules.find((rule) => !rule.toolId && rule.stageId === event.payload.stageId);
|
|
262
262
|
if (!rule) {
|
|
263
263
|
if (part.trim()) {
|
|
264
264
|
disabled = true;
|
|
@@ -276,7 +276,7 @@ export function createReplyPreview(options) {
|
|
|
276
276
|
return;
|
|
277
277
|
}
|
|
278
278
|
name += part.name ?? '';
|
|
279
|
-
const rule = rules.find((rule) => rule.
|
|
279
|
+
const rule = rules.find((rule) => rule.toolId === name && (!rule.stageId || rule.stageId === event.payload.stageId));
|
|
280
280
|
if (!rule) {
|
|
281
281
|
if (selected) {
|
|
282
282
|
disabled = true;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ModelToolSource, RegisteredModelTool } from '../../structs/capabilities/model.js';
|
|
2
|
+
import type { ModelResponseCollector } from '../../structs/model/interactions.js';
|
|
3
|
+
import type { ModelOptions } from '../../structs/model/messages.js';
|
|
4
|
+
import type { ModelTransportDefinition } from '../../structs/model/runtime.js';
|
|
5
|
+
import type { ModelSessionCall, ModelSessionResult } from '../../structs/model/session.js';
|
|
6
|
+
/** One completed call with host-facing resolution; unknown tools and bad JSON stay non-fatal. */
|
|
7
|
+
export interface ResolvedSessionCall extends ModelSessionCall {
|
|
8
|
+
/** Registered tool id, absent when the name is unknown to this stage. */
|
|
9
|
+
readonly toolId?: string;
|
|
10
|
+
/** Parsed arguments, absent when parsing failed or the tool is unknown. */
|
|
11
|
+
readonly input?: Record<string, unknown>;
|
|
12
|
+
/** Non-fatal problem the workflow should turn into a tool error message. */
|
|
13
|
+
readonly problem?: 'unknown-tool' | 'invalid-arguments';
|
|
14
|
+
}
|
|
15
|
+
/** Complete result of one session response after host-facing resolution. */
|
|
16
|
+
export interface ResolvedSessionResult extends Omit<ModelSessionResult, 'calls'> {
|
|
17
|
+
readonly calls: readonly ResolvedSessionCall[];
|
|
18
|
+
}
|
|
19
|
+
/** Prepared session transport handed to the runner. */
|
|
20
|
+
export interface PreparedSessionTransport {
|
|
21
|
+
readonly options: Pick<ModelOptions, 'functions' | 'json' | 'temperature' | 'toolChoice' | 'parallelToolCalls'>;
|
|
22
|
+
readonly schemaChars: number;
|
|
23
|
+
readonly instruction: string;
|
|
24
|
+
createResponse(): ModelResponseCollector<ResolvedSessionResult>;
|
|
25
|
+
}
|
|
26
|
+
/** Options a session transport may pass through to provider options. */
|
|
27
|
+
export interface SessionFunctionOptions {
|
|
28
|
+
readonly temperature?: number;
|
|
29
|
+
readonly toolChoice?: 'auto' | 'required' | 'none';
|
|
30
|
+
readonly parallelToolCalls?: boolean | 'omit';
|
|
31
|
+
}
|
|
32
|
+
/** Registration for one session transport. */
|
|
33
|
+
export interface SessionModelTransportRegistration {
|
|
34
|
+
/** Transport id used by call requests and diagnostics. */
|
|
35
|
+
readonly id: string;
|
|
36
|
+
/** Tools advertised to the model for this stage. */
|
|
37
|
+
readonly tools: ModelToolSource;
|
|
38
|
+
/** Sampling and tool-selection settings. */
|
|
39
|
+
readonly options?: SessionFunctionOptions;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Build the session policy for one stage.
|
|
43
|
+
*
|
|
44
|
+
* @param tools - Registered tools available in this stage; must be non-empty.
|
|
45
|
+
* @param options - Sampling and tool-selection settings.
|
|
46
|
+
* @returns A prepared transport whose collector returns text and every completed call.
|
|
47
|
+
* @throws TypeError When the tool list is empty or two ids collide on the wire name.
|
|
48
|
+
*/
|
|
49
|
+
export declare function prepareSessionFunctions(tools: readonly RegisteredModelTool[], options?: SessionFunctionOptions): PreparedSessionTransport;
|
|
50
|
+
/**
|
|
51
|
+
* Create a session transport.
|
|
52
|
+
*
|
|
53
|
+
* @param registration - Transport id, tool source and optional settings.
|
|
54
|
+
* @returns A frozen transport definition whose result contains text and every completed call.
|
|
55
|
+
* @throws TypeError When the id is blank.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createSessionModelTransport<const Id extends string>(registration: SessionModelTransportRegistration & {
|
|
58
|
+
readonly id: Id;
|
|
59
|
+
}): ModelTransportDefinition<ResolvedSessionResult> & {
|
|
60
|
+
readonly id: Id;
|
|
61
|
+
};
|