@opencode/ai 0.0.0-dev-21920 → 0.0.0-dev-44
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 +61 -19
- package/dist/ai-client.d.ts +2 -2
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +3 -3
- package/dist/decision.d.ts +4 -1
- package/dist/decision.js +3 -0
- package/dist/effect.d.ts +4 -5
- package/dist/effect.js +2 -3
- package/dist/experimental/realtime.d.ts +3 -2
- package/dist/image-client.d.ts +1 -1
- package/dist/image.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/llm.d.ts +3 -0
- package/dist/media-client.d.ts +2 -1
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/protocols/alibaba-chat.d.ts +4 -0
- package/dist/protocols/alibaba-messages.d.ts +19 -19
- package/dist/protocols/alibaba-responses.d.ts +3 -3
- package/dist/protocols/anthropic-messages.d.ts +59 -59
- package/dist/protocols/anthropic-messages.js +3 -5
- package/dist/protocols/bedrock-converse.d.ts +110 -15
- package/dist/protocols/bedrock-converse.js +112 -15
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/meta-messages.d.ts +19 -19
- package/dist/protocols/meta-messages.js +2 -1
- package/dist/protocols/open-responses.d.ts +3 -0
- package/dist/protocols/openai-chat.d.ts +588 -1
- package/dist/protocols/openai-chat.js +7 -2
- package/dist/protocols/openai-compatible-chat.d.ts +6 -2
- package/dist/protocols/openai-compatible-responses.d.ts +3 -3
- package/dist/protocols/openai-responses.d.ts +24 -0
- package/dist/protocols/openai-responses.js +5 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +9 -0
- package/dist/protocols/venice-chat.d.ts +3 -0
- package/dist/protocols/venice-chat.js +1 -1
- package/dist/protocols/zai-chat.d.ts +4 -0
- package/dist/protocols/zai-messages.d.ts +19 -19
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +26 -21
- package/dist/providers/alibaba.js +12 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +23 -19
- package/dist/providers/amazon-bedrock.d.ts +34 -14
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +19 -19
- package/dist/providers/anthropic.d.ts +19 -19
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +15 -1
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +13 -4
- package/dist/providers/baseten.js +15 -8
- package/dist/providers/cerebras.d.ts +8 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +57 -40
- package/dist/providers/cloudflare-ai-gateway.js +11 -6
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +13 -3
- package/dist/providers/cloudflare-workers-ai.js +16 -7
- package/dist/providers/cohere.d.ts +8 -0
- package/dist/providers/deepinfra.d.ts +8 -0
- package/dist/providers/deepseek.d.ts +8 -0
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean.d.ts +21 -4
- package/dist/providers/digitalocean.js +25 -8
- package/dist/providers/fireworks.d.ts +8 -0
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +4 -0
- package/dist/providers/google-vertex-messages.d.ts +19 -19
- package/dist/providers/google-vertex.d.ts +3 -1
- package/dist/providers/google-vertex.js +30 -13
- package/dist/providers/google.d.ts +5 -4
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +8 -0
- package/dist/providers/meta.d.ts +23 -19
- package/dist/providers/minimax.d.ts +23 -19
- package/dist/providers/moonshot.d.ts +23 -19
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible.d.ts +7 -1
- package/dist/providers/openai-compatible.js +21 -9
- package/dist/providers/openai.d.ts +18 -8
- package/dist/providers/openai.js +10 -2
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +9 -4
- package/dist/providers/opencode.js +2 -1
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter.d.ts +25 -4
- package/dist/providers/openrouter.js +31 -9
- package/dist/providers/togetherai.d.ts +8 -0
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +9 -4
- package/dist/providers/typesafe-ai.js +2 -1
- package/dist/providers/venice.d.ts +3 -0
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +9 -7
- package/dist/providers/vercel-ai-gateway.js +18 -10
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +9 -4
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan.d.ts +23 -19
- package/dist/providers/zai.d.ts +9 -4
- package/dist/providers/zai.js +15 -8
- package/dist/route/client.d.ts +2 -2
- package/dist/route/client.js +15 -4
- package/dist/route/decision.d.ts +2 -1
- package/dist/route/decision.js +1 -0
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media.d.ts +5 -1
- package/dist/route/media.js +6 -2
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +135 -6
- package/dist/schema/events.js +10 -0
- package/dist/schema/messages.d.ts +6 -2
- package/dist/schema/messages.js +3 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +1 -1
- package/dist/speech.js +2 -1
- package/dist/testing.d.ts +25 -24
- package/dist/testing.js +3 -21
- package/dist/transcription-client.d.ts +1 -1
- package/dist/transcription.js +1 -0
- package/dist/video-client.d.ts +1 -1
- package/dist/video.js +1 -0
- package/package.json +510 -8
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
package/dist/providers/xai.js
CHANGED
|
@@ -67,19 +67,26 @@ export const configure = (input = {}) => {
|
|
|
67
67
|
model: responses,
|
|
68
68
|
responses,
|
|
69
69
|
chat,
|
|
70
|
-
image: (modelID) => XAIImages.model({ ...media, id: modelID }),
|
|
70
|
+
image: (modelID, providerOptions) => XAIImages.model({ ...media, id: modelID, providerOptions }),
|
|
71
71
|
video: (modelID) => XAIVideo.model({ ...media, id: modelID }),
|
|
72
72
|
configure,
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
export const provider = configure();
|
|
76
|
-
export const model = (modelID,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
export const model = (modelID, settings) => configure(config(settings)).model(modelID);
|
|
77
|
+
export const imageModel = (modelID, settings) => {
|
|
78
|
+
const input = config(settings);
|
|
79
|
+
return configure(input).image(modelID, input.providerOptions);
|
|
80
|
+
};
|
|
81
|
+
function config({ apiKey, baseURL, body, headers, ...providerOptions }) {
|
|
82
|
+
return {
|
|
83
|
+
apiKey,
|
|
84
|
+
baseURL,
|
|
85
|
+
headers,
|
|
86
|
+
http: body === undefined ? undefined : { body },
|
|
87
|
+
providerOptions,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
83
90
|
export const responses = provider.responses;
|
|
84
91
|
export const chat = provider.chat;
|
|
85
92
|
export const image = provider.image;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { imageModel as model } from "../zai.js";
|
|
@@ -320,6 +320,10 @@ export declare const routes: (Route<{
|
|
|
320
320
|
} | undefined;
|
|
321
321
|
readonly store?: boolean | undefined;
|
|
322
322
|
readonly prompt_cache_key?: string | undefined;
|
|
323
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
324
|
+
readonly prompt_cache_options?: {
|
|
325
|
+
readonly ttl?: string | undefined;
|
|
326
|
+
} | undefined;
|
|
323
327
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
324
328
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
325
329
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
@@ -365,7 +369,7 @@ export declare const routes: (Route<{
|
|
|
365
369
|
readonly text: string;
|
|
366
370
|
readonly cache_control?: {
|
|
367
371
|
readonly type: "ephemeral";
|
|
368
|
-
readonly ttl?:
|
|
372
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
369
373
|
} | undefined;
|
|
370
374
|
}[] | undefined;
|
|
371
375
|
readonly messages: readonly ({
|
|
@@ -375,7 +379,7 @@ export declare const routes: (Route<{
|
|
|
375
379
|
readonly text: string;
|
|
376
380
|
readonly cache_control?: {
|
|
377
381
|
readonly type: "ephemeral";
|
|
378
|
-
readonly ttl?:
|
|
382
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
379
383
|
} | undefined;
|
|
380
384
|
} | {
|
|
381
385
|
readonly type: "image";
|
|
@@ -392,7 +396,7 @@ export declare const routes: (Route<{
|
|
|
392
396
|
};
|
|
393
397
|
readonly cache_control?: {
|
|
394
398
|
readonly type: "ephemeral";
|
|
395
|
-
readonly ttl?:
|
|
399
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
396
400
|
} | undefined;
|
|
397
401
|
readonly transformations?: {
|
|
398
402
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
@@ -412,7 +416,7 @@ export declare const routes: (Route<{
|
|
|
412
416
|
};
|
|
413
417
|
readonly cache_control?: {
|
|
414
418
|
readonly type: "ephemeral";
|
|
415
|
-
readonly ttl?:
|
|
419
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
416
420
|
} | undefined;
|
|
417
421
|
} | {
|
|
418
422
|
readonly type: "document";
|
|
@@ -433,7 +437,7 @@ export declare const routes: (Route<{
|
|
|
433
437
|
};
|
|
434
438
|
readonly cache_control?: {
|
|
435
439
|
readonly type: "ephemeral";
|
|
436
|
-
readonly ttl?:
|
|
440
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
437
441
|
} | undefined;
|
|
438
442
|
readonly title?: string | undefined;
|
|
439
443
|
readonly context?: string | undefined;
|
|
@@ -448,7 +452,7 @@ export declare const routes: (Route<{
|
|
|
448
452
|
readonly text: string;
|
|
449
453
|
readonly cache_control?: {
|
|
450
454
|
readonly type: "ephemeral";
|
|
451
|
-
readonly ttl?:
|
|
455
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
452
456
|
} | undefined;
|
|
453
457
|
} | {
|
|
454
458
|
readonly type: "image";
|
|
@@ -465,7 +469,7 @@ export declare const routes: (Route<{
|
|
|
465
469
|
};
|
|
466
470
|
readonly cache_control?: {
|
|
467
471
|
readonly type: "ephemeral";
|
|
468
|
-
readonly ttl?:
|
|
472
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
469
473
|
} | undefined;
|
|
470
474
|
readonly transformations?: {
|
|
471
475
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
@@ -485,7 +489,7 @@ export declare const routes: (Route<{
|
|
|
485
489
|
};
|
|
486
490
|
readonly cache_control?: {
|
|
487
491
|
readonly type: "ephemeral";
|
|
488
|
-
readonly ttl?:
|
|
492
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
489
493
|
} | undefined;
|
|
490
494
|
} | {
|
|
491
495
|
readonly type: "document";
|
|
@@ -506,7 +510,7 @@ export declare const routes: (Route<{
|
|
|
506
510
|
};
|
|
507
511
|
readonly cache_control?: {
|
|
508
512
|
readonly type: "ephemeral";
|
|
509
|
-
readonly ttl?:
|
|
513
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
510
514
|
} | undefined;
|
|
511
515
|
readonly title?: string | undefined;
|
|
512
516
|
readonly context?: string | undefined;
|
|
@@ -517,7 +521,7 @@ export declare const routes: (Route<{
|
|
|
517
521
|
readonly is_error?: boolean | undefined;
|
|
518
522
|
readonly cache_control?: {
|
|
519
523
|
readonly type: "ephemeral";
|
|
520
|
-
readonly ttl?:
|
|
524
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
521
525
|
} | undefined;
|
|
522
526
|
})[];
|
|
523
527
|
} | {
|
|
@@ -530,7 +534,7 @@ export declare const routes: (Route<{
|
|
|
530
534
|
readonly text: string;
|
|
531
535
|
readonly cache_control?: {
|
|
532
536
|
readonly type: "ephemeral";
|
|
533
|
-
readonly ttl?:
|
|
537
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
534
538
|
} | undefined;
|
|
535
539
|
} | {
|
|
536
540
|
readonly type: "thinking";
|
|
@@ -538,14 +542,14 @@ export declare const routes: (Route<{
|
|
|
538
542
|
readonly signature: string;
|
|
539
543
|
readonly cache_control?: {
|
|
540
544
|
readonly type: "ephemeral";
|
|
541
|
-
readonly ttl?:
|
|
545
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
542
546
|
} | undefined;
|
|
543
547
|
} | {
|
|
544
548
|
readonly type: "redacted_thinking";
|
|
545
549
|
readonly data: string;
|
|
546
550
|
readonly cache_control?: {
|
|
547
551
|
readonly type: "ephemeral";
|
|
548
|
-
readonly ttl?:
|
|
552
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
549
553
|
} | undefined;
|
|
550
554
|
} | {
|
|
551
555
|
readonly type: "tool_use";
|
|
@@ -554,7 +558,7 @@ export declare const routes: (Route<{
|
|
|
554
558
|
readonly input: unknown;
|
|
555
559
|
readonly cache_control?: {
|
|
556
560
|
readonly type: "ephemeral";
|
|
557
|
-
readonly ttl?:
|
|
561
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
558
562
|
} | undefined;
|
|
559
563
|
} | {
|
|
560
564
|
readonly type: "server_tool_use";
|
|
@@ -563,7 +567,7 @@ export declare const routes: (Route<{
|
|
|
563
567
|
readonly input: unknown;
|
|
564
568
|
readonly cache_control?: {
|
|
565
569
|
readonly type: "ephemeral";
|
|
566
|
-
readonly ttl?:
|
|
570
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
567
571
|
} | undefined;
|
|
568
572
|
} | {
|
|
569
573
|
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
@@ -571,7 +575,7 @@ export declare const routes: (Route<{
|
|
|
571
575
|
readonly content: unknown;
|
|
572
576
|
readonly cache_control?: {
|
|
573
577
|
readonly type: "ephemeral";
|
|
574
|
-
readonly ttl?:
|
|
578
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
575
579
|
} | undefined;
|
|
576
580
|
})[];
|
|
577
581
|
} | {
|
|
@@ -581,7 +585,7 @@ export declare const routes: (Route<{
|
|
|
581
585
|
readonly text: string;
|
|
582
586
|
readonly cache_control?: {
|
|
583
587
|
readonly type: "ephemeral";
|
|
584
|
-
readonly ttl?:
|
|
588
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
585
589
|
} | undefined;
|
|
586
590
|
}[];
|
|
587
591
|
readonly output_config?: {
|
|
@@ -596,7 +600,7 @@ export declare const routes: (Route<{
|
|
|
596
600
|
};
|
|
597
601
|
readonly cache_control?: {
|
|
598
602
|
readonly type: "ephemeral";
|
|
599
|
-
readonly ttl?:
|
|
603
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
600
604
|
} | undefined;
|
|
601
605
|
}[] | undefined;
|
|
602
606
|
readonly tool_choice?: {
|
|
@@ -624,7 +628,7 @@ export declare const routes: (Route<{
|
|
|
624
628
|
} | undefined;
|
|
625
629
|
readonly cache_control?: {
|
|
626
630
|
readonly type: "ephemeral";
|
|
627
|
-
readonly ttl?:
|
|
631
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
628
632
|
} | undefined;
|
|
629
633
|
readonly container?: string | {
|
|
630
634
|
readonly id?: string | null | undefined;
|
package/dist/providers/zai.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ProviderPackage } from "../provider-package.js";
|
|
|
2
2
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
3
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
|
-
import { type ModelID } from "../schema/index.js";
|
|
5
|
+
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
7
|
export type ChatOptionsInput = ZAIChat.OptionsInput;
|
|
8
8
|
export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
@@ -135,6 +135,10 @@ export declare const routes: Route<{
|
|
|
135
135
|
} | undefined;
|
|
136
136
|
readonly store?: boolean | undefined;
|
|
137
137
|
readonly prompt_cache_key?: string | undefined;
|
|
138
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
139
|
+
readonly prompt_cache_options?: {
|
|
140
|
+
readonly ttl?: string | undefined;
|
|
141
|
+
} | undefined;
|
|
138
142
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
139
143
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
140
144
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
@@ -193,7 +197,7 @@ export declare const configure: (input?: Config) => {
|
|
|
193
197
|
readonly requestID?: string | undefined;
|
|
194
198
|
readonly userID?: string | undefined;
|
|
195
199
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
196
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
200
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
197
201
|
configure: typeof configure;
|
|
198
202
|
};
|
|
199
203
|
export declare const provider: {
|
|
@@ -226,10 +230,10 @@ export declare const provider: {
|
|
|
226
230
|
readonly requestID?: string | undefined;
|
|
227
231
|
readonly userID?: string | undefined;
|
|
228
232
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
229
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
233
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
230
234
|
configure: typeof configure;
|
|
231
235
|
};
|
|
232
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
236
|
+
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
233
237
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
234
238
|
readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
235
239
|
readonly thinking?: {
|
|
@@ -245,4 +249,5 @@ export declare const chat: (modelID: string | ModelID) => import("../schema/opti
|
|
|
245
249
|
readonly userID?: string | undefined;
|
|
246
250
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
247
251
|
export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
|
|
252
|
+
export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
248
253
|
export * as ZAI from "./zai.js";
|
package/dist/providers/zai.js
CHANGED
|
@@ -27,7 +27,7 @@ export const configure = (input = {}) => {
|
|
|
27
27
|
})
|
|
28
28
|
.model({ id: modelID, compatibility: ZAIChat.compatibility });
|
|
29
29
|
const media = MediaRoute.deployment(input, auth(input));
|
|
30
|
-
const image = (modelID) => ZAIImages.model({ ...media, id: modelID });
|
|
30
|
+
const image = (modelID, providerOptions) => ZAIImages.model({ ...media, id: modelID, providerOptions });
|
|
31
31
|
return {
|
|
32
32
|
id,
|
|
33
33
|
model: chat,
|
|
@@ -39,11 +39,18 @@ export const configure = (input = {}) => {
|
|
|
39
39
|
export const provider = configure();
|
|
40
40
|
export const image = provider.image;
|
|
41
41
|
export const chat = provider.chat;
|
|
42
|
-
export const model = (modelID,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
export const model = (modelID, settings) => configure(config(settings)).model(modelID);
|
|
43
|
+
export const imageModel = (modelID, settings) => {
|
|
44
|
+
const input = config(settings);
|
|
45
|
+
return configure(input).image(modelID, input.providerOptions);
|
|
46
|
+
};
|
|
47
|
+
function config({ apiKey, baseURL, body, headers, ...providerOptions }) {
|
|
48
|
+
return {
|
|
49
|
+
apiKey,
|
|
50
|
+
baseURL,
|
|
51
|
+
headers,
|
|
52
|
+
http: body === undefined ? undefined : { body },
|
|
53
|
+
providerOptions,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
49
56
|
export * as ZAI from "./zai.js";
|
package/dist/route/client.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ export declare function make<Body, Prepared, Frame, Event, State>(input: MakeTra
|
|
|
193
193
|
* the public surface preemptively.
|
|
194
194
|
*/
|
|
195
195
|
export declare function make<Body, Frame, Event, State>(input: MakeInput<Body, Frame, Event, State>): Route<Body, HttpTransport.HttpPrepared<Frame>>;
|
|
196
|
-
/**
|
|
196
|
+
/** Test-only projection of the execution compiler; exported from `@opencode/ai/testing`. */
|
|
197
197
|
export declare const compileRequest: (request: LLMRequest<LanguageModel<{
|
|
198
198
|
readonly [x: string]: unknown;
|
|
199
199
|
}, CompactionOperations | undefined>>) => Effect.Effect<{
|
|
@@ -220,7 +220,7 @@ export declare const LLMClient: {
|
|
|
220
220
|
readonly canCompact: typeof canCompact;
|
|
221
221
|
readonly compact: typeof compact;
|
|
222
222
|
readonly Service: typeof LLMClientService;
|
|
223
|
-
readonly layer: Layer.Layer<LLMClientService, never,
|
|
223
|
+
readonly layer: Layer.Layer<LLMClientService, never, RequestExecutor.RequestExecutorService>;
|
|
224
224
|
readonly stream: typeof stream;
|
|
225
225
|
readonly generate: typeof generate;
|
|
226
226
|
};
|
package/dist/route/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cause, Context, Effect, Layer, Schema, Stream } from "effect";
|
|
1
|
+
import { Cause, Context, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
2
2
|
import { Auth } from "./auth.js";
|
|
3
3
|
import { Endpoint } from "./endpoint.js";
|
|
4
4
|
import { RequestExecutor } from "./executor.js";
|
|
@@ -91,13 +91,22 @@ const incompleteStreamError = (route) => new AIError({
|
|
|
91
91
|
const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
|
|
92
92
|
let terminal = false;
|
|
93
93
|
return events.pipe(Stream.mapEffect((event) => {
|
|
94
|
-
|
|
94
|
+
// Raw events carry provider frames that may trail the terminal event.
|
|
95
|
+
if (terminal && !LLMEvent.is.raw(event))
|
|
95
96
|
return Effect.fail(ProviderShared.eventError(route, `Provider emitted ${event.type} after the terminal event`));
|
|
96
97
|
if (LLMEvent.is.finish(event) || LLMEvent.is.providerError(event))
|
|
97
98
|
terminal = true;
|
|
98
99
|
return Effect.succeed(event);
|
|
99
100
|
}), Stream.onEnd(Effect.suspend(() => (terminal ? Effect.void : Effect.fail(incompleteStreamError(route))))));
|
|
100
101
|
});
|
|
102
|
+
const decodeJsonOption = Schema.decodeUnknownOption(ProviderShared.Json);
|
|
103
|
+
// JSON text frames are parsed; non-JSON sentinels such as `[DONE]` stay strings.
|
|
104
|
+
const rawFrame = (frame) => typeof frame === "string" ? Option.getOrElse(decodeJsonOption(frame), () => frame) : frame;
|
|
105
|
+
// Transports may interleave their own marker objects with provider frames, e.g. Gemini's continuation boundary.
|
|
106
|
+
const isProviderFrame = (frame) => typeof frame !== "object" ||
|
|
107
|
+
frame === null ||
|
|
108
|
+
Array.isArray(frame) ||
|
|
109
|
+
Object.getPrototypeOf(frame) === Object.prototype;
|
|
101
110
|
function makeFromTransport(input) {
|
|
102
111
|
const protocol = input.protocol;
|
|
103
112
|
const decodeEventEffect = Schema.decodeUnknownEffect(protocol.stream.event);
|
|
@@ -165,7 +174,9 @@ function makeFromTransport(input) {
|
|
|
165
174
|
let state = protocol.stream.initial(request);
|
|
166
175
|
const parsed = events.pipe(Stream.mapEffect(({ event, frame }) => protocol.stream.step(state, event).pipe(Effect.catchCause((cause) => Effect.fail(streamError(route, `Failed to parse ${route} event`, cause))), Effect.map(([next, output]) => {
|
|
167
176
|
state = next;
|
|
168
|
-
return
|
|
177
|
+
return request.includeRaw && isProviderFrame(frame)
|
|
178
|
+
? [LLMEvent.raw({ data: execution.raw?.(frame) ?? rawFrame(frame) }), ...output]
|
|
179
|
+
: output;
|
|
169
180
|
}), Effect.mapError(frameError(frame, event)))), Stream.flatMap(Stream.fromIterable));
|
|
170
181
|
const onHalt = protocol.stream.onHalt;
|
|
171
182
|
return onHalt
|
|
@@ -238,7 +249,7 @@ const compile = Effect.fn("LLM.compile")(function* (request, options) {
|
|
|
238
249
|
prepared,
|
|
239
250
|
};
|
|
240
251
|
});
|
|
241
|
-
/**
|
|
252
|
+
/** Test-only projection of the execution compiler; exported from `@opencode/ai/testing`. */
|
|
242
253
|
export const compileRequest = Effect.fn("LLM.compileRequest")(function* (request) {
|
|
243
254
|
const compiled = yield* compile(request);
|
|
244
255
|
return {
|
package/dist/route/decision.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { HttpClientResponse } from "effect/http";
|
|
3
3
|
import { DecisionModel, DecisionModelCompatibility, type DecisionOptions, type DecisionRequestFor, type DecisionResponse } from "../decision.js";
|
|
4
|
-
import { HttpOptions, ProviderID, type AIError } from "../schema/index.js";
|
|
4
|
+
import { HttpOptions, ProviderID, type AIError, type ProviderOptions } from "../schema/index.js";
|
|
5
5
|
import { Auth } from "./auth.js";
|
|
6
6
|
import { Endpoint } from "./endpoint.js";
|
|
7
7
|
import { MediaProtocol } from "./media-protocol.js";
|
|
@@ -45,6 +45,7 @@ export interface Route {
|
|
|
45
45
|
readonly model: <Options extends DecisionOptions = DecisionOptions>(input: {
|
|
46
46
|
readonly id: string;
|
|
47
47
|
readonly compatibility?: DecisionModelCompatibility.Input;
|
|
48
|
+
readonly providerOptions?: ProviderOptions;
|
|
48
49
|
}) => DecisionModel<Options>;
|
|
49
50
|
}
|
|
50
51
|
export interface MakeInput extends Omit<Patch, "endpoint"> {
|
package/dist/route/decision.js
CHANGED
|
@@ -36,6 +36,7 @@ export const make = (input) => {
|
|
|
36
36
|
id: model.id,
|
|
37
37
|
provider,
|
|
38
38
|
http: route.http,
|
|
39
|
+
providerOptions: model.providerOptions,
|
|
39
40
|
compatibility: model.compatibility === undefined ? undefined : DecisionModelCompatibility.make(model.compatibility),
|
|
40
41
|
route: { id: route.id, generate: send },
|
|
41
42
|
});
|
package/dist/route/executor.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
|
3
3
|
import { AIError } from "../schema/index.js";
|
|
4
4
|
import { Service, type HttpMiddleware, type Interface } from "./executor-service.js";
|
|
5
5
|
export { responseHttp, Service } from "./executor-service.js";
|
|
6
|
-
export type { HttpHandler, HttpMiddleware, Interface } from "./executor-service.js";
|
|
6
|
+
export type { HttpHandler, HttpMiddleware, Interface, RequestExecutorService } from "./executor-service.js";
|
|
7
7
|
/** Preserve HTTP diagnostics for executor and externally captured failures alike. */
|
|
8
8
|
export declare const httpFailure: (input: {
|
|
9
9
|
readonly message: string;
|
package/dist/route/framing.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface Definition<Frame> {
|
|
|
21
21
|
readonly frame: (bytes: Stream.Stream<Uint8Array, AIError>) => Stream.Stream<Frame, AIError>;
|
|
22
22
|
/** Original wire representation when framing transforms the provider payload. */
|
|
23
23
|
readonly body?: (frame: Frame) => string | undefined;
|
|
24
|
+
/** Provider value exposed as a `raw` event when framing adds fields of its own. Defaults to the frame. */
|
|
25
|
+
readonly raw?: (frame: Frame) => unknown;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
|
package/dist/route/index.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export { Framing } from "./framing.js";
|
|
|
10
10
|
export { Protocol } from "./protocol.js";
|
|
11
11
|
export { HttpTransport, WebSocketTransport } from "./transport/index.js";
|
|
12
12
|
export * as Transport from "./transport/index.js";
|
|
13
|
+
export { ProviderShared } from "../protocols/shared.js";
|
|
14
|
+
export { classifyProviderFailure } from "../provider-error.js";
|
|
15
|
+
export { mergeHttpOptions } from "../schema/index.js";
|
|
13
16
|
export type { Definition as AuthShape, AuthInput, Credential, CredentialError } from "./auth.js";
|
|
14
17
|
export type { ApiKeyMode, AuthOverride, ProviderAuthOption } from "./auth-options.js";
|
|
15
18
|
export type { Definition as EndpointFn, EndpointInput } from "./endpoint.js";
|
package/dist/route/index.js
CHANGED
|
@@ -9,3 +9,6 @@ export { Framing } from "./framing.js";
|
|
|
9
9
|
export { Protocol } from "./protocol.js";
|
|
10
10
|
export { HttpTransport, WebSocketTransport } from "./transport/index.js";
|
|
11
11
|
export * as Transport from "./transport/index.js";
|
|
12
|
+
export { ProviderShared } from "../protocols/shared.js";
|
|
13
|
+
export { classifyProviderFailure } from "../provider-error.js";
|
|
14
|
+
export { mergeHttpOptions } from "../schema/index.js";
|
package/dist/route/media.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Endpoint } from "./endpoint.js";
|
|
|
4
4
|
import { type Interface } from "./executor-service.js";
|
|
5
5
|
import { MediaProtocol } from "./media-protocol.js";
|
|
6
6
|
import { Generation } from "../generation.js";
|
|
7
|
-
import { AIError, HttpOptions, ProviderID } from "../schema/index.js";
|
|
7
|
+
import { AIError, HttpOptions, ProviderID, type ProviderOptions } from "../schema/index.js";
|
|
8
8
|
export type Execute = Interface["execute"];
|
|
9
9
|
/** The minimum a media request must carry for the route to build a transport request. */
|
|
10
10
|
export interface MediaRequest {
|
|
@@ -12,7 +12,9 @@ export interface MediaRequest {
|
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly provider: ProviderID;
|
|
14
14
|
readonly http?: HttpOptions;
|
|
15
|
+
readonly providerOptions?: ProviderOptions;
|
|
15
16
|
};
|
|
17
|
+
readonly providerOptions?: ProviderOptions;
|
|
16
18
|
readonly http?: HttpOptions;
|
|
17
19
|
}
|
|
18
20
|
/** Deployment inputs every media model factory accepts; provider facades fill these from `configure(...)`. */
|
|
@@ -22,6 +24,8 @@ export interface ModelInput {
|
|
|
22
24
|
readonly baseURL?: string;
|
|
23
25
|
readonly headers?: Record<string, string>;
|
|
24
26
|
readonly http?: HttpOptions;
|
|
27
|
+
/** Defaults under each request's `providerOptions`. */
|
|
28
|
+
readonly providerOptions?: ProviderOptions;
|
|
25
29
|
}
|
|
26
30
|
/** A provider facade's `configure(...)` input as the `ModelInput` every media selector shares, minus the model id. */
|
|
27
31
|
export declare const deployment: (input: {
|
package/dist/route/media.js
CHANGED
|
@@ -7,7 +7,7 @@ import { RequestExecutor } from "./executor.js";
|
|
|
7
7
|
import { MediaProtocol } from "./media-protocol.js";
|
|
8
8
|
import { Generation, isTerminal } from "../generation.js";
|
|
9
9
|
import { isRetryable } from "../provider-error.js";
|
|
10
|
-
import { AIError, AIErrorReason, HttpOptions, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeHttpOptions, } from "../schema/index.js";
|
|
10
|
+
import { AIError, AIErrorReason, HttpOptions, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
|
|
11
11
|
import { encodeJson } from "../utils/json.js";
|
|
12
12
|
import { sanitizeSurrogates } from "../utils/sanitize.js";
|
|
13
13
|
/** A provider facade's `configure(...)` input as the `ModelInput` every media selector shares, minus the model id. */
|
|
@@ -161,12 +161,16 @@ const makeTransport = (input) => {
|
|
|
161
161
|
submit: Effect.fn("MediaRoute.submit")(function* (request, protocol, execute) {
|
|
162
162
|
yield* rejectUnsupported(input.protocol.id, input.protocol.provider, request, protocol.unsupported);
|
|
163
163
|
const http = mergeHttpOptions(routeHttp, request.model.http, request.http);
|
|
164
|
+
const providerOptions = mergeProviderOptions(request.model.providerOptions, request.providerOptions);
|
|
164
165
|
const headers = Headers.fromInput(http?.headers);
|
|
165
166
|
const prepared = protocol.prepare === undefined
|
|
166
167
|
? request
|
|
167
168
|
: yield* protocol.prepare(request, (path, body) => send({ method: "POST", url: baseURL(path), headers, request, body }, execute).pipe(Effect.map((sent) => sent.response)));
|
|
168
169
|
// Sanitize after merging so model-level overlays are covered; the model value is restored, not sanitized.
|
|
169
|
-
const resolved = {
|
|
170
|
+
const resolved = {
|
|
171
|
+
...sanitizeSurrogates({ ...prepared, http, providerOptions }),
|
|
172
|
+
model: request.model,
|
|
173
|
+
};
|
|
170
174
|
const body = yield* protocol.from(resolved);
|
|
171
175
|
const url = withQuery(withQuery(Endpoint.render(input.endpoint, { request: resolved, body }), body.type === "multipart" ? undefined : body.query), http?.query);
|
|
172
176
|
const sent = yield* send({ method: "POST", url, headers, request: resolved, body }, execute);
|
|
@@ -78,6 +78,7 @@ export const httpJson = (input) => ({
|
|
|
78
78
|
}), Stream.interruptWhen(Effect.sleep(remaining).pipe(Effect.andThen(Effect.fail(timeout("read", "Timed out waiting for the response to complete", http))))))),
|
|
79
79
|
http,
|
|
80
80
|
body: prepared.framing.body,
|
|
81
|
+
raw: prepared.framing.raw,
|
|
81
82
|
};
|
|
82
83
|
}),
|
|
83
84
|
});
|
|
@@ -11,6 +11,7 @@ export interface TransportExecution<Frame> {
|
|
|
11
11
|
readonly frames: Stream.Stream<Frame, AIError>;
|
|
12
12
|
readonly http?: HttpContext;
|
|
13
13
|
body?(frame: Frame): string | undefined;
|
|
14
|
+
raw?(frame: Frame): unknown;
|
|
14
15
|
/** Optional successful-consumption acknowledgement. HTTP leaves this absent. */
|
|
15
16
|
readonly complete?: Effect.Effect<void>;
|
|
16
17
|
}
|