@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.
package/dist/index.cjs CHANGED
@@ -1818,13 +1818,69 @@ function executionCancelPath(executionId) {
1818
1818
  return `${EXECUTION_PATH}/${executionId}/cancel`;
1819
1819
  }
1820
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, languages, defaultLanguage } = 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
+
1821
1874
  // src/resources/agents.ts
1822
1875
  var AgentsAPI = class extends BaseResourceAPI {
1823
1876
  constructor(http, getStreamConfig) {
1824
1877
  super(http, "/api/v1/agents");
1825
1878
  this.getStreamConfig = getStreamConfig;
1879
+ this.messages = new AgentMessagesAPI(http);
1826
1880
  }
1827
1881
  getStreamConfig;
1882
+ /** Saved agent messages (p13): `list()` and `render()` */
1883
+ messages;
1828
1884
  // ===== LIST Operations =====
1829
1885
  /**
1830
1886
  * List all agents in the organization
@@ -3734,6 +3790,7 @@ exports.AISaaSClient = CadraClient;
3734
3790
  exports.AISaaSError = CadraError;
3735
3791
  exports.AI_FUNCTION_DESCRIPTOR_TTL_MS = AI_FUNCTION_DESCRIPTOR_TTL_MS;
3736
3792
  exports.AI_FUNCTION_RUN_TIMEOUT_MS = AI_FUNCTION_RUN_TIMEOUT_MS;
3793
+ exports.AgentMessagesAPI = AgentMessagesAPI;
3737
3794
  exports.AiFunctionChargedError = AiFunctionChargedError;
3738
3795
  exports.AiFunctionDuplicateError = AiFunctionDuplicateError;
3739
3796
  exports.AiFunctionParameterError = AiFunctionParameterError;
@@ -3743,6 +3800,7 @@ exports.AuthorizationError = AuthorizationError;
3743
3800
  exports.CadraClient = CadraClient;
3744
3801
  exports.CadraError = CadraError;
3745
3802
  exports.ConflictError = ConflictError;
3803
+ exports.MESSAGE_KEY_PATTERN = MESSAGE_KEY_PATTERN;
3746
3804
  exports.NetworkError = NetworkError;
3747
3805
  exports.NotFoundError = NotFoundError;
3748
3806
  exports.RateLimitError = RateLimitError;
@@ -3754,5 +3812,6 @@ exports.collectImagesFromStream = collectImagesFromStream;
3754
3812
  exports.deriveImagesFromToolCalls = deriveImagesFromToolCalls;
3755
3813
  exports.extractImagesFromExecutionOutput = extractImagesFromExecutionOutput;
3756
3814
  exports.extractImagesFromResult = extractImagesFromResult;
3815
+ exports.isValidMessageKey = isValidMessageKey;
3757
3816
  //# sourceMappingURL=index.cjs.map
3758
3817
  //# sourceMappingURL=index.cjs.map