@picassohq/cli 1.0.6 → 1.0.8
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/LICENSE +14 -0
- package/README.md +100 -0
- package/dist/build-info.json +1 -1
- package/dist/index.js +1699 -1461
- package/package.json +27 -5
- package/runtime/engine-manifest.json +13 -3
- package/runtime/packages/picasso-compaction/index.js +116 -1
- package/runtime/packages/picasso-computer/cordis.patch.yml +5 -0
- package/runtime/packages/picasso-computer/index.js +670 -0
- package/runtime/packages/picasso-computer/native-anthropic.js +212 -0
- package/runtime/packages/picasso-computer/package.json +30 -0
- package/runtime/packages/picasso-computer/support.js +95 -0
- package/runtime/packages/picasso-lean-context/index.js +714 -8
- package/runtime/packages/picasso-lean-context/timeline.js +3 -2
- package/runtime/plugins/picasso-compaction/index.js +116 -1
- package/runtime/plugins/picasso-computer/index.js +670 -0
- package/runtime/plugins/picasso-computer/native-anthropic.js +212 -0
- package/runtime/plugins/picasso-computer/package.json +30 -0
- package/runtime/plugins/picasso-computer/support.js +95 -0
- package/runtime/plugins/picasso-lean-context/index.js +714 -8
- package/runtime/plugins/picasso-lean-context/timeline.js +3 -2
- package/runtime/relay/main.mjs +3052 -1564
- package/runtime/relay/remote/index.html +10 -2
- package/runtime/relay/remote/remote.css +8 -1
- package/runtime/relay/remote/remote.js +78 -17
- package/runtime/relay/versions-routes.mjs +14 -1
- package/scripts/install-runtime.mjs +33 -7
|
@@ -19,8 +19,16 @@
|
|
|
19
19
|
-->
|
|
20
20
|
<link rel="stylesheet" href="/remote/remote.css">
|
|
21
21
|
</head>
|
|
22
|
-
<body class="screen-
|
|
23
|
-
|
|
22
|
+
<body class="screen-boot">
|
|
23
|
+
<!-- What shows before (or without) remote.js: never a blank page. The late hint fades in by CSS only if the script
|
|
24
|
+
never replaces it (it would replace it within milliseconds). -->
|
|
25
|
+
<div id="app"><main class="boot" id="boot">
|
|
26
|
+
<div class="boot-title">Picasso Remote Control</div>
|
|
27
|
+
<div class="boot-sub">Loading…</div>
|
|
28
|
+
<div class="boot-late">Still loading? Reload this page. It needs JavaScript and a current Safari, Chrome, Edge or Firefox.
|
|
29
|
+
The address must start with https (not plain http).</div>
|
|
30
|
+
<noscript><div class="boot-err">Turn on JavaScript for this site to use Remote Control.</div></noscript>
|
|
31
|
+
</main></div>
|
|
24
32
|
<script src="/remote/remote.js" defer></script>
|
|
25
33
|
</body>
|
|
26
34
|
</html>
|
|
@@ -26,7 +26,14 @@ body {
|
|
|
26
26
|
}
|
|
27
27
|
[hidden] { display: none !important; }
|
|
28
28
|
button, input, textarea { font: inherit; color: inherit; }
|
|
29
|
-
|
|
29
|
+
/* The page before remote.js runs, and the screen a startup failure paints (never a blank page). */
|
|
30
|
+
.boot { max-width: 380px; width: 100%; margin: 0 auto; padding: calc(30vh + env(safe-area-inset-top)) 16px 24px; text-align: center; }
|
|
31
|
+
.boot-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
|
|
32
|
+
.boot-sub { font-size: 13px; color: var(--muted); }
|
|
33
|
+
.boot-late { margin-top: 16px; font-size: 12px; color: var(--muted); opacity: 0; animation: boot-late 0s linear 6s forwards; }
|
|
34
|
+
.boot-err { margin-top: 16px; padding: 8px 10px; border-radius: 8px; font-size: 12px; background: var(--err-bg); color: var(--danger); text-align: left; }
|
|
35
|
+
@keyframes boot-late { to { opacity: 1; } }
|
|
36
|
+
.fatal pre { margin-top: 8px; font: 12px/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
|
|
30
37
|
|
|
31
38
|
#app { display: flex; flex-direction: column; min-height: 100dvh; }
|
|
32
39
|
|
|
@@ -20,8 +20,11 @@ const STORE_KEY = 'picasso.remote';
|
|
|
20
20
|
const STALE_AFTER_MS = 20_000;
|
|
21
21
|
const MAX_EVENTS_PER_THREAD = 3_000;
|
|
22
22
|
const SCOPE_WORDS = { read: 'follow threads', prompt: 'send prompts', approve: 'answer approvals and questions', stop: 'stop turns' };
|
|
23
|
+
const UNREACHABLE = `Can't reach Picasso at ${location.host}. Check that the computer is awake and that this device is on the same network or tailnet.`;
|
|
23
24
|
|
|
24
25
|
const $app = document.getElementById('app');
|
|
26
|
+
window.addEventListener('error', (e) => fatal(e.error || e.message));
|
|
27
|
+
window.addEventListener('unhandledrejection', (e) => fatal(e.reason));
|
|
25
28
|
const state = {
|
|
26
29
|
cred: loadCred(), // {token, device:{id,name,kind?,scopes?}, base}
|
|
27
30
|
scopes: new Set(),
|
|
@@ -38,6 +41,8 @@ const state = {
|
|
|
38
41
|
retry: 0,
|
|
39
42
|
retryTimer: null,
|
|
40
43
|
paintQueued: false,
|
|
44
|
+
synced: false, // a snapshot arrived on this page (until then the list says Loading or can't reach)
|
|
45
|
+
unreachable: false, // the last stream attempt failed before any snapshot
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
function loadCred() {
|
|
@@ -47,8 +52,14 @@ function loadCred() {
|
|
|
47
52
|
} catch { /* fall through */ }
|
|
48
53
|
return null;
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
// Storage can be refused (blocked site data, an old private window): the sign-in then lasts for this page only.
|
|
56
|
+
let storageWarned = false;
|
|
57
|
+
function saveCred(c) {
|
|
58
|
+
try { localStorage.setItem(STORE_KEY, JSON.stringify(c)); } catch {
|
|
59
|
+
if (!storageWarned) { storageWarned = true; notice('This browser will not keep the sign-in, so pair again after a reload.', false); }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function dropCred() { try { localStorage.removeItem(STORE_KEY); } catch { /* nothing stored */ } state.cred = null; }
|
|
52
63
|
|
|
53
64
|
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
54
65
|
const fmtWhen = (ms) => {
|
|
@@ -77,7 +88,7 @@ async function api(path, opts = {}) {
|
|
|
77
88
|
headers: { 'content-type': 'application/json', authorization: `Bearer ${state.cred.token}`, ...(opts.headers || {}) },
|
|
78
89
|
});
|
|
79
90
|
} catch {
|
|
80
|
-
throw new ApiError(
|
|
91
|
+
throw new ApiError(UNREACHABLE);
|
|
81
92
|
}
|
|
82
93
|
if (res.status === 401) { signOut('This device is no longer paired. Pair it again.'); throw new ApiError('unpaired'); }
|
|
83
94
|
const body = res.status === 204 ? {} : await res.json().catch(() => ({}));
|
|
@@ -172,18 +183,26 @@ async function pairWith(code) {
|
|
|
172
183
|
});
|
|
173
184
|
const body = await res.json().catch(() => ({}));
|
|
174
185
|
if (!res.ok || typeof body.token !== 'string') {
|
|
175
|
-
err.innerHTML = `<div class="banner err">${esc(
|
|
186
|
+
err.innerHTML = `<div class="banner err">${esc(pairErrorText(res.status, body))}</div>`;
|
|
176
187
|
return;
|
|
177
188
|
}
|
|
178
189
|
state.cred = { token: body.token, device: body.device || { id: '', name: 'This device' }, base: location.origin };
|
|
179
190
|
saveCred(state.cred);
|
|
180
|
-
history.replaceState(null, '', '/remote');
|
|
181
|
-
boot();
|
|
182
191
|
} catch {
|
|
183
|
-
err.innerHTML =
|
|
192
|
+
err.innerHTML = `<div class="banner err">${esc(UNREACHABLE)}</div>`;
|
|
193
|
+
return;
|
|
184
194
|
} finally {
|
|
185
195
|
btn.disabled = false;
|
|
186
196
|
}
|
|
197
|
+
try { history.replaceState(null, '', '/remote'); } catch { /* the code stays in the address bar */ }
|
|
198
|
+
safeBoot();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Why a pairing code was refused, in words a person can act on (an expired or used code is the usual case). */
|
|
202
|
+
function pairErrorText(status, body) {
|
|
203
|
+
if (status === 401 || status === 410) return 'This pairing code has expired or was already used. Make a new one on the computer: picasso remote pair, or Settings › Remote on the Mac.';
|
|
204
|
+
if (status === 404) return 'Pairing is turned off on this computer.';
|
|
205
|
+
return errorText(status, body);
|
|
187
206
|
}
|
|
188
207
|
|
|
189
208
|
async function signInWithToken(token) {
|
|
@@ -201,10 +220,11 @@ async function signInWithToken(token) {
|
|
|
201
220
|
}
|
|
202
221
|
state.cred = { token: clean, device: body.device, base: location.origin };
|
|
203
222
|
saveCred(state.cred);
|
|
204
|
-
boot();
|
|
205
223
|
} catch {
|
|
206
|
-
err.innerHTML =
|
|
224
|
+
err.innerHTML = `<div class="banner err">${esc(UNREACHABLE)}</div>`;
|
|
225
|
+
return;
|
|
207
226
|
}
|
|
227
|
+
safeBoot();
|
|
208
228
|
}
|
|
209
229
|
|
|
210
230
|
function signOut(message) {
|
|
@@ -319,6 +339,7 @@ function openStream() {
|
|
|
319
339
|
es.close();
|
|
320
340
|
state.es = null;
|
|
321
341
|
setConn('reconnecting');
|
|
342
|
+
if (!state.synced) { state.unreachable = true; schedulePaint(); }
|
|
322
343
|
void checkStillPaired();
|
|
323
344
|
scheduleReopen();
|
|
324
345
|
};
|
|
@@ -385,6 +406,8 @@ function onFrame(name, d) {
|
|
|
385
406
|
state.rows.clear(); state.running.clear(); state.pending.clear(); state.threads.clear();
|
|
386
407
|
break;
|
|
387
408
|
case 'snapshot': {
|
|
409
|
+
state.synced = true;
|
|
410
|
+
state.unreachable = false;
|
|
388
411
|
state.rows.clear();
|
|
389
412
|
for (const row of d.threads || []) if (row && row.sessionId && row.origin !== 'subagent' && !row.archived) state.rows.set(row.sessionId, row);
|
|
390
413
|
state.running = new Set(d.running || [...state.rows.values()].filter((r) => r.running).map((r) => r.sessionId));
|
|
@@ -451,7 +474,9 @@ function normalizeRecord(record) {
|
|
|
451
474
|
return null;
|
|
452
475
|
}
|
|
453
476
|
|
|
454
|
-
|
|
477
|
+
/* `fromHistory`: a page of older records. It only fills the feed: the live text of a turn streaming right now, and
|
|
478
|
+
whether the thread runs, come from the stream (a history page can land after the first chunks of a new turn). */
|
|
479
|
+
function addEvent(id, event, fromHistory = false) {
|
|
455
480
|
const t = thread(id);
|
|
456
481
|
let seq = typeof event.seq === 'number' ? event.seq : undefined;
|
|
457
482
|
if (seq !== undefined && t.events.has(seq)) return false;
|
|
@@ -460,6 +485,7 @@ function addEvent(id, event) {
|
|
|
460
485
|
if (!t.order.length || seq > t.order[t.order.length - 1]) t.order.push(seq);
|
|
461
486
|
else { t.order.push(seq); t.order.sort((a, b) => a - b); }
|
|
462
487
|
while (t.order.length > MAX_EVENTS_PER_THREAD) t.events.delete(t.order.shift());
|
|
488
|
+
if (fromHistory) return true;
|
|
463
489
|
const d = event.data || {};
|
|
464
490
|
switch (event.type) {
|
|
465
491
|
case 'turn/start': t.liveText = ''; t.liveThink = ''; state.running.add(id); break;
|
|
@@ -512,7 +538,7 @@ async function loadHistory(id, earlier) {
|
|
|
512
538
|
if (first !== undefined) params.set('beforeSeq', String(first));
|
|
513
539
|
}
|
|
514
540
|
const page = await api(`/threads/${encodeURIComponent(id)}/history?${params}`);
|
|
515
|
-
for (const record of page.records || []) { const ev = normalizeRecord(record); if (ev) addEvent(id, ev); }
|
|
541
|
+
for (const record of page.records || []) { const ev = normalizeRecord(record); if (ev) addEvent(id, ev, true); }
|
|
516
542
|
t.hasMore = Boolean(page.hasMore);
|
|
517
543
|
t.loaded = true;
|
|
518
544
|
} catch (e) {
|
|
@@ -591,7 +617,10 @@ async function decide(btn, act) {
|
|
|
591
617
|
function schedulePaint() {
|
|
592
618
|
if (state.paintQueued) return;
|
|
593
619
|
state.paintQueued = true;
|
|
594
|
-
|
|
620
|
+
const run = () => { state.paintQueued = false; paint(); };
|
|
621
|
+
// A hidden page gets no animation frames (a background tab, a phone's other app): paint on a timer instead, so the
|
|
622
|
+
// screen is already current when it shows again.
|
|
623
|
+
if (document.hidden) setTimeout(run, 50); else requestAnimationFrame(run);
|
|
595
624
|
}
|
|
596
625
|
|
|
597
626
|
function applyScopes() {
|
|
@@ -629,7 +658,9 @@ function paintList() {
|
|
|
629
658
|
const list = document.getElementById('list');
|
|
630
659
|
const rows = sortedRows();
|
|
631
660
|
if (!rows.length) {
|
|
632
|
-
list.innerHTML =
|
|
661
|
+
list.innerHTML = !state.synced
|
|
662
|
+
? (state.unreachable ? `<div class="empty"><div class="big">Can't reach the computer</div>${esc(UNREACHABLE)} Retrying…</div>` : '<div class="empty">Loading…</div>')
|
|
663
|
+
: `<div class="empty"><div class="big">No threads yet</div>${can('prompt') ? 'Start one on the computer, or here with New.' : 'Threads started on the computer show up here.'}</div>`;
|
|
633
664
|
return;
|
|
634
665
|
}
|
|
635
666
|
const needing = new Set([...state.pending.values()].map((p) => p.sessionId));
|
|
@@ -783,6 +814,11 @@ function needHtml(p) {
|
|
|
783
814
|
|
|
784
815
|
/* ---------- boot ---------- */
|
|
785
816
|
|
|
817
|
+
/** boot(), with a failure (a browser without EventSource, say) shown as the error card rather than a stuck screen. */
|
|
818
|
+
function safeBoot() {
|
|
819
|
+
try { boot(); } catch (err) { stopStream(); fatal(err, true); }
|
|
820
|
+
}
|
|
821
|
+
|
|
786
822
|
function boot() {
|
|
787
823
|
setScopes(state.cred.device);
|
|
788
824
|
shell();
|
|
@@ -792,10 +828,35 @@ function boot() {
|
|
|
792
828
|
openStream();
|
|
793
829
|
}
|
|
794
830
|
|
|
831
|
+
/* A failure while starting (an exception in start(), or any uncaught error while the boot screen is still up: a
|
|
832
|
+
browser missing an API) paints a visible error card, so the page is never blank or stuck on Loading. Errors after a
|
|
833
|
+
screen rendered are left to that screen. */
|
|
834
|
+
function fatal(err, starting = false) {
|
|
835
|
+
if (!$app || (!starting && !document.getElementById('boot'))) return;
|
|
836
|
+
document.body.className = 'screen-signin';
|
|
837
|
+
const detail = err && (err.message || String(err));
|
|
838
|
+
$app.innerHTML = `
|
|
839
|
+
<main class="signin fatal">
|
|
840
|
+
<div class="card">
|
|
841
|
+
<div class="h">Remote control could not start</div>
|
|
842
|
+
<div class="p">Reload the page. If it keeps happening, open the link in a current Safari or Chrome, or pair again from the computer (picasso remote pair).</div>
|
|
843
|
+
<pre></pre>
|
|
844
|
+
<button class="btn full" id="reloadbtn">Reload</button>
|
|
845
|
+
</div>
|
|
846
|
+
</main>`;
|
|
847
|
+
const pre = $app.querySelector('.fatal pre');
|
|
848
|
+
if (detail) pre.textContent = detail; else pre.remove();
|
|
849
|
+
document.getElementById('reloadbtn').addEventListener('click', () => location.reload());
|
|
850
|
+
}
|
|
851
|
+
|
|
795
852
|
(function start() {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
853
|
+
try {
|
|
854
|
+
const code = /[#&?]c=([A-Za-z0-9-]+)/.exec(location.hash)?.[1] || /[?&]c=([A-Za-z0-9-]+)/.exec(location.search)?.[1];
|
|
855
|
+
if (code) { try { history.replaceState(null, '', '/remote'); } catch { /* the code stays in the address bar */ } }
|
|
856
|
+
if (!state.cred) { signInScreen(code || ''); return; }
|
|
857
|
+
safeBoot();
|
|
858
|
+
} catch (err) {
|
|
859
|
+
fatal(err, true);
|
|
860
|
+
}
|
|
800
861
|
})();
|
|
801
862
|
})();
|
|
@@ -90,6 +90,15 @@ var LOCAL_ATTACH_PROVIDER_ROUTES = Object.freeze([
|
|
|
90
90
|
{ method: "GET", path: "/providers/:id/model-choices" },
|
|
91
91
|
{ method: "POST", path: "/providers/:id/active-models" }
|
|
92
92
|
]);
|
|
93
|
+
var LOCAL_ATTACH_REMOTE_ROUTES = Object.freeze([
|
|
94
|
+
{ method: "POST", path: "/bridge/join" },
|
|
95
|
+
{ method: "GET", path: "/bridge/:id/commands" },
|
|
96
|
+
{ method: "POST", path: "/bridge/:id/frames" },
|
|
97
|
+
{ method: "POST", path: "/bridge/:id/leave" },
|
|
98
|
+
{ method: "POST", path: "/pair/codes" },
|
|
99
|
+
{ method: "GET", path: "/pair/state" },
|
|
100
|
+
{ method: "GET", path: "/pair/devices" }
|
|
101
|
+
]);
|
|
93
102
|
var LOCAL_ATTACH_ROUTES = Object.freeze([
|
|
94
103
|
{ method: "GET", path: "/health" },
|
|
95
104
|
{ method: "GET", path: "/threads" },
|
|
@@ -104,7 +113,11 @@ var LOCAL_ATTACH_ROUTES = Object.freeze([
|
|
|
104
113
|
// with each thread's status, goal and usage from its log. Read-only; its bulk actions and the folders routes stay
|
|
105
114
|
// owner-only (stop goes through `/threads/:id/cancel`, already allowed).
|
|
106
115
|
{ method: "GET", path: "/center" },
|
|
107
|
-
|
|
116
|
+
// Computer use status (`picasso computer status` beside an open Picasso for Mac): whether the app is attached as the
|
|
117
|
+
// computer host and what it reported. Read-only; the actions and the host state stay owner-only.
|
|
118
|
+
{ method: "GET", path: "/computer/status" },
|
|
119
|
+
...LOCAL_ATTACH_PROVIDER_ROUTES,
|
|
120
|
+
...LOCAL_ATTACH_REMOTE_ROUTES
|
|
108
121
|
]);
|
|
109
122
|
var LOCAL_ATTACH_FORBIDDEN_DECISIONS = Object.freeze(["allow-always"]);
|
|
110
123
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Postinstall for the published @picassohq/cli (AO-038.03, GO-LIVE-PRD Lane 1 D19/D20): make sure the pinned
|
|
3
3
|
// engine (@deepseek-ai/dsh, DSH_PINNED_VERSION below = packages/core contract.ts) is installed in
|
|
4
|
-
// ~/.picasso/dsh from the committed lock: <pkg>/runtime-lock/{package.json,package-lock.json} → `npm ci`.
|
|
4
|
+
// $PICASSO_HOME/dsh (when PICASSO_HOME is set) or ~/.picasso/dsh from the committed lock: <pkg>/runtime-lock/{package.json,package-lock.json} → `npm ci`.
|
|
5
5
|
// `<prefix>/bin/dsh` links to `../node_modules/.bin/dsh`, the path the CLI resolves first when it is the pin.
|
|
6
6
|
//
|
|
7
7
|
// Guards (install skipped, exit 0):
|
|
8
8
|
// * repo/workspace checkouts (pnpm-workspace.yaml two levels above the package and a workspace manifest);
|
|
9
9
|
// * PICASSO_SKIP_DSH_INSTALL=1;
|
|
10
10
|
// * CI (CI/CONTINUOUS_INTEGRATION) unless PICASSO_INSTALL_DSH=1;
|
|
11
|
-
// * an engine on PATH that already reports the pin (a different version on PATH never blocks the install)
|
|
11
|
+
// * an engine on PATH that already reports the pin (a different version on PATH never blocks the install);
|
|
12
|
+
// * the pin already installed in any managed prefix (`$PICASSO_HOME/dsh` or the older `~/.picasso/dsh`).
|
|
12
13
|
//
|
|
13
14
|
// Every failure path is NON-FATAL: the CLI still installs and `picasso update runtime --install` retries.
|
|
14
15
|
|
|
@@ -25,9 +26,32 @@ const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
|
25
26
|
const packageDir = join(scriptDir, "..");
|
|
26
27
|
const say = (msg) => process.stderr.write(`picasso postinstall: ${msg}\n`);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
const nonEmpty = (value) => (typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined);
|
|
30
|
+
|
|
31
|
+
/** `~/.picasso/dsh`: where every install went before PICASSO_HOME was honoured. */
|
|
32
|
+
export function homeRuntimePrefix(env = process.env) {
|
|
33
|
+
return join(env.HOME ?? homedir(), ".picasso", "dsh");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Install prefix: `PICASSO_DSH_HOME`, else `$PICASSO_HOME/dsh` when PICASSO_HOME is set, else `~/.picasso/dsh`.
|
|
38
|
+
* The engine resolver (packages/core `choosePinnedDshBin`) looks in `$PICASSO_HOME/dsh/bin` and `~/.picasso/dsh/bin`.
|
|
39
|
+
*/
|
|
29
40
|
export function defaultRuntimePrefix(env = process.env) {
|
|
30
|
-
|
|
41
|
+
const explicit = nonEmpty(env.PICASSO_DSH_HOME);
|
|
42
|
+
if (explicit !== undefined) return explicit;
|
|
43
|
+
const picassoHome = nonEmpty(env.PICASSO_HOME);
|
|
44
|
+
return picassoHome === undefined ? homeRuntimePrefix(env) : join(picassoHome, "dsh");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Every prefix an existing install may live in, install target first: an older `~/.picasso/dsh` install keeps working. */
|
|
48
|
+
export function runtimePrefixes(env = process.env) {
|
|
49
|
+
return [...new Set([defaultRuntimePrefix(env), homeRuntimePrefix(env)])];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The first managed prefix that already holds the pinned engine (with its `bin` link), if any. */
|
|
53
|
+
export function pinnedRuntimePrefix(env = process.env) {
|
|
54
|
+
return runtimePrefixes(env).find((prefix) => installedVersion(prefix) === DSH_PINNED_VERSION && existsSync(join(prefix, "bin")));
|
|
31
55
|
}
|
|
32
56
|
|
|
33
57
|
/** Version of the engine package installed under `prefixDir` (lock layout or `npm -g --prefix` layout). */
|
|
@@ -369,12 +393,14 @@ function main() {
|
|
|
369
393
|
return;
|
|
370
394
|
}
|
|
371
395
|
|
|
372
|
-
const
|
|
373
|
-
if (
|
|
374
|
-
say(`pinned runtime ${DSH_PINNED_VERSION} already present at ${
|
|
396
|
+
const present = pinnedRuntimePrefix();
|
|
397
|
+
if (present !== undefined) {
|
|
398
|
+
say(`pinned runtime ${DSH_PINNED_VERSION} already present at ${present}`);
|
|
375
399
|
return;
|
|
376
400
|
}
|
|
377
401
|
|
|
402
|
+
const prefixDir = defaultRuntimePrefix();
|
|
403
|
+
|
|
378
404
|
try {
|
|
379
405
|
installPinnedRuntime(prefixDir);
|
|
380
406
|
say(`installed pinned runtime ${DSH_PINNED_VERSION} -> ${prefixDir}/bin`);
|