@coder/ai-sdk-agent 0.9.0 → 0.9.2
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 +67 -34
- package/dist/index.d.ts +104 -15
- package/dist/index.js +222 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -223,9 +223,11 @@ conversation with server‑side history). `agent.chatId` is the current chat id.
|
|
|
223
223
|
- `agent.interrupt({ signal? })` — interrupt an in‑flight generation.
|
|
224
224
|
- `agent.archive({ signal? })` — archive the underlying chat (cleanup; see [Cleanup](#cleanup)).
|
|
225
225
|
- `agent.listModels()` — list the deployment's model configs, so you don't have to guess the `model` hint.
|
|
226
|
-
- Resume a prior chat: `new CoderAgent({ …, chatId: "…" })` —
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
- Resume a prior chat: `new CoderAgent({ …, chatId: "…" })` — optionally with
|
|
227
|
+
`lastSeenMessageId` (the persisted resume cursor, read from
|
|
228
|
+
`agent.lastSeenMessageId`) to skip the resumed turn's pre‑prompt history
|
|
229
|
+
probe. See [Durable workflows](#durable-workflows-persist-resume-recover)
|
|
230
|
+
for the full resumption how‑to.
|
|
229
231
|
|
|
230
232
|
Interrupting is asynchronous on the server: `interrupt()` resolves as soon as the
|
|
231
233
|
interrupt is acknowledged, and the run keeps winding down for a few seconds
|
|
@@ -883,24 +885,25 @@ sequence pinpoints _where_ a turn died:
|
|
|
883
885
|
|
|
884
886
|
`CoderAgentSettings`:
|
|
885
887
|
|
|
886
|
-
| field | description
|
|
887
|
-
| --------------------------------- |
|
|
888
|
-
| `client` \| (`baseUrl` + `token`) | connection (one or the other; `baseUrl`/`token` default from `CODER_URL`/`CODER_SESSION_TOKEN`)
|
|
889
|
-
| `organizationId` | org UUID that owns the chat (required)
|
|
890
|
-
| `model` | model hint: UUID, `provider:model`, model id, or display‑name substring
|
|
891
|
-
| `instructions` | system prompt
|
|
892
|
-
| `tools` | AI SDK `ToolSet` (client‑executed)
|
|
893
|
-
| `workspaceId` | bind the chat to a Coder workspace (enables workspace‑scoped tools)
|
|
894
|
-
| `workspaceFiles` | adapter enabling `uploadToWorkspace()` (write files to the workspace FS)
|
|
895
|
-
| `mcpServerIds` | server‑side MCP servers to enable
|
|
896
|
-
| `planMode` | enable plan mode (`"plan"`)
|
|
897
|
-
| `stopWhen` | AI SDK stop condition(s); default `stepCountIs(64)`
|
|
898
|
-
| `maxRetries` | default `0` — SDK retries can duplicate server‑side turns; override with care
|
|
899
|
-
| `requestTimeoutMs` | per‑turn time budget (ms); interrupts the run and rejects (`kind: "timeout"`) instead of hanging
|
|
900
|
-
| `onTransportEvent` | observability hook for typed transport events (see [Observability](#observability))
|
|
901
|
-
| `settleDeadlineMs` | overall deadline for bounded cleanup (`archive()` 409 retries, disposal); default 15 000
|
|
902
|
-
| `settleRetryDelayMs` | pause between `archive()` retries while the chat settles; default 1000
|
|
903
|
-
| `chatId` | resume an existing chat
|
|
888
|
+
| field | description |
|
|
889
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
890
|
+
| `client` \| (`baseUrl` + `token`) | connection (one or the other; `baseUrl`/`token` default from `CODER_URL`/`CODER_SESSION_TOKEN`) |
|
|
891
|
+
| `organizationId` | org UUID that owns the chat (required) |
|
|
892
|
+
| `model` | model hint: UUID, `provider:model`, model id, or display‑name substring |
|
|
893
|
+
| `instructions` | system prompt |
|
|
894
|
+
| `tools` | AI SDK `ToolSet` (client‑executed) |
|
|
895
|
+
| `workspaceId` | bind the chat to a Coder workspace (enables workspace‑scoped tools) |
|
|
896
|
+
| `workspaceFiles` | adapter enabling `uploadToWorkspace()` (write files to the workspace FS) |
|
|
897
|
+
| `mcpServerIds` | server‑side MCP servers to enable |
|
|
898
|
+
| `planMode` | enable plan mode (`"plan"`) |
|
|
899
|
+
| `stopWhen` | AI SDK stop condition(s); default `stepCountIs(64)` |
|
|
900
|
+
| `maxRetries` | default `0` — SDK retries can duplicate server‑side turns; override with care |
|
|
901
|
+
| `requestTimeoutMs` | per‑turn time budget (ms); interrupts the run and rejects (`kind: "timeout"`) instead of hanging |
|
|
902
|
+
| `onTransportEvent` | observability hook for typed transport events (see [Observability](#observability)) |
|
|
903
|
+
| `settleDeadlineMs` | overall deadline for bounded cleanup (`archive()` 409 retries, disposal); default 15 000 |
|
|
904
|
+
| `settleRetryDelayMs` | pause between `archive()` retries while the chat settles; default 1000 |
|
|
905
|
+
| `chatId` | resume an existing chat |
|
|
906
|
+
| `lastSeenMessageId` | resume cursor for `chatId` (persist `agent.lastSeenMessageId`) — skips the resumed turn's pre‑prompt history probe |
|
|
904
907
|
|
|
905
908
|
The `model` hint resolves against the deployment's model configs in order: a
|
|
906
909
|
config UUID is used as‑is, then an exact `provider:model` match, an exact model
|
|
@@ -943,7 +946,9 @@ Two facts make the pattern work:
|
|
|
943
946
|
|
|
944
947
|
- **All chat state lives on the Coder server.** Messages, tool activity, the
|
|
945
948
|
run itself — none of it is in your process. The only durable thing a
|
|
946
|
-
workflow has to carry between steps is **`agent.chatId`: a string
|
|
949
|
+
workflow has to carry between steps is **`agent.chatId`: a string** — plus,
|
|
950
|
+
optionally, **`agent.lastSeenMessageId`: the resume cursor**, which saves the
|
|
951
|
+
resumed turn one serial round‑trip (below).
|
|
947
952
|
- **`CoderAgent` can't ride a `fetch`‑shim durability layer** (it talks REST +
|
|
948
953
|
WebSocket through its own client), so each turn runs **inside** a durable
|
|
949
954
|
step — and the checkpointed chat id is the thread between steps.
|
|
@@ -956,18 +961,29 @@ on another machine, hours apart, retried after failures.
|
|
|
956
961
|
```ts
|
|
957
962
|
import { CoderAgent, type CoderTransportEvent } from "@coder/ai-sdk-agent";
|
|
958
963
|
|
|
964
|
+
interface WorkflowCheckpoint {
|
|
965
|
+
chatId: string;
|
|
966
|
+
/** The resume cursor — pairs with chatId, never persisted without it. */
|
|
967
|
+
lastSeenMessageId?: number;
|
|
968
|
+
}
|
|
969
|
+
|
|
959
970
|
// Any durable KV your engine gives you: step state, a job row, a DB table.
|
|
960
971
|
declare const checkpoints: {
|
|
961
|
-
get(workflowId: string): Promise<
|
|
962
|
-
set(workflowId: string,
|
|
972
|
+
get(workflowId: string): Promise<WorkflowCheckpoint | undefined>;
|
|
973
|
+
set(workflowId: string, checkpoint: WorkflowCheckpoint): Promise<void>;
|
|
963
974
|
};
|
|
964
975
|
|
|
965
976
|
export async function runTurn(workflowId: string, prompt: string): Promise<string> {
|
|
977
|
+
const checkpoint = await checkpoints.get(workflowId); // undefined on the first step → the turn creates the chat
|
|
966
978
|
const agent = new CoderAgent({
|
|
967
979
|
baseUrl: process.env.CODER_URL!,
|
|
968
980
|
token: process.env.CODER_SESSION_TOKEN!, // read per step — never checkpoint or log it
|
|
969
981
|
organizationId: process.env.CODER_ORG_ID!,
|
|
970
|
-
chatId:
|
|
982
|
+
chatId: checkpoint?.chatId,
|
|
983
|
+
// The previous step's cursor lets this step skip its pre-prompt history
|
|
984
|
+
// probe; absent (first resume, older checkpoints), the turn seeds it from
|
|
985
|
+
// the chat's newest message instead — one extra GET, same result.
|
|
986
|
+
lastSeenMessageId: checkpoint?.lastSeenMessageId,
|
|
971
987
|
requestTimeoutMs: 300_000, // always bound workflow steps — see below
|
|
972
988
|
onTransportEvent: observe, // per-step telemetry — see below
|
|
973
989
|
});
|
|
@@ -990,7 +1006,15 @@ export async function runTurn(workflowId: string, prompt: string): Promise<strin
|
|
|
990
1006
|
// CoderStreamError's chatId still names the stranded chat, and
|
|
991
1007
|
// agent.archive() retires it via agent.lastKnownChatId — see the
|
|
992
1008
|
// CoderStreamError notes below for what retrying means then.
|
|
993
|
-
if (agent.chatId)
|
|
1009
|
+
if (agent.chatId) {
|
|
1010
|
+
const next: WorkflowCheckpoint = { chatId: agent.chatId };
|
|
1011
|
+
// The cursor is optional sugar: persist it when a turn established one
|
|
1012
|
+
// (a turn that failed before streaming may not have), skip it otherwise.
|
|
1013
|
+
if (agent.lastSeenMessageId !== undefined) {
|
|
1014
|
+
next.lastSeenMessageId = agent.lastSeenMessageId;
|
|
1015
|
+
}
|
|
1016
|
+
await checkpoints.set(workflowId, next);
|
|
1017
|
+
}
|
|
994
1018
|
}
|
|
995
1019
|
}
|
|
996
1020
|
```
|
|
@@ -1023,12 +1047,16 @@ await archiveWorkflowChat("wf-1042");
|
|
|
1023
1047
|
|
|
1024
1048
|
What resuming does (and doesn't do):
|
|
1025
1049
|
|
|
1026
|
-
- **Construction is free.** `new CoderAgent({ …, chatId })` performs no I/O
|
|
1027
|
-
|
|
1028
|
-
|
|
1050
|
+
- **Construction is free.** `new CoderAgent({ …, chatId })` performs no I/O —
|
|
1051
|
+
a bad or archived id fails the _turn_, not the constructor. (The one
|
|
1052
|
+
exception is local validation of `lastSeenMessageId`: a cursor that isn't a
|
|
1053
|
+
positive integer, or arrives without its `chatId`, throws immediately.)
|
|
1029
1054
|
- **The first resumed turn seeds its cursor** from the chat's newest message
|
|
1030
1055
|
(one single‑message history probe), so it streams only its own events —
|
|
1031
|
-
it never re‑absorbs earlier turns' content or usage.
|
|
1056
|
+
it never re‑absorbs earlier turns' content or usage. Supplying the
|
|
1057
|
+
checkpointed `lastSeenMessageId` skips that probe: the previous step already
|
|
1058
|
+
knew the cursor, so the resumed prompt goes out without any pre‑prompt
|
|
1059
|
+
round‑trip.
|
|
1032
1060
|
- **Re‑supply process‑local configuration.** Client `tools` live in your
|
|
1033
1061
|
process, not on the server, so each step that expects tool calls must pass
|
|
1034
1062
|
them again. The workspace binding is the opposite: fixed at creation,
|
|
@@ -1036,7 +1064,10 @@ What resuming does (and doesn't do):
|
|
|
1036
1064
|
- **Sessions stay single‑flight across the whole system**, not just within one
|
|
1037
1065
|
process: run steps strictly sequentially per chat. A second job posting to
|
|
1038
1066
|
the same chat queues behind the live run and burns its own
|
|
1039
|
-
`requestTimeoutMs` waiting
|
|
1067
|
+
`requestTimeoutMs` waiting — it attributes nothing of the live run's output
|
|
1068
|
+
to itself (its window opens only when its own queued prompt materializes),
|
|
1069
|
+
and if it times out first, it withdraws its queued prompt rather than
|
|
1070
|
+
leaving it to run unattended.
|
|
1040
1071
|
|
|
1041
1072
|
### Let the SDK absorb drops — and handle what it re‑throws
|
|
1042
1073
|
|
|
@@ -1162,9 +1193,11 @@ checkpoint:
|
|
|
1162
1193
|
turns into resuming the dead chat.)
|
|
1163
1194
|
- **Crashed after the checkpoint** — the chat is resumable, but don't just
|
|
1164
1195
|
resubmit. The crashed attempt's run may still be live server‑side, and a
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1196
|
+
resubmission then queues behind it: nothing the old run commits is
|
|
1197
|
+
attributed to the resumed turn (its window opens only at its own queued
|
|
1198
|
+
prompt's materialization), but the step burns its `requestTimeoutMs`
|
|
1199
|
+
waiting for the old run to finish first — and a timeout withdraws the
|
|
1200
|
+
queued prompt again. A crash _inside one of your client tools_ is worse: the
|
|
1168
1201
|
chat is paused in `requires_action`, where new messages wait forever — and
|
|
1169
1202
|
if the tool's external effect committed before the crash, that pause is the
|
|
1170
1203
|
only pending record of it, so reconcile the tool ledger **before** any
|
package/dist/index.d.ts
CHANGED
|
@@ -352,7 +352,7 @@ interface TransportEventBase {
|
|
|
352
352
|
* extend this union; treat unrecognized values as "some other operation"
|
|
353
353
|
* rather than matching exhaustively.
|
|
354
354
|
*/
|
|
355
|
-
type CoderClientOperation = "listModelConfigs" | "resolveModelConfigId" | "createChat" | "getChat" | "createChatMessage" | "getMessages" | "submitToolResults" | "interruptChat" | "updateChat" | "archiveChat" | "uploadChatFile" | "getChatFile";
|
|
355
|
+
type CoderClientOperation = "listModelConfigs" | "resolveModelConfigId" | "createChat" | "getChat" | "createChatMessage" | "getMessages" | "submitToolResults" | "interruptChat" | "deleteQueuedMessage" | "updateChat" | "archiveChat" | "uploadChatFile" | "getChatFile";
|
|
356
356
|
interface HttpTransportEventBase extends TransportEventBase {
|
|
357
357
|
/**
|
|
358
358
|
* Correlates a request with its response/error. Monotonically increasing
|
|
@@ -725,6 +725,15 @@ declare class CoderChatClient {
|
|
|
725
725
|
wait?: boolean;
|
|
726
726
|
signal?: AbortSignal;
|
|
727
727
|
}): Promise<Chat>;
|
|
728
|
+
/**
|
|
729
|
+
* Withdraw a QUEUED (not yet materialized) message from the chat's
|
|
730
|
+
* submission queue (`DELETE /queue/{id}`). `queuedMessageId` is the
|
|
731
|
+
* queue-entry id from `CreateChatMessageResponse.queued_message` — a
|
|
732
|
+
* different id space from committed chat message ids. Rejects with a
|
|
733
|
+
* {@link CoderApiError}: 404 when the entry no longer exists (already
|
|
734
|
+
* promoted into history, or deleted), 409 when the chat has no queue.
|
|
735
|
+
*/
|
|
736
|
+
deleteQueuedMessage(chatId: string, queuedMessageId: number, signal?: AbortSignal): Promise<void>;
|
|
728
737
|
updateChat(chatId: string, req: UpdateChatRequest, signal?: AbortSignal): Promise<void>;
|
|
729
738
|
/** Convenience: archive a chat (soft-hide; safe for cleanup). */
|
|
730
739
|
archiveChat(chatId: string, signal?: AbortSignal): Promise<void>;
|
|
@@ -925,6 +934,16 @@ interface CoderAgentSettings<TOOLS extends ToolSet = {}> {
|
|
|
925
934
|
planMode?: "" | "plan";
|
|
926
935
|
/** Resume an existing chat (session) instead of creating a new one. */
|
|
927
936
|
chatId?: string;
|
|
937
|
+
/**
|
|
938
|
+
* Resume cursor for `chatId`: the newest chat message id a previous
|
|
939
|
+
* instance had already seen. Persist {@link CoderAgent.lastSeenMessageId}
|
|
940
|
+
* alongside the chat id when a turn ends and supply both here — the resumed
|
|
941
|
+
* turn then skips its pre-prompt seed GET (the single-message history probe
|
|
942
|
+
* that would otherwise establish the cursor). Without it, behavior is
|
|
943
|
+
* unchanged. Must be a positive integer obtained from the getter, and
|
|
944
|
+
* requires `chatId`; anything else fails construction.
|
|
945
|
+
*/
|
|
946
|
+
lastSeenMessageId?: number;
|
|
928
947
|
/** Stable agent id (exposed as {@link CoderAgent.id}). */
|
|
929
948
|
id?: string;
|
|
930
949
|
/** System instructions → chatd `system_prompt`. */
|
|
@@ -1030,6 +1049,14 @@ declare class CoderAgent<TOOLS extends ToolSet = {}> implements Agent<never, TOO
|
|
|
1030
1049
|
get client(): CoderChatClient;
|
|
1031
1050
|
/** The current chatd chat id, once a turn has started. */
|
|
1032
1051
|
get chatId(): string | undefined;
|
|
1052
|
+
/**
|
|
1053
|
+
* The session's resume cursor: the newest chat message id observed, or
|
|
1054
|
+
* `undefined` before any turn has streamed. Persist it alongside
|
|
1055
|
+
* {@link chatId} when a turn ends and supply both to a future instance
|
|
1056
|
+
* ({@link CoderAgentSettings.lastSeenMessageId}) to skip the resumed turn's
|
|
1057
|
+
* pre-prompt seed GET. Read it between turns, not mid-generation.
|
|
1058
|
+
*/
|
|
1059
|
+
get lastSeenMessageId(): number | undefined;
|
|
1033
1060
|
/**
|
|
1034
1061
|
* The last chat id this agent created or attached to, retained for CLEANUP
|
|
1035
1062
|
* even after the session was dropped — a fresh-chat stream failure discards
|
|
@@ -1187,6 +1214,17 @@ interface CoderLanguageModelConfig {
|
|
|
1187
1214
|
planMode?: "" | "plan";
|
|
1188
1215
|
/** Resume an existing chat instead of creating a new one. */
|
|
1189
1216
|
chatId?: string;
|
|
1217
|
+
/**
|
|
1218
|
+
* Resume cursor for `chatId`: the newest chat message id a previous
|
|
1219
|
+
* instance had already seen — persist {@link CoderLanguageModel.lastSeenMessageId}
|
|
1220
|
+
* alongside the chat id and supply both here. Skips the resumed turn's
|
|
1221
|
+
* pre-prompt seed GET (the single-message history probe that would
|
|
1222
|
+
* otherwise establish the cursor); without it, behavior is unchanged and
|
|
1223
|
+
* the seed GET remains the fallback. Must be a positive integer obtained
|
|
1224
|
+
* from the getter, and requires `chatId` (the constructor rejects anything
|
|
1225
|
+
* else — a wrong cursor would silently misattribute replayed history).
|
|
1226
|
+
*/
|
|
1227
|
+
lastSeenMessageId?: number;
|
|
1190
1228
|
/**
|
|
1191
1229
|
* Per-segment time budget in milliseconds, applied to each model round-trip
|
|
1192
1230
|
* (one `doStream`/`doGenerate` call: chat creation or message/tool-result
|
|
@@ -1241,6 +1279,16 @@ declare class CoderLanguageModel implements LanguageModelV4 {
|
|
|
1241
1279
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
1242
1280
|
constructor(config: CoderLanguageModelConfig);
|
|
1243
1281
|
get chatId(): string | undefined;
|
|
1282
|
+
/**
|
|
1283
|
+
* The resume cursor: the newest chat message id this session has observed,
|
|
1284
|
+
* or `undefined` before any turn has streamed (nothing to persist then —
|
|
1285
|
+
* a fresh instance seeds from history instead). Persist it alongside
|
|
1286
|
+
* {@link chatId} once a turn settles and supply both to a future instance
|
|
1287
|
+
* ({@link CoderLanguageModelConfig.lastSeenMessageId}) to skip the resumed
|
|
1288
|
+
* turn's pre-prompt seed GET. Read it between turns, not mid-generation:
|
|
1289
|
+
* the cursor advances when a segment ends.
|
|
1290
|
+
*/
|
|
1291
|
+
get lastSeenMessageId(): number | undefined;
|
|
1244
1292
|
/**
|
|
1245
1293
|
* The last chat id this model created or attached to, for CLEANUP targeting
|
|
1246
1294
|
* only — generation always targets {@link chatId}. It survives
|
|
@@ -1303,6 +1351,34 @@ declare class CoderLanguageModel implements LanguageModelV4 {
|
|
|
1303
1351
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
1304
1352
|
}
|
|
1305
1353
|
|
|
1354
|
+
/** Constructor options for {@link TurnTranslator}. */
|
|
1355
|
+
interface TurnTranslatorOptions {
|
|
1356
|
+
dynamicToolNames: ReadonlySet<string>;
|
|
1357
|
+
turnCursor?: number;
|
|
1358
|
+
/**
|
|
1359
|
+
* Tool-call ids whose results the session already submitted. With the
|
|
1360
|
+
* stream retained across segments (and redialed with the turn's original
|
|
1361
|
+
* cursor), a reconnect can replay a previous segment's `action_required`
|
|
1362
|
+
* snapshot; re-emitting an already-answered call would make the AI SDK
|
|
1363
|
+
* execute the tool a second time. A live reference — the set grows as
|
|
1364
|
+
* later segments submit results.
|
|
1365
|
+
*/
|
|
1366
|
+
submittedToolCallIds?: ReadonlySet<string>;
|
|
1367
|
+
/**
|
|
1368
|
+
* Present when the submission was QUEUED (`CreateChatMessageResponse`
|
|
1369
|
+
* carried no committed `message`): `turnCursor` is then only the PRE-TURN
|
|
1370
|
+
* cursor, and attribution is withheld until the queue entry materializes as
|
|
1371
|
+
* this turn's own user message — see {@link QueuedSubmissionGate} for the
|
|
1372
|
+
* correlation protocol. `id`/`content` come from the response's
|
|
1373
|
+
* `queued_message`; either may be absent on unexpected wire shapes, which
|
|
1374
|
+
* degrades matching (no confirmation / match-any) but never widens
|
|
1375
|
+
* attribution beyond the first observed user message.
|
|
1376
|
+
*/
|
|
1377
|
+
queuedSubmission?: {
|
|
1378
|
+
id?: number;
|
|
1379
|
+
content?: readonly ChatMessagePart[];
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1306
1382
|
/**
|
|
1307
1383
|
* Translates one chatd turn's {@link ChatStreamEvent} stream into a sequence of
|
|
1308
1384
|
* `LanguageModelV4StreamPart`s for the AI SDK.
|
|
@@ -1323,27 +1399,40 @@ declare class CoderLanguageModel implements LanguageModelV4 {
|
|
|
1323
1399
|
* Client (custom) tool calls are emitted from the reliable `action_required`
|
|
1324
1400
|
* event and left for the AI SDK to execute. chatd's own server-side tools are
|
|
1325
1401
|
* surfaced best-effort as `providerExecuted` tool calls/results.
|
|
1402
|
+
*
|
|
1403
|
+
* A QUEUED submission additionally starts behind an attribution gate: until
|
|
1404
|
+
* the queue entry materializes as this turn's own user message, every event
|
|
1405
|
+
* belongs to the chat's concurrent run and is withheld (see
|
|
1406
|
+
* {@link QueuedSubmissionGate} and {@link TurnTranslatorOptions.queuedSubmission}).
|
|
1326
1407
|
*/
|
|
1327
1408
|
declare class TurnTranslator {
|
|
1328
1409
|
#private;
|
|
1329
|
-
constructor(opts:
|
|
1330
|
-
dynamicToolNames: ReadonlySet<string>;
|
|
1331
|
-
turnCursor?: number;
|
|
1332
|
-
/**
|
|
1333
|
-
* Tool-call ids whose results the session already submitted. With the
|
|
1334
|
-
* stream retained across segments (and redialed with the turn's original
|
|
1335
|
-
* cursor), a reconnect can replay a previous segment's `action_required`
|
|
1336
|
-
* snapshot; re-emitting an already-answered call would make the AI SDK
|
|
1337
|
-
* execute the tool a second time. A live reference — the set grows as
|
|
1338
|
-
* later segments submit results.
|
|
1339
|
-
*/
|
|
1340
|
-
submittedToolCallIds?: ReadonlySet<string>;
|
|
1341
|
-
});
|
|
1410
|
+
constructor(opts: TurnTranslatorOptions);
|
|
1342
1411
|
get terminalStatus(): ChatStatus | undefined;
|
|
1343
1412
|
/** Whether a client (custom) tool call has been emitted this turn. */
|
|
1344
1413
|
get clientToolCallSeen(): boolean;
|
|
1345
1414
|
get maxMessageId(): number;
|
|
1346
1415
|
get error(): ChatErrorPayload | undefined;
|
|
1416
|
+
/**
|
|
1417
|
+
* The turn's EFFECTIVE attribution cursor: the constructor's `turnCursor`
|
|
1418
|
+
* until a queued submission anchors, the materialized user message's id
|
|
1419
|
+
* after. Distinct from the stream's redial cursor, which deliberately stays
|
|
1420
|
+
* the turn's original `after_id` (see `streamChatEvents`).
|
|
1421
|
+
*/
|
|
1422
|
+
get turnCursor(): number;
|
|
1423
|
+
/**
|
|
1424
|
+
* Whether a queued submission is still awaiting its own user-message
|
|
1425
|
+
* snapshot (#114). While true, nothing is attributed to this turn — no
|
|
1426
|
+
* content, usage, tool calls, or settle statuses — because the stream
|
|
1427
|
+
* window still belongs to the chat's concurrent run.
|
|
1428
|
+
*/
|
|
1429
|
+
get awaitingQueuedSubmission(): boolean;
|
|
1430
|
+
/**
|
|
1431
|
+
* Set when a queued submission's wait can never complete (see
|
|
1432
|
+
* {@link QueuedSubmissionGate}); the model layer throws it so the turn
|
|
1433
|
+
* fails fast instead of hanging until timeout/abort.
|
|
1434
|
+
*/
|
|
1435
|
+
get queuedSubmissionDeadEnd(): ChatErrorPayload | undefined;
|
|
1347
1436
|
ingest(ev: ChatStreamEvent): LanguageModelV4StreamPart[];
|
|
1348
1437
|
finish(): LanguageModelV4StreamPart[];
|
|
1349
1438
|
}
|
|
@@ -1512,4 +1601,4 @@ declare class CoderChatError extends CoderAgentError {
|
|
|
1512
1601
|
constructor(payload: ChatErrorPayload);
|
|
1513
1602
|
}
|
|
1514
1603
|
|
|
1515
|
-
export { CHAT_ATTACHMENT_MEDIA_TYPES, CODER_PROVIDER_OPTIONS, type Chat, type ChatAttachment, type ChatAttachmentMediaType, type ChatBusyBehavior, type ChatClientType, type ChatErrorPayload, type ChatFileInput, type ChatInputPart, type ChatInputPartType, type ChatMessage, type ChatMessagePart, type ChatMessagePartType, type ChatMessageRole, type ChatMessageUsage, type ChatMessagesResponse, type ChatMessagesToUIMessagesOptions, type ChatModelConfig, type ChatPlanMode, type ChatQueuedMessage, type ChatStatus, type ChatStreamActionRequired, type ChatStreamEvent, type ChatStreamEventType, type ChatStreamMessagePart, type ChatStreamRetry, type ChatStreamStatus, type ChatStreamToolCall, type ChatWatchEvent, type ChatWatchEventKind, CoderAgent, CoderAgentError, type CoderAgentSettings, CoderApiError, type CoderArchiveResult, CoderChatClient, type CoderChatClientOptions, CoderChatError, type CoderClientOperation, type CoderFileProviderOptions, type CoderInterruptResult, CoderLanguageModel, type CoderLanguageModelConfig, CoderStreamError, type CoderTransportEvent, type CreateChatMessageRequest, type CreateChatMessageResponse, type CreateChatRequest, type DynamicTool, type FileContent, type FilePartUploader, type HttpErrorTransportEvent, type HttpRequestTransportEvent, type HttpResponseTransportEvent, MAX_CHAT_FILE_SIZE_BYTES, type PreviewShareLevel, type ResolvedFile, type SegmentSettleTransportEvent, type SegmentStartTransportEvent, type SharePreviewOptions, type SharedWorkspacePreview, type StreamCloseTransportEvent, type StreamDialTransportEvent, type StreamErrorTransportEvent, type StreamEventTransportEvent, type StreamOpenTransportEvent, type StreamRedialTransportEvent, type SubmitToolResultsRequest, TERMINAL_STATUSES, type ToolResult, type TransportEventHandler, type TurnAction, TurnTranslator, type UpdateChatRequest, type UploadChatFileResponse, type UploadedChatFile, type UserContent, type WatchChatEventsOptions, type WebSocketFactory, type WebSocketLike, type WorkspaceFileStore, type WorkspacePlacement, type WorkspacePreview, type WorkspacePreviewOptions, chatMessagesToUIMessages, classifyTurnAction, dataContentToFileContent, dynamicToolNames, extractSystemPrompt, resolveFileContent, streamChatEvents, toolsToDynamicTools, userContentToInputParts, watchChatEvents };
|
|
1604
|
+
export { CHAT_ATTACHMENT_MEDIA_TYPES, CODER_PROVIDER_OPTIONS, type Chat, type ChatAttachment, type ChatAttachmentMediaType, type ChatBusyBehavior, type ChatClientType, type ChatErrorPayload, type ChatFileInput, type ChatInputPart, type ChatInputPartType, type ChatMessage, type ChatMessagePart, type ChatMessagePartType, type ChatMessageRole, type ChatMessageUsage, type ChatMessagesResponse, type ChatMessagesToUIMessagesOptions, type ChatModelConfig, type ChatPlanMode, type ChatQueuedMessage, type ChatStatus, type ChatStreamActionRequired, type ChatStreamEvent, type ChatStreamEventType, type ChatStreamMessagePart, type ChatStreamRetry, type ChatStreamStatus, type ChatStreamToolCall, type ChatWatchEvent, type ChatWatchEventKind, CoderAgent, CoderAgentError, type CoderAgentSettings, CoderApiError, type CoderArchiveResult, CoderChatClient, type CoderChatClientOptions, CoderChatError, type CoderClientOperation, type CoderFileProviderOptions, type CoderInterruptResult, CoderLanguageModel, type CoderLanguageModelConfig, CoderStreamError, type CoderTransportEvent, type CreateChatMessageRequest, type CreateChatMessageResponse, type CreateChatRequest, type DynamicTool, type FileContent, type FilePartUploader, type HttpErrorTransportEvent, type HttpRequestTransportEvent, type HttpResponseTransportEvent, MAX_CHAT_FILE_SIZE_BYTES, type PreviewShareLevel, type ResolvedFile, type SegmentSettleTransportEvent, type SegmentStartTransportEvent, type SharePreviewOptions, type SharedWorkspacePreview, type StreamCloseTransportEvent, type StreamDialTransportEvent, type StreamErrorTransportEvent, type StreamEventTransportEvent, type StreamOpenTransportEvent, type StreamRedialTransportEvent, type SubmitToolResultsRequest, TERMINAL_STATUSES, type ToolResult, type TransportEventHandler, type TurnAction, TurnTranslator, type TurnTranslatorOptions, type UpdateChatRequest, type UploadChatFileResponse, type UploadedChatFile, type UserContent, type WatchChatEventsOptions, type WebSocketFactory, type WebSocketLike, type WorkspaceFileStore, type WorkspacePlacement, type WorkspacePreview, type WorkspacePreviewOptions, chatMessagesToUIMessages, classifyTurnAction, dataContentToFileContent, dynamicToolNames, extractSystemPrompt, resolveFileContent, streamChatEvents, toolsToDynamicTools, userContentToInputParts, watchChatEvents };
|