@neta-art/cohub-cli 10.23.0 → 10.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/bin/cohub.js +4 -1
- package/dist/board-gpu/page.js +1566 -71230
- package/dist/bootstrap.js +67 -27
- package/dist/build.json +1 -1
- package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
- package/dist/chunks/about.js +102 -0
- package/dist/chunks/app-realtime.js +2216 -0
- package/dist/chunks/app-realtime2.js +2 -0
- package/dist/chunks/app-ref.js +88 -0
- package/dist/chunks/apps.js +1423 -0
- package/dist/chunks/auth.js +175 -0
- package/dist/chunks/avatar.js +146 -0
- package/dist/chunks/board-export-resources.js +232 -0
- package/dist/chunks/board-export.js +874 -0
- package/dist/chunks/board-export2.js +2 -0
- package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
- package/dist/chunks/board-kernel2.js +4 -0
- package/dist/chunks/board-profile.js +69 -0
- package/dist/chunks/board-simulate.js +315 -0
- package/dist/chunks/board-time.js +34 -0
- package/dist/chunks/boards.js +1943 -0
- package/dist/{board-kernel → chunks}/browserAll.js +9 -8
- package/dist/chunks/channels.js +64 -0
- package/dist/chunks/client.js +12606 -0
- package/dist/chunks/command-input.js +17 -0
- package/dist/chunks/commander.js +2962 -0
- package/dist/chunks/cron-jobs.js +163 -0
- package/dist/chunks/daemon.js +545 -0
- package/dist/chunks/daemon2.js +2 -0
- package/dist/chunks/desktop.js +172 -0
- package/dist/chunks/endpoint-options.js +26 -0
- package/dist/chunks/env-proxy.js +35 -0
- package/dist/chunks/environment.js +154 -0
- package/dist/chunks/feedback.js +120 -0
- package/dist/chunks/generations.js +379 -0
- package/dist/chunks/host.js +9 -0
- package/dist/chunks/http-put.js +131 -0
- package/dist/chunks/id.js +2416 -0
- package/dist/{board-kernel → chunks}/init.js +1 -1
- package/dist/chunks/install.js +11959 -0
- package/dist/chunks/launch.js +374 -0
- package/dist/chunks/local-media.js +47 -0
- package/dist/chunks/me.js +134 -0
- package/dist/chunks/media.js +315 -0
- package/dist/chunks/models.js +242 -0
- package/dist/chunks/operands.js +46 -0
- package/dist/chunks/package-paths.js +13 -0
- package/dist/chunks/policy.js +221 -0
- package/dist/chunks/preferences.js +29 -0
- package/dist/chunks/profile.js +64 -0
- package/dist/chunks/prompts.js +41 -0
- package/dist/chunks/public.js +2 -0
- package/dist/chunks/public2.js +244 -0
- package/dist/chunks/references.js +197 -0
- package/dist/chunks/referrals.js +90 -0
- package/dist/chunks/rolldown-runtime.js +26 -0
- package/dist/chunks/rooms-connect.js +2 -0
- package/dist/chunks/rooms-connect2.js +151 -0
- package/dist/chunks/rooms-rtc.js +309 -0
- package/dist/chunks/rooms.js +211 -0
- package/dist/chunks/run.js +220 -0
- package/dist/chunks/runtime.js +638 -0
- package/dist/chunks/runtime2.js +286 -0
- package/dist/chunks/runtimes.js +48 -0
- package/dist/chunks/safe-remote-image.js +198 -0
- package/dist/chunks/schemas.js +6017 -0
- package/dist/chunks/search.js +113 -0
- package/dist/chunks/self-update.js +238 -0
- package/dist/chunks/serve.js +1246 -0
- package/dist/chunks/session-status.js +24 -0
- package/dist/chunks/skills.js +35 -0
- package/dist/chunks/spaces.js +5080 -0
- package/dist/chunks/src.js +405 -0
- package/dist/chunks/supervisor.js +2511 -0
- package/dist/chunks/supervisor2.js +2 -0
- package/dist/chunks/tasks.js +82 -0
- package/dist/chunks/themes.js +2898 -0
- package/dist/chunks/version.js +2 -0
- package/dist/chunks/version2.js +22 -0
- package/dist/chunks/version3.js +18 -0
- package/dist/chunks/web.js +7 -0
- package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
- package/dist/runtime/native/pi-extension.js +174 -166
- package/dist/runtime/worker.js +27 -16
- package/package.json +8 -9
- package/dist/about.d.ts +0 -2
- package/dist/about.js +0 -71
- package/dist/app-download.d.ts +0 -11
- package/dist/app-download.js +0 -252
- package/dist/app-ref.d.ts +0 -5
- package/dist/app-ref.js +0 -8
- package/dist/app-target.d.ts +0 -26
- package/dist/app-target.js +0 -55
- package/dist/auth.d.ts +0 -45
- package/dist/auth.js +0 -307
- package/dist/avatar.d.ts +0 -55
- package/dist/avatar.js +0 -104
- package/dist/board-command-support.d.ts +0 -6
- package/dist/board-command-support.js +0 -88
- package/dist/board-export-resources.d.ts +0 -12
- package/dist/board-export-resources.js +0 -51
- package/dist/board-export.d.ts +0 -110
- package/dist/board-export.js +0 -592
- package/dist/board-fonts.d.ts +0 -11
- package/dist/board-fonts.js +0 -10
- package/dist/board-gpu/daemon.d.ts +0 -11
- package/dist/board-gpu/daemon.js +0 -295
- package/dist/board-gpu/index.d.ts +0 -33
- package/dist/board-gpu/index.js +0 -189
- package/dist/board-gpu/protocol.d.ts +0 -77
- package/dist/board-gpu/protocol.js +0 -1
- package/dist/board-kernel.d.ts +0 -5
- package/dist/board-media-export.d.ts +0 -17
- package/dist/board-media-export.js +0 -164
- package/dist/board-media.d.ts +0 -5
- package/dist/board-media.js +0 -66
- package/dist/board-profile.d.ts +0 -21
- package/dist/board-profile.js +0 -67
- package/dist/board-simulate.d.ts +0 -67
- package/dist/board-simulate.js +0 -259
- package/dist/board-time.d.ts +0 -3
- package/dist/board-time.js +0 -34
- package/dist/bootstrap.d.ts +0 -2
- package/dist/client.d.ts +0 -5
- package/dist/client.js +0 -24
- package/dist/command-input.d.ts +0 -4
- package/dist/command-input.js +0 -16
- package/dist/commands/app-commerce.d.ts +0 -2
- package/dist/commands/app-commerce.js +0 -228
- package/dist/commands/app-domains.d.ts +0 -2
- package/dist/commands/app-domains.js +0 -133
- package/dist/commands/apps.d.ts +0 -4
- package/dist/commands/apps.js +0 -827
- package/dist/commands/auth.d.ts +0 -2
- package/dist/commands/auth.js +0 -186
- package/dist/commands/boards/authoring.d.ts +0 -2
- package/dist/commands/boards/authoring.js +0 -166
- package/dist/commands/boards/examples.d.ts +0 -10
- package/dist/commands/boards/examples.js +0 -118
- package/dist/commands/boards.d.ts +0 -13
- package/dist/commands/boards.js +0 -836
- package/dist/commands/channels.d.ts +0 -2
- package/dist/commands/channels.js +0 -74
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -155
- package/dist/commands/decision.d.ts +0 -4
- package/dist/commands/decision.js +0 -113
- package/dist/commands/desktop.d.ts +0 -10
- package/dist/commands/desktop.js +0 -233
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -131
- package/dist/commands/generations.d.ts +0 -2
- package/dist/commands/generations.js +0 -427
- package/dist/commands/host.d.ts +0 -2
- package/dist/commands/host.js +0 -11
- package/dist/commands/me.d.ts +0 -2
- package/dist/commands/me.js +0 -118
- package/dist/commands/models.d.ts +0 -28
- package/dist/commands/models.js +0 -271
- package/dist/commands/profile.d.ts +0 -2
- package/dist/commands/profile.js +0 -81
- package/dist/commands/prompts.d.ts +0 -2
- package/dist/commands/prompts.js +0 -37
- package/dist/commands/public.d.ts +0 -20
- package/dist/commands/public.js +0 -291
- package/dist/commands/references.d.ts +0 -2
- package/dist/commands/references.js +0 -193
- package/dist/commands/referrals.d.ts +0 -2
- package/dist/commands/referrals.js +0 -88
- package/dist/commands/rooms-connect.d.ts +0 -17
- package/dist/commands/rooms-connect.js +0 -140
- package/dist/commands/rooms-rtc-binary.d.ts +0 -2
- package/dist/commands/rooms-rtc-binary.js +0 -107
- package/dist/commands/rooms-rtc.d.ts +0 -21
- package/dist/commands/rooms-rtc.js +0 -171
- package/dist/commands/rooms.d.ts +0 -3
- package/dist/commands/rooms.js +0 -277
- package/dist/commands/run.d.ts +0 -13
- package/dist/commands/run.js +0 -246
- package/dist/commands/runtime.d.ts +0 -3
- package/dist/commands/runtime.js +0 -320
- package/dist/commands/sandboxd-binary.d.ts +0 -11
- package/dist/commands/sandboxd-binary.js +0 -238
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -114
- package/dist/commands/session-access.d.ts +0 -2
- package/dist/commands/session-access.js +0 -70
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -34
- package/dist/commands/space-activity.d.ts +0 -26
- package/dist/commands/space-activity.js +0 -147
- package/dist/commands/space-commerce.d.ts +0 -2
- package/dist/commands/space-commerce.js +0 -514
- package/dist/commands/space-displays.d.ts +0 -2
- package/dist/commands/space-displays.js +0 -620
- package/dist/commands/space-files.d.ts +0 -5
- package/dist/commands/space-files.js +0 -215
- package/dist/commands/space-invitations.d.ts +0 -29
- package/dist/commands/space-invitations.js +0 -189
- package/dist/commands/space-turns.d.ts +0 -49
- package/dist/commands/space-turns.js +0 -205
- package/dist/commands/space-wallet.d.ts +0 -2
- package/dist/commands/space-wallet.js +0 -64
- package/dist/commands/space-webhooks.d.ts +0 -7
- package/dist/commands/space-webhooks.js +0 -73
- package/dist/commands/spaces.d.ts +0 -25
- package/dist/commands/spaces.js +0 -2139
- package/dist/commands/tasks.d.ts +0 -8
- package/dist/commands/tasks.js +0 -80
- package/dist/commands/version.d.ts +0 -2
- package/dist/commands/version.js +0 -21
- package/dist/endpoint-options.d.ts +0 -4
- package/dist/endpoint-options.js +0 -26
- package/dist/env-proxy.d.ts +0 -5
- package/dist/env-proxy.js +0 -20
- package/dist/help-path.d.ts +0 -18
- package/dist/help-path.js +0 -223
- package/dist/host/auth.d.ts +0 -20
- package/dist/host/auth.js +0 -119
- package/dist/host/login-env.d.ts +0 -1
- package/dist/host/login-env.js +0 -31
- package/dist/host/runtime.d.ts +0 -35
- package/dist/host/runtime.js +0 -395
- package/dist/host/runtimes.d.ts +0 -9
- package/dist/host/runtimes.js +0 -42
- package/dist/host/serve.d.ts +0 -2
- package/dist/host/serve.js +0 -117
- package/dist/host/workspaces.d.ts +0 -2
- package/dist/host/workspaces.js +0 -18
- package/dist/http-put.d.ts +0 -25
- package/dist/http-put.js +0 -132
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/launcher.d.ts +0 -4
- package/dist/launcher.js +0 -38
- package/dist/local-media.d.ts +0 -2
- package/dist/local-media.js +0 -30
- package/dist/network-error.d.ts +0 -3
- package/dist/network-error.js +0 -22
- package/dist/output.d.ts +0 -46
- package/dist/output.js +0 -244
- package/dist/runtime/archive-store.d.ts +0 -54
- package/dist/runtime/archive-store.js +0 -379
- package/dist/runtime/cli-path.d.ts +0 -5
- package/dist/runtime/cli-path.js +0 -27
- package/dist/runtime/codex-usage.d.ts +0 -7
- package/dist/runtime/codex-usage.js +0 -11
- package/dist/runtime/connection.d.ts +0 -42
- package/dist/runtime/connection.js +0 -789
- package/dist/runtime/diagnostics.d.ts +0 -107
- package/dist/runtime/diagnostics.js +0 -392
- package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
- package/dist/runtime/harnesses/chained-projection.js +0 -95
- package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
- package/dist/runtime/harnesses/chained-transcript.js +0 -62
- package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
- package/dist/runtime/harnesses/claude-approval.js +0 -124
- package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/claude-transcript.js +0 -138
- package/dist/runtime/harnesses/claude.d.ts +0 -8
- package/dist/runtime/harnesses/claude.js +0 -225
- package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
- package/dist/runtime/harnesses/codex-approval.js +0 -69
- package/dist/runtime/harnesses/codex.d.ts +0 -4
- package/dist/runtime/harnesses/codex.js +0 -269
- package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
- package/dist/runtime/harnesses/cursor-transcript.js +0 -183
- package/dist/runtime/harnesses/cursor.d.ts +0 -24
- package/dist/runtime/harnesses/cursor.js +0 -620
- package/dist/runtime/harnesses/index.d.ts +0 -16
- package/dist/runtime/harnesses/index.js +0 -73
- package/dist/runtime/harnesses/pi.d.ts +0 -4
- package/dist/runtime/harnesses/pi.js +0 -247
- package/dist/runtime/harnesses/process.d.ts +0 -31
- package/dist/runtime/harnesses/process.js +0 -75
- package/dist/runtime/harnesses/stream-json.d.ts +0 -48
- package/dist/runtime/harnesses/stream-json.js +0 -336
- package/dist/runtime/harnesses/types.d.ts +0 -117
- package/dist/runtime/harnesses/types.js +0 -1
- package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
- package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
- package/dist/runtime/harnesses/workbuddy.js +0 -123
- package/dist/runtime/instance.d.ts +0 -20
- package/dist/runtime/instance.js +0 -247
- package/dist/runtime/json-rpc.d.ts +0 -53
- package/dist/runtime/json-rpc.js +0 -212
- package/dist/runtime/launch.d.ts +0 -25
- package/dist/runtime/launch.js +0 -247
- package/dist/runtime/local-workspace.d.ts +0 -15
- package/dist/runtime/local-workspace.js +0 -52
- package/dist/runtime/model-catalog.d.ts +0 -12
- package/dist/runtime/model-catalog.js +0 -84
- package/dist/runtime/native/adapters.d.ts +0 -15
- package/dist/runtime/native/adapters.js +0 -11
- package/dist/runtime/native/approvals.d.ts +0 -18
- package/dist/runtime/native/approvals.js +0 -54
- package/dist/runtime/native/archive.d.ts +0 -19
- package/dist/runtime/native/archive.js +0 -142
- package/dist/runtime/native/attach.d.ts +0 -36
- package/dist/runtime/native/attach.js +0 -128
- package/dist/runtime/native/codex-link.d.ts +0 -60
- package/dist/runtime/native/codex-link.js +0 -322
- package/dist/runtime/native/config.d.ts +0 -16
- package/dist/runtime/native/config.js +0 -24
- package/dist/runtime/native/daemon.d.ts +0 -92
- package/dist/runtime/native/daemon.js +0 -380
- package/dist/runtime/native/execution.d.ts +0 -26
- package/dist/runtime/native/execution.js +0 -34
- package/dist/runtime/native/identity.d.ts +0 -9
- package/dist/runtime/native/identity.js +0 -15
- package/dist/runtime/native/ingest.d.ts +0 -263
- package/dist/runtime/native/ingest.js +0 -884
- package/dist/runtime/native/install.d.ts +0 -9
- package/dist/runtime/native/install.js +0 -113
- package/dist/runtime/native/paths.d.ts +0 -2
- package/dist/runtime/native/paths.js +0 -7
- package/dist/runtime/native/pi-extension.d.ts +0 -36
- package/dist/runtime/native/pi-link.d.ts +0 -69
- package/dist/runtime/native/pi-link.js +0 -269
- package/dist/runtime/native/results.d.ts +0 -41
- package/dist/runtime/native/results.js +0 -128
- package/dist/runtime/native/sessions.d.ts +0 -45
- package/dist/runtime/native/sessions.js +0 -87
- package/dist/runtime/native/transcript.d.ts +0 -89
- package/dist/runtime/native/transcript.js +0 -656
- package/dist/runtime/native/translate.d.ts +0 -46
- package/dist/runtime/native/translate.js +0 -299
- package/dist/runtime/native/transport.d.ts +0 -7
- package/dist/runtime/native/transport.js +0 -16
- package/dist/runtime/native/version.d.ts +0 -5
- package/dist/runtime/native/version.js +0 -21
- package/dist/runtime/preferences.d.ts +0 -7
- package/dist/runtime/preferences.js +0 -22
- package/dist/runtime/presentation.d.ts +0 -32
- package/dist/runtime/presentation.js +0 -124
- package/dist/runtime/process-group.d.ts +0 -5
- package/dist/runtime/process-group.js +0 -161
- package/dist/runtime/projection-store.d.ts +0 -27
- package/dist/runtime/projection-store.js +0 -30
- package/dist/runtime/space-binding.d.ts +0 -48
- package/dist/runtime/space-binding.js +0 -342
- package/dist/runtime/supervisor.d.ts +0 -19
- package/dist/runtime/supervisor.js +0 -441
- package/dist/runtime/turn-projection.d.ts +0 -41
- package/dist/runtime/turn-projection.js +0 -120
- package/dist/runtime/worker.d.ts +0 -1
- package/dist/safe-remote-image.d.ts +0 -36
- package/dist/safe-remote-image.js +0 -191
- package/dist/self-update.d.ts +0 -7
- package/dist/self-update.js +0 -202
- package/dist/session-status.d.ts +0 -6
- package/dist/session-status.js +0 -16
- package/dist/space-files/limit.d.ts +0 -2
- package/dist/space-files/limit.js +0 -16
- package/dist/space-files/operands.d.ts +0 -17
- package/dist/space-files/operands.js +0 -33
- package/dist/space-files/transfer.d.ts +0 -53
- package/dist/space-files/transfer.js +0 -297
- package/dist/space-files/upload.d.ts +0 -17
- package/dist/space-files/upload.js +0 -76
- package/dist/space.d.ts +0 -44
- package/dist/space.js +0 -192
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -17
- package/dist/web.d.ts +0 -1
- package/dist/web.js +0 -4
- /package/dist/{board-kernel → chunks}/lexer.js +0 -0
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import dns from "node:dns/promises";
|
|
2
|
-
import http from "node:http";
|
|
3
|
-
import https from "node:https";
|
|
4
|
-
import { isIP } from "node:net";
|
|
5
|
-
import { isPublicBoardRemoteAddress, normalizeBoardRemoteUrl, } from "@neta-art/cohub/board";
|
|
6
|
-
export const REMOTE_IMAGE_MAX_BYTES = 16 * 1024 * 1024;
|
|
7
|
-
export const REMOTE_IMAGE_TIMEOUT_MS = 15_000;
|
|
8
|
-
const MAX_REDIRECTS = 3;
|
|
9
|
-
const IMAGE_MIME_TYPES = new Set([
|
|
10
|
-
"image/avif",
|
|
11
|
-
"image/gif",
|
|
12
|
-
"image/jpeg",
|
|
13
|
-
"image/png",
|
|
14
|
-
"image/webp",
|
|
15
|
-
]);
|
|
16
|
-
const AUDIO_MIME_TYPES = new Set([
|
|
17
|
-
"audio/mpeg", "audio/mp3", "audio/mp4", "audio/aac", "audio/ogg",
|
|
18
|
-
"audio/wav", "audio/x-wav", "audio/wave", "audio/flac", "audio/x-flac",
|
|
19
|
-
"audio/webm", "audio/opus", "application/ogg",
|
|
20
|
-
]);
|
|
21
|
-
const VIDEO_MIME_TYPES = new Set(["video/mp4", "video/webm", "video/quicktime", "video/ogg", "video/x-matroska"]);
|
|
22
|
-
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
23
|
-
async function defaultLookup(hostname) {
|
|
24
|
-
const records = await dns.lookup(hostname, { all: true, verbatim: true });
|
|
25
|
-
return records.map((record) => ({
|
|
26
|
-
address: record.address,
|
|
27
|
-
family: record.family,
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
function responseHeaders(input) {
|
|
31
|
-
const headers = new Headers();
|
|
32
|
-
for (const [key, value] of Object.entries(input)) {
|
|
33
|
-
if (Array.isArray(value)) {
|
|
34
|
-
for (const item of value)
|
|
35
|
-
headers.append(key, item);
|
|
36
|
-
}
|
|
37
|
-
else if (value !== undefined) {
|
|
38
|
-
headers.set(key, value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return headers;
|
|
42
|
-
}
|
|
43
|
-
/** Async like `dns.lookup`: a synchronous answer crashes TLS on an immediate connect failure. */
|
|
44
|
-
export function pinnedLookup(addresses) {
|
|
45
|
-
const [first] = addresses;
|
|
46
|
-
return (_hostname, options, callback) => {
|
|
47
|
-
process.nextTick(() => options.all
|
|
48
|
-
? callback(null, [...addresses])
|
|
49
|
-
: callback(null, first.address, first.family));
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
const client = url.protocol === "https:" ? https : http;
|
|
55
|
-
const request = client.request(url, {
|
|
56
|
-
agent: false,
|
|
57
|
-
headers: { Accept: "image/*,audio/*,application/ogg" },
|
|
58
|
-
lookup: pinnedLookup(addresses),
|
|
59
|
-
}, (response) => {
|
|
60
|
-
const status = response.statusCode ?? 0;
|
|
61
|
-
const headers = responseHeaders(response.headers);
|
|
62
|
-
if (REDIRECT_STATUSES.has(status)) {
|
|
63
|
-
response.resume();
|
|
64
|
-
resolve({ status, headers, bytes: new Uint8Array() });
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const declaredLength = Number(headers.get("content-length") ?? 0);
|
|
68
|
-
if (Number.isFinite(declaredLength) && declaredLength > maxBytes) {
|
|
69
|
-
response.destroy();
|
|
70
|
-
reject(new Error(`Media exceeds the ${maxBytes} byte download limit`));
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const chunks = [];
|
|
74
|
-
let total = 0;
|
|
75
|
-
response.on("data", (chunk) => {
|
|
76
|
-
total += chunk.byteLength;
|
|
77
|
-
if (total > maxBytes) {
|
|
78
|
-
response.destroy(new Error(`Media exceeds the ${maxBytes} byte download limit`));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
chunks.push(chunk);
|
|
82
|
-
});
|
|
83
|
-
response.once("error", reject);
|
|
84
|
-
response.once("end", () => {
|
|
85
|
-
const bytes = new Uint8Array(total);
|
|
86
|
-
let offset = 0;
|
|
87
|
-
for (const chunk of chunks) {
|
|
88
|
-
bytes.set(chunk, offset);
|
|
89
|
-
offset += chunk.byteLength;
|
|
90
|
-
}
|
|
91
|
-
resolve({ status, headers, bytes });
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
request.setTimeout(timeoutMs, () => {
|
|
95
|
-
request.destroy(new Error(`Media download timed out after ${timeoutMs}ms`));
|
|
96
|
-
});
|
|
97
|
-
request.once("error", reject);
|
|
98
|
-
request.end();
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
function remainingMs(deadline) {
|
|
102
|
-
const remaining = deadline - Date.now();
|
|
103
|
-
if (remaining <= 0)
|
|
104
|
-
throw new Error("Media download timed out");
|
|
105
|
-
return remaining;
|
|
106
|
-
}
|
|
107
|
-
async function withDeadline(promise, deadline) {
|
|
108
|
-
const timeoutMs = remainingMs(deadline);
|
|
109
|
-
let timer;
|
|
110
|
-
try {
|
|
111
|
-
return await Promise.race([
|
|
112
|
-
promise,
|
|
113
|
-
new Promise((_, reject) => {
|
|
114
|
-
timer = setTimeout(() => reject(new Error(`Media download timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
115
|
-
}),
|
|
116
|
-
]);
|
|
117
|
-
}
|
|
118
|
-
finally {
|
|
119
|
-
if (timer)
|
|
120
|
-
clearTimeout(timer);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
async function resolvePublicUrl(value, lookup, deadline) {
|
|
124
|
-
const normalized = normalizeBoardRemoteUrl(value);
|
|
125
|
-
if (!normalized)
|
|
126
|
-
throw new Error("Media URL must be a public HTTP(S) URL");
|
|
127
|
-
const url = new URL(normalized);
|
|
128
|
-
const hostname = url.hostname.replace(/^\[|\]$/g, "");
|
|
129
|
-
const addresses = isIP(hostname)
|
|
130
|
-
? [{ address: hostname, family: isIP(hostname) }]
|
|
131
|
-
: await withDeadline(lookup(hostname), deadline);
|
|
132
|
-
const [first, ...rest] = addresses;
|
|
133
|
-
if (!first ||
|
|
134
|
-
addresses.some((entry) => !isPublicBoardRemoteAddress(entry.address))) {
|
|
135
|
-
throw new Error("Media URL resolves to a private address");
|
|
136
|
-
}
|
|
137
|
-
return { url, addresses: [first, ...rest] };
|
|
138
|
-
}
|
|
139
|
-
export function downloadPublicImage(input, options = {}) {
|
|
140
|
-
return downloadPublicMedia(input, IMAGE_MIME_TYPES, options);
|
|
141
|
-
}
|
|
142
|
-
export function downloadPublicAudio(input, options = {}) {
|
|
143
|
-
return downloadPublicMedia(input, AUDIO_MIME_TYPES, {
|
|
144
|
-
maxBytes: 64 * 1024 * 1024,
|
|
145
|
-
timeoutMs: 30_000,
|
|
146
|
-
...options,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
export function downloadPublicVideo(input, options = {}) {
|
|
150
|
-
return downloadPublicMedia(input, VIDEO_MIME_TYPES, {
|
|
151
|
-
maxBytes: 512 * 1024 * 1024,
|
|
152
|
-
timeoutMs: 120_000,
|
|
153
|
-
...options,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
async function downloadPublicMedia(input, mimeTypes, options) {
|
|
157
|
-
const lookup = options.lookup ?? defaultLookup;
|
|
158
|
-
const requester = options.requester ?? requestPinned;
|
|
159
|
-
const maxBytes = options.maxBytes ?? REMOTE_IMAGE_MAX_BYTES;
|
|
160
|
-
const deadline = Date.now() + (options.timeoutMs ?? REMOTE_IMAGE_TIMEOUT_MS);
|
|
161
|
-
let current = input;
|
|
162
|
-
for (let redirect = 0; redirect <= MAX_REDIRECTS; redirect += 1) {
|
|
163
|
-
const { url, addresses } = await resolvePublicUrl(current, lookup, deadline);
|
|
164
|
-
const response = await withDeadline(requester(url, addresses, remainingMs(deadline), maxBytes), deadline);
|
|
165
|
-
if (REDIRECT_STATUSES.has(response.status)) {
|
|
166
|
-
const location = response.headers.get("location");
|
|
167
|
-
if (!location)
|
|
168
|
-
throw new Error("Media redirect is missing a location");
|
|
169
|
-
if (redirect === MAX_REDIRECTS)
|
|
170
|
-
throw new Error("Too many media redirects");
|
|
171
|
-
current = new URL(location, url).toString();
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
if (response.status < 200 || response.status >= 300) {
|
|
175
|
-
throw new Error(`HTTP ${response.status}`);
|
|
176
|
-
}
|
|
177
|
-
if (response.bytes.byteLength > maxBytes) {
|
|
178
|
-
throw new Error(`Media exceeds the ${maxBytes} byte download limit`);
|
|
179
|
-
}
|
|
180
|
-
const mimeType = response.headers
|
|
181
|
-
.get("content-type")
|
|
182
|
-
?.split(";", 1)[0]
|
|
183
|
-
?.trim()
|
|
184
|
-
.toLowerCase();
|
|
185
|
-
if (!mimeType || !mimeTypes.has(mimeType)) {
|
|
186
|
-
throw new Error("Remote resource has an unsupported media type");
|
|
187
|
-
}
|
|
188
|
-
return { bytes: response.bytes, mimeType };
|
|
189
|
-
}
|
|
190
|
-
throw new Error("Too many media redirects");
|
|
191
|
-
}
|
package/dist/self-update.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const SELF_UPDATE_WORKER_ENV = "COHUB_CLI_SELF_UPDATE_WORKER";
|
|
2
|
-
export type CliSelfUpdateResult = "current" | "updated" | "updated-by-peer";
|
|
3
|
-
export declare function isNewerVersion(candidate: string, installed: string | undefined): boolean;
|
|
4
|
-
export declare function resolveSelfUpdateResult(beforeVersion: string | undefined, afterVersion: string | undefined, updatedByPeer: boolean): CliSelfUpdateResult;
|
|
5
|
-
export declare const isCliSelfUpdateDue: () => boolean;
|
|
6
|
-
export declare function startCliSelfUpdate(entrypoint: string): void;
|
|
7
|
-
export declare function ensureCliSelfUpdated(): Promise<CliSelfUpdateResult>;
|
package/dist/self-update.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
const PACKAGE_NAME = "@neta-art/cohub-cli";
|
|
6
|
-
export const SELF_UPDATE_WORKER_ENV = "COHUB_CLI_SELF_UPDATE_WORKER";
|
|
7
|
-
const DEFAULT_INTERVAL_MS = 6 * 60 * 60 * 1000;
|
|
8
|
-
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
9
|
-
const LOCK_STALE_MS = 5 * 60 * 1000;
|
|
10
|
-
const STATE_PATH = join(homedir(), ".cache", "cohub-cli", "self-update.json");
|
|
11
|
-
const LOCK_PATH = join(homedir(), ".cache", "cohub-cli", "self-update.lock");
|
|
12
|
-
const PACKAGE_PATH = new URL("../package.json", import.meta.url);
|
|
13
|
-
const parsePositiveIntEnv = (name, fallback) => {
|
|
14
|
-
const raw = process.env[name]?.trim();
|
|
15
|
-
if (!raw)
|
|
16
|
-
return fallback;
|
|
17
|
-
const value = Number.parseInt(raw, 10);
|
|
18
|
-
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
19
|
-
};
|
|
20
|
-
const getIntervalMs = () => {
|
|
21
|
-
const explicitMs = process.env.COHUB_CLI_UPDATE_INTERVAL_MS;
|
|
22
|
-
if (explicitMs?.trim())
|
|
23
|
-
return parsePositiveIntEnv("COHUB_CLI_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
|
|
24
|
-
const hours = process.env.COHUB_CLI_UPDATE_INTERVAL_HOURS;
|
|
25
|
-
if (hours?.trim()) {
|
|
26
|
-
const value = Number.parseFloat(hours);
|
|
27
|
-
if (Number.isFinite(value) && value > 0)
|
|
28
|
-
return Math.round(value * 60 * 60 * 1000);
|
|
29
|
-
}
|
|
30
|
-
return DEFAULT_INTERVAL_MS;
|
|
31
|
-
};
|
|
32
|
-
const getTimeoutMs = () => parsePositiveIntEnv("COHUB_CLI_UPDATE_TIMEOUT_MS", DEFAULT_TIMEOUT_MS);
|
|
33
|
-
const readState = () => {
|
|
34
|
-
try {
|
|
35
|
-
return JSON.parse(readFileSync(STATE_PATH, "utf-8"));
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const writeState = (state) => {
|
|
42
|
-
mkdirSync(dirname(STATE_PATH), { recursive: true });
|
|
43
|
-
writeFileSync(STATE_PATH, `${JSON.stringify({ checkedAt: new Date().toISOString(), ...state }, null, 2)}\n`);
|
|
44
|
-
};
|
|
45
|
-
const readInstalledVersion = () => {
|
|
46
|
-
try {
|
|
47
|
-
const pkg = JSON.parse(readFileSync(PACKAGE_PATH, "utf-8"));
|
|
48
|
-
return typeof pkg.version === "string" ? pkg.version : undefined;
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const parseVersion = (value) => {
|
|
55
|
-
const match = /^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(value.trim());
|
|
56
|
-
if (!match)
|
|
57
|
-
return null;
|
|
58
|
-
const core = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
59
|
-
return { core, prerelease: Boolean(match[4]) };
|
|
60
|
-
};
|
|
61
|
-
export function isNewerVersion(candidate, installed) {
|
|
62
|
-
const next = parseVersion(candidate);
|
|
63
|
-
if (!next)
|
|
64
|
-
return false;
|
|
65
|
-
const current = installed === undefined ? null : parseVersion(installed);
|
|
66
|
-
if (!current)
|
|
67
|
-
return true;
|
|
68
|
-
const [major, minor, patch] = next.core;
|
|
69
|
-
const [installedMajor, installedMinor, installedPatch] = current.core;
|
|
70
|
-
const delta = major - installedMajor || minor - installedMinor || patch - installedPatch;
|
|
71
|
-
return delta === 0 ? current.prerelease && !next.prerelease : delta > 0;
|
|
72
|
-
}
|
|
73
|
-
export function resolveSelfUpdateResult(beforeVersion, afterVersion, updatedByPeer) {
|
|
74
|
-
if (beforeVersion !== undefined && beforeVersion === afterVersion)
|
|
75
|
-
return "current";
|
|
76
|
-
return updatedByPeer ? "updated-by-peer" : "updated";
|
|
77
|
-
}
|
|
78
|
-
export const isCliSelfUpdateDue = () => {
|
|
79
|
-
const checkedAt = Date.parse(readState().checkedAt ?? "");
|
|
80
|
-
if (!Number.isFinite(checkedAt))
|
|
81
|
-
return true;
|
|
82
|
-
return Date.now() - checkedAt >= getIntervalMs();
|
|
83
|
-
};
|
|
84
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
85
|
-
const acquireLock = async (timeoutMs) => {
|
|
86
|
-
mkdirSync(dirname(LOCK_PATH), { recursive: true });
|
|
87
|
-
const startedAt = Date.now();
|
|
88
|
-
while (Date.now() - startedAt < timeoutMs) {
|
|
89
|
-
try {
|
|
90
|
-
mkdirSync(LOCK_PATH);
|
|
91
|
-
writeFileSync(join(LOCK_PATH, "pid"), `${process.pid}\n${Date.now()}\n`);
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
try {
|
|
96
|
-
const raw = readFileSync(join(LOCK_PATH, "pid"), "utf-8");
|
|
97
|
-
const timestamp = Number.parseInt(raw.trim().split(/\s+/).at(-1) ?? "0", 10);
|
|
98
|
-
if (!Number.isFinite(timestamp) || Date.now() - timestamp > LOCK_STALE_MS) {
|
|
99
|
-
rmSync(LOCK_PATH, { recursive: true, force: true });
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
rmSync(LOCK_PATH, { recursive: true, force: true });
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
await sleep(250);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
111
|
-
};
|
|
112
|
-
const releaseLock = () => {
|
|
113
|
-
rmSync(LOCK_PATH, { recursive: true, force: true });
|
|
114
|
-
};
|
|
115
|
-
const runNpm = (args, timeoutMs) => {
|
|
116
|
-
return new Promise((resolve, reject) => {
|
|
117
|
-
const child = spawn("npm", args, {
|
|
118
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
119
|
-
env: process.env,
|
|
120
|
-
});
|
|
121
|
-
const stdoutChunks = [];
|
|
122
|
-
const stderrChunks = [];
|
|
123
|
-
child.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
124
|
-
child.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
125
|
-
const timer = setTimeout(() => {
|
|
126
|
-
child.kill("SIGTERM");
|
|
127
|
-
setTimeout(() => child.kill("SIGKILL"), 3000).unref();
|
|
128
|
-
}, timeoutMs);
|
|
129
|
-
timer.unref();
|
|
130
|
-
child.on("error", (error) => {
|
|
131
|
-
clearTimeout(timer);
|
|
132
|
-
reject(error);
|
|
133
|
-
});
|
|
134
|
-
child.on("close", (code, signal) => {
|
|
135
|
-
clearTimeout(timer);
|
|
136
|
-
const stdout = Buffer.concat(stdoutChunks).toString().trim();
|
|
137
|
-
if (code === 0) {
|
|
138
|
-
resolve(stdout);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const stderr = Buffer.concat(stderrChunks).toString().trim();
|
|
142
|
-
const detail = [stderr, stdout].filter(Boolean).join("\n");
|
|
143
|
-
reject(new Error(`npm ${args.join(" ")} failed${signal ? ` (${signal})` : code !== null ? ` (exit ${code})` : ""}${detail ? `:\n${detail}` : ""}`));
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
export function startCliSelfUpdate(entrypoint) {
|
|
148
|
-
if (process.env.COHUB_CLI_AUTO_UPDATE === "0" || !isCliSelfUpdateDue())
|
|
149
|
-
return;
|
|
150
|
-
const worker = spawn(process.execPath, [entrypoint], {
|
|
151
|
-
detached: true,
|
|
152
|
-
env: { ...process.env, [SELF_UPDATE_WORKER_ENV]: "1" },
|
|
153
|
-
stdio: "ignore",
|
|
154
|
-
});
|
|
155
|
-
worker.on("error", () => undefined);
|
|
156
|
-
worker.unref();
|
|
157
|
-
}
|
|
158
|
-
export async function ensureCliSelfUpdated() {
|
|
159
|
-
if (process.env.COHUB_CLI_AUTO_UPDATE === "0")
|
|
160
|
-
return "current";
|
|
161
|
-
if (!isCliSelfUpdateDue())
|
|
162
|
-
return "current";
|
|
163
|
-
const beforeVersion = readInstalledVersion();
|
|
164
|
-
const timeoutMs = getTimeoutMs();
|
|
165
|
-
const locked = await acquireLock(timeoutMs);
|
|
166
|
-
if (!locked) {
|
|
167
|
-
throw new Error(`Timed out waiting for ${PACKAGE_NAME} self-update lock after ${timeoutMs}ms`);
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
// Another process may have completed the update while this process was
|
|
171
|
-
// waiting for the lock.
|
|
172
|
-
if (!isCliSelfUpdateDue()) {
|
|
173
|
-
return resolveSelfUpdateResult(beforeVersion, readInstalledVersion(), true);
|
|
174
|
-
}
|
|
175
|
-
// Reinstalling briefly removes the `cohub` bin, so only do it for a newer release.
|
|
176
|
-
let latestVersion;
|
|
177
|
-
try {
|
|
178
|
-
latestVersion = await runNpm(["view", `${PACKAGE_NAME}@latest`, "version"], timeoutMs);
|
|
179
|
-
if (!isNewerVersion(latestVersion, beforeVersion)) {
|
|
180
|
-
writeState({ installedVersion: beforeVersion, latestVersion, result: "current" });
|
|
181
|
-
return "current";
|
|
182
|
-
}
|
|
183
|
-
await runNpm(["install", "-g", `${PACKAGE_NAME}@${latestVersion}`, "--silent"], timeoutMs);
|
|
184
|
-
}
|
|
185
|
-
catch (error) {
|
|
186
|
-
writeState({
|
|
187
|
-
installedVersion: beforeVersion,
|
|
188
|
-
latestVersion,
|
|
189
|
-
result: "failed",
|
|
190
|
-
error: (error instanceof Error ? error.message : String(error)).slice(0, 500),
|
|
191
|
-
});
|
|
192
|
-
throw error;
|
|
193
|
-
}
|
|
194
|
-
const afterVersion = readInstalledVersion();
|
|
195
|
-
const result = resolveSelfUpdateResult(beforeVersion, afterVersion, false);
|
|
196
|
-
writeState({ installedVersion: afterVersion, latestVersion, result });
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
finally {
|
|
200
|
-
releaseLock();
|
|
201
|
-
}
|
|
202
|
-
}
|
package/dist/session-status.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { SessionRecord } from "@neta-art/cohub";
|
|
2
|
-
import type { Column } from "./output.js";
|
|
3
|
-
type SessionStatusFields = Pick<SessionRecord, "activeTurn" | "lastTurnIssue">;
|
|
4
|
-
export declare function sessionStatusText(session: Partial<SessionStatusFields>): string;
|
|
5
|
-
export declare const SESSION_STATUS_COLUMN: Column;
|
|
6
|
-
export {};
|
package/dist/session-status.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function sessionStatusText(session) {
|
|
2
|
-
const turn = session.activeTurn;
|
|
3
|
-
if (turn)
|
|
4
|
-
return turn.status === "abort_requested" ? "stopping" : turn.status;
|
|
5
|
-
const issue = session.lastTurnIssue;
|
|
6
|
-
if (issue?.status === "failed")
|
|
7
|
-
return "failed";
|
|
8
|
-
if (issue?.reason === "billing")
|
|
9
|
-
return "stopped: insufficient balance";
|
|
10
|
-
return issue?.reason === "stale_active_recovered" ? "interrupted" : "";
|
|
11
|
-
}
|
|
12
|
-
export const SESSION_STATUS_COLUMN = {
|
|
13
|
-
key: "activeTurn",
|
|
14
|
-
label: "Status",
|
|
15
|
-
format: (_value, row) => sessionStatusText(row),
|
|
16
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function createLimiter(concurrency) {
|
|
2
|
-
let active = 0;
|
|
3
|
-
const waiting = [];
|
|
4
|
-
return async (task) => {
|
|
5
|
-
if (active >= concurrency)
|
|
6
|
-
await new Promise((resolve) => waiting.push(resolve));
|
|
7
|
-
active += 1;
|
|
8
|
-
try {
|
|
9
|
-
return await task();
|
|
10
|
-
}
|
|
11
|
-
finally {
|
|
12
|
-
active -= 1;
|
|
13
|
-
waiting.shift()?.();
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type SpaceOperand = {
|
|
2
|
-
kind: "space";
|
|
3
|
-
space: string | null;
|
|
4
|
-
path: string;
|
|
5
|
-
};
|
|
6
|
-
export type LocalOperand = {
|
|
7
|
-
kind: "local";
|
|
8
|
-
path: string;
|
|
9
|
-
};
|
|
10
|
-
export type FileOperand = SpaceOperand | LocalOperand;
|
|
11
|
-
export declare class InvalidFileOperandError extends Error {
|
|
12
|
-
name: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const WORKSPACE_ROOT = "/workspace";
|
|
15
|
-
export declare function normalizeSpacePath(raw: string): string;
|
|
16
|
-
export declare function parseSpaceFileOperand(raw: string): SpaceOperand;
|
|
17
|
-
export declare function parseCopyOperand(raw: string, currentSpaceDeclared: boolean): FileOperand;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { posix, resolve } from "node:path";
|
|
2
|
-
import { parseSpaceRef } from "@neta-art/cohub";
|
|
3
|
-
export class InvalidFileOperandError extends Error {
|
|
4
|
-
name = "InvalidFileOperandError";
|
|
5
|
-
}
|
|
6
|
-
export const WORKSPACE_ROOT = "/workspace";
|
|
7
|
-
const isWorkspacePath = (path) => path === WORKSPACE_ROOT || path.startsWith(`${WORKSPACE_ROOT}/`);
|
|
8
|
-
export function normalizeSpacePath(raw) {
|
|
9
|
-
let path = raw.trim();
|
|
10
|
-
if (isWorkspacePath(path))
|
|
11
|
-
path = path.slice(WORKSPACE_ROOT.length + 1);
|
|
12
|
-
else if (path.startsWith("/"))
|
|
13
|
-
throw new InvalidFileOperandError(`'${raw}' is not a Space path`);
|
|
14
|
-
const normalized = posix.normalize(path || ".").replace(/\/+$/, "");
|
|
15
|
-
return normalized === "." ? "" : normalized;
|
|
16
|
-
}
|
|
17
|
-
function parseSpacePrefix(raw) {
|
|
18
|
-
const colon = raw.indexOf(":");
|
|
19
|
-
if (colon <= 0)
|
|
20
|
-
return null;
|
|
21
|
-
const space = raw.slice(0, colon);
|
|
22
|
-
return parseSpaceRef(space) ? { kind: "space", space, path: normalizeSpacePath(raw.slice(colon + 1)) } : null;
|
|
23
|
-
}
|
|
24
|
-
export function parseSpaceFileOperand(raw) {
|
|
25
|
-
return parseSpacePrefix(raw) ?? { kind: "space", space: null, path: normalizeSpacePath(raw) };
|
|
26
|
-
}
|
|
27
|
-
export function parseCopyOperand(raw, currentSpaceDeclared) {
|
|
28
|
-
const space = parseSpacePrefix(raw);
|
|
29
|
-
if (space)
|
|
30
|
-
return space;
|
|
31
|
-
const local = !currentSpaceDeclared || (raw.startsWith("/") && !isWorkspacePath(raw));
|
|
32
|
-
return local ? { kind: "local", path: resolve(raw) } : { kind: "space", space: null, path: normalizeSpacePath(raw) };
|
|
33
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type SpaceFsCopyResult, type SpaceFsCopyStats, type SpaceFsTreeResponse } from "@neta-art/cohub";
|
|
2
|
-
import { type SpaceFiles } from "./upload.js";
|
|
3
|
-
export type CopyOptions = {
|
|
4
|
-
recursive: boolean;
|
|
5
|
-
noClobber: boolean;
|
|
6
|
-
preserveTimestamps: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare class CopyAbortError extends Error {
|
|
9
|
-
name: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const emptyCopyResult: () => SpaceFsCopyResult;
|
|
12
|
-
export declare function mergeCopyResults(results: SpaceFsCopyResult[]): SpaceFsCopyResult;
|
|
13
|
-
type SpaceNode = {
|
|
14
|
-
type: "dir";
|
|
15
|
-
tree: SpaceFsTreeResponse;
|
|
16
|
-
} | {
|
|
17
|
-
type: "file";
|
|
18
|
-
} | null;
|
|
19
|
-
export declare function statSpacePath(files: SpaceFiles, path: string): Promise<SpaceNode>;
|
|
20
|
-
export declare function checkDestination(input: {
|
|
21
|
-
sourceCount: number;
|
|
22
|
-
display: string;
|
|
23
|
-
stat: (path: string) => Promise<"dir" | "file" | null>;
|
|
24
|
-
path: string;
|
|
25
|
-
parent: string;
|
|
26
|
-
}): Promise<boolean>;
|
|
27
|
-
export declare const spaceNodeType: (files: SpaceFiles, path: string) => Promise<"dir" | "file" | null>;
|
|
28
|
-
export declare const localNodeType: (path: string) => Promise<"dir" | "file" | null>;
|
|
29
|
-
export declare function uploadToSpace(input: {
|
|
30
|
-
files: SpaceFiles;
|
|
31
|
-
sources: string[];
|
|
32
|
-
destination: string;
|
|
33
|
-
intoDirectory: boolean;
|
|
34
|
-
options: CopyOptions;
|
|
35
|
-
onProgress: (stats: SpaceFsCopyStats) => void;
|
|
36
|
-
}): Promise<SpaceFsCopyResult>;
|
|
37
|
-
export declare function downloadFromSpace(input: {
|
|
38
|
-
sources: Array<{
|
|
39
|
-
files: SpaceFiles;
|
|
40
|
-
path: string;
|
|
41
|
-
}>;
|
|
42
|
-
destination: string;
|
|
43
|
-
intoDirectory: boolean;
|
|
44
|
-
options: CopyOptions;
|
|
45
|
-
onProgress: (stats: SpaceFsCopyStats) => void;
|
|
46
|
-
}): Promise<SpaceFsCopyResult>;
|
|
47
|
-
export declare function copyLocal(input: {
|
|
48
|
-
sources: string[];
|
|
49
|
-
destination: string;
|
|
50
|
-
intoDirectory: boolean;
|
|
51
|
-
options: CopyOptions;
|
|
52
|
-
}): Promise<SpaceFsCopyResult>;
|
|
53
|
-
export {};
|