@outerlayer/cli 0.36.0-next.20261101174803 → 0.36.0-next.20261102135508
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/dist/agent-setup-Q3HDN23U.js +39 -0
- package/dist/agent-subcommand-Z6SOLWZW.js +25 -0
- package/dist/bridge-4KPODDN7.js +15 -0
- package/dist/build-KYXFZQ33.js +23 -0
- package/dist/build-disk-W6AL5WHI.js +20 -0
- package/dist/build-info.json +1 -1
- package/dist/builder-IMNOEYV7.js +19 -0
- package/dist/caller-NLRE272L.js +22 -0
- package/dist/{check-K4RVAP4L.js → check-WWX32IGY.js} +78 -74
- package/dist/{chunk-MKSZHT6S.js → chunk-2YC3TXWX.js} +1 -1
- package/dist/{chunk-QIOTIQWD.js → chunk-3UFX6KH2.js} +12 -11
- package/dist/{chunk-F2LPX2HS.js → chunk-3YEPLVNW.js} +8 -8
- package/dist/chunk-4DLJ343I.js +38 -0
- package/dist/{chunk-5WYT3PPE.js → chunk-4OD45RBP.js} +4 -1
- package/dist/{chunk-H7SKHAUE.js → chunk-4XXBV37R.js} +6 -6
- package/dist/{chunk-XNBUZGRO.js → chunk-6B3V6EGQ.js} +11 -9
- package/dist/{chunk-O36YAH2G.js → chunk-6HDXRDC5.js} +4 -4
- package/dist/chunk-6JLYU322.js +68 -0
- package/dist/{chunk-5GHJFETA.js → chunk-6KH3NMIT.js} +3010 -1196
- package/dist/{chunk-SPXVFFQV.js → chunk-AQE6E54X.js} +10 -9
- package/dist/{chunk-LGV5N5DG.js → chunk-ATKCHMFD.js} +1 -1
- package/dist/{chunk-7J7HRYZ3.js → chunk-B2P72DAE.js} +1 -1
- package/dist/{chunk-LEHBDEUG.js → chunk-B36NSEUM.js} +4 -5
- package/dist/{chunk-B62TYDP2.js → chunk-B5SWBFVE.js} +5 -4
- package/dist/chunk-BSPJI5T7.js +28 -0
- package/dist/{chunk-VJYSPH2J.js → chunk-BUYXEU7J.js} +26 -21
- package/dist/{chunk-CIUD3436.js → chunk-BZSJ77MO.js} +1 -1
- package/dist/{chunk-OEBFKPHK.js → chunk-CDG475ZP.js} +11 -11
- package/dist/{chunk-AGKQEOFS.js → chunk-CSBW4LGL.js} +54 -31
- package/dist/{chunk-D2OTBS47.js → chunk-CSVJGW3I.js} +2 -2
- package/dist/{chunk-GANAOCHR.js → chunk-CXJC3JLN.js} +25 -374
- package/dist/{chunk-WAZJPDR2.js → chunk-D4VGJQY7.js} +1 -1
- package/dist/{chunk-BRUDBWLO.js → chunk-D5I5SSPU.js} +7 -7
- package/dist/{chunk-KFUDKFEH.js → chunk-D6EXW4EB.js} +45 -19
- package/dist/{chunk-AF6DQJ5W.js → chunk-DG3M5DZU.js} +1 -1
- package/dist/{chunk-WT7J2627.js → chunk-DTCTXDJP.js} +1 -1
- package/dist/chunk-DTQPDMHG.js +654 -0
- package/dist/{chunk-EZRAR5YG.js → chunk-E3TP4QTM.js} +1 -1
- package/dist/{chunk-NFZJ5XHP.js → chunk-ENBOAE2W.js} +33 -32
- package/dist/{chunk-R3252UTU.js → chunk-ENMX3VQ7.js} +7 -7
- package/dist/{chunk-AH6634HC.js → chunk-FOSYM7TQ.js} +1 -2
- package/dist/{chunk-HL7UNTXO.js → chunk-FRMAQ3C4.js} +17 -10
- package/dist/{chunk-HAWPG7QW.js → chunk-FTP7SE6Y.js} +3 -3
- package/dist/{chunk-IP7BIBXJ.js → chunk-FWSVWPMS.js} +16 -7
- package/dist/{chunk-GLUQVET2.js → chunk-GFZ7PELR.js} +6 -6
- package/dist/{chunk-UZGQT6OF.js → chunk-H2NJG3TE.js} +6 -3
- package/dist/{chunk-46OBCATR.js → chunk-HRHWA6TZ.js} +1 -1
- package/dist/chunk-HTRDL42C.js +45 -0
- package/dist/{chunk-YBAVN6WS.js → chunk-I4DM7SNX.js} +7 -7
- package/dist/{chunk-24FEVLX7.js → chunk-I6U6QPN6.js} +1311 -73
- package/dist/{chunk-4DJZSNVT.js → chunk-IKFAJTLZ.js} +1 -1
- package/dist/{chunk-55PYF6S2.js → chunk-J2OMKFYB.js} +3 -3
- package/dist/{chunk-7Y5VW4JG.js → chunk-K2G3VB7W.js} +1 -1
- package/dist/chunk-K7N6LAPC.js +78 -0
- package/dist/{chunk-ULBVE7MP.js → chunk-KRCU66AM.js} +9 -9
- package/dist/{chunk-JU3VU42K.js → chunk-LHHDX7FB.js} +5 -5
- package/dist/{chunk-FUJUFLDC.js → chunk-LO4CK734.js} +8 -14
- package/dist/chunk-LSLK4RS4.js +82 -0
- package/dist/{chunk-ABAVN4RT.js → chunk-LSZUTI6O.js} +29 -26
- package/dist/chunk-MVPOYQQY.js +136 -0
- package/dist/{chunk-YQHEJ5SV.js → chunk-NXQK2I3G.js} +3 -3
- package/dist/{chunk-DJMR4YPG.js → chunk-O3MJAHLI.js} +82 -96
- package/dist/{chunk-B7PYT2BY.js → chunk-PBGNX3PS.js} +6 -3
- package/dist/{chunk-CJJDJ7AT.js → chunk-PIZA7OG2.js} +5 -3
- package/dist/{chunk-RIHB3HA2.js → chunk-PMA67TIN.js} +3 -3
- package/dist/{chunk-DJDTL6AY.js → chunk-QKOJ22OV.js} +148 -293
- package/dist/{chunk-RDWKRG4K.js → chunk-RF4JHGGB.js} +7 -7
- package/dist/{chunk-MOOZJRKM.js → chunk-SJJXDU2J.js} +27 -30
- package/dist/chunk-T5QBWM6M.js +113 -0
- package/dist/{chunk-W7I65BKE.js → chunk-TJIFYV2Z.js} +12 -12
- package/dist/{chunk-EBOQU6QC.js → chunk-TKY3SDXH.js} +6 -6
- package/dist/{chunk-ALEUIS35.js → chunk-ULBYRPAP.js} +1 -1
- package/dist/{chunk-ZP7F3OHV.js → chunk-URHS76GV.js} +48 -38
- package/dist/{chunk-X2XTCGUS.js → chunk-VAYVTUU4.js} +11 -12
- package/dist/{chunk-TSYHUUAT.js → chunk-VUH7KKVD.js} +3 -3
- package/dist/{chunk-RIIPBJK6.js → chunk-WACPWYMH.js} +4 -4
- package/dist/{chunk-AAGU5FJF.js → chunk-WGC7UFRM.js} +1 -1
- package/dist/{chunk-2SRQSGPR.js → chunk-WVAXJOWG.js} +30 -24
- package/dist/{chunk-KLXECBIE.js → chunk-XEWG4AB2.js} +151 -108
- package/dist/{chunk-KDK6AF7B.js → chunk-XIDDJSQU.js} +7 -6
- package/dist/{chunk-MXIFRYLA.js → chunk-Y4E7IS7H.js} +2 -2
- package/dist/{chunk-DHFNBNC3.js → chunk-YJQ7YA7J.js} +5 -5
- package/dist/{chunk-6A2GEFN3.js → chunk-YMVRCSKD.js} +4 -4
- package/dist/{chunk-JW5BENE6.js → chunk-YYQ5NOT5.js} +3 -3
- package/dist/chunk-ZHQC43NH.js +130 -0
- package/dist/{chunk-KB5B6ZT5.js → chunk-ZSRMJOAK.js} +20 -20
- package/dist/{claude-launcher-L77BKZOC.js → claude-launcher-LGKJZH33.js} +99 -120
- package/dist/{cli-QQY5UECM.js → cli-Q5L64EEG.js} +327 -298
- package/dist/{cli-update-notice-T3CXRWNB.js → cli-update-notice-AWYJ4A7R.js} +2 -2
- package/dist/{command-QLHQZ32L.js → command-CGEFJZNC.js} +65 -64
- package/dist/{config-5GY7FL35.js → config-T22KVOOT.js} +14 -10
- package/dist/connect-cmd-RUBP466E.js +28 -0
- package/dist/{container-start-OCJODSMB.js → container-start-JRF3SBUA.js} +65 -62
- package/dist/{context-cleanup-A7KBEBIO.js → context-cleanup-3K2AOECJ.js} +6 -2
- package/dist/{context-show-cmd-MZ74ZIVO.js → context-show-cmd-4UXO5WQJ.js} +18 -16
- package/dist/{control-plane-launch-3TZFOSCX.js → control-plane-launch-AAH4YH56.js} +31 -27
- package/dist/{demo-record-cmd-Y57UWBCX.js → demo-record-cmd-2OKCGST7.js} +10 -5
- package/dist/{demo-voice-cmd-4INIOVTC.js → demo-voice-cmd-GEPX7GIG.js} +27 -27
- package/dist/{dist-6KGTCWKR.js → dist-VVZIGSAF.js} +1 -1
- package/dist/docker-5VWK335X.js +19 -0
- package/dist/{doctor-DB2AJUAO.js → doctor-EQM3JRZI.js} +81 -76
- package/dist/emit-artifact-cmd-TA3MPHLU.js +43 -0
- package/dist/{emit-cmd-IOWTTZSA.js → emit-cmd-RO4L4PFZ.js} +9 -8
- package/dist/emit-criteria-cmd-NMTUV2KM.js +34 -0
- package/dist/emit-demo-cmd-Y2Y6LEL7.js +46 -0
- package/dist/{emit-finding-cmd-KQIGM5IF.js → emit-finding-cmd-VECM64UR.js} +20 -19
- package/dist/{emit-result-cmd-6Q7OU2NY.js → emit-result-cmd-2ERWFDUN.js} +25 -24
- package/dist/{emit-step-cmd-GZU5O2FR.js → emit-step-cmd-V2ET66N4.js} +20 -19
- package/dist/exec-client-54XKNPTI.js +16 -0
- package/dist/find-unit-CNAPU7XQ.js +23 -0
- package/dist/{findings-cmd-T7PQAVJG.js → findings-cmd-QJPPF6BY.js} +20 -19
- package/dist/{fleet-readiness-PTMOEX6L.js → fleet-readiness-DKAPHAZN.js} +16 -15
- package/dist/governing-source-7PZ6DAJU.js +40 -0
- package/dist/guest-init-5QZRGP62.js +18 -0
- package/dist/{hook-fast-RW7RU3O6.js → hook-fast-VXROB4KF.js} +7 -5
- package/dist/hook-install-GDNRMML4.js +14 -0
- package/dist/{hook-wrap-fast-545QJSBJ.js → hook-wrap-fast-LWWKKPGK.js} +4 -2
- package/dist/host-checks-WAPO5X7X.js +78 -0
- package/dist/host-key-HLLV37NV.js +16 -0
- package/dist/image-tag-PBWQBATH.js +17 -0
- package/dist/index.js +8 -9
- package/dist/init-EK3PUU6W.js +78 -0
- package/dist/{init-HUQLVUPO.js → init-Y2URPVVY.js} +62 -59
- package/dist/{init-cmd-6NQGBVAJ.js → init-cmd-XNANUDIW.js} +38 -33
- package/dist/{init-update-MA6QKX46.js → init-update-EFCTKF6D.js} +55 -46
- package/dist/install-cmd-RHFUZFV4.js +19 -0
- package/dist/layout-7XMC7S6K.js +13 -0
- package/dist/{logs-FEITSC2V.js → logs-E7MGQINH.js} +10 -3
- package/dist/loop-L6TX6OR4.js +89 -0
- package/dist/machine-VJKAY2GX.js +78 -0
- package/dist/{machine-skills-237PQFRC.js → machine-skills-HR4RNRNR.js} +5 -4
- package/dist/{mcp-install-cmd-23ZY4IBK.js → mcp-install-cmd-SMPLT43Q.js} +7 -1
- package/dist/{mcp-serve-cmd-ZINYSLY6.js → mcp-serve-cmd-XXERT673.js} +11 -7
- package/dist/{paths-XEYE7OZ2.js → paths-F2ZR2EKC.js} +10 -3
- package/dist/pending-VOFQRXP4.js +16 -0
- package/dist/pidfile-7M7O2M7T.js +17 -0
- package/dist/record-YCJ6DZOY.js +16 -0
- package/dist/{relay-IEYNSKAZ.js → relay-I2T43PPB.js} +8 -1
- package/dist/relay-protocol-GI2GC2AM.js +13 -0
- package/dist/runner-env-YW55JVU7.js +23 -0
- package/dist/runner-identity-Y5ZFCC7V.js +19 -0
- package/dist/{runner-key-CFZ47PR3.js → runner-key-R47C6374.js} +54 -54
- package/dist/session-sender-UPACLRGG.js +43 -0
- package/dist/{shell-function-NRD4KVUK.js → shell-function-GYD2ZQQG.js} +2 -1
- package/dist/{spec-cmd-CNASSB6L.js → spec-cmd-7QRE2SZK.js} +21 -20
- package/dist/{starter-pack-CCVIEY72.js → starter-pack-IMKIUA56.js} +7 -6
- package/dist/state-VAHBIMS5.js +16 -0
- package/dist/{status-VNHIHQ57.js → status-BQEYEG2V.js} +54 -54
- package/dist/{statusline-fast-E7RWVREA.js → statusline-fast-NUVHCNRX.js} +4 -2
- package/dist/{sync-cmd-5JLJBODH.js → sync-cmd-NBLYEPQG.js} +25 -24
- package/dist/update-steps-VGKNGWTZ.js +79 -0
- package/dist/{watch-AEWWTUEK.js → watch-IHV4V3HZ.js} +25 -24
- package/dist/{work-claim-cmd-GUYOJYH7.js → work-claim-cmd-WGTSU5IT.js} +24 -24
- package/dist/{work-cmd-YRPYMGII.js → work-cmd-HKOJU5FJ.js} +18 -17
- package/dist/{work-comment-cmd-U5Z6FKEU.js → work-comment-cmd-H3JCWQ2J.js} +21 -20
- package/dist/{work-demo-cmd-OLCWTVWM.js → work-demo-cmd-J4AZAIVP.js} +18 -17
- package/dist/{work-launch-TTGSHLY4.js → work-launch-LWDQXLGI.js} +1 -1
- package/dist/{work-logs-cmd-2OA7ENDU.js → work-logs-cmd-UOO4JVLG.js} +18 -17
- package/dist/{work-open-pr-cmd-6GUCDYVM.js → work-open-pr-cmd-QFRDDBAM.js} +20 -19
- package/dist/{work-pr-cmd-KK3VQUQI.js → work-pr-cmd-3Q2D5RQT.js} +19 -18
- package/dist/{work-proofs-cmd-BUOS5OJC.js → work-proofs-cmd-7Y3HGT7C.js} +21 -20
- package/dist/{work-proofs-record-6WLMOK53.js → work-proofs-record-QPUM6DY4.js} +31 -31
- package/dist/{work-stop-cmd-VZJX5X4L.js → work-stop-cmd-SD2ZRMSY.js} +18 -17
- package/package.json +1 -1
- package/dist/agent-setup-DJRQFPDU.js +0 -33
- package/dist/bridge-XM4QLKIX.js +0 -8
- package/dist/build-ZE5IG3V6.js +0 -18
- package/dist/build-disk-GMXDIZU4.js +0 -15
- package/dist/builder-LJ3FSB36.js +0 -14
- package/dist/caller-YLNJJPFU.js +0 -18
- package/dist/chunk-CXFJOX2C.js +0 -144
- package/dist/chunk-FGF52V4V.js +0 -137
- package/dist/chunk-HCVLP7XA.js +0 -53
- package/dist/chunk-KYDEBGJG.js +0 -402
- package/dist/chunk-MESOOLF4.js +0 -45
- package/dist/chunk-OHQMGLJP.js +0 -113
- package/dist/chunk-OUPQTA7N.js +0 -145
- package/dist/chunk-VRMXYQWR.js +0 -74
- package/dist/connect-cmd-THV7XBVP.js +0 -27
- package/dist/docker-5YVUZ3J2.js +0 -14
- package/dist/emit-artifact-cmd-H27MFSKH.js +0 -42
- package/dist/emit-criteria-cmd-IOUVMB2Q.js +0 -33
- package/dist/emit-demo-cmd-WJSS7KU2.js +0 -46
- package/dist/exec-client-FGGPQSYQ.js +0 -9
- package/dist/find-unit-PRZIFBIK.js +0 -19
- package/dist/governing-source-CND5ZZC3.js +0 -39
- package/dist/guest-init-WPUS45IN.js +0 -11
- package/dist/host-checks-S3B7Z4SY.js +0 -78
- package/dist/host-key-O4DFMOSV.js +0 -9
- package/dist/image-tag-WBD57QBN.js +0 -10
- package/dist/init-ILTX4V56.js +0 -78
- package/dist/install-cmd-JKPXIOEY.js +0 -12
- package/dist/layout-2ZMCT2D3.js +0 -11
- package/dist/loop-KDWDOSMQ.js +0 -89
- package/dist/machine-Z6K5XXI6.js +0 -78
- package/dist/pending-D2NNV54J.js +0 -9
- package/dist/pidfile-FLFVRKVW.js +0 -10
- package/dist/record-JMZOXD4R.js +0 -9
- package/dist/relay-protocol-5LSWUJCW.js +0 -6
- package/dist/runner-env-W2UMHY7P.js +0 -19
- package/dist/runner-identity-IIY5UJL3.js +0 -14
- package/dist/session-sender-NO4F2IQ5.js +0 -42
- package/dist/settings-XB2HYBKO.js +0 -7
- package/dist/state-UWIM42JH.js +0 -9
- package/dist/update-steps-XGOXDCOS.js +0 -79
- package/dist/{chunk-OLM2TIOW.js → chunk-NFZMENCY.js} +1 -1
|
@@ -1,371 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { TARGET_TUNNEL, TARGET_LEASE, destinationTarget } from './chunk-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { builtInNames, TARGET_TUNNEL, TARGET_LEASE, destinationTarget, builtInDestinations, strippedVariables, builtInEnvironment, managedAgentCredential, agentCredential, destinationPort } from './chunk-DTQPDMHG.js';
|
|
4
|
+
import { defaultAgents } from './chunk-I6U6QPN6.js';
|
|
5
|
+
import { PROVIDERS } from './chunk-LSLK4RS4.js';
|
|
6
|
+
import { existsSync, unlinkSync, chmodSync } from 'fs';
|
|
7
7
|
import { request as request$1, createServer } from 'http';
|
|
8
8
|
import { request } from 'https';
|
|
9
9
|
import { createServer as createServer$1 } from 'net';
|
|
10
|
+
import { join } from 'path';
|
|
10
11
|
|
|
11
12
|
createRequire(import.meta.url);
|
|
12
|
-
var FD_STORE_ENV = "OUTERLAYER_FD_STORE";
|
|
13
|
-
var MIN_SYSTEMD = 254;
|
|
14
|
-
var LISTEN_FDS_START = 3;
|
|
15
|
-
var FD_SLOTS_PER_BUILD = 64;
|
|
16
|
-
function fdName(buildId, socket) {
|
|
17
|
-
return `ol-${buildId}-${socket}`;
|
|
18
|
-
}
|
|
19
|
-
function listenFdOf(server) {
|
|
20
|
-
const handle = server._handle;
|
|
21
|
-
return typeof handle?.fd === "number" && handle.fd >= 0 ? handle.fd : void 0;
|
|
22
|
-
}
|
|
23
|
-
function parseListenFds(env, pid) {
|
|
24
|
-
const found = /* @__PURE__ */ new Map();
|
|
25
|
-
if (env.LISTEN_PID !== String(pid)) return found;
|
|
26
|
-
const count = Number(env.LISTEN_FDS);
|
|
27
|
-
if (!Number.isInteger(count) || count <= 0) return found;
|
|
28
|
-
const names = (env.LISTEN_FDNAMES ?? "").split(":");
|
|
29
|
-
for (let index = 0; index < count; index++) {
|
|
30
|
-
const name = names[index];
|
|
31
|
-
if (name !== void 0 && name !== "" && name !== "stored") found.set(name, LISTEN_FDS_START + index);
|
|
32
|
-
}
|
|
33
|
-
return found;
|
|
34
|
-
}
|
|
35
|
-
function listenOnFd(server, fd) {
|
|
36
|
-
return new Promise((resolve, reject) => {
|
|
37
|
-
server.once("error", reject);
|
|
38
|
-
server.listen({ fd }, () => {
|
|
39
|
-
server.off("error", reject);
|
|
40
|
-
resolve();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function run(spawnFn, command, args, fd) {
|
|
45
|
-
return new Promise((resolve) => {
|
|
46
|
-
let stdout = "";
|
|
47
|
-
let stderr = "";
|
|
48
|
-
let child;
|
|
49
|
-
try {
|
|
50
|
-
child = spawnFn(command, args, { stdio: ["ignore", "pipe", "pipe", ...fd === void 0 ? [] : [fd]] });
|
|
51
|
-
} catch (err) {
|
|
52
|
-
resolve({ status: null, stdout, stderr: err instanceof Error ? err.message : String(err) });
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
child.stdout?.on("data", (chunk) => stdout += chunk.toString("utf8"));
|
|
56
|
-
child.stderr?.on("data", (chunk) => stderr += chunk.toString("utf8"));
|
|
57
|
-
child.on("error", (err) => resolve({ status: null, stdout, stderr: err.message }));
|
|
58
|
-
child.on("close", (status) => resolve({ status, stdout, stderr }));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function systemdVersion(ran) {
|
|
62
|
-
const match = /^systemd (\d+)/.exec(ran.stdout);
|
|
63
|
-
return ran.status === 0 && match !== null ? Number(match[1]) : void 0;
|
|
64
|
-
}
|
|
65
|
-
function realFdStorePort(options = {}) {
|
|
66
|
-
const env = options.env ?? process.env;
|
|
67
|
-
const pid = options.pid ?? process.pid;
|
|
68
|
-
const command = options.command ?? "systemd-notify";
|
|
69
|
-
const spawnFn = options.spawn ?? spawn;
|
|
70
|
-
let inherited;
|
|
71
|
-
let held2;
|
|
72
|
-
let version;
|
|
73
|
-
const inheritedNames = () => inherited ??= parseListenFds(env, pid);
|
|
74
|
-
const heldNames = () => held2 ??= new Set(inheritedNames().keys());
|
|
75
|
-
return {
|
|
76
|
-
async status() {
|
|
77
|
-
if (env.NOTIFY_SOCKET === void 0 || env.NOTIFY_SOCKET === "") return { ok: false, reason: "NOTIFY_SOCKET is not set, so this runner was not started by a service that accepts descriptors" };
|
|
78
|
-
const size = Number(env[FD_STORE_ENV]);
|
|
79
|
-
if (!Number.isInteger(size) || size <= 0) return { ok: false, reason: `${FD_STORE_ENV} is not set, so the service's unit keeps no descriptor store` };
|
|
80
|
-
version ??= run(spawnFn, command, ["--version"]).then(systemdVersion);
|
|
81
|
-
const found = await version;
|
|
82
|
-
if (found === void 0) return { ok: false, reason: `${command} could not be run, so no descriptor can be stored` };
|
|
83
|
-
if (found < MIN_SYSTEMD) return { ok: false, reason: `systemd ${found} cannot store a descriptor sent from a child process: it needs systemd ${MIN_SYSTEMD} or later` };
|
|
84
|
-
return { ok: true };
|
|
85
|
-
},
|
|
86
|
-
async push(name, server) {
|
|
87
|
-
const fd = listenFdOf(server);
|
|
88
|
-
if (fd === void 0) throw new Error(`${name} has no descriptor to store`);
|
|
89
|
-
const size = Number(env[FD_STORE_ENV]);
|
|
90
|
-
const names = heldNames();
|
|
91
|
-
if (Number.isInteger(size) && names.size >= size) {
|
|
92
|
-
throw new Error(`the descriptor store is full: it holds ${names.size} descriptors, the size the service's unit sets (FileDescriptorStoreMax=${size})`);
|
|
93
|
-
}
|
|
94
|
-
const ran = await run(spawnFn, command, [`--fd=${LISTEN_FDS_START}`, `--fdname=${name}`, "FDSTORE=1"], fd);
|
|
95
|
-
if (ran.status !== 0) throw new Error(`storing ${name} failed${ran.status === null ? "" : ` (exit ${ran.status})`}: ${ran.stderr.trim().split("\n")[0] ?? ""}`);
|
|
96
|
-
names.add(name);
|
|
97
|
-
},
|
|
98
|
-
async remove(name) {
|
|
99
|
-
const ran = await run(spawnFn, command, ["FDSTOREREMOVE=1", `FDNAME=${name}`]);
|
|
100
|
-
if (ran.status !== 0) throw new Error(`removing ${name} from the store failed${ran.status === null ? "" : ` (exit ${ran.status})`}: ${ran.stderr.trim().split("\n")[0] ?? ""}`);
|
|
101
|
-
heldNames().delete(name);
|
|
102
|
-
},
|
|
103
|
-
inherited() {
|
|
104
|
-
return inheritedNames();
|
|
105
|
-
},
|
|
106
|
-
listenOn: listenOnFd
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/runner/service/slice.ts
|
|
111
|
-
var BUILD_SLICE_MEMORY_ENV = "OUTERLAYER_BUILD_SLICE_MEMORY";
|
|
112
|
-
|
|
113
|
-
// src/runner/service/inspect.ts
|
|
114
|
-
var CREDENTIAL_VARIABLES = ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"];
|
|
115
|
-
function property(shown, name) {
|
|
116
|
-
return new RegExp(`^${name}=(.*)$`, "m").exec(shown)?.[1]?.trim();
|
|
117
|
-
}
|
|
118
|
-
function holdsGroup(status, gid) {
|
|
119
|
-
const primary = /^Gid:\s+(\d+)/m.exec(status)?.[1];
|
|
120
|
-
const supplementary = /^Groups:[ \t]*(.*)$/m.exec(status)?.[1]?.trim().split(/\s+/).filter((g) => g !== "") ?? [];
|
|
121
|
-
return [primary, ...supplementary].some((g) => g !== void 0 && Number(g) === gid);
|
|
122
|
-
}
|
|
123
|
-
function parseRunnerEnv(text) {
|
|
124
|
-
const env = {};
|
|
125
|
-
for (const line of text.split("\n")) {
|
|
126
|
-
const match = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.exec(line);
|
|
127
|
-
if (match === null) continue;
|
|
128
|
-
env[match[1]] = match[2].trim().replace(/^(["'])(.*)\1$/, "$2");
|
|
129
|
-
}
|
|
130
|
-
return env;
|
|
131
|
-
}
|
|
132
|
-
function credentialNames(env) {
|
|
133
|
-
const set = parseRunnerEnv(env ?? "");
|
|
134
|
-
return CREDENTIAL_VARIABLES.filter((name) => (set[name] ?? "").trim() !== "");
|
|
135
|
-
}
|
|
136
|
-
function startedWithStore(environ) {
|
|
137
|
-
const vars = new Map(environ.split("\0").map((entry) => [entry.slice(0, entry.indexOf("=")), entry.slice(entry.indexOf("=") + 1)]));
|
|
138
|
-
return (vars.get("NOTIFY_SOCKET") ?? "") !== "" && Number(vars.get(FD_STORE_ENV)) > 0;
|
|
139
|
-
}
|
|
140
|
-
function inspectService(unit, configDir, probes) {
|
|
141
|
-
const shown = probes.show(unit);
|
|
142
|
-
if (shown === void 0 || property(shown, "LoadState") !== "loaded") return void 0;
|
|
143
|
-
const pid = Number(property(shown, "MainPID") ?? "0");
|
|
144
|
-
const mainPid = Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
145
|
-
const delegate = property(shown, "Delegate");
|
|
146
|
-
const storeMax = Number(property(shown, "FileDescriptorStoreMax"));
|
|
147
|
-
const status = mainPid === void 0 ? void 0 : probes.readFile(`/proc/${mainPid}/status`);
|
|
148
|
-
const environ = mainPid === void 0 ? void 0 : probes.readFile(`/proc/${mainPid}/environ`);
|
|
149
|
-
const systemd = Number(/^systemd (\d+)/.exec(probes.systemctlVersion?.() ?? "")?.[1]);
|
|
150
|
-
const kvm = probes.kvmGid();
|
|
151
|
-
const sliceMemory = Number(new RegExp(`(?:^|\\s)${BUILD_SLICE_MEMORY_ENV}=(\\d+)(?:\\s|$)`).exec(property(shown, "Environment") ?? "")?.[1]);
|
|
152
|
-
return {
|
|
153
|
-
unit,
|
|
154
|
-
...Number.isSafeInteger(sliceMemory) && sliceMemory > 0 ? { buildSliceMemory: sliceMemory } : {},
|
|
155
|
-
mainPid,
|
|
156
|
-
delegate: delegate === void 0 ? void 0 : delegate !== "no",
|
|
157
|
-
...Number.isInteger(storeMax) && property(shown, "FileDescriptorStoreMax") !== void 0 ? { fdStoreMax: storeMax } : {},
|
|
158
|
-
hasKvmGroup: status === void 0 || kvm === void 0 ? void 0 : holdsGroup(status, kvm),
|
|
159
|
-
...environ === void 0 ? {} : { startedWithStore: startedWithStore(environ) },
|
|
160
|
-
...systemd > 0 ? { systemdVersion: systemd } : {},
|
|
161
|
-
// `claude.env` first, where the service loads the credential from; `runner.env` holds one that was never moved.
|
|
162
|
-
credentialVariables: [.../* @__PURE__ */ new Set([...credentialNames(probes.readFile(join(configDir, "claude.env"))), ...credentialNames(probes.readFile(join(configDir, "runner.env")))])]
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function realInspectProbes() {
|
|
166
|
-
return {
|
|
167
|
-
show: (unit) => {
|
|
168
|
-
const result = spawnSync("systemctl", ["show", "--property=LoadState,MainPID,Delegate,FileDescriptorStoreMax,Environment", unit], { encoding: "utf8", timeout: 1e4 });
|
|
169
|
-
return result.status === 0 ? result.stdout : void 0;
|
|
170
|
-
},
|
|
171
|
-
readFile: (path) => {
|
|
172
|
-
try {
|
|
173
|
-
return readFileSync(path, "utf8");
|
|
174
|
-
} catch {
|
|
175
|
-
return void 0;
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
systemctlVersion: () => {
|
|
179
|
-
const result = spawnSync("systemctl", ["--version"], { encoding: "utf8", timeout: 1e4 });
|
|
180
|
-
return result.status === 0 ? result.stdout : void 0;
|
|
181
|
-
},
|
|
182
|
-
kvmGid: () => {
|
|
183
|
-
try {
|
|
184
|
-
return statSync("/dev/kvm").gid;
|
|
185
|
-
} catch {
|
|
186
|
-
return void 0;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
var CLAUDE_CREDENTIAL_ID = "claude";
|
|
192
|
-
var CLAUDE_ENV_FILE = "claude.env";
|
|
193
|
-
function claudeEnvPath(configPath) {
|
|
194
|
-
return join(dirname(configPath), CLAUDE_ENV_FILE);
|
|
195
|
-
}
|
|
196
|
-
var CLAUDE_CREDENTIAL_VARIABLES = ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"];
|
|
197
|
-
var FORWARDED_CLAUDE_CREDENTIAL_VARIABLES = ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"];
|
|
198
|
-
var FORWARDED = FORWARDED_CLAUDE_CREDENTIAL_VARIABLES;
|
|
199
|
-
function firstOf(values, source) {
|
|
200
|
-
for (const variable of FORWARDED) {
|
|
201
|
-
const value = values[variable];
|
|
202
|
-
if (value !== void 0 && value !== "") return { variable, value, source };
|
|
203
|
-
}
|
|
204
|
-
return void 0;
|
|
205
|
-
}
|
|
206
|
-
function readClaudeCredential(env) {
|
|
207
|
-
const fromEnvironment = firstOf(env, "environment");
|
|
208
|
-
if (fromEnvironment !== void 0) return fromEnvironment;
|
|
209
|
-
const directory = env.CREDENTIALS_DIRECTORY;
|
|
210
|
-
if (directory === void 0 || directory === "") return void 0;
|
|
211
|
-
const path = join(directory, CLAUDE_CREDENTIAL_ID);
|
|
212
|
-
try {
|
|
213
|
-
const text = readFileSync(path, "utf8");
|
|
214
|
-
const found = firstOf(parseRunnerEnv(text), "credentials-directory");
|
|
215
|
-
if (found === void 0 && text.trim() !== "") complain(path, "it sets neither CLAUDE_CODE_OAUTH_TOKEN nor ANTHROPIC_API_KEY, each as NAME=value");
|
|
216
|
-
return found;
|
|
217
|
-
} catch (err) {
|
|
218
|
-
if (err.code !== "ENOENT") complain(path, `it could not be read (${err instanceof Error ? err.message : String(err)})`);
|
|
219
|
-
return void 0;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
function claudeCredentialVariablesSet(env, options = {}) {
|
|
223
|
-
const found = /* @__PURE__ */ new Set();
|
|
224
|
-
const add = (values) => {
|
|
225
|
-
for (const variable of FORWARDED) if ((values[variable] ?? "") !== "") found.add(variable);
|
|
226
|
-
};
|
|
227
|
-
add(env);
|
|
228
|
-
const directory = env.CREDENTIALS_DIRECTORY;
|
|
229
|
-
if (directory) {
|
|
230
|
-
try {
|
|
231
|
-
add(parseRunnerEnv(readFileSync(join(directory, CLAUDE_CREDENTIAL_ID), "utf8")));
|
|
232
|
-
} catch {
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (options.ignoreHeld !== true && held !== void 0) found.add(held.variable);
|
|
236
|
-
return found;
|
|
237
|
-
}
|
|
238
|
-
var complained = /* @__PURE__ */ new Set();
|
|
239
|
-
function complain(path, reason) {
|
|
240
|
-
if (complained.has(path)) return;
|
|
241
|
-
complained.add(path);
|
|
242
|
-
process.stderr.write(`the Claude credential file ${path} holds no usable credential: ${reason}
|
|
243
|
-
`);
|
|
244
|
-
}
|
|
245
|
-
var held;
|
|
246
|
-
var removedValues = /* @__PURE__ */ new Set();
|
|
247
|
-
function holdClaudeCredential(env = process.env) {
|
|
248
|
-
held ??= readClaudeCredential(env);
|
|
249
|
-
for (const name of CLAUDE_CREDENTIAL_VARIABLES) {
|
|
250
|
-
const value = env[name];
|
|
251
|
-
if (value !== void 0 && value !== "") removedValues.add(value);
|
|
252
|
-
delete env[name];
|
|
253
|
-
}
|
|
254
|
-
return held;
|
|
255
|
-
}
|
|
256
|
-
function takeClaudeCredential(env, hooks) {
|
|
257
|
-
return /^builtin:(container|process|vm)$/.test(hooks.provision) ? holdClaudeCredential(env) : void 0;
|
|
258
|
-
}
|
|
259
|
-
function removedClaudeCredentialValues() {
|
|
260
|
-
return [...removedValues];
|
|
261
|
-
}
|
|
262
|
-
function heldClaudeCredential() {
|
|
263
|
-
return held;
|
|
264
|
-
}
|
|
265
|
-
function currentClaudeCredential(env) {
|
|
266
|
-
return held ?? readClaudeCredential(env);
|
|
267
|
-
}
|
|
268
|
-
var SETS = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=/;
|
|
269
|
-
function credentialLineIn(text) {
|
|
270
|
-
const set = parseRunnerEnv(text);
|
|
271
|
-
const lines = text.split("\n");
|
|
272
|
-
for (const variable of FORWARDED) {
|
|
273
|
-
if ((set[variable] ?? "") === "") continue;
|
|
274
|
-
const line = lines.find((candidate) => (parseRunnerEnv(candidate)[variable] ?? "") !== "");
|
|
275
|
-
return line.replace(/^\s*(?:export\s+)?/, "").trimEnd();
|
|
276
|
-
}
|
|
277
|
-
return void 0;
|
|
278
|
-
}
|
|
279
|
-
function withoutCredentialLines(text) {
|
|
280
|
-
const lines = text.split("\n");
|
|
281
|
-
const kept = lines.filter((line) => !CLAUDE_CREDENTIAL_VARIABLES.includes(SETS.exec(line)?.[1] ?? ""));
|
|
282
|
-
if (kept.length === lines.length) return void 0;
|
|
283
|
-
while (kept[kept.length - 1] === "") kept.pop();
|
|
284
|
-
return kept.length === 0 ? "" : `${kept.join("\n")}
|
|
285
|
-
`;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// src/runner/builtin-destinations.ts
|
|
289
|
-
var GATEWAY_DESTINATION = "gateway";
|
|
290
|
-
var CLAUDE_DESTINATION = "claude";
|
|
291
|
-
var BUILT_IN_NAMES = [GATEWAY_DESTINATION, CLAUDE_DESTINATION];
|
|
292
|
-
var GATEWAY_PORT = 3126;
|
|
293
|
-
var CLAUDE_PORT = 3127;
|
|
294
|
-
var GATEWAY_SOCKET = "gateway.sock";
|
|
295
|
-
var CLAUDE_SOCKET = "claude.sock";
|
|
296
|
-
var CLAUDE_UPSTREAM = "https://api.anthropic.com/";
|
|
297
|
-
var AGENT_CREDENTIAL_MISSING = "agent_credential_missing";
|
|
298
|
-
var OAUTH_PLACEHOLDER = "sk-ant-oat01-placeholder-not-a-real-token";
|
|
299
|
-
var API_KEY_PLACEHOLDER = "sk-ant-api03-placeholder-not-a-real-key";
|
|
300
|
-
var ITEM_KEY_PLACEHOLDER = "olitem_placeholder-not-a-real-key";
|
|
301
|
-
var ITEM_KEY_VARIABLE = "OUTERLAYER_ITEM_KEY";
|
|
302
|
-
function claudeCredential(hostEnv, options = {}) {
|
|
303
|
-
const credential = options.ignoreHeld === true ? readClaudeCredential(hostEnv) : currentClaudeCredential(hostEnv);
|
|
304
|
-
if (credential === void 0) return void 0;
|
|
305
|
-
return { variable: credential.variable, placeholder: credential.variable === "CLAUDE_CODE_OAUTH_TOKEN" ? OAUTH_PLACEHOLDER : API_KEY_PLACEHOLDER };
|
|
306
|
-
}
|
|
307
|
-
function managedClaudeCredential() {
|
|
308
|
-
return { variable: "ANTHROPIC_API_KEY", placeholder: API_KEY_PLACEHOLDER };
|
|
309
|
-
}
|
|
310
|
-
function gatewayUpstream(gatewayUrl) {
|
|
311
|
-
return `${new URL(gatewayUrl).origin}/`;
|
|
312
|
-
}
|
|
313
|
-
function forwardedEnvironment(hostEnv) {
|
|
314
|
-
const env = {};
|
|
315
|
-
for (const name of ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"]) {
|
|
316
|
-
Object.defineProperty(env, name, {
|
|
317
|
-
enumerable: true,
|
|
318
|
-
get: () => {
|
|
319
|
-
const current = currentClaudeCredential(hostEnv);
|
|
320
|
-
return current !== void 0 && current.variable === name ? current.value : hostEnv[name];
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
return env;
|
|
325
|
-
}
|
|
326
|
-
function builtInDestinations(input) {
|
|
327
|
-
const managedKey = input.claudeApiKey !== void 0 && input.claudeApiKey !== "";
|
|
328
|
-
const credential = managedKey ? void 0 : claudeCredential(input.hostEnv);
|
|
329
|
-
const apiKeyMode = managedKey || credential?.variable === "ANTHROPIC_API_KEY";
|
|
330
|
-
return [
|
|
331
|
-
{
|
|
332
|
-
destination: {
|
|
333
|
-
name: GATEWAY_DESTINATION,
|
|
334
|
-
upstream: gatewayUpstream(input.gatewayUrl),
|
|
335
|
-
header: { name: "Authorization", value: `Bearer \${${ITEM_KEY_VARIABLE}}`, variables: [ITEM_KEY_VARIABLE] },
|
|
336
|
-
env: {}
|
|
337
|
-
},
|
|
338
|
-
hostEnv: input.itemKey === void 0 ? {} : { [ITEM_KEY_VARIABLE]: input.itemKey },
|
|
339
|
-
drop: [],
|
|
340
|
-
socket: GATEWAY_SOCKET
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
destination: {
|
|
344
|
-
name: CLAUDE_DESTINATION,
|
|
345
|
-
upstream: input.claudeUpstream ?? CLAUDE_UPSTREAM,
|
|
346
|
-
header: apiKeyMode ? { name: "x-api-key", value: "${ANTHROPIC_API_KEY}", variables: ["ANTHROPIC_API_KEY"] } : { name: "Authorization", value: "Bearer ${CLAUDE_CODE_OAUTH_TOKEN}", variables: ["CLAUDE_CODE_OAUTH_TOKEN"] },
|
|
347
|
-
env: {}
|
|
348
|
-
},
|
|
349
|
-
hostEnv: managedKey ? { ANTHROPIC_API_KEY: input.claudeApiKey } : forwardedEnvironment(input.hostEnv),
|
|
350
|
-
// A build's own key in either header would sit beside the runner's, and the upstream takes one of them.
|
|
351
|
-
drop: ["x-api-key", "authorization"],
|
|
352
|
-
socket: CLAUDE_SOCKET
|
|
353
|
-
}
|
|
354
|
-
];
|
|
355
|
-
}
|
|
356
|
-
function builtInEnvironment(localFor, credential) {
|
|
357
|
-
return {
|
|
358
|
-
OUTERLAYER_URL: localFor(GATEWAY_DESTINATION),
|
|
359
|
-
OUTERLAYER_API_KEY: ITEM_KEY_PLACEHOLDER,
|
|
360
|
-
ANTHROPIC_BASE_URL: localFor(CLAUDE_DESTINATION),
|
|
361
|
-
...credential === void 0 ? {} : { [credential.variable]: credential.placeholder },
|
|
362
|
-
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1"
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// src/runner/destinations.ts
|
|
367
13
|
var MAX_RELEASED_DESTINATIONS = 20;
|
|
368
|
-
|
|
14
|
+
function maxDestinations(agents = defaultAgents(), providers = PROVIDERS) {
|
|
15
|
+
return MAX_RELEASED_DESTINATIONS - builtInNames(agents, providers).length;
|
|
16
|
+
}
|
|
369
17
|
var DESTINATION_BASE_PORT = 3129;
|
|
370
18
|
var DESTINATION_NAME = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
371
19
|
var VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
|
|
@@ -377,12 +25,14 @@ var UPSTREAM_IDLE_MS = 6e5;
|
|
|
377
25
|
function headerVariables(destinations) {
|
|
378
26
|
return [...new Set((destinations ?? []).flatMap((d) => d.header.variables))];
|
|
379
27
|
}
|
|
380
|
-
function resolveDestinations(given, variables, isReserved, fail) {
|
|
28
|
+
function resolveDestinations(given, variables, isReserved, fail, agents = defaultAgents(), providers = PROVIDERS) {
|
|
381
29
|
if (!Array.isArray(given)) fail("runner.build.destinations", "must be a list of destinations");
|
|
382
|
-
|
|
30
|
+
const builtIns = builtInNames(agents, providers);
|
|
31
|
+
const most = maxDestinations(agents, providers);
|
|
32
|
+
if (given.length > most) {
|
|
383
33
|
fail(
|
|
384
34
|
"runner.build.destinations",
|
|
385
|
-
`lists ${given.length} destinations; a release records at most ${MAX_RELEASED_DESTINATIONS}, and ${
|
|
35
|
+
`lists ${given.length} destinations; a release records at most ${MAX_RELEASED_DESTINATIONS}, and ${builtIns.length} of those are the built-in ${builtIns.join(" and ")} destinations, so a host lists at most ${most}`
|
|
386
36
|
);
|
|
387
37
|
}
|
|
388
38
|
const resolved = [];
|
|
@@ -401,7 +51,7 @@ function resolveDestinations(given, variables, isReserved, fail) {
|
|
|
401
51
|
if (typeof name !== "string" || !DESTINATION_NAME.test(name)) {
|
|
402
52
|
fail(`${at}.name`, "must be 1 to 63 lower-case letters, digits or hyphens, starting with a letter or digit");
|
|
403
53
|
}
|
|
404
|
-
if (
|
|
54
|
+
if (builtIns.includes(name)) fail(`${at}.name`, `is ${name}, a destination the runner serves itself`);
|
|
405
55
|
if (names.has(name)) fail(`${at}.name`, `repeats the destination ${name}`);
|
|
406
56
|
names.add(name);
|
|
407
57
|
const upstream = parseUpstream(record.upstream, `${at}.upstream`, fail);
|
|
@@ -655,7 +305,7 @@ async function startBuildServices(input) {
|
|
|
655
305
|
targets.set(destinationTarget(index), (stream) => server.acceptStream(stream));
|
|
656
306
|
if (server.port !== void 0) destinationPorts.push(server.port);
|
|
657
307
|
}
|
|
658
|
-
const builtIns = input.builtIns === void 0 ? [] : builtInDestinations({
|
|
308
|
+
const builtIns = input.builtIns === void 0 ? [] : builtInDestinations({ ...input.builtIns, hostEnv: input.hostEnv }, input.builtIns.agents, input.builtIns.providers);
|
|
659
309
|
for (const builtIn of builtIns) {
|
|
660
310
|
const server = await startDestination({
|
|
661
311
|
destination: builtIn.destination,
|
|
@@ -863,8 +513,8 @@ function runnerLiterals(repository, repositories = [], unpinnedRuntimes, missing
|
|
|
863
513
|
...missingSetupScripts === void 0 || missingSetupScripts.length === 0 ? {} : { OUTERLAYER_MISSING_SETUP_SCRIPTS: JSON.stringify(missingSetupScripts) }
|
|
864
514
|
};
|
|
865
515
|
}
|
|
866
|
-
function containerBuiltInAddress(name) {
|
|
867
|
-
return `http://127.0.0.1:${name
|
|
516
|
+
function containerBuiltInAddress(name, agents) {
|
|
517
|
+
return `http://127.0.0.1:${destinationPort(name, agents)}`;
|
|
868
518
|
}
|
|
869
519
|
function reservedNames() {
|
|
870
520
|
return /* @__PURE__ */ new Set([
|
|
@@ -881,8 +531,8 @@ function isReservedVariable(name) {
|
|
|
881
531
|
function isRefusedInConfig(name) {
|
|
882
532
|
return isReservedVariable(name) && !githubVariables().has(name);
|
|
883
533
|
}
|
|
884
|
-
function isMiseVariableAllowed(name) {
|
|
885
|
-
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) && !isReservedVariable(name) && !
|
|
534
|
+
function isMiseVariableAllowed(name, agents) {
|
|
535
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) && !isReservedVariable(name) && !strippedVariables(agents).includes(name);
|
|
886
536
|
}
|
|
887
537
|
function withMiseVariables(env, variables) {
|
|
888
538
|
if (variables === void 0) return env;
|
|
@@ -906,6 +556,7 @@ function buildEnvironment(input) {
|
|
|
906
556
|
if (!isReservedVariable(name) && !(name in authored)) recipe[name] = value;
|
|
907
557
|
}
|
|
908
558
|
const builtIns = input.builtIns === true;
|
|
559
|
+
const credentialVariables = strippedVariables(input.agents);
|
|
909
560
|
const passed = {
|
|
910
561
|
...builtIns ? {} : { OUTERLAYER_URL: input.config.url },
|
|
911
562
|
...builtIns || input.itemKey === void 0 ? {} : { OUTERLAYER_API_KEY: input.itemKey },
|
|
@@ -918,7 +569,7 @@ function buildEnvironment(input) {
|
|
|
918
569
|
if (input.factoryVariables !== void 0) {
|
|
919
570
|
for (const { name, value } of input.factoryVariables) {
|
|
920
571
|
if (isReservedVariable(name) || name in authored) continue;
|
|
921
|
-
if (builtIns &&
|
|
572
|
+
if (builtIns && credentialVariables.includes(name)) continue;
|
|
922
573
|
passed[name] = value;
|
|
923
574
|
variables.push(name);
|
|
924
575
|
}
|
|
@@ -931,13 +582,13 @@ function buildEnvironment(input) {
|
|
|
931
582
|
}
|
|
932
583
|
const value = input.hostEnv[name];
|
|
933
584
|
if (value === void 0 || isReservedVariable(name) || name in authored) continue;
|
|
934
|
-
if (builtIns &&
|
|
585
|
+
if (builtIns && credentialVariables.includes(name)) continue;
|
|
935
586
|
passed[name] = value;
|
|
936
587
|
variables.push(name);
|
|
937
588
|
}
|
|
938
589
|
}
|
|
939
590
|
const destinations = destinationEnvironment(input.config.build?.destinations, containerLocalAddress);
|
|
940
|
-
const builtInLiterals = builtIns ? builtInEnvironment(containerBuiltInAddress, input.config.managed === true ?
|
|
591
|
+
const builtInLiterals = builtIns ? builtInEnvironment((name) => containerBuiltInAddress(name, input.agents), input.config.managed === true ? managedAgentCredential(input.agents) : agentCredential(input.hostEnv, {}, input.agents), input.agents) : {};
|
|
941
592
|
const hooksPath = input.identity?.hooksPath;
|
|
942
593
|
const hooks = {};
|
|
943
594
|
if (hooksPath !== void 0) {
|
|
@@ -978,7 +629,7 @@ function checkEnvironment(input) {
|
|
|
978
629
|
builtIns: false,
|
|
979
630
|
factoryVariables: input.factoryVariables
|
|
980
631
|
});
|
|
981
|
-
const withheld = /* @__PURE__ */ new Set(["OUTERLAYER_URL", "OUTERLAYER_API_KEY", ...
|
|
632
|
+
const withheld = /* @__PURE__ */ new Set(["OUTERLAYER_URL", "OUTERLAYER_API_KEY", ...strippedVariables()]);
|
|
982
633
|
const literals = { OUTERLAYER_EVAL_INPUT: EVAL_INPUT_DIR, OUTERLAYER_CHECK_ITEMS: CHECK_ITEMS_FILE };
|
|
983
634
|
for (const [name, value] of Object.entries(env.literals)) if (!withheld.has(name)) literals[name] = value;
|
|
984
635
|
const passed = {};
|
|
@@ -1026,4 +677,4 @@ function routesOf(counts) {
|
|
|
1026
677
|
return routes.length === 0 ? {} : { routes };
|
|
1027
678
|
}
|
|
1028
679
|
|
|
1029
|
-
export {
|
|
680
|
+
export { BUILD_HOME, CHECKOUT_DIR, CHECK_ITEMS_FILE, DESTINATION_BASE_PORT, EVAL_INPUT_DIR, JOB_MOUNT, PROXY_WARNING_FLAG, RELAY_PORT, SCRUB_ENV_VARIABLE, authorEnvironment, buildEnvironment, checkEnvironment, checkoutPath, commitIdentityRecord, containerLocalAddress, destinationEnvironment, headerVariables, isMiseVariableAllowed, isRefusedInConfig, isReservedVariable, lifecycleWorkdir, parseClaimIdentity, parseClaimedRepositories, parseIsolation, parseUnreachable, primaryOf, proxyEnvironment, repositoriesOf, repositoryPath, resolveDestinations, sharedUserEnvironment, startBuildServices, tokenHeader, withGitConfig, withHooksPath, withMiseVariables, withProxyWarningHidden, withTokenHeader, withTunnelRecord };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { isSameProcess } from './chunk-JBJTC3UU.js';
|
|
4
|
-
import { RUNNER_DIR_MODE, RUNNER_FILE_MODE } from './chunk-
|
|
4
|
+
import { RUNNER_DIR_MODE, RUNNER_FILE_MODE } from './chunk-DTCTXDJP.js';
|
|
5
5
|
import { existsSync, readFileSync, mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
6
6
|
import { dirname } from 'path';
|
|
7
7
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { scrubReason, stripTerminalControls } from './chunk-
|
|
4
|
-
import { checkFit, RUNNER_RESERVE_BYTES } from './chunk-
|
|
5
|
-
import { RunnerAlreadyRunningError, readPidFile } from './chunk-
|
|
3
|
+
import { scrubReason, stripTerminalControls } from './chunk-XEWG4AB2.js';
|
|
4
|
+
import { checkFit, RUNNER_RESERVE_BYTES } from './chunk-CSBW4LGL.js';
|
|
5
|
+
import { RunnerAlreadyRunningError, readPidFile } from './chunk-D4VGJQY7.js';
|
|
6
6
|
import { isSameProcess } from './chunk-JBJTC3UU.js';
|
|
7
|
-
import { keyRunnerFactory } from './chunk-
|
|
8
|
-
import { isSignatureRefusal, postJson } from './chunk-
|
|
9
|
-
import { signerFor } from './chunk-
|
|
10
|
-
import { pidFilePath } from './chunk-
|
|
7
|
+
import { keyRunnerFactory } from './chunk-WACPWYMH.js';
|
|
8
|
+
import { isSignatureRefusal, postJson } from './chunk-AQE6E54X.js';
|
|
9
|
+
import { signerFor } from './chunk-IKFAJTLZ.js';
|
|
10
|
+
import { pidFilePath } from './chunk-DTCTXDJP.js';
|
|
11
11
|
import { readFileSync } from 'fs';
|
|
12
12
|
|
|
13
13
|
createRequire(import.meta.url);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE } from './chunk-
|
|
4
|
-
import {
|
|
3
|
+
import { normalizePath, CONTEXT_PIN_FILENAME, contextAgents, defaultAgents, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, legacyAgent, legacySubcommand } from './chunk-I6U6QPN6.js';
|
|
4
|
+
import { LEGACY_AGENT } from './chunk-LSLK4RS4.js';
|
|
5
5
|
import { existsSync, readdirSync, readFileSync, mkdirSync, writeFileSync, lstatSync, readlinkSync, symlinkSync, rmdirSync } from 'fs';
|
|
6
|
-
import { relative, sep, join } from 'path';
|
|
6
|
+
import { relative, sep, join, posix } from 'path';
|
|
7
7
|
|
|
8
8
|
createRequire(import.meta.url);
|
|
9
9
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
@@ -41,8 +41,15 @@ function walk(dir, repoRoot, insideOuterlayer, out) {
|
|
|
41
41
|
// src/layout.ts
|
|
42
42
|
var AGENTS_MD_LAYOUT = 2;
|
|
43
43
|
var FIRST_VERSION_READING_AGENTS_SKILLS = "0.21.0";
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
function linkTargetFor(folder) {
|
|
45
|
+
return posix.relative(posix.dirname(folder), AGENTS_SKILLS_BASE);
|
|
46
|
+
}
|
|
47
|
+
function mcpFiles(agents = defaultAgents()) {
|
|
48
|
+
return [...new Set(contextAgents(agents).map((agent) => agent.context.mcp.file))];
|
|
49
|
+
}
|
|
50
|
+
function skillLinkFolders(agents = defaultAgents()) {
|
|
51
|
+
return contextAgents(agents).flatMap((agent) => agent.descriptor.context.repoSkillFolders);
|
|
52
|
+
}
|
|
46
53
|
var CONFIG_PATH = ".outerlayer/config.json";
|
|
47
54
|
function readConfigObject(repoRoot) {
|
|
48
55
|
try {
|
|
@@ -97,8 +104,9 @@ function filesBelow(repoRoot, rel) {
|
|
|
97
104
|
}
|
|
98
105
|
return out.sort();
|
|
99
106
|
}
|
|
100
|
-
function
|
|
101
|
-
const abs = join(repoRoot,
|
|
107
|
+
function linkFolder(repoRoot, folder) {
|
|
108
|
+
const abs = join(repoRoot, folder);
|
|
109
|
+
const target = linkTargetFor(folder);
|
|
102
110
|
let stat;
|
|
103
111
|
try {
|
|
104
112
|
stat = lstatSync(abs);
|
|
@@ -107,45 +115,63 @@ function linkClaudeSkills(repoRoot) {
|
|
|
107
115
|
}
|
|
108
116
|
if (stat?.isSymbolicLink()) {
|
|
109
117
|
try {
|
|
110
|
-
return readlinkSync(abs) ===
|
|
118
|
+
return readlinkSync(abs) === target ? { status: "present" } : { status: "elsewhere" };
|
|
111
119
|
} catch {
|
|
112
120
|
return { status: "elsewhere" };
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
if (stat !== void 0) {
|
|
116
|
-
if (!stat.isDirectory()) return { status: "blocked", blocking: [
|
|
117
|
-
const files = filesBelow(repoRoot,
|
|
124
|
+
if (!stat.isDirectory()) return { status: "blocked", blocking: [folder] };
|
|
125
|
+
const files = filesBelow(repoRoot, folder);
|
|
118
126
|
if (files.length > 0) return { status: "blocked", blocking: files };
|
|
119
127
|
removeEmptyTree(abs);
|
|
120
128
|
}
|
|
121
129
|
try {
|
|
122
|
-
mkdirSync(join(repoRoot,
|
|
123
|
-
symlinkSync(
|
|
130
|
+
mkdirSync(join(repoRoot, posix.dirname(folder)), { recursive: true });
|
|
131
|
+
symlinkSync(target, abs, "dir");
|
|
124
132
|
return { status: "linked" };
|
|
125
133
|
} catch (err) {
|
|
126
134
|
return { status: "failed", reason: err instanceof Error ? err.message : String(err) };
|
|
127
135
|
}
|
|
128
136
|
}
|
|
137
|
+
var URGENCY = { failed: 4, blocked: 3, elsewhere: 2, linked: 1, present: 0 };
|
|
138
|
+
function linkAgentSkills(repoRoot, agents = defaultAgents()) {
|
|
139
|
+
const outcomes = contextAgents(agents).flatMap(
|
|
140
|
+
(agent) => agent.descriptor.context.repoSkillFolders.map((folder) => {
|
|
141
|
+
const outcome = linkFolder(repoRoot, folder);
|
|
142
|
+
return agent.descriptor.id === LEGACY_AGENT ? outcome : { ...outcome, folder, agent: agent.descriptor.label };
|
|
143
|
+
})
|
|
144
|
+
);
|
|
145
|
+
const first = outcomes.reduce((pick, outcome) => pick === void 0 || URGENCY[outcome.status] > URGENCY[pick.status] ? outcome : pick, void 0);
|
|
146
|
+
if (first === void 0) return { status: "present" };
|
|
147
|
+
const linkedFolders = contextAgents(agents).flatMap((agent) => agent.descriptor.context.repoSkillFolders.map((folder) => ({ folder, id: agent.descriptor.id })));
|
|
148
|
+
if (first.status !== "linked" || linkedFolders.every((entry) => entry.id === LEGACY_AGENT)) return first;
|
|
149
|
+
return { ...first, folders: outcomes.flatMap((outcome, index) => outcome.status === "linked" ? [linkedFolders[index].folder] : []) };
|
|
150
|
+
}
|
|
129
151
|
function removeEmptyTree(abs) {
|
|
130
152
|
for (const entry of readdirSync(abs, { withFileTypes: true })) {
|
|
131
153
|
if (entry.isDirectory()) removeEmptyTree(join(abs, entry.name));
|
|
132
154
|
}
|
|
133
155
|
rmdirSync(abs);
|
|
134
156
|
}
|
|
135
|
-
var
|
|
136
|
-
function describeSkillsLink(outcome) {
|
|
157
|
+
var windowsLinkNote = (agent) => `On Windows, git commits a link only when core.symlinks is true. Without it, git writes a text file and ${agent} finds no skills.`;
|
|
158
|
+
function describeSkillsLink(outcome, agents = defaultAgents()) {
|
|
159
|
+
const fallback = legacyAgent(agents);
|
|
160
|
+
const folder = outcome.folder ?? fallback.descriptor.context.repoSkillFolders[0];
|
|
161
|
+
const agent = outcome.agent ?? fallback.descriptor.label;
|
|
162
|
+
const target = linkTargetFor(folder);
|
|
137
163
|
switch (outcome.status) {
|
|
138
164
|
case "linked":
|
|
139
|
-
return `Linked ${
|
|
165
|
+
return `Linked ${folder} to ${target}, so ${agent} finds the skills. ${windowsLinkNote(agent)}`;
|
|
140
166
|
case "present":
|
|
141
167
|
return "";
|
|
142
168
|
case "blocked":
|
|
143
|
-
return `Left ${
|
|
169
|
+
return `Left ${folder}/ as it is and made no link, because it still holds ${outcome.blocking.join(", ")}.`;
|
|
144
170
|
case "elsewhere":
|
|
145
|
-
return `Left ${
|
|
171
|
+
return `Left ${folder} as it is: it is a link to somewhere other than ${target}.`;
|
|
146
172
|
case "failed":
|
|
147
|
-
return `Could not link ${
|
|
173
|
+
return `Could not link ${folder} to ${target}: ${outcome.reason}. On Windows, git needs core.symlinks and a permission to create links. The launcher, \`outerlayer ${legacySubcommand(agents)}\`, does not need the link.`;
|
|
148
174
|
}
|
|
149
175
|
}
|
|
150
176
|
|
|
151
|
-
export { AGENTS_MD_LAYOUT, FIRST_VERSION_READING_AGENTS_SKILLS,
|
|
177
|
+
export { AGENTS_MD_LAYOUT, FIRST_VERSION_READING_AGENTS_SKILLS, declareAgentsMdLayout, describeSkillsLink, discoverOuterlayerPaths, filesBelow, holdsTodaysLayoutSources, isAgentsMdLayout, isForeignTree, linkAgentSkills, mcpFiles, readConfigObject, skillLinkFolders, skillsBaseFor, toRepoRelative };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { runnerDir, RUNNER_DIR_MODE, RUNNER_FILE_MODE } from './chunk-
|
|
3
|
+
import { runnerDir, RUNNER_DIR_MODE, RUNNER_FILE_MODE } from './chunk-DTCTXDJP.js';
|
|
4
4
|
import { readlinkSync, realpathSync, mkdirSync, unlinkSync, symlinkSync, renameSync, readFileSync, writeFileSync, rmSync, existsSync, readdirSync } from 'fs';
|
|
5
5
|
import { join, basename, sep, resolve } from 'path';
|
|
6
6
|
|