@opencode/ai 0.0.0-dev-306 → 0.0.0-dev-329
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/dist/decision.d.ts +0 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.js +10 -7
- package/dist/tool.d.ts +8 -3
- package/package.json +3 -3
package/dist/decision.d.ts
CHANGED
|
@@ -464,7 +464,6 @@ export declare function request<const Model extends DecisionModel, const Questio
|
|
|
464
464
|
export declare function request(input: DecisionRequest): DecisionRequest;
|
|
465
465
|
export declare function request(input: DecisionRequest | DecisionRequestInput): DecisionRequest;
|
|
466
466
|
export declare function generate<const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>): Effect.Effect<DecisionResponseFor<Questions>, AIError, Service>;
|
|
467
|
-
export declare function generate(input: DecisionRequest): Effect.Effect<DecisionResponse, AIError, Service>;
|
|
468
467
|
export declare const Decision: {
|
|
469
468
|
readonly request: typeof request;
|
|
470
469
|
readonly generate: typeof generate;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ import type { AwaitOptions, Event, Snapshot } from "./generation.js";
|
|
|
5
5
|
import { type ImageModel, type ImageRequest, type ImageRequestInput } from "./image.js";
|
|
6
6
|
import { LLM } from "./effect.js";
|
|
7
7
|
import { Media } from "./media.js";
|
|
8
|
-
import { type CheckpointRequest, type CompactionRequest, type EndpointCompactOptions, type TriggerCompactOptions } from "./route/client.js";
|
|
8
|
+
import { type CheckpointRequest, type CompactionRequest, type EndpointCompactOptions, type StreamOptions, type TriggerCompactOptions } from "./route/client.js";
|
|
9
9
|
import { RequestExecutor } from "./route/executor.js";
|
|
10
10
|
import { LanguageModel, type CompactionCheckpointResponse, type CompactionResponse, type LLMRequest } from "./schema/index.js";
|
|
11
11
|
import type { GenerateObjectDynamicOptions, GenerateObjectOptions, GenerateObjectResponse, LoopInput, RequestInput } from "./llm.js";
|
|
12
12
|
import { type SpeechModel, type SpeechRequest, type SpeechRequestInput } from "./speech.js";
|
|
13
13
|
import { type TranscriptionModel, type TranscriptionRequest, type TranscriptionRequestInput } from "./transcription.js";
|
|
14
|
-
import {
|
|
14
|
+
import type { NoExecute, ToolExecuteContext, ToolOptions, ToolSchema } from "./tool.js";
|
|
15
15
|
import { type VideoModel, type VideoRequest, type VideoRequestInput } from "./video.js";
|
|
16
16
|
/**
|
|
17
17
|
* Promise-first entrypoint for scripts and non-Effect callers. One `ManagedRuntime` hosts the LLM, image, video, speech,
|
|
@@ -33,6 +33,8 @@ export type Services = AIClient.Services;
|
|
|
33
33
|
* new handle rather than updating this one.
|
|
34
34
|
*/
|
|
35
35
|
export type GenerationHandle<Response> = Snapshot & {
|
|
36
|
+
readonly snapshot: Snapshot;
|
|
37
|
+
readonly terminal: boolean;
|
|
36
38
|
/** Serializable JSON; pass it back to `resume` from another process. */
|
|
37
39
|
readonly token: unknown;
|
|
38
40
|
readonly await: (options?: AwaitOptions & RunOptions) => Promise<Response>;
|
|
@@ -56,8 +58,8 @@ export declare const make: <R = never>(options?: Options<R>) => {
|
|
|
56
58
|
write: (asset: Media.Asset, path: string, options?: RunOptions) => Promise<void>;
|
|
57
59
|
llm: {
|
|
58
60
|
request: typeof LLM.request;
|
|
59
|
-
generate: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => Promise<import("./effect.js").LLMResponse>;
|
|
60
|
-
stream: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => AsyncIterable<{
|
|
61
|
+
generate: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: StreamOptions & RunOptions) => Promise<import("./effect.js").LLMResponse>;
|
|
62
|
+
stream: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: StreamOptions & RunOptions) => AsyncIterable<{
|
|
61
63
|
readonly type: "step-start";
|
|
62
64
|
readonly index: number;
|
|
63
65
|
} | {
|
|
@@ -277,7 +279,7 @@ export declare const make: <R = never>(options?: Options<R>) => {
|
|
|
277
279
|
readonly encrypted?: never;
|
|
278
280
|
}))>;
|
|
279
281
|
/** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
|
|
280
|
-
loop: <const Model extends LanguageModel>(input: LoopInput<Model>, options?: RunOptions) => AsyncIterable<{
|
|
282
|
+
loop: <const Model extends LanguageModel>(input: LoopInput<Model>, options?: StreamOptions & RunOptions) => AsyncIterable<{
|
|
281
283
|
readonly type: "step-start";
|
|
282
284
|
readonly index: number;
|
|
283
285
|
} | {
|
|
@@ -506,6 +508,7 @@ export declare const make: <R = never>(options?: Options<R>) => {
|
|
|
506
508
|
(request: CheckpointRequest, options: TriggerCompactOptions & RunOptions): Promise<CompactionCheckpointResponse>;
|
|
507
509
|
(request: CompactionRequest, options?: EndpointCompactOptions & RunOptions): Promise<CompactionResponse>;
|
|
508
510
|
};
|
|
511
|
+
canCompact: typeof import("./route/client.js").canCompact;
|
|
509
512
|
};
|
|
510
513
|
image: {
|
|
511
514
|
request: typeof import("./image.js").request;
|
|
@@ -735,13 +738,9 @@ export declare const make: <R = never>(options?: Options<R>) => {
|
|
|
735
738
|
};
|
|
736
739
|
export type Client<R = never> = ReturnType<typeof make<R>>;
|
|
737
740
|
/** `tool` from `@opencode/ai/effect`, with an `execute` that returns a value or a Promise and throws to fail. */
|
|
738
|
-
export declare const tool: <Parameters extends ToolSchema<any> = typeof Schema.Unknown, Success extends ToolSchema<any> = typeof Schema.Unknown, Result extends Schema.Schema.Type<Success> | PromiseLike<Schema.Schema.Type<Success>> =
|
|
741
|
+
export declare const tool: <Parameters extends ToolSchema<any> = typeof Schema.Unknown, Success extends ToolSchema<any> = typeof Schema.Unknown, Result extends Schema.Schema.Type<Success> | PromiseLike<Schema.Schema.Type<Success>> | NoExecute = NoExecute>(config: ToolOptions<Parameters, Success, (params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
|
|
739
742
|
signal: AbortSignal;
|
|
740
|
-
}) => Result>) => (
|
|
741
|
-
signal: AbortSignal;
|
|
742
|
-
}) => Result) extends infer T ? T extends (params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
|
|
743
|
-
signal: AbortSignal;
|
|
744
|
-
}) => Result ? T extends (...args: never) => never ? import("./tool.js").Tool<Parameters, Success> : import("./tool.js").ExecutableTool<Parameters, Success> : never : never;
|
|
743
|
+
}) => Result>) => 0 extends 1 & Result ? import("./tool.js").ExecutableTool<Parameters, Success> : [Result, NoExecute] extends [NoExecute, Result] ? import("./tool.js").Tool<Parameters, Success> : import("./tool.js").ExecutableTool<Parameters, Success>;
|
|
745
744
|
/** Default client over `RequestExecutor.fetchLayer` for scripts; the runtime builds its layer on first use. */
|
|
746
745
|
export declare const ai: {
|
|
747
746
|
run: <A, E>(effect: Effect.Effect<A, E, import("./image-client.js").ImageClientService | import("./effect.js").LLMClientService | RequestExecutor.RequestExecutorService | import("./decision-client.js").Service | import("./speech-client.js").SpeechClientService | import("./transcription-client.js").TranscriptionClientService | import("./video-client.js").VideoClientService>, options?: RunOptions) => Promise<A>;
|
|
@@ -758,10 +757,10 @@ export declare const ai: {
|
|
|
758
757
|
request: typeof LLM.request;
|
|
759
758
|
generate: <const Model extends LanguageModel>(input: LLMRequest<LanguageModel<{
|
|
760
759
|
readonly [x: string]: unknown;
|
|
761
|
-
}, import("./route/client.js").CompactionOperations | undefined>> | RequestInput<Model>, options?: RunOptions) => Promise<import("./effect.js").LLMResponse>;
|
|
760
|
+
}, import("./route/client.js").CompactionOperations | undefined>> | RequestInput<Model>, options?: StreamOptions & RunOptions) => Promise<import("./effect.js").LLMResponse>;
|
|
762
761
|
stream: <const Model extends LanguageModel>(input: LLMRequest<LanguageModel<{
|
|
763
762
|
readonly [x: string]: unknown;
|
|
764
|
-
}, import("./route/client.js").CompactionOperations | undefined>> | RequestInput<Model>, options?: RunOptions) => AsyncIterable<{
|
|
763
|
+
}, import("./route/client.js").CompactionOperations | undefined>> | RequestInput<Model>, options?: StreamOptions & RunOptions) => AsyncIterable<{
|
|
765
764
|
readonly type: "step-start";
|
|
766
765
|
readonly index: number;
|
|
767
766
|
} | {
|
|
@@ -981,7 +980,7 @@ export declare const ai: {
|
|
|
981
980
|
readonly encrypted?: never;
|
|
982
981
|
}))>;
|
|
983
982
|
/** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
|
|
984
|
-
loop: <const Model extends LanguageModel>(input: LoopInput<Model>, options?: RunOptions) => AsyncIterable<{
|
|
983
|
+
loop: <const Model extends LanguageModel>(input: LoopInput<Model>, options?: StreamOptions & RunOptions) => AsyncIterable<{
|
|
985
984
|
readonly type: "step-start";
|
|
986
985
|
readonly index: number;
|
|
987
986
|
} | {
|
|
@@ -1210,6 +1209,7 @@ export declare const ai: {
|
|
|
1210
1209
|
(request: CheckpointRequest, options: TriggerCompactOptions & RunOptions): Promise<CompactionCheckpointResponse>;
|
|
1211
1210
|
(request: CompactionRequest, options?: EndpointCompactOptions & RunOptions): Promise<CompactionResponse>;
|
|
1212
1211
|
};
|
|
1212
|
+
canCompact: typeof import("./route/client.js").canCompact;
|
|
1213
1213
|
};
|
|
1214
1214
|
image: {
|
|
1215
1215
|
request: typeof import("./image.js").request;
|
package/dist/index.js
CHANGED
|
@@ -42,9 +42,11 @@ export const make = (options = {}) => {
|
|
|
42
42
|
}
|
|
43
43
|
const handle = (generation) => ({
|
|
44
44
|
...generation.snapshot,
|
|
45
|
+
snapshot: generation.snapshot,
|
|
46
|
+
terminal: generation.terminal,
|
|
45
47
|
token: generation.token,
|
|
46
|
-
await: (options) => run(generation.await(
|
|
47
|
-
events: (options) => iterate(generation.events(
|
|
48
|
+
await: (options) => run(generation.await(options), options),
|
|
49
|
+
events: (options) => iterate(generation.events(options), options),
|
|
48
50
|
result: (options) => run(generation.result(), options),
|
|
49
51
|
refresh: (options) => run(generation.refresh(), options).then(handle),
|
|
50
52
|
cancel: (options) => run(generation.cancel(), options),
|
|
@@ -77,19 +79,20 @@ export const make = (options = {}) => {
|
|
|
77
79
|
},
|
|
78
80
|
llm: {
|
|
79
81
|
request: LLM.request,
|
|
80
|
-
generate: (input, options) => run(LLM.generate(input), options),
|
|
81
|
-
stream: (input, options) => iterate(LLM.stream(input), options),
|
|
82
|
+
generate: (input, options) => run(LLM.generate(input, options), options),
|
|
83
|
+
stream: (input, options) => iterate(LLM.stream(input, options), options),
|
|
82
84
|
/** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
|
|
83
|
-
loop: (input, options) => iterate(LLM.loop(input), options),
|
|
85
|
+
loop: (input, options) => iterate(LLM.loop(input, options), options),
|
|
84
86
|
/** Decode the model's output against `schema` (or `jsonSchema`, unvalidated) like `LLM.generateObject`. */
|
|
85
87
|
generateObject,
|
|
86
88
|
/** Compact a Responses request like `LLMClient.compact`: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
|
|
87
89
|
compact,
|
|
90
|
+
canCompact: LLMClient.canCompact,
|
|
88
91
|
},
|
|
89
92
|
image: {
|
|
90
93
|
request: Image.request,
|
|
91
|
-
generate: (input, options) => run(Image.generate(input,
|
|
92
|
-
stream: (input, options) => iterate(Image.stream(input,
|
|
94
|
+
generate: (input, options) => run(Image.generate(input, options), options),
|
|
95
|
+
stream: (input, options) => iterate(Image.stream(input, options), options),
|
|
93
96
|
start: (input, options) => run(Image.start(input), options).then(handle),
|
|
94
97
|
resume: (model, token, options) => run(Image.resume(model, token), options).then(handle),
|
|
95
98
|
},
|
package/dist/tool.d.ts
CHANGED
|
@@ -90,9 +90,14 @@ export type ToolOptions<Parameters extends ToolSchema<any>, Success extends Tool
|
|
|
90
90
|
* })
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
export declare const tool: <Parameters extends ToolSchema<any> = typeof Schema.Unknown, Success extends ToolSchema<any> = typeof Schema.Unknown, Result extends Effect.Effect<Schema.Schema.Type<Success>, ToolFailure> =
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
export declare const tool: <Parameters extends ToolSchema<any> = typeof Schema.Unknown, Success extends ToolSchema<any> = typeof Schema.Unknown, Result extends Effect.Effect<Schema.Schema.Type<Success>, ToolFailure> | NoExecute = NoExecute>(config: ToolOptions<Parameters, Success, (params: Schema.Schema.Type<Parameters>, context?: ToolExecuteContext) => Result>) => 0 extends 1 & Result ? ExecutableTool<Parameters, Success> : [Result, NoExecute] extends [NoExecute, Result] ? Tool<Parameters, Success> : ExecutableTool<Parameters, Success>;
|
|
94
|
+
declare const noExecute: unique symbol;
|
|
95
|
+
/** @internal The inferred `execute` result when `execute` is omitted; no function can return it. */
|
|
96
|
+
export type NoExecute = {
|
|
97
|
+
readonly [noExecute]: never;
|
|
98
|
+
};
|
|
99
|
+
/** @internal Builds a tool for both clients from its options and an Effect `execute`. */
|
|
100
|
+
export declare function build<Parameters extends ToolSchema<any>, Success extends ToolSchema<any>, Result>(config: ToolOptions<Parameters, Success, (...args: never) => Result>, execute: ((params: Schema.Schema.Type<Parameters>, context?: ToolExecuteContext) => unknown) | undefined): 0 extends 1 & Result ? ExecutableTool<Parameters, Success> : [Result, NoExecute] extends [NoExecute, Result] ? Tool<Parameters, Success> : ExecutableTool<Parameters, Success>;
|
|
96
101
|
/**
|
|
97
102
|
* A record of named tools. The record key becomes the tool name on the wire.
|
|
98
103
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-329",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -516,7 +516,7 @@
|
|
|
516
516
|
"devDependencies": {
|
|
517
517
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
518
518
|
"@effect/platform-node": "4.0.6",
|
|
519
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
519
|
+
"@opencode/http-recorder": "0.0.0-dev-329",
|
|
520
520
|
"@tsconfig/bun": "1.0.9",
|
|
521
521
|
"@types/bun": "1.4.3",
|
|
522
522
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
@@ -526,7 +526,7 @@
|
|
|
526
526
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
527
527
|
"@smithy/eventstream-codec": "4.2.14",
|
|
528
528
|
"@smithy/util-utf8": "4.2.2",
|
|
529
|
-
"@opencode/schema": "0.0.0-dev-
|
|
529
|
+
"@opencode/schema": "0.0.0-dev-329",
|
|
530
530
|
"aws4fetch": "1.0.20",
|
|
531
531
|
"effect": "4.0.6",
|
|
532
532
|
"google-auth-library": "10.5.0"
|