@cadraos/sdk 0.3.14-p46.3 → 0.3.14

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 (52) 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/board-host/index.cjs +217 -129
  15. package/dist/board-host/index.cjs.map +1 -1
  16. package/dist/board-host/index.d.cts +96 -1
  17. package/dist/board-host/index.d.ts +96 -1
  18. package/dist/board-host/index.js +218 -131
  19. package/dist/board-host/index.js.map +1 -1
  20. package/dist/board-host/server/index.d.cts +44 -0
  21. package/dist/board-host/server/index.d.ts +44 -0
  22. package/dist/chat/index.cjs +299 -17
  23. package/dist/chat/index.cjs.map +1 -1
  24. package/dist/chat/index.d.cts +225 -0
  25. package/dist/chat/index.d.ts +225 -0
  26. package/dist/chat/index.js +299 -17
  27. package/dist/chat/index.js.map +1 -1
  28. package/dist/index.cjs +221 -3
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +286 -1
  31. package/dist/index.d.ts +286 -1
  32. package/dist/index.js +215 -4
  33. package/dist/index.js.map +1 -1
  34. package/dist/kanban/engine/index.cjs +774 -683
  35. package/dist/kanban/engine/index.cjs.map +1 -1
  36. package/dist/kanban/engine/index.d.cts +90 -1
  37. package/dist/kanban/engine/index.d.ts +90 -1
  38. package/dist/kanban/engine/index.js +774 -684
  39. package/dist/kanban/engine/index.js.map +1 -1
  40. package/dist/kanban/index.cjs +214 -3
  41. package/dist/kanban/index.cjs.map +1 -1
  42. package/dist/kanban/index.d.cts +252 -0
  43. package/dist/kanban/index.d.ts +252 -0
  44. package/dist/kanban/index.js +214 -3
  45. package/dist/kanban/index.js.map +1 -1
  46. package/dist/teams/index.cjs +214 -3
  47. package/dist/teams/index.cjs.map +1 -1
  48. package/dist/teams/index.d.cts +225 -0
  49. package/dist/teams/index.d.ts +225 -0
  50. package/dist/teams/index.js +214 -3
  51. package/dist/teams/index.js.map +1 -1
  52. package/package.json +21 -1
@@ -65,6 +65,12 @@ 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
+ * may take up to 60 s while every other call keeps the 30 s default).
72
+ */
73
+ timeoutMs?: number;
68
74
  }
69
75
  /**
70
76
  * HTTP Client class
@@ -96,6 +102,7 @@ declare class HttpClient {
96
102
  post<T>(path: string, body?: unknown, options?: {
97
103
  idempotencyKey?: string;
98
104
  skipRetry?: boolean;
105
+ timeoutMs?: number;
99
106
  }): Promise<T>;
100
107
  /**
101
108
  * PATCH request
@@ -1085,6 +1092,16 @@ interface ToolResultEvent {
1085
1092
  result: unknown;
1086
1093
  /** Duration in milliseconds */
1087
1094
  durationMs: number;
1095
+ /**
1096
+ * CAD-243: true when the tool call FAILED (the producer stamps
1097
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
1098
+ * older producers — consumers then fall back to the result shape.
1099
+ */
1100
+ isError?: boolean;
1101
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
1102
+ status?: string;
1103
+ /** CAD-243: error text for a failed call. */
1104
+ error?: string;
1088
1105
  /** See {@link ToolCallEvent.forwardedFrom} */
1089
1106
  forwardedFrom?: string;
1090
1107
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -1374,6 +1391,133 @@ interface StreamController {
1374
1391
  wait(): Promise<AgentExecution>;
1375
1392
  }
1376
1393
 
