@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
@@ -874,6 +874,16 @@ interface ToolResultEvent {
874
874
  result: unknown;
875
875
  /** Duration in milliseconds */
876
876
  durationMs: number;
877
+ /**
878
+ * CAD-243: true when the tool call FAILED (the producer stamps
879
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
880
+ * older producers — consumers then fall back to the result shape.
881
+ */
882
+ isError?: boolean;
883
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
884
+ status?: string;
885
+ /** CAD-243: error text for a failed call. */
886
+ error?: string;
877
887
  /** See {@link ToolCallEvent.forwardedFrom} */
878
888
  forwardedFrom?: string;
879
889
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -1863,6 +1873,12 @@ interface RequestOptions {
1863
1873
  skipRetry?: boolean;
1864
1874
  /** Idempotency key */
1865
1875
  idempotencyKey?: string;
1876
+ /**
1877
+ * Per-request timeout in milliseconds. Overrides the client-wide
1878
+ * `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
1879
+ * may take up to 60 s while every other call keeps the 30 s default).
1880
+ */
1881
+ timeoutMs?: number;
1866
1882
  }
1867
1883
  /**
1868
1884
  * HTTP Client class
@@ -1894,6 +1910,7 @@ declare class HttpClient {
1894
1910
  post<T>(path: string, body?: unknown, options?: {
1895
1911
  idempotencyKey?: string;
1896
1912
  skipRetry?: boolean;
1913
+ timeoutMs?: number;
1897
1914
  }): Promise<T>;
1898
1915
  /**
1899
1916
  * PATCH request
@@ -2521,6 +2538,133 @@ interface RemoteAgentExecuteResponse {
2521
2538
  streamUrl: string;
2522
2539
  }
2523
2540
 
2541
+ /**
2542
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
2543
+ *
2544
+ * An AI function is a published prompt in the Cadra Prompts library that makes
2545
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
2546
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
2547
+ * by slot key.
2548
+ */
2549
+ /** Output kind of an AI function. */
2550
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
2551
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
2552
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
2553
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
2554
+ type AiFunctionVariableValue = string | number | boolean;
2555
+ /** Parameters (variables) for one run, keyed by parameter name. */
2556
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
2557
+ /** How a run names its function (§4). */
2558
+ type AiFunctionRef = {
2559
+ slot: string;
2560
+ } | {
2561
+ functionKey: string;
2562
+ } | {
2563
+ promptUuid: string;
2564
+ };
2565
+ /** One declared parameter of a function's live (golden) version — D27a. */
2566
+ interface AiFunctionParameter {
2567
+ name: string;
2568
+ type: AiFunctionParameterType;
2569
+ required: boolean;
2570
+ defaultValue?: AiFunctionVariableValue;
2571
+ maxLength?: number;
2572
+ options?: string[];
2573
+ description?: string;
2574
+ }
2575
+ /**
2576
+ * The discovery "index" entry for one callable function — D27a. Built from the
2577
+ * golden version snapshot; never carries prompt or system text.
2578
+ */
2579
+ interface AiFunctionDescriptor {
2580
+ functionKey: string;
2581
+ title: string;
2582
+ description?: string | null;
2583
+ outputKind: AiFunctionOutputKind;
2584
+ /** The live (golden) version number. */
2585
+ liveVersion: number;
2586
+ parameters: AiFunctionParameter[];
2587
+ /** JSON schema of the output, for `json` functions. */
2588
+ outputSchema?: Record<string, unknown> | null;
2589
+ }
2590
+ /** Who paid for a run (D4). */
2591
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
2592
+ /** Runtime params a slot may accept per run (D26d3). */
2593
+ interface AiFunctionRuntimeParams {
2594
+ aspect_ratio?: string;
2595
+ image_size?: string;
2596
+ }
2597
+ /** Options for the object form `run(ref, { variables, … })`. */
2598
+ interface AiFunctionRunOptions {
2599
+ /** Parameters for this run (sent as `variables`). */
2600
+ variables: AiFunctionVariables;
2601
+ /** Pin a published version number (D3d). Skips the client-side check. */
2602
+ version?: number;
2603
+ /** Idempotency key (uuid). Generated when omitted (D15). */
2604
+ idempotencyKey?: string;
2605
+ /** Slot runtime params (D26d3). */
2606
+ params?: AiFunctionRuntimeParams;
2607
+ /** `false` skips the client-side parameter check (D27c). Default true. */
2608
+ validate?: boolean;
2609
+ }
2610
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
2611
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
2612
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
2613
+ interface AiFunctionImage {
2614
+ mimeType: string;
2615
+ url?: string;
2616
+ bytes?: Uint8Array;
2617
+ }
2618
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
2619
+ type AiFunctionOutput<TOutput = unknown> = {
2620
+ type: 'text';
2621
+ text: string;
2622
+ } | {
2623
+ type: 'json';
2624
+ json: TOutput;
2625
+ } | {
2626
+ type: 'image';
2627
+ images: AiFunctionImage[];
2628
+ };
2629
+ /** Token and billing usage of a run (§4). */
2630
+ interface AiFunctionUsage {
2631
+ promptTokens: number;
2632
+ completionTokens: number;
2633
+ imageCount: number;
2634
+ billedTo: AiFunctionBilledTo;
2635
+ }
2636
+ /** Result of a successful run (§4). */
2637
+ interface AiFunctionRunResult<TOutput = unknown> {
2638
+ /** = the run's execution uuid (usage-ledger executionUuid). */
2639
+ executionId: string;
2640
+ functionUuid: string;
2641
+ version: number;
2642
+ output: AiFunctionOutput<TOutput>;
2643
+ usage: AiFunctionUsage;
2644
+ latencyMs: number;
2645
+ }
2646
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
2647
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
2648
+ /** Safe projection of one of the caller org's own runs (§6.5). */
2649
+ interface AiFunctionRun {
2650
+ executionId: string;
2651
+ ref: {
2652
+ slot?: string;
2653
+ functionKey?: string;
2654
+ promptUuid?: string;
2655
+ };
2656
+ version: number | null;
2657
+ status: AiFunctionRunStatus;
2658
+ errorCode: string | null;
2659
+ promptTokens: number | null;
2660
+ completionTokens: number | null;
2661
+ imageCount: number | null;
2662
+ latencyMs: number | null;
2663
+ billedTo: AiFunctionBilledTo | null;
2664
+ createdAt: string;
2665
+ finishedAt: string | null;
2666
+ }
2667
+
2524
2668
  /**
2525
2669
  * Base Resource API
2526
2670
  *
@@ -2549,6 +2693,7 @@ declare abstract class BaseResourceAPI {
2549
2693
  protected httpPost<T>(path: string, body?: unknown, options?: {
2550
2694
  idempotencyKey?: string;
2551
2695
  skipRetry?: boolean;
2696
+ timeoutMs?: number;
2552
2697
  }): Promise<T>;
2553
2698
  /**
2554
2699
  * HTTP PATCH request helper
@@ -3828,6 +3973,11 @@ interface KanbanCard {
3828
3973
  configVersion?: number;
3829
3974
  /** Arbitrary shared context carried across transitions. */
3830
3975
  sharedContext?: Record<string, unknown>;
3976
+ /**
3977
+ * p46 (P46-002): the card's id in an external host (a Jira issue key).
3978
+ * Absent on native / crm / yobo cards.
3979
+ */
3980
+ externalRef?: string;
3831
3981
  /**
3832
3982
  * Execution UUID of the card's current/last run, if any.
3833
3983
  *
@@ -3890,6 +4040,18 @@ interface CreateCardInput {
3890
4040
  * in the lifecycle's initial lane.
3891
4041
  */
3892
4042
  lane?: string;
4043
+ /**
4044
+ * p46 (P46-002): the card's id in an EXTERNAL host (a Jira issue key, e.g.
4045
+ * `CAD-231`). Optional. When set, a card is created at most ONCE per
4046
+ * `(boardConfigUuid, externalRef)`: a repeat create returns the existing card
4047
+ * and dispatches nothing. Hosts that don't store it simply ignore it.
4048
+ */
4049
+ externalRef?: string;
4050
+ /**
4051
+ * p46 (P46-002): opaque host facts stored with the card (Jira `statusId`,
4052
+ * `mover`, `detached`, …). Passed through to `adapter.createCard` untouched.
4053
+ */
4054
+ externalMeta?: Record<string, unknown>;
3893
4055
  }
