@astralform/js 7.2.0 → 7.4.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
@@ -563,6 +563,12 @@ interface Conversation {
563
563
  messageCount: number;
564
564
  createdAt: string;
565
565
  updatedAt: string;
566
+ /**
567
+ * The project this task belongs to (`owner/repo`), or `null` for an ordinary
568
+ * conversation. Set on the first turn and immutable after. Absent (rather than
569
+ * null) from an Astralform older than 0.70.0.
570
+ */
571
+ repository?: string | null;
566
572
  }
567
573
  interface Message {
568
574
  id: string;
@@ -612,6 +618,18 @@ interface AgentInfo {
612
618
  isOrchestrator: boolean;
613
619
  isEnabled: boolean;
614
620
  avatarUrl?: string;
621
+ /**
622
+ * What the agent is for. A client shows Projects and Tasks only for `"code"`.
623
+ * Absent on Astralform older than 0.70.0 — treat that as `"chat"`, which is
624
+ * also the server's default.
625
+ *
626
+ * It is a property of the WORKSPACE, not of a persona: `GET /v1/agents` selects
627
+ * the workspace row itself and returns exactly one entry, so the mode is
628
+ * `agents[0].mode` rather than something that varies across the list. The
629
+ * workspace picker (`listAgents`) does not carry it, so a client learns an
630
+ * agent's mode after opening it.
631
+ */
632
+ mode?: "chat" | "code";
615
633
  }
616
634
  interface TeamSummary {
617
635
  id: string;
@@ -738,6 +756,15 @@ interface ModelChoiceOptions {
738
756
  interface ChatStreamRequest {
739
757
  message?: string;
740
758
  conversation_id?: string;
759
+ /**
760
+ * Which project (GitHub repository, `owner/repo`) this task belongs to.
761
+ *
762
+ * Required on the FIRST turn of a conversation on a code-mode agent and
763
+ * ignored afterwards — a task is bound to one repository for life, so a
764
+ * different repository means a new task. Chat-mode agents ignore it entirely.
765
+ * Astralform >= 0.70.0.
766
+ */
767
+ repository?: string;
741
768
  mcp_manifest?: ToolDefinition[];
742
769
  enabled_mcp?: string[];
743
770
  continue_from_message?: string;
@@ -762,6 +789,37 @@ interface ChatStreamRequest {
762
789
  reasoning_effort?: ReasoningEffort;
763
790
  temperature?: number;
764
791
  }
792
+ /** One repository an app user works with on a code-mode agent. */
793
+ interface CodeProject {
794
+ repoFullName: string;
795
+ addedAt: string;
796
+ }
797
+ /** A repository the workspace's GitHub installations cover. */
798
+ interface AvailableRepository {
799
+ fullName: string;
800
+ private: boolean;
801
+ }
802
+ /**
803
+ * What an app user may add, and why the list might be empty.
804
+ *
805
+ * `state` separates the three empty cases a picker must not conflate:
806
+ * `ok` (connected, covers nothing new), `not_installed` (no installation to ask)
807
+ * and `unavailable` (GitHub could not be reached — try again, do not tell the
808
+ * user they have no repositories). `totalCount` is the installations' raw total
809
+ * BEFORE already-added projects are subtracted, so it is not the list's length.
810
+ */
811
+ interface AvailableRepositories {
812
+ state: "ok" | "unavailable" | "not_installed";
813
+ repositories: AvailableRepository[];
814
+ totalCount: number;
815
+ /**
816
+ * At least one of the workspace's GitHub installations could not be
817
+ * enumerated, so the list is missing whatever that one covers. It is NOT
818
+ * pagination — there is no next page to ask for. A picker should say some
819
+ * repositories may be missing rather than present the list as complete.
820
+ */
821
+ partial: boolean;
822
+ }
765
823
  interface ToolResultRequest {
766
824
  conversation_id: string;
767
825
  message_id: string;
@@ -822,7 +880,118 @@ interface StreamJobSSEOptions {
822
880
  headers: Record<string, string>;
823
881
  signal?: AbortSignal;
824
882
  fetchFn: typeof globalThis.fetch;
883
+ /** Request method; defaults to GET (the job event stream). */
884
+ method?: "GET" | "POST";
885
+ /** A JSON-serialised body for POST streams (the voice polish stream). */
886
+ body?: string;
825
887
  }
888
+ /**
889
+ * The styles a transcript can be shaped into, as the server names them.
890
+ * `raw` never calls the model — the transcript is used as recognized.
891
+ */
892
+ declare const VOICE_POLISH_MODES: readonly ["raw", "light", "structured", "formal"];
893
+ type VoicePolishMode = (typeof VOICE_POLISH_MODES)[number];
894
+ /** A mode that calls the polish model — every mode except `raw`. */
895
+ type VoiceLLMMode = Exclude<VoicePolishMode, "raw">;
896
+ /** Whether `value` is one of the four modes this SDK version knows. */
897
+ declare function isVoicePolishMode(value: unknown): value is VoicePolishMode;
898
+ /**
899
+ * Whether `mode` may be passed to `streamVoicePolish` — the check to make on
900
+ * `VoiceConfig.defaultMode`, which can be `raw`.
901
+ */
902
+ declare function isVoiceLLMMode(mode: VoicePolishMode): mode is VoiceLLMMode;
903
+ /**
904
+ * What a client needs to run the microphone for an agent, from
905
+ * `GET /v1/voice/config`. Deliberately carries no provider or model names.
906
+ */
907
+ interface VoiceConfig {
908
+ enabled: boolean;
909
+ /**
910
+ * The styles the client may request, as the server names them. Kept as
911
+ * plain strings so a mode this SDK version does not know still reaches a
912
+ * picker; `isVoicePolishMode` narrows one.
913
+ */
914
+ modes: string[];
915
+ /**
916
+ * The style to use when the user has not picked one. Falls back to
917
+ * `structured` when the server names a mode this SDK does not know. Can be
918
+ * `raw`, which `streamVoicePolish` refuses — check it with `isVoiceLLMMode`
919
+ * (or compare against `"raw"`) before polishing.
920
+ */
921
+ defaultMode: VoicePolishMode;
922
+ /** In tap-to-talk mode, the pause that ends a recording. */
923
+ silenceAutoStopSeconds: number;
924
+ /** Send the message as soon as the result is ready. */
925
+ autoSend: boolean;
926
+ maxRecordingSeconds: number;
927
+ /**
928
+ * Whether the configured recognizer emits live partial transcripts. Batch
929
+ * (Whisper-style) providers do not; they transcribe on stop.
930
+ */
931
+ supportsStreaming: boolean;
932
+ /**
933
+ * The project vocabulary, for display. The server applies it to every
934
+ * transcription and polish itself; `transcribeVoice({ hotwords })` and
935
+ * `VoicePolishRequest.hotwords` carry only the user's own words, which the
936
+ * server merges after these.
937
+ */
938
+ hotwords: string[];
939
+ }
940
+ /** One recording turned into text, from `POST /v1/voice/transcriptions`. */
941
+ interface VoiceTranscript {
942
+ text: string;
943
+ language: string | null;
944
+ /** Length of the submitted audio, when the WAV header said so. */
945
+ durationMs: number | null;
946
+ /** Time the provider took. */
947
+ asrMs: number;
948
+ }
949
+ interface VoiceTranscribeOptions {
950
+ /** File name sent with the recording; defaults to `recording.wav`. */
951
+ filename?: string;
952
+ /**
953
+ * The user's own vocabulary — not the project's, which the server already
954
+ * holds and merges in first. Sent comma-separated, so a word cannot itself
955
+ * contain a comma.
956
+ */
957
+ hotwords?: string[];
958
+ /** ISO 639-1 hint; omit for auto-detection. */
959
+ language?: string;
960
+ /**
961
+ * Abort the upload. No client-side deadline applies to this call (a
962
+ * recording can run to `maxRecordingSeconds` and the upload with it), so
963
+ * this is the only way to give up on a stalled one; the promise rejects
964
+ * with the abort reason (the runtime's `AbortError`, or what was passed to
965
+ * `abort(reason)`).
966
+ */
967
+ signal?: AbortSignal;
968
+ }
969
+ interface VoicePolishRequest {
970
+ text: string;
971
+ /** One of the LLM modes; `raw` is refused by the server. */
972
+ mode: VoiceLLMMode;
973
+ /** The user's own vocabulary; the server merges it after the project's. */
974
+ hotwords?: string[];
975
+ }
976
+ /**
977
+ * One frame of the polish stream. `delta` text arrives in order; `done.text`
978
+ * is authoritative (the cleaned full output, which can differ from the
979
+ * concatenated deltas). On `error` keep the raw transcript; `partial` is what
980
+ * was streamed before the failure.
981
+ */
982
+ type VoicePolishEvent = {
983
+ type: "delta";
984
+ text: string;
985
+ } | {
986
+ type: "done";
987
+ text: string;
988
+ polishMs: number;
989
+ } | {
990
+ type: "error";
991
+ reason: string;
992
+ partial: string;
993
+ detail?: string;
994
+ };
826
995
  interface ChatStreamEvent {
827
996
  event: string;
828
997
  data: string;
@@ -892,6 +1061,15 @@ interface SendOptions$1 extends ModelChoiceOptions {
892
1061
  * it's complete. Omit for a normal turn.
893
1062
  */
894
1063
  goal?: string;
1064
+ /**
1065
+ * The project this task belongs to (`owner/repo`), on a code-mode agent.
1066
+ *
1067
+ * Send it on the turn that STARTS a task; the binding is write-once, so later
1068
+ * turns can omit it (sending a different one is refused). A first turn without
1069
+ * it on a code-mode agent is refused too — the run needs a repository before it
1070
+ * can hold a credential scoped to one. Astralform >= 0.70.0.
1071
+ */
1072
+ repository?: string;
895
1073
  }
896
1074
  /**
897
1075
  * A selectable model for one of the team's connected providers, from
@@ -1039,7 +1217,16 @@ declare class AstralformClient {
1039
1217
  ollama_connected: boolean;
1040
1218
  }>;
1041
1219
  getAgentStatus(): Promise<AgentStatus>;
1042
- getConversations(limit?: number, offset?: number): Promise<Conversation[]>;
1220
+ /**
1221
+ * A page of conversations, newest-updated first.
1222
+ *
1223
+ * `options.repository` narrows to one project's tasks (`owner/repo`) on a
1224
+ * code-mode agent — the same paging applies within the filter, so a client
1225
+ * showing tasks per project pages each project separately.
1226
+ */
1227
+ getConversations(limit?: number, offset?: number, options?: {
1228
+ repository?: string;
1229
+ }): Promise<Conversation[]>;
1043
1230
  getMessages(conversationId: string): Promise<Message[]>;
1044
1231
  /**
1045
1232
  * Replace the title the server generated from the conversation's first turn.
@@ -1087,6 +1274,34 @@ declare class AstralformClient {
1087
1274
  revokeToolPermission(id: string): Promise<void>;
1088
1275
  private mapAsset;
1089
1276
  uploadFile(conversationId: string, file: Blob, filename?: string): Promise<ConversationAsset>;
1277
+ /** The agent's voice-input defaults (`GET /v1/voice/config`). */
1278
+ getVoiceConfig(): Promise<VoiceConfig>;
1279
+ /**
1280
+ * Transcribe one recording with the agent's configured speech-to-text
1281
+ * provider (`POST /v1/voice/transcriptions`). 16 kHz mono 16-bit WAV is the
1282
+ * reference format; anything the provider accepts works.
1283
+ *
1284
+ * Deliberately outside `withDeadline`: a recording can run to
1285
+ * `VoiceConfig.maxRecordingSeconds`, so the 30 s default would cut real
1286
+ * uploads off. Pass `options.signal` to give up on a stalled one; the
1287
+ * promise then rejects with the abort reason — the runtime's `AbortError`,
1288
+ * or whatever was passed to `abort(reason)`.
1289
+ */
1290
+ transcribeVoice(audio: Blob, options?: VoiceTranscribeOptions): Promise<VoiceTranscript>;
1291
+ /**
1292
+ * Stream the LLM rewrite of a transcript (`POST /v1/voice/polish`) as typed
1293
+ * frames.
1294
+ *
1295
+ * Failures the server reports mid-stream arrive as an `error` frame, but
1296
+ * the iteration itself can reject: aborting `signal` closes the connection
1297
+ * (which cancels the model call upstream) and rejects with
1298
+ * `StreamAbortedError`; a non-2xx open rejects with `AuthenticationError`,
1299
+ * `RateLimitError` or `ServerError`; a network failure with
1300
+ * `ConnectionError`. Wrap the `for await` accordingly.
1301
+ */
1302
+ streamVoicePolish(request: VoicePolishRequest, options?: {
1303
+ signal?: AbortSignal;
1304
+ }): AsyncGenerator<VoicePolishEvent>;
1090
1305
  listUploads(conversationId: string): Promise<ConversationAsset[]>;
1091
1306
  listOutputs(conversationId: string): Promise<ConversationAsset[]>;
1092
1307
  listTeams(): Promise<TeamSummary[]>;
@@ -1096,6 +1311,39 @@ declare class AstralformClient {
1096
1311
  * `getAgents()`, which lists the AI personas inside the active agent.
1097
1312
  */
1098
1313
  listAgents(teamId: string): Promise<TeamAgentSummary[]>;
1314
+ /**
1315
+ * The projects (GitHub repositories) this app user works with, and what they
1316
+ * may add.
1317
+ *
1318
+ * A project list is per app user within a code-mode agent: the developer
1319
+ * connects the workspace's GitHub account, and each user curates their own
1320
+ * list from what that connection covers. Every method 404s on a chat-mode
1321
+ * agent, so the surface is invisible rather than empty there.
1322
+ */
1323
+ readonly code: {
1324
+ projects: {
1325
+ /** This user's projects on the active agent, oldest first. */
1326
+ list: () => Promise<CodeProject[]>;
1327
+ /**
1328
+ * What the workspace's GitHub installations cover, minus what this user
1329
+ * has already added. Read `state` before the list: an empty `repositories`
1330
+ * means something different in each of its three values.
1331
+ */
1332
+ available: () => Promise<AvailableRepositories>;
1333
+ /**
1334
+ * Add a repository. The server checks it against the workspace's own
1335
+ * installations and answers a repository it cannot reach the same way it
1336
+ * answers one owned by someone else — deliberately, so this call cannot be
1337
+ * used to discover which organisations use Astralform.
1338
+ */
1339
+ add: (repoFullName: string) => Promise<CodeProject>;
1340
+ /**
1341
+ * Remove a project. Tasks already bound to that repository keep their
1342
+ * binding — they simply stop grouping under it.
1343
+ */
1344
+ remove: (owner: string, repo: string) => Promise<void>;
1345
+ };
1346
+ };
1099
1347
  createJob(request: ChatStreamRequest): Promise<JobCreateResponse>;
1100
1348
  streamJobEvents(jobId: string, afterSeq?: number, signal?: AbortSignal): AsyncGenerator<ChatStreamEvent>;
1101
1349
  cancelJob(jobId: string): Promise<void>;
@@ -1104,6 +1352,14 @@ declare class AstralformClient {
1104
1352
  getActiveJob(conversationId: string): Promise<ActiveJob>;
1105
1353
  listJobs(conversationId: string): Promise<JobSummary[]>;
1106
1354
  }
1355
+ /**
1356
+ * Decode one SSE frame of `POST /v1/voice/polish`; null for frames the
1357
+ * client does not act on (pings, unknown events).
1358
+ */
1359
+ declare function parseVoicePolishFrame(frame: {
1360
+ event: string;
1361
+ data: string;
1362
+ }): VoicePolishEvent | null;
1107
1363
 
1108
1364
  /**
1109
1365
  * Minimal adapter contract. Frontends extend this with a `render()`
@@ -1532,7 +1788,8 @@ declare class StreamAbortedError extends AstralformError {
1532
1788
  declare function generateId(): string;
1533
1789
 
1534
1790
  /**
1535
- * GET-based SSE stream for job events.
1791
+ * SSE stream reader. GET for the job event stream (the default); POST with a
1792
+ * JSON body for the voice polish stream. The frame parser is the same.
1536
1793
  */
1537
1794
  declare function streamJobSSE(options: StreamJobSSEOptions): AsyncGenerator<ChatStreamEvent>;
1538
1795
 
@@ -1855,4 +2112,4 @@ declare function isEmbeddedResource(value: unknown): value is {
1855
2112
  */
1856
2113
  declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
1857
2114
 
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 };
2115
+ 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 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 };