sensorium-mcp 3.1.2 → 3.1.3-board.10
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/Install-Sensorium.ps1 +257 -43
- package/README.md +2 -0
- package/dist/board/api/api.js +84 -0
- package/dist/board/api/api.test.ts +23 -0
- package/dist/board/api/client.js +113 -0
- package/dist/board/components/BottomNav.js +32 -0
- package/dist/board/components/Card.js +78 -0
- package/dist/board/components/Combobox.js +79 -0
- package/dist/board/components/CommentComposer.js +29 -0
- package/dist/board/components/CommentList.js +42 -0
- package/dist/board/components/DirTreePicker.js +128 -0
- package/dist/board/components/Dropdown.js +67 -0
- package/dist/board/components/Lane.js +47 -0
- package/dist/board/components/PriorityChip.js +20 -0
- package/dist/board/components/ProfileSummary.js +89 -0
- package/dist/board/components/StateBanner.js +24 -0
- package/dist/board/components/StatusChip.js +26 -0
- package/dist/board/components/rateLimit.js +32 -0
- package/dist/board/components/rateLimit.test.ts +16 -0
- package/dist/board/components/time.js +14 -0
- package/dist/board/config.js +56 -0
- package/dist/board/index.html +18 -0
- package/dist/board/main.js +37 -0
- package/dist/board/mock/api.mock.js +491 -0
- package/dist/board/mock/api.mock.test.ts +460 -0
- package/dist/board/mock/fixtures.js +512 -0
- package/dist/board/schema/policy.js +261 -0
- package/dist/board/state/recur.js +24 -0
- package/dist/board/state/recur.test.ts +24 -0
- package/dist/board/state/useBoard.js +161 -0
- package/dist/board/state/useBuilder.js +357 -0
- package/dist/board/state/useBuilder.test.ts +468 -0
- package/dist/board/state/useCard.js +193 -0
- package/dist/board/state/useCard.test.ts +435 -0
- package/dist/board/state/useDirBrowser.js +23 -0
- package/dist/board/styles/board.css +2885 -0
- package/dist/board/styles/tokens.css +72 -0
- package/dist/board/vendor/vue.esm-browser.js +9 -0
- package/dist/board/views/App.js +61 -0
- package/dist/board/views/BoardView.js +153 -0
- package/dist/board/views/BuilderView.js +582 -0
- package/dist/board/views/CardView.js +382 -0
- package/dist/board/views/SettingsView.js +152 -0
- package/dist/config/agent-settings.d.ts +11 -0
- package/dist/config/agent-settings.d.ts.map +1 -1
- package/dist/config/agent-settings.js +79 -0
- package/dist/config/agent-settings.js.map +1 -1
- package/dist/config/detail-grant.d.ts +7 -16
- package/dist/config/detail-grant.d.ts.map +1 -1
- package/dist/config/detail-grant.js +12 -35
- package/dist/config/detail-grant.js.map +1 -1
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +17 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/mcp-settings.d.ts +7 -1
- package/dist/config/mcp-settings.d.ts.map +1 -1
- package/dist/config/mcp-settings.js +9 -0
- package/dist/config/mcp-settings.js.map +1 -1
- package/dist/config/misc-settings.d.ts +22 -1
- package/dist/config/misc-settings.d.ts.map +1 -1
- package/dist/config/misc-settings.js +93 -3
- package/dist/config/misc-settings.js.map +1 -1
- package/dist/config/operator-grant.d.ts +9 -0
- package/dist/config/operator-grant.d.ts.map +1 -0
- package/dist/config/operator-grant.js +24 -0
- package/dist/config/operator-grant.js.map +1 -0
- package/dist/config/voice-grant.d.ts +10 -0
- package/dist/config/voice-grant.d.ts.map +1 -0
- package/dist/config/voice-grant.js +18 -0
- package/dist/config/voice-grant.js.map +1 -0
- package/dist/dashboard/board-static.d.ts +22 -0
- package/dist/dashboard/board-static.d.ts.map +1 -0
- package/dist/dashboard/board-static.js +130 -0
- package/dist/dashboard/board-static.js.map +1 -0
- package/dist/dashboard/presets.d.ts +1 -1
- package/dist/dashboard/presets.d.ts.map +1 -1
- package/dist/dashboard/presets.js +1 -1
- package/dist/dashboard/presets.js.map +1 -1
- package/dist/dashboard/routes/agent-templates.d.ts.map +1 -1
- package/dist/dashboard/routes/agent-templates.js +6 -9
- package/dist/dashboard/routes/agent-templates.js.map +1 -1
- package/dist/dashboard/routes/board-body.d.ts +8 -0
- package/dist/dashboard/routes/board-body.d.ts.map +1 -0
- package/dist/dashboard/routes/board-body.js +20 -0
- package/dist/dashboard/routes/board-body.js.map +1 -0
- package/dist/dashboard/routes/board-dir-listing.d.ts +70 -0
- package/dist/dashboard/routes/board-dir-listing.d.ts.map +1 -0
- package/dist/dashboard/routes/board-dir-listing.js +192 -0
- package/dist/dashboard/routes/board-dir-listing.js.map +1 -0
- package/dist/dashboard/routes/board-lane-groups.d.ts +6 -0
- package/dist/dashboard/routes/board-lane-groups.d.ts.map +1 -0
- package/dist/dashboard/routes/board-lane-groups.js +52 -0
- package/dist/dashboard/routes/board-lane-groups.js.map +1 -0
- package/dist/dashboard/routes/board-policy.d.ts +224 -0
- package/dist/dashboard/routes/board-policy.d.ts.map +1 -0
- package/dist/dashboard/routes/board-policy.js +214 -0
- package/dist/dashboard/routes/board-policy.js.map +1 -0
- package/dist/dashboard/routes/board-profile-parse.d.ts +32 -0
- package/dist/dashboard/routes/board-profile-parse.d.ts.map +1 -0
- package/dist/dashboard/routes/board-profile-parse.js +338 -0
- package/dist/dashboard/routes/board-profile-parse.js.map +1 -0
- package/dist/dashboard/routes/board.d.ts +90 -0
- package/dist/dashboard/routes/board.d.ts.map +1 -0
- package/dist/dashboard/routes/board.js +721 -0
- package/dist/dashboard/routes/board.js.map +1 -0
- package/dist/dashboard/routes/codex.d.ts +14 -0
- package/dist/dashboard/routes/codex.d.ts.map +1 -0
- package/dist/dashboard/routes/codex.js +92 -0
- package/dist/dashboard/routes/codex.js.map +1 -0
- package/dist/dashboard/routes/prompts.d.ts +2 -2
- package/dist/dashboard/routes/prompts.d.ts.map +1 -1
- package/dist/dashboard/routes/prompts.js +2 -2
- package/dist/dashboard/routes/prompts.js.map +1 -1
- package/dist/dashboard/routes/settings.d.ts +2 -0
- package/dist/dashboard/routes/settings.d.ts.map +1 -1
- package/dist/dashboard/routes/settings.js +24 -1
- package/dist/dashboard/routes/settings.js.map +1 -1
- package/dist/dashboard/routes/skills.d.ts +7 -1
- package/dist/dashboard/routes/skills.d.ts.map +1 -1
- package/dist/dashboard/routes/skills.js +6 -6
- package/dist/dashboard/routes/skills.js.map +1 -1
- package/dist/dashboard/routes/snapshots.d.ts +2 -1
- package/dist/dashboard/routes/snapshots.d.ts.map +1 -1
- package/dist/dashboard/routes/snapshots.js +24 -18
- package/dist/dashboard/routes/snapshots.js.map +1 -1
- package/dist/dashboard/routes/templates.js +5 -5
- package/dist/dashboard/routes/templates.js.map +1 -1
- package/dist/dashboard/routes/threads-create.d.ts +17 -0
- package/dist/dashboard/routes/threads-create.d.ts.map +1 -1
- package/dist/dashboard/routes/threads-create.js +32 -10
- package/dist/dashboard/routes/threads-create.js.map +1 -1
- package/dist/dashboard/routes/threads-helpers.d.ts +11 -2
- package/dist/dashboard/routes/threads-helpers.d.ts.map +1 -1
- package/dist/dashboard/routes/threads-helpers.js +20 -3
- package/dist/dashboard/routes/threads-helpers.js.map +1 -1
- package/dist/dashboard/routes/threads-read.d.ts +16 -4
- package/dist/dashboard/routes/threads-read.d.ts.map +1 -1
- package/dist/dashboard/routes/threads-read.js +61 -55
- package/dist/dashboard/routes/threads-read.js.map +1 -1
- package/dist/dashboard/routes/threads.d.ts +2 -2
- package/dist/dashboard/routes/threads.d.ts.map +1 -1
- package/dist/dashboard/routes/threads.js +143 -29
- package/dist/dashboard/routes/threads.js.map +1 -1
- package/dist/dashboard/routes/types.d.ts +6 -0
- package/dist/dashboard/routes/types.d.ts.map +1 -1
- package/dist/dashboard/routes/types.js.map +1 -1
- package/dist/dashboard/routes.d.ts +2 -2
- package/dist/dashboard/routes.d.ts.map +1 -1
- package/dist/dashboard/routes.js +85 -7
- package/dist/dashboard/routes.js.map +1 -1
- package/dist/dashboard/spa.html +15 -12
- package/dist/data/board/board-schema.d.ts +29 -0
- package/dist/data/board/board-schema.d.ts.map +1 -0
- package/dist/data/board/board-schema.js +202 -0
- package/dist/data/board/board-schema.js.map +1 -0
- package/dist/data/board/board-types.d.ts +175 -0
- package/dist/data/board/board-types.d.ts.map +1 -0
- package/dist/data/board/board-types.js +9 -0
- package/dist/data/board/board-types.js.map +1 -0
- package/dist/data/board/card.repository.d.ts +137 -0
- package/dist/data/board/card.repository.d.ts.map +1 -0
- package/dist/data/board/card.repository.js +470 -0
- package/dist/data/board/card.repository.js.map +1 -0
- package/dist/data/board/comment.repository.d.ts +14 -0
- package/dist/data/board/comment.repository.d.ts.map +1 -0
- package/dist/data/board/comment.repository.js +42 -0
- package/dist/data/board/comment.repository.js.map +1 -0
- package/dist/data/board/lane-group.repository.d.ts +19 -0
- package/dist/data/board/lane-group.repository.d.ts.map +1 -0
- package/dist/data/board/lane-group.repository.js +66 -0
- package/dist/data/board/lane-group.repository.js.map +1 -0
- package/dist/data/board/profile-defaults.d.ts +17 -0
- package/dist/data/board/profile-defaults.d.ts.map +1 -0
- package/dist/data/board/profile-defaults.js +107 -0
- package/dist/data/board/profile-defaults.js.map +1 -0
- package/dist/data/interfaces.d.ts +1 -0
- package/dist/data/interfaces.d.ts.map +1 -1
- package/dist/data/memory/bootstrap.d.ts +1 -8
- package/dist/data/memory/bootstrap.d.ts.map +1 -1
- package/dist/data/memory/bootstrap.js +27 -37
- package/dist/data/memory/bootstrap.js.map +1 -1
- package/dist/data/memory/consolidation.d.ts +9 -31
- package/dist/data/memory/consolidation.d.ts.map +1 -1
- package/dist/data/memory/consolidation.js +22 -32
- package/dist/data/memory/consolidation.js.map +1 -1
- package/dist/data/memory/db-maintenance.d.ts +54 -0
- package/dist/data/memory/db-maintenance.d.ts.map +1 -0
- package/dist/data/memory/db-maintenance.js +81 -0
- package/dist/data/memory/db-maintenance.js.map +1 -0
- package/dist/data/memory/episodes.d.ts +2 -1
- package/dist/data/memory/episodes.d.ts.map +1 -1
- package/dist/data/memory/episodes.js +5 -1
- package/dist/data/memory/episodes.js.map +1 -1
- package/dist/data/memory/index.d.ts +0 -4
- package/dist/data/memory/index.d.ts.map +1 -1
- package/dist/data/memory/index.js +0 -4
- package/dist/data/memory/index.js.map +1 -1
- package/dist/data/memory/key-knowledge.d.ts +51 -0
- package/dist/data/memory/key-knowledge.d.ts.map +1 -0
- package/dist/data/memory/key-knowledge.js +128 -0
- package/dist/data/memory/key-knowledge.js.map +1 -0
- package/dist/data/memory/migration-runner.d.ts +1 -1
- package/dist/data/memory/migration-runner.d.ts.map +1 -1
- package/dist/data/memory/migration-runner.js +407 -1
- package/dist/data/memory/migration-runner.js.map +1 -1
- package/dist/data/memory/narrative-lint.d.ts +2 -2
- package/dist/data/memory/narrative-lint.d.ts.map +1 -1
- package/dist/data/memory/narrative-lint.js +23 -13
- package/dist/data/memory/narrative-lint.js.map +1 -1
- package/dist/data/memory/narrative-resolutions.d.ts +9 -2
- package/dist/data/memory/narrative-resolutions.d.ts.map +1 -1
- package/dist/data/memory/narrative-resolutions.js +9 -8
- package/dist/data/memory/narrative-resolutions.js.map +1 -1
- package/dist/data/memory/narrative-sources.d.ts +1 -1
- package/dist/data/memory/narrative-sources.d.ts.map +1 -1
- package/dist/data/memory/narrative-sources.js +8 -3
- package/dist/data/memory/narrative-sources.js.map +1 -1
- package/dist/data/memory/narrative-store.d.ts +24 -0
- package/dist/data/memory/narrative-store.d.ts.map +1 -1
- package/dist/data/memory/narrative-store.js +73 -35
- package/dist/data/memory/narrative-store.js.map +1 -1
- package/dist/data/memory/narrative.d.ts.map +1 -1
- package/dist/data/memory/narrative.js +47 -29
- package/dist/data/memory/narrative.js.map +1 -1
- package/dist/data/memory/note-archival.d.ts +1 -1
- package/dist/data/memory/note-archival.d.ts.map +1 -1
- package/dist/data/memory/note-archival.js +7 -3
- package/dist/data/memory/note-archival.js.map +1 -1
- package/dist/data/memory/note-embeddings.d.ts +7 -0
- package/dist/data/memory/note-embeddings.d.ts.map +1 -1
- package/dist/data/memory/note-embeddings.js +6 -2
- package/dist/data/memory/note-embeddings.js.map +1 -1
- package/dist/data/memory/passive-notice.repository.d.ts +70 -0
- package/dist/data/memory/passive-notice.repository.d.ts.map +1 -0
- package/dist/data/memory/passive-notice.repository.js +85 -0
- package/dist/data/memory/passive-notice.repository.js.map +1 -0
- package/dist/data/memory/schema-ddl.d.ts +120 -1
- package/dist/data/memory/schema-ddl.d.ts.map +1 -1
- package/dist/data/memory/schema-ddl.js +171 -4
- package/dist/data/memory/schema-ddl.js.map +1 -1
- package/dist/data/memory/schema-guard.d.ts.map +1 -1
- package/dist/data/memory/schema-guard.js +5 -41
- package/dist/data/memory/schema-guard.js.map +1 -1
- package/dist/data/memory/schema.d.ts.map +1 -1
- package/dist/data/memory/schema.js +10 -34
- package/dist/data/memory/schema.js.map +1 -1
- package/dist/data/memory/semantic-notes.d.ts +13 -8
- package/dist/data/memory/semantic-notes.d.ts.map +1 -1
- package/dist/data/memory/semantic-notes.js +12 -17
- package/dist/data/memory/semantic-notes.js.map +1 -1
- package/dist/data/memory/thread-registry.d.ts +330 -15
- package/dist/data/memory/thread-registry.d.ts.map +1 -1
- package/dist/data/memory/thread-registry.js +523 -67
- package/dist/data/memory/thread-registry.js.map +1 -1
- package/dist/data/memory/utils.d.ts +6 -0
- package/dist/data/memory/utils.d.ts.map +1 -1
- package/dist/data/memory/utils.js +13 -0
- package/dist/data/memory/utils.js.map +1 -1
- package/dist/data/memory/worker-lifecycle.repository.d.ts +308 -0
- package/dist/data/memory/worker-lifecycle.repository.d.ts.map +1 -0
- package/dist/data/memory/worker-lifecycle.repository.js +428 -0
- package/dist/data/memory/worker-lifecycle.repository.js.map +1 -0
- package/dist/data/optional.d.ts +16 -0
- package/dist/data/optional.d.ts.map +1 -0
- package/dist/data/optional.js +47 -0
- package/dist/data/optional.js.map +1 -0
- package/dist/index.js +156 -24
- package/dist/index.js.map +1 -1
- package/dist/integrations/openai/speech.d.ts.map +1 -1
- package/dist/integrations/openai/speech.js +52 -19
- package/dist/integrations/openai/speech.js.map +1 -1
- package/dist/integrations/openai/video.d.ts +1 -1
- package/dist/integrations/openai/video.d.ts.map +1 -1
- package/dist/integrations/openai/video.js +13 -8
- package/dist/integrations/openai/video.js.map +1 -1
- package/dist/integrations/telegram/types.d.ts +11 -0
- package/dist/integrations/telegram/types.d.ts.map +1 -1
- package/dist/lib/http-retry.d.ts +91 -0
- package/dist/lib/http-retry.d.ts.map +1 -0
- package/dist/lib/http-retry.js +177 -0
- package/dist/lib/http-retry.js.map +1 -0
- package/dist/lib/mcp-http-port.d.ts +12 -0
- package/dist/lib/mcp-http-port.d.ts.map +1 -0
- package/dist/lib/mcp-http-port.js +19 -0
- package/dist/lib/mcp-http-port.js.map +1 -0
- package/dist/lib/paths.d.ts +29 -4
- package/dist/lib/paths.d.ts.map +1 -1
- package/dist/lib/paths.js +31 -4
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/types.d.ts +2 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/usage-metering/pricing.js +1 -1
- package/dist/lib/usage-metering/pricing.js.map +1 -1
- package/dist/lib/usage-metering/sink.d.ts +4 -0
- package/dist/lib/usage-metering/sink.d.ts.map +1 -1
- package/dist/lib/usage-metering/sink.js +6 -4
- package/dist/lib/usage-metering/sink.js.map +1 -1
- package/dist/lib/utils.d.ts +31 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +49 -0
- package/dist/lib/utils.js.map +1 -1
- package/dist/llm/prompts/narrative.d.ts.map +1 -1
- package/dist/llm/prompts/narrative.js +27 -86
- package/dist/llm/prompts/narrative.js.map +1 -1
- package/dist/log-parsing/log-events.d.ts +38 -0
- package/dist/log-parsing/log-events.d.ts.map +1 -0
- package/dist/log-parsing/log-events.js +2 -0
- package/dist/log-parsing/log-events.js.map +1 -0
- package/dist/log-parsing/parser-registry.d.ts +4 -0
- package/dist/log-parsing/parser-registry.d.ts.map +1 -0
- package/dist/log-parsing/parser-registry.js +18 -0
- package/dist/log-parsing/parser-registry.js.map +1 -0
- package/dist/log-parsing/parsers/claude.d.ts +6 -0
- package/dist/log-parsing/parsers/claude.d.ts.map +1 -0
- package/dist/log-parsing/parsers/claude.js +100 -0
- package/dist/log-parsing/parsers/claude.js.map +1 -0
- package/dist/log-parsing/parsers/codex.d.ts +6 -0
- package/dist/log-parsing/parsers/codex.d.ts.map +1 -0
- package/dist/log-parsing/parsers/codex.js +116 -0
- package/dist/log-parsing/parsers/codex.js.map +1 -0
- package/dist/log-parsing/parsers/copilot.d.ts +6 -0
- package/dist/log-parsing/parsers/copilot.d.ts.map +1 -0
- package/dist/log-parsing/parsers/copilot.js +65 -0
- package/dist/log-parsing/parsers/copilot.js.map +1 -0
- package/dist/log-parsing/parsers/json-lines.d.ts +9 -0
- package/dist/log-parsing/parsers/json-lines.d.ts.map +1 -0
- package/dist/log-parsing/parsers/json-lines.js +25 -0
- package/dist/log-parsing/parsers/json-lines.js.map +1 -0
- package/dist/log-parsing/render.d.ts +33 -0
- package/dist/log-parsing/render.d.ts.map +1 -0
- package/dist/log-parsing/render.js +113 -0
- package/dist/log-parsing/render.js.map +1 -0
- package/dist/log-parsing/text.d.ts +8 -0
- package/dist/log-parsing/text.d.ts.map +1 -0
- package/dist/log-parsing/text.js +20 -0
- package/dist/log-parsing/text.js.map +1 -0
- package/dist/server/http-server.d.ts +8 -1
- package/dist/server/http-server.d.ts.map +1 -1
- package/dist/server/http-server.js +41 -19
- package/dist/server/http-server.js.map +1 -1
- package/dist/server/port-holder.d.ts +94 -0
- package/dist/server/port-holder.d.ts.map +1 -0
- package/dist/server/port-holder.js +122 -0
- package/dist/server/port-holder.js.map +1 -0
- package/dist/services/agent-spawn.service.d.ts +50 -5
- package/dist/services/agent-spawn.service.d.ts.map +1 -1
- package/dist/services/agent-spawn.service.js +59 -66
- package/dist/services/agent-spawn.service.js.map +1 -1
- package/dist/services/background-runner.d.ts +0 -1
- package/dist/services/background-runner.d.ts.map +1 -1
- package/dist/services/background-runner.js +0 -58
- package/dist/services/background-runner.js.map +1 -1
- package/dist/services/board/board-signals.d.ts +45 -0
- package/dist/services/board/board-signals.d.ts.map +1 -0
- package/dist/services/board/board-signals.js +170 -0
- package/dist/services/board/board-signals.js.map +1 -0
- package/dist/services/board/card-briefing.d.ts +24 -0
- package/dist/services/board/card-briefing.d.ts.map +1 -0
- package/dist/services/board/card-briefing.js +132 -0
- package/dist/services/board/card-briefing.js.map +1 -0
- package/dist/services/board/card-diagnostics.d.ts +25 -0
- package/dist/services/board/card-diagnostics.d.ts.map +1 -0
- package/dist/services/board/card-diagnostics.js +50 -0
- package/dist/services/board/card-diagnostics.js.map +1 -0
- package/dist/services/board/live-root-thread.d.ts +8 -0
- package/dist/services/board/live-root-thread.d.ts.map +1 -0
- package/dist/services/board/live-root-thread.js +2 -0
- package/dist/services/board/live-root-thread.js.map +1 -0
- package/dist/services/board/orchestrator.service.d.ts +119 -0
- package/dist/services/board/orchestrator.service.d.ts.map +1 -0
- package/dist/services/board/orchestrator.service.js +387 -0
- package/dist/services/board/orchestrator.service.js.map +1 -0
- package/dist/services/board/release-worker.d.ts +43 -0
- package/dist/services/board/release-worker.d.ts.map +1 -0
- package/dist/services/board/release-worker.js +96 -0
- package/dist/services/board/release-worker.js.map +1 -0
- package/dist/services/board/report-capture.d.ts +94 -0
- package/dist/services/board/report-capture.d.ts.map +1 -0
- package/dist/services/board/report-capture.js +398 -0
- package/dist/services/board/report-capture.js.map +1 -0
- package/dist/services/board/worker-spawn.d.ts +89 -0
- package/dist/services/board/worker-spawn.d.ts.map +1 -0
- package/dist/services/board/worker-spawn.js +177 -0
- package/dist/services/board/worker-spawn.js.map +1 -0
- package/dist/services/board/worktree.d.ts +45 -0
- package/dist/services/board/worktree.d.ts.map +1 -0
- package/dist/services/board/worktree.js +183 -0
- package/dist/services/board/worktree.js.map +1 -0
- package/dist/services/broker-client.d.ts +84 -2
- package/dist/services/broker-client.d.ts.map +1 -1
- package/dist/services/broker-client.js +72 -6
- package/dist/services/broker-client.js.map +1 -1
- package/dist/services/claude-spawn.service.d.ts +5 -0
- package/dist/services/claude-spawn.service.d.ts.map +1 -1
- package/dist/services/claude-spawn.service.js +37 -21
- package/dist/services/claude-spawn.service.js.map +1 -1
- package/dist/services/codex-spawn.service.d.ts +8 -3
- package/dist/services/codex-spawn.service.d.ts.map +1 -1
- package/dist/services/codex-spawn.service.js +84 -67
- package/dist/services/codex-spawn.service.js.map +1 -1
- package/dist/services/consolidation.service.d.ts.map +1 -1
- package/dist/services/consolidation.service.js +5 -49
- package/dist/services/consolidation.service.js.map +1 -1
- package/dist/services/copilot-spawn.service.d.ts +1 -1
- package/dist/services/copilot-spawn.service.d.ts.map +1 -1
- package/dist/services/copilot-spawn.service.js +10 -5
- package/dist/services/copilot-spawn.service.js.map +1 -1
- package/dist/services/daily-session.d.ts +24 -11
- package/dist/services/daily-session.d.ts.map +1 -1
- package/dist/services/daily-session.js +113 -33
- package/dist/services/daily-session.js.map +1 -1
- package/dist/services/death-alert.service.d.ts +55 -0
- package/dist/services/death-alert.service.d.ts.map +1 -0
- package/dist/services/death-alert.service.js +64 -0
- package/dist/services/death-alert.service.js.map +1 -0
- package/dist/services/dispatcher/broker.d.ts +66 -0
- package/dist/services/dispatcher/broker.d.ts.map +1 -1
- package/dist/services/dispatcher/broker.js +60 -52
- package/dist/services/dispatcher/broker.js.map +1 -1
- package/dist/services/dispatcher/poller.d.ts.map +1 -1
- package/dist/services/dispatcher/poller.js +31 -24
- package/dist/services/dispatcher/poller.js.map +1 -1
- package/dist/services/http-retry.d.ts +1 -90
- package/dist/services/http-retry.d.ts.map +1 -1
- package/dist/services/http-retry.js +1 -176
- package/dist/services/http-retry.js.map +1 -1
- package/dist/services/intent.d.ts +15 -1
- package/dist/services/intent.d.ts.map +1 -1
- package/dist/services/intent.js +39 -27
- package/dist/services/intent.js.map +1 -1
- package/dist/services/keeper.service.d.ts +76 -3
- package/dist/services/keeper.service.d.ts.map +1 -1
- package/dist/services/keeper.service.js +112 -35
- package/dist/services/keeper.service.js.map +1 -1
- package/dist/services/mcp-config.service.d.ts.map +1 -1
- package/dist/services/mcp-config.service.js +14 -1
- package/dist/services/mcp-config.service.js.map +1 -1
- package/dist/services/memory-briefing.service.d.ts +1 -1
- package/dist/services/memory-briefing.service.d.ts.map +1 -1
- package/dist/services/memory-briefing.service.js +28 -73
- package/dist/services/memory-briefing.service.js.map +1 -1
- package/dist/services/passive-notice.service.d.ts +56 -0
- package/dist/services/passive-notice.service.d.ts.map +1 -0
- package/dist/services/passive-notice.service.js +92 -0
- package/dist/services/passive-notice.service.js.map +1 -0
- package/dist/services/predefined-prompts.d.ts +11 -0
- package/dist/services/predefined-prompts.d.ts.map +1 -0
- package/dist/services/predefined-prompts.js +25 -0
- package/dist/services/predefined-prompts.js.map +1 -0
- package/dist/services/process.service.d.ts +111 -27
- package/dist/services/process.service.d.ts.map +1 -1
- package/dist/services/process.service.js +245 -173
- package/dist/services/process.service.js.map +1 -1
- package/dist/services/spawn-common.d.ts +281 -5
- package/dist/services/spawn-common.d.ts.map +1 -1
- package/dist/services/spawn-common.js +884 -188
- package/dist/services/spawn-common.js.map +1 -1
- package/dist/services/spawn-exit-watcher.d.ts +45 -35
- package/dist/services/spawn-exit-watcher.d.ts.map +1 -1
- package/dist/services/spawn-exit-watcher.js +120 -100
- package/dist/services/spawn-exit-watcher.js.map +1 -1
- package/dist/services/telegram.d.ts +31 -8
- package/dist/services/telegram.d.ts.map +1 -1
- package/dist/services/telegram.js +58 -26
- package/dist/services/telegram.js.map +1 -1
- package/dist/services/thread-health.service.d.ts +8 -0
- package/dist/services/thread-health.service.d.ts.map +1 -1
- package/dist/services/thread-health.service.js +14 -10
- package/dist/services/thread-health.service.js.map +1 -1
- package/dist/services/thread-lifecycle.service.d.ts +17 -1
- package/dist/services/thread-lifecycle.service.d.ts.map +1 -1
- package/dist/services/thread-lifecycle.service.js +47 -6
- package/dist/services/thread-lifecycle.service.js.map +1 -1
- package/dist/services/thread-log-reader.d.ts +81 -0
- package/dist/services/thread-log-reader.d.ts.map +1 -0
- package/dist/services/thread-log-reader.js +141 -0
- package/dist/services/thread-log-reader.js.map +1 -0
- package/dist/services/thread-purge.service.d.ts +200 -0
- package/dist/services/thread-purge.service.d.ts.map +1 -0
- package/dist/services/thread-purge.service.js +644 -0
- package/dist/services/thread-purge.service.js.map +1 -0
- package/dist/services/topic.service.d.ts +44 -2
- package/dist/services/topic.service.d.ts.map +1 -1
- package/dist/services/topic.service.js +74 -13
- package/dist/services/topic.service.js.map +1 -1
- package/dist/services/usage/usage-inbox-notifier.d.ts +50 -0
- package/dist/services/usage/usage-inbox-notifier.d.ts.map +1 -0
- package/dist/services/usage/usage-inbox-notifier.js +118 -0
- package/dist/services/usage/usage-inbox-notifier.js.map +1 -0
- package/dist/services/usage/usage-poller.service.d.ts +41 -0
- package/dist/services/usage/usage-poller.service.d.ts.map +1 -0
- package/dist/services/usage/usage-poller.service.js +67 -0
- package/dist/services/usage/usage-poller.service.js.map +1 -0
- package/dist/services/usage/usage-snapshot-provider.d.ts +40 -0
- package/dist/services/usage/usage-snapshot-provider.d.ts.map +1 -0
- package/dist/services/usage/usage-snapshot-provider.js +89 -0
- package/dist/services/usage/usage-snapshot-provider.js.map +1 -0
- package/dist/services/usage/usage-types.d.ts +28 -0
- package/dist/services/usage/usage-types.d.ts.map +1 -0
- package/dist/services/usage/usage-types.js +14 -0
- package/dist/services/usage/usage-types.js.map +1 -0
- package/dist/services/worker-birth.d.ts +154 -0
- package/dist/services/worker-birth.d.ts.map +1 -0
- package/dist/services/worker-birth.js +274 -0
- package/dist/services/worker-birth.js.map +1 -0
- package/dist/services/worker-cleanup.service.d.ts +242 -19
- package/dist/services/worker-cleanup.service.d.ts.map +1 -1
- package/dist/services/worker-cleanup.service.js +893 -355
- package/dist/services/worker-cleanup.service.js.map +1 -1
- package/dist/services/worker-lifecycle-executor.d.ts +42 -0
- package/dist/services/worker-lifecycle-executor.d.ts.map +1 -0
- package/dist/services/worker-lifecycle-executor.js +63 -0
- package/dist/services/worker-lifecycle-executor.js.map +1 -0
- package/dist/services/worker-single-use.d.ts +92 -0
- package/dist/services/worker-single-use.d.ts.map +1 -0
- package/dist/services/worker-single-use.js +155 -0
- package/dist/services/worker-single-use.js.map +1 -0
- package/dist/sessions/mcp-registry.d.ts +33 -2
- package/dist/sessions/mcp-registry.d.ts.map +1 -1
- package/dist/sessions/mcp-registry.js +153 -30
- package/dist/sessions/mcp-registry.js.map +1 -1
- package/dist/test-bootstrap.d.ts +19 -12
- package/dist/test-bootstrap.d.ts.map +1 -1
- package/dist/test-bootstrap.js +69 -21
- package/dist/test-bootstrap.js.map +1 -1
- package/dist/test-tripwire.test-support.d.ts +75 -0
- package/dist/test-tripwire.test-support.d.ts.map +1 -0
- package/dist/test-tripwire.test-support.js +353 -0
- package/dist/test-tripwire.test-support.js.map +1 -0
- package/dist/tools/defs/memory-defs.d.ts.map +1 -1
- package/dist/tools/defs/memory-defs.js +12 -4
- package/dist/tools/defs/memory-defs.js.map +1 -1
- package/dist/tools/defs/session-defs.d.ts.map +1 -1
- package/dist/tools/defs/session-defs.js +26 -10
- package/dist/tools/defs/session-defs.js.map +1 -1
- package/dist/tools/defs/utility-defs.js +1 -1
- package/dist/tools/defs/utility-defs.js.map +1 -1
- package/dist/tools/delegate-tool.d.ts +81 -1
- package/dist/tools/delegate-tool.d.ts.map +1 -1
- package/dist/tools/delegate-tool.js +840 -219
- package/dist/tools/delegate-tool.js.map +1 -1
- package/dist/tools/memory-tools.d.ts.map +1 -1
- package/dist/tools/memory-tools.js +66 -9
- package/dist/tools/memory-tools.js.map +1 -1
- package/dist/tools/response-builders.d.ts.map +1 -1
- package/dist/tools/response-builders.js +12 -8
- package/dist/tools/response-builders.js.map +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +3 -32
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/skill-tools.js +1 -1
- package/dist/tools/skill-tools.js.map +1 -1
- package/dist/tools/start-session-tool.d.ts.map +1 -1
- package/dist/tools/start-session-tool.js +66 -20
- package/dist/tools/start-session-tool.js.map +1 -1
- package/dist/tools/utility-tools.d.ts.map +1 -1
- package/dist/tools/utility-tools.js +38 -3
- package/dist/tools/utility-tools.js.map +1 -1
- package/dist/tools/wait/auto-forward.d.ts.map +1 -1
- package/dist/tools/wait/auto-forward.js +8 -3
- package/dist/tools/wait/auto-forward.js.map +1 -1
- package/dist/tools/wait/consolidation-strategy.d.ts +42 -0
- package/dist/tools/wait/consolidation-strategy.d.ts.map +1 -0
- package/dist/tools/wait/consolidation-strategy.js +50 -0
- package/dist/tools/wait/consolidation-strategy.js.map +1 -0
- package/dist/tools/wait/drive-handler.d.ts +5 -7
- package/dist/tools/wait/drive-handler.d.ts.map +1 -1
- package/dist/tools/wait/drive-handler.js +45 -59
- package/dist/tools/wait/drive-handler.js.map +1 -1
- package/dist/tools/wait/media-processor.d.ts.map +1 -1
- package/dist/tools/wait/media-processor.js +8 -4
- package/dist/tools/wait/media-processor.js.map +1 -1
- package/dist/tools/wait/message-delivery.d.ts +9 -6
- package/dist/tools/wait/message-delivery.d.ts.map +1 -1
- package/dist/tools/wait/message-delivery.js +77 -58
- package/dist/tools/wait/message-delivery.js.map +1 -1
- package/dist/tools/wait/message-processing.d.ts.map +1 -1
- package/dist/tools/wait/message-processing.js +2 -1
- package/dist/tools/wait/message-processing.js.map +1 -1
- package/dist/tools/wait/poll-loop.d.ts.map +1 -1
- package/dist/tools/wait/poll-loop.js +339 -239
- package/dist/tools/wait/poll-loop.js.map +1 -1
- package/package.json +4 -3
- package/templates/azure-devops-securevault.default.md +20 -6
- package/templates/board-quality-checklist.default.md +121 -0
- package/templates/buildless-vue-preview.default.md +47 -0
- package/templates/expert-code-review.default.md +12 -0
- package/templates/handoff.default.md +41 -18
- package/templates/increment-pr-pipeline.default.md +79 -0
- package/templates/swarm.default.md +1 -0
- package/templates/worker-autonomous.default.md +1 -0
- package/templates/worker-delegate.default.md +1 -0
- package/dist/dashboard/log-parser.d.ts +0 -65
- package/dist/dashboard/log-parser.d.ts.map +0 -1
- package/dist/dashboard/log-parser.js +0 -219
- package/dist/dashboard/log-parser.js.map +0 -1
- package/dist/data/memory/reflection-dedup.d.ts +0 -17
- package/dist/data/memory/reflection-dedup.d.ts.map +0 -1
- package/dist/data/memory/reflection-dedup.js +0 -55
- package/dist/data/memory/reflection-dedup.js.map +0 -1
- package/dist/data/memory/reflection-gates.d.ts +0 -40
- package/dist/data/memory/reflection-gates.d.ts.map +0 -1
- package/dist/data/memory/reflection-gates.js +0 -220
- package/dist/data/memory/reflection-gates.js.map +0 -1
- package/dist/data/memory/reflection-sources.d.ts +0 -13
- package/dist/data/memory/reflection-sources.d.ts.map +0 -1
- package/dist/data/memory/reflection-sources.js +0 -115
- package/dist/data/memory/reflection-sources.js.map +0 -1
- package/dist/data/memory/reflection.d.ts +0 -43
- package/dist/data/memory/reflection.d.ts.map +0 -1
- package/dist/data/memory/reflection.js +0 -329
- package/dist/data/memory/reflection.js.map +0 -1
- package/dist/llm/prompts/reflection.d.ts +0 -6
- package/dist/llm/prompts/reflection.d.ts.map +0 -1
- package/dist/llm/prompts/reflection.js +0 -77
- package/dist/llm/prompts/reflection.js.map +0 -1
- package/dist/services/memory-pruning.service.d.ts +0 -12
- package/dist/services/memory-pruning.service.d.ts.map +0 -1
- package/dist/services/memory-pruning.service.js +0 -179
- package/dist/services/memory-pruning.service.js.map +0 -1
- package/templates/daily-review.default.md +0 -26
- package/templates/fire-and-forget.default.md +0 -76
- package/templates/offload.default.md +0 -33
- package/templates/sensorium-repair.default.md +0 -114
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable, thread-scoped worker lifecycle state — the ONLY store for it.
|
|
3
|
+
*
|
|
4
|
+
* Replaces worker-deaths.json, unkillable-workers.json, the
|
|
5
|
+
* board_operator_released_workers table and the in-memory
|
|
6
|
+
* workerDeathNotifiedAt / workerDeathReasons / workerGraceDeadlines /
|
|
7
|
+
* unkillableNotifiedAt maps. Every claim here is a single SQLite statement whose
|
|
8
|
+
* `changes` count IS the arbitration, so two processes (self-update window) and
|
|
9
|
+
* N in-process actors cannot both win one claim.
|
|
10
|
+
*
|
|
11
|
+
* Keyed by thread id and read by the general worker net (worker-cleanup,
|
|
12
|
+
* spawn-common, delegate-tool, poll-loop) — not board state, so the table is
|
|
13
|
+
* created on the MAIN migration line (migration 32), alongside thread_registry.
|
|
14
|
+
*
|
|
15
|
+
* `phase` is a coarse label maintained alongside the facts it summarizes, with
|
|
16
|
+
* one exception that IS arbitrated on: the launch window (`launching` →
|
|
17
|
+
* `spawning` → `launched`), whose three CAS points decide between a dispatch that
|
|
18
|
+
* is starting a process and an operator release that stopped the card (increment
|
|
19
|
+
* D), and whose middle one SPENDS the window at the spawn choke point — the
|
|
20
|
+
* worker single-use rule's one carrier (`admitWorkerLaunch`). Design:
|
|
21
|
+
* implementation_plans/2026-09-25_board-architecture-escalation.md §T2, Inc B/D.
|
|
22
|
+
*/
|
|
23
|
+
import { Optional } from "../optional.js";
|
|
24
|
+
import { enqueuePassiveNotice } from "./passive-notice.repository.js";
|
|
25
|
+
function lifecycleRow(db, threadId) {
|
|
26
|
+
return Optional.fromNullable(db
|
|
27
|
+
.prepare(`SELECT reason, operator_released, grace_deadline_at, first_unkillable_at, notified_at
|
|
28
|
+
FROM worker_lifecycle WHERE thread_id = ?`)
|
|
29
|
+
// eslint-disable-next-line no-restricted-syntax -- SQLite returns undefined for an absent row
|
|
30
|
+
.get(threadId));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Open a worker's launch window, and record the card that owns it when one does.
|
|
34
|
+
*
|
|
35
|
+
* Called between registerThread and the agent launch, so it is the durable
|
|
36
|
+
* statement "a process may exist for thread N from here on". Returns false when
|
|
37
|
+
* the row is already an operator release: a Stop that landed while this dispatch
|
|
38
|
+
* was preparing owns the worker, and the launch must be abandoned rather than
|
|
39
|
+
* started behind a kill that already ran. The claim can be exact because every
|
|
40
|
+
* caller MINTS its worker id (worker-birth.ts step 1): no earlier worker ever
|
|
41
|
+
* held it, so any row this statement meets was written for this worker.
|
|
42
|
+
*
|
|
43
|
+
* The other term, `notified_at IS NULL`, is what makes "never reused" CAS-PROVABLE
|
|
44
|
+
* rather than merely checked above it: a worker whose ending has been claimed can
|
|
45
|
+
* never be handed a second window, whatever state its registry row is patched into.
|
|
46
|
+
* Those two terms are exactly `workerDeathNoticeClaimable`'s, and that is the point —
|
|
47
|
+
* the read is the NON-AUTHORITATIVE mirror of this statement, so the spawn choke
|
|
48
|
+
* point's audit term is only ever as strong as this CAS is.
|
|
49
|
+
*
|
|
50
|
+
* `reason IS NULL` is NOT a third term, and adding one back as defence in depth would
|
|
51
|
+
* be adding a dead branch. `claimWorkerDeath` writes `reason` and `notified_at` in ONE
|
|
52
|
+
* statement, and the only writer that separates them is `markWorkerReleased`, which
|
|
53
|
+
* nulls `reason` while setting `operator_released = 1` — a row the first term already
|
|
54
|
+
* refuses. So no reachable row distinguishes the two columns: with all three terms
|
|
55
|
+
* present, a mutation dropping EITHER `notified_at IS NULL` or `reason IS NULL` alone
|
|
56
|
+
* left the whole suite green, which is one meaning spelled twice and exactly the dead
|
|
57
|
+
* term this file deleted from the read-time audit.
|
|
58
|
+
*
|
|
59
|
+
* `cardId` is empty for a worker no card owns — `start_thread mode=worker`, whose
|
|
60
|
+
* launch needs the same window and has no card to link. One statement rather than
|
|
61
|
+
* a card-less twin of it, because the arbitration the window performs is the same
|
|
62
|
+
* either way and `card_id` is nullable precisely so the link can be absent; a
|
|
63
|
+
* second opener would state the same CAS twice and let the two drift.
|
|
64
|
+
*/
|
|
65
|
+
export function beginWorkerLaunch(db, threadId, cardId) {
|
|
66
|
+
return (db
|
|
67
|
+
.prepare(`INSERT INTO worker_lifecycle (thread_id, phase, card_id) VALUES (?, 'launching', ?)
|
|
68
|
+
ON CONFLICT(thread_id) DO UPDATE SET phase = 'launching', card_id = excluded.card_id
|
|
69
|
+
WHERE worker_lifecycle.operator_released = 0
|
|
70
|
+
AND worker_lifecycle.notified_at IS NULL`)
|
|
71
|
+
// eslint-disable-next-line no-restricted-syntax -- SQLite bind: the nullable card_id column
|
|
72
|
+
.run(threadId, cardId.orElse(null)).changes === 1);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* SPEND the worker's one launch ticket: the admission at the choke point where
|
|
76
|
+
* processes are born (`claimWorkerBirth`, services/worker-single-use.ts). True for
|
|
77
|
+
* the ONE caller that gets the birth; false for every other.
|
|
78
|
+
*
|
|
79
|
+
* This replaced a READ of the same phase, and the difference is the whole rule. A
|
|
80
|
+
* read does not spend anything, so ONE open window admitted however many callers
|
|
81
|
+
* looked into it: the window spans the awaited spawn — minutes, under a broker
|
|
82
|
+
* budget plus reconcile rounds — and the dashboard start route runs freely inside
|
|
83
|
+
* it, with a no-PID liveness probe that reads dead because the pid file is written
|
|
84
|
+
* only after the spawn returns. Worse than a race: nothing on the dispatch path
|
|
85
|
+
* ever CLOSED the window, only `completeWorkerLaunch` at the far end did, so a
|
|
86
|
+
* crash-mid-birth row (the declared `phase='launching'` residue) was serially
|
|
87
|
+
* startable without bound. `changes` IS the arbitration here, as everywhere else in
|
|
88
|
+
* this file, so the second admission loses in SQLite rather than in whoever read
|
|
89
|
+
* first.
|
|
90
|
+
*
|
|
91
|
+
* The window is the right ticket to spend precisely because it is NARROW:
|
|
92
|
+
* `beginWorkerLaunch` opens it immediately before a spawn and `completeWorkerLaunch`
|
|
93
|
+
* commits it immediately after, so a worker's own first launch finds 'launching' and
|
|
94
|
+
* every later attempt on that id meets 'spawning', 'launched', 'grace', 'dead',
|
|
95
|
+
* 'exited', 'released', 'unkillable' — or no row at all, which is every worker born
|
|
96
|
+
* before the window existed. Asking "is the phase terminal?" instead would be
|
|
97
|
+
* weaker, not merely different: a crash between process death and exit bookkeeping
|
|
98
|
+
* leaves a worker `active` with no process, an aborted decommission leaves `exiting`,
|
|
99
|
+
* and neither is terminal.
|
|
100
|
+
*
|
|
101
|
+
* One term, like `beginWorkerLaunch`'s arm after its trim: `operator_released = 0` is
|
|
102
|
+
* not a second one, because `markWorkerReleased` relabels the phase in the same
|
|
103
|
+
* statement that sets the flag, so no reachable row is both 'launching' and released.
|
|
104
|
+
* A release therefore still beats this CAS, and beats the commit after it.
|
|
105
|
+
*/
|
|
106
|
+
export function admitWorkerLaunch(db, threadId) {
|
|
107
|
+
return (db
|
|
108
|
+
.prepare(`UPDATE worker_lifecycle SET phase = 'spawning'
|
|
109
|
+
WHERE thread_id = ? AND phase = 'launching'`)
|
|
110
|
+
.run(threadId).changes === 1);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Close the launch window: the process is running and the card still owns it.
|
|
114
|
+
*
|
|
115
|
+
* Loses to an operator release that landed while the agent was starting — whose
|
|
116
|
+
* kill necessarily missed, because there was no process to kill yet. The loser
|
|
117
|
+
* therefore owns what it started: it kills the worker and tears the dispatch
|
|
118
|
+
* down, so a Stop can never be outlived by the worker it stopped.
|
|
119
|
+
*
|
|
120
|
+
* The two terms say different things and the overlap between them is deliberate:
|
|
121
|
+
* `phase = 'spawning'` makes the commit once-only, so two orchestrators ticking
|
|
122
|
+
* the same card cannot both conclude they launched it, while
|
|
123
|
+
* `operator_released = 0` is the release arbitration itself. Today a release also
|
|
124
|
+
* relabels the phase, so either term alone would reject this commit — do not trim
|
|
125
|
+
* one as redundant: that would leave the other carrying a meaning it does not have.
|
|
126
|
+
*
|
|
127
|
+
* It commits from 'spawning' and NOT from 'launching', which makes the admission
|
|
128
|
+
* unskippable: only a birth the choke point actually admitted
|
|
129
|
+
* ({@link admitWorkerLaunch}) has a window left to commit. A launch that reached
|
|
130
|
+
* step 8 without one never passed the refusal, so there is nothing to commit and
|
|
131
|
+
* `birthWorker` gives the worker up — the same verdict as losing the window to a
|
|
132
|
+
* release. Anything that fakes the spawn must spend the ticket the way the real
|
|
133
|
+
* choke point does, or it is not modelling a birth.
|
|
134
|
+
*/
|
|
135
|
+
export function completeWorkerLaunch(db, threadId) {
|
|
136
|
+
return (db
|
|
137
|
+
.prepare(`UPDATE worker_lifecycle SET phase = 'launched'
|
|
138
|
+
WHERE thread_id = ? AND phase = 'spawning' AND operator_released = 0`)
|
|
139
|
+
.run(threadId).changes === 1);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Record that this thread READ its pre-queued task — the single-use signal, durable.
|
|
143
|
+
*
|
|
144
|
+
* Written at the one place a task is consumed (`consumePendingTask`, the poll loop) and
|
|
145
|
+
* read by the two places that decide whether a worker may be started again: the
|
|
146
|
+
* born-dead net's `taskConsumed` input and the spawn choke point's audit (i).
|
|
147
|
+
*
|
|
148
|
+
* It replaced an in-process Set, and the premise that justified a Set was false. The
|
|
149
|
+
* Set's own comment read "both consume and process-exit run in THIS server process, so
|
|
150
|
+
* a Set is sufficient — workers are never resumed across a server restart anyway", but
|
|
151
|
+
* the exit watcher observes the exit of a worker that OUTLIVED the restart. The refusal gates BIRTHS, not EXITS: so the net fires in a fresh process
|
|
152
|
+
* whose Set is empty, reads a finished worker as one that never started, and relaunches
|
|
153
|
+
* it. The exit path's own death claim could not save it either — the net runs BEFORE
|
|
154
|
+
* that claim and returns on "respawned", so the claim is never taken.
|
|
155
|
+
*
|
|
156
|
+
* FIRST write wins. The mailbox is a shared append-only file that `report_progress`
|
|
157
|
+
* forwarding and cross-thread sends can RECREATE after a worker already acted on its
|
|
158
|
+
* task, so a worker can consume more than once; the question every reader asks is
|
|
159
|
+
* "did it EVER read work", and the first answer is the honest one.
|
|
160
|
+
*
|
|
161
|
+
* An UPSERT, not an UPDATE, because the poll loop serves every thread type and a root
|
|
162
|
+
* or branch has no lifecycle row. Such a row carries nothing but this timestamp, and
|
|
163
|
+
* no reader of the table changes its answer for it: the card guard keys on `card_id`,
|
|
164
|
+
* the sweeps on `retire_at` and `grace_deadline_at`, the release and notice reads on
|
|
165
|
+
* their own columns — all absent here. Narrowing the write to workers would need the
|
|
166
|
+
* registry read this path does not do, and would buy nothing.
|
|
167
|
+
*/
|
|
168
|
+
export function markWorkerTaskConsumed(db, threadId, now) {
|
|
169
|
+
db.prepare(`INSERT INTO worker_lifecycle (thread_id, task_consumed_at) VALUES (?, ?)
|
|
170
|
+
ON CONFLICT(thread_id) DO UPDATE SET task_consumed_at = excluded.task_consumed_at
|
|
171
|
+
WHERE worker_lifecycle.task_consumed_at IS NULL`).run(threadId, now);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Whether this thread ever read its pre-queued task. Durable, so unlike the Set it
|
|
175
|
+
* replaces it is not empty in a process that did not watch the consumption — which is
|
|
176
|
+
* the whole point: the process that decides whether to relaunch a worker is often not
|
|
177
|
+
* the process that saw it work.
|
|
178
|
+
*
|
|
179
|
+
* NOT keyed on the pending-task FILE, which is the shape this signal had before and the
|
|
180
|
+
* reason it exists: that mailbox is append-only and shared, `report_progress`
|
|
181
|
+
* parent-forwarding and cross-thread sends recreate it after a worker has acted, and
|
|
182
|
+
* relaunching on "file present" re-ran finished workers into duplicate posts.
|
|
183
|
+
*/
|
|
184
|
+
export function wasWorkerTaskConsumed(db, threadId) {
|
|
185
|
+
return Optional.fromNullable(db
|
|
186
|
+
.prepare(`SELECT 1 AS consumed FROM worker_lifecycle
|
|
187
|
+
WHERE thread_id = ? AND task_consumed_at IS NOT NULL`)
|
|
188
|
+
// eslint-disable-next-line no-restricted-syntax -- SQLite returns undefined for an absent row
|
|
189
|
+
.get(threadId)).has();
|
|
190
|
+
}
|
|
191
|
+
/** Every worker this card has launched and not yet been proven done with — the
|
|
192
|
+
* prior-worker guard's whole candidate set. Durable, so unlike the process-local
|
|
193
|
+
* map it replaces it is not empty after a restart, and it covers a card whose
|
|
194
|
+
* worker shares the main checkout as well as one running in its own worktree. */
|
|
195
|
+
export function listCardWorkers(db, cardId) {
|
|
196
|
+
return db
|
|
197
|
+
.prepare("SELECT thread_id FROM worker_lifecycle WHERE card_id = ? ORDER BY thread_id")
|
|
198
|
+
.all(cardId).map((row) => row.thread_id);
|
|
199
|
+
}
|
|
200
|
+
/** Drop the card link of a worker proven dead, so the next dispatch of that card
|
|
201
|
+
* does not probe it again. The row itself stays: its death reason and release
|
|
202
|
+
* marker are still read by the paths that report on this worker. */
|
|
203
|
+
export function forgetCardWorker(db, threadId) {
|
|
204
|
+
db.prepare("UPDATE worker_lifecycle SET card_id = NULL WHERE thread_id = ?").run(threadId);
|
|
205
|
+
}
|
|
206
|
+
/** The terminal phase each ending lands the row in. `clean-exit` gets its own
|
|
207
|
+
* phase rather than borrowing 'dead': the table is the thing a human reads when
|
|
208
|
+
* a worker vanishes, and labelling an orderly code-0 exit "dead" is the same
|
|
209
|
+
* lie the notice text is being fixed to stop telling. Every value here is
|
|
210
|
+
* outside the ('active','launched') set the grace/unkillable claims re-enter, so
|
|
211
|
+
* a terminal row behaves identically to 'dead' for all of them. Exhaustive on
|
|
212
|
+
* purpose: the next reason added has to name its phase, rather than falling into
|
|
213
|
+
* 'dead' because nobody chose. */
|
|
214
|
+
const TERMINAL_PHASE = {
|
|
215
|
+
"confirmed-dead": "dead",
|
|
216
|
+
"past-TTL": "dead",
|
|
217
|
+
unkillable: "unkillable",
|
|
218
|
+
"clean-exit": "exited",
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Claim the one exit notice for a worker AND queue that notice, as one durable
|
|
222
|
+
* step. Wins only when no notice was claimed before and the operator did not stop
|
|
223
|
+
* this worker — so a deliberate release is never reported as a death, and an ending
|
|
224
|
+
* is reported exactly once even when the claim and the notice straddle a restart.
|
|
225
|
+
* Clears any grace deadline: grace is over the moment the worker is declared gone.
|
|
226
|
+
*
|
|
227
|
+
* This single claim is what lets the process-exit watcher and the teardown
|
|
228
|
+
* sweeps both emit unconditionally: whichever observes the ending FIRST reports
|
|
229
|
+
* it, and the other finds the claim taken and stays quiet. There is deliberately
|
|
230
|
+
* no second in-memory dedup beside it.
|
|
231
|
+
*
|
|
232
|
+
* `notice` is REQUIRED, and it is inside the transaction, because the claim used
|
|
233
|
+
* to be taken at "an observer STARTED reporting" instead of "the report EXISTS".
|
|
234
|
+
* Committing `notified_at` first and only then pushing the text meant a death in
|
|
235
|
+
* between consumed the worker's only notice: the claim stood, every retry lost to
|
|
236
|
+
* it, and the orchestrator was never told its worker was gone. So the two commit
|
|
237
|
+
* together or not at all — and an enqueue that throws rolls the claim back, which
|
|
238
|
+
* is what makes a retry able to succeed rather than merely fail again.
|
|
239
|
+
*
|
|
240
|
+
* The previous ordering was documented here as deliberate ("a crash can omit one
|
|
241
|
+
* notice but cannot cause a second notice on restart"). That trade-off is inverted
|
|
242
|
+
* for THIS news: a lost "your worker is gone" is unbounded silence for whoever is
|
|
243
|
+
* waiting on a reply that has already become impossible, while a duplicate FYI is
|
|
244
|
+
* noise in a queue that gets drained. There is now no window for either.
|
|
245
|
+
*
|
|
246
|
+
* A worker with nobody recorded to tell passes an empty notice: the claim is still
|
|
247
|
+
* taken, so a later teardown of the same worker does not retry a notice that has
|
|
248
|
+
* no recipient.
|
|
249
|
+
*/
|
|
250
|
+
export function claimWorkerDeath(db, threadId, reason, now, notice) {
|
|
251
|
+
return db.transaction(() => {
|
|
252
|
+
const claimed = db
|
|
253
|
+
.prepare(`INSERT INTO worker_lifecycle (thread_id, phase, reason, notified_at)
|
|
254
|
+
VALUES (?, ?, ?, ?)
|
|
255
|
+
ON CONFLICT(thread_id) DO UPDATE SET phase = excluded.phase,
|
|
256
|
+
reason = excluded.reason, notified_at = excluded.notified_at,
|
|
257
|
+
grace_deadline_at = NULL
|
|
258
|
+
WHERE worker_lifecycle.operator_released = 0
|
|
259
|
+
AND worker_lifecycle.notified_at IS NULL`)
|
|
260
|
+
.run(threadId, TERMINAL_PHASE[reason], reason, now).changes === 1;
|
|
261
|
+
if (!claimed)
|
|
262
|
+
return false;
|
|
263
|
+
notice.ifPresent((queued) => enqueuePassiveNotice(db, queued.threadId, "worker-death", queued.text, new Date(now).toISOString()));
|
|
264
|
+
return true;
|
|
265
|
+
})();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Whether nobody owns this worker's ENDING yet — a NON-AUTHORITATIVE read, and the
|
|
269
|
+
* ONLY place in this file that is. Two readers, and neither may treat it as a claim.
|
|
270
|
+
*
|
|
271
|
+
* The exit path asks it so a reporter can skip building a payload it would not be
|
|
272
|
+
* allowed to queue (it parses a multi-megabyte log for the notice's log tail).
|
|
273
|
+
* better-sqlite3 transactions are synchronous, so that payload has to be computed
|
|
274
|
+
* BEFORE claimWorkerDeath's transaction opens — which is what removed the thunk that
|
|
275
|
+
* used to give the claim's loser the same saving for free. There it is an optimization
|
|
276
|
+
* and NEVER the arbitration: it can go stale the instant it returns, and a caller that
|
|
277
|
+
* trusted it would be exactly the two-step claim increment B exists to delete. The
|
|
278
|
+
* authoritative decision is the single statement inside claimWorkerDeath's
|
|
279
|
+
* transaction, and that caller must still act on ITS answer.
|
|
280
|
+
*
|
|
281
|
+
* The spawn choke point asks it as ONE TERM of the born-dead net's audited exception
|
|
282
|
+
* (services/worker-single-use.ts) — the term that makes the exception unsmugglable
|
|
283
|
+
* ACROSS A RESTART, where the net's in-process signal (`wasTaskConsumed`) is an empty
|
|
284
|
+
* Set and would otherwise wave every finished worker on the host through. It is not an
|
|
285
|
+
* arbitration there either: a claim landing after this read leaves the relaunch
|
|
286
|
+
* standing, exactly as it stands today with no term at all, so the audit is strictly
|
|
287
|
+
* stronger than what it replaces and not a new guarantee. What makes the single-use
|
|
288
|
+
* rule PROVABLE is beginWorkerLaunch's CAS, not this read.
|
|
289
|
+
*
|
|
290
|
+
* `reason` is deliberately NOT a third term, for the reason recorded on
|
|
291
|
+
* `beginWorkerLaunch` — no reachable row distinguishes it from `notified_at`, and a
|
|
292
|
+
* mutation dropping a `reason IS NULL` term survived the whole suite, which is what a
|
|
293
|
+
* dead term looks like. That CAS carries exactly these two terms and no more, so the
|
|
294
|
+
* authoritative statement and this read of it cannot drift into different predicates.
|
|
295
|
+
*/
|
|
296
|
+
export function workerDeathNoticeClaimable(db, threadId) {
|
|
297
|
+
return lifecycleRow(db, threadId)
|
|
298
|
+
.map((row) => !Optional.fromNullable(row.notified_at).has() && row.operator_released === 0)
|
|
299
|
+
.orElse(true);
|
|
300
|
+
}
|
|
301
|
+
/** The recorded death reason, used for honest send_message_to_thread rejects.
|
|
302
|
+
* Empty for an operator-released worker — a Stop is not a death — because
|
|
303
|
+
* markWorkerReleased nulls the reason. That is the single enforcement point: a
|
|
304
|
+
* second check here would be an unreachable branch, since claimWorkerDeath cannot
|
|
305
|
+
* write a reason onto a released row either. */
|
|
306
|
+
export function workerDeathReason(db, threadId) {
|
|
307
|
+
return lifecycleRow(db, threadId).map((row) => row.reason);
|
|
308
|
+
}
|
|
309
|
+
/** Record an operator Stop. Written BEFORE any teardown guard or kill, so every
|
|
310
|
+
* actor that later meets this worker can tell an intentional stop from a death.
|
|
311
|
+
* Idempotent, and it drops a stale death reason left by an earlier lifecycle.
|
|
312
|
+
* It also ends any launch window — the phase and operator_released it writes are
|
|
313
|
+
* exactly what the launch CAS above loses to — so a Stop never needs to know
|
|
314
|
+
* whether the worker it is stopping has a process yet. */
|
|
315
|
+
export function markWorkerReleased(db, threadId) {
|
|
316
|
+
db.prepare(`INSERT INTO worker_lifecycle (thread_id, phase, operator_released)
|
|
317
|
+
VALUES (?, 'released', 1)
|
|
318
|
+
ON CONFLICT(thread_id) DO UPDATE SET phase = 'released', operator_released = 1,
|
|
319
|
+
reason = NULL, grace_deadline_at = NULL, retire_at = NULL`).run(threadId);
|
|
320
|
+
}
|
|
321
|
+
/** Schedule a reported worker's retirement: it is finished, but it keeps polling
|
|
322
|
+
* for instructions, so it is given a short window for the capture reply to reach
|
|
323
|
+
* it and is then torn down. The deadline is durable, so a restart inside the
|
|
324
|
+
* window still retires it. Not written for an operator-released worker — that
|
|
325
|
+
* teardown is already owned, and markWorkerReleased drops any deadline — which
|
|
326
|
+
* keeps "released implies no pending retirement" true in both directions. */
|
|
327
|
+
export function scheduleWorkerRetirement(db, threadId, retireAt) {
|
|
328
|
+
db.prepare(`INSERT INTO worker_lifecycle (thread_id, retire_at) VALUES (?, ?)
|
|
329
|
+
ON CONFLICT(thread_id) DO UPDATE SET retire_at = excluded.retire_at
|
|
330
|
+
WHERE worker_lifecycle.operator_released = 0`).run(threadId, retireAt);
|
|
331
|
+
}
|
|
332
|
+
/** The absolute ms deadline at which a reported worker is retired, while one is
|
|
333
|
+
* pending. Read by the orphan sweep and the prior-worker guard to tell a worker
|
|
334
|
+
* that is on its way out from one that was never retired at all. */
|
|
335
|
+
export function workerRetirementDeadline(db, threadId) {
|
|
336
|
+
return Optional.fromNullable(db.prepare("SELECT retire_at FROM worker_lifecycle WHERE thread_id = ?").get(threadId)?.retire_at);
|
|
337
|
+
}
|
|
338
|
+
/** The workers whose retirement is due — the orchestrator tick's whole input for
|
|
339
|
+
* retiring reported workers. A query over the durable deadline, not a scan of
|
|
340
|
+
* every thread against an age heuristic. */
|
|
341
|
+
export function listDueWorkerRetirements(db, now) {
|
|
342
|
+
return db
|
|
343
|
+
.prepare("SELECT thread_id FROM worker_lifecycle WHERE retire_at <= ? ORDER BY retire_at")
|
|
344
|
+
.all(now).map((row) => row.thread_id);
|
|
345
|
+
}
|
|
346
|
+
/** Consume a pending retirement. Called at the head of teardown, so a worker torn
|
|
347
|
+
* down by any owner (its own exit, an operator Stop, the TTL sweep) leaves no
|
|
348
|
+
* deadline for the tick to act on a second time. */
|
|
349
|
+
export function clearWorkerRetirement(db, threadId) {
|
|
350
|
+
db.prepare("UPDATE worker_lifecycle SET retire_at = NULL WHERE thread_id = ?").run(threadId);
|
|
351
|
+
}
|
|
352
|
+
export function isWorkerReleased(db, threadId) {
|
|
353
|
+
return lifecycleRow(db, threadId)
|
|
354
|
+
.map((row) => row.operator_released === 1)
|
|
355
|
+
.orElse(false);
|
|
356
|
+
}
|
|
357
|
+
/** Claim the TTL grace window for a worker, returning true for the writer that
|
|
358
|
+
* set the deadline. The claim is on the deadline alone — a worker already dead
|
|
359
|
+
* or already released must still be torn down by the sweep that owns it, so the
|
|
360
|
+
* only thing decided here is who logs "entering grace". */
|
|
361
|
+
export function startWorkerGrace(db, threadId, deadline) {
|
|
362
|
+
return (db
|
|
363
|
+
.prepare(`INSERT INTO worker_lifecycle (thread_id, phase, grace_deadline_at)
|
|
364
|
+
VALUES (?, 'grace', ?)
|
|
365
|
+
ON CONFLICT(thread_id) DO UPDATE SET grace_deadline_at = excluded.grace_deadline_at,
|
|
366
|
+
phase = CASE WHEN worker_lifecycle.phase IN ('active', 'launched') THEN 'grace'
|
|
367
|
+
ELSE worker_lifecycle.phase END
|
|
368
|
+
WHERE worker_lifecycle.grace_deadline_at IS NULL`)
|
|
369
|
+
.run(threadId, deadline).changes === 1);
|
|
370
|
+
}
|
|
371
|
+
/** The absolute ms deadline after which a worker in grace is torn down. */
|
|
372
|
+
export function workerGraceDeadline(db, threadId) {
|
|
373
|
+
return lifecycleRow(db, threadId).map((row) => row.grace_deadline_at);
|
|
374
|
+
}
|
|
375
|
+
/** True while a worker is inside its TTL grace window (winding down, but its MCP
|
|
376
|
+
* socket is still open so it can deliver a final result). Read by the poll loop
|
|
377
|
+
* (to tell the worker to wrap up) and by send_message_to_thread (to honestly
|
|
378
|
+
* reject new orchestrator work rather than silently queue it to a dying worker). */
|
|
379
|
+
export function isWorkerInGrace(db, threadId) {
|
|
380
|
+
return workerGraceDeadline(db, threadId).has();
|
|
381
|
+
}
|
|
382
|
+
/** Drop a worker's grace deadline without running teardown. Used when exit
|
|
383
|
+
* bookkeeping finds teardown already owned elsewhere, and at the head of
|
|
384
|
+
* teardown itself. Safe when no row or no deadline exists. */
|
|
385
|
+
export function clearWorkerGrace(db, threadId) {
|
|
386
|
+
db.prepare(`UPDATE worker_lifecycle SET grace_deadline_at = NULL,
|
|
387
|
+
phase = CASE WHEN phase = 'grace' THEN 'active' ELSE phase END
|
|
388
|
+
WHERE thread_id = ?`).run(threadId);
|
|
389
|
+
}
|
|
390
|
+
/** Record (once) the first time a worker survived a kill and return that anchor.
|
|
391
|
+
* The unkillable escalation threshold is measured from it, so it must outlive a
|
|
392
|
+
* restart — a wedged worker can span a server update. Later calls return the
|
|
393
|
+
* original first-attempt time. */
|
|
394
|
+
export function recordFirstUnkillable(db, threadId, now) {
|
|
395
|
+
db.prepare(`INSERT INTO worker_lifecycle (thread_id, phase, first_unkillable_at)
|
|
396
|
+
VALUES (?, 'unkillable', ?)
|
|
397
|
+
ON CONFLICT(thread_id) DO UPDATE SET first_unkillable_at = excluded.first_unkillable_at,
|
|
398
|
+
phase = CASE WHEN worker_lifecycle.phase IN ('active', 'launched') THEN 'unkillable'
|
|
399
|
+
ELSE worker_lifecycle.phase END
|
|
400
|
+
WHERE worker_lifecycle.first_unkillable_at IS NULL`).run(threadId, now);
|
|
401
|
+
return lifecycleRow(db, threadId)
|
|
402
|
+
.map((row) => row.first_unkillable_at)
|
|
403
|
+
.orElse(now);
|
|
404
|
+
}
|
|
405
|
+
/** Forget a worker's unkillable history once its process is confirmed gone, so a
|
|
406
|
+
* future thread that reuses the id starts its clock fresh. */
|
|
407
|
+
export function clearUnkillable(db, threadId) {
|
|
408
|
+
db.prepare(`UPDATE worker_lifecycle SET first_unkillable_at = NULL, unkillable_notified_at = NULL,
|
|
409
|
+
phase = CASE WHEN phase = 'unkillable' AND reason IS NULL THEN 'active' ELSE phase END
|
|
410
|
+
WHERE thread_id = ?`).run(threadId);
|
|
411
|
+
}
|
|
412
|
+
/** Claim the right to escalate an unkillable worker to the operator, at most once
|
|
413
|
+
* per renotify interval. Taken BEFORE the send so two sweeps cannot both alert;
|
|
414
|
+
* a failed send hands it back via releaseUnkillableAlertClaim. */
|
|
415
|
+
export function claimUnkillableAlert(db, threadId, now, intervalMs) {
|
|
416
|
+
return (db
|
|
417
|
+
.prepare(`UPDATE worker_lifecycle SET unkillable_notified_at = ?
|
|
418
|
+
WHERE thread_id = ? AND first_unkillable_at IS NOT NULL
|
|
419
|
+
AND (unkillable_notified_at IS NULL OR unkillable_notified_at <= ?)`)
|
|
420
|
+
.run(now, threadId, now - intervalMs).changes === 1);
|
|
421
|
+
}
|
|
422
|
+
/** Hand back a claim whose alert failed to send, so the next sweep retries it.
|
|
423
|
+
* Matches on the claim's own timestamp: a newer claim must not be cleared. */
|
|
424
|
+
export function releaseUnkillableAlertClaim(db, threadId, now) {
|
|
425
|
+
db.prepare(`UPDATE worker_lifecycle SET unkillable_notified_at = NULL
|
|
426
|
+
WHERE thread_id = ? AND unkillable_notified_at = ?`).run(threadId, now);
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=worker-lifecycle.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-lifecycle.repository.js","sourceRoot":"","sources":["../../../src/data/memory/worker-lifecycle.repository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AA0BtE,SAAS,YAAY,CAAC,EAAY,EAAE,QAAgB;IAClD,OAAO,QAAQ,CAAC,YAAY,CAC1B,EAAE;SACC,OAAO,CACN;qDAC6C,CAC9C;QACD,8FAA8F;SAC7F,GAAG,CAAC,QAAQ,CAA6B,CAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAY,EACZ,QAAgB,EAChB,MAAwB;IAExB,OAAO,CACL,EAAE;SACC,OAAO,CACN;;;oDAG4C,CAC7C;QACD,4FAA4F;SAC3F,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,CACpD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAY,EAAE,QAAgB;IAC9D,OAAO,CACL,EAAE;SACC,OAAO,CACN;qDAC6C,CAC9C;SACA,GAAG,CAAC,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAC/B,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB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C,EAAY,EACZ,QAAgB,EAChB,GAAW,EACX,UAAkB;IAElB,OAAO,CACL,EAAE;SACC,OAAO,CACN;;+EAEuE,CACxE;SACA,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,UAAU,CAAC,CAAC,OAAO,KAAK,CAAC,CACtD,CAAC;AACJ,CAAC;AAED;+EAC+E;AAC/E,MAAM,UAAU,2BAA2B,CAAC,EAAY,EAAE,QAAgB,EAAE,GAAW;IACrF,EAAE,CAAC,OAAO,CACR;wDACoD,CACrD,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A value that may be present without exposing absence to its consumers. */
|
|
2
|
+
export declare class Optional<T> {
|
|
3
|
+
private readonly content;
|
|
4
|
+
private constructor();
|
|
5
|
+
static of<T>(value: NonNullable<T>): Optional<NonNullable<T>>;
|
|
6
|
+
static empty<T>(): Optional<T>;
|
|
7
|
+
static fromNullable<T>(value: T | null | undefined): Optional<NonNullable<T>>;
|
|
8
|
+
/** Collect the present values from a list of Optionals, dropping the empties. */
|
|
9
|
+
static values<T>(optionals: ReadonlyArray<Optional<T>>): T[];
|
|
10
|
+
has(): boolean;
|
|
11
|
+
get(): T;
|
|
12
|
+
orElse<R>(fallback: R): T | R;
|
|
13
|
+
map<R>(mapper: (value: T) => R): Optional<NonNullable<R>>;
|
|
14
|
+
ifPresent(consumer: (value: T) => void): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=optional.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../../src/data/optional.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qBAAa,QAAQ,CAAC,CAAC;IACD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAA5C,OAAO;WAEO,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;WAOtD,KAAK,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC;WAIvB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAIpF,iFAAiF;WACnE,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;IAM5D,GAAG,IAAI,OAAO;IAId,GAAG,IAAI,CAAC;IAKR,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;IAI7B,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAMzD,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;CAGrD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** A value that may be present without exposing absence to its consumers. */
|
|
2
|
+
export class Optional {
|
|
3
|
+
content;
|
|
4
|
+
constructor(content) {
|
|
5
|
+
this.content = content;
|
|
6
|
+
}
|
|
7
|
+
static of(value) {
|
|
8
|
+
if (value === null || value === undefined) {
|
|
9
|
+
throw new Error("Optional.of cannot accept null or undefined");
|
|
10
|
+
}
|
|
11
|
+
return new Optional({ value });
|
|
12
|
+
}
|
|
13
|
+
static empty() {
|
|
14
|
+
return new Optional(null);
|
|
15
|
+
}
|
|
16
|
+
static fromNullable(value) {
|
|
17
|
+
return value === null || value === undefined ? Optional.empty() : Optional.of(value);
|
|
18
|
+
}
|
|
19
|
+
/** Collect the present values from a list of Optionals, dropping the empties. */
|
|
20
|
+
static values(optionals) {
|
|
21
|
+
const present = [];
|
|
22
|
+
for (const optional of optionals)
|
|
23
|
+
optional.ifPresent((value) => present.push(value));
|
|
24
|
+
return present;
|
|
25
|
+
}
|
|
26
|
+
has() {
|
|
27
|
+
return this.content !== null;
|
|
28
|
+
}
|
|
29
|
+
get() {
|
|
30
|
+
if (this.content === null)
|
|
31
|
+
throw new Error("Optional is empty");
|
|
32
|
+
return this.content.value;
|
|
33
|
+
}
|
|
34
|
+
orElse(fallback) {
|
|
35
|
+
return this.content === null ? fallback : this.content.value;
|
|
36
|
+
}
|
|
37
|
+
map(mapper) {
|
|
38
|
+
return this.content === null
|
|
39
|
+
? Optional.empty()
|
|
40
|
+
: Optional.fromNullable(mapper(this.content.value));
|
|
41
|
+
}
|
|
42
|
+
ifPresent(consumer) {
|
|
43
|
+
if (this.content !== null)
|
|
44
|
+
consumer(this.content.value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=optional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../src/data/optional.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,OAAO,QAAQ;IACkB;IAArC,YAAqC,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;IAAG,CAAC;IAEvE,MAAM,CAAC,EAAE,CAAI,KAAqB;QACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,KAAK;QACjB,OAAO,IAAI,QAAQ,CAAI,IAAI,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,YAAY,CAAI,KAA2B;QACvD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KA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