Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/test/run/noninteractive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async function run(input: {
yield value
}
})()
spyOn(sdk.event, "subscribe").mockImplementation(() => stream)
spyOn(sdk.event, "subscribe").mockImplementation((() => stream) as typeof sdk.event.subscribe)
spyOn(sdk.permission, "list").mockImplementation(() => ok([]) as never)
spyOn(sdk.session.form, "list").mockImplementation(
(request) => ok(input.pendingForms?.filter((item) => item.sessionID === request.sessionID) ?? []) as never,
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/effect/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { WebsearchApi } from "./api/api.js"

export type { RpcApi, RpcClient } from "./rpc.js"
export type { SelectedEvent } from "../shared-events.js"

export type * from "./api/api.js"

Expand Down
103 changes: 102 additions & 1 deletion packages/client/src/effect/api/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/client/src/effect/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { Cause, Context, Effect, Stream } from "effect"
import { HttpClient, HttpClientRequest } from "effect/http"
import { SharedEvents } from "../shared-events.js"
import { ClientError, OpenCode } from "./generated/index.js"
import type { EventSubscribeInput } from "./api.js"
import { RpcClientRuntime } from "./rpc.js"
import type { RpcCallOptions } from "../promise/rpc.js"

type EventType = NonNullable<EventSubscribeInput["types"]>[number]

const CurrentHeaders = Context.Reference<RpcCallOptions["headers"]>("@opencode/client/effect/rpc/headers", {
defaultValue: () => undefined,
})
Expand Down Expand Up @@ -38,8 +41,8 @@ export const make = Effect.fn("OpenCode.make")(function* (options?: { readonly b
context,
),
)
const subscribe = () =>
Stream.fromAsyncIterable(shared.subscribe(), (error) => error).pipe(
const subscribe = <Type extends EventType = EventType>(input?: { readonly types?: ReadonlyArray<Type> }) =>
Stream.fromAsyncIterable(shared.subscribe({ types: input?.types }), (error) => error).pipe(
Stream.catch((error) =>
Stream.failCause(error instanceof EventFailure ? error.cause : Cause.fail(new ClientError({ cause: error }))),
),
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/effect/generated/client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/client/src/promise/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { OpenCode } from "./client.js"
type Client = ReturnType<typeof OpenCode.make>

export type { RpcApi, RpcCallOptions, RpcClient, RpcEventPayload } from "./rpc.js"
export type { SelectedEvent, SubscribeOptions } from "../shared-events.js"

export type AgentApi = Client["agent"]
export type CommandApi = Client["command"]
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/promise/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type { ClientOptions, RequestOptions } from "./generated/client.js"

export function make(options: ClientOptions) {
const raw = OpenCode.make(options)
const events = SharedEvents.make((signal, onActivity) => raw.event.subscribe({ signal, onActivity }))
const events = SharedEvents.make((signal, onActivity) => raw.event.subscribe(undefined, { signal, onActivity }))
return {
...raw,
rpc: Object.assign(makeRpc(raw, events), raw.rpc),
Expand Down
12 changes: 10 additions & 2 deletions packages/client/src/promise/generated/client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions packages/client/src/promise/generated/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading