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