@distri/core 0.2.5 → 0.2.8
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 +60 -1
- package/dist/index.d.mts +45 -36
- package/dist/index.d.ts +45 -36
- package/dist/index.js +65 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -137,4 +137,63 @@ const part: DistriPart = {
|
|
|
137
137
|
code: 'console.log("Hello");'
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
```
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Session Store API
|
|
143
|
+
|
|
144
|
+
The `DistriClient` provides a comprehensive session store API for managing thread-scoped key-value storage.
|
|
145
|
+
|
|
146
|
+
### Basic Operations
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { DistriClient } from '@distri/core';
|
|
150
|
+
|
|
151
|
+
const client = DistriClient.create();
|
|
152
|
+
const sessionId = 'thread-123';
|
|
153
|
+
|
|
154
|
+
// Set a session value
|
|
155
|
+
await client.setSessionValue(sessionId, 'key', { data: 'value' });
|
|
156
|
+
|
|
157
|
+
// Get a session value
|
|
158
|
+
const value = await client.getSessionValue(sessionId, 'key');
|
|
159
|
+
|
|
160
|
+
// Get all session values (returns a map)
|
|
161
|
+
const allValues = await client.getSessionValues(sessionId);
|
|
162
|
+
|
|
163
|
+
// Delete a session value
|
|
164
|
+
await client.deleteSessionValue(sessionId, 'key');
|
|
165
|
+
|
|
166
|
+
// Clear all session values
|
|
167
|
+
await client.clearSession(sessionId);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### API Endpoints
|
|
171
|
+
|
|
172
|
+
All session methods use the following endpoints (mounted at `/v1/sessions/`):
|
|
173
|
+
|
|
174
|
+
- `POST /sessions/{sessionId}/values` - Set a session value
|
|
175
|
+
- `GET /sessions/{sessionId}/values` - Get all session values (returns map)
|
|
176
|
+
- `GET /sessions/{sessionId}/values/{key}` - Get a specific session value
|
|
177
|
+
- `DELETE /sessions/{sessionId}/values/{key}` - Delete a session value
|
|
178
|
+
- `DELETE /sessions/{sessionId}` - Clear all session values
|
|
179
|
+
|
|
180
|
+
### Integration with Agent Definitions
|
|
181
|
+
|
|
182
|
+
Session values can be referenced in agent definitions using `UserMessageOverrides`:
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
# Agent definition
|
|
186
|
+
user_message_overrides:
|
|
187
|
+
parts:
|
|
188
|
+
- type: session_key
|
|
189
|
+
key: "observation" # References session value with key "observation"
|
|
190
|
+
- type: template
|
|
191
|
+
template: "custom_user_template"
|
|
192
|
+
include_artifacts: true
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
When the agent processes a message, it will automatically:
|
|
196
|
+
1. Load all session values as a map
|
|
197
|
+
2. Resolve `PartDefinition::SessionKey` references from the map
|
|
198
|
+
3. Merge override parts with the default message parts
|
|
199
|
+
4. Include the merged message in the LLM prompt
|
package/dist/index.d.mts
CHANGED
|
@@ -223,6 +223,14 @@ declare class DistriClient {
|
|
|
223
223
|
private refreshPromise?;
|
|
224
224
|
private agentClients;
|
|
225
225
|
constructor(config: DistriClientConfig);
|
|
226
|
+
/**
|
|
227
|
+
* Get the configured client ID.
|
|
228
|
+
*/
|
|
229
|
+
get clientId(): string | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* Set the client ID for embed token issuance.
|
|
232
|
+
*/
|
|
233
|
+
set clientId(value: string | undefined);
|
|
226
234
|
/**
|
|
227
235
|
* Create a client with default cloud configuration.
|
|
228
236
|
*
|
|
@@ -257,25 +265,6 @@ declare class DistriClient {
|
|
|
257
265
|
* Session store: clear all keys in a session
|
|
258
266
|
*/
|
|
259
267
|
clearSession(sessionId: string): Promise<void>;
|
|
260
|
-
private static readonly ADDITIONAL_PARTS_KEY;
|
|
261
|
-
/**
|
|
262
|
-
* Set additional user message parts for the next agent iteration.
|
|
263
|
-
* These parts will be appended to the user message in the prompt.
|
|
264
|
-
* @param sessionId - The thread/session ID
|
|
265
|
-
* @param parts - Array of DistriPart objects to append to user message
|
|
266
|
-
*/
|
|
267
|
-
setAdditionalUserParts(sessionId: string, parts: DistriPart[]): Promise<void>;
|
|
268
|
-
/**
|
|
269
|
-
* Get the current additional user message parts.
|
|
270
|
-
* @param sessionId - The thread/session ID
|
|
271
|
-
* @returns Array of DistriPart objects or null if not set
|
|
272
|
-
*/
|
|
273
|
-
getAdditionalUserParts(sessionId: string): Promise<DistriPart[] | null>;
|
|
274
|
-
/**
|
|
275
|
-
* Clear/delete the additional user message parts.
|
|
276
|
-
* @param sessionId - The thread/session ID
|
|
277
|
-
*/
|
|
278
|
-
clearAdditionalUserParts(sessionId: string): Promise<void>;
|
|
279
268
|
/**
|
|
280
269
|
* Response from the token endpoint
|
|
281
270
|
*/
|
|
@@ -315,6 +304,10 @@ declare class DistriClient {
|
|
|
315
304
|
accessToken?: string;
|
|
316
305
|
refreshToken?: string;
|
|
317
306
|
}): void;
|
|
307
|
+
/**
|
|
308
|
+
* Reset all authentication tokens.
|
|
309
|
+
*/
|
|
310
|
+
resetTokens(): void;
|
|
318
311
|
/**
|
|
319
312
|
* Start streaming speech-to-text transcription via WebSocket
|
|
320
313
|
*/
|
|
@@ -341,7 +334,7 @@ declare class DistriClient {
|
|
|
341
334
|
/**
|
|
342
335
|
* Get specific agent by ID
|
|
343
336
|
*/
|
|
344
|
-
getAgent(agentId: string): Promise<
|
|
337
|
+
getAgent(agentId: string): Promise<AgentConfigWithTools>;
|
|
345
338
|
/**
|
|
346
339
|
* Get or create A2AClient for an agent
|
|
347
340
|
*/
|
|
@@ -392,6 +385,9 @@ declare class DistriClient {
|
|
|
392
385
|
*/
|
|
393
386
|
get baseUrl(): string;
|
|
394
387
|
private applyTokens;
|
|
388
|
+
/**
|
|
389
|
+
* Ensure access token is valid, refreshing if necessary
|
|
390
|
+
*/
|
|
395
391
|
private ensureAccessToken;
|
|
396
392
|
private refreshTokens;
|
|
397
393
|
private performTokenRefresh;
|
|
@@ -405,9 +401,10 @@ declare class DistriClient {
|
|
|
405
401
|
*/
|
|
406
402
|
private fetchAbsolute;
|
|
407
403
|
/**
|
|
408
|
-
* Enhanced fetch with retry logic
|
|
404
|
+
* Enhanced fetch with retry logic and auth headers.
|
|
405
|
+
* Exposed publicly for extensions like DistriHomeClient.
|
|
409
406
|
*/
|
|
410
|
-
|
|
407
|
+
fetch(input: RequestInfo | URL, initialInit?: RequestInit): Promise<Response>;
|
|
411
408
|
/**
|
|
412
409
|
* Delay utility
|
|
413
410
|
*/
|
|
@@ -479,7 +476,7 @@ declare class Agent {
|
|
|
479
476
|
private agentDefinition;
|
|
480
477
|
private hookHandlers;
|
|
481
478
|
private defaultHookHandler;
|
|
482
|
-
constructor(agentDefinition:
|
|
479
|
+
constructor(agentDefinition: AgentConfigWithTools, client: DistriClient);
|
|
483
480
|
/**
|
|
484
481
|
* Get agent information
|
|
485
482
|
*/
|
|
@@ -491,7 +488,7 @@ declare class Agent {
|
|
|
491
488
|
/**
|
|
492
489
|
* Get the full agent definition (including backend tools)
|
|
493
490
|
*/
|
|
494
|
-
getDefinition():
|
|
491
|
+
getDefinition(): AgentConfigWithTools;
|
|
495
492
|
/**
|
|
496
493
|
* Fetch messages for a thread (public method for useChat)
|
|
497
494
|
*/
|
|
@@ -524,7 +521,7 @@ declare class Agent {
|
|
|
524
521
|
/**
|
|
525
522
|
* Create an agent instance from an agent ID
|
|
526
523
|
*/
|
|
527
|
-
static create(agentIdOrDef: string |
|
|
524
|
+
static create(agentIdOrDef: string | AgentConfigWithTools, client: DistriClient): Promise<Agent>;
|
|
528
525
|
/**
|
|
529
526
|
* Complete an external tool call by sending the result back to the server
|
|
530
527
|
*/
|
|
@@ -713,14 +710,18 @@ interface FileUrl {
|
|
|
713
710
|
name?: string;
|
|
714
711
|
}
|
|
715
712
|
type FileType = FileBytes | FileUrl;
|
|
713
|
+
interface ToolDefinition {
|
|
714
|
+
name: string;
|
|
715
|
+
description: string;
|
|
716
|
+
parameters: object;
|
|
717
|
+
examples?: string;
|
|
718
|
+
output_schema?: object;
|
|
719
|
+
}
|
|
716
720
|
/**
|
|
717
721
|
* Tool definition interface following AG-UI pattern
|
|
718
722
|
*/
|
|
719
|
-
interface DistriBaseTool {
|
|
720
|
-
name: string;
|
|
723
|
+
interface DistriBaseTool extends ToolDefinition {
|
|
721
724
|
type: 'function' | 'ui';
|
|
722
|
-
description: string;
|
|
723
|
-
parameters: object;
|
|
724
725
|
is_final?: boolean;
|
|
725
726
|
autoExecute?: boolean;
|
|
726
727
|
isExternal?: boolean;
|
|
@@ -776,6 +777,10 @@ declare function createFailedToolResult(toolCallId: string, toolName: string, er
|
|
|
776
777
|
* Handles both frontend DistriPart format and backend BackendPart format
|
|
777
778
|
*/
|
|
778
779
|
declare function extractToolResultData(toolResult: ToolResult): ToolResultData | null;
|
|
780
|
+
interface AgentConfigWithTools extends AgentDefinition {
|
|
781
|
+
markdown?: string;
|
|
782
|
+
resolved_tools?: ToolDefinition[];
|
|
783
|
+
}
|
|
779
784
|
/**
|
|
780
785
|
* Distri-specific Agent type that wraps A2A AgentCard
|
|
781
786
|
*/
|
|
@@ -795,6 +800,8 @@ interface AgentDefinition {
|
|
|
795
800
|
mcp_servers?: McpDefinition[];
|
|
796
801
|
/** Settings related to the model used by the agent. */
|
|
797
802
|
model_settings?: ModelSettings;
|
|
803
|
+
/** Secondary Model Settings used for analysis */
|
|
804
|
+
analysis_model_settings?: ModelSettings;
|
|
798
805
|
/** The size of the history to maintain for the agent. */
|
|
799
806
|
history_size?: number;
|
|
800
807
|
/** The planning configuration for the agent, if any. */
|
|
@@ -805,8 +812,8 @@ interface AgentDefinition {
|
|
|
805
812
|
skills?: AgentSkill[];
|
|
806
813
|
/** List of sub-agents that this agent can transfer control to */
|
|
807
814
|
sub_agents?: string[];
|
|
808
|
-
agentType?: string;
|
|
809
815
|
agent_type?: string;
|
|
816
|
+
context_size?: number;
|
|
810
817
|
tools?: DistriBaseTool[];
|
|
811
818
|
browser_config?: BrowserAgentConfig;
|
|
812
819
|
}
|
|
@@ -940,6 +947,11 @@ interface DistriClientConfig {
|
|
|
940
947
|
* Request interceptor for modifying requests before sending
|
|
941
948
|
*/
|
|
942
949
|
interceptor?: (init?: RequestInit) => Promise<RequestInit | undefined>;
|
|
950
|
+
/**
|
|
951
|
+
* Hook to refresh the access token when it expires.
|
|
952
|
+
* Useful for public clients where only an access token is available.
|
|
953
|
+
*/
|
|
954
|
+
onTokenRefresh?: () => Promise<string | null>;
|
|
943
955
|
/**
|
|
944
956
|
* Access token for bearer auth (optional)
|
|
945
957
|
*/
|
|
@@ -953,12 +965,9 @@ interface DistriClientConfig {
|
|
|
953
965
|
*/
|
|
954
966
|
tokenRefreshSkewMs?: number;
|
|
955
967
|
/**
|
|
956
|
-
*
|
|
968
|
+
* Client ID from Distri Cloud.
|
|
957
969
|
*/
|
|
958
|
-
|
|
959
|
-
accessToken: string;
|
|
960
|
-
refreshToken: string;
|
|
961
|
-
}) => void;
|
|
970
|
+
clientId?: string;
|
|
962
971
|
}
|
|
963
972
|
interface LLMResponse {
|
|
964
973
|
finish_reason: string;
|
|
@@ -1069,4 +1078,4 @@ declare function extractToolCallsFromDistriMessage(message: DistriMessage): any[
|
|
|
1069
1078
|
*/
|
|
1070
1079
|
declare function extractToolResultsFromDistriMessage(message: DistriMessage): any[];
|
|
1071
1080
|
|
|
1072
|
-
export { A2AProtocolError, type A2AStreamEventData, type ActionPlanStep, Agent, 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 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -223,6 +223,14 @@ declare class DistriClient {
|
|
|
223
223
|
private refreshPromise?;
|
|
224
224
|
private agentClients;
|
|
225
225
|
constructor(config: DistriClientConfig);
|
|
226
|
+
/**
|
|
227
|
+
* Get the configured client ID.
|
|
228
|
+
*/
|
|
229
|
+
get clientId(): string | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* Set the client ID for embed token issuance.
|
|
232
|
+
*/
|
|
233
|
+
set clientId(value: string | undefined);
|
|
226
234
|
/**
|
|
227
235
|
* Create a client with default cloud configuration.
|
|
228
236
|
*
|
|
@@ -257,25 +265,6 @@ declare class DistriClient {
|
|
|
257
265
|
* Session store: clear all keys in a session
|
|
258
266
|
*/
|
|
259
267
|
clearSession(sessionId: string): Promise<void>;
|
|
260
|
-
private static readonly ADDITIONAL_PARTS_KEY;
|
|
261
|
-
/**
|
|
262
|
-
* Set additional user message parts for the next agent iteration.
|
|
263
|
-
* These parts will be appended to the user message in the prompt.
|
|
264
|
-
* @param sessionId - The thread/session ID
|
|
265
|
-
* @param parts - Array of DistriPart objects to append to user message
|
|
266
|
-
*/
|
|
267
|
-
setAdditionalUserParts(sessionId: string, parts: DistriPart[]): Promise<void>;
|
|
268
|
-
/**
|
|
269
|
-
* Get the current additional user message parts.
|
|
270
|
-
* @param sessionId - The thread/session ID
|
|
271
|
-
* @returns Array of DistriPart objects or null if not set
|
|
272
|
-
*/
|
|
273
|
-
getAdditionalUserParts(sessionId: string): Promise<DistriPart[] | null>;
|
|
274
|
-
/**
|
|
275
|
-
* Clear/delete the additional user message parts.
|
|
276
|
-
* @param sessionId - The thread/session ID
|
|
277
|
-
*/
|
|
278
|
-
clearAdditionalUserParts(sessionId: string): Promise<void>;
|
|
279
268
|
/**
|
|
280
269
|
* Response from the token endpoint
|
|
281
270
|
*/
|
|
@@ -315,6 +304,10 @@ declare class DistriClient {
|
|
|
315
304
|
accessToken?: string;
|
|
316
305
|
refreshToken?: string;
|
|
317
306
|
}): void;
|
|
307
|
+
/**
|
|
308
|
+
* Reset all authentication tokens.
|
|
309
|
+
*/
|
|
310
|
+
resetTokens(): void;
|
|
318
311
|
/**
|
|
319
312
|
* Start streaming speech-to-text transcription via WebSocket
|
|
320
313
|
*/
|
|
@@ -341,7 +334,7 @@ declare class DistriClient {
|
|
|
341
334
|
/**
|
|
342
335
|
* Get specific agent by ID
|
|
343
336
|
*/
|
|
344
|
-
getAgent(agentId: string): Promise<
|
|
337
|
+
getAgent(agentId: string): Promise<AgentConfigWithTools>;
|
|
345
338
|
/**
|
|
346
339
|
* Get or create A2AClient for an agent
|
|
347
340
|
*/
|
|
@@ -392,6 +385,9 @@ declare class DistriClient {
|
|
|
392
385
|
*/
|
|
393
386
|
get baseUrl(): string;
|
|
394
387
|
private applyTokens;
|
|
388
|
+
/**
|
|
389
|
+
* Ensure access token is valid, refreshing if necessary
|
|
390
|
+
*/
|
|
395
391
|
private ensureAccessToken;
|
|
396
392
|
private refreshTokens;
|
|
397
393
|
private performTokenRefresh;
|
|
@@ -405,9 +401,10 @@ declare class DistriClient {
|
|
|
405
401
|
*/
|
|
406
402
|
private fetchAbsolute;
|
|
407
403
|
/**
|
|
408
|
-
* Enhanced fetch with retry logic
|
|
404
|
+
* Enhanced fetch with retry logic and auth headers.
|
|
405
|
+
* Exposed publicly for extensions like DistriHomeClient.
|
|
409
406
|
*/
|
|
410
|
-
|
|
407
|
+
fetch(input: RequestInfo | URL, initialInit?: RequestInit): Promise<Response>;
|
|
411
408
|
/**
|
|
412
409
|
* Delay utility
|
|
413
410
|
*/
|
|
@@ -479,7 +476,7 @@ declare class Agent {
|
|
|
479
476
|
private agentDefinition;
|
|
480
477
|
private hookHandlers;
|
|
481
478
|
private defaultHookHandler;
|
|
482
|
-
constructor(agentDefinition:
|
|
479
|
+
constructor(agentDefinition: AgentConfigWithTools, client: DistriClient);
|
|
483
480
|
/**
|
|
484
481
|
* Get agent information
|
|
485
482
|
*/
|
|
@@ -491,7 +488,7 @@ declare class Agent {
|
|
|
491
488
|
/**
|
|
492
489
|
* Get the full agent definition (including backend tools)
|
|
493
490
|
*/
|
|
494
|
-
getDefinition():
|
|
491
|
+
getDefinition(): AgentConfigWithTools;
|
|
495
492
|
/**
|
|
496
493
|
* Fetch messages for a thread (public method for useChat)
|
|
497
494
|
*/
|
|
@@ -524,7 +521,7 @@ declare class Agent {
|
|
|
524
521
|
/**
|
|
525
522
|
* Create an agent instance from an agent ID
|
|
526
523
|
*/
|
|
527
|
-
static create(agentIdOrDef: string |
|
|
524
|
+
static create(agentIdOrDef: string | AgentConfigWithTools, client: DistriClient): Promise<Agent>;
|
|
528
525
|
/**
|
|
529
526
|
* Complete an external tool call by sending the result back to the server
|
|
530
527
|
*/
|
|
@@ -713,14 +710,18 @@ interface FileUrl {
|
|
|
713
710
|
name?: string;
|
|
714
711
|
}
|
|
715
712
|
type FileType = FileBytes | FileUrl;
|
|
713
|
+
interface ToolDefinition {
|
|
714
|
+
name: string;
|
|
715
|
+
description: string;
|
|
716
|
+
parameters: object;
|
|
717
|
+
examples?: string;
|
|
718
|
+
output_schema?: object;
|
|
719
|
+
}
|
|
716
720
|
/**
|
|
717
721
|
* Tool definition interface following AG-UI pattern
|
|
718
722
|
*/
|
|
719
|
-
interface DistriBaseTool {
|
|
720
|
-
name: string;
|
|
723
|
+
interface DistriBaseTool extends ToolDefinition {
|
|
721
724
|
type: 'function' | 'ui';
|
|
722
|
-
description: string;
|
|
723
|
-
parameters: object;
|
|
724
725
|
is_final?: boolean;
|
|
725
726
|
autoExecute?: boolean;
|
|
726
727
|
isExternal?: boolean;
|
|
@@ -776,6 +777,10 @@ declare function createFailedToolResult(toolCallId: string, toolName: string, er
|
|
|
776
777
|
* Handles both frontend DistriPart format and backend BackendPart format
|
|
777
778
|
*/
|
|
778
779
|
declare function extractToolResultData(toolResult: ToolResult): ToolResultData | null;
|
|
780
|
+
interface AgentConfigWithTools extends AgentDefinition {
|
|
781
|
+
markdown?: string;
|
|
782
|
+
resolved_tools?: ToolDefinition[];
|
|
783
|
+
}
|
|
779
784
|
/**
|
|
780
785
|
* Distri-specific Agent type that wraps A2A AgentCard
|
|
781
786
|
*/
|
|
@@ -795,6 +800,8 @@ interface AgentDefinition {
|
|
|
795
800
|
mcp_servers?: McpDefinition[];
|
|
796
801
|
/** Settings related to the model used by the agent. */
|
|
797
802
|
model_settings?: ModelSettings;
|
|
803
|
+
/** Secondary Model Settings used for analysis */
|
|
804
|
+
analysis_model_settings?: ModelSettings;
|
|
798
805
|
/** The size of the history to maintain for the agent. */
|
|
799
806
|
history_size?: number;
|
|
800
807
|
/** The planning configuration for the agent, if any. */
|
|
@@ -805,8 +812,8 @@ interface AgentDefinition {
|
|
|
805
812
|
skills?: AgentSkill[];
|
|
806
813
|
/** List of sub-agents that this agent can transfer control to */
|
|
807
814
|
sub_agents?: string[];
|
|
808
|
-
agentType?: string;
|
|
809
815
|
agent_type?: string;
|
|
816
|
+
context_size?: number;
|
|
810
817
|
tools?: DistriBaseTool[];
|
|
811
818
|
browser_config?: BrowserAgentConfig;
|
|
812
819
|
}
|
|
@@ -940,6 +947,11 @@ interface DistriClientConfig {
|
|
|
940
947
|
* Request interceptor for modifying requests before sending
|
|
941
948
|
*/
|
|
942
949
|
interceptor?: (init?: RequestInit) => Promise<RequestInit | undefined>;
|
|
950
|
+
/**
|
|
951
|
+
* Hook to refresh the access token when it expires.
|
|
952
|
+
* Useful for public clients where only an access token is available.
|
|
953
|
+
*/
|
|
954
|
+
onTokenRefresh?: () => Promise<string | null>;
|
|
943
955
|
/**
|
|
944
956
|
* Access token for bearer auth (optional)
|
|
945
957
|
*/
|
|
@@ -953,12 +965,9 @@ interface DistriClientConfig {
|
|
|
953
965
|
*/
|
|
954
966
|
tokenRefreshSkewMs?: number;
|
|
955
967
|
/**
|
|
956
|
-
*
|
|
968
|
+
* Client ID from Distri Cloud.
|
|
957
969
|
*/
|
|
958
|
-
|
|
959
|
-
accessToken: string;
|
|
960
|
-
refreshToken: string;
|
|
961
|
-
}) => void;
|
|
970
|
+
clientId?: string;
|
|
962
971
|
}
|
|
963
972
|
interface LLMResponse {
|
|
964
973
|
finish_reason: string;
|
|
@@ -1069,4 +1078,4 @@ declare function extractToolCallsFromDistriMessage(message: DistriMessage): any[
|
|
|
1069
1078
|
*/
|
|
1070
1079
|
declare function extractToolResultsFromDistriMessage(message: DistriMessage): any[];
|
|
1071
1080
|
|
|
1072
|
-
export { A2AProtocolError, type A2AStreamEventData, type ActionPlanStep, Agent, 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 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 };
|
|
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 };
|