@puddle-code/cli 0.3.14 → 0.4.2
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/CHANGELOG.md +15 -5
- package/README.md +33 -19
- package/dist/host-control.mjs +1980 -133
- package/dist/index.js +4342 -970
- package/dist/install.sh +401 -40
- package/dist/public/assets/App-CbjV_eCr.js +19 -0
- package/dist/public/assets/{CompilationCommandForm-8ipw9M-Z.js → CompilationCommandForm-C71yC-_B.js} +1 -1
- package/dist/public/assets/Dashboard-CaVEQBQm.js +1 -0
- package/dist/public/assets/{EditorTabClose-o1L4BgTN.js → EditorTabClose-CHZNbZkD.js} +1 -1
- package/dist/public/assets/{FindWidget-CVH9U-_P.js → FindWidget-CaVwYvST.js} +1 -1
- package/dist/public/assets/LazyTerminal-BvZY-D0f.js +2 -0
- package/dist/public/assets/{ModelRefcount-0o8MEOUT.js → ModelRefcount-R_PJzn4E.js} +1 -1
- package/dist/public/assets/NewProjectDialog-B6wof57i.js +1 -0
- package/dist/public/assets/{NotebookWidget-Ci7TAuWd.js → NotebookWidget-D6vzMCnH.js} +1 -1
- package/dist/public/assets/PaneEditorBody-Bn8cmN5i.js +284 -0
- package/dist/public/assets/PdfViewer-C-dXDOjG.js +2 -0
- package/dist/public/assets/ReleaseNotesDialog-Z7jtCZYz.js +1 -0
- package/dist/public/assets/SettingsDialog-lSPFdtsX.js +8 -0
- package/dist/public/assets/{Terminal-B3Iw783s.js → Terminal-C9fEeTMx.js} +5 -5
- package/dist/public/assets/Workspace-DleYwgSG.js +20 -0
- package/dist/public/assets/api-BOuyloUi.js +1 -0
- package/dist/public/assets/auth-olLlgxc3.js +64 -0
- package/dist/public/assets/{buffer-store-B2nYD11t.js → buffer-store-DeLu2KS4.js} +1 -1
- package/dist/public/assets/button-q0ardkfx.js +1 -0
- package/dist/public/assets/{chevron-down--sjpQEHH.js → chevron-down-HQLVE6o5.js} +1 -1
- package/dist/public/assets/chevron-right-BP2NLwlG.js +1 -0
- package/dist/public/assets/code-Cf4ftdOa.js +1 -0
- package/dist/public/assets/command-BkdEYC1b.js +1 -0
- package/dist/public/assets/{context-CwZ4epwz.js → context-C3-WejyN.js} +1 -1
- package/dist/public/assets/context-menu-C0cOAj0E.js +1 -0
- package/dist/public/assets/control-tray-D7OXXkAy.css +1 -0
- package/dist/public/assets/control-tray-OJfh0_ml.js +1 -0
- package/dist/public/assets/{copy-CGsu8426.js → copy-D0Theg4Q.js} +1 -1
- package/dist/public/assets/createLucideIcon-C9A1vLE-.js +1 -0
- package/dist/public/assets/dialog-IU2fjIs9.js +41 -0
- package/dist/public/assets/{dist-Cde1E3eV.js → dist-BHBQY7ao.js} +1 -1
- package/dist/public/assets/{dist-CBag2On7.js → dist-CGlwr6Pc.js} +1 -1
- package/dist/public/assets/dist-eLNGMhYC.js +1 -0
- package/dist/public/assets/{forward-link-C-8Xn8gf.js → forward-link-DMvLf0Xw.js} +1 -1
- package/dist/public/assets/{hotkeys-DOpJ1a7g.js → hotkeys-Cu0t6sbz.js} +1 -1
- package/dist/public/assets/index-C3TPFFMc.css +2 -0
- package/dist/public/assets/{index-B9DFgBft.js → index-DK1twGI0.js} +3 -3
- package/dist/public/assets/markdown-CMSzQtLp.js +8 -0
- package/dist/public/assets/markdown-it-CWoG9_Dn.js +13 -0
- package/dist/public/assets/{markdown-mermaid-CZnHoKN5.js → markdown-mermaid-B648xTNp.js} +1 -1
- package/dist/public/assets/media-refresh-store-CHPkX-XV.js +1 -0
- package/dist/public/assets/notification-delivery-BlvH2Ojs.js +1 -0
- package/dist/public/assets/popover-B5Bw2ljC.js +1 -0
- package/dist/public/assets/{preview-kind-DiWpvEc0.js → preview-kind-CPkO-rSz.js} +1 -1
- package/dist/public/assets/protocol-support-CsLR9u7d.js +1 -0
- package/dist/public/assets/queue-BlrQxHDl.js +3 -0
- package/dist/public/assets/{rotate-ccw-CNjR2LSi.js → rotate-ccw-BI2k_h3A.js} +1 -1
- package/dist/public/assets/{scroll-restoration-gKZDDamc.js → scroll-restoration-CwXbvZvT.js} +1 -1
- package/dist/public/assets/{select-9OADuw7W.js → select-C0UTbo8D.js} +1 -1
- package/dist/public/assets/selection-actions-BLoNrxbO.js +1 -0
- package/dist/public/assets/session-order-2oedrwDu.js +1 -0
- package/dist/public/assets/switch-DihTSmnc.js +1 -0
- package/dist/public/assets/{use-ui-state-CQp93ZE4.js → use-ui-state-e6mUjW-H.js} +1 -1
- package/dist/public/assets/{view-state-store-CVAUWqnG.js → view-state-store-Cy9sQJoZ.js} +1 -1
- package/dist/public/assets/{whole-word-2m2pmAFT.js → whole-word-BJjKpISQ.js} +1 -1
- package/dist/public/assets/ws-BX1iQbeP.js +1 -0
- package/dist/public/assets/x-Dq6POV20.js +1 -0
- package/dist/public/file-icons/material/LICENSE +8 -0
- package/dist/public/file-icons/material/SOURCE.txt +4 -0
- package/dist/public/file-icons/material/astro.svg +1 -0
- package/dist/public/file-icons/material/audio.svg +1 -0
- package/dist/public/file-icons/material/c.svg +1 -0
- package/dist/public/file-icons/material/console.svg +1 -0
- package/dist/public/file-icons/material/cpp.svg +1 -0
- package/dist/public/file-icons/material/csharp.svg +1 -0
- package/dist/public/file-icons/material/css.svg +1 -0
- package/dist/public/file-icons/material/dart.svg +1 -0
- package/dist/public/file-icons/material/database.svg +1 -0
- package/dist/public/file-icons/material/docker.svg +1 -0
- package/dist/public/file-icons/material/document.svg +1 -0
- package/dist/public/file-icons/material/eslint.svg +1 -0
- package/dist/public/file-icons/material/font.svg +1 -0
- package/dist/public/file-icons/material/git.svg +1 -0
- package/dist/public/file-icons/material/go-mod.svg +1 -0
- package/dist/public/file-icons/material/go.svg +1 -0
- package/dist/public/file-icons/material/h.svg +1 -0
- package/dist/public/file-icons/material/hpp.svg +1 -0
- package/dist/public/file-icons/material/html.svg +1 -0
- package/dist/public/file-icons/material/image.svg +1 -0
- package/dist/public/file-icons/material/java.svg +1 -0
- package/dist/public/file-icons/material/javascript.svg +1 -0
- package/dist/public/file-icons/material/json.svg +1 -0
- package/dist/public/file-icons/material/jupyter.svg +1 -0
- package/dist/public/file-icons/material/kotlin.svg +1 -0
- package/dist/public/file-icons/material/less.svg +1 -0
- package/dist/public/file-icons/material/license.svg +1 -0
- package/dist/public/file-icons/material/lock.svg +1 -0
- package/dist/public/file-icons/material/markdown.svg +1 -0
- package/dist/public/file-icons/material/npm.svg +1 -0
- package/dist/public/file-icons/material/pdf.svg +1 -0
- package/dist/public/file-icons/material/php.svg +1 -0
- package/dist/public/file-icons/material/pnpm.svg +1 -0
- package/dist/public/file-icons/material/prettier.svg +1 -0
- package/dist/public/file-icons/material/python.svg +1 -0
- package/dist/public/file-icons/material/react.svg +1 -0
- package/dist/public/file-icons/material/react_ts.svg +1 -0
- package/dist/public/file-icons/material/readme.svg +1 -0
- package/dist/public/file-icons/material/ruby.svg +1 -0
- package/dist/public/file-icons/material/rust.svg +1 -0
- package/dist/public/file-icons/material/sass.svg +1 -0
- package/dist/public/file-icons/material/settings.svg +1 -0
- package/dist/public/file-icons/material/svelte.svg +1 -0
- package/dist/public/file-icons/material/svg.svg +1 -0
- package/dist/public/file-icons/material/swift.svg +1 -0
- package/dist/public/file-icons/material/table.svg +1 -0
- package/dist/public/file-icons/material/toml.svg +1 -0
- package/dist/public/file-icons/material/tune.svg +1 -0
- package/dist/public/file-icons/material/typescript-def.svg +1 -0
- package/dist/public/file-icons/material/typescript.svg +1 -0
- package/dist/public/file-icons/material/video.svg +1 -0
- package/dist/public/file-icons/material/vite.svg +1 -0
- package/dist/public/file-icons/material/vitest.svg +1 -0
- package/dist/public/file-icons/material/vue.svg +1 -0
- package/dist/public/file-icons/material/xml.svg +1 -0
- package/dist/public/file-icons/material/yaml.svg +1 -0
- package/dist/public/file-icons/material/yarn.svg +1 -0
- package/dist/public/file-icons/material/zip.svg +1 -0
- package/dist/public/index.html +3 -3
- package/dist/pudl.js +1996 -183
- package/package.json +1 -1
- package/dist/public/assets/App-5QiKmUI_.js +0 -2
- package/dist/public/assets/Dashboard-B9v8mQKk.js +0 -1
- package/dist/public/assets/LazyTerminal-Crwcrh-K.js +0 -2
- package/dist/public/assets/NewProjectDialog-qFDLTphH.js +0 -1
- package/dist/public/assets/PaneEditorBody-C8uTV9yU.js +0 -303
- package/dist/public/assets/PdfViewer-BoFsXAue.js +0 -2
- package/dist/public/assets/SettingsDialog-tW18Y_Wr.js +0 -8
- package/dist/public/assets/Workspace-D2IYXJV2.js +0 -20
- package/dist/public/assets/api-CfmzEbQ_.js +0 -1
- package/dist/public/assets/auth-CIb9G2C5.js +0 -64
- package/dist/public/assets/button-9AVMLaMQ.js +0 -1
- package/dist/public/assets/chevron-right-BRjnLYaO.js +0 -1
- package/dist/public/assets/code-DRWf9a5s.js +0 -1
- package/dist/public/assets/command-BUOkDmUW.js +0 -1
- package/dist/public/assets/context-menu-D-5BvS0X.js +0 -1
- package/dist/public/assets/createLucideIcon-DyMAgLa3.js +0 -1
- package/dist/public/assets/dialog-BMWRC2HO.js +0 -41
- package/dist/public/assets/dist-CcLyf3-2.js +0 -1
- package/dist/public/assets/errors-DTaodZDR.js +0 -1
- package/dist/public/assets/index-DwtrJj9v.css +0 -2
- package/dist/public/assets/media-refresh-store-DDvrEM5K.js +0 -1
- package/dist/public/assets/notification-delivery-DdTD40aA.js +0 -1
- package/dist/public/assets/popover-CtxJVkPi.js +0 -1
- package/dist/public/assets/protocol-support-BGk73LFk.js +0 -1
- package/dist/public/assets/selection-actions-BjVj7hXw.js +0 -1
- package/dist/public/assets/session-order-SN_zG4Us.js +0 -1
- package/dist/public/assets/switch-iVuj74VW.js +0 -1
- package/dist/public/assets/ws-CspBmo8M.js +0 -1
- package/dist/public/assets/x-DCpy1q13.js +0 -1
package/dist/host-control.mjs
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (
|
|
2
|
+
var __export = (target2, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
|
-
__defProp(
|
|
4
|
+
__defProp(target2, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/host-control.ts
|
|
8
8
|
import { connect as connect2 } from "node:net";
|
|
9
9
|
|
|
10
|
+
// ../shared/src/protocol.ts
|
|
11
|
+
var PROTOCOL_VERSION = { major: 26, minor: 1 };
|
|
12
|
+
function supportsApplicationFeature(peer, introduced, client = PROTOCOL_VERSION) {
|
|
13
|
+
return peer?.major === client.major && (peer.major > introduced.major || peer.major === introduced.major && peer.minor >= introduced.minor);
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
11
17
|
var external_exports = {};
|
|
12
18
|
__export(external_exports, {
|
|
@@ -754,8 +760,8 @@ function defineLazy(object2, key, getter) {
|
|
|
754
760
|
function objectClone(obj) {
|
|
755
761
|
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
756
762
|
}
|
|
757
|
-
function assignProp(
|
|
758
|
-
Object.defineProperty(
|
|
763
|
+
function assignProp(target2, prop, value) {
|
|
764
|
+
Object.defineProperty(target2, prop, {
|
|
759
765
|
value,
|
|
760
766
|
writable: true,
|
|
761
767
|
enumerable: true,
|
|
@@ -773,10 +779,10 @@ function mergeDefs(...defs) {
|
|
|
773
779
|
function cloneDef(schema) {
|
|
774
780
|
return mergeDefs(schema._zod.def);
|
|
775
781
|
}
|
|
776
|
-
function getElementAtPath(obj,
|
|
777
|
-
if (!
|
|
782
|
+
function getElementAtPath(obj, path2) {
|
|
783
|
+
if (!path2)
|
|
778
784
|
return obj;
|
|
779
|
-
return
|
|
785
|
+
return path2.reduce((acc, key) => acc?.[key], obj);
|
|
780
786
|
}
|
|
781
787
|
function promiseAllObject(promisesObj) {
|
|
782
788
|
const keys = Object.keys(promisesObj);
|
|
@@ -938,35 +944,35 @@ function normalizeParams(_params) {
|
|
|
938
944
|
return params;
|
|
939
945
|
}
|
|
940
946
|
function createTransparentProxy(getter) {
|
|
941
|
-
let
|
|
947
|
+
let target2;
|
|
942
948
|
return new Proxy({}, {
|
|
943
949
|
get(_, prop, receiver) {
|
|
944
|
-
|
|
945
|
-
return Reflect.get(
|
|
950
|
+
target2 ?? (target2 = getter());
|
|
951
|
+
return Reflect.get(target2, prop, receiver);
|
|
946
952
|
},
|
|
947
953
|
set(_, prop, value, receiver) {
|
|
948
|
-
|
|
949
|
-
return Reflect.set(
|
|
954
|
+
target2 ?? (target2 = getter());
|
|
955
|
+
return Reflect.set(target2, prop, value, receiver);
|
|
950
956
|
},
|
|
951
957
|
has(_, prop) {
|
|
952
|
-
|
|
953
|
-
return Reflect.has(
|
|
958
|
+
target2 ?? (target2 = getter());
|
|
959
|
+
return Reflect.has(target2, prop);
|
|
954
960
|
},
|
|
955
961
|
deleteProperty(_, prop) {
|
|
956
|
-
|
|
957
|
-
return Reflect.deleteProperty(
|
|
962
|
+
target2 ?? (target2 = getter());
|
|
963
|
+
return Reflect.deleteProperty(target2, prop);
|
|
958
964
|
},
|
|
959
965
|
ownKeys(_) {
|
|
960
|
-
|
|
961
|
-
return Reflect.ownKeys(
|
|
966
|
+
target2 ?? (target2 = getter());
|
|
967
|
+
return Reflect.ownKeys(target2);
|
|
962
968
|
},
|
|
963
969
|
getOwnPropertyDescriptor(_, prop) {
|
|
964
|
-
|
|
965
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
970
|
+
target2 ?? (target2 = getter());
|
|
971
|
+
return Reflect.getOwnPropertyDescriptor(target2, prop);
|
|
966
972
|
},
|
|
967
973
|
defineProperty(_, prop, descriptor) {
|
|
968
|
-
|
|
969
|
-
return Reflect.defineProperty(
|
|
974
|
+
target2 ?? (target2 = getter());
|
|
975
|
+
return Reflect.defineProperty(target2, prop, descriptor);
|
|
970
976
|
}
|
|
971
977
|
});
|
|
972
978
|
}
|
|
@@ -1185,11 +1191,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1185
1191
|
}
|
|
1186
1192
|
return false;
|
|
1187
1193
|
}
|
|
1188
|
-
function prefixIssues(
|
|
1194
|
+
function prefixIssues(path2, issues) {
|
|
1189
1195
|
return issues.map((iss) => {
|
|
1190
1196
|
var _a3;
|
|
1191
1197
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1192
|
-
iss.path.unshift(
|
|
1198
|
+
iss.path.unshift(path2);
|
|
1193
1199
|
return iss;
|
|
1194
1200
|
});
|
|
1195
1201
|
}
|
|
@@ -1336,16 +1342,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1336
1342
|
}
|
|
1337
1343
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1338
1344
|
const fieldErrors = { _errors: [] };
|
|
1339
|
-
const processError = (error52,
|
|
1345
|
+
const processError = (error52, path2 = []) => {
|
|
1340
1346
|
for (const issue2 of error52.issues) {
|
|
1341
1347
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1342
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1348
|
+
issue2.errors.map((issues) => processError({ issues }, [...path2, ...issue2.path]));
|
|
1343
1349
|
} else if (issue2.code === "invalid_key") {
|
|
1344
|
-
processError({ issues: issue2.issues }, [...
|
|
1350
|
+
processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
|
|
1345
1351
|
} else if (issue2.code === "invalid_element") {
|
|
1346
|
-
processError({ issues: issue2.issues }, [...
|
|
1352
|
+
processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
|
|
1347
1353
|
} else {
|
|
1348
|
-
const fullpath = [...
|
|
1354
|
+
const fullpath = [...path2, ...issue2.path];
|
|
1349
1355
|
if (fullpath.length === 0) {
|
|
1350
1356
|
fieldErrors._errors.push(mapper(issue2));
|
|
1351
1357
|
} else {
|
|
@@ -1372,17 +1378,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1372
1378
|
}
|
|
1373
1379
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1374
1380
|
const result = { errors: [] };
|
|
1375
|
-
const processError = (error52,
|
|
1381
|
+
const processError = (error52, path2 = []) => {
|
|
1376
1382
|
var _a3, _b;
|
|
1377
1383
|
for (const issue2 of error52.issues) {
|
|
1378
1384
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1379
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1385
|
+
issue2.errors.map((issues) => processError({ issues }, [...path2, ...issue2.path]));
|
|
1380
1386
|
} else if (issue2.code === "invalid_key") {
|
|
1381
|
-
processError({ issues: issue2.issues }, [...
|
|
1387
|
+
processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
|
|
1382
1388
|
} else if (issue2.code === "invalid_element") {
|
|
1383
|
-
processError({ issues: issue2.issues }, [...
|
|
1389
|
+
processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
|
|
1384
1390
|
} else {
|
|
1385
|
-
const fullpath = [...
|
|
1391
|
+
const fullpath = [...path2, ...issue2.path];
|
|
1386
1392
|
if (fullpath.length === 0) {
|
|
1387
1393
|
result.errors.push(mapper(issue2));
|
|
1388
1394
|
continue;
|
|
@@ -1414,8 +1420,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1414
1420
|
}
|
|
1415
1421
|
function toDotPath(_path) {
|
|
1416
1422
|
const segs = [];
|
|
1417
|
-
const
|
|
1418
|
-
for (const seg of
|
|
1423
|
+
const path2 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1424
|
+
for (const seg of path2) {
|
|
1419
1425
|
if (typeof seg === "number")
|
|
1420
1426
|
segs.push(`[${seg}]`);
|
|
1421
1427
|
else if (typeof seg === "symbol")
|
|
@@ -1906,8 +1912,8 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
|
|
|
1906
1912
|
});
|
|
1907
1913
|
inst._zod.check = (payload) => {
|
|
1908
1914
|
const input = payload.value;
|
|
1909
|
-
const
|
|
1910
|
-
if (
|
|
1915
|
+
const size2 = input.size;
|
|
1916
|
+
if (size2 <= def.maximum)
|
|
1911
1917
|
return;
|
|
1912
1918
|
payload.issues.push({
|
|
1913
1919
|
origin: getSizableOrigin(input),
|
|
@@ -1934,8 +1940,8 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
|
|
|
1934
1940
|
});
|
|
1935
1941
|
inst._zod.check = (payload) => {
|
|
1936
1942
|
const input = payload.value;
|
|
1937
|
-
const
|
|
1938
|
-
if (
|
|
1943
|
+
const size2 = input.size;
|
|
1944
|
+
if (size2 >= def.minimum)
|
|
1939
1945
|
return;
|
|
1940
1946
|
payload.issues.push({
|
|
1941
1947
|
origin: getSizableOrigin(input),
|
|
@@ -1963,10 +1969,10 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
|
|
|
1963
1969
|
});
|
|
1964
1970
|
inst._zod.check = (payload) => {
|
|
1965
1971
|
const input = payload.value;
|
|
1966
|
-
const
|
|
1967
|
-
if (
|
|
1972
|
+
const size2 = input.size;
|
|
1973
|
+
if (size2 === def.size)
|
|
1968
1974
|
return;
|
|
1969
|
-
const tooBig =
|
|
1975
|
+
const tooBig = size2 > def.size;
|
|
1970
1976
|
payload.issues.push({
|
|
1971
1977
|
origin: getSizableOrigin(input),
|
|
1972
1978
|
...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
|
|
@@ -3099,42 +3105,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3099
3105
|
}
|
|
3100
3106
|
doc.write(`const newResult = {};`);
|
|
3101
3107
|
for (const key of normalized.keys) {
|
|
3102
|
-
const
|
|
3108
|
+
const id3 = ids[key];
|
|
3103
3109
|
const k = esc(key);
|
|
3104
3110
|
const schema = shape[key];
|
|
3105
3111
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3106
3112
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
3107
|
-
doc.write(`const ${
|
|
3113
|
+
doc.write(`const ${id3} = ${parseStr(key)};`);
|
|
3108
3114
|
if (isOptionalIn && isOptionalOut) {
|
|
3109
3115
|
doc.write(`
|
|
3110
|
-
if (${
|
|
3116
|
+
if (${id3}.issues.length) {
|
|
3111
3117
|
if (${k} in input) {
|
|
3112
|
-
payload.issues = payload.issues.concat(${
|
|
3118
|
+
payload.issues = payload.issues.concat(${id3}.issues.map(iss => ({
|
|
3113
3119
|
...iss,
|
|
3114
3120
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3115
3121
|
})));
|
|
3116
3122
|
}
|
|
3117
3123
|
}
|
|
3118
3124
|
|
|
3119
|
-
if (${
|
|
3125
|
+
if (${id3}.value === undefined) {
|
|
3120
3126
|
if (${k} in input) {
|
|
3121
3127
|
newResult[${k}] = undefined;
|
|
3122
3128
|
}
|
|
3123
3129
|
} else {
|
|
3124
|
-
newResult[${k}] = ${
|
|
3130
|
+
newResult[${k}] = ${id3}.value;
|
|
3125
3131
|
}
|
|
3126
3132
|
|
|
3127
3133
|
`);
|
|
3128
3134
|
} else if (!isOptionalIn) {
|
|
3129
3135
|
doc.write(`
|
|
3130
|
-
const ${
|
|
3131
|
-
if (${
|
|
3132
|
-
payload.issues = payload.issues.concat(${
|
|
3136
|
+
const ${id3}_present = ${k} in input;
|
|
3137
|
+
if (${id3}.issues.length) {
|
|
3138
|
+
payload.issues = payload.issues.concat(${id3}.issues.map(iss => ({
|
|
3133
3139
|
...iss,
|
|
3134
3140
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3135
3141
|
})));
|
|
3136
3142
|
}
|
|
3137
|
-
if (!${
|
|
3143
|
+
if (!${id3}_present && !${id3}.issues.length) {
|
|
3138
3144
|
payload.issues.push({
|
|
3139
3145
|
code: "invalid_type",
|
|
3140
3146
|
expected: "nonoptional",
|
|
@@ -3143,30 +3149,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3143
3149
|
});
|
|
3144
3150
|
}
|
|
3145
3151
|
|
|
3146
|
-
if (${
|
|
3147
|
-
if (${
|
|
3152
|
+
if (${id3}_present) {
|
|
3153
|
+
if (${id3}.value === undefined) {
|
|
3148
3154
|
newResult[${k}] = undefined;
|
|
3149
3155
|
} else {
|
|
3150
|
-
newResult[${k}] = ${
|
|
3156
|
+
newResult[${k}] = ${id3}.value;
|
|
3151
3157
|
}
|
|
3152
3158
|
}
|
|
3153
3159
|
|
|
3154
3160
|
`);
|
|
3155
3161
|
} else {
|
|
3156
3162
|
doc.write(`
|
|
3157
|
-
if (${
|
|
3158
|
-
payload.issues = payload.issues.concat(${
|
|
3163
|
+
if (${id3}.issues.length) {
|
|
3164
|
+
payload.issues = payload.issues.concat(${id3}.issues.map(iss => ({
|
|
3159
3165
|
...iss,
|
|
3160
3166
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3161
3167
|
})));
|
|
3162
3168
|
}
|
|
3163
3169
|
|
|
3164
|
-
if (${
|
|
3170
|
+
if (${id3}.value === undefined) {
|
|
3165
3171
|
if (${k} in input) {
|
|
3166
3172
|
newResult[${k}] = undefined;
|
|
3167
3173
|
}
|
|
3168
3174
|
} else {
|
|
3169
|
-
newResult[${k}] = ${
|
|
3175
|
+
newResult[${k}] = ${id3}.value;
|
|
3170
3176
|
}
|
|
3171
3177
|
|
|
3172
3178
|
`);
|
|
@@ -4643,8 +4649,8 @@ function az_default() {
|
|
|
4643
4649
|
}
|
|
4644
4650
|
|
|
4645
4651
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/be.js
|
|
4646
|
-
function getBelarusianPlural(
|
|
4647
|
-
const absCount = Math.abs(
|
|
4652
|
+
function getBelarusianPlural(count2, one, few, many) {
|
|
4653
|
+
const absCount = Math.abs(count2);
|
|
4648
4654
|
const lastDigit = absCount % 10;
|
|
4649
4655
|
const lastTwoDigits = absCount % 100;
|
|
4650
4656
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -6722,8 +6728,8 @@ function hu_default() {
|
|
|
6722
6728
|
}
|
|
6723
6729
|
|
|
6724
6730
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/hy.js
|
|
6725
|
-
function getArmenianPlural(
|
|
6726
|
-
return Math.abs(
|
|
6731
|
+
function getArmenianPlural(count2, one, many) {
|
|
6732
|
+
return Math.abs(count2) === 1 ? one : many;
|
|
6727
6733
|
}
|
|
6728
6734
|
function withDefiniteArticle(word) {
|
|
6729
6735
|
if (!word)
|
|
@@ -7645,8 +7651,8 @@ function ko_default() {
|
|
|
7645
7651
|
}
|
|
7646
7652
|
|
|
7647
7653
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/lt.js
|
|
7648
|
-
var capitalizeFirstCharacter = (
|
|
7649
|
-
return
|
|
7654
|
+
var capitalizeFirstCharacter = (text2) => {
|
|
7655
|
+
return text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
7650
7656
|
};
|
|
7651
7657
|
function getUnitTypeFromNumber(number4) {
|
|
7652
7658
|
const abs = Math.abs(number4);
|
|
@@ -8851,8 +8857,8 @@ function ro_default() {
|
|
|
8851
8857
|
}
|
|
8852
8858
|
|
|
8853
8859
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/ru.js
|
|
8854
|
-
function getRussianPlural(
|
|
8855
|
-
const absCount = Math.abs(
|
|
8860
|
+
function getRussianPlural(count2, one, few, many) {
|
|
8861
|
+
const absCount = Math.abs(count2);
|
|
8856
8862
|
const lastDigit = absCount % 10;
|
|
8857
8863
|
const lastTwoDigits = absCount % 100;
|
|
8858
8864
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -10936,11 +10942,11 @@ function _minSize(minimum, params) {
|
|
|
10936
10942
|
});
|
|
10937
10943
|
}
|
|
10938
10944
|
// @__NO_SIDE_EFFECTS__
|
|
10939
|
-
function _size(
|
|
10945
|
+
function _size(size2, params) {
|
|
10940
10946
|
return new $ZodCheckSizeEquals({
|
|
10941
10947
|
check: "size_equals",
|
|
10942
10948
|
...normalizeParams(params),
|
|
10943
|
-
size
|
|
10949
|
+
size: size2
|
|
10944
10950
|
});
|
|
10945
10951
|
}
|
|
10946
10952
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -11418,15 +11424,15 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
|
|
|
11418
11424
|
|
|
11419
11425
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
|
|
11420
11426
|
function initializeContext(params) {
|
|
11421
|
-
let
|
|
11422
|
-
if (
|
|
11423
|
-
|
|
11424
|
-
if (
|
|
11425
|
-
|
|
11427
|
+
let target2 = params?.target ?? "draft-2020-12";
|
|
11428
|
+
if (target2 === "draft-4")
|
|
11429
|
+
target2 = "draft-04";
|
|
11430
|
+
if (target2 === "draft-7")
|
|
11431
|
+
target2 = "draft-07";
|
|
11426
11432
|
return {
|
|
11427
11433
|
processors: params.processors ?? {},
|
|
11428
11434
|
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
11429
|
-
target,
|
|
11435
|
+
target: target2,
|
|
11430
11436
|
unrepresentable: params?.unrepresentable ?? "throw",
|
|
11431
11437
|
override: params?.override ?? (() => {
|
|
11432
11438
|
}),
|
|
@@ -11493,33 +11499,33 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
11493
11499
|
return _result.schema;
|
|
11494
11500
|
}
|
|
11495
11501
|
function extractDefs(ctx, schema) {
|
|
11496
|
-
const
|
|
11497
|
-
if (!
|
|
11502
|
+
const root2 = ctx.seen.get(schema);
|
|
11503
|
+
if (!root2)
|
|
11498
11504
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11499
11505
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
11500
11506
|
for (const entry of ctx.seen.entries()) {
|
|
11501
|
-
const
|
|
11502
|
-
if (
|
|
11503
|
-
const existing = idToSchema.get(
|
|
11507
|
+
const id3 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11508
|
+
if (id3) {
|
|
11509
|
+
const existing = idToSchema.get(id3);
|
|
11504
11510
|
if (existing && existing !== entry[0]) {
|
|
11505
|
-
throw new Error(`Duplicate schema id "${
|
|
11511
|
+
throw new Error(`Duplicate schema id "${id3}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
11506
11512
|
}
|
|
11507
|
-
idToSchema.set(
|
|
11513
|
+
idToSchema.set(id3, entry[0]);
|
|
11508
11514
|
}
|
|
11509
11515
|
}
|
|
11510
11516
|
const makeURI = (entry) => {
|
|
11511
11517
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11512
11518
|
if (ctx.external) {
|
|
11513
11519
|
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
11514
|
-
const uriGenerator = ctx.external.uri ?? ((
|
|
11520
|
+
const uriGenerator = ctx.external.uri ?? ((id4) => id4);
|
|
11515
11521
|
if (externalId) {
|
|
11516
11522
|
return { ref: uriGenerator(externalId) };
|
|
11517
11523
|
}
|
|
11518
|
-
const
|
|
11519
|
-
entry[1].defId =
|
|
11520
|
-
return { defId:
|
|
11524
|
+
const id3 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
11525
|
+
entry[1].defId = id3;
|
|
11526
|
+
return { defId: id3, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id3}` };
|
|
11521
11527
|
}
|
|
11522
|
-
if (entry[1] ===
|
|
11528
|
+
if (entry[1] === root2) {
|
|
11523
11529
|
return { ref: "#" };
|
|
11524
11530
|
}
|
|
11525
11531
|
const uriPrefix = `#`;
|
|
@@ -11565,8 +11571,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11565
11571
|
continue;
|
|
11566
11572
|
}
|
|
11567
11573
|
}
|
|
11568
|
-
const
|
|
11569
|
-
if (
|
|
11574
|
+
const id3 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11575
|
+
if (id3) {
|
|
11570
11576
|
extractToDef(entry);
|
|
11571
11577
|
continue;
|
|
11572
11578
|
}
|
|
@@ -11583,8 +11589,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11583
11589
|
}
|
|
11584
11590
|
}
|
|
11585
11591
|
function finalize(ctx, schema) {
|
|
11586
|
-
const
|
|
11587
|
-
if (!
|
|
11592
|
+
const root2 = ctx.seen.get(schema);
|
|
11593
|
+
if (!root2)
|
|
11588
11594
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11589
11595
|
const flattenRef = (zodSchema) => {
|
|
11590
11596
|
const seen = ctx.seen.get(zodSchema);
|
|
@@ -11662,12 +11668,12 @@ function finalize(ctx, schema) {
|
|
|
11662
11668
|
} else {
|
|
11663
11669
|
}
|
|
11664
11670
|
if (ctx.external?.uri) {
|
|
11665
|
-
const
|
|
11666
|
-
if (!
|
|
11671
|
+
const id3 = ctx.external.registry.get(schema)?.id;
|
|
11672
|
+
if (!id3)
|
|
11667
11673
|
throw new Error("Schema is missing an `id` property");
|
|
11668
|
-
result.$id = ctx.external.uri(
|
|
11674
|
+
result.$id = ctx.external.uri(id3);
|
|
11669
11675
|
}
|
|
11670
|
-
Object.assign(result,
|
|
11676
|
+
Object.assign(result, root2.def ?? root2.schema);
|
|
11671
11677
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
11672
11678
|
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
11673
11679
|
delete result.id;
|
|
@@ -11768,8 +11774,8 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
11768
11774
|
return finalize(ctx, schema);
|
|
11769
11775
|
};
|
|
11770
11776
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
11771
|
-
const { libraryOptions, target } = params ?? {};
|
|
11772
|
-
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
11777
|
+
const { libraryOptions, target: target2 } = params ?? {};
|
|
11778
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target: target2, io, processors });
|
|
11773
11779
|
process2(schema, ctx);
|
|
11774
11780
|
extractDefs(ctx, schema);
|
|
11775
11781
|
return finalize(ctx, schema);
|
|
@@ -12828,8 +12834,8 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
12828
12834
|
catch(params) {
|
|
12829
12835
|
return _catch2(this, params);
|
|
12830
12836
|
},
|
|
12831
|
-
pipe(
|
|
12832
|
-
return pipe(this,
|
|
12837
|
+
pipe(target2) {
|
|
12838
|
+
return pipe(this, target2);
|
|
12833
12839
|
},
|
|
12834
12840
|
readonly() {
|
|
12835
12841
|
return readonly(this);
|
|
@@ -13656,8 +13662,8 @@ var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
|
13656
13662
|
$ZodFile.init(inst, def);
|
|
13657
13663
|
ZodType.init(inst, def);
|
|
13658
13664
|
inst._zod.processJSONSchema = (ctx, json3, params) => fileProcessor(inst, ctx, json3, params);
|
|
13659
|
-
inst.min = (
|
|
13660
|
-
inst.max = (
|
|
13665
|
+
inst.min = (size2, params) => inst.check(_minSize(size2, params));
|
|
13666
|
+
inst.max = (size2, params) => inst.check(_maxSize(size2, params));
|
|
13661
13667
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
13662
13668
|
});
|
|
13663
13669
|
function file(params) {
|
|
@@ -14107,13 +14113,13 @@ function resolveRef(ref, ctx) {
|
|
|
14107
14113
|
if (!ref.startsWith("#")) {
|
|
14108
14114
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14109
14115
|
}
|
|
14110
|
-
const
|
|
14111
|
-
if (
|
|
14116
|
+
const path2 = ref.slice(1).split("/").filter(Boolean);
|
|
14117
|
+
if (path2.length === 0) {
|
|
14112
14118
|
return ctx.rootSchema;
|
|
14113
14119
|
}
|
|
14114
14120
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14115
|
-
if (
|
|
14116
|
-
const key =
|
|
14121
|
+
if (path2[0] === defsKey) {
|
|
14122
|
+
const key = path2[1];
|
|
14117
14123
|
if (!key || !ctx.defs[key]) {
|
|
14118
14124
|
throw new Error(`Reference not found: ${ref}`);
|
|
14119
14125
|
}
|
|
@@ -14580,12 +14586,307 @@ var versionResponseSchema = external_exports.object({
|
|
|
14580
14586
|
remote_notifications: external_exports.boolean().optional(),
|
|
14581
14587
|
remote_notification_previews: external_exports.boolean().optional(),
|
|
14582
14588
|
remote_image_uploads: external_exports.boolean().optional(),
|
|
14589
|
+
/** Exact admitted device has a current host-approved maintenance grant (application 26). */
|
|
14590
|
+
remote_host_updates: external_exports.boolean().optional(),
|
|
14583
14591
|
protocol: external_exports.object({
|
|
14584
14592
|
major: external_exports.number().int().nonnegative(),
|
|
14585
14593
|
minor: external_exports.number().int().nonnegative()
|
|
14586
14594
|
})
|
|
14587
14595
|
});
|
|
14588
14596
|
|
|
14597
|
+
// ../shared/src/api/connection/release-notes.ts
|
|
14598
|
+
var RELEASE_NOTES_MAX_BYTES = 256 * 1024;
|
|
14599
|
+
var releaseNotesSchema = external_exports.object({
|
|
14600
|
+
releases: external_exports.array(
|
|
14601
|
+
external_exports.object({
|
|
14602
|
+
component: external_exports.enum(["daemon", "runtime"]),
|
|
14603
|
+
version: external_exports.string().min(1).max(128),
|
|
14604
|
+
markdown: external_exports.string().min(1).max(RELEASE_NOTES_MAX_BYTES).refine((value) => new TextEncoder().encode(value).length <= RELEASE_NOTES_MAX_BYTES)
|
|
14605
|
+
})
|
|
14606
|
+
).max(2).refine((entries) => new Set(entries.map((entry) => entry.component)).size === entries.length)
|
|
14607
|
+
});
|
|
14608
|
+
|
|
14609
|
+
// ../shared/src/installation/version.ts
|
|
14610
|
+
function parseHostReleaseVersion(value) {
|
|
14611
|
+
const version2 = value.trim();
|
|
14612
|
+
return value.length <= 129 && version2.length <= 128 && /^[0-9]+\.[0-9]+\.[0-9]+([+-][A-Za-z0-9.-]+)?$/.test(version2) ? version2 : void 0;
|
|
14613
|
+
}
|
|
14614
|
+
|
|
14615
|
+
// ../shared/src/installation/stage.ts
|
|
14616
|
+
var hostStageRecordSchema = external_exports.object({
|
|
14617
|
+
format: external_exports.literal(1),
|
|
14618
|
+
component: external_exports.enum(["daemon", "runtime"]),
|
|
14619
|
+
generation: external_exports.string().max(135).regex(/^[A-Za-z0-9.+-]+~[A-Za-z0-9]{6}$/),
|
|
14620
|
+
version: external_exports.string().max(128).refine((value) => parseHostReleaseVersion(value) === value),
|
|
14621
|
+
protocol: external_exports.object({
|
|
14622
|
+
major: external_exports.number().int().nonnegative().safe(),
|
|
14623
|
+
minor: external_exports.number().int().nonnegative().safe()
|
|
14624
|
+
}).strict(),
|
|
14625
|
+
archive_sha256: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
14626
|
+
tree_sha256: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
14627
|
+
checksum_verified: external_exports.boolean()
|
|
14628
|
+
}).strict().refine((record2) => record2.generation.startsWith(`${record2.version}~`));
|
|
14629
|
+
var hostStageReceiptSchema = external_exports.object({
|
|
14630
|
+
record: hostStageRecordSchema,
|
|
14631
|
+
digest: external_exports.string().regex(/^[0-9a-f]{64}$/)
|
|
14632
|
+
}).strict();
|
|
14633
|
+
|
|
14634
|
+
// ../shared/src/installation/update.ts
|
|
14635
|
+
var fingerprint = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
14636
|
+
var timestamp = external_exports.number().int().nonnegative().safe();
|
|
14637
|
+
var hostUpdateTargetsSchema = external_exports.array(
|
|
14638
|
+
external_exports.object({
|
|
14639
|
+
component: hostStageRecordSchema.shape.component,
|
|
14640
|
+
version: hostStageRecordSchema.shape.version
|
|
14641
|
+
}).strict()
|
|
14642
|
+
).min(1).max(2).refine((targets) => new Set(targets.map((target2) => target2.component)).size === targets.length);
|
|
14643
|
+
var hostUpdateOperationSchema = external_exports.object({
|
|
14644
|
+
format: external_exports.literal(1),
|
|
14645
|
+
id: external_exports.uuid(),
|
|
14646
|
+
revision: external_exports.number().int().positive().safe(),
|
|
14647
|
+
created_at: timestamp,
|
|
14648
|
+
updated_at: timestamp,
|
|
14649
|
+
phase: external_exports.enum([
|
|
14650
|
+
"checking",
|
|
14651
|
+
"downloading",
|
|
14652
|
+
"staged",
|
|
14653
|
+
"preflight",
|
|
14654
|
+
"approved",
|
|
14655
|
+
"dispatching",
|
|
14656
|
+
"applying",
|
|
14657
|
+
"verifying",
|
|
14658
|
+
"complete",
|
|
14659
|
+
"blocked",
|
|
14660
|
+
"cancelled",
|
|
14661
|
+
"superseded",
|
|
14662
|
+
"failed",
|
|
14663
|
+
"recovery_required",
|
|
14664
|
+
"rolled_back"
|
|
14665
|
+
]),
|
|
14666
|
+
targets: hostUpdateTargetsSchema,
|
|
14667
|
+
stages: external_exports.array(hostStageReceiptSchema).max(2),
|
|
14668
|
+
preflight: fingerprint.nullable(),
|
|
14669
|
+
approved: fingerprint.nullable(),
|
|
14670
|
+
dispatch_id: external_exports.uuid().nullable(),
|
|
14671
|
+
worker_id: external_exports.uuid().nullable(),
|
|
14672
|
+
verification: fingerprint.nullable(),
|
|
14673
|
+
message: external_exports.string().max(1024).nullable()
|
|
14674
|
+
}).strict().superRefine((record2, context) => {
|
|
14675
|
+
const fail = (message) => context.addIssue({ code: "custom", message });
|
|
14676
|
+
if (record2.updated_at < record2.created_at) fail("Update timestamp moved backwards");
|
|
14677
|
+
if (["blocked", "cancelled", "superseded", "failed"].includes(record2.phase) && (record2.dispatch_id !== null || record2.worker_id !== null))
|
|
14678
|
+
fail("A dispatched update requires verified recovery before becoming terminal");
|
|
14679
|
+
const components = /* @__PURE__ */ new Set();
|
|
14680
|
+
for (const stage of record2.stages) {
|
|
14681
|
+
if (!stage.record.checksum_verified || !record2.targets.some(
|
|
14682
|
+
(target2) => target2.component === stage.record.component && target2.version === stage.record.version
|
|
14683
|
+
) || components.has(stage.record.component))
|
|
14684
|
+
fail("Stage does not match a verified update target");
|
|
14685
|
+
components.add(stage.record.component);
|
|
14686
|
+
}
|
|
14687
|
+
const prepared = [
|
|
14688
|
+
"staged",
|
|
14689
|
+
"preflight",
|
|
14690
|
+
"approved",
|
|
14691
|
+
"dispatching",
|
|
14692
|
+
"applying",
|
|
14693
|
+
"verifying",
|
|
14694
|
+
"complete",
|
|
14695
|
+
"recovery_required",
|
|
14696
|
+
"rolled_back"
|
|
14697
|
+
].includes(record2.phase);
|
|
14698
|
+
if (prepared && record2.stages.length !== record2.targets.length)
|
|
14699
|
+
fail("Update is not completely staged");
|
|
14700
|
+
if ([
|
|
14701
|
+
"preflight",
|
|
14702
|
+
"approved",
|
|
14703
|
+
"dispatching",
|
|
14704
|
+
"applying",
|
|
14705
|
+
"verifying",
|
|
14706
|
+
"complete",
|
|
14707
|
+
"recovery_required",
|
|
14708
|
+
"rolled_back"
|
|
14709
|
+
].includes(record2.phase) && !record2.preflight)
|
|
14710
|
+
fail("Update requires preflight evidence");
|
|
14711
|
+
if ([
|
|
14712
|
+
"approved",
|
|
14713
|
+
"dispatching",
|
|
14714
|
+
"applying",
|
|
14715
|
+
"verifying",
|
|
14716
|
+
"complete",
|
|
14717
|
+
"recovery_required",
|
|
14718
|
+
"rolled_back"
|
|
14719
|
+
].includes(record2.phase) && record2.approved !== record2.preflight)
|
|
14720
|
+
fail("Update approval does not match preflight");
|
|
14721
|
+
if ([
|
|
14722
|
+
"dispatching",
|
|
14723
|
+
"applying",
|
|
14724
|
+
"verifying",
|
|
14725
|
+
"complete",
|
|
14726
|
+
"recovery_required",
|
|
14727
|
+
"rolled_back"
|
|
14728
|
+
].includes(record2.phase) && !record2.dispatch_id)
|
|
14729
|
+
fail("Update requires a recorded dispatch");
|
|
14730
|
+
if (["applying", "verifying", "complete"].includes(record2.phase) && !record2.worker_id)
|
|
14731
|
+
fail("Update requires a claimed worker");
|
|
14732
|
+
if (["complete", "rolled_back"].includes(record2.phase) && !record2.verification)
|
|
14733
|
+
fail("Update requires verification evidence");
|
|
14734
|
+
});
|
|
14735
|
+
var HOST_UPDATE_HISTORY_LIMIT = 32;
|
|
14736
|
+
var HOST_UPDATE_RECORD_BYTES = 512 * 1024;
|
|
14737
|
+
var hostUpdateLedgerSchema = external_exports.object({
|
|
14738
|
+
format: external_exports.literal(1),
|
|
14739
|
+
current: hostUpdateOperationSchema.nullable(),
|
|
14740
|
+
history: external_exports.array(hostUpdateOperationSchema).max(HOST_UPDATE_HISTORY_LIMIT)
|
|
14741
|
+
}).strict().superRefine((ledger, context) => {
|
|
14742
|
+
const ids = [ledger.current?.id, ...ledger.history.map((operation2) => operation2.id)].filter(
|
|
14743
|
+
Boolean
|
|
14744
|
+
);
|
|
14745
|
+
if (new Set(ids).size !== ids.length || ledger.history.some((operation2) => !hostUpdateTerminal(operation2.phase)))
|
|
14746
|
+
context.addIssue({ code: "custom", message: "Invalid update history" });
|
|
14747
|
+
});
|
|
14748
|
+
function hostUpdateTerminal(phase) {
|
|
14749
|
+
return ["complete", "blocked", "cancelled", "superseded", "failed", "rolled_back"].includes(
|
|
14750
|
+
phase
|
|
14751
|
+
);
|
|
14752
|
+
}
|
|
14753
|
+
|
|
14754
|
+
// ../shared/src/installation/catalogue.ts
|
|
14755
|
+
var releaseRepositorySchema = external_exports.string().max(201).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9_.-]+$/).refine((value) => ![".", ".."].includes(value.split("/")[1]));
|
|
14756
|
+
var timestamp2 = external_exports.number().int().nonnegative().safe();
|
|
14757
|
+
var hostReleaseCheckSchema = external_exports.object({
|
|
14758
|
+
repository: releaseRepositorySchema.nullable(),
|
|
14759
|
+
state: external_exports.enum(["unconfigured", "checking", "ready", "failed"]),
|
|
14760
|
+
checked_at: timestamp2.nullable(),
|
|
14761
|
+
succeeded_at: timestamp2.nullable(),
|
|
14762
|
+
latest: external_exports.object({
|
|
14763
|
+
version: external_exports.string().max(128).regex(/^[0-9]+\.[0-9]+\.[0-9]+$/),
|
|
14764
|
+
host_asset: external_exports.boolean()
|
|
14765
|
+
}).strict().nullable()
|
|
14766
|
+
}).strict();
|
|
14767
|
+
var component = external_exports.object({
|
|
14768
|
+
version: external_exports.string().min(1).max(128),
|
|
14769
|
+
protocol: hostStageRecordSchema.shape.protocol
|
|
14770
|
+
});
|
|
14771
|
+
var count = external_exports.number().int().nonnegative().max(4096);
|
|
14772
|
+
var hostUpdateCatalogueSchema = external_exports.object({
|
|
14773
|
+
observed_at: timestamp2,
|
|
14774
|
+
daemon_version: external_exports.string().min(1).max(128),
|
|
14775
|
+
runtime_default: component.strict().nullable(),
|
|
14776
|
+
runtimes: external_exports.object({
|
|
14777
|
+
complete: external_exports.boolean(),
|
|
14778
|
+
versions: external_exports.array(component.extend({ running: count, starting: count, unavailable: count }).strict()).max(128)
|
|
14779
|
+
}).strict(),
|
|
14780
|
+
releases: hostReleaseCheckSchema
|
|
14781
|
+
}).strict();
|
|
14782
|
+
|
|
14783
|
+
// ../shared/src/api/connection/host-updates.ts
|
|
14784
|
+
var hostUpdateReferenceSchema = external_exports.object({
|
|
14785
|
+
id: hostUpdateOperationSchema.shape.id,
|
|
14786
|
+
revision: hostUpdateOperationSchema.shape.revision
|
|
14787
|
+
}).strict();
|
|
14788
|
+
var hostUpdateFingerprintSchema = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
14789
|
+
var reference = hostUpdateReferenceSchema;
|
|
14790
|
+
var fingerprint2 = hostUpdateFingerprintSchema;
|
|
14791
|
+
var hostUpdateCommandSchema = external_exports.discriminatedUnion("action", [
|
|
14792
|
+
external_exports.object({
|
|
14793
|
+
action: external_exports.literal("status"),
|
|
14794
|
+
id: external_exports.uuid().optional(),
|
|
14795
|
+
/** Fresh private worker observation; never authorises activation. */
|
|
14796
|
+
adoption_nonce: external_exports.uuid().optional(),
|
|
14797
|
+
/** Recorded continuation metadata, capability-detected from application 25.12. */
|
|
14798
|
+
include_recovery: external_exports.literal(true).optional(),
|
|
14799
|
+
/** Host-wide versions and coalesced release discovery (25.14), never admission evidence. */
|
|
14800
|
+
include_catalogue: external_exports.literal(true).optional()
|
|
14801
|
+
}).strict().refine(
|
|
14802
|
+
(command) => !command.adoption_nonce || command.id !== void 0,
|
|
14803
|
+
"Adoption inspection requires an exact operation"
|
|
14804
|
+
),
|
|
14805
|
+
external_exports.object({ action: external_exports.literal("begin"), targets: hostUpdateTargetsSchema }).strict(),
|
|
14806
|
+
external_exports.object({ action: external_exports.literal("stage"), reference, receipt: hostStageReceiptSchema }).strict(),
|
|
14807
|
+
external_exports.object({
|
|
14808
|
+
action: external_exports.literal("recover"),
|
|
14809
|
+
reference,
|
|
14810
|
+
strategy: external_exports.enum(["verify-completion", "continue"])
|
|
14811
|
+
}).strict(),
|
|
14812
|
+
external_exports.object({
|
|
14813
|
+
action: external_exports.literal("inspect"),
|
|
14814
|
+
reference,
|
|
14815
|
+
cockpit: hostStageRecordSchema.shape.protocol
|
|
14816
|
+
}).strict(),
|
|
14817
|
+
external_exports.object({
|
|
14818
|
+
action: external_exports.literal("apply"),
|
|
14819
|
+
reference,
|
|
14820
|
+
cockpit: hostStageRecordSchema.shape.protocol,
|
|
14821
|
+
fingerprint: fingerprint2,
|
|
14822
|
+
/** Explicit consent to the exact reviewed daemon-owned interruption inventory (25.10). */
|
|
14823
|
+
interruption_approval: fingerprint2.optional()
|
|
14824
|
+
}).strict(),
|
|
14825
|
+
external_exports.object({
|
|
14826
|
+
action: external_exports.literal("cancel"),
|
|
14827
|
+
reference,
|
|
14828
|
+
reason: external_exports.enum(["cancelled", "staging_failed"])
|
|
14829
|
+
}).strict()
|
|
14830
|
+
]);
|
|
14831
|
+
var hostUpdateReviewSchema = external_exports.object({
|
|
14832
|
+
fingerprint: fingerprint2.nullable(),
|
|
14833
|
+
can_apply: external_exports.boolean(),
|
|
14834
|
+
/** Never makes can_apply true; only a matching explicit apply approval permits interruption. */
|
|
14835
|
+
interruption_fingerprint: fingerprint2.optional(),
|
|
14836
|
+
blockers: external_exports.array(external_exports.object({ code: external_exports.string().min(1).max(64), target: external_exports.string().max(4096) }).strict()).max(32),
|
|
14837
|
+
more_blockers: external_exports.number().int().nonnegative().safe(),
|
|
14838
|
+
affected: external_exports.object({
|
|
14839
|
+
terminals: external_exports.number().int().nonnegative().safe(),
|
|
14840
|
+
notebooks: external_exports.number().int().nonnegative().safe(),
|
|
14841
|
+
compilation: external_exports.number().int().nonnegative().safe(),
|
|
14842
|
+
programmes: external_exports.number().int().nonnegative().safe()
|
|
14843
|
+
}).strict()
|
|
14844
|
+
}).strict();
|
|
14845
|
+
var hostUpdateRecoveryStatusSchema = external_exports.object({
|
|
14846
|
+
id: external_exports.uuid(),
|
|
14847
|
+
requested_revision: hostUpdateOperationSchema.shape.revision,
|
|
14848
|
+
revision: hostUpdateOperationSchema.shape.revision,
|
|
14849
|
+
/** Durable consumption, not a claim that the worker is still running or completed. */
|
|
14850
|
+
consumed: external_exports.boolean()
|
|
14851
|
+
}).strict();
|
|
14852
|
+
var hostUpdateReplySchema = external_exports.discriminatedUnion("ok", [
|
|
14853
|
+
external_exports.object({
|
|
14854
|
+
ok: external_exports.literal(true),
|
|
14855
|
+
operation: hostUpdateOperationSchema.nullable(),
|
|
14856
|
+
created: external_exports.boolean().optional(),
|
|
14857
|
+
review: hostUpdateReviewSchema.optional(),
|
|
14858
|
+
recovery: hostUpdateRecoveryStatusSchema.optional(),
|
|
14859
|
+
catalogue: hostUpdateCatalogueSchema.optional()
|
|
14860
|
+
}).strict(),
|
|
14861
|
+
external_exports.object({
|
|
14862
|
+
ok: external_exports.literal(false),
|
|
14863
|
+
code: external_exports.enum(["rejected", "unavailable", "unsupported", "conflict", "failed"]),
|
|
14864
|
+
operation: hostUpdateOperationSchema.nullable()
|
|
14865
|
+
}).strict()
|
|
14866
|
+
]);
|
|
14867
|
+
var hostUpdateControlRequestSchema = external_exports.object({ t: external_exports.literal("host-update"), request_id: external_exports.uuid(), command: hostUpdateCommandSchema }).strict();
|
|
14868
|
+
var hostUpdateControlResponseSchema = external_exports.object({
|
|
14869
|
+
t: external_exports.literal("host-update-result"),
|
|
14870
|
+
request_id: external_exports.uuid(),
|
|
14871
|
+
result: hostUpdateReplySchema
|
|
14872
|
+
}).strict();
|
|
14873
|
+
|
|
14874
|
+
// ../shared/src/api/connection/connector-inspection.ts
|
|
14875
|
+
var connectorInspectionRequestSchema = external_exports.object({ t: external_exports.literal("inspect"), nonce: external_exports.uuid() }).strict();
|
|
14876
|
+
var connectorInspectionResponseSchema = external_exports.object({
|
|
14877
|
+
t: external_exports.literal("inspection"),
|
|
14878
|
+
nonce: external_exports.uuid(),
|
|
14879
|
+
instance: external_exports.uuid(),
|
|
14880
|
+
ready: external_exports.boolean(),
|
|
14881
|
+
pid: external_exports.number().int().positive().safe(),
|
|
14882
|
+
version: external_exports.string().min(1).max(128),
|
|
14883
|
+
application: hostStageRecordSchema.shape.protocol,
|
|
14884
|
+
remote: external_exports.number().int().nonnegative().safe(),
|
|
14885
|
+
node_path: external_exports.string().min(1).max(4096),
|
|
14886
|
+
entry_path: external_exports.string().min(1).max(4096),
|
|
14887
|
+
release_path: external_exports.string().min(1).max(4096)
|
|
14888
|
+
}).strip();
|
|
14889
|
+
|
|
14589
14890
|
// ../shared/src/api/agents/agent-signal.ts
|
|
14590
14891
|
var statusSignalSchema = external_exports.object({
|
|
14591
14892
|
nonce: external_exports.string().min(16),
|
|
@@ -15492,7 +15793,7 @@ var notebookKernelsResponseSchema = external_exports.object({
|
|
|
15492
15793
|
error: external_exports.string().optional()
|
|
15493
15794
|
});
|
|
15494
15795
|
var notebookKernelRequestSchema = external_exports.object({ source: compilationFileTargetSchema });
|
|
15495
|
-
var pythonPathSchema = external_exports.string().trim().min(1).max(4096).refine((
|
|
15796
|
+
var pythonPathSchema = external_exports.string().trim().min(1).max(4096).refine((path2) => !path2.includes("\0"));
|
|
15496
15797
|
var notebookEnvironmentSchema = external_exports.object({
|
|
15497
15798
|
python: pythonPathSchema,
|
|
15498
15799
|
label: external_exports.string(),
|
|
@@ -15828,7 +16129,92 @@ var cockpitFileManagerSchema = external_exports.object({
|
|
|
15828
16129
|
name: external_exports.enum(["Finder", "File Explorer", "File Manager"]).nullable()
|
|
15829
16130
|
});
|
|
15830
16131
|
var cockpitRevealRequestSchema = external_exports.object({
|
|
15831
|
-
path: external_exports.string().min(1).max(4096).refine((
|
|
16132
|
+
path: external_exports.string().min(1).max(4096).refine((path2) => !path2.includes("\0"))
|
|
16133
|
+
}).strict();
|
|
16134
|
+
|
|
16135
|
+
// ../shared/src/api/connection/cockpit-updates.ts
|
|
16136
|
+
var onlineHostUpdateRequestSchema = external_exports.discriminatedUnion("action", [
|
|
16137
|
+
external_exports.object({ action: external_exports.literal("prepare"), targets: hostUpdateTargetsSchema }).strict(),
|
|
16138
|
+
external_exports.object({ action: external_exports.literal("inspect"), reference: hostUpdateReferenceSchema }).strict(),
|
|
16139
|
+
external_exports.object({
|
|
16140
|
+
action: external_exports.literal("apply"),
|
|
16141
|
+
reference: hostUpdateReferenceSchema,
|
|
16142
|
+
fingerprint: hostUpdateFingerprintSchema,
|
|
16143
|
+
interruption_approval: hostUpdateFingerprintSchema.optional()
|
|
16144
|
+
}).strict(),
|
|
16145
|
+
external_exports.object({ action: external_exports.literal("cancel"), reference: hostUpdateReferenceSchema }).strict(),
|
|
16146
|
+
external_exports.object({
|
|
16147
|
+
action: external_exports.literal("recover"),
|
|
16148
|
+
reference: hostUpdateReferenceSchema,
|
|
16149
|
+
strategy: external_exports.enum(["verify-completion", "continue"])
|
|
16150
|
+
}).strict()
|
|
16151
|
+
]);
|
|
16152
|
+
var cockpitHostUpdateRequestSchema = external_exports.discriminatedUnion("action", [
|
|
16153
|
+
...onlineHostUpdateRequestSchema.options,
|
|
16154
|
+
external_exports.object({ action: external_exports.literal("continue-offline"), reference: hostUpdateReferenceSchema }).strict()
|
|
16155
|
+
]);
|
|
16156
|
+
var cockpitHostUpdateQuerySchema = external_exports.object({ id: external_exports.uuid().optional() }).strict();
|
|
16157
|
+
var operation = hostUpdateOperationSchema.shape;
|
|
16158
|
+
var cockpitHostUpdateOperationSchema = external_exports.object({
|
|
16159
|
+
id: operation.id,
|
|
16160
|
+
revision: operation.revision,
|
|
16161
|
+
created_at: operation.created_at,
|
|
16162
|
+
updated_at: operation.updated_at,
|
|
16163
|
+
phase: operation.phase,
|
|
16164
|
+
targets: operation.targets,
|
|
16165
|
+
staged: external_exports.boolean(),
|
|
16166
|
+
dispatched: external_exports.boolean(),
|
|
16167
|
+
message: operation.message
|
|
16168
|
+
}).strict();
|
|
16169
|
+
var cockpitHostUpdateReviewSchema = hostUpdateReviewSchema.extend({
|
|
16170
|
+
blockers: external_exports.array(external_exports.object({ code: external_exports.string().min(1).max(64) }).strict()).max(32)
|
|
16171
|
+
});
|
|
16172
|
+
var cockpitHostUpdateReplySchema = external_exports.discriminatedUnion("ok", [
|
|
16173
|
+
external_exports.object({
|
|
16174
|
+
ok: external_exports.literal(true),
|
|
16175
|
+
operation: cockpitHostUpdateOperationSchema.nullable(),
|
|
16176
|
+
review: cockpitHostUpdateReviewSchema.optional(),
|
|
16177
|
+
recovery: hostUpdateRecoveryStatusSchema.optional()
|
|
16178
|
+
}).strict(),
|
|
16179
|
+
external_exports.object({
|
|
16180
|
+
ok: external_exports.literal(false),
|
|
16181
|
+
code: external_exports.enum(["rejected", "unavailable", "unsupported", "conflict", "failed"]),
|
|
16182
|
+
operation: cockpitHostUpdateOperationSchema.nullable()
|
|
16183
|
+
}).strict()
|
|
16184
|
+
]);
|
|
16185
|
+
var cockpitHostUpdateStatusSchema = external_exports.object({
|
|
16186
|
+
availability: external_exports.enum(["ready", "unavailable", "upgrade_required"]),
|
|
16187
|
+
/** Recorded operations do not establish current service health or adoption. */
|
|
16188
|
+
observation: external_exports.enum(["live", "recorded"]).optional(),
|
|
16189
|
+
daemon_version: external_exports.string().max(128).nullable(),
|
|
16190
|
+
capabilities: external_exports.object({
|
|
16191
|
+
interruption_approval: external_exports.boolean(),
|
|
16192
|
+
verify_completion: external_exports.boolean(),
|
|
16193
|
+
continue_recovery: external_exports.boolean(),
|
|
16194
|
+
offline_continuation: external_exports.boolean().optional()
|
|
16195
|
+
}).strict(),
|
|
16196
|
+
result: cockpitHostUpdateReplySchema.nullable(),
|
|
16197
|
+
catalogue: hostUpdateCatalogueSchema.optional()
|
|
16198
|
+
}).strict();
|
|
16199
|
+
|
|
16200
|
+
// ../shared/src/api/connection/host-maintenance.ts
|
|
16201
|
+
var hostMaintenanceCommandSchema = external_exports.discriminatedUnion("action", [
|
|
16202
|
+
external_exports.object({ action: external_exports.literal("status"), id: external_exports.uuid().optional() }).strict(),
|
|
16203
|
+
...onlineHostUpdateRequestSchema.options
|
|
16204
|
+
]);
|
|
16205
|
+
var hostMaintenanceReplySchema = external_exports.discriminatedUnion("kind", [
|
|
16206
|
+
external_exports.object({ kind: external_exports.literal("status"), status: cockpitHostUpdateStatusSchema }).strict(),
|
|
16207
|
+
external_exports.object({ kind: external_exports.literal("result"), result: cockpitHostUpdateReplySchema }).strict()
|
|
16208
|
+
]);
|
|
16209
|
+
var hostMaintenanceControlRequestSchema = external_exports.object({
|
|
16210
|
+
t: external_exports.literal("host-maintenance"),
|
|
16211
|
+
request_id: external_exports.uuid(),
|
|
16212
|
+
command: hostMaintenanceCommandSchema
|
|
16213
|
+
}).strict();
|
|
16214
|
+
var hostMaintenanceControlResponseSchema = external_exports.object({
|
|
16215
|
+
t: external_exports.literal("host-maintenance-result"),
|
|
16216
|
+
request_id: external_exports.uuid(),
|
|
16217
|
+
result: hostMaintenanceReplySchema
|
|
15832
16218
|
}).strict();
|
|
15833
16219
|
|
|
15834
16220
|
// ../shared/src/ws/messages.ts
|
|
@@ -15866,6 +16252,8 @@ var wsClientMessageSchema = external_exports.discriminatedUnion("t", [
|
|
|
15866
16252
|
})
|
|
15867
16253
|
]);
|
|
15868
16254
|
var wsServerMessageSchema = external_exports.discriminatedUnion("t", [
|
|
16255
|
+
/** Host-wide invalidation only; profile-scoped remote leases never receive it. */
|
|
16256
|
+
external_exports.object({ t: external_exports.literal("host-updates-changed") }),
|
|
15869
16257
|
agentNotificationSchema,
|
|
15870
16258
|
external_exports.object({ t: external_exports.literal("authenticated") }),
|
|
15871
16259
|
external_exports.object({ t: external_exports.literal("shell-spawned"), session: external_exports.string(), term: external_exports.string() }),
|
|
@@ -15913,8 +16301,10 @@ var wsServerMessageSchema = external_exports.discriminatedUnion("t", [
|
|
|
15913
16301
|
]);
|
|
15914
16302
|
|
|
15915
16303
|
// ../shared/src/remote/protocol.ts
|
|
15916
|
-
var REMOTE_PROTOCOL_VERSION =
|
|
16304
|
+
var REMOTE_PROTOCOL_VERSION = 5;
|
|
15917
16305
|
var REMOTE_POLICY = {
|
|
16306
|
+
/** Two sequential bounded host stages; participation remains required throughout. */
|
|
16307
|
+
maintenanceRequestMs: 3e5,
|
|
15918
16308
|
chunkBytes: 32 * 1024,
|
|
15919
16309
|
frameBytes: 48 * 1024,
|
|
15920
16310
|
requestBytes: 256 * 1024,
|
|
@@ -15958,6 +16348,7 @@ var relayMessageSchema = external_exports.discriminatedUnion("t", [
|
|
|
15958
16348
|
external_exports.object({ t: external_exports.literal("ready"), connection: remoteIdSchema, account: remoteAccountSchema }).strict()
|
|
15959
16349
|
]);
|
|
15960
16350
|
var remoteDeviceSchema = external_exports.object({
|
|
16351
|
+
maintenance: external_exports.boolean().optional(),
|
|
15961
16352
|
id: remoteIdSchema,
|
|
15962
16353
|
peer: remotePeerSchema,
|
|
15963
16354
|
account: remoteAccountSchema,
|
|
@@ -16034,6 +16425,15 @@ var remoteChunkSchema = external_exports.object({
|
|
|
16034
16425
|
data: external_exports.string().max(REMOTE_POLICY.chunkBytes)
|
|
16035
16426
|
}).strict();
|
|
16036
16427
|
|
|
16428
|
+
// ../shared/src/remote/maintenance.ts
|
|
16429
|
+
var remoteMaintenanceClaimSchema = external_exports.object({
|
|
16430
|
+
device: remoteIdSchema,
|
|
16431
|
+
peer: remotePeerSchema,
|
|
16432
|
+
account: remoteAccountSchema,
|
|
16433
|
+
host: remoteIdSchema,
|
|
16434
|
+
grant: remoteIdSchema
|
|
16435
|
+
}).strict();
|
|
16436
|
+
|
|
16037
16437
|
// ../shared/src/remote/service.ts
|
|
16038
16438
|
var remoteHostSchema = external_exports.object({
|
|
16039
16439
|
id: remoteIdSchema,
|
|
@@ -16098,7 +16498,8 @@ var remoteBrowserHostSchema = external_exports.object({
|
|
|
16098
16498
|
// ../shared/src/api/connection/cockpit-remote.ts
|
|
16099
16499
|
var connectorLocalRequestSchema = external_exports.union([
|
|
16100
16500
|
remoteAdminRequestSchema,
|
|
16101
|
-
external_exports.object({ t: external_exports.literal("delete_registration") }).strict()
|
|
16501
|
+
external_exports.object({ t: external_exports.literal("delete_registration") }).strict(),
|
|
16502
|
+
external_exports.object({ t: external_exports.literal("maintenance"), id: remoteIdSchema, enabled: external_exports.boolean() }).strict()
|
|
16102
16503
|
]);
|
|
16103
16504
|
var cockpitRemoteRequestSchema = external_exports.union([
|
|
16104
16505
|
connectorLocalRequestSchema,
|
|
@@ -16115,6 +16516,7 @@ var cockpitRemoteStatusSchema = external_exports.object({
|
|
|
16115
16516
|
enabled: external_exports.boolean(),
|
|
16116
16517
|
connected: external_exports.boolean(),
|
|
16117
16518
|
canDeleteRegistration: external_exports.boolean().optional(),
|
|
16519
|
+
canManageMaintenance: external_exports.boolean().optional(),
|
|
16118
16520
|
supervisor: external_exports.enum(["systemd", "launchd"]).nullable(),
|
|
16119
16521
|
host: remoteIdSchema.optional(),
|
|
16120
16522
|
peer: remotePeerSchema.optional(),
|
|
@@ -16147,7 +16549,13 @@ var authErrorCodeSchema = external_exports.enum([
|
|
|
16147
16549
|
"protocol_mismatch"
|
|
16148
16550
|
]);
|
|
16149
16551
|
var controlRequestSchema = external_exports.discriminatedUnion("t", [
|
|
16150
|
-
|
|
16552
|
+
hostUpdateControlRequestSchema,
|
|
16553
|
+
hostMaintenanceControlRequestSchema,
|
|
16554
|
+
external_exports.object({
|
|
16555
|
+
t: external_exports.literal("open"),
|
|
16556
|
+
profile: profileId.optional(),
|
|
16557
|
+
maintenance: remoteMaintenanceClaimSchema.optional()
|
|
16558
|
+
}).strict(),
|
|
16151
16559
|
external_exports.object({ t: external_exports.literal("renew"), resources: external_exports.array(resourceIdSchema).max(2048) }).strict(),
|
|
16152
16560
|
external_exports.object({ t: external_exports.literal("close") }).strict()
|
|
16153
16561
|
]);
|
|
@@ -16158,6 +16566,8 @@ var hostInspectionSchema = external_exports.object({
|
|
|
16158
16566
|
liveSessions: external_exports.number().int().nonnegative()
|
|
16159
16567
|
});
|
|
16160
16568
|
var controlResponseSchema = external_exports.discriminatedUnion("t", [
|
|
16569
|
+
hostUpdateControlResponseSchema,
|
|
16570
|
+
hostMaintenanceControlResponseSchema,
|
|
16161
16571
|
external_exports.object({
|
|
16162
16572
|
t: external_exports.literal("authority"),
|
|
16163
16573
|
generation: external_exports.string().uuid(),
|
|
@@ -16379,6 +16789,44 @@ var puddlangContextSchema = external_exports.object({
|
|
|
16379
16789
|
)
|
|
16380
16790
|
});
|
|
16381
16791
|
|
|
16792
|
+
// ../shared/src/api/agents/puddlang-outcomes.ts
|
|
16793
|
+
var puddlangOutcomeOperationSchema = external_exports.number().int().safe();
|
|
16794
|
+
var puddlangOutcomeActionSchema = external_exports.enum(["read", "discard"]);
|
|
16795
|
+
var fingerprint3 = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
16796
|
+
var terminalStatus = external_exports.enum(["completed", "failed", "cancelled", "interrupted"]);
|
|
16797
|
+
var puddlangOutcomeDispositionSchema = external_exports.object({
|
|
16798
|
+
action: puddlangOutcomeActionSchema,
|
|
16799
|
+
fingerprint: fingerprint3,
|
|
16800
|
+
at: external_exports.iso.datetime()
|
|
16801
|
+
}).strict();
|
|
16802
|
+
var puddlangOutcomeSchema = external_exports.object({
|
|
16803
|
+
operation_id: puddlangOutcomeOperationSchema,
|
|
16804
|
+
runtime_id: external_exports.uuid(),
|
|
16805
|
+
turn: external_exports.number().int().positive().safe(),
|
|
16806
|
+
status: external_exports.enum(["running", "completed", "failed", "cancelled", "interrupted", "unavailable"]),
|
|
16807
|
+
retained: external_exports.boolean(),
|
|
16808
|
+
consumed: external_exports.boolean().nullable(),
|
|
16809
|
+
fingerprint: fingerprint3.nullable(),
|
|
16810
|
+
disposition: puddlangOutcomeDispositionSchema.nullable()
|
|
16811
|
+
}).strict();
|
|
16812
|
+
var puddlangOutcomesSchema = external_exports.object({
|
|
16813
|
+
outcomes: external_exports.array(puddlangOutcomeSchema).max(50),
|
|
16814
|
+
next_after: puddlangOutcomeOperationSchema.nullable()
|
|
16815
|
+
}).strict();
|
|
16816
|
+
var puddlangOutcomeRequestSchema = external_exports.object({
|
|
16817
|
+
action: puddlangOutcomeActionSchema,
|
|
16818
|
+
fingerprint: fingerprint3
|
|
16819
|
+
}).strict();
|
|
16820
|
+
var puddlangOutcomeResponseSchema = external_exports.object({
|
|
16821
|
+
outcome: puddlangOutcomeSchema,
|
|
16822
|
+
// Explicit reads only. Native references and prompts are never projected here.
|
|
16823
|
+
result: external_exports.object({
|
|
16824
|
+
status: terminalStatus,
|
|
16825
|
+
reply: external_exports.string().max(256 * 1024).optional(),
|
|
16826
|
+
error: external_exports.string().max(4096).optional()
|
|
16827
|
+
}).strict().nullable()
|
|
16828
|
+
}).strict();
|
|
16829
|
+
|
|
16382
16830
|
// ../shared/src/api/agents/puddlang-mcp.ts
|
|
16383
16831
|
var puddlangMcpRequestSchema = external_exports.object({
|
|
16384
16832
|
jsonrpc: external_exports.literal("2.0"),
|
|
@@ -16396,6 +16844,13 @@ var puddlangMcpEventsSchema = puddlangMcpIdSchema.extend({
|
|
|
16396
16844
|
after: external_exports.number().int().nonnegative().default(0)
|
|
16397
16845
|
});
|
|
16398
16846
|
var puddlangMcpEmptySchema = external_exports.object({}).strict();
|
|
16847
|
+
var puddlangMcpOutcomesSchema = puddlangMcpIdSchema.extend({
|
|
16848
|
+
after: puddlangOutcomeOperationSchema.optional()
|
|
16849
|
+
}).strict();
|
|
16850
|
+
var puddlangMcpOutcomeSchema = puddlangOutcomeRequestSchema.extend({
|
|
16851
|
+
id: external_exports.uuid(),
|
|
16852
|
+
operation: puddlangOutcomeOperationSchema
|
|
16853
|
+
}).strict();
|
|
16399
16854
|
var definitions = [
|
|
16400
16855
|
[
|
|
16401
16856
|
"puddlang_context",
|
|
@@ -16426,6 +16881,18 @@ var definitions = [
|
|
|
16426
16881
|
"Cancel a run, interrupt its pending asks, and stop agents it created. Attached agents are retained.",
|
|
16427
16882
|
puddlangMcpIdSchema,
|
|
16428
16883
|
false
|
|
16884
|
+
],
|
|
16885
|
+
[
|
|
16886
|
+
"puddlang_outcomes",
|
|
16887
|
+
"Inspect up to 50 retained outcome identities for a run without reading reply text or releasing retention. Use next_after to paginate. Requires application 26.1+.",
|
|
16888
|
+
puddlangMcpOutcomesSchema,
|
|
16889
|
+
true
|
|
16890
|
+
],
|
|
16891
|
+
[
|
|
16892
|
+
"puddlang_outcome",
|
|
16893
|
+
"Explicitly read or discard one unchanged terminal outcome of a finished programme, using its inspected fingerprint. Both actions release retention for later reclamation and create a metadata-only audit. No programme or prompt is replayed. Repeating the same disposition observes it; a reclaimed reply is unavailable. Requires application 26.1+.",
|
|
16894
|
+
puddlangMcpOutcomeSchema,
|
|
16895
|
+
false
|
|
16429
16896
|
]
|
|
16430
16897
|
];
|
|
16431
16898
|
var puddlangMcpTools = definitions.map(([name, description, schema, readOnlyHint]) => ({
|
|
@@ -16572,6 +17039,1030 @@ var storageStatusSchema = external_exports.object({
|
|
|
16572
17039
|
database_degraded: external_exports.boolean()
|
|
16573
17040
|
});
|
|
16574
17041
|
|
|
17042
|
+
// ../shared/src/runtime/protocol.ts
|
|
17043
|
+
var RUNTIME_PROTOCOL_VERSION = { major: 1, minor: 0 };
|
|
17044
|
+
var RUNTIME_LIMITS = {
|
|
17045
|
+
frameBytes: 8 * 1024 * 1024,
|
|
17046
|
+
inputBytes: 64 * 1024,
|
|
17047
|
+
outputBytes: 256 * 1024,
|
|
17048
|
+
pendingRequests: 64,
|
|
17049
|
+
queuedBytes: 16 * 1024 * 1024,
|
|
17050
|
+
requestMs: 15e3,
|
|
17051
|
+
handshakeMs: 5e3,
|
|
17052
|
+
terminals: 32,
|
|
17053
|
+
journalEvents: 4096,
|
|
17054
|
+
journalBytes: 2 * 1024 * 1024,
|
|
17055
|
+
eventPage: 256,
|
|
17056
|
+
turnPromptBytes: 64 * 1024,
|
|
17057
|
+
turnReplyBytes: 256 * 1024,
|
|
17058
|
+
environmentVariables: 128,
|
|
17059
|
+
environmentValueBytes: 32 * 1024,
|
|
17060
|
+
historySegments: 256,
|
|
17061
|
+
historyLogBytes: 64 * 1024 * 1024,
|
|
17062
|
+
historyLogFiles: 1024,
|
|
17063
|
+
historySnapshotBytes: 64 * 1024 * 1024,
|
|
17064
|
+
pendingCheckpoints: 64,
|
|
17065
|
+
pendingCheckpointBytes: 16 * 1024 * 1024,
|
|
17066
|
+
launchRefs: 16384
|
|
17067
|
+
};
|
|
17068
|
+
var id2 = external_exports.uuid();
|
|
17069
|
+
var sequence = external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
17070
|
+
var text = external_exports.string().max(4096);
|
|
17071
|
+
var path = text.refine(
|
|
17072
|
+
(value) => value.startsWith("/") && !value.includes("\0"),
|
|
17073
|
+
"Absolute host path required"
|
|
17074
|
+
);
|
|
17075
|
+
var protocol = external_exports.object({ major: sequence, minor: sequence });
|
|
17076
|
+
var terminalName = external_exports.string().regex(/^(agent|shell-[1-9][0-9]{0,5})$/);
|
|
17077
|
+
var size = { cols: external_exports.number().int().min(1).max(1e3), rows: external_exports.number().int().min(1).max(1e3) };
|
|
17078
|
+
var environmentName = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(256);
|
|
17079
|
+
var environmentValue = external_exports.string().max(RUNTIME_LIMITS.environmentValueBytes).refine(
|
|
17080
|
+
(value) => !value.includes("\0") && new TextEncoder().encode(value).length <= RUNTIME_LIMITS.environmentValueBytes
|
|
17081
|
+
);
|
|
17082
|
+
var runtimeEnvDeltaSchema = external_exports.discriminatedUnion("op", [
|
|
17083
|
+
external_exports.object({ op: external_exports.literal("unset"), name: environmentName }),
|
|
17084
|
+
external_exports.object({
|
|
17085
|
+
op: external_exports.literal("set"),
|
|
17086
|
+
name: environmentName,
|
|
17087
|
+
value: environmentValue
|
|
17088
|
+
})
|
|
17089
|
+
]);
|
|
17090
|
+
var runtimeCaptureSchema = external_exports.object({
|
|
17091
|
+
enabled: external_exports.boolean(),
|
|
17092
|
+
values: external_exports.record(environmentName, environmentValue).refine((values) => Object.keys(values).length <= RUNTIME_LIMITS.environmentVariables)
|
|
17093
|
+
});
|
|
17094
|
+
var runtimeEnvironmentStateSchema = external_exports.object({
|
|
17095
|
+
enabled: external_exports.boolean(),
|
|
17096
|
+
count: external_exports.number().int().min(0).max(RUNTIME_LIMITS.environmentVariables)
|
|
17097
|
+
});
|
|
17098
|
+
var runtimeIdentitySchema = external_exports.object({
|
|
17099
|
+
runtime_id: id2,
|
|
17100
|
+
incarnation: id2,
|
|
17101
|
+
launch_id: id2,
|
|
17102
|
+
profile_id: external_exports.string().regex(/^[a-f0-9]{10}$/),
|
|
17103
|
+
project_id: external_exports.string().regex(/^[a-f0-9]{10}$/),
|
|
17104
|
+
session_id: id2,
|
|
17105
|
+
canonical_worktree_path: path
|
|
17106
|
+
});
|
|
17107
|
+
var runtimeTerminalSchema = external_exports.object({
|
|
17108
|
+
term: terminalName,
|
|
17109
|
+
generation: id2,
|
|
17110
|
+
pid: external_exports.number().int().positive().nullable(),
|
|
17111
|
+
exit_code: external_exports.number().int().nullable(),
|
|
17112
|
+
...size
|
|
17113
|
+
});
|
|
17114
|
+
var runtimeThemeSchema = external_exports.object({
|
|
17115
|
+
fg: external_exports.string().regex(/^#[0-9a-fA-F]{6}$/),
|
|
17116
|
+
bg: external_exports.string().regex(/^#[0-9a-fA-F]{6}$/)
|
|
17117
|
+
});
|
|
17118
|
+
var runtimeAttentionSchema = external_exports.object({
|
|
17119
|
+
id: id2,
|
|
17120
|
+
segment_id: id2,
|
|
17121
|
+
reason: external_exports.enum(["waiting_input", "exited"]),
|
|
17122
|
+
created_at: external_exports.iso.datetime().max(32)
|
|
17123
|
+
});
|
|
17124
|
+
var runtimeSegmentSchema = external_exports.object({
|
|
17125
|
+
id: id2,
|
|
17126
|
+
start_cursor: sequence,
|
|
17127
|
+
agent_session_ref: external_exports.string().min(1).max(200).nullable()
|
|
17128
|
+
});
|
|
17129
|
+
var runtimePlacementSchema = external_exports.object({ segment_id: id2, session_id: id2 });
|
|
17130
|
+
var runtimePlacementBindingSchema = runtimePlacementSchema.extend({ through: sequence });
|
|
17131
|
+
var runtimeCheckpointSchema = external_exports.object({
|
|
17132
|
+
format: external_exports.literal(1),
|
|
17133
|
+
identity: runtimeIdentitySchema,
|
|
17134
|
+
segment: runtimeSegmentSchema,
|
|
17135
|
+
through: sequence,
|
|
17136
|
+
terminal: runtimeTerminalSchema,
|
|
17137
|
+
data: external_exports.string().max(RUNTIME_LIMITS.frameBytes)
|
|
17138
|
+
}).refine((value) => value.through >= value.segment.start_cursor);
|
|
17139
|
+
var runtimeCommandSchema = external_exports.object({
|
|
17140
|
+
file: text.min(1).refine((value) => !value.includes("\0")),
|
|
17141
|
+
args: external_exports.array(
|
|
17142
|
+
external_exports.string().max(64 * 1024).refine((value) => !value.includes("\0"))
|
|
17143
|
+
).max(512),
|
|
17144
|
+
cwd: path,
|
|
17145
|
+
env: external_exports.record(
|
|
17146
|
+
external_exports.string().regex(/^[^=\0]+$/).max(256),
|
|
17147
|
+
external_exports.string().max(64 * 1024).refine((value) => !value.includes("\0"))
|
|
17148
|
+
).refine((value) => Object.keys(value).length <= 512, "Too many environment variables"),
|
|
17149
|
+
...size
|
|
17150
|
+
});
|
|
17151
|
+
var runtimeProviderLaunchSchema = external_exports.object({
|
|
17152
|
+
id: external_exports.string().min(1).max(64),
|
|
17153
|
+
config_dir: path,
|
|
17154
|
+
mode: external_exports.enum(["interactive", "headless"]),
|
|
17155
|
+
skip_permissions: external_exports.boolean(),
|
|
17156
|
+
prompt: external_exports.string().max(64 * 1024).optional(),
|
|
17157
|
+
resume_ref: external_exports.string().min(1).max(200).optional(),
|
|
17158
|
+
/** Exact adapter-declared id passed on a new preset-id launch, not a resume. */
|
|
17159
|
+
initial_ref: external_exports.string().min(1).max(200).optional(),
|
|
17160
|
+
/** Existing native ids before a minted-id launch; recovery must exclude them. */
|
|
17161
|
+
prior_refs: external_exports.array(external_exports.string().min(1).max(200)).max(RUNTIME_LIMITS.launchRefs).optional()
|
|
17162
|
+
}).refine(
|
|
17163
|
+
(value) => !(value.resume_ref && (value.initial_ref || value.prior_refs)),
|
|
17164
|
+
"A resume cannot carry new-launch identity evidence"
|
|
17165
|
+
);
|
|
17166
|
+
var runtimeLifecycleSchema = external_exports.object({
|
|
17167
|
+
event: external_exports.enum(["session_start", "session_end"]),
|
|
17168
|
+
agent_session_ref: external_exports.string().min(1).max(200).optional(),
|
|
17169
|
+
cwd: path,
|
|
17170
|
+
source: external_exports.enum(["startup", "resume", "clear", "fork", "compact", "exit", "other"]),
|
|
17171
|
+
parent_agent_session_ref: external_exports.string().min(1).max(200).optional(),
|
|
17172
|
+
native_title: external_exports.string().max(4096).optional(),
|
|
17173
|
+
native_created_at: external_exports.iso.datetime({ offset: true }).optional(),
|
|
17174
|
+
native_updated_at: external_exports.iso.datetime({ offset: true }).optional()
|
|
17175
|
+
}).refine(
|
|
17176
|
+
(value) => value.event !== "session_start" || value.agent_session_ref !== void 0,
|
|
17177
|
+
"A native start requires an exact conversation ref"
|
|
17178
|
+
);
|
|
17179
|
+
var runtimeAgentStateSchema = external_exports.object({
|
|
17180
|
+
provider: external_exports.string().min(1).max(64),
|
|
17181
|
+
native_sync: external_exports.enum(["full", "fallback"]),
|
|
17182
|
+
status: external_exports.enum(["starting", "running", "waiting_input", "exited"]),
|
|
17183
|
+
agent_session_ref: external_exports.string().min(1).max(200).nullable(),
|
|
17184
|
+
control_ready: external_exports.boolean(),
|
|
17185
|
+
sidecar_pids: external_exports.array(external_exports.number().int().positive()).max(32),
|
|
17186
|
+
hidden_ports: external_exports.array(external_exports.number().int().min(1).max(65535)).max(64)
|
|
17187
|
+
});
|
|
17188
|
+
var runtimeTurnSchema = external_exports.object({
|
|
17189
|
+
turn: sequence.refine((value) => value > 0),
|
|
17190
|
+
status: external_exports.enum(["running", "completed", "failed", "cancelled", "interrupted"]),
|
|
17191
|
+
/** Native identity at admission; a new headless conversation may initially have none. */
|
|
17192
|
+
expected_ref: external_exports.string().min(1).max(200).nullable()
|
|
17193
|
+
});
|
|
17194
|
+
var runtimeTurnResultSchema = runtimeTurnSchema.extend({
|
|
17195
|
+
reply: external_exports.string().max(RUNTIME_LIMITS.turnReplyBytes).refine((value) => new TextEncoder().encode(value).length <= RUNTIME_LIMITS.turnReplyBytes).optional(),
|
|
17196
|
+
error: external_exports.string().max(4096).optional()
|
|
17197
|
+
}).refine(
|
|
17198
|
+
(value) => value.status === "completed" ? value.reply !== void 0 && value.error === void 0 : value.reply === void 0 && (value.status === "running" ? value.error === void 0 : value.error !== void 0),
|
|
17199
|
+
"Turn outcome fields do not match its status"
|
|
17200
|
+
);
|
|
17201
|
+
var runtimeRetainedEventSchema = external_exports.discriminatedUnion("t", [
|
|
17202
|
+
external_exports.object({
|
|
17203
|
+
t: external_exports.literal("env-delta"),
|
|
17204
|
+
cursor: sequence,
|
|
17205
|
+
term: terminalName,
|
|
17206
|
+
generation: id2,
|
|
17207
|
+
delta: runtimeEnvDeltaSchema
|
|
17208
|
+
}),
|
|
17209
|
+
external_exports.object({
|
|
17210
|
+
t: external_exports.literal("cwd"),
|
|
17211
|
+
cursor: sequence,
|
|
17212
|
+
term: terminalName,
|
|
17213
|
+
generation: id2,
|
|
17214
|
+
cwd: path
|
|
17215
|
+
}),
|
|
17216
|
+
external_exports.object({ t: external_exports.literal("capture-env"), cursor: sequence, enabled: external_exports.boolean() }),
|
|
17217
|
+
external_exports.object({ t: external_exports.literal("clear-env"), cursor: sequence }),
|
|
17218
|
+
external_exports.object({
|
|
17219
|
+
t: external_exports.literal("turn-started"),
|
|
17220
|
+
cursor: sequence,
|
|
17221
|
+
turn: runtimeTurnSchema.extend({ status: external_exports.literal("running") })
|
|
17222
|
+
}),
|
|
17223
|
+
external_exports.object({
|
|
17224
|
+
t: external_exports.literal("turn-finished"),
|
|
17225
|
+
cursor: sequence,
|
|
17226
|
+
result: runtimeTurnResultSchema.refine(
|
|
17227
|
+
(value) => value.status !== "running",
|
|
17228
|
+
"Turn has not finished"
|
|
17229
|
+
)
|
|
17230
|
+
}),
|
|
17231
|
+
external_exports.object({
|
|
17232
|
+
t: external_exports.literal("native-lifecycle"),
|
|
17233
|
+
cursor: sequence,
|
|
17234
|
+
lifecycle: runtimeLifecycleSchema,
|
|
17235
|
+
segment: runtimeSegmentSchema,
|
|
17236
|
+
previous_segment_id: id2.nullable()
|
|
17237
|
+
}),
|
|
17238
|
+
external_exports.object({
|
|
17239
|
+
t: external_exports.literal("native-collision"),
|
|
17240
|
+
cursor: sequence,
|
|
17241
|
+
agent_session_ref: external_exports.string().min(1).max(200)
|
|
17242
|
+
}),
|
|
17243
|
+
external_exports.object({ t: external_exports.literal("terminal-created"), cursor: sequence, terminal: runtimeTerminalSchema }),
|
|
17244
|
+
external_exports.object({
|
|
17245
|
+
t: external_exports.literal("osc-title"),
|
|
17246
|
+
cursor: sequence,
|
|
17247
|
+
term: external_exports.literal("agent"),
|
|
17248
|
+
generation: id2,
|
|
17249
|
+
segment_id: id2,
|
|
17250
|
+
title: external_exports.string().min(1).max(80)
|
|
17251
|
+
}),
|
|
17252
|
+
external_exports.object({
|
|
17253
|
+
t: external_exports.literal("exit"),
|
|
17254
|
+
cursor: sequence,
|
|
17255
|
+
term: terminalName,
|
|
17256
|
+
generation: id2,
|
|
17257
|
+
exit_code: external_exports.number().int()
|
|
17258
|
+
})
|
|
17259
|
+
]);
|
|
17260
|
+
var runtimeJournalStatusSchema = external_exports.object({
|
|
17261
|
+
cursor: sequence,
|
|
17262
|
+
acknowledged: sequence,
|
|
17263
|
+
lost_through: sequence,
|
|
17264
|
+
persistence_pending: external_exports.boolean()
|
|
17265
|
+
});
|
|
17266
|
+
var runtimeEventPageSchema = external_exports.object({
|
|
17267
|
+
events: external_exports.array(runtimeRetainedEventSchema).max(RUNTIME_LIMITS.eventPage),
|
|
17268
|
+
through: sequence,
|
|
17269
|
+
more: external_exports.boolean(),
|
|
17270
|
+
gap: external_exports.boolean(),
|
|
17271
|
+
journal: runtimeJournalStatusSchema
|
|
17272
|
+
});
|
|
17273
|
+
var runtimeStateSchema = external_exports.object({
|
|
17274
|
+
identity: runtimeIdentitySchema,
|
|
17275
|
+
build: external_exports.string().min(1).max(128),
|
|
17276
|
+
/** Process-group separation does not establish survival of host session teardown. */
|
|
17277
|
+
lifetime: external_exports.enum(["service", "host_session", "unknown"]).optional(),
|
|
17278
|
+
protocol,
|
|
17279
|
+
state: external_exports.enum(["prepared", "running", "exited", "failed"]),
|
|
17280
|
+
terminals: external_exports.array(runtimeTerminalSchema).max(RUNTIME_LIMITS.terminals),
|
|
17281
|
+
event_cursor: sequence,
|
|
17282
|
+
command_cursor: sequence,
|
|
17283
|
+
persistence_pending: external_exports.boolean(),
|
|
17284
|
+
journal: runtimeJournalStatusSchema,
|
|
17285
|
+
agent: runtimeAgentStateSchema.nullable(),
|
|
17286
|
+
turn: runtimeTurnSchema.nullable(),
|
|
17287
|
+
environment: runtimeEnvironmentStateSchema,
|
|
17288
|
+
/** Omitted by older experimental owners; null means no cockpit report yet. */
|
|
17289
|
+
theme: runtimeThemeSchema.nullable().optional(),
|
|
17290
|
+
attention: runtimeAttentionSchema.nullable().optional(),
|
|
17291
|
+
/** Transient foreground hint for a terminal placement; never a native binding. */
|
|
17292
|
+
terminal_agent: external_exports.string().min(1).max(64).nullable().optional(),
|
|
17293
|
+
binding: runtimePlacementBindingSchema.nullable(),
|
|
17294
|
+
history: external_exports.object({
|
|
17295
|
+
current: runtimeSegmentSchema,
|
|
17296
|
+
pending_checkpoints: external_exports.number().int().min(0).max(RUNTIME_LIMITS.pendingCheckpoints),
|
|
17297
|
+
gap: external_exports.boolean()
|
|
17298
|
+
})
|
|
17299
|
+
});
|
|
17300
|
+
var runtimeRequestSchema = external_exports.discriminatedUnion("t", [
|
|
17301
|
+
external_exports.object({
|
|
17302
|
+
t: external_exports.literal("hello"),
|
|
17303
|
+
id: id2,
|
|
17304
|
+
protocol,
|
|
17305
|
+
runtime_id: id2,
|
|
17306
|
+
incarnation: id2,
|
|
17307
|
+
secret: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
17308
|
+
controller_id: id2,
|
|
17309
|
+
controller_epoch: sequence
|
|
17310
|
+
}),
|
|
17311
|
+
external_exports.object({ t: external_exports.literal("inspect"), id: id2, sequence }),
|
|
17312
|
+
external_exports.object({
|
|
17313
|
+
t: external_exports.literal("attention-preview"),
|
|
17314
|
+
id: id2,
|
|
17315
|
+
sequence,
|
|
17316
|
+
placement: runtimePlacementSchema,
|
|
17317
|
+
attention_id: id2
|
|
17318
|
+
}),
|
|
17319
|
+
external_exports.object({
|
|
17320
|
+
t: external_exports.literal("theme"),
|
|
17321
|
+
id: id2,
|
|
17322
|
+
sequence,
|
|
17323
|
+
placement: runtimePlacementSchema,
|
|
17324
|
+
colours: runtimeThemeSchema
|
|
17325
|
+
}),
|
|
17326
|
+
external_exports.object({
|
|
17327
|
+
t: external_exports.literal("bind-placement"),
|
|
17328
|
+
id: id2,
|
|
17329
|
+
sequence,
|
|
17330
|
+
binding: runtimePlacementBindingSchema
|
|
17331
|
+
}),
|
|
17332
|
+
external_exports.object({
|
|
17333
|
+
t: external_exports.literal("capture-env"),
|
|
17334
|
+
id: id2,
|
|
17335
|
+
sequence,
|
|
17336
|
+
placement: runtimePlacementSchema,
|
|
17337
|
+
enabled: external_exports.boolean()
|
|
17338
|
+
}),
|
|
17339
|
+
external_exports.object({ t: external_exports.literal("clear-env"), id: id2, sequence, placement: runtimePlacementSchema }),
|
|
17340
|
+
external_exports.object({ t: external_exports.literal("events"), id: id2, sequence, after: sequence }),
|
|
17341
|
+
external_exports.object({ t: external_exports.literal("ack-events"), id: id2, sequence, through: sequence }),
|
|
17342
|
+
external_exports.object({
|
|
17343
|
+
t: external_exports.literal("start-turn"),
|
|
17344
|
+
id: id2,
|
|
17345
|
+
sequence,
|
|
17346
|
+
placement: runtimePlacementSchema,
|
|
17347
|
+
turn: runtimeTurnSchema.shape.turn,
|
|
17348
|
+
expected_ref: runtimeTurnSchema.shape.expected_ref,
|
|
17349
|
+
prompt: external_exports.string().min(1).max(RUNTIME_LIMITS.turnPromptBytes).refine((value) => new TextEncoder().encode(value).length <= RUNTIME_LIMITS.turnPromptBytes),
|
|
17350
|
+
output_schema: external_exports.record(external_exports.string().max(256), external_exports.unknown()).refine(
|
|
17351
|
+
(value) => new TextEncoder().encode(JSON.stringify(value)).length <= 64 * 1024,
|
|
17352
|
+
"Output schema exceeds its byte limit"
|
|
17353
|
+
).optional()
|
|
17354
|
+
}),
|
|
17355
|
+
external_exports.object({ t: external_exports.literal("turn-result"), id: id2, sequence, turn: runtimeTurnSchema.shape.turn }),
|
|
17356
|
+
external_exports.object({
|
|
17357
|
+
t: external_exports.literal("cancel-turn"),
|
|
17358
|
+
id: id2,
|
|
17359
|
+
sequence,
|
|
17360
|
+
placement: runtimePlacementSchema,
|
|
17361
|
+
turn: runtimeTurnSchema.shape.turn
|
|
17362
|
+
}),
|
|
17363
|
+
external_exports.object({ t: external_exports.literal("snapshot"), id: id2, sequence, term: terminalName, generation: id2 }),
|
|
17364
|
+
external_exports.object({
|
|
17365
|
+
t: external_exports.literal("segment-snapshot"),
|
|
17366
|
+
id: id2,
|
|
17367
|
+
sequence,
|
|
17368
|
+
segment_id: id2,
|
|
17369
|
+
term: terminalName,
|
|
17370
|
+
generation: id2
|
|
17371
|
+
}),
|
|
17372
|
+
external_exports.object({
|
|
17373
|
+
t: external_exports.literal("input"),
|
|
17374
|
+
id: id2,
|
|
17375
|
+
sequence,
|
|
17376
|
+
placement: runtimePlacementSchema,
|
|
17377
|
+
term: terminalName,
|
|
17378
|
+
generation: id2,
|
|
17379
|
+
data: external_exports.string().max(RUNTIME_LIMITS.inputBytes),
|
|
17380
|
+
source: external_exports.enum(["human", "script"])
|
|
17381
|
+
}),
|
|
17382
|
+
external_exports.object({
|
|
17383
|
+
t: external_exports.literal("resize"),
|
|
17384
|
+
id: id2,
|
|
17385
|
+
sequence,
|
|
17386
|
+
placement: runtimePlacementSchema,
|
|
17387
|
+
term: terminalName,
|
|
17388
|
+
generation: id2,
|
|
17389
|
+
...size
|
|
17390
|
+
}),
|
|
17391
|
+
external_exports.object({
|
|
17392
|
+
t: external_exports.literal("spawn-shell"),
|
|
17393
|
+
id: id2,
|
|
17394
|
+
sequence,
|
|
17395
|
+
placement: runtimePlacementSchema,
|
|
17396
|
+
term: terminalName.refine((value) => value !== "agent"),
|
|
17397
|
+
command: runtimeCommandSchema
|
|
17398
|
+
}),
|
|
17399
|
+
external_exports.object({
|
|
17400
|
+
t: external_exports.literal("kill-terminal"),
|
|
17401
|
+
id: id2,
|
|
17402
|
+
sequence,
|
|
17403
|
+
placement: runtimePlacementSchema,
|
|
17404
|
+
term: terminalName,
|
|
17405
|
+
generation: id2
|
|
17406
|
+
}),
|
|
17407
|
+
external_exports.object({ t: external_exports.literal("stop"), id: id2, sequence, placement: runtimePlacementSchema })
|
|
17408
|
+
]);
|
|
17409
|
+
var runtimeResponseSchema = external_exports.discriminatedUnion("t", [
|
|
17410
|
+
external_exports.object({ t: external_exports.literal("attention-preview"), id: id2, attention_id: id2, text: external_exports.string().max(4096) }),
|
|
17411
|
+
external_exports.object({ t: external_exports.literal("state"), id: id2, state: runtimeStateSchema }),
|
|
17412
|
+
external_exports.object({ t: external_exports.literal("ok"), id: id2 }),
|
|
17413
|
+
external_exports.object({
|
|
17414
|
+
t: external_exports.literal("env-cleared"),
|
|
17415
|
+
id: id2,
|
|
17416
|
+
through: sequence,
|
|
17417
|
+
cleared: external_exports.number().int().min(0).max(RUNTIME_LIMITS.environmentVariables)
|
|
17418
|
+
}),
|
|
17419
|
+
external_exports.object({ t: external_exports.literal("events"), id: id2, page: runtimeEventPageSchema }),
|
|
17420
|
+
external_exports.object({ t: external_exports.literal("turn"), id: id2, result: runtimeTurnResultSchema }),
|
|
17421
|
+
external_exports.object({ t: external_exports.literal("segment-snapshot"), id: id2, checkpoint: runtimeCheckpointSchema }),
|
|
17422
|
+
external_exports.object({
|
|
17423
|
+
t: external_exports.literal("snapshot"),
|
|
17424
|
+
id: id2,
|
|
17425
|
+
term: terminalName,
|
|
17426
|
+
generation: id2,
|
|
17427
|
+
cursor: sequence,
|
|
17428
|
+
segment_id: id2,
|
|
17429
|
+
data: external_exports.string().max(RUNTIME_LIMITS.frameBytes)
|
|
17430
|
+
}),
|
|
17431
|
+
external_exports.object({
|
|
17432
|
+
t: external_exports.literal("error"),
|
|
17433
|
+
id: id2,
|
|
17434
|
+
code: external_exports.enum([
|
|
17435
|
+
"invalid_request",
|
|
17436
|
+
"incompatible",
|
|
17437
|
+
"unauthorised",
|
|
17438
|
+
"fenced",
|
|
17439
|
+
"busy",
|
|
17440
|
+
"stale_terminal",
|
|
17441
|
+
"stale_placement",
|
|
17442
|
+
"duplicate_request",
|
|
17443
|
+
"result_unavailable",
|
|
17444
|
+
"failed"
|
|
17445
|
+
]),
|
|
17446
|
+
message: external_exports.string().max(1024)
|
|
17447
|
+
})
|
|
17448
|
+
]);
|
|
17449
|
+
var runtimeEventSchema = external_exports.discriminatedUnion("t", [
|
|
17450
|
+
...runtimeRetainedEventSchema.options,
|
|
17451
|
+
external_exports.object({
|
|
17452
|
+
t: external_exports.literal("terminal-agent-state"),
|
|
17453
|
+
cursor: sequence,
|
|
17454
|
+
agent: external_exports.string().min(1).max(64).nullable()
|
|
17455
|
+
}),
|
|
17456
|
+
external_exports.object({
|
|
17457
|
+
t: external_exports.literal("attention-state"),
|
|
17458
|
+
cursor: sequence,
|
|
17459
|
+
attention: runtimeAttentionSchema.nullable()
|
|
17460
|
+
}),
|
|
17461
|
+
external_exports.object({ t: external_exports.literal("agent-state"), cursor: sequence, agent: runtimeAgentStateSchema }),
|
|
17462
|
+
external_exports.object({
|
|
17463
|
+
t: external_exports.literal("output"),
|
|
17464
|
+
cursor: sequence,
|
|
17465
|
+
term: terminalName,
|
|
17466
|
+
generation: id2,
|
|
17467
|
+
segment_id: id2,
|
|
17468
|
+
data: external_exports.string().max(RUNTIME_LIMITS.outputBytes)
|
|
17469
|
+
})
|
|
17470
|
+
]);
|
|
17471
|
+
var runtimeMessageSchema = external_exports.union([runtimeResponseSchema, runtimeEventSchema]);
|
|
17472
|
+
var messageTypes = /* @__PURE__ */ new Set([
|
|
17473
|
+
...runtimeResponseSchema.options.map((schema) => schema.shape.t.value),
|
|
17474
|
+
...runtimeEventSchema.options.map((schema) => schema.shape.t.value)
|
|
17475
|
+
]);
|
|
17476
|
+
var messageEnvelope = external_exports.object({ t: external_exports.string().min(1).max(64) });
|
|
17477
|
+
|
|
17478
|
+
// ../shared/src/api/agents/runtime.ts
|
|
17479
|
+
var software = external_exports.object({
|
|
17480
|
+
version: external_exports.string().min(1).max(128),
|
|
17481
|
+
protocol: hostStageRecordSchema.shape.protocol
|
|
17482
|
+
}).strict();
|
|
17483
|
+
var sessionRuntimeInspectionSchema = external_exports.object({
|
|
17484
|
+
runtime: software.extend({
|
|
17485
|
+
id: external_exports.uuid(),
|
|
17486
|
+
connected: external_exports.boolean(),
|
|
17487
|
+
lifetime: external_exports.enum(["service", "host_session", "unknown"]).optional(),
|
|
17488
|
+
terminals: external_exports.array(external_exports.object({ term: runtimeTerminalSchema.shape.term }).strict()).max(RUNTIME_LIMITS.terminals).nullable()
|
|
17489
|
+
}).strict().nullable(),
|
|
17490
|
+
installed: software.nullable(),
|
|
17491
|
+
restart: external_exports.discriminatedUnion("available", [
|
|
17492
|
+
external_exports.object({ available: external_exports.literal(true), fingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/) }).strict(),
|
|
17493
|
+
external_exports.object({
|
|
17494
|
+
available: external_exports.literal(false),
|
|
17495
|
+
reason: external_exports.enum([
|
|
17496
|
+
"no_live_runtime",
|
|
17497
|
+
"runtime_unavailable",
|
|
17498
|
+
"runtime_changed",
|
|
17499
|
+
"release_unavailable",
|
|
17500
|
+
"conversation_unknown",
|
|
17501
|
+
"resume_unsupported",
|
|
17502
|
+
"worktree_missing",
|
|
17503
|
+
"state_not_saved"
|
|
17504
|
+
])
|
|
17505
|
+
}).strict()
|
|
17506
|
+
])
|
|
17507
|
+
}).strict();
|
|
17508
|
+
var restartSessionRuntimeRequestSchema = external_exports.object({
|
|
17509
|
+
fingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/)
|
|
17510
|
+
}).strict();
|
|
17511
|
+
|
|
17512
|
+
// ../shared/src/runtime/storage.ts
|
|
17513
|
+
var runtimeAssetsSchema = external_exports.object({
|
|
17514
|
+
format: external_exports.literal(1),
|
|
17515
|
+
node_path: external_exports.string().max(4096).refine((value) => value.startsWith("/") && !value.includes("\0")),
|
|
17516
|
+
files: external_exports.record(external_exports.string().regex(/^[a-z0-9][a-z0-9-]*\.(mjs|js)$/), external_exports.string().regex(/^[a-f0-9]{64}$/)).refine((value) => Object.keys(value).length <= 16)
|
|
17517
|
+
});
|
|
17518
|
+
var runtimeJournalSchema = external_exports.object({
|
|
17519
|
+
format: external_exports.literal(1),
|
|
17520
|
+
identity: runtimeIdentitySchema,
|
|
17521
|
+
cursor: runtimeJournalStatusSchema.shape.cursor,
|
|
17522
|
+
acknowledged: runtimeJournalStatusSchema.shape.acknowledged,
|
|
17523
|
+
lost_through: runtimeJournalStatusSchema.shape.lost_through,
|
|
17524
|
+
events: external_exports.array(runtimeRetainedEventSchema).max(RUNTIME_LIMITS.journalEvents)
|
|
17525
|
+
}).superRefine((record2, ctx) => {
|
|
17526
|
+
let previous = record2.acknowledged;
|
|
17527
|
+
if (record2.acknowledged > record2.cursor || record2.lost_through > record2.cursor)
|
|
17528
|
+
ctx.addIssue({ code: "custom", message: "Journal cursor exceeds its head" });
|
|
17529
|
+
for (const event of record2.events) {
|
|
17530
|
+
if (event.cursor <= previous || event.cursor > record2.cursor)
|
|
17531
|
+
ctx.addIssue({ code: "custom", message: "Journal events must be strictly ordered" });
|
|
17532
|
+
previous = event.cursor;
|
|
17533
|
+
}
|
|
17534
|
+
});
|
|
17535
|
+
var runtimeLaunchSchema = external_exports.object({
|
|
17536
|
+
format: external_exports.literal(1),
|
|
17537
|
+
identity: runtimeIdentitySchema,
|
|
17538
|
+
secret: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
17539
|
+
/** A queued launch must never execute on a later host boot. */
|
|
17540
|
+
boot_id: external_exports.uuid().optional(),
|
|
17541
|
+
lifetime: external_exports.enum(["service", "host_session"]).optional(),
|
|
17542
|
+
main: runtimeCommandSchema,
|
|
17543
|
+
/** Daemon launch environment, below captured values and command-specific overrides. */
|
|
17544
|
+
environment: runtimeCommandSchema.shape.env.optional(),
|
|
17545
|
+
/** Absence is supported only for older experimental launch records. */
|
|
17546
|
+
shell_hooks: external_exports.literal(true).optional(),
|
|
17547
|
+
provider: runtimeProviderLaunchSchema.optional(),
|
|
17548
|
+
capture_env: runtimeCaptureSchema.optional(),
|
|
17549
|
+
theme: runtimeThemeSchema.optional()
|
|
17550
|
+
});
|
|
17551
|
+
var runtimeRetiredSchema = external_exports.object({
|
|
17552
|
+
format: external_exports.literal(1),
|
|
17553
|
+
identity: runtimeIdentitySchema
|
|
17554
|
+
});
|
|
17555
|
+
var runtimeControllerSchema = external_exports.object({
|
|
17556
|
+
format: external_exports.literal(1),
|
|
17557
|
+
id: external_exports.uuid(),
|
|
17558
|
+
epoch: external_exports.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
17559
|
+
active: external_exports.boolean()
|
|
17560
|
+
});
|
|
17561
|
+
var runtimeSupervisorSchema = external_exports.object({
|
|
17562
|
+
format: external_exports.literal(1),
|
|
17563
|
+
identity: runtimeIdentitySchema,
|
|
17564
|
+
kind: external_exports.enum(["systemd", "launchd", "detached"]),
|
|
17565
|
+
name: external_exports.string().regex(
|
|
17566
|
+
/^(puddler-[a-f0-9]{8}-[a-f0-9-]{36}\.(service|process)|dev\.puddle\.runtime\.[a-f0-9]{8}\.[a-f0-9-]{36})$/
|
|
17567
|
+
),
|
|
17568
|
+
domain: external_exports.string().regex(/^gui\/[0-9]+$/).nullable(),
|
|
17569
|
+
node_path: external_exports.string().max(4096),
|
|
17570
|
+
entry_path: external_exports.string().max(4096),
|
|
17571
|
+
state: external_exports.enum(["dispatching", "dispatched", "removed"])
|
|
17572
|
+
});
|
|
17573
|
+
|
|
17574
|
+
// ../shared/src/installation/collection.ts
|
|
17575
|
+
var HOST_RELEASE_COLLECTION_LIMIT = 32;
|
|
17576
|
+
var HOST_RELEASE_COLLECTION_BYTES = 64 * 1024;
|
|
17577
|
+
var hostReleaseCollectionSchema = external_exports.object({
|
|
17578
|
+
format: external_exports.literal(1),
|
|
17579
|
+
id: external_exports.uuid(),
|
|
17580
|
+
home: external_exports.string().min(1).max(4096),
|
|
17581
|
+
fingerprint: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
17582
|
+
releases: external_exports.array(
|
|
17583
|
+
external_exports.object({
|
|
17584
|
+
generation: hostStageRecordSchema.shape.generation,
|
|
17585
|
+
device: external_exports.number().int().nonnegative().safe(),
|
|
17586
|
+
inode: external_exports.number().int().nonnegative().safe(),
|
|
17587
|
+
receipt: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
17588
|
+
publishedAt: external_exports.number().nonnegative()
|
|
17589
|
+
}).strict()
|
|
17590
|
+
).min(1).max(HOST_RELEASE_COLLECTION_LIMIT),
|
|
17591
|
+
actions: external_exports.array(
|
|
17592
|
+
external_exports.object({
|
|
17593
|
+
action: hostStageRecordSchema.shape.generation,
|
|
17594
|
+
state: external_exports.enum(["planned", "started", "finished"])
|
|
17595
|
+
}).strict()
|
|
17596
|
+
).min(1).max(HOST_RELEASE_COLLECTION_LIMIT)
|
|
17597
|
+
}).strict().superRefine((record2, context) => {
|
|
17598
|
+
const generations = record2.releases.map(({ generation }) => generation);
|
|
17599
|
+
if (new Set(generations).size !== generations.length || JSON.stringify(generations) !== JSON.stringify(record2.actions.map(({ action }) => action)))
|
|
17600
|
+
context.addIssue({
|
|
17601
|
+
code: "custom",
|
|
17602
|
+
message: "Collection actions do not match the accepted releases"
|
|
17603
|
+
});
|
|
17604
|
+
let unfinished = false;
|
|
17605
|
+
for (const { state } of record2.actions) {
|
|
17606
|
+
if (unfinished && state !== "planned")
|
|
17607
|
+
context.addIssue({ code: "custom", message: "Collection actions are not a serial prefix" });
|
|
17608
|
+
if (state !== "finished") unfinished = true;
|
|
17609
|
+
}
|
|
17610
|
+
});
|
|
17611
|
+
|
|
17612
|
+
// ../shared/src/installation/supervision.ts
|
|
17613
|
+
var hostServiceReplacementSchema = external_exports.object({
|
|
17614
|
+
kind: external_exports.enum(["systemd", "launchd"]),
|
|
17615
|
+
component: external_exports.enum(["daemon", "connector"]).optional(),
|
|
17616
|
+
name: external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/),
|
|
17617
|
+
domain: external_exports.string().regex(/^gui\/\d+$/).nullable(),
|
|
17618
|
+
pid: external_exports.number().int().positive().safe(),
|
|
17619
|
+
invocation: external_exports.string().regex(/^[0-9a-f]{32}$/).nullable(),
|
|
17620
|
+
controlGroup: external_exports.string().min(1).max(4096).nullable(),
|
|
17621
|
+
definition_path: external_exports.string().min(1).max(4096).nullable(),
|
|
17622
|
+
definition_digest: external_exports.string().regex(/^[0-9a-f]{64}$/)
|
|
17623
|
+
}).strict().refine(
|
|
17624
|
+
(service2) => service2.kind === "systemd" ? service2.name.endsWith(".service") && service2.domain === null && service2.invocation !== null && service2.controlGroup !== null && service2.definition_path === null : service2.domain !== null && service2.invocation === null && service2.controlGroup === null && service2.definition_path !== null,
|
|
17625
|
+
"Inconsistent service replacement evidence"
|
|
17626
|
+
);
|
|
17627
|
+
|
|
17628
|
+
// ../shared/src/installation/connector.ts
|
|
17629
|
+
var hostConnectorReplacementSchema = external_exports.discriminatedUnion("state", [
|
|
17630
|
+
external_exports.object({ state: external_exports.literal("absent") }).strict(),
|
|
17631
|
+
external_exports.object({
|
|
17632
|
+
state: external_exports.literal("running"),
|
|
17633
|
+
identity: connectorInspectionResponseSchema.omit({ t: true, nonce: true }).extend({
|
|
17634
|
+
ready: external_exports.literal(true)
|
|
17635
|
+
}),
|
|
17636
|
+
service: hostServiceReplacementSchema.refine((service2) => service2.component === "connector")
|
|
17637
|
+
}).strict().refine(
|
|
17638
|
+
(value) => value.identity.pid === value.service.pid,
|
|
17639
|
+
"Connector service PID does not match its process"
|
|
17640
|
+
)
|
|
17641
|
+
]);
|
|
17642
|
+
|
|
17643
|
+
// ../shared/src/installation/worker.ts
|
|
17644
|
+
var hostUpdateWorkerSchema = external_exports.object({
|
|
17645
|
+
format: external_exports.literal(1),
|
|
17646
|
+
operation_id: external_exports.uuid(),
|
|
17647
|
+
dispatch_id: external_exports.uuid(),
|
|
17648
|
+
dispatch_revision: external_exports.number().int().positive().safe(),
|
|
17649
|
+
preflight: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17650
|
+
kind: external_exports.enum(["systemd", "launchd"]),
|
|
17651
|
+
name: external_exports.string().min(1).max(128),
|
|
17652
|
+
domain: external_exports.string().regex(/^gui\/\d+$/).nullable(),
|
|
17653
|
+
release_path: external_exports.string().min(1).max(4096),
|
|
17654
|
+
node_path: external_exports.string().min(1).max(4096),
|
|
17655
|
+
entry_path: external_exports.string().min(1).max(4096),
|
|
17656
|
+
installer_path: external_exports.string().min(1).max(4096),
|
|
17657
|
+
state: external_exports.enum(["dispatching", "dispatched"]),
|
|
17658
|
+
daemon_service: hostServiceReplacementSchema.optional(),
|
|
17659
|
+
connector: hostConnectorReplacementSchema.optional(),
|
|
17660
|
+
/** Explicit consent, bound to the same release and impact as preflight. */
|
|
17661
|
+
interruption_approval: external_exports.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
17662
|
+
/** Only this outgoing daemon may publish the worker's shutdown checkpoint. */
|
|
17663
|
+
outgoing: external_exports.object({
|
|
17664
|
+
pid: external_exports.number().int().positive().safe(),
|
|
17665
|
+
controller: runtimeControllerSchema.pick({ id: true, epoch: true }).strict()
|
|
17666
|
+
}).strict().optional()
|
|
17667
|
+
}).strict().refine(
|
|
17668
|
+
(record2) => !record2.interruption_approval || !!record2.outgoing && !!record2.daemon_service && record2.interruption_approval === record2.preflight,
|
|
17669
|
+
"Interruption approval does not match the daemon update"
|
|
17670
|
+
);
|
|
17671
|
+
var hostUpdateWorkerLifetimeSchema = external_exports.object({
|
|
17672
|
+
format: external_exports.literal(1),
|
|
17673
|
+
operation_id: external_exports.uuid(),
|
|
17674
|
+
dispatch_id: external_exports.uuid(),
|
|
17675
|
+
worker_id: external_exports.uuid(),
|
|
17676
|
+
preflight: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17677
|
+
/** The worker must lead this group; its commands are never detached from it. */
|
|
17678
|
+
process_group: external_exports.number().int().positive().max(2 ** 31 - 1)
|
|
17679
|
+
}).strict();
|
|
17680
|
+
|
|
17681
|
+
// ../shared/src/installation/actions.ts
|
|
17682
|
+
var hostUpdateActionSchema = external_exports.enum([
|
|
17683
|
+
"stop-connector",
|
|
17684
|
+
"stop-daemon",
|
|
17685
|
+
"select-daemon",
|
|
17686
|
+
"select-runtime",
|
|
17687
|
+
"start-daemon",
|
|
17688
|
+
"start-connector"
|
|
17689
|
+
]);
|
|
17690
|
+
var hostUpdateActionsSchema = external_exports.object({
|
|
17691
|
+
format: external_exports.literal(1),
|
|
17692
|
+
operation_id: external_exports.uuid(),
|
|
17693
|
+
dispatch_id: external_exports.uuid(),
|
|
17694
|
+
worker_id: external_exports.uuid(),
|
|
17695
|
+
preflight: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17696
|
+
actions: external_exports.array(
|
|
17697
|
+
external_exports.object({
|
|
17698
|
+
action: hostUpdateActionSchema,
|
|
17699
|
+
state: external_exports.enum(["planned", "started", "finished"])
|
|
17700
|
+
}).strict()
|
|
17701
|
+
).min(1).max(6)
|
|
17702
|
+
}).strict().superRefine((record2, context) => {
|
|
17703
|
+
const names = record2.actions.map(({ action }) => action);
|
|
17704
|
+
if (new Set(names).size !== names.length)
|
|
17705
|
+
context.addIssue({ code: "custom", message: "Duplicate update action" });
|
|
17706
|
+
let unfinished = false;
|
|
17707
|
+
for (const { state } of record2.actions) {
|
|
17708
|
+
if (unfinished && state !== "planned")
|
|
17709
|
+
context.addIssue({ code: "custom", message: "Update actions are not a serial prefix" });
|
|
17710
|
+
if (state !== "finished") unfinished = true;
|
|
17711
|
+
}
|
|
17712
|
+
});
|
|
17713
|
+
|
|
17714
|
+
// ../shared/src/installation/checkpoint.ts
|
|
17715
|
+
var HOST_UPDATE_CHECKPOINT_OWNERS = 4096;
|
|
17716
|
+
var HOST_UPDATE_CHECKPOINT_BYTES = 8 * 1024 * 1024;
|
|
17717
|
+
var hostUpdateCheckpointReferenceSchema = external_exports.object({
|
|
17718
|
+
operation_id: external_exports.uuid(),
|
|
17719
|
+
dispatch_id: external_exports.uuid(),
|
|
17720
|
+
preflight: external_exports.string().regex(/^[0-9a-f]{64}$/)
|
|
17721
|
+
}).strict();
|
|
17722
|
+
var hostUpdateCheckpointSchema = hostUpdateCheckpointReferenceSchema.extend({
|
|
17723
|
+
format: external_exports.literal(1),
|
|
17724
|
+
captured_at: external_exports.number().int().nonnegative().safe(),
|
|
17725
|
+
daemon: external_exports.object({
|
|
17726
|
+
pid: external_exports.number().int().positive().safe(),
|
|
17727
|
+
version: external_exports.string().min(1).max(128),
|
|
17728
|
+
controller: runtimeControllerSchema.pick({ id: true, epoch: true }).strip(),
|
|
17729
|
+
schema_version: external_exports.number().int().nonnegative().safe()
|
|
17730
|
+
}).strip(),
|
|
17731
|
+
owners: external_exports.array(
|
|
17732
|
+
external_exports.object({
|
|
17733
|
+
identity: runtimeIdentitySchema.strip(),
|
|
17734
|
+
build: runtimeStateSchema.shape.build,
|
|
17735
|
+
protocol: runtimeStateSchema.shape.protocol,
|
|
17736
|
+
release_path: runtimeIdentitySchema.shape.canonical_worktree_path,
|
|
17737
|
+
launch_fingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17738
|
+
event_cursor: external_exports.number().int().min(-1).safe(),
|
|
17739
|
+
state: external_exports.enum(["prepared", "running", "exited", "failed", "interrupted"])
|
|
17740
|
+
}).strip()
|
|
17741
|
+
).max(HOST_UPDATE_CHECKPOINT_OWNERS)
|
|
17742
|
+
}).strip().refine(
|
|
17743
|
+
(record2) => new Set(record2.owners.map((owner) => owner.identity.runtime_id)).size === record2.owners.length,
|
|
17744
|
+
"Duplicate checkpoint owner"
|
|
17745
|
+
);
|
|
17746
|
+
|
|
17747
|
+
// ../shared/src/installation/recovery.ts
|
|
17748
|
+
var fingerprint4 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
17749
|
+
var revision = external_exports.number().int().positive().safe();
|
|
17750
|
+
var hostUpdateRecoveryJobSchema = external_exports.object({
|
|
17751
|
+
format: external_exports.literal(1),
|
|
17752
|
+
id: external_exports.uuid(),
|
|
17753
|
+
operation_id: external_exports.uuid(),
|
|
17754
|
+
requested_revision: revision,
|
|
17755
|
+
revision,
|
|
17756
|
+
original_dispatch_id: external_exports.uuid(),
|
|
17757
|
+
original_worker_id: external_exports.uuid(),
|
|
17758
|
+
preflight: fingerprint4,
|
|
17759
|
+
original_worker_digest: fingerprint4,
|
|
17760
|
+
actions_digest: fingerprint4,
|
|
17761
|
+
/** New explicit connector start after confirmed loss, bound to its selected service/build. */
|
|
17762
|
+
connector_restart: fingerprint4.optional(),
|
|
17763
|
+
/** Explicit fresh attempt after confirmed daemon loss, bound to current storage and ownership. */
|
|
17764
|
+
daemon_restart: external_exports.object({
|
|
17765
|
+
fingerprint: fingerprint4,
|
|
17766
|
+
database_schema_version: hostUpdateCheckpointSchema.shape.daemon.shape.schema_version,
|
|
17767
|
+
owners: hostUpdateCheckpointSchema.shape.owners
|
|
17768
|
+
}).strict().refine(
|
|
17769
|
+
(record2) => new Set(record2.owners.map(({ identity }) => identity.runtime_id)).size === record2.owners.length,
|
|
17770
|
+
"Duplicate restart runtime"
|
|
17771
|
+
).optional(),
|
|
17772
|
+
service: external_exports.object(hostUpdateWorkerSchema.shape).pick({
|
|
17773
|
+
kind: true,
|
|
17774
|
+
name: true,
|
|
17775
|
+
domain: true,
|
|
17776
|
+
release_path: true,
|
|
17777
|
+
node_path: true,
|
|
17778
|
+
entry_path: true,
|
|
17779
|
+
installer_path: true
|
|
17780
|
+
}).strict()
|
|
17781
|
+
}).strict().refine(
|
|
17782
|
+
(job) => job.revision === job.requested_revision + 1,
|
|
17783
|
+
"Recovery dispatch must fence its requested revision"
|
|
17784
|
+
);
|
|
17785
|
+
var hostUpdateRecoveryAttemptSchema = external_exports.object({
|
|
17786
|
+
job: hostUpdateRecoveryJobSchema,
|
|
17787
|
+
/** Written before any component mutation, while the recovery worker holds execution. */
|
|
17788
|
+
execution: external_exports.object({
|
|
17789
|
+
id: external_exports.uuid(),
|
|
17790
|
+
process_group: hostUpdateWorkerLifetimeSchema.shape.process_group
|
|
17791
|
+
}).strict().nullable()
|
|
17792
|
+
}).strict();
|
|
17793
|
+
var HOST_UPDATE_RECOVERY_ATTEMPTS = 8;
|
|
17794
|
+
var HOST_UPDATE_RECOVERY_BYTES = 256 * 1024;
|
|
17795
|
+
var hostUpdateRecoveryLedgerSchema = external_exports.object({
|
|
17796
|
+
format: external_exports.literal(1),
|
|
17797
|
+
attempts: external_exports.array(hostUpdateRecoveryAttemptSchema).max(HOST_UPDATE_RECOVERY_ATTEMPTS)
|
|
17798
|
+
}).strict().superRefine(({ attempts }, context) => {
|
|
17799
|
+
const ids = /* @__PURE__ */ new Set();
|
|
17800
|
+
let previous = 0;
|
|
17801
|
+
for (const { job } of attempts) {
|
|
17802
|
+
if (ids.has(job.id) || job.requested_revision < previous)
|
|
17803
|
+
context.addIssue({
|
|
17804
|
+
code: "custom",
|
|
17805
|
+
message: "Recovery attempts must have unique identities and ordered revisions"
|
|
17806
|
+
});
|
|
17807
|
+
ids.add(job.id);
|
|
17808
|
+
previous = job.revision;
|
|
17809
|
+
}
|
|
17810
|
+
});
|
|
17811
|
+
|
|
17812
|
+
// ../shared/src/installation/adoption.ts
|
|
17813
|
+
var hostUpdateAdoptionSchema = hostUpdateCheckpointReferenceSchema.extend({
|
|
17814
|
+
format: external_exports.literal(1),
|
|
17815
|
+
nonce: external_exports.uuid(),
|
|
17816
|
+
checkpoint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17817
|
+
stage: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17818
|
+
observed_at: external_exports.number().int().nonnegative().safe(),
|
|
17819
|
+
daemon: hostUpdateCheckpointSchema.shape.daemon.extend({
|
|
17820
|
+
port: external_exports.number().int().min(1).max(65535),
|
|
17821
|
+
protocol: hostStageRecordSchema.shape.protocol,
|
|
17822
|
+
release_path: external_exports.string().min(1).max(4096),
|
|
17823
|
+
node_path: external_exports.string().min(1).max(4096),
|
|
17824
|
+
entry_path: external_exports.string().min(1).max(4096),
|
|
17825
|
+
controller: hostUpdateCheckpointSchema.shape.daemon.shape.controller.strip()
|
|
17826
|
+
}).strip(),
|
|
17827
|
+
owners: external_exports.array(
|
|
17828
|
+
external_exports.object({
|
|
17829
|
+
runtime_id: external_exports.uuid(),
|
|
17830
|
+
event_cursor: external_exports.number().int().nonnegative().safe(),
|
|
17831
|
+
state: external_exports.enum(["running", "exited", "failed"])
|
|
17832
|
+
}).strip()
|
|
17833
|
+
).max(HOST_UPDATE_CHECKPOINT_OWNERS)
|
|
17834
|
+
}).strip().refine(
|
|
17835
|
+
(record2) => new Set(record2.owners.map((owner) => owner.runtime_id)).size === record2.owners.length,
|
|
17836
|
+
"Duplicate adopted owner"
|
|
17837
|
+
);
|
|
17838
|
+
|
|
17839
|
+
// ../shared/src/installation/capabilities.ts
|
|
17840
|
+
var SUPPORTED_RUNTIME_MAJORS = [RUNTIME_PROTOCOL_VERSION.major];
|
|
17841
|
+
var hostReleaseCapabilitiesSchema = external_exports.object({
|
|
17842
|
+
format: external_exports.literal(1),
|
|
17843
|
+
version: external_exports.string().min(1).max(128),
|
|
17844
|
+
application: hostStageRecordSchema.shape.protocol,
|
|
17845
|
+
remote: external_exports.number().int().nonnegative().safe(),
|
|
17846
|
+
runtime: hostStageRecordSchema.shape.protocol,
|
|
17847
|
+
supported_runtime_majors: external_exports.array(external_exports.number().int().nonnegative().safe()).min(1).max(16).refine((values) => new Set(values).size === values.length),
|
|
17848
|
+
/** Existing SQLite migration ceiling, not another protocol or rollback permission. */
|
|
17849
|
+
database_schema_version: external_exports.number().int().nonnegative().max(2 ** 31 - 1).optional()
|
|
17850
|
+
}).strict();
|
|
17851
|
+
|
|
17852
|
+
// ../shared/src/installation/removal/services.ts
|
|
17853
|
+
var service = hostServiceReplacementSchema.shape;
|
|
17854
|
+
var target = external_exports.object({ kind: service.kind, name: service.name, domain: service.domain }).strict();
|
|
17855
|
+
var process3 = target.extend({
|
|
17856
|
+
pid: service.pid,
|
|
17857
|
+
invocation: service.invocation,
|
|
17858
|
+
controlGroup: service.controlGroup
|
|
17859
|
+
});
|
|
17860
|
+
var hostRemovalServiceReviewSchema = external_exports.object({
|
|
17861
|
+
target,
|
|
17862
|
+
component: external_exports.enum(["daemon", "connector"]),
|
|
17863
|
+
definition: external_exports.string().min(1).max(4096),
|
|
17864
|
+
sourceDigest: service.definition_digest,
|
|
17865
|
+
definitionDigest: service.definition_digest,
|
|
17866
|
+
process: process3.nullable()
|
|
17867
|
+
}).strict().superRefine((review, context) => {
|
|
17868
|
+
const observed = review.process;
|
|
17869
|
+
const expected = review.target;
|
|
17870
|
+
if ((expected.kind === "systemd" ? expected.domain !== null || !expected.name.endsWith(".service") : expected.domain === null) || observed && (observed.kind !== expected.kind || observed.name !== expected.name || observed.domain !== expected.domain || (observed.kind === "systemd" ? observed.invocation === null || observed.controlGroup === null : observed.invocation !== null || observed.controlGroup !== null)))
|
|
17871
|
+
context.addIssue({ code: "custom", message: "Inconsistent removal service evidence" });
|
|
17872
|
+
});
|
|
17873
|
+
var hostRemovalServiceActionSchema = external_exports.enum([
|
|
17874
|
+
"disable-remote",
|
|
17875
|
+
"stop-connector",
|
|
17876
|
+
"stop-daemon",
|
|
17877
|
+
"unregister-connector",
|
|
17878
|
+
"unregister-daemon",
|
|
17879
|
+
"unregister-disable-connector",
|
|
17880
|
+
"unregister-disable-daemon",
|
|
17881
|
+
"unregister-reset-connector",
|
|
17882
|
+
"unregister-reset-daemon",
|
|
17883
|
+
"unregister-delete-connector",
|
|
17884
|
+
"unregister-delete-daemon",
|
|
17885
|
+
"unregister-reload-connector",
|
|
17886
|
+
"unregister-reload-daemon"
|
|
17887
|
+
]);
|
|
17888
|
+
function hostRemovalUnregisterPlan(review) {
|
|
17889
|
+
const component2 = review.component;
|
|
17890
|
+
return review.target.kind === "systemd" ? [
|
|
17891
|
+
`unregister-disable-${component2}`,
|
|
17892
|
+
`unregister-reset-${component2}`,
|
|
17893
|
+
`unregister-delete-${component2}`,
|
|
17894
|
+
`unregister-reload-${component2}`
|
|
17895
|
+
] : [`unregister-delete-${component2}`];
|
|
17896
|
+
}
|
|
17897
|
+
var hostRemovalServicesSchema = external_exports.object({
|
|
17898
|
+
format: external_exports.literal(1),
|
|
17899
|
+
id: external_exports.uuid(),
|
|
17900
|
+
release_path: external_exports.string().min(1).max(4096),
|
|
17901
|
+
services: external_exports.array(
|
|
17902
|
+
external_exports.object({
|
|
17903
|
+
review: hostRemovalServiceReviewSchema,
|
|
17904
|
+
// The original may contain environment values. Keep it only in private host storage.
|
|
17905
|
+
source: external_exports.string().min(1).max(87384)
|
|
17906
|
+
}).strict()
|
|
17907
|
+
).min(1).max(2),
|
|
17908
|
+
actions: external_exports.array(
|
|
17909
|
+
external_exports.object({
|
|
17910
|
+
action: hostRemovalServiceActionSchema,
|
|
17911
|
+
state: external_exports.enum(["planned", "started", "finished"])
|
|
17912
|
+
}).strict()
|
|
17913
|
+
).min(2).max(11)
|
|
17914
|
+
}).strict().superRefine((record2, context) => {
|
|
17915
|
+
const components = record2.services.map(({ review }) => review.component);
|
|
17916
|
+
const ordered = ["connector", "daemon"].filter(
|
|
17917
|
+
(component2) => components.includes(component2)
|
|
17918
|
+
);
|
|
17919
|
+
const plan = [
|
|
17920
|
+
...record2.actions[0]?.action === "disable-remote" ? ["disable-remote"] : [],
|
|
17921
|
+
...ordered.map((component2) => `stop-${component2}`),
|
|
17922
|
+
...ordered.flatMap(
|
|
17923
|
+
(component2) => record2.actions.some(({ action }) => action === "unregister-daemon") ? [`unregister-${component2}`] : hostRemovalUnregisterPlan(
|
|
17924
|
+
record2.services.find(({ review }) => review.component === component2).review
|
|
17925
|
+
)
|
|
17926
|
+
)
|
|
17927
|
+
];
|
|
17928
|
+
if (new Set(components).size !== components.length || !components.includes("daemon") || JSON.stringify(record2.actions.map(({ action }) => action)) !== JSON.stringify(plan))
|
|
17929
|
+
context.addIssue({
|
|
17930
|
+
code: "custom",
|
|
17931
|
+
message: "Removal service plan does not match its inventory"
|
|
17932
|
+
});
|
|
17933
|
+
let unfinished = false;
|
|
17934
|
+
for (const { state } of record2.actions) {
|
|
17935
|
+
if (unfinished && state !== "planned")
|
|
17936
|
+
context.addIssue({ code: "custom", message: "Removal actions are not a serial prefix" });
|
|
17937
|
+
if (state !== "finished") unfinished = true;
|
|
17938
|
+
}
|
|
17939
|
+
});
|
|
17940
|
+
var HOST_REMOVAL_SERVICES_BYTES = 256 * 1024;
|
|
17941
|
+
|
|
17942
|
+
// ../shared/src/installation/removal/restore.ts
|
|
17943
|
+
var hostRemovalRestoreActionSchema = external_exports.enum([
|
|
17944
|
+
"restore-connector",
|
|
17945
|
+
"restore-daemon",
|
|
17946
|
+
"reload-services",
|
|
17947
|
+
"enable-connector",
|
|
17948
|
+
"enable-daemon",
|
|
17949
|
+
"restore-supervisor"
|
|
17950
|
+
]);
|
|
17951
|
+
var hostRemovalRestoreSchema = external_exports.object({
|
|
17952
|
+
format: external_exports.literal(1),
|
|
17953
|
+
removal_id: external_exports.uuid(),
|
|
17954
|
+
removal_digest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17955
|
+
/** Exact completed purge proof; absent on historical ordinary restoration journals. */
|
|
17956
|
+
purge_digest: external_exports.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
17957
|
+
actions: external_exports.array(
|
|
17958
|
+
external_exports.object({
|
|
17959
|
+
action: hostRemovalRestoreActionSchema,
|
|
17960
|
+
state: external_exports.enum(["planned", "started", "finished"])
|
|
17961
|
+
}).strict()
|
|
17962
|
+
).min(1).max(6)
|
|
17963
|
+
}).strict().superRefine((record2, context) => {
|
|
17964
|
+
if (Boolean(record2.purge_digest) !== record2.actions.some(({ action }) => action === "restore-supervisor"))
|
|
17965
|
+
context.addIssue({
|
|
17966
|
+
code: "custom",
|
|
17967
|
+
message: "Supervisor restoration requires completed purge evidence"
|
|
17968
|
+
});
|
|
17969
|
+
if (new Set(record2.actions.map(({ action }) => action)).size !== record2.actions.length)
|
|
17970
|
+
context.addIssue({ code: "custom", message: "Duplicate restoration action" });
|
|
17971
|
+
let unfinished = false;
|
|
17972
|
+
for (const { state } of record2.actions) {
|
|
17973
|
+
if (unfinished && state !== "planned")
|
|
17974
|
+
context.addIssue({
|
|
17975
|
+
code: "custom",
|
|
17976
|
+
message: "Restoration actions are not a serial prefix"
|
|
17977
|
+
});
|
|
17978
|
+
if (state !== "finished") unfinished = true;
|
|
17979
|
+
}
|
|
17980
|
+
});
|
|
17981
|
+
|
|
17982
|
+
// ../shared/src/installation/removal/status.ts
|
|
17983
|
+
var hostRemovalStatusSchema = external_exports.discriminatedUnion("state", [
|
|
17984
|
+
external_exports.object({ state: external_exports.literal("none") }).strict(),
|
|
17985
|
+
external_exports.object({
|
|
17986
|
+
state: external_exports.enum(["removing", "removed", "restoring", "restored"]),
|
|
17987
|
+
id: external_exports.uuid()
|
|
17988
|
+
}).strict()
|
|
17989
|
+
]);
|
|
17990
|
+
|
|
17991
|
+
// ../shared/src/installation/removal/runtime.ts
|
|
17992
|
+
var HOST_REMOVAL_RUNTIME_LIMIT = 1024;
|
|
17993
|
+
var fingerprint5 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
17994
|
+
var hostRemovalRuntimeReviewSchema = external_exports.object({
|
|
17995
|
+
id: external_exports.uuid(),
|
|
17996
|
+
fingerprint: fingerprint5,
|
|
17997
|
+
owners: external_exports.array(
|
|
17998
|
+
external_exports.object({
|
|
17999
|
+
id: external_exports.uuid(),
|
|
18000
|
+
session: external_exports.string().min(1).max(128),
|
|
18001
|
+
version: external_exports.string().min(1).max(128),
|
|
18002
|
+
terminals: external_exports.number().int().nonnegative().max(1024).nullable(),
|
|
18003
|
+
stop_blocker: external_exports.enum(["unavailable", "unsaved", "stop_pending"]).nullable()
|
|
18004
|
+
}).strict()
|
|
18005
|
+
).max(HOST_REMOVAL_RUNTIME_LIMIT)
|
|
18006
|
+
}).strict();
|
|
18007
|
+
var hostRemovalFinishSchema = external_exports.object({
|
|
18008
|
+
id: external_exports.uuid(),
|
|
18009
|
+
fingerprint: fingerprint5,
|
|
18010
|
+
attempt_id: external_exports.uuid(),
|
|
18011
|
+
disposition: external_exports.enum(["retain", "stop"])
|
|
18012
|
+
}).strict();
|
|
18013
|
+
|
|
18014
|
+
// ../shared/src/installation/removal/purge.ts
|
|
18015
|
+
var fingerprint6 = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
18016
|
+
var HOST_PURGE_RECORD_BYTES = 4 * 1024 * 1024;
|
|
18017
|
+
var HOST_PURGE_ANCHORS = [
|
|
18018
|
+
"bin",
|
|
18019
|
+
"installation",
|
|
18020
|
+
"runtime-claims",
|
|
18021
|
+
"runtime-controller.json",
|
|
18022
|
+
"updates"
|
|
18023
|
+
];
|
|
18024
|
+
var root = external_exports.object({
|
|
18025
|
+
name: external_exports.string().min(1).max(255).refine(
|
|
18026
|
+
(name) => name !== "." && name !== ".." && !/[\\/\0]/.test(name) && !HOST_PURGE_ANCHORS.some((anchor) => anchor === name)
|
|
18027
|
+
),
|
|
18028
|
+
device: external_exports.number().int().nonnegative(),
|
|
18029
|
+
inode: external_exports.number().int().positive(),
|
|
18030
|
+
kind: external_exports.enum(["directory", "file", "symlink"]),
|
|
18031
|
+
state: external_exports.enum(["planned", "detached", "deleted"])
|
|
18032
|
+
}).strict();
|
|
18033
|
+
var worktree = external_exports.object({
|
|
18034
|
+
path: external_exports.string().min(1).max(4096),
|
|
18035
|
+
dirty: external_exports.boolean(),
|
|
18036
|
+
local_only: external_exports.boolean()
|
|
18037
|
+
}).strict();
|
|
18038
|
+
var hostPurgeRecordSchema = external_exports.object({
|
|
18039
|
+
format: external_exports.literal(1),
|
|
18040
|
+
id: external_exports.uuid(),
|
|
18041
|
+
boot_id: external_exports.uuid(),
|
|
18042
|
+
removal_digest: fingerprint6,
|
|
18043
|
+
phase: external_exports.enum(["waiting", "deleting", "complete"]),
|
|
18044
|
+
fingerprint: fingerprint6.nullable(),
|
|
18045
|
+
worktree_fingerprint: fingerprint6.nullable(),
|
|
18046
|
+
roots: external_exports.array(root).max(512),
|
|
18047
|
+
worktrees: external_exports.array(worktree).max(4096),
|
|
18048
|
+
attempt_id: external_exports.uuid().nullable()
|
|
18049
|
+
}).strict().superRefine((record2, context) => {
|
|
18050
|
+
if (new Set(record2.roots.map((root2) => root2.name)).size !== record2.roots.length || record2.phase === "waiting" && (record2.attempt_id !== null || record2.roots.some((root2) => root2.state !== "planned")) || record2.phase !== "waiting" && (!record2.fingerprint || !record2.worktree_fingerprint || !record2.attempt_id) || record2.phase === "complete" && record2.roots.some((root2) => root2.state !== "deleted") || record2.fingerprint === null !== (record2.worktree_fingerprint === null))
|
|
18051
|
+
context.addIssue({ code: "custom", message: "Inconsistent purge progress evidence" });
|
|
18052
|
+
});
|
|
18053
|
+
var hostPurgeReviewSchema = external_exports.object({
|
|
18054
|
+
id: external_exports.uuid(),
|
|
18055
|
+
phase: external_exports.enum(["reboot_required", "ready", "deleting", "complete"]),
|
|
18056
|
+
fingerprint: fingerprint6.nullable(),
|
|
18057
|
+
worktrees: external_exports.array(worktree).max(4096),
|
|
18058
|
+
attempt_id: external_exports.uuid().nullable()
|
|
18059
|
+
}).strict();
|
|
18060
|
+
var hostPurgeApplySchema = external_exports.object({
|
|
18061
|
+
id: external_exports.uuid(),
|
|
18062
|
+
fingerprint: fingerprint6,
|
|
18063
|
+
attempt_id: external_exports.uuid()
|
|
18064
|
+
}).strict();
|
|
18065
|
+
|
|
16575
18066
|
// ../shared/src/node/security.ts
|
|
16576
18067
|
import { createHash, randomBytes } from "node:crypto";
|
|
16577
18068
|
import {
|
|
@@ -16585,6 +18076,7 @@ import {
|
|
|
16585
18076
|
mkdirSync,
|
|
16586
18077
|
openSync,
|
|
16587
18078
|
readFileSync,
|
|
18079
|
+
readSync,
|
|
16588
18080
|
realpathSync,
|
|
16589
18081
|
renameSync,
|
|
16590
18082
|
rmSync,
|
|
@@ -16592,36 +18084,58 @@ import {
|
|
|
16592
18084
|
} from "node:fs";
|
|
16593
18085
|
import { dirname, join, resolve } from "node:path";
|
|
16594
18086
|
var digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
16595
|
-
function privatePath(
|
|
16596
|
-
const st = lstatSync(
|
|
18087
|
+
function privatePath(path2, directory = false) {
|
|
18088
|
+
const st = lstatSync(path2);
|
|
16597
18089
|
if (st.isSymbolicLink() || (directory ? !st.isDirectory() : !st.isFile() && !st.isSocket()) || process.getuid && st.uid !== process.getuid() || process.platform !== "win32" && (st.mode & 63) !== 0) {
|
|
16598
18090
|
throw new Error("Puddle authority storage must be private and owned by the current user");
|
|
16599
18091
|
}
|
|
16600
18092
|
}
|
|
16601
|
-
function privateDirectory(
|
|
16602
|
-
mkdirSync(
|
|
16603
|
-
privatePath(
|
|
18093
|
+
function privateDirectory(path2) {
|
|
18094
|
+
mkdirSync(path2, { recursive: true, mode: 448 });
|
|
18095
|
+
privatePath(path2, true);
|
|
16604
18096
|
}
|
|
16605
18097
|
function initialisePrivateHome(home) {
|
|
16606
|
-
const
|
|
16607
|
-
mkdirSync(
|
|
18098
|
+
const path2 = resolve(home);
|
|
18099
|
+
mkdirSync(path2, { recursive: true, mode: 448 });
|
|
16608
18100
|
if (process.platform === "win32") {
|
|
16609
|
-
privatePath(
|
|
18101
|
+
privatePath(path2, true);
|
|
16610
18102
|
return;
|
|
16611
18103
|
}
|
|
16612
|
-
const fd = openSync(
|
|
18104
|
+
const fd = openSync(path2, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
16613
18105
|
try {
|
|
16614
18106
|
const st = fstatSync(fd);
|
|
16615
18107
|
if (!st.isDirectory() || st.uid !== process.getuid() || (st.mode & 18) !== 0) {
|
|
16616
18108
|
throw new Error(
|
|
16617
|
-
`Puddle home must be owned by the current user and not writable by other users: ${
|
|
18109
|
+
`Puddle home must be owned by the current user and not writable by other users: ${path2}`
|
|
16618
18110
|
);
|
|
16619
18111
|
}
|
|
16620
18112
|
if ((st.mode & 63) !== 0) fchmodSync(fd, 448);
|
|
16621
18113
|
} finally {
|
|
16622
18114
|
closeSync(fd);
|
|
16623
18115
|
}
|
|
16624
|
-
privatePath(
|
|
18116
|
+
privatePath(path2, true);
|
|
18117
|
+
}
|
|
18118
|
+
function readPrivateJson(path2, maxBytes) {
|
|
18119
|
+
privatePath(path2);
|
|
18120
|
+
if (maxBytes !== void 0) {
|
|
18121
|
+
const fd = openSync(path2, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
18122
|
+
try {
|
|
18123
|
+
const stat = fstatSync(fd);
|
|
18124
|
+
if (!stat.isFile() || stat.size > maxBytes) throw new Error("Invalid private record size");
|
|
18125
|
+
const buffer = Buffer.alloc(stat.size + 1);
|
|
18126
|
+
let size2 = 0;
|
|
18127
|
+
while (size2 < buffer.length) {
|
|
18128
|
+
const count2 = readSync(fd, buffer, size2, buffer.length - size2, size2);
|
|
18129
|
+
if (count2 === 0) break;
|
|
18130
|
+
size2 += count2;
|
|
18131
|
+
}
|
|
18132
|
+
if (size2 > stat.size) throw new Error("Private record grew while reading");
|
|
18133
|
+
return JSON.parse(buffer.subarray(0, size2).toString("utf8"));
|
|
18134
|
+
} finally {
|
|
18135
|
+
closeSync(fd);
|
|
18136
|
+
}
|
|
18137
|
+
}
|
|
18138
|
+
return JSON.parse(readFileSync(path2, "utf8"));
|
|
16625
18139
|
}
|
|
16626
18140
|
function ipcPath(home, scope) {
|
|
16627
18141
|
initialisePrivateHome(home);
|
|
@@ -16631,13 +18145,15 @@ function ipcPath(home, scope) {
|
|
|
16631
18145
|
privateDirectory(dir);
|
|
16632
18146
|
return join(dir, "control.sock");
|
|
16633
18147
|
}
|
|
16634
|
-
function jsonLines(stream, receive, fail) {
|
|
18148
|
+
function jsonLines(stream, receive, fail, maxBytes = CONTROL_MAX_BYTES) {
|
|
18149
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > CONTROL_MAX_BYTES)
|
|
18150
|
+
throw new Error("Invalid private message bound");
|
|
16635
18151
|
let buffer = "";
|
|
16636
18152
|
let failed = false;
|
|
16637
18153
|
const onData = (chunk) => {
|
|
16638
18154
|
if (failed) return;
|
|
16639
18155
|
buffer += chunk.toString();
|
|
16640
|
-
if (Buffer.byteLength(buffer) >
|
|
18156
|
+
if (Buffer.byteLength(buffer) > maxBytes) {
|
|
16641
18157
|
failed = true;
|
|
16642
18158
|
fail();
|
|
16643
18159
|
return;
|
|
@@ -16711,8 +18227,8 @@ async function inspectLegacyHost(home) {
|
|
|
16711
18227
|
} catch {
|
|
16712
18228
|
}
|
|
16713
18229
|
}
|
|
16714
|
-
const get = async (
|
|
16715
|
-
const response = await fetch(`http://127.0.0.1:${port}${
|
|
18230
|
+
const get = async (path2) => {
|
|
18231
|
+
const response = await fetch(`http://127.0.0.1:${port}${path2}`, {
|
|
16716
18232
|
headers: { authorization: `Bearer ${token}` },
|
|
16717
18233
|
signal: AbortSignal.timeout(3e3)
|
|
16718
18234
|
});
|
|
@@ -16738,14 +18254,14 @@ async function inspectLegacyHost(home) {
|
|
|
16738
18254
|
}
|
|
16739
18255
|
}
|
|
16740
18256
|
async function inspectHostLocally(home) {
|
|
16741
|
-
const
|
|
18257
|
+
const path2 = ipcPath(home, "host");
|
|
16742
18258
|
try {
|
|
16743
|
-
privatePath(
|
|
18259
|
+
privatePath(path2);
|
|
16744
18260
|
} catch (err) {
|
|
16745
18261
|
if (err.code === "ENOENT") return inspectLegacyHost(home);
|
|
16746
18262
|
throw err;
|
|
16747
18263
|
}
|
|
16748
|
-
const socket = connect(
|
|
18264
|
+
const socket = connect(path2);
|
|
16749
18265
|
try {
|
|
16750
18266
|
const grant = await new Promise((resolve2, reject) => {
|
|
16751
18267
|
socket.setTimeout(5e3, () => socket.destroy(new Error("Host inspection timed out")));
|
|
@@ -16785,17 +18301,348 @@ async function inspectHostLocally(home) {
|
|
|
16785
18301
|
}
|
|
16786
18302
|
}
|
|
16787
18303
|
|
|
18304
|
+
// ../shared/src/node/installation/capabilities.ts
|
|
18305
|
+
import { constants as constants2 } from "node:fs";
|
|
18306
|
+
import { open, realpath } from "node:fs/promises";
|
|
18307
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
18308
|
+
async function readStageCapabilities(home, input) {
|
|
18309
|
+
const stage = hostStageReceiptSchema.parse(input);
|
|
18310
|
+
if (!stage.record.checksum_verified || digest(`${JSON.stringify(stage.record)}
|
|
18311
|
+
`) !== stage.digest)
|
|
18312
|
+
throw new Error("Unverified host update stage");
|
|
18313
|
+
const versions = await realpath(join4(home, "bin/versions"));
|
|
18314
|
+
const root2 = await realpath(join4(versions, stage.record.generation));
|
|
18315
|
+
if (dirname2(root2) !== versions || root2 !== join4(versions, stage.record.generation))
|
|
18316
|
+
throw new Error("Host stage is outside its exact installed generation");
|
|
18317
|
+
const receipt = readPrivateJson(join4(root2, ".puddle-stage.json"), 4096);
|
|
18318
|
+
if (digest(`${JSON.stringify(receipt)}
|
|
18319
|
+
`) !== stage.digest)
|
|
18320
|
+
throw new Error("Host stage receipt changed");
|
|
18321
|
+
const capabilities = await readInstalledCapabilities(root2);
|
|
18322
|
+
const protocol2 = stage.record.component === "daemon" ? capabilities.application : capabilities.runtime;
|
|
18323
|
+
if (capabilities.version !== stage.record.version || protocol2.major !== stage.record.protocol.major || protocol2.minor !== stage.record.protocol.minor)
|
|
18324
|
+
throw new Error("Host capabilities do not match the staged component");
|
|
18325
|
+
return capabilities;
|
|
18326
|
+
}
|
|
18327
|
+
async function readInstalledCapabilities(root2) {
|
|
18328
|
+
const file2 = await open(
|
|
18329
|
+
join4(root2, "HOST_CAPABILITIES.json"),
|
|
18330
|
+
constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK
|
|
18331
|
+
);
|
|
18332
|
+
try {
|
|
18333
|
+
const stat = await file2.stat();
|
|
18334
|
+
if (!stat.isFile() || stat.size > 32 * 1024)
|
|
18335
|
+
throw new Error("Invalid host capability metadata");
|
|
18336
|
+
const buffer = Buffer.alloc(stat.size + 1);
|
|
18337
|
+
let size2 = 0;
|
|
18338
|
+
while (size2 < buffer.length) {
|
|
18339
|
+
const { bytesRead } = await file2.read(buffer, size2, buffer.length - size2, size2);
|
|
18340
|
+
if (bytesRead === 0) break;
|
|
18341
|
+
size2 += bytesRead;
|
|
18342
|
+
}
|
|
18343
|
+
if (size2 > stat.size) throw new Error("Host capability metadata changed during inspection");
|
|
18344
|
+
const capabilities = hostReleaseCapabilitiesSchema.parse(
|
|
18345
|
+
JSON.parse(buffer.subarray(0, size2).toString("utf8"))
|
|
18346
|
+
);
|
|
18347
|
+
return capabilities;
|
|
18348
|
+
} finally {
|
|
18349
|
+
await file2.close();
|
|
18350
|
+
}
|
|
18351
|
+
}
|
|
18352
|
+
|
|
18353
|
+
// ../shared/src/node/installation/boot.ts
|
|
18354
|
+
import { execFile } from "node:child_process";
|
|
18355
|
+
import { promisify } from "node:util";
|
|
18356
|
+
var execute = promisify(execFile);
|
|
18357
|
+
|
|
18358
|
+
// ../shared/src/node/releases/github.ts
|
|
18359
|
+
var assetSchema = external_exports.object({
|
|
18360
|
+
name: external_exports.string().min(1).max(256),
|
|
18361
|
+
browser_download_url: external_exports.string().max(2048).url().refine((value) => value.startsWith("https://"))
|
|
18362
|
+
});
|
|
18363
|
+
var releaseSchema = external_exports.object({
|
|
18364
|
+
tag_name: external_exports.string().max(129).regex(/^v?[0-9]+\.[0-9]+\.[0-9]+$/),
|
|
18365
|
+
draft: external_exports.literal(false).optional(),
|
|
18366
|
+
prerelease: external_exports.literal(false).optional(),
|
|
18367
|
+
assets: external_exports.array(assetSchema).max(1024).default([])
|
|
18368
|
+
});
|
|
18369
|
+
|
|
18370
|
+
// ../shared/src/node/installation/workers.ts
|
|
18371
|
+
import { accessSync, constants as constants3, realpathSync as realpathSync2, statSync } from "node:fs";
|
|
18372
|
+
import { dirname as dirname3, isAbsolute, join as join5 } from "node:path";
|
|
18373
|
+
function updateWorkerExecutables(home, release) {
|
|
18374
|
+
if (!isAbsolute(release) || /[\u0000-\u001f\u007f]/.test(release))
|
|
18375
|
+
throw new Error("Invalid worker executable path");
|
|
18376
|
+
const versions = realpathSync2(join5(home, "bin", "versions"));
|
|
18377
|
+
const root2 = realpathSync2(release);
|
|
18378
|
+
if (dirname3(root2) !== versions) throw new Error("Update worker is outside installed releases");
|
|
18379
|
+
const file2 = (relative, access) => {
|
|
18380
|
+
const expected = join5(root2, relative);
|
|
18381
|
+
const path2 = realpathSync2(expected);
|
|
18382
|
+
if (path2 !== expected || !statSync(path2).isFile())
|
|
18383
|
+
throw new Error("Update worker file is not pinned to its release");
|
|
18384
|
+
accessSync(path2, access);
|
|
18385
|
+
return path2;
|
|
18386
|
+
};
|
|
18387
|
+
return {
|
|
18388
|
+
release_path: root2,
|
|
18389
|
+
node_path: file2("bin/node", constants3.X_OK),
|
|
18390
|
+
entry_path: file2("daemon/host-update.mjs", constants3.R_OK),
|
|
18391
|
+
installer_path: file2("daemon/install.sh", constants3.R_OK)
|
|
18392
|
+
};
|
|
18393
|
+
}
|
|
18394
|
+
|
|
18395
|
+
// ../shared/src/node/installation/participation.ts
|
|
18396
|
+
function watchUpdateParticipation(input) {
|
|
18397
|
+
const controller = new AbortController();
|
|
18398
|
+
const abort = () => controller.abort();
|
|
18399
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
18400
|
+
for (const event of ["end", "close", "error"]) input.on(event, abort);
|
|
18401
|
+
for (const signal of signals) process.on(signal, abort);
|
|
18402
|
+
if (input.destroyed || input.readableEnded) abort();
|
|
18403
|
+
return {
|
|
18404
|
+
signal: controller.signal,
|
|
18405
|
+
abort,
|
|
18406
|
+
dispose() {
|
|
18407
|
+
for (const event of ["end", "close", "error"]) input.off(event, abort);
|
|
18408
|
+
for (const signal of signals) process.off(signal, abort);
|
|
18409
|
+
}
|
|
18410
|
+
};
|
|
18411
|
+
}
|
|
18412
|
+
|
|
18413
|
+
// ../shared/src/node/installation/recovery.ts
|
|
18414
|
+
import { join as join6 } from "node:path";
|
|
18415
|
+
function updateRecoveryDirectory(home, operationId) {
|
|
18416
|
+
hostUpdateOperationSchema.shape.id.parse(operationId);
|
|
18417
|
+
return join6(home, "updates/jobs", operationId, "recovery");
|
|
18418
|
+
}
|
|
18419
|
+
function readUpdateRecoveryAttempts(home, operationId) {
|
|
18420
|
+
const directory = updateRecoveryDirectory(home, operationId);
|
|
18421
|
+
try {
|
|
18422
|
+
privatePath(directory, true);
|
|
18423
|
+
const ledger = hostUpdateRecoveryLedgerSchema.parse(
|
|
18424
|
+
readPrivateJson(join6(directory, "attempts.json"), HOST_UPDATE_RECOVERY_BYTES)
|
|
18425
|
+
);
|
|
18426
|
+
if (ledger.attempts.some(({ job }) => job.operation_id !== operationId))
|
|
18427
|
+
throw new Error("Recovery ledger belongs to another update");
|
|
18428
|
+
return ledger;
|
|
18429
|
+
} catch (error51) {
|
|
18430
|
+
if (error51.code === "ENOENT") return { format: 1, attempts: [] };
|
|
18431
|
+
throw error51;
|
|
18432
|
+
}
|
|
18433
|
+
}
|
|
18434
|
+
function inspectRecordedRecovery(home, operation2) {
|
|
18435
|
+
const attempt = readUpdateRecoveryAttempts(home, operation2.id).attempts.at(-1);
|
|
18436
|
+
if (!attempt) return void 0;
|
|
18437
|
+
const { job, execution } = attempt;
|
|
18438
|
+
if (job.original_dispatch_id !== operation2.dispatch_id || job.original_worker_id !== operation2.worker_id || job.preflight !== operation2.approved)
|
|
18439
|
+
throw new Error("Recovery record does not match this update");
|
|
18440
|
+
return {
|
|
18441
|
+
id: job.id,
|
|
18442
|
+
requested_revision: job.requested_revision,
|
|
18443
|
+
revision: job.revision,
|
|
18444
|
+
consumed: execution !== null
|
|
18445
|
+
};
|
|
18446
|
+
}
|
|
18447
|
+
|
|
18448
|
+
// ../shared/src/node/installation/updates.ts
|
|
18449
|
+
import { lstatSync as lstatSync2 } from "node:fs";
|
|
18450
|
+
import { join as join7 } from "node:path";
|
|
18451
|
+
function validateHostUpdateLedger(value) {
|
|
18452
|
+
const ledger = hostUpdateLedgerSchema.parse(value);
|
|
18453
|
+
for (const operation2 of [ledger.current, ...ledger.history]) {
|
|
18454
|
+
for (const stage of operation2?.stages ?? []) {
|
|
18455
|
+
if (digest(`${JSON.stringify(stage.record)}
|
|
18456
|
+
`) !== stage.digest)
|
|
18457
|
+
throw new Error("Host update stage receipt digest mismatch");
|
|
18458
|
+
}
|
|
18459
|
+
}
|
|
18460
|
+
return ledger;
|
|
18461
|
+
}
|
|
18462
|
+
function readHostUpdateLedger(home) {
|
|
18463
|
+
try {
|
|
18464
|
+
lstatSync2(home);
|
|
18465
|
+
initialisePrivateHome(home);
|
|
18466
|
+
privatePath(join7(home, "updates"), true);
|
|
18467
|
+
return validateHostUpdateLedger(
|
|
18468
|
+
readPrivateJson(join7(home, "updates/operations.json"), HOST_UPDATE_RECORD_BYTES)
|
|
18469
|
+
);
|
|
18470
|
+
} catch (error51) {
|
|
18471
|
+
if (error51.code === "ENOENT")
|
|
18472
|
+
return { format: 1, current: null, history: [] };
|
|
18473
|
+
throw error51;
|
|
18474
|
+
}
|
|
18475
|
+
}
|
|
18476
|
+
|
|
18477
|
+
// src/lib/host/updates/inspection.ts
|
|
18478
|
+
function inspectStoredHostUpdate(home, input) {
|
|
18479
|
+
const command = hostUpdateCommandSchema.parse(input);
|
|
18480
|
+
if (command.action !== "status" || command.adoption_nonce)
|
|
18481
|
+
return { ok: false, code: "unsupported", operation: null };
|
|
18482
|
+
try {
|
|
18483
|
+
const ledger = readHostUpdateLedger(home);
|
|
18484
|
+
const operation2 = command.id === void 0 || ledger.current?.id === command.id ? ledger.current : ledger.history.find((item) => item.id === command.id) ?? null;
|
|
18485
|
+
return {
|
|
18486
|
+
ok: true,
|
|
18487
|
+
operation: operation2,
|
|
18488
|
+
...operation2 && command.include_recovery ? { recovery: inspectRecordedRecovery(home, operation2) } : {}
|
|
18489
|
+
};
|
|
18490
|
+
} catch {
|
|
18491
|
+
return { ok: false, code: "failed", operation: null };
|
|
18492
|
+
}
|
|
18493
|
+
}
|
|
18494
|
+
|
|
18495
|
+
// src/lib/host/updates/continuation.ts
|
|
18496
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
18497
|
+
import { join as join8 } from "node:path";
|
|
18498
|
+
function supportsParticipatingRecovery(protocol2) {
|
|
18499
|
+
return supportsApplicationFeature(protocol2, { major: 25, minor: 17 });
|
|
18500
|
+
}
|
|
18501
|
+
async function continueStoredHostUpdate(home, input, participation) {
|
|
18502
|
+
const command = hostUpdateCommandSchema.parse(input);
|
|
18503
|
+
if (command.action !== "recover" || command.strategy !== "continue")
|
|
18504
|
+
return { ok: false, code: "unsupported", operation: null };
|
|
18505
|
+
const inspect = () => {
|
|
18506
|
+
const operation2 = readHostUpdateLedger(home).current;
|
|
18507
|
+
if (!operation2 || operation2.id !== command.reference.id)
|
|
18508
|
+
throw new Error("Not the current host update");
|
|
18509
|
+
return { operation: operation2, recovery: inspectRecordedRecovery(home, operation2) };
|
|
18510
|
+
};
|
|
18511
|
+
const requireAuthority = () => {
|
|
18512
|
+
if (participation && (participation.signal.aborted || !participation.authorised()))
|
|
18513
|
+
throw new Error("Host recovery authority expired");
|
|
18514
|
+
};
|
|
18515
|
+
try {
|
|
18516
|
+
requireAuthority();
|
|
18517
|
+
const current = inspect();
|
|
18518
|
+
if (current.operation.phase === "complete" || current.recovery?.requested_revision === command.reference.revision)
|
|
18519
|
+
return { ok: true, ...current };
|
|
18520
|
+
if (current.operation.revision !== command.reference.revision)
|
|
18521
|
+
return { ok: false, code: "conflict", operation: current.operation };
|
|
18522
|
+
const stage = current.operation.stages.find(({ record: record2 }) => record2.component === "daemon");
|
|
18523
|
+
if (!stage) return { ok: false, code: "unsupported", operation: current.operation };
|
|
18524
|
+
const candidate = await readStageCapabilities(home, stage);
|
|
18525
|
+
if (!supportsApplicationFeature(candidate.application, { major: 25, minor: 12 }) || participation && !supportsParticipatingRecovery(candidate.application))
|
|
18526
|
+
return { ok: false, code: "unsupported", operation: current.operation };
|
|
18527
|
+
const paths = updateWorkerExecutables(
|
|
18528
|
+
home,
|
|
18529
|
+
join8(home, "bin/versions", stage.record.generation)
|
|
18530
|
+
);
|
|
18531
|
+
requireAuthority();
|
|
18532
|
+
await new Promise((resolve2) => {
|
|
18533
|
+
const revoke = () => child.stdin?.end();
|
|
18534
|
+
const child = execFile2(
|
|
18535
|
+
paths.node_path,
|
|
18536
|
+
[
|
|
18537
|
+
paths.entry_path,
|
|
18538
|
+
"--home",
|
|
18539
|
+
home,
|
|
18540
|
+
"--operation",
|
|
18541
|
+
command.reference.id,
|
|
18542
|
+
participation ? "--participating-recovery" : "--dispatch-recovery",
|
|
18543
|
+
String(command.reference.revision)
|
|
18544
|
+
],
|
|
18545
|
+
{ encoding: "utf8", maxBuffer: 256 * 1024, timeout: 12e4 },
|
|
18546
|
+
() => {
|
|
18547
|
+
participation?.signal.removeEventListener("abort", revoke);
|
|
18548
|
+
resolve2();
|
|
18549
|
+
}
|
|
18550
|
+
);
|
|
18551
|
+
child.stdin?.on("error", () => {
|
|
18552
|
+
});
|
|
18553
|
+
participation?.signal.addEventListener("abort", revoke, { once: true });
|
|
18554
|
+
if (participation?.signal.aborted) revoke();
|
|
18555
|
+
});
|
|
18556
|
+
const observed = inspect();
|
|
18557
|
+
return observed.recovery?.requested_revision === command.reference.revision ? { ok: true, ...observed } : { ok: false, code: "failed", operation: observed.operation };
|
|
18558
|
+
} catch {
|
|
18559
|
+
return { ok: false, code: "failed", operation: null };
|
|
18560
|
+
}
|
|
18561
|
+
}
|
|
18562
|
+
|
|
18563
|
+
// src/lib/host/updates/channel.ts
|
|
18564
|
+
async function serveParticipatingUpdate(home, input, output) {
|
|
18565
|
+
const participation = watchUpdateParticipation(input);
|
|
18566
|
+
let stop = () => {
|
|
18567
|
+
};
|
|
18568
|
+
let received = false;
|
|
18569
|
+
let ended = () => {
|
|
18570
|
+
};
|
|
18571
|
+
const timer = setTimeout(participation.abort, 135e3);
|
|
18572
|
+
timer.unref();
|
|
18573
|
+
output.on("error", participation.abort);
|
|
18574
|
+
try {
|
|
18575
|
+
await new Promise((resolve2) => {
|
|
18576
|
+
ended = () => {
|
|
18577
|
+
if (!received) resolve2();
|
|
18578
|
+
};
|
|
18579
|
+
participation.signal.addEventListener("abort", ended, { once: true });
|
|
18580
|
+
stop = jsonLines(
|
|
18581
|
+
input,
|
|
18582
|
+
(value) => {
|
|
18583
|
+
if (received) {
|
|
18584
|
+
participation.abort();
|
|
18585
|
+
return;
|
|
18586
|
+
}
|
|
18587
|
+
const request = hostUpdateControlRequestSchema.parse(value);
|
|
18588
|
+
received = true;
|
|
18589
|
+
void continueStoredHostUpdate(home, request.command, {
|
|
18590
|
+
signal: participation.signal,
|
|
18591
|
+
authorised: () => !participation.signal.aborted
|
|
18592
|
+
}).then((result) => {
|
|
18593
|
+
if (!participation.signal.aborted)
|
|
18594
|
+
output.write(
|
|
18595
|
+
JSON.stringify({
|
|
18596
|
+
t: "host-update-result",
|
|
18597
|
+
request_id: request.request_id,
|
|
18598
|
+
result
|
|
18599
|
+
}) + "\n"
|
|
18600
|
+
);
|
|
18601
|
+
}).catch(participation.abort).finally(resolve2);
|
|
18602
|
+
},
|
|
18603
|
+
participation.abort,
|
|
18604
|
+
16 * 1024
|
|
18605
|
+
);
|
|
18606
|
+
if (participation.signal.aborted) ended();
|
|
18607
|
+
});
|
|
18608
|
+
} finally {
|
|
18609
|
+
clearTimeout(timer);
|
|
18610
|
+
stop();
|
|
18611
|
+
participation.signal.removeEventListener("abort", ended);
|
|
18612
|
+
participation.dispose();
|
|
18613
|
+
input.destroy();
|
|
18614
|
+
}
|
|
18615
|
+
}
|
|
18616
|
+
|
|
16788
18617
|
// src/host-control.ts
|
|
16789
|
-
if (process.argv.
|
|
18618
|
+
if (process.argv.length === 3 && process.argv[2] === "--participating-update") {
|
|
18619
|
+
await serveParticipatingUpdate(clientHome(), process.stdin, process.stdout);
|
|
18620
|
+
} else if (process.argv.length === 3 && ["--updates", "--continue-update"].includes(process.argv[2])) {
|
|
18621
|
+
try {
|
|
18622
|
+
let input = "";
|
|
18623
|
+
for await (const chunk of process.stdin) {
|
|
18624
|
+
input += String(chunk);
|
|
18625
|
+
if (Buffer.byteLength(input) > 16 * 1024)
|
|
18626
|
+
throw new Error("Inspection input exceeds its limit");
|
|
18627
|
+
}
|
|
18628
|
+
const request = hostUpdateControlRequestSchema.parse(JSON.parse(input));
|
|
18629
|
+
const result = process.argv[2] === "--continue-update" ? await continueStoredHostUpdate(clientHome(), request.command) : inspectStoredHostUpdate(clientHome(), request.command);
|
|
18630
|
+
process.stdout.write(
|
|
18631
|
+
JSON.stringify({ t: "host-update-result", request_id: request.request_id, result }) + "\n"
|
|
18632
|
+
);
|
|
18633
|
+
} catch {
|
|
18634
|
+
process.stdout.write(JSON.stringify({ t: "error", code: "rejected" }) + "\n");
|
|
18635
|
+
}
|
|
18636
|
+
} else if (process.argv.includes("--inspect")) {
|
|
16790
18637
|
const inspection = await inspectHostLocally(clientHome()).catch(() => ({
|
|
16791
18638
|
t: "error",
|
|
16792
18639
|
code: "rejected"
|
|
16793
18640
|
}));
|
|
16794
18641
|
process.stdout.write(JSON.stringify(inspection ?? { t: "error", code: "unavailable" }) + "\n");
|
|
16795
18642
|
} else {
|
|
16796
|
-
const
|
|
16797
|
-
privatePath(
|
|
16798
|
-
const socket = connect2(
|
|
18643
|
+
const path2 = ipcPath(clientHome(), "host");
|
|
18644
|
+
privatePath(path2);
|
|
18645
|
+
const socket = connect2(path2);
|
|
16799
18646
|
const stop = () => {
|
|
16800
18647
|
socket.destroy();
|
|
16801
18648
|
process.stdin.destroy();
|