@opencode/sdk 0.0.0-dev-19794 → 0.0.0-dev-19808

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.
@@ -0,0 +1,47 @@
1
+ import {
2
+ create5
3
+ } from "./tool-89hnd1wk.js";
4
+ import {
5
+ __export
6
+ } from "./tool-9rqn6x4v.js";
7
+
8
+ // src/promise.ts
9
+ var exports_promise = {};
10
+ __export(exports_promise, {
11
+ PromiseSdk: () => exports_promise,
12
+ create: () => create4
13
+ });
14
+ import { OpenCode } from "@opencode/client";
15
+ import { Session } from "@opencode/schema/session";
16
+ import { Effect, Schema } from "effect";
17
+ async function create4(options = {}, embed = {}) {
18
+ const { plugins, instances, ...hostOptions } = options;
19
+ const host = await Effect.runPromise(create5({
20
+ ...hostOptions,
21
+ instances: instances ? {
22
+ key: (session) => instances.key(Schema.encodeSync(Session.Info)(session)),
23
+ configure: (key) => Effect.gen(function* () {
24
+ const { PluginPromise } = yield* Effect.promise(() => import("@opencode/core/plugin/promise"));
25
+ const configuration = yield* Effect.tryPromise(async () => instances.configure(key));
26
+ return { plugins: configuration.plugins.map(PluginPromise.fromPromise) };
27
+ })
28
+ } : undefined
29
+ }, embed));
30
+ const client = OpenCode.make({ baseUrl: "http://opencode.local", fetch: host.fetch });
31
+ const register = async (plugin) => {
32
+ const { PluginPromise } = await import("@opencode/core/plugin/promise");
33
+ return host.runtime.runPromise(host.plugins.register(PluginPromise.fromPromise(plugin)));
34
+ };
35
+ for (const plugin of plugins ?? [])
36
+ await register(plugin);
37
+ return {
38
+ ...client,
39
+ sessions: client.session,
40
+ events: client.event,
41
+ plugin: Object.assign(register, client.plugin),
42
+ close: host.close,
43
+ [Symbol.asyncDispose]: host.close
44
+ };
45
+ }
46
+
47
+ export { create4, exports_promise };
@@ -0,0 +1,23 @@
1
+ import {
2
+ __export
3
+ } from "./tool-9rqn6x4v.js";
4
+
5
+ // src/internal/workerd.ts
6
+ var exports_workerd = {};
7
+ __export(exports_workerd, {
8
+ WorkerdProfile: () => exports_workerd,
9
+ make: () => make2
10
+ });
11
+ import { ServerWorkerd } from "@opencode/server/workerd";
12
+ function make2({ config, ...options }) {
13
+ const server = {
14
+ ...options,
15
+ config: config === undefined ? undefined : { content: JSON.stringify(config) }
16
+ };
17
+ return {
18
+ options: ServerWorkerd.serverOptions(server),
19
+ replacements: ServerWorkerd.replacements(server)
20
+ };
21
+ }
22
+
23
+ export { make2, exports_workerd };
@@ -0,0 +1,54 @@
1
+ import {
2
+ layer4,
3
+ context2
4
+ } from "./tool-ya9awdj2.js";
5
+ import {
6
+ make3
7
+ } from "./tool-wyq33nd6.js";
8
+ import {
9
+ provide2,
10
+ node2
11
+ } from "./tool-pqb0kjhx.js";
12
+ import {
13
+ __export
14
+ } from "./tool-9rqn6x4v.js";
15
+
16
+ // src/internal/host.ts
17
+ var exports_host = {};
18
+ __export(exports_host, {
19
+ EmbeddedHost: () => exports_host,
20
+ create: () => create5
21
+ });
22
+ import { SdkPlugins } from "@opencode/core/plugin/sdk";
23
+ import { SessionRestart } from "@opencode/core/session/execution/restart";
24
+ import { Session } from "@opencode/core/session";
25
+ import { Workspace } from "@opencode/core/workspace";
26
+ import { WorkspaceDriver } from "@opencode/core/workspace/driver";
27
+ import { createEmbeddedRoutes } from "@opencode/server/routes";
28
+ import { Context, Effect, Layer, ManagedRuntime } from "effect";
29
+ import { HttpEffect, HttpRouter, HttpServer } from "effect/unstable/http";
30
+ var create5 = Effect.fn("EmbeddedHost.create")(function* (options = {}, embed = {}) {
31
+ const { log, workspaceProviders, instances, ...server } = options;
32
+ const selector = instances ? provide2(instances, yield* Effect.context()) : undefined;
33
+ const runtime = ManagedRuntime.make(createEmbeddedRoutes({
34
+ ...server,
35
+ app: { ...server.app, name: server.app?.name ?? "sdk" },
36
+ database: { path: ":memory:", ...server.database }
37
+ }, workspaceProviders ? [...embed.overrides ?? [], WorkspaceDriver.node.replace(WorkspaceDriver.registryNode(workspaceProviders))] : embed.overrides, selector ? (replacements) => node2(selector, replacements) : undefined).pipe(Layer.provide(HttpServer.layerServices), Layer.provideMerge(layer4(log))));
38
+ return yield* Effect.gen(function* () {
39
+ const services = yield* runtime.contextEffect;
40
+ runtime.runFork(Context.get(services, SessionRestart.Service).resumeSuspendedSessions);
41
+ const handler = HttpEffect.toWebHandlerWith(context2(services))(Context.get(services, HttpRouter.HttpRouter).asHttpEffect());
42
+ const transport = make3(handler, runtime.dispose);
43
+ return {
44
+ runtime,
45
+ fetch: transport.fetch,
46
+ plugins: Context.get(services, SdkPlugins.Service),
47
+ sessions: Context.get(services, Session.Service),
48
+ workspace: Context.get(services, Workspace.Service),
49
+ close: transport.close
50
+ };
51
+ }).pipe(Effect.onError(() => runtime.disposeEffect));
52
+ });
53
+
54
+ export { create5, exports_host };
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+
16
+ export { __export };
@@ -0,0 +1,29 @@
1
+ // src/contracts.ts
2
+ import { Agent as Agent2 } from "@opencode/schema/agent";
3
+ import { Command as Command2 } from "@opencode/schema/command";
4
+ import { Config as Config2 } from "@opencode/schema/config";
5
+ import { Credential as Credential2 } from "@opencode/schema/credential";
6
+ import { Event as Event2 } from "@opencode/schema/event";
7
+ import { FileSystem as FileSystem2 } from "@opencode/schema/filesystem";
8
+ import { Integration as Integration2 } from "@opencode/schema/integration";
9
+ import { Location as Location2 } from "@opencode/schema/location";
10
+ import { Model as Model2 } from "@opencode/schema/model";
11
+ import { Permission as Permission2 } from "@opencode/schema/permission";
12
+ import { PermissionSaved as PermissionSaved2 } from "@opencode/schema/permission-saved";
13
+ import { Project as Project2 } from "@opencode/schema/project";
14
+ import { Worktree as Worktree2 } from "@opencode/schema/worktree";
15
+ import { Prompt as Prompt2 } from "@opencode/schema/prompt";
16
+ import { PromptInput as PromptInput2 } from "@opencode/schema/prompt-input";
17
+ import { Provider as Provider2 } from "@opencode/schema/provider";
18
+ import { Pty as Pty2 } from "@opencode/schema/pty";
19
+ import { Question as Question2 } from "@opencode/schema/question";
20
+ import { Reference as Reference2 } from "@opencode/schema/reference";
21
+ import { WebSearch as WebSearch2 } from "@opencode/schema/websearch";
22
+ import { AbsolutePath as AbsolutePath2, RelativePath as RelativePath2 } from "@opencode/schema/schema";
23
+ import { Session as Session2 } from "@opencode/schema/session";
24
+ import { SessionInbox as SessionInbox2 } from "@opencode/schema/session-inbox";
25
+ import { SessionMessage as SessionMessage2 } from "@opencode/schema/session-message";
26
+ import { Skill as Skill2 } from "@opencode/schema/skill";
27
+ import { Workspace as Workspace2 } from "@opencode/schema/workspace";
28
+
29
+ export { Agent2, Command2, Config2, Credential2, Event2, FileSystem2, Integration2, Location2, Model2, Permission2, PermissionSaved2, Project2, Worktree2, Prompt2, PromptInput2, Provider2, Pty2, Question2, Reference2, WebSearch2, AbsolutePath2, RelativePath2, Session2, SessionInbox2, SessionMessage2, Skill2, Workspace2 };
@@ -0,0 +1,14 @@
1
+ import {
2
+ __export
3
+ } from "./tool-9rqn6x4v.js";
4
+
5
+ // src/tool.ts
6
+ var exports_tool = {};
7
+ __export(exports_tool, {
8
+ Error: () => Error2,
9
+ RegistrationError: () => RegistrationError2
10
+ });
11
+ import { RegistrationError as RegistrationError2 } from "@opencode/core/tool";
12
+ import { Error as Error2 } from "@opencode/schema/tool";
13
+
14
+ export { exports_tool, RegistrationError2, Error2 };
@@ -0,0 +1,45 @@
1
+ import {
2
+ create5
3
+ } from "./tool-89hnd1wk.js";
4
+ import {
5
+ __export
6
+ } from "./tool-9rqn6x4v.js";
7
+
8
+ // src/effect/opencode.ts
9
+ var exports_opencode = {};
10
+ __export(exports_opencode, {
11
+ OpenCode: () => exports_opencode,
12
+ Service: () => Service2,
13
+ create: () => create2,
14
+ layer: () => layer2
15
+ });
16
+ import { OpenCode } from "@opencode/client/effect";
17
+ import { Context, Effect, Layer } from "effect";
18
+ import { FetchHttpClient, HttpClient } from "effect/unstable/http";
19
+ var create2 = Effect.fn("OpenCode.create")(function* (options = {}, embed = {}) {
20
+ const host = yield* Effect.acquireRelease(create5(options, embed), (host) => Effect.promise(host.close));
21
+ const httpClient = yield* HttpClient.HttpClient.pipe(Effect.provide(FetchHttpClient.layer));
22
+ const client = yield* OpenCode.make({ baseUrl: "http://opencode.local" }).pipe(Effect.provideService(HttpClient.HttpClient, HttpClient.transformResponse(httpClient, Effect.provideService(FetchHttpClient.Fetch, host.fetch))));
23
+ return {
24
+ ...client,
25
+ sessions: {
26
+ ...client.session,
27
+ create: host.sessions.create,
28
+ get: (input) => host.sessions.get(input.sessionID),
29
+ move: host.sessions.move
30
+ },
31
+ events: client.event,
32
+ workspace: {
33
+ create: host.workspace.create,
34
+ provision: ({ workspaceID }) => host.workspace.provision(workspaceID),
35
+ destroy: ({ workspaceID }) => host.workspace.destroy(workspaceID)
36
+ },
37
+ plugin: Object.assign(host.plugins.register, client.plugin)
38
+ };
39
+ });
40
+
41
+ class Service2 extends Context.Service()("@opencode/sdk/OpenCode") {
42
+ }
43
+ var layer2 = (options = {}) => Layer.effect(Service2, create2(options));
44
+
45
+ export { create2, Service2, layer2, exports_opencode };
@@ -0,0 +1,62 @@
1
+ import {
2
+ __export
3
+ } from "./tool-9rqn6x4v.js";
4
+
5
+ // src/internal/instances.ts
6
+ var exports_instances = {};
7
+ __export(exports_instances, {
8
+ SdkInstances: () => exports_instances,
9
+ layer: () => layer3,
10
+ node: () => node2,
11
+ provide: () => provide2
12
+ });
13
+ import { Instance } from "@opencode/core/instance";
14
+ import { LocationServiceMap } from "@opencode/core/location-service-map";
15
+ import { Plugin } from "@opencode/core/plugin";
16
+ import { Location } from "@opencode/schema/location";
17
+ import { makeGlobalNode } from "@opencode/util/effect/app-node";
18
+ import { Context, Duration, Effect, Layer, LayerMap } from "effect";
19
+ function provide2(options, context) {
20
+ return {
21
+ key: options.key,
22
+ configure: (key) => options.configure(key).pipe(Effect.updateContext((ambient) => Context.merge(context, ambient)))
23
+ };
24
+ }
25
+ function node2(options, replacements) {
26
+ return makeGlobalNode({
27
+ service: Instance.Service,
28
+ layer: layer3(options, replacements),
29
+ deps: [LocationServiceMap.node]
30
+ });
31
+ }
32
+ function layer3(options, replacements) {
33
+ return Layer.effect(Instance.Service, Effect.gen(function* () {
34
+ const scope = yield* Effect.scope;
35
+ const locations = yield* LocationServiceMap.Service;
36
+ const key = (session) => ({
37
+ key: options.key(session),
38
+ ...LocationServiceMap.canonical(session.location)
39
+ });
40
+ const provide = (session) => Effect.provide(instances.get(key(session)));
41
+ const instances = yield* LayerMap.make((input) => Layer.unwrap(Effect.gen(function* () {
42
+ const configuration = yield* options.configure(input.key).pipe(Effect.orDie);
43
+ return Instance.layer(Location.Ref.make({ directory: input.directory, workspaceID: input.workspaceID }), {
44
+ plugins: configuration.plugins,
45
+ replacements: [
46
+ ...replacements(),
47
+ Instance.node.replace(Layer.succeed(Instance.Service, { provide })),
48
+ LocationServiceMap.node.replace(Layer.succeed(LocationServiceMap.Service, locations))
49
+ ]
50
+ }).pipe(Layer.tap((context) => Effect.gen(function* () {
51
+ const plugins = yield* Plugin.Service;
52
+ yield* plugins.awaitActivation;
53
+ const failed = (yield* plugins.list()).filter((plugin) => plugin.state.status === "failed" && configuration.plugins.some((configured) => configured.id === plugin.id));
54
+ if (failed.length > 0)
55
+ yield* Effect.die(new Error(`Instance plugin setup failed: ${failed.map((plugin) => plugin.id).join(", ")}`));
56
+ }).pipe(Effect.provide(context))));
57
+ })).pipe(Layer.tapCause(() => instances.invalidate(input).pipe(Effect.forkIn(scope, { startImmediately: true }), Effect.asVoid))), { idleTimeToLive: Duration.infinity });
58
+ return Instance.Service.of({ provide });
59
+ }));
60
+ }
61
+
62
+ export { provide2, node2, layer3, exports_instances };
@@ -0,0 +1,15 @@
1
+ import {
2
+ create4
3
+ } from "./tool-0e5r93hw.js";
4
+ import {
5
+ __export
6
+ } from "./tool-9rqn6x4v.js";
7
+
8
+ // src/opencode.ts
9
+ var exports_opencode2 = {};
10
+ __export(exports_opencode2, {
11
+ create: () => create3
12
+ });
13
+ var create3 = (options = {}) => create4(options);
14
+
15
+ export { create3, exports_opencode2 };
@@ -0,0 +1,125 @@
1
+ import {
2
+ __export
3
+ } from "./tool-9rqn6x4v.js";
4
+
5
+ // src/internal/fetch.ts
6
+ var exports_fetch = {};
7
+ __export(exports_fetch, {
8
+ OwnedFetch: () => exports_fetch,
9
+ make: () => make3
10
+ });
11
+ function make3(handler, dispose) {
12
+ const requests = new Set;
13
+ const shutdown = new AbortController;
14
+ const closed = new Error("OpenCode host is closed");
15
+ let closePromise;
16
+ const fetch = Object.assign((input, init) => {
17
+ if (closePromise)
18
+ return Promise.reject(closed);
19
+ const source = new Request(input, init);
20
+ if (source.signal.aborted)
21
+ return Promise.reject(source.signal.reason);
22
+ const request = new Request(source, { signal: AbortSignal.any([source.signal, shutdown.signal]) });
23
+ const lifetime = Promise.withResolvers();
24
+ const finish = () => {
25
+ requests.delete(lifetime.promise);
26
+ lifetime.resolve();
27
+ };
28
+ requests.add(lifetime.promise);
29
+ const handled = handler(request);
30
+ return rejectOnAbort(handled, request.signal).then((response) => trackResponse(response, request.signal, finish), (cause) => {
31
+ handled.then(finish, finish);
32
+ throw cause;
33
+ });
34
+ }, { preconnect: () => {
35
+ return;
36
+ } });
37
+ const close = () => {
38
+ if (closePromise)
39
+ return closePromise;
40
+ closePromise = Promise.resolve().then(async () => {
41
+ shutdown.abort(closed);
42
+ await Promise.allSettled(requests);
43
+ await dispose();
44
+ });
45
+ return closePromise;
46
+ };
47
+ return { fetch, close };
48
+ }
49
+ function rejectOnAbort(promise, signal) {
50
+ if (signal.aborted)
51
+ return Promise.reject(signal.reason);
52
+ return new Promise((resolve, reject) => {
53
+ const abort = () => reject(signal.reason);
54
+ signal.addEventListener("abort", abort, { once: true });
55
+ promise.then((value) => {
56
+ signal.removeEventListener("abort", abort);
57
+ resolve(value);
58
+ }, (cause) => {
59
+ signal.removeEventListener("abort", abort);
60
+ reject(cause);
61
+ });
62
+ });
63
+ }
64
+ function trackResponse(response, signal, finish) {
65
+ if (!response.body) {
66
+ finish();
67
+ return response;
68
+ }
69
+ const reader = response.body.getReader();
70
+ let done = false;
71
+ let abort = () => {};
72
+ const complete = () => {
73
+ if (done)
74
+ return false;
75
+ done = true;
76
+ signal.removeEventListener("abort", abort);
77
+ return true;
78
+ };
79
+ const body = new ReadableStream({
80
+ start(controller) {
81
+ abort = () => {
82
+ if (!complete())
83
+ return;
84
+ controller.error(signal.reason);
85
+ reader.cancel(signal.reason).then(finish, finish);
86
+ };
87
+ if (signal.aborted)
88
+ abort();
89
+ else
90
+ signal.addEventListener("abort", abort, { once: true });
91
+ },
92
+ async pull(controller) {
93
+ try {
94
+ const next = await reader.read();
95
+ if (done)
96
+ return;
97
+ if (!next.done) {
98
+ controller.enqueue(next.value);
99
+ return;
100
+ }
101
+ if (!complete())
102
+ return;
103
+ controller.close();
104
+ finish();
105
+ } catch (cause) {
106
+ if (!complete())
107
+ return;
108
+ controller.error(cause);
109
+ finish();
110
+ }
111
+ },
112
+ async cancel(reason) {
113
+ if (!complete())
114
+ return;
115
+ try {
116
+ await reader.cancel(reason);
117
+ } finally {
118
+ finish();
119
+ }
120
+ }
121
+ });
122
+ return new Response(body, response);
123
+ }
124
+
125
+ export { make3, exports_fetch };
@@ -0,0 +1,14 @@
1
+ import {
2
+ __export
3
+ } from "./tool-9rqn6x4v.js";
4
+
5
+ // src/effect/tool.ts
6
+ var exports_tool2 = {};
7
+ __export(exports_tool2, {
8
+ Error: () => Error3,
9
+ RegistrationError: () => RegistrationError3
10
+ });
11
+ import { RegistrationError as RegistrationError3 } from "@opencode/core/tool";
12
+ import { Error as Error3 } from "@opencode/schema/tool";
13
+
14
+ export { exports_tool2, RegistrationError3, Error3 };
@@ -0,0 +1,55 @@
1
+ // src/logging.ts
2
+ import { Context, Formatter, Layer, Logger, References } from "effect";
3
+ var levels = {
4
+ trace: "Trace",
5
+ debug: "Debug",
6
+ info: "Info",
7
+ warn: "Warn",
8
+ error: "Error",
9
+ fatal: "Fatal"
10
+ };
11
+ var levelNames = new Map([
12
+ [levels.trace, "trace"],
13
+ [levels.debug, "debug"],
14
+ [levels.info, "info"],
15
+ [levels.warn, "warn"],
16
+ [levels.error, "error"],
17
+ [levels.fatal, "fatal"]
18
+ ]);
19
+ function normalizeLevel(level) {
20
+ return levelNames.get(level);
21
+ }
22
+ function layer4(log) {
23
+ const logger = Logger.make((options) => {
24
+ if (!log)
25
+ return;
26
+ const level = normalizeLevel(options.logLevel);
27
+ if (!level)
28
+ return;
29
+ const entry = Logger.formatStructured.log(options);
30
+ const values = Array.isArray(entry.message) ? entry.message : [entry.message];
31
+ const [message, ...data] = values;
32
+ const details = data.length === 1 && !Array.isArray(data[0]) ? data[0] : undefined;
33
+ const { cause: detailCause, ...detailAttributes } = details ?? {};
34
+ const attributes = {
35
+ ...entry.annotations,
36
+ ...detailAttributes,
37
+ ...Object.keys(entry.spans).length > 0 ? { spans: entry.spans } : {},
38
+ ...!details && data.length > 0 ? { data: data.length === 1 ? data[0] : data } : {}
39
+ };
40
+ try {
41
+ log.emit({
42
+ level,
43
+ message: typeof message === "string" ? message : Formatter.format(message),
44
+ ...Object.keys(attributes).length > 0 ? { attributes } : {},
45
+ ...entry.cause === undefined && detailCause === undefined ? {} : { cause: entry.cause ?? detailCause }
46
+ });
47
+ } catch {}
48
+ });
49
+ return Layer.merge(Logger.layer([logger], { mergeWithExisting: false }), Layer.succeed(References.MinimumLogLevel, levels[log?.level ?? "info"]));
50
+ }
51
+ function context2(source) {
52
+ return Context.make(Logger.CurrentLoggers, Context.get(source, Logger.CurrentLoggers)).pipe(Context.add(References.MinimumLogLevel, Context.get(source, References.MinimumLogLevel)));
53
+ }
54
+
55
+ export { layer4, context2 };
package/dist/contracts.js CHANGED
@@ -1,26 +1,58 @@
1
- export { Agent } from "@opencode/schema/agent";
2
- export { Command } from "@opencode/schema/command";
3
- export { Config } from "@opencode/schema/config";
4
- export { Credential } from "@opencode/schema/credential";
5
- export { Event } from "@opencode/schema/event";
6
- export { FileSystem } from "@opencode/schema/filesystem";
7
- export { Integration } from "@opencode/schema/integration";
8
- export { Location } from "@opencode/schema/location";
9
- export { Model } from "@opencode/schema/model";
10
- export { Permission } from "@opencode/schema/permission";
11
- export { PermissionSaved } from "@opencode/schema/permission-saved";
12
- export { Project } from "@opencode/schema/project";
13
- export { Worktree } from "@opencode/schema/worktree";
14
- export { Prompt } from "@opencode/schema/prompt";
15
- export { PromptInput } from "@opencode/schema/prompt-input";
16
- export { Provider } from "@opencode/schema/provider";
17
- export { Pty } from "@opencode/schema/pty";
18
- export { Question } from "@opencode/schema/question";
19
- export { Reference } from "@opencode/schema/reference";
20
- export { WebSearch } from "@opencode/schema/websearch";
21
- export { AbsolutePath, RelativePath } from "@opencode/schema/schema";
22
- export { Session } from "@opencode/schema/session";
23
- export { SessionInbox } from "@opencode/schema/session-inbox";
24
- export { SessionMessage } from "@opencode/schema/session-message";
25
- export { Skill } from "@opencode/schema/skill";
26
- export { Workspace } from "@opencode/schema/workspace";
1
+ import {
2
+ Agent2,
3
+ Command2,
4
+ Config2,
5
+ Credential2,
6
+ Event2,
7
+ FileSystem2,
8
+ Integration2,
9
+ Location2,
10
+ Model2,
11
+ Permission2,
12
+ PermissionSaved2,
13
+ Project2,
14
+ Worktree2,
15
+ Prompt2,
16
+ PromptInput2,
17
+ Provider2,
18
+ Pty2,
19
+ Question2,
20
+ Reference2,
21
+ WebSearch2,
22
+ AbsolutePath2,
23
+ RelativePath2,
24
+ Session2,
25
+ SessionInbox2,
26
+ SessionMessage2,
27
+ Skill2,
28
+ Workspace2
29
+ } from "./chunks/tool-j1jhtwv7.js";
30
+ export {
31
+ AbsolutePath2 as AbsolutePath,
32
+ Agent2 as Agent,
33
+ Command2 as Command,
34
+ Config2 as Config,
35
+ Credential2 as Credential,
36
+ Event2 as Event,
37
+ FileSystem2 as FileSystem,
38
+ Integration2 as Integration,
39
+ Location2 as Location,
40
+ Model2 as Model,
41
+ Permission2 as Permission,
42
+ PermissionSaved2 as PermissionSaved,
43
+ Project2 as Project,
44
+ Prompt2 as Prompt,
45
+ PromptInput2 as PromptInput,
46
+ Provider2 as Provider,
47
+ Pty2 as Pty,
48
+ Question2 as Question,
49
+ Reference2 as Reference,
50
+ RelativePath2 as RelativePath,
51
+ Session2 as Session,
52
+ SessionInbox2 as SessionInbox,
53
+ SessionMessage2 as SessionMessage,
54
+ Skill2 as Skill,
55
+ WebSearch2 as WebSearch,
56
+ Workspace2 as Workspace,
57
+ Worktree2 as Worktree
58
+ };
@@ -1,4 +1,74 @@
1
- export * as OpenCode from "./opencode";
2
- export * as Tool from "./tool";
3
- export { ClientError } from "@opencode/client/effect";
4
- export * from "../contracts";
1
+ import"../chunks/tool-ya9awdj2.js";
2
+ import"../chunks/tool-wyq33nd6.js";
3
+ import"../chunks/tool-pqb0kjhx.js";
4
+ import"../chunks/tool-89hnd1wk.js";
5
+ import {
6
+ exports_opencode
7
+ } from "../chunks/tool-kkqmfsvg.js";
8
+ import {
9
+ exports_tool2
10
+ } from "../chunks/tool-xjkw3602.js";
11
+ import {
12
+ Agent2,
13
+ Command2,
14
+ Config2,
15
+ Credential2,
16
+ Event2,
17
+ FileSystem2,
18
+ Integration2,
19
+ Location2,
20
+ Model2,
21
+ Permission2,
22
+ PermissionSaved2,
23
+ Project2,
24
+ Worktree2,
25
+ Prompt2,
26
+ PromptInput2,
27
+ Provider2,
28
+ Pty2,
29
+ Question2,
30
+ Reference2,
31
+ WebSearch2,
32
+ AbsolutePath2,
33
+ RelativePath2,
34
+ Session2,
35
+ SessionInbox2,
36
+ SessionMessage2,
37
+ Skill2,
38
+ Workspace2
39
+ } from "../chunks/tool-j1jhtwv7.js";
40
+
41
+ // src/effect/index.ts
42
+ import { ClientError } from "@opencode/client/effect";
43
+ export {
44
+ AbsolutePath2 as AbsolutePath,
45
+ Agent2 as Agent,
46
+ ClientError,
47
+ Command2 as Command,
48
+ Config2 as Config,
49
+ Credential2 as Credential,
50
+ Event2 as Event,
51
+ FileSystem2 as FileSystem,
52
+ Integration2 as Integration,
53
+ Location2 as Location,
54
+ Model2 as Model,
55
+ exports_opencode as OpenCode,
56
+ Permission2 as Permission,
57
+ PermissionSaved2 as PermissionSaved,
58
+ Project2 as Project,
59
+ Prompt2 as Prompt,
60
+ PromptInput2 as PromptInput,
61
+ Provider2 as Provider,
62
+ Pty2 as Pty,
63
+ Question2 as Question,
64
+ Reference2 as Reference,
65
+ RelativePath2 as RelativePath,
66
+ Session2 as Session,
67
+ SessionInbox2 as SessionInbox,
68
+ SessionMessage2 as SessionMessage,
69
+ Skill2 as Skill,
70
+ exports_tool2 as Tool,
71
+ WebSearch2 as WebSearch,
72
+ Workspace2 as Workspace,
73
+ Worktree2 as Worktree
74
+ };
@@ -1,28 +1,16 @@
1
- export * as OpenCode from "./opencode";
2
- import { OpenCode } from "@opencode/client/effect";
3
- import { Context, Effect, Layer } from "effect";
4
- import { FetchHttpClient, HttpClient } from "effect/unstable/http";
5
- import { EmbeddedHost } from "../internal/host";
6
- export const create = Effect.fn("OpenCode.create")(function* (options = {}, embed = {}) {
7
- const host = yield* Effect.acquireRelease(EmbeddedHost.create(options, embed), (host) => Effect.promise(host.close)), httpClient = yield* HttpClient.HttpClient.pipe(Effect.provide(FetchHttpClient.layer)), client = yield* OpenCode.make({ baseUrl: "http://opencode.local" }).pipe(Effect.provideService(HttpClient.HttpClient, HttpClient.transformResponse(httpClient, Effect.provideService(FetchHttpClient.Fetch, host.fetch))));
8
- return {
9
- ...client,
10
- sessions: {
11
- ...client.session,
12
- create: host.sessions.create,
13
- get: (input) => host.sessions.get(input.sessionID),
14
- move: host.sessions.move
15
- },
16
- events: client.event,
17
- workspace: {
18
- create: host.workspace.create,
19
- provision: ({ workspaceID }) => host.workspace.provision(workspaceID),
20
- destroy: ({ workspaceID }) => host.workspace.destroy(workspaceID)
21
- },
22
- plugin: Object.assign(host.plugins.register, client.plugin)
23
- };
24
- });
25
-
26
- export class Service extends Context.Service()("@opencode/sdk/OpenCode") {
27
- }
28
- export const layer = (options = {}) => Layer.effect(Service, create(options));
1
+ import {
2
+ create2,
3
+ Service2,
4
+ layer2,
5
+ exports_opencode
6
+ } from "../chunks/tool-kkqmfsvg.js";
7
+ import"../chunks/tool-89hnd1wk.js";
8
+ import"../chunks/tool-wyq33nd6.js";
9
+ import"../chunks/tool-pqb0kjhx.js";
10
+ import"../chunks/tool-ya9awdj2.js";
11
+ export {
12
+ exports_opencode as OpenCode,
13
+ Service2 as Service,
14
+ create2 as create,
15
+ layer2 as layer
16
+ };
@@ -1,2 +1,8 @@
1
- export { RegistrationError } from "@opencode/core/tool";
2
- export { Error } from "@opencode/schema/tool";
1
+ import {
2
+ RegistrationError3,
3
+ Error3
4
+ } from "../chunks/tool-xjkw3602.js";
5
+ export {
6
+ Error3 as Error,
7
+ RegistrationError3 as RegistrationError
8
+ };
@@ -1,8 +1,33 @@
1
- export * as OpenCodeWorkerd from "./workerd";
1
+ import {
2
+ make2
3
+ } from "../chunks/tool-39225h8g.js";
4
+ import"../chunks/tool-ya9awdj2.js";
5
+ import"../chunks/tool-wyq33nd6.js";
6
+ import"../chunks/tool-pqb0kjhx.js";
7
+ import"../chunks/tool-89hnd1wk.js";
8
+ import {
9
+ create2,
10
+ Service2
11
+ } from "../chunks/tool-kkqmfsvg.js";
12
+ import {
13
+ __export
14
+ } from "../chunks/tool-9rqn6x4v.js";
15
+
16
+ // src/effect/workerd.ts
17
+ var exports_workerd = {};
18
+ __export(exports_workerd, {
19
+ OpenCodeWorkerd: () => exports_workerd,
20
+ create: () => create,
21
+ layer: () => layer
22
+ });
2
23
  import { Layer } from "effect";
