@neta-art/cohub-cli 10.24.0 → 10.25.1
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/bin/cohub.js +4 -1
- package/dist/board-gpu/page.js +1566 -71230
- package/dist/bootstrap.js +67 -27
- package/dist/build.json +1 -1
- package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
- package/dist/chunks/about.js +102 -0
- package/dist/chunks/app-realtime.js +2216 -0
- package/dist/chunks/app-realtime2.js +2 -0
- package/dist/chunks/app-ref.js +88 -0
- package/dist/chunks/apps.js +1423 -0
- package/dist/chunks/auth.js +175 -0
- package/dist/chunks/avatar.js +146 -0
- package/dist/chunks/binary-pins.js +5 -0
- package/dist/chunks/board-export-resources.js +232 -0
- package/dist/chunks/board-export.js +874 -0
- package/dist/chunks/board-export2.js +2 -0
- package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
- package/dist/chunks/board-kernel2.js +4 -0
- package/dist/chunks/board-profile.js +69 -0
- package/dist/chunks/board-simulate.js +315 -0
- package/dist/chunks/board-time.js +34 -0
- package/dist/chunks/boards.js +1943 -0
- package/dist/{board-kernel → chunks}/browserAll.js +9 -8
- package/dist/chunks/channels.js +64 -0
- package/dist/chunks/client.js +12606 -0
- package/dist/chunks/command-input.js +17 -0
- package/dist/chunks/commander.js +2962 -0
- package/dist/chunks/cron-jobs.js +163 -0
- package/dist/chunks/daemon.js +545 -0
- package/dist/chunks/daemon2.js +2 -0
- package/dist/chunks/desktop.js +172 -0
- package/dist/chunks/endpoint-options.js +26 -0
- package/dist/chunks/env-proxy.js +35 -0
- package/dist/chunks/environment.js +154 -0
- package/dist/chunks/feedback.js +120 -0
- package/dist/chunks/generations.js +379 -0
- package/dist/chunks/host.js +9 -0
- package/dist/chunks/http-put.js +131 -0
- package/dist/chunks/id.js +2416 -0
- package/dist/{board-kernel → chunks}/init.js +1 -1
- package/dist/chunks/install.js +11959 -0
- package/dist/chunks/launch.js +374 -0
- package/dist/chunks/local-media.js +47 -0
- package/dist/chunks/me.js +134 -0
- package/dist/chunks/media.js +315 -0
- package/dist/chunks/models.js +242 -0
- package/dist/chunks/operands.js +46 -0
- package/dist/chunks/package-paths.js +13 -0
- package/dist/chunks/policy.js +221 -0
- package/dist/chunks/preferences.js +29 -0
- package/dist/chunks/profile.js +64 -0
- package/dist/chunks/prompts.js +41 -0
- package/dist/chunks/public.js +2 -0
- package/dist/chunks/public2.js +244 -0
- package/dist/chunks/references.js +197 -0
- package/dist/chunks/referrals.js +90 -0
- package/dist/chunks/rolldown-runtime.js +26 -0
- package/dist/chunks/rooms-connect.js +2 -0
- package/dist/chunks/rooms-connect2.js +151 -0
- package/dist/chunks/rooms-rtc.js +311 -0
- package/dist/chunks/rooms.js +211 -0
- package/dist/chunks/run.js +220 -0
- package/dist/chunks/runtime.js +638 -0
- package/dist/chunks/runtime2.js +286 -0
- package/dist/chunks/runtimes.js +48 -0
- package/dist/chunks/safe-remote-image.js +198 -0
- package/dist/chunks/schemas.js +6017 -0
- package/dist/chunks/search.js +113 -0
- package/dist/chunks/self-update.js +238 -0
- package/dist/chunks/serve.js +1246 -0
- package/dist/chunks/session-status.js +24 -0
- package/dist/chunks/skills.js +35 -0
- package/dist/chunks/spaces.js +5080 -0
- package/dist/chunks/src.js +405 -0
- package/dist/chunks/supervisor.js +2513 -0
- package/dist/chunks/supervisor2.js +2 -0
- package/dist/chunks/tasks.js +82 -0
- package/dist/chunks/themes.js +2898 -0
- package/dist/chunks/version.js +2 -0
- package/dist/chunks/version2.js +22 -0
- package/dist/chunks/version3.js +18 -0
- package/dist/chunks/web.js +7 -0
- package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
- package/dist/runtime/native/pi-extension.js +174 -166
- package/dist/runtime/worker.js +27 -16
- package/package.json +8 -9
- package/dist/about.d.ts +0 -2
- package/dist/about.js +0 -71
- package/dist/app-download.d.ts +0 -11
- package/dist/app-download.js +0 -252
- package/dist/app-ref.d.ts +0 -5
- package/dist/app-ref.js +0 -8
- package/dist/app-target.d.ts +0 -26
- package/dist/app-target.js +0 -55
- package/dist/auth.d.ts +0 -45
- package/dist/auth.js +0 -307
- package/dist/avatar.d.ts +0 -55
- package/dist/avatar.js +0 -104
- package/dist/board-command-support.d.ts +0 -6
- package/dist/board-command-support.js +0 -88
- package/dist/board-export-resources.d.ts +0 -12
- package/dist/board-export-resources.js +0 -51
- package/dist/board-export.d.ts +0 -110
- package/dist/board-export.js +0 -592
- package/dist/board-fonts.d.ts +0 -11
- package/dist/board-fonts.js +0 -10
- package/dist/board-gpu/daemon.d.ts +0 -11
- package/dist/board-gpu/daemon.js +0 -295
- package/dist/board-gpu/index.d.ts +0 -33
- package/dist/board-gpu/index.js +0 -189
- package/dist/board-gpu/protocol.d.ts +0 -77
- package/dist/board-gpu/protocol.js +0 -1
- package/dist/board-kernel.d.ts +0 -5
- package/dist/board-media-export.d.ts +0 -17
- package/dist/board-media-export.js +0 -164
- package/dist/board-media.d.ts +0 -5
- package/dist/board-media.js +0 -66
- package/dist/board-profile.d.ts +0 -21
- package/dist/board-profile.js +0 -67
- package/dist/board-simulate.d.ts +0 -67
- package/dist/board-simulate.js +0 -259
- package/dist/board-time.d.ts +0 -3
- package/dist/board-time.js +0 -34
- package/dist/bootstrap.d.ts +0 -2
- package/dist/client.d.ts +0 -5
- package/dist/client.js +0 -24
- package/dist/command-input.d.ts +0 -4
- package/dist/command-input.js +0 -16
- package/dist/commands/app-commerce.d.ts +0 -2
- package/dist/commands/app-commerce.js +0 -228
- package/dist/commands/app-domains.d.ts +0 -2
- package/dist/commands/app-domains.js +0 -133
- package/dist/commands/apps.d.ts +0 -4
- package/dist/commands/apps.js +0 -827
- package/dist/commands/auth.d.ts +0 -2
- package/dist/commands/auth.js +0 -186
- package/dist/commands/boards/authoring.d.ts +0 -2
- package/dist/commands/boards/authoring.js +0 -166
- package/dist/commands/boards/examples.d.ts +0 -10
- package/dist/commands/boards/examples.js +0 -118
- package/dist/commands/boards.d.ts +0 -13
- package/dist/commands/boards.js +0 -836
- package/dist/commands/channels.d.ts +0 -2
- package/dist/commands/channels.js +0 -74
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -155
- package/dist/commands/decision.d.ts +0 -4
- package/dist/commands/decision.js +0 -113
- package/dist/commands/desktop.d.ts +0 -10
- package/dist/commands/desktop.js +0 -233
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -131
- package/dist/commands/generations.d.ts +0 -2
- package/dist/commands/generations.js +0 -427
- package/dist/commands/host.d.ts +0 -2
- package/dist/commands/host.js +0 -11
- package/dist/commands/me.d.ts +0 -2
- package/dist/commands/me.js +0 -121
- package/dist/commands/models.d.ts +0 -28
- package/dist/commands/models.js +0 -271
- package/dist/commands/profile.d.ts +0 -2
- package/dist/commands/profile.js +0 -81
- package/dist/commands/prompts.d.ts +0 -2
- package/dist/commands/prompts.js +0 -37
- package/dist/commands/public.d.ts +0 -20
- package/dist/commands/public.js +0 -291
- package/dist/commands/references.d.ts +0 -2
- package/dist/commands/references.js +0 -193
- package/dist/commands/referrals.d.ts +0 -2
- package/dist/commands/referrals.js +0 -88
- package/dist/commands/rooms-connect.d.ts +0 -17
- package/dist/commands/rooms-connect.js +0 -140
- package/dist/commands/rooms-rtc-binary.d.ts +0 -2
- package/dist/commands/rooms-rtc-binary.js +0 -107
- package/dist/commands/rooms-rtc.d.ts +0 -21
- package/dist/commands/rooms-rtc.js +0 -171
- package/dist/commands/rooms.d.ts +0 -3
- package/dist/commands/rooms.js +0 -277
- package/dist/commands/run.d.ts +0 -13
- package/dist/commands/run.js +0 -246
- package/dist/commands/runtime.d.ts +0 -3
- package/dist/commands/runtime.js +0 -320
- package/dist/commands/sandboxd-binary.d.ts +0 -11
- package/dist/commands/sandboxd-binary.js +0 -238
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -114
- package/dist/commands/session-access.d.ts +0 -2
- package/dist/commands/session-access.js +0 -70
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -34
- package/dist/commands/space-activity.d.ts +0 -26
- package/dist/commands/space-activity.js +0 -147
- package/dist/commands/space-commerce.d.ts +0 -2
- package/dist/commands/space-commerce.js +0 -514
- package/dist/commands/space-displays.d.ts +0 -2
- package/dist/commands/space-displays.js +0 -620
- package/dist/commands/space-files.d.ts +0 -5
- package/dist/commands/space-files.js +0 -215
- package/dist/commands/space-invitations.d.ts +0 -29
- package/dist/commands/space-invitations.js +0 -189
- package/dist/commands/space-turns.d.ts +0 -49
- package/dist/commands/space-turns.js +0 -205
- package/dist/commands/space-wallet.d.ts +0 -2
- package/dist/commands/space-wallet.js +0 -141
- package/dist/commands/space-webhooks.d.ts +0 -7
- package/dist/commands/space-webhooks.js +0 -73
- package/dist/commands/spaces.d.ts +0 -25
- package/dist/commands/spaces.js +0 -2170
- package/dist/commands/tasks.d.ts +0 -8
- package/dist/commands/tasks.js +0 -80
- package/dist/commands/version.d.ts +0 -2
- package/dist/commands/version.js +0 -21
- package/dist/endpoint-options.d.ts +0 -4
- package/dist/endpoint-options.js +0 -26
- package/dist/env-proxy.d.ts +0 -5
- package/dist/env-proxy.js +0 -20
- package/dist/help-path.d.ts +0 -18
- package/dist/help-path.js +0 -223
- package/dist/host/auth.d.ts +0 -20
- package/dist/host/auth.js +0 -119
- package/dist/host/login-env.d.ts +0 -1
- package/dist/host/login-env.js +0 -31
- package/dist/host/runtime.d.ts +0 -35
- package/dist/host/runtime.js +0 -395
- package/dist/host/runtimes.d.ts +0 -9
- package/dist/host/runtimes.js +0 -42
- package/dist/host/serve.d.ts +0 -2
- package/dist/host/serve.js +0 -117
- package/dist/host/workspaces.d.ts +0 -2
- package/dist/host/workspaces.js +0 -18
- package/dist/http-put.d.ts +0 -25
- package/dist/http-put.js +0 -132
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/launcher.d.ts +0 -4
- package/dist/launcher.js +0 -38
- package/dist/local-media.d.ts +0 -2
- package/dist/local-media.js +0 -30
- package/dist/network-error.d.ts +0 -3
- package/dist/network-error.js +0 -22
- package/dist/output.d.ts +0 -46
- package/dist/output.js +0 -244
- package/dist/runtime/archive-store.d.ts +0 -54
- package/dist/runtime/archive-store.js +0 -379
- package/dist/runtime/cli-path.d.ts +0 -5
- package/dist/runtime/cli-path.js +0 -27
- package/dist/runtime/codex-usage.d.ts +0 -7
- package/dist/runtime/codex-usage.js +0 -11
- package/dist/runtime/connection.d.ts +0 -42
- package/dist/runtime/connection.js +0 -789
- package/dist/runtime/diagnostics.d.ts +0 -107
- package/dist/runtime/diagnostics.js +0 -392
- package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
- package/dist/runtime/harnesses/chained-projection.js +0 -95
- package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
- package/dist/runtime/harnesses/chained-transcript.js +0 -62
- package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
- package/dist/runtime/harnesses/claude-approval.js +0 -124
- package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/claude-transcript.js +0 -138
- package/dist/runtime/harnesses/claude.d.ts +0 -8
- package/dist/runtime/harnesses/claude.js +0 -225
- package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
- package/dist/runtime/harnesses/codex-approval.js +0 -69
- package/dist/runtime/harnesses/codex.d.ts +0 -4
- package/dist/runtime/harnesses/codex.js +0 -269
- package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
- package/dist/runtime/harnesses/cursor-transcript.js +0 -183
- package/dist/runtime/harnesses/cursor.d.ts +0 -24
- package/dist/runtime/harnesses/cursor.js +0 -620
- package/dist/runtime/harnesses/index.d.ts +0 -16
- package/dist/runtime/harnesses/index.js +0 -73
- package/dist/runtime/harnesses/pi.d.ts +0 -4
- package/dist/runtime/harnesses/pi.js +0 -247
- package/dist/runtime/harnesses/process.d.ts +0 -31
- package/dist/runtime/harnesses/process.js +0 -75
- package/dist/runtime/harnesses/stream-json.d.ts +0 -48
- package/dist/runtime/harnesses/stream-json.js +0 -336
- package/dist/runtime/harnesses/types.d.ts +0 -117
- package/dist/runtime/harnesses/types.js +0 -1
- package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
- package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
- package/dist/runtime/harnesses/workbuddy.js +0 -123
- package/dist/runtime/instance.d.ts +0 -20
- package/dist/runtime/instance.js +0 -247
- package/dist/runtime/json-rpc.d.ts +0 -53
- package/dist/runtime/json-rpc.js +0 -212
- package/dist/runtime/launch.d.ts +0 -25
- package/dist/runtime/launch.js +0 -247
- package/dist/runtime/local-workspace.d.ts +0 -15
- package/dist/runtime/local-workspace.js +0 -52
- package/dist/runtime/model-catalog.d.ts +0 -12
- package/dist/runtime/model-catalog.js +0 -84
- package/dist/runtime/native/adapters.d.ts +0 -15
- package/dist/runtime/native/adapters.js +0 -11
- package/dist/runtime/native/approvals.d.ts +0 -18
- package/dist/runtime/native/approvals.js +0 -54
- package/dist/runtime/native/archive.d.ts +0 -19
- package/dist/runtime/native/archive.js +0 -142
- package/dist/runtime/native/attach.d.ts +0 -36
- package/dist/runtime/native/attach.js +0 -128
- package/dist/runtime/native/codex-link.d.ts +0 -60
- package/dist/runtime/native/codex-link.js +0 -322
- package/dist/runtime/native/config.d.ts +0 -16
- package/dist/runtime/native/config.js +0 -24
- package/dist/runtime/native/daemon.d.ts +0 -92
- package/dist/runtime/native/daemon.js +0 -380
- package/dist/runtime/native/execution.d.ts +0 -26
- package/dist/runtime/native/execution.js +0 -34
- package/dist/runtime/native/identity.d.ts +0 -9
- package/dist/runtime/native/identity.js +0 -15
- package/dist/runtime/native/ingest.d.ts +0 -263
- package/dist/runtime/native/ingest.js +0 -884
- package/dist/runtime/native/install.d.ts +0 -9
- package/dist/runtime/native/install.js +0 -113
- package/dist/runtime/native/paths.d.ts +0 -2
- package/dist/runtime/native/paths.js +0 -7
- package/dist/runtime/native/pi-extension.d.ts +0 -36
- package/dist/runtime/native/pi-link.d.ts +0 -69
- package/dist/runtime/native/pi-link.js +0 -269
- package/dist/runtime/native/results.d.ts +0 -41
- package/dist/runtime/native/results.js +0 -128
- package/dist/runtime/native/sessions.d.ts +0 -45
- package/dist/runtime/native/sessions.js +0 -87
- package/dist/runtime/native/transcript.d.ts +0 -89
- package/dist/runtime/native/transcript.js +0 -656
- package/dist/runtime/native/translate.d.ts +0 -46
- package/dist/runtime/native/translate.js +0 -299
- package/dist/runtime/native/transport.d.ts +0 -7
- package/dist/runtime/native/transport.js +0 -16
- package/dist/runtime/native/version.d.ts +0 -5
- package/dist/runtime/native/version.js +0 -21
- package/dist/runtime/preferences.d.ts +0 -7
- package/dist/runtime/preferences.js +0 -22
- package/dist/runtime/presentation.d.ts +0 -32
- package/dist/runtime/presentation.js +0 -124
- package/dist/runtime/process-group.d.ts +0 -5
- package/dist/runtime/process-group.js +0 -161
- package/dist/runtime/projection-store.d.ts +0 -27
- package/dist/runtime/projection-store.js +0 -30
- package/dist/runtime/space-binding.d.ts +0 -48
- package/dist/runtime/space-binding.js +0 -342
- package/dist/runtime/supervisor.d.ts +0 -19
- package/dist/runtime/supervisor.js +0 -441
- package/dist/runtime/turn-projection.d.ts +0 -41
- package/dist/runtime/turn-projection.js +0 -120
- package/dist/runtime/worker.d.ts +0 -1
- package/dist/safe-remote-image.d.ts +0 -36
- package/dist/safe-remote-image.js +0 -191
- package/dist/self-update.d.ts +0 -7
- package/dist/self-update.js +0 -202
- package/dist/session-status.d.ts +0 -10
- package/dist/session-status.js +0 -25
- package/dist/space-files/limit.d.ts +0 -2
- package/dist/space-files/limit.js +0 -16
- package/dist/space-files/operands.d.ts +0 -17
- package/dist/space-files/operands.js +0 -33
- package/dist/space-files/transfer.d.ts +0 -53
- package/dist/space-files/transfer.js +0 -297
- package/dist/space-files/upload.d.ts +0 -17
- package/dist/space-files/upload.js +0 -76
- package/dist/space.d.ts +0 -44
- package/dist/space.js +0 -192
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -17
- package/dist/web.d.ts +0 -1
- package/dist/web.js +0 -4
- /package/dist/{board-kernel → chunks}/lexer.js +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { access, stat } from "node:fs/promises";
|
|
2
|
-
import { constants } from "node:fs";
|
|
3
|
-
import { LOCAL_HARNESSES } from "@neta-art/cohub";
|
|
4
|
-
import { harnessExecutableCandidates } from "./process.js";
|
|
5
|
-
import { piHarness } from "./pi.js";
|
|
6
|
-
import { codexHarness } from "./codex.js";
|
|
7
|
-
import { claudeHarness } from "./claude.js";
|
|
8
|
-
import { workbuddyHarness } from "./workbuddy.js";
|
|
9
|
-
import { cursorHarness } from "./cursor.js";
|
|
10
|
-
export { harnessCommand, harnessExecutableCandidates } from "./process.js";
|
|
11
|
-
/** Every local harness is one adapter; the protocol registry lists their identities. Built lazily to tolerate import cycles. */
|
|
12
|
-
let registry = null;
|
|
13
|
-
const adapters = () => registry ??= { pi: piHarness, codex: codexHarness, claude: claudeHarness, workbuddy: workbuddyHarness, cursor: cursorHarness };
|
|
14
|
-
export const harnessAdapter = (harness) => adapters()[harness];
|
|
15
|
-
export const harnessExecutable = (harness, executables) => executables[harness] || adapters()[harness].binary;
|
|
16
|
-
export const transcriptFormat = (harness) => adapters()[harness].transcript;
|
|
17
|
-
/** Discover installed executables only; authentication/capability errors stay explicit. */
|
|
18
|
-
export async function installedHarnesses(cwd, executables, path = process.env.PATH ?? "") {
|
|
19
|
-
const explicit = LOCAL_HARNESSES.filter((harness) => executables[harness]);
|
|
20
|
-
const found = await Promise.all((explicit.length ? explicit : LOCAL_HARNESSES).map(async (harness) => {
|
|
21
|
-
for (const candidate of harnessExecutableCandidates(harnessExecutable(harness, executables), cwd, path)) {
|
|
22
|
-
try {
|
|
23
|
-
await access(candidate, process.platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
24
|
-
if ((await stat(candidate)).isFile())
|
|
25
|
-
return harness;
|
|
26
|
-
}
|
|
27
|
-
catch { /* Try the next PATH entry. */ }
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}));
|
|
31
|
-
return found.filter((harness) => harness !== null);
|
|
32
|
-
}
|
|
33
|
-
/** Whatever a harness offers beyond its models. A failed probe keeps `previous`, never failing discovery. */
|
|
34
|
-
async function harnessFeatures(harnesses, executables, cwd, previous) {
|
|
35
|
-
const entries = await Promise.all(harnesses.map(async (harness) => {
|
|
36
|
-
const modes = await adapters()[harness].approvalModes?.(harnessExecutable(harness, executables), cwd).catch(() => previous?.approvalModes?.[harness] ?? []);
|
|
37
|
-
return modes?.length ? [[harness, modes]] : [];
|
|
38
|
-
}));
|
|
39
|
-
const approvalModes = Object.fromEntries(entries.flat());
|
|
40
|
-
return Object.keys(approvalModes).length ? { approvalModes } : {};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Explicitly requested harnesses must all work. With `onUnavailable`, a failing harness is reported
|
|
44
|
-
* and left out instead, so auto-discovery still starts with the ones that work.
|
|
45
|
-
*/
|
|
46
|
-
export async function discoverHarnesses(harnesses, executables, cwd, onUnavailable) {
|
|
47
|
-
const catalogs = await Promise.all(harnesses.map(async (harness) => {
|
|
48
|
-
try {
|
|
49
|
-
return { harness, models: await adapters()[harness].models(harnessExecutable(harness, executables), cwd) };
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
if (!onUnavailable)
|
|
53
|
-
throw error;
|
|
54
|
-
onUnavailable(harness, error);
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}));
|
|
58
|
-
const available = catalogs.filter((catalog) => catalog !== null).map((catalog) => catalog.harness);
|
|
59
|
-
return { harnesses: available, models: catalogs.flatMap((catalog) => catalog?.models ?? []), ...await harnessFeatures(available, executables, cwd) };
|
|
60
|
-
}
|
|
61
|
-
/** Rediscover the running harnesses' models; a harness that fails keeps its previous models. */
|
|
62
|
-
export async function refreshHarnesses(current, executables, cwd, onUnavailable) {
|
|
63
|
-
const catalogs = await Promise.all(current.harnesses.map(async (harness) => {
|
|
64
|
-
try {
|
|
65
|
-
return await adapters()[harness].models(harnessExecutable(harness, executables), cwd, { strict: true });
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
onUnavailable(harness, error);
|
|
69
|
-
return current.models.filter((model) => model.harness === harness);
|
|
70
|
-
}
|
|
71
|
-
}));
|
|
72
|
-
return { harnesses: current.harnesses, models: catalogs.flat(), ...await harnessFeatures(current.harnesses, executables, cwd, current) };
|
|
73
|
-
}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { createReadStream } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { basename, dirname, join } from "node:path";
|
|
4
|
-
import { projectNativeSession } from "@neta-art/cohub";
|
|
5
|
-
import { JsonRpcProcess, record } from "../json-rpc.js";
|
|
6
|
-
import { piModelCatalog } from "../model-catalog.js";
|
|
7
|
-
import { describeError } from "../../network-error.js";
|
|
8
|
-
import { PI_DISCONNECTED } from "../native/pi-link.js";
|
|
9
|
-
import { copyNativeArchive } from "../native/archive.js";
|
|
10
|
-
import { readFirstRecord, readNativeTranscript } from "../native/transcript.js";
|
|
11
|
-
import { piTranslator } from "../native/translate.js";
|
|
12
|
-
import { array, closeHost, harnessCommand, inlineImage, text, turnEnvironment, watchHost } from "./process.js";
|
|
13
|
-
/** A stop request that the harness does not honour within this long ends its private process. */
|
|
14
|
-
const ABORT_ESCALATION_MS = 5_000;
|
|
15
|
-
/** Pause before asking a busy Pi again, so a Turn that is starting has reported itself. */
|
|
16
|
-
const PI_BUSY_RETRY_MS = 100;
|
|
17
|
-
/** Pi stop reasons that end a reply; anything else (a tool call) means more is coming. */
|
|
18
|
-
const PI_ENDED = ["stop", "length", "error", "aborted"];
|
|
19
|
-
const agentDirectory = () => process.env.PI_CODING_AGENT_DIR?.trim() || join(homedir(), ".pi", "agent");
|
|
20
|
-
const sessionRoot = () => process.env.PI_CODING_AGENT_SESSION_DIR?.trim() || join(agentDirectory(), "sessions");
|
|
21
|
-
/** Pi's encoding of a project directory into its session folder name. */
|
|
22
|
-
export const piSessionDirectoryName = (cwd) => `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
23
|
-
/** Whether a Pi project folder may hold sessions of `cwd` or a subdirectory of it. */
|
|
24
|
-
function piProjectFolderMatches(folder, cwd) {
|
|
25
|
-
const project = piSessionDirectoryName(cwd).slice(0, -2);
|
|
26
|
-
const name = basename(folder);
|
|
27
|
-
return name === `${project}--` || name.startsWith(`${project}-`);
|
|
28
|
-
}
|
|
29
|
-
function piSessionPath(nativeSessionId, cwd) {
|
|
30
|
-
const directory = process.env.PI_CODING_AGENT_SESSION_DIR?.trim() || join(agentDirectory(), "sessions", piSessionDirectoryName(cwd));
|
|
31
|
-
return join(directory, `${new Date().toISOString().replace(/[:.]/g, "-")}_${nativeSessionId}.jsonl`);
|
|
32
|
-
}
|
|
33
|
-
async function runPi(executor, turn) {
|
|
34
|
-
const { input, signal, context } = turn;
|
|
35
|
-
// Cohub drives every Pi through its extension, which needs the control socket and a recent Pi.
|
|
36
|
-
if (executor.pi.unavailable)
|
|
37
|
-
throw new Error(executor.pi.unavailable);
|
|
38
|
-
const prepared = await executor.sessions.prepare({
|
|
39
|
-
sessionId: input.sessionId, turnId: input.turnId, harness: "pi", cwd: executor.cwd,
|
|
40
|
-
provider: input.provider, context: input.context, signal,
|
|
41
|
-
// A terminal Pi is continued only through its extension; without one it is read-only.
|
|
42
|
-
resumable: (transcript) => transcript.path !== turn.diverged && (transcript.origin === "cohub" || executor.pi.find(transcript.nativeSessionId) !== null),
|
|
43
|
-
});
|
|
44
|
-
let session = prepared.session;
|
|
45
|
-
let link = executor.pi.find(session.nativeSessionId);
|
|
46
|
-
let host = null;
|
|
47
|
-
let message = { ordinal: 0, content: [] };
|
|
48
|
-
let begun = false;
|
|
49
|
-
try {
|
|
50
|
-
if (!link) {
|
|
51
|
-
host = new JsonRpcProcess(...harnessCommand(executor.executables.pi || "pi", ["--mode", "rpc", "--session", session.path, "-e", executor.piExtension], executor.cwd), executor.cwd, "pi", turnEnvironment(input));
|
|
52
|
-
watchHost(host, executor.diagnostics, context);
|
|
53
|
-
const rpc = host;
|
|
54
|
-
// Nobody is at this Pi's terminal to answer an extension's question.
|
|
55
|
-
rpc.onEvent((event) => {
|
|
56
|
-
if (event.type === "extension_ui_request" && ["confirm", "select", "input", "editor"].includes(text(event.method)))
|
|
57
|
-
rpc.write({ type: "extension_ui_response", id: event.id, cancelled: true });
|
|
58
|
-
});
|
|
59
|
-
await configurePiHost(host, input);
|
|
60
|
-
link = await Promise.race([
|
|
61
|
-
executor.pi.waitFor({ sessionId: session.nativeSessionId, sessionFile: session.path }, signal),
|
|
62
|
-
new Promise((_, reject) => host?.onFailure(reject)),
|
|
63
|
-
]);
|
|
64
|
-
}
|
|
65
|
-
const piSession = link;
|
|
66
|
-
session = { ...session, nativeSessionId: piSession.sessionId };
|
|
67
|
-
// Never interleave with a Turn a terminal user is running; follow it instead.
|
|
68
|
-
await executor.pi.idle(piSession.sessionId, signal);
|
|
69
|
-
const content = await piPrompt(input);
|
|
70
|
-
signal.throwIfAborted();
|
|
71
|
-
await turn.started(session);
|
|
72
|
-
begun = true;
|
|
73
|
-
const translator = piTranslator(turn.emit);
|
|
74
|
-
const model = !host && input.model && input.provider ? { provider: input.provider, id: input.model } : null;
|
|
75
|
-
await new Promise((resolve, reject) => {
|
|
76
|
-
let escalation;
|
|
77
|
-
/** Events held until Pi takes the prompt; until then they belong to a terminal Turn. */
|
|
78
|
-
let held = [];
|
|
79
|
-
let done = false;
|
|
80
|
-
const finish = (error) => {
|
|
81
|
-
if (done)
|
|
82
|
-
return;
|
|
83
|
-
done = true;
|
|
84
|
-
off();
|
|
85
|
-
signal.removeEventListener("abort", abort);
|
|
86
|
-
clearTimeout(escalation);
|
|
87
|
-
if (error)
|
|
88
|
-
reject(error);
|
|
89
|
-
else
|
|
90
|
-
resolve();
|
|
91
|
-
};
|
|
92
|
-
const feed = (event) => {
|
|
93
|
-
try {
|
|
94
|
-
if (translator.push(event))
|
|
95
|
-
finish();
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
finish(error);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const off = executor.pi.subscribe(piSession.sessionId, (event) => {
|
|
102
|
-
if (event.type === PI_DISCONNECTED) {
|
|
103
|
-
finish(new Error("Pi exited during the Turn"));
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (held)
|
|
107
|
-
held.push(event);
|
|
108
|
-
else
|
|
109
|
-
feed(event);
|
|
110
|
-
});
|
|
111
|
-
const abort = () => {
|
|
112
|
-
// Not taken yet: the Pi is running someone else's Turn, which is not Cohub's to stop.
|
|
113
|
-
if (held) {
|
|
114
|
-
finish(signal.reason ?? new Error("Aborted"));
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
void executor.pi.abort(piSession.sessionId).catch(() => undefined);
|
|
118
|
-
if (host)
|
|
119
|
-
escalation = setTimeout(() => void host?.close().catch(() => undefined), ABORT_ESCALATION_MS);
|
|
120
|
-
};
|
|
121
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
122
|
-
void (async () => {
|
|
123
|
-
for (;;) {
|
|
124
|
-
// Only what follows this request can be this Turn's.
|
|
125
|
-
held = [];
|
|
126
|
-
const { accepted } = await executor.pi.prompt(piSession.sessionId, { turnId: input.turnId, content, model, thinkingLevel: host ? null : input.thinkingLevel ?? null, env: turnEnvironment(input) });
|
|
127
|
-
if (accepted)
|
|
128
|
-
break;
|
|
129
|
-
// The terminal started a Turn first: wait for it to settle, then ask again.
|
|
130
|
-
await new Promise((resolve) => setTimeout(resolve, PI_BUSY_RETRY_MS));
|
|
131
|
-
await executor.pi.idle(piSession.sessionId, signal);
|
|
132
|
-
if (done)
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const events = held ?? [];
|
|
136
|
-
held = null;
|
|
137
|
-
if (done) {
|
|
138
|
-
void executor.pi.abort(piSession.sessionId).catch(() => undefined);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
for (const event of events)
|
|
142
|
-
feed(event);
|
|
143
|
-
if (signal.aborted)
|
|
144
|
-
abort();
|
|
145
|
-
})().catch(finish);
|
|
146
|
-
if (signal.aborted)
|
|
147
|
-
abort();
|
|
148
|
-
});
|
|
149
|
-
message = translator.last();
|
|
150
|
-
// The Pi keeps running for its terminal user; its tools no longer work for this Turn.
|
|
151
|
-
if (!host)
|
|
152
|
-
void executor.pi.context(piSession.sessionId, { COHUB_TURN_ID: null }).catch(() => undefined);
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
// Before the prompt, nothing ran and the error is the outcome.
|
|
156
|
-
if (!begun) {
|
|
157
|
-
if (host)
|
|
158
|
-
await closeHost(host, null).catch(() => undefined);
|
|
159
|
-
throw error;
|
|
160
|
-
}
|
|
161
|
-
message = { ...message, stopReason: signal.aborted ? "aborted" : "error", errorMessage: signal.aborted ? null : describeError(error) };
|
|
162
|
-
}
|
|
163
|
-
return { session, resume: prepared.resume, message, host };
|
|
164
|
-
}
|
|
165
|
-
/** A Pi that Cohub starts is configured through its RPC before the extension takes the prompt. */
|
|
166
|
-
async function configurePiHost(host, input) {
|
|
167
|
-
if (input.model) {
|
|
168
|
-
let provider = input.provider;
|
|
169
|
-
if (!provider) {
|
|
170
|
-
const catalog = await host.request("get_available_models");
|
|
171
|
-
const matches = (Array.isArray(catalog.models) ? catalog.models : []).map(record).filter((model) => model.id === input.model);
|
|
172
|
-
if (matches.length !== 1)
|
|
173
|
-
throw new Error("Select a provider for this local model");
|
|
174
|
-
provider = text(matches[0]?.provider);
|
|
175
|
-
}
|
|
176
|
-
await host.request("set_model", { provider, modelId: input.model });
|
|
177
|
-
}
|
|
178
|
-
if (input.thinkingLevel)
|
|
179
|
-
await host.request("set_thinking_level", { level: input.thinkingLevel });
|
|
180
|
-
}
|
|
181
|
-
async function piPrompt(input) {
|
|
182
|
-
const blocks = input.messages.flatMap((message) => message.content);
|
|
183
|
-
return await Promise.all(blocks.map(async (block) => {
|
|
184
|
-
if (block.type === "image")
|
|
185
|
-
return await inlineImage(block);
|
|
186
|
-
return { type: "text", text: block.type === "text" ? block.text : JSON.stringify(block) };
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
export const piHarness = {
|
|
190
|
-
id: "pi",
|
|
191
|
-
binary: "pi",
|
|
192
|
-
async models(executable, cwd) {
|
|
193
|
-
const rpc = new JsonRpcProcess(...harnessCommand(executable, ["--mode", "rpc", "--no-session"], cwd), cwd, "pi");
|
|
194
|
-
try {
|
|
195
|
-
const result = await rpc.request("get_available_models");
|
|
196
|
-
const state = await rpc.request("get_state");
|
|
197
|
-
return piModelCatalog(array(result.models), state);
|
|
198
|
-
}
|
|
199
|
-
finally {
|
|
200
|
-
await rpc.close();
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
run: runPi,
|
|
204
|
-
session: {
|
|
205
|
-
path: piSessionPath,
|
|
206
|
-
startsWithoutFile: false,
|
|
207
|
-
project: (input) => projectNativeSession(input, "pi"),
|
|
208
|
-
rebind: (records, nativeSessionId) => records.map((entry) => entry.sourceTurnId === null && entry.record.type === "session"
|
|
209
|
-
? { ...entry, record: { ...entry.record, id: nativeSessionId, affinity: { ...record(entry.record.affinity), threadId: nativeSessionId } } }
|
|
210
|
-
: entry),
|
|
211
|
-
archive: {
|
|
212
|
-
target: ({ id, cwd }) => piSessionPath(id, cwd),
|
|
213
|
-
async import(input) {
|
|
214
|
-
const { checksum } = await copyNativeArchive({
|
|
215
|
-
...input,
|
|
216
|
-
header: (header) => {
|
|
217
|
-
if (header.type !== "session" || header.id !== input.nativeSessionId)
|
|
218
|
-
throw new Error("Pi archive identity mismatch");
|
|
219
|
-
const next = { ...header, cwd: input.cwd };
|
|
220
|
-
delete next.parentSession;
|
|
221
|
-
return next;
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
return { checksum, nativeSessionId: input.nativeSessionId };
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
transcript: {
|
|
229
|
-
roots: () => [sessionRoot()],
|
|
230
|
-
acceptsDirectory: (path, root, cwd) => Boolean(process.env.PI_CODING_AGENT_SESSION_DIR?.trim()) || dirname(path) !== root || piProjectFolderMatches(path, cwd),
|
|
231
|
-
acceptsTranscript: (path, cwd) => path.endsWith(".jsonl") && (Boolean(process.env.PI_CODING_AGENT_SESSION_DIR?.trim()) || piProjectFolderMatches(dirname(path), cwd)),
|
|
232
|
-
async header(path, signal) {
|
|
233
|
-
const header = await readFirstRecord(createReadStream(path, { signal }));
|
|
234
|
-
if (header.type !== "session" || !text(header.id) || !text(header.cwd))
|
|
235
|
-
return null;
|
|
236
|
-
return { harness: "pi", nativeSessionId: text(header.id), cwd: text(header.cwd), thread: "user" };
|
|
237
|
-
},
|
|
238
|
-
// A Pi Turn's end is inferred by the caller, so the tail is parsed as settled here.
|
|
239
|
-
read: (path, signal) => readNativeTranscript(path, "pi", { settled: true, signal }),
|
|
240
|
-
boundaries: ['"role":"user"', ...PI_ENDED.map((reason) => `"stopReason":"${reason}"`)],
|
|
241
|
-
turnEndRecorded: false,
|
|
242
|
-
replyEnded: (turn) => PI_ENDED.includes(turn.messages.at(-1)?.stopReason ?? ""),
|
|
243
|
-
userFinalMarked: false,
|
|
244
|
-
globalTurnKeys: false,
|
|
245
|
-
marksCohubTurns: true,
|
|
246
|
-
},
|
|
247
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ContentBlock, RuntimeTurnInput } from "@neta-art/cohub";
|
|
2
|
-
import { type JsonRpcProcess } from "../json-rpc.js";
|
|
3
|
-
import { type RuntimeDiagnosticContext, type RuntimeDiagnostics } from "../diagnostics.js";
|
|
4
|
-
import type { HarnessResult } from "./types.js";
|
|
5
|
-
export declare const text: (value: unknown) => string;
|
|
6
|
-
export declare const array: (value: unknown) => unknown[];
|
|
7
|
-
export declare const missing: (error: unknown) => boolean;
|
|
8
|
-
/** Aborted streams leave tool calls with an empty id or name. */
|
|
9
|
-
export declare const identifiable: (value: unknown) => value is string;
|
|
10
|
-
export declare function harnessExecutableCandidates(binary: string, cwd: string, path: string, platform?: NodeJS.Platform, pathExt?: string | undefined): string[];
|
|
11
|
-
/**
|
|
12
|
-
* Windows npm/pnpm installs expose harnesses as .cmd shims, which cannot be spawned
|
|
13
|
-
* without a shell. Run an .exe directly, or the shim's Node entry with this Node.
|
|
14
|
-
*/
|
|
15
|
-
export declare function harnessCommand(binary: string, args: string[], cwd: string): [string, string[]];
|
|
16
|
-
/** Variables a Turn's tools see, so a `cohub` call inside a tool knows where it runs. */
|
|
17
|
-
export declare const turnEnvironment: (input: RuntimeTurnInput) => {
|
|
18
|
-
COHUB_SPACE_ID: string;
|
|
19
|
-
COHUB_SESSION_ID: string;
|
|
20
|
-
COHUB_TURN_ID: string;
|
|
21
|
-
};
|
|
22
|
-
export declare function inlineImage(block: Extract<ContentBlock, {
|
|
23
|
-
type: "image";
|
|
24
|
-
}>): Promise<{
|
|
25
|
-
type: "image";
|
|
26
|
-
data: string;
|
|
27
|
-
mimeType: string;
|
|
28
|
-
}>;
|
|
29
|
-
export declare function watchHost(host: JsonRpcProcess, diagnostics: RuntimeDiagnostics | undefined, context: RuntimeDiagnosticContext | undefined): void;
|
|
30
|
-
/** Close a harness process Cohub started. An unconfirmable cleanup marks the result uncertain; it never masks it. */
|
|
31
|
-
export declare function closeHost(host: JsonRpcProcess, executionError: string | null | undefined): Promise<HarnessResult["uncertainCleanup"]>;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { readFileSync, statSync } from "node:fs";
|
|
2
|
-
import { delimiter, join, resolve, win32 } from "node:path";
|
|
3
|
-
import { RpcProcessClosedError } from "../json-rpc.js";
|
|
4
|
-
import { ProcessCleanupUncertainError } from "../process-group.js";
|
|
5
|
-
import { downloadPublicImage } from "../../safe-remote-image.js";
|
|
6
|
-
import { serializeDiagnosticError } from "../diagnostics.js";
|
|
7
|
-
export const text = (value) => typeof value === "string" ? value : "";
|
|
8
|
-
export const array = (value) => Array.isArray(value) ? value : [];
|
|
9
|
-
export const missing = (error) => error?.code === "ENOENT";
|
|
10
|
-
/** Aborted streams leave tool calls with an empty id or name. */
|
|
11
|
-
export const identifiable = (value) => typeof value === "string" && value.length > 0;
|
|
12
|
-
export function harnessExecutableCandidates(binary, cwd, path, platform = process.platform, pathExt = process.env.PATHEXT) {
|
|
13
|
-
const windows = platform === "win32";
|
|
14
|
-
const paths = windows ? win32 : { delimiter, join, resolve };
|
|
15
|
-
// Windows runs only PATHEXT names; npm/pnpm also write an extensionless sh script beside the .cmd shim.
|
|
16
|
-
const extensions = windows && !win32.extname(binary)
|
|
17
|
-
? (pathExt || ".COM;.EXE;.BAT;.CMD").split(";").filter((ext) => /^\.[a-z0-9]+$/i.test(ext))
|
|
18
|
-
: [""];
|
|
19
|
-
const roots = binary.includes("/") || binary.includes("\\")
|
|
20
|
-
? [paths.resolve(cwd, binary)]
|
|
21
|
-
: path.split(paths.delimiter).map((directory) => directory.replace(/^"(.*)"$/, "$1")).filter(Boolean).map((directory) => paths.resolve(cwd, directory, binary));
|
|
22
|
-
return roots.flatMap((root) => extensions.map((ext) => `${root}${ext}`));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Windows npm/pnpm installs expose harnesses as .cmd shims, which cannot be spawned
|
|
26
|
-
* without a shell. Run an .exe directly, or the shim's Node entry with this Node.
|
|
27
|
-
*/
|
|
28
|
-
export function harnessCommand(binary, args, cwd) {
|
|
29
|
-
if (process.platform !== "win32")
|
|
30
|
-
return [binary, args];
|
|
31
|
-
const path = harnessExecutableCandidates(binary, cwd, process.env.PATH ?? "").find((candidate) => statSync(candidate, { throwIfNoEntry: false })?.isFile());
|
|
32
|
-
if (!path)
|
|
33
|
-
throw new Error(`${binary} was not found on PATH`);
|
|
34
|
-
const extension = win32.extname(path).toLowerCase();
|
|
35
|
-
if (extension === ".exe" || extension === ".com")
|
|
36
|
-
return [path, args];
|
|
37
|
-
if ([".js", ".mjs", ".cjs"].includes(extension))
|
|
38
|
-
return [process.execPath, [path, ...args]];
|
|
39
|
-
if (extension === ".cmd") {
|
|
40
|
-
// npm (cmd-shim): SET "_prog=node" … "%dp0%\entry" %*; pnpm (@zkochan/cmd-shim): node "%~dp0\entry" %*
|
|
41
|
-
const shim = readFileSync(path, "utf8");
|
|
42
|
-
const runsNode = /SET "_prog=node"/i.test(shim) || /^\s*node\s+"%~dp0\\/im.test(shim);
|
|
43
|
-
const entry = runsNode ? /"%~?dp0%?\\([^"]+)"\s+%\*/i.exec(shim)?.[1] : undefined;
|
|
44
|
-
if (entry)
|
|
45
|
-
return [process.execPath, [win32.join(win32.dirname(path), entry), ...args]];
|
|
46
|
-
}
|
|
47
|
-
throw new Error(`Cannot run ${path} without a shell; pass its executable option with an .exe or Node script`);
|
|
48
|
-
}
|
|
49
|
-
/** Variables a Turn's tools see, so a `cohub` call inside a tool knows where it runs. */
|
|
50
|
-
export const turnEnvironment = (input) => ({ COHUB_SPACE_ID: input.spaceId, COHUB_SESSION_ID: input.sessionId, COHUB_TURN_ID: input.turnId });
|
|
51
|
-
export async function inlineImage(block) {
|
|
52
|
-
if (block.source.type === "base64")
|
|
53
|
-
return { type: "image", data: block.source.data, mimeType: block.source.media_type };
|
|
54
|
-
const image = await downloadPublicImage(block.source.url);
|
|
55
|
-
return { type: "image", data: Buffer.from(image.bytes).toString("base64"), mimeType: image.mimeType };
|
|
56
|
-
}
|
|
57
|
-
export function watchHost(host, diagnostics, context) {
|
|
58
|
-
if (!diagnostics)
|
|
59
|
-
return;
|
|
60
|
-
host.onFailure((error) => {
|
|
61
|
-
if (!(error instanceof RpcProcessClosedError))
|
|
62
|
-
diagnostics.log("error", "harness.rpc_process_failed", { error: serializeDiagnosticError(error) }, { ...context, component: "harness" });
|
|
63
|
-
});
|
|
64
|
-
host.onTimeout((method, timeoutMs) => diagnostics.log("error", "harness.rpc_timeout", { method, timeoutMs }, { ...context, component: "harness" }));
|
|
65
|
-
}
|
|
66
|
-
/** Close a harness process Cohub started. An unconfirmable cleanup marks the result uncertain; it never masks it. */
|
|
67
|
-
export async function closeHost(host, executionError) {
|
|
68
|
-
return await host.close().then(() => undefined, (cleanupError) => {
|
|
69
|
-
const processGroupId = host.processGroupId;
|
|
70
|
-
if (!(cleanupError instanceof ProcessCleanupUncertainError) || processGroupId == null)
|
|
71
|
-
throw cleanupError;
|
|
72
|
-
const detail = executionError ? `; execution error: ${executionError}` : "";
|
|
73
|
-
return { processGroupId, error: `${cleanupError.message}${detail}` };
|
|
74
|
-
});
|
|
75
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { type ContentBlock, type RuntimeMessage, type RuntimeTurnInput } from "@neta-art/cohub";
|
|
2
|
-
import { type JsonRecord } from "../json-rpc.js";
|
|
3
|
-
import type { Executor } from "../native/execution.js";
|
|
4
|
-
import type { HarnessModel, HarnessRun, HarnessTurn } from "./types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Plan mode still honours the user's allow rules, so a read-only Turn also gets only these
|
|
7
|
-
* built-in tools and no configured MCP servers.
|
|
8
|
-
*/
|
|
9
|
-
export declare const READ_ONLY_ARGS: string[];
|
|
10
|
-
/** Runs without `--model`, so the CLI's own configuration and account default apply. */
|
|
11
|
-
export declare const DEFAULT_MODEL = "default";
|
|
12
|
-
/** A Claude Code–compatible CLI (`-p --input-format stream-json --output-format stream-json`). */
|
|
13
|
-
export type StreamJsonProfile = {
|
|
14
|
-
harness: RuntimeTurnInput["harness"];
|
|
15
|
-
label: string;
|
|
16
|
-
binary: string;
|
|
17
|
-
provider: string;
|
|
18
|
-
/** Root holding `projects/<project>/<session>.jsonl`. */
|
|
19
|
-
dataRoot(): string;
|
|
20
|
-
projectDirectory(cwd: string): string;
|
|
21
|
-
/** Thinking levels offered when the CLI does not list a model's own. */
|
|
22
|
-
effortLevels: readonly string[];
|
|
23
|
-
/** The CLI keeps a stream-json prompt's `uuid` as its record id, so the file names the Cohub Turn. */
|
|
24
|
-
promptUuid: boolean;
|
|
25
|
-
/** Without it, a Turn with full access runs `acceptEdits` and every permission prompt is denied. */
|
|
26
|
-
approvals?(executor: Executor, input: RuntimeTurnInput): Promise<StreamJsonApprovals | null>;
|
|
27
|
-
};
|
|
28
|
-
export type StreamJsonApprovals = {
|
|
29
|
-
/** Replaces `--permission-mode acceptEdits`. */
|
|
30
|
-
args: string[];
|
|
31
|
-
/** Answers a `can_use_tool` request; absent, it is denied. */
|
|
32
|
-
answer?(request: JsonRecord, signal: AbortSignal): Promise<JsonRecord>;
|
|
33
|
-
};
|
|
34
|
-
/** The CLI's help, after checking it offers every flag a Turn uses. */
|
|
35
|
-
export declare function streamJsonHelp(profile: StreamJsonProfile, executable: string, cwd: string): Promise<string>;
|
|
36
|
-
export declare function streamJsonModel(profile: StreamJsonProfile, id: string, name: string, options: {
|
|
37
|
-
reasoning: boolean;
|
|
38
|
-
isDefault?: boolean;
|
|
39
|
-
provider?: string;
|
|
40
|
-
effortLevels?: readonly string[];
|
|
41
|
-
}): HarnessModel;
|
|
42
|
-
export declare function streamContent(value: unknown): ContentBlock[];
|
|
43
|
-
export declare function streamUsage(value: unknown, cost: unknown): RuntimeMessage["usage"];
|
|
44
|
-
/**
|
|
45
|
-
* One Turn per process. Cohub grants a permission prompt only through the profile's approvals;
|
|
46
|
-
* otherwise workspace edits follow `acceptEdits` and every other tool the user's own rules.
|
|
47
|
-
*/
|
|
48
|
-
export declare function runStreamJson(profile: StreamJsonProfile, executor: Executor, turn: HarnessTurn): Promise<HarnessRun>;
|