@ocno/oryn-sdk 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,800 @@
1
+ /** Website intent is data. Runtime, device, loader and download authority remain local. */
2
+ interface SelectionModelRef {
3
+ provider: "huggingface";
4
+ repository: string;
5
+ revision?: string;
6
+ files?: string[];
7
+ }
8
+ type ModelSelection = {
9
+ version: 1;
10
+ intent: "source-checkpoint";
11
+ sourceCheckpoint: SelectionModelRef;
12
+ } | {
13
+ version: 1;
14
+ intent: "preferred-variant";
15
+ sourceCheckpoint?: SelectionModelRef;
16
+ } | {
17
+ version: 1;
18
+ intent: "exact-artifact";
19
+ };
20
+ interface SelectionExplanation {
21
+ version: 1;
22
+ kind: "requested-artifact" | "same-checkpoint" | "different-model";
23
+ source: "local-measurements" | "active-configuration" | "deterministic-default";
24
+ confidence: "measured" | "heuristic" | "unknown";
25
+ catalogVersion: number;
26
+ rulesVersion: number;
27
+ ruleIds: string[];
28
+ reasons: string[];
29
+ }
30
+
31
+ interface TaskContractRef {
32
+ id: string;
33
+ revision: number;
34
+ }
35
+ type TaskFeatureState = "supported" | "unsupported" | "unknown" | "requires-input";
36
+ interface TaskParameter {
37
+ inputPointer: string;
38
+ valueSchema: Record<string, unknown>;
39
+ default?: unknown;
40
+ handling: "honored" | "fixed" | "unsupported" | "requires-input";
41
+ editable: boolean;
42
+ affects: Array<"result" | "memory" | "latency">;
43
+ unit?: string;
44
+ }
45
+ interface TaskProfile {
46
+ kind: "task-profile";
47
+ schemaVersion: 1;
48
+ profileId: string;
49
+ contract: TaskContractRef;
50
+ task: string;
51
+ inputModalities: Array<"text" | "image" | "audio" | "video" | "document">;
52
+ outputModalities: Array<"text" | "image" | "audio" | "video" | "embedding" | "structured">;
53
+ inputSchemaRef: string;
54
+ resultSchemaRef: string;
55
+ features: Record<string, TaskFeatureState>;
56
+ parameters: Record<string, TaskParameter>;
57
+ limits: Record<string, number>;
58
+ streamingChannels: string[];
59
+ extensions: Record<string, never>;
60
+ provenance: "runtime-tested" | "runtime-declared" | "adapter-derived" | "runtime-fallback";
61
+ }
62
+ interface TaskRequirements {
63
+ task?: string;
64
+ contract?: TaskContractRef;
65
+ requiredFeatures?: string[];
66
+ parameterValues?: Record<string, unknown>;
67
+ inputModalities?: TaskProfile["inputModalities"];
68
+ outputModalities?: TaskProfile["outputModalities"];
69
+ }
70
+
71
+ type ModelProvider = "huggingface";
72
+ type InputModality = "text" | "image" | "audio" | "video" | "document";
73
+ type OutputModality = "text" | "image" | "audio" | "video" | "embedding" | "structured";
74
+ type BehavioralCapability = "chat" | "streaming" | "structuredOutput" | "toolCalling" | "imageEditing" | "inpainting" | "outpainting" | "speechRecognition" | "speechSynthesis" | "audioOutput" | "lyrics" | "deterministicSeed" | "multimodalConversation";
75
+ interface RuntimeCapabilities {
76
+ runtimeAvailable: boolean;
77
+ runtimeState: "ready" | "starting" | "unavailable" | "error";
78
+ sdkVersion: string;
79
+ browserApiVersion?: string;
80
+ supportedModelProviders: ModelProvider[];
81
+ features: {
82
+ modelSelection?: boolean;
83
+ taskProfiles?: boolean;
84
+ modelRequests: boolean;
85
+ modelSubstitution: boolean;
86
+ streaming: boolean;
87
+ artifacts: boolean;
88
+ artifactUrls: boolean;
89
+ cancellation: boolean;
90
+ queueing: boolean;
91
+ multipleSubmittedJobs: boolean;
92
+ };
93
+ scheduler?: {
94
+ generation: {
95
+ globalAcrossOrigins: boolean;
96
+ maxConcurrentRunning: number;
97
+ };
98
+ };
99
+ }
100
+ /** Optional website-owned conveniences. All options default to disabled. */
101
+ interface LocalAIClientOptions {
102
+ /**
103
+ * Show one website-owned explanation when this document is opened outside
104
+ * Oryn Browser. This never probes the network or grants Local AI authority.
105
+ */
106
+ showOrynBrowserAlert?: boolean;
107
+ }
108
+ interface ModelRef {
109
+ files?: string[];
110
+ provider: "huggingface";
111
+ repository: string;
112
+ revision?: string;
113
+ }
114
+ interface ResolvedModelRef {
115
+ files?: string[];
116
+ provider: "huggingface";
117
+ repository: string;
118
+ revision: string;
119
+ displayName?: string;
120
+ publisher?: string;
121
+ sourceUrl: string;
122
+ }
123
+ interface ModelRequirements extends TaskRequirements {
124
+ task?: string;
125
+ architectures?: string[];
126
+ parameters?: {
127
+ minBillions?: number;
128
+ maxBillions?: number;
129
+ };
130
+ minimumContextLength?: number;
131
+ inputModalities?: InputModality[];
132
+ outputModalities?: OutputModality[];
133
+ capabilities?: Partial<Record<BehavioralCapability, boolean>>;
134
+ memory?: {
135
+ maximumRecommendedBytes?: number;
136
+ };
137
+ }
138
+ interface ExplicitModelRequest {
139
+ selection?: ModelSelection;
140
+ role: string;
141
+ preferredModel: ModelRef;
142
+ certifiedModels?: ModelRef[];
143
+ requirements?: ModelRequirements;
144
+ substitution?: {
145
+ automatic?: "none" | "certified-only" | "same-checkpoint" | "compatible";
146
+ };
147
+ }
148
+ interface CapabilityModelRequest {
149
+ selection?: never;
150
+ role: string;
151
+ preferredModel?: never;
152
+ requirements: ModelRequirements & {
153
+ task: string;
154
+ outputModalities: OutputModality[];
155
+ };
156
+ substitution?: {
157
+ automatic?: "compatible";
158
+ };
159
+ }
160
+ interface CheckpointModelRequest {
161
+ role: string;
162
+ selection: Extract<ModelSelection, {
163
+ intent: 'source-checkpoint';
164
+ }>;
165
+ preferredModel?: never;
166
+ requirements?: ModelRequirements;
167
+ substitution?: {
168
+ automatic?: 'none' | 'same-checkpoint' | 'compatible';
169
+ };
170
+ }
171
+ type ModelRequest = ExplicitModelRequest | CapabilityModelRequest | CheckpointModelRequest;
172
+ type ModelRequestProgress = {
173
+ stage: "resolving";
174
+ } | {
175
+ stage: "awaiting-permission";
176
+ } | {
177
+ stage: "awaiting-model-choice";
178
+ } | {
179
+ stage: "downloading";
180
+ model: ResolvedModelRef;
181
+ downloadedBytes: number;
182
+ totalBytes?: number;
183
+ } | {
184
+ stage: "loading";
185
+ model: ResolvedModelRef;
186
+ progress?: number;
187
+ } | {
188
+ stage: "ready";
189
+ sessionId: string;
190
+ };
191
+ interface ModelRequestOptions {
192
+ signal?: AbortSignal;
193
+ onProgress?: (progress: ModelRequestProgress) => void;
194
+ }
195
+ interface CompatibilityReason {
196
+ code: string;
197
+ status: "satisfied" | "unknown" | "failed";
198
+ message?: string;
199
+ }
200
+ interface ModelResolution {
201
+ selection?: SelectionExplanation;
202
+ preferredModel: ResolvedModelRef;
203
+ resolvedModel: ResolvedModelRef;
204
+ compatibility: "certified" | "compatible" | "uncertain" | "incompatible";
205
+ executability: "executable" | "not-executable" | "unknown";
206
+ security: "allowed" | "blocked" | "developer-mode-required";
207
+ /** The browser, not the website, grants exact-revision trust after user consent. */
208
+ trust: "oryn-verified" | "user-approved-unverified";
209
+ developerCertified: boolean;
210
+ substituted: boolean;
211
+ overriddenByUser: boolean;
212
+ resolutionReason: "preferred-model" | "developer-certified-alternative" | "already-installed" | "site-preference" | "global-user-preference" | "automatic-compatible-substitution" | "capability-match" | "user-override";
213
+ compatibilityReasons: CompatibilityReason[];
214
+ }
215
+ interface ResolvedModelCapabilities {
216
+ task?: string;
217
+ architectures?: string[];
218
+ parameterCount?: number;
219
+ contextLength?: number;
220
+ inputModalities?: InputModality[];
221
+ outputModalities?: OutputModality[];
222
+ capabilities?: Partial<Record<BehavioralCapability, boolean | "unknown">>;
223
+ }
224
+ interface ModelSession {
225
+ taskProfile?: TaskProfile;
226
+ sessionId: string;
227
+ role: string;
228
+ origin: string;
229
+ resolution: ModelResolution;
230
+ capabilities: ResolvedModelCapabilities;
231
+ }
232
+ interface ArtifactReference {
233
+ id: string;
234
+ mimeType: string;
235
+ sizeBytes: number;
236
+ name?: string;
237
+ }
238
+ interface ArtifactMetadata extends ArtifactReference {
239
+ createdAt: number;
240
+ expiresAt?: number;
241
+ url?: string;
242
+ }
243
+ interface CreateArtifactOptions {
244
+ name?: string;
245
+ lifetime?: "ephemeral" | "session";
246
+ }
247
+ interface SaveArtifactOptions {
248
+ suggestedFilename?: string;
249
+ }
250
+ type InferenceResult = StructuredResult | ArtifactResult | MultiResult;
251
+ interface StructuredResult {
252
+ kind: "structured";
253
+ value: unknown;
254
+ }
255
+ interface ArtifactResult {
256
+ kind: "artifact";
257
+ artifact: ArtifactMetadata;
258
+ }
259
+ interface MultiResult {
260
+ kind: "multi";
261
+ outputs: InferenceResult[];
262
+ }
263
+ interface ModelInvocationRequest<TInput = unknown> {
264
+ sessionId: string;
265
+ input: TInput;
266
+ }
267
+ type JobState = "created" | "queued" | "loading" | "running" | "streaming" | "saving" | "completed" | "failed" | "cancelled";
268
+ interface JobQueueStatus {
269
+ lane: "generation";
270
+ position: number;
271
+ jobsAhead: number;
272
+ reason: "generation-slot" | "model-loading" | "resource-policy";
273
+ }
274
+ interface JobReference {
275
+ jobId: string;
276
+ sessionId: string;
277
+ state: "created" | "queued" | "loading" | "running";
278
+ queue?: JobQueueStatus;
279
+ }
280
+ interface LocalAIEventBase {
281
+ event: string;
282
+ timestamp: number;
283
+ jobId: string;
284
+ sessionId: string;
285
+ sequence: number;
286
+ }
287
+ type LocalAIEvent = LocalAIEventBase & ({
288
+ event: "job.state";
289
+ data: {
290
+ state: "queued" | "loading" | "running" | "streaming" | "saving";
291
+ queue?: JobQueueStatus;
292
+ };
293
+ } | {
294
+ event: "job.queue.updated";
295
+ data: JobQueueStatus;
296
+ } | {
297
+ event: "job.progress";
298
+ data: {
299
+ progress?: number;
300
+ stage?: string;
301
+ };
302
+ } | {
303
+ event: "job.output.delta";
304
+ data: {
305
+ channel: string;
306
+ delta: unknown;
307
+ };
308
+ } | {
309
+ event: "job.preview";
310
+ data: {
311
+ artifactId: string;
312
+ };
313
+ } | {
314
+ event: "job.completed";
315
+ data: {
316
+ result: InferenceResult;
317
+ };
318
+ } | {
319
+ event: "job.failed";
320
+ data: {
321
+ error: SerializedLocalAIError;
322
+ };
323
+ } | {
324
+ event: "job.cancelled";
325
+ data: {
326
+ reason?: "website" | "user" | "resource-policy" | "runtime-shutdown";
327
+ };
328
+ });
329
+ type LocalAIErrorCode = "RUNTIME_NOT_AVAILABLE" | "RUNTIME_STARTING" | "RUNTIME_PROTOCOL_ERROR" | "RUNTIME_DEPENDENCY_UNAVAILABLE" | "UNAUTHORIZED_ORIGIN" | "UNAUTHORIZED_FRAME" | "PERMISSION_DENIED" | "USER_DENIED" | "MODEL_REFERENCE_INVALID" | "MODEL_SOURCE_INVALID" | "MODEL_REVISION_INVALID" | "MODEL_NOT_FOUND" | "MODEL_METADATA_INVALID" | "MODEL_NOT_EXECUTABLE" | "MODEL_SECURITY_BLOCKED" | "CUSTOM_CODE_REQUIRED" | "UNSAFE_MODEL_FORMAT" | "NO_EXECUTABLE_MODEL" | "DOWNLOAD_REQUIRED" | "RESOURCE_REQUIREMENTS_UNSATISFIABLE" | "RESOURCE_LIMIT_EXCEEDED" | "DISK_SPACE_INSUFFICIENT" | "MODEL_OUT_OF_MEMORY" | "MODEL_LOAD_FAILED" | "MODEL_NOT_LOADED" | "SESSION_NOT_FOUND" | "SESSION_ACCESS_DENIED" | "SESSION_RELEASED" | "REQUEST_ABORTED" | "ARTIFACT_NOT_FOUND" | "ARTIFACT_ACCESS_DENIED" | "ARTIFACT_EXPIRED" | "ARTIFACT_INVALID" | "ARTIFACT_IO_ERROR" | "ARTIFACT_PATH_INVALID" | "ARTIFACT_BINDING_INVALID" | "AUDIO_FORMAT_UNSUPPORTED" | "AUDIO_TOO_LARGE" | "AUDIO_DECODE_FAILED" | "AUDIO_PROCESSING_FAILED" | "JOB_NOT_FOUND" | "JOB_ACCESS_DENIED" | "JOB_INPUT_INVALID" | "JOB_ID_CONFLICT" | "JOB_QUEUE_FULL" | "JOB_EXECUTION_FAILED" | "JOB_CANCELLED" | "MODEL_OUTPUT_FILTERED" | "ASR_INFERENCE_FAILED" | "ASR_OUTPUT_INVALID" | "ALIGNMENT_LANGUAGE_UNSUPPORTED" | "ALIGNMENT_OUTPUT_INVALID" | "SONG_GENERATION_FAILED" | "SONG_OUTPUT_INVALID" | "RUNNER_NOT_AVAILABLE";
330
+ interface SerializedLocalAIError {
331
+ code: LocalAIErrorCode;
332
+ message: string;
333
+ details?: Record<string, unknown>;
334
+ }
335
+ type BridgeResult<T> = {
336
+ ok: true;
337
+ value: T;
338
+ } | {
339
+ ok: false;
340
+ error: SerializedLocalAIError;
341
+ };
342
+ interface InjectedLocalAI {
343
+ readonly sdkVersion: string;
344
+ getCapabilities(): Promise<RuntimeCapabilities>;
345
+ requestModel(operationId: string, request: ModelRequest): Promise<BridgeResult<ModelSession>>;
346
+ cancelModelRequest(operationId: string): Promise<void>;
347
+ releaseModelSession(sessionId: string): Promise<BridgeResult<void>>;
348
+ onModelRequestProgress(operationId: string, listener: (progress: ModelRequestProgress) => void): () => void;
349
+ beginArtifactCreate(metadata: {
350
+ mimeType: string;
351
+ sizeBytes: number;
352
+ name?: string;
353
+ lifetime?: "ephemeral" | "session";
354
+ }): Promise<BridgeResult<{
355
+ uploadId: string;
356
+ }>>;
357
+ appendArtifactChunk(uploadId: string, chunk: ArrayBuffer): Promise<BridgeResult<void>>;
358
+ finishArtifactCreate(uploadId: string): Promise<BridgeResult<ArtifactReference>>;
359
+ abortArtifactCreate(uploadId: string): Promise<void>;
360
+ getArtifact(artifactId: string): Promise<BridgeResult<ArtifactMetadata>>;
361
+ getArtifactUrl(artifactId: string): Promise<BridgeResult<string>>;
362
+ saveArtifactAs(artifactId: string, options?: SaveArtifactOptions): Promise<BridgeResult<void>>;
363
+ releaseArtifact(artifactId: string): Promise<BridgeResult<void>>;
364
+ invokeJob(request: ModelInvocationRequest): Promise<BridgeResult<JobReference>>;
365
+ cancelJob(jobId: string): Promise<BridgeResult<void>>;
366
+ onJobEvent(listener: (event: LocalAIEvent) => void): () => void;
367
+ }
368
+ interface LocalAIClient {
369
+ readonly sdkVersion: string;
370
+ getCapabilities(): Promise<RuntimeCapabilities>;
371
+ models: {
372
+ request(request: ModelRequest, options?: ModelRequestOptions): Promise<ModelSession>;
373
+ releaseSession(sessionId: string): Promise<void>;
374
+ };
375
+ artifacts: {
376
+ create(input: Blob | File, options?: CreateArtifactOptions): Promise<ArtifactReference>;
377
+ get(artifactId: string): Promise<ArtifactMetadata>;
378
+ getUrl(artifactId: string): Promise<string>;
379
+ readBlob(artifactId: string): Promise<Blob>;
380
+ saveAs(artifactId: string, options?: SaveArtifactOptions): Promise<void>;
381
+ release(artifactId: string): Promise<void>;
382
+ };
383
+ invoke<TInput = unknown>(request: ModelInvocationRequest<TInput>): Promise<JobReference>;
384
+ cancel(jobId: string): Promise<void>;
385
+ subscribe(listener: (event: LocalAIEvent) => void): () => void;
386
+ }
387
+
388
+ declare const SDK_VERSION = "0.1.0";
389
+ declare class LocalAIError extends Error {
390
+ readonly code: LocalAIErrorCode;
391
+ readonly details?: Record<string, unknown>;
392
+ constructor(error: SerializedLocalAIError);
393
+ }
394
+ declare function createLocalAIClient(options?: LocalAIClientOptions): LocalAIClient;
395
+ declare function invokeAndWait<TInput = unknown, TResult extends InferenceResult = InferenceResult>(client: LocalAIClient, request: ModelInvocationRequest<TInput>, options?: {
396
+ signal?: AbortSignal;
397
+ onEvent?: (event: LocalAIEvent) => void;
398
+ }): Promise<TResult>;
399
+ declare function invokeStream<TInput = unknown>(client: LocalAIClient, request: ModelInvocationRequest<TInput>, options?: {
400
+ signal?: AbortSignal;
401
+ }): AsyncIterable<LocalAIEvent>;
402
+
403
+ /** Closed additive task contracts. Unknown tasks remain unavailable on older peers. */
404
+ interface SharedTaskInputs {
405
+ "unconditional-image-generation-v1": {
406
+ "width"?: number;
407
+ "height"?: number;
408
+ "steps"?: number;
409
+ "seed"?: number;
410
+ };
411
+ "audio-question-answering-v1": {
412
+ "audioArtifactId": string;
413
+ "instruction": string;
414
+ "maxTokens"?: number;
415
+ };
416
+ "audio-transformation-v1": {
417
+ "operation": "enhance" | "separate" | "voice-conversion" | "encode" | "decode" | "vocode";
418
+ "audioArtifactId"?: string;
419
+ "referenceAudioArtifactId"?: string;
420
+ "codes"?: ((number)[])[];
421
+ "spectrogram"?: ((number)[])[];
422
+ "sampleRate"?: number;
423
+ };
424
+ "multimodal-generation-v1": {
425
+ "instruction": string;
426
+ "imageArtifactId"?: string;
427
+ "audioArtifactId"?: string;
428
+ "inputMode": "image" | "audio" | "image-and-audio";
429
+ "outputMode"?: "text" | "audio" | "text-and-audio";
430
+ "maxTokens"?: number;
431
+ };
432
+ "image-text-to-video-v1": {
433
+ "imageArtifactId": string;
434
+ "prompt": string;
435
+ "width"?: number;
436
+ "height"?: number;
437
+ "frames"?: number;
438
+ "fps"?: number;
439
+ "steps"?: number;
440
+ "guidanceScale"?: number;
441
+ "seed"?: number;
442
+ };
443
+ "video-editing-v1": {
444
+ "videoArtifactId": string;
445
+ "prompt"?: string;
446
+ "maskVideoArtifactId"?: string;
447
+ "operation"?: "edit" | "restore";
448
+ "startSeconds"?: number;
449
+ "durationSeconds"?: number;
450
+ "width"?: number;
451
+ "height"?: number;
452
+ "frames"?: number;
453
+ "fps"?: number;
454
+ "steps"?: number;
455
+ "guidanceScale"?: number;
456
+ "seed"?: number;
457
+ };
458
+ "tabular-classification-v1": {
459
+ "columns": ({
460
+ "name": string;
461
+ "type": "numeric" | "categorical";
462
+ })[];
463
+ "trainingRows": ((number | string | null)[])[];
464
+ "queryRows": ((number | string | null)[])[];
465
+ "targets": (string)[];
466
+ };
467
+ "tabular-regression-v1": {
468
+ "columns": ({
469
+ "name": string;
470
+ "type": "numeric" | "categorical";
471
+ })[];
472
+ "trainingRows": ((number | string | null)[])[];
473
+ "queryRows": ((number | string | null)[])[];
474
+ "targets": (number)[];
475
+ };
476
+ "time-series-forecasting-v1": {
477
+ "context": (number)[];
478
+ "horizon"?: number;
479
+ "quantiles"?: (number)[];
480
+ "timestamps"?: (number)[];
481
+ "frequencyMilliseconds"?: number;
482
+ "pastCovariates"?: ((number)[])[];
483
+ "futureCovariates"?: ((number)[])[];
484
+ };
485
+ "pose-estimation-v1": {
486
+ "imageArtifactId": string;
487
+ "boxes": ((number)[])[];
488
+ };
489
+ "visual-document-retrieval-v1": {
490
+ imageArtifactId: string;
491
+ queries: string[];
492
+ };
493
+ "table-question-answering-v1": {
494
+ question: string;
495
+ columns: string[];
496
+ rows: string[][];
497
+ };
498
+ "document-question-answering-v1": {
499
+ imageArtifactId: string;
500
+ question: string;
501
+ words: string[];
502
+ boxes: [number, number, number, number][];
503
+ };
504
+ "keypoint-detection-v1": {
505
+ imageArtifactId: string;
506
+ threshold?: number;
507
+ maxKeypoints?: number;
508
+ };
509
+ "video-classification-v1": {
510
+ videoArtifactId: string;
511
+ startSeconds?: number;
512
+ durationSeconds?: number;
513
+ topK?: number;
514
+ };
515
+ "video-question-answering-v1": {
516
+ videoArtifactId: string;
517
+ question: string;
518
+ startSeconds?: number;
519
+ durationSeconds?: number;
520
+ maxTokens?: number;
521
+ };
522
+ "voice-activity-detection-v1": {
523
+ audioArtifactId: string;
524
+ threshold?: number;
525
+ minSpeechSeconds?: number;
526
+ minSilenceSeconds?: number;
527
+ };
528
+ "image-editing-v1": {
529
+ imageArtifactId: string;
530
+ referenceImageArtifactIds?: string[];
531
+ prompt: string;
532
+ negativePrompt?: string;
533
+ width?: number;
534
+ height?: number;
535
+ steps?: number;
536
+ guidanceScale?: number;
537
+ seed?: number;
538
+ };
539
+ "image-layers-v1": {
540
+ imageArtifactId: string;
541
+ prompt: string;
542
+ negativePrompt?: string;
543
+ resolution?: 640 | 1024;
544
+ layers?: number;
545
+ steps?: number;
546
+ guidanceScale?: number;
547
+ seed?: number;
548
+ };
549
+ "zero-shot-classification-v1": {
550
+ text: string;
551
+ labels: string[];
552
+ multiLabel?: boolean;
553
+ };
554
+ "image-embeddings-v1": {
555
+ imageArtifactId: string;
556
+ normalize?: boolean;
557
+ };
558
+ "image-segmentation-v1": {
559
+ imageArtifactId: string;
560
+ };
561
+ "mask-generation-v1": {
562
+ imageArtifactId: string;
563
+ points: {
564
+ x: number;
565
+ y: number;
566
+ label: 0 | 1;
567
+ }[];
568
+ };
569
+ "zero-shot-object-detection-v1": {
570
+ imageArtifactId: string;
571
+ labels: string[];
572
+ threshold?: number;
573
+ };
574
+ "image-to-text-v1": {
575
+ imageArtifactId: string;
576
+ maxTokens?: number;
577
+ };
578
+ "visual-question-answering-v1": {
579
+ imageArtifactId: string;
580
+ question: string;
581
+ maxTokens?: number;
582
+ };
583
+ }
584
+ type SharedTaskContract = keyof SharedTaskInputs;
585
+ declare const SHARED_TASK_CONTRACTS: readonly ["unconditional-image-generation-v1", "audio-question-answering-v1", "audio-transformation-v1", "multimodal-generation-v1", "image-text-to-video-v1", "video-editing-v1", "tabular-classification-v1", "tabular-regression-v1", "time-series-forecasting-v1", "pose-estimation-v1", "visual-document-retrieval-v1", "table-question-answering-v1", "document-question-answering-v1", "keypoint-detection-v1", "video-classification-v1", "video-question-answering-v1", "voice-activity-detection-v1", "image-editing-v1", "image-layers-v1", "zero-shot-classification-v1", "image-embeddings-v1", "image-segmentation-v1", "mask-generation-v1", "zero-shot-object-detection-v1", "image-to-text-v1", "visual-question-answering-v1"];
586
+ type SpatialMaskResult = {
587
+ kind: "artifact";
588
+ artifact: ArtifactMetadata;
589
+ } | {
590
+ kind: "multi";
591
+ outputs: [
592
+ {
593
+ kind: "artifact";
594
+ artifact: ArtifactMetadata;
595
+ },
596
+ {
597
+ kind: "structured";
598
+ value: {
599
+ width: number;
600
+ height: number;
601
+ encoding: "class-id-16bit" | "binary-8bit";
602
+ segments: {
603
+ id: number;
604
+ label: string;
605
+ pixelCount: number;
606
+ }[];
607
+ };
608
+ }
609
+ ];
610
+ };
611
+ /** Structured values, or the existing artifact/multi wrapper for spatial masks. */
612
+ interface SharedTaskOutputs {
613
+ "unconditional-image-generation-v1": {
614
+ "kind": "artifact";
615
+ "artifact": ArtifactMetadata;
616
+ };
617
+ "audio-question-answering-v1": {
618
+ "text": string;
619
+ };
620
+ "audio-transformation-v1": {
621
+ "kind": "artifact";
622
+ "artifact": ArtifactMetadata;
623
+ } | {
624
+ "kind": "multi";
625
+ "outputs": ({
626
+ "kind": "artifact";
627
+ "artifact": ArtifactMetadata;
628
+ })[];
629
+ } | {
630
+ "kind": "structured";
631
+ "value": {
632
+ "codes": ((number)[])[];
633
+ "sampleRate": number;
634
+ "durationSeconds": number;
635
+ };
636
+ };
637
+ "multimodal-generation-v1": {
638
+ "kind": "structured";
639
+ "value": {
640
+ "text": string;
641
+ };
642
+ } | {
643
+ "kind": "artifact";
644
+ "artifact": ArtifactMetadata;
645
+ } | {
646
+ "kind": "multi";
647
+ "outputs": [{
648
+ "kind": "structured";
649
+ "value": {
650
+ "text": string;
651
+ };
652
+ }, {
653
+ "kind": "artifact";
654
+ "artifact": ArtifactMetadata;
655
+ }];
656
+ };
657
+ "image-text-to-video-v1": {
658
+ "kind": "artifact";
659
+ "artifact": ArtifactMetadata;
660
+ };
661
+ "video-editing-v1": {
662
+ "kind": "artifact";
663
+ "artifact": ArtifactMetadata;
664
+ };
665
+ "tabular-classification-v1": {
666
+ "classes": (string)[];
667
+ "predictions": ({
668
+ "label": string;
669
+ "probabilities": (number)[];
670
+ })[];
671
+ };
672
+ "tabular-regression-v1": {
673
+ "predictions": (number)[];
674
+ };
675
+ "time-series-forecasting-v1": {
676
+ "predictions": (number)[];
677
+ "quantiles": ({
678
+ "level": number;
679
+ "values": (number)[];
680
+ })[];
681
+ "timestamps"?: (number)[];
682
+ };
683
+ "pose-estimation-v1": {
684
+ "width": number;
685
+ "height": number;
686
+ "poses": ({
687
+ "box": (number)[];
688
+ "keypoints": ({
689
+ "id": number;
690
+ "label": string;
691
+ "x": number;
692
+ "y": number;
693
+ "confidence": number;
694
+ "visible": boolean;
695
+ })[];
696
+ })[];
697
+ };
698
+ "visual-document-retrieval-v1": {
699
+ dimensions: 128 | 320 | 4096;
700
+ normalized: true;
701
+ scoring: "sum-max-cosine" | "mean-max-cosine";
702
+ documentVectors: number[][];
703
+ queries: {
704
+ vectors: number[][];
705
+ score: number;
706
+ }[];
707
+ };
708
+ "table-question-answering-v1": {
709
+ answer: string;
710
+ cells: {
711
+ row: number;
712
+ column: number;
713
+ text: string;
714
+ }[];
715
+ aggregation: "none" | "sum" | "average" | "count" | "generated";
716
+ };
717
+ "document-question-answering-v1": {
718
+ answer: string;
719
+ score: number;
720
+ wordStart: number;
721
+ wordEnd: number;
722
+ box: [number, number, number, number];
723
+ };
724
+ "keypoint-detection-v1": {
725
+ width: number;
726
+ height: number;
727
+ keypoints: {
728
+ x: number;
729
+ y: number;
730
+ score: number;
731
+ }[];
732
+ };
733
+ "video-classification-v1": {
734
+ predictions: {
735
+ label: string;
736
+ score: number;
737
+ }[];
738
+ sampledTimestamps: number[];
739
+ durationSeconds: number;
740
+ };
741
+ "video-question-answering-v1": {
742
+ text: string;
743
+ sampledTimestamps: number[];
744
+ durationSeconds: number;
745
+ };
746
+ "voice-activity-detection-v1": {
747
+ segments: {
748
+ start: number;
749
+ end: number;
750
+ }[];
751
+ durationSeconds: number;
752
+ };
753
+ "image-editing-v1": {
754
+ kind: "artifact";
755
+ artifact: ArtifactMetadata;
756
+ };
757
+ "image-layers-v1": {
758
+ kind: "multi";
759
+ outputs: {
760
+ kind: "artifact";
761
+ artifact: ArtifactMetadata;
762
+ }[];
763
+ };
764
+ "image-segmentation-v1": SpatialMaskResult;
765
+ "mask-generation-v1": SpatialMaskResult;
766
+ "zero-shot-classification-v1": {
767
+ predictions: {
768
+ label: string;
769
+ score: number;
770
+ }[];
771
+ multiLabel: boolean;
772
+ };
773
+ "image-embeddings-v1": {
774
+ vector: number[];
775
+ dimensions: number;
776
+ normalized: boolean;
777
+ pooling: "cls";
778
+ };
779
+ "zero-shot-object-detection-v1": {
780
+ detections: {
781
+ label: string;
782
+ score: number;
783
+ box: [number, number, number, number];
784
+ }[];
785
+ width: number;
786
+ height: number;
787
+ };
788
+ "image-to-text-v1": {
789
+ text: string;
790
+ };
791
+ "visual-question-answering-v1": {
792
+ text: string;
793
+ };
794
+ }
795
+
796
+ declare const SHARED_MODEL_TASK_CONTRACTS: Readonly<Record<string, SharedTaskContract>>;
797
+ /** Canonical data validation only. Browser still owns permissions and artifact leases. */
798
+ declare function validateSharedTaskInput<C extends SharedTaskContract>(contract: C, input: unknown): SharedTaskInputs[C];
799
+
800
+ export { type ArtifactMetadata, type ArtifactReference, type ArtifactResult, type BehavioralCapability, type BridgeResult, type CapabilityModelRequest, type CheckpointModelRequest, type CompatibilityReason, type CreateArtifactOptions, type ExplicitModelRequest, type InferenceResult, type InjectedLocalAI, type InputModality, type JobQueueStatus, type JobReference, type JobState, type LocalAIClient, type LocalAIClientOptions, LocalAIError, type LocalAIErrorCode, type LocalAIEvent, type LocalAIEventBase, type ModelInvocationRequest, type ModelProvider, type ModelRef, type ModelRequest, type ModelRequestOptions, type ModelRequestProgress, type ModelRequirements, type ModelResolution, type ModelSelection, type ModelSession, type MultiResult, type OutputModality, type ResolvedModelCapabilities, type ResolvedModelRef, type RuntimeCapabilities, SDK_VERSION, SHARED_MODEL_TASK_CONTRACTS, SHARED_TASK_CONTRACTS, type SaveArtifactOptions, type SelectionExplanation, type SerializedLocalAIError, type SharedTaskContract, type SharedTaskInputs, type SharedTaskOutputs, type SpatialMaskResult, type StructuredResult, type TaskContractRef, type TaskFeatureState, type TaskParameter, type TaskProfile, type TaskRequirements, createLocalAIClient, invokeAndWait, invokeStream, validateSharedTaskInput };