@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.
@@ -1179,6 +1179,51 @@ interface ExecuteResponse {
1179
1179
  /** Initial status */
1180
1180
  status: ExecutionStatus;
1181
1181
  }
1182
+ /**
1183
+ * Languages an agent message can be stored and rendered in.
1184
+ */
1185
+ type AgentMessageLang = 'en' | 'es' | 'id';
1186
+ /**
1187
+ * One saved agent message (e.g. `handoff.requested`), text per language.
1188
+ */
1189
+ interface AgentMessage {
1190
+ /** Lowercase dotted key, e.g. `chat.welcome` */
1191
+ key: string;
1192
+ /** Text per language; `en` is the fallback language */
1193
+ text: Partial<Record<AgentMessageLang, string>>;
1194
+ /** `{word}` placeholder names found in any language */
1195
+ placeholders: string[];
1196
+ }
1197
+ /**
1198
+ * Response of `client.agents.messages.list()`
1199
+ */
1200
+ interface AgentMessageList {
1201
+ /** The resolved agent (a team uuid resolves to its lead agent) */
1202
+ agentUuid: string;
1203
+ /** The agent's saved messages, sorted by key */
1204
+ messages: AgentMessage[];
1205
+ /** Every key the platform knows about, for pickers (saved or not) */
1206
+ knownKeys: string[];
1207
+ }
1208
+ /**
1209
+ * Options for `client.agents.messages.render()`
1210
+ */
1211
+ interface AgentMessageRenderOptions {
1212
+ /** Requested language; falls back to `en` server-side */
1213
+ lang?: AgentMessageLang;
1214
+ /** Values for `{word}` placeholders; unknown placeholders are left as-is */
1215
+ vars?: Record<string, string | number>;
1216
+ }
1217
+ /**
1218
+ * Response of `client.agents.messages.render()`
1219
+ */
1220
+ interface AgentMessageRenderResult {
1221
+ key: string;
1222
+ /** The language actually rendered */
1223
+ lang: AgentMessageLang;
1224
+ /** Filled text, or `null` when the agent has no message for this key */
1225
+ text: string | null;
1226
+ }
1182
1227
 
1183
1228
  /**
1184
1229
  * Image extraction utilities
@@ -3767,6 +3812,46 @@ interface StreamImagesResult {
3767
3812
  executionId: string;
3768
3813
  }
3769
3814
 
3815
+ /**
3816
+ * Agent Messages Resource API (p13)
3817
+ *
3818
+ * Read-only access to an agent's saved messages (welcome, handoff, fallback
3819
+ * copy, ...). Reached as `client.agents.messages`.
3820
+ * - list(): the agent's saved messages + every known key
3821
+ * - render(): one message filled with vars, in a language (falls back to en)
3822
+ */
3823
+
3824
+ declare class AgentMessagesAPI extends BaseResourceAPI {
3825
+ constructor(http: HttpClient);
3826
+ /**
3827
+ * List an agent's saved messages and the known keys
3828
+ *
3829
+ * @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
3830
+ *
3831
+ * @example
3832
+ * ```typescript
3833
+ * const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
3834
+ * ```
3835
+ */
3836
+ list(agentUuid: string): Promise<AgentMessageList>;
3837
+ /**
3838
+ * Render one message with placeholders filled
3839
+ *
3840
+ * Resolves with `text: null` when the agent has no message for the key.
3841
+ * Throws `ValidationError` before any request when the key is not a
3842
+ * lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
3843
+ *
3844
+ * @example
3845
+ * ```typescript
3846
+ * const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
3847
+ * lang: 'es',
3848
+ * vars: { agentName: 'Ana' },
3849
+ * });
3850
+ * ```
3851
+ */
3852
+ render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
3853
+ }
3854
+
3770
3855
  /**
3771
3856
  * Agents Resource API
3772
3857
  *
@@ -3782,6 +3867,8 @@ interface StreamImagesResult {
3782
3867
  */
3783
3868
  declare class AgentsAPI extends BaseResourceAPI {
3784
3869
  private readonly getStreamConfig;
3870
+ /** Saved agent messages (p13): `list()` and `render()` */
3871
+ readonly messages: AgentMessagesAPI;
3785
3872
  constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
3786
3873
  /**
3787
3874
  * List all agents in the organization
@@ -1179,6 +1179,51 @@ interface ExecuteResponse {
1179
1179
  /** Initial status */
1180
1180
  status: ExecutionStatus;
1181
1181
  }
1182
+ /**
1183
+ * Languages an agent message can be stored and rendered in.
1184
+ */
1185
+ type AgentMessageLang = 'en' | 'es' | 'id';
1186
+ /**
1187
+ * One saved agent message (e.g. `handoff.requested`), text per language.
1188
+ */
1189
+ interface AgentMessage {
1190
+ /** Lowercase dotted key, e.g. `chat.welcome` */
1191
+ key: string;
1192
+ /** Text per language; `en` is the fallback language */
1193
+ text: Partial<Record<AgentMessageLang, string>>;
1194
+ /** `{word}` placeholder names found in any language */
1195
+ placeholders: string[];
1196
+ }
1197
+ /**
1198
+ * Response of `client.agents.messages.list()`
1199
+ */
1200
+ interface AgentMessageList {
1201
+ /** The resolved agent (a team uuid resolves to its lead agent) */
1202
+ agentUuid: string;
1203
+ /** The agent's saved messages, sorted by key */
1204
+ messages: AgentMessage[];
1205
+ /** Every key the platform knows about, for pickers (saved or not) */
1206
+ knownKeys: string[];
1207
+ }
1208
+ /**
1209
+ * Options for `client.agents.messages.render()`
1210
+ */
1211
+ interface AgentMessageRenderOptions {
1212
+ /** Requested language; falls back to `en` server-side */
1213
+ lang?: AgentMessageLang;
1214
+ /** Values for `{word}` placeholders; unknown placeholders are left as-is */
1215
+ vars?: Record<string, string | number>;
1216
+ }
1217
+ /**
1218
+ * Response of `client.agents.messages.render()`
1219
+ */
1220
+ interface AgentMessageRenderResult {
1221
+ key: string;
1222
+ /** The language actually rendered */
1223
+ lang: AgentMessageLang;
1224
+ /** Filled text, or `null` when the agent has no message for this key */
1225
+ text: string | null;
1226
+ }
1182
1227
 
1183
1228
  /**
1184
1229
  * Image extraction utilities
@@ -3767,6 +3812,46 @@ interface StreamImagesResult {
3767
3812
  executionId: string;
3768
3813
  }
3769
3814
 
3815
+ /**
3816
+ * Agent Messages Resource API (p13)
3817
+ *
3818
+ * Read-only access to an agent's saved messages (welcome, handoff, fallback
3819
+ * copy, ...). Reached as `client.agents.messages`.
3820
+ * - list(): the agent's saved messages + every known key
3821
+ * - render(): one message filled with vars, in a language (falls back to en)
3822
+ */
3823
+
3824
+ declare class AgentMessagesAPI extends BaseResourceAPI {
3825
+ constructor(http: HttpClient);
3826
+ /**
3827
+ * List an agent's saved messages and the known keys
3828
+ *
3829
+ * @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
3830
+ *
3831
+ * @example
3832
+ * ```typescript
3833
+ * const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
3834
+ * ```
3835
+ */
3836
+ list(agentUuid: string): Promise<AgentMessageList>;
3837
+ /**
3838
+ * Render one message with placeholders filled
3839
+ *
3840
+ * Resolves with `text: null` when the agent has no message for the key.
3841
+ * Throws `ValidationError` before any request when the key is not a
3842
+ * lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
3843
+ *
3844
+ * @example
3845
+ * ```typescript
3846
+ * const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
3847
+ * lang: 'es',
3848
+ * vars: { agentName: 'Ana' },
3849
+ * });
3850
+ * ```
3851
+ */
3852
+ render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
3853
+ }
3854
+
3770
3855
  /**
3771
3856
  * Agents Resource API
3772
3857
  *
@@ -3782,6 +3867,8 @@ interface StreamImagesResult {
3782
3867
  */
3783
3868
  declare class AgentsAPI extends BaseResourceAPI {
3784
3869
  private readonly getStreamConfig;
3870
+ /** Saved agent messages (p13): `list()` and `render()` */
3871
+ readonly messages: AgentMessagesAPI;
3785
3872
  constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
3786
3873
  /**
3787
3874
  * List all agents in the organization
@@ -5410,13 +5410,69 @@ function executionCancelPath(executionId) {
5410
5410
  return `${EXECUTION_PATH}/${executionId}/cancel`;
5411
5411
  }
5412
5412
 
5413
+ // src/utils/message-key.ts
5414
+ var MESSAGE_KEY_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/;
5415
+ function isValidMessageKey(key) {
5416
+ return MESSAGE_KEY_PATTERN.test(key);
5417
+ }
5418
+
5419
+ // src/resources/agent-messages.ts
5420
+ var AgentMessagesAPI = class extends BaseResourceAPI {
5421
+ constructor(http) {
5422
+ super(http, "/api/v1/agents");
5423
+ }
5424
+ /**
5425
+ * List an agent's saved messages and the known keys
5426
+ *
5427
+ * @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
5428
+ *
5429
+ * @example
5430
+ * ```typescript
5431
+ * const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
5432
+ * ```
5433
+ */
5434
+ async list(agentUuid) {
5435
+ return this.httpGet(`/${agentUuid}/messages`);
5436
+ }
5437
+ /**
5438
+ * Render one message with placeholders filled
5439
+ *
5440
+ * Resolves with `text: null` when the agent has no message for the key.
5441
+ * Throws `ValidationError` before any request when the key is not a
5442
+ * lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
5443
+ *
5444
+ * @example
5445
+ * ```typescript
5446
+ * const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
5447
+ * lang: 'es',
5448
+ * vars: { agentName: 'Ana' },
5449
+ * });
5450
+ * ```
5451
+ */
5452
+ async render(agentUuid, key, options = {}) {
5453
+ if (!isValidMessageKey(key)) {
5454
+ throw new ValidationError(`Invalid message key "${key}"`, [
5455
+ { field: "key", message: "Must be a lowercase dotted key, e.g. chat.welcome" }
5456
+ ]);
5457
+ }
5458
+ return this.httpPost(`/${agentUuid}/messages/render`, {
5459
+ key,
5460
+ ...options.lang ? { lang: options.lang } : {},
5461
+ ...options.vars ? { vars: options.vars } : {}
5462
+ });
5463
+ }
5464
+ };
5465
+
5413
5466
  // src/resources/agents.ts
5414
5467
  var AgentsAPI = class extends BaseResourceAPI {
5415
5468
  constructor(http, getStreamConfig) {
5416
5469
  super(http, "/api/v1/agents");
5417
5470
  this.getStreamConfig = getStreamConfig;
5471
+ this.messages = new AgentMessagesAPI(http);
5418
5472
  }
5419
5473
  getStreamConfig;
5474
+ /** Saved agent messages (p13): `list()` and `render()` */
5475
+ messages;
5420
5476
  // ===== LIST Operations =====
5421
5477
  /**
5422
5478
  * List all agents in the organization