wicked-crew 0.18.19 → 0.18.21
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/README.md +9 -6
- package/dist/api/ask-paths.d.ts +2 -0
- package/dist/api/ask-paths.d.ts.map +1 -1
- package/dist/api/ask-paths.js +6 -0
- package/dist/api/ask-paths.js.map +1 -1
- package/dist/api/auth.d.ts +7 -5
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +23 -9
- package/dist/api/auth.js.map +1 -1
- package/dist/api/capture.d.ts +5 -2
- package/dist/api/capture.d.ts.map +1 -1
- package/dist/api/capture.js +13 -10
- package/dist/api/capture.js.map +1 -1
- package/dist/api/chat-attachments.d.ts.map +1 -1
- package/dist/api/chat-attachments.js +69 -19
- package/dist/api/chat-attachments.js.map +1 -1
- package/dist/api/chat-citations.d.ts.map +1 -1
- package/dist/api/chat-citations.js +22 -0
- package/dist/api/chat-citations.js.map +1 -1
- package/dist/api/chat-context.d.ts +16 -1
- package/dist/api/chat-context.d.ts.map +1 -1
- package/dist/api/chat-context.js +75 -14
- package/dist/api/chat-context.js.map +1 -1
- package/dist/api/chat-freshness.js +2 -2
- package/dist/api/chat-freshness.js.map +1 -1
- package/dist/api/chat-history.d.ts +13 -0
- package/dist/api/chat-history.d.ts.map +1 -1
- package/dist/api/chat-history.js +25 -0
- package/dist/api/chat-history.js.map +1 -1
- package/dist/api/chat-jobs.d.ts +67 -6
- package/dist/api/chat-jobs.d.ts.map +1 -1
- package/dist/api/chat-jobs.js +243 -22
- package/dist/api/chat-jobs.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +69 -6
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +310 -49
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-requirements.d.ts.map +1 -1
- package/dist/api/chat-requirements.js +4 -1
- package/dist/api/chat-requirements.js.map +1 -1
- package/dist/api/chat-scope.d.ts +17 -9
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +55 -21
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/cluster-status.d.ts +24 -12
- package/dist/api/cluster-status.d.ts.map +1 -1
- package/dist/api/cluster-status.js +82 -4
- package/dist/api/cluster-status.js.map +1 -1
- package/dist/api/codebase-archive.d.ts +4 -3
- package/dist/api/codebase-archive.d.ts.map +1 -1
- package/dist/api/codebase-archive.js +6 -5
- package/dist/api/codebase-archive.js.map +1 -1
- package/dist/api/delivery-cache.d.ts +2 -0
- package/dist/api/delivery-cache.d.ts.map +1 -1
- package/dist/api/delivery-cache.js +1 -2
- package/dist/api/delivery-cache.js.map +1 -1
- package/dist/api/delivery-index.d.ts +2 -2
- package/dist/api/delivery-index.d.ts.map +1 -1
- package/dist/api/delivery-index.js +1 -2
- package/dist/api/delivery-index.js.map +1 -1
- package/dist/api/eval-compare.d.ts +1 -1
- package/dist/api/eval-compare.js +1 -1
- package/dist/api/eval-sample.d.ts +7 -0
- package/dist/api/eval-sample.d.ts.map +1 -1
- package/dist/api/eval-sample.js +20 -0
- package/dist/api/eval-sample.js.map +1 -1
- package/dist/api/gate-cache.d.ts +1 -0
- package/dist/api/gate-cache.d.ts.map +1 -1
- package/dist/api/gate-cache.js +19 -6
- package/dist/api/gate-cache.js.map +1 -1
- package/dist/api/governance-steering.d.ts +17 -4
- package/dist/api/governance-steering.d.ts.map +1 -1
- package/dist/api/governance-steering.js +56 -7
- package/dist/api/governance-steering.js.map +1 -1
- package/dist/api/mcp.d.ts +12 -2
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +56 -12
- package/dist/api/mcp.js.map +1 -1
- package/dist/api/needs.d.ts +20 -0
- package/dist/api/needs.d.ts.map +1 -1
- package/dist/api/needs.js +120 -19
- package/dist/api/needs.js.map +1 -1
- package/dist/api/onboarding-capture.d.ts +21 -1
- package/dist/api/onboarding-capture.d.ts.map +1 -1
- package/dist/api/onboarding-capture.js +112 -8
- package/dist/api/onboarding-capture.js.map +1 -1
- package/dist/api/policy-landing.d.ts +36 -0
- package/dist/api/policy-landing.d.ts.map +1 -1
- package/dist/api/policy-landing.js +123 -4
- package/dist/api/policy-landing.js.map +1 -1
- package/dist/api/post-hoc-deliver.d.ts.map +1 -1
- package/dist/api/post-hoc-deliver.js +2 -1
- package/dist/api/post-hoc-deliver.js.map +1 -1
- package/dist/api/product.d.ts +1 -1
- package/dist/api/proposal-decisions.d.ts +44 -0
- package/dist/api/proposal-decisions.d.ts.map +1 -0
- package/dist/api/proposal-decisions.js +85 -0
- package/dist/api/proposal-decisions.js.map +1 -0
- package/dist/api/proposal-onboard.d.ts +38 -1
- package/dist/api/proposal-onboard.d.ts.map +1 -1
- package/dist/api/proposal-onboard.js +203 -14
- package/dist/api/proposal-onboard.js.map +1 -1
- package/dist/api/recording.d.ts +1 -1
- package/dist/api/recording.d.ts.map +1 -1
- package/dist/api/recording.js +4 -5
- package/dist/api/recording.js.map +1 -1
- package/dist/api/redeliver.d.ts.map +1 -1
- package/dist/api/redeliver.js +11 -7
- package/dist/api/redeliver.js.map +1 -1
- package/dist/api/repo-input.d.ts.map +1 -1
- package/dist/api/repo-input.js +5 -2
- package/dist/api/repo-input.js.map +1 -1
- package/dist/api/repo-origins.d.ts +24 -0
- package/dist/api/repo-origins.d.ts.map +1 -0
- package/dist/api/repo-origins.js +71 -0
- package/dist/api/repo-origins.js.map +1 -0
- package/dist/api/requirements.d.ts +37 -16
- package/dist/api/requirements.d.ts.map +1 -1
- package/dist/api/requirements.js +73 -2
- package/dist/api/requirements.js.map +1 -1
- package/dist/api/retry-index.d.ts +2 -0
- package/dist/api/retry-index.d.ts.map +1 -1
- package/dist/api/retry-index.js +16 -8
- package/dist/api/retry-index.js.map +1 -1
- package/dist/api/review-change.d.ts +5 -6
- package/dist/api/review-change.d.ts.map +1 -1
- package/dist/api/review-change.js +45 -8
- package/dist/api/review-change.js.map +1 -1
- package/dist/api/roster-standing.d.ts +2 -0
- package/dist/api/roster-standing.d.ts.map +1 -1
- package/dist/api/roster-standing.js +8 -1
- package/dist/api/roster-standing.js.map +1 -1
- package/dist/api/routes.d.ts +55 -12
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +961 -277
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-documents.d.ts +9 -1
- package/dist/api/run-documents.d.ts.map +1 -1
- package/dist/api/run-documents.js +63 -5
- package/dist/api/run-documents.js.map +1 -1
- package/dist/api/run-sources.d.ts +11 -1
- package/dist/api/run-sources.d.ts.map +1 -1
- package/dist/api/run-sources.js +26 -3
- package/dist/api/run-sources.js.map +1 -1
- package/dist/api/run-timing-index.d.ts +47 -0
- package/dist/api/run-timing-index.d.ts.map +1 -1
- package/dist/api/run-timing-index.js +196 -86
- package/dist/api/run-timing-index.js.map +1 -1
- package/dist/api/runtime-state.d.ts +6 -0
- package/dist/api/runtime-state.d.ts.map +1 -1
- package/dist/api/runtime-state.js +14 -3
- package/dist/api/runtime-state.js.map +1 -1
- package/dist/api/seat-agents.d.ts.map +1 -1
- package/dist/api/seat-agents.js +3 -3
- package/dist/api/seat-agents.js.map +1 -1
- package/dist/api/seat-container-login.d.ts +6 -2
- package/dist/api/seat-container-login.d.ts.map +1 -1
- package/dist/api/seat-container-login.js +17 -9
- package/dist/api/seat-container-login.js.map +1 -1
- package/dist/api/seat-governance.d.ts +3 -2
- package/dist/api/seat-governance.d.ts.map +1 -1
- package/dist/api/seat-governance.js +31 -9
- package/dist/api/seat-governance.js.map +1 -1
- package/dist/api/seat-standing.d.ts +8 -0
- package/dist/api/seat-standing.d.ts.map +1 -1
- package/dist/api/seat-standing.js +26 -1
- package/dist/api/seat-standing.js.map +1 -1
- package/dist/api/server.d.ts +7 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +172 -59
- package/dist/api/server.js.map +1 -1
- package/dist/api/stall-watchdog.d.ts +6 -0
- package/dist/api/stall-watchdog.d.ts.map +1 -1
- package/dist/api/stall-watchdog.js +28 -0
- package/dist/api/stall-watchdog.js.map +1 -1
- package/dist/api/start-on-login.d.ts +4 -0
- package/dist/api/start-on-login.d.ts.map +1 -0
- package/dist/api/start-on-login.js +35 -0
- package/dist/api/start-on-login.js.map +1 -0
- package/dist/api/steering-landing.d.ts +33 -8
- package/dist/api/steering-landing.d.ts.map +1 -1
- package/dist/api/steering-landing.js +235 -51
- package/dist/api/steering-landing.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +5 -0
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +22 -10
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/testing.d.ts +2 -2
- package/dist/api/ui-text.js +2 -2
- package/dist/api/ui-text.js.map +1 -1
- package/dist/api/worktree-sweep.d.ts +7 -3
- package/dist/api/worktree-sweep.d.ts.map +1 -1
- package/dist/api/worktree-sweep.js +10 -6
- package/dist/api/worktree-sweep.js.map +1 -1
- package/dist/apps/actions/api-action.js +5 -2
- package/dist/apps/actions/api-action.js.map +1 -1
- package/dist/apps/actions/write-path.d.ts +9 -0
- package/dist/apps/actions/write-path.d.ts.map +1 -1
- package/dist/apps/actions/write-path.js +17 -9
- package/dist/apps/actions/write-path.js.map +1 -1
- package/dist/apps/exec/executor.d.ts +8 -15
- package/dist/apps/exec/executor.d.ts.map +1 -1
- package/dist/apps/exec/executor.js +10 -3
- package/dist/apps/exec/executor.js.map +1 -1
- package/dist/apps/exec/recall.d.ts.map +1 -1
- package/dist/apps/exec/recall.js +4 -4
- package/dist/apps/exec/recall.js.map +1 -1
- package/dist/apps/exec/redescribe.d.ts +37 -0
- package/dist/apps/exec/redescribe.d.ts.map +1 -0
- package/dist/apps/exec/redescribe.js +86 -0
- package/dist/apps/exec/redescribe.js.map +1 -0
- package/dist/apps/exec/source-stage.d.ts +3 -1
- package/dist/apps/exec/source-stage.d.ts.map +1 -1
- package/dist/apps/exec/source-stage.js +13 -3
- package/dist/apps/exec/source-stage.js.map +1 -1
- package/dist/apps/exec/sources.d.ts +6 -0
- package/dist/apps/exec/sources.d.ts.map +1 -1
- package/dist/apps/exec/sources.js +8 -0
- package/dist/apps/exec/sources.js.map +1 -1
- package/dist/apps/git.js +2 -2
- package/dist/apps/git.js.map +1 -1
- package/dist/apps/publish/manifest.d.ts +8 -1
- package/dist/apps/publish/manifest.d.ts.map +1 -1
- package/dist/apps/publish/manifest.js +14 -3
- package/dist/apps/publish/manifest.js.map +1 -1
- package/dist/apps/publish/run.d.ts +15 -2
- package/dist/apps/publish/run.d.ts.map +1 -1
- package/dist/apps/publish/run.js +100 -17
- package/dist/apps/publish/run.js.map +1 -1
- package/dist/apps/routes.d.ts +3 -0
- package/dist/apps/routes.d.ts.map +1 -1
- package/dist/apps/routes.js +58 -2
- package/dist/apps/routes.js.map +1 -1
- package/dist/apps/store.d.ts +24 -3
- package/dist/apps/store.d.ts.map +1 -1
- package/dist/apps/store.js +26 -9
- package/dist/apps/store.js.map +1 -1
- package/dist/apps/turns.d.ts +25 -2
- package/dist/apps/turns.d.ts.map +1 -1
- package/dist/apps/turns.js +276 -11
- package/dist/apps/turns.js.map +1 -1
- package/dist/apps-server/Dockerfile +2 -2
- package/dist/apps-server/runners/sqlite-runner.mjs +67 -12
- package/dist/apps-server/server/lib/bundle/server.mjs +353 -159
- package/dist/cli/governance.d.ts +5 -2
- package/dist/cli/governance.d.ts.map +1 -1
- package/dist/cli/governance.js +8 -5
- package/dist/cli/governance.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +6 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/service.d.ts +10 -6
- package/dist/cli/service.d.ts.map +1 -1
- package/dist/cli/service.js +39 -23
- package/dist/cli/service.js.map +1 -1
- package/dist/core/adapter.d.ts +61 -29
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +214 -83
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/ado-deliver-helper.d.ts +2 -1
- package/dist/core/ado-deliver-helper.d.ts.map +1 -1
- package/dist/core/ado-deliver-helper.js +26 -1
- package/dist/core/ado-deliver-helper.js.map +1 -1
- package/dist/core/assurance.d.ts +45 -42
- package/dist/core/assurance.d.ts.map +1 -1
- package/dist/core/assurance.js +74 -67
- package/dist/core/assurance.js.map +1 -1
- package/dist/core/deliver-text.d.ts +14 -0
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +41 -2
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts +66 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +183 -10
- package/dist/core/deliver.js.map +1 -1
- package/dist/core/engine-roster.d.ts +2 -0
- package/dist/core/engine-roster.d.ts.map +1 -1
- package/dist/core/engine-roster.js +13 -0
- package/dist/core/engine-roster.js.map +1 -1
- package/dist/core/estate-mcp-client.d.ts +13 -14
- package/dist/core/estate-mcp-client.d.ts.map +1 -1
- package/dist/core/estate-mcp-client.js +49 -68
- package/dist/core/estate-mcp-client.js.map +1 -1
- package/dist/core/exec.d.ts +24 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +45 -2
- package/dist/core/exec.js.map +1 -1
- package/dist/core/linked-issues.d.ts +13 -2
- package/dist/core/linked-issues.d.ts.map +1 -1
- package/dist/core/linked-issues.js +135 -4
- package/dist/core/linked-issues.js.map +1 -1
- package/dist/core/pr-checks-helper.d.ts +8 -4
- package/dist/core/pr-checks-helper.d.ts.map +1 -1
- package/dist/core/pr-checks-helper.js +39 -17
- package/dist/core/pr-checks-helper.js.map +1 -1
- package/dist/core/redeliver.js +2 -2
- package/dist/core/redeliver.js.map +1 -1
- package/dist/core/repo-clone.d.ts +64 -0
- package/dist/core/repo-clone.d.ts.map +1 -0
- package/dist/core/repo-clone.js +306 -0
- package/dist/core/repo-clone.js.map +1 -0
- package/dist/core/repoPaths.d.ts +2 -4
- package/dist/core/repoPaths.d.ts.map +1 -1
- package/dist/core/repoPaths.js +4 -6
- package/dist/core/repoPaths.js.map +1 -1
- package/dist/core/run-identity.d.ts.map +1 -1
- package/dist/core/run-identity.js +3 -0
- package/dist/core/run-identity.js.map +1 -1
- package/dist/core/run-read-lane.d.ts +30 -0
- package/dist/core/run-read-lane.d.ts.map +1 -0
- package/dist/core/run-read-lane.js +103 -0
- package/dist/core/run-read-lane.js.map +1 -0
- package/dist/core/types.d.ts +10 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/walkthrough-root.d.ts.map +1 -1
- package/dist/core/walkthrough-root.js +3 -5
- package/dist/core/walkthrough-root.js.map +1 -1
- package/dist/core/wicked-home.d.ts +9 -0
- package/dist/core/wicked-home.d.ts.map +1 -0
- package/dist/core/wicked-home.js +25 -0
- package/dist/core/wicked-home.js.map +1 -0
- package/dist/decisions/consider.d.ts +2 -1
- package/dist/decisions/consider.d.ts.map +1 -1
- package/dist/decisions/consider.js +2 -2
- package/dist/decisions/consider.js.map +1 -1
- package/dist/decisions/land.d.ts +2 -0
- package/dist/decisions/land.d.ts.map +1 -1
- package/dist/decisions/land.js +16 -3
- package/dist/decisions/land.js.map +1 -1
- package/dist/decisions/rules-brief.d.ts +4 -1
- package/dist/decisions/rules-brief.d.ts.map +1 -1
- package/dist/decisions/rules-brief.js +3 -2
- package/dist/decisions/rules-brief.js.map +1 -1
- package/dist/editors/conformance-runtime.d.ts +0 -2
- package/dist/editors/conformance-runtime.d.ts.map +1 -1
- package/dist/editors/conformance-runtime.js +0 -4
- package/dist/editors/conformance-runtime.js.map +1 -1
- package/dist/editors/csp.d.ts +6 -0
- package/dist/editors/csp.d.ts.map +1 -1
- package/dist/editors/csp.js +10 -0
- package/dist/editors/csp.js.map +1 -1
- package/dist/editors/pack-install.d.ts +11 -15
- package/dist/editors/pack-install.d.ts.map +1 -1
- package/dist/editors/pack-install.js +52 -65
- package/dist/editors/pack-install.js.map +1 -1
- package/dist/editors/registry.d.ts +31 -13
- package/dist/editors/registry.d.ts.map +1 -1
- package/dist/editors/registry.js +51 -18
- package/dist/editors/registry.js.map +1 -1
- package/dist/editors/routes.d.ts +4 -2
- package/dist/editors/routes.d.ts.map +1 -1
- package/dist/editors/routes.js +23 -6
- package/dist/editors/routes.js.map +1 -1
- package/dist/editors/visuals.d.ts +4 -3
- package/dist/editors/visuals.d.ts.map +1 -1
- package/dist/editors/visuals.js +17 -7
- package/dist/editors/visuals.js.map +1 -1
- package/dist/evals/runner.js +1 -1
- package/dist/evals/runner.js.map +1 -1
- package/dist/evals/shape-corrections.js +1 -1
- package/dist/evals/shape-corrections.js.map +1 -1
- package/dist/evals/shape.d.ts +7 -1
- package/dist/evals/shape.d.ts.map +1 -1
- package/dist/evals/shape.js +26 -6
- package/dist/evals/shape.js.map +1 -1
- package/dist/evals/workflow.d.ts +16 -3
- package/dist/evals/workflow.d.ts.map +1 -1
- package/dist/evals/workflow.js +32 -6
- package/dist/evals/workflow.js.map +1 -1
- package/dist/governance/rule-revision.d.ts +7 -0
- package/dist/governance/rule-revision.d.ts.map +1 -0
- package/dist/governance/rule-revision.js +23 -0
- package/dist/governance/rule-revision.js.map +1 -0
- package/dist/insights/review-service.d.ts +26 -3
- package/dist/insights/review-service.d.ts.map +1 -1
- package/dist/insights/review-service.js +101 -11
- package/dist/insights/review-service.js.map +1 -1
- package/dist/insights/routes.d.ts +2 -1
- package/dist/insights/routes.d.ts.map +1 -1
- package/dist/insights/routes.js +19 -4
- package/dist/insights/routes.js.map +1 -1
- package/dist/insights/run-facts.d.ts +5 -0
- package/dist/insights/run-facts.d.ts.map +1 -1
- package/dist/insights/run-facts.js +15 -0
- package/dist/insights/run-facts.js.map +1 -1
- package/dist/insights/workflow.d.ts +2 -1
- package/dist/insights/workflow.d.ts.map +1 -1
- package/dist/insights/workflow.js +4 -4
- package/dist/insights/workflow.js.map +1 -1
- package/dist/inspect/service.d.ts +3 -2
- package/dist/inspect/service.d.ts.map +1 -1
- package/dist/inspect/service.js +4 -4
- package/dist/inspect/service.js.map +1 -1
- package/dist/interactive/bridge-pool.d.ts +2 -0
- package/dist/interactive/bridge-pool.d.ts.map +1 -1
- package/dist/interactive/bridge-pool.js +18 -8
- package/dist/interactive/bridge-pool.js.map +1 -1
- package/dist/interactive/chat-events.d.ts +3 -0
- package/dist/interactive/chat-events.d.ts.map +1 -1
- package/dist/interactive/chat-events.js +20 -5
- package/dist/interactive/chat-events.js.map +1 -1
- package/dist/interactive/doc-delete-routes.d.ts +1 -0
- package/dist/interactive/doc-delete-routes.d.ts.map +1 -1
- package/dist/interactive/doc-delete-routes.js +126 -123
- package/dist/interactive/doc-delete-routes.js.map +1 -1
- package/dist/interactive/draft-events.d.ts +11 -7
- package/dist/interactive/draft-events.d.ts.map +1 -1
- package/dist/interactive/draft-events.js +29 -22
- package/dist/interactive/draft-events.js.map +1 -1
- package/dist/interactive/draft-skill.d.ts +56 -3
- package/dist/interactive/draft-skill.d.ts.map +1 -1
- package/dist/interactive/draft-skill.js +129 -20
- package/dist/interactive/draft-skill.js.map +1 -1
- package/dist/interactive/landing-guard.d.ts +30 -5
- package/dist/interactive/landing-guard.d.ts.map +1 -1
- package/dist/interactive/landing-guard.js +121 -5
- package/dist/interactive/landing-guard.js.map +1 -1
- package/dist/interactive/proposal-create.d.ts +9 -11
- package/dist/interactive/proposal-create.d.ts.map +1 -1
- package/dist/interactive/proposal-create.js +28 -21
- package/dist/interactive/proposal-create.js.map +1 -1
- package/dist/interactive/proposal-refine.d.ts +4 -4
- package/dist/interactive/proposal-refine.d.ts.map +1 -1
- package/dist/interactive/proposal-refine.js +40 -7
- package/dist/interactive/proposal-refine.js.map +1 -1
- package/dist/interactive/proxy-routes.d.ts +10 -5
- package/dist/interactive/proxy-routes.d.ts.map +1 -1
- package/dist/interactive/proxy-routes.js +108 -11
- package/dist/interactive/proxy-routes.js.map +1 -1
- package/dist/interactive/review-events.js +1 -1
- package/dist/interactive/review-events.js.map +1 -1
- package/dist/interactive/run-units.d.ts.map +1 -1
- package/dist/interactive/run-units.js +3 -2
- package/dist/interactive/run-units.js.map +1 -1
- package/dist/interactive/source-packet.d.ts +13 -1
- package/dist/interactive/source-packet.d.ts.map +1 -1
- package/dist/interactive/source-packet.js +108 -34
- package/dist/interactive/source-packet.js.map +1 -1
- package/dist/knowledge/adapters/toolbox/memory.d.ts +2 -0
- package/dist/knowledge/adapters/toolbox/memory.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/memory.js +43 -0
- package/dist/knowledge/adapters/toolbox/memory.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts +30 -4
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -1
- package/dist/knowledge/adapters/toolbox/supervisor.js +112 -28
- package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -1
- package/dist/knowledge/estate-write.d.ts +5 -0
- package/dist/knowledge/estate-write.d.ts.map +1 -1
- package/dist/knowledge/estate-write.js +7 -0
- package/dist/knowledge/estate-write.js.map +1 -1
- package/dist/knowledge/gate/gate.d.ts.map +1 -1
- package/dist/knowledge/gate/gate.js +4 -1
- package/dist/knowledge/gate/gate.js.map +1 -1
- package/dist/knowledge/gate/record.d.ts +15 -2
- package/dist/knowledge/gate/record.d.ts.map +1 -1
- package/dist/knowledge/gate/record.js +108 -29
- package/dist/knowledge/gate/record.js.map +1 -1
- package/dist/knowledge/projector.d.ts +60 -5
- package/dist/knowledge/projector.d.ts.map +1 -1
- package/dist/knowledge/projector.js +264 -21
- package/dist/knowledge/projector.js.map +1 -1
- package/dist/knowledge/registry/entry.d.ts +7 -0
- package/dist/knowledge/registry/entry.d.ts.map +1 -1
- package/dist/knowledge/registry/entry.js +4 -0
- package/dist/knowledge/registry/entry.js.map +1 -1
- package/dist/knowledge/shapes/map.d.ts.map +1 -1
- package/dist/knowledge/shapes/map.js +12 -2
- package/dist/knowledge/shapes/map.js.map +1 -1
- package/dist/knowledge/shapes/routes.d.ts +1 -1
- package/dist/knowledge/shapes/routes.d.ts.map +1 -1
- package/dist/knowledge/shapes/routes.js +42 -16
- package/dist/knowledge/shapes/routes.js.map +1 -1
- package/dist/knowledge/shapes/shapes.d.ts +60 -13
- package/dist/knowledge/shapes/shapes.d.ts.map +1 -1
- package/dist/knowledge/shapes/shapes.js +199 -31
- package/dist/knowledge/shapes/shapes.js.map +1 -1
- package/dist/knowledge/shapes/verified.d.ts.map +1 -1
- package/dist/knowledge/shapes/verified.js +3 -2
- package/dist/knowledge/shapes/verified.js.map +1 -1
- package/dist/knowledge/trackers/addresses.d.ts +27 -3
- package/dist/knowledge/trackers/addresses.d.ts.map +1 -1
- package/dist/knowledge/trackers/addresses.js +33 -5
- package/dist/knowledge/trackers/addresses.js.map +1 -1
- package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -1
- package/dist/knowledge/trackers/gate-pm.js +4 -2
- package/dist/knowledge/trackers/gate-pm.js.map +1 -1
- package/dist/knowledge/trackers/projector.d.ts +3 -1
- package/dist/knowledge/trackers/projector.d.ts.map +1 -1
- package/dist/knowledge/trackers/projector.js +59 -8
- package/dist/knowledge/trackers/projector.js.map +1 -1
- package/dist/learn/scheduler.d.ts.map +1 -1
- package/dist/learn/scheduler.js +13 -3
- package/dist/learn/scheduler.js.map +1 -1
- package/dist/learnings/estate.d.ts.map +1 -1
- package/dist/learnings/estate.js +3 -14
- package/dist/learnings/estate.js.map +1 -1
- package/dist/learnings/extract.d.ts +9 -3
- package/dist/learnings/extract.d.ts.map +1 -1
- package/dist/learnings/extract.js +62 -4
- package/dist/learnings/extract.js.map +1 -1
- package/dist/learnings/replacement-lineage.d.ts +3 -2
- package/dist/learnings/replacement-lineage.d.ts.map +1 -1
- package/dist/learnings/replacement-lineage.js +7 -6
- package/dist/learnings/replacement-lineage.js.map +1 -1
- package/dist/learnings/service.d.ts +12 -2
- package/dist/learnings/service.d.ts.map +1 -1
- package/dist/learnings/service.js +30 -5
- package/dist/learnings/service.js.map +1 -1
- package/dist/mcp/broker.d.ts.map +1 -1
- package/dist/mcp/broker.js +19 -5
- package/dist/mcp/broker.js.map +1 -1
- package/dist/mcp/env.d.ts +12 -4
- package/dist/mcp/env.d.ts.map +1 -1
- package/dist/mcp/env.js +24 -4
- package/dist/mcp/env.js.map +1 -1
- package/dist/mcp/estate-relay.d.ts +3 -0
- package/dist/mcp/estate-relay.d.ts.map +1 -1
- package/dist/mcp/estate-relay.js +7 -6
- package/dist/mcp/estate-relay.js.map +1 -1
- package/dist/mcp/invoke.d.ts.map +1 -1
- package/dist/mcp/invoke.js +6 -5
- package/dist/mcp/invoke.js.map +1 -1
- package/dist/mcp/probe.d.ts +14 -1
- package/dist/mcp/probe.d.ts.map +1 -1
- package/dist/mcp/probe.js +55 -10
- package/dist/mcp/probe.js.map +1 -1
- package/dist/mcp/redact.d.ts +1 -1
- package/dist/mcp/redact.d.ts.map +1 -1
- package/dist/mcp/redact.js +61 -4
- package/dist/mcp/redact.js.map +1 -1
- package/dist/mcp/registry-store.d.ts +37 -0
- package/dist/mcp/registry-store.d.ts.map +1 -1
- package/dist/mcp/registry-store.js +43 -0
- package/dist/mcp/registry-store.js.map +1 -1
- package/dist/mcp/registry.d.ts +38 -6
- package/dist/mcp/registry.d.ts.map +1 -1
- package/dist/mcp/registry.js +145 -14
- package/dist/mcp/registry.js.map +1 -1
- package/dist/mcp/rest.js +4 -4
- package/dist/mcp/rest.js.map +1 -1
- package/dist/mcp/run-fence.d.ts +2 -0
- package/dist/mcp/run-fence.d.ts.map +1 -1
- package/dist/mcp/run-fence.js +9 -0
- package/dist/mcp/run-fence.js.map +1 -1
- package/dist/mcp/secrets.d.ts +1 -1
- package/dist/mcp/secrets.d.ts.map +1 -1
- package/dist/mcp/secrets.js +10 -11
- package/dist/mcp/secrets.js.map +1 -1
- package/dist/mcp/upstream-error.d.ts +6 -2
- package/dist/mcp/upstream-error.d.ts.map +1 -1
- package/dist/mcp/upstream-error.js +5 -1
- package/dist/mcp/upstream-error.js.map +1 -1
- package/dist/projects/graph.d.ts +15 -5
- package/dist/projects/graph.d.ts.map +1 -1
- package/dist/projects/graph.js +354 -26
- package/dist/projects/graph.js.map +1 -1
- package/dist/projects/repo-watch.d.ts +2 -2
- package/dist/projects/repo-watch.d.ts.map +1 -1
- package/dist/projects/repo-watch.js +26 -9
- package/dist/projects/repo-watch.js.map +1 -1
- package/dist/projects/routes.d.ts +9 -1
- package/dist/projects/routes.d.ts.map +1 -1
- package/dist/projects/routes.js +63 -6
- package/dist/projects/routes.js.map +1 -1
- package/dist/projects/state-home-preflight.d.ts +5 -0
- package/dist/projects/state-home-preflight.d.ts.map +1 -1
- package/dist/projects/state-home-preflight.js +48 -8
- package/dist/projects/state-home-preflight.js.map +1 -1
- package/dist/projects/state-home-registry.d.ts.map +1 -1
- package/dist/projects/state-home-registry.js +9 -0
- package/dist/projects/state-home-registry.js.map +1 -1
- package/dist/projects/state-home.d.ts +11 -0
- package/dist/projects/state-home.d.ts.map +1 -1
- package/dist/projects/state-home.js +14 -0
- package/dist/projects/state-home.js.map +1 -1
- package/dist/qe/author-workflow.d.ts +4 -0
- package/dist/qe/author-workflow.d.ts.map +1 -1
- package/dist/qe/author-workflow.js +4 -0
- package/dist/qe/author-workflow.js.map +1 -1
- package/dist/qe/test-sets.d.ts +5 -6
- package/dist/qe/test-sets.d.ts.map +1 -1
- package/dist/qe/test-sets.js +4 -3
- package/dist/qe/test-sets.js.map +1 -1
- package/dist/schedules/routes.d.ts +5 -0
- package/dist/schedules/routes.d.ts.map +1 -1
- package/dist/schedules/routes.js +32 -5
- package/dist/schedules/routes.js.map +1 -1
- package/dist/schedules/scheduler.d.ts +8 -1
- package/dist/schedules/scheduler.d.ts.map +1 -1
- package/dist/schedules/scheduler.js +10 -1
- package/dist/schedules/scheduler.js.map +1 -1
- package/dist/schedules/store.d.ts +7 -0
- package/dist/schedules/store.d.ts.map +1 -1
- package/dist/schedules/store.js +19 -4
- package/dist/schedules/store.js.map +1 -1
- package/dist/skills/plugin-source.js +4 -4
- package/dist/skills/plugin-source.js.map +1 -1
- package/dist/sources/ask.d.ts.map +1 -1
- package/dist/sources/ask.js +12 -12
- package/dist/sources/ask.js.map +1 -1
- package/dist/sources/dialer.d.ts +6 -1
- package/dist/sources/dialer.d.ts.map +1 -1
- package/dist/sources/dialer.js +53 -31
- package/dist/sources/dialer.js.map +1 -1
- package/dist/sources/drivers/mysql.d.ts +2 -0
- package/dist/sources/drivers/mysql.d.ts.map +1 -1
- package/dist/sources/drivers/mysql.js +18 -2
- package/dist/sources/drivers/mysql.js.map +1 -1
- package/dist/sources/drivers/postgres.d.ts +2 -0
- package/dist/sources/drivers/postgres.d.ts.map +1 -1
- package/dist/sources/drivers/postgres.js +10 -3
- package/dist/sources/drivers/postgres.js.map +1 -1
- package/dist/sources/drivers/sqlite.d.ts +33 -3
- package/dist/sources/drivers/sqlite.d.ts.map +1 -1
- package/dist/sources/drivers/sqlite.js +18 -6
- package/dist/sources/drivers/sqlite.js.map +1 -1
- package/dist/sources/drivers/types.d.ts +3 -1
- package/dist/sources/drivers/types.d.ts.map +1 -1
- package/dist/sources/drivers/types.js +3 -1
- package/dist/sources/drivers/types.js.map +1 -1
- package/dist/sources/routes.d.ts.map +1 -1
- package/dist/sources/routes.js +1 -0
- package/dist/sources/routes.js.map +1 -1
- package/dist/sources/uploads.d.ts +22 -15
- package/dist/sources/uploads.d.ts.map +1 -1
- package/dist/sources/uploads.js +124 -436
- package/dist/sources/uploads.js.map +1 -1
- package/dist/standing-orders/history.d.ts +5 -3
- package/dist/standing-orders/history.d.ts.map +1 -1
- package/dist/standing-orders/history.js +6 -2
- package/dist/standing-orders/history.js.map +1 -1
- package/dist/standing-orders/parse.d.ts +8 -0
- package/dist/standing-orders/parse.d.ts.map +1 -1
- package/dist/standing-orders/parse.js +52 -5
- package/dist/standing-orders/parse.js.map +1 -1
- package/dist/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/apps-standalone/runtime.js +1 -1
- package/dist/studio/assets/{KnowledgeGraph-DWw0I8RJ.js → KnowledgeGraph-yP4WsnST.js} +1 -1
- package/dist/studio/assets/index-DNaLjJ7M.css +32 -0
- package/dist/studio/assets/index-DW53FKuT.js +1114 -0
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +2 -2
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +2 -2
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +1 -1
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +1589 -281
- package/dist/team/routes.d.ts +11 -1
- package/dist/team/routes.d.ts.map +1 -1
- package/dist/team/routes.js +8 -4
- package/dist/team/routes.js.map +1 -1
- package/dist/voice/tts.d.ts +12 -0
- package/dist/voice/tts.d.ts.map +1 -1
- package/dist/voice/tts.js +118 -28
- package/dist/voice/tts.js.map +1 -1
- package/dist/workflow-catalog/build-v2.d.ts +34 -0
- package/dist/workflow-catalog/build-v2.d.ts.map +1 -1
- package/dist/workflow-catalog/build-v2.js +131 -10
- package/dist/workflow-catalog/build-v2.js.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.d.ts +6 -2
- package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.js.map +1 -1
- package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data.js +0 -2
- package/dist/workflow-catalog/catalog-data.js.map +1 -1
- package/dist/workflow-catalog/detect.d.ts +18 -3
- package/dist/workflow-catalog/detect.d.ts.map +1 -1
- package/dist/workflow-catalog/detect.js +43 -8
- package/dist/workflow-catalog/detect.js.map +1 -1
- package/dist/workflow-catalog/shape.d.ts +1 -1
- package/dist/working-doc/event-lines.d.ts +12 -2
- package/dist/working-doc/event-lines.d.ts.map +1 -1
- package/dist/working-doc/event-lines.js +62 -10
- package/dist/working-doc/event-lines.js.map +1 -1
- package/dist/working-doc/sections.d.ts +3 -0
- package/dist/working-doc/sections.d.ts.map +1 -1
- package/dist/working-doc/sections.js +5 -0
- package/dist/working-doc/sections.js.map +1 -1
- package/dist/working-doc/service.d.ts +23 -3
- package/dist/working-doc/service.d.ts.map +1 -1
- package/dist/working-doc/service.js +93 -54
- package/dist/working-doc/service.js.map +1 -1
- package/endpoint-manifest.json +148 -8
- package/evals/corpora/shape-v1.json +25 -1
- package/evals/corpora/shape-v1.seat-fixture.json +25 -1
- package/package.json +4 -4
- package/runners/sqlite-runner.mjs +67 -12
- package/runners/upload-parse.d.mts +13 -0
- package/runners/upload-parse.mjs +364 -0
- package/dist/studio/assets/index-C4Xj-zxa.css +0 -32
- package/dist/studio/assets/index-CrNY3d06.js +0 -1109
package/dist/sources/uploads.js
CHANGED
|
@@ -4,22 +4,26 @@
|
|
|
4
4
|
* `<state home>/mcp/snapshots/<sha256>.sqlite` — outside any git repo (an app repo holds only the
|
|
5
5
|
* digest) and inside the state-home entry workers are fenced out of.
|
|
6
6
|
*
|
|
7
|
-
* - CSV/XLSX: parsed
|
|
8
|
-
* becomes `col_1…`),
|
|
7
|
+
* - CSV/XLSX: parsed in the killable runner child (crew#1289), header detected (a first row that
|
|
8
|
+
* looks like data becomes `col_1…`), types inferred (INTEGER, REAL, TEXT), written to a SQLite file.
|
|
9
9
|
* The first 20 rows are returned for the PERSON's sheet only (the route never gives them to an agent).
|
|
10
10
|
* - XLSX is a zip: entries are inflated with a hard output cap, so a file that expands past 200 MB is
|
|
11
11
|
* refused before it is held (a zip bomb). Zip64, encryption and unknown methods are refused.
|
|
12
|
-
* - `.sqlite`: refused if it holds a view
|
|
13
|
-
*
|
|
12
|
+
* - `.sqlite`: refused if it holds a view or a trigger (§5.1), inspected in the snapshot runner's child
|
|
13
|
+
* process, never in the daemon. A virtual table (a full-text index, an R-tree) is dropped from crew's copy
|
|
14
|
+
* with its shadow tables, in the same child, and the result names it (crew#1731); one whose module this
|
|
15
|
+
* SQLite lacks cannot be dropped, and the file is refused naming it. Every copy is then rewritten with
|
|
16
|
+
* VACUUM INTO, so no snapshot keeps the file's free pages (crew#1787).
|
|
17
|
+
* - A crash mid-upload leaves its `.tmp-*` files behind: each upload starts a sweep (one at a time, never awaited) that
|
|
18
|
+
* removes the ones older than {@link STALE_TMP_MS} and not a live upload's (crew#1724).
|
|
14
19
|
* - Limits: 50 MB file, 200 MB after decompression, 1,000,000 rows, 200 columns, 30 s to parse.
|
|
15
20
|
*/
|
|
16
21
|
import { createHash, randomUUID } from 'node:crypto';
|
|
17
|
-
import { chmod, mkdir, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
22
|
+
import { chmod, mkdir, readdir, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
18
23
|
import { homedir } from 'node:os';
|
|
19
24
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
20
|
-
import { inflateRawSync } from 'node:zlib';
|
|
21
25
|
import { mcpStateDir } from '../mcp/registry-store.js';
|
|
22
|
-
import {
|
|
26
|
+
import { isRunnerFailure, sqliteIngest, sqliteInspect, sqliteStrip } from './drivers/sqlite.js';
|
|
23
27
|
import { SourceQueryError } from './drivers/types.js';
|
|
24
28
|
export const UPLOAD_LIMITS = Object.freeze({
|
|
25
29
|
fileBytes: 50 * 1024 * 1024,
|
|
@@ -52,417 +56,60 @@ export function snapshotPath(digest, dir = snapshotDir()) {
|
|
|
52
56
|
throw new UploadError('bad_digest', 'a snapshot digest is 64 hex characters');
|
|
53
57
|
return join(dir, `${digest}.sqlite`);
|
|
54
58
|
}
|
|
55
|
-
// ── CSV ──────────────────────────────────────────────────────────────────────────────────────
|
|
56
|
-
function detectDelimiter(text) {
|
|
57
|
-
// The first record, with quoted fields taken out (a quoted field may hold any delimiter).
|
|
58
|
-
let first = '';
|
|
59
|
-
let quoted = false;
|
|
60
|
-
for (let i = 0; i < text.length && i < 1_000_000; i++) {
|
|
61
|
-
const c = text[i];
|
|
62
|
-
if (c === '"')
|
|
63
|
-
quoted = !quoted;
|
|
64
|
-
else if (!quoted && (c === '\n' || c === '\r'))
|
|
65
|
-
break;
|
|
66
|
-
else if (!quoted)
|
|
67
|
-
first += c;
|
|
68
|
-
}
|
|
69
|
-
const counts = [',', ';', '\t'].map((d) => [d, first.split(d).length]);
|
|
70
|
-
return counts.sort((a, b) => b[1] - a[1])[0]?.[0] ?? ',';
|
|
71
|
-
}
|
|
72
|
-
/** RFC 4180 rows (quoted fields, doubled quotes, CRLF or LF), bounded by the limits. */
|
|
73
|
-
export function parseCsv(text, deadline) {
|
|
74
|
-
const d = detectDelimiter(text);
|
|
75
|
-
const rows = [];
|
|
76
|
-
let row = [];
|
|
77
|
-
let field = '';
|
|
78
|
-
let i = 0;
|
|
79
|
-
let quoted = false;
|
|
80
|
-
const n = text.length;
|
|
81
|
-
const endRow = () => {
|
|
82
|
-
row.push(field);
|
|
83
|
-
field = '';
|
|
84
|
-
if (!(row.length === 1 && row[0] === '')) {
|
|
85
|
-
if (row.length > UPLOAD_LIMITS.columns)
|
|
86
|
-
throw new UploadError('too_many_columns', `the file has more than ${UPLOAD_LIMITS.columns} columns`);
|
|
87
|
-
rows.push(row);
|
|
88
|
-
if (rows.length > UPLOAD_LIMITS.rows + 1)
|
|
89
|
-
throw new UploadError('too_many_rows', `the file has more than ${UPLOAD_LIMITS.rows} rows`);
|
|
90
|
-
if (rows.length % 10_000 === 0 && Date.now() > deadline)
|
|
91
|
-
throw new UploadError('too_slow', `the file took more than ${UPLOAD_LIMITS.parseMs / 1000} s to parse`);
|
|
92
|
-
}
|
|
93
|
-
row = [];
|
|
94
|
-
};
|
|
95
|
-
while (i < n) {
|
|
96
|
-
if ((i & 0xffff) === 0 && Date.now() > deadline)
|
|
97
|
-
throw new UploadError('too_slow', `the file took more than ${UPLOAD_LIMITS.parseMs / 1000} s to parse`);
|
|
98
|
-
const c = text[i];
|
|
99
|
-
if (quoted) {
|
|
100
|
-
if (c === '"') {
|
|
101
|
-
if (text[i + 1] === '"') {
|
|
102
|
-
field += '"';
|
|
103
|
-
i += 2;
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
quoted = false;
|
|
107
|
-
i++;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
field += c;
|
|
111
|
-
i++;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (c === '"' && field === '') {
|
|
115
|
-
quoted = true;
|
|
116
|
-
i++;
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
if (c === d) {
|
|
120
|
-
row.push(field);
|
|
121
|
-
field = '';
|
|
122
|
-
if (row.length > UPLOAD_LIMITS.columns)
|
|
123
|
-
throw new UploadError('too_many_columns', `the file has more than ${UPLOAD_LIMITS.columns} columns`);
|
|
124
|
-
i++;
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (c === '\r' && text[i + 1] === '\n') {
|
|
128
|
-
endRow();
|
|
129
|
-
i += 2;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
if (c === '\n' || c === '\r') {
|
|
133
|
-
endRow();
|
|
134
|
-
i++;
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
field += c;
|
|
138
|
-
i++;
|
|
139
|
-
}
|
|
140
|
-
if (quoted)
|
|
141
|
-
throw new UploadError('bad_csv', 'the file ends inside a quoted field');
|
|
142
|
-
if (field !== '' || row.length > 0)
|
|
143
|
-
endRow();
|
|
144
|
-
return rows;
|
|
145
|
-
}
|
|
146
|
-
function zipEntries(buf) {
|
|
147
|
-
const min = Math.max(0, buf.length - 65_557);
|
|
148
|
-
let eocd = -1;
|
|
149
|
-
for (let i = buf.length - 22; i >= min; i--) {
|
|
150
|
-
if (buf.readUInt32LE(i) === 0x06054b50) {
|
|
151
|
-
eocd = i;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (eocd < 0)
|
|
156
|
-
throw new UploadError('bad_xlsx', 'the file is not an XLSX workbook (no zip directory)');
|
|
157
|
-
const count = buf.readUInt16LE(eocd + 10);
|
|
158
|
-
const cdSize = buf.readUInt32LE(eocd + 12);
|
|
159
|
-
const cdOffset = buf.readUInt32LE(eocd + 16);
|
|
160
|
-
if (count === 0xffff || cdOffset === 0xffffffff || cdSize === 0xffffffff)
|
|
161
|
-
throw new UploadError('bad_xlsx', 'zip64 workbooks are not supported');
|
|
162
|
-
if (cdOffset + cdSize > buf.length)
|
|
163
|
-
throw new UploadError('bad_xlsx', 'the zip directory points past the end of the file');
|
|
164
|
-
const out = [];
|
|
165
|
-
let p = cdOffset;
|
|
166
|
-
for (let k = 0; k < count; k++) {
|
|
167
|
-
if (p + 46 > buf.length || buf.readUInt32LE(p) !== 0x02014b50)
|
|
168
|
-
throw new UploadError('bad_xlsx', 'a damaged zip directory');
|
|
169
|
-
const flags = buf.readUInt16LE(p + 8);
|
|
170
|
-
const method = buf.readUInt16LE(p + 10);
|
|
171
|
-
const compressedSize = buf.readUInt32LE(p + 20);
|
|
172
|
-
const size = buf.readUInt32LE(p + 24);
|
|
173
|
-
const nameLen = buf.readUInt16LE(p + 28);
|
|
174
|
-
const extraLen = buf.readUInt16LE(p + 30);
|
|
175
|
-
const commentLen = buf.readUInt16LE(p + 32);
|
|
176
|
-
const localOffset = buf.readUInt32LE(p + 42);
|
|
177
|
-
const name = buf.subarray(p + 46, p + 46 + nameLen).toString('utf8');
|
|
178
|
-
out.push({ name, method, flags, compressedSize, size, localOffset });
|
|
179
|
-
p += 46 + nameLen + extraLen + commentLen;
|
|
180
|
-
}
|
|
181
|
-
return out;
|
|
182
|
-
}
|
|
183
|
-
class ZipReader {
|
|
184
|
-
buf;
|
|
185
|
-
entries;
|
|
186
|
-
expanded = 0;
|
|
187
|
-
constructor(buf, entries) {
|
|
188
|
-
this.buf = buf;
|
|
189
|
-
this.entries = entries;
|
|
190
|
-
}
|
|
191
|
-
has(name) {
|
|
192
|
-
return this.entries.some((e) => e.name === name);
|
|
193
|
-
}
|
|
194
|
-
/** One entry's bytes, inflated with the remaining expansion budget as a HARD cap. */
|
|
195
|
-
read(name) {
|
|
196
|
-
const e = this.entries.find((x) => x.name === name);
|
|
197
|
-
if (e === undefined)
|
|
198
|
-
throw new UploadError('bad_xlsx', `the workbook has no ${name}`);
|
|
199
|
-
if ((e.flags & 0x1) !== 0)
|
|
200
|
-
throw new UploadError('bad_xlsx', 'encrypted workbooks are not supported');
|
|
201
|
-
const p = e.localOffset;
|
|
202
|
-
if (p + 30 > this.buf.length || this.buf.readUInt32LE(p) !== 0x04034b50)
|
|
203
|
-
throw new UploadError('bad_xlsx', 'a damaged zip entry');
|
|
204
|
-
const start = p + 30 + this.buf.readUInt16LE(p + 26) + this.buf.readUInt16LE(p + 28);
|
|
205
|
-
const data = this.buf.subarray(start, start + e.compressedSize);
|
|
206
|
-
const budget = UPLOAD_LIMITS.expandedBytes - this.expanded;
|
|
207
|
-
if (e.size > budget)
|
|
208
|
-
throw new UploadError('too_large', `the workbook expands past ${UPLOAD_LIMITS.expandedBytes / (1024 * 1024)} MB`);
|
|
209
|
-
let bytes;
|
|
210
|
-
if (e.method === 0)
|
|
211
|
-
bytes = Buffer.from(data);
|
|
212
|
-
else if (e.method === 8) {
|
|
213
|
-
try {
|
|
214
|
-
bytes = inflateRawSync(data, { maxOutputLength: Math.max(1, budget) });
|
|
215
|
-
}
|
|
216
|
-
catch (err) {
|
|
217
|
-
const code = err.code;
|
|
218
|
-
if (code === 'ERR_BUFFER_TOO_LARGE' || /buffer|too large|maxOutputLength/i.test(String(err.message))) {
|
|
219
|
-
throw new UploadError('too_large', `the workbook expands past ${UPLOAD_LIMITS.expandedBytes / (1024 * 1024)} MB`);
|
|
220
|
-
}
|
|
221
|
-
throw new UploadError('bad_xlsx', `a zip entry could not be inflated: ${err.message}`);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else
|
|
225
|
-
throw new UploadError('bad_xlsx', `zip method ${e.method} is not supported`);
|
|
226
|
-
this.expanded += bytes.length;
|
|
227
|
-
if (this.expanded > UPLOAD_LIMITS.expandedBytes)
|
|
228
|
-
throw new UploadError('too_large', `the workbook expands past ${UPLOAD_LIMITS.expandedBytes / (1024 * 1024)} MB`);
|
|
229
|
-
return bytes.toString('utf8');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function xmlText(s) {
|
|
233
|
-
return s
|
|
234
|
-
.replace(/&#x([0-9a-fA-F]+);/g, (_m, h) => String.fromCodePoint(parseInt(h, 16)))
|
|
235
|
-
.replace(/&#(\d+);/g, (_m, d) => String.fromCodePoint(Number(d)))
|
|
236
|
-
.replace(/</g, '<')
|
|
237
|
-
.replace(/>/g, '>')
|
|
238
|
-
.replace(/"/g, '"')
|
|
239
|
-
.replace(/'/g, "'")
|
|
240
|
-
.replace(/&/g, '&');
|
|
241
|
-
}
|
|
242
|
-
function attr(tag, name) {
|
|
243
|
-
const m = new RegExp(`\\s${name}="([^"]*)"`).exec(tag);
|
|
244
|
-
return m === null ? null : xmlText(m[1]);
|
|
245
|
-
}
|
|
246
|
-
function colIndex(ref) {
|
|
247
|
-
const letters = /^([A-Z]+)/.exec(ref)?.[1] ?? 'A';
|
|
248
|
-
let n = 0;
|
|
249
|
-
for (const ch of letters)
|
|
250
|
-
n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
251
|
-
return n - 1;
|
|
252
|
-
}
|
|
253
|
-
function* elements(xml, tag, withHead = false) {
|
|
254
|
-
const open = `<${tag}`;
|
|
255
|
-
const close = `</${tag}>`;
|
|
256
|
-
let at = 0;
|
|
257
|
-
for (;;) {
|
|
258
|
-
let i = xml.indexOf(open, at);
|
|
259
|
-
while (i >= 0 && !/[\s>/]/.test(xml[i + open.length] ?? ''))
|
|
260
|
-
i = xml.indexOf(open, i + 1);
|
|
261
|
-
if (i < 0)
|
|
262
|
-
return;
|
|
263
|
-
const headEnd = xml.indexOf('>', i);
|
|
264
|
-
if (headEnd < 0)
|
|
265
|
-
return;
|
|
266
|
-
const head = xml.slice(i, headEnd + 1);
|
|
267
|
-
if (head.endsWith('/>')) {
|
|
268
|
-
yield withHead ? { head, body: '' } : '';
|
|
269
|
-
at = headEnd + 1;
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
const end = xml.indexOf(close, headEnd + 1);
|
|
273
|
-
if (end < 0)
|
|
274
|
-
return;
|
|
275
|
-
const body = xml.slice(headEnd + 1, end);
|
|
276
|
-
yield withHead ? { head, body } : body;
|
|
277
|
-
at = end + close.length;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
/** The concatenated text of every `<t>` in a fragment (a shared string's runs, an inline string). */
|
|
281
|
-
function texts(fragment) {
|
|
282
|
-
let out = '';
|
|
283
|
-
for (const t of elements(fragment, 't'))
|
|
284
|
-
out += xmlText(t);
|
|
285
|
-
return out;
|
|
286
|
-
}
|
|
287
|
-
/** The first sheet of an XLSX workbook as rows of strings. */
|
|
288
|
-
export function parseXlsx(buf, deadline) {
|
|
289
|
-
const zip = new ZipReader(buf, zipEntries(buf));
|
|
290
|
-
const workbook = zip.read('xl/workbook.xml');
|
|
291
|
-
const sheetTag = /<sheet\b[^>]*>/.exec(workbook)?.[0];
|
|
292
|
-
if (sheetTag === undefined)
|
|
293
|
-
throw new UploadError('bad_xlsx', 'the workbook has no sheet');
|
|
294
|
-
const rid = attr(sheetTag, 'r:id');
|
|
295
|
-
const rels = zip.read('xl/_rels/workbook.xml.rels');
|
|
296
|
-
let target = 'worksheets/sheet1.xml';
|
|
297
|
-
for (const m of rels.matchAll(/<Relationship\b[^>]*>/g))
|
|
298
|
-
if (attr(m[0], 'Id') === rid)
|
|
299
|
-
target = attr(m[0], 'Target') ?? target;
|
|
300
|
-
const sheetPath = target.startsWith('/') ? target.slice(1) : `xl/${target.replace(/^\.\//, '')}`;
|
|
301
|
-
// Every scan below is linear (indexOf from a moving cursor, never a lazy regex over the rest of the
|
|
302
|
-
// text), so a hostile sheet of unclosed tags costs one pass, not one pass per tag.
|
|
303
|
-
const shared = [];
|
|
304
|
-
if (zip.has('xl/sharedStrings.xml')) {
|
|
305
|
-
const sst = zip.read('xl/sharedStrings.xml');
|
|
306
|
-
let sharedBytes = 0;
|
|
307
|
-
for (const si of elements(sst, 'si')) {
|
|
308
|
-
if ((shared.length & 0x3ff) === 0)
|
|
309
|
-
within(deadline);
|
|
310
|
-
const t = texts(si);
|
|
311
|
-
sharedBytes += t.length;
|
|
312
|
-
if (sharedBytes > UPLOAD_LIMITS.expandedBytes)
|
|
313
|
-
throw new UploadError('too_large', `the workbook's strings expand past ${UPLOAD_LIMITS.expandedBytes / (1024 * 1024)} MB`);
|
|
314
|
-
shared.push(t);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
const sheet = zip.read(sheetPath);
|
|
318
|
-
const rows = [];
|
|
319
|
-
// Shared strings are referenced, not copied: count what the cells hold once resolved, so a small
|
|
320
|
-
// sheet repeating one large string cannot become a snapshot far past the expansion limit.
|
|
321
|
-
let cellBytes = 0;
|
|
322
|
-
let cells = 0;
|
|
323
|
-
for (const rowXml of elements(sheet, 'row')) {
|
|
324
|
-
const row = [];
|
|
325
|
-
for (const cell of elements(rowXml, 'c', true)) {
|
|
326
|
-
// Every cell counts toward the deadline, so one row of a million cells cannot outrun it.
|
|
327
|
-
if ((++cells & 0xfff) === 0)
|
|
328
|
-
within(deadline);
|
|
329
|
-
const ref = attr(cell.head, 'r');
|
|
330
|
-
const t = attr(cell.head, 't');
|
|
331
|
-
const inner = cell.body;
|
|
332
|
-
const vStart = inner.indexOf('<v>');
|
|
333
|
-
const vEnd = vStart < 0 ? -1 : inner.indexOf('</v>', vStart + 3);
|
|
334
|
-
const v = vStart < 0 || vEnd < 0 ? undefined : inner.slice(vStart + 3, vEnd);
|
|
335
|
-
let value = '';
|
|
336
|
-
if (t === 's')
|
|
337
|
-
value = shared[Number(v)] ?? '';
|
|
338
|
-
else if (t === 'inlineStr')
|
|
339
|
-
value = texts(inner);
|
|
340
|
-
else if (t === 'b')
|
|
341
|
-
value = v === '1' ? 'true' : 'false';
|
|
342
|
-
else if (v !== undefined)
|
|
343
|
-
value = xmlText(v);
|
|
344
|
-
const idx = ref === null ? row.length : colIndex(ref);
|
|
345
|
-
if (idx >= UPLOAD_LIMITS.columns)
|
|
346
|
-
throw new UploadError('too_many_columns', `the sheet has more than ${UPLOAD_LIMITS.columns} columns`);
|
|
347
|
-
while (row.length < idx)
|
|
348
|
-
row.push('');
|
|
349
|
-
row[idx] = value;
|
|
350
|
-
cellBytes += value.length;
|
|
351
|
-
if (cellBytes > UPLOAD_LIMITS.expandedBytes)
|
|
352
|
-
throw new UploadError('too_large', `the sheet's values expand past ${UPLOAD_LIMITS.expandedBytes / (1024 * 1024)} MB`);
|
|
353
|
-
}
|
|
354
|
-
if (row.length > 0 && row.some((c) => c !== ''))
|
|
355
|
-
rows.push(row);
|
|
356
|
-
if (rows.length > UPLOAD_LIMITS.rows + 1)
|
|
357
|
-
throw new UploadError('too_many_rows', `the sheet has more than ${UPLOAD_LIMITS.rows} rows`);
|
|
358
|
-
if (rows.length % 1_000 === 0)
|
|
359
|
-
within(deadline);
|
|
360
|
-
}
|
|
361
|
-
within(deadline);
|
|
362
|
-
return rows;
|
|
363
|
-
}
|
|
364
|
-
// ── Rows → a SQLite snapshot ─────────────────────────────────────────────────────────────────
|
|
365
|
-
const NUMBER = /^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;
|
|
366
|
-
const DATEISH = /^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
367
59
|
/**
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
|
|
60
|
+
* (crew#1724) A `.tmp-*` file in the snapshot store older than this is left by an upload that never finished (the daemon
|
|
61
|
+
* died mid-upload). Twice the upload's deadline: a live upload's files are younger than its deadline, and the margin
|
|
62
|
+
* covers the steps after its last check (storing the snapshot, the cleanup).
|
|
63
|
+
*/
|
|
64
|
+
export const STALE_TMP_MS = 2 * UPLOAD_LIMITS.parseMs;
|
|
65
|
+
/** The temporary files an upload writes in the store: its bytes, the snapshot being built and its journals. */
|
|
66
|
+
const TMP_FILE_RE = /^\.tmp-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.(?:upload|sqlite(?:-vacuum)?(?:-journal|-wal|-shm)?)$/;
|
|
67
|
+
/** A `.sqlite` temp's sidecars: its journals, and the rewrite of a stripped copy (`-vacuum`) with its journal. */
|
|
68
|
+
const TMP_SIDECARS = ['-journal', '-wal', '-shm', '-vacuum', '-vacuum-journal'];
|
|
69
|
+
/**
|
|
70
|
+
* The temporary files of the uploads this process is running (codex r1): never swept, however long one has stalled. Only
|
|
71
|
+
* one daemon writes a state home's snapshot store, so these are all the live ones.
|
|
372
72
|
*/
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return values.length > 0 && values.every((v) => NUMBER.test(v) || DATEISH.test(v) || /^(true|false)$/i.test(v));
|
|
73
|
+
const liveTmp = new Set();
|
|
74
|
+
/** The sweep running now, if one is: uploads that start while it runs start none of their own (codex r2). */
|
|
75
|
+
let sweeping = null;
|
|
76
|
+
/** Start a sweep of `dir` unless one runs; never awaited by an upload, so it never spends an upload's deadline. */
|
|
77
|
+
function startSweep(dir) {
|
|
78
|
+
if (sweeping !== null)
|
|
79
|
+
return;
|
|
80
|
+
sweeping = sweepStale(dir).finally(() => {
|
|
81
|
+
sweeping = null;
|
|
383
82
|
});
|
|
384
83
|
}
|
|
84
|
+
/** TESTS ONLY: resolves once the sweep running now (if any) has finished. */
|
|
85
|
+
export async function sweepSettled() {
|
|
86
|
+
await sweeping;
|
|
87
|
+
}
|
|
385
88
|
/**
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
* an email address, a domain, a URL or a time is a value, never a name.
|
|
89
|
+
* Remove the store's stale `.tmp-*` files (crew#1724), never a live upload's. Housekeeping: a failure is never the
|
|
90
|
+
* upload's. `now`: TESTS ONLY.
|
|
389
91
|
*/
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return false;
|
|
395
|
-
const seen = new Set();
|
|
396
|
-
for (const raw of first) {
|
|
397
|
-
const cell = raw.trim();
|
|
398
|
-
if (cell === '' || NUMBER.test(cell) || DATEISH.test(cell) || /^(true|false)$/i.test(cell) || !NAME_LIKE.test(cell))
|
|
399
|
-
return false;
|
|
400
|
-
const k = cell.toLowerCase();
|
|
401
|
-
if (seen.has(k))
|
|
402
|
-
return false;
|
|
403
|
-
seen.add(k);
|
|
92
|
+
export async function sweepStale(dir, now = Date.now()) {
|
|
93
|
+
let names;
|
|
94
|
+
try {
|
|
95
|
+
names = await readdir(dir);
|
|
404
96
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
function columnNames(first, width, header) {
|
|
408
|
-
const names = [];
|
|
409
|
-
const taken = new Set(); // SQLite compares names case-insensitively
|
|
410
|
-
for (let i = 0; i < width; i++) {
|
|
411
|
-
let n = header ? (first[i] ?? '').trim().replace(/\s+/g, ' ').slice(0, 56) : '';
|
|
412
|
-
if (n === '')
|
|
413
|
-
n = `col_${i + 1}`;
|
|
414
|
-
let unique = n;
|
|
415
|
-
for (let k = 2; taken.has(unique.toLowerCase()); k++)
|
|
416
|
-
unique = `${n}_${k}`;
|
|
417
|
-
taken.add(unique.toLowerCase());
|
|
418
|
-
names.push(unique);
|
|
97
|
+
catch {
|
|
98
|
+
return;
|
|
419
99
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const INT64_MIN = -(2n ** 63n);
|
|
423
|
-
const INT64_MAX = 2n ** 63n - 1n;
|
|
424
|
-
function isInt64(v) {
|
|
425
|
-
if (!/^[+-]?\d{1,20}$/.test(v))
|
|
426
|
-
return false;
|
|
427
|
-
const b = BigInt(v);
|
|
428
|
-
return b >= INT64_MIN && b <= INT64_MAX;
|
|
429
|
-
}
|
|
430
|
-
/** INTEGER (stored exactly, as a 64-bit integer), REAL, or TEXT; an integer past int64 makes the column TEXT. */
|
|
431
|
-
function inferType(values, deadline) {
|
|
432
|
-
let t = null;
|
|
433
|
-
let n = 0;
|
|
434
|
-
for (const raw of values) {
|
|
435
|
-
if ((++n & 0xffff) === 0)
|
|
436
|
-
within(deadline);
|
|
437
|
-
const v = raw.trim();
|
|
438
|
-
if (v === '')
|
|
100
|
+
for (const n of names) {
|
|
101
|
+
if (!TMP_FILE_RE.test(n))
|
|
439
102
|
continue;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
103
|
+
const p = join(dir, n);
|
|
104
|
+
if (liveTmp.has(p.replace(/(?:-vacuum)?(?:-journal|-wal|-shm)?$/, '')))
|
|
105
|
+
continue;
|
|
106
|
+
try {
|
|
107
|
+
if (now - (await stat(p)).mtimeMs > STALE_TMP_MS)
|
|
108
|
+
await rm(p, { force: true });
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// gone already, or not ours to judge now
|
|
444
112
|
}
|
|
445
|
-
else if (NUMBER.test(v) && Number.isFinite(Number(v)))
|
|
446
|
-
t = t === 'TEXT' ? 'TEXT' : 'REAL';
|
|
447
|
-
else
|
|
448
|
-
return 'TEXT';
|
|
449
|
-
}
|
|
450
|
-
return t ?? 'TEXT';
|
|
451
|
-
}
|
|
452
|
-
function tableNameFor(filename) {
|
|
453
|
-
const base = filename.replace(/^.*[\\/]/, '').replace(/\.[^.]+$/, '').toLowerCase().replace(/[^a-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
|
|
454
|
-
return /^[a-z_]/.test(base) && base.length > 0 ? base.slice(0, 63) : `data${base === '' ? '' : `_${base}`}`.slice(0, 63);
|
|
455
|
-
}
|
|
456
|
-
/** Write the rows as a new SQLite file at `tmp`, in the snapshot runner (the daemon loads no SQLite library). */
|
|
457
|
-
async function writeRowsSnapshot(tmp, table, names, types, rows, deadline) {
|
|
458
|
-
within(deadline);
|
|
459
|
-
try {
|
|
460
|
-
await sqliteCreate(tmp, table, names, types, rows, Math.max(1, deadline - Date.now()));
|
|
461
|
-
}
|
|
462
|
-
catch (err) {
|
|
463
|
-
if (err instanceof SourceQueryError && err.errorClass === 'timeout')
|
|
464
|
-
throw tooSlow();
|
|
465
|
-
throw unavailable(err) ?? err;
|
|
466
113
|
}
|
|
467
114
|
}
|
|
468
115
|
async function store(tmp, dir) {
|
|
@@ -503,7 +150,8 @@ function sqliteAvailable() {
|
|
|
503
150
|
}
|
|
504
151
|
/** The runner's own refusal on a runtime without the authorizer or defensive mode, as the upload's. */
|
|
505
152
|
function unavailable(err) {
|
|
506
|
-
|
|
153
|
+
const message = typeof err === 'string' ? err : err instanceof SourceQueryError ? err.message : '';
|
|
154
|
+
return /need Node\.js 24\.12/.test(message) ? new UploadError('sqlite_unavailable', UNAVAILABLE) : null;
|
|
507
155
|
}
|
|
508
156
|
const UNAVAILABLE = 'uploads need Node.js 24.12, 25.1 or later (its built-in SQLite, with the authorizer and defensive mode)';
|
|
509
157
|
/** `p` with every symlink of its longest existing prefix resolved (the rest does not exist yet). */
|
|
@@ -578,17 +226,47 @@ export async function ingestUpload(filename, data, opts = {}) {
|
|
|
578
226
|
throw err;
|
|
579
227
|
});
|
|
580
228
|
const tmp = join(dir, `.tmp-${randomUUID()}.sqlite`);
|
|
229
|
+
const input = join(dir, `.tmp-${randomUUID()}.upload`);
|
|
581
230
|
const kind = kindOf(filename, data);
|
|
231
|
+
liveTmp.add(tmp);
|
|
232
|
+
liveTmp.add(input);
|
|
233
|
+
startSweep(dir);
|
|
582
234
|
try {
|
|
583
235
|
if (kind === 'sqlite') {
|
|
584
236
|
if (data.subarray(0, 16).toString('latin1') !== 'SQLite format 3\0')
|
|
585
237
|
throw new UploadError('bad_sqlite', 'the file is not a SQLite database');
|
|
586
238
|
await writeFile(tmp, data, { mode: 0o600 });
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
if (
|
|
590
|
-
throw new UploadError('sqlite_code', `an uploaded .sqlite may hold only tables and indexes; it holds ${
|
|
239
|
+
let inspected = await inspectWithin(tmp, deadline);
|
|
240
|
+
const code = inspected.objects.filter((o) => o.type !== 'table' && o.type !== 'index');
|
|
241
|
+
if (code.length > 0) {
|
|
242
|
+
throw new UploadError('sqlite_code', `an uploaded .sqlite may hold only tables and indexes; it holds ${code.map((o) => `the ${o.type} ${o.name}`).join(', ')}`);
|
|
243
|
+
}
|
|
244
|
+
// (crew#1731) Virtual tables are dropped from this copy (their shadow tables go with them), then the copy is
|
|
245
|
+
// inspected again: what is left must be plain tables and indexes.
|
|
246
|
+
const dropped = inspected.objects.filter((o) => o.virtual).map((o) => o.name);
|
|
247
|
+
// Every table that belonged to them: one that outlives the drop (a declaration rewritten so the module's destroy
|
|
248
|
+
// skips it) is refused, never kept as a plain table (codex r1).
|
|
249
|
+
const theirs = new Set([...dropped, ...inspected.objects.filter((o) => o.shadow).map((o) => o.name)]);
|
|
250
|
+
// (crew#1787) Every copy is rewritten (VACUUM INTO, in the runner's child), virtual tables or not, so the snapshot
|
|
251
|
+
// holds live pages only: rows or tables the person deleted before the upload never ride in its free pages (or in
|
|
252
|
+
// an image a publish copies it into). A plain file's snapshot is therefore not its bytes, and its digest differs.
|
|
253
|
+
within(deadline);
|
|
254
|
+
let failed;
|
|
255
|
+
try {
|
|
256
|
+
failed = (await sqliteStrip(tmp, `${tmp}-vacuum`, dropped, Math.max(1, deadline - Date.now()))).failed;
|
|
591
257
|
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
if (err instanceof SourceQueryError && err.errorClass === 'timeout')
|
|
260
|
+
throw tooSlow();
|
|
261
|
+
throw unavailable(err) ?? err;
|
|
262
|
+
}
|
|
263
|
+
if (failed.length > 0) {
|
|
264
|
+
throw new UploadError('sqlite_code', `an uploaded .sqlite may hold only tables and indexes, and crew could not drop ${failed.map((f) => `the virtual table ${f.name} (${f.error})`).join(', ')} from its copy; drop ${failed.length === 1 ? 'it' : 'them'} from a copy of the file (DROP TABLE <name>) and upload that`);
|
|
265
|
+
}
|
|
266
|
+
inspected = await inspectWithin(tmp, deadline);
|
|
267
|
+
const left = inspected.objects.filter((o) => (o.type !== 'table' && o.type !== 'index') || o.virtual || o.shadow || theirs.has(o.name));
|
|
268
|
+
if (left.length > 0)
|
|
269
|
+
throw new UploadError('sqlite_code', `an uploaded .sqlite may hold only tables and indexes; after its virtual tables were dropped it still holds ${left.map((o) => o.name).join(', ')}`);
|
|
592
270
|
if (inspected.generated.length > 0)
|
|
593
271
|
throw new UploadError('sqlite_code', `an uploaded .sqlite may not hold generated or hidden columns; it holds ${inspected.generated.join(', ')}`);
|
|
594
272
|
const total = inspected.catalog.relations.reduce((a, r) => a + (r.rowEstimate ?? 0), 0);
|
|
@@ -597,40 +275,50 @@ export async function ingestUpload(filename, data, opts = {}) {
|
|
|
597
275
|
if (inspected.catalog.relations.some((r) => r.columns.length > UPLOAD_LIMITS.columns))
|
|
598
276
|
throw new UploadError('too_many_columns', `a table has more than ${UPLOAD_LIMITS.columns} columns`);
|
|
599
277
|
const s = await store(tmp, dir);
|
|
600
|
-
return { digest: s.digest, bytes: s.bytes, kind, table: null, header: null, sample: [], catalog: (await inspectWithin(s.path, deadline)).catalog };
|
|
278
|
+
return { digest: s.digest, bytes: s.bytes, kind, table: null, header: null, sample: [], dropped, catalog: (await inspectWithin(s.path, deadline)).catalog };
|
|
279
|
+
}
|
|
280
|
+
await writeFile(input, data, { mode: 0o600 });
|
|
281
|
+
within(deadline);
|
|
282
|
+
let ingested;
|
|
283
|
+
try {
|
|
284
|
+
ingested = await sqliteIngest(tmp, input, kind, filename, opts.header ?? null, UPLOAD_LIMITS, Math.max(1, deadline - Date.now()));
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
if (err instanceof SourceQueryError && err.errorClass === 'timeout')
|
|
288
|
+
throw tooSlow();
|
|
289
|
+
// Only the child's own failure is the file's; a runner that could not start or answered too much passes
|
|
290
|
+
// through as before (crew#1721 coord r1).
|
|
291
|
+
if (isRunnerFailure(err))
|
|
292
|
+
throw unavailable(err) ?? new UploadError('unreadable', 'crew could not read the file (its parser failed)');
|
|
293
|
+
throw unavailable(err) ?? err;
|
|
294
|
+
}
|
|
295
|
+
if (!ingested.ok) {
|
|
296
|
+
if (ingested.refused === true)
|
|
297
|
+
throw new UploadError(ingested.code, ingested.error);
|
|
298
|
+
throw unavailable(ingested.error) ?? new UploadError('unreadable', 'crew could not read the file (its parser failed)');
|
|
601
299
|
}
|
|
602
|
-
const rows = kind === 'xlsx'
|
|
603
|
-
? parseXlsx(data, deadline)
|
|
604
|
-
: parseCsv(data.toString('utf8').replace(/^/, ''), deadline);
|
|
605
|
-
if (rows.length === 0)
|
|
606
|
-
throw new UploadError('empty', 'the file has no rows');
|
|
607
|
-
const first = rows[0];
|
|
608
|
-
const header = detectHeader(rows, opts.header ?? null);
|
|
609
|
-
const width = rows.reduce((w, r) => Math.max(w, r.length), 0);
|
|
610
|
-
const names = columnNames(first, width, header);
|
|
611
|
-
const body = header ? rows.slice(1) : rows;
|
|
612
|
-
if (body.length > UPLOAD_LIMITS.rows)
|
|
613
|
-
throw new UploadError('too_many_rows', `the file has more than ${UPLOAD_LIMITS.rows} rows`);
|
|
614
|
-
const types = names.map((_n, i) => inferType((function* () {
|
|
615
|
-
for (const r of body)
|
|
616
|
-
yield r[i] ?? '';
|
|
617
|
-
})(), deadline));
|
|
618
|
-
const table = tableNameFor(filename);
|
|
619
|
-
await writeRowsSnapshot(tmp, table, names, types, body, deadline);
|
|
620
300
|
const s = await store(tmp, dir);
|
|
621
301
|
return {
|
|
622
302
|
digest: s.digest,
|
|
623
303
|
bytes: s.bytes,
|
|
624
304
|
kind,
|
|
625
|
-
table,
|
|
626
|
-
header:
|
|
627
|
-
sample:
|
|
305
|
+
table: ingested.table,
|
|
306
|
+
header: ingested.header,
|
|
307
|
+
sample: ingested.sample,
|
|
308
|
+
dropped: [],
|
|
628
309
|
catalog: (await inspectWithin(s.path, deadline)).catalog,
|
|
629
310
|
};
|
|
630
311
|
}
|
|
631
312
|
finally {
|
|
632
313
|
// The file and any journal a runner ended mid-transaction left beside it.
|
|
633
|
-
|
|
314
|
+
try {
|
|
315
|
+
await Promise.all([rm(input, { force: true }), ...['', ...TMP_SIDECARS].map((s) => rm(`${tmp}${s}`, { force: true }))]);
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
// Not live any more even if a removal failed: the next sweep takes what is left (codex r2).
|
|
319
|
+
liveTmp.delete(tmp);
|
|
320
|
+
liveTmp.delete(input);
|
|
321
|
+
}
|
|
634
322
|
}
|
|
635
323
|
}
|
|
636
324
|
//# sourceMappingURL=uploads.js.map
|