@neta-art/cohub-cli 10.24.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/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 -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,54 +0,0 @@
|
|
|
1
|
-
import { type LocalHarness, type HarnessArchive, type HarnessArchiveIndex, type RuntimeArchivePage, type RuntimeArchiveUpload } from "@neta-art/cohub";
|
|
2
|
-
export type ArchiveTransport = {
|
|
3
|
-
fetchObject?: typeof fetch;
|
|
4
|
-
prepareRuntimeArchive(index: HarnessArchiveIndex, options?: {
|
|
5
|
-
signal?: AbortSignal;
|
|
6
|
-
}): Promise<{
|
|
7
|
-
uploads: RuntimeArchiveUpload[];
|
|
8
|
-
}>;
|
|
9
|
-
commitRuntimeArchive(index: HarnessArchiveIndex, options?: {
|
|
10
|
-
signal?: AbortSignal;
|
|
11
|
-
}): Promise<{
|
|
12
|
-
ready: true;
|
|
13
|
-
}>;
|
|
14
|
-
getRuntimeArchive(sessionId: string, turnId: string, options?: {
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
}): Promise<RuntimeArchivePage>;
|
|
17
|
-
};
|
|
18
|
-
/** Raised when local capture bytes fail integrity checks (checksum, truncation, boundary); retryable via cache rebuild. */
|
|
19
|
-
export declare class ArchiveCaptureIntegrityError extends Error {
|
|
20
|
-
constructor(message: string);
|
|
21
|
-
}
|
|
22
|
-
export declare function checksumNativeFile(path: string): Promise<string>;
|
|
23
|
-
export declare function atomicRuntimeJson(path: string, value: unknown): Promise<void>;
|
|
24
|
-
/** Immutable local segments are the outbox. Model acknowledgements never remove them. */
|
|
25
|
-
export declare class RuntimeArchiveStore {
|
|
26
|
-
readonly root: string;
|
|
27
|
-
private readonly transport?;
|
|
28
|
-
private flushing;
|
|
29
|
-
private readonly capturing;
|
|
30
|
-
private errorReporter;
|
|
31
|
-
constructor(root: string, transport?: ArchiveTransport | null | undefined);
|
|
32
|
-
/** Distinguishes "no transport configured" from transient upload failures. */
|
|
33
|
-
get hasTransport(): boolean;
|
|
34
|
-
setErrorReporter(reporter: ((error: unknown, index?: HarnessArchiveIndex) => void) | null): void;
|
|
35
|
-
pendingCount(): Promise<number>;
|
|
36
|
-
failedCaptureCount(): Promise<number>;
|
|
37
|
-
hasCapture(turnId: string): Promise<boolean>;
|
|
38
|
-
private version;
|
|
39
|
-
private blob;
|
|
40
|
-
private saveBlob;
|
|
41
|
-
private readIndex;
|
|
42
|
-
stage(state: {
|
|
43
|
-
sessionId: string;
|
|
44
|
-
harness: LocalHarness;
|
|
45
|
-
nativeSessionId: string;
|
|
46
|
-
path: string;
|
|
47
|
-
sizeBytes?: number;
|
|
48
|
-
expectedChecksum?: string;
|
|
49
|
-
}, turnId: string): Promise<HarnessArchive>;
|
|
50
|
-
private capture;
|
|
51
|
-
flush(signal: AbortSignal): Promise<void>;
|
|
52
|
-
private drain;
|
|
53
|
-
restore(reference: HarnessArchive, target: string, signal?: AbortSignal): Promise<HarnessArchiveIndex>;
|
|
54
|
-
}
|
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { createReadStream } from "node:fs";
|
|
3
|
-
import { mkdir, open, readFile, readdir, rename, rm, stat, link } from "node:fs/promises";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import { LOCAL_HARNESS_SPECS, RUNTIME_ARCHIVE_SEGMENT_BYTES, harnessArchiveIndexSchema, validateArchiveBoundary, } from "@neta-art/cohub";
|
|
6
|
-
const missing = (error) => error?.code === "ENOENT";
|
|
7
|
-
/** Raised when local capture bytes fail integrity checks (checksum, truncation, boundary); retryable via cache rebuild. */
|
|
8
|
-
export class ArchiveCaptureIntegrityError extends Error {
|
|
9
|
-
constructor(message) { super(message); this.name = "ArchiveCaptureIntegrityError"; }
|
|
10
|
-
}
|
|
11
|
-
const hash = (bytes, algorithm = "sha256") => createHash(algorithm).update(bytes).digest("hex");
|
|
12
|
-
export async function checksumNativeFile(path) {
|
|
13
|
-
const digest = createHash("sha256");
|
|
14
|
-
for await (const bytes of createReadStream(path))
|
|
15
|
-
digest.update(bytes);
|
|
16
|
-
return digest.digest("hex");
|
|
17
|
-
}
|
|
18
|
-
export async function atomicRuntimeJson(path, value) {
|
|
19
|
-
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
20
|
-
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
21
|
-
try {
|
|
22
|
-
const file = await open(temporary, "wx", 0o600);
|
|
23
|
-
try {
|
|
24
|
-
await file.writeFile(JSON.stringify(value));
|
|
25
|
-
await file.sync();
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
await file.close();
|
|
29
|
-
}
|
|
30
|
-
await rename(temporary, path);
|
|
31
|
-
if (process.platform !== "win32") {
|
|
32
|
-
const directory = await open(dirname(path), "r");
|
|
33
|
-
try {
|
|
34
|
-
await directory.sync();
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
await directory.close();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
await rm(temporary, { force: true });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/** Immutable local segments are the outbox. Model acknowledgements never remove them. */
|
|
46
|
-
export class RuntimeArchiveStore {
|
|
47
|
-
root;
|
|
48
|
-
transport;
|
|
49
|
-
flushing = null;
|
|
50
|
-
capturing = new Map();
|
|
51
|
-
errorReporter = null;
|
|
52
|
-
constructor(root, transport) {
|
|
53
|
-
this.root = root;
|
|
54
|
-
this.transport = transport;
|
|
55
|
-
}
|
|
56
|
-
/** Distinguishes "no transport configured" from transient upload failures. */
|
|
57
|
-
get hasTransport() { return this.transport != null; }
|
|
58
|
-
setErrorReporter(reporter) {
|
|
59
|
-
this.errorReporter = reporter;
|
|
60
|
-
}
|
|
61
|
-
async pendingCount() {
|
|
62
|
-
const pending = new Set();
|
|
63
|
-
for (const directory of ["pending", "captures"]) {
|
|
64
|
-
const names = await readdir(join(this.root, directory)).catch((error) => { if (missing(error))
|
|
65
|
-
return []; throw error; });
|
|
66
|
-
for (const name of names)
|
|
67
|
-
if (name.endsWith(".json"))
|
|
68
|
-
pending.add(name);
|
|
69
|
-
}
|
|
70
|
-
return pending.size;
|
|
71
|
-
}
|
|
72
|
-
async failedCaptureCount() {
|
|
73
|
-
const names = await readdir(join(this.root, "failed", "captures")).catch((error) => { if (missing(error))
|
|
74
|
-
return []; throw error; });
|
|
75
|
-
return names.filter((name) => name.endsWith(".json")).length;
|
|
76
|
-
}
|
|
77
|
-
async hasCapture(turnId) { return Boolean(await this.readIndex(this.version(turnId))); }
|
|
78
|
-
version(turnId) { return join(this.root, "versions", `${turnId}.json`); }
|
|
79
|
-
blob(sha) { return join(this.root, "objects", sha); }
|
|
80
|
-
async saveBlob(sha, bytes) {
|
|
81
|
-
await mkdir(join(this.root, "objects"), { recursive: true, mode: 0o700 });
|
|
82
|
-
const target = this.blob(sha), temporary = `${target}.${randomUUID()}.tmp`;
|
|
83
|
-
try {
|
|
84
|
-
const output = await open(temporary, "wx", 0o600);
|
|
85
|
-
try {
|
|
86
|
-
await output.writeFile(bytes);
|
|
87
|
-
await output.sync();
|
|
88
|
-
}
|
|
89
|
-
finally {
|
|
90
|
-
await output.close();
|
|
91
|
-
}
|
|
92
|
-
await link(temporary, target).catch((error) => { if (error.code !== "EEXIST")
|
|
93
|
-
throw error; });
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
await rm(temporary, { force: true });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async readIndex(path) {
|
|
100
|
-
try {
|
|
101
|
-
return harnessArchiveIndexSchema.parse(JSON.parse(await readFile(path, "utf8")));
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (missing(error))
|
|
105
|
-
return null;
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
stage(state, turnId) {
|
|
110
|
-
const existing = this.capturing.get(turnId);
|
|
111
|
-
if (existing)
|
|
112
|
-
return existing;
|
|
113
|
-
const task = this.capture(state, turnId).finally(() => this.capturing.delete(turnId));
|
|
114
|
-
this.capturing.set(turnId, task);
|
|
115
|
-
return task;
|
|
116
|
-
}
|
|
117
|
-
async capture(state, turnId) {
|
|
118
|
-
const identity = { sessionId: state.sessionId, turnId, harness: state.harness };
|
|
119
|
-
const headPath = join(this.root, "heads", `${state.sessionId}.${state.harness}.json`);
|
|
120
|
-
const saved = await this.readIndex(this.version(turnId));
|
|
121
|
-
if (saved) {
|
|
122
|
-
if (saved.sessionId !== state.sessionId || saved.harness !== state.harness)
|
|
123
|
-
throw new Error("Archive identity mismatch");
|
|
124
|
-
if (state.expectedChecksum && state.expectedChecksum !== saved.sha256)
|
|
125
|
-
throw new ArchiveCaptureIntegrityError("Native Turn bytes changed; original archive retained");
|
|
126
|
-
const committed = await stat(join(this.root, "ready", `${turnId}.json`)).catch((error) => { if (missing(error))
|
|
127
|
-
return null; throw error; });
|
|
128
|
-
if (!committed)
|
|
129
|
-
await atomicRuntimeJson(join(this.root, "pending", `${turnId}.json`), saved);
|
|
130
|
-
if (!await this.readIndex(headPath))
|
|
131
|
-
await atomicRuntimeJson(headPath, saved);
|
|
132
|
-
return identity;
|
|
133
|
-
}
|
|
134
|
-
const previous = await this.readIndex(headPath);
|
|
135
|
-
const file = await open(state.path, "r");
|
|
136
|
-
let index;
|
|
137
|
-
try {
|
|
138
|
-
const before = await file.stat();
|
|
139
|
-
if (!before.isFile() || !before.size)
|
|
140
|
-
throw new ArchiveCaptureIntegrityError("Native archive is empty");
|
|
141
|
-
const sizeBytes = state.sizeBytes ?? before.size;
|
|
142
|
-
if (!Number.isSafeInteger(sizeBytes) || sizeBytes < 1 || sizeBytes > before.size)
|
|
143
|
-
throw new ArchiveCaptureIntegrityError("Native archive boundary is unavailable");
|
|
144
|
-
const buffer = Buffer.alloc(RUNTIME_ARCHIVE_SEGMENT_BYTES);
|
|
145
|
-
let offset = 0;
|
|
146
|
-
let digest = createHash("sha256");
|
|
147
|
-
let parent = null;
|
|
148
|
-
// Hash the old prefix, not just its size: equal-size and growing rewrites are valid.
|
|
149
|
-
if (previous && previous.nativeSessionId === state.nativeSessionId && previous.sizeBytes <= sizeBytes) {
|
|
150
|
-
while (offset < previous.sizeBytes) {
|
|
151
|
-
const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, previous.sizeBytes - offset), offset);
|
|
152
|
-
if (!bytesRead)
|
|
153
|
-
throw new Error("Native file changed during capture");
|
|
154
|
-
digest.update(buffer.subarray(0, bytesRead));
|
|
155
|
-
offset += bytesRead;
|
|
156
|
-
}
|
|
157
|
-
if (digest.copy().digest("hex") === previous.sha256)
|
|
158
|
-
parent = previous;
|
|
159
|
-
}
|
|
160
|
-
if (!parent) {
|
|
161
|
-
offset = 0;
|
|
162
|
-
digest = createHash("sha256");
|
|
163
|
-
}
|
|
164
|
-
const segments = [];
|
|
165
|
-
await mkdir(join(this.root, "objects"), { recursive: true, mode: 0o700 });
|
|
166
|
-
while (offset < sizeBytes) {
|
|
167
|
-
const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, sizeBytes - offset), offset);
|
|
168
|
-
if (!bytesRead)
|
|
169
|
-
throw new Error("Native file changed during capture");
|
|
170
|
-
const bytes = buffer.subarray(0, bytesRead);
|
|
171
|
-
digest.update(bytes);
|
|
172
|
-
const segment = { offset, sizeBytes: bytesRead, sha256: hash(bytes), md5: hash(bytes, "md5") };
|
|
173
|
-
await this.saveBlob(segment.sha256, bytes);
|
|
174
|
-
segments.push(segment);
|
|
175
|
-
offset += bytesRead;
|
|
176
|
-
}
|
|
177
|
-
const after = await stat(state.path);
|
|
178
|
-
if (before.ino !== after.ino || after.size < sizeBytes || state.sizeBytes === undefined && (before.size !== after.size || before.mtimeMs !== after.mtimeMs))
|
|
179
|
-
throw new ArchiveCaptureIntegrityError("Native file changed during capture");
|
|
180
|
-
if (state.sizeBytes !== undefined) {
|
|
181
|
-
// Native clients may append while an earlier Turn is captured. Validate the exact prefix twice.
|
|
182
|
-
const verified = createHash("sha256");
|
|
183
|
-
for await (const bytes of createReadStream(state.path, { end: sizeBytes - 1 }))
|
|
184
|
-
verified.update(bytes);
|
|
185
|
-
if (verified.digest("hex") !== digest.copy().digest("hex"))
|
|
186
|
-
throw new ArchiveCaptureIntegrityError("Native prefix changed during capture");
|
|
187
|
-
}
|
|
188
|
-
if (process.platform !== "win32") {
|
|
189
|
-
const directory = await open(join(this.root, "objects"), "r");
|
|
190
|
-
try {
|
|
191
|
-
await directory.sync();
|
|
192
|
-
}
|
|
193
|
-
finally {
|
|
194
|
-
await directory.close();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
index = harnessArchiveIndexSchema.parse({ ...identity, version: 1, nativeSessionId: state.nativeSessionId,
|
|
198
|
-
nativeFormat: LOCAL_HARNESS_SPECS[state.harness].nativeFormat, parentTurnId: parent?.turnId ?? null,
|
|
199
|
-
sizeBytes, sha256: digest.digest("hex"), segments });
|
|
200
|
-
validateArchiveBoundary(index, parent);
|
|
201
|
-
if (state.expectedChecksum && index.sha256 !== state.expectedChecksum)
|
|
202
|
-
throw new ArchiveCaptureIntegrityError("Native Turn bytes changed during capture; original retained");
|
|
203
|
-
}
|
|
204
|
-
finally {
|
|
205
|
-
await file.close();
|
|
206
|
-
}
|
|
207
|
-
// Publish the outbox before advancing the local head. Neither points at mutable files.
|
|
208
|
-
await atomicRuntimeJson(join(this.root, "pending", `${turnId}.json`), index);
|
|
209
|
-
await atomicRuntimeJson(this.version(turnId), index);
|
|
210
|
-
await atomicRuntimeJson(headPath, index);
|
|
211
|
-
return identity;
|
|
212
|
-
}
|
|
213
|
-
async flush(signal) {
|
|
214
|
-
if (!this.transport)
|
|
215
|
-
return;
|
|
216
|
-
if (this.flushing)
|
|
217
|
-
return this.flushing;
|
|
218
|
-
this.flushing = this.drain(signal).finally(() => { this.flushing = null; });
|
|
219
|
-
return this.flushing;
|
|
220
|
-
}
|
|
221
|
-
async drain(signal) {
|
|
222
|
-
const transport = this.transport;
|
|
223
|
-
if (!transport)
|
|
224
|
-
return;
|
|
225
|
-
const names = await readdir(join(this.root, "pending")).catch((error) => { if (missing(error))
|
|
226
|
-
return []; throw error; });
|
|
227
|
-
const pending = new Map();
|
|
228
|
-
for (const name of names) {
|
|
229
|
-
if (!name.endsWith(".json"))
|
|
230
|
-
continue;
|
|
231
|
-
const index = await this.readIndex(join(this.root, "pending", name));
|
|
232
|
-
if (index)
|
|
233
|
-
pending.set(index.turnId, index);
|
|
234
|
-
}
|
|
235
|
-
const children = new Map();
|
|
236
|
-
const queue = [];
|
|
237
|
-
for (const index of pending.values()) {
|
|
238
|
-
if (index.parentTurnId && pending.has(index.parentTurnId)) {
|
|
239
|
-
const siblings = children.get(index.parentTurnId) ?? [];
|
|
240
|
-
siblings.push(index);
|
|
241
|
-
children.set(index.parentTurnId, siblings);
|
|
242
|
-
}
|
|
243
|
-
else
|
|
244
|
-
queue.push(index);
|
|
245
|
-
}
|
|
246
|
-
if (pending.size && !queue.length)
|
|
247
|
-
throw new Error("Cyclic archive outbox");
|
|
248
|
-
for (let cursor = 0; cursor < queue.length; cursor++) {
|
|
249
|
-
signal.throwIfAborted();
|
|
250
|
-
const index = queue[cursor];
|
|
251
|
-
if (!index)
|
|
252
|
-
continue;
|
|
253
|
-
try {
|
|
254
|
-
const { uploads } = await transport.prepareRuntimeArchive(index, { signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]) });
|
|
255
|
-
if (uploads.length > index.segments.length)
|
|
256
|
-
throw new Error("Upload plan mismatch");
|
|
257
|
-
const expected = new Set(index.segments.map((segment) => JSON.stringify(segment)));
|
|
258
|
-
for (const { segment, uploadUrl, headers } of uploads) {
|
|
259
|
-
if (!expected.has(JSON.stringify(segment)))
|
|
260
|
-
throw new Error("Upload segment mismatch");
|
|
261
|
-
signal.throwIfAborted();
|
|
262
|
-
const bytes = await readFile(this.blob(segment.sha256));
|
|
263
|
-
if (bytes.length !== segment.sizeBytes || hash(bytes) !== segment.sha256)
|
|
264
|
-
throw new Error("Local archive segment is corrupt");
|
|
265
|
-
const response = await (transport.fetchObject ?? fetch)(uploadUrl, { method: "PUT", headers, body: bytes, redirect: "error", signal: AbortSignal.any([signal, AbortSignal.timeout(60_000)]) });
|
|
266
|
-
// An immutable segment may already exist after a lost acknowledgement. Commit verifies it.
|
|
267
|
-
if (!response.ok && ![409, 412].includes(response.status))
|
|
268
|
-
throw new Error(`Archive upload failed: ${response.status}`);
|
|
269
|
-
}
|
|
270
|
-
await transport.commitRuntimeArchive(index, { signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]) });
|
|
271
|
-
await atomicRuntimeJson(join(this.root, "ready", `${index.turnId}.json`), { turnId: index.turnId, sha256: index.sha256 });
|
|
272
|
-
await rm(join(this.root, "pending", `${index.turnId}.json`), { force: true });
|
|
273
|
-
queue.push(...children.get(index.turnId) ?? []);
|
|
274
|
-
}
|
|
275
|
-
catch (error) {
|
|
276
|
-
if (!signal.aborted) {
|
|
277
|
-
this.errorReporter?.(error, index);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
async restore(reference, target, signal) {
|
|
283
|
-
if (!this.transport)
|
|
284
|
-
throw new Error("Archive transport unavailable");
|
|
285
|
-
const timeout = (ms) => signal ? AbortSignal.any([signal, AbortSignal.timeout(ms)]) : AbortSignal.timeout(ms);
|
|
286
|
-
const pages = [];
|
|
287
|
-
const visited = new Set();
|
|
288
|
-
let turnId = reference.turnId;
|
|
289
|
-
while (turnId) {
|
|
290
|
-
signal?.throwIfAborted();
|
|
291
|
-
if (visited.has(turnId))
|
|
292
|
-
throw new Error("Cyclic archive");
|
|
293
|
-
visited.add(turnId);
|
|
294
|
-
const page = await this.transport.getRuntimeArchive(reference.sessionId, turnId, { signal: timeout(30_000) });
|
|
295
|
-
const index = harnessArchiveIndexSchema.parse(page.index);
|
|
296
|
-
if (index.turnId !== turnId || index.sessionId !== reference.sessionId || index.harness !== reference.harness)
|
|
297
|
-
throw new Error("Archive identity mismatch");
|
|
298
|
-
pages.push({ ...page, index });
|
|
299
|
-
turnId = index.parentTurnId;
|
|
300
|
-
}
|
|
301
|
-
const head = pages[0]?.index;
|
|
302
|
-
if (!head)
|
|
303
|
-
throw new Error("Archive missing");
|
|
304
|
-
await mkdir(dirname(target), { recursive: true, mode: 0o700 });
|
|
305
|
-
const temporary = `${target}.${randomUUID()}.restoring`;
|
|
306
|
-
const file = await open(temporary, "wx", 0o600);
|
|
307
|
-
try {
|
|
308
|
-
let parent = null;
|
|
309
|
-
const digest = createHash("sha256");
|
|
310
|
-
for (const page of pages.reverse()) {
|
|
311
|
-
validateArchiveBoundary(page.index, parent);
|
|
312
|
-
if (page.segments.length !== page.index.segments.length)
|
|
313
|
-
throw new Error("Missing archive segments");
|
|
314
|
-
for (const [ordinal, expected] of page.index.segments.entries()) {
|
|
315
|
-
signal?.throwIfAborted();
|
|
316
|
-
const cached = await readFile(this.blob(expected.sha256)).catch((error) => { if (missing(error))
|
|
317
|
-
return null; throw error; });
|
|
318
|
-
if (cached) {
|
|
319
|
-
if (cached.length !== expected.sizeBytes || hash(cached) !== expected.sha256)
|
|
320
|
-
throw new Error("Cached archive segment is corrupt");
|
|
321
|
-
digest.update(cached);
|
|
322
|
-
await file.writeFile(cached);
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
let link = page.segments[ordinal];
|
|
326
|
-
if (!link || JSON.stringify(link.segment) !== JSON.stringify(expected))
|
|
327
|
-
throw new Error("Archive segment identity mismatch");
|
|
328
|
-
let response = await (this.transport.fetchObject ?? fetch)(link.downloadUrl, { redirect: "error", signal: timeout(60_000) });
|
|
329
|
-
if ([401, 403].includes(response.status)) {
|
|
330
|
-
const refreshed = await this.transport.getRuntimeArchive(reference.sessionId, page.index.turnId, { signal: timeout(30_000) });
|
|
331
|
-
link = refreshed.segments[ordinal];
|
|
332
|
-
if (!link || JSON.stringify(link.segment) !== JSON.stringify(expected))
|
|
333
|
-
throw new Error("Archive segment missing");
|
|
334
|
-
response = await (this.transport.fetchObject ?? fetch)(link.downloadUrl, { redirect: "error", signal: timeout(60_000) });
|
|
335
|
-
}
|
|
336
|
-
if (!response.ok || !response.body)
|
|
337
|
-
throw new Error(`Archive download failed: ${response.status}`);
|
|
338
|
-
const segmentHash = createHash("sha256");
|
|
339
|
-
let size = 0;
|
|
340
|
-
const chunks = [];
|
|
341
|
-
for await (const chunk of response.body) {
|
|
342
|
-
size += chunk.length;
|
|
343
|
-
if (size > expected.sizeBytes)
|
|
344
|
-
throw new Error("Archive size mismatch");
|
|
345
|
-
chunks.push(chunk);
|
|
346
|
-
segmentHash.update(chunk);
|
|
347
|
-
digest.update(chunk);
|
|
348
|
-
await file.writeFile(chunk);
|
|
349
|
-
}
|
|
350
|
-
if (size !== expected.sizeBytes || segmentHash.digest("hex") !== expected.sha256)
|
|
351
|
-
throw new Error("Archive checksum mismatch");
|
|
352
|
-
await this.saveBlob(expected.sha256, Buffer.concat(chunks));
|
|
353
|
-
}
|
|
354
|
-
if (digest.copy().digest("hex") !== page.index.sha256)
|
|
355
|
-
throw new Error("Archive version checksum mismatch");
|
|
356
|
-
parent = page.index;
|
|
357
|
-
}
|
|
358
|
-
if ((await file.stat()).size !== head.sizeBytes)
|
|
359
|
-
throw new Error("Archive length mismatch");
|
|
360
|
-
await file.sync();
|
|
361
|
-
await file.close();
|
|
362
|
-
await link(temporary, target);
|
|
363
|
-
if (process.platform !== "win32") {
|
|
364
|
-
const directory = await open(dirname(target), "r");
|
|
365
|
-
try {
|
|
366
|
-
await directory.sync();
|
|
367
|
-
}
|
|
368
|
-
finally {
|
|
369
|
-
await directory.close();
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
return head;
|
|
373
|
-
}
|
|
374
|
-
finally {
|
|
375
|
-
await file.close();
|
|
376
|
-
await rm(temporary, { force: true });
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Puts this Runtime's own `cohub` last on PATH, so what it runs can always call the CLI while a
|
|
3
|
-
* `cohub` already on PATH (a global install that updates itself) still comes first.
|
|
4
|
-
*/
|
|
5
|
-
export declare function appendCliToPath(env?: NodeJS.ProcessEnv, node?: string, entry?: string): string;
|
package/dist/runtime/cli-path.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { delimiter, join } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
const ENTRY = fileURLToPath(new URL("../../bin/cohub.js", import.meta.url));
|
|
7
|
-
/**
|
|
8
|
-
* Puts this Runtime's own `cohub` last on PATH, so what it runs can always call the CLI while a
|
|
9
|
-
* `cohub` already on PATH (a global install that updates itself) still comes first.
|
|
10
|
-
*/
|
|
11
|
-
export function appendCliToPath(env = process.env, node = process.execPath, entry = ENTRY) {
|
|
12
|
-
const dir = join(homedir(), ".cache", "cohub", "cli", createHash("sha256").update(`${node}\0${entry}`).digest("hex").slice(0, 12));
|
|
13
|
-
const windows = process.platform === "win32";
|
|
14
|
-
const script = windows
|
|
15
|
-
? `@"${node}" "${entry}" %*\r\n`
|
|
16
|
-
: `#!/bin/sh\nexec ${quote(node)} ${quote(entry)} "$@"\n`;
|
|
17
|
-
mkdirSync(dir, { recursive: true });
|
|
18
|
-
const file = join(dir, windows ? "cohub.cmd" : "cohub");
|
|
19
|
-
const temporary = `${file}.${process.pid}`;
|
|
20
|
-
writeFileSync(temporary, script, { mode: 0o755 });
|
|
21
|
-
renameSync(temporary, file);
|
|
22
|
-
const path = env.PATH?.split(delimiter).filter(Boolean) ?? [];
|
|
23
|
-
if (!path.includes(dir))
|
|
24
|
-
env.PATH = [...path, dir].join(delimiter);
|
|
25
|
-
return dir;
|
|
26
|
-
}
|
|
27
|
-
const quote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RuntimeMessage } from "@neta-art/cohub";
|
|
2
|
-
declare const fields: readonly ["inputTokens", "outputTokens", "cachedInputTokens", "cacheWriteInputTokens", "totalTokens"];
|
|
3
|
-
export type CodexTokenTotals = Record<typeof fields[number], number>;
|
|
4
|
-
export declare const codexTokenTotals: (value: unknown) => CodexTokenTotals;
|
|
5
|
-
export declare const subtractCodexTokens: (total: CodexTokenTotals, base: CodexTokenTotals) => CodexTokenTotals;
|
|
6
|
-
export declare function codexUsage(total: CodexTokenTotals): NonNullable<RuntimeMessage["usage"]>;
|
|
7
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { record } from "./json-rpc.js";
|
|
2
|
-
const fields = ["inputTokens", "outputTokens", "cachedInputTokens", "cacheWriteInputTokens", "totalTokens"];
|
|
3
|
-
const tokens = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
4
|
-
export const codexTokenTotals = (value) => {
|
|
5
|
-
const input = record(value);
|
|
6
|
-
return Object.fromEntries(fields.map((key) => [key, tokens(input[key])]));
|
|
7
|
-
};
|
|
8
|
-
export const subtractCodexTokens = (total, base) => Object.fromEntries(fields.map((key) => [key, Math.max(0, total[key] - base[key])]));
|
|
9
|
-
export function codexUsage(total) {
|
|
10
|
-
return { input: Math.max(0, total.inputTokens - total.cachedInputTokens - total.cacheWriteInputTokens), output: total.outputTokens, cacheRead: total.cachedInputTokens, cacheWrite: total.cacheWriteInputTokens, totalTokens: total.totalTokens };
|
|
11
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type RuntimeNativeStop, type RuntimeApprovalDecision, type RuntimeCapabilities, type LocalHarness, type NativeRuntimeEvent } from "@neta-art/cohub";
|
|
2
|
-
import { type Executor, type HarnessResult } from "./native/execution.js";
|
|
3
|
-
import { type RuntimeDiagnosticContext, type RuntimeDiagnostics } from "./diagnostics.js";
|
|
4
|
-
export type Execution = {
|
|
5
|
-
controller: AbortController;
|
|
6
|
-
promise: Promise<void>;
|
|
7
|
-
sessionId: string;
|
|
8
|
-
turnId: string;
|
|
9
|
-
harness: LocalHarness;
|
|
10
|
-
requestId?: string | null;
|
|
11
|
-
traceContext?: RuntimeDiagnosticContext["traceContext"];
|
|
12
|
-
result?: HarnessResult;
|
|
13
|
-
/** Started on a transport that has since closed; it keeps running and replays on a later one. */
|
|
14
|
-
detached?: boolean;
|
|
15
|
-
/** Only replays a saved result for its connection; it does no local work and ends with that connection. */
|
|
16
|
-
recovery?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export type RuntimeConnectionOptions = {
|
|
19
|
-
spaceId: string;
|
|
20
|
-
cwd: string;
|
|
21
|
-
url: string;
|
|
22
|
-
capabilities: RuntimeCapabilities;
|
|
23
|
-
/** Rediscovers the catalog; a change is published to the registration without restarting. */
|
|
24
|
-
refreshCapabilities?: (current: RuntimeCapabilities) => Promise<RuntimeCapabilities>;
|
|
25
|
-
capabilitiesRefreshMs?: number;
|
|
26
|
-
token: (forceRefresh?: boolean) => Promise<string>;
|
|
27
|
-
signal: AbortSignal;
|
|
28
|
-
executor: Executor;
|
|
29
|
-
onReady: () => void;
|
|
30
|
-
onDisconnected?: () => void;
|
|
31
|
-
runtimeId?: string;
|
|
32
|
-
diagnostics?: RuntimeDiagnostics;
|
|
33
|
-
leaseConflictTimeoutMs?: number;
|
|
34
|
-
onNativeChannel?: (send: (event: NativeRuntimeEvent) => Promise<unknown>, features: {
|
|
35
|
-
approvals: boolean;
|
|
36
|
-
}) => void;
|
|
37
|
-
/** The web asked to stop a Turn; one running in a native client is stopped there. */
|
|
38
|
-
onNativeStop?: (stop: RuntimeNativeStop) => void;
|
|
39
|
-
onApprovalDecision?: (decision: RuntimeApprovalDecision) => void;
|
|
40
|
-
executions?: Map<string, Execution>;
|
|
41
|
-
};
|
|
42
|
-
export declare function serveRuntime(options: RuntimeConnectionOptions): Promise<void>;
|