harnery 0.38.0 → 0.40.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/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +32 -8
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +97 -6
- package/dist/commands/backup.d.ts +16 -0
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +239 -33
- package/dist/commands/browse.d.ts +8 -0
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +466 -231
- package/dist/commands/diagnostics.d.ts.map +1 -1
- package/dist/commands/diagnostics.js +6 -3
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +20 -4
- package/dist/commands/qa-run.d.ts.map +1 -1
- package/dist/commands/qa-run.js +26 -3
- package/dist/commands/qa-status.d.ts.map +1 -1
- package/dist/commands/qa-status.js +7 -2
- package/dist/commands/resources.d.ts.map +1 -1
- package/dist/commands/resources.js +23 -3
- package/dist/commands/review-pack.d.ts.map +1 -1
- package/dist/commands/review-pack.js +98 -23
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +2 -2
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/canonical-emit.d.ts +3 -2
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +2 -0
- package/dist/core/agents/cli.js +13 -6
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +5 -3
- package/dist/core/agents/live-lifecycle-v3.d.ts +2 -2
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.d.ts +7 -5
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +63 -8
- package/dist/core/agents/session-finalizer-v3.d.ts +2 -2
- package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.d.ts +3 -3
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +2 -1
- package/dist/core/agents/state/names.d.ts +35 -2
- package/dist/core/agents/state/names.d.ts.map +1 -1
- package/dist/core/agents/state/names.js +80 -5
- package/dist/core/agents/state/stale-sweep.d.ts +2 -1
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +23 -6
- package/dist/core/agents/turn-elapsed.d.ts +51 -0
- package/dist/core/agents/turn-elapsed.d.ts.map +1 -0
- package/dist/core/agents/turn-elapsed.js +91 -0
- package/dist/core/artifacts/activity.d.ts +14 -0
- package/dist/core/artifacts/activity.d.ts.map +1 -0
- package/dist/core/artifacts/activity.js +52 -0
- package/dist/core/artifacts/delivery-card.d.ts +39 -0
- package/dist/core/artifacts/delivery-card.d.ts.map +1 -0
- package/dist/core/artifacts/delivery-card.js +282 -0
- package/dist/core/artifacts/index.d.ts +42 -7
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +288 -76
- package/dist/core/artifacts/mutation-lock.d.ts +2 -0
- package/dist/core/artifacts/mutation-lock.d.ts.map +1 -0
- package/dist/core/artifacts/mutation-lock.js +91 -0
- package/dist/core/backup/host-snapshot.d.ts +18 -0
- package/dist/core/backup/host-snapshot.d.ts.map +1 -0
- package/dist/core/backup/host-snapshot.js +64 -0
- package/dist/core/config.d.ts +20 -5
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +44 -10
- package/dist/core/diagnostics/advice.d.ts +38 -3
- package/dist/core/diagnostics/advice.d.ts.map +1 -1
- package/dist/core/diagnostics/advice.js +103 -99
- package/dist/core/diagnostics/bundle.d.ts.map +1 -1
- package/dist/core/diagnostics/bundle.js +111 -47
- package/dist/core/diagnostics/comparison.d.ts.map +1 -1
- package/dist/core/diagnostics/comparison.js +3 -2
- package/dist/core/diagnostics/contract.d.ts +15 -31
- package/dist/core/diagnostics/contract.d.ts.map +1 -1
- package/dist/core/diagnostics/contract.js +2 -5
- package/dist/core/diagnostics/index.d.ts +2 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -1
- package/dist/core/diagnostics/index.js +2 -0
- package/dist/core/diagnostics/pressure-contract.d.ts +260 -0
- package/dist/core/diagnostics/pressure-contract.d.ts.map +1 -0
- package/dist/core/diagnostics/pressure-contract.js +70 -0
- package/dist/core/diagnostics/pressure.d.ts +25 -0
- package/dist/core/diagnostics/pressure.d.ts.map +1 -0
- package/dist/core/diagnostics/pressure.js +1138 -0
- package/dist/core/diagnostics/replay.d.ts.map +1 -1
- package/dist/core/diagnostics/replay.js +90 -10
- package/dist/core/events/v3/adapter-id.d.ts +6 -0
- package/dist/core/events/v3/adapter-id.d.ts.map +1 -0
- package/dist/core/events/v3/adapter-id.js +7 -0
- package/dist/core/events/v3/archive-retention.d.ts.map +1 -1
- package/dist/core/events/v3/archive-retention.js +3 -2
- package/dist/core/events/v3/bootstrap.d.ts +41 -4
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
- package/dist/core/events/v3/bootstrap.js +120 -17
- package/dist/core/events/v3/capabilities.d.ts +16 -9
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +37 -2
- package/dist/core/events/v3/capability-drift.d.ts +2 -2
- package/dist/core/events/v3/capability-drift.d.ts.map +1 -1
- package/dist/core/events/v3/control-witness.d.ts +48 -5
- package/dist/core/events/v3/control-witness.d.ts.map +1 -1
- package/dist/core/events/v3/control-witness.js +91 -36
- package/dist/core/events/v3/control.d.ts.map +1 -1
- package/dist/core/events/v3/control.js +22 -2
- package/dist/core/events/v3/index.d.ts +2 -1
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +2 -1
- package/dist/core/events/v3/live-feed.d.ts +7 -1
- package/dist/core/events/v3/live-feed.d.ts.map +1 -1
- package/dist/core/events/v3/live-feed.js +21 -3
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +10 -2
- package/dist/core/events/v3/producers/command-recorder.d.ts +2 -2
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/command-recorder.js +2 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +2 -2
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +2 -1
- package/dist/core/events/v3/producers/hook-base.d.ts +2 -2
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +15 -5
- package/dist/core/events/v3/producers/hook.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook.js +17 -4
- package/dist/core/events/v3/producers/intake.d.ts +4 -4
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +3 -2
- package/dist/core/events/v3/producers/producer-state-observer.d.ts.map +1 -1
- package/dist/core/events/v3/producers/producer-state-observer.js +2 -1
- package/dist/core/events/v3/producers/recorder.d.ts +16 -5
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +31 -9
- package/dist/core/events/v3/reader.d.ts.map +1 -1
- package/dist/core/events/v3/reader.js +10 -13
- package/dist/core/events/v3/runtime-build.d.ts.map +1 -1
- package/dist/core/events/v3/runtime-build.js +3 -2
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts +2 -2
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/turn-telemetry.d.ts +2 -2
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.d.ts +16 -14
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +36 -38
- package/dist/core/hooks/backup-schedule.d.ts +34 -0
- package/dist/core/hooks/backup-schedule.d.ts.map +1 -0
- package/dist/core/hooks/backup-schedule.js +114 -0
- package/dist/core/hooks/cli.js +61 -18
- package/dist/core/hooks/codex-wsl-bridge.d.ts +2 -0
- package/dist/core/hooks/codex-wsl-bridge.d.ts.map +1 -1
- package/dist/core/hooks/codex-wsl-bridge.js +18 -4
- package/dist/core/hooks/index.d.ts +1 -0
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js +1 -0
- package/dist/core/hooks/prompt-context/contract.d.ts +61 -0
- package/dist/core/hooks/prompt-context/contract.d.ts.map +1 -0
- package/dist/core/hooks/prompt-context/contract.js +102 -0
- package/dist/core/hooks/prompt-context/index.d.ts +5 -0
- package/dist/core/hooks/prompt-context/index.d.ts.map +1 -0
- package/dist/core/hooks/prompt-context/index.js +2 -0
- package/dist/core/hooks/prompt-context/runner.d.ts +24 -0
- package/dist/core/hooks/prompt-context/runner.d.ts.map +1 -0
- package/dist/core/hooks/prompt-context/runner.js +249 -0
- package/dist/core/qa-artifacts.d.ts +3 -0
- package/dist/core/qa-artifacts.d.ts.map +1 -1
- package/dist/core/qa-artifacts.js +25 -3
- package/dist/core/resources/contract.d.ts +69 -3
- package/dist/core/resources/contract.d.ts.map +1 -1
- package/dist/core/resources/contract.js +1 -1
- package/dist/core/resources/index.d.ts +1 -0
- package/dist/core/resources/index.d.ts.map +1 -1
- package/dist/core/resources/index.js +1 -0
- package/dist/core/resources/native.d.ts +36 -0
- package/dist/core/resources/native.d.ts.map +1 -0
- package/dist/core/resources/native.js +418 -0
- package/dist/core/resources/sampler.d.ts +2 -0
- package/dist/core/resources/sampler.d.ts.map +1 -1
- package/dist/core/resources/sampler.js +31 -1
- package/dist/core/resources/status.d.ts +61 -0
- package/dist/core/resources/status.d.ts.map +1 -0
- package/dist/core/resources/status.js +536 -0
- package/dist/core/resources/system.d.ts +27 -0
- package/dist/core/resources/system.d.ts.map +1 -0
- package/dist/core/resources/system.js +439 -0
- package/dist/core/semantic/contract.d.ts +13 -13
- package/dist/core/semantic/service.d.ts +2 -0
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +27 -4
- package/dist/core/storage/builtins.js +41 -0
- package/dist/core/supervisor/contract.d.ts +41 -3
- package/dist/core/supervisor/contract.d.ts.map +1 -1
- package/dist/core/supervisor/contract.js +3 -2
- package/dist/core/supervisor/findings.d.ts +3 -0
- package/dist/core/supervisor/findings.d.ts.map +1 -1
- package/dist/core/supervisor/findings.js +88 -0
- package/dist/core/supervisor/history.d.ts.map +1 -1
- package/dist/core/supervisor/history.js +14 -0
- package/dist/core/supervisor/ledger-state.d.ts +55 -0
- package/dist/core/supervisor/ledger-state.d.ts.map +1 -0
- package/dist/core/supervisor/ledger-state.js +0 -0
- package/dist/core/supervisor/service.d.ts.map +1 -1
- package/dist/core/supervisor/service.js +120 -7
- package/dist/core/supervisor/storage.d.ts +3 -1
- package/dist/core/supervisor/storage.d.ts.map +1 -1
- package/dist/core/supervisor/storage.js +4 -0
- package/dist/core/workflow/admission.d.ts +3 -0
- package/dist/core/workflow/admission.d.ts.map +1 -1
- package/dist/core/workflow/admission.js +28 -16
- package/dist/core/workflow/engine.js +2 -2
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +6 -1
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +4 -3
- package/dist/lib/browser/capture-fidelity.d.ts +7 -0
- package/dist/lib/browser/capture-fidelity.d.ts.map +1 -1
- package/dist/lib/browser/capture-fidelity.js +17 -0
- package/dist/lib/browser/client.d.ts +9 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +85 -37
- package/dist/lib/browser/index.d.ts +3 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -1
- package/dist/lib/browser/page-review-budget.d.ts +13 -0
- package/dist/lib/browser/page-review-budget.d.ts.map +1 -0
- package/dist/lib/browser/page-review-budget.js +251 -0
- package/dist/lib/browser/page-review-contracts.d.ts +127 -0
- package/dist/lib/browser/page-review-contracts.d.ts.map +1 -0
- package/dist/lib/browser/page-review-contracts.js +5 -0
- package/dist/lib/browser/page-review-evidence.d.ts +48 -0
- package/dist/lib/browser/page-review-evidence.d.ts.map +1 -0
- package/dist/lib/browser/page-review-evidence.js +340 -0
- package/dist/lib/browser/page-review-judge.d.ts +1 -1
- package/dist/lib/browser/page-review-judge.d.ts.map +1 -1
- package/dist/lib/browser/page-review-judge.js +46 -38
- package/dist/lib/browser/page-review-pack.d.ts +44 -22
- package/dist/lib/browser/page-review-pack.d.ts.map +1 -1
- package/dist/lib/browser/page-review-pack.js +116 -36
- package/dist/lib/browser/page-review-source.d.ts +12 -0
- package/dist/lib/browser/page-review-source.d.ts.map +1 -0
- package/dist/lib/browser/page-review-source.js +22 -0
- package/dist/lib/browser/qa-run-contracts.d.ts +35 -9
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -1
- package/dist/lib/browser/qa-run-contracts.js +48 -14
- package/dist/lib/browser/qa-run.d.ts.map +1 -1
- package/dist/lib/browser/qa-run.js +215 -68
- package/dist/lib/browser/qa-snapshot.d.ts +6 -0
- package/dist/lib/browser/qa-snapshot.d.ts.map +1 -1
- package/dist/lib/browser/qa-snapshot.js +259 -48
- package/dist/lib/browser/review-capture-transaction.d.ts +13 -0
- package/dist/lib/browser/review-capture-transaction.d.ts.map +1 -0
- package/dist/lib/browser/review-capture-transaction.js +79 -0
- package/dist/lib/browser/standalone-html.d.ts.map +1 -1
- package/dist/lib/browser/standalone-html.js +4 -2
- package/dist/lib/browser/thumbnail-association.d.ts +34 -0
- package/dist/lib/browser/thumbnail-association.d.ts.map +1 -0
- package/dist/lib/browser/thumbnail-association.js +158 -0
- package/dist/lib/browser/tiling.d.ts +30 -0
- package/dist/lib/browser/tiling.d.ts.map +1 -1
- package/dist/lib/browser/tiling.js +38 -0
- package/dist/lib/docs-metadata-managed.d.ts.map +1 -1
- package/dist/lib/docs-metadata-managed.js +4 -1
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +7 -1
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +1 -0
- package/dist/lib/local-file-url.d.ts +12 -0
- package/dist/lib/local-file-url.d.ts.map +1 -1
- package/dist/lib/local-file-url.js +16 -2
- package/dist/lib/tunnel/state.d.ts +19 -4
- package/dist/lib/tunnel/state.d.ts.map +1 -1
- package/dist/lib/tunnel/state.js +53 -13
- package/package.json +7 -4
- package/schemas/config.schema.json +69 -2
- package/src/commands/agents.ts +42 -9
- package/src/commands/artifacts.ts +130 -6
- package/src/commands/backup.ts +287 -34
- package/src/commands/browse.ts +564 -267
- package/src/commands/diagnostics.ts +6 -3
- package/src/commands/ledger-v3.ts +20 -3
- package/src/commands/qa-run.ts +37 -3
- package/src/commands/qa-status.ts +11 -2
- package/src/commands/resources.ts +23 -3
- package/src/commands/review-pack.ts +165 -62
- package/src/commands/tunnel.ts +2 -1
- package/src/core/agents/canonical-emit.ts +4 -2
- package/src/core/agents/cli.ts +14 -6
- package/src/core/agents/live-authority-v3.ts +7 -3
- package/src/core/agents/live-lifecycle-v3.ts +2 -2
- package/src/core/agents/render/prompt-context.ts +68 -14
- package/src/core/agents/session-finalizer-v3.ts +2 -2
- package/src/core/agents/state/live-coordination-view.ts +4 -4
- package/src/core/agents/state/names.ts +92 -7
- package/src/core/agents/state/stale-sweep.ts +22 -8
- package/src/core/agents/turn-elapsed.ts +135 -0
- package/src/core/artifacts/activity.ts +71 -0
- package/src/core/artifacts/delivery-card.ts +375 -0
- package/src/core/artifacts/index.ts +385 -91
- package/src/core/artifacts/mutation-lock.ts +106 -0
- package/src/core/backup/host-snapshot.ts +76 -0
- package/src/core/config.ts +66 -13
- package/src/core/diagnostics/advice.ts +148 -120
- package/src/core/diagnostics/bundle.ts +138 -52
- package/src/core/diagnostics/comparison.ts +6 -2
- package/src/core/diagnostics/contract.ts +39 -42
- package/src/core/diagnostics/index.ts +2 -0
- package/src/core/diagnostics/pressure-contract.ts +294 -0
- package/src/core/diagnostics/pressure.ts +1361 -0
- package/src/core/diagnostics/replay.ts +116 -11
- package/src/core/events/v3/adapter-id.ts +12 -0
- package/src/core/events/v3/archive-retention.ts +3 -6
- package/src/core/events/v3/bootstrap.ts +163 -16
- package/src/core/events/v3/capabilities.ts +75 -25
- package/src/core/events/v3/capability-drift.ts +2 -2
- package/src/core/events/v3/control-witness.ts +172 -41
- package/src/core/events/v3/control.ts +34 -2
- package/src/core/events/v3/index.ts +3 -0
- package/src/core/events/v3/live-feed.ts +23 -5
- package/src/core/events/v3/live-routing.ts +14 -2
- package/src/core/events/v3/producers/command-recorder.ts +4 -4
- package/src/core/events/v3/producers/coordination-recorder.ts +4 -4
- package/src/core/events/v3/producers/hook-base.ts +21 -16
- package/src/core/events/v3/producers/hook.ts +21 -4
- package/src/core/events/v3/producers/intake.ts +6 -6
- package/src/core/events/v3/producers/producer-state-observer.ts +2 -1
- package/src/core/events/v3/producers/recorder.ts +50 -21
- package/src/core/events/v3/reader.ts +14 -13
- package/src/core/events/v3/runtime-build.ts +3 -2
- package/src/core/events/v3/runtime-telemetry-capabilities.ts +3 -3
- package/src/core/events/v3/turn-telemetry.ts +4 -4
- package/src/core/hooks/adapter/output.ts +50 -36
- package/src/core/hooks/backup-schedule.ts +147 -0
- package/src/core/hooks/cli.ts +65 -14
- package/src/core/hooks/codex-wsl-bridge.ts +21 -5
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/prompt-context/contract.ts +177 -0
- package/src/core/hooks/prompt-context/index.ts +22 -0
- package/src/core/hooks/prompt-context/runner.ts +303 -0
- package/src/core/qa-artifacts.ts +29 -3
- package/src/core/resources/contract.ts +76 -3
- package/src/core/resources/index.ts +1 -0
- package/src/core/resources/native.ts +481 -0
- package/src/core/resources/sampler.ts +46 -1
- package/src/core/resources/status.ts +717 -0
- package/src/core/resources/system.ts +530 -0
- package/src/core/semantic/service.ts +37 -3
- package/src/core/storage/builtins.ts +41 -0
- package/src/core/supervisor/contract.ts +45 -3
- package/src/core/supervisor/findings.ts +159 -0
- package/src/core/supervisor/history.ts +15 -0
- package/src/core/supervisor/ledger-state.ts +0 -0
- package/src/core/supervisor/service.ts +133 -5
- package/src/core/supervisor/storage.ts +7 -0
- package/src/core/workflow/admission.ts +33 -17
- package/src/core/workflow/engine.ts +2 -2
- package/src/core/workflow/live-session-v3.ts +6 -8
- package/src/core/workflow/proof.ts +4 -3
- package/src/lib/browser/capture-fidelity.ts +23 -0
- package/src/lib/browser/client.ts +96 -44
- package/src/lib/browser/index.ts +15 -1
- package/src/lib/browser/page-review-budget.ts +309 -0
- package/src/lib/browser/page-review-contracts.ts +129 -0
- package/src/lib/browser/page-review-evidence.ts +465 -0
- package/src/lib/browser/page-review-judge.ts +56 -40
- package/src/lib/browser/page-review-pack.ts +181 -43
- package/src/lib/browser/page-review-source.ts +30 -0
- package/src/lib/browser/qa-run-contracts.ts +62 -18
- package/src/lib/browser/qa-run.ts +259 -71
- package/src/lib/browser/qa-snapshot.ts +289 -48
- package/src/lib/browser/review-capture-transaction.ts +106 -0
- package/src/lib/browser/standalone-html.ts +4 -2
- package/src/lib/browser/thumbnail-association.ts +190 -0
- package/src/lib/browser/tiling.ts +63 -0
- package/src/lib/docs-metadata-managed.ts +4 -1
- package/src/lib/identities/assume.ts +12 -4
- package/src/lib/instructions/templates.ts +1 -0
- package/src/lib/local-file-url.ts +17 -2
- package/src/lib/tunnel/state.ts +70 -13
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { closeSync, openSync, readdirSync, readSync, statfsSync, statSync } from "node:fs";
|
|
2
|
+
import { platform, tmpdir } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { performance } from "node:perf_hooks";
|
|
5
|
+
/** The `/proc/vmstat` counters the reclaim rates are derived from, in report order. */
|
|
6
|
+
const VMSTAT_COUNTERS = ["pswpin", "pswpout", "pgscan_direct", "pgmajfault"];
|
|
7
|
+
/**
|
|
8
|
+
* Linux reports `pswpin` and `pswpout` in pages, and the kernel does not
|
|
9
|
+
* publish the page size in `/proc/vmstat`. Every architecture Harnery runs on
|
|
10
|
+
* uses a 4096 byte base page, so that value converts pages to bytes here. A
|
|
11
|
+
* platform with a different base page would need its page size supplied.
|
|
12
|
+
*/
|
|
13
|
+
const VMSTAT_PAGE_SIZE_BYTES = 4_096;
|
|
14
|
+
const ioBaselines = new Map();
|
|
15
|
+
const oomBaselines = new Map();
|
|
16
|
+
const vmstatBaselines = new Map();
|
|
17
|
+
const MAX_BASELINES = 64;
|
|
18
|
+
const MAX_BLOCK_DEVICES = 1_024;
|
|
19
|
+
/** Collect only the workspace and temporary volume; never walk their contents. */
|
|
20
|
+
export function collectSystemResources(coordRoot, options = {}) {
|
|
21
|
+
const currentPlatform = options.platform ?? platform();
|
|
22
|
+
const procRoot = options.procRoot ?? "/proc";
|
|
23
|
+
const sysRoot = options.sysRoot ?? "/sys";
|
|
24
|
+
const disks = collectDisks(coordRoot, options);
|
|
25
|
+
if (currentPlatform !== "linux") {
|
|
26
|
+
return {
|
|
27
|
+
disks,
|
|
28
|
+
pressure: {
|
|
29
|
+
state: "unsupported",
|
|
30
|
+
cpu: null,
|
|
31
|
+
memory: null,
|
|
32
|
+
io: null,
|
|
33
|
+
memory_full: null,
|
|
34
|
+
io_full: null,
|
|
35
|
+
reason: `Linux pressure stall information is unavailable on ${currentPlatform}.`,
|
|
36
|
+
},
|
|
37
|
+
io: unavailableIo("unsupported", `Disk I/O rates are not collected on ${currentPlatform}.`),
|
|
38
|
+
oom: {
|
|
39
|
+
state: "unsupported",
|
|
40
|
+
total_kills: null,
|
|
41
|
+
kills_since_last_sample: null,
|
|
42
|
+
last_kill_age_ms: null,
|
|
43
|
+
reason: `Kernel OOM kill counters are not collected on ${currentPlatform}.`,
|
|
44
|
+
},
|
|
45
|
+
vmstat: unavailableVmstat("unsupported", `Kernel memory reclaim counters are not collected on ${currentPlatform}.`, false),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const key = JSON.stringify([
|
|
49
|
+
resolve(coordRoot),
|
|
50
|
+
options.namespace ?? "linux",
|
|
51
|
+
resolve(procRoot),
|
|
52
|
+
resolve(sysRoot),
|
|
53
|
+
]);
|
|
54
|
+
return {
|
|
55
|
+
disks,
|
|
56
|
+
pressure: collectPressure(procRoot),
|
|
57
|
+
io: collectIo(procRoot, sysRoot, options.nowMs ?? performance.now(), key),
|
|
58
|
+
oom: collectOom(procRoot, options.nowMs ?? performance.now(), key),
|
|
59
|
+
vmstat: collectVmstat(procRoot, options.nowMs ?? performance.now(), key),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function collectDisks(coordRoot, options) {
|
|
63
|
+
const inspect = options.statfs ?? statfsSync;
|
|
64
|
+
const filesystemId = options.filesystemId ?? ((path) => statSync(path).dev);
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
const results = [];
|
|
67
|
+
for (const path of new Set([resolve(coordRoot), resolve(options.tmpPath ?? tmpdir())])) {
|
|
68
|
+
try {
|
|
69
|
+
const stat = inspect(path);
|
|
70
|
+
const blockSize = Number(stat.bsize);
|
|
71
|
+
const total = blockSize * Number(stat.blocks);
|
|
72
|
+
const available = blockSize * Number(stat.bavail);
|
|
73
|
+
const free = blockSize * Number(stat.bfree);
|
|
74
|
+
if (![blockSize, total, available, free].every(Number.isFinite) ||
|
|
75
|
+
blockSize <= 0 ||
|
|
76
|
+
total <= 0 ||
|
|
77
|
+
free < 0 ||
|
|
78
|
+
free > total ||
|
|
79
|
+
available > total) {
|
|
80
|
+
throw new Error("Invalid filesystem capacity counters.");
|
|
81
|
+
}
|
|
82
|
+
// st_dev identifies the mounted filesystem, unlike coincidentally equal capacity values.
|
|
83
|
+
try {
|
|
84
|
+
const id = filesystemId(path);
|
|
85
|
+
if (seen.has(id))
|
|
86
|
+
continue;
|
|
87
|
+
seen.add(id);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Capacity is still useful when stat cannot identify the filesystem.
|
|
91
|
+
}
|
|
92
|
+
results.push({
|
|
93
|
+
path,
|
|
94
|
+
state: "supported",
|
|
95
|
+
total_bytes: total,
|
|
96
|
+
available_bytes: Math.max(0, available),
|
|
97
|
+
used_percent: round(((total - free) / total) * 100),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
results.push({
|
|
102
|
+
path,
|
|
103
|
+
state: unsupportedError(error) ? "unsupported" : "error",
|
|
104
|
+
total_bytes: null,
|
|
105
|
+
available_bytes: null,
|
|
106
|
+
used_percent: null,
|
|
107
|
+
reason: errorReason(error),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return results;
|
|
112
|
+
}
|
|
113
|
+
function collectPressure(procRoot) {
|
|
114
|
+
const sample = {
|
|
115
|
+
state: "supported",
|
|
116
|
+
cpu: null,
|
|
117
|
+
memory: null,
|
|
118
|
+
io: null,
|
|
119
|
+
memory_full: null,
|
|
120
|
+
io_full: null,
|
|
121
|
+
};
|
|
122
|
+
const reasons = [];
|
|
123
|
+
let supported = 0;
|
|
124
|
+
let failures = 0;
|
|
125
|
+
for (const resource of ["cpu", "memory", "io"]) {
|
|
126
|
+
try {
|
|
127
|
+
const raw = readBounded(join(procRoot, "pressure", resource), 4_096);
|
|
128
|
+
const some = parsePressure(raw, "some");
|
|
129
|
+
// System-wide CPU full is undefined. Memory and I/O full measure all non-idle tasks stalled.
|
|
130
|
+
if (resource !== "cpu")
|
|
131
|
+
sample[`${resource}_full`] = parsePressure(raw, "full");
|
|
132
|
+
sample[resource] = some;
|
|
133
|
+
supported++;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (!missingError(error) && !unsupportedError(error))
|
|
137
|
+
failures++;
|
|
138
|
+
reasons.push(`${resource}: ${errorReason(error)}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
sample.state =
|
|
142
|
+
supported === 3
|
|
143
|
+
? "supported"
|
|
144
|
+
: supported > 0
|
|
145
|
+
? "partial"
|
|
146
|
+
: failures > 0
|
|
147
|
+
? "error"
|
|
148
|
+
: "unsupported";
|
|
149
|
+
if (reasons.length > 0)
|
|
150
|
+
sample.reason = reasons.join("; ");
|
|
151
|
+
return sample;
|
|
152
|
+
}
|
|
153
|
+
function parsePressure(source, kind) {
|
|
154
|
+
const lines = source
|
|
155
|
+
.trim()
|
|
156
|
+
.split(/\r?\n/)
|
|
157
|
+
.filter((line) => line.startsWith(`${kind} `));
|
|
158
|
+
if (lines.length !== 1)
|
|
159
|
+
throw new Error(`Malformed PSI: expected one ${kind} row.`);
|
|
160
|
+
const fields = new Map();
|
|
161
|
+
for (const token of lines[0].trim().split(/\s+/).slice(1)) {
|
|
162
|
+
const [name, value, extra] = token.split("=");
|
|
163
|
+
if (!name || !value || extra !== undefined || fields.has(name))
|
|
164
|
+
throw new Error("Malformed PSI fields.");
|
|
165
|
+
fields.set(name, value);
|
|
166
|
+
}
|
|
167
|
+
const values = ["avg10", "avg60", "avg300"].map((name) => {
|
|
168
|
+
const raw = fields.get(name);
|
|
169
|
+
const value = Number(raw);
|
|
170
|
+
if (!raw || !/^\d+(?:\.\d+)?$/.test(raw) || !Number.isFinite(value) || value > 100) {
|
|
171
|
+
throw new Error(`Malformed PSI ${name}.`);
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
});
|
|
175
|
+
if (!/^\d+$/.test(fields.get("total") ?? ""))
|
|
176
|
+
throw new Error("Malformed PSI total.");
|
|
177
|
+
return { avg10: values[0], avg60: values[1], avg300: values[2] };
|
|
178
|
+
}
|
|
179
|
+
function collectOom(procRoot, now, key) {
|
|
180
|
+
try {
|
|
181
|
+
const rows = readBounded(join(procRoot, "vmstat"), 65_536)
|
|
182
|
+
.split(/\r?\n/)
|
|
183
|
+
.filter((line) => /^oom_kill\s/.test(line));
|
|
184
|
+
if (rows.length === 0) {
|
|
185
|
+
oomBaselines.delete(key);
|
|
186
|
+
return {
|
|
187
|
+
state: "unsupported",
|
|
188
|
+
total_kills: null,
|
|
189
|
+
kills_since_last_sample: null,
|
|
190
|
+
last_kill_age_ms: null,
|
|
191
|
+
reason: "Kernel does not expose oom_kill.",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const match = rows.length === 1 ? /^oom_kill\s+(\d+)\s*$/.exec(rows[0]) : null;
|
|
195
|
+
const kills = match ? Number(match[1]) : NaN;
|
|
196
|
+
if (!Number.isSafeInteger(kills) || kills < 0 || !Number.isFinite(now))
|
|
197
|
+
throw new Error("Malformed OOM kill counter or sample time.");
|
|
198
|
+
const previous = oomBaselines.get(key);
|
|
199
|
+
const consecutive = previous && now > previous.sampledAt && kills >= previous.kills;
|
|
200
|
+
const delta = consecutive ? kills - previous.kills : null;
|
|
201
|
+
const lastKillAt = delta !== null && delta > 0 ? now : consecutive ? previous.lastKillAt : null;
|
|
202
|
+
oomBaselines.delete(key);
|
|
203
|
+
oomBaselines.set(key, { sampledAt: now, kills, lastKillAt });
|
|
204
|
+
if (oomBaselines.size > MAX_BASELINES)
|
|
205
|
+
oomBaselines.delete(oomBaselines.keys().next().value);
|
|
206
|
+
return {
|
|
207
|
+
state: "supported",
|
|
208
|
+
total_kills: kills,
|
|
209
|
+
kills_since_last_sample: delta,
|
|
210
|
+
last_kill_age_ms: lastKillAt === null ? null : now - lastKillAt,
|
|
211
|
+
...(delta === null
|
|
212
|
+
? { reason: "Recent OOM kills need two consecutive counters; baseline started." }
|
|
213
|
+
: {}),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
oomBaselines.delete(key);
|
|
218
|
+
return {
|
|
219
|
+
state: missingError(error) || unsupportedError(error) ? "unsupported" : "error",
|
|
220
|
+
total_kills: null,
|
|
221
|
+
kills_since_last_sample: null,
|
|
222
|
+
last_kill_age_ms: null,
|
|
223
|
+
reason: errorReason(error),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Read the kernel reclaim counters and turn them into per-second rates. Only a
|
|
229
|
+
* pair of consecutive reads can express a rate, so the first read after a
|
|
230
|
+
* start, a restart, a stalled clock, or a counter reset reports
|
|
231
|
+
* `counters_reset` with null rates instead of inventing a baseline.
|
|
232
|
+
*/
|
|
233
|
+
function collectVmstat(procRoot, now, key) {
|
|
234
|
+
try {
|
|
235
|
+
if (!Number.isFinite(now))
|
|
236
|
+
throw new Error("Malformed reclaim sample time.");
|
|
237
|
+
const counters = parseVmstatCounters(readBounded(join(procRoot, "vmstat"), 65_536));
|
|
238
|
+
const missing = VMSTAT_COUNTERS.filter((name) => counters[name] === null);
|
|
239
|
+
if (missing.length === VMSTAT_COUNTERS.length) {
|
|
240
|
+
vmstatBaselines.delete(key);
|
|
241
|
+
return unavailableVmstat("unsupported", "Kernel does not expose the memory reclaim counters.", false);
|
|
242
|
+
}
|
|
243
|
+
const state = missing.length > 0 ? "partial" : "supported";
|
|
244
|
+
const partialReason = missing.length > 0 ? `Kernel does not expose ${missing.join(", ")}.` : undefined;
|
|
245
|
+
const previous = vmstatBaselines.get(key);
|
|
246
|
+
vmstatBaselines.delete(key);
|
|
247
|
+
vmstatBaselines.set(key, { sampledAt: now, counters });
|
|
248
|
+
if (vmstatBaselines.size > MAX_BASELINES)
|
|
249
|
+
vmstatBaselines.delete(vmstatBaselines.keys().next().value);
|
|
250
|
+
const elapsedSeconds = previous ? (now - previous.sampledAt) / 1_000 : 0;
|
|
251
|
+
if (!previous || !Number.isFinite(elapsedSeconds) || elapsedSeconds <= 0) {
|
|
252
|
+
return unavailableVmstat(state, joinReasons(partialReason, previous
|
|
253
|
+
? "The reclaim sample interval did not advance, so a new baseline started."
|
|
254
|
+
: "Reclaim rates need two consecutive counters, so a baseline started."));
|
|
255
|
+
}
|
|
256
|
+
const decreased = VMSTAT_COUNTERS.some((name) => {
|
|
257
|
+
const current = counters[name];
|
|
258
|
+
const last = previous.counters[name];
|
|
259
|
+
return current !== null && last !== null && current < last;
|
|
260
|
+
});
|
|
261
|
+
if (decreased) {
|
|
262
|
+
return unavailableVmstat(state, joinReasons(partialReason, "Kernel reclaim counters decreased, so a new baseline started."));
|
|
263
|
+
}
|
|
264
|
+
const perSecond = (name) => {
|
|
265
|
+
const current = counters[name];
|
|
266
|
+
const last = previous.counters[name];
|
|
267
|
+
if (current === null || last === null)
|
|
268
|
+
return null;
|
|
269
|
+
return (current - last) / elapsedSeconds;
|
|
270
|
+
};
|
|
271
|
+
const swapIn = perSecond("pswpin");
|
|
272
|
+
const swapOut = perSecond("pswpout");
|
|
273
|
+
return {
|
|
274
|
+
state,
|
|
275
|
+
swap_in_bytes_per_second: swapIn === null ? null : round(swapIn * VMSTAT_PAGE_SIZE_BYTES),
|
|
276
|
+
swap_out_bytes_per_second: swapOut === null ? null : round(swapOut * VMSTAT_PAGE_SIZE_BYTES),
|
|
277
|
+
direct_reclaim_pages_per_second: nullableRound(perSecond("pgscan_direct")),
|
|
278
|
+
major_faults_per_second: nullableRound(perSecond("pgmajfault")),
|
|
279
|
+
counters_reset: false,
|
|
280
|
+
...(partialReason ? { reason: partialReason } : {}),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
vmstatBaselines.delete(key);
|
|
285
|
+
return unavailableVmstat(missingError(error) || unsupportedError(error) ? "unsupported" : "error", errorReason(error), false);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function parseVmstatCounters(source) {
|
|
289
|
+
const counters = {
|
|
290
|
+
pswpin: null,
|
|
291
|
+
pswpout: null,
|
|
292
|
+
pgscan_direct: null,
|
|
293
|
+
pgmajfault: null,
|
|
294
|
+
};
|
|
295
|
+
for (const name of VMSTAT_COUNTERS) {
|
|
296
|
+
// Anchor on whitespace so pgscan_direct never absorbs pgscan_direct_throttle.
|
|
297
|
+
const rows = source.split(/\r?\n/).filter((line) => line.startsWith(`${name} `));
|
|
298
|
+
if (rows.length === 0)
|
|
299
|
+
continue;
|
|
300
|
+
if (rows.length > 1)
|
|
301
|
+
throw new Error(`Duplicate vmstat row for ${name}.`);
|
|
302
|
+
const match = new RegExp(`^${name}\\s+(\\d+)\\s*$`).exec(rows[0]);
|
|
303
|
+
const value = match ? Number(match[1]) : NaN;
|
|
304
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
305
|
+
throw new Error(`Malformed vmstat counter for ${name}.`);
|
|
306
|
+
counters[name] = value;
|
|
307
|
+
}
|
|
308
|
+
return counters;
|
|
309
|
+
}
|
|
310
|
+
function unavailableVmstat(state, reason, countersReset = true) {
|
|
311
|
+
return {
|
|
312
|
+
state,
|
|
313
|
+
swap_in_bytes_per_second: null,
|
|
314
|
+
swap_out_bytes_per_second: null,
|
|
315
|
+
direct_reclaim_pages_per_second: null,
|
|
316
|
+
major_faults_per_second: null,
|
|
317
|
+
counters_reset: countersReset,
|
|
318
|
+
reason,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function joinReasons(...parts) {
|
|
322
|
+
return parts.filter((part) => Boolean(part)).join(" ");
|
|
323
|
+
}
|
|
324
|
+
function collectIo(procRoot, sysRoot, now, key) {
|
|
325
|
+
try {
|
|
326
|
+
const devices = readIoCounters(procRoot, sysRoot);
|
|
327
|
+
const previous = ioBaselines.get(key);
|
|
328
|
+
ioBaselines.delete(key);
|
|
329
|
+
ioBaselines.set(key, { sampledAt: now, devices });
|
|
330
|
+
if (ioBaselines.size > MAX_BASELINES)
|
|
331
|
+
ioBaselines.delete(ioBaselines.keys().next().value);
|
|
332
|
+
if (!previous)
|
|
333
|
+
return unavailableIo("supported", "Disk I/O rates need two samples.");
|
|
334
|
+
const elapsed = (now - previous.sampledAt) / 1_000;
|
|
335
|
+
if (!Number.isFinite(elapsed) || elapsed <= 0)
|
|
336
|
+
return unavailableIo("supported", "Disk I/O sample interval did not advance.");
|
|
337
|
+
if (devices.size !== previous.devices.size)
|
|
338
|
+
return unavailableIo("supported", "Block devices changed; disk I/O baseline restarted.");
|
|
339
|
+
let read = 0;
|
|
340
|
+
let write = 0;
|
|
341
|
+
for (const [id, current] of devices) {
|
|
342
|
+
const last = previous.devices.get(id);
|
|
343
|
+
if (!last || current.read < last.read || current.write < last.write) {
|
|
344
|
+
return unavailableIo("supported", "Block device counters reset or devices changed; disk I/O baseline restarted.");
|
|
345
|
+
}
|
|
346
|
+
read += current.read - last.read;
|
|
347
|
+
write += current.write - last.write;
|
|
348
|
+
}
|
|
349
|
+
// Linux diskstats sectors are always 512 bytes, independent of device block size.
|
|
350
|
+
return {
|
|
351
|
+
state: "supported",
|
|
352
|
+
read_bytes_per_second: round((read * 512) / elapsed),
|
|
353
|
+
write_bytes_per_second: round((write * 512) / elapsed),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
ioBaselines.delete(key);
|
|
358
|
+
return unavailableIo(missingError(error) || unsupportedError(error) ? "unsupported" : "error", errorReason(error));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function readIoCounters(procRoot, sysRoot) {
|
|
362
|
+
const entries = readdirSync(join(sysRoot, "block"));
|
|
363
|
+
if (entries.length > MAX_BLOCK_DEVICES)
|
|
364
|
+
throw new Error("Block device inventory exceeds the collector limit.");
|
|
365
|
+
const selected = new Set();
|
|
366
|
+
for (const device of entries) {
|
|
367
|
+
// Whole devices only. Exclude memory-backed disks and stacked devices so
|
|
368
|
+
// device-mapper/RAID activity is counted once, at the underlying disks.
|
|
369
|
+
if (/^(?:loop|ram|zram)\d+$/.test(device))
|
|
370
|
+
continue;
|
|
371
|
+
if (readdirSync(join(sysRoot, "block", device, "slaves")).length > 0)
|
|
372
|
+
continue;
|
|
373
|
+
selected.add(device);
|
|
374
|
+
}
|
|
375
|
+
if (selected.size === 0)
|
|
376
|
+
throw Object.assign(new Error("No underlying block devices are visible."), { code: "ENOTSUP" });
|
|
377
|
+
const results = new Map();
|
|
378
|
+
for (const line of readBounded(join(procRoot, "diskstats"), 1_048_576).trim().split(/\r?\n/)) {
|
|
379
|
+
const fields = line.trim().split(/\s+/);
|
|
380
|
+
const device = fields[2];
|
|
381
|
+
if (!device || !selected.has(device))
|
|
382
|
+
continue;
|
|
383
|
+
if (fields.length < 14 ||
|
|
384
|
+
![...fields.slice(0, 2), ...fields.slice(3)].every((value) => /^\d+$/.test(value))) {
|
|
385
|
+
throw new Error(`Malformed diskstats for ${device}.`);
|
|
386
|
+
}
|
|
387
|
+
const read = Number(fields[5]);
|
|
388
|
+
const write = Number(fields[9]);
|
|
389
|
+
if (![read, write].every(Number.isSafeInteger))
|
|
390
|
+
throw new Error(`Invalid diskstats counters for ${device}.`);
|
|
391
|
+
const id = `${fields[0]}:${fields[1]}:${device}`;
|
|
392
|
+
if (results.has(id))
|
|
393
|
+
throw new Error(`Duplicate diskstats for ${device}.`);
|
|
394
|
+
results.set(id, { read, write });
|
|
395
|
+
}
|
|
396
|
+
if (results.size !== selected.size)
|
|
397
|
+
throw new Error("Block device inventory changed while collecting diskstats.");
|
|
398
|
+
return results;
|
|
399
|
+
}
|
|
400
|
+
function readBounded(path, limit) {
|
|
401
|
+
const fd = openSync(path, "r");
|
|
402
|
+
try {
|
|
403
|
+
const buffer = Buffer.alloc(limit + 1);
|
|
404
|
+
let offset = 0;
|
|
405
|
+
while (offset < buffer.length) {
|
|
406
|
+
const count = readSync(fd, buffer, offset, buffer.length - offset, null);
|
|
407
|
+
if (count === 0)
|
|
408
|
+
break;
|
|
409
|
+
offset += count;
|
|
410
|
+
}
|
|
411
|
+
if (offset > limit)
|
|
412
|
+
throw new Error("Resource counter file exceeds the collector limit.");
|
|
413
|
+
return buffer.toString("utf8", 0, offset);
|
|
414
|
+
}
|
|
415
|
+
finally {
|
|
416
|
+
closeSync(fd);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function errorCode(error) {
|
|
420
|
+
return error && typeof error === "object" && "code" in error ? String(error.code) : undefined;
|
|
421
|
+
}
|
|
422
|
+
function missingError(error) {
|
|
423
|
+
return ["ENOENT", "ENOTDIR"].includes(errorCode(error) ?? "");
|
|
424
|
+
}
|
|
425
|
+
function unsupportedError(error) {
|
|
426
|
+
return ["ENOSYS", "ENOTSUP", "EOPNOTSUPP"].includes(errorCode(error) ?? "");
|
|
427
|
+
}
|
|
428
|
+
function errorReason(error) {
|
|
429
|
+
return (errorCode(error) ?? (error instanceof Error ? error.message : "Resource collection failed."));
|
|
430
|
+
}
|
|
431
|
+
function unavailableIo(state, reason) {
|
|
432
|
+
return { state, read_bytes_per_second: null, write_bytes_per_second: null, reason };
|
|
433
|
+
}
|
|
434
|
+
function round(value) {
|
|
435
|
+
return Math.round(value * 100) / 100;
|
|
436
|
+
}
|
|
437
|
+
function nullableRound(value) {
|
|
438
|
+
return value === null ? null : round(value);
|
|
439
|
+
}
|
|
@@ -164,7 +164,7 @@ export declare const SemanticEvidenceV1Schema: import("@sinclair/typebox").TObje
|
|
|
164
164
|
evidence_contract_version: import("@sinclair/typebox").TLiteral<1>;
|
|
165
165
|
instance_id: import("@sinclair/typebox").TString;
|
|
166
166
|
generation_id: import("@sinclair/typebox").TString;
|
|
167
|
-
source_harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
167
|
+
source_harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
168
168
|
source: import("@sinclair/typebox").TObject<{
|
|
169
169
|
ledger_genesis_id: import("@sinclair/typebox").TString;
|
|
170
170
|
observed_through_event_id: import("@sinclair/typebox").TString;
|
|
@@ -403,7 +403,7 @@ export declare const SemanticAcceptedReadModelV2Schema: import("@sinclair/typebo
|
|
|
403
403
|
reader: import("@sinclair/typebox").TObject<{
|
|
404
404
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
405
405
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
406
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
406
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
407
407
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
408
408
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
409
409
|
}>;
|
|
@@ -536,13 +536,13 @@ export declare const SemanticAcceptedReadModelV2Schema: import("@sinclair/typebo
|
|
|
536
536
|
export declare const SemanticUnavailableReadModelV2Schema: import("@sinclair/typebox").TObject<{
|
|
537
537
|
reader_outcome: import("@sinclair/typebox").TLiteral<"unavailable">;
|
|
538
538
|
reader: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
539
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
539
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
540
540
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
541
541
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
542
542
|
}>, import("@sinclair/typebox").TObject<{
|
|
543
543
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
544
544
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
545
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
545
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
546
546
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
547
547
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
548
548
|
}>]>;
|
|
@@ -622,7 +622,7 @@ export declare const SemanticInvalidReadModelV2Schema: import("@sinclair/typebox
|
|
|
622
622
|
reader: import("@sinclair/typebox").TObject<{
|
|
623
623
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
624
624
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
625
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
625
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
626
626
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
627
627
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
628
628
|
}>;
|
|
@@ -701,13 +701,13 @@ export declare const SemanticInvalidReadModelV2Schema: import("@sinclair/typebox
|
|
|
701
701
|
export declare const SemanticDeferredReadModelV2Schema: import("@sinclair/typebox").TObject<{
|
|
702
702
|
reader_outcome: import("@sinclair/typebox").TLiteral<"deferred">;
|
|
703
703
|
reader: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
704
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
704
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
705
705
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
706
706
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
707
707
|
}>, import("@sinclair/typebox").TObject<{
|
|
708
708
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
709
709
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
710
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
710
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
711
711
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
712
712
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
713
713
|
}>]>;
|
|
@@ -731,7 +731,7 @@ export declare const SemanticAgentReadModelV2Schema: import("@sinclair/typebox")
|
|
|
731
731
|
reader: import("@sinclair/typebox").TObject<{
|
|
732
732
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
733
733
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
734
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
734
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
735
735
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
736
736
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
737
737
|
}>;
|
|
@@ -863,13 +863,13 @@ export declare const SemanticAgentReadModelV2Schema: import("@sinclair/typebox")
|
|
|
863
863
|
}>, import("@sinclair/typebox").TObject<{
|
|
864
864
|
reader_outcome: import("@sinclair/typebox").TLiteral<"unavailable">;
|
|
865
865
|
reader: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
866
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
866
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
867
867
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
868
868
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
869
869
|
}>, import("@sinclair/typebox").TObject<{
|
|
870
870
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
871
871
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
872
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
872
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
873
873
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
874
874
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
875
875
|
}>]>;
|
|
@@ -948,7 +948,7 @@ export declare const SemanticAgentReadModelV2Schema: import("@sinclair/typebox")
|
|
|
948
948
|
reader: import("@sinclair/typebox").TObject<{
|
|
949
949
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
950
950
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
951
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
951
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
952
952
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
953
953
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
954
954
|
}>;
|
|
@@ -1026,13 +1026,13 @@ export declare const SemanticAgentReadModelV2Schema: import("@sinclair/typebox")
|
|
|
1026
1026
|
}>, import("@sinclair/typebox").TObject<{
|
|
1027
1027
|
reader_outcome: import("@sinclair/typebox").TLiteral<"deferred">;
|
|
1028
1028
|
reader: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
1029
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
1029
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
1030
1030
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
1031
1031
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
1032
1032
|
}>, import("@sinclair/typebox").TObject<{
|
|
1033
1033
|
resolved_model_id: import("@sinclair/typebox").TString;
|
|
1034
1034
|
model_attestation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified">, import("@sinclair/typebox").TLiteral<"requested-only">]>;
|
|
1035
|
-
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"
|
|
1035
|
+
harness: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"claude-code" | "cursor" | "codex">[]>;
|
|
1036
1036
|
configured_model: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"haiku-4.5" | "gpt-5.6-luna" | "composer-2.5">[]>;
|
|
1037
1037
|
prompt_contract_version: import("@sinclair/typebox").TLiteral<4>;
|
|
1038
1038
|
}>]>;
|
|
@@ -5,11 +5,13 @@ export { readSemanticServiceStatus, SEMANTIC_SERVICE_STATUS_SCHEMA_VERSION, type
|
|
|
5
5
|
export declare const SEMANTIC_SERVICE_DEFAULT_DEBOUNCE_MS = 5000;
|
|
6
6
|
export declare const SEMANTIC_SERVICE_DEFAULT_WAKE_MS = 1000;
|
|
7
7
|
export declare const SEMANTIC_SERVICE_DEFAULT_HEARTBEAT_MS = 5000;
|
|
8
|
+
export declare const SEMANTIC_SERVICE_DEFAULT_IDLE_WAKE_MAX_MS = 30000;
|
|
8
9
|
export interface RunSemanticServiceDaemonInput {
|
|
9
10
|
coordRoot: string;
|
|
10
11
|
callsPerHour?: number;
|
|
11
12
|
debounceMs?: number;
|
|
12
13
|
wakeIntervalMs?: number;
|
|
14
|
+
idleWakeMaxMs?: number;
|
|
13
15
|
heartbeatIntervalMs?: number;
|
|
14
16
|
maxSweeps?: number;
|
|
15
17
|
now?: () => Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/core/semantic/service.ts"],"names":[],"mappings":"AAoBA,OAAO,EAGL,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAC;AAc7B,OAAO,EACL,yBAAyB,EACzB,sCAAsC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,oCAAoC,OAAQ,CAAC;AAC1D,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AACtD,eAAO,MAAM,qCAAqC,OAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/core/semantic/service.ts"],"names":[],"mappings":"AAoBA,OAAO,EAGL,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAC;AAc7B,OAAO,EACL,yBAAyB,EACzB,sCAAsC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,oCAAoC,OAAQ,CAAC;AAC1D,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AACtD,eAAO,MAAM,qCAAqC,OAAQ,CAAC;AAK3D,eAAO,MAAM,yCAAyC,QAAS,CAAC;AA2BhE,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,iBAAiB,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,OAAO,CAAC;KAC3B,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAED,MAAM,MAAM,0BAA0B,GAClC,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,aAAa,CAAC;AAElB,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,0BAA0B,CAAC;IAClC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iCAAiC;IAChD,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,qBAAqB,CAAC;IACzD,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC7D,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C;AAED,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GACtC,OAAO,CAAC,qBAAqB,CAAC,CAgDhC;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,OAAO,CAAC,iCAAiC,CAAM,GACzD,OAAO,CAAC,2BAA2B,CAAC,CAsBtC;AAED,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,qBAAqB,CAgBtF;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CA8MtC;AAED,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,IAAI,CAuC5E;AAmID,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,QAAQ,GAAG,QAAQ,CAerB"}
|