@opencode-ai/sdk 0.0.0-dev-18474 → 0.0.0-dev-202608280009
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 +11653 -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 -72
- 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 -28
- 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 -14
- 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 -28
- package/dist/internal/host.js +0 -29
- package/dist/internal/workerd.d.ts +0 -54
- 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 -5
- package/dist/opencode.js +0 -2
- package/dist/promise.d.ts +0 -15
- package/dist/promise.js +0 -20
- package/dist/tool.d.ts +0 -3
- package/dist/tool.js +0 -2
- package/dist/workerd.d.ts +0 -25
- package/dist/workerd.js +0 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./client.js";
|
|
2
|
+
export * from "./server.js";
|
|
3
|
+
import type { ServerOptions } from "./server.js";
|
|
4
|
+
export * as data from "./data.js";
|
|
5
|
+
export declare function createOpencode(options?: ServerOptions): Promise<{
|
|
6
|
+
client: import("./client.js").OpencodeClient;
|
|
7
|
+
server: {
|
|
8
|
+
url: string;
|
|
9
|
+
close(): void;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
package/dist/v2/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./client.js";
|
|
2
|
+
export * from "./server.js";
|
|
3
|
+
import { createOpencodeClient } from "./client.js";
|
|
4
|
+
import { createOpencodeServer } from "./server.js";
|
|
5
|
+
export * as data from "./data.js";
|
|
6
|
+
export async function createOpencode(options) {
|
|
7
|
+
const server = await createOpencodeServer({
|
|
8
|
+
...options,
|
|
9
|
+
});
|
|
10
|
+
const client = createOpencodeClient({
|
|
11
|
+
baseUrl: server.url,
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
client,
|
|
15
|
+
server,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Config } from "./gen/types.gen.js";
|
|
2
|
+
export type ServerOptions = {
|
|
3
|
+
hostname?: string;
|
|
4
|
+
port?: number;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
config?: Config;
|
|
8
|
+
};
|
|
9
|
+
export type TuiOptions = {
|
|
10
|
+
project?: string;
|
|
11
|
+
model?: string;
|
|
12
|
+
session?: string;
|
|
13
|
+
agent?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
config?: Config;
|
|
16
|
+
};
|
|
17
|
+
export declare function createOpencodeServer(options?: ServerOptions): Promise<{
|
|
18
|
+
url: string;
|
|
19
|
+
close(): void;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function createOpencodeTui(options?: TuiOptions): {
|
|
22
|
+
close(): void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import launch from "cross-spawn";
|
|
2
|
+
import { stop, bindAbort } from "../process.js";
|
|
3
|
+
export async function createOpencodeServer(options) {
|
|
4
|
+
options = Object.assign({
|
|
5
|
+
hostname: "127.0.0.1",
|
|
6
|
+
port: 4096,
|
|
7
|
+
timeout: 5000,
|
|
8
|
+
}, options ?? {});
|
|
9
|
+
const args = [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`];
|
|
10
|
+
if (options.config?.logLevel)
|
|
11
|
+
args.push(`--log-level=${options.config.logLevel}`);
|
|
12
|
+
const proc = launch(`opencode`, args, {
|
|
13
|
+
env: {
|
|
14
|
+
...process.env,
|
|
15
|
+
OPENCODE_CONFIG_CONTENT: JSON.stringify(options.config ?? {}),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
let clear = () => { };
|
|
19
|
+
const url = await new Promise((resolve, reject) => {
|
|
20
|
+
const id = setTimeout(() => {
|
|
21
|
+
clear();
|
|
22
|
+
stop(proc);
|
|
23
|
+
reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`));
|
|
24
|
+
}, options.timeout);
|
|
25
|
+
let output = "";
|
|
26
|
+
let resolved = false;
|
|
27
|
+
proc.stdout?.on("data", (chunk) => {
|
|
28
|
+
if (resolved)
|
|
29
|
+
return;
|
|
30
|
+
output += chunk.toString();
|
|
31
|
+
const lines = output.split("\n");
|
|
32
|
+
for (const line of lines) {
|
|
33
|
+
if (line.startsWith("opencode server listening")) {
|
|
34
|
+
const match = line.match(/on\s+(https?:\/\/[^\s]+)/);
|
|
35
|
+
if (!match) {
|
|
36
|
+
clear();
|
|
37
|
+
stop(proc);
|
|
38
|
+
clearTimeout(id);
|
|
39
|
+
reject(new Error(`Failed to parse server url from output: ${line}`));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
clearTimeout(id);
|
|
43
|
+
resolved = true;
|
|
44
|
+
resolve(match[1]);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
proc.stderr?.on("data", (chunk) => {
|
|
50
|
+
output += chunk.toString();
|
|
51
|
+
});
|
|
52
|
+
proc.on("exit", (code) => {
|
|
53
|
+
clearTimeout(id);
|
|
54
|
+
let msg = `Server exited with code ${code}`;
|
|
55
|
+
if (output.trim()) {
|
|
56
|
+
msg += `\nServer output: ${output}`;
|
|
57
|
+
}
|
|
58
|
+
reject(new Error(msg));
|
|
59
|
+
});
|
|
60
|
+
proc.on("error", (error) => {
|
|
61
|
+
clearTimeout(id);
|
|
62
|
+
reject(error);
|
|
63
|
+
});
|
|
64
|
+
clear = bindAbort(proc, options.signal, () => {
|
|
65
|
+
clearTimeout(id);
|
|
66
|
+
reject(options.signal?.reason);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
url,
|
|
71
|
+
close() {
|
|
72
|
+
clear();
|
|
73
|
+
stop(proc);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function createOpencodeTui(options) {
|
|
78
|
+
const args = [];
|
|
79
|
+
if (options?.project) {
|
|
80
|
+
args.push(`--project=${options.project}`);
|
|
81
|
+
}
|
|
82
|
+
if (options?.model) {
|
|
83
|
+
args.push(`--model=${options.model}`);
|
|
84
|
+
}
|
|
85
|
+
if (options?.session) {
|
|
86
|
+
args.push(`--session=${options.session}`);
|
|
87
|
+
}
|
|
88
|
+
if (options?.agent) {
|
|
89
|
+
args.push(`--agent=${options.agent}`);
|
|
90
|
+
}
|
|
91
|
+
const proc = launch(`opencode`, args, {
|
|
92
|
+
stdio: "inherit",
|
|
93
|
+
env: {
|
|
94
|
+
...process.env,
|
|
95
|
+
OPENCODE_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}),
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const clear = bindAbort(proc, options?.signal);
|
|
99
|
+
return {
|
|
100
|
+
close() {
|
|
101
|
+
clear();
|
|
102
|
+
stop(proc);
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-18474",
|
|
4
3
|
"name": "@opencode-ai/sdk",
|
|
4
|
+
"version": "0.0.0-dev-202608280009",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
},
|
|
12
|
-
"publishConfig": {
|
|
13
|
-
"access": "public"
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "bun test",
|
|
9
|
+
"typecheck": "tsgo --noEmit",
|
|
10
|
+
"build": "bun ./script/build.ts"
|
|
14
11
|
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
12
|
"exports": {
|
|
19
13
|
".": {
|
|
20
14
|
"import": "./dist/index.js",
|
|
21
15
|
"types": "./dist/index.d.ts"
|
|
22
16
|
},
|
|
23
|
-
"./
|
|
24
|
-
"import": "./dist/
|
|
25
|
-
"types": "./dist/
|
|
17
|
+
"./client": {
|
|
18
|
+
"import": "./dist/client.js",
|
|
19
|
+
"types": "./dist/client.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./server": {
|
|
22
|
+
"import": "./dist/server.js",
|
|
23
|
+
"types": "./dist/server.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./v2": {
|
|
26
|
+
"import": "./dist/v2/index.js",
|
|
27
|
+
"types": "./dist/v2/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./v2/client": {
|
|
30
|
+
"import": "./dist/v2/client.js",
|
|
31
|
+
"types": "./dist/v2/client.d.ts"
|
|
26
32
|
},
|
|
27
|
-
"./
|
|
28
|
-
"import": "./dist/
|
|
29
|
-
"types": "./dist/
|
|
33
|
+
"./v2/gen/client": {
|
|
34
|
+
"import": "./dist/v2/gen/client/index.js",
|
|
35
|
+
"types": "./dist/v2/gen/client/index.d.ts"
|
|
30
36
|
},
|
|
31
|
-
"./
|
|
32
|
-
"import": "./dist/
|
|
33
|
-
"types": "./dist/
|
|
37
|
+
"./v2/server": {
|
|
38
|
+
"import": "./dist/v2/server.js",
|
|
39
|
+
"types": "./dist/v2/server.d.ts"
|
|
40
|
+
},
|
|
41
|
+
"./v2/types": {
|
|
42
|
+
"import": "./dist/v2/gen/types.gen.js",
|
|
43
|
+
"types": "./dist/v2/gen/types.gen.d.ts"
|
|
34
44
|
}
|
|
35
45
|
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
46
|
+
"files": [
|
|
47
|
+
"dist"
|
|
48
|
+
],
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@hey-api/openapi-ts": "0.90.10",
|
|
51
|
+
"@tsconfig/node22": "22.0.2",
|
|
52
|
+
"@types/cross-spawn": "6.0.6",
|
|
53
|
+
"@types/node": "24.12.2",
|
|
54
|
+
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
55
|
+
"typescript": "5.8.2"
|
|
41
56
|
},
|
|
42
57
|
"dependencies": {
|
|
43
|
-
"
|
|
44
|
-
"@opencode-ai/core": "0.0.0-dev-18474",
|
|
45
|
-
"@opencode-ai/plugin": "0.0.0-dev-18474",
|
|
46
|
-
"@opencode-ai/schema": "0.0.0-dev-18474",
|
|
47
|
-
"@opencode-ai/server": "0.0.0-dev-18474",
|
|
48
|
-
"@opencode-ai/util": "0.0.0-dev-18474",
|
|
49
|
-
"effect": "4.0.0-rc.111"
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@opencode-ai/ai": "0.0.0-dev-18474",
|
|
53
|
-
"@opencode-ai/httpapi-codegen": "0.0.0-dev-18474",
|
|
54
|
-
"@opencode-ai/protocol": "0.0.0-dev-18474",
|
|
55
|
-
"@tsconfig/bun": "1.0.9",
|
|
56
|
-
"@types/bun": "1.3.13",
|
|
57
|
-
"@typescript/native-preview": "7.0.0-dev.20251207.1"
|
|
58
|
+
"cross-spawn": "7.0.6"
|
|
58
59
|
}
|
|
59
|
-
}
|
|
60
|
+
}
|
package/README.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# @opencode-ai/sdk
|
|
2
|
-
|
|
3
|
-
In-process OpenCode host for Promise and Effect applications. The SDK executes Server's assembled HTTP router in memory, opening no listener and adding no network hop.
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { OpenCode } from "@opencode-ai/sdk"
|
|
7
|
-
|
|
8
|
-
await using opencode = await OpenCode.create()
|
|
9
|
-
const session = await opencode.sessions.create({
|
|
10
|
-
location: { directory: "/workspace" },
|
|
11
|
-
})
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Pass imported Promise plugins in `plugins`, or register one later with `await opencode.plugin(plugin)`.
|
|
15
|
-
|
|
16
|
-
The Promise API uses the same values, errors, request options, and `AsyncIterable` streams as `@opencode-ai/client`.
|
|
17
|
-
|
|
18
|
-
Embedded hosts are silent by default. Set `log` to receive structured log entries:
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
await using opencode = await OpenCode.create({
|
|
22
|
-
log: {
|
|
23
|
-
level: "warn",
|
|
24
|
-
emit: (entry) => console.error(entry.message, entry.attributes, entry.cause),
|
|
25
|
-
},
|
|
26
|
-
})
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
`close()` and `Symbol.asyncDispose` release router resources, Location services, fibers, and scoped plugin registrations.
|
|
30
|
-
|
|
31
|
-
## Workerd
|
|
32
|
-
|
|
33
|
-
Use the Workerd entrypoint inside a Cloudflare Durable Object. Hold one host for the lifetime of the object instance rather than creating one per request.
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import { OpenCodeWorkerd } from "@opencode-ai/sdk/workerd"
|
|
37
|
-
import myPlugin from "./my-plugin"
|
|
38
|
-
|
|
39
|
-
export class OpenCodeDO {
|
|
40
|
-
private readonly opencode: Promise<OpenCodeWorkerd.Interface>
|
|
41
|
-
|
|
42
|
-
constructor(state: DurableObjectState) {
|
|
43
|
-
this.opencode = state.blockConcurrencyWhile(() =>
|
|
44
|
-
OpenCodeWorkerd.create({
|
|
45
|
-
storage: state.storage,
|
|
46
|
-
config: { default_agent: "build" },
|
|
47
|
-
plugins: [myPlugin],
|
|
48
|
-
}),
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async fetch() {
|
|
53
|
-
const opencode = await this.opencode
|
|
54
|
-
return Response.json(await opencode.health.get())
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
`blockConcurrencyWhile` keeps every Durable Object event out until the host is ready and resets the object if initialization fails. The retained Promise gives request handlers direct access to the same host after startup. Configuration is a typed JavaScript object, and plugins are imported values bundled with the Worker.
|
|
60
|
-
|
|
61
|
-
## Effect
|
|
62
|
-
|
|
63
|
-
The Effect-native API remains available from `@opencode-ai/sdk/effect`:
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
import { OpenCode } from "@opencode-ai/sdk/effect"
|
|
67
|
-
|
|
68
|
-
const opencode = yield * OpenCode.create()
|
|
69
|
-
const session = yield * opencode.sessions.get({ sessionID })
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
The Effect Workerd entrypoint is `@opencode-ai/sdk/workerd/effect`.
|
package/dist/contracts.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export { Agent } from "@opencode-ai/schema/agent";
|
|
2
|
-
export { Command } from "@opencode-ai/schema/command";
|
|
3
|
-
export { Config } from "@opencode-ai/schema/config";
|
|
4
|
-
export { Credential } from "@opencode-ai/schema/credential";
|
|
5
|
-
export { Event } from "@opencode-ai/schema/event";
|
|
6
|
-
export { FileSystem } from "@opencode-ai/schema/filesystem";
|
|
7
|
-
export { Integration } from "@opencode-ai/schema/integration";
|
|
8
|
-
export { Location } from "@opencode-ai/schema/location";
|
|
9
|
-
export { Model } from "@opencode-ai/schema/model";
|
|
10
|
-
export { Permission } from "@opencode-ai/schema/permission";
|
|
11
|
-
export { PermissionSaved } from "@opencode-ai/schema/permission-saved";
|
|
12
|
-
export { Project } from "@opencode-ai/schema/project";
|
|
13
|
-
export { Worktree } from "@opencode-ai/schema/worktree";
|
|
14
|
-
export { Prompt } from "@opencode-ai/schema/prompt";
|
|
15
|
-
export { PromptInput } from "@opencode-ai/schema/prompt-input";
|
|
16
|
-
export { Provider } from "@opencode-ai/schema/provider";
|
|
17
|
-
export { Pty } from "@opencode-ai/schema/pty";
|
|
18
|
-
export { Question } from "@opencode-ai/schema/question";
|
|
19
|
-
export { Reference } from "@opencode-ai/schema/reference";
|
|
20
|
-
export { WebSearch } from "@opencode-ai/schema/websearch";
|
|
21
|
-
export { AbsolutePath, RelativePath } from "@opencode-ai/schema/schema";
|
|
22
|
-
export { Session } from "@opencode-ai/schema/session";
|
|
23
|
-
export { SessionInbox } from "@opencode-ai/schema/session-inbox";
|
|
24
|
-
export { SessionMessage } from "@opencode-ai/schema/session-message";
|
|
25
|
-
export { Skill } from "@opencode-ai/schema/skill";
|
|
26
|
-
export { Workspace } from "@opencode-ai/schema/workspace";
|
package/dist/contracts.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export { Agent } from "@opencode-ai/schema/agent";
|
|
2
|
-
export { Command } from "@opencode-ai/schema/command";
|
|
3
|
-
export { Config } from "@opencode-ai/schema/config";
|
|
4
|
-
export { Credential } from "@opencode-ai/schema/credential";
|
|
5
|
-
export { Event } from "@opencode-ai/schema/event";
|
|
6
|
-
export { FileSystem } from "@opencode-ai/schema/filesystem";
|
|
7
|
-
export { Integration } from "@opencode-ai/schema/integration";
|
|
8
|
-
export { Location } from "@opencode-ai/schema/location";
|
|
9
|
-
export { Model } from "@opencode-ai/schema/model";
|
|
10
|
-
export { Permission } from "@opencode-ai/schema/permission";
|
|
11
|
-
export { PermissionSaved } from "@opencode-ai/schema/permission-saved";
|
|
12
|
-
export { Project } from "@opencode-ai/schema/project";
|
|
13
|
-
export { Worktree } from "@opencode-ai/schema/worktree";
|
|
14
|
-
export { Prompt } from "@opencode-ai/schema/prompt";
|
|
15
|
-
export { PromptInput } from "@opencode-ai/schema/prompt-input";
|
|
16
|
-
export { Provider } from "@opencode-ai/schema/provider";
|
|
17
|
-
export { Pty } from "@opencode-ai/schema/pty";
|
|
18
|
-
export { Question } from "@opencode-ai/schema/question";
|
|
19
|
-
export { Reference } from "@opencode-ai/schema/reference";
|
|
20
|
-
export { WebSearch } from "@opencode-ai/schema/websearch";
|
|
21
|
-
export { AbsolutePath, RelativePath } from "@opencode-ai/schema/schema";
|
|
22
|
-
export { Session } from "@opencode-ai/schema/session";
|
|
23
|
-
export { SessionInbox } from "@opencode-ai/schema/session-inbox";
|
|
24
|
-
export { SessionMessage } from "@opencode-ai/schema/session-message";
|
|
25
|
-
export { Skill } from "@opencode-ai/schema/skill";
|
|
26
|
-
export { Workspace } from "@opencode-ai/schema/workspace";
|
package/dist/effect/index.d.ts
DELETED
package/dist/effect/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * as OpenCode from "./opencode";
|
|
2
|
-
import { type OpenCodeClient } from "@opencode-ai/client/effect";
|
|
3
|
-
import type { Workspace } from "@opencode-ai/core/workspace";
|
|
4
|
-
import { Context, Effect, Layer } from "effect";
|
|
5
|
-
import type { Config, Scope } from "effect";
|
|
6
|
-
import { EmbeddedHost } from "../internal/host";
|
|
7
|
-
export type { LogEntry, LogLevel, LogOptions, LogWriter } from "../logging";
|
|
8
|
-
export type CreateOptions = EmbeddedHost.CreateOptions;
|
|
9
|
-
export type EmbedOptions = EmbeddedHost.EmbedOptions;
|
|
10
|
-
export type Interface = Omit<OpenCodeClient, "plugin" | "workspace"> & {
|
|
11
|
-
readonly sessions: OpenCodeClient["session"];
|
|
12
|
-
readonly events: OpenCodeClient["event"];
|
|
13
|
-
readonly workspace: {
|
|
14
|
-
readonly create: Workspace.Interface["create"];
|
|
15
|
-
readonly provision: (options: {
|
|
16
|
-
readonly workspaceID: Workspace.ID;
|
|
17
|
-
}) => ReturnType<Workspace.Interface["provision"]>;
|
|
18
|
-
readonly destroy: (options: {
|
|
19
|
-
readonly workspaceID: Workspace.ID;
|
|
20
|
-
}) => ReturnType<Workspace.Interface["destroy"]>;
|
|
21
|
-
};
|
|
22
|
-
readonly plugin: EmbeddedHost.Interface["plugins"]["register"] & OpenCodeClient["plugin"];
|
|
23
|
-
};
|
|
24
|
-
export declare const create: (options?: CreateOptions, embed?: EmbedOptions) => Effect.Effect<Interface, Config.ConfigError | Error, Scope.Scope>;
|
|
25
|
-
declare const Service_base: Context.ServiceClass<Service, "@opencode-ai/sdk/OpenCode", Interface>;
|
|
26
|
-
export declare class Service extends Service_base {
|
|
27
|
-
}
|
|
28
|
-
export declare const layer: (options?: CreateOptions) => Layer.Layer<Service, Config.ConfigError | Error>;
|
package/dist/effect/opencode.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export * as OpenCode from "./opencode";
|
|
2
|
-
import { OpenCode } from "@opencode-ai/client/effect";
|
|
3
|
-
import { Context, Effect, Layer } from "effect";
|
|
4
|
-
import { FetchHttpClient } 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)), client = yield* OpenCode.make({ baseUrl: "http://opencode.local" }).pipe(Effect.provide(FetchHttpClient.layer.pipe(Layer.provide(Layer.succeed(FetchHttpClient.Fetch, host.fetch)), Layer.fresh)));
|
|
8
|
-
return {
|
|
9
|
-
...client,
|
|
10
|
-
sessions: client.session,
|
|
11
|
-
events: client.event,
|
|
12
|
-
workspace: {
|
|
13
|
-
create: host.workspace.create,
|
|
14
|
-
provision: ({ workspaceID }) => host.workspace.provision(workspaceID),
|
|
15
|
-
destroy: ({ workspaceID }) => host.workspace.destroy(workspaceID)
|
|
16
|
-
},
|
|
17
|
-
plugin: Object.assign(host.plugins.register, client.plugin)
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export class Service extends Context.Service()("@opencode-ai/sdk/OpenCode") {
|
|
22
|
-
}
|
|
23
|
-
export const layer = (options = {}) => Layer.effect(Service, create(options));
|
package/dist/effect/tool.d.ts
DELETED
package/dist/effect/tool.js
DELETED
package/dist/effect/workerd.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * as OpenCodeWorkerd from "./workerd";
|
|
2
|
-
import { Layer } from "effect";
|
|
3
|
-
import type { Config, Scope } from "effect";
|
|
4
|
-
import { WorkerdProfile } from "../internal/workerd";
|
|
5
|
-
import { OpenCode } from "./opencode";
|
|
6
|
-
export type Configuration = WorkerdProfile.Configuration;
|
|
7
|
-
export interface CreateOptions extends WorkerdProfile.Options {
|
|
8
|
-
readonly log?: OpenCode.CreateOptions["log"];
|
|
9
|
-
readonly workspaceProviders?: OpenCode.CreateOptions["workspaceProviders"];
|
|
10
|
-
}
|
|
11
|
-
export declare const create: ({ log, workspaceProviders, ...options }: CreateOptions) => import("effect/Effect").Effect<OpenCode.Interface, Error | Config.ConfigError, Scope.Scope>;
|
|
12
|
-
export declare const layer: (options: CreateOptions) => Layer.Layer<OpenCode.Service, Config.ConfigError | Error>;
|
|
13
|
-
export type Interface = OpenCode.Interface;
|
|
14
|
-
export type Requirements = Scope.Scope;
|
package/dist/effect/workerd.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * as OpenCodeWorkerd from "./workerd";
|
|
2
|
-
import { Layer } from "effect";
|
|
3
|
-
import { WorkerdProfile } from "../internal/workerd";
|
|
4
|
-
import { OpenCode } from "./opencode";
|
|
5
|
-
export const create = ({ log, workspaceProviders, ...options }) => {
|
|
6
|
-
const profile = WorkerdProfile.make(options);
|
|
7
|
-
return OpenCode.create({ ...profile.options, log, workspaceProviders }, { overrides: profile.replacements });
|
|
8
|
-
}, layer = (options) => Layer.effect(OpenCode.Service, create(options));
|
package/dist/internal/fetch.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * as OwnedFetch from "./fetch";
|
|
2
|
-
export declare function make(handler: (request: Request) => Promise<Response>, dispose: () => Promise<void>): {
|
|
3
|
-
fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & {
|
|
4
|
-
preconnect: () => undefined;
|
|
5
|
-
};
|
|
6
|
-
close: () => Promise<void>;
|
|
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,28 +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
|
-
export interface CreateOptions extends Omit<ServerOptions, "hostname" | "port" | "password"> {
|
|
12
|
-
readonly log?: LogOptions;
|
|
13
|
-
readonly workspaceProviders?: Readonly<Record<string, WorkspaceDriver.Interface>>;
|
|
14
|
-
}
|
|
15
|
-
/** Host hooks for embedding opencode on a non-default runtime profile. */
|
|
16
|
-
export interface EmbedOptions {
|
|
17
|
-
readonly overrides?: LayerNode.Replacements;
|
|
18
|
-
}
|
|
19
|
-
export declare const create: (options?: CreateOptions | undefined, embed?: EmbedOptions | undefined) => Effect.Effect<{
|
|
20
|
-
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/credential").Service | import("@opencode-ai/core/bus").Service | import("@opencode-ai/core/wellknown").Service | Workspace.Service | import("@opencode-ai/core/job").Service | import("@opencode-ai/core/permission/saved").Service | SdkPlugins.Service | import("@opencode-ai/core/worktree").Service | import("@opencode-ai/core/project").Service | import("@opencode-ai/core/location-service-map").Service | import("@opencode-ai/core/session").Service | SessionRestart.Service | import("@opencode-ai/core/pty/ticket").Service | import("@opencode-ai/core/persistent-pty/index").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>;
|
|
21
|
-
fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & {
|
|
22
|
-
preconnect: () => undefined;
|
|
23
|
-
};
|
|
24
|
-
plugins: SdkPlugins.Interface;
|
|
25
|
-
workspace: Workspace.Interface;
|
|
26
|
-
close: () => Promise<void>;
|
|
27
|
-
}, Error | import("@opencode-ai/core/persistent-pty/index").UnavailableError, never>;
|
|
28
|
-
export type Interface = Effect.Success<ReturnType<typeof create>>;
|