@cadraos/sdk 0.3.14-p46.4 → 0.3.15

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.
Files changed (38) hide show
  1. package/README.md +104 -53
  2. package/dist/ai-functions/react/index.cjs +176 -0
  3. package/dist/ai-functions/react/index.cjs.map +1 -0
  4. package/dist/ai-functions/react/index.d.cts +129 -0
  5. package/dist/ai-functions/react/index.d.ts +129 -0
  6. package/dist/ai-functions/react/index.js +153 -0
  7. package/dist/ai-functions/react/index.js.map +1 -0
  8. package/dist/ai-functions/server/index.cjs +296 -0
  9. package/dist/ai-functions/server/index.cjs.map +1 -0
  10. package/dist/ai-functions/server/index.d.cts +334 -0
  11. package/dist/ai-functions/server/index.d.ts +334 -0
  12. package/dist/ai-functions/server/index.js +284 -0
  13. package/dist/ai-functions/server/index.js.map +1 -0
  14. package/dist/chat/index.cjs +303 -17
  15. package/dist/chat/index.cjs.map +1 -1
  16. package/dist/chat/index.d.cts +211 -0
  17. package/dist/chat/index.d.ts +211 -0
  18. package/dist/chat/index.js +303 -17
  19. package/dist/chat/index.js.map +1 -1
  20. package/dist/index.cjs +225 -3
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +279 -1
  23. package/dist/index.d.ts +279 -1
  24. package/dist/index.js +219 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/kanban/index.cjs +218 -3
  27. package/dist/kanban/index.cjs.map +1 -1
  28. package/dist/kanban/index.d.cts +211 -0
  29. package/dist/kanban/index.d.ts +211 -0
  30. package/dist/kanban/index.js +218 -3
  31. package/dist/kanban/index.js.map +1 -1
  32. package/dist/teams/index.cjs +218 -3
  33. package/dist/teams/index.cjs.map +1 -1
  34. package/dist/teams/index.d.cts +211 -0
  35. package/dist/teams/index.d.ts +211 -0
  36. package/dist/teams/index.js +218 -3
  37. package/dist/teams/index.js.map +1 -1
  38. package/package.json +21 -1
@@ -65,6 +65,13 @@ interface RequestOptions {
65
65
  skipRetry?: boolean;
66
66
  /** Idempotency key */
67
67
  idempotencyKey?: string;
68
+ /**
69
+ * Per-request timeout in milliseconds. Overrides the client-wide
70
+ * `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
71
+ * waits for the server's route ceiling while every other call keeps the
72
+ * 30 s default).
73
+ */
74
+ timeoutMs?: number;
68
75
  }
69
76
  /**
70
77
  * HTTP Client class
@@ -74,6 +81,8 @@ declare class HttpClient {
74
81
  private tokenRefreshAttempts;
75
82
  private readonly maxTokenRefreshAttempts;
76
83
  constructor(config: HttpClientConfig);
84
+ /** The client-wide request timeout (ms) this client was configured with. */
85
+ get timeoutMs(): number;
77
86
  /**
78
87
  * Get authorization header value
79
88
  */
