@ouro.bot/cli 0.1.0-alpha.816 → 0.1.0-alpha.818

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.
Files changed (50) hide show
  1. package/assets/sanctuary-host-launcher.sh +16 -0
  2. package/changelog.json +16 -0
  3. package/deploy/unraid/Dockerfile +6 -0
  4. package/deploy/unraid/README.txt +296 -62
  5. package/deploy/unraid/docker-man-template-transaction.mjs +192 -7
  6. package/deploy/unraid/sanctuary-acceptance-adapter.sh +1 -1
  7. package/deploy/unraid/sanctuary-acceptance-contract.json +7 -7
  8. package/deploy/unraid/sanctuary-authority-installation.json +36 -0
  9. package/deploy/unraid/sanctuary-authority-service.sh +30 -0
  10. package/deploy/unraid/sanctuary-unit16-host-broker.mjs +62 -9
  11. package/deploy/unraid/sanctuary-unit16-run.sh +15 -15
  12. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
  13. package/deploy/unraid/sanctuary.ouro/tool-profiles.json +2 -2
  14. package/deploy/unraid/sanctuary.xml +2 -1
  15. package/dist/heart/core.js +2 -1
  16. package/dist/heart/daemon/container-spec-auditor-main.js +8 -7
  17. package/dist/heart/daemon/container-spec-auditor.js +16 -9
  18. package/dist/heart/daemon/sanctuary-acceptance-adapter.js +95 -91
  19. package/dist/heart/daemon/sanctuary-acceptance-harness.js +95 -169
  20. package/dist/heart/daemon/sanctuary-acceptance-scenarios.js +4 -5
  21. package/dist/heart/daemon/sanctuary-authority-codec.js +86 -0
  22. package/dist/heart/daemon/sanctuary-authority-epoch.js +256 -0
  23. package/dist/heart/daemon/sanctuary-authority-installation.js +140 -0
  24. package/dist/heart/daemon/sanctuary-authority-ledger.js +241 -0
  25. package/dist/heart/daemon/sanctuary-authority-root-lifecycle.js +780 -0
  26. package/dist/heart/daemon/sanctuary-authority-vault-migration.js +79 -0
  27. package/dist/heart/daemon/sanctuary-host-authority.js +1008 -0
  28. package/dist/heart/daemon/sanctuary-host-detached-supervisor.js +494 -0
  29. package/dist/heart/daemon/sanctuary-host-executor.js +670 -0
  30. package/dist/heart/daemon/sanctuary-host-linux-kernel.js +334 -0
  31. package/dist/heart/daemon/sanctuary-host-supervisor-entry.js +207 -0
  32. package/dist/heart/daemon/sanctuary-host-supervisor.js +95 -0
  33. package/dist/heart/daemon/sanctuary-telegram-authority-entry.js +445 -0
  34. package/dist/heart/daemon/sanctuary-telegram-authority-gateway.js +585 -0
  35. package/dist/heart/daemon/sanctuary-telegram-authority-service.js +615 -0
  36. package/dist/heart/daemon/sense-manager.js +20 -10
  37. package/dist/repertoire/tools-sanctuary-host.js +202 -0
  38. package/dist/repertoire/tools.js +15 -6
  39. package/dist/senses/private-runtime.js +2 -2
  40. package/dist/senses/root-host-approval-port.js +345 -0
  41. package/dist/senses/root-host-approval-runtime.js +393 -0
  42. package/dist/senses/sanctuary-authority-resident.js +102 -0
  43. package/dist/senses/telegram-admission.js +7 -0
  44. package/dist/senses/telegram-attachments.js +5 -1
  45. package/dist/senses/telegram-authority-transport.js +231 -0
  46. package/dist/senses/telegram-client.js +31 -8
  47. package/dist/senses/telegram-entry.js +1 -1
  48. package/dist/senses/telegram.js +168 -28
  49. package/npm-shrinkwrap.json +2 -2
  50. package/package.json +1 -1
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateSanctuaryAuthorityVault = migrateSanctuaryAuthorityVault;
4
+ const runtime_credentials_1 = require("../runtime-credentials");
5
+ const runtime_1 = require("../../nerves/runtime");
6
+ function identity(value) {
7
+ const candidate = value;
8
+ if (!candidate || typeof candidate.token !== "string" || !/^[1-9][0-9]*:[A-Za-z0-9_-]{20,}$/u.test(candidate.token)
9
+ || candidate.token.split(":")[0] !== candidate.botId || !/^[1-9][0-9]*$/u.test(candidate.ownerUserId)
10
+ || candidate.ownerUserId !== candidate.ownerChatId)
11
+ throw new Error("Sanctuary vault token identity is invalid");
12
+ return candidate;
13
+ }
14
+ async function readOwners() {
15
+ const results = [
16
+ await (0, runtime_credentials_1.refreshRuntimeCredentialConfig)("sanctuary"),
17
+ await (0, runtime_credentials_1.refreshMachineRuntimeCredentialConfig)("sanctuary", "sanctuary"),
18
+ ];
19
+ return results.map((result) => {
20
+ if (result.ok)
21
+ return result.config;
22
+ if (result.reason === "missing")
23
+ return {};
24
+ throw new Error("Sanctuary vault owner is unavailable");
25
+ });
26
+ }
27
+ function absent(owners) {
28
+ if (owners.some((owner) => Object.hasOwn(owner, "telegramBotToken")))
29
+ throw new Error("Sanctuary resident token residue");
30
+ return { tokenAbsent: true };
31
+ }
32
+ // Invoked only by the fixed root migration process, never by the resident daemon.
33
+ // Snapshot output travels through a private pipe to the root transaction, not logs.
34
+ async function migrateSanctuaryAuthorityVault(operation, input) {
35
+ if (process.getuid() !== 0 || process.getgid() !== 0)
36
+ throw new Error("Sanctuary vault migration requires root");
37
+ if (!["snapshot", "presence", "absent", "remove", "restore"].includes(operation))
38
+ throw new Error("Sanctuary vault migration operation is invalid");
39
+ (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "daemon.sanctuary_vault_handoff_requested", message: "Sanctuary vault handoff requested", meta: { operation } });
40
+ const supplied = operation === "restore" ? identity(input) : null;
41
+ const owners = await readOwners();
42
+ if (operation === "presence")
43
+ return { tokenPresent: owners.some((owner) => Object.hasOwn(owner, "telegramBotToken")) };
44
+ if (operation === "absent")
45
+ return absent(owners);
46
+ if (operation === "snapshot") {
47
+ const merged = Object.assign({}, ...owners);
48
+ const selected = identity({ token: merged.telegramBotToken, botId: String(merged.telegramBotToken).split(":")[0], ownerUserId: merged.telegramAuthorizedUserId, ownerChatId: merged.telegramAuthorizedChatId });
49
+ for (const owner of owners) {
50
+ for (const [field, expected] of [["telegramBotToken", selected.token], ["telegramAuthorizedUserId", selected.ownerUserId], ["telegramAuthorizedChatId", selected.ownerChatId]]) {
51
+ if (Object.hasOwn(owner, field) && owner[field] !== expected)
52
+ throw new Error("Sanctuary vault owner identity disagrees");
53
+ }
54
+ }
55
+ return selected;
56
+ }
57
+ const next = owners.map((owner) => {
58
+ const copy = { ...owner };
59
+ delete copy.telegramBotToken;
60
+ return copy;
61
+ });
62
+ if (supplied) {
63
+ next[0].telegramBotToken = supplied.token;
64
+ next[0].telegramAuthorizedUserId = supplied.ownerUserId;
65
+ next[0].telegramAuthorizedChatId = supplied.ownerChatId;
66
+ }
67
+ // Full replacement is intentional here: merge cannot remove a credential.
68
+ // Each replacement starts from a fresh read of its own canonical owner.
69
+ await (0, runtime_credentials_1.upsertRuntimeCredentialConfig)("sanctuary", next[0]);
70
+ await (0, runtime_credentials_1.upsertMachineRuntimeCredentialConfig)("sanctuary", "sanctuary", next[1]);
71
+ const readback = await readOwners();
72
+ if (!supplied)
73
+ return absent(readback);
74
+ absent([readback[1]]);
75
+ if (readback[0].telegramBotToken !== supplied.token || readback[0].telegramAuthorizedUserId !== supplied.ownerUserId
76
+ || readback[0].telegramAuthorizedChatId !== supplied.ownerChatId)
77
+ throw new Error("Sanctuary vault token restoration readback failed");
78
+ return { restored: true };
79
+ }