@neta-art/cohub-cli 10.24.0 → 10.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cohub.js +4 -1
- package/dist/board-gpu/page.js +1566 -71230
- package/dist/bootstrap.js +67 -27
- package/dist/build.json +1 -1
- package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
- package/dist/chunks/about.js +102 -0
- package/dist/chunks/app-realtime.js +2216 -0
- package/dist/chunks/app-realtime2.js +2 -0
- package/dist/chunks/app-ref.js +88 -0
- package/dist/chunks/apps.js +1423 -0
- package/dist/chunks/auth.js +175 -0
- package/dist/chunks/avatar.js +146 -0
- package/dist/chunks/binary-pins.js +5 -0
- package/dist/chunks/board-export-resources.js +232 -0
- package/dist/chunks/board-export.js +874 -0
- package/dist/chunks/board-export2.js +2 -0
- package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
- package/dist/chunks/board-kernel2.js +4 -0
- package/dist/chunks/board-profile.js +69 -0
- package/dist/chunks/board-simulate.js +315 -0
- package/dist/chunks/board-time.js +34 -0
- package/dist/chunks/boards.js +1943 -0
- package/dist/{board-kernel → chunks}/browserAll.js +9 -8
- package/dist/chunks/channels.js +64 -0
- package/dist/chunks/client.js +12606 -0
- package/dist/chunks/command-input.js +17 -0
- package/dist/chunks/commander.js +2962 -0
- package/dist/chunks/cron-jobs.js +163 -0
- package/dist/chunks/daemon.js +545 -0
- package/dist/chunks/daemon2.js +2 -0
- package/dist/chunks/desktop.js +172 -0
- package/dist/chunks/endpoint-options.js +26 -0
- package/dist/chunks/env-proxy.js +35 -0
- package/dist/chunks/environment.js +154 -0
- package/dist/chunks/feedback.js +120 -0
- package/dist/chunks/generations.js +379 -0
- package/dist/chunks/host.js +9 -0
- package/dist/chunks/http-put.js +131 -0
- package/dist/chunks/id.js +2416 -0
- package/dist/{board-kernel → chunks}/init.js +1 -1
- package/dist/chunks/install.js +11959 -0
- package/dist/chunks/launch.js +374 -0
- package/dist/chunks/local-media.js +47 -0
- package/dist/chunks/me.js +134 -0
- package/dist/chunks/media.js +315 -0
- package/dist/chunks/models.js +242 -0
- package/dist/chunks/operands.js +46 -0
- package/dist/chunks/package-paths.js +13 -0
- package/dist/chunks/policy.js +221 -0
- package/dist/chunks/preferences.js +29 -0
- package/dist/chunks/profile.js +64 -0
- package/dist/chunks/prompts.js +41 -0
- package/dist/chunks/public.js +2 -0
- package/dist/chunks/public2.js +244 -0
- package/dist/chunks/references.js +197 -0
- package/dist/chunks/referrals.js +90 -0
- package/dist/chunks/rolldown-runtime.js +26 -0
- package/dist/chunks/rooms-connect.js +2 -0
- package/dist/chunks/rooms-connect2.js +151 -0
- package/dist/chunks/rooms-rtc.js +311 -0
- package/dist/chunks/rooms.js +211 -0
- package/dist/chunks/run.js +220 -0
- package/dist/chunks/runtime.js +638 -0
- package/dist/chunks/runtime2.js +286 -0
- package/dist/chunks/runtimes.js +48 -0
- package/dist/chunks/safe-remote-image.js +198 -0
- package/dist/chunks/schemas.js +6017 -0
- package/dist/chunks/search.js +113 -0
- package/dist/chunks/self-update.js +238 -0
- package/dist/chunks/serve.js +1246 -0
- package/dist/chunks/session-status.js +24 -0
- package/dist/chunks/skills.js +35 -0
- package/dist/chunks/spaces.js +5080 -0
- package/dist/chunks/src.js +405 -0
- package/dist/chunks/supervisor.js +2513 -0
- package/dist/chunks/supervisor2.js +2 -0
- package/dist/chunks/tasks.js +82 -0
- package/dist/chunks/themes.js +2898 -0
- package/dist/chunks/version.js +2 -0
- package/dist/chunks/version2.js +22 -0
- package/dist/chunks/version3.js +18 -0
- package/dist/chunks/web.js +7 -0
- package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
- package/dist/runtime/native/pi-extension.js +174 -166
- package/dist/runtime/worker.js +27 -16
- package/package.json +8 -9
- package/dist/about.d.ts +0 -2
- package/dist/about.js +0 -71
- package/dist/app-download.d.ts +0 -11
- package/dist/app-download.js +0 -252
- package/dist/app-ref.d.ts +0 -5
- package/dist/app-ref.js +0 -8
- package/dist/app-target.d.ts +0 -26
- package/dist/app-target.js +0 -55
- package/dist/auth.d.ts +0 -45
- package/dist/auth.js +0 -307
- package/dist/avatar.d.ts +0 -55
- package/dist/avatar.js +0 -104
- package/dist/board-command-support.d.ts +0 -6
- package/dist/board-command-support.js +0 -88
- package/dist/board-export-resources.d.ts +0 -12
- package/dist/board-export-resources.js +0 -51
- package/dist/board-export.d.ts +0 -110
- package/dist/board-export.js +0 -592
- package/dist/board-fonts.d.ts +0 -11
- package/dist/board-fonts.js +0 -10
- package/dist/board-gpu/daemon.d.ts +0 -11
- package/dist/board-gpu/daemon.js +0 -295
- package/dist/board-gpu/index.d.ts +0 -33
- package/dist/board-gpu/index.js +0 -189
- package/dist/board-gpu/protocol.d.ts +0 -77
- package/dist/board-gpu/protocol.js +0 -1
- package/dist/board-kernel.d.ts +0 -5
- package/dist/board-media-export.d.ts +0 -17
- package/dist/board-media-export.js +0 -164
- package/dist/board-media.d.ts +0 -5
- package/dist/board-media.js +0 -66
- package/dist/board-profile.d.ts +0 -21
- package/dist/board-profile.js +0 -67
- package/dist/board-simulate.d.ts +0 -67
- package/dist/board-simulate.js +0 -259
- package/dist/board-time.d.ts +0 -3
- package/dist/board-time.js +0 -34
- package/dist/bootstrap.d.ts +0 -2
- package/dist/client.d.ts +0 -5
- package/dist/client.js +0 -24
- package/dist/command-input.d.ts +0 -4
- package/dist/command-input.js +0 -16
- package/dist/commands/app-commerce.d.ts +0 -2
- package/dist/commands/app-commerce.js +0 -228
- package/dist/commands/app-domains.d.ts +0 -2
- package/dist/commands/app-domains.js +0 -133
- package/dist/commands/apps.d.ts +0 -4
- package/dist/commands/apps.js +0 -827
- package/dist/commands/auth.d.ts +0 -2
- package/dist/commands/auth.js +0 -186
- package/dist/commands/boards/authoring.d.ts +0 -2
- package/dist/commands/boards/authoring.js +0 -166
- package/dist/commands/boards/examples.d.ts +0 -10
- package/dist/commands/boards/examples.js +0 -118
- package/dist/commands/boards.d.ts +0 -13
- package/dist/commands/boards.js +0 -836
- package/dist/commands/channels.d.ts +0 -2
- package/dist/commands/channels.js +0 -74
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -155
- package/dist/commands/decision.d.ts +0 -4
- package/dist/commands/decision.js +0 -113
- package/dist/commands/desktop.d.ts +0 -10
- package/dist/commands/desktop.js +0 -233
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -131
- package/dist/commands/generations.d.ts +0 -2
- package/dist/commands/generations.js +0 -427
- package/dist/commands/host.d.ts +0 -2
- package/dist/commands/host.js +0 -11
- package/dist/commands/me.d.ts +0 -2
- package/dist/commands/me.js +0 -121
- package/dist/commands/models.d.ts +0 -28
- package/dist/commands/models.js +0 -271
- package/dist/commands/profile.d.ts +0 -2
- package/dist/commands/profile.js +0 -81
- package/dist/commands/prompts.d.ts +0 -2
- package/dist/commands/prompts.js +0 -37
- package/dist/commands/public.d.ts +0 -20
- package/dist/commands/public.js +0 -291
- package/dist/commands/references.d.ts +0 -2
- package/dist/commands/references.js +0 -193
- package/dist/commands/referrals.d.ts +0 -2
- package/dist/commands/referrals.js +0 -88
- package/dist/commands/rooms-connect.d.ts +0 -17
- package/dist/commands/rooms-connect.js +0 -140
- package/dist/commands/rooms-rtc-binary.d.ts +0 -2
- package/dist/commands/rooms-rtc-binary.js +0 -107
- package/dist/commands/rooms-rtc.d.ts +0 -21
- package/dist/commands/rooms-rtc.js +0 -171
- package/dist/commands/rooms.d.ts +0 -3
- package/dist/commands/rooms.js +0 -277
- package/dist/commands/run.d.ts +0 -13
- package/dist/commands/run.js +0 -246
- package/dist/commands/runtime.d.ts +0 -3
- package/dist/commands/runtime.js +0 -320
- package/dist/commands/sandboxd-binary.d.ts +0 -11
- package/dist/commands/sandboxd-binary.js +0 -238
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -114
- package/dist/commands/session-access.d.ts +0 -2
- package/dist/commands/session-access.js +0 -70
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -34
- package/dist/commands/space-activity.d.ts +0 -26
- package/dist/commands/space-activity.js +0 -147
- package/dist/commands/space-commerce.d.ts +0 -2
- package/dist/commands/space-commerce.js +0 -514
- package/dist/commands/space-displays.d.ts +0 -2
- package/dist/commands/space-displays.js +0 -620
- package/dist/commands/space-files.d.ts +0 -5
- package/dist/commands/space-files.js +0 -215
- package/dist/commands/space-invitations.d.ts +0 -29
- package/dist/commands/space-invitations.js +0 -189
- package/dist/commands/space-turns.d.ts +0 -49
- package/dist/commands/space-turns.js +0 -205
- package/dist/commands/space-wallet.d.ts +0 -2
- package/dist/commands/space-wallet.js +0 -141
- package/dist/commands/space-webhooks.d.ts +0 -7
- package/dist/commands/space-webhooks.js +0 -73
- package/dist/commands/spaces.d.ts +0 -25
- package/dist/commands/spaces.js +0 -2170
- package/dist/commands/tasks.d.ts +0 -8
- package/dist/commands/tasks.js +0 -80
- package/dist/commands/version.d.ts +0 -2
- package/dist/commands/version.js +0 -21
- package/dist/endpoint-options.d.ts +0 -4
- package/dist/endpoint-options.js +0 -26
- package/dist/env-proxy.d.ts +0 -5
- package/dist/env-proxy.js +0 -20
- package/dist/help-path.d.ts +0 -18
- package/dist/help-path.js +0 -223
- package/dist/host/auth.d.ts +0 -20
- package/dist/host/auth.js +0 -119
- package/dist/host/login-env.d.ts +0 -1
- package/dist/host/login-env.js +0 -31
- package/dist/host/runtime.d.ts +0 -35
- package/dist/host/runtime.js +0 -395
- package/dist/host/runtimes.d.ts +0 -9
- package/dist/host/runtimes.js +0 -42
- package/dist/host/serve.d.ts +0 -2
- package/dist/host/serve.js +0 -117
- package/dist/host/workspaces.d.ts +0 -2
- package/dist/host/workspaces.js +0 -18
- package/dist/http-put.d.ts +0 -25
- package/dist/http-put.js +0 -132
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/launcher.d.ts +0 -4
- package/dist/launcher.js +0 -38
- package/dist/local-media.d.ts +0 -2
- package/dist/local-media.js +0 -30
- package/dist/network-error.d.ts +0 -3
- package/dist/network-error.js +0 -22
- package/dist/output.d.ts +0 -46
- package/dist/output.js +0 -244
- package/dist/runtime/archive-store.d.ts +0 -54
- package/dist/runtime/archive-store.js +0 -379
- package/dist/runtime/cli-path.d.ts +0 -5
- package/dist/runtime/cli-path.js +0 -27
- package/dist/runtime/codex-usage.d.ts +0 -7
- package/dist/runtime/codex-usage.js +0 -11
- package/dist/runtime/connection.d.ts +0 -42
- package/dist/runtime/connection.js +0 -789
- package/dist/runtime/diagnostics.d.ts +0 -107
- package/dist/runtime/diagnostics.js +0 -392
- package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
- package/dist/runtime/harnesses/chained-projection.js +0 -95
- package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
- package/dist/runtime/harnesses/chained-transcript.js +0 -62
- package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
- package/dist/runtime/harnesses/claude-approval.js +0 -124
- package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/claude-transcript.js +0 -138
- package/dist/runtime/harnesses/claude.d.ts +0 -8
- package/dist/runtime/harnesses/claude.js +0 -225
- package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
- package/dist/runtime/harnesses/codex-approval.js +0 -69
- package/dist/runtime/harnesses/codex.d.ts +0 -4
- package/dist/runtime/harnesses/codex.js +0 -269
- package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
- package/dist/runtime/harnesses/cursor-transcript.js +0 -183
- package/dist/runtime/harnesses/cursor.d.ts +0 -24
- package/dist/runtime/harnesses/cursor.js +0 -620
- package/dist/runtime/harnesses/index.d.ts +0 -16
- package/dist/runtime/harnesses/index.js +0 -73
- package/dist/runtime/harnesses/pi.d.ts +0 -4
- package/dist/runtime/harnesses/pi.js +0 -247
- package/dist/runtime/harnesses/process.d.ts +0 -31
- package/dist/runtime/harnesses/process.js +0 -75
- package/dist/runtime/harnesses/stream-json.d.ts +0 -48
- package/dist/runtime/harnesses/stream-json.js +0 -336
- package/dist/runtime/harnesses/types.d.ts +0 -117
- package/dist/runtime/harnesses/types.js +0 -1
- package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
- package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
- package/dist/runtime/harnesses/workbuddy.js +0 -123
- package/dist/runtime/instance.d.ts +0 -20
- package/dist/runtime/instance.js +0 -247
- package/dist/runtime/json-rpc.d.ts +0 -53
- package/dist/runtime/json-rpc.js +0 -212
- package/dist/runtime/launch.d.ts +0 -25
- package/dist/runtime/launch.js +0 -247
- package/dist/runtime/local-workspace.d.ts +0 -15
- package/dist/runtime/local-workspace.js +0 -52
- package/dist/runtime/model-catalog.d.ts +0 -12
- package/dist/runtime/model-catalog.js +0 -84
- package/dist/runtime/native/adapters.d.ts +0 -15
- package/dist/runtime/native/adapters.js +0 -11
- package/dist/runtime/native/approvals.d.ts +0 -18
- package/dist/runtime/native/approvals.js +0 -54
- package/dist/runtime/native/archive.d.ts +0 -19
- package/dist/runtime/native/archive.js +0 -142
- package/dist/runtime/native/attach.d.ts +0 -36
- package/dist/runtime/native/attach.js +0 -128
- package/dist/runtime/native/codex-link.d.ts +0 -60
- package/dist/runtime/native/codex-link.js +0 -322
- package/dist/runtime/native/config.d.ts +0 -16
- package/dist/runtime/native/config.js +0 -24
- package/dist/runtime/native/daemon.d.ts +0 -92
- package/dist/runtime/native/daemon.js +0 -380
- package/dist/runtime/native/execution.d.ts +0 -26
- package/dist/runtime/native/execution.js +0 -34
- package/dist/runtime/native/identity.d.ts +0 -9
- package/dist/runtime/native/identity.js +0 -15
- package/dist/runtime/native/ingest.d.ts +0 -263
- package/dist/runtime/native/ingest.js +0 -884
- package/dist/runtime/native/install.d.ts +0 -9
- package/dist/runtime/native/install.js +0 -113
- package/dist/runtime/native/paths.d.ts +0 -2
- package/dist/runtime/native/paths.js +0 -7
- package/dist/runtime/native/pi-extension.d.ts +0 -36
- package/dist/runtime/native/pi-link.d.ts +0 -69
- package/dist/runtime/native/pi-link.js +0 -269
- package/dist/runtime/native/results.d.ts +0 -41
- package/dist/runtime/native/results.js +0 -128
- package/dist/runtime/native/sessions.d.ts +0 -45
- package/dist/runtime/native/sessions.js +0 -87
- package/dist/runtime/native/transcript.d.ts +0 -89
- package/dist/runtime/native/transcript.js +0 -656
- package/dist/runtime/native/translate.d.ts +0 -46
- package/dist/runtime/native/translate.js +0 -299
- package/dist/runtime/native/transport.d.ts +0 -7
- package/dist/runtime/native/transport.js +0 -16
- package/dist/runtime/native/version.d.ts +0 -5
- package/dist/runtime/native/version.js +0 -21
- package/dist/runtime/preferences.d.ts +0 -7
- package/dist/runtime/preferences.js +0 -22
- package/dist/runtime/presentation.d.ts +0 -32
- package/dist/runtime/presentation.js +0 -124
- package/dist/runtime/process-group.d.ts +0 -5
- package/dist/runtime/process-group.js +0 -161
- package/dist/runtime/projection-store.d.ts +0 -27
- package/dist/runtime/projection-store.js +0 -30
- package/dist/runtime/space-binding.d.ts +0 -48
- package/dist/runtime/space-binding.js +0 -342
- package/dist/runtime/supervisor.d.ts +0 -19
- package/dist/runtime/supervisor.js +0 -441
- package/dist/runtime/turn-projection.d.ts +0 -41
- package/dist/runtime/turn-projection.js +0 -120
- package/dist/runtime/worker.d.ts +0 -1
- package/dist/safe-remote-image.d.ts +0 -36
- package/dist/safe-remote-image.js +0 -191
- package/dist/self-update.d.ts +0 -7
- package/dist/self-update.js +0 -202
- package/dist/session-status.d.ts +0 -10
- package/dist/session-status.js +0 -25
- package/dist/space-files/limit.d.ts +0 -2
- package/dist/space-files/limit.js +0 -16
- package/dist/space-files/operands.d.ts +0 -17
- package/dist/space-files/operands.js +0 -33
- package/dist/space-files/transfer.d.ts +0 -53
- package/dist/space-files/transfer.js +0 -297
- package/dist/space-files/upload.d.ts +0 -17
- package/dist/space-files/upload.js +0 -76
- package/dist/space.d.ts +0 -44
- package/dist/space.js +0 -192
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -17
- package/dist/web.d.ts +0 -1
- package/dist/web.js +0 -4
- /package/dist/{board-kernel → chunks}/lexer.js +0 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { n as standaloneModule } from "./package-paths.js";
|
|
2
|
+
import { S as isLocalHarness, v as LOCAL_HARNESSES, y as LOCAL_HARNESS_SPECS } from "./runtime.js";
|
|
3
|
+
import { J as getRuntimeSpaceBinding, U as requireAccessToken, X as resolveRuntimeSpace, g as explicitSpace, h as currentIdentityKey, l as requestRuntimeInstance, q as canonicalRuntimeRoot, s as controlRuntimeInstance, t as createClient, u as runtimeInstanceDirectory, x as resolveSpaceRef } from "./client.js";
|
|
4
|
+
import { A as formatVersion, C as installedHarnesses, D as sharedServerAvailable, J as serializeDiagnosticError, L as PI_MIN_VERSION, O as supportsSharedServer, T as CODEX_SHARED_MIN_VERSION, _ as runtimeWebUrl, c as runtimeStateRoot, d as createDiagnosticConsole, g as printRuntimeSummary, i as removeLegacyCodexHooks, j as harnessVersion, k as atLeast, l as writeNativeConfig, o as discoverTranscripts, r as piExtensionState, s as readNativeConfig, t as installPiExtension, x as discoverHarnesses } from "./install.js";
|
|
5
|
+
import { execFile, fork } from "node:child_process";
|
|
6
|
+
import { basename, join, resolve } from "node:path";
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
import { stat } from "node:fs/promises";
|
|
9
|
+
import { promisify } from "node:util";
|
|
10
|
+
import { createInterface } from "node:readline/promises";
|
|
11
|
+
//#region src/runtime/native/attach.ts
|
|
12
|
+
/** Whether this directory already syncs every requested harness. */
|
|
13
|
+
function nativeSyncSatisfied(config, input) {
|
|
14
|
+
return Boolean(config && config.spaceId === input.spaceId && config.root === input.root && input.harnesses.every((harness) => config.harnesses.includes(harness)));
|
|
15
|
+
}
|
|
16
|
+
async function defaultAsk(question) {
|
|
17
|
+
const rl = createInterface({
|
|
18
|
+
input: process.stdin,
|
|
19
|
+
output: process.stderr
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
return /^(|y(es)?)$/i.test((await rl.question(question)).trim());
|
|
23
|
+
} finally {
|
|
24
|
+
rl.close();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Enable native sync after consent. Native history may contain secrets, so nothing is read before
|
|
29
|
+
* the user agrees; a failure here never blocks the Runtime, it only leaves sessions read-only.
|
|
30
|
+
*/
|
|
31
|
+
async function ensureNativeSync(input, log = (line) => process.stderr.write(line), ask = defaultAsk) {
|
|
32
|
+
if (!input.harnesses.length) return {
|
|
33
|
+
enabled: false,
|
|
34
|
+
harnesses: [],
|
|
35
|
+
codexShared: false,
|
|
36
|
+
importHistory: false,
|
|
37
|
+
note: "unsupported"
|
|
38
|
+
};
|
|
39
|
+
const stateRoot = runtimeStateRoot(input.spaceId);
|
|
40
|
+
const previous = await readNativeConfig(stateRoot, input.identity).catch(() => null);
|
|
41
|
+
const alreadySynced = previous && nativeSyncSatisfied(previous, input);
|
|
42
|
+
const interactive = process.stdin.isTTY === true;
|
|
43
|
+
const confirm = async (question) => input.yes ? true : interactive ? await ask(question) : false;
|
|
44
|
+
if (!alreadySynced) {
|
|
45
|
+
if (!input.yes && !interactive) {
|
|
46
|
+
log("Native sync off · rerun interactively or with --yes to enable\n");
|
|
47
|
+
return {
|
|
48
|
+
enabled: false,
|
|
49
|
+
harnesses: input.harnesses,
|
|
50
|
+
codexShared: false,
|
|
51
|
+
importHistory: false,
|
|
52
|
+
note: "non-interactive"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (!await confirm(`Sync ${input.harnesses.map((harness) => LOCAL_HARNESS_SPECS[harness].label).join(" and ")} chats in this folder to this Space so they continue on the web? Their history may contain secrets. [Y/n] `)) return {
|
|
56
|
+
enabled: false,
|
|
57
|
+
harnesses: input.harnesses,
|
|
58
|
+
codexShared: false,
|
|
59
|
+
importHistory: false,
|
|
60
|
+
note: "declined"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let codexShared = previous?.codexShared ?? false;
|
|
64
|
+
if (input.harnesses.includes("codex") && !codexShared && (input.yes || interactive)) {
|
|
65
|
+
const version = await harnessVersion(input.executables?.codex || "codex");
|
|
66
|
+
if (!sharedServerAvailable) log("Shared Codex sessions are unavailable on Windows; terminal Codex chats sync read-only\n");
|
|
67
|
+
else if (!supportsSharedServer(version)) log(`Codex ${formatVersion(version)} predates the shared app-server (${CODEX_SHARED_MIN_VERSION.join(".")}+); terminal Codex chats sync read-only\n`);
|
|
68
|
+
else 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] ");
|
|
69
|
+
}
|
|
70
|
+
if (previous && alreadySynced) {
|
|
71
|
+
if (codexShared !== previous.codexShared) await writeNativeConfig(stateRoot, {
|
|
72
|
+
...previous,
|
|
73
|
+
codexShared
|
|
74
|
+
}).catch((error) => {
|
|
75
|
+
log(`Shared Codex sessions unavailable; Runtime continues without them — ${serializeDiagnosticError(error).message}\n`);
|
|
76
|
+
codexShared = previous.codexShared;
|
|
77
|
+
});
|
|
78
|
+
await maintain(previous, log, input.executables?.pi);
|
|
79
|
+
return {
|
|
80
|
+
enabled: true,
|
|
81
|
+
harnesses: previous.harnesses,
|
|
82
|
+
codexShared,
|
|
83
|
+
importHistory: false
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const harnesses = [.../* @__PURE__ */ new Set([...previous?.root === input.root ? previous.harnesses : [], ...input.harnesses])];
|
|
87
|
+
const config = {
|
|
88
|
+
version: 2,
|
|
89
|
+
identity: input.identity,
|
|
90
|
+
spaceId: input.spaceId,
|
|
91
|
+
root: input.root,
|
|
92
|
+
harnesses,
|
|
93
|
+
enabledAt: previous?.root === input.root ? previous.enabledAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
94
|
+
codexShared
|
|
95
|
+
};
|
|
96
|
+
try {
|
|
97
|
+
await writeNativeConfig(stateRoot, config);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
log(`Native sync unavailable; Runtime continues without it — ${serializeDiagnosticError(error).message}\n`);
|
|
100
|
+
return {
|
|
101
|
+
enabled: false,
|
|
102
|
+
harnesses: input.harnesses,
|
|
103
|
+
codexShared: false,
|
|
104
|
+
importHistory: false,
|
|
105
|
+
note: "config"
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
await maintain(config, log, input.executables?.pi, true);
|
|
109
|
+
const history = (await discoverTranscripts(input.root, input.harnesses, { headers: true }).catch(() => [])).filter((candidate) => candidate.mtimeMs < Date.parse(config.enabledAt)).length;
|
|
110
|
+
let importHistory = false;
|
|
111
|
+
if (history && !previous) {
|
|
112
|
+
importHistory = await confirm(`Import ${history} earlier conversation${history === 1 ? "" : "s"} from this folder? [Y/n] `);
|
|
113
|
+
if (!importHistory) log("Import them later with cohub runtime import\n");
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
enabled: true,
|
|
117
|
+
harnesses,
|
|
118
|
+
codexShared,
|
|
119
|
+
importHistory
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Keep integrations current on every `up`. */
|
|
123
|
+
async function maintain(config, log, piBinary, announce = false) {
|
|
124
|
+
if (config.harnesses.includes("pi")) await maintainPiExtension(piBinary, log, announce);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Before any harness starts, repair what earlier releases installed: an outdated Pi extension can keep
|
|
128
|
+
* Pi from starting, and legacy Codex hooks run a script that is gone. Both had consent back then.
|
|
129
|
+
*/
|
|
130
|
+
async function repairIntegrations(piBinary, log = (line) => process.stderr.write(line)) {
|
|
131
|
+
await removeLegacyCodexHooks().catch(() => void 0);
|
|
132
|
+
if (await piExtensionState().catch(() => null) === "outdated") await maintainPiExtension(piBinary, log);
|
|
133
|
+
}
|
|
134
|
+
/** Pi without the extension still syncs, read-only. */
|
|
135
|
+
async function maintainPiExtension(piBinary, log, announce = false) {
|
|
136
|
+
const version = await harnessVersion(piBinary || "pi");
|
|
137
|
+
if (!atLeast(version, PI_MIN_VERSION)) {
|
|
138
|
+
log(`Pi ${formatVersion(version)} predates the Cohub extension (${PI_MIN_VERSION.join(".")}+); Pi chats sync read-only\n`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const state = await piExtensionState();
|
|
143
|
+
if (state === "installed") return;
|
|
144
|
+
if (state === "foreign" || state === "missing" && !announce) {
|
|
145
|
+
log("Pi extension not installed; Pi chats sync read-only. Install with cohub runtime attach --harness pi\n");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
await installPiExtension();
|
|
149
|
+
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");
|
|
150
|
+
} catch (error) {
|
|
151
|
+
log(`Pi extension not installed — ${serializeDiagnosticError(error).message}; Pi chats sync read-only\n`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/runtime/launch.ts
|
|
156
|
+
const EXPECTED_IDENTITY_ENV = "COHUB_RUNTIME_EXPECTED_IDENTITY";
|
|
157
|
+
/** Executable overrides come from the per-harness `--<harness> <path>` options. */
|
|
158
|
+
const runtimeExecutables = (options) => Object.fromEntries(LOCAL_HARNESSES.flatMap((harness) => options[harness] ? [[harness, options[harness]]] : []));
|
|
159
|
+
const resolveLocalSpaceName = (root, name) => name?.trim() || basename(root) || "local-space";
|
|
160
|
+
function parseRuntimeHarnesses(values) {
|
|
161
|
+
const names = values.flatMap((value) => value.split(",")).map((name) => name.trim()).filter(Boolean);
|
|
162
|
+
if (names.some((name) => !isLocalHarness(name))) throw new Error(`Harness must be one of: ${LOCAL_HARNESSES.join(", ")}`);
|
|
163
|
+
return [...new Set(names.length ? names : ["pi"])];
|
|
164
|
+
}
|
|
165
|
+
function parseRuntimeDisplay(value, platform = process.platform, env = process.env) {
|
|
166
|
+
if (value === false) return void 0;
|
|
167
|
+
if (value === void 0 && platform !== "darwin" && platform !== "win32" && (platform !== "linux" || !env.DISPLAY)) return void 0;
|
|
168
|
+
const spec = value === void 0 || value === true ? "auto" : value.trim();
|
|
169
|
+
if (!/^(auto|macos|windows|x11(:[\w.:-]+)?|xvfb(:\d{3,4}x\d{3,4})?)$/.test(spec)) throw new Error("Display must be auto, macos, windows, x11[:display] or xvfb[:WIDTHxHEIGHT]");
|
|
170
|
+
if (platform === "linux" && spec === "auto" && !env.DISPLAY) throw new Error(env.WAYLAND_DISPLAY ? "Wayland sessions cannot be shared yet: log in with an X11 session, or use --display xvfb for a virtual screen" : "No X11 session to share (DISPLAY is unset): use --display xvfb for a virtual screen");
|
|
171
|
+
return spec;
|
|
172
|
+
}
|
|
173
|
+
const isVirtualDisplay = (spec) => spec.startsWith("xvfb");
|
|
174
|
+
async function requestedRuntimeSpace(program, target) {
|
|
175
|
+
const ref = target?.trim() || explicitSpace(program);
|
|
176
|
+
return ref ? resolveSpaceRef(ref) : null;
|
|
177
|
+
}
|
|
178
|
+
async function resolveRuntimeTarget(program, target) {
|
|
179
|
+
const spaceId = await requestedRuntimeSpace(program, target) ?? (await getRuntimeSpaceBinding(process.cwd(), currentIdentityKey()))?.spaceId;
|
|
180
|
+
if (!spaceId) throw new Error("No directory binding. Use --space <space> or runtime up");
|
|
181
|
+
return spaceId;
|
|
182
|
+
}
|
|
183
|
+
async function startBackgroundRuntime(config) {
|
|
184
|
+
return new Promise((resolve, reject) => {
|
|
185
|
+
const worker = standaloneModule("runtime/worker");
|
|
186
|
+
const child = fork(worker, [], {
|
|
187
|
+
detached: true,
|
|
188
|
+
stdio: [
|
|
189
|
+
"ignore",
|
|
190
|
+
"ignore",
|
|
191
|
+
"ignore",
|
|
192
|
+
"ipc"
|
|
193
|
+
],
|
|
194
|
+
windowsHide: true
|
|
195
|
+
});
|
|
196
|
+
const diagnosticConsole = createDiagnosticConsole(config.verbose);
|
|
197
|
+
let last = null;
|
|
198
|
+
let settled = false;
|
|
199
|
+
const finish = (error) => {
|
|
200
|
+
if (settled) return;
|
|
201
|
+
settled = true;
|
|
202
|
+
clearTimeout(timeout);
|
|
203
|
+
child.removeAllListeners("message");
|
|
204
|
+
setImmediate(() => {
|
|
205
|
+
if (child.connected) child.disconnect();
|
|
206
|
+
child.unref();
|
|
207
|
+
});
|
|
208
|
+
if (error) reject(error);
|
|
209
|
+
else if (last) resolve(last);
|
|
210
|
+
else reject(/* @__PURE__ */ new Error("Runtime did not start"));
|
|
211
|
+
};
|
|
212
|
+
const timeout = setTimeout(() => finish(last ? void 0 : /* @__PURE__ */ new Error("Runtime startup timed out")), 3e4);
|
|
213
|
+
child.on("error", (error) => finish(error));
|
|
214
|
+
child.on("exit", (code) => finish(/* @__PURE__ */ new Error(`Runtime exited (${code})`)));
|
|
215
|
+
child.on("message", (message) => {
|
|
216
|
+
if (message.type === "status" && message.status) {
|
|
217
|
+
last = message.status;
|
|
218
|
+
if (last.state === "ready") finish();
|
|
219
|
+
} else if (message.type === "failed") finish(new Error(message.error ?? "Runtime failed"));
|
|
220
|
+
else if (message.type === "diagnostic" && message.event) diagnosticConsole(message.event);
|
|
221
|
+
});
|
|
222
|
+
child.send(config);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/** Collaborators execute as this OS user; an elevated Windows token would grant them administrator rights. */
|
|
226
|
+
async function assertNotElevatedOnWindows() {
|
|
227
|
+
if (process.platform !== "win32") return;
|
|
228
|
+
if (!process.env.SystemRoot) throw new Error("SystemRoot is not set; cannot check terminal elevation");
|
|
229
|
+
const { stdout } = await promisify(execFile)(join(process.env.SystemRoot, "System32", "whoami.exe"), ["/groups"], {
|
|
230
|
+
encoding: "utf8",
|
|
231
|
+
windowsHide: true
|
|
232
|
+
});
|
|
233
|
+
if (/\bS-1-16-(?:12288|16384)\b/.test(stdout)) throw new Error("Run cohub runtime up from a non-elevated terminal");
|
|
234
|
+
}
|
|
235
|
+
async function runtimeUp(program, dir, options) {
|
|
236
|
+
await assertNotElevatedOnWindows();
|
|
237
|
+
const requestedRoot = resolve(dir ?? process.cwd());
|
|
238
|
+
if (!(await stat(requestedRoot)).isDirectory()) throw new Error("Workspace is not a directory");
|
|
239
|
+
const root = await canonicalRuntimeRoot(requestedRoot);
|
|
240
|
+
const requestedRef = options.space?.trim() || explicitSpace(program);
|
|
241
|
+
if (options.new && requestedRef) throw new Error("--new cannot be combined with --space or COHUB_SPACE_ID");
|
|
242
|
+
if (options.name && requestedRef) throw new Error("--name only applies to a new Space");
|
|
243
|
+
const requested = await requestedRuntimeSpace(program, options.space);
|
|
244
|
+
const identity = currentIdentityKey();
|
|
245
|
+
if (!identity) {
|
|
246
|
+
await requireAccessToken();
|
|
247
|
+
throw new Error("Cannot identify the signed-in account");
|
|
248
|
+
}
|
|
249
|
+
const expected = process.env[EXPECTED_IDENTITY_ENV];
|
|
250
|
+
delete process.env[EXPECTED_IDENTITY_ENV];
|
|
251
|
+
if (expected && expected !== identity) throw new Error("The signed-in account changed");
|
|
252
|
+
const binding = await getRuntimeSpaceBinding(root, identity);
|
|
253
|
+
const existingId = requested || binding?.spaceId;
|
|
254
|
+
let harnesses = parseRuntimeHarnesses(options.harness);
|
|
255
|
+
const executables = runtimeExecutables(options);
|
|
256
|
+
let display = options.display === void 0 ? void 0 : parseRuntimeDisplay(options.display);
|
|
257
|
+
if (existingId && !options.new) {
|
|
258
|
+
const existing = await requestRuntimeInstance(runtimeInstanceDirectory(identity, existingId));
|
|
259
|
+
if (existing) {
|
|
260
|
+
if (existing.root !== root || options.harness.length && [...existing.harnesses].sort().join() !== [...harnesses].sort().join() || Object.keys(executables).length || options.display !== void 0 && display !== existing.display) throw new Error("Runtime is running with a different configuration. Use down first");
|
|
261
|
+
const native = await ensureNativeSync({
|
|
262
|
+
root,
|
|
263
|
+
spaceId: existing.spaceId,
|
|
264
|
+
identity,
|
|
265
|
+
harnesses: options.harness.length ? harnesses : parseRuntimeHarnesses(existing.harnesses),
|
|
266
|
+
yes: options.yes,
|
|
267
|
+
executables
|
|
268
|
+
});
|
|
269
|
+
const directory = runtimeInstanceDirectory(identity, existing.spaceId);
|
|
270
|
+
await controlRuntimeInstance(directory, "reload").catch(() => void 0);
|
|
271
|
+
if (native.importHistory) await controlRuntimeInstance(directory, "import", { command: "start" }, 6e4).catch(() => void 0);
|
|
272
|
+
printRuntimeSummary(existing, options.json, true);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
display = parseRuntimeDisplay(options.display);
|
|
277
|
+
if (!options.harness.length) harnesses = await installedHarnesses(root, executables);
|
|
278
|
+
let createNew = Boolean(options.new);
|
|
279
|
+
let name = resolveLocalSpaceName(root, options.name);
|
|
280
|
+
if (!options.yes) {
|
|
281
|
+
if (!process.stdin.isTTY) throw new Error("Use --yes to authorize local execution");
|
|
282
|
+
const rl = createInterface({
|
|
283
|
+
input: process.stdin,
|
|
284
|
+
output: process.stderr
|
|
285
|
+
});
|
|
286
|
+
try {
|
|
287
|
+
if (!requested && binding) {
|
|
288
|
+
process.stderr.write(`\nLinked Space\n ${runtimeWebUrl(binding.spaceId)}\n`);
|
|
289
|
+
const answer = (await rl.question("Reuse this Space? [Y/n, q to cancel] ")).trim().toLowerCase();
|
|
290
|
+
if (answer === "q") return;
|
|
291
|
+
createNew = answer === "n" || answer === "no";
|
|
292
|
+
} else if (!requested) {
|
|
293
|
+
const answer = (await rl.question("Create a new Space? [Y/n] ")).trim().toLowerCase();
|
|
294
|
+
if (answer && answer !== "y" && answer !== "yes") return;
|
|
295
|
+
}
|
|
296
|
+
if (binding && createNew && !options.name) name = `${name}-${randomUUID().slice(0, 6)}`;
|
|
297
|
+
if (!requested && (!binding || createNew)) name = (await rl.question(`Space name [${name}]: `)).trim() || name;
|
|
298
|
+
process.stderr.write(`\nDirectory ${root}\n${requested ? `Space ${runtimeWebUrl(requested)}\n` : ""}`);
|
|
299
|
+
const answer = await rl.question("Collaborators can execute as your OS user, beyond this folder. Allow? [Y/n] ");
|
|
300
|
+
if (/^n(o)?$/i.test(answer.trim())) return;
|
|
301
|
+
if (display && !isVirtualDisplay(display)) {
|
|
302
|
+
const share = await rl.question("Collaborators and agents can see and control this screen. Share it? [Y/n] ");
|
|
303
|
+
if (!/^(y(es)?)?$/i.test(share.trim())) display = void 0;
|
|
304
|
+
}
|
|
305
|
+
} finally {
|
|
306
|
+
rl.close();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (options.yes && createNew && binding && !options.name) name = `${name}-${randomUUID().slice(0, 6)}`;
|
|
310
|
+
if (createNew && binding && await requestRuntimeInstance(runtimeInstanceDirectory(identity, binding.spaceId))) throw new Error("Stop the existing Runtime before rebinding this directory");
|
|
311
|
+
await repairIntegrations(options.pi);
|
|
312
|
+
const capabilities = await discoverHarnesses(harnesses, executables, root, options.harness.length ? void 0 : (harness, error) => {
|
|
313
|
+
process.stderr.write(`Skipping ${LOCAL_HARNESS_SPECS[harness].label}: ${serializeDiagnosticError(error).message.split("\n")[0]}\n`);
|
|
314
|
+
});
|
|
315
|
+
harnesses = capabilities.harnesses;
|
|
316
|
+
if (!harnesses.length) process.stderr.write(`No local Harness found (${LOCAL_HARNESSES.map((harness) => LOCAL_HARNESS_SPECS[harness].label).join(", ")}); Turns run on Cohub. Reconnect after installing one\n`);
|
|
317
|
+
const client = createClient();
|
|
318
|
+
const { spaceId, source } = await resolveRuntimeSpace({
|
|
319
|
+
root,
|
|
320
|
+
identityKey: identity,
|
|
321
|
+
explicitSpaceId: requested,
|
|
322
|
+
newSpace: createNew,
|
|
323
|
+
expectedSpaceId: binding?.spaceId ?? null,
|
|
324
|
+
createSpace: async () => (await client.spaces.create({
|
|
325
|
+
name,
|
|
326
|
+
config: { sandbox: { provider: "local" } }
|
|
327
|
+
})).space.id,
|
|
328
|
+
validateSpace: async (id) => {
|
|
329
|
+
if ((await client.space(id).sandbox.get()).sandbox?.provider !== "local") throw new Error("Space does not have a local Runtime");
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
const native = await ensureNativeSync({
|
|
333
|
+
root,
|
|
334
|
+
spaceId,
|
|
335
|
+
identity,
|
|
336
|
+
harnesses,
|
|
337
|
+
yes: options.yes,
|
|
338
|
+
executables
|
|
339
|
+
});
|
|
340
|
+
const config = {
|
|
341
|
+
spaceId,
|
|
342
|
+
root,
|
|
343
|
+
identity,
|
|
344
|
+
harnesses,
|
|
345
|
+
capabilities,
|
|
346
|
+
executables,
|
|
347
|
+
background: Boolean(options.detach),
|
|
348
|
+
verbose: options.verbose,
|
|
349
|
+
importHistory: native.importHistory,
|
|
350
|
+
display
|
|
351
|
+
};
|
|
352
|
+
const existing = await requestRuntimeInstance(runtimeInstanceDirectory(identity, spaceId));
|
|
353
|
+
if (existing) {
|
|
354
|
+
if (existing.root !== root) throw new Error("This Space is running in another directory");
|
|
355
|
+
printRuntimeSummary(existing, options.json, true);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (options.detach) {
|
|
359
|
+
const summary = await startBackgroundRuntime(config);
|
|
360
|
+
printRuntimeSummary(summary, options.json, source === "binding");
|
|
361
|
+
if (summary.state !== "ready") process.exitCode = 2;
|
|
362
|
+
} else {
|
|
363
|
+
let announced = false;
|
|
364
|
+
const { runRuntime } = await import("./supervisor2.js");
|
|
365
|
+
await runRuntime(config, (status) => {
|
|
366
|
+
if (!announced && status.state === "ready") {
|
|
367
|
+
announced = true;
|
|
368
|
+
printRuntimeSummary(status, options.json, source === "binding");
|
|
369
|
+
} else if (!announced && status.state === "starting" && !options.json) process.stderr.write(`Connecting\n ${runtimeWebUrl(spaceId)}\n Logs ${status.diagnosticsPath}\n`);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
export { resolveRuntimeTarget as a, resolveLocalSpaceName as i, parseRuntimeDisplay as n, runtimeUp as o, parseRuntimeHarnesses as r, EXPECTED_IDENTITY_ENV as t };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
//#region src/local-media.ts
|
|
4
|
+
const run = promisify(execFile);
|
|
5
|
+
const oriented = (width, height, turned) => turned ? {
|
|
6
|
+
width: height,
|
|
7
|
+
height: width
|
|
8
|
+
} : {
|
|
9
|
+
width,
|
|
10
|
+
height
|
|
11
|
+
};
|
|
12
|
+
async function localMediaFacts(file, type, signal) {
|
|
13
|
+
try {
|
|
14
|
+
if (type === "image") {
|
|
15
|
+
const { default: sharp } = await import("sharp");
|
|
16
|
+
const { width = 0, height = 0, orientation = 1 } = await sharp(file).metadata();
|
|
17
|
+
return width > 0 && height > 0 ? oriented(width, height, orientation >= 5) : null;
|
|
18
|
+
}
|
|
19
|
+
const { stdout } = await run("ffprobe", [
|
|
20
|
+
"-v",
|
|
21
|
+
"error",
|
|
22
|
+
"-select_streams",
|
|
23
|
+
"v:0",
|
|
24
|
+
"-show_entries",
|
|
25
|
+
"stream=width,height:stream_side_data=rotation:format=duration",
|
|
26
|
+
"-of",
|
|
27
|
+
"json",
|
|
28
|
+
file
|
|
29
|
+
], {
|
|
30
|
+
signal,
|
|
31
|
+
timeout: 5e3
|
|
32
|
+
});
|
|
33
|
+
const { streams, format } = JSON.parse(stdout);
|
|
34
|
+
const stream = streams?.[0];
|
|
35
|
+
if (!stream?.width || !stream.height) return null;
|
|
36
|
+
const rotation = stream.side_data_list?.find((data) => data.rotation !== void 0)?.rotation ?? 0;
|
|
37
|
+
const durationMs = Math.round(Number(format?.duration) * 1e3);
|
|
38
|
+
return {
|
|
39
|
+
...oriented(stream.width, stream.height, Math.abs(rotation) % 180 === 90),
|
|
40
|
+
...durationMs > 0 ? { durationMs } : {}
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { localMediaFacts as t };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { D as json, E as handleHttp, O as jsonRequested, T as formatLocalDateTime, j as table, t as createClient } from "./client.js";
|
|
2
|
+
import { n as sessionArchiveFilter, t as SESSION_STATUS_COLUMN } from "./session-status.js";
|
|
3
|
+
//#region src/commands/me.ts
|
|
4
|
+
function parseInteger(value, name, min) {
|
|
5
|
+
const parsed = Number.parseInt(value, 10);
|
|
6
|
+
if (!Number.isSafeInteger(parsed) || parsed < min) {
|
|
7
|
+
process.stderr.write(`\n ✗ Invalid ${name}\n ${name} must be an integer ≥ ${min}\n\n`);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
return parsed;
|
|
11
|
+
}
|
|
12
|
+
function registerMe(program) {
|
|
13
|
+
const meCmd = program.command("me").description("Account-level data across your spaces");
|
|
14
|
+
meCmd.command("sessions").alias("list-sessions").description("List sessions you created across all spaces (archived sessions are hidden by default)").option("--limit <n>", "Maximum number of sessions (default 20)").option("--cursor <cursor>", "Pagination cursor from a previous result").option("--archived", "List only archived sessions").option("--all", "Include archived sessions").option("--json", "Output as JSON").action(async (opts) => {
|
|
15
|
+
const client = createClient();
|
|
16
|
+
try {
|
|
17
|
+
const result = await client.user.listSessions({
|
|
18
|
+
limit: opts.limit ? parseInteger(opts.limit, "limit", 1) : void 0,
|
|
19
|
+
cursor: opts.cursor ?? null,
|
|
20
|
+
archived: sessionArchiveFilter(opts)
|
|
21
|
+
});
|
|
22
|
+
if (jsonRequested(opts)) return json(result);
|
|
23
|
+
if (result.sessions.length === 0) {
|
|
24
|
+
console.log(" (empty)");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
table(result.sessions, [
|
|
28
|
+
{
|
|
29
|
+
key: "id",
|
|
30
|
+
label: "ID"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
key: "spaceId",
|
|
34
|
+
label: "Space"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
key: "title",
|
|
38
|
+
label: "Title"
|
|
39
|
+
},
|
|
40
|
+
SESSION_STATUS_COLUMN,
|
|
41
|
+
{
|
|
42
|
+
key: "totalMessages",
|
|
43
|
+
label: "Messages"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "createdAt",
|
|
47
|
+
label: "Created"
|
|
48
|
+
}
|
|
49
|
+
]);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
handleHttp(e);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
meCmd.command("billing-activity").description("List your personal wallet activity, including generation reserves and refunds").option("--page <n>", "Page number (default 1)").option("--json", "Output as JSON").action(async (opts) => {
|
|
55
|
+
const client = createClient();
|
|
56
|
+
try {
|
|
57
|
+
const { activities } = await client.billing.getBalanceActivities({ page: opts.page ? parseInteger(opts.page, "page", 1) : void 0 });
|
|
58
|
+
if (jsonRequested(opts)) return json(activities);
|
|
59
|
+
if (activities.items.length === 0) {
|
|
60
|
+
console.log(" (empty)");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
table(activities.items, [
|
|
64
|
+
{
|
|
65
|
+
key: "title",
|
|
66
|
+
label: "Activity"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "amountUsd",
|
|
70
|
+
label: "Amount (USD)"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
key: "operationId",
|
|
74
|
+
label: "Operation"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "createdAt",
|
|
78
|
+
label: "Date"
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
if (activities.pagination.hasMore) console.log(` More: --page ${activities.page + 1}`);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
handleHttp(e);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
meCmd.command("activity").description("Show your activity across all spaces").option("--days <n>", "Show the last N days (default: 30)").option("--from <date>", "Start at this ISO 8601 date").option("--to <date>", "Stop before this ISO 8601 date").option("--json", "Output as JSON").addHelpText("after", "\nExamples:\n $ cohub me activity --days 7\n $ cohub me activity --from 2026-01-01 --to 2026-02-01").action(async (opts) => {
|
|
87
|
+
if (opts.days && (opts.from || opts.to)) {
|
|
88
|
+
process.stderr.write("\n ✗ Invalid range\n --days cannot be combined with --from or --to\n\n");
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (opts.to && !opts.from) {
|
|
93
|
+
process.stderr.write("\n ✗ Invalid range\n --from is required when --to is provided\n\n");
|
|
94
|
+
process.exitCode = 1;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const client = createClient();
|
|
98
|
+
try {
|
|
99
|
+
const activity = await client.user.getActivity({
|
|
100
|
+
days: opts.days ? parseInteger(opts.days, "days", 1) : void 0,
|
|
101
|
+
from: opts.from,
|
|
102
|
+
to: opts.to
|
|
103
|
+
});
|
|
104
|
+
if (jsonRequested(opts)) return json(activity);
|
|
105
|
+
console.log(`\n ${formatLocalDateTime(activity.range.from)} → ${formatLocalDateTime(activity.range.to)}`);
|
|
106
|
+
table([activity.totals], [
|
|
107
|
+
{
|
|
108
|
+
key: "totalTokens",
|
|
109
|
+
label: "Tokens"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
key: "costTotal",
|
|
113
|
+
label: "Cost ($)"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
key: "requestCount",
|
|
117
|
+
label: "Requests"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
key: "successCount",
|
|
121
|
+
label: "Success"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: "errorCount",
|
|
125
|
+
label: "Errors"
|
|
126
|
+
}
|
|
127
|
+
]);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
handleHttp(e);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { registerMe };
|