@cadraos/sdk 0.3.14 → 0.3.16-dev.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/chat/index.cjs +165 -2
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +136 -2
- package/dist/chat/index.d.ts +136 -2
- package/dist/chat/index.js +163 -3
- package/dist/chat/index.js.map +1 -1
- package/dist/index.cjs +65 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -4
- package/dist/index.d.ts +112 -4
- package/dist/index.js +63 -3
- package/dist/index.js.map +1 -1
- package/dist/kanban/index.cjs +62 -2
- package/dist/kanban/index.cjs.map +1 -1
- package/dist/kanban/index.d.cts +91 -1
- package/dist/kanban/index.d.ts +91 -1
- package/dist/kanban/index.js +62 -2
- package/dist/kanban/index.js.map +1 -1
- package/dist/teams/index.cjs +62 -2
- package/dist/teams/index.cjs.map +1 -1
- package/dist/teams/index.d.cts +91 -1
- package/dist/teams/index.d.ts +91 -1
- package/dist/teams/index.js +62 -2
- package/dist/teams/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -65,7 +65,8 @@ interface RequestOptions {
|
|
|
65
65
|
/**
|
|
66
66
|
* Per-request timeout in milliseconds. Overrides the client-wide
|
|
67
67
|
* `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
|
|
68
|
-
*
|
|
68
|
+
* waits for the server's route ceiling while every other call keeps the
|
|
69
|
+
* 30 s default).
|
|
69
70
|
*/
|
|
70
71
|
timeoutMs?: number;
|
|
71
72
|
}
|
|
@@ -77,6 +78,8 @@ declare class HttpClient {
|
|
|
77
78
|
private tokenRefreshAttempts;
|
|
78
79
|
private readonly maxTokenRefreshAttempts;
|
|
79
80
|
constructor(config: HttpClientConfig);
|
|
81
|
+
/** The client-wide request timeout (ms) this client was configured with. */
|
|
82
|
+
get timeoutMs(): number;
|
|
80
83
|
/**
|
|
81
84
|
* Get authorization header value
|
|
82
85
|
*/
|
|
@@ -387,6 +390,51 @@ interface ExecuteResponse {
|
|
|
387
390
|
/** Initial status */
|
|
388
391
|
status: ExecutionStatus;
|
|
389
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* Languages an agent message can be stored and rendered in.
|
|
395
|
+
*/
|
|
396
|
+
type AgentMessageLang = 'en' | 'es' | 'id';
|
|
397
|
+
/**
|
|
398
|
+
* One saved agent message (e.g. `handoff.requested`), text per language.
|
|
399
|
+
*/
|
|
400
|
+
interface AgentMessage {
|
|
401
|
+
/** Lowercase dotted key, e.g. `chat.welcome` */
|
|
402
|
+
key: string;
|
|
403
|
+
/** Text per language; `en` is the fallback language */
|
|
404
|
+
text: Partial<Record<AgentMessageLang, string>>;
|
|
405
|
+
/** `{word}` placeholder names found in any language */
|
|
406
|
+
placeholders: string[];
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Response of `client.agents.messages.list()`
|
|
410
|
+
*/
|
|
411
|
+
interface AgentMessageList {
|
|
412
|
+
/** The resolved agent (a team uuid resolves to its lead agent) */
|
|
413
|
+
agentUuid: string;
|
|
414
|
+
/** The agent's saved messages, sorted by key */
|
|
415
|
+
messages: AgentMessage[];
|
|
416
|
+
/** Every key the platform knows about, for pickers (saved or not) */
|
|
417
|
+
knownKeys: string[];
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Options for `client.agents.messages.render()`
|
|
421
|
+
*/
|
|
422
|
+
interface AgentMessageRenderOptions {
|
|
423
|
+
/** Requested language; falls back to `en` server-side */
|
|
424
|
+
lang?: AgentMessageLang;
|
|
425
|
+
/** Values for `{word}` placeholders; unknown placeholders are left as-is */
|
|
426
|
+
vars?: Record<string, string | number>;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Response of `client.agents.messages.render()`
|
|
430
|
+
*/
|
|
431
|
+
interface AgentMessageRenderResult {
|
|
432
|
+
key: string;
|
|
433
|
+
/** The language actually rendered */
|
|
434
|
+
lang: AgentMessageLang;
|
|
435
|
+
/** Filled text, or `null` when the agent has no message for this key */
|
|
436
|
+
text: string | null;
|
|
437
|
+
}
|
|
390
438
|
|
|
391
439
|
/**
|
|
392
440
|
* Skill types
|
|
@@ -1844,6 +1892,46 @@ interface StreamImagesResult {
|
|
|
1844
1892
|
*/
|
|
1845
1893
|
declare function collectImagesFromStream(stream: ExecutionStreamController, options?: CollectImagesOptions): Promise<StreamImagesResult>;
|
|
1846
1894
|
|
|
1895
|
+
/**
|
|
1896
|
+
* Agent Messages Resource API (p13)
|
|
1897
|
+
*
|
|
1898
|
+
* Read-only access to an agent's saved messages (welcome, handoff, fallback
|
|
1899
|
+
* copy, ...). Reached as `client.agents.messages`.
|
|
1900
|
+
* - list(): the agent's saved messages + every known key
|
|
1901
|
+
* - render(): one message filled with vars, in a language (falls back to en)
|
|
1902
|
+
*/
|
|
1903
|
+
|
|
1904
|
+
declare class AgentMessagesAPI extends BaseResourceAPI {
|
|
1905
|
+
constructor(http: HttpClient);
|
|
1906
|
+
/**
|
|
1907
|
+
* List an agent's saved messages and the known keys
|
|
1908
|
+
*
|
|
1909
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
1910
|
+
*
|
|
1911
|
+
* @example
|
|
1912
|
+
* ```typescript
|
|
1913
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
1914
|
+
* ```
|
|
1915
|
+
*/
|
|
1916
|
+
list(agentUuid: string): Promise<AgentMessageList>;
|
|
1917
|
+
/**
|
|
1918
|
+
* Render one message with placeholders filled
|
|
1919
|
+
*
|
|
1920
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
1921
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
1922
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
1923
|
+
*
|
|
1924
|
+
* @example
|
|
1925
|
+
* ```typescript
|
|
1926
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
1927
|
+
* lang: 'es',
|
|
1928
|
+
* vars: { agentName: 'Ana' },
|
|
1929
|
+
* });
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1932
|
+
render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1847
1935
|
/**
|
|
1848
1936
|
* Agents Resource API
|
|
1849
1937
|
*
|
|
@@ -1859,6 +1947,8 @@ declare function collectImagesFromStream(stream: ExecutionStreamController, opti
|
|
|
1859
1947
|
*/
|
|
1860
1948
|
declare class AgentsAPI extends BaseResourceAPI {
|
|
1861
1949
|
private readonly getStreamConfig;
|
|
1950
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
1951
|
+
readonly messages: AgentMessagesAPI;
|
|
1862
1952
|
constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
|
|
1863
1953
|
/**
|
|
1864
1954
|
* List all agents in the organization
|
|
@@ -3421,8 +3511,15 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
|
|
|
3421
3511
|
* ```
|
|
3422
3512
|
*/
|
|
3423
3513
|
|
|
3424
|
-
/**
|
|
3425
|
-
|
|
3514
|
+
/**
|
|
3515
|
+
* How long the client waits for a paid run. It tracks cadra-web
|
|
3516
|
+
* `AI_FUNCTION_ROUTE_MAX_MS` (300 s, the Vercel `maxDuration` of the run
|
|
3517
|
+
* routes) plus 10 s, so the server always answers first — with the result or
|
|
3518
|
+
* with its own `failed_timeout` — and the client never abandons a run the
|
|
3519
|
+
* server is still finishing. A larger client-wide `timeout` wins.
|
|
3520
|
+
* (Was 60 s, from the old p93 D6 route budget.)
|
|
3521
|
+
*/
|
|
3522
|
+
declare const AI_FUNCTION_RUN_TIMEOUT_MS = 310000;
|
|
3426
3523
|
/** Descriptors used by the client-side check are cached per client for 60 s (D27c). */
|
|
3427
3524
|
declare const AI_FUNCTION_DESCRIPTOR_TTL_MS = 60000;
|
|
3428
3525
|
/**
|
|
@@ -3655,6 +3752,17 @@ declare class CadraClient {
|
|
|
3655
3752
|
private validateOptions;
|
|
3656
3753
|
}
|
|
3657
3754
|
|
|
3755
|
+
/**
|
|
3756
|
+
* Agent message keys (p13) — lowercase dotted, e.g. `chat.welcome`.
|
|
3757
|
+
*
|
|
3758
|
+
* Same rule cadra-web enforces on `/api/v1/agents/:id/messages/render`, so an
|
|
3759
|
+
* invalid key fails client-side before a request is made. Kept free of any
|
|
3760
|
+
* client import so the chat entry can use it without pulling in the client.
|
|
3761
|
+
*/
|
|
3762
|
+
declare const MESSAGE_KEY_PATTERN: RegExp;
|
|
3763
|
+
/** True when `key` is a valid lowercase dotted agent message key. */
|
|
3764
|
+
declare function isValidMessageKey(key: string): boolean;
|
|
3765
|
+
|
|
3658
3766
|
/**
|
|
3659
3767
|
* SDK Error Classes
|
|
3660
3768
|
*
|
|
@@ -3793,4 +3901,4 @@ declare class AiFunctionParameterError extends ValidationError {
|
|
|
3793
3901
|
constructor(functionKey: string, issues: AiFunctionParameterIssue[]);
|
|
3794
3902
|
}
|
|
3795
3903
|
|
|
3796
|
-
export { CadraClient as AISaaSClient, type CadraClientOptions as AISaaSClientOptions, CadraError as AISaaSError, AI_FUNCTION_DESCRIPTOR_TTL_MS, AI_FUNCTION_RUN_TIMEOUT_MS, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentStatus, type AgentType, type AgentUpdateInput, type AiFunctionBilledTo, AiFunctionChargedError, type AiFunctionDescriptor, AiFunctionDuplicateError, type AiFunctionImage, type AiFunctionOutput, type AiFunctionOutputKind, type AiFunctionParameter, AiFunctionParameterError, type AiFunctionParameterIssue, type AiFunctionParameterIssueCode, type AiFunctionParameterType, type AiFunctionRef, type AiFunctionRun, type AiFunctionRunOptions, type AiFunctionRunResult, type AiFunctionRunShorthandOptions, type AiFunctionRunStatus, type AiFunctionRuntimeParams, type AiFunctionUsage, type AiFunctionVariableValue, type AiFunctionVariables, AiFunctionsAPI, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, type AttachmentUploadUrlInput, type AttachmentUploadUrlResponse, AuthenticationError, AuthorizationError, CadraClient, type CadraClientOptions, CadraError, type CollectImagesOptions, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type ExtractContext, type ImageData, type ImageEvent, type JSONSchema, type ListOptions, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type RemoteAgent, type RemoteAgentCreateInput, type RemoteAgentExecuteResponse, type RemoteAgentExecutionTargetKind, type RemoteAgentListOptions, type RemoteAgentStatus, type RemoteAgentUpdateInput, type RemoteAgentVisibility, type RemoteRunner, type RemoteRunnerListOptions, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type StreamImagesResult, type TeamMemberRef, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError, checkAiFunctionParameters, collectImagesFromStream, deriveImagesFromToolCalls, extractImagesFromExecutionOutput, extractImagesFromResult };
|
|
3904
|
+
export { CadraClient as AISaaSClient, type CadraClientOptions as AISaaSClientOptions, CadraError as AISaaSError, AI_FUNCTION_DESCRIPTOR_TTL_MS, AI_FUNCTION_RUN_TIMEOUT_MS, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentMessage, type AgentMessageLang, type AgentMessageList, type AgentMessageRenderOptions, type AgentMessageRenderResult, AgentMessagesAPI, type AgentStatus, type AgentType, type AgentUpdateInput, type AiFunctionBilledTo, AiFunctionChargedError, type AiFunctionDescriptor, AiFunctionDuplicateError, type AiFunctionImage, type AiFunctionOutput, type AiFunctionOutputKind, type AiFunctionParameter, AiFunctionParameterError, type AiFunctionParameterIssue, type AiFunctionParameterIssueCode, type AiFunctionParameterType, type AiFunctionRef, type AiFunctionRun, type AiFunctionRunOptions, type AiFunctionRunResult, type AiFunctionRunShorthandOptions, type AiFunctionRunStatus, type AiFunctionRuntimeParams, type AiFunctionUsage, type AiFunctionVariableValue, type AiFunctionVariables, AiFunctionsAPI, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, type AttachmentUploadUrlInput, type AttachmentUploadUrlResponse, AuthenticationError, AuthorizationError, CadraClient, type CadraClientOptions, CadraError, type CollectImagesOptions, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type ExtractContext, type ImageData, type ImageEvent, type JSONSchema, type ListOptions, MESSAGE_KEY_PATTERN, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type RemoteAgent, type RemoteAgentCreateInput, type RemoteAgentExecuteResponse, type RemoteAgentExecutionTargetKind, type RemoteAgentListOptions, type RemoteAgentStatus, type RemoteAgentUpdateInput, type RemoteAgentVisibility, type RemoteRunner, type RemoteRunnerListOptions, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type StreamImagesResult, type TeamMemberRef, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError, checkAiFunctionParameters, collectImagesFromStream, deriveImagesFromToolCalls, extractImagesFromExecutionOutput, extractImagesFromResult, isValidMessageKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -65,7 +65,8 @@ interface RequestOptions {
|
|
|
65
65
|
/**
|
|
66
66
|
* Per-request timeout in milliseconds. Overrides the client-wide
|
|
67
67
|
* `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
|
|
68
|
-
*
|
|
68
|
+
* waits for the server's route ceiling while every other call keeps the
|
|
69
|
+
* 30 s default).
|
|
69
70
|
*/
|
|
70
71
|
timeoutMs?: number;
|
|
71
72
|
}
|
|
@@ -77,6 +78,8 @@ declare class HttpClient {
|
|
|
77
78
|
private tokenRefreshAttempts;
|
|
78
79
|
private readonly maxTokenRefreshAttempts;
|
|
79
80
|
constructor(config: HttpClientConfig);
|
|
81
|
+
/** The client-wide request timeout (ms) this client was configured with. */
|
|
82
|
+
get timeoutMs(): number;
|
|
80
83
|
/**
|
|
81
84
|
* Get authorization header value
|
|
82
85
|
*/
|
|
@@ -387,6 +390,51 @@ interface ExecuteResponse {
|
|
|
387
390
|
/** Initial status */
|
|
388
391
|
status: ExecutionStatus;
|
|
389
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* Languages an agent message can be stored and rendered in.
|
|
395
|
+
*/
|
|
396
|
+
type AgentMessageLang = 'en' | 'es' | 'id';
|
|
397
|
+
/**
|
|
398
|
+
* One saved agent message (e.g. `handoff.requested`), text per language.
|
|
399
|
+
*/
|
|
400
|
+
interface AgentMessage {
|
|
401
|
+
/** Lowercase dotted key, e.g. `chat.welcome` */
|
|
402
|
+
key: string;
|
|
403
|
+
/** Text per language; `en` is the fallback language */
|
|
404
|
+
text: Partial<Record<AgentMessageLang, string>>;
|
|
405
|
+
/** `{word}` placeholder names found in any language */
|
|
406
|
+
placeholders: string[];
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Response of `client.agents.messages.list()`
|
|
410
|
+
*/
|
|
411
|
+
interface AgentMessageList {
|
|
412
|
+
/** The resolved agent (a team uuid resolves to its lead agent) */
|
|
413
|
+
agentUuid: string;
|
|
414
|
+
/** The agent's saved messages, sorted by key */
|
|
415
|
+
messages: AgentMessage[];
|
|
416
|
+
/** Every key the platform knows about, for pickers (saved or not) */
|
|
417
|
+
knownKeys: string[];
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Options for `client.agents.messages.render()`
|
|
421
|
+
*/
|
|
422
|
+
interface AgentMessageRenderOptions {
|
|
423
|
+
/** Requested language; falls back to `en` server-side */
|
|
424
|
+
lang?: AgentMessageLang;
|
|
425
|
+
/** Values for `{word}` placeholders; unknown placeholders are left as-is */
|
|
426
|
+
vars?: Record<string, string | number>;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Response of `client.agents.messages.render()`
|
|
430
|
+
*/
|
|
431
|
+
interface AgentMessageRenderResult {
|
|
432
|
+
key: string;
|
|
433
|
+
/** The language actually rendered */
|
|
434
|
+
lang: AgentMessageLang;
|
|
435
|
+
/** Filled text, or `null` when the agent has no message for this key */
|
|
436
|
+
text: string | null;
|
|
437
|
+
}
|
|
390
438
|
|
|
391
439
|
/**
|
|
392
440
|
* Skill types
|
|
@@ -1844,6 +1892,46 @@ interface StreamImagesResult {
|
|
|
1844
1892
|
*/
|
|
1845
1893
|
declare function collectImagesFromStream(stream: ExecutionStreamController, options?: CollectImagesOptions): Promise<StreamImagesResult>;
|
|
1846
1894
|
|
|
1895
|
+
/**
|
|
1896
|
+
* Agent Messages Resource API (p13)
|
|
1897
|
+
*
|
|
1898
|
+
* Read-only access to an agent's saved messages (welcome, handoff, fallback
|
|
1899
|
+
* copy, ...). Reached as `client.agents.messages`.
|
|
1900
|
+
* - list(): the agent's saved messages + every known key
|
|
1901
|
+
* - render(): one message filled with vars, in a language (falls back to en)
|
|
1902
|
+
*/
|
|
1903
|
+
|
|
1904
|
+
declare class AgentMessagesAPI extends BaseResourceAPI {
|
|
1905
|
+
constructor(http: HttpClient);
|
|
1906
|
+
/**
|
|
1907
|
+
* List an agent's saved messages and the known keys
|
|
1908
|
+
*
|
|
1909
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
1910
|
+
*
|
|
1911
|
+
* @example
|
|
1912
|
+
* ```typescript
|
|
1913
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
1914
|
+
* ```
|
|
1915
|
+
*/
|
|
1916
|
+
list(agentUuid: string): Promise<AgentMessageList>;
|
|
1917
|
+
/**
|
|
1918
|
+
* Render one message with placeholders filled
|
|
1919
|
+
*
|
|
1920
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
1921
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
1922
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
1923
|
+
*
|
|
1924
|
+
* @example
|
|
1925
|
+
* ```typescript
|
|
1926
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
1927
|
+
* lang: 'es',
|
|
1928
|
+
* vars: { agentName: 'Ana' },
|
|
1929
|
+
* });
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1932
|
+
render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1847
1935
|
/**
|
|
1848
1936
|
* Agents Resource API
|
|
1849
1937
|
*
|
|
@@ -1859,6 +1947,8 @@ declare function collectImagesFromStream(stream: ExecutionStreamController, opti
|
|
|
1859
1947
|
*/
|
|
1860
1948
|
declare class AgentsAPI extends BaseResourceAPI {
|
|
1861
1949
|
private readonly getStreamConfig;
|
|
1950
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
1951
|
+
readonly messages: AgentMessagesAPI;
|
|
1862
1952
|
constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
|
|
1863
1953
|
/**
|
|
1864
1954
|
* List all agents in the organization
|
|
@@ -3421,8 +3511,15 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
|
|
|
3421
3511
|
* ```
|
|
3422
3512
|
*/
|
|
3423
3513
|
|
|
3424
|
-
/**
|
|
3425
|
-
|
|
3514
|
+
/**
|
|
3515
|
+
* How long the client waits for a paid run. It tracks cadra-web
|
|
3516
|
+
* `AI_FUNCTION_ROUTE_MAX_MS` (300 s, the Vercel `maxDuration` of the run
|
|
3517
|
+
* routes) plus 10 s, so the server always answers first — with the result or
|
|
3518
|
+
* with its own `failed_timeout` — and the client never abandons a run the
|
|
3519
|
+
* server is still finishing. A larger client-wide `timeout` wins.
|
|
3520
|
+
* (Was 60 s, from the old p93 D6 route budget.)
|
|
3521
|
+
*/
|
|
3522
|
+
declare const AI_FUNCTION_RUN_TIMEOUT_MS = 310000;
|
|
3426
3523
|
/** Descriptors used by the client-side check are cached per client for 60 s (D27c). */
|
|
3427
3524
|
declare const AI_FUNCTION_DESCRIPTOR_TTL_MS = 60000;
|
|
3428
3525
|
/**
|
|
@@ -3655,6 +3752,17 @@ declare class CadraClient {
|
|
|
3655
3752
|
private validateOptions;
|
|
3656
3753
|
}
|
|
3657
3754
|
|
|
3755
|
+
/**
|
|
3756
|
+
* Agent message keys (p13) — lowercase dotted, e.g. `chat.welcome`.
|
|
3757
|
+
*
|
|
3758
|
+
* Same rule cadra-web enforces on `/api/v1/agents/:id/messages/render`, so an
|
|
3759
|
+
* invalid key fails client-side before a request is made. Kept free of any
|
|
3760
|
+
* client import so the chat entry can use it without pulling in the client.
|
|
3761
|
+
*/
|
|
3762
|
+
declare const MESSAGE_KEY_PATTERN: RegExp;
|
|
3763
|
+
/** True when `key` is a valid lowercase dotted agent message key. */
|
|
3764
|
+
declare function isValidMessageKey(key: string): boolean;
|
|
3765
|
+
|
|
3658
3766
|
/**
|
|
3659
3767
|
* SDK Error Classes
|
|
3660
3768
|
*
|
|
@@ -3793,4 +3901,4 @@ declare class AiFunctionParameterError extends ValidationError {
|
|
|
3793
3901
|
constructor(functionKey: string, issues: AiFunctionParameterIssue[]);
|
|
3794
3902
|
}
|
|
3795
3903
|
|
|
3796
|
-
export { CadraClient as AISaaSClient, type CadraClientOptions as AISaaSClientOptions, CadraError as AISaaSError, AI_FUNCTION_DESCRIPTOR_TTL_MS, AI_FUNCTION_RUN_TIMEOUT_MS, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentStatus, type AgentType, type AgentUpdateInput, type AiFunctionBilledTo, AiFunctionChargedError, type AiFunctionDescriptor, AiFunctionDuplicateError, type AiFunctionImage, type AiFunctionOutput, type AiFunctionOutputKind, type AiFunctionParameter, AiFunctionParameterError, type AiFunctionParameterIssue, type AiFunctionParameterIssueCode, type AiFunctionParameterType, type AiFunctionRef, type AiFunctionRun, type AiFunctionRunOptions, type AiFunctionRunResult, type AiFunctionRunShorthandOptions, type AiFunctionRunStatus, type AiFunctionRuntimeParams, type AiFunctionUsage, type AiFunctionVariableValue, type AiFunctionVariables, AiFunctionsAPI, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, type AttachmentUploadUrlInput, type AttachmentUploadUrlResponse, AuthenticationError, AuthorizationError, CadraClient, type CadraClientOptions, CadraError, type CollectImagesOptions, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type ExtractContext, type ImageData, type ImageEvent, type JSONSchema, type ListOptions, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type RemoteAgent, type RemoteAgentCreateInput, type RemoteAgentExecuteResponse, type RemoteAgentExecutionTargetKind, type RemoteAgentListOptions, type RemoteAgentStatus, type RemoteAgentUpdateInput, type RemoteAgentVisibility, type RemoteRunner, type RemoteRunnerListOptions, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type StreamImagesResult, type TeamMemberRef, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError, checkAiFunctionParameters, collectImagesFromStream, deriveImagesFromToolCalls, extractImagesFromExecutionOutput, extractImagesFromResult };
|
|
3904
|
+
export { CadraClient as AISaaSClient, type CadraClientOptions as AISaaSClientOptions, CadraError as AISaaSError, AI_FUNCTION_DESCRIPTOR_TTL_MS, AI_FUNCTION_RUN_TIMEOUT_MS, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentMessage, type AgentMessageLang, type AgentMessageList, type AgentMessageRenderOptions, type AgentMessageRenderResult, AgentMessagesAPI, type AgentStatus, type AgentType, type AgentUpdateInput, type AiFunctionBilledTo, AiFunctionChargedError, type AiFunctionDescriptor, AiFunctionDuplicateError, type AiFunctionImage, type AiFunctionOutput, type AiFunctionOutputKind, type AiFunctionParameter, AiFunctionParameterError, type AiFunctionParameterIssue, type AiFunctionParameterIssueCode, type AiFunctionParameterType, type AiFunctionRef, type AiFunctionRun, type AiFunctionRunOptions, type AiFunctionRunResult, type AiFunctionRunShorthandOptions, type AiFunctionRunStatus, type AiFunctionRuntimeParams, type AiFunctionUsage, type AiFunctionVariableValue, type AiFunctionVariables, AiFunctionsAPI, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, type AttachmentUploadUrlInput, type AttachmentUploadUrlResponse, AuthenticationError, AuthorizationError, CadraClient, type CadraClientOptions, CadraError, type CollectImagesOptions, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type ExtractContext, type ImageData, type ImageEvent, type JSONSchema, type ListOptions, MESSAGE_KEY_PATTERN, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type RemoteAgent, type RemoteAgentCreateInput, type RemoteAgentExecuteResponse, type RemoteAgentExecutionTargetKind, type RemoteAgentListOptions, type RemoteAgentStatus, type RemoteAgentUpdateInput, type RemoteAgentVisibility, type RemoteRunner, type RemoteRunnerListOptions, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type StreamImagesResult, type TeamMemberRef, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError, checkAiFunctionParameters, collectImagesFromStream, deriveImagesFromToolCalls, extractImagesFromExecutionOutput, extractImagesFromResult, isValidMessageKey };
|
package/dist/index.js
CHANGED
|
@@ -287,6 +287,10 @@ var HttpClient = class {
|
|
|
287
287
|
constructor(config) {
|
|
288
288
|
this.config = config;
|
|
289
289
|
}
|
|
290
|
+
/** The client-wide request timeout (ms) this client was configured with. */
|
|
291
|
+
get timeoutMs() {
|
|
292
|
+
return this.config.timeout;
|
|
293
|
+
}
|
|
290
294
|
/**
|
|
291
295
|
* Get authorization header value
|
|
292
296
|
*/
|
|
@@ -1812,13 +1816,69 @@ function executionCancelPath(executionId) {
|
|
|
1812
1816
|
return `${EXECUTION_PATH}/${executionId}/cancel`;
|
|
1813
1817
|
}
|
|
1814
1818
|
|
|
1819
|
+
// src/utils/message-key.ts
|
|
1820
|
+
var MESSAGE_KEY_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/;
|
|
1821
|
+
function isValidMessageKey(key) {
|
|
1822
|
+
return MESSAGE_KEY_PATTERN.test(key);
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
// src/resources/agent-messages.ts
|
|
1826
|
+
var AgentMessagesAPI = class extends BaseResourceAPI {
|
|
1827
|
+
constructor(http) {
|
|
1828
|
+
super(http, "/api/v1/agents");
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* List an agent's saved messages and the known keys
|
|
1832
|
+
*
|
|
1833
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
1834
|
+
*
|
|
1835
|
+
* @example
|
|
1836
|
+
* ```typescript
|
|
1837
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
1838
|
+
* ```
|
|
1839
|
+
*/
|
|
1840
|
+
async list(agentUuid) {
|
|
1841
|
+
return this.httpGet(`/${agentUuid}/messages`);
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Render one message with placeholders filled
|
|
1845
|
+
*
|
|
1846
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
1847
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
1848
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
1849
|
+
*
|
|
1850
|
+
* @example
|
|
1851
|
+
* ```typescript
|
|
1852
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
1853
|
+
* lang: 'es',
|
|
1854
|
+
* vars: { agentName: 'Ana' },
|
|
1855
|
+
* });
|
|
1856
|
+
* ```
|
|
1857
|
+
*/
|
|
1858
|
+
async render(agentUuid, key, options = {}) {
|
|
1859
|
+
if (!isValidMessageKey(key)) {
|
|
1860
|
+
throw new ValidationError(`Invalid message key "${key}"`, [
|
|
1861
|
+
{ field: "key", message: "Must be a lowercase dotted key, e.g. chat.welcome" }
|
|
1862
|
+
]);
|
|
1863
|
+
}
|
|
1864
|
+
return this.httpPost(`/${agentUuid}/messages/render`, {
|
|
1865
|
+
key,
|
|
1866
|
+
...options.lang ? { lang: options.lang } : {},
|
|
1867
|
+
...options.vars ? { vars: options.vars } : {}
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1815
1872
|
// src/resources/agents.ts
|
|
1816
1873
|
var AgentsAPI = class extends BaseResourceAPI {
|
|
1817
1874
|
constructor(http, getStreamConfig) {
|
|
1818
1875
|
super(http, "/api/v1/agents");
|
|
1819
1876
|
this.getStreamConfig = getStreamConfig;
|
|
1877
|
+
this.messages = new AgentMessagesAPI(http);
|
|
1820
1878
|
}
|
|
1821
1879
|
getStreamConfig;
|
|
1880
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
1881
|
+
messages;
|
|
1822
1882
|
// ===== LIST Operations =====
|
|
1823
1883
|
/**
|
|
1824
1884
|
* List all agents in the organization
|
|
@@ -3413,7 +3473,7 @@ var RemoteRunnersAPI = class extends BaseResourceAPI {
|
|
|
3413
3473
|
};
|
|
3414
3474
|
|
|
3415
3475
|
// src/resources/ai-functions.ts
|
|
3416
|
-
var AI_FUNCTION_RUN_TIMEOUT_MS =
|
|
3476
|
+
var AI_FUNCTION_RUN_TIMEOUT_MS = 31e4;
|
|
3417
3477
|
var AI_FUNCTION_DESCRIPTOR_TTL_MS = 6e4;
|
|
3418
3478
|
function checkAiFunctionParameters(parameters, variables) {
|
|
3419
3479
|
const issues = [];
|
|
@@ -3526,7 +3586,7 @@ var AiFunctionsAPI = class extends BaseResourceAPI {
|
|
|
3526
3586
|
try {
|
|
3527
3587
|
return await this.httpPost("/run", body, {
|
|
3528
3588
|
skipRetry: true,
|
|
3529
|
-
timeoutMs: AI_FUNCTION_RUN_TIMEOUT_MS
|
|
3589
|
+
timeoutMs: Math.max(AI_FUNCTION_RUN_TIMEOUT_MS, this.http.timeoutMs ?? 0)
|
|
3530
3590
|
});
|
|
3531
3591
|
} catch (error) {
|
|
3532
3592
|
throw this.mapRunError(error, functionKey);
|
|
@@ -3724,6 +3784,6 @@ var CadraClient = class {
|
|
|
3724
3784
|
}
|
|
3725
3785
|
};
|
|
3726
3786
|
|
|
3727
|
-
export { CadraClient as AISaaSClient, CadraError as AISaaSError, AI_FUNCTION_DESCRIPTOR_TTL_MS, AI_FUNCTION_RUN_TIMEOUT_MS, AiFunctionChargedError, AiFunctionDuplicateError, AiFunctionParameterError, AiFunctionsAPI, AuthenticationError, AuthorizationError, CadraClient, CadraError, ConflictError, NetworkError, NotFoundError, RateLimitError, ServerError, TimeoutError, ValidationError, checkAiFunctionParameters, collectImagesFromStream, deriveImagesFromToolCalls, extractImagesFromExecutionOutput, extractImagesFromResult };
|
|
3787
|
+
export { CadraClient as AISaaSClient, CadraError as AISaaSError, AI_FUNCTION_DESCRIPTOR_TTL_MS, AI_FUNCTION_RUN_TIMEOUT_MS, AgentMessagesAPI, AiFunctionChargedError, AiFunctionDuplicateError, AiFunctionParameterError, AiFunctionsAPI, AuthenticationError, AuthorizationError, CadraClient, CadraError, ConflictError, MESSAGE_KEY_PATTERN, NetworkError, NotFoundError, RateLimitError, ServerError, TimeoutError, ValidationError, checkAiFunctionParameters, collectImagesFromStream, deriveImagesFromToolCalls, extractImagesFromExecutionOutput, extractImagesFromResult, isValidMessageKey };
|
|
3728
3788
|
//# sourceMappingURL=index.js.map
|
|
3729
3789
|
//# sourceMappingURL=index.js.map
|