3894
4056
  /**
3895
4057
  * Input for transitioning a card to another lane.
@@ -4168,6 +4330,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
4168
4330
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
4169
4331
  }
4170
4332
 
4333
+ /**
4334
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
4335
+ *
4336
+ * @example
4337
+ * ```typescript
4338
+ * // Discover what the org can call, and with which parameters
4339
+ * const functions = await client.aiFunctions.list();
4340
+ * const fn = await client.aiFunctions.get('summarise_ticket');
4341
+ *
4342
+ * // Call it — parameters are checked against the live version before sending
4343
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
4344
+ * if (result.output.type === 'text') console.log(result.output.text);
4345
+ * ```
4346
+ */
4347
+
4348
+ /**
4349
+ * AI Functions API
4350
+ */
4351
+ declare class AiFunctionsAPI extends BaseResourceAPI {
4352
+ private readonly descriptorCache;
4353
+ constructor(http: HttpClient);
4354
+ /**
4355
+ * List the functions this org can call — the index (D27a). Each entry carries
4356
+ * the live version's typed parameters; never prompt text.
4357
+ */
4358
+ list(): Promise<AiFunctionDescriptor[]>;
4359
+ /**
4360
+ * Get one function's descriptor by key (D27a).
4361
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
4362
+ */
4363
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
4364
+ /**
4365
+ * Read one of this org's own runs (safe projection, §6.5).
4366
+ */
4367
+ getRun(executionId: string): Promise<AiFunctionRun>;
4368
+ /** Forget cached descriptors (one key, or all). */
4369
+ clearDescriptorCache(functionKey?: string): void;
4370
+ /**
4371
+ * Run an AI function — one paid provider call.
4372
+ *
4373
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
4374
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
4375
+ *
4376
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
4377
+ * against the live version first (D27c); a problem throws
4378
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
4379
+ * auto-retried; an idempotency key is generated when omitted.
4380
+ *
4381
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
4382
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
4383
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
4384
+ */
4385
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
4386
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
4387
+ private cacheDescriptor;
4388
+ private getCachedDescriptor;
4389
+ private mapRunError;
4390
+ }
4391
+
4171
4392
  /**
4172
4393
  * Cadra Client
4173
4394
  *
@@ -4312,6 +4533,10 @@ declare class CadraClient {
4312
4533
  * Remote runner operations (list)
4313
4534
  */
