@cadraos/sdk 0.3.15 → 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.
@@ -393,6 +393,51 @@ interface ExecuteResponse {
393
393
  /** Initial status */
394
394
  status: ExecutionStatus;
395
395
  }
396
+ /**
397
+ * Languages an agent message can be stored and rendered in.
398
+ */
399
+ type AgentMessageLang = 'en' | 'es' | 'id';
400
+ /**
401
+ * One saved agent message (e.g. `handoff.requested`), text per language.
402
+ */
403
+ interface AgentMessage {
404
+ /** Lowercase dotted key, e.g. `chat.welcome` */
405
+ key: string;
406
+ /** Text per language; `en` is the fallback language */
407
+ text: Partial<Record<AgentMessageLang, string>>;
408
+ /** `{word}` placeholder names found in any language */
409
+ placeholders: string[];
410
+ }
411
+ /**
412
+ * Response of `client.agents.messages.list()`
413
+ */
414
+ interface AgentMessageList {
415
+ /** The resolved agent (a team uuid resolves to its lead agent) */
416
+ agentUuid: string;
417
+ /** The agent's saved messages, sorted by key */
418
+ messages: AgentMessage[];
419
+ /** Every key the platform knows about, for pickers (saved or not) */
420
+ knownKeys: string[];
421
+ }
422
+ /**
423
+ * Options for `client.agents.messages.render()`
424
+ */
425
+ interface AgentMessageRenderOptions {
426
+ /** Requested language; falls back to `en` server-side */
427
+ lang?: AgentMessageLang;
428
+ /** Values for `{word}` placeholders; unknown placeholders are left as-is */
429
+ vars?: Record<string, string | number>;
430
+ }
431
+ /**
432
+ * Response of `client.agents.messages.render()`
433
+ */
434
+ interface AgentMessageRenderResult {
435
+ key: string;
436
+ /** The language actually rendered */
437
+ lang: AgentMessageLang;
438
+ /** Filled text, or `null` when the agent has no message for this key */
439
+ text: string | null;
440
+ }
396
441
 
397
442
  /**
398
443
  * Skill types
@@ -1649,6 +1694,46 @@ interface StreamImagesResult {
1649
1694
  executionId: string;
1650
1695
  }
1651
1696
 
1697
+ /**
1698
+ * Agent Messages Resource API (p13)
1699
+ *
1700
+ * Read-only access to an agent's saved messages (welcome, handoff, fallback
1701
+ * copy, ...). Reached as `client.agents.messages`.
1702
+ * - list(): the agent's saved messages + every known key
1703
+ * - render(): one message filled with vars, in a language (falls back to en)
1704
+ */
1705
+
1706
+ declare class AgentMessagesAPI extends BaseResourceAPI {
1707
+ constructor(http: HttpClient);
1708
+ /**
1709
+ * List an agent's saved messages and the known keys
1710
+ *
1711
+ * @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
1712
+ *
1713
+ * @example
1714
+ * ```typescript
1715
+ * const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
1716
+ * ```
1717
+ */
1718
+ list(agentUuid: string): Promise<AgentMessageList>;
1719
+ /**
1720
+ * Render one message with placeholders filled
1721
+ *
1722
+ * Resolves with `text: null` when the agent has no message for the key.
1723
+ * Throws `ValidationError` before any request when the key is not a
1724
+ * lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
1725
+ *
1726
+ * @example
1727
+ * ```typescript
1728
+ * const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
1729
+ * lang: 'es',
1730
+ * vars: { agentName: 'Ana' },
1731
+ * });
1732
+ * ```
1733
+ */
1734
+ render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
1735
+ }
1736
+
1652
1737
  /**
1653
1738
  * Agents Resource API
1654
1739
  *
@@ -1664,6 +1749,8 @@ interface StreamImagesResult {
1664
1749
  */
1665
1750
  declare class AgentsAPI extends BaseResourceAPI {
1666
1751
  private readonly getStreamConfig;
1752
+ /** Saved agent messages (p13): `list()` and `render()` */
1753
+ readonly messages: AgentMessagesAPI;
1667
1754
  constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
1668
1755
  /**
1669
1756
  * List all agents in the organization
@@ -393,6 +393,51 @@ interface ExecuteResponse {
393
393
  /** Initial status */
394
394
  status: ExecutionStatus;
395
395
  }
396
+ /**
397
+ * Languages an agent message can be stored and rendered in.
398
+ */
399
+ type AgentMessageLang = 'en' | 'es' | 'id';
400
+ /**
401
+ * One saved agent message (e.g. `handoff.requested`), text per language.
402
+ */
403
+ interface AgentMessage {
404
+ /** Lowercase dotted key, e.g. `chat.welcome` */
405
+ key: string;
406
+ /** Text per language; `en` is the fallback language */
407
+ text: Partial<Record<AgentMessageLang, string>>;
408
+ /** `{word}` placeholder names found in any language */
409
+ placeholders: string[];
410
+ }
411
+ /**
412
+ * Response of `client.agents.messages.list()`
413
+ */
414
+ interface AgentMessageList {
415
+ /** The resolved agent (a team uuid resolves to its lead agent) */
416
+ agentUuid: string;
417
+ /** The agent's saved messages, sorted by key */
418
+ messages: AgentMessage[];
419
+ /** Every key the platform knows about, for pickers (saved or not) */
420
+ knownKeys: string[];
421
+ }
422
+ /**
423
+ * Options for `client.agents.messages.render()`
424
+ */
425
+ interface AgentMessageRenderOptions {
426
+ /** Requested language; falls back to `en` server-side */
427
+ lang?: AgentMessageLang;
428
+ /** Values for `{word}` placeholders; unknown placeholders are left as-is */
429
+ vars?: Record<string, string | number>;
430
+ }
431
+ /**
432
+ * Response of `client.agents.messages.render()`
433
+ */
434
+ interface AgentMessageRenderResult {
435
+ key: string;
436
+ /** The language actually rendered */
437
+ lang: AgentMessageLang;
438
+ /** Filled text, or `null` when the agent has no message for this key */
439
+ text: string | null;
440
+ }
396
441
 
