@astralform/js 9.1.0 → 9.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/dist/index.d.cts CHANGED
@@ -902,8 +902,10 @@ interface ThinkingDescriptor {
902
902
  }
903
903
  /**
904
904
  * The per-request model choice (client-side model selection). `provider` and
905
- * `model` are paired — send both or neither; when omitted, the server reuses the
906
- * conversation's last model or a connected-provider default.
905
+ * `model` are paired — send both or neither. Pass them on the first message of
906
+ * a new conversation: newer servers reject a new conversation that names no
907
+ * model, and every server accepts one that does. Omitted later, the server
908
+ * reuses the conversation's last model.
907
909
  */
908
910
  interface ModelChoiceOptions {
909
911
  provider?: string;
@@ -943,7 +945,9 @@ interface ChatStreamRequest {
943
945
  goal?: string;
944
946
  /**
945
947
  * Per-request model choice (client-side model selection), wire shape.
946
- * `provider` and `model` are paired; omit to reuse the thread's last model.
948
+ * `provider` and `model` are paired. Pass them on a new conversation (newer
949
+ * servers reject one without); omit them mid-thread to reuse the thread's
950
+ * last model.
947
951
  */
948
952
  provider?: string;
949
953
  model?: string;
@@ -1082,7 +1086,11 @@ interface VoiceConfig {
1082
1086
  defaultMode: VoicePolishMode;
1083
1087
  /** In tap-to-talk mode, the pause that ends a recording. */
1084
1088
  silenceAutoStopSeconds: number;
1085
- /** Send the message as soon as the result is ready. */
1089
+ /**
1090
+ * @deprecated Always `false`. Auto-send was removed from the platform
1091
+ * (2026-09-14); a dictation only fills the composer and the user sends it.
1092
+ * Kept so existing code compiles; slated for removal in the next major.
1093
+ */
1086
1094
  autoSend: boolean;
1087
1095
  maxRecordingSeconds: number;
1088
1096
  /**
@@ -1199,6 +1207,50 @@ interface ToolOutputStub {
1199
1207
  declare function isToolOutputStub(value: unknown): value is ToolOutputStub;
1200
1208
  /** How a restore asks for tool outputs. */
1201
1209
  type ToolOutputMode = "inline" | "stub";
1210
+ /**
1211
+ * A tool's image preview the server declined to inline, with a handle to fetch it.
1212
+ *
1213
+ * Restore can ask for these with `toolImages: "stub"`. It replaces an entry of a
1214
+ * `tool_use` final's `images` — and only that entry's `url`: `mime_type`,
1215
+ * `width`, `height` and `bytes` survive, so a consumer can reserve the image's
1216
+ * box before the bytes arrive and the transcript does not jump when they do.
1217
+ * Resolve it with `client.getToolImage`.
1218
+ *
1219
+ * Previews are exempt from `toolOutputs: "stub"`, which is why this is its own
1220
+ * opt-in: they are hoisted out of `output` precisely so a stubbed pill keeps its
1221
+ * thumbnail, and on a picture-heavy conversation they were three quarters of
1222
+ * the bytes a restore shipped before first render.
1223
+ */
1224
+ interface ToolImageStub {
1225
+ __stub: "tool_image";
1226
+ call_id: string;
1227
+ /** The entry's position in its call's `images` — what the fetch reads. */
1228
+ index: number;
1229
+ /**
1230
+ * The job this call belongs to. The same rule as `ToolOutputStub.job_id`:
1231
+ * a version-switched read returns superseded jobs the unscoped fetch cannot
1232
+ * see. `getToolImage` takes the whole stub so it cannot be dropped.
1233
+ */
1234
+ job_id?: string;
1235
+ mime_type?: string;
1236
+ /** Pixel size of the preview, for reserving its box. */
1237
+ width?: number;
1238
+ height?: number;
1239
+ /** Encoded size of the preview. */
1240
+ bytes?: number;
1241
+ }
1242
+ /**
1243
+ * Is this `images` entry a stub to fetch rather than a preview with a `url`?
1244
+ *
1245
+ * Checks every field the fetch is built from — `call_id` AND `index` — for the
1246
+ * reason `isToolOutputStub` gives: narrowing on the marker alone hands a caller
1247
+ * fields the type promises but the value lacks, and the next line puts them in
1248
+ * a URL. The display fields are hints and are not required, so a stub missing
1249
+ * its dimensions still resolves; it just cannot reserve its box.
1250
+ */
1251
+ declare function isToolImageStub(value: unknown): value is ToolImageStub;
1252
+ /** How a restore asks for tool image previews. */
1253
+ type ToolImageMode = "inline" | "stub";
1202
1254
  interface ConversationEvent {
1203
1255
  seq: number;
1204
1256
  event: string;
@@ -1356,6 +1408,69 @@ interface ConversationJob {
1356
1408
  status: string;
1357
1409
  message_id?: string | null;
1358
1410
  metrics?: Record<string, unknown>;
1411
+ /**
1412
+ * The per-turn state a consumer rehydrates a restored transcript from —
1413
+ * attachment chips, composer modes, goal linkage, the model the turn ran on.
1414
+ *
1415
+ * Every field below was ALREADY in this response and already fetched by the
1416
+ * restore's own paged read. They were simply not TYPED, and a field the SDK
1417
+ * does not surface is one a consumer cannot reach without re-requesting the
1418
+ * endpoint itself — which is exactly what happened: the chat issued a second,
1419
+ * UNBOUNDED `GET /jobs` on `restoreSettled`, a payload that grows with the
1420
+ * transcript, landing before first paint (measured 409-959 ms on the #1052
1421
+ * reference conversation). Widening the type is what lets that request be
1422
+ * deleted rather than merely bounded, which keeps ONE page size and ONE
1423
+ * cursor in the SDK instead of a second copy of both in every consumer.
1424
+ *
1425
+ * Optional throughout, because "the backend cannot say" is a real answer for
1426
+ * most of them: a job older than the field, or a server that does not project
1427
+ * it yet. `plan_mode`/`image_mode`/`video_mode` are three-valued for that
1428
+ * reason — absent/null is NOT false. `llm_provider`/`llm_model` come as a
1429
+ * pair or not at all.
1430
+ */
1431
+ created_at?: string | null;
1432
+ completed_at?: string | null;
1433
+ goal_id?: string | null;
1434
+ goal_objective?: string | null;
1435
+ plan_mode?: boolean | null;
1436
+ image_mode?: boolean | null;
1437
+ video_mode?: boolean | null;
1438
+ llm_provider?: string | null;
1439
+ llm_model?: string | null;
1440
+ /**
1441
+ * Files that rode along with this turn's user message, as display metadata.
1442
+ *
1443
+ * Present for every job that carried uploads WHATEVER its status — the files
1444
+ * are stored at attach time, before the turn starts, so a stopped or failed
1445
+ * turn still carried them and its bubble should still show them.
1446
+ */
1447
+ attachments?: ConversationJobAttachment[] | null;
1448
+ }
1449
+ /**
1450
+ * One file that rode along with a turn's user message.
1451
+ *
1452
+ * Named rather than inlined into `ConversationJob.attachments`: a consumer
1453
+ * rebuilding attachment chips writes a function over ONE of these, and an
1454
+ * inline literal is nameable only by indexing back out of the parent
1455
+ * (`NonNullable<ConversationJob["attachments"]>[number]`). Handing the rows
1456
+ * over is pointless if the row's element type cannot be spelled.
1457
+ *
1458
+ * `asset_id` and `filename` are required while the rest of `ConversationJob`
1459
+ * is optional, and that is not an oversight: the others are optional because
1460
+ * the BACKEND may not project them (a job older than the field, a server that
1461
+ * does not send it yet), whereas this whole object is built in one place and
1462
+ * both fields are unconditionally populated from the asset row whenever an
1463
+ * entry exists at all.
1464
+ */
1465
+ interface ConversationJobAttachment {
1466
+ asset_id: string;
1467
+ filename: string;
1468
+ media_type?: string | null;
1469
+ size_bytes?: number | null;
1470
+ /** Signed and expiring — the restored thumbnail. */
1471
+ url?: string | null;
1472
+ /** Permanent address, for keeping or linking. */
1473
+ content_url?: string | null;
1359
1474
  }
1360
1475
  /** One page of turns, plus where the next older page starts. */
1361
1476
  interface JobsPage {
@@ -1450,6 +1565,8 @@ declare class AstralformClient {
1450
1565
  */
1451
1566
  private getWithHeaders;
1452
1567
  get<T>(path: string): Promise<T>;
1568
+ /** A GET whose body is binary. Read inside the race, for the reason above. */
1569
+ private getBlob;
1453
1570
  post<T>(path: string, body: unknown): Promise<T>;
1454
1571
  patch<T>(path: string, body: unknown): Promise<T>;
1455
1572
  private del;
@@ -1548,6 +1665,7 @@ declare class AstralformClient {
1548
1665
  listSkillCommands(surface?: SlashCommandSurface): Promise<SlashCommand[]>;
1549
1666
  getConversationEvents(conversationId: string, jobId?: string, options?: {
1550
1667
  toolOutputs?: ToolOutputMode;
1668
+ toolImages?: ToolImageMode;
1551
1669
  }): Promise<ConversationEvent[]>;
1552
1670
  /**
1553
1671
  * The full output behind a {@link ToolOutputStub}.
@@ -1569,6 +1687,20 @@ declare class AstralformClient {
1569
1687
  * Prefer the overload above, which takes the stub and cannot be got wrong.
1570
1688
  */
1571
1689
  getToolOutput(conversationId: string, callId: string, jobId?: string): Promise<unknown>;
1690
+ /**
1691
+ * The image behind a {@link ToolImageStub}, as a `Blob` of the preview's bytes.
1692
+ *
1693
+ * Takes the stub itself and nothing else — the `job_id` scoping that
1694
+ * `getToolOutput`'s id form warns about cannot be dropped from a value that
1695
+ * carries it. There is deliberately no by-ids form.
1696
+ *
1697
+ * A `Blob` rather than a URL because the route is authenticated: an `<img
1698
+ * src>` cannot send the bearer token, so a browser consumer turns this into
1699
+ * an object URL (`URL.createObjectURL`) and revokes it when the image
1700
+ * unmounts. The response is `private, immutable`, so a repeat fetch of the
1701
+ * same preview is served by the HTTP cache.
1702
+ */
1703
+ getToolImage(conversationId: string, stub: ToolImageStub): Promise<Blob>;
1572
1704
  submitToolResult(request: ToolResultRequest): Promise<void>;
1573
1705
  submitToolApproval(request: ToolApprovalRequest): Promise<void>;
1574
1706
  /**
@@ -2138,6 +2270,20 @@ declare function streamJobSSE(options: StreamJobSSEOptions): AsyncGenerator<Chat
2138
2270
 
2139
2271
  type StreamState = "idle" | "streaming" | "restoring" | "detached";
2140
2272
  interface SendOptions extends ModelChoiceOptions {
2273
+ /**
2274
+ * Client tools to enable for THIS turn, overriding `session.enabledClientTools`
2275
+ * for it alone. Omit to use that Set, which is the persistent default.
2276
+ *
2277
+ * Present here while `conversationId` — the session's other extra field — is
2278
+ * deliberately absent, and the difference is worth stating so neither gets
2279
+ * "tidied" to match the other. `send` overwrites `conversationId` on its
2280
+ * forward below, because the manager owns the pointer, so accepting one would
2281
+ * silently discard the caller's value. Nothing overwrites this: the spread
2282
+ * carries it and `ChatSession.send` reads it as the override. It was missing
2283
+ * only because it was never added — #55 fixed the same loss for `repository`
2284
+ * in the forward direction and recorded that this one had gone the other way.
2285
+ */
2286
+ enabledClientTools?: string[];
2141
2287
  agentName?: string;
2142
2288
  uploadIds?: string[];
2143
2289
  planMode?: boolean;
@@ -2196,6 +2342,20 @@ type StreamManagerEvent = {
2196
2342
  position: "prepend";
2197
2343
  /** Whether anything older still remains after this page. */
2198
2344
  hasMore: boolean;
2345
+ /**
2346
+ * This page's turns, as the job list describes them — the rows this
2347
+ * page was replayed FROM, handed over rather than re-fetched.
2348
+ *
2349
+ * A consumer rehydrating per-turn state (attachment chips, composer
2350
+ * modes, goal runs, the turn's model) needs these for a prepended page
2351
+ * exactly as it does for the first render, and has no cursor of its own
2352
+ * to ask for them with. Empty when the page replayed nothing.
2353
+ *
2354
+ * Read this only when `complete` is `true`, for the same reason the
2355
+ * buffered blocks are discarded otherwise: an incomplete page's cursor
2356
+ * did not advance and the same turns replay again next request.
2357
+ */
2358
+ jobs: ConversationJob[];
2199
2359
  /**
2200
2360
  * Did the whole page replay?
2201
2361
  *
@@ -2240,6 +2400,18 @@ type StreamManagerEvent = {
2240
2400
  */
2241
2401
  type: "restoreSettled";
2242
2402
  conversationId: string;
2403
+ /**
2404
+ * The newest page's turns, as the job list describes them.
2405
+ *
2406
+ * The restore ALREADY fetched these — `jobList` asks for
2407
+ * `RESTORE_TURN_PAGE_SIZE` of them, and gets that many from any server
2408
+ * that honours the cursor (an older one ignores `limit` and answers with
2409
+ * the whole list, the documented degrade). Handing them over is what lets
2410
+ * a consumer rehydrate without issuing its OWN unbounded `GET /jobs`,
2411
+ * which is unbounded against every server, not just an old one, and lands
2412
+ * before first paint.
2413
+ */
2414
+ jobs: ConversationJob[];
2243
2415
  };
2244
2416
  type EventHandler = (event: StreamManagerEvent) => void;
2245
2417
  declare class StreamManager {
@@ -2257,6 +2429,12 @@ declare class StreamManager {
2257
2429
  * Defaults to inline, so this is inert until a consumer opts in.
2258
2430
  */
2259
2431
  private toolOutputs;
2432
+ /**
2433
+ * Whether restore asks for tool image previews inline or as fetch handles.
2434
+ * Separate from `toolOutputs` because the server keeps them separate — see
2435
+ * `ToolImageStub` — and on the same one-setting-both-waves rule.
2436
+ */
2437
+ private toolImages;
2260
2438
  private _state;
2261
2439
  private _activeConversationId;
2262
2440
  private _backgroundJobs;
@@ -2296,6 +2474,21 @@ declare class StreamManager {
2296
2474
  * belongs, because that is what arrives in `final.output`.
2297
2475
  */
2298
2476
  setToolOutputMode(mode: ToolOutputMode): void;
2477
+ /**
2478
+ * Ask restore for stubbed image previews, fetched on demand.
2479
+ *
2480
+ * The same caution as `setToolOutputMode`, sharper: a consumer that cannot
2481
+ * resolve one (`isToolImageStub`, `client.getToolImage`) finds an `images`
2482
+ * entry with no `url` and draws a broken image where the preview was.
2483
+ */
2484
+ setToolImageMode(mode: ToolImageMode): void;
2485
+ /**
2486
+ * The ONE options object both event waves fetch with — the newest page and
2487
+ * every `loadEarlierTurns` page. Built in one place so an opt-in added here
2488
+ * reaches both by construction: two literals at two call sites is how one
2489
+ * wave would silently keep asking for inline payloads.
2490
+ */
2491
+ private get eventFetchOptions();
2299
2492
  private emit;
2300
2493
  private setState;
2301
2494
  private attach;
@@ -2573,4 +2766,4 @@ declare function isEmbeddedResource(value: unknown): value is {
2573
2766
  */
2574
2767
  declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
2575
2768
 
2576
- export { type ActiveJob, type AgentCapability, type AgentIdentity, type AgentInfo, type AgentStatus, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type AvailableRepositories, type AvailableRepository, type BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, type CodeProject, ConnectionError, type ContextUpdatePayload, type ContextWarningPayload, type Conversation, type ConversationAsset, type ConversationEvent, type DesktopStreamPayload, type EffortRung, type EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, LLMNotConfiguredError, type MemoryProviderErrorPayload, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NestedLlmUsagePayload, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SendOptions$1 as SessionSendOptions, type SkillInfo, type SlashCommand, type SlashCommandSurface, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentStartPayload, type SubagentStopPayload, type TaskStatus, type TeamAgentSummary, type TeamSummary, type ThinkingDescriptor, type ThinkingRungOption, type TitleGeneratedPayload, type TodoItem, type TodoUpdatePayload, type ToolApprovalDecision, type ToolApprovalGrantedPayload, type ToolApprovalRequest, type ToolApprovalRequestedPayload, type ToolApprovalScope, type ToolCallRequest, type ToolDefinition, type ToolGrant, type ToolHandler, type ToolHarnessWarningPayload, type ToolOutputMode, type ToolOutputStub, type ToolProgressPayload, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolSource, type TurnUsage, type UIComponentsConfig, type UserUnavailablePayload, VOICE_POLISH_MODES, type VoiceConfig, type VoiceLLMMode, type VoicePolishEvent, type VoicePolishMode, type VoicePolishRequest, type VoiceTranscribeOptions, type VoiceTranscript, type WireBlockDelta, type WireBlockDeltaPayload, type WireBlockKind, type WireBlockStart, type WireBlockStatus, type WireBlockStop, type WireCustomEvent, type WireErrorEvent, type WireEvent, type WireInputArgDelta, type WireInputDelta, type WireKeepalive, type WireMessageStart, type WireMessageStop, type WireOutputDelta, type WireRetryEvent, type WireSignatureDelta, type WireStallWarning, type WireStatusDelta, type WireStopReason, type WireTextDelta, type WireThinkingDelta, type WorkspaceReadyPayload, generateId, isEmbeddedResource, isToolOutputStub, isVoiceLLMMode, isVoicePolishMode, mapSseToChat, parseEmbeddedResource, parseVoicePolishFrame, replayEvents, streamJobSSE, translateDelta };
2769
+ export { type ActiveJob, type AgentCapability, type AgentIdentity, type AgentInfo, type AgentStatus, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type AvailableRepositories, type AvailableRepository, type BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, type CodeProject, ConnectionError, type ContextUpdatePayload, type ContextWarningPayload, type Conversation, type ConversationAsset, type ConversationEvent, type ConversationJob, type ConversationJobAttachment, type DesktopStreamPayload, type EffortRung, type EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, type JobsPage, LLMNotConfiguredError, type MemoryProviderErrorPayload, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type MessagesPage, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NestedLlmUsagePayload, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SendOptions$1 as SessionSendOptions, type SkillInfo, type SlashCommand, type SlashCommandSurface, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentStartPayload, type SubagentStopPayload, type TaskStatus, type TeamAgentSummary, type TeamSummary, type ThinkingDescriptor, type ThinkingRungOption, type TitleGeneratedPayload, type TodoItem, type TodoUpdatePayload, type ToolApprovalDecision, type ToolApprovalGrantedPayload, type ToolApprovalRequest, type ToolApprovalRequestedPayload, type ToolApprovalScope, type ToolCallRequest, type ToolDefinition, type ToolGrant, type ToolHandler, type ToolHarnessWarningPayload, type ToolImageMode, type ToolImageStub, type ToolOutputMode, type ToolOutputStub, type ToolProgressPayload, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolSource, type TurnUsage, type UIComponentsConfig, type UserUnavailablePayload, VOICE_POLISH_MODES, type VoiceConfig, type VoiceLLMMode, type VoicePolishEvent, type VoicePolishMode, type VoicePolishRequest, type VoiceTranscribeOptions, type VoiceTranscript, type WireBlockDelta, type WireBlockDeltaPayload, type WireBlockKind, type WireBlockStart, type WireBlockStatus, type WireBlockStop, type WireCustomEvent, type WireErrorEvent, type WireEvent, type WireInputArgDelta, type WireInputDelta, type WireKeepalive, type WireMessageStart, type WireMessageStop, type WireOutputDelta, type WireRetryEvent, type WireSignatureDelta, type WireStallWarning, type WireStatusDelta, type WireStopReason, type WireTextDelta, type WireThinkingDelta, type WorkspaceReadyPayload, generateId, isEmbeddedResource, isToolImageStub, isToolOutputStub, isVoiceLLMMode, isVoicePolishMode, mapSseToChat, parseEmbeddedResource, parseVoicePolishFrame, replayEvents, streamJobSSE, translateDelta };
package/dist/index.d.ts CHANGED
@@ -902,8 +902,10 @@ interface ThinkingDescriptor {
902
902
  }
903
903
  /**
904
904
  * The per-request model choice (client-side model selection). `provider` and
905
- * `model` are paired — send both or neither; when omitted, the server reuses the
906
- * conversation's last model or a connected-provider default.
905
+ * `model` are paired — send both or neither. Pass them on the first message of
906
+ * a new conversation: newer servers reject a new conversation that names no
907
+ * model, and every server accepts one that does. Omitted later, the server
908
+ * reuses the conversation's last model.
907
909
  */
908
910
  interface ModelChoiceOptions {
909
911
  provider?: string;
@@ -943,7 +945,9 @@ interface ChatStreamRequest {
943
945
  goal?: string;
944
946
  /**
945
947
  * Per-request model choice (client-side model selection), wire shape.
946
- * `provider` and `model` are paired; omit to reuse the thread's last model.
948
+ * `provider` and `model` are paired. Pass them on a new conversation (newer
949
+ * servers reject one without); omit them mid-thread to reuse the thread's
950
+ * last model.
947
951
  */
948
952
  provider?: string;
949
953
  model?: string;
@@ -1082,7 +1086,11 @@ interface VoiceConfig {
1082
1086
  defaultMode: VoicePolishMode;
1083
1087
  /** In tap-to-talk mode, the pause that ends a recording. */
1084
1088
  silenceAutoStopSeconds: number;
1085
- /** Send the message as soon as the result is ready. */
1089
+ /**
1090
+ * @deprecated Always `false`. Auto-send was removed from the platform
1091
+ * (2026-09-14); a dictation only fills the composer and the user sends it.
1092
+ * Kept so existing code compiles; slated for removal in the next major.
1093
+ */
1086
1094
  autoSend: boolean;
1087
1095
  maxRecordingSeconds: number;
1088
1096
  /**
@@ -1199,6 +1207,50 @@ interface ToolOutputStub {
1199
1207
  declare function isToolOutputStub(value: unknown): value is ToolOutputStub;
1200
1208
  /** How a restore asks for tool outputs. */
1201
1209
  type ToolOutputMode = "inline" | "stub";
1210
+ /**
1211
+ * A tool's image preview the server declined to inline, with a handle to fetch it.
1212
+ *
1213
+ * Restore can ask for these with `toolImages: "stub"`. It replaces an entry of a
1214
+ * `tool_use` final's `images` — and only that entry's `url`: `mime_type`,
1215
+ * `width`, `height` and `bytes` survive, so a consumer can reserve the image's
1216
+ * box before the bytes arrive and the transcript does not jump when they do.
1217
+ * Resolve it with `client.getToolImage`.
1218
+ *
1219
+ * Previews are exempt from `toolOutputs: "stub"`, which is why this is its own
1220
+ * opt-in: they are hoisted out of `output` precisely so a stubbed pill keeps its
1221
+ * thumbnail, and on a picture-heavy conversation they were three quarters of
1222
+ * the bytes a restore shipped before first render.
1223
+ */
1224
+ interface ToolImageStub {
1225
+ __stub: "tool_image";
1226
+ call_id: string;
1227
+ /** The entry's position in its call's `images` — what the fetch reads. */
1228
+ index: number;
1229
+ /**
1230
+ * The job this call belongs to. The same rule as `ToolOutputStub.job_id`:
1231
+ * a version-switched read returns superseded jobs the unscoped fetch cannot
1232
+ * see. `getToolImage` takes the whole stub so it cannot be dropped.
1233
+ */
1234
+ job_id?: string;
1235
+ mime_type?: string;
1236
+ /** Pixel size of the preview, for reserving its box. */
1237
+ width?: number;
1238
+ height?: number;
1239
+ /** Encoded size of the preview. */
1240
+ bytes?: number;
1241
+ }
1242
+ /**
1243
+ * Is this `images` entry a stub to fetch rather than a preview with a `url`?
1244
+ *
1245
+ * Checks every field the fetch is built from — `call_id` AND `index` — for the
1246
+ * reason `isToolOutputStub` gives: narrowing on the marker alone hands a caller
1247
+ * fields the type promises but the value lacks, and the next line puts them in
1248
+ * a URL. The display fields are hints and are not required, so a stub missing
1249
+ * its dimensions still resolves; it just cannot reserve its box.
1250
+ */
1251
+ declare function isToolImageStub(value: unknown): value is ToolImageStub;
1252
+ /** How a restore asks for tool image previews. */
1253
+ type ToolImageMode = "inline" | "stub";
1202
1254
  interface ConversationEvent {
1203
1255
  seq: number;
1204
1256
  event: string;
@@ -1356,6 +1408,69 @@ interface ConversationJob {
1356
1408
  status: string;
1357
1409
  message_id?: string | null;
1358
1410
  metrics?: Record<string, unknown>;
1411
+ /**
1412
+ * The per-turn state a consumer rehydrates a restored transcript from —
1413
+ * attachment chips, composer modes, goal linkage, the model the turn ran on.
1414
+ *
1415
+ * Every field below was ALREADY in this response and already fetched by the
1416
+ * restore's own paged read. They were simply not TYPED, and a field the SDK
1417
+ * does not surface is one a consumer cannot reach without re-requesting the
1418
+ * endpoint itself — which is exactly what happened: the chat issued a second,
1419
+ * UNBOUNDED `GET /jobs` on `restoreSettled`, a payload that grows with the
1420
+ * transcript, landing before first paint (measured 409-959 ms on the #1052
1421
+ * reference conversation). Widening the type is what lets that request be
1422
+ * deleted rather than merely bounded, which keeps ONE page size and ONE
1423
+ * cursor in the SDK instead of a second copy of both in every consumer.
1424
+ *
1425
+ * Optional throughout, because "the backend cannot say" is a real answer for
1426
+ * most of them: a job older than the field, or a server that does not project
1427
+ * it yet. `plan_mode`/`image_mode`/`video_mode` are three-valued for that
1428
+ * reason — absent/null is NOT false. `llm_provider`/`llm_model` come as a
1429
+ * pair or not at all.
1430
+ */
1431
+ created_at?: string | null;
1432
+ completed_at?: string | null;
1433
+ goal_id?: string | null;
1434
+ goal_objective?: string | null;
1435
+ plan_mode?: boolean | null;
1436
+ image_mode?: boolean | null;
1437
+ video_mode?: boolean | null;
1438
+ llm_provider?: string | null;
1439
+ llm_model?: string | null;
1440
+ /**
1441
+ * Files that rode along with this turn's user message, as display metadata.
1442
+ *
1443
+ * Present for every job that carried uploads WHATEVER its status — the files
1444
+ * are stored at attach time, before the turn starts, so a stopped or failed
1445
+ * turn still carried them and its bubble should still show them.
1446
+ */
1447
+ attachments?: ConversationJobAttachment[] | null;
1448
+ }
1449
+ /**
1450
+ * One file that rode along with a turn's user message.
1451
+ *
1452
+ * Named rather than inlined into `ConversationJob.attachments`: a consumer
1453
+ * rebuilding attachment chips writes a function over ONE of these, and an
1454
+ * inline literal is nameable only by indexing back out of the parent
1455
+ * (`NonNullable<ConversationJob["attachments"]>[number]`). Handing the rows
1456
+ * over is pointless if the row's element type cannot be spelled.
1457
+ *
1458
+ * `asset_id` and `filename` are required while the rest of `ConversationJob`
1459
+ * is optional, and that is not an oversight: the others are optional because
1460
+ * the BACKEND may not project them (a job older than the field, a server that
1461
+ * does not send it yet), whereas this whole object is built in one place and
1462
+ * both fields are unconditionally populated from the asset row whenever an
1463
+ * entry exists at all.
1464
+ */
1465
+ interface ConversationJobAttachment {
1466
+ asset_id: string;
1467
+ filename: string;
1468
+ media_type?: string | null;
1469
+ size_bytes?: number | null;
1470
+ /** Signed and expiring — the restored thumbnail. */
1471
+ url?: string | null;
1472
+ /** Permanent address, for keeping or linking. */
1473
+ content_url?: string | null;
1359
1474
  }
1360
1475
  /** One page of turns, plus where the next older page starts. */
1361
1476
  interface JobsPage {
@@ -1450,6 +1565,8 @@ declare class AstralformClient {
1450
1565
  */
1451
1566
  private getWithHeaders;
1452
1567
  get<T>(path: string): Promise<T>;
1568
+ /** A GET whose body is binary. Read inside the race, for the reason above. */
1569
+ private getBlob;
1453
1570
  post<T>(path: string, body: unknown): Promise<T>;
1454
1571
  patch<T>(path: string, body: unknown): Promise<T>;
1455
1572
  private del;
@@ -1548,6 +1665,7 @@ declare class AstralformClient {
1548
1665
  listSkillCommands(surface?: SlashCommandSurface): Promise<SlashCommand[]>;
1549
1666
  getConversationEvents(conversationId: string, jobId?: string, options?: {
1550
1667
  toolOutputs?: ToolOutputMode;
1668
+ toolImages?: ToolImageMode;
1551
1669
  }): Promise<ConversationEvent[]>;
1552
1670
  /**
1553
1671
  * The full output behind a {@link ToolOutputStub}.
@@ -1569,6 +1687,20 @@ declare class AstralformClient {
1569
1687
  * Prefer the overload above, which takes the stub and cannot be got wrong.
1570
1688
  */
1571
1689
  getToolOutput(conversationId: string, callId: string, jobId?: string): Promise<unknown>;
1690
+ /**
1691
+ * The image behind a {@link ToolImageStub}, as a `Blob` of the preview's bytes.
1692
+ *
1693
+ * Takes the stub itself and nothing else — the `job_id` scoping that
1694
+ * `getToolOutput`'s id form warns about cannot be dropped from a value that
1695
+ * carries it. There is deliberately no by-ids form.
1696
+ *
1697
+ * A `Blob` rather than a URL because the route is authenticated: an `<img
1698
+ * src>` cannot send the bearer token, so a browser consumer turns this into
1699
+ * an object URL (`URL.createObjectURL`) and revokes it when the image
1700
+ * unmounts. The response is `private, immutable`, so a repeat fetch of the
1701
+ * same preview is served by the HTTP cache.
1702
+ */
1703
+ getToolImage(conversationId: string, stub: ToolImageStub): Promise<Blob>;
1572
1704
  submitToolResult(request: ToolResultRequest): Promise<void>;
1573
1705
  submitToolApproval(request: ToolApprovalRequest): Promise<void>;
1574
1706
  /**
@@ -2138,6 +2270,20 @@ declare function streamJobSSE(options: StreamJobSSEOptions): AsyncGenerator<Chat
2138
2270
 
2139
2271
  type StreamState = "idle" | "streaming" | "restoring" | "detached";
2140
2272
  interface SendOptions extends ModelChoiceOptions {
2273
+ /**
2274
+ * Client tools to enable for THIS turn, overriding `session.enabledClientTools`
2275
+ * for it alone. Omit to use that Set, which is the persistent default.
2276
+ *
2277
+ * Present here while `conversationId` — the session's other extra field — is
2278
+ * deliberately absent, and the difference is worth stating so neither gets
2279
+ * "tidied" to match the other. `send` overwrites `conversationId` on its
2280
+ * forward below, because the manager owns the pointer, so accepting one would
2281
+ * silently discard the caller's value. Nothing overwrites this: the spread
2282
+ * carries it and `ChatSession.send` reads it as the override. It was missing
2283
+ * only because it was never added — #55 fixed the same loss for `repository`
2284
+ * in the forward direction and recorded that this one had gone the other way.
2285
+ */
2286
+ enabledClientTools?: string[];
2141
2287
  agentName?: string;
2142
2288
  uploadIds?: string[];
2143
2289
  planMode?: boolean;
@@ -2196,6 +2342,20 @@ type StreamManagerEvent = {
2196
2342
  position: "prepend";
2197
2343
  /** Whether anything older still remains after this page. */
2198
2344
  hasMore: boolean;
2345
+ /**
2346
+ * This page's turns, as the job list describes them — the rows this
2347
+ * page was replayed FROM, handed over rather than re-fetched.
2348
+ *
2349
+ * A consumer rehydrating per-turn state (attachment chips, composer
2350
+ * modes, goal runs, the turn's model) needs these for a prepended page
2351
+ * exactly as it does for the first render, and has no cursor of its own
2352
+ * to ask for them with. Empty when the page replayed nothing.
2353
+ *
2354
+ * Read this only when `complete` is `true`, for the same reason the
2355
+ * buffered blocks are discarded otherwise: an incomplete page's cursor
2356
+ * did not advance and the same turns replay again next request.
2357
+ */
2358
+ jobs: ConversationJob[];
2199
2359
  /**
2200
2360
  * Did the whole page replay?
2201
2361
  *
@@ -2240,6 +2400,18 @@ type StreamManagerEvent = {
2240
2400
  */
2241
2401
  type: "restoreSettled";
2242
2402
  conversationId: string;
2403
+ /**
2404
+ * The newest page's turns, as the job list describes them.
2405
+ *
2406
+ * The restore ALREADY fetched these — `jobList` asks for
2407
+ * `RESTORE_TURN_PAGE_SIZE` of them, and gets that many from any server
2408
+ * that honours the cursor (an older one ignores `limit` and answers with
2409
+ * the whole list, the documented degrade). Handing them over is what lets
2410
+ * a consumer rehydrate without issuing its OWN unbounded `GET /jobs`,
2411
+ * which is unbounded against every server, not just an old one, and lands
2412
+ * before first paint.
2413
+ */
2414
+ jobs: ConversationJob[];
2243
2415
  };
2244
2416
  type EventHandler = (event: StreamManagerEvent) => void;
2245
2417
  declare class StreamManager {
@@ -2257,6 +2429,12 @@ declare class StreamManager {
2257
2429
  * Defaults to inline, so this is inert until a consumer opts in.
2258
2430
  */
2259
2431
  private toolOutputs;
2432
+ /**
2433
+ * Whether restore asks for tool image previews inline or as fetch handles.
2434
+ * Separate from `toolOutputs` because the server keeps them separate — see
2435
+ * `ToolImageStub` — and on the same one-setting-both-waves rule.
2436
+ */
2437
+ private toolImages;
2260
2438
  private _state;
2261
2439
  private _activeConversationId;
2262
2440
  private _backgroundJobs;
@@ -2296,6 +2474,21 @@ declare class StreamManager {
2296
2474
  * belongs, because that is what arrives in `final.output`.
2297
2475
  */
2298
2476
  setToolOutputMode(mode: ToolOutputMode): void;
2477
+ /**
2478
+ * Ask restore for stubbed image previews, fetched on demand.
2479
+ *
2480
+ * The same caution as `setToolOutputMode`, sharper: a consumer that cannot
2481
+ * resolve one (`isToolImageStub`, `client.getToolImage`) finds an `images`
2482
+ * entry with no `url` and draws a broken image where the preview was.
2483
+ */
2484
+ setToolImageMode(mode: ToolImageMode): void;
2485
+ /**
2486
+ * The ONE options object both event waves fetch with — the newest page and
2487
+ * every `loadEarlierTurns` page. Built in one place so an opt-in added here
2488
+ * reaches both by construction: two literals at two call sites is how one
2489
+ * wave would silently keep asking for inline payloads.
2490
+ */
2491
+ private get eventFetchOptions();
2299
2492
  private emit;
2300
2493
  private setState;
2301
2494
  private attach;
@@ -2573,4 +2766,4 @@ declare function isEmbeddedResource(value: unknown): value is {
2573
2766
  */
2574
2767
  declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
2575
2768
 
2576
- export { type ActiveJob, type AgentCapability, type AgentIdentity, type AgentInfo, type AgentStatus, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type AvailableRepositories, type AvailableRepository, type BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, type CodeProject, ConnectionError, type ContextUpdatePayload, type ContextWarningPayload, type Conversation, type ConversationAsset, type ConversationEvent, type DesktopStreamPayload, type EffortRung, type EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, LLMNotConfiguredError, type MemoryProviderErrorPayload, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NestedLlmUsagePayload, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SendOptions$1 as SessionSendOptions, type SkillInfo, type SlashCommand, type SlashCommandSurface, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentStartPayload, type SubagentStopPayload, type TaskStatus, type TeamAgentSummary, type TeamSummary, type ThinkingDescriptor, type ThinkingRungOption, type TitleGeneratedPayload, type TodoItem, type TodoUpdatePayload, type ToolApprovalDecision, type ToolApprovalGrantedPayload, type ToolApprovalRequest, type ToolApprovalRequestedPayload, type ToolApprovalScope, type ToolCallRequest, type ToolDefinition, type ToolGrant, type ToolHandler, type ToolHarnessWarningPayload, type ToolOutputMode, type ToolOutputStub, type ToolProgressPayload, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolSource, type TurnUsage, type UIComponentsConfig, type UserUnavailablePayload, VOICE_POLISH_MODES, type VoiceConfig, type VoiceLLMMode, type VoicePolishEvent, type VoicePolishMode, type VoicePolishRequest, type VoiceTranscribeOptions, type VoiceTranscript, type WireBlockDelta, type WireBlockDeltaPayload, type WireBlockKind, type WireBlockStart, type WireBlockStatus, type WireBlockStop, type WireCustomEvent, type WireErrorEvent, type WireEvent, type WireInputArgDelta, type WireInputDelta, type WireKeepalive, type WireMessageStart, type WireMessageStop, type WireOutputDelta, type WireRetryEvent, type WireSignatureDelta, type WireStallWarning, type WireStatusDelta, type WireStopReason, type WireTextDelta, type WireThinkingDelta, type WorkspaceReadyPayload, generateId, isEmbeddedResource, isToolOutputStub, isVoiceLLMMode, isVoicePolishMode, mapSseToChat, parseEmbeddedResource, parseVoicePolishFrame, replayEvents, streamJobSSE, translateDelta };
2769
+ export { type ActiveJob, type AgentCapability, type AgentIdentity, type AgentInfo, type AgentStatus, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type AvailableRepositories, type AvailableRepository, type BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, type CodeProject, ConnectionError, type ContextUpdatePayload, type ContextWarningPayload, type Conversation, type ConversationAsset, type ConversationEvent, type ConversationJob, type ConversationJobAttachment, type DesktopStreamPayload, type EffortRung, type EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, type JobsPage, LLMNotConfiguredError, type MemoryProviderErrorPayload, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type MessagesPage, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NestedLlmUsagePayload, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SendOptions$1 as SessionSendOptions, type SkillInfo, type SlashCommand, type SlashCommandSurface, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentStartPayload, type SubagentStopPayload, type TaskStatus, type TeamAgentSummary, type TeamSummary, type ThinkingDescriptor, type ThinkingRungOption, type TitleGeneratedPayload, type TodoItem, type TodoUpdatePayload, type ToolApprovalDecision, type ToolApprovalGrantedPayload, type ToolApprovalRequest, type ToolApprovalRequestedPayload, type ToolApprovalScope, type ToolCallRequest, type ToolDefinition, type ToolGrant, type ToolHandler, type ToolHarnessWarningPayload, type ToolImageMode, type ToolImageStub, type ToolOutputMode, type ToolOutputStub, type ToolProgressPayload, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolSource, type TurnUsage, type UIComponentsConfig, type UserUnavailablePayload, VOICE_POLISH_MODES, type VoiceConfig, type VoiceLLMMode, type VoicePolishEvent, type VoicePolishMode, type VoicePolishRequest, type VoiceTranscribeOptions, type VoiceTranscript, type WireBlockDelta, type WireBlockDeltaPayload, type WireBlockKind, type WireBlockStart, type WireBlockStatus, type WireBlockStop, type WireCustomEvent, type WireErrorEvent, type WireEvent, type WireInputArgDelta, type WireInputDelta, type WireKeepalive, type WireMessageStart, type WireMessageStop, type WireOutputDelta, type WireRetryEvent, type WireSignatureDelta, type WireStallWarning, type WireStatusDelta, type WireStopReason, type WireTextDelta, type WireThinkingDelta, type WorkspaceReadyPayload, generateId, isEmbeddedResource, isToolImageStub, isToolOutputStub, isVoiceLLMMode, isVoicePolishMode, mapSseToChat, parseEmbeddedResource, parseVoicePolishFrame, replayEvents, streamJobSSE, translateDelta };