@opencode/sdk 2.0.8 → 2.0.9
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/chunks/tool-39225h8g.js +23 -0
- package/dist/chunks/tool-9rqn6x4v.js +16 -0
- package/dist/chunks/tool-b54z5jwe.js +54 -0
- package/dist/chunks/tool-hdqq71na.js +14 -0
- package/dist/chunks/tool-j1jhtwv7.js +29 -0
- package/dist/chunks/tool-j34yx374.js +15 -0
- package/dist/chunks/tool-kp70gr0x.js +47 -0
- package/dist/chunks/tool-n1hprnh9.js +14 -0
- package/dist/chunks/tool-pqb0kjhx.js +62 -0
- package/dist/chunks/tool-wyq33nd6.js +125 -0
- package/dist/chunks/tool-xcejgzf0.js +45 -0
- package/dist/chunks/tool-ya9awdj2.js +55 -0
- package/dist/contracts.js +58 -26
- package/dist/effect/index.js +74 -4
- package/dist/effect/opencode.js +16 -28
- package/dist/effect/tool.js +8 -2
- package/dist/effect/workerd.js +32 -7
- package/dist/index.js +75 -4
- package/dist/internal/fetch.js +8 -106
- package/dist/internal/host.d.ts +1 -1
- package/dist/internal/host.js +11 -32
- package/dist/internal/instances.js +12 -45
- package/dist/internal/workerd.js +8 -12
- package/dist/logging.js +8 -46
- package/dist/opencode.js +11 -2
- package/dist/promise.js +12 -30
- package/dist/tool.js +8 -2
- package/dist/workerd.js +27 -6
- package/package.json +10 -10
package/dist/effect/opencode.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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-xcejgzf0.js";
|
|
7
|
+
import"../chunks/tool-b54z5jwe.js";
|
|
8
|
+
import"../chunks/tool-pqb0kjhx.js";
|
|
9
|
+
import"../chunks/tool-ya9awdj2.js";
|
|
10
|
+
import"../chunks/tool-wyq33nd6.js";
|
|
11
|
+
export {
|
|
12
|
+
exports_opencode as OpenCode,
|
|
13
|
+
Service2 as Service,
|
|
14
|
+
create2 as create,
|
|
15
|
+
layer2 as layer
|
|
16
|
+
};
|
package/dist/effect/tool.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
RegistrationError2,
|
|
3
|
+
Error2
|
|
4
|
+
} from "../chunks/tool-n1hprnh9.js";
|
|
5
|
+
export {
|
|
6
|
+
Error2 as Error,
|
|
7
|
+
RegistrationError2 as RegistrationError
|
|
8
|
+
};
|
package/dist/effect/workerd.js
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
|
|
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-b54z5jwe.js";
|
|
8
|
+
import {
|
|
9
|
+
create2,
|
|
10
|
+
Service2
|
|
11
|
+
} from "../chunks/tool-xcejgzf0.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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import"./chunks/tool-ya9awdj2.js";
|
|
2
|
+
import"./chunks/tool-wyq33nd6.js";
|
|
3
|
+
import"./chunks/tool-pqb0kjhx.js";
|
|
4
|
+
import"./chunks/tool-b54z5jwe.js";
|
|
5
|
+
import"./chunks/tool-kp70gr0x.js";
|
|
6
|
+
import {
|
|
7
|
+
exports_opencode2
|
|
8
|
+
} from "./chunks/tool-j34yx374.js";
|
|
9
|
+
import {
|
|
10
|
+
exports_tool2
|
|
11
|
+
} from "./chunks/tool-hdqq71na.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_tool2 as Tool,
|
|
72
|
+
WebSearch2 as WebSearch,
|
|
73
|
+
Workspace2 as Workspace,
|
|
74
|
+
Worktree2 as Worktree
|
|
75
|
+
};
|
package/dist/internal/fetch.js
CHANGED
|
@@ -1,106 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
};
|
package/dist/internal/host.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface EmbedOptions {
|
|
|
20
20
|
readonly overrides?: LayerNode.Replacements;
|
|
21
21
|
}
|
|
22
22
|
export declare const create: <R = never>(options?: CreateOptions<R> | undefined, embed?: EmbedOptions | undefined) => Effect.Effect<{
|
|
23
|
-
runtime: ManagedRuntime.ManagedRuntime<import("effect/unstable/http/HttpClient").HttpClient | import("@opencode/util/global").Service | import("@opencode/core/database/database").Service | import("@opencode/core/project").Service | import("@opencode/core/bus").Service | import("@opencode/core/persistent-pty/index").Service | import("@opencode/core/credential").Service | import("@opencode/core/wellknown").Service | Workspace.Service | import("@opencode/core/permission/saved").Service | SdkPlugins.Service | import("@opencode/core/plugin/update").Service |
|
|
23
|
+
runtime: ManagedRuntime.ManagedRuntime<import("effect/unstable/http/HttpClient").HttpClient | import("@opencode/util/global").Service | import("@opencode/core/database/database").Service | import("@opencode/core/project").Service | import("@opencode/core/bus").Service | import("@opencode/core/persistent-pty/index").Service | import("@opencode/core/credential").Service | import("@opencode/core/wellknown").Service | Workspace.Service | import("@opencode/core/permission/saved").Service | SdkPlugins.Service | import("@opencode/core/plugin/update").Service | import("@opencode/core/job").Service | Session.Service | import("@opencode/core/worktree").Service | import("@opencode/core/instance").Service | import("@opencode/core/location-service-map").Service | SessionRestart.Service | import("@opencode/core/pty/ticket").Service | import("@opencode/core/session/transfer").Service | import("@opencode/core/location-activity").Service | import("@opencode/server/pty-environment").Service | HttpRouter.HttpRouter, Error | import("@opencode/core/persistent-pty/index").UnavailableError>;
|
|
24
24
|
fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & {
|
|
25
25
|
preconnect: () => undefined;
|
|
26
26
|
};
|
package/dist/internal/host.js
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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-b54z5jwe.js";
|
|
5
|
+
import"../chunks/tool-pqb0kjhx.js";
|
|
6
|
+
import"../chunks/tool-ya9awdj2.js";
|
|
7
|
+
import"../chunks/tool-wyq33nd6.js";
|
|
8
|
+
export {
|
|
9
|
+
exports_host as EmbeddedHost,
|
|
10
|
+
create5 as create
|
|
11
|
+
};
|
|
@@ -1,45 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
};
|
package/dist/internal/workerd.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
create3
|
|
3
|
+
} from "./chunks/tool-j34yx374.js";
|
|
4
|
+
import"./chunks/tool-kp70gr0x.js";
|
|
5
|
+
import"./chunks/tool-b54z5jwe.js";
|
|
6
|
+
import"./chunks/tool-pqb0kjhx.js";
|
|
7
|
+
import"./chunks/tool-ya9awdj2.js";
|
|
8
|
+
import"./chunks/tool-wyq33nd6.js";
|
|
9
|
+
export {
|
|
10
|
+
create3 as create
|
|
11
|
+
};
|
package/dist/promise.js
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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-kp70gr0x.js";
|
|
5
|
+
import"./chunks/tool-b54z5jwe.js";
|
|
6
|
+
import"./chunks/tool-pqb0kjhx.js";
|
|
7
|
+
import"./chunks/tool-ya9awdj2.js";
|
|
8
|
+
import"./chunks/tool-wyq33nd6.js";
|
|
9
|
+
export {
|
|
10
|
+
exports_promise as PromiseSdk,
|
|
11
|
+
create4 as create
|
|
12
|
+
};
|
package/dist/tool.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
RegistrationError3,
|
|
3
|
+
Error3
|
|
4
|
+
} from "./chunks/tool-hdqq71na.js";
|
|
5
|
+
export {
|
|
6
|
+
Error3 as Error,
|
|
7
|
+
RegistrationError3 as RegistrationError
|
|
8
|
+
};
|
package/dist/workerd.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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-b54z5jwe.js";
|
|
8
|
+
import {
|
|
9
|
+
create4
|
|
10
|
+
} from "./chunks/tool-kp70gr0x.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": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
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": "2.0.
|
|
44
|
-
"@opencode/core": "2.0.
|
|
45
|
-
"@opencode/plugin": "2.0.
|
|
46
|
-
"@opencode/schema": "2.0.
|
|
47
|
-
"@opencode/server": "2.0.
|
|
48
|
-
"@opencode/util": "2.0.
|
|
43
|
+
"@opencode/client": "2.0.9",
|
|
44
|
+
"@opencode/core": "2.0.9",
|
|
45
|
+
"@opencode/plugin": "2.0.9",
|
|
46
|
+
"@opencode/schema": "2.0.9",
|
|
47
|
+
"@opencode/server": "2.0.9",
|
|
48
|
+
"@opencode/util": "2.0.9",
|
|
49
49
|
"effect": "4.0.0-rc.112"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@opencode/ai": "2.0.
|
|
53
|
-
"@opencode/httpapi-codegen": "2.0.
|
|
54
|
-
"@opencode/protocol": "2.0.
|
|
52
|
+
"@opencode/ai": "2.0.9",
|
|
53
|
+
"@opencode/httpapi-codegen": "2.0.9",
|
|
54
|
+
"@opencode/protocol": "2.0.9",
|
|
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"
|