@@ -96,6 +105,7 @@ declare class HttpClient {
96
105
  post<T>(path: string, body?: unknown, options?: {
97
106
  idempotencyKey?: string;
98
107
  skipRetry?: boolean;
108
+ timeoutMs?: number;
99
109
  }): Promise<T>;
100
110
  /**
101
111
  * PATCH request
@@ -1085,6 +1095,16 @@ interface ToolResultEvent {
1085
1095
  result: unknown;
1086
1096
  /** Duration in milliseconds */
1087
1097
  durationMs: number;
1098
+ /**
1099
+ * CAD-243: true when the tool call FAILED (the producer stamps
1100
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
1101
+ * older producers — consumers then fall back to the result shape.
1102
+ */
1103
+ isError?: boolean;
1104
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
1105
+ status?: string;
1106
+ /** CAD-243: error text for a failed call. */
1107
+ error?: string;
1088
1108
  /** See {@link ToolCallEvent.forwardedFrom} */
1089
1109
  forwardedFrom?: string;
1090
1110
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -1374,6 +1394,133 @@ interface StreamController {
1374
1394
  wait(): Promise<AgentExecution>;
1375
1395
  }
1376
1396
 
1397
+ /**
1398
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
1399
+ *
1400
+ * An AI function is a published prompt in the Cadra Prompts library that makes
1401
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
1402
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
1403
+ * by slot key.
1404
+ */
1405
+ /** Output kind of an AI function. */
1406
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
1407
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
1408
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
1409
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
1410
+ type AiFunctionVariableValue = string | number | boolean;
1411
+ /** Parameters (variables) for one run, keyed by parameter name. */
1412
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
1413
+ /** How a run names its function (§4). */
1414
+ type AiFunctionRef = {
1415
+ slot: string;
1416
+ } | {
1417
+ functionKey: string;
1418
+ } | {
1419
+ promptUuid: string;
1420
+ };
1421
+ /** One declared parameter of a function's live (golden) version — D27a. */
1422
+ interface AiFunctionParameter {
1423
+ name: string;
1424
+ type: AiFunctionParameterType;
1425
+ required: boolean;
1426
+ defaultValue?: AiFunctionVariableValue;
1427
+ maxLength?: number;
1428
+ options?: string[];
1429
+ description?: string;
1430
+ }
1431
+ /**
1432
+ * The discovery "index" entry for one callable function — D27a. Built from the
1433
+ * golden version snapshot; never carries prompt or system text.
1434
+ */
1435
+ interface AiFunctionDescriptor {
1436
+ functionKey: string;
1437
+ title: string;
1438
+ description?: string | null;
1439
+ outputKind: AiFunctionOutputKind;
1440
+ /** The live (golden) version number. */
1441
+ liveVersion: number;
1442
+ parameters: AiFunctionParameter[];
1443
+ /** JSON schema of the output, for `json` functions. */
1444
+ outputSchema?: Record<string, unknown> | null;
1445
+ }
1446
+ /** Who paid for a run (D4). */
1447
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
1448
+ /** Runtime params a slot may accept per run (D26d3). */
1449
+ interface AiFunctionRuntimeParams {
1450
+ aspect_ratio?: string;
1451
+ image_size?: string;
1452
+ }
1453
+ /** Options for the object form `run(ref, { variables, … })`. */
1454
+ interface AiFunctionRunOptions {
1455
+ /** Parameters for this run (sent as `variables`). */
1456
+ variables: AiFunctionVariables;
1457
+ /** Pin a published version number (D3d). Skips the client-side check. */
1458
+ version?: number;
1459
+ /** Idempotency key (uuid). Generated when omitted (D15). */
1460
+ idempotencyKey?: string;
1461
+ /** Slot runtime params (D26d3). */
1462
+ params?: AiFunctionRuntimeParams;
1463
+ /** `false` skips the client-side parameter check (D27c). Default true. */
1464
+ validate?: boolean;
1465
+ }
1466
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
1467
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
1468
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
1469
+ interface AiFunctionImage {
1470
+ mimeType: string;
1471
+ url?: string;
1472
+ bytes?: Uint8Array;
1473
+ }
1474
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
1475
+ type AiFunctionOutput<TOutput = unknown> = {
1476
+ type: 'text';
1477
+ text: string;
1478
+ } | {
1479
+ type: 'json';
1480
+ json: TOutput;
1481
+ } | {
1482
+ type: 'image';
1483
+ images: AiFunctionImage[];
1484
+ };
1485
+ /** Token and billing usage of a run (§4). */
1486
+ interface AiFunctionUsage {
1487
+ promptTokens: number;
1488
+ completionTokens: number;
1489
+ imageCount: number;
1490
+ billedTo: AiFunctionBilledTo;
1491
+ }
1492
+ /** Result of a successful run (§4). */
1493
+ interface AiFunctionRunResult<TOutput = unknown> {
1494
+ /** = the run's execution uuid (usage-ledger executionUuid). */
1495
+ executionId: string;
1496
+ functionUuid: string;
1497
+ version: number;
1498
+ output: AiFunctionOutput<TOutput>;
1499
+ usage: AiFunctionUsage;
1500
+ latencyMs: number;
1501
+ }
1502
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
1503
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
1504
+ /** Safe projection of one of the caller org's own runs (§6.5). */
1505
+ interface AiFunctionRun {
1506
+ executionId: string;
1507
+ ref: {
1508
+ slot?: string;
1509
+ functionKey?: string;
1510
+ promptUuid?: string;
1511
+ };
1512
+ version: number | null;
1513
+ status: AiFunctionRunStatus;
1514
+ errorCode: string | null;
1515
+ promptTokens: number | null;
1516
+ completionTokens: number | null;
1517
+ imageCount: number | null;
1518
+ latencyMs: number | null;
1519
+ billedTo: AiFunctionBilledTo | null;
1520
+ createdAt: string;
1521
+ finishedAt: string | null;
1522
+ }
1523
+
1377
1524
  /**
1378
1525
  * Base Resource API
1379
1526
  *
@@ -1402,6 +1549,7 @@ declare abstract class BaseResourceAPI {
1402
1549
  protected httpPost<T>(path: string, body?: unknown, options?: {
1403
1550
  idempotencyKey?: string;
1404
1551
  skipRetry?: boolean;
1552
+ timeoutMs?: number;
1405
1553
  }): Promise<T>;
1406
1554
  /**
1407
1555
  * HTTP PATCH request helper
@@ -3063,6 +3211,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
3063
3211
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
3064
3212
  }
3065
3213
 
3214
+ /**
3215
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
3216
+ *
3217
+ * @example
3218
+ * ```typescript
3219
+ * // Discover what the org can call, and with which parameters
3220
+ * const functions = await client.aiFunctions.list();
3221
+ * const fn = await client.aiFunctions.get('summarise_ticket');
3222
+ *
3223
+ * // Call it — parameters are checked against the live version before sending
3224
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
3225
+ * if (result.output.type === 'text') console.log(result.output.text);
3226
+ * ```
3227
+ */
3228
+
3229
+ /**
3230
+ * AI Functions API
3231
+ */
3232
+ declare class AiFunctionsAPI extends BaseResourceAPI {
3233
+ private readonly descriptorCache;
3234
+ constructor(http: HttpClient);
3235
+ /**
3236
+ * List the functions this org can call — the index (D27a). Each entry carries
3237
+ * the live version's typed parameters; never prompt text.
3238
+ */
3239
+ list(): Promise<AiFunctionDescriptor[]>;
3240
+ /**
3241
+ * Get one function's descriptor by key (D27a).
3242
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
3243
+ */
3244
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
3245
+ /**
3246
+ * Read one of this org's own runs (safe projection, §6.5).
3247
+ */
3248
+ getRun(executionId: string): Promise<AiFunctionRun>;
3249
+ /** Forget cached descriptors (one key, or all). */
3250
+ clearDescriptorCache(functionKey?: string): void;
3251
+ /**
3252
+ * Run an AI function — one paid provider call.
3253
+ *
3254
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
3255
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
3256
+ *
3257
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
3258
+ * against the live version first (D27c); a problem throws
3259
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
3260
+ * auto-retried; an idempotency key is generated when omitted.
3261
+ *
3262
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
3263
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
3264
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
3265
+ */
3266
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
3267
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
3268
+ private cacheDescriptor;
3269
+ private getCachedDescriptor;
3270
+ private mapRunError;
3271
+ }
3272
+
3066
3273
  /**
3067
3274
  * Cadra Client
3068
3275
  *
@@ -3207,6 +3414,10 @@ declare class CadraClient {
3207
3414
  * Remote runner operations (list)
3208
3415
  */
3209
3416
  readonly remoteRunners: RemoteRunnersAPI;
3417
+ /**
3418
+ * AI function operations (list, get, run, getRun) — p93
3419
+ */
3420
+ readonly aiFunctions: AiFunctionsAPI;
3210
3421
  /**
3211
3422
  * Create a new AI SaaS client
3212
3423
  *
@@ -65,6 +65,13 @@ interface RequestOptions {
65
65
  skipRetry?: boolean;
66
66
  /** Idempotency key */
67
67
  idempotencyKey?: string;
68
+ /**
69
+ * Per-request timeout in milliseconds. Overrides the client-wide
70
+ * `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
71
+ * waits for the server's route ceiling while every other call keeps the
72
+ * 30 s default).
73
+ */
74
+ timeoutMs?: number;
68
75
  }