4314
4535
  readonly remoteRunners: RemoteRunnersAPI;
4536
+ /**
4537
+ * AI function operations (list, get, run, getRun) — p93
4538
+ */
4539
+ readonly aiFunctions: AiFunctionsAPI;
4315
4540
  /**
4316
4541
  * Create a new AI SaaS client
4317
4542
  *
@@ -874,6 +874,16 @@ interface ToolResultEvent {
874
874
  result: unknown;
875
875
  /** Duration in milliseconds */
876
876
  durationMs: number;
877
+ /**
878
+ * CAD-243: true when the tool call FAILED (the producer stamps
879
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
880
+ * older producers — consumers then fall back to the result shape.
881
+ */
882
+ isError?: boolean;
883
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
884
+ status?: string;
885
+ /** CAD-243: error text for a failed call. */
886
+ error?: string;
877
887
  /** See {@link ToolCallEvent.forwardedFrom} */
878
888
  forwardedFrom?: string;
879
889
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -1863,6 +1873,12 @@ interface RequestOptions {
1863
1873
  skipRetry?: boolean;
1864
1874
  /** Idempotency key */
1865
1875
  idempotencyKey?: string;
1876
+ /**
1877
+ * Per-request timeout in milliseconds. Overrides the client-wide
1878
+ * `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
1879
+ * may take up to 60 s while every other call keeps the 30 s default).
1880
+ */
1881
+ timeoutMs?: number;
1866
1882
  }
