@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
|
@@ -45,10 +45,10 @@ export function addAgentUsage(left, right) {
|
|
|
45
45
|
*
|
|
46
46
|
* @param status - Status to classify.
|
|
47
47
|
* @returns `true` for `rejected`, `succeeded`, `failed`, and `outcome_unknown`; `false` for
|
|
48
|
-
* `awaiting_approval` and
|
|
48
|
+
* `awaiting_approval`, `approved`, and every {@link AgentToolCallWaitingStatus}.
|
|
49
49
|
*/
|
|
50
50
|
export function isFinalToolCallStatus(status) {
|
|
51
|
-
return status
|
|
51
|
+
return (status === "rejected" || status === "succeeded" || status === "failed" || status === "outcome_unknown");
|
|
52
52
|
}
|
|
53
53
|
/** Tool result text the model sees for an `outcome_unknown` call; the same text as the Python core. */
|
|
54
54
|
export const outcomeUnknownToolResult = "The tool call's outcome is unknown: it stopped without returning a result, so it may " +
|
|
@@ -61,6 +61,34 @@ export const turnFailureNoteFooter = "Do not repeat these tool calls unless the
|
|
|
61
61
|
export const defaultRejectionToolResult = "The user rejected this tool call.";
|
|
62
62
|
/** Rejection message recorded when an approval deadline passes. */
|
|
63
63
|
export const approvalDeadlinePassed = "approval deadline passed";
|
|
64
|
+
/** Rejection message recorded when a question's deadline passes. */
|
|
65
|
+
export const questionDeadlinePassed = "question deadline passed";
|
|
66
|
+
/** Tool result text the model sees when the user declines a question without a message, or with an empty one. */
|
|
67
|
+
export const defaultQuestionDeclinedToolResult = "The user declined to answer.";
|
|
68
|
+
/** First line of the note `ApplyTurnControl` stores after a steered turn ran tools. */
|
|
69
|
+
export const turnSteeredNoteHeader = "[Dex] The user steered the conversation after these tool calls ran:";
|
|
70
|
+
/** First line of the note `ApplyTurnControl` stores after a cancelled turn ran tools. */
|
|
71
|
+
export const turnCancelledNoteHeader = "[Dex] The user stopped the previous turn after these tool calls ran:";
|
|
72
|
+
/** Model-visible result of a tool call that steering abandoned before it started; the same text as the Python core. */
|
|
73
|
+
export const toolCallCancelledBySteeringResult = '{"status":"cancelled","reason":"superseded_by_steered_user_message"}';
|
|
74
|
+
/** Model-visible result of a tool call that `cancel_turn` abandoned before it started. */
|
|
75
|
+
export const toolCallCancelledByTurnCancellationResult = '{"status":"cancelled","reason":"turn_cancelled_by_user"}';
|
|
76
|
+
/**
|
|
77
|
+
* Error recorded when a tool returns {@link ToolTaskStarted} to a runner without
|
|
78
|
+
* {@link AgentFrameworkRunner.pollToolTask}. The Python core names its method `poll_tool_task`.
|
|
79
|
+
*/
|
|
80
|
+
export const missingToolTaskPoller = "the tool started a task, but the runner does not implement pollToolTask";
|
|
81
|
+
/** Error recorded when a {@link ToolTaskStarted} has a blank `taskId`; the same text as the Python core. */
|
|
82
|
+
export const blankToolTaskId = "the tool started a task without a task ID";
|
|
83
|
+
/** Error recorded when a task's poll interval is not a number; the same text as the Python core. */
|
|
84
|
+
export const invalidToolTaskPollInterval = "the tool task's poll interval is not a number";
|
|
85
|
+
/** Error of an `outcome_unknown` record whose task `cancel_turn` abandoned; the same text as the Python core. */
|
|
86
|
+
export const toolTaskAbandonedError = "the turn was cancelled while the tool's task was running; the task may have taken effect";
|
|
87
|
+
/**
|
|
88
|
+
* Start of the `error` of a `failed` record whose tool Step certainly never ran the tool; the same text as the
|
|
89
|
+
* Python core.
|
|
90
|
+
*/
|
|
91
|
+
export const toolCallNotRunErrorPrefix = "the tool did not run, so it is safe to call again";
|
|
64
92
|
/**
|
|
65
93
|
* Returns the note text that tells the model what a failed turn already did.
|
|
66
94
|
*
|
|
@@ -81,7 +109,11 @@ export const approvalDeadlinePassed = "approval deadline passed";
|
|
|
81
109
|
* @throws {TypeError} When a record is not final.
|
|
82
110
|
*/
|
|
83
111
|
export function buildTurnFailureNote(toolCalls) {
|
|
84
|
-
|
|
112
|
+
return buildToolCallNote(turnFailureNoteHeader, toolCalls);
|
|
113
|
+
}
|
|
114
|
+
/** Returns a note in the turn-failure note's line format with another first line. */
|
|
115
|
+
export function buildToolCallNote(header, toolCalls) {
|
|
116
|
+
const lines = [header];
|
|
85
117
|
for (const toolCall of [...toolCalls].sort((left, right) => left.deferralOrder - right.deferralOrder)) {
|
|
86
118
|
const outcome = describeToolCallOutcome(toolCall);
|
|
87
119
|
lines.push(`- ${toolCall.toolName} ${toolCall.arguments} -> ${toolCall.status}: ${outcome}`);
|
|
@@ -107,7 +139,7 @@ export function buildTurnFailureNote(toolCalls) {
|
|
|
107
139
|
* @returns The output for `succeeded`; `The tool call failed: <error>` for `failed`; the rejection
|
|
108
140
|
* message, or {@link defaultRejectionToolResult}, for `rejected`; {@link outcomeUnknownToolResult}
|
|
109
141
|
* for `outcome_unknown`.
|
|
110
|
-
* @throws {TypeError} When the record status is
|
|
142
|
+
* @throws {TypeError} When the record status is not final.
|
|
111
143
|
*/
|
|
112
144
|
export function describeToolCallOutcome(toolCall) {
|
|
113
145
|
switch (toolCall.status) {
|
|
@@ -121,6 +153,9 @@ export function describeToolCallOutcome(toolCall) {
|
|
|
121
153
|
return outcomeUnknownToolResult;
|
|
122
154
|
case "awaiting_approval":
|
|
123
155
|
case "approved":
|
|
156
|
+
case "awaiting_answer":
|
|
157
|
+
case "waiting_for_timer":
|
|
158
|
+
case "waiting_for_task":
|
|
124
159
|
throw new TypeError(`tool call ${toolCall.toolCallId} has no final outcome yet`);
|
|
125
160
|
}
|
|
126
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-values.js","sourceRoot":"","sources":["../../src/agent-session-values.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;
|
|
1
|
+
{"version":3,"file":"agent-session-values.js","sourceRoot":"","sources":["../../src/agent-session-values.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAi+B1D;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,CAAC;QACf,iBAAiB,EAAE,CAAC;QACpB,eAAe,EAAE,CAAC;KACnB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,IAAgB,EAAE,KAAiB;IAC/D,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;QAC9C,WAAW,EAAE,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW;QACjD,YAAY,EAAE,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY;QACpD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB;QACnE,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A0B,CAAC;QACjE,KAAK,iBAAiB;YACpB,OAAO,wBAAwB,CAAC;QAClC,KAAK,mBAAmB,CAAC;QACzB,KAAK,UAAU,CAAC;QAChB,KAAK,iBAAiB,CAAC;QACvB,KAAK,mBAAmB,CAAC;QACzB,KAAK,kBAAkB;YACrB,MAAM,IAAI,SAAS,CAAC,aAAa,QAAQ,CAAC,UAAU,2BAA2B,CAAC,CAAC;IACrF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Wait, type AsyncContext, type Context, type Step, type StepDecision, type StepOptions } from "@superdurable/dex";
|
|
2
|
+
import { type AgentSessionTransitions } from "./agent-session-transitions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Waits for the answer to one question: an `ask_user` call, or a tool's {@link ToolInputRequested}.
|
|
5
|
+
*
|
|
6
|
+
* `RunModel` raises an `ask_user` question in its own commit. A tool Step runs unlocked, so it only
|
|
7
|
+
* records its question, and this Step's first Execute raises it under the `PendingInterrupts` lock.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AwaitQuestionAnswerStep implements Step<string> {
|
|
10
|
+
private readonly transitions;
|
|
11
|
+
readonly inputCodec: import("@superdurable/dex").Codec<string>;
|
|
12
|
+
constructor(transitions: AgentSessionTransitions);
|
|
13
|
+
getStepType(): string;
|
|
14
|
+
getStepOptions(): StepOptions;
|
|
15
|
+
waitFor(context: Context, toolCallId: string): Wait;
|
|
16
|
+
execute(context: Context, toolCallId: string): StepDecision;
|
|
17
|
+
/**
|
|
18
|
+
* A tool question's `<id>-input-<n>` is taken when another call's interrupt is pending under it or a
|
|
19
|
+
* record has that key, as in the Python core.
|
|
20
|
+
*/
|
|
21
|
+
private isInterruptIdOwnedByAnotherCall;
|
|
22
|
+
/** A tool's question waits to be raised when it is neither pending nor answered. */
|
|
23
|
+
private isToolQuestionUnraised;
|
|
24
|
+
private raiseToolQuestion;
|
|
25
|
+
private resolveQuestion;
|
|
26
|
+
/** Hands a started task's question back to it; its result, not `rejected`, ends the call. */
|
|
27
|
+
private returnQuestionToTask;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Polls one tool's remote task after its poll interval, until the task finishes.
|
|
31
|
+
*
|
|
32
|
+
* A tool Step that received {@link ToolTaskStarted} moves here. Each execution waits on a Timer, calls
|
|
33
|
+
* the runner's `pollToolTask` once, and records the result, asks the task's question, or moves to itself.
|
|
34
|
+
*/
|
|
35
|
+
export declare class PollToolTaskStep implements Step<string> {
|
|
36
|
+
private readonly transitions;
|
|
37
|
+
readonly inputCodec: import("@superdurable/dex").Codec<string>;
|
|
38
|
+
constructor(transitions: AgentSessionTransitions);
|
|
39
|
+
getStepType(): string;
|
|
40
|
+
getStepOptions(): StepOptions;
|
|
41
|
+
waitFor(context: Context, toolCallId: string): Wait;
|
|
42
|
+
execute(context: AsyncContext, toolCallId: string): Promise<StepDecision>;
|
|
43
|
+
}
|
|
44
|
+
/** Waits on a Dex Timer for one `durable_wait` call, then records its result. */
|
|
45
|
+
export declare class AwaitTimerStep implements Step<string> {
|
|
46
|
+
private readonly transitions;
|
|
47
|
+
readonly inputCodec: import("@superdurable/dex").Codec<string>;
|
|
48
|
+
constructor(transitions: AgentSessionTransitions);
|
|
49
|
+
getStepType(): string;
|
|
50
|
+
getStepOptions(): StepOptions;
|
|
51
|
+
waitFor(context: Context, toolCallId: string): Wait;
|
|
52
|
+
execute(context: Context, toolCallId: string): StepDecision;
|
|
53
|
+
}
|
|
@@ -0,0 +1,389 @@
|
|
|
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 { Timer, Wait, deadEnd, goToMany, stringCodec, } from "@superdurable/dex";
|
|
9
|
+
import { buildDurableWaitCompletedOutput, buildQuestionAnsweredOutput } from "./agent-built-in-tools.js";
|
|
10
|
+
import { ToolExecutionError, } from "./agent-framework-runner.js";
|
|
11
|
+
import { cancelWaitingToolCall, isToolInputRequested, noPendingToolQuestion, questionAnswerMovement, questionInterruptId, recordToolInputRequest, recordToolTaskDefect, toolStepMovement, toolStepOptions, toolTaskPollIntervalSeconds, toolTaskPollMovement, } from "./agent-session-steps.js";
|
|
12
|
+
import { agentSessionStepTypes, cancelledToolCall, finishTurnCancellationMovement, isCancellableByTurnControl, toolStepTypeForEffect, } from "./agent-session-transitions.js";
|
|
13
|
+
import { defaultQuestionDeclinedToolResult, invalidToolTaskPollInterval, isFinalToolCallStatus, missingToolTaskPoller, questionDeadlinePassed, } from "./agent-session-values.js";
|
|
14
|
+
/**
|
|
15
|
+
* Waits for the answer to one question: an `ask_user` call, or a tool's {@link ToolInputRequested}.
|
|
16
|
+
*
|
|
17
|
+
* `RunModel` raises an `ask_user` question in its own commit. A tool Step runs unlocked, so it only
|
|
18
|
+
* records its question, and this Step's first Execute raises it under the `PendingInterrupts` lock.
|
|
19
|
+
*/
|
|
20
|
+
export class AwaitQuestionAnswerStep {
|
|
21
|
+
transitions;
|
|
22
|
+
inputCodec = stringCodec;
|
|
23
|
+
constructor(transitions) {
|
|
24
|
+
this.transitions = transitions;
|
|
25
|
+
}
|
|
26
|
+
getStepType() {
|
|
27
|
+
return agentSessionStepTypes.awaitQuestionAnswer;
|
|
28
|
+
}
|
|
29
|
+
getStepOptions() {
|
|
30
|
+
return toolStepOptions(this.transitions.persistence, agentSessionStepTypes.awaitQuestionAnswer);
|
|
31
|
+
}
|
|
32
|
+
waitFor(context, toolCallId) {
|
|
33
|
+
const transitions = this.transitions;
|
|
34
|
+
const toolCall = transitions.readToolCall(context, toolCallId);
|
|
35
|
+
const interruptId = questionInterruptId(toolCall);
|
|
36
|
+
if (this.isInterruptIdOwnedByAnotherCall(context, toolCall, interruptId)) {
|
|
37
|
+
// Never wait on the other call's answers; Execute fails this call at once.
|
|
38
|
+
return Wait.until(Timer.byDuration(0));
|
|
39
|
+
}
|
|
40
|
+
const conditions = [
|
|
41
|
+
transitions.persistence.toolCallCancellations.forOne(toolCallId),
|
|
42
|
+
transitions.persistence.interruptResolutions.forOne(interruptId),
|
|
43
|
+
];
|
|
44
|
+
// After answer_question removed the interrupt, its deadline no longer applies.
|
|
45
|
+
const interrupt = transitions
|
|
46
|
+
.readPendingInterrupts(context)
|
|
47
|
+
.find((pendingInterrupt) => pendingInterrupt.interruptId === interruptId);
|
|
48
|
+
if (interrupt?.deadline != null) {
|
|
49
|
+
// Dex Timers take whole seconds; rounding up can only fire late, never early.
|
|
50
|
+
const remainingMs = Math.max(0, Date.parse(interrupt.deadline) - Date.now());
|
|
51
|
+
conditions.push(Timer.byDuration(Math.ceil(remainingMs / 1_000) * 1_000));
|
|
52
|
+
}
|
|
53
|
+
else if (this.isToolQuestionUnraised(context, toolCall, interruptId)) {
|
|
54
|
+
// Execute holds the PendingInterrupts lock, so it raises the tool's question at once.
|
|
55
|
+
conditions.push(Timer.byDuration(0));
|
|
56
|
+
}
|
|
57
|
+
return Wait.anyOf(...conditions);
|
|
58
|
+
}
|
|
59
|
+
execute(context, toolCallId) {
|
|
60
|
+
const transitions = this.transitions;
|
|
61
|
+
const persistence = transitions.persistence;
|
|
62
|
+
const toolCall = transitions.readToolCall(context, toolCallId);
|
|
63
|
+
if (toolCall.status !== "awaiting_answer") {
|
|
64
|
+
return deadEnd();
|
|
65
|
+
}
|
|
66
|
+
const interruptId = questionInterruptId(toolCall);
|
|
67
|
+
if (this.isInterruptIdOwnedByAnotherCall(context, toolCall, interruptId)) {
|
|
68
|
+
const error = `the tool's question cannot use interrupt ID ${interruptId}, which another tool call of this turn uses`;
|
|
69
|
+
transitions.finishToolCall(context,
|
|
70
|
+
// A started task may have taken effect, so its call is recorded by effect.
|
|
71
|
+
(toolCall.taskId ?? null) !== null
|
|
72
|
+
? recordToolTaskDefect(toolCall, error)
|
|
73
|
+
: { ...toolCall, status: "failed", error, ...noPendingToolQuestion });
|
|
74
|
+
return deadEnd();
|
|
75
|
+
}
|
|
76
|
+
if (context.channelResults(persistence.toolCallCancellations, toolCallId).length > 0) {
|
|
77
|
+
return cancelWaitingToolCall(transitions, context, toolCall, { interruptId, kind: "question" }, questionAnswerMovement(persistence, toolCall));
|
|
78
|
+
}
|
|
79
|
+
const [resolution] = context.channelResults(persistence.interruptResolutions, interruptId);
|
|
80
|
+
if (resolution !== undefined) {
|
|
81
|
+
return this.resolveQuestion(context, toolCall, interruptId, resolution);
|
|
82
|
+
}
|
|
83
|
+
if (!context.hasTimerFired()) {
|
|
84
|
+
throw new Error(`the question wait for ${interruptId} completed without an answer`);
|
|
85
|
+
}
|
|
86
|
+
if (this.isToolQuestionUnraised(context, toolCall, interruptId)) {
|
|
87
|
+
if (transitions.isTurnCancelled(context, toolCall.turnId) && (toolCall.taskId ?? null) !== null) {
|
|
88
|
+
// cancel_turn abandons a started task instead of asking its question.
|
|
89
|
+
return goToMany(finishTurnCancellationMovement(toolCall.turnId));
|
|
90
|
+
}
|
|
91
|
+
const reason = transitions.readTurnControlReason(context, toolCall.turnId);
|
|
92
|
+
if (reason !== null && isCancellableByTurnControl(toolCall)) {
|
|
93
|
+
// The turn is steered or cancelled, so the tool's question is never asked.
|
|
94
|
+
transitions.finishToolCall(context, cancelledToolCall(toolCall, reason));
|
|
95
|
+
return deadEnd();
|
|
96
|
+
}
|
|
97
|
+
this.raiseToolQuestion(context, toolCall, interruptId);
|
|
98
|
+
return goToMany(questionAnswerMovement(persistence, toolCall));
|
|
99
|
+
}
|
|
100
|
+
const pendingInterrupts = transitions.readPendingInterrupts(context);
|
|
101
|
+
const interrupt = pendingInterrupts.find((pending) => pending.interruptId === interruptId);
|
|
102
|
+
// An early Timer, or an answer that the next wait consumes.
|
|
103
|
+
if (interrupt?.deadline == null || Date.parse(interrupt.deadline) > Date.now()) {
|
|
104
|
+
return goToMany(questionAnswerMovement(persistence, toolCall));
|
|
105
|
+
}
|
|
106
|
+
persistence.pendingInterrupts.set(context, pendingInterrupts.filter((pending) => pending.interruptId !== interruptId));
|
|
107
|
+
return this.resolveQuestion(context, toolCall, interruptId, { approved: false, rejectionMessage: questionDeadlinePassed, answer: null }, true);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A tool question's `<id>-input-<n>` is taken when another call's interrupt is pending under it or a
|
|
111
|
+
* record has that key, as in the Python core.
|
|
112
|
+
*/
|
|
113
|
+
isInterruptIdOwnedByAnotherCall(context, toolCall, interruptId) {
|
|
114
|
+
if (toolCall.status !== "awaiting_answer" || toolCall.inputQuestion === null) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const transitions = this.transitions;
|
|
118
|
+
const pending = transitions.readPendingInterrupts(context).find((interrupt) => interrupt.interruptId === interruptId);
|
|
119
|
+
if (pending !== undefined && pending.toolCallId !== toolCall.toolCallId) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return transitions.persistence.agentToolCalls.get(context, interruptId) !== undefined;
|
|
123
|
+
}
|
|
124
|
+
/** A tool's question waits to be raised when it is neither pending nor answered. */
|
|
125
|
+
isToolQuestionUnraised(context, toolCall, interruptId) {
|
|
126
|
+
const transitions = this.transitions;
|
|
127
|
+
return (toolCall.status === "awaiting_answer" &&
|
|
128
|
+
toolCall.inputQuestion !== null &&
|
|
129
|
+
!transitions.readPendingInterrupts(context).some((pending) => pending.interruptId === interruptId) &&
|
|
130
|
+
context.channelSize(transitions.persistence.interruptResolutions, interruptId) === 0);
|
|
131
|
+
}
|
|
132
|
+
raiseToolQuestion(context, toolCall, interruptId) {
|
|
133
|
+
const transitions = this.transitions;
|
|
134
|
+
const createdAt = new Date();
|
|
135
|
+
const deadlineMs = transitions.config.interruptDeadlineMs;
|
|
136
|
+
const interrupt = {
|
|
137
|
+
interruptId,
|
|
138
|
+
kind: "question",
|
|
139
|
+
toolCallId: toolCall.toolCallId,
|
|
140
|
+
toolName: toolCall.toolName,
|
|
141
|
+
arguments: toolCall.arguments,
|
|
142
|
+
createdAt: createdAt.toISOString(),
|
|
143
|
+
deadline: deadlineMs === undefined ? null : new Date(createdAt.getTime() + deadlineMs).toISOString(),
|
|
144
|
+
question: toolCall.inputQuestion,
|
|
145
|
+
choices: [...toolCall.inputChoices],
|
|
146
|
+
allowsFreeText: toolCall.inputAllowsFreeText,
|
|
147
|
+
};
|
|
148
|
+
transitions.persistence.pendingInterrupts.set(context, [...transitions.readPendingInterrupts(context), interrupt]);
|
|
149
|
+
transitions.writeEvents(context, toolCall.turnId, (events) => transitions.writeInterruptRaised(events, interrupt));
|
|
150
|
+
}
|
|
151
|
+
resolveQuestion(context, toolCall, interruptId, resolution, isDeadlinePassed = false) {
|
|
152
|
+
const transitions = this.transitions;
|
|
153
|
+
const answer = resolution.answer ?? null;
|
|
154
|
+
const isAnswered = resolution.approved && answer !== null;
|
|
155
|
+
transitions.writeInterruptResolved(context, toolCall.turnId, {
|
|
156
|
+
interruptId,
|
|
157
|
+
kind: "question",
|
|
158
|
+
isApproved: resolution.approved,
|
|
159
|
+
isAnswered,
|
|
160
|
+
rejectionMessage: resolution.rejectionMessage,
|
|
161
|
+
});
|
|
162
|
+
if ((toolCall.taskId ?? null) !== null && toolCall.inputQuestion !== null) {
|
|
163
|
+
return this.returnQuestionToTask(context, toolCall, interruptId, resolution, isDeadlinePassed);
|
|
164
|
+
}
|
|
165
|
+
if (!isAnswered || answer === null) {
|
|
166
|
+
transitions.finishToolCall(context, {
|
|
167
|
+
...toolCall,
|
|
168
|
+
status: "rejected",
|
|
169
|
+
rejectionMessage: declineText(resolution.rejectionMessage),
|
|
170
|
+
cancellationReason: null,
|
|
171
|
+
...noPendingToolQuestion,
|
|
172
|
+
});
|
|
173
|
+
return deadEnd();
|
|
174
|
+
}
|
|
175
|
+
if (toolCall.inputQuestion === null) {
|
|
176
|
+
transitions.finishToolCall(context, {
|
|
177
|
+
...toolCall,
|
|
178
|
+
status: "succeeded",
|
|
179
|
+
output: buildQuestionAnsweredOutput(answer),
|
|
180
|
+
cancellationReason: null,
|
|
181
|
+
});
|
|
182
|
+
return deadEnd();
|
|
183
|
+
}
|
|
184
|
+
transitions.writeToolCall(context, {
|
|
185
|
+
...toolCall,
|
|
186
|
+
status: "approved",
|
|
187
|
+
inputAnswers: [
|
|
188
|
+
...toolCall.inputAnswers,
|
|
189
|
+
{ interruptId, question: toolCall.inputQuestion, answer, resolution: "answered" },
|
|
190
|
+
],
|
|
191
|
+
cancellationReason: null,
|
|
192
|
+
...noPendingToolQuestion,
|
|
193
|
+
});
|
|
194
|
+
return goToMany(toolStepMovement(transitions.persistence, toolStepTypeForEffect(toolCall.effect), toolCall.toolCallId));
|
|
195
|
+
}
|
|
196
|
+
/** Hands a started task's question back to it; its result, not `rejected`, ends the call. */
|
|
197
|
+
returnQuestionToTask(context, toolCall, interruptId, resolution, isDeadlinePassed) {
|
|
198
|
+
const answer = resolution.answer ?? null;
|
|
199
|
+
const resolved = resolution.approved && answer !== null
|
|
200
|
+
? { interruptId, question: toolCall.inputQuestion ?? "", answer, resolution: "answered" }
|
|
201
|
+
: isDeadlinePassed
|
|
202
|
+
? { interruptId, question: toolCall.inputQuestion ?? "", answer: questionDeadlinePassed, resolution: "deadline_passed" }
|
|
203
|
+
: {
|
|
204
|
+
interruptId,
|
|
205
|
+
question: toolCall.inputQuestion ?? "",
|
|
206
|
+
answer: declineText(resolution.rejectionMessage),
|
|
207
|
+
resolution: "declined",
|
|
208
|
+
};
|
|
209
|
+
const waiting = {
|
|
210
|
+
...toolCall,
|
|
211
|
+
status: "waiting_for_task",
|
|
212
|
+
inputAnswers: [...toolCall.inputAnswers, resolved],
|
|
213
|
+
taskAnswerPending: true,
|
|
214
|
+
cancellationReason: null,
|
|
215
|
+
...noPendingToolQuestion,
|
|
216
|
+
};
|
|
217
|
+
this.transitions.writeToolCall(context, waiting);
|
|
218
|
+
return goToMany(toolTaskPollMovement(this.transitions.persistence, waiting));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Polls one tool's remote task after its poll interval, until the task finishes.
|
|
223
|
+
*
|
|
224
|
+
* A tool Step that received {@link ToolTaskStarted} moves here. Each execution waits on a Timer, calls
|
|
225
|
+
* the runner's `pollToolTask` once, and records the result, asks the task's question, or moves to itself.
|
|
226
|
+
*/
|
|
227
|
+
export class PollToolTaskStep {
|
|
228
|
+
transitions;
|
|
229
|
+
inputCodec = stringCodec;
|
|
230
|
+
constructor(transitions) {
|
|
231
|
+
this.transitions = transitions;
|
|
232
|
+
}
|
|
233
|
+
getStepType() {
|
|
234
|
+
return agentSessionStepTypes.pollToolTask;
|
|
235
|
+
}
|
|
236
|
+
getStepOptions() {
|
|
237
|
+
return toolStepOptions(this.transitions.persistence, agentSessionStepTypes.pollToolTask);
|
|
238
|
+
}
|
|
239
|
+
waitFor(context, toolCallId) {
|
|
240
|
+
const toolCall = this.transitions.readToolCall(context, toolCallId);
|
|
241
|
+
// A resolved question, or a cancelled turn, reaches the task at once.
|
|
242
|
+
const intervalSeconds = toolCall.taskAnswerPending === true || this.transitions.isTurnCancelled(context, toolCall.turnId)
|
|
243
|
+
? 0
|
|
244
|
+
: (toolCall.taskPollIntervalSeconds ?? 1);
|
|
245
|
+
return Wait.until(Timer.byDuration(intervalSeconds * 1_000));
|
|
246
|
+
}
|
|
247
|
+
async execute(context, toolCallId) {
|
|
248
|
+
const transitions = this.transitions;
|
|
249
|
+
const toolCall = transitions.readToolCall(context, toolCallId);
|
|
250
|
+
if (isFinalToolCallStatus(toolCall.status)) {
|
|
251
|
+
return deadEnd();
|
|
252
|
+
}
|
|
253
|
+
if (toolCall.status !== "waiting_for_task" || (toolCall.taskId ?? null) === null) {
|
|
254
|
+
throw new Error(`tool call ${toolCallId} is not waiting for a task`);
|
|
255
|
+
}
|
|
256
|
+
if (transitions.isTurnCancelled(context, toolCall.turnId)) {
|
|
257
|
+
// This poll started after cancel_turn committed, so it abandons the task instead.
|
|
258
|
+
return goToMany(finishTurnCancellationMovement(toolCall.turnId));
|
|
259
|
+
}
|
|
260
|
+
const pollToolTask = transitions.runner.pollToolTask;
|
|
261
|
+
const events = transitions.createEventWriter(context, toolCall.turnId);
|
|
262
|
+
try {
|
|
263
|
+
if (pollToolTask === undefined) {
|
|
264
|
+
// A Worker whose runner lost the method; the task may still run.
|
|
265
|
+
transitions.finishToolCall(context, recordToolTaskDefect(toolCall, missingToolTaskPoller), events);
|
|
266
|
+
return deadEnd();
|
|
267
|
+
}
|
|
268
|
+
const poll = {
|
|
269
|
+
flowId: context.flowId,
|
|
270
|
+
toolCall,
|
|
271
|
+
idempotencyKey: `${context.flowId}/${toolCall.turnId}/${toolCall.toolCallId}`,
|
|
272
|
+
attempt: context.attempt,
|
|
273
|
+
inputAnswers: toolCall.inputAnswers,
|
|
274
|
+
pendingAnswer: toolCall.taskAnswerPending ? (toolCall.inputAnswers.at(-1) ?? null) : null,
|
|
275
|
+
events,
|
|
276
|
+
cancellationSignal: context.cancellationSignal,
|
|
277
|
+
deadline: context.deadline,
|
|
278
|
+
heartbeat: () => transitions.recordHeartbeat(context),
|
|
279
|
+
};
|
|
280
|
+
const polled = await transitions.tracer.traceToolCall(context, this.getStepType(), toolCall, async (pollSpan) => {
|
|
281
|
+
let outcome;
|
|
282
|
+
try {
|
|
283
|
+
outcome = await transitions.runWithHeartbeats(context, () => pollToolTask.call(transitions.runner, poll));
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
if (!(error instanceof ToolExecutionError)) {
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
const failed = { ...toolCall, status: "failed", error: error.message };
|
|
290
|
+
pollSpan.recordFinished(failed);
|
|
291
|
+
return failed;
|
|
292
|
+
}
|
|
293
|
+
const record = recordToolTaskPoll(toolCall, outcome);
|
|
294
|
+
pollSpan.recordFinished(record);
|
|
295
|
+
return record;
|
|
296
|
+
});
|
|
297
|
+
if (isFinalToolCallStatus(polled.status)) {
|
|
298
|
+
transitions.finishToolCall(context, polled, events);
|
|
299
|
+
return deadEnd();
|
|
300
|
+
}
|
|
301
|
+
if (polled.status === "awaiting_answer") {
|
|
302
|
+
// This Step runs unlocked, so it leaves PendingInterrupts to AwaitQuestionAnswer.
|
|
303
|
+
transitions.writeToolCall(context, polled);
|
|
304
|
+
return goToMany(questionAnswerMovement(transitions.persistence, polled));
|
|
305
|
+
}
|
|
306
|
+
if (polled.taskPollIntervalSeconds !== toolCall.taskPollIntervalSeconds ||
|
|
307
|
+
polled.taskAnswerPending !== (toolCall.taskAnswerPending ?? false) ||
|
|
308
|
+
polled.inputContinuation !== toolCall.inputContinuation) {
|
|
309
|
+
transitions.writeToolCall(context, polled);
|
|
310
|
+
}
|
|
311
|
+
return goToMany(toolTaskPollMovement(transitions.persistence, polled));
|
|
312
|
+
}
|
|
313
|
+
finally {
|
|
314
|
+
events.close();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/** Returns the record after one poll: final, awaiting an answer, or still waiting. */
|
|
319
|
+
function recordToolTaskPoll(toolCall, outcome) {
|
|
320
|
+
const polled = { ...toolCall, taskAnswerPending: false };
|
|
321
|
+
if (isToolTaskPending(outcome)) {
|
|
322
|
+
const pollIntervalSeconds = toolTaskPollIntervalSeconds(outcome.pollIntervalSeconds);
|
|
323
|
+
// The runner decides what the next poll needs to know, such as an answer not taken yet.
|
|
324
|
+
return pollIntervalSeconds === null
|
|
325
|
+
? recordToolTaskDefect(toolCall, invalidToolTaskPollInterval)
|
|
326
|
+
: { ...polled, taskPollIntervalSeconds: pollIntervalSeconds, inputContinuation: outcome.continuation ?? null };
|
|
327
|
+
}
|
|
328
|
+
if (isToolInputRequested(outcome)) {
|
|
329
|
+
const asked = recordToolInputRequest(polled, outcome);
|
|
330
|
+
return isFinalToolCallStatus(asked.status) ? recordToolTaskDefect(toolCall, asked.error ?? "") : asked;
|
|
331
|
+
}
|
|
332
|
+
if (typeof outcome?.output !== "string") {
|
|
333
|
+
throw new TypeError("pollToolTask must return a ToolExecutionResult, a ToolInputRequested, or a ToolTaskPending");
|
|
334
|
+
}
|
|
335
|
+
return { ...polled, status: "succeeded", output: outcome.output };
|
|
336
|
+
}
|
|
337
|
+
/** Returns the text the model sees for a declined question; an empty message reads as none, as in Python. */
|
|
338
|
+
function declineText(rejectionMessage) {
|
|
339
|
+
return rejectionMessage === null || rejectionMessage === "" ? defaultQuestionDeclinedToolResult : rejectionMessage;
|
|
340
|
+
}
|
|
341
|
+
function isToolTaskPending(outcome) {
|
|
342
|
+
return outcome?.kind === "tool_task_pending";
|
|
343
|
+
}
|
|
344
|
+
/** Waits on a Dex Timer for one `durable_wait` call, then records its result. */
|
|
345
|
+
export class AwaitTimerStep {
|
|
346
|
+
transitions;
|
|
347
|
+
inputCodec = stringCodec;
|
|
348
|
+
constructor(transitions) {
|
|
349
|
+
this.transitions = transitions;
|
|
350
|
+
}
|
|
351
|
+
getStepType() {
|
|
352
|
+
return agentSessionStepTypes.awaitTimer;
|
|
353
|
+
}
|
|
354
|
+
getStepOptions() {
|
|
355
|
+
return toolStepOptions(this.transitions.persistence, agentSessionStepTypes.awaitTimer);
|
|
356
|
+
}
|
|
357
|
+
waitFor(context, toolCallId) {
|
|
358
|
+
const toolCall = this.transitions.readToolCall(context, toolCallId);
|
|
359
|
+
if (toolCall.waitUntil === null) {
|
|
360
|
+
throw new Error(`durable_wait call ${toolCallId} has no wait_until`);
|
|
361
|
+
}
|
|
362
|
+
// Dex Timers take whole seconds; rounding up can only fire late, never early.
|
|
363
|
+
const remainingMs = Math.max(0, Date.parse(toolCall.waitUntil) - Date.now());
|
|
364
|
+
return Wait.anyOf(Timer.byDuration(Math.ceil(remainingMs / 1_000) * 1_000), this.transitions.persistence.toolCallCancellations.forOne(toolCallId));
|
|
365
|
+
}
|
|
366
|
+
execute(context, toolCallId) {
|
|
367
|
+
const transitions = this.transitions;
|
|
368
|
+
const toolCall = transitions.readToolCall(context, toolCallId);
|
|
369
|
+
if (toolCall.status !== "waiting_for_timer") {
|
|
370
|
+
return deadEnd();
|
|
371
|
+
}
|
|
372
|
+
if (!context.hasTimerFired()) {
|
|
373
|
+
if (context.channelResults(transitions.persistence.toolCallCancellations, toolCallId).length === 0) {
|
|
374
|
+
throw new Error(`the durable wait ${toolCallId} completed without its Timer`);
|
|
375
|
+
}
|
|
376
|
+
return cancelWaitingToolCall(transitions, context, toolCall, null, toolStepMovement(transitions.persistence, agentSessionStepTypes.awaitTimer, toolCallId));
|
|
377
|
+
}
|
|
378
|
+
// The Timer is the authority: it never fires early, and skipping it ends the wait.
|
|
379
|
+
// RunModel validated these arguments, so a later maxDurableWaitMs cannot fail a started wait.
|
|
380
|
+
const { duration_seconds: waitedSeconds, reason } = JSON.parse(toolCall.arguments);
|
|
381
|
+
transitions.finishToolCall(context, {
|
|
382
|
+
...toolCall,
|
|
383
|
+
status: "succeeded",
|
|
384
|
+
output: buildDurableWaitCompletedOutput(Math.trunc(waitedSeconds), reason),
|
|
385
|
+
});
|
|
386
|
+
return deadEnd();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=agent-session-wait-steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-wait-steps.js","sourceRoot":"","sources":["../../src/agent-session-wait-steps.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,WAAW,GAOZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,+BAA+B,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACzG,OAAO,EACL,kBAAkB,GAInB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,mBA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