@opencode-ai/sdk 0.0.0-dev-19144 → 0.0.0-dev-202609050337
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/client.d.ts +7 -0
- package/dist/client.js +53 -0
- package/dist/error-interceptor.d.ts +15 -0
- package/dist/error-interceptor.js +43 -0
- package/dist/gen/client/client.gen.d.ts +2 -0
- package/dist/gen/client/client.gen.js +165 -0
- package/dist/gen/client/index.d.ts +7 -0
- package/dist/gen/client/index.js +5 -0
- package/dist/gen/client/types.gen.d.ts +127 -0
- package/dist/gen/client/types.gen.js +2 -0
- package/dist/gen/client/utils.gen.d.ts +38 -0
- package/dist/gen/client/utils.gen.js +226 -0
- package/dist/gen/client.gen.d.ts +12 -0
- package/dist/gen/client.gen.js +5 -0
- package/dist/gen/core/auth.gen.d.ts +18 -0
- package/dist/gen/core/auth.gen.js +14 -0
- package/dist/gen/core/bodySerializer.gen.d.ts +17 -0
- package/dist/gen/core/bodySerializer.gen.js +57 -0
- package/dist/gen/core/params.gen.d.ts +33 -0
- package/dist/gen/core/params.gen.js +89 -0
- package/dist/gen/core/pathSerializer.gen.d.ts +33 -0
- package/dist/gen/core/pathSerializer.gen.js +106 -0
- package/dist/gen/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/gen/core/queryKeySerializer.gen.js +93 -0
- package/dist/gen/core/serverSentEvents.gen.d.ts +59 -0
- package/dist/gen/core/serverSentEvents.gen.js +117 -0
- package/dist/gen/core/types.gen.d.ts +78 -0
- package/dist/gen/core/types.gen.js +2 -0
- package/dist/gen/core/utils.gen.d.ts +14 -0
- package/dist/gen/core/utils.gen.js +69 -0
- package/dist/gen/sdk.gen.d.ts +403 -0
- package/dist/gen/sdk.gen.js +881 -0
- package/dist/gen/types.gen.d.ts +3383 -0
- package/dist/gen/types.gen.js +2 -0
- package/dist/index.d.ts +10 -5
- package/dist/index.js +16 -4
- package/dist/process.d.ts +3 -0
- package/dist/process.js +33 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +105 -0
- package/dist/v2/client.d.ts +9 -0
- package/dist/v2/client.js +80 -0
- package/dist/v2/data.d.ts +9 -0
- package/dist/v2/data.js +22 -0
- package/dist/v2/gen/client/client.gen.d.ts +2 -0
- package/dist/v2/gen/client/client.gen.js +232 -0
- package/dist/v2/gen/client/index.d.ts +8 -0
- package/dist/v2/gen/client/index.js +6 -0
- package/dist/v2/gen/client/types.gen.d.ts +117 -0
- package/dist/v2/gen/client/types.gen.js +2 -0
- package/dist/v2/gen/client/utils.gen.d.ts +33 -0
- package/dist/v2/gen/client/utils.gen.js +226 -0
- package/dist/v2/gen/client.gen.d.ts +12 -0
- package/dist/v2/gen/client.gen.js +3 -0
- package/dist/v2/gen/core/auth.gen.d.ts +18 -0
- package/dist/v2/gen/core/auth.gen.js +14 -0
- package/dist/v2/gen/core/bodySerializer.gen.d.ts +25 -0
- package/dist/v2/gen/core/bodySerializer.gen.js +57 -0
- package/dist/v2/gen/core/params.gen.d.ts +43 -0
- package/dist/v2/gen/core/params.gen.js +102 -0
- package/dist/v2/gen/core/pathSerializer.gen.d.ts +33 -0
- package/dist/v2/gen/core/pathSerializer.gen.js +106 -0
- package/dist/v2/gen/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/v2/gen/core/queryKeySerializer.gen.js +93 -0
- package/dist/v2/gen/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/v2/gen/core/serverSentEvents.gen.js +133 -0
- package/dist/v2/gen/core/types.gen.d.ts +78 -0
- package/dist/v2/gen/core/types.gen.js +2 -0
- package/dist/v2/gen/core/utils.gen.d.ts +19 -0
- package/dist/v2/gen/core/utils.gen.js +87 -0
- package/dist/v2/gen/sdk.gen.d.ts +2302 -0
- package/dist/v2/gen/sdk.gen.js +4456 -0
- package/dist/v2/gen/types.gen.d.ts +11656 -0
- package/dist/v2/gen/types.gen.js +2 -0
- package/dist/v2/index.d.ts +11 -0
- package/dist/v2/index.js +17 -0
- package/dist/v2/server.d.ts +23 -0
- package/dist/v2/server.js +105 -0
- package/package.json +42 -41
- package/README.md +0 -143
- package/dist/contracts.d.ts +0 -26
- package/dist/contracts.js +0 -26
- package/dist/effect/index.d.ts +0 -5
- package/dist/effect/index.js +0 -4
- package/dist/effect/opencode.d.ts +0 -31
- package/dist/effect/opencode.js +0 -23
- package/dist/effect/tool.d.ts +0 -3
- package/dist/effect/tool.js +0 -2
- package/dist/effect/workerd.d.ts +0 -15
- package/dist/effect/workerd.js +0 -8
- package/dist/internal/fetch.d.ts +0 -7
- package/dist/internal/fetch.js +0 -106
- package/dist/internal/host.d.ts +0 -30
- package/dist/internal/host.js +0 -30
- package/dist/internal/instances.d.ts +0 -24
- package/dist/internal/instances.js +0 -45
- package/dist/internal/workerd.d.ts +0 -55
- package/dist/internal/workerd.js +0 -12
- package/dist/logging.d.ts +0 -15
- package/dist/logging.js +0 -46
- package/dist/opencode.d.ts +0 -7
- package/dist/opencode.js +0 -2
- package/dist/promise.d.ts +0 -26
- package/dist/promise.js +0 -30
- package/dist/tool.d.ts +0 -3
- package/dist/tool.js +0 -2
- package/dist/workerd.d.ts +0 -26
- package/dist/workerd.js +0 -7
package/dist/internal/fetch.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/internal/host.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export * as EmbeddedHost from "./host";
|
|
2
|
-
import { SdkPlugins } from "@opencode-ai/core/plugin/sdk";
|
|
3
|
-
import { SessionRestart } from "@opencode-ai/core/session/execution/restart";
|
|
4
|
-
import { Workspace } from "@opencode-ai/core/workspace";
|
|
5
|
-
import { WorkspaceDriver } from "@opencode-ai/core/workspace/driver";
|
|
6
|
-
import type { ServerOptions } from "@opencode-ai/server/options";
|
|
7
|
-
import type { LayerNode } from "@opencode-ai/util/effect/layer-node";
|
|
8
|
-
import { Effect, ManagedRuntime } from "effect";
|
|
9
|
-
import { HttpRouter } from "effect/unstable/http";
|
|
10
|
-
import { type LogOptions } from "../logging";
|
|
11
|
-
import { SdkInstances } from "./instances";
|
|
12
|
-
export interface CreateOptions<R = never> extends Omit<ServerOptions, "hostname" | "port" | "password"> {
|
|
13
|
-
readonly log?: LogOptions;
|
|
14
|
-
readonly workspaceProviders?: Readonly<Record<string, WorkspaceDriver.Interface>>;
|
|
15
|
-
readonly instances?: SdkInstances.Options<R>;
|
|
16
|
-
}
|
|
17
|
-
/** Host hooks for embedding opencode on a non-default runtime profile. */
|
|
18
|
-
export interface EmbedOptions {
|
|
19
|
-
readonly overrides?: LayerNode.Replacements;
|
|
20
|
-
}
|
|
21
|
-
export declare const create: <R = never>(options?: CreateOptions<R> | undefined, embed?: EmbedOptions | undefined) => Effect.Effect<{
|
|
22
|
-
runtime: ManagedRuntime.ManagedRuntime<import("effect/unstable/http/HttpClient").HttpClient | import("@opencode-ai/util/global").Service | import("@opencode-ai/core/database/database").Service | import("@opencode-ai/core/project").Service | import("@opencode-ai/core/bus").Service | import("@opencode-ai/core/persistent-pty/index").Service | import("@opencode-ai/core/credential").Service | import("@opencode-ai/core/wellknown").Service | Workspace.Service | import("@opencode-ai/core/permission/saved").Service | SdkPlugins.Service | import("@opencode-ai/core/plugin/update").Service | import("@opencode-ai/core/session").Service | import("@opencode-ai/core/job").Service | import("@opencode-ai/core/instance").Service | import("@opencode-ai/core/location-service-map").Service | SessionRestart.Service | import("@opencode-ai/core/pty/ticket").Service | import("@opencode-ai/core/session/transfer").Service | import("@opencode-ai/core/location-activity").Service | import("@opencode-ai/server/pty-environment").Service | HttpRouter.HttpRouter, Error | import("@opencode-ai/core/persistent-pty/index").UnavailableError>;
|
|
23
|
-
fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & {
|
|
24
|
-
preconnect: () => undefined;
|
|
25
|
-
};
|
|
26
|
-
plugins: SdkPlugins.Interface;
|
|
27
|
-
workspace: Workspace.Interface;
|
|
28
|
-
close: () => Promise<void>;
|
|
29
|
-
}, Error, R>;
|
|
30
|
-
export type Interface = Effect.Success<ReturnType<typeof create>>;
|
package/dist/internal/host.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export * as EmbeddedHost from "./host";
|
|
2
|
-
import { SdkPlugins } from "@opencode-ai/core/plugin/sdk";
|
|
3
|
-
import { SessionRestart } from "@opencode-ai/core/session/execution/restart";
|
|
4
|
-
import { Workspace } from "@opencode-ai/core/workspace";
|
|
5
|
-
import { WorkspaceDriver } from "@opencode-ai/core/workspace/driver";
|
|
6
|
-
import { createEmbeddedRoutes } from "@opencode-ai/server/routes";
|
|
7
|
-
import { Context, Effect, Layer, ManagedRuntime, Scope } from "effect";
|
|
8
|
-
import { HttpEffect, HttpRouter, HttpServer, HttpServerRequest } from "effect/unstable/http";
|
|
9
|
-
import { context, layer } from "../logging";
|
|
10
|
-
import { OwnedFetch } from "./fetch";
|
|
11
|
-
import { SdkInstances } from "./instances";
|
|
12
|
-
export const create = Effect.fn("EmbeddedHost.create")(function* (options = {}, embed = {}) {
|
|
13
|
-
const { log, workspaceProviders, instances, ...server } = options, selector = instances ? SdkInstances.provide(instances, yield* Effect.context()) : void 0, runtime = ManagedRuntime.make(createEmbeddedRoutes({
|
|
14
|
-
...server,
|
|
15
|
-
app: { ...server.app, name: server.app?.name ?? "sdk" },
|
|
16
|
-
database: { path: ":memory:", ...server.database }
|
|
17
|
-
}, 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))));
|
|
18
|
-
return yield* Effect.gen(function* () {
|
|
19
|
-
const services = yield* runtime.contextEffect;
|
|
20
|
-
runtime.runFork(Context.get(services, SessionRestart.Service).resumeSuspendedSessions);
|
|
21
|
-
const handler = HttpEffect.toWebHandlerWith(context(services))(Context.get(services, HttpRouter.HttpRouter).asHttpEffect()), transport = OwnedFetch.make(handler, runtime.dispose);
|
|
22
|
-
return {
|
|
23
|
-
runtime,
|
|
24
|
-
fetch: transport.fetch,
|
|
25
|
-
plugins: Context.get(services, SdkPlugins.Service),
|
|
26
|
-
workspace: Context.get(services, Workspace.Service),
|
|
27
|
-
close: transport.close
|
|
28
|
-
};
|
|
29
|
-
}).pipe(Effect.onError(() => runtime.disposeEffect));
|
|
30
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export * as SdkInstances from "./instances";
|
|
2
|
-
import { Instance } from "@opencode-ai/core/instance";
|
|
3
|
-
import { LocationServiceMap } from "@opencode-ai/core/location-service-map";
|
|
4
|
-
import type { InstancePlugins } from "@opencode-ai/core/plugin/instance";
|
|
5
|
-
import type { Session } from "@opencode-ai/schema/session";
|
|
6
|
-
import type { LayerNode } from "@opencode-ai/util/effect/layer-node";
|
|
7
|
-
import { Context, Effect, Layer, Scope } from "effect";
|
|
8
|
-
export interface Configuration {
|
|
9
|
-
readonly plugins: InstancePlugins.List;
|
|
10
|
-
}
|
|
11
|
-
export interface Options<R = never> {
|
|
12
|
-
/** Select a sharing key within the Session's current Location. Must not initialize plugins. */
|
|
13
|
-
readonly key: (session: Session.Info) => string;
|
|
14
|
-
/**
|
|
15
|
-
* Reconstruct configuration on a cache miss. Resources belong to the instance Scope; other requirements
|
|
16
|
-
* are the services the SDK entrypoint was built with.
|
|
17
|
-
*/
|
|
18
|
-
readonly configure: (key: string) => Effect.Effect<Configuration, unknown, R | Scope.Scope>;
|
|
19
|
-
}
|
|
20
|
-
/** Closes `configure` over services captured where the SDK entrypoint was built; the host graph has none of its own. */
|
|
21
|
-
export declare function provide<R>(options: Options<R>, context: Context.Context<R>): Options;
|
|
22
|
-
/** Replaces the host's `Instance.node`; `replacements` resolves lazily so instances inherit the final host graph. */
|
|
23
|
-
export declare function node(options: Options, replacements: () => LayerNode.Replacements): LayerNode.Provider<Instance.Service, never, LayerNode.Tag<"global">>;
|
|
24
|
-
export declare function layer(options: Options, replacements: () => LayerNode.Replacements): Layer.Layer<Instance.Service, never, LocationServiceMap.Service>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export * as SdkInstances from "./instances";
|
|
2
|
-
import { Instance } from "@opencode-ai/core/instance";
|
|
3
|
-
import { LocationServiceMap } from "@opencode-ai/core/location-service-map";
|
|
4
|
-
import { Plugin } from "@opencode-ai/core/plugin";
|
|
5
|
-
import { Location } from "@opencode-ai/schema/location";
|
|
6
|
-
import { makeGlobalNode } from "@opencode-ai/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,55 +0,0 @@
|
|
|
1
|
-
export * as WorkerdProfile from "./workerd";
|
|
2
|
-
import type { Config } from "@opencode-ai/schema/config";
|
|
3
|
-
import { ServerWorkerd } from "@opencode-ai/server/workerd";
|
|
4
|
-
export type Configuration = Omit<typeof Config.Info.Encoded, "plugins">;
|
|
5
|
-
export interface Options extends Omit<ServerWorkerd.Options, "password" | "config"> {
|
|
6
|
-
readonly config?: Configuration;
|
|
7
|
-
}
|
|
8
|
-
export declare function make({ config, ...options }: Options): {
|
|
9
|
-
options: {
|
|
10
|
-
readonly models?: {
|
|
11
|
-
readonly url?: string | undefined;
|
|
12
|
-
readonly file?: string | undefined;
|
|
13
|
-
readonly snapshot?: boolean | undefined;
|
|
14
|
-
readonly fetch?: boolean | undefined;
|
|
15
|
-
} | undefined;
|
|
16
|
-
readonly pty?: {
|
|
17
|
-
readonly handoff?: {
|
|
18
|
-
readonly directory: string;
|
|
19
|
-
readonly instanceID: string;
|
|
20
|
-
readonly ticket: string;
|
|
21
|
-
readonly expiresAt: number;
|
|
22
|
-
} | undefined;
|
|
23
|
-
} | undefined;
|
|
24
|
-
readonly config?: {
|
|
25
|
-
readonly directory?: string | undefined;
|
|
26
|
-
readonly project?: boolean | undefined;
|
|
27
|
-
readonly content?: string | undefined;
|
|
28
|
-
readonly file?: string | undefined;
|
|
29
|
-
} | undefined;
|
|
30
|
-
readonly events?: {
|
|
31
|
-
readonly persist?: boolean | undefined;
|
|
32
|
-
} | undefined;
|
|
33
|
-
readonly port?: number | undefined;
|
|
34
|
-
readonly hostname?: string | undefined;
|
|
35
|
-
readonly cors?: readonly string[] | undefined;
|
|
36
|
-
readonly windows?: {
|
|
37
|
-
readonly gitbash?: string | undefined;
|
|
38
|
-
} | undefined;
|
|
39
|
-
readonly app?: {
|
|
40
|
-
readonly version?: string | undefined;
|
|
41
|
-
readonly name?: string | undefined;
|
|
42
|
-
readonly channel?: string | undefined;
|
|
43
|
-
} | undefined;
|
|
44
|
-
readonly fs?: {
|
|
45
|
-
readonly fff?: boolean | undefined;
|
|
46
|
-
readonly filewatcher?: boolean | undefined;
|
|
47
|
-
} | undefined;
|
|
48
|
-
readonly password?: string | undefined;
|
|
49
|
-
readonly simulation?: boolean | undefined;
|
|
50
|
-
readonly database?: {
|
|
51
|
-
readonly path?: string | undefined;
|
|
52
|
-
} | undefined;
|
|
53
|
-
};
|
|
54
|
-
replacements: import("@opencode-ai/util/effect/layer-node").Replacements;
|
|
55
|
-
};
|
package/dist/internal/workerd.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * as WorkerdProfile from "./workerd";
|
|
2
|
-
import { ServerWorkerd } from "@opencode-ai/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
|
-
}
|
package/dist/logging.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Context, Layer } from "effect";
|
|
2
|
-
export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
3
|
-
export type LogEntry = {
|
|
4
|
-
readonly level: LogLevel;
|
|
5
|
-
readonly message: string;
|
|
6
|
-
readonly attributes?: Readonly<Record<string, unknown>>;
|
|
7
|
-
readonly cause?: unknown;
|
|
8
|
-
};
|
|
9
|
-
export type LogWriter = (entry: LogEntry) => void;
|
|
10
|
-
export type LogOptions = {
|
|
11
|
-
readonly level?: LogLevel;
|
|
12
|
-
readonly emit: LogWriter;
|
|
13
|
-
};
|
|
14
|
-
export declare function layer(log?: LogOptions): Layer.Layer<never, never, never>;
|
|
15
|
-
export declare function context(source: Context.Context<never>): Context.Context<never>;
|
package/dist/logging.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/opencode.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PromiseSdk } from "./promise";
|
|
2
|
-
export type { LogEntry, LogLevel, LogOptions, LogWriter } from "./logging";
|
|
3
|
-
export type CreateOptions = PromiseSdk.CreateOptions;
|
|
4
|
-
export type InstanceOptions = PromiseSdk.InstanceOptions;
|
|
5
|
-
export type InstanceConfiguration = PromiseSdk.InstanceConfiguration;
|
|
6
|
-
export type Interface = PromiseSdk.Interface;
|
|
7
|
-
export declare const create: (options?: CreateOptions) => Promise<PromiseSdk.Interface>;
|
package/dist/opencode.js
DELETED
package/dist/promise.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export * as PromiseSdk from "./promise";
|
|
2
|
-
import { type OpenCodeClient } from "@opencode-ai/client";
|
|
3
|
-
import type { Plugin } from "@opencode-ai/plugin";
|
|
4
|
-
import { Session } from "@opencode-ai/schema/session";
|
|
5
|
-
import { EmbeddedHost } from "./internal/host";
|
|
6
|
-
export interface InstanceConfiguration {
|
|
7
|
-
readonly plugins: ReadonlyArray<Plugin.Plugin>;
|
|
8
|
-
}
|
|
9
|
-
export interface InstanceOptions {
|
|
10
|
-
/** Select a sharing key within the Session's current Location. Must not initialize plugins. */
|
|
11
|
-
readonly key: (session: typeof Session.Info.Encoded) => string;
|
|
12
|
-
/** Reconstruct configuration on a cache miss, including after a host restart. */
|
|
13
|
-
readonly configure: (key: string) => InstanceConfiguration | Promise<InstanceConfiguration>;
|
|
14
|
-
}
|
|
15
|
-
export interface CreateOptions extends Omit<EmbeddedHost.CreateOptions, "workspaceProviders" | "instances"> {
|
|
16
|
-
readonly plugins?: ReadonlyArray<Plugin.Plugin>;
|
|
17
|
-
readonly instances?: InstanceOptions;
|
|
18
|
-
}
|
|
19
|
-
export type Interface = Omit<OpenCodeClient, "plugin"> & {
|
|
20
|
-
readonly sessions: OpenCodeClient["session"];
|
|
21
|
-
readonly events: OpenCodeClient["event"];
|
|
22
|
-
readonly plugin: ((plugin: Plugin.Plugin) => Promise<void>) & OpenCodeClient["plugin"];
|
|
23
|
-
readonly close: () => Promise<void>;
|
|
24
|
-
readonly [Symbol.asyncDispose]: () => Promise<void>;
|
|
25
|
-
};
|
|
26
|
-
export declare function create(options?: CreateOptions, embed?: EmbeddedHost.EmbedOptions): Promise<Interface>;
|
package/dist/promise.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export * as PromiseSdk from "./promise";
|
|
2
|
-
import { OpenCode } from "@opencode-ai/client";
|
|
3
|
-
import { Session } from "@opencode-ai/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-ai/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-ai/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
|
-
}
|
package/dist/tool.d.ts
DELETED
package/dist/tool.js
DELETED
package/dist/workerd.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export * as OpenCodeWorkerd from "./workerd";
|
|
2
|
-
import { WorkerdProfile } from "./internal/workerd";
|
|
3
|
-
import type { LogOptions } from "./logging";
|
|
4
|
-
import { PromiseSdk } from "./promise";
|
|
5
|
-
export type Configuration = WorkerdProfile.Configuration;
|
|
6
|
-
export interface CreateOptions extends WorkerdProfile.Options {
|
|
7
|
-
readonly log?: LogOptions;
|
|
8
|
-
readonly plugins?: PromiseSdk.CreateOptions["plugins"];
|
|
9
|
-
readonly instances?: PromiseSdk.CreateOptions["instances"];
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Boots the embedded opencode SDK on the workerd runtime profile: the full
|
|
13
|
-
* application graph inside a Cloudflare Durable Object, with the database on
|
|
14
|
-
* the injected `DurableObjectStorage` SQLite and every intentionally-local
|
|
15
|
-
* service replaced or disabled (see `ServerWorkerd.replacements`).
|
|
16
|
-
*
|
|
17
|
-
* Suspended Sessions resume on boot (as on every runtime) because a Durable
|
|
18
|
-
* Object can be evicted mid-turn with no teardown; the write-ahead execution
|
|
19
|
-
* claim marks the turn and the boot-time sweep replays it.
|
|
20
|
-
*
|
|
21
|
-
* Returns the same typed `OpenCode.Interface` as `OpenCode.create` — typed
|
|
22
|
-
* session operations plus the live `events.subscribe()` stream — served over
|
|
23
|
-
* an in-process fetch transport, so no request leaves the isolate.
|
|
24
|
-
*/
|
|
25
|
-
export declare const create: ({ log, plugins, instances, ...options }: CreateOptions) => Promise<PromiseSdk.Interface>;
|
|
26
|
-
export type Interface = PromiseSdk.Interface;
|
package/dist/workerd.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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 });
|
|
7
|
-
};
|