@superdurable/dex-agents 0.4.0 → 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/README.md +506 -52
- package/dist/src/agent-context-compaction.d.ts +1 -1
- package/dist/src/agent-framework-runner.d.ts +122 -11
- package/dist/src/agent-framework-runner.js +4 -0
- package/dist/src/agent-framework-runner.js.map +1 -1
- package/dist/src/agent-local-directory-media-store.d.ts +111 -0
- package/dist/src/agent-local-directory-media-store.js +417 -0
- package/dist/src/agent-local-directory-media-store.js.map +1 -0
- package/dist/src/agent-media.d.ts +279 -0
- package/dist/src/agent-media.js +457 -0
- package/dist/src/agent-media.js.map +1 -0
- package/dist/src/agent-session-codecs.d.ts +3 -1
- package/dist/src/agent-session-codecs.js +45 -4
- package/dist/src/agent-session-codecs.js.map +1 -1
- package/dist/src/agent-session-failure.d.ts +4 -2
- package/dist/src/agent-session-failure.js +6 -2
- package/dist/src/agent-session-failure.js.map +1 -1
- package/dist/src/agent-session-flow-graph.d.ts +46 -0
- package/dist/src/agent-session-flow-graph.js +51 -0
- package/dist/src/agent-session-flow-graph.js.map +1 -1
- package/dist/src/agent-session-flow.d.ts +5 -3
- package/dist/src/agent-session-flow.js +10 -1
- package/dist/src/agent-session-flow.js.map +1 -1
- package/dist/src/agent-session-start.d.ts +1 -1
- package/dist/src/agent-session-start.js +2 -2
- package/dist/src/agent-session-start.js.map +1 -1
- package/dist/src/agent-session-steps.d.ts +2 -0
- package/dist/src/agent-session-steps.js +52 -3
- package/dist/src/agent-session-steps.js.map +1 -1
- package/dist/src/agent-session-tracer.js +1 -1
- package/dist/src/agent-session-tracer.js.map +1 -1
- package/dist/src/agent-session-transitions.d.ts +2 -0
- package/dist/src/agent-session-transitions.js +21 -1
- package/dist/src/agent-session-transitions.js.map +1 -1
- package/dist/src/agent-session-values.d.ts +76 -1
- package/dist/src/agent-session-values.js.map +1 -1
- package/dist/src/agent-session-wait-steps.js +14 -2
- package/dist/src/agent-session-wait-steps.js.map +1 -1
- package/dist/src/ai-sdk/ai-sdk-model-client.d.ts +15 -3
- package/dist/src/ai-sdk/ai-sdk-model-client.js +36 -7
- package/dist/src/ai-sdk/ai-sdk-model-client.js.map +1 -1
- package/dist/src/ai-sdk/index.d.ts +1 -1
- package/dist/src/ai-sdk/index.js +1 -1
- package/dist/src/ai-sdk/index.js.map +1 -1
- package/dist/src/{stepwise → builtin-loop}/agent-definition.d.ts +120 -5
- package/dist/src/builtin-loop/agent-definition.js.map +1 -0
- package/dist/src/builtin-loop/builtin-agent-session-flow.d.ts +69 -0
- package/dist/src/{stepwise/stepwise-agent-session-flow.js → builtin-loop/builtin-agent-session-flow.js} +15 -9
- package/dist/src/builtin-loop/builtin-agent-session-flow.js.map +1 -0
- package/dist/src/{stepwise/stepwise-agent-runner.d.ts → builtin-loop/builtin-loop-agent-runner.d.ts} +72 -14
- package/dist/src/{stepwise/stepwise-agent-runner.js → builtin-loop/builtin-loop-agent-runner.js} +284 -41
- package/dist/src/builtin-loop/builtin-loop-agent-runner.js.map +1 -0
- package/dist/src/{stepwise/stepwise-input-items.d.ts → builtin-loop/builtin-loop-input-items.d.ts} +7 -3
- package/dist/src/{stepwise/stepwise-input-items.js → builtin-loop/builtin-loop-input-items.js} +57 -10
- package/dist/src/builtin-loop/builtin-loop-input-items.js.map +1 -0
- package/dist/src/builtin-loop/function-tool.d.ts +282 -0
- package/dist/src/{stepwise → builtin-loop}/function-tool.js +63 -3
- package/dist/src/builtin-loop/function-tool.js.map +1 -0
- package/dist/src/builtin-loop/index.d.ts +8 -0
- package/dist/src/builtin-loop/index.js +13 -0
- package/dist/src/builtin-loop/index.js.map +1 -0
- package/dist/src/builtin-loop/json-schema-validation.js.map +1 -0
- package/dist/src/{stepwise → builtin-loop}/model-client.d.ts +36 -7
- package/dist/src/builtin-loop/model-client.js.map +1 -0
- package/dist/src/{stepwise → builtin-loop}/scripted-model-client.d.ts +8 -5
- package/dist/src/{stepwise → builtin-loop}/scripted-model-client.js +8 -5
- package/dist/src/builtin-loop/scripted-model-client.js.map +1 -0
- package/dist/src/{stepwise → builtin-loop}/tool-source.d.ts +2 -2
- package/dist/src/builtin-loop/tool-source.js.map +1 -0
- package/dist/src/connectors/connector-input-schema.js +1 -1
- package/dist/src/connectors/connector-input-schema.js.map +1 -1
- package/dist/src/connectors/connector-step-context.d.ts +19 -2
- package/dist/src/connectors/connector-step-context.js +61 -5
- package/dist/src/connectors/connector-step-context.js.map +1 -1
- package/dist/src/connectors/connector-tool-source.d.ts +61 -13
- package/dist/src/connectors/connector-tool-source.js +111 -24
- package/dist/src/connectors/connector-tool-source.js.map +1 -1
- package/dist/src/index.d.ts +6 -4
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/index.d.ts +1 -0
- package/dist/src/mcp/index.js +1 -0
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/mcp-dex-conventions.d.ts +57 -0
- package/dist/src/mcp/mcp-dex-conventions.js +90 -0
- package/dist/src/mcp/mcp-dex-conventions.js.map +1 -0
- package/dist/src/mcp/mcp-image-content.d.ts +20 -0
- package/dist/src/mcp/mcp-image-content.js +82 -0
- package/dist/src/mcp/mcp-image-content.js.map +1 -0
- package/dist/src/mcp/mcp-tool-source.d.ts +178 -17
- package/dist/src/mcp/mcp-tool-source.js +237 -34
- package/dist/src/mcp/mcp-tool-source.js.map +1 -1
- package/dist/src/s3/index.d.ts +1 -0
- package/dist/src/s3/index.js +9 -0
- package/dist/src/s3/index.js.map +1 -0
- package/dist/src/s3/s3-media-store.d.ts +138 -0
- package/dist/src/s3/s3-media-store.js +255 -0
- package/dist/src/s3/s3-media-store.js.map +1 -0
- package/dist/src/stepwise/index.d.ts +41 -8
- package/dist/src/stepwise/index.js +35 -5
- package/dist/src/stepwise/index.js.map +1 -1
- package/dist/src/testing/agent-session-test-client.d.ts +6 -3
- package/dist/src/testing/agent-session-test-client.js +10 -3
- package/dist/src/testing/agent-session-test-client.js.map +1 -1
- package/dist/src/testing/scripted-model-client.d.ts +1 -1
- package/dist/src/testing/scripted-model-client.js +2 -2
- package/dist/src/testing/scripted-model-client.js.map +1 -1
- package/dist/src/tool-source-router.d.ts +3 -3
- package/dist/src/tool-source-router.js +2 -2
- package/dist/src/ui-stream/agent-event-json.d.ts +2 -1
- package/dist/src/ui-stream/agent-event-json.js +3 -1
- package/dist/src/ui-stream/agent-event-json.js.map +1 -1
- package/dist/src/ui-stream/agent-ui-messages.d.ts +11 -3
- package/dist/src/ui-stream/agent-ui-messages.js +29 -5
- package/dist/src/ui-stream/agent-ui-messages.js.map +1 -1
- package/package.json +16 -3
- package/dist/src/stepwise/agent-definition.js.map +0 -1
- package/dist/src/stepwise/function-tool.d.ts +0 -130
- package/dist/src/stepwise/function-tool.js.map +0 -1
- package/dist/src/stepwise/json-schema-validation.js.map +0 -1
- package/dist/src/stepwise/model-client.js.map +0 -1
- package/dist/src/stepwise/scripted-model-client.js.map +0 -1
- package/dist/src/stepwise/stepwise-agent-runner.js.map +0 -1
- package/dist/src/stepwise/stepwise-agent-session-flow.d.ts +0 -35
- package/dist/src/stepwise/stepwise-agent-session-flow.js.map +0 -1
- package/dist/src/stepwise/stepwise-input-items.js.map +0 -1
- package/dist/src/stepwise/tool-source.js.map +0 -1
- /package/dist/src/{stepwise → builtin-loop}/agent-definition.js +0 -0
- /package/dist/src/{stepwise → builtin-loop}/json-schema-validation.d.ts +0 -0
- /package/dist/src/{stepwise → builtin-loop}/json-schema-validation.js +0 -0
- /package/dist/src/{stepwise → builtin-loop}/model-client.js +0 -0
- /package/dist/src/{stepwise → builtin-loop}/tool-source.js +0 -0
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Deprecated alias of `@superdurable/dex-agents/builtin-loop`, the built-in agent loop.
|
|
3
|
+
*
|
|
4
|
+
* Every name it exported still works and refers to the same value. Two names changed:
|
|
5
|
+
* `StepwiseAgentRunner` is `BuiltinLoopAgentRunner`, and `createStepwiseAgentSessionFlow` is
|
|
6
|
+
* `createBuiltinAgentSessionFlow`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // Before
|
|
11
|
+
* import { createStepwiseAgentSessionFlow } from "@superdurable/dex-agents/stepwise";
|
|
12
|
+
* // After
|
|
13
|
+
* import { createBuiltinAgentSessionFlow } from "@superdurable/dex-agents/builtin-loop";
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @deprecated Since 0.5.0. Import from `@superdurable/dex-agents/builtin-loop` instead.
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import { createBuiltinAgentSessionFlow } from "../builtin-loop/builtin-agent-session-flow.js";
|
|
20
|
+
import { BuiltinLoopAgentRunner } from "../builtin-loop/builtin-loop-agent-runner.js";
|
|
21
|
+
export * from "../builtin-loop/index.js";
|
|
22
|
+
/**
|
|
23
|
+
* The {@link BuiltinLoopAgentRunner} under its old name.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Since 0.5.0. Use `BuiltinLoopAgentRunner` from `@superdurable/dex-agents/builtin-loop`; it is the
|
|
26
|
+
* same class.
|
|
27
|
+
*/
|
|
28
|
+
export declare const StepwiseAgentRunner: typeof BuiltinLoopAgentRunner;
|
|
29
|
+
/**
|
|
30
|
+
* The {@link BuiltinLoopAgentRunner} type under its old name.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Since 0.5.0. Use `BuiltinLoopAgentRunner` from `@superdurable/dex-agents/builtin-loop`.
|
|
33
|
+
*/
|
|
34
|
+
export type StepwiseAgentRunner = BuiltinLoopAgentRunner;
|
|
35
|
+
/**
|
|
36
|
+
* {@link createBuiltinAgentSessionFlow} under its old name.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Since 0.5.0. Use `createBuiltinAgentSessionFlow` from `@superdurable/dex-agents/builtin-loop`; it
|
|
39
|
+
* is the same function.
|
|
40
|
+
*/
|
|
41
|
+
export declare const createStepwiseAgentSessionFlow: typeof createBuiltinAgentSessionFlow;
|
|
@@ -5,9 +5,39 @@
|
|
|
5
5
|
// See the LICENSE file in the repository root.
|
|
6
6
|
//
|
|
7
7
|
// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Deprecated alias of `@superdurable/dex-agents/builtin-loop`, the built-in agent loop.
|
|
10
|
+
*
|
|
11
|
+
* Every name it exported still works and refers to the same value. Two names changed:
|
|
12
|
+
* `StepwiseAgentRunner` is `BuiltinLoopAgentRunner`, and `createStepwiseAgentSessionFlow` is
|
|
13
|
+
* `createBuiltinAgentSessionFlow`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // Before
|
|
18
|
+
* import { createStepwiseAgentSessionFlow } from "@superdurable/dex-agents/stepwise";
|
|
19
|
+
* // After
|
|
20
|
+
* import { createBuiltinAgentSessionFlow } from "@superdurable/dex-agents/builtin-loop";
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @deprecated Since 0.5.0. Import from `@superdurable/dex-agents/builtin-loop` instead.
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
import { createBuiltinAgentSessionFlow } from "../builtin-loop/builtin-agent-session-flow.js";
|
|
27
|
+
import { BuiltinLoopAgentRunner } from "../builtin-loop/builtin-loop-agent-runner.js";
|
|
28
|
+
export * from "../builtin-loop/index.js";
|
|
29
|
+
/**
|
|
30
|
+
* The {@link BuiltinLoopAgentRunner} under its old name.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Since 0.5.0. Use `BuiltinLoopAgentRunner` from `@superdurable/dex-agents/builtin-loop`; it is the
|
|
33
|
+
* same class.
|
|
34
|
+
*/
|
|
35
|
+
export const StepwiseAgentRunner = BuiltinLoopAgentRunner;
|
|
36
|
+
/**
|
|
37
|
+
* {@link createBuiltinAgentSessionFlow} under its old name.
|
|
38
|
+
*
|
|
39
|
+
* @deprecated Since 0.5.0. Use `createBuiltinAgentSessionFlow` from `@superdurable/dex-agents/builtin-loop`; it
|
|
40
|
+
* is the same function.
|
|
41
|
+
*/
|
|
42
|
+
export const createStepwiseAgentSessionFlow = createBuiltinAgentSessionFlow;
|
|
13
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stepwise/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stepwise/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAEtF,cAAc,0BAA0B,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAS1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,6BAA6B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Client, type StartFlowOptions } from "@superdurable/dex";
|
|
2
2
|
import type { AgentFrameworkRunner, DeferredToolOutcome } from "../agent-framework-runner.js";
|
|
3
3
|
import type { AgentSessionFlow } from "../agent-session-flow.js";
|
|
4
|
-
import type { AgentEvent, AgentInterrupt, AgentMessagesPage, AgentSnapshot, AgentState, AgentToolCallRecord, SessionSettings } from "../agent-session-values.js";
|
|
4
|
+
import type { AgentEvent, AgentImageReference, AgentInterrupt, AgentMessagesPage, AgentSnapshot, AgentState, AgentToolCallRecord, SessionSettings } from "../agent-session-values.js";
|
|
5
5
|
/** Options of the `waitFor*` methods of {@link AgentSessionTestClient}. */
|
|
6
6
|
export interface AgentSessionWaitOptions {
|
|
7
7
|
/** Total milliseconds to wait. Defaults to 60,000. */
|
|
@@ -60,9 +60,12 @@ export declare class AgentSessionTestClient {
|
|
|
60
60
|
* @param sessionId - Session Flow ID.
|
|
61
61
|
* @param text - Message text.
|
|
62
62
|
* @param planMode - Whether the message starts a planning turn. Defaults to `false`.
|
|
63
|
-
* @
|
|
63
|
+
* @param images - Images of the message, uploaded first; none by default. The client does not check them, so a
|
|
64
|
+
* test can send references that the session refuses. Since 0.5.0.
|
|
65
|
+
* @returns The RPC result: `false` for blank text, for a `planMode` message when plan mode is off, or for images
|
|
66
|
+
* that the session refuses.
|
|
64
67
|
*/
|
|
65
|
-
sendUserMessage(sessionId: string, text: string, planMode?: boolean): Promise<boolean>;
|
|
68
|
+
sendUserMessage(sessionId: string, text: string, planMode?: boolean, images?: readonly AgentImageReference[]): Promise<boolean>;
|
|
66
69
|
/**
|
|
67
70
|
* Calls `execute_plan`, retrying an `RpcLockConflictError` for up to 30 seconds.
|
|
68
71
|
* @param sessionId - Session Flow ID.
|
|
@@ -70,10 +70,17 @@ export class AgentSessionTestClient {
|
|
|
70
70
|
* @param sessionId - Session Flow ID.
|
|
71
71
|
* @param text - Message text.
|
|
72
72
|
* @param planMode - Whether the message starts a planning turn. Defaults to `false`.
|
|
73
|
-
* @
|
|
73
|
+
* @param images - Images of the message, uploaded first; none by default. The client does not check them, so a
|
|
74
|
+
* test can send references that the session refuses. Since 0.5.0.
|
|
75
|
+
* @returns The RPC result: `false` for blank text, for a `planMode` message when plan mode is off, or for images
|
|
76
|
+
* that the session refuses.
|
|
74
77
|
*/
|
|
75
|
-
sendUserMessage(sessionId, text, planMode = false) {
|
|
76
|
-
return this.client.invokeRPC(this.flow.sendUserMessage, sessionId, {
|
|
78
|
+
sendUserMessage(sessionId, text, planMode = false, images = []) {
|
|
79
|
+
return this.client.invokeRPC(this.flow.sendUserMessage, sessionId, {
|
|
80
|
+
text,
|
|
81
|
+
planMode,
|
|
82
|
+
...(images.length > 0 ? { images } : {}),
|
|
83
|
+
});
|
|
77
84
|
}
|
|
78
85
|
/**
|
|
79
86
|
* Calls `execute_plan`, retrying an `RpcLockConflictError` for up to 30 seconds.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-test-client.js","sourceRoot":"","sources":["../../../src/testing/agent-session-test-client.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAsC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-test-client.js","sourceRoot":"","sources":["../../../src/testing/agent-session-test-client.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAsC,MAAM,mBAAmB,CAAC;AAe7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAC1C,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,cAAc,GAAG,GAAG,CAAC;AAQ3B;;;;;;;;;;;;;;;G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,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACnE,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC;QACjC,CAAC,QAAQ,SAAS,KAAK,EAAE,EAAE;QAC3B,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;CACF;AAED,KAAK,UAAU,kBAAkB,CAAC,MAA8B;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,0BAA0B,CAAC;IACzD,SAAS,CAAC;QACR,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,CAAC,CAAC,KAAK,YAAY,oBAAoB,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;gBACvE,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,MAAM,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ScriptedModelClient, scriptedModelApi, scriptedModelProvider, type ScriptedModelReply, type ScriptedModelResponder, type ScriptedToolCall, } from "../
|
|
1
|
+
export { ScriptedModelClient, scriptedModelApi, scriptedModelProvider, type ScriptedModelReply, type ScriptedModelResponder, type ScriptedToolCall, } from "../builtin-loop/scripted-model-client.js";
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
// See the LICENSE file in the repository root.
|
|
6
6
|
//
|
|
7
7
|
// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
-
// The scripted model client lives in the
|
|
9
|
-
export { ScriptedModelClient, scriptedModelApi, scriptedModelProvider, } from "../
|
|
8
|
+
// The scripted model client lives in the builtin-loop entry point; this path keeps the 0.1.0 module.
|
|
9
|
+
export { ScriptedModelClient, scriptedModelApi, scriptedModelProvider, } from "../builtin-loop/scripted-model-client.js";
|
|
10
10
|
//# sourceMappingURL=scripted-model-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripted-model-client.js","sourceRoot":"","sources":["../../../src/testing/scripted-model-client.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAG1D,
|
|
1
|
+
{"version":3,"file":"scripted-model-client.js","sourceRoot":"","sources":["../../../src/testing/scripted-model-client.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAG1D,qGAAqG;AACrG,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,GAItB,MAAM,0CAA0C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentTurnContext, type DeferredToolCall, type DeferredToolExecution, type DeferredToolOutcome, type ToolCallStepOptions, type ToolExecutionResult, type ToolTaskCancellation, type ToolTaskPoll, type ToolTaskPollOutcome } from "./agent-framework-runner.js";
|
|
2
2
|
import type { AgentToolCall } from "./agent-session-values.js";
|
|
3
|
-
import type { SourceToolDefinition, ToolSource } from "./
|
|
3
|
+
import type { SourceToolDefinition, ToolSource } from "./builtin-loop/tool-source.js";
|
|
4
4
|
/**
|
|
5
5
|
* Default `AgentDefinition.toolSourceListingTimeoutMs`: 10 seconds. It is also the default time one model call of a
|
|
6
6
|
* framework adapter waits for each tool source's listing. Exported from the package root since 0.4.0.
|
|
@@ -42,7 +42,7 @@ export interface ToolSourceRouterOptions {
|
|
|
42
42
|
readonly listingTimeoutMs?: number;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Serves {@link ToolSource}s from a framework runner, so their calls run in tool Steps as the
|
|
45
|
+
* Serves {@link ToolSource}s from a framework runner, so their calls run in tool Steps as the built-in loop runner runs
|
|
46
46
|
* them.
|
|
47
47
|
*
|
|
48
48
|
* A framework adapter that implements {@link AgentFrameworkRunner} builds one router from its `toolSources`. In each
|
|
@@ -53,7 +53,7 @@ export interface ToolSourceRouterOptions {
|
|
|
53
53
|
* {@link executeDeferredToolCall} on any Worker, with the full execution: the Step context, the heartbeat
|
|
54
54
|
* checkpoint, and the attempt. {@link toolCallStepOptions}, {@link pollToolTask}, and {@link cancelToolTask} route
|
|
55
55
|
* the same way. A runner whose `executeDeferredToolCall` returns only results, and so polls no tool tasks, uses
|
|
56
|
-
* {@link executeDeferredToolCallForResult} instead. `
|
|
56
|
+
* {@link executeDeferredToolCallForResult} instead. `BuiltinLoopAgentRunner` uses a router too.
|
|
57
57
|
*
|
|
58
58
|
* Construction refuses a source without a {@link ToolSource} method or a non-blank, unique `sourceName`, and a
|
|
59
59
|
* name that a source declares through `declaredToolNames` when it repeats a local tool, a built-in tool, or another
|
|
@@ -14,7 +14,7 @@ export const defaultToolSourceListingTimeoutMs = 10_000;
|
|
|
14
14
|
const toolSourceMethods = ["listTools", "deferredToolCall", "executeDeferredToolCall", "pollToolTask"];
|
|
15
15
|
const toolSourceReferenceKey = "reference";
|
|
16
16
|
/**
|
|
17
|
-
* Serves {@link ToolSource}s from a framework runner, so their calls run in tool Steps as the
|
|
17
|
+
* Serves {@link ToolSource}s from a framework runner, so their calls run in tool Steps as the built-in loop runner runs
|
|
18
18
|
* them.
|
|
19
19
|
*
|
|
20
20
|
* A framework adapter that implements {@link AgentFrameworkRunner} builds one router from its `toolSources`. In each
|
|
@@ -25,7 +25,7 @@ const toolSourceReferenceKey = "reference";
|
|
|
25
25
|
* {@link executeDeferredToolCall} on any Worker, with the full execution: the Step context, the heartbeat
|
|
26
26
|
* checkpoint, and the attempt. {@link toolCallStepOptions}, {@link pollToolTask}, and {@link cancelToolTask} route
|
|
27
27
|
* the same way. A runner whose `executeDeferredToolCall` returns only results, and so polls no tool tasks, uses
|
|
28
|
-
* {@link executeDeferredToolCallForResult} instead. `
|
|
28
|
+
* {@link executeDeferredToolCallForResult} instead. `BuiltinLoopAgentRunner` uses a router too.
|
|
29
29
|
*
|
|
30
30
|
* Construction refuses a source without a {@link ToolSource} method or a non-blank, unique `sourceName`, and a
|
|
31
31
|
* name that a source declares through `declaredToolNames` when it repeats a local tool, a built-in tool, or another
|
|
@@ -18,7 +18,8 @@ export declare function convertAgentEventToJson(event: AgentEvent): AgentEventJs
|
|
|
18
18
|
* Use it when a browser shared with Python backends reads the snapshot. It is the `get_agent_snapshot` wire
|
|
19
19
|
* format without the fields only the session's Steps use. Messages leave out `framework_item`, the
|
|
20
20
|
* framework's replay data, which can hold the agent's instructions. Tool calls leave out
|
|
21
|
-
* `tool_source_reference`, `trace_context`, `input_continuation`, `input_answers`,
|
|
21
|
+
* `tool_source_reference`, `trace_context`, `input_continuation`, `input_answers`, `task_answer_pending`, and
|
|
22
|
+
* `runner_tool_state`.
|
|
22
23
|
*
|
|
23
24
|
* `session_settings` is included as stored, so the browser sees the settings the next turn starts with. Keep
|
|
24
25
|
* anything a browser must not see out of session settings, or remove the key before serving the JSON.
|
|
@@ -34,6 +34,7 @@ const workerOnlyToolCallFieldNames = new Set([
|
|
|
34
34
|
"input_continuation",
|
|
35
35
|
"input_answers",
|
|
36
36
|
"task_answer_pending",
|
|
37
|
+
"runner_tool_state",
|
|
37
38
|
]);
|
|
38
39
|
/**
|
|
39
40
|
* Converts an `AgentSnapshot` to the snake_case JSON a browser reads, the same JSON the Python core produces.
|
|
@@ -41,7 +42,8 @@ const workerOnlyToolCallFieldNames = new Set([
|
|
|
41
42
|
* Use it when a browser shared with Python backends reads the snapshot. It is the `get_agent_snapshot` wire
|
|
42
43
|
* format without the fields only the session's Steps use. Messages leave out `framework_item`, the
|
|
43
44
|
* framework's replay data, which can hold the agent's instructions. Tool calls leave out
|
|
44
|
-
* `tool_source_reference`, `trace_context`, `input_continuation`, `input_answers`,
|
|
45
|
+
* `tool_source_reference`, `trace_context`, `input_continuation`, `input_answers`, `task_answer_pending`, and
|
|
46
|
+
* `runner_tool_state`.
|
|
45
47
|
*
|
|
46
48
|
* `session_settings` is included as stored, so the browser sees the settings the next turn starts with. Keep
|
|
47
49
|
* anything a browser must not see out of session settings, or remove the key before serving the JSON.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-event-json.js","sourceRoot":"","sources":["../../../src/ui-stream/agent-event-json.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAiB;IACvD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,MAAM;QACrB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,iBAAiB,EAAE,KAAK,CAAC,eAAe;QACxC,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACrF,MAAM,4BAA4B,GAAwB,IAAI,GAAG,CAAC;IAChE,uBAAuB;IACvB,eAAe;IACf,oBAAoB;IACpB,eAAe;IACf,qBAAqB;
|
|
1
|
+
{"version":3,"file":"agent-event-json.js","sourceRoot":"","sources":["../../../src/ui-stream/agent-event-json.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAiB;IACvD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,MAAM;QACrB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,iBAAiB,EAAE,KAAK,CAAC,eAAe;QACxC,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACrF,MAAM,4BAA4B,GAAwB,IAAI,GAAG,CAAC;IAChE,uBAAuB;IACvB,eAAe;IACf,oBAAoB;IACpB,eAAe;IACf,qBAAqB;IACrB,mBAAmB;CACpB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAAuB;IAChE,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAA4B,CAAC;IAC9E,OAAO;QACL,GAAG,YAAY;QACf,QAAQ,EAAG,YAAY,CAAC,UAAU,CAA+B,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAChF,cAAc,CAAC,OAAO,EAAE,2BAA2B,CAAC,CACrD;QACD,UAAU,EAAG,YAAY,CAAC,YAAY,CAA+B,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACrF,cAAc,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CACvD;KACF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CACrB,KAA8B,EAC9B,UAA+B;IAE/B,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACvG,CAAC"}
|
|
@@ -23,11 +23,19 @@ export interface AgentSessionUIMessages {
|
|
|
23
23
|
* assistant and tool messages of one turn become one assistant message with ID
|
|
24
24
|
* {@link agentAssistantUIMessageId}: a `step-start` part before each model call, a text part per model
|
|
25
25
|
* text, and a dynamic tool part per tool call. A stored tool result shows the text the model saw, so a
|
|
26
|
-
* failed or rejected call appears as `output-available` with that text. A turn-failure
|
|
27
|
-
* user message and appears as
|
|
26
|
+
* failed or rejected call appears as `output-available` with that text. A turn-failure, steered, or cancelled
|
|
27
|
+
* note is the last stored user message of a turn that has ended, and it appears as a user message. Any other user
|
|
28
|
+
* message after the turn's first model output, such as the message of a built-in loop continuation, is not shown;
|
|
29
|
+
* it starts the step of the next model call, also while that call is still running, as the UI stream does.
|
|
30
|
+
* Changed in 0.5.0: such a message no longer appears as a user message that splits the turn.
|
|
31
|
+
*
|
|
32
|
+
* The UI stream starts a step for every `RunModel` Step, and this function one for every model call. They differ
|
|
33
|
+
* only where a `RunModel` makes no model call, such as when `decideTurnContinuation` ends a turn after its tools:
|
|
34
|
+
* the stream then sends one more `start-step` and `finish-step` with no visible part, which leaves no part in the
|
|
35
|
+
* AI SDK message, so the message still matches the converted snapshot.
|
|
28
36
|
*
|
|
29
37
|
* The session stores a turn's messages when the turn ends, or after each model call for a runner such as
|
|
30
|
-
* the
|
|
38
|
+
* the built-in loop runner. For the active turn the function shows each tool call of `snapshot.toolCalls` once in
|
|
31
39
|
* the turn's assistant message: a stored call without a result takes the record's state, and a call not
|
|
32
40
|
* stored yet is added. Approvals waiting for `resolve_interrupt` are `approval-requested`, running calls
|
|
33
41
|
* are `input-available` or `approval-responded`, and finished calls show their result. The active turn's
|
|
@@ -17,11 +17,19 @@ import { encodeAgentUIStreamCursor } from "./agent-ui-stream-cursor.js";
|
|
|
17
17
|
* assistant and tool messages of one turn become one assistant message with ID
|
|
18
18
|
* {@link agentAssistantUIMessageId}: a `step-start` part before each model call, a text part per model
|
|
19
19
|
* text, and a dynamic tool part per tool call. A stored tool result shows the text the model saw, so a
|
|
20
|
-
* failed or rejected call appears as `output-available` with that text. A turn-failure
|
|
21
|
-
* user message and appears as
|
|
20
|
+
* failed or rejected call appears as `output-available` with that text. A turn-failure, steered, or cancelled
|
|
21
|
+
* note is the last stored user message of a turn that has ended, and it appears as a user message. Any other user
|
|
22
|
+
* message after the turn's first model output, such as the message of a built-in loop continuation, is not shown;
|
|
23
|
+
* it starts the step of the next model call, also while that call is still running, as the UI stream does.
|
|
24
|
+
* Changed in 0.5.0: such a message no longer appears as a user message that splits the turn.
|
|
25
|
+
*
|
|
26
|
+
* The UI stream starts a step for every `RunModel` Step, and this function one for every model call. They differ
|
|
27
|
+
* only where a `RunModel` makes no model call, such as when `decideTurnContinuation` ends a turn after its tools:
|
|
28
|
+
* the stream then sends one more `start-step` and `finish-step` with no visible part, which leaves no part in the
|
|
29
|
+
* AI SDK message, so the message still matches the converted snapshot.
|
|
22
30
|
*
|
|
23
31
|
* The session stores a turn's messages when the turn ends, or after each model call for a runner such as
|
|
24
|
-
* the
|
|
32
|
+
* the built-in loop runner. For the active turn the function shows each tool call of `snapshot.toolCalls` once in
|
|
25
33
|
* the turn's assistant message: a stored call without a result takes the record's state, and a call not
|
|
26
34
|
* stored yet is added. Approvals waiting for `resolve_interrupt` are `approval-requested`, running calls
|
|
27
35
|
* are `input-available` or `approval-responded`, and finished calls show their result. The active turn's
|
|
@@ -38,9 +46,14 @@ import { encodeAgentUIStreamCursor } from "./agent-ui-stream-cursor.js";
|
|
|
38
46
|
*/
|
|
39
47
|
export function convertAgentSnapshotToUIMessages(snapshot) {
|
|
40
48
|
const uiMessages = [];
|
|
49
|
+
const activeTurnId = snapshot.state?.activeTurnId ?? null;
|
|
41
50
|
let assistantMessage;
|
|
42
|
-
for (const message of snapshot.messages) {
|
|
51
|
+
for (const [index, message] of snapshot.messages.entries()) {
|
|
43
52
|
if (message.role === "user") {
|
|
53
|
+
if (assistantMessage?.turnId === message.turnId && !isTurnEndingNote(snapshot, index, activeTurnId)) {
|
|
54
|
+
assistantMessage.startModelCall();
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
44
57
|
assistantMessage = undefined;
|
|
45
58
|
uiMessages.push({
|
|
46
59
|
id: agentUserUIMessageId(message.sequence),
|
|
@@ -55,7 +68,6 @@ export function convertAgentSnapshotToUIMessages(snapshot) {
|
|
|
55
68
|
}
|
|
56
69
|
assistantMessage.appendStoredMessage(message);
|
|
57
70
|
}
|
|
58
|
-
const activeTurnId = snapshot.state?.activeTurnId ?? null;
|
|
59
71
|
if (activeTurnId !== null && snapshot.toolCalls.length > 0) {
|
|
60
72
|
if (assistantMessage?.turnId !== activeTurnId) {
|
|
61
73
|
assistantMessage = new AgentAssistantUIMessageBuilder(activeTurnId);
|
|
@@ -65,6 +77,13 @@ export function convertAgentSnapshotToUIMessages(snapshot) {
|
|
|
65
77
|
}
|
|
66
78
|
return uiMessages;
|
|
67
79
|
}
|
|
80
|
+
/** Whether a user message after the turn's model output is a note: the last stored message of an ended turn. */
|
|
81
|
+
function isTurnEndingNote(snapshot, index, activeTurnId) {
|
|
82
|
+
const message = snapshot.messages[index];
|
|
83
|
+
const following = snapshot.messages[index + 1];
|
|
84
|
+
const isLastOfTurn = following === undefined || following.turnId !== message.turnId;
|
|
85
|
+
return isLastOfTurn && message.turnId !== activeTurnId;
|
|
86
|
+
}
|
|
68
87
|
/**
|
|
69
88
|
* Reads an agent session as AI SDK messages and the UI stream resume token of its active turn.
|
|
70
89
|
*
|
|
@@ -108,6 +127,11 @@ class AgentAssistantUIMessageBuilder {
|
|
|
108
127
|
parts: [{ type: "step-start" }],
|
|
109
128
|
};
|
|
110
129
|
}
|
|
130
|
+
/** Starts the step of a model call that follows a user message within the turn. */
|
|
131
|
+
startModelCall() {
|
|
132
|
+
this.message.parts.push({ type: "step-start" });
|
|
133
|
+
this.isAfterToolResult = false;
|
|
134
|
+
}
|
|
111
135
|
appendStoredMessage(message) {
|
|
112
136
|
if (message.role === "tool") {
|
|
113
137
|
this.appendToolResult(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-ui-messages.js","sourceRoot":"","sources":["../../../src/ui-stream/agent-ui-messages.ts"],"names":[],"mapp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AK,WAAW;YACd,OAAO,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,eAAe,EAAE,CAAC;QACvG,KAAK,QAAQ,CAAC;QACd,KAAK,iBAAiB;YACpB,OAAO;gBACL,GAAG,QAAQ;gBACX,KAAK,EAAE,cAAc;gBACrB,SAAS,EAAE,uBAAuB,CAAC,QAAQ,CAAC;gBAC5C,GAAG,eAAe;aACnB,CAAC;QACJ,KAAK,UAAU;YACb,OAAO;gBACL,GAAG,QAAQ;gBACX,KAAK,EAAE,eAAe;gBACtB,QAAQ,EAAE;oBACR,EAAE,EAAE,UAAU;oBACd,QAAQ,EAAE,KAAK;oBACf,GAAG,CAAC,QAAQ,CAAC,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,gBAAgB,EAAE,CAAC;iBACrF;aACF,CAAC;IACN,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/dex-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Durable agent sessions for Dex, shared by the Dex TypeScript agent framework adapters",
|
|
5
5
|
"license": "LicenseRef-Sustainable-Use-1.0",
|
|
6
6
|
"repository": {
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./dist/src/ui-stream/index.d.ts",
|
|
47
47
|
"import": "./dist/src/ui-stream/index.js"
|
|
48
48
|
},
|
|
49
|
+
"./builtin-loop": {
|
|
50
|
+
"types": "./dist/src/builtin-loop/index.d.ts",
|
|
51
|
+
"import": "./dist/src/builtin-loop/index.js"
|
|
52
|
+
},
|
|
49
53
|
"./stepwise": {
|
|
50
54
|
"types": "./dist/src/stepwise/index.d.ts",
|
|
51
55
|
"import": "./dist/src/stepwise/index.js"
|
|
@@ -53,6 +57,10 @@
|
|
|
53
57
|
"./ai-sdk": {
|
|
54
58
|
"types": "./dist/src/ai-sdk/index.d.ts",
|
|
55
59
|
"import": "./dist/src/ai-sdk/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./s3": {
|
|
62
|
+
"types": "./dist/src/s3/index.d.ts",
|
|
63
|
+
"import": "./dist/src/s3/index.js"
|
|
56
64
|
}
|
|
57
65
|
},
|
|
58
66
|
"scripts": {
|
|
@@ -62,13 +70,17 @@
|
|
|
62
70
|
"test:long": "npm run build && node --test --test-concurrency=1 --test-timeout=1800000 'dist/test/long/*.integration.test.js'"
|
|
63
71
|
},
|
|
64
72
|
"peerDependencies": {
|
|
73
|
+
"@aws-sdk/client-s3": "^3.700.0",
|
|
65
74
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
66
75
|
"@opentelemetry/api": "^1.3.0",
|
|
67
76
|
"@superdurable/connectors-sdk": "0.9.0",
|
|
68
|
-
"@superdurable/dex": "1.
|
|
77
|
+
"@superdurable/dex": "1.45.0",
|
|
69
78
|
"ai": "^7.0.159"
|
|
70
79
|
},
|
|
71
80
|
"peerDependenciesMeta": {
|
|
81
|
+
"@aws-sdk/client-s3": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
72
84
|
"@modelcontextprotocol/sdk": {
|
|
73
85
|
"optional": true
|
|
74
86
|
},
|
|
@@ -83,11 +95,12 @@
|
|
|
83
95
|
}
|
|
84
96
|
},
|
|
85
97
|
"devDependencies": {
|
|
98
|
+
"@aws-sdk/client-s3": "3.1155.0",
|
|
86
99
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
87
100
|
"@opentelemetry/api": "1.9.1",
|
|
88
101
|
"@opentelemetry/sdk-trace-base": "2.12.0",
|
|
89
102
|
"@superdurable/connectors-sdk": "0.9.0",
|
|
90
|
-
"@superdurable/dex": "1.
|
|
103
|
+
"@superdurable/dex": "1.45.0",
|
|
91
104
|
"@types/node": "22.20.5",
|
|
92
105
|
"ai": "7.0.159",
|
|
93
106
|
"typescript": "5.9.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-definition.js","sourceRoot":"","sources":["../../../src/stepwise/agent-definition.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { AgentEventWriter } from "../agent-framework-runner.js";
|
|
2
|
-
import type { QuestionAnswer, ToolEffect } from "../agent-session-values.js";
|
|
3
|
-
/**
|
|
4
|
-
* What a function tool receives besides its arguments, for one run of one tool call.
|
|
5
|
-
*
|
|
6
|
-
* Pass {@link idempotencyKey} to services that deduplicate requests: it is the same on every attempt
|
|
7
|
-
* of the call, so an `idempotent_write` retried by `CallTool` is applied once.
|
|
8
|
-
*/
|
|
9
|
-
export interface ToolCallContext {
|
|
10
|
-
/** Flow ID, which is the session ID. */
|
|
11
|
-
readonly flowId: string;
|
|
12
|
-
/** Turn that requested the call. */
|
|
13
|
-
readonly turnId: string;
|
|
14
|
-
/** Model tool call ID. */
|
|
15
|
-
readonly toolCallId: string;
|
|
16
|
-
/** Stable key `<flowId>/<turnId>/<toolCallId>`, identical on every attempt of the call. */
|
|
17
|
-
readonly idempotencyKey: string;
|
|
18
|
-
/** One-based attempt of the tool Step; `read` and `idempotent_write` calls get up to three. */
|
|
19
|
-
readonly attempt: number;
|
|
20
|
-
/** Events writer bound to the turn and attempt, for progress text. */
|
|
21
|
-
readonly events: AgentEventWriter;
|
|
22
|
-
/** Signal aborted when Dex cancels the attempt; pass it to network calls. */
|
|
23
|
-
readonly cancellationSignal: AbortSignal;
|
|
24
|
-
/** Absolute deadline of the current attempt, or `undefined`. */
|
|
25
|
-
readonly deadline: Date | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Answers to the questions this call asked by returning {@link ToolInputRequested}, oldest first;
|
|
28
|
-
* empty on the first run.
|
|
29
|
-
*/
|
|
30
|
-
readonly inputAnswers: readonly QuestionAnswer[];
|
|
31
|
-
/** `continuation` of the call's last {@link ToolInputRequested}, or `null`. */
|
|
32
|
-
readonly inputContinuation: string | null;
|
|
33
|
-
/**
|
|
34
|
-
* Records a heartbeat. The session already records one every 20 seconds while the tool runs.
|
|
35
|
-
* @returns A Promise that resolves when the Worker accepted the heartbeat.
|
|
36
|
-
*/
|
|
37
|
-
heartbeat(): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
/** Definition passed to {@link functionTool}. */
|
|
40
|
-
export interface FunctionToolDefinition<Arguments> {
|
|
41
|
-
/** Tool name as the model calls it: 1 to 64 letters, digits, `_`, or `-`, unique within the agent. */
|
|
42
|
-
readonly name: string;
|
|
43
|
-
/** Description for the model; say what the tool does and when to use it. */
|
|
44
|
-
readonly description: string;
|
|
45
|
-
/**
|
|
46
|
-
* JSON Schema of the arguments, with `type` `"object"`. The runner checks the model's arguments
|
|
47
|
-
* against it before {@link execute} runs, as the Python core does: `type`, `enum`, `anyOf`,
|
|
48
|
-
* `properties`, `required`, `additionalProperties`, `items`, `minimum`, and `maximum` are checked, and
|
|
49
|
-
* other keywords are only shown to the model.
|
|
50
|
-
*/
|
|
51
|
-
readonly parameters: Readonly<Record<string, unknown>>;
|
|
52
|
-
/** Side-effect class; it picks `CallTool` or `CallSingleAttemptTool` and the default approval. */
|
|
53
|
-
readonly effect: ToolEffect;
|
|
54
|
-
/**
|
|
55
|
-
* Whether every call waits for `resolve_interrupt` before it runs. Defaults to `true` for
|
|
56
|
-
* `non_idempotent_write` and `unclassified` and to `false` otherwise. A tool policy in
|
|
57
|
-
* {@link AgentDefinition.toolPolicies} overrides it.
|
|
58
|
-
*/
|
|
59
|
-
readonly requiresApproval?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Runs the tool once, inside its own tool Step.
|
|
62
|
-
*
|
|
63
|
-
* A `string` result is the output the model sees. A {@link ToolInputRequested} result asks the user a
|
|
64
|
-
* question; return it only before the tool took any effect, and the tool runs again with the answer in
|
|
65
|
-
* {@link ToolCallContext.inputAnswers}. Any other result is serialized as JSON, with the separators
|
|
66
|
-
* of Python's `json.dumps`. Throw `ToolExecutionError` for a failure the model should see; any other
|
|
67
|
-
* error fails the attempt, as {@link ToolExecutionError} describes.
|
|
68
|
-
* @param args - Arguments that passed the {@link parameters} check.
|
|
69
|
-
* @param context - Idempotency key, attempt, events, and heartbeat of this run.
|
|
70
|
-
* @returns The tool result.
|
|
71
|
-
*/
|
|
72
|
-
readonly execute: (args: Arguments, context: ToolCallContext) => unknown;
|
|
73
|
-
}
|
|
74
|
-
/** A tool implemented by a plain function, created by {@link functionTool}. */
|
|
75
|
-
export interface FunctionTool {
|
|
76
|
-
/** Discriminator. */
|
|
77
|
-
readonly kind: "function_tool";
|
|
78
|
-
/** Tool name. */
|
|
79
|
-
readonly name: string;
|
|
80
|
-
/** Description for the model. */
|
|
81
|
-
readonly description: string;
|
|
82
|
-
/** JSON Schema of the arguments. */
|
|
83
|
-
readonly parameters: Readonly<Record<string, unknown>>;
|
|
84
|
-
/** Side-effect class. */
|
|
85
|
-
readonly effect: ToolEffect;
|
|
86
|
-
/** Approval override, or `undefined` for the effect's default. */
|
|
87
|
-
readonly requiresApproval: boolean | undefined;
|
|
88
|
-
/**
|
|
89
|
-
* Runs the tool with checked arguments.
|
|
90
|
-
* @param args - Arguments that passed the schema check.
|
|
91
|
-
* @param context - Context of this run.
|
|
92
|
-
* @returns A Promise of the tool result.
|
|
93
|
-
*/
|
|
94
|
-
execute(args: unknown, context: ToolCallContext): Promise<unknown>;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Creates a function tool for a Stepwise agent.
|
|
98
|
-
*
|
|
99
|
-
* Every function tool declares its effect, which picks the tool Step and the default approval exactly
|
|
100
|
-
* as for adapter tools. Each call runs in its own Step, so a crash repeats at most a `read` or
|
|
101
|
-
* `idempotent_write` call and never repeats a `non_idempotent_write` call.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts
|
|
105
|
-
* const lookupOrder = functionTool<{ order_id: string }>({
|
|
106
|
-
* name: "lookup_order",
|
|
107
|
-
* description: "Look up an order by its ID.",
|
|
108
|
-
* parameters: { type: "object", properties: { order_id: { type: "string" } }, required: ["order_id"] },
|
|
109
|
-
* effect: "read",
|
|
110
|
-
* execute: async ({ order_id }) => orders.get(order_id),
|
|
111
|
-
* });
|
|
112
|
-
* const refundOrder = functionTool<{ order_id: string; amount_cents: number }>({
|
|
113
|
-
* name: "refund_order",
|
|
114
|
-
* description: "Refund part of an order.",
|
|
115
|
-
* parameters: {
|
|
116
|
-
* type: "object",
|
|
117
|
-
* properties: { order_id: { type: "string" }, amount_cents: { type: "integer", minimum: 1 } },
|
|
118
|
-
* required: ["order_id", "amount_cents"],
|
|
119
|
-
* },
|
|
120
|
-
* effect: "non_idempotent_write",
|
|
121
|
-
* execute: async ({ order_id, amount_cents }, context) =>
|
|
122
|
-
* payments.refund(order_id, amount_cents, { idempotencyKey: context.idempotencyKey }),
|
|
123
|
-
* });
|
|
124
|
-
* ```
|
|
125
|
-
* @typeParam Arguments - Type of the checked arguments; it is not checked against the schema.
|
|
126
|
-
* @param definition - Name, description, schema, effect, approval, and implementation.
|
|
127
|
-
* @returns The tool, to pass in {@link AgentDefinition.tools}.
|
|
128
|
-
* @throws {TypeError} When the name, description, schema, effect, or implementation is invalid.
|
|
129
|
-
*/
|
|
130
|
-
export declare function functionTool<Arguments = Record<string, unknown>>(definition: FunctionToolDefinition<Arguments>): FunctionTool;
|