@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.cjs
CHANGED
|
@@ -289,6 +289,10 @@ var HttpClient = class {
|
|
|
289
289
|
constructor(config) {
|
|
290
290
|
this.config = config;
|
|
291
291
|
}
|
|
292
|
+
/** The client-wide request timeout (ms) this client was configured with. */
|
|
293
|
+
get timeoutMs() {
|
|
294
|
+
return this.config.timeout;
|
|
295
|
+
}
|
|
292
296
|
/**
|
|
293
297
|
* Get authorization header value
|
|
294
298
|
*/
|
|
@@ -1814,13 +1818,69 @@ function executionCancelPath(executionId) {
|
|
|
1814
1818
|
return `${EXECUTION_PATH}/${executionId}/cancel`;
|
|
1815
1819
|
}
|
|
1816
1820
|
|
|
1821
|
+
// src/utils/message-key.ts
|
|
1822
|
+
var MESSAGE_KEY_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/;
|
|
1823
|
+
function isValidMessageKey(key) {
|
|
1824
|
+
return MESSAGE_KEY_PATTERN.test(key);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
// src/resources/agent-messages.ts
|
|
1828
|
+
var AgentMessagesAPI = class extends BaseResourceAPI {
|
|
1829
|
+
constructor(http) {
|
|
1830
|
+
super(http, "/api/v1/agents");
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* List an agent's saved messages and the known keys
|
|
1834
|
+
*
|
|
1835
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
1836
|
+
*
|
|
1837
|
+
* @example
|
|
1838
|
+
* ```typescript
|
|
1839
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
1840
|
+
* ```
|
|
1841
|
+
*/
|
|
1842
|
+
async list(agentUuid) {
|
|
1843
|
+
return this.httpGet(`/${agentUuid}/messages`);
|
|
1844
|
+
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Render one message with placeholders filled
|
|
1847
|
+
*
|
|
1848
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
1849
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
1850
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
1851
|
+
*
|
|
1852
|
+
* @example
|
|
1853
|
+
* ```typescript
|
|
1854
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
1855
|
+
* lang: 'es',
|
|
1856
|
+
* vars: { agentName: 'Ana' },
|
|
1857
|
+
* });
|
|
1858
|
+
* ```
|
|
1859
|
+
*/
|
|
1860
|
+
async render(agentUuid, key, options = {}) {
|
|
1861
|
+
if (!isValidMessageKey(key)) {
|
|
1862
|
+
throw new ValidationError(`Invalid message key "${key}"`, [
|
|
1863
|
+
{ field: "key", message: "Must be a lowercase dotted key, e.g. chat.welcome" }
|
|
1864
|
+
]);
|
|
1865
|
+
}
|
|
1866
|
+
return this.httpPost(`/${agentUuid}/messages/render`, {
|
|
1867
|
+
key,
|
|
1868
|
+
...options.lang ? { lang: options.lang } : {},
|
|
1869
|
+
...options.vars ? { vars: options.vars } : {}
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1817
1874
|
// src/resources/agents.ts
|
|
1818
1875
|
var AgentsAPI = class extends BaseResourceAPI {
|
|
1819
1876
|
constructor(http, getStreamConfig) {
|
|
1820
1877
|
super(http, "/api/v1/agents");
|
|
1821
1878
|
this.getStreamConfig = getStreamConfig;
|
|
1879
|
+
this.messages = new AgentMessagesAPI(http);
|
|
1822
1880
|
}
|
|
1823
1881
|
getStreamConfig;
|
|
1882
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
1883
|
+
messages;
|
|
1824
1884
|
// ===== LIST Operations =====
|
|
1825
1885
|
/**
|
|
1826
1886
|
* List all agents in the organization
|
|
@@ -3415,7 +3475,7 @@ var RemoteRunnersAPI = class extends BaseResourceAPI {
|
|
|
3415
3475
|
};
|
|
3416
3476
|
|
|
3417
3477
|
// src/resources/ai-functions.ts
|
|
3418
|
-
var AI_FUNCTION_RUN_TIMEOUT_MS =
|
|
3478
|
+
var AI_FUNCTION_RUN_TIMEOUT_MS = 31e4;
|
|
3419
3479
|
var AI_FUNCTION_DESCRIPTOR_TTL_MS = 6e4;
|
|
3420
3480
|
function checkAiFunctionParameters(parameters, variables) {
|
|
3421
3481
|
const issues = [];
|
|
@@ -3528,7 +3588,7 @@ var AiFunctionsAPI = class extends BaseResourceAPI {
|
|
|
3528
3588
|
try {
|
|
3529
3589
|
return await this.httpPost("/run", body, {
|
|
3530
3590
|
skipRetry: true,
|
|
3531
|
-
timeoutMs: AI_FUNCTION_RUN_TIMEOUT_MS
|
|
3591
|
+
timeoutMs: Math.max(AI_FUNCTION_RUN_TIMEOUT_MS, this.http.timeoutMs ?? 0)
|
|
3532
3592
|
});
|
|
3533
3593
|
} catch (error) {
|
|
3534
3594
|
throw this.mapRunError(error, functionKey);
|
|
@@ -3730,6 +3790,7 @@ exports.AISaaSClient = CadraClient;
|
|
|
3730
3790
|
exports.AISaaSError = CadraError;
|
|
3731
3791
|
exports.AI_FUNCTION_DESCRIPTOR_TTL_MS = AI_FUNCTION_DESCRIPTOR_TTL_MS;
|
|
3732
3792
|
exports.AI_FUNCTION_RUN_TIMEOUT_MS = AI_FUNCTION_RUN_TIMEOUT_MS;
|
|
3793
|
+
exports.AgentMessagesAPI = AgentMessagesAPI;
|
|
3733
3794
|
exports.AiFunctionChargedError = AiFunctionChargedError;
|
|
3734
3795
|
exports.AiFunctionDuplicateError = AiFunctionDuplicateError;
|
|
3735
3796
|
exports.AiFunctionParameterError = AiFunctionParameterError;
|
|
@@ -3739,6 +3800,7 @@ exports.AuthorizationError = AuthorizationError;
|
|
|
3739
3800
|
exports.CadraClient = CadraClient;
|
|
3740
3801
|
exports.CadraError = CadraError;
|
|
3741
3802
|
exports.ConflictError = ConflictError;
|
|
3803
|
+
exports.MESSAGE_KEY_PATTERN = MESSAGE_KEY_PATTERN;
|
|
3742
3804
|
exports.NetworkError = NetworkError;
|
|
3743
3805
|
exports.NotFoundError = NotFoundError;
|
|
3744
3806
|
exports.RateLimitError = RateLimitError;
|
|
@@ -3750,5 +3812,6 @@ exports.collectImagesFromStream = collectImagesFromStream;
|
|
|
3750
3812
|
exports.deriveImagesFromToolCalls = deriveImagesFromToolCalls;
|
|
3751
3813
|
exports.extractImagesFromExecutionOutput = extractImagesFromExecutionOutput;
|
|
3752
3814
|
exports.extractImagesFromResult = extractImagesFromResult;
|
|
3815
|
+
exports.isValidMessageKey = isValidMessageKey;
|
|
3753
3816
|
//# sourceMappingURL=index.cjs.map
|
|
3754
3817
|
//# sourceMappingURL=index.cjs.map
|