@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.
Files changed (168) hide show
  1. package/README.md +1608 -64
  2. package/dist/src/agent-built-in-tools.d.ts +81 -0
  3. package/dist/src/agent-built-in-tools.js +246 -0
  4. package/dist/src/agent-built-in-tools.js.map +1 -0
  5. package/dist/src/agent-context-compaction.d.ts +254 -0
  6. package/dist/src/agent-context-compaction.js +287 -0
  7. package/dist/src/agent-context-compaction.js.map +1 -0
  8. package/dist/src/agent-framework-runner.d.ts +456 -16
  9. package/dist/src/agent-framework-runner.js +4 -3
  10. package/dist/src/agent-framework-runner.js.map +1 -1
  11. package/dist/src/agent-plans.d.ts +48 -0
  12. package/dist/src/agent-plans.js +86 -0
  13. package/dist/src/agent-plans.js.map +1 -0
  14. package/dist/src/agent-session-cancellation-steps.d.ts +28 -0
  15. package/dist/src/agent-session-cancellation-steps.js +154 -0
  16. package/dist/src/agent-session-cancellation-steps.js.map +1 -0
  17. package/dist/src/agent-session-codecs.d.ts +65 -4
  18. package/dist/src/agent-session-codecs.js +343 -8
  19. package/dist/src/agent-session-codecs.js.map +1 -1
  20. package/dist/src/agent-session-failure.d.ts +58 -0
  21. package/dist/src/agent-session-failure.js +126 -0
  22. package/dist/src/agent-session-failure.js.map +1 -0
  23. package/dist/src/agent-session-flow-graph-cli.d.ts +2 -0
  24. package/dist/src/agent-session-flow-graph-cli.js +47 -0
  25. package/dist/src/agent-session-flow-graph-cli.js.map +1 -0
  26. package/dist/src/agent-session-flow-graph.d.ts +38 -0
  27. package/dist/src/agent-session-flow-graph.js +54 -0
  28. package/dist/src/agent-session-flow-graph.js.map +1 -0
  29. package/dist/src/agent-session-flow-graph.json +2187 -0
  30. package/dist/src/agent-session-flow.d.ts +317 -28
  31. package/dist/src/agent-session-flow.js +373 -21
  32. package/dist/src/agent-session-flow.js.map +1 -1
  33. package/dist/src/agent-session-persistence.d.ts +81 -4
  34. package/dist/src/agent-session-persistence.js +33 -2
  35. package/dist/src/agent-session-persistence.js.map +1 -1
  36. package/dist/src/agent-session-settings.d.ts +58 -0
  37. package/dist/src/agent-session-settings.js +81 -0
  38. package/dist/src/agent-session-settings.js.map +1 -0
  39. package/dist/src/agent-session-spend-limit.d.ts +156 -0
  40. package/dist/src/agent-session-spend-limit.js +42 -0
  41. package/dist/src/agent-session-spend-limit.js.map +1 -0
  42. package/dist/src/agent-session-start.d.ts +49 -0
  43. package/dist/src/agent-session-start.js +67 -0
  44. package/dist/src/agent-session-start.js.map +1 -0
  45. package/dist/src/agent-session-step-options.d.ts +78 -0
  46. package/dist/src/agent-session-step-options.js +71 -0
  47. package/dist/src/agent-session-step-options.js.map +1 -0
  48. package/dist/src/agent-session-step-types.d.ts +20 -0
  49. package/dist/src/agent-session-step-types.js +28 -0
  50. package/dist/src/agent-session-step-types.js.map +1 -0
  51. package/dist/src/agent-session-steps.d.ts +103 -8
  52. package/dist/src/agent-session-steps.js +997 -197
  53. package/dist/src/agent-session-steps.js.map +1 -1
  54. package/dist/src/agent-session-tracer.d.ts +61 -0
  55. package/dist/src/agent-session-tracer.js +608 -0
  56. package/dist/src/agent-session-tracer.js.map +1 -0
  57. package/dist/src/agent-session-transitions.d.ts +200 -26
  58. package/dist/src/agent-session-transitions.js +732 -32
  59. package/dist/src/agent-session-transitions.js.map +1 -1
  60. package/dist/src/agent-session-values.d.ts +696 -30
  61. package/dist/src/agent-session-values.js +39 -4
  62. package/dist/src/agent-session-values.js.map +1 -1
  63. package/dist/src/agent-session-wait-steps.d.ts +53 -0
  64. package/dist/src/agent-session-wait-steps.js +389 -0
  65. package/dist/src/agent-session-wait-steps.js.map +1 -0
  66. package/dist/src/agent-tracing-options.d.ts +107 -0
  67. package/dist/src/agent-tracing-options.js +20 -0
  68. package/dist/src/agent-tracing-options.js.map +1 -0
  69. package/dist/src/ai-sdk/ai-sdk-model-client.d.ts +40 -0
  70. package/dist/src/ai-sdk/ai-sdk-model-client.js +235 -0
  71. package/dist/src/ai-sdk/ai-sdk-model-client.js.map +1 -0
  72. package/dist/src/ai-sdk/index.d.ts +1 -0
  73. package/dist/src/ai-sdk/index.js +9 -0
  74. package/dist/src/ai-sdk/index.js.map +1 -0
  75. package/dist/src/index.d.ts +14 -3
  76. package/dist/src/index.js +12 -2
  77. package/dist/src/index.js.map +1 -1
  78. package/dist/src/mcp/index.d.ts +3 -0
  79. package/dist/src/mcp/index.js +10 -0
  80. package/dist/src/mcp/index.js.map +1 -0
  81. package/dist/src/mcp/mcp-resource-and-prompt-tools.d.ts +29 -0
  82. package/dist/src/mcp/mcp-resource-and-prompt-tools.js +185 -0
  83. package/dist/src/mcp/mcp-resource-and-prompt-tools.js.map +1 -0
  84. package/dist/src/mcp/mcp-server-config.d.ts +86 -0
  85. package/dist/src/mcp/mcp-server-config.js +38 -0
  86. package/dist/src/mcp/mcp-server-config.js.map +1 -0
  87. package/dist/src/mcp/mcp-tool-source.d.ts +470 -0
  88. package/dist/src/mcp/mcp-tool-source.js +1204 -0
  89. package/dist/src/mcp/mcp-tool-source.js.map +1 -0
  90. package/dist/src/stepwise/agent-definition.d.ts +166 -0
  91. package/dist/src/stepwise/agent-definition.js +9 -0
  92. package/dist/src/stepwise/agent-definition.js.map +1 -0
  93. package/dist/src/stepwise/function-tool.d.ts +130 -0
  94. package/dist/src/stepwise/function-tool.js +75 -0
  95. package/dist/src/stepwise/function-tool.js.map +1 -0
  96. package/dist/src/stepwise/index.d.ts +8 -0
  97. package/dist/src/stepwise/index.js +13 -0
  98. package/dist/src/stepwise/index.js.map +1 -0
  99. package/dist/src/stepwise/json-schema-validation.d.ts +9 -0
  100. package/dist/src/stepwise/json-schema-validation.js +141 -0
  101. package/dist/src/stepwise/json-schema-validation.js.map +1 -0
  102. package/dist/src/stepwise/model-client.d.ts +194 -0
  103. package/dist/src/stepwise/model-client.js +9 -0
  104. package/dist/src/stepwise/model-client.js.map +1 -0
  105. package/dist/src/stepwise/scripted-model-client.d.ts +99 -0
  106. package/dist/src/stepwise/scripted-model-client.js +156 -0
  107. package/dist/src/stepwise/scripted-model-client.js.map +1 -0
  108. package/dist/src/stepwise/stepwise-agent-runner.d.ts +171 -0
  109. package/dist/src/stepwise/stepwise-agent-runner.js +777 -0
  110. package/dist/src/stepwise/stepwise-agent-runner.js.map +1 -0
  111. package/dist/src/stepwise/stepwise-agent-session-flow.d.ts +35 -0
  112. package/dist/src/stepwise/stepwise-agent-session-flow.js +57 -0
  113. package/dist/src/stepwise/stepwise-agent-session-flow.js.map +1 -0
  114. package/dist/src/stepwise/stepwise-input-items.d.ts +12 -0
  115. package/dist/src/stepwise/stepwise-input-items.js +172 -0
  116. package/dist/src/stepwise/stepwise-input-items.js.map +1 -0
  117. package/dist/src/stepwise/tool-source.d.ts +103 -0
  118. package/dist/src/stepwise/tool-source.js +9 -0
  119. package/dist/src/stepwise/tool-source.js.map +1 -0
  120. package/dist/src/testing/agent-session-test-client.d.ts +65 -8
  121. package/dist/src/testing/agent-session-test-client.js +92 -22
  122. package/dist/src/testing/agent-session-test-client.js.map +1 -1
  123. package/dist/src/testing/context-window.d.ts +194 -0
  124. package/dist/src/testing/context-window.js +360 -0
  125. package/dist/src/testing/context-window.js.map +1 -0
  126. package/dist/src/testing/index.d.ts +2 -0
  127. package/dist/src/testing/index.js +2 -0
  128. package/dist/src/testing/index.js.map +1 -1
  129. package/dist/src/testing/private-dex-engine.d.ts +9 -0
  130. package/dist/src/testing/private-dex-engine.js +9 -1
  131. package/dist/src/testing/private-dex-engine.js.map +1 -1
  132. package/dist/src/testing/scripted-model-client.d.ts +1 -0
  133. package/dist/src/testing/scripted-model-client.js +10 -0
  134. package/dist/src/testing/scripted-model-client.js.map +1 -0
  135. package/dist/src/ui-stream/agent-event-json.d.ts +30 -0
  136. package/dist/src/ui-stream/agent-event-json.js +64 -0
  137. package/dist/src/ui-stream/agent-event-json.js.map +1 -0
  138. package/dist/src/ui-stream/agent-event-sse.d.ts +155 -0
  139. package/dist/src/ui-stream/agent-event-sse.js +167 -0
  140. package/dist/src/ui-stream/agent-event-sse.js.map +1 -0
  141. package/dist/src/ui-stream/agent-event-stream-positions.d.ts +42 -0
  142. package/dist/src/ui-stream/agent-event-stream-positions.js +153 -0
  143. package/dist/src/ui-stream/agent-event-stream-positions.js.map +1 -0
  144. package/dist/src/ui-stream/agent-session-record-reader.d.ts +74 -0
  145. package/dist/src/ui-stream/agent-session-record-reader.js +246 -0
  146. package/dist/src/ui-stream/agent-session-record-reader.js.map +1 -0
  147. package/dist/src/ui-stream/agent-ui-message-stream-responses.d.ts +219 -0
  148. package/dist/src/ui-stream/agent-ui-message-stream-responses.js +441 -0
  149. package/dist/src/ui-stream/agent-ui-message-stream-responses.js.map +1 -0
  150. package/dist/src/ui-stream/agent-ui-message-stream.d.ts +138 -0
  151. package/dist/src/ui-stream/agent-ui-message-stream.js +695 -0
  152. package/dist/src/ui-stream/agent-ui-message-stream.js.map +1 -0
  153. package/dist/src/ui-stream/agent-ui-message-types.d.ts +238 -0
  154. package/dist/src/ui-stream/agent-ui-message-types.js +57 -0
  155. package/dist/src/ui-stream/agent-ui-message-types.js.map +1 -0
  156. package/dist/src/ui-stream/agent-ui-messages.d.ts +68 -0
  157. package/dist/src/ui-stream/agent-ui-messages.js +222 -0
  158. package/dist/src/ui-stream/agent-ui-messages.js.map +1 -0
  159. package/dist/src/ui-stream/agent-ui-stream-cursor.d.ts +64 -0
  160. package/dist/src/ui-stream/agent-ui-stream-cursor.js +186 -0
  161. package/dist/src/ui-stream/agent-ui-stream-cursor.js.map +1 -0
  162. package/dist/src/ui-stream/index.d.ts +14 -0
  163. package/dist/src/ui-stream/index.js +22 -0
  164. package/dist/src/ui-stream/index.js.map +1 -0
  165. package/dist/src/ui-stream/server-sent-event-responses.d.ts +6 -0
  166. package/dist/src/ui-stream/server-sent-event-responses.js +34 -0
  167. package/dist/src/ui-stream/server-sent-event-responses.js.map +1 -0
  168. package/package.json +44 -5