1867
1883
  /**
1868
1884
  * HTTP Client class
@@ -1894,6 +1910,7 @@ declare class HttpClient {
1894
1910
  post<T>(path: string, body?: unknown, options?: {
1895
1911
  idempotencyKey?: string;
1896
1912
  skipRetry?: boolean;
1913
+ timeoutMs?: number;
1897
1914
  }): Promise<T>;
1898
1915
  /**
1899
1916
  * PATCH request
@@ -2521,6 +2538,133 @@ interface RemoteAgentExecuteResponse {
2521
2538
  streamUrl: string;
2522
2539
  }
2523
2540
 
2541
+ /**
2542
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
2543
+ *
2544
+ * An AI function is a published prompt in the Cadra Prompts library that makes
2545
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
2546
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
2547
+ * by slot key.
2548
+ */
2549
+ /** Output kind of an AI function. */
2550
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
2551
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
2552
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
2553
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
2554
+ type AiFunctionVariableValue = string | number | boolean;
2555
+ /** Parameters (variables) for one run, keyed by parameter name. */
2556
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
2557
+ /** How a run names its function (§4). */
2558
+ type AiFunctionRef = {
2559
+ slot: string;
2560
+ } | {
2561
+ functionKey: string;
2562
+ } | {
2563
+ promptUuid: string;
2564
+ };
2565
+ /** One declared parameter of a function's live (golden) version — D27a. */
2566
+ interface AiFunctionParameter {
2567
+ name: string;
2568
+ type: AiFunctionParameterType;
2569
+ required: boolean;
2570
+ defaultValue?: AiFunctionVariableValue;
2571
+ maxLength?: number;
2572
+ options?: string[];
2573
+ description?: string;
2574
+ }
2575
+ /**
2576
+ * The discovery "index" entry for one callable function — D27a. Built from the
2577
+ * golden version snapshot; never carries prompt or system text.
2578
+ */
2579
+ interface AiFunctionDescriptor {
2580
+ functionKey: string;
2581
+ title: string;
2582
+ description?: string | null;
2583
+ outputKind: AiFunctionOutputKind;
2584
+ /** The live (golden) version number. */
2585
+ liveVersion: number;
2586
+ parameters: AiFunctionParameter[];
2587
+ /** JSON schema of the output, for `json` functions. */
2588
+ outputSchema?: Record<string, unknown> | null;
2589
+ }
2590
+ /** Who paid for a run (D4). */
2591
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
2592
+ /** Runtime params a slot may accept per run (D26d3). */
2593
+ interface AiFunctionRuntimeParams {
2594
+ aspect_ratio?: string;
2595
+ image_size?: string;
2596
+ }
2597
+ /** Options for the object form `run(ref, { variables, … })`. */
2598
+ interface AiFunctionRunOptions {
2599
+ /** Parameters for this run (sent as `variables`). */
2600
+ variables: AiFunctionVariables;
2601
+ /** Pin a published version number (D3d). Skips the client-side check. */
2602
+ version?: number;
2603
+ /** Idempotency key (uuid). Generated when omitted (D15). */
2604
+ idempotencyKey?: string;
2605
+ /** Slot runtime params (D26d3). */
2606
+ params?: AiFunctionRuntimeParams;
2607
+ /** `false` skips the client-side parameter check (D27c). Default true. */
2608
+ validate?: boolean;
2609
+ }
2610
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
2611
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
2612
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
2613
+ interface AiFunctionImage {
2614
+ mimeType: string;
2615
+ url?: string;
2616
+ bytes?: Uint8Array;
2617
+ }
2618
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
2619
+ type AiFunctionOutput<TOutput = unknown> = {
2620
+ type: 'text';
2621
+ text: string;
2622
+ } | {
2623
+ type: 'json';
2624
+ json: TOutput;
2625
+ } | {
2626
+ type: 'image';
2627
+ images: AiFunctionImage[];
2628
+ };
2629
+ /** Token and billing usage of a run (§4). */
2630
+ interface AiFunctionUsage {
2631
+ promptTokens: number;
2632
+ completionTokens: number;
2633
+ imageCount: number;
2634
+ billedTo: AiFunctionBilledTo;
2635
+ }
2636
+ /** Result of a successful run (§4). */
2637
+ interface AiFunctionRunResult<TOutput = unknown> {
2638
+ /** = the run's execution uuid (usage-ledger executionUuid). */
2639
+ executionId: string;
2640
+ functionUuid: string;
2641
+ version: number;
2642
+ output: AiFunctionOutput<TOutput>;
2643
+ usage: AiFunctionUsage;
2644
+ latencyMs: number;
2645
+ }
2646
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
2647
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
2648
+ /** Safe projection of one of the caller org's own runs (§6.5). */
2649
+ interface AiFunctionRun {
2650
+ executionId: string;
2651
+ ref: {
2652
+ slot?: string;
2653
+ functionKey?: string;
2654
+ promptUuid?: string;
2655
+ };
2656
+ version: number | null;
2657
+ status: AiFunctionRunStatus;
2658
+ errorCode: string | null;
2659
+ promptTokens: number | null;
2660
+ completionTokens: number | null;
2661
+ imageCount: number | null;
2662
+ latencyMs: number | null;
2663
+ billedTo: AiFunctionBilledTo | null;
2664
+ createdAt: string;
2665
+ finishedAt: string | null;
2666
+ }
2667
+
2524
2668
  /**
2525
2669
  * Base Resource API
2526
2670
  *
@@ -2549,6 +2693,7 @@ declare abstract class BaseResourceAPI {
2549
2693
  protected httpPost<T>(path: string, body?: unknown, options?: {
2550
2694
  idempotencyKey?: string;
2551
2695
  skipRetry?: boolean;
2696
+ timeoutMs?: number;
2552
2697
  }): Promise<T>;
2553
2698
  /**
2554
2699
  * HTTP PATCH request helper
@@ -3828,6 +3973,11 @@ interface KanbanCard {
3828
3973
  configVersion?: number;
3829
3974
  /** Arbitrary shared context carried across transitions. */
