@aithos/sdk 0.1.0-alpha.5 → 0.1.0-alpha.51
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 +245 -7
- package/dist/src/apps.d.ts +224 -0
- package/dist/src/apps.js +432 -0
- package/dist/src/assets.d.ts +209 -0
- package/dist/src/assets.js +534 -0
- package/dist/src/auth-api.d.ts +219 -0
- package/dist/src/auth-api.js +248 -0
- package/dist/src/auth.d.ts +543 -0
- package/dist/src/auth.js +937 -31
- package/dist/src/compute.d.ts +464 -6
- package/dist/src/compute.js +746 -20
- package/dist/src/data-schema-contacts-v1.d.ts +14 -0
- package/dist/src/data-schema-contacts-v1.js +28 -0
- package/dist/src/data.d.ts +342 -0
- package/dist/src/data.js +1002 -0
- package/dist/src/endpoints.d.ts +25 -0
- package/dist/src/endpoints.js +7 -0
- package/dist/src/ethos.d.ts +85 -0
- package/dist/src/ethos.js +463 -7
- package/dist/src/index.d.ts +17 -6
- package/dist/src/index.js +25 -3
- package/dist/src/internal/delegate-bundle.js +7 -2
- package/dist/src/internal/envelope.d.ts +93 -0
- package/dist/src/internal/envelope.js +59 -0
- package/dist/src/mandates.d.ts +111 -2
- package/dist/src/mandates.js +150 -7
- package/dist/src/react/AithosAsset.d.ts +66 -0
- package/dist/src/react/AithosAsset.js +67 -0
- package/dist/src/react/context.d.ts +29 -0
- package/dist/src/react/context.js +31 -0
- package/dist/src/react/index.d.ts +29 -0
- package/dist/src/react/index.js +31 -0
- package/dist/src/react/use-aithos-asset.d.ts +39 -0
- package/dist/src/react/use-aithos-asset.js +118 -0
- package/dist/src/react/use-transcribe-pending.d.ts +21 -0
- package/dist/src/react/use-transcribe-pending.js +47 -0
- package/dist/src/sdk.d.ts +10 -0
- package/dist/src/sdk.js +22 -0
- package/dist/src/transcribe-resilience.d.ts +57 -0
- package/dist/src/transcribe-resilience.js +203 -0
- package/dist/src/web.d.ts +279 -0
- package/dist/src/web.js +186 -0
- package/dist/test/auth-j3.test.js +32 -1
- package/dist/test/canonical-conformance.test.d.ts +2 -0
- package/dist/test/canonical-conformance.test.js +86 -0
- package/dist/test/compute-delegate-path.test.d.ts +2 -0
- package/dist/test/compute-delegate-path.test.js +183 -0
- package/dist/test/compute.test.js +4 -0
- package/dist/test/endpoints.test.js +30 -1
- package/dist/test/envelope-core-conformance.test.d.ts +2 -0
- package/dist/test/envelope-core-conformance.test.js +75 -0
- package/dist/test/envelope.test.d.ts +2 -0
- package/dist/test/envelope.test.js +318 -0
- package/dist/test/ethos-first-edition.test.d.ts +2 -0
- package/dist/test/ethos-first-edition.test.js +371 -0
- package/dist/test/mandates-compute.test.d.ts +2 -0
- package/dist/test/mandates-compute.test.js +256 -0
- package/dist/test/sdk.test.js +11 -2
- package/dist/test/signup-bootstrap.test.d.ts +2 -0
- package/dist/test/signup-bootstrap.test.js +311 -0
- package/dist/test/transcribe-invoke.test.d.ts +2 -0
- package/dist/test/transcribe-invoke.test.js +204 -0
- package/dist/test/transcribe.test.d.ts +2 -0
- package/dist/test/transcribe.test.js +186 -0
- package/dist/test/web.test.d.ts +2 -0
- package/dist/test/web.test.js +270 -0
- package/package.json +20 -3
package/dist/src/compute.d.ts
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
import type { AithosAuth } from "./auth.js";
|
|
2
2
|
import { type AithosSdkEndpoints } from "./endpoints.js";
|
|
3
|
+
import { type LocalPendingEntry, type TranscribeDraftMeta, type TranscribeDraftRecord } from "./transcribe-resilience.js";
|
|
3
4
|
export interface ComputeMessage {
|
|
4
5
|
readonly role: "user" | "assistant";
|
|
5
6
|
readonly content: string;
|
|
6
7
|
}
|
|
7
8
|
export interface InvokeBedrockArgs {
|
|
8
|
-
/**
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Mandate ID under which this call should be attributed.
|
|
11
|
+
*
|
|
12
|
+
* - **Owner sessions**: optional. The SDK uses the owner's own DID
|
|
13
|
+
* as a sentinel "self" mandate id — the proxy skips all
|
|
14
|
+
* mandate-related checks (scope, allowed_models, caps) when the
|
|
15
|
+
* envelope is owner-signed, so the value is informational only.
|
|
16
|
+
* - **Delegate sessions**: required. Must reference the imported
|
|
17
|
+
* mandate bundle the SDK signs with (the proxy enforces
|
|
18
|
+
* `compute.invoke` scope and any `allowed_models` filter).
|
|
19
|
+
*/
|
|
20
|
+
readonly mandateId?: string;
|
|
10
21
|
/**
|
|
11
22
|
* Model id. Today the proxy accepts the canonical Aithos identifiers:
|
|
12
|
-
* `claude-sonnet-4-6`, `claude-haiku-4-5`, `claude-opus-4-
|
|
23
|
+
* `claude-sonnet-4-6`, `claude-haiku-4-5`, `claude-opus-4-6`.
|
|
13
24
|
* The proxy maps these to Bedrock cross-region inference profiles.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: `claude-opus-4-7` is also provisioned on the Bedrock account
|
|
27
|
+
* but commercial access is gated behind an AWS Sales unlock (as of
|
|
28
|
+
* May 2026) — InvokeModel returns AccessDeniedException pointing to
|
|
29
|
+
* AWS Sales. Stick with `claude-opus-4-6` until the unlock lands.
|
|
14
30
|
*/
|
|
15
31
|
readonly model: string;
|
|
16
32
|
/** Conversation messages (user / assistant turns). */
|
|
@@ -43,6 +59,301 @@ export interface InvokeBedrockResult {
|
|
|
43
59
|
readonly walletBalance: number;
|
|
44
60
|
/** Audit log id for traceability. */
|
|
45
61
|
readonly auditId: string;
|
|
62
|
+
/**
|
|
63
|
+
* Which wallet was actually debited (draft §13.8, V0.1 sponsorship).
|
|
64
|
+
* - `"sponsored"` — the app developer's wallet (free trial / promo).
|
|
65
|
+
* - `"grant"` — the user's grant bucket (Aithos-donated credits).
|
|
66
|
+
* - `"purchase"` — the user's own paid credits.
|
|
67
|
+
* Absent on legacy server responses (pre-2026-05-27).
|
|
68
|
+
*/
|
|
69
|
+
readonly fundedBy?: "sponsored" | "grant" | "purchase";
|
|
70
|
+
/**
|
|
71
|
+
* If `fundedBy === "sponsored"`, the sponsor's DID (= the developer
|
|
72
|
+
* who pre-paid the pool). Absent otherwise.
|
|
73
|
+
*/
|
|
74
|
+
readonly sponsoredBy?: string;
|
|
75
|
+
/**
|
|
76
|
+
* If sponsored, the signed `ConsumptionReceipt` id (`rcpt_…`) the
|
|
77
|
+
* authority issued for this debit. The receipt itself can be fetched
|
|
78
|
+
* later via the receipts API (V0.2). Present on every signed call
|
|
79
|
+
* when the authority is configured, regardless of `fundedBy`.
|
|
80
|
+
*/
|
|
81
|
+
readonly receiptId?: string;
|
|
82
|
+
/**
|
|
83
|
+
* If sponsored, remaining microcredits for THIS consumer in this
|
|
84
|
+
* sponsorship pool. Useful for displaying "X free calls remaining"
|
|
85
|
+
* without an extra round-trip. May be `0` even when the user can
|
|
86
|
+
* still consume — when the authority can't compute the remainder
|
|
87
|
+
* cheaply (e.g. windowed caps), the SDK gets a conservative 0 and
|
|
88
|
+
* the SPA should fall back to calling `sdk.apps.getSponsorshipStatusForUser`
|
|
89
|
+
* (V0.2).
|
|
90
|
+
*/
|
|
91
|
+
readonly sponsoredRemainingForUser?: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Stable cross-provider image model ids supported by the Aithos compute
|
|
95
|
+
* proxy. New models can be added on the server side without an SDK
|
|
96
|
+
* release — but tagging the namespaced literal here gives consumers
|
|
97
|
+
* autocomplete + type-checking.
|
|
98
|
+
*
|
|
99
|
+
* The `image:` prefix is part of the wire contract: the server uses it
|
|
100
|
+
* to disambiguate text and image dispatch when a mandate's
|
|
101
|
+
* `allowed_models` mixes both.
|
|
102
|
+
*/
|
|
103
|
+
export type ImageModelId = "image:flux-schnell" | "image:flux-dev" | "image:flux-pro-1.1" | "image:flux-pro-1.1-ultra" | "image:imagen-3" | "image:imagen-4" | "image:nano-banana";
|
|
104
|
+
/** Aspect ratios accepted by `invokeImage`. */
|
|
105
|
+
export type ImageAspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "21:9";
|
|
106
|
+
export interface InvokeImageArgs {
|
|
107
|
+
/**
|
|
108
|
+
* Mandate ID under which this call should be attributed.
|
|
109
|
+
*
|
|
110
|
+
* - **Owner sessions**: optional. The SDK uses the owner's own DID
|
|
111
|
+
* as a sentinel "self" mandate id — the proxy skips all
|
|
112
|
+
* mandate-related checks when the envelope is owner-signed.
|
|
113
|
+
* - **Delegate sessions**: required. Must reference the imported
|
|
114
|
+
* mandate bundle the SDK signs with.
|
|
115
|
+
*/
|
|
116
|
+
readonly mandateId?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Image model id. Defaults to `"image:flux-pro-1.1"` on the SDK side
|
|
119
|
+
* if omitted — the server allowlist is the source of truth for which
|
|
120
|
+
* ones actually work.
|
|
121
|
+
*/
|
|
122
|
+
readonly model?: ImageModelId;
|
|
123
|
+
/** What to draw. */
|
|
124
|
+
readonly prompt: string;
|
|
125
|
+
/** Optional comma-separated list of things to avoid (e.g. "blurry, watermark"). */
|
|
126
|
+
readonly negativePrompt?: string;
|
|
127
|
+
/** Default 1:1. */
|
|
128
|
+
readonly aspectRatio?: ImageAspectRatio;
|
|
129
|
+
/** Deterministic seed (re-rolls). Omit for random. */
|
|
130
|
+
readonly seed?: number;
|
|
131
|
+
/** Number of images to generate. Default 1, max 4. */
|
|
132
|
+
readonly numberOfImages?: number;
|
|
133
|
+
/** Idempotency key for retries (generated if omitted). */
|
|
134
|
+
readonly idempotencyKey?: string;
|
|
135
|
+
/** Abort signal to cancel the request (network + provider call). */
|
|
136
|
+
readonly signal?: AbortSignal;
|
|
137
|
+
}
|
|
138
|
+
export interface InvokeImageImage {
|
|
139
|
+
/** Base64-encoded image bytes (raw, no data: URI prefix). */
|
|
140
|
+
readonly base64: string;
|
|
141
|
+
/** "image/png" | "image/jpeg". */
|
|
142
|
+
readonly contentType: string;
|
|
143
|
+
readonly width: number;
|
|
144
|
+
readonly height: number;
|
|
145
|
+
}
|
|
146
|
+
export interface InvokeImageResult {
|
|
147
|
+
readonly images: readonly InvokeImageImage[];
|
|
148
|
+
/** Seed actually used by the provider (echoed back even when caller didn't set one). */
|
|
149
|
+
readonly seed: number;
|
|
150
|
+
/** Microcredits debited from the wallet (exact — no reconcile path for images). */
|
|
151
|
+
readonly creditsCharged: number;
|
|
152
|
+
/** Wallet balance after debit. */
|
|
153
|
+
readonly walletBalance: number;
|
|
154
|
+
/** Audit log id for traceability. */
|
|
155
|
+
readonly auditId: string;
|
|
156
|
+
}
|
|
157
|
+
export interface InvokeBedrockVisionArgs {
|
|
158
|
+
readonly mandateId?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Model id. Sonnet 4.6 is the default — it's vision-capable and
|
|
161
|
+
* returns reliable structured JSON when prompted.
|
|
162
|
+
*/
|
|
163
|
+
readonly model?: string;
|
|
164
|
+
/** Source image — Blob (recommended) or raw base64. */
|
|
165
|
+
readonly image: Blob | {
|
|
166
|
+
readonly base64: string;
|
|
167
|
+
readonly contentType: string;
|
|
168
|
+
};
|
|
169
|
+
/** Text prompt accompanying the image. */
|
|
170
|
+
readonly prompt: string;
|
|
171
|
+
/** Optional system prompt. */
|
|
172
|
+
readonly system?: string;
|
|
173
|
+
readonly maxTokens?: number;
|
|
174
|
+
readonly temperature?: number;
|
|
175
|
+
readonly idempotencyKey?: string;
|
|
176
|
+
readonly signal?: AbortSignal;
|
|
177
|
+
}
|
|
178
|
+
export interface InvokeBedrockVisionResult {
|
|
179
|
+
readonly content: string;
|
|
180
|
+
readonly stopReason: StopReason;
|
|
181
|
+
readonly usage: {
|
|
182
|
+
readonly inputTokens: number;
|
|
183
|
+
readonly outputTokens: number;
|
|
184
|
+
};
|
|
185
|
+
readonly creditsCharged: number;
|
|
186
|
+
readonly walletBalance: number;
|
|
187
|
+
readonly auditId: string;
|
|
188
|
+
}
|
|
189
|
+
export interface InvokeSegmentationArgs {
|
|
190
|
+
/** Mandate id (optional for owner sessions — see InvokeImageArgs). */
|
|
191
|
+
readonly mandateId?: string;
|
|
192
|
+
/** Source image. Blob (recommended) or raw base64. */
|
|
193
|
+
readonly image: Blob | {
|
|
194
|
+
readonly base64: string;
|
|
195
|
+
readonly contentType: string;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Text phrase describing what to segment. Florence-2 is robust with
|
|
199
|
+
* natural-language descriptions: "the torso of the robot", "the
|
|
200
|
+
* dog's head", "the chest of the character".
|
|
201
|
+
*/
|
|
202
|
+
readonly textInput: string;
|
|
203
|
+
readonly idempotencyKey?: string;
|
|
204
|
+
readonly signal?: AbortSignal;
|
|
205
|
+
}
|
|
206
|
+
export interface SegmentPolygon {
|
|
207
|
+
readonly points: ReadonlyArray<{
|
|
208
|
+
readonly x: number;
|
|
209
|
+
readonly y: number;
|
|
210
|
+
}>;
|
|
211
|
+
}
|
|
212
|
+
export interface InvokeSegmentationResult {
|
|
213
|
+
/** All polygons Florence-2 returned (typically 1, sometimes a few when the prompt matches multiple regions). */
|
|
214
|
+
readonly polygons: readonly SegmentPolygon[];
|
|
215
|
+
/** Bbox of the first polygon for callers that only need a coarse target. */
|
|
216
|
+
readonly bbox: {
|
|
217
|
+
readonly left: number;
|
|
218
|
+
readonly top: number;
|
|
219
|
+
readonly right: number;
|
|
220
|
+
readonly bottom: number;
|
|
221
|
+
} | null;
|
|
222
|
+
readonly creditsCharged: number;
|
|
223
|
+
readonly walletBalance: number;
|
|
224
|
+
readonly auditId: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Stable cross-provider transcription model ids. The `transcribe:` prefix
|
|
228
|
+
* is part of the wire contract (mirrors `image:` for image models). New
|
|
229
|
+
* models can be added server-side without an SDK release; the union here
|
|
230
|
+
* gives autocomplete + type-checking for the common ones.
|
|
231
|
+
*/
|
|
232
|
+
export type TranscribeModelId = "transcribe:aws-fr-standard" | "transcribe:aws-en-standard";
|
|
233
|
+
/** Progress callback states emitted by {@link ComputeNamespace.invokeTranscribe}. */
|
|
234
|
+
export type TranscribeProgressState = {
|
|
235
|
+
readonly phase: "queued";
|
|
236
|
+
} | {
|
|
237
|
+
readonly phase: "uploading";
|
|
238
|
+
readonly bytesUploaded: number;
|
|
239
|
+
readonly totalBytes: number;
|
|
240
|
+
} | {
|
|
241
|
+
readonly phase: "starting";
|
|
242
|
+
} | {
|
|
243
|
+
readonly phase: "processing";
|
|
244
|
+
readonly elapsedSec: number;
|
|
245
|
+
} | {
|
|
246
|
+
readonly phase: "completed";
|
|
247
|
+
};
|
|
248
|
+
export interface TranscribeSegment {
|
|
249
|
+
readonly start_sec: number;
|
|
250
|
+
readonly end_sec: number;
|
|
251
|
+
readonly text: string;
|
|
252
|
+
readonly speaker_label?: string;
|
|
253
|
+
}
|
|
254
|
+
export interface TranscribeWord {
|
|
255
|
+
readonly start_sec: number;
|
|
256
|
+
readonly end_sec: number;
|
|
257
|
+
readonly content: string;
|
|
258
|
+
readonly confidence: number;
|
|
259
|
+
}
|
|
260
|
+
/** High-level args for the one-call {@link ComputeNamespace.invokeTranscribe}. */
|
|
261
|
+
export interface InvokeTranscribeArgs {
|
|
262
|
+
/** Mandate id — optional for owner sessions, required for delegate sessions. */
|
|
263
|
+
readonly mandateId?: string;
|
|
264
|
+
/** The audio to transcribe. `Blob` is supported in both Node 18+ and browsers. */
|
|
265
|
+
readonly audio: Blob;
|
|
266
|
+
/** Model alias. Default `"transcribe:aws-fr-standard"`. */
|
|
267
|
+
readonly model?: TranscribeModelId;
|
|
268
|
+
/** AWS language code override (e.g. `"fr-FR"`). Defaults to the model alias's language. */
|
|
269
|
+
readonly languageCode?: string;
|
|
270
|
+
/** Speaker diarization. Default `false`. */
|
|
271
|
+
readonly diarization?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Audio duration in seconds. REQUIRED on backends / non-browser runtimes
|
|
274
|
+
* (used for the wallet pre-debit estimate). In a browser it is probed
|
|
275
|
+
* automatically from the Blob when omitted; if probing fails the SDK
|
|
276
|
+
* falls back to a server-reconciled estimate of 0.
|
|
277
|
+
*/
|
|
278
|
+
readonly durationSecOverride?: number;
|
|
279
|
+
/** Idempotency key for replay-safe retries (generated if omitted). */
|
|
280
|
+
readonly idempotencyKey?: string;
|
|
281
|
+
/** Progress callback (upload bytes, processing elapsed, …). */
|
|
282
|
+
readonly onProgress?: (state: TranscribeProgressState) => void;
|
|
283
|
+
/** Abort signal — cancels upload + polling. */
|
|
284
|
+
readonly signal?: AbortSignal;
|
|
285
|
+
/**
|
|
286
|
+
* Polling cadence override (ms) for the status loop. Defaults to an
|
|
287
|
+
* exponential backoff 2s → 15s. Mainly for tests.
|
|
288
|
+
*/
|
|
289
|
+
readonly pollIntervalMs?: number;
|
|
290
|
+
}
|
|
291
|
+
export interface InvokeTranscribeResult {
|
|
292
|
+
readonly text: string;
|
|
293
|
+
readonly segments: readonly TranscribeSegment[];
|
|
294
|
+
readonly words: readonly TranscribeWord[];
|
|
295
|
+
readonly durationSec: number;
|
|
296
|
+
readonly languageCode: string;
|
|
297
|
+
readonly creditsCharged: number;
|
|
298
|
+
readonly walletBalance: number;
|
|
299
|
+
readonly auditId: string;
|
|
300
|
+
readonly jobId: string;
|
|
301
|
+
readonly fundedBy?: "sponsored" | "grant" | "purchase";
|
|
302
|
+
readonly sponsoredBy?: string;
|
|
303
|
+
readonly receiptId?: string;
|
|
304
|
+
}
|
|
305
|
+
export interface PrepareTranscribeArgs {
|
|
306
|
+
readonly contentType: string;
|
|
307
|
+
readonly durationSecEstimate?: number;
|
|
308
|
+
/** Selects the delegate signer for delegate sessions (not sent on the wire). */
|
|
309
|
+
readonly mandateId?: string;
|
|
310
|
+
readonly signal?: AbortSignal;
|
|
311
|
+
}
|
|
312
|
+
export interface PrepareTranscribeResult {
|
|
313
|
+
readonly jobId: string;
|
|
314
|
+
readonly uploadUrl: string;
|
|
315
|
+
readonly s3ObjectKey: string;
|
|
316
|
+
readonly expiresAt: number;
|
|
317
|
+
}
|
|
318
|
+
export interface StartTranscribeArgs {
|
|
319
|
+
readonly jobId: string;
|
|
320
|
+
readonly mandateId?: string;
|
|
321
|
+
readonly model: TranscribeModelId | string;
|
|
322
|
+
readonly durationSec: number;
|
|
323
|
+
readonly languageCode?: string;
|
|
324
|
+
readonly diarization?: boolean;
|
|
325
|
+
readonly idempotencyKey?: string;
|
|
326
|
+
readonly signal?: AbortSignal;
|
|
327
|
+
}
|
|
328
|
+
export interface StartTranscribeResult {
|
|
329
|
+
readonly jobId: string;
|
|
330
|
+
readonly status: "running";
|
|
331
|
+
readonly estimatedCredits: number;
|
|
332
|
+
readonly walletBalance: number;
|
|
333
|
+
readonly fundedBy?: "sponsored" | "grant" | "purchase";
|
|
334
|
+
readonly receiptId?: string;
|
|
335
|
+
}
|
|
336
|
+
export type TranscribeStatusResult = {
|
|
337
|
+
readonly jobId: string;
|
|
338
|
+
readonly status: "running";
|
|
339
|
+
readonly elapsedSec: number;
|
|
340
|
+
} | ({
|
|
341
|
+
readonly jobId: string;
|
|
342
|
+
readonly status: "completed";
|
|
343
|
+
} & InvokeTranscribeResult) | {
|
|
344
|
+
readonly jobId: string;
|
|
345
|
+
readonly status: "failed";
|
|
346
|
+
readonly error: {
|
|
347
|
+
readonly code: string;
|
|
348
|
+
readonly message: string;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
export interface TranscribeJobSummary {
|
|
352
|
+
readonly jobId: string;
|
|
353
|
+
readonly status: "prepared" | "running" | "completed" | "failed";
|
|
354
|
+
readonly createdAt: number;
|
|
355
|
+
readonly estimatedCredits?: number;
|
|
356
|
+
readonly creditsCharged?: number;
|
|
46
357
|
}
|
|
47
358
|
export interface ComputeNamespaceDeps {
|
|
48
359
|
readonly auth: AithosAuth;
|
|
@@ -63,11 +374,158 @@ export declare class ComputeNamespace {
|
|
|
63
374
|
* Invoke a Bedrock model through the compute proxy. See
|
|
64
375
|
* {@link InvokeBedrockArgs} and {@link InvokeBedrockResult}.
|
|
65
376
|
*
|
|
377
|
+
* Two signer paths are supported:
|
|
378
|
+
*
|
|
379
|
+
* - **Owner**: when the caller is signed in as an owner, the
|
|
380
|
+
* envelope is signed with the owner's `#public` sphere key and
|
|
381
|
+
* no mandate is attached (the proxy resolves the mandate
|
|
382
|
+
* server-side from `params.mandate_id`).
|
|
383
|
+
* - **Delegate**: when the caller is delegate-only (mandate
|
|
384
|
+
* imported via `auth.importMandate`), the envelope is signed
|
|
385
|
+
* with the delegate's bound keypair and the full SignedMandate
|
|
386
|
+
* is attached so the proxy can verify both signature and
|
|
387
|
+
* authorisation in one pass. The mandate must carry the
|
|
388
|
+
* `compute.invoke` scope and the proxy enforces its constraints
|
|
389
|
+
* (caps, allowed models, …) at server-side.
|
|
390
|
+
*
|
|
391
|
+
* Owner takes precedence: if a session has BOTH an owner and a
|
|
392
|
+
* matching delegate session, we use the owner key (more flexible —
|
|
393
|
+
* the mandate is dereferenced via `mandate_id` and there's no
|
|
394
|
+
* lifetime cliff if the delegate seed has been wiped).
|
|
395
|
+
*
|
|
66
396
|
* @throws {AithosSDKError} on protocol errors. The `code` field is one of
|
|
67
|
-
* `
|
|
68
|
-
* the proxy (`quota_exceeded`,
|
|
69
|
-
* …).
|
|
397
|
+
* `sdk_no_signer`, `sdk_no_delegate_for_mandate`, `network`, `http`,
|
|
398
|
+
* `empty`, or any code returned by the proxy (`quota_exceeded`,
|
|
399
|
+
* `mandate_revoked`, `insufficient_credits`, …).
|
|
70
400
|
*/
|
|
71
401
|
invokeBedrock(args: InvokeBedrockArgs): Promise<InvokeBedrockResult>;
|
|
402
|
+
/**
|
|
403
|
+
* Multimodal Bedrock invoke — image + text → text response.
|
|
404
|
+
* Default model: `claude-sonnet-4-6` (vision-capable, reliable JSON).
|
|
405
|
+
*
|
|
406
|
+
* Use when you need a VLM to reason about an image: locating
|
|
407
|
+
* features, structured extraction, semantic Q&A. Prompt the model
|
|
408
|
+
* to return JSON if you need structured output (the API itself is
|
|
409
|
+
* unstructured).
|
|
410
|
+
*/
|
|
411
|
+
invokeBedrockVision(args: InvokeBedrockVisionArgs): Promise<InvokeBedrockVisionResult>;
|
|
412
|
+
/**
|
|
413
|
+
* Generate one or more images through the Aithos compute proxy
|
|
414
|
+
* (currently powered by fal.ai FLUX models). Spec mirror of
|
|
415
|
+
* {@link invokeBedrock}: same envelope, same wallet path, same
|
|
416
|
+
* mandate-scope gate (`compute.invoke` + `allowed_models`). The
|
|
417
|
+
* separation at the JSON-RPC method level (`aithos.compute_invoke_image`
|
|
418
|
+
* vs `aithos.compute_invoke`) commits each envelope to a specific
|
|
419
|
+
* modality so a stolen text-invoke envelope cannot be replayed
|
|
420
|
+
* against the image endpoint.
|
|
421
|
+
*
|
|
422
|
+
* Default model: `"image:flux-pro-1.1"`. Default aspect ratio: 1:1.
|
|
423
|
+
* Default count: 1 image.
|
|
424
|
+
*
|
|
425
|
+
* Pricing is per image and deterministic (no token-based reconcile):
|
|
426
|
+
* - flux-schnell: 3 000 mc + fee per image
|
|
427
|
+
* - flux-dev: 25 000 mc + fee per image
|
|
428
|
+
* - flux-pro-1.1: 40 000 mc + fee per image
|
|
429
|
+
* - flux-pro-1.1-ultra: 60 000 mc + fee per image
|
|
430
|
+
*/
|
|
431
|
+
invokeImage(args: InvokeImageArgs): Promise<InvokeImageResult>;
|
|
432
|
+
/**
|
|
433
|
+
* Run text-prompted segmentation (Florence-2 referring-expression)
|
|
434
|
+
* on a source image. Returns one or more polygons hugging the
|
|
435
|
+
* region matching the text prompt.
|
|
436
|
+
*
|
|
437
|
+
* Use cases: locate the chest/torso area of a generated mascot
|
|
438
|
+
* for logo compositing, find the face zone for a thumbnail crop,
|
|
439
|
+
* extract a product from a marketing shot — anything that needs
|
|
440
|
+
* a precise mask + bbox from natural-language description.
|
|
441
|
+
*
|
|
442
|
+
* Pricing: flat 5 000 mc per call (~$0.005 — Florence-2 is cheap).
|
|
443
|
+
*/
|
|
444
|
+
invokeSegmentation(args: InvokeSegmentationArgs): Promise<InvokeSegmentationResult>;
|
|
445
|
+
/**
|
|
446
|
+
* Provision a transcription job and get a pre-signed S3 URL to PUT the
|
|
447
|
+
* audio to. No wallet debit. `mandateId` only selects the delegate
|
|
448
|
+
* signer (it is not part of the wire params for prepare).
|
|
449
|
+
*/
|
|
450
|
+
prepareTranscribe(args: PrepareTranscribeArgs): Promise<PrepareTranscribeResult>;
|
|
451
|
+
/**
|
|
452
|
+
* Verify the uploaded audio, pre-debit the wallet, and launch the AWS
|
|
453
|
+
* Transcribe job. Returns immediately with `status: "running"`.
|
|
454
|
+
*/
|
|
455
|
+
startTranscribe(args: StartTranscribeArgs): Promise<StartTranscribeResult>;
|
|
456
|
+
/**
|
|
457
|
+
* Poll a job's status. On completion the server finalises (reconcile +
|
|
458
|
+
* audit) and returns the transcript; a resumed poll after reconnect
|
|
459
|
+
* re-reads the transcript while it's still in the 24h output window.
|
|
460
|
+
*/
|
|
461
|
+
getTranscribeStatus(args: {
|
|
462
|
+
readonly jobId: string;
|
|
463
|
+
readonly mandateId?: string;
|
|
464
|
+
readonly signal?: AbortSignal;
|
|
465
|
+
}): Promise<TranscribeStatusResult>;
|
|
466
|
+
/**
|
|
467
|
+
* List the caller's transcription jobs. Excludes terminal `completed`
|
|
468
|
+
* jobs unless `includeCompleted` is set — the resilience "what's still
|
|
469
|
+
* pending server-side" query.
|
|
470
|
+
*/
|
|
471
|
+
listPendingTranscribes(args?: {
|
|
472
|
+
readonly includeCompleted?: boolean;
|
|
473
|
+
readonly mandateId?: string;
|
|
474
|
+
readonly signal?: AbortSignal;
|
|
475
|
+
}): Promise<{
|
|
476
|
+
readonly jobs: readonly TranscribeJobSummary[];
|
|
477
|
+
}>;
|
|
478
|
+
/**
|
|
479
|
+
* Transcribe an audio Blob to text in one call. Composes the four
|
|
480
|
+
* low-level methods: prepare → direct S3 upload → start → poll. Returns
|
|
481
|
+
* the transcript and stores NOTHING server-side beyond the ephemeral
|
|
482
|
+
* job — the consumer decides what to do with the result.
|
|
483
|
+
*
|
|
484
|
+
* Isomorphic: depends only on `Blob`, `fetch`/`XMLHttpRequest` and
|
|
485
|
+
* timers. On a backend, pass `durationSecOverride` (no Blob duration
|
|
486
|
+
* probing is possible without a DOM); in a browser the duration is
|
|
487
|
+
* probed automatically when omitted.
|
|
488
|
+
*
|
|
489
|
+
* Resilience: the job id is recorded in a localStorage tracker (browser)
|
|
490
|
+
* before upload, so `listLocalPendingTranscribes()` / `resumeTranscribe()`
|
|
491
|
+
* can recover a job whose result never arrived. In Node the tracker is a
|
|
492
|
+
* harmless in-memory no-op.
|
|
493
|
+
*/
|
|
494
|
+
invokeTranscribe(args: InvokeTranscribeArgs): Promise<InvokeTranscribeResult>;
|
|
495
|
+
/**
|
|
496
|
+
* Resume polling an in-flight job by id — for recovery after a reload or
|
|
497
|
+
* crash. Returns the final result and clears the job from the local
|
|
498
|
+
* pending tracker. Throws if the job has already failed.
|
|
499
|
+
*/
|
|
500
|
+
resumeTranscribe(jobId: string, opts?: {
|
|
501
|
+
readonly mandateId?: string;
|
|
502
|
+
readonly onProgress?: (state: TranscribeProgressState) => void;
|
|
503
|
+
readonly signal?: AbortSignal;
|
|
504
|
+
readonly pollIntervalMs?: number;
|
|
505
|
+
}): Promise<InvokeTranscribeResult>;
|
|
506
|
+
/** Snapshot of locally-tracked in-flight jobs (stable ref between mutations). */
|
|
507
|
+
listLocalPendingTranscribes(): readonly LocalPendingEntry[];
|
|
508
|
+
/** Stable snapshot for `useSyncExternalStore`-style consumers. */
|
|
509
|
+
getLocalPendingTranscribesSnapshot(): readonly LocalPendingEntry[];
|
|
510
|
+
/**
|
|
511
|
+
* Subscribe to changes in the local pending-jobs registry. Returns an
|
|
512
|
+
* unsubscribe function. Framework-agnostic: wrap it in a React
|
|
513
|
+
* `useSyncExternalStore`, a Vue effect, a Svelte store, etc.
|
|
514
|
+
*/
|
|
515
|
+
subscribeLocalPendingTranscribes(listener: () => void): () => void;
|
|
516
|
+
/**
|
|
517
|
+
* IndexedDB-backed draft queue: persist a recording before any network
|
|
518
|
+
* call, upload it when the user confirms. Browser-only (methods reject
|
|
519
|
+
* with TranscribeDraftUnavailableError when IndexedDB is absent).
|
|
520
|
+
*/
|
|
521
|
+
get transcribeDraft(): {
|
|
522
|
+
readonly save: (blob: Blob, meta?: TranscribeDraftMeta) => Promise<{
|
|
523
|
+
readonly draftId: string;
|
|
524
|
+
}>;
|
|
525
|
+
readonly list: () => Promise<readonly TranscribeDraftRecord[]>;
|
|
526
|
+
readonly get: (draftId: string) => Promise<TranscribeDraftRecord | null>;
|
|
527
|
+
readonly delete: (draftId: string) => Promise<void>;
|
|
528
|
+
readonly upload: (draftId: string, args: Omit<InvokeTranscribeArgs, "audio">) => Promise<InvokeTranscribeResult>;
|
|
529
|
+
};
|
|
72
530
|
}
|
|
73
531
|
//# sourceMappingURL=compute.d.ts.map
|