@@ -0,0 +1,86 @@
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
+ /**
9
+ * Rejection message of a call to any tool other than `write_todos` in a `planning` turn; the same text as
10
+ * the Python core.
11
+ */
12
+ export const planningTurnToolRejection = "The tool call was not run: a planning turn can only call write_todos.";
13
+ /** First line of the plan note while no plan exists; the same text as the Python core. */
14
+ export const noPlanNote = "[Dex] There is no plan yet.";
15
+ /** Last line of the plan note in a `planning` turn; the same text as the Python core. */
16
+ export const planningTurnInstruction = "This turn only plans: write or revise the plan with write_todos, and do not do or claim any of its " +
17
+ "tasks. The user reviews the plan before it runs.";
18
+ /**
19
+ * Returns the user message text of a turn that `execute_plan` started.
20
+ *
21
+ * @param revision - The approved {@link AgentPlan.revision}.
22
+ * @returns `[Dex] The user approved plan revision <n>. Execute it and keep the task statuses current with
23
+ * write_todos.`, the same text as the Python core.
24
+ */
25
+ export function buildPlanExecutionMessage(revision) {
26
+ return (`[Dex] The user approved plan revision ${revision}. ` +
27
+ "Execute it and keep the task statuses current with write_todos.");
28
+ }
29
+ /**
30
+ * Returns the text that shows the model the current plan, or `undefined` for none.
31
+ *
32
+ * A runner that honors plan mode adds it to the model input of every model call, after the context summary
33
+ * and before the turn's messages, as user text. It is not stored as a message, so it always shows the
34
+ * latest plan. The text is the same as the Python core's `build_plan_note`:
35
+ *
36
+ * ```text
37
+ * [Dex] The current plan, revision 2, is draft:
38
+ * - [completed] Look up the order
39
+ * - [pending] Refund the order
40
+ * This turn only plans: write or revise the plan with write_todos, ...
41
+ * ```
42
+ *
43
+ * @param plan - The {@link AgentPlan}, or `null` or `undefined` when there is none.
44
+ * @param interactionMode - The turn's mode; `undefined` means `chat`.
45
+ * @returns One line for the plan and one per task, then {@link planningTurnInstruction} in a `planning`
46
+ * turn, joined with newlines. {@link noPlanNote} stands for a missing or cleared plan in a `planning` turn.
47
+ * `undefined` when there is no plan to show outside a `planning` turn.
48
+ */
49
+ export function buildPlanNote(plan, interactionMode) {
50
+ const isPlanning = interactionMode === "planning";
51
+ let lines;
52
+ if (plan == null || plan.status === "cleared") {
53
+ if (!isPlanning) {
54
+ return undefined;
55
+ }
56
+ lines = [noPlanNote];
57
+ }
58
+ else {
59
+ lines = [
60
+ `[Dex] The current plan, revision ${plan.revision}, is ${plan.status}:`,
61
+ ...plan.tasks.map((task) => `- [${task.status}] ${task.content}`),
62
+ ];
63
+ }
64
+ if (isPlanning) {
65
+ lines.push(planningTurnInstruction);
66
+ }
67
+ return lines.join("\n");
68
+ }
69
+ /**
70
+ * Returns the status of the plan that `write_todos` writes.
71
+ *
72
+ * @param tasks - The tasks written.
73
+ * @param interactionMode - The mode of the turn that wrote them.
74
+ * @returns `cleared` for no tasks, `draft` in a `planning` turn, `completed` when every task is completed,
75
+ * and `active` otherwise.
76
+ */
77
+ export function planStatusAfterWrite(tasks, interactionMode) {
78
+ if (tasks.length === 0) {
79
+ return "cleared";
80
+ }
81
+ if (interactionMode === "planning") {
82
+ return "draft";
83
+ }
84
+ return tasks.every((task) => task.status === "completed") ? "completed" : "active";
85
+ }
86
+ //# sourceMappingURL=agent-plans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-plans.js","sourceRoot":"","sources":["../../src/agent-plans.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAI1D;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,uEAAuE,CAAC;AAEjH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG,6BAA6B,CAAC;AAExD,yFAAyF;AACzF,MAAM,CAAC,MAAM,uBAAuB,GAClC,qGAAqG;IACrG,kDAAkD,CAAC;AAErD;;;;;;GAMG;AACH,MAAM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CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;AACrF,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type AsyncContext, type Context, type Step, type StepDecision, type StepOptions } from "@superdurable/dex";
2
+ import { type AgentSessionTransitions } from "./agent-session-transitions.js";
3
+ /**
4
+ * Finishes a turn that `cancel_turn` stopped, from the state that committed.
5
+ *
6
+ * `cancel_turn` cancels the Steps that call a model or wait, then moves here with the turn ID. When the model
7
+ * call or compaction was cancelled, it moves to `ApplyTurnControl`. Otherwise `ResumeTurn` still waits: this
8
+ * Step records each call whose wait was cancelled, hands each abandoned task to `CancelToolTask`, and ends, so
9
+ * `ResumeTurn` ends the turn once every started tool Step finishes.
10
+ */
11
+ export declare class FinishTurnCancellationStep implements Step<string> {
12
+ private readonly transitions;
13
+ readonly inputCodec: import("@superdurable/dex").Codec<string>;
14
+ constructor(transitions: AgentSessionTransitions);
15
+ getStepType(): string;
16
+ getStepOptions(): StepOptions;
17
+ execute(context: Context, turnId: string): StepDecision;
18
+ private finishWaitingToolCalls;
19
+ }
20
+ /** Asks the runner to cancel one task that `cancel_turn` abandoned, then records it `outcome_unknown`. */
21
+ export declare class CancelToolTaskStep implements Step<string> {
22
+ private readonly transitions;
23
+ readonly inputCodec: import("@superdurable/dex").Codec<string>;
24
+ constructor(transitions: AgentSessionTransitions);
25
+ getStepType(): string;
26
+ getStepOptions(): StepOptions;
27
+ execute(context: AsyncContext, toolCallId: string): Promise<StepDecision>;
28
+ }
@@ -0,0 +1,154 @@
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 { deadEnd, goToMany, stringCodec, } from "@superdurable/dex";
9
+ import { noPendingToolQuestion, questionAnswerMovement, questionInterruptId, toolStepMovement, toolStepOptions, } from "./agent-session-steps.js";
10
+ import { agentSessionStepTypes, cancelledToolCall, isAbandonedToolTask, isCancellableByTurnControl, } from "./agent-session-transitions.js";
11
+ import { isFinalToolCallStatus, toolTaskAbandonedError } from "./agent-session-values.js";
12
+ // Recovery Steps must eventually run; cap their backoff so a returning Worker picks them up quickly.
13
+ const recoveryRetry = { maximumIntervalMs: 5_000 };
14
+ /**
15
+ * Finishes a turn that `cancel_turn` stopped, from the state that committed.
16
+ *
17
+ * `cancel_turn` cancels the Steps that call a model or wait, then moves here with the turn ID. When the model
18
+ * call or compaction was cancelled, it moves to `ApplyTurnControl`. Otherwise `ResumeTurn` still waits: this
19
+ * Step records each call whose wait was cancelled, hands each abandoned task to `CancelToolTask`, and ends, so
20
+ * `ResumeTurn` ends the turn once every started tool Step finishes.
21
+ */
22
+ export class FinishTurnCancellationStep {
23
+ transitions;
24
+ inputCodec = stringCodec;
25
+ constructor(transitions) {
26
+ this.transitions = transitions;
27
+ }
28
+ getStepType() {
29
+ return agentSessionStepTypes.finishTurnCancellation;
30
+ }
31
+ getStepOptions() {
32
+ const persistence = this.transitions.persistence;
33
+ // The cancel_turn RPC holds both locks, so this Step reads the state that RPC committed.
34
+ return {
35
+ waitForDurability: "sync",
36
+ executeDurability: "sync",
37
+ executeRetry: recoveryRetry,
38
+ executeLoadAttributeMaps: [persistence.agentToolCalls],
39
+ executeLockAttributes: [persistence.turnCancellationRequest.lock(), persistence.pendingInterrupts.lock()],
40
+ };
41
+ }
42
+ execute(context, turnId) {
43
+ const transitions = this.transitions;
44
+ const state = transitions.readOptionalAgentState(context);
45
+ if (state === null || state.activeTurnId !== turnId || !transitions.isTurnCancelled(context, turnId)) {
46
+ // The turn ended before the cancellation applied.
47
+ return deadEnd();
48
+ }
49
+ if (state.status !== "running_tools") {
50
+ // cancel_turn cancelled the model call or compaction, so no other Step ends the turn.
51
+ return transitions.goToApplyTurnControl(context);
52
+ }
53
+ // ResumeTurn waits for every result and ends the turn; started tool Steps still finish.
54
+ return this.finishWaitingToolCalls(context, turnId);
55
+ }
56
+ finishWaitingToolCalls(context, turnId) {
57
+ const transitions = this.transitions;
58
+ const persistence = transitions.persistence;
59
+ const interrupts = transitions.readPendingInterrupts(context);
60
+ const cancelledInterruptIds = new Set();
61
+ const movements = [];
62
+ for (const toolCall of transitions.readTurnToolCalls(context, turnId)) {
63
+ const interrupt = waitingInterrupt(toolCall);
64
+ if (interrupt !== null) {
65
+ if (context.channelSize(persistence.interruptResolutions, interrupt.interruptId) > 0) {
66
+ // The answer committed first; a new wait applies it, and its next Step decides.
67
+ if ((toolCall.cancellationReason ?? null) === null) {
68
+ // The mark keeps a later FinishTurnCancellation from starting a second wait.
69
+ const handedBack = { ...toolCall, cancellationReason: "turn_cancelled" };
70
+ transitions.writeToolCall(context, handedBack);
71
+ movements.push(handedBack.status === "awaiting_approval"
72
+ ? toolStepMovement(persistence, agentSessionStepTypes.awaitToolApproval, handedBack.toolCallId)
73
+ : questionAnswerMovement(persistence, handedBack));
74
+ }
75
+ continue;
76
+ }
77
+ if (interrupts.some((pending) => pending.interruptId === interrupt.interruptId)) {
78
+ cancelledInterruptIds.add(interrupt.interruptId);
79
+ transitions.writeInterruptCancelled(context, turnId, interrupt.interruptId, interrupt.kind, "turn_cancelled");
80
+ }
81
+ }
82
+ if (isAbandonedToolTask(toolCall)) {
83
+ if ((toolCall.cancellationReason ?? null) === null) {
84
+ const abandoned = {
85
+ ...toolCall,
86
+ status: "waiting_for_task",
87
+ cancellationReason: "turn_cancelled",
88
+ taskAnswerPending: false,
89
+ ...noPendingToolQuestion,
90
+ };
91
+ transitions.writeToolCall(context, abandoned);
92
+ movements.push(toolStepMovement(persistence, agentSessionStepTypes.cancelToolTask, toolCall.toolCallId));
93
+ }
94
+ continue;
95
+ }
96
+ if (isCancellableByTurnControl(toolCall)) {
97
+ transitions.finishToolCall(context, cancelledToolCall(toolCall, "turn_cancelled"));
98
+ }
99
+ }
100
+ if (cancelledInterruptIds.size > 0) {
101
+ persistence.pendingInterrupts.set(context, interrupts.filter((pending) => !cancelledInterruptIds.has(pending.interruptId)));
102
+ }
103
+ return movements.length > 0 ? goToMany(...movements) : deadEnd();
104
+ }
105
+ }
106
+ /** Asks the runner to cancel one task that `cancel_turn` abandoned, then records it `outcome_unknown`. */
107
+ export class CancelToolTaskStep {
108
+ transitions;
109
+ inputCodec = stringCodec;
110
+ constructor(transitions) {
111
+ this.transitions = transitions;
112
+ }
113
+ getStepType() {
114
+ return agentSessionStepTypes.cancelToolTask;
115
+ }
116
+ getStepOptions() {
117
+ return toolStepOptions(this.transitions.persistence, agentSessionStepTypes.cancelToolTask);
118
+ }
119
+ async execute(context, toolCallId) {
120
+ const transitions = this.transitions;
121
+ const toolCall = transitions.readToolCall(context, toolCallId);
122
+ if (isFinalToolCallStatus(toolCall.status)) {
123
+ return deadEnd();
124
+ }
125
+ if ((toolCall.taskId ?? null) === null || (toolCall.cancellationReason ?? null) === null) {
126
+ throw new Error(`tool call ${toolCallId} has no abandoned task`);
127
+ }
128
+ const cancelToolTask = transitions.runner.cancelToolTask;
129
+ if (cancelToolTask !== undefined) {
130
+ const cancellation = {
131
+ flowId: context.flowId,
132
+ toolCall,
133
+ idempotencyKey: `${context.flowId}/${toolCall.turnId}/${toolCall.toolCallId}`,
134
+ attempt: context.attempt,
135
+ cancellationSignal: context.cancellationSignal,
136
+ heartbeat: () => transitions.recordHeartbeat(context),
137
+ };
138
+ await transitions.runWithHeartbeats(context, () => cancelToolTask.call(transitions.runner, cancellation));
139
+ }
140
+ transitions.finishToolCall(context, { ...toolCall, status: "outcome_unknown", error: toolTaskAbandonedError });
141
+ return deadEnd();
142
+ }
143
+ }
144
+ /** Returns the interrupt a waiting record's Step waits on, or `null`. */
145
+ function waitingInterrupt(toolCall) {
146
+ if (toolCall.status === "awaiting_approval") {
147
+ return { interruptId: toolCall.toolCallId, kind: "tool_approval" };
148
+ }
149
+ if (toolCall.status === "awaiting_answer") {
150
+ return { interruptId: questionInterruptId(toolCall), kind: "question" };
151
+ }
152
+ return null;
153
+ }
154
+ //# sourceMappingURL=agent-session-cancellation-steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-session-cancellation-steps.js","sourceRoot":"","sources":["../../src/agent-session-cancellation-steps.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EACL,OAAO,EACP,QAAQ,EACR,WAAW,GAOZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GAEhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAA4B,MAAM,2BAA2B,CAAC;AAEpH,qGAAqG;AACrG,MAAM,aAAa,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAW,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,OAAO,0BAA0B;IAGD;IAFpB,UAAU,GAAG,WAAW,CAAC;IAEzC,YAAoC,WAAoC;QAApC,gBAAW,GAAX,WAAW,CAAyB;IAAG,CAAC;IAErE,WAAW;QAChB,OAAO,qBAAqB,CAAC,sBAAsB,CAAC;IACtD,CAAC;IAEM,cAAc;QACnB,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;QACjD,yFAAyF;QACzF,OAAO;YACL,iBAAiB,EAAE,MAAM;YACzB,iBAAiB,EAAE,MAAM;YACzB,YAAY,EAAE,aAAa;YAC3B,wBAAwB,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC;YACtD,qBAAqB,EAAE,CAAC,WAAW,CAAC,uBAAuB,CAAC,IAAI,EAAE,EAAE,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;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C,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;IACrE,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,iBAAiB,EAAE,CAAC;QAC1C,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC1E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,27 +1,69 @@
1
1
  import { type Codec } from "@superdurable/dex";
