@superdurable/dex-agents 0.3.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 +598 -45
- package/dist/src/agent-context-compaction.d.ts +1 -1
- package/dist/src/agent-framework-runner.d.ts +210 -10
- package/dist/src/agent-framework-runner.js +30 -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 +53 -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-graph.json +98 -81
- 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 +9 -0
- package/dist/src/agent-session-steps.js +219 -34
- 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 +4 -0
- package/dist/src/agent-session-transitions.js +29 -1
- package/dist/src/agent-session-transitions.js.map +1 -1
- package/dist/src/agent-session-values.d.ts +112 -1
- package/dist/src/agent-session-values.js +6 -0
- package/dist/src/agent-session-values.js.map +1 -1
- package/dist/src/agent-session-wait-steps.js +17 -5
- 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} +85 -26
- package/dist/src/{stepwise/stepwise-agent-runner.js → builtin-loop/builtin-loop-agent-runner.js} +320 -213
- 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 +13 -3
- package/dist/src/builtin-loop/tool-source.js.map +1 -0
- package/dist/src/connectors/connector-input-schema.d.ts +19 -0
- package/dist/src/connectors/connector-input-schema.js +228 -0
- package/dist/src/connectors/connector-input-schema.js.map +1 -0
- package/dist/src/connectors/connector-step-context.d.ts +94 -0
- package/dist/src/connectors/connector-step-context.js +180 -0
- package/dist/src/connectors/connector-step-context.js.map +1 -0
- package/dist/src/connectors/connector-tool-source.d.ts +401 -0
- package/dist/src/connectors/connector-tool-source.js +628 -0
- package/dist/src/connectors/connector-tool-source.js.map +1 -0
- package/dist/src/connectors/index.d.ts +3 -0
- package/dist/src/connectors/index.js +11 -0
- package/dist/src/connectors/index.js.map +1 -0
- package/dist/src/index.d.ts +7 -3
- package/dist/src/index.js +6 -3
- 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 +211 -0
- package/dist/src/tool-source-router.js +380 -0
- package/dist/src/tool-source-router.js.map +1 -0
- 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 +25 -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
|
@@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CACL,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM;YACnD,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAC7G,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,KAAK,KAAK,CAAC;AACxB,CAAC;AAED,SAAS,eAAe,CAAC,IAAY,EAAE,KAAc;IACnD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;QACnC,KAAK,SAAS;YACZ,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;QACpC,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,IAAI,CAAC;QACxB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9E,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;QACnC,KAAK,SAAS;YACZ,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9D;YACE,MAAM,IAAI,SAAS,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import type { AgentUsage } from "../agent-session-values.js";
|
|
1
|
+
import type { AgentImageReference, AgentUsage } from "../agent-session-values.js";
|
|
2
2
|
/**
|
|
3
3
|
* User text in a model input, stored for a user message and for Dex notes such as the turn-failure note.
|
|
4
|
-
* Wire shape: `{"type":"user_text","text"}
|
|
4
|
+
* Wire shape: `{"type":"user_text","text"}`, plus `"images"` when the message has images.
|
|
5
5
|
*/
|
|
6
6
|
export interface ModelUserTextItem {
|
|
7
7
|
/** Discriminator. Wire field: `type`. */
|
|
8
8
|
readonly type: "user_text";
|
|
9
9
|
/** The text. Wire field: `text`. */
|
|
10
10
|
readonly text: string;
|
|
11
|
+
/**
|
|
12
|
+
* The images of a user message, after the text, in order. The item holds references only; the request's
|
|
13
|
+
* {@link ModelRequest.imageBytes} holds their bytes. Omitted or empty for a message without images and for every
|
|
14
|
+
* note Dex adds. Wire field: `images`, a list of snake_case image references, written only when non-empty.
|
|
15
|
+
*
|
|
16
|
+
* @since 0.5.0
|
|
17
|
+
*/
|
|
18
|
+
readonly images?: readonly AgentImageReference[];
|
|
11
19
|
}
|
|
12
20
|
/** One tool call of a model response, in provider-neutral form. */
|
|
13
21
|
export interface ModelToolCall {
|
|
@@ -44,7 +52,8 @@ export interface ModelOutputItem {
|
|
|
44
52
|
}
|
|
45
53
|
/**
|
|
46
54
|
* The result of one tool call in a model input, in provider-neutral form.
|
|
47
|
-
* Wire shape: `{"type":"tool_result","tool_call_id","tool_name","output"}
|
|
55
|
+
* Wire shape: `{"type":"tool_result","tool_call_id","tool_name","output"}`, plus `"images"` when the tool returned
|
|
56
|
+
* images.
|
|
48
57
|
*/
|
|
49
58
|
export interface ModelToolResultItem {
|
|
50
59
|
/** Discriminator. Wire field: `type`. */
|
|
@@ -55,9 +64,17 @@ export interface ModelToolResultItem {
|
|
|
55
64
|
readonly toolName: string;
|
|
56
65
|
/** Model-visible result text, from `describeToolCallOutcome`. Wire field: `output`. */
|
|
57
66
|
readonly output: string;
|
|
67
|
+
/**
|
|
68
|
+
* The images the tool returned with {@link output}, from `AgentToolCall.images`, in order. The item holds
|
|
69
|
+
* references only; the request's {@link ModelRequest.imageBytes} holds their bytes. Wire field: `images`, written
|
|
70
|
+
* only when non-empty.
|
|
71
|
+
*
|
|
72
|
+
* @since 0.5.0
|
|
73
|
+
*/
|
|
74
|
+
readonly images?: readonly AgentImageReference[];
|
|
58
75
|
}
|
|
59
76
|
/**
|
|
60
|
-
* One item of a model input. The
|
|
77
|
+
* One item of a model input. The built-in loop runner stores each one as the `framework_item` of an
|
|
61
78
|
* `AgentMessage`, as snake_case JSON.
|
|
62
79
|
*/
|
|
63
80
|
export type ModelInputItem = ModelUserTextItem | ModelOutputItem | ModelToolResultItem;
|
|
@@ -99,7 +116,7 @@ export interface ModelRequestMetadata {
|
|
|
99
116
|
/** One-based attempt of the `RunModel` Step. */
|
|
100
117
|
readonly attempt: number;
|
|
101
118
|
}
|
|
102
|
-
/** One model call, built by the
|
|
119
|
+
/** One model call, built by the built-in loop runner from committed session state only. */
|
|
103
120
|
export interface ModelRequest {
|
|
104
121
|
/** System instructions for this call. */
|
|
105
122
|
readonly instructions: string;
|
|
@@ -115,6 +132,14 @@ export interface ModelRequest {
|
|
|
115
132
|
readonly metadata: ModelRequestMetadata;
|
|
116
133
|
/** Signal aborted when Dex cancels the attempt; pass it to the provider request. */
|
|
117
134
|
readonly cancellationSignal: AbortSignal;
|
|
135
|
+
/**
|
|
136
|
+
* The bytes of every image of {@link inputItems}, keyed by `AgentImageReference.sha256`. The runner reads them
|
|
137
|
+
* from its media store right before `callModel`, so a client never reads a store. Omitted when the input has no
|
|
138
|
+
* images, and in the requests passed to `estimateInputTokens`, which count each image without its bytes.
|
|
139
|
+
*
|
|
140
|
+
* @since 0.5.0
|
|
141
|
+
*/
|
|
142
|
+
readonly imageBytes?: ReadonlyMap<string, Uint8Array>;
|
|
118
143
|
}
|
|
119
144
|
/** Result of one model call. */
|
|
120
145
|
export interface ModelResponse {
|
|
@@ -131,7 +156,7 @@ export interface ModelResponse {
|
|
|
131
156
|
/** Provider finish reason, such as `"stop"` or `"tool-calls"`. */
|
|
132
157
|
readonly finishReason: string;
|
|
133
158
|
}
|
|
134
|
-
/** Receives the live text of one model call; the
|
|
159
|
+
/** Receives the live text of one model call; the built-in loop runner forwards it to `AgentEvents`. */
|
|
135
160
|
export interface ModelOutputWriter {
|
|
136
161
|
/**
|
|
137
162
|
* Writes visible text as a `text_delta` event.
|
|
@@ -145,7 +170,7 @@ export interface ModelOutputWriter {
|
|
|
145
170
|
writeReasoningDelta(text: string): void;
|
|
146
171
|
}
|
|
147
172
|
/**
|
|
148
|
-
* Makes one model call for the
|
|
173
|
+
* Makes one model call for the built-in loop runner.
|
|
149
174
|
*
|
|
150
175
|
* Use `createAiSdkModelClient` from `@superdurable/dex-agents/ai-sdk` for any AI SDK provider, or
|
|
151
176
|
* implement this interface for another model API. Every client follows these rules:
|
|
@@ -158,6 +183,10 @@ export interface ModelOutputWriter {
|
|
|
158
183
|
* thinking signatures or encrypted reasoning, from display text.
|
|
159
184
|
* - Dex-authored items, {@link ModelUserTextItem} and {@link ModelToolResultItem}, are converted at call
|
|
160
185
|
* time. An item from another provider or API is replayed as its text and tool calls.
|
|
186
|
+
* - Images. A user text or tool result item may carry `images`. A client that sends images converts each one to
|
|
187
|
+
* the provider's image part, with its bytes from {@link ModelRequest.imageBytes}, and throws when they are
|
|
188
|
+
* missing. A client that ignores `images` shows the model the text only. The runner sends images only when it
|
|
189
|
+
* has a media store; see `BuiltinLoopAgentRunner`.
|
|
161
190
|
*
|
|
162
191
|
* @example
|
|
163
192
|
* ```ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-client.js","sourceRoot":"","sources":["../../../src/builtin-loop/model-client.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D"}
|
|
@@ -29,12 +29,12 @@ export interface ScriptedModelReply {
|
|
|
29
29
|
/** The script: a function from the whole request to the reply. */
|
|
30
30
|
export type ScriptedModelResponder = (request: ModelRequest) => ScriptedModelReply | Promise<ScriptedModelReply>;
|
|
31
31
|
/**
|
|
32
|
-
* A
|
|
32
|
+
* A built-in agent loop {@link ModelClient} that answers every model call from a script, for demos and tests without a
|
|
33
33
|
* model key. It mirrors the Python core's `ScriptedModelClient`.
|
|
34
34
|
*
|
|
35
|
-
* Use it as `AgentDefinition.model` to run a
|
|
35
|
+
* Use it as `AgentDefinition.model` to run a built-in loop agent with no provider account: a local demo
|
|
36
36
|
* mode of an application, a tutorial, or an integration test. It is a supported part of
|
|
37
|
-
* `@superdurable/dex-agents/
|
|
37
|
+
* `@superdurable/dex-agents/builtin-loop` and needs no optional peer. `@superdurable/dex-agents/testing`
|
|
38
38
|
* exports the same class.
|
|
39
39
|
*
|
|
40
40
|
* The script is a function of the whole {@link ModelRequest}, so it can read the user text, with
|
|
@@ -50,7 +50,7 @@ export type ScriptedModelResponder = (request: ModelRequest) => ScriptedModelRep
|
|
|
50
50
|
* ScriptedModelClient.toolResults(request).length > 0
|
|
51
51
|
* ? { text: "done" }
|
|
52
52
|
* : { toolCalls: [{ toolName: "lookup_order", arguments: { order_id: "7" } }] });
|
|
53
|
-
* const flow =
|
|
53
|
+
* const flow = createBuiltinAgentSessionFlow(
|
|
54
54
|
* { name: "demo", instructions: "Help.", model, tools: [lookupOrder] }, "DemoAgent");
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
@@ -92,8 +92,11 @@ export declare class ScriptedModelClient implements ModelClient {
|
|
|
92
92
|
static userTexts(request: ModelRequest): string[];
|
|
93
93
|
/**
|
|
94
94
|
* Returns the tool results after the last user item of a request.
|
|
95
|
+
*
|
|
96
|
+
* A continuation message from `decideTurnContinuation` is a user item too. After one, this returns only the
|
|
97
|
+
* results that follow it, so a script that decides from these results must also read the earlier ones itself.
|
|
95
98
|
* @param request - The request.
|
|
96
|
-
* @returns The
|
|
99
|
+
* @returns The tool results after the last user item, oldest first.
|
|
97
100
|
*/
|
|
98
101
|
static toolResults(request: ModelRequest): ModelToolResultItem[];
|
|
99
102
|
}
|
|
@@ -13,12 +13,12 @@ export const scriptedModelApi = "scripted";
|
|
|
13
13
|
/** Default number of latest requests {@link ScriptedModelClient.requests} keeps. */
|
|
14
14
|
export const defaultMaxRecordedRequests = 100;
|
|
15
15
|
/**
|
|
16
|
-
* A
|
|
16
|
+
* A built-in agent loop {@link ModelClient} that answers every model call from a script, for demos and tests without a
|
|
17
17
|
* model key. It mirrors the Python core's `ScriptedModelClient`.
|
|
18
18
|
*
|
|
19
|
-
* Use it as `AgentDefinition.model` to run a
|
|
19
|
+
* Use it as `AgentDefinition.model` to run a built-in loop agent with no provider account: a local demo
|
|
20
20
|
* mode of an application, a tutorial, or an integration test. It is a supported part of
|
|
21
|
-
* `@superdurable/dex-agents/
|
|
21
|
+
* `@superdurable/dex-agents/builtin-loop` and needs no optional peer. `@superdurable/dex-agents/testing`
|
|
22
22
|
* exports the same class.
|
|
23
23
|
*
|
|
24
24
|
* The script is a function of the whole {@link ModelRequest}, so it can read the user text, with
|
|
@@ -34,7 +34,7 @@ export const defaultMaxRecordedRequests = 100;
|
|
|
34
34
|
* ScriptedModelClient.toolResults(request).length > 0
|
|
35
35
|
* ? { text: "done" }
|
|
36
36
|
* : { toolCalls: [{ toolName: "lookup_order", arguments: { order_id: "7" } }] });
|
|
37
|
-
* const flow =
|
|
37
|
+
* const flow = createBuiltinAgentSessionFlow(
|
|
38
38
|
* { name: "demo", instructions: "Help.", model, tools: [lookupOrder] }, "DemoAgent");
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
@@ -127,8 +127,11 @@ export class ScriptedModelClient {
|
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Returns the tool results after the last user item of a request.
|
|
130
|
+
*
|
|
131
|
+
* A continuation message from `decideTurnContinuation` is a user item too. After one, this returns only the
|
|
132
|
+
* results that follow it, so a script that decides from these results must also read the earlier ones itself.
|
|
130
133
|
* @param request - The request.
|
|
131
|
-
* @returns The
|
|
134
|
+
* @returns The tool results after the last user item, oldest first.
|
|
132
135
|
*/
|
|
133
136
|
static toolResults(request) {
|
|
134
137
|
let results = [];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripted-model-client.js","sourceRoot":"","sources":["../../../src/builtin-loop/scripted-model-client.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAG1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAWhF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,qFAAqF;AACrF,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE3C,oFAAoF;AACpF,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AA2B9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,mBAAmB;IAaX;IAZF,gBAAgB,GAAmB,EAAE,CAAC;IACtC,mBAAmB,CAAS;IAE7C;;;;;;;OAOG;IACH,YACmB,OAA+B,EAChD,UAAqD,EAAE;QADtC,YAAO,GAAP,OAAO,CAAwB;QAGhD,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,0BAA0B,CAAC;QACrF,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,IAAI,CAAC,mBAAmB,GAAG,CAAC,EAAE,CAAC;YACpF,MAAM,IAAI,UAAU,CAAC,oDAAoD,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED,2GAA2G;IAC3G,IAAW,QAAQ;QACjB,OAAO,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,OAAqB,EAAE,MAAyB;QACrE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,gBAAgB,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AAC,MAAM,CAAC;iBAC3G,MAAM,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,OAAqB;QAC3C,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,WAAW,CAAC,OAAqB;QAC7C,IAAI,OAAO,GAA0B,EAAE,CAAC;QACxC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC9B,OAAO,GAAG,EAAE,CAAC;YACf,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;gBACvC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED,SAAS,kBAAkB,CACzB,IAAuC,EACvC,IAAmB,EACnB,SAAmC;IAEnC,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,qBAAqB;QAC/B,GAAG,EAAE,gBAAgB;QACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAC1B,IAAI;QACJ,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AgentTurnContext, DeferredToolCall, DeferredToolExecution, DeferredToolOutcome, ToolTaskCancellation, ToolTaskPoll, ToolTaskPollOutcome } from "../agent-framework-runner.js";
|
|
1
|
+
import type { AgentTurnContext, DeferredToolCall, DeferredToolExecution, DeferredToolOutcome, ToolCallStepOptions, ToolTaskCancellation, ToolTaskPoll, ToolTaskPollOutcome } from "../agent-framework-runner.js";
|
|
2
|
+
import type { AgentToolCall } from "../agent-session-values.js";
|
|
2
3
|
/**
|
|
3
4
|
* One tool that a {@link ToolSource} lists, as the model sees it. `McpTool` satisfies it; the runner reads only
|
|
4
5
|
* these three fields.
|
|
@@ -15,7 +16,7 @@ export interface SourceToolDefinition {
|
|
|
15
16
|
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
* Tools that a
|
|
19
|
+
* Tools that a built-in loop agent lists at run time, such as an MCP server's tools, run one tool Step per call.
|
|
19
20
|
*
|
|
20
21
|
* Put a source in `AgentDefinition.toolSources`. `McpToolSource` from `@superdurable/dex-agents/mcp`
|
|
21
22
|
* implements it. In every `RunModel` of a chat or executing turn, the runner awaits {@link listTools} and
|
|
@@ -38,7 +39,7 @@ export interface SourceToolDefinition {
|
|
|
38
39
|
* @example
|
|
39
40
|
* ```ts
|
|
40
41
|
* const tools = new McpToolSource([{ name: "files", transport: "stdio", command: "mcp-files" }]);
|
|
41
|
-
* const flow =
|
|
42
|
+
* const flow = createBuiltinAgentSessionFlow(
|
|
42
43
|
* { name: "files", instructions: "You manage reports.", model, toolSources: [tools] },
|
|
43
44
|
* "FilesAgent",
|
|
44
45
|
* );
|
|
@@ -100,4 +101,13 @@ export interface ToolSource {
|
|
|
100
101
|
* @returns A Promise that resolves once the remote system took the cancellation.
|
|
101
102
|
*/
|
|
102
103
|
cancelToolTask?(cancellation: ToolTaskCancellation): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Optional: the timeout and retry policy of one call's tool Step, or `undefined` for the defaults, as
|
|
106
|
+
* {@link AgentFrameworkRunner.toolCallStepOptions} describes. `ConnectorToolSource` uses it for each
|
|
107
|
+
* operation's timeout and retry policy.
|
|
108
|
+
* @param toolCall - The record whose tool Step starts, with this source's own reference.
|
|
109
|
+
* @returns The options, or `undefined`.
|
|
110
|
+
* @since 0.4.0
|
|
111
|
+
*/
|
|
112
|
+
toolCallStepOptions?(toolCall: AgentToolCall): ToolCallStepOptions | undefined;
|
|
103
113
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-source.js","sourceRoot":"","sources":["../../../src/builtin-loop/tool-source.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type JsonSchema = Readonly<Record<string, unknown>>;
|
|
2
|
+
/**
|
|
3
|
+
* Throws when a schema uses a keyword the agent core cannot enforce.
|
|
4
|
+
* @param schema - A Connector operation's `inputSchema`.
|
|
5
|
+
* @throws {TypeError} When the schema is not an object schema, uses an unknown keyword or type, or has a `$ref`
|
|
6
|
+
* outside `#/$defs/`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function checkConnectorInputSchema(schema: JsonSchema): void;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the first way the arguments break the schema, such as `arguments.amount must be integer`, or
|
|
11
|
+
* `undefined`. The texts match the Python core.
|
|
12
|
+
* @param value - The decoded JSON arguments.
|
|
13
|
+
* @param schema - A schema that {@link checkConnectorInputSchema} accepted.
|
|
14
|
+
* @returns The violation text, or `undefined`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findConnectorInputViolation(value: unknown, schema: JsonSchema): string | undefined;
|
|
17
|
+
/** Orders keys by code point, as Python's `sorted` does. */
|
|
18
|
+
export declare function compareCodePoints(left: string, right: string): number;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
// You may not use this file except in compliance with the License.
|
|
5
|
+
// See the LICENSE file in the repository root.
|
|
6
|
+
//
|
|
7
|
+
// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
// Checks the JSON Schema subset of Connector `inputSchema` values with the Python core's messages.
|
|
9
|
+
import { serializeJsonWithSpacedSeparators } from "../builtin-loop/json-schema-validation.js";
|
|
10
|
+
// Keywords that constrain a value; an unlisted keyword refuses the tool, so nothing is unchecked.
|
|
11
|
+
const checkedKeywords = new Set([
|
|
12
|
+
"type",
|
|
13
|
+
"properties",
|
|
14
|
+
"required",
|
|
15
|
+
"additionalProperties",
|
|
16
|
+
"items",
|
|
17
|
+
"enum",
|
|
18
|
+
"anyOf",
|
|
19
|
+
"$ref",
|
|
20
|
+
"$defs",
|
|
21
|
+
"minimum",
|
|
22
|
+
"maximum",
|
|
23
|
+
]);
|
|
24
|
+
// Annotations: format is an annotation in draft 2020-12, and the operation's validator checks it.
|
|
25
|
+
const annotationKeywords = new Set([
|
|
26
|
+
"description",
|
|
27
|
+
"title",
|
|
28
|
+
"format",
|
|
29
|
+
"contentEncoding",
|
|
30
|
+
"default",
|
|
31
|
+
"$schema",
|
|
32
|
+
"$id",
|
|
33
|
+
"examples",
|
|
34
|
+
]);
|
|
35
|
+
const jsonTypes = new Set(["string", "boolean", "null", "array", "object", "number", "integer"]);
|
|
36
|
+
const definitionsPrefix = "#/$defs/";
|
|
37
|
+
/**
|
|
38
|
+
* Throws when a schema uses a keyword the agent core cannot enforce.
|
|
39
|
+
* @param schema - A Connector operation's `inputSchema`.
|
|
40
|
+
* @throws {TypeError} When the schema is not an object schema, uses an unknown keyword or type, or has a `$ref`
|
|
41
|
+
* outside `#/$defs/`.
|
|
42
|
+
*/
|
|
43
|
+
export function checkConnectorInputSchema(schema) {
|
|
44
|
+
if (schema["type"] !== "object") {
|
|
45
|
+
throw new TypeError("inputSchema must have type object");
|
|
46
|
+
}
|
|
47
|
+
const definitions = schema["$defs"] ?? {};
|
|
48
|
+
if (!isRecord(definitions)) {
|
|
49
|
+
throw new TypeError("inputSchema $defs must be an object");
|
|
50
|
+
}
|
|
51
|
+
checkNode(schema, definitions, "inputSchema");
|
|
52
|
+
}
|
|
53
|
+
function checkNode(node, definitions, path) {
|
|
54
|
+
if (!isRecord(node)) {
|
|
55
|
+
throw new TypeError(`${path} must be a schema object`);
|
|
56
|
+
}
|
|
57
|
+
for (const [keyword, value] of Object.entries(node)) {
|
|
58
|
+
if (annotationKeywords.has(keyword)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (!checkedKeywords.has(keyword)) {
|
|
62
|
+
throw new TypeError(`${path} uses ${keyword}, which agent tools do not check`);
|
|
63
|
+
}
|
|
64
|
+
if (keyword === "type") {
|
|
65
|
+
const names = typeof value === "string" ? [value] : value;
|
|
66
|
+
if (!Array.isArray(names) || names.some((name) => typeof name !== "string" || !jsonTypes.has(name))) {
|
|
67
|
+
throw new TypeError(`${path}.type is not a JSON type`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (keyword === "properties" || keyword === "$defs") {
|
|
71
|
+
if (!isRecord(value)) {
|
|
72
|
+
throw new TypeError(`${path}.${keyword} must be an object`);
|
|
73
|
+
}
|
|
74
|
+
for (const [name, child] of Object.entries(value)) {
|
|
75
|
+
checkNode(child, definitions, `${path}.${keyword}.${name}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (keyword === "items" || (keyword === "additionalProperties" && typeof value !== "boolean")) {
|
|
79
|
+
checkNode(value, definitions, `${path}.${keyword}`);
|
|
80
|
+
}
|
|
81
|
+
else if (keyword === "anyOf") {
|
|
82
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
83
|
+
throw new TypeError(`${path}.anyOf must be a non-empty array`);
|
|
84
|
+
}
|
|
85
|
+
value.forEach((child, index) => checkNode(child, definitions, `${path}.anyOf[${index}]`));
|
|
86
|
+
}
|
|
87
|
+
else if (keyword === "$ref") {
|
|
88
|
+
if (typeof value !== "string" || !value.startsWith(definitionsPrefix)) {
|
|
89
|
+
throw new TypeError(`${path}.$ref must point into #/$defs/`);
|
|
90
|
+
}
|
|
91
|
+
if (!Object.hasOwn(definitions, value.slice(definitionsPrefix.length))) {
|
|
92
|
+
throw new TypeError(`${path}.$ref names a missing definition`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (keyword === "required" && (!Array.isArray(value) || value.some((name) => typeof name !== "string"))) {
|
|
96
|
+
throw new TypeError(`${path}.required must be an array of names`);
|
|
97
|
+
}
|
|
98
|
+
else if (keyword === "enum" && !Array.isArray(value)) {
|
|
99
|
+
throw new TypeError(`${path}.enum must be an array`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the first way the arguments break the schema, such as `arguments.amount must be integer`, or
|
|
105
|
+
* `undefined`. The texts match the Python core.
|
|
106
|
+
* @param value - The decoded JSON arguments.
|
|
107
|
+
* @param schema - A schema that {@link checkConnectorInputSchema} accepted.
|
|
108
|
+
* @returns The violation text, or `undefined`.
|
|
109
|
+
*/
|
|
110
|
+
export function findConnectorInputViolation(value, schema) {
|
|
111
|
+
const definitions = schema["$defs"];
|
|
112
|
+
return findViolation(value, schema, isRecord(definitions) ? definitions : {}, "arguments");
|
|
113
|
+
}
|
|
114
|
+
function findViolation(value, schema, definitions, path) {
|
|
115
|
+
const reference = schema["$ref"];
|
|
116
|
+
if (typeof reference === "string") {
|
|
117
|
+
const problem = findViolation(value, definitions[reference.slice(definitionsPrefix.length)], definitions, path);
|
|
118
|
+
if (problem !== undefined) {
|
|
119
|
+
return problem;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const anyOf = schema["anyOf"];
|
|
123
|
+
if (Array.isArray(anyOf) &&
|
|
124
|
+
anyOf.every((option) => findViolation(value, option, definitions, path) !== undefined)) {
|
|
125
|
+
return `${path} matches none of the allowed types`;
|
|
126
|
+
}
|
|
127
|
+
const expected = schema["type"];
|
|
128
|
+
if (expected !== undefined) {
|
|
129
|
+
const expectedTypes = (typeof expected === "string" ? [expected] : expected).map(String);
|
|
130
|
+
if (!expectedTypes.some((type) => matchesJsonType(type, value))) {
|
|
131
|
+
return `${path} must be ${expectedTypes.join(" or ")}`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const allowedValues = schema["enum"];
|
|
135
|
+
if (Array.isArray(allowedValues) && !allowedValues.some((allowed) => isJsonEqual(value, allowed))) {
|
|
136
|
+
return `${path} must be one of ${serializeJsonWithSpacedSeparators(allowedValues)}`;
|
|
137
|
+
}
|
|
138
|
+
if (isRecord(value)) {
|
|
139
|
+
return findObjectViolation(value, schema, definitions, path);
|
|
140
|
+
}
|
|
141
|
+
const items = schema["items"];
|
|
142
|
+
if (Array.isArray(value) && isRecord(items)) {
|
|
143
|
+
for (const [index, item] of value.entries()) {
|
|
144
|
+
const problem = findViolation(item, items, definitions, `${path}[${index}]`);
|
|
145
|
+
if (problem !== undefined) {
|
|
146
|
+
return problem;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (typeof value === "number") {
|
|
151
|
+
if (typeof schema["minimum"] === "number" && value < schema["minimum"]) {
|
|
152
|
+
return `${path} must be at least ${schema["minimum"]}`;
|
|
153
|
+
}
|
|
154
|
+
if (typeof schema["maximum"] === "number" && value > schema["maximum"]) {
|
|
155
|
+
return `${path} must be at most ${schema["maximum"]}`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
function findObjectViolation(value, schema, definitions, path) {
|
|
161
|
+
const properties = (schema["properties"] ?? {});
|
|
162
|
+
for (const name of (schema["required"] ?? [])) {
|
|
163
|
+
if (!Object.hasOwn(value, name)) {
|
|
164
|
+
return `${path}.${name} is required`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const additional = schema["additionalProperties"] ?? true;
|
|
168
|
+
for (const name of Object.keys(value).sort(compareCodePoints)) {
|
|
169
|
+
const item = value[name];
|
|
170
|
+
let problem;
|
|
171
|
+
if (Object.hasOwn(properties, name)) {
|
|
172
|
+
problem = findViolation(item, properties[name] ?? {}, definitions, `${path}.${name}`);
|
|
173
|
+
}
|
|
174
|
+
else if (additional === false) {
|
|
175
|
+
problem = `${path}.${name} is not allowed`;
|
|
176
|
+
}
|
|
177
|
+
else if (isRecord(additional)) {
|
|
178
|
+
problem = findViolation(item, additional, definitions, `${path}.${name}`);
|
|
179
|
+
}
|
|
180
|
+
if (problem !== undefined) {
|
|
181
|
+
return problem;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
/** JSON equality: booleans never equal numbers, and `1` equals `1.0`. */
|
|
187
|
+
function isJsonEqual(left, right) {
|
|
188
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
189
|
+
return (Array.isArray(left) &&
|
|
190
|
+
Array.isArray(right) &&
|
|
191
|
+
left.length === right.length &&
|
|
192
|
+
left.every((item, index) => isJsonEqual(item, right[index])));
|
|
193
|
+
}
|
|
194
|
+
if (isRecord(left) && isRecord(right)) {
|
|
195
|
+
const leftKeys = Object.keys(left);
|
|
196
|
+
return (leftKeys.length === Object.keys(right).length &&
|
|
197
|
+
leftKeys.every((key) => Object.hasOwn(right, key) && isJsonEqual(left[key], right[key])));
|
|
198
|
+
}
|
|
199
|
+
return left === right;
|
|
200
|
+
}
|
|
201
|
+
function matchesJsonType(type, value) {
|
|
202
|
+
switch (type) {
|
|
203
|
+
case "string":
|
|
204
|
+
return typeof value === "string";
|
|
205
|
+
case "boolean":
|
|
206
|
+
return typeof value === "boolean";
|
|
207
|
+
case "null":
|
|
208
|
+
return value === null;
|
|
209
|
+
case "array":
|
|
210
|
+
return Array.isArray(value);
|
|
211
|
+
case "object":
|
|
212
|
+
return isRecord(value);
|
|
213
|
+
case "number":
|
|
214
|
+
return typeof value === "number";
|
|
215
|
+
case "integer":
|
|
216
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
217
|
+
default:
|
|
218
|
+
throw new TypeError(`unsupported JSON Schema type ${type}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/** Orders keys by code point, as Python's `sorted` does. */
|
|
222
|
+
export function compareCodePoints(left, right) {
|
|
223
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
224
|
+
}
|
|
225
|
+
function isRecord(value) {
|
|
226
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=connector-input-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-input-schema.js","sourceRoot":"","sources":["../../../src/connectors/connector-input-schema.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,mGAAmG;AAEnG,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAI9F,kGAAkG;AAClG,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IACnD,MAAM;IACN,YAAY;IACZ,UAAU;IACV,sBAAsB;IACtB,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AACH,kGAAkG;AAClG,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,aAAa;IACb,OAAO;IACP,QAAQ;IACR,iBAAiB;IACjB,SAAS;IACT,SAAS;IACT,KAAK;IACL,UAAU;CACX,CAAC,CAAC;AACH,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AACtH,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,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AC;QACxB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzB,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;QACnC,KAAK,SAAS;YACZ,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9D;YACE,MAAM,IAAI,SAAS,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,KAAa;IAC3D,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { AsyncContext } from "@superdurable/dex";
|
|
2
|
+
/** What one call's saved fence markers in this attempt prove; a later checkpoint cannot erase it. Internal. */
|
|
3
|
+
export interface FenceEvidence {
|
|
4
|
+
/** A claim stands: no valid `canResend` followed it. */
|
|
5
|
+
isClaimed: boolean;
|
|
6
|
+
/** The attempt claimed a send at some point. */
|
|
7
|
+
hasClaimed: boolean;
|
|
8
|
+
/** A claim recorded a provider ID. */
|
|
9
|
+
hasProviderId: boolean;
|
|
10
|
+
/** A `notSent` before any claim, or a valid `canResend`. */
|
|
11
|
+
hasNotSentProof: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Returns the evidence of one call's saved fence markers in this attempt, or `undefined`. Internal to the core. */
|
|
14
|
+
export declare function readFenceEvidence(context: ConnectorStepContext, callId: string): Readonly<FenceEvidence> | undefined;
|
|
15
|
+
/** Reports whether a value is a single-dispatch fence marker with only its declared fields. Internal to the core. */
|
|
16
|
+
export declare function isFenceMarker(value: unknown): value is Readonly<Record<string, unknown>>;
|
|
17
|
+
/** Returns the text checkpoint an earlier attempt saved, or `undefined`. Internal to the core. */
|
|
18
|
+
export declare function readPreviousCheckpoint(context: ConnectorStepContext): string | undefined;
|
|
19
|
+
/** Reports whether the operation asked this context for an earlier attempt's checkpoint. Internal to the core. */
|
|
20
|
+
export declare function hasReadCheckpoint(context: ConnectorStepContext): boolean;
|
|
21
|
+
/** How a {@link ConnectorStepContext} reaches the tool Step's heartbeats. */
|
|
22
|
+
export interface ConnectorStepHeartbeats {
|
|
23
|
+
/** The text checkpoint an earlier attempt of the tool Step saved, or `undefined`. */
|
|
24
|
+
readonly previousCheckpoint: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Records a plain heartbeat, which repeats the attempt's saved checkpoint.
|
|
27
|
+
* @returns A Promise that resolves when the Worker accepted the heartbeat.
|
|
28
|
+
*/
|
|
29
|
+
heartbeat(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Records a heartbeat carrying a text checkpoint; absent when the tool Step cannot save checkpoints.
|
|
32
|
+
* @param checkpoint - The text to hand to the next attempt.
|
|
33
|
+
* @returns A Promise that resolves when the Worker accepted the heartbeat.
|
|
34
|
+
*/
|
|
35
|
+
saveCheckpoint?(checkpoint: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The Step context a connector operation sees inside an agent tool Step, with heartbeat values kept as text.
|
|
39
|
+
*
|
|
40
|
+
* The single-dispatch fence records markers as heartbeat values and reads the previous attempt's marker back. The
|
|
41
|
+
* agent session's tool Step keeps one text checkpoint per attempt and repeats it on every background heartbeat.
|
|
42
|
+
* This context stores each heartbeat value as that text checkpoint, as JSON with sorted keys, and parses it on the
|
|
43
|
+
* next attempt, so a marker survives the session's own heartbeats and a retry can read it. It exposes only the
|
|
44
|
+
* members the fence uses, plus the identities a Call needs; the agent core's conformance tests pin that list.
|
|
45
|
+
*
|
|
46
|
+
* `ConnectorToolSource` builds one per tool Step attempt. Applications do not construct it.
|
|
47
|
+
* @since 0.4.0
|
|
48
|
+
*/
|
|
49
|
+
export declare class ConnectorStepContext {
|
|
50
|
+
private readonly context;
|
|
51
|
+
private readonly heartbeats;
|
|
52
|
+
/**
|
|
53
|
+
* Creates the context for one tool Step attempt.
|
|
54
|
+
* @param context - The tool Step's live context.
|
|
55
|
+
* @param heartbeats - The tool Step's checkpoint and heartbeat functions.
|
|
56
|
+
*/
|
|
57
|
+
constructor(context: AsyncContext, heartbeats: ConnectorStepHeartbeats);
|
|
58
|
+
/** The Flow ID. */
|
|
59
|
+
get flowId(): string;
|
|
60
|
+
/** The Flow run ID. */
|
|
61
|
+
get runId(): string;
|
|
62
|
+
/** The tool Step's execution ID, the same on every attempt. */
|
|
63
|
+
get stepExecutionId(): string;
|
|
64
|
+
/** The one-based attempt. */
|
|
65
|
+
get attempt(): number;
|
|
66
|
+
/** The attempt's deadline, or `undefined`. */
|
|
67
|
+
get deadline(): Date | undefined;
|
|
68
|
+
/** The signal Dex aborts when it cancels the attempt. */
|
|
69
|
+
get cancellationSignal(): AbortSignal;
|
|
70
|
+
/**
|
|
71
|
+
* Reports whether an earlier attempt of this tool Step saved a heartbeat value.
|
|
72
|
+
* @returns `true` when the session read a checkpoint for this attempt.
|
|
73
|
+
*/
|
|
74
|
+
hasLastHeartbeatValue(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Parses the earlier attempt's heartbeat value from its JSON text.
|
|
77
|
+
* @param codec - Must be omitted; values are JSON.
|
|
78
|
+
* @returns The parsed value, or `undefined` when there is none.
|
|
79
|
+
* @throws {TypeError} When a codec is given.
|
|
80
|
+
* @throws {SyntaxError} When the checkpoint is not JSON.
|
|
81
|
+
*/
|
|
82
|
+
getLastHeartbeatValue<T = unknown>(codec?: unknown): T | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Records a heartbeat, saving a value as the attempt's text checkpoint.
|
|
85
|
+
* @param value - The heartbeat value, such as a fence marker; `undefined` records a plain heartbeat, which
|
|
86
|
+
* repeats the saved checkpoint.
|
|
87
|
+
* @param codec - Must be omitted; values are JSON.
|
|
88
|
+
* @returns A Promise that resolves when the Worker accepted the heartbeat.
|
|
89
|
+
* @throws {TypeError} When a codec is given, or a value is given and the tool Step cannot save checkpoints.
|
|
90
|
+
*/
|
|
91
|
+
recordHeartbeat<T>(value?: T, codec?: unknown): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
/** Returns compact JSON with object keys sorted by code point, the text the Python core stores. */
|
|
94
|
+
export declare function stringifyWithSortedKeys(value: unknown): string;
|