gentle-pi 4.6.0 → 4.7.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 +10 -11
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +5 -2
- package/assets/agents/gentle-ai-worker.md +3 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +16 -1
- package/assets/orchestrator-delegation-reference.md +4 -4
- package/assets/orchestrator-delegation.md +1 -1
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +7 -5
- package/assets/orchestrator.md +3 -3
- package/bin/gentle-shell.mjs +164 -56
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/delegated-verification.md +29 -7
- package/docs/gentle-agents-activity.md +14 -0
- package/docs/gentle-shell.md +54 -16
- package/docs/install-wizard.md +1 -1
- package/docs/permission-modes.md +9 -4
- package/docs/readme-reference.md +75 -30
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +326 -34
- package/extensions/gentle-ai.ts +1496 -454
- package/extensions/gentle-shell.ts +293 -63
- package/extensions/gentle-todo.ts +18 -2
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +175 -18
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +46 -0
- package/lib/agents-history.ts +24 -5
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-runner.ts +183 -12
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/card-content-policy.ts +8 -6
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +270 -140
- package/lib/jobs-view.ts +198 -11
- package/lib/model-routing-authority.ts +22 -4
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +96 -19
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +46 -10
- package/lib/review-integration-v2.ts +7 -1
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/verifier-admission.ts +1 -1
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +40 -15
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +93 -16
- package/runtime/review-integration-v2.mjs +7 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +5 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +40 -28
- package/scripts/verify-package-files.mjs +12 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +178 -2
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +30 -5
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +3 -3
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1070 -12
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +113 -38
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +77 -10
- package/tests/gentle-shell.test.ts +899 -59
- package/tests/gentle-todo.test.ts +19 -2
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +8 -4
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +176 -4
- package/tests/installer-posix-bootstrap.test.ts +1 -1
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/jobs-view.test.ts +260 -6
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +4 -1
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +3 -1
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +11 -9
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/pi-update-launcher.test.ts +8 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +115 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +1 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/skill-registry.test.ts +838 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +5 -3
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verify-first-launch-contract.test.ts +78 -3
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +28 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +23 -18
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
// A corporate proxy is the only route to the internet for many operators, and
|
|
2
|
+
// npm already honours it, so the installer has to as well. The Gentle AI
|
|
3
|
+
// release asset is fetched with node:https, whose client ignores HTTPS_PROXY,
|
|
4
|
+
// HTTP_PROXY and NO_PROXY unless the process opts in, and Node only grew that
|
|
5
|
+
// opt-in in v24 (NODE_USE_ENV_PROXY / --use-env-proxy) while this package
|
|
6
|
+
// supports node >= 22.19.0. The tunnel below is the portable equivalent of
|
|
7
|
+
// that opt-in: it opens a CONNECT tunnel to the proxy and speaks TLS to the
|
|
8
|
+
// origin host through it, so the origin's own certificate still decides
|
|
9
|
+
// whether the connection is trusted and the proxy never sees the request.
|
|
10
|
+
import https from "node:https";
|
|
11
|
+
import net from "node:net";
|
|
12
|
+
import tls from "node:tls";
|
|
13
|
+
|
|
14
|
+
// Both spellings are read because shells and CI runners disagree about the
|
|
15
|
+
// convention, and the lowercase form is what most corporate setups export.
|
|
16
|
+
const PROXY_ENV_BY_PROTOCOL = Object.freeze({
|
|
17
|
+
"https:": Object.freeze(["HTTPS_PROXY", "https_proxy"]),
|
|
18
|
+
"http:": Object.freeze(["HTTP_PROXY", "http_proxy"]),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const TRANSIENT_PROXY_STATUSES = Object.freeze([429, 500, 502, 503, 504]);
|
|
22
|
+
|
|
23
|
+
function proxyPort(proxy) {
|
|
24
|
+
if (proxy.port !== "") return Number(proxy.port);
|
|
25
|
+
return proxy.protocol === "https:" ? 443 : 80;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// URL.hostname keeps the brackets of an IPv6 literal, but a socket address
|
|
29
|
+
// and a TLS server name need the bare address, so the brackets come off here.
|
|
30
|
+
// The bare address stays the server name because dropping it would turn off
|
|
31
|
+
// the certificate identity check.
|
|
32
|
+
function proxyHost(proxy) {
|
|
33
|
+
return proxy.hostname.replace(/^\[|\]$/g, "");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// A proxy value that is not a usable http(s) URL is ignored rather than
|
|
37
|
+
// allowed to break an install that would have reached the host directly.
|
|
38
|
+
function parseProxy(raw) {
|
|
39
|
+
try {
|
|
40
|
+
// A bare "host:port" is a proxy address, not a URL whose scheme is "host".
|
|
41
|
+
const proxy = new URL(raw.includes("://") ? raw : `http://${raw}`);
|
|
42
|
+
if (proxy.protocol !== "http:" && proxy.protocol !== "https:") return undefined;
|
|
43
|
+
if (proxy.hostname === "") return undefined;
|
|
44
|
+
// Credentials are percent-encoded in the URL and decoded when the
|
|
45
|
+
// Proxy-Authorization header is built. Decoding them here rejects a
|
|
46
|
+
// malformed value now, instead of failing later inside the tunnel.
|
|
47
|
+
decodeURIComponent(proxy.username);
|
|
48
|
+
decodeURIComponent(proxy.password);
|
|
49
|
+
return proxy;
|
|
50
|
+
} catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function splitHostPort(entry) {
|
|
56
|
+
if (entry.startsWith("[")) {
|
|
57
|
+
const end = entry.indexOf("]");
|
|
58
|
+
if (end === -1) return { host: entry, port: undefined };
|
|
59
|
+
const rest = entry.slice(end + 1);
|
|
60
|
+
return { host: entry.slice(0, end + 1), port: rest.startsWith(":") ? rest.slice(1) : undefined };
|
|
61
|
+
}
|
|
62
|
+
const separator = entry.lastIndexOf(":");
|
|
63
|
+
// More than one colon is a bare IPv6 address, which carries no port.
|
|
64
|
+
if (separator === -1 || entry.indexOf(":") !== separator) return { host: entry, port: undefined };
|
|
65
|
+
return { host: entry.slice(0, separator), port: entry.slice(separator + 1) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function matchesNoProxy(target, entry) {
|
|
69
|
+
if (entry === "*") return true;
|
|
70
|
+
const { host: pattern, port } = splitHostPort(entry.toLowerCase());
|
|
71
|
+
const host = target.hostname.toLowerCase();
|
|
72
|
+
const targetPort = target.port !== "" ? target.port : target.protocol === "https:" ? "443" : "80";
|
|
73
|
+
if (port !== undefined && port !== targetPort) return false;
|
|
74
|
+
if (pattern.startsWith("*.")) {
|
|
75
|
+
const base = pattern.slice(2);
|
|
76
|
+
return host === base || host.endsWith(`.${base}`);
|
|
77
|
+
}
|
|
78
|
+
// A leading dot covers the domain and its subdomains; a bare domain is an
|
|
79
|
+
// exact match, so one entry never silently exempts a whole namespace.
|
|
80
|
+
if (pattern.startsWith(".")) {
|
|
81
|
+
const base = pattern.slice(1);
|
|
82
|
+
return host === base || host.endsWith(`.${base}`);
|
|
83
|
+
}
|
|
84
|
+
return host === pattern;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The proxy that applies to `target`, or undefined when the target is reached
|
|
89
|
+
* directly. HTTPS_PROXY answers for an https target and HTTP_PROXY is the
|
|
90
|
+
* fallback, exactly as every other HTTP client on the platform resolves them,
|
|
91
|
+
* and NO_PROXY always wins over both. A value that is not a usable proxy URL
|
|
92
|
+
* is ignored, so a stray variable cannot break an install that would otherwise
|
|
93
|
+
* reach the host directly.
|
|
94
|
+
*/
|
|
95
|
+
export function resolveProxyForTarget(target, env = process.env) {
|
|
96
|
+
const url = target instanceof URL ? target : new URL(String(target));
|
|
97
|
+
const noProxy = String(env.NO_PROXY ?? env.no_proxy ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
98
|
+
if (noProxy.some((entry) => matchesNoProxy(url, entry))) return undefined;
|
|
99
|
+
const primary = PROXY_ENV_BY_PROTOCOL[url.protocol] ?? [];
|
|
100
|
+
const fallback = url.protocol === "https:" ? PROXY_ENV_BY_PROTOCOL["http:"] : [];
|
|
101
|
+
for (const key of [...primary, ...fallback]) {
|
|
102
|
+
const raw = env[key];
|
|
103
|
+
if (typeof raw !== "string" || raw.trim() === "") continue;
|
|
104
|
+
const proxy = parseProxy(raw.trim());
|
|
105
|
+
if (proxy !== undefined) return proxy;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function tunnelAuthority(host, port) {
|
|
111
|
+
return host.includes(":") ? `[${host}]:${port}` : `${host}:${port}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The TLS options for the connection to an https proxy.
|
|
116
|
+
*
|
|
117
|
+
* The proxy host is always the name the certificate is checked against,
|
|
118
|
+
* because Node leaves the socket host unset and would otherwise fall back
|
|
119
|
+
* to "localhost". An IP address cannot be a server name, and a modern Node
|
|
120
|
+
* refuses the handshake outright when it is given one, so the server name
|
|
121
|
+
* is only sent for a hostname.
|
|
122
|
+
*/
|
|
123
|
+
export function proxyTlsOptions(proxy) {
|
|
124
|
+
return hostTlsOptions(proxyHost(proxy));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The TLS options for a host reached through the tunnel.
|
|
129
|
+
*
|
|
130
|
+
* The host is always the name the certificate is checked against, because
|
|
131
|
+
* Node leaves the socket host unset and would otherwise fall back to
|
|
132
|
+
* "localhost". An IP address cannot be a server name, and a modern Node
|
|
133
|
+
* refuses the handshake outright when it is given one, so the server name
|
|
134
|
+
* is only sent for a hostname.
|
|
135
|
+
*/
|
|
136
|
+
export function hostTlsOptions(name) {
|
|
137
|
+
return net.isIP(name) ? { host: name } : { host: name, servername: name };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The trust options for a handshake, so a caller that trusts a private
|
|
142
|
+
* certificate authority reaches a peer that presents one.
|
|
143
|
+
*
|
|
144
|
+
* An explicit `ca` replaces Node's default certificate authority list
|
|
145
|
+
* rather than adding to it, so a caller that sets it has to include the
|
|
146
|
+
* authorities of both peers it expects to reach. The proxy and the origin
|
|
147
|
+
* are separate peers, so a private authority for one of them and a public
|
|
148
|
+
* certificate for the other need both authorities in the list.
|
|
149
|
+
*/
|
|
150
|
+
export function proxyTrustOptions(options) {
|
|
151
|
+
return {
|
|
152
|
+
...(options.rejectUnauthorized === undefined ? {} : { rejectUnauthorized: options.rejectUnauthorized }),
|
|
153
|
+
...(options.ca === undefined ? {} : { ca: options.ca }),
|
|
154
|
+
...(options.cert === undefined ? {} : { cert: options.cert }),
|
|
155
|
+
...(options.key === undefined ? {} : { key: options.key }),
|
|
156
|
+
...(options.passphrase === undefined ? {} : { passphrase: options.passphrase }),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The trust options for the proxy handshake.
|
|
162
|
+
*
|
|
163
|
+
* The client credentials belong to the origin, so they stay on the origin
|
|
164
|
+
* handshake: a proxy that asks for a client certificate would otherwise
|
|
165
|
+
* receive the identity of the origin. The certificate authority and the
|
|
166
|
+
* verification setting are shared, because the proxy is a peer of the
|
|
167
|
+
* client just like the origin is.
|
|
168
|
+
*
|
|
169
|
+
* The certificate authority is the same list the origin handshake uses, so
|
|
170
|
+
* it has to trust both peers, and an explicit list replaces Node's default
|
|
171
|
+
* authorities rather than adding to them.
|
|
172
|
+
*/
|
|
173
|
+
export function proxyHandshakeTrustOptions(trust) {
|
|
174
|
+
return {
|
|
175
|
+
...(trust.rejectUnauthorized === undefined ? {} : { rejectUnauthorized: trust.rejectUnauthorized }),
|
|
176
|
+
...(trust.ca === undefined ? {} : { ca: trust.ca }),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* An https.Agent whose sockets are CONNECT tunnels to `proxy`. The origin host
|
|
182
|
+
* is still verified by TLS over the tunnel, so the proxy cannot read the
|
|
183
|
+
* request and cannot impersonate the release host without the origin's own
|
|
184
|
+
* certificate chain failing the handshake.
|
|
185
|
+
*/
|
|
186
|
+
export function createProxyTunnelAgent(proxy, headerTimeoutMs = 10_000, trust = {}) {
|
|
187
|
+
const agent = new https.Agent({ keepAlive: false });
|
|
188
|
+
agent.createConnection = (options, callback) => {
|
|
189
|
+
const host = options.host ?? options.hostname;
|
|
190
|
+
const port = Number(options.port ?? 443);
|
|
191
|
+
const authority = tunnelAuthority(host, port);
|
|
192
|
+
const raw = net.connect({ host: proxyHost(proxy), port: proxyPort(proxy) });
|
|
193
|
+
let channel = raw;
|
|
194
|
+
let head = Buffer.alloc(0);
|
|
195
|
+
let delivered = false;
|
|
196
|
+
let timer;
|
|
197
|
+
const closed = new Set();
|
|
198
|
+
// The listener identity of each socket is kept so every one of them can
|
|
199
|
+
// be detached again on completion, failure and teardown.
|
|
200
|
+
const listeners = new Map();
|
|
201
|
+
const onEnd = () => fail(Object.assign(new Error("Gentle AI download proxy closed before completing CONNECT headers"), { code: "ECONNRESET" }));
|
|
202
|
+
const deliver = (error, secure) => {
|
|
203
|
+
if (delivered) return;
|
|
204
|
+
delivered = true;
|
|
205
|
+
clearTimeout(timer);
|
|
206
|
+
raw.off("connect", onConnect);
|
|
207
|
+
for (const [socket, bound] of listeners) {
|
|
208
|
+
// TLS queues an error while handling EOF, so the error handler
|
|
209
|
+
// stays until teardown finishes and is removed with the close.
|
|
210
|
+
if (error && !closed.has(socket)) socket.once("close", () => socket.off("error", bound.error));
|
|
211
|
+
else socket.off("error", bound.error);
|
|
212
|
+
socket.off("end", bound.end);
|
|
213
|
+
socket.off("close", bound.close);
|
|
214
|
+
socket.off("data", onData);
|
|
215
|
+
}
|
|
216
|
+
callback(error, secure);
|
|
217
|
+
};
|
|
218
|
+
function fail(error) {
|
|
219
|
+
if (delivered) return;
|
|
220
|
+
channel.destroy();
|
|
221
|
+
raw.destroy();
|
|
222
|
+
deliver(error, undefined);
|
|
223
|
+
}
|
|
224
|
+
const watch = (socket) => {
|
|
225
|
+
const bound = {
|
|
226
|
+
error: fail,
|
|
227
|
+
end: onEnd,
|
|
228
|
+
close: () => {
|
|
229
|
+
closed.add(socket);
|
|
230
|
+
onEnd();
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
listeners.set(socket, bound);
|
|
234
|
+
socket.on("error", bound.error);
|
|
235
|
+
socket.on("end", bound.end);
|
|
236
|
+
socket.on("close", bound.close);
|
|
237
|
+
return bound;
|
|
238
|
+
};
|
|
239
|
+
// The request cannot enforce its deadline until this agent hands it a
|
|
240
|
+
// socket. Bound TCP, proxy TLS and the CONNECT headers here instead.
|
|
241
|
+
timer = setTimeout(() => fail(Object.assign(new Error("Gentle AI download proxy CONNECT timed out"), { code: "GENTLE_AI_DOWNLOAD_TIMEOUT" })), headerTimeoutMs);
|
|
242
|
+
watch(raw);
|
|
243
|
+
raw.once("connect", onConnect);
|
|
244
|
+
function onConnect() {
|
|
245
|
+
// A proxy reached over TLS speaks the same CONNECT protocol once its
|
|
246
|
+
// own handshake is done, so the tunnel is written to whichever
|
|
247
|
+
// channel is open.
|
|
248
|
+
if (proxy.protocol === "https:") {
|
|
249
|
+
channel = tls.connect({ socket: raw, ...proxyTlsOptions(proxy), ...proxyHandshakeTrustOptions(trust) });
|
|
250
|
+
watch(channel);
|
|
251
|
+
}
|
|
252
|
+
const lines = [`CONNECT ${authority} HTTP/1.1`, `Host: ${authority}`];
|
|
253
|
+
if (proxy.username !== "") {
|
|
254
|
+
const credentials = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
255
|
+
lines.push(`Proxy-Authorization: Basic ${Buffer.from(credentials).toString("base64")}`);
|
|
256
|
+
}
|
|
257
|
+
channel.write(`${lines.join("\r\n")}\r\n\r\n`);
|
|
258
|
+
channel.on("data", onData);
|
|
259
|
+
}
|
|
260
|
+
function onData(chunk) {
|
|
261
|
+
head = Buffer.concat([head, chunk]);
|
|
262
|
+
const boundary = head.indexOf("\r\n\r\n");
|
|
263
|
+
if (boundary === -1) return;
|
|
264
|
+
channel.off("data", onData);
|
|
265
|
+
const status = Number(head.subarray(0, head.indexOf("\r\n")).toString("latin1").split(" ")[1]);
|
|
266
|
+
if (status !== 200) {
|
|
267
|
+
// A proxy that is briefly overloaded answers like any other
|
|
268
|
+
// transient HTTP failure, and the downloader's own retry rule
|
|
269
|
+
// decides whether the attempt is worth repeating.
|
|
270
|
+
const error = new Error(`Gentle AI download proxy refused the tunnel with status ${status}`);
|
|
271
|
+
error.code = TRANSIENT_PROXY_STATUSES.includes(status) ? "GENTLE_AI_DOWNLOAD_TRANSIENT_HTTP" : "GENTLE_AI_DOWNLOAD_HTTP";
|
|
272
|
+
fail(error);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
// Bytes the proxy sent past the header block belong to the origin
|
|
276
|
+
// stream and have to reach the TLS layer rather than be dropped.
|
|
277
|
+
const remainder = head.subarray(boundary + 4);
|
|
278
|
+
if (remainder.length > 0) channel.unshift(remainder);
|
|
279
|
+
deliver(undefined, tls.connect({
|
|
280
|
+
socket: channel,
|
|
281
|
+
// A request for an address leaves the server name empty, and an
|
|
282
|
+
// empty server name would make the certificate be checked
|
|
283
|
+
// against "localhost" instead of the origin.
|
|
284
|
+
...hostTlsOptions(options.servername || host),
|
|
285
|
+
ALPNProtocols: options.ALPNProtocols ?? ["http/1.1"],
|
|
286
|
+
// The origin handshake is the one that carries the client
|
|
287
|
+
// credentials, because they are the identity of the origin.
|
|
288
|
+
...proxyTrustOptions(options),
|
|
289
|
+
...trust,
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
return agent;
|
|
294
|
+
}
|
|
@@ -57,10 +57,23 @@ function describeGentleAiInstallFailure(error) {
|
|
|
57
57
|
if (process.env.GENTLE_PI_SKIP_GENTLE_AI_INSTALL === "1") {
|
|
58
58
|
console.warn("GENTLE_PI_SKIP_GENTLE_AI_INSTALL=1: skipped package-local Gentle AI installation; native review operations will fail with package-local-binary-missing until gentle-pi is reinstalled.");
|
|
59
59
|
} else {
|
|
60
|
+
// A live progress line only on a terminal: npm logs and CI output stay
|
|
61
|
+
// unchanged. Loaded lazily and optional, so it can never break the install.
|
|
62
|
+
let progress;
|
|
63
|
+
if (process.stderr.isTTY === true) {
|
|
64
|
+
try {
|
|
65
|
+
const { createDownloadProgress } = await import("./download-progress.mjs");
|
|
66
|
+
progress = createDownloadProgress({ label: `Downloading Gentle AI v${INSTALLER_VERSION}`, write: (text) => process.stderr.write(text), width: () => process.stderr.columns || 80 });
|
|
67
|
+
} catch {
|
|
68
|
+
progress = undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
60
71
|
try {
|
|
61
|
-
const result = await installGentleAi();
|
|
72
|
+
const result = await installGentleAi(progress === undefined ? {} : { onProgress: (state) => progress.update(state) });
|
|
73
|
+
progress?.done();
|
|
62
74
|
console.log(`Gentle AI v${INSTALLER_VERSION} ${result.installed ? "installed" : "integrity-verified"} at ${result.binaryPath}`);
|
|
63
75
|
} catch (error) {
|
|
76
|
+
progress?.done();
|
|
64
77
|
// The whole cause chain: the failing command's own output is the diagnosis.
|
|
65
78
|
console.error(`gentle-pi could not install its package-local Gentle AI v${INSTALLER_VERSION} binary: ${describeGentleAiInstallFailure(error)}`);
|
|
66
79
|
process.exitCode = 1;
|
|
@@ -22,8 +22,8 @@ export const requirements = Object.freeze({
|
|
|
22
22
|
go: GENTLE_AI_WINDOWS_MINIMUM_GO_VERSION,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
/** Pi
|
|
26
|
-
*
|
|
25
|
+
/** Legacy Pi pin retained for verified distribution and compatibility checks.
|
|
26
|
+
* Global installs resolve the latest stable Pi after consent instead.
|
|
27
27
|
*/
|
|
28
28
|
export const PI_INSTALL_VERSION = "1.5.0";
|
|
29
29
|
|
|
@@ -206,7 +206,7 @@ export function planPreflight(inventory, { channel = "release" } = {}) {
|
|
|
206
206
|
}
|
|
207
207
|
record("node", classify(inventory.node, requirements.node), requirements.node);
|
|
208
208
|
// An older Pi whose owner (pnpm or npm) is known is updated with that package
|
|
209
|
-
// manager to
|
|
209
|
+
// manager to the latest stable version instead of blocking; the plan records the
|
|
210
210
|
// found version and owner the update must still match. An older Pi neither
|
|
211
211
|
// owns (mise, Homebrew, a binary) is left as it is: the installer's Pi is
|
|
212
212
|
// installed alongside, exactly as when Pi is absent.
|
|
@@ -327,7 +327,7 @@ export function planPreflight(inventory, { channel = "release" } = {}) {
|
|
|
327
327
|
if (update || npmCurrent) {
|
|
328
328
|
// Only an update builds: main, or a Windows release postinstall.
|
|
329
329
|
if (update) acquireGo();
|
|
330
|
-
if (updatePi) action("update-pi", "upgrade", "pi",
|
|
330
|
+
if (updatePi) action("update-pi", "upgrade", "pi", "latest");
|
|
331
331
|
// A current npm Shell next to an older Pi neither manager owns gets the installer's Pi.
|
|
332
332
|
if (!update && tools.pi.status === "needs-install") action("install-pi", "install-global", "pi", requirements.pi);
|
|
333
333
|
if (update) {
|
|
@@ -369,7 +369,7 @@ export function planPreflight(inventory, { channel = "release" } = {}) {
|
|
|
369
369
|
else if (pnpm) action("persist-pnpm", "install-global", "pnpm", persistencePins.pnpm);
|
|
370
370
|
}
|
|
371
371
|
if (installPi) action("install-pi", "install-global", "pi", requirements.pi);
|
|
372
|
-
if (updatePi) action("update-pi", "upgrade", "pi",
|
|
372
|
+
if (updatePi) action("update-pi", "upgrade", "pi", "latest");
|
|
373
373
|
if (missingShell) action("install-shell", "install-global", "shell", requirements.shell);
|
|
374
374
|
// Global gentle-pi postinstall owns native provisioning when Shell is missing.
|
|
375
375
|
// Otherwise the later runner must reuse that existing installer, not duplicate it.
|
|
@@ -46,6 +46,7 @@ export const blockedReasons = Object.freeze([
|
|
|
46
46
|
/** Every `failedStep` a `failed` outcome can carry (for host guidance; no behavior). */
|
|
47
47
|
export const failedSteps = Object.freeze([
|
|
48
48
|
"prepare-pnpm-home",
|
|
49
|
+
"resolve-pi-version",
|
|
49
50
|
"persist-node",
|
|
50
51
|
"persist-package-managers",
|
|
51
52
|
"persist-npm",
|
|
@@ -101,7 +102,7 @@ const knownActions = Object.freeze({
|
|
|
101
102
|
"record-channel": { kind: "configure", target: "channel" },
|
|
102
103
|
"update-shell-release": { kind: "upgrade", target: "shell" },
|
|
103
104
|
"update-shell-main": { kind: "upgrade", target: "shell" },
|
|
104
|
-
"update-pi": { kind: "upgrade", target: "pi", version:
|
|
105
|
+
"update-pi": { kind: "upgrade", target: "pi", version: "latest" },
|
|
105
106
|
});
|
|
106
107
|
// The clean-stack path: both global packages are missing.
|
|
107
108
|
const requiredActions = ["install-pi", "install-shell", "setup-shell", "verify-readiness"];
|
|
@@ -601,7 +602,7 @@ function noExistingStack(stdout) {
|
|
|
601
602
|
* only Gentle Shell was added), and that runnable Pi (runnablePi) must exist;
|
|
602
603
|
* other projects (such as the persisted npm and pnpm) are ignored.
|
|
603
604
|
*/
|
|
604
|
-
async function verifiedPackageRoot(stdout, pnpmHome, platform, fs, shellVersion = requirements.shell, requirePi = true) {
|
|
605
|
+
async function verifiedPackageRoot(stdout, pnpmHome, platform, fs, shellVersion = requirements.shell, requirePi = true, expectedPi = PI_INSTALL_VERSION) {
|
|
605
606
|
const path = platform === "win32" ? win32 : posix;
|
|
606
607
|
const projects = JSON.parse(stdout);
|
|
607
608
|
if (!Array.isArray(projects)) return null;
|
|
@@ -610,7 +611,7 @@ async function verifiedPackageRoot(stdout, pnpmHome, platform, fs, shellVersion
|
|
|
610
611
|
if (!plainObject(dependencies)) return null;
|
|
611
612
|
const pi = dependencies[PI_PACKAGE];
|
|
612
613
|
const shell = dependencies[SHELL_PACKAGE];
|
|
613
|
-
if ((requirePi && pi?.version !==
|
|
614
|
+
if ((requirePi && (stable(expectedPi) === null || pi?.version !== expectedPi)) || shell?.version !== shellVersion) return null;
|
|
614
615
|
if (typeof shell.path !== "string" || !path.isAbsolute(shell.path)) return null;
|
|
615
616
|
const [root, home] = [await fs.realpath(shell.path), await fs.realpath(pnpmHome)];
|
|
616
617
|
if (!contains(home, root, platform)) return null;
|
|
@@ -906,6 +907,7 @@ export async function runStandardInstall(request, adapters) {
|
|
|
906
907
|
let runsPi = null;
|
|
907
908
|
let persistentNode = null;
|
|
908
909
|
let npmPrefix = null;
|
|
910
|
+
let piVersion = null;
|
|
909
911
|
// One add of only the missing managers (fixed versions only: never a blanket build approval).
|
|
910
912
|
const addOnly = ids.find((id) => ["persist-package-managers", "persist-npm", "persist-pnpm"].includes(id));
|
|
911
913
|
const addManagers = [addOnly, async () => succeeded(await runPnpm(["add", "-g", ...(addNpm ? [`npm@${persistencePins.npm}`] : []),
|
|
@@ -931,7 +933,7 @@ export async function runStandardInstall(request, adapters) {
|
|
|
931
933
|
// from the same owner at the target version, never a downgrade.
|
|
932
934
|
const piSteps = updatingPi ? [
|
|
933
935
|
["update-pi", async () => {
|
|
934
|
-
const spec = `${PI_PACKAGE}@${
|
|
936
|
+
const spec = `${PI_PACKAGE}@${piVersion}`;
|
|
935
937
|
const result = installedPi.owner === "npm"
|
|
936
938
|
? await adapters.run(npmCommand.command, [...npmCommand.prefix, "install", "-g", spec], { env, deadlineMs: deadlines.install })
|
|
937
939
|
: await runPnpm(["add", "-g", spec], deadlines.install);
|
|
@@ -940,7 +942,7 @@ export async function runStandardInstall(request, adapters) {
|
|
|
940
942
|
["verify-updated-pi", async () => {
|
|
941
943
|
const after = await adapters.locatePi();
|
|
942
944
|
if (!after || after.owner !== installedPi.owner || typeof after.root !== "string" || !path.isAbsolute(after.root)) return false;
|
|
943
|
-
if (
|
|
945
|
+
if (after.version !== piVersion) return false;
|
|
944
946
|
// npm replaces the package in place; pnpm 11 moves it to a new global directory.
|
|
945
947
|
return after.owner === "pnpm" || samePath(after.root, installedPi.root, platform);
|
|
946
948
|
}],
|
|
@@ -972,7 +974,7 @@ export async function runStandardInstall(request, adapters) {
|
|
|
972
974
|
] : [];
|
|
973
975
|
// Pi and gentle-pi stay separate pnpm groups, so `pi update` (which replaces Pi's
|
|
974
976
|
// own group) never removes gentle-pi; gentle-pi gets pnpm's peer Pi beside it.
|
|
975
|
-
const install = ["install-global", () => addGlobal([...(shellOnly ? [] : [`${PI_PACKAGE}@${
|
|
977
|
+
const install = ["install-global", () => addGlobal([...(shellOnly ? [] : [`${PI_PACKAGE}@${piVersion}`]),
|
|
976
978
|
`${SHELL_PACKAGE}@${requirements.shell}`, `--allow-build=${SHELL_PACKAGE}`], buildEnv())];
|
|
977
979
|
function mainSteps() {
|
|
978
980
|
const channel = adapters.mainChannel;
|
|
@@ -996,7 +998,7 @@ export async function runStandardInstall(request, adapters) {
|
|
|
996
998
|
const result = await list();
|
|
997
999
|
if (!succeeded(result)) return false;
|
|
998
1000
|
const verified = await verifiedPackageRoot(String(result.stdout ?? ""), globalBin.pnpmHome, platform, adapters.fs,
|
|
999
|
-
mainVersion(requirements.shell, shellCommit), !shellOnly);
|
|
1001
|
+
mainVersion(requirements.shell, shellCommit), !shellOnly, piVersion);
|
|
1000
1002
|
if (verified === null) return false;
|
|
1001
1003
|
({ root: packageRoot, pi: runsPi } = verified);
|
|
1002
1004
|
return true;
|
|
@@ -1016,7 +1018,8 @@ export async function runStandardInstall(request, adapters) {
|
|
|
1016
1018
|
["verify-global-list", async () => {
|
|
1017
1019
|
const result = await list();
|
|
1018
1020
|
if (!succeeded(result)) return false;
|
|
1019
|
-
const verified = await verifiedPackageRoot(String(result.stdout ?? ""), globalBin.pnpmHome, platform, adapters.fs, requirements.shell, !shellOnly
|
|
1021
|
+
const verified = await verifiedPackageRoot(String(result.stdout ?? ""), globalBin.pnpmHome, platform, adapters.fs, requirements.shell, !shellOnly,
|
|
1022
|
+
recovering ? PI_INSTALL_VERSION : piVersion);
|
|
1020
1023
|
if (verified === null) return false;
|
|
1021
1024
|
({ root: packageRoot, pi: runsPi } = verified);
|
|
1022
1025
|
return true;
|
|
@@ -1043,7 +1046,7 @@ export async function runStandardInstall(request, adapters) {
|
|
|
1043
1046
|
const setupStep = steps.find(([name]) => name === "shell-setup");
|
|
1044
1047
|
steps.splice(0, steps.length,
|
|
1045
1048
|
...goSteps,
|
|
1046
|
-
...(ids.includes("install-pi") ? [["install-pi", async () => succeeded(await runPnpm(["add", "-g", `${PI_PACKAGE}@${
|
|
1049
|
+
...(ids.includes("install-pi") ? [["install-pi", async () => succeeded(await runPnpm(["add", "-g", `${PI_PACKAGE}@${piVersion}`], deadlines.install))]] : []),
|
|
1047
1050
|
...piSteps,
|
|
1048
1051
|
["update-shell", withMainDetail(async () => (await adapters.upgradeShell({ channel, packageRoot: installed.root, currentVersion: installed.version,
|
|
1049
1052
|
...(pinnedGo ? { goPath: pinnedGo } : {}) })) === true)],
|
|
@@ -1069,14 +1072,26 @@ export async function runStandardInstall(request, adapters) {
|
|
|
1069
1072
|
if (piOnly) {
|
|
1070
1073
|
// The installer's Pi alone: the same `add -g` as install-pi, then found in pnpm's list.
|
|
1071
1074
|
steps.splice(0, steps.length, ...(updatingPi ? piSteps : [
|
|
1072
|
-
["install-pi", async () => succeeded(await runPnpm(["add", "-g", `${PI_PACKAGE}@${
|
|
1075
|
+
["install-pi", async () => succeeded(await runPnpm(["add", "-g", `${PI_PACKAGE}@${piVersion}`], deadlines.install))],
|
|
1073
1076
|
["verify-installed-pi", async () => {
|
|
1074
1077
|
const after = await adapters.locatePi();
|
|
1075
1078
|
return after?.owner === "pnpm" && typeof after.root === "string" && path.isAbsolute(after.root) &&
|
|
1076
|
-
|
|
1079
|
+
after.version === piVersion;
|
|
1077
1080
|
}],
|
|
1078
1081
|
]));
|
|
1079
1082
|
}
|
|
1083
|
+
if (ids.includes("install-pi") || updatingPi) {
|
|
1084
|
+
// Resolve before any package/runtime installation; never trust registry output
|
|
1085
|
+
// as an argument until it is an exact stable version meeting the minimum.
|
|
1086
|
+
steps.unshift(["resolve-pi-version", async () => {
|
|
1087
|
+
const result = await runPnpm(["view", `${PI_PACKAGE}@latest`, "version"], deadlines.probe);
|
|
1088
|
+
const version = String(result.stdout ?? "").trim();
|
|
1089
|
+
if (!succeeded(result) || result.truncated === true || !atLeast(version, requirements.pi) ||
|
|
1090
|
+
(installedPi && !atLeast(version, installedPi.version))) return false;
|
|
1091
|
+
piVersion = version;
|
|
1092
|
+
return true;
|
|
1093
|
+
}]);
|
|
1094
|
+
}
|
|
1080
1095
|
const persistPath = !globalBin.onPath && (privateHome || (!update && !piOnly));
|
|
1081
1096
|
if (persistPath) {
|
|
1082
1097
|
steps.push(["persist-path", async () => {
|
|
@@ -1096,7 +1111,7 @@ export async function runStandardInstall(request, adapters) {
|
|
|
1096
1111
|
log({ step, status: "done" });
|
|
1097
1112
|
}
|
|
1098
1113
|
// Reported only when Gentle Shell runs a Pi other than the installer's.
|
|
1099
|
-
const prefix = { ...(persistRuntime ? { npmPrefix } : {}), ...(runsPi !== null && runsPi !== PI_INSTALL_VERSION ? { piVersion: runsPi } : {}) };
|
|
1114
|
+
const prefix = { ...(persistRuntime ? { npmPrefix } : {}), ...(runsPi !== null && runsPi !== (piVersion ?? request.plan.tools.pi.version ?? PI_INSTALL_VERSION) ? { piVersion: runsPi } : {}) };
|
|
1100
1115
|
if (persistPath) return { outcome: "terminal-action-required", action: "open-new-terminal", completed, ...prefix };
|
|
1101
1116
|
return { outcome: "ready", completed, ...prefix };
|
|
1102
1117
|
}
|
|
@@ -2,7 +2,7 @@ import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { goAcquisition, requirements } from "./installer-preflight.mjs";
|
|
6
6
|
|
|
7
7
|
// Local wizard host: a dependency-free loopback HTTP server with a fixed route
|
|
8
8
|
// allowlist. The browser never sends commands, paths, plans or environment:
|
|
@@ -71,8 +71,8 @@ export const actionDescriptions = Object.freeze({
|
|
|
71
71
|
"persist-pnpm": "Install pnpm under PNPM_HOME with `pnpm add -g`.",
|
|
72
72
|
"acquire-go": "Download the installer's pinned Go from go.dev and verify it, only to build Gentle AI.",
|
|
73
73
|
"verify-go": "Check that the downloaded Go runs and reports the pinned version.",
|
|
74
|
-
"install-pi": "
|
|
75
|
-
"install-shell": `Install Gentle Shell (gentle-pi) globally with pnpm. pnpm may put
|
|
74
|
+
"install-pi": "Resolve the latest stable Pi and install that exact version globally with pnpm.",
|
|
75
|
+
"install-shell": `Install Gentle Shell (gentle-pi) globally with pnpm. pnpm may put another Pi next to it ` +
|
|
76
76
|
`(at least Pi ${requirements.pi}), and Gentle Shell runs that Pi.`,
|
|
77
77
|
"provision-native": "Provision the package-native Gentle AI binary with the existing installer.",
|
|
78
78
|
"setup-shell": "Run the normal `gentle-shell setup`.",
|
|
@@ -135,6 +135,7 @@ export const guidance = Object.freeze({
|
|
|
135
135
|
"build-gentle-ai-main": `Gentle AI could not be built from its latest \`main\` commit. Check your network connection and that \`go\` runs in a terminal. ${tryAgain}`,
|
|
136
136
|
"install-shell-main": `Gentle Shell could not be installed from its latest \`main\` commit. Check your network connection. ${tryAgain}`,
|
|
137
137
|
"record-channel": "Gentle Shell is installed from `main`, but the channel could not be saved under `~/.pi/gentle-ai`. Check that folder's permissions, then run the installer again.",
|
|
138
|
+
"resolve-pi-version": `The latest stable Pi could not be resolved or did not meet the minimum. No packages were installed. Check your network connection. ${tryAgain}`,
|
|
138
139
|
"install-pi": `Installing Pi with pnpm failed. Your existing Gentle Shell was not changed. Check your network connection. ${tryAgain}`,
|
|
139
140
|
"update-shell": "Updating Gentle Shell failed. Run `gentle-shell upgrade` in a terminal to see the details.",
|
|
140
141
|
"verify-updated-shell": "Gentle Shell did not report the expected version after the update. Run `gentle-shell --version`, then `gentle-shell upgrade` in a terminal.",
|
|
@@ -351,12 +352,12 @@ function actionDescription(action, plan) {
|
|
|
351
352
|
const pi = plan.tools?.pi;
|
|
352
353
|
const stable = (...versions) => versions.every((version) => typeof version === "string" && STABLE.test(version));
|
|
353
354
|
const bare = (version) => version.replace(/^v/, "");
|
|
354
|
-
if (action.id === "update-pi" && ["pnpm", "npm"].includes(pi?.owner) && stable(pi.version, pi.required
|
|
355
|
-
return `Update Pi ${bare(pi.version)} to
|
|
355
|
+
if (action.id === "update-pi" && action.version === "latest" && ["pnpm", "npm"].includes(pi?.owner) && stable(pi.version, pi.required)) {
|
|
356
|
+
return `Update Pi ${bare(pi.version)} to the latest stable version with ${pi.owner}, the package manager that installed it. ` +
|
|
356
357
|
`Gentle Shell needs Pi ${bare(pi.required)} or newer.`;
|
|
357
358
|
}
|
|
358
359
|
if (action.id === "install-pi" && pi?.status === "needs-install" && stable(pi.version)) {
|
|
359
|
-
return `Install Pi
|
|
360
|
+
return `Install the latest stable Pi globally with pnpm for Gentle Shell. The Pi ${bare(pi.version)} already on this computer ` +
|
|
360
361
|
"was not installed with pnpm or npm, so it is left unchanged. Gentle Shell uses the installer's Pi; the `pi` command in a terminal may still run the older one.";
|
|
361
362
|
}
|
|
362
363
|
// The pinned Go: its version, the Go found (older, unchecked or missing), and what stays unchanged.
|
|
@@ -558,7 +559,7 @@ function outcomeView(result) {
|
|
|
558
559
|
} else {
|
|
559
560
|
view.guidance = guidance.outcomes[result.outcome];
|
|
560
561
|
// The Pi Gentle Shell runs, when pnpm put one other than the installer's next to it.
|
|
561
|
-
if (typeof result.piVersion === "string" && STABLE.test(result.piVersion)
|
|
562
|
+
if (typeof result.piVersion === "string" && STABLE.test(result.piVersion)) {
|
|
562
563
|
view.guidance += ` Gentle Shell runs Pi ${result.piVersion.replace(/^v/, "")}, which pnpm installed next to it.`;
|
|
563
564
|
}
|
|
564
565
|
if (result.action === "open-new-terminal") view.action = "open-new-terminal";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Shared --pi-root contract. The comparison driver and the measurement worker
|
|
2
|
+
// must refuse a bad root with the same curated message, and both must do it
|
|
3
|
+
// before reading, hashing or importing anything from the host.
|
|
4
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
|
|
7
|
+
export const SUPPORTED_PI_VERSION = "1.2.0";
|
|
8
|
+
export const PI_ROOT_LAYOUT = "dist/ plus node_modules/@earendil-works/{pi-tui,pi-ai,pi-agent-core} and node_modules/jiti";
|
|
9
|
+
export const HOST_PACKAGE = "@earendil-works/pi-coding-agent";
|
|
10
|
+
export const TUI_PACKAGE = "@earendil-works/pi-tui";
|
|
11
|
+
export const HOST_ENTRY = "core/extensions/jiti-loader.js";
|
|
12
|
+
export const HOST_DEPENDENCIES = [
|
|
13
|
+
"node_modules/@earendil-works/pi-tui",
|
|
14
|
+
"node_modules/@earendil-works/pi-ai",
|
|
15
|
+
"node_modules/@earendil-works/pi-agent-core",
|
|
16
|
+
"node_modules/jiti",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function layoutError(piRoot, detail) {
|
|
20
|
+
return new Error(`--pi-root ${piRoot} is not a Pi install root: ${detail} It must carry ${PI_ROOT_LAYOUT}.`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function hostPackage(piRoot, relative, expectedName) {
|
|
24
|
+
const path = resolve(piRoot, relative);
|
|
25
|
+
let manifest;
|
|
26
|
+
try {
|
|
27
|
+
manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
28
|
+
} catch {
|
|
29
|
+
throw layoutError(piRoot, `${path} is unreadable.`);
|
|
30
|
+
}
|
|
31
|
+
if (manifest === null || typeof manifest !== "object" || typeof manifest.name !== "string" || typeof manifest.version !== "string") {
|
|
32
|
+
throw layoutError(piRoot, `${path} declares no package name and version.`);
|
|
33
|
+
}
|
|
34
|
+
if (manifest.name !== expectedName) {
|
|
35
|
+
throw layoutError(piRoot, `${path} is ${manifest.name}@${manifest.version}, expected ${expectedName}.`);
|
|
36
|
+
}
|
|
37
|
+
return { name: manifest.name, version: manifest.version };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function directoryAt(path) {
|
|
41
|
+
try {
|
|
42
|
+
return statSync(path).isDirectory();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error?.code === "ENOENT" || error?.code === "ENOTDIR") return false;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function requireHostLayout(piRoot) {
|
|
50
|
+
const dist = resolve(piRoot, "dist");
|
|
51
|
+
if (!directoryAt(dist)) throw layoutError(piRoot, `${dist} is not a directory.`);
|
|
52
|
+
const entry = resolve(dist, HOST_ENTRY);
|
|
53
|
+
if (!existsSync(entry)) throw layoutError(piRoot, `${entry} is missing.`);
|
|
54
|
+
for (const relative of HOST_DEPENDENCIES) {
|
|
55
|
+
const path = resolve(piRoot, relative);
|
|
56
|
+
if (!directoryAt(path)) throw layoutError(piRoot, `${path} is missing or not a directory.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Validates the install root and returns the two audited manifests. */
|
|
61
|
+
export function validatePiRoot(piRoot) {
|
|
62
|
+
const host = hostPackage(piRoot, "package.json", HOST_PACKAGE);
|
|
63
|
+
const hostTui = hostPackage(piRoot, "node_modules/@earendil-works/pi-tui/package.json", TUI_PACKAGE);
|
|
64
|
+
if (host.version !== SUPPORTED_PI_VERSION) {
|
|
65
|
+
throw new Error(`--pi-root ${piRoot} is ${host.name}@${host.version}, but the private frame API is audited only on ${SUPPORTED_PI_VERSION}. Point --pi-root at a Pi ${SUPPORTED_PI_VERSION} install (${PI_ROOT_LAYOUT}).`);
|
|
66
|
+
}
|
|
67
|
+
if (hostTui.version !== host.version) {
|
|
68
|
+
throw new Error(`--pi-root ${piRoot} mixes ${host.name}@${host.version} with ${hostTui.name}@${hostTui.version}; a mixed host cannot be measured. Point --pi-root at a Pi ${SUPPORTED_PI_VERSION} install (${PI_ROOT_LAYOUT}).`);
|
|
69
|
+
}
|
|
70
|
+
requireHostLayout(piRoot);
|
|
71
|
+
return { host, hostTui };
|
|
72
|
+
}
|
|
@@ -4,12 +4,12 @@ import { readFileSync } from "node:fs";
|
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { performance } from "node:perf_hooks";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { validatePiRoot } from "./render-cache-host.mjs";
|
|
7
8
|
|
|
8
9
|
const config = JSON.parse(process.argv[2]);
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
assert.equal(tuiVersion, piVersion, "host TUI package must match");
|
|
10
|
+
const { host, hostTui } = validatePiRoot(config.piRoot);
|
|
11
|
+
const piVersion = host.version;
|
|
12
|
+
const tuiVersion = hostTui.version;
|
|
13
13
|
const hostImport = (path) => import(pathToFileURL(resolve(config.piRoot, "dist", path)).href);
|
|
14
14
|
const { createJiti } = await hostImport("core/extensions/jiti-loader.js");
|
|
15
15
|
const { VIRTUAL_MODULES } = await hostImport("core/extensions/virtual-modules.js");
|
|
@@ -54,6 +54,7 @@ function fixture(spec, live = false) {
|
|
|
54
54
|
manager.getEntries = () => { counts.entries++; return getEntries(); };
|
|
55
55
|
const model = { id: "synthetic-model", provider: "synthetic", reasoning: true, contextWindow: 200000 };
|
|
56
56
|
const ctx = { model, sessionManager: manager, modelRegistry: { isUsingOAuth: () => false },
|
|
57
|
+
ui: { theme: { name: "performance" }, getAllThemes: () => [] },
|
|
57
58
|
getContextUsage() { counts.projections++; return pi.AgentSession.prototype.getContextUsage.call({ sessionManager: manager, _limitsModel: () => model }); } };
|
|
58
59
|
const api = { getThinkingLevel: () => "high" };
|
|
59
60
|
const footerData = { getGitBranch: () => "performance", getExtensionStatuses: () => new Map(), onBranchChange: () => () => {} };
|