1394
+ /**
1395
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
1396
+ *
1397
+ * An AI function is a published prompt in the Cadra Prompts library that makes
1398
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
1399
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
1400
+ * by slot key.
1401
+ */
1402
+ /** Output kind of an AI function. */
1403
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
1404
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
1405
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
1406
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
1407
+ type AiFunctionVariableValue = string | number | boolean;
1408
+ /** Parameters (variables) for one run, keyed by parameter name. */
1409
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
1410
+ /** How a run names its function (§4). */
1411
+ type AiFunctionRef = {
1412
+ slot: string;
1413
+ } | {
1414
+ functionKey: string;
1415
+ } | {
1416
+ promptUuid: string;
1417
+ };
1418
+ /** One declared parameter of a function's live (golden) version — D27a. */
1419
+ interface AiFunctionParameter {
1420
+ name: string;
1421
+ type: AiFunctionParameterType;
1422
+ required: boolean;
1423
+ defaultValue?: AiFunctionVariableValue;
1424
+ maxLength?: number;
1425
+ options?: string[];
1426
+ description?: string;
1427
+ }
1428
+ /**
1429
+ * The discovery "index" entry for one callable function — D27a. Built from the
1430
+ * golden version snapshot; never carries prompt or system text.
1431
+ */
1432
+ interface AiFunctionDescriptor {
1433
+ functionKey: string;
1434
+ title: string;
1435
+ description?: string | null;
1436
+ outputKind: AiFunctionOutputKind;
1437
+ /** The live (golden) version number. */
1438
+ liveVersion: number;
1439
+ parameters: AiFunctionParameter[];
1440
+ /** JSON schema of the output, for `json` functions. */
1441
+ outputSchema?: Record<string, unknown> | null;
1442
+ }
1443
+ /** Who paid for a run (D4). */
1444
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
1445
+ /** Runtime params a slot may accept per run (D26d3). */
1446
+ interface AiFunctionRuntimeParams {
1447
+ aspect_ratio?: string;
1448
+ image_size?: string;
1449
+ }
1450
+ /** Options for the object form `run(ref, { variables, … })`. */
1451
+ interface AiFunctionRunOptions {
1452
+ /** Parameters for this run (sent as `variables`). */
1453
+ variables: AiFunctionVariables;
1454
+ /** Pin a published version number (D3d). Skips the client-side check. */
1455
+ version?: number;
1456
+ /** Idempotency key (uuid). Generated when omitted (D15). */
1457
+ idempotencyKey?: string;
1458
+ /** Slot runtime params (D26d3). */
1459
+ params?: AiFunctionRuntimeParams;
1460
+ /** `false` skips the client-side parameter check (D27c). Default true. */
1461
+ validate?: boolean;
1462
+ }
1463
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
1464
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
1465
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
1466
+ interface AiFunctionImage {
1467
+ mimeType: string;
1468
+ url?: string;
1469
+ bytes?: Uint8Array;
1470
+ }
1471
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
1472
+ type AiFunctionOutput<TOutput = unknown> = {
1473
+ type: 'text';
1474
+ text: string;
1475
+ } | {
1476
+ type: 'json';
1477
+ json: TOutput;
1478
+ } | {
1479
+ type: 'image';
1480
+ images: AiFunctionImage[];
1481
+ };
1482
+ /** Token and billing usage of a run (§4). */
1483
+ interface AiFunctionUsage {
1484
+ promptTokens: number;
1485
+ completionTokens: number;
1486
+ imageCount: number;
1487
+ billedTo: AiFunctionBilledTo;
1488
+ }
1489
+ /** Result of a successful run (§4). */
1490
+ interface AiFunctionRunResult<TOutput = unknown> {
1491
+ /** = the run's execution uuid (usage-ledger executionUuid). */
1492
+ executionId: string;
1493
+ functionUuid: string;
1494
+ version: number;
1495
+ output: AiFunctionOutput<TOutput>;
1496
+ usage: AiFunctionUsage;
1497
+ latencyMs: number;
1498
+ }
1499
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
1500
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
1501
+ /** Safe projection of one of the caller org's own runs (§6.5). */
1502
+ interface AiFunctionRun {
1503
+ executionId: string;
1504
+ ref: {
1505
+ slot?: string;
1506
+ functionKey?: string;
1507
+ promptUuid?: string;
1508
+ };
1509
+ version: number | null;
1510
+ status: AiFunctionRunStatus;
1511
+ errorCode: string | null;
1512
+ promptTokens: number | null;
1513
+ completionTokens: number | null;
1514
+ imageCount: number | null;
1515
+ latencyMs: number | null;
1516
+ billedTo: AiFunctionBilledTo | null;
1517
+ createdAt: string;
1518
+ finishedAt: string | null;
1519
+ }
1520
+
1377
1521
  /**
1378
1522
  * Base Resource API
1379
1523
  *
@@ -1402,6 +1546,7 @@ declare abstract class BaseResourceAPI {
1402
1546
  protected httpPost<T>(path: string, body?: unknown, options?: {
1403
1547
  idempotencyKey?: string;
1404
1548
  skipRetry?: boolean;
1549
+ timeoutMs?: number;
1405
1550
  }): Promise<T>;
1406
1551
  /**
1407
1552
  * HTTP PATCH request helper
@@ -2706,6 +2851,11 @@ interface KanbanCard {
2706
2851
  configVersion?: number;
2707
2852
  /** Arbitrary shared context carried across transitions. */