3830
3975
  sharedContext?: Record<string, unknown>;
3976
+ /**
3977
+ * p46 (P46-002): the card's id in an external host (a Jira issue key).
3978
+ * Absent on native / crm / yobo cards.
3979
+ */
3980
+ externalRef?: string;
3831
3981
  /**
3832
3982
  * Execution UUID of the card's current/last run, if any.
3833
3983
  *
@@ -3890,6 +4040,18 @@ interface CreateCardInput {
3890
4040
  * in the lifecycle's initial lane.
3891
4041
  */
3892
4042
  lane?: string;
4043
+ /**
4044
+ * p46 (P46-002): the card's id in an EXTERNAL host (a Jira issue key, e.g.
4045
+ * `CAD-231`). Optional. When set, a card is created at most ONCE per
4046
+ * `(boardConfigUuid, externalRef)`: a repeat create returns the existing card
4047
+ * and dispatches nothing. Hosts that don't store it simply ignore it.
4048
+ */
4049
+ externalRef?: string;
4050
+ /**
4051
+ * p46 (P46-002): opaque host facts stored with the card (Jira `statusId`,
4052
+ * `mover`, `detached`, …). Passed through to `adapter.createCard` untouched.
4053
+ */
4054
+ externalMeta?: Record<string, unknown>;
3893
4055
  }
3894
4056
  /**
3895
4057
  * Input for transitioning a card to another lane.
@@ -4168,6 +4330,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
4168
4330
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
4169
4331
  }
4170
4332
 
4333
+ /**
4334
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
4335
+ *
4336
+ * @example
4337
+ * ```typescript
4338
+ * // Discover what the org can call, and with which parameters
4339
+ * const functions = await client.aiFunctions.list();
4340
+ * const fn = await client.aiFunctions.get('summarise_ticket');
4341
+ *
4342
+ * // Call it — parameters are checked against the live version before sending
4343
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
4344
+ * if (result.output.type === 'text') console.log(result.output.text);
4345
+ * ```
4346
+ */
4347
+
4348
+ /**
4349
+ * AI Functions API
4350
+ */
4351
+ declare class AiFunctionsAPI extends BaseResourceAPI {
4352
+ private readonly descriptorCache;
4353
+ constructor(http: HttpClient);
4354
+ /**
4355
+ * List the functions this org can call — the index (D27a). Each entry carries
4356
+ * the live version's typed parameters; never prompt text.
4357
+ */
4358
+ list(): Promise<AiFunctionDescriptor[]>;
4359
+ /**
4360
+ * Get one function's descriptor by key (D27a).
4361
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
4362
+ */
4363
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
4364
+ /**
4365
+ * Read one of this org's own runs (safe projection, §6.5).
4366
+ */
4367
+ getRun(executionId: string): Promise<AiFunctionRun>;
4368
+ /** Forget cached descriptors (one key, or all). */
4369
+ clearDescriptorCache(functionKey?: string): void;
4370
+ /**
4371
+ * Run an AI function — one paid provider call.
4372
+ *
4373
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
4374
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
4375
+ *
4376
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
4377
+ * against the live version first (D27c); a problem throws
4378
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
4379
+ * auto-retried; an idempotency key is generated when omitted.
4380
+ *
4381
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
4382
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
4383
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
4384
+ */
4385
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
4386
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
4387
+ private cacheDescriptor;
4388
+ private getCachedDescriptor;
4389
+ private mapRunError;
4390
+ }
4391
+
4171
4392
  /**
4172
4393
  * Cadra Client
4173
4394
  *
@@ -4312,6 +4533,10 @@ declare class CadraClient {
4312
4533
  * Remote runner operations (list)
4313
4534
  */
4314
4535
  readonly remoteRunners: RemoteRunnersAPI;
4536
+ /**
4537
+ * AI function operations (list, get, run, getRun) — p93
4538
+ */
4539
+ readonly aiFunctions: AiFunctionsAPI;
4315
4540
  /**
4316
4541
  * Create a new AI SaaS client
4317
4542
  *