pi-better-server 0.4.0 → 0.6.0
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/package.json +8 -1
- package/scripts/copy-pi-test-providers.mjs +10 -0
- package/scripts/event-publication/README.md +26 -0
- package/scripts/event-publication/commit.mjs +21 -0
- package/scripts/event-publication/measure.mjs +87 -0
- package/scripts/event-publication/writer.mjs +6 -0
- package/scripts/measure-full-runtime/frontend.ts +24 -0
- package/scripts/measure-full-runtime/hosted-extension.ts +28 -0
- package/scripts/measure-full-runtime/probe.mjs +29 -0
- package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
- package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
- package/scripts/measure-full-runtime.mjs +146 -0
- package/scripts/measure-shared-reads/probe.mjs +26 -2
- package/scripts/measure-shared-reads.mjs +44 -9
- package/scripts/private-runtime/package-lock.json +66 -4
- package/scripts/private-runtime/package.json +10 -2
- package/scripts/source-provenance.mjs +31 -0
- package/scripts/test-on-pi.sh +3 -9
- package/src/handshake.ts +1 -1
- package/src/hosted-session.ts +32 -4
- package/src/maintenance.ts +35 -7
- package/src/registry.ts +28 -4
- package/src/runtime/attempt-invalidation.ts +54 -0
- package/src/runtime/background-history.ts +151 -45
- package/src/runtime/background-policy.ts +27 -0
- package/src/runtime/background-tools.ts +389 -0
- package/src/runtime/background.ts +410 -48
- package/src/runtime/cancellation.ts +28 -7
- package/src/runtime/catalog-sources.ts +199 -0
- package/src/runtime/catalog.ts +53 -21
- package/src/runtime/client.ts +22 -2
- package/src/runtime/domain/assignment-inbox.mjs +119 -0
- package/src/runtime/domain/assignment-observation.d.mts +1 -1
- package/src/runtime/domain/assignment-observation.mjs +71 -33
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +3 -3
- package/src/runtime/domain/background/registry.mjs +89 -4
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +83 -0
- package/src/runtime/domain/background-service/adapter-contract.ts +70 -0
- package/src/runtime/domain/background-service/batch.domain.mjs +91 -0
- package/src/runtime/domain/background-service/batch.ts +111 -0
- package/src/runtime/domain/background-service/conditions.domain.mjs +94 -0
- package/src/runtime/domain/background-service/conditions.ts +99 -0
- package/src/runtime/domain/background-service/delivery-observer.domain.mjs +37 -0
- package/src/runtime/domain/background-service/delivery-observer.ts +42 -0
- package/src/runtime/domain/background-service/failures.domain.mjs +209 -0
- package/src/runtime/domain/background-service/failures.ts +212 -0
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +193 -0
- package/src/runtime/domain/background-service/goal-provider.ts +209 -0
- package/src/runtime/domain/background-service/index.domain.mjs +54 -0
- package/src/runtime/domain/background-service/index.ts +55 -0
- package/src/runtime/domain/background-service/logs.domain.mjs +129 -0
- package/src/runtime/domain/background-service/logs.ts +134 -0
- package/src/runtime/domain/background-service/maintenance.domain.mjs +95 -0
- package/src/runtime/domain/background-service/maintenance.ts +98 -0
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +32 -0
- package/src/runtime/domain/background-service/managed-authority.ts +30 -0
- package/src/runtime/domain/background-service/managed-client.domain.mjs +79 -0
- package/src/runtime/domain/background-service/managed-client.ts +73 -0
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +225 -0
- package/src/runtime/domain/background-service/managed-frontend.ts +176 -0
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +492 -0
- package/src/runtime/domain/background-service/navigator-provider.ts +485 -0
- package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
- package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +4080 -0
- package/src/runtime/domain/background-service/observed-waits.ts +4513 -0
- package/src/runtime/domain/background-service/output.domain.mjs +867 -0
- package/src/runtime/domain/background-service/output.ts +952 -0
- package/src/runtime/domain/background-service/process-identity.domain.mjs +129 -0
- package/src/runtime/domain/background-service/process-identity.ts +134 -0
- package/src/runtime/domain/background-service/process.domain.mjs +512 -0
- package/src/runtime/domain/background-service/process.ts +532 -0
- package/src/runtime/domain/background-service/prompt.domain.mjs +58 -0
- package/src/runtime/domain/background-service/prompt.ts +72 -0
- package/src/runtime/domain/background-service/registry.domain.mjs +460 -0
- package/src/runtime/domain/background-service/registry.ts +450 -0
- package/src/runtime/domain/background-service/remote-task-preset.domain.mjs +67 -0
- package/src/runtime/domain/background-service/remote-task-preset.ts +127 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +1511 -0
- package/src/runtime/domain/background-service/runtime.ts +1636 -0
- package/src/runtime/domain/background-service/sandbox.domain.mjs +735 -0
- package/src/runtime/domain/background-service/sandbox.ts +913 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/background-service/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/background-service/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/background-service/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/background-service/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/background-service/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/background-service/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/background-service/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/background-service/shared-navigator.ts +1962 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +698 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.ts +979 -0
- package/src/runtime/domain/background-service/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/background-service/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/background-service/shared-work-client.mjs +303 -0
- package/src/runtime/domain/background-service/stall-attention.domain.mjs +29 -0
- package/src/runtime/domain/background-service/stall-attention.ts +31 -0
- package/src/runtime/domain/background-service/stall.domain.mjs +57 -0
- package/src/runtime/domain/background-service/stall.ts +57 -0
- package/src/runtime/domain/background-service/supervisor/README.md +111 -0
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +90 -0
- package/src/runtime/domain/background-service/supervisor/generated/conditions.mjs +96 -0
- package/src/runtime/domain/background-service/supervisor/generated/identity.mjs +95 -0
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +131 -0
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +514 -0
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +872 -0
- package/src/runtime/domain/background-service/supervisor/generated/store.mjs +609 -0
- package/src/runtime/domain/background-service/supervisor/generated/types.mjs +50 -0
- package/src/runtime/domain/background-service/supervisor/identity.domain.mjs +93 -0
- package/src/runtime/domain/background-service/supervisor/identity.ts +99 -0
- package/src/runtime/domain/background-service/supervisor/index.domain.mjs +22 -0
- package/src/runtime/domain/background-service/supervisor/index.ts +37 -0
- package/src/runtime/domain/background-service/supervisor/invocation.domain.mjs +30 -0
- package/src/runtime/domain/background-service/supervisor/invocation.ts +44 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +870 -0
- package/src/runtime/domain/background-service/supervisor/runner.ts +982 -0
- package/src/runtime/domain/background-service/supervisor/store.domain.mjs +605 -0
- package/src/runtime/domain/background-service/supervisor/store.ts +651 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +721 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.ts +804 -0
- package/src/runtime/domain/background-service/supervisor/types.domain.mjs +48 -0
- package/src/runtime/domain/background-service/supervisor/types.ts +394 -0
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +60 -0
- package/src/runtime/domain/background-service/task-diagnostics.ts +71 -0
- package/src/runtime/domain/background-service/tools.domain.mjs +1050 -0
- package/src/runtime/domain/background-service/tools.ts +1142 -0
- package/src/runtime/domain/background-service/types.domain.mjs +5 -0
- package/src/runtime/domain/background-service/types.ts +236 -0
- package/src/runtime/domain/background-service/work-observation.domain.mjs +176 -0
- package/src/runtime/domain/background-service/work-observation.ts +144 -0
- package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
- package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
- package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
- package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
- package/src/runtime/domain/coordinator/src/background-parent-callbacks.mjs +65 -0
- package/src/runtime/domain/coordinator/src/background-requests.mjs +86 -0
- package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
- package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
- package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
- package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +73 -21
- package/src/runtime/domain/coordinator/src/store.mjs +32 -3
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +119 -0
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- package/src/runtime/domain/coordinator/src/upgrade.mjs +22 -0
- package/src/runtime/domain/health-observation.d.mts +3 -1
- package/src/runtime/domain/health-observation.mjs +189 -190
- package/src/runtime/domain/log-cursor.d.mts +2 -0
- package/src/runtime/domain/log-cursor.mjs +85 -16
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +50 -5
- package/src/runtime/domain/sandbox-policy/README.md +633 -0
- package/src/runtime/domain/sandbox-policy/background-admission.domain.mjs +83 -0
- package/src/runtime/domain/sandbox-policy/background-admission.ts +75 -0
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +245 -0
- package/src/runtime/domain/sandbox-policy/commands.ts +336 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.domain.mjs +440 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.ts +620 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.domain.mjs +30 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.ts +27 -0
- package/src/runtime/domain/sandbox-policy/events.domain.mjs +49 -0
- package/src/runtime/domain/sandbox-policy/events.ts +85 -0
- package/src/runtime/domain/sandbox-policy/files.domain.mjs +153 -0
- package/src/runtime/domain/sandbox-policy/files.ts +224 -0
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +289 -0
- package/src/runtime/domain/sandbox-policy/index.ts +386 -0
- package/src/runtime/domain/sandbox-policy/package.json +66 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +36 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +46 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +309 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +295 -0
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +98 -0
- package/src/runtime/domain/sandbox-policy/permissions.ts +125 -0
- package/src/runtime/domain/sandbox-policy/policy.domain.mjs +80 -0
- package/src/runtime/domain/sandbox-policy/policy.ts +102 -0
- package/src/runtime/domain/sandbox-policy/preferences.domain.mjs +55 -0
- package/src/runtime/domain/sandbox-policy/preferences.ts +82 -0
- package/src/runtime/domain/sandbox-policy/rules-page.domain.mjs +138 -0
- package/src/runtime/domain/sandbox-policy/rules-page.ts +176 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.domain.mjs +22 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.ts +24 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.ts +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +335 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.ts +342 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +123 -0
- package/src/runtime/domain/sandbox-policy/shell.domain.mjs +93 -0
- package/src/runtime/domain/sandbox-policy/shell.ts +129 -0
- package/src/runtime/domain/sandbox-policy/state.domain.mjs +307 -0
- package/src/runtime/domain/sandbox-policy/state.ts +408 -0
- package/src/runtime/domain/sandbox-policy/status.domain.mjs +64 -0
- package/src/runtime/domain/sandbox-policy/status.ts +76 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.domain.mjs +69 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.ts +60 -0
- package/src/runtime/domain/subagents/CONTEXT.md +202 -0
- package/src/runtime/domain/subagents/PRODUCT.md +49 -0
- package/src/runtime/domain/subagents/README.md +201 -0
- package/src/runtime/domain/subagents/agent-catalog.mjs +64 -0
- package/src/runtime/domain/subagents/agent-commands.domain.mjs +822 -0
- package/src/runtime/domain/subagents/agent-commands.ts +905 -0
- package/src/runtime/domain/subagents/agent-inspection.domain.mjs +398 -0
- package/src/runtime/domain/subagents/agent-inspection.ts +574 -0
- package/src/runtime/domain/subagents/agent-operations.domain.mjs +40 -0
- package/src/runtime/domain/subagents/agent-operations.ts +61 -0
- package/src/runtime/domain/subagents/agent-session-settings.domain.mjs +112 -0
- package/src/runtime/domain/subagents/agent-session-settings.ts +118 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.domain.mjs +84 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.ts +118 -0
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +276 -0
- package/src/runtime/domain/subagents/assignment-outcomes.ts +212 -0
- package/src/runtime/domain/subagents/assignment-projection.mjs +261 -0
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +174 -0
- package/src/runtime/domain/subagents/assignment-report.ts +156 -0
- package/src/runtime/domain/subagents/batch.mjs +275 -0
- package/src/runtime/domain/subagents/callback-fields.domain.mjs +72 -0
- package/src/runtime/domain/subagents/callback-fields.ts +95 -0
- package/src/runtime/domain/subagents/capacity.mjs +108 -0
- package/src/runtime/domain/subagents/catalog-editor.domain.mjs +98 -0
- package/src/runtime/domain/subagents/catalog-editor.ts +125 -0
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +104 -0
- package/src/runtime/domain/subagents/catalog-host-admission.ts +85 -0
- package/src/runtime/domain/subagents/catalog-identity.domain.mjs +222 -0
- package/src/runtime/domain/subagents/catalog-identity.ts +258 -0
- package/src/runtime/domain/subagents/catalog-overlay.domain.mjs +9 -0
- package/src/runtime/domain/subagents/catalog-overlay.ts +10 -0
- package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +164 -0
- package/src/runtime/domain/subagents/catalog-preferences.ts +139 -0
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +366 -0
- package/src/runtime/domain/subagents/catalog-resolver.ts +540 -0
- package/src/runtime/domain/subagents/catalog-runtime.domain.mjs +570 -0
- package/src/runtime/domain/subagents/catalog-runtime.ts +680 -0
- package/src/runtime/domain/subagents/catalog-schema.domain.mjs +1331 -0
- package/src/runtime/domain/subagents/catalog-schema.ts +1563 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.domain.mjs +95 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.ts +116 -0
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +808 -0
- package/src/runtime/domain/subagents/catalog-store.ts +1006 -0
- package/src/runtime/domain/subagents/catalog-ui.domain.mjs +651 -0
- package/src/runtime/domain/subagents/catalog-ui.ts +611 -0
- package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
- package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
- package/src/runtime/domain/subagents/child-codemode.domain.mjs +16 -0
- package/src/runtime/domain/subagents/child-codemode.ts +17 -0
- package/src/runtime/domain/subagents/child-dependencies.mjs +193 -0
- package/src/runtime/domain/subagents/child-incidents.domain.mjs +170 -0
- package/src/runtime/domain/subagents/child-incidents.ts +169 -0
- package/src/runtime/domain/subagents/child-operations.domain.mjs +986 -0
- package/src/runtime/domain/subagents/child-operations.ts +1191 -0
- package/src/runtime/domain/subagents/child-ownership.domain.mjs +205 -0
- package/src/runtime/domain/subagents/child-ownership.ts +160 -0
- package/src/runtime/domain/subagents/child-preflight.mjs +38 -0
- package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
- package/src/runtime/domain/subagents/child-process-list.ts +8 -0
- package/src/runtime/domain/subagents/child-runtime.mjs +67 -0
- package/src/runtime/domain/subagents/child-steer.domain.mjs +109 -0
- package/src/runtime/domain/subagents/child-steer.ts +102 -0
- package/src/runtime/domain/subagents/cleanup.domain.mjs +818 -0
- package/src/runtime/domain/subagents/cleanup.ts +1017 -0
- package/src/runtime/domain/subagents/codex-import.domain.mjs +575 -0
- package/src/runtime/domain/subagents/codex-import.ts +717 -0
- package/src/runtime/domain/subagents/completion.domain.mjs +6 -0
- package/src/runtime/domain/subagents/completion.mjs +152 -0
- package/src/runtime/domain/subagents/completion.ts +11 -0
- package/src/runtime/domain/subagents/config.domain.mjs +248 -0
- package/src/runtime/domain/subagents/config.json +15 -0
- package/src/runtime/domain/subagents/config.ts +328 -0
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +38 -0
- package/src/runtime/domain/subagents/continuation-authority.ts +31 -0
- package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
- package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
- package/src/runtime/domain/subagents/continuation.domain.mjs +942 -0
- package/src/runtime/domain/subagents/continuation.ts +1051 -0
- package/src/runtime/domain/subagents/delegation.domain.mjs +19 -0
- package/src/runtime/domain/subagents/delegation.ts +24 -0
- package/src/runtime/domain/subagents/effective-settings.domain.mjs +130 -0
- package/src/runtime/domain/subagents/effective-settings.ts +184 -0
- package/src/runtime/domain/subagents/extensions.domain.mjs +6 -0
- package/src/runtime/domain/subagents/extensions.mjs +164 -0
- package/src/runtime/domain/subagents/extensions.ts +19 -0
- package/src/runtime/domain/subagents/failures.domain.mjs +362 -0
- package/src/runtime/domain/subagents/failures.ts +319 -0
- package/src/runtime/domain/subagents/finalization.domain.mjs +168 -0
- package/src/runtime/domain/subagents/finalization.ts +218 -0
- package/src/runtime/domain/subagents/git-remotes.domain.mjs +351 -0
- package/src/runtime/domain/subagents/git-remotes.ts +413 -0
- package/src/runtime/domain/subagents/git-workspace.domain.mjs +337 -0
- package/src/runtime/domain/subagents/git-workspace.ts +430 -0
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +125 -0
- package/src/runtime/domain/subagents/goal-provider.ts +132 -0
- package/src/runtime/domain/subagents/health-observation.domain.mjs +617 -0
- package/src/runtime/domain/subagents/health-observation.ts +818 -0
- package/src/runtime/domain/subagents/health-surface.mjs +284 -0
- package/src/runtime/domain/subagents/health.domain.mjs +261 -0
- package/src/runtime/domain/subagents/health.ts +343 -0
- package/src/runtime/domain/subagents/historical-attention.domain.mjs +37 -0
- package/src/runtime/domain/subagents/historical-attention.ts +35 -0
- package/src/runtime/domain/subagents/incident-model.domain.mjs +322 -0
- package/src/runtime/domain/subagents/incident-model.ts +358 -0
- package/src/runtime/domain/subagents/index.domain.mjs +4731 -0
- package/src/runtime/domain/subagents/index.ts +4781 -0
- package/src/runtime/domain/subagents/launch-abort.domain.mjs +13 -0
- package/src/runtime/domain/subagents/launch-abort.ts +21 -0
- package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
- package/src/runtime/domain/subagents/launch-context.ts +23 -0
- package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
- package/src/runtime/domain/subagents/lifecycle.domain.mjs +265 -0
- package/src/runtime/domain/subagents/lifecycle.ts +360 -0
- package/src/runtime/domain/subagents/list.domain.mjs +2 -0
- package/src/runtime/domain/subagents/list.mjs +152 -0
- package/src/runtime/domain/subagents/list.ts +19 -0
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +217 -0
- package/src/runtime/domain/subagents/log-cursor.ts +268 -0
- package/src/runtime/domain/subagents/managed-background-capability.domain.mjs +10 -0
- package/src/runtime/domain/subagents/managed-background-capability.ts +9 -0
- package/src/runtime/domain/subagents/managed-failure-worker.mjs +36 -0
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +48 -0
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +75 -0
- package/src/runtime/domain/subagents/managed-launch-client.ts +59 -0
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +627 -0
- package/src/runtime/domain/subagents/managed-launch-host.ts +504 -0
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +17 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.ts +22 -0
- package/src/runtime/domain/subagents/managed-launch-port.domain.mjs +2 -0
- package/src/runtime/domain/subagents/managed-launch-port.ts +25 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.ts +45 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.domain.mjs +63 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.ts +48 -0
- package/src/runtime/domain/subagents/managed-worker.mjs +13 -0
- package/src/runtime/domain/subagents/model-resolution-core.domain.mjs +822 -0
- package/src/runtime/domain/subagents/model-resolution-core.ts +1074 -0
- package/src/runtime/domain/subagents/model-resolution.domain.mjs +22 -0
- package/src/runtime/domain/subagents/model-resolution.ts +32 -0
- package/src/runtime/domain/subagents/navigator.domain.mjs +6 -0
- package/src/runtime/domain/subagents/navigator.mjs +1233 -0
- package/src/runtime/domain/subagents/navigator.ts +39 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +1012 -0
- package/src/runtime/domain/subagents/operation-bridge-types.ts +1156 -0
- package/src/runtime/domain/subagents/outage-observations.domain.mjs +84 -0
- package/src/runtime/domain/subagents/outage-observations.ts +73 -0
- package/src/runtime/domain/subagents/output-payload.domain.mjs +767 -0
- package/src/runtime/domain/subagents/output-payload.ts +987 -0
- package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
- package/src/runtime/domain/subagents/owned-exit.ts +12 -0
- package/src/runtime/domain/subagents/package.json +86 -0
- package/src/runtime/domain/subagents/park-checkpoint.domain.mjs +55 -0
- package/src/runtime/domain/subagents/park-checkpoint.ts +61 -0
- package/src/runtime/domain/subagents/parse.domain.mjs +1218 -0
- package/src/runtime/domain/subagents/parse.ts +1451 -0
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +232 -0
- package/src/runtime/domain/subagents/permission-policy.ts +291 -0
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +1584 -0
- package/src/runtime/domain/subagents/registry.ts +1904 -0
- package/src/runtime/domain/subagents/role-assignment.domain.mjs +104 -0
- package/src/runtime/domain/subagents/role-assignment.ts +141 -0
- package/src/runtime/domain/subagents/roles/role.architect.md +13 -0
- package/src/runtime/domain/subagents/roles/role.developer.md +16 -0
- package/src/runtime/domain/subagents/roles/role.explorer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.product-manager.md +13 -0
- package/src/runtime/domain/subagents/roles/role.researcher.md +13 -0
- package/src/runtime/domain/subagents/roles/role.reviewer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.writer.md +12 -0
- package/src/runtime/domain/subagents/sandbox.domain.mjs +64 -0
- package/src/runtime/domain/subagents/sandbox.ts +92 -0
- package/src/runtime/domain/subagents/session-selection.domain.mjs +32 -0
- package/src/runtime/domain/subagents/session-selection.ts +35 -0
- package/src/runtime/domain/subagents/session-store.domain.mjs +489 -0
- package/src/runtime/domain/subagents/session-store.ts +468 -0
- package/src/runtime/domain/subagents/settings-page.domain.mjs +313 -0
- package/src/runtime/domain/subagents/settings-page.ts +363 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +70 -0
- package/src/runtime/domain/subagents/shared-catalog.ts +61 -0
- package/src/runtime/domain/subagents/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/subagents/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/subagents/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/subagents/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/subagents/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/subagents/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/subagents/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/subagents/shared-navigator.ts +1962 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/subagents/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/subagents/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/subagents/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/subagents/shared-task-application.ts +185 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/subagents/shared-task-exec.ts +335 -0
- package/src/runtime/domain/subagents/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/subagents/shared-task-files.ts +342 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/subagents/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/subagents/shared-task-tools.ts +123 -0
- package/src/runtime/domain/subagents/shared-work-client.mjs +303 -0
- package/src/runtime/domain/subagents/shared-worktree-context.domain.mjs +142 -0
- package/src/runtime/domain/subagents/shared-worktree-context.ts +158 -0
- package/src/runtime/domain/subagents/skill-picker.domain.mjs +316 -0
- package/src/runtime/domain/subagents/skill-picker.ts +353 -0
- package/src/runtime/domain/subagents/skills.domain.mjs +138 -0
- package/src/runtime/domain/subagents/skills.ts +183 -0
- package/src/runtime/domain/subagents/spawn.domain.mjs +72 -0
- package/src/runtime/domain/subagents/spawn.ts +80 -0
- package/src/runtime/domain/subagents/stop.domain.mjs +184 -0
- package/src/runtime/domain/subagents/stop.ts +217 -0
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +101 -0
- package/src/runtime/domain/subagents/subagent-tools.ts +137 -0
- package/src/runtime/domain/subagents/task-guard.domain.mjs +163 -0
- package/src/runtime/domain/subagents/task-guard.ts +144 -0
- package/src/runtime/domain/subagents/task-policy.domain.mjs +201 -0
- package/src/runtime/domain/subagents/task-policy.ts +236 -0
- package/src/runtime/domain/subagents/task-runtime.mjs +53 -0
- package/src/runtime/domain/subagents/task-tool-owner.domain.mjs +18 -0
- package/src/runtime/domain/subagents/task-tool-owner.ts +21 -0
- package/src/runtime/domain/subagents/thinking.domain.mjs +22 -0
- package/src/runtime/domain/subagents/thinking.ts +28 -0
- package/src/runtime/domain/subagents/tier-policy.domain.mjs +75 -0
- package/src/runtime/domain/subagents/tier-policy.ts +126 -0
- package/src/runtime/domain/subagents/timing-notifications.domain.mjs +51 -0
- package/src/runtime/domain/subagents/timing-notifications.ts +37 -0
- package/src/runtime/domain/subagents/timing.domain.mjs +487 -0
- package/src/runtime/domain/subagents/timing.ts +634 -0
- package/src/runtime/domain/subagents/tools.domain.mjs +558 -0
- package/src/runtime/domain/subagents/tools.ts +629 -0
- package/src/runtime/domain/subagents/widget.domain.mjs +6 -0
- package/src/runtime/domain/subagents/widget.mjs +246 -0
- package/src/runtime/domain/subagents/widget.ts +30 -0
- package/src/runtime/domain/subagents/work-observation.domain.mjs +316 -0
- package/src/runtime/domain/subagents/work-observation.ts +248 -0
- package/src/runtime/domain/subagents/worker-catalog.domain.mjs +120 -0
- package/src/runtime/domain/subagents/worker-catalog.ts +162 -0
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +1009 -0
- package/src/runtime/domain/subagents/worker-operations-host.ts +1238 -0
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +2336 -0
- package/src/runtime/domain/subagents/worker-waits.ts +2878 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.mjs +52 -0
- package/src/runtime/domain/subagents/workspace-scope.ts +50 -0
- package/src/runtime/health-config.ts +27 -11
- package/src/runtime/log-checkpoints.ts +117 -0
- package/src/runtime/mutation-store.ts +5 -4
- package/src/runtime/queries.ts +27 -3
- package/src/runtime/query-executor.ts +178 -34
- package/src/runtime/query-worker.mjs +119 -22
- package/src/runtime/read-model.ts +939 -113
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +73 -0
- package/src/runtime/work-budget.ts +130 -0
- package/src/runtime/work-client.d.mts +8 -0
- package/src/runtime/work-client.mjs +150 -7
- package/src/server.ts +185 -22
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { connect } from "node:net";
|
|
2
3
|
import { performance } from "node:perf_hooks";
|
|
4
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
5
|
+
|
|
6
|
+
/** A persisted session can own work even when its selected branch is empty. */
|
|
7
|
+
export function shouldRestoreWorkObservation(event, session) {
|
|
8
|
+
if (event?.piBetterObserveWork) return true;
|
|
9
|
+
const reason = event?.reason;
|
|
10
|
+
if (reason === "new") return false;
|
|
11
|
+
if (reason !== "startup" || typeof session?.getSessionFile !== "function") return true;
|
|
12
|
+
const file = session.getSessionFile();
|
|
13
|
+
return file ? existsSync(file) : Boolean(session.getLeafId?.());
|
|
14
|
+
}
|
|
3
15
|
|
|
4
16
|
/** SDK-free observation stream. Cached snapshots are the only synchronous read API. */
|
|
5
17
|
export class WorkClient {
|
|
@@ -12,6 +24,11 @@ export class WorkClient {
|
|
|
12
24
|
scope;
|
|
13
25
|
buffer = "";
|
|
14
26
|
closed = false;
|
|
27
|
+
recoveryTimer;
|
|
28
|
+
recoveryActive = false;
|
|
29
|
+
recoveryAgain = false;
|
|
30
|
+
recoveryDelay = 100;
|
|
31
|
+
scopeGeneration = 0;
|
|
15
32
|
|
|
16
33
|
constructor(socketPath, agentDir, requiredCapabilities = []) {
|
|
17
34
|
this.socket = typeof socketPath === "string" ? connect(socketPath) : socketPath;
|
|
@@ -26,8 +43,8 @@ export class WorkClient {
|
|
|
26
43
|
const message = JSON.parse(line);
|
|
27
44
|
if (message.type === "event") {
|
|
28
45
|
if (message.event.type === "runtime_catalog_snapshot") { for (const listener of this.catalogListeners) listener(message.event.snapshot); continue; }
|
|
29
|
-
if (message.event.type === "resync_required") { this.degrade(message.event.reason);
|
|
30
|
-
else if (message.event.type === "runtime_snapshot") this.accept(message.event.snapshot);
|
|
46
|
+
if (message.event.type === "resync_required") { this.degrade(message.event.reason); this.scheduleRecovery(); }
|
|
47
|
+
else if (message.event.type === "runtime_snapshot") this.accept(message.event.snapshot, message.event.previousSeq);
|
|
31
48
|
} else {
|
|
32
49
|
const request = this.pending.get(message.id);
|
|
33
50
|
if (!request) continue;
|
|
@@ -37,7 +54,9 @@ export class WorkClient {
|
|
|
37
54
|
} catch (error) { this.fail(error); }
|
|
38
55
|
}
|
|
39
56
|
});
|
|
40
|
-
this.socket.on("error", error => this.fail(error)
|
|
57
|
+
this.socket.on("error", error => this.fail(["ECONNRESET", "EPIPE"].includes(error.code)
|
|
58
|
+
? Object.assign(new Error(`runtime-unavailable: disconnected (${error.code}); resync required`, { cause: error }), { code: error.code })
|
|
59
|
+
: error));
|
|
41
60
|
this.socket.on("close", () => this.fail(new Error("runtime-unavailable: disconnected; resync required")));
|
|
42
61
|
this.ready = this.request("hello", { protocolVersion: 1, runtimeRoot: agentDir, requiredCapabilities: ["runtime-state-v1", "runtime-subscriptions-v1", ...requiredCapabilities] })
|
|
43
62
|
.then(async hello => { if (typeof socketPath === "string" && hello.capabilities?.includes("runtime-client-retention-v1")) await this.request("runtime_register_client", { clientId: `work-${process.pid}` }); return hello; });
|
|
@@ -59,27 +78,63 @@ export class WorkClient {
|
|
|
59
78
|
this.snapshot = { ...this.snapshot, status: "degraded", reason, rows: this.snapshot?.rows ?? [] };
|
|
60
79
|
this.notify();
|
|
61
80
|
}
|
|
62
|
-
accept(snapshot) {
|
|
81
|
+
accept(snapshot, previousSeq) {
|
|
63
82
|
if (this.snapshot?.instanceId === snapshot.instanceId && snapshot.seq < this.snapshot.seq) return;
|
|
64
83
|
if (this.snapshot?.instanceId && this.snapshot.instanceId !== snapshot.instanceId) {
|
|
65
84
|
this.degrade("instance-changed: resync required");
|
|
66
85
|
snapshot = { ...snapshot, resyncRequired: true, resyncReason: "instance-changed" };
|
|
67
|
-
} else if (this.snapshot?.seq !== undefined &&
|
|
86
|
+
} else if (this.snapshot?.seq !== undefined && Number.isSafeInteger(previousSeq) && previousSeq > this.snapshot.seq) {
|
|
68
87
|
this.degrade("sequence-gap: replacing with a full authoritative snapshot");
|
|
69
88
|
snapshot = { ...snapshot, resyncRequired: true, resyncReason: "sequence-gap" };
|
|
70
89
|
}
|
|
71
|
-
//
|
|
90
|
+
// Global seq may skip unrelated changes; only a missing subscription
|
|
91
|
+
// predecessor indicates loss. The received snapshot is still complete.
|
|
72
92
|
this.snapshot = Object.freeze(snapshot); this.notify();
|
|
73
93
|
}
|
|
94
|
+
scheduleRecovery(delay = 0) {
|
|
95
|
+
if (this.closed) return;
|
|
96
|
+
if (this.recoveryActive) { this.recoveryAgain = true; return; }
|
|
97
|
+
if (this.recoveryTimer) return;
|
|
98
|
+
this.recoveryTimer = setTimeout(() => {
|
|
99
|
+
this.recoveryTimer = undefined;
|
|
100
|
+
void this.recover();
|
|
101
|
+
}, delay);
|
|
102
|
+
this.recoveryTimer.unref?.();
|
|
103
|
+
}
|
|
104
|
+
async recover() {
|
|
105
|
+
const generation = this.scopeGeneration;
|
|
106
|
+
this.recoveryActive = true;
|
|
107
|
+
let retry = false;
|
|
108
|
+
try { await this.resync(); this.recoveryDelay = 100; }
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (!this.closed && generation === this.scopeGeneration) {
|
|
111
|
+
this.degrade(String(error));
|
|
112
|
+
retry = /runtime-(?:timeout|overloaded|unhealthy)/.test(String(error));
|
|
113
|
+
}
|
|
114
|
+
} finally {
|
|
115
|
+
this.recoveryActive = false;
|
|
116
|
+
const again = this.recoveryAgain;
|
|
117
|
+
this.recoveryAgain = false;
|
|
118
|
+
if (!this.closed && (again || retry && generation === this.scopeGeneration)) {
|
|
119
|
+
this.scheduleRecovery(again ? 0 : this.recoveryDelay);
|
|
120
|
+
this.recoveryDelay = Math.min(1000, this.recoveryDelay * 2);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
74
124
|
async subscribe(scope) {
|
|
75
125
|
await this.ready;
|
|
126
|
+
this.scopeGeneration++;
|
|
127
|
+
clearTimeout(this.recoveryTimer); this.recoveryTimer = undefined;
|
|
128
|
+
this.recoveryAgain = false; this.recoveryDelay = 100;
|
|
76
129
|
this.scope = scope;
|
|
77
130
|
const snapshot = await this.request("runtime_subscribe", { scope });
|
|
78
131
|
this.accept(snapshot); return snapshot;
|
|
79
132
|
}
|
|
80
133
|
async resync() {
|
|
134
|
+
const generation = this.scopeGeneration;
|
|
81
135
|
const snapshot = await this.request("runtime_subscribe", { scope: this.scope, sinceSeq: this.snapshot?.seq, instanceId: this.snapshot?.instanceId });
|
|
82
|
-
this.accept(snapshot);
|
|
136
|
+
if (!this.closed && generation === this.scopeGeneration) this.accept(snapshot);
|
|
137
|
+
return snapshot;
|
|
83
138
|
}
|
|
84
139
|
async get(scope) {
|
|
85
140
|
await this.ready;
|
|
@@ -94,9 +149,97 @@ export class WorkClient {
|
|
|
94
149
|
fail(error) {
|
|
95
150
|
if (this.closed) return;
|
|
96
151
|
this.closed = true;
|
|
152
|
+
this.scopeGeneration++;
|
|
153
|
+
clearTimeout(this.recoveryTimer); this.recoveryTimer = undefined;
|
|
97
154
|
for (const request of this.pending.values()) { clearTimeout(request.timer); request.reject(error); }
|
|
98
155
|
this.pending.clear(); this.socket.destroy(); this.degrade(String(error));
|
|
99
156
|
for (const listener of this.catalogListeners) listener({ status: "revoked" });
|
|
100
157
|
}
|
|
101
158
|
close() { this.fail(new Error("runtime-unavailable: client closed")); this.listeners.clear(); this.catalogListeners.clear(); }
|
|
102
159
|
}
|
|
160
|
+
|
|
161
|
+
// Shared across the standalone extension copies, but never across agent roots.
|
|
162
|
+
const recoveryKey = Symbol.for("pi-better-runtime.connection-recovery.v2");
|
|
163
|
+
const recoveries = globalThis[recoveryKey] ??= new Map();
|
|
164
|
+
const connectionDemands = globalThis[Symbol.for("pi-better-runtime.connection-demand.v2")] ??= new Map();
|
|
165
|
+
|
|
166
|
+
/** Establish a transport only. Never replay an application request after dispatch. */
|
|
167
|
+
export async function connectWorkClient(socketPath, agentDir, capabilities = [], options = {}) {
|
|
168
|
+
const timeoutMs = options.timeoutMs ?? 60000;
|
|
169
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) throw new Error("Invalid connection timeout");
|
|
170
|
+
const deadline = performance.now() + timeoutMs;
|
|
171
|
+
const started = performance.now();
|
|
172
|
+
let backoff = 100, recovered = false, lastError, recoveryError, ownedRecovery;
|
|
173
|
+
const remaining = () => Math.max(1, deadline - performance.now());
|
|
174
|
+
const key = JSON.stringify([agentDir, socketPath]);
|
|
175
|
+
connectionDemands.set(key, (connectionDemands.get(key) ?? 0) + 1);
|
|
176
|
+
try {
|
|
177
|
+
while (performance.now() < deadline) {
|
|
178
|
+
options.signal?.throwIfAborted();
|
|
179
|
+
const client = new WorkClient(socketPath, agentDir, capabilities);
|
|
180
|
+
const abort = () => client.close();
|
|
181
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
182
|
+
const timer = setTimeout(() => client.close(), remaining());
|
|
183
|
+
try {
|
|
184
|
+
await client.ready;
|
|
185
|
+
options.signal?.throwIfAborted();
|
|
186
|
+
return client;
|
|
187
|
+
} catch (error) {
|
|
188
|
+
client.close();
|
|
189
|
+
options.signal?.throwIfAborted();
|
|
190
|
+
lastError = error;
|
|
191
|
+
if (recoveryError) throw recoveryError;
|
|
192
|
+
if (!["ENOENT", "ECONNREFUSED", "ECONNRESET", "EPIPE"].includes(error?.code)
|
|
193
|
+
&& !/runtime-unavailable: (?:disconnected|server closed)/.test(String(error))) throw error;
|
|
194
|
+
} finally {
|
|
195
|
+
clearTimeout(timer);
|
|
196
|
+
options.signal?.removeEventListener("abort", abort);
|
|
197
|
+
}
|
|
198
|
+
// Most replacement gaps need only a reconnect. Startup remains owner-safe.
|
|
199
|
+
if (!recovered && options.recover && performance.now() - started >= 250 && performance.now() < deadline) {
|
|
200
|
+
recovered = true;
|
|
201
|
+
let recovery = recoveries.get(key);
|
|
202
|
+
if (!recovery) {
|
|
203
|
+
const controller = new AbortController();
|
|
204
|
+
const budget = Math.ceil(remaining());
|
|
205
|
+
const timer = setTimeout(() => {
|
|
206
|
+
controller.abort(new Error("runtime-unavailable: reconnect deadline exceeded during recovery"));
|
|
207
|
+
}, budget);
|
|
208
|
+
const promise = waitForRecovery(Promise.resolve().then(() => options.recover({ timeoutMs: budget, signal: controller.signal })), controller.signal)
|
|
209
|
+
.finally(() => clearTimeout(timer));
|
|
210
|
+
recovery = { promise, controller, key };
|
|
211
|
+
recoveries.set(key, recovery);
|
|
212
|
+
void recovery.promise.finally(() => { if (recoveries.get(key) === recovery) recoveries.delete(key); }).catch(() => {});
|
|
213
|
+
}
|
|
214
|
+
// A caller can cancel its wait without cancelling another caller's recovery.
|
|
215
|
+
// Keep trying the transport while the owner-safe installer waits.
|
|
216
|
+
// A replacement can accept compatible clients before the pinned
|
|
217
|
+
// installer finishes; waiting for it would stall all subscribers.
|
|
218
|
+
ownedRecovery = recovery;
|
|
219
|
+
void recovery.promise.catch(error => { recoveryError = error; });
|
|
220
|
+
}
|
|
221
|
+
if (performance.now() >= deadline) break;
|
|
222
|
+
await delay(Math.min(backoff, remaining()), undefined, { signal: options.signal });
|
|
223
|
+
backoff = Math.min(1000, backoff * 2);
|
|
224
|
+
}
|
|
225
|
+
throw new Error("runtime-unavailable: reconnect deadline exceeded; task state is unknown, retry after recovery", { cause: lastError });
|
|
226
|
+
} finally {
|
|
227
|
+
const remainingDemand = connectionDemands.get(key) - 1;
|
|
228
|
+
if (remainingDemand) connectionDemands.set(key, remainingDemand);
|
|
229
|
+
else {
|
|
230
|
+
connectionDemands.delete(key);
|
|
231
|
+
const recovery = recoveries.get(key) ?? ownedRecovery;
|
|
232
|
+
if (recovery) { recoveries.delete(key); recovery.controller.abort(); }
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function waitForRecovery(recovery, signal) {
|
|
238
|
+
return new Promise((resolve, reject) => {
|
|
239
|
+
const finish = (callback, value) => { signal.removeEventListener("abort", abort); callback(value); };
|
|
240
|
+
const abort = () => finish(reject, signal.reason);
|
|
241
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
242
|
+
recovery.then(value => finish(resolve, value), error => finish(reject, error));
|
|
243
|
+
if (signal.aborted) abort();
|
|
244
|
+
});
|
|
245
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createBackgroundTools } from "./runtime/background-tools.ts";
|
|
1
2
|
import { createLocalWorkClient } from "./runtime/local-client.ts";
|
|
2
3
|
import { chmodSync, existsSync, realpathSync, unlinkSync, writeFileSync, renameSync } from "node:fs";
|
|
3
4
|
import { join } from "node:path";
|
|
@@ -19,11 +20,12 @@ import type { IdleSessionsLease, UpgradeRequest } from "./startup/managed-types.
|
|
|
19
20
|
import { HostedSession } from "./hosted-session.ts";
|
|
20
21
|
import { readLifecycleConfig, type LifecycleConfig } from "./lifecycle-config.ts";
|
|
21
22
|
import { runtimeRoot } from "./runtime/root.ts";
|
|
22
|
-
import { RuntimeCancellation
|
|
23
|
-
import { RuntimeResultSupervision
|
|
23
|
+
import { RuntimeCancellation } from "./runtime/cancellation.ts";
|
|
24
|
+
import { RuntimeResultSupervision } from "./runtime/result-supervision.ts";
|
|
24
25
|
import { SharedCatalog } from "./runtime/catalog.ts";
|
|
25
|
-
import { mutationStoreMetrics } from "./runtime/mutation-store.ts";
|
|
26
|
+
import { acquireMutationStore, mutationStoreMetrics } from "./runtime/mutation-store.ts";
|
|
26
27
|
import { WorkQueryExecutor } from "./runtime/query-executor.ts";
|
|
28
|
+
import { createSubagentLaunch } from "./runtime/subagent-launch.ts";
|
|
27
29
|
|
|
28
30
|
export interface DaemonOptions extends Partial<LifecycleConfig> {
|
|
29
31
|
/** Defaults to `~/.pi/agent/server` (or `$PI_SERVER_DIR`). */
|
|
@@ -42,6 +44,8 @@ export interface DaemonOptions extends Partial<LifecycleConfig> {
|
|
|
42
44
|
onDraining?: () => void;
|
|
43
45
|
/** Trusted fault-injection seam; never exposed through the socket protocol. */
|
|
44
46
|
cancellationFault?: (stage: import("./runtime/cancellation.ts").CancellationStage) => void;
|
|
47
|
+
/** Private fixture hook; no protocol command, parameters or authority are passed. */
|
|
48
|
+
rpcEvidence?: { bind(read: () => unknown): void; event(plane: string, slot: number, phase: string): void };
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
export interface Daemon {
|
|
@@ -91,15 +95,28 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
91
95
|
const owner = inspectDaemonOwner(serverDir);
|
|
92
96
|
const instanceId = owner.status === "live" ? owner.owner.token : undefined;
|
|
93
97
|
admitDaemonStartup({ canonicalServerDir: serverDir, agentDir: getAgentDir(), build, intent: startupIntentFromEnv(process.env) });
|
|
98
|
+
let launches: Awaited<ReturnType<typeof createSubagentLaunch>> | undefined;
|
|
99
|
+
let launchInitialization: ReturnType<typeof createSubagentLaunch> | undefined;
|
|
100
|
+
let backgroundInitialization: ReturnType<typeof createBackgroundTools> | undefined;
|
|
101
|
+
let backgroundTools: Awaited<ReturnType<typeof createBackgroundTools>> | undefined;
|
|
102
|
+
const initializeBackground = () => backgroundInitialization ??= (() => {
|
|
103
|
+
options.rpcEvidence?.event('background', 0, 'init-pending');
|
|
104
|
+
return createBackgroundTools(realpathSync(getAgentDir()), instanceId!, () => Boolean(pendingUpgrade), scope => work().snapshot(scope), config.runtimeIdleMs,
|
|
105
|
+
options.rpcEvidence ? (slot, phase) => options.rpcEvidence!.event('adapter', slot, phase) : undefined)
|
|
106
|
+
.then(host => { options.rpcEvidence?.event('background', 0, 'init-returned'); return backgroundTools = host; })
|
|
107
|
+
.catch(error => { options.rpcEvidence?.event('background', 0, 'init-failed'); backgroundInitialization = undefined; throw error; });
|
|
108
|
+
})();
|
|
94
109
|
let cancellations: RuntimeCancellation | undefined;
|
|
110
|
+
const controlStore = acquireMutationStore(realpathSync(getAgentDir()));
|
|
95
111
|
let resultSupervision: RuntimeResultSupervision | undefined;
|
|
96
112
|
const resultPortKey = Symbol.for("pi-better-server:result-supervision-ports-v1");
|
|
97
113
|
const resultPorts: Map<string, any> = (globalThis as any)[resultPortKey] ??= new Map();
|
|
98
114
|
const resultRoot = realpathSync(getAgentDir());
|
|
99
115
|
const resultPort = { status() {
|
|
100
|
-
resultSupervision ??= new RuntimeResultSupervision(resultRoot, instanceId
|
|
116
|
+
resultSupervision ??= new RuntimeResultSupervision(resultRoot, instanceId!, config.runtimeIdleMs);
|
|
101
117
|
resultSupervision.reconcile();
|
|
102
|
-
return { hostId: resultSupervision.hostId, epoch: resultSupervision.epoch, reason: resultSupervision.reason
|
|
118
|
+
return { hostId: resultSupervision.hostId, epoch: resultSupervision.epoch, reason: resultSupervision.reason,
|
|
119
|
+
obligations: resultSupervision.livenessReasons(), metrics: resultSupervision.metrics };
|
|
103
120
|
} };
|
|
104
121
|
let workModel: WorkQueryExecutor | undefined;
|
|
105
122
|
let registry!: SessionRegistry;
|
|
@@ -109,18 +126,46 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
109
126
|
try { await cancellations?.close(); }
|
|
110
127
|
finally {
|
|
111
128
|
resultSupervision?.close();
|
|
129
|
+
controlStore.release();
|
|
112
130
|
if (resultPorts.get(resultRoot) === resultPort) resultPorts.delete(resultRoot);
|
|
113
|
-
await
|
|
131
|
+
try { await (await launchInitialization?.catch(() => undefined))?.close();
|
|
132
|
+
await (await backgroundInitialization?.catch(() => undefined))?.close(); }
|
|
133
|
+
finally { await workModel?.close(); }
|
|
114
134
|
}
|
|
115
135
|
}
|
|
116
136
|
};
|
|
117
|
-
if (
|
|
137
|
+
if (controlStore.store.resultSupervisions(true).length || controlStore.store.listAssignmentCleanupOperations(1).length) {
|
|
138
|
+
resultSupervision = new RuntimeResultSupervision(resultRoot, instanceId!, config.runtimeIdleMs);
|
|
139
|
+
}
|
|
118
140
|
resultPorts.set(resultRoot, resultPort);
|
|
119
|
-
if (
|
|
141
|
+
if (controlStore.store.pendingTaskCancellations().length) cancellations = new RuntimeCancellation(realpathSync(getAgentDir()), instanceId!, options.cancellationFault);
|
|
120
142
|
const catalog = new SharedCatalog(realpathSync(getAgentDir()), instanceId!);
|
|
143
|
+
const initializeLaunch = () => {
|
|
144
|
+
if (!launchInitialization) {
|
|
145
|
+
const pending = createSubagentLaunch(realpathSync(getAgentDir()), instanceId!, catalog, config.runtimeIdleMs);
|
|
146
|
+
launchInitialization = pending;
|
|
147
|
+
void pending.then(host => { launches = host; }, () => {
|
|
148
|
+
// The factory releases partial resources before rejection. A later
|
|
149
|
+
// request may retry after the underlying recovery fault is repaired.
|
|
150
|
+
if (launchInitialization === pending) launchInitialization = undefined;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return launchInitialization;
|
|
154
|
+
};
|
|
155
|
+
if (controlStore.store.hasSubagentManagement()) {
|
|
156
|
+
void initializeLaunch().catch(error => log(`Subagent supervision unavailable: ${String(error)}`));
|
|
157
|
+
}
|
|
121
158
|
const work = () => {
|
|
122
159
|
if (!workModel) {
|
|
123
|
-
workModel = new WorkQueryExecutor(realpathSync(getAgentDir()), instanceId
|
|
160
|
+
workModel = new WorkQueryExecutor(realpathSync(getAgentDir()), instanceId!, {
|
|
161
|
+
logWatchdog: log,
|
|
162
|
+
budgetBuffer: controlStore.budget.buffer,
|
|
163
|
+
onTerminalLogsChanged: async ids => {
|
|
164
|
+
if (!launchInitialization && !controlStore.store.hasSubagentManagement()) return;
|
|
165
|
+
const host = await initializeLaunch();
|
|
166
|
+
await host.foldTerminalFailures(ids);
|
|
167
|
+
},
|
|
168
|
+
});
|
|
124
169
|
}
|
|
125
170
|
return workModel;
|
|
126
171
|
};
|
|
@@ -130,14 +175,23 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
130
175
|
// Structural port permits independent integration with the shared maintenance owner.
|
|
131
176
|
const sessionMaintenance = (registry as SessionRegistry & { maintenance?: {
|
|
132
177
|
readonly busy: boolean;
|
|
178
|
+
lifecycleReasons(): unknown[];
|
|
133
179
|
enterSessionOperation(): () => void;
|
|
134
180
|
withIdleSessions<T>(purpose: "upgrade", run: (live: HostedSession[], lease: IdleSessionsLease) => Promise<T>): Promise<T>;
|
|
135
181
|
} }).maintenance;
|
|
136
182
|
const safeUpgrade = !!(build && instanceId && sessionMaintenance
|
|
137
183
|
&& typeof sessionMaintenance.withIdleSessions === "function" && "publishRuntimeEvent" in HostedSession.prototype);
|
|
138
184
|
let pendingUpgrade: UpgradeRequest | undefined;
|
|
185
|
+
if(controlStore.store.backgroundRequests().hasPending()) void initializeBackground().catch(error => log(`Background request recovery unavailable: ${String(error)}`));
|
|
139
186
|
const reconnectControllers = new Map<ConnectionControl, boolean>();
|
|
187
|
+
const setUpgradeFence = (epoch: string | null) => {
|
|
188
|
+
const lease = acquireMutationStore(realpathSync(getAgentDir()));
|
|
189
|
+
try { lease.store.setUpgradeFence(epoch); } finally { lease.release(); }
|
|
190
|
+
};
|
|
191
|
+
// Startup ownership has proved the preceding manager exited.
|
|
192
|
+
setUpgradeFence(null);
|
|
140
193
|
let upgradeCommitted = false;
|
|
194
|
+
let upgradeBlockers: unknown[] = [];
|
|
141
195
|
const companions = new CompanionManager({
|
|
142
196
|
socketPath,
|
|
143
197
|
...options.companion,
|
|
@@ -151,8 +205,13 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
151
205
|
const sockets = new Set<Socket>();
|
|
152
206
|
const dispatches = new Set<Promise<void>>();
|
|
153
207
|
let inFlight = 0;
|
|
208
|
+
let requestCounter = 0, connectionCounter = 0;
|
|
209
|
+
const requests = new Map<number, { kind: string; id: number; connection: number; operation?: { kind: string; id: string }; lastProgressAt: number; nextDeadline: null; executionDeadline: null; recovery: string }>();
|
|
210
|
+
options.rpcEvidence?.bind(() => ({ lanes: controlStore.budget.metrics().lanes,
|
|
211
|
+
read: workModel?.metrics().executor, observation: workModel?.observation().status }));
|
|
154
212
|
let draining = false;
|
|
155
213
|
let idleStopping = false;
|
|
214
|
+
let idleEvidence: unknown;
|
|
156
215
|
const runtimeClients = new Map<Socket, string>();
|
|
157
216
|
let guardianBinding: { socket: Socket; identity: import("./daemon-owner.ts").DaemonOwnerIdentity } | undefined;
|
|
158
217
|
let observationUnavailable = false;
|
|
@@ -161,6 +220,7 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
161
220
|
let zeroSince: number | undefined = registry.activeCount === 0 ? now() : undefined;
|
|
162
221
|
let startupUntil = 0;
|
|
163
222
|
const server: Server = createServer((socket) => {
|
|
223
|
+
const connection = ++connectionCounter;
|
|
164
224
|
sockets.add(socket);
|
|
165
225
|
const send = (message: ServerMessage): void => {
|
|
166
226
|
if (!socket.destroyed) socket.write(encodeLine(message));
|
|
@@ -190,7 +250,24 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
190
250
|
send(failure(id, type || "unknown", "Daemon is shutting down; reconnect to start it again"));
|
|
191
251
|
return;
|
|
192
252
|
}
|
|
253
|
+
if (pendingUpgrade && type === "runtime_launch_subagent") {
|
|
254
|
+
send(failure(id, type, "runtime-draining: new execution is deferred while a fixed-build upgrade is pending"));
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
193
257
|
inFlight++;
|
|
258
|
+
const request = ++requestCounter;
|
|
259
|
+
const evidencePlane = type === 'runtime_background_tool' ? 'background'
|
|
260
|
+
: ['runtime_cancel_task', 'runtime_query_cancellation', 'runtime_cancellation_status'].includes(type) ? 'cancel'
|
|
261
|
+
: ['runtime_get_snapshot', 'runtime_subscribe', 'runtime_get_metrics'].includes(type) ? 'read' : undefined;
|
|
262
|
+
if (evidencePlane) options.rpcEvidence?.event(evidencePlane, request, 'request-pending');
|
|
263
|
+
requests.set(request, { kind: 'transport-request', id: request, connection, lastProgressAt: now(),
|
|
264
|
+
nextDeadline: null, executionDeadline: null,
|
|
265
|
+
recovery: 'dispatch-drains-to-settlement-read-waiters-use-existing-caller-cancellation-accepted-effects-use-durable-owner' });
|
|
266
|
+
const accepted = (kind: string) => (operationId: string) => {
|
|
267
|
+
const record = requests.get(request);
|
|
268
|
+
if (record) { record.operation = { kind, id: operationId }; record.lastProgressAt = now(); }
|
|
269
|
+
};
|
|
270
|
+
let evidenceFailed = false;
|
|
194
271
|
try {
|
|
195
272
|
if (!type) {
|
|
196
273
|
send(failure(id, "unknown", "Missing command type"));
|
|
@@ -214,12 +291,24 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
214
291
|
const observation = workModel?.observation();
|
|
215
292
|
return reply({ data: { agentDir: realpathSync(getAgentDir()), serverDir, instanceId, build, nodeVersion: process.versions.node,
|
|
216
293
|
capabilities: ["runtime-status-v1"], hostedSessions: registry.activeCount, lifecycle: config,
|
|
294
|
+
subagentManagement: launches?.status() ?? null,
|
|
295
|
+
backgroundManagement: backgroundTools?.metrics() ?? null,
|
|
296
|
+
resultSupervision: resultSupervision ? { reason: resultSupervision.reason, metrics: resultSupervision.metrics } : null,
|
|
297
|
+
workBudget: controlStore.budget.metrics(),
|
|
217
298
|
guardianBinding: guardianBinding?.identity ?? null,
|
|
218
299
|
workObservation: observation ? { status: observation.status, reason: observation.reason, observedAt: observation.observedAt } : null,
|
|
219
300
|
livenessReasons: [...[...runtimeClients.values()].map(id => ({ kind: "connection", id })),
|
|
220
|
-
...
|
|
221
|
-
...(
|
|
301
|
+
...requests.values(),
|
|
302
|
+
...registry.lifecycleReasons(),
|
|
303
|
+
...(resultSupervision?.livenessReasons() ?? []),
|
|
304
|
+
...(launches?.lifecycleReasons() ?? []),
|
|
305
|
+
...(backgroundTools?.lifecycleReasons() ?? []),
|
|
306
|
+
...(cancellations?.lifecycleReasons() ?? []),
|
|
307
|
+
...(sessionMaintenance?.lifecycleReasons() ?? []),
|
|
308
|
+
...(observation?.reasons ?? []).filter((reason: any) => !resultSupervision?.manages(reason.operationId))],
|
|
222
309
|
livenessObservation: observation ?? { status: "unobserved", reasons: [], observedAt: null },
|
|
310
|
+
readRequests: workModel?.requestReasons() ?? [],
|
|
311
|
+
transportRequests: [...requests.values()].map(reason => ({ ...reason })),
|
|
223
312
|
nextIdleDeadline: runtimeClients.size > 0 || registry.activeCount > 0 ? null
|
|
224
313
|
: hostedUsed ? config.daemonIdleMs === 0 || zeroSince === undefined ? null : zeroSince + config.daemonIdleMs
|
|
225
314
|
: runtimeZeroSince === undefined ? null : runtimeZeroSince + config.runtimeIdleMs } });
|
|
@@ -234,16 +323,39 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
234
323
|
if (runtimeInFlight >= 32) throw new Error("not_accepted: too many in-flight runtime requests");
|
|
235
324
|
if (socket.writableLength > 4 * 1024 * 1024) { socket.destroy(); return; }
|
|
236
325
|
runtimeInFlight++;
|
|
326
|
+
const releaseControl = controlStore.budget.enter("control");
|
|
237
327
|
try {
|
|
328
|
+
if (!releaseControl) throw new Error("runtime-overloaded: control source capacity");
|
|
238
329
|
cancellations ??= new RuntimeCancellation(realpathSync(getAgentDir()), instanceId!, options.cancellationFault);
|
|
239
|
-
return reply({ data: await cancellations.handle(command) });
|
|
240
|
-
} finally { runtimeInFlight--; }
|
|
330
|
+
return reply({ data: await cancellations.handle(command, accepted('cancellation'), releaseControl) });
|
|
331
|
+
} finally { releaseControl?.(); runtimeInFlight--; }
|
|
241
332
|
}
|
|
242
333
|
if (type === "runtime_bind_catalog_host") {
|
|
243
334
|
if (!greeted) throw new Error(`${type} requires hello`);
|
|
244
335
|
catalog.admission.bind(command.authority, socket);
|
|
245
336
|
return reply({ data: { bound: true } });
|
|
246
337
|
}
|
|
338
|
+
if (type === "runtime_background_tool") {
|
|
339
|
+
if (!greeted) throw new Error("Background tools require hello");
|
|
340
|
+
if (socket.writableLength > 4 * 1024 * 1024) { socket.destroy(); return; }
|
|
341
|
+
if (runtimeInFlight >= 32) throw new Error("runtime-overloaded");
|
|
342
|
+
runtimeInFlight++;
|
|
343
|
+
try { return reply({data: await (await initializeBackground()).handle(command, accepted('background-request'))}); } finally { runtimeInFlight--; }
|
|
344
|
+
}
|
|
345
|
+
if (type === "runtime_launch_subagent") {
|
|
346
|
+
if (!greeted) throw new Error("not_accepted: launch requires hello");
|
|
347
|
+
if (runtimeInFlight >= 32) throw new Error("not_accepted: too many in-flight runtime requests");
|
|
348
|
+
if (socket.writableLength > 4 * 1024 * 1024) { socket.destroy(); return; }
|
|
349
|
+
runtimeInFlight++;
|
|
350
|
+
try {
|
|
351
|
+
launches = await initializeLaunch();
|
|
352
|
+
const data = await launches.handle(command, accepted('managed-launch'));
|
|
353
|
+
// The durable launch receipt must not fail because derived reads
|
|
354
|
+
// are rebuilding or overloaded. Refresh independently.
|
|
355
|
+
void work().livenessReasons().catch(error => log(`Launch snapshot refresh unavailable: ${String(error)}`));
|
|
356
|
+
return reply({ data });
|
|
357
|
+
} finally { runtimeInFlight--; }
|
|
358
|
+
}
|
|
247
359
|
if (type === "runtime_subscribe_catalog") {
|
|
248
360
|
if (!greeted) throw new Error(`${type} requires hello`);
|
|
249
361
|
catalogSubscription?.close();
|
|
@@ -278,7 +390,10 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
278
390
|
guardianBinding = { socket, identity: guardian.owner };
|
|
279
391
|
return reply({ data: { server: current.owner, guardian: guardian.owner } });
|
|
280
392
|
}
|
|
281
|
-
if (type === "runtime_upgrade_status")
|
|
393
|
+
if (type === "runtime_upgrade_status") {
|
|
394
|
+
const journal = readActivationJournal(serverDir);
|
|
395
|
+
return reply({ data: journal ? { ...journal, blockers: upgradeBlockers } : null });
|
|
396
|
+
}
|
|
282
397
|
if (["runtime_get_snapshot", "runtime_subscribe", "runtime_unsubscribe", "runtime_get_metrics"].includes(type)) {
|
|
283
398
|
if (!greeted) throw new Error(`${type} requires hello`);
|
|
284
399
|
if (id && id.length > 128) throw new Error("Runtime request ID exceeds 128 characters");
|
|
@@ -289,7 +404,9 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
289
404
|
workQueries ??= work().connect(socket);
|
|
290
405
|
const data = await workQueries.handle(command);
|
|
291
406
|
if (type === "runtime_get_metrics") {
|
|
292
|
-
return reply({ data: { ...JSON.parse(data.json), mutationSqlite: mutationStoreMetrics(getAgentDir())
|
|
407
|
+
return reply({ data: { ...JSON.parse(data.json), mutationSqlite: mutationStoreMetrics(getAgentDir()),
|
|
408
|
+
workBudget: controlStore.budget.metrics(), resultSupervision: resultSupervision?.metrics,
|
|
409
|
+
subagentLifecycle: launches?.status().lifecycle } });
|
|
293
410
|
}
|
|
294
411
|
if (socket.writableLength > 4 * 1024 * 1024) { socket.destroy(); return; }
|
|
295
412
|
// Snapshot JSON is encoded in the worker; only the small envelope runs here.
|
|
@@ -310,9 +427,10 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
310
427
|
|| journal.previousOwner?.token !== instanceId || journal.phase !== "prepared") throw new Error("Upgrade request does not match this daemon's activation journal");
|
|
311
428
|
if (!compatibleUpgrade(build, runtime.build)) throw new Error("Unsafe SDK downgrade or incompatible protocol");
|
|
312
429
|
if (pendingUpgrade && pendingUpgrade.operationId !== command.operationId) throw new Error("activation-conflict: another upgrade is pending");
|
|
430
|
+
setUpgradeFence(instanceId!);
|
|
313
431
|
pendingUpgrade = { runtime, operationId: command.operationId, serverDir, agentDir: command.agentDir as string };
|
|
314
432
|
setImmediate(() => { void daemon.sweepIdle().catch(error => log(`upgrade maintenance failed: ${String(error)}`)); });
|
|
315
|
-
return reply({ data: { status: "deferred", operationId: command.operationId, reason: "Waiting for idle sessions" } });
|
|
433
|
+
return reply({ data: { status: "deferred", operationId: command.operationId, reason: "Waiting for accepted runtime work and idle sessions" } });
|
|
316
434
|
}
|
|
317
435
|
if (NATIVE_HOST_COMMANDS.has(type)) return reply({ data: await nativeHost.handle(command) });
|
|
318
436
|
if ((sessionMaintenance?.busy || nativeHost.busy) && !["list_sessions", "client_snapshot", "subscribe", "acquire_control", "release_control", "extension_ui_response"].includes(type)) {
|
|
@@ -385,7 +503,15 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
385
503
|
await nativeHost.reload(sessionId);
|
|
386
504
|
return reply({ sessionId });
|
|
387
505
|
}
|
|
388
|
-
if (type === "client_snapshot")
|
|
506
|
+
if (type === "client_snapshot") {
|
|
507
|
+
if (socket.destroyed) return;
|
|
508
|
+
const data = await new Promise<unknown>((resolve, reject) => {
|
|
509
|
+
const closed = () => reject(new Error('Read caller disconnected'));
|
|
510
|
+
socket.once('close', closed);
|
|
511
|
+
void hosted.clientSnapshot().then(resolve, reject).finally(() => socket.off('close', closed));
|
|
512
|
+
});
|
|
513
|
+
return reply({ sessionId, data });
|
|
514
|
+
}
|
|
389
515
|
if (type === "clear_queue") return reply({ sessionId, data: hosted.session.clearQueue() });
|
|
390
516
|
if (type === "abort_compaction") {
|
|
391
517
|
hosted.session.abortCompaction();
|
|
@@ -395,10 +521,16 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
395
521
|
const response = await hosted.handle(rpc as RpcCommand);
|
|
396
522
|
send({ ...response, sessionId } as ServerMessage);
|
|
397
523
|
} catch (error) {
|
|
524
|
+
evidenceFailed = true;
|
|
398
525
|
send(failure(id, type || "unknown", error instanceof Error ? error.message : String(error)));
|
|
399
526
|
} finally {
|
|
527
|
+
if (evidencePlane) {
|
|
528
|
+
options.rpcEvidence?.event(evidencePlane, request, evidenceFailed ? 'request-failed' : 'request-returned');
|
|
529
|
+
options.rpcEvidence?.event(evidencePlane, request, 'settled');
|
|
530
|
+
}
|
|
400
531
|
releaseSessionOperation?.();
|
|
401
532
|
inFlight--;
|
|
533
|
+
requests.delete(request);
|
|
402
534
|
if (registry.activeCount > 0) { zeroSince = undefined; hostedUsed = true; }
|
|
403
535
|
else zeroSince ??= now();
|
|
404
536
|
}
|
|
@@ -436,7 +568,10 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
436
568
|
|
|
437
569
|
cleanupStartup = async () => {
|
|
438
570
|
await cancellations?.close();
|
|
571
|
+
await (await launchInitialization?.catch(() => undefined))?.close();
|
|
572
|
+
await (await backgroundInitialization?.catch(() => undefined))?.close();
|
|
439
573
|
resultSupervision?.close();
|
|
574
|
+
controlStore.release();
|
|
440
575
|
if (resultPorts.get(resultRoot) === resultPort) resultPorts.delete(resultRoot);
|
|
441
576
|
await workModel?.close();
|
|
442
577
|
for (const socket of sockets) socket.destroy();
|
|
@@ -471,9 +606,10 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
471
606
|
if (pendingUpgrade && sessionMaintenance) {
|
|
472
607
|
const request = pendingUpgrade;
|
|
473
608
|
const journal = readActivationJournal(serverDir);
|
|
474
|
-
if (!journal || journal.operationId !== request.operationId || !hasActivationReservations(journal)) pendingUpgrade = undefined;
|
|
609
|
+
if (!journal || journal.operationId !== request.operationId || !hasActivationReservations(journal)) { setUpgradeFence(null); pendingUpgrade = undefined; upgradeBlockers = []; }
|
|
475
610
|
else {
|
|
476
611
|
try {
|
|
612
|
+
upgradeBlockers = [];
|
|
477
613
|
// Observe background completion before taking the idle fence. A slow or
|
|
478
614
|
// failed provider must leave admitted work and dialog answers usable.
|
|
479
615
|
const live = registry.list().filter(item => item.live).map(item => registry.get(item.sessionId)!);
|
|
@@ -485,6 +621,11 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
485
621
|
const legacyController = () => live.some(hosted => hosted.controllerIs(controller =>
|
|
486
622
|
!(controller instanceof ConnectionControl) || reconnectControllers.get(controller) !== true));
|
|
487
623
|
if (legacyController()) throw new Error("Waiting for legacy controllers to detach");
|
|
624
|
+
// HostedSession idleness does not cover detached accepted work.
|
|
625
|
+
// Unknown observation fails closed for an irreversible activation.
|
|
626
|
+
upgradeBlockers = await work().upgradeObligations();
|
|
627
|
+
if (upgradeBlockers.length) throw new Error(`Waiting for runtime work: ${JSON.stringify(upgradeBlockers)}`);
|
|
628
|
+
if (inFlight > 0 || cancellations?.busy) throw new Error("Waiting for in-flight runtime admission");
|
|
488
629
|
commitActivationStop(request, lease, () => { draining = true; upgradeCommitted = true; });
|
|
489
630
|
for (const hosted of live) {
|
|
490
631
|
(hosted as HostedSession & { publishRuntimeEvent(event: unknown): void }).publishRuntimeEvent({
|
|
@@ -492,7 +633,10 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
492
633
|
});
|
|
493
634
|
}
|
|
494
635
|
});
|
|
495
|
-
} catch (error) {
|
|
636
|
+
} catch (error) {
|
|
637
|
+
if (!upgradeBlockers.length) upgradeBlockers = [{ kind: "upgrade-unavailable", reason: String(error) }];
|
|
638
|
+
log(`upgrade waiting: ${String(error)}`);
|
|
639
|
+
}
|
|
496
640
|
// Pending upgrades take priority over expiry and release their idle fence on busy passes.
|
|
497
641
|
return;
|
|
498
642
|
}
|
|
@@ -511,11 +655,25 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
511
655
|
: (now() - runtimeZeroSince < config.runtimeIdleMs || now() < startupUntil)) return;
|
|
512
656
|
// Recheck durable activity before fencing admission; observation never adopts a writer.
|
|
513
657
|
if (draining) return;
|
|
658
|
+
resultSupervision?.reconcile();
|
|
659
|
+
if (resultSupervision?.livenessReasons().length) {
|
|
660
|
+
runtimeZeroSince = undefined;
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
if (launches?.lifecycleReasons().length) { runtimeZeroSince = undefined; return; }
|
|
664
|
+
if (backgroundTools?.lifecycleReasons().length) { runtimeZeroSince = undefined; return; }
|
|
514
665
|
try {
|
|
515
|
-
|
|
666
|
+
// Control never waits for a queued/rebuilding/wedged read worker.
|
|
667
|
+
// Legacy passive evidence is usable only within its existing idle
|
|
668
|
+
// verification window; it cannot renew itself through a probe RPC.
|
|
669
|
+
const observation = workModel?.observation();
|
|
670
|
+
const fresh = observation?.observedAt !== null && observation?.observedAt !== undefined
|
|
671
|
+
&& now() < observation.observedAt + config.runtimeIdleMs;
|
|
672
|
+
if (fresh && observation.reasons.some((reason: any) => !resultSupervision?.manages(reason.operationId))) {
|
|
516
673
|
runtimeZeroSince = undefined;
|
|
517
674
|
return;
|
|
518
675
|
}
|
|
676
|
+
if (observation && (!fresh || observation.status !== "ready")) observationUnavailable = true;
|
|
519
677
|
} catch (error) {
|
|
520
678
|
// The executor already bounds query deadlines and terminates failed workers.
|
|
521
679
|
// Unknown obligations cannot keep an otherwise detached runtime alive forever.
|
|
@@ -524,9 +682,11 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
524
682
|
log(`runtime observation unavailable at idle shutdown: ${String(error)}`);
|
|
525
683
|
}
|
|
526
684
|
// No create/open can slip between this check and the synchronous admission fence.
|
|
527
|
-
if (runtimeClients.size > 0 || registry.activeCount > 0 || inFlight > 0 || cancellations?.busy || sessionMaintenance?.busy || nativeHost.busy || registry.hasPendingOperations) return;
|
|
685
|
+
if (runtimeClients.size > 0 || registry.activeCount > 0 || inFlight > 0 || launches?.busy || backgroundTools?.busy || cancellations?.busy || sessionMaintenance?.busy || nativeHost.busy || registry.hasPendingOperations) return;
|
|
528
686
|
draining = true;
|
|
529
687
|
idleStopping = true;
|
|
688
|
+
idleEvidence = { at: now(), deadline: hostedUsed ? zeroSince! + config.daemonIdleMs : runtimeZeroSince! + config.runtimeIdleMs,
|
|
689
|
+
lifecycle: config, obligations: [], budget: controlStore.budget.metrics() };
|
|
530
690
|
log("idle timeout with no active sessions; shutting down");
|
|
531
691
|
})().finally(() => { maintenance = undefined; });
|
|
532
692
|
return maintenance.then(() => draining ? daemon.stop() : undefined);
|
|
@@ -554,14 +714,17 @@ export async function startDaemon(options: DaemonOptions = {}): Promise<Daemon>
|
|
|
554
714
|
for (const socket of sockets) socket.destroy();
|
|
555
715
|
await closed;
|
|
556
716
|
await cancellations?.close();
|
|
717
|
+
await (await launchInitialization?.catch(() => undefined))?.close();
|
|
718
|
+
await (await backgroundInitialization?.catch(() => undefined))?.close();
|
|
557
719
|
resultSupervision?.close();
|
|
720
|
+
controlStore.release();
|
|
558
721
|
if (resultPorts.get(resultRoot) === resultPort) resultPorts.delete(resultRoot);
|
|
559
722
|
await workModel?.close();
|
|
560
723
|
await registry.shutdown();
|
|
561
724
|
await Promise.allSettled([...dispatches]);
|
|
562
725
|
if (existsSync(socketPath)) unlinkSync(socketPath);
|
|
563
726
|
const checkpoint = join(serverDir, `clean-stop-${instanceId}.tmp`);
|
|
564
|
-
writeFileSync(checkpoint, JSON.stringify({ pid: process.pid, token: instanceId, reason: "clean-stop", observation: observationUnavailable ? "unavailable" : "verified" }), { mode: 0o600 });
|
|
727
|
+
writeFileSync(checkpoint, JSON.stringify({ pid: process.pid, token: instanceId, reason: "clean-stop", observation: observationUnavailable ? "unavailable" : "verified", idleEvidence }), { mode: 0o600 });
|
|
565
728
|
renameSync(checkpoint, join(serverDir, "clean-stop.json"));
|
|
566
729
|
releaseOwner();
|
|
567
730
|
finishClosed();
|