overvues 0.0.1 → 0.4.10
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 +58 -2
- package/dist/ansi.js +24 -0
- package/dist/attach-client.js +586 -0
- package/dist/auth-connect-browser.js +112 -0
- package/dist/auth-connect.js +306 -0
- package/dist/browser-bootstrap.js +190 -0
- package/dist/browser-loopback.js +289 -0
- package/dist/build-identity.js +6 -0
- package/dist/codex-reviewer-apparmor.json +4 -0
- package/dist/codex-reviewer-seccomp.json +1238 -0
- package/dist/codex-runtime-protocol.js +1 -0
- package/dist/codex-subscription.js +53 -0
- package/dist/config.js +297 -0
- package/dist/connect-comparison-code.js +26 -0
- package/dist/development-runner.js +109 -0
- package/dist/dns-doctor.js +390 -0
- package/dist/docker-names.js +47 -0
- package/dist/doctor.js +114 -0
- package/dist/gadget-job.js +804 -0
- package/dist/health-check.js +112 -0
- package/dist/help.js +71 -0
- package/dist/host-auth.js +22 -0
- package/dist/host-diagnostics.js +20 -0
- package/dist/host-runtime-identity.js +39 -0
- package/dist/host-runtime-metadata.js +56 -0
- package/dist/host-service.js +377 -0
- package/dist/host-stack.js +484 -0
- package/dist/host-supervisor.js +237 -0
- package/dist/host-update.js +387 -0
- package/dist/hub-address.js +100 -0
- package/dist/hub-client.js +459 -0
- package/dist/hub-kind.js +88 -0
- package/dist/identity.js +73 -0
- package/dist/index.js +185 -0
- package/dist/init.js +295 -0
- package/dist/isolated-run-cache.js +116 -0
- package/dist/local-stack.js +685 -0
- package/dist/machine-capacity.js +128 -0
- package/dist/managed-runner-image.js +13 -0
- package/dist/os-acted-record.js +49 -0
- package/dist/os-adapter.js +8190 -0
- package/dist/os-command.js +292 -0
- package/dist/os-handoff.js +274 -0
- package/dist/os-keychain.js +247 -0
- package/dist/os-machine.js +818 -0
- package/dist/os-owner.js +61 -0
- package/dist/os-private-file.js +98 -0
- package/dist/os-protocol.js +468 -0
- package/dist/os-session-store.js +133 -0
- package/dist/os-status.js +102 -0
- package/dist/picker.js +863 -0
- package/dist/portable-workspace-capability.js +60 -0
- package/dist/project-environment-capability.js +62 -0
- package/dist/project-environment.js +28 -0
- package/dist/project-preparation.js +134 -0
- package/dist/readiness.js +28 -0
- package/dist/redaction.js +27 -0
- package/dist/reviewer-isolation-capability.js +61 -0
- package/dist/runner-api-auth.js +80 -0
- package/dist/runner-command-fence.js +536 -0
- package/dist/runner-inspection.js +57 -0
- package/dist/runner-inventory.js +587 -0
- package/dist/runner-server.js +2520 -0
- package/dist/runner-session.js +470 -0
- package/dist/runner-slug-folder.js +39 -0
- package/dist/runner-slug.js +40 -0
- package/dist/setup.js +139 -0
- package/dist/shutdown.js +102 -0
- package/dist/splash.js +65 -0
- package/dist/staged-workspaces.js +441 -0
- package/dist/staging-disk.js +97 -0
- package/dist/terminal-lane.js +339 -0
- package/dist/terminal-recovery.js +502 -0
- package/licenses/capnweb.txt +23 -0
- package/licenses/moby-profiles.txt +212 -0
- package/licenses/ws.txt +22 -0
- package/package.json +28 -7
- package/cli.js +0 -2
package/dist/setup.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { TILLER_CLIENT_ID, TILLER_CLIENT_SECRET, CONFIG_PATH, HUB_URL, LOCAL_RUNNER_IMAGE, configExists, isLocalHubUrl, loadConfig, } from "./config.js";
|
|
2
|
+
import { hubParentDomainsText, isAllowedHubUrl } from "./hub-address.js";
|
|
3
|
+
import { checkHubHealth, dockerInstalled, dockerReady, localImageExists, } from "./local-stack.js";
|
|
4
|
+
import { hasFailures, hasWarnings, printCheckReport } from "./readiness.js";
|
|
5
|
+
import { CLI } from "./identity.js";
|
|
6
|
+
/** What to check when the hub does not answer: the `tiller` build keeps its words. */
|
|
7
|
+
const HUB_DEPLOYMENT = CLI.name === "tiller" ? "the tiller-hub deployment" : "the hub";
|
|
8
|
+
function sourceLabel(envValue, configValue) {
|
|
9
|
+
if (envValue)
|
|
10
|
+
return "via env";
|
|
11
|
+
if (configValue)
|
|
12
|
+
return `via ${CONFIG_PATH}`;
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
function configHint() {
|
|
16
|
+
return `run \`${CLI.command} init --hub-url https://<exact-host>.workers.dev\``;
|
|
17
|
+
}
|
|
18
|
+
export async function collectSetupChecks(options = {}) {
|
|
19
|
+
const config = loadConfig();
|
|
20
|
+
const checks = [];
|
|
21
|
+
const configPresent = configExists();
|
|
22
|
+
const configuredHubUrl = (process.env[CLI.hubUrlEnv] || config.hubUrl || "").trim();
|
|
23
|
+
const accessSource = config.clientId && config.clientSecret ? `via ${CONFIG_PATH}` : undefined;
|
|
24
|
+
const hasAccessCredentials = Boolean(TILLER_CLIENT_ID && TILLER_CLIENT_SECRET);
|
|
25
|
+
const hasConfiguredHubUrl = Boolean(configuredHubUrl);
|
|
26
|
+
const supportedHubUrl = isAllowedHubUrl(configuredHubUrl)
|
|
27
|
+
|| isLocalHubUrl(configuredHubUrl);
|
|
28
|
+
const localHub = isLocalHubUrl(configuredHubUrl);
|
|
29
|
+
const hubHealth = supportedHubUrl ? await checkHubHealth() : null;
|
|
30
|
+
const requireLocal = options.local === true;
|
|
31
|
+
checks.push({
|
|
32
|
+
id: "config-file",
|
|
33
|
+
label: "config file",
|
|
34
|
+
level: configPresent ? "ok" : hasAccessCredentials || hasConfiguredHubUrl ? "warn" : "fail",
|
|
35
|
+
detail: configPresent ? CONFIG_PATH : `missing: ${CONFIG_PATH}`,
|
|
36
|
+
fixHint: configPresent ? undefined : configHint(),
|
|
37
|
+
});
|
|
38
|
+
checks.push({
|
|
39
|
+
id: "hub-url",
|
|
40
|
+
label: "hub URL configured",
|
|
41
|
+
level: supportedHubUrl ? "ok" : "fail",
|
|
42
|
+
detail: supportedHubUrl
|
|
43
|
+
? `${configuredHubUrl}${sourceLabel(process.env[CLI.hubUrlEnv], config.hubUrl) ? ` (${sourceLabel(process.env[CLI.hubUrlEnv], config.hubUrl)})` : ""}`
|
|
44
|
+
: hasConfiguredHubUrl
|
|
45
|
+
? `saved URL is not an exact https Hub origin under ${hubParentDomainsText()}`
|
|
46
|
+
: "hubUrl missing",
|
|
47
|
+
fixHint: supportedHubUrl
|
|
48
|
+
? undefined
|
|
49
|
+
: `run \`${CLI.command} host setup --hub-url https://<exact-host>.workers.dev\``,
|
|
50
|
+
});
|
|
51
|
+
checks.push({
|
|
52
|
+
id: "access-creds",
|
|
53
|
+
label: "hub connection",
|
|
54
|
+
level: hasAccessCredentials || localHub ? "ok" : "warn",
|
|
55
|
+
detail: hasAccessCredentials
|
|
56
|
+
? accessSource ?? "configured"
|
|
57
|
+
: localHub
|
|
58
|
+
? "not required for localhost development"
|
|
59
|
+
: "not configured",
|
|
60
|
+
fixHint: hasAccessCredentials || localHub
|
|
61
|
+
? undefined
|
|
62
|
+
: `run \`${CLI.command} init --hub-url https://<exact-host>.workers.dev\` to renew the encrypted connection`,
|
|
63
|
+
});
|
|
64
|
+
if (hubHealth) {
|
|
65
|
+
checks.push({
|
|
66
|
+
id: "hub-reachable",
|
|
67
|
+
label: "hub reachable",
|
|
68
|
+
level: hubHealth.ok ? "ok" : "fail",
|
|
69
|
+
detail: hubHealth.ok ? HUB_URL : hubHealth.detail ?? HUB_URL,
|
|
70
|
+
fixHint: hubHealth.ok
|
|
71
|
+
? undefined
|
|
72
|
+
: hasAccessCredentials
|
|
73
|
+
? `check ${HUB_DEPLOYMENT} at ${HUB_URL}, then reconnect with \`${CLI.command} host setup\``
|
|
74
|
+
: `check ${HUB_DEPLOYMENT} at ${HUB_URL}, then reconnect through \`${CLI.command} init\``,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
checks.push({
|
|
79
|
+
id: "hub-reachable",
|
|
80
|
+
label: "hub reachable",
|
|
81
|
+
level: "warn",
|
|
82
|
+
detail: "skipped until hubUrl is configured",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const hasDockerInstalled = dockerInstalled();
|
|
86
|
+
checks.push({
|
|
87
|
+
id: "docker-installed",
|
|
88
|
+
label: "docker installed",
|
|
89
|
+
level: hasDockerInstalled ? "ok" : requireLocal ? "fail" : "warn",
|
|
90
|
+
detail: hasDockerInstalled ? "docker is on PATH" : "docker not found",
|
|
91
|
+
fixHint: hasDockerInstalled
|
|
92
|
+
? undefined
|
|
93
|
+
: requireLocal
|
|
94
|
+
? `install Docker Desktop or another Docker engine and re-run \`${CLI.command} setup\``
|
|
95
|
+
: "needed only for workloads on Your machine; install Docker Desktop or another Docker engine before selecting it",
|
|
96
|
+
});
|
|
97
|
+
const isDockerReady = hasDockerInstalled && dockerReady();
|
|
98
|
+
const hasLocalImage = isDockerReady && localImageExists();
|
|
99
|
+
checks.push({
|
|
100
|
+
id: "docker-running",
|
|
101
|
+
label: "docker running",
|
|
102
|
+
level: hasDockerInstalled ? (isDockerReady ? "ok" : requireLocal ? "fail" : "warn") : "warn",
|
|
103
|
+
detail: hasDockerInstalled ? (isDockerReady ? "daemon ready" : "Docker daemon is not responding") : "skipped until Docker is installed",
|
|
104
|
+
fixHint: hasDockerInstalled && !isDockerReady
|
|
105
|
+
? requireLocal
|
|
106
|
+
? `start Docker Desktop or your Docker daemon and re-run \`${CLI.command} setup\``
|
|
107
|
+
: "needed only for workloads on Your machine; start Docker Desktop or your Docker daemon before selecting it"
|
|
108
|
+
: undefined,
|
|
109
|
+
});
|
|
110
|
+
checks.push({
|
|
111
|
+
id: "host-image",
|
|
112
|
+
label: "host image present",
|
|
113
|
+
level: isDockerReady ? (hasLocalImage ? "ok" : requireLocal ? "fail" : "warn") : "warn",
|
|
114
|
+
detail: isDockerReady ? (hasLocalImage ? LOCAL_RUNNER_IMAGE : `${LOCAL_RUNNER_IMAGE} not found`) : "skipped until Docker is running",
|
|
115
|
+
fixHint: isDockerReady && !hasLocalImage
|
|
116
|
+
? requireLocal
|
|
117
|
+
? `run \`${CLI.command} host setup\` to pull the image, or set localRunnerImage in config if using a custom image`
|
|
118
|
+
: `needed only for workloads on Your machine; run \`${CLI.command} host setup\` to pull the image automatically`
|
|
119
|
+
: undefined,
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
checks,
|
|
123
|
+
ready: !hasFailures(checks),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export async function runSetup(argv = []) {
|
|
127
|
+
const requireLocal = argv.includes("--local");
|
|
128
|
+
const report = await collectSetupChecks({ local: requireLocal });
|
|
129
|
+
printCheckReport("Setup check", report.checks);
|
|
130
|
+
const summary = !report.ready
|
|
131
|
+
? `${CLI.logTag} Setup incomplete. Fix the items above and re-run \`${CLI.command} setup\`.\n`
|
|
132
|
+
: hasWarnings(report.checks)
|
|
133
|
+
? requireLocal
|
|
134
|
+
? `${CLI.logTag} Setup is usable but has warnings. Review the items above before selecting Your machine.\n`
|
|
135
|
+
: `${CLI.logTag} Cloudflare Containers are ready. The warnings above only matter if you want to use Your machine later.\n`
|
|
136
|
+
: `${CLI.logTag} Setup complete. You can run \`${CLI.command}\`.\n`;
|
|
137
|
+
process.stderr.write(summary);
|
|
138
|
+
process.exitCode = report.ready ? 0 : 1;
|
|
139
|
+
}
|
package/dist/shutdown.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const DEFAULT_CHILD_TERM_GRACE_MS = 2_000;
|
|
2
|
+
const DEFAULT_CHILD_KILL_GRACE_MS = 2_000;
|
|
3
|
+
const DEFAULT_HTTP_FORCE_CLOSE_MS = 1_000;
|
|
4
|
+
const DEFAULT_HTTP_RESOLVE_CLOSE_MS = 3_000;
|
|
5
|
+
function setShutdownTimeout(callback, ms) {
|
|
6
|
+
const timeout = setTimeout(callback, ms);
|
|
7
|
+
if (typeof timeout === "object" && "unref" in timeout && typeof timeout.unref === "function") {
|
|
8
|
+
timeout.unref();
|
|
9
|
+
}
|
|
10
|
+
return timeout;
|
|
11
|
+
}
|
|
12
|
+
function childHasExited(child) {
|
|
13
|
+
return child.exitCode !== null || child.signalCode !== null;
|
|
14
|
+
}
|
|
15
|
+
function cleanupChildHandles(child) {
|
|
16
|
+
child.stdout?.removeAllListeners("data");
|
|
17
|
+
child.stderr?.removeAllListeners("data");
|
|
18
|
+
child.stdout?.destroy();
|
|
19
|
+
child.stderr?.destroy();
|
|
20
|
+
child.stdin?.destroy();
|
|
21
|
+
child.unref();
|
|
22
|
+
}
|
|
23
|
+
function sendChildSignal(child, signal) {
|
|
24
|
+
try {
|
|
25
|
+
return child.kill(signal);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function waitForChildExit(child, timeoutMs) {
|
|
32
|
+
if (childHasExited(child)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (timeoutMs <= 0) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
let settled = false;
|
|
40
|
+
const finish = (exited) => {
|
|
41
|
+
if (settled)
|
|
42
|
+
return;
|
|
43
|
+
settled = true;
|
|
44
|
+
clearTimeout(timeout);
|
|
45
|
+
child.off("exit", onExit);
|
|
46
|
+
child.off("close", onExit);
|
|
47
|
+
resolve(exited);
|
|
48
|
+
};
|
|
49
|
+
const onExit = () => finish(true);
|
|
50
|
+
const timeout = setShutdownTimeout(() => finish(childHasExited(child)), timeoutMs);
|
|
51
|
+
child.once("exit", onExit);
|
|
52
|
+
child.once("close", onExit);
|
|
53
|
+
if (childHasExited(child)) {
|
|
54
|
+
finish(true);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export async function stopChildProcess(child, options = {}) {
|
|
59
|
+
if (!child?.pid)
|
|
60
|
+
return;
|
|
61
|
+
const termGraceMs = options.termGraceMs ?? DEFAULT_CHILD_TERM_GRACE_MS;
|
|
62
|
+
const killGraceMs = options.killGraceMs ?? DEFAULT_CHILD_KILL_GRACE_MS;
|
|
63
|
+
const signal = options.signal ?? "SIGTERM";
|
|
64
|
+
if (!childHasExited(child) && !sendChildSignal(child, signal)) {
|
|
65
|
+
cleanupChildHandles(child);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!await waitForChildExit(child, termGraceMs)) {
|
|
69
|
+
if (!sendChildSignal(child, "SIGKILL")) {
|
|
70
|
+
cleanupChildHandles(child);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await waitForChildExit(child, killGraceMs);
|
|
74
|
+
}
|
|
75
|
+
cleanupChildHandles(child);
|
|
76
|
+
}
|
|
77
|
+
export function closeHttpServer(server, options = {}) {
|
|
78
|
+
const forceAfterMs = options.forceAfterMs ?? DEFAULT_HTTP_FORCE_CLOSE_MS;
|
|
79
|
+
const resolveAfterMs = options.resolveAfterMs ?? DEFAULT_HTTP_RESOLVE_CLOSE_MS;
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
let settled = false;
|
|
82
|
+
const forceClose = () => {
|
|
83
|
+
server.closeIdleConnections?.();
|
|
84
|
+
server.closeAllConnections?.();
|
|
85
|
+
};
|
|
86
|
+
const finish = () => {
|
|
87
|
+
if (settled)
|
|
88
|
+
return;
|
|
89
|
+
settled = true;
|
|
90
|
+
clearTimeout(forceTimer);
|
|
91
|
+
clearTimeout(resolveTimer);
|
|
92
|
+
resolve();
|
|
93
|
+
};
|
|
94
|
+
const forceTimer = setShutdownTimeout(forceClose, forceAfterMs);
|
|
95
|
+
const resolveTimer = setShutdownTimeout(() => {
|
|
96
|
+
forceClose();
|
|
97
|
+
finish();
|
|
98
|
+
}, resolveAfterMs);
|
|
99
|
+
server.close(() => finish());
|
|
100
|
+
server.closeIdleConnections?.();
|
|
101
|
+
});
|
|
102
|
+
}
|
package/dist/splash.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ansi } from "./ansi.js";
|
|
2
|
+
// Benford dory — two-masted junk-rigged schooner with portholes.
|
|
3
|
+
//
|
|
4
|
+
// | |
|
|
5
|
+
// /| /|
|
|
6
|
+
// /_| /_|
|
|
7
|
+
// __/__|_/__|___
|
|
8
|
+
// \__o__o__o__/
|
|
9
|
+
// ~^~~^~
|
|
10
|
+
const BOAT = [
|
|
11
|
+
" | |",
|
|
12
|
+
" /| /|",
|
|
13
|
+
" /_| /_|",
|
|
14
|
+
"___/__|_/__|___",
|
|
15
|
+
" \\__o__o__o___/",
|
|
16
|
+
];
|
|
17
|
+
const DECK_WIDTH = 15;
|
|
18
|
+
function waveFrame(tick) {
|
|
19
|
+
const p = "~^~~^~";
|
|
20
|
+
let s = "";
|
|
21
|
+
for (let i = 0; i < DECK_WIDTH; i++)
|
|
22
|
+
s += p[(i + tick) % p.length];
|
|
23
|
+
return `${ansi.cyan}${s}${ansi.reset}`;
|
|
24
|
+
}
|
|
25
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
26
|
+
async function waitForSettlementOrWaveTick(settled, timeoutMs) {
|
|
27
|
+
let timer = null;
|
|
28
|
+
try {
|
|
29
|
+
await Promise.race([
|
|
30
|
+
settled,
|
|
31
|
+
new Promise((resolve) => {
|
|
32
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
if (timer)
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export async function playSplash(work) {
|
|
42
|
+
if (!process.stderr.isTTY)
|
|
43
|
+
return work;
|
|
44
|
+
let done = false;
|
|
45
|
+
const settled = work.then(() => { done = true; }, () => { done = true; });
|
|
46
|
+
// Draw boat line by line
|
|
47
|
+
process.stderr.write("\n");
|
|
48
|
+
for (let i = 0; i < 3; i++) {
|
|
49
|
+
process.stderr.write(`${ansi.bold}${BOAT[i]}${ansi.reset}\n`);
|
|
50
|
+
await sleep(60);
|
|
51
|
+
}
|
|
52
|
+
process.stderr.write(`${ansi.yellow}${BOAT[3]}${ansi.reset}\n`);
|
|
53
|
+
await sleep(60);
|
|
54
|
+
process.stderr.write(`${ansi.yellow}${BOAT[4].replace(/o/g, `${ansi.reset}${ansi.cyan}o${ansi.reset}${ansi.yellow}`)}${ansi.reset}\n`);
|
|
55
|
+
await sleep(120);
|
|
56
|
+
// Then animate wave while work runs
|
|
57
|
+
let tick = 0;
|
|
58
|
+
while (!done) {
|
|
59
|
+
process.stderr.write(`\r${ansi.eraseLine}${waveFrame(tick)}`);
|
|
60
|
+
tick++;
|
|
61
|
+
await waitForSettlementOrWaveTick(settled, 400);
|
|
62
|
+
}
|
|
63
|
+
process.stderr.write(`\r${ansi.eraseLine}\n`);
|
|
64
|
+
return work;
|
|
65
|
+
}
|