@superdurable/dex-agents 0.0.0-stage → 0.2.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/LICENSE +105 -0
- package/README.md +1981 -2
- 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 +108 -0
- package/dist/src/agent-context-compaction.js +39 -0
- package/dist/src/agent-context-compaction.js.map +1 -0
- package/dist/src/agent-event-writer.d.ts +26 -0
- package/dist/src/agent-event-writer.js +110 -0
- package/dist/src/agent-event-writer.js.map +1 -0
- package/dist/src/agent-framework-runner.d.ts +808 -0
- package/dist/src/agent-framework-runner.js +82 -0
- package/dist/src/agent-framework-runner.js.map +1 -0
- 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 +105 -0
- package/dist/src/agent-session-codecs.js +689 -0
- package/dist/src/agent-session-codecs.js.map +1 -0
- package/dist/src/agent-session-flow.d.ts +416 -0
- package/dist/src/agent-session-flow.js +623 -0
- package/dist/src/agent-session-flow.js.map +1 -0
- package/dist/src/agent-session-persistence.d.ts +133 -0
- package/dist/src/agent-session-persistence.js +74 -0
- package/dist/src/agent-session-persistence.js.map +1 -0
- 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-step-options.d.ts +27 -0
- package/dist/src/agent-session-step-options.js +39 -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 +179 -0
- package/dist/src/agent-session-steps.js +1272 -0
- package/dist/src/agent-session-steps.js.map +1 -0
- 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 +224 -0
- package/dist/src/agent-session-transitions.js +850 -0
- package/dist/src/agent-session-transitions.js.map +1 -0
- package/dist/src/agent-session-values.d.ts +998 -0
- package/dist/src/agent-session-values.js +162 -0
- package/dist/src/agent-session-values.js.map +1 -0
- 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 +10 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- 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 +158 -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 +7 -0
- package/dist/src/stepwise/index.js +12 -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 +189 -0
- package/dist/src/stepwise/stepwise-agent-runner.js +804 -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 +56 -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 +205 -0
- package/dist/src/testing/agent-session-test-client.js +290 -0
- package/dist/src/testing/agent-session-test-client.js.map +1 -0
- package/dist/src/testing/agent-test-environment.d.ts +52 -0
- package/dist/src/testing/agent-test-environment.js +86 -0
- package/dist/src/testing/agent-test-environment.js.map +1 -0
- package/dist/src/testing/agent-worker-process.d.ts +91 -0
- package/dist/src/testing/agent-worker-process.js +150 -0
- package/dist/src/testing/agent-worker-process.js.map +1 -0
- package/dist/src/testing/child-process-group.d.ts +33 -0
- package/dist/src/testing/child-process-group.js +164 -0
- package/dist/src/testing/child-process-group.js.map +1 -0
- package/dist/src/testing/coordination.d.ts +99 -0
- package/dist/src/testing/coordination.js +155 -0
- package/dist/src/testing/coordination.js.map +1 -0
- package/dist/src/testing/index.d.ts +8 -0
- package/dist/src/testing/index.js +16 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/polling.d.ts +31 -0
- package/dist/src/testing/polling.js +51 -0
- package/dist/src/testing/polling.js.map +1 -0
- package/dist/src/testing/private-dex-engine.d.ts +101 -0
- package/dist/src/testing/private-dex-engine.js +223 -0
- package/dist/src/testing/private-dex-engine.js.map +1 -0
- 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/testing/step-history.d.ts +40 -0
- package/dist/src/testing/step-history.js +59 -0
- package/dist/src/testing/step-history.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 +154 -0
- package/dist/src/ui-stream/agent-event-sse.js +159 -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 +72 -0
- package/dist/src/ui-stream/agent-session-record-reader.js +241 -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 +440 -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 +681 -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 +66 -0
- package/dist/src/ui-stream/agent-ui-messages.js +220 -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 +86 -4
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
* Returns the effective policy of one tool.
|
|
10
|
+
*
|
|
11
|
+
* Runners normally call {@link AgentTurnContext.resolveToolPolicy}. Call this function when an adapter
|
|
12
|
+
* classifies tools outside a turn, for example while building framework tool wrappers. Precedence: the
|
|
13
|
+
* tool's {@link ToolPolicy}, then `frameworkEffect`, then `defaultToolEffect`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const policy = resolveToolPolicy("refund_order", flow.options.toolPolicies, flow.options.defaultToolEffect);
|
|
18
|
+
* const label = policy.requiresApproval ? "needs approval" : "runs without approval";
|
|
19
|
+
* ```
|
|
20
|
+
* @param toolName - Tool name as the model calls it.
|
|
21
|
+
* @param toolPolicies - Explicit policies by tool name.
|
|
22
|
+
* @param defaultToolEffect - Effect of a tool without a policy or framework metadata.
|
|
23
|
+
* @param frameworkEffect - Effect declared by framework metadata, or `undefined`.
|
|
24
|
+
* @returns The effective policy.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveToolPolicy(toolName, toolPolicies, defaultToolEffect, frameworkEffect) {
|
|
27
|
+
const policy = Object.hasOwn(toolPolicies, toolName) ? toolPolicies[toolName] : undefined;
|
|
28
|
+
const effect = policy?.effect ?? frameworkEffect ?? defaultToolEffect;
|
|
29
|
+
const requiresApproval = policy?.requiresApproval ?? (effect === "non_idempotent_write" || effect === "unclassified");
|
|
30
|
+
return { effect, requiresApproval };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Tool failure that the model should see, thrown from {@link AgentFrameworkRunner.executeDeferredToolCall}.
|
|
34
|
+
*
|
|
35
|
+
* The session records the call as `failed` with this error's message and does not retry it. Throw any
|
|
36
|
+
* other error for an unexpected failure: `CallTool` retries it and, once its attempts run out, records
|
|
37
|
+
* `failed` for a `read` tool and `outcome_unknown` for a write; `CallSingleAttemptTool` records
|
|
38
|
+
* `outcome_unknown` at once, because the write may have taken effect.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* if (response.status === 404) {
|
|
43
|
+
* throw new ToolExecutionError(`order ${orderId} does not exist`);
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export class ToolExecutionError extends Error {
|
|
48
|
+
/**
|
|
49
|
+
* Creates a tool failure.
|
|
50
|
+
* @param message - Error text recorded on the call and shown to the model.
|
|
51
|
+
* @param options - Standard error options, such as `cause`.
|
|
52
|
+
*/
|
|
53
|
+
constructor(message, options) {
|
|
54
|
+
super(message, options);
|
|
55
|
+
this.name = "ToolExecutionError";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Maps MCP tool annotations to a framework effect for {@link AgentTurnContext.resolveToolPolicy}.
|
|
60
|
+
*
|
|
61
|
+
* Annotations are hints from the tool server. Pass the result only for servers the application
|
|
62
|
+
* trusts; otherwise leave the effect to policies and the session default.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const policy = turn.resolveToolPolicy(tool.name, toolEffectFromMcpToolAnnotations(tool.annotations ?? {}));
|
|
67
|
+
* ```
|
|
68
|
+
* @param annotations - The tool's MCP annotations.
|
|
69
|
+
* @returns `read` when `readOnlyHint` is `true`; otherwise `idempotent_write` when `idempotentHint` is
|
|
70
|
+
* `true`, whatever `destructiveHint` says, as in the Python core; otherwise `undefined`, so the session
|
|
71
|
+
* default applies.
|
|
72
|
+
*/
|
|
73
|
+
export function toolEffectFromMcpToolAnnotations(annotations) {
|
|
74
|
+
if (annotations.readOnlyHint === true) {
|
|
75
|
+
return "read";
|
|
76
|
+
}
|
|
77
|
+
if (annotations.idempotentHint === true) {
|
|
78
|
+
return "idempotent_write";
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=agent-framework-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-framework-runner.js","sourceRoot":"","sources":["../../src/agent-framework-runner.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAmD1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,YAAkD,EAClD,iBAA6B,EAC7B,eAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,eAAe,IAAI,iBAAiB,CAAC;IACtE,MAAM,gBAAgB,GACpB,MAAM,EAAE,gBAAgB,IAAI,CAAC,MAAM,KAAK,sBAAsB,IAAI,MAAM,KAAK,cAAc,CAAC,CAAC;IAC/F,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;AACtC,CAAC;AAogBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C;;;;OAIG;IACH,YAAmB,OAAe,EAAE,OAAsB;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AA+ND;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gCAAgC,CAC9C,WAA+B;IAE/B,IAAI,WAAW,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,WAAW,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AgentPlan, AgentPlanTask, InteractionMode, PlanStatus } from "./agent-session-values.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rejection message of a call to any tool other than `write_todos` in a `planning` turn; the same text as
|
|
4
|
+
* the Python core.
|
|
5
|
+
*/
|
|
6
|
+
export declare const planningTurnToolRejection = "The tool call was not run: a planning turn can only call write_todos.";
|
|
7
|
+
/** First line of the plan note while no plan exists; the same text as the Python core. */
|
|
8
|
+
export declare const noPlanNote = "[Dex] There is no plan yet.";
|
|
9
|
+
/** Last line of the plan note in a `planning` turn; the same text as the Python core. */
|
|
10
|
+
export declare const planningTurnInstruction: string;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the user message text of a turn that `execute_plan` started.
|
|
13
|
+
*
|
|
14
|
+
* @param revision - The approved {@link AgentPlan.revision}.
|
|
15
|
+
* @returns `[Dex] The user approved plan revision <n>. Execute it and keep the task statuses current with
|
|
16
|
+
* write_todos.`, the same text as the Python core.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildPlanExecutionMessage(revision: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the text that shows the model the current plan, or `undefined` for none.
|
|
21
|
+
*
|
|
22
|
+
* A runner that honors plan mode adds it to the model input of every model call, after the context summary
|
|
23
|
+
* and before the turn's messages, as user text. It is not stored as a message, so it always shows the
|
|
24
|
+
* latest plan. The text is the same as the Python core's `build_plan_note`:
|
|
25
|
+
*
|
|
26
|
+
* ```text
|
|
27
|
+
* [Dex] The current plan, revision 2, is draft:
|
|
28
|
+
* - [completed] Look up the order
|
|
29
|
+
* - [pending] Refund the order
|
|
30
|
+
* This turn only plans: write or revise the plan with write_todos, ...
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param plan - The {@link AgentPlan}, or `null` or `undefined` when there is none.
|
|
34
|
+
* @param interactionMode - The turn's mode; `undefined` means `chat`.
|
|
35
|
+
* @returns One line for the plan and one per task, then {@link planningTurnInstruction} in a `planning`
|
|
36
|
+
* turn, joined with newlines. {@link noPlanNote} stands for a missing or cleared plan in a `planning` turn.
|
|
37
|
+
* `undefined` when there is no plan to show outside a `planning` turn.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildPlanNote(plan: AgentPlan | null | undefined, interactionMode: InteractionMode | undefined): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the status of the plan that `write_todos` writes.
|
|
42
|
+
*
|
|
43
|
+
* @param tasks - The tasks written.
|
|
44
|
+
* @param interactionMode - The mode of the turn that wrote them.
|
|
45
|
+
* @returns `cleared` for no tasks, `draft` in a `planning` turn, `completed` when every task is completed,
|
|
46
|
+
* and `active` otherwise.
|
|
47
|
+
*/
|
|
48
|
+
export declare function planStatusAfterWrite(tasks: readonly AgentPlanTask[], interactionMode: InteractionMode | undefined): PlanStatus;
|
|
@@ -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,UAAU,yBAAyB,CAAC,QAAgB;IACxD,OAAO,CACL,yCAAyC,QAAQ,IAAI;QACrD,iEAAiE,CAClE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAkC,EAClC,eAA4C;IAE5C,MAAM,UAAU,GAAG,eAAe,KAAK,UAAU,CAAC;IAClD,IAAI,KAAe,CAAC;IACpB,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,KAAK,GAAG,CAAC,UAAU,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,KAAK,GAAG;YACN,oCAAoC,IAAI,CAAC,QAAQ,QAAQ,IAAI,CAAC,MAAM,GAAG;YACvE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;SAClE,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAA+B,EAC/B,eAA4C;IAE5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,eAAe,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,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","sourceRo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,CAAC;QAC1C,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC1E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { type Codec } from "@superdurable/dex";
|
|
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
|
+
export declare function encodeAgentSessionStartInput(value: AgentSessionStartInput): unknown;
|
|
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;
|
|
11
|
+
export declare function encodeAgentState(value: AgentState): unknown;
|
|
12
|
+
export declare function decodeAgentState(value: unknown): AgentState;
|
|
13
|
+
export declare function encodeAgentMessage(value: AgentMessage): unknown;
|
|
14
|
+
export declare function decodeAgentMessage(value: unknown): AgentMessage;
|
|
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;
|
|
19
|
+
export declare function encodeAgentInterrupt(value: AgentInterrupt): unknown;
|
|
20
|
+
export declare function decodeAgentInterrupt(value: unknown): AgentInterrupt;
|
|
21
|
+
export declare function encodeAgentInterruptResolution(value: AgentInterruptResolution): unknown;
|
|
22
|
+
export declare function decodeAgentInterruptResolution(value: unknown): AgentInterruptResolution;
|
|
23
|
+
export declare function encodeAnswerQuestionRequest(value: AnswerQuestionRequest): unknown;
|
|
24
|
+
export declare function decodeAnswerQuestionRequest(value: unknown): AnswerQuestionRequest;
|
|
25
|
+
export declare function encodeAgentUsage(value: AgentUsage): unknown;
|
|
26
|
+
export declare function decodeAgentUsage(value: unknown): AgentUsage;
|
|
27
|
+
export declare function encodeAgentUserMessage(value: AgentUserMessage): unknown;
|
|
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;
|
|
49
|
+
export declare function encodeToolCallCompleted(value: ToolCallCompleted): unknown;
|
|
50
|
+
export declare function decodeToolCallCompleted(value: unknown): ToolCallCompleted;
|
|
51
|
+
export declare function encodeAgentEvent(value: AgentEvent): unknown;
|
|
52
|
+
export declare function decodeAgentEvent(value: unknown): AgentEvent;
|
|
53
|
+
export declare function encodeResolveInterruptInput(value: ResolveInterruptInput): unknown;
|
|
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;
|
|
67
|
+
export declare function encodeAgentSnapshot(value: AgentSnapshot): unknown;
|
|
68
|
+
export declare function decodeAgentSnapshot(value: unknown): AgentSnapshot;
|
|
69
|
+
export declare function encodeListAgentMessagesInput(value: ListAgentMessagesInput): unknown;
|
|
70
|
+
export declare function decodeListAgentMessagesInput(value: unknown): ListAgentMessagesInput;
|
|
71
|
+
export declare function encodeAgentMessagesPage(value: AgentMessagesPage): unknown;
|
|
72
|
+
export declare function decodeAgentMessagesPage(value: unknown): AgentMessagesPage;
|
|
73
|
+
export declare const agentSessionStartInputCodec: Codec<AgentSessionStartInput>;
|
|
74
|
+
export declare const agentStateCodec: Codec<AgentState>;
|
|
75
|
+
export declare const agentMessageCodec: Codec<AgentMessage>;
|
|
76
|
+
export declare const agentToolCallCodec: Codec<AgentToolCallRecord>;
|
|
77
|
+
export declare const agentInterruptListCodec: Codec<readonly AgentInterrupt[]>;
|
|
78
|
+
export declare const agentInterruptResolutionCodec: Codec<AgentInterruptResolution>;
|
|
79
|
+
export declare const agentUsageCodec: Codec<AgentUsage>;
|
|
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>;
|
|
84
|
+
export declare const toolCallCompletedCodec: Codec<ToolCallCompleted>;
|
|
85
|
+
export declare const agentEventCodec: Codec<AgentEvent>;
|
|
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>;
|
|
94
|
+
export declare const agentSnapshotCodec: Codec<AgentSnapshot>;
|
|
95
|
+
export declare const listAgentMessagesInputCodec: Codec<ListAgentMessagesInput>;
|
|
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>;
|