2
- import type { AgentEvent, AgentInterrupt, AgentInterruptResolution, AgentMessage, AgentMessagesPage, AgentSessionStartInput, AgentSnapshot, AgentState, AgentToolCall, AgentUsage, AgentUserMessage, ListAgentMessagesInput, ResolveInterruptInput, ToolCallCompleted } from "./agent-session-values.js";
2
+ import type { AgentEvent, AgentInterrupt, AgentInterruptResolution, AgentMessage, AgentMessageChunk, AgentMessageChunkRange, AgentMessageIndex, AgentMessagesPage, AgentPlan, AgentPlanTask, AgentSessionStartInput, AgentSnapshot, AgentState, AgentToolCallRecord, AgentUsage, AgentUserMessage, AnswerQuestionRequest, CancelTurnRequest, DeleteQueuedMessageRequest, ExecutePlanRequest, CompactContextInput, ContextSummary, ListAgentMessagesInput, PendingUserMessage, PlanExecutionRequest, QuestionAnswer, ResolveInterruptInput, SteerUserMessageRequest, ToolCallCancellation, ToolCallCompleted, TurnCancellationRequest, TurnControlRequest, SessionSettings, TurnReplySequence, TurnSessionSettings, UpdateSessionSettingsRequest } from "./agent-session-values.js";
3
3
  export declare function encodeAgentSessionStartInput(value: AgentSessionStartInput): unknown;
