@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,142 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { createReadStream } from "node:fs";
|
|
3
|
-
import { link, mkdir, open, rm } from "node:fs/promises";
|
|
4
|
-
import { dirname } from "node:path";
|
|
5
|
-
import { RUNTIME_MAX_FRAME_BYTES } from "@neta-art/cohub";
|
|
6
|
-
/** A structurally unrestorable archive (e.g. its history reference is not carried); never retried. */
|
|
7
|
-
export class ArchiveNotRestorableError extends Error {
|
|
8
|
-
constructor(message) { super(message); this.name = "ArchiveNotRestorableError"; }
|
|
9
|
-
}
|
|
10
|
-
const NEWLINE = Buffer.from("\n");
|
|
11
|
-
const SESSION_ID_KEY = Buffer.from('"sessionId"');
|
|
12
|
-
/** End of the JSON string starting at `start`, or -1 when the line ends inside it. */
|
|
13
|
-
function stringEnd(line, start) {
|
|
14
|
-
for (let index = start + 1; index < line.length; index++) {
|
|
15
|
-
if (line[index] === 0x5c)
|
|
16
|
-
index++;
|
|
17
|
-
else if (line[index] === 0x22)
|
|
18
|
-
return index;
|
|
19
|
-
}
|
|
20
|
-
return -1;
|
|
21
|
-
}
|
|
22
|
-
const skipSpace = (line, index) => {
|
|
23
|
-
while ([0x20, 0x09, 0x0d].includes(line[index] ?? -1))
|
|
24
|
-
index++;
|
|
25
|
-
return index;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Replace the top-level `sessionId` string of one JSON line; every other byte, including numbers a
|
|
29
|
-
* parser would round and lines that are not JSON, is kept as written. Structural JSON bytes are
|
|
30
|
-
* ASCII, which UTF-8 never uses inside a multi-byte character, so bytes are scanned directly.
|
|
31
|
-
*/
|
|
32
|
-
function rebindLine(line, sessionId) {
|
|
33
|
-
let depth = 0;
|
|
34
|
-
for (let index = 0; index < line.length; index++) {
|
|
35
|
-
const byte = line[index];
|
|
36
|
-
if (byte === 0x22) {
|
|
37
|
-
const end = stringEnd(line, index);
|
|
38
|
-
if (end < 0)
|
|
39
|
-
return line;
|
|
40
|
-
const colon = skipSpace(line, end + 1);
|
|
41
|
-
if (depth === 1 && line[colon] === 0x3a && line.subarray(index, end + 1).equals(SESSION_ID_KEY)) {
|
|
42
|
-
const value = skipSpace(line, colon + 1);
|
|
43
|
-
const valueEnd = line[value] === 0x22 ? stringEnd(line, value) : -1;
|
|
44
|
-
if (valueEnd < 0)
|
|
45
|
-
return line;
|
|
46
|
-
return Buffer.concat([line.subarray(0, value), Buffer.from(JSON.stringify(sessionId)), line.subarray(valueEnd + 1)]);
|
|
47
|
-
}
|
|
48
|
-
index = end;
|
|
49
|
-
}
|
|
50
|
-
else if (byte === 0x7b || byte === 0x5b)
|
|
51
|
-
depth++;
|
|
52
|
-
else if (byte === 0x7d || byte === 0x5d)
|
|
53
|
-
depth--;
|
|
54
|
-
}
|
|
55
|
-
return line;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Create a working copy of raw archive bytes. The header line may be rewritten, or with `sessionId`
|
|
59
|
-
* the top-level session id of every line; the target is created exclusively, so an existing native
|
|
60
|
-
* file is never replaced.
|
|
61
|
-
*/
|
|
62
|
-
export async function copyNativeArchive(input) {
|
|
63
|
-
await mkdir(dirname(input.target), { recursive: true, mode: 0o700 });
|
|
64
|
-
const temporary = `${input.target}.${randomUUID()}.importing`;
|
|
65
|
-
const file = await open(temporary, "wx", 0o600);
|
|
66
|
-
const digest = createHash("sha256");
|
|
67
|
-
let headerReady = !input.header, headerBytes = 0;
|
|
68
|
-
const fragments = [];
|
|
69
|
-
const write = async (bytes) => { digest.update(bytes); await file.writeFile(bytes); };
|
|
70
|
-
const writeHeader = async () => {
|
|
71
|
-
const header = input.header?.(JSON.parse(Buffer.concat(fragments).toString("utf8")));
|
|
72
|
-
await write(Buffer.from(`${JSON.stringify(header)}\n`));
|
|
73
|
-
fragments.length = 0;
|
|
74
|
-
headerReady = true;
|
|
75
|
-
};
|
|
76
|
-
try {
|
|
77
|
-
if (input.sessionId) {
|
|
78
|
-
const sessionId = input.sessionId;
|
|
79
|
-
const line = [];
|
|
80
|
-
let lineBytes = 0;
|
|
81
|
-
const flush = async (newline) => {
|
|
82
|
-
const bytes = Buffer.concat(line);
|
|
83
|
-
line.length = 0;
|
|
84
|
-
lineBytes = 0;
|
|
85
|
-
await write(Buffer.concat([rebindLine(bytes, sessionId), newline ? NEWLINE : Buffer.alloc(0)]));
|
|
86
|
-
};
|
|
87
|
-
for await (const chunk of createReadStream(input.source, { signal: input.signal })) {
|
|
88
|
-
let bytes = chunk;
|
|
89
|
-
for (let newline = bytes.indexOf(10); newline >= 0; newline = bytes.indexOf(10)) {
|
|
90
|
-
line.push(bytes.subarray(0, newline));
|
|
91
|
-
await flush(true);
|
|
92
|
-
bytes = bytes.subarray(newline + 1);
|
|
93
|
-
}
|
|
94
|
-
lineBytes += bytes.length;
|
|
95
|
-
if (lineBytes > RUNTIME_MAX_FRAME_BYTES)
|
|
96
|
-
throw new Error("Native record is too large");
|
|
97
|
-
if (bytes.length)
|
|
98
|
-
line.push(bytes);
|
|
99
|
-
}
|
|
100
|
-
if (line.length)
|
|
101
|
-
await flush(false);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
for await (const bytes of createReadStream(input.source, { signal: input.signal })) {
|
|
105
|
-
if (headerReady) {
|
|
106
|
-
await write(bytes);
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
const newline = bytes.indexOf(10);
|
|
110
|
-
const prefix = newline < 0 ? bytes : bytes.subarray(0, newline);
|
|
111
|
-
headerBytes += prefix.length;
|
|
112
|
-
if (headerBytes > RUNTIME_MAX_FRAME_BYTES)
|
|
113
|
-
throw new Error("Native header is too large");
|
|
114
|
-
fragments.push(prefix);
|
|
115
|
-
if (newline >= 0) {
|
|
116
|
-
await writeHeader();
|
|
117
|
-
await write(bytes.subarray(newline + 1));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (!headerReady)
|
|
121
|
-
await writeHeader();
|
|
122
|
-
}
|
|
123
|
-
input.signal?.throwIfAborted();
|
|
124
|
-
await file.sync();
|
|
125
|
-
await file.close();
|
|
126
|
-
await link(temporary, input.target);
|
|
127
|
-
if (process.platform !== "win32") {
|
|
128
|
-
const directory = await open(dirname(input.target), "r");
|
|
129
|
-
try {
|
|
130
|
-
await directory.sync();
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
await directory.close();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return { checksum: digest.digest("hex") };
|
|
137
|
-
}
|
|
138
|
-
finally {
|
|
139
|
-
await file.close();
|
|
140
|
-
await rm(temporary, { force: true });
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { HarnessExecutables } from "../harnesses/types.js";
|
|
2
|
-
import type { Harness } from "./adapters.js";
|
|
3
|
-
import { type NativeConfig } from "./config.js";
|
|
4
|
-
export type NativeSyncReport = {
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
harnesses: Harness[];
|
|
7
|
-
codexShared: boolean;
|
|
8
|
-
importHistory: boolean;
|
|
9
|
-
note?: string;
|
|
10
|
-
};
|
|
11
|
-
type Input = {
|
|
12
|
-
root: string;
|
|
13
|
-
spaceId: string;
|
|
14
|
-
identity: string;
|
|
15
|
-
harnesses: Harness[];
|
|
16
|
-
yes?: boolean;
|
|
17
|
-
executables?: HarnessExecutables;
|
|
18
|
-
};
|
|
19
|
-
type Ask = (question: string) => Promise<boolean>;
|
|
20
|
-
/** Whether this directory already syncs every requested harness. */
|
|
21
|
-
export declare function nativeSyncSatisfied(config: NativeConfig | null, input: {
|
|
22
|
-
spaceId: string;
|
|
23
|
-
root: string;
|
|
24
|
-
harnesses: Harness[];
|
|
25
|
-
}): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Enable native sync after consent. Native history may contain secrets, so nothing is read before
|
|
28
|
-
* the user agrees; a failure here never blocks the Runtime, it only leaves sessions read-only.
|
|
29
|
-
*/
|
|
30
|
-
export declare function ensureNativeSync(input: Input, log?: (line: string) => void, ask?: Ask): Promise<NativeSyncReport>;
|
|
31
|
-
/**
|
|
32
|
-
* Before any harness starts, repair what earlier releases installed: an outdated Pi extension can keep
|
|
33
|
-
* Pi from starting, and legacy Codex hooks run a script that is gone. Both had consent back then.
|
|
34
|
-
*/
|
|
35
|
-
export declare function repairIntegrations(piBinary: string | undefined, log?: (line: string) => void): Promise<void>;
|
|
36
|
-
export {};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { createInterface } from "node:readline/promises";
|
|
2
|
-
import { LOCAL_HARNESS_SPECS } from "@neta-art/cohub";
|
|
3
|
-
import { serializeDiagnosticError } from "../diagnostics.js";
|
|
4
|
-
import { CODEX_SHARED_MIN_VERSION, sharedServerAvailable, supportsSharedServer } from "./codex-link.js";
|
|
5
|
-
import { PI_MIN_VERSION } from "./pi-link.js";
|
|
6
|
-
import { atLeast, formatVersion, harnessVersion } from "./version.js";
|
|
7
|
-
import { readNativeConfig, runtimeStateRoot, writeNativeConfig } from "./config.js";
|
|
8
|
-
import { discoverTranscripts } from "./ingest.js";
|
|
9
|
-
import { installPiExtension, piExtensionState, removeLegacyCodexHooks } from "./install.js";
|
|
10
|
-
/** Whether this directory already syncs every requested harness. */
|
|
11
|
-
export function nativeSyncSatisfied(config, input) {
|
|
12
|
-
return Boolean(config && config.spaceId === input.spaceId && config.root === input.root && input.harnesses.every((harness) => config.harnesses.includes(harness)));
|
|
13
|
-
}
|
|
14
|
-
async function defaultAsk(question) {
|
|
15
|
-
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
16
|
-
try {
|
|
17
|
-
return /^(|y(es)?)$/i.test((await rl.question(question)).trim());
|
|
18
|
-
}
|
|
19
|
-
finally {
|
|
20
|
-
rl.close();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Enable native sync after consent. Native history may contain secrets, so nothing is read before
|
|
25
|
-
* the user agrees; a failure here never blocks the Runtime, it only leaves sessions read-only.
|
|
26
|
-
*/
|
|
27
|
-
export async function ensureNativeSync(input, log = (line) => process.stderr.write(line), ask = defaultAsk) {
|
|
28
|
-
if (!input.harnesses.length)
|
|
29
|
-
return { enabled: false, harnesses: [], codexShared: false, importHistory: false, note: "unsupported" };
|
|
30
|
-
const stateRoot = runtimeStateRoot(input.spaceId);
|
|
31
|
-
const previous = await readNativeConfig(stateRoot, input.identity).catch(() => null);
|
|
32
|
-
const alreadySynced = previous && nativeSyncSatisfied(previous, input);
|
|
33
|
-
const interactive = process.stdin.isTTY === true;
|
|
34
|
-
const confirm = async (question) => input.yes ? true : interactive ? await ask(question) : false;
|
|
35
|
-
if (!alreadySynced) {
|
|
36
|
-
if (!input.yes && !interactive) {
|
|
37
|
-
log("Native sync off · rerun interactively or with --yes to enable\n");
|
|
38
|
-
return { enabled: false, harnesses: input.harnesses, codexShared: false, importHistory: false, note: "non-interactive" };
|
|
39
|
-
}
|
|
40
|
-
const names = input.harnesses.map((harness) => LOCAL_HARNESS_SPECS[harness].label).join(" and ");
|
|
41
|
-
if (!await confirm(`Sync ${names} chats in this folder to this Space so they continue on the web? Their history may contain secrets. [Y/n] `)) {
|
|
42
|
-
return { enabled: false, harnesses: input.harnesses, codexShared: false, importHistory: false, note: "declined" };
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
let codexShared = previous?.codexShared ?? false;
|
|
46
|
-
if (input.harnesses.includes("codex") && !codexShared && (input.yes || interactive)) {
|
|
47
|
-
const version = await harnessVersion(input.executables?.codex || "codex");
|
|
48
|
-
if (!sharedServerAvailable) {
|
|
49
|
-
log("Shared Codex sessions are unavailable on Windows; terminal Codex chats sync read-only\n");
|
|
50
|
-
}
|
|
51
|
-
else if (!supportsSharedServer(version)) {
|
|
52
|
-
log(`Codex ${formatVersion(version)} predates the shared app-server (${CODEX_SHARED_MIN_VERSION.join(".")}+); terminal Codex chats sync read-only\n`);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
codexShared = await confirm("Let terminal Codex and the web drive the same live sessions? Cohub starts Codex's shared app-server, which keeps running in the background. [Y/n] ");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (previous && alreadySynced) {
|
|
59
|
-
if (codexShared !== previous.codexShared) {
|
|
60
|
-
await writeNativeConfig(stateRoot, { ...previous, codexShared }).catch((error) => {
|
|
61
|
-
log(`Shared Codex sessions unavailable; Runtime continues without them — ${serializeDiagnosticError(error).message}\n`);
|
|
62
|
-
codexShared = previous.codexShared;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
await maintain(previous, log, input.executables?.pi);
|
|
66
|
-
return { enabled: true, harnesses: previous.harnesses, codexShared, importHistory: false };
|
|
67
|
-
}
|
|
68
|
-
const harnesses = [...new Set([...(previous?.root === input.root ? previous.harnesses : []), ...input.harnesses])];
|
|
69
|
-
const config = {
|
|
70
|
-
version: 2, identity: input.identity, spaceId: input.spaceId, root: input.root, harnesses,
|
|
71
|
-
// History is whatever existed before the first consent for this directory.
|
|
72
|
-
enabledAt: previous?.root === input.root ? previous.enabledAt : new Date().toISOString(),
|
|
73
|
-
codexShared,
|
|
74
|
-
};
|
|
75
|
-
try {
|
|
76
|
-
await writeNativeConfig(stateRoot, config);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
log(`Native sync unavailable; Runtime continues without it — ${serializeDiagnosticError(error).message}\n`);
|
|
80
|
-
return { enabled: false, harnesses: input.harnesses, codexShared: false, importHistory: false, note: "config" };
|
|
81
|
-
}
|
|
82
|
-
await maintain(config, log, input.executables?.pi, true);
|
|
83
|
-
const history = (await discoverTranscripts(input.root, input.harnesses, { headers: true }).catch(() => []))
|
|
84
|
-
.filter((candidate) => candidate.mtimeMs < Date.parse(config.enabledAt)).length;
|
|
85
|
-
let importHistory = false;
|
|
86
|
-
if (history && !previous) {
|
|
87
|
-
importHistory = await confirm(`Import ${history} earlier conversation${history === 1 ? "" : "s"} from this folder? [Y/n] `);
|
|
88
|
-
if (!importHistory)
|
|
89
|
-
log("Import them later with cohub runtime import\n");
|
|
90
|
-
}
|
|
91
|
-
return { enabled: true, harnesses, codexShared, importHistory };
|
|
92
|
-
}
|
|
93
|
-
/** Keep integrations current on every `up`. */
|
|
94
|
-
async function maintain(config, log, piBinary, announce = false) {
|
|
95
|
-
if (config.harnesses.includes("pi"))
|
|
96
|
-
await maintainPiExtension(piBinary, log, announce);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Before any harness starts, repair what earlier releases installed: an outdated Pi extension can keep
|
|
100
|
-
* Pi from starting, and legacy Codex hooks run a script that is gone. Both had consent back then.
|
|
101
|
-
*/
|
|
102
|
-
export async function repairIntegrations(piBinary, log = (line) => process.stderr.write(line)) {
|
|
103
|
-
await removeLegacyCodexHooks().catch(() => undefined);
|
|
104
|
-
if (await piExtensionState().catch(() => null) === "outdated")
|
|
105
|
-
await maintainPiExtension(piBinary, log);
|
|
106
|
-
}
|
|
107
|
-
/** Pi without the extension still syncs, read-only. */
|
|
108
|
-
async function maintainPiExtension(piBinary, log, announce = false) {
|
|
109
|
-
const version = await harnessVersion(piBinary || "pi");
|
|
110
|
-
if (!atLeast(version, PI_MIN_VERSION)) {
|
|
111
|
-
log(`Pi ${formatVersion(version)} predates the Cohub extension (${PI_MIN_VERSION.join(".")}+); Pi chats sync read-only\n`);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
const state = await piExtensionState();
|
|
116
|
-
if (state === "installed")
|
|
117
|
-
return;
|
|
118
|
-
if (state === "foreign" || state === "missing" && !announce) {
|
|
119
|
-
log("Pi extension not installed; Pi chats sync read-only. Install with cohub runtime attach --harness pi\n");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
await installPiExtension();
|
|
123
|
-
log(state === "outdated" ? "Pi extension updated; run /reload in open Pi sessions\n" : "Pi extension installed; run /reload in open Pi sessions to connect them\n");
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
log(`Pi extension not installed — ${serializeDiagnosticError(error).message}; Pi chats sync read-only\n`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { type JsonRpcProcess, type JsonRecord } from "../json-rpc.js";
|
|
2
|
-
import { type Version } from "./version.js";
|
|
3
|
-
/** First Codex release whose terminal client attaches to a shared app-server by default. */
|
|
4
|
-
export declare const CODEX_SHARED_MIN_VERSION: Version;
|
|
5
|
-
/**
|
|
6
|
-
* A loaded thread holds Codex's per-thread writer lock, which Codex Desktop and other app-servers
|
|
7
|
-
* need to continue it. Long enough for an immediate follow-up Turn; honoured from Codex 0.164.
|
|
8
|
-
*/
|
|
9
|
-
export declare const CODEX_UNLOAD_DELAY_SECS = 10;
|
|
10
|
-
export type CodexEvent = {
|
|
11
|
-
method: string;
|
|
12
|
-
params: JsonRecord;
|
|
13
|
-
};
|
|
14
|
-
/** One JSON-RPC peer of an app-server, over either a shared control socket or a private stdio process. */
|
|
15
|
-
export interface CodexChannel {
|
|
16
|
-
request(method: string, params?: JsonRecord, timeoutMs?: number): Promise<JsonRecord>;
|
|
17
|
-
refuse(id: string | number, message: string): void;
|
|
18
|
-
respond(id: string | number, result: JsonRecord): void;
|
|
19
|
-
onEvent(listener: (event: CodexEvent & {
|
|
20
|
-
id?: string | number;
|
|
21
|
-
}) => void): () => void;
|
|
22
|
-
onClose(listener: (error: Error) => void): () => void;
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
readonly shared: boolean;
|
|
25
|
-
readonly closed: boolean;
|
|
26
|
-
/** The app-server's own version, which may differ from the binary on PATH. */
|
|
27
|
-
readonly version: Version | null;
|
|
28
|
-
}
|
|
29
|
-
/** Codex's shared server listens on an AF_UNIX socket, which Node cannot reach on Windows. */
|
|
30
|
-
export declare const sharedServerAvailable: boolean;
|
|
31
|
-
export declare const supportsSharedServer: (version: Version | null) => boolean;
|
|
32
|
-
/** Version of a shared app-server already running, which Cohub's Turns would use instead of the binary. */
|
|
33
|
-
export declare function runningSharedVersion(): Promise<Version | null>;
|
|
34
|
-
/** A private app-server over stdio, used when no shared one is available; it lives for one Turn. */
|
|
35
|
-
export declare function openPrivateServer(rpc: JsonRpcProcess): Promise<CodexChannel>;
|
|
36
|
-
/** The Runtime's connection to the shared app-server. */
|
|
37
|
-
export declare class CodexShared {
|
|
38
|
-
private readonly binary;
|
|
39
|
-
private readonly cwd;
|
|
40
|
-
enabled: boolean;
|
|
41
|
-
private channel;
|
|
42
|
-
private opening;
|
|
43
|
-
private ensured;
|
|
44
|
-
private readonly connectListeners;
|
|
45
|
-
private readonly releaseListeners;
|
|
46
|
-
readonly driving: Set<string>;
|
|
47
|
-
constructor(binary: string, cwd: string, enabled: boolean);
|
|
48
|
-
get(): Promise<CodexChannel | null>;
|
|
49
|
-
onConnect(listener: (channel: CodexChannel) => void): () => void;
|
|
50
|
-
onRelease(listener: (threadId: string) => void): () => void;
|
|
51
|
-
/** Drop this connection's subscription so an idle thread can unload and free its writer lock. */
|
|
52
|
-
release(threadId: string): Promise<void>;
|
|
53
|
-
join(threadId: string): Promise<JsonRecord | null>;
|
|
54
|
-
interrupt(threadId: string, turnId: string): Promise<boolean>;
|
|
55
|
-
close(): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
/** `userAgent` starts with `<client name>/<server version>`. */
|
|
58
|
-
export declare function userAgentVersion(userAgent: unknown): Version | null;
|
|
59
|
-
/** Resume a thread for a Cohub Turn, waiting out an unload in progress. */
|
|
60
|
-
export declare function resumeThread(channel: CodexChannel, params: JsonRecord): Promise<JsonRecord>;
|