3
- import { WorkerdProfile } from "../internal/workerd";
4
- import { OpenCode } from "./opencode";
5
- export const create = ({ log, workspaceProviders, instances, ...options }) => {
6
- const profile = WorkerdProfile.make(options);
7
- return OpenCode.create({ ...profile.options, log, workspaceProviders, instances }, { overrides: profile.replacements });
8
- }, layer = (options) => Layer.effect(OpenCode.Service, create(options));
24
+ var create = ({ log, workspaceProviders, instances, ...options }) => {
25
+ const profile = make2(options);
26
+ return create2({ ...profile.options, log, workspaceProviders, instances }, { overrides: profile.replacements });
27
+ };
28
+ var layer = (options) => Layer.effect(Service2, create(options));
29
+ export {
30
+ exports_workerd as OpenCodeWorkerd,
31
+ create,
32
+ layer
33
+ };
package/dist/index.js CHANGED
@@ -1,4 +1,75 @@
1
- export * as OpenCode from "./opencode";
2
- export * as Tool from "./tool";
3
- export { ClientError } from "@opencode/client";
4
- export * from "./contracts";
1
+ import"./chunks/tool-ya9awdj2.js";
2
+ import"./chunks/tool-wyq33nd6.js";
3
+ import"./chunks/tool-pqb0kjhx.js";
4
+ import"./chunks/tool-89hnd1wk.js";
5
+ import"./chunks/tool-0e5r93hw.js";
6
+ import {
7
+ exports_opencode2
8
+ } from "./chunks/tool-ttb5t6ba.js";
9
+ import {
10
+ exports_tool
11
+ } from "./chunks/tool-jw22y9b0.js";
12
+ import {
13
+ Agent2,
14
+ Command2,
15
+ Config2,
16
+ Credential2,
17
+ Event2,
18
+ FileSystem2,
19
+ Integration2,
20
+ Location2,
21
+ Model2,
22
+ Permission2,
23
+ PermissionSaved2,
24
+ Project2,
25
+ Worktree2,
26
+ Prompt2,
27
+ PromptInput2,
28
+ Provider2,
29
+ Pty2,
30
+ Question2,
31
+ Reference2,
32
+ WebSearch2,
33
+ AbsolutePath2,
34
+ RelativePath2,
35
+ Session2,
36
+ SessionInbox2,
37
+ SessionMessage2,
38
+ Skill2,
39
+ Workspace2
40
+ } from "./chunks/tool-j1jhtwv7.js";
41
+
42
+ // src/index.ts
43
+ import { ClientError } from "@opencode/client";
44
+ export {
45
+ AbsolutePath2 as AbsolutePath,
46
+ Agent2 as Agent,
47
+ ClientError,
48
+ Command2 as Command,
49
+ Config2 as Config,
50
+ Credential2 as Credential,
51
+ Event2 as Event,
52
+ FileSystem2 as FileSystem,
53
+ Integration2 as Integration,
54
+ Location2 as Location,
55
+ Model2 as Model,
56
+ exports_opencode2 as OpenCode,
57
+ Permission2 as Permission,
58
+ PermissionSaved2 as PermissionSaved,
59
+ Project2 as Project,
60
+ Prompt2 as Prompt,
61
+ PromptInput2 as PromptInput,
62
+ Provider2 as Provider,
63
+ Pty2 as Pty,
64
+ Question2 as Question,
65
+ Reference2 as Reference,
66
+ RelativePath2 as RelativePath,
67
+ Session2 as Session,
68
+ SessionInbox2 as SessionInbox,
69
+ SessionMessage2 as SessionMessage,
70
+ Skill2 as Skill,
71
+ exports_tool as Tool,
72
+ WebSearch2 as WebSearch,
73
+ Workspace2 as Workspace,
74
+ Worktree2 as Worktree
75
+ };
@@ -1,106 +1,8 @@
1
- export * as OwnedFetch from "./fetch";
2
- export function make(handler, dispose) {
3
- const requests = new Set, shutdown = new AbortController, closed = Error("OpenCode host is closed");
4
- let closePromise;
5
- return { fetch: Object.assign((input, init) => {
6
- if (closePromise)
7
- return Promise.reject(closed);
8
- const source = new Request(input, init);
9
- if (source.signal.aborted)
10
- return Promise.reject(source.signal.reason);
11
- const request = new Request(source, { signal: AbortSignal.any([source.signal, shutdown.signal]) }), lifetime = Promise.withResolvers(), finish = () => {
12
- requests.delete(lifetime.promise);
13
- lifetime.resolve();
14
- };
15
- requests.add(lifetime.promise);
16
- const handled = handler(request);
17
- return rejectOnAbort(handled, request.signal).then((response) => trackResponse(response, request.signal, finish), (cause) => {
18
- handled.then(finish, finish);
19
- throw cause;
20
- });
21
- }, { preconnect: () => {
22
- return;
23
- } }), close: () => {
24
- if (closePromise)
25
- return closePromise;
26
- closePromise = Promise.resolve().then(async () => {
27
- shutdown.abort(closed);
28
- await Promise.allSettled(requests);
29
- await dispose();
30
- });
31
- return closePromise;
32
- } };
33
- }
34
- function rejectOnAbort(promise, signal) {
35
- if (signal.aborted)
36
- return Promise.reject(signal.reason);
37
- return new Promise((resolve, reject) => {
38
- const abort = () => reject(signal.reason);
39
- signal.addEventListener("abort", abort, { once: !0 });
40
- promise.then((value) => {
41
- signal.removeEventListener("abort", abort);
42
- resolve(value);
43
- }, (cause) => {
44
- signal.removeEventListener("abort", abort);
45
- reject(cause);
46
- });
47
- });
48
- }
49
- function trackResponse(response, signal, finish) {
50
- if (!response.body) {
51
- finish();
52
- return response;
53
- }
54
- const reader = response.body.getReader();
55
- let done = !1, abort = () => {};
56
- const complete = () => {
57
- if (done)
58
- return !1;
59
- done = !0;
60
- signal.removeEventListener("abort", abort);
61
- return !0;
62
- }, body = new ReadableStream({
63
- start(controller) {
64
- abort = () => {
65
- if (!complete())
66
- return;
67
- controller.error(signal.reason);
68
- reader.cancel(signal.reason).then(finish, finish);
69
- };
70
- if (signal.aborted)
71
- abort();
72
- else
73
- signal.addEventListener("abort", abort, { once: !0 });
74
- },
75
- async pull(controller) {
76
- try {
77
- const next = await reader.read();
78
- if (done)
79
- return;
80
- if (!next.done) {
81
- controller.enqueue(next.value);
82
- return;
83
- }
84
- if (!complete())
85
- return;
86
- controller.close();
87
- finish();
88
- } catch (cause) {
89
- if (!complete())
90
- return;
91
- controller.error(cause);
92
- finish();
93
- }
94
- },
95
- async cancel(reason) {
96
- if (!complete())
97
- return;
98
- try {
99
- await reader.cancel(reason);
100
- } finally {
101
- finish();
102
- }
103
- }
104
- });
105
- return new Response(body, response);
106
- }
1
+ import {
2
+ make3,
3
+ exports_fetch
4
+ } from "../chunks/tool-wyq33nd6.js";
5
+ export {
6
+ exports_fetch as OwnedFetch,
7
+ make3 as make
8
+ };
@@ -1,32 +1,11 @@
1
- export * as EmbeddedHost from "./host";
2
- import { SdkPlugins } from "@opencode/core/plugin/sdk";
3
- import { SessionRestart } from "@opencode/core/session/execution/restart";
4
- import { Session } from "@opencode/core/session";
5
- import { Workspace } from "@opencode/core/workspace";
6
- import { WorkspaceDriver } from "@opencode/core/workspace/driver";
7
- import { createEmbeddedRoutes } from "@opencode/server/routes";
8
- import { Context, Effect, Layer, ManagedRuntime, Scope } from "effect";
9
- import { HttpEffect, HttpRouter, HttpServer, HttpServerRequest } from "effect/unstable/http";
10
- import { context, layer } from "../logging";
11
- import { OwnedFetch } from "./fetch";
12
- import { SdkInstances } from "./instances";
13
- export const create = Effect.fn("EmbeddedHost.create")(function* (options = {}, embed = {}) {
14
- const { log, workspaceProviders, instances, ...server } = options, selector = instances ? SdkInstances.provide(instances, yield* Effect.context()) : void 0, runtime = ManagedRuntime.make(createEmbeddedRoutes({
15
- ...server,
16
- app: { ...server.app, name: server.app?.name ?? "sdk" },
17
- database: { path: ":memory:", ...server.database }
18
- }, workspaceProviders ? [...embed.overrides ?? [], WorkspaceDriver.node.replace(WorkspaceDriver.registryNode(workspaceProviders))] : embed.overrides, selector ? (replacements) => SdkInstances.node(selector, replacements) : void 0).pipe(Layer.provide(HttpServer.layerServices), Layer.provideMerge(layer(log))));
19
- return yield* Effect.gen(function* () {
20
- const services = yield* runtime.contextEffect;
21
- runtime.runFork(Context.get(services, SessionRestart.Service).resumeSuspendedSessions);
22
- const handler = HttpEffect.toWebHandlerWith(context(services))(Context.get(services, HttpRouter.HttpRouter).asHttpEffect()), transport = OwnedFetch.make(handler, runtime.dispose);
23
- return {
24
- runtime,
25
- fetch: transport.fetch,
26
- plugins: Context.get(services, SdkPlugins.Service),
27
- sessions: Context.get(services, Session.Service),
28
- workspace: Context.get(services, Workspace.Service),
29
- close: transport.close
30
- };
31
- }).pipe(Effect.onError(() => runtime.disposeEffect));
32
- });
1
+ import {
2
+ create5,
3
+ exports_host
4
+ } from "../chunks/tool-89hnd1wk.js";
5
+ import"../chunks/tool-wyq33nd6.js";
6
+ import"../chunks/tool-pqb0kjhx.js";
7
+ import"../chunks/tool-ya9awdj2.js";
8
+ export {
9
+ exports_host as EmbeddedHost,
10
+ create5 as create
11
+ };
@@ -1,45 +1,12 @@
1
- export * as SdkInstances from "./instances";
2
- import { Instance } from "@opencode/core/instance";
3
- import { LocationServiceMap } from "@opencode/core/location-service-map";
4
- import { Plugin } from "@opencode/core/plugin";
5
- import { Location } from "@opencode/schema/location";
6
- import { makeGlobalNode } from "@opencode/util/effect/app-node";
7
- import { Context, Duration, Effect, Layer, LayerMap, Scope } from "effect";
8
- export function provide(options, context) {
9
- return {
10
- key: options.key,
11
- configure: (key) => options.configure(key).pipe(Effect.updateContext((ambient) => Context.merge(context, ambient)))
12
- };
13
- }
14
- export function node(options, replacements) {
15
- return makeGlobalNode({
16
- service: Instance.Service,
17
- layer: layer(options, replacements),
18
- deps: [LocationServiceMap.node]
19
- });
20
- }
21
- export function layer(options, replacements) {
22
- return Layer.effect(Instance.Service, Effect.gen(function* () {
23
- const scope = yield* Effect.scope, locations = yield* LocationServiceMap.Service, key = (session) => ({
24
- key: options.key(session),
25
- ...LocationServiceMap.canonical(session.location)
26
- }), provide = (session) => Effect.provide(instances.get(key(session))), instances = yield* LayerMap.make((input) => Layer.unwrap(Effect.gen(function* () {
27
- const configuration = yield* options.configure(input.key).pipe(Effect.orDie);
28
- return Instance.layer(Location.Ref.make({ directory: input.directory, workspaceID: input.workspaceID }), {
29
- plugins: configuration.plugins,
30
- replacements: [
31
- ...replacements(),
32
- Instance.node.replace(Layer.succeed(Instance.Service, { provide })),
33
- LocationServiceMap.node.replace(Layer.succeed(LocationServiceMap.Service, locations))
34
- ]
35
- }).pipe(Layer.tap((context) => Effect.gen(function* () {
36
- const plugins = yield* Plugin.Service;
37
- yield* plugins.awaitActivation;
38
- const failed = (yield* plugins.list()).filter((plugin) => plugin.state.status === "failed" && configuration.plugins.some((configured) => configured.id === plugin.id));
39
- if (failed.length > 0)
40
- yield* Effect.die(Error(`Instance plugin setup failed: ${failed.map((plugin) => plugin.id).join(", ")}`));
41
- }).pipe(Effect.provide(context))));
42
- })).pipe(Layer.tapCause(() => instances.invalidate(input).pipe(Effect.forkIn(scope, { startImmediately: !0 }), Effect.asVoid))), { idleTimeToLive: Duration.infinity });
43
- return Instance.Service.of({ provide });
44
- }));
45
- }
1
+ import {
2
+ provide2,
3
+ node2,
4
+ layer3,
5
+ exports_instances
6
+ } from "../chunks/tool-pqb0kjhx.js";
7
+ export {
8
+ exports_instances as SdkInstances,
9
+ layer3 as layer,
10
+ node2 as node,
11
+ provide2 as provide
12
+ };
@@ -1,12 +1,8 @@
1
- export * as WorkerdProfile from "./workerd";
2
- import { ServerWorkerd } from "@opencode/server/workerd";
3
- export function make({ config, ...options }) {
4
- const server = {
5
- ...options,
6
- config: config === void 0 ? void 0 : { content: JSON.stringify(config) }
7
- };
8
- return {
9
- options: ServerWorkerd.serverOptions(server),
10
- replacements: ServerWorkerd.replacements(server)
11
- };
12
- }
1
+ import {
2
+ make2,
3
+ exports_workerd
4
+ } from "../chunks/tool-39225h8g.js";
5
+ export {
6
+ exports_workerd as WorkerdProfile,
7
+ make2 as make
8
+ };
package/dist/logging.js CHANGED
@@ -1,46 +1,8 @@
1
- import { Context, Formatter, Layer, Logger, References } from "effect";
2
- const levels = {
3
- trace: "Trace",
4
- debug: "Debug",
5
- info: "Info",
6
- warn: "Warn",
7
- error: "Error",
8
- fatal: "Fatal"
9
- }, levelNames = new Map([
10
- [levels.trace, "trace"],
11
- [levels.debug, "debug"],
12
- [levels.info, "info"],
13
- [levels.warn, "warn"],
14
- [levels.error, "error"],
15
- [levels.fatal, "fatal"]
16
- ]);
17
- function normalizeLevel(level) {
18
- return levelNames.get(level);
19
- }
20
- export function layer(log) {
21
- const logger = Logger.make((options) => {
22
- if (!log)
23
- return;
24
- const level = normalizeLevel(options.logLevel);
25
- if (!level)
26
- return;
27
- const entry = Logger.formatStructured.log(options), values = Array.isArray(entry.message) ? entry.message : [entry.message], [message, ...data] = values, details = data.length === 1 && !Array.isArray(data[0]) ? data[0] : void 0, { cause: detailCause, ...detailAttributes } = details ?? {}, attributes = {
28
- ...entry.annotations,
29
- ...detailAttributes,
30
- ...Object.keys(entry.spans).length > 0 ? { spans: entry.spans } : {},
31
- ...!details && data.length > 0 ? { data: data.length === 1 ? data[0] : data } : {}
32
- };
33
- try {
34
- log.emit({
35
- level,
36
- message: typeof message === "string" ? message : Formatter.format(message),
37
- ...Object.keys(attributes).length > 0 ? { attributes } : {},
38
- ...entry.cause === void 0 && detailCause === void 0 ? {} : { cause: entry.cause ?? detailCause }
39
- });
40
- } catch {}
41
- });
42
- return Layer.merge(Logger.layer([logger], { mergeWithExisting: !1 }), Layer.succeed(References.MinimumLogLevel, levels[log?.level ?? "info"]));
43
- }
44
- export function context(source) {
45
- return Context.make(Logger.CurrentLoggers, Context.get(source, Logger.CurrentLoggers)).pipe(Context.add(References.MinimumLogLevel, Context.get(source, References.MinimumLogLevel)));
46
- }
1
+ import {
2
+ layer4,
3
+ context2
4
+ } from "./chunks/tool-ya9awdj2.js";
5
+ export {
6
+ context2 as context,
7
+ layer4 as layer
8
+ };
package/dist/opencode.js CHANGED
@@ -1,2 +1,11 @@
1
- import { PromiseSdk } from "./promise";
2
- export const create = (options = {}) => PromiseSdk.create(options);
1
+ import {
2
+ create3
3
+ } from "./chunks/tool-ttb5t6ba.js";
4
+ import"./chunks/tool-0e5r93hw.js";
5
+ import"./chunks/tool-89hnd1wk.js";
6
+ import"./chunks/tool-wyq33nd6.js";
7
+ import"./chunks/tool-pqb0kjhx.js";
8
+ import"./chunks/tool-ya9awdj2.js";
9
+ export {
10
+ create3 as create
11
+ };
package/dist/promise.js CHANGED
@@ -1,30 +1,12 @@
1
- export * as PromiseSdk from "./promise";
2
- import { OpenCode } from "@opencode/client";
3
- import { Session } from "@opencode/schema/session";
4
- import { Effect, Schema } from "effect";
5
- import { EmbeddedHost } from "./internal/host";
6
- export async function create(options = {}, embed = {}) {
7
- const { plugins, instances, ...hostOptions } = options, host = await Effect.runPromise(EmbeddedHost.create({
8
- ...hostOptions,
9
- instances: instances ? {
10
- key: (session) => instances.key(Schema.encodeSync(Session.Info)(session)),
11
- configure: (key) => Effect.gen(function* () {
12
- const { PluginPromise } = yield* Effect.promise(() => import("@opencode/core/plugin/promise"));
13
- return { plugins: (yield* Effect.tryPromise(async () => instances.configure(key))).plugins.map(PluginPromise.fromPromise) };
14
- })
15
- } : void 0
16
- }, embed)), client = OpenCode.make({ baseUrl: "http://opencode.local", fetch: host.fetch }), register = async (plugin) => {
17
- const { PluginPromise } = await import("@opencode/core/plugin/promise");
18
- return host.runtime.runPromise(host.plugins.register(PluginPromise.fromPromise(plugin)));
19
- };
20
- for (const plugin of plugins ?? [])
21
- await register(plugin);
22
- return {
23
- ...client,
24
- sessions: client.session,
25
- events: client.event,
26
- plugin: Object.assign(register, client.plugin),
27
- close: host.close,
28
- [Symbol.asyncDispose]: host.close
29
- };
30
- }
1
+ import {
2
+ create4,
3
+ exports_promise
4
+ } from "./chunks/tool-0e5r93hw.js";
5
+ import"./chunks/tool-89hnd1wk.js";
6
+ import"./chunks/tool-wyq33nd6.js";
7
+ import"./chunks/tool-pqb0kjhx.js";
8
+ import"./chunks/tool-ya9awdj2.js";
9
+ export {
10
+ exports_promise as PromiseSdk,
11
+ create4 as create
12
+ };
package/dist/tool.js CHANGED
@@ -1,2 +1,8 @@
1
- export { RegistrationError } from "@opencode/core/tool";
2
- export { Error } from "@opencode/schema/tool";
1
+ import {
2
+ RegistrationError2,
3
+ Error2
4
+ } from "./chunks/tool-jw22y9b0.js";
5
+ export {
6
+ Error2 as Error,
7
+ RegistrationError2 as RegistrationError
8
+ };
package/dist/workerd.js CHANGED
@@ -1,7 +1,28 @@
1
- export * as OpenCodeWorkerd from "./workerd";
2
- import { WorkerdProfile } from "./internal/workerd";
3
- import { PromiseSdk } from "./promise";
4
- export const create = ({ log, plugins, instances, ...options }) => {
5
- const profile = WorkerdProfile.make(options);
6
- return PromiseSdk.create({ ...profile.options, log, plugins, instances }, { overrides: profile.replacements });
1
+ import {
2
+ make2
3
+ } from "./chunks/tool-39225h8g.js";
4
+ import"./chunks/tool-ya9awdj2.js";
5
+ import"./chunks/tool-wyq33nd6.js";
6
+ import"./chunks/tool-pqb0kjhx.js";
7
+ import"./chunks/tool-89hnd1wk.js";
8
+ import {
9
+ create4
10
+ } from "./chunks/tool-0e5r93hw.js";
11
+ import {
12
+ __export
13
+ } from "./chunks/tool-9rqn6x4v.js";
14
+
15
+ // src/workerd.ts
16
+ var exports_workerd = {};
17
+ __export(exports_workerd, {
18
+ OpenCodeWorkerd: () => exports_workerd,
19
+ create: () => create
20
+ });
21
+ var create = ({ log, plugins, instances, ...options }) => {
22
+ const profile = make2(options);
23
+ return create4({ ...profile.options, log, plugins, instances }, { overrides: profile.replacements });
24
+ };
25
+ export {
26
+ exports_workerd as OpenCodeWorkerd,
27
+ create
7
28
  };
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-19794",
3
+ "version": "0.0.0-dev-19808",
4
4
  "name": "@opencode/sdk",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,18 +40,18 @@
40
40
  "verify:package": "bun run script/verify-package.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@opencode/client": "0.0.0-dev-19794",
44
- "@opencode/core": "0.0.0-dev-19794",
45
- "@opencode/plugin": "0.0.0-dev-19794",
46
- "@opencode/schema": "0.0.0-dev-19794",
47
- "@opencode/server": "0.0.0-dev-19794",
48
- "@opencode/util": "0.0.0-dev-19794",
43
+ "@opencode/client": "0.0.0-dev-19808",
44
+ "@opencode/core": "0.0.0-dev-19808",
45
+ "@opencode/plugin": "0.0.0-dev-19808",
46
+ "@opencode/schema": "0.0.0-dev-19808",
47
+ "@opencode/server": "0.0.0-dev-19808",
48
+ "@opencode/util": "0.0.0-dev-19808",
49
49
  "effect": "4.0.0-rc.112"
50
50
  },
51
51
  "devDependencies": {
52
- "@opencode/ai": "0.0.0-dev-19794",
53
- "@opencode/httpapi-codegen": "0.0.0-dev-19794",
54
- "@opencode/protocol": "0.0.0-dev-19794",
52
+ "@opencode/ai": "0.0.0-dev-19808",
53
+ "@opencode/httpapi-codegen": "0.0.0-dev-19808",
54
+ "@opencode/protocol": "0.0.0-dev-19808",
55
55
  "@tsconfig/bun": "1.0.9",
56
56
  "@types/bun": "1.4.0",
57
57
  "@typescript/native-preview": "7.0.0-dev.20251207.1"