@abot-ai/runtime 1.2.0 → 1.3.1
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 +14 -0
- package/dist/scripts/init-runtime.js +4 -13
- package/dist/scripts/runtime-setup-directories.d.ts +2 -0
- package/dist/scripts/runtime-setup-directories.js +38 -0
- package/dist/src/bridge/request-steering.d.ts +2 -1
- package/dist/src/bridge/request-steering.js +4 -2
- package/dist/src/bridge/runtime-replay.js +2 -19
- package/dist/src/bridge/start-agent-bridge.js +1 -1
- package/dist/src/capabilities/normal-invocation/validator.js +1 -1
- package/dist/src/capabilities/tool-definition-validator/event-presentation.js +3 -0
- package/dist/src/capabilities/tool-definition-validator/event-result-metadata.d.ts +2 -0
- package/dist/src/capabilities/tool-definition-validator/event-result-metadata.js +74 -0
- package/dist/src/capabilities/tool-event-metadata.js +3 -0
- package/dist/src/capabilities/tool-result-event-projection.d.ts +3 -0
- package/dist/src/capabilities/tool-result-event-projection.js +82 -0
- package/dist/src/capabilities/tool-types.d.ts +5 -0
- package/dist/src/cli/abot.js +2 -11
- package/dist/src/runtime/adapters/in-memory-session-store.js +1 -0
- package/dist/src/runtime/adapters/long-term-memory/file-lock/acquisition.js +11 -2
- package/dist/src/runtime/adapters/long-term-memory/file-lock/contracts.d.ts +2 -0
- package/dist/src/runtime/adapters/long-term-memory/file-lock/synchronous-release.d.ts +2 -0
- package/dist/src/runtime/adapters/long-term-memory/file-lock/synchronous-release.js +40 -0
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/approval.d.ts +3 -0
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/approval.js +9 -0
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/rejection-event.d.ts +13 -0
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/rejection-event.js +25 -0
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/run.js +18 -2
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/executor.js +8 -0
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/payload/lifecycle.js +7 -3
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/shared/contracts.d.ts +17 -2
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/shared/event-metadata.d.ts +9 -0
- package/dist/src/runtime/adapters/registered-tool-normal-invocations/shared/event-metadata.js +8 -0
- package/dist/src/runtime/adapters/registered-tool-worker-capabilities/execution.js +16 -1
- package/dist/src/runtime/adapters/registered-tool-worker-capabilities/payload-observability.js +2 -2
- package/dist/src/runtime/adapters/scheduled-request-outcome.d.ts +11 -0
- package/dist/src/runtime/adapters/scheduled-request-outcome.js +41 -0
- package/dist/src/runtime/adapters/scheduler-runtime.d.ts +19 -0
- package/dist/src/runtime/adapters/scheduler-runtime.js +138 -0
- package/dist/src/runtime/capabilities/scheduling/create-operations.d.ts +55 -0
- package/dist/src/runtime/capabilities/scheduling/create-operations.js +30 -0
- package/dist/src/runtime/capabilities/scheduling/create-time-zone.d.ts +1 -0
- package/dist/src/runtime/capabilities/scheduling/create-time-zone.js +11 -0
- package/dist/src/runtime/capabilities/scheduling/job-list-page.d.ts +25 -0
- package/dist/src/runtime/capabilities/scheduling/job-list-page.js +40 -0
- package/dist/src/runtime/capabilities/scheduling/model-validation.d.ts +2 -0
- package/dist/src/runtime/capabilities/scheduling/model-validation.js +15 -0
- package/dist/src/runtime/capabilities/scheduling/tool-contract.d.ts +2 -0
- package/dist/src/runtime/capabilities/scheduling/tool-contract.js +35 -0
- package/dist/src/runtime/capabilities/scheduling/tool-input-properties.d.ts +43 -0
- package/dist/src/runtime/capabilities/scheduling/tool-input-properties.js +27 -0
- package/dist/src/runtime/capabilities/scheduling/tool-module.d.ts +4 -0
- package/dist/src/runtime/capabilities/scheduling/tool-module.js +158 -0
- package/dist/src/runtime/capabilities/scheduling/update-operations.d.ts +2 -0
- package/dist/src/runtime/capabilities/scheduling/update-operations.js +49 -0
- package/dist/src/runtime/composition.d.ts +23 -3
- package/dist/src/runtime/composition.js +12 -17
- package/dist/src/runtime/config/environment-paths.d.ts +10 -0
- package/dist/src/runtime/config/environment-paths.js +31 -0
- package/dist/src/runtime/config/environment-storage.d.ts +9 -0
- package/dist/src/runtime/config/environment-storage.js +65 -0
- package/dist/src/runtime/config/fields.js +7 -0
- package/dist/src/runtime/config/long-term-memory.js +15 -0
- package/dist/src/runtime/config/schema.js +8 -0
- package/dist/src/runtime/config.js +9 -5
- package/dist/src/runtime/context/scheduled-execution-context.d.ts +10 -0
- package/dist/src/runtime/context/scheduled-execution-context.js +52 -0
- package/dist/src/runtime/default-adapters.d.ts +3 -32
- package/dist/src/runtime/default-adapters.js +3 -270
- package/dist/src/runtime/default-environment-adapters.d.ts +19 -0
- package/dist/src/runtime/default-environment-adapters.js +144 -0
- package/dist/src/runtime/index.d.ts +5 -0
- package/dist/src/runtime/index.js +4 -0
- package/dist/src/runtime/local-application.d.ts +22 -0
- package/dist/src/runtime/local-application.js +81 -0
- package/dist/src/runtime/local-host/app-memory-dispatch.d.ts +11 -0
- package/dist/src/runtime/local-host/app-memory-dispatch.js +103 -0
- package/dist/src/runtime/local-host/app-owner.d.ts +4 -0
- package/dist/src/runtime/local-host/app-owner.js +119 -0
- package/dist/src/runtime/local-host/app-request-control.d.ts +24 -0
- package/dist/src/runtime/local-host/app-request-control.js +135 -0
- package/dist/src/runtime/local-host/app-service-dispatch.d.ts +5 -0
- package/dist/src/runtime/local-host/app-service-dispatch.js +64 -0
- package/dist/src/runtime/local-host/client-identity.d.ts +3 -0
- package/dist/src/runtime/local-host/client-identity.js +17 -0
- package/dist/src/runtime/local-host/client-memory.d.ts +7 -0
- package/dist/src/runtime/local-host/client-memory.js +54 -0
- package/dist/src/runtime/local-host/client-requests.d.ts +19 -0
- package/dist/src/runtime/local-host/client-requests.js +145 -0
- package/dist/src/runtime/local-host/client-services.d.ts +10 -0
- package/dist/src/runtime/local-host/client-services.js +14 -0
- package/dist/src/runtime/local-host/contracts.d.ts +36 -0
- package/dist/src/runtime/local-host/contracts.js +1 -0
- package/dist/src/runtime/local-host/endpoint.d.ts +7 -0
- package/dist/src/runtime/local-host/endpoint.js +79 -0
- package/dist/src/runtime/local-host/owner-activity.d.ts +10 -0
- package/dist/src/runtime/local-host/owner-activity.js +30 -0
- package/dist/src/runtime/local-host/owner-retirement.d.ts +3 -0
- package/dist/src/runtime/local-host/owner-retirement.js +15 -0
- package/dist/src/runtime/local-host/owner-server.d.ts +6 -0
- package/dist/src/runtime/local-host/owner-server.js +88 -0
- package/dist/src/runtime/local-host/private-access.d.ts +2 -0
- package/dist/src/runtime/local-host/private-access.js +16 -0
- package/dist/src/runtime/local-host/private-directory.d.ts +1 -0
- package/dist/src/runtime/local-host/private-directory.js +57 -0
- package/dist/src/runtime/local-host/rpc-peer.d.ts +22 -0
- package/dist/src/runtime/local-host/rpc-peer.js +168 -0
- package/dist/src/runtime/local-host/rpc-protocol.d.ts +21 -0
- package/dist/src/runtime/local-host/rpc-protocol.js +46 -0
- package/dist/src/runtime/local-host/startup-connection.d.ts +5 -0
- package/dist/src/runtime/local-host/startup-connection.js +72 -0
- package/dist/src/runtime/local-host/transport.d.ts +3 -0
- package/dist/src/runtime/local-host/transport.js +88 -0
- package/dist/src/runtime/local-host/windows-private-access.d.ts +1 -0
- package/dist/src/runtime/local-host/windows-private-access.js +51 -0
- package/dist/src/runtime/long-term-memory/onboarding/configuration.js +6 -0
- package/dist/src/runtime/long-term-memory/recall-binding.d.ts +3 -0
- package/dist/src/runtime/long-term-memory/recall-binding.js +27 -0
- package/dist/src/runtime/long-term-memory/recall-context.d.ts +20 -0
- package/dist/src/runtime/long-term-memory/recall-context.js +101 -0
- package/dist/src/runtime/long-term-memory/recall-continuation.d.ts +8 -0
- package/dist/src/runtime/long-term-memory/recall-continuation.js +36 -0
- package/dist/src/runtime/long-term-memory/recall-policy.d.ts +7 -0
- package/dist/src/runtime/long-term-memory/recall-policy.js +14 -0
- package/dist/src/runtime/long-term-memory/recall-result.d.ts +5 -0
- package/dist/src/runtime/long-term-memory/recall-result.js +54 -0
- package/dist/src/runtime/long-term-memory/repository-state.d.ts +2 -1
- package/dist/src/runtime/long-term-memory/repository-state.js +2 -2
- package/dist/src/runtime/model/invoke-raw-step.d.ts +1 -0
- package/dist/src/runtime/model/invoke-raw-step.js +1 -0
- package/dist/src/runtime/model/invoke-step.js +6 -0
- package/dist/src/runtime/model/invoke-structured-step.d.ts +1 -0
- package/dist/src/runtime/model/invoke-structured-step.js +1 -0
- package/dist/src/runtime/model/model-step-port.d.ts +2 -0
- package/dist/src/runtime/model/model-step-steering.d.ts +8 -0
- package/dist/src/runtime/model/model-step-steering.js +19 -0
- package/dist/src/runtime/orchestration/final-response/authoring-contract.js +1 -1
- package/dist/src/runtime/orchestration/final-response/invoke.d.ts +1 -0
- package/dist/src/runtime/orchestration/final-response/invoke.js +1 -0
- package/dist/src/runtime/orchestration/role-calls/activation-budget.js +1 -0
- package/dist/src/runtime/orchestration/role-calls/candidate-validation.js +9 -49
- package/dist/src/runtime/orchestration/role-calls/capability-selection-reconsideration.d.ts +9 -0
- package/dist/src/runtime/orchestration/role-calls/capability-selection-reconsideration.js +17 -8
- package/dist/src/runtime/orchestration/role-calls/capability-selection-supervision-validation.d.ts +2 -0
- package/dist/src/runtime/orchestration/role-calls/capability-selection-supervision-validation.js +62 -0
- package/dist/src/runtime/orchestration/role-calls/command-decoder.js +4 -0
- package/dist/src/runtime/orchestration/role-calls/command-dispatch/memory-recall-transitions.d.ts +4 -0
- package/dist/src/runtime/orchestration/role-calls/command-dispatch/memory-recall-transitions.js +89 -0
- package/dist/src/runtime/orchestration/role-calls/command-dispatch.js +5 -0
- package/dist/src/runtime/orchestration/role-calls/contracts.d.ts +9 -7
- package/dist/src/runtime/orchestration/role-calls/contracts.js +2 -2
- package/dist/src/runtime/orchestration/role-calls/diagnostics.js +3 -0
- package/dist/src/runtime/orchestration/role-calls/index.d.ts +1 -0
- package/dist/src/runtime/orchestration/role-calls/index.js +1 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-contract.d.ts +51 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-contract.js +4 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-decoder.d.ts +6 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-decoder.js +147 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-diagnostics.d.ts +5 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-diagnostics.js +27 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-state-validation.d.ts +3 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-state-validation.js +121 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-transactions.d.ts +3 -0
- package/dist/src/runtime/orchestration/role-calls/memory-recall-transactions.js +44 -0
- package/dist/src/runtime/orchestration/role-calls/reducer.js +1 -0
- package/dist/src/runtime/orchestration/role-calls/transaction-effect.d.ts +5 -0
- package/dist/src/runtime/orchestration/role-calls/transaction-effect.js +14 -0
- package/dist/src/runtime/orchestration/role-calls/transactions.js +3 -24
- package/dist/src/runtime/plugins/manifest-validator.js +4 -1
- package/dist/src/runtime/ports.d.ts +4 -0
- package/dist/src/runtime/request/bound-runtime-handler.d.ts +2 -0
- package/dist/src/runtime/request/bound-runtime-handler.js +25 -0
- package/dist/src/runtime/request/contracts.d.ts +6 -0
- package/dist/src/runtime/request/execution-agent-root-execution.js +12 -0
- package/dist/src/runtime/request/execution-facets.js +6 -0
- package/dist/src/runtime/request/execution-scope-surfaces.js +10 -0
- package/dist/src/runtime/request/execution-scope.d.ts +1 -1
- package/dist/src/runtime/request/handler.js +6 -0
- package/dist/src/runtime/request/root-contract.d.ts +7 -1
- package/dist/src/runtime/request/root-execution-kernel.js +33 -37
- package/dist/src/runtime/request/root-memory-recall.d.ts +11 -0
- package/dist/src/runtime/request/root-memory-recall.js +71 -0
- package/dist/src/runtime/request/root-observation-handoff.d.ts +17 -0
- package/dist/src/runtime/request/root-observation-handoff.js +44 -0
- package/dist/src/runtime/request/scheduled-execution.d.ts +9 -0
- package/dist/src/runtime/request/scheduled-execution.js +32 -0
- package/dist/src/runtime/request/session-admission.d.ts +17 -0
- package/dist/src/runtime/request/session-admission.js +88 -0
- package/dist/src/runtime/request/supervisor-root-execution-diagnostics.d.ts +1 -1
- package/dist/src/runtime/request/supervisor-root-execution.js +8 -0
- package/dist/src/runtime/runtime-environment.d.ts +31 -0
- package/dist/src/runtime/runtime-environment.js +102 -0
- package/dist/src/runtime/runtime-host-environment.d.ts +8 -0
- package/dist/src/runtime/runtime-host-environment.js +57 -0
- package/dist/src/runtime/runtime-host-lifecycle.d.ts +4 -0
- package/dist/src/runtime/runtime-host-lifecycle.js +64 -0
- package/dist/src/runtime/runtime-host-scheduler-ownership.d.ts +5 -0
- package/dist/src/runtime/runtime-host-scheduler-ownership.js +67 -0
- package/dist/src/runtime/runtime-host.d.ts +19 -0
- package/dist/src/runtime/runtime-host.js +63 -0
- package/dist/src/runtime/scheduler/calendar-time.d.ts +10 -0
- package/dist/src/runtime/scheduler/calendar-time.js +58 -0
- package/dist/src/runtime/scheduler/contracts.d.ts +143 -0
- package/dist/src/runtime/scheduler/contracts.js +1 -0
- package/dist/src/runtime/scheduler/file-store.d.ts +2 -0
- package/dist/src/runtime/scheduler/file-store.js +76 -0
- package/dist/src/runtime/scheduler/instant-validation.d.ts +4 -0
- package/dist/src/runtime/scheduler/instant-validation.js +69 -0
- package/dist/src/runtime/scheduler/interval-range.d.ts +8 -0
- package/dist/src/runtime/scheduler/interval-range.js +24 -0
- package/dist/src/runtime/scheduler/job-management.d.ts +8 -0
- package/dist/src/runtime/scheduler/job-management.js +212 -0
- package/dist/src/runtime/scheduler/journal-checkpoint.d.ts +9 -0
- package/dist/src/runtime/scheduler/journal-checkpoint.js +45 -0
- package/dist/src/runtime/scheduler/journal-durability.d.ts +8 -0
- package/dist/src/runtime/scheduler/journal-durability.js +59 -0
- package/dist/src/runtime/scheduler/journal-files.d.ts +14 -0
- package/dist/src/runtime/scheduler/journal-files.js +59 -0
- package/dist/src/runtime/scheduler/journal-head.d.ts +21 -0
- package/dist/src/runtime/scheduler/journal-head.js +81 -0
- package/dist/src/runtime/scheduler/journal-index-state.d.ts +31 -0
- package/dist/src/runtime/scheduler/journal-index-state.js +137 -0
- package/dist/src/runtime/scheduler/journal-index.d.ts +22 -0
- package/dist/src/runtime/scheduler/journal-index.js +195 -0
- package/dist/src/runtime/scheduler/journal-store.d.ts +21 -0
- package/dist/src/runtime/scheduler/journal-store.js +184 -0
- package/dist/src/runtime/scheduler/journal-transaction.d.ts +14 -0
- package/dist/src/runtime/scheduler/journal-transaction.js +104 -0
- package/dist/src/runtime/scheduler/next-occurrence.d.ts +3 -0
- package/dist/src/runtime/scheduler/next-occurrence.js +39 -0
- package/dist/src/runtime/scheduler/run-completion.d.ts +12 -0
- package/dist/src/runtime/scheduler/run-completion.js +77 -0
- package/dist/src/runtime/scheduler/run-list-query.d.ts +5 -0
- package/dist/src/runtime/scheduler/run-list-query.js +38 -0
- package/dist/src/runtime/scheduler/run-records.d.ts +6 -0
- package/dist/src/runtime/scheduler/run-records.js +41 -0
- package/dist/src/runtime/scheduler/schedule-update.d.ts +3 -0
- package/dist/src/runtime/scheduler/schedule-update.js +22 -0
- package/dist/src/runtime/scheduler/schedule-validation.d.ts +10 -0
- package/dist/src/runtime/scheduler/schedule-validation.js +132 -0
- package/dist/src/runtime/scheduler/scheduler-engine.d.ts +2 -0
- package/dist/src/runtime/scheduler/scheduler-engine.js +174 -0
- package/dist/src/runtime/scheduler/scheduler-service.d.ts +10 -0
- package/dist/src/runtime/scheduler/scheduler-service.js +115 -0
- package/dist/src/runtime/scheduler/service-context.d.ts +21 -0
- package/dist/src/runtime/scheduler/service-context.js +26 -0
- package/dist/src/runtime/scheduler/session-deletion-state.d.ts +9 -0
- package/dist/src/runtime/scheduler/session-deletion-state.js +30 -0
- package/dist/src/runtime/scheduler/snapshot-validation.d.ts +4 -0
- package/dist/src/runtime/scheduler/snapshot-validation.js +112 -0
- package/dist/src/runtime/scheduler/startup-recovery.d.ts +2 -0
- package/dist/src/runtime/scheduler/startup-recovery.js +38 -0
- package/dist/src/runtime/scheduler/validation-error.d.ts +4 -0
- package/dist/src/runtime/scheduler/validation-error.js +8 -0
- package/dist/src/runtime/scheduler/working-store.d.ts +3 -0
- package/dist/src/runtime/scheduler/working-store.js +8 -0
- package/dist/src/runtime/session/request-session.d.ts +1 -0
- package/dist/src/runtime/session/request-session.js +14 -1
- package/dist/src/runtime/session/session-attachment-deletion.d.ts +8 -0
- package/dist/src/runtime/session/session-attachment-deletion.js +87 -0
- package/dist/src/runtime/session/session-deletion-boundary.d.ts +10 -0
- package/dist/src/runtime/session/session-deletion-boundary.js +39 -0
- package/dist/src/runtime/session/session-deletion-cleanup.d.ts +7 -0
- package/dist/src/runtime/session/session-deletion-cleanup.js +62 -0
- package/dist/src/runtime/session/session-deletion-finalization.d.ts +7 -0
- package/dist/src/runtime/session/session-deletion-finalization.js +34 -0
- package/dist/src/runtime/session/session-deletion-receipts.d.ts +7 -0
- package/dist/src/runtime/session/session-deletion-receipts.js +18 -0
- package/dist/src/runtime/session/session-lifecycle-store.d.ts +21 -0
- package/dist/src/runtime/session/session-lifecycle-store.js +72 -0
- package/dist/src/runtime/session/session-mutation-queue.d.ts +3 -0
- package/dist/src/runtime/session/session-mutation-queue.js +15 -0
- package/dist/src/runtime/steps/execution-agent/capability-decision-parsing.d.ts +16 -0
- package/dist/src/runtime/steps/execution-agent/capability-decision-parsing.js +165 -0
- package/dist/src/runtime/steps/execution-agent/contracts.d.ts +3 -1
- package/dist/src/runtime/steps/execution-agent/decision-parsing.d.ts +2 -0
- package/dist/src/runtime/steps/execution-agent/decision-parsing.js +195 -0
- package/dist/src/runtime/steps/execution-agent/decision-validation.d.ts +30 -0
- package/dist/src/runtime/steps/execution-agent/decision-validation.js +127 -0
- package/dist/src/runtime/steps/execution-agent/format.d.ts +1 -0
- package/dist/src/runtime/steps/execution-agent/format.js +12 -0
- package/dist/src/runtime/steps/execution-agent/input.d.ts +2 -1
- package/dist/src/runtime/steps/execution-agent/input.js +17 -2
- package/dist/src/runtime/steps/execution-agent/parser.d.ts +1 -2
- package/dist/src/runtime/steps/execution-agent/parser.js +1 -472
- package/dist/src/runtime/steps/execution-agent/prompt.d.ts +2 -0
- package/dist/src/runtime/steps/execution-agent/prompt.js +2 -0
- package/dist/src/runtime/steps/execution-agent/reconsideration-context.js +4 -3
- package/dist/src/runtime/steps/execution-agent/response-input.js +5 -4
- package/dist/src/runtime/steps/execution-agent/response-run.d.ts +3 -0
- package/dist/src/runtime/steps/execution-agent/response-run.js +7 -3
- package/dist/src/runtime/steps/execution-agent/run.d.ts +2 -0
- package/dist/src/runtime/steps/execution-agent/run.js +2 -0
- package/dist/src/runtime/steps/execution-agent/state-context.d.ts +2 -1
- package/dist/src/runtime/steps/execution-agent/state-context.js +13 -5
- package/dist/src/runtime/steps/memory-recall-decision.d.ts +30 -0
- package/dist/src/runtime/steps/memory-recall-decision.js +101 -0
- package/dist/src/runtime/steps/memory-recall-prompt.d.ts +1 -0
- package/dist/src/runtime/steps/memory-recall-prompt.js +15 -0
- package/dist/src/runtime/steps/supervisor-decision/contracts.d.ts +4 -2
- package/dist/src/runtime/steps/supervisor-decision/diagnostics.d.ts +2 -0
- package/dist/src/runtime/steps/supervisor-decision/diagnostics.js +13 -6
- package/dist/src/runtime/steps/supervisor-decision/format.d.ts +2 -0
- package/dist/src/runtime/steps/supervisor-decision/format.js +41 -2
- package/dist/src/runtime/steps/supervisor-decision/input.d.ts +5 -1
- package/dist/src/runtime/steps/supervisor-decision/input.js +25 -5
- package/dist/src/runtime/steps/supervisor-decision/memory-recall-continuation.d.ts +10 -0
- package/dist/src/runtime/steps/supervisor-decision/memory-recall-continuation.js +32 -0
- package/dist/src/runtime/steps/supervisor-decision/parser.d.ts +2 -0
- package/dist/src/runtime/steps/supervisor-decision/parser.js +36 -1
- package/dist/src/runtime/steps/supervisor-decision/prompt.d.ts +3 -0
- package/dist/src/runtime/steps/supervisor-decision/prompt.js +16 -8
- package/dist/src/runtime/steps/supervisor-decision/response-recommendation.d.ts +13 -0
- package/dist/src/runtime/steps/supervisor-decision/response-recommendation.js +32 -0
- package/dist/src/runtime/steps/supervisor-decision/resume.d.ts +2 -0
- package/dist/src/runtime/steps/supervisor-decision/resume.js +13 -0
- package/dist/src/runtime/steps/supervisor-decision/run.d.ts +3 -0
- package/dist/src/runtime/steps/supervisor-decision/run.js +19 -0
- package/dist/src/runtime/steps/supervisor-decision/working-directory.js +7 -1
- package/dist/src/runtime/steps/supervisor-response/diagnostics.d.ts +1 -0
- package/dist/src/runtime/steps/supervisor-response/diagnostics.js +1 -0
- package/dist/src/runtime/steps/supervisor-response/input.d.ts +2 -1
- package/dist/src/runtime/steps/supervisor-response/input.js +17 -4
- package/dist/src/runtime/steps/supervisor-response/memory-authoring.d.ts +1 -0
- package/dist/src/runtime/steps/supervisor-response/memory-authoring.js +4 -0
- package/dist/src/runtime/steps/supervisor-response/prompt.d.ts +1 -0
- package/dist/src/runtime/steps/supervisor-response/prompt.js +8 -2
- package/dist/src/runtime/steps/supervisor-response/response-recommendation.d.ts +10 -0
- package/dist/src/runtime/steps/supervisor-response/response-recommendation.js +25 -0
- package/dist/src/runtime/steps/supervisor-response/run.d.ts +6 -1
- package/dist/src/runtime/steps/supervisor-response/run.js +26 -7
- package/dist/src/sessions/record/projection.js +1 -0
- package/dist/src/sessions/schedule-metadata.d.ts +8 -0
- package/dist/src/sessions/schedule-metadata.js +1 -0
- package/dist/src/sessions/session-service.d.ts +1 -0
- package/dist/src/sessions/session-service.js +1 -0
- package/dist/src/sessions/types.d.ts +2 -0
- package/dist/src/shared/directory-authority/bootstrap.d.ts +1 -0
- package/dist/src/shared/directory-authority/bootstrap.js +118 -0
- package/dist/src/shared/directory-authority/command.d.ts +8 -0
- package/dist/src/shared/directory-authority/command.js +27 -0
- package/dist/src/shared/directory-authority/errors.d.ts +5 -0
- package/dist/src/shared/directory-authority/errors.js +10 -0
- package/dist/src/shared/directory-authority/index.d.ts +3 -0
- package/dist/src/shared/directory-authority/index.js +3 -0
- package/dist/src/shared/directory-authority/protocol.d.ts +11 -0
- package/dist/src/shared/directory-authority/protocol.js +62 -0
- package/dist/src/shared/directory-authority/task.d.ts +7 -0
- package/dist/src/shared/directory-authority/task.js +97 -0
- package/dist/src/shared/http-server-shutdown.d.ts +4 -0
- package/dist/src/shared/http-server-shutdown.js +17 -0
- package/dist/src/shared/public-http/aggregate-gate.d.ts +3 -0
- package/dist/src/shared/public-http/aggregate-gate.js +87 -0
- package/dist/src/shared/public-http/deadline.d.ts +2 -0
- package/dist/src/shared/public-http/deadline.js +29 -0
- package/dist/src/shared/public-http/errors.d.ts +6 -0
- package/dist/src/shared/public-http/errors.js +11 -0
- package/dist/src/shared/public-http/limits.d.ts +8 -0
- package/dist/src/shared/public-http/limits.js +8 -0
- package/dist/src/shared/public-http/network-policy.d.ts +11 -0
- package/dist/src/shared/public-http/network-policy.js +178 -0
- package/dist/src/shared/public-http/public-http.d.ts +24 -0
- package/dist/src/shared/public-http/public-http.js +85 -0
- package/dist/src/shared/public-http/request-hop.d.ts +18 -0
- package/dist/src/shared/public-http/request-hop.js +140 -0
- package/dist/src/web-ui/app/ARCHITECTURE.md +66 -4
- package/dist/src/web-ui/app/app-bootstrap.js +53 -0
- package/dist/src/web-ui/app/app-dom.js +80 -0
- package/dist/src/web-ui/app/app.js +195 -212
- package/dist/src/web-ui/app/components/conversation-activity.d.ts +2 -0
- package/dist/src/web-ui/app/components/conversation-activity.js +34 -7
- package/dist/src/web-ui/app/components/conversation-role-cards.d.ts +1 -0
- package/dist/src/web-ui/app/components/conversation-role-cards.js +61 -5
- package/dist/src/web-ui/app/components/conversation-schedule.js +71 -0
- package/dist/src/web-ui/app/components/conversation-status.js +65 -0
- package/dist/src/web-ui/app/components/conversation-tools.d.ts +13 -0
- package/dist/src/web-ui/app/components/conversation-tools.js +284 -0
- package/dist/src/web-ui/app/components/conversation-view.js +39 -11
- package/dist/src/web-ui/app/components/dashboard/activity.js +61 -0
- package/dist/src/web-ui/app/components/dashboard/icons.js +23 -0
- package/dist/src/web-ui/app/components/dashboard/recent-conversations.js +64 -0
- package/dist/src/web-ui/app/components/dashboard/workspace.js +107 -0
- package/dist/src/web-ui/app/components/message-link-previews.d.ts +16 -0
- package/dist/src/web-ui/app/components/message-link-previews.js +179 -0
- package/dist/src/web-ui/app/components/schedules/details.js +101 -0
- package/dist/src/web-ui/app/components/schedules/form.d.ts +13 -0
- package/dist/src/web-ui/app/components/schedules/form.js +246 -0
- package/dist/src/web-ui/app/components/schedules/workspace-state.js +59 -0
- package/dist/src/web-ui/app/components/schedules/workspace.js +165 -0
- package/dist/src/web-ui/app/components/workspace-shell.js +48 -2
- package/dist/src/web-ui/app/configuration-feature.js +72 -0
- package/dist/src/web-ui/app/controllers/composer-attachments-controller.d.ts +1 -0
- package/dist/src/web-ui/app/controllers/composer-attachments-controller.js +17 -6
- package/dist/src/web-ui/app/controllers/composer-submit-controller.d.ts +2 -0
- package/dist/src/web-ui/app/controllers/composer-submit-controller.js +15 -1
- package/dist/src/web-ui/app/controllers/composer-surface-controller.js +58 -0
- package/dist/src/web-ui/app/controllers/composer-workspace-controller.d.ts +53 -0
- package/dist/src/web-ui/app/controllers/composer-workspace-controller.js +180 -0
- package/dist/src/web-ui/app/controllers/conversation-read-state-controller.d.ts +23 -0
- package/dist/src/web-ui/app/controllers/conversation-read-state-controller.js +82 -0
- package/dist/src/web-ui/app/controllers/conversation-session-controller.d.ts +8 -0
- package/dist/src/web-ui/app/controllers/conversation-session-controller.js +28 -39
- package/dist/src/web-ui/app/controllers/dashboard-controller.js +127 -0
- package/dist/src/web-ui/app/controllers/home-composer-feature.d.ts +40 -0
- package/dist/src/web-ui/app/controllers/home-composer-feature.js +119 -0
- package/dist/src/web-ui/app/controllers/home-conversation-activation.js +37 -0
- package/dist/src/web-ui/app/controllers/realtime-event-controller.d.ts +1 -0
- package/dist/src/web-ui/app/controllers/realtime-event-controller.js +74 -3
- package/dist/src/web-ui/app/controllers/runtime-selection-controller.d.ts +2 -1
- package/dist/src/web-ui/app/controllers/runtime-selection-controller.js +15 -14
- package/dist/src/web-ui/app/controllers/schedule-realtime.js +118 -0
- package/dist/src/web-ui/app/controllers/schedules-controller.js +421 -0
- package/dist/src/web-ui/app/controllers/session-controller.js +30 -3
- package/dist/src/web-ui/app/dashboard-feature.js +44 -0
- package/dist/src/web-ui/app/index.html +53 -1
- package/dist/src/web-ui/app/lib/composer-submission-scope.d.ts +21 -0
- package/dist/src/web-ui/app/lib/composer-submission-scope.js +13 -0
- package/dist/src/web-ui/app/lib/context-window-snapshot-order.d.ts +15 -0
- package/dist/src/web-ui/app/lib/context-window-snapshot-order.js +31 -0
- package/dist/src/web-ui/app/lib/conversation-role-model.d.ts +10 -1
- package/dist/src/web-ui/app/lib/conversation-role-model.js +97 -15
- package/dist/src/web-ui/app/lib/conversation-status-model.d.ts +12 -0
- package/dist/src/web-ui/app/lib/conversation-status-model.js +116 -0
- package/dist/src/web-ui/app/lib/dashboard-job-templates.js +41 -0
- package/dist/src/web-ui/app/lib/dashboard-presentation.js +126 -0
- package/dist/src/web-ui/app/lib/message-markdown.d.ts +5 -0
- package/dist/src/web-ui/app/lib/message-markdown.js +99 -0
- package/dist/src/web-ui/app/lib/message-url-policy.d.ts +1 -0
- package/dist/src/web-ui/app/lib/message-url-policy.js +13 -0
- package/dist/src/web-ui/app/lib/schedule-errors.js +29 -0
- package/dist/src/web-ui/app/lib/schedule-message.js +30 -0
- package/dist/src/web-ui/app/lib/schedule-presentation.js +81 -0
- package/dist/src/web-ui/app/lib/session-read-state.d.ts +22 -0
- package/dist/src/web-ui/app/lib/session-read-state.js +63 -0
- package/dist/src/web-ui/app/lib/text-format.js +2 -143
- package/dist/src/web-ui/app/lib/tool-activity-event.d.ts +26 -0
- package/dist/src/web-ui/app/lib/tool-activity-event.js +228 -0
- package/dist/src/web-ui/app/lib/tool-activity-model.d.ts +41 -0
- package/dist/src/web-ui/app/lib/tool-activity-model.js +255 -0
- package/dist/src/web-ui/app/lib/tool-timeline.d.ts +3 -0
- package/dist/src/web-ui/app/lib/tool-timeline.js +18 -0
- package/dist/src/web-ui/app/schedules-feature.js +87 -0
- package/dist/src/web-ui/app/services/message-link-preview-client.d.ts +14 -0
- package/dist/src/web-ui/app/services/message-link-preview-client.js +96 -0
- package/dist/src/web-ui/app/services/runtime-web-client/schedules.js +51 -0
- package/dist/src/web-ui/app/services/runtime-web-client.d.ts +37 -0
- package/dist/src/web-ui/app/services/runtime-web-client.js +13 -8
- package/dist/src/web-ui/app/styles/00-tokens-base.css +11 -11
- package/dist/src/web-ui/app/styles/18-dashboard.css +384 -0
- package/dist/src/web-ui/app/styles/20-chat-composer.css +1 -130
- package/dist/src/web-ui/app/styles/26-message-content.css +295 -0
- package/dist/src/web-ui/app/styles/27-conversation-tools.css +266 -0
- package/dist/src/web-ui/app/styles/28-conversation-status.css +52 -0
- package/dist/src/web-ui/app/styles/38-schedule-workspace.css +263 -0
- package/dist/src/web-ui/app/styles/38-schedules.css +352 -0
- package/dist/src/web-ui/app/styles/90-responsive.css +14 -0
- package/dist/src/web-ui/app/styles/91-schedules-responsive.css +72 -0
- package/dist/src/web-ui/app/styles/92-dashboard-responsive.css +88 -0
- package/dist/src/web-ui/app/styles.css +8 -0
- package/dist/src/web-ui/app/ui-behavior.d.ts +1 -1
- package/dist/src/web-ui/app/ui-behavior.js +3 -1
- package/dist/src/web-ui/app/vendor/README.md +15 -0
- package/dist/src/web-ui/app/vendor/markdown-it.LICENSE +22 -0
- package/dist/src/web-ui/app/vendor/markdown-it.js +3003 -0
- package/dist/src/web-ui/link-preview/metadata.d.ts +9 -0
- package/dist/src/web-ui/link-preview/metadata.js +97 -0
- package/dist/src/web-ui/link-preview/preview-cache.d.ts +4 -0
- package/dist/src/web-ui/link-preview/preview-cache.js +23 -0
- package/dist/src/web-ui/link-preview/raster-response.d.ts +9 -0
- package/dist/src/web-ui/link-preview/raster-response.js +49 -0
- package/dist/src/web-ui/link-preview/routes.d.ts +3 -0
- package/dist/src/web-ui/link-preview/routes.js +97 -0
- package/dist/src/web-ui/link-preview/service.d.ts +11 -0
- package/dist/src/web-ui/link-preview/service.js +117 -0
- package/dist/src/web-ui/local-runtime/api-router.d.ts +4 -1
- package/dist/src/web-ui/local-runtime/api-router.js +42 -73
- package/dist/src/web-ui/local-runtime/contracts.d.ts +2 -2
- package/dist/src/web-ui/local-runtime/environment-registry.d.ts +12 -1
- package/dist/src/web-ui/local-runtime/environment-registry.js +38 -3
- package/dist/src/web-ui/local-runtime/realtime-controller.js +3 -1
- package/dist/src/web-ui/local-runtime/request-execution.d.ts +5 -1
- package/dist/src/web-ui/local-runtime/request-execution.js +38 -2
- package/dist/src/web-ui/local-runtime/schedule-job-creation.d.ts +7 -0
- package/dist/src/web-ui/local-runtime/schedule-job-creation.js +62 -0
- package/dist/src/web-ui/local-runtime/schedule-management-routes.d.ts +30 -0
- package/dist/src/web-ui/local-runtime/schedule-management-routes.js +134 -0
- package/dist/src/web-ui/local-runtime/schedule-run-page.d.ts +5 -0
- package/dist/src/web-ui/local-runtime/schedule-run-page.js +23 -0
- package/dist/src/web-ui/local-runtime/session-routes.d.ts +17 -0
- package/dist/src/web-ui/local-runtime/session-routes.js +74 -0
- package/dist/src/web-ui/local-runtime-backend.d.ts +2 -0
- package/dist/src/web-ui/local-runtime-backend.js +11 -1
- package/dist/src/web-ui/schedule-creation-contract.d.ts +7 -0
- package/dist/src/web-ui/schedule-creation-contract.js +1 -0
- package/dist/src/web-ui/server-shutdown.d.ts +4 -0
- package/dist/src/web-ui/server-shutdown.js +32 -0
- package/dist/src/web-ui/server.js +13 -10
- package/dist/src/web-ui/session-read-state/availability.d.ts +16 -0
- package/dist/src/web-ui/session-read-state/availability.js +20 -0
- package/dist/src/web-ui/session-read-state/projection.d.ts +17 -0
- package/dist/src/web-ui/session-read-state/projection.js +71 -0
- package/dist/src/web-ui/session-read-state/service.d.ts +86 -0
- package/dist/src/web-ui/session-read-state/service.js +89 -0
- package/dist/src/web-ui/session-read-state/store.d.ts +22 -0
- package/dist/src/web-ui/session-read-state/store.js +110 -0
- package/docs/configuration.md +41 -1
- package/docs/long-term-memory.md +46 -5
- package/docs/plugins.md +15 -9
- package/docs/runtime-invariant-coverage.md +1 -1
- package/docs/runtime-library.md +23 -0
- package/docs/runtime-public-contracts.md +32 -1
- package/package.json +3 -1
- package/plugins/code-outline/plugin.json +15 -0
- package/plugins/document-reader/plugin.json +17 -0
- package/plugins/exec/plugin.json +3 -3
- package/plugins/exec/skills/exec_skill/SKILL.md +1 -1
- package/plugins/exec/source/process-manager.ts +1 -20
- package/plugins/exec/source/shell-platform.ts +29 -0
- package/plugins/exec/src/index.cjs +25 -18
- package/plugins/filesystem/plugin.json +17 -2
- package/plugins/filesystem/source/atomic-write.ts +9 -0
- package/plugins/filesystem/source/bounded-io.ts +5 -99
- package/plugins/filesystem/source/directory-authority-write.ts +64 -0
- package/plugins/filesystem/source/directory-sample-task.ts +23 -0
- package/plugins/filesystem/source/directory-sample.ts +132 -0
- package/plugins/filesystem/source/directory-write-task.ts +160 -0
- package/plugins/filesystem/source/mutation-parent.ts +11 -0
- package/plugins/filesystem/src/index.cjs +693 -118
- package/plugins/json-inspector/plugin.json +12 -0
- package/plugins/local-search/plugin.json +12 -0
- package/plugins/local-search/source/index.ts +2 -0
- package/plugins/local-search/source/paths.ts +30 -7
- package/plugins/local-search/source/ripgrep-process.ts +69 -0
- package/plugins/local-search/source/ripgrep.ts +19 -23
- package/plugins/local-search/src/index.cjs +295 -32
- package/plugins/memory/plugin.json +26 -1
- package/plugins/memory/source/index.ts +10 -6
- package/plugins/memory/src/index.cjs +11 -7
- package/plugins/project-orientation/plugin.json +14 -0
- package/plugins/web/source/aggregate-gate.ts +8 -130
- package/plugins/web/source/deadline.ts +14 -50
- package/plugins/web/source/errors.ts +17 -11
- package/plugins/web/source/limits.ts +3 -6
- package/plugins/web/source/network-policy.ts +28 -226
- package/plugins/web/source/public-http.ts +17 -142
- package/plugins/web/source/request-hop.ts +11 -191
- package/plugins/web/src/index.cjs +119 -59
- package/runtime.config.schema.json +7 -0
- package/src/runtime/README.md +105 -1
- package/src/runtime/local-host/README.md +86 -0
- package/src/runtime/scheduler/README.md +166 -0
|
@@ -253,13 +253,13 @@ var writeFileAdapter = Object.freeze({
|
|
|
253
253
|
});
|
|
254
254
|
|
|
255
255
|
// plugins/filesystem/source/dev-view.ts
|
|
256
|
-
var
|
|
256
|
+
var import_promises3 = require("node:fs/promises");
|
|
257
257
|
|
|
258
258
|
// plugins/filesystem/source/bounded-io.ts
|
|
259
259
|
var import_node_crypto = require("node:crypto");
|
|
260
|
-
var
|
|
261
|
-
var
|
|
262
|
-
var
|
|
260
|
+
var import_node_fs2 = require("node:fs");
|
|
261
|
+
var import_promises2 = require("node:fs/promises");
|
|
262
|
+
var import_node_path3 = require("node:path");
|
|
263
263
|
var import_node_string_decoder = require("node:string_decoder");
|
|
264
264
|
var import_node_util = require("node:util");
|
|
265
265
|
|
|
@@ -302,12 +302,462 @@ function rethrowFilesystemError(error, operation, logicalPath) {
|
|
|
302
302
|
);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
// plugins/filesystem/source/directory-sample.ts
|
|
306
|
+
var import_node_fs = require("node:fs");
|
|
307
|
+
var import_promises = require("node:fs/promises");
|
|
308
|
+
var import_node_path2 = require("node:path");
|
|
309
|
+
|
|
310
|
+
// src/shared/directory-authority/bootstrap.ts
|
|
311
|
+
function directoryAuthorityBootstrap(mode, messageLimit, task) {
|
|
312
|
+
const fs = require("node:fs");
|
|
313
|
+
function fail2(code, message) {
|
|
314
|
+
throw Object.assign(new Error(message), { code });
|
|
315
|
+
}
|
|
316
|
+
function verifyDirectoryAuthority() {
|
|
317
|
+
const expected = fs.fstatSync(3, { bigint: true });
|
|
318
|
+
const actual = fs.statSync(".", { bigint: true });
|
|
319
|
+
const matchesHeldDirectory = expected.isDirectory() && actual.isDirectory() && expected.dev === actual.dev && expected.ino === actual.ino;
|
|
320
|
+
if (matchesHeldDirectory) return;
|
|
321
|
+
fail2(
|
|
322
|
+
"directory_authority_changed",
|
|
323
|
+
"The directory changed before the operation could establish its authority."
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
function readRequest() {
|
|
327
|
+
const fd = mode === "task" ? 0 : 4;
|
|
328
|
+
const chunk = Buffer.alloc(64 * 1024);
|
|
329
|
+
const chunks = [];
|
|
330
|
+
let total = 0;
|
|
331
|
+
for (; ; ) {
|
|
332
|
+
const length = fs.readSync(fd, chunk, 0, chunk.length, null);
|
|
333
|
+
if (length === 0) break;
|
|
334
|
+
total += length;
|
|
335
|
+
if (total > messageLimit) {
|
|
336
|
+
fail2(
|
|
337
|
+
"directory_authority_request_too_large",
|
|
338
|
+
"The directory operation input exceeds the bridge byte limit."
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
chunks.push(Buffer.from(chunk.subarray(0, length)));
|
|
342
|
+
}
|
|
343
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
344
|
+
}
|
|
345
|
+
function reportFailure(error) {
|
|
346
|
+
const detail = error;
|
|
347
|
+
const code = typeof detail?.code === "string" ? detail.code.slice(0, 256) : "directory_authority_failed";
|
|
348
|
+
const message = typeof detail?.message === "string" ? detail.message.slice(0, 4096) : "The directory operation failed.";
|
|
349
|
+
let encoded;
|
|
350
|
+
try {
|
|
351
|
+
encoded = JSON.stringify({
|
|
352
|
+
ok: false,
|
|
353
|
+
error: { code, message, data: detail?.data }
|
|
354
|
+
});
|
|
355
|
+
if (Buffer.byteLength(encoded) > messageLimit) throw new Error();
|
|
356
|
+
} catch {
|
|
357
|
+
encoded = JSON.stringify({ ok: false, error: { code, message } });
|
|
358
|
+
}
|
|
359
|
+
writeResponse(mode === "task" ? 1 : 2, encoded);
|
|
360
|
+
process.exitCode = mode === "task" ? 0 : 125;
|
|
361
|
+
}
|
|
362
|
+
function writeResponse(fd, encoded) {
|
|
363
|
+
const bytes = Buffer.from(encoded);
|
|
364
|
+
let offset = 0;
|
|
365
|
+
while (offset < bytes.length) {
|
|
366
|
+
offset += fs.writeSync(fd, bytes, offset, bytes.length - offset);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
async function runTask(input) {
|
|
370
|
+
if (!task)
|
|
371
|
+
fail2("directory_authority_failed", "The directory task is missing.");
|
|
372
|
+
const result = await task(input);
|
|
373
|
+
const encoded = JSON.stringify({ ok: true, result });
|
|
374
|
+
if (Buffer.byteLength(encoded) > messageLimit) {
|
|
375
|
+
fail2(
|
|
376
|
+
"directory_authority_result_too_large",
|
|
377
|
+
"The directory operation result exceeds the bridge byte limit."
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
writeResponse(1, encoded);
|
|
381
|
+
}
|
|
382
|
+
function runCommand(input) {
|
|
383
|
+
const { spawn: spawn2 } = require("node:child_process");
|
|
384
|
+
const command = input;
|
|
385
|
+
const child = spawn2(command.command, command.args, {
|
|
386
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
387
|
+
env: process.env
|
|
388
|
+
});
|
|
389
|
+
child.once("error", reportFailure);
|
|
390
|
+
child.once("exit", (code, signal) => {
|
|
391
|
+
if (signal) {
|
|
392
|
+
process.kill(process.pid, signal);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (typeof code === "number") process.exitCode = code;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
try {
|
|
399
|
+
verifyDirectoryAuthority();
|
|
400
|
+
const input = readRequest();
|
|
401
|
+
if (mode === "command") {
|
|
402
|
+
runCommand(input);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
void runTask(input).catch(reportFailure);
|
|
406
|
+
} catch (error) {
|
|
407
|
+
reportFailure(error);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function directoryAuthorityScript(mode, messageLimit, task) {
|
|
411
|
+
const taskSource = task ? `(${task.toString()})` : "undefined";
|
|
412
|
+
const preserveFunctionName = "const __name=(target,value)=>Object.defineProperty(target,'name',{value,configurable:true});";
|
|
413
|
+
return `${preserveFunctionName}(${directoryAuthorityBootstrap.toString()})(${JSON.stringify(mode)},${messageLimit},${taskSource});`;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// src/shared/directory-authority/protocol.ts
|
|
417
|
+
var import_node_path = require("node:path");
|
|
418
|
+
|
|
419
|
+
// src/shared/directory-authority/errors.ts
|
|
420
|
+
var DirectoryAuthorityError = class extends Error {
|
|
421
|
+
constructor(code, message, data) {
|
|
422
|
+
super(message);
|
|
423
|
+
this.code = code;
|
|
424
|
+
this.data = data;
|
|
425
|
+
this.name = "DirectoryAuthorityError";
|
|
426
|
+
}
|
|
427
|
+
code;
|
|
428
|
+
data;
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// src/shared/directory-authority/protocol.ts
|
|
432
|
+
var AUTHORITY_MESSAGE_LIMIT = 8 * 1024 * 1024;
|
|
433
|
+
var AUTHORITY_STDERR_LIMIT = 16 * 1024;
|
|
434
|
+
var AUTHORITY_TASK_TIMEOUT_MS = 3e4;
|
|
435
|
+
function assertDirectoryAuthorityLocation(location) {
|
|
436
|
+
if (!(0, import_node_path.isAbsolute)(location.directoryPath)) {
|
|
437
|
+
throw new DirectoryAuthorityError(
|
|
438
|
+
"directory_authority_invalid_path",
|
|
439
|
+
"The directory authority requires an absolute starting path."
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
const hasOpenDescriptorNumber = Number.isInteger(location.directoryFd) && location.directoryFd >= 0;
|
|
443
|
+
if (hasOpenDescriptorNumber) return;
|
|
444
|
+
throw new DirectoryAuthorityError(
|
|
445
|
+
"directory_authority_invalid_fd",
|
|
446
|
+
"The directory authority requires an open directory descriptor."
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
function authorityEnvironment(environment = process.env) {
|
|
450
|
+
const sanitized = { ...environment };
|
|
451
|
+
delete sanitized.NODE_OPTIONS;
|
|
452
|
+
delete sanitized.NODE_PATH;
|
|
453
|
+
return sanitized;
|
|
454
|
+
}
|
|
455
|
+
function encodeAuthorityRequest(input) {
|
|
456
|
+
let encoded;
|
|
457
|
+
try {
|
|
458
|
+
encoded = JSON.stringify(input);
|
|
459
|
+
} catch {
|
|
460
|
+
throw new DirectoryAuthorityError(
|
|
461
|
+
"directory_authority_invalid_request",
|
|
462
|
+
"The directory operation input must be JSON serializable."
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
if (encoded === void 0) {
|
|
466
|
+
throw new DirectoryAuthorityError(
|
|
467
|
+
"directory_authority_invalid_request",
|
|
468
|
+
"The directory operation input must be JSON serializable."
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
if (Buffer.byteLength(encoded) <= AUTHORITY_MESSAGE_LIMIT) return encoded;
|
|
472
|
+
throw new DirectoryAuthorityError(
|
|
473
|
+
"directory_authority_request_too_large",
|
|
474
|
+
"The directory operation input exceeds the bridge byte limit."
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
function isAuthorityMessageObject(value) {
|
|
478
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
479
|
+
}
|
|
480
|
+
function decodeAuthorityResult(output) {
|
|
481
|
+
let message;
|
|
482
|
+
try {
|
|
483
|
+
message = JSON.parse(output);
|
|
484
|
+
} catch {
|
|
485
|
+
throw new DirectoryAuthorityError(
|
|
486
|
+
"directory_authority_protocol_error",
|
|
487
|
+
"The directory operation returned an invalid response."
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
if (!isAuthorityMessageObject(message)) {
|
|
491
|
+
throw new DirectoryAuthorityError(
|
|
492
|
+
"directory_authority_protocol_error",
|
|
493
|
+
"The directory operation returned an invalid response."
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
if (message.ok === true) return message.result;
|
|
497
|
+
const hasAuthorityError = message.ok === false && isAuthorityMessageObject(message.error);
|
|
498
|
+
if (!hasAuthorityError) {
|
|
499
|
+
throw new DirectoryAuthorityError(
|
|
500
|
+
"directory_authority_protocol_error",
|
|
501
|
+
"The directory operation returned an invalid response."
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
const {
|
|
505
|
+
code,
|
|
506
|
+
message: explanation,
|
|
507
|
+
data
|
|
508
|
+
} = message.error;
|
|
509
|
+
const hasErrorDescription = typeof code === "string" && typeof explanation === "string";
|
|
510
|
+
if (!hasErrorDescription) {
|
|
511
|
+
throw new DirectoryAuthorityError(
|
|
512
|
+
"directory_authority_protocol_error",
|
|
513
|
+
"The directory operation returned an invalid error response."
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
throw new DirectoryAuthorityError(
|
|
517
|
+
code,
|
|
518
|
+
explanation,
|
|
519
|
+
isAuthorityMessageObject(data) ? data : void 0
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// src/shared/directory-authority/task.ts
|
|
524
|
+
var import_node_child_process = require("node:child_process");
|
|
525
|
+
async function runDirectoryAuthorityTask(input) {
|
|
526
|
+
assertDirectoryAuthorityLocation(input);
|
|
527
|
+
const request = encodeAuthorityRequest(input.input);
|
|
528
|
+
const timeoutMs = input.timeoutMs ?? AUTHORITY_TASK_TIMEOUT_MS;
|
|
529
|
+
const hasPositiveDeadline = Number.isFinite(timeoutMs) && timeoutMs > 0;
|
|
530
|
+
if (!hasPositiveDeadline) {
|
|
531
|
+
throw new DirectoryAuthorityError(
|
|
532
|
+
"directory_authority_invalid_timeout",
|
|
533
|
+
"The directory operation deadline must be a positive finite duration."
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
if (input.signal?.aborted) {
|
|
537
|
+
throw new DirectoryAuthorityError(
|
|
538
|
+
"directory_authority_aborted",
|
|
539
|
+
"The directory operation was cancelled before it started."
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
const child = (0, import_node_child_process.spawn)(
|
|
543
|
+
process.execPath,
|
|
544
|
+
[
|
|
545
|
+
"--input-type=commonjs",
|
|
546
|
+
"-e",
|
|
547
|
+
directoryAuthorityScript("task", AUTHORITY_MESSAGE_LIMIT, input.task)
|
|
548
|
+
],
|
|
549
|
+
{
|
|
550
|
+
cwd: input.directoryPath,
|
|
551
|
+
env: authorityEnvironment(),
|
|
552
|
+
detached: true,
|
|
553
|
+
windowsHide: true,
|
|
554
|
+
stdio: ["pipe", "pipe", "pipe", input.directoryFd]
|
|
555
|
+
}
|
|
556
|
+
);
|
|
557
|
+
return new Promise((resolve, reject) => {
|
|
558
|
+
const chunks = [];
|
|
559
|
+
const stderrChunks = [];
|
|
560
|
+
let bytes = 0;
|
|
561
|
+
let stderrBytes = 0;
|
|
562
|
+
let failure;
|
|
563
|
+
const stop = (error) => {
|
|
564
|
+
if (failure) return;
|
|
565
|
+
failure = error;
|
|
566
|
+
if (typeof child.pid === "number") {
|
|
567
|
+
try {
|
|
568
|
+
process.kill(-child.pid, "SIGKILL");
|
|
569
|
+
return;
|
|
570
|
+
} catch {
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
child.kill("SIGKILL");
|
|
574
|
+
};
|
|
575
|
+
const onAbort = () => stop(
|
|
576
|
+
new DirectoryAuthorityError(
|
|
577
|
+
"directory_authority_aborted",
|
|
578
|
+
"The directory operation was cancelled."
|
|
579
|
+
)
|
|
580
|
+
);
|
|
581
|
+
const timer = setTimeout(
|
|
582
|
+
() => stop(
|
|
583
|
+
new DirectoryAuthorityError(
|
|
584
|
+
"directory_authority_timeout",
|
|
585
|
+
"The directory operation exceeded its deadline."
|
|
586
|
+
)
|
|
587
|
+
),
|
|
588
|
+
timeoutMs
|
|
589
|
+
);
|
|
590
|
+
timer.unref();
|
|
591
|
+
input.signal?.addEventListener("abort", onAbort, { once: true });
|
|
592
|
+
if (input.signal?.aborted) onAbort();
|
|
593
|
+
child.stdout.on("data", (chunk) => {
|
|
594
|
+
bytes += chunk.length;
|
|
595
|
+
if (bytes > AUTHORITY_MESSAGE_LIMIT) {
|
|
596
|
+
stop(
|
|
597
|
+
new DirectoryAuthorityError(
|
|
598
|
+
"directory_authority_result_too_large",
|
|
599
|
+
"The directory operation result exceeds the bridge byte limit."
|
|
600
|
+
)
|
|
601
|
+
);
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
chunks.push(chunk);
|
|
605
|
+
});
|
|
606
|
+
child.stderr.on("data", (chunk) => {
|
|
607
|
+
const remaining = Math.max(AUTHORITY_STDERR_LIMIT - stderrBytes, 0);
|
|
608
|
+
if (remaining === 0) return;
|
|
609
|
+
stderrChunks.push(chunk.subarray(0, remaining));
|
|
610
|
+
stderrBytes += Math.min(chunk.length, remaining);
|
|
611
|
+
});
|
|
612
|
+
child.stdin.on("error", () => void 0);
|
|
613
|
+
child.once("error", (error) => {
|
|
614
|
+
failure ??= new DirectoryAuthorityError(
|
|
615
|
+
"directory_authority_unavailable",
|
|
616
|
+
`The directory operation could not start: ${error.message}`
|
|
617
|
+
);
|
|
618
|
+
});
|
|
619
|
+
child.once("close", (code, signal) => {
|
|
620
|
+
clearTimeout(timer);
|
|
621
|
+
input.signal?.removeEventListener("abort", onAbort);
|
|
622
|
+
if (failure) {
|
|
623
|
+
reject(failure);
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (code !== 0) {
|
|
627
|
+
reject(
|
|
628
|
+
new DirectoryAuthorityError(
|
|
629
|
+
"directory_authority_failed",
|
|
630
|
+
"The directory operation process did not complete successfully.",
|
|
631
|
+
{
|
|
632
|
+
exitCode: code,
|
|
633
|
+
signal,
|
|
634
|
+
stderr: Buffer.concat(stderrChunks).toString("utf8")
|
|
635
|
+
}
|
|
636
|
+
)
|
|
637
|
+
);
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
try {
|
|
641
|
+
resolve(
|
|
642
|
+
decodeAuthorityResult(Buffer.concat(chunks).toString("utf8"))
|
|
643
|
+
);
|
|
644
|
+
} catch (error) {
|
|
645
|
+
reject(error);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
child.stdin.end(request);
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// plugins/filesystem/source/directory-sample-task.ts
|
|
653
|
+
async function sampleDirectoryTask(input) {
|
|
654
|
+
const { opendir: opendir2 } = require("node:fs/promises");
|
|
655
|
+
const entries = [];
|
|
656
|
+
const directory = await opendir2(".");
|
|
657
|
+
for await (const entry of directory) {
|
|
658
|
+
if (entries.length >= input.maxEntries) {
|
|
659
|
+
entries.sort((left, right) => left.localeCompare(right));
|
|
660
|
+
return { entries, truncated: true };
|
|
661
|
+
}
|
|
662
|
+
entries.push(`${entry.name}${entry.isDirectory() ? "/" : ""}`);
|
|
663
|
+
}
|
|
664
|
+
entries.sort((left, right) => left.localeCompare(right));
|
|
665
|
+
return { entries, truncated: false };
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// plugins/filesystem/source/directory-sample.ts
|
|
669
|
+
var DIRECTORY_ENTRY_LIMIT = 160;
|
|
670
|
+
async function readDirectorySample(target) {
|
|
671
|
+
const entries = [];
|
|
672
|
+
let handle;
|
|
673
|
+
try {
|
|
674
|
+
if (typeof import_node_fs.constants.O_DIRECTORY !== "number" || typeof import_node_fs.constants.O_NOFOLLOW !== "number") {
|
|
675
|
+
fail(
|
|
676
|
+
"filesystem_safe_io_unsupported",
|
|
677
|
+
"This platform does not provide the no-follow directory operation required for a safe read."
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
handle = await (0, import_promises.open)(
|
|
681
|
+
target.absolutePath,
|
|
682
|
+
import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_DIRECTORY | import_node_fs.constants.O_NOFOLLOW
|
|
683
|
+
);
|
|
684
|
+
const before = await handle.stat({ bigint: true });
|
|
685
|
+
if (!before.isDirectory()) {
|
|
686
|
+
fail("not_a_directory", `Expected a directory: ${target.logicalPath}`);
|
|
687
|
+
}
|
|
688
|
+
const [canonicalRoot, canonicalTarget] = await Promise.all([
|
|
689
|
+
(0, import_promises.realpath)(target.rootPath),
|
|
690
|
+
(0, import_promises.realpath)(target.absolutePath)
|
|
691
|
+
]);
|
|
692
|
+
const rootRelative = (0, import_node_path2.relative)(canonicalRoot, canonicalTarget);
|
|
693
|
+
if (rootRelative === ".." || rootRelative.startsWith(`..${import_node_path2.sep}`) || rootRelative.startsWith(import_node_path2.sep)) {
|
|
694
|
+
fail(
|
|
695
|
+
"filesystem_path_changed",
|
|
696
|
+
`Directory changed outside its configured root: ${target.logicalPath}`
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
const pathIdentity = await (0, import_promises.stat)(canonicalTarget, { bigint: true });
|
|
700
|
+
if (!pathIdentity.isDirectory() || pathIdentity.dev !== before.dev || pathIdentity.ino !== before.ino) {
|
|
701
|
+
fail(
|
|
702
|
+
"filesystem_path_changed",
|
|
703
|
+
`Directory changed while it was being opened: ${target.logicalPath}`
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
if (requiresIsolatedDirectorySample()) {
|
|
707
|
+
const sample = await runDirectoryAuthorityTask({
|
|
708
|
+
directoryPath: target.absolutePath,
|
|
709
|
+
directoryFd: handle.fd,
|
|
710
|
+
input: { maxEntries: DIRECTORY_ENTRY_LIMIT },
|
|
711
|
+
task: sampleDirectoryTask
|
|
712
|
+
});
|
|
713
|
+
await assertDirectoryStable(handle, before, target.logicalPath);
|
|
714
|
+
return sample;
|
|
715
|
+
}
|
|
716
|
+
const directory = await (0, import_promises.opendir)(`/proc/self/fd/${handle.fd}`);
|
|
717
|
+
for await (const entry of directory) {
|
|
718
|
+
if (entries.length >= DIRECTORY_ENTRY_LIMIT) {
|
|
719
|
+
await assertDirectoryStable(handle, before, target.logicalPath);
|
|
720
|
+
entries.sort((left, right) => left.localeCompare(right));
|
|
721
|
+
return Object.freeze({
|
|
722
|
+
entries: Object.freeze(entries),
|
|
723
|
+
truncated: true
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
entries.push(`${entry.name}${entry.isDirectory() ? "/" : ""}`);
|
|
727
|
+
}
|
|
728
|
+
await assertDirectoryStable(handle, before, target.logicalPath);
|
|
729
|
+
entries.sort((left, right) => left.localeCompare(right));
|
|
730
|
+
return Object.freeze({ entries: Object.freeze(entries), truncated: false });
|
|
731
|
+
} catch (error) {
|
|
732
|
+
if (error instanceof DirectoryAuthorityError && error.code.startsWith("directory_authority_")) {
|
|
733
|
+
fail(
|
|
734
|
+
"filesystem_path_changed",
|
|
735
|
+
`Directory authority was lost: ${target.logicalPath}`
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
return rethrowFilesystemError(error, "inspect", target.logicalPath);
|
|
739
|
+
} finally {
|
|
740
|
+
await handle?.close().catch(() => void 0);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
async function assertDirectoryStable(handle, before, logicalPath) {
|
|
744
|
+
const after = await handle.stat({ bigint: true });
|
|
745
|
+
if (!after.isDirectory() || after.dev !== before.dev || after.ino !== before.ino || after.mtimeNs !== before.mtimeNs || after.ctimeNs !== before.ctimeNs) {
|
|
746
|
+
fail(
|
|
747
|
+
"filesystem_read_changed",
|
|
748
|
+
`Directory changed while it was being read: ${logicalPath}`
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function requiresIsolatedDirectorySample() {
|
|
753
|
+
return process.platform === "darwin";
|
|
754
|
+
}
|
|
755
|
+
|
|
305
756
|
// plugins/filesystem/source/bounded-io.ts
|
|
306
757
|
var MAX_MUTATION_BYTES = 1048576;
|
|
307
758
|
var READ_HEAD_BYTES = 24576;
|
|
308
759
|
var READ_TAIL_BYTES = 12288;
|
|
309
760
|
var DEV_SCAN_BYTES = 1048576;
|
|
310
|
-
var DIRECTORY_ENTRY_LIMIT = 160;
|
|
311
761
|
async function readExactBytes(reader, buffer, position, logicalPath) {
|
|
312
762
|
let offset = 0;
|
|
313
763
|
while (offset < buffer.length) {
|
|
@@ -349,15 +799,15 @@ function decodeMutationText(buffer, logicalPath) {
|
|
|
349
799
|
async function openRegularFile(target) {
|
|
350
800
|
let handle;
|
|
351
801
|
try {
|
|
352
|
-
if (typeof
|
|
802
|
+
if (typeof import_node_fs2.constants.O_NOFOLLOW !== "number") {
|
|
353
803
|
fail(
|
|
354
804
|
"filesystem_safe_io_unsupported",
|
|
355
805
|
"This platform does not provide the no-follow operation required for a safe read."
|
|
356
806
|
);
|
|
357
807
|
}
|
|
358
|
-
handle = await (0,
|
|
808
|
+
handle = await (0, import_promises2.open)(
|
|
359
809
|
target.absolutePath,
|
|
360
|
-
|
|
810
|
+
import_node_fs2.constants.O_RDONLY | import_node_fs2.constants.O_NOFOLLOW
|
|
361
811
|
);
|
|
362
812
|
const info = await handle.stat({ bigint: true });
|
|
363
813
|
if (!info.isFile()) {
|
|
@@ -365,17 +815,17 @@ async function openRegularFile(target) {
|
|
|
365
815
|
}
|
|
366
816
|
const metadata = metadataFromStat(info, target.logicalPath);
|
|
367
817
|
const [canonicalRoot, canonicalTarget] = await Promise.all([
|
|
368
|
-
(0,
|
|
369
|
-
(0,
|
|
818
|
+
(0, import_promises2.realpath)(target.rootPath),
|
|
819
|
+
(0, import_promises2.realpath)(target.absolutePath)
|
|
370
820
|
]);
|
|
371
|
-
const rootRelative = (0,
|
|
372
|
-
if (rootRelative === ".." || rootRelative.startsWith(`..${
|
|
821
|
+
const rootRelative = (0, import_node_path3.relative)(canonicalRoot, canonicalTarget);
|
|
822
|
+
if (rootRelative === ".." || rootRelative.startsWith(`..${import_node_path3.sep}`) || rootRelative.startsWith(import_node_path3.sep)) {
|
|
373
823
|
fail(
|
|
374
824
|
"filesystem_path_changed",
|
|
375
825
|
`File changed outside its configured root: ${target.logicalPath}`
|
|
376
826
|
);
|
|
377
827
|
}
|
|
378
|
-
const pathIdentity = await (0,
|
|
828
|
+
const pathIdentity = await (0, import_promises2.stat)(canonicalTarget, { bigint: true });
|
|
379
829
|
if (!pathIdentity.isFile() || pathIdentity.dev !== info.dev || pathIdentity.ino !== info.ino) {
|
|
380
830
|
fail(
|
|
381
831
|
"filesystem_path_changed",
|
|
@@ -546,72 +996,6 @@ function assertMutationContentSize(content) {
|
|
|
546
996
|
}
|
|
547
997
|
return byteCount;
|
|
548
998
|
}
|
|
549
|
-
async function readDirectorySample(target) {
|
|
550
|
-
const entries = [];
|
|
551
|
-
let handle;
|
|
552
|
-
try {
|
|
553
|
-
if (typeof import_node_fs.constants.O_DIRECTORY !== "number" || typeof import_node_fs.constants.O_NOFOLLOW !== "number") {
|
|
554
|
-
fail(
|
|
555
|
-
"filesystem_safe_io_unsupported",
|
|
556
|
-
"This platform does not provide the no-follow directory operation required for a safe read."
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
handle = await (0, import_promises.open)(
|
|
560
|
-
target.absolutePath,
|
|
561
|
-
import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_DIRECTORY | import_node_fs.constants.O_NOFOLLOW
|
|
562
|
-
);
|
|
563
|
-
const before = await handle.stat({ bigint: true });
|
|
564
|
-
if (!before.isDirectory()) {
|
|
565
|
-
fail("not_a_directory", `Expected a directory: ${target.logicalPath}`);
|
|
566
|
-
}
|
|
567
|
-
const [canonicalRoot, canonicalTarget] = await Promise.all([
|
|
568
|
-
(0, import_promises.realpath)(target.rootPath),
|
|
569
|
-
(0, import_promises.realpath)(target.absolutePath)
|
|
570
|
-
]);
|
|
571
|
-
const rootRelative = (0, import_node_path.relative)(canonicalRoot, canonicalTarget);
|
|
572
|
-
if (rootRelative === ".." || rootRelative.startsWith(`..${import_node_path.sep}`) || rootRelative.startsWith(import_node_path.sep)) {
|
|
573
|
-
fail(
|
|
574
|
-
"filesystem_path_changed",
|
|
575
|
-
`Directory changed outside its configured root: ${target.logicalPath}`
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
const pathIdentity = await (0, import_promises.stat)(canonicalTarget, { bigint: true });
|
|
579
|
-
if (!pathIdentity.isDirectory() || pathIdentity.dev !== before.dev || pathIdentity.ino !== before.ino) {
|
|
580
|
-
fail(
|
|
581
|
-
"filesystem_path_changed",
|
|
582
|
-
`Directory changed while it was being opened: ${target.logicalPath}`
|
|
583
|
-
);
|
|
584
|
-
}
|
|
585
|
-
const directory = await (0, import_promises.opendir)(`/proc/self/fd/${handle.fd}`);
|
|
586
|
-
for await (const entry of directory) {
|
|
587
|
-
if (entries.length >= DIRECTORY_ENTRY_LIMIT) {
|
|
588
|
-
await assertDirectoryStable(handle, before, target.logicalPath);
|
|
589
|
-
entries.sort((left, right) => left.localeCompare(right));
|
|
590
|
-
return Object.freeze({
|
|
591
|
-
entries: Object.freeze(entries),
|
|
592
|
-
truncated: true
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
entries.push(`${entry.name}${entry.isDirectory() ? "/" : ""}`);
|
|
596
|
-
}
|
|
597
|
-
await assertDirectoryStable(handle, before, target.logicalPath);
|
|
598
|
-
entries.sort((left, right) => left.localeCompare(right));
|
|
599
|
-
return Object.freeze({ entries: Object.freeze(entries), truncated: false });
|
|
600
|
-
} catch (error) {
|
|
601
|
-
return rethrowFilesystemError(error, "inspect", target.logicalPath);
|
|
602
|
-
} finally {
|
|
603
|
-
await handle?.close().catch(() => void 0);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
async function assertDirectoryStable(handle, before, logicalPath) {
|
|
607
|
-
const after = await handle.stat({ bigint: true });
|
|
608
|
-
if (!after.isDirectory() || after.dev !== before.dev || after.ino !== before.ino || after.mtimeNs !== before.mtimeNs || after.ctimeNs !== before.ctimeNs) {
|
|
609
|
-
fail(
|
|
610
|
-
"filesystem_read_changed",
|
|
611
|
-
`Directory changed while it was being read: ${logicalPath}`
|
|
612
|
-
);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
999
|
function rejectBinary(buffer, logicalPath) {
|
|
616
1000
|
if (buffer.includes(0)) {
|
|
617
1001
|
fail(
|
|
@@ -725,7 +1109,7 @@ function createDevViewHandler(paths) {
|
|
|
725
1109
|
const target = paths.resolve(pathRange.path, context);
|
|
726
1110
|
let info;
|
|
727
1111
|
try {
|
|
728
|
-
info = await (0,
|
|
1112
|
+
info = await (0, import_promises3.stat)(target.absolutePath);
|
|
729
1113
|
} catch (error) {
|
|
730
1114
|
rethrowFilesystemError(error, "inspect", target.logicalPath);
|
|
731
1115
|
}
|
|
@@ -924,22 +1308,22 @@ async function viewFile(input) {
|
|
|
924
1308
|
|
|
925
1309
|
// plugins/filesystem/source/atomic-write.ts
|
|
926
1310
|
var import_node_crypto2 = require("node:crypto");
|
|
927
|
-
var
|
|
928
|
-
var
|
|
1311
|
+
var import_promises5 = require("node:fs/promises");
|
|
1312
|
+
var import_node_path5 = require("node:path");
|
|
929
1313
|
|
|
930
1314
|
// plugins/filesystem/source/mutation-parent.ts
|
|
931
|
-
var
|
|
932
|
-
var
|
|
933
|
-
var
|
|
1315
|
+
var import_node_fs3 = require("node:fs");
|
|
1316
|
+
var import_promises4 = require("node:fs/promises");
|
|
1317
|
+
var import_node_path4 = require("node:path");
|
|
934
1318
|
function isWithinRoot(target, root) {
|
|
935
|
-
const rel = (0,
|
|
936
|
-
return rel === "" || rel !== ".." && !rel.startsWith(`..${
|
|
1319
|
+
const rel = (0, import_node_path4.relative)(root, target);
|
|
1320
|
+
return rel === "" || rel !== ".." && !rel.startsWith(`..${import_node_path4.sep}`);
|
|
937
1321
|
}
|
|
938
1322
|
function sameIdentity(left, right) {
|
|
939
1323
|
return left.dev === right.dev && left.ino === right.ino;
|
|
940
1324
|
}
|
|
941
1325
|
async function openDirectory(path, rootPath, logicalPath, allowMissing = false) {
|
|
942
|
-
if (typeof
|
|
1326
|
+
if (typeof import_node_fs3.constants.O_DIRECTORY !== "number" || typeof import_node_fs3.constants.O_NOFOLLOW !== "number") {
|
|
943
1327
|
fail(
|
|
944
1328
|
"filesystem_safe_io_unsupported",
|
|
945
1329
|
"This platform does not provide the no-follow directory operations required for a safe write."
|
|
@@ -947,17 +1331,17 @@ async function openDirectory(path, rootPath, logicalPath, allowMissing = false)
|
|
|
947
1331
|
}
|
|
948
1332
|
let handle;
|
|
949
1333
|
try {
|
|
950
|
-
handle = await (0,
|
|
1334
|
+
handle = await (0, import_promises4.open)(
|
|
951
1335
|
path,
|
|
952
|
-
|
|
1336
|
+
import_node_fs3.constants.O_RDONLY | import_node_fs3.constants.O_DIRECTORY | import_node_fs3.constants.O_NOFOLLOW
|
|
953
1337
|
);
|
|
954
1338
|
const opened = await handle.stat({ bigint: true });
|
|
955
1339
|
if (!opened.isDirectory()) {
|
|
956
1340
|
fail("not_a_directory", `Expected a directory: ${logicalPath}`);
|
|
957
1341
|
}
|
|
958
1342
|
const [canonicalRoot, canonicalDirectory] = await Promise.all([
|
|
959
|
-
(0,
|
|
960
|
-
(0,
|
|
1343
|
+
(0, import_promises4.realpath)(rootPath),
|
|
1344
|
+
(0, import_promises4.realpath)(path)
|
|
961
1345
|
]);
|
|
962
1346
|
if (!isWithinRoot(canonicalDirectory, canonicalRoot)) {
|
|
963
1347
|
fail(
|
|
@@ -965,15 +1349,16 @@ async function openDirectory(path, rootPath, logicalPath, allowMissing = false)
|
|
|
965
1349
|
`Directory changed outside its configured root: ${logicalPath}`
|
|
966
1350
|
);
|
|
967
1351
|
}
|
|
968
|
-
const pathIdentity = await (0,
|
|
1352
|
+
const pathIdentity = await (0, import_promises4.stat)(canonicalDirectory, { bigint: true });
|
|
969
1353
|
if (!pathIdentity.isDirectory() || !sameIdentity(opened, pathIdentity)) {
|
|
970
1354
|
fail(
|
|
971
1355
|
"filesystem_path_changed",
|
|
972
1356
|
`Directory changed while it was being opened: ${logicalPath}`
|
|
973
1357
|
);
|
|
974
1358
|
}
|
|
1359
|
+
if (usesIsolatedDirectoryAuthority()) return handle;
|
|
975
1360
|
const procPath = `/proc/self/fd/${handle.fd}`;
|
|
976
|
-
const procIdentity = await (0,
|
|
1361
|
+
const procIdentity = await (0, import_promises4.stat)(procPath, { bigint: true });
|
|
977
1362
|
if (!procIdentity.isDirectory() || !sameIdentity(opened, procIdentity)) {
|
|
978
1363
|
fail(
|
|
979
1364
|
"filesystem_safe_io_unsupported",
|
|
@@ -1000,7 +1385,7 @@ async function openChildDirectory(parent, name, logicalPath) {
|
|
|
1000
1385
|
if (!isNodeErrorCode(error, "ENOENT")) throw error;
|
|
1001
1386
|
}
|
|
1002
1387
|
try {
|
|
1003
|
-
await (0,
|
|
1388
|
+
await (0, import_promises4.mkdir)(anchoredPath);
|
|
1004
1389
|
} catch (error) {
|
|
1005
1390
|
if (!isNodeErrorCode(error, "EEXIST")) {
|
|
1006
1391
|
rethrowFilesystemError(error, "write", logicalPath);
|
|
@@ -1047,10 +1432,197 @@ async function openMutationParent(target) {
|
|
|
1047
1432
|
throw error;
|
|
1048
1433
|
}
|
|
1049
1434
|
}
|
|
1435
|
+
function usesIsolatedDirectoryAuthority() {
|
|
1436
|
+
return process.platform === "darwin";
|
|
1437
|
+
}
|
|
1438
|
+
function openMutationRoot(target) {
|
|
1439
|
+
return openDirectory(target.rootPath, target.rootPath, target.logicalPath);
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
// plugins/filesystem/source/directory-write-task.ts
|
|
1443
|
+
async function commitDirectoryWrite(input) {
|
|
1444
|
+
const fs = require("node:fs/promises");
|
|
1445
|
+
const { constants: constants4 } = require("node:fs");
|
|
1446
|
+
const { createHash: createHash3, randomUUID: randomUUID2 } = require("node:crypto");
|
|
1447
|
+
const expected = input.expectedVersion;
|
|
1448
|
+
function failWrite(code) {
|
|
1449
|
+
throw Object.assign(new Error(code), { code });
|
|
1450
|
+
}
|
|
1451
|
+
function hasNodeCode(error, code) {
|
|
1452
|
+
return error instanceof Error && "code" in error && error.code === code;
|
|
1453
|
+
}
|
|
1454
|
+
function isSingleComponent(value) {
|
|
1455
|
+
if (!value || value === "." || value === "..") return false;
|
|
1456
|
+
if (value.includes("/") || value.includes("\\")) return false;
|
|
1457
|
+
return !value.includes("\0");
|
|
1458
|
+
}
|
|
1459
|
+
const segments = input.relativePath.split("/");
|
|
1460
|
+
if (!segments.every(isSingleComponent)) failWrite("filesystem_path_changed");
|
|
1461
|
+
const targetName = segments.pop();
|
|
1462
|
+
if (Buffer.byteLength(input.content, "utf8") > 1048576) {
|
|
1463
|
+
failWrite("filesystem_file_too_large");
|
|
1464
|
+
}
|
|
1465
|
+
async function enterChildDirectory(name) {
|
|
1466
|
+
let handle;
|
|
1467
|
+
const flags = constants4.O_RDONLY | constants4.O_DIRECTORY | constants4.O_NOFOLLOW;
|
|
1468
|
+
try {
|
|
1469
|
+
handle = await fs.open(name, flags);
|
|
1470
|
+
} catch (error) {
|
|
1471
|
+
if (!hasNodeCode(error, "ENOENT")) throw error;
|
|
1472
|
+
try {
|
|
1473
|
+
await fs.mkdir(name);
|
|
1474
|
+
} catch (creationError) {
|
|
1475
|
+
if (!hasNodeCode(creationError, "EEXIST")) throw creationError;
|
|
1476
|
+
}
|
|
1477
|
+
handle = await fs.open(name, flags);
|
|
1478
|
+
}
|
|
1479
|
+
try {
|
|
1480
|
+
const held = await handle.stat({ bigint: true });
|
|
1481
|
+
if (!held.isDirectory()) failWrite("filesystem_path_changed");
|
|
1482
|
+
process.chdir(name);
|
|
1483
|
+
const entered = await fs.stat(".", { bigint: true });
|
|
1484
|
+
if (held.dev !== entered.dev || held.ino !== entered.ino) {
|
|
1485
|
+
failWrite("filesystem_path_changed");
|
|
1486
|
+
}
|
|
1487
|
+
} finally {
|
|
1488
|
+
await handle.close();
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
for (const segment of segments) await enterChildDirectory(segment);
|
|
1492
|
+
function hasExpectedMetadata(info) {
|
|
1493
|
+
if (expected.kind !== "file" || !info.isFile()) return false;
|
|
1494
|
+
if (String(info.dev) !== expected.device) return false;
|
|
1495
|
+
if (String(info.ino) !== expected.inode) return false;
|
|
1496
|
+
if (Number(info.size) !== expected.size) return false;
|
|
1497
|
+
if ((Number(info.mode) & 4095) !== expected.mode) return false;
|
|
1498
|
+
if (String(info.mtimeNs) !== expected.modifiedNs) return false;
|
|
1499
|
+
return String(info.ctimeNs) === expected.changedNs;
|
|
1500
|
+
}
|
|
1501
|
+
async function assertExpectedTarget() {
|
|
1502
|
+
let target;
|
|
1503
|
+
try {
|
|
1504
|
+
target = await fs.open(
|
|
1505
|
+
targetName,
|
|
1506
|
+
constants4.O_RDONLY | constants4.O_NOFOLLOW | constants4.O_NONBLOCK
|
|
1507
|
+
);
|
|
1508
|
+
} catch (error) {
|
|
1509
|
+
if (hasNodeCode(error, "ENOENT") && expected.kind === "absent") return;
|
|
1510
|
+
failWrite("filesystem_target_changed");
|
|
1511
|
+
}
|
|
1512
|
+
try {
|
|
1513
|
+
const before = await target.stat({ bigint: true });
|
|
1514
|
+
if (!hasExpectedMetadata(before)) failWrite("filesystem_target_changed");
|
|
1515
|
+
if (expected.kind !== "file") failWrite("filesystem_target_changed");
|
|
1516
|
+
const bytes = Buffer.alloc(expected.size);
|
|
1517
|
+
let offset = 0;
|
|
1518
|
+
while (offset < bytes.length) {
|
|
1519
|
+
const { bytesRead } = await target.read(
|
|
1520
|
+
bytes,
|
|
1521
|
+
offset,
|
|
1522
|
+
bytes.length - offset,
|
|
1523
|
+
offset
|
|
1524
|
+
);
|
|
1525
|
+
if (bytesRead <= 0) failWrite("filesystem_target_changed");
|
|
1526
|
+
offset += bytesRead;
|
|
1527
|
+
}
|
|
1528
|
+
const after = await target.stat({ bigint: true });
|
|
1529
|
+
if (!hasExpectedMetadata(after)) failWrite("filesystem_target_changed");
|
|
1530
|
+
const digest2 = createHash3("sha256").update(bytes).digest("hex");
|
|
1531
|
+
if (digest2 !== expected.digest) failWrite("filesystem_target_changed");
|
|
1532
|
+
} finally {
|
|
1533
|
+
await target.close();
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
const parent = await fs.open(
|
|
1537
|
+
".",
|
|
1538
|
+
constants4.O_RDONLY | constants4.O_DIRECTORY | constants4.O_NOFOLLOW
|
|
1539
|
+
);
|
|
1540
|
+
const temporaryName = `.abot-${targetName}-${randomUUID2()}.tmp`;
|
|
1541
|
+
let temporaryCreated = false;
|
|
1542
|
+
try {
|
|
1543
|
+
const temporary = await fs.open(temporaryName, "wx");
|
|
1544
|
+
temporaryCreated = true;
|
|
1545
|
+
try {
|
|
1546
|
+
await temporary.writeFile(input.content, "utf8");
|
|
1547
|
+
if (expected.kind === "file") await temporary.chmod(expected.mode);
|
|
1548
|
+
await temporary.sync();
|
|
1549
|
+
} finally {
|
|
1550
|
+
await temporary.close();
|
|
1551
|
+
}
|
|
1552
|
+
await assertExpectedTarget();
|
|
1553
|
+
if (expected.kind === "file") {
|
|
1554
|
+
await fs.rename(temporaryName, targetName);
|
|
1555
|
+
temporaryCreated = false;
|
|
1556
|
+
} else {
|
|
1557
|
+
try {
|
|
1558
|
+
await fs.link(temporaryName, targetName);
|
|
1559
|
+
} catch (error) {
|
|
1560
|
+
if (hasNodeCode(error, "EEXIST"))
|
|
1561
|
+
failWrite("filesystem_target_changed");
|
|
1562
|
+
throw error;
|
|
1563
|
+
}
|
|
1564
|
+
const removed = await fs.rm(temporaryName, { force: true }).then(() => true).catch(() => false);
|
|
1565
|
+
temporaryCreated = !removed;
|
|
1566
|
+
}
|
|
1567
|
+
await parent.sync().catch(() => void 0);
|
|
1568
|
+
} finally {
|
|
1569
|
+
if (temporaryCreated)
|
|
1570
|
+
await fs.rm(temporaryName, { force: true }).catch(() => void 0);
|
|
1571
|
+
await parent.close().catch(() => void 0);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
// plugins/filesystem/source/directory-authority-write.ts
|
|
1576
|
+
async function writeWithDirectoryAuthority(input) {
|
|
1577
|
+
const root = await openMutationRoot(input.target);
|
|
1578
|
+
const expected = input.expectedVersion;
|
|
1579
|
+
const expectedVersion = expected.kind === "absent" ? { kind: "absent" } : {
|
|
1580
|
+
...expected,
|
|
1581
|
+
device: String(expected.device),
|
|
1582
|
+
inode: String(expected.inode),
|
|
1583
|
+
modifiedNs: String(expected.modifiedNs),
|
|
1584
|
+
changedNs: String(expected.changedNs)
|
|
1585
|
+
};
|
|
1586
|
+
try {
|
|
1587
|
+
await runDirectoryAuthorityTask({
|
|
1588
|
+
directoryPath: input.target.rootPath,
|
|
1589
|
+
directoryFd: root.fd,
|
|
1590
|
+
input: {
|
|
1591
|
+
relativePath: input.target.relativePath,
|
|
1592
|
+
content: input.content,
|
|
1593
|
+
expectedVersion
|
|
1594
|
+
},
|
|
1595
|
+
task: commitDirectoryWrite
|
|
1596
|
+
});
|
|
1597
|
+
} catch (error) {
|
|
1598
|
+
if (error instanceof DirectoryAuthorityError) {
|
|
1599
|
+
if (error.code.startsWith("filesystem_")) {
|
|
1600
|
+
fail(
|
|
1601
|
+
error.code,
|
|
1602
|
+
`Safe write failed: ${input.target.logicalPath}`,
|
|
1603
|
+
error.data
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
if (error.code.startsWith("directory_authority_")) {
|
|
1607
|
+
fail(
|
|
1608
|
+
"filesystem_path_changed",
|
|
1609
|
+
`Directory authority was lost: ${input.target.logicalPath}`
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
rethrowFilesystemError(error, "write", input.target.logicalPath);
|
|
1614
|
+
} finally {
|
|
1615
|
+
await root.close().catch(() => void 0);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1050
1618
|
|
|
1051
1619
|
// plugins/filesystem/source/atomic-write.ts
|
|
1052
1620
|
async function atomicWriteText(input) {
|
|
1053
1621
|
assertMutationContentSize(input.content);
|
|
1622
|
+
if (requiresIsolatedDirectoryAuthority()) {
|
|
1623
|
+
await writeWithDirectoryAuthority(input);
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1054
1626
|
const parent = await openMutationParent(input.target);
|
|
1055
1627
|
const targetPath = `${parent.procPath}/${parent.targetName}`;
|
|
1056
1628
|
const anchoredTarget = Object.freeze({
|
|
@@ -1059,12 +1631,12 @@ async function atomicWriteText(input) {
|
|
|
1059
1631
|
absolutePath: targetPath,
|
|
1060
1632
|
relativePath: parent.targetName
|
|
1061
1633
|
});
|
|
1062
|
-
const temporaryName = `.abot-${
|
|
1634
|
+
const temporaryName = `.abot-${import_node_path5.posix.basename(parent.targetName)}-${(0, import_node_crypto2.randomUUID)()}.tmp`;
|
|
1063
1635
|
const temporaryPath = `${parent.procPath}/${temporaryName}`;
|
|
1064
1636
|
const existingMode = input.expectedVersion.kind === "file" ? input.expectedVersion.mode : void 0;
|
|
1065
1637
|
let temporaryCreated = false;
|
|
1066
1638
|
try {
|
|
1067
|
-
const temporaryHandle = await (0,
|
|
1639
|
+
const temporaryHandle = await (0, import_promises5.open)(temporaryPath, "wx");
|
|
1068
1640
|
temporaryCreated = true;
|
|
1069
1641
|
try {
|
|
1070
1642
|
await temporaryHandle.writeFile(input.content, "utf8");
|
|
@@ -1086,7 +1658,7 @@ async function atomicWriteText(input) {
|
|
|
1086
1658
|
if (input.expectedVersion.kind === "file") {
|
|
1087
1659
|
temporaryCreated = false;
|
|
1088
1660
|
} else {
|
|
1089
|
-
const removed = await (0,
|
|
1661
|
+
const removed = await (0, import_promises5.rm)(temporaryPath, { force: true }).then(() => true).catch(() => false);
|
|
1090
1662
|
temporaryCreated = !removed;
|
|
1091
1663
|
}
|
|
1092
1664
|
await syncDirectoryBestEffort(parent.handle);
|
|
@@ -1094,7 +1666,7 @@ async function atomicWriteText(input) {
|
|
|
1094
1666
|
rethrowFilesystemError(error, "write", input.target.logicalPath);
|
|
1095
1667
|
} finally {
|
|
1096
1668
|
if (temporaryCreated) {
|
|
1097
|
-
await (0,
|
|
1669
|
+
await (0, import_promises5.rm)(temporaryPath, { force: true }).catch(() => void 0);
|
|
1098
1670
|
}
|
|
1099
1671
|
await parent.handle.close().catch(() => void 0);
|
|
1100
1672
|
}
|
|
@@ -1103,11 +1675,11 @@ async function installPreparedFile(input) {
|
|
|
1103
1675
|
const temporaryPath = `${input.parentProcPath}/${input.temporaryName}`;
|
|
1104
1676
|
const targetPath = `${input.parentProcPath}/${input.targetName}`;
|
|
1105
1677
|
if (input.expectedKind === "file") {
|
|
1106
|
-
await (0,
|
|
1678
|
+
await (0, import_promises5.rename)(temporaryPath, targetPath);
|
|
1107
1679
|
return;
|
|
1108
1680
|
}
|
|
1109
1681
|
try {
|
|
1110
|
-
await (0,
|
|
1682
|
+
await (0, import_promises5.link)(temporaryPath, targetPath);
|
|
1111
1683
|
} catch (error) {
|
|
1112
1684
|
if (isNodeErrorCode(error, "EEXIST")) {
|
|
1113
1685
|
fail(
|
|
@@ -1124,10 +1696,13 @@ async function syncDirectoryBestEffort(handle) {
|
|
|
1124
1696
|
} catch {
|
|
1125
1697
|
}
|
|
1126
1698
|
}
|
|
1699
|
+
function requiresIsolatedDirectoryAuthority() {
|
|
1700
|
+
return process.platform === "darwin";
|
|
1701
|
+
}
|
|
1127
1702
|
|
|
1128
1703
|
// plugins/filesystem/source/draft/grounding.ts
|
|
1129
1704
|
var import_node_crypto3 = require("node:crypto");
|
|
1130
|
-
var
|
|
1705
|
+
var import_node_path6 = require("node:path");
|
|
1131
1706
|
var GROUNDING_MAX_CHARS = 32768;
|
|
1132
1707
|
var SNAPSHOT_MAX_CHARS = 3e4;
|
|
1133
1708
|
var SNAPSHOT_SEGMENT_CHARS = Math.floor(SNAPSHOT_MAX_CHARS / 2);
|
|
@@ -1136,7 +1711,7 @@ function buildMutationGrounding(input) {
|
|
|
1136
1711
|
const byteCount = Buffer.byteLength(input.content, "utf8");
|
|
1137
1712
|
const lineCount = input.content.length ? input.content.split(/\r?\n/u).length : 0;
|
|
1138
1713
|
const sha256 = (0, import_node_crypto3.createHash)("sha256").update(input.content).digest("hex");
|
|
1139
|
-
const extension = (0,
|
|
1714
|
+
const extension = (0, import_node_path6.extname)(input.logicalPath).toLowerCase() || "none";
|
|
1140
1715
|
const snapshot = projectSnapshot(input.content, input.previousContent);
|
|
1141
1716
|
const summary = bound(
|
|
1142
1717
|
[
|
|
@@ -1380,7 +1955,7 @@ function scopeError(message) {
|
|
|
1380
1955
|
// plugins/filesystem/source/draft/validators.ts
|
|
1381
1956
|
var import_parser = require("@babel/parser");
|
|
1382
1957
|
var import_postcss = require("postcss");
|
|
1383
|
-
var
|
|
1958
|
+
var import_node_path7 = require("node:path");
|
|
1384
1959
|
var SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1385
1960
|
".js",
|
|
1386
1961
|
".jsx",
|
|
@@ -1420,7 +1995,7 @@ function lineColumnAt(content, offset) {
|
|
|
1420
1995
|
});
|
|
1421
1996
|
}
|
|
1422
1997
|
function scriptOptions(targetPath) {
|
|
1423
|
-
const extension = (0,
|
|
1998
|
+
const extension = (0, import_node_path7.extname)(targetPath).toLowerCase();
|
|
1424
1999
|
const plugins = [];
|
|
1425
2000
|
if ([".js", ".jsx", ".mjs", ".cjs", ".tsx"].includes(extension)) {
|
|
1426
2001
|
plugins.push("jsx");
|
|
@@ -1483,7 +2058,7 @@ function foreignScriptWrapper(content, targetPath, originalError) {
|
|
|
1483
2058
|
return parseScript(projected.join("\n"), targetPath) === void 0;
|
|
1484
2059
|
};
|
|
1485
2060
|
if (opening && closing && first < last && parsesWithout(first, last)) {
|
|
1486
|
-
const extension = (0,
|
|
2061
|
+
const extension = (0, import_node_path7.extname)(targetPath).toLowerCase();
|
|
1487
2062
|
if (!originalError && [".jsx", ".tsx"].includes(extension))
|
|
1488
2063
|
return void 0;
|
|
1489
2064
|
return wrapperDiagnostic(lines[first], first, "opening", 2);
|
|
@@ -1501,14 +2076,14 @@ var validators = Object.freeze([
|
|
|
1501
2076
|
id: "json",
|
|
1502
2077
|
label: "strict JSON",
|
|
1503
2078
|
authoritativeStructure: true,
|
|
1504
|
-
matchesTarget: (targetPath) => (0,
|
|
2079
|
+
matchesTarget: (targetPath) => (0, import_node_path7.extname)(targetPath).toLowerCase() === ".json",
|
|
1505
2080
|
validate: (content) => validateJson(content)
|
|
1506
2081
|
}),
|
|
1507
2082
|
Object.freeze({
|
|
1508
2083
|
id: "css",
|
|
1509
2084
|
label: "CSS",
|
|
1510
2085
|
authoritativeStructure: true,
|
|
1511
|
-
matchesTarget: (targetPath) => (0,
|
|
2086
|
+
matchesTarget: (targetPath) => (0, import_node_path7.extname)(targetPath).toLowerCase() === ".css",
|
|
1512
2087
|
validate(content, targetPath) {
|
|
1513
2088
|
try {
|
|
1514
2089
|
(0, import_postcss.parse)(content, { from: targetPath });
|
|
@@ -1528,7 +2103,7 @@ var validators = Object.freeze([
|
|
|
1528
2103
|
id: "script",
|
|
1529
2104
|
label: "JavaScript/TypeScript",
|
|
1530
2105
|
authoritativeStructure: true,
|
|
1531
|
-
matchesTarget: (targetPath) => SCRIPT_EXTENSIONS.has((0,
|
|
2106
|
+
matchesTarget: (targetPath) => SCRIPT_EXTENSIONS.has((0, import_node_path7.extname)(targetPath).toLowerCase()),
|
|
1532
2107
|
validate(content, targetPath) {
|
|
1533
2108
|
const error = parseScript(content, targetPath);
|
|
1534
2109
|
return foreignScriptWrapper(content, targetPath, error) ?? (error ? scriptDiagnostic(error) : void 0);
|
|
@@ -1877,17 +2452,17 @@ function delimiterRegressions(previous, updated) {
|
|
|
1877
2452
|
["square", "[", "]"],
|
|
1878
2453
|
["paren", "(", ")"]
|
|
1879
2454
|
];
|
|
1880
|
-
return delimiters.flatMap(([name,
|
|
1881
|
-
if (!previous.includes(
|
|
1882
|
-
const before = balance(previous,
|
|
1883
|
-
const after = balance(updated,
|
|
2455
|
+
return delimiters.flatMap(([name, open5, close]) => {
|
|
2456
|
+
if (!previous.includes(open5) || !previous.includes(close)) return [];
|
|
2457
|
+
const before = balance(previous, open5, close);
|
|
2458
|
+
const after = balance(updated, open5, close);
|
|
1884
2459
|
return before === 0 && after !== 0 ? [`${name} delimiter balance changed from 0 to ${after}`] : [];
|
|
1885
2460
|
});
|
|
1886
2461
|
}
|
|
1887
|
-
function balance(content,
|
|
2462
|
+
function balance(content, open5, close) {
|
|
1888
2463
|
let count = 0;
|
|
1889
2464
|
for (const character of content) {
|
|
1890
|
-
if (character ===
|
|
2465
|
+
if (character === open5) count += 1;
|
|
1891
2466
|
else if (character === close) count -= 1;
|
|
1892
2467
|
}
|
|
1893
2468
|
return count;
|
|
@@ -1933,7 +2508,7 @@ function getProcessFilesystemMutationCoordinator() {
|
|
|
1933
2508
|
}
|
|
1934
2509
|
|
|
1935
2510
|
// plugins/filesystem/source/path-service.ts
|
|
1936
|
-
var
|
|
2511
|
+
var import_node_path8 = require("node:path");
|
|
1937
2512
|
var FILESYSTEM_LOCATIONS = Object.freeze([
|
|
1938
2513
|
"agent_work",
|
|
1939
2514
|
"workspace"
|
|
@@ -1951,7 +2526,7 @@ function logicalParent(logicalPath) {
|
|
|
1951
2526
|
if (logicalPath === "." || logicalPath === "workspace") {
|
|
1952
2527
|
return logicalPath;
|
|
1953
2528
|
}
|
|
1954
|
-
return
|
|
2529
|
+
return import_node_path8.posix.dirname(logicalPath);
|
|
1955
2530
|
}
|
|
1956
2531
|
function createFilesystemPathService(fallbackResolver) {
|
|
1957
2532
|
return Object.freeze({
|
|
@@ -1966,7 +2541,7 @@ function createFilesystemPathService(fallbackResolver) {
|
|
|
1966
2541
|
},
|
|
1967
2542
|
sibling(target, name, context) {
|
|
1968
2543
|
const parent = logicalParent(target.logicalPath);
|
|
1969
|
-
const logicalPath = parent === "." ? name :
|
|
2544
|
+
const logicalPath = parent === "." ? name : import_node_path8.posix.join(parent, name);
|
|
1970
2545
|
return resolveWith(resolverFor(fallbackResolver, context), logicalPath);
|
|
1971
2546
|
}
|
|
1972
2547
|
});
|