4
4
  export declare function decodeAgentSessionStartInput(value: unknown): AgentSessionStartInput;
5
+ export declare function encodeSessionSettings(value: SessionSettings): unknown;
6
+ export declare function decodeSessionSettings(value: unknown): SessionSettings;
7
+ export declare function encodeUpdateSessionSettingsRequest(value: UpdateSessionSettingsRequest): unknown;
8
+ export declare function decodeUpdateSessionSettingsRequest(value: unknown): UpdateSessionSettingsRequest;
9
+ export declare function encodeTurnSessionSettings(value: TurnSessionSettings): unknown;
10
+ export declare function decodeTurnSessionSettings(value: unknown): TurnSessionSettings;
5
11
  export declare function encodeAgentState(value: AgentState): unknown;
6
12
  export declare function decodeAgentState(value: unknown): AgentState;
7
13
  export declare function encodeAgentMessage(value: AgentMessage): unknown;
8
14
  export declare function decodeAgentMessage(value: unknown): AgentMessage;
9
- export declare function encodeAgentToolCall(value: AgentToolCall): unknown;
10
- export declare function decodeAgentToolCall(value: unknown): AgentToolCall;
15
+ export declare function encodeAgentToolCall(value: AgentToolCallRecord): unknown;
16
+ export declare function decodeAgentToolCall(value: unknown): AgentToolCallRecord;
17
+ export declare function encodeQuestionAnswer(value: QuestionAnswer): unknown;
18
+ export declare function decodeQuestionAnswer(value: unknown): QuestionAnswer;
11
19
  export declare function encodeAgentInterrupt(value: AgentInterrupt): unknown;
