@cadraos/sdk 0.3.15 → 0.3.16-dev.1

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.
@@ -1831,13 +1831,69 @@ function executionCancelPath(executionId) {
1831
1831
  return `${EXECUTION_PATH}/${executionId}/cancel`;
1832
1832
  }
1833
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, languages, defaultLanguage } = 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
+
1834
1887
  // src/resources/agents.ts
1835
1888
  var AgentsAPI = class extends BaseResourceAPI {
1836
1889
  constructor(http, getStreamConfig) {
1837
1890
  super(http, "/api/v1/agents");
1838
1891
  this.getStreamConfig = getStreamConfig;
1892
+ this.messages = new AgentMessagesAPI(http);
1839
1893
  }
1840
1894
  getStreamConfig;
1895
+ /** Saved agent messages (p13): `list()` and `render()` */
1896
+ messages;
1841
1897
  // ===== LIST Operations =====
1842
1898
  /**
1843
1899
  * List all agents in the organization