@plurnk/plurnk-service 1.18.0 → 1.19.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/.env.defaults +76 -13
- package/README.md +5 -3
- package/SPEC.md +924 -689
- package/dist/Paths.js +3 -3
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts +1 -0
- package/dist/content/body-preview.d.ts.map +1 -1
- package/dist/content/body-preview.js +8 -10
- package/dist/content/body-preview.js.map +1 -1
- package/dist/content/edit-receipt.d.ts.map +1 -1
- package/dist/content/edit-receipt.js +30 -29
- package/dist/content/edit-receipt.js.map +1 -1
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +17 -5
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/read-projector.d.ts +2 -2
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +79 -37
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/scope-format.d.ts +9 -0
- package/dist/content/scope-format.d.ts.map +1 -0
- package/dist/content/scope-format.js +28 -0
- package/dist/content/scope-format.js.map +1 -0
- package/dist/core/AdministrativeLoop.d.ts +8 -0
- package/dist/core/AdministrativeLoop.d.ts.map +1 -0
- package/dist/core/AdministrativeLoop.js +16 -0
- package/dist/core/AdministrativeLoop.js.map +1 -0
- package/dist/core/AdmittedTurnExecutor.d.ts +2 -1
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +19 -19
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +1 -2
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js +7 -12
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +3 -4
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +4 -2
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +23 -2
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +2 -2
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +6 -3
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +3 -6
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +8 -8
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +17 -11
- package/dist/core/ClientInteractions.d.ts +11 -1
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +26 -2
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +1 -0
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.js +6 -6
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +12 -4
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +112 -90
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +11 -26
- package/dist/core/DurableStatement.d.ts +4 -1
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +4 -4
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/EditMutations.d.ts.map +1 -1
- package/dist/core/EditMutations.js +5 -2
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/Engine.d.ts +11 -9
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +27 -65
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +2 -22
- package/dist/core/EnvFlags.d.ts.map +1 -1
- package/dist/core/EnvFlags.js +4 -2
- package/dist/core/EnvFlags.js.map +1 -1
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +2 -1
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +7 -12
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/Knob.d.ts +9 -0
- package/dist/core/Knob.d.ts.map +1 -0
- package/dist/core/Knob.js +50 -0
- package/dist/core/Knob.js.map +1 -0
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +6 -35
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +4 -0
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +2 -1
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LogWriter.js +2 -2
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LoopDriver.d.ts +1 -1
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +23 -29
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopLifecycle.d.ts +4 -17
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +20 -22
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +36 -49
- package/dist/core/LoopOutcome.d.ts +10 -0
- package/dist/core/LoopOutcome.d.ts.map +1 -0
- package/dist/core/LoopOutcome.js +28 -0
- package/dist/core/LoopOutcome.js.map +1 -0
- package/dist/core/LoopPolicies.d.ts +7 -0
- package/dist/core/LoopPolicies.d.ts.map +1 -0
- package/dist/core/LoopPolicies.js +37 -0
- package/dist/core/LoopPolicies.js.map +1 -0
- package/dist/core/MessageResources.d.ts +15 -0
- package/dist/core/MessageResources.d.ts.map +1 -0
- package/dist/core/MessageResources.js +46 -0
- package/dist/core/MessageResources.js.map +1 -0
- package/dist/core/MessageResources.sql +36 -0
- package/dist/core/OperatorConfig.d.ts +2 -1
- package/dist/core/OperatorConfig.d.ts.map +1 -1
- package/dist/core/OperatorConfig.js +14 -6
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +20 -35
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +24 -6
- package/dist/core/PatternSelection.d.ts +1 -1
- package/dist/core/PatternSelection.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.d.ts +3 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +85 -22
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProviderInstantiate.d.ts +1 -0
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +12 -7
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReasoningView.d.ts +1 -2
- package/dist/core/ReasoningView.d.ts.map +1 -1
- package/dist/core/ReasoningView.js +9 -20
- package/dist/core/ReasoningView.js.map +1 -1
- package/dist/core/ResourceBindings.d.ts.map +1 -1
- package/dist/core/ResourceBindings.js +5 -4
- package/dist/core/ResourceBindings.js.map +1 -1
- package/dist/core/ResourceMutations.d.ts +4 -4
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +2 -3
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.d.ts +10 -3
- package/dist/core/ResourceSelector.d.ts.map +1 -1
- package/dist/core/ResourceSelector.js +52 -13
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.d.ts.map +1 -1
- package/dist/core/ResourceTransfers.js +4 -2
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/SchemeRegistry.d.ts +2 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +11 -5
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StoredPacket.d.ts +3 -1
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +7 -3
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +9 -3
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/TerminalResult.d.ts +2 -2
- package/dist/core/TerminalResult.d.ts.map +1 -1
- package/dist/core/TerminalResult.js +15 -8
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/ToolInputSchema.d.ts.map +1 -1
- package/dist/core/ToolInputSchema.js +24 -8
- package/dist/core/ToolInputSchema.js.map +1 -1
- package/dist/core/ToolResources.d.ts +1 -0
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +45 -23
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.d.ts +3 -1
- package/dist/core/Turn.d.ts.map +1 -1
- package/dist/core/Turn.js +4 -1
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/Turn.sql +14 -2
- package/dist/core/TurnDispositionHandler.d.ts +13 -21
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +32 -190
- package/dist/core/TurnDispositionHandler.js.map +1 -1
- package/dist/core/TurnMaterialization.d.ts +9 -7
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +63 -41
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +23 -6
- package/dist/core/TurnOps.js +1 -1
- package/dist/core/TurnRunner.d.ts +1 -3
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +148 -189
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnRunner.sql +1 -24
- package/dist/core/TurnSources.sql +42 -11
- package/dist/core/WorkerName.d.ts +1 -1
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +3 -3
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/ambient.sql +45 -19
- package/dist/core/attachments.d.ts +3 -1
- package/dist/core/attachments.d.ts.map +1 -1
- package/dist/core/attachments.js +4 -0
- package/dist/core/attachments.js.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.js +4 -2
- package/dist/core/caps/CoreInteractionCaps.js.map +1 -1
- package/dist/core/caps/DbChannelCaps.js +6 -6
- package/dist/core/caps/DbChannelCaps.js.map +1 -1
- package/dist/core/caps/DbEntryCaps.js +1 -1
- package/dist/core/caps/DbEntryCaps.js.map +1 -1
- package/dist/core/caps/DbMessageCaps.d.ts +10 -0
- package/dist/core/caps/DbMessageCaps.d.ts.map +1 -0
- package/dist/core/caps/DbMessageCaps.js +39 -0
- package/dist/core/caps/DbMessageCaps.js.map +1 -0
- package/dist/core/caps/DbProjectionCaps.d.ts +2 -2
- package/dist/core/caps/DbProjectionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +10 -4
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +3 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +11 -0
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/fork.sql +7 -6
- package/dist/core/git-state.d.ts +3 -2
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +37 -20
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/packet-inject.js +1 -1
- package/dist/core/packet-wire.d.ts +11 -0
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +112 -88
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +4 -5
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +10 -31
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/scheme-types.d.ts +3 -1
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/teaching.d.ts.map +1 -1
- package/dist/core/teaching.js +2 -1
- package/dist/core/teaching.js.map +1 -1
- package/dist/core/types.d.ts +1 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-ops.sql +3 -8
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +35 -30
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +1 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +53 -1
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/DigestRequiem.d.ts.map +1 -1
- package/dist/digest/DigestRequiem.js +13 -15
- package/dist/digest/DigestRequiem.js.map +1 -1
- package/dist/digest/digest-db.d.ts +3 -0
- package/dist/digest/digest-db.d.ts.map +1 -0
- package/dist/digest/digest-db.js +68 -0
- package/dist/digest/digest-db.js.map +1 -0
- package/dist/digest/digest-paths.d.ts +6 -0
- package/dist/digest/digest-paths.d.ts.map +1 -0
- package/dist/digest/digest-paths.js +23 -0
- package/dist/digest/digest-paths.js.map +1 -0
- package/dist/digest/digest-rows.d.ts +15 -0
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +13 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/observe/genai.d.ts +2 -2
- package/dist/observe/genai.d.ts.map +1 -1
- package/dist/observe/genai.js +15 -5
- package/dist/observe/genai.js.map +1 -1
- package/dist/schemes/EffectPolicy.d.ts +0 -2
- package/dist/schemes/EffectPolicy.d.ts.map +1 -1
- package/dist/schemes/EffectPolicy.js +25 -36
- package/dist/schemes/EffectPolicy.js.map +1 -1
- package/dist/schemes/Exec.d.ts +4 -5
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +74 -62
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +6 -5
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +49 -16
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +28 -20
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts +4 -4
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +29 -9
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +14 -1
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/TurnSource.d.ts +3 -2
- package/dist/schemes/TurnSource.d.ts.map +1 -1
- package/dist/schemes/TurnSource.js +80 -35
- package/dist/schemes/TurnSource.js.map +1 -1
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +22 -56
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.js +6 -6
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +19 -17
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +6 -5
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-fts.d.ts.map +1 -1
- package/dist/schemes/_entry-fts.js +6 -3
- package/dist/schemes/_entry-fts.js.map +1 -1
- package/dist/schemes/_entry-fts.sql +25 -6
- package/dist/schemes/_entry-manifest.d.ts +1 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +5 -3
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-ops.js +4 -4
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +2 -2
- package/dist/schemes/_entry-readable.d.ts.map +1 -1
- package/dist/schemes/_entry-readable.js +5 -4
- package/dist/schemes/_entry-readable.js.map +1 -1
- package/dist/schemes/_entry-send.js +2 -2
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/schemes/_search-exclusion.d.ts +1 -0
- package/dist/schemes/_search-exclusion.d.ts.map +1 -1
- package/dist/schemes/_search-exclusion.js +12 -0
- package/dist/schemes/_search-exclusion.js.map +1 -1
- package/dist/schemes/_search-index.js +4 -4
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/exec-abort.d.ts.map +1 -1
- package/dist/schemes/exec-abort.js +4 -3
- package/dist/schemes/exec-abort.js.map +1 -1
- package/dist/schemes/exec-lifetime.d.ts +11 -0
- package/dist/schemes/exec-lifetime.d.ts.map +1 -0
- package/dist/schemes/exec-lifetime.js +29 -0
- package/dist/schemes/exec-lifetime.js.map +1 -0
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +3 -1
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +30 -7
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +107 -48
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +19 -5
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +13 -11
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +87 -98
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts +12 -3
- package/dist/server/EnvFunctionality.d.ts.map +1 -1
- package/dist/server/EnvFunctionality.js +19 -14
- package/dist/server/EnvFunctionality.js.map +1 -1
- package/dist/server/Functionality.d.ts +2 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +97 -62
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +3 -1
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +11 -5
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/HttpListener.d.ts +16 -0
- package/dist/server/HttpListener.d.ts.map +1 -0
- package/dist/server/HttpListener.js +81 -0
- package/dist/server/HttpListener.js.map +1 -0
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +12 -16
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/PlurnkSkill.d.ts.map +1 -1
- package/dist/server/PlurnkSkill.js +1 -0
- package/dist/server/PlurnkSkill.js.map +1 -1
- package/dist/server/Retention.d.ts +11 -0
- package/dist/server/Retention.d.ts.map +1 -1
- package/dist/server/Retention.js +47 -2
- package/dist/server/Retention.js.map +1 -1
- package/dist/server/Retention.sql +32 -1
- package/dist/server/ServiceModules.d.ts.map +1 -1
- package/dist/server/ServiceModules.js +2 -0
- package/dist/server/ServiceModules.js.map +1 -1
- package/dist/server/SkillsFunctionality.d.ts +2 -0
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +22 -15
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
- package/dist/server/WorkspaceCapabilities.js +1 -0
- package/dist/server/WorkspaceCapabilities.js.map +1 -1
- package/dist/server/WorkspaceStorage.d.ts +8 -0
- package/dist/server/WorkspaceStorage.d.ts.map +1 -0
- package/dist/server/WorkspaceStorage.js +26 -0
- package/dist/server/WorkspaceStorage.js.map +1 -0
- package/dist/server/client-input.d.ts +4 -3
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +24 -26
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +2 -2
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +69 -132
- package/dist/server/envelope.d.ts +2 -2
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +7 -9
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +10 -6
- package/dist/server/exec-poll-backoff.js +3 -3
- package/dist/server/exec-poll-backoff.js.map +1 -1
- package/dist/server/lifecycle-recovery.sql +8 -35
- package/dist/server/logEntry.sql +2 -2
- package/dist/server/loopDocs.js +3 -3
- package/dist/server/loopDocs.sql +4 -2
- package/dist/server/model-catalog.d.ts.map +1 -1
- package/dist/server/model-catalog.js +2 -2
- package/dist/server/model-catalog.js.map +1 -1
- package/dist/server/seam-loop.sql +0 -1
- package/dist/server/workspace-storage.sql +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +21 -10
- package/dist/service.js.map +1 -1
- package/docs/copy-move.md +31 -0
- package/docs/env.md +19 -7
- package/docs/skills.md +2 -2
- package/migrations/002_workers.sql +26 -17
- package/migrations/003_loops.sql +82 -28
- package/migrations/005_entries.sql +135 -22
- package/migrations/006_log.sql +77 -25
- package/migrations/007_subscriptions.sql +10 -15
- package/package.json +35 -36
- package/dist/core/PromptFrames.d.ts +0 -12
- package/dist/core/PromptFrames.d.ts.map +0 -1
- package/dist/core/PromptFrames.js +0 -28
- package/dist/core/PromptFrames.js.map +0 -1
- package/dist/schemes/Prompt.d.ts +0 -8
- package/dist/schemes/Prompt.d.ts.map +0 -1
- package/dist/schemes/Prompt.js +0 -25
- package/dist/schemes/Prompt.js.map +0 -1
package/dist/server/Daemon.js
CHANGED
|
@@ -23,13 +23,17 @@ import SkillsFunctionality from "./SkillsFunctionality.js";
|
|
|
23
23
|
import PlurnkSkill from "./PlurnkSkill.js";
|
|
24
24
|
import Skill from "../schemes/Skill.js";
|
|
25
25
|
import MembersFunctionality from "./MembersFunctionality.js";
|
|
26
|
-
import EnvFunctionality from "./EnvFunctionality.js";
|
|
26
|
+
import EnvFunctionality, { ENV_OWNER } from "./EnvFunctionality.js";
|
|
27
|
+
import HostPaths from "../core/HostPaths.js";
|
|
28
|
+
import WorkspaceStorage from "./WorkspaceStorage.js";
|
|
27
29
|
import Fork from "../core/fork.js";
|
|
28
30
|
import WorkerControlAddress from "../core/WorkerControlAddress.js";
|
|
29
|
-
import LoopLifecycle
|
|
31
|
+
import LoopLifecycle from "../core/LoopLifecycle.js";
|
|
32
|
+
import Knob from "../core/Knob.js";
|
|
33
|
+
import LoopPolicies from "../core/LoopPolicies.js";
|
|
30
34
|
import LoopPolicyReader from "../core/LoopPolicyReader.js";
|
|
31
|
-
import { promptLoopPrefix } from "../core/plurnk-uri.js";
|
|
32
35
|
import { contentWeight } from "../core/content-weight.js";
|
|
36
|
+
import MessageResources from "../core/MessageResources.js";
|
|
33
37
|
import { parseAliasesFromEnv, resolveActiveRoute } from "@plurnk/plurnk-providers";
|
|
34
38
|
import ProviderInstantiate from "../core/ProviderInstantiate.js";
|
|
35
39
|
import Results, { OperationFailureError } from "../core/results.js";
|
|
@@ -61,6 +65,9 @@ export default class Daemon {
|
|
|
61
65
|
#ownsMimetypes;
|
|
62
66
|
#provider;
|
|
63
67
|
#nodeModulesPath;
|
|
68
|
+
// {§http-host} — the one listener, bound by the service before durable admission; null in
|
|
69
|
+
// tests that never open a transport.
|
|
70
|
+
#http;
|
|
64
71
|
#discoveryCwd;
|
|
65
72
|
#started = false; // {§module-lifecycle}: one discovery/module boot; no listener
|
|
66
73
|
#modules = [];
|
|
@@ -78,8 +85,11 @@ export default class Daemon {
|
|
|
78
85
|
#eventSubscribers = new Set();
|
|
79
86
|
#workerModels;
|
|
80
87
|
#reads;
|
|
81
|
-
|
|
88
|
+
#storage;
|
|
89
|
+
constructor({ db, schemes, mimetypes, provider, nodeModulesPath, hostPaths = new HostPaths(), skills, http = null }) {
|
|
82
90
|
this.#db = db;
|
|
91
|
+
this.#http = http;
|
|
92
|
+
this.#storage = new WorkspaceStorage(db, hostPaths);
|
|
83
93
|
this.#lifecycle = new LoopLifecycle(db);
|
|
84
94
|
this.#schemes = schemes ?? new SchemeRegistry();
|
|
85
95
|
this.#provider = provider ?? null;
|
|
@@ -132,6 +142,7 @@ export default class Daemon {
|
|
|
132
142
|
// {§skills-functionality} — Core's own family: standard Agent Skills.
|
|
133
143
|
this.#skills = new SkillsFunctionality({
|
|
134
144
|
db,
|
|
145
|
+
hostPaths,
|
|
135
146
|
...skills,
|
|
136
147
|
provided: async () => {
|
|
137
148
|
const tree = await PlurnkSkill.load(this.#nodeModulesPath);
|
|
@@ -152,6 +163,7 @@ export default class Daemon {
|
|
|
152
163
|
// model-independent. Request-shaped token facts stay provider-owned.
|
|
153
164
|
weigh: contentWeight,
|
|
154
165
|
streamEventNotify: (workspaceId, event) => this.notifyStreamEvent(workspaceId, event),
|
|
166
|
+
operationSettledNotify: (workspaceId, logEntryId) => this.#drains.operationSettled(workspaceId, logEntryId),
|
|
155
167
|
reasoningEventNotify: (workspaceId, event) => this.notifyReasoningEvent(workspaceId, event),
|
|
156
168
|
wakeWorkerNotify: (payload) => this.#drains.notifyWakeWorker(payload),
|
|
157
169
|
// worker:// loop-start primitive — spawn/fork/irc deliver through
|
|
@@ -159,7 +171,7 @@ export default class Daemon {
|
|
|
159
171
|
// daemon owns provider + the law-file system prompt; the worker scheme
|
|
160
172
|
// handler carries neither. Fire-and-forget: the returned drain runs
|
|
161
173
|
// independently (the sister is its own worker). {§machine-processes}
|
|
162
|
-
injectWorker: async ({ workspaceId, workerId, sourceLoopId, prompt, freshLoopPolicy, spawn,
|
|
174
|
+
injectWorker: async ({ workspaceId, workerId, sourceLoopId, prompt, freshLoopPolicy, spawn, environment, attachments }) => {
|
|
163
175
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
164
176
|
const sender = await this.#db.drain_message_source.get({ loop_id: sourceLoopId });
|
|
165
177
|
if (sender === undefined || sender.workspace_id !== workspaceId) {
|
|
@@ -205,12 +217,13 @@ export default class Daemon {
|
|
|
205
217
|
await this.#functionality.invoke("env", "add", { alias, definition: { value } }, { workspaceId, workerId }, "operation");
|
|
206
218
|
}
|
|
207
219
|
}
|
|
208
|
-
const
|
|
220
|
+
const delivered = await this.#prepareMessage(workspaceId, workerId, prompt, attachments);
|
|
221
|
+
const { action, loopId } = await this.inject({
|
|
209
222
|
workspaceId,
|
|
210
223
|
workerId,
|
|
211
|
-
prompt,
|
|
224
|
+
prompt: delivered.body,
|
|
225
|
+
evidence: delivered.evidence,
|
|
212
226
|
sourceLoopId,
|
|
213
|
-
...(schedule === undefined ? {} : { schedule }),
|
|
214
227
|
...(source === undefined ? {} : { source }),
|
|
215
228
|
providerSpec,
|
|
216
229
|
reasoningPolicy,
|
|
@@ -218,7 +231,7 @@ export default class Daemon {
|
|
|
218
231
|
systemPrompt,
|
|
219
232
|
...(freshLoopPolicy === undefined ? {} : { freshLoopPolicy })
|
|
220
233
|
});
|
|
221
|
-
return { action, loopId
|
|
234
|
+
return { action, loopId };
|
|
222
235
|
},
|
|
223
236
|
acquireWorkspaceTurn: async (workspaceId, workerId, signal) => this.#workspaceGate.acquireTurn(workspaceId, workerId, signal),
|
|
224
237
|
// {§skills-hotload} — filesystem installers operate out of band.
|
|
@@ -230,7 +243,6 @@ export default class Daemon {
|
|
|
230
243
|
// worker:// KILL (terminate) — cancel the addressed worker subtree and
|
|
231
244
|
// tear down its held streams before the operation completes.
|
|
232
245
|
cancelWorker: async (workerId, reason) => this.#drains.cancelWorkerTree(workerId, reason),
|
|
233
|
-
cancelDescendants: async (workerId, reason) => this.#drains.cancelDescendants(workerId, reason),
|
|
234
246
|
noticeNotify: (workspaceId, payload) => this.notifyNotice(workspaceId, payload),
|
|
235
247
|
loopPacketNotify: (workspaceId, payload) => {
|
|
236
248
|
this.#broadcast({ workspaceId }, "loop/packet", payload);
|
|
@@ -240,7 +252,7 @@ export default class Daemon {
|
|
|
240
252
|
this.#drains = new DrainSupervisor({
|
|
241
253
|
db,
|
|
242
254
|
lifecycle: this.#lifecycle,
|
|
243
|
-
injectPrompt: (loopId, prompt, openPaths, source) => this.#engine.injectIntoLoop(loopId, prompt, openPaths, source),
|
|
255
|
+
injectPrompt: (loopId, prompt, openPaths, source, evidence, messageAddress) => this.#engine.injectIntoLoop(loopId, prompt, openPaths, source, evidence, messageAddress),
|
|
244
256
|
assertInjectionCompatibility: async ({ workerId, loopId, providerSpec, providerSpecExplicit, reasoningPolicy, childProviderSpec, turnCeiling, policy }) => {
|
|
245
257
|
await this.#assertFoldPosture(workerId, policy, loopId);
|
|
246
258
|
// An omitted selector keeps the loop's durable provider; only an
|
|
@@ -254,7 +266,7 @@ export default class Daemon {
|
|
|
254
266
|
}
|
|
255
267
|
await this.#assertLoopMaxTurns(loopId, turnCeiling?.source === "explicit" ? turnCeiling.effective : undefined);
|
|
256
268
|
},
|
|
257
|
-
|
|
269
|
+
reconcileMessages: (workerId, endedLoopId) => this.#reconcileOrphanedMessages(workerId, endedLoopId),
|
|
258
270
|
runLoop: async ({ workspaceId, workerId, loopId, maxTurns, prompt, systemPrompt, signal, onSettled }) => {
|
|
259
271
|
// The drain callback is the final provider/model boundary. Every
|
|
260
272
|
// admission path, including boot recovery, terminates here.
|
|
@@ -302,6 +314,7 @@ export default class Daemon {
|
|
|
302
314
|
const { workspaceId, ...proposal } = event;
|
|
303
315
|
this.#broadcast({ workspaceId }, "loop/proposal", proposal);
|
|
304
316
|
});
|
|
317
|
+
// {§notifications-loop-interaction} — the projection is the payload; its scope is the envelope's.
|
|
305
318
|
this.#engine.onClientInteractionPending((event) => {
|
|
306
319
|
const { workspaceId, ...interaction } = event;
|
|
307
320
|
this.#broadcast({ workspaceId }, "loop/interaction", interaction);
|
|
@@ -335,10 +348,28 @@ export default class Daemon {
|
|
|
335
348
|
const checkedWorkspaceId = ClientInput.assertId("pendingClientInteractions", "workspaceId", workspaceId);
|
|
336
349
|
return this.#engine.pendingClientInteractions(checkedWorkspaceId);
|
|
337
350
|
}
|
|
338
|
-
async resolveClientInteraction(interactionId, resolution) {
|
|
351
|
+
async resolveClientInteraction(interactionId, resolution, message) {
|
|
339
352
|
const checkedInteractionId = ClientInput.assertId("resolveClientInteraction", "interactionId", interactionId);
|
|
340
353
|
const checkedResolution = ClientInput.assertClientInteractionResolution("resolveClientInteraction", resolution);
|
|
341
|
-
|
|
354
|
+
if (message !== undefined) {
|
|
355
|
+
ClientInput.assertPrompt("resolveClientInteraction", message.body);
|
|
356
|
+
ClientInput.assertOptionalSource("resolveClientInteraction", message.source);
|
|
357
|
+
}
|
|
358
|
+
await this.#engine.resolveClientInteraction(checkedInteractionId, checkedResolution, message);
|
|
359
|
+
}
|
|
360
|
+
async #prepareMessage(workspaceId, workerId, body, attachments = [], envelope) {
|
|
361
|
+
const published = await MessageResources.publish(body, attachments, {
|
|
362
|
+
db: this.#db, workspaceId, workerId, loopId: 0, turnId: 0, writer: "_plurnk", signal: undefined,
|
|
363
|
+
weigh: contentWeight, mimetypes: this.#mimetypes,
|
|
364
|
+
});
|
|
365
|
+
return { body: published.body, evidence: {
|
|
366
|
+
...(envelope === undefined ? {} : { envelope: structuredClone(envelope) }),
|
|
367
|
+
...(published.attachments.length === 0 ? {} : { attachments: published.attachments }),
|
|
368
|
+
} };
|
|
369
|
+
}
|
|
370
|
+
async readMessages(args) {
|
|
371
|
+
await this.#assertModelWorker(args.workspaceId, args.workerId);
|
|
372
|
+
return MessageResources.read(this.#db, args);
|
|
342
373
|
}
|
|
343
374
|
// {§methods-loop-run} — drive/steer a loop. The module supplies only workspace/worker/prompt;
|
|
344
375
|
// the provider and the law-file system prompt are core's and stay inside. Returns immediately — the
|
|
@@ -348,8 +379,10 @@ export default class Daemon {
|
|
|
348
379
|
const workspaceId = ClientInput.assertId("runLoop", "workspaceId", args.workspaceId);
|
|
349
380
|
const workerId = ClientInput.assertId("runLoop", "workerId", args.workerId);
|
|
350
381
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
351
|
-
const
|
|
382
|
+
const attachments = ClientInput.assertMessageResources("runLoop", args.attachments);
|
|
383
|
+
const body = ClientInput.assertPrompt("runLoop", args.prompt, attachments.length > 0);
|
|
352
384
|
const source = ClientInput.assertOptionalSource("runLoop", args.source);
|
|
385
|
+
const messageAddress = ClientInput.assertOptionalSource("runLoop", args.messageAddress);
|
|
353
386
|
const requestedMaxTurns = ClientInput.assertMaxTurns("runLoop", args.maxTurns);
|
|
354
387
|
const openPaths = ClientInput.assertOpenPaths("runLoop", args.openPaths);
|
|
355
388
|
const selector = ClientInput.assertOptionalSelector("runLoop", "selector", args.selector);
|
|
@@ -376,17 +409,20 @@ export default class Daemon {
|
|
|
376
409
|
const systemPrompt = await readFile(Paths.instructionsSystem, "utf8");
|
|
377
410
|
// {§operator-config-max-turns-ceiling} — the operator ceiling clamps a per-call maxTurns; a
|
|
378
411
|
// seam caller must not bypass operator policy (inject only DEFAULTS from env, never clamps).
|
|
379
|
-
const ceiling =
|
|
412
|
+
const ceiling = Knob.integer("PLURNK_SERVICE_MAX_TURNS", -1);
|
|
380
413
|
const requested = requestedMaxTurns ?? ceiling;
|
|
381
414
|
const maxTurns = ceiling < 0 ? requested : (requested < 0 ? ceiling : Math.min(requested, ceiling));
|
|
382
415
|
const turnCeiling = {
|
|
383
416
|
effective: maxTurns,
|
|
384
417
|
source: requestedMaxTurns === undefined ? "implicit" : "explicit"
|
|
385
418
|
};
|
|
419
|
+
const delivered = await this.#prepareMessage(workspaceId, workerId, body, attachments, args.envelope);
|
|
386
420
|
const { action, loopId, turnSeq } = await this.inject({
|
|
387
421
|
workspaceId,
|
|
388
422
|
workerId,
|
|
389
|
-
prompt,
|
|
423
|
+
prompt: delivered.body,
|
|
424
|
+
evidence: delivered.evidence,
|
|
425
|
+
...(messageAddress === undefined ? {} : { messageAddress }),
|
|
390
426
|
...(source === undefined ? {} : { source }),
|
|
391
427
|
...(policy !== undefined ? { policy } : {}),
|
|
392
428
|
...(openPaths !== undefined ? { openPaths } : {}),
|
|
@@ -905,7 +941,6 @@ export default class Daemon {
|
|
|
905
941
|
promptSource: row.promptSource,
|
|
906
942
|
terminatedAt: row.terminatedAt,
|
|
907
943
|
packetCount: row.packetCount,
|
|
908
|
-
...taskTiming(row),
|
|
909
944
|
terminalResult: row.terminalResult === null
|
|
910
945
|
? null
|
|
911
946
|
: Validator.assertOperationResult(JSON.parse(row.terminalResult))
|
|
@@ -915,7 +950,7 @@ export default class Daemon {
|
|
|
915
950
|
listPrompts(workspaceId, limit) {
|
|
916
951
|
const checkedWorkspaceId = ClientInput.assertId("workspace.prompts", "workspaceId", workspaceId);
|
|
917
952
|
const checkedLimit = ClientInput.assertLimit("workspace.prompts", limit);
|
|
918
|
-
return Envelope.listPromptsForWorkspace(this.#db, checkedWorkspaceId, checkedLimit ??
|
|
953
|
+
return Envelope.listPromptsForWorkspace(this.#db, checkedWorkspaceId, checkedLimit ?? Knob.integer("PLURNK_SERVICE_PROMPTS_PAGE", 1));
|
|
919
954
|
}
|
|
920
955
|
workspaceDerivationStatus(workspaceId) {
|
|
921
956
|
return this.#engine.workspaceDerivationStatus(ClientInput.assertId("workspace.derivation", "workspaceId", workspaceId));
|
|
@@ -1036,6 +1071,18 @@ export default class Daemon {
|
|
|
1036
1071
|
scheme
|
|
1037
1072
|
};
|
|
1038
1073
|
}
|
|
1074
|
+
// {§http-host} — exterior adapters mount on the daemon's one listener at start(); the
|
|
1075
|
+
// daemon never opens a second transport, and a daemon without a listener says so.
|
|
1076
|
+
registerHttpRoute(prefix, handler) {
|
|
1077
|
+
if (this.#http === null)
|
|
1078
|
+
throw new Error(`registerHttpRoute: this daemon has no HTTP listener to mount '${prefix}' on`);
|
|
1079
|
+
this.#http.registerHttpRoute(prefix, handler);
|
|
1080
|
+
}
|
|
1081
|
+
httpAddress() {
|
|
1082
|
+
if (this.#http === null)
|
|
1083
|
+
throw new Error("httpAddress: this daemon has no HTTP listener");
|
|
1084
|
+
return this.#http.httpAddress();
|
|
1085
|
+
}
|
|
1039
1086
|
registerModuleAction(registration) {
|
|
1040
1087
|
const { name, scope, inputSchema, outputSchema, handler } = registration;
|
|
1041
1088
|
if (name.length === 0)
|
|
@@ -1112,9 +1159,24 @@ export default class Daemon {
|
|
|
1112
1159
|
registerWorkspaceCapabilityProvider(namespaceOwner, provider) {
|
|
1113
1160
|
this.#residency.registerProvider(namespaceOwner, provider);
|
|
1114
1161
|
}
|
|
1162
|
+
// {§module-functionality-adapter}
|
|
1115
1163
|
registerFunctionalityAdapter(adapter) {
|
|
1116
1164
|
return this.#functionality.register(adapter);
|
|
1117
1165
|
}
|
|
1166
|
+
async readWorkspaceEnvironment(workspaceId) {
|
|
1167
|
+
const snapshot = await EnvFunctionality.workspace(this.#db, workspaceId);
|
|
1168
|
+
return (ambient) => snapshot(ambient).env;
|
|
1169
|
+
}
|
|
1170
|
+
workspaceStateDirectory(workspaceId, namespaceOwner) {
|
|
1171
|
+
return this.#storage.directory(workspaceId, namespaceOwner);
|
|
1172
|
+
}
|
|
1173
|
+
async readWorkerEnvironment(workspaceId, workerId) {
|
|
1174
|
+
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
1175
|
+
const shared = await EnvFunctionality.workspace(this.#db, workspaceId);
|
|
1176
|
+
const row = await this.#db.worker_module_state_get.get({ worker_id: workerId, namespace_owner: ENV_OWNER });
|
|
1177
|
+
const state = row === undefined ? { version: 1, definitions: {} } : JSON.parse(row.state);
|
|
1178
|
+
return (ambient) => EnvFunctionality.compose(shared(ambient).env, state).env;
|
|
1179
|
+
}
|
|
1118
1180
|
async readWorkspaceModuleState(workspaceId, namespaceOwner) {
|
|
1119
1181
|
return this.#residency.readModuleState(workspaceId, namespaceOwner);
|
|
1120
1182
|
}
|
|
@@ -1134,6 +1196,11 @@ export default class Daemon {
|
|
|
1134
1196
|
if (this.#started)
|
|
1135
1197
|
throw new Error("daemon already started");
|
|
1136
1198
|
this.#started = true;
|
|
1199
|
+
// {§db-space-reclamation} — the file is brought to the policy's auto-vacuum mode before any work.
|
|
1200
|
+
const storage = await this.#retention.prepareStorage();
|
|
1201
|
+
if (storage.converted) {
|
|
1202
|
+
console.error(`database: converted to auto_vacuum=${this.#retention.policy.autoVacuum} (${storage.pagesBefore} → ${storage.pagesAfter} pages)`);
|
|
1203
|
+
}
|
|
1137
1204
|
this.#drains.start();
|
|
1138
1205
|
this.#retention.start((cause) => { console.error("retention pass failed:", cause instanceof Error ? cause.message : String(cause)); });
|
|
1139
1206
|
// Mimetypes owns its own discovery scan over @plurnk/plurnk-mimetypes-*
|
|
@@ -1165,6 +1232,7 @@ export default class Daemon {
|
|
|
1165
1232
|
}]);
|
|
1166
1233
|
// {§effect-policy-tunable} — invalid operator policy fails boot, not the first execution.
|
|
1167
1234
|
EffectPolicy.validateConfiguration();
|
|
1235
|
+
LoopPolicies.validateConfiguration();
|
|
1168
1236
|
// {§exec} — mint a scheme per runtime tag so exec output entries address by tag
|
|
1169
1237
|
// authority (sh:///l/t/s). The "exec" scheme stays for execution dispatch.
|
|
1170
1238
|
this.#schemes.registerRuntimeSchemes(executors);
|
|
@@ -1191,8 +1259,9 @@ export default class Daemon {
|
|
|
1191
1259
|
await this.#schemes.ready();
|
|
1192
1260
|
this.#residency.publish();
|
|
1193
1261
|
await this.#recoverLifecycle();
|
|
1194
|
-
// {§module-lifecycle} — the daemon
|
|
1195
|
-
// after capability publication and durable
|
|
1262
|
+
// {§module-lifecycle} — the daemon opened its one transport before admission ({§http-host});
|
|
1263
|
+
// modules mount their routes on it here, only after capability publication and durable
|
|
1264
|
+
// lifecycle recovery are complete. None opens a listener of its own.
|
|
1196
1265
|
for (const module of this.#modules) {
|
|
1197
1266
|
const started = await module.start?.(this);
|
|
1198
1267
|
if (started !== undefined && !this.#moduleClosers.includes(started)) {
|
|
@@ -1210,13 +1279,13 @@ export default class Daemon {
|
|
|
1210
1279
|
await this.#db.recovery_error_orphan_subscription_channels.run({});
|
|
1211
1280
|
await this.#db.recovery_fail_orphan_subscriptions.run({});
|
|
1212
1281
|
await this.#db.recovery_resume_unblocked_parks.run({});
|
|
1213
|
-
const orphanSources = await this.#db.
|
|
1282
|
+
const orphanSources = await this.#db.recovery_orphan_message_sources.all({});
|
|
1214
1283
|
const invalidOrphan = orphanSources.find(({ origin }) => origin !== "model");
|
|
1215
1284
|
if (invalidOrphan !== undefined) {
|
|
1216
1285
|
throw new Error(`Orphaned provider work belongs to ${invalidOrphan.origin} worker ${invalidOrphan.worker_id}; only model workers may enter inference.`);
|
|
1217
1286
|
}
|
|
1218
1287
|
for (const source of orphanSources) {
|
|
1219
|
-
await this.#drains.
|
|
1288
|
+
await this.#drains.reconcileOrphanedMessages(source.worker_id, source.loop_id);
|
|
1220
1289
|
}
|
|
1221
1290
|
const systemPrompt = await readFile(Paths.instructionsSystem, "utf8");
|
|
1222
1291
|
const queued = await this.#db.recovery_queued_workers.all({});
|
|
@@ -1245,15 +1314,11 @@ export default class Daemon {
|
|
|
1245
1314
|
await this.#drains.scheduleWakes(row.workspace_id, row.worker_id, systemPrompt);
|
|
1246
1315
|
}
|
|
1247
1316
|
}
|
|
1248
|
-
// {§crash-only-stop} — the settle deadline.
|
|
1249
|
-
//
|
|
1250
|
-
//
|
|
1317
|
+
// {§crash-only-stop} — the settle deadline. The panel owns the value; an operator can raise it
|
|
1318
|
+
// for slow hosts or lower it for tests. 0 is refused (an unbounded stop is exactly the wedge
|
|
1319
|
+
// this exists to prevent).
|
|
1251
1320
|
static #stopDeadlineMs() {
|
|
1252
|
-
|
|
1253
|
-
if (!Number.isSafeInteger(raw) || raw <= 0) {
|
|
1254
|
-
throw new Error(`PLURNK_SERVICE_STOP_TIMEOUT_MS must be a positive integer; got ${JSON.stringify(process.env.PLURNK_SERVICE_STOP_TIMEOUT_MS)}.`);
|
|
1255
|
-
}
|
|
1256
|
-
return raw;
|
|
1321
|
+
return Knob.integer("PLURNK_SERVICE_STOP_TIMEOUT_MS", 1);
|
|
1257
1322
|
}
|
|
1258
1323
|
async stop() {
|
|
1259
1324
|
if (!this.#started)
|
|
@@ -1353,7 +1418,7 @@ export default class Daemon {
|
|
|
1353
1418
|
// (SSE, WS) add themselves here as they land.
|
|
1354
1419
|
async #drainStreamingSchemes() {
|
|
1355
1420
|
const exec = this.#schemes.get("exec");
|
|
1356
|
-
// {§exec-
|
|
1421
|
+
// {§exec-lifetime} — a detached spawn ends with the daemon: nothing else ever aborts it.
|
|
1357
1422
|
exec?.abortDetached?.();
|
|
1358
1423
|
if (exec?.idle !== undefined)
|
|
1359
1424
|
await exec.idle();
|
|
@@ -1403,40 +1468,34 @@ export default class Daemon {
|
|
|
1403
1468
|
inject(args) {
|
|
1404
1469
|
return this.#drains.inject(args);
|
|
1405
1470
|
}
|
|
1406
|
-
// Durable
|
|
1471
|
+
// Durable message promotion remains daemon policy; DrainSupervisor invokes
|
|
1407
1472
|
// it under the same worker lock as enqueue and drain teardown.
|
|
1408
|
-
async #
|
|
1409
|
-
const
|
|
1410
|
-
const
|
|
1411
|
-
const frames = await this.#db.drain_orphaned_prompts_for_loop.all({ loop_id: endedLoopId, worker_id: workerId, pattern: `${prefix}%`, prefix_len: prefix.length });
|
|
1412
|
-
const first = frames[0];
|
|
1473
|
+
async #reconcileOrphanedMessages(workerId, endedLoopId) {
|
|
1474
|
+
const messages = await this.#db.drain_orphaned_messages_for_loop.all({ loop_id: endedLoopId });
|
|
1475
|
+
const first = messages[0];
|
|
1413
1476
|
if (first === undefined)
|
|
1414
1477
|
return;
|
|
1415
1478
|
const recovery = await this.#db.drain_enqueue_orphan_recovery_loop.get({
|
|
1416
1479
|
worker_id: workerId,
|
|
1417
1480
|
prompt: first.body,
|
|
1418
|
-
prompt_source: first.
|
|
1481
|
+
prompt_source: first.source,
|
|
1419
1482
|
policy: first.policy,
|
|
1420
1483
|
model_route_id: first.model_route_id,
|
|
1421
1484
|
spawn_model_route_id: first.spawn_model_route_id,
|
|
1422
1485
|
reasoning_policy: first.reasoning_policy,
|
|
1423
1486
|
max_turns: first.max_turns,
|
|
1424
|
-
open_paths: first.open_paths ?? "[]",
|
|
1425
1487
|
orphan_source_loop_id: endedLoopId
|
|
1426
1488
|
});
|
|
1427
1489
|
if (recovery === undefined)
|
|
1428
|
-
throw new Error("
|
|
1490
|
+
throw new Error("reconcileOrphanedMessages: enqueue returned no row");
|
|
1429
1491
|
if (recovery.status !== 100)
|
|
1430
1492
|
return;
|
|
1431
|
-
const moved = await this.#db.
|
|
1432
|
-
worker_id: workerId,
|
|
1493
|
+
const moved = await this.#db.drain_rehome_orphaned_messages.all({
|
|
1433
1494
|
source_loop_id: endedLoopId,
|
|
1434
|
-
|
|
1435
|
-
source_prefix_len: prefix.length,
|
|
1436
|
-
target_prefix: promptLoopPrefix(recovery.sequence)
|
|
1495
|
+
target_loop_id: recovery.id
|
|
1437
1496
|
});
|
|
1438
|
-
if (moved.length !==
|
|
1439
|
-
throw new Error(`
|
|
1497
|
+
if (moved.length !== messages.length) {
|
|
1498
|
+
throw new Error(`reconcileOrphanedMessages: expected to re-home ${messages.length} messages, moved ${moved.length}`);
|
|
1440
1499
|
}
|
|
1441
1500
|
}
|
|
1442
1501
|
cancelDrain(workerId, reason = "user_cancelled") {
|