12
20
  export declare function decodeAgentInterrupt(value: unknown): AgentInterrupt;
13
21
  export declare function encodeAgentInterruptResolution(value: AgentInterruptResolution): unknown;
14
22
  export declare function decodeAgentInterruptResolution(value: unknown): AgentInterruptResolution;
23
+ export declare function encodeAnswerQuestionRequest(value: AnswerQuestionRequest): unknown;
24
+ export declare function decodeAnswerQuestionRequest(value: unknown): AnswerQuestionRequest;
15
25
  export declare function encodeAgentUsage(value: AgentUsage): unknown;
16
26
  export declare function decodeAgentUsage(value: unknown): AgentUsage;
17
27
  export declare function encodeAgentUserMessage(value: AgentUserMessage): unknown;
18
28
  export declare function decodeAgentUserMessage(value: unknown): AgentUserMessage;
29
+ export declare function encodeAgentPlan(value: AgentPlan): unknown;
30
+ export declare function decodeAgentPlan(value: unknown): AgentPlan;
31
+ export declare function encodeAgentPlanTask(value: AgentPlanTask): unknown;
32
+ export declare function decodeAgentPlanTask(value: unknown): AgentPlanTask;
33
+ export declare function encodePlanRevisionRequest(value: ExecutePlanRequest | PlanExecutionRequest): unknown;
34
+ export declare function decodePlanRevisionRequest(value: unknown): PlanExecutionRequest;
35
+ export declare function encodePendingUserMessage(value: PendingUserMessage): unknown;
36
+ export declare function decodePendingUserMessage(value: unknown): PendingUserMessage;
37
+ export declare function encodeSteerUserMessageRequest(value: SteerUserMessageRequest): unknown;
38
+ export declare function decodeSteerUserMessageRequest(value: unknown): SteerUserMessageRequest;
39
+ export declare function encodeDeleteQueuedMessageRequest(value: DeleteQueuedMessageRequest): unknown;
40
+ export declare function decodeDeleteQueuedMessageRequest(value: unknown): DeleteQueuedMessageRequest;
41
+ export declare function encodeCancelTurnRequest(value: CancelTurnRequest): unknown;
42
+ export declare function decodeCancelTurnRequest(value: unknown): CancelTurnRequest;
43
+ export declare function encodeTurnControlRequest(value: TurnControlRequest): unknown;
44
+ export declare function decodeTurnControlRequest(value: unknown): TurnControlRequest;
45
+ export declare function encodeTurnCancellationRequest(value: TurnCancellationRequest): unknown;
46
+ export declare function decodeTurnCancellationRequest(value: unknown): TurnCancellationRequest;
47
+ export declare function encodeToolCallCancellation(value: ToolCallCancellation): unknown;
48
+ export declare function decodeToolCallCancellation(value: unknown): ToolCallCancellation;
19
49
  export declare function encodeToolCallCompleted(value: ToolCallCompleted): unknown;
