@opencode/ai 0.0.0-dev-20213 → 0.0.0-dev-20215

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 CHANGED
@@ -773,7 +773,9 @@ Provider notes:
773
773
  The promise client exposes the same surface: `ai.video.start(...)` resolves to a handle with `await`, `events`,
774
774
  `result`, `refresh`, `cancel`, and `token`; `ai.video.generate`, `ai.video.resume(model, token)`, and
775
775
  `ai.video.stream` mirror the Effect API. The handle's `status` and `progress` are a snapshot from when it was
776
- created; `refresh()` resolves to a new handle.
776
+ created; `refresh()` resolves to a new handle. Every promise method and stream accepts `{ signal }`: like `fetch`,
777
+ aborting rejects the Promise or throws from the `for await` loop with `signal.reason` (an `AbortError` `DOMException`
778
+ unless `abort(reason)` passed one), while `break` stops a stream without throwing.
777
779
 
778
780
  ```ts
779
781
  import { ai } from "@opencode/ai/promise"
package/dist/promise.d.ts CHANGED
@@ -30,7 +30,7 @@ export type GenerationHandle<Response> = Snapshot & {
30
30
  /** Serializable JSON; pass it back to `resume` from another process. */
31
31
  readonly token: unknown;
32
32
  readonly await: (options?: AwaitOptions & RunOptions) => Promise<Response>;
33
- /** Status observations until the first terminal one, polling like `await`; abort ends iteration without throwing. */
33
+ /** Status observations until the first terminal one, polling like `await`; abort throws `signal.reason`. */
34
34
  readonly events: (options?: AwaitOptions & RunOptions) => AsyncIterable<Event>;
35
35
  /** The result without polling; fails when the generation has not completed. */
36
36
  readonly result: (options?: RunOptions) => Promise<Response>;
package/dist/promise.js CHANGED
@@ -10,21 +10,22 @@ import { Speech } from "./speech.js";
10
10
  import { Transcription, } from "./transcription.js";
11
11
  import { fileMediaType } from "./utils/media-type.js";
12
12
  import { Video } from "./video.js";
13
+ // Fails with `signal.reason` so aborted calls reject and aborted streams throw like `fetch`: an `AbortError` by default.
13
14
  const abortEffect = (signal) => signal === undefined
14
15
  ? Effect.never
15
16
  : Effect.callback((resume) => {
16
17
  if (signal.aborted) {
17
- resume(Effect.void);
18
+ resume(Effect.fail(signal.reason));
18
19
  return;
19
20
  }
20
- const onAbort = () => resume(Effect.void);
21
+ const onAbort = () => resume(Effect.fail(signal.reason));
21
22
  signal.addEventListener("abort", onAbort, { once: true });
22
23
  return Effect.sync(() => signal.removeEventListener("abort", onAbort));
23
24
  });
24
25
  export const make = (options = {}) => {
25
26
  const runtime = ManagedRuntime.make(AIClient.layerWith(options.layer ?? RequestExecutor.fetchLayer));
26
27
  /** Run any package Effect (for example `LLMClient.compact(...)`) inside this runtime. */
27
- const run = (effect, options) => runtime.runPromise(effect, { signal: options?.signal });
28
+ const run = (effect, options) => runtime.runPromise(Effect.raceFirst(effect, abortEffect(options?.signal)));
28
29
  const iterate = (stream, options) => Stream.toAsyncIterable(Stream.unwrap(runtime.contextEffect.pipe(Effect.map((context) => stream.pipe(Stream.interruptWhen(abortEffect(options?.signal)), Stream.provideContext(context))))));
29
30
  const handle = (generation) => ({
30
31
  ...generation.snapshot,
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-20213",
3
+ "version": "0.0.0-dev-20215",
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-20213",
37
+ "@opencode/http-recorder": "0.0.0-dev-20215",
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-20213",
47
+ "@opencode/schema": "0.0.0-dev-20215",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.0-rc.112",
50
50
  "google-auth-library": "10.5.0"