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,175 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Builds assets/orchestrator-full-delegation-card.md, the lazy card a full
|
|
3
|
+
// delegation session reads instead of the organic delegation and writer cards.
|
|
4
|
+
//
|
|
5
|
+
// Full delegation mode must never put an organic routing rule ("small work stays
|
|
6
|
+
// inline", "a large task alone never delegates") in front of the orchestrator,
|
|
7
|
+
// but it still needs the rules both modes share: handoff language, launch
|
|
8
|
+
// checks, allowed edit surfaces, background policy, the closing block. Those rules
|
|
9
|
+
// keep exactly one source, the organic assets that contract tests already pin;
|
|
10
|
+
// this script projects the shared sections out of them, so the card can never
|
|
11
|
+
// drift into a second, diverging copy.
|
|
12
|
+
//
|
|
13
|
+
// Every selection and every pointer rewrite throws when its anchor is missing:
|
|
14
|
+
// a source edit that moves an anchor must fail the drift check loudly, never
|
|
15
|
+
// produce a silently incomplete card.
|
|
16
|
+
//
|
|
17
|
+
// Usage: node scripts/build-full-delegation-card.mjs --write | --check
|
|
18
|
+
|
|
19
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
export const FULL_DELEGATION_CARD = "orchestrator-full-delegation-card.md";
|
|
24
|
+
|
|
25
|
+
const HEADING = /^#{1,6} /;
|
|
26
|
+
|
|
27
|
+
function requireIncludes(text, anchor, source) {
|
|
28
|
+
if (!text.includes(anchor)) throw new Error(`${source}: anchor not found: ${JSON.stringify(anchor)}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The lines of one section, from its heading to the next heading of any level, trimmed of blank edges. */
|
|
32
|
+
function section(text, heading, source) {
|
|
33
|
+
const lines = text.split("\n");
|
|
34
|
+
const start = lines.indexOf(heading);
|
|
35
|
+
if (start === -1) throw new Error(`${source}: heading not found: ${JSON.stringify(heading)}`);
|
|
36
|
+
const body = [];
|
|
37
|
+
for (const line of lines.slice(start + 1)) {
|
|
38
|
+
if (HEADING.test(line)) break;
|
|
39
|
+
body.push(line);
|
|
40
|
+
}
|
|
41
|
+
while (body.length > 0 && body[0] === "") body.shift();
|
|
42
|
+
while (body.length > 0 && body.at(-1) === "") body.pop();
|
|
43
|
+
return body.join("\n");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The first heading after the given heading's section starts. */
|
|
47
|
+
function headingAfter(text, heading, source) {
|
|
48
|
+
const lines = text.split("\n");
|
|
49
|
+
const start = lines.indexOf(heading);
|
|
50
|
+
if (start === -1) throw new Error(`${source}: heading not found: ${JSON.stringify(heading)}`);
|
|
51
|
+
const next = lines.slice(start + 1).find((line) => HEADING.test(line));
|
|
52
|
+
if (next === undefined) throw new Error(`${source}: no heading follows ${JSON.stringify(heading)}`);
|
|
53
|
+
return next;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One paragraph line, selected by its exact leading text. */
|
|
57
|
+
function paragraph(text, prefix, source) {
|
|
58
|
+
const line = text.split("\n").find((candidate) => candidate.startsWith(prefix));
|
|
59
|
+
if (line === undefined) throw new Error(`${source}: paragraph not found: ${JSON.stringify(prefix)}`);
|
|
60
|
+
return line;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The marked block, markers included, so its own consumers keep recognizing it. */
|
|
64
|
+
function marked(text, name, source) {
|
|
65
|
+
const open = `<!-- ${name} -->`;
|
|
66
|
+
const close = `<!-- /${name} -->`;
|
|
67
|
+
const start = text.indexOf(open);
|
|
68
|
+
const end = text.indexOf(close);
|
|
69
|
+
if (start === -1 || end <= start) throw new Error(`${source}: marked block not found: ${name}`);
|
|
70
|
+
return text.slice(start, end + close.length);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Apply exact rewrites, each of which must find its anchor. */
|
|
74
|
+
function rewrite(text, replacements, source) {
|
|
75
|
+
let result = text;
|
|
76
|
+
for (const [from, to] of replacements) {
|
|
77
|
+
requireIncludes(result, from, source);
|
|
78
|
+
result = result.replace(from, to);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function renderFullDelegationCard(assetsDir) {
|
|
84
|
+
const delegationSource = "orchestrator-delegation.md";
|
|
85
|
+
const writerSource = "orchestrator-writer.md";
|
|
86
|
+
const referenceSource = "orchestrator-delegation-reference.md";
|
|
87
|
+
const delegation = readFileSync(join(assetsDir, delegationSource), "utf8");
|
|
88
|
+
const writer = readFileSync(join(assetsDir, writerSource), "utf8");
|
|
89
|
+
const reference = readFileSync(join(assetsDir, referenceSource), "utf8");
|
|
90
|
+
|
|
91
|
+
// The card is self-contained: pointers back to the organic cards would send a
|
|
92
|
+
// full delegation session straight into the rules this card exists to keep out.
|
|
93
|
+
const handoff = rewrite(section(delegation, "## Handoff", delegationSource), [
|
|
94
|
+
[" (language domain detail: reference)", ""],
|
|
95
|
+
["via `orchestrator_session_id` (reference).", "via `orchestrator_session_id`."],
|
|
96
|
+
], delegationSource);
|
|
97
|
+
const invariants = rewrite(paragraph(delegation, "**Invariants:**", delegationSource), [
|
|
98
|
+
["whoever writes, inline or delegated, reuses", "the writer reuses"],
|
|
99
|
+
[" (`orchestrator-writer.md`)", ""],
|
|
100
|
+
], delegationSource);
|
|
101
|
+
const differential = paragraph(delegation, "**Differential check (PRESERVE):**", delegationSource);
|
|
102
|
+
const launch = rewrite(section(delegation, "## Launch", delegationSource), [
|
|
103
|
+
[" before launching a writer (`orchestrator-writer.md`).", " before launching a writer (below)."],
|
|
104
|
+
["Otherwise run in the foreground. Detail: reference.", "Otherwise run in the foreground. Detail: below."],
|
|
105
|
+
["report the capability gap; a fired trigger is never replaced by inline work.", "report the capability gap; never do the work yourself instead."],
|
|
106
|
+
], delegationSource);
|
|
107
|
+
const surfaces = section(writer, "#### Allowed edit surfaces (MANDATORY)", writerSource);
|
|
108
|
+
const background = marked(reference, "gentle-pi:background-subagents", referenceSource);
|
|
109
|
+
// The closing-block section is selected by position, as the heading that follows
|
|
110
|
+
// the launch section, and its heading text is copied from the source. Pi runtime
|
|
111
|
+
// code must never carry the block's name (tests/delegated-key-learnings-contract
|
|
112
|
+
// .test.ts): this script copies documentation, it never reads model output.
|
|
113
|
+
const closingHeading = headingAfter(delegation, "## Launch", delegationSource);
|
|
114
|
+
const closing = section(delegation, closingHeading, delegationSource);
|
|
115
|
+
|
|
116
|
+
return [
|
|
117
|
+
"# Orchestrator — Full Delegation Card (lazy-loaded)",
|
|
118
|
+
"",
|
|
119
|
+
// The comment names the script, never the organic source cards: anything this
|
|
120
|
+
// card names is something a full delegation session may go and read.
|
|
121
|
+
"<!-- Generated by scripts/build-full-delegation-card.mjs. Do not edit; run it with --write. -->",
|
|
122
|
+
"",
|
|
123
|
+
"Parent Pi session only, in full delegation mode: every authorized change goes to a bounded writer. These are the handoff, launch, edit-surface and background rules both workflow modes share.",
|
|
124
|
+
"",
|
|
125
|
+
"## Handoff",
|
|
126
|
+
"",
|
|
127
|
+
handoff,
|
|
128
|
+
"",
|
|
129
|
+
invariants,
|
|
130
|
+
"",
|
|
131
|
+
differential,
|
|
132
|
+
"",
|
|
133
|
+
"## Launch",
|
|
134
|
+
"",
|
|
135
|
+
launch,
|
|
136
|
+
"",
|
|
137
|
+
"#### Allowed edit surfaces (MANDATORY)",
|
|
138
|
+
"",
|
|
139
|
+
surfaces,
|
|
140
|
+
"",
|
|
141
|
+
background,
|
|
142
|
+
"",
|
|
143
|
+
closingHeading,
|
|
144
|
+
"",
|
|
145
|
+
closing,
|
|
146
|
+
"",
|
|
147
|
+
].join("\n");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const isMain = process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1];
|
|
151
|
+
if (isMain) {
|
|
152
|
+
const assetsDir = join(dirname(fileURLToPath(import.meta.url)), "..", "assets");
|
|
153
|
+
const target = join(assetsDir, FULL_DELEGATION_CARD);
|
|
154
|
+
const rendered = renderFullDelegationCard(assetsDir);
|
|
155
|
+
const mode = process.argv[2];
|
|
156
|
+
if (mode === "--write") {
|
|
157
|
+
writeFileSync(target, rendered);
|
|
158
|
+
process.stdout.write(`wrote assets/${FULL_DELEGATION_CARD}\n`);
|
|
159
|
+
} else if (mode === "--check") {
|
|
160
|
+
let current = "";
|
|
161
|
+
try {
|
|
162
|
+
current = readFileSync(target, "utf8");
|
|
163
|
+
} catch {
|
|
164
|
+
current = "";
|
|
165
|
+
}
|
|
166
|
+
if (current !== rendered) {
|
|
167
|
+
process.stderr.write(`assets/${FULL_DELEGATION_CARD} is out of date with its sources; run node scripts/build-full-delegation-card.mjs --write\n`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
process.stdout.write(`assets/${FULL_DELEGATION_CARD} is up to date\n`);
|
|
171
|
+
} else {
|
|
172
|
+
process.stderr.write("usage: node scripts/build-full-delegation-card.mjs --write | --check\n");
|
|
173
|
+
process.exit(2);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -1002,9 +1002,9 @@ function activateWithLauncher(layout, id, active, { module, next }) {
|
|
|
1002
1002
|
* print exactly the release's gentle-pi and Pi before `current` switches; the
|
|
1003
1003
|
* release's launcher is then written (a failure puts `current` back) and two
|
|
1004
1004
|
* versions are kept (a pruning failure is only a warning). An already current
|
|
1005
|
-
* release changes nothing
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1005
|
+
* release changes nothing. A newer active Pi is kept across Shell releases,
|
|
1006
|
+
* without applying a different Pi's verified lockfile; any failure leaves
|
|
1007
|
+
* `current` as it was and removes a version this
|
|
1008
1008
|
* call installed. Returns { id, changed, previous?, removed?, warning? }.
|
|
1009
1009
|
*/
|
|
1010
1010
|
export async function upgradeBundled({ layout, home, platform = layout.platform, arch = process.arch, env = {}, adapters, out = () => {} }) {
|
|
@@ -1018,10 +1018,26 @@ export async function upgradeBundled({ layout, home, platform = layout.platform,
|
|
|
1018
1018
|
out(`Gentle Shell ${shell} with Pi ${pi} is already current.`);
|
|
1019
1019
|
return { id, changed: false };
|
|
1020
1020
|
}
|
|
1021
|
-
|
|
1021
|
+
let activePi = null;
|
|
1022
|
+
if (active) {
|
|
1023
|
+
try {
|
|
1024
|
+
if (!installedVersion(layout, active)) throw new Error("not installed");
|
|
1025
|
+
const dependencies = JSON.parse(read(pathFor(process.platform).join(versionDirectory(layout, active), "package.json"))).dependencies;
|
|
1026
|
+
const current = versionsOf({ shell: dependencies?.["gentle-pi"], pi: dependencies?.[PI_PACKAGE] });
|
|
1027
|
+
if (current.id !== active) throw new Error("version mismatch");
|
|
1028
|
+
activePi = current.pi;
|
|
1029
|
+
} catch {
|
|
1030
|
+
throw new Error(`the active version ${active} could not be verified; current stays as it is`);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1022
1033
|
if (activePi && newerVersion(activePi, pi)) {
|
|
1023
|
-
|
|
1024
|
-
|
|
1034
|
+
if (piOfVersion(active, shell)) {
|
|
1035
|
+
out(`Gentle Shell ${shell} is current; Pi ${activePi} is newer than this release's verified Pi ${pi}.`);
|
|
1036
|
+
return { id: active, changed: false };
|
|
1037
|
+
}
|
|
1038
|
+
out(`warning: keeping Pi ${activePi}, newer than this release's verified Pi ${pi}; installing without the release's verified lockfile. Gentle Shell features that rely on audited Pi internals may turn off.`);
|
|
1039
|
+
return installAndActivate({ layout, home, platform, arch, env, adapters, out, manifest: { ...manifest, pi: activePi }, unverified: true, active,
|
|
1040
|
+
success: `Upgraded to Gentle Shell ${shell} with Pi ${activePi} (from ${active}). Run 'gentle-shell upgrade --rollback' to switch back.` });
|
|
1025
1041
|
}
|
|
1026
1042
|
return installAndActivate({ layout, home, platform, arch, env, adapters, out, manifest, lockfile, active,
|
|
1027
1043
|
success: `Upgraded to Gentle Shell ${shell} with Pi ${pi} (from ${active ?? "no active version"}). Run 'gentle-shell upgrade --rollback' to switch back.` });
|
|
@@ -1032,11 +1048,25 @@ function piOfVersion(id, shell) {
|
|
|
1032
1048
|
const pi = typeof id === "string" && id.startsWith(`${shell}-`) ? id.slice(shell.length + 1) : "";
|
|
1033
1049
|
return SEMVER.test(pi) ? pi : null;
|
|
1034
1050
|
}
|
|
1035
|
-
/**
|
|
1051
|
+
/** Semver precedence, including prereleases; callers already validated both versions. */
|
|
1036
1052
|
function newerVersion(a, b) {
|
|
1037
1053
|
const [left, right] = [a, b].map((version) => SEMVER.exec(version).slice(1, 4).map(Number));
|
|
1038
1054
|
const index = left.findIndex((part, at) => part !== right[at]);
|
|
1039
|
-
|
|
1055
|
+
if (index !== -1) return left[index] > right[index];
|
|
1056
|
+
const [preA, preB] = [a, b].map((version) => version.split("-").slice(1).join("-"));
|
|
1057
|
+
if (!preA || !preB) return !preA && Boolean(preB);
|
|
1058
|
+
const [partsA, partsB] = [preA.split("."), preB.split(".")];
|
|
1059
|
+
for (let i = 0; i < Math.max(partsA.length, partsB.length); i += 1) {
|
|
1060
|
+
if (partsA[i] === undefined) return false;
|
|
1061
|
+
if (partsB[i] === undefined) return true;
|
|
1062
|
+
if (partsA[i] === partsB[i]) continue;
|
|
1063
|
+
const numericA = /^\d+$/.test(partsA[i]);
|
|
1064
|
+
const numericB = /^\d+$/.test(partsB[i]);
|
|
1065
|
+
if (numericA && numericB) return BigInt(partsA[i]) > BigInt(partsB[i]);
|
|
1066
|
+
if (numericA !== numericB) return !numericA;
|
|
1067
|
+
return partsA[i] > partsB[i];
|
|
1068
|
+
}
|
|
1069
|
+
return false;
|
|
1040
1070
|
}
|
|
1041
1071
|
|
|
1042
1072
|
/** Installs `manifest` beside the active version (with the release lockfile,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// One-line terminal progress for the package-local Gentle AI download. Pure
|
|
2
|
+
// formatting plus a throttled reporter over an injected writer; the caller
|
|
3
|
+
// decides whether a terminal is attached (install-gentle-ai.mjs).
|
|
4
|
+
|
|
5
|
+
const KB = 1024;
|
|
6
|
+
const MB = 1024 * 1024;
|
|
7
|
+
|
|
8
|
+
function size(bytes) {
|
|
9
|
+
return bytes >= MB ? `${(bytes / MB).toFixed(1)} MB` : `${Math.round(bytes / KB)} KB`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function truncate(text, width) {
|
|
13
|
+
const chars = [...text];
|
|
14
|
+
return chars.length <= width ? text : chars.slice(0, Math.max(0, width)).join("");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function formatDownloadProgress({ label, received, total, elapsedMs, width }) {
|
|
18
|
+
const rate = elapsedMs > 0 ? (received * 1000) / elapsedMs : 0;
|
|
19
|
+
const known = typeof total === "number" && total > 0;
|
|
20
|
+
const amount = known
|
|
21
|
+
? total >= MB
|
|
22
|
+
? `${(received / MB).toFixed(1)}/${(total / MB).toFixed(1)} MB`
|
|
23
|
+
: `${Math.round(received / KB)}/${Math.round(total / KB)} KB`
|
|
24
|
+
: size(received);
|
|
25
|
+
const parts = [amount];
|
|
26
|
+
if (known) parts.push(`${String(Math.min(100, Math.floor((received / total) * 100))).padStart(3)}%`);
|
|
27
|
+
// The rate is the first thing to go when even the bare numbers do not fit.
|
|
28
|
+
if (rate > 0 && [...parts.join(" ")].length + [...size(rate)].length + 3 <= width) parts.push(`${size(rate)}/s`);
|
|
29
|
+
const metrics = parts.join(" ");
|
|
30
|
+
// The moving numbers win over the label on a narrow terminal: the label is
|
|
31
|
+
// shortened, then dropped, before the amount and percent are ever cut.
|
|
32
|
+
const room = width - [...metrics].length - 1;
|
|
33
|
+
if (room < [...label].length) return room >= 1 ? `${truncate(label, room)} ${metrics}` : truncate(metrics, width);
|
|
34
|
+
const text = `${label} ${metrics}`;
|
|
35
|
+
if (!known) return text;
|
|
36
|
+
const barWidth = Math.min(30, width - [...text].length - 3);
|
|
37
|
+
if (barWidth < 5) return truncate(text, width);
|
|
38
|
+
const filled = Math.min(barWidth, Math.round((received / total) * barWidth));
|
|
39
|
+
return `${text} [${"#".repeat(filled)}${"-".repeat(barWidth - filled)}]`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Redraws at most every `intervalMs`, except the completed state, which is
|
|
43
|
+
// always drawn. `done` clears the line once, and only if something was drawn.
|
|
44
|
+
export function createDownloadProgress({ label, write: rawWrite, now = Date.now, width = () => 80, intervalMs = 100 }) {
|
|
45
|
+
// Display only: a failing terminal write (closed pipe, detached tty) must
|
|
46
|
+
// never change the install result, including during cleanup in `done`.
|
|
47
|
+
const write = (text) => { try { rawWrite(text); } catch { /* display only */ } };
|
|
48
|
+
const started = now();
|
|
49
|
+
let lastDraw;
|
|
50
|
+
let drawn = false;
|
|
51
|
+
let finished = false;
|
|
52
|
+
return {
|
|
53
|
+
update({ received, total }) {
|
|
54
|
+
if (finished) return;
|
|
55
|
+
const at = now();
|
|
56
|
+
const complete = typeof total === "number" && total > 0 && received >= total;
|
|
57
|
+
if (lastDraw !== undefined && at - lastDraw < intervalMs && !complete) return;
|
|
58
|
+
lastDraw = at;
|
|
59
|
+
drawn = true;
|
|
60
|
+
write(`\r${formatDownloadProgress({ label, received, total, elapsedMs: at - started, width: Math.max(10, width() - 1) })}\x1b[K`);
|
|
61
|
+
},
|
|
62
|
+
done() {
|
|
63
|
+
if (finished) return;
|
|
64
|
+
finished = true;
|
|
65
|
+
if (drawn) write("\r\x1b[K");
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -14,10 +14,11 @@ import {
|
|
|
14
14
|
} from "node:fs/promises";
|
|
15
15
|
import https from "node:https";
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
|
-
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
17
|
+
import { dirname, isAbsolute, join, relative, toNamespacedPath } from "node:path";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import { execFile } from "node:child_process";
|
|
20
20
|
import { promisify } from "node:util";
|
|
21
|
+
import { createProxyTunnelAgent, proxyTrustOptions, resolveProxyForTarget } from "./gentle-ai-proxy.mjs";
|
|
21
22
|
|
|
22
23
|
const execFileAsync = promisify(execFile);
|
|
23
24
|
const MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
|
|
@@ -37,7 +38,7 @@ const WINDOWS_SYSTEM_ROOT = "C:\\Windows";
|
|
|
37
38
|
// version check below) derives from this constant instead of repeating the
|
|
38
39
|
// literal, so a pin bump cannot leave a stale copy behind. See
|
|
39
40
|
// scripts/install-gentle-ai.mjs for the incident that motivated this.
|
|
40
|
-
export const INSTALLER_VERSION = "4.
|
|
41
|
+
export const INSTALLER_VERSION = "4.4.0";
|
|
41
42
|
export const RELEASE_BASE_URL = `https://github.com/Gentleman-Programming/gentle-ai/releases/download/v${INSTALLER_VERSION}/`;
|
|
42
43
|
export const GENTLE_AI_INSTALL_METHOD = Object.freeze({
|
|
43
44
|
SIGNED_RELEASE_ASSET: "signed-release-asset",
|
|
@@ -46,11 +47,11 @@ export const GENTLE_AI_INSTALL_METHOD = Object.freeze({
|
|
|
46
47
|
export const GENTLE_AI_WINDOWS_SOURCE_PACKAGE_PATH = "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai";
|
|
47
48
|
export const GENTLE_AI_WINDOWS_SOURCE_MODULE = "github.com/gentleman-programming/gentle-ai/v4";
|
|
48
49
|
export const GENTLE_AI_WINDOWS_SOURCE_TAG = `v${INSTALLER_VERSION}`;
|
|
49
|
-
// `go mod download -json github.com/gentleman-programming/gentle-ai/v4@v4.
|
|
50
|
+
// `go mod download -json github.com/gentleman-programming/gentle-ai/v4@v4.4.0`
|
|
50
51
|
// with GOSUMDB=sum.golang.org reports this exact module SumDB checksum, and the
|
|
51
|
-
// tag resolves to commit
|
|
52
|
+
// tag resolves to commit 55240afb100ad6d2ef5fbe16f7be33a7693f77ad, the published v4.4.0 release head.
|
|
52
53
|
// v4.0.0 moved the Go module path to the /v4 major-version suffix.
|
|
53
|
-
export const GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM = "h1:
|
|
54
|
+
export const GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM = "h1:cAQAzIsbocYcQfOzA1CmgGpGgiCivUNcPjdfJE8RJ6g=";
|
|
54
55
|
export const GENTLE_AI_WINDOWS_SOURCE_PACKAGE = `${GENTLE_AI_WINDOWS_SOURCE_PACKAGE_PATH}@${GENTLE_AI_WINDOWS_SOURCE_TAG}`;
|
|
55
56
|
export const GENTLE_AI_WINDOWS_MINIMUM_GO_VERSION = "1.25.10";
|
|
56
57
|
export const GENTLE_AI_GO_TOOLCHAIN_UNAVAILABLE_CODE = "GENTLE_AI_GO_TOOLCHAIN_UNAVAILABLE";
|
|
@@ -69,7 +70,7 @@ export class GentleAiInstallerError extends Error {
|
|
|
69
70
|
// Sentinel used while a re-pinned gentle-ai release is not yet published. A
|
|
70
71
|
// sentinel digest can never match a real SHA-256, so installation fails closed,
|
|
71
72
|
// and verify-package-files.mjs refuses to pack/publish while any digest below
|
|
72
|
-
// still holds it. The v4.
|
|
73
|
+
// still holds it. The v4.4.0 digests are pinned from the published release:
|
|
73
74
|
// archive sha256 values verified against the minisign-signed checksums.txt and
|
|
74
75
|
// freshly computed hashes; binary sha256 values computed from the extracted
|
|
75
76
|
// executables.
|
|
@@ -94,12 +95,14 @@ function asset(name, sha256, binarySha256, executable) {
|
|
|
94
95
|
// documented recovery instead of leaving a dead end until the next repin.
|
|
95
96
|
async function downloadPinnedGentleAiAsset(asset, destination, options) {
|
|
96
97
|
const download = options.download ?? downloadGentleAiAsset;
|
|
98
|
+
// Progress is display-only: it never changes what is downloaded or verified.
|
|
99
|
+
const progress = options.onProgress === undefined ? [] : [undefined, undefined, { onProgress: options.onProgress }];
|
|
97
100
|
try {
|
|
98
|
-
await download(asset.url, destination);
|
|
101
|
+
await download(asset.url, destination, ...progress);
|
|
99
102
|
} catch (primaryError) {
|
|
100
103
|
if (asset.mirrorUrl === undefined) throw primaryError;
|
|
101
104
|
try {
|
|
102
|
-
await download(asset.mirrorUrl, destination);
|
|
105
|
+
await download(asset.mirrorUrl, destination, ...progress);
|
|
103
106
|
} catch (mirrorError) {
|
|
104
107
|
throw new GentleAiInstallerError(
|
|
105
108
|
GENTLE_AI_ASSET_UNAVAILABLE_CODE,
|
|
@@ -111,15 +114,15 @@ async function downloadPinnedGentleAiAsset(asset, destination, options) {
|
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
// Windows is absent from signed release archives on purpose. gentle-ai stopped
|
|
114
|
-
// distributing unsigned Windows builds in c4b764d0, so v4.
|
|
117
|
+
// distributing unsigned Windows builds in c4b764d0, so v4.4.0 publishes signed
|
|
115
118
|
// Darwin/Linux archives only. Windows x64/arm64 uses the separately verified
|
|
116
119
|
// exact-tag Go SumDB source-build path below; restore archive rows only when
|
|
117
120
|
// upstream ships signed Windows assets.
|
|
118
121
|
export const GENTLE_AI_RELEASE_ASSETS = Object.freeze({
|
|
119
|
-
"darwin/amd64": asset("gentle-ai_4.
|
|
120
|
-
"darwin/arm64": asset("gentle-ai_4.
|
|
121
|
-
"linux/amd64": asset("gentle-ai_4.
|
|
122
|
-
"linux/arm64": asset("gentle-ai_4.
|
|
122
|
+
"darwin/amd64": asset("gentle-ai_4.4.0_darwin_amd64.tar.gz", "95686ea30615516aa29ebb6257227b1cdd4c67649dff63ec7adb576ca26a678d", "634189866db1db635aed6257716969e87e7cde6830c26627795becbd2969e104", "gentle-ai"),
|
|
123
|
+
"darwin/arm64": asset("gentle-ai_4.4.0_darwin_arm64.tar.gz", "b6e00957eb81115f18e33197ae2035f75812a624c6d53e72826ecf7b4a635539", "5bb53e7e32da585f08b668444209bde7a9b5c9c26489e2052bf180b05a2aab81", "gentle-ai"),
|
|
124
|
+
"linux/amd64": asset("gentle-ai_4.4.0_linux_amd64.tar.gz", "1f72ca13b32e87cb7f65b29e7fae6df4490b53d69d4763cdf23e944165880cd6", "9f39a94cef0b9882be4cd519fac3ef3602e602e3bf437df7db55c8cbd42f358d", "gentle-ai"),
|
|
125
|
+
"linux/arm64": asset("gentle-ai_4.4.0_linux_arm64.tar.gz", "2d8874464cbe54b66a77d7c9fe66ce577933de00936ed1a035c81de6406a95fc", "b9913af83cbeff2719e33d4b6c09e6ed568a000c4d6b885b4806ec5ce796f2b7", "gentle-ai"),
|
|
123
126
|
});
|
|
124
127
|
|
|
125
128
|
// A pinned asset is either a signed archive or, for a prerelease pin only,
|
|
@@ -171,17 +174,37 @@ async function sha256File(path) {
|
|
|
171
174
|
function downloadTimeoutError(stage) { return Object.assign(new Error(`Gentle AI download ${stage} timed out`), { code: "GENTLE_AI_DOWNLOAD_TIMEOUT" }); }
|
|
172
175
|
function isRetryableDownloadError(error) { return error && typeof error === "object" && ["GENTLE_AI_DOWNLOAD_TIMEOUT", "GENTLE_AI_DOWNLOAD_TRANSIENT_HTTP", "ECONNABORTED", "ECONNREFUSED", "ECONNRESET", "EAI_AGAIN", "EHOSTUNREACH", "ENETUNREACH", "ETIMEDOUT"].includes(error.code); }
|
|
173
176
|
function downloadHttpError(status) { return Object.assign(new Error(`Gentle AI download failed with HTTP ${status}`), { code: [429, 500, 502, 503, 504].includes(status) ? "GENTLE_AI_DOWNLOAD_TRANSIENT_HTTP" : "GENTLE_AI_DOWNLOAD_HTTP" }); }
|
|
177
|
+
/**
|
|
178
|
+
* Downloads a release asset over HTTPS.
|
|
179
|
+
*
|
|
180
|
+
* The trust options in `options` reach both peers of the connection, the
|
|
181
|
+
* proxy and the origin. An explicit `ca` replaces Node's default certificate
|
|
182
|
+
* authority list rather than adding to it, so it has to include the
|
|
183
|
+
* authorities of both peers the download is expected to reach. The client
|
|
184
|
+
* credentials are used for the origin only and are never offered to the
|
|
185
|
+
* proxy.
|
|
186
|
+
*/
|
|
174
187
|
export async function downloadGentleAiAsset(url, destination, maxBytes = MAX_DOWNLOAD_BYTES, redirects = MAX_REDIRECTS, options = {}) {
|
|
175
|
-
const { request = https.get, headerTimeoutMs = DOWNLOAD_TIMEOUTS.headers, bodyTimeoutMs = DOWNLOAD_TIMEOUTS.body, maxAttempts = DOWNLOAD_TIMEOUTS.attempts, retryDelayMs = DOWNLOAD_TIMEOUTS.retryDelay } = options;
|
|
188
|
+
const { request = https.get, env = process.env, headerTimeoutMs = DOWNLOAD_TIMEOUTS.headers, bodyTimeoutMs = DOWNLOAD_TIMEOUTS.body, maxAttempts = DOWNLOAD_TIMEOUTS.attempts, retryDelayMs = DOWNLOAD_TIMEOUTS.retryDelay, onProgress } = options;
|
|
189
|
+
// `onProgress({ received, total })` is display-only: `total` is undefined
|
|
190
|
+
// without a content-length. A reporter failure must never fail or alter the
|
|
191
|
+
// download itself, so it is swallowed here and reported per chunk below.
|
|
192
|
+
const report = (received, total) => { try { onProgress?.({ received, total }); } catch { /* display only */ } };
|
|
193
|
+
const trust = proxyTrustOptions(options);
|
|
176
194
|
if (![headerTimeoutMs, bodyTimeoutMs, retryDelayMs, maxAttempts].every((value) => Number.isSafeInteger(value) && value >= 0) || maxAttempts < 1) throw new TypeError("Gentle AI download timeout and retry options must be safe non-negative integers");
|
|
177
195
|
const responseFor = async (currentUrl, remainingRedirects) => {
|
|
178
196
|
const parsed = new URL(currentUrl);
|
|
179
197
|
if (parsed.protocol !== "https:") throw new Error("Gentle AI installer requires HTTPS downloads");
|
|
198
|
+
// The proxy is resolved per URL rather than once per download, because a
|
|
199
|
+
// redirect may land on a host that NO_PROXY exempts.
|
|
200
|
+
const proxy = resolveProxyForTarget(parsed, env);
|
|
201
|
+
const requestOptions = { headers: { "user-agent": "gentle-pi-installer" }, ...trust };
|
|
202
|
+
if (proxy !== undefined) requestOptions.agent = createProxyTunnelAgent(proxy, headerTimeoutMs, trust);
|
|
180
203
|
return new Promise((resolve, reject) => {
|
|
181
204
|
let pending;
|
|
182
205
|
const timer = setTimeout(() => pending?.destroy(downloadTimeoutError("headers")), headerTimeoutMs);
|
|
183
206
|
const fail = (error) => { clearTimeout(timer); reject(error); };
|
|
184
|
-
pending = request(parsed,
|
|
207
|
+
pending = request(parsed, requestOptions, (response) => {
|
|
185
208
|
clearTimeout(timer);
|
|
186
209
|
const status = response.statusCode ?? 0, location = response.headers.location;
|
|
187
210
|
if (status >= 300 && status < 400 && location) { response.resume(); return remainingRedirects <= 0 ? fail(new Error("Gentle AI download exceeded redirect limit")) : responseFor(new URL(location, parsed).toString(), remainingRedirects - 1).then(resolve, reject); }
|
|
@@ -210,7 +233,7 @@ export async function downloadGentleAiAsset(url, destination, maxBytes = MAX_DOW
|
|
|
210
233
|
const finish = (callback, value) => { if (settled) return; settled = true; clearTimeout(timer); void closed().then(() => callback(value)); };
|
|
211
234
|
const fail = (error) => { response.destroy(); output.destroy(); finish(reject, error); };
|
|
212
235
|
const reset = () => { clearTimeout(timer); timer = setTimeout(() => response.destroy(downloadTimeoutError("body")), bodyTimeoutMs); };
|
|
213
|
-
response.on("data", (chunk) => { reset(); received += chunk.length; if (received > maxBytes) response.destroy(new Error("Gentle AI download exceeds the maximum allowed size")); });
|
|
236
|
+
response.on("data", (chunk) => { reset(); received += chunk.length; if (received > maxBytes) response.destroy(new Error("Gentle AI download exceeds the maximum allowed size")); else report(received, contentLength > 0 ? contentLength : undefined); });
|
|
214
237
|
response.on("error", fail); response.setTimeout?.(bodyTimeoutMs, () => response.destroy(downloadTimeoutError("body")));
|
|
215
238
|
output.on("error", fail); output.on("finish", () => finish(resolve)); response.pipe(output);
|
|
216
239
|
});
|
|
@@ -661,7 +684,7 @@ async function installWindowsGentleAiFromGoSumdb(options, packageRoot, architect
|
|
|
661
684
|
const execute = options.execFile ?? execFileAsync;
|
|
662
685
|
return withInstallLock(packageRoot, options, async (runtimeRoot) => {
|
|
663
686
|
await cleanupStaleStagingBundles(runtimeRoot);
|
|
664
|
-
const stagingDirectory = await mkdtemp(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`));
|
|
687
|
+
const stagingDirectory = await mkdtemp(toNamespacedPath(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`)));
|
|
665
688
|
// Go builds in a short private directory under the system temp directory, never inside
|
|
666
689
|
// the package: from a deep pnpm store path (179 characters, run 38063142924) the
|
|
667
690
|
// working directories Go gives asm.exe inside GOMODCACHE exceed MAX_PATH and
|
|
@@ -704,7 +727,7 @@ async function installSignedRelease(options, packageRoot, platform, arch, asset)
|
|
|
704
727
|
await cleanupStaleStagingBundles(runtimeRoot);
|
|
705
728
|
const existing = versionBundlePath(runtimeRoot);
|
|
706
729
|
if (await existingSignedBundleMatches(existing, asset, platform)) return { installed: false, binaryPath: join(existing, asset.executable), asset };
|
|
707
|
-
const stagingDirectory = await mkdtemp(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`));
|
|
730
|
+
const stagingDirectory = await mkdtemp(toNamespacedPath(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`)));
|
|
708
731
|
try {
|
|
709
732
|
const form = gentleAiAssetForm(asset.name);
|
|
710
733
|
const archive = join(stagingDirectory, asset.name);
|