69
76
  /**
70
77
  * HTTP Client class
@@ -74,6 +81,8 @@ declare class HttpClient {
74
81
  private tokenRefreshAttempts;
75
82
  private readonly maxTokenRefreshAttempts;
76
83
  constructor(config: HttpClientConfig);
84
+ /** The client-wide request timeout (ms) this client was configured with. */
85
+ get timeoutMs(): number;
77
86
  /**
78
87
  * Get authorization header value
79
88
  */
@@ -96,6 +105,7 @@ declare class HttpClient {
96
105
  post<T>(path: string, body?: unknown, options?: {
97
106
  idempotencyKey?: string;
98
107
  skipRetry?: boolean;
108
+ timeoutMs?: number;
99
109
  }): Promise<T>;
100
110
  /**
101
111
  * PATCH request
@@ -1085,6 +1095,16 @@ interface ToolResultEvent {
1085
1095
  result: unknown;
1086
1096
  /** Duration in milliseconds */
1087
1097
  durationMs: number;
1098
+ /**
1099
+ * CAD-243: true when the tool call FAILED (the producer stamps
1100
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
1101
+ * older producers — consumers then fall back to the result shape.
1102
+ */
1103
+ isError?: boolean;
1104
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
1105
+ status?: string;
1106
+ /** CAD-243: error text for a failed call. */
1107
+ error?: string;
1088
1108
  /** See {@link ToolCallEvent.forwardedFrom} */
1089
1109
  forwardedFrom?: string;
1090
1110
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -1374,6 +1394,133 @@ interface StreamController {
1374
1394
  wait(): Promise<AgentExecution>;
1375
1395
  }
1376
1396
 
1397
+ /**
1398
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
1399
+ *
1400
+ * An AI function is a published prompt in the Cadra Prompts library that makes
1401
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
1402
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
1403
+ * by slot key.
1404
+ */
1405
+ /** Output kind of an AI function. */
1406
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
1407
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
1408
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
1409
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
1410
+ type AiFunctionVariableValue = string | number | boolean;
1411
+ /** Parameters (variables) for one run, keyed by parameter name. */
1412
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
1413
+ /** How a run names its function (§4). */
1414
+ type AiFunctionRef = {
1415
+ slot: string;
1416
+ } | {
1417
+ functionKey: string;
1418
+ } | {
1419
+ promptUuid: string;
1420
+ };
1421
+ /** One declared parameter of a function's live (golden) version — D27a. */
1422
+ interface AiFunctionParameter {
1423
+ name: string;
1424
+ type: AiFunctionParameterType;
1425
+ required: boolean;
1426
+ defaultValue?: AiFunctionVariableValue;
1427
+ maxLength?: number;
1428
+ options?: string[];
1429
+ description?: string;
1430
+ }
1431
+ /**
1432
+ * The discovery "index" entry for one callable function — D27a. Built from the
1433
+ * golden version snapshot; never carries prompt or system text.
1434
+ */
1435
+ interface AiFunctionDescriptor {
1436
+ functionKey: string;
1437
+ title: string;
1438
+ description?: string | null;
1439
+ outputKind: AiFunctionOutputKind;
1440
+ /** The live (golden) version number. */
1441
+ liveVersion: number;
1442
+ parameters: AiFunctionParameter[];
1443
+ /** JSON schema of the output, for `json` functions. */
1444
+ outputSchema?: Record<string, unknown> | null;
1445
+ }
1446
+ /** Who paid for a run (D4). */
1447
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
1448
+ /** Runtime params a slot may accept per run (D26d3). */
1449
+ interface AiFunctionRuntimeParams {
1450
+ aspect_ratio?: string;
1451
+ image_size?: string;
1452
+ }
1453
+ /** Options for the object form `run(ref, { variables, … })`. */
1454
+ interface AiFunctionRunOptions {
1455
+ /** Parameters for this run (sent as `variables`). */
1456
+ variables: AiFunctionVariables;
1457
+ /** Pin a published version number (D3d). Skips the client-side check. */
1458
+ version?: number;
1459
+ /** Idempotency key (uuid). Generated when omitted (D15). */
1460
+ idempotencyKey?: string;
1461
+ /** Slot runtime params (D26d3). */
1462
+ params?: AiFunctionRuntimeParams;
1463
+ /** `false` skips the client-side parameter check (D27c). Default true. */
1464
+ validate?: boolean;
1465
+ }
1466
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
1467
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
1468
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
1469
+ interface AiFunctionImage {
1470
+ mimeType: string;
1471
+ url?: string;
1472
+ bytes?: Uint8Array;
1473
+ }
1474
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
1475
+ type AiFunctionOutput<TOutput = unknown> = {
1476
+ type: 'text';
1477
+ text: string;
1478
+ } | {
1479
+ type: 'json';
1480
+ json: TOutput;
1481
+ } | {
1482
+ type: 'image';
1483
+ images: AiFunctionImage[];
1484
+ };
1485
+ /** Token and billing usage of a run (§4). */
1486
+ interface AiFunctionUsage {
1487
+ promptTokens: number;
1488
+ completionTokens: number;
1489
+ imageCount: number;
1490
+ billedTo: AiFunctionBilledTo;
1491
+ }
1492
+ /** Result of a successful run (§4). */
1493
+ interface AiFunctionRunResult<TOutput = unknown> {
1494
+ /** = the run's execution uuid (usage-ledger executionUuid). */
1495
+ executionId: string;
1496
+ functionUuid: string;
1497
+ version: number;
1498
+ output: AiFunctionOutput<TOutput>;
1499
+ usage: AiFunctionUsage;
1500
+ latencyMs: number;
1501
+ }
1502
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
1503
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
1504
+ /** Safe projection of one of the caller org's own runs (§6.5). */
1505
+ interface AiFunctionRun {
1506
+ executionId: string;
1507
+ ref: {
1508
+ slot?: string;
1509
+ functionKey?: string;
1510
+ promptUuid?: string;
1511
+ };
1512
+ version: number | null;
1513
+ status: AiFunctionRunStatus;
1514
+ errorCode: string | null;
1515
+ promptTokens: number | null;
1516
+ completionTokens: number | null;
1517
+ imageCount: number | null;
1518
+ latencyMs: number | null;
1519
+ billedTo: AiFunctionBilledTo | null;
1520
+ createdAt: string;
1521
+ finishedAt: string | null;
1522
+ }
1523
+
1377
1524
  /**
1378
1525
  * Base Resource API
1379
1526
  *
@@ -1402,6 +1549,7 @@ declare abstract class BaseResourceAPI {
1402
1549
  protected httpPost<T>(path: string, body?: unknown, options?: {
1403
1550
  idempotencyKey?: string;
1404
1551
  skipRetry?: boolean;
1552
+ timeoutMs?: number;
1405
1553
  }): Promise<T>;
1406
1554
  /**
1407
1555
  * HTTP PATCH request helper
@@ -3063,6 +3211,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
3063
3211
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
3064
3212
  }
3065
3213
 
3214
+ /**
3215
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
3216
+ *
3217
+ * @example
3218
+ * ```typescript
3219
+ * // Discover what the org can call, and with which parameters
3220
+ * const functions = await client.aiFunctions.list();
3221
+ * const fn = await client.aiFunctions.get('summarise_ticket');
3222
+ *
3223
+ * // Call it — parameters are checked against the live version before sending
3224
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
3225
+ * if (result.output.type === 'text') console.log(result.output.text);
3226
+ * ```
3227
+ */
3228
+
3229
+ /**
3230
+ * AI Functions API
3231
+ */
3232
+ declare class AiFunctionsAPI extends BaseResourceAPI {
3233
+ private readonly descriptorCache;
3234
+ constructor(http: HttpClient);
3235
+ /**
3236
+ * List the functions this org can call — the index (D27a). Each entry carries
3237
+ * the live version's typed parameters; never prompt text.
3238
+ */
3239
+ list(): Promise<AiFunctionDescriptor[]>;
3240
+ /**
3241
+ * Get one function's descriptor by key (D27a).
3242
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
3243
+ */
3244
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
3245
+ /**
3246
+ * Read one of this org's own runs (safe projection, §6.5).
3247
+ */
3248
+ getRun(executionId: string): Promise<AiFunctionRun>;
3249
+ /** Forget cached descriptors (one key, or all). */
3250
+ clearDescriptorCache(functionKey?: string): void;
3251
+ /**
3252
+ * Run an AI function — one paid provider call.
3253
+ *
3254
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
3255
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
3256
+ *
3257
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
3258
+ * against the live version first (D27c); a problem throws
3259
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
3260
+ * auto-retried; an idempotency key is generated when omitted.
3261
+ *
3262
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
3263
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
3264
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
3265
+ */
3266
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
3267
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
3268
+ private cacheDescriptor;
3269
+ private getCachedDescriptor;
3270
+ private mapRunError;
3271
+ }
3272
+
3066
3273
  /**
3067
3274
  * Cadra Client
3068
3275
  *
@@ -3207,6 +3414,10 @@ declare class CadraClient {
3207
3414
  * Remote runner operations (list)
3208
3415
  */
3209
3416
  readonly remoteRunners: RemoteRunnersAPI;
3417
+ /**
3418
+ * AI function operations (list, get, run, getRun) — p93
3419
+ */
3420
+ readonly aiFunctions: AiFunctionsAPI;
3210
3421
  /**
3211
3422
  * Create a new AI SaaS client
3212
3423
  *