397
442
  /**
398
443
  * Skill types
@@ -1649,6 +1694,46 @@ interface StreamImagesResult {
1649
1694
  executionId: string;
1650
1695
  }
1651
1696
 
1697
+ /**
1698
+ * Agent Messages Resource API (p13)
1699
+ *
1700
+ * Read-only access to an agent's saved messages (welcome, handoff, fallback
1701
+ * copy, ...). Reached as `client.agents.messages`.
1702
+ * - list(): the agent's saved messages + every known key
1703
+ * - render(): one message filled with vars, in a language (falls back to en)
1704
+ */
1705
+
1706
+ declare class AgentMessagesAPI extends BaseResourceAPI {
1707
+ constructor(http: HttpClient);
1708
+ /**
1709
+ * List an agent's saved messages and the known keys
1710
+ *
1711
+ * @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
1712
+ *
1713
+ * @example
1714
+ * ```typescript
1715
+ * const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
1716
+ * ```
1717
+ */
1718
+ list(agentUuid: string): Promise<AgentMessageList>;
1719
+ /**
1720
+ * Render one message with placeholders filled
1721
+ *
1722
+ * Resolves with `text: null` when the agent has no message for the key.
1723
+ * Throws `ValidationError` before any request when the key is not a
1724
+ * lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
1725
+ *
1726
+ * @example
1727
+ * ```typescript
1728
+ * const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
1729
+ * lang: 'es',
1730
+ * vars: { agentName: 'Ana' },
1731
+ * });
1732
+ * ```
1733
+ */
1734
+ render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
1735
+ }
1736
+
1652
1737
  /**
1653
1738
  * Agents Resource API
1654
1739
  *
@@ -1664,6 +1749,8 @@ interface StreamImagesResult {
1664
1749
  */
1665
1750
  declare class AgentsAPI extends BaseResourceAPI {
1666
1751
  private readonly getStreamConfig;
1752
+ /** Saved agent messages (p13): `list()` and `render()` */
1753
+ readonly messages: AgentMessagesAPI;
1667
1754
  constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
1668
1755
  /**
1669
1756
  * List all agents in the organization
@@ -1810,13 +1810,69 @@ function executionCancelPath(executionId) {
1810
1810
  return `${EXECUTION_PATH}/${executionId}/cancel`;
1811
1811
  }
1812
1812
 
1813
+ // src/utils/message-key.ts
1814
+ var MESSAGE_KEY_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/;
1815
+ function isValidMessageKey(key) {
1816
+ return MESSAGE_KEY_PATTERN.test(key);
1817
+ }
1818
+
1819
+ // src/resources/agent-messages.ts
1820
+ var AgentMessagesAPI = class extends BaseResourceAPI {
1821
+ constructor(http) {
1822
+ super(http, "/api/v1/agents");
1823
+ }
1824
+ /**
1825
+ * List an agent's saved messages and the known keys
1826
+ *
1827
+ * @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
1828
+ *
1829
+ * @example
1830
+ * ```typescript
1831
+ * const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
1832
+ * ```
1833
+ */
1834
+ async list(agentUuid) {
1835
+ return this.httpGet(`/${agentUuid}/messages`);
1836
+ }
1837
+ /**
1838
+ * Render one message with placeholders filled
1839
+ *
1840
+ * Resolves with `text: null` when the agent has no message for the key.
1841
+ * Throws `ValidationError` before any request when the key is not a
1842
+ * lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
1843
+ *
1844
+ * @example
1845
+ * ```typescript
1846
+ * const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
1847
+ * lang: 'es',
1848
+ * vars: { agentName: 'Ana' },
1849
+ * });
1850
+ * ```
1851
+ */
1852
+ async render(agentUuid, key, options = {}) {
1853
+ if (!isValidMessageKey(key)) {
1854
+ throw new ValidationError(`Invalid message key "${key}"`, [
1855
+ { field: "key", message: "Must be a lowercase dotted key, e.g. chat.welcome" }
1856
+ ]);
1857
+ }
1858
+ return this.httpPost(`/${agentUuid}/messages/render`, {
1859
+ key,
1860
+ ...options.lang ? { lang: options.lang } : {},
1861
+ ...options.vars ? { vars: options.vars } : {}
1862
+ });
1863
+ }
1864
+ };
1865
+
1813
1866
  // src/resources/agents.ts
1814
1867
  var AgentsAPI = class extends BaseResourceAPI {
1815
1868
  constructor(http, getStreamConfig) {
1816
1869
  super(http, "/api/v1/agents");
1817
1870
  this.getStreamConfig = getStreamConfig;
1871
+ this.messages = new AgentMessagesAPI(http);
1818
1872
  }
1819
1873
  getStreamConfig;
1874
+ /** Saved agent messages (p13): `list()` and `render()` */
1875
+ messages;
1820
1876
  // ===== LIST Operations =====
1821
1877
  /**
1822
1878
  * List all agents in the organization