@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
package/dist/runtime/launch.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type LocalHarness } from "@neta-art/cohub";
|
|
2
|
-
import { type HarnessExecutables } from "./harnesses/index.js";
|
|
3
|
-
import type { Command } from "commander";
|
|
4
|
-
import { type RuntimeSummary } from "./presentation.js";
|
|
5
|
-
import { type RuntimeLaunch } from "./supervisor.js";
|
|
6
|
-
export declare const EXPECTED_IDENTITY_ENV = "COHUB_RUNTIME_EXPECTED_IDENTITY";
|
|
7
|
-
export type RuntimeUpOptions = HarnessExecutables & {
|
|
8
|
-
space?: string;
|
|
9
|
-
new?: boolean;
|
|
10
|
-
name?: string;
|
|
11
|
-
harness: string[];
|
|
12
|
-
display?: string | boolean;
|
|
13
|
-
yes?: boolean;
|
|
14
|
-
json?: boolean;
|
|
15
|
-
detach?: boolean;
|
|
16
|
-
verbose?: boolean;
|
|
17
|
-
};
|
|
18
|
-
/** Executable overrides come from the per-harness `--<harness> <path>` options. */
|
|
19
|
-
export declare const runtimeExecutables: (options: HarnessExecutables) => HarnessExecutables;
|
|
20
|
-
export declare const resolveLocalSpaceName: (root: string, name?: string) => string;
|
|
21
|
-
export declare function parseRuntimeHarnesses(values: string[]): LocalHarness[];
|
|
22
|
-
export declare function parseRuntimeDisplay(value: string | boolean | undefined, platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): string | undefined;
|
|
23
|
-
export declare function resolveRuntimeTarget(program: Command, target?: string): Promise<string>;
|
|
24
|
-
export declare function startBackgroundRuntime(config: RuntimeLaunch): Promise<RuntimeSummary>;
|
|
25
|
-
export declare function runtimeUp(program: Command, dir: string | undefined, options: RuntimeUpOptions): Promise<void>;
|
package/dist/runtime/launch.js
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { execFile, fork } from "node:child_process";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { stat } from "node:fs/promises";
|
|
4
|
-
import { basename, join, resolve } from "node:path";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
import { createInterface } from "node:readline/promises";
|
|
7
|
-
import { isLocalHarness, LOCAL_HARNESS_SPECS, LOCAL_HARNESSES } from "@neta-art/cohub";
|
|
8
|
-
import { discoverHarnesses, installedHarnesses } from "./harnesses/index.js";
|
|
9
|
-
import { requireAccessToken } from "../auth.js";
|
|
10
|
-
import { createClient } from "../client.js";
|
|
11
|
-
import { currentIdentityKey, explicitSpace, resolveSpaceRef } from "../space.js";
|
|
12
|
-
import { canonicalRuntimeRoot, getRuntimeSpaceBinding, resolveRuntimeSpace } from "./space-binding.js";
|
|
13
|
-
import { controlRuntimeInstance, requestRuntimeInstance, runtimeInstanceDirectory } from "./instance.js";
|
|
14
|
-
import { ensureNativeSync, repairIntegrations } from "./native/attach.js";
|
|
15
|
-
import { serializeDiagnosticError } from "./diagnostics.js";
|
|
16
|
-
import { createDiagnosticConsole, printRuntimeSummary, runtimeWebUrl } from "./presentation.js";
|
|
17
|
-
import { runRuntime } from "./supervisor.js";
|
|
18
|
-
export const EXPECTED_IDENTITY_ENV = "COHUB_RUNTIME_EXPECTED_IDENTITY";
|
|
19
|
-
/** Executable overrides come from the per-harness `--<harness> <path>` options. */
|
|
20
|
-
export const runtimeExecutables = (options) => Object.fromEntries(LOCAL_HARNESSES.flatMap((harness) => options[harness] ? [[harness, options[harness]]] : []));
|
|
21
|
-
export const resolveLocalSpaceName = (root, name) => name?.trim() || basename(root) || "local-space";
|
|
22
|
-
export function parseRuntimeHarnesses(values) {
|
|
23
|
-
const names = values.flatMap((value) => value.split(",")).map((name) => name.trim()).filter(Boolean);
|
|
24
|
-
if (names.some((name) => !isLocalHarness(name)))
|
|
25
|
-
throw new Error(`Harness must be one of: ${LOCAL_HARNESSES.join(", ")}`);
|
|
26
|
-
return [...new Set(names.length ? names : ["pi"])];
|
|
27
|
-
}
|
|
28
|
-
export function parseRuntimeDisplay(value, platform = process.platform, env = process.env) {
|
|
29
|
-
if (value === false)
|
|
30
|
-
return undefined;
|
|
31
|
-
if (value === undefined && platform !== "darwin" && platform !== "win32" && (platform !== "linux" || !env.DISPLAY))
|
|
32
|
-
return undefined;
|
|
33
|
-
const spec = value === undefined || value === true ? "auto" : value.trim();
|
|
34
|
-
if (!/^(auto|macos|windows|x11(:[\w.:-]+)?|xvfb(:\d{3,4}x\d{3,4})?)$/.test(spec)) {
|
|
35
|
-
throw new Error("Display must be auto, macos, windows, x11[:display] or xvfb[:WIDTHxHEIGHT]");
|
|
36
|
-
}
|
|
37
|
-
if (platform === "linux" && spec === "auto" && !env.DISPLAY) {
|
|
38
|
-
throw new Error(env.WAYLAND_DISPLAY
|
|
39
|
-
? "Wayland sessions cannot be shared yet: log in with an X11 session, or use --display xvfb for a virtual screen"
|
|
40
|
-
: "No X11 session to share (DISPLAY is unset): use --display xvfb for a virtual screen");
|
|
41
|
-
}
|
|
42
|
-
return spec;
|
|
43
|
-
}
|
|
44
|
-
const isVirtualDisplay = (spec) => spec.startsWith("xvfb");
|
|
45
|
-
async function requestedRuntimeSpace(program, target) {
|
|
46
|
-
const ref = target?.trim() || explicitSpace(program);
|
|
47
|
-
return ref ? resolveSpaceRef(ref) : null;
|
|
48
|
-
}
|
|
49
|
-
export async function resolveRuntimeTarget(program, target) {
|
|
50
|
-
const spaceId = await requestedRuntimeSpace(program, target)
|
|
51
|
-
?? (await getRuntimeSpaceBinding(process.cwd(), currentIdentityKey()))?.spaceId;
|
|
52
|
-
if (!spaceId)
|
|
53
|
-
throw new Error("No directory binding. Use --space <space> or runtime up");
|
|
54
|
-
return spaceId;
|
|
55
|
-
}
|
|
56
|
-
export async function startBackgroundRuntime(config) {
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
// Keep the same Node executable and loader (also works from source in tests).
|
|
59
|
-
const workerUrl = new URL(import.meta.url.endsWith(".ts") ? "./worker.ts" : "./worker.js", import.meta.url);
|
|
60
|
-
// fork forwards spawn options; windowsHide keeps a detached Windows worker from opening a console.
|
|
61
|
-
const forkOptions = { detached: true, stdio: ["ignore", "ignore", "ignore", "ipc"], windowsHide: true };
|
|
62
|
-
const child = fork(workerUrl, [], forkOptions);
|
|
63
|
-
const diagnosticConsole = createDiagnosticConsole(config.verbose);
|
|
64
|
-
let last = null;
|
|
65
|
-
let settled = false;
|
|
66
|
-
const finish = (error) => {
|
|
67
|
-
if (settled)
|
|
68
|
-
return;
|
|
69
|
-
settled = true;
|
|
70
|
-
clearTimeout(timeout);
|
|
71
|
-
child.removeAllListeners("message");
|
|
72
|
-
// Let already queued IPC messages drain before closing Node's channel.
|
|
73
|
-
setImmediate(() => { if (child.connected)
|
|
74
|
-
child.disconnect(); child.unref(); });
|
|
75
|
-
if (error)
|
|
76
|
-
reject(error);
|
|
77
|
-
else if (last)
|
|
78
|
-
resolve(last);
|
|
79
|
-
else
|
|
80
|
-
reject(new Error("Runtime did not start"));
|
|
81
|
-
};
|
|
82
|
-
const timeout = setTimeout(() => finish(last ? undefined : new Error("Runtime startup timed out")), 30_000);
|
|
83
|
-
child.on("error", (error) => finish(error));
|
|
84
|
-
child.on("exit", (code) => finish(new Error(`Runtime exited (${code})`)));
|
|
85
|
-
child.on("message", (message) => {
|
|
86
|
-
if (message.type === "status" && message.status) {
|
|
87
|
-
last = message.status;
|
|
88
|
-
if (last.state === "ready")
|
|
89
|
-
finish();
|
|
90
|
-
}
|
|
91
|
-
else if (message.type === "failed")
|
|
92
|
-
finish(new Error(message.error ?? "Runtime failed"));
|
|
93
|
-
else if (message.type === "diagnostic" && message.event)
|
|
94
|
-
diagnosticConsole(message.event);
|
|
95
|
-
});
|
|
96
|
-
child.send(config);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/** Collaborators execute as this OS user; an elevated Windows token would grant them administrator rights. */
|
|
100
|
-
async function assertNotElevatedOnWindows() {
|
|
101
|
-
if (process.platform !== "win32")
|
|
102
|
-
return;
|
|
103
|
-
if (!process.env.SystemRoot)
|
|
104
|
-
throw new Error("SystemRoot is not set; cannot check terminal elevation");
|
|
105
|
-
const { stdout } = await promisify(execFile)(join(process.env.SystemRoot, "System32", "whoami.exe"), ["/groups"], { encoding: "utf8", windowsHide: true });
|
|
106
|
-
// High (S-1-16-12288) and System (S-1-16-16384) integrity labels mark an elevated token.
|
|
107
|
-
if (/\bS-1-16-(?:12288|16384)\b/.test(stdout))
|
|
108
|
-
throw new Error("Run cohub runtime up from a non-elevated terminal");
|
|
109
|
-
}
|
|
110
|
-
export async function runtimeUp(program, dir, options) {
|
|
111
|
-
await assertNotElevatedOnWindows();
|
|
112
|
-
const requestedRoot = resolve(dir ?? process.cwd());
|
|
113
|
-
if (!(await stat(requestedRoot)).isDirectory())
|
|
114
|
-
throw new Error("Workspace is not a directory");
|
|
115
|
-
const root = await canonicalRuntimeRoot(requestedRoot);
|
|
116
|
-
const requestedRef = options.space?.trim() || explicitSpace(program);
|
|
117
|
-
if (options.new && requestedRef)
|
|
118
|
-
throw new Error("--new cannot be combined with --space or COHUB_SPACE_ID");
|
|
119
|
-
if (options.name && requestedRef)
|
|
120
|
-
throw new Error("--name only applies to a new Space");
|
|
121
|
-
const requested = await requestedRuntimeSpace(program, options.space);
|
|
122
|
-
const identity = currentIdentityKey();
|
|
123
|
-
if (!identity) {
|
|
124
|
-
await requireAccessToken();
|
|
125
|
-
throw new Error("Cannot identify the signed-in account");
|
|
126
|
-
}
|
|
127
|
-
// Consumed here, so the Runtime and the tools it runs never inherit it.
|
|
128
|
-
const expected = process.env[EXPECTED_IDENTITY_ENV];
|
|
129
|
-
delete process.env[EXPECTED_IDENTITY_ENV];
|
|
130
|
-
if (expected && expected !== identity)
|
|
131
|
-
throw new Error("The signed-in account changed");
|
|
132
|
-
const binding = await getRuntimeSpaceBinding(root, identity);
|
|
133
|
-
const existingId = requested || binding?.spaceId;
|
|
134
|
-
let harnesses = parseRuntimeHarnesses(options.harness);
|
|
135
|
-
const executables = runtimeExecutables(options);
|
|
136
|
-
let display = options.display === undefined ? undefined : parseRuntimeDisplay(options.display);
|
|
137
|
-
if (existingId && !options.new) {
|
|
138
|
-
const existing = await requestRuntimeInstance(runtimeInstanceDirectory(identity, existingId));
|
|
139
|
-
if (existing) {
|
|
140
|
-
if (existing.root !== root || options.harness.length && [...existing.harnesses].sort().join() !== [...harnesses].sort().join() || Object.keys(executables).length || options.display !== undefined && display !== existing.display) {
|
|
141
|
-
throw new Error("Runtime is running with a different configuration. Use down first");
|
|
142
|
-
}
|
|
143
|
-
// `up` is the single idempotent entry: a reused instance adopts its running
|
|
144
|
-
// Harnesses (unless explicitly overridden) and completes native sync setup.
|
|
145
|
-
const native = await ensureNativeSync({ root, spaceId: existing.spaceId, identity, harnesses: options.harness.length ? harnesses : parseRuntimeHarnesses(existing.harnesses), yes: options.yes, executables });
|
|
146
|
-
// The running Runtime applies consent given now without restarting.
|
|
147
|
-
const directory = runtimeInstanceDirectory(identity, existing.spaceId);
|
|
148
|
-
await controlRuntimeInstance(directory, "reload").catch(() => undefined);
|
|
149
|
-
if (native.importHistory)
|
|
150
|
-
await controlRuntimeInstance(directory, "import", { command: "start" }, 60_000).catch(() => undefined);
|
|
151
|
-
printRuntimeSummary(existing, options.json, true);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
display = parseRuntimeDisplay(options.display);
|
|
156
|
-
if (!options.harness.length)
|
|
157
|
-
harnesses = await installedHarnesses(root, executables);
|
|
158
|
-
let createNew = Boolean(options.new);
|
|
159
|
-
let name = resolveLocalSpaceName(root, options.name);
|
|
160
|
-
if (!options.yes) {
|
|
161
|
-
if (!process.stdin.isTTY)
|
|
162
|
-
throw new Error("Use --yes to authorize local execution");
|
|
163
|
-
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
164
|
-
try {
|
|
165
|
-
if (!requested && binding) {
|
|
166
|
-
process.stderr.write(`\nLinked Space\n ${runtimeWebUrl(binding.spaceId)}\n`);
|
|
167
|
-
const answer = (await rl.question("Reuse this Space? [Y/n, q to cancel] ")).trim().toLowerCase();
|
|
168
|
-
if (answer === "q")
|
|
169
|
-
return;
|
|
170
|
-
createNew = answer === "n" || answer === "no";
|
|
171
|
-
}
|
|
172
|
-
else if (!requested) {
|
|
173
|
-
const answer = (await rl.question("Create a new Space? [Y/n] ")).trim().toLowerCase();
|
|
174
|
-
if (answer && answer !== "y" && answer !== "yes")
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (binding && createNew && !options.name)
|
|
178
|
-
name = `${name}-${randomUUID().slice(0, 6)}`;
|
|
179
|
-
if (!requested && (!binding || createNew))
|
|
180
|
-
name = (await rl.question(`Space name [${name}]: `)).trim() || name;
|
|
181
|
-
process.stderr.write(`\nDirectory ${root}\n${requested ? `Space ${runtimeWebUrl(requested)}\n` : ""}`);
|
|
182
|
-
const answer = await rl.question("Collaborators can execute as your OS user, beyond this folder. Allow? [Y/n] ");
|
|
183
|
-
if (/^n(o)?$/i.test(answer.trim()))
|
|
184
|
-
return;
|
|
185
|
-
if (display && !isVirtualDisplay(display)) {
|
|
186
|
-
const share = await rl.question("Collaborators and agents can see and control this screen. Share it? [Y/n] ");
|
|
187
|
-
if (!/^(y(es)?)?$/i.test(share.trim()))
|
|
188
|
-
display = undefined;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
finally {
|
|
192
|
-
rl.close();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (options.yes && createNew && binding && !options.name)
|
|
196
|
-
name = `${name}-${randomUUID().slice(0, 6)}`;
|
|
197
|
-
if (createNew && binding && await requestRuntimeInstance(runtimeInstanceDirectory(identity, binding.spaceId))) {
|
|
198
|
-
throw new Error("Stop the existing Runtime before rebinding this directory");
|
|
199
|
-
}
|
|
200
|
-
await repairIntegrations(options.pi);
|
|
201
|
-
// Fail local preflight before creating remote state; the worker reuses this catalog. Without
|
|
202
|
-
// `--harness`, a discovered harness that cannot start is skipped with a warning.
|
|
203
|
-
const capabilities = await discoverHarnesses(harnesses, executables, root, options.harness.length ? undefined : (harness, error) => {
|
|
204
|
-
process.stderr.write(`Skipping ${LOCAL_HARNESS_SPECS[harness].label}: ${serializeDiagnosticError(error).message.split("\n")[0]}\n`);
|
|
205
|
-
});
|
|
206
|
-
harnesses = capabilities.harnesses;
|
|
207
|
-
if (!harnesses.length)
|
|
208
|
-
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`);
|
|
209
|
-
const client = createClient();
|
|
210
|
-
const { spaceId, source } = await resolveRuntimeSpace({
|
|
211
|
-
root, identityKey: identity, explicitSpaceId: requested,
|
|
212
|
-
newSpace: createNew, expectedSpaceId: binding?.spaceId ?? null,
|
|
213
|
-
createSpace: async () => (await client.spaces.create({ name, config: { sandbox: { provider: "local" } } })).space.id,
|
|
214
|
-
validateSpace: async (id) => {
|
|
215
|
-
const sandbox = (await client.space(id).sandbox.get()).sandbox;
|
|
216
|
-
if (sandbox?.provider !== "local")
|
|
217
|
-
throw new Error("Space does not have a local Runtime");
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
// Consent (or --yes) precedes any user-level integration install; failure never blocks startup.
|
|
221
|
-
const native = await ensureNativeSync({ root, spaceId, identity, harnesses, yes: options.yes, executables });
|
|
222
|
-
const config = { spaceId, root, identity, harnesses, capabilities, executables, background: Boolean(options.detach), verbose: options.verbose, importHistory: native.importHistory, display };
|
|
223
|
-
const existing = await requestRuntimeInstance(runtimeInstanceDirectory(identity, spaceId));
|
|
224
|
-
if (existing) {
|
|
225
|
-
if (existing.root !== root)
|
|
226
|
-
throw new Error("This Space is running in another directory");
|
|
227
|
-
printRuntimeSummary(existing, options.json, true);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
if (options.detach) {
|
|
231
|
-
const summary = await startBackgroundRuntime(config);
|
|
232
|
-
printRuntimeSummary(summary, options.json, source === "binding");
|
|
233
|
-
if (summary.state !== "ready")
|
|
234
|
-
process.exitCode = 2;
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
let announced = false;
|
|
238
|
-
await runRuntime(config, (status) => {
|
|
239
|
-
if (!announced && status.state === "ready") {
|
|
240
|
-
announced = true;
|
|
241
|
-
printRuntimeSummary(status, options.json, source === "binding");
|
|
242
|
-
}
|
|
243
|
-
else if (!announced && status.state === "starting" && !options.json)
|
|
244
|
-
process.stderr.write(`Connecting\n ${runtimeWebUrl(spaceId)}\n Logs ${status.diagnosticsPath}\n`);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type LocalWorkspaceResolver, type LocalWorkspaceTransport } from "@neta-art/cohub";
|
|
2
|
-
export declare const connectLocalWorkspace: (endpoint: Endpoint) => LocalWorkspaceTransport;
|
|
3
|
-
type Endpoint = {
|
|
4
|
-
url: string;
|
|
5
|
-
token: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function findLocalWorkspace(spaceId: string): Promise<Endpoint | null>;
|
|
8
|
-
/**
|
|
9
|
-
* Files and displays of a Space this machine serves go straight to its Runtime,
|
|
10
|
-
* looked up once per account and process. Only the signed-in owner goes direct: a scoped
|
|
11
|
-
* execution token stays on the API that enforces its scope, as does
|
|
12
|
-
* `COHUB_NO_DIRECT=1`.
|
|
13
|
-
*/
|
|
14
|
-
export declare const resolveLocalWorkspace: LocalWorkspaceResolver;
|
|
15
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Agent, request } from "node:http";
|
|
2
|
-
import { Readable } from "node:stream";
|
|
3
|
-
import { loopbackWorkspace } from "@neta-art/cohub";
|
|
4
|
-
import { currentIdentityKey } from "../space.js";
|
|
5
|
-
import { controlRuntimeInstance, runtimeInstanceDirectory } from "./instance.js";
|
|
6
|
-
const DISCOVERY_TIMEOUT_MS = 1_500;
|
|
7
|
-
const NULL_BODY_STATUS = new Set([204, 304]);
|
|
8
|
-
/** Its own agent keeps requests off the proxy `--use-env-proxy` gives global fetch and http: they carry the Runtime's token. */
|
|
9
|
-
const direct = new Agent({ keepAlive: true });
|
|
10
|
-
const loopbackFetch = (input, init = {}) => new Promise((resolve, reject) => {
|
|
11
|
-
const client = request(String(input), { agent: direct, method: init.method ?? "GET", headers: Object.fromEntries(new Headers(init.headers)), signal: init.signal ?? undefined }, (response) => {
|
|
12
|
-
const headers = new Headers(Object.entries(response.headers).flatMap(([name, value]) => [value ?? []].flat().map((item) => [name, item])));
|
|
13
|
-
const status = response.statusCode ?? 502;
|
|
14
|
-
resolve(new Response(NULL_BODY_STATUS.has(status) ? null : Readable.toWeb(response), { status, headers }));
|
|
15
|
-
});
|
|
16
|
-
client.on("error", (cause) => reject(new TypeError("fetch failed", { cause })));
|
|
17
|
-
const { body } = init;
|
|
18
|
-
if (body instanceof Blob)
|
|
19
|
-
Readable.from(body.stream()).on("error", (error) => client.destroy(error)).pipe(client);
|
|
20
|
-
else
|
|
21
|
-
client.end(typeof body === "string" ? body : undefined);
|
|
22
|
-
});
|
|
23
|
-
export const connectLocalWorkspace = (endpoint) => loopbackWorkspace(endpoint, loopbackFetch);
|
|
24
|
-
const isEndpoint = (value) => {
|
|
25
|
-
const endpoint = value;
|
|
26
|
-
return typeof endpoint?.token === "string" && typeof endpoint.url === "string" && /^http:\/\/127\.0\.0\.1:\d+$/.test(endpoint.url);
|
|
27
|
-
};
|
|
28
|
-
export async function findLocalWorkspace(spaceId) {
|
|
29
|
-
const identity = currentIdentityKey();
|
|
30
|
-
if (!identity)
|
|
31
|
-
return null;
|
|
32
|
-
const response = await controlRuntimeInstance(runtimeInstanceDirectory(identity, spaceId), "workspace", {}, DISCOVERY_TIMEOUT_MS).catch(() => null);
|
|
33
|
-
return isEndpoint(response?.result) ? response.result : null;
|
|
34
|
-
}
|
|
35
|
-
const found = new Map();
|
|
36
|
-
/**
|
|
37
|
-
* Files and displays of a Space this machine serves go straight to its Runtime,
|
|
38
|
-
* looked up once per account and process. Only the signed-in owner goes direct: a scoped
|
|
39
|
-
* execution token stays on the API that enforces its scope, as does
|
|
40
|
-
* `COHUB_NO_DIRECT=1`.
|
|
41
|
-
*/
|
|
42
|
-
export const resolveLocalWorkspace = (spaceId) => {
|
|
43
|
-
if (process.env.COHUB_NO_DIRECT === "1" || process.env.COHUB_EXECUTION_TOKEN?.trim())
|
|
44
|
-
return null;
|
|
45
|
-
const key = `${currentIdentityKey()}\0${spaceId}`;
|
|
46
|
-
let workspace = found.get(key);
|
|
47
|
-
if (!workspace) {
|
|
48
|
-
workspace = findLocalWorkspace(spaceId).then((endpoint) => (endpoint ? connectLocalWorkspace(endpoint) : null));
|
|
49
|
-
found.set(key, workspace);
|
|
50
|
-
}
|
|
51
|
-
return workspace;
|
|
52
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type RuntimeModel as Model } from "@neta-art/cohub";
|
|
2
|
-
import { type JsonRecord } from "./json-rpc.js";
|
|
3
|
-
/**
|
|
4
|
-
* Publish only picker metadata, never provider credentials or request configuration.
|
|
5
|
-
* `state` is a fresh Pi's `get_state`: its model is what Pi runs when Cohub requests
|
|
6
|
-
* nothing, and its level is resolved and clamped for that model only. Pi's levels for
|
|
7
|
-
* other models live in its settings, which RPC does not expose; those models fall back
|
|
8
|
-
* to the picker's rule, and Cohub always sends the chosen level explicitly.
|
|
9
|
-
*/
|
|
10
|
-
export declare function piModelCatalog(entries: unknown[], state: JsonRecord): Model[];
|
|
11
|
-
/** Use Codex's picker-visible model/list for every provider, including custom providers. */
|
|
12
|
-
export declare function codexModelCatalog(configResponse: JsonRecord, entries: unknown[]): Model[];
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { isModelThinkingLevel, MODEL_THINKING_LEVELS as thinkingLevels, RUNTIME_MAX_SERVICE_TIERS, runtimeServiceTierSchema, STANDARD_SERVICE_TIER, thinkingLevelMapFor } from "@neta-art/cohub";
|
|
2
|
-
import { record } from "./json-rpc.js";
|
|
3
|
-
const thinkingLevel = (value) => isModelThinkingLevel(value) ? value : undefined;
|
|
4
|
-
/**
|
|
5
|
-
* Publish only picker metadata, never provider credentials or request configuration.
|
|
6
|
-
* `state` is a fresh Pi's `get_state`: its model is what Pi runs when Cohub requests
|
|
7
|
-
* nothing, and its level is resolved and clamped for that model only. Pi's levels for
|
|
8
|
-
* other models live in its settings, which RPC does not expose; those models fall back
|
|
9
|
-
* to the picker's rule, and Cohub always sends the chosen level explicitly.
|
|
10
|
-
*/
|
|
11
|
-
export function piModelCatalog(entries, state) {
|
|
12
|
-
const current = record(state.model);
|
|
13
|
-
const currentLevel = thinkingLevel(state.thinkingLevel);
|
|
14
|
-
return entries.flatMap((value) => {
|
|
15
|
-
const model = record(value);
|
|
16
|
-
if (typeof model.id !== "string" || !model.id || typeof model.provider !== "string" || !model.provider)
|
|
17
|
-
return [];
|
|
18
|
-
const map = record(model.thinkingLevelMap);
|
|
19
|
-
const thinkingLevelMap = thinkingLevelMapFor((level) => map[level] === null || typeof map[level] === "string" ? map[level] : undefined);
|
|
20
|
-
const isDefault = current.provider === model.provider && current.id === model.id;
|
|
21
|
-
return [{
|
|
22
|
-
harness: "pi", id: model.id, provider: model.provider, name: typeof model.name === "string" ? model.name : model.id,
|
|
23
|
-
...(isDefault ? { isDefault } : {}),
|
|
24
|
-
...(typeof model.reasoning === "boolean" ? { reasoning: model.reasoning } : {}),
|
|
25
|
-
...(isDefault && currentLevel ? { defaultThinkingLevel: currentLevel } : {}),
|
|
26
|
-
...(Object.keys(thinkingLevelMap).length ? { thinkingLevelMap } : {}),
|
|
27
|
-
}];
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function codexThinking(model, configuredEffort) {
|
|
31
|
-
if (!Array.isArray(model.supportedReasoningEfforts))
|
|
32
|
-
return {};
|
|
33
|
-
const efforts = new Set(model.supportedReasoningEfforts.map((entry) => record(entry).reasoningEffort));
|
|
34
|
-
const thinkingLevelMap = thinkingLevelMapFor((level) => {
|
|
35
|
-
const effort = level === "off" ? "none" : level;
|
|
36
|
-
return efforts.has(effort) ? effort : null;
|
|
37
|
-
});
|
|
38
|
-
const normalize = (value) => thinkingLevel(value === "none" ? "off" : value);
|
|
39
|
-
const configured = normalize(configuredEffort);
|
|
40
|
-
const fallback = normalize(model.defaultReasoningEffort);
|
|
41
|
-
const defaultThinkingLevel = [configured, fallback].find((level) => level && thinkingLevelMap[level] != null);
|
|
42
|
-
return {
|
|
43
|
-
reasoning: thinkingLevels.some((level) => level !== "off" && thinkingLevelMap[level] != null),
|
|
44
|
-
thinkingLevelMap,
|
|
45
|
-
...(defaultThinkingLevel ? { defaultThinkingLevel } : {}),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/** `serviceTiers` supersedes the deprecated `additionalSpeedTiers`, which only names tier ids. */
|
|
49
|
-
function codexServiceTiers(model, configuredTier) {
|
|
50
|
-
const candidates = Array.isArray(model.serviceTiers)
|
|
51
|
-
? model.serviceTiers.map((entry) => {
|
|
52
|
-
const tier = record(entry);
|
|
53
|
-
return { id: tier.id, name: tier.name, ...(typeof tier.description === "string" && tier.description ? { description: tier.description } : {}) };
|
|
54
|
-
})
|
|
55
|
-
: Array.isArray(model.additionalSpeedTiers) ? model.additionalSpeedTiers.map((id) => ({ id, name: id })) : [];
|
|
56
|
-
// An entry outside the protocol's bounds is dropped rather than invalidating the whole catalog.
|
|
57
|
-
const tiers = candidates.flatMap((tier) => {
|
|
58
|
-
const parsed = runtimeServiceTierSchema.safeParse(tier);
|
|
59
|
-
return parsed.success ? [parsed.data] : [];
|
|
60
|
-
}).slice(0, RUNTIME_MAX_SERVICE_TIERS);
|
|
61
|
-
// A configured `service_tier` replaces the catalog default; `fast` is its legacy name for `priority`.
|
|
62
|
-
const configured = configuredTier === "fast" ? "priority" : configuredTier;
|
|
63
|
-
const preferred = configured === STANDARD_SERVICE_TIER ? undefined : typeof configured === "string" && configured ? configured : model.defaultServiceTier;
|
|
64
|
-
const defaultServiceTier = typeof preferred === "string" && tiers.some((tier) => tier.id === preferred) ? preferred : undefined;
|
|
65
|
-
return { ...(tiers.length ? { serviceTiers: tiers } : {}), ...(defaultServiceTier ? { defaultServiceTier } : {}) };
|
|
66
|
-
}
|
|
67
|
-
/** Use Codex's picker-visible model/list for every provider, including custom providers. */
|
|
68
|
-
export function codexModelCatalog(configResponse, entries) {
|
|
69
|
-
const config = record(configResponse.config);
|
|
70
|
-
const provider = typeof config.model_provider === "string" ? config.model_provider : "openai";
|
|
71
|
-
const configuredModel = typeof config.model === "string" ? config.model : null;
|
|
72
|
-
const models = entries.flatMap((value) => {
|
|
73
|
-
const model = record(value);
|
|
74
|
-
const id = typeof model.model === "string" ? model.model : typeof model.id === "string" ? model.id : null;
|
|
75
|
-
if (!id || model.hidden)
|
|
76
|
-
return [];
|
|
77
|
-
// A configured model replaces the catalog's own default.
|
|
78
|
-
const isDefault = configuredModel ? id === configuredModel : model.isDefault === true;
|
|
79
|
-
return [{ harness: "codex", provider, id, name: typeof model.displayName === "string" ? model.displayName : id, ...(isDefault ? { isDefault } : {}), ...codexThinking(model, config.model_reasoning_effort), ...codexServiceTiers(model, config.service_tier) }];
|
|
80
|
-
});
|
|
81
|
-
if (configuredModel && !models.some((model) => model.id === configuredModel))
|
|
82
|
-
models.unshift({ harness: "codex", provider, id: configuredModel, name: configuredModel, isDefault: true });
|
|
83
|
-
return models;
|
|
84
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { LocalHarness } from "@neta-art/cohub";
|
|
2
|
-
import type { SessionHeader, ThreadKind } from "../harnesses/types.js";
|
|
3
|
-
import type { NativeTranscript, NativeTranscriptTurn } from "./transcript.js";
|
|
4
|
-
export type { NativeTranscript, NativeTranscriptTurn, SessionHeader, ThreadKind };
|
|
5
|
-
export type Harness = LocalHarness;
|
|
6
|
-
/** Directories holding this harness's transcripts; a transcript's header says which project it is. */
|
|
7
|
-
export declare const transcriptRoots: (harness: Harness) => string[];
|
|
8
|
-
/** Whether a directory found under a root can hold transcripts of `cwd`. */
|
|
9
|
-
export declare const acceptsDirectory: (path: string, root: string, harness: Harness, cwd: string) => boolean;
|
|
10
|
-
/** Name-only check: can this path hold a transcript of this harness for `cwd`? */
|
|
11
|
-
export declare const acceptsTranscript: (path: string, harness: Harness, cwd: string) => boolean;
|
|
12
|
-
/** The first line of a transcript: identity, project and purpose. Nothing else is read. */
|
|
13
|
-
export declare const readSessionHeader: (path: string, harness: Harness, signal?: AbortSignal) => Promise<SessionHeader | null>;
|
|
14
|
-
/** Parse a transcript into Turns. */
|
|
15
|
-
export declare const readTranscript: (path: string, harness: Harness, signal?: AbortSignal) => Promise<NativeTranscript>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { transcriptFormat } from "../harnesses/index.js";
|
|
2
|
-
/** Directories holding this harness's transcripts; a transcript's header says which project it is. */
|
|
3
|
-
export const transcriptRoots = (harness) => transcriptFormat(harness).roots();
|
|
4
|
-
/** Whether a directory found under a root can hold transcripts of `cwd`. */
|
|
5
|
-
export const acceptsDirectory = (path, root, harness, cwd) => transcriptFormat(harness).acceptsDirectory(path, root, cwd);
|
|
6
|
-
/** Name-only check: can this path hold a transcript of this harness for `cwd`? */
|
|
7
|
-
export const acceptsTranscript = (path, harness, cwd) => transcriptFormat(harness).acceptsTranscript(path, cwd);
|
|
8
|
-
/** The first line of a transcript: identity, project and purpose. Nothing else is read. */
|
|
9
|
-
export const readSessionHeader = async (path, harness, signal) => await transcriptFormat(harness).header(path, signal);
|
|
10
|
-
/** Parse a transcript into Turns. */
|
|
11
|
-
export const readTranscript = async (path, harness, signal) => await transcriptFormat(harness).read(path, signal);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ApprovalDecision, NativeRuntimeEvent, RuntimeApproval, RuntimeApprovalDecision } from "@neta-art/cohub";
|
|
2
|
-
/** How long a card waits for a person; unanswered, the request is declined. */
|
|
3
|
-
export declare const APPROVAL_TIMEOUT_MS: number;
|
|
4
|
-
type Send = (event: NativeRuntimeEvent) => Promise<unknown>;
|
|
5
|
-
export type ApprovalRequest = Omit<RuntimeApproval, "id" | "requestedAt" | "expiresAt">;
|
|
6
|
-
/** Asks the web for a decision over the control connection; without one, it declines. */
|
|
7
|
-
export declare class ApprovalBroker {
|
|
8
|
-
private readonly timeoutMs;
|
|
9
|
-
private send;
|
|
10
|
-
private readonly pending;
|
|
11
|
-
constructor(timeoutMs?: number);
|
|
12
|
-
/** `null` when the Gateway cannot relay decisions; open cards are then declined. */
|
|
13
|
-
connect(send: Send | null): void;
|
|
14
|
-
get available(): boolean;
|
|
15
|
-
request(sessionId: string, turnId: string, request: ApprovalRequest, signal: AbortSignal): Promise<ApprovalDecision>;
|
|
16
|
-
decide(input: Pick<RuntimeApprovalDecision, "sessionId" | "turnId" | "approvalId" | "decision">): void;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
/** How long a card waits for a person; unanswered, the request is declined. */
|
|
3
|
-
export const APPROVAL_TIMEOUT_MS = 30 * 60_000;
|
|
4
|
-
/** Asks the web for a decision over the control connection; without one, it declines. */
|
|
5
|
-
export class ApprovalBroker {
|
|
6
|
-
timeoutMs;
|
|
7
|
-
send = null;
|
|
8
|
-
pending = new Map();
|
|
9
|
-
constructor(timeoutMs = APPROVAL_TIMEOUT_MS) {
|
|
10
|
-
this.timeoutMs = timeoutMs;
|
|
11
|
-
}
|
|
12
|
-
/** `null` when the Gateway cannot relay decisions; open cards are then declined. */
|
|
13
|
-
connect(send) {
|
|
14
|
-
this.send = send;
|
|
15
|
-
if (!send)
|
|
16
|
-
for (const entry of this.pending.values())
|
|
17
|
-
entry.resolve("decline");
|
|
18
|
-
}
|
|
19
|
-
get available() { return this.send !== null; }
|
|
20
|
-
async request(sessionId, turnId, request, signal) {
|
|
21
|
-
const send = this.send;
|
|
22
|
-
if (!send || signal.aborted)
|
|
23
|
-
return "decline";
|
|
24
|
-
const id = randomUUID();
|
|
25
|
-
const now = Date.now();
|
|
26
|
-
let timer;
|
|
27
|
-
let onAbort = () => { };
|
|
28
|
-
const decided = new Promise((resolve) => {
|
|
29
|
-
this.pending.set(id, { sessionId, turnId, resolve });
|
|
30
|
-
timer = setTimeout(() => resolve("decline"), this.timeoutMs);
|
|
31
|
-
onAbort = () => resolve("decline");
|
|
32
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
await send({ type: "approval", sessionId, turnId, approval: { ...request, id, requestedAt: new Date(now).toISOString(), expiresAt: new Date(now + this.timeoutMs).toISOString() } });
|
|
36
|
-
return await decided;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// A server that cannot show the card cannot answer it either.
|
|
40
|
-
return "decline";
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
clearTimeout(timer);
|
|
44
|
-
signal.removeEventListener("abort", onAbort);
|
|
45
|
-
this.pending.delete(id);
|
|
46
|
-
void this.send?.({ type: "approval.closed", sessionId, turnId, approvalId: id }).catch(() => undefined);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
decide(input) {
|
|
50
|
-
const entry = this.pending.get(input.approvalId);
|
|
51
|
-
if (entry && entry.sessionId === input.sessionId && entry.turnId === input.turnId)
|
|
52
|
-
entry.resolve(input.decision);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { JsonRecord } from "../json-rpc.js";
|
|
2
|
-
/** A structurally unrestorable archive (e.g. its history reference is not carried); never retried. */
|
|
3
|
-
export declare class ArchiveNotRestorableError extends Error {
|
|
4
|
-
constructor(message: string);
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Create a working copy of raw archive bytes. The header line may be rewritten, or with `sessionId`
|
|
8
|
-
* the top-level session id of every line; the target is created exclusively, so an existing native
|
|
9
|
-
* file is never replaced.
|
|
10
|
-
*/
|
|
11
|
-
export declare function copyNativeArchive(input: {
|
|
12
|
-
source: string;
|
|
13
|
-
target: string;
|
|
14
|
-
signal?: AbortSignal;
|
|
15
|
-
header?: (header: JsonRecord) => JsonRecord;
|
|
16
|
-
sessionId?: string;
|
|
17
|
-
}): Promise<{
|
|
18
|
-
checksum: string;
|
|
19
|
-
}>;
|