@plurnk/plurnk-service 1.17.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 +95 -14
- package/README.md +5 -3
- package/SPEC.md +1756 -1442
- 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 +81 -39
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/read-resolve.d.ts +1 -0
- package/dist/content/read-resolve.d.ts.map +1 -1
- package/dist/content/read-resolve.js +13 -10
- package/dist/content/read-resolve.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 -2
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +26 -26
- 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 +46 -36
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +4 -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.d.ts.map +1 -1
- package/dist/core/DataStatementRunner.js +198 -148
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +18 -5
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +135 -114
- 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/ExecutionOutputs.sql +8 -0
- package/dist/core/ExecutorRegistry.d.ts +4 -0
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +3 -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 +8 -36
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +8 -10
- 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.d.ts.map +1 -1
- package/dist/core/LogWriter.js +11 -9
- 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 +24 -32
- 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/ModelCall.d.ts.map +1 -1
- package/dist/core/ModelCall.js +2 -6
- package/dist/core/ModelCall.js.map +1 -1
- package/dist/core/ModelCall.sql +7 -36
- 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 +93 -28
- 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/RuntimeWorker.d.ts.map +1 -1
- package/dist/core/RuntimeWorker.js +6 -1
- package/dist/core/RuntimeWorker.js.map +1 -1
- package/dist/core/RuntimeWorker.sql +7 -1
- package/dist/core/SchemeRegistry.d.ts +2 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +12 -6
- 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 +2 -2
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +15 -7
- 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 +50 -26
- 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 -23
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +30 -180
- 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 +66 -46
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +23 -6
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +2 -2
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +2 -8
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +1116 -1123
- 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/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +23 -0
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +3 -6
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +10 -26
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkspaceGate.js +4 -4
- package/dist/core/WorkspaceGate.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/env-catalog.d.ts +28 -0
- package/dist/core/env-catalog.d.ts.map +1 -0
- package/dist/core/env-catalog.js +99 -0
- package/dist/core/env-catalog.js.map +1 -0
- package/dist/core/file-materialization.js +1 -1
- package/dist/core/file-materialization.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 +38 -21
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/operation-target-groups.d.ts.map +1 -1
- package/dist/core/operation-target-groups.js +2 -1
- package/dist/core/operation-target-groups.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 +382 -333
- 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 +37 -30
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +2 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +97 -9
- 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 +21 -0
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +24 -5
- 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 +129 -82
- 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/ExecScheduler.js +2 -2
- package/dist/schemes/ExecScheduler.js.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +30 -21
- 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 +30 -10
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +15 -2
- 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 +87 -41
- 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 +37 -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 +10 -17
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-manifest.sql +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.d.ts +5 -1
- package/dist/schemes/_search-index.d.ts.map +1 -1
- package/dist/schemes/_search-index.js +99 -59
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/_search-index.sql +17 -0
- package/dist/schemes/exec-abort.d.ts.map +1 -1
- package/dist/schemes/exec-abort.js +5 -4
- package/dist/schemes/exec-abort.js.map +1 -1
- package/dist/schemes/exec-env.d.ts +3 -0
- package/dist/schemes/exec-env.d.ts.map +1 -1
- package/dist/schemes/exec-env.js +66 -15
- package/dist/schemes/exec-env.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/schemes/exec-runtime.d.ts +1 -1
- package/dist/schemes/exec-runtime.d.ts.map +1 -1
- package/dist/schemes/exec-runtime.js +1 -1
- package/dist/schemes/exec-runtime.js.map +1 -1
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +5 -2
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +31 -7
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +137 -60
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +25 -6
- 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 +52 -0
- package/dist/server/EnvFunctionality.d.ts.map +1 -0
- package/dist/server/EnvFunctionality.js +199 -0
- package/dist/server/EnvFunctionality.js.map +1 -0
- package/dist/server/Functionality.d.ts +4 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +250 -106
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +5 -1
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +24 -8
- 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 -17
- 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 +14 -0
- package/dist/server/Retention.d.ts.map +1 -1
- package/dist/server/Retention.js +52 -4
- package/dist/server/Retention.js.map +1 -1
- package/dist/server/Retention.sql +55 -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 +27 -17
- 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/WorkspaceResidency.d.ts +2 -0
- package/dist/server/WorkspaceResidency.d.ts.map +1 -1
- package/dist/server/WorkspaceResidency.js +27 -0
- package/dist/server/WorkspaceResidency.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 +25 -27
- 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 -3
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +7 -21
- 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 +12 -38
- 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-capabilities.sql +45 -0
- package/dist/server/workspace-storage.sql +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +37 -11
- package/dist/service.js.map +1 -1
- package/docs/copy-move.md +31 -0
- package/docs/env.md +67 -0
- package/docs/members.md +4 -4
- package/docs/skills.md +2 -2
- package/migrations/002_workers.sql +41 -17
- package/migrations/003_loops.sql +82 -28
- package/migrations/004_inference.sql +53 -12
- package/migrations/005_entries.sql +135 -14
- package/migrations/006_log.sql +79 -24
- package/migrations/007_subscriptions.sql +10 -15
- package/package.json +45 -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,12 +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, { ENV_OWNER } from "./EnvFunctionality.js";
|
|
27
|
+
import HostPaths from "../core/HostPaths.js";
|
|
28
|
+
import WorkspaceStorage from "./WorkspaceStorage.js";
|
|
26
29
|
import Fork from "../core/fork.js";
|
|
27
30
|
import WorkerControlAddress from "../core/WorkerControlAddress.js";
|
|
28
|
-
import LoopLifecycle
|
|
31
|
+
import LoopLifecycle from "../core/LoopLifecycle.js";
|
|
32
|
+
import Knob from "../core/Knob.js";
|
|
33
|
+
import LoopPolicies from "../core/LoopPolicies.js";
|
|
29
34
|
import LoopPolicyReader from "../core/LoopPolicyReader.js";
|
|
30
|
-
import { promptLoopPrefix } from "../core/plurnk-uri.js";
|
|
31
35
|
import { contentWeight } from "../core/content-weight.js";
|
|
36
|
+
import MessageResources from "../core/MessageResources.js";
|
|
32
37
|
import { parseAliasesFromEnv, resolveActiveRoute } from "@plurnk/plurnk-providers";
|
|
33
38
|
import ProviderInstantiate from "../core/ProviderInstantiate.js";
|
|
34
39
|
import Results, { OperationFailureError } from "../core/results.js";
|
|
@@ -60,6 +65,9 @@ export default class Daemon {
|
|
|
60
65
|
#ownsMimetypes;
|
|
61
66
|
#provider;
|
|
62
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;
|
|
63
71
|
#discoveryCwd;
|
|
64
72
|
#started = false; // {§module-lifecycle}: one discovery/module boot; no listener
|
|
65
73
|
#modules = [];
|
|
@@ -77,8 +85,11 @@ export default class Daemon {
|
|
|
77
85
|
#eventSubscribers = new Set();
|
|
78
86
|
#workerModels;
|
|
79
87
|
#reads;
|
|
80
|
-
|
|
88
|
+
#storage;
|
|
89
|
+
constructor({ db, schemes, mimetypes, provider, nodeModulesPath, hostPaths = new HostPaths(), skills, http = null }) {
|
|
81
90
|
this.#db = db;
|
|
91
|
+
this.#http = http;
|
|
92
|
+
this.#storage = new WorkspaceStorage(db, hostPaths);
|
|
82
93
|
this.#lifecycle = new LoopLifecycle(db);
|
|
83
94
|
this.#schemes = schemes ?? new SchemeRegistry();
|
|
84
95
|
this.#provider = provider ?? null;
|
|
@@ -123,12 +134,15 @@ export default class Daemon {
|
|
|
123
134
|
registerWorkspaceCapabilityProvider: (owner, provider) => this.registerWorkspaceCapabilityProvider(owner, provider),
|
|
124
135
|
readWorkspaceModuleState: (workspaceId, owner) => this.readWorkspaceModuleState(workspaceId, owner),
|
|
125
136
|
replaceWorkspaceCapabilities: (replacement, options) => this.replaceWorkspaceCapabilities(replacement, options),
|
|
137
|
+
readWorkerModuleState: (workerId, owner) => this.#residency.readWorkerModuleState(workerId, owner),
|
|
138
|
+
replaceWorkerModuleState: (workerId, owner, state) => this.#residency.replaceWorkerModuleState(workerId, owner, state),
|
|
126
139
|
mutateWorkspace: (workspaceId, owner, caller, run) => this.#residency.exclusively(workspaceId, owner, caller === "operation" ? "wait" : "try", run),
|
|
127
140
|
retainWorkspace: (workspaceId) => this.#residency.retain(workspaceId)
|
|
128
141
|
});
|
|
129
142
|
// {§skills-functionality} — Core's own family: standard Agent Skills.
|
|
130
143
|
this.#skills = new SkillsFunctionality({
|
|
131
144
|
db,
|
|
145
|
+
hostPaths,
|
|
132
146
|
...skills,
|
|
133
147
|
provided: async () => {
|
|
134
148
|
const tree = await PlurnkSkill.load(this.#nodeModulesPath);
|
|
@@ -140,6 +154,8 @@ export default class Daemon {
|
|
|
140
154
|
// {§members-functionality} — Core's own family: file membership on the same surface.
|
|
141
155
|
this.#members = new MembersFunctionality({ db, engine: () => this.#engine });
|
|
142
156
|
this.#functionality.register(this.#members);
|
|
157
|
+
// {§env-functionality} — Core's own family: the environment a Worker's commands run in.
|
|
158
|
+
this.#functionality.register(new EnvFunctionality(EnvFunctionality.defaultsReader(Paths.packageRoot, this.#nodeModulesPath)));
|
|
143
159
|
this.#engine = new Engine({
|
|
144
160
|
db, lifecycle: this.#lifecycle, schemes: this.#schemes, mimetypes: this.#mimetypes,
|
|
145
161
|
// {§tokenomics-agnostic-ruler} — stored and catalog curation weights
|
|
@@ -147,6 +163,7 @@ export default class Daemon {
|
|
|
147
163
|
// model-independent. Request-shaped token facts stay provider-owned.
|
|
148
164
|
weigh: contentWeight,
|
|
149
165
|
streamEventNotify: (workspaceId, event) => this.notifyStreamEvent(workspaceId, event),
|
|
166
|
+
operationSettledNotify: (workspaceId, logEntryId) => this.#drains.operationSettled(workspaceId, logEntryId),
|
|
150
167
|
reasoningEventNotify: (workspaceId, event) => this.notifyReasoningEvent(workspaceId, event),
|
|
151
168
|
wakeWorkerNotify: (payload) => this.#drains.notifyWakeWorker(payload),
|
|
152
169
|
// worker:// loop-start primitive — spawn/fork/irc deliver through
|
|
@@ -154,7 +171,7 @@ export default class Daemon {
|
|
|
154
171
|
// daemon owns provider + the law-file system prompt; the worker scheme
|
|
155
172
|
// handler carries neither. Fire-and-forget: the returned drain runs
|
|
156
173
|
// independently (the sister is its own worker). {§machine-processes}
|
|
157
|
-
injectWorker: async ({ workspaceId, workerId, sourceLoopId, prompt, freshLoopPolicy, spawn,
|
|
174
|
+
injectWorker: async ({ workspaceId, workerId, sourceLoopId, prompt, freshLoopPolicy, spawn, environment, attachments }) => {
|
|
158
175
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
159
176
|
const sender = await this.#db.drain_message_source.get({ loop_id: sourceLoopId });
|
|
160
177
|
if (sender === undefined || sender.workspace_id !== workspaceId) {
|
|
@@ -193,13 +210,20 @@ export default class Daemon {
|
|
|
193
210
|
reasoning_policy: reasoningPolicy,
|
|
194
211
|
reasoning_source: "default"
|
|
195
212
|
});
|
|
213
|
+
// {§env-option} — the heading's environment lands as the child's own entries through the
|
|
214
|
+
// family's add, after the copy it inherited at creation ({§functionality-scope}); names
|
|
215
|
+
// were admitted at the operation, so a refusal here is a defect and throws.
|
|
216
|
+
for (const [alias, value] of Object.entries(environment ?? {})) {
|
|
217
|
+
await this.#functionality.invoke("env", "add", { alias, definition: { value } }, { workspaceId, workerId }, "operation");
|
|
218
|
+
}
|
|
196
219
|
}
|
|
197
|
-
const
|
|
220
|
+
const delivered = await this.#prepareMessage(workspaceId, workerId, prompt, attachments);
|
|
221
|
+
const { action, loopId } = await this.inject({
|
|
198
222
|
workspaceId,
|
|
199
223
|
workerId,
|
|
200
|
-
prompt,
|
|
224
|
+
prompt: delivered.body,
|
|
225
|
+
evidence: delivered.evidence,
|
|
201
226
|
sourceLoopId,
|
|
202
|
-
...(schedule === undefined ? {} : { schedule }),
|
|
203
227
|
...(source === undefined ? {} : { source }),
|
|
204
228
|
providerSpec,
|
|
205
229
|
reasoningPolicy,
|
|
@@ -207,7 +231,7 @@ export default class Daemon {
|
|
|
207
231
|
systemPrompt,
|
|
208
232
|
...(freshLoopPolicy === undefined ? {} : { freshLoopPolicy })
|
|
209
233
|
});
|
|
210
|
-
return { action, loopId
|
|
234
|
+
return { action, loopId };
|
|
211
235
|
},
|
|
212
236
|
acquireWorkspaceTurn: async (workspaceId, workerId, signal) => this.#workspaceGate.acquireTurn(workspaceId, workerId, signal),
|
|
213
237
|
// {§skills-hotload} — filesystem installers operate out of band.
|
|
@@ -219,7 +243,6 @@ export default class Daemon {
|
|
|
219
243
|
// worker:// KILL (terminate) — cancel the addressed worker subtree and
|
|
220
244
|
// tear down its held streams before the operation completes.
|
|
221
245
|
cancelWorker: async (workerId, reason) => this.#drains.cancelWorkerTree(workerId, reason),
|
|
222
|
-
cancelDescendants: async (workerId, reason) => this.#drains.cancelDescendants(workerId, reason),
|
|
223
246
|
noticeNotify: (workspaceId, payload) => this.notifyNotice(workspaceId, payload),
|
|
224
247
|
loopPacketNotify: (workspaceId, payload) => {
|
|
225
248
|
this.#broadcast({ workspaceId }, "loop/packet", payload);
|
|
@@ -229,7 +252,7 @@ export default class Daemon {
|
|
|
229
252
|
this.#drains = new DrainSupervisor({
|
|
230
253
|
db,
|
|
231
254
|
lifecycle: this.#lifecycle,
|
|
232
|
-
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),
|
|
233
256
|
assertInjectionCompatibility: async ({ workerId, loopId, providerSpec, providerSpecExplicit, reasoningPolicy, childProviderSpec, turnCeiling, policy }) => {
|
|
234
257
|
await this.#assertFoldPosture(workerId, policy, loopId);
|
|
235
258
|
// An omitted selector keeps the loop's durable provider; only an
|
|
@@ -243,7 +266,7 @@ export default class Daemon {
|
|
|
243
266
|
}
|
|
244
267
|
await this.#assertLoopMaxTurns(loopId, turnCeiling?.source === "explicit" ? turnCeiling.effective : undefined);
|
|
245
268
|
},
|
|
246
|
-
|
|
269
|
+
reconcileMessages: (workerId, endedLoopId) => this.#reconcileOrphanedMessages(workerId, endedLoopId),
|
|
247
270
|
runLoop: async ({ workspaceId, workerId, loopId, maxTurns, prompt, systemPrompt, signal, onSettled }) => {
|
|
248
271
|
// The drain callback is the final provider/model boundary. Every
|
|
249
272
|
// admission path, including boot recovery, terminates here.
|
|
@@ -291,6 +314,7 @@ export default class Daemon {
|
|
|
291
314
|
const { workspaceId, ...proposal } = event;
|
|
292
315
|
this.#broadcast({ workspaceId }, "loop/proposal", proposal);
|
|
293
316
|
});
|
|
317
|
+
// {§notifications-loop-interaction} — the projection is the payload; its scope is the envelope's.
|
|
294
318
|
this.#engine.onClientInteractionPending((event) => {
|
|
295
319
|
const { workspaceId, ...interaction } = event;
|
|
296
320
|
this.#broadcast({ workspaceId }, "loop/interaction", interaction);
|
|
@@ -324,10 +348,28 @@ export default class Daemon {
|
|
|
324
348
|
const checkedWorkspaceId = ClientInput.assertId("pendingClientInteractions", "workspaceId", workspaceId);
|
|
325
349
|
return this.#engine.pendingClientInteractions(checkedWorkspaceId);
|
|
326
350
|
}
|
|
327
|
-
async resolveClientInteraction(interactionId, resolution) {
|
|
351
|
+
async resolveClientInteraction(interactionId, resolution, message) {
|
|
328
352
|
const checkedInteractionId = ClientInput.assertId("resolveClientInteraction", "interactionId", interactionId);
|
|
329
353
|
const checkedResolution = ClientInput.assertClientInteractionResolution("resolveClientInteraction", resolution);
|
|
330
|
-
|
|
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);
|
|
331
373
|
}
|
|
332
374
|
// {§methods-loop-run} — drive/steer a loop. The module supplies only workspace/worker/prompt;
|
|
333
375
|
// the provider and the law-file system prompt are core's and stay inside. Returns immediately — the
|
|
@@ -337,8 +379,10 @@ export default class Daemon {
|
|
|
337
379
|
const workspaceId = ClientInput.assertId("runLoop", "workspaceId", args.workspaceId);
|
|
338
380
|
const workerId = ClientInput.assertId("runLoop", "workerId", args.workerId);
|
|
339
381
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
340
|
-
const
|
|
382
|
+
const attachments = ClientInput.assertMessageResources("runLoop", args.attachments);
|
|
383
|
+
const body = ClientInput.assertPrompt("runLoop", args.prompt, attachments.length > 0);
|
|
341
384
|
const source = ClientInput.assertOptionalSource("runLoop", args.source);
|
|
385
|
+
const messageAddress = ClientInput.assertOptionalSource("runLoop", args.messageAddress);
|
|
342
386
|
const requestedMaxTurns = ClientInput.assertMaxTurns("runLoop", args.maxTurns);
|
|
343
387
|
const openPaths = ClientInput.assertOpenPaths("runLoop", args.openPaths);
|
|
344
388
|
const selector = ClientInput.assertOptionalSelector("runLoop", "selector", args.selector);
|
|
@@ -365,17 +409,20 @@ export default class Daemon {
|
|
|
365
409
|
const systemPrompt = await readFile(Paths.instructionsSystem, "utf8");
|
|
366
410
|
// {§operator-config-max-turns-ceiling} — the operator ceiling clamps a per-call maxTurns; a
|
|
367
411
|
// seam caller must not bypass operator policy (inject only DEFAULTS from env, never clamps).
|
|
368
|
-
const ceiling =
|
|
412
|
+
const ceiling = Knob.integer("PLURNK_SERVICE_MAX_TURNS", -1);
|
|
369
413
|
const requested = requestedMaxTurns ?? ceiling;
|
|
370
414
|
const maxTurns = ceiling < 0 ? requested : (requested < 0 ? ceiling : Math.min(requested, ceiling));
|
|
371
415
|
const turnCeiling = {
|
|
372
416
|
effective: maxTurns,
|
|
373
417
|
source: requestedMaxTurns === undefined ? "implicit" : "explicit"
|
|
374
418
|
};
|
|
419
|
+
const delivered = await this.#prepareMessage(workspaceId, workerId, body, attachments, args.envelope);
|
|
375
420
|
const { action, loopId, turnSeq } = await this.inject({
|
|
376
421
|
workspaceId,
|
|
377
422
|
workerId,
|
|
378
|
-
prompt,
|
|
423
|
+
prompt: delivered.body,
|
|
424
|
+
evidence: delivered.evidence,
|
|
425
|
+
...(messageAddress === undefined ? {} : { messageAddress }),
|
|
379
426
|
...(source === undefined ? {} : { source }),
|
|
380
427
|
...(policy !== undefined ? { policy } : {}),
|
|
381
428
|
...(openPaths !== undefined ? { openPaths } : {}),
|
|
@@ -510,7 +557,7 @@ export default class Daemon {
|
|
|
510
557
|
async readWorkerModel(args) {
|
|
511
558
|
const workspaceId = ClientInput.assertId("worker.model.get", "workspaceId", args.workspaceId);
|
|
512
559
|
const workerId = ClientInput.assertId("worker.model.get", "workerId", args.workerId);
|
|
513
|
-
await this.#
|
|
560
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
514
561
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
515
562
|
if (row === undefined)
|
|
516
563
|
throw new Error(`worker ${workerId}: model route row missing`);
|
|
@@ -526,7 +573,7 @@ export default class Daemon {
|
|
|
526
573
|
async setWorkerModel(args) {
|
|
527
574
|
const workspaceId = ClientInput.assertId("worker.model.set", "workspaceId", args.workspaceId);
|
|
528
575
|
const workerId = ClientInput.assertId("worker.model.set", "workerId", args.workerId);
|
|
529
|
-
await this.#
|
|
576
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
530
577
|
const selector = ClientInput.assertSelector("worker.model.set", "selector", args.selector);
|
|
531
578
|
const policy = await this.#workerModels.resolveWorkerModel(workerId, selector);
|
|
532
579
|
if (policy === null) {
|
|
@@ -539,7 +586,7 @@ export default class Daemon {
|
|
|
539
586
|
async readWorkerReasoning(args) {
|
|
540
587
|
const workspaceId = ClientInput.assertId("worker.reasoning.get", "workspaceId", args.workspaceId);
|
|
541
588
|
const workerId = ClientInput.assertId("worker.reasoning.get", "workerId", args.workerId);
|
|
542
|
-
await this.#
|
|
589
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
543
590
|
await this.#workerModels.resolveWorkerModel(workerId, undefined);
|
|
544
591
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
545
592
|
if (row === undefined)
|
|
@@ -571,7 +618,7 @@ export default class Daemon {
|
|
|
571
618
|
catch (cause) {
|
|
572
619
|
throw daemonFailure("daemon:input", "reasoning-policy-invalid", 400, cause instanceof Error ? cause.message : "The reasoning policy is invalid.", { field: "policy", retryable: false });
|
|
573
620
|
}
|
|
574
|
-
await this.#
|
|
621
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
575
622
|
await this.#workerModels.resolveWorkerModel(workerId, undefined);
|
|
576
623
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
577
624
|
if (row === undefined)
|
|
@@ -598,7 +645,7 @@ export default class Daemon {
|
|
|
598
645
|
async setWorkerSpawnModel(args) {
|
|
599
646
|
const workspaceId = ClientInput.assertId("worker.child.set", "workspaceId", args.workspaceId);
|
|
600
647
|
const workerId = ClientInput.assertId("worker.child.set", "workerId", args.workerId);
|
|
601
|
-
await this.#
|
|
648
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
602
649
|
const selector = ClientInput.assertChildSelector("worker.child.set", args.selector);
|
|
603
650
|
const spec = await this.#workerModels.resolveWorkerSpawnModel(workerId, selector);
|
|
604
651
|
if (spec === null)
|
|
@@ -616,8 +663,9 @@ export default class Daemon {
|
|
|
616
663
|
}
|
|
617
664
|
}
|
|
618
665
|
// {§machine-processes} — provider inference is an exclusive capability of a
|
|
619
|
-
// model worker. The same assertion is used by early client admissions
|
|
620
|
-
//
|
|
666
|
+
// model worker. The same assertion is used by early client admissions, the final
|
|
667
|
+
// drain callback, and the model, reasoning, and spawn-model controls
|
|
668
|
+
// ({§worker-model-selection}), so recovery and internal callers cannot bypass it.
|
|
621
669
|
async #assertModelWorker(workspaceId, workerId) {
|
|
622
670
|
const worker = await this.#db.envelope_get_worker_by_id.get({ id: workerId });
|
|
623
671
|
if (worker === undefined) {
|
|
@@ -635,7 +683,7 @@ export default class Daemon {
|
|
|
635
683
|
throw daemonFailure("daemon:worker", "model-worker-required", 409, `Worker ${workerId} is not a model worker.`, {
|
|
636
684
|
workerId,
|
|
637
685
|
actualOrigin: worker.origin,
|
|
638
|
-
recovery: "Select or create a model worker
|
|
686
|
+
recovery: "Select or create a model worker.",
|
|
639
687
|
retryable: false
|
|
640
688
|
});
|
|
641
689
|
}
|
|
@@ -764,11 +812,17 @@ export default class Daemon {
|
|
|
764
812
|
// dispatchClientAction). Its closed observation segment supplies the numeric loop coordinate
|
|
765
813
|
// required by plugin context and relative log:/// addresses without impersonating an active
|
|
766
814
|
// client lifecycle. It creates no turn or log row. Engine.look enforces READ-only.
|
|
815
|
+
// {§op-look} — the segment is the acting worker's; the READ resolves as the perspective worker.
|
|
767
816
|
async look(args) {
|
|
768
817
|
const workspaceId = ClientInput.assertId("operation.look", "workspaceId", args.workspaceId);
|
|
769
818
|
const workerId = ClientInput.assertId("operation.look", "workerId", args.workerId);
|
|
819
|
+
const perspective = args.perspectiveWorkerId === undefined
|
|
820
|
+
? workerId
|
|
821
|
+
: ClientInput.assertId("operation.look", "perspectiveWorkerId", args.perspectiveWorkerId);
|
|
770
822
|
const { statement } = args;
|
|
771
823
|
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
824
|
+
if (perspective !== workerId)
|
|
825
|
+
await this.#assertWorkerOwned(workspaceId, perspective);
|
|
772
826
|
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
773
827
|
try {
|
|
774
828
|
const releaseWorkspace = await this.#workspaceGate.acquireTurn(workspaceId, workerId);
|
|
@@ -776,7 +830,7 @@ export default class Daemon {
|
|
|
776
830
|
await this.#residency.reconcile(workspaceId);
|
|
777
831
|
const clientLoopId = await Envelope.ensureClientLoop(this.#db, workerId);
|
|
778
832
|
try {
|
|
779
|
-
const result = await this.#engine.look({ statement, workspaceId, workerId, loopId: clientLoopId });
|
|
833
|
+
const result = await this.#engine.look({ statement, workspaceId, workerId: perspective, loopId: clientLoopId });
|
|
780
834
|
await Envelope.closeClientLoop(this.#db, clientLoopId, { status: 200 });
|
|
781
835
|
return result;
|
|
782
836
|
}
|
|
@@ -887,7 +941,6 @@ export default class Daemon {
|
|
|
887
941
|
promptSource: row.promptSource,
|
|
888
942
|
terminatedAt: row.terminatedAt,
|
|
889
943
|
packetCount: row.packetCount,
|
|
890
|
-
...taskTiming(row),
|
|
891
944
|
terminalResult: row.terminalResult === null
|
|
892
945
|
? null
|
|
893
946
|
: Validator.assertOperationResult(JSON.parse(row.terminalResult))
|
|
@@ -897,7 +950,7 @@ export default class Daemon {
|
|
|
897
950
|
listPrompts(workspaceId, limit) {
|
|
898
951
|
const checkedWorkspaceId = ClientInput.assertId("workspace.prompts", "workspaceId", workspaceId);
|
|
899
952
|
const checkedLimit = ClientInput.assertLimit("workspace.prompts", limit);
|
|
900
|
-
return Envelope.listPromptsForWorkspace(this.#db, checkedWorkspaceId, checkedLimit ??
|
|
953
|
+
return Envelope.listPromptsForWorkspace(this.#db, checkedWorkspaceId, checkedLimit ?? Knob.integer("PLURNK_SERVICE_PROMPTS_PAGE", 1));
|
|
901
954
|
}
|
|
902
955
|
workspaceDerivationStatus(workspaceId) {
|
|
903
956
|
return this.#engine.workspaceDerivationStatus(ClientInput.assertId("workspace.derivation", "workspaceId", workspaceId));
|
|
@@ -948,7 +1001,7 @@ export default class Daemon {
|
|
|
948
1001
|
if (name !== undefined) {
|
|
949
1002
|
const taken = await this.#db.envelope_get_worker_by_name.get({ workspace_id: workspaceId, name });
|
|
950
1003
|
if (taken !== undefined) {
|
|
951
|
-
throw daemonFailure("daemon:worker", "name-conflict", 409, `Worker name '${name}' is already in use in workspace ${workspaceId}.`, { workspaceId, name, recovery: "Choose another worker name.", retryable: false });
|
|
1004
|
+
throw daemonFailure("daemon:worker", "name-conflict", 409, `Worker name '${name}' is already in use in workspace ${workspaceId} by a ${taken.origin} worker.`, { workspaceId, name, actualOrigin: taken.origin, recovery: "Choose another worker name.", retryable: false });
|
|
952
1005
|
}
|
|
953
1006
|
}
|
|
954
1007
|
const worker = await Envelope.createModelWorker(this.#db, workspaceId, name);
|
|
@@ -975,7 +1028,7 @@ export default class Daemon {
|
|
|
975
1028
|
if (name !== undefined) {
|
|
976
1029
|
const taken = await this.#db.envelope_get_worker_by_name.get({ workspace_id: workspaceId, name });
|
|
977
1030
|
if (taken !== undefined) {
|
|
978
|
-
throw daemonFailure("daemon:worker", "name-conflict", 409, `Worker name '${name}' is already in use in workspace ${workspaceId}.`, { workspaceId, name, recovery: "Choose another worker name.", retryable: false });
|
|
1031
|
+
throw daemonFailure("daemon:worker", "name-conflict", 409, `Worker name '${name}' is already in use in workspace ${workspaceId} by a ${taken.origin} worker.`, { workspaceId, name, actualOrigin: taken.origin, recovery: "Choose another worker name.", retryable: false });
|
|
979
1032
|
}
|
|
980
1033
|
}
|
|
981
1034
|
const branchWorkerId = await Fork.fork(this.#db, workerId, name);
|
|
@@ -1018,6 +1071,18 @@ export default class Daemon {
|
|
|
1018
1071
|
scheme
|
|
1019
1072
|
};
|
|
1020
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
|
+
}
|
|
1021
1086
|
registerModuleAction(registration) {
|
|
1022
1087
|
const { name, scope, inputSchema, outputSchema, handler } = registration;
|
|
1023
1088
|
if (name.length === 0)
|
|
@@ -1094,9 +1159,24 @@ export default class Daemon {
|
|
|
1094
1159
|
registerWorkspaceCapabilityProvider(namespaceOwner, provider) {
|
|
1095
1160
|
this.#residency.registerProvider(namespaceOwner, provider);
|
|
1096
1161
|
}
|
|
1162
|
+
// {§module-functionality-adapter}
|
|
1097
1163
|
registerFunctionalityAdapter(adapter) {
|
|
1098
1164
|
return this.#functionality.register(adapter);
|
|
1099
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
|
+
}
|
|
1100
1180
|
async readWorkspaceModuleState(workspaceId, namespaceOwner) {
|
|
1101
1181
|
return this.#residency.readModuleState(workspaceId, namespaceOwner);
|
|
1102
1182
|
}
|
|
@@ -1116,6 +1196,11 @@ export default class Daemon {
|
|
|
1116
1196
|
if (this.#started)
|
|
1117
1197
|
throw new Error("daemon already started");
|
|
1118
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
|
+
}
|
|
1119
1204
|
this.#drains.start();
|
|
1120
1205
|
this.#retention.start((cause) => { console.error("retention pass failed:", cause instanceof Error ? cause.message : String(cause)); });
|
|
1121
1206
|
// Mimetypes owns its own discovery scan over @plurnk/plurnk-mimetypes-*
|
|
@@ -1145,10 +1230,11 @@ export default class Daemon {
|
|
|
1145
1230
|
detail: "in-process"
|
|
1146
1231
|
}
|
|
1147
1232
|
}]);
|
|
1148
|
-
// {§effect-policy-tunable} — invalid operator policy fails boot, not the first
|
|
1233
|
+
// {§effect-policy-tunable} — invalid operator policy fails boot, not the first execution.
|
|
1149
1234
|
EffectPolicy.validateConfiguration();
|
|
1235
|
+
LoopPolicies.validateConfiguration();
|
|
1150
1236
|
// {§exec} — mint a scheme per runtime tag so exec output entries address by tag
|
|
1151
|
-
// authority (sh:///l/t/s). The "exec" scheme stays for
|
|
1237
|
+
// authority (sh:///l/t/s). The "exec" scheme stays for execution dispatch.
|
|
1152
1238
|
this.#schemes.registerRuntimeSchemes(executors);
|
|
1153
1239
|
// Discover external @plurnk/plurnk-schemes-* siblings + register them
|
|
1154
1240
|
// (agnostic, by plurnk.kind:"scheme"). They light up http://, etc. with
|
|
@@ -1173,8 +1259,9 @@ export default class Daemon {
|
|
|
1173
1259
|
await this.#schemes.ready();
|
|
1174
1260
|
this.#residency.publish();
|
|
1175
1261
|
await this.#recoverLifecycle();
|
|
1176
|
-
// {§module-lifecycle} — the daemon
|
|
1177
|
-
// 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.
|
|
1178
1265
|
for (const module of this.#modules) {
|
|
1179
1266
|
const started = await module.start?.(this);
|
|
1180
1267
|
if (started !== undefined && !this.#moduleClosers.includes(started)) {
|
|
@@ -1192,13 +1279,13 @@ export default class Daemon {
|
|
|
1192
1279
|
await this.#db.recovery_error_orphan_subscription_channels.run({});
|
|
1193
1280
|
await this.#db.recovery_fail_orphan_subscriptions.run({});
|
|
1194
1281
|
await this.#db.recovery_resume_unblocked_parks.run({});
|
|
1195
|
-
const orphanSources = await this.#db.
|
|
1282
|
+
const orphanSources = await this.#db.recovery_orphan_message_sources.all({});
|
|
1196
1283
|
const invalidOrphan = orphanSources.find(({ origin }) => origin !== "model");
|
|
1197
1284
|
if (invalidOrphan !== undefined) {
|
|
1198
1285
|
throw new Error(`Orphaned provider work belongs to ${invalidOrphan.origin} worker ${invalidOrphan.worker_id}; only model workers may enter inference.`);
|
|
1199
1286
|
}
|
|
1200
1287
|
for (const source of orphanSources) {
|
|
1201
|
-
await this.#drains.
|
|
1288
|
+
await this.#drains.reconcileOrphanedMessages(source.worker_id, source.loop_id);
|
|
1202
1289
|
}
|
|
1203
1290
|
const systemPrompt = await readFile(Paths.instructionsSystem, "utf8");
|
|
1204
1291
|
const queued = await this.#db.recovery_queued_workers.all({});
|
|
@@ -1227,15 +1314,11 @@ export default class Daemon {
|
|
|
1227
1314
|
await this.#drains.scheduleWakes(row.workspace_id, row.worker_id, systemPrompt);
|
|
1228
1315
|
}
|
|
1229
1316
|
}
|
|
1230
|
-
// {§crash-only-stop} — the settle deadline.
|
|
1231
|
-
//
|
|
1232
|
-
//
|
|
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).
|
|
1233
1320
|
static #stopDeadlineMs() {
|
|
1234
|
-
|
|
1235
|
-
if (!Number.isSafeInteger(raw) || raw <= 0) {
|
|
1236
|
-
throw new Error(`PLURNK_SERVICE_STOP_TIMEOUT_MS must be a positive integer; got ${JSON.stringify(process.env.PLURNK_SERVICE_STOP_TIMEOUT_MS)}.`);
|
|
1237
|
-
}
|
|
1238
|
-
return raw;
|
|
1321
|
+
return Knob.integer("PLURNK_SERVICE_STOP_TIMEOUT_MS", 1);
|
|
1239
1322
|
}
|
|
1240
1323
|
async stop() {
|
|
1241
1324
|
if (!this.#started)
|
|
@@ -1335,7 +1418,7 @@ export default class Daemon {
|
|
|
1335
1418
|
// (SSE, WS) add themselves here as they land.
|
|
1336
1419
|
async #drainStreamingSchemes() {
|
|
1337
1420
|
const exec = this.#schemes.get("exec");
|
|
1338
|
-
// {§exec-
|
|
1421
|
+
// {§exec-lifetime} — a detached spawn ends with the daemon: nothing else ever aborts it.
|
|
1339
1422
|
exec?.abortDetached?.();
|
|
1340
1423
|
if (exec?.idle !== undefined)
|
|
1341
1424
|
await exec.idle();
|
|
@@ -1385,40 +1468,34 @@ export default class Daemon {
|
|
|
1385
1468
|
inject(args) {
|
|
1386
1469
|
return this.#drains.inject(args);
|
|
1387
1470
|
}
|
|
1388
|
-
// Durable
|
|
1471
|
+
// Durable message promotion remains daemon policy; DrainSupervisor invokes
|
|
1389
1472
|
// it under the same worker lock as enqueue and drain teardown.
|
|
1390
|
-
async #
|
|
1391
|
-
const
|
|
1392
|
-
const
|
|
1393
|
-
const frames = await this.#db.drain_orphaned_prompts_for_loop.all({ loop_id: endedLoopId, worker_id: workerId, pattern: `${prefix}%`, prefix_len: prefix.length });
|
|
1394
|
-
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];
|
|
1395
1476
|
if (first === undefined)
|
|
1396
1477
|
return;
|
|
1397
1478
|
const recovery = await this.#db.drain_enqueue_orphan_recovery_loop.get({
|
|
1398
1479
|
worker_id: workerId,
|
|
1399
1480
|
prompt: first.body,
|
|
1400
|
-
prompt_source: first.
|
|
1481
|
+
prompt_source: first.source,
|
|
1401
1482
|
policy: first.policy,
|
|
1402
1483
|
model_route_id: first.model_route_id,
|
|
1403
1484
|
spawn_model_route_id: first.spawn_model_route_id,
|
|
1404
1485
|
reasoning_policy: first.reasoning_policy,
|
|
1405
1486
|
max_turns: first.max_turns,
|
|
1406
|
-
open_paths: first.open_paths ?? "[]",
|
|
1407
1487
|
orphan_source_loop_id: endedLoopId
|
|
1408
1488
|
});
|
|
1409
1489
|
if (recovery === undefined)
|
|
1410
|
-
throw new Error("
|
|
1490
|
+
throw new Error("reconcileOrphanedMessages: enqueue returned no row");
|
|
1411
1491
|
if (recovery.status !== 100)
|
|
1412
1492
|
return;
|
|
1413
|
-
const moved = await this.#db.
|
|
1414
|
-
worker_id: workerId,
|
|
1493
|
+
const moved = await this.#db.drain_rehome_orphaned_messages.all({
|
|
1415
1494
|
source_loop_id: endedLoopId,
|
|
1416
|
-
|
|
1417
|
-
source_prefix_len: prefix.length,
|
|
1418
|
-
target_prefix: promptLoopPrefix(recovery.sequence)
|
|
1495
|
+
target_loop_id: recovery.id
|
|
1419
1496
|
});
|
|
1420
|
-
if (moved.length !==
|
|
1421
|
-
throw new Error(`
|
|
1497
|
+
if (moved.length !== messages.length) {
|
|
1498
|
+
throw new Error(`reconcileOrphanedMessages: expected to re-home ${messages.length} messages, moved ${moved.length}`);
|
|
1422
1499
|
}
|
|
1423
1500
|
}
|
|
1424
1501
|
cancelDrain(workerId, reason = "user_cancelled") {
|