@murphai/murph 0.2.7 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/config.schema.json +148 -35
- package/dist/cli-entry.d.ts.map +1 -1
- package/dist/cli-entry.js +44 -9
- package/dist/cli-entry.js.map +1 -1
- package/dist/commands/automation.d.ts +4 -8
- package/dist/commands/automation.d.ts.map +1 -1
- package/dist/commands/automation.js +2 -2
- package/dist/commands/automation.js.map +1 -1
- package/dist/commands/document.d.ts.map +1 -1
- package/dist/commands/document.js +9 -5
- package/dist/commands/document.js.map +1 -1
- package/dist/commands/experiment.d.ts.map +1 -1
- package/dist/commands/experiment.js +8 -4
- package/dist/commands/experiment.js.map +1 -1
- package/dist/commands/intake.d.ts.map +1 -1
- package/dist/commands/intake.js +8 -4
- package/dist/commands/intake.js.map +1 -1
- package/dist/commands/intervention.d.ts.map +1 -1
- package/dist/commands/intervention.js +11 -7
- package/dist/commands/intervention.js.map +1 -1
- package/dist/commands/meal.d.ts +1 -1
- package/dist/commands/meal.d.ts.map +1 -1
- package/dist/commands/meal.js +60 -6
- package/dist/commands/meal.js.map +1 -1
- package/dist/commands/occurred-at-option.d.ts +7 -0
- package/dist/commands/occurred-at-option.d.ts.map +1 -0
- package/dist/commands/occurred-at-option.js +61 -0
- package/dist/commands/occurred-at-option.js.map +1 -0
- package/dist/commands/route.d.ts.map +1 -1
- package/dist/commands/route.js +6 -6
- package/dist/commands/route.js.map +1 -1
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +2 -1
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/workout.d.ts.map +1 -1
- package/dist/commands/workout.js +27 -17
- package/dist/commands/workout.js.map +1 -1
- package/dist/incur.generated.d.ts +17 -8
- package/dist/incur.generated.d.ts.map +1 -1
- package/dist/review-gpt-runtime.d.ts.map +1 -1
- package/dist/review-gpt-runtime.js +5 -0
- package/dist/review-gpt-runtime.js.map +1 -1
- package/dist/vault-cli-bootstrap.d.ts +1 -1
- package/dist/vault-cli-bootstrap.d.ts.map +1 -1
- package/dist/vault-cli-bootstrap.js +2 -2
- package/dist/vault-cli-bootstrap.js.map +1 -1
- package/dist/vault-cli-command-manifest.d.ts +3 -0
- package/dist/vault-cli-command-manifest.d.ts.map +1 -1
- package/dist/vault-cli-command-manifest.js +4 -0
- package/dist/vault-cli-command-manifest.js.map +1 -1
- package/dist/vault-cli.d.ts +6 -0
- package/dist/vault-cli.d.ts.map +1 -1
- package/dist/vault-cli.js +19 -8
- package/dist/vault-cli.js.map +1 -1
- package/node_modules/@murphai/assistant-cli/dist/assistant/service.d.ts +2 -2
- package/node_modules/@murphai/assistant-engine/dist/assistant/automation/run-loop.js +7 -7
- package/node_modules/@murphai/assistant-engine/dist/assistant/automation/run-loop.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/descriptors.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/descriptors.js +1 -16
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/descriptors.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/helpers.d.ts +2 -12
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/helpers.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/helpers.js +23 -43
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/helpers.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/registry.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/registry.js +3 -2
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/registry.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/types.d.ts +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/channels/types.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/notification-delivery.d.ts +6 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/notification-delivery.d.ts.map +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/notification-delivery.js +21 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/notification-delivery.js.map +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/store.d.ts +0 -2
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/store.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/store.js +0 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron/store.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron.js +67 -43
- package/node_modules/@murphai/assistant-engine/dist/assistant/cron.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/notification-turn.d.ts +25 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/notification-turn.d.ts.map +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/notification-turn.js +201 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/notification-turn.js.map +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox/dispatch-state.d.ts +38 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox/dispatch-state.d.ts.map +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox/dispatch-state.js +215 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox/dispatch-state.js.map +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox/retry-policy.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox/retry-policy.js +77 -41
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox/retry-policy.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox.js +4 -201
- package/node_modules/@murphai/assistant-engine/dist/assistant/outbox.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/provider-config.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/provider-config.js +10 -3
- package/node_modules/@murphai/assistant-engine/dist/assistant/provider-config.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/provider-turn-runner.d.ts +9 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/provider-turn-runner.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/provider-turn-runner.js +60 -25
- package/node_modules/@murphai/assistant-engine/dist/assistant/provider-turn-runner.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/providers/openai-compatible.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/providers/openai-compatible.js +20 -58
- package/node_modules/@murphai/assistant-engine/dist/assistant/providers/openai-compatible.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/redaction.d.ts +4 -8
- package/node_modules/@murphai/assistant-engine/dist/assistant/redaction.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/redaction.js +3 -37
- package/node_modules/@murphai/assistant-engine/dist/assistant/redaction.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/service.d.ts +8 -5
- package/node_modules/@murphai/assistant-engine/dist/assistant/service.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/service.js +5 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/service.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/state-ids.d.ts +0 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/state-ids.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/state-ids.js +3 -8
- package/node_modules/@murphai/assistant-engine/dist/assistant/state-ids.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/state-secrets.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/state-secrets.js +9 -15
- package/node_modules/@murphai/assistant-engine/dist/assistant/state-secrets.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/system-prompt.d.ts +8 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/system-prompt.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/system-prompt.js +46 -11
- package/node_modules/@murphai/assistant-engine/dist/assistant/system-prompt.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/turn-finalizer.d.ts +3 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant/turn-finalizer.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant/turn-finalizer.js +19 -11
- package/node_modules/@murphai/assistant-engine/dist/assistant/turn-finalizer.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/capability-definitions.d.ts +3 -3
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/capability-definitions.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/capability-definitions.js +35 -17
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/capability-definitions.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/catalog-profiles.d.ts +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/catalog-profiles.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/catalog-profiles.js +14 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/catalog-profiles.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/policy-wrappers.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/policy-wrappers.js +1 -0
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools/policy-wrappers.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools.d.ts +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools.js +1 -1
- package/node_modules/@murphai/assistant-engine/dist/assistant-cli-tools.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/inbox-model-contracts.d.ts +1 -4
- package/node_modules/@murphai/assistant-engine/dist/inbox-model-contracts.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/inbox-model-contracts.js +1 -1
- package/node_modules/@murphai/assistant-engine/dist/inbox-model-contracts.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/inbox-model-harness.js +1 -1
- package/node_modules/@murphai/assistant-engine/dist/inbox-model-harness.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/knowledge/service.js +5 -0
- package/node_modules/@murphai/assistant-engine/dist/knowledge/service.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/model-harness.d.ts +4 -0
- package/node_modules/@murphai/assistant-engine/dist/model-harness.d.ts.map +1 -1
- package/node_modules/@murphai/assistant-engine/dist/model-harness.js +46 -25
- package/node_modules/@murphai/assistant-engine/dist/model-harness.js.map +1 -1
- package/node_modules/@murphai/assistant-engine/package.json +2 -2
- package/node_modules/@murphai/assistantd/package.json +1 -1
- package/node_modules/@murphai/core/dist/audited-write.d.ts +33 -0
- package/node_modules/@murphai/core/dist/audited-write.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/audited-write.js +33 -0
- package/node_modules/@murphai/core/dist/audited-write.js.map +1 -0
- package/node_modules/@murphai/core/dist/automation.d.ts +1 -1
- package/node_modules/@murphai/core/dist/automation.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/automation.js +13 -16
- package/node_modules/@murphai/core/dist/automation.js.map +1 -1
- package/node_modules/@murphai/core/dist/bank/foods.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/bank/foods.js +34 -0
- package/node_modules/@murphai/core/dist/bank/foods.js.map +1 -1
- package/node_modules/@murphai/core/dist/bank/providers.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/bank/providers.js +6 -0
- package/node_modules/@murphai/core/dist/bank/providers.js.map +1 -1
- package/node_modules/@murphai/core/dist/bank/recipes.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/bank/recipes.js +5 -0
- package/node_modules/@murphai/core/dist/bank/recipes.js.map +1 -1
- package/node_modules/@murphai/core/dist/bank/types.d.ts +3 -1
- package/node_modules/@murphai/core/dist/bank/types.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/bank/types.js.map +1 -1
- package/node_modules/@murphai/core/dist/canonical-mutations.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/canonical-mutations.js +25 -7
- package/node_modules/@murphai/core/dist/canonical-mutations.js.map +1 -1
- package/node_modules/@murphai/core/dist/constants.d.ts +1 -1
- package/node_modules/@murphai/core/dist/constants.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/domains/events.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/domains/events.js +41 -0
- package/node_modules/@murphai/core/dist/domains/events.js.map +1 -1
- package/node_modules/@murphai/core/dist/domains/experiments.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/domains/experiments.js +43 -16
- package/node_modules/@murphai/core/dist/domains/experiments.js.map +1 -1
- package/node_modules/@murphai/core/dist/domains/journal.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/domains/journal.js +41 -14
- package/node_modules/@murphai/core/dist/domains/journal.js.map +1 -1
- package/node_modules/@murphai/core/dist/domains/vault-summary.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/domains/vault-summary.js +25 -9
- package/node_modules/@murphai/core/dist/domains/vault-summary.js.map +1 -1
- package/node_modules/@murphai/core/dist/markdown-documents.d.ts +7 -13
- package/node_modules/@murphai/core/dist/markdown-documents.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/markdown-documents.js +36 -34
- package/node_modules/@murphai/core/dist/markdown-documents.js.map +1 -1
- package/node_modules/@murphai/core/dist/memory.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/memory.js +31 -4
- package/node_modules/@murphai/core/dist/memory.js.map +1 -1
- package/node_modules/@murphai/core/dist/mutations.d.ts +3 -2
- package/node_modules/@murphai/core/dist/mutations.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/mutations.js +6 -3
- package/node_modules/@murphai/core/dist/mutations.js.map +1 -1
- package/node_modules/@murphai/core/dist/nutrition.d.ts +6 -0
- package/node_modules/@murphai/core/dist/nutrition.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/nutrition.js +69 -0
- package/node_modules/@murphai/core/dist/nutrition.js.map +1 -0
- package/node_modules/@murphai/core/dist/preferences.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/preferences.js +32 -5
- package/node_modules/@murphai/core/dist/preferences.js.map +1 -1
- package/node_modules/@murphai/core/dist/public-mutations.d.ts +2 -0
- package/node_modules/@murphai/core/dist/public-mutations.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/public-mutations.js +44 -7
- package/node_modules/@murphai/core/dist/public-mutations.js.map +1 -1
- package/node_modules/@murphai/core/dist/registry/api.d.ts +6 -1
- package/node_modules/@murphai/core/dist/registry/api.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/registry/api.js +8 -2
- package/node_modules/@murphai/core/dist/registry/api.js.map +1 -1
- package/node_modules/@murphai/core/dist/registry/markdown.d.ts +4 -4
- package/node_modules/@murphai/core/dist/registry/markdown.d.ts.map +1 -1
- package/node_modules/@murphai/core/dist/registry/markdown.js +2 -7
- package/node_modules/@murphai/core/dist/registry/markdown.js.map +1 -1
- package/node_modules/@murphai/core/package.json +1 -1
- package/node_modules/@murphai/device-syncd/README.md +4 -2
- package/node_modules/@murphai/device-syncd/dist/callback-redirect.d.ts +11 -0
- package/node_modules/@murphai/device-syncd/dist/callback-redirect.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/callback-redirect.js +51 -0
- package/node_modules/@murphai/device-syncd/dist/callback-redirect.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/client.d.ts +21 -0
- package/node_modules/@murphai/device-syncd/dist/client.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/client.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js +11 -30
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/http.d.ts +1 -5
- package/node_modules/@murphai/device-syncd/dist/http.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/http.js +10 -26
- package/node_modules/@murphai/device-syncd/dist/http.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/index.d.ts +1 -0
- package/node_modules/@murphai/device-syncd/dist/index.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/index.js +1 -0
- package/node_modules/@murphai/device-syncd/dist/index.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts +2 -1
- package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/public-ingress.js +22 -12
- package/node_modules/@murphai/device-syncd/dist/public-ingress.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/service.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/service.js +1 -1
- package/node_modules/@murphai/device-syncd/dist/service.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/store/oauth-states.d.ts +2 -2
- package/node_modules/@murphai/device-syncd/dist/store/oauth-states.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/store/oauth-states.js +20 -4
- package/node_modules/@murphai/device-syncd/dist/store/oauth-states.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/store/webhook-traces.d.ts +1 -1
- package/node_modules/@murphai/device-syncd/dist/store/webhook-traces.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/store/webhook-traces.js +18 -4
- package/node_modules/@murphai/device-syncd/dist/store/webhook-traces.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/store.d.ts +2 -2
- package/node_modules/@murphai/device-syncd/dist/store.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/store.js +2 -2
- package/node_modules/@murphai/device-syncd/dist/store.js.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/types.d.ts +12 -23
- package/node_modules/@murphai/device-syncd/dist/types.d.ts.map +1 -1
- package/node_modules/@murphai/device-syncd/dist/types.js.map +1 -1
- package/node_modules/@murphai/device-syncd/package.json +4 -0
- package/node_modules/@murphai/gateway-local/package.json +1 -1
- package/node_modules/@murphai/importers/package.json +1 -1
- package/node_modules/@murphai/inbox-services/package.json +1 -1
- package/node_modules/@murphai/inboxd/README.md +2 -1
- package/node_modules/@murphai/inboxd/dist/index.d.ts +1 -1
- package/node_modules/@murphai/inboxd/dist/index.d.ts.map +1 -1
- package/node_modules/@murphai/inboxd/dist/index.js +1 -1
- package/node_modules/@murphai/inboxd/dist/index.js.map +1 -1
- package/node_modules/@murphai/inboxd/dist/indexing/persist.d.ts +2 -26
- package/node_modules/@murphai/inboxd/dist/indexing/persist.d.ts.map +1 -1
- package/node_modules/@murphai/inboxd/dist/indexing/persist.js +257 -241
- package/node_modules/@murphai/inboxd/dist/indexing/persist.js.map +1 -1
- package/node_modules/@murphai/inboxd/dist/kernel/pipeline.js +1 -1
- package/node_modules/@murphai/inboxd/dist/kernel/pipeline.js.map +1 -1
- package/node_modules/@murphai/inboxd/package.json +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant/provider-config.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant/provider-config.js +1 -2
- package/node_modules/@murphai/operator-config/dist/assistant/provider-config.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant/redaction.d.ts +1 -0
- package/node_modules/@murphai/operator-config/dist/assistant/redaction.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant/redaction.js +8 -2
- package/node_modules/@murphai/operator-config/dist/assistant/redaction.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant/target-runtime.d.ts +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant/target-runtime.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant/target-runtime.js +36 -31
- package/node_modules/@murphai/operator-config/dist/assistant/target-runtime.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant-cli-contracts.d.ts +30 -40
- package/node_modules/@murphai/operator-config/dist/assistant-cli-contracts.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/assistant-cli-contracts.js +28 -21
- package/node_modules/@murphai/operator-config/dist/assistant-cli-contracts.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/device-sync-client.d.ts +1 -22
- package/node_modules/@murphai/operator-config/dist/device-sync-client.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/device-sync-client.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/operator-config/cli-vault-defaults.d.ts +1 -0
- package/node_modules/@murphai/operator-config/dist/operator-config/cli-vault-defaults.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/operator-config/cli-vault-defaults.js +17 -11
- package/node_modules/@murphai/operator-config/dist/operator-config/cli-vault-defaults.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/operator-config.d.ts +2 -1
- package/node_modules/@murphai/operator-config/dist/operator-config.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/operator-config.js +12 -1
- package/node_modules/@murphai/operator-config/dist/operator-config.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/setup-cli-contracts.d.ts +9 -0
- package/node_modules/@murphai/operator-config/dist/setup-cli-contracts.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/setup-cli-contracts.js +5 -0
- package/node_modules/@murphai/operator-config/dist/setup-cli-contracts.js.map +1 -1
- package/node_modules/@murphai/operator-config/dist/vault-cli-contracts.d.ts +1 -0
- package/node_modules/@murphai/operator-config/dist/vault-cli-contracts.d.ts.map +1 -1
- package/node_modules/@murphai/operator-config/dist/vault-cli-contracts.js +4 -1
- package/node_modules/@murphai/operator-config/dist/vault-cli-contracts.js.map +1 -1
- package/node_modules/@murphai/operator-config/package.json +7 -2
- package/node_modules/@murphai/query/README.md +2 -0
- package/node_modules/@murphai/query/dist/automation.d.ts +1 -1
- package/node_modules/@murphai/query/dist/automation.d.ts.map +1 -1
- package/node_modules/@murphai/query/dist/automation.js +7 -8
- package/node_modules/@murphai/query/dist/automation.js.map +1 -1
- package/node_modules/@murphai/query/dist/entity-families.d.ts +2 -0
- package/node_modules/@murphai/query/dist/entity-families.d.ts.map +1 -0
- package/node_modules/@murphai/query/dist/entity-families.js +20 -0
- package/node_modules/@murphai/query/dist/entity-families.js.map +1 -0
- package/node_modules/@murphai/query/dist/health/bank-registry-query-metadata.d.ts +1 -3
- package/node_modules/@murphai/query/dist/health/bank-registry-query-metadata.d.ts.map +1 -1
- package/node_modules/@murphai/query/dist/health/bank-registry-query-metadata.js +1 -4
- package/node_modules/@murphai/query/dist/health/bank-registry-query-metadata.js.map +1 -1
- package/node_modules/@murphai/query/dist/health/registries.d.ts +6 -1
- package/node_modules/@murphai/query/dist/health/registries.d.ts.map +1 -1
- package/node_modules/@murphai/query/dist/health/registries.js.map +1 -1
- package/node_modules/@murphai/query/dist/index.d.ts +3 -1
- package/node_modules/@murphai/query/dist/index.d.ts.map +1 -1
- package/node_modules/@murphai/query/dist/index.js +2 -1
- package/node_modules/@murphai/query/dist/index.js.map +1 -1
- package/node_modules/@murphai/query/dist/meal-nutrition.d.ts +31 -0
- package/node_modules/@murphai/query/dist/meal-nutrition.d.ts.map +1 -0
- package/node_modules/@murphai/query/dist/meal-nutrition.js +127 -0
- package/node_modules/@murphai/query/dist/meal-nutrition.js.map +1 -0
- package/node_modules/@murphai/query/dist/model.d.ts +0 -1
- package/node_modules/@murphai/query/dist/model.d.ts.map +1 -1
- package/node_modules/@murphai/query/dist/model.js +1 -19
- package/node_modules/@murphai/query/dist/model.js.map +1 -1
- package/node_modules/@murphai/query/package.json +6 -1
- package/node_modules/@murphai/runtime-state/README.md +2 -1
- package/node_modules/@murphai/runtime-state/dist/assistant-ids.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-ids.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-ids.js +14 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-ids.js.map +1 -0
- package/node_modules/@murphai/runtime-state/package.json +4 -0
- package/node_modules/@murphai/setup-cli/dist/setup-cli.d.ts.map +1 -1
- package/node_modules/@murphai/setup-cli/dist/setup-cli.js +60 -2
- package/node_modules/@murphai/setup-cli/dist/setup-cli.js.map +1 -1
- package/node_modules/@murphai/setup-cli/dist/setup-services/operator-defaults.d.ts +27 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services/operator-defaults.d.ts.map +1 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services/operator-defaults.js +92 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services/operator-defaults.js.map +1 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services/tool-provisioning.d.ts +29 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services/tool-provisioning.d.ts.map +1 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services/tool-provisioning.js +306 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services/tool-provisioning.js.map +1 -0
- package/node_modules/@murphai/setup-cli/dist/setup-services.d.ts.map +1 -1
- package/node_modules/@murphai/setup-cli/dist/setup-services.js +21 -406
- package/node_modules/@murphai/setup-cli/dist/setup-services.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/query-runtime.d.ts +10 -3
- package/node_modules/@murphai/vault-usecases/dist/query-runtime.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/query-runtime.js +1 -2
- package/node_modules/@murphai/vault-usecases/dist/query-runtime.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/runtime.d.ts +1 -1
- package/node_modules/@murphai/vault-usecases/dist/runtime.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/runtime.js +1 -1
- package/node_modules/@murphai/vault-usecases/dist/runtime.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/food.d.ts +49 -12
- package/node_modules/@murphai/vault-usecases/dist/usecases/food.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/food.js +20 -4
- package/node_modules/@murphai/vault-usecases/dist/usecases/food.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/integrated-services.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/integrated-services.js +21 -2
- package/node_modules/@murphai/vault-usecases/dist/usecases/integrated-services.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/intervention.d.ts +2 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/intervention.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/intervention.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/types.d.ts +29 -2
- package/node_modules/@murphai/vault-usecases/dist/usecases/types.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout-import.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout-import.js +6 -0
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout-import.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout-measurement.d.ts +2 -2
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout-measurement.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout-measurement.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout.d.ts +2 -2
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout.d.ts.map +1 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout.js +73 -1
- package/node_modules/@murphai/vault-usecases/dist/usecases/workout.js.map +1 -1
- package/node_modules/@murphai/vault-usecases/package.json +1 -1
- package/package.json +4 -4
- package/dist/runner-vault-cli-bin.d.ts +0 -3
- package/dist/runner-vault-cli-bin.d.ts.map +0 -1
- package/dist/runner-vault-cli-bin.js +0 -8
- package/dist/runner-vault-cli-bin.js.map +0 -1
- package/dist/runner-vault-cli-command-manifest.d.ts +0 -9
- package/dist/runner-vault-cli-command-manifest.d.ts.map +0 -1
- package/dist/runner-vault-cli-command-manifest.js +0 -71
- package/dist/runner-vault-cli-command-manifest.js.map +0 -1
- package/dist/runner-vault-cli.d.ts +0 -10
- package/dist/runner-vault-cli.d.ts.map +0 -1
- package/dist/runner-vault-cli.js +0 -22
- package/dist/runner-vault-cli.js.map +0 -1
- package/node_modules/@murphai/core/dist/storage-spine.d.ts +0 -3
- package/node_modules/@murphai/core/dist/storage-spine.d.ts.map +0 -1
- package/node_modules/@murphai/core/dist/storage-spine.js +0 -3
- package/node_modules/@murphai/core/dist/storage-spine.js.map +0 -1
- package/node_modules/@murphai/operator-config/dist/assistant/state-ids.d.ts +0 -2
- package/node_modules/@murphai/operator-config/dist/assistant/state-ids.d.ts.map +0 -1
- package/node_modules/@murphai/operator-config/dist/assistant/state-ids.js +0 -7
- package/node_modules/@murphai/operator-config/dist/assistant/state-ids.js.map +0 -1
- package/node_modules/@murphai/query/dist/health/health-registry-query-metadata.d.ts +0 -3
- package/node_modules/@murphai/query/dist/health/health-registry-query-metadata.d.ts.map +0 -1
- package/node_modules/@murphai/query/dist/health/health-registry-query-metadata.js +0 -2
- package/node_modules/@murphai/query/dist/health/health-registry-query-metadata.js.map +0 -1
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
import {
|
|
3
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { assertContract, inboxCaptureRecordSchema, } from "@murphai/contracts";
|
|
6
|
-
import { acquireCanonicalWriteLock, applyCanonicalWriteBatch, loadVault, readJsonlRecords, VAULT_LAYOUT, walkVaultFiles, withCanonicalWriteLockScope, } from "@murphai/core";
|
|
7
|
-
import { buildAttachmentId, createDeterministicInboxCaptureId, createInboxCaptureIdentityKey,
|
|
8
|
-
import { INBOX_CAPTURE_LEDGER_DIRECTORY,
|
|
9
|
-
const STORED_CAPTURE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u;
|
|
10
|
-
const QUARANTINED_INVALID_CAPTURE_ID_SUFFIX = "quarantined-invalid-capture-id";
|
|
11
|
-
class UnsafeStoredCaptureIdError extends Error {
|
|
12
|
-
captureId;
|
|
13
|
-
canonicalCaptureId;
|
|
14
|
-
absolutePath;
|
|
15
|
-
constructor(input) {
|
|
16
|
-
super(`Stored inbox envelope at ${input.absolutePath} contains unsafe captureId "${input.captureId}".`);
|
|
17
|
-
this.name = "UnsafeStoredCaptureIdError";
|
|
18
|
-
this.captureId = input.captureId;
|
|
19
|
-
this.canonicalCaptureId = input.canonicalCaptureId;
|
|
20
|
-
this.absolutePath = input.absolutePath;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
6
|
+
import { acquireCanonicalWriteLock, applyCanonicalWriteBatch, loadVault, listWriteOperationMetadataPaths, readJsonlRecords, readStoredWriteOperation, VAULT_LAYOUT, walkVaultFiles, withCanonicalWriteLockScope, } from "@murphai/core";
|
|
7
|
+
import { buildAttachmentId, createDeterministicInboxCaptureId, createInboxCaptureIdentityKey, normalizeStoredAttachments, normalizeAccountKey, normalizeRelativePath, redactSensitivePaths, resolveVaultPath, sanitizeFileName, sanitizeSegment, sha256File, } from "../shared.js";
|
|
8
|
+
import { INBOX_CAPTURE_LEDGER_DIRECTORY, buildInboxCaptureLedgerPathForOccurredAt, buildInboxCaptureRecord, } from "./persist/canonical-records.js";
|
|
23
9
|
export async function ensureInboxVault(vaultRoot) {
|
|
24
10
|
await loadVault({ vaultRoot });
|
|
25
11
|
}
|
|
@@ -204,23 +190,6 @@ async function prepareRawCapturePersistence({ captureId, eventId, input, storedA
|
|
|
204
190
|
rawContents,
|
|
205
191
|
};
|
|
206
192
|
}
|
|
207
|
-
export async function persistRawCapture({ vaultRoot, captureId, eventId, input, storedAt = new Date().toISOString(), }) {
|
|
208
|
-
const prepared = await prepareRawCapturePersistence({
|
|
209
|
-
captureId,
|
|
210
|
-
eventId,
|
|
211
|
-
input,
|
|
212
|
-
storedAt,
|
|
213
|
-
});
|
|
214
|
-
await applyCanonicalWriteBatch({
|
|
215
|
-
vaultRoot,
|
|
216
|
-
operationType: "inbox_capture_raw_persist",
|
|
217
|
-
summary: `Persist inbox capture ${captureId}`,
|
|
218
|
-
occurredAt: prepared.stored.storedAt,
|
|
219
|
-
rawCopies: prepared.rawCopies,
|
|
220
|
-
rawContents: prepared.rawContents,
|
|
221
|
-
});
|
|
222
|
-
return prepared.stored;
|
|
223
|
-
}
|
|
224
193
|
export async function persistCanonicalInboxCapture({ vaultRoot, captureId, eventId, input, storedAt = new Date().toISOString(), }) {
|
|
225
194
|
const prepared = await prepareRawCapturePersistence({
|
|
226
195
|
captureId,
|
|
@@ -239,6 +208,12 @@ export async function persistCanonicalInboxCapture({ vaultRoot, captureId, event
|
|
|
239
208
|
operationType: "inbox_capture_persist",
|
|
240
209
|
summary: `Persist inbox capture ${captureId}`,
|
|
241
210
|
occurredAt: prepared.stored.storedAt,
|
|
211
|
+
audit: {
|
|
212
|
+
action: "inbox_capture_persist",
|
|
213
|
+
commandName: "inboxd.persistCanonicalInboxCapture",
|
|
214
|
+
summary: `Persisted inbox capture ${captureId}.`,
|
|
215
|
+
targetIds: [captureId, eventId],
|
|
216
|
+
},
|
|
242
217
|
rawCopies: prepared.rawCopies,
|
|
243
218
|
rawContents: prepared.rawContents,
|
|
244
219
|
jsonlAppends: [
|
|
@@ -266,37 +241,29 @@ export async function findStoredCaptureEnvelope(input) {
|
|
|
266
241
|
if (storedRecord) {
|
|
267
242
|
return inboxCaptureRecordToStoredCaptureEnvelope(storedRecord);
|
|
268
243
|
}
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
244
|
+
const expectedEnvelopePath = buildInboxEnvelopePath(input.inbound, captureId);
|
|
245
|
+
const expectedCapturePath = buildInboxCaptureLedgerPathForOccurredAt(input.inbound.occurredAt);
|
|
246
|
+
const recoverableOperations = await listRecoverableInboxCaptureOperations(input.vaultRoot);
|
|
247
|
+
const recoverableOperation = recoverableOperations.get(expectedEnvelopePath);
|
|
248
|
+
if (!recoverableOperation || recoverableOperation.capturePath !== expectedCapturePath) {
|
|
249
|
+
return null;
|
|
273
250
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
for (const envelopePath of envelopeFiles) {
|
|
279
|
-
const envelope = await readStoredCaptureEnvelope(envelopePath);
|
|
280
|
-
if (!envelope || createInboxCaptureIdentityKey(envelope.input) !== identityKey) {
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
const entry = { absolutePath: envelopePath, envelope };
|
|
284
|
-
if (!selected || compareEnvelopeEntries(entry, selected) < 0) {
|
|
285
|
-
selected = entry;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return selected?.envelope ?? null;
|
|
251
|
+
return await readStoredCaptureEnvelope({
|
|
252
|
+
vaultRoot: input.vaultRoot,
|
|
253
|
+
relativePath: expectedEnvelopePath,
|
|
254
|
+
});
|
|
289
255
|
}
|
|
290
256
|
export async function ensureStoredCaptureCanonicalEvidence(input) {
|
|
291
|
-
const
|
|
257
|
+
const relativePath = buildInboxCaptureLedgerPathForOccurredAt(input.envelope.input.occurredAt);
|
|
292
258
|
await withCanonicalWriteLockScope(input.vaultRoot, async () => {
|
|
293
259
|
const lock = await acquireCanonicalWriteLock(input.vaultRoot);
|
|
294
260
|
try {
|
|
295
|
-
const
|
|
261
|
+
const records = await readInboxCaptureRecordsIfPresent({
|
|
296
262
|
vaultRoot: input.vaultRoot,
|
|
297
|
-
relativePath
|
|
263
|
+
relativePath,
|
|
298
264
|
});
|
|
299
|
-
|
|
265
|
+
const identityKey = createInboxCaptureIdentityKey(input.envelope.input);
|
|
266
|
+
if (selectMatchingInboxCaptureRecord(records, identityKey, input.envelope.captureId)) {
|
|
300
267
|
return;
|
|
301
268
|
}
|
|
302
269
|
await applyCanonicalWriteBatch({
|
|
@@ -304,9 +271,15 @@ export async function ensureStoredCaptureCanonicalEvidence(input) {
|
|
|
304
271
|
operationType: "inbox_capture_canonical_evidence",
|
|
305
272
|
summary: `Ensure canonical evidence for inbox capture ${input.envelope.captureId}`,
|
|
306
273
|
occurredAt: input.envelope.stored.storedAt,
|
|
274
|
+
audit: {
|
|
275
|
+
action: "inbox_capture_canonical_evidence",
|
|
276
|
+
commandName: "inboxd.ensureStoredCaptureCanonicalEvidence",
|
|
277
|
+
summary: `Ensured canonical inbox evidence for capture ${input.envelope.captureId}.`,
|
|
278
|
+
targetIds: [input.envelope.captureId, input.envelope.eventId],
|
|
279
|
+
},
|
|
307
280
|
jsonlAppends: [
|
|
308
281
|
{
|
|
309
|
-
relativePath
|
|
282
|
+
relativePath,
|
|
310
283
|
record: buildInboxCaptureRecord({
|
|
311
284
|
eventId: input.envelope.eventId,
|
|
312
285
|
inbound: input.envelope.input,
|
|
@@ -321,53 +294,6 @@ export async function ensureStoredCaptureCanonicalEvidence(input) {
|
|
|
321
294
|
}
|
|
322
295
|
});
|
|
323
296
|
}
|
|
324
|
-
export async function appendInboxCaptureEvent(input) {
|
|
325
|
-
const vault = await loadVault({ vaultRoot: input.vaultRoot });
|
|
326
|
-
const relativePath = buildInboxCaptureEventPathForOccurredAt(input.occurredAt);
|
|
327
|
-
const record = buildInboxCaptureEventRecord({
|
|
328
|
-
eventId: input.eventId,
|
|
329
|
-
inbound: input.inbound,
|
|
330
|
-
stored: input.stored,
|
|
331
|
-
timeZone: vault.metadata.timezone,
|
|
332
|
-
});
|
|
333
|
-
await applyCanonicalWriteBatch({
|
|
334
|
-
vaultRoot: input.vaultRoot,
|
|
335
|
-
operationType: "inbox_capture_event_append",
|
|
336
|
-
summary: `Append inbox capture event ${input.eventId}`,
|
|
337
|
-
occurredAt: input.stored.storedAt,
|
|
338
|
-
jsonlAppends: [
|
|
339
|
-
{
|
|
340
|
-
relativePath,
|
|
341
|
-
record,
|
|
342
|
-
},
|
|
343
|
-
],
|
|
344
|
-
});
|
|
345
|
-
return { relativePath, record };
|
|
346
|
-
}
|
|
347
|
-
export async function appendImportAudit(input) {
|
|
348
|
-
const relativePath = buildInboxCaptureAuditPathForStoredAt(input.stored.storedAt);
|
|
349
|
-
const record = buildInboxCaptureAuditRecord({
|
|
350
|
-
auditId: input.auditId,
|
|
351
|
-
eventId: input.eventId,
|
|
352
|
-
inbound: input.inbound,
|
|
353
|
-
stored: input.stored,
|
|
354
|
-
capturePath: input.capturePath,
|
|
355
|
-
eventPath: input.eventPath,
|
|
356
|
-
});
|
|
357
|
-
await applyCanonicalWriteBatch({
|
|
358
|
-
vaultRoot: input.vaultRoot,
|
|
359
|
-
operationType: "inbox_capture_audit_append",
|
|
360
|
-
summary: `Append inbox capture audit ${input.auditId}`,
|
|
361
|
-
occurredAt: input.stored.storedAt,
|
|
362
|
-
jsonlAppends: [
|
|
363
|
-
{
|
|
364
|
-
relativePath,
|
|
365
|
-
record,
|
|
366
|
-
},
|
|
367
|
-
],
|
|
368
|
-
});
|
|
369
|
-
return { relativePath, record };
|
|
370
|
-
}
|
|
371
297
|
export async function rebuildRuntimeFromVault(input) {
|
|
372
298
|
const canonicalRecords = await listCanonicalInboxCaptureRecords(input.vaultRoot);
|
|
373
299
|
const restoredIdentityKeys = new Set();
|
|
@@ -385,47 +311,24 @@ export async function rebuildRuntimeFromVault(input) {
|
|
|
385
311
|
});
|
|
386
312
|
restoredIdentityKeys.add(record.identityKey);
|
|
387
313
|
}
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
catch {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
await assertVaultPathOnDisk(input.vaultRoot, inboxRoot);
|
|
396
|
-
const envelopeFiles = await walkInboxEnvelopeFiles(inboxRoot);
|
|
397
|
-
const canonicalEntries = new Map();
|
|
398
|
-
for (const envelopePath of envelopeFiles) {
|
|
399
|
-
const envelope = await readStoredCaptureEnvelope(envelopePath);
|
|
400
|
-
if (!envelope) {
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
const identityKey = createInboxCaptureIdentityKey(envelope.input);
|
|
404
|
-
if (restoredIdentityKeys.has(identityKey)) {
|
|
405
|
-
continue;
|
|
406
|
-
}
|
|
407
|
-
const entry = { absolutePath: envelopePath, envelope };
|
|
408
|
-
const current = canonicalEntries.get(identityKey);
|
|
409
|
-
if (!current || compareEnvelopeEntries(entry, current) < 0) {
|
|
410
|
-
canonicalEntries.set(identityKey, entry);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
for (const entry of [...canonicalEntries.values()].sort(compareEnvelopeEntries)) {
|
|
314
|
+
const recoverableOperations = await listRecoverableInboxCaptureOperations(input.vaultRoot);
|
|
315
|
+
const recoveredEnvelopes = await listRecoverableRawCaptureEnvelopes(input.vaultRoot, restoredIdentityKeys, recoverableOperations);
|
|
316
|
+
for (const envelope of recoveredEnvelopes) {
|
|
414
317
|
await ensureStoredCaptureCanonicalEvidence({
|
|
415
318
|
vaultRoot: input.vaultRoot,
|
|
416
|
-
envelope
|
|
319
|
+
envelope,
|
|
417
320
|
});
|
|
418
321
|
const captureId = input.runtime.upsertCaptureIndex({
|
|
419
|
-
captureId:
|
|
420
|
-
eventId:
|
|
421
|
-
input:
|
|
422
|
-
stored:
|
|
322
|
+
captureId: envelope.captureId,
|
|
323
|
+
eventId: envelope.eventId,
|
|
324
|
+
input: envelope.input,
|
|
325
|
+
stored: envelope.stored,
|
|
423
326
|
});
|
|
424
327
|
input.runtime.enqueueDerivedJobs({
|
|
425
328
|
captureId,
|
|
426
|
-
stored:
|
|
329
|
+
stored: envelope.stored,
|
|
427
330
|
});
|
|
428
|
-
restoredIdentityKeys.add(createInboxCaptureIdentityKey(
|
|
331
|
+
restoredIdentityKeys.add(createInboxCaptureIdentityKey(envelope.input));
|
|
429
332
|
}
|
|
430
333
|
}
|
|
431
334
|
function buildInboxAccountDirectory(input) {
|
|
@@ -439,71 +342,78 @@ function buildInboxCaptureDirectory(input, captureId) {
|
|
|
439
342
|
function buildInboxEnvelopePath(input, captureId) {
|
|
440
343
|
return normalizeRelativePath(path.posix.join(buildInboxCaptureDirectory(input, captureId), "envelope.json"));
|
|
441
344
|
}
|
|
442
|
-
async function
|
|
345
|
+
async function readStoredCaptureEnvelope(input) {
|
|
346
|
+
const absolutePath = await resolveVaultPath(input.vaultRoot, input.relativePath);
|
|
443
347
|
try {
|
|
444
|
-
return (await
|
|
348
|
+
return normalizeStoredCaptureEnvelope(JSON.parse(await readFile(absolutePath, "utf8")), input.relativePath);
|
|
445
349
|
}
|
|
446
350
|
catch (error) {
|
|
447
351
|
if (isMissingFileError(error)) {
|
|
448
|
-
return
|
|
352
|
+
return null;
|
|
449
353
|
}
|
|
450
354
|
throw error;
|
|
451
355
|
}
|
|
452
356
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
357
|
+
function normalizeStoredCaptureEnvelope(value, relativePath) {
|
|
358
|
+
const context = `stored inbox envelope at ${relativePath}`;
|
|
359
|
+
const envelope = expectRecord(value, context);
|
|
360
|
+
if (envelope.schema !== "murph.inbox-envelope.v1") {
|
|
361
|
+
throw new TypeError(`Expected canonical "schema" in ${context}.`);
|
|
456
362
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
return null;
|
|
464
|
-
}
|
|
465
|
-
throw error;
|
|
363
|
+
const inbound = buildSanitizedInboundCapture(normalizeStoredCaptureInboundInput(envelope.input, `${context}.input`));
|
|
364
|
+
const captureId = createDeterministicInboxCaptureId(inbound);
|
|
365
|
+
const eventId = requireStringField(envelope, "eventId", context);
|
|
366
|
+
const storedAt = requireStringField(envelope, "storedAt", context);
|
|
367
|
+
if (requireStringField(envelope, "captureId", context) !== captureId) {
|
|
368
|
+
throw new TypeError(`Stored inbox envelope at ${relativePath} must use the deterministic captureId.`);
|
|
466
369
|
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
370
|
+
const storedRecord = expectRecord(envelope.stored, `${context}.stored`);
|
|
371
|
+
const sourceDirectory = requireStringField(storedRecord, "sourceDirectory", `${context}.stored`);
|
|
372
|
+
const envelopePath = requireStringField(storedRecord, "envelopePath", `${context}.stored`);
|
|
373
|
+
const attachmentsValue = storedRecord.attachments;
|
|
374
|
+
if (!Array.isArray(attachmentsValue)) {
|
|
375
|
+
throw new TypeError(`Expected canonical "attachments" array in ${context}.stored.`);
|
|
471
376
|
}
|
|
472
|
-
if (
|
|
473
|
-
throw new TypeError(`
|
|
377
|
+
if (requireStringField(storedRecord, "captureId", `${context}.stored`) !== captureId) {
|
|
378
|
+
throw new TypeError(`Stored inbox envelope at ${relativePath} has a mismatched stored.captureId.`);
|
|
474
379
|
}
|
|
475
|
-
if (
|
|
476
|
-
throw new TypeError(`
|
|
380
|
+
if (requireStringField(storedRecord, "eventId", `${context}.stored`) !== eventId) {
|
|
381
|
+
throw new TypeError(`Stored inbox envelope at ${relativePath} has a mismatched stored.eventId.`);
|
|
477
382
|
}
|
|
478
|
-
if (
|
|
479
|
-
throw new TypeError(`
|
|
383
|
+
if (requireStringField(storedRecord, "storedAt", `${context}.stored`) !== storedAt) {
|
|
384
|
+
throw new TypeError(`Stored inbox envelope at ${relativePath} has a mismatched stored.storedAt.`);
|
|
480
385
|
}
|
|
481
|
-
|
|
482
|
-
|
|
386
|
+
const expectedSourceDirectory = buildInboxCaptureDirectory(inbound, captureId);
|
|
387
|
+
if (sourceDirectory !== expectedSourceDirectory) {
|
|
388
|
+
throw new TypeError(`Stored inbox envelope at ${relativePath} has a mismatched stored.sourceDirectory.`);
|
|
483
389
|
}
|
|
484
|
-
|
|
485
|
-
|
|
390
|
+
const expectedEnvelopePath = buildInboxEnvelopePath(inbound, captureId);
|
|
391
|
+
if (envelopePath !== expectedEnvelopePath) {
|
|
392
|
+
throw new TypeError(`Stored inbox envelope at ${relativePath} has a mismatched stored.envelopePath.`);
|
|
486
393
|
}
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
394
|
+
const attachments = normalizeStoredAttachments(captureId, attachmentsValue, `${context}.stored.attachments`).map((attachment) => {
|
|
395
|
+
const expectedAttachmentId = buildAttachmentId(captureId, attachment.ordinal);
|
|
396
|
+
if (attachment.attachmentId !== expectedAttachmentId) {
|
|
397
|
+
throw new TypeError(`Stored inbox envelope at ${relativePath} has a mismatched attachmentId for ordinal ${attachment.ordinal}.`);
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
...attachment,
|
|
401
|
+
attachmentId: expectedAttachmentId,
|
|
402
|
+
originalPath: null,
|
|
403
|
+
};
|
|
492
404
|
});
|
|
493
|
-
return {
|
|
494
|
-
|
|
495
|
-
|
|
405
|
+
return inboxCaptureRecordToStoredCaptureEnvelope(buildInboxCaptureRecord({
|
|
406
|
+
eventId,
|
|
407
|
+
inbound,
|
|
496
408
|
stored: {
|
|
497
|
-
...envelope.stored,
|
|
498
409
|
captureId,
|
|
499
|
-
eventId
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}),
|
|
410
|
+
eventId,
|
|
411
|
+
storedAt,
|
|
412
|
+
sourceDirectory,
|
|
413
|
+
envelopePath,
|
|
414
|
+
attachments,
|
|
505
415
|
},
|
|
506
|
-
};
|
|
416
|
+
}));
|
|
507
417
|
}
|
|
508
418
|
async function readJsonlRecordsIfPresent(input) {
|
|
509
419
|
try {
|
|
@@ -518,24 +428,80 @@ async function readJsonlRecordsIfPresent(input) {
|
|
|
518
428
|
throw error;
|
|
519
429
|
}
|
|
520
430
|
}
|
|
521
|
-
function
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
431
|
+
async function listRecoverableRawCaptureEnvelopes(vaultRoot, restoredIdentityKeys, recoverableOperations) {
|
|
432
|
+
const selectedByIdentityKey = new Map();
|
|
433
|
+
for (const relativePath of [...recoverableOperations.keys()].sort()) {
|
|
434
|
+
const envelope = await readStoredCaptureEnvelope({ vaultRoot, relativePath });
|
|
435
|
+
if (!envelope) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
const identityKey = createInboxCaptureIdentityKey(envelope.input);
|
|
439
|
+
if (restoredIdentityKeys.has(identityKey)) {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const current = selectedByIdentityKey.get(identityKey);
|
|
443
|
+
const candidate = { relativePath, envelope };
|
|
444
|
+
if (!current || compareEnvelopeEntries(candidate, current) < 0) {
|
|
445
|
+
selectedByIdentityKey.set(identityKey, candidate);
|
|
446
|
+
}
|
|
525
447
|
}
|
|
448
|
+
return [...selectedByIdentityKey.values()].sort(compareEnvelopeEntries).map((entry) => entry.envelope);
|
|
449
|
+
}
|
|
450
|
+
async function listRecoverableInboxCaptureOperations(vaultRoot) {
|
|
451
|
+
const relativePaths = await listWriteOperationMetadataPaths(vaultRoot);
|
|
452
|
+
const selected = new Map();
|
|
453
|
+
for (const relativePath of relativePaths) {
|
|
454
|
+
let operation;
|
|
455
|
+
try {
|
|
456
|
+
operation = await readStoredWriteOperation(vaultRoot, relativePath);
|
|
457
|
+
}
|
|
458
|
+
catch {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
const recoverable = selectRecoverableInboxCaptureOperation(operation);
|
|
462
|
+
if (!recoverable) {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const current = selected.get(recoverable.envelopePath);
|
|
466
|
+
if (!current || current.updatedAt.localeCompare(recoverable.updatedAt) < 0) {
|
|
467
|
+
selected.set(recoverable.envelopePath, recoverable);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return selected;
|
|
471
|
+
}
|
|
472
|
+
function selectRecoverableInboxCaptureOperation(operation) {
|
|
473
|
+
if (operation.operationType !== "inbox_capture_persist") {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
if (operation.status === "committed" || operation.status === "rolled_back") {
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
const envelopeAction = operation.actions.find((action) => action.kind === "raw_copy" &&
|
|
480
|
+
action.targetRelativePath.startsWith(`${VAULT_LAYOUT.rawInboxDirectory}/`) &&
|
|
481
|
+
action.targetRelativePath.endsWith("/envelope.json") &&
|
|
482
|
+
(action.state === "applied" || action.state === "reused"));
|
|
483
|
+
const captureAction = operation.actions.find((action) => action.kind === "jsonl_append" &&
|
|
484
|
+
action.targetRelativePath.startsWith(`${INBOX_CAPTURE_LEDGER_DIRECTORY}/`) &&
|
|
485
|
+
action.state === "staged");
|
|
486
|
+
if (!envelopeAction || !captureAction) {
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
envelopePath: envelopeAction.targetRelativePath,
|
|
491
|
+
capturePath: captureAction.targetRelativePath,
|
|
492
|
+
updatedAt: operation.updatedAt,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
function compareEnvelopeEntries(left, right) {
|
|
526
496
|
const storedAtComparison = left.envelope.stored.storedAt.localeCompare(right.envelope.stored.storedAt);
|
|
527
497
|
if (storedAtComparison !== 0) {
|
|
528
498
|
return storedAtComparison;
|
|
529
499
|
}
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
532
|
-
return
|
|
500
|
+
const captureIdComparison = left.envelope.captureId.localeCompare(right.envelope.captureId);
|
|
501
|
+
if (captureIdComparison !== 0) {
|
|
502
|
+
return captureIdComparison;
|
|
533
503
|
}
|
|
534
|
-
return left.
|
|
535
|
-
}
|
|
536
|
-
function comparePreferenceScore(entry) {
|
|
537
|
-
const canonicalCaptureId = createDeterministicInboxCaptureId(entry.envelope.input);
|
|
538
|
-
return path.basename(path.dirname(entry.absolutePath)) === canonicalCaptureId ? 0 : 1;
|
|
504
|
+
return left.relativePath.localeCompare(right.relativePath);
|
|
539
505
|
}
|
|
540
506
|
function inboxCaptureRecordToStoredCaptureEnvelope(record) {
|
|
541
507
|
const input = {
|
|
@@ -666,10 +632,6 @@ function compareInboxCaptureRecords(left, right) {
|
|
|
666
632
|
}
|
|
667
633
|
return left.envelopePath.localeCompare(right.envelopePath);
|
|
668
634
|
}
|
|
669
|
-
function findMatchingInboxCaptureRecord(records, envelope) {
|
|
670
|
-
const identityKey = createInboxCaptureIdentityKey(envelope.input);
|
|
671
|
-
return selectMatchingInboxCaptureRecord(records, identityKey, envelope.captureId);
|
|
672
|
-
}
|
|
673
635
|
function stripEphemeralAttachmentFields(attachment) {
|
|
674
636
|
const { data, ...sanitized } = attachment;
|
|
675
637
|
return sanitized;
|
|
@@ -684,55 +646,109 @@ function buildUnstoredAttachment(input) {
|
|
|
684
646
|
sha256: null,
|
|
685
647
|
};
|
|
686
648
|
}
|
|
687
|
-
function
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
649
|
+
function normalizeStoredCaptureInboundInput(value, context) {
|
|
650
|
+
const input = expectRecord(value, context);
|
|
651
|
+
const thread = expectRecord(input.thread, `${context}.thread`);
|
|
652
|
+
const actor = expectRecord(input.actor, `${context}.actor`);
|
|
653
|
+
const raw = expectRecord(input.raw, `${context}.raw`);
|
|
654
|
+
const attachmentsValue = input.attachments;
|
|
655
|
+
if (!Array.isArray(attachmentsValue)) {
|
|
656
|
+
throw new TypeError(`Expected canonical "attachments" array in ${context}.`);
|
|
691
657
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
658
|
+
return {
|
|
659
|
+
source: requireStringField(input, "source", context),
|
|
660
|
+
externalId: requireStringField(input, "externalId", context),
|
|
661
|
+
accountId: readOptionalNullableStringField(input, "accountId", context),
|
|
662
|
+
thread: {
|
|
663
|
+
id: requireStringField(thread, "id", `${context}.thread`),
|
|
664
|
+
title: readOptionalNullableStringField(thread, "title", `${context}.thread`),
|
|
665
|
+
isDirect: readOptionalBooleanField(thread, "isDirect", `${context}.thread`),
|
|
666
|
+
},
|
|
667
|
+
actor: {
|
|
668
|
+
id: readOptionalNullableStringField(actor, "id", `${context}.actor`),
|
|
669
|
+
displayName: readOptionalNullableStringField(actor, "displayName", `${context}.actor`),
|
|
670
|
+
isSelf: requireBooleanField(actor, "isSelf", `${context}.actor`),
|
|
671
|
+
},
|
|
672
|
+
occurredAt: requireStringField(input, "occurredAt", context),
|
|
673
|
+
receivedAt: readOptionalNullableStringField(input, "receivedAt", context),
|
|
674
|
+
text: readOptionalNullableStringField(input, "text", context) ?? null,
|
|
675
|
+
attachments: attachmentsValue.map((attachment, index) => normalizeStoredCaptureInboundAttachment(attachment, `${context}.attachments[${index}]`)),
|
|
676
|
+
raw,
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function normalizeStoredCaptureInboundAttachment(value, context) {
|
|
680
|
+
const attachment = expectRecord(value, context);
|
|
681
|
+
const kind = requireStringField(attachment, "kind", context);
|
|
682
|
+
if (!isInboundAttachmentKind(kind)) {
|
|
683
|
+
throw new TypeError(`Unsupported canonical attachment kind "${kind}" in ${context}.`);
|
|
698
684
|
}
|
|
699
|
-
return
|
|
685
|
+
return {
|
|
686
|
+
externalId: readOptionalNullableStringField(attachment, "externalId", context),
|
|
687
|
+
kind,
|
|
688
|
+
mime: readOptionalNullableStringField(attachment, "mime", context),
|
|
689
|
+
originalPath: null,
|
|
690
|
+
fileName: readOptionalNullableStringField(attachment, "fileName", context),
|
|
691
|
+
byteSize: readOptionalNullableNumberField(attachment, "byteSize", context),
|
|
692
|
+
};
|
|
700
693
|
}
|
|
701
|
-
function
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}));
|
|
694
|
+
function expectRecord(value, context) {
|
|
695
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
696
|
+
throw new TypeError(`Expected object in ${context}.`);
|
|
697
|
+
}
|
|
698
|
+
return value;
|
|
707
699
|
}
|
|
708
|
-
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
700
|
+
function requireStringField(value, field, context) {
|
|
701
|
+
const fieldValue = value[field];
|
|
702
|
+
if (typeof fieldValue !== "string" || fieldValue.trim().length === 0) {
|
|
703
|
+
throw new TypeError(`Expected canonical "${field}" string in ${context}.`);
|
|
712
704
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
705
|
+
return fieldValue;
|
|
706
|
+
}
|
|
707
|
+
function requireBooleanField(value, field, context) {
|
|
708
|
+
const fieldValue = value[field];
|
|
709
|
+
if (typeof fieldValue !== "boolean") {
|
|
710
|
+
throw new TypeError(`Expected canonical "${field}" boolean in ${context}.`);
|
|
718
711
|
}
|
|
712
|
+
return fieldValue;
|
|
719
713
|
}
|
|
720
|
-
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
catch (error) {
|
|
729
|
-
if (isMissingFileError(error)) {
|
|
730
|
-
return candidate;
|
|
731
|
-
}
|
|
732
|
-
throw error;
|
|
733
|
-
}
|
|
714
|
+
function readOptionalBooleanField(value, field, context) {
|
|
715
|
+
const fieldValue = value[field];
|
|
716
|
+
if (fieldValue === undefined) {
|
|
717
|
+
return undefined;
|
|
718
|
+
}
|
|
719
|
+
if (typeof fieldValue !== "boolean") {
|
|
720
|
+
throw new TypeError(`Expected canonical "${field}" boolean in ${context}.`);
|
|
734
721
|
}
|
|
735
|
-
|
|
722
|
+
return fieldValue;
|
|
723
|
+
}
|
|
724
|
+
function readOptionalNullableStringField(value, field, context) {
|
|
725
|
+
const fieldValue = value[field];
|
|
726
|
+
if (fieldValue === undefined) {
|
|
727
|
+
return undefined;
|
|
728
|
+
}
|
|
729
|
+
if (fieldValue === null) {
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
if (typeof fieldValue !== "string") {
|
|
733
|
+
throw new TypeError(`Expected canonical "${field}" string in ${context}.`);
|
|
734
|
+
}
|
|
735
|
+
return fieldValue;
|
|
736
|
+
}
|
|
737
|
+
function readOptionalNullableNumberField(value, field, context) {
|
|
738
|
+
const fieldValue = value[field];
|
|
739
|
+
if (fieldValue === undefined) {
|
|
740
|
+
return undefined;
|
|
741
|
+
}
|
|
742
|
+
if (fieldValue === null) {
|
|
743
|
+
return null;
|
|
744
|
+
}
|
|
745
|
+
if (typeof fieldValue !== "number" || !Number.isFinite(fieldValue)) {
|
|
746
|
+
throw new TypeError(`Expected canonical "${field}" number in ${context}.`);
|
|
747
|
+
}
|
|
748
|
+
return fieldValue;
|
|
749
|
+
}
|
|
750
|
+
function isInboundAttachmentKind(value) {
|
|
751
|
+
return ["image", "audio", "video", "document", "other"].includes(value);
|
|
736
752
|
}
|
|
737
753
|
function isMissingFileError(error) {
|
|
738
754
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|