@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31
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/CHANGELOG.md +238 -0
- package/README.md +739 -116
- package/dist/adapters.d.ts +35 -6
- package/dist/adapters.js +152 -26
- package/dist/agents.d.ts +18 -7
- package/dist/agents.js +19 -10
- package/dist/app.js +101 -26
- package/dist/background.d.ts +29 -0
- package/dist/background.js +397 -0
- package/dist/box-egress-vm.d.ts +125 -0
- package/dist/box-egress-vm.js +350 -0
- package/dist/box-egress.d.ts +99 -0
- package/dist/box-egress.js +259 -0
- package/dist/box-image.d.ts +1 -1
- package/dist/box-image.js +9 -7
- package/dist/box-relay-vm.d.ts +84 -0
- package/dist/box-relay-vm.js +410 -0
- package/dist/box-relay.d.ts +8 -5
- package/dist/box-relay.js +14 -9
- package/dist/boxes.d.ts +28 -5
- package/dist/boxes.js +44 -18
- package/dist/browser-cost.d.ts +41 -0
- package/dist/browser-cost.js +158 -0
- package/dist/cap.d.ts +130 -21
- package/dist/cap.js +339 -67
- package/dist/cli.js +30 -4
- package/dist/coding-tools.d.ts +7 -3
- package/dist/coding-tools.js +16 -10
- package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
- package/dist/console/assets/index-CnJBf7Lc.js +486 -0
- package/dist/console/assets/index-DUHbWcIP.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-rows.d.ts +11 -3
- package/dist/decision-rows.js +18 -11
- package/dist/decisions.d.ts +3 -3
- package/dist/decisions.js +4 -3
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -2
- package/dist/files.d.ts +9 -1
- package/dist/files.js +10 -2
- package/dist/grade.d.ts +11 -11
- package/dist/grade.js +43 -55
- package/dist/graph-served.d.ts +23 -0
- package/dist/graph-served.js +75 -0
- package/dist/graph-view.d.ts +7 -5
- package/dist/graph-view.js +10 -3
- package/dist/harness-app.d.ts +4 -2
- package/dist/harness-app.js +110 -19
- package/dist/harness-opencode/adapter.d.ts +45 -0
- package/dist/harness-opencode/adapter.js +272 -0
- package/dist/harness-opencode/binary.d.ts +18 -0
- package/dist/harness-opencode/binary.js +87 -0
- package/dist/harness-opencode/config.d.ts +24 -0
- package/dist/harness-opencode/config.js +61 -0
- package/dist/harness-opencode/harness.d.ts +77 -0
- package/dist/harness-opencode/harness.js +620 -0
- package/dist/harness-opencode/host/mcp.d.ts +40 -0
- package/dist/harness-opencode/host/mcp.js +208 -0
- package/dist/harness-opencode/host/policy.d.ts +71 -0
- package/dist/harness-opencode/host/policy.js +419 -0
- package/dist/harness-opencode/host/server.d.ts +55 -0
- package/dist/harness-opencode/host/server.js +165 -0
- package/dist/harness-opencode/index.d.ts +9 -0
- package/dist/harness-opencode/index.js +6 -0
- package/dist/harness-opencode/verify.d.ts +32 -0
- package/dist/harness-opencode/verify.js +75 -0
- package/dist/harness-opencode/versions.d.ts +33 -0
- package/dist/harness-opencode/versions.js +64 -0
- package/dist/harness.d.ts +4 -1
- package/dist/harness.js +5 -2
- package/dist/host-check.d.ts +12 -0
- package/dist/host-check.js +34 -0
- package/dist/host-tools.d.ts +12 -2
- package/dist/host-tools.js +26 -12
- package/dist/host.js +6 -2
- package/dist/hosted-search.js +5 -1
- package/dist/import.d.ts +2 -2
- package/dist/import.js +4 -3
- package/dist/key-check.d.ts +3 -2
- package/dist/key-check.js +7 -3
- package/dist/key-refusal.js +8 -4
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/check.d.ts +10 -1
- package/dist/learn/check.js +19 -1
- package/dist/learn/grade.d.ts +6 -2
- package/dist/learn/grade.js +28 -14
- package/dist/learn/index.d.ts +3 -3
- package/dist/learn/index.js +3 -3
- package/dist/learn/notes.js +2 -1
- package/dist/learn/reflect.d.ts +2 -2
- package/dist/learn/reflect.js +53 -5
- package/dist/learn/secrets.js +28 -8
- package/dist/learn/skills.d.ts +19 -4
- package/dist/learn/skills.js +95 -6
- package/dist/learned-workflow.d.ts +59 -0
- package/dist/learned-workflow.js +191 -0
- package/dist/learning-routes.d.ts +30 -1
- package/dist/learning-routes.js +173 -19
- package/dist/learning-run.d.ts +8 -6
- package/dist/learning-run.js +70 -27
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +34 -13
- package/dist/learning.d.ts +52 -3
- package/dist/learning.js +204 -4
- package/dist/mcp-gateway.d.ts +96 -0
- package/dist/mcp-gateway.js +408 -0
- package/dist/mcp-meta.d.ts +17 -0
- package/dist/mcp-meta.js +38 -0
- package/dist/mcp-servers.d.ts +33 -9
- package/dist/mcp-servers.js +58 -10
- package/dist/mcp.js +5 -5
- package/dist/model.d.ts +13 -11
- package/dist/model.js +11 -10
- package/dist/openapi/agentrun-v2.openapi.json +1 -0
- package/dist/openapi.js +407 -54
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -0
- package/dist/paid-calls.d.ts +5 -1
- package/dist/paid-calls.js +1 -1
- package/dist/pause.d.ts +2 -0
- package/dist/place.d.ts +29 -5
- package/dist/place.js +51 -11
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +38 -8
- package/dist/request-start.d.ts +12 -4
- package/dist/request-start.js +139 -15
- package/dist/run-box.d.ts +56 -4
- package/dist/run-box.js +183 -23
- package/dist/runnable.d.ts +13 -3
- package/dist/runnable.js +63 -6
- package/dist/runs.d.ts +266 -37
- package/dist/runs.js +884 -90
- package/dist/secrets.d.ts +27 -0
- package/dist/secrets.js +38 -2
- package/dist/server.d.ts +141 -36
- package/dist/server.js +562 -118
- package/dist/sign-ins.d.ts +99 -0
- package/dist/sign-ins.js +288 -0
- package/dist/skills.d.ts +16 -4
- package/dist/skills.js +35 -7
- package/dist/stats.d.ts +7 -2
- package/dist/stats.js +28 -7
- package/dist/tool-gate.d.ts +281 -0
- package/dist/tool-gate.js +585 -0
- package/dist/tool-keys.d.ts +48 -11
- package/dist/tool-keys.js +46 -8
- package/dist/tool-plane.d.ts +116 -27
- package/dist/tool-plane.js +232 -50
- package/dist/tools.d.ts +69 -14
- package/dist/tools.js +148 -26
- package/dist/trigger-secrets.d.ts +32 -0
- package/dist/trigger-secrets.js +143 -0
- package/dist/triggers.d.ts +439 -0
- package/dist/triggers.js +863 -0
- package/dist/turn-end.d.ts +3 -2
- package/dist/turn-end.js +3 -2
- package/dist/usage-lines.d.ts +26 -0
- package/dist/usage-lines.js +28 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +11 -2
- package/dist/web-fetch.js +3 -3
- package/dist/webhooks.d.ts +11 -4
- package/dist/webhooks.js +17 -1
- package/launcher/agentrun-serve +1 -1
- package/package.json +16 -14
- package/dist/console/assets/index-BN7oVcO4.js +0 -445
- package/dist/console/assets/index-By-jkqki.css +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Where this machine's pinned OpenCode binary is. Written for AgentRun.
|
|
2
|
+
//
|
|
3
|
+
// `opencode-ai` is a small launcher plus one optional npm package per platform (`opencode-<platform>-<arch>`, with
|
|
4
|
+
// `-baseline` builds for x64 CPUs without AVX2 and `-musl` builds for musl Linux), each carrying the native binary at
|
|
5
|
+
// `bin/opencode` (`bin/opencode.exe` on Windows). The launcher's own postinstall links one of them to its `bin`, but an
|
|
6
|
+
// install with scripts off (`npm ci --ignore-scripts`) leaves that link a stub, so the platform package is found here
|
|
7
|
+
// directly, in the order the launcher's postinstall tries them.
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import { env } from "node:process";
|
|
12
|
+
/** The OpenCode version this package is built and tested against (`opencode --version` prints it). */
|
|
13
|
+
export const OPENCODE_VERSION = "1.19.5";
|
|
14
|
+
const PLATFORMS = { darwin: "darwin", linux: "linux", win32: "windows" };
|
|
15
|
+
/** Whether this x64 CPU has AVX2 (the non-baseline builds need it); true where it cannot be read. */
|
|
16
|
+
function avx2() {
|
|
17
|
+
if (process.platform !== "linux")
|
|
18
|
+
return true;
|
|
19
|
+
try {
|
|
20
|
+
return /\bavx2\b/.test(readFileSync("/proc/cpuinfo", "utf8"));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Whether this Linux runs on musl rather than glibc. */
|
|
27
|
+
function musl() {
|
|
28
|
+
const header = process.report?.getReport?.()?.header;
|
|
29
|
+
return process.platform === "linux" && !header?.glibcVersionRuntime;
|
|
30
|
+
}
|
|
31
|
+
/** The platform packages that may carry this machine's binary, most fitting first; none on a platform OpenCode does not
|
|
32
|
+
* ship. */
|
|
33
|
+
export function openCodePackages(platform = process.platform, arch = process.arch) {
|
|
34
|
+
const os = PLATFORMS[platform];
|
|
35
|
+
if (!os || (arch !== "x64" && arch !== "arm64"))
|
|
36
|
+
return [];
|
|
37
|
+
const base = `opencode-${os}-${arch}`;
|
|
38
|
+
if (os === "linux") {
|
|
39
|
+
const libc = musl() ? [`${base}-musl`, ...(arch === "x64" ? [`${base}-baseline-musl`] : [])] : [base, ...(arch === "x64" ? [`${base}-baseline`] : [])];
|
|
40
|
+
return arch === "x64" && !avx2() ? [...libc].reverse() : libc;
|
|
41
|
+
}
|
|
42
|
+
if (arch === "x64")
|
|
43
|
+
return avx2() ? [base, `${base}-baseline`] : [`${base}-baseline`, base];
|
|
44
|
+
return [base];
|
|
45
|
+
}
|
|
46
|
+
/** The binary's name inside a platform package. */
|
|
47
|
+
const binName = (platform = process.platform) => (platform === "win32" ? "opencode.exe" : "opencode");
|
|
48
|
+
/**
|
|
49
|
+
* The binary to run, the platform package it came from and that package's version, or `undefined` if none is installed:
|
|
50
|
+
*
|
|
51
|
+
* 1. `OPENCODE_BIN`;
|
|
52
|
+
* 2. the first platform package (`openCodePackages`) installed next to the `opencode-ai` this package depends on.
|
|
53
|
+
*/
|
|
54
|
+
export function findOpenCode() {
|
|
55
|
+
if (env.OPENCODE_BIN)
|
|
56
|
+
return { path: env.OPENCODE_BIN };
|
|
57
|
+
let launcher;
|
|
58
|
+
try {
|
|
59
|
+
launcher = dirname(createRequire(import.meta.url).resolve("opencode-ai/package.json"));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const from = createRequire(join(launcher, "package.json"));
|
|
65
|
+
for (const pkg of openCodePackages()) {
|
|
66
|
+
try {
|
|
67
|
+
const dir = dirname(from.resolve(`${pkg}/package.json`));
|
|
68
|
+
const bin = join(dir, "bin", binName());
|
|
69
|
+
if (existsSync(bin))
|
|
70
|
+
return { path: bin, pkg, packageVersion: packageVersion(dir) };
|
|
71
|
+
}
|
|
72
|
+
catch { }
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
/** The binary to run, or `undefined` if none is installed (see `findOpenCode`). */
|
|
77
|
+
export function openCodeBinary() {
|
|
78
|
+
return findOpenCode()?.path;
|
|
79
|
+
}
|
|
80
|
+
function packageVersion(dir) {
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(readFileSync(join(dir, "package.json"), "utf8")).version;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface OpenCodeConfigOptions {
|
|
2
|
+
model: string;
|
|
3
|
+
/** The model proxy's base for the Responses API: its loopback origin and `/v1`. */
|
|
4
|
+
modelUrl: string;
|
|
5
|
+
modelKey: string;
|
|
6
|
+
/** The adapter's MCP endpoint and its key. */
|
|
7
|
+
mcpUrl: string;
|
|
8
|
+
mcpKey: string;
|
|
9
|
+
contextWindow: number;
|
|
10
|
+
maxOutputTokens: number;
|
|
11
|
+
instructions?: string;
|
|
12
|
+
effort?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The longest an MCP call may go without progress: a day. The server reports progress every 15 s while a call runs. */
|
|
15
|
+
export declare const MCP_TIMEOUT_MS: number;
|
|
16
|
+
/** OpenCode's `tool_output` limits, from the host's result bound: a result within it holds at most that many characters
|
|
17
|
+
* (UTF-16 units), so at most that many lines plus one, and three bytes of UTF-8 to a character. */
|
|
18
|
+
export declare const TOOL_OUTPUT: Readonly<{
|
|
19
|
+
max_lines: number;
|
|
20
|
+
max_bytes: number;
|
|
21
|
+
}>;
|
|
22
|
+
/** The permission rules: everything denied, the adapter's MCP tools allowed (the last matching rule wins). */
|
|
23
|
+
export declare const PERMISSION: Readonly<Record<string, string>>;
|
|
24
|
+
export declare function openCodeConfig(options: OpenCodeConfigOptions): Record<string, unknown>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// OpenCode's whole config for a session, in a 0600 file OPENCODE_CONFIG names. Written for AgentRun; every key is one the
|
|
2
|
+
// pinned build's config schema holds (an unknown key refuses the start).
|
|
3
|
+
// - One provider, `openai` (the AI SDK's Responses client), at the session's model proxy with the session's own key,
|
|
4
|
+
// and one model, the session's, which is also the small model: no request goes to any other.
|
|
5
|
+
// - One agent, `hands`, whose prompt is the session's instructions (in place of OpenCode's own) and the default; every
|
|
6
|
+
// built-in agent is off, the title and summary agents among them, so OpenCode makes no side request of its own.
|
|
7
|
+
// - Every OpenCode tool denied and only the adapter's MCP tools (`hands_*`) allowed; OpenCode's own sharing,
|
|
8
|
+
// snapshots, formatters, language servers, instruction files and automatic compaction off.
|
|
9
|
+
// - One MCP server, `hands`, the adapter's, with a call timeout long enough for a person to answer (progress resets it).
|
|
10
|
+
// - A host tool's result within the host's bound (HOST_RESULT_MAX_CHARS) reaches the model whole: OpenCode cuts a
|
|
11
|
+
// longer tool output (by default 2,000 lines or 51,200 bytes) and saves the rest to a file, which the session has no
|
|
12
|
+
// tool to read.
|
|
13
|
+
import { HOST_RESULT_MAX_CHARS } from "@parcha/agentrun-kernel";
|
|
14
|
+
/** The longest an MCP call may go without progress: a day. The server reports progress every 15 s while a call runs. */
|
|
15
|
+
export const MCP_TIMEOUT_MS = 24 * 60 * 60 * 1000;
|
|
16
|
+
/** OpenCode's `tool_output` limits, from the host's result bound: a result within it holds at most that many characters
|
|
17
|
+
* (UTF-16 units), so at most that many lines plus one, and three bytes of UTF-8 to a character. */
|
|
18
|
+
export const TOOL_OUTPUT = Object.freeze({ max_lines: HOST_RESULT_MAX_CHARS + 1, max_bytes: HOST_RESULT_MAX_CHARS * 3 });
|
|
19
|
+
/** The permission rules: everything denied, the adapter's MCP tools allowed (the last matching rule wins). */
|
|
20
|
+
export const PERMISSION = Object.freeze({ "*": "deny", "hands_*": "allow" });
|
|
21
|
+
const BUILT_IN_AGENTS = ["build", "plan", "general", "explore", "title", "summary", "compaction"];
|
|
22
|
+
export function openCodeConfig(options) {
|
|
23
|
+
const modelRef = `openai/${options.model}`;
|
|
24
|
+
return {
|
|
25
|
+
autoupdate: false,
|
|
26
|
+
share: "disabled",
|
|
27
|
+
snapshot: false,
|
|
28
|
+
formatter: false,
|
|
29
|
+
lsp: false,
|
|
30
|
+
instructions: [],
|
|
31
|
+
compaction: { auto: false },
|
|
32
|
+
tool_output: { ...TOOL_OUTPUT },
|
|
33
|
+
enabled_providers: ["openai"],
|
|
34
|
+
provider: {
|
|
35
|
+
openai: {
|
|
36
|
+
options: { baseURL: options.modelUrl, apiKey: options.modelKey },
|
|
37
|
+
models: {
|
|
38
|
+
[options.model]: {
|
|
39
|
+
name: options.model,
|
|
40
|
+
tool_call: true,
|
|
41
|
+
reasoning: options.effort !== undefined,
|
|
42
|
+
attachment: false,
|
|
43
|
+
limit: { context: options.contextWindow, output: options.maxOutputTokens },
|
|
44
|
+
...(options.effort ? { options: { reasoningEffort: options.effort } } : {}),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
model: modelRef,
|
|
50
|
+
small_model: modelRef,
|
|
51
|
+
default_agent: "hands",
|
|
52
|
+
agent: {
|
|
53
|
+
hands: { mode: "primary", ...(options.instructions ? { prompt: options.instructions } : {}), permission: { ...PERMISSION } },
|
|
54
|
+
...Object.fromEntries(BUILT_IN_AGENTS.map((name) => [name, { disable: true }])),
|
|
55
|
+
},
|
|
56
|
+
permission: { ...PERMISSION },
|
|
57
|
+
mcp: {
|
|
58
|
+
hands: { type: "remote", url: options.mcpUrl, headers: { authorization: `Bearer ${options.mcpKey}` }, enabled: true, oauth: false, timeout: MCP_TIMEOUT_MS },
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { DriveContext, HostTool, SessionState } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
+
import { type ModelProxyHooks, type ModelProxyOptions, type ParentWatch } from "@parcha/agentrun-kernel/host";
|
|
3
|
+
import { type ConfineChild } from "./host/server.js";
|
|
4
|
+
/** The journal stream that holds OpenCode's own events for the session, as `/sync/history` gives them. */
|
|
5
|
+
export declare const SYNC_STREAM = "opencode.sync";
|
|
6
|
+
/** The journal stream that holds the message id each submission was sent under. */
|
|
7
|
+
export declare const PROMPT_STREAM = "opencode.prompt";
|
|
8
|
+
/** The submissions a drive of the session marked as sent to OpenCode (PROMPT_STREAM, written just before each send),
|
|
9
|
+
* with those a recovery's send carried (its `covers`). */
|
|
10
|
+
export declare function sentSubmissions(state: SessionState): Set<string>;
|
|
11
|
+
/** The session's private directories, under its own directory. */
|
|
12
|
+
export declare const PRIVATE_DIRS: readonly ["home", "config", "data", "cache", "state", "tmp"];
|
|
13
|
+
/** OpenCode's agent for the session: its prompt is the session's instructions, and its only tools are the host's. */
|
|
14
|
+
export declare const AGENT = "hands";
|
|
15
|
+
/** How long one try of a drive's event stream may take to say `server.connected`, and how many tries a drive has. */
|
|
16
|
+
export declare const EVENT_CONNECT_MS = 10000;
|
|
17
|
+
export declare const EVENT_TRIES = 3;
|
|
18
|
+
/** How long a drive that was not stopped waits, at its end, for the host tool calls still running to settle, when the
|
|
19
|
+
* kernel gives it no deadline (DriveContext.deadline). Codex waits for its in-flight calls the same way
|
|
20
|
+
* (run-adapters-codex/src/harness.ts:815-819 and :1125-1128), bounded by its own invocation deadline, which is
|
|
21
|
+
* codex-internal (invocationDeadline: the World's runtime deadline, else 10 minutes); this is opencode's own bound. */
|
|
22
|
+
export declare const CALLS_SETTLE_MS = 30000;
|
|
23
|
+
export interface OpenCodeHarnessOptions {
|
|
24
|
+
/** The kernel's tools: exactly the host's (and `read_skill_file` with skills). */
|
|
25
|
+
tools: HostTool[];
|
|
26
|
+
/** The provider's model id. */
|
|
27
|
+
model: string;
|
|
28
|
+
/** The session's instructions: OpenCode's agent prompt, in place of OpenCode's own. */
|
|
29
|
+
instructions?: string;
|
|
30
|
+
/** The reasoning effort, when the session names one. */
|
|
31
|
+
effort?: string;
|
|
32
|
+
/** The session's own directory: its private directories are made in it. */
|
|
33
|
+
dir: string;
|
|
34
|
+
/** The workspace OpenCode runs in (absolute), or `<dir>/work`. */
|
|
35
|
+
cwd?: string;
|
|
36
|
+
/** OpenCode, or a test's stand-in for it. */
|
|
37
|
+
command: {
|
|
38
|
+
command: string;
|
|
39
|
+
args: string[];
|
|
40
|
+
env?: Record<string, string>;
|
|
41
|
+
};
|
|
42
|
+
confine?: ConfineChild;
|
|
43
|
+
parentWatch?: ParentWatch;
|
|
44
|
+
/** The provider the proxy forwards to and its credential, read per request. */
|
|
45
|
+
provider: {
|
|
46
|
+
origin: string;
|
|
47
|
+
credential: () => Promise<string> | string;
|
|
48
|
+
};
|
|
49
|
+
hooks: ModelProxyHooks;
|
|
50
|
+
price?: ModelProxyOptions["price"];
|
|
51
|
+
maxOutputTokens?: number;
|
|
52
|
+
contextWindow: number;
|
|
53
|
+
/** How long one try of the event stream may take to open. Default EVENT_CONNECT_MS. */
|
|
54
|
+
eventConnectMs?: number;
|
|
55
|
+
log?: (message: string, fields?: Record<string, unknown>) => void;
|
|
56
|
+
/** For tests: the fetch the model proxy forwards with. */
|
|
57
|
+
fetch?: typeof fetch;
|
|
58
|
+
/** For tests: the environment the child's allowlist reads. */
|
|
59
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
60
|
+
}
|
|
61
|
+
/** What the adapter holds of the drive in flight, to stop its turn. */
|
|
62
|
+
export interface DriveControl {
|
|
63
|
+
/** Stop the turn in flight: OpenCode aborts it, and the drive ends once OpenCode's records of it are mirrored, with no
|
|
64
|
+
* end written for the turn (it stays open). Resolves true when that happened within `ms`, false when the drive must be
|
|
65
|
+
* halted instead. */
|
|
66
|
+
interrupt(ms: number): Promise<boolean>;
|
|
67
|
+
}
|
|
68
|
+
/** JSON text of `value` with every object's keys sorted: two argument objects that say the same are the same text. */
|
|
69
|
+
export declare function canonical(value: unknown): string;
|
|
70
|
+
/** A message id in OpenCode's own format (`msg_` + 12 hex of the time + 14 base62), which OpenCode orders messages by: it
|
|
71
|
+
* sorts after every id this process made before it. The random part comes from `seed` (the submission's id). */
|
|
72
|
+
export declare function messageId(seed: string, now?: number): string;
|
|
73
|
+
/** The OpenCode harness. `control` is told of each drive's stop hook while it runs. */
|
|
74
|
+
export declare function openCodeHarness(options: OpenCodeHarnessOptions, control?: (drive: DriveControl | undefined) => void): {
|
|
75
|
+
name: string;
|
|
76
|
+
drive(ctx: DriveContext): Promise<void>;
|
|
77
|
+
};
|