@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
@@ -1272,6 +1272,16 @@ interface ToolResultEvent {
1272
1272
  result: unknown;
1273
1273
  /** Duration in milliseconds */
1274
1274
  durationMs: number;
1275
+ /**
1276
+ * CAD-243: true when the tool call FAILED (the producer stamps
1277
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
1278
+ * older producers — consumers then fall back to the result shape.
1279
+ */
1280
+ isError?: boolean;
1281
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
1282
+ status?: string;
1283
+ /** CAD-243: error text for a failed call. */
1284
+ error?: string;
1275
1285
  /** See {@link ToolCallEvent.forwardedFrom} */
1276
1286
  forwardedFrom?: string;
1277
1287
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -2859,6 +2869,13 @@ interface RequestOptions {
2859
2869
  skipRetry?: boolean;
2860
2870
  /** Idempotency key */
2861
2871
  idempotencyKey?: string;
2872
+ /**
2873
+ * Per-request timeout in milliseconds. Overrides the client-wide
2874
+ * `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
2875
+ * waits for the server's route ceiling while every other call keeps the
2876
+ * 30 s default).
2877
+ */
2878
+ timeoutMs?: number;
2862
2879
  }
2863
2880
  /**
2864
2881
  * HTTP Client class
@@ -2868,6 +2885,8 @@ declare class HttpClient {
2868
2885
  private tokenRefreshAttempts;
2869
2886
  private readonly maxTokenRefreshAttempts;
2870
2887
  constructor(config: HttpClientConfig);
2888
+ /** The client-wide request timeout (ms) this client was configured with. */
2889
+ get timeoutMs(): number;
2871
2890
  /**
2872
2891
  * Get authorization header value
2873
2892
  */
@@ -2890,6 +2909,7 @@ declare class HttpClient {
2890
2909
  post<T>(path: string, body?: unknown, options?: {
2891
2910
  idempotencyKey?: string;
2892
2911
  skipRetry?: boolean;
2912
+ timeoutMs?: number;
2893
2913
  }): Promise<T>;
2894
2914
  /**
2895
2915
  * PATCH request
@@ -3517,6 +3537,133 @@ interface RemoteAgentExecuteResponse {
3517
3537
  streamUrl: string;
3518
3538
  }
3519
3539
 
3540
+ /**
3541
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
3542
+ *
3543
+ * An AI function is a published prompt in the Cadra Prompts library that makes
3544
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
3545
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
3546
+ * by slot key.
3547
+ */
3548
+ /** Output kind of an AI function. */
3549
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
3550
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
3551
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
3552
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
3553
+ type AiFunctionVariableValue = string | number | boolean;
3554
+ /** Parameters (variables) for one run, keyed by parameter name. */
3555
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
3556
+ /** How a run names its function (§4). */
3557
+ type AiFunctionRef = {
3558
+ slot: string;
3559
+ } | {
3560
+ functionKey: string;
3561
+ } | {
3562
+ promptUuid: string;
3563
+ };
3564
+ /** One declared parameter of a function's live (golden) version — D27a. */
3565
+ interface AiFunctionParameter {
3566
+ name: string;
3567
+ type: AiFunctionParameterType;
3568
+ required: boolean;
3569
+ defaultValue?: AiFunctionVariableValue;
3570
+ maxLength?: number;
3571
+ options?: string[];
3572
+ description?: string;
3573
+ }
3574
+ /**
3575
+ * The discovery "index" entry for one callable function — D27a. Built from the
3576
+ * golden version snapshot; never carries prompt or system text.
3577
+ */
3578
+ interface AiFunctionDescriptor {
3579
+ functionKey: string;
3580
+ title: string;
3581
+ description?: string | null;
3582
+ outputKind: AiFunctionOutputKind;
3583
+ /** The live (golden) version number. */
3584
+ liveVersion: number;
3585
+ parameters: AiFunctionParameter[];
3586
+ /** JSON schema of the output, for `json` functions. */
3587
+ outputSchema?: Record<string, unknown> | null;
3588
+ }
3589
+ /** Who paid for a run (D4). */
3590
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
3591
+ /** Runtime params a slot may accept per run (D26d3). */
3592
+ interface AiFunctionRuntimeParams {
3593
+ aspect_ratio?: string;
3594
+ image_size?: string;
3595
+ }
3596
+ /** Options for the object form `run(ref, { variables, … })`. */
3597
+ interface AiFunctionRunOptions {
3598
+ /** Parameters for this run (sent as `variables`). */
3599
+ variables: AiFunctionVariables;
3600
+ /** Pin a published version number (D3d). Skips the client-side check. */
3601
+ version?: number;
3602
+ /** Idempotency key (uuid). Generated when omitted (D15). */
3603
+ idempotencyKey?: string;
3604
+ /** Slot runtime params (D26d3). */
3605
+ params?: AiFunctionRuntimeParams;
3606
+ /** `false` skips the client-side parameter check (D27c). Default true. */
3607
+ validate?: boolean;
3608
+ }
3609
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
3610
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
3611
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
3612
+ interface AiFunctionImage {
3613
+ mimeType: string;
3614
+ url?: string;
3615
+ bytes?: Uint8Array;
3616
+ }
3617
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
3618
+ type AiFunctionOutput<TOutput = unknown> = {
3619
+ type: 'text';
3620
+ text: string;
3621
+ } | {
3622
+ type: 'json';
3623
+ json: TOutput;
3624
+ } | {
3625
+ type: 'image';
3626
+ images: AiFunctionImage[];
3627
+ };
3628
+ /** Token and billing usage of a run (§4). */
3629
+ interface AiFunctionUsage {
3630
+ promptTokens: number;
3631
+ completionTokens: number;
3632
+ imageCount: number;
3633
+ billedTo: AiFunctionBilledTo;
3634
+ }
3635
+ /** Result of a successful run (§4). */
3636
+ interface AiFunctionRunResult<TOutput = unknown> {
3637
+ /** = the run's execution uuid (usage-ledger executionUuid). */
3638
+ executionId: string;
3639
+ functionUuid: string;
3640
+ version: number;
3641
+ output: AiFunctionOutput<TOutput>;
3642
+ usage: AiFunctionUsage;
3643
+ latencyMs: number;
3644
+ }
3645
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
3646
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
3647
+ /** Safe projection of one of the caller org's own runs (§6.5). */
3648
+ interface AiFunctionRun {
3649
+ executionId: string;
3650
+ ref: {
3651
+ slot?: string;
3652
+ functionKey?: string;
3653
+ promptUuid?: string;
3654
+ };
3655
+ version: number | null;
3656
+ status: AiFunctionRunStatus;
3657
+ errorCode: string | null;
3658
+ promptTokens: number | null;
3659
+ completionTokens: number | null;
3660
+ imageCount: number | null;
3661
+ latencyMs: number | null;
3662
+ billedTo: AiFunctionBilledTo | null;
3663
+ createdAt: string;
3664
+ finishedAt: string | null;
3665
+ }
3666
+
3520
3667
  /**
3521
3668
  * Base Resource API
3522
3669
  *
@@ -3545,6 +3692,7 @@ declare abstract class BaseResourceAPI {
3545
3692
  protected httpPost<T>(path: string, body?: unknown, options?: {
3546
3693
  idempotencyKey?: string;
3547
3694
  skipRetry?: boolean;
3695
+ timeoutMs?: number;
3548
3696
  }): Promise<T>;
3549
3697
  /**
3550
3698
  * HTTP PATCH request helper
@@ -4744,6 +4892,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
4744
4892
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
4745
4893
  }
4746
4894
 
4895
+ /**
4896
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
4897
+ *
4898
+ * @example
4899
+ * ```typescript
4900
+ * // Discover what the org can call, and with which parameters
4901
+ * const functions = await client.aiFunctions.list();
4902
+ * const fn = await client.aiFunctions.get('summarise_ticket');
4903
+ *
4904
+ * // Call it — parameters are checked against the live version before sending
4905
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
4906
+ * if (result.output.type === 'text') console.log(result.output.text);
4907
+ * ```
4908
+ */
4909
+
4910
+ /**
4911
+ * AI Functions API
4912
+ */
4913
+ declare class AiFunctionsAPI extends BaseResourceAPI {
4914
+ private readonly descriptorCache;
4915
+ constructor(http: HttpClient);
4916
+ /**
4917
+ * List the functions this org can call — the index (D27a). Each entry carries
4918
+ * the live version's typed parameters; never prompt text.
4919
+ */
4920
+ list(): Promise<AiFunctionDescriptor[]>;
4921
+ /**
4922
+ * Get one function's descriptor by key (D27a).
4923
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
4924
+ */
4925
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
4926
+ /**
4927
+ * Read one of this org's own runs (safe projection, §6.5).
4928
+ */
4929
+ getRun(executionId: string): Promise<AiFunctionRun>;
4930
+ /** Forget cached descriptors (one key, or all). */
4931
+ clearDescriptorCache(functionKey?: string): void;
4932
+ /**
4933
+ * Run an AI function — one paid provider call.
4934
+ *
4935
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
4936
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
4937
+ *
4938
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
4939
+ * against the live version first (D27c); a problem throws
4940
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
4941
+ * auto-retried; an idempotency key is generated when omitted.
4942
+ *
4943
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
4944
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
4945
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
4946
+ */
4947
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
4948
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
4949
+ private cacheDescriptor;
4950
+ private getCachedDescriptor;
4951
+ private mapRunError;
4952
+ }
4953
+
4747
4954
  /**
4748
4955
  * Cadra Client
4749
4956
  *
@@ -4888,6 +5095,10 @@ declare class CadraClient {
4888
5095
  * Remote runner operations (list)
4889
5096
  */
4890
5097
  readonly remoteRunners: RemoteRunnersAPI;
5098
+ /**
5099
+ * AI function operations (list, get, run, getRun) — p93
5100
+ */
5101
+ readonly aiFunctions: AiFunctionsAPI;
4891
5102
  /**
4892
5103
  * Create a new AI SaaS client
4893
5104
  *
@@ -1272,6 +1272,16 @@ interface ToolResultEvent {
1272
1272
  result: unknown;
1273
1273
  /** Duration in milliseconds */
1274
1274
  durationMs: number;
1275
+ /**
1276
+ * CAD-243: true when the tool call FAILED (the producer stamps
1277
+ * `isError: true` + `status: 'failed'` on a thrown tool call). Absent on
1278
+ * older producers — consumers then fall back to the result shape.
1279
+ */
1280
+ isError?: boolean;
1281
+ /** CAD-243: producer verdict, `'failed'` for a failed call. */
1282
+ status?: string;
1283
+ /** CAD-243: error text for a failed call. */
1284
+ error?: string;
1275
1285
  /** See {@link ToolCallEvent.forwardedFrom} */
1276
1286
  forwardedFrom?: string;
1277
1287
  /** See {@link ToolCallEvent.sourceExecutionId} (CAD-87 S1-001). */
@@ -2859,6 +2869,13 @@ interface RequestOptions {
2859
2869
  skipRetry?: boolean;
2860
2870
  /** Idempotency key */
2861
2871
  idempotencyKey?: string;
2872
+ /**
2873
+ * Per-request timeout in milliseconds. Overrides the client-wide
2874
+ * `config.timeout` for this call only (p93 AIF-010: a paid AI-function run
2875
+ * waits for the server's route ceiling while every other call keeps the
2876
+ * 30 s default).
2877
+ */
2878
+ timeoutMs?: number;
2862
2879
  }
2863
2880
  /**
2864
2881
  * HTTP Client class
@@ -2868,6 +2885,8 @@ declare class HttpClient {
2868
2885
  private tokenRefreshAttempts;
2869
2886
  private readonly maxTokenRefreshAttempts;
2870
2887
  constructor(config: HttpClientConfig);
2888
+ /** The client-wide request timeout (ms) this client was configured with. */
2889
+ get timeoutMs(): number;
2871
2890
  /**
2872
2891
  * Get authorization header value
2873
2892
  */
@@ -2890,6 +2909,7 @@ declare class HttpClient {
2890
2909
  post<T>(path: string, body?: unknown, options?: {
2891
2910
  idempotencyKey?: string;
2892
2911
  skipRetry?: boolean;
2912
+ timeoutMs?: number;
2893
2913
  }): Promise<T>;
2894
2914
  /**
2895
2915
  * PATCH request
@@ -3517,6 +3537,133 @@ interface RemoteAgentExecuteResponse {
3517
3537
  streamUrl: string;
3518
3538
  }
3519
3539
 
3540
+ /**
3541
+ * AI function types (p93 — specs §4 run contract, D27 discovery, §6.5 run reads).
3542
+ *
3543
+ * An AI function is a published prompt in the Cadra Prompts library that makes
3544
+ * ONE direct AI-provider call (never an agent). Callers reference it by its
3545
+ * `functionKey` (unique per org), by prompt uuid, or — for platform features —
3546
+ * by slot key.
3547
+ */
3548
+ /** Output kind of an AI function. */
3549
+ type AiFunctionOutputKind = 'text' | 'json' | 'image';
3550
+ /** Parameter (prompt variable) types — specs D10 + D26d. */
3551
+ type AiFunctionParameterType = 'string' | 'text' | 'number' | 'boolean' | 'enum' | 'image';
3552
+ /** A value passed for one parameter. `image` parameters take an artifact uuid (string). */
3553
+ type AiFunctionVariableValue = string | number | boolean;
3554
+ /** Parameters (variables) for one run, keyed by parameter name. */
3555
+ type AiFunctionVariables = Record<string, AiFunctionVariableValue>;
3556
+ /** How a run names its function (§4). */
3557
+ type AiFunctionRef = {
3558
+ slot: string;
3559
+ } | {
3560
+ functionKey: string;
3561
+ } | {
3562
+ promptUuid: string;
3563
+ };
3564
+ /** One declared parameter of a function's live (golden) version — D27a. */
3565
+ interface AiFunctionParameter {
3566
+ name: string;
3567
+ type: AiFunctionParameterType;
3568
+ required: boolean;
3569
+ defaultValue?: AiFunctionVariableValue;
3570
+ maxLength?: number;
3571
+ options?: string[];
3572
+ description?: string;
3573
+ }
3574
+ /**
3575
+ * The discovery "index" entry for one callable function — D27a. Built from the
3576
+ * golden version snapshot; never carries prompt or system text.
3577
+ */
3578
+ interface AiFunctionDescriptor {
3579
+ functionKey: string;
3580
+ title: string;
3581
+ description?: string | null;
3582
+ outputKind: AiFunctionOutputKind;
3583
+ /** The live (golden) version number. */
3584
+ liveVersion: number;
3585
+ parameters: AiFunctionParameter[];
3586
+ /** JSON schema of the output, for `json` functions. */
3587
+ outputSchema?: Record<string, unknown> | null;
3588
+ }
3589
+ /** Who paid for a run (D4). */
3590
+ type AiFunctionBilledTo = 'own_key' | 'credits' | 'platform_funded';
3591
+ /** Runtime params a slot may accept per run (D26d3). */
3592
+ interface AiFunctionRuntimeParams {
3593
+ aspect_ratio?: string;
3594
+ image_size?: string;
3595
+ }
3596
+ /** Options for the object form `run(ref, { variables, … })`. */
3597
+ interface AiFunctionRunOptions {
3598
+ /** Parameters for this run (sent as `variables`). */
3599
+ variables: AiFunctionVariables;
3600
+ /** Pin a published version number (D3d). Skips the client-side check. */
3601
+ version?: number;
3602
+ /** Idempotency key (uuid). Generated when omitted (D15). */
3603
+ idempotencyKey?: string;
3604
+ /** Slot runtime params (D26d3). */
3605
+ params?: AiFunctionRuntimeParams;
3606
+ /** `false` skips the client-side parameter check (D27c). Default true. */
3607
+ validate?: boolean;
3608
+ }
3609
+ /** Options for the shorthand `run('function_key', parameters, opts)`. */
3610
+ type AiFunctionRunShorthandOptions = Omit<AiFunctionRunOptions, 'variables'>;
3611
+ /** Image produced by an `image` function. Over HTTP only `url` (presigned, 1 h) is set. */
3612
+ interface AiFunctionImage {
3613
+ mimeType: string;
3614
+ url?: string;
3615
+ bytes?: Uint8Array;
3616
+ }
3617
+ /** Output of a run, by kind (§4). `TOutput` types `json`. */
3618
+ type AiFunctionOutput<TOutput = unknown> = {
3619
+ type: 'text';
3620
+ text: string;
3621
+ } | {
3622
+ type: 'json';
3623
+ json: TOutput;
3624
+ } | {
3625
+ type: 'image';
3626
+ images: AiFunctionImage[];
3627
+ };
3628
+ /** Token and billing usage of a run (§4). */
3629
+ interface AiFunctionUsage {
3630
+ promptTokens: number;
3631
+ completionTokens: number;
3632
+ imageCount: number;
3633
+ billedTo: AiFunctionBilledTo;
3634
+ }
3635
+ /** Result of a successful run (§4). */
3636
+ interface AiFunctionRunResult<TOutput = unknown> {
3637
+ /** = the run's execution uuid (usage-ledger executionUuid). */
3638
+ executionId: string;
3639
+ functionUuid: string;
3640
+ version: number;
3641
+ output: AiFunctionOutput<TOutput>;
3642
+ usage: AiFunctionUsage;
3643
+ latencyMs: number;
3644
+ }
3645
+ /** Run status as reported by run reads (D12; `abandoned` is computed on read). */
3646
+ type AiFunctionRunStatus = 'running' | 'succeeded' | 'failed_provider' | 'failed_timeout' | 'refused_billing' | 'failed_output' | 'failed_delivery' | 'abandoned';
3647
+ /** Safe projection of one of the caller org's own runs (§6.5). */
3648
+ interface AiFunctionRun {
3649
+ executionId: string;
3650
+ ref: {
3651
+ slot?: string;
3652
+ functionKey?: string;
3653
+ promptUuid?: string;
3654
+ };
3655
+ version: number | null;
3656
+ status: AiFunctionRunStatus;
3657
+ errorCode: string | null;
3658
+ promptTokens: number | null;
3659
+ completionTokens: number | null;
3660
+ imageCount: number | null;
3661
+ latencyMs: number | null;
3662
+ billedTo: AiFunctionBilledTo | null;
3663
+ createdAt: string;
3664
+ finishedAt: string | null;
3665
+ }
3666
+
3520
3667
  /**
3521
3668
  * Base Resource API
3522
3669
  *
@@ -3545,6 +3692,7 @@ declare abstract class BaseResourceAPI {
3545
3692
  protected httpPost<T>(path: string, body?: unknown, options?: {
3546
3693
  idempotencyKey?: string;
3547
3694
  skipRetry?: boolean;
3695
+ timeoutMs?: number;
3548
3696
  }): Promise<T>;
3549
3697
  /**
3550
3698
  * HTTP PATCH request helper
@@ -4744,6 +4892,65 @@ declare class RemoteRunnersAPI extends BaseResourceAPI {
4744
4892
  list(options?: RemoteRunnerListOptions): Promise<PaginatedResponse<RemoteRunner>>;
4745
4893
  }
4746
4894
 
4895
+ /**
4896
+ * AI Functions API (p93 AIF-010 — specs §9, D27).
4897
+ *
4898
+ * @example
4899
+ * ```typescript
4900
+ * // Discover what the org can call, and with which parameters
4901
+ * const functions = await client.aiFunctions.list();
4902
+ * const fn = await client.aiFunctions.get('summarise_ticket');
4903
+ *
4904
+ * // Call it — parameters are checked against the live version before sending
4905
+ * const result = await client.aiFunctions.run('summarise_ticket', { ticket_text: '…' });
4906
+ * if (result.output.type === 'text') console.log(result.output.text);
4907
+ * ```
4908
+ */
4909
+
4910
+ /**
4911
+ * AI Functions API
4912
+ */
4913
+ declare class AiFunctionsAPI extends BaseResourceAPI {
4914
+ private readonly descriptorCache;
4915
+ constructor(http: HttpClient);
4916
+ /**
4917
+ * List the functions this org can call — the index (D27a). Each entry carries
4918
+ * the live version's typed parameters; never prompt text.
4919
+ */
4920
+ list(): Promise<AiFunctionDescriptor[]>;
4921
+ /**
4922
+ * Get one function's descriptor by key (D27a).
4923
+ * `NotFoundError` (`FUNCTION_NOT_FOUND`) / `ConflictError` (`FUNCTION_NOT_PUBLISHED`).
4924
+ */
4925
+ get(functionKey: string): Promise<AiFunctionDescriptor>;
4926
+ /**
4927
+ * Read one of this org's own runs (safe projection, §6.5).
4928
+ */
4929
+ getRun(executionId: string): Promise<AiFunctionRun>;
4930
+ /** Forget cached descriptors (one key, or all). */
4931
+ clearDescriptorCache(functionKey?: string): void;
4932
+ /**
4933
+ * Run an AI function — one paid provider call.
4934
+ *
4935
+ * - `run('function_key', parameters, opts?)` — shorthand for `{ functionKey }`.
4936
+ * - `run({ functionKey | promptUuid | slot }, { variables, version?, idempotencyKey?, params?, validate? })`.
4937
+ *
4938
+ * For a `functionKey` ref without a pinned `version`, parameters are checked
4939
+ * against the live version first (D27c); a problem throws
4940
+ * `AiFunctionParameterError` and NO run request is sent. Paid runs are never
4941
+ * auto-retried; an idempotency key is generated when omitted.
4942
+ *
4943
+ * @throws AiFunctionParameterError — client-side check failed (nothing sent)
4944
+ * @throws AiFunctionDuplicateError — 409 `DUPLICATE_REQUEST`
4945
+ * @throws AiFunctionChargedError — the run was metered but its output failed (`details.charged`)
4946
+ */
4947
+ run<TOutput = unknown>(functionKey: string, parameters: AiFunctionVariables, opts?: AiFunctionRunShorthandOptions): Promise<AiFunctionRunResult<TOutput>>;
4948
+ run<TOutput = unknown>(ref: AiFunctionRef, options: AiFunctionRunOptions): Promise<AiFunctionRunResult<TOutput>>;
4949
+ private cacheDescriptor;
4950
+ private getCachedDescriptor;
4951
+ private mapRunError;
4952
+ }
4953
+
4747
4954
  /**
4748
4955
  * Cadra Client
4749
4956
  *
@@ -4888,6 +5095,10 @@ declare class CadraClient {
4888
5095
  * Remote runner operations (list)
4889
5096
  */
4890
5097
  readonly remoteRunners: RemoteRunnersAPI;
5098
+ /**
5099
+ * AI function operations (list, get, run, getRun) — p93
5100
+ */
5101
+ readonly aiFunctions: AiFunctionsAPI;
4891
5102
  /**
4892
5103
  * Create a new AI SaaS client
4893
5104
  *