@distri/core 0.2.8 → 0.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.mts CHANGED
@@ -143,6 +143,14 @@ interface BrowserScreenshotEvent {
143
143
  timestamp_ms?: number;
144
144
  };
145
145
  }
146
+ interface BrowserSessionStartedEvent {
147
+ type: 'browser_session_started';
148
+ data: {
149
+ session_id: string;
150
+ viewer_url?: string;
151
+ stream_url?: string;
152
+ };
153
+ }
146
154
  interface InlineHookRequestedEvent {
147
155
  type: 'inline_hook_requested';
148
156
  data: {
@@ -161,7 +169,7 @@ interface InlineHookRequestedEvent {
161
169
  result?: any;
162
170
  };
163
171
  }
164
- type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | PlanStartedEvent | PlanFinishedEvent | PlanPrunedEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolExecutionStartEvent | ToolExecutionEndEvent | ToolRejectedEvent | StepStartedEvent | StepCompletedEvent | AgentHandoverEvent | FeedbackReceivedEvent | ToolCallsEvent | ToolResultsEvent | BrowserScreenshotEvent | InlineHookRequestedEvent;
172
+ type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | PlanStartedEvent | PlanFinishedEvent | PlanPrunedEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolExecutionStartEvent | ToolExecutionEndEvent | ToolRejectedEvent | StepStartedEvent | StepCompletedEvent | AgentHandoverEvent | FeedbackReceivedEvent | ToolCallsEvent | ToolResultsEvent | BrowserScreenshotEvent | BrowserSessionStartedEvent | InlineHookRequestedEvent;
165
173
 
166
174
  type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool';
167
175
  interface ChatCompletionMessage {
@@ -335,6 +343,12 @@ declare class DistriClient {
335
343
  * Get specific agent by ID
336
344
  */
337
345
  getAgent(agentId: string): Promise<AgentConfigWithTools>;
346
+ /**
347
+ * Update an agent's definition (markdown only)
348
+ */
349
+ updateAgent(agentId: string, update: {
350
+ markdown: string;
351
+ }): Promise<AgentConfigWithTools>;
338
352
  /**
339
353
  * Get or create A2AClient for an agent
340
354
  */
@@ -356,9 +370,18 @@ declare class DistriClient {
356
370
  */
357
371
  cancelTask(agentId: string, taskId: string): Promise<void>;
358
372
  /**
359
- * Get threads from Distri server
373
+ * Get threads from Distri server with filtering and pagination
374
+ */
375
+ getThreads(params?: ThreadListParams): Promise<ThreadListResponse>;
376
+ /**
377
+ * Get agents sorted by thread count (most active first)
360
378
  */
361
- getThreads(): Promise<DistriThread[]>;
379
+ getAgentsByUsage(): Promise<AgentUsageInfo[]>;
380
+ /**
381
+ * Create a new browser session
382
+ * Returns session info including viewer_url and stream_url from browsr
383
+ */
384
+ createBrowserSession(): Promise<BrowserSession>;
362
385
  getThread(threadId: string): Promise<DistriThread>;
363
386
  /**
364
387
  * Get thread messages
@@ -816,6 +839,16 @@ interface AgentDefinition {
816
839
  context_size?: number;
817
840
  tools?: DistriBaseTool[];
818
841
  browser_config?: BrowserAgentConfig;
842
+ /** Agent usage statistics */
843
+ stats?: AgentStats;
844
+ }
845
+ /**
846
+ * Agent usage statistics
847
+ */
848
+ interface AgentStats {
849
+ thread_count: number;
850
+ sub_agent_usage_count: number;
851
+ last_used_at?: string | null;
819
852
  }
820
853
  interface BrowserAgentConfig {
821
854
  enabled?: boolean;
@@ -876,6 +909,9 @@ interface DistriThread {
876
909
  updated_at: string;
877
910
  message_count: number;
878
911
  last_message?: string;
912
+ user_id?: string;
913
+ external_id?: string;
914
+ tags?: string[];
879
915
  }
880
916
  interface Thread {
881
917
  id: string;
@@ -885,6 +921,49 @@ interface Thread {
885
921
  updated_at: string;
886
922
  message_count: number;
887
923
  last_message?: string;
924
+ user_id?: string;
925
+ external_id?: string;
926
+ tags?: string[];
927
+ }
928
+ /**
929
+ * Parameters for listing threads with filtering and pagination
930
+ */
931
+ interface ThreadListParams {
932
+ agent_id?: string;
933
+ external_id?: string;
934
+ search?: string;
935
+ from_date?: string;
936
+ to_date?: string;
937
+ tags?: string[];
938
+ limit?: number;
939
+ offset?: number;
940
+ }
941
+ /**
942
+ * Paginated response for thread listing
943
+ */
944
+ interface ThreadListResponse {
945
+ threads: DistriThread[];
946
+ total: number;
947
+ page: number;
948
+ page_size: number;
949
+ }
950
+ /**
951
+ * Agent usage information for sorting agents by thread count
952
+ */
953
+ interface AgentUsageInfo {
954
+ agent_id: string;
955
+ agent_name: string;
956
+ thread_count: number;
957
+ }
958
+ /**
959
+ * Browser session info returned when creating a session
960
+ */
961
+ interface BrowserSession {
962
+ session_id: string;
963
+ /** SSE stream URL (backend API) for event streaming */
964
+ sse_url?: string;
965
+ /** Frame URL for embedding (frontend app with token) */
966
+ frame_url?: string;
888
967
  }
889
968
  interface ChatProps {
890
969
  thread: Thread;
@@ -1078,4 +1157,4 @@ declare function extractToolCallsFromDistriMessage(message: DistriMessage): any[
1078
1157
  */
1079
1158
  declare function extractToolResultsFromDistriMessage(message: DistriMessage): any[];
1080
1159
 
1081
- export { A2AProtocolError, type A2AStreamEventData, type ActionPlanStep, Agent, type AgentConfigWithTools, type AgentDefinition, type AgentHandoverEvent, ApiError, type AssistantWithToolCalls, type BasePlanStep, type BatchToolCallsStep, type BrowserAgentConfig, type BrowserScreenshotEvent, type ChatCompletionChoice, type ChatCompletionMessage, type ChatCompletionRequest, type ChatCompletionResponse, type ChatCompletionResponseFormat, type ChatCompletionRole, type ChatProps, type CodePlanStep, type ConfigurationMeta, type ConfigurationResponse, ConnectionError, type ConnectionStatus, DEFAULT_BASE_URL, type DataPart, type DistriBaseTool, type DistriBrowserRuntimeConfig, type DistriChatMessage, DistriClient, type DistriClientConfig, type DistriConfiguration, DistriError, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriPlan, type DistriStreamEvent, type DistriThread, type ExternalMcpServer, ExternalToolValidationError, type ExternalToolValidationResult, type FeedbackReceivedEvent, type FileBytes, type FileType, type FileUrl, type FinalResultPlanStep, type HookContext, type HookHandler, type HookMutation, type ImagePart, type InlineHookEventData, type InlineHookRequest, type InlineHookRequestedEvent, type InvokeConfig, type InvokeContext, type InvokeResult, type LLMResponse, type LlmExecuteOptions, type LlmPlanStep, type McpDefinition, type McpServerType, type MessageRole, type ModelProviderConfig, type ModelProviderName, type ModelSettings, type PlanAction, type PlanFinishedEvent, type PlanPrunedEvent, type PlanStartedEvent, type PlanStep, type ReactStep, type Role, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type ServerConfig, type SpeechToTextConfig, type StepCompletedEvent, type StepStartedEvent, type StreamingTranscriptionOptions, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type ThoughtPlanStep, type ThoughtStep, type Thread, type ToolCall, type ToolCallPart, type ToolCallsEvent, type ToolDefinition, type ToolExecutionEndEvent, type ToolExecutionOptions, type ToolExecutionStartEvent, type ToolHandler, type ToolRejectedEvent, type ToolResult, type ToolResultData, type ToolResultRefPart, type ToolResults, type ToolResultsEvent, type UseToolsOptions, convertA2AMessageToDistri, convertA2APartToDistri, convertA2AStatusUpdateToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, createFailedToolResult, createSuccessfulToolResult, decodeA2AStreamEvent, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultData, extractToolResultsFromDistriMessage, isArrayParts, isDistriEvent, isDistriMessage, processA2AMessagesData, processA2AStreamData, uuidv4 };
1160
+ export { A2AProtocolError, type A2AStreamEventData, type ActionPlanStep, Agent, type AgentConfigWithTools, type AgentDefinition, type AgentHandoverEvent, type AgentStats, type AgentUsageInfo, ApiError, type AssistantWithToolCalls, type BasePlanStep, type BatchToolCallsStep, type BrowserAgentConfig, type BrowserScreenshotEvent, type BrowserSession, type BrowserSessionStartedEvent, type ChatCompletionChoice, type ChatCompletionMessage, type ChatCompletionRequest, type ChatCompletionResponse, type ChatCompletionResponseFormat, type ChatCompletionRole, type ChatProps, type CodePlanStep, type ConfigurationMeta, type ConfigurationResponse, ConnectionError, type ConnectionStatus, DEFAULT_BASE_URL, type DataPart, type DistriBaseTool, type DistriBrowserRuntimeConfig, type DistriChatMessage, DistriClient, type DistriClientConfig, type DistriConfiguration, DistriError, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriPlan, type DistriStreamEvent, type DistriThread, type ExternalMcpServer, ExternalToolValidationError, type ExternalToolValidationResult, type FeedbackReceivedEvent, type FileBytes, type FileType, type FileUrl, type FinalResultPlanStep, type HookContext, type HookHandler, type HookMutation, type ImagePart, type InlineHookEventData, type InlineHookRequest, type InlineHookRequestedEvent, type InvokeConfig, type InvokeContext, type InvokeResult, type LLMResponse, type LlmExecuteOptions, type LlmPlanStep, type McpDefinition, type McpServerType, type MessageRole, type ModelProviderConfig, type ModelProviderName, type ModelSettings, type PlanAction, type PlanFinishedEvent, type PlanPrunedEvent, type PlanStartedEvent, type PlanStep, type ReactStep, type Role, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type ServerConfig, type SpeechToTextConfig, type StepCompletedEvent, type StepStartedEvent, type StreamingTranscriptionOptions, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type ThoughtPlanStep, type ThoughtStep, type Thread, type ThreadListParams, type ThreadListResponse, type ToolCall, type ToolCallPart, type ToolCallsEvent, type ToolDefinition, type ToolExecutionEndEvent, type ToolExecutionOptions, type ToolExecutionStartEvent, type ToolHandler, type ToolRejectedEvent, type ToolResult, type ToolResultData, type ToolResultRefPart, type ToolResults, type ToolResultsEvent, type UseToolsOptions, convertA2AMessageToDistri, convertA2APartToDistri, convertA2AStatusUpdateToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, createFailedToolResult, createSuccessfulToolResult, decodeA2AStreamEvent, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultData, extractToolResultsFromDistriMessage, isArrayParts, isDistriEvent, isDistriMessage, processA2AMessagesData, processA2AStreamData, uuidv4 };
package/dist/index.d.ts CHANGED
@@ -143,6 +143,14 @@ interface BrowserScreenshotEvent {
143
143
  timestamp_ms?: number;
144
144
  };
145
145
  }
146
+ interface BrowserSessionStartedEvent {
147
+ type: 'browser_session_started';
148
+ data: {
149
+ session_id: string;
150
+ viewer_url?: string;
151
+ stream_url?: string;
152
+ };
153
+ }
146
154
  interface InlineHookRequestedEvent {
147
155
  type: 'inline_hook_requested';
148
156
  data: {
@@ -161,7 +169,7 @@ interface InlineHookRequestedEvent {
161
169
  result?: any;
162
170
  };
163
171
  }
164
- type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | PlanStartedEvent | PlanFinishedEvent | PlanPrunedEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolExecutionStartEvent | ToolExecutionEndEvent | ToolRejectedEvent | StepStartedEvent | StepCompletedEvent | AgentHandoverEvent | FeedbackReceivedEvent | ToolCallsEvent | ToolResultsEvent | BrowserScreenshotEvent | InlineHookRequestedEvent;
172
+ type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | PlanStartedEvent | PlanFinishedEvent | PlanPrunedEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolExecutionStartEvent | ToolExecutionEndEvent | ToolRejectedEvent | StepStartedEvent | StepCompletedEvent | AgentHandoverEvent | FeedbackReceivedEvent | ToolCallsEvent | ToolResultsEvent | BrowserScreenshotEvent | BrowserSessionStartedEvent | InlineHookRequestedEvent;
165
173
 
166
174
  type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool';
167
175
  interface ChatCompletionMessage {
@@ -335,6 +343,12 @@ declare class DistriClient {
335
343
  * Get specific agent by ID
336
344
  */
337
345
  getAgent(agentId: string): Promise<AgentConfigWithTools>;
346
+ /**
347
+ * Update an agent's definition (markdown only)
348
+ */
349
+ updateAgent(agentId: string, update: {
350
+ markdown: string;
351
+ }): Promise<AgentConfigWithTools>;
338
352
  /**
339
353
  * Get or create A2AClient for an agent
340
354
  */
@@ -356,9 +370,18 @@ declare class DistriClient {
356
370
  */
357
371
  cancelTask(agentId: string, taskId: string): Promise<void>;
358
372
  /**
359
- * Get threads from Distri server
373
+ * Get threads from Distri server with filtering and pagination
374
+ */
375
+ getThreads(params?: ThreadListParams): Promise<ThreadListResponse>;
376
+ /**
377
+ * Get agents sorted by thread count (most active first)
360
378
  */
361
- getThreads(): Promise<DistriThread[]>;
379
+ getAgentsByUsage(): Promise<AgentUsageInfo[]>;
380
+ /**
381
+ * Create a new browser session
382
+ * Returns session info including viewer_url and stream_url from browsr
383
+ */
384
+ createBrowserSession(): Promise<BrowserSession>;
362
385
  getThread(threadId: string): Promise<DistriThread>;
363
386
  /**
364
387
  * Get thread messages
@@ -816,6 +839,16 @@ interface AgentDefinition {
816
839
  context_size?: number;
817
840
  tools?: DistriBaseTool[];
818
841
  browser_config?: BrowserAgentConfig;
842
+ /** Agent usage statistics */
843
+ stats?: AgentStats;
844
+ }
845
+ /**
846
+ * Agent usage statistics
847
+ */
848
+ interface AgentStats {
849
+ thread_count: number;
850
+ sub_agent_usage_count: number;
851
+ last_used_at?: string | null;
819
852
  }
820
853
  interface BrowserAgentConfig {
821
854
  enabled?: boolean;
@@ -876,6 +909,9 @@ interface DistriThread {
876
909
  updated_at: string;
877
910
  message_count: number;
878
911
  last_message?: string;
912
+ user_id?: string;
913
+ external_id?: string;
914
+ tags?: string[];
879
915
  }
880
916
  interface Thread {
881
917
  id: string;
@@ -885,6 +921,49 @@ interface Thread {
885
921
  updated_at: string;
886
922
  message_count: number;
887
923
  last_message?: string;
924
+ user_id?: string;
925
+ external_id?: string;
926
+ tags?: string[];
927
+ }
928
+ /**
929
+ * Parameters for listing threads with filtering and pagination
930
+ */
931
+ interface ThreadListParams {
932
+ agent_id?: string;
933
+ external_id?: string;
934
+ search?: string;
935
+ from_date?: string;
936
+ to_date?: string;
937
+ tags?: string[];
938
+ limit?: number;
939
+ offset?: number;
940
+ }
941
+ /**
942
+ * Paginated response for thread listing
943
+ */
944
+ interface ThreadListResponse {
945
+ threads: DistriThread[];
946
+ total: number;
947
+ page: number;
948
+ page_size: number;
949
+ }
950
+ /**
951
+ * Agent usage information for sorting agents by thread count
952
+ */
953
+ interface AgentUsageInfo {
954
+ agent_id: string;
955
+ agent_name: string;
956
+ thread_count: number;
957
+ }
958
+ /**
959
+ * Browser session info returned when creating a session
960
+ */
961
+ interface BrowserSession {
962
+ session_id: string;
963
+ /** SSE stream URL (backend API) for event streaming */
964
+ sse_url?: string;
965
+ /** Frame URL for embedding (frontend app with token) */
966
+ frame_url?: string;
888
967
  }
889
968
  interface ChatProps {
890
969
  thread: Thread;
@@ -1078,4 +1157,4 @@ declare function extractToolCallsFromDistriMessage(message: DistriMessage): any[
1078
1157
  */
1079
1158
  declare function extractToolResultsFromDistriMessage(message: DistriMessage): any[];
1080
1159
 
1081
- export { A2AProtocolError, type A2AStreamEventData, type ActionPlanStep, Agent, type AgentConfigWithTools, type AgentDefinition, type AgentHandoverEvent, ApiError, type AssistantWithToolCalls, type BasePlanStep, type BatchToolCallsStep, type BrowserAgentConfig, type BrowserScreenshotEvent, type ChatCompletionChoice, type ChatCompletionMessage, type ChatCompletionRequest, type ChatCompletionResponse, type ChatCompletionResponseFormat, type ChatCompletionRole, type ChatProps, type CodePlanStep, type ConfigurationMeta, type ConfigurationResponse, ConnectionError, type ConnectionStatus, DEFAULT_BASE_URL, type DataPart, type DistriBaseTool, type DistriBrowserRuntimeConfig, type DistriChatMessage, DistriClient, type DistriClientConfig, type DistriConfiguration, DistriError, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriPlan, type DistriStreamEvent, type DistriThread, type ExternalMcpServer, ExternalToolValidationError, type ExternalToolValidationResult, type FeedbackReceivedEvent, type FileBytes, type FileType, type FileUrl, type FinalResultPlanStep, type HookContext, type HookHandler, type HookMutation, type ImagePart, type InlineHookEventData, type InlineHookRequest, type InlineHookRequestedEvent, type InvokeConfig, type InvokeContext, type InvokeResult, type LLMResponse, type LlmExecuteOptions, type LlmPlanStep, type McpDefinition, type McpServerType, type MessageRole, type ModelProviderConfig, type ModelProviderName, type ModelSettings, type PlanAction, type PlanFinishedEvent, type PlanPrunedEvent, type PlanStartedEvent, type PlanStep, type ReactStep, type Role, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type ServerConfig, type SpeechToTextConfig, type StepCompletedEvent, type StepStartedEvent, type StreamingTranscriptionOptions, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type ThoughtPlanStep, type ThoughtStep, type Thread, type ToolCall, type ToolCallPart, type ToolCallsEvent, type ToolDefinition, type ToolExecutionEndEvent, type ToolExecutionOptions, type ToolExecutionStartEvent, type ToolHandler, type ToolRejectedEvent, type ToolResult, type ToolResultData, type ToolResultRefPart, type ToolResults, type ToolResultsEvent, type UseToolsOptions, convertA2AMessageToDistri, convertA2APartToDistri, convertA2AStatusUpdateToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, createFailedToolResult, createSuccessfulToolResult, decodeA2AStreamEvent, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultData, extractToolResultsFromDistriMessage, isArrayParts, isDistriEvent, isDistriMessage, processA2AMessagesData, processA2AStreamData, uuidv4 };
1160
+ export { A2AProtocolError, type A2AStreamEventData, type ActionPlanStep, Agent, type AgentConfigWithTools, type AgentDefinition, type AgentHandoverEvent, type AgentStats, type AgentUsageInfo, ApiError, type AssistantWithToolCalls, type BasePlanStep, type BatchToolCallsStep, type BrowserAgentConfig, type BrowserScreenshotEvent, type BrowserSession, type BrowserSessionStartedEvent, type ChatCompletionChoice, type ChatCompletionMessage, type ChatCompletionRequest, type ChatCompletionResponse, type ChatCompletionResponseFormat, type ChatCompletionRole, type ChatProps, type CodePlanStep, type ConfigurationMeta, type ConfigurationResponse, ConnectionError, type ConnectionStatus, DEFAULT_BASE_URL, type DataPart, type DistriBaseTool, type DistriBrowserRuntimeConfig, type DistriChatMessage, DistriClient, type DistriClientConfig, type DistriConfiguration, DistriError, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriPlan, type DistriStreamEvent, type DistriThread, type ExternalMcpServer, ExternalToolValidationError, type ExternalToolValidationResult, type FeedbackReceivedEvent, type FileBytes, type FileType, type FileUrl, type FinalResultPlanStep, type HookContext, type HookHandler, type HookMutation, type ImagePart, type InlineHookEventData, type InlineHookRequest, type InlineHookRequestedEvent, type InvokeConfig, type InvokeContext, type InvokeResult, type LLMResponse, type LlmExecuteOptions, type LlmPlanStep, type McpDefinition, type McpServerType, type MessageRole, type ModelProviderConfig, type ModelProviderName, type ModelSettings, type PlanAction, type PlanFinishedEvent, type PlanPrunedEvent, type PlanStartedEvent, type PlanStep, type ReactStep, type Role, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type ServerConfig, type SpeechToTextConfig, type StepCompletedEvent, type StepStartedEvent, type StreamingTranscriptionOptions, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type ThoughtPlanStep, type ThoughtStep, type Thread, type ThreadListParams, type ThreadListResponse, type ToolCall, type ToolCallPart, type ToolCallsEvent, type ToolDefinition, type ToolExecutionEndEvent, type ToolExecutionOptions, type ToolExecutionStartEvent, type ToolHandler, type ToolRejectedEvent, type ToolResult, type ToolResultData, type ToolResultRefPart, type ToolResults, type ToolResultsEvent, type UseToolsOptions, convertA2AMessageToDistri, convertA2APartToDistri, convertA2AStatusUpdateToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, createFailedToolResult, createSuccessfulToolResult, decodeA2AStreamEvent, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultData, extractToolResultsFromDistriMessage, isArrayParts, isDistriEvent, isDistriMessage, processA2AMessagesData, processA2AStreamData, uuidv4 };
package/dist/index.js CHANGED
@@ -730,6 +730,17 @@ function convertA2AStatusUpdateToDistri(statusUpdate) {
730
730
  };
731
731
  return hookRequested;
732
732
  }
733
+ case "browser_session_started": {
734
+ const browserSessionStarted = {
735
+ type: "browser_session_started",
736
+ data: {
737
+ session_id: metadata.session_id || "",
738
+ viewer_url: metadata.viewer_url,
739
+ stream_url: metadata.stream_url
740
+ }
741
+ };
742
+ return browserSessionStarted;
743
+ }
733
744
  default: {
734
745
  console.warn(`Unhandled status update metadata type: ${metadata.type}`, metadata);
735
746
  const defaultResult = {
@@ -1312,6 +1323,31 @@ var _DistriClient = class _DistriClient {
1312
1323
  throw new DistriError(`Failed to fetch agent ${agentId}`, "FETCH_ERROR", error);
1313
1324
  }
1314
1325
  }
1326
+ /**
1327
+ * Update an agent's definition (markdown only)
1328
+ */
1329
+ async updateAgent(agentId, update) {
1330
+ try {
1331
+ const response = await this.fetch(`/agents/${agentId}`, {
1332
+ method: "PUT",
1333
+ headers: {
1334
+ "Content-Type": "application/json",
1335
+ ...this.config.headers
1336
+ },
1337
+ body: JSON.stringify(update)
1338
+ });
1339
+ if (!response.ok) {
1340
+ if (response.status === 404) {
1341
+ throw new ApiError(`Agent not found: ${agentId}`, 404);
1342
+ }
1343
+ throw new ApiError(`Failed to update agent: ${response.statusText}`, response.status);
1344
+ }
1345
+ return await response.json();
1346
+ } catch (error) {
1347
+ if (error instanceof ApiError) throw error;
1348
+ throw new DistriError(`Failed to update agent ${agentId}`, "UPDATE_ERROR", error);
1349
+ }
1350
+ }
1315
1351
  /**
1316
1352
  * Get or create A2AClient for an agent
1317
1353
  */
@@ -1397,11 +1433,22 @@ var _DistriClient = class _DistriClient {
1397
1433
  }
1398
1434
  }
1399
1435
  /**
1400
- * Get threads from Distri server
1436
+ * Get threads from Distri server with filtering and pagination
1401
1437
  */
1402
- async getThreads() {
1438
+ async getThreads(params = {}) {
1403
1439
  try {
1404
- const response = await this.fetch(`/threads`);
1440
+ const searchParams = new URLSearchParams();
1441
+ if (params.agent_id) searchParams.set("agent_id", params.agent_id);
1442
+ if (params.external_id) searchParams.set("external_id", params.external_id);
1443
+ if (params.search) searchParams.set("search", params.search);
1444
+ if (params.from_date) searchParams.set("from_date", params.from_date);
1445
+ if (params.to_date) searchParams.set("to_date", params.to_date);
1446
+ if (params.tags?.length) searchParams.set("tags", params.tags.join(","));
1447
+ if (params.limit !== void 0) searchParams.set("limit", params.limit.toString());
1448
+ if (params.offset !== void 0) searchParams.set("offset", params.offset.toString());
1449
+ const queryString = searchParams.toString();
1450
+ const url = queryString ? `/threads?${queryString}` : "/threads";
1451
+ const response = await this.fetch(url);
1405
1452
  if (!response.ok) {
1406
1453
  throw new ApiError(`Failed to fetch threads: ${response.statusText}`, response.status);
1407
1454
  }
@@ -1411,6 +1458,39 @@ var _DistriClient = class _DistriClient {
1411
1458
  throw new DistriError("Failed to fetch threads", "FETCH_ERROR", error);
1412
1459
  }
1413
1460
  }
1461
+ /**
1462
+ * Get agents sorted by thread count (most active first)
1463
+ */
1464
+ async getAgentsByUsage() {
1465
+ try {
1466
+ const response = await this.fetch("/threads/agents");
1467
+ if (!response.ok) {
1468
+ throw new ApiError(`Failed to fetch agents by usage: ${response.statusText}`, response.status);
1469
+ }
1470
+ return await response.json();
1471
+ } catch (error) {
1472
+ if (error instanceof ApiError) throw error;
1473
+ throw new DistriError("Failed to fetch agents by usage", "FETCH_ERROR", error);
1474
+ }
1475
+ }
1476
+ /**
1477
+ * Create a new browser session
1478
+ * Returns session info including viewer_url and stream_url from browsr
1479
+ */
1480
+ async createBrowserSession() {
1481
+ try {
1482
+ const response = await this.fetch("/browser/session", {
1483
+ method: "POST"
1484
+ });
1485
+ if (!response.ok) {
1486
+ throw new ApiError(`Failed to create browser session: ${response.statusText}`, response.status);
1487
+ }
1488
+ return await response.json();
1489
+ } catch (error) {
1490
+ if (error instanceof ApiError) throw error;
1491
+ throw new DistriError("Failed to create browser session", "FETCH_ERROR", error);
1492
+ }
1493
+ }
1414
1494
  async getThread(threadId) {
1415
1495
  try {
1416
1496
  const response = await this.fetch(`/threads/${threadId}`);
@@ -1865,7 +1945,7 @@ var Agent = class _Agent {
1865
1945
  const enhancedParams = this.enhanceParamsWithTools(params, tools);
1866
1946
  const a2aStream = this.client.sendMessageStream(this.agentDefinition.id, enhancedParams);
1867
1947
  const self = this;
1868
- return async function* () {
1948
+ return (async function* () {
1869
1949
  for await (const event of a2aStream) {
1870
1950
  const converted = decodeA2AStreamEvent(event);
1871
1951
  if (converted && converted.type === "inline_hook_requested") {
@@ -1886,7 +1966,7 @@ var Agent = class _Agent {
1886
1966
  yield converted;
1887
1967
  }
1888
1968
  }
1889
- }();
1969
+ })();
1890
1970
  }
1891
1971
  /**
1892
1972
  * Validate that required external tools are registered before invoking.