@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.
@@ -312,6 +312,10 @@ var HttpClient = class {
312
312
  constructor(config) {
313
313
  this.config = config;
314
314
  }
315
+ /** The client-wide request timeout (ms) this client was configured with. */
316
+ get timeoutMs() {
317
+ return this.config.timeout;
318
+ }
315
319
  /**
316
320
  * Get authorization header value
317
321
  */
@@ -1827,13 +1831,69 @@ function executionCancelPath(executionId) {
1827
1831
  return `${EXECUTION_PATH}/${executionId}/cancel`;
1828
1832
  }
1829
1833
 
1834
+ // src/utils/message-key.ts
1835
+ var MESSAGE_KEY_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/;
1836
+ function isValidMessageKey(key) {
1837
+ return MESSAGE_KEY_PATTERN.test(key);
1838
+ }
1839
+
1840
+ // src/resources/agent-messages.ts
1841
+ var AgentMessagesAPI = class extends BaseResourceAPI {
1842
+ constructor(http) {
1843
+ super(http, "/api/v1/agents");
1844
+ }
1845
+ /**
1846
+ * List an agent's saved messages and the known keys
1847
+ *
1848
+ * @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
1849
+ *
1850
+ * @example
1851
+ * ```typescript
1852
+ * const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
1853
+ * ```
1854
+ */
1855
+ async list(agentUuid) {
1856
+ return this.httpGet(`/${agentUuid}/messages`);
1857
+ }
1858
+ /**
1859
+ * Render one message with placeholders filled
1860
+ *
1861
+ * Resolves with `text: null` when the agent has no message for the key.
1862
+ * Throws `ValidationError` before any request when the key is not a
1863
+ * lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
1864
+ *
1865
+ * @example
1866
+ * ```typescript
1867
+ * const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
1868
+ * lang: 'es',
1869
+ * vars: { agentName: 'Ana' },
1870
+ * });
1871
+ * ```
1872
+ */
1873
+ async render(agentUuid, key, options = {}) {
1874
+ if (!isValidMessageKey(key)) {
1875
+ throw new ValidationError(`Invalid message key "${key}"`, [
1876
+ { field: "key", message: "Must be a lowercase dotted key, e.g. chat.welcome" }
1877
+ ]);
1878
+ }
1879
+ return this.httpPost(`/${agentUuid}/messages/render`, {
1880
+ key,
1881
+ ...options.lang ? { lang: options.lang } : {},
1882
+ ...options.vars ? { vars: options.vars } : {}
1883
+ });
1884
+ }
1885
+ };
1886
+
1830
1887
  // src/resources/agents.ts
1831
1888
  var AgentsAPI = class extends BaseResourceAPI {
1832
1889
  constructor(http, getStreamConfig) {
1833
1890
  super(http, "/api/v1/agents");
1834
1891
  this.getStreamConfig = getStreamConfig;
1892
+ this.messages = new AgentMessagesAPI(http);
1835
1893
  }
1836
1894
  getStreamConfig;
1895
+ /** Saved agent messages (p13): `list()` and `render()` */
1896
+ messages;
1837
1897
  // ===== LIST Operations =====
1838
1898
  /**
1839
1899
  * List all agents in the organization
@@ -3428,7 +3488,7 @@ var RemoteRunnersAPI = class extends BaseResourceAPI {
3428
3488
  };
3429
3489
 
3430
3490
  // src/resources/ai-functions.ts
3431
- var AI_FUNCTION_RUN_TIMEOUT_MS = 6e4;
3491
+ var AI_FUNCTION_RUN_TIMEOUT_MS = 31e4;
3432
3492
  var AI_FUNCTION_DESCRIPTOR_TTL_MS = 6e4;
3433
3493
  function checkAiFunctionParameters(parameters, variables) {
3434
3494
  const issues = [];
@@ -3541,7 +3601,7 @@ var AiFunctionsAPI = class extends BaseResourceAPI {
3541
3601
  try {
3542
3602
  return await this.httpPost("/run", body, {
3543
3603
  skipRetry: true,
3544
- timeoutMs: AI_FUNCTION_RUN_TIMEOUT_MS
3604
+ timeoutMs: Math.max(AI_FUNCTION_RUN_TIMEOUT_MS, this.http.timeoutMs ?? 0)
3545
3605
  });
3546
3606
  } catch (error) {
3547
3607
  throw this.mapRunError(error, functionKey);