20
50
  export declare function decodeToolCallCompleted(value: unknown): ToolCallCompleted;
21
51
  export declare function encodeAgentEvent(value: AgentEvent): unknown;
22
52
  export declare function decodeAgentEvent(value: unknown): AgentEvent;
23
53
  export declare function encodeResolveInterruptInput(value: ResolveInterruptInput): unknown;
24
54
  export declare function decodeResolveInterruptInput(value: unknown): ResolveInterruptInput;
55
+ export declare function encodeContextSummary(value: ContextSummary): unknown;
56
+ export declare function decodeContextSummary(value: unknown): ContextSummary;
57
+ export declare function encodeAgentMessageChunk(value: AgentMessageChunk): unknown;
58
+ export declare function decodeAgentMessageChunk(value: unknown): AgentMessageChunk;
59
+ export declare function encodeAgentMessageChunkRange(value: AgentMessageChunkRange): unknown;
60
+ export declare function decodeAgentMessageChunkRange(value: unknown): AgentMessageChunkRange;
61
+ export declare function encodeAgentMessageIndex(value: AgentMessageIndex): unknown;
62
+ export declare function decodeAgentMessageIndex(value: unknown): AgentMessageIndex;
63
+ export declare function encodeTurnReplySequence(value: TurnReplySequence): unknown;
64
+ export declare function decodeTurnReplySequence(value: unknown): TurnReplySequence;
65
+ export declare function encodeCompactContextInput(value: CompactContextInput): unknown;
66
+ export declare function decodeCompactContextInput(value: unknown): CompactContextInput;
25
67
  export declare function encodeAgentSnapshot(value: AgentSnapshot): unknown;
