@astralform/js 1.2.0 → 2.0.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/README.md +6 -6
- package/dist/index.cjs +43 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -21
- package/dist/index.d.ts +37 -21
- package/dist/index.js +43 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -122,7 +122,7 @@ interface AstralformBaseConfig {
|
|
|
122
122
|
fetch?: typeof globalThis.fetch;
|
|
123
123
|
}
|
|
124
124
|
interface AstralformApiKeyConfig extends AstralformBaseConfig {
|
|
125
|
-
/**
|
|
125
|
+
/** Agent API key (`sk_live_...` or `sk_test_...`). */
|
|
126
126
|
apiKey: string;
|
|
127
127
|
/**
|
|
128
128
|
* The customer's own identifier for the end user making this call.
|
|
@@ -138,16 +138,16 @@ interface AstralformUserTokenConfig extends AstralformBaseConfig {
|
|
|
138
138
|
*/
|
|
139
139
|
accessToken: string;
|
|
140
140
|
/**
|
|
141
|
-
* Active
|
|
142
|
-
* verifies the token's developer has access to this
|
|
143
|
-
* request; switching
|
|
141
|
+
* Active agent context. Sent as the `X-Project-ID` header (legacy wire name). The backend
|
|
142
|
+
* verifies the token's developer has access to this agent on every
|
|
143
|
+
* request; switching agents is a local `updateAgentId()` call.
|
|
144
144
|
*
|
|
145
145
|
* Optional so a pre-pick client (right after login, before the user has
|
|
146
|
-
* chosen a team/
|
|
147
|
-
* like `listTeams()` / `
|
|
146
|
+
* chosen a team/agent) can still call account-scoped discovery routes
|
|
147
|
+
* like `listTeams()` / `listAgents(teamId)`. Agent-scoped calls
|
|
148
148
|
* (conversations, messages, chat) will error out until one is set.
|
|
149
149
|
*/
|
|
150
|
-
|
|
150
|
+
agentId?: string;
|
|
151
151
|
/**
|
|
152
152
|
* Optional end-user override — lets a developer acting under a user
|
|
153
153
|
* token impersonate a downstream end-user identity for testing
|
|
@@ -533,7 +533,7 @@ interface UIComponentsConfig {
|
|
|
533
533
|
/** MIME type to match against embedded resources (e.g. "application/json+a2ui"). */
|
|
534
534
|
mimeType: string | null;
|
|
535
535
|
}
|
|
536
|
-
interface
|
|
536
|
+
interface AgentStatus {
|
|
537
537
|
isReady: boolean;
|
|
538
538
|
llmConfigured: boolean;
|
|
539
539
|
llmProvider?: string;
|
|
@@ -557,7 +557,12 @@ interface TeamSummary {
|
|
|
557
557
|
/** Caller's role in this team (e.g. "owner", "admin", "member"). */
|
|
558
558
|
role: string;
|
|
559
559
|
}
|
|
560
|
-
|
|
560
|
+
/**
|
|
561
|
+
* A team-level agent (formerly "project") — the workspace a user opens to
|
|
562
|
+
* chat. Distinct from `AgentInfo`, which describes the AI personas available
|
|
563
|
+
* INSIDE an agent workspace (orchestrator + specialists).
|
|
564
|
+
*/
|
|
565
|
+
interface TeamAgentSummary {
|
|
561
566
|
id: string;
|
|
562
567
|
name: string;
|
|
563
568
|
teamId: string;
|
|
@@ -717,7 +722,7 @@ declare class AstralformClient {
|
|
|
717
722
|
private readonly fetchFn;
|
|
718
723
|
/**
|
|
719
724
|
* Auth state is mutable so callers can rotate access tokens or switch
|
|
720
|
-
*
|
|
725
|
+
* agent context without re-instantiating the client. API-key mode is
|
|
721
726
|
* effectively immutable in practice but uses the same shape for uniformity.
|
|
722
727
|
*/
|
|
723
728
|
private auth;
|
|
@@ -729,10 +734,10 @@ declare class AstralformClient {
|
|
|
729
734
|
*/
|
|
730
735
|
updateAccessToken(accessToken: string): void;
|
|
731
736
|
/**
|
|
732
|
-
* Swap the active
|
|
733
|
-
* current developer has access to the new
|
|
737
|
+
* Swap the active agent for a user-token client. The backend verifies the
|
|
738
|
+
* current developer has access to the new agent; a 403 comes back if not.
|
|
734
739
|
*/
|
|
735
|
-
|
|
740
|
+
updateAgentId(agentId: string): void;
|
|
736
741
|
/**
|
|
737
742
|
* Set (or clear) the end-user override for user-token mode.
|
|
738
743
|
*
|
|
@@ -745,12 +750,12 @@ declare class AstralformClient {
|
|
|
745
750
|
/** Current end-user override in user-token mode, or `null` if unset. */
|
|
746
751
|
get endUserId(): string | null;
|
|
747
752
|
/**
|
|
748
|
-
* Active
|
|
749
|
-
* was constructed without one). For API-key mode the
|
|
753
|
+
* Active agent for user-token mode, or `null` if pre-pick (client
|
|
754
|
+
* was constructed without one). For API-key mode the agent is baked
|
|
750
755
|
* into the key, so this getter returns `null` there too — use
|
|
751
756
|
* `authMode` to disambiguate.
|
|
752
757
|
*/
|
|
753
|
-
get
|
|
758
|
+
get agentId(): string | null;
|
|
754
759
|
/** Which auth mode this client was constructed with. */
|
|
755
760
|
get authMode(): "api_key" | "user_token";
|
|
756
761
|
/**
|
|
@@ -771,10 +776,16 @@ declare class AstralformClient {
|
|
|
771
776
|
version: string;
|
|
772
777
|
ollama_connected: boolean;
|
|
773
778
|
}>;
|
|
774
|
-
|
|
779
|
+
getAgentStatus(): Promise<AgentStatus>;
|
|
775
780
|
getConversations(limit?: number, offset?: number): Promise<Conversation[]>;
|
|
776
781
|
getMessages(conversationId: string): Promise<Message[]>;
|
|
777
782
|
deleteConversation(id: string): Promise<void>;
|
|
783
|
+
/**
|
|
784
|
+
* List the AI personas (sub-agents) available INSIDE the client's active
|
|
785
|
+
* agent workspace — orchestrator + specialists, addressed per message via
|
|
786
|
+
* `ChatStreamRequest.agent_name`. Not to be confused with `listAgents()`,
|
|
787
|
+
* which enumerates the team-level agents a signed-in user can open.
|
|
788
|
+
*/
|
|
778
789
|
getAgents(): Promise<AgentInfo[]>;
|
|
779
790
|
getSkills(): Promise<SkillInfo[]>;
|
|
780
791
|
getConversationEvents(conversationId: string, jobId?: string): Promise<ConversationEvent[]>;
|
|
@@ -800,7 +811,12 @@ declare class AstralformClient {
|
|
|
800
811
|
listUploads(conversationId: string): Promise<ConversationAsset[]>;
|
|
801
812
|
listOutputs(conversationId: string): Promise<ConversationAsset[]>;
|
|
802
813
|
listTeams(): Promise<TeamSummary[]>;
|
|
803
|
-
|
|
814
|
+
/**
|
|
815
|
+
* List the team-level agents (formerly "projects") the signed-in user can
|
|
816
|
+
* open — the pickable workspaces under a team. Not to be confused with
|
|
817
|
+
* `getAgents()`, which lists the AI personas inside the active agent.
|
|
818
|
+
*/
|
|
819
|
+
listAgents(teamId: string): Promise<TeamAgentSummary[]>;
|
|
804
820
|
createJob(request: ChatStreamRequest): Promise<JobCreateResponse>;
|
|
805
821
|
streamJobEvents(jobId: string, afterSeq?: number, signal?: AbortSignal): AsyncGenerator<ChatStreamEvent>;
|
|
806
822
|
cancelJob(jobId: string): Promise<void>;
|
|
@@ -887,7 +903,7 @@ declare class ChatSession {
|
|
|
887
903
|
/**
|
|
888
904
|
* Pluggable UI protocol adapters. Consumers register a framework-
|
|
889
905
|
* specific adapter (e.g. React) for each MIME type they can render,
|
|
890
|
-
* typically gated on ``session.
|
|
906
|
+
* typically gated on ``session.agentStatus.uiComponents.protocol``.
|
|
891
907
|
* ``ToolBlock``-style consumers look up the adapter for an incoming
|
|
892
908
|
* embedded resource and hand off rendering.
|
|
893
909
|
*/
|
|
@@ -896,7 +912,7 @@ declare class ChatSession {
|
|
|
896
912
|
conversations: Conversation[];
|
|
897
913
|
messages: Message[];
|
|
898
914
|
isStreaming: boolean;
|
|
899
|
-
|
|
915
|
+
agentStatus: AgentStatus | null;
|
|
900
916
|
agents: AgentInfo[];
|
|
901
917
|
skills: SkillInfo[];
|
|
902
918
|
enabledClientTools: Set<string>;
|
|
@@ -1175,4 +1191,4 @@ declare function isEmbeddedResource(value: unknown): value is {
|
|
|
1175
1191
|
*/
|
|
1176
1192
|
declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
|
|
1177
1193
|
|
|
1178
|
-
export { type ActiveJob, type AgentIdentity, type AgentInfo, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type BlockDeltaPayload, 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 EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, LLMNotConfiguredError, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type MyToolGrantsPage, type
|
|
1194
|
+
export { type ActiveJob, type AgentIdentity, type AgentInfo, type AgentStatus, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type BlockDeltaPayload, 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 EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, LLMNotConfiguredError, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type MyToolGrantsPage, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type SendOptions, ServerError, type SkillInfo, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentStartPayload, type SubagentStopPayload, type TaskStatus, type TeamAgentSummary, type TeamSummary, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -122,7 +122,7 @@ interface AstralformBaseConfig {
|
|
|
122
122
|
fetch?: typeof globalThis.fetch;
|
|
123
123
|
}
|
|
124
124
|
interface AstralformApiKeyConfig extends AstralformBaseConfig {
|
|
125
|
-
/**
|
|
125
|
+
/** Agent API key (`sk_live_...` or `sk_test_...`). */
|
|
126
126
|
apiKey: string;
|
|
127
127
|
/**
|
|
128
128
|
* The customer's own identifier for the end user making this call.
|
|
@@ -138,16 +138,16 @@ interface AstralformUserTokenConfig extends AstralformBaseConfig {
|
|
|
138
138
|
*/
|
|
139
139
|
accessToken: string;
|
|
140
140
|
/**
|
|
141
|
-
* Active
|
|
142
|
-
* verifies the token's developer has access to this
|
|
143
|
-
* request; switching
|
|
141
|
+
* Active agent context. Sent as the `X-Project-ID` header (legacy wire name). The backend
|
|
142
|
+
* verifies the token's developer has access to this agent on every
|
|
143
|
+
* request; switching agents is a local `updateAgentId()` call.
|
|
144
144
|
*
|
|
145
145
|
* Optional so a pre-pick client (right after login, before the user has
|
|
146
|
-
* chosen a team/
|
|
147
|
-
* like `listTeams()` / `
|
|
146
|
+
* chosen a team/agent) can still call account-scoped discovery routes
|
|
147
|
+
* like `listTeams()` / `listAgents(teamId)`. Agent-scoped calls
|
|
148
148
|
* (conversations, messages, chat) will error out until one is set.
|
|
149
149
|
*/
|
|
150
|
-
|
|
150
|
+
agentId?: string;
|
|
151
151
|
/**
|
|
152
152
|
* Optional end-user override — lets a developer acting under a user
|
|
153
153
|
* token impersonate a downstream end-user identity for testing
|
|
@@ -533,7 +533,7 @@ interface UIComponentsConfig {
|
|
|
533
533
|
/** MIME type to match against embedded resources (e.g. "application/json+a2ui"). */
|
|
534
534
|
mimeType: string | null;
|
|
535
535
|
}
|
|
536
|
-
interface
|
|
536
|
+
interface AgentStatus {
|
|
537
537
|
isReady: boolean;
|
|
538
538
|
llmConfigured: boolean;
|
|
539
539
|
llmProvider?: string;
|
|
@@ -557,7 +557,12 @@ interface TeamSummary {
|
|
|
557
557
|
/** Caller's role in this team (e.g. "owner", "admin", "member"). */
|
|
558
558
|
role: string;
|
|
559
559
|
}
|
|
560
|
-
|
|
560
|
+
/**
|
|
561
|
+
* A team-level agent (formerly "project") — the workspace a user opens to
|
|
562
|
+
* chat. Distinct from `AgentInfo`, which describes the AI personas available
|
|
563
|
+
* INSIDE an agent workspace (orchestrator + specialists).
|
|
564
|
+
*/
|
|
565
|
+
interface TeamAgentSummary {
|
|
561
566
|
id: string;
|
|
562
567
|
name: string;
|
|
563
568
|
teamId: string;
|
|
@@ -717,7 +722,7 @@ declare class AstralformClient {
|
|
|
717
722
|
private readonly fetchFn;
|
|
718
723
|
/**
|
|
719
724
|
* Auth state is mutable so callers can rotate access tokens or switch
|
|
720
|
-
*
|
|
725
|
+
* agent context without re-instantiating the client. API-key mode is
|
|
721
726
|
* effectively immutable in practice but uses the same shape for uniformity.
|
|
722
727
|
*/
|
|
723
728
|
private auth;
|
|
@@ -729,10 +734,10 @@ declare class AstralformClient {
|
|
|
729
734
|
*/
|
|
730
735
|
updateAccessToken(accessToken: string): void;
|
|
731
736
|
/**
|
|
732
|
-
* Swap the active
|
|
733
|
-
* current developer has access to the new
|
|
737
|
+
* Swap the active agent for a user-token client. The backend verifies the
|
|
738
|
+
* current developer has access to the new agent; a 403 comes back if not.
|
|
734
739
|
*/
|
|
735
|
-
|
|
740
|
+
updateAgentId(agentId: string): void;
|
|
736
741
|
/**
|
|
737
742
|
* Set (or clear) the end-user override for user-token mode.
|
|
738
743
|
*
|
|
@@ -745,12 +750,12 @@ declare class AstralformClient {
|
|
|
745
750
|
/** Current end-user override in user-token mode, or `null` if unset. */
|
|
746
751
|
get endUserId(): string | null;
|
|
747
752
|
/**
|
|
748
|
-
* Active
|
|
749
|
-
* was constructed without one). For API-key mode the
|
|
753
|
+
* Active agent for user-token mode, or `null` if pre-pick (client
|
|
754
|
+
* was constructed without one). For API-key mode the agent is baked
|
|
750
755
|
* into the key, so this getter returns `null` there too — use
|
|
751
756
|
* `authMode` to disambiguate.
|
|
752
757
|
*/
|
|
753
|
-
get
|
|
758
|
+
get agentId(): string | null;
|
|
754
759
|
/** Which auth mode this client was constructed with. */
|
|
755
760
|
get authMode(): "api_key" | "user_token";
|
|
756
761
|
/**
|
|
@@ -771,10 +776,16 @@ declare class AstralformClient {
|
|
|
771
776
|
version: string;
|
|
772
777
|
ollama_connected: boolean;
|
|
773
778
|
}>;
|
|
774
|
-
|
|
779
|
+
getAgentStatus(): Promise<AgentStatus>;
|
|
775
780
|
getConversations(limit?: number, offset?: number): Promise<Conversation[]>;
|
|
776
781
|
getMessages(conversationId: string): Promise<Message[]>;
|
|
777
782
|
deleteConversation(id: string): Promise<void>;
|
|
783
|
+
/**
|
|
784
|
+
* List the AI personas (sub-agents) available INSIDE the client's active
|
|
785
|
+
* agent workspace — orchestrator + specialists, addressed per message via
|
|
786
|
+
* `ChatStreamRequest.agent_name`. Not to be confused with `listAgents()`,
|
|
787
|
+
* which enumerates the team-level agents a signed-in user can open.
|
|
788
|
+
*/
|
|
778
789
|
getAgents(): Promise<AgentInfo[]>;
|
|
779
790
|
getSkills(): Promise<SkillInfo[]>;
|
|
780
791
|
getConversationEvents(conversationId: string, jobId?: string): Promise<ConversationEvent[]>;
|
|
@@ -800,7 +811,12 @@ declare class AstralformClient {
|
|
|
800
811
|
listUploads(conversationId: string): Promise<ConversationAsset[]>;
|
|
801
812
|
listOutputs(conversationId: string): Promise<ConversationAsset[]>;
|
|
802
813
|
listTeams(): Promise<TeamSummary[]>;
|
|
803
|
-
|
|
814
|
+
/**
|
|
815
|
+
* List the team-level agents (formerly "projects") the signed-in user can
|
|
816
|
+
* open — the pickable workspaces under a team. Not to be confused with
|
|
817
|
+
* `getAgents()`, which lists the AI personas inside the active agent.
|
|
818
|
+
*/
|
|
819
|
+
listAgents(teamId: string): Promise<TeamAgentSummary[]>;
|
|
804
820
|
createJob(request: ChatStreamRequest): Promise<JobCreateResponse>;
|
|
805
821
|
streamJobEvents(jobId: string, afterSeq?: number, signal?: AbortSignal): AsyncGenerator<ChatStreamEvent>;
|
|
806
822
|
cancelJob(jobId: string): Promise<void>;
|
|
@@ -887,7 +903,7 @@ declare class ChatSession {
|
|
|
887
903
|
/**
|
|
888
904
|
* Pluggable UI protocol adapters. Consumers register a framework-
|
|
889
905
|
* specific adapter (e.g. React) for each MIME type they can render,
|
|
890
|
-
* typically gated on ``session.
|
|
906
|
+
* typically gated on ``session.agentStatus.uiComponents.protocol``.
|
|
891
907
|
* ``ToolBlock``-style consumers look up the adapter for an incoming
|
|
892
908
|
* embedded resource and hand off rendering.
|
|
893
909
|
*/
|
|
@@ -896,7 +912,7 @@ declare class ChatSession {
|
|
|
896
912
|
conversations: Conversation[];
|
|
897
913
|
messages: Message[];
|
|
898
914
|
isStreaming: boolean;
|
|
899
|
-
|
|
915
|
+
agentStatus: AgentStatus | null;
|
|
900
916
|
agents: AgentInfo[];
|
|
901
917
|
skills: SkillInfo[];
|
|
902
918
|
enabledClientTools: Set<string>;
|
|
@@ -1175,4 +1191,4 @@ declare function isEmbeddedResource(value: unknown): value is {
|
|
|
1175
1191
|
*/
|
|
1176
1192
|
declare function parseEmbeddedResource(value: unknown): EmbeddedResource | null;
|
|
1177
1193
|
|
|
1178
|
-
export { type ActiveJob, type AgentIdentity, type AgentInfo, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type BlockDeltaPayload, 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 EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, LLMNotConfiguredError, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type MyToolGrantsPage, type
|
|
1194
|
+
export { type ActiveJob, type AgentIdentity, type AgentInfo, type AgentStatus, type AssetCreatedPayload, type AstralformApiKeyConfig, AstralformClient, type AstralformConfig, AstralformError, type AstralformUserTokenConfig, type AttachmentStagedPayload, AuthenticationError, type BlockDeltaPayload, 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 EmbeddedResource, type FeedbackRequest, type FeedbackResponse, InMemoryStorage, type JobCreateResponse, type JobStatus, type JobSummary, LLMNotConfiguredError, type MemoryRecallPayload, type MemoryRecord, type MemoryUpdatePayload, type Message, type MyToolGrantsPage, type PromptSuggestionPayload, type ProtocolAdapter, ProtocolRegistry, RateLimitError, type RateLimitErrorDetails, type RawSseEvent, type SendOptions, ServerError, type SkillInfo, StreamAbortedError, type StreamJobSSEOptions, StreamManager, type StreamManagerEvent, type StreamState, type SubagentStartPayload, type SubagentStopPayload, type TaskStatus, type TeamAgentSummary, type TeamSummary, 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 };
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var RateLimitError = class extends AstralformError {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
var LLMNotConfiguredError = class extends AstralformError {
|
|
23
|
-
constructor(message = "LLM provider not configured for this
|
|
23
|
+
constructor(message = "LLM provider not configured for this agent") {
|
|
24
24
|
super(message, "llm_not_configured");
|
|
25
25
|
this.name = "LLMNotConfiguredError";
|
|
26
26
|
}
|
|
@@ -292,11 +292,11 @@ var AstralformClient = class {
|
|
|
292
292
|
"accessToken is required and must be a non-empty string in user-token mode"
|
|
293
293
|
);
|
|
294
294
|
}
|
|
295
|
-
const
|
|
295
|
+
const agentId = typeof config.agentId === "string" && config.agentId.length > 0 ? config.agentId : null;
|
|
296
296
|
this.auth = {
|
|
297
297
|
kind: "user_token",
|
|
298
298
|
accessToken: config.accessToken,
|
|
299
|
-
|
|
299
|
+
agentId,
|
|
300
300
|
endUserId: typeof config.endUserId === "string" && config.endUserId.length > 0 ? config.endUserId : null
|
|
301
301
|
};
|
|
302
302
|
}
|
|
@@ -318,17 +318,17 @@ var AstralformClient = class {
|
|
|
318
318
|
this.auth = { ...this.auth, accessToken };
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
|
-
* Swap the active
|
|
322
|
-
* current developer has access to the new
|
|
321
|
+
* Swap the active agent for a user-token client. The backend verifies the
|
|
322
|
+
* current developer has access to the new agent; a 403 comes back if not.
|
|
323
323
|
*/
|
|
324
|
-
|
|
324
|
+
updateAgentId(agentId) {
|
|
325
325
|
if (this.auth.kind !== "user_token") {
|
|
326
|
-
throw new Error("
|
|
326
|
+
throw new Error("updateAgentId is only valid in user-token mode");
|
|
327
327
|
}
|
|
328
|
-
if (!
|
|
329
|
-
throw new Error("
|
|
328
|
+
if (!agentId || typeof agentId !== "string") {
|
|
329
|
+
throw new Error("agentId must be a non-empty string");
|
|
330
330
|
}
|
|
331
|
-
this.auth = { ...this.auth,
|
|
331
|
+
this.auth = { ...this.auth, agentId };
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
334
|
* Set (or clear) the end-user override for user-token mode.
|
|
@@ -350,13 +350,13 @@ var AstralformClient = class {
|
|
|
350
350
|
return this.auth.kind === "user_token" ? this.auth.endUserId : null;
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
|
-
* Active
|
|
354
|
-
* was constructed without one). For API-key mode the
|
|
353
|
+
* Active agent for user-token mode, or `null` if pre-pick (client
|
|
354
|
+
* was constructed without one). For API-key mode the agent is baked
|
|
355
355
|
* into the key, so this getter returns `null` there too — use
|
|
356
356
|
* `authMode` to disambiguate.
|
|
357
357
|
*/
|
|
358
|
-
get
|
|
359
|
-
return this.auth.kind === "user_token" ? this.auth.
|
|
358
|
+
get agentId() {
|
|
359
|
+
return this.auth.kind === "user_token" ? this.auth.agentId : null;
|
|
360
360
|
}
|
|
361
361
|
/** Which auth mode this client was constructed with. */
|
|
362
362
|
get authMode() {
|
|
@@ -378,8 +378,8 @@ var AstralformClient = class {
|
|
|
378
378
|
const headers = {
|
|
379
379
|
Authorization: `Bearer ${this.auth.accessToken}`
|
|
380
380
|
};
|
|
381
|
-
if (this.auth.
|
|
382
|
-
headers["X-Project-ID"] = this.auth.
|
|
381
|
+
if (this.auth.agentId) {
|
|
382
|
+
headers["X-Project-ID"] = this.auth.agentId;
|
|
383
383
|
}
|
|
384
384
|
if (this.auth.endUserId) {
|
|
385
385
|
headers["X-End-User-ID"] = this.auth.endUserId;
|
|
@@ -434,7 +434,9 @@ var AstralformClient = class {
|
|
|
434
434
|
async getHealth() {
|
|
435
435
|
return this.get("/v1/health");
|
|
436
436
|
}
|
|
437
|
-
|
|
437
|
+
// Agent readiness check. The path is a legacy wire name (shared with the
|
|
438
|
+
// iOS SDK) — it scopes to the client's active agent via X-Project-ID.
|
|
439
|
+
async getAgentStatus() {
|
|
438
440
|
const raw = await this.get("/v1/project/status");
|
|
439
441
|
const ui = raw.ui_components ?? {};
|
|
440
442
|
return {
|
|
@@ -477,6 +479,12 @@ var AstralformClient = class {
|
|
|
477
479
|
async deleteConversation(id) {
|
|
478
480
|
await this.del(`/v1/conversations/${encodeURIComponent(id)}`);
|
|
479
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* List the AI personas (sub-agents) available INSIDE the client's active
|
|
484
|
+
* agent workspace — orchestrator + specialists, addressed per message via
|
|
485
|
+
* `ChatStreamRequest.agent_name`. Not to be confused with `listAgents()`,
|
|
486
|
+
* which enumerates the team-level agents a signed-in user can open.
|
|
487
|
+
*/
|
|
480
488
|
async getAgents() {
|
|
481
489
|
const raw = await this.get("/v1/agents");
|
|
482
490
|
return raw.map((a) => ({
|
|
@@ -598,7 +606,7 @@ var AstralformClient = class {
|
|
|
598
606
|
}
|
|
599
607
|
// --- Account-scoped discovery (user-token mode) ---
|
|
600
608
|
//
|
|
601
|
-
// Lets a signed-in user pick which team/
|
|
609
|
+
// Lets a signed-in user pick which team/agent they want to act on.
|
|
602
610
|
// Backend gates these on OIDC user context (no X-Project-ID required) —
|
|
603
611
|
// sending them in API-key mode yields 401.
|
|
604
612
|
async listTeams() {
|
|
@@ -611,14 +619,19 @@ var AstralformClient = class {
|
|
|
611
619
|
role: t.role
|
|
612
620
|
}));
|
|
613
621
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
+
/**
|
|
623
|
+
* List the team-level agents (formerly "projects") the signed-in user can
|
|
624
|
+
* open — the pickable workspaces under a team. Not to be confused with
|
|
625
|
+
* `getAgents()`, which lists the AI personas inside the active agent.
|
|
626
|
+
*/
|
|
627
|
+
async listAgents(teamId) {
|
|
628
|
+
const raw = await this.get(`/v1/teams/${encodeURIComponent(teamId)}/agents`);
|
|
629
|
+
return raw.map((a) => ({
|
|
630
|
+
id: a.id,
|
|
631
|
+
name: a.name,
|
|
632
|
+
teamId: a.team_id,
|
|
633
|
+
createdAt: a.created_at,
|
|
634
|
+
updatedAt: a.updated_at
|
|
622
635
|
}));
|
|
623
636
|
}
|
|
624
637
|
// --- Jobs API ---
|
|
@@ -1161,7 +1174,7 @@ var ChatSession = class {
|
|
|
1161
1174
|
/**
|
|
1162
1175
|
* Pluggable UI protocol adapters. Consumers register a framework-
|
|
1163
1176
|
* specific adapter (e.g. React) for each MIME type they can render,
|
|
1164
|
-
* typically gated on ``session.
|
|
1177
|
+
* typically gated on ``session.agentStatus.uiComponents.protocol``.
|
|
1165
1178
|
* ``ToolBlock``-style consumers look up the adapter for an incoming
|
|
1166
1179
|
* embedded resource and hand off rendering.
|
|
1167
1180
|
*/
|
|
@@ -1171,7 +1184,7 @@ var ChatSession = class {
|
|
|
1171
1184
|
this.conversations = [];
|
|
1172
1185
|
this.messages = [];
|
|
1173
1186
|
this.isStreaming = false;
|
|
1174
|
-
this.
|
|
1187
|
+
this.agentStatus = null;
|
|
1175
1188
|
this.agents = [];
|
|
1176
1189
|
this.skills = [];
|
|
1177
1190
|
this.enabledClientTools = /* @__PURE__ */ new Set();
|
|
@@ -1214,13 +1227,13 @@ var ChatSession = class {
|
|
|
1214
1227
|
}
|
|
1215
1228
|
async connect() {
|
|
1216
1229
|
const [status, conversations, agents, skills] = await Promise.allSettled([
|
|
1217
|
-
this.client.
|
|
1230
|
+
this.client.getAgentStatus(),
|
|
1218
1231
|
this.client.getConversations(),
|
|
1219
1232
|
this.client.getAgents().catch(() => []),
|
|
1220
1233
|
this.client.getSkills().catch(() => [])
|
|
1221
1234
|
]);
|
|
1222
1235
|
if (status.status === "fulfilled") {
|
|
1223
|
-
this.
|
|
1236
|
+
this.agentStatus = status.value;
|
|
1224
1237
|
}
|
|
1225
1238
|
if (conversations.status === "fulfilled") {
|
|
1226
1239
|
this.conversations = conversations.value;
|