@murphai/hosted-execution 0.1.15 → 0.1.17
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 +201 -674
- package/README.md +15 -14
- package/dist/auth.d.ts +11 -25
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +32 -76
- package/dist/auth.js.map +1 -1
- package/dist/builders.d.ts +3 -4
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js +24 -24
- package/dist/builders.js.map +1 -1
- package/dist/bundles.d.ts +3 -13
- package/dist/bundles.d.ts.map +1 -1
- package/dist/bundles.js +1 -16
- package/dist/bundles.js.map +1 -1
- package/dist/client.d.ts +2 -26
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +38 -212
- package/dist/client.js.map +1 -1
- package/dist/contracts.d.ts +49 -118
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +15 -58
- package/dist/contracts.js.map +1 -1
- package/dist/dispatch-ref.d.ts +1 -2
- package/dist/dispatch-ref.d.ts.map +1 -1
- package/dist/dispatch-ref.js +16 -30
- package/dist/dispatch-ref.js.map +1 -1
- package/dist/env.d.ts +0 -38
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +1 -87
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts +3 -1
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +76 -53
- package/dist/observability.js.map +1 -1
- package/dist/outbox-payload.d.ts +7 -5
- package/dist/outbox-payload.d.ts.map +1 -1
- package/dist/outbox-payload.js +75 -38
- package/dist/outbox-payload.js.map +1 -1
- package/dist/parsers.d.ts +10 -10
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +192 -139
- package/dist/parsers.js.map +1 -1
- package/dist/routes.d.ts +4 -9
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +7 -18
- package/dist/routes.js.map +1 -1
- package/node_modules/@murphai/core/README.md +3 -0
- package/node_modules/@murphai/core/dist/assessment/index.d.ts +5 -0
- package/node_modules/@murphai/core/dist/assessment/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/index.js +4 -0
- package/node_modules/@murphai/core/dist/assessment/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/project.d.ts +9 -0
- package/node_modules/@murphai/core/dist/assessment/project.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/project.js +353 -0
- package/node_modules/@murphai/core/dist/assessment/project.js.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/storage.d.ts +13 -0
- package/node_modules/@murphai/core/dist/assessment/storage.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/storage.js +202 -0
- package/node_modules/@murphai/core/dist/assessment/storage.js.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/types.d.ts +112 -0
- package/node_modules/@murphai/core/dist/assessment/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/types.js +5 -0
- package/node_modules/@murphai/core/dist/assessment/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/atomic-write.d.ts +5 -0
- package/node_modules/@murphai/core/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/atomic-write.js +120 -0
- package/node_modules/@murphai/core/dist/atomic-write.js.map +1 -0
- package/node_modules/@murphai/core/dist/audit.d.ts +27 -0
- package/node_modules/@murphai/core/dist/audit.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/audit.js +94 -0
- package/node_modules/@murphai/core/dist/audit.js.map +1 -0
- package/node_modules/@murphai/core/dist/automation.d.ts +55 -0
- package/node_modules/@murphai/core/dist/automation.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/automation.js +411 -0
- package/node_modules/@murphai/core/dist/automation.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/allergies.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/allergies.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/allergies.js +209 -0
- package/node_modules/@murphai/core/dist/bank/allergies.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/conditions.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/conditions.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/conditions.js +249 -0
- package/node_modules/@murphai/core/dist/bank/conditions.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/foods.d.ts +8 -0
- package/node_modules/@murphai/core/dist/bank/foods.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/foods.js +255 -0
- package/node_modules/@murphai/core/dist/bank/foods.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/goals.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/goals.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/goals.js +289 -0
- package/node_modules/@murphai/core/dist/bank/goals.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/index.d.ts +10 -0
- package/node_modules/@murphai/core/dist/bank/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/index.js +10 -0
- package/node_modules/@murphai/core/dist/bank/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/protocols.d.ts +8 -0
- package/node_modules/@murphai/core/dist/bank/protocols.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/protocols.js +466 -0
- package/node_modules/@murphai/core/dist/bank/protocols.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/providers.d.ts +46 -0
- package/node_modules/@murphai/core/dist/bank/providers.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/providers.js +160 -0
- package/node_modules/@murphai/core/dist/bank/providers.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/recipes.d.ts +8 -0
- package/node_modules/@murphai/core/dist/bank/recipes.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/recipes.js +287 -0
- package/node_modules/@murphai/core/dist/bank/recipes.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/shared.d.ts +39 -0
- package/node_modules/@murphai/core/dist/bank/shared.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/shared.js +150 -0
- package/node_modules/@murphai/core/dist/bank/shared.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/types.d.ts +469 -0
- package/node_modules/@murphai/core/dist/bank/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/types.js +35 -0
- package/node_modules/@murphai/core/dist/bank/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.js +204 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.js.map +1 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.d.ts +54 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.js +196 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.js.map +1 -0
- package/node_modules/@murphai/core/dist/constants.d.ts +125 -0
- package/node_modules/@murphai/core/dist/constants.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/constants.js +132 -0
- package/node_modules/@murphai/core/dist/constants.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/events.d.ts +100 -0
- package/node_modules/@murphai/core/dist/domains/events.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/events.js +593 -0
- package/node_modules/@murphai/core/dist/domains/events.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/experiments.d.ts +71 -0
- package/node_modules/@murphai/core/dist/domains/experiments.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/experiments.js +275 -0
- package/node_modules/@murphai/core/dist/domains/experiments.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/journal.d.ts +52 -0
- package/node_modules/@murphai/core/dist/domains/journal.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/journal.js +173 -0
- package/node_modules/@murphai/core/dist/domains/journal.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/shared.d.ts +37 -0
- package/node_modules/@murphai/core/dist/domains/shared.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/shared.js +101 -0
- package/node_modules/@murphai/core/dist/domains/shared.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.d.ts +15 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.js +58 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.js.map +1 -0
- package/node_modules/@murphai/core/dist/errors.d.ts +8 -0
- package/node_modules/@murphai/core/dist/errors.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/errors.js +14 -0
- package/node_modules/@murphai/core/dist/errors.js.map +1 -0
- package/node_modules/@murphai/core/dist/event-attachments.d.ts +69 -0
- package/node_modules/@murphai/core/dist/event-attachments.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/event-attachments.js +202 -0
- package/node_modules/@murphai/core/dist/event-attachments.js.map +1 -0
- package/node_modules/@murphai/core/dist/event-links.d.ts +15 -0
- package/node_modules/@murphai/core/dist/event-links.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/event-links.js +54 -0
- package/node_modules/@murphai/core/dist/event-links.js.map +1 -0
- package/node_modules/@murphai/core/dist/family/api.d.ts +5 -0
- package/node_modules/@murphai/core/dist/family/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/family/api.js +221 -0
- package/node_modules/@murphai/core/dist/family/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/family/index.d.ts +3 -0
- package/node_modules/@murphai/core/dist/family/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/family/index.js +3 -0
- package/node_modules/@murphai/core/dist/family/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/family/types.d.ts +34 -0
- package/node_modules/@murphai/core/dist/family/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/family/types.js +2 -0
- package/node_modules/@murphai/core/dist/family/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/frontmatter.d.ts +4 -0
- package/node_modules/@murphai/core/dist/frontmatter.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/frontmatter.js +99 -0
- package/node_modules/@murphai/core/dist/frontmatter.js.map +1 -0
- package/node_modules/@murphai/core/dist/fs.d.ts +22 -0
- package/node_modules/@murphai/core/dist/fs.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/fs.js +172 -0
- package/node_modules/@murphai/core/dist/fs.js.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/api.d.ts +5 -0
- package/node_modules/@murphai/core/dist/genetics/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/api.js +226 -0
- package/node_modules/@murphai/core/dist/genetics/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/index.d.ts +3 -0
- package/node_modules/@murphai/core/dist/genetics/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/index.js +3 -0
- package/node_modules/@murphai/core/dist/genetics/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/types.d.ts +40 -0
- package/node_modules/@murphai/core/dist/genetics/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/types.js +4 -0
- package/node_modules/@murphai/core/dist/genetics/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/api.d.ts +7 -0
- package/node_modules/@murphai/core/dist/history/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/api.js +473 -0
- package/node_modules/@murphai/core/dist/history/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/event-spine.d.ts +41 -0
- package/node_modules/@murphai/core/dist/history/event-spine.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/event-spine.js +111 -0
- package/node_modules/@murphai/core/dist/history/event-spine.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/index.d.ts +3 -0
- package/node_modules/@murphai/core/dist/history/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/index.js +3 -0
- package/node_modules/@murphai/core/dist/history/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/shared.d.ts +25 -0
- package/node_modules/@murphai/core/dist/history/shared.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/shared.js +144 -0
- package/node_modules/@murphai/core/dist/history/shared.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/types.d.ts +127 -0
- package/node_modules/@murphai/core/dist/history/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/types.js +8 -0
- package/node_modules/@murphai/core/dist/history/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/ids.d.ts +3 -0
- package/node_modules/@murphai/core/dist/ids.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/ids.js +20 -0
- package/node_modules/@murphai/core/dist/ids.js.map +1 -0
- package/node_modules/@murphai/core/dist/index.d.ts +30 -0
- package/node_modules/@murphai/core/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/index.js +23 -0
- package/node_modules/@murphai/core/dist/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/jsonl.d.ts +12 -0
- package/node_modules/@murphai/core/dist/jsonl.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/jsonl.js +40 -0
- package/node_modules/@murphai/core/dist/jsonl.js.map +1 -0
- package/node_modules/@murphai/core/dist/memory.d.ts +17 -0
- package/node_modules/@murphai/core/dist/memory.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/memory.js +72 -0
- package/node_modules/@murphai/core/dist/memory.js.map +1 -0
- package/node_modules/@murphai/core/dist/mutations.d.ts +150 -0
- package/node_modules/@murphai/core/dist/mutations.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/mutations.js +1109 -0
- package/node_modules/@murphai/core/dist/mutations.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.d.ts +29 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.js +164 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/index.d.ts +5 -0
- package/node_modules/@murphai/core/dist/operations/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/index.js +3 -0
- package/node_modules/@murphai/core/dist/operations/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.d.ts +33 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.js +105 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.d.ts +166 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.js +886 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.js.map +1 -0
- package/node_modules/@murphai/core/dist/path-safety.d.ts +19 -0
- package/node_modules/@murphai/core/dist/path-safety.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/path-safety.js +193 -0
- package/node_modules/@murphai/core/dist/path-safety.js.map +1 -0
- package/node_modules/@murphai/core/dist/profile/index.d.ts +4 -0
- package/node_modules/@murphai/core/dist/profile/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/profile/index.js +3 -0
- package/node_modules/@murphai/core/dist/profile/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/profile/storage.d.ts +41 -0
- package/node_modules/@murphai/core/dist/profile/storage.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/profile/storage.js +225 -0
- package/node_modules/@murphai/core/dist/profile/storage.js.map +1 -0
- package/node_modules/@murphai/core/dist/profile/types.d.ts +29 -0
- package/node_modules/@murphai/core/dist/profile/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/profile/types.js +8 -0
- package/node_modules/@murphai/core/dist/profile/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/public-mutations.d.ts +120 -0
- package/node_modules/@murphai/core/dist/public-mutations.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/public-mutations.js +275 -0
- package/node_modules/@murphai/core/dist/public-mutations.js.map +1 -0
- package/node_modules/@murphai/core/dist/raw.d.ts +28 -0
- package/node_modules/@murphai/core/dist/raw.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/raw.js +107 -0
- package/node_modules/@murphai/core/dist/raw.js.map +1 -0
- package/node_modules/@murphai/core/dist/registry/api.d.ts +80 -0
- package/node_modules/@murphai/core/dist/registry/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/registry/api.js +113 -0
- package/node_modules/@murphai/core/dist/registry/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.d.ts +15 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.js +9 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.js.map +1 -0
- package/node_modules/@murphai/core/dist/registry/markdown.d.ts +101 -0
- package/node_modules/@murphai/core/dist/registry/markdown.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/registry/markdown.js +136 -0
- package/node_modules/@murphai/core/dist/registry/markdown.js.map +1 -0
- package/node_modules/@murphai/core/dist/shares.d.ts +36 -0
- package/node_modules/@murphai/core/dist/shares.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/shares.js +333 -0
- package/node_modules/@murphai/core/dist/shares.js.map +1 -0
- package/node_modules/@murphai/core/dist/storage-spine.d.ts +3 -0
- package/node_modules/@murphai/core/dist/storage-spine.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/storage-spine.js +3 -0
- package/node_modules/@murphai/core/dist/storage-spine.js.map +1 -0
- package/node_modules/@murphai/core/dist/time.d.ts +11 -0
- package/node_modules/@murphai/core/dist/time.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/time.js +72 -0
- package/node_modules/@murphai/core/dist/time.js.map +1 -0
- package/node_modules/@murphai/core/dist/types.d.ts +18 -0
- package/node_modules/@murphai/core/dist/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/types.js +7 -0
- package/node_modules/@murphai/core/dist/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault-core-document.d.ts +8 -0
- package/node_modules/@murphai/core/dist/vault-core-document.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault-core-document.js +16 -0
- package/node_modules/@murphai/core/dist/vault-core-document.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault-metadata.d.ts +17 -0
- package/node_modules/@murphai/core/dist/vault-metadata.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault-metadata.js +44 -0
- package/node_modules/@murphai/core/dist/vault-metadata.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.d.ts +24 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.js +44 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault.d.ts +40 -0
- package/node_modules/@murphai/core/dist/vault.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault.js +649 -0
- package/node_modules/@murphai/core/dist/vault.js.map +1 -0
- package/node_modules/@murphai/core/dist/write-policy.d.ts +63 -0
- package/node_modules/@murphai/core/dist/write-policy.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/write-policy.js +146 -0
- package/node_modules/@murphai/core/dist/write-policy.js.map +1 -0
- package/node_modules/@murphai/core/package.json +27 -0
- package/node_modules/@murphai/device-syncd/README.md +123 -0
- package/node_modules/@murphai/device-syncd/dist/bin.d.ts +2 -0
- package/node_modules/@murphai/device-syncd/dist/bin.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/bin.js +29 -0
- package/node_modules/@murphai/device-syncd/dist/bin.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/client.d.ts +124 -0
- package/node_modules/@murphai/device-syncd/dist/client.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/client.js +199 -0
- package/node_modules/@murphai/device-syncd/dist/client.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/config.d.ts +18 -0
- package/node_modules/@murphai/device-syncd/dist/config.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/config.js +279 -0
- package/node_modules/@murphai/device-syncd/dist/config.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.d.ts +6 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.js +27 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/errors.d.ts +21 -0
- package/node_modules/@murphai/device-syncd/dist/errors.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/errors.js +32 -0
- package/node_modules/@murphai/device-syncd/dist/errors.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.d.ts +3 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.js +110 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.d.ts +139 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js +336 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/http.d.ts +34 -0
- package/node_modules/@murphai/device-syncd/dist/http.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/http.js +644 -0
- package/node_modules/@murphai/device-syncd/dist/http.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/index.d.ts +23 -0
- package/node_modules/@murphai/device-syncd/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/index.js +15 -0
- package/node_modules/@murphai/device-syncd/dist/index.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.d.ts +15 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.js +485 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.d.ts +49 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.js +401 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.d.ts +20 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.js +804 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.d.ts +104 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.js +214 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.d.ts +15 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.js +551 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.d.ts +4 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.js +13 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts +43 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.js +353 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/registry.d.ts +3 -0
- package/node_modules/@murphai/device-syncd/dist/registry.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/registry.js +5 -0
- package/node_modules/@murphai/device-syncd/dist/registry.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/service.d.ts +61 -0
- package/node_modules/@murphai/device-syncd/dist/service.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/service.js +496 -0
- package/node_modules/@murphai/device-syncd/dist/service.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/shared.d.ts +26 -0
- package/node_modules/@murphai/device-syncd/dist/shared.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/shared.js +182 -0
- package/node_modules/@murphai/device-syncd/dist/shared.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/store.d.ts +105 -0
- package/node_modules/@murphai/device-syncd/dist/store.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/store.js +965 -0
- package/node_modules/@murphai/device-syncd/dist/store.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/types.d.ts +287 -0
- package/node_modules/@murphai/device-syncd/dist/types.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/types.js +2 -0
- package/node_modules/@murphai/device-syncd/dist/types.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.d.ts +14 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.js +16 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.js.map +1 -0
- package/node_modules/@murphai/device-syncd/package.json +85 -0
- package/node_modules/@murphai/importers/README.md +34 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.d.ts +13 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.js +13 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.js.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.d.ts +15 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.js +32 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.js.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/index.d.ts +4 -0
- package/node_modules/@murphai/importers/dist/assessment/index.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/index.js +2 -0
- package/node_modules/@murphai/importers/dist/assessment/index.js.map +1 -0
- package/node_modules/@murphai/importers/dist/core-port.d.ts +119 -0
- package/node_modules/@murphai/importers/dist/core-port.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/core-port.js +22 -0
- package/node_modules/@murphai/importers/dist/core-port.js.map +1 -0
- package/node_modules/@murphai/importers/dist/create-importers.d.ts +17 -0
- package/node_modules/@murphai/importers/dist/create-importers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/create-importers.js +68 -0
- package/node_modules/@murphai/importers/dist/create-importers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.d.ts +22 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.js +153 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.d.ts +5 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.js +11 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.d.ts +9 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.js +172 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.d.ts +12 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.js +619 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.d.ts +40 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.js +295 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.d.ts +19 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.js +150 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.d.ts +14 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.js +37 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.d.ts +10 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.js +8 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.d.ts +20 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.js +602 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.d.ts +491 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.js +326 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.d.ts +9 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.js +5 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.d.ts +81 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.js +215 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.d.ts +12 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.js +2 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.d.ts +16 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.js +410 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.js.map +1 -0
- package/node_modules/@murphai/importers/dist/document-importer.d.ts +15 -0
- package/node_modules/@murphai/importers/dist/document-importer.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/document-importer.js +31 -0
- package/node_modules/@murphai/importers/dist/document-importer.js.map +1 -0
- package/node_modules/@murphai/importers/dist/index.d.ts +10 -0
- package/node_modules/@murphai/importers/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/index.js +9 -0
- package/node_modules/@murphai/importers/dist/index.js.map +1 -0
- package/node_modules/@murphai/importers/dist/meal-importer.d.ts +15 -0
- package/node_modules/@murphai/importers/dist/meal-importer.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/meal-importer.js +39 -0
- package/node_modules/@murphai/importers/dist/meal-importer.js.map +1 -0
- package/node_modules/@murphai/importers/dist/preset-registry.d.ts +31 -0
- package/node_modules/@murphai/importers/dist/preset-registry.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/preset-registry.js +96 -0
- package/node_modules/@murphai/importers/dist/preset-registry.js.map +1 -0
- package/node_modules/@murphai/importers/dist/shared.d.ts +31 -0
- package/node_modules/@murphai/importers/dist/shared.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/shared.js +154 -0
- package/node_modules/@murphai/importers/dist/shared.js.map +1 -0
- package/node_modules/@murphai/importers/package.json +36 -0
- package/node_modules/@murphai/runtime-state/README.md +37 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.js +80 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.d.ts +29 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.js +159 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.d.ts +33 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.js +47 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.d.ts +56 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.js +189 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.d.ts +7 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.js +27 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.js +12 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.js +13 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.d.ts +43 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.js +203 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.d.ts +13 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.js +46 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.d.ts +67 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.js +261 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.d.ts +31 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.js +211 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.d.ts +50 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.js +191 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.d.ts +14 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.js +59 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.d.ts +83 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.js +308 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.js +18 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/index.d.ts +7 -0
- package/node_modules/@murphai/runtime-state/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/index.js +7 -0
- package/node_modules/@murphai/runtime-state/dist/index.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.d.ts +31 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.js +120 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.js +17 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.d.ts +10 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.js +27 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.d.ts +29 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.js +82 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/locks.d.ts +46 -0
- package/node_modules/@murphai/runtime-state/dist/locks.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/locks.js +187 -0
- package/node_modules/@murphai/runtime-state/dist/locks.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.d.ts +4 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.js +35 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.d.ts +22 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.js +22 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.js +12 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.d.ts +4 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.js +124 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.js +13 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.d.ts +48 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.js +93 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/shared.d.ts +14 -0
- package/node_modules/@murphai/runtime-state/dist/shared.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/shared.js +46 -0
- package/node_modules/@murphai/runtime-state/dist/shared.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.d.ts +26 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.js +110 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.d.ts +5 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.js +31 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.d.ts +24 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.js +30 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.d.ts +18 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.js +25 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.js +12 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/package.json +30 -0
- package/package.json +45 -11
- package/dist/.tsbuildinfo +0 -1
- package/dist/callback-hosts.d.ts +0 -19
- package/dist/callback-hosts.d.ts.map +0 -1
- package/dist/callback-hosts.js +0 -19
- package/dist/callback-hosts.js.map +0 -1
- package/dist/web-control-plane.d.ts +0 -105
- package/dist/web-control-plane.d.ts.map +0 -1
- package/dist/web-control-plane.js +0 -358
- package/dist/web-control-plane.js.map +0 -1
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { promises as fs } from "node:fs";
|
|
4
|
+
import { copyFileAtomic, copyFileAtomicExclusive, writeTextFileAtomic, } from "../atomic-write.js";
|
|
5
|
+
import { VaultError } from "../errors.js";
|
|
6
|
+
import { ensureDirectory, pathExists, walkVaultFiles } from "../fs.js";
|
|
7
|
+
import { VAULT_LAYOUT } from "../constants.js";
|
|
8
|
+
import { normalizeRelativeVaultPath, normalizeVaultRoot, resolveVaultPath, } from "../path-safety.js";
|
|
9
|
+
import { toIsoTimestamp } from "../time.js";
|
|
10
|
+
import { isErrnoException, isPlainRecord } from "../types.js";
|
|
11
|
+
import { applyImmutableWriteTarget, applyJsonlAppendTarget, applyTextWriteTarget, assertWriteTargetPolicy, prepareVerifiedWriteTarget, } from "../write-policy.js";
|
|
12
|
+
import { acquireCanonicalWriteLock } from "./canonical-write-lock.js";
|
|
13
|
+
export const WRITE_OPERATION_SCHEMA_VERSION = "murph.write-operation.v1";
|
|
14
|
+
export const WRITE_OPERATION_DIRECTORY = ".runtime/operations";
|
|
15
|
+
const PROTECTED_CANONICAL_ROOT_FILES = new Set([VAULT_LAYOUT.metadata, VAULT_LAYOUT.coreDocument]);
|
|
16
|
+
const CANONICAL_WRITE_GUARD_RECEIPT_DIRECTORY_ENV = "MURPH_CANONICAL_WRITE_GUARD_RECEIPT_DIR";
|
|
17
|
+
const WRITE_OPERATION_GUARD_RECEIPT_SCHEMA_VERSION = "murph.write-operation-guard-receipt.v1";
|
|
18
|
+
function isStoredWriteOperationStatus(value) {
|
|
19
|
+
return (value === "staged" ||
|
|
20
|
+
value === "committing" ||
|
|
21
|
+
value === "committed" ||
|
|
22
|
+
value === "rolled_back" ||
|
|
23
|
+
value === "failed");
|
|
24
|
+
}
|
|
25
|
+
function parseWriteOperationActionState(value) {
|
|
26
|
+
return value === "staged" || value === "applied" || value === "reused" || value === "rolled_back"
|
|
27
|
+
? value
|
|
28
|
+
: null;
|
|
29
|
+
}
|
|
30
|
+
function nowIso() {
|
|
31
|
+
return toIsoTimestamp(new Date(), "updatedAt");
|
|
32
|
+
}
|
|
33
|
+
function generateOperationId() {
|
|
34
|
+
return `op_${randomUUID().replace(/-/g, "")}`;
|
|
35
|
+
}
|
|
36
|
+
function createCommittedPayloadReceipt(content) {
|
|
37
|
+
const buffer = Buffer.from(content);
|
|
38
|
+
return {
|
|
39
|
+
sha256: createHash("sha256").update(buffer).digest("hex"),
|
|
40
|
+
byteLength: buffer.byteLength,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function normalizeStoredRelativePath(candidate) {
|
|
44
|
+
if (typeof candidate !== "string") {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const normalized = normalizeRelativeVaultPath(candidate);
|
|
49
|
+
return normalized === candidate ? normalized : null;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function parseStoredOptionalBackupRelativePath(record) {
|
|
56
|
+
if (!("backupRelativePath" in record) || record.backupRelativePath === undefined) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return normalizeStoredRelativePath(record.backupRelativePath);
|
|
60
|
+
}
|
|
61
|
+
function parseStoredRequiredStageRelativePath(record) {
|
|
62
|
+
return normalizeStoredRelativePath(record.stageRelativePath);
|
|
63
|
+
}
|
|
64
|
+
function parseStoredActionBase(record) {
|
|
65
|
+
const state = parseWriteOperationActionState(record.state);
|
|
66
|
+
const targetRelativePath = normalizeStoredRelativePath(record.targetRelativePath);
|
|
67
|
+
if (!state || !targetRelativePath) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
appliedAt: typeof record.appliedAt === "string" ? record.appliedAt : undefined,
|
|
72
|
+
existedBefore: typeof record.existedBefore === "boolean" ? record.existedBefore : undefined,
|
|
73
|
+
rolledBackAt: typeof record.rolledBackAt === "string" ? record.rolledBackAt : undefined,
|
|
74
|
+
state,
|
|
75
|
+
targetRelativePath,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function parseCommittedPayloadReceipt(value) {
|
|
79
|
+
if (value === undefined) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
if (!isPlainRecord(value)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const record = value;
|
|
86
|
+
if (typeof record.sha256 !== "string" ||
|
|
87
|
+
!/^[a-f0-9]{64}$/u.test(record.sha256) ||
|
|
88
|
+
typeof record.byteLength !== "number" ||
|
|
89
|
+
!Number.isInteger(record.byteLength) ||
|
|
90
|
+
record.byteLength < 0) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
sha256: record.sha256,
|
|
95
|
+
byteLength: record.byteLength,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function resolveGuardReceiptDirectoryFromEnv(env = process.env) {
|
|
99
|
+
const candidate = typeof env[CANONICAL_WRITE_GUARD_RECEIPT_DIRECTORY_ENV] === "string"
|
|
100
|
+
? env[CANONICAL_WRITE_GUARD_RECEIPT_DIRECTORY_ENV]?.trim()
|
|
101
|
+
: "";
|
|
102
|
+
return candidate ? path.resolve(candidate) : null;
|
|
103
|
+
}
|
|
104
|
+
function metadataRelativePath(operationId) {
|
|
105
|
+
return `${WRITE_OPERATION_DIRECTORY}/${operationId}.json`;
|
|
106
|
+
}
|
|
107
|
+
function stageRootRelativePath(operationId) {
|
|
108
|
+
return `${WRITE_OPERATION_DIRECTORY}/${operationId}`;
|
|
109
|
+
}
|
|
110
|
+
function stageArtifactRelativePath(operationId, fileName) {
|
|
111
|
+
return `${stageRootRelativePath(operationId)}/payloads/${fileName}`;
|
|
112
|
+
}
|
|
113
|
+
function backupArtifactRelativePath(operationId, fileName) {
|
|
114
|
+
return `${stageRootRelativePath(operationId)}/backups/${fileName}`;
|
|
115
|
+
}
|
|
116
|
+
function toStoredOperationError(error) {
|
|
117
|
+
if (error instanceof VaultError) {
|
|
118
|
+
return {
|
|
119
|
+
code: error.code,
|
|
120
|
+
message: error.message,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (error instanceof Error) {
|
|
124
|
+
return {
|
|
125
|
+
message: error.message,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
message: String(error),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async function readText(absolutePath) {
|
|
133
|
+
return fs.readFile(absolutePath, "utf8");
|
|
134
|
+
}
|
|
135
|
+
async function safeUnlink(absolutePath) {
|
|
136
|
+
try {
|
|
137
|
+
await fs.unlink(absolutePath);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (isErrnoException(error) && error.code === "ENOENT") {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export function isTerminalWriteOperationStatus(status) {
|
|
147
|
+
return status === "committed" || status === "rolled_back";
|
|
148
|
+
}
|
|
149
|
+
export async function listWriteOperationMetadataPaths(vaultRoot) {
|
|
150
|
+
const operationFiles = await walkVaultFiles(vaultRoot, WRITE_OPERATION_DIRECTORY, {
|
|
151
|
+
extension: ".json",
|
|
152
|
+
});
|
|
153
|
+
return operationFiles.filter((relativePath) => path.posix.dirname(relativePath) === WRITE_OPERATION_DIRECTORY);
|
|
154
|
+
}
|
|
155
|
+
function parseStoredAction(value) {
|
|
156
|
+
if (!isPlainRecord(value) || typeof value.kind !== "string") {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const record = value;
|
|
160
|
+
const base = parseStoredActionBase(record);
|
|
161
|
+
if (!base) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
switch (record.kind) {
|
|
165
|
+
case "delete": {
|
|
166
|
+
const backupRelativePath = parseStoredOptionalBackupRelativePath(record);
|
|
167
|
+
if (backupRelativePath === null) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
kind: "delete",
|
|
172
|
+
...base,
|
|
173
|
+
backupRelativePath,
|
|
174
|
+
effect: record.effect === "delete" ? record.effect : undefined,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
case "raw_copy": {
|
|
178
|
+
const stageRelativePath = parseStoredRequiredStageRelativePath(record);
|
|
179
|
+
if (!stageRelativePath) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
kind: "raw_copy",
|
|
184
|
+
...base,
|
|
185
|
+
allowExistingMatch: record.allowExistingMatch === true,
|
|
186
|
+
effect: record.effect === "copy" || record.effect === "reuse" ? record.effect : undefined,
|
|
187
|
+
mediaType: typeof record.mediaType === "string" ? record.mediaType : "",
|
|
188
|
+
originalFileName: typeof record.originalFileName === "string" ? record.originalFileName : "",
|
|
189
|
+
stageRelativePath,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
case "text_write": {
|
|
193
|
+
const stageRelativePath = parseStoredRequiredStageRelativePath(record);
|
|
194
|
+
if (!stageRelativePath) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const backupRelativePath = parseStoredOptionalBackupRelativePath(record);
|
|
198
|
+
if (backupRelativePath === null) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
const committedPayloadReceipt = parseCommittedPayloadReceipt(record.committedPayloadReceipt);
|
|
202
|
+
if (committedPayloadReceipt === null) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
kind: "text_write",
|
|
207
|
+
...base,
|
|
208
|
+
allowExistingMatch: record.allowExistingMatch === true,
|
|
209
|
+
allowRaw: record.allowRaw === true,
|
|
210
|
+
backupRelativePath,
|
|
211
|
+
committedPayloadReceipt,
|
|
212
|
+
effect: record.effect === "create" || record.effect === "update" || record.effect === "reuse"
|
|
213
|
+
? record.effect
|
|
214
|
+
: undefined,
|
|
215
|
+
overwrite: record.overwrite !== false,
|
|
216
|
+
stageRelativePath,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
case "jsonl_append": {
|
|
220
|
+
const stageRelativePath = parseStoredRequiredStageRelativePath(record);
|
|
221
|
+
if (!stageRelativePath) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const committedPayloadReceipt = parseCommittedPayloadReceipt(record.committedPayloadReceipt);
|
|
225
|
+
if (committedPayloadReceipt === null) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
kind: "jsonl_append",
|
|
230
|
+
...base,
|
|
231
|
+
committedPayloadReceipt,
|
|
232
|
+
effect: record.effect === "append" ? record.effect : undefined,
|
|
233
|
+
originalSize: typeof record.originalSize === "number" && Number.isFinite(record.originalSize)
|
|
234
|
+
? record.originalSize
|
|
235
|
+
: undefined,
|
|
236
|
+
stageRelativePath,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
default:
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
export function isProtectedCanonicalPath(relativePath) {
|
|
244
|
+
let normalizedRelativePath;
|
|
245
|
+
try {
|
|
246
|
+
normalizedRelativePath = normalizeRelativeVaultPath(relativePath);
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
// Raw artifacts stay outside the protected canonical-write set; assistant turns
|
|
252
|
+
// rely on the shared Murph runtime/tool boundary rather than a second workspace guard.
|
|
253
|
+
return (PROTECTED_CANONICAL_ROOT_FILES.has(normalizedRelativePath) ||
|
|
254
|
+
normalizedRelativePath.startsWith(`${VAULT_LAYOUT.journalDirectory}/`) ||
|
|
255
|
+
normalizedRelativePath.startsWith("bank/") ||
|
|
256
|
+
(normalizedRelativePath.startsWith("ledger/") && normalizedRelativePath.endsWith(".jsonl")) ||
|
|
257
|
+
(normalizedRelativePath.startsWith(`${VAULT_LAYOUT.auditDirectory}/`) &&
|
|
258
|
+
normalizedRelativePath.endsWith(".jsonl")));
|
|
259
|
+
}
|
|
260
|
+
export async function listProtectedCanonicalPaths(vaultRoot) {
|
|
261
|
+
const matches = new Set();
|
|
262
|
+
await Promise.all([...PROTECTED_CANONICAL_ROOT_FILES].map(async (relativePath) => {
|
|
263
|
+
if (await pathExists(resolveVaultPath(vaultRoot, relativePath).absolutePath)) {
|
|
264
|
+
matches.add(relativePath);
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
for (const relativeDirectory of [VAULT_LAYOUT.journalDirectory, "bank", "ledger", VAULT_LAYOUT.auditDirectory]) {
|
|
268
|
+
await walkProtectedCanonicalFiles(vaultRoot, relativeDirectory, matches);
|
|
269
|
+
}
|
|
270
|
+
return [...matches].sort();
|
|
271
|
+
}
|
|
272
|
+
async function walkProtectedCanonicalFiles(vaultRoot, relativeDirectory, matches) {
|
|
273
|
+
const absoluteDirectory = resolveVaultPath(vaultRoot, relativeDirectory).absolutePath;
|
|
274
|
+
if (!(await pathExists(absoluteDirectory))) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const entries = await fs.readdir(absoluteDirectory, { withFileTypes: true });
|
|
278
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
279
|
+
for (const entry of entries) {
|
|
280
|
+
const childRelativePath = path.posix.join(relativeDirectory, entry.name);
|
|
281
|
+
if (entry.isDirectory()) {
|
|
282
|
+
await walkProtectedCanonicalFiles(vaultRoot, childRelativePath, matches);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (entry.isFile() && isProtectedCanonicalPath(childRelativePath)) {
|
|
286
|
+
matches.add(childRelativePath);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function parseStoredActions(value) {
|
|
291
|
+
if (!Array.isArray(value)) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
const actions = [];
|
|
295
|
+
for (const candidate of value) {
|
|
296
|
+
const action = parseStoredAction(candidate);
|
|
297
|
+
if (!action) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
actions.push(action);
|
|
301
|
+
}
|
|
302
|
+
return actions;
|
|
303
|
+
}
|
|
304
|
+
function hasMissingCommittedPayloadReceipts(status, actions) {
|
|
305
|
+
return (status === "committed" &&
|
|
306
|
+
actions.some((action) => (action.kind === "text_write" || action.kind === "jsonl_append") &&
|
|
307
|
+
action.committedPayloadReceipt === undefined));
|
|
308
|
+
}
|
|
309
|
+
function parseStoredOperationError(value) {
|
|
310
|
+
return isPlainRecord(value) && typeof value.message === "string"
|
|
311
|
+
? {
|
|
312
|
+
message: value.message,
|
|
313
|
+
code: typeof value.code === "string" ? value.code : undefined,
|
|
314
|
+
}
|
|
315
|
+
: undefined;
|
|
316
|
+
}
|
|
317
|
+
function parseStrictStoredWriteOperation(raw) {
|
|
318
|
+
const actions = parseStoredActions(raw.actions);
|
|
319
|
+
if (raw.schemaVersion !== WRITE_OPERATION_SCHEMA_VERSION ||
|
|
320
|
+
typeof raw.operationId !== "string" ||
|
|
321
|
+
typeof raw.operationType !== "string" ||
|
|
322
|
+
typeof raw.summary !== "string" ||
|
|
323
|
+
!isStoredWriteOperationStatus(raw.status) ||
|
|
324
|
+
typeof raw.createdAt !== "string" ||
|
|
325
|
+
typeof raw.updatedAt !== "string" ||
|
|
326
|
+
typeof raw.occurredAt !== "string" ||
|
|
327
|
+
!actions) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
schemaVersion: WRITE_OPERATION_SCHEMA_VERSION,
|
|
332
|
+
operationId: raw.operationId,
|
|
333
|
+
operationType: raw.operationType,
|
|
334
|
+
summary: raw.summary,
|
|
335
|
+
status: raw.status,
|
|
336
|
+
createdAt: raw.createdAt,
|
|
337
|
+
updatedAt: raw.updatedAt,
|
|
338
|
+
occurredAt: raw.occurredAt,
|
|
339
|
+
actions,
|
|
340
|
+
error: parseStoredOperationError(raw.error),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function parseRecoverableStoredWriteOperationRecord(raw) {
|
|
344
|
+
const actions = parseStoredActions(raw.actions);
|
|
345
|
+
if (typeof raw.operationId !== "string" ||
|
|
346
|
+
typeof raw.createdAt !== "string" ||
|
|
347
|
+
typeof raw.updatedAt !== "string" ||
|
|
348
|
+
typeof raw.status !== "string" ||
|
|
349
|
+
!actions) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
if (hasMissingCommittedPayloadReceipts(raw.status, actions)) {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
operationId: raw.operationId,
|
|
357
|
+
status: raw.status,
|
|
358
|
+
createdAt: raw.createdAt,
|
|
359
|
+
updatedAt: raw.updatedAt,
|
|
360
|
+
actions,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
export async function readStoredWriteOperation(vaultRoot, relativePath) {
|
|
364
|
+
const resolved = resolveVaultPath(vaultRoot, relativePath);
|
|
365
|
+
const raw = JSON.parse(await readText(resolved.absolutePath));
|
|
366
|
+
if (!isPlainRecord(raw)) {
|
|
367
|
+
throw new VaultError("OPERATION_INVALID", "Write operation metadata must be a JSON object.", {
|
|
368
|
+
relativePath,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
const operation = parseStrictStoredWriteOperation(raw);
|
|
372
|
+
if (!operation) {
|
|
373
|
+
throw new VaultError("OPERATION_INVALID", "Write operation metadata has an unexpected shape.", {
|
|
374
|
+
relativePath,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
if (hasMissingCommittedPayloadReceipts(operation.status, operation.actions)) {
|
|
378
|
+
throw new VaultError("OPERATION_INVALID", "Committed write operation metadata is missing committed payload receipts.", {
|
|
379
|
+
relativePath,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return operation;
|
|
383
|
+
}
|
|
384
|
+
export async function readRecoverableStoredWriteOperation(vaultRoot, relativePath) {
|
|
385
|
+
try {
|
|
386
|
+
const resolved = resolveVaultPath(vaultRoot, relativePath);
|
|
387
|
+
const raw = JSON.parse(await readText(resolved.absolutePath));
|
|
388
|
+
return isPlainRecord(raw) ? parseRecoverableStoredWriteOperationRecord(raw) : null;
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
export async function runCanonicalWrite({ vaultRoot, operationType, summary, occurredAt = new Date(), mutate, }) {
|
|
395
|
+
const batch = await WriteBatch.create({
|
|
396
|
+
vaultRoot,
|
|
397
|
+
operationType,
|
|
398
|
+
summary,
|
|
399
|
+
occurredAt,
|
|
400
|
+
});
|
|
401
|
+
let result;
|
|
402
|
+
try {
|
|
403
|
+
result = await mutate({
|
|
404
|
+
batch,
|
|
405
|
+
vaultRoot: batch.vaultRoot,
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
catch (error) {
|
|
409
|
+
await batch.rollback();
|
|
410
|
+
throw error;
|
|
411
|
+
}
|
|
412
|
+
await batch.commit();
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
export class WriteBatch {
|
|
416
|
+
vaultRoot;
|
|
417
|
+
operationId;
|
|
418
|
+
metadataRelativePath;
|
|
419
|
+
stageRootRelativePath;
|
|
420
|
+
metadataAbsolutePath;
|
|
421
|
+
stageRootAbsolutePath;
|
|
422
|
+
record;
|
|
423
|
+
constructor(vaultRoot, record) {
|
|
424
|
+
this.vaultRoot = vaultRoot;
|
|
425
|
+
this.operationId = record.operationId;
|
|
426
|
+
this.metadataRelativePath = metadataRelativePath(record.operationId);
|
|
427
|
+
this.stageRootRelativePath = stageRootRelativePath(record.operationId);
|
|
428
|
+
this.metadataAbsolutePath = resolveVaultPath(vaultRoot, this.metadataRelativePath).absolutePath;
|
|
429
|
+
this.stageRootAbsolutePath = resolveVaultPath(vaultRoot, this.stageRootRelativePath).absolutePath;
|
|
430
|
+
this.record = record;
|
|
431
|
+
}
|
|
432
|
+
static async create({ vaultRoot, operationType, summary, occurredAt = new Date(), }) {
|
|
433
|
+
const absoluteRoot = normalizeVaultRoot(vaultRoot);
|
|
434
|
+
const operationId = generateOperationId();
|
|
435
|
+
const createdAt = nowIso();
|
|
436
|
+
const record = {
|
|
437
|
+
schemaVersion: WRITE_OPERATION_SCHEMA_VERSION,
|
|
438
|
+
operationId,
|
|
439
|
+
operationType: String(operationType).trim() || "write_batch",
|
|
440
|
+
summary: String(summary).trim() || "write_batch",
|
|
441
|
+
status: "staged",
|
|
442
|
+
createdAt,
|
|
443
|
+
updatedAt: createdAt,
|
|
444
|
+
occurredAt: toIsoTimestamp(occurredAt, "occurredAt"),
|
|
445
|
+
actions: [],
|
|
446
|
+
};
|
|
447
|
+
const batch = new WriteBatch(absoluteRoot, record);
|
|
448
|
+
await ensureDirectory(path.dirname(batch.metadataAbsolutePath));
|
|
449
|
+
await ensureDirectory(batch.stageRootAbsolutePath);
|
|
450
|
+
await batch.persist();
|
|
451
|
+
return batch;
|
|
452
|
+
}
|
|
453
|
+
async stageRawCopy({ sourcePath, targetRelativePath, allowExistingMatch = false, originalFileName, mediaType, }) {
|
|
454
|
+
this.assertMutable();
|
|
455
|
+
const normalizedTarget = normalizeRelativeVaultPath(targetRelativePath);
|
|
456
|
+
assertWriteTargetPolicy(normalizedTarget, {
|
|
457
|
+
kind: "raw",
|
|
458
|
+
messages: {
|
|
459
|
+
rawRequired: "Raw copies must target the raw/ tree.",
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
const sourceAbsolutePath = path.resolve(String(sourcePath ?? "").trim());
|
|
463
|
+
if (!(await pathExists(sourceAbsolutePath))) {
|
|
464
|
+
throw new VaultError("VAULT_SOURCE_MISSING", "Raw source file does not exist.");
|
|
465
|
+
}
|
|
466
|
+
const sourceStats = await fs.stat(sourceAbsolutePath);
|
|
467
|
+
if (!sourceStats.isFile()) {
|
|
468
|
+
throw new VaultError("VAULT_SOURCE_INVALID", "Raw source path must point to a file.");
|
|
469
|
+
}
|
|
470
|
+
const stageRelativePath = stageArtifactRelativePath(this.operationId, `${String(this.record.actions.length).padStart(4, "0")}.raw`);
|
|
471
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, stageRelativePath).absolutePath;
|
|
472
|
+
await ensureDirectory(path.dirname(stageAbsolutePath));
|
|
473
|
+
await fs.copyFile(sourceAbsolutePath, stageAbsolutePath);
|
|
474
|
+
this.record.actions.push({
|
|
475
|
+
kind: "raw_copy",
|
|
476
|
+
state: "staged",
|
|
477
|
+
targetRelativePath: normalizedTarget,
|
|
478
|
+
stageRelativePath,
|
|
479
|
+
allowExistingMatch,
|
|
480
|
+
originalFileName,
|
|
481
|
+
mediaType,
|
|
482
|
+
});
|
|
483
|
+
await this.persist();
|
|
484
|
+
return {
|
|
485
|
+
relativePath: normalizedTarget,
|
|
486
|
+
originalFileName,
|
|
487
|
+
mediaType,
|
|
488
|
+
stagedAbsolutePath: stageAbsolutePath,
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
async stageRawText({ targetRelativePath, originalFileName, mediaType, content, allowExistingMatch = false, }) {
|
|
492
|
+
return this.stageRawContent({
|
|
493
|
+
targetRelativePath,
|
|
494
|
+
originalFileName,
|
|
495
|
+
mediaType,
|
|
496
|
+
content,
|
|
497
|
+
allowExistingMatch,
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
async stageRawBytes({ targetRelativePath, originalFileName, mediaType, content, allowExistingMatch = false, }) {
|
|
501
|
+
return this.stageRawContent({
|
|
502
|
+
targetRelativePath,
|
|
503
|
+
originalFileName,
|
|
504
|
+
mediaType,
|
|
505
|
+
content,
|
|
506
|
+
allowExistingMatch,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
async stageRawContent({ targetRelativePath, originalFileName, mediaType, content, allowExistingMatch = false, }) {
|
|
510
|
+
this.assertMutable();
|
|
511
|
+
const normalizedTarget = normalizeRelativeVaultPath(targetRelativePath);
|
|
512
|
+
assertWriteTargetPolicy(normalizedTarget, {
|
|
513
|
+
kind: "raw",
|
|
514
|
+
messages: {
|
|
515
|
+
rawRequired: "Raw copies must target the raw/ tree.",
|
|
516
|
+
},
|
|
517
|
+
});
|
|
518
|
+
const stageRelativePath = stageArtifactRelativePath(this.operationId, `${String(this.record.actions.length).padStart(4, "0")}.raw`);
|
|
519
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, stageRelativePath).absolutePath;
|
|
520
|
+
await ensureDirectory(path.dirname(stageAbsolutePath));
|
|
521
|
+
if (typeof content === "string") {
|
|
522
|
+
await fs.writeFile(stageAbsolutePath, content, "utf8");
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
await fs.writeFile(stageAbsolutePath, content);
|
|
526
|
+
}
|
|
527
|
+
this.record.actions.push({
|
|
528
|
+
kind: "raw_copy",
|
|
529
|
+
state: "staged",
|
|
530
|
+
targetRelativePath: normalizedTarget,
|
|
531
|
+
stageRelativePath,
|
|
532
|
+
allowExistingMatch,
|
|
533
|
+
originalFileName,
|
|
534
|
+
mediaType,
|
|
535
|
+
});
|
|
536
|
+
await this.persist();
|
|
537
|
+
return {
|
|
538
|
+
relativePath: normalizedTarget,
|
|
539
|
+
originalFileName,
|
|
540
|
+
mediaType,
|
|
541
|
+
stagedAbsolutePath: stageAbsolutePath,
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
async stageTextWrite(targetRelativePath, content, options = {}) {
|
|
545
|
+
this.assertMutable();
|
|
546
|
+
const normalizedTarget = normalizeRelativeVaultPath(targetRelativePath);
|
|
547
|
+
assertWriteTargetPolicy(normalizedTarget, {
|
|
548
|
+
kind: "text",
|
|
549
|
+
allowAppendOnlyJsonl: options.allowAppendOnlyJsonl,
|
|
550
|
+
allowRaw: options.allowRaw,
|
|
551
|
+
messages: {
|
|
552
|
+
appendOnlyDisallowed: "Use stageJsonlAppend for ledger and audit shards.",
|
|
553
|
+
rawDisallowed: "Use stageRawCopy for raw artifacts.",
|
|
554
|
+
},
|
|
555
|
+
});
|
|
556
|
+
const stageRelativePath = stageArtifactRelativePath(this.operationId, `${String(this.record.actions.length).padStart(4, "0")}.txt`);
|
|
557
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, stageRelativePath).absolutePath;
|
|
558
|
+
await ensureDirectory(path.dirname(stageAbsolutePath));
|
|
559
|
+
await fs.writeFile(stageAbsolutePath, content, "utf8");
|
|
560
|
+
this.record.actions.push({
|
|
561
|
+
kind: "text_write",
|
|
562
|
+
state: "staged",
|
|
563
|
+
targetRelativePath: normalizedTarget,
|
|
564
|
+
stageRelativePath,
|
|
565
|
+
overwrite: options.overwrite ?? true,
|
|
566
|
+
allowExistingMatch: options.allowExistingMatch ?? false,
|
|
567
|
+
allowRaw: options.allowRaw ?? false,
|
|
568
|
+
});
|
|
569
|
+
await this.persist();
|
|
570
|
+
return normalizedTarget;
|
|
571
|
+
}
|
|
572
|
+
async stageJsonlAppend(targetRelativePath, content) {
|
|
573
|
+
this.assertMutable();
|
|
574
|
+
const normalizedTarget = normalizeRelativeVaultPath(targetRelativePath);
|
|
575
|
+
assertWriteTargetPolicy(normalizedTarget, {
|
|
576
|
+
kind: "jsonl_append",
|
|
577
|
+
messages: {
|
|
578
|
+
appendOnlyDisallowed: "Append-only writes are restricted to JSONL ledger and audit shards.",
|
|
579
|
+
rawDisallowed: "Raw files are immutable once written.",
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
const stageRelativePath = stageArtifactRelativePath(this.operationId, `${String(this.record.actions.length).padStart(4, "0")}.jsonl`);
|
|
583
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, stageRelativePath).absolutePath;
|
|
584
|
+
await ensureDirectory(path.dirname(stageAbsolutePath));
|
|
585
|
+
await fs.writeFile(stageAbsolutePath, content, "utf8");
|
|
586
|
+
this.record.actions.push({
|
|
587
|
+
kind: "jsonl_append",
|
|
588
|
+
state: "staged",
|
|
589
|
+
targetRelativePath: normalizedTarget,
|
|
590
|
+
stageRelativePath,
|
|
591
|
+
});
|
|
592
|
+
await this.persist();
|
|
593
|
+
return normalizedTarget;
|
|
594
|
+
}
|
|
595
|
+
async stageDelete(targetRelativePath, options = {}) {
|
|
596
|
+
this.assertMutable();
|
|
597
|
+
const normalizedTarget = normalizeRelativeVaultPath(targetRelativePath);
|
|
598
|
+
assertWriteTargetPolicy(normalizedTarget, {
|
|
599
|
+
kind: "delete",
|
|
600
|
+
allowAppendOnlyJsonl: options.allowAppendOnlyJsonl,
|
|
601
|
+
messages: {
|
|
602
|
+
appendOnlyDisallowed: "Use stageJsonlAppend for ledger and audit shards.",
|
|
603
|
+
rawDisallowed: "Use stageRawCopy for raw artifacts.",
|
|
604
|
+
},
|
|
605
|
+
});
|
|
606
|
+
this.record.actions.push({
|
|
607
|
+
kind: "delete",
|
|
608
|
+
state: "staged",
|
|
609
|
+
targetRelativePath: normalizedTarget,
|
|
610
|
+
});
|
|
611
|
+
await this.persist();
|
|
612
|
+
return normalizedTarget;
|
|
613
|
+
}
|
|
614
|
+
async commit() {
|
|
615
|
+
this.assertMutable();
|
|
616
|
+
const lock = await acquireCanonicalWriteLock(this.vaultRoot);
|
|
617
|
+
try {
|
|
618
|
+
this.record.status = "committing";
|
|
619
|
+
this.record.updatedAt = nowIso();
|
|
620
|
+
this.record.error = undefined;
|
|
621
|
+
await this.persist();
|
|
622
|
+
for (const [index, action] of this.record.actions.entries()) {
|
|
623
|
+
if (action.state === "applied" || action.state === "reused") {
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
await this.applyAction(index, action);
|
|
627
|
+
}
|
|
628
|
+
this.record.status = "committed";
|
|
629
|
+
this.record.updatedAt = nowIso();
|
|
630
|
+
await this.persist();
|
|
631
|
+
await this.persistGuardReceiptIfConfigured();
|
|
632
|
+
await this.cleanupStageArtifacts();
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
this.record.error = toStoredOperationError(error);
|
|
636
|
+
this.record.updatedAt = nowIso();
|
|
637
|
+
await this.persist();
|
|
638
|
+
try {
|
|
639
|
+
await this.rollbackAppliedActions();
|
|
640
|
+
this.record.status = "rolled_back";
|
|
641
|
+
this.record.updatedAt = nowIso();
|
|
642
|
+
await this.persist();
|
|
643
|
+
await this.cleanupStageArtifacts();
|
|
644
|
+
}
|
|
645
|
+
catch (rollbackError) {
|
|
646
|
+
this.record.status = "failed";
|
|
647
|
+
this.record.error = toStoredOperationError(rollbackError);
|
|
648
|
+
this.record.updatedAt = nowIso();
|
|
649
|
+
await this.persist();
|
|
650
|
+
}
|
|
651
|
+
throw error;
|
|
652
|
+
}
|
|
653
|
+
finally {
|
|
654
|
+
await lock.release();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
async rollback() {
|
|
658
|
+
this.assertMutable();
|
|
659
|
+
const lock = await acquireCanonicalWriteLock(this.vaultRoot);
|
|
660
|
+
try {
|
|
661
|
+
await this.rollbackAppliedActions();
|
|
662
|
+
this.record.status = "rolled_back";
|
|
663
|
+
this.record.updatedAt = nowIso();
|
|
664
|
+
this.record.error = undefined;
|
|
665
|
+
await this.persist();
|
|
666
|
+
await this.cleanupStageArtifacts();
|
|
667
|
+
}
|
|
668
|
+
finally {
|
|
669
|
+
await lock.release();
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
assertMutable() {
|
|
673
|
+
if (isTerminalWriteOperationStatus(this.record.status) || this.record.status === "failed") {
|
|
674
|
+
throw new VaultError("OPERATION_STATE_INVALID", `Write batch "${this.operationId}" can no longer be modified after status "${this.record.status}".`);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
async persist() {
|
|
678
|
+
await writeTextFileAtomic(this.metadataAbsolutePath, `${JSON.stringify(this.record, null, 2)}\n`);
|
|
679
|
+
}
|
|
680
|
+
async cleanupStageArtifacts() {
|
|
681
|
+
await fs.rm(this.stageRootAbsolutePath, { recursive: true, force: true });
|
|
682
|
+
}
|
|
683
|
+
async persistGuardReceiptIfConfigured() {
|
|
684
|
+
const receiptRoot = resolveGuardReceiptDirectoryFromEnv();
|
|
685
|
+
if (!receiptRoot) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
const actions = [];
|
|
689
|
+
await ensureDirectory(receiptRoot);
|
|
690
|
+
for (const [index, action] of this.record.actions.entries()) {
|
|
691
|
+
if (!isProtectedCanonicalPath(action.targetRelativePath)) {
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
if (action.kind === "delete") {
|
|
695
|
+
actions.push({
|
|
696
|
+
kind: "delete",
|
|
697
|
+
targetRelativePath: action.targetRelativePath,
|
|
698
|
+
});
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (action.kind !== "text_write" && action.kind !== "jsonl_append") {
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
const payloadReceipt = action.committedPayloadReceipt;
|
|
705
|
+
if (!payloadReceipt) {
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
const payloadDirectory = path.join(receiptRoot, this.operationId);
|
|
709
|
+
const payloadFileName = `${String(index).padStart(4, "0")}.${action.kind === "text_write" ? "txt" : "jsonl"}`;
|
|
710
|
+
const payloadAbsolutePath = path.join(payloadDirectory, payloadFileName);
|
|
711
|
+
const payloadRelativePath = path.posix.join(this.operationId, payloadFileName);
|
|
712
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, action.stageRelativePath).absolutePath;
|
|
713
|
+
await ensureDirectory(payloadDirectory);
|
|
714
|
+
await fs.copyFile(stageAbsolutePath, payloadAbsolutePath);
|
|
715
|
+
actions.push({
|
|
716
|
+
kind: action.kind,
|
|
717
|
+
targetRelativePath: action.targetRelativePath,
|
|
718
|
+
committedPayloadReceipt: payloadReceipt,
|
|
719
|
+
payloadRelativePath,
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
if (actions.length === 0) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const receipt = {
|
|
726
|
+
schemaVersion: WRITE_OPERATION_GUARD_RECEIPT_SCHEMA_VERSION,
|
|
727
|
+
operationId: this.operationId,
|
|
728
|
+
createdAt: this.record.createdAt,
|
|
729
|
+
updatedAt: this.record.updatedAt,
|
|
730
|
+
actions,
|
|
731
|
+
};
|
|
732
|
+
await fs.writeFile(path.join(receiptRoot, `${this.operationId}.json`), `${JSON.stringify(receipt, null, 2)}\n`, "utf8");
|
|
733
|
+
}
|
|
734
|
+
async applyAction(index, action) {
|
|
735
|
+
if (action.kind === "raw_copy") {
|
|
736
|
+
await this.applyRawCopy(action);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
if (action.kind === "text_write") {
|
|
740
|
+
await this.applyTextWrite(index, action);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
if (action.kind === "jsonl_append") {
|
|
744
|
+
await this.applyJsonlAppend(action);
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
await this.applyDelete(index, action);
|
|
748
|
+
}
|
|
749
|
+
async applyRawCopy(action) {
|
|
750
|
+
const target = await prepareVerifiedWriteTarget(this.vaultRoot, action.targetRelativePath);
|
|
751
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, action.stageRelativePath).absolutePath;
|
|
752
|
+
const stagedContent = await fs.readFile(stageAbsolutePath);
|
|
753
|
+
const result = await applyImmutableWriteTarget({
|
|
754
|
+
allowExistingMatch: action.allowExistingMatch,
|
|
755
|
+
createEffect: "copy",
|
|
756
|
+
createTarget: () => copyFileAtomicExclusive(stageAbsolutePath, target.absolutePath),
|
|
757
|
+
existsErrorMessage: "Raw target already exists and may not be overwritten.",
|
|
758
|
+
matchesExistingContent: async () => {
|
|
759
|
+
const existingContent = await fs.readFile(target.absolutePath);
|
|
760
|
+
return existingContent.equals(stagedContent);
|
|
761
|
+
},
|
|
762
|
+
target,
|
|
763
|
+
});
|
|
764
|
+
action.state = result.effect === "reuse" ? "reused" : "applied";
|
|
765
|
+
action.effect = result.effect === "reuse" ? "reuse" : "copy";
|
|
766
|
+
action.existedBefore = result.existedBefore;
|
|
767
|
+
action.appliedAt = nowIso();
|
|
768
|
+
this.record.updatedAt = action.appliedAt;
|
|
769
|
+
await this.persist();
|
|
770
|
+
}
|
|
771
|
+
async applyTextWrite(index, action) {
|
|
772
|
+
const target = await prepareVerifiedWriteTarget(this.vaultRoot, action.targetRelativePath);
|
|
773
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, action.stageRelativePath).absolutePath;
|
|
774
|
+
const stagedContent = await readText(stageAbsolutePath);
|
|
775
|
+
const result = await applyTextWriteTarget({
|
|
776
|
+
allowExistingMatch: action.allowExistingMatch,
|
|
777
|
+
backupExisting: action.overwrite
|
|
778
|
+
? async () => {
|
|
779
|
+
const backupRelativePath = action.backupRelativePath ??
|
|
780
|
+
backupArtifactRelativePath(this.operationId, `${String(index).padStart(4, "0")}.bak`);
|
|
781
|
+
await this.ensureBackupArtifactExists(target.absolutePath, backupRelativePath);
|
|
782
|
+
action.backupRelativePath = backupRelativePath;
|
|
783
|
+
}
|
|
784
|
+
: undefined,
|
|
785
|
+
createTarget: () => copyFileAtomicExclusive(stageAbsolutePath, target.absolutePath),
|
|
786
|
+
matchesExistingContent: async () => {
|
|
787
|
+
const existingContent = await readText(target.absolutePath);
|
|
788
|
+
return existingContent === stagedContent;
|
|
789
|
+
},
|
|
790
|
+
overwrite: action.overwrite,
|
|
791
|
+
replaceTarget: () => copyFileAtomic(stageAbsolutePath, target.absolutePath),
|
|
792
|
+
target,
|
|
793
|
+
});
|
|
794
|
+
action.state = result.effect === "reuse" ? "reused" : "applied";
|
|
795
|
+
action.effect = result.effect;
|
|
796
|
+
action.existedBefore = result.existedBefore;
|
|
797
|
+
action.committedPayloadReceipt = createCommittedPayloadReceipt(stagedContent);
|
|
798
|
+
action.appliedAt = nowIso();
|
|
799
|
+
this.record.updatedAt = action.appliedAt;
|
|
800
|
+
await this.persist();
|
|
801
|
+
}
|
|
802
|
+
async applyJsonlAppend(action) {
|
|
803
|
+
const target = await prepareVerifiedWriteTarget(this.vaultRoot, action.targetRelativePath);
|
|
804
|
+
const stageAbsolutePath = resolveVaultPath(this.vaultRoot, action.stageRelativePath).absolutePath;
|
|
805
|
+
const payload = await readText(stageAbsolutePath);
|
|
806
|
+
const result = await applyJsonlAppendTarget({
|
|
807
|
+
appendPayload: (payload) => fs.appendFile(target.absolutePath, payload, "utf8"),
|
|
808
|
+
readPayload: async () => payload,
|
|
809
|
+
target,
|
|
810
|
+
});
|
|
811
|
+
action.state = "applied";
|
|
812
|
+
action.effect = result.effect;
|
|
813
|
+
action.existedBefore = result.existedBefore;
|
|
814
|
+
action.originalSize = result.originalSize;
|
|
815
|
+
action.committedPayloadReceipt = createCommittedPayloadReceipt(payload);
|
|
816
|
+
action.appliedAt = nowIso();
|
|
817
|
+
this.record.updatedAt = action.appliedAt;
|
|
818
|
+
await this.persist();
|
|
819
|
+
}
|
|
820
|
+
async applyDelete(index, action) {
|
|
821
|
+
const target = await prepareVerifiedWriteTarget(this.vaultRoot, action.targetRelativePath);
|
|
822
|
+
const existedBefore = await pathExists(target.absolutePath);
|
|
823
|
+
if (!existedBefore) {
|
|
824
|
+
action.state = "reused";
|
|
825
|
+
action.effect = "delete";
|
|
826
|
+
action.existedBefore = false;
|
|
827
|
+
action.appliedAt = nowIso();
|
|
828
|
+
this.record.updatedAt = action.appliedAt;
|
|
829
|
+
await this.persist();
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
const backupRelativePath = backupArtifactRelativePath(this.operationId, `${String(index).padStart(4, "0")}.bak`);
|
|
833
|
+
await this.ensureBackupArtifactExists(target.absolutePath, backupRelativePath);
|
|
834
|
+
await fs.unlink(target.absolutePath);
|
|
835
|
+
action.state = "applied";
|
|
836
|
+
action.effect = "delete";
|
|
837
|
+
action.existedBefore = true;
|
|
838
|
+
action.backupRelativePath = backupRelativePath;
|
|
839
|
+
action.appliedAt = nowIso();
|
|
840
|
+
this.record.updatedAt = action.appliedAt;
|
|
841
|
+
await this.persist();
|
|
842
|
+
}
|
|
843
|
+
async rollbackAppliedActions() {
|
|
844
|
+
for (const action of [...this.record.actions].reverse()) {
|
|
845
|
+
if (action.state !== "applied") {
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
if (action.kind === "raw_copy") {
|
|
849
|
+
await safeUnlink(resolveVaultPath(this.vaultRoot, action.targetRelativePath).absolutePath);
|
|
850
|
+
}
|
|
851
|
+
else if (action.kind === "text_write") {
|
|
852
|
+
if (action.effect === "create") {
|
|
853
|
+
await safeUnlink(resolveVaultPath(this.vaultRoot, action.targetRelativePath).absolutePath);
|
|
854
|
+
}
|
|
855
|
+
else if (action.backupRelativePath) {
|
|
856
|
+
const targetAbsolutePath = resolveVaultPath(this.vaultRoot, action.targetRelativePath).absolutePath;
|
|
857
|
+
const backupAbsolutePath = resolveVaultPath(this.vaultRoot, action.backupRelativePath).absolutePath;
|
|
858
|
+
await copyFileAtomic(backupAbsolutePath, targetAbsolutePath);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
else if (action.kind === "jsonl_append") {
|
|
862
|
+
const targetAbsolutePath = resolveVaultPath(this.vaultRoot, action.targetRelativePath).absolutePath;
|
|
863
|
+
if (!action.existedBefore) {
|
|
864
|
+
await safeUnlink(targetAbsolutePath);
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
await fs.truncate(targetAbsolutePath, action.originalSize ?? 0);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
else if (action.kind === "delete" && action.backupRelativePath) {
|
|
871
|
+
const targetAbsolutePath = resolveVaultPath(this.vaultRoot, action.targetRelativePath).absolutePath;
|
|
872
|
+
const backupAbsolutePath = resolveVaultPath(this.vaultRoot, action.backupRelativePath).absolutePath;
|
|
873
|
+
await copyFileAtomic(backupAbsolutePath, targetAbsolutePath);
|
|
874
|
+
}
|
|
875
|
+
action.state = "rolled_back";
|
|
876
|
+
action.rolledBackAt = nowIso();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
async ensureBackupArtifactExists(sourceAbsolutePath, backupRelativePath) {
|
|
880
|
+
const backupAbsolutePath = resolveVaultPath(this.vaultRoot, backupRelativePath).absolutePath;
|
|
881
|
+
if (!(await pathExists(backupAbsolutePath))) {
|
|
882
|
+
await copyFileAtomicExclusive(sourceAbsolutePath, backupAbsolutePath);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
//# sourceMappingURL=write-batch.js.map
|