26
68
  export declare function decodeAgentSnapshot(value: unknown): AgentSnapshot;
27
69
  export declare function encodeListAgentMessagesInput(value: ListAgentMessagesInput): unknown;
@@ -31,14 +73,33 @@ export declare function decodeAgentMessagesPage(value: unknown): AgentMessagesPa
31
73
  export declare const agentSessionStartInputCodec: Codec<AgentSessionStartInput>;
32
74
  export declare const agentStateCodec: Codec<AgentState>;
33
75
  export declare const agentMessageCodec: Codec<AgentMessage>;
34
- export declare const agentToolCallCodec: Codec<AgentToolCall>;
76
+ export declare const agentToolCallCodec: Codec<AgentToolCallRecord>;
35
77
  export declare const agentInterruptListCodec: Codec<readonly AgentInterrupt[]>;
36
78
  export declare const agentInterruptResolutionCodec: Codec<AgentInterruptResolution>;
37
79
  export declare const agentUsageCodec: Codec<AgentUsage>;
38
80
  export declare const agentUserMessageCodec: Codec<AgentUserMessage>;
81
+ export declare const agentPlanCodec: Codec<AgentPlan>;
82
+ export declare const planExecutionRequestCodec: Codec<PlanExecutionRequest>;
83
+ export declare const executePlanRequestCodec: Codec<ExecutePlanRequest>;
39
84
  export declare const toolCallCompletedCodec: Codec<ToolCallCompleted>;
