@astralform/js 0.2.2 → 0.2.3

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
@@ -106,7 +106,24 @@ interface ErrorBlock {
106
106
  id: string;
107
107
  message: string;
108
108
  }
109
- type Block = UserBlock | TextBlock | ThinkingBlock | AgentBlock | SubagentBlock | ToolBlock | CapsuleBlock | AssetBlock | TodoBlock | EditorBlock | ErrorBlock;
109
+ interface DesktopStreamBlock {
110
+ type: "desktop_stream";
111
+ id: string;
112
+ url: string;
113
+ authKey: string;
114
+ sandboxId: string;
115
+ }
116
+ interface AttachmentBlock {
117
+ type: "attachment";
118
+ id: string;
119
+ files: {
120
+ name: string;
121
+ path: string;
122
+ mediaType: string;
123
+ sizeBytes: number;
124
+ }[];
125
+ }
126
+ type Block = UserBlock | TextBlock | ThinkingBlock | AgentBlock | SubagentBlock | ToolBlock | CapsuleBlock | AssetBlock | TodoBlock | EditorBlock | DesktopStreamBlock | AttachmentBlock | ErrorBlock;
110
127
  type EventHandler$1 = (event: ChatEvent, builder: BlockBuilder) => void;
111
128
  declare class BlockBuilder {
112
129
  private _blocks;
@@ -174,6 +191,10 @@ declare const ChatEventType: {
174
191
  readonly Error: "error";
175
192
  readonly Disconnected: "disconnected";
176
193
  readonly Retry: "retry";
194
+ readonly ContextUpdate: "context_update";
195
+ readonly DesktopStream: "desktop_stream";
196
+ readonly AttachmentStaged: "attachment_staged";
197
+ readonly WorkspaceReady: "workspace_ready";
177
198
  };
178
199
  interface UserMessageEvent {
179
200
  type: "user_message";
@@ -358,7 +379,33 @@ interface RetryEvent {
358
379
  max_attempts: number;
359
380
  delay_seconds: number;
360
381
  }
361
- type SSEEvent = MessageStartEvent | UserMessageEvent | TitleGeneratedEvent | ContentBlockDeltaEvent | ToolUseStartEvent | ToolUseEndEvent | ToolExecutingEvent | ToolProgressEvent | AgentStartEvent | AgentEndEvent | SubagentStartEvent | SubagentContentDeltaEvent | SubagentUpdateEvent | SubagentEndEvent | SubagentToolUseEvent | ThinkingDeltaEvent | ThinkingCompleteEvent | CapsuleOutputEvent | CapsuleOutputChunkEvent | TodoUpdateEvent | MessageStopEvent | AssetCreatedEvent | EditorContentStartEvent | EditorContentDeltaEvent | EditorContentEndEvent | RetryEvent | SSEErrorEvent;
382
+ interface ContextUpdateEvent {
383
+ type: "context_update";
384
+ context: Record<string, unknown>;
385
+ phase?: string;
386
+ updated_at?: number;
387
+ }
388
+ interface DesktopStreamEvent {
389
+ type: "desktop_stream";
390
+ url: string;
391
+ auth_key: string;
392
+ sandbox_id: string;
393
+ }
394
+ interface AttachmentStagedEvent {
395
+ type: "attachment_staged";
396
+ files: {
397
+ name: string;
398
+ path: string;
399
+ media_type: string;
400
+ size_bytes: number;
401
+ }[];
402
+ }
403
+ interface WorkspaceReadyEvent {
404
+ type: "workspace_ready";
405
+ conversation_id: string;
406
+ sandbox_id: string;
407
+ }
408
+ type SSEEvent = MessageStartEvent | UserMessageEvent | TitleGeneratedEvent | ContentBlockDeltaEvent | ToolUseStartEvent | ToolUseEndEvent | ToolExecutingEvent | ToolProgressEvent | AgentStartEvent | AgentEndEvent | SubagentStartEvent | SubagentContentDeltaEvent | SubagentUpdateEvent | SubagentEndEvent | SubagentToolUseEvent | ThinkingDeltaEvent | ThinkingCompleteEvent | CapsuleOutputEvent | CapsuleOutputChunkEvent | TodoUpdateEvent | MessageStopEvent | AssetCreatedEvent | EditorContentStartEvent | EditorContentDeltaEvent | EditorContentEndEvent | RetryEvent | ContextUpdateEvent | DesktopStreamEvent | AttachmentStagedEvent | WorkspaceReadyEvent | SSEErrorEvent;
362
409
  type ChatEvent = {
363
410
  type: "connected";
364
411
  } | {
@@ -481,6 +528,11 @@ type ChatEvent = {
481
528
  attempt: number;
482
529
  maxAttempts: number;
483
530
  delaySeconds: number;
531
+ } | {
532
+ type: "context_update";
533
+ context: Record<string, unknown>;
534
+ phase?: string;
535
+ updatedAt?: number;
484
536
  } | {
485
537
  type: "editor_content_start";
486
538
  callId: string;
@@ -494,6 +546,23 @@ type ChatEvent = {
494
546
  } | {
495
547
  type: "editor_content_end";
496
548
  callId: string;
549
+ } | {
550
+ type: "desktop_stream";
551
+ url: string;
552
+ authKey: string;
553
+ sandboxId: string;
554
+ } | {
555
+ type: "attachment_staged";
556
+ files: {
557
+ name: string;
558
+ path: string;
559
+ mediaType: string;
560
+ sizeBytes: number;
561
+ }[];
562
+ } | {
563
+ type: "workspace_ready";
564
+ conversationId: string;
565
+ sandboxId: string;
497
566
  } | {
498
567
  type: "model_info";
499
568
  name: string;
@@ -915,4 +984,4 @@ declare class StreamManager {
915
984
  private setActiveConversation;
916
985
  }
917
986
 
918
- export { type AgentBlock, type AgentEndEvent, type AgentInfo, type AgentStartEvent, type AssetBlock, AstralformClient, type AstralformConfig, AstralformError, AuthenticationError, type Block, BlockBuilder, type CapsuleBlock, type CapsuleOutput, type CapsuleOutputChunkEvent, type CapsuleOutputEvent, type ChatEvent, ChatEventType, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, ConnectionError, type ContentBlockDeltaEvent, type Conversation, type ConversationAsset, type ConversationEvent, type EditorBlock, type ErrorBlock, type EventHandler$1 as EventHandler, InMemoryStorage, type JobCreateResponse, LLMNotConfiguredError, type Message, type MessageStartEvent, type MessageStopEvent, type ProjectStatus, RateLimitError, type RetryEvent, type SSEErrorEvent, type SSEEvent, type SendOptions, ServerError, type SkillInfo, type Source, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentBlock, type SubagentContentDeltaEvent, type SubagentEndEvent, type SubagentStartEvent, type SubagentState, type SubagentToolUseEvent, type TextBlock, type ThinkingBlock, type ThinkingCompleteEvent, type ThinkingDeltaEvent, type TodoBlock, type TodoItem, type TodoUpdateEvent, type ToolBlock, type ToolCallRequest, type ToolDefinition, type ToolExecutingEvent, type ToolHandler, type ToolProgressEvent, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolState, type ToolUseEndEvent, type ToolUseStartEvent, type UserBlock, generateId, standardHandlers, streamJobSSE };
987
+ export { type AgentBlock, type AgentEndEvent, type AgentInfo, type AgentStartEvent, type AssetBlock, AstralformClient, type AstralformConfig, AstralformError, type AttachmentBlock, type AttachmentStagedEvent, AuthenticationError, type Block, BlockBuilder, type CapsuleBlock, type CapsuleOutput, type CapsuleOutputChunkEvent, type CapsuleOutputEvent, type ChatEvent, ChatEventType, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, ConnectionError, type ContentBlockDeltaEvent, type Conversation, type ConversationAsset, type ConversationEvent, type DesktopStreamBlock, type DesktopStreamEvent, type EditorBlock, type ErrorBlock, type EventHandler$1 as EventHandler, InMemoryStorage, type JobCreateResponse, LLMNotConfiguredError, type Message, type MessageStartEvent, type MessageStopEvent, type ProjectStatus, RateLimitError, type RetryEvent, type SSEErrorEvent, type SSEEvent, type SendOptions, ServerError, type SkillInfo, type Source, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentBlock, type SubagentContentDeltaEvent, type SubagentEndEvent, type SubagentStartEvent, type SubagentState, type SubagentToolUseEvent, type TextBlock, type ThinkingBlock, type ThinkingCompleteEvent, type ThinkingDeltaEvent, type TodoBlock, type TodoItem, type TodoUpdateEvent, type ToolBlock, type ToolCallRequest, type ToolDefinition, type ToolExecutingEvent, type ToolHandler, type ToolProgressEvent, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolState, type ToolUseEndEvent, type ToolUseStartEvent, type UserBlock, type WorkspaceReadyEvent, generateId, standardHandlers, streamJobSSE };
package/dist/index.d.ts CHANGED
@@ -106,7 +106,24 @@ interface ErrorBlock {
106
106
  id: string;
107
107
  message: string;
108
108
  }
109
- type Block = UserBlock | TextBlock | ThinkingBlock | AgentBlock | SubagentBlock | ToolBlock | CapsuleBlock | AssetBlock | TodoBlock | EditorBlock | ErrorBlock;
109
+ interface DesktopStreamBlock {
110
+ type: "desktop_stream";
111
+ id: string;
112
+ url: string;
113
+ authKey: string;
114
+ sandboxId: string;
115
+ }
116
+ interface AttachmentBlock {
117
+ type: "attachment";
118
+ id: string;
119
+ files: {
120
+ name: string;
121
+ path: string;
122
+ mediaType: string;
123
+ sizeBytes: number;
124
+ }[];
125
+ }
126
+ type Block = UserBlock | TextBlock | ThinkingBlock | AgentBlock | SubagentBlock | ToolBlock | CapsuleBlock | AssetBlock | TodoBlock | EditorBlock | DesktopStreamBlock | AttachmentBlock | ErrorBlock;
110
127
  type EventHandler$1 = (event: ChatEvent, builder: BlockBuilder) => void;
111
128
  declare class BlockBuilder {
112
129
  private _blocks;
@@ -174,6 +191,10 @@ declare const ChatEventType: {
174
191
  readonly Error: "error";
175
192
  readonly Disconnected: "disconnected";
176
193
  readonly Retry: "retry";
194
+ readonly ContextUpdate: "context_update";
195
+ readonly DesktopStream: "desktop_stream";
196
+ readonly AttachmentStaged: "attachment_staged";
197
+ readonly WorkspaceReady: "workspace_ready";
177
198
  };
178
199
  interface UserMessageEvent {
179
200
  type: "user_message";
@@ -358,7 +379,33 @@ interface RetryEvent {
358
379
  max_attempts: number;
359
380
  delay_seconds: number;
360
381
  }
361
- type SSEEvent = MessageStartEvent | UserMessageEvent | TitleGeneratedEvent | ContentBlockDeltaEvent | ToolUseStartEvent | ToolUseEndEvent | ToolExecutingEvent | ToolProgressEvent | AgentStartEvent | AgentEndEvent | SubagentStartEvent | SubagentContentDeltaEvent | SubagentUpdateEvent | SubagentEndEvent | SubagentToolUseEvent | ThinkingDeltaEvent | ThinkingCompleteEvent | CapsuleOutputEvent | CapsuleOutputChunkEvent | TodoUpdateEvent | MessageStopEvent | AssetCreatedEvent | EditorContentStartEvent | EditorContentDeltaEvent | EditorContentEndEvent | RetryEvent | SSEErrorEvent;
382
+ interface ContextUpdateEvent {
383
+ type: "context_update";
384
+ context: Record<string, unknown>;
385
+ phase?: string;
386
+ updated_at?: number;
387
+ }
388
+ interface DesktopStreamEvent {
389
+ type: "desktop_stream";
390
+ url: string;
391
+ auth_key: string;
392
+ sandbox_id: string;
393
+ }
394
+ interface AttachmentStagedEvent {
395
+ type: "attachment_staged";
396
+ files: {
397
+ name: string;
398
+ path: string;
399
+ media_type: string;
400
+ size_bytes: number;
401
+ }[];
402
+ }
403
+ interface WorkspaceReadyEvent {
404
+ type: "workspace_ready";
405
+ conversation_id: string;
406
+ sandbox_id: string;
407
+ }
408
+ type SSEEvent = MessageStartEvent | UserMessageEvent | TitleGeneratedEvent | ContentBlockDeltaEvent | ToolUseStartEvent | ToolUseEndEvent | ToolExecutingEvent | ToolProgressEvent | AgentStartEvent | AgentEndEvent | SubagentStartEvent | SubagentContentDeltaEvent | SubagentUpdateEvent | SubagentEndEvent | SubagentToolUseEvent | ThinkingDeltaEvent | ThinkingCompleteEvent | CapsuleOutputEvent | CapsuleOutputChunkEvent | TodoUpdateEvent | MessageStopEvent | AssetCreatedEvent | EditorContentStartEvent | EditorContentDeltaEvent | EditorContentEndEvent | RetryEvent | ContextUpdateEvent | DesktopStreamEvent | AttachmentStagedEvent | WorkspaceReadyEvent | SSEErrorEvent;
362
409
  type ChatEvent = {
363
410
  type: "connected";
364
411
  } | {
@@ -481,6 +528,11 @@ type ChatEvent = {
481
528
  attempt: number;
482
529
  maxAttempts: number;
483
530
  delaySeconds: number;
531
+ } | {
532
+ type: "context_update";
533
+ context: Record<string, unknown>;
534
+ phase?: string;
535
+ updatedAt?: number;
484
536
  } | {
485
537
  type: "editor_content_start";
486
538
  callId: string;
@@ -494,6 +546,23 @@ type ChatEvent = {
494
546
  } | {
495
547
  type: "editor_content_end";
496
548
  callId: string;
549
+ } | {
550
+ type: "desktop_stream";
551
+ url: string;
552
+ authKey: string;
553
+ sandboxId: string;
554
+ } | {
555
+ type: "attachment_staged";
556
+ files: {
557
+ name: string;
558
+ path: string;
559
+ mediaType: string;
560
+ sizeBytes: number;
561
+ }[];
562
+ } | {
563
+ type: "workspace_ready";
564
+ conversationId: string;
565
+ sandboxId: string;
497
566
  } | {
498
567
  type: "model_info";
499
568
  name: string;
@@ -915,4 +984,4 @@ declare class StreamManager {
915
984
  private setActiveConversation;
916
985
  }
917
986
 
918
- export { type AgentBlock, type AgentEndEvent, type AgentInfo, type AgentStartEvent, type AssetBlock, AstralformClient, type AstralformConfig, AstralformError, AuthenticationError, type Block, BlockBuilder, type CapsuleBlock, type CapsuleOutput, type CapsuleOutputChunkEvent, type CapsuleOutputEvent, type ChatEvent, ChatEventType, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, ConnectionError, type ContentBlockDeltaEvent, type Conversation, type ConversationAsset, type ConversationEvent, type EditorBlock, type ErrorBlock, type EventHandler$1 as EventHandler, InMemoryStorage, type JobCreateResponse, LLMNotConfiguredError, type Message, type MessageStartEvent, type MessageStopEvent, type ProjectStatus, RateLimitError, type RetryEvent, type SSEErrorEvent, type SSEEvent, type SendOptions, ServerError, type SkillInfo, type Source, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentBlock, type SubagentContentDeltaEvent, type SubagentEndEvent, type SubagentStartEvent, type SubagentState, type SubagentToolUseEvent, type TextBlock, type ThinkingBlock, type ThinkingCompleteEvent, type ThinkingDeltaEvent, type TodoBlock, type TodoItem, type TodoUpdateEvent, type ToolBlock, type ToolCallRequest, type ToolDefinition, type ToolExecutingEvent, type ToolHandler, type ToolProgressEvent, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolState, type ToolUseEndEvent, type ToolUseStartEvent, type UserBlock, generateId, standardHandlers, streamJobSSE };
987
+ export { type AgentBlock, type AgentEndEvent, type AgentInfo, type AgentStartEvent, type AssetBlock, AstralformClient, type AstralformConfig, AstralformError, type AttachmentBlock, type AttachmentStagedEvent, AuthenticationError, type Block, BlockBuilder, type CapsuleBlock, type CapsuleOutput, type CapsuleOutputChunkEvent, type CapsuleOutputEvent, type ChatEvent, ChatEventType, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, ConnectionError, type ContentBlockDeltaEvent, type Conversation, type ConversationAsset, type ConversationEvent, type DesktopStreamBlock, type DesktopStreamEvent, type EditorBlock, type ErrorBlock, type EventHandler$1 as EventHandler, InMemoryStorage, type JobCreateResponse, LLMNotConfiguredError, type Message, type MessageStartEvent, type MessageStopEvent, type ProjectStatus, RateLimitError, type RetryEvent, type SSEErrorEvent, type SSEEvent, type SendOptions, ServerError, type SkillInfo, type Source, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentBlock, type SubagentContentDeltaEvent, type SubagentEndEvent, type SubagentStartEvent, type SubagentState, type SubagentToolUseEvent, type TextBlock, type ThinkingBlock, type ThinkingCompleteEvent, type ThinkingDeltaEvent, type TodoBlock, type TodoItem, type TodoUpdateEvent, type ToolBlock, type ToolCallRequest, type ToolDefinition, type ToolExecutingEvent, type ToolHandler, type ToolProgressEvent, ToolRegistry, type ToolResult, type ToolResultRequest, type ToolState, type ToolUseEndEvent, type ToolUseStartEvent, type UserBlock, type WorkspaceReadyEvent, generateId, standardHandlers, streamJobSSE };
package/dist/index.js CHANGED
@@ -1050,6 +1050,40 @@ var ChatSession = class {
1050
1050
  this.todos = event.todos;
1051
1051
  this.emit({ type: "todo_update", todos: event.todos });
1052
1052
  break;
1053
+ case "context_update":
1054
+ this.emit({
1055
+ type: "context_update",
1056
+ context: event.context,
1057
+ phase: event.phase,
1058
+ updatedAt: event.updated_at
1059
+ });
1060
+ break;
1061
+ case "desktop_stream":
1062
+ this.emit({
1063
+ type: "desktop_stream",
1064
+ url: event.url,
1065
+ authKey: event.auth_key,
1066
+ sandboxId: event.sandbox_id
1067
+ });
1068
+ break;
1069
+ case "attachment_staged":
1070
+ this.emit({
1071
+ type: "attachment_staged",
1072
+ files: (event.files || []).map((f) => ({
1073
+ name: f.name,
1074
+ path: f.path,
1075
+ mediaType: f.media_type,
1076
+ sizeBytes: f.size_bytes
1077
+ }))
1078
+ });
1079
+ break;
1080
+ case "workspace_ready":
1081
+ this.emit({
1082
+ type: "workspace_ready",
1083
+ conversationId: event.conversation_id,
1084
+ sandboxId: event.sandbox_id
1085
+ });
1086
+ break;
1053
1087
  case "asset_created":
1054
1088
  this.emit({
1055
1089
  type: "asset_created",
@@ -1599,6 +1633,35 @@ var handleEditorContentEnd = (event, builder) => {
1599
1633
  }
1600
1634
  builder.activeEditorId = null;
1601
1635
  };
1636
+ var handleDesktopStream = (event, builder) => {
1637
+ const e = event;
1638
+ if (!e.url) return;
1639
+ const existing = builder.findBlock((b) => b.type === "desktop_stream");
1640
+ if (existing) {
1641
+ builder.patchBlock(existing.id, {
1642
+ url: e.url,
1643
+ authKey: e.authKey,
1644
+ sandboxId: e.sandboxId
1645
+ });
1646
+ } else {
1647
+ builder.addBlock({
1648
+ type: "desktop_stream",
1649
+ id: builder.nextId(),
1650
+ url: e.url,
1651
+ authKey: e.authKey,
1652
+ sandboxId: e.sandboxId
1653
+ });
1654
+ }
1655
+ };
1656
+ var handleAttachmentStaged = (event, builder) => {
1657
+ const e = event;
1658
+ if (!e.files || e.files.length === 0) return;
1659
+ builder.addBlock({
1660
+ type: "attachment",
1661
+ id: builder.nextId(),
1662
+ files: e.files
1663
+ });
1664
+ };
1602
1665
  var noop = () => {
1603
1666
  };
1604
1667
  var standardHandlers = {
@@ -1625,6 +1688,9 @@ var standardHandlers = {
1625
1688
  editor_content_start: handleEditorContentStart,
1626
1689
  editor_content_delta: handleEditorContentDelta,
1627
1690
  editor_content_end: handleEditorContentEnd,
1691
+ desktop_stream: handleDesktopStream,
1692
+ attachment_staged: handleAttachmentStaged,
1693
+ workspace_ready: noop,
1628
1694
  retry: noop,
1629
1695
  complete: handleComplete,
1630
1696
  error: handleError,
@@ -1663,7 +1729,11 @@ var ChatEventType = {
1663
1729
  Complete: "complete",
1664
1730
  Error: "error",
1665
1731
  Disconnected: "disconnected",
1666
- Retry: "retry"
1732
+ Retry: "retry",
1733
+ ContextUpdate: "context_update",
1734
+ DesktopStream: "desktop_stream",
1735
+ AttachmentStaged: "attachment_staged",
1736
+ WorkspaceReady: "workspace_ready"
1667
1737
  };
1668
1738
 
1669
1739
  // src/stream-manager.ts