2708
2853
  sharedContext?: Record<string, unknown>;
2854
+ /**
2855
+ * p46 (P46-002): the card's id in an external host (a Jira issue key).
2856
+ * Absent on native / crm / yobo cards.
2857
+ */
2858
+ externalRef?: string;
2709
2859
  /**
2710
2860
  * Execution UUID of the card's current/last run, if any.
2711
2861
  *
@@ -2768,6 +2918,18 @@ interface CreateCardInput {
2768
2918
  * in the lifecycle's initial lane.
2769
2919
  */
2770
2920
  lane?: string;
2921
+ /**
2922
+ * p46 (P46-002): the card's id in an EXTERNAL host (a Jira issue key, e.g.
2923
+ * `CAD-231`). Optional. When set, a card is created at most ONCE per
2924
+ * `(boardConfigUuid, externalRef)`: a repeat create returns the existing card
2925
+ * and dispatches nothing. Hosts that don't store it simply ignore it.
2926
+ */
2927
+ externalRef?: string;
2928
+ /**
2929
+ * p46 (P46-002): opaque host facts stored with the card (Jira `statusId`,
2930
+ * `mover`, `detached`, …). Passed through to `adapter.createCard` untouched.
2931
+ */
2932
+ externalMeta?: Record<string, unknown>;
2771
2933
  }
2772
2934
  /**
2773
2935
  * Input for transitioning a card to another lane.
@@ -3046,6 +3208,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
3046
3208
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
3047
3209
  }
3048
3210
 
3211
+ /**
3212
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
3213
+ *
3214
+ * @example
3215
+ * ```typescript
3216
+ * // Discover what the org can call, and with which parameters
3217
+ * const functions = await client.aiFunctions.list();
3218
+ * const fn = await client.aiFunctions.get('summarise_ticket');
3219
+ *
3220
+ * // Call it — parameters are checked against the live version before sending
3221
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
3222
+ * if (result.output.type === 'text') console.log(result.output.text);
3223
+ * ```
3224
+ */
3225
+
3226
+ /**
3227
+ * AI Functions API
3228
+ */
3229
+ declare class AiFunctionsAPI extends BaseResourceAPI {
3230
+ private readonly descriptorCache;
3231
+ constructor(http: HttpClient);
3232
+ /**
3233
+ * List the functions this org can call — the index (D27a). Each entry carries
3234
+ * the live version's typed parameters; never prompt text.
3235
+ */
3236
+ list(): Promise<AiFunctionDescriptor[]>;
3237
+ /**
3238
+ * Get one function's descriptor by key (D27a).
3239
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
3240
+ */
3241
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
3242
+ /**
3243
+ * Read one of this org's own runs (safe projection, §6.5).
3244
+ */
3245
+ getRun(executionId: string): Promise<AiFunctionRun>;
3246
+ /** Forget cached descriptors (one key, or all). */
3247
+ clearDescriptorCache(functionKey?: string): void;
3248
+ /**
3249
+ * Run an AI function — one paid provider call.
3250
+ *
3251
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
3252
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
3253
+ *
3254
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
3255
+ * against the live version first (D27c); a problem throws
3256
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
3257
+ * auto-retried; an idempotency key is generated when omitted.
3258
+ *
3259
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
3260
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
3261
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
3262
+ */
3263
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
3264
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
3265
+ private cacheDescriptor;
3266
+ private getCachedDescriptor;
3267
+ private mapRunError;
3268
+ }
3269
+
3049
3270
  /**
3050
3271
  * Cadra Client
3051
3272
  *
@@ -3190,6 +3411,10 @@ declare class CadraClient {
3190
3411
  * Remote runner operations (list)
3191
3412
  */
