@neta-art/cohub-cli 10.23.0 → 10.25.0
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/README.md +18 -5
- 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/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 +309 -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 +2511 -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 -118
- 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 -64
- 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 -2139
- 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 -6
- package/dist/session-status.js +0 -16
- 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,9 +0,0 @@
|
|
|
1
|
-
export declare const piAgentDirectory: () => string;
|
|
2
|
-
/** The extension shipped with this CLI: one self-contained module, loadable by Pi as is. */
|
|
3
|
-
export declare const piExtensionSource: () => string;
|
|
4
|
-
export type PiExtensionState = "installed" | "outdated" | "missing" | "foreign";
|
|
5
|
-
export declare function piExtensionState(): Promise<PiExtensionState>;
|
|
6
|
-
/** Install or upgrade the Pi extension in the user's Pi configuration. */
|
|
7
|
-
export declare function installPiExtension(): Promise<PiExtensionState>;
|
|
8
|
-
/** Remove the Codex hooks earlier releases installed; Cohub now reads Codex's own files instead. */
|
|
9
|
-
export declare function removeLegacyCodexHooks(): Promise<boolean>;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { lstat, mkdir, open, readFile, rename, rm } from "node:fs/promises";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { dirname, extname, join } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { withRuntimeSpaceBindingsLock } from "../space-binding.js";
|
|
7
|
-
const missing = (error) => error.code === "ENOENT";
|
|
8
|
-
/** First line of the installed extension; a file without it belongs to someone else. */
|
|
9
|
-
const PI_EXTENSION_HEADER = "// Cohub control extension for Pi. Managed by `cohub runtime`; local edits are replaced on upgrade.\n";
|
|
10
|
-
/** CLI 8.0–8.2 installed a re-export under this comment; its module is gone, so Pi fails to start while it remains. */
|
|
11
|
-
const LEGACY_PI_EXTENSION_HEADER = "// Cohub native Turn sync";
|
|
12
|
-
/** Earlier releases installed Codex hooks; they are removed on upgrade. */
|
|
13
|
-
const LEGACY_CODEX_HOOKS = /\n*# BEGIN COHUB NATIVE SYNC\n[\s\S]*?# END COHUB NATIVE SYNC\n?/;
|
|
14
|
-
export const piAgentDirectory = () => process.env.PI_CODING_AGENT_DIR?.trim() || join(homedir(), ".pi", "agent");
|
|
15
|
-
const codexConfigPath = () => join(process.env.CODEX_HOME?.trim() || join(homedir(), ".codex"), "config.toml");
|
|
16
|
-
/** The extension shipped with this CLI: one self-contained module, loadable by Pi as is. */
|
|
17
|
-
export const piExtensionSource = () => fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "./pi-extension.ts" : "./pi-extension.js", import.meta.url));
|
|
18
|
-
const piExtensionPath = (extension) => join(piAgentDirectory(), "extensions", `cohub${extension}`);
|
|
19
|
-
const readOptional = (path) => readFile(path, "utf8").catch((error) => { if (missing(error))
|
|
20
|
-
return null; throw error; });
|
|
21
|
-
const isLegacy = (text) => Boolean(text?.startsWith(LEGACY_PI_EXTENSION_HEADER));
|
|
22
|
-
export async function piExtensionState() {
|
|
23
|
-
const source = piExtensionSource();
|
|
24
|
-
const [expected, current, legacy] = await Promise.all([readFile(source, "utf8"), readOptional(piExtensionPath(extname(source))), readOptional(piExtensionPath(".ts"))]);
|
|
25
|
-
if (isLegacy(legacy))
|
|
26
|
-
return "outdated";
|
|
27
|
-
if (current === null)
|
|
28
|
-
return "missing";
|
|
29
|
-
if (current === PI_EXTENSION_HEADER + expected)
|
|
30
|
-
return "installed";
|
|
31
|
-
return current.startsWith(PI_EXTENSION_HEADER) ? "outdated" : "foreign";
|
|
32
|
-
}
|
|
33
|
-
/** Install or upgrade the Pi extension in the user's Pi configuration. */
|
|
34
|
-
export async function installPiExtension() {
|
|
35
|
-
const source = piExtensionSource();
|
|
36
|
-
const content = PI_EXTENSION_HEADER + await readFile(source, "utf8");
|
|
37
|
-
const target = piExtensionPath(extname(source));
|
|
38
|
-
await writeManaged(target, (existing) => {
|
|
39
|
-
if (existing !== null && !existing.startsWith(PI_EXTENSION_HEADER) && !isLegacy(existing))
|
|
40
|
-
throw new Error(`${target} exists and is not managed by Cohub; move it aside, then retry`);
|
|
41
|
-
return content;
|
|
42
|
-
}, { backup: false });
|
|
43
|
-
// Pi loads every file here: drop a legacy or managed copy under the other extension.
|
|
44
|
-
for (const other of [".ts", ".js"].map(piExtensionPath).filter((path) => path !== target)) {
|
|
45
|
-
const text = await readOptional(other).catch(() => null);
|
|
46
|
-
if (isLegacy(text) || text?.startsWith(PI_EXTENSION_HEADER))
|
|
47
|
-
await rm(other, { force: true });
|
|
48
|
-
}
|
|
49
|
-
return "installed";
|
|
50
|
-
}
|
|
51
|
-
/** Remove the Codex hooks earlier releases installed; Cohub now reads Codex's own files instead. */
|
|
52
|
-
export async function removeLegacyCodexHooks() {
|
|
53
|
-
const path = codexConfigPath();
|
|
54
|
-
// Read first: the lock would create `~/.codex` for someone who never used Codex.
|
|
55
|
-
if (!LEGACY_CODEX_HOOKS.test(await readOptional(path) ?? ""))
|
|
56
|
-
return false;
|
|
57
|
-
let removed = false;
|
|
58
|
-
await writeManaged(path, (existing) => {
|
|
59
|
-
if (existing === null || !LEGACY_CODEX_HOOKS.test(existing))
|
|
60
|
-
return existing;
|
|
61
|
-
removed = true;
|
|
62
|
-
return existing.replace(LEGACY_CODEX_HOOKS, "\n");
|
|
63
|
-
}).catch((error) => { if (!missing(error))
|
|
64
|
-
throw error; });
|
|
65
|
-
return removed;
|
|
66
|
-
}
|
|
67
|
-
/** Replace a user configuration file atomically, keeping one backup of what was there. */
|
|
68
|
-
async function writeManaged(path, update, options = { backup: true }) {
|
|
69
|
-
await withRuntimeSpaceBindingsLock(async () => {
|
|
70
|
-
const info = await lstat(path).catch((error) => { if (missing(error))
|
|
71
|
-
return null; throw error; });
|
|
72
|
-
if (info && (!info.isFile() || info.isSymbolicLink()))
|
|
73
|
-
throw new Error(`Refusing to replace a non-regular file: ${path}`);
|
|
74
|
-
const original = info ? await readFile(path, "utf8") : null;
|
|
75
|
-
const next = update(original);
|
|
76
|
-
if (next === null || next === original)
|
|
77
|
-
return;
|
|
78
|
-
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
79
|
-
if (original !== null && options.backup) {
|
|
80
|
-
const backup = `${path}.cohub-backup-${createHash("sha256").update(original).digest("hex").slice(0, 16)}`;
|
|
81
|
-
const file = await open(backup, "wx", 0o600).catch((error) => { if (error.code === "EEXIST")
|
|
82
|
-
return null; throw error; });
|
|
83
|
-
if (file) {
|
|
84
|
-
try {
|
|
85
|
-
await file.writeFile(original);
|
|
86
|
-
await file.sync();
|
|
87
|
-
}
|
|
88
|
-
finally {
|
|
89
|
-
await file.close();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
94
|
-
try {
|
|
95
|
-
const file = await open(temporary, "wx", info?.mode ?? 0o600);
|
|
96
|
-
try {
|
|
97
|
-
await file.writeFile(next);
|
|
98
|
-
await file.sync();
|
|
99
|
-
}
|
|
100
|
-
finally {
|
|
101
|
-
await file.close();
|
|
102
|
-
}
|
|
103
|
-
const current = await readFile(path, "utf8").catch((error) => { if (missing(error))
|
|
104
|
-
return null; throw error; });
|
|
105
|
-
if (current !== original)
|
|
106
|
-
throw new Error(`Configuration changed during installation: ${path}`);
|
|
107
|
-
await rename(temporary, path);
|
|
108
|
-
}
|
|
109
|
-
finally {
|
|
110
|
-
await rm(temporary, { force: true });
|
|
111
|
-
}
|
|
112
|
-
}, { lockPath: `${path}.cohub-lock` });
|
|
113
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { posix, win32 } from "node:path";
|
|
2
|
-
/** Whether a native path is the root itself or one of its descendants. */
|
|
3
|
-
export function containsNativePath(root, path, platform = process.platform) {
|
|
4
|
-
const paths = platform === "win32" ? win32 : posix;
|
|
5
|
-
const relative = paths.relative(root, path);
|
|
6
|
-
return relative === "" || relative !== ".." && !relative.startsWith(`..${paths.sep}`) && !paths.isAbsolute(relative);
|
|
7
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/** Bumped when the daemon and the extension must be installed together. */
|
|
2
|
-
export declare const COHUB_PI_PROTOCOL = 1;
|
|
3
|
-
type PiContext = {
|
|
4
|
-
cwd: string;
|
|
5
|
-
sessionManager: {
|
|
6
|
-
getSessionFile(): string | undefined;
|
|
7
|
-
getSessionId(): string;
|
|
8
|
-
};
|
|
9
|
-
isIdle(): boolean;
|
|
10
|
-
abort(): void;
|
|
11
|
-
modelRegistry?: {
|
|
12
|
-
find(provider: string, id: string): unknown;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
type Content = string | Array<{
|
|
16
|
-
type: "text";
|
|
17
|
-
text: string;
|
|
18
|
-
} | {
|
|
19
|
-
type: "image";
|
|
20
|
-
data: string;
|
|
21
|
-
mimeType: string;
|
|
22
|
-
}>;
|
|
23
|
-
type Pi = {
|
|
24
|
-
on(event: string, handler: (event: unknown, context: PiContext) => unknown): void;
|
|
25
|
-
sendUserMessage(content: Content, options?: {
|
|
26
|
-
deliverAs?: "steer" | "followUp";
|
|
27
|
-
}): void;
|
|
28
|
-
appendEntry(customType: string, data?: unknown): void;
|
|
29
|
-
setModel?(model: unknown): Promise<boolean> | boolean;
|
|
30
|
-
setThinkingLevel?(level: string): void;
|
|
31
|
-
};
|
|
32
|
-
/** Runtime directory shared with the CLI; one socket per bound directory, hashed to stay short. */
|
|
33
|
-
export declare function controlSocketPath(root: string): string;
|
|
34
|
-
export declare function forwardedEvent(name: string, event: unknown): Record<string, unknown>;
|
|
35
|
-
export default function cohub(pi: Pi): void;
|
|
36
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Version } from "./version.js";
|
|
2
|
-
/**
|
|
3
|
-
* Oldest Pi whose extension API Cohub relies on (`agent_settled`, `appendEntry`, steer and follow-
|
|
4
|
-
* up delivery).
|
|
5
|
-
*/
|
|
6
|
-
export declare const PI_MIN_VERSION: Version;
|
|
7
|
-
/** Delivered to a session's subscribers when its Pi goes away. */
|
|
8
|
-
export declare const PI_DISCONNECTED = "cohub_disconnected";
|
|
9
|
-
/** A Pi process that is connected and can be driven: a terminal session or one Cohub started. */
|
|
10
|
-
export type PiSessionLink = {
|
|
11
|
-
pid: number;
|
|
12
|
-
cwd: string;
|
|
13
|
-
sessionId: string;
|
|
14
|
-
sessionFile: string | null;
|
|
15
|
-
idle: boolean;
|
|
16
|
-
settledAt: number;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* The Pi half of the control plane. Cohub never instructs Pi through a private channel it owns: the
|
|
20
|
-
* extension inside the running Pi process is the single interface, so a terminal session and one
|
|
21
|
-
* Cohub started behave identically.
|
|
22
|
-
*/
|
|
23
|
-
export declare class PiLink {
|
|
24
|
-
private readonly options;
|
|
25
|
-
private server;
|
|
26
|
-
unavailable: string | null;
|
|
27
|
-
private readonly sessions;
|
|
28
|
-
private readonly listeners;
|
|
29
|
-
private counter;
|
|
30
|
-
constructor(options: {
|
|
31
|
-
socketPath: string;
|
|
32
|
-
owns: (cwd: string) => boolean;
|
|
33
|
-
onEvent?: (session: PiSessionLink, event: Record<string, unknown>) => void;
|
|
34
|
-
onConnect?: (session: PiSessionLink) => void;
|
|
35
|
-
onDisconnect?: (session: PiSessionLink) => void;
|
|
36
|
-
/** A line over the limit was skipped; the connection stays up. */
|
|
37
|
-
onDroppedLine?: (sessionId: string | null, bytes: number) => void;
|
|
38
|
-
});
|
|
39
|
-
get socketPath(): string;
|
|
40
|
-
subscribe(sessionId: string, listener: (event: Record<string, unknown>) => void): () => void;
|
|
41
|
-
waitFor(match: {
|
|
42
|
-
sessionId: string;
|
|
43
|
-
sessionFile: string;
|
|
44
|
-
}, signal: AbortSignal, timeoutMs?: number): Promise<PiSessionLink>;
|
|
45
|
-
idle(sessionId: string, signal: AbortSignal): Promise<void>;
|
|
46
|
-
listen(signal: AbortSignal): Promise<void>;
|
|
47
|
-
list(): PiSessionLink[];
|
|
48
|
-
find(sessionId: string): PiSessionLink | null;
|
|
49
|
-
isStreaming(sessionId: string): boolean | null;
|
|
50
|
-
prompt(sessionId: string, input: {
|
|
51
|
-
turnId?: string;
|
|
52
|
-
content: unknown;
|
|
53
|
-
deliverAs?: "steer" | "followUp";
|
|
54
|
-
model?: {
|
|
55
|
-
provider: string;
|
|
56
|
-
id: string;
|
|
57
|
-
} | null;
|
|
58
|
-
thinkingLevel?: string | null;
|
|
59
|
-
env?: Record<string, string | null>;
|
|
60
|
-
}): Promise<{
|
|
61
|
-
accepted: boolean;
|
|
62
|
-
}>;
|
|
63
|
-
context(sessionId: string, env: Record<string, string | null>): Promise<void>;
|
|
64
|
-
abort(sessionId: string): Promise<void>;
|
|
65
|
-
close(): Promise<void>;
|
|
66
|
-
private request;
|
|
67
|
-
private accept;
|
|
68
|
-
private hello;
|
|
69
|
-
}
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { createServer } from "node:net";
|
|
3
|
-
import { chmod, mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
4
|
-
import { dirname } from "node:path";
|
|
5
|
-
import { COHUB_PI_PROTOCOL } from "./pi-extension.js";
|
|
6
|
-
const MAX_LINE_BYTES = 8 * 1024 * 1024;
|
|
7
|
-
const REQUEST_TIMEOUT_MS = 20 * 60_000;
|
|
8
|
-
/**
|
|
9
|
-
* Oldest Pi whose extension API Cohub relies on (`agent_settled`, `appendEntry`, steer and follow-
|
|
10
|
-
* up delivery).
|
|
11
|
-
*/
|
|
12
|
-
export const PI_MIN_VERSION = [0, 85, 1];
|
|
13
|
-
/** Delivered to a session's subscribers when its Pi goes away. */
|
|
14
|
-
export const PI_DISCONNECTED = "cohub_disconnected";
|
|
15
|
-
/**
|
|
16
|
-
* The Pi half of the control plane. Cohub never instructs Pi through a private channel it owns: the
|
|
17
|
-
* extension inside the running Pi process is the single interface, so a terminal session and one
|
|
18
|
-
* Cohub started behave identically.
|
|
19
|
-
*/
|
|
20
|
-
export class PiLink {
|
|
21
|
-
options;
|
|
22
|
-
server = null;
|
|
23
|
-
unavailable = null;
|
|
24
|
-
sessions = new Map();
|
|
25
|
-
listeners = new Map();
|
|
26
|
-
counter = 0;
|
|
27
|
-
constructor(options) {
|
|
28
|
-
this.options = options;
|
|
29
|
-
}
|
|
30
|
-
get socketPath() { return this.options.socketPath; }
|
|
31
|
-
subscribe(sessionId, listener) {
|
|
32
|
-
let set = this.listeners.get(sessionId);
|
|
33
|
-
if (!set) {
|
|
34
|
-
set = new Set();
|
|
35
|
-
this.listeners.set(sessionId, set);
|
|
36
|
-
}
|
|
37
|
-
set.add(listener);
|
|
38
|
-
return () => { set?.delete(listener); if (!set?.size)
|
|
39
|
-
this.listeners.delete(sessionId); };
|
|
40
|
-
}
|
|
41
|
-
async waitFor(match, signal, timeoutMs = 30_000) {
|
|
42
|
-
const deadline = Date.now() + timeoutMs;
|
|
43
|
-
while (Date.now() < deadline) {
|
|
44
|
-
signal.throwIfAborted();
|
|
45
|
-
const found = this.list().find((session) => session.sessionId === match.sessionId || session.sessionFile === match.sessionFile);
|
|
46
|
-
if (found)
|
|
47
|
-
return found;
|
|
48
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
49
|
-
}
|
|
50
|
-
throw new Error("Pi did not attach to the Runtime; check that the Cohub extension loads");
|
|
51
|
-
}
|
|
52
|
-
async idle(sessionId, signal) {
|
|
53
|
-
if (this.sessions.get(sessionId)?.idle !== false)
|
|
54
|
-
return;
|
|
55
|
-
await new Promise((resolve, reject) => {
|
|
56
|
-
const finish = (error) => { off(); signal.removeEventListener("abort", onAbort); if (error)
|
|
57
|
-
reject(error);
|
|
58
|
-
else
|
|
59
|
-
resolve(); };
|
|
60
|
-
const onAbort = () => finish(signal.reason instanceof Error ? signal.reason : new Error("Aborted"));
|
|
61
|
-
const off = this.subscribe(sessionId, (event) => {
|
|
62
|
-
if (event.type === "agent_settled")
|
|
63
|
-
finish();
|
|
64
|
-
if (event.type === PI_DISCONNECTED)
|
|
65
|
-
finish(new Error("Pi disconnected"));
|
|
66
|
-
});
|
|
67
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
async listen(signal) {
|
|
71
|
-
const { socketPath } = this.options;
|
|
72
|
-
const windows = process.platform === "win32";
|
|
73
|
-
// Windows named pipes share one global namespace: listen on a random name and
|
|
74
|
-
// publish it at socketPath, so another account cannot pre-claim the endpoint.
|
|
75
|
-
const endpoint = windows ? `\\\\.\\pipe\\cohub-pi-${randomUUID()}` : socketPath;
|
|
76
|
-
// The socket accepts commands that drive the user's agent: only this user may reach it.
|
|
77
|
-
await mkdir(dirname(socketPath), { recursive: true, mode: 0o700 });
|
|
78
|
-
if (!windows)
|
|
79
|
-
await chmod(dirname(socketPath), 0o700);
|
|
80
|
-
await rm(socketPath, { force: true });
|
|
81
|
-
const server = createServer((socket) => this.accept(socket));
|
|
82
|
-
await new Promise((resolve, reject) => {
|
|
83
|
-
server.once("error", reject);
|
|
84
|
-
server.listen(endpoint, () => { server.removeListener("error", reject); resolve(); });
|
|
85
|
-
});
|
|
86
|
-
if (windows) {
|
|
87
|
-
const temporary = `${socketPath}.${randomUUID()}.tmp`;
|
|
88
|
-
try {
|
|
89
|
-
await writeFile(temporary, endpoint, { mode: 0o600 });
|
|
90
|
-
await rename(temporary, socketPath);
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
server.close();
|
|
94
|
-
await rm(temporary, { force: true });
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else
|
|
99
|
-
await chmod(socketPath, 0o600);
|
|
100
|
-
this.server = server;
|
|
101
|
-
signal.addEventListener("abort", () => {
|
|
102
|
-
for (const session of this.sessions.values())
|
|
103
|
-
session.socket.destroy();
|
|
104
|
-
this.sessions.clear();
|
|
105
|
-
server.close();
|
|
106
|
-
void rm(socketPath, { force: true }).catch(() => undefined);
|
|
107
|
-
}, { once: true });
|
|
108
|
-
}
|
|
109
|
-
list() {
|
|
110
|
-
return [...this.sessions.values()].map(({ socket: _socket, pending: _pending, ...link }) => link);
|
|
111
|
-
}
|
|
112
|
-
find(sessionId) {
|
|
113
|
-
const live = this.sessions.get(sessionId);
|
|
114
|
-
if (!live)
|
|
115
|
-
return null;
|
|
116
|
-
const { socket: _socket, pending: _pending, ...link } = live;
|
|
117
|
-
return link;
|
|
118
|
-
}
|
|
119
|
-
isStreaming(sessionId) {
|
|
120
|
-
const live = this.sessions.get(sessionId);
|
|
121
|
-
return live ? !live.idle : null;
|
|
122
|
-
}
|
|
123
|
-
async prompt(sessionId, input) {
|
|
124
|
-
const result = await this.request(sessionId, { type: "prompt", ...input });
|
|
125
|
-
// A Cohub Turn is refused while the terminal runs one of its own; nothing was written then.
|
|
126
|
-
return { accepted: result?.accepted !== false };
|
|
127
|
-
}
|
|
128
|
-
async context(sessionId, env) {
|
|
129
|
-
await this.request(sessionId, { type: "context", env });
|
|
130
|
-
}
|
|
131
|
-
async abort(sessionId) {
|
|
132
|
-
await this.request(sessionId, { type: "abort" });
|
|
133
|
-
}
|
|
134
|
-
async close() {
|
|
135
|
-
for (const session of this.sessions.values())
|
|
136
|
-
session.socket.destroy();
|
|
137
|
-
this.sessions.clear();
|
|
138
|
-
await new Promise((resolve) => this.server?.close(() => resolve()) ?? resolve());
|
|
139
|
-
}
|
|
140
|
-
request(sessionId, command) {
|
|
141
|
-
const live = this.sessions.get(sessionId);
|
|
142
|
-
if (!live || live.socket.destroyed)
|
|
143
|
-
return Promise.reject(new Error("Pi is not connected"));
|
|
144
|
-
const id = `cohub-${++this.counter}`;
|
|
145
|
-
return new Promise((resolve, reject) => {
|
|
146
|
-
const timer = setTimeout(() => { live.pending.delete(id); reject(new Error("Pi did not answer in time")); }, REQUEST_TIMEOUT_MS);
|
|
147
|
-
live.pending.set(id, { resolve, reject, timer });
|
|
148
|
-
live.socket.write(`${JSON.stringify({ ...command, id })}\n`);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
accept(socket) {
|
|
152
|
-
/** The line being received; an oversized one is only counted, until its newline arrives. */
|
|
153
|
-
let parts = [];
|
|
154
|
-
let size = 0;
|
|
155
|
-
/** This connection's link; a newer connection for the same session replaces it in the map. */
|
|
156
|
-
let own = null;
|
|
157
|
-
const dropped = (bytes) => this.options.onDroppedLine?.(own?.sessionId ?? null, bytes);
|
|
158
|
-
socket.setNoDelay?.(true);
|
|
159
|
-
socket.on("error", () => socket.destroy());
|
|
160
|
-
socket.on("close", () => {
|
|
161
|
-
if (!own)
|
|
162
|
-
return;
|
|
163
|
-
const live = own;
|
|
164
|
-
for (const pending of live.pending.values()) {
|
|
165
|
-
clearTimeout(pending.timer);
|
|
166
|
-
pending.reject(new Error("Pi disconnected"));
|
|
167
|
-
}
|
|
168
|
-
live.pending.clear();
|
|
169
|
-
if (this.sessions.get(live.sessionId) !== live)
|
|
170
|
-
return;
|
|
171
|
-
this.sessions.delete(live.sessionId);
|
|
172
|
-
for (const listener of this.listeners.get(live.sessionId) ?? [])
|
|
173
|
-
listener({ type: PI_DISCONNECTED });
|
|
174
|
-
const { socket: _socket, pending: _pending, ...link } = live;
|
|
175
|
-
this.options.onDisconnect?.(link);
|
|
176
|
-
});
|
|
177
|
-
socket.on("data", (bytes) => {
|
|
178
|
-
for (let start = 0;;) {
|
|
179
|
-
const end = bytes.indexOf(0x0a, start);
|
|
180
|
-
const piece = bytes.subarray(start, end < 0 ? bytes.length : end);
|
|
181
|
-
size += piece.length;
|
|
182
|
-
if (size <= MAX_LINE_BYTES)
|
|
183
|
-
parts.push(piece);
|
|
184
|
-
else
|
|
185
|
-
parts = [];
|
|
186
|
-
if (end < 0)
|
|
187
|
-
return;
|
|
188
|
-
start = end + 1;
|
|
189
|
-
const length = size, kept = parts;
|
|
190
|
-
parts = [];
|
|
191
|
-
size = 0;
|
|
192
|
-
if (length > MAX_LINE_BYTES) {
|
|
193
|
-
dropped(length);
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
const line = Buffer.concat(kept, length).toString("utf8");
|
|
197
|
-
if (!line)
|
|
198
|
-
continue;
|
|
199
|
-
let message;
|
|
200
|
-
try {
|
|
201
|
-
message = JSON.parse(line);
|
|
202
|
-
}
|
|
203
|
-
catch {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
if (message.type === "hello") {
|
|
207
|
-
// One session per connection; a Pi that switches sessions reconnects.
|
|
208
|
-
const attached = own ? null : this.hello(socket, message);
|
|
209
|
-
if (!attached) {
|
|
210
|
-
socket.destroy();
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
own = attached;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
const live = own && this.sessions.get(own.sessionId) === own ? own : null;
|
|
217
|
-
if (!live)
|
|
218
|
-
continue;
|
|
219
|
-
if (message.type === "event") {
|
|
220
|
-
const event = (message.event ?? {});
|
|
221
|
-
if (event.type === "agent_start")
|
|
222
|
-
live.idle = false;
|
|
223
|
-
if (event.type === "agent_settled") {
|
|
224
|
-
live.idle = true;
|
|
225
|
-
live.settledAt = Date.now();
|
|
226
|
-
}
|
|
227
|
-
const { socket: _socket, pending: _pending, ...link } = live;
|
|
228
|
-
this.options.onEvent?.(link, event);
|
|
229
|
-
for (const listener of this.listeners.get(live.sessionId) ?? [])
|
|
230
|
-
listener(event);
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
const id = typeof message.id === "string" ? message.id : null;
|
|
234
|
-
const pending = id ? live.pending.get(id) : null;
|
|
235
|
-
if (!pending || !id)
|
|
236
|
-
continue;
|
|
237
|
-
live.pending.delete(id);
|
|
238
|
-
clearTimeout(pending.timer);
|
|
239
|
-
if (message.type === "error")
|
|
240
|
-
pending.reject(new Error(typeof message.message === "string" ? message.message : "Pi rejected the command"));
|
|
241
|
-
else
|
|
242
|
-
pending.resolve(message);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
hello(socket, message) {
|
|
247
|
-
if (message.protocol !== COHUB_PI_PROTOCOL)
|
|
248
|
-
return null;
|
|
249
|
-
const cwd = typeof message.cwd === "string" ? message.cwd : "";
|
|
250
|
-
const sessionId = typeof message.sessionId === "string" ? message.sessionId : "";
|
|
251
|
-
const pid = typeof message.pid === "number" ? message.pid : 0;
|
|
252
|
-
if (!sessionId || !this.options.owns(cwd))
|
|
253
|
-
return null;
|
|
254
|
-
const live = {
|
|
255
|
-
pid, cwd, sessionId,
|
|
256
|
-
sessionFile: typeof message.sessionFile === "string" ? message.sessionFile : null,
|
|
257
|
-
idle: message.idle !== false,
|
|
258
|
-
settledAt: message.idle !== false ? Date.now() : 0,
|
|
259
|
-
socket,
|
|
260
|
-
pending: new Map(),
|
|
261
|
-
};
|
|
262
|
-
// A Pi that reconnects after a Runtime restart replaces its stale link.
|
|
263
|
-
this.sessions.get(sessionId)?.socket.destroy();
|
|
264
|
-
this.sessions.set(sessionId, live);
|
|
265
|
-
const { socket: _socket, pending: _pending, ...link } = live;
|
|
266
|
-
this.options.onConnect?.(link);
|
|
267
|
-
return live;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type RuntimeExecutionEvent, type RuntimePendingExecution, type RuntimeTurnInput } from "@neta-art/cohub";
|
|
2
|
-
import type { NativeSession } from "./sessions.js";
|
|
3
|
-
export declare class ContextRequiredError extends Error {
|
|
4
|
-
}
|
|
5
|
-
type Receipt = {
|
|
6
|
-
version: 2;
|
|
7
|
-
requestId: string | null;
|
|
8
|
-
sessionId: string;
|
|
9
|
-
turnId: string;
|
|
10
|
-
session: NativeSession;
|
|
11
|
-
events?: RuntimeExecutionEvent[];
|
|
12
|
-
uncertainCleanup?: {
|
|
13
|
-
processGroupId: number;
|
|
14
|
-
error: string;
|
|
15
|
-
confirmedAt?: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export type RecoveredResult = {
|
|
19
|
-
session: NativeSession;
|
|
20
|
-
events: RuntimeExecutionEvent[];
|
|
21
|
-
};
|
|
22
|
-
/** One small receipt per Cohub-executed Turn until the server acknowledges its result. */
|
|
23
|
-
export declare class ExecutionResults {
|
|
24
|
-
private readonly root;
|
|
25
|
-
constructor(root: string);
|
|
26
|
-
private path;
|
|
27
|
-
private read;
|
|
28
|
-
/**
|
|
29
|
-
* Admit a new Turn. An unacknowledged earlier Turn is released once the server has settled it;
|
|
30
|
-
* otherwise the server must decide first, so a result is never overwritten unseen.
|
|
31
|
-
*/
|
|
32
|
-
admit(input: RuntimeTurnInput): Promise<string | null>;
|
|
33
|
-
start(session: NativeSession, input: Pick<RuntimeTurnInput, "sessionId" | "turnId">, requestId: string | null): Promise<void>;
|
|
34
|
-
record(session: NativeSession, input: Pick<RuntimeTurnInput, "sessionId" | "turnId">, requestId: string | null, events: RuntimeExecutionEvent[], uncertainCleanup?: Receipt["uncertainCleanup"]): Promise<void>;
|
|
35
|
-
recover(input: Pick<RuntimeTurnInput, "sessionId" | "turnId" | "harness">, requestId?: string): Promise<RecoveredResult | null>;
|
|
36
|
-
acknowledge(sessionId: string, turnId: string): Promise<void>;
|
|
37
|
-
pendingTurnIds(sessionId: string): Promise<string[]>;
|
|
38
|
-
pendingBatches(): AsyncGenerator<RuntimePendingExecution[]>;
|
|
39
|
-
private fromTranscript;
|
|
40
|
-
}
|
|
41
|
-
export {};
|