@opencode-ai/server 0.0.0-dev-17880
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/api.d.ts +7528 -0
- package/dist/api.js +9 -0
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +17 -0
- package/dist/cors.d.ts +7 -0
- package/dist/cors.js +36 -0
- package/dist/event-feed.d.ts +32 -0
- package/dist/event-feed.js +60 -0
- package/dist/fetch.d.ts +68 -0
- package/dist/fetch.js +11 -0
- package/dist/handlers/agent.d.ts +1 -0
- package/dist/handlers/agent.js +17 -0
- package/dist/handlers/command.d.ts +1 -0
- package/dist/handlers/command.js +5 -0
- package/dist/handlers/config.d.ts +1 -0
- package/dist/handlers/config.js +4 -0
- package/dist/handlers/credential.d.ts +1 -0
- package/dist/handlers/credential.js +11 -0
- package/dist/handlers/debug.d.ts +1 -0
- package/dist/handlers/debug.js +11 -0
- package/dist/handlers/event.d.ts +2 -0
- package/dist/handlers/event.js +27 -0
- package/dist/handlers/form.d.ts +1 -0
- package/dist/handlers/form.js +57 -0
- package/dist/handlers/fs.d.ts +1 -0
- package/dist/handlers/fs.js +19 -0
- package/dist/handlers/generate.d.ts +1 -0
- package/dist/handlers/generate.js +10 -0
- package/dist/handlers/health.d.ts +2 -0
- package/dist/handlers/health.js +11 -0
- package/dist/handlers/integration.d.ts +2 -0
- package/dist/handlers/integration.js +83 -0
- package/dist/handlers/location.d.ts +1 -0
- package/dist/handlers/location.js +12 -0
- package/dist/handlers/mcp.d.ts +1 -0
- package/dist/handlers/mcp.js +31 -0
- package/dist/handlers/message.d.ts +2 -0
- package/dist/handlers/message.js +42 -0
- package/dist/handlers/migration.d.ts +1 -0
- package/dist/handlers/migration.js +7 -0
- package/dist/handlers/model.d.ts +1 -0
- package/dist/handlers/model.js +22 -0
- package/dist/handlers/permission.d.ts +2 -0
- package/dist/handlers/permission.js +56 -0
- package/dist/handlers/plugin-readiness.d.ts +4 -0
- package/dist/handlers/plugin-readiness.js +9 -0
- package/dist/handlers/plugin.d.ts +1 -0
- package/dist/handlers/plugin.js +8 -0
- package/dist/handlers/project.d.ts +2 -0
- package/dist/handlers/project.js +10 -0
- package/dist/handlers/provider.d.ts +1 -0
- package/dist/handlers/provider.js +20 -0
- package/dist/handlers/pty.d.ts +3 -0
- package/dist/handlers/pty.js +109 -0
- package/dist/handlers/reference.d.ts +1 -0
- package/dist/handlers/reference.js +5 -0
- package/dist/handlers/server.d.ts +2 -0
- package/dist/handlers/server.js +7 -0
- package/dist/handlers/session-error.d.ts +5 -0
- package/dist/handlers/session-error.js +13 -0
- package/dist/handlers/session.d.ts +3 -0
- package/dist/handlers/session.js +275 -0
- package/dist/handlers/shell.d.ts +1 -0
- package/dist/handlers/shell.js +30 -0
- package/dist/handlers/skill.d.ts +1 -0
- package/dist/handlers/skill.js +5 -0
- package/dist/handlers/vcs.d.ts +1 -0
- package/dist/handlers/vcs.js +14 -0
- package/dist/handlers/websearch.d.ts +1 -0
- package/dist/handlers/websearch.js +38 -0
- package/dist/handlers/worktree.d.ts +2 -0
- package/dist/handlers/worktree.js +32 -0
- package/dist/handlers.d.ts +2 -0
- package/dist/handlers.js +32 -0
- package/dist/location.d.ts +23 -0
- package/dist/location.js +44 -0
- package/dist/middleware/authorization.d.ts +7 -0
- package/dist/middleware/authorization.js +48 -0
- package/dist/middleware/form-location.d.ts +18 -0
- package/dist/middleware/form-location.js +42 -0
- package/dist/middleware/schema-error.d.ts +3 -0
- package/dist/middleware/schema-error.js +15 -0
- package/dist/middleware/session-location.d.ts +18 -0
- package/dist/middleware/session-location.js +36 -0
- package/dist/options.d.ts +38 -0
- package/dist/options.js +32 -0
- package/dist/process.d.ts +47 -0
- package/dist/process.js +115 -0
- package/dist/pty-environment.d.ts +13 -0
- package/dist/pty-environment.js +9 -0
- package/dist/request-tracing.d.ts +2 -0
- package/dist/request-tracing.js +2 -0
- package/dist/routes.d.ts +23 -0
- package/dist/routes.js +112 -0
- package/dist/server-info.d.ts +11 -0
- package/dist/server-info.js +22 -0
- package/dist/service-status.d.ts +25 -0
- package/dist/service-status.js +11 -0
- package/dist/workerd.d.ts +45 -0
- package/dist/workerd.js +57 -0
- package/package.json +45 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * as Status from "./service-status";
|
|
2
|
+
import { Effect, Ref } from "effect";
|
|
3
|
+
export const make = Effect.fnUntraced(function* (options = {}) {
|
|
4
|
+
const current = yield* Ref.make(options.initial ?? { type: "starting" }), beginStopping = Ref.update(current, (status) => status.type === "stopping" ? status : { type: "stopping" });
|
|
5
|
+
return {
|
|
6
|
+
current: Ref.get(current),
|
|
7
|
+
ready: Ref.update(current, (status) => status.type === "starting" ? { type: "ready" } : status),
|
|
8
|
+
fail: Ref.update(current, (status) => status.type === "starting" ? { type: "failed" } : status),
|
|
9
|
+
beginStopping
|
|
10
|
+
};
|
|
11
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export * as ServerWorkerd from "./workerd";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import type { DurableObjectStorage } from "@opencode-ai/core/database/sqlite.workerd";
|
|
4
|
+
import type { LayerNode } from "@opencode-ai/util/effect/layer-node";
|
|
5
|
+
import type { ServerOptions } from "./options";
|
|
6
|
+
/**
|
|
7
|
+
* The workerd runtime profile: boots opencode core and server inside a
|
|
8
|
+
* Cloudflare Durable Object, with every intentionally-local service replaced
|
|
9
|
+
* or disabled.
|
|
10
|
+
*
|
|
11
|
+
* - Database runs on the injected `DurableObjectStorage` SQLite.
|
|
12
|
+
* - Watcher and fff are disabled through their existing option flags; pty, fff,
|
|
13
|
+
* shell-parser, photon, and process-lock native modules resolve to inert
|
|
14
|
+
* stubs under the `workerd` bundle condition.
|
|
15
|
+
* - Bare locations use a typed no-execution-plane process spawner; FileSystem,
|
|
16
|
+
* FileSystemSearch, and Pty fail with a clear defect until a remote sandbox
|
|
17
|
+
* backs them; Snapshot and Vcs degrade to no-op results.
|
|
18
|
+
* - Config is injected as a string (no filesystem); plugin discovery is
|
|
19
|
+
* precompiled-only, and stdio MCP reports the same no-plane failure as Shell.
|
|
20
|
+
*
|
|
21
|
+
* Bundle with the `workerd` condition, e.g.
|
|
22
|
+
* `bun build src/workerd.ts --conditions=workerd --target=node`
|
|
23
|
+
* (see `script/workerd-probe.ts`).
|
|
24
|
+
*/
|
|
25
|
+
export interface Options {
|
|
26
|
+
/** Durable Object storage whose SQLite database backs the opencode database. */
|
|
27
|
+
readonly storage: DurableObjectStorage;
|
|
28
|
+
readonly app?: ServerOptions["app"];
|
|
29
|
+
readonly password?: string;
|
|
30
|
+
/** Inline opencode config content (JSON), same as `ServerOptions.config.content`. */
|
|
31
|
+
readonly config?: {
|
|
32
|
+
readonly content?: string;
|
|
33
|
+
};
|
|
34
|
+
/** models.dev catalog options; the bundled snapshot is the boot-time floor either way. */
|
|
35
|
+
readonly models?: ServerOptions["models"];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Builds the web-standard fetch handler for a Durable Object's `fetch()`. The
|
|
39
|
+
* application layer builds eagerly in the caller's scope, so hold it in the
|
|
40
|
+
* Durable Object instance rather than per request.
|
|
41
|
+
*/
|
|
42
|
+
export declare function create(options: Options): Effect.Effect<(request: Request, context?: import("effect/Context").Context<never> | undefined) => Promise<globalThis.Response>, Error, import("effect/Scope").Scope>;
|
|
43
|
+
export declare function serverOptions(options: Options): ServerOptions;
|
|
44
|
+
/** The workerd replacement graph, applied after the standard server replacements. */
|
|
45
|
+
export declare function replacements(options: Options): LayerNode.Replacements;
|
package/dist/workerd.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export * as ServerWorkerd from "./workerd";
|
|
2
|
+
import { Effect, Layer } from "effect";
|
|
3
|
+
import { ConfigPluginSource } from "@opencode-ai/core/config/plugin/source";
|
|
4
|
+
import { Database } from "@opencode-ai/core/database/database";
|
|
5
|
+
import { sqliteLayer } from "@opencode-ai/core/database/sqlite.workerd";
|
|
6
|
+
import { EnvironmentUnavailable } from "@opencode-ai/core/environment/unavailable";
|
|
7
|
+
import { FileSystem } from "@opencode-ai/core/filesystem";
|
|
8
|
+
import { FileSystemSearch } from "@opencode-ai/core/filesystem/search";
|
|
9
|
+
import { Pty } from "@opencode-ai/core/pty";
|
|
10
|
+
import { Snapshot } from "@opencode-ai/core/snapshot";
|
|
11
|
+
import { Vcs } from "@opencode-ai/core/vcs";
|
|
12
|
+
import { CrossSpawnSpawner } from "@opencode-ai/util/cross-spawn-spawner";
|
|
13
|
+
import { ServerFetch } from "./fetch";
|
|
14
|
+
export function create(options) {
|
|
15
|
+
return ServerFetch.make(serverOptions(options), { overrides: replacements(options) });
|
|
16
|
+
}
|
|
17
|
+
export function serverOptions(options) {
|
|
18
|
+
return {
|
|
19
|
+
app: options.app,
|
|
20
|
+
password: options.password,
|
|
21
|
+
fs: { filewatcher: !1, fff: !1 },
|
|
22
|
+
events: { persist: !0 },
|
|
23
|
+
config: { content: options.config?.content },
|
|
24
|
+
models: options.models
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function replacements(options) {
|
|
28
|
+
return [
|
|
29
|
+
[Database.node, Database.configuredClient(sqliteLayer({ storage: options.storage }))],
|
|
30
|
+
[CrossSpawnSpawner.node, EnvironmentUnavailable.layer],
|
|
31
|
+
[Snapshot.node, Snapshot.noopLayer],
|
|
32
|
+
[Vcs.node, vcsLayer],
|
|
33
|
+
[FileSystem.node, fileSystemLayer],
|
|
34
|
+
[FileSystemSearch.node, fileSystemSearchLayer],
|
|
35
|
+
[Pty.node, ptyLayer],
|
|
36
|
+
[ConfigPluginSource.node, ConfigPluginSource.empty]
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
const unavailable = (what) => Effect.die(Error(`${what} is unavailable in the workerd profile`)), vcsLayer = Layer.succeed(Vcs.Service, Vcs.Service.of({
|
|
40
|
+
info: () => Effect.succeed({ branch: {} }),
|
|
41
|
+
status: () => Effect.succeed([]),
|
|
42
|
+
diff: () => Effect.succeed([])
|
|
43
|
+
})), fileSystemLayer = Layer.succeed(FileSystem.Service, FileSystem.Service.of({
|
|
44
|
+
read: () => unavailable("FileSystem.read"),
|
|
45
|
+
list: () => unavailable("FileSystem.list"),
|
|
46
|
+
find: () => unavailable("FileSystem.find")
|
|
47
|
+
})), fileSystemSearchLayer = Layer.succeed(FileSystemSearch.Service, FileSystemSearch.Service.of({
|
|
48
|
+
find: () => unavailable("FileSystemSearch.find")
|
|
49
|
+
})), ptyLayer = Layer.succeed(Pty.Service, Pty.Service.of({
|
|
50
|
+
list: () => Effect.succeed([]),
|
|
51
|
+
get: (ptyID) => Effect.fail(new Pty.NotFoundError({ ptyID })),
|
|
52
|
+
create: () => unavailable("Pty.create"),
|
|
53
|
+
update: (ptyID) => Effect.fail(new Pty.NotFoundError({ ptyID })),
|
|
54
|
+
remove: (ptyID) => Effect.fail(new Pty.NotFoundError({ ptyID })),
|
|
55
|
+
write: (ptyID) => Effect.fail(new Pty.NotFoundError({ ptyID })),
|
|
56
|
+
attach: (ptyID) => Effect.fail(new Pty.NotFoundError({ ptyID }))
|
|
57
|
+
}));
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@opencode-ai/server",
|
|
4
|
+
"version": "0.0.0-dev-17880",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/anomalyco/opencode.git",
|
|
10
|
+
"directory": "packages/server"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
"./*": {
|
|
20
|
+
"import": "./dist/*.js",
|
|
21
|
+
"types": "./dist/*.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "bun run script/build.ts",
|
|
26
|
+
"test": "bun test --only-failures",
|
|
27
|
+
"typecheck": "tsgo -b",
|
|
28
|
+
"probe:workerd": "bun run script/workerd-probe.ts"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@effect/platform-node": "4.0.0-rc.110",
|
|
32
|
+
"@opencode-ai/core": "0.0.0-dev-17880",
|
|
33
|
+
"@opencode-ai/protocol": "0.0.0-dev-17880",
|
|
34
|
+
"@opencode-ai/schema": "0.0.0-dev-17880",
|
|
35
|
+
"@opencode-ai/simulation": "0.0.0-dev-17880",
|
|
36
|
+
"@opencode-ai/util": "0.0.0-dev-17880",
|
|
37
|
+
"drizzle-orm": "1.0.0-rc.2",
|
|
38
|
+
"effect": "4.0.0-rc.110"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@tsconfig/bun": "1.0.9",
|
|
42
|
+
"@types/bun": "1.3.13",
|
|
43
|
+
"@typescript/native-preview": "7.0.0-dev.20251207.1"
|
|
44
|
+
}
|
|
45
|
+
}
|