@ouro.bot/cli 0.1.0-alpha.1653 → 0.1.0-alpha.1655
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.json +22 -1
- package/deploy/unraid/Dockerfile +2 -2
- package/deploy/unraid/README.txt +39 -37
- package/deploy/unraid/install.sh +12 -5
- package/deploy/unraid/sanctuary-acceptance-contract.json +12 -12
- package/deploy/unraid/sanctuary-deployment-target.mjs +2 -1
- package/deploy/unraid/sanctuary-replay-gate.mjs +2 -2
- package/deploy/unraid/sanctuary-unit16-host-broker.mjs +25 -15
- package/deploy/unraid/sanctuary-unit16-run.sh +16 -11
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +3 -3
- package/dist/a2a/operator-trust.js +1 -1
- package/dist/heart/daemon/sanctuary-acceptance-adapter.js +55 -52
- package/dist/heart/daemon/sanctuary-acceptance-marker.js +9 -0
- package/dist/heart/daemon/sanctuary-acceptance-scenarios.js +9 -8
- package/dist/senses/sanctuary-health-acceptance-probe.js +10 -9
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -113,6 +113,11 @@ test "$IMAGE_DIGEST" != "$IMAGE_ID" || exit 2
|
|
|
113
113
|
test "${#IMAGE_DIGEST}" -eq 64 || exit 2
|
|
114
114
|
case "$IMAGE_DIGEST" in *[!0-9a-f]*) exit 2 ;; esac
|
|
115
115
|
test "$(/usr/bin/timeout -s KILL 20 /usr/bin/docker image inspect --format '{{.Id}}' "$IMAGE_ID")" = "$IMAGE_ID" || exit 1
|
|
116
|
+
# The host bundle keeps its folder name; inside the container it sits under the Butler name the image runs, its ENTRYPOINT's
|
|
117
|
+
# `--package-managed-agent <name>` (butler from M2 on, sanctuary before it), as src/heart/butler-agent.ts butlerNameFromEntrypoint reads it.
|
|
118
|
+
BUTLER_NAME=$(/usr/bin/timeout -s KILL 20 /usr/bin/docker image inspect --format '{{json .Config.Entrypoint}}' "$IMAGE_ID" | sed -n 's/.*"--package-managed-agent","\([^"]*\)".*/\1/p') || exit 1
|
|
119
|
+
case "$BUTLER_NAME" in butler | sanctuary) ;; *) BUTLER_NAME=sanctuary ;; esac
|
|
120
|
+
CONTAINER_BUNDLE=/home/ouro/AgentBundles/$BUTLER_NAME.ouro
|
|
116
121
|
test -d "$CONFIG_ROOT" && test ! -L "$CONFIG_ROOT" || exit 1
|
|
117
122
|
test -d "$EVIDENCE_ROOT" && test ! -L "$EVIDENCE_ROOT" || exit 1
|
|
118
123
|
test "$(stat -c '%u:%g %a' "$CONFIG_ROOT")" = "10001:10001 700" || exit 1
|
|
@@ -305,7 +310,7 @@ materialize_config() {
|
|
|
305
310
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence,readonly" \
|
|
306
311
|
--mount "type=bind,src=$EXTRA_MOUNT,dst=/run/ouro-acceptance/closed-inventory.json,readonly" \
|
|
307
312
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
308
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
313
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE,readonly" \
|
|
309
314
|
--entrypoint /opt/ouro/deploy/unraid/sanctuary-acceptance-adapter.sh \
|
|
310
315
|
"$IMAGE_ID" materialize-config "$COMMAND" >"$OUTPUT"
|
|
311
316
|
elif test -n "$SNAPSHOT_PHASE"; then
|
|
@@ -314,7 +319,7 @@ materialize_config() {
|
|
|
314
319
|
--mount "type=bind,src=/run/ouro-authority,dst=/run/ouro-authority,readonly" \
|
|
315
320
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence,readonly" \
|
|
316
321
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
317
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
322
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE,readonly" \
|
|
318
323
|
--entrypoint /opt/ouro/deploy/unraid/sanctuary-acceptance-adapter.sh \
|
|
319
324
|
"$IMAGE_ID" materialize-config "$COMMAND" "$SNAPSHOT_PHASE" >"$OUTPUT"
|
|
320
325
|
else
|
|
@@ -323,7 +328,7 @@ materialize_config() {
|
|
|
323
328
|
--mount "type=bind,src=/run/ouro-authority,dst=/run/ouro-authority,readonly" \
|
|
324
329
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence,readonly" \
|
|
325
330
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
326
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
331
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE,readonly" \
|
|
327
332
|
--entrypoint /opt/ouro/deploy/unraid/sanctuary-acceptance-adapter.sh \
|
|
328
333
|
"$IMAGE_ID" materialize-config "$COMMAND" >"$OUTPUT"
|
|
329
334
|
fi
|
|
@@ -384,7 +389,7 @@ assert_acceptance_state_inode() {
|
|
|
384
389
|
ACCEPTANCE_PIN_INODE=$(stat -Lc '%d:%i' "$ACCEPTANCE_PIN_ROOT") || return 1
|
|
385
390
|
test "$(stat -Lc '%d:%i' "$ACCEPTANCE_STATE_ROOT")" = "$ACCEPTANCE_PIN_INODE" || return 1
|
|
386
391
|
test "$(/usr/bin/timeout -s KILL 20 /usr/bin/docker inspect --format '{{.Name}} {{.Image}}' "$TARGET_CONTAINER_ID")" = "/$PRODUCTION_CONTAINER $IMAGE_ID" || return 1
|
|
387
|
-
test "$(/usr/bin/timeout -s KILL 20 /usr/bin/docker exec "$TARGET_CONTAINER_ID" stat -Lc '%d:%i' /
|
|
392
|
+
test "$(/usr/bin/timeout -s KILL 20 /usr/bin/docker exec "$TARGET_CONTAINER_ID" stat -Lc '%d:%i' "$CONTAINER_BUNDLE/state/acceptance")" = "$ACCEPTANCE_PIN_INODE" || return 1
|
|
388
393
|
}
|
|
389
394
|
|
|
390
395
|
if test "$COMMAND" = evidence-snapshot || test "$COMMAND" = reboot-request || test "$COMMAND" = reboot-resume; then
|
|
@@ -435,7 +440,7 @@ run_harness() {
|
|
|
435
440
|
--mount "type=bind,src=$CONFIG_PATH,dst=/run/ouro-acceptance/config.json,readonly" \
|
|
436
441
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence" \
|
|
437
442
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
438
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
443
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE$BUNDLE_SUFFIX" \
|
|
439
444
|
--mount "type=bind,src=$SOCKET_ROOT,dst=/run/ouro-host-acceptance,readonly" \
|
|
440
445
|
--mount "type=bind,src=$IMAGE_FACT,dst=/run/ouro-acceptance/image-digest,readonly" \
|
|
441
446
|
--mount "type=bind,src=$CONTAINER_FACT,dst=/run/ouro-acceptance/container-digest,readonly" \
|
|
@@ -452,7 +457,7 @@ run_harness() {
|
|
|
452
457
|
--mount "type=bind,src=$CONFIG_PATH,dst=/run/ouro-acceptance/config.json,readonly" \
|
|
453
458
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence" \
|
|
454
459
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
455
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
460
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE$BUNDLE_SUFFIX" \
|
|
456
461
|
--mount "type=bind,src=$IMAGE_FACT,dst=/run/ouro-acceptance/image-digest,readonly" \
|
|
457
462
|
--mount "type=bind,src=$CONTAINER_FACT,dst=/run/ouro-acceptance/container-digest,readonly" \
|
|
458
463
|
--mount "type=bind,src=$HEALTH_FACT,dst=/run/ouro-acceptance/postboot-health.json,readonly" \
|
|
@@ -468,8 +473,8 @@ run_harness() {
|
|
|
468
473
|
--mount "type=bind,src=$CONFIG_PATH,dst=/run/ouro-acceptance/config.json,readonly" \
|
|
469
474
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence" \
|
|
470
475
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
471
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
472
|
-
--mount "type=bind,src=$ACCEPTANCE_PIN_ROOT,dst
|
|
476
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE,readonly" \
|
|
477
|
+
--mount "type=bind,src=$ACCEPTANCE_PIN_ROOT,dst=$CONTAINER_BUNDLE/state/acceptance" \
|
|
473
478
|
--mount "type=bind,src=$SOCKET_ROOT,dst=/run/ouro-host-acceptance,readonly" \
|
|
474
479
|
--mount "type=bind,src=$IMAGE_FACT,dst=/run/ouro-acceptance/image-digest,readonly" \
|
|
475
480
|
--mount "type=bind,src=$CONTAINER_FACT,dst=/run/ouro-acceptance/container-digest,readonly" \
|
|
@@ -480,14 +485,14 @@ run_harness() {
|
|
|
480
485
|
--entrypoint /opt/ouro/deploy/unraid/sanctuary-acceptance-harness.sh \
|
|
481
486
|
"$IMAGE_ID" "$COMMAND" --config /run/ouro-acceptance/config.json
|
|
482
487
|
elif test "$BROKER" = yes; then
|
|
483
|
-
if test "$COMMAND" = reboot-request || test "$COMMAND" = reboot-resume; then ACCEPTANCE_MOUNT="--mount type=bind,src=$ACCEPTANCE_PIN_ROOT,dst
|
|
488
|
+
if test "$COMMAND" = reboot-request || test "$COMMAND" = reboot-resume; then ACCEPTANCE_MOUNT="--mount type=bind,src=$ACCEPTANCE_PIN_ROOT,dst=$CONTAINER_BUNDLE/state/acceptance"; else ACCEPTANCE_MOUNT=; fi
|
|
484
489
|
/usr/bin/timeout -s KILL "$TIME_LIMIT" /usr/bin/docker run --rm --pull=never --network "$NETWORK" \
|
|
485
490
|
--user 10001:10001 --read-only --cap-drop ALL --security-opt no-new-privileges \
|
|
486
491
|
--mount "type=bind,src=/run/ouro-authority,dst=/run/ouro-authority,readonly" \
|
|
487
492
|
--mount "type=bind,src=$CONFIG_PATH,dst=/run/ouro-acceptance/config.json,readonly" \
|
|
488
493
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence" \
|
|
489
494
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
490
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
495
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE$BUNDLE_SUFFIX" \
|
|
491
496
|
$ACCEPTANCE_MOUNT \
|
|
492
497
|
--mount "type=bind,src=$SOCKET_ROOT,dst=/run/ouro-host-acceptance,readonly" \
|
|
493
498
|
--mount "type=bind,src=$IMAGE_FACT,dst=/run/ouro-acceptance/image-digest,readonly" \
|
|
@@ -505,7 +510,7 @@ run_harness() {
|
|
|
505
510
|
--mount "type=bind,src=$CONFIG_PATH,dst=/run/ouro-acceptance/config.json,readonly" \
|
|
506
511
|
--mount "type=bind,src=$EVIDENCE_ROOT,dst=/evidence" \
|
|
507
512
|
--mount "type=bind,src=$RUNTIME_ROOT,dst=/home/ouro/.ouro-cli,readonly" \
|
|
508
|
-
--mount "type=bind,src=$BUNDLE_ROOT,dst
|
|
513
|
+
--mount "type=bind,src=$BUNDLE_ROOT,dst=$CONTAINER_BUNDLE$BUNDLE_SUFFIX" \
|
|
509
514
|
--mount "type=bind,src=$IMAGE_FACT,dst=/run/ouro-acceptance/image-digest,readonly" \
|
|
510
515
|
--mount "type=bind,src=$CONTAINER_FACT,dst=/run/ouro-acceptance/container-digest,readonly" \
|
|
511
516
|
--mount "type=bind,src=$HEALTH_FACT,dst=/run/ouro-acceptance/postboot-health.json,readonly" \
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1655</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
<DonateLink/>
|
|
23
23
|
<Requires/>
|
|
24
24
|
<Config Name="Runtime state" Target="/home/ouro/.ouro-cli" Default="/mnt/user/appdata/ouro-butler/runtime/.ouro-cli" Mode="rw" Description="Machine-scoped runtime" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/ouro-butler/runtime/.ouro-cli</Config>
|
|
25
|
-
<Config Name="Agent bundle" Target="/home/ouro/AgentBundles/
|
|
25
|
+
<Config Name="Agent bundle" Target="/home/ouro/AgentBundles/butler.ouro" Default="/mnt/user/appdata/ouro-butler/agent/sanctuary.ouro" Mode="rw" Description="Sanctuary bundle" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/ouro-butler/agent/sanctuary.ouro</Config>
|
|
26
26
|
<Config Name="Privileged event spool" Target="/run/ouro-events" Default="/boot/config/custom/ouro-events/spool" Mode="ro" Description="Root-owned detector envelopes, read-only inside the Butler" Type="Path" Display="always" Required="true" Mask="false">/boot/config/custom/ouro-events/spool</Config>
|
|
27
27
|
<Config Name="Root authority socket" Target="/run/ouro-authority" Default="/run/ouro-authority" Mode="ro" Description="Root-owned gateway socket and public issuer pins only" Type="Path" Display="always" Required="true" Mask="false">/run/ouro-authority</Config>
|
|
28
|
-
<Config Name="Operator trust (read-only)" Target="/etc/ouro/trust/
|
|
28
|
+
<Config Name="Operator trust (read-only)" Target="/etc/ouro/trust/butler" Default="/mnt/user/appdata/ouro-butler/trust/sanctuary" Mode="ro" Description="Root-owned grants the Butler honours (delegated commands, escalation). Read-only inside the Butler; only the host operator can change it" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/ouro-butler/trust/sanctuary</Config>
|
|
29
29
|
<Config Name="Bundle sync key (read-only)" Target="/run/ouro-sync" Default="/mnt/user/appdata/ouro-butler/sync" Mode="ro" Description="Deploy key the Butler's bundle sync pushes with, owned by 10002:10002 mode 0400 so only the sync wrapper reads it. Read-only inside the Butler" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/ouro-butler/sync</Config>
|
|
30
30
|
</Container>
|
|
@@ -67,7 +67,7 @@ function overrideTrustRootForTests(root) {
|
|
|
67
67
|
throw new Error("overrideTrustRootForTests is for tests only");
|
|
68
68
|
trustRoot = root ?? exports.OPERATOR_TRUST_ROOT;
|
|
69
69
|
}
|
|
70
|
-
/** The agent a bundle root belongs to: `~/AgentBundles/
|
|
70
|
+
/** The agent a bundle root belongs to: `~/AgentBundles/butler.ouro` is `butler`, so its grants are read from `/etc/ouro/trust/butler`. */
|
|
71
71
|
function agentNameFromRoot(agentRoot) {
|
|
72
72
|
return path.basename(agentRoot).replace(/\.ouro$/u, "");
|
|
73
73
|
}
|
|
@@ -74,6 +74,7 @@ const sanctuary_grounding_1 = require("../../senses/sanctuary-grounding");
|
|
|
74
74
|
const tools_1 = require("../../repertoire/tools");
|
|
75
75
|
const relationship_authorization_1 = require("../../repertoire/relationship-authorization");
|
|
76
76
|
const core_1 = require("../core");
|
|
77
|
+
const butler_agent_1 = require("../butler-agent");
|
|
77
78
|
const identity_1 = require("../identity");
|
|
78
79
|
const approval_store_1 = require("../approval-store");
|
|
79
80
|
const provider_credentials_1 = require("../provider-credentials");
|
|
@@ -103,9 +104,9 @@ const NETWORK_TIMEOUT_MS = 10_000;
|
|
|
103
104
|
const KEY_DIRECTORY = "/boot/config/plugins/dynamix.my.servers/keys";
|
|
104
105
|
const SELECTED_KEY_RECORD = "/run/ouro-acceptance/unraid-key.json";
|
|
105
106
|
const CALLBACK_PLAYBACK_JOURNAL = "state/approvals/sanctuary-callback-playback.sqlite";
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
107
|
+
const telegramIdentityKeyPath = () => `${(0, butler_agent_1.butlerContainerPaths)((0, sanctuary_acceptance_marker_1.acceptanceButler)()).agentRoot}/state/senses/telegram/identity.key`;
|
|
108
|
+
const telegramAuditPath = () => `${(0, butler_agent_1.butlerContainerPaths)((0, sanctuary_acceptance_marker_1.acceptanceButler)()).agentRoot}/${telegram_audit_ledger_1.TELEGRAM_ACCEPTANCE_AUDIT_RELATIVE_PATH}`;
|
|
109
|
+
const telegramAuditHeadPath = () => `${(0, butler_agent_1.butlerContainerPaths)((0, sanctuary_acceptance_marker_1.acceptanceButler)()).agentRoot}/${telegram_audit_ledger_1.TELEGRAM_ACCEPTANCE_AUDIT_HEAD_RELATIVE_PATH}`;
|
|
109
110
|
const IMAGE_DIGEST_FILE = "/run/ouro-acceptance/image-digest";
|
|
110
111
|
const CONTAINER_DIGEST_FILE = "/run/ouro-acceptance/container-digest";
|
|
111
112
|
const PROCESS_BINDING_DIGEST_FILE = "/run/ouro-acceptance/process-binding-digest";
|
|
@@ -116,7 +117,9 @@ const CLOSED_INVENTORY_FILE = "/run/ouro-acceptance/closed-inventory.json";
|
|
|
116
117
|
const HOST_BROKER_SOCKET = "/run/ouro-host-acceptance/adapter.sock";
|
|
117
118
|
const MAX_BROKER_RESPONSE = 256 * 1024;
|
|
118
119
|
const TARGET_SERVER_ID = "sanctuary-unraid";
|
|
120
|
+
// The host broker's target and the vault's machine id. Both keep the name `sanctuary` through the rename.
|
|
119
121
|
const TARGET_ID = "sanctuary";
|
|
122
|
+
const MACHINE_ID = "sanctuary";
|
|
120
123
|
const SHA256 = /^[0-9a-f]{64}$/u;
|
|
121
124
|
const APPROVAL_EVIDENCE_LABELS = new Set([
|
|
122
125
|
"unit-15c-1-no-callback-terminalization", "unit-16i-delayed-approval", "unit-16j-denial",
|
|
@@ -267,7 +270,7 @@ function createSanctuaryAcceptanceAdapterDependencies(secretFd = 3, options = {}
|
|
|
267
270
|
refreshMachine: runtime_credentials_1.refreshMachineRuntimeCredentialConfig,
|
|
268
271
|
mergeMachine: runtime_credentials_1.mergeMachineRuntimeCredentialConfig,
|
|
269
272
|
callbackProbe: executeSanctuaryAcceptanceCallbackProbe,
|
|
270
|
-
callbackPlaybackSnapshot: (coordinateDigest) => callbackPlaybackSnapshot((0, identity_1.getAgentRoot)(
|
|
273
|
+
callbackPlaybackSnapshot: (coordinateDigest) => callbackPlaybackSnapshot((0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)()), coordinateDigest),
|
|
271
274
|
interactiveRuntime: executeSanctuaryInteractiveRuntimeOperation,
|
|
272
275
|
hostRequest: options.hostRequest ?? ((payload) => defaultHostRequest(payload, hostBrokerSocket, adapterTimeoutMs)),
|
|
273
276
|
telegramCredentials: acceptanceTelegramIdentity,
|
|
@@ -276,7 +279,7 @@ function createSanctuaryAcceptanceAdapterDependencies(secretFd = 3, options = {}
|
|
|
276
279
|
providerRuntime: core_1.getProviderRuntime,
|
|
277
280
|
};
|
|
278
281
|
const healthDriver = createSanctuaryHealthAcceptanceScenarioDriver(dependencies.hostRequest);
|
|
279
|
-
const scenarioAgentRoot = options.scenarioCapture?.agentRoot ?? (0, identity_1.getAgentRoot)(
|
|
282
|
+
const scenarioAgentRoot = options.scenarioCapture?.agentRoot ?? (0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)());
|
|
280
283
|
const interactiveDriver = createSanctuaryInteractiveAcceptanceScenarioDriver({
|
|
281
284
|
agentRoot: scenarioAgentRoot,
|
|
282
285
|
hostRequest: dependencies.hostRequest,
|
|
@@ -296,7 +299,7 @@ function createSanctuaryAcceptanceAdapterDependencies(secretFd = 3, options = {}
|
|
|
296
299
|
gateStatusPath: options.scenarioCapture?.gateStatusPath,
|
|
297
300
|
});
|
|
298
301
|
dependencies.finalizeScenarios = createSanctuaryAcceptanceScenarioFinalizer({
|
|
299
|
-
readActiveScenario: () => (0, sanctuary_acceptance_marker_1.readSanctuaryAcceptanceMarker)(
|
|
302
|
+
readActiveScenario: () => (0, sanctuary_acceptance_marker_1.readSanctuaryAcceptanceMarker)((0, sanctuary_acceptance_marker_1.acceptanceButler)(), scenarioAgentRoot),
|
|
300
303
|
recoverHealthScenario: healthDriver.recover,
|
|
301
304
|
finalizeInteractiveScenario: (label, scenarioHandleDigest) => {
|
|
302
305
|
interactiveDriver.complete(label, scenarioHandleDigest);
|
|
@@ -743,6 +746,7 @@ function parseHealthProbeReceipt(raw, label, scenarioHandleDigest, identityKey)
|
|
|
743
746
|
const manifestJob = object(manifest[0], "Sanctuary scheduler manifest job");
|
|
744
747
|
const origin = object(scheduler.schedulerOrigin, "Sanctuary scheduler origin");
|
|
745
748
|
const manifestKeys = ["agent", "command", "id", "lastRun", "schedule", "taskId", "taskPath"].sort();
|
|
749
|
+
const butler = (0, butler_agent_1.butlerContainerPaths)((0, sanctuary_acceptance_marker_1.acceptanceButler)());
|
|
746
750
|
if (!identityKey || !(0, sanctuary_scheduler_liveness_1.verifySanctuarySchedulerLivenessReceiptMac)(identityKey, scheduler)
|
|
747
751
|
|| JSON.stringify(Object.keys(scheduler).sort()) !== JSON.stringify(schedulerKeys)
|
|
748
752
|
|| scheduler.schemaVersion !== "sanctuary-scheduler-liveness-receipt-v1" || scheduler.label !== label || scheduler.scenarioHandleDigest !== scenarioHandleDigest
|
|
@@ -757,13 +761,13 @@ function parseHealthProbeReceipt(raw, label, scenarioHandleDigest, identityKey)
|
|
|
757
761
|
|| typeof sweep.recordDigest !== "string" || !SHA256.test(sweep.recordDigest) || sweep.opened !== 0 || sweep.recovered !== 0 || sweep.digestDue !== false || sweep.deliveryId !== null
|
|
758
762
|
|| JSON.stringify(Object.keys(supervisor).sort()) !== JSON.stringify(supervisorKeys) || supervisor.schemaVersion !== "supercronic-supervisor-snapshot-v1"
|
|
759
763
|
|| !Number.isSafeInteger(supervisor.daemonPid) || Number(supervisor.daemonPid) !== 1 || supervisor.childCount !== 1 || !Number.isSafeInteger(supervisor.childPid) || Number(supervisor.childPid) <= 1 || supervisor.healthy !== true
|
|
760
|
-
|| supervisor.binaryPath !== "/usr/local/bin/supercronic" || supervisor.crontabPath !==
|
|
761
|
-
|| JSON.stringify(supervisor.args) !== JSON.stringify(["-split-logs", "-inotify",
|
|
762
|
-
|| supervisor.namespace !==
|
|
764
|
+
|| supervisor.binaryPath !== "/usr/local/bin/supercronic" || supervisor.crontabPath !== butler.crontabPath
|
|
765
|
+
|| JSON.stringify(supervisor.args) !== JSON.stringify(["-split-logs", "-inotify", butler.crontabPath])
|
|
766
|
+
|| supervisor.namespace !== butler.habitNamespace || manifestJob.id !== butler.healthJobId || manifestJob.agent !== (0, sanctuary_acceptance_marker_1.acceptanceButler)()
|
|
763
767
|
|| JSON.stringify(Object.keys(manifestJob).sort()) !== JSON.stringify(manifestKeys)
|
|
764
768
|
|| manifestJob.taskId !== "sanctuary-health" || manifestJob.schedule !== "*/15 * * * *" || sweep.recordDigest !== phases[0]?.sweepReceiptDigest
|
|
765
|
-
|| manifestJob.taskPath !==
|
|
766
|
-
|| manifestJob.command !==
|
|
769
|
+
|| manifestJob.taskPath !== butler.healthTaskPath
|
|
770
|
+
|| manifestJob.command !== butler.healthCommand
|
|
767
771
|
|| JSON.stringify(Object.keys(origin).sort()) !== JSON.stringify(["invocationPid", "invocationStartTime", "occurrenceId", "parentPid", "parentStartTime", "proofMac", "scenarioHandleDigest", "schedulerRunId", "slot"].sort())
|
|
768
772
|
|| origin.parentPid !== supervisor.childPid || typeof origin.slot !== "string" || scheduler.occurrenceId !== `cron:${origin.slot}` || origin.occurrenceId !== scheduler.occurrenceId
|
|
769
773
|
|| origin.scenarioHandleDigest !== scenarioHandleDigest
|
|
@@ -807,10 +811,9 @@ function millisecondsAfterLocalNine(timestamp) {
|
|
|
807
811
|
}
|
|
808
812
|
function canonicalSanctuaryHealthCronRegistered(raw) {
|
|
809
813
|
const lines = raw.split(/\r?\n/u);
|
|
810
|
-
const
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
return index >= 0 && lines[index + 1] === command;
|
|
814
|
+
const { healthCronMarker, healthCommand } = (0, butler_agent_1.butlerContainerPaths)((0, sanctuary_acceptance_marker_1.acceptanceButler)());
|
|
815
|
+
const index = lines.indexOf(healthCronMarker);
|
|
816
|
+
return index >= 0 && lines[index + 1] === `*/15 * * * * ${healthCommand}`;
|
|
814
817
|
}
|
|
815
818
|
function readBoundedIdentitySurfaces(agentRoot) {
|
|
816
819
|
const roots = [
|
|
@@ -936,7 +939,7 @@ function parseTelegramTurnReceipts(raw, scenarioHandleDigest, identityKey) {
|
|
|
936
939
|
});
|
|
937
940
|
}
|
|
938
941
|
async function readIndependentSanctuaryGrounding(toolName) {
|
|
939
|
-
const sanctuary = (0, sanctuary_runtime_1.createSanctuaryToolContext)(
|
|
942
|
+
const sanctuary = (0, sanctuary_runtime_1.createSanctuaryToolContext)((0, sanctuary_acceptance_marker_1.acceptanceButler)()).sanctuary;
|
|
940
943
|
const result = toolName === "unraid_get_system" ? await sanctuary.getSystem() : await sanctuary.getStorage();
|
|
941
944
|
const facts = (0, sanctuary_grounding_1.projectSanctuaryGrounding)(toolName, result);
|
|
942
945
|
const sourceIdentityDigest = result.data?.sourceIdentityDigest;
|
|
@@ -954,7 +957,7 @@ function containmentToolContext(agentRoot, profileId) {
|
|
|
954
957
|
if (!profile)
|
|
955
958
|
throw new Error("Sanctuary containment profile is missing");
|
|
956
959
|
return {
|
|
957
|
-
signin: async () => undefined, agentName:
|
|
960
|
+
signin: async () => undefined, agentName: (0, sanctuary_acceptance_marker_1.acceptanceButler)(), agentRoot,
|
|
958
961
|
relationshipAuthorization: {
|
|
959
962
|
profileId, authorizedContextScopes: profile.contextScopes, advertisedToolNames: profile.toolNames,
|
|
960
963
|
// This request-bound subject audits the profile contract; it is not a persisted Friend or grant.
|
|
@@ -985,7 +988,7 @@ async function runSanctuaryProductionBoundaryProbe(input) {
|
|
|
985
988
|
controlOutputs.push(output); }, resetTurnState: () => undefined, ping: async () => undefined, classifyError: () => "unknown",
|
|
986
989
|
};
|
|
987
990
|
const receipts = [];
|
|
988
|
-
const sanctuary = (0, sanctuary_runtime_1.createSanctuaryToolContext)(
|
|
991
|
+
const sanctuary = (0, sanctuary_runtime_1.createSanctuaryToolContext)((0, sanctuary_acceptance_marker_1.acceptanceButler)()).sanctuary;
|
|
989
992
|
const context = containmentToolContext(input.agentRoot, input.profileId);
|
|
990
993
|
const relationship = context.relationshipAuthorization;
|
|
991
994
|
const poisonedContext = { ...context, sanctuary, relationshipAuthorization: {
|
|
@@ -1180,7 +1183,7 @@ async function captureReadOnlyDenialBoundary(agentRoot, deps) {
|
|
|
1180
1183
|
|| typeof targetSnapshot.running !== "boolean" || typeof targetSnapshot.status !== "string"
|
|
1181
1184
|
|| !Number.isSafeInteger(targetSnapshot.restartCount) || Number(targetSnapshot.restartCount) < 0)
|
|
1182
1185
|
throw new Error("denial target snapshot is invalid");
|
|
1183
|
-
const auditPath =
|
|
1186
|
+
const auditPath = telegramAuditPath();
|
|
1184
1187
|
const providerPath = pathFor(agentRoot, "state/acceptance/telegram-turns.ndjson");
|
|
1185
1188
|
const toolPath = pathFor(agentRoot, "state/acceptance/restart-attempts.ndjson");
|
|
1186
1189
|
const approvalDatabase = pathFor(agentRoot, "state/approvals/approvals.sqlite");
|
|
@@ -1189,14 +1192,14 @@ async function captureReadOnlyDenialBoundary(agentRoot, deps) {
|
|
|
1189
1192
|
targetSnapshotDigest: (0, node_crypto_1.createHash)("sha256").update(JSON.stringify(targetSnapshot)).digest("hex"),
|
|
1190
1193
|
targetRestartCount: Number(targetSnapshot.restartCount),
|
|
1191
1194
|
targetContainerIdDigest: String(targetSnapshot.containerIdDigest),
|
|
1192
|
-
auditCursorDigest: digestOptionalFiles([auditPath,
|
|
1195
|
+
auditCursorDigest: digestOptionalFiles([auditPath, telegramAuditHeadPath()]),
|
|
1193
1196
|
providerUsageCursorDigest: digestOptionalFiles([providerPath]),
|
|
1194
1197
|
sessionCursorDigest: (0, node_crypto_1.createHash)("sha256").update(JSON.stringify(readBoundedIdentitySurfaces(agentRoot))).digest("hex"),
|
|
1195
1198
|
toolActionCursorDigest: digestOptionalFiles([toolPath, approvalDatabase, `${approvalDatabase}-wal`, `${approvalDatabase}-shm`]),
|
|
1196
1199
|
};
|
|
1197
1200
|
}
|
|
1198
1201
|
async function executeSanctuaryReadOnlyDenialProbe(label, scenarioHandleDigest, agentRoot, deps) {
|
|
1199
|
-
const runtime = (0, runtime_credentials_1.readMachineRuntimeCredentialConfig)(
|
|
1202
|
+
const runtime = (0, runtime_credentials_1.readMachineRuntimeCredentialConfig)((0, sanctuary_acceptance_marker_1.acceptanceButler)());
|
|
1200
1203
|
if (!runtime.ok)
|
|
1201
1204
|
throw new Error("read-only denial probe requires an unlocked machine runtime credential");
|
|
1202
1205
|
const endpoint = exactLoopbackGraphqlEndpoint(runtime.config.unraidGraphqlUrl);
|
|
@@ -1236,18 +1239,18 @@ async function executeSanctuaryReadOnlyDenialProbe(label, scenarioHandleDigest,
|
|
|
1236
1239
|
httpStatus: response.status, errorCode, before, after,
|
|
1237
1240
|
};
|
|
1238
1241
|
}
|
|
1239
|
-
async function readDefaultSanctuaryScenarioFacts(label, scenarioHandleDigest, deps, configuredAgentRoot = (0, identity_1.getAgentRoot)(
|
|
1242
|
+
async function readDefaultSanctuaryScenarioFacts(label, scenarioHandleDigest, deps, configuredAgentRoot = (0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)()), options = {}) {
|
|
1240
1243
|
if (options.skipContainerSnapshot === true && options.containerSnapshot !== undefined)
|
|
1241
1244
|
throw new Error("container snapshot options are mutually exclusive");
|
|
1242
1245
|
const agentRoot = configuredAgentRoot;
|
|
1243
1246
|
const identityRaw = optionalFixedFile(deps, pathFor(agentRoot, "state/senses/telegram/identity.key"));
|
|
1244
|
-
const auditRaw = optionalFixedFile(deps,
|
|
1245
|
-
const auditHeadRaw = optionalFixedFile(deps,
|
|
1247
|
+
const auditRaw = optionalFixedFile(deps, telegramAuditPath());
|
|
1248
|
+
const auditHeadRaw = optionalFixedFile(deps, telegramAuditHeadPath());
|
|
1246
1249
|
const gatewayCursor = await readGatewayCursor(deps);
|
|
1247
1250
|
const checkpointsRaw = optionalFixedFile(deps, pathFor(agentRoot, "state/approvals/checkpoints.json"));
|
|
1248
1251
|
const restartAttemptsRaw = optionalFixedFile(deps, pathFor(agentRoot, "state/acceptance/restart-attempts.ndjson")) ?? "";
|
|
1249
1252
|
const telegramTurnsRaw = optionalFixedFile(deps, pathFor(agentRoot, "state/acceptance/telegram-turns.ndjson")) ?? "";
|
|
1250
|
-
const cronRaw = optionalFixedFile(deps,
|
|
1253
|
+
const cronRaw = optionalFixedFile(deps, (0, butler_agent_1.butlerContainerPaths)((0, sanctuary_acceptance_marker_1.acceptanceButler)()).crontabPath);
|
|
1251
1254
|
const healthRaw = optionalFixedFile(deps, pathFor(agentRoot, "state/health/sanctuary-health.json"));
|
|
1252
1255
|
const healthProbeRaw = optionalFixedFile(deps, pathFor(agentRoot, `state/acceptance/health-probe-receipts/${scenarioHandleDigest}.json`));
|
|
1253
1256
|
const interactiveDriverRaw = optionalFixedFile(deps, pathFor(agentRoot, `state/acceptance/interactive-driver-receipts/${scenarioHandleDigest}.json`));
|
|
@@ -1467,7 +1470,7 @@ async function readDefaultSanctuaryScenarioFacts(label, scenarioHandleDigest, de
|
|
|
1467
1470
|
};
|
|
1468
1471
|
}
|
|
1469
1472
|
const health = parseHealthAcceptanceState(healthRaw);
|
|
1470
|
-
const activeMarker = (0, sanctuary_acceptance_marker_1.readSanctuaryAcceptanceMarker)(
|
|
1473
|
+
const activeMarker = (0, sanctuary_acceptance_marker_1.readSanctuaryAcceptanceMarker)((0, sanctuary_acceptance_marker_1.acceptanceButler)(), agentRoot);
|
|
1471
1474
|
const postbootIntegrity = buildPostbootIntegritySnapshot({ telegramNextUpdateId, checkpointsRaw, restartAttempts: parseRestartAttempts(restartAttemptsRaw, null), cronRaw, health, auditLedgerEntries, activeScenarioHandleDigest: activeMarker?.scenarioHandleDigest ?? null });
|
|
1472
1475
|
const prebootIntegrity = rebootCheckpoint && typeof rebootCheckpoint.prebootIntegrity === "object" && !Array.isArray(rebootCheckpoint.prebootIntegrity)
|
|
1473
1476
|
? rebootCheckpoint.prebootIntegrity : undefined;
|
|
@@ -1488,7 +1491,7 @@ async function readDefaultSanctuaryScenarioFacts(label, scenarioHandleDigest, de
|
|
|
1488
1491
|
if (minimaxReadiness && outwardConfig.provider === "minimax" && innerConfig.provider === "minimax") {
|
|
1489
1492
|
const readCredential = deps.readProviderCredential ?? provider_credentials_1.readProviderCredentialRecord;
|
|
1490
1493
|
const checkProvider = deps.providerPing ?? provider_ping_1.pingProvider;
|
|
1491
|
-
const minimaxRecord = await readCredential(
|
|
1494
|
+
const minimaxRecord = await readCredential((0, sanctuary_acceptance_marker_1.acceptanceButler)(), "minimax", { refreshIfMissing: false });
|
|
1492
1495
|
const outwardModel = text(outwardConfig.model, "outward model");
|
|
1493
1496
|
const innerModel = text(innerConfig.model, "inner model");
|
|
1494
1497
|
const minimaxConfig = minimaxRecord.ok ? { ...minimaxRecord.record.credentials, ...minimaxRecord.record.config } : null;
|
|
@@ -1550,7 +1553,7 @@ async function readDefaultSanctuaryScenarioFacts(label, scenarioHandleDigest, de
|
|
|
1550
1553
|
const boundaryFor = async (profileId) => {
|
|
1551
1554
|
const profile = relationshipRegistry.profiles[profileId];
|
|
1552
1555
|
const inner = profileId === "sanctuary-event";
|
|
1553
|
-
const runtime = await dependency(deps.providerRuntime, "current provider runtime")(inner ? "agent" : "human", { agentName:
|
|
1556
|
+
const runtime = await dependency(deps.providerRuntime, "current provider runtime")(inner ? "agent" : "human", { agentName: (0, sanctuary_acceptance_marker_1.acceptanceButler)(), agentRoot });
|
|
1554
1557
|
const context = containmentToolContext(agentRoot, profileId);
|
|
1555
1558
|
const select = (toolContext) => (0, tools_1.selectToolsForChannel)((0, friends_1.getChannelCapabilities)(inner ? "inner" : "telegram"), undefined, undefined, runtime.capabilities, undefined, undefined, toolContext);
|
|
1556
1559
|
const selection = select(context);
|
|
@@ -1615,7 +1618,7 @@ async function readDefaultSanctuaryScenarioFacts(label, scenarioHandleDigest, de
|
|
|
1615
1618
|
writeScopeDigest: (0, node_crypto_1.createHash)("sha256").update(JSON.stringify(writeRecord ? flattenedPermissions(writeRecord) : [])).digest("hex"),
|
|
1616
1619
|
keyRoleAssignmentCount: inventory.reduce((count, record) => count + record.roles.length, 0),
|
|
1617
1620
|
profileBoundaries,
|
|
1618
|
-
auditPathDigest: (0, node_crypto_1.createHash)("sha256").update(
|
|
1621
|
+
auditPathDigest: (0, node_crypto_1.createHash)("sha256").update(telegramAuditPath()).digest("hex"),
|
|
1619
1622
|
auditLedgerDigest: (0, node_crypto_1.createHash)("sha256").update(JSON.stringify(auditLedgerEntries)).digest("hex"),
|
|
1620
1623
|
auditRecordCount: auditLedgerEntries.length,
|
|
1621
1624
|
auditLifecyclePairCount: lifecyclePairs,
|
|
@@ -1710,10 +1713,10 @@ async function readDefaultSanctuaryScenarioFacts(label, scenarioHandleDigest, de
|
|
|
1710
1713
|
};
|
|
1711
1714
|
}
|
|
1712
1715
|
async function postbootIntegritySnapshot(deps) {
|
|
1713
|
-
const agentRoot = (0, identity_1.getAgentRoot)(
|
|
1716
|
+
const agentRoot = (0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)());
|
|
1714
1717
|
const identityRaw = optionalFixedFile(deps, pathFor(agentRoot, "state/senses/telegram/identity.key"));
|
|
1715
|
-
const auditRaw = optionalFixedFile(deps,
|
|
1716
|
-
const auditHeadRaw = optionalFixedFile(deps,
|
|
1718
|
+
const auditRaw = optionalFixedFile(deps, telegramAuditPath());
|
|
1719
|
+
const auditHeadRaw = optionalFixedFile(deps, telegramAuditHeadPath());
|
|
1717
1720
|
if ((auditRaw === null) !== (auditHeadRaw === null))
|
|
1718
1721
|
throw new Error("Telegram audit ledger/head presence mismatch");
|
|
1719
1722
|
if (auditRaw !== null && (!identityRaw || !/^[A-Za-z0-9_-]{43}\n?$/u.test(identityRaw)))
|
|
@@ -1726,9 +1729,9 @@ async function postbootIntegritySnapshot(deps) {
|
|
|
1726
1729
|
const restartAttemptsRaw = optionalFixedFile(deps, pathFor(agentRoot, "state/acceptance/restart-attempts.ndjson")) ?? "";
|
|
1727
1730
|
return buildPostbootIntegritySnapshot({
|
|
1728
1731
|
telegramNextUpdateId: (await readGatewayCursor(deps)).nextUpdateId, checkpointsRaw: optionalFixedFile(deps, pathFor(agentRoot, "state/approvals/checkpoints.json")),
|
|
1729
|
-
restartAttempts: parseRestartAttempts(restartAttemptsRaw, null), cronRaw: optionalFixedFile(deps,
|
|
1732
|
+
restartAttempts: parseRestartAttempts(restartAttemptsRaw, null), cronRaw: optionalFixedFile(deps, (0, butler_agent_1.butlerContainerPaths)((0, sanctuary_acceptance_marker_1.acceptanceButler)()).crontabPath),
|
|
1730
1733
|
health: parseHealthAcceptanceState(optionalFixedFile(deps, pathFor(agentRoot, "state/health/sanctuary-health.json"))), auditLedgerEntries,
|
|
1731
|
-
activeScenarioHandleDigest: (0, sanctuary_acceptance_marker_1.readSanctuaryAcceptanceMarker)(
|
|
1734
|
+
activeScenarioHandleDigest: (0, sanctuary_acceptance_marker_1.readSanctuaryAcceptanceMarker)((0, sanctuary_acceptance_marker_1.acceptanceButler)())?.scenarioHandleDigest ?? null,
|
|
1732
1735
|
});
|
|
1733
1736
|
}
|
|
1734
1737
|
function pathFor(root, suffix) { return `${root}/${suffix}`; }
|
|
@@ -1898,7 +1901,7 @@ async function cursorSnapshot(payload, deps) {
|
|
|
1898
1901
|
if (payload.schema !== "telegram-cursor-v1" || typeof payload.allowGenesis !== "boolean")
|
|
1899
1902
|
throw new Error("Telegram cursor snapshot request is invalid");
|
|
1900
1903
|
const cursor = await readGatewayCursor(deps);
|
|
1901
|
-
const identityKey = fixedFile(deps,
|
|
1904
|
+
const identityKey = fixedFile(deps, telegramIdentityKeyPath()).trim();
|
|
1902
1905
|
if (!/^[A-Za-z0-9_-]{43}$/u.test(identityKey) || Buffer.from(identityKey, "base64url").length !== 32) {
|
|
1903
1906
|
throw new Error("Telegram identity key is invalid");
|
|
1904
1907
|
}
|
|
@@ -1906,9 +1909,9 @@ async function cursorSnapshot(payload, deps) {
|
|
|
1906
1909
|
let verificationFailure;
|
|
1907
1910
|
let observedAuditState = false;
|
|
1908
1911
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
1909
|
-
const headBefore = optionalFixedFile(deps,
|
|
1910
|
-
const auditRaw = optionalFixedFile(deps,
|
|
1911
|
-
const headAfter = optionalFixedFile(deps,
|
|
1912
|
+
const headBefore = optionalFixedFile(deps, telegramAuditHeadPath());
|
|
1913
|
+
const auditRaw = optionalFixedFile(deps, telegramAuditPath());
|
|
1914
|
+
const headAfter = optionalFixedFile(deps, telegramAuditHeadPath());
|
|
1912
1915
|
if (headBefore === null && auditRaw === null && headAfter === null) {
|
|
1913
1916
|
if (payload.allowGenesis !== true)
|
|
1914
1917
|
throw new Error("Telegram audit genesis is not authorized for this snapshot");
|
|
@@ -2083,7 +2086,7 @@ async function interactiveRuntimeReady(payload) {
|
|
|
2083
2086
|
if (payload.label !== "unit-16m-restart-continuation" || typeof payload.scenarioHandleDigest !== "string" || !SHA256.test(payload.scenarioHandleDigest)) {
|
|
2084
2087
|
throw new Error("interactive readiness coordinates are invalid");
|
|
2085
2088
|
}
|
|
2086
|
-
const agentRoot = (0, identity_1.getAgentRoot)(
|
|
2089
|
+
const agentRoot = (0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)());
|
|
2087
2090
|
const socketPath = path.join(agentRoot, "state", "acceptance", "telegram-control.sock");
|
|
2088
2091
|
try {
|
|
2089
2092
|
const response = object(await defaultHostRequest(payload, socketPath, 2_000), "interactive readiness response");
|
|
@@ -2144,7 +2147,7 @@ async function createKey(payload, deps) {
|
|
|
2144
2147
|
if (created.name !== name || JSON.stringify(flattenedPermissions(created)) !== JSON.stringify(permissions)
|
|
2145
2148
|
|| created.roles.length !== 0)
|
|
2146
2149
|
throw new Error("created Unraid key scope mismatch");
|
|
2147
|
-
const stored = await dependency(deps.mergeMachine, "machine vault writer")(
|
|
2150
|
+
const stored = await dependency(deps.mergeMachine, "machine vault writer")((0, sanctuary_acceptance_marker_1.acceptanceButler)(), MACHINE_ID, {
|
|
2148
2151
|
[field]: key,
|
|
2149
2152
|
sanctuaryAcceptanceKeyHandles: { [id]: key },
|
|
2150
2153
|
});
|
|
@@ -2161,7 +2164,7 @@ async function storeKey(payload, deps) {
|
|
|
2161
2164
|
const handle = text(payload.key, "Unraid key handle");
|
|
2162
2165
|
if (handle !== `unraid-key:${id}:${field}`)
|
|
2163
2166
|
throw new Error("Unraid key handle is invalid");
|
|
2164
|
-
const stored = await runtimeConfig(deps.refreshMachine, "Sanctuary machine runtime config",
|
|
2167
|
+
const stored = await runtimeConfig(deps.refreshMachine, "Sanctuary machine runtime config", (0, sanctuary_acceptance_marker_1.acceptanceButler)(), MACHINE_ID);
|
|
2165
2168
|
const handles = object(stored.sanctuaryAcceptanceKeyHandles, "vault-backed acceptance key handles");
|
|
2166
2169
|
if (text(handles[id], "vault-backed Unraid credential") !== text(stored[field], "vault-backed Unraid credential")) {
|
|
2167
2170
|
throw new Error("Unraid key handle does not bind to the active vault field");
|
|
@@ -2178,7 +2181,7 @@ async function probeKey(payload, deps) {
|
|
|
2178
2181
|
requireTargetServer(payload);
|
|
2179
2182
|
const id = keyId(payload.id);
|
|
2180
2183
|
const handle = text(payload.key, "Unraid key handle");
|
|
2181
|
-
const config = await runtimeConfig(deps.refreshMachine, "Sanctuary machine runtime config",
|
|
2184
|
+
const config = await runtimeConfig(deps.refreshMachine, "Sanctuary machine runtime config", (0, sanctuary_acceptance_marker_1.acceptanceButler)(), MACHINE_ID);
|
|
2182
2185
|
const handleMatch = /^unraid-key:([A-Za-z0-9._:-]+):(unraidReadApiKey|unraidWriteApiKey)$/u.exec(handle);
|
|
2183
2186
|
if (!handleMatch || handleMatch[1] !== id)
|
|
2184
2187
|
throw new Error("Unraid key handle is invalid");
|
|
@@ -2209,7 +2212,7 @@ async function readOldKey(payload, deps) {
|
|
|
2209
2212
|
const record = { ...normalizeKey(raw), key: text(raw.key, "old Unraid key credential") };
|
|
2210
2213
|
if (record.id !== id)
|
|
2211
2214
|
throw new Error("old Unraid key ID does not match the host record");
|
|
2212
|
-
const stored = await dependency(deps.mergeMachine, "machine vault writer")(
|
|
2215
|
+
const stored = await dependency(deps.mergeMachine, "machine vault writer")((0, sanctuary_acceptance_marker_1.acceptanceButler)(), MACHINE_ID, { sanctuaryAcceptanceKeyHandles: { [id]: record.key } });
|
|
2213
2216
|
if (!stored.ok)
|
|
2214
2217
|
throw new Error("old Unraid key recovery storage failed");
|
|
2215
2218
|
return { key: `unraid-key:${id}:legacy` };
|
|
@@ -2236,7 +2239,7 @@ async function probeRevokedKey(payload, deps) {
|
|
|
2236
2239
|
if (response.valid !== false || response.id !== id || (response.status !== 401 && response.status !== 403)) {
|
|
2237
2240
|
throw new Error("revoked Unraid key still authenticates");
|
|
2238
2241
|
}
|
|
2239
|
-
const cleared = await dependency(deps.mergeMachine, "machine vault writer")(
|
|
2242
|
+
const cleared = await dependency(deps.mergeMachine, "machine vault writer")((0, sanctuary_acceptance_marker_1.acceptanceButler)(), MACHINE_ID, { sanctuaryAcceptanceKeyHandles: { [id]: "" } });
|
|
2240
2243
|
if (!cleared.ok)
|
|
2241
2244
|
throw new Error("revoked Unraid key recovery cleanup failed");
|
|
2242
2245
|
return { valid: false, status: response.status, id };
|
|
@@ -2510,7 +2513,7 @@ async function executeSanctuaryAcceptanceVaultProbe(keyIdValue, capabilityValue,
|
|
|
2510
2513
|
const capability = text(capabilityValue, "capability");
|
|
2511
2514
|
if (capability !== "read-only" && capability !== "bounded-write")
|
|
2512
2515
|
throw new Error("capability is invalid");
|
|
2513
|
-
const refreshed = await deps.refresh(
|
|
2516
|
+
const refreshed = await deps.refresh((0, sanctuary_acceptance_marker_1.acceptanceButler)(), MACHINE_ID);
|
|
2514
2517
|
if (!refreshed.ok)
|
|
2515
2518
|
throw new Error("Sanctuary machine runtime credentials are unavailable");
|
|
2516
2519
|
const endpoint = exactLoopbackGraphqlEndpoint(refreshed.config.unraidGraphqlUrl);
|
|
@@ -2582,7 +2585,7 @@ function createAcceptanceProbeEffects(input) {
|
|
|
2582
2585
|
? { allowed: true, receiptId: `configured-owner:${input.subject}`, expiresAt: new Date(Date.now() + 5 * 60_000).toISOString(), transport: { chatId: input.chatId } }
|
|
2583
2586
|
: { allowed: false, reason: "effect target is not the configured owner relationship" },
|
|
2584
2587
|
});
|
|
2585
|
-
const sessionPath = (0, shared_turn_1.getSenseSessionPath)(
|
|
2588
|
+
const sessionPath = (0, shared_turn_1.getSenseSessionPath)((0, sanctuary_acceptance_marker_1.acceptanceButler)(), target.friendId, "telegram", target.sessionKey, input.agentRoot);
|
|
2586
2589
|
const port = (0, telegram_effect_adapter_1.createTelegramApprovalEffectPort)({
|
|
2587
2590
|
target,
|
|
2588
2591
|
chatId: input.chatId,
|
|
@@ -2594,7 +2597,7 @@ function createAcceptanceProbeEffects(input) {
|
|
|
2594
2597
|
exports.proveAttemptedRecoveryWithoutRetry = sanctuary_interactive_control_1.proveSanctuaryAttemptedRecoveryWithoutRetry;
|
|
2595
2598
|
async function executeSanctuaryInteractiveRuntimeOperation(rawPayload, supplied) {
|
|
2596
2599
|
exactKeys(rawPayload, ["operation", "label", "scenarioHandleDigest"], "interactive runtime payload");
|
|
2597
|
-
const agentRoot = supplied?.agentRoot ?? (0, identity_1.getAgentRoot)(
|
|
2600
|
+
const agentRoot = supplied?.agentRoot ?? (0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)());
|
|
2598
2601
|
if (!supplied)
|
|
2599
2602
|
return defaultHostRequest(rawPayload, path.join(agentRoot, "state", "acceptance", "telegram-control.sock"), ADAPTER_TIMEOUT_MS);
|
|
2600
2603
|
const deps = {
|
|
@@ -2614,15 +2617,15 @@ async function executeSanctuaryAcceptanceCallbackProbe(rawUpdate, replay, deps =
|
|
|
2614
2617
|
createRuntime: telegram_approval_runtime_1.createTelegramApprovalRuntime,
|
|
2615
2618
|
toolContext: sanctuary_runtime_1.createSanctuaryToolContext,
|
|
2616
2619
|
effects: createAcceptanceProbeEffects,
|
|
2617
|
-
recordCallbackPlayback: (coordinateDigest) => recordCallbackPlayback((0, identity_1.getAgentRoot)(
|
|
2620
|
+
recordCallbackPlayback: (coordinateDigest) => recordCallbackPlayback((0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)()), coordinateDigest),
|
|
2618
2621
|
}) {
|
|
2619
2622
|
const update = callbackUpdate(rawUpdate);
|
|
2620
2623
|
const gateway = deps.gateway();
|
|
2621
2624
|
const credentials = gateway.credentials;
|
|
2622
|
-
const identityKey = deps.identityKey((0, identity_1.getAgentRoot)(
|
|
2625
|
+
const identityKey = deps.identityKey((0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)()));
|
|
2623
2626
|
const subject = (0, telegram_1.opaqueTelegramSubject)(identityKey, credentials.botId, credentials.authorizedUserId, credentials.authorizedChatId);
|
|
2624
2627
|
const api = gateway.authorityTransport.api;
|
|
2625
|
-
const effectBoundary = deps.effects?.({ agentRoot: (0, identity_1.getAgentRoot)(
|
|
2628
|
+
const effectBoundary = deps.effects?.({ agentRoot: (0, identity_1.getAgentRoot)((0, sanctuary_acceptance_marker_1.acceptanceButler)()), api, subject, chatId: credentials.authorizedChatId });
|
|
2626
2629
|
const unavailableEffects = {
|
|
2627
2630
|
sendText: async () => { throw new Error("Telegram acceptance probe effect boundary is unavailable"); },
|
|
2628
2631
|
sendCard: async () => { throw new Error("Telegram acceptance probe effect boundary is unavailable"); },
|
|
@@ -2630,13 +2633,13 @@ async function executeSanctuaryAcceptanceCallbackProbe(rawUpdate, replay, deps =
|
|
|
2630
2633
|
acknowledge: async () => { throw new Error("Telegram acceptance probe effect boundary is unavailable"); },
|
|
2631
2634
|
};
|
|
2632
2635
|
const runtime = deps.createRuntime({
|
|
2633
|
-
agentName:
|
|
2636
|
+
agentName: (0, sanctuary_acceptance_marker_1.acceptanceButler)(),
|
|
2634
2637
|
api,
|
|
2635
2638
|
authorizedUserId: credentials.authorizedUserId,
|
|
2636
2639
|
authorizedChatId: credentials.authorizedChatId,
|
|
2637
2640
|
subject,
|
|
2638
2641
|
identityKey,
|
|
2639
|
-
toolContext: deps.toolContext(
|
|
2642
|
+
toolContext: deps.toolContext((0, sanctuary_acceptance_marker_1.acceptanceButler)()),
|
|
2640
2643
|
effects: effectBoundary?.port ?? unavailableEffects,
|
|
2641
2644
|
});
|
|
2642
2645
|
try {
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.boundDirectoryEntryPath = boundDirectoryEntryPath;
|
|
37
37
|
exports.secureRenameBoundInodeSync = secureRenameBoundInodeSync;
|
|
38
|
+
exports.acceptanceButler = acceptanceButler;
|
|
38
39
|
exports.readSanctuaryAcceptanceMarker = readSanctuaryAcceptanceMarker;
|
|
39
40
|
exports.writeSanctuaryAcceptanceMarker = writeSanctuaryAcceptanceMarker;
|
|
40
41
|
exports.clearSanctuaryAcceptanceMarker = clearSanctuaryAcceptanceMarker;
|
|
@@ -93,6 +94,14 @@ function parseMarker(value) {
|
|
|
93
94
|
}
|
|
94
95
|
return marker;
|
|
95
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The Butler this container runs: the one bundle on disk, which the image mounts under its own name (`butler` from M2 on,
|
|
99
|
+
* `sanctuary` before it and after a rollback to such an image). The acceptance tools run as their own processes, where no
|
|
100
|
+
* daemon start has said which name is running; with neither bundle (or both) there it keeps `sanctuary`.
|
|
101
|
+
*/
|
|
102
|
+
function acceptanceButler(bundlesRoot = (0, identity_1.getAgentBundlesRoot)(), exists = fs.existsSync) {
|
|
103
|
+
return (0, butler_agent_1.butlerOnDisk)(bundlesRoot, exists) ?? "sanctuary";
|
|
104
|
+
}
|
|
96
105
|
function readSanctuaryAcceptanceMarker(agentName, configuredAgentRoot) {
|
|
97
106
|
if (!(0, butler_agent_1.isButlerAgent)(agentName))
|
|
98
107
|
return null;
|