40
85
  export declare const agentEventCodec: Codec<AgentEvent>;
41
86
  export declare const resolveInterruptInputCodec: Codec<ResolveInterruptInput>;
87
+ export declare const answerQuestionRequestCodec: Codec<AnswerQuestionRequest>;
88
+ export declare const steerUserMessageRequestCodec: Codec<SteerUserMessageRequest>;
89
+ export declare const deleteQueuedMessageRequestCodec: Codec<DeleteQueuedMessageRequest>;
90
+ export declare const cancelTurnRequestCodec: Codec<CancelTurnRequest>;
91
+ export declare const turnControlRequestCodec: Codec<TurnControlRequest>;
92
+ export declare const turnCancellationRequestCodec: Codec<TurnCancellationRequest>;
93
+ export declare const toolCallCancellationCodec: Codec<ToolCallCancellation>;
42
94
  export declare const agentSnapshotCodec: Codec<AgentSnapshot>;
43
95
  export declare const listAgentMessagesInputCodec: Codec<ListAgentMessagesInput>;
44
96
  export declare const agentMessagesPageCodec: Codec<AgentMessagesPage>;
97
+ export declare const sessionSettingsCodec: Codec<Readonly<Record<string, unknown>>>;
98
+ export declare const turnSessionSettingsCodec: Codec<TurnSessionSettings>;
99
+ export declare const updateSessionSettingsRequestCodec: Codec<UpdateSessionSettingsRequest>;
100
+ export declare const agentMessageChunkCodec: Codec<AgentMessageChunk>;
101
+ export declare const agentMessageIndexCodec: Codec<AgentMessageIndex>;
102
+ export declare const turnReplySequenceCodec: Codec<TurnReplySequence>;
103
+ export declare const contextSummaryCodec: Codec<ContextSummary>;
104
+ /** Input of `CompactContext` and `RecordTurnFailure`: a `CompactContextInput`, or `RunModel`'s JSON `null` as `undefined`. */
105
+ export declare const turnFailureRouteInputCodec: Codec<CompactContextInput | undefined>;