3192
3413
  readonly remoteRunners: RemoteRunnersAPI;
3414
+ /**
3415
+ * AI function operations (list, get, run, getRun) — p93
3416
+ */
3417
+ readonly aiFunctions: AiFunctionsAPI;
3193
3418
  /**
3194
3419
  * Create a new AI SaaS client
3195
3420
  *
@@ -65,6 +65,12 @@ 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
+ * may take up to 60 s while every other call keeps the 30 s default).
72
+ */
73
+ timeoutMs?: number;
68
74
  }
69
75
  /**
70
76
  * HTTP Client class
@@ -96,6 +102,7 @@ declare class HttpClient {
96
102
  post<T>(path: string, body?: unknown, options?: {
97
103
  idempotencyKey?: string;
98
104
  skipRetry?: boolean;
105
+ timeoutMs?: number;
99
106
  }): Promise<T>;
100
107
  /**
101
108
  * PATCH request
@@ -1085,6 +1092,16 @@ interface ToolResultEvent {
1085
1092
  result: unknown;
1086
1093
  /** Duration in milliseconds */
1087
1094
  durationMs: number;
1095
+ /**
1096
+ * CAD-243: true when the tool call FAILED (the producer stamps
1097
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
1098
+ * older producers — consumers then fall back to the result shape.
1099
+ */
1100
+ isError?: boolean;
1101
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
1102
+ status?: string;
1103
+ /** CAD-243: error text for a failed call. */
1104
+ error?: string;
1088
1105
  /** See {@link ToolCallEvent.forwardedFrom} */
1089
1106
  forwardedFrom?: string;
1090
1107
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -1374,6 +1391,133 @@ interface StreamController {
1374
1391
  wait(): Promise<AgentExecution>;
1375
1392
  }
1376
1393
 
1394
+ /**
1395
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
1396
+ *
1397
+ * An AI function is a published prompt in the Cadra Prompts library that makes
1398
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
1399
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
1400
+ * by slot key.
1401
+ */
1402
+ /** Output kind of an AI function. */
1403
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
1404
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
1405
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
1406
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
1407
+ type AiFunctionVariableValue = string | number | boolean;
1408
+ /** Parameters (variables) for one run, keyed by parameter name. */
1409
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
1410
+ /** How a run names its function (§4). */
1411
+ type AiFunctionRef = {
1412
+ slot: string;
1413
+ } | {
1414
+ functionKey: string;
1415
+ } | {
1416
+ promptUuid: string;
1417
+ };
1418
+ /** One declared parameter of a function's live (golden) version — D27a. */
1419
+ interface AiFunctionParameter {
1420
+ name: string;
1421
+ type: AiFunctionParameterType;
1422
+ required: boolean;
1423
+ defaultValue?: AiFunctionVariableValue;
1424
+ maxLength?: number;
1425
+ options?: string[];
1426
+ description?: string;
1427
+ }
1428
+ /**
1429
+ * The discovery "index" entry for one callable function — D27a. Built from the
1430
+ * golden version snapshot; never carries prompt or system text.
1431
+ */
1432
+ interface AiFunctionDescriptor {
1433
+ functionKey: string;
1434
+ title: string;
1435
+ description?: string | null;
1436
+ outputKind: AiFunctionOutputKind;
1437
+ /** The live (golden) version number. */
1438
+ liveVersion: number;
1439
+ parameters: AiFunctionParameter[];
1440
+ /** JSON schema of the output, for `json` functions. */
1441
+ outputSchema?: Record<string, unknown> | null;
1442
+ }
1443
+ /** Who paid for a run (D4). */
1444
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
1445
+ /** Runtime params a slot may accept per run (D26d3). */
1446
+ interface AiFunctionRuntimeParams {
1447
+ aspect_ratio?: string;
1448
+ image_size?: string;
1449
+ }
1450
+ /** Options for the object form `run(ref, { variables, … })`. */
1451
+ interface AiFunctionRunOptions {
1452
+ /** Parameters for this run (sent as `variables`). */
1453
+ variables: AiFunctionVariables;
1454
+ /** Pin a published version number (D3d). Skips the client-side check. */
1455
+ version?: number;
1456
+ /** Idempotency key (uuid). Generated when omitted (D15). */
1457
+ idempotencyKey?: string;
1458
+ /** Slot runtime params (D26d3). */
1459
+ params?: AiFunctionRuntimeParams;
1460
+ /** `false` skips the client-side parameter check (D27c). Default true. */
1461
+ validate?: boolean;
1462
+ }
1463
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
1464
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
1465
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
1466
+ interface AiFunctionImage {
1467
+ mimeType: string;
1468
+ url?: string;
1469
+ bytes?: Uint8Array;
1470
+ }
1471
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
1472
+ type AiFunctionOutput<TOutput = unknown> = {
1473
+ type: 'text';
1474
+ text: string;
1475
+ } | {
1476
+ type: 'json';
1477
+ json: TOutput;
1478
+ } | {
1479
+ type: 'image';
1480
+ images: AiFunctionImage[];
1481
+ };
1482
+ /** Token and billing usage of a run (§4). */
1483
+ interface AiFunctionUsage {
1484
+ promptTokens: number;
1485
+ completionTokens: number;
1486
+ imageCount: number;
1487
+ billedTo: AiFunctionBilledTo;
1488
+ }
1489
+ /** Result of a successful run (§4). */
1490
+ interface AiFunctionRunResult<TOutput = unknown> {
1491
+ /** = the run's execution uuid (usage-ledger executionUuid). */
1492
+ executionId: string;
1493
+ functionUuid: string;
1494
+ version: number;
1495
+ output: AiFunctionOutput<TOutput>;
1496
+ usage: AiFunctionUsage;
1497
+ latencyMs: number;
1498
+ }
1499
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
1500
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
1501
+ /** Safe projection of one of the caller org's own runs (§6.5). */
1502
+ interface AiFunctionRun {
1503
+ executionId: string;
1504
+ ref: {
1505
+ slot?: string;
1506
+ functionKey?: string;
1507
+ promptUuid?: string;
1508
+ };
1509
+ version: number | null;
1510
+ status: AiFunctionRunStatus;
1511
+ errorCode: string | null;
1512
+ promptTokens: number | null;
1513
+ completionTokens: number | null;
1514
+ imageCount: number | null;
1515
+ latencyMs: number | null;
1516
+ billedTo: AiFunctionBilledTo | null;
1517
+ createdAt: string;
1518
+ finishedAt: string | null;
1519
+ }
1520
+
1377
1521
  /**
1378
1522
  * Base Resource API
1379
1523
  *
@@ -1402,6 +1546,7 @@ declare abstract class BaseResourceAPI {
1402
1546
  protected httpPost<T>(path: string, body?: unknown, options?: {
1403
1547
  idempotencyKey?: string;
1404
1548
  skipRetry?: boolean;
1549
+ timeoutMs?: number;
1405
1550
  }): Promise<T>;
1406
1551
  /**
1407
1552
  * HTTP PATCH request helper
@@ -2706,6 +2851,11 @@ interface KanbanCard {
2706
2851
  configVersion?: number;
2707
2852
  /** Arbitrary shared context carried across transitions. */
2708
2853
  sharedContext?: Record<string, unknown>;
2854
+ /**
2855
+ * p46 (P46-002): the card's id in an external host (a Jira issue key).
2856
+ * Absent on native / crm / yobo cards.
2857
+ */
2858
+ externalRef?: string;
2709
2859
  /**
2710
2860
  * Execution UUID of the card's current/last run, if any.
2711
2861
  *
@@ -2768,6 +2918,18 @@ interface CreateCardInput {
2768
2918
  * in the lifecycle's initial lane.
2769
2919
  */
2770
2920
  lane?: string;
2921
+ /**
2922
+ * p46 (P46-002): the card's id in an EXTERNAL host (a Jira issue key, e.g.
2923
+ * `CAD-231`). Optional. When set, a card is created at most ONCE per
2924
+ * `(boardConfigUuid, externalRef)`: a repeat create returns the existing card
2925
+ * and dispatches nothing. Hosts that don't store it simply ignore it.
2926
+ */
2927
+ externalRef?: string;
2928
+ /**
2929
+ * p46 (P46-002): opaque host facts stored with the card (Jira `statusId`,
2930
+ * `mover`, `detached`, …). Passed through to `adapter.createCard` untouched.
2931
+ */
2932
+ externalMeta?: Record<string, unknown>;
2771
2933
  }
2772
2934
  /**
2773
2935
  * Input for transitioning a card to another lane.
@@ -3046,6 +3208,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
3046
3208
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
3047
3209
  }
3048
3210
 
3211
+ /**
3212
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
3213
+ *
3214
+ * @example
3215
+ * ```typescript
3216
+ * // Discover what the org can call, and with which parameters
3217
+ * const functions = await client.aiFunctions.list();
3218
+ * const fn = await client.aiFunctions.get('summarise_ticket');
3219
+ *
3220
+ * // Call it — parameters are checked against the live version before sending
3221
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
3222
+ * if (result.output.type === 'text') console.log(result.output.text);
3223
+ * ```
3224
+ */
3225
+
3226
+ /**
3227
+ * AI Functions API
3228
+ */
3229
+ declare class AiFunctionsAPI extends BaseResourceAPI {
3230
+ private readonly descriptorCache;
3231
+ constructor(http: HttpClient);
3232
+ /**
3233
+ * List the functions this org can call — the index (D27a). Each entry carries
3234
+ * the live version's typed parameters; never prompt text.
3235
+ */
3236
+ list(): Promise<AiFunctionDescriptor[]>;
3237
+ /**
3238
+ * Get one function's descriptor by key (D27a).
3239
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
3240
+ */
3241
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
3242
+ /**
3243
+ * Read one of this org's own runs (safe projection, §6.5).
3244
+ */
3245
+ getRun(executionId: string): Promise<AiFunctionRun>;
3246
+ /** Forget cached descriptors (one key, or all). */
3247
+ clearDescriptorCache(functionKey?: string): void;
3248
+ /**
3249
+ * Run an AI function — one paid provider call.
3250
+ *
3251
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
3252
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
3253
+ *
3254
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
3255
+ * against the live version first (D27c); a problem throws
3256
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
3257
+ * auto-retried; an idempotency key is generated when omitted.
3258
+ *
3259
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
3260
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
3261
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
3262
+ */
3263
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
3264
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
3265
+ private cacheDescriptor;
3266
+ private getCachedDescriptor;
3267
+ private mapRunError;
3268
+ }
3269
+
3049
3270
  /**
3050
3271
  * Cadra Client
3051
3272
  *
@@ -3190,6 +3411,10 @@ declare class CadraClient {
3190
3411
  * Remote runner operations (list)
3191
3412
  */
3192
3413
  readonly remoteRunners: RemoteRunnersAPI;
3414
+ /**
3415
+ * AI function operations (list, get, run, getRun) — p93
3416
+ */
3417
+ readonly aiFunctions: AiFunctionsAPI;
3193
3418
  /**
3194
3419
  * Create a new AI SaaS client
3195
3420
  *