@ouro.bot/cli 0.1.0-alpha.150 → 0.1.0-alpha.1501
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +194 -30
- package/RepairGuide.ouro/agent.json +5 -0
- package/RepairGuide.ouro/psyche/IDENTITY.md +19 -0
- package/RepairGuide.ouro/psyche/SOUL.md +55 -0
- package/RepairGuide.ouro/skills/diagnose-broken-remote.md +63 -0
- package/RepairGuide.ouro/skills/diagnose-stacked-typed-issues.md +35 -0
- package/RepairGuide.ouro/skills/diagnose-sync-blocked.md +54 -0
- package/RepairGuide.ouro/skills/diagnose-vault-expired.md +60 -0
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +4 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +2 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
- package/assets/bluebubbles-host +264 -0
- package/assets/sanctuary-host-launcher.sh +16 -0
- package/changelog.json +8790 -41
- package/deploy/unraid/Dockerfile +85 -0
- package/deploy/unraid/INSTALL.md +64 -0
- package/deploy/unraid/README.txt +3034 -0
- package/deploy/unraid/audit-container-spec.sh +4 -0
- package/deploy/unraid/container-runtime.json +1 -0
- package/deploy/unraid/credit-gateway.md +95 -0
- package/deploy/unraid/docker-man-template-transaction.mjs +733 -0
- package/deploy/unraid/docker-man-template-xml.cjs +105 -0
- package/deploy/unraid/github_known_hosts +3 -0
- package/deploy/unraid/install.sh +274 -0
- package/deploy/unraid/migrate-sanctuary-bundle.mjs +63 -0
- package/deploy/unraid/ouro-events/bootstrap-spool.sh +92 -0
- package/deploy/unraid/ouro-events/emit-event.mjs +310 -0
- package/deploy/unraid/ouro-events/emit-usenet-event.sh +54 -0
- package/deploy/unraid/ouro-events/install-usenet-guard.sh +435 -0
- package/deploy/unraid/ouro-events/usenet-health.sh +176 -0
- package/deploy/unraid/ouro-host-lock.mjs +207 -0
- package/deploy/unraid/ouro-sync-ssh +98 -0
- package/deploy/unraid/ouro-sync.sudoers +3 -0
- package/deploy/unraid/sanctuary-acceptance-adapter.sh +43 -0
- package/deploy/unraid/sanctuary-acceptance-contract.json +198 -0
- package/deploy/unraid/sanctuary-acceptance-harness.sh +23 -0
- package/deploy/unraid/sanctuary-authority-installation.json +36 -0
- package/deploy/unraid/sanctuary-authority-service.sh +30 -0
- package/deploy/unraid/sanctuary-butler-upgrade.mjs +1604 -0
- package/deploy/unraid/sanctuary-deployment-target.mjs +710 -0
- package/deploy/unraid/sanctuary-replay-gate.mjs +2781 -0
- package/deploy/unraid/sanctuary-safe-rename.py +24 -0
- package/deploy/unraid/sanctuary-sync-cutover.sh +1039 -0
- package/deploy/unraid/sanctuary-unit16-host-broker.mjs +2088 -0
- package/deploy/unraid/sanctuary-unit16-run.sh +570 -0
- package/deploy/unraid/sanctuary-unit18-target-audit.sh +27 -0
- package/deploy/unraid/sanctuary.ouro/agent.json +73 -0
- package/deploy/unraid/sanctuary.ouro/arc/README.md +3 -0
- package/deploy/unraid/sanctuary.ouro/awaiting/house-care-sweep.md +17 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +5 -0
- package/deploy/unraid/sanctuary.ouro/habits/sanctuary-health.md +8 -0
- package/deploy/unraid/sanctuary.ouro/mcp/media-mcp.mjs +2533 -0
- package/deploy/unraid/sanctuary.ouro/product/PRODUCT.md +13 -0
- package/deploy/unraid/sanctuary.ouro/provider-readiness.json +11 -0
- package/deploy/unraid/sanctuary.ouro/psyche/ASPIRATIONS.md +5 -0
- package/deploy/unraid/sanctuary.ouro/psyche/IDENTITY.md +7 -0
- package/deploy/unraid/sanctuary.ouro/psyche/LORE.md +7 -0
- package/deploy/unraid/sanctuary.ouro/psyche/SOUL.md +15 -0
- package/deploy/unraid/sanctuary.ouro/psyche/TACIT.md +3 -0
- package/deploy/unraid/sanctuary.ouro/state/policy/steward.json +7 -0
- package/deploy/unraid/sanctuary.ouro/tool-profiles.json +274 -0
- package/deploy/unraid/sanctuary.xml +30 -0
- package/desk.lock.json +8 -0
- package/dist/a2a/approval-relay-forward.js +117 -0
- package/dist/a2a/approval-relay.js +95 -0
- package/dist/a2a/approval-request-wire.js +123 -0
- package/dist/a2a/card.js +57 -0
- package/dist/a2a/client.js +331 -0
- package/dist/a2a/config.js +50 -0
- package/dist/a2a/delegated-command-grants.js +93 -0
- package/dist/a2a/delegated-command.js +200 -0
- package/dist/a2a/delegation-stores.js +56 -0
- package/dist/a2a/did-resolution.js +205 -0
- package/dist/a2a/escalation-grants.js +84 -0
- package/dist/a2a/escalation-wiring.js +60 -0
- package/dist/a2a/identity.js +258 -0
- package/dist/a2a/inbound-share.js +131 -0
- package/dist/a2a/mission-result-wire.js +265 -0
- package/dist/a2a/onboarding.js +133 -0
- package/dist/a2a/operator-trust.js +399 -0
- package/dist/a2a/outbox-client.js +59 -0
- package/dist/a2a/outbox-store.js +245 -0
- package/dist/a2a/outbox-wire.js +106 -0
- package/dist/a2a/pin-store.js +167 -0
- package/dist/a2a/refusals.js +55 -0
- package/dist/a2a/relay-client.js +106 -0
- package/dist/a2a/relay-config-vault.js +64 -0
- package/dist/a2a/relay-contacts.js +120 -0
- package/dist/a2a/relay-inbox.js +360 -0
- package/dist/a2a/relay-retirements.js +89 -0
- package/dist/a2a/replay-grant-holders.js +33 -0
- package/dist/a2a/replay-harness.js +188 -0
- package/dist/a2a/resolution-proof.js +53 -0
- package/dist/a2a/sealed-chat.js +142 -0
- package/dist/a2a/seen-ledger.js +216 -0
- package/dist/a2a/server.js +1088 -0
- package/dist/a2a/task-store.js +69 -0
- package/dist/a2a/transport.js +100 -0
- package/dist/a2a/trust-commands.js +203 -0
- package/dist/a2a/trusted-files.js +185 -0
- package/dist/a2a/types.js +3 -0
- package/dist/actions/generated/mailbox/actions.json +41 -0
- package/dist/actions/generated/mailbox/commands.json +15 -0
- package/dist/actions/generated/mailbox/mcp.json +46 -0
- package/dist/actions/generated/mailbox-tools/tools.json +35 -0
- package/dist/arc/attention-types.js +8 -0
- package/dist/arc/cares.js +360 -0
- package/dist/arc/episodes.js +118 -0
- package/dist/arc/evolution.js +490 -0
- package/dist/arc/flight-recorder.js +1030 -0
- package/dist/arc/intentions.js +134 -0
- package/dist/arc/json-store.js +117 -0
- package/dist/arc/obligations.js +386 -0
- package/dist/arc/packets.js +336 -0
- package/dist/arc/presence.js +185 -0
- package/dist/arc/task-lifecycle.js +57 -0
- package/dist/commerce/store.js +755 -0
- package/dist/commerce/types.js +3 -0
- package/dist/eval/assertions/index.js +378 -0
- package/dist/eval/budget.js +135 -0
- package/dist/eval/domain/case.js +115 -0
- package/dist/eval/domain/stats.js +19 -0
- package/dist/eval/guest-entry.js +18 -0
- package/dist/eval/h-guest-entry.js +19 -0
- package/dist/eval/interview-entry.js +169 -0
- package/dist/eval/interview-grade-entry.js +36 -0
- package/dist/eval/interview-guest-entry.js +19 -0
- package/dist/eval/interviews/allocation.js +90 -0
- package/dist/eval/interviews/final.js +133 -0
- package/dist/eval/interviews/grader.js +196 -0
- package/dist/eval/interviews/guest/arms.js +173 -0
- package/dist/eval/interviews/guest/ax/ax-command.js +792 -0
- package/dist/eval/interviews/guest/ax/effects.js +51 -0
- package/dist/eval/interviews/guest/ax/exit-codes.js +51 -0
- package/dist/eval/interviews/guest/ax/help.js +181 -0
- package/dist/eval/interviews/guest/ax/mcp.js +246 -0
- package/dist/eval/interviews/guest/ax/outcome.js +211 -0
- package/dist/eval/interviews/guest/ax/output.js +53 -0
- package/dist/eval/interviews/guest/ax/precise-copy.js +200 -0
- package/dist/eval/interviews/guest/ax/problem.js +95 -0
- package/dist/eval/interviews/guest/ax/voice.js +83 -0
- package/dist/eval/interviews/guest/ax/wait.js +158 -0
- package/dist/eval/interviews/guest/books-core.js +54 -0
- package/dist/eval/interviews/guest/cli-shell.js +267 -0
- package/dist/eval/interviews/guest/h/run.js +60 -0
- package/dist/eval/interviews/guest/loop.js +87 -0
- package/dist/eval/interviews/guest/operations.js +108 -0
- package/dist/eval/interviews/guest/run.js +81 -0
- package/dist/eval/interviews/guest/u/arms.js +266 -0
- package/dist/eval/interviews/latch.js +134 -0
- package/dist/eval/interviews/protocol.js +77 -0
- package/dist/eval/interviews/rewrite.js +49 -0
- package/dist/eval/interviews/runner.js +340 -0
- package/dist/eval/interviews/u/kit.js +83 -0
- package/dist/eval/readback/hedges.js +39 -0
- package/dist/eval/remote-entry.js +32 -0
- package/dist/eval/report.js +85 -0
- package/dist/eval/run-command.js +161 -0
- package/dist/eval/run-entry.js +89 -0
- package/dist/eval/sandbox/agent-profile.js +74 -0
- package/dist/eval/sandbox/declared-gaps.js +17 -0
- package/dist/eval/sandbox/docker.js +353 -0
- package/dist/eval/sandbox/guest.js +55 -0
- package/dist/eval/sandbox/host-lock.js +62 -0
- package/dist/eval/sandbox/images.js +39 -0
- package/dist/eval/sandbox/oracle.js +32 -0
- package/dist/eval/sandbox/projection.js +127 -0
- package/dist/eval/sandbox/readback.js +137 -0
- package/dist/eval/sandbox/remote.js +102 -0
- package/dist/eval/sandbox/slugger-projection.js +289 -0
- package/dist/eval/self-test.js +84 -0
- package/dist/eval/targets/index.js +127 -0
- package/dist/eval/transport/provider-proxy.js +262 -0
- package/dist/eval/transport/synthetic-sanctuary.js +111 -0
- package/dist/eval/transport/telegram-turn.js +241 -0
- package/dist/eval/watch/cli.js +55 -0
- package/dist/eval/watch/guarded-fs.js +254 -0
- package/dist/eval/watch/log-reader.js +99 -0
- package/dist/eval/watch/rows.js +143 -0
- package/dist/eval/watch/run-watch.js +160 -0
- package/dist/eval/watch-entry.js +26 -0
- package/dist/gateway/keys.js +117 -0
- package/dist/gateway/server.js +429 -0
- package/dist/heart/active-work.js +421 -45
- package/dist/heart/agent-entry.js +255 -4
- package/dist/heart/approval-files.js +94 -0
- package/dist/heart/approval-store.js +1000 -0
- package/dist/heart/atomic-file.js +115 -0
- package/dist/heart/attachments/downloaded-store.js +89 -0
- package/dist/heart/attachments/image-normalize.js +201 -0
- package/dist/heart/attachments/materialize.js +97 -0
- package/dist/heart/attachments/originals.js +102 -0
- package/dist/heart/attachments/render.js +29 -0
- package/dist/heart/attachments/sources/bluebubbles.js +155 -0
- package/dist/heart/attachments/sources/cli-local-file.js +78 -0
- package/dist/heart/attachments/sources/downloaded.js +76 -0
- package/dist/heart/attachments/sources/index.js +19 -0
- package/dist/heart/attachments/store.js +132 -0
- package/dist/heart/attachments/transcribe-audio.js +231 -0
- package/dist/heart/attachments/types.js +93 -0
- package/dist/heart/attachments/understand.js +195 -0
- package/dist/heart/auth/auth-flow.js +590 -0
- package/dist/heart/auth/github-device-login.js +104 -0
- package/dist/heart/autonomy-budget.js +478 -0
- package/dist/heart/awaiting/a2a-await-delivery.js +109 -0
- package/dist/heart/awaiting/await-alert.js +152 -0
- package/dist/heart/awaiting/await-expiry.js +143 -0
- package/dist/heart/awaiting/await-loader.js +91 -0
- package/dist/heart/awaiting/await-parser.js +152 -0
- package/dist/heart/awaiting/await-runtime-state.js +130 -0
- package/dist/heart/awaiting/await-scheduler.js +462 -0
- package/dist/heart/background-operations.js +281 -0
- package/dist/heart/bluebubbles-host-account.js +78 -0
- package/dist/heart/bridges/manager.js +137 -17
- package/dist/heart/bridges/store.js +14 -2
- package/dist/heart/bundle-state.js +168 -0
- package/dist/heart/chat-interaction.js +69 -0
- package/dist/heart/commitments.js +44 -14
- package/dist/heart/config-registry.js +340 -0
- package/dist/heart/config.js +191 -140
- package/dist/heart/context-loss-gauntlet.js +387 -0
- package/dist/heart/context-loss-sentinel.js +1200 -0
- package/dist/heart/core.js +2781 -697
- package/dist/heart/cross-chat-delivery.js +29 -22
- package/dist/heart/daemon/agent-config-check.js +494 -0
- package/dist/heart/daemon/agent-discovery.js +304 -3
- package/dist/heart/daemon/agent-home.js +409 -0
- package/dist/heart/daemon/agent-service.js +210 -28
- package/dist/heart/daemon/agentic-repair.js +548 -0
- package/dist/heart/daemon/await-private-wake.js +59 -0
- package/dist/heart/daemon/bluebubbles-cli-integration.js +71 -0
- package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
- package/dist/heart/daemon/bluebubbles-host-protocol.js +433 -0
- package/dist/heart/daemon/bluebubbles-host.js +273 -0
- package/dist/heart/daemon/boot-sync-probe.js +223 -0
- package/dist/heart/daemon/cadence.js +110 -0
- package/dist/heart/daemon/cli-arg-redaction.js +26 -0
- package/dist/heart/daemon/cli-commands/a2a.js +26 -0
- package/dist/heart/daemon/cli-commands/cards.js +68 -0
- package/dist/heart/daemon/cli-commands/coding-tools.js +13 -0
- package/dist/heart/daemon/cli-commands/desk.js +43 -0
- package/dist/heart/daemon/cli-commands/dns.js +13 -0
- package/dist/heart/daemon/cli-commands/entry-points.js +176 -0
- package/dist/heart/daemon/cli-commands/failure-code.js +11 -0
- package/dist/heart/daemon/cli-commands/friends.js +18 -0
- package/dist/heart/daemon/cli-commands/habits.js +15 -0
- package/dist/heart/daemon/cli-commands/lifecycle.js +42 -0
- package/dist/heart/daemon/cli-commands/mail.js +11 -0
- package/dist/heart/daemon/cli-commands/mind.js +25 -0
- package/dist/heart/daemon/cli-commands/presence.js +28 -0
- package/dist/heart/daemon/cli-commands/providers.js +20 -0
- package/dist/heart/daemon/cli-commands/rsvp.js +20 -0
- package/dist/heart/daemon/cli-commands/shepherd.js +17 -0
- package/dist/heart/daemon/cli-commands/vault.js +23 -0
- package/dist/heart/daemon/cli-defaults.js +997 -0
- package/dist/heart/daemon/cli-desk.js +346 -0
- package/dist/heart/daemon/cli-exec.js +9672 -0
- package/dist/heart/daemon/cli-gate.js +198 -0
- package/dist/heart/daemon/cli-help.js +800 -0
- package/dist/heart/daemon/cli-manifest.js +115 -0
- package/dist/heart/daemon/cli-parse.js +3623 -0
- package/dist/heart/daemon/cli-render-doctor.js +57 -0
- package/dist/heart/daemon/cli-render.js +816 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/compile-cache.js +69 -0
- package/dist/heart/daemon/connect-bay.js +323 -0
- package/dist/heart/daemon/container-credential-bootstrap.js +273 -0
- package/dist/heart/daemon/container-healthcheck.js +123 -0
- package/dist/heart/daemon/container-runtime.js +97 -0
- package/dist/heart/daemon/container-spec-auditor-main.js +187 -0
- package/dist/heart/daemon/container-spec-auditor.js +261 -0
- package/dist/heart/daemon/daemon-bootstrap-startup.js +115 -0
- package/dist/heart/daemon/daemon-cli.js +29 -3145
- package/dist/heart/daemon/daemon-entry.js +1082 -55
- package/dist/heart/daemon/daemon-health.js +186 -0
- package/dist/heart/daemon/daemon-rollup.js +57 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +147 -13
- package/dist/heart/daemon/daemon-tombstone.js +134 -4
- package/dist/heart/daemon/daemon.js +1975 -131
- package/dist/heart/daemon/desk-admin.js +420 -0
- package/dist/heart/daemon/dns-workflow.js +394 -0
- package/dist/heart/daemon/doctor-types.js +8 -0
- package/dist/heart/daemon/doctor.js +1890 -0
- package/dist/heart/daemon/freshness.js +345 -0
- package/dist/heart/daemon/habit-private-wake.js +61 -0
- package/dist/heart/daemon/health-monitor.js +209 -12
- package/dist/heart/daemon/home-filesystem.js +93 -0
- package/dist/heart/daemon/hook-post-tool-use.js +149 -0
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +135 -1
- package/dist/heart/daemon/http-health-probe.js +80 -0
- package/dist/heart/daemon/human-command-screens.js +234 -0
- package/dist/heart/daemon/human-readiness.js +114 -0
- package/dist/heart/daemon/inner-status.js +7 -18
- package/dist/heart/daemon/interactive-repair.js +394 -0
- package/dist/heart/daemon/launchd.js +40 -8
- package/dist/heart/daemon/linux-service.js +382 -0
- package/dist/heart/daemon/log-tailer.js +79 -10
- package/dist/heart/daemon/logs-prune.js +132 -0
- package/dist/heart/daemon/mcp-canary.js +525 -0
- package/dist/heart/daemon/message-router.js +65 -5
- package/dist/heart/daemon/migrate-to-desk.js +848 -0
- package/dist/heart/daemon/os-cron-deps.js +5 -0
- package/dist/heart/daemon/os-cron.js +45 -15
- package/dist/heart/daemon/ouro-bot-entry.js +8 -3
- package/dist/heart/daemon/ouro-cli-main.js +50 -0
- package/dist/heart/daemon/ouro-entry.js +43 -20
- package/dist/heart/daemon/plugin-cli.js +432 -0
- package/dist/heart/daemon/portable-git-install.js +265 -0
- package/dist/heart/daemon/portable-git.js +179 -0
- package/dist/heart/daemon/presence-daemon.js +265 -0
- package/dist/heart/daemon/presence-roster.js +259 -0
- package/dist/heart/daemon/presence.js +462 -0
- package/dist/heart/daemon/process-manager.js +790 -71
- package/dist/heart/daemon/process-tree.js +109 -0
- package/dist/heart/daemon/provider-discovery.js +171 -0
- package/dist/heart/daemon/provider-ping-progress.js +83 -0
- package/dist/heart/daemon/prunable-bundle.js +144 -0
- package/dist/heart/daemon/pulse.js +511 -0
- package/dist/heart/daemon/readiness-repair.js +365 -0
- package/dist/heart/daemon/run-hooks.js +2 -0
- package/dist/heart/daemon/runtime-logging.js +54 -14
- package/dist/heart/daemon/runtime-metadata.js +2 -30
- package/dist/heart/daemon/runtime-mode.js +13 -2
- package/dist/heart/daemon/runtime-replacement-handoff.js +207 -0
- package/dist/heart/daemon/safe-mode.js +161 -0
- package/dist/heart/daemon/sanctuary-acceptance-adapter.js +2659 -0
- package/dist/heart/daemon/sanctuary-acceptance-harness.js +1832 -0
- package/dist/heart/daemon/sanctuary-acceptance-marker.js +267 -0
- package/dist/heart/daemon/sanctuary-acceptance-scenarios.js +956 -0
- package/dist/heart/daemon/sanctuary-authority-codec.js +86 -0
- package/dist/heart/daemon/sanctuary-authority-epoch.js +291 -0
- package/dist/heart/daemon/sanctuary-authority-installation.js +161 -0
- package/dist/heart/daemon/sanctuary-authority-ledger.js +241 -0
- package/dist/heart/daemon/sanctuary-authority-root-lifecycle.js +1370 -0
- package/dist/heart/daemon/sanctuary-authority-vault-migration.js +79 -0
- package/dist/heart/daemon/sanctuary-bundle-migration.js +974 -0
- package/dist/heart/daemon/sanctuary-host-authority.js +1008 -0
- package/dist/heart/daemon/sanctuary-host-detached-supervisor.js +493 -0
- package/dist/heart/daemon/sanctuary-host-executor.js +670 -0
- package/dist/heart/daemon/sanctuary-host-linux-kernel.js +334 -0
- package/dist/heart/daemon/sanctuary-host-supervisor-entry.js +210 -0
- package/dist/heart/daemon/sanctuary-host-supervisor.js +95 -0
- package/dist/heart/daemon/sanctuary-package-management.js +113 -0
- package/dist/heart/daemon/sanctuary-scheduler-liveness.js +227 -0
- package/dist/heart/daemon/sanctuary-scheduler-origin.js +132 -0
- package/dist/heart/daemon/sanctuary-telegram-authority-entry.js +481 -0
- package/dist/heart/daemon/sanctuary-telegram-authority-gateway.js +614 -0
- package/dist/heart/daemon/sanctuary-telegram-authority-service.js +763 -0
- package/dist/heart/daemon/sanctuary-telegram-test-driver-entry.js +97 -0
- package/dist/heart/daemon/sanctuary-telegram-test-driver.js +294 -0
- package/dist/heart/daemon/sense-manager.js +1071 -60
- package/dist/heart/daemon/skill-management-installer.js +1 -1
- package/dist/heart/daemon/socket-client.js +180 -12
- package/dist/heart/daemon/stale-bundle-prune.js +113 -0
- package/dist/heart/daemon/startup-tui.js +339 -0
- package/dist/heart/daemon/state-retention.js +222 -0
- package/dist/heart/daemon/supercronic-supervisor.js +282 -0
- package/dist/heart/daemon/task-scheduler.js +115 -15
- package/dist/heart/daemon/terminal-ui.js +503 -0
- package/dist/heart/daemon/thoughts.js +133 -49
- package/dist/heart/daemon/up-progress.js +366 -0
- package/dist/heart/daemon/vault-items.js +56 -0
- package/dist/heart/daemon/vault-outage.js +74 -0
- package/dist/heart/delegated-work-report.js +115 -0
- package/dist/heart/delegation.js +0 -3
- package/dist/heart/external-events/router.js +1556 -0
- package/dist/heart/failure-reports.js +398 -0
- package/dist/heart/file-lock.js +109 -0
- package/dist/heart/frontend-approval-runtime.js +506 -0
- package/dist/heart/frontend-journal.js +215 -0
- package/dist/heart/frontend-session-service.js +330 -0
- package/dist/heart/frontend-socket-client.js +173 -0
- package/dist/heart/frontend-socket.js +434 -0
- package/dist/heart/frontend-turn-errors.js +20 -0
- package/dist/heart/habits/habit-cancel.js +810 -0
- package/dist/heart/habits/habit-lifecycle.js +1324 -0
- package/dist/heart/{daemon → habits}/habit-migration.js +41 -28
- package/dist/heart/habits/habit-parser.js +278 -0
- package/dist/heart/habits/habit-runtime-state.js +93 -0
- package/dist/heart/habits/habit-scheduler.js +667 -0
- package/dist/heart/habits/habit-session-summary.js +318 -0
- package/dist/heart/habits/habit-session.js +643 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +60 -36
- package/dist/heart/{daemon → hatch}/hatch-specialist.js +6 -8
- package/dist/heart/{daemon → hatch}/specialist-prompt.js +10 -6
- package/dist/heart/hatch/specialist-tools.js +395 -0
- package/dist/heart/identity.js +389 -60
- package/dist/heart/kept-notes.js +289 -0
- package/dist/heart/letters/doors-tools.js +31 -0
- package/dist/heart/letters/doors.js +226 -0
- package/dist/heart/machine-identity.js +175 -0
- package/dist/heart/mail-import-discovery.js +356 -0
- package/dist/heart/mcp/mcp-server.js +893 -0
- package/dist/heart/migrate-config.js +100 -0
- package/dist/heart/model-capabilities.js +98 -16
- package/dist/heart/model-limits.js +49 -0
- package/dist/heart/optional-packages.js +77 -0
- package/dist/heart/orientation-frame.js +393 -0
- package/dist/heart/platform.js +81 -0
- package/dist/heart/primitives.js +1 -1
- package/dist/heart/private-runtime/decision-renderer.js +158 -0
- package/dist/heart/private-runtime/index.js +18 -0
- package/dist/heart/private-runtime/ledger.js +212 -0
- package/dist/heart/private-runtime/policy.js +303 -0
- package/dist/heart/private-runtime/types.js +2 -0
- package/dist/heart/progress-story.js +1 -1
- package/dist/heart/provider-attempt.js +137 -0
- package/dist/heart/provider-binding-resolver.js +273 -0
- package/dist/heart/provider-credentials.js +449 -0
- package/dist/heart/provider-failover.js +260 -37
- package/dist/heart/provider-fallback.js +228 -0
- package/dist/heart/provider-models.js +96 -0
- package/dist/heart/provider-ping-child.js +125 -0
- package/dist/heart/provider-ping-entry.js +8 -0
- package/dist/heart/provider-ping.js +217 -78
- package/dist/heart/provider-readiness-cache.js +119 -0
- package/dist/heart/provider-visibility.js +188 -0
- package/dist/heart/providers/account-pool.js +717 -0
- package/dist/heart/providers/anthropic-token.js +15 -47
- package/dist/heart/providers/anthropic.js +275 -80
- package/dist/heart/providers/azure.js +19 -31
- package/dist/heart/providers/error-classification.js +129 -0
- package/dist/heart/providers/github-copilot.js +131 -36
- package/dist/heart/providers/minimax-vlm.js +189 -0
- package/dist/heart/providers/minimax.js +19 -27
- package/dist/heart/providers/openai-codex-token.js +349 -0
- package/dist/heart/providers/openai-codex.js +46 -57
- package/dist/heart/providers/openai-compatible.js +177 -0
- package/dist/heart/quota/fleet-readings.js +222 -0
- package/dist/heart/quota/tranche.js +59 -0
- package/dist/heart/reach-channel.js +85 -0
- package/dist/heart/reply-style.js +52 -0
- package/dist/heart/run-ledger.js +247 -0
- package/dist/heart/runtime-capability-check.js +170 -0
- package/dist/heart/runtime-credentials.js +647 -0
- package/dist/heart/runtime-cwd.js +87 -0
- package/dist/heart/sense-truth.js +26 -4
- package/dist/heart/sent-message-ledger.js +98 -0
- package/dist/heart/session-activity.js +89 -23
- package/dist/heart/session-events.js +1602 -0
- package/dist/heart/session-playback-cli-main.js +10 -0
- package/dist/heart/session-playback-cli.js +36 -0
- package/dist/heart/session-playback.js +231 -0
- package/dist/heart/session-redaction-repair-cli-main.js +34 -0
- package/dist/heart/session-redaction-repair.js +552 -0
- package/dist/heart/session-stats-cli-main.js +10 -0
- package/dist/heart/session-stats.js +183 -0
- package/dist/heart/session-transcript.js +133 -0
- package/dist/heart/shelf-claims.js +136 -0
- package/dist/heart/shepherd/custody-types.js +2 -0
- package/dist/heart/shepherd/mandates.js +352 -0
- package/dist/heart/shepherd/operation-commands.js +19 -0
- package/dist/heart/shepherd/operations.js +139 -0
- package/dist/heart/shepherd/supervision-read.js +131 -0
- package/dist/heart/shepherd/supervision.js +114 -0
- package/dist/heart/shepherd/types.js +2 -0
- package/dist/heart/shepherd-config.js +113 -0
- package/dist/heart/source-grounding.js +313 -0
- package/dist/heart/sqlite.js +18 -0
- package/dist/heart/start-of-turn-packet.js +372 -0
- package/dist/heart/steward-policy.js +656 -0
- package/dist/heart/streaming.js +625 -192
- package/dist/heart/structured-output.js +196 -0
- package/dist/heart/sync-classification.js +176 -0
- package/dist/heart/sync-health.js +152 -0
- package/dist/heart/sync-lock.js +431 -0
- package/dist/heart/sync.js +1580 -0
- package/dist/heart/target-resolution.js +7 -7
- package/dist/heart/tempo.js +93 -0
- package/dist/heart/temporal-view.js +41 -0
- package/dist/heart/termination-guard.js +27 -0
- package/dist/heart/timeouts.js +101 -0
- package/dist/heart/tool-activity-callbacks.js +59 -0
- package/dist/heart/tool-approval.js +382 -0
- package/dist/heart/tool-description.js +155 -0
- package/dist/heart/tool-friction.js +55 -0
- package/dist/heart/tool-images.js +42 -0
- package/dist/heart/tool-loop.js +9 -3
- package/dist/heart/tool-output-budget.js +41 -0
- package/dist/heart/turn-context.js +503 -0
- package/dist/heart/turn-execution-lease.js +78 -0
- package/dist/heart/turn-summary.js +216 -0
- package/dist/heart/versioning/host-self-update.js +118 -0
- package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +6 -5
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +3 -2
- package/dist/heart/versioning/ouro-path-installer.js +432 -0
- package/dist/heart/versioning/ouro-recovery-launcher.js +98 -0
- package/dist/heart/versioning/ouro-version-manager.js +432 -0
- package/dist/heart/versioning/release-sources.js +185 -0
- package/dist/heart/versioning/self-update-defaults.js +443 -0
- package/dist/heart/versioning/self-update.js +270 -0
- package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
- package/dist/heart/{daemon → versioning}/update-checker.js +12 -35
- package/dist/heart/versioning/update-hooks.js +160 -0
- package/dist/heart/versioning/update-state.js +134 -0
- package/dist/heart/versioning/updater-launchd.js +204 -0
- package/dist/heart/versioning/version-intent.js +114 -0
- package/dist/heart/work-card.js +380 -0
- package/dist/mailroom/attention.js +167 -0
- package/dist/mailroom/autonomy.js +209 -0
- package/dist/mailroom/azure-sdk.js +27 -0
- package/dist/mailroom/blob-store.js +974 -0
- package/dist/mailroom/body-cache.js +61 -0
- package/dist/mailroom/cache-sync-cli.js +58 -0
- package/dist/mailroom/core.js +805 -0
- package/dist/mailroom/entry.js +169 -0
- package/dist/mailroom/file-store.js +568 -0
- package/dist/mailroom/hosted-cache-sync.js +384 -0
- package/dist/mailroom/mbox-import.js +393 -0
- package/dist/mailroom/migration.js +164 -0
- package/dist/mailroom/outbound.js +380 -0
- package/dist/mailroom/policy.js +263 -0
- package/dist/mailroom/reader.js +291 -0
- package/dist/mailroom/search-cache.js +513 -0
- package/dist/mailroom/search-relevance.js +319 -0
- package/dist/mailroom/smtp-ingress.js +176 -0
- package/dist/mailroom/source-state.js +176 -0
- package/dist/mailroom/sweep-orphans-cli.js +34 -0
- package/dist/mailroom/thread.js +109 -0
- package/dist/mailroom/travel-extract.js +89 -0
- package/dist/mind/bundle-manifest.js +25 -4
- package/dist/mind/context.js +335 -198
- package/dist/mind/desk-section.js +332 -0
- package/dist/mind/diary-integrity.js +60 -0
- package/dist/mind/diary.js +31 -53
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/friend-link-codes.js +209 -0
- package/dist/mind/friend-merge.js +336 -0
- package/dist/mind/house-names.js +43 -0
- package/dist/mind/note-search.js +198 -0
- package/dist/mind/obligation-steering.js +15 -9
- package/dist/mind/outbound-record.js +176 -0
- package/dist/mind/pending.js +294 -11
- package/dist/mind/prompt-budget.js +511 -0
- package/dist/mind/prompt-refresh.js +3 -2
- package/dist/mind/prompt.js +948 -364
- package/dist/mind/provenance-trust.js +26 -0
- package/dist/mind/record-paths.js +312 -0
- package/dist/mind/scrutiny.js +121 -0
- package/dist/mind/session-transaction.js +642 -0
- package/dist/mind/token-estimate.js +17 -0
- package/dist/mind/where-am-i.js +147 -0
- package/dist/nerves/cli-logging.js +7 -1
- package/dist/nerves/coverage/audit-rules.js +15 -6
- package/dist/nerves/coverage/audit.js +28 -2
- package/dist/nerves/coverage/cli-main.js +6 -1
- package/dist/nerves/coverage/cli.js +1 -1
- package/dist/nerves/coverage/contract.js +5 -5
- package/dist/nerves/coverage/file-completeness.js +153 -5
- package/dist/nerves/coverage/run-artifacts.js +55 -35
- package/dist/nerves/coverage/source-scanner.js +4 -4
- package/dist/nerves/event-buffer.js +111 -0
- package/dist/nerves/index.js +270 -31
- package/dist/nerves/observation.js +18 -0
- package/dist/nerves/redact.js +79 -0
- package/dist/nerves/review/cli-main.js +10 -0
- package/dist/nerves/review/cli.js +156 -0
- package/dist/nerves/review/core.js +159 -0
- package/dist/nerves/runtime.js +16 -1
- package/dist/repertoire/ado-client.js +15 -56
- package/dist/repertoire/ado-semantic.js +108 -40
- package/dist/repertoire/api-client.js +97 -0
- package/dist/repertoire/auth-required.js +22 -0
- package/dist/repertoire/bitwarden-native.js +458 -0
- package/dist/repertoire/bitwarden-store.js +1296 -0
- package/dist/repertoire/bundle-templates.js +71 -0
- package/dist/repertoire/bw-installer.js +268 -0
- package/dist/repertoire/coding/context-pack.js +80 -3
- package/dist/repertoire/coding/feedback.js +27 -26
- package/dist/repertoire/coding/index.js +63 -6
- package/dist/repertoire/coding/manager.js +31 -14
- package/dist/repertoire/coding/orca-client.js +194 -0
- package/dist/repertoire/coding/orca-manager.js +460 -0
- package/dist/repertoire/coding/router.js +124 -0
- package/dist/repertoire/coding/spawner.js +3 -2
- package/dist/repertoire/coding/tools.js +178 -34
- package/dist/repertoire/coding/workbench-client.js +272 -0
- package/dist/repertoire/coding/workbench-manager.js +404 -0
- package/dist/repertoire/commerce-errors.js +109 -0
- package/dist/repertoire/commerce-self-test.js +156 -0
- package/dist/repertoire/credential-access.js +183 -0
- package/dist/repertoire/desk/classifier.js +362 -0
- package/dist/repertoire/desk-mcp.js +140 -0
- package/dist/repertoire/duffel-client.js +185 -0
- package/dist/repertoire/github-client.js +14 -55
- package/dist/repertoire/graph-client.js +11 -52
- package/dist/repertoire/guardrails.js +1174 -70
- package/dist/repertoire/house-sweep.js +471 -0
- package/dist/repertoire/in-turn-tools-door.js +54 -0
- package/dist/repertoire/mcp-client.js +58 -5
- package/dist/repertoire/mcp-declared-tools.js +156 -0
- package/dist/repertoire/mcp-manager.js +457 -141
- package/dist/repertoire/mcp-tools.js +199 -0
- package/dist/repertoire/mcp-write-guard.js +85 -0
- package/dist/repertoire/plugin-mcp.js +175 -0
- package/dist/repertoire/plugins.js +253 -0
- package/dist/repertoire/relationship-authorization.js +322 -0
- package/dist/repertoire/sanctuary-container-policy.js +50 -0
- package/dist/repertoire/shell-sessions.js +136 -0
- package/dist/repertoire/skill-search.js +177 -0
- package/dist/repertoire/skill-summaries.js +129 -0
- package/dist/repertoire/skills.js +34 -4
- package/dist/repertoire/stripe-client.js +163 -0
- package/dist/repertoire/tool-arguments.js +180 -0
- package/dist/repertoire/tool-candidates.js +50 -0
- package/dist/repertoire/tool-catalog.js +228 -0
- package/dist/repertoire/tool-error-code.js +30 -0
- package/dist/repertoire/tool-limits.js +20 -0
- package/dist/repertoire/tool-results.js +29 -0
- package/dist/repertoire/tools-a2a.js +792 -0
- package/dist/repertoire/tools-app-sessions.js +219 -0
- package/dist/repertoire/tools-attachments.js +302 -0
- package/dist/repertoire/tools-awaiting.js +934 -0
- package/dist/repertoire/tools-base.js +85 -1420
- package/dist/repertoire/tools-bridge.js +153 -0
- package/dist/repertoire/tools-bundle.js +998 -0
- package/dist/repertoire/tools-chat.js +185 -0
- package/dist/repertoire/tools-commerce.js +272 -0
- package/dist/repertoire/tools-config.js +199 -0
- package/dist/repertoire/tools-continuity.js +648 -0
- package/dist/repertoire/tools-credential.js +410 -0
- package/dist/repertoire/tools-escalation.js +98 -0
- package/dist/repertoire/tools-evolution.js +560 -0
- package/dist/repertoire/tools-files.js +521 -0
- package/dist/repertoire/tools-flight.js +313 -0
- package/dist/repertoire/tools-flow.js +169 -0
- package/dist/repertoire/tools-friend-link.js +65 -0
- package/dist/repertoire/tools-github.js +11 -4
- package/dist/repertoire/tools-habits.js +111 -0
- package/dist/repertoire/tools-house-care.js +190 -0
- package/dist/repertoire/tools-mail.js +1928 -0
- package/dist/repertoire/tools-notes.js +567 -0
- package/dist/repertoire/tools-obligations.js +187 -0
- package/dist/repertoire/tools-orientation.js +36 -0
- package/dist/repertoire/tools-record.js +497 -0
- package/dist/repertoire/tools-rsvp.js +148 -0
- package/dist/repertoire/tools-runtime.js +260 -0
- package/dist/repertoire/tools-sanctuary-host.js +213 -0
- package/dist/repertoire/tools-session.js +1190 -0
- package/dist/repertoire/tools-shell.js +275 -0
- package/dist/repertoire/tools-shepherd-guidance.js +183 -0
- package/dist/repertoire/tools-shepherd.js +369 -0
- package/dist/repertoire/tools-steward-policy.js +157 -0
- package/dist/repertoire/tools-stripe.js +244 -0
- package/dist/repertoire/tools-surface.js +553 -0
- package/dist/repertoire/tools-teams.js +67 -17
- package/dist/repertoire/tools-telegram-contacts.js +41 -0
- package/dist/repertoire/tools-travel.js +142 -0
- package/dist/repertoire/tools-trip.js +1041 -0
- package/dist/repertoire/tools-unraid.js +627 -0
- package/dist/repertoire/tools-user-profile.js +166 -0
- package/dist/repertoire/tools-vault.js +46 -0
- package/dist/repertoire/tools-voice-local.js +210 -0
- package/dist/repertoire/tools-voice.js +153 -0
- package/dist/repertoire/tools-web.js +238 -0
- package/dist/repertoire/tools.js +608 -288
- package/dist/repertoire/travel-api-client.js +463 -0
- package/dist/repertoire/unraid-client.js +155 -0
- package/dist/repertoire/unraid-restart.js +342 -0
- package/dist/repertoire/user-profile.js +131 -0
- package/dist/repertoire/vault-setup.js +298 -0
- package/dist/repertoire/vault-unlock.js +816 -0
- package/dist/rsvp/aisleplanner-client.js +354 -0
- package/dist/rsvp/cli.js +936 -0
- package/dist/rsvp/config.js +327 -0
- package/dist/rsvp/cutover.js +453 -0
- package/dist/rsvp/diagnostics.js +232 -0
- package/dist/rsvp/diff-renderer.js +176 -0
- package/dist/rsvp/habit-policy.js +110 -0
- package/dist/rsvp/habit-stage.js +123 -0
- package/dist/rsvp/incident-bundle.js +97 -0
- package/dist/rsvp/migration.js +204 -0
- package/dist/rsvp/native-habit-runner.js +630 -0
- package/dist/rsvp/outbound-state.js +628 -0
- package/dist/rsvp/query.js +118 -0
- package/dist/rsvp/replay.js +233 -0
- package/dist/rsvp/snapshot.js +232 -0
- package/dist/rsvp/spend-ledger.js +175 -0
- package/dist/scripts/claude-code-stop-hook.js +4 -3
- package/dist/senses/a2a-entry.js +145 -0
- package/dist/senses/acp-server.js +386 -0
- package/dist/senses/app-sessions/client.js +128 -0
- package/dist/senses/app-sessions/digest-cards.js +187 -0
- package/dist/senses/app-sessions/digest-push.js +108 -0
- package/dist/senses/app-sessions/digest-sources.js +204 -0
- package/dist/senses/app-sessions/digest.js +284 -0
- package/dist/senses/app-sessions/run-command.js +51 -0
- package/dist/senses/app-sessions/sense.js +242 -0
- package/dist/senses/app-sessions/shepherd-cli.js +166 -0
- package/dist/senses/app-sessions/shepherd-rows.js +67 -0
- package/dist/senses/app-sessions/store.js +149 -0
- package/dist/senses/app-sessions/waiting-prompts.js +137 -0
- package/dist/senses/app-sessions/waiting-status.js +23 -0
- package/dist/senses/app-sessions-entry.js +87 -0
- package/dist/senses/attention-queue.js +95 -6
- package/dist/senses/await-turn-message.js +65 -0
- package/dist/senses/bluebubbles/active-turns.js +241 -0
- package/dist/senses/bluebubbles/attachment-cache.js +53 -0
- package/dist/senses/bluebubbles/attachment-download.js +143 -0
- package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +391 -49
- package/dist/senses/bluebubbles/context-packet.js +207 -0
- package/dist/senses/bluebubbles/context-smoke.js +144 -0
- package/dist/senses/bluebubbles/entry.js +80 -0
- package/dist/senses/bluebubbles/host-account-verifier.js +113 -0
- package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +21 -3
- package/dist/senses/bluebubbles/index.js +4663 -0
- package/dist/senses/bluebubbles/latest-turn.js +342 -0
- package/dist/senses/bluebubbles/media.js +255 -0
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +152 -30
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +24 -13
- package/dist/senses/bluebubbles/outbound-state.js +335 -0
- package/dist/senses/bluebubbles/processed-log.js +133 -0
- package/dist/senses/bluebubbles/reactions.js +18 -0
- package/dist/senses/bluebubbles/replay.js +284 -0
- package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +47 -4
- package/dist/senses/bluebubbles/semantic-receipts.js +2014 -0
- package/dist/senses/bluebubbles/send-file.js +20 -0
- package/dist/senses/bluebubbles/send-health.js +126 -0
- package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
- package/dist/senses/bluebubbles/webhook-registration.js +257 -0
- package/dist/senses/bluebubbles-meta-guard.js +39 -0
- package/dist/senses/chat-file.js +75 -0
- package/dist/senses/cli/bracketed-paste.js +82 -0
- package/dist/senses/cli/image-paste.js +287 -0
- package/dist/senses/cli/image-ref-navigation.js +75 -0
- package/dist/senses/cli/ink-app.js +156 -0
- package/dist/senses/cli/inline-diff.js +64 -0
- package/dist/senses/cli/input-keys.js +209 -0
- package/dist/senses/cli/kill-ring.js +86 -0
- package/dist/senses/cli/message-list.js +51 -0
- package/dist/senses/cli/ouro-tui.js +633 -0
- package/dist/senses/cli/spinner-imperative.js +135 -0
- package/dist/senses/cli/spinner.js +101 -0
- package/dist/senses/cli/status-line.js +60 -0
- package/dist/senses/cli/streaming-markdown.js +526 -0
- package/dist/senses/cli/tool-display.js +85 -0
- package/dist/senses/cli/tool-render.js +85 -0
- package/dist/senses/cli/tui-store.js +252 -0
- package/dist/senses/cli/virtual-list.js +35 -0
- package/dist/senses/cli-entry.js +62 -9
- package/dist/senses/cli.js +627 -350
- package/dist/senses/commands.js +66 -3
- package/dist/senses/context-packet-ledger.js +367 -0
- package/dist/senses/context-packets.js +154 -0
- package/dist/senses/habit-lifecycle-guard.js +24 -0
- package/dist/senses/habit-turn-message.js +160 -0
- package/dist/senses/inbound-journal.js +186 -0
- package/dist/senses/ingress-evidence.js +2 -0
- package/dist/senses/mail-entry.js +69 -0
- package/dist/senses/mail.js +524 -0
- package/dist/senses/ordinary-owner-decision.js +98 -0
- package/dist/senses/pipeline.js +1216 -289
- package/dist/senses/private-runtime-worker.js +857 -0
- package/dist/senses/private-runtime.js +1692 -0
- package/dist/senses/proactive-content-guard.js +51 -0
- package/dist/senses/program-status.js +155 -0
- package/dist/senses/repeat-while.js +36 -0
- package/dist/senses/root-host-approval-port.js +345 -0
- package/dist/senses/root-host-approval-runtime.js +393 -0
- package/dist/senses/sanctuary-authority-resident.js +102 -0
- package/dist/senses/sanctuary-download-credit-presentation.js +31 -0
- package/dist/senses/sanctuary-full-visibility-contract.js +302 -0
- package/dist/senses/sanctuary-grounding.js +118 -0
- package/dist/senses/sanctuary-health-acceptance-probe-entry.js +21 -0
- package/dist/senses/sanctuary-health-acceptance-probe.js +802 -0
- package/dist/senses/sanctuary-health-runner.js +106 -0
- package/dist/senses/sanctuary-health.js +442 -0
- package/dist/senses/sanctuary-house.js +97 -0
- package/dist/senses/sanctuary-install-state-contract.js +169 -0
- package/dist/senses/sanctuary-interactive-control.js +410 -0
- package/dist/senses/sanctuary-media-catalog-contract.js +268 -0
- package/dist/senses/sanctuary-media-optimization.js +517 -0
- package/dist/senses/sanctuary-runtime.js +392 -0
- package/dist/senses/sanctuary-sab.js +85 -0
- package/dist/senses/sanctuary-storage-optimization-contract.js +32 -0
- package/dist/senses/sense-shutdown.js +72 -0
- package/dist/senses/shared-turn.js +741 -97
- package/dist/senses/shepherd/agent-presentation.js +88 -0
- package/dist/senses/shepherd/attention-page.js +166 -0
- package/dist/senses/shepherd/attention-sidebar.js +76 -0
- package/dist/senses/shepherd/attention.js +295 -0
- package/dist/senses/shepherd/checkin-config.js +76 -0
- package/dist/senses/shepherd/checkin-store.js +383 -0
- package/dist/senses/shepherd/client.js +196 -0
- package/dist/senses/shepherd/cmux.js +483 -0
- package/dist/senses/shepherd/composer.js +336 -0
- package/dist/senses/shepherd/conversation-hold.js +78 -0
- package/dist/senses/shepherd/feedback-reply.js +108 -0
- package/dist/senses/shepherd/feedback-source.js +20 -0
- package/dist/senses/shepherd/feedback-store.js +328 -0
- package/dist/senses/shepherd/feedback-submit.js +182 -0
- package/dist/senses/shepherd/feedback-worker.js +208 -0
- package/dist/senses/shepherd/guidance.js +273 -0
- package/dist/senses/shepherd/herdr.js +427 -0
- package/dist/senses/shepherd/host.js +14 -0
- package/dist/senses/shepherd/human-decision-guard.js +29 -0
- package/dist/senses/shepherd/judge-evaluation-command.js +185 -0
- package/dist/senses/shepherd/judge-evaluation-entry.js +20 -0
- package/dist/senses/shepherd/judge-evaluation.js +144 -0
- package/dist/senses/shepherd/judge.js +210 -0
- package/dist/senses/shepherd/notice-outbox.js +254 -0
- package/dist/senses/shepherd/observation-publisher.js +320 -0
- package/dist/senses/shepherd/operations-defaults.js +86 -0
- package/dist/senses/shepherd/operations.js +159 -0
- package/dist/senses/shepherd/owner-notice.js +496 -0
- package/dist/senses/shepherd/prompt-state.js +60 -0
- package/dist/senses/shepherd/recovery.js +543 -0
- package/dist/senses/shepherd/redact.js +66 -0
- package/dist/senses/shepherd/returns.js +79 -0
- package/dist/senses/shepherd/sense.js +862 -0
- package/dist/senses/shepherd/shepherd-judge-corpus-v1.json +170 -0
- package/dist/senses/shepherd/surface.js +125 -0
- package/dist/senses/shepherd/target-binding.js +13 -0
- package/dist/senses/shepherd/terminal-process.js +147 -0
- package/dist/senses/shepherd-entry.js +98 -0
- package/dist/senses/surface-tool.js +60 -34
- package/dist/senses/teams-attachments.js +68 -0
- package/dist/senses/teams-entry.js +80 -9
- package/dist/senses/teams-image.js +128 -0
- package/dist/senses/teams-inbound.js +76 -0
- package/dist/senses/teams-off-turn.js +199 -0
- package/dist/senses/teams-outbox.js +242 -0
- package/dist/senses/teams.js +1249 -378
- package/dist/senses/telegram-admission.js +700 -0
- package/dist/senses/telegram-approval-relay.js +293 -0
- package/dist/senses/telegram-approval-runtime.js +831 -0
- package/dist/senses/telegram-attachments.js +128 -0
- package/dist/senses/telegram-audit-ledger.js +220 -0
- package/dist/senses/telegram-authority-transport.js +233 -0
- package/dist/senses/telegram-chat-actions.js +57 -0
- package/dist/senses/telegram-client.js +1896 -0
- package/dist/senses/telegram-effect-adapter.js +892 -0
- package/dist/senses/telegram-entry.js +87 -0
- package/dist/senses/telegram-handoff.js +150 -0
- package/dist/senses/telegram-identity-key.js +143 -0
- package/dist/senses/telegram-markdown.js +331 -0
- package/dist/senses/telegram-owner-route.js +129 -0
- package/dist/senses/telegram.js +2789 -0
- package/dist/senses/terminal-handoff.js +44 -0
- package/dist/senses/trust-gate.js +104 -9
- package/dist/senses/turn-attempts.js +171 -0
- package/dist/senses/turn-watch.js +268 -0
- package/dist/senses/voice/audio-playback.js +237 -0
- package/dist/senses/voice/audio-routing.js +119 -0
- package/dist/senses/voice/call-auth.js +250 -0
- package/dist/senses/voice/elevenlabs.js +202 -0
- package/dist/senses/voice/floor-control.js +431 -0
- package/dist/senses/voice/floor-controller.js +115 -0
- package/dist/senses/voice/golden-path.js +116 -0
- package/dist/senses/voice/index.js +29 -0
- package/dist/senses/voice/local-audio-control.js +344 -0
- package/dist/senses/voice/local-audio-devices.js +516 -0
- package/dist/senses/voice/local-audio-disclosure.js +174 -0
- package/dist/senses/voice/local-audio-identity.js +103 -0
- package/dist/senses/voice/local-audio-join.js +325 -0
- package/dist/senses/voice/local-audio-mute.js +199 -0
- package/dist/senses/voice/local-audio-notify.js +124 -0
- package/dist/senses/voice/local-audio-prompts.js +116 -0
- package/dist/senses/voice/local-audio-transport.js +427 -0
- package/dist/senses/voice/local-audio.js +281 -0
- package/dist/senses/voice/local-media-stream.js +145 -0
- package/dist/senses/voice/meeting.js +113 -0
- package/dist/senses/voice/outbound.js +190 -0
- package/dist/senses/voice/phone.js +33 -0
- package/dist/senses/voice/playback.js +139 -0
- package/dist/senses/voice/process-guards.js +51 -0
- package/dist/senses/voice/realtime-eval.js +496 -0
- package/dist/senses/voice/realtime-tool-schema.js +195 -0
- package/dist/senses/voice/realtime-trace.js +531 -0
- package/dist/senses/voice/realtime-utterances.js +158 -0
- package/dist/senses/voice/transcript.js +70 -0
- package/dist/senses/voice/turn.js +219 -0
- package/dist/senses/voice/twilio-phone-runtime.js +836 -0
- package/dist/senses/voice/twilio-phone.js +5660 -0
- package/dist/senses/voice/types.js +2 -0
- package/dist/senses/voice/utterances.js +207 -0
- package/dist/senses/voice/whisper.js +153 -0
- package/dist/senses/voice-entry.js +84 -0
- package/dist/senses/voice-realtime-eval-command.js +99 -0
- package/dist/senses/voice-realtime-eval-entry.js +25 -0
- package/dist/senses/voice-twilio-entry.js +88 -0
- package/dist/trips/core.js +138 -0
- package/dist/trips/store.js +265 -0
- package/dist/util/frontmatter.js +69 -0
- package/node_modules/@ouro.bot/friends/LICENSE +201 -0
- package/node_modules/@ouro.bot/friends/README.md +687 -0
- package/node_modules/@ouro.bot/friends/actions/generated/mcp.json +1105 -0
- package/node_modules/@ouro.bot/friends/changelog.json +197 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/a2a-message.d.ts +39 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/a2a-message.js +54 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/adapter.d.ts +117 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/adapter.js +202 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/agent-card.d.ts +50 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/agent-card.js +32 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-key.d.ts +38 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-key.js +120 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-verifier.d.ts +195 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-verifier.js +342 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-web.d.ts +26 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-web.js +140 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.d.ts +62 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.js +83 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/index.d.ts +26 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/index.js +82 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/jcs.d.ts +5 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/jcs.js +84 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/reachability.d.ts +22 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/reachability.js +17 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/roster-verify.d.ts +15 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/roster-verify.js +61 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/seal.d.ts +47 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/seal.js +95 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sealed-envelope.d.ts +58 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sealed-envelope.js +113 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sign.d.ts +42 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sign.js +87 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sodium.d.ts +5 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sodium.js +19 -0
- package/node_modules/@ouro.bot/friends/dist/account-roster.d.ts +52 -0
- package/node_modules/@ouro.bot/friends/dist/account-roster.js +108 -0
- package/node_modules/@ouro.bot/friends/dist/agent-peer.d.ts +26 -0
- package/node_modules/@ouro.bot/friends/dist/agent-peer.js +138 -0
- package/node_modules/@ouro.bot/friends/dist/audit.d.ts +42 -0
- package/node_modules/@ouro.bot/friends/dist/audit.js +86 -0
- package/node_modules/@ouro.bot/friends/dist/channel.d.ts +16 -0
- package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/channel.js +83 -4
- package/node_modules/@ouro.bot/friends/dist/connect-authority.d.ts +43 -0
- package/node_modules/@ouro.bot/friends/dist/connect-authority.js +84 -0
- package/node_modules/@ouro.bot/friends/dist/connect.d.ts +56 -0
- package/node_modules/@ouro.bot/friends/dist/connect.js +163 -0
- package/node_modules/@ouro.bot/friends/dist/consent.d.ts +34 -0
- package/node_modules/@ouro.bot/friends/dist/consent.js +65 -0
- package/node_modules/@ouro.bot/friends/dist/coordination.d.ts +116 -0
- package/node_modules/@ouro.bot/friends/dist/coordination.js +329 -0
- package/node_modules/@ouro.bot/friends/dist/delegation-grant.d.ts +21 -0
- package/node_modules/@ouro.bot/friends/dist/delegation-grant.js +39 -0
- package/node_modules/@ouro.bot/friends/dist/file-bundle.d.ts +17 -0
- package/node_modules/@ouro.bot/friends/dist/file-bundle.js +27 -0
- package/node_modules/@ouro.bot/friends/dist/friend-lookup.d.ts +9 -0
- package/node_modules/@ouro.bot/friends/dist/friend-lookup.js +69 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store-file.d.ts +19 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store-file.js +157 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store.js +8 -0
- package/node_modules/@ouro.bot/friends/dist/grants.d.ts +43 -0
- package/node_modules/@ouro.bot/friends/dist/grants.js +100 -0
- package/node_modules/@ouro.bot/friends/dist/group-context.d.ts +21 -0
- package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/group-context.js +5 -4
- package/node_modules/@ouro.bot/friends/dist/identity.d.ts +17 -0
- package/node_modules/@ouro.bot/friends/dist/identity.js +68 -0
- package/node_modules/@ouro.bot/friends/dist/index.d.ts +73 -0
- package/node_modules/@ouro.bot/friends/dist/index.js +164 -0
- package/node_modules/@ouro.bot/friends/dist/link-identity.d.ts +14 -0
- package/node_modules/@ouro.bot/friends/dist/link-identity.js +157 -0
- package/node_modules/@ouro.bot/friends/dist/mailbox/index.d.ts +105 -0
- package/node_modules/@ouro.bot/friends/dist/mailbox/index.js +205 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/bin.d.ts +2 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/bin.js +17 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/dispatch.d.ts +40 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/dispatch.js +744 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/index.d.ts +6 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/index.js +14 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/run-main.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/run-main.js +59 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/schemas.d.ts +10 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/schemas.js +23 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/server.d.ts +30 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/server.js +195 -0
- package/node_modules/@ouro.bot/friends/dist/message.d.ts +93 -0
- package/node_modules/@ouro.bot/friends/dist/message.js +129 -0
- package/node_modules/@ouro.bot/friends/dist/mission-result.d.ts +89 -0
- package/node_modules/@ouro.bot/friends/dist/mission-result.js +207 -0
- package/node_modules/@ouro.bot/friends/dist/mission-share.d.ts +94 -0
- package/node_modules/@ouro.bot/friends/dist/mission-share.js +232 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store-file.d.ts +18 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store-file.js +169 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store.d.ts +10 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store.js +9 -0
- package/node_modules/@ouro.bot/friends/dist/missions.d.ts +31 -0
- package/node_modules/@ouro.bot/friends/dist/missions.js +99 -0
- package/node_modules/@ouro.bot/friends/dist/notes.d.ts +11 -0
- package/node_modules/@ouro.bot/friends/dist/notes.js +90 -0
- package/node_modules/@ouro.bot/friends/dist/observability.d.ts +27 -0
- package/node_modules/@ouro.bot/friends/dist/observability.js +31 -0
- package/node_modules/@ouro.bot/friends/dist/outcomes.d.ts +9 -0
- package/node_modules/@ouro.bot/friends/dist/outcomes.js +51 -0
- package/node_modules/@ouro.bot/friends/dist/resolver.d.ts +59 -0
- package/node_modules/@ouro.bot/friends/dist/resolver.js +276 -0
- package/node_modules/@ouro.bot/friends/dist/results.d.ts +10 -0
- package/node_modules/@ouro.bot/friends/dist/results.js +2 -0
- package/node_modules/@ouro.bot/friends/dist/room.d.ts +22 -0
- package/node_modules/@ouro.bot/friends/dist/room.js +40 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-file.d.ts +16 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-file.js +125 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-memory.d.ts +9 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-memory.js +20 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store.d.ts +29 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store.js +9 -0
- package/node_modules/@ouro.bot/friends/dist/roster-verifier.d.ts +23 -0
- package/node_modules/@ouro.bot/friends/dist/roster-verifier.js +47 -0
- package/node_modules/@ouro.bot/friends/dist/share.d.ts +113 -0
- package/node_modules/@ouro.bot/friends/dist/share.js +314 -0
- package/node_modules/@ouro.bot/friends/dist/standing.d.ts +83 -0
- package/node_modules/@ouro.bot/friends/dist/standing.js +111 -0
- package/node_modules/@ouro.bot/friends/dist/store-file.d.ts +82 -0
- package/node_modules/@ouro.bot/friends/dist/store-file.js +1089 -0
- package/node_modules/@ouro.bot/friends/dist/store.d.ts +43 -0
- package/node_modules/@ouro.bot/friends/dist/tokens.d.ts +10 -0
- package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/tokens.js +7 -4
- package/node_modules/@ouro.bot/friends/dist/trust-explanation.d.ts +22 -0
- package/node_modules/@ouro.bot/friends/dist/trust-explanation.js +90 -0
- package/node_modules/@ouro.bot/friends/dist/trust-mutation.d.ts +16 -0
- package/node_modules/@ouro.bot/friends/dist/trust-mutation.js +67 -0
- package/node_modules/@ouro.bot/friends/dist/types.d.ts +333 -0
- package/node_modules/@ouro.bot/friends/dist/types.js +55 -0
- package/node_modules/@ouro.bot/friends/dist/util/cap-string.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/util/cap-string.js +35 -0
- package/node_modules/@ouro.bot/friends/dist/util/safe-id.d.ts +1 -0
- package/node_modules/@ouro.bot/friends/dist/util/safe-id.js +10 -0
- package/node_modules/@ouro.bot/friends/dist/verifier.d.ts +11 -0
- package/node_modules/@ouro.bot/friends/dist/verifier.js +29 -0
- package/node_modules/@ouro.bot/friends/dist/whoami.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/whoami.js +39 -0
- package/node_modules/@ouro.bot/friends/package.json +82 -0
- package/node_modules/libsodium/LICENSE +16 -0
- package/node_modules/libsodium/README.md +281 -0
- package/node_modules/libsodium/dist/modules/libsodium.js +1 -0
- package/node_modules/libsodium/dist/modules-esm/libsodium.mjs +1 -0
- package/node_modules/libsodium/package.json +54 -0
- package/node_modules/libsodium-wrappers/LICENSE +16 -0
- package/node_modules/libsodium-wrappers/README.md +281 -0
- package/node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.d.ts +2155 -0
- package/node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.js +1 -0
- package/node_modules/libsodium-wrappers/dist/modules-esm/libsodium-wrappers.d.mts +2743 -0
- package/node_modules/libsodium-wrappers/dist/modules-esm/libsodium-wrappers.mjs +1 -0
- package/node_modules/libsodium-wrappers/package.json +74 -0
- package/npm-shrinkwrap.json +8789 -0
- package/package.json +96 -12
- package/skills/agent-commerce.md +116 -0
- package/skills/browser-navigation.md +120 -0
- package/skills/commerce-setup-guide.md +116 -0
- package/skills/commerce-setup.md +87 -0
- package/skills/configure-dev-tools.md +32 -14
- package/skills/sense-setup.md +56 -0
- package/skills/travel-planning.md +141 -0
- package/vendor/desk/.claude-plugin/plugin.json +35 -0
- package/vendor/desk/.mcp.claude-codex.json +28 -0
- package/vendor/desk/.mcp.copilot.json +16 -0
- package/vendor/desk/.ouro-desk.json +6 -0
- package/vendor/desk/CHANGELOG.md +7004 -0
- package/vendor/desk/README.md +195 -0
- package/vendor/desk/activation/README.md +98 -0
- package/vendor/desk/activation/copilot-root.flattened-bundle.json +38 -0
- package/vendor/desk/activation/desk.activation.json +251 -0
- package/vendor/desk/activation/host-capability-evidence.md +46 -0
- package/vendor/desk/activation/support-matrix.json +84 -0
- package/vendor/desk/agency.json +20 -0
- package/vendor/desk/agents/observer.agent.md +26 -0
- package/vendor/desk/agents/observer.md +29 -0
- package/vendor/desk/agents/worker.agent.md +32 -0
- package/vendor/desk/agents/worker.md +40 -0
- package/vendor/desk/artifacts/tombstones/tombstone.schema.json +53 -0
- package/vendor/desk/artifacts/tombstones/tombstones.jsonl +1 -0
- package/vendor/desk/changelog.d/README.md +12 -0
- package/vendor/desk/docs/agent-files.md +104 -0
- package/vendor/desk/docs/agentic-engineering-v2-rfc.md +206 -0
- package/vendor/desk/docs/agentic-engineering-v3-rfc.md +109 -0
- package/vendor/desk/docs/browser-remote-desktops.md +69 -0
- package/vendor/desk/docs/dependency-activation-stories-and-criteria.md +500 -0
- package/vendor/desk/docs/evaluation-packet.md +363 -0
- package/vendor/desk/docs/factory-local-capture.md +651 -0
- package/vendor/desk/docs/factory-store-playbook.md +927 -0
- package/vendor/desk/docs/images/factory-site.png +0 -0
- package/vendor/desk/docs/issue-drains.md +79 -0
- package/vendor/desk/docs/lfs-inspection.md +55 -0
- package/vendor/desk/docs/preview-diagnostics.md +11 -0
- package/vendor/desk/docs/relays.md +88 -0
- package/vendor/desk/docs/schedules.md +69 -0
- package/vendor/desk/docs/search-recovery.md +22 -0
- package/vendor/desk/docs/session-labels.md +157 -0
- package/vendor/desk/docs/session-retention.md +125 -0
- package/vendor/desk/docs/sessions.md +17 -0
- package/vendor/desk/docs/stalled-nudges.md +54 -0
- package/vendor/desk/docs/webhooks.md +80 -0
- package/vendor/desk/docs/workspace-tidy.md +74 -0
- package/vendor/desk/hooks/boot-checks.cjs +7 -0
- package/vendor/desk/hooks/claude-session-start.cjs +123 -0
- package/vendor/desk/hooks/compatible-node.cjs +97 -0
- package/vendor/desk/hooks/copilot-boot-prompt.cjs +69 -0
- package/vendor/desk/hooks/copilot-durable-files.cjs +8 -0
- package/vendor/desk/hooks/copilot-hooks.json +61 -0
- package/vendor/desk/hooks/copilot-intake-context.cjs +5 -0
- package/vendor/desk/hooks/copilot-lane-model.cjs +8 -0
- package/vendor/desk/hooks/copilot-session-start.cjs +264 -0
- package/vendor/desk/hooks/copilot-skill-current.cjs +28 -0
- package/vendor/desk/hooks/factory-end.cjs +5 -0
- package/vendor/desk/hooks/factory-start.cjs +27 -0
- package/vendor/desk/hooks/hooks.json +40 -0
- package/vendor/desk/hooks/lib/boot-checks.cjs +643 -0
- package/vendor/desk/hooks/lib/child-agent.cjs +14 -0
- package/vendor/desk/hooks/lib/copilot-intake-context.cjs +73 -0
- package/vendor/desk/hooks/lib/current-release.cjs +162 -0
- package/vendor/desk/hooks/lib/delivery-stop.cjs +326 -0
- package/vendor/desk/hooks/lib/detach-worker.cjs +43 -0
- package/vendor/desk/hooks/lib/durable-files.cjs +102 -0
- package/vendor/desk/hooks/lib/factory-end.cjs +327 -0
- package/vendor/desk/hooks/lib/lane-model.cjs +82 -0
- package/vendor/desk/hooks/lib/node-required.cjs +56 -0
- package/vendor/desk/hooks/lib/orca-session-title.cjs +60 -0
- package/vendor/desk/hooks/lib/session-end.cjs +30 -0
- package/vendor/desk/hooks/lib/sync-end.cjs +89 -0
- package/vendor/desk/hooks/loop-start.cjs +105 -0
- package/vendor/desk/hooks/node-missing.sh +78 -0
- package/vendor/desk/hooks/orca-session-title.cjs +8 -0
- package/vendor/desk/hooks/session-end.cjs +8 -0
- package/vendor/desk/mcp/README.md +269 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/support-matrix.json +72 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/README.md +25 -0
- package/vendor/desk/mcp/bootstrap.cjs +761 -0
- package/vendor/desk/mcp/docs/private-feedback.md +13 -0
- package/vendor/desk/mcp/idle-proxy.cjs +423 -0
- package/vendor/desk/mcp/index.js +813 -0
- package/vendor/desk/mcp/package-lock.json +3717 -0
- package/vendor/desk/mcp/package.json +44 -0
- package/vendor/desk/mcp/scripts/agency-desk-channel.js +7 -0
- package/vendor/desk/mcp/scripts/build-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/scripts/crew.js +89 -0
- package/vendor/desk/mcp/scripts/drains-launcher.mjs +329 -0
- package/vendor/desk/mcp/scripts/drains.js +5 -0
- package/vendor/desk/mcp/scripts/factory.js +657 -0
- package/vendor/desk/mcp/scripts/file-desk-problem.js +9 -0
- package/vendor/desk/mcp/scripts/finish-commit.js +7 -0
- package/vendor/desk/mcp/scripts/lfs.js +37 -0
- package/vendor/desk/mcp/scripts/local-recovery.js +363 -0
- package/vendor/desk/mcp/scripts/migrations.js +11 -0
- package/vendor/desk/mcp/scripts/private-view.js +177 -0
- package/vendor/desk/mcp/scripts/resolve-desk-root.js +106 -0
- package/vendor/desk/mcp/scripts/session-boot.js +22 -0
- package/vendor/desk/mcp/scripts/session-retention.js +5 -0
- package/vendor/desk/mcp/scripts/session-sync.js +10 -0
- package/vendor/desk/mcp/scripts/sessions.js +5 -0
- package/vendor/desk/mcp/scripts/sync-push.js +13 -0
- package/vendor/desk/mcp/scripts/tidy-status.js +8 -0
- package/vendor/desk/mcp/scripts/verify-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/src/actions/desk-read.actions.mts +73 -0
- package/vendor/desk/mcp/src/actions/desk-session.actions.mts +42 -0
- package/vendor/desk/mcp/src/actions/desk-web.actions.mts +52 -0
- package/vendor/desk/mcp/src/actions/desk.actions.mts +5 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActions.swift +649 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActionsReins.swift +61 -0
- package/vendor/desk/mcp/src/actions/generated/desk/actions.json +280 -0
- package/vendor/desk/mcp/src/actions/generated/desk/commands.json +145 -0
- package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +256 -0
- package/vendor/desk/mcp/src/actions/generated/desk/web.ts +59 -0
- package/vendor/desk/mcp/src/actions/generated/desk/webmcp.json +250 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActions.swift +241 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActionsReins.swift +25 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/actions.json +73 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/commands.json +53 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/mcp.json +83 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/web.ts +47 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/webmcp.json +81 -0
- package/vendor/desk/mcp/src/actions/served.js +5 -0
- package/vendor/desk/mcp/src/activation/admit.js +77 -0
- package/vendor/desk/mcp/src/activation/failures.js +65 -0
- package/vendor/desk/mcp/src/activation/readiness-policy.js +102 -0
- package/vendor/desk/mcp/src/activation/schema.js +17 -0
- package/vendor/desk/mcp/src/activation/superpowers-context.js +265 -0
- package/vendor/desk/mcp/src/activation/validate.js +540 -0
- package/vendor/desk/mcp/src/artifacts/tombstones.js +61 -0
- package/vendor/desk/mcp/src/crew/initiative.js +287 -0
- package/vendor/desk/mcp/src/crew/workspace.js +1259 -0
- package/vendor/desk/mcp/src/db/init.js +75 -0
- package/vendor/desk/mcp/src/db/schema.sql +83 -0
- package/vendor/desk/mcp/src/desk/active-tasks.js +408 -0
- package/vendor/desk/mcp/src/desk/card-commit-guard.js +281 -0
- package/vendor/desk/mcp/src/desk/cleanup-index.js +53 -0
- package/vendor/desk/mcp/src/desk/content-home.js +246 -0
- package/vendor/desk/mcp/src/desk/crew-config.js +102 -0
- package/vendor/desk/mcp/src/desk/crew-member.js +196 -0
- package/vendor/desk/mcp/src/desk/crew-roster.js +151 -0
- package/vendor/desk/mcp/src/desk/frontmatter-lite.js +228 -0
- package/vendor/desk/mcp/src/desk/gh-logins.js +109 -0
- package/vendor/desk/mcp/src/desk/handles.js +123 -0
- package/vendor/desk/mcp/src/desk/handoff-reference.js +35 -0
- package/vendor/desk/mcp/src/desk/improvement-authority.js +3 -0
- package/vendor/desk/mcp/src/desk/improvement-cards.js +704 -0
- package/vendor/desk/mcp/src/desk/improvement-person.js +51 -0
- package/vendor/desk/mcp/src/desk/lifecycle.js +16 -0
- package/vendor/desk/mcp/src/desk/machine-desks.js +119 -0
- package/vendor/desk/mcp/src/desk/naming.js +333 -0
- package/vendor/desk/mcp/src/desk/organization.js +592 -0
- package/vendor/desk/mcp/src/desk/resources.js +274 -0
- package/vendor/desk/mcp/src/desk/runtime-resolver.js +30 -0
- package/vendor/desk/mcp/src/desk/scratch-paths.js +44 -0
- package/vendor/desk/mcp/src/desk/step-delivery.js +140 -0
- package/vendor/desk/mcp/src/desk/steps.js +263 -0
- package/vendor/desk/mcp/src/desk/tidy.js +930 -0
- package/vendor/desk/mcp/src/desk/unsigned-deliveries.js +359 -0
- package/vendor/desk/mcp/src/factory/agent-types.js +45 -0
- package/vendor/desk/mcp/src/factory/andon-watch.js +109 -0
- package/vendor/desk/mcp/src/factory/binding.js +612 -0
- package/vendor/desk/mcp/src/factory/boot-check.js +645 -0
- package/vendor/desk/mcp/src/factory/capture-classify.js +158 -0
- package/vendor/desk/mcp/src/factory/capture-count.js +183 -0
- package/vendor/desk/mcp/src/factory/capture-flush.js +268 -0
- package/vendor/desk/mcp/src/factory/capture-publish.js +141 -0
- package/vendor/desk/mcp/src/factory/capture-schema.js +193 -0
- package/vendor/desk/mcp/src/factory/capture-sweep.js +239 -0
- package/vendor/desk/mcp/src/factory/catch-point.js +60 -0
- package/vendor/desk/mcp/src/factory/commit-resolve.js +94 -0
- package/vendor/desk/mcp/src/factory/consent-answer.js +37 -0
- package/vendor/desk/mcp/src/factory/context-capability.js +15 -0
- package/vendor/desk/mcp/src/factory/context-outbox.js +885 -0
- package/vendor/desk/mcp/src/factory/context-run.js +386 -0
- package/vendor/desk/mcp/src/factory/context-schema.js +249 -0
- package/vendor/desk/mcp/src/factory/copilot-turn-index.js +93 -0
- package/vendor/desk/mcp/src/factory/copilot-usage.js +148 -0
- package/vendor/desk/mcp/src/factory/credential.js +45 -0
- package/vendor/desk/mcp/src/factory/derive-claude.js +960 -0
- package/vendor/desk/mcp/src/factory/derive-codex.js +734 -0
- package/vendor/desk/mcp/src/factory/derive-common.js +279 -0
- package/vendor/desk/mcp/src/factory/derive-copilot.js +1057 -0
- package/vendor/desk/mcp/src/factory/derive-run.js +807 -0
- package/vendor/desk/mcp/src/factory/desk-problem-file.js +310 -0
- package/vendor/desk/mcp/src/factory/desk-problem-fingerprint.js +70 -0
- package/vendor/desk/mcp/src/factory/desk-problem-known.js +246 -0
- package/vendor/desk/mcp/src/factory/desk-problem-template.js +107 -0
- package/vendor/desk/mcp/src/factory/desk-repo.js +1223 -0
- package/vendor/desk/mcp/src/factory/desk-task-line.js +28 -0
- package/vendor/desk/mcp/src/factory/desk-visibility.js +48 -0
- package/vendor/desk/mcp/src/factory/end-hook.js +14 -0
- package/vendor/desk/mcp/src/factory/evaluate-kick.js +164 -0
- package/vendor/desk/mcp/src/factory/evaluate-run.js +678 -0
- package/vendor/desk/mcp/src/factory/evaluator-step.js +484 -0
- package/vendor/desk/mcp/src/factory/filer-launch.js +79 -0
- package/vendor/desk/mcp/src/factory/flush-health.js +26 -0
- package/vendor/desk/mcp/src/factory/flush.js +1758 -0
- package/vendor/desk/mcp/src/factory/focus.js +326 -0
- package/vendor/desk/mcp/src/factory/headless-flag.cjs +32 -0
- package/vendor/desk/mcp/src/factory/headless-flag.js +25 -0
- package/vendor/desk/mcp/src/factory/headless-ledger.js +743 -0
- package/vendor/desk/mcp/src/factory/headless.js +567 -0
- package/vendor/desk/mcp/src/factory/held-route.js +93 -0
- package/vendor/desk/mcp/src/factory/host-flags.js +36 -0
- package/vendor/desk/mcp/src/factory/improvement-verify.js +429 -0
- package/vendor/desk/mcp/src/factory/kaizen-file.js +231 -0
- package/vendor/desk/mcp/src/factory/label-binding.js +90 -0
- package/vendor/desk/mcp/src/factory/label-schema.js +426 -0
- package/vendor/desk/mcp/src/factory/local-status.js +368 -0
- package/vendor/desk/mcp/src/factory/loop-conditions.js +121 -0
- package/vendor/desk/mcp/src/factory/loop-health.js +500 -0
- package/vendor/desk/mcp/src/factory/loop-slot.js +90 -0
- package/vendor/desk/mcp/src/factory/loop-status.js +100 -0
- package/vendor/desk/mcp/src/factory/loop-switch.cjs +14 -0
- package/vendor/desk/mcp/src/factory/loop-worker-state.js +96 -0
- package/vendor/desk/mcp/src/factory/loop-worker.js +290 -0
- package/vendor/desk/mcp/src/factory/marker.js +61 -0
- package/vendor/desk/mcp/src/factory/mirror-step.js +145 -0
- package/vendor/desk/mcp/src/factory/os-protect.js +243 -0
- package/vendor/desk/mcp/src/factory/outbox.js +2231 -0
- package/vendor/desk/mcp/src/factory/outcome.js +431 -0
- package/vendor/desk/mcp/src/factory/pipeline/andon.js +319 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention-rollup.js +158 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention.js +146 -0
- package/vendor/desk/mcp/src/factory/pipeline/build.js +299 -0
- package/vendor/desk/mcp/src/factory/pipeline/compare.js +148 -0
- package/vendor/desk/mcp/src/factory/pipeline/formulas.js +652 -0
- package/vendor/desk/mcp/src/factory/pipeline/kaizen.js +387 -0
- package/vendor/desk/mcp/src/factory/pipeline/lifecycle-clocks.js +345 -0
- package/vendor/desk/mcp/src/factory/pipeline/normalize.js +73 -0
- package/vendor/desk/mcp/src/factory/pipeline/number-states.js +154 -0
- package/vendor/desk/mcp/src/factory/pipeline/outcomes.js +268 -0
- package/vendor/desk/mcp/src/factory/pipeline/report.js +737 -0
- package/vendor/desk/mcp/src/factory/pipeline/rollups.js +883 -0
- package/vendor/desk/mcp/src/factory/pipeline/stretches.js +523 -0
- package/vendor/desk/mcp/src/factory/pipeline/timeline.js +199 -0
- package/vendor/desk/mcp/src/factory/pipeline/validate-pr.js +238 -0
- package/vendor/desk/mcp/src/factory/pipeline/versions.js +42 -0
- package/vendor/desk/mcp/src/factory/pipeline/walk.js +1177 -0
- package/vendor/desk/mcp/src/factory/plugin-registry.js +72 -0
- package/vendor/desk/mcp/src/factory/plugin-sources.cjs +249 -0
- package/vendor/desk/mcp/src/factory/pr-green.js +77 -0
- package/vendor/desk/mcp/src/factory/process-lock.js +142 -0
- package/vendor/desk/mcp/src/factory/proof-session.js +75 -0
- package/vendor/desk/mcp/src/factory/publish.js +637 -0
- package/vendor/desk/mcp/src/factory/published-schema.js +648 -0
- package/vendor/desk/mcp/src/factory/reconcile-reasons.js +22 -0
- package/vendor/desk/mcp/src/factory/reconcile-step.js +251 -0
- package/vendor/desk/mcp/src/factory/reconcile.js +808 -0
- package/vendor/desk/mcp/src/factory/release-version.js +134 -0
- package/vendor/desk/mcp/src/factory/repo-name.js +13 -0
- package/vendor/desk/mcp/src/factory/retention.js +60 -0
- package/vendor/desk/mcp/src/factory/route-desk.js +40 -0
- package/vendor/desk/mcp/src/factory/route-issues.js +251 -0
- package/vendor/desk/mcp/src/factory/route-local.js +264 -0
- package/vendor/desk/mcp/src/factory/schema.js +957 -0
- package/vendor/desk/mcp/src/factory/session-kind.js +16 -0
- package/vendor/desk/mcp/src/factory/session-lifetime.js +56 -0
- package/vendor/desk/mcp/src/factory/session-route.js +183 -0
- package/vendor/desk/mcp/src/factory/shell-git.js +500 -0
- package/vendor/desk/mcp/src/factory/store-issues.js +143 -0
- package/vendor/desk/mcp/src/factory/store-route.js +208 -0
- package/vendor/desk/mcp/src/factory/test-state-guard.js +103 -0
- package/vendor/desk/mcp/src/factory/time.js +36 -0
- package/vendor/desk/mcp/src/factory/tool-issue-file.js +84 -0
- package/vendor/desk/mcp/src/factory/tool-kinds.js +87 -0
- package/vendor/desk/mcp/src/factory/triage-schema.js +233 -0
- package/vendor/desk/mcp/src/factory/windows-acl.js +679 -0
- package/vendor/desk/mcp/src/indexer/chunk.js +232 -0
- package/vendor/desk/mcp/src/indexer/discover.js +434 -0
- package/vendor/desk/mcp/src/indexer/exclusions.js +247 -0
- package/vendor/desk/mcp/src/indexer/index.js +167 -0
- package/vendor/desk/mcp/src/indexer/refs.js +0 -0
- package/vendor/desk/mcp/src/indexer/text-hash.js +18 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/actions.claims.json +75 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/dist-manifest.json +70 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/ouro-actions.mts +1416 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/LICENSE +21 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +190 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +1020 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/checks.ts +343 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/cli.ts +240 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/component.ts +430 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/dev-commands.ts +204 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/doctor.ts +126 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/effects.ts +68 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/exit-codes.ts +75 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/help.ts +220 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +268 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/outcome.ts +265 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/output.ts +67 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/precise-copy.ts +235 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/problem.ts +124 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.kit.mts +8 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.ts +568 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/terminal.ts +245 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/voice.ts +136 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/wait.ts +226 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/work-event.ts +181 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.kit.mts +18 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +2072 -0
- package/vendor/desk/mcp/src/package-metadata.js +20 -0
- package/vendor/desk/mcp/src/protected/legacy-ledger.js +55 -0
- package/vendor/desk/mcp/src/readiness/leftovers.js +75 -0
- package/vendor/desk/mcp/src/readiness/process-start.js +149 -0
- package/vendor/desk/mcp/src/runtime/admission-worker.js +194 -0
- package/vendor/desk/mcp/src/runtime/admission.js +177 -0
- package/vendor/desk/mcp/src/runtime/agency-desk-channel.js +342 -0
- package/vendor/desk/mcp/src/runtime/agents-md.js +62 -0
- package/vendor/desk/mcp/src/runtime/append-lane.js +68 -0
- package/vendor/desk/mcp/src/runtime/argv-safe-reason.js +55 -0
- package/vendor/desk/mcp/src/runtime/boot-dependencies.js +75 -0
- package/vendor/desk/mcp/src/runtime/boot-text.js +504 -0
- package/vendor/desk/mcp/src/runtime/boot.js +1677 -0
- package/vendor/desk/mcp/src/runtime/bootstrap.js +1455 -0
- package/vendor/desk/mcp/src/runtime/chunked-import.js +102 -0
- package/vendor/desk/mcp/src/runtime/copilot-commit-trailer.js +133 -0
- package/vendor/desk/mcp/src/runtime/copilot-session.js +155 -0
- package/vendor/desk/mcp/src/runtime/deliver.js +469 -0
- package/vendor/desk/mcp/src/runtime/desk-channel.js +86 -0
- package/vendor/desk/mcp/src/runtime/desk-failure.js +26 -0
- package/vendor/desk/mcp/src/runtime/desk-health.js +168 -0
- package/vendor/desk/mcp/src/runtime/desk-session.js +1451 -0
- package/vendor/desk/mcp/src/runtime/diagnostic-server.js +72 -0
- package/vendor/desk/mcp/src/runtime/diagnostics.js +241 -0
- package/vendor/desk/mcp/src/runtime/drains-cli.js +187 -0
- package/vendor/desk/mcp/src/runtime/drains.js +781 -0
- package/vendor/desk/mcp/src/runtime/elsewhere-note.js +9 -0
- package/vendor/desk/mcp/src/runtime/failure-evidence.js +21 -0
- package/vendor/desk/mcp/src/runtime/fast-refs.js +209 -0
- package/vendor/desk/mcp/src/runtime/filer-throttle.js +66 -0
- package/vendor/desk/mcp/src/runtime/focused-card.js +147 -0
- package/vendor/desk/mcp/src/runtime/front-door.js +204 -0
- package/vendor/desk/mcp/src/runtime/gate-wait.js +2 -0
- package/vendor/desk/mcp/src/runtime/git-inspection.js +201 -0
- package/vendor/desk/mcp/src/runtime/git-read-worker.js +157 -0
- package/vendor/desk/mcp/src/runtime/health.js +50 -0
- package/vendor/desk/mcp/src/runtime/hooks.js +353 -0
- package/vendor/desk/mcp/src/runtime/hosted.js +163 -0
- package/vendor/desk/mcp/src/runtime/inbox.js +102 -0
- package/vendor/desk/mcp/src/runtime/index-drift.js +118 -0
- package/vendor/desk/mcp/src/runtime/last-start.js +133 -0
- package/vendor/desk/mcp/src/runtime/lesson-section.js +92 -0
- package/vendor/desk/mcp/src/runtime/lessons-shelf.js +100 -0
- package/vendor/desk/mcp/src/runtime/lfs.js +319 -0
- package/vendor/desk/mcp/src/runtime/native-path.js +12 -0
- package/vendor/desk/mcp/src/runtime/newest-release.js +197 -0
- package/vendor/desk/mcp/src/runtime/node-selection.js +233 -0
- package/vendor/desk/mcp/src/runtime/orca-session-title.js +225 -0
- package/vendor/desk/mcp/src/runtime/other-sessions.js +183 -0
- package/vendor/desk/mcp/src/runtime/pending-migrations.js +653 -0
- package/vendor/desk/mcp/src/runtime/plugin-update.js +215 -0
- package/vendor/desk/mcp/src/runtime/pluginless-runtimes.js +34 -0
- package/vendor/desk/mcp/src/runtime/pr-publication.js +226 -0
- package/vendor/desk/mcp/src/runtime/preview-snapshot.js +23 -0
- package/vendor/desk/mcp/src/runtime/publication-mode.js +19 -0
- package/vendor/desk/mcp/src/runtime/relays.js +974 -0
- package/vendor/desk/mcp/src/runtime/release-alert.js +148 -0
- package/vendor/desk/mcp/src/runtime/remote-identity.js +140 -0
- package/vendor/desk/mcp/src/runtime/resolve-here.js +4 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps-cli.js +65 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps.js +1109 -0
- package/vendor/desk/mcp/src/runtime/runtime-identity.js +22 -0
- package/vendor/desk/mcp/src/runtime/runtime-swap.js +101 -0
- package/vendor/desk/mcp/src/runtime/schedules.js +235 -0
- package/vendor/desk/mcp/src/runtime/session-activity.js +190 -0
- package/vendor/desk/mcp/src/runtime/session-label.js +30 -0
- package/vendor/desk/mcp/src/runtime/session-retention.js +662 -0
- package/vendor/desk/mcp/src/runtime/session-sync.js +333 -0
- package/vendor/desk/mcp/src/runtime/session-trailer.js +126 -0
- package/vendor/desk/mcp/src/runtime/sessions-cli.js +301 -0
- package/vendor/desk/mcp/src/runtime/signoff-listed.js +81 -0
- package/vendor/desk/mcp/src/runtime/skills.js +76 -0
- package/vendor/desk/mcp/src/runtime/stale-card-lead.js +52 -0
- package/vendor/desk/mcp/src/runtime/stale-desk-refresh.js +198 -0
- package/vendor/desk/mcp/src/runtime/stale-desk.js +219 -0
- package/vendor/desk/mcp/src/runtime/stalled.js +255 -0
- package/vendor/desk/mcp/src/runtime/standing-authority.js +79 -0
- package/vendor/desk/mcp/src/runtime/startup-boot.js +341 -0
- package/vendor/desk/mcp/src/runtime/startup-resolve.js +140 -0
- package/vendor/desk/mcp/src/runtime/state-branch.js +203 -0
- package/vendor/desk/mcp/src/runtime/status-compact.js +165 -0
- package/vendor/desk/mcp/src/runtime/status-inspection-child.js +26 -0
- package/vendor/desk/mcp/src/runtime/status-inspection.js +147 -0
- package/vendor/desk/mcp/src/runtime/status-root.js +39 -0
- package/vendor/desk/mcp/src/runtime/sync-worker.js +911 -0
- package/vendor/desk/mcp/src/runtime/test-state-guard.js +107 -0
- package/vendor/desk/mcp/src/runtime/unmerged-saves.js +247 -0
- package/vendor/desk/mcp/src/runtime/workspace-claim.js +53 -0
- package/vendor/desk/mcp/src/runtime/workspace-evidence.js +96 -0
- package/vendor/desk/mcp/src/runtime/workspace-tidy.js +509 -0
- package/vendor/desk/mcp/src/search/direct-lexical.js +54 -0
- package/vendor/desk/mcp/src/search/embedder.js +108 -0
- package/vendor/desk/mcp/src/search/engine.js +406 -0
- package/vendor/desk/mcp/src/search/files-router.js +22 -0
- package/vendor/desk/mcp/src/search/old-index.js +46 -0
- package/vendor/desk/mcp/src/search/vectors.js +60 -0
- package/vendor/desk/mcp/src/server.js +389 -0
- package/vendor/desk/mcp/src/tool-names.js +73 -0
- package/vendor/desk/mcp/src/tool-refusal.cjs +35 -0
- package/vendor/desk/mcp/src/tool-schema-parts.js +12 -0
- package/vendor/desk/mcp/src/tool-schemas.js +325 -0
- package/vendor/desk/mcp/src/tools/_card-commit.js +148 -0
- package/vendor/desk/mcp/src/tools/archive-links.js +185 -0
- package/vendor/desk/mcp/src/tools/archive-move.js +18 -0
- package/vendor/desk/mcp/src/tools/archive-native-session.js +728 -0
- package/vendor/desk/mcp/src/tools/archive-state.js +513 -0
- package/vendor/desk/mcp/src/tools/delivery-gate.js +251 -0
- package/vendor/desk/mcp/src/tools/desk-save.js +444 -0
- package/vendor/desk/mcp/src/tools/doctor.js +122 -0
- package/vendor/desk/mcp/src/tools/done-evidence.js +260 -0
- package/vendor/desk/mcp/src/tools/factory-context.js +204 -0
- package/vendor/desk/mcp/src/tools/friction.js +332 -0
- package/vendor/desk/mcp/src/tools/improvement.js +156 -0
- package/vendor/desk/mcp/src/tools/lesson-lines.js +22 -0
- package/vendor/desk/mcp/src/tools/lesson-owners.js +137 -0
- package/vendor/desk/mcp/src/tools/lesson-team.js +169 -0
- package/vendor/desk/mcp/src/tools/lesson.js +254 -0
- package/vendor/desk/mcp/src/tools/local-only.js +151 -0
- package/vendor/desk/mcp/src/tools/move.js +794 -0
- package/vendor/desk/mcp/src/tools/native-stage-context.js +32 -0
- package/vendor/desk/mcp/src/tools/note.js +267 -0
- package/vendor/desk/mcp/src/tools/search.js +634 -0
- package/vendor/desk/mcp/src/tools/shared-write.js +196 -0
- package/vendor/desk/mcp/src/tools/sibling-desk.js +37 -0
- package/vendor/desk/mcp/src/tools/status.js +233 -0
- package/vendor/desk/mcp/src/tools/task-archive-due.js +9 -0
- package/vendor/desk/mcp/src/tools/task-archived-resource.js +53 -0
- package/vendor/desk/mcp/src/tools/task-body.js +141 -0
- package/vendor/desk/mcp/src/tools/task-focus.js +164 -0
- package/vendor/desk/mcp/src/tools/task-log.js +76 -0
- package/vendor/desk/mcp/src/tools/task-signoff.js +155 -0
- package/vendor/desk/mcp/src/tools/task.js +1768 -0
- package/vendor/desk/mcp/src/tools/track-row.js +89 -0
- package/vendor/desk/mcp/src/tools/track.js +240 -0
- package/vendor/desk/mcp/src/util/agency-session.cjs +29 -0
- package/vendor/desk/mcp/src/util/archive-links.js +105 -0
- package/vendor/desk/mcp/src/util/bash.js +36 -0
- package/vendor/desk/mcp/src/util/capture-record.js +73 -0
- package/vendor/desk/mcp/src/util/cas-commit.js +252 -0
- package/vendor/desk/mcp/src/util/created-dirs.js +71 -0
- package/vendor/desk/mcp/src/util/deferred-tools.js +51 -0
- package/vendor/desk/mcp/src/util/desk-owner.js +99 -0
- package/vendor/desk/mcp/src/util/env-value.js +13 -0
- package/vendor/desk/mcp/src/util/file-identity.js +40 -0
- package/vendor/desk/mcp/src/util/finish-commit.js +145 -0
- package/vendor/desk/mcp/src/util/fm.js +410 -0
- package/vendor/desk/mcp/src/util/git-config-file.js +85 -0
- package/vendor/desk/mcp/src/util/git-stage.js +440 -0
- package/vendor/desk/mcp/src/util/main-publish.js +240 -0
- package/vendor/desk/mcp/src/util/markdown-links.cjs +555 -0
- package/vendor/desk/mcp/src/util/object-input.js +59 -0
- package/vendor/desk/mcp/src/util/paths.js +647 -0
- package/vendor/desk/mcp/src/util/rank.js +189 -0
- package/vendor/desk/mcp/src/util/redact.js +92 -0
- package/vendor/desk/mcp/src/util/remove-retry.js +35 -0
- package/vendor/desk/mcp/src/util/rename-retry.js +73 -0
- package/vendor/desk/mcp/src/util/route-around.js +265 -0
- package/vendor/desk/mcp/src/util/shell-quote.js +18 -0
- package/vendor/desk/mcp/src/util/startup-direction.js +124 -0
- package/vendor/desk/mcp/src/util/state-ignore.js +33 -0
- package/vendor/desk/mcp/src/util/tool-commits.js +64 -0
- package/vendor/desk/mcp/src/util/unicode-16/LICENSE-MIT.txt +7 -0
- package/vendor/desk/mcp/src/util/unicode-16/README.md +9 -0
- package/vendor/desk/mcp/src/util/unicode-16/letter.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/mark.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/number.cjs +1 -0
- package/vendor/desk/mcp/web-auth.cjs +1897 -0
- package/vendor/desk/mcp/web-browser-discovery.cjs +53 -0
- package/vendor/desk/mcp/web-catalog.json +34 -0
- package/vendor/desk/mcp/web-launch.cjs +101 -0
- package/vendor/desk/mcp/web.cjs +1239 -0
- package/vendor/desk/migrations/01-move-to-ourostack-desk.md +188 -0
- package/vendor/desk/migrations/02-tidy-desk.md +87 -0
- package/vendor/desk/migrations/03-desk-release-channel.md +38 -0
- package/vendor/desk/optional/session-label/consumer.mjs +237 -0
- package/vendor/desk/optional/session-label/extension.mjs +32 -0
- package/vendor/desk/plugin.json +54 -0
- package/vendor/desk/settings.json +3 -0
- package/vendor/desk/skills/add-workspace-mcp/SKILL.md +180 -0
- package/vendor/desk/skills/adopt-inflight-work/SKILL.md +212 -0
- package/vendor/desk/skills/archive-workflow/SKILL.md +132 -0
- package/vendor/desk/skills/content-routing/SKILL.md +95 -0
- package/vendor/desk/skills/core-meeting-capture/SKILL.md +47 -0
- package/vendor/desk/skills/core-meeting-capture/references/capture-contract.md +175 -0
- package/vendor/desk/skills/curator/SKILL.md +103 -0
- package/vendor/desk/skills/delightful-decks/SKILL.md +67 -0
- package/vendor/desk/skills/desk-problem/SKILL.md +87 -0
- package/vendor/desk/skills/directory-structure/SKILL.md +169 -0
- package/vendor/desk/skills/doc-review-rigor/SKILL.md +63 -0
- package/vendor/desk/skills/draining-issues/SKILL.md +62 -0
- package/vendor/desk/skills/evaluate-release/SKILL.md +96 -0
- package/vendor/desk/skills/evidence-discipline/SKILL.md +150 -0
- package/vendor/desk/skills/factory-evaluator/SKILL.md +122 -0
- package/vendor/desk/skills/factory-task-context/SKILL.md +116 -0
- package/vendor/desk/skills/factory-work/SKILL.md +16 -0
- package/vendor/desk/skills/fast-honest-ci/SKILL.md +70 -0
- package/vendor/desk/skills/fast-honest-ci/examples.md +49 -0
- package/vendor/desk/skills/first-run-bootstrap/SKILL.md +95 -0
- package/vendor/desk/skills/friction-management/SKILL.md +98 -0
- package/vendor/desk/skills/git-hygiene/SKILL.md +253 -0
- package/vendor/desk/skills/independent-review/SKILL.md +34 -0
- package/vendor/desk/skills/interaction-style/SKILL.md +239 -0
- package/vendor/desk/skills/lesson-capture/SKILL.md +85 -0
- package/vendor/desk/skills/lesson-capture/agents-md-budget.mjs +61 -0
- package/vendor/desk/skills/online-evaluation/SKILL.md +81 -0
- package/vendor/desk/skills/operator-voice-comments/LICENSE-humanize +21 -0
- package/vendor/desk/skills/operator-voice-comments/SKILL.md +90 -0
- package/vendor/desk/skills/operator-voice-comments/human-voice.md +43 -0
- package/vendor/desk/skills/peer-pr-review/SKILL.md +104 -0
- package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +145 -0
- package/vendor/desk/skills/pr-review-interrogation/SKILL.md +121 -0
- package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +68 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +335 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +486 -0
- package/vendor/desk/skills/pr-self-review/SKILL.md +86 -0
- package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +105 -0
- package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +99 -0
- package/vendor/desk/skills/pr-surface-hygiene/repository-setup.md +19 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pr-visual-proof.yml +29 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pull-request-template.md +5 -0
- package/vendor/desk/skills/preflight-actions/SKILL.md +60 -0
- package/vendor/desk/skills/preview-feedback/SKILL.md +70 -0
- package/vendor/desk/skills/repo-handling/SKILL.md +67 -0
- package/vendor/desk/skills/rnd-lab/SKILL.md +52 -0
- package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +106 -0
- package/vendor/desk/skills/session-resumption/SKILL.md +126 -0
- package/vendor/desk/skills/session-start/SKILL.md +54 -0
- package/vendor/desk/skills/session-start/details.md +150 -0
- package/vendor/desk/skills/session-start-migrations/README.md +71 -0
- package/vendor/desk/skills/session-start-migrations/SKILL.md +108 -0
- package/vendor/desk/skills/start-task/SKILL.md +88 -0
- package/vendor/desk/skills/task-card-format/SKILL.md +198 -0
- package/vendor/desk/skills/task-lifecycle/SKILL.md +217 -0
- package/vendor/desk/skills/track-card-format/SKILL.md +90 -0
- package/vendor/desk/skills/using-desk/SKILL.md +58 -0
- package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +156 -0
- package/vendor/desk/skills/work-orchestration/SKILL.md +162 -0
- package/dist/heart/daemon/auth-flow.js +0 -457
- package/dist/heart/daemon/habit-parser.js +0 -119
- package/dist/heart/daemon/habit-scheduler.js +0 -252
- package/dist/heart/daemon/mcp-server.js +0 -591
- package/dist/heart/daemon/ouro-path-installer.js +0 -221
- package/dist/heart/daemon/ouro-version-manager.js +0 -171
- package/dist/heart/daemon/specialist-tools.js +0 -283
- package/dist/heart/daemon/update-hooks.js +0 -138
- package/dist/heart/obligations.js +0 -197
- package/dist/heart/session-recall.js +0 -216
- package/dist/mind/associative-recall.js +0 -287
- package/dist/mind/friends/resolver.js +0 -84
- package/dist/mind/friends/store-file.js +0 -190
- package/dist/mind/friends/trust-explanation.js +0 -74
- package/dist/mind/friends/types.js +0 -29
- package/dist/mind/journal-index.js +0 -161
- package/dist/mind/obligations.js +0 -134
- package/dist/repertoire/tasks/board.js +0 -134
- package/dist/repertoire/tasks/index.js +0 -224
- package/dist/repertoire/tasks/lifecycle.js +0 -80
- package/dist/repertoire/tasks/middleware.js +0 -65
- package/dist/repertoire/tasks/parser.js +0 -171
- package/dist/repertoire/tasks/scanner.js +0 -132
- package/dist/repertoire/tasks/transitions.js +0 -126
- package/dist/repertoire/tools-bluebubbles.js +0 -94
- package/dist/senses/bluebubbles-entry.js +0 -13
- package/dist/senses/bluebubbles-media.js +0 -339
- package/dist/senses/bluebubbles.js +0 -1268
- package/dist/senses/contextual-heartbeat.js +0 -106
- package/dist/senses/debug-activity.js +0 -154
- package/dist/senses/inner-dialog-worker.js +0 -154
- package/dist/senses/inner-dialog.js +0 -768
- package/subagents/README.md +0 -7
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
- /package/dist/{repertoire/tasks/types.js → heart/attachments/sources/adapter.js} +0 -0
- /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
- /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
- /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
- /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
- /package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/store.js +0 -0
|
@@ -0,0 +1,2014 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getBlueBubblesSemanticPaths = getBlueBubblesSemanticPaths;
|
|
37
|
+
exports.getBlueBubblesSemanticPathsAtRoot = getBlueBubblesSemanticPathsAtRoot;
|
|
38
|
+
exports.serializeBlueBubblesSemanticJson = serializeBlueBubblesSemanticJson;
|
|
39
|
+
exports.normalizeIngressIdentifier = normalizeIngressIdentifier;
|
|
40
|
+
exports.hashIngressActorIdentity = hashIngressActorIdentity;
|
|
41
|
+
exports.normalizeIngressParticipants = normalizeIngressParticipants;
|
|
42
|
+
exports.initializeBlueBubblesSemanticCutover = initializeBlueBubblesSemanticCutover;
|
|
43
|
+
exports.rotateBlueBubblesSemanticCutover = rotateBlueBubblesSemanticCutover;
|
|
44
|
+
exports.readBlueBubblesSemanticCutover = readBlueBubblesSemanticCutover;
|
|
45
|
+
exports.readBlueBubblesSemanticCutoverAtRoot = readBlueBubblesSemanticCutoverAtRoot;
|
|
46
|
+
exports.buildBlueBubblesSemanticIdentity = buildBlueBubblesSemanticIdentity;
|
|
47
|
+
exports.buildBlueBubblesSemanticCapture = buildBlueBubblesSemanticCapture;
|
|
48
|
+
exports.buildBlueBubblesReactionCoordinateRecord = buildBlueBubblesReactionCoordinateRecord;
|
|
49
|
+
exports.buildBlueBubblesSemanticClaimRecord = buildBlueBubblesSemanticClaimRecord;
|
|
50
|
+
exports.classifyBlueBubblesRecoveryRecord = classifyBlueBubblesRecoveryRecord;
|
|
51
|
+
exports.writeBlueBubblesSemanticCapture = writeBlueBubblesSemanticCapture;
|
|
52
|
+
exports.readBlueBubblesSemanticCapture = readBlueBubblesSemanticCapture;
|
|
53
|
+
exports.readBlueBubblesSemanticCaptureAtRoot = readBlueBubblesSemanticCaptureAtRoot;
|
|
54
|
+
exports.listPendingBlueBubblesSemanticCaptures = listPendingBlueBubblesSemanticCaptures;
|
|
55
|
+
exports.compareBlueBubblesSemanticCaptureOrder = compareBlueBubblesSemanticCaptureOrder;
|
|
56
|
+
exports.writeBlueBubblesSemanticHandled = writeBlueBubblesSemanticHandled;
|
|
57
|
+
exports.readBlueBubblesSemanticHandled = readBlueBubblesSemanticHandled;
|
|
58
|
+
exports.acquireBlueBubblesSemanticClaim = acquireBlueBubblesSemanticClaim;
|
|
59
|
+
exports.releaseBlueBubblesSemanticClaim = releaseBlueBubblesSemanticClaim;
|
|
60
|
+
exports.allocateBlueBubblesReactionCoordinate = allocateBlueBubblesReactionCoordinate;
|
|
61
|
+
const node_crypto_1 = require("node:crypto");
|
|
62
|
+
const node_child_process_1 = require("node:child_process");
|
|
63
|
+
const fs = __importStar(require("node:fs"));
|
|
64
|
+
const os = __importStar(require("node:os"));
|
|
65
|
+
const path = __importStar(require("node:path"));
|
|
66
|
+
const sqlite_1 = require("../../heart/sqlite");
|
|
67
|
+
const identity_1 = require("../../heart/identity");
|
|
68
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
69
|
+
const UUID_V4_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
70
|
+
const ISO_MILLISECONDS_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
71
|
+
const CUTOVER_KEYS = ["schemaVersion", "providerNamespace", "effectiveAt"];
|
|
72
|
+
const CANONICAL_VALUES = new Set([
|
|
73
|
+
"love",
|
|
74
|
+
"like",
|
|
75
|
+
"dislike",
|
|
76
|
+
"laugh",
|
|
77
|
+
"emphasize",
|
|
78
|
+
"question",
|
|
79
|
+
"custom",
|
|
80
|
+
"unknown",
|
|
81
|
+
]);
|
|
82
|
+
const CANONICAL_ACTIONS = new Set(["add", "remove"]);
|
|
83
|
+
const SEMANTIC_KEY_HASH_PATTERN = /^[0-9a-f]{64}$/;
|
|
84
|
+
const SEMANTIC_CLAIM_POLL_MS = 50;
|
|
85
|
+
const SEMANTIC_CLAIM_TIMEOUT_MS = 5_000;
|
|
86
|
+
const SEMANTIC_OWNERSHIP_SCHEMA_VERSION = 1;
|
|
87
|
+
const SEMANTIC_OWNERSHIP_SCHEMA_SQL = `CREATE TABLE owner_leases (
|
|
88
|
+
resource_key TEXT PRIMARY KEY,
|
|
89
|
+
lease_id TEXT NOT NULL,
|
|
90
|
+
owner_json TEXT NOT NULL
|
|
91
|
+
) STRICT, WITHOUT ROWID`;
|
|
92
|
+
const CAPTURE_KEYS = ["schemaVersion", "canonicalKey", "keyHash", "providerNamespace", "capturedAt", "event"];
|
|
93
|
+
const OBSERVATION_ORDER_KEYS = [
|
|
94
|
+
"schemaVersion",
|
|
95
|
+
"keyHash",
|
|
96
|
+
"captureHash",
|
|
97
|
+
"observedAt",
|
|
98
|
+
"observationEpoch",
|
|
99
|
+
"observationOrdinal",
|
|
100
|
+
];
|
|
101
|
+
const CAPTURE_EVENT_KEYS = [
|
|
102
|
+
"provider",
|
|
103
|
+
"kind",
|
|
104
|
+
"eventGuid",
|
|
105
|
+
"fromMe",
|
|
106
|
+
"actor",
|
|
107
|
+
"participants",
|
|
108
|
+
"sourceEventType",
|
|
109
|
+
"sessionKey",
|
|
110
|
+
"chatGuid",
|
|
111
|
+
"chatIdentifier",
|
|
112
|
+
"text",
|
|
113
|
+
"textSha256",
|
|
114
|
+
"targetGuid",
|
|
115
|
+
"targetAuthorship",
|
|
116
|
+
"canonicalAction",
|
|
117
|
+
"canonicalValue",
|
|
118
|
+
"rawTransportValue",
|
|
119
|
+
"effectiveAt",
|
|
120
|
+
"revision",
|
|
121
|
+
"contentSha256",
|
|
122
|
+
];
|
|
123
|
+
const OBSERVED_IDENTITY_KEYS = ["provider", "externalId", "displayName"];
|
|
124
|
+
const CLAIM_KEYS = ["schemaVersion", "canonicalKey", "keyHash", "owner"];
|
|
125
|
+
const CLAIM_OWNER_KEYS = ["operationId", "pid", "bootIdentity", "processStartedAt", "acquiredAt"];
|
|
126
|
+
const HANDLED_KEYS = ["schemaVersion", "canonicalKey", "keyHash", "handledAt", "outcome", "detailCode"];
|
|
127
|
+
const COORDINATE_KEYS = [
|
|
128
|
+
"schemaVersion",
|
|
129
|
+
"coordinateKey",
|
|
130
|
+
"coordinateHash",
|
|
131
|
+
"generation",
|
|
132
|
+
"lastAction",
|
|
133
|
+
"updatedAt",
|
|
134
|
+
];
|
|
135
|
+
const SEMANTIC_EVENT_KINDS = new Set(["message", "reaction", "edit", "unsend", "read", "delivery"]);
|
|
136
|
+
const SEMANTIC_HANDLED_OUTCOMES = new Set([
|
|
137
|
+
"ignored_self",
|
|
138
|
+
"capture_only_removal",
|
|
139
|
+
"capture_only_positive",
|
|
140
|
+
"capture_only_custom",
|
|
141
|
+
"capture_only_unknown",
|
|
142
|
+
"capture_only_target_not_agent",
|
|
143
|
+
"capture_only_untrusted_actor",
|
|
144
|
+
"restricted_feedback_settled",
|
|
145
|
+
"restricted_feedback_observed",
|
|
146
|
+
"restricted_feedback_failed",
|
|
147
|
+
"message_completed",
|
|
148
|
+
"message_observed",
|
|
149
|
+
"message_failed",
|
|
150
|
+
"edit_capture_only",
|
|
151
|
+
"unsend_capture_only",
|
|
152
|
+
"read_audit_only",
|
|
153
|
+
"delivery_audit_only",
|
|
154
|
+
]);
|
|
155
|
+
const lastOwnerAcquisitionMs = new Map();
|
|
156
|
+
const semanticClaimLeaseIds = new WeakMap();
|
|
157
|
+
function getBlueBubblesSemanticPaths(agentName) {
|
|
158
|
+
return getBlueBubblesSemanticPathsAtRoot((0, identity_1.getAgentRoot)(agentName));
|
|
159
|
+
}
|
|
160
|
+
function getBlueBubblesSemanticPathsAtRoot(agentRoot) {
|
|
161
|
+
const root = path.join(agentRoot, "state", "senses", "bluebubbles", "semantic-receipts");
|
|
162
|
+
return {
|
|
163
|
+
root,
|
|
164
|
+
cutover: path.join(root, "cutover.json"),
|
|
165
|
+
captures: path.join(root, "captures"),
|
|
166
|
+
observationOrders: path.join(root, "observation-orders"),
|
|
167
|
+
handled: path.join(root, "handled"),
|
|
168
|
+
claims: path.join(root, "claims"),
|
|
169
|
+
coordinates: path.join(root, "coordinates"),
|
|
170
|
+
quarantine: path.join(root, "quarantine"),
|
|
171
|
+
ownership: path.join(root, "ownership.sqlite"),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function serializeBlueBubblesSemanticJson(value) {
|
|
175
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
176
|
+
}
|
|
177
|
+
function normalizeIngressIdentifier(value) {
|
|
178
|
+
return String(value).trim().toLowerCase();
|
|
179
|
+
}
|
|
180
|
+
function hashIngressActorIdentity(externalId) {
|
|
181
|
+
const normalized = normalizeIngressIdentifier(externalId);
|
|
182
|
+
return sha256Utf8(JSON.stringify(["imessage-handle", normalized]));
|
|
183
|
+
}
|
|
184
|
+
function normalizeIngressParticipants(participants) {
|
|
185
|
+
return participants
|
|
186
|
+
.map((participant) => ({
|
|
187
|
+
provider: "imessage-handle",
|
|
188
|
+
externalId: normalizeIngressIdentifier(participant.externalId),
|
|
189
|
+
displayName: normalizeDisplayName(participant.displayName),
|
|
190
|
+
}))
|
|
191
|
+
.filter((participant) => participant.externalId.length > 0)
|
|
192
|
+
.sort((left, right) => left.externalId.localeCompare(right.externalId));
|
|
193
|
+
}
|
|
194
|
+
function initializeBlueBubblesSemanticCutover(agentName, deps = {}) {
|
|
195
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
196
|
+
const existing = readBlueBubblesSemanticCutover(agentName);
|
|
197
|
+
if (existing)
|
|
198
|
+
return existing;
|
|
199
|
+
if (fs.existsSync(paths.cutover))
|
|
200
|
+
throw new Error("semantic_cutover_invalid");
|
|
201
|
+
const marker = createCutover(deps);
|
|
202
|
+
fs.mkdirSync(paths.root, { recursive: true });
|
|
203
|
+
const tempPath = path.join(paths.root, `.cutover.json.${process.pid}.${marker.providerNamespace}.tmp`);
|
|
204
|
+
let tempFd = null;
|
|
205
|
+
let tempOwned = false;
|
|
206
|
+
let published = false;
|
|
207
|
+
let primaryError;
|
|
208
|
+
try {
|
|
209
|
+
tempFd = fs.openSync(tempPath, "wx", 0o600);
|
|
210
|
+
tempOwned = true;
|
|
211
|
+
fs.writeFileSync(tempFd, serializeBlueBubblesSemanticJson(marker), "utf8");
|
|
212
|
+
fs.fsyncSync(tempFd);
|
|
213
|
+
fs.closeSync(tempFd);
|
|
214
|
+
tempFd = null;
|
|
215
|
+
try {
|
|
216
|
+
fs.linkSync(tempPath, paths.cutover);
|
|
217
|
+
published = true;
|
|
218
|
+
fsyncDirectory(paths.root);
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
if (!isNodeError(error, "EEXIST"))
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
primaryError = error;
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
let cleanupError;
|
|
231
|
+
if (tempFd !== null) {
|
|
232
|
+
try {
|
|
233
|
+
fs.closeSync(tempFd);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
cleanupError = error;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (tempOwned) {
|
|
240
|
+
try {
|
|
241
|
+
fs.unlinkSync(tempPath);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
if (!isNodeError(error, "ENOENT") && cleanupError === undefined)
|
|
245
|
+
cleanupError = error;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (primaryError === undefined && cleanupError !== undefined)
|
|
249
|
+
throw cleanupError;
|
|
250
|
+
}
|
|
251
|
+
if (!published) {
|
|
252
|
+
const winner = readBlueBubblesSemanticCutover(agentName);
|
|
253
|
+
if (!winner)
|
|
254
|
+
throw new Error("semantic_cutover_invalid");
|
|
255
|
+
return winner;
|
|
256
|
+
}
|
|
257
|
+
(0, runtime_1.emitNervesEvent)({
|
|
258
|
+
component: "senses",
|
|
259
|
+
event: "senses.bluebubbles_semantic_cutover_initialized",
|
|
260
|
+
message: "initialized bluebubbles semantic cutover",
|
|
261
|
+
meta: { agentName, schemaVersion: 1 },
|
|
262
|
+
});
|
|
263
|
+
return marker;
|
|
264
|
+
}
|
|
265
|
+
function rotateBlueBubblesSemanticCutover(agentName, reason, deps = {}) {
|
|
266
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
267
|
+
const marker = createCutover(deps);
|
|
268
|
+
fs.mkdirSync(paths.root, { recursive: true });
|
|
269
|
+
const tempPath = path.join(paths.root, `.cutover.json.${process.pid}.${marker.providerNamespace}.tmp`);
|
|
270
|
+
let tempFd = null;
|
|
271
|
+
let tempOwned = false;
|
|
272
|
+
let primaryError;
|
|
273
|
+
try {
|
|
274
|
+
tempFd = fs.openSync(tempPath, "wx", 0o600);
|
|
275
|
+
tempOwned = true;
|
|
276
|
+
fs.writeFileSync(tempFd, serializeBlueBubblesSemanticJson(marker), "utf8");
|
|
277
|
+
fs.fsyncSync(tempFd);
|
|
278
|
+
fs.closeSync(tempFd);
|
|
279
|
+
tempFd = null;
|
|
280
|
+
fs.renameSync(tempPath, paths.cutover);
|
|
281
|
+
fsyncDirectory(paths.root);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
primaryError = error;
|
|
285
|
+
throw error;
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
let cleanupError;
|
|
289
|
+
if (tempFd !== null) {
|
|
290
|
+
try {
|
|
291
|
+
fs.closeSync(tempFd);
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
cleanupError = error;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (tempOwned) {
|
|
298
|
+
try {
|
|
299
|
+
fs.unlinkSync(tempPath);
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
if (!isNodeError(error, "ENOENT") && cleanupError === undefined)
|
|
303
|
+
cleanupError = error;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (primaryError === undefined && cleanupError !== undefined)
|
|
307
|
+
throw cleanupError;
|
|
308
|
+
}
|
|
309
|
+
(0, runtime_1.emitNervesEvent)({
|
|
310
|
+
component: "senses",
|
|
311
|
+
event: "senses.bluebubbles_semantic_cutover_rotated",
|
|
312
|
+
message: "rotated bluebubbles semantic provider namespace",
|
|
313
|
+
meta: { agentName, reason, schemaVersion: 1 },
|
|
314
|
+
});
|
|
315
|
+
return marker;
|
|
316
|
+
}
|
|
317
|
+
function readBlueBubblesSemanticCutover(agentName) {
|
|
318
|
+
return readBlueBubblesSemanticCutoverAtRoot((0, identity_1.getAgentRoot)(agentName), {}, agentName);
|
|
319
|
+
}
|
|
320
|
+
function readBlueBubblesSemanticCutoverAtRoot(agentRoot, deps = {}, diagnosticIdentity = path.basename(agentRoot)) {
|
|
321
|
+
const storeFs = deps.fs ?? fs;
|
|
322
|
+
const filePath = getBlueBubblesSemanticPathsAtRoot(agentRoot).cutover;
|
|
323
|
+
if (!storeFs.existsSync(filePath))
|
|
324
|
+
return null;
|
|
325
|
+
try {
|
|
326
|
+
const parsed = JSON.parse(storeFs.readFileSync(filePath, "utf8"));
|
|
327
|
+
return isBlueBubblesSemanticCutover(parsed) ? parsed : null;
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
(0, runtime_1.emitNervesEvent)({
|
|
331
|
+
level: "error",
|
|
332
|
+
component: "senses",
|
|
333
|
+
event: "senses.bluebubbles_semantic_cutover_error",
|
|
334
|
+
message: "failed to read bluebubbles semantic cutover",
|
|
335
|
+
meta: {
|
|
336
|
+
agentName: diagnosticIdentity,
|
|
337
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function buildBlueBubblesSemanticIdentity(input) {
|
|
344
|
+
const providerNamespace = normalizeProviderNamespace(input.providerNamespace);
|
|
345
|
+
if (!providerNamespace)
|
|
346
|
+
return null;
|
|
347
|
+
if (input.kind === "message") {
|
|
348
|
+
const eventGuid = requiredIdentifier(input.eventGuid);
|
|
349
|
+
if (!eventGuid)
|
|
350
|
+
return null;
|
|
351
|
+
return identityFromKey(["bb-sem-v1", providerNamespace, "message", eventGuid], true);
|
|
352
|
+
}
|
|
353
|
+
if (input.kind === "reaction") {
|
|
354
|
+
const eventGuid = requiredIdentifier(input.eventGuid);
|
|
355
|
+
const targetGuid = requiredIdentifier(input.targetGuid);
|
|
356
|
+
const actorExternalId = requiredIdentifier(input.actorExternalId);
|
|
357
|
+
const canonicalValue = normalizeCanonicalValue(input.canonicalValue);
|
|
358
|
+
const canonicalAction = normalizeCanonicalAction(input.canonicalAction);
|
|
359
|
+
if (!eventGuid || !targetGuid || !actorExternalId || !canonicalValue || !canonicalAction)
|
|
360
|
+
return null;
|
|
361
|
+
const actorIdentityHash = hashIngressActorIdentity(actorExternalId);
|
|
362
|
+
const coordinateTuple = [
|
|
363
|
+
"bb-sem-v1",
|
|
364
|
+
providerNamespace,
|
|
365
|
+
"reaction-coordinate",
|
|
366
|
+
eventGuid,
|
|
367
|
+
targetGuid,
|
|
368
|
+
actorIdentityHash,
|
|
369
|
+
canonicalValue,
|
|
370
|
+
];
|
|
371
|
+
const coordinateKey = JSON.stringify(coordinateTuple);
|
|
372
|
+
const coordinateHash = sha256Utf8(coordinateKey);
|
|
373
|
+
const discriminator = mutationDiscriminator(input)
|
|
374
|
+
?? generationDiscriminator(input.coordinateGeneration);
|
|
375
|
+
if (!discriminator)
|
|
376
|
+
return null;
|
|
377
|
+
return identityFromKey([
|
|
378
|
+
"bb-sem-v1",
|
|
379
|
+
providerNamespace,
|
|
380
|
+
"reaction",
|
|
381
|
+
eventGuid,
|
|
382
|
+
targetGuid,
|
|
383
|
+
actorIdentityHash,
|
|
384
|
+
canonicalValue,
|
|
385
|
+
canonicalAction,
|
|
386
|
+
discriminator,
|
|
387
|
+
], true, discriminator, coordinateKey, coordinateHash);
|
|
388
|
+
}
|
|
389
|
+
if (input.kind === "edit") {
|
|
390
|
+
const messageGuid = requiredIdentifier(input.eventGuid);
|
|
391
|
+
if (!messageGuid)
|
|
392
|
+
return null;
|
|
393
|
+
const discriminator = mutationDiscriminator(input)
|
|
394
|
+
?? (typeof input.text === "string" ? `content:${sha256Utf8(input.text)}` : null);
|
|
395
|
+
if (!discriminator)
|
|
396
|
+
return null;
|
|
397
|
+
return identityFromKey(["bb-sem-v1", providerNamespace, "edit", messageGuid, discriminator], true, discriminator);
|
|
398
|
+
}
|
|
399
|
+
if (input.kind === "unsend") {
|
|
400
|
+
const targetGuid = requiredIdentifier(input.targetGuid);
|
|
401
|
+
if (!targetGuid)
|
|
402
|
+
return null;
|
|
403
|
+
const discriminator = mutationDiscriminator(input) ?? "terminal";
|
|
404
|
+
return identityFromKey(["bb-sem-v1", providerNamespace, "unsend", targetGuid, discriminator], true, discriminator);
|
|
405
|
+
}
|
|
406
|
+
const eventGuid = requiredIdentifier(input.eventGuid);
|
|
407
|
+
if (!eventGuid)
|
|
408
|
+
return null;
|
|
409
|
+
const discriminator = effectiveTimestampDiscriminator(input.effectiveTimestamp) ?? "terminal";
|
|
410
|
+
return identityFromKey(["bb-sem-v1", providerNamespace, "audit", input.kind, eventGuid, discriminator], false, discriminator);
|
|
411
|
+
}
|
|
412
|
+
function buildBlueBubblesSemanticCapture(input) {
|
|
413
|
+
if (typeof input.event.fromMe !== "boolean")
|
|
414
|
+
return null;
|
|
415
|
+
const providerNamespace = normalizeProviderNamespace(input.cutover.providerNamespace);
|
|
416
|
+
const capturedAt = exactIsoMilliseconds(input.capturedAt);
|
|
417
|
+
const sender = input.event.sender;
|
|
418
|
+
const actorExternalId = sender.observed === true
|
|
419
|
+
? requiredIdentifier(sender.externalId)
|
|
420
|
+
: null;
|
|
421
|
+
if (!providerNamespace || !capturedAt || !actorExternalId)
|
|
422
|
+
return null;
|
|
423
|
+
const inputObservationEpoch = input.observationEpoch;
|
|
424
|
+
const inputObservationOrdinal = input.observationOrdinal;
|
|
425
|
+
const observationClock = inputObservationEpoch === undefined
|
|
426
|
+
&& inputObservationOrdinal === undefined
|
|
427
|
+
? null
|
|
428
|
+
: isBlueBubblesObservationEpoch(inputObservationEpoch)
|
|
429
|
+
&& typeof inputObservationOrdinal === "number"
|
|
430
|
+
&& Number.isSafeInteger(inputObservationOrdinal)
|
|
431
|
+
&& inputObservationOrdinal > 0
|
|
432
|
+
? {
|
|
433
|
+
observationEpoch: inputObservationEpoch,
|
|
434
|
+
observationOrdinal: inputObservationOrdinal,
|
|
435
|
+
}
|
|
436
|
+
: false;
|
|
437
|
+
if (observationClock === false)
|
|
438
|
+
return null;
|
|
439
|
+
const kind = input.event.kind === "message" ? "message" : input.event.mutationType;
|
|
440
|
+
// BlueBubbles looks messages up by exact GUID. The identity key folds case so
|
|
441
|
+
// spellings deduplicate, but the capture keeps the provider's spelling so
|
|
442
|
+
// recovery can fetch the message again.
|
|
443
|
+
const eventGuid = providerGuid(input.event.messageGuid);
|
|
444
|
+
const targetGuid = input.event.kind === "mutation"
|
|
445
|
+
? providerGuid(input.event.targetMessageGuid)
|
|
446
|
+
?? (input.event.mutationType === "unsend" ? eventGuid : null)
|
|
447
|
+
: null;
|
|
448
|
+
const reaction = input.event.kind === "mutation" ? input.event.reaction : undefined;
|
|
449
|
+
const editedText = input.event.kind === "mutation" ? input.event.editedText : undefined;
|
|
450
|
+
const identity = buildBlueBubblesSemanticIdentity({
|
|
451
|
+
providerNamespace,
|
|
452
|
+
kind,
|
|
453
|
+
eventGuid,
|
|
454
|
+
targetGuid,
|
|
455
|
+
actorExternalId,
|
|
456
|
+
canonicalValue: reaction?.canonicalValue,
|
|
457
|
+
canonicalAction: reaction?.action,
|
|
458
|
+
revision: input.event.kind === "mutation" ? input.event.revision : undefined,
|
|
459
|
+
effectiveTimestamp: input.event.kind === "mutation" ? input.event.effectiveTimestamp : undefined,
|
|
460
|
+
text: input.event.kind === "message" ? input.event.text : editedText,
|
|
461
|
+
coordinateGeneration: input.coordinateGeneration,
|
|
462
|
+
});
|
|
463
|
+
if (!identity)
|
|
464
|
+
return null;
|
|
465
|
+
const text = input.event.kind === "message"
|
|
466
|
+
? input.event.text
|
|
467
|
+
: kind === "edit" ? editedText ?? null : null;
|
|
468
|
+
const textSha256 = text === null ? null : sha256Utf8(text);
|
|
469
|
+
const effectiveAt = input.event.kind === "mutation"
|
|
470
|
+
? finiteTimestampIso(input.event.effectiveTimestamp)
|
|
471
|
+
: null;
|
|
472
|
+
const revision = input.event.kind === "mutation"
|
|
473
|
+
? normalizedRevision(input.event.revision)
|
|
474
|
+
: null;
|
|
475
|
+
const participants = normalizeIngressParticipants(input.event.chat.participantHandles.map((externalId) => ({
|
|
476
|
+
provider: "imessage-handle",
|
|
477
|
+
externalId,
|
|
478
|
+
displayName: null,
|
|
479
|
+
})));
|
|
480
|
+
const capture = {
|
|
481
|
+
schemaVersion: 1,
|
|
482
|
+
canonicalKey: identity.canonicalKey,
|
|
483
|
+
keyHash: identity.keyHash,
|
|
484
|
+
providerNamespace,
|
|
485
|
+
capturedAt,
|
|
486
|
+
event: {
|
|
487
|
+
provider: "bluebubbles",
|
|
488
|
+
kind,
|
|
489
|
+
eventGuid,
|
|
490
|
+
fromMe: input.event.fromMe,
|
|
491
|
+
actor: {
|
|
492
|
+
provider: "imessage-handle",
|
|
493
|
+
externalId: actorExternalId,
|
|
494
|
+
displayName: normalizeDisplayName(sender.displayName),
|
|
495
|
+
},
|
|
496
|
+
participants,
|
|
497
|
+
sourceEventType: input.event.eventType,
|
|
498
|
+
sessionKey: nullableString(input.event.chat.sessionKey),
|
|
499
|
+
chatGuid: nullableString(input.event.chat.chatGuid),
|
|
500
|
+
chatIdentifier: nullableString(input.event.chat.chatIdentifier),
|
|
501
|
+
text,
|
|
502
|
+
textSha256,
|
|
503
|
+
targetGuid,
|
|
504
|
+
targetAuthorship: input.targetAuthorship,
|
|
505
|
+
canonicalAction: reaction?.action ?? null,
|
|
506
|
+
canonicalValue: reaction?.canonicalValue ?? null,
|
|
507
|
+
rawTransportValue: reaction?.rawTransportValue ?? null,
|
|
508
|
+
effectiveAt,
|
|
509
|
+
revision,
|
|
510
|
+
contentSha256: kind === "edit" ? textSha256 : null,
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
if (observationClock) {
|
|
514
|
+
attachBlueBubblesSemanticObservationOrder(capture, {
|
|
515
|
+
schemaVersion: 1,
|
|
516
|
+
keyHash: capture.keyHash,
|
|
517
|
+
captureHash: blueBubblesSemanticCaptureHash(capture),
|
|
518
|
+
observedAt: capturedAt,
|
|
519
|
+
...observationClock,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return capture;
|
|
523
|
+
}
|
|
524
|
+
function buildBlueBubblesReactionCoordinateRecord(input) {
|
|
525
|
+
return {
|
|
526
|
+
schemaVersion: 1,
|
|
527
|
+
coordinateKey: input.coordinateKey,
|
|
528
|
+
coordinateHash: input.coordinateHash,
|
|
529
|
+
generation: input.generation,
|
|
530
|
+
lastAction: input.lastAction,
|
|
531
|
+
updatedAt: input.updatedAt,
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function buildBlueBubblesSemanticClaimRecord(input) {
|
|
535
|
+
return {
|
|
536
|
+
schemaVersion: 1,
|
|
537
|
+
canonicalKey: input.canonicalKey,
|
|
538
|
+
keyHash: input.keyHash,
|
|
539
|
+
owner: {
|
|
540
|
+
operationId: input.operationId,
|
|
541
|
+
pid: input.pid,
|
|
542
|
+
bootIdentity: input.bootIdentity,
|
|
543
|
+
processStartedAt: input.processStartedAt,
|
|
544
|
+
acquiredAt: input.acquiredAt,
|
|
545
|
+
},
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function classifyBlueBubblesRecoveryRecord(value, cutover) {
|
|
549
|
+
if (!isRecord(value) || value.schemaVersion !== 1) {
|
|
550
|
+
emitLegacyRecoveryBlocked(value);
|
|
551
|
+
return { disposition: "audit_only", reason: "legacy_or_actorless" };
|
|
552
|
+
}
|
|
553
|
+
if (!isRecord(value.event)) {
|
|
554
|
+
emitInvalidSemanticRecoveryRecord(value, false, "event_missing");
|
|
555
|
+
return { disposition: "audit_only", reason: "legacy_or_actorless" };
|
|
556
|
+
}
|
|
557
|
+
const actor = value.event.actor;
|
|
558
|
+
if (!isRecord(actor)
|
|
559
|
+
|| actor.provider !== "imessage-handle"
|
|
560
|
+
|| typeof actor.externalId !== "string"
|
|
561
|
+
|| actor.externalId.trim().length === 0) {
|
|
562
|
+
emitInvalidSemanticRecoveryRecord(value, false, "actor_missing");
|
|
563
|
+
return { disposition: "audit_only", reason: "legacy_or_actorless" };
|
|
564
|
+
}
|
|
565
|
+
if (value.providerNamespace !== cutover.providerNamespace
|
|
566
|
+
|| typeof value.capturedAt !== "string"
|
|
567
|
+
|| !exactIsoMilliseconds(value.capturedAt)
|
|
568
|
+
|| value.capturedAt < cutover.effectiveAt) {
|
|
569
|
+
return { disposition: "audit_only", reason: "before_cutover" };
|
|
570
|
+
}
|
|
571
|
+
if (value.event.kind === "read" || value.event.kind === "delivery") {
|
|
572
|
+
return { disposition: "audit_only", reason: "audit_event" };
|
|
573
|
+
}
|
|
574
|
+
if (typeof value.keyHash !== "string" || value.keyHash.length === 0) {
|
|
575
|
+
emitInvalidSemanticRecoveryRecord(value, true, "key_hash_missing");
|
|
576
|
+
return { disposition: "audit_only", reason: "legacy_or_actorless" };
|
|
577
|
+
}
|
|
578
|
+
return { disposition: "handleable", keyHash: value.keyHash };
|
|
579
|
+
}
|
|
580
|
+
function writeBlueBubblesSemanticCapture(agentName, capture, deps = {}) {
|
|
581
|
+
(0, runtime_1.emitNervesEvent)({
|
|
582
|
+
component: "senses",
|
|
583
|
+
event: "bluebubbles_semantic_capture_start",
|
|
584
|
+
message: "publishing bluebubbles semantic capture",
|
|
585
|
+
meta: { agentName, keyHash: capture.keyHash },
|
|
586
|
+
});
|
|
587
|
+
try {
|
|
588
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
589
|
+
const finalPath = semanticRecordPath(paths.captures, capture.keyHash);
|
|
590
|
+
const validCapture = isBlueBubblesSemanticCapture(capture, capture.keyHash);
|
|
591
|
+
const existing = readExistingCaptureForWrite(agentName, capture.keyHash, deps);
|
|
592
|
+
if (existing) {
|
|
593
|
+
if (validCapture && capturesAreEquivalent(existing, capture)) {
|
|
594
|
+
persistBlueBubblesSemanticObservationOrder(agentName, capture, deps);
|
|
595
|
+
}
|
|
596
|
+
return finishCaptureComparison(agentName, existing, capture, deps);
|
|
597
|
+
}
|
|
598
|
+
if (!validCapture)
|
|
599
|
+
throw semanticStoreError("semantic_capture_invalid");
|
|
600
|
+
persistBlueBubblesSemanticObservationOrder(agentName, capture, deps);
|
|
601
|
+
const publication = publishImmutableSemanticRecord(paths.captures, finalPath, capture, deps);
|
|
602
|
+
if (publication === "exists") {
|
|
603
|
+
const winner = readExistingCaptureForWrite(agentName, capture.keyHash, deps);
|
|
604
|
+
if (!winner) {
|
|
605
|
+
return writeBlueBubblesSemanticCaptureAfterQuarantine(agentName, capture, deps);
|
|
606
|
+
}
|
|
607
|
+
return finishCaptureComparison(agentName, winner, capture, deps);
|
|
608
|
+
}
|
|
609
|
+
(0, runtime_1.emitNervesEvent)({
|
|
610
|
+
component: "senses",
|
|
611
|
+
event: "bluebubbles_semantic_capture_end",
|
|
612
|
+
message: "published bluebubbles semantic capture",
|
|
613
|
+
meta: { agentName, keyHash: capture.keyHash, result: "semantic_capture_published" },
|
|
614
|
+
});
|
|
615
|
+
return "semantic_capture_published";
|
|
616
|
+
}
|
|
617
|
+
catch (error) {
|
|
618
|
+
emitCaptureError(agentName, capture.keyHash, error);
|
|
619
|
+
throw semanticStoreError("semantic_capture_failed", error);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function readBlueBubblesSemanticCapture(agentName, keyHash, deps = {}) {
|
|
623
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
624
|
+
const finalPath = semanticRecordPath(paths.captures, keyHash);
|
|
625
|
+
const capture = readSemanticRecord(finalPath, "capture", keyHash, (value) => isBlueBubblesSemanticCapture(value, keyHash), deps);
|
|
626
|
+
return capture ? attachStoredBlueBubblesSemanticObservationOrder(paths, capture, deps) : null;
|
|
627
|
+
}
|
|
628
|
+
function readBlueBubblesSemanticCaptureAtRoot(agentRoot, keyHash, deps = {}) {
|
|
629
|
+
const paths = getBlueBubblesSemanticPathsAtRoot(agentRoot);
|
|
630
|
+
const finalPath = semanticRecordPath(paths.captures, keyHash);
|
|
631
|
+
const capture = readSemanticRecord(finalPath, "capture", keyHash, (value) => isBlueBubblesSemanticCapture(value, keyHash), deps);
|
|
632
|
+
return capture ? attachStoredBlueBubblesSemanticObservationOrder(paths, capture, deps) : null;
|
|
633
|
+
}
|
|
634
|
+
function listPendingBlueBubblesSemanticCaptures(agentName, deps = {}) {
|
|
635
|
+
const storeFs = semanticFs(deps);
|
|
636
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
637
|
+
if (!storeFs.existsSync(paths.captures))
|
|
638
|
+
return [];
|
|
639
|
+
const captures = [];
|
|
640
|
+
const names = storeFs.readdirSync(paths.captures)
|
|
641
|
+
.filter((name) => /^[0-9a-f]{64}\.json$/.test(name))
|
|
642
|
+
.sort();
|
|
643
|
+
for (const name of names) {
|
|
644
|
+
const keyHash = name.slice(0, -".json".length);
|
|
645
|
+
const capture = readBlueBubblesSemanticCapture(agentName, keyHash, deps);
|
|
646
|
+
if (!capture)
|
|
647
|
+
continue;
|
|
648
|
+
if (readBlueBubblesSemanticHandled(agentName, keyHash, deps))
|
|
649
|
+
continue;
|
|
650
|
+
captures.push(capture);
|
|
651
|
+
}
|
|
652
|
+
return captures.sort((left, right) => (compareBlueBubblesSemanticCaptureOrder(left, right)));
|
|
653
|
+
}
|
|
654
|
+
function compareBlueBubblesSemanticCaptureOrder(left, right) {
|
|
655
|
+
if (left.observationEpoch !== undefined
|
|
656
|
+
&& left.observationEpoch === right.observationEpoch
|
|
657
|
+
&& left.observationOrdinal !== undefined
|
|
658
|
+
&& right.observationOrdinal !== undefined
|
|
659
|
+
&& left.observationOrdinal !== right.observationOrdinal) {
|
|
660
|
+
return left.observationOrdinal - right.observationOrdinal;
|
|
661
|
+
}
|
|
662
|
+
const capturedOrder = (left.observationObservedAt ?? left.capturedAt)
|
|
663
|
+
.localeCompare(right.observationObservedAt ?? right.capturedAt);
|
|
664
|
+
if (capturedOrder !== 0)
|
|
665
|
+
return capturedOrder;
|
|
666
|
+
if (left.observationEpoch === undefined && right.observationEpoch === undefined)
|
|
667
|
+
return 0;
|
|
668
|
+
const epochOrder = (left.observationEpoch ?? "").localeCompare(right.observationEpoch ?? "");
|
|
669
|
+
if (epochOrder !== 0)
|
|
670
|
+
return epochOrder;
|
|
671
|
+
return left.keyHash.localeCompare(right.keyHash);
|
|
672
|
+
}
|
|
673
|
+
function attachBlueBubblesSemanticObservationOrder(capture, order) {
|
|
674
|
+
Object.defineProperties(capture, {
|
|
675
|
+
observationObservedAt: {
|
|
676
|
+
configurable: true,
|
|
677
|
+
enumerable: false,
|
|
678
|
+
value: order.observedAt,
|
|
679
|
+
},
|
|
680
|
+
observationEpoch: {
|
|
681
|
+
configurable: true,
|
|
682
|
+
enumerable: false,
|
|
683
|
+
value: order.observationEpoch,
|
|
684
|
+
},
|
|
685
|
+
observationOrdinal: {
|
|
686
|
+
configurable: true,
|
|
687
|
+
enumerable: false,
|
|
688
|
+
value: order.observationOrdinal,
|
|
689
|
+
},
|
|
690
|
+
});
|
|
691
|
+
return capture;
|
|
692
|
+
}
|
|
693
|
+
function blueBubblesSemanticObservationOrderFromCapture(capture) {
|
|
694
|
+
if (!isBlueBubblesObservationEpoch(capture.observationEpoch)
|
|
695
|
+
|| typeof capture.observationOrdinal !== "number"
|
|
696
|
+
|| !Number.isSafeInteger(capture.observationOrdinal)
|
|
697
|
+
|| capture.observationOrdinal <= 0)
|
|
698
|
+
return null;
|
|
699
|
+
return {
|
|
700
|
+
schemaVersion: 1,
|
|
701
|
+
keyHash: capture.keyHash,
|
|
702
|
+
captureHash: blueBubblesSemanticCaptureHash(capture),
|
|
703
|
+
observedAt: capture.capturedAt,
|
|
704
|
+
observationEpoch: capture.observationEpoch,
|
|
705
|
+
observationOrdinal: capture.observationOrdinal,
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
function compareBlueBubblesSemanticObservationOrders(left, right) {
|
|
709
|
+
if (left.observationEpoch === right.observationEpoch
|
|
710
|
+
&& left.observationOrdinal !== right.observationOrdinal) {
|
|
711
|
+
return left.observationOrdinal - right.observationOrdinal;
|
|
712
|
+
}
|
|
713
|
+
const observedOrder = left.observedAt.localeCompare(right.observedAt);
|
|
714
|
+
if (observedOrder !== 0)
|
|
715
|
+
return observedOrder;
|
|
716
|
+
const epochOrder = left.observationEpoch.localeCompare(right.observationEpoch);
|
|
717
|
+
if (epochOrder !== 0)
|
|
718
|
+
return epochOrder;
|
|
719
|
+
return left.observationOrdinal - right.observationOrdinal;
|
|
720
|
+
}
|
|
721
|
+
function persistBlueBubblesSemanticObservationOrder(agentName, capture, deps) {
|
|
722
|
+
const candidate = blueBubblesSemanticObservationOrderFromCapture(capture);
|
|
723
|
+
if (!candidate)
|
|
724
|
+
return;
|
|
725
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
726
|
+
const finalPath = semanticRecordPath(paths.observationOrders, candidate.captureHash);
|
|
727
|
+
const startedAt = semanticNow(deps).getTime();
|
|
728
|
+
while (true) {
|
|
729
|
+
const result = withExclusiveSemanticOwnership(paths.ownership, deps, () => {
|
|
730
|
+
const inspected = inspectSemanticRecord(finalPath, capture.keyHash, (value) => (isBlueBubblesSemanticObservationOrderRecord(value, capture.keyHash, candidate.captureHash)), deps);
|
|
731
|
+
if (inspected.status === "valid") {
|
|
732
|
+
if (compareBlueBubblesSemanticObservationOrders(inspected.value, candidate) <= 0) {
|
|
733
|
+
fsyncSemanticDirectory(paths.observationOrders, semanticFs(deps));
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
else if (inspected.status === "invalid") {
|
|
738
|
+
quarantineSemanticRecord(finalPath, "observation-order", capture.keyHash, deps, inspected.reason);
|
|
739
|
+
}
|
|
740
|
+
writeMutableSemanticRecord(paths.observationOrders, finalPath, candidate, deps);
|
|
741
|
+
});
|
|
742
|
+
if (result.status === "completed")
|
|
743
|
+
return;
|
|
744
|
+
if (semanticNow(deps).getTime() - startedAt >= SEMANTIC_CLAIM_TIMEOUT_MS) {
|
|
745
|
+
throw semanticStoreError("semantic_ownership_busy");
|
|
746
|
+
}
|
|
747
|
+
semanticSleepSync(SEMANTIC_CLAIM_POLL_MS, deps);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
function attachStoredBlueBubblesSemanticObservationOrder(paths, capture, deps) {
|
|
751
|
+
const captureHash = blueBubblesSemanticCaptureHash(capture);
|
|
752
|
+
const finalPath = semanticRecordPath(paths.observationOrders, captureHash);
|
|
753
|
+
const order = readSemanticRecord(finalPath, "observation-order", capture.keyHash, (value) => (isBlueBubblesSemanticObservationOrderRecord(value, capture.keyHash, captureHash)), deps);
|
|
754
|
+
return order ? attachBlueBubblesSemanticObservationOrder(capture, order) : capture;
|
|
755
|
+
}
|
|
756
|
+
function writeBlueBubblesSemanticHandled(agentName, record, deps = {}) {
|
|
757
|
+
try {
|
|
758
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
759
|
+
const finalPath = semanticRecordPath(paths.handled, record.keyHash);
|
|
760
|
+
const existing = readExistingHandledForWrite(agentName, record.keyHash, deps);
|
|
761
|
+
if (existing)
|
|
762
|
+
return finishHandledComparison(agentName, existing, record, deps);
|
|
763
|
+
if (!isBlueBubblesSemanticHandledRecord(record, record.keyHash)) {
|
|
764
|
+
throw semanticStoreError("semantic_handled_invalid");
|
|
765
|
+
}
|
|
766
|
+
const publication = publishImmutableSemanticRecord(paths.handled, finalPath, record, deps);
|
|
767
|
+
if (publication === "exists") {
|
|
768
|
+
const winner = readExistingHandledForWrite(agentName, record.keyHash, deps);
|
|
769
|
+
if (!winner)
|
|
770
|
+
return writeBlueBubblesSemanticHandled(agentName, record, deps);
|
|
771
|
+
return finishHandledComparison(agentName, winner, record, deps);
|
|
772
|
+
}
|
|
773
|
+
return "semantic_handled_published";
|
|
774
|
+
}
|
|
775
|
+
catch (error) {
|
|
776
|
+
emitSemanticStoreError(agentName, record.keyHash, "semantic_handled_failed", error);
|
|
777
|
+
if (error instanceof Error && error.message === "semantic_handled_failed")
|
|
778
|
+
throw error;
|
|
779
|
+
throw semanticStoreError("semantic_handled_failed", error);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function readBlueBubblesSemanticHandled(agentName, keyHash, deps = {}) {
|
|
783
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
784
|
+
const finalPath = semanticRecordPath(paths.handled, keyHash);
|
|
785
|
+
return readSemanticRecord(finalPath, "handled", keyHash, (value) => isBlueBubblesSemanticHandledRecord(value, keyHash), deps);
|
|
786
|
+
}
|
|
787
|
+
async function acquireBlueBubblesSemanticClaim(agentName, identity, deps = {}) {
|
|
788
|
+
const keyHash = validatedKeyHash(identity.keyHash);
|
|
789
|
+
if (sha256Utf8(identity.canonicalKey) !== keyHash) {
|
|
790
|
+
throw semanticStoreError("semantic_claim_invalid");
|
|
791
|
+
}
|
|
792
|
+
const handled = readBlueBubblesSemanticHandled(agentName, identity.keyHash, deps);
|
|
793
|
+
if (handled)
|
|
794
|
+
return { status: "already_handled", record: handled };
|
|
795
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
796
|
+
const ownerPath = path.join(paths.claims, `${validatedKeyHash(identity.keyHash)}.owner.json`);
|
|
797
|
+
let ownerResult;
|
|
798
|
+
try {
|
|
799
|
+
ownerResult = await acquireExclusiveSemanticOwner({
|
|
800
|
+
directoryPath: paths.claims,
|
|
801
|
+
ownerPath,
|
|
802
|
+
canonicalKey: identity.canonicalKey,
|
|
803
|
+
keyHash: identity.keyHash,
|
|
804
|
+
operationId: `semantic-handle:${identity.keyHash}`,
|
|
805
|
+
recordKind: "claim",
|
|
806
|
+
ownershipPath: paths.ownership,
|
|
807
|
+
resourceKey: `claim:${keyHash}`,
|
|
808
|
+
}, deps);
|
|
809
|
+
}
|
|
810
|
+
catch (error) {
|
|
811
|
+
if (error instanceof Error && error.message === "semantic_owner_liveness_failed") {
|
|
812
|
+
throw semanticStoreError("semantic_claim_liveness_failed", error);
|
|
813
|
+
}
|
|
814
|
+
throw error;
|
|
815
|
+
}
|
|
816
|
+
if (ownerResult.status === "timeout") {
|
|
817
|
+
return { status: "timeout", code: "semantic_claim_timeout" };
|
|
818
|
+
}
|
|
819
|
+
const lease = { status: "acquired", record: ownerResult.record };
|
|
820
|
+
semanticClaimLeaseIds.set(lease, ownerResult.leaseId);
|
|
821
|
+
const handledAfterClaim = readBlueBubblesSemanticHandled(agentName, identity.keyHash, deps);
|
|
822
|
+
if (handledAfterClaim) {
|
|
823
|
+
releaseBlueBubblesSemanticClaim(agentName, lease, deps);
|
|
824
|
+
return { status: "already_handled", record: handledAfterClaim };
|
|
825
|
+
}
|
|
826
|
+
(0, runtime_1.emitNervesEvent)({
|
|
827
|
+
component: "senses",
|
|
828
|
+
event: "bluebubbles_semantic_recovery_claimed",
|
|
829
|
+
message: "claimed captured bluebubbles semantic event",
|
|
830
|
+
meta: { schemaVersion: 1, actorPresent: true, keyHash: identity.keyHash },
|
|
831
|
+
});
|
|
832
|
+
return lease;
|
|
833
|
+
}
|
|
834
|
+
function releaseBlueBubblesSemanticClaim(agentName, lease, deps = {}) {
|
|
835
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
836
|
+
const ownerPath = path.join(paths.claims, `${validatedKeyHash(lease.record.keyHash)}.owner.json`);
|
|
837
|
+
const leaseId = semanticClaimLeaseIds.get(lease);
|
|
838
|
+
if (!leaseId)
|
|
839
|
+
return false;
|
|
840
|
+
return releaseExclusiveSemanticOwner({
|
|
841
|
+
directoryPath: paths.claims,
|
|
842
|
+
ownerPath,
|
|
843
|
+
ownershipPath: paths.ownership,
|
|
844
|
+
resourceKey: `claim:${lease.record.keyHash}`,
|
|
845
|
+
record: lease.record,
|
|
846
|
+
leaseId,
|
|
847
|
+
}, deps);
|
|
848
|
+
}
|
|
849
|
+
async function allocateBlueBubblesReactionCoordinate(agentName, input, deps = {}) {
|
|
850
|
+
const coordinateHash = validatedKeyHash(input.coordinateHash);
|
|
851
|
+
if (sha256Utf8(input.coordinateKey) !== coordinateHash || !CANONICAL_ACTIONS.has(input.canonicalAction)) {
|
|
852
|
+
throw semanticStoreError("semantic_coordinate_invalid");
|
|
853
|
+
}
|
|
854
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
855
|
+
const finalPath = path.join(paths.coordinates, `${coordinateHash}.json`);
|
|
856
|
+
const ownerPath = path.join(paths.coordinates, `${coordinateHash}.owner.lock`);
|
|
857
|
+
if (hasSemanticQuarantine(paths.quarantine, "coordinate", path.basename(finalPath), deps)) {
|
|
858
|
+
throw semanticStoreError("semantic_coordinate_invalid");
|
|
859
|
+
}
|
|
860
|
+
let ownerResult;
|
|
861
|
+
try {
|
|
862
|
+
ownerResult = await acquireExclusiveSemanticOwner({
|
|
863
|
+
directoryPath: paths.coordinates,
|
|
864
|
+
ownerPath,
|
|
865
|
+
canonicalKey: input.coordinateKey,
|
|
866
|
+
keyHash: coordinateHash,
|
|
867
|
+
operationId: `semantic-coordinate:${coordinateHash}`,
|
|
868
|
+
recordKind: "coordinate-owner",
|
|
869
|
+
ownershipPath: paths.ownership,
|
|
870
|
+
resourceKey: `coordinate:${coordinateHash}`,
|
|
871
|
+
}, deps);
|
|
872
|
+
}
|
|
873
|
+
catch (error) {
|
|
874
|
+
if (error instanceof Error && error.message === "semantic_owner_liveness_failed") {
|
|
875
|
+
throw semanticStoreError("semantic_coordinate_liveness_failed", error);
|
|
876
|
+
}
|
|
877
|
+
throw error;
|
|
878
|
+
}
|
|
879
|
+
if (ownerResult.status === "timeout") {
|
|
880
|
+
throw semanticStoreError("semantic_coordinate_lock_timeout");
|
|
881
|
+
}
|
|
882
|
+
try {
|
|
883
|
+
if (hasSemanticQuarantine(paths.quarantine, "coordinate", path.basename(finalPath), deps)) {
|
|
884
|
+
throw semanticStoreError("semantic_coordinate_invalid");
|
|
885
|
+
}
|
|
886
|
+
const existing = readSemanticRecord(finalPath, "coordinate", coordinateHash, (value) => isBlueBubblesReactionCoordinateRecord(value, input.coordinateKey, coordinateHash), deps);
|
|
887
|
+
if (!existing && hasSemanticQuarantine(paths.quarantine, "coordinate", path.basename(finalPath), deps)) {
|
|
888
|
+
throw semanticStoreError("semantic_coordinate_invalid");
|
|
889
|
+
}
|
|
890
|
+
if (existing && existing.lastAction === input.canonicalAction) {
|
|
891
|
+
fsyncSemanticDirectory(paths.coordinates, semanticFs(deps));
|
|
892
|
+
return existing;
|
|
893
|
+
}
|
|
894
|
+
const record = buildBlueBubblesReactionCoordinateRecord({
|
|
895
|
+
coordinateKey: input.coordinateKey,
|
|
896
|
+
coordinateHash,
|
|
897
|
+
generation: existing ? existing.generation + 1 : 0,
|
|
898
|
+
lastAction: input.canonicalAction,
|
|
899
|
+
updatedAt: semanticNow(deps).toISOString(),
|
|
900
|
+
});
|
|
901
|
+
writeMutableSemanticRecord(paths.coordinates, finalPath, record, deps);
|
|
902
|
+
return record;
|
|
903
|
+
}
|
|
904
|
+
finally {
|
|
905
|
+
releaseExclusiveSemanticOwner({
|
|
906
|
+
directoryPath: paths.coordinates,
|
|
907
|
+
ownerPath,
|
|
908
|
+
ownershipPath: paths.ownership,
|
|
909
|
+
resourceKey: `coordinate:${coordinateHash}`,
|
|
910
|
+
record: ownerResult.record,
|
|
911
|
+
leaseId: ownerResult.leaseId,
|
|
912
|
+
}, deps);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
function writeBlueBubblesSemanticCaptureAfterQuarantine(agentName, capture, deps) {
|
|
916
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
917
|
+
const finalPath = semanticRecordPath(paths.captures, capture.keyHash);
|
|
918
|
+
const publication = publishImmutableSemanticRecord(paths.captures, finalPath, capture, deps);
|
|
919
|
+
if (publication === "exists") {
|
|
920
|
+
const winner = readExistingCaptureForWrite(agentName, capture.keyHash, deps);
|
|
921
|
+
if (!winner)
|
|
922
|
+
throw semanticStoreError("semantic_capture_failed");
|
|
923
|
+
return finishCaptureComparison(agentName, winner, capture, deps);
|
|
924
|
+
}
|
|
925
|
+
(0, runtime_1.emitNervesEvent)({
|
|
926
|
+
component: "senses",
|
|
927
|
+
event: "bluebubbles_semantic_capture_end",
|
|
928
|
+
message: "published bluebubbles semantic capture after quarantining invalid state",
|
|
929
|
+
meta: { agentName, keyHash: capture.keyHash, result: "semantic_capture_published" },
|
|
930
|
+
});
|
|
931
|
+
return "semantic_capture_published";
|
|
932
|
+
}
|
|
933
|
+
function readExistingCaptureForWrite(agentName, keyHash, deps) {
|
|
934
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
935
|
+
const finalPath = semanticRecordPath(paths.captures, keyHash);
|
|
936
|
+
return semanticFs(deps).existsSync(finalPath)
|
|
937
|
+
? readBlueBubblesSemanticCapture(agentName, keyHash, deps)
|
|
938
|
+
: null;
|
|
939
|
+
}
|
|
940
|
+
function finishCaptureComparison(agentName, existing, candidate, deps) {
|
|
941
|
+
fsyncSemanticDirectory(getBlueBubblesSemanticPaths(agentName).captures, semanticFs(deps));
|
|
942
|
+
if (capturesAreEquivalent(existing, candidate)) {
|
|
943
|
+
(0, runtime_1.emitNervesEvent)({
|
|
944
|
+
component: "senses",
|
|
945
|
+
event: "bluebubbles_semantic_capture_end",
|
|
946
|
+
message: "recognized duplicate bluebubbles semantic capture",
|
|
947
|
+
meta: { agentName, keyHash: candidate.keyHash, result: "semantic_capture_duplicate" },
|
|
948
|
+
});
|
|
949
|
+
return "semantic_capture_duplicate";
|
|
950
|
+
}
|
|
951
|
+
const error = semanticStoreError("semantic_identity_collision");
|
|
952
|
+
emitCaptureError(agentName, candidate.keyHash, error);
|
|
953
|
+
return "semantic_identity_collision";
|
|
954
|
+
}
|
|
955
|
+
function readExistingHandledForWrite(agentName, keyHash, deps) {
|
|
956
|
+
const paths = getBlueBubblesSemanticPaths(agentName);
|
|
957
|
+
const finalPath = semanticRecordPath(paths.handled, keyHash);
|
|
958
|
+
return semanticFs(deps).existsSync(finalPath)
|
|
959
|
+
? readBlueBubblesSemanticHandled(agentName, keyHash, deps)
|
|
960
|
+
: null;
|
|
961
|
+
}
|
|
962
|
+
function finishHandledComparison(agentName, existing, candidate, deps) {
|
|
963
|
+
fsyncSemanticDirectory(getBlueBubblesSemanticPaths(agentName).handled, semanticFs(deps));
|
|
964
|
+
if (handledRecordsAreEquivalent(existing, candidate))
|
|
965
|
+
return "semantic_handled_duplicate";
|
|
966
|
+
emitSemanticStoreError(agentName, candidate.keyHash, "semantic_handled_collision", semanticStoreError("semantic_handled_collision"));
|
|
967
|
+
return "semantic_handled_collision";
|
|
968
|
+
}
|
|
969
|
+
function capturesAreEquivalent(left, right) {
|
|
970
|
+
return blueBubblesSemanticCaptureHash(left) === blueBubblesSemanticCaptureHash(right);
|
|
971
|
+
}
|
|
972
|
+
function blueBubblesSemanticCaptureHash(capture) {
|
|
973
|
+
const projection = {
|
|
974
|
+
schemaVersion: capture.schemaVersion,
|
|
975
|
+
canonicalKey: capture.canonicalKey,
|
|
976
|
+
keyHash: capture.keyHash,
|
|
977
|
+
providerNamespace: capture.providerNamespace,
|
|
978
|
+
event: {
|
|
979
|
+
provider: capture.event.provider,
|
|
980
|
+
kind: capture.event.kind,
|
|
981
|
+
eventGuid: caseFoldedGuid(capture.event.eventGuid),
|
|
982
|
+
fromMe: capture.event.fromMe,
|
|
983
|
+
actor: capture.event.actor,
|
|
984
|
+
participants: capture.event.participants,
|
|
985
|
+
text: capture.event.text,
|
|
986
|
+
textSha256: capture.event.textSha256,
|
|
987
|
+
targetGuid: caseFoldedGuid(capture.event.targetGuid),
|
|
988
|
+
targetAuthorship: capture.event.targetAuthorship,
|
|
989
|
+
canonicalAction: capture.event.canonicalAction,
|
|
990
|
+
canonicalValue: capture.event.canonicalValue,
|
|
991
|
+
effectiveAt: capture.event.effectiveAt,
|
|
992
|
+
revision: capture.event.revision,
|
|
993
|
+
contentSha256: capture.event.contentSha256,
|
|
994
|
+
},
|
|
995
|
+
};
|
|
996
|
+
return sha256Utf8(JSON.stringify(projection));
|
|
997
|
+
}
|
|
998
|
+
function handledRecordsAreEquivalent(left, right) {
|
|
999
|
+
const project = (record) => ({
|
|
1000
|
+
schemaVersion: record.schemaVersion,
|
|
1001
|
+
canonicalKey: record.canonicalKey,
|
|
1002
|
+
keyHash: record.keyHash,
|
|
1003
|
+
outcome: record.outcome,
|
|
1004
|
+
detailCode: record.detailCode,
|
|
1005
|
+
});
|
|
1006
|
+
return JSON.stringify(project(left)) === JSON.stringify(project(right));
|
|
1007
|
+
}
|
|
1008
|
+
function publishImmutableSemanticRecord(directoryPath, finalPath, value, deps) {
|
|
1009
|
+
const storeFs = semanticFs(deps);
|
|
1010
|
+
storeFs.mkdirSync(directoryPath, { recursive: true });
|
|
1011
|
+
const tempPath = semanticTempPath(finalPath, deps);
|
|
1012
|
+
let tempFd = null;
|
|
1013
|
+
let tempOwned = false;
|
|
1014
|
+
let outcome = null;
|
|
1015
|
+
let primaryError;
|
|
1016
|
+
try {
|
|
1017
|
+
tempFd = storeFs.openSync(tempPath, "wx", 0o600);
|
|
1018
|
+
tempOwned = true;
|
|
1019
|
+
storeFs.writeFileSync(tempFd, serializeBlueBubblesSemanticJson(value), "utf8");
|
|
1020
|
+
storeFs.fsyncSync(tempFd);
|
|
1021
|
+
storeFs.closeSync(tempFd);
|
|
1022
|
+
tempFd = null;
|
|
1023
|
+
try {
|
|
1024
|
+
storeFs.linkSync(tempPath, finalPath);
|
|
1025
|
+
fsyncSemanticDirectory(directoryPath, storeFs);
|
|
1026
|
+
outcome = "published";
|
|
1027
|
+
}
|
|
1028
|
+
catch (error) {
|
|
1029
|
+
if (!isNodeError(error, "EEXIST"))
|
|
1030
|
+
throw error;
|
|
1031
|
+
outcome = "exists";
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
catch (error) {
|
|
1035
|
+
primaryError = error;
|
|
1036
|
+
}
|
|
1037
|
+
let cleanupError;
|
|
1038
|
+
if (tempFd !== null) {
|
|
1039
|
+
try {
|
|
1040
|
+
storeFs.closeSync(tempFd);
|
|
1041
|
+
}
|
|
1042
|
+
catch (error) {
|
|
1043
|
+
cleanupError = error;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (tempOwned) {
|
|
1047
|
+
try {
|
|
1048
|
+
storeFs.unlinkSync(tempPath);
|
|
1049
|
+
}
|
|
1050
|
+
catch (error) {
|
|
1051
|
+
if (!isNodeError(error, "ENOENT") && cleanupError === undefined)
|
|
1052
|
+
cleanupError = error;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
if (primaryError !== undefined)
|
|
1056
|
+
throw primaryError;
|
|
1057
|
+
if (cleanupError !== undefined)
|
|
1058
|
+
throw cleanupError;
|
|
1059
|
+
return outcome;
|
|
1060
|
+
}
|
|
1061
|
+
function writeMutableSemanticRecord(directoryPath, finalPath, value, deps) {
|
|
1062
|
+
const storeFs = semanticFs(deps);
|
|
1063
|
+
storeFs.mkdirSync(directoryPath, { recursive: true });
|
|
1064
|
+
const tempPath = semanticTempPath(finalPath, deps);
|
|
1065
|
+
let tempFd = null;
|
|
1066
|
+
let tempOwned = false;
|
|
1067
|
+
let primaryError;
|
|
1068
|
+
try {
|
|
1069
|
+
tempFd = storeFs.openSync(tempPath, "wx", 0o600);
|
|
1070
|
+
tempOwned = true;
|
|
1071
|
+
storeFs.writeFileSync(tempFd, serializeBlueBubblesSemanticJson(value), "utf8");
|
|
1072
|
+
storeFs.fsyncSync(tempFd);
|
|
1073
|
+
storeFs.closeSync(tempFd);
|
|
1074
|
+
tempFd = null;
|
|
1075
|
+
storeFs.renameSync(tempPath, finalPath);
|
|
1076
|
+
fsyncSemanticDirectory(directoryPath, storeFs);
|
|
1077
|
+
}
|
|
1078
|
+
catch (error) {
|
|
1079
|
+
primaryError = error;
|
|
1080
|
+
}
|
|
1081
|
+
let cleanupError;
|
|
1082
|
+
if (tempFd !== null) {
|
|
1083
|
+
try {
|
|
1084
|
+
storeFs.closeSync(tempFd);
|
|
1085
|
+
}
|
|
1086
|
+
catch (error) {
|
|
1087
|
+
cleanupError = error;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
if (tempOwned) {
|
|
1091
|
+
try {
|
|
1092
|
+
storeFs.unlinkSync(tempPath);
|
|
1093
|
+
}
|
|
1094
|
+
catch (error) {
|
|
1095
|
+
if (!isNodeError(error, "ENOENT") && cleanupError === undefined)
|
|
1096
|
+
cleanupError = error;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
if (primaryError !== undefined)
|
|
1100
|
+
throw primaryError;
|
|
1101
|
+
if (cleanupError !== undefined)
|
|
1102
|
+
throw cleanupError;
|
|
1103
|
+
}
|
|
1104
|
+
async function acquireExclusiveSemanticOwner(input, deps) {
|
|
1105
|
+
const keyHash = validatedKeyHash(input.keyHash);
|
|
1106
|
+
const pid = semanticPid(deps);
|
|
1107
|
+
const ownerRecord = buildBlueBubblesSemanticClaimRecord({
|
|
1108
|
+
canonicalKey: input.canonicalKey,
|
|
1109
|
+
keyHash,
|
|
1110
|
+
operationId: input.operationId,
|
|
1111
|
+
pid,
|
|
1112
|
+
bootIdentity: semanticBootIdentity(deps),
|
|
1113
|
+
processStartedAt: requiredProbeIdentity(semanticProcessStartedAt(pid, deps)),
|
|
1114
|
+
acquiredAt: nextOwnerAcquiredAt(input.ownerPath, deps),
|
|
1115
|
+
});
|
|
1116
|
+
const leaseId = semanticRandomUuid(deps);
|
|
1117
|
+
const startedAt = semanticNow(deps).getTime();
|
|
1118
|
+
while (true) {
|
|
1119
|
+
const attempt = withExclusiveSemanticOwnership(input.ownershipPath, deps, (database) => acquireSemanticOwnerInTransaction(database, input, ownerRecord, leaseId, deps));
|
|
1120
|
+
if (attempt.status === "completed" && attempt.value === "acquired") {
|
|
1121
|
+
return { status: "acquired", record: ownerRecord, leaseId };
|
|
1122
|
+
}
|
|
1123
|
+
if (semanticNow(deps).getTime() - startedAt >= SEMANTIC_CLAIM_TIMEOUT_MS) {
|
|
1124
|
+
return { status: "timeout" };
|
|
1125
|
+
}
|
|
1126
|
+
await semanticSleep(SEMANTIC_CLAIM_POLL_MS, deps);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
function releaseExclusiveSemanticOwner(input, deps) {
|
|
1130
|
+
const startedAt = semanticNow(deps).getTime();
|
|
1131
|
+
while (true) {
|
|
1132
|
+
const result = withExclusiveSemanticOwnership(input.ownershipPath, deps, (database) => {
|
|
1133
|
+
const row = readSemanticOwnershipRow(database, input.resourceKey);
|
|
1134
|
+
if (!row || row.lease_id !== input.leaseId)
|
|
1135
|
+
return false;
|
|
1136
|
+
const rowOwner = parseSemanticOwnershipRow(row, {
|
|
1137
|
+
canonicalKey: input.record.canonicalKey,
|
|
1138
|
+
keyHash: input.record.keyHash,
|
|
1139
|
+
operationId: input.record.owner.operationId,
|
|
1140
|
+
});
|
|
1141
|
+
if (serializeBlueBubblesSemanticJson(rowOwner) !== serializeBlueBubblesSemanticJson(input.record)) {
|
|
1142
|
+
return false;
|
|
1143
|
+
}
|
|
1144
|
+
const evidence = inspectSemanticOwnerEvidence(input.ownerPath, {
|
|
1145
|
+
canonicalKey: input.record.canonicalKey,
|
|
1146
|
+
keyHash: input.record.keyHash,
|
|
1147
|
+
operationId: input.record.owner.operationId,
|
|
1148
|
+
}, deps);
|
|
1149
|
+
if (evidence.status === "invalid")
|
|
1150
|
+
return false;
|
|
1151
|
+
if (evidence.status === "valid" && evidence.bytes !== row.owner_json)
|
|
1152
|
+
return false;
|
|
1153
|
+
if (evidence.status === "valid" && !removeSemanticOwnerEvidenceIfUnchanged(input.directoryPath, input.ownerPath, row.owner_json, semanticFs(deps)))
|
|
1154
|
+
return false;
|
|
1155
|
+
deleteSemanticOwnershipRow(database, input.resourceKey, input.leaseId);
|
|
1156
|
+
return true;
|
|
1157
|
+
});
|
|
1158
|
+
if (result.status === "completed")
|
|
1159
|
+
return result.value;
|
|
1160
|
+
if (semanticNow(deps).getTime() - startedAt >= SEMANTIC_CLAIM_TIMEOUT_MS) {
|
|
1161
|
+
throw semanticStoreError("semantic_ownership_busy");
|
|
1162
|
+
}
|
|
1163
|
+
semanticSleepSync(SEMANTIC_CLAIM_POLL_MS, deps);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
function removeSemanticOwnerEvidenceIfUnchanged(directoryPath, ownerPath, expectedBytes, storeFs) {
|
|
1167
|
+
let before;
|
|
1168
|
+
try {
|
|
1169
|
+
before = storeFs.lstatSync(ownerPath);
|
|
1170
|
+
}
|
|
1171
|
+
catch (error) {
|
|
1172
|
+
if (isNodeError(error, "ENOENT"))
|
|
1173
|
+
return false;
|
|
1174
|
+
throw error;
|
|
1175
|
+
}
|
|
1176
|
+
let current;
|
|
1177
|
+
try {
|
|
1178
|
+
current = storeFs.readFileSync(ownerPath, "utf8");
|
|
1179
|
+
}
|
|
1180
|
+
catch (error) {
|
|
1181
|
+
if (isNodeError(error, "ENOENT"))
|
|
1182
|
+
return false;
|
|
1183
|
+
throw error;
|
|
1184
|
+
}
|
|
1185
|
+
const after = storeFs.lstatSync(ownerPath);
|
|
1186
|
+
if (!before.isFile()
|
|
1187
|
+
|| !after.isFile()
|
|
1188
|
+
|| before.dev !== after.dev
|
|
1189
|
+
|| before.ino !== after.ino
|
|
1190
|
+
|| current !== expectedBytes)
|
|
1191
|
+
return false;
|
|
1192
|
+
storeFs.unlinkSync(ownerPath);
|
|
1193
|
+
fsyncSemanticDirectory(directoryPath, storeFs);
|
|
1194
|
+
return true;
|
|
1195
|
+
}
|
|
1196
|
+
function withExclusiveSemanticOwnership(ownershipPath, deps, operation) {
|
|
1197
|
+
const storeFs = semanticFs(deps);
|
|
1198
|
+
storeFs.mkdirSync(path.dirname(ownershipPath), { recursive: true });
|
|
1199
|
+
let database = null;
|
|
1200
|
+
try {
|
|
1201
|
+
database = (0, sqlite_1.openDatabase)(ownershipPath, { timeout: 0 });
|
|
1202
|
+
database.pragma("busy_timeout = 0");
|
|
1203
|
+
database.pragma("journal_mode = DELETE");
|
|
1204
|
+
database.pragma("synchronous = FULL");
|
|
1205
|
+
database.exec("BEGIN EXCLUSIVE");
|
|
1206
|
+
initializeSemanticOwnershipSchema(database);
|
|
1207
|
+
fsyncSemanticDirectory(path.dirname(ownershipPath), storeFs);
|
|
1208
|
+
const value = operation(database);
|
|
1209
|
+
database.exec("COMMIT");
|
|
1210
|
+
return { status: "completed", value };
|
|
1211
|
+
}
|
|
1212
|
+
catch (error) {
|
|
1213
|
+
if (database?.inTransaction) {
|
|
1214
|
+
database.exec("ROLLBACK");
|
|
1215
|
+
}
|
|
1216
|
+
if (isSqliteBusy(error))
|
|
1217
|
+
return { status: "busy" };
|
|
1218
|
+
if (isSqliteError(error))
|
|
1219
|
+
throw semanticStoreError("semantic_ownership_invalid", error);
|
|
1220
|
+
throw error;
|
|
1221
|
+
}
|
|
1222
|
+
finally {
|
|
1223
|
+
database?.close();
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
function initializeSemanticOwnershipSchema(database) {
|
|
1227
|
+
const version = database.pragma("user_version", { simple: true });
|
|
1228
|
+
if (version === 0) {
|
|
1229
|
+
database.exec(SEMANTIC_OWNERSHIP_SCHEMA_SQL);
|
|
1230
|
+
database.pragma(`user_version = ${SEMANTIC_OWNERSHIP_SCHEMA_VERSION}`);
|
|
1231
|
+
}
|
|
1232
|
+
else if (version !== SEMANTIC_OWNERSHIP_SCHEMA_VERSION) {
|
|
1233
|
+
throw semanticStoreError("semantic_ownership_invalid");
|
|
1234
|
+
}
|
|
1235
|
+
const schema = database.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'owner_leases'").get();
|
|
1236
|
+
if (schema?.sql !== SEMANTIC_OWNERSHIP_SCHEMA_SQL) {
|
|
1237
|
+
throw semanticStoreError("semantic_ownership_invalid");
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
function acquireSemanticOwnerInTransaction(database, input, candidate, leaseId, deps) {
|
|
1241
|
+
const row = readSemanticOwnershipRow(database, input.resourceKey);
|
|
1242
|
+
if (row) {
|
|
1243
|
+
const existing = parseSemanticOwnershipRow(row, input);
|
|
1244
|
+
if (!semanticOwnerIsStale(existing, deps)) {
|
|
1245
|
+
reconcileSemanticOwnerEvidence(input, existing, deps);
|
|
1246
|
+
return "occupied";
|
|
1247
|
+
}
|
|
1248
|
+
quarantineSemanticOwnerEvidenceIfPresent(input, deps);
|
|
1249
|
+
deleteSemanticOwnershipRow(database, input.resourceKey, row.lease_id);
|
|
1250
|
+
}
|
|
1251
|
+
else {
|
|
1252
|
+
const evidence = inspectSemanticOwnerEvidence(input.ownerPath, input, deps);
|
|
1253
|
+
if (evidence.status === "valid" && !semanticOwnerIsStale(evidence.record, deps)) {
|
|
1254
|
+
insertSemanticOwnershipRow(database, input.resourceKey, semanticRandomUuid(deps), evidence.bytes);
|
|
1255
|
+
return "occupied";
|
|
1256
|
+
}
|
|
1257
|
+
if (evidence.status !== "missing") {
|
|
1258
|
+
quarantineSemanticRecord(input.ownerPath, input.recordKind, input.keyHash, deps, evidence.status === "invalid"
|
|
1259
|
+
? evidence.reason
|
|
1260
|
+
: semanticStoreError("semantic_owner_stale"));
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
const ownerJson = serializeBlueBubblesSemanticJson(candidate);
|
|
1264
|
+
insertSemanticOwnershipRow(database, input.resourceKey, leaseId, ownerJson);
|
|
1265
|
+
ensureSemanticOwnerEvidence(input, candidate, ownerJson, deps);
|
|
1266
|
+
return "acquired";
|
|
1267
|
+
}
|
|
1268
|
+
function readSemanticOwnershipRow(database, resourceKey) {
|
|
1269
|
+
return database.prepare("SELECT resource_key, lease_id, owner_json FROM owner_leases WHERE resource_key = ?").get(resourceKey) ?? null;
|
|
1270
|
+
}
|
|
1271
|
+
function insertSemanticOwnershipRow(database, resourceKey, leaseId, ownerJson) {
|
|
1272
|
+
database.prepare("INSERT INTO owner_leases (resource_key, lease_id, owner_json) VALUES (?, ?, ?)").run(resourceKey, leaseId, ownerJson);
|
|
1273
|
+
}
|
|
1274
|
+
function deleteSemanticOwnershipRow(database, resourceKey, leaseId) {
|
|
1275
|
+
database.prepare("DELETE FROM owner_leases WHERE resource_key = ? AND lease_id = ?").run(resourceKey, leaseId);
|
|
1276
|
+
}
|
|
1277
|
+
function parseSemanticOwnershipRow(row, expected) {
|
|
1278
|
+
if (!UUID_V4_PATTERN.test(row.lease_id)) {
|
|
1279
|
+
throw semanticStoreError("semantic_ownership_invalid");
|
|
1280
|
+
}
|
|
1281
|
+
let value;
|
|
1282
|
+
try {
|
|
1283
|
+
value = JSON.parse(row.owner_json);
|
|
1284
|
+
}
|
|
1285
|
+
catch (error) {
|
|
1286
|
+
throw semanticStoreError("semantic_ownership_invalid", error);
|
|
1287
|
+
}
|
|
1288
|
+
if (!isBlueBubblesSemanticClaimRecord(value, expected)
|
|
1289
|
+
|| row.owner_json !== serializeBlueBubblesSemanticJson(value)) {
|
|
1290
|
+
throw semanticStoreError("semantic_ownership_invalid");
|
|
1291
|
+
}
|
|
1292
|
+
return value;
|
|
1293
|
+
}
|
|
1294
|
+
function semanticOwnerIsStale(owner, deps) {
|
|
1295
|
+
try {
|
|
1296
|
+
if (owner.owner.bootIdentity !== semanticBootIdentity(deps))
|
|
1297
|
+
return true;
|
|
1298
|
+
if (!semanticIsProcessAlive(owner.owner.pid, deps))
|
|
1299
|
+
return true;
|
|
1300
|
+
const observedStart = semanticProcessStartedAt(owner.owner.pid, deps);
|
|
1301
|
+
if (observedStart === null)
|
|
1302
|
+
throw semanticStoreError("semantic_owner_liveness_failed");
|
|
1303
|
+
return observedStart !== owner.owner.processStartedAt;
|
|
1304
|
+
}
|
|
1305
|
+
catch (error) {
|
|
1306
|
+
if (error instanceof Error && error.message === "semantic_owner_liveness_failed")
|
|
1307
|
+
throw error;
|
|
1308
|
+
throw semanticStoreError("semantic_owner_liveness_failed", error);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function inspectSemanticOwnerEvidence(ownerPath, input, deps) {
|
|
1312
|
+
const storeFs = semanticFs(deps);
|
|
1313
|
+
let stat;
|
|
1314
|
+
try {
|
|
1315
|
+
stat = storeFs.lstatSync(ownerPath);
|
|
1316
|
+
}
|
|
1317
|
+
catch (error) {
|
|
1318
|
+
if (isNodeError(error, "ENOENT"))
|
|
1319
|
+
return { status: "missing" };
|
|
1320
|
+
throw error;
|
|
1321
|
+
}
|
|
1322
|
+
if (!stat.isFile() || stat.isSymbolicLink()) {
|
|
1323
|
+
return { status: "invalid", reason: semanticStoreError("semantic_owner_evidence_invalid") };
|
|
1324
|
+
}
|
|
1325
|
+
let bytes;
|
|
1326
|
+
try {
|
|
1327
|
+
bytes = storeFs.readFileSync(ownerPath, "utf8");
|
|
1328
|
+
}
|
|
1329
|
+
catch (error) {
|
|
1330
|
+
return { status: "invalid", reason: error };
|
|
1331
|
+
}
|
|
1332
|
+
let value;
|
|
1333
|
+
try {
|
|
1334
|
+
value = JSON.parse(bytes);
|
|
1335
|
+
}
|
|
1336
|
+
catch (error) {
|
|
1337
|
+
return { status: "invalid", reason: error };
|
|
1338
|
+
}
|
|
1339
|
+
if (!isBlueBubblesSemanticClaimRecord(value, input)
|
|
1340
|
+
|| bytes !== serializeBlueBubblesSemanticJson(value)) {
|
|
1341
|
+
return { status: "invalid", reason: semanticStoreError("semantic_owner_evidence_invalid") };
|
|
1342
|
+
}
|
|
1343
|
+
return { status: "valid", record: value, bytes };
|
|
1344
|
+
}
|
|
1345
|
+
function reconcileSemanticOwnerEvidence(input, owner, deps) {
|
|
1346
|
+
const ownerJson = serializeBlueBubblesSemanticJson(owner);
|
|
1347
|
+
const evidence = inspectSemanticOwnerEvidence(input.ownerPath, input, deps);
|
|
1348
|
+
if (evidence.status === "valid" && evidence.bytes === ownerJson) {
|
|
1349
|
+
fsyncSemanticDirectory(input.directoryPath, semanticFs(deps));
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
if (evidence.status !== "missing") {
|
|
1353
|
+
quarantineSemanticRecord(input.ownerPath, input.recordKind, input.keyHash, deps, evidence.status === "invalid"
|
|
1354
|
+
? evidence.reason
|
|
1355
|
+
: semanticStoreError("semantic_owner_evidence_mismatch"));
|
|
1356
|
+
}
|
|
1357
|
+
ensureSemanticOwnerEvidence(input, owner, ownerJson, deps);
|
|
1358
|
+
}
|
|
1359
|
+
function quarantineSemanticOwnerEvidenceIfPresent(input, deps) {
|
|
1360
|
+
const evidence = inspectSemanticOwnerEvidence(input.ownerPath, input, deps);
|
|
1361
|
+
if (evidence.status === "missing")
|
|
1362
|
+
return;
|
|
1363
|
+
quarantineSemanticRecord(input.ownerPath, input.recordKind, input.keyHash, deps, evidence.status === "invalid" ? evidence.reason : semanticStoreError("semantic_owner_stale"));
|
|
1364
|
+
}
|
|
1365
|
+
function ensureSemanticOwnerEvidence(input, owner, ownerJson, deps) {
|
|
1366
|
+
const evidence = inspectSemanticOwnerEvidence(input.ownerPath, input, deps);
|
|
1367
|
+
if (evidence.status === "valid" && evidence.bytes === ownerJson) {
|
|
1368
|
+
fsyncSemanticDirectory(input.directoryPath, semanticFs(deps));
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
if (evidence.status !== "missing") {
|
|
1372
|
+
quarantineSemanticRecord(input.ownerPath, input.recordKind, input.keyHash, deps, evidence.status === "invalid"
|
|
1373
|
+
? evidence.reason
|
|
1374
|
+
: semanticStoreError("semantic_owner_evidence_mismatch"));
|
|
1375
|
+
}
|
|
1376
|
+
const publication = publishImmutableSemanticRecord(input.directoryPath, input.ownerPath, owner, deps);
|
|
1377
|
+
if (publication !== "published")
|
|
1378
|
+
throw semanticStoreError("semantic_owner_evidence_collision");
|
|
1379
|
+
}
|
|
1380
|
+
function isSqliteBusy(error) {
|
|
1381
|
+
if (!(error instanceof Error) || !("code" in error) || typeof error.code !== "string") {
|
|
1382
|
+
return false;
|
|
1383
|
+
}
|
|
1384
|
+
return error.code.startsWith("SQLITE_BUSY") || error.code.startsWith("SQLITE_LOCKED");
|
|
1385
|
+
}
|
|
1386
|
+
function isSqliteError(error) {
|
|
1387
|
+
return error instanceof Error
|
|
1388
|
+
&& "code" in error
|
|
1389
|
+
&& typeof error.code === "string"
|
|
1390
|
+
&& error.code.startsWith("SQLITE_");
|
|
1391
|
+
}
|
|
1392
|
+
function readSemanticRecord(finalPath, recordKind, keyHash, validate, deps) {
|
|
1393
|
+
const initial = inspectSemanticRecord(finalPath, keyHash, validate, deps);
|
|
1394
|
+
if (initial.status === "missing")
|
|
1395
|
+
return null;
|
|
1396
|
+
if (initial.status === "valid")
|
|
1397
|
+
return initial.value;
|
|
1398
|
+
const ownershipPath = path.join(path.dirname(path.dirname(finalPath)), "ownership.sqlite");
|
|
1399
|
+
const startedAt = semanticNow(deps).getTime();
|
|
1400
|
+
while (true) {
|
|
1401
|
+
const result = withExclusiveSemanticOwnership(ownershipPath, deps, () => {
|
|
1402
|
+
const current = inspectSemanticRecord(finalPath, keyHash, validate, deps);
|
|
1403
|
+
if (current.status === "missing")
|
|
1404
|
+
return null;
|
|
1405
|
+
if (current.status === "valid")
|
|
1406
|
+
return current.value;
|
|
1407
|
+
quarantineSemanticRecord(finalPath, recordKind, keyHash, deps, current.reason);
|
|
1408
|
+
return null;
|
|
1409
|
+
});
|
|
1410
|
+
if (result.status === "completed")
|
|
1411
|
+
return result.value;
|
|
1412
|
+
if (semanticNow(deps).getTime() - startedAt >= SEMANTIC_CLAIM_TIMEOUT_MS) {
|
|
1413
|
+
throw semanticStoreError("semantic_ownership_busy");
|
|
1414
|
+
}
|
|
1415
|
+
semanticSleepSync(SEMANTIC_CLAIM_POLL_MS, deps);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
function inspectSemanticRecord(finalPath, keyHash, validate, deps) {
|
|
1419
|
+
const storeFs = semanticFs(deps);
|
|
1420
|
+
if (!storeFs.existsSync(finalPath))
|
|
1421
|
+
return { status: "missing" };
|
|
1422
|
+
let bytes;
|
|
1423
|
+
try {
|
|
1424
|
+
bytes = storeFs.readFileSync(finalPath, "utf8");
|
|
1425
|
+
}
|
|
1426
|
+
catch (error) {
|
|
1427
|
+
emitSemanticStoreError("unknown", keyHash, "semantic_record_read_failed", error);
|
|
1428
|
+
throw semanticStoreError("semantic_record_read_failed", error);
|
|
1429
|
+
}
|
|
1430
|
+
let value;
|
|
1431
|
+
try {
|
|
1432
|
+
value = JSON.parse(bytes);
|
|
1433
|
+
}
|
|
1434
|
+
catch (error) {
|
|
1435
|
+
return { status: "invalid", reason: error };
|
|
1436
|
+
}
|
|
1437
|
+
if (!validate(value)) {
|
|
1438
|
+
return {
|
|
1439
|
+
status: "invalid",
|
|
1440
|
+
reason: semanticStoreError("semantic_record_invalid"),
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
return { status: "valid", value };
|
|
1444
|
+
}
|
|
1445
|
+
function quarantineSemanticRecord(finalPath, recordKind, keyHash, deps, reason) {
|
|
1446
|
+
const storeFs = semanticFs(deps);
|
|
1447
|
+
const paths = semanticQuarantinePaths(finalPath, recordKind, deps);
|
|
1448
|
+
try {
|
|
1449
|
+
storeFs.mkdirSync(paths.directoryPath, { recursive: true });
|
|
1450
|
+
const sourceStat = storeFs.lstatSync(finalPath);
|
|
1451
|
+
if (sourceStat.isSymbolicLink()) {
|
|
1452
|
+
storeFs.symlinkSync(storeFs.readlinkSync(finalPath), paths.quarantinePath);
|
|
1453
|
+
}
|
|
1454
|
+
else {
|
|
1455
|
+
storeFs.linkSync(finalPath, paths.quarantinePath);
|
|
1456
|
+
}
|
|
1457
|
+
fsyncSemanticDirectory(paths.directoryPath, storeFs);
|
|
1458
|
+
storeFs.unlinkSync(finalPath);
|
|
1459
|
+
fsyncSemanticDirectory(path.dirname(finalPath), storeFs);
|
|
1460
|
+
}
|
|
1461
|
+
catch (error) {
|
|
1462
|
+
emitSemanticStoreError("unknown", keyHash, "semantic_quarantine_failed", error);
|
|
1463
|
+
throw semanticStoreError("semantic_quarantine_failed", error);
|
|
1464
|
+
}
|
|
1465
|
+
emitSemanticStoreError("unknown", keyHash, "semantic_record_quarantined", reason);
|
|
1466
|
+
}
|
|
1467
|
+
function semanticQuarantinePaths(finalPath, recordKind, deps) {
|
|
1468
|
+
const semanticRoot = path.dirname(path.dirname(finalPath));
|
|
1469
|
+
const directoryPath = path.join(semanticRoot, "quarantine", recordKind);
|
|
1470
|
+
const observedAtUnixMs = semanticNow(deps).getTime();
|
|
1471
|
+
const uuid = semanticRandomUuid(deps);
|
|
1472
|
+
return {
|
|
1473
|
+
directoryPath,
|
|
1474
|
+
quarantinePath: path.join(directoryPath, `${path.basename(finalPath)}.${observedAtUnixMs}.${uuid}.json`),
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
function hasSemanticQuarantine(quarantineRoot, recordKind, originalBase, deps) {
|
|
1478
|
+
const storeFs = semanticFs(deps);
|
|
1479
|
+
const directoryPath = path.join(quarantineRoot, recordKind);
|
|
1480
|
+
if (!storeFs.existsSync(directoryPath))
|
|
1481
|
+
return false;
|
|
1482
|
+
return storeFs.readdirSync(directoryPath).some((name) => name.startsWith(`${originalBase}.`));
|
|
1483
|
+
}
|
|
1484
|
+
function isBlueBubblesSemanticCapture(value, expectedKeyHash) {
|
|
1485
|
+
if (!isRecord(value) || !hasExactKeys(value, CAPTURE_KEYS))
|
|
1486
|
+
return false;
|
|
1487
|
+
if (value.schemaVersion !== 1
|
|
1488
|
+
|| typeof value.canonicalKey !== "string"
|
|
1489
|
+
|| value.keyHash !== expectedKeyHash
|
|
1490
|
+
|| sha256Utf8(value.canonicalKey) !== value.keyHash
|
|
1491
|
+
|| normalizeProviderNamespace(value.providerNamespace) !== value.providerNamespace
|
|
1492
|
+
|| exactIsoMilliseconds(value.capturedAt) === null
|
|
1493
|
+
|| !isRecord(value.event)
|
|
1494
|
+
|| !hasExactKeys(value.event, CAPTURE_EVENT_KEYS))
|
|
1495
|
+
return false;
|
|
1496
|
+
const event = value.event;
|
|
1497
|
+
if (event.provider !== "bluebubbles"
|
|
1498
|
+
|| typeof event.kind !== "string"
|
|
1499
|
+
|| !SEMANTIC_EVENT_KINDS.has(event.kind)
|
|
1500
|
+
|| !isNullableString(event.eventGuid)
|
|
1501
|
+
|| typeof event.fromMe !== "boolean"
|
|
1502
|
+
|| !isObservedIngressIdentity(event.actor)
|
|
1503
|
+
|| !Array.isArray(event.participants)
|
|
1504
|
+
|| !event.participants.every(isObservedIngressIdentity)
|
|
1505
|
+
|| !participantsAreSorted(event.participants)
|
|
1506
|
+
|| typeof event.sourceEventType !== "string"
|
|
1507
|
+
|| !isNullableString(event.sessionKey)
|
|
1508
|
+
|| !isNullableString(event.chatGuid)
|
|
1509
|
+
|| !isNullableString(event.chatIdentifier)
|
|
1510
|
+
|| !isNullableString(event.text)
|
|
1511
|
+
|| !isNullableString(event.textSha256)
|
|
1512
|
+
|| !isNullableString(event.targetGuid)
|
|
1513
|
+
|| !isIngressTargetAuthorship(event.targetAuthorship)
|
|
1514
|
+
|| !isIngressCanonicalAction(event.canonicalAction)
|
|
1515
|
+
|| !isIngressCanonicalValue(event.canonicalValue)
|
|
1516
|
+
|| !isNullableString(event.rawTransportValue)
|
|
1517
|
+
|| !(event.effectiveAt === null || exactIsoMilliseconds(event.effectiveAt) !== null)
|
|
1518
|
+
|| !isNullableString(event.revision)
|
|
1519
|
+
|| !isNullableString(event.contentSha256))
|
|
1520
|
+
return false;
|
|
1521
|
+
if (event.text === null) {
|
|
1522
|
+
if (event.textSha256 !== null)
|
|
1523
|
+
return false;
|
|
1524
|
+
}
|
|
1525
|
+
else if (event.textSha256 !== sha256Utf8(event.text)) {
|
|
1526
|
+
return false;
|
|
1527
|
+
}
|
|
1528
|
+
return captureIdentityMatchesEvent(value);
|
|
1529
|
+
}
|
|
1530
|
+
function isBlueBubblesSemanticObservationOrderRecord(value, expectedKeyHash, expectedCaptureHash) {
|
|
1531
|
+
return isRecord(value)
|
|
1532
|
+
&& hasExactKeys(value, OBSERVATION_ORDER_KEYS)
|
|
1533
|
+
&& value.schemaVersion === 1
|
|
1534
|
+
&& value.keyHash === expectedKeyHash
|
|
1535
|
+
&& value.captureHash === expectedCaptureHash
|
|
1536
|
+
&& exactIsoMilliseconds(value.observedAt) !== null
|
|
1537
|
+
&& isBlueBubblesObservationEpoch(value.observationEpoch)
|
|
1538
|
+
&& typeof value.observationOrdinal === "number"
|
|
1539
|
+
&& Number.isSafeInteger(value.observationOrdinal)
|
|
1540
|
+
&& value.observationOrdinal > 0;
|
|
1541
|
+
}
|
|
1542
|
+
function isBlueBubblesObservationEpoch(value) {
|
|
1543
|
+
if (typeof value !== "string")
|
|
1544
|
+
return false;
|
|
1545
|
+
const parts = value.split("/");
|
|
1546
|
+
return parts.length === 2
|
|
1547
|
+
&& exactIsoMilliseconds(parts[0]) !== null
|
|
1548
|
+
&& UUID_V4_PATTERN.test(parts[1]);
|
|
1549
|
+
}
|
|
1550
|
+
function captureIdentityMatchesEvent(value) {
|
|
1551
|
+
const event = value.event;
|
|
1552
|
+
const coordinateGeneration = event.kind === "reaction"
|
|
1553
|
+
&& event.revision === null
|
|
1554
|
+
&& event.effectiveAt === null
|
|
1555
|
+
? reactionGenerationFromCanonicalKey(value.canonicalKey)
|
|
1556
|
+
: undefined;
|
|
1557
|
+
if (coordinateGeneration === null)
|
|
1558
|
+
return false;
|
|
1559
|
+
const identity = buildBlueBubblesSemanticIdentity({
|
|
1560
|
+
providerNamespace: value.providerNamespace,
|
|
1561
|
+
kind: event.kind,
|
|
1562
|
+
eventGuid: event.eventGuid,
|
|
1563
|
+
targetGuid: event.targetGuid,
|
|
1564
|
+
actorExternalId: event.actor.externalId,
|
|
1565
|
+
canonicalValue: event.canonicalValue ?? undefined,
|
|
1566
|
+
canonicalAction: event.canonicalAction ?? undefined,
|
|
1567
|
+
revision: event.revision ?? undefined,
|
|
1568
|
+
effectiveTimestamp: event.effectiveAt === null ? undefined : Date.parse(event.effectiveAt),
|
|
1569
|
+
text: event.text ?? undefined,
|
|
1570
|
+
coordinateGeneration,
|
|
1571
|
+
});
|
|
1572
|
+
return identity !== null
|
|
1573
|
+
&& identity.canonicalKey === value.canonicalKey
|
|
1574
|
+
&& identity.keyHash === value.keyHash;
|
|
1575
|
+
}
|
|
1576
|
+
function reactionGenerationFromCanonicalKey(canonicalKey) {
|
|
1577
|
+
let tuple;
|
|
1578
|
+
try {
|
|
1579
|
+
tuple = JSON.parse(canonicalKey);
|
|
1580
|
+
}
|
|
1581
|
+
catch {
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1584
|
+
if (!Array.isArray(tuple) || tuple.length !== 9 || typeof tuple[8] !== "string")
|
|
1585
|
+
return null;
|
|
1586
|
+
const match = /^generation:(0|[1-9]\d*)$/.exec(tuple[8]);
|
|
1587
|
+
if (!match)
|
|
1588
|
+
return null;
|
|
1589
|
+
const generation = Number(match[1]);
|
|
1590
|
+
return Number.isInteger(generation) && generation >= 0 ? generation : null;
|
|
1591
|
+
}
|
|
1592
|
+
function isBlueBubblesSemanticHandledRecord(value, expectedKeyHash) {
|
|
1593
|
+
return isRecord(value)
|
|
1594
|
+
&& hasExactKeys(value, HANDLED_KEYS)
|
|
1595
|
+
&& value.schemaVersion === 1
|
|
1596
|
+
&& typeof value.canonicalKey === "string"
|
|
1597
|
+
&& value.keyHash === expectedKeyHash
|
|
1598
|
+
&& sha256Utf8(value.canonicalKey) === value.keyHash
|
|
1599
|
+
&& exactIsoMilliseconds(value.handledAt) !== null
|
|
1600
|
+
&& typeof value.outcome === "string"
|
|
1601
|
+
&& SEMANTIC_HANDLED_OUTCOMES.has(value.outcome)
|
|
1602
|
+
&& (value.detailCode === null || typeof value.detailCode === "string");
|
|
1603
|
+
}
|
|
1604
|
+
function isBlueBubblesSemanticClaimRecord(value, expected) {
|
|
1605
|
+
if (!isRecord(value) || !hasExactKeys(value, CLAIM_KEYS) || !isRecord(value.owner))
|
|
1606
|
+
return false;
|
|
1607
|
+
return hasExactKeys(value.owner, CLAIM_OWNER_KEYS)
|
|
1608
|
+
&& value.schemaVersion === 1
|
|
1609
|
+
&& value.canonicalKey === expected.canonicalKey
|
|
1610
|
+
&& value.keyHash === expected.keyHash
|
|
1611
|
+
&& sha256Utf8(value.canonicalKey) === value.keyHash
|
|
1612
|
+
&& value.owner.operationId === expected.operationId
|
|
1613
|
+
&& typeof value.owner.pid === "number"
|
|
1614
|
+
&& Number.isInteger(value.owner.pid)
|
|
1615
|
+
&& value.owner.pid > 0
|
|
1616
|
+
&& typeof value.owner.bootIdentity === "string"
|
|
1617
|
+
&& value.owner.bootIdentity.length > 0
|
|
1618
|
+
&& typeof value.owner.processStartedAt === "string"
|
|
1619
|
+
&& value.owner.processStartedAt.length > 0
|
|
1620
|
+
&& exactIsoMilliseconds(value.owner.acquiredAt) !== null;
|
|
1621
|
+
}
|
|
1622
|
+
function isBlueBubblesReactionCoordinateRecord(value, coordinateKey, coordinateHash) {
|
|
1623
|
+
return isRecord(value)
|
|
1624
|
+
&& hasExactKeys(value, COORDINATE_KEYS)
|
|
1625
|
+
&& value.schemaVersion === 1
|
|
1626
|
+
&& value.coordinateKey === coordinateKey
|
|
1627
|
+
&& value.coordinateHash === coordinateHash
|
|
1628
|
+
&& sha256Utf8(coordinateKey) === coordinateHash
|
|
1629
|
+
&& typeof value.generation === "number"
|
|
1630
|
+
&& Number.isInteger(value.generation)
|
|
1631
|
+
&& value.generation >= 0
|
|
1632
|
+
&& (value.lastAction === "add" || value.lastAction === "remove")
|
|
1633
|
+
&& exactIsoMilliseconds(value.updatedAt) !== null;
|
|
1634
|
+
}
|
|
1635
|
+
function isObservedIngressIdentity(value) {
|
|
1636
|
+
return isRecord(value)
|
|
1637
|
+
&& hasExactKeys(value, OBSERVED_IDENTITY_KEYS)
|
|
1638
|
+
&& value.provider === "imessage-handle"
|
|
1639
|
+
&& typeof value.externalId === "string"
|
|
1640
|
+
&& value.externalId.length > 0
|
|
1641
|
+
&& normalizeIngressIdentifier(value.externalId) === value.externalId
|
|
1642
|
+
&& (value.displayName === null || typeof value.displayName === "string");
|
|
1643
|
+
}
|
|
1644
|
+
function participantsAreSorted(participants) {
|
|
1645
|
+
return participants.every((participant, index) => (index === 0 || participants[index - 1].externalId.localeCompare(participant.externalId) <= 0));
|
|
1646
|
+
}
|
|
1647
|
+
function isIngressTargetAuthorship(value) {
|
|
1648
|
+
return value === null || value === "agent" || value === "non_agent_unknown";
|
|
1649
|
+
}
|
|
1650
|
+
function isIngressCanonicalAction(value) {
|
|
1651
|
+
return value === null || value === "add" || value === "remove";
|
|
1652
|
+
}
|
|
1653
|
+
function isIngressCanonicalValue(value) {
|
|
1654
|
+
return value === null || (typeof value === "string"
|
|
1655
|
+
&& CANONICAL_VALUES.has(value));
|
|
1656
|
+
}
|
|
1657
|
+
function isNullableString(value) {
|
|
1658
|
+
return value === null || typeof value === "string";
|
|
1659
|
+
}
|
|
1660
|
+
function hasExactKeys(value, keys) {
|
|
1661
|
+
const actual = Object.keys(value);
|
|
1662
|
+
return actual.length === keys.length && actual.every((key, index) => key === keys[index]);
|
|
1663
|
+
}
|
|
1664
|
+
function semanticRecordPath(directoryPath, keyHash) {
|
|
1665
|
+
return path.join(directoryPath, `${validatedKeyHash(keyHash)}.json`);
|
|
1666
|
+
}
|
|
1667
|
+
function validatedKeyHash(value) {
|
|
1668
|
+
if (!SEMANTIC_KEY_HASH_PATTERN.test(value))
|
|
1669
|
+
throw semanticStoreError("semantic_key_hash_invalid");
|
|
1670
|
+
return value;
|
|
1671
|
+
}
|
|
1672
|
+
function semanticTempPath(finalPath, deps) {
|
|
1673
|
+
return path.join(path.dirname(finalPath), `.${path.basename(finalPath)}.${semanticPid(deps)}.${semanticRandomUuid(deps)}.tmp`);
|
|
1674
|
+
}
|
|
1675
|
+
function semanticFs(deps) {
|
|
1676
|
+
return deps.fs ?? fs;
|
|
1677
|
+
}
|
|
1678
|
+
function semanticNow(deps) {
|
|
1679
|
+
return (deps.now ?? (() => new Date()))();
|
|
1680
|
+
}
|
|
1681
|
+
function semanticRandomUuid(deps) {
|
|
1682
|
+
const uuid = (deps.randomUUID ?? node_crypto_1.randomUUID)();
|
|
1683
|
+
if (!UUID_V4_PATTERN.test(uuid))
|
|
1684
|
+
throw semanticStoreError("semantic_uuid_invalid");
|
|
1685
|
+
return uuid;
|
|
1686
|
+
}
|
|
1687
|
+
function semanticPid(deps) {
|
|
1688
|
+
const pid = (deps.pid ?? (() => process.pid))();
|
|
1689
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
1690
|
+
throw semanticStoreError("semantic_pid_invalid");
|
|
1691
|
+
return pid;
|
|
1692
|
+
}
|
|
1693
|
+
function semanticBootIdentity(deps) {
|
|
1694
|
+
const identity = deps.bootIdentity ? deps.bootIdentity() : defaultBootIdentity(deps);
|
|
1695
|
+
return requiredProbeIdentity(identity);
|
|
1696
|
+
}
|
|
1697
|
+
function semanticProcessStartedAt(pid, deps) {
|
|
1698
|
+
return deps.processStartedAt
|
|
1699
|
+
? deps.processStartedAt(pid)
|
|
1700
|
+
: defaultProcessStartedAt(pid, deps);
|
|
1701
|
+
}
|
|
1702
|
+
function semanticIsProcessAlive(pid, deps) {
|
|
1703
|
+
return deps.isProcessAlive ? deps.isProcessAlive(pid) : defaultIsProcessAlive(pid, deps);
|
|
1704
|
+
}
|
|
1705
|
+
async function semanticSleep(milliseconds, deps) {
|
|
1706
|
+
if (deps.sleep) {
|
|
1707
|
+
await deps.sleep(milliseconds);
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
await new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
1711
|
+
}
|
|
1712
|
+
function semanticSleepSync(milliseconds, deps) {
|
|
1713
|
+
if (deps.sleepSync) {
|
|
1714
|
+
deps.sleepSync(milliseconds);
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
const waitCell = new Int32Array(new SharedArrayBuffer(4));
|
|
1718
|
+
Atomics.wait(waitCell, 0, 0, milliseconds);
|
|
1719
|
+
}
|
|
1720
|
+
function requiredProbeIdentity(value) {
|
|
1721
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
1722
|
+
throw semanticStoreError("semantic_owner_liveness_failed");
|
|
1723
|
+
}
|
|
1724
|
+
return value;
|
|
1725
|
+
}
|
|
1726
|
+
function defaultBootIdentity(deps) {
|
|
1727
|
+
const platform = deps.platform ?? process.platform;
|
|
1728
|
+
const storeFs = semanticFs(deps);
|
|
1729
|
+
const run = deps.execFileSync ?? node_child_process_1.execFileSync;
|
|
1730
|
+
if (platform === "linux") {
|
|
1731
|
+
const bootId = storeFs.readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
1732
|
+
return requiredProbeIdentity(`linux:${bootId}`);
|
|
1733
|
+
}
|
|
1734
|
+
if (platform === "darwin" || platform === "freebsd") {
|
|
1735
|
+
const output = run("/usr/sbin/sysctl", ["-n", "kern.boottime"], {
|
|
1736
|
+
encoding: "utf8",
|
|
1737
|
+
}).trim();
|
|
1738
|
+
return requiredProbeIdentity(`${platform}:${output}`);
|
|
1739
|
+
}
|
|
1740
|
+
if (platform === "win32") {
|
|
1741
|
+
const output = run("powershell.exe", [
|
|
1742
|
+
"-NoProfile",
|
|
1743
|
+
"-Command",
|
|
1744
|
+
"(Get-CimInstance Win32_OperatingSystem).LastBootUpTime.ToUniversalTime().Ticks",
|
|
1745
|
+
], { encoding: "utf8" }).trim();
|
|
1746
|
+
return requiredProbeIdentity(`win32:${output}`);
|
|
1747
|
+
}
|
|
1748
|
+
const uptime = deps.uptime ?? os.uptime;
|
|
1749
|
+
const bootEpochSeconds = Math.round((semanticNow(deps).getTime() - (uptime() * 1_000)) / 1_000);
|
|
1750
|
+
return requiredProbeIdentity(`${platform}:${bootEpochSeconds}`);
|
|
1751
|
+
}
|
|
1752
|
+
function defaultProcessStartedAt(pid, deps) {
|
|
1753
|
+
const platform = deps.platform ?? process.platform;
|
|
1754
|
+
const storeFs = semanticFs(deps);
|
|
1755
|
+
const run = deps.execFileSync ?? node_child_process_1.execFileSync;
|
|
1756
|
+
if (platform === "linux") {
|
|
1757
|
+
try {
|
|
1758
|
+
const stat = storeFs.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
1759
|
+
const closeParen = stat.lastIndexOf(")");
|
|
1760
|
+
if (closeParen < 0)
|
|
1761
|
+
return null;
|
|
1762
|
+
const fields = stat.slice(closeParen + 2).trim().split(/\s+/);
|
|
1763
|
+
return fields[19] ? `linux:${fields[19]}` : null;
|
|
1764
|
+
}
|
|
1765
|
+
catch (error) {
|
|
1766
|
+
if (isNodeError(error, "ENOENT") || isNodeError(error, "ESRCH"))
|
|
1767
|
+
return null;
|
|
1768
|
+
throw error;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
if (platform === "win32") {
|
|
1772
|
+
try {
|
|
1773
|
+
const output = run("powershell.exe", ["-NoProfile", "-Command", `(Get-Process -Id ${pid}).StartTime.ToUniversalTime().Ticks`], { encoding: "utf8" }).trim();
|
|
1774
|
+
return output ? `win32:${output}` : null;
|
|
1775
|
+
}
|
|
1776
|
+
catch {
|
|
1777
|
+
return null;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
try {
|
|
1781
|
+
const output = run("/bin/ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
1782
|
+
encoding: "utf8",
|
|
1783
|
+
}).trim();
|
|
1784
|
+
return output ? `${platform}:${output}` : null;
|
|
1785
|
+
}
|
|
1786
|
+
catch {
|
|
1787
|
+
return null;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
function defaultIsProcessAlive(pid, deps) {
|
|
1791
|
+
const kill = deps.kill ?? process.kill;
|
|
1792
|
+
try {
|
|
1793
|
+
kill(pid, 0);
|
|
1794
|
+
return true;
|
|
1795
|
+
}
|
|
1796
|
+
catch (error) {
|
|
1797
|
+
if (isNodeError(error, "ESRCH"))
|
|
1798
|
+
return false;
|
|
1799
|
+
if (isNodeError(error, "EPERM"))
|
|
1800
|
+
return true;
|
|
1801
|
+
throw error;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
function nextOwnerAcquiredAt(ownerPath, deps) {
|
|
1805
|
+
const observed = semanticNow(deps).getTime();
|
|
1806
|
+
const previous = lastOwnerAcquisitionMs.get(ownerPath);
|
|
1807
|
+
const next = previous === undefined ? observed : Math.max(observed, previous + 1);
|
|
1808
|
+
lastOwnerAcquisitionMs.set(ownerPath, next);
|
|
1809
|
+
return new Date(next).toISOString();
|
|
1810
|
+
}
|
|
1811
|
+
function fsyncSemanticDirectory(directoryPath, storeFs) {
|
|
1812
|
+
const directoryFd = storeFs.openSync(directoryPath, "r");
|
|
1813
|
+
try {
|
|
1814
|
+
storeFs.fsyncSync(directoryFd);
|
|
1815
|
+
}
|
|
1816
|
+
finally {
|
|
1817
|
+
storeFs.closeSync(directoryFd);
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
function semanticStoreError(code, cause) {
|
|
1821
|
+
return cause === undefined ? new Error(code) : new Error(code, { cause });
|
|
1822
|
+
}
|
|
1823
|
+
function emitCaptureError(agentName, keyHash, error) {
|
|
1824
|
+
(0, runtime_1.emitNervesEvent)({
|
|
1825
|
+
level: "error",
|
|
1826
|
+
component: "senses",
|
|
1827
|
+
event: "bluebubbles_semantic_capture_error",
|
|
1828
|
+
message: "failed to publish bluebubbles semantic capture",
|
|
1829
|
+
meta: { agentName, keyHash, reason: errorReason(error) },
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
function emitSemanticStoreError(agentName, keyHash, code, error) {
|
|
1833
|
+
(0, runtime_1.emitNervesEvent)({
|
|
1834
|
+
level: "error",
|
|
1835
|
+
component: "senses",
|
|
1836
|
+
event: "bluebubbles_semantic_store_error",
|
|
1837
|
+
message: "bluebubbles semantic store operation failed",
|
|
1838
|
+
meta: { agentName, keyHash, code, reason: errorReason(error) },
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1841
|
+
function errorReason(error) {
|
|
1842
|
+
return error instanceof Error ? error.message : String(error);
|
|
1843
|
+
}
|
|
1844
|
+
function createCutover(deps) {
|
|
1845
|
+
const providerNamespace = normalizeProviderNamespace((deps.randomUUID ?? node_crypto_1.randomUUID)());
|
|
1846
|
+
if (!providerNamespace)
|
|
1847
|
+
throw new Error("semantic_provider_namespace_invalid");
|
|
1848
|
+
const effectiveAt = (deps.now ?? (() => new Date()))().toISOString();
|
|
1849
|
+
if (!exactIsoMilliseconds(effectiveAt))
|
|
1850
|
+
throw new Error("semantic_cutover_timestamp_invalid");
|
|
1851
|
+
return { schemaVersion: 1, providerNamespace, effectiveAt };
|
|
1852
|
+
}
|
|
1853
|
+
function isBlueBubblesSemanticCutover(value) {
|
|
1854
|
+
if (!isRecord(value))
|
|
1855
|
+
return false;
|
|
1856
|
+
if (JSON.stringify(Object.keys(value)) !== JSON.stringify(CUTOVER_KEYS))
|
|
1857
|
+
return false;
|
|
1858
|
+
return value.schemaVersion === 1
|
|
1859
|
+
&& normalizeProviderNamespace(value.providerNamespace) === value.providerNamespace
|
|
1860
|
+
&& exactIsoMilliseconds(value.effectiveAt) !== null;
|
|
1861
|
+
}
|
|
1862
|
+
function identityFromKey(tuple, handleable, discriminator = null, coordinateKey = null, coordinateHash = null) {
|
|
1863
|
+
const canonicalKey = JSON.stringify(tuple);
|
|
1864
|
+
return {
|
|
1865
|
+
canonicalKey,
|
|
1866
|
+
keyHash: sha256Utf8(canonicalKey),
|
|
1867
|
+
handleable,
|
|
1868
|
+
discriminator,
|
|
1869
|
+
coordinateKey,
|
|
1870
|
+
coordinateHash,
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
function mutationDiscriminator(input) {
|
|
1874
|
+
const revision = normalizedRevision(input.revision);
|
|
1875
|
+
if (revision)
|
|
1876
|
+
return `revision:${revision}`;
|
|
1877
|
+
return effectiveTimestampDiscriminator(input.effectiveTimestamp);
|
|
1878
|
+
}
|
|
1879
|
+
function effectiveTimestampDiscriminator(value) {
|
|
1880
|
+
const effectiveAt = finiteTimestampIso(value);
|
|
1881
|
+
return effectiveAt ? `effectiveAt:${effectiveAt}` : null;
|
|
1882
|
+
}
|
|
1883
|
+
function generationDiscriminator(value) {
|
|
1884
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0
|
|
1885
|
+
? `generation:${value}`
|
|
1886
|
+
: null;
|
|
1887
|
+
}
|
|
1888
|
+
function finiteTimestampIso(value) {
|
|
1889
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
1890
|
+
return null;
|
|
1891
|
+
const date = new Date(value);
|
|
1892
|
+
return Number.isFinite(date.getTime()) ? date.toISOString() : null;
|
|
1893
|
+
}
|
|
1894
|
+
function normalizedRevision(value) {
|
|
1895
|
+
if (typeof value !== "string")
|
|
1896
|
+
return null;
|
|
1897
|
+
return value.trim() || null;
|
|
1898
|
+
}
|
|
1899
|
+
function requiredIdentifier(value) {
|
|
1900
|
+
if (value === null || value === undefined)
|
|
1901
|
+
return null;
|
|
1902
|
+
const normalized = normalizeIngressIdentifier(value);
|
|
1903
|
+
return normalized || null;
|
|
1904
|
+
}
|
|
1905
|
+
function providerGuid(value) {
|
|
1906
|
+
if (typeof value !== "string")
|
|
1907
|
+
return requiredIdentifier(value);
|
|
1908
|
+
return value.trim() || null;
|
|
1909
|
+
}
|
|
1910
|
+
/** Captures from older builds stored lower-case GUIDs; compare them case-insensitively. */
|
|
1911
|
+
function caseFoldedGuid(value) {
|
|
1912
|
+
return value === null ? null : value.toLowerCase();
|
|
1913
|
+
}
|
|
1914
|
+
function normalizeProviderNamespace(value) {
|
|
1915
|
+
const normalized = requiredIdentifier(value);
|
|
1916
|
+
return normalized && UUID_V4_PATTERN.test(normalized) ? normalized : null;
|
|
1917
|
+
}
|
|
1918
|
+
function normalizeCanonicalValue(value) {
|
|
1919
|
+
return typeof value === "string"
|
|
1920
|
+
&& CANONICAL_VALUES.has(value)
|
|
1921
|
+
? value
|
|
1922
|
+
: null;
|
|
1923
|
+
}
|
|
1924
|
+
function normalizeCanonicalAction(value) {
|
|
1925
|
+
return typeof value === "string"
|
|
1926
|
+
&& CANONICAL_ACTIONS.has(value)
|
|
1927
|
+
? value
|
|
1928
|
+
: null;
|
|
1929
|
+
}
|
|
1930
|
+
function normalizeDisplayName(value) {
|
|
1931
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
1932
|
+
}
|
|
1933
|
+
function nullableString(value) {
|
|
1934
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
1935
|
+
}
|
|
1936
|
+
function exactIsoMilliseconds(value) {
|
|
1937
|
+
if (typeof value !== "string" || !ISO_MILLISECONDS_PATTERN.test(value))
|
|
1938
|
+
return null;
|
|
1939
|
+
const milliseconds = Date.parse(value);
|
|
1940
|
+
return Number.isFinite(milliseconds) && new Date(milliseconds).toISOString() === value ? value : null;
|
|
1941
|
+
}
|
|
1942
|
+
function sha256Utf8(input) {
|
|
1943
|
+
return (0, node_crypto_1.createHash)("sha256").update(input, "utf8").digest("hex");
|
|
1944
|
+
}
|
|
1945
|
+
function fsyncDirectory(directoryPath) {
|
|
1946
|
+
const directoryFd = fs.openSync(directoryPath, "r");
|
|
1947
|
+
try {
|
|
1948
|
+
fs.fsyncSync(directoryFd);
|
|
1949
|
+
}
|
|
1950
|
+
finally {
|
|
1951
|
+
fs.closeSync(directoryFd);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
function isNodeError(error, code) {
|
|
1955
|
+
return error instanceof Error && "code" in error && error.code === code;
|
|
1956
|
+
}
|
|
1957
|
+
function isRecord(value) {
|
|
1958
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1959
|
+
}
|
|
1960
|
+
// Every recovery pass re-reads the same legacy records, so a bundle with
|
|
1961
|
+
// 1,530 of them wrote 1,530 identical warnings every 30 seconds. Report each
|
|
1962
|
+
// distinct record once per process; the record stays audit-only either way.
|
|
1963
|
+
const reportedLegacyRecoveryRecords = new Set();
|
|
1964
|
+
function legacyRecoveryFingerprint(value) {
|
|
1965
|
+
try {
|
|
1966
|
+
const serialized = JSON.stringify(value);
|
|
1967
|
+
return serialized === undefined ? null : sha256Utf8(serialized);
|
|
1968
|
+
}
|
|
1969
|
+
catch {
|
|
1970
|
+
return null;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
function emitLegacyRecoveryBlocked(value) {
|
|
1974
|
+
const fingerprint = legacyRecoveryFingerprint(value);
|
|
1975
|
+
if (fingerprint !== null) {
|
|
1976
|
+
if (reportedLegacyRecoveryRecords.has(fingerprint))
|
|
1977
|
+
return;
|
|
1978
|
+
reportedLegacyRecoveryRecords.add(fingerprint);
|
|
1979
|
+
}
|
|
1980
|
+
(0, runtime_1.emitNervesEvent)({
|
|
1981
|
+
level: "warn",
|
|
1982
|
+
component: "senses",
|
|
1983
|
+
event: "senses.bluebubbles_legacy_recovery_blocked",
|
|
1984
|
+
message: "blocked legacy or actorless bluebubbles recovery record",
|
|
1985
|
+
meta: {
|
|
1986
|
+
schemaVersion: 0,
|
|
1987
|
+
actorPresent: false,
|
|
1988
|
+
recordKind: recoveryRecordKind(value),
|
|
1989
|
+
reason: "legacy_or_actorless",
|
|
1990
|
+
},
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
function emitInvalidSemanticRecoveryRecord(value, actorPresent, reason) {
|
|
1994
|
+
(0, runtime_1.emitNervesEvent)({
|
|
1995
|
+
level: "warn",
|
|
1996
|
+
component: "senses",
|
|
1997
|
+
event: "senses.bluebubbles_semantic_recovery_invalid",
|
|
1998
|
+
message: "blocked invalid v1 bluebubbles recovery record",
|
|
1999
|
+
meta: {
|
|
2000
|
+
schemaVersion: 1,
|
|
2001
|
+
actorPresent,
|
|
2002
|
+
recordKind: recoveryRecordKind(value),
|
|
2003
|
+
reason,
|
|
2004
|
+
},
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
function recoveryRecordKind(value) {
|
|
2008
|
+
const record = isRecord(value) ? value : null;
|
|
2009
|
+
return typeof record?.mutationType === "string"
|
|
2010
|
+
? record.mutationType
|
|
2011
|
+
: isRecord(record?.event) && typeof record.event.kind === "string"
|
|
2012
|
+
? record.event.kind
|
|
2013
|
+
: "inbound";
|
|
2014
|
+
}
|