@astralform/js 9.2.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
@@ -1207,6 +1207,50 @@ interface ToolOutputStub {
1207
1207
  declare function isToolOutputStub(value: unknown): value is ToolOutputStub;
1208
1208
  /** How a restore asks for tool outputs. */
1209
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";
1210
1254
  interface ConversationEvent {
1211
1255
  seq: number;
1212
1256
  event: string;
@@ -1521,6 +1565,8 @@ declare class AstralformClient {
1521
1565
  */
1522
1566
  private getWithHeaders;
1523
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;
1524
1570
  post<T>(path: string, body: unknown): Promise<T>;
1525
1571
  patch<T>(path: string, body: unknown): Promise<T>;
1526
1572
  private del;
@@ -1619,6 +1665,7 @@ declare class AstralformClient {
1619
1665
  listSkillCommands(surface?: SlashCommandSurface): Promise<SlashCommand[]>;
1620
1666
  getConversationEvents(conversationId: string, jobId?: string, options?: {
1621
1667
  toolOutputs?: ToolOutputMode;
1668
+ toolImages?: ToolImageMode;
1622
1669
  }): Promise<ConversationEvent[]>;
1623
1670
  /**
1624
1671
  * The full output behind a {@link ToolOutputStub}.
@@ -1640,6 +1687,20 @@ declare class AstralformClient {
1640
1687
  * Prefer the overload above, which takes the stub and cannot be got wrong.
1641
1688
  */
1642
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>;
1643
1704
  submitToolResult(request: ToolResultRequest): Promise<void>;
1644
1705
  submitToolApproval(request: ToolApprovalRequest): Promise<void>;
1645
1706
  /**
@@ -2368,6 +2429,12 @@ declare class StreamManager {
2368
2429
  * Defaults to inline, so this is inert until a consumer opts in.
2369
2430
  */
2370
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;
2371
2438
  private _state;
2372
2439
  private _activeConversationId;
2373
2440
  private _backgroundJobs;
@@ -2407,6 +2474,21 @@ declare class StreamManager {
2407
2474
  * belongs, because that is what arrives in `final.output`.
2408
2475
  */
2409
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();
2410
2492
  private emit;
2411
2493
  private setState;
2412
2494
  private attach;
@@ -2684,4 +2766,4 @@ declare function isEmbeddedResource(value: unknown): value is {
2684
2766
  */
2685
2767
  declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
2686
2768
 
2687
- 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 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
@@ -1207,6 +1207,50 @@ interface ToolOutputStub {
1207
1207
  declare function isToolOutputStub(value: unknown): value is ToolOutputStub;
1208
1208
  /** How a restore asks for tool outputs. */
1209
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";
1210
1254
  interface ConversationEvent {
1211
1255
  seq: number;
1212
1256
  event: string;
@@ -1521,6 +1565,8 @@ declare class AstralformClient {
1521
1565
  */
1522
1566
  private getWithHeaders;
1523
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;
1524
1570
  post<T>(path: string, body: unknown): Promise<T>;
1525
1571
  patch<T>(path: string, body: unknown): Promise<T>;
1526
1572
  private del;
@@ -1619,6 +1665,7 @@ declare class AstralformClient {
1619
1665
  listSkillCommands(surface?: SlashCommandSurface): Promise<SlashCommand[]>;
1620
1666
  getConversationEvents(conversationId: string, jobId?: string, options?: {
1621
1667
  toolOutputs?: ToolOutputMode;
1668
+ toolImages?: ToolImageMode;
1622
1669
  }): Promise<ConversationEvent[]>;
1623
1670
  /**
1624
1671
  * The full output behind a {@link ToolOutputStub}.
@@ -1640,6 +1687,20 @@ declare class AstralformClient {
1640
1687
  * Prefer the overload above, which takes the stub and cannot be got wrong.
1641
1688
  */
1642
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>;
1643
1704
  submitToolResult(request: ToolResultRequest): Promise<void>;
1644
1705
  submitToolApproval(request: ToolApprovalRequest): Promise<void>;
1645
1706
  /**
@@ -2368,6 +2429,12 @@ declare class StreamManager {
2368
2429
  * Defaults to inline, so this is inert until a consumer opts in.
2369
2430
  */
2370
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;
2371
2438
  private _state;
2372
2439
  private _activeConversationId;
2373
2440
  private _backgroundJobs;
@@ -2407,6 +2474,21 @@ declare class StreamManager {
2407
2474
  * belongs, because that is what arrives in `final.output`.
2408
2475
  */
2409
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();
2410
2492
  private emit;
2411
2493
  private setState;
2412
2494
  private attach;
@@ -2684,4 +2766,4 @@ declare function isEmbeddedResource(value: unknown): value is {
2684
2766
  */
2685
2767
  declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
2686
2768
 
2687
- 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 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.js CHANGED
@@ -319,6 +319,11 @@ function isToolOutputStub(value) {
319
319
  const v = value;
320
320
  return v.__stub === "tool_output" && typeof v.call_id === "string" && v.call_id.length > 0;
321
321
  }
322
+ function isToolImageStub(value) {
323
+ if (typeof value !== "object" || value === null) return false;
324
+ const v = value;
325
+ return v.__stub === "tool_image" && typeof v.call_id === "string" && v.call_id.length > 0 && typeof v.index === "number" && Number.isInteger(v.index) && v.index >= 0;
326
+ }
322
327
 
323
328
  // src/client.ts
324
329
  var DEFAULT_BASE_URL = "https://api.astralform.ai";
@@ -642,6 +647,13 @@ var AstralformClient = class {
642
647
  return await response.json();
643
648
  });
644
649
  }
650
+ /** A GET whose body is binary. Read inside the race, for the reason above. */
651
+ async getBlob(path) {
652
+ return this.withDeadline(async (signal) => {
653
+ const response = await this.send("GET", path, void 0, signal);
654
+ return response.blob();
655
+ });
656
+ }
645
657
  async post(path, body) {
646
658
  return this.withDeadline(async (signal) => {
647
659
  const response = await this.send("POST", path, body, signal);
@@ -861,6 +873,7 @@ var AstralformClient = class {
861
873
  const params = new URLSearchParams();
862
874
  if (jobId) params.set("job_id", jobId);
863
875
  if (options?.toolOutputs === "stub") params.set("tool_outputs", "stub");
876
+ if (options?.toolImages === "stub") params.set("tool_images", "stub");
864
877
  const query = params.toString();
865
878
  return this.get(
866
879
  `/v1/conversations/${encodeURIComponent(conversationId)}/events${query ? `?${query}` : ""}`
@@ -875,6 +888,25 @@ var AstralformClient = class {
875
888
  );
876
889
  return res.output;
877
890
  }
891
+ /**
892
+ * The image behind a {@link ToolImageStub}, as a `Blob` of the preview's bytes.
893
+ *
894
+ * Takes the stub itself and nothing else — the `job_id` scoping that
895
+ * `getToolOutput`'s id form warns about cannot be dropped from a value that
896
+ * carries it. There is deliberately no by-ids form.
897
+ *
898
+ * A `Blob` rather than a URL because the route is authenticated: an `<img
899
+ * src>` cannot send the bearer token, so a browser consumer turns this into
900
+ * an object URL (`URL.createObjectURL`) and revokes it when the image
901
+ * unmounts. The response is `private, immutable`, so a repeat fetch of the
902
+ * same preview is served by the HTTP cache.
903
+ */
904
+ async getToolImage(conversationId, stub) {
905
+ const query = stub.job_id ? `?job_id=${encodeURIComponent(stub.job_id)}` : "";
906
+ return this.getBlob(
907
+ `/v1/conversations/${encodeURIComponent(conversationId)}/tool-output/${encodeURIComponent(stub.call_id)}/images/${stub.index}${query}`
908
+ );
909
+ }
878
910
  async submitToolResult(request) {
879
911
  await this.post("/v1/tool-result", request);
880
912
  }
@@ -2749,6 +2781,12 @@ var StreamManager = class _StreamManager {
2749
2781
  * Defaults to inline, so this is inert until a consumer opts in.
2750
2782
  */
2751
2783
  this.toolOutputs = "inline";
2784
+ /**
2785
+ * Whether restore asks for tool image previews inline or as fetch handles.
2786
+ * Separate from `toolOutputs` because the server keeps them separate — see
2787
+ * `ToolImageStub` — and on the same one-setting-both-waves rule.
2788
+ */
2789
+ this.toolImages = "inline";
2752
2790
  this._state = "idle";
2753
2791
  this._activeConversationId = null;
2754
2792
  this._backgroundJobs = /* @__PURE__ */ new Map();
@@ -2805,6 +2843,25 @@ var StreamManager = class _StreamManager {
2805
2843
  setToolOutputMode(mode) {
2806
2844
  this.toolOutputs = mode;
2807
2845
  }
2846
+ /**
2847
+ * Ask restore for stubbed image previews, fetched on demand.
2848
+ *
2849
+ * The same caution as `setToolOutputMode`, sharper: a consumer that cannot
2850
+ * resolve one (`isToolImageStub`, `client.getToolImage`) finds an `images`
2851
+ * entry with no `url` and draws a broken image where the preview was.
2852
+ */
2853
+ setToolImageMode(mode) {
2854
+ this.toolImages = mode;
2855
+ }
2856
+ /**
2857
+ * The ONE options object both event waves fetch with — the newest page and
2858
+ * every `loadEarlierTurns` page. Built in one place so an opt-in added here
2859
+ * reaches both by construction: two literals at two call sites is how one
2860
+ * wave would silently keep asking for inline payloads.
2861
+ */
2862
+ get eventFetchOptions() {
2863
+ return { toolOutputs: this.toolOutputs, toolImages: this.toolImages };
2864
+ }
2808
2865
  emit(event) {
2809
2866
  for (const handler of this.handlers) {
2810
2867
  try {
@@ -3305,9 +3362,7 @@ var StreamManager = class _StreamManager {
3305
3362
  const boundary = this.oldestDrawnMessageId;
3306
3363
  const eventLists = await Promise.all(
3307
3364
  page.jobs.map(
3308
- (job) => session.client.getConversationEvents(conversationId, job.job_id, {
3309
- toolOutputs: this.toolOutputs
3310
- }).catch(() => [])
3365
+ (job) => session.client.getConversationEvents(conversationId, job.job_id, this.eventFetchOptions).catch(() => [])
3311
3366
  )
3312
3367
  );
3313
3368
  if (stop()) return 0;
@@ -3428,9 +3483,7 @@ var StreamManager = class _StreamManager {
3428
3483
  });
3429
3484
  const eventLists = await Promise.all(
3430
3485
  replayableJobs.map(
3431
- (job) => this.session.client.getConversationEvents(conversationId, job.job_id, {
3432
- toolOutputs: this.toolOutputs
3433
- }).catch(() => [])
3486
+ (job) => this.session.client.getConversationEvents(conversationId, job.job_id, this.eventFetchOptions).catch(() => [])
3434
3487
  )
3435
3488
  );
3436
3489
  if (stopReplay()) return false;
@@ -3578,6 +3631,7 @@ export {
3578
3631
  VOICE_POLISH_MODES,
3579
3632
  generateId,
3580
3633
  isEmbeddedResource,
3634
+ isToolImageStub,
3581
3635
  isToolOutputStub,
3582
3636
  isVoiceLLMMode,
3583
3637
  isVoicePolishMode,