@astralform/js 7.2.0 → 7.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
@@ -822,7 +822,118 @@ interface StreamJobSSEOptions {
822
822
  headers: Record<string, string>;
823
823
  signal?: AbortSignal;
824
824
  fetchFn: typeof globalThis.fetch;
825
+ /** Request method; defaults to GET (the job event stream). */
826
+ method?: "GET" | "POST";
827
+ /** A JSON-serialised body for POST streams (the voice polish stream). */
828
+ body?: string;
825
829
  }
830
+ /**
831
+ * The styles a transcript can be shaped into, as the server names them.
832
+ * `raw` never calls the model — the transcript is used as recognized.
833
+ */
834
+ declare const VOICE_POLISH_MODES: readonly ["raw", "light", "structured", "formal"];
835
+ type VoicePolishMode = (typeof VOICE_POLISH_MODES)[number];
836
+ /** A mode that calls the polish model — every mode except `raw`. */
837
+ type VoiceLLMMode = Exclude<VoicePolishMode, "raw">;
838
+ /** Whether `value` is one of the four modes this SDK version knows. */
839
+ declare function isVoicePolishMode(value: unknown): value is VoicePolishMode;
840
+ /**
841
+ * Whether `mode` may be passed to `streamVoicePolish` — the check to make on
842
+ * `VoiceConfig.defaultMode`, which can be `raw`.
843
+ */
844
+ declare function isVoiceLLMMode(mode: VoicePolishMode): mode is VoiceLLMMode;
845
+ /**
846
+ * What a client needs to run the microphone for an agent, from
847
+ * `GET /v1/voice/config`. Deliberately carries no provider or model names.
848
+ */
849
+ interface VoiceConfig {
850
+ enabled: boolean;
851
+ /**
852
+ * The styles the client may request, as the server names them. Kept as
853
+ * plain strings so a mode this SDK version does not know still reaches a
854
+ * picker; `isVoicePolishMode` narrows one.
855
+ */
856
+ modes: string[];
857
+ /**
858
+ * The style to use when the user has not picked one. Falls back to
859
+ * `structured` when the server names a mode this SDK does not know. Can be
860
+ * `raw`, which `streamVoicePolish` refuses — check it with `isVoiceLLMMode`
861
+ * (or compare against `"raw"`) before polishing.
862
+ */
863
+ defaultMode: VoicePolishMode;
864
+ /** In tap-to-talk mode, the pause that ends a recording. */
865
+ silenceAutoStopSeconds: number;
866
+ /** Send the message as soon as the result is ready. */
867
+ autoSend: boolean;
868
+ maxRecordingSeconds: number;
869
+ /**
870
+ * Whether the configured recognizer emits live partial transcripts. Batch
871
+ * (Whisper-style) providers do not; they transcribe on stop.
872
+ */
873
+ supportsStreaming: boolean;
874
+ /**
875
+ * The project vocabulary, for display. The server applies it to every
876
+ * transcription and polish itself; `transcribeVoice({ hotwords })` and
877
+ * `VoicePolishRequest.hotwords` carry only the user's own words, which the
878
+ * server merges after these.
879
+ */
880
+ hotwords: string[];
881
+ }
882
+ /** One recording turned into text, from `POST /v1/voice/transcriptions`. */
883
+ interface VoiceTranscript {
884
+ text: string;
885
+ language: string | null;
886
+ /** Length of the submitted audio, when the WAV header said so. */
887
+ durationMs: number | null;
888
+ /** Time the provider took. */
889
+ asrMs: number;
890
+ }
891
+ interface VoiceTranscribeOptions {
892
+ /** File name sent with the recording; defaults to `recording.wav`. */
893
+ filename?: string;
894
+ /**
895
+ * The user's own vocabulary — not the project's, which the server already
896
+ * holds and merges in first. Sent comma-separated, so a word cannot itself
897
+ * contain a comma.
898
+ */
899
+ hotwords?: string[];
900
+ /** ISO 639-1 hint; omit for auto-detection. */
901
+ language?: string;
902
+ /**
903
+ * Abort the upload. No client-side deadline applies to this call (a
904
+ * recording can run to `maxRecordingSeconds` and the upload with it), so
905
+ * this is the only way to give up on a stalled one; the promise rejects
906
+ * with the abort reason (the runtime's `AbortError`, or what was passed to
907
+ * `abort(reason)`).
908
+ */
909
+ signal?: AbortSignal;
910
+ }
911
+ interface VoicePolishRequest {
912
+ text: string;
913
+ /** One of the LLM modes; `raw` is refused by the server. */
914
+ mode: VoiceLLMMode;
915
+ /** The user's own vocabulary; the server merges it after the project's. */
916
+ hotwords?: string[];
917
+ }
918
+ /**
919
+ * One frame of the polish stream. `delta` text arrives in order; `done.text`
920
+ * is authoritative (the cleaned full output, which can differ from the
921
+ * concatenated deltas). On `error` keep the raw transcript; `partial` is what
922
+ * was streamed before the failure.
923
+ */
924
+ type VoicePolishEvent = {
925
+ type: "delta";
926
+ text: string;
927
+ } | {
928
+ type: "done";
929
+ text: string;
930
+ polishMs: number;
931
+ } | {
932
+ type: "error";
933
+ reason: string;
934
+ partial: string;
935
+ detail?: string;
936
+ };
826
937
  interface ChatStreamEvent {
827
938
  event: string;
828
939
  data: string;
@@ -1087,6 +1198,34 @@ declare class AstralformClient {
1087
1198
  revokeToolPermission(id: string): Promise<void>;
1088
1199
  private mapAsset;
1089
1200
  uploadFile(conversationId: string, file: Blob, filename?: string): Promise<ConversationAsset>;
1201
+ /** The agent's voice-input defaults (`GET /v1/voice/config`). */
1202
+ getVoiceConfig(): Promise<VoiceConfig>;
1203
+ /**
1204
+ * Transcribe one recording with the agent's configured speech-to-text
1205
+ * provider (`POST /v1/voice/transcriptions`). 16 kHz mono 16-bit WAV is the
1206
+ * reference format; anything the provider accepts works.
1207
+ *
1208
+ * Deliberately outside `withDeadline`: a recording can run to
1209
+ * `VoiceConfig.maxRecordingSeconds`, so the 30 s default would cut real
1210
+ * uploads off. Pass `options.signal` to give up on a stalled one; the
1211
+ * promise then rejects with the abort reason — the runtime's `AbortError`,
1212
+ * or whatever was passed to `abort(reason)`.
1213
+ */
1214
+ transcribeVoice(audio: Blob, options?: VoiceTranscribeOptions): Promise<VoiceTranscript>;
1215
+ /**
1216
+ * Stream the LLM rewrite of a transcript (`POST /v1/voice/polish`) as typed
1217
+ * frames.
1218
+ *
1219
+ * Failures the server reports mid-stream arrive as an `error` frame, but
1220
+ * the iteration itself can reject: aborting `signal` closes the connection
1221
+ * (which cancels the model call upstream) and rejects with
1222
+ * `StreamAbortedError`; a non-2xx open rejects with `AuthenticationError`,
1223
+ * `RateLimitError` or `ServerError`; a network failure with
1224
+ * `ConnectionError`. Wrap the `for await` accordingly.
1225
+ */
1226
+ streamVoicePolish(request: VoicePolishRequest, options?: {
1227
+ signal?: AbortSignal;
1228
+ }): AsyncGenerator<VoicePolishEvent>;
1090
1229
  listUploads(conversationId: string): Promise<ConversationAsset[]>;
1091
1230
  listOutputs(conversationId: string): Promise<ConversationAsset[]>;
1092
1231
  listTeams(): Promise<TeamSummary[]>;
@@ -1104,6 +1243,14 @@ declare class AstralformClient {
1104
1243
  getActiveJob(conversationId: string): Promise<ActiveJob>;
1105
1244
  listJobs(conversationId: string): Promise<JobSummary[]>;
1106
1245
  }
1246
+ /**
1247
+ * Decode one SSE frame of `POST /v1/voice/polish`; null for frames the
1248
+ * client does not act on (pings, unknown events).
1249
+ */
1250
+ declare function parseVoicePolishFrame(frame: {
1251
+ event: string;
1252
+ data: string;
1253
+ }): VoicePolishEvent | null;
1107
1254
 
1108
1255
  /**
1109
1256
  * Minimal adapter contract. Frontends extend this with a `render()`
@@ -1532,7 +1679,8 @@ declare class StreamAbortedError extends AstralformError {
1532
1679
  declare function generateId(): string;
1533
1680
 
1534
1681
  /**
1535
- * GET-based SSE stream for job events.
1682
+ * SSE stream reader. GET for the job event stream (the default); POST with a
1683
+ * JSON body for the voice polish stream. The frame parser is the same.
1536
1684
  */
1537
1685
  declare function streamJobSSE(options: StreamJobSSEOptions): AsyncGenerator<ChatStreamEvent>;
1538
1686
 
@@ -1855,4 +2003,4 @@ declare function isEmbeddedResource(value: unknown): value is {
1855
2003
  */
1856
2004
  declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
1857
2005
 
1858
- 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 BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, 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 MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SkillInfo, 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 ToolPermissionDeniedPayload, ToolRegistry, type ToolResult, type ToolResultRequest, type TurnUsage, type UIComponentsConfig, type UserUnavailablePayload, 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, mapSseToChat, parseEmbeddedResource, replayEvents, streamJobSSE, translateDelta };
2006
+ 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 BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, 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 MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SkillInfo, 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 ToolPermissionDeniedPayload, ToolRegistry, type ToolResult, type ToolResultRequest, 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, isVoiceLLMMode, isVoicePolishMode, mapSseToChat, parseEmbeddedResource, parseVoicePolishFrame, replayEvents, streamJobSSE, translateDelta };
package/dist/index.d.ts CHANGED
@@ -822,7 +822,118 @@ interface StreamJobSSEOptions {
822
822
  headers: Record<string, string>;
823
823
  signal?: AbortSignal;
824
824
  fetchFn: typeof globalThis.fetch;
825
+ /** Request method; defaults to GET (the job event stream). */
826
+ method?: "GET" | "POST";
827
+ /** A JSON-serialised body for POST streams (the voice polish stream). */
828
+ body?: string;
825
829
  }
830
+ /**
831
+ * The styles a transcript can be shaped into, as the server names them.
832
+ * `raw` never calls the model — the transcript is used as recognized.
833
+ */
834
+ declare const VOICE_POLISH_MODES: readonly ["raw", "light", "structured", "formal"];
835
+ type VoicePolishMode = (typeof VOICE_POLISH_MODES)[number];
836
+ /** A mode that calls the polish model — every mode except `raw`. */
837
+ type VoiceLLMMode = Exclude<VoicePolishMode, "raw">;
838
+ /** Whether `value` is one of the four modes this SDK version knows. */
839
+ declare function isVoicePolishMode(value: unknown): value is VoicePolishMode;
840
+ /**
841
+ * Whether `mode` may be passed to `streamVoicePolish` — the check to make on
842
+ * `VoiceConfig.defaultMode`, which can be `raw`.
843
+ */
844
+ declare function isVoiceLLMMode(mode: VoicePolishMode): mode is VoiceLLMMode;
845
+ /**
846
+ * What a client needs to run the microphone for an agent, from
847
+ * `GET /v1/voice/config`. Deliberately carries no provider or model names.
848
+ */
849
+ interface VoiceConfig {
850
+ enabled: boolean;
851
+ /**
852
+ * The styles the client may request, as the server names them. Kept as
853
+ * plain strings so a mode this SDK version does not know still reaches a
854
+ * picker; `isVoicePolishMode` narrows one.
855
+ */
856
+ modes: string[];
857
+ /**
858
+ * The style to use when the user has not picked one. Falls back to
859
+ * `structured` when the server names a mode this SDK does not know. Can be
860
+ * `raw`, which `streamVoicePolish` refuses — check it with `isVoiceLLMMode`
861
+ * (or compare against `"raw"`) before polishing.
862
+ */
863
+ defaultMode: VoicePolishMode;
864
+ /** In tap-to-talk mode, the pause that ends a recording. */
865
+ silenceAutoStopSeconds: number;
866
+ /** Send the message as soon as the result is ready. */
867
+ autoSend: boolean;
868
+ maxRecordingSeconds: number;
869
+ /**
870
+ * Whether the configured recognizer emits live partial transcripts. Batch
871
+ * (Whisper-style) providers do not; they transcribe on stop.
872
+ */
873
+ supportsStreaming: boolean;
874
+ /**
875
+ * The project vocabulary, for display. The server applies it to every
876
+ * transcription and polish itself; `transcribeVoice({ hotwords })` and
877
+ * `VoicePolishRequest.hotwords` carry only the user's own words, which the
878
+ * server merges after these.
879
+ */
880
+ hotwords: string[];
881
+ }
882
+ /** One recording turned into text, from `POST /v1/voice/transcriptions`. */
883
+ interface VoiceTranscript {
884
+ text: string;
885
+ language: string | null;
886
+ /** Length of the submitted audio, when the WAV header said so. */
887
+ durationMs: number | null;
888
+ /** Time the provider took. */
889
+ asrMs: number;
890
+ }
891
+ interface VoiceTranscribeOptions {
892
+ /** File name sent with the recording; defaults to `recording.wav`. */
893
+ filename?: string;
894
+ /**
895
+ * The user's own vocabulary — not the project's, which the server already
896
+ * holds and merges in first. Sent comma-separated, so a word cannot itself
897
+ * contain a comma.
898
+ */
899
+ hotwords?: string[];
900
+ /** ISO 639-1 hint; omit for auto-detection. */
901
+ language?: string;
902
+ /**
903
+ * Abort the upload. No client-side deadline applies to this call (a
904
+ * recording can run to `maxRecordingSeconds` and the upload with it), so
905
+ * this is the only way to give up on a stalled one; the promise rejects
906
+ * with the abort reason (the runtime's `AbortError`, or what was passed to
907
+ * `abort(reason)`).
908
+ */
909
+ signal?: AbortSignal;
910
+ }
911
+ interface VoicePolishRequest {
912
+ text: string;
913
+ /** One of the LLM modes; `raw` is refused by the server. */
914
+ mode: VoiceLLMMode;
915
+ /** The user's own vocabulary; the server merges it after the project's. */
916
+ hotwords?: string[];
917
+ }
918
+ /**
919
+ * One frame of the polish stream. `delta` text arrives in order; `done.text`
920
+ * is authoritative (the cleaned full output, which can differ from the
921
+ * concatenated deltas). On `error` keep the raw transcript; `partial` is what
922
+ * was streamed before the failure.
923
+ */
924
+ type VoicePolishEvent = {
925
+ type: "delta";
926
+ text: string;
927
+ } | {
928
+ type: "done";
929
+ text: string;
930
+ polishMs: number;
931
+ } | {
932
+ type: "error";
933
+ reason: string;
934
+ partial: string;
935
+ detail?: string;
936
+ };
826
937
  interface ChatStreamEvent {
827
938
  event: string;
828
939
  data: string;
@@ -1087,6 +1198,34 @@ declare class AstralformClient {
1087
1198
  revokeToolPermission(id: string): Promise<void>;
1088
1199
  private mapAsset;
1089
1200
  uploadFile(conversationId: string, file: Blob, filename?: string): Promise<ConversationAsset>;
1201
+ /** The agent's voice-input defaults (`GET /v1/voice/config`). */
1202
+ getVoiceConfig(): Promise<VoiceConfig>;
1203
+ /**
1204
+ * Transcribe one recording with the agent's configured speech-to-text
1205
+ * provider (`POST /v1/voice/transcriptions`). 16 kHz mono 16-bit WAV is the
1206
+ * reference format; anything the provider accepts works.
1207
+ *
1208
+ * Deliberately outside `withDeadline`: a recording can run to
1209
+ * `VoiceConfig.maxRecordingSeconds`, so the 30 s default would cut real
1210
+ * uploads off. Pass `options.signal` to give up on a stalled one; the
1211
+ * promise then rejects with the abort reason — the runtime's `AbortError`,
1212
+ * or whatever was passed to `abort(reason)`.
1213
+ */
1214
+ transcribeVoice(audio: Blob, options?: VoiceTranscribeOptions): Promise<VoiceTranscript>;
1215
+ /**
1216
+ * Stream the LLM rewrite of a transcript (`POST /v1/voice/polish`) as typed
1217
+ * frames.
1218
+ *
1219
+ * Failures the server reports mid-stream arrive as an `error` frame, but
1220
+ * the iteration itself can reject: aborting `signal` closes the connection
1221
+ * (which cancels the model call upstream) and rejects with
1222
+ * `StreamAbortedError`; a non-2xx open rejects with `AuthenticationError`,
1223
+ * `RateLimitError` or `ServerError`; a network failure with
1224
+ * `ConnectionError`. Wrap the `for await` accordingly.
1225
+ */
1226
+ streamVoicePolish(request: VoicePolishRequest, options?: {
1227
+ signal?: AbortSignal;
1228
+ }): AsyncGenerator<VoicePolishEvent>;
1090
1229
  listUploads(conversationId: string): Promise<ConversationAsset[]>;
1091
1230
  listOutputs(conversationId: string): Promise<ConversationAsset[]>;
1092
1231
  listTeams(): Promise<TeamSummary[]>;
@@ -1104,6 +1243,14 @@ declare class AstralformClient {
1104
1243
  getActiveJob(conversationId: string): Promise<ActiveJob>;
1105
1244
  listJobs(conversationId: string): Promise<JobSummary[]>;
1106
1245
  }
1246
+ /**
1247
+ * Decode one SSE frame of `POST /v1/voice/polish`; null for frames the
1248
+ * client does not act on (pings, unknown events).
1249
+ */
1250
+ declare function parseVoicePolishFrame(frame: {
1251
+ event: string;
1252
+ data: string;
1253
+ }): VoicePolishEvent | null;
1107
1254
 
1108
1255
  /**
1109
1256
  * Minimal adapter contract. Frontends extend this with a `render()`
@@ -1532,7 +1679,8 @@ declare class StreamAbortedError extends AstralformError {
1532
1679
  declare function generateId(): string;
1533
1680
 
1534
1681
  /**
1535
- * GET-based SSE stream for job events.
1682
+ * SSE stream reader. GET for the job event stream (the default); POST with a
1683
+ * JSON body for the voice polish stream. The frame parser is the same.
1536
1684
  */
1537
1685
  declare function streamJobSSE(options: StreamJobSSEOptions): AsyncGenerator<ChatStreamEvent>;
1538
1686
 
@@ -1855,4 +2003,4 @@ declare function isEmbeddedResource(value: unknown): value is {
1855
2003
  */
1856
2004
  declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
1857
2005
 
1858
- 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 BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, 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 MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SkillInfo, 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 ToolPermissionDeniedPayload, ToolRegistry, type ToolResult, type ToolResultRequest, type TurnUsage, type UIComponentsConfig, type UserUnavailablePayload, 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, mapSseToChat, parseEmbeddedResource, replayEvents, streamJobSSE, translateDelta };
2006
+ 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 BlockDeltaPayload, CONVERSATION_PAGE_SIZE, type ChatEvent, ChatEventType, type ChatEventTypeValue, ChatSession, type ChatStorage, type ChatStreamEvent, type ChatStreamRequest, 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 MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type ModelChoiceOptions, type ModelOption, type MyToolGrantsPage, type NoteUpdatePayload, type PlanUpdatePayload, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type ReasoningEffort, type SendOptions, ServerError, type SkillInfo, 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 ToolPermissionDeniedPayload, ToolRegistry, type ToolResult, type ToolResultRequest, 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, isVoiceLLMMode, isVoicePolishMode, mapSseToChat, parseEmbeddedResource, parseVoicePolishFrame, replayEvents, streamJobSSE, translateDelta };
package/dist/index.js CHANGED
@@ -194,12 +194,13 @@ function createRateLimitErrorFromHttp(response, rawText) {
194
194
 
195
195
  // src/streaming.ts
196
196
  async function* streamJobSSE(options) {
197
- const { url, headers, signal, fetchFn } = options;
197
+ const { url, headers, signal, fetchFn, method = "GET", body } = options;
198
198
  let response;
199
199
  try {
200
200
  response = await fetchFn(url, {
201
- method: "GET",
201
+ method,
202
202
  headers,
203
+ body,
203
204
  signal
204
205
  });
205
206
  } catch (err) {
@@ -261,6 +262,57 @@ async function* streamJobSSE(options) {
261
262
  }
262
263
  }
263
264
 
265
+ // src/types.ts
266
+ var ChatEventType = {
267
+ // Connection lifecycle (SDK-local, not wire)
268
+ Connected: "connected",
269
+ Disconnected: "disconnected",
270
+ // Turn lifecycle
271
+ MessageStart: "message_start",
272
+ MessageStop: "message_stop",
273
+ // Block lifecycle
274
+ BlockStart: "block_start",
275
+ BlockDelta: "block_delta",
276
+ BlockStop: "block_stop",
277
+ // Reliability
278
+ Stall: "stall",
279
+ Retry: "retry",
280
+ Error: "error",
281
+ Keepalive: "keepalive",
282
+ // Conversation-level (typed custom events)
283
+ UserMessage: "user_message",
284
+ TitleGenerated: "title_generated",
285
+ TodoUpdate: "todo_update",
286
+ PlanUpdate: "plan_update",
287
+ NoteUpdate: "note_update",
288
+ ContextUpdate: "context_update",
289
+ SubagentStart: "subagent_start",
290
+ SubagentStop: "subagent_stop",
291
+ ContextWarning: "context_warning",
292
+ MemoryRecall: "memory_recall",
293
+ MemoryUpdate: "memory_update",
294
+ DesktopStream: "desktop_stream",
295
+ AttachmentStaged: "attachment_staged",
296
+ WorkspaceReady: "workspace_ready",
297
+ AssetCreated: "asset_created",
298
+ ToolApprovalRequested: "tool_approval_requested",
299
+ ToolApprovalGranted: "tool_approval_granted",
300
+ ToolPermissionDenied: "tool_permission_denied",
301
+ ToolHarnessWarning: "tool_harness_warning",
302
+ UserUnavailable: "user_unavailable",
303
+ PromptSuggestion: "prompt_suggestion",
304
+ StateChanged: "state_changed",
305
+ // Generic fallthrough for unknown custom events
306
+ Custom: "custom"
307
+ };
308
+ var VOICE_POLISH_MODES = ["raw", "light", "structured", "formal"];
309
+ function isVoicePolishMode(value) {
310
+ return typeof value === "string" && VOICE_POLISH_MODES.includes(value);
311
+ }
312
+ function isVoiceLLMMode(mode) {
313
+ return mode !== "raw";
314
+ }
315
+
264
316
  // src/client.ts
265
317
  var DEFAULT_BASE_URL = "https://api.astralform.ai";
266
318
  var DEFAULT_TIMEOUT_MS = 3e4;
@@ -689,6 +741,94 @@ var AstralformClient = class {
689
741
  const raw = await response.json();
690
742
  return this.mapAsset(raw);
691
743
  }
744
+ // --- Voice input ---
745
+ /** The agent's voice-input defaults (`GET /v1/voice/config`). */
746
+ async getVoiceConfig() {
747
+ const raw = await this.get("/v1/voice/config");
748
+ return {
749
+ enabled: Boolean(raw.enabled),
750
+ modes: raw.modes ?? [...VOICE_POLISH_MODES],
751
+ // A mode this SDK does not know must not reach a `switch` typed as
752
+ // `VoicePolishMode`; `structured` is the server's own default.
753
+ defaultMode: isVoicePolishMode(raw.default_mode) ? raw.default_mode : "structured",
754
+ silenceAutoStopSeconds: raw.silence_auto_stop_seconds ?? 2,
755
+ autoSend: raw.auto_send ?? true,
756
+ maxRecordingSeconds: raw.max_recording_seconds ?? 300,
757
+ supportsStreaming: Boolean(raw.supports_streaming),
758
+ hotwords: raw.hotwords ?? []
759
+ };
760
+ }
761
+ /**
762
+ * Transcribe one recording with the agent's configured speech-to-text
763
+ * provider (`POST /v1/voice/transcriptions`). 16 kHz mono 16-bit WAV is the
764
+ * reference format; anything the provider accepts works.
765
+ *
766
+ * Deliberately outside `withDeadline`: a recording can run to
767
+ * `VoiceConfig.maxRecordingSeconds`, so the 30 s default would cut real
768
+ * uploads off. Pass `options.signal` to give up on a stalled one; the
769
+ * promise then rejects with the abort reason — the runtime's `AbortError`,
770
+ * or whatever was passed to `abort(reason)`.
771
+ */
772
+ async transcribeVoice(audio, options = {}) {
773
+ const formData = new FormData();
774
+ formData.append("file", audio, options.filename ?? "recording.wav");
775
+ if (options.hotwords?.length) {
776
+ formData.append("hotwords", options.hotwords.join(", "));
777
+ }
778
+ if (options.language) {
779
+ formData.append("language", options.language);
780
+ }
781
+ const response = await this.fetchFn(`${this.baseURL}/v1/voice/transcriptions`, {
782
+ method: "POST",
783
+ headers: this.authHeaders,
784
+ body: formData,
785
+ signal: options.signal
786
+ }).catch((err) => {
787
+ if (options.signal?.aborted) {
788
+ throw err;
789
+ }
790
+ throw new ConnectionError(
791
+ err instanceof Error ? err.message : "Failed to connect"
792
+ );
793
+ });
794
+ await this.handleError(response);
795
+ const raw = await response.json();
796
+ return {
797
+ text: raw.text ?? "",
798
+ language: raw.language ?? null,
799
+ durationMs: raw.duration_ms ?? null,
800
+ asrMs: raw.asr_ms ?? 0
801
+ };
802
+ }
803
+ /**
804
+ * Stream the LLM rewrite of a transcript (`POST /v1/voice/polish`) as typed
805
+ * frames.
806
+ *
807
+ * Failures the server reports mid-stream arrive as an `error` frame, but
808
+ * the iteration itself can reject: aborting `signal` closes the connection
809
+ * (which cancels the model call upstream) and rejects with
810
+ * `StreamAbortedError`; a non-2xx open rejects with `AuthenticationError`,
811
+ * `RateLimitError` or `ServerError`; a network failure with
812
+ * `ConnectionError`. Wrap the `for await` accordingly.
813
+ */
814
+ async *streamVoicePolish(request, options = {}) {
815
+ const frames = streamJobSSE({
816
+ url: `${this.baseURL}/v1/voice/polish`,
817
+ headers: { ...this.headers, Accept: "text/event-stream" },
818
+ method: "POST",
819
+ body: JSON.stringify({
820
+ text: request.text,
821
+ mode: request.mode,
822
+ hotwords: request.hotwords ?? []
823
+ }),
824
+ signal: options.signal,
825
+ fetchFn: this.fetchFn
826
+ });
827
+ for await (const frame of frames) {
828
+ const event = parseVoicePolishFrame(frame);
829
+ if (event) yield event;
830
+ }
831
+ }
692
832
  async listUploads(conversationId) {
693
833
  const raw = await this.get(
694
834
  `/v1/conversations/${encodeURIComponent(conversationId)}/uploads`
@@ -775,6 +915,35 @@ var AstralformClient = class {
775
915
  }));
776
916
  }
777
917
  };
918
+ function parseVoicePolishFrame(frame) {
919
+ let payload;
920
+ try {
921
+ const parsed = JSON.parse(frame.data);
922
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
923
+ payload = parsed;
924
+ } catch {
925
+ return null;
926
+ }
927
+ switch (frame.event) {
928
+ case "delta":
929
+ return typeof payload.text === "string" ? { type: "delta", text: payload.text } : null;
930
+ case "done":
931
+ return typeof payload.text === "string" ? {
932
+ type: "done",
933
+ text: payload.text,
934
+ polishMs: payload.polish_ms ?? 0
935
+ } : null;
936
+ case "error":
937
+ return {
938
+ type: "error",
939
+ reason: payload.reason ?? "unknown",
940
+ partial: payload.partial ?? "",
941
+ ...typeof payload.detail === "string" ? { detail: payload.detail } : {}
942
+ };
943
+ default:
944
+ return null;
945
+ }
946
+ }
778
947
 
779
948
  // src/storage.ts
780
949
  var InMemoryStorage = class {
@@ -2259,50 +2428,6 @@ function planRestore(args) {
2259
2428
  return steps;
2260
2429
  }
2261
2430
 
2262
- // src/types.ts
2263
- var ChatEventType = {
2264
- // Connection lifecycle (SDK-local, not wire)
2265
- Connected: "connected",
2266
- Disconnected: "disconnected",
2267
- // Turn lifecycle
2268
- MessageStart: "message_start",
2269
- MessageStop: "message_stop",
2270
- // Block lifecycle
2271
- BlockStart: "block_start",
2272
- BlockDelta: "block_delta",
2273
- BlockStop: "block_stop",
2274
- // Reliability
2275
- Stall: "stall",
2276
- Retry: "retry",
2277
- Error: "error",
2278
- Keepalive: "keepalive",
2279
- // Conversation-level (typed custom events)
2280
- UserMessage: "user_message",
2281
- TitleGenerated: "title_generated",
2282
- TodoUpdate: "todo_update",
2283
- PlanUpdate: "plan_update",
2284
- NoteUpdate: "note_update",
2285
- ContextUpdate: "context_update",
2286
- SubagentStart: "subagent_start",
2287
- SubagentStop: "subagent_stop",
2288
- ContextWarning: "context_warning",
2289
- MemoryRecall: "memory_recall",
2290
- MemoryUpdate: "memory_update",
2291
- DesktopStream: "desktop_stream",
2292
- AttachmentStaged: "attachment_staged",
2293
- WorkspaceReady: "workspace_ready",
2294
- AssetCreated: "asset_created",
2295
- ToolApprovalRequested: "tool_approval_requested",
2296
- ToolApprovalGranted: "tool_approval_granted",
2297
- ToolPermissionDenied: "tool_permission_denied",
2298
- ToolHarnessWarning: "tool_harness_warning",
2299
- UserUnavailable: "user_unavailable",
2300
- PromptSuggestion: "prompt_suggestion",
2301
- StateChanged: "state_changed",
2302
- // Generic fallthrough for unknown custom events
2303
- Custom: "custom"
2304
- };
2305
-
2306
2431
  // src/stream-manager.ts
2307
2432
  var StreamManager = class {
2308
2433
  constructor(session) {
@@ -2956,10 +3081,14 @@ export {
2956
3081
  StreamAbortedError,
2957
3082
  StreamManager,
2958
3083
  ToolRegistry,
3084
+ VOICE_POLISH_MODES,
2959
3085
  generateId,
2960
3086
  isEmbeddedResource,
3087
+ isVoiceLLMMode,
3088
+ isVoicePolishMode,
2961
3089
  mapSseToChat,
2962
3090
  parseEmbeddedResource,
3091
+ parseVoicePolishFrame,
2963
3092
  replayEvents,
2964
3093
  streamJobSSE,
2965
3094
  translateDelta