@opencode/ai 0.0.0-dev-20537 → 0.0.0-dev-20539

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.
@@ -1132,7 +1132,7 @@ const onContentBlockStart = (state, event) => {
1132
1132
  const events = [];
1133
1133
  return [{ ...state, lifecycle: Lifecycle.stepStart(state.lifecycle, events) }, [...events, result]];
1134
1134
  };
1135
- const onContentBlockDelta = Effect.fn("AnthropicMessages.onContentBlockDelta")(function* (state, event) {
1135
+ const onContentBlockDelta = Effect.fnUntraced(function* (state, event) {
1136
1136
  const delta = event.delta;
1137
1137
  if (delta.type === "compaction_delta") {
1138
1138
  if (event.index === undefined || !(event.index in state.compactions) || delta.content === undefined)
@@ -1190,7 +1190,7 @@ const onContentBlockDelta = Effect.fn("AnthropicMessages.onContentBlockDelta")(f
1190
1190
  }
1191
1191
  return [state, NO_EVENTS];
1192
1192
  });
1193
- const onContentBlockStop = Effect.fn("AnthropicMessages.onContentBlockStop")(function* (state, event) {
1193
+ const onContentBlockStop = Effect.fnUntraced(function* (state, event) {
1194
1194
  if (event.index === undefined)
1195
1195
  return [state, NO_EVENTS];
1196
1196
  if (event.index in state.compactions) {
@@ -1246,7 +1246,7 @@ const onMessageDelta = (state, event) => {
1246
1246
  NO_EVENTS,
1247
1247
  ];
1248
1248
  };
1249
- const onMessageStop = Effect.fn("AnthropicMessages.onMessageStop")(function* (state) {
1249
+ const onMessageStop = Effect.fnUntraced(function* (state) {
1250
1250
  if (Object.keys(state.compactions).length)
1251
1251
  return yield* ProviderShared.eventError(ADAPTER, "Response ended with an incomplete compaction block");
1252
1252
  const result = yield* ToolStream.finishAll(ADAPTER, state.tools);
@@ -38,7 +38,7 @@ const decodeEvent = route.decodeFrame(SseEvent);
38
38
  /** Timestamps exist only on the SSE endpoint, so a `generate` that asks for them collects an SSE stream. */
39
39
  const usesSse = (request) => request.mode === "stream" || request.timestamps === true;
40
40
  const CONTAINERS = { pcm: "raw", wav: "wav", mp3: "mp3" };
41
- const outputFormat = Effect.fn("CartesiaSpeech.outputFormat")(function* (request) {
41
+ const outputFormat = Effect.fnUntraced(function* (request) {
42
42
  const sse = usesSse(request);
43
43
  const format = request.format ?? (sse ? "pcm" : "mp3");
44
44
  const container = CONTAINERS[format];
@@ -69,7 +69,7 @@ const fromRequest = Effect.fn("CartesiaSpeech.fromRequest")(function* (request)
69
69
  // ---------------------------------------------------------------------------
70
70
  // 6. Stream parsing
71
71
  // ---------------------------------------------------------------------------
72
- const onEvent = Effect.fn("CartesiaSpeech.onEvent")(function* (state, frame) {
72
+ const onEvent = Effect.fnUntraced(function* (state, frame) {
73
73
  const event = yield* decodeEvent(frame);
74
74
  if (event.type === "chunk" && event.data !== undefined)
75
75
  return SpeechStream.delta(state, event.data);
@@ -89,7 +89,7 @@ const onEvent = Effect.fn("CartesiaSpeech.onEvent")(function* (state, frame) {
89
89
  });
90
90
  return [state, []];
91
91
  });
92
- const finish = Effect.fn("CartesiaSpeech.finish")(function* (state, context) {
92
+ const finish = Effect.fnUntraced(function* (state, context) {
93
93
  if (usesSse(context.request) && !state.done)
94
94
  return yield* route.incomplete();
95
95
  const format = yield* outputFormat(context.request);
@@ -225,7 +225,7 @@ const mapUsage = (usage) => new Usage({
225
225
  providerMetadata: { cohere: usage },
226
226
  });
227
227
  // Lifecycle deltas open blocks on demand and ends are no-ops for closed blocks, so content-start needs no handling.
228
- const step = Effect.fn("CohereChat.step")(function* (state, event) {
228
+ const step = Effect.fnUntraced(function* (state, event) {
229
229
  const events = [];
230
230
  switch (event.type) {
231
231
  case "message-start":
@@ -32,7 +32,7 @@ const OUTPUT_FORMATS = {
32
32
  opus: "opus_48000_64",
33
33
  };
34
34
  /** WAV is served only by the non-streaming endpoints. */
35
- const outputFormat = Effect.fn("ElevenLabsSpeech.outputFormat")(function* (request) {
35
+ const outputFormat = Effect.fnUntraced(function* (request) {
36
36
  const format = request.providerOptions?.outputFormat ?? OUTPUT_FORMATS[request.format ?? "mp3"];
37
37
  if (format === undefined)
38
38
  return yield* route.unsupported("media.format", `${route.name} has no default output format for "${request.format}"; pass providerOptions.outputFormat`);
@@ -55,7 +55,7 @@ const path = (request) => `${PATH}/${encodeURIComponent(SpeechStream.voiceID(req
55
55
  // ---------------------------------------------------------------------------
56
56
  // 6. Stream parsing
57
57
  // ---------------------------------------------------------------------------
58
- const onRecord = Effect.fn("ElevenLabsSpeech.onRecord")(function* (state, frame) {
58
+ const onRecord = Effect.fnUntraced(function* (state, frame) {
59
59
  const record = yield* decodeRecord(frame);
60
60
  const [next, events] = SpeechStream.delta(state, record.audio_base64);
61
61
  const alignment = record.alignment;
@@ -80,7 +80,7 @@ const describeOutput = (format) => {
80
80
  const encoding = PCM_CODECS[codec];
81
81
  return encoding === undefined ? SpeechStream.container(codec, sampleRate) : SpeechStream.pcm(encoding, sampleRate);
82
82
  };
83
- const finish = Effect.fn("ElevenLabsSpeech.finish")(function* (state, context) {
83
+ const finish = Effect.fnUntraced(function* (state, context) {
84
84
  const requestID = context.http.headers["request-id"];
85
85
  return yield* SpeechStream.finish(route, state, {
86
86
  ...describeOutput(yield* outputFormat(context.request)),
@@ -306,7 +306,7 @@ const mapUsage = (usage, key) => {
306
306
  providerMetadata: { [key]: usage },
307
307
  });
308
308
  };
309
- const onStart = Effect.fn("GoogleInteractions.onStart")(function* (state, index, step) {
309
+ const onStart = Effect.fnUntraced(function* (state, index, step) {
310
310
  const events = [];
311
311
  let lifecycle = Lifecycle.stepStart(state.lifecycle, events);
312
312
  let tools = state.tools;
@@ -340,7 +340,7 @@ const onStart = Effect.fn("GoogleInteractions.onStart")(function* (state, index,
340
340
  return yield* ProviderShared.eventError(ADAPTER, `Unsupported Interactions step: ${step.type}`, encodeJson(step));
341
341
  return [{ ...state, lifecycle, tools, steps: { ...state.steps, [index]: step } }, events];
342
342
  });
343
- const onDelta = Effect.fn("GoogleInteractions.onDelta")(function* (state, index, delta) {
343
+ const onDelta = Effect.fnUntraced(function* (state, index, delta) {
344
344
  const step = state.steps[index];
345
345
  if (!step)
346
346
  return yield* ProviderShared.eventError(ADAPTER, "Interactions delta without step.start", encodeJson(delta));
@@ -375,7 +375,7 @@ const onDelta = Effect.fn("GoogleInteractions.onDelta")(function* (state, index,
375
375
  }
376
376
  return yield* ProviderShared.eventError(ADAPTER, `Unsupported Interactions delta: ${delta.type}`, encodeJson(delta));
377
377
  });
378
- const onStop = Effect.fn("GoogleInteractions.onStop")(function* (state, index) {
378
+ const onStop = Effect.fnUntraced(function* (state, index) {
379
379
  const step = state.steps[index];
380
380
  if (!step)
381
381
  return yield* ProviderShared.eventError(ADAPTER, "Interactions step.stop without step.start");
@@ -393,7 +393,7 @@ const onStop = Effect.fn("GoogleInteractions.onStop")(function* (state, index) {
393
393
  const result = yield* ToolStream.finish(ADAPTER, state.tools, index);
394
394
  return [{ ...state, tools: result.tools }, result.events ?? []];
395
395
  });
396
- const step = Effect.fn("GoogleInteractions.step")(function* (state, event) {
396
+ const step = Effect.fnUntraced(function* (state, event) {
397
397
  switch (event.event_type) {
398
398
  case "step.start":
399
399
  return yield* onStart(state, event.index, event.step);
@@ -42,7 +42,7 @@ const fromRequest = Effect.fn("GoogleSpeech.fromRequest")(function* (request) {
42
42
  // ---------------------------------------------------------------------------
43
43
  // 6. Stream parsing
44
44
  // ---------------------------------------------------------------------------
45
- const step = Effect.fn("GoogleSpeech.step")(function* (state, frame) {
45
+ const step = Effect.fnUntraced(function* (state, frame) {
46
46
  const chunk = yield* decodeChunk(frame);
47
47
  const blocked = GeminiGenerateContent.blocked(route.name, chunk, frame);
48
48
  if (blocked !== undefined)
@@ -70,7 +70,7 @@ const turn = (part) => {
70
70
  },
71
71
  };
72
72
  };
73
- const step = Effect.fn("GoogleTranscription.step")(function* (state, frame) {
73
+ const step = Effect.fnUntraced(function* (state, frame) {
74
74
  const chunk = yield* decodeChunk(frame);
75
75
  const blocked = GeminiGenerateContent.blocked(route.name, chunk, frame);
76
76
  if (blocked !== undefined)
@@ -74,7 +74,7 @@ const HOSTED_TOOLS = {
74
74
  image_generation_call: {
75
75
  name: "image_generation",
76
76
  input: () => ({}),
77
- result: Effect.fn("MetaResponses.imageResult")(function* (raw) {
77
+ result: Effect.fnUntraced(function* (raw) {
78
78
  const item = yield* Schema.decodeUnknownEffect(ImageItem)(raw).pipe(Effect.mapError((cause) => ProviderShared.eventError(ADAPTER, "Meta returned an invalid image item", ProviderShared.encodeJson(raw), cause)));
79
79
  if (item.error !== undefined && item.error !== null)
80
80
  return { type: "error", value: item.error };
@@ -92,7 +92,7 @@ const HOSTED_TOOLS = {
92
92
  }),
93
93
  },
94
94
  };
95
- const onEvent = Effect.fn("MetaResponses.onEvent")(function* (state, input) {
95
+ const onEvent = Effect.fnUntraced(function* (state, input) {
96
96
  const event = OpenResponses.normalize(state, input);
97
97
  if (event.type === "response.output_item.done" && event.item && ResponsesHostedTools.isItem(event.item, HOSTED_TOOLS))
98
98
  return yield* ResponsesHostedTools.onDone(state, event.item, HOSTED_TOOLS);
@@ -116,7 +116,7 @@ const onEvent = Effect.fn("MetaResponses.onEvent")(function* (state, input) {
116
116
  : item),
117
117
  ];
118
118
  });
119
- const step = Effect.fn("MetaResponses.step")(function* (state, input) {
119
+ const step = Effect.fnUntraced(function* (state, input) {
120
120
  const completedItems = new Set(state.completedItems);
121
121
  const event = OpenResponses.normalize(state, input);
122
122
  if (event.type === "response.output_item.done" && event.item && completedItems.has(event.item.id))
@@ -451,7 +451,7 @@ const toolText = (tool) => {
451
451
  return value;
452
452
  return value === null || value === undefined ? "" : ProviderShared.encodeJson(value);
453
453
  };
454
- const appendTools = Effect.fn("MistralChat.appendTools")(function* (initial, events, deltas) {
454
+ const appendTools = Effect.fnUntraced(function* (initial, events, deltas) {
455
455
  if (deltas.length === 0)
456
456
  return initial;
457
457
  let state = closeActive(initial, events);
@@ -506,7 +506,7 @@ const hasLateContent = (event) => {
506
506
  return true;
507
507
  return (delta?.tool_calls ?? []).some((tool) => Boolean(tool.id) || Boolean(tool.function?.name) || tool.function?.arguments !== undefined);
508
508
  };
509
- const step = Effect.fn("MistralChat.step")(function* (state, event) {
509
+ const step = Effect.fnUntraced(function* (state, event) {
510
510
  if (event.error) {
511
511
  const body = ProviderShared.encodeJson(event);
512
512
  return yield* new AIError({
@@ -559,7 +559,7 @@ const step = Effect.fn("MistralChat.step")(function* (state, event) {
559
559
  events,
560
560
  ];
561
561
  });
562
- const finishEvents = Effect.fn("MistralChat.finishEvents")(function* (state) {
562
+ const finishEvents = Effect.fnUntraced(function* (state) {
563
563
  if (!state.finishReason)
564
564
  return yield* new AIError({
565
565
  reason: new InvalidProviderOutputError({
@@ -902,7 +902,7 @@ const onReasoningSummaryPartDone = (state, event) => {
902
902
  NO_EVENTS,
903
903
  ];
904
904
  };
905
- const onFunctionCallArgumentsDelta = Effect.fn("OpenResponses.onFunctionCallArgumentsDelta")(function* (state, event) {
905
+ const onFunctionCallArgumentsDelta = Effect.fnUntraced(function* (state, event) {
906
906
  if (event.item_id === undefined)
907
907
  return [state, NO_EVENTS];
908
908
  const tool = state.tools[event.item_id];
@@ -927,7 +927,7 @@ const onFunctionCallArgumentsDelta = Effect.fn("OpenResponses.onFunctionCallArgu
927
927
  events.push(...result.events);
928
928
  return [{ ...state, lifecycle, tools: result.tools }, events];
929
929
  });
930
- const onOutputItemDone = Effect.fn("OpenResponses.onOutputItemDone")(function* (state, item) {
930
+ const onOutputItemDone = Effect.fnUntraced(function* (state, item) {
931
931
  if (!item)
932
932
  return [state, NO_EVENTS];
933
933
  if (item.type === "compaction") {
@@ -1055,7 +1055,7 @@ const onOutputItemDone = Effect.fn("OpenResponses.onOutputItemDone")(function* (
1055
1055
  }
1056
1056
  return [state, NO_EVENTS];
1057
1057
  });
1058
- const onResponseFinish = Effect.fn("OpenResponses.onResponseFinish")(function* (state, event) {
1058
+ const onResponseFinish = Effect.fnUntraced(function* (state, event) {
1059
1059
  let current = state;
1060
1060
  const events = [];
1061
1061
  if (event.type === "response.completed") {
@@ -674,7 +674,7 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
674
674
  // Streaming parsers are small state machines: every event returns a new state
675
675
  // plus the common `LLMEvent`s produced by that event. Tool calls are accumulated
676
676
  // because OpenAI streams JSON arguments across multiple deltas.
677
- const mapFinishReason = Effect.fn("OpenAIChat.mapFinishReason")(function* (event, reason) {
677
+ const mapFinishReason = Effect.fnUntraced(function* (event, reason) {
678
678
  switch (reason) {
679
679
  case "error":
680
680
  return yield* new AIError({
@@ -981,7 +981,7 @@ const step = (state, event) => Effect.gen(function* () {
981
981
  events,
982
982
  ];
983
983
  });
984
- const finishEvents = Effect.fn("OpenAIChat.finishEvents")(function* (state) {
984
+ const finishEvents = Effect.fnUntraced(function* (state) {
985
985
  if (state.finishReason === undefined && state.requireFinishReason)
986
986
  return yield* new AIError({
987
987
  reason: new InvalidProviderOutputError({
@@ -126,7 +126,7 @@ const info = (format, size) => {
126
126
  const eventImage = (frame, label, data, format, size) => MediaInput.decodedAsset((message, cause) => route.frameError(message, frame, cause), label, data, `image/${format}`, {
127
127
  info: info(format, size),
128
128
  });
129
- const onEvent = Effect.fn("OpenAIImages.onEvent")(function* (state, frame) {
129
+ const onEvent = Effect.fnUntraced(function* (state, frame) {
130
130
  const event = yield* decodeEvent(frame);
131
131
  const format = event.output_format;
132
132
  if ("partial_image_index" in event) {
@@ -146,7 +146,7 @@ const onEvent = Effect.fn("OpenAIImages.onEvent")(function* (state, frame) {
146
146
  [ImageOutputEvent.make({ index: state.completed, image })],
147
147
  ];
148
148
  });
149
- const onDocument = Effect.fn("OpenAIImages.onDocument")(function* (frame) {
149
+ const onDocument = Effect.fnUntraced(function* (frame) {
150
150
  const invalid = (message, cause) => route.frameError(message, frame.document, cause);
151
151
  const decoded = yield* decodeDocument(frame.document).pipe(Effect.mapError((cause) => invalid(`${route.name} returned an invalid response`, cause)));
152
152
  const format = decoded.output_format ?? frame.requested ?? "png";
@@ -191,7 +191,7 @@ const checkpointBody = {
191
191
  };
192
192
  }),
193
193
  };
194
- const hostedToolResult = Effect.fn("OpenAIResponses.hostedToolResult")(function* (item) {
194
+ const hostedToolResult = Effect.fnUntraced(function* (item) {
195
195
  const isError = item.error !== undefined && item.error !== null;
196
196
  if (item.type === "image_generation_call" && item.result) {
197
197
  yield* Effect.fromResult(Encoding.decodeBase64(item.result)).pipe(Effect.mapError((cause) => ProviderShared.eventError(ADAPTER, "OpenAI Responses returned invalid image base64", undefined, cause)));
@@ -51,7 +51,7 @@ const fromRequest = Effect.fn("OpenAISpeech.fromRequest")(function* (request) {
51
51
  // 6. Stream parsing
52
52
  // ---------------------------------------------------------------------------
53
53
  const isSse = (body) => body.type === "json" && body.value.stream_format === "sse";
54
- const onEvent = Effect.fn("OpenAISpeech.onEvent")(function* (state, frame) {
54
+ const onEvent = Effect.fnUntraced(function* (state, frame) {
55
55
  const event = yield* decodeEvent(frame);
56
56
  if (event.type === "speech.audio.delta")
57
57
  return SpeechStream.delta(state, event.audio);
@@ -131,7 +131,7 @@ const segment = (value) => ({
131
131
  endSeconds: value.end,
132
132
  speaker: value.speaker,
133
133
  });
134
- const onEvent = Effect.fn("OpenAITranscription.onEvent")(function* (state, frame) {
134
+ const onEvent = Effect.fnUntraced(function* (state, frame) {
135
135
  if (!EVENT_TYPES.has((yield* decodeEventType(frame)).type))
136
136
  return [state, []];
137
137
  const event = yield* decodeEvent(frame);
@@ -30,7 +30,7 @@ const Started = Schema.Struct({ id: Schema.String });
30
30
  /** `sd3.5-*` ids share the `sd3` endpoint and select the model with a form field. */
31
31
  const endpoint = (model) => (model.startsWith("sd3") ? "sd3" : model);
32
32
  const RESERVED_FORM_FIELDS = new Set(["image", "prompt", "mode", "model"]);
33
- const form = Effect.fn("StabilityImages.form")(function* (identity, fields, native, source) {
33
+ const form = Effect.fnUntraced(function* (identity, fields, native, source) {
34
34
  if ((source?.length ?? 0) > 1)
35
35
  return yield* identity.unsupported("media.images", `${identity.name} takes one source image`);
36
36
  const body = new FormData();
@@ -4,7 +4,7 @@ import { Protocol } from "../../route/protocol.js";
4
4
  import { CompactionCheckpointResponse, LLMEvent, LLMRequest } from "../../schema/index.js";
5
5
  import { OpenResponses } from "../open-responses.js";
6
6
  import { ProviderShared } from "../shared.js";
7
- const onOutputItem = Effect.fn("ResponsesCheckpoint.onOutputItem")(function* (state, input) {
7
+ const onOutputItem = Effect.fnUntraced(function* (state, input) {
8
8
  const event = OpenResponses.normalize(state.parser, input);
9
9
  const item = event.item;
10
10
  if (!item)
@@ -49,7 +49,7 @@ export const make = (body) => Effect.fn("ResponsesCheckpoint.execute")(function*
49
49
  checkpoints: {},
50
50
  }),
51
51
  terminal: OpenResponses.terminal,
52
- step: Effect.fn("ResponsesCheckpoint.step")(function* (state, event) {
52
+ step: Effect.fnUntraced(function* (state, event) {
53
53
  if (event.response?.id && state.responseID && event.response.id !== state.responseID)
54
54
  return yield* ProviderShared.eventError(source.id, "Compaction response ID changed during execution");
55
55
  if (event.type === "response.created")
@@ -3,7 +3,7 @@ import { LLMEvent } from "../../schema/index.js";
3
3
  import { OpenResponses } from "../open-responses.js";
4
4
  import { Lifecycle } from "./lifecycle.js";
5
5
  export const isItem = (item, tools) => item.type in tools;
6
- export const onDone = Effect.fn("ResponsesHostedTools.onDone")(function* (state, item, tools) {
6
+ export const onDone = Effect.fnUntraced(function* (state, item, tools) {
7
7
  const tool = tools[item.type];
8
8
  if (!tool)
9
9
  return [state, []];
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-20537",
3
+ "version": "0.0.0-dev-20539",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.0-rc.112",
37
- "@opencode/http-recorder": "0.0.0-dev-20537",
37
+ "@opencode/http-recorder": "0.0.0-dev-20539",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "0.0.0-dev-20537",
47
+ "@opencode/schema": "0.0.0-dev-20539",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.0-rc.112",
50
50
  "google-auth-library": "10.5.0"