@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
|
@@ -5,14 +5,108 @@
|
|
|
5
5
|
* - `running_model`: `RunModel` makes the turn's next model call.
|
|
6
6
|
* - `running_tools`: the requested tool calls run in parallel Steps, some possibly waiting for
|
|
7
7
|
* approval, and `ResumeTurn` waits for their results.
|
|
8
|
+
* - `compacting_context`: `CompactContext` summarizes earlier messages before the turn's next model
|
|
9
|
+
* call. Only a session with {@link AgentSessionOptions.compaction} reaches it.
|
|
10
|
+
* - `failed`: the session ended and takes no more messages. Its Flow closed failed, and
|
|
11
|
+
* {@link AgentState.lastTurnError} holds the reason.
|
|
8
12
|
*/
|
|
9
|
-
export type AgentSessionStatus = "waiting_for_user_message" | "running_model" | "running_tools";
|
|
13
|
+
export type AgentSessionStatus = "waiting_for_user_message" | "running_model" | "running_tools" | "compacting_context" | "failed";
|
|
14
|
+
/**
|
|
15
|
+
* Kind of a turn, stored in {@link AgentState.interactionMode} when the turn starts, for the runner to choose
|
|
16
|
+
* the tools it offers. Plan mode needs {@link AgentSessionOptions.planModeEnabled}; without it every turn is
|
|
17
|
+
* `chat`.
|
|
18
|
+
*
|
|
19
|
+
* - `chat`: an ordinary turn. The runner offers every tool.
|
|
20
|
+
* - `planning`: a turn that only plans. A message of the turn has `planMode`, or a `draft` plan waits for
|
|
21
|
+
* review. The runner offers only `write_todos`, and `RunModel` rejects any other call.
|
|
22
|
+
* - `executing`: a turn that `execute_plan` started. The runner offers every tool.
|
|
23
|
+
*/
|
|
24
|
+
export type InteractionMode = "chat" | "planning" | "executing";
|
|
25
|
+
/**
|
|
26
|
+
* Where an {@link AgentPlan} stands.
|
|
27
|
+
*
|
|
28
|
+
* - `draft`: a planning turn wrote the plan, and it waits for `execute_plan`.
|
|
29
|
+
* - `active`: the plan runs, or `write_todos` wrote it outside a planning turn with a task not completed.
|
|
30
|
+
* - `completed`: every task is completed.
|
|
31
|
+
* - `cleared`: `write_todos` replaced the plan with no tasks.
|
|
32
|
+
*/
|
|
33
|
+
export type PlanStatus = "draft" | "active" | "completed" | "cleared";
|
|
34
|
+
/** Where one task of an {@link AgentPlan} stands: `pending`, `in_progress`, or `completed`. */
|
|
35
|
+
export type PlanTaskStatus = "pending" | "in_progress" | "completed";
|
|
36
|
+
/** One task of an {@link AgentPlan}. */
|
|
37
|
+
export interface AgentPlanTask {
|
|
38
|
+
/** What the task does, as the model wrote it; never blank. Wire field: `content`. */
|
|
39
|
+
readonly content: string;
|
|
40
|
+
/** Where the task stands. Wire field: `status`. */
|
|
41
|
+
readonly status: PlanTaskStatus;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The session's plan, stored in the `AgentPlan` Attribute: a short task list the model replaces as a whole.
|
|
45
|
+
*
|
|
46
|
+
* `write_todos` replaces it with the next revision, and `execute_plan` names the revision the user approves.
|
|
47
|
+
* Compaction never summarizes it.
|
|
48
|
+
*/
|
|
49
|
+
export interface AgentPlan {
|
|
50
|
+
/**
|
|
51
|
+
* Revision of the plan, starting at 1. Every `write_todos` call that succeeds adds 1, an empty list
|
|
52
|
+
* included. Wire field: `revision`.
|
|
53
|
+
*/
|
|
54
|
+
readonly revision: number;
|
|
55
|
+
/** Where the plan stands. Wire field: `status`. */
|
|
56
|
+
readonly status: PlanStatus;
|
|
57
|
+
/** Every task in order; empty when `cleared`. Wire field: `tasks`. */
|
|
58
|
+
readonly tasks: readonly AgentPlanTask[];
|
|
59
|
+
/** RFC 3339 time of the last change. Wire field: `updated_at`. */
|
|
60
|
+
readonly updatedAt: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Input of the `execute_plan` RPC.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const snapshot = await client.invokeRPC(flow.getAgentSnapshot, sessionId);
|
|
68
|
+
* if (snapshot.plan?.status === "draft") {
|
|
69
|
+
* await client.invokeRPC(flow.executePlan, sessionId, { revision: snapshot.plan.revision });
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export interface ExecutePlanRequest {
|
|
74
|
+
/**
|
|
75
|
+
* {@link AgentPlan.revision} the user reviewed. A stale revision is refused, so the session never runs a
|
|
76
|
+
* plan the user did not see. Wire field: `revision`.
|
|
77
|
+
*/
|
|
78
|
+
readonly revision: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* One approved plan execution, published to the `PlanExecutions` ChannelMap instance named by the revision
|
|
82
|
+
* and held in the `PendingPlanExecution` Attribute until `AwaitUserMessage` starts its `executing` turn.
|
|
83
|
+
*/
|
|
84
|
+
export interface PlanExecutionRequest {
|
|
85
|
+
/** The approved {@link AgentPlan.revision}. Wire field: `revision`. */
|
|
86
|
+
readonly revision: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A session's settings: one JSON object that the application chooses, such as `{ model: "gpt-5-mini" }`.
|
|
90
|
+
*
|
|
91
|
+
* Set them in {@link AgentSessionStartInput.sessionSettings} and replace them with the
|
|
92
|
+
* `update_session_settings` RPC. A runner reads the settings of the running turn from
|
|
93
|
+
* `AgentTurnContext.sessionSettings`; a Stepwise agent maps them to a model client with
|
|
94
|
+
* `AgentDefinition.resolveModel`. Keys keep their spelling on the wire; nothing is converted to snake_case.
|
|
95
|
+
*
|
|
96
|
+
* Settings are stored in the session and returned by `get_agent_snapshot`, so never put a secret in them. Put a
|
|
97
|
+
* reference, such as a credential name, that the Worker resolves. Their compact JSON text must fit in
|
|
98
|
+
* `MAX_SESSION_SETTINGS_BYTES`; see `validateSessionSettings`.
|
|
99
|
+
*/
|
|
100
|
+
export type SessionSettings = Readonly<Record<string, unknown>>;
|
|
10
101
|
/**
|
|
11
102
|
* Input of the `StartAgentSession` Step, passed to `Client.startFlow`.
|
|
12
103
|
*
|
|
13
104
|
* @example
|
|
14
105
|
* ```ts
|
|
15
|
-
* await client.startFlow(flow, "session-42", {
|
|
106
|
+
* await client.startFlow(flow, "session-42", {
|
|
107
|
+
* initialMessage: "Summarize my inbox",
|
|
108
|
+
* sessionSettings: { model: "gpt-5-mini" },
|
|
109
|
+
* });
|
|
16
110
|
* ```
|
|
17
111
|
*/
|
|
18
112
|
export interface AgentSessionStartInput {
|
|
@@ -21,6 +115,15 @@ export interface AgentSessionStartInput {
|
|
|
21
115
|
* Blank text is treated as `null`. Wire field: `initial_message`.
|
|
22
116
|
*/
|
|
23
117
|
readonly initialMessage: string | null;
|
|
118
|
+
/**
|
|
119
|
+
* The session's {@link SessionSettings}, which every turn's `AgentTurnContext.sessionSettings` carries until
|
|
120
|
+
* `update_session_settings` replaces them. Absent or `null` starts without settings. Settings that the session
|
|
121
|
+
* refuses, because they are not a JSON object or are too large, fail the session at once with no retry; check
|
|
122
|
+
* them first with `validateSessionSettings`. Never put a secret in them: `get_agent_snapshot` and the browser
|
|
123
|
+
* snapshot JSON return them. Start sessions with settings only after every Worker of the Flow type runs
|
|
124
|
+
* dex-agents 0.2.0, because a 0.1.0 Worker drops them. Wire field: `session_settings`.
|
|
125
|
+
*/
|
|
126
|
+
readonly sessionSettings?: SessionSettings | null;
|
|
24
127
|
}
|
|
25
128
|
/** Small durable summary of an agent session, stored in the `AgentState` Attribute. */
|
|
26
129
|
export interface AgentState {
|
|
@@ -32,8 +135,28 @@ export interface AgentState {
|
|
|
32
135
|
readonly activeTurnId: string | null;
|
|
33
136
|
/** Sequence assigned to the next stored message; starts at 1. Wire field: `next_message_sequence`. */
|
|
34
137
|
readonly nextMessageSequence: number;
|
|
35
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Error text of the most recent failed turn, or `null`. With status `failed`, the reason the session ended.
|
|
140
|
+
* Wire field: `last_turn_error`.
|
|
141
|
+
*/
|
|
36
142
|
readonly lastTurnError: string | null;
|
|
143
|
+
/**
|
|
144
|
+
* Kind of the active turn, or of the last turn between turns; the session sets it when a turn starts.
|
|
145
|
+
* Wire field: `interaction_mode`, `chat` by default.
|
|
146
|
+
*
|
|
147
|
+
* Like every field plans added, a decoded value omits it at its default, so a value of a session that
|
|
148
|
+
* uses no plans has its 0.1.0 shape, and code that compares whole values keeps working; the wire always
|
|
149
|
+
* carries it. Treat `undefined` as `chat`.
|
|
150
|
+
*/
|
|
151
|
+
readonly interactionMode?: InteractionMode;
|
|
152
|
+
/**
|
|
153
|
+
* Whether `steer_user_message` and `cancel_turn` may end the active turn. A Worker that applies them sets it
|
|
154
|
+
* when a turn starts and clears it when the turn ends. An earlier Worker drops it whenever it writes
|
|
155
|
+
* `AgentState`, so the RPCs refuse a turn that such a Worker started or advanced. Wire field:
|
|
156
|
+
* `accepts_turn_control`. The decoder sets it only when it is `true`, so `undefined` means `false` and an idle
|
|
157
|
+
* state keeps its 0.1.0 shape.
|
|
158
|
+
*/
|
|
159
|
+
readonly acceptsTurnControl?: boolean;
|
|
37
160
|
}
|
|
38
161
|
/** Author of one stored agent message. */
|
|
39
162
|
export type AgentMessageRole = "user" | "assistant" | "tool";
|
|
@@ -79,16 +202,75 @@ export interface AgentMessage extends FrameworkMessage {
|
|
|
79
202
|
*/
|
|
80
203
|
export type ToolEffect = "read" | "idempotent_write" | "non_idempotent_write" | "unclassified";
|
|
81
204
|
/**
|
|
82
|
-
* Status of one deferred tool call record.
|
|
205
|
+
* Status of one deferred tool call record, as a runner sees it.
|
|
83
206
|
*
|
|
84
207
|
* `awaiting_approval` and `approved` are open. The other statuses are final: the session
|
|
85
208
|
* never runs a call whose record is final, and the runner reports the result to the model.
|
|
86
|
-
* `failed` means the tool threw {@link ToolExecutionError},
|
|
87
|
-
* its attempts ran out
|
|
88
|
-
*
|
|
209
|
+
* `failed` means the tool threw {@link ToolExecutionError}, a `read` call ended without a result after
|
|
210
|
+
* its attempts ran out, or the tool did not run (its error starts with {@link toolCallNotRunErrorPrefix}).
|
|
211
|
+
* `outcome_unknown` means a write's tool Step ended without a result, through a Worker crash, a timeout,
|
|
212
|
+
* or another error after its attempts ran out.
|
|
213
|
+
*
|
|
214
|
+
* The set of final statuses never grows, so an exhaustive mapping of final statuses stays complete.
|
|
215
|
+
* A stored record can also hold an {@link AgentToolCallWaitingStatus}; runners never see one.
|
|
89
216
|
*/
|
|
90
217
|
export type AgentToolCallStatus = "awaiting_approval" | "approved" | "rejected" | "succeeded" | "failed" | "outcome_unknown";
|
|
91
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* Non-final status of a stored record while a session Step waits on the call's behalf.
|
|
220
|
+
*
|
|
221
|
+
* - `awaiting_answer`: `AwaitQuestionAnswer` waits for `answer_question`. The call is an `ask_user`
|
|
222
|
+
* call, or a tool call whose tool returned {@link ToolInputRequested}.
|
|
223
|
+
* - `waiting_for_timer`: `AwaitTimer` waits until {@link AgentToolCallRecord.waitUntil} for a
|
|
224
|
+
* `durable_wait` call.
|
|
225
|
+
* - `waiting_for_task`: the tool returned {@link ToolTaskStarted}, and `PollToolTask` polls the task in
|
|
226
|
+
* {@link AgentToolCallRecord.taskId} every {@link AgentToolCallRecord.taskPollIntervalSeconds}.
|
|
227
|
+
*
|
|
228
|
+
* These statuses appear in {@link AgentSnapshot.toolCalls} and in records read with
|
|
229
|
+
* `Client.getAttributes`. A runner never receives a record with one of them: `RunModel` runs only after
|
|
230
|
+
* every record of the turn is final, and a tool Step runs only an `approved` record.
|
|
231
|
+
*/
|
|
232
|
+
export type AgentToolCallWaitingStatus = "awaiting_answer" | "waiting_for_timer" | "waiting_for_task";
|
|
233
|
+
/** Status of a stored tool call record: an {@link AgentToolCallStatus} or an {@link AgentToolCallWaitingStatus}. */
|
|
234
|
+
export type AgentToolCallRecordStatus = AgentToolCallStatus | AgentToolCallWaitingStatus;
|
|
235
|
+
/**
|
|
236
|
+
* How a question that a tool or its task asked was resolved.
|
|
237
|
+
*
|
|
238
|
+
* - `answered`: the user answered with `answer_question`.
|
|
239
|
+
* - `declined`: the user declined with `resolve_interrupt` and `approved` `false`.
|
|
240
|
+
* - `deadline_passed`: `interruptDeadlineMs` passed first.
|
|
241
|
+
*
|
|
242
|
+
* A tool's own question is only ever answered: a decline or a passed deadline ends the call with
|
|
243
|
+
* `rejected`. A question that a started task asked through {@link AgentFrameworkRunner.pollToolTask}
|
|
244
|
+
* goes back to the task in every case, so the task, not the session, decides what a decline means.
|
|
245
|
+
*/
|
|
246
|
+
export type QuestionResolution = "answered" | "declined" | "deadline_passed";
|
|
247
|
+
/**
|
|
248
|
+
* How one question that a tool asked by returning {@link ToolInputRequested} was resolved.
|
|
249
|
+
*
|
|
250
|
+
* `AwaitQuestionAnswer` appends one to the call's `inputAnswers` when the user answers. The tool then
|
|
251
|
+
* runs again and receives every answer in {@link DeferredToolExecution.inputAnswers}. For a question that
|
|
252
|
+
* a started task asked, it also appends one when the user declines or the deadline passes, and
|
|
253
|
+
* `PollToolTask` hands it to the task as {@link ToolTaskPoll.pendingAnswer}.
|
|
254
|
+
*/
|
|
255
|
+
export interface QuestionAnswer {
|
|
256
|
+
/** Interrupt ID of the resolved question, `<toolCallId>-input-<n>`. Wire field: `interrupt_id`. */
|
|
257
|
+
readonly interruptId: string;
|
|
258
|
+
/** Question text the tool asked. Wire field: `question`. */
|
|
259
|
+
readonly question: string;
|
|
260
|
+
/**
|
|
261
|
+
* The user's answer, exactly as sent to `answer_question`. For a declined question, the user's rejection
|
|
262
|
+
* message or {@link defaultQuestionDeclinedToolResult}; for a passed deadline, {@link questionDeadlinePassed}.
|
|
263
|
+
* Wire field: `answer`.
|
|
264
|
+
*/
|
|
265
|
+
readonly answer: string;
|
|
266
|
+
/**
|
|
267
|
+
* How the question was resolved; `answered` when absent, the only resolution of a tool's own question.
|
|
268
|
+
* Answers the session reads always carry it; it is optional so that code that builds answers by hand keeps
|
|
269
|
+
* compiling. Wire field: `resolution`.
|
|
270
|
+
*/
|
|
271
|
+
readonly resolution?: QuestionResolution;
|
|
272
|
+
}
|
|
273
|
+
/** Durable record of one deferred tool call, as a runner sees it; stored in `AgentToolCalls` under its tool call ID. */
|
|
92
274
|
export interface AgentToolCall {
|
|
93
275
|
/** Framework tool call ID; non-empty and slash-free. Wire field: `tool_call_id`. */
|
|
94
276
|
readonly toolCallId: string;
|
|
@@ -108,7 +290,8 @@ export interface AgentToolCall {
|
|
|
108
290
|
readonly output: string | null;
|
|
109
291
|
/**
|
|
110
292
|
* The `ToolExecutionError` message, or the failed Step's recovery detail, after `failed` or
|
|
111
|
-
* `outcome_unknown`; otherwise `null`. Wire field: `error`.
|
|
293
|
+
* `outcome_unknown`; otherwise `null`. Wire field: `error`. A tool Step that failed before the tool
|
|
294
|
+
* ran records `failed` with {@link toolCallNotRunErrorPrefix}, `": "`, and the recovery detail.
|
|
112
295
|
*/
|
|
113
296
|
readonly error: string | null;
|
|
114
297
|
/** Rejection text after `rejected`, otherwise `null`. Wire field: `rejection_message`. */
|
|
@@ -118,30 +301,195 @@ export interface AgentToolCall {
|
|
|
118
301
|
* It extends the planned contract, as in the Python core. Wire field: `deferral_order`.
|
|
119
302
|
*/
|
|
120
303
|
readonly deferralOrder: number;
|
|
304
|
+
/**
|
|
305
|
+
* {@link DeferredToolCall.toolSourceReference}: opaque text the tool's source stored with the call,
|
|
306
|
+
* absent when it stored none. Wire field: `tool_source_reference`, `null` when absent.
|
|
307
|
+
*/
|
|
308
|
+
readonly toolSourceReference?: string;
|
|
309
|
+
/**
|
|
310
|
+
* W3C `traceparent` of the activation root that the call's `execute_tool` spans join; absent when
|
|
311
|
+
* none recorded. The session sets it when `RunModel` defers the call and again when an approval
|
|
312
|
+
* starts a new activation, so parallel activations never swap tool spans. Wire field:
|
|
313
|
+
* `trace_context`, `null` when absent.
|
|
314
|
+
*/
|
|
315
|
+
readonly traceContext?: string;
|
|
316
|
+
/**
|
|
317
|
+
* RFC 3339 time at which a `durable_wait` call's Timer ends, otherwise `null`. Wire field: `wait_until`.
|
|
318
|
+
*
|
|
319
|
+
* Records the session reads always carry this field. It is optional only so that code that builds
|
|
320
|
+
* records by hand, such as a unit test, keeps compiling.
|
|
321
|
+
*/
|
|
322
|
+
readonly waitUntil?: string | null;
|
|
323
|
+
/**
|
|
324
|
+
* Opaque text from the tool's last {@link ToolInputRequested}, returned to the tool when it runs
|
|
325
|
+
* again after the answer. For a call waiting for a task, the continuation of the task's last question
|
|
326
|
+
* until the next poll, and then what the last {@link ToolTaskPending} returned. `null` when there is none.
|
|
327
|
+
* Wire field: `input_continuation`. Optional for the same reason as {@link waitUntil}.
|
|
328
|
+
*/
|
|
329
|
+
readonly inputContinuation?: string | null;
|
|
330
|
+
/**
|
|
331
|
+
* Answers to the questions the tool asked through {@link ToolInputRequested}, oldest first; empty
|
|
332
|
+
* for other calls. Wire field: `input_answers`. Optional for the same reason as {@link waitUntil}.
|
|
333
|
+
*/
|
|
334
|
+
readonly inputAnswers?: readonly QuestionAnswer[];
|
|
335
|
+
/**
|
|
336
|
+
* Question text of the tool's pending {@link ToolInputRequested} while the record is
|
|
337
|
+
* `awaiting_answer`, otherwise `null`. It is `null` for an `ask_user` call, whose question is in
|
|
338
|
+
* {@link arguments}. `AwaitQuestionAnswer` raises the question interrupt from it under the
|
|
339
|
+
* `PendingInterrupts` lock. Wire field: `input_question`. Optional for the same reason as
|
|
340
|
+
* {@link waitUntil}.
|
|
341
|
+
*/
|
|
342
|
+
readonly inputQuestion?: string | null;
|
|
343
|
+
/**
|
|
344
|
+
* Choices of that pending {@link ToolInputRequested}; empty for a free-text question or when no tool
|
|
345
|
+
* question is pending. Wire field: `input_choices`. Optional for the same reason as {@link waitUntil}.
|
|
346
|
+
*/
|
|
347
|
+
readonly inputChoices?: readonly string[];
|
|
348
|
+
/**
|
|
349
|
+
* Whether that pending {@link ToolInputRequested} accepts free text; `true` when no tool question is
|
|
350
|
+
* pending. Wire field: `input_allows_free_text`. Optional for the same reason as {@link waitUntil}.
|
|
351
|
+
*/
|
|
352
|
+
readonly inputAllowsFreeText?: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Why steering or `cancel_turn` abandoned the call before it started, on a `rejected` record;
|
|
355
|
+
* otherwise `null`. Wire field: `cancellation_reason`. Optional for the same reason as
|
|
356
|
+
* {@link waitUntil}.
|
|
357
|
+
*/
|
|
358
|
+
readonly cancellationReason?: ToolCallCancellationReason | null;
|
|
359
|
+
/**
|
|
360
|
+
* The remote task ID from the tool's {@link ToolTaskStarted}, or `null` for a call that started no
|
|
361
|
+
* task. It stays on the record after the task finishes. Wire field: `task_id`. Optional for the same
|
|
362
|
+
* reason as {@link waitUntil}.
|
|
363
|
+
*/
|
|
364
|
+
readonly taskId?: string | null;
|
|
365
|
+
/**
|
|
366
|
+
* Whole seconds `PollToolTask` waits before the next poll, at least 1, from {@link ToolTaskStarted} or
|
|
367
|
+
* the last {@link ToolTaskPending}; `null` for a call that started no task. Wire field:
|
|
368
|
+
* `task_poll_interval_seconds`. Optional for the same reason as {@link waitUntil}.
|
|
369
|
+
*/
|
|
370
|
+
readonly taskPollIntervalSeconds?: number | null;
|
|
371
|
+
/**
|
|
372
|
+
* Whether the last entry of {@link inputAnswers}, the resolution of the task's last question, has not
|
|
373
|
+
* reached the task yet. `AwaitQuestionAnswer` sets it, `PollToolTask` then polls at once and hands that
|
|
374
|
+
* entry to the runner, and the poll's commit clears it. Wire field: `task_answer_pending`. Optional for
|
|
375
|
+
* the same reason as {@link waitUntil}.
|
|
376
|
+
*/
|
|
377
|
+
readonly taskAnswerPending?: boolean;
|
|
121
378
|
}
|
|
122
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* Why steering or cancellation abandoned a tool call before it started.
|
|
381
|
+
*
|
|
382
|
+
* - `steered`: `steer_user_message` superseded the turn.
|
|
383
|
+
* - `turn_cancelled`: `cancel_turn` stopped the turn.
|
|
384
|
+
*
|
|
385
|
+
* A `rejected` record carries one in {@link AgentToolCall.cancellationReason}; its `rejectionMessage` is
|
|
386
|
+
* {@link toolCallCancelledBySteeringResult} or {@link toolCallCancelledByTurnCancellationResult}.
|
|
387
|
+
*/
|
|
388
|
+
export type ToolCallCancellationReason = "steered" | "turn_cancelled";
|
|
389
|
+
/**
|
|
390
|
+
* A stored tool call record, as `get_agent_snapshot` and `Client.getAttributes` return it.
|
|
391
|
+
*
|
|
392
|
+
* It is an {@link AgentToolCall} whose status may also be an {@link AgentToolCallWaitingStatus}, and
|
|
393
|
+
* whose fields added in 0.2.0 are always present.
|
|
394
|
+
*/
|
|
395
|
+
export interface AgentToolCallRecord extends Omit<AgentToolCall, "status" | "waitUntil" | "inputContinuation" | "inputAnswers" | "inputQuestion" | "inputChoices" | "inputAllowsFreeText" | "cancellationReason" | "taskId" | "taskPollIntervalSeconds" | "taskAnswerPending"> {
|
|
396
|
+
/** Current status. Wire field: `status`. */
|
|
397
|
+
readonly status: AgentToolCallRecordStatus;
|
|
398
|
+
/** See {@link AgentToolCall.waitUntil}. Wire field: `wait_until`. */
|
|
399
|
+
readonly waitUntil: string | null;
|
|
400
|
+
/** See {@link AgentToolCall.inputContinuation}. Wire field: `input_continuation`. */
|
|
401
|
+
readonly inputContinuation: string | null;
|
|
402
|
+
/** See {@link AgentToolCall.inputAnswers}. Wire field: `input_answers`. */
|
|
403
|
+
readonly inputAnswers: readonly QuestionAnswer[];
|
|
404
|
+
/** See {@link AgentToolCall.inputQuestion}. Wire field: `input_question`. */
|
|
405
|
+
readonly inputQuestion: string | null;
|
|
406
|
+
/** See {@link AgentToolCall.inputChoices}. Wire field: `input_choices`. */
|
|
407
|
+
readonly inputChoices: readonly string[];
|
|
408
|
+
/** See {@link AgentToolCall.inputAllowsFreeText}. Wire field: `input_allows_free_text`. */
|
|
409
|
+
readonly inputAllowsFreeText: boolean;
|
|
410
|
+
/**
|
|
411
|
+
* See {@link AgentToolCall.cancellationReason}. Wire field: `cancellation_reason`. Records the session reads
|
|
412
|
+
* always carry it; it is optional so that code that builds records by hand keeps compiling.
|
|
413
|
+
*/
|
|
414
|
+
readonly cancellationReason?: ToolCallCancellationReason | null;
|
|
415
|
+
/**
|
|
416
|
+
* See {@link AgentToolCall.taskId}. Wire field: `task_id`. Records the session reads always carry it; it is
|
|
417
|
+
* optional so that code that builds records by hand keeps compiling, and a missing value means `null`.
|
|
418
|
+
*/
|
|
419
|
+
readonly taskId?: string | null;
|
|
420
|
+
/**
|
|
421
|
+
* See {@link AgentToolCall.taskPollIntervalSeconds}. Wire field: `task_poll_interval_seconds`. Optional for
|
|
422
|
+
* the same reason as {@link taskId}; a missing value means `null`.
|
|
423
|
+
*/
|
|
424
|
+
readonly taskPollIntervalSeconds?: number | null;
|
|
425
|
+
/**
|
|
426
|
+
* See {@link AgentToolCall.taskAnswerPending}. Wire field: `task_answer_pending`. Optional for the same
|
|
427
|
+
* reason as {@link taskId}; a missing value means `false`.
|
|
428
|
+
*/
|
|
429
|
+
readonly taskAnswerPending?: boolean;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Kind of one {@link AgentInterrupt}.
|
|
433
|
+
*
|
|
434
|
+
* - `tool_approval`: a tool call waits for approval. Answer it with `resolve_interrupt`.
|
|
435
|
+
* - `question`: the model, through `ask_user`, or a tool, through {@link ToolInputRequested}, asked the
|
|
436
|
+
* user a question. Answer it with `answer_question`, or decline it with `resolve_interrupt` and
|
|
437
|
+
* `approved` `false`.
|
|
438
|
+
*/
|
|
439
|
+
export type AgentInterruptKind = "tool_approval" | "question";
|
|
440
|
+
/** One pending approval or question, stored in the `PendingInterrupts` Attribute. */
|
|
123
441
|
export interface AgentInterrupt {
|
|
124
|
-
/**
|
|
442
|
+
/**
|
|
443
|
+
* Interrupt ID passed to `resolve_interrupt` or `answer_question`. It equals the tool call ID for a
|
|
444
|
+
* tool approval and an `ask_user` question, and is `<toolCallId>-input-<n>` for the `n`-th question a
|
|
445
|
+
* tool asked through {@link ToolInputRequested}. Wire field: `interrupt_id`.
|
|
446
|
+
*/
|
|
125
447
|
readonly interruptId: string;
|
|
126
448
|
/** Interrupt kind. Wire field: `kind`. */
|
|
127
|
-
readonly kind:
|
|
128
|
-
/** Tool call
|
|
449
|
+
readonly kind: AgentInterruptKind;
|
|
450
|
+
/** Tool call that waits. Wire field: `tool_call_id`. */
|
|
129
451
|
readonly toolCallId: string;
|
|
130
|
-
/** Tool name. Wire field: `tool_name`. */
|
|
452
|
+
/** Tool name; `ask_user` for an `ask_user` question. Wire field: `tool_name`. */
|
|
131
453
|
readonly toolName: string;
|
|
132
454
|
/** Tool arguments as JSON text. Wire field: `arguments`. */
|
|
133
455
|
readonly arguments: string;
|
|
134
456
|
/** RFC 3339 time at which the interrupt was raised. Wire field: `created_at`. */
|
|
135
457
|
readonly createdAt: string;
|
|
136
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* RFC 3339 deadline, or `null` for no deadline. After it, the session rejects the call with
|
|
460
|
+
* {@link approvalDeadlinePassed} or {@link questionDeadlinePassed}. Wire field: `deadline`.
|
|
461
|
+
*/
|
|
137
462
|
readonly deadline: string | null;
|
|
463
|
+
/**
|
|
464
|
+
* Question text of a `question` interrupt, otherwise `null`. Wire field: `question`.
|
|
465
|
+
*
|
|
466
|
+
* Interrupts the session reads always carry this field and the two below. They are optional only so
|
|
467
|
+
* that code written against 0.1.0, which builds interrupts by hand, keeps compiling; treat `undefined`
|
|
468
|
+
* as `null`, an empty list, and `true`.
|
|
469
|
+
*/
|
|
470
|
+
readonly question?: string | null;
|
|
471
|
+
/** Answers to offer for a `question` interrupt; empty for a free-text question. Wire field: `choices`. */
|
|
472
|
+
readonly choices?: readonly string[];
|
|
473
|
+
/**
|
|
474
|
+
* Whether `answer_question` accepts an answer that is not one of {@link choices}. Always `true` when
|
|
475
|
+
* `choices` is empty and for a tool approval. Wire field: `allows_free_text`.
|
|
476
|
+
*/
|
|
477
|
+
readonly allowsFreeText?: boolean;
|
|
138
478
|
}
|
|
139
479
|
/** Resolution of one interrupt, published to the `InterruptResolutions` ChannelMap. */
|
|
140
480
|
export interface AgentInterruptResolution {
|
|
141
|
-
/**
|
|
481
|
+
/**
|
|
482
|
+
* Whether the tool call may run, or, for a question, whether the user answered it. Wire field:
|
|
483
|
+
* `approved`.
|
|
484
|
+
*/
|
|
142
485
|
readonly approved: boolean;
|
|
143
|
-
/** Text shown to the model when rejected, or `null`. Wire field: `rejection_message`. */
|
|
486
|
+
/** Text shown to the model when rejected or declined, or `null`. Wire field: `rejection_message`. */
|
|
144
487
|
readonly rejectionMessage: string | null;
|
|
488
|
+
/**
|
|
489
|
+
* The answer to a `question` interrupt, otherwise `null`. Wire field: `answer`. Resolutions the
|
|
490
|
+
* session reads always carry it; it is optional so that 0.1.0 code keeps compiling.
|
|
491
|
+
*/
|
|
492
|
+
readonly answer?: string | null;
|
|
145
493
|
}
|
|
146
494
|
/**
|
|
147
495
|
* Model usage counters, stored cumulatively in the `AgentUsage` Attribute.
|
|
@@ -170,10 +518,120 @@ export interface ToolCallCompleted {
|
|
|
170
518
|
/** Tool call whose record is final. Wire field: `tool_call_id`. */
|
|
171
519
|
readonly toolCallId: string;
|
|
172
520
|
}
|
|
173
|
-
/**
|
|
521
|
+
/**
|
|
522
|
+
* One user message, the input of the `send_user_message` RPC and the value of the `QueuedUserMessages` and
|
|
523
|
+
* `SteeredUserMessages` Channels.
|
|
524
|
+
*/
|
|
174
525
|
export interface AgentUserMessage {
|
|
175
526
|
/** Message text. Blank text is rejected. Wire field: `text`. */
|
|
176
527
|
readonly text: string;
|
|
528
|
+
/**
|
|
529
|
+
* Whether the message starts a `planning` turn, which drafts a plan for review instead of doing the work.
|
|
530
|
+
* `send_user_message` rejects it unless {@link AgentSessionOptions.planModeEnabled} is set. Wire field:
|
|
531
|
+
* `plan_mode`, `false` by default; a decoded message omits it when `false`, and `null` reads as `false`.
|
|
532
|
+
*/
|
|
533
|
+
readonly planMode?: boolean;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* One user message that waits in `QueuedUserMessages` or `SteeredUserMessages`, as `get_agent_snapshot` lists it,
|
|
537
|
+
* so a UI can delete or steer a queued message by its ID.
|
|
538
|
+
*/
|
|
539
|
+
export interface PendingUserMessage {
|
|
540
|
+
/** Channel message ID that Dex assigned when the message was published. Wire field: `message_id`. */
|
|
541
|
+
readonly messageId: string;
|
|
542
|
+
/** The user message. Wire field: `message`. */
|
|
543
|
+
readonly message: AgentUserMessage;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Input of the `steer_user_message` RPC. Set exactly one field: `messageId` moves a queued message, and `text`
|
|
547
|
+
* sends a new one.
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* ```ts
|
|
551
|
+
* await client.invokeRPC(flow.steerUserMessage, sessionId, { messageId: null, text: "Use staging instead" });
|
|
552
|
+
* const [queued] = (await client.invokeRPC(flow.getAgentSnapshot, sessionId)).queuedMessages ?? [];
|
|
553
|
+
* if (queued !== undefined) {
|
|
554
|
+
* await client.invokeRPC(flow.steerUserMessage, sessionId, { messageId: queued.messageId, text: null });
|
|
555
|
+
* }
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
export interface SteerUserMessageRequest {
|
|
559
|
+
/** {@link PendingUserMessage.messageId} of a queued message, or `null`. Wire field: `message_id`. */
|
|
560
|
+
readonly messageId: string | null;
|
|
561
|
+
/** Text of a new steered message, or `null`. Wire field: `text`. */
|
|
562
|
+
readonly text: string | null;
|
|
563
|
+
}
|
|
564
|
+
/** Input of the `delete_queued_message` RPC. */
|
|
565
|
+
export interface DeleteQueuedMessageRequest {
|
|
566
|
+
/** {@link PendingUserMessage.messageId} of a queued message. Wire field: `message_id`. */
|
|
567
|
+
readonly messageId: string;
|
|
568
|
+
}
|
|
569
|
+
/** Input of the `cancel_turn` RPC. */
|
|
570
|
+
export interface CancelTurnRequest {
|
|
571
|
+
/**
|
|
572
|
+
* The turn to stop, or `null` for whichever turn is active. A turn ID that is not the active turn makes the
|
|
573
|
+
* RPC return `false`. Wire field: `turn_id`.
|
|
574
|
+
*/
|
|
575
|
+
readonly turnId: string | null;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Input of the `update_session_settings` RPC, which replaces the session's settings from the next turn on.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```ts
|
|
582
|
+
* await client.invokeRpc(flow.updateSessionSettings, "session-42", { sessionSettings: { model: "gpt-5" } });
|
|
583
|
+
* ```
|
|
584
|
+
*/
|
|
585
|
+
export interface UpdateSessionSettingsRequest {
|
|
586
|
+
/**
|
|
587
|
+
* The complete new {@link SessionSettings}. They replace the old settings; nothing is merged, and `{}` clears
|
|
588
|
+
* them. Never put a secret in them. `null`, which a missing field also decodes to, makes the RPC return
|
|
589
|
+
* `false` and change nothing. Wire field: `session_settings`.
|
|
590
|
+
*/
|
|
591
|
+
readonly sessionSettings: SessionSettings | null;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* The settings one turn started with, stored in the `TurnSessionSettings` Attribute.
|
|
595
|
+
*
|
|
596
|
+
* The Step that starts a turn writes it in the commit that starts the turn. The session reads it only while
|
|
597
|
+
* {@link turnId} is `AgentState.activeTurnId`, so a copy an earlier turn left, such as when a Worker without
|
|
598
|
+
* session settings started the current turn, reads as no settings.
|
|
599
|
+
*/
|
|
600
|
+
export interface TurnSessionSettings {
|
|
601
|
+
/** Turn ID of the turn that started with these settings. Wire field: `turn_id`. */
|
|
602
|
+
readonly turnId: string;
|
|
603
|
+
/** The settings, a non-empty JSON object. Wire field: `session_settings`. */
|
|
604
|
+
readonly sessionSettings: SessionSettings;
|
|
605
|
+
}
|
|
606
|
+
/** Name of the RPC that published one {@link TurnControlRequest}. */
|
|
607
|
+
export type TurnControlKind = "steer" | "cancel_turn";
|
|
608
|
+
/**
|
|
609
|
+
* Wake-up of a waiting session Step, published to the internal `TurnControlRequests` Channel by
|
|
610
|
+
* `steer_user_message` and `cancel_turn`. The session decides from `SteeredUserMessages` and
|
|
611
|
+
* `TurnCancellationRequest`, not from this message.
|
|
612
|
+
*/
|
|
613
|
+
export interface TurnControlRequest {
|
|
614
|
+
/** The RPC that published it. Wire field: `kind`. */
|
|
615
|
+
readonly kind: TurnControlKind;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* The latest `cancel_turn` request, stored in the `TurnCancellationRequest` Attribute. A turn is cancelled while
|
|
619
|
+
* `turnId` equals `AgentState.activeTurnId`. Turn IDs never repeat, so a request for an earlier turn never matches.
|
|
620
|
+
*/
|
|
621
|
+
export interface TurnCancellationRequest {
|
|
622
|
+
/** The turn to stop. Wire field: `turn_id`. */
|
|
623
|
+
readonly turnId: string;
|
|
624
|
+
/** RFC 3339 time of the request. Wire field: `requested_at`. */
|
|
625
|
+
readonly requestedAt: string;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Wake-up of the Step that waits on one tool call, published by `ResumeTurn` to the internal
|
|
629
|
+
* `ToolCallCancellations` ChannelMap instance named by the tool call ID. The waiting Step decides from the
|
|
630
|
+
* session's flags, not from this message.
|
|
631
|
+
*/
|
|
632
|
+
export interface ToolCallCancellation {
|
|
633
|
+
/** Why the turn ends. Wire field: `reason`. */
|
|
634
|
+
readonly reason: ToolCallCancellationReason;
|
|
177
635
|
}
|
|
178
636
|
/**
|
|
179
637
|
* Standard type of one {@link AgentEvent}. Adapters may write other types with an adapter prefix.
|
|
@@ -182,18 +640,37 @@ export interface AgentUserMessage {
|
|
|
182
640
|
* - `turn_started`: `{"sequence"}`, the sequence of the user message that started the turn.
|
|
183
641
|
* - `turn_completed`: `{"message_count"}`, the number of messages the turn appended.
|
|
184
642
|
* - `turn_failed`: `{"error"}`.
|
|
643
|
+
* - `turn_steered`: `{"steered_message_count","message_count"}`, when steering ended the turn before its final
|
|
644
|
+
* answer: the steered messages that start the next turn, and the messages the ended turn appended. Treat it
|
|
645
|
+
* like `turn_completed`.
|
|
646
|
+
* - `turn_cancelled`: `{"message_count"}`, when `cancel_turn` ended the turn before its final answer. Treat it
|
|
647
|
+
* like `turn_completed`.
|
|
185
648
|
* - `text_delta` and `reasoning_delta`: `{"text"}`.
|
|
186
649
|
* - `tool_call_started`: `{"tool_call_id","tool_name"}`.
|
|
187
650
|
* - `tool_call_finished`: `{"tool_call_id","tool_name","status"}`, when a record becomes final,
|
|
188
651
|
* including a rejection.
|
|
189
652
|
* - `tool_call_deferred`: `{"tool_call_id","tool_name","effect","requires_approval"}`, when the model
|
|
190
|
-
* asks for a call, which then runs in its own Step.
|
|
191
|
-
* - `interrupt_raised`: `{"interrupt_id","tool_call_id","tool_name","deadline"
|
|
192
|
-
*
|
|
653
|
+
* asks for a call, which then runs in its own Step or, for a built-in tool, waits in the session.
|
|
654
|
+
* - `interrupt_raised`: `{"interrupt_id","kind","tool_call_id","tool_name","deadline","question",
|
|
655
|
+
* "choices","allows_free_text"}`. For a tool approval, `question` is `null`, `choices` is empty, and
|
|
656
|
+
* `allows_free_text` is `true`.
|
|
657
|
+
* - `interrupt_resolved`: `{"interrupt_id","kind","approved","answered","rejection_message",
|
|
658
|
+
* "cancellation_reason"}`. `answered` is `true` only for an answered question. `cancellation_reason`
|
|
659
|
+
* is `"steered"` or `"turn_cancelled"` when steering or `cancel_turn` abandoned the call, otherwise `null`.
|
|
660
|
+
* - `timer_started`: `{"tool_call_id","wait_until","reason"}`, when a `durable_wait` call starts its Timer.
|
|
661
|
+
* - `plan_updated`: `{"revision","status","task_count"}`, when `write_todos` replaced the plan or an
|
|
662
|
+
* approval marked a draft `active`.
|
|
663
|
+
* - `plan_execution_started`: `{"revision"}`, after the `turn_started` of an `executing` turn.
|
|
664
|
+
* - `tool_task_started`: `{"tool_call_id","tool_name","task_id"}`, when a tool starts remote work that
|
|
665
|
+
* `PollToolTask` polls.
|
|
193
666
|
* - `usage_recorded`: `{"recorded","session"}`: one model call's and the cumulative usage, each with
|
|
194
667
|
* {@link AgentUsage} wire fields.
|
|
668
|
+
* - `compaction_started`: `{"through_sequence"}`, when `CompactContext` starts summarizing the messages
|
|
669
|
+
* through that sequence. A retried attempt writes it again.
|
|
670
|
+
* - `compaction_finished`: `{"generation","through_sequence"}`, when `CompactContext` wrote a
|
|
671
|
+
* {@link ContextSummary}.
|
|
195
672
|
*/
|
|
196
|
-
export type AgentEventType = "turn_started" | "turn_completed" | "turn_failed" | "text_delta" | "reasoning_delta" | "tool_call_started" | "tool_call_finished" | "tool_call_deferred" | "interrupt_raised" | "interrupt_resolved" | "usage_recorded";
|
|
673
|
+
export type AgentEventType = "turn_started" | "turn_completed" | "turn_failed" | "turn_steered" | "turn_cancelled" | "text_delta" | "reasoning_delta" | "tool_call_started" | "tool_call_finished" | "tool_call_deferred" | "interrupt_raised" | "interrupt_resolved" | "timer_started" | "plan_updated" | "plan_execution_started" | "tool_task_started" | "usage_recorded" | "compaction_started" | "compaction_finished";
|
|
197
674
|
/** One best-effort live event, written to the `AgentEvents` Stream. */
|
|
198
675
|
export interface AgentEvent {
|
|
199
676
|
/** An {@link AgentEventType} or an adapter-specific type such as `"vercel_ai.step"`. Wire field: `type`. */
|
|
@@ -209,8 +686,8 @@ export interface AgentEvent {
|
|
|
209
686
|
* Group live text by `(turnId, stepExecutionId, attempt)`. Within one `stepExecutionId`, keep only the
|
|
210
687
|
* events of the highest `attempt` seen and drop the partial text of lower attempts. Different
|
|
211
688
|
* `stepExecutionId` values of one turn are its model calls and tool Steps, and each keeps its
|
|
212
|
-
* own events. After `turn_completed` or `
|
|
213
|
-
* messages.
|
|
689
|
+
* own events. After `turn_completed`, `turn_failed`, `turn_steered`, or `turn_cancelled`, replace the
|
|
690
|
+
* turn's live text with the stored messages.
|
|
214
691
|
*/
|
|
215
692
|
readonly stepExecutionId: string;
|
|
216
693
|
/** Event payload as JSON text. Wire field: `payload`. */
|
|
@@ -225,6 +702,134 @@ export interface ResolveInterruptInput {
|
|
|
225
702
|
/** Text shown to the model when rejected, or `null`. Wire field: `rejection_message`. */
|
|
226
703
|
readonly rejectionMessage: string | null;
|
|
227
704
|
}
|
|
705
|
+
/**
|
|
706
|
+
* Input of the `answer_question` RPC.
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```ts
|
|
710
|
+
* const question = snapshot.pendingInterrupts.find((interrupt) => interrupt.kind === "question");
|
|
711
|
+
* if (question !== undefined) {
|
|
712
|
+
* await client.invokeRPC(flow.answerQuestion, sessionId, {
|
|
713
|
+
* interruptId: question.interruptId, answer: question.choices[0] ?? "yes" });
|
|
714
|
+
* }
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
export interface AnswerQuestionRequest {
|
|
718
|
+
/** {@link AgentInterrupt.interruptId} of a pending `question` interrupt. Wire field: `interrupt_id`. */
|
|
719
|
+
readonly interruptId: string;
|
|
720
|
+
/**
|
|
721
|
+
* The answer. It must not be blank. When the interrupt has `choices` and `allowsFreeText` is `false`,
|
|
722
|
+
* it must equal one of the choices exactly. Wire field: `answer`.
|
|
723
|
+
*/
|
|
724
|
+
readonly answer: string;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* The summary that replaces a session's earlier messages in the model input, stored in the
|
|
728
|
+
* `ContextSummary` Attribute.
|
|
729
|
+
*
|
|
730
|
+
* Only `CompactContext` writes it, in a session with {@link AgentSessionOptions.compaction}. Each new
|
|
731
|
+
* summary folds in the previous one, so it always covers the messages from {@link firstSequence}
|
|
732
|
+
* through {@link lastSequence}. The summarized messages stay stored, and `list_agent_messages` and
|
|
733
|
+
* `get_agent_snapshot` return them, until retention deletes whole archive chunks of them; see
|
|
734
|
+
* `AgentSessionOptions.retainedMessageLimit`. Only the model input changes.
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* ```ts
|
|
738
|
+
* const snapshot = await client.invokeRPC(flow.getAgentSnapshot, sessionId);
|
|
739
|
+
* const summarizedThrough = snapshot.contextSummary?.lastSequence ?? 0;
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
export interface ContextSummary {
|
|
743
|
+
/** Count of summaries the session has written, starting at 1. Wire field: `generation`. */
|
|
744
|
+
readonly generation: number;
|
|
745
|
+
/** Sequence of the first summarized message; always 1. Wire field: `first_sequence`. */
|
|
746
|
+
readonly firstSequence: number;
|
|
747
|
+
/**
|
|
748
|
+
* Sequence of the last summarized message. A runner with the compaction capability receives only the
|
|
749
|
+
* messages after it. Wire field: `last_sequence`.
|
|
750
|
+
*/
|
|
751
|
+
readonly lastSequence: number;
|
|
752
|
+
/** Summary text from the runner's `summarizeContext`. Wire field: `text`. */
|
|
753
|
+
readonly text: string;
|
|
754
|
+
/** RFC 3339 time at which `CompactContext` wrote the summary. Wire field: `created_at`. */
|
|
755
|
+
readonly createdAt: string;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* One immutable archive chunk of the `AgentMessageChunks` AttributeMap.
|
|
759
|
+
*
|
|
760
|
+
* When the `AgentMessages` window grows past `AgentSessionOptions.messageWindowSize`, its oldest messages
|
|
761
|
+
* move into chunks of at most `messageChunkSize` messages and `messageChunkMaxBytes` bytes, each keyed by
|
|
762
|
+
* `messageSequenceKey` of its first sequence. A chunk is never rewritten. Retention deletes a whole chunk.
|
|
763
|
+
*/
|
|
764
|
+
export interface AgentMessageChunk {
|
|
765
|
+
/**
|
|
766
|
+
* The chunk's messages with consecutive sequences, oldest first: the range its
|
|
767
|
+
* {@link AgentMessageChunkRange} names. Wire field: `messages`.
|
|
768
|
+
*/
|
|
769
|
+
readonly messages: readonly AgentMessage[];
|
|
770
|
+
}
|
|
771
|
+
/** The sequences one `AgentMessageChunks` instance holds, as {@link AgentMessageIndex.chunks} lists it. */
|
|
772
|
+
export interface AgentMessageChunkRange {
|
|
773
|
+
/** Sequence of the chunk's first message; the instance key is `messageSequenceKey` of it. Wire field: `first_sequence`. */
|
|
774
|
+
readonly firstSequence: number;
|
|
775
|
+
/** Sequence of the chunk's last message. Wire field: `last_sequence`. */
|
|
776
|
+
readonly lastSequence: number;
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Where a session's messages are stored, held in the `AgentMessageIndex` Attribute.
|
|
780
|
+
*
|
|
781
|
+
* Messages from {@link windowFirstSequence} on are in the `AgentMessages` window, one instance per message.
|
|
782
|
+
* Earlier ones, from {@link firstSequence}, are in the `AgentMessageChunks` instances that {@link chunks}
|
|
783
|
+
* lists. A chunk holds at most `messageChunkSize` messages and at most `messageChunkMaxBytes` bytes, except
|
|
784
|
+
* that a larger message gets a chunk of its own. A session that a 0.1.0 Worker wrote has no index: every
|
|
785
|
+
* message is in `AgentMessages` until the session's writes on this version move them, a few chunks per
|
|
786
|
+
* commit.
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* ```ts
|
|
790
|
+
* const [index] = await client.getAttributes(sessionId, flow.agentMessageIndex);
|
|
791
|
+
* const oldestStored = index?.firstSequence ?? 1;
|
|
792
|
+
* const chunk = index?.chunks.find((range) => range.firstSequence <= 7 && 7 <= range.lastSequence);
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
export interface AgentMessageIndex {
|
|
796
|
+
/**
|
|
797
|
+
* Every kept chunk, oldest first, without overlaps. The archived ones, before `windowFirstSequence`, are
|
|
798
|
+
* contiguous from `firstSequence`. A chunk at or after `windowFirstSequence` holds one message that was too
|
|
799
|
+
* large for the window, stored straight into its own chunk. Wire field: `chunks`.
|
|
800
|
+
*/
|
|
801
|
+
readonly chunks: readonly AgentMessageChunkRange[];
|
|
802
|
+
/**
|
|
803
|
+
* Sequence of the oldest stored message: the first archived chunk's first sequence, or `windowFirstSequence`
|
|
804
|
+
* when no archived chunk is kept. Retention deleted every earlier message. Wire field: `first_sequence`.
|
|
805
|
+
*/
|
|
806
|
+
readonly firstSequence: number;
|
|
807
|
+
/** Sequence of the first message in the `AgentMessages` window. Wire field: `window_first_sequence`. */
|
|
808
|
+
readonly windowFirstSequence: number;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Where the replies of a turn start: the value of the `TurnReplySequence` Attribute.
|
|
812
|
+
*
|
|
813
|
+
* The Step that starts a turn writes it, so the turn's `turn_completed`, `turn_steered`, and `turn_cancelled`
|
|
814
|
+
* events count the turn's messages after its user messages without reading them. A value for another turn,
|
|
815
|
+
* such as one a 0.1.0 Worker started, is ignored.
|
|
816
|
+
*/
|
|
817
|
+
export interface TurnReplySequence {
|
|
818
|
+
/** `"turn-<n>"` of the turn. Wire field: `turn_id`. */
|
|
819
|
+
readonly turnId: string;
|
|
820
|
+
/** First sequence after the user messages that started the turn. Wire field: `sequence`. */
|
|
821
|
+
readonly sequence: number;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Input of the `CompactContext` Step: the last message to summarize.
|
|
825
|
+
*
|
|
826
|
+
* `RunModel` moves to `CompactContext` with it when the next model input would cross the compaction
|
|
827
|
+
* threshold.
|
|
828
|
+
*/
|
|
829
|
+
export interface CompactContextInput {
|
|
830
|
+
/** Sequence of the last message to summarize, after the current summary's. Wire field: `through_sequence`. */
|
|
831
|
+
readonly throughSequence: number;
|
|
832
|
+
}
|
|
228
833
|
/** Output of the `get_agent_snapshot` RPC, enough for a UI to rebuild its view. */
|
|
229
834
|
export interface AgentSnapshot {
|
|
230
835
|
/** Current session state, or `null` before `StartAgentSession` committed. Wire field: `state`. */
|
|
@@ -234,11 +839,36 @@ export interface AgentSnapshot {
|
|
|
234
839
|
/** Interrupts that `resolve_interrupt` still accepts. Wire field: `pending_interrupts`. */
|
|
235
840
|
readonly pendingInterrupts: readonly AgentInterrupt[];
|
|
236
841
|
/** Deferred tool call records of the active turn, in deferral order. Wire field: `tool_calls`. */
|
|
237
|
-
readonly toolCalls: readonly
|
|
842
|
+
readonly toolCalls: readonly AgentToolCallRecord[];
|
|
238
843
|
/** Cumulative usage. Wire field: `usage`. */
|
|
239
844
|
readonly usage: AgentUsage;
|
|
240
845
|
/** User messages queued and not yet consumed. Wire field: `queued_message_count`. */
|
|
241
846
|
readonly queuedMessageCount: number;
|
|
847
|
+
/**
|
|
848
|
+
* The {@link AgentPlan}, or absent before `write_todos` first succeeded. Wire field: `plan`, `null` while
|
|
849
|
+
* there is none; a decoded snapshot omits it then, like the other fields plans added.
|
|
850
|
+
*/
|
|
851
|
+
readonly plan?: AgentPlan | null;
|
|
852
|
+
/**
|
|
853
|
+
* Those queued messages with their Channel message IDs, oldest first; pass an ID to `delete_queued_message` or
|
|
854
|
+
* `steer_user_message`. Wire field: `queued_messages`. Snapshots the session returns always carry it and the
|
|
855
|
+
* field below; they are optional so that 0.1.0 code that builds snapshots keeps compiling.
|
|
856
|
+
*/
|
|
857
|
+
readonly queuedMessages?: readonly PendingUserMessage[];
|
|
858
|
+
/** Steered messages the session has not applied yet, oldest first. Wire field: `steered_messages`. */
|
|
859
|
+
readonly steeredMessages?: readonly PendingUserMessage[];
|
|
860
|
+
/**
|
|
861
|
+
* The current {@link ContextSummary}, or `null` when the session never compacted; {@link messages}
|
|
862
|
+
* still holds the summarized messages. Wire field: `context_summary`. The RPC always sets it; it is
|
|
863
|
+
* optional so that 0.1.0 code that builds a snapshot keeps compiling.
|
|
864
|
+
*/
|
|
865
|
+
readonly contextSummary?: ContextSummary | null;
|
|
866
|
+
/**
|
|
867
|
+
* The `SessionSettings` Attribute: the settings the next turn starts with, or `null` when the session has
|
|
868
|
+
* none. The active turn may still run with the settings it started with. Wire field: `session_settings`. The
|
|
869
|
+
* RPC always sets it; it is optional so that 0.1.0 code that builds a snapshot keeps compiling.
|
|
870
|
+
*/
|
|
871
|
+
readonly sessionSettings?: SessionSettings | null;
|
|
242
872
|
}
|
|
243
873
|
/** Input of the `list_agent_messages` RPC. */
|
|
244
874
|
export interface ListAgentMessagesInput {
|
|
@@ -256,6 +886,12 @@ export interface AgentMessagesPage {
|
|
|
256
886
|
* Wire field: `next_before_sequence`.
|
|
257
887
|
*/
|
|
258
888
|
readonly nextBeforeSequence: number | null;
|
|
889
|
+
/**
|
|
890
|
+
* The oldest stored sequence when retention deleted every earlier message, or `null` when none was deleted.
|
|
891
|
+
* A page whose `nextBeforeSequence` is `null` reaches the start of the conversation only when this is
|
|
892
|
+
* `null` too. Absent in a page a 0.1.0 Worker returned. Wire field: `deleted_before_sequence`.
|
|
893
|
+
*/
|
|
894
|
+
readonly deletedBeforeSequence?: number | null;
|
|
259
895
|
}
|
|
260
896
|
/**
|
|
261
897
|
* Returns usage with every counter at zero.
|
|
@@ -281,9 +917,9 @@ export declare function addAgentUsage(left: AgentUsage, right: AgentUsage): Agen
|
|
|
281
917
|
*
|
|
282
918
|
* @param status - Status to classify.
|
|
283
919
|
* @returns `true` for `rejected`, `succeeded`, `failed`, and `outcome_unknown`; `false` for
|
|
284
|
-
* `awaiting_approval` and
|
|
920
|
+
* `awaiting_approval`, `approved`, and every {@link AgentToolCallWaitingStatus}.
|
|
285
921
|
*/
|
|
286
|
-
export declare function isFinalToolCallStatus(status:
|
|
922
|
+
export declare function isFinalToolCallStatus(status: AgentToolCallRecordStatus): boolean;
|
|
287
923
|
/** Tool result text the model sees for an `outcome_unknown` call; the same text as the Python core. */
|
|
288
924
|
export declare const outcomeUnknownToolResult: string;
|
|
289
925
|
/** First line of the note `RecordTurnFailure` stores after a failed turn ran tools. */
|
|
@@ -294,6 +930,34 @@ export declare const turnFailureNoteFooter = "Do not repeat these tool calls unl
|
|
|
294
930
|
export declare const defaultRejectionToolResult = "The user rejected this tool call.";
|
|
295
931
|
/** Rejection message recorded when an approval deadline passes. */
|
|
296
932
|
export declare const approvalDeadlinePassed = "approval deadline passed";
|
|
933
|
+
/** Rejection message recorded when a question's deadline passes. */
|
|
934
|
+
export declare const questionDeadlinePassed = "question deadline passed";
|
|
935
|
+
/** Tool result text the model sees when the user declines a question without a message, or with an empty one. */
|
|
936
|
+
export declare const defaultQuestionDeclinedToolResult = "The user declined to answer.";
|
|
937
|
+
/** First line of the note `ApplyTurnControl` stores after a steered turn ran tools. */
|
|
938
|
+
export declare const turnSteeredNoteHeader = "[Dex] The user steered the conversation after these tool calls ran:";
|
|
939
|
+
/** First line of the note `ApplyTurnControl` stores after a cancelled turn ran tools. */
|
|
940
|
+
export declare const turnCancelledNoteHeader = "[Dex] The user stopped the previous turn after these tool calls ran:";
|
|
941
|
+
/** Model-visible result of a tool call that steering abandoned before it started; the same text as the Python core. */
|
|
942
|
+
export declare const toolCallCancelledBySteeringResult = "{\"status\":\"cancelled\",\"reason\":\"superseded_by_steered_user_message\"}";
|
|
943
|
+
/** Model-visible result of a tool call that `cancel_turn` abandoned before it started. */
|
|
944
|
+
export declare const toolCallCancelledByTurnCancellationResult = "{\"status\":\"cancelled\",\"reason\":\"turn_cancelled_by_user\"}";
|
|
945
|
+
/**
|
|
946
|
+
* Error recorded when a tool returns {@link ToolTaskStarted} to a runner without
|
|
947
|
+
* {@link AgentFrameworkRunner.pollToolTask}. The Python core names its method `poll_tool_task`.
|
|
948
|
+
*/
|
|
949
|
+
export declare const missingToolTaskPoller = "the tool started a task, but the runner does not implement pollToolTask";
|
|
950
|
+
/** Error recorded when a {@link ToolTaskStarted} has a blank `taskId`; the same text as the Python core. */
|
|
951
|
+
export declare const blankToolTaskId = "the tool started a task without a task ID";
|
|
952
|
+
/** Error recorded when a task's poll interval is not a number; the same text as the Python core. */
|
|
953
|
+
export declare const invalidToolTaskPollInterval = "the tool task's poll interval is not a number";
|
|
954
|
+
/** Error of an `outcome_unknown` record whose task `cancel_turn` abandoned; the same text as the Python core. */
|
|
955
|
+
export declare const toolTaskAbandonedError = "the turn was cancelled while the tool's task was running; the task may have taken effect";
|
|
956
|
+
/**
|
|
957
|
+
* Start of the `error` of a `failed` record whose tool Step certainly never ran the tool; the same text as the
|
|
958
|
+
* Python core.
|
|
959
|
+
*/
|
|
960
|
+
export declare const toolCallNotRunErrorPrefix = "the tool did not run, so it is safe to call again";
|
|
297
961
|
/**
|
|
298
962
|
* Returns the note text that tells the model what a failed turn already did.
|
|
299
963
|
*
|
|
@@ -313,7 +977,9 @@ export declare const approvalDeadlinePassed = "approval deadline passed";
|
|
|
313
977
|
* joined with newlines.
|
|
314
978
|
* @throws {TypeError} When a record is not final.
|
|
315
979
|
*/
|
|
316
|
-
export declare function buildTurnFailureNote(toolCalls: readonly AgentToolCall[]): string;
|
|
980
|
+
export declare function buildTurnFailureNote(toolCalls: readonly (AgentToolCall | AgentToolCallRecord)[]): string;
|
|
981
|
+
/** Returns a note in the turn-failure note's line format with another first line. */
|
|
982
|
+
export declare function buildToolCallNote(header: string, toolCalls: readonly (AgentToolCall | AgentToolCallRecord)[]): string;
|
|
317
983
|
/**
|
|
318
984
|
* Returns the tool result text a runner shows the model for a final tool call record.
|
|
319
985
|
*
|
|
@@ -332,6 +998,6 @@ export declare function buildTurnFailureNote(toolCalls: readonly AgentToolCall[]
|
|
|
332
998
|
* @returns The output for `succeeded`; `The tool call failed: <error>` for `failed`; the rejection
|
|
333
999
|
* message, or {@link defaultRejectionToolResult}, for `rejected`; {@link outcomeUnknownToolResult}
|
|
334
1000
|
* for `outcome_unknown`.
|
|
335
|
-
* @throws {TypeError} When the record status is
|
|
1001
|
+
* @throws {TypeError} When the record status is not final.
|
|
336
1002
|
*/
|
|
337
|
-
export declare function describeToolCallOutcome(toolCall: AgentToolCall): string;
|
|
1003
|
+
export declare function describeToolCallOutcome(toolCall: AgentToolCall | AgentToolCallRecord): string;
|