@superdurable/dex-agents 0.1.0 → 0.3.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 +1608 -64
- package/dist/src/agent-built-in-tools.d.ts +81 -0
- package/dist/src/agent-built-in-tools.js +246 -0
- package/dist/src/agent-built-in-tools.js.map +1 -0
- package/dist/src/agent-context-compaction.d.ts +254 -0
- package/dist/src/agent-context-compaction.js +287 -0
- package/dist/src/agent-context-compaction.js.map +1 -0
- package/dist/src/agent-framework-runner.d.ts +456 -16
- package/dist/src/agent-framework-runner.js +4 -3
- package/dist/src/agent-framework-runner.js.map +1 -1
- package/dist/src/agent-plans.d.ts +48 -0
- package/dist/src/agent-plans.js +86 -0
- package/dist/src/agent-plans.js.map +1 -0
- package/dist/src/agent-session-cancellation-steps.d.ts +28 -0
- package/dist/src/agent-session-cancellation-steps.js +154 -0
- package/dist/src/agent-session-cancellation-steps.js.map +1 -0
- package/dist/src/agent-session-codecs.d.ts +65 -4
- package/dist/src/agent-session-codecs.js +343 -8
- package/dist/src/agent-session-codecs.js.map +1 -1
- package/dist/src/agent-session-failure.d.ts +58 -0
- package/dist/src/agent-session-failure.js +126 -0
- package/dist/src/agent-session-failure.js.map +1 -0
- package/dist/src/agent-session-flow-graph-cli.d.ts +2 -0
- package/dist/src/agent-session-flow-graph-cli.js +47 -0
- package/dist/src/agent-session-flow-graph-cli.js.map +1 -0
- package/dist/src/agent-session-flow-graph.d.ts +38 -0
- package/dist/src/agent-session-flow-graph.js +54 -0
- package/dist/src/agent-session-flow-graph.js.map +1 -0
- package/dist/src/agent-session-flow-graph.json +2187 -0
- package/dist/src/agent-session-flow.d.ts +317 -28
- package/dist/src/agent-session-flow.js +373 -21
- package/dist/src/agent-session-flow.js.map +1 -1
- package/dist/src/agent-session-persistence.d.ts +81 -4
- package/dist/src/agent-session-persistence.js +33 -2
- package/dist/src/agent-session-persistence.js.map +1 -1
- package/dist/src/agent-session-settings.d.ts +58 -0
- package/dist/src/agent-session-settings.js +81 -0
- package/dist/src/agent-session-settings.js.map +1 -0
- package/dist/src/agent-session-spend-limit.d.ts +156 -0
- package/dist/src/agent-session-spend-limit.js +42 -0
- package/dist/src/agent-session-spend-limit.js.map +1 -0
- package/dist/src/agent-session-start.d.ts +49 -0
- package/dist/src/agent-session-start.js +67 -0
- package/dist/src/agent-session-start.js.map +1 -0
- package/dist/src/agent-session-step-options.d.ts +78 -0
- package/dist/src/agent-session-step-options.js +71 -0
- package/dist/src/agent-session-step-options.js.map +1 -0
- package/dist/src/agent-session-step-types.d.ts +20 -0
- package/dist/src/agent-session-step-types.js +28 -0
- package/dist/src/agent-session-step-types.js.map +1 -0
- package/dist/src/agent-session-steps.d.ts +103 -8
- package/dist/src/agent-session-steps.js +997 -197
- package/dist/src/agent-session-steps.js.map +1 -1
- package/dist/src/agent-session-tracer.d.ts +61 -0
- package/dist/src/agent-session-tracer.js +608 -0
- package/dist/src/agent-session-tracer.js.map +1 -0
- package/dist/src/agent-session-transitions.d.ts +200 -26
- package/dist/src/agent-session-transitions.js +732 -32
- package/dist/src/agent-session-transitions.js.map +1 -1
- package/dist/src/agent-session-values.d.ts +696 -30
- package/dist/src/agent-session-values.js +39 -4
- package/dist/src/agent-session-values.js.map +1 -1
- package/dist/src/agent-session-wait-steps.d.ts +53 -0
- package/dist/src/agent-session-wait-steps.js +389 -0
- package/dist/src/agent-session-wait-steps.js.map +1 -0
- package/dist/src/agent-tracing-options.d.ts +107 -0
- package/dist/src/agent-tracing-options.js +20 -0
- package/dist/src/agent-tracing-options.js.map +1 -0
- package/dist/src/ai-sdk/ai-sdk-model-client.d.ts +40 -0
- package/dist/src/ai-sdk/ai-sdk-model-client.js +235 -0
- package/dist/src/ai-sdk/ai-sdk-model-client.js.map +1 -0
- package/dist/src/ai-sdk/index.d.ts +1 -0
- package/dist/src/ai-sdk/index.js +9 -0
- package/dist/src/ai-sdk/index.js.map +1 -0
- package/dist/src/index.d.ts +14 -3
- package/dist/src/index.js +12 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/index.d.ts +3 -0
- package/dist/src/mcp/index.js +10 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/mcp-resource-and-prompt-tools.d.ts +29 -0
- package/dist/src/mcp/mcp-resource-and-prompt-tools.js +185 -0
- package/dist/src/mcp/mcp-resource-and-prompt-tools.js.map +1 -0
- package/dist/src/mcp/mcp-server-config.d.ts +86 -0
- package/dist/src/mcp/mcp-server-config.js +38 -0
- package/dist/src/mcp/mcp-server-config.js.map +1 -0
- package/dist/src/mcp/mcp-tool-source.d.ts +470 -0
- package/dist/src/mcp/mcp-tool-source.js +1204 -0
- package/dist/src/mcp/mcp-tool-source.js.map +1 -0
- package/dist/src/stepwise/agent-definition.d.ts +166 -0
- package/dist/src/stepwise/agent-definition.js +9 -0
- package/dist/src/stepwise/agent-definition.js.map +1 -0
- package/dist/src/stepwise/function-tool.d.ts +130 -0
- package/dist/src/stepwise/function-tool.js +75 -0
- package/dist/src/stepwise/function-tool.js.map +1 -0
- package/dist/src/stepwise/index.d.ts +8 -0
- package/dist/src/stepwise/index.js +13 -0
- package/dist/src/stepwise/index.js.map +1 -0
- package/dist/src/stepwise/json-schema-validation.d.ts +9 -0
- package/dist/src/stepwise/json-schema-validation.js +141 -0
- package/dist/src/stepwise/json-schema-validation.js.map +1 -0
- package/dist/src/stepwise/model-client.d.ts +194 -0
- package/dist/src/stepwise/model-client.js +9 -0
- package/dist/src/stepwise/model-client.js.map +1 -0
- package/dist/src/stepwise/scripted-model-client.d.ts +99 -0
- package/dist/src/stepwise/scripted-model-client.js +156 -0
- package/dist/src/stepwise/scripted-model-client.js.map +1 -0
- package/dist/src/stepwise/stepwise-agent-runner.d.ts +171 -0
- package/dist/src/stepwise/stepwise-agent-runner.js +777 -0
- package/dist/src/stepwise/stepwise-agent-runner.js.map +1 -0
- package/dist/src/stepwise/stepwise-agent-session-flow.d.ts +35 -0
- package/dist/src/stepwise/stepwise-agent-session-flow.js +57 -0
- package/dist/src/stepwise/stepwise-agent-session-flow.js.map +1 -0
- package/dist/src/stepwise/stepwise-input-items.d.ts +12 -0
- package/dist/src/stepwise/stepwise-input-items.js +172 -0
- package/dist/src/stepwise/stepwise-input-items.js.map +1 -0
- package/dist/src/stepwise/tool-source.d.ts +103 -0
- package/dist/src/stepwise/tool-source.js +9 -0
- package/dist/src/stepwise/tool-source.js.map +1 -0
- package/dist/src/testing/agent-session-test-client.d.ts +65 -8
- package/dist/src/testing/agent-session-test-client.js +92 -22
- package/dist/src/testing/agent-session-test-client.js.map +1 -1
- package/dist/src/testing/context-window.d.ts +194 -0
- package/dist/src/testing/context-window.js +360 -0
- package/dist/src/testing/context-window.js.map +1 -0
- package/dist/src/testing/index.d.ts +2 -0
- package/dist/src/testing/index.js +2 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/testing/private-dex-engine.d.ts +9 -0
- package/dist/src/testing/private-dex-engine.js +9 -1
- package/dist/src/testing/private-dex-engine.js.map +1 -1
- package/dist/src/testing/scripted-model-client.d.ts +1 -0
- package/dist/src/testing/scripted-model-client.js +10 -0
- package/dist/src/testing/scripted-model-client.js.map +1 -0
- package/dist/src/ui-stream/agent-event-json.d.ts +30 -0
- package/dist/src/ui-stream/agent-event-json.js +64 -0
- package/dist/src/ui-stream/agent-event-json.js.map +1 -0
- package/dist/src/ui-stream/agent-event-sse.d.ts +155 -0
- package/dist/src/ui-stream/agent-event-sse.js +167 -0
- package/dist/src/ui-stream/agent-event-sse.js.map +1 -0
- package/dist/src/ui-stream/agent-event-stream-positions.d.ts +42 -0
- package/dist/src/ui-stream/agent-event-stream-positions.js +153 -0
- package/dist/src/ui-stream/agent-event-stream-positions.js.map +1 -0
- package/dist/src/ui-stream/agent-session-record-reader.d.ts +74 -0
- package/dist/src/ui-stream/agent-session-record-reader.js +246 -0
- package/dist/src/ui-stream/agent-session-record-reader.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-message-stream-responses.d.ts +219 -0
- package/dist/src/ui-stream/agent-ui-message-stream-responses.js +441 -0
- package/dist/src/ui-stream/agent-ui-message-stream-responses.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-message-stream.d.ts +138 -0
- package/dist/src/ui-stream/agent-ui-message-stream.js +695 -0
- package/dist/src/ui-stream/agent-ui-message-stream.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-message-types.d.ts +238 -0
- package/dist/src/ui-stream/agent-ui-message-types.js +57 -0
- package/dist/src/ui-stream/agent-ui-message-types.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-messages.d.ts +68 -0
- package/dist/src/ui-stream/agent-ui-messages.js +222 -0
- package/dist/src/ui-stream/agent-ui-messages.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-stream-cursor.d.ts +64 -0
- package/dist/src/ui-stream/agent-ui-stream-cursor.js +186 -0
- package/dist/src/ui-stream/agent-ui-stream-cursor.js.map +1 -0
- package/dist/src/ui-stream/index.d.ts +14 -0
- package/dist/src/ui-stream/index.js +22 -0
- package/dist/src/ui-stream/index.js.map +1 -0
- package/dist/src/ui-stream/server-sent-event-responses.d.ts +6 -0
- package/dist/src/ui-stream/server-sent-event-responses.js +34 -0
- package/dist/src/ui-stream/server-sent-event-responses.js.map +1 -0
- package/package.json +44 -5
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
import { ActiveStepSearchMode } from "@superdurable/dex";
|
|
9
|
+
import { validateSessionSettings } from "./agent-session-settings.js";
|
|
10
|
+
/**
|
|
11
|
+
* The search mode {@link startAgentSession} gives a new session.
|
|
12
|
+
*
|
|
13
|
+
* It indexes the Steps that wait, such as `AwaitToolApproval`, `AwaitQuestionAnswer`, and `AwaitUserMessage`, and
|
|
14
|
+
* leaves out Steps that run straight away, such as `RunModel`. So a session's search entry changes when it enters or
|
|
15
|
+
* leaves a wait, not on every Step.
|
|
16
|
+
*
|
|
17
|
+
* Pass it as `activeStepSearchMode` in `StartFlowOptions.configOverride` to `Client.startFlow`, in a SubFlow's
|
|
18
|
+
* `configOverride`, or to `Client.updateFlowConfig` for a running session.
|
|
19
|
+
*
|
|
20
|
+
* The value is `ActiveStepSearchMode.DEFAULT` because the Dex SDK this core supports has no `WITH_WAIT_FOR` value.
|
|
21
|
+
* It sends the unspecified mode, which the server stores on the Flow and treats as Steps with a wait.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.3.0
|
|
24
|
+
*/
|
|
25
|
+
export const agentSessionActiveStepSearchMode = ActiveStepSearchMode.DEFAULT;
|
|
26
|
+
/**
|
|
27
|
+
* Starts one agent session, searchable by the Steps it waits in.
|
|
28
|
+
*
|
|
29
|
+
* `ActiveStepTypes = "AwaitToolApproval"` then finds the session while a tool call waits for a person. Prefer this to
|
|
30
|
+
* `Client.startFlow`, which leaves the session out of that search unless `configOverride` sets
|
|
31
|
+
* {@link agentSessionActiveStepSearchMode}.
|
|
32
|
+
*
|
|
33
|
+
* Set `configOverride.activeStepSearchMode` to choose another mode. To leave a session out of the search, start it
|
|
34
|
+
* with `Client.startFlow` and no mode: the Dex SDK this core supports cannot send the disabled mode. A session started
|
|
35
|
+
* as a SubFlow inherits its parent's mode unless its `configOverride` sets one.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* await startAgentSession(client, flow, "session-42", { initialMessage: "Refund order 7" });
|
|
40
|
+
* const page = await client.searchFlows('ActiveStepTypes = "AwaitToolApproval"', 50);
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param client - An open Client whose Registry contains `flow`.
|
|
44
|
+
* @param flow - The registered agent session Flow.
|
|
45
|
+
* @param sessionId - Flow ID of the new session.
|
|
46
|
+
* @param input - The first user message and the session's settings.
|
|
47
|
+
* @param options - Start options, such as a Request ID for an idempotent start. `configOverride` keeps every field
|
|
48
|
+
* it sets.
|
|
49
|
+
* @returns The server-assigned run ID.
|
|
50
|
+
* @throws {TypeError | RangeError} From `validateSessionSettings`, before anything is sent.
|
|
51
|
+
* @throws {FlowAlreadyStartedError} When the Flow ID is already in use.
|
|
52
|
+
* @since 0.3.0
|
|
53
|
+
*/
|
|
54
|
+
export async function startAgentSession(client, flow, sessionId, input = {}, options = {}) {
|
|
55
|
+
const sessionSettings = input.sessionSettings ?? null;
|
|
56
|
+
if (sessionSettings !== null) {
|
|
57
|
+
validateSessionSettings(sessionSettings);
|
|
58
|
+
}
|
|
59
|
+
return client.startFlow(flow, sessionId, { initialMessage: input.initialMessage ?? null, sessionSettings }, {
|
|
60
|
+
...options,
|
|
61
|
+
configOverride: {
|
|
62
|
+
...options.configOverride,
|
|
63
|
+
activeStepSearchMode: options.configOverride?.activeStepSearchMode ?? agentSessionActiveStepSearchMode,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=agent-session-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-start.js","sourceRoot":"","sources":["../../src/agent-session-start.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,oBAAoB,EAAsC,MAAM,mBAAmB,CAAC;AAI7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGtE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAyB,oBAAoB,CAAC,OAAO,CAAC;AAEnG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,IAAiE,EACjE,SAAiB,EACjB,QAAyC,EAAE,EAC3C,UAA4B,EAAE;IAE9B,MAAM,eAAe,GAAG,KAAK,CAAC,eAAe,IAAI,IAAI,CAAC;IACtD,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,uBAAuB,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC,SAAS,CACrB,IAAI,EACJ,SAAS,EACT,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,IAAI,EAAE,eAAe,EAAE,EACjE;QACE,GAAG,OAAO;QACV,cAAc,EAAE;YACd,GAAG,OAAO,CAAC,cAAc;YACzB,oBAAoB,EAAE,OAAO,CAAC,cAAc,EAAE,oBAAoB,IAAI,gCAAgC;SACvG;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ExecuteFailure, type AttributeMapLoad, type RetryPolicy, type StepOptions } from "@superdurable/dex";
|
|
2
|
+
import type { AgentSessionPersistence } from "./agent-session-persistence.js";
|
|
3
|
+
export declare const minuteMs = 60000;
|
|
4
|
+
/**
|
|
5
|
+
* Sets how long one `RunModel` Step may run and how often it runs again.
|
|
6
|
+
*
|
|
7
|
+
* The defaults fit one model call. A harness runner, such as the Claude Agent SDK adapter, runs a whole turn segment
|
|
8
|
+
* in one `RunModel`: several model calls and inline tool calls. Raise {@link methodTimeoutMs} when a segment needs
|
|
9
|
+
* longer than 15 minutes.
|
|
10
|
+
*
|
|
11
|
+
* Background heartbeats continue through the Step, so a long silent call stays within the heartbeat timeout and
|
|
12
|
+
* `methodTimeoutMs` is its only cap. Dex ends an attempt at `methodTimeoutMs` and aborts its `cancellationSignal`. The
|
|
13
|
+
* next attempt reruns the whole segment and pays for it again, so consider `maximumAttempts: 1` for an expensive
|
|
14
|
+
* segment. A hung call holds its Worker slot until `methodTimeoutMs`, so do not set it higher than needed.
|
|
15
|
+
*
|
|
16
|
+
* The retry budget moves with these values. It is `methodTimeoutMs` times one less than `maximumAttempts`, and at least
|
|
17
|
+
* twice `methodTimeoutMs`, so the default limit gives 30 minutes. Dex checks it only after an attempt fails, and never
|
|
18
|
+
* ends a running attempt, so it must exceed `methodTimeoutMs` for a timed-out attempt to retry at all.
|
|
19
|
+
*
|
|
20
|
+
* `CompactContext` keeps the defaults, because it makes one model call. A changed limit applies to each `RunModel`
|
|
21
|
+
* scheduled after the Worker restarts. An attempt in flight, and its retries, keep their limit.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const flow = createClaudeAgentSessionFlow(agent, "SupportAgent", {
|
|
26
|
+
* runModelLimit: { methodTimeoutMs: 60 * 60_000, maximumAttempts: 2 },
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @since 0.3.0
|
|
31
|
+
*/
|
|
32
|
+
export interface RunModelLimit {
|
|
33
|
+
/** Longest one attempt may run, in milliseconds, a whole number of seconds. Defaults to 15 minutes. */
|
|
34
|
+
readonly methodTimeoutMs?: number;
|
|
35
|
+
/** Attempts, including the first. `1` disables retries. Defaults to 3. */
|
|
36
|
+
readonly maximumAttempts?: number;
|
|
37
|
+
}
|
|
38
|
+
/** A {@link RunModelLimit} with every default filled in and the retry budget it implies. */
|
|
39
|
+
export interface ResolvedRunModelLimit {
|
|
40
|
+
/** Longest one attempt may run, in milliseconds. */
|
|
41
|
+
readonly methodTimeoutMs: number;
|
|
42
|
+
/** Attempts, including the first. */
|
|
43
|
+
readonly maximumAttempts: number;
|
|
44
|
+
/** The retry budget in milliseconds. */
|
|
45
|
+
readonly totalDurationMs: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Fills in a {@link RunModelLimit}.
|
|
49
|
+
* @param limit - The application's limit.
|
|
50
|
+
* @returns The limit with its defaults and retry budget.
|
|
51
|
+
* @throws {RangeError} When `methodTimeoutMs` is not a positive whole number of seconds, `maximumAttempts` is not a
|
|
52
|
+
* positive integer, or the retry budget does not fit a signed 32-bit number of seconds.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveRunModelLimit(limit?: RunModelLimit): ResolvedRunModelLimit;
|
|
55
|
+
export declare const modelCallStepOptions: {
|
|
56
|
+
readonly executeMethodTimeoutMs: number;
|
|
57
|
+
readonly heartbeatTimeoutMs: number;
|
|
58
|
+
readonly executeRetry: {
|
|
59
|
+
readonly maximumAttempts: 3;
|
|
60
|
+
readonly totalDurationMs: number;
|
|
61
|
+
};
|
|
62
|
+
readonly executeFailure: ExecuteFailure;
|
|
63
|
+
};
|
|
64
|
+
export declare const recoveryRetry: RetryPolicy;
|
|
65
|
+
export declare const syncDurability: {
|
|
66
|
+
readonly waitForDurability: "sync";
|
|
67
|
+
readonly executeDurability: "sync";
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The archive chunks a Step reads on top of the whole `AgentMessages` window: exact instances, or every chunk
|
|
71
|
+
* when the model input covers them all.
|
|
72
|
+
*/
|
|
73
|
+
export interface MessageChunkLoads {
|
|
74
|
+
readonly isWholeMap: boolean;
|
|
75
|
+
readonly instances: readonly AttributeMapLoad[];
|
|
76
|
+
}
|
|
77
|
+
/** Returns the options of a Step that reads model input and stores messages, with its chunk loads. */
|
|
78
|
+
export declare function messageStepOptions(persistence: AgentSessionPersistence, stepType: string, chunkLoads: MessageChunkLoads, runModelLimit: ResolvedRunModelLimit): StepOptions;
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
import { ExecuteFailure, StepRef } from "@superdurable/dex";
|
|
9
|
+
import { agentSessionStepTypes } from "./agent-session-step-types.js";
|
|
10
|
+
export const minuteMs = 60_000;
|
|
11
|
+
const maxStepDurationMs = 2_147_483_647_000;
|
|
12
|
+
/**
|
|
13
|
+
* Fills in a {@link RunModelLimit}.
|
|
14
|
+
* @param limit - The application's limit.
|
|
15
|
+
* @returns The limit with its defaults and retry budget.
|
|
16
|
+
* @throws {RangeError} When `methodTimeoutMs` is not a positive whole number of seconds, `maximumAttempts` is not a
|
|
17
|
+
* positive integer, or the retry budget does not fit a signed 32-bit number of seconds.
|
|
18
|
+
*/
|
|
19
|
+
export function resolveRunModelLimit(limit = {}) {
|
|
20
|
+
const methodTimeoutMs = limit.methodTimeoutMs ?? modelCallStepOptions.executeMethodTimeoutMs;
|
|
21
|
+
if (!Number.isSafeInteger(methodTimeoutMs) || methodTimeoutMs < 1_000 || methodTimeoutMs % 1_000 !== 0) {
|
|
22
|
+
throw new RangeError("runModelLimit.methodTimeoutMs must be a whole number of seconds, at least one");
|
|
23
|
+
}
|
|
24
|
+
const maximumAttempts = limit.maximumAttempts ?? modelCallStepOptions.executeRetry.maximumAttempts;
|
|
25
|
+
if (!Number.isSafeInteger(maximumAttempts) || maximumAttempts < 1) {
|
|
26
|
+
throw new RangeError("runModelLimit.maximumAttempts must be positive");
|
|
27
|
+
}
|
|
28
|
+
const totalDurationMs = methodTimeoutMs * Math.max(maximumAttempts - 1, 2);
|
|
29
|
+
if (totalDurationMs > maxStepDurationMs) {
|
|
30
|
+
throw new RangeError("runModelLimit.methodTimeoutMs times maximumAttempts is too long for Dex");
|
|
31
|
+
}
|
|
32
|
+
return Object.freeze({ methodTimeoutMs, maximumAttempts, totalDurationMs });
|
|
33
|
+
}
|
|
34
|
+
// CompactContext makes one model call, so it shares RunModel's timeouts and retries.
|
|
35
|
+
export const modelCallStepOptions = {
|
|
36
|
+
executeMethodTimeoutMs: 15 * minuteMs,
|
|
37
|
+
heartbeatTimeoutMs: 2 * minuteMs,
|
|
38
|
+
executeRetry: { maximumAttempts: 3, totalDurationMs: 30 * minuteMs },
|
|
39
|
+
executeFailure: ExecuteFailure.proceedTo(new StepRef(agentSessionStepTypes.recordTurnFailure)),
|
|
40
|
+
};
|
|
41
|
+
// Recovery Steps must eventually run; cap their backoff so a returning Worker picks them up quickly.
|
|
42
|
+
export const recoveryRetry = { maximumIntervalMs: 5_000 };
|
|
43
|
+
// An ASYNC FlowConfig could replay a committed result after a Server failover, re-running a write.
|
|
44
|
+
export const syncDurability = { waitForDurability: "sync", executeDurability: "sync" };
|
|
45
|
+
/** Returns the options of a Step that reads model input and stores messages, with its chunk loads. */
|
|
46
|
+
export function messageStepOptions(persistence, stepType, chunkLoads, runModelLimit) {
|
|
47
|
+
const loads = {
|
|
48
|
+
executeLoadAttributeMaps: chunkLoads.isWholeMap
|
|
49
|
+
? [persistence.agentMessages, persistence.agentToolCalls, persistence.agentMessageChunks]
|
|
50
|
+
: [persistence.agentMessages, persistence.agentToolCalls],
|
|
51
|
+
...(chunkLoads.instances.length === 0 ? {} : { executeLoadAttributeMapInstances: chunkLoads.instances }),
|
|
52
|
+
};
|
|
53
|
+
switch (stepType) {
|
|
54
|
+
case agentSessionStepTypes.runModel:
|
|
55
|
+
return {
|
|
56
|
+
...syncDurability,
|
|
57
|
+
...modelCallStepOptions,
|
|
58
|
+
executeMethodTimeoutMs: runModelLimit.methodTimeoutMs,
|
|
59
|
+
executeRetry: {
|
|
60
|
+
maximumAttempts: runModelLimit.maximumAttempts,
|
|
61
|
+
totalDurationMs: runModelLimit.totalDurationMs,
|
|
62
|
+
},
|
|
63
|
+
...loads,
|
|
64
|
+
};
|
|
65
|
+
case agentSessionStepTypes.applyTurnControl:
|
|
66
|
+
return { ...syncDurability, executeRetry: recoveryRetry, ...loads };
|
|
67
|
+
default:
|
|
68
|
+
throw new TypeError(`Step type ${stepType} does not read the model input`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=agent-session-step-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-step-options.js","sourceRoot":"","sources":["../../src/agent-session-step-options.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Step types of every agent session Flow, shared with the Python core. */
|
|
2
|
+
export declare const agentSessionStepTypes: {
|
|
3
|
+
readonly startAgentSession: "StartAgentSession";
|
|
4
|
+
readonly awaitUserMessage: "AwaitUserMessage";
|
|
5
|
+
readonly runModel: "RunModel";
|
|
6
|
+
readonly compactContext: "CompactContext";
|
|
7
|
+
readonly awaitToolApproval: "AwaitToolApproval";
|
|
8
|
+
readonly awaitQuestionAnswer: "AwaitQuestionAnswer";
|
|
9
|
+
readonly awaitTimer: "AwaitTimer";
|
|
10
|
+
readonly callTool: "CallTool";
|
|
11
|
+
readonly callSingleAttemptTool: "CallSingleAttemptTool";
|
|
12
|
+
readonly pollToolTask: "PollToolTask";
|
|
13
|
+
readonly recordToolFailure: "RecordToolFailure";
|
|
14
|
+
readonly recordToolOutcomeUnknown: "RecordToolOutcomeUnknown";
|
|
15
|
+
readonly resumeTurn: "ResumeTurn";
|
|
16
|
+
readonly applyTurnControl: "ApplyTurnControl";
|
|
17
|
+
readonly recordTurnFailure: "RecordTurnFailure";
|
|
18
|
+
readonly finishTurnCancellation: "FinishTurnCancellation";
|
|
19
|
+
readonly cancelToolTask: "CancelToolTask";
|
|
20
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/** Step types of every agent session Flow, shared with the Python core. */
|
|
9
|
+
export const agentSessionStepTypes = {
|
|
10
|
+
startAgentSession: "StartAgentSession",
|
|
11
|
+
awaitUserMessage: "AwaitUserMessage",
|
|
12
|
+
runModel: "RunModel",
|
|
13
|
+
compactContext: "CompactContext",
|
|
14
|
+
awaitToolApproval: "AwaitToolApproval",
|
|
15
|
+
awaitQuestionAnswer: "AwaitQuestionAnswer",
|
|
16
|
+
awaitTimer: "AwaitTimer",
|
|
17
|
+
callTool: "CallTool",
|
|
18
|
+
callSingleAttemptTool: "CallSingleAttemptTool",
|
|
19
|
+
pollToolTask: "PollToolTask",
|
|
20
|
+
recordToolFailure: "RecordToolFailure",
|
|
21
|
+
recordToolOutcomeUnknown: "RecordToolOutcomeUnknown",
|
|
22
|
+
resumeTurn: "ResumeTurn",
|
|
23
|
+
applyTurnControl: "ApplyTurnControl",
|
|
24
|
+
recordTurnFailure: "RecordTurnFailure",
|
|
25
|
+
finishTurnCancellation: "FinishTurnCancellation",
|
|
26
|
+
cancelToolTask: "CancelToolTask",
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=agent-session-step-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-step-types.js","sourceRoot":"","sources":["../../src/agent-session-step-types.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,2EAA2E;AAC3E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,QAAQ,EAAE,UAAU;IACpB,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,mBAAmB,EAAE,qBAAqB;IAC1C,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,qBAAqB,EAAE,uBAAuB;IAC9C,YAAY,EAAE,cAAc;IAC5B,iBAAiB,EAAE,mBAAmB;IACtC,wBAAwB,EAAE,0BAA0B;IACpD,UAAU,EAAE,YAAY;IACxB,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,sBAAsB,EAAE,wBAAwB;IAChD,cAAc,EAAE,gBAAgB;CACxB,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { Wait, type AsyncContext, type Codec, type Context, type Step, type StepDecision, type StepOptions } from "@superdurable/dex";
|
|
1
|
+
import { StepMovement, Wait, type AsyncContext, type Codec, type Context, type RecoveryErrorInfo, type Step, type StepDecision, type StepOptions } from "@superdurable/dex";
|
|
2
|
+
import { type ToolInputRequested } from "./agent-framework-runner.js";
|
|
2
3
|
import { type AgentSessionTransitions } from "./agent-session-transitions.js";
|
|
3
|
-
import { type
|
|
4
|
+
import { type AgentSessionPersistence } from "./agent-session-persistence.js";
|
|
5
|
+
import { type AgentInterruptKind, type AgentSessionStartInput, type AgentToolCallRecord, type CompactContextInput, type PlanStatus } from "./agent-session-values.js";
|
|
6
|
+
/** Start of the Flow failure reason when `StartAgentSession` refuses the start input's settings. */
|
|
7
|
+
export declare const invalidStartSessionSettingsReason = "dex-agents: the start input's session_settings are not valid session settings";
|
|
4
8
|
export declare class StartAgentSessionStep implements Step<AgentSessionStartInput> {
|
|
5
9
|
private readonly transitions;
|
|
6
10
|
readonly inputCodec: Codec<AgentSessionStartInput>;
|
|
@@ -9,15 +13,19 @@ export declare class StartAgentSessionStep implements Step<AgentSessionStartInpu
|
|
|
9
13
|
getStepOptions(): StepOptions;
|
|
10
14
|
execute(context: Context, input: AgentSessionStartInput): StepDecision;
|
|
11
15
|
}
|
|
16
|
+
/** Waits for one queued user message, or an approved plan execution, and starts its turn. */
|
|
12
17
|
export declare class AwaitUserMessageStep implements Step<void> {
|
|
13
18
|
private readonly transitions;
|
|
14
19
|
readonly inputCodec: Codec<void>;
|
|
15
20
|
constructor(transitions: AgentSessionTransitions);
|
|
16
21
|
getStepType(): string;
|
|
17
22
|
getStepOptions(): StepOptions;
|
|
18
|
-
waitFor(): Wait;
|
|
23
|
+
waitFor(context: Context): Wait;
|
|
19
24
|
execute(context: Context): StepDecision;
|
|
25
|
+
private beginUserMessageTurn;
|
|
20
26
|
}
|
|
27
|
+
/** Plan statuses that `execute_plan` accepts and `AwaitUserMessage` waits for. */
|
|
28
|
+
export declare function isExecutablePlanStatus(status: PlanStatus): boolean;
|
|
21
29
|
/** Makes the turn's next model call and fans the requested tool calls out to parallel Steps. */
|
|
22
30
|
export declare class RunModelStep implements Step<void> {
|
|
23
31
|
private readonly transitions;
|
|
@@ -26,8 +34,31 @@ export declare class RunModelStep implements Step<void> {
|
|
|
26
34
|
getStepType(): string;
|
|
27
35
|
getStepOptions(): StepOptions;
|
|
28
36
|
execute(context: AsyncContext): Promise<StepDecision>;
|
|
37
|
+
/** Returns RunModel's move instead of a model call, or `null` to call the model. */
|
|
38
|
+
private decideBeforeModelCall;
|
|
29
39
|
private completeTurn;
|
|
40
|
+
/** Returns the sequence to summarize through before this model call, or `null` to make the call. */
|
|
41
|
+
private selectCompactionBeforeModelCall;
|
|
42
|
+
private startCompaction;
|
|
30
43
|
private requestToolCalls;
|
|
44
|
+
/** A planning turn hides executable tools; a call to one never runs. */
|
|
45
|
+
private rejectPlanningTurnToolCall;
|
|
46
|
+
private deferApplicationToolCall;
|
|
47
|
+
/** Records a built-in call with its fixed policy and routes it to its wait Step; invalid arguments fail at once. */
|
|
48
|
+
private deferBuiltInToolCall;
|
|
49
|
+
/** Replaces the plan and records the call final, in this commit; no tool Step runs. */
|
|
50
|
+
private writeTodos;
|
|
51
|
+
private failBuiltInToolCall;
|
|
52
|
+
}
|
|
53
|
+
/** Summarizes the messages through a sequence for the model input, then moves back to `RunModel`. */
|
|
54
|
+
export declare class CompactContextStep implements Step<CompactContextInput | undefined> {
|
|
55
|
+
private readonly transitions;
|
|
56
|
+
readonly inputCodec: Codec<CompactContextInput | undefined>;
|
|
57
|
+
constructor(transitions: AgentSessionTransitions);
|
|
58
|
+
getStepType(): string;
|
|
59
|
+
getStepOptions(): StepOptions;
|
|
60
|
+
execute(context: AsyncContext, input: CompactContextInput | undefined): Promise<StepDecision>;
|
|
61
|
+
private summarize;
|
|
31
62
|
}
|
|
32
63
|
/** Waits for one tool call's approval or its deadline, then runs or rejects the call. */
|
|
33
64
|
export declare class AwaitToolApprovalStep implements Step<string> {
|
|
@@ -38,8 +69,8 @@ export declare class AwaitToolApprovalStep implements Step<string> {
|
|
|
38
69
|
getStepOptions(): StepOptions;
|
|
39
70
|
waitFor(context: Context, toolCallId: string): Wait;
|
|
40
71
|
execute(context: Context, toolCallId: string): StepDecision;
|
|
72
|
+
private applyResolution;
|
|
41
73
|
private rejectToolCall;
|
|
42
|
-
private writeInterruptResolved;
|
|
43
74
|
}
|
|
44
75
|
/** Runs one tool call; one class serves `CallTool` and `CallSingleAttemptTool`. */
|
|
45
76
|
export declare class ToolCallStep implements Step<string> {
|
|
@@ -50,11 +81,16 @@ export declare class ToolCallStep implements Step<string> {
|
|
|
50
81
|
getStepType(): string;
|
|
51
82
|
getStepOptions(): StepOptions;
|
|
52
83
|
execute(context: AsyncContext, toolCallId: string): Promise<StepDecision>;
|
|
84
|
+
/** Records `awaiting_answer` with the tool's question; `AwaitQuestionAnswer` raises it under the lock. */
|
|
85
|
+
private requestToolInput;
|
|
86
|
+
/** Records `waiting_for_task` and moves to `PollToolTask`, or records a task it cannot poll by effect. */
|
|
87
|
+
private startToolTask;
|
|
53
88
|
}
|
|
54
89
|
/**
|
|
55
90
|
* Failure route of a tool Step; it receives the failed Step's input, the tool call ID.
|
|
56
91
|
* `RecordToolFailure` records `failed` for a `read` call and `outcome_unknown` for a write;
|
|
57
|
-
* `RecordToolOutcomeUnknown` always records `outcome_unknown`.
|
|
92
|
+
* `RecordToolOutcomeUnknown` always records `outcome_unknown`. Either records `failed` with
|
|
93
|
+
* {@link toolCallNotRunErrorPrefix} when the tool certainly never ran.
|
|
58
94
|
*/
|
|
59
95
|
export declare class ToolCallFailureRecordingStep implements Step<string> {
|
|
60
96
|
private readonly transitions;
|
|
@@ -66,7 +102,14 @@ export declare class ToolCallFailureRecordingStep implements Step<string> {
|
|
|
66
102
|
getStepOptions(): StepOptions;
|
|
67
103
|
execute(context: Context, toolCallId: string): StepDecision;
|
|
68
104
|
}
|
|
69
|
-
/**
|
|
105
|
+
/** Returns the final record that a tool Step's failure route writes. */
|
|
106
|
+
export declare function recoveredToolCall(toolCall: AgentToolCallRecord, recoveryError: RecoveryErrorInfo | undefined, status: "failed" | "outcome_unknown"): AgentToolCallRecord;
|
|
107
|
+
/**
|
|
108
|
+
* Waits until every tool call of the batch has a final record, then makes the next model call.
|
|
109
|
+
*
|
|
110
|
+
* A steer wakes it early: it cancels the turn's pending interrupts and Timers, and waits again. After a steer or
|
|
111
|
+
* `cancel_turn`, once every result is in, it moves to `ApplyTurnControl` instead of `RunModel`.
|
|
112
|
+
*/
|
|
70
113
|
export declare class ResumeTurnStep implements Step<number> {
|
|
71
114
|
private readonly transitions;
|
|
72
115
|
readonly inputCodec: Codec<number>;
|
|
@@ -74,13 +117,65 @@ export declare class ResumeTurnStep implements Step<number> {
|
|
|
74
117
|
getStepType(): string;
|
|
75
118
|
getStepOptions(): StepOptions;
|
|
76
119
|
waitFor(_context: Context, expectedResultCount: number): Wait;
|
|
77
|
-
execute(context: Context): StepDecision;
|
|
120
|
+
execute(context: Context, expectedResultCount: number): StepDecision;
|
|
121
|
+
/** Cancels the turn's pending interrupts and wakes each Step waiting for a person or a Timer. */
|
|
122
|
+
private wakeWaitingToolCalls;
|
|
78
123
|
}
|
|
79
|
-
|
|
124
|
+
/** Ends a steered or cancelled turn, then starts a turn with the steered messages. */
|
|
125
|
+
export declare class ApplyTurnControlStep implements Step<void> {
|
|
80
126
|
private readonly transitions;
|
|
81
127
|
readonly inputCodec: Codec<void>;
|
|
82
128
|
constructor(transitions: AgentSessionTransitions);
|
|
83
129
|
getStepType(): string;
|
|
84
130
|
getStepOptions(): StepOptions;
|
|
131
|
+
waitFor(): Wait;
|
|
85
132
|
execute(context: Context): StepDecision;
|
|
86
133
|
}
|
|
134
|
+
/** Ends a failed turn; it is the failure route of `RunModel` and `CompactContext`, so it takes either's input. */
|
|
135
|
+
export declare class RecordTurnFailureStep implements Step<CompactContextInput | undefined> {
|
|
136
|
+
private readonly transitions;
|
|
137
|
+
readonly inputCodec: Codec<CompactContextInput | undefined>;
|
|
138
|
+
constructor(transitions: AgentSessionTransitions);
|
|
139
|
+
getStepType(): string;
|
|
140
|
+
getStepOptions(): StepOptions;
|
|
141
|
+
execute(context: Context): StepDecision;
|
|
142
|
+
}
|
|
143
|
+
/** Reports whether a Step failed because its commit would exceed the Flow's state limit. */
|
|
144
|
+
export declare function isStateLimitFailure(recoveryError: RecoveryErrorInfo | undefined): boolean;
|
|
145
|
+
/** `last_turn_error` of a turn whose runner stored messages incrementally without the builder. */
|
|
146
|
+
export declare const missingUnfinishedTurnMessageBuilder = "a runner that sets ToolCallsRequested.newMessages must implement buildUnfinishedTurnMessages";
|
|
147
|
+
/**
|
|
148
|
+
* Returns the full options of a tool Step type. With a tool call ID, the Step loads only that call's
|
|
149
|
+
* record; a movement's options replace the Step's static options, so every option is repeated here.
|
|
150
|
+
*/
|
|
151
|
+
export declare function toolStepOptions(persistence: AgentSessionPersistence, stepType: string, toolCallId?: string): StepOptions;
|
|
152
|
+
export declare function toolStepMovement(persistence: AgentSessionPersistence, stepType: string, toolCallId: string): StepMovement<string>;
|
|
153
|
+
/** Moves to `PollToolTask`; a poll that keeps failing leaves the task running, so the call is recorded by effect. */
|
|
154
|
+
export declare function toolTaskPollMovement(persistence: AgentSessionPersistence, toolCall: AgentToolCallRecord): StepMovement<string>;
|
|
155
|
+
/** Returns the record of a tool's question: `awaiting_answer`, or `failed` when it is blank. */
|
|
156
|
+
export declare function recordToolInputRequest(toolCall: AgentToolCallRecord, request: ToolInputRequested): AgentToolCallRecord;
|
|
157
|
+
/** Returns a final record for a task that cannot be polled: `failed` for a read, else `outcome_unknown`. */
|
|
158
|
+
export declare function recordToolTaskDefect(toolCall: AgentToolCallRecord, error: string): AgentToolCallRecord;
|
|
159
|
+
/** Returns a poll interval in whole seconds from 1 to a day, or `null` when it is not a finite number. */
|
|
160
|
+
export declare function toolTaskPollIntervalSeconds(seconds: unknown): number | null;
|
|
161
|
+
/** Record fields of a call without a pending tool question. */
|
|
162
|
+
export declare const noPendingToolQuestion: {
|
|
163
|
+
readonly inputQuestion: null;
|
|
164
|
+
readonly inputChoices: readonly [];
|
|
165
|
+
readonly inputAllowsFreeText: true;
|
|
166
|
+
};
|
|
167
|
+
/** Moves to `AwaitQuestionAnswer`, which reads the answer count to tell an unraised question from an answer. */
|
|
168
|
+
export declare function questionAnswerMovement(persistence: AgentSessionPersistence, toolCall: AgentToolCallRecord): StepMovement<string>;
|
|
169
|
+
/** An `ask_user` question uses the tool call ID; a tool's `n`-th question appends `-input-<n>`. */
|
|
170
|
+
export declare function questionInterruptId(toolCall: AgentToolCallRecord): string;
|
|
171
|
+
/** The interrupt a waiting tool call answers to: its ID and kind. */
|
|
172
|
+
export interface WaitingToolCallInterrupt {
|
|
173
|
+
readonly interruptId: string;
|
|
174
|
+
readonly kind: AgentInterruptKind;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Records a call that `ToolCallCancellations` woke as cancelled, or waits again. Pass `interrupt` `null` for a
|
|
178
|
+
* durable wait.
|
|
179
|
+
*/
|
|
180
|
+
export declare function cancelWaitingToolCall(transitions: AgentSessionTransitions, context: Context, toolCall: AgentToolCallRecord, interrupt: WaitingToolCallInterrupt | null, waitAgain: StepMovement<string>): StepDecision;
|
|
181
|
+
export declare function isToolInputRequested(outcome: unknown): outcome is ToolInputRequested;
|