@plurnk/plurnk-service 1.16.4 → 1.17.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 +122 -246
- package/INSTALL.md +84 -138
- package/README.md +9 -5
- package/SPEC.md +1710 -1015
- package/dist/Paths.d.ts +2 -0
- package/dist/Paths.d.ts.map +1 -1
- package/dist/Paths.js +2 -0
- package/dist/Paths.js.map +1 -1
- package/dist/build-info.d.ts.map +1 -1
- package/dist/build-info.js +7 -1
- package/dist/build-info.js.map +1 -1
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts +8 -0
- package/dist/content/body-preview.d.ts.map +1 -0
- package/dist/content/body-preview.js +39 -0
- package/dist/content/body-preview.js.map +1 -0
- package/dist/content/byte-view.d.ts +1 -4
- package/dist/content/byte-view.d.ts.map +1 -1
- package/dist/content/byte-view.js.map +1 -1
- package/dist/content/edit-collision.d.ts.map +1 -1
- package/dist/content/edit-collision.js +3 -4
- package/dist/content/edit-collision.js.map +1 -1
- package/dist/content/line-anchors.d.ts +2 -2
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +4 -3
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/line-selection.d.ts +9 -0
- package/dist/content/line-selection.d.ts.map +1 -0
- package/dist/content/line-selection.js +29 -0
- package/dist/content/line-selection.js.map +1 -0
- package/dist/content/matcher.d.ts +0 -1
- package/dist/content/matcher.d.ts.map +1 -1
- package/dist/content/matcher.js +2 -3
- package/dist/content/matcher.js.map +1 -1
- package/dist/content/pattern-edits.d.ts +39 -0
- package/dist/content/pattern-edits.d.ts.map +1 -0
- package/dist/content/pattern-edits.js +121 -0
- package/dist/content/pattern-edits.js.map +1 -0
- package/dist/content/read-projector.d.ts +18 -9
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +132 -35
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/read-resolve.d.ts +3 -1
- package/dist/content/read-resolve.d.ts.map +1 -1
- package/dist/content/read-resolve.js +39 -7
- package/dist/content/read-resolve.js.map +1 -1
- package/dist/core/AdmittedTurnExecutor.d.ts +3 -5
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +91 -83
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +6 -1
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js +20 -5
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts +2 -3
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +23 -32
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +3 -8
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +2 -28
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +10 -10
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +87 -65
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +14 -11
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +11 -12
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +99 -9
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +7 -0
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts +13 -10
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +13 -5
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.d.ts +2 -2
- package/dist/core/DataStatementRunner.d.ts.map +1 -1
- package/dist/core/DataStatementRunner.js +36 -39
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +19 -26
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +369 -219
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +66 -0
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +2 -1
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/EditMutations.d.ts +14 -18
- package/dist/core/EditMutations.d.ts.map +1 -1
- package/dist/core/EditMutations.js +211 -280
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/EditMutations.sql +15 -0
- package/dist/core/EditSequence.d.ts +13 -0
- package/dist/core/EditSequence.d.ts.map +1 -0
- package/dist/core/EditSequence.js +73 -0
- package/dist/core/EditSequence.js.map +1 -0
- package/dist/core/Engine.d.ts +17 -23
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +73 -163
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +0 -724
- package/dist/core/EntryAddressBinding.d.ts +7 -17
- package/dist/core/EntryAddressBinding.d.ts.map +1 -1
- package/dist/core/EntryAddressBinding.js +12 -72
- package/dist/core/EntryAddressBinding.js.map +1 -1
- package/dist/core/ExecutionOutputs.d.ts +9 -0
- package/dist/core/ExecutionOutputs.d.ts.map +1 -0
- package/dist/core/ExecutionOutputs.js +36 -0
- package/dist/core/ExecutionOutputs.js.map +1 -0
- package/dist/core/ExecutionOutputs.sql +13 -0
- package/dist/core/ExecutorRegistry.d.ts +7 -5
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +36 -32
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/HostPaths.d.ts +1 -0
- package/dist/core/HostPaths.d.ts.map +1 -1
- package/dist/core/HostPaths.js +4 -0
- package/dist/core/HostPaths.js.map +1 -1
- package/dist/core/InferenceCall.d.ts.map +1 -1
- package/dist/core/InferenceCall.js +1 -2
- package/dist/core/InferenceCall.js.map +1 -1
- package/dist/core/InferenceCall.sql +29 -0
- package/dist/core/KillHandler.d.ts +1 -0
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +24 -21
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/LogBody.d.ts +8 -1
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +42 -11
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts +1 -0
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +18 -10
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LogVisibility.d.ts +1 -0
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +3 -0
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LogWriter.d.ts +2 -3
- package/dist/core/LogWriter.d.ts.map +1 -1
- package/dist/core/LogWriter.js +25 -32
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LogWriter.sql +23 -0
- package/dist/core/LoopDriver.d.ts +11 -8
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +163 -189
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopDriver.sql +11 -0
- package/dist/core/LoopLifecycle.d.ts +32 -2
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +88 -4
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +145 -28
- package/dist/core/LoopPolicyReader.sql +6 -0
- package/dist/core/MembershipMaterialization.d.ts.map +1 -1
- package/dist/core/MembershipMaterialization.js +6 -28
- package/dist/core/MembershipMaterialization.js.map +1 -1
- package/dist/core/ModelCall.sql +70 -0
- package/dist/core/MutationEffects.d.ts +5 -3
- package/dist/core/MutationEffects.d.ts.map +1 -1
- package/dist/core/MutationEffects.js +10 -28
- package/dist/core/MutationEffects.js.map +1 -1
- package/dist/core/NativeContent.d.ts +6 -0
- package/dist/core/NativeContent.d.ts.map +1 -0
- package/dist/core/NativeContent.js +16 -0
- package/dist/core/NativeContent.js.map +1 -0
- package/dist/core/NativeContent.sql +6 -0
- package/dist/core/NoticeChannel.js +1 -1
- package/dist/core/NoticeChannel.js.map +1 -1
- package/dist/core/OperatorConfig.js +5 -5
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts +8 -5
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +117 -81
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +146 -0
- package/dist/core/PatternSelection.d.ts +28 -0
- package/dist/core/PatternSelection.d.ts.map +1 -0
- package/dist/core/PatternSelection.js +42 -0
- package/dist/core/PatternSelection.js.map +1 -0
- package/dist/core/ProblemLog.d.ts.map +1 -1
- package/dist/core/ProblemLog.js +0 -1
- package/dist/core/ProblemLog.js.map +1 -1
- package/dist/core/PromptFrames.d.ts +12 -0
- package/dist/core/PromptFrames.d.ts.map +1 -0
- package/dist/core/PromptFrames.js +28 -0
- package/dist/core/PromptFrames.js.map +1 -0
- package/dist/core/ProposalLifecycle.d.ts +0 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +20 -19
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProposalLifecycle.sql +33 -0
- package/dist/core/ProviderInstantiate.d.ts +1 -1
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +7 -14
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReasoningView.d.ts +9 -0
- package/dist/core/ReasoningView.d.ts.map +1 -0
- package/dist/core/ReasoningView.js +47 -0
- package/dist/core/ReasoningView.js.map +1 -0
- package/dist/core/ResourceBindings.d.ts +16 -0
- package/dist/core/ResourceBindings.d.ts.map +1 -0
- package/dist/core/ResourceBindings.js +45 -0
- package/dist/core/ResourceBindings.js.map +1 -0
- package/dist/core/ResourceMutations.d.ts +5 -8
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +6 -7
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.d.ts +2 -2
- package/dist/core/ResourceSelector.d.ts.map +1 -1
- package/dist/core/ResourceSelector.js +122 -62
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.d.ts +4 -2
- package/dist/core/ResourceTransfers.d.ts.map +1 -1
- package/dist/core/ResourceTransfers.js +95 -26
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/RuntimeWorker.d.ts +5 -0
- package/dist/core/RuntimeWorker.d.ts.map +1 -0
- package/dist/core/RuntimeWorker.js +10 -0
- package/dist/core/RuntimeWorker.js.map +1 -0
- package/dist/core/RuntimeWorker.sql +5 -0
- package/dist/core/SchemeRegistry.d.ts +12 -16
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +58 -84
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StoredPacket.d.ts +6 -1
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +30 -10
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts +9 -6
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +60 -113
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/StrikeRail.sql +12 -0
- package/dist/core/TerminalResult.d.ts +1 -1
- package/dist/core/TerminalResult.d.ts.map +1 -1
- package/dist/core/TerminalResult.js +2 -2
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/TokenCalibration.d.ts +1 -6
- package/dist/core/TokenCalibration.d.ts.map +1 -1
- package/dist/core/TokenCalibration.js +13 -9
- package/dist/core/TokenCalibration.js.map +1 -1
- package/dist/core/TokenCalibration.sql +15 -0
- package/dist/core/ToolInputSchema.d.ts +6 -0
- package/dist/core/ToolInputSchema.d.ts.map +1 -0
- package/dist/core/ToolInputSchema.js +43 -0
- package/dist/core/ToolInputSchema.js.map +1 -0
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +76 -52
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.d.ts +5 -2
- package/dist/core/Turn.d.ts.map +1 -1
- package/dist/core/Turn.js +13 -11
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/Turn.sql +25 -39
- package/dist/core/{SendBroadcastHandler.d.ts → TurnDispositionHandler.d.ts} +25 -17
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -0
- package/dist/core/TurnDispositionHandler.js +198 -0
- package/dist/core/TurnDispositionHandler.js.map +1 -0
- package/dist/core/TurnMaterialization.d.ts +2 -3
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +40 -15
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +44 -0
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +8 -64
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +9 -12
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +232 -408
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnRunner.sql +74 -0
- package/dist/core/TurnSources.sql +39 -0
- package/dist/core/WorkerControlAddress.d.ts +1 -0
- package/dist/core/WorkerControlAddress.d.ts.map +1 -1
- package/dist/core/WorkerControlAddress.js +5 -0
- package/dist/core/WorkerControlAddress.js.map +1 -1
- package/dist/core/WorkerControlHandler.d.ts +1 -3
- package/dist/core/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +41 -48
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +8 -6
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +33 -24
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkerName.sql +7 -10
- package/dist/core/WorkspaceGate.d.ts +1 -1
- package/dist/core/WorkspaceGate.d.ts.map +1 -1
- package/dist/core/WorkspaceGate.js +29 -6
- package/dist/core/WorkspaceGate.js.map +1 -1
- package/dist/core/ambient.sql +236 -0
- package/dist/core/attachments.d.ts +2 -1
- package/dist/core/attachments.d.ts.map +1 -1
- package/dist/core/attachments.js +5 -4
- package/dist/core/attachments.js.map +1 -1
- package/dist/core/caps/CapsResolve.d.ts +2 -3
- package/dist/core/caps/CapsResolve.d.ts.map +1 -1
- package/dist/core/caps/CapsResolve.js +5 -5
- package/dist/core/caps/CapsResolve.js.map +1 -1
- package/dist/core/caps/DbChannelCaps.d.ts +1 -1
- package/dist/core/caps/DbChannelCaps.d.ts.map +1 -1
- package/dist/core/caps/DbChannelCaps.js +4 -6
- package/dist/core/caps/DbChannelCaps.js.map +1 -1
- package/dist/core/caps/DbEntryCaps.d.ts +2 -1
- package/dist/core/caps/DbEntryCaps.d.ts.map +1 -1
- package/dist/core/caps/DbEntryCaps.js +11 -17
- package/dist/core/caps/DbEntryCaps.js.map +1 -1
- package/dist/core/caps/DbNotifyCaps.d.ts +1 -1
- package/dist/core/caps/DbNotifyCaps.d.ts.map +1 -1
- package/dist/core/caps/DbNotifyCaps.js +3 -5
- package/dist/core/caps/DbNotifyCaps.js.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +1 -1
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/caps/DbSubscriptionCaps.d.ts +1 -1
- package/dist/core/caps/DbSubscriptionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbSubscriptionCaps.js +5 -7
- package/dist/core/caps/DbSubscriptionCaps.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +0 -2
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +4 -20
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/env-defaults.d.ts.map +1 -1
- package/dist/core/env-defaults.js +4 -2
- package/dist/core/env-defaults.js.map +1 -1
- package/dist/core/file-materialization.d.ts +4 -1
- package/dist/core/file-materialization.d.ts.map +1 -1
- package/dist/core/file-materialization.js +14 -0
- package/dist/core/file-materialization.js.map +1 -1
- package/dist/core/fork.d.ts +1 -6
- package/dist/core/fork.d.ts.map +1 -1
- package/dist/core/fork.js +9 -153
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +162 -185
- package/dist/core/git-env.d.ts +1 -0
- package/dist/core/git-env.d.ts.map +1 -1
- package/dist/core/git-env.js +39 -2
- package/dist/core/git-env.js.map +1 -1
- package/dist/core/git-membership.d.ts.map +1 -1
- package/dist/core/git-membership.js +64 -48
- package/dist/core/git-membership.js.map +1 -1
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +25 -19
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/glob_match.d.ts +4 -0
- package/dist/core/glob_match.d.ts.map +1 -0
- package/dist/core/glob_match.js +7 -0
- package/dist/core/glob_match.js.map +1 -0
- package/dist/core/maintenance.sql +6 -0
- package/dist/core/mutation-types.d.ts +7 -28
- package/dist/core/mutation-types.d.ts.map +1 -1
- package/dist/core/packet-inject.d.ts.map +1 -1
- package/dist/core/packet-inject.js +2 -3
- package/dist/core/packet-inject.js.map +1 -1
- package/dist/core/packet-wire.d.ts +8 -6
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +131 -163
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +1 -1
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +5 -12
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/scheme-types.d.ts +3 -3
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.d.ts.map +1 -0
- package/dist/core/sha256.js +6 -0
- package/dist/core/sha256.js.map +1 -0
- package/dist/core/teaching.js +1 -1
- package/dist/core/teaching.js.map +1 -1
- package/dist/core/turn-scheduler.d.ts.map +1 -1
- package/dist/core/turn-scheduler.js +5 -18
- package/dist/core/turn-scheduler.js.map +1 -1
- package/dist/core/turn-signals.d.ts +0 -6
- package/dist/core/turn-signals.d.ts.map +1 -1
- package/dist/core/turn-signals.js +1 -7
- package/dist/core/turn-signals.js.map +1 -1
- package/dist/core/worker-ops.sql +15 -22
- package/dist/core/workspace-settings.d.ts.map +1 -1
- package/dist/core/workspace-settings.js +18 -2
- package/dist/core/workspace-settings.js.map +1 -1
- package/dist/core/workspace-settings.sql +6 -0
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +27 -90
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +14 -54
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/digest-rows.d.ts +10 -32
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +43 -18
- package/dist/schemes/Exec.d.ts +6 -12
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +256 -188
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +8 -6
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +33 -61
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/ExecutionInput.d.ts +12 -0
- package/dist/schemes/ExecutionInput.d.ts.map +1 -0
- package/dist/schemes/ExecutionInput.js +94 -0
- package/dist/schemes/ExecutionInput.js.map +1 -0
- package/dist/schemes/File.d.ts +5 -2
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +62 -92
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +84 -79
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Log.sql +183 -15
- package/dist/schemes/Prompt.d.ts.map +1 -1
- package/dist/schemes/Prompt.js +3 -12
- package/dist/schemes/Prompt.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts +5 -0
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +6 -14
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/Skill.d.ts +12 -7
- package/dist/schemes/Skill.d.ts.map +1 -1
- package/dist/schemes/Skill.js +149 -21
- package/dist/schemes/Skill.js.map +1 -1
- package/dist/schemes/TurnSource.d.ts +12 -0
- package/dist/schemes/TurnSource.d.ts.map +1 -0
- package/dist/schemes/TurnSource.js +116 -0
- package/dist/schemes/TurnSource.js.map +1 -0
- package/dist/schemes/Worker.d.ts +3 -3
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +61 -208
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.d.ts +12 -15
- package/dist/schemes/_entry-crud.d.ts.map +1 -1
- package/dist/schemes/_entry-crud.js +63 -63
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +142 -46
- package/dist/schemes/_entry-find.d.ts +1 -3
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +111 -112
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-find.sql +22 -14
- package/dist/schemes/_entry-fts.d.ts +14 -0
- package/dist/schemes/_entry-fts.d.ts.map +1 -0
- package/dist/schemes/_entry-fts.js +82 -0
- package/dist/schemes/_entry-fts.js.map +1 -0
- package/dist/schemes/_entry-fts.sql +31 -0
- package/dist/schemes/_entry-graph.d.ts.map +1 -1
- package/dist/schemes/_entry-graph.js +6 -14
- package/dist/schemes/_entry-graph.js.map +1 -1
- package/dist/schemes/_entry-graph.sql +29 -44
- package/dist/schemes/_entry-manifest.d.ts +2 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +15 -12
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-manifest.sql +26 -0
- package/dist/schemes/_entry-ops.d.ts +3 -5
- package/dist/schemes/_entry-ops.d.ts.map +1 -1
- package/dist/schemes/_entry-ops.js +30 -43
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +5 -6
- package/dist/schemes/_entry-readable.d.ts +8 -0
- package/dist/schemes/_entry-readable.d.ts.map +1 -0
- package/dist/schemes/_entry-readable.js +38 -0
- package/dist/schemes/_entry-readable.js.map +1 -0
- package/dist/schemes/_entry-send.d.ts +1 -1
- package/dist/schemes/_entry-send.d.ts.map +1 -1
- package/dist/schemes/_entry-send.js +3 -3
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/schemes/_search-index.d.ts +1 -3
- package/dist/schemes/_search-index.d.ts.map +1 -1
- package/dist/schemes/_search-index.js +79 -110
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/_search-index.sql +30 -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.map +1 -1
- package/dist/server/ClientReads.d.ts +2 -2
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +5 -8
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +14 -21
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +135 -156
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +23 -21
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +8 -21
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +278 -306
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/Functionality.d.ts +11 -12
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +129 -101
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +3 -5
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +20 -58
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/MembersFunctionality.d.ts +5 -4
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +24 -37
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/PlurnkSkill.d.ts +11 -0
- package/dist/server/PlurnkSkill.d.ts.map +1 -0
- package/dist/server/PlurnkSkill.js +41 -0
- package/dist/server/PlurnkSkill.js.map +1 -0
- package/dist/server/Retention.d.ts +22 -0
- package/dist/server/Retention.d.ts.map +1 -0
- package/dist/server/Retention.js +54 -0
- package/dist/server/Retention.js.map +1 -0
- package/dist/server/Retention.sql +36 -0
- package/dist/server/ServiceModules.d.ts +5 -0
- package/dist/server/ServiceModules.d.ts.map +1 -0
- package/dist/server/ServiceModules.js +10 -0
- package/dist/server/ServiceModules.js.map +1 -0
- package/dist/server/SkillsFunctionality.d.ts +14 -19
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +97 -104
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/WorkerModelResolver.d.ts +4 -0
- package/dist/server/WorkerModelResolver.d.ts.map +1 -1
- package/dist/server/WorkerModelResolver.js +72 -39
- package/dist/server/WorkerModelResolver.js.map +1 -1
- package/dist/server/WorkspaceCapabilities.d.ts +21 -0
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -0
- package/dist/server/{WorkerCapabilities.js → WorkspaceCapabilities.js} +40 -40
- package/dist/server/WorkspaceCapabilities.js.map +1 -0
- package/dist/server/WorkspaceResidency.d.ts +36 -0
- package/dist/server/WorkspaceResidency.d.ts.map +1 -0
- package/dist/server/WorkspaceResidency.js +199 -0
- package/dist/server/WorkspaceResidency.js.map +1 -0
- package/dist/server/client-input.d.ts +1 -4
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +4 -45
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.d.ts.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +4 -22
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +65 -42
- package/dist/server/envelope.d.ts +8 -0
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +9 -7
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +49 -13
- package/dist/server/lifecycle-recovery.sql +14 -17
- package/dist/server/logEntry.d.ts +1 -1
- package/dist/server/logEntry.d.ts.map +1 -1
- package/dist/server/logEntry.js +4 -1
- package/dist/server/logEntry.js.map +1 -1
- package/dist/server/logEntry.sql +25 -1
- package/dist/server/loopDocs.d.ts +2 -2
- package/dist/server/loopDocs.d.ts.map +1 -1
- package/dist/server/loopDocs.js +38 -31
- package/dist/server/loopDocs.js.map +1 -1
- package/dist/server/loopDocs.sql +1 -3
- package/dist/server/model-catalog.d.ts.map +1 -1
- package/dist/server/model-catalog.js +2 -1
- package/dist/server/model-catalog.js.map +1 -1
- package/dist/server/model-route.d.ts +1 -1
- package/dist/server/model-route.d.ts.map +1 -1
- package/dist/server/model-route.js +4 -2
- package/dist/server/model-route.js.map +1 -1
- package/dist/server/seam-entry-read.sql +3 -4
- package/dist/server/seam-loop.sql +2 -9
- package/dist/server/workspace-capabilities.sql +19 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +5 -17
- package/dist/service.js.map +1 -1
- package/docs/members.md +83 -0
- package/docs/skills.md +50 -0
- package/migrations/001_workspaces.sql +53 -0
- package/migrations/002_workers.sql +183 -0
- package/migrations/003_loops.sql +326 -0
- package/migrations/004_inference.sql +360 -0
- package/migrations/005_entries.sql +207 -0
- package/migrations/006_log.sql +578 -0
- package/migrations/007_subscriptions.sql +175 -0
- package/migrations/008_interactions.sql +29 -0
- package/package.json +33 -40
- package/digest-sql/channel-dispositions/dispositions.sql +0 -15
- package/digest-sql/channel-state/state.sql +0 -6
- package/digest-sql/curation/curation.sql +0 -6
- package/digest-sql/derivations/derivations.sql +0 -4
- package/digest-sql/embeddings/embeddings.sql +0 -4
- package/digest-sql/entry-dispositions/dispositions.sql +0 -15
- package/digest-sql/entry-state/state.sql +0 -6
- package/digest-sql/token-counts/token-counts.sql +0 -2
- package/dist/core/EmbeddingCall.d.ts +0 -23
- package/dist/core/EmbeddingCall.d.ts.map +0 -1
- package/dist/core/EmbeddingCall.js +0 -149
- package/dist/core/EmbeddingCall.js.map +0 -1
- package/dist/core/OverflowTurn.d.ts +0 -11
- package/dist/core/OverflowTurn.d.ts.map +0 -1
- package/dist/core/OverflowTurn.js +0 -80
- package/dist/core/OverflowTurn.js.map +0 -1
- package/dist/core/Owner.d.ts +0 -8
- package/dist/core/Owner.d.ts.map +0 -1
- package/dist/core/Owner.js +0 -46
- package/dist/core/Owner.js.map +0 -1
- package/dist/core/SendBroadcastHandler.d.ts.map +0 -1
- package/dist/core/SendBroadcastHandler.js +0 -159
- package/dist/core/SendBroadcastHandler.js.map +0 -1
- package/dist/core/VectorPump.d.ts +0 -28
- package/dist/core/VectorPump.d.ts.map +0 -1
- package/dist/core/VectorPump.js +0 -130
- package/dist/core/VectorPump.js.map +0 -1
- package/dist/core/owner.sql +0 -11
- package/dist/core/worker-settings.d.ts +0 -10
- package/dist/core/worker-settings.d.ts.map +0 -1
- package/dist/core/worker-settings.js +0 -53
- package/dist/core/worker-settings.js.map +0 -1
- package/dist/schemes/_entry-chunk.d.ts +0 -14
- package/dist/schemes/_entry-chunk.d.ts.map +0 -1
- package/dist/schemes/_entry-chunk.js +0 -165
- package/dist/schemes/_entry-chunk.js.map +0 -1
- package/dist/schemes/_entry-semantic.d.ts +0 -63
- package/dist/schemes/_entry-semantic.d.ts.map +0 -1
- package/dist/schemes/_entry-semantic.js +0 -299
- package/dist/schemes/_entry-semantic.js.map +0 -1
- package/dist/schemes/_entry-semantic.sql +0 -99
- package/dist/schemes/cosine.d.ts +0 -4
- package/dist/schemes/cosine.d.ts.map +0 -1
- package/dist/schemes/cosine.js +0 -9
- package/dist/schemes/cosine.js.map +0 -1
- package/dist/server/WorkerCapabilities.d.ts +0 -21
- package/dist/server/WorkerCapabilities.d.ts.map +0 -1
- package/dist/server/WorkerCapabilities.js.map +0 -1
- package/dist/server/WorkerResidency.d.ts +0 -40
- package/dist/server/WorkerResidency.d.ts.map +0 -1
- package/dist/server/WorkerResidency.js +0 -283
- package/dist/server/WorkerResidency.js.map +0 -1
- package/dist/server/seam-log-read.sql +0 -21
- package/dist/server/worker-capabilities.sql +0 -28
- package/migrations/001_schema.sql +0 -2207
package/dist/server/Daemon.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// the transport-free plugin-module seam ({§rpc}).
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { resolve, dirname } from "node:path";
|
|
5
|
-
import { isDeepStrictEqual } from "node:util";
|
|
6
5
|
import Paths from "../Paths.js";
|
|
7
6
|
import Engine from "../core/Engine.js";
|
|
8
7
|
import ExecutorRegistry from "../core/ExecutorRegistry.js";
|
|
@@ -11,29 +10,30 @@ import { Mimetypes } from "@plurnk/plurnk-mimetypes";
|
|
|
11
10
|
import { RuntimeDeclaration } from "@plurnk/plurnk-execs";
|
|
12
11
|
import { projectModelRoute, routeForSpec, specForRoute } from "./model-route.js";
|
|
13
12
|
import { discoverDaemonModules } from "./module-discovery.js";
|
|
14
|
-
import WorkerSettingsReader from "../core/worker-settings.js";
|
|
15
13
|
import EffectPolicy from "../schemes/EffectPolicy.js";
|
|
16
14
|
import QuestionTool, { questionRuntimeDecl } from "../schemes/QuestionTool.js";
|
|
17
15
|
import DrainSupervisor from "./DrainSupervisor.js";
|
|
18
|
-
import {
|
|
16
|
+
import Retention, { retentionPolicy } from "./Retention.js";
|
|
17
|
+
import { Validator } from "@plurnk/plurnk-contracts";
|
|
19
18
|
import LogEntry from "./logEntry.js";
|
|
20
|
-
import Envelope from "./envelope.js";
|
|
19
|
+
import Envelope, { projectWorkerRow } from "./envelope.js";
|
|
21
20
|
import ClientInput from "./client-input.js";
|
|
22
21
|
import Turn from "../core/Turn.js";
|
|
23
22
|
import SkillsFunctionality from "./SkillsFunctionality.js";
|
|
23
|
+
import PlurnkSkill from "./PlurnkSkill.js";
|
|
24
|
+
import Skill from "../schemes/Skill.js";
|
|
24
25
|
import MembersFunctionality from "./MembersFunctionality.js";
|
|
25
26
|
import Fork from "../core/fork.js";
|
|
26
27
|
import WorkerControlAddress from "../core/WorkerControlAddress.js";
|
|
27
|
-
import LoopLifecycle from "../core/LoopLifecycle.js";
|
|
28
|
+
import LoopLifecycle, { taskTiming } from "../core/LoopLifecycle.js";
|
|
29
|
+
import LoopPolicyReader from "../core/LoopPolicyReader.js";
|
|
28
30
|
import { promptLoopPrefix } from "../core/plurnk-uri.js";
|
|
29
31
|
import { contentWeight } from "../core/content-weight.js";
|
|
30
32
|
import { parseAliasesFromEnv, resolveActiveRoute } from "@plurnk/plurnk-providers";
|
|
31
33
|
import ProviderInstantiate from "../core/ProviderInstantiate.js";
|
|
32
|
-
import LoopPolicyReader from "../core/LoopPolicyReader.js";
|
|
33
|
-
import CapabilityPolicies from "../core/CapabilityPolicies.js";
|
|
34
34
|
import Results, { OperationFailureError } from "../core/results.js";
|
|
35
35
|
import WorkspaceGate from "../core/WorkspaceGate.js";
|
|
36
|
-
import
|
|
36
|
+
import WorkspaceResidency from "./WorkspaceResidency.js";
|
|
37
37
|
import Functionality from "./Functionality.js";
|
|
38
38
|
import { observed, observedSync } from "../observe/spans.js";
|
|
39
39
|
import { listModelCatalog } from "./model-catalog.js";
|
|
@@ -67,6 +67,8 @@ export default class Daemon {
|
|
|
67
67
|
#moduleActions = new Map();
|
|
68
68
|
#residency;
|
|
69
69
|
#functionality;
|
|
70
|
+
// {§retention-policy} — the operator's retention, run on a cadence and at shutdown.
|
|
71
|
+
#retention;
|
|
70
72
|
#skills;
|
|
71
73
|
#members;
|
|
72
74
|
// {§methods-event-subscribe} — the broadcast's in-process event source. A transport
|
|
@@ -106,9 +108,9 @@ export default class Daemon {
|
|
|
106
108
|
});
|
|
107
109
|
return row !== undefined;
|
|
108
110
|
});
|
|
109
|
-
// {§module-
|
|
111
|
+
// {§module-workspace-residency} — residency, activation/cooling, and
|
|
110
112
|
// capability replacement live in their one owner; the Daemon delegates.
|
|
111
|
-
this.#residency = new
|
|
113
|
+
this.#residency = new WorkspaceResidency({
|
|
112
114
|
db,
|
|
113
115
|
engine: () => this.#engine,
|
|
114
116
|
workspaceGate: this.#workspaceGate,
|
|
@@ -118,19 +120,28 @@ export default class Daemon {
|
|
|
118
120
|
// adapter; Core hosts it, modules register adapters through the seam.
|
|
119
121
|
this.#functionality = new Functionality({
|
|
120
122
|
registerModuleAction: (registration) => this.registerModuleAction(registration),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
registerWorkspaceCapabilityProvider: (owner, provider) => this.registerWorkspaceCapabilityProvider(owner, provider),
|
|
124
|
+
readWorkspaceModuleState: (workspaceId, owner) => this.readWorkspaceModuleState(workspaceId, owner),
|
|
125
|
+
replaceWorkspaceCapabilities: (replacement, options) => this.replaceWorkspaceCapabilities(replacement, options),
|
|
126
|
+
mutateWorkspace: (workspaceId, owner, caller, run) => this.#residency.exclusively(workspaceId, owner, caller === "operation" ? "wait" : "try", run),
|
|
127
|
+
retainWorkspace: (workspaceId) => this.#residency.retain(workspaceId)
|
|
125
128
|
});
|
|
126
129
|
// {§skills-functionality} — Core's own family: standard Agent Skills.
|
|
127
|
-
this.#skills = new SkillsFunctionality({
|
|
130
|
+
this.#skills = new SkillsFunctionality({
|
|
131
|
+
db,
|
|
132
|
+
...skills,
|
|
133
|
+
provided: async () => {
|
|
134
|
+
const tree = await PlurnkSkill.load(this.#nodeModulesPath);
|
|
135
|
+
return new Map([[tree.document.name, tree]]);
|
|
136
|
+
},
|
|
137
|
+
});
|
|
128
138
|
this.#skills.attach(this.#functionality.register(this.#skills));
|
|
139
|
+
this.#schemes.register("skill", new Skill((workspaceId) => this.#skills.trees(workspaceId)));
|
|
129
140
|
// {§members-functionality} — Core's own family: file membership on the same surface.
|
|
130
141
|
this.#members = new MembersFunctionality({ db, engine: () => this.#engine });
|
|
131
142
|
this.#functionality.register(this.#members);
|
|
132
143
|
this.#engine = new Engine({
|
|
133
|
-
db, schemes: this.#schemes, mimetypes: this.#mimetypes,
|
|
144
|
+
db, lifecycle: this.#lifecycle, schemes: this.#schemes, mimetypes: this.#mimetypes,
|
|
134
145
|
// {§tokenomics-agnostic-ruler} — stored and catalog curation weights
|
|
135
146
|
// are workspace-wide across concurrent models, so they remain
|
|
136
147
|
// model-independent. Request-shaped token facts stay provider-owned.
|
|
@@ -143,14 +154,18 @@ export default class Daemon {
|
|
|
143
154
|
// daemon owns provider + the law-file system prompt; the worker scheme
|
|
144
155
|
// handler carries neither. Fire-and-forget: the returned drain runs
|
|
145
156
|
// independently (the sister is its own worker). {§machine-processes}
|
|
146
|
-
injectWorker: async ({ workspaceId, workerId,
|
|
157
|
+
injectWorker: async ({ workspaceId, workerId, sourceLoopId, prompt, freshLoopPolicy, spawn, schedule }) => {
|
|
147
158
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
148
|
-
const
|
|
159
|
+
const sender = await this.#db.drain_message_source.get({ loop_id: sourceLoopId });
|
|
160
|
+
if (sender === undefined || sender.workspace_id !== workspaceId) {
|
|
161
|
+
throw new Error(`injectWorker: source loop ${sourceLoopId} does not belong to workspace ${workspaceId}`);
|
|
162
|
+
}
|
|
163
|
+
const source = await this.#workerPromptSource(workspaceId, sender.worker_id, workerId);
|
|
149
164
|
const systemPrompt = await readFile(Paths.instructionsSystem, "utf8");
|
|
150
165
|
let providerSpec;
|
|
151
166
|
let childProviderSpec;
|
|
152
167
|
let reasoningPolicy;
|
|
153
|
-
if (
|
|
168
|
+
if (spawn !== true) {
|
|
154
169
|
// {§worker-model-selection} — the voice door addresses an
|
|
155
170
|
// existing worker. Its own durable generation policy is the
|
|
156
171
|
// receiver's identity; the daemon default and sender do not
|
|
@@ -164,24 +179,27 @@ export default class Daemon {
|
|
|
164
179
|
childProviderSpec = await this.#workerModels.resolveWorkerSpawnModel(workerId, undefined);
|
|
165
180
|
}
|
|
166
181
|
else {
|
|
167
|
-
const parentPolicy = await this.#providerPolicyForLoop(
|
|
182
|
+
const parentPolicy = await this.#providerPolicyForLoop(sourceLoopId);
|
|
168
183
|
providerSpec = parentPolicy.childProviderSpec ?? parentPolicy.providerSpec;
|
|
169
184
|
reasoningPolicy = parentPolicy.reasoningPolicy;
|
|
170
185
|
// {§worker-model-selection} — lineage inheritance by value:
|
|
171
186
|
// the child begins with the spawning loop's effective spawn
|
|
172
187
|
// model and no separate override of its own.
|
|
173
188
|
childProviderSpec = null;
|
|
174
|
-
|
|
175
|
-
|
|
189
|
+
// {§worker-reasoning-source} — inherited by value, chosen by nobody on this worker.
|
|
190
|
+
await this.#workerModels.persistGenerationPolicy(workerId, {
|
|
176
191
|
model_route_id: await routeForSpec(this.#db, providerSpec),
|
|
177
192
|
spawn_model_route_id: null,
|
|
178
|
-
reasoning_policy: reasoningPolicy
|
|
193
|
+
reasoning_policy: reasoningPolicy,
|
|
194
|
+
reasoning_source: "default"
|
|
179
195
|
});
|
|
180
196
|
}
|
|
181
|
-
const { action, loopId } = await this.inject({
|
|
197
|
+
const { action, loopId, scheduledAt, intervalMinutes, recurrenceId } = await this.inject({
|
|
182
198
|
workspaceId,
|
|
183
199
|
workerId,
|
|
184
200
|
prompt,
|
|
201
|
+
sourceLoopId,
|
|
202
|
+
...(schedule === undefined ? {} : { schedule }),
|
|
185
203
|
...(source === undefined ? {} : { source }),
|
|
186
204
|
providerSpec,
|
|
187
205
|
reasoningPolicy,
|
|
@@ -189,14 +207,14 @@ export default class Daemon {
|
|
|
189
207
|
systemPrompt,
|
|
190
208
|
...(freshLoopPolicy === undefined ? {} : { freshLoopPolicy })
|
|
191
209
|
});
|
|
192
|
-
return { action, loopId };
|
|
210
|
+
return { action, loopId, scheduledAt, intervalMinutes, recurrenceId };
|
|
193
211
|
},
|
|
194
|
-
acquireWorkspaceTurn: async (workspaceId, workerId) => this.#workspaceGate.acquireTurn(workspaceId, workerId),
|
|
212
|
+
acquireWorkspaceTurn: async (workspaceId, workerId, signal) => this.#workspaceGate.acquireTurn(workspaceId, workerId, signal),
|
|
195
213
|
// {§skills-hotload} — filesystem installers operate out of band.
|
|
196
214
|
// Republish under the workspace turn gate before packet assembly so
|
|
197
215
|
// the first subsequent model turn sees their exact result.
|
|
198
|
-
workspaceTurnStarting: async ({ workspaceId
|
|
199
|
-
await this.#skills.refreshIfChanged({ workspaceId
|
|
216
|
+
workspaceTurnStarting: async ({ workspaceId }) => {
|
|
217
|
+
await this.#skills.refreshIfChanged({ workspaceId });
|
|
200
218
|
},
|
|
201
219
|
// worker:// KILL (terminate) — cancel the addressed worker subtree and
|
|
202
220
|
// tear down its held streams before the operation completes.
|
|
@@ -207,10 +225,11 @@ export default class Daemon {
|
|
|
207
225
|
this.#broadcast({ workspaceId }, "loop/packet", payload);
|
|
208
226
|
}
|
|
209
227
|
});
|
|
228
|
+
this.#retention = new Retention(db, retentionPolicy());
|
|
210
229
|
this.#drains = new DrainSupervisor({
|
|
211
230
|
db,
|
|
212
231
|
lifecycle: this.#lifecycle,
|
|
213
|
-
injectPrompt: (
|
|
232
|
+
injectPrompt: (loopId, prompt, openPaths, source) => this.#engine.injectIntoLoop(loopId, prompt, openPaths, source),
|
|
214
233
|
assertInjectionCompatibility: async ({ workerId, loopId, providerSpec, providerSpecExplicit, reasoningPolicy, childProviderSpec, turnCeiling, policy }) => {
|
|
215
234
|
await this.#assertFoldPosture(workerId, policy, loopId);
|
|
216
235
|
// An omitted selector keeps the loop's durable provider; only an
|
|
@@ -229,12 +248,12 @@ export default class Daemon {
|
|
|
229
248
|
// The drain callback is the final provider/model boundary. Every
|
|
230
249
|
// admission path, including boot recovery, terminates here.
|
|
231
250
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
232
|
-
const releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
251
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
233
252
|
try {
|
|
234
253
|
// Worker settings can change while Functionality remains
|
|
235
254
|
// resident. Reconcile the worker-private discovery surface
|
|
236
255
|
// at the same pre-inference boundary used for activation.
|
|
237
|
-
await this.#residency.reconcile(workspaceId
|
|
256
|
+
await this.#residency.reconcile(workspaceId);
|
|
238
257
|
const { provider, childProvider } = await this.#providersForLoop(loopId);
|
|
239
258
|
return await this.#engine.runLoop({
|
|
240
259
|
provider,
|
|
@@ -257,15 +276,8 @@ export default class Daemon {
|
|
|
257
276
|
},
|
|
258
277
|
loopUsage: (loopId) => this.#engine.loopUsage(loopId),
|
|
259
278
|
loopAttributions: (loopId) => this.#engine.loopAttributions(loopId),
|
|
260
|
-
takeParkDeadline: (loopId) => {
|
|
261
|
-
const deadline = this.#engine.parkDeadlines.get(loopId);
|
|
262
|
-
this.#engine.parkDeadlines.delete(loopId);
|
|
263
|
-
return deadline;
|
|
264
|
-
},
|
|
265
279
|
cancelSubscription: (subscriptionId) => this.#engine.cancelSubscription(subscriptionId),
|
|
266
280
|
hasActiveStreams: (workerId) => this.#workerHasActiveStreams(workerId),
|
|
267
|
-
// {§exec-timeout} — a `<-1>` spawn is nobody's obligation.
|
|
268
|
-
isDetachedSubscription: (subscriptionId) => this.#schemes.get("exec")?.isDetachedSpawn?.(subscriptionId) === true,
|
|
269
281
|
readSystemPrompt: () => readFile(Paths.instructionsSystem, "utf8"),
|
|
270
282
|
emitLogEntry: async (workspaceId, logEntryId) => {
|
|
271
283
|
const entry = await LogEntry.fetchLogEntry(this.#db, logEntryId);
|
|
@@ -469,43 +481,29 @@ export default class Daemon {
|
|
|
469
481
|
}
|
|
470
482
|
// {§methods-model-worker} — the workspace's model worker (created on first use), distinct from the client
|
|
471
483
|
// worker so the model's packets never carry client-action rows. The module binds its threads to this.
|
|
472
|
-
|
|
473
|
-
// creation AND on every subsequent ensure, so a client can change its mind between loops.
|
|
474
|
-
async ensureModelWorker(workspaceId, settings) {
|
|
484
|
+
async ensureModelWorker(workspaceId) {
|
|
475
485
|
const checked = ClientInput.assertId("worker.ensure-model", "workspaceId", workspaceId);
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
//
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
498
|
-
return this.#engine.capabilityProjection(workspaceId, workerId);
|
|
499
|
-
}
|
|
500
|
-
// {§worker-settings} — replace the Worker's mutable policy, then return the
|
|
501
|
-
// resolver-owned projection so a narrowing ceiling cannot be mistaken for
|
|
502
|
-
// newly effective authority.
|
|
503
|
-
async setWorkerCapabilities(args) {
|
|
504
|
-
const workspaceId = ClientInput.assertId("worker.capabilities.set", "workspaceId", args.workspaceId);
|
|
505
|
-
const workerId = ClientInput.assertId("worker.capabilities.set", "workerId", args.workerId);
|
|
506
|
-
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
507
|
-
await this.#mergeWorkerSettings(workerId, { capabilities: args.policy });
|
|
508
|
-
return this.#engine.capabilityProjection(workspaceId, workerId);
|
|
486
|
+
return await Envelope.ensureModelWorker(this.#db, checked);
|
|
487
|
+
}
|
|
488
|
+
async readWorkspaceCapabilities(args) {
|
|
489
|
+
const workspaceId = ClientInput.assertId("workspace.capabilities.get", "workspaceId", args.workspaceId);
|
|
490
|
+
return this.#engine.capabilityProjection(workspaceId);
|
|
491
|
+
}
|
|
492
|
+
// {§workspace-capability-policy} Policy changes share the workspace's
|
|
493
|
+
// quiescent publication boundary; no in-flight proposal can change authority.
|
|
494
|
+
async setWorkspaceCapabilities(args) {
|
|
495
|
+
const workspaceId = ClientInput.assertId("workspace.capabilities.set", "workspaceId", args.workspaceId);
|
|
496
|
+
const settings = JSON.parse(ClientInput.parseSettings({ capabilities: args.policy }));
|
|
497
|
+
if (settings.capabilities === undefined)
|
|
498
|
+
throw daemonFailure("daemon:input", "capability-policy-required", 400, "policy is required.", { field: "policy", retryable: false });
|
|
499
|
+
return this.#residency.exclusively(workspaceId, "capabilities", "try", async () => {
|
|
500
|
+
const row = await this.#db.workspace_capability_policy_update.get({
|
|
501
|
+
workspace_id: workspaceId, policy: JSON.stringify(settings.capabilities),
|
|
502
|
+
});
|
|
503
|
+
if (row === undefined)
|
|
504
|
+
throw daemonFailure("daemon:workspace", "workspace-not-found", 404, `Workspace ${workspaceId} does not exist.`, { workspaceId });
|
|
505
|
+
return await this.#engine.capabilityProjection(workspaceId);
|
|
506
|
+
});
|
|
509
507
|
}
|
|
510
508
|
// {§worker-model-selection} — project a worker's durable model and spawn override
|
|
511
509
|
// for a client-interface get/set surface. Ownership is checked at this boundary.
|
|
@@ -519,8 +517,8 @@ export default class Daemon {
|
|
|
519
517
|
const modelSpec = await specForRoute(this.#db, row.model_route_id);
|
|
520
518
|
const spawnModelSpec = await specForRoute(this.#db, row.spawn_model_route_id);
|
|
521
519
|
return {
|
|
522
|
-
model: modelSpec === null ? null : projectModelRoute(modelSpec, row.reasoning_policy),
|
|
523
|
-
spawnModel: spawnModelSpec === null ? null : projectModelRoute(spawnModelSpec, row.reasoning_policy)
|
|
520
|
+
model: modelSpec === null ? null : projectModelRoute(modelSpec, row.reasoning_policy, row.reasoning_source),
|
|
521
|
+
spawnModel: spawnModelSpec === null ? null : projectModelRoute(spawnModelSpec, row.reasoning_policy, row.reasoning_source)
|
|
524
522
|
};
|
|
525
523
|
}
|
|
526
524
|
// {§worker-model-selection} — persist an explicit model selection onto the worker
|
|
@@ -529,23 +527,12 @@ export default class Daemon {
|
|
|
529
527
|
const workspaceId = ClientInput.assertId("worker.model.set", "workspaceId", args.workspaceId);
|
|
530
528
|
const workerId = ClientInput.assertId("worker.model.set", "workerId", args.workerId);
|
|
531
529
|
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
532
|
-
await this.#assertWorkerSelectable(workerId);
|
|
533
530
|
const selector = ClientInput.assertSelector("worker.model.set", "selector", args.selector);
|
|
534
531
|
const policy = await this.#workerModels.resolveWorkerModel(workerId, selector);
|
|
535
532
|
if (policy === null) {
|
|
536
533
|
throw new OperationFailureError(Results.failure("daemon:provider", "not-configured", 501, "No provider is configured for this worker.", {}, { stage: "provider-selection", recovery: "Select a configured model provider.", retryable: false }));
|
|
537
534
|
}
|
|
538
|
-
return projectModelRoute(policy.providerSpec, policy.reasoningPolicy);
|
|
539
|
-
}
|
|
540
|
-
async #reasoningSupportForWorker(workerId, row, providerSpec, policy) {
|
|
541
|
-
const provider = await this.#workerModels.providerForPolicy(providerSpec, policy);
|
|
542
|
-
if (row.spawn_model_route_id === null)
|
|
543
|
-
return provider.supportedReasoningPolicies;
|
|
544
|
-
const spawnSpec = await specForRoute(this.#db, row.spawn_model_route_id);
|
|
545
|
-
if (spawnSpec === null)
|
|
546
|
-
throw new Error(`worker ${workerId}: spawn model route is missing`);
|
|
547
|
-
const spawnProvider = await this.#workerModels.providerForPolicy(spawnSpec, policy);
|
|
548
|
-
return provider.supportedReasoningPolicies.filter((candidate) => spawnProvider.supportedReasoningPolicies.includes(candidate));
|
|
535
|
+
return projectModelRoute(policy.providerSpec, policy.reasoningPolicy, policy.reasoningSource);
|
|
549
536
|
}
|
|
550
537
|
// {§worker-reasoning-policy} — the worker's reasoning policy is durable and
|
|
551
538
|
// provider-relative. A model-less worker remains explicitly uninitialized.
|
|
@@ -561,17 +548,15 @@ export default class Daemon {
|
|
|
561
548
|
if (row.reasoning_policy !== null) {
|
|
562
549
|
throw new Error(`worker ${workerId}: reasoning policy exists without a model route`);
|
|
563
550
|
}
|
|
564
|
-
return { policy: null, supportedPolicies: [] };
|
|
551
|
+
return { policy: null, source: "default", supportedPolicies: [] };
|
|
565
552
|
}
|
|
566
553
|
if (row.reasoning_policy === null) {
|
|
567
554
|
throw new Error(`worker ${workerId}: durable model has no reasoning policy`);
|
|
568
555
|
}
|
|
569
|
-
const spec = await specForRoute(this.#db, row.model_route_id);
|
|
570
|
-
if (spec === null)
|
|
571
|
-
throw new Error(`worker ${workerId}: model route is missing`);
|
|
572
556
|
return {
|
|
573
557
|
policy: row.reasoning_policy,
|
|
574
|
-
|
|
558
|
+
source: row.reasoning_source,
|
|
559
|
+
supportedPolicies: await this.#workerModels.supportedPolicies(row)
|
|
575
560
|
};
|
|
576
561
|
}
|
|
577
562
|
// {§worker-reasoning-policy} — mutate between loops, validate against both
|
|
@@ -587,7 +572,6 @@ export default class Daemon {
|
|
|
587
572
|
throw daemonFailure("daemon:input", "reasoning-policy-invalid", 400, cause instanceof Error ? cause.message : "The reasoning policy is invalid.", { field: "policy", retryable: false });
|
|
588
573
|
}
|
|
589
574
|
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
590
|
-
await this.#assertWorkerSelectable(workerId);
|
|
591
575
|
await this.#workerModels.resolveWorkerModel(workerId, undefined);
|
|
592
576
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
593
577
|
if (row === undefined)
|
|
@@ -601,14 +585,13 @@ export default class Daemon {
|
|
|
601
585
|
retryable: false
|
|
602
586
|
});
|
|
603
587
|
}
|
|
604
|
-
const supportedPolicies = await this.#
|
|
605
|
-
await this.#db.worker_generation_policy_update.run({
|
|
606
|
-
id: workerId,
|
|
588
|
+
const supportedPolicies = await this.#workerModels.persistGenerationPolicy(workerId, {
|
|
607
589
|
model_route_id: row.model_route_id,
|
|
608
590
|
spawn_model_route_id: row.spawn_model_route_id,
|
|
609
|
-
reasoning_policy: policy
|
|
591
|
+
reasoning_policy: policy,
|
|
592
|
+
reasoning_source: "explicit"
|
|
610
593
|
});
|
|
611
|
-
return { policy, supportedPolicies };
|
|
594
|
+
return { policy, source: "explicit", supportedPolicies };
|
|
612
595
|
}
|
|
613
596
|
// {§worker-model-selection} — persist the worker's spawn override; a null
|
|
614
597
|
// selector means inherit (clears the override).
|
|
@@ -616,26 +599,12 @@ export default class Daemon {
|
|
|
616
599
|
const workspaceId = ClientInput.assertId("worker.child.set", "workspaceId", args.workspaceId);
|
|
617
600
|
const workerId = ClientInput.assertId("worker.child.set", "workerId", args.workerId);
|
|
618
601
|
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
619
|
-
await this.#assertWorkerSelectable(workerId);
|
|
620
602
|
const selector = ClientInput.assertChildSelector("worker.child.set", args.selector);
|
|
621
603
|
const spec = await this.#workerModels.resolveWorkerSpawnModel(workerId, selector);
|
|
622
604
|
if (spec === null)
|
|
623
605
|
return null;
|
|
624
606
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
625
|
-
return projectModelRoute(spec, row?.reasoning_policy ?? null);
|
|
626
|
-
}
|
|
627
|
-
// {§worker-model-selection} — a selection must not mutate underneath active
|
|
628
|
-
// work: a live or parked loop is a precise 409, never a silent retroactive
|
|
629
|
-
// switch of the immutable loop snapshot.
|
|
630
|
-
async #assertWorkerSelectable(workerId) {
|
|
631
|
-
if (await this.#drains.hasLiveWork(workerId)) {
|
|
632
|
-
throw daemonFailure("daemon:worker", "worker-loop-active", 409, `Worker ${workerId} has a live or parked loop; select a model after concluding or cancelling it.`, {
|
|
633
|
-
workerId,
|
|
634
|
-
stage: "model-selection",
|
|
635
|
-
recovery: "Conclude or cancel the active loop before selecting a model.",
|
|
636
|
-
retryable: false
|
|
637
|
-
});
|
|
638
|
-
}
|
|
607
|
+
return projectModelRoute(spec, row?.reasoning_policy ?? null, row?.reasoning_source ?? "default");
|
|
639
608
|
}
|
|
640
609
|
async #assertWorkerOwned(workspaceId, workerId) {
|
|
641
610
|
const owner = await this.#db.envelope_get_worker_by_id.get({ id: workerId });
|
|
@@ -687,20 +656,19 @@ export default class Daemon {
|
|
|
687
656
|
// grammar package and hands over the statement, then fans the emitted entry out to its own clients.
|
|
688
657
|
// {§functionality-model-mutation} — await every queued Functionality
|
|
689
658
|
// publication (a Worker's accepted mutation publishes at its turn boundary).
|
|
690
|
-
async settleFunctionality(
|
|
691
|
-
await this.#functionality.settle(
|
|
659
|
+
async settleFunctionality(workspaceId) {
|
|
660
|
+
await this.#functionality.settle(workspaceId);
|
|
692
661
|
}
|
|
693
662
|
async dispatchAsClient(args) {
|
|
694
663
|
const workspaceId = ClientInput.assertId("operation.dispatch", "workspaceId", args.workspaceId);
|
|
695
664
|
const workerId = ClientInput.assertId("operation.dispatch", "workerId", args.workerId);
|
|
696
|
-
const functionalityWorkerId = ClientInput.assertId("operation.dispatch", "functionalityWorkerId", args.functionalityWorkerId);
|
|
697
665
|
const { statement } = args;
|
|
698
|
-
await this.#assertWorkerOwned(workspaceId,
|
|
699
|
-
const releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
666
|
+
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
667
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
700
668
|
try {
|
|
701
669
|
const clientLoopId = await Envelope.ensureClientLoop(this.#db, workerId);
|
|
702
670
|
try {
|
|
703
|
-
const result = await this.#dispatchClientStatement({ workspaceId, workerId,
|
|
671
|
+
const result = await this.#dispatchClientStatement({ workspaceId, workerId, loopId: clientLoopId, statement });
|
|
704
672
|
await Envelope.closeClientLoop(this.#db, clientLoopId, { status: 200 });
|
|
705
673
|
return result;
|
|
706
674
|
}
|
|
@@ -717,23 +685,25 @@ export default class Daemon {
|
|
|
717
685
|
// loop, regardless of how many statements op.parse produced. Each statement is one
|
|
718
686
|
// ordinary operation turn; a proposal may keep that turn and loop open across
|
|
719
687
|
// interrupt/resume until settlement.
|
|
688
|
+
executorTags(workspaceId) {
|
|
689
|
+
return this.#engine.executorTags(workspaceId);
|
|
690
|
+
}
|
|
720
691
|
async dispatchClientAction(args) {
|
|
721
692
|
const workspaceId = ClientInput.assertId("operation.dispatch-batch", "workspaceId", args.workspaceId);
|
|
722
693
|
const workerId = ClientInput.assertId("operation.dispatch-batch", "workerId", args.workerId);
|
|
723
|
-
const functionalityWorkerId = ClientInput.assertId("operation.dispatch-batch", "functionalityWorkerId", args.functionalityWorkerId);
|
|
724
694
|
const { statements } = args;
|
|
725
695
|
if (statements.length === 0)
|
|
726
696
|
return [];
|
|
727
|
-
await this.#assertWorkerOwned(workspaceId,
|
|
728
|
-
// {§actor-boundary-attached-functionality}
|
|
729
|
-
//
|
|
730
|
-
const releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
697
|
+
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
698
|
+
// {§actor-boundary-attached-functionality} The client retains its journal;
|
|
699
|
+
// the workspace supplies policy and the shared runtime environment.
|
|
700
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
731
701
|
try {
|
|
732
702
|
const clientLoopId = await Envelope.ensureClientLoop(this.#db, workerId);
|
|
733
703
|
try {
|
|
734
704
|
const results = [];
|
|
735
705
|
for (const statement of statements) {
|
|
736
|
-
results.push(await this.#dispatchClientStatement({ workspaceId, workerId,
|
|
706
|
+
results.push(await this.#dispatchClientStatement({ workspaceId, workerId, loopId: clientLoopId, statement }));
|
|
737
707
|
}
|
|
738
708
|
await Envelope.closeClientLoop(this.#db, clientLoopId, { status: 200 });
|
|
739
709
|
return results;
|
|
@@ -748,9 +718,10 @@ export default class Daemon {
|
|
|
748
718
|
}
|
|
749
719
|
}
|
|
750
720
|
async #dispatchClientStatement(args) {
|
|
751
|
-
const { workspaceId, workerId,
|
|
721
|
+
const { workspaceId, workerId, loopId, statement } = args;
|
|
752
722
|
const release = await this.#workspaceGate.acquireTurn(workspaceId, workerId);
|
|
753
723
|
try {
|
|
724
|
+
await this.#residency.reconcile(workspaceId);
|
|
754
725
|
const { id: turnId } = await Turn.open(this.#db, {
|
|
755
726
|
loopId,
|
|
756
727
|
producer: "client",
|
|
@@ -760,7 +731,7 @@ export default class Daemon {
|
|
|
760
731
|
try {
|
|
761
732
|
const entryIds = [];
|
|
762
733
|
const result = await this.#engine.dispatch({
|
|
763
|
-
statement, workspaceId, workerId,
|
|
734
|
+
statement, workspaceId, workerId, loopId, turnId, sequence: 1,
|
|
764
735
|
origin: "client", onDispatch: (logEntryId) => { entryIds.push(logEntryId); }
|
|
765
736
|
});
|
|
766
737
|
await Turn.complete(this.#db, turnId, result.status);
|
|
@@ -796,16 +767,16 @@ export default class Daemon {
|
|
|
796
767
|
async look(args) {
|
|
797
768
|
const workspaceId = ClientInput.assertId("operation.look", "workspaceId", args.workspaceId);
|
|
798
769
|
const workerId = ClientInput.assertId("operation.look", "workerId", args.workerId);
|
|
799
|
-
const functionalityWorkerId = ClientInput.assertId("operation.look", "functionalityWorkerId", args.functionalityWorkerId);
|
|
800
770
|
const { statement } = args;
|
|
801
|
-
await this.#assertWorkerOwned(workspaceId,
|
|
802
|
-
const releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
771
|
+
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
772
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
803
773
|
try {
|
|
804
774
|
const releaseWorkspace = await this.#workspaceGate.acquireTurn(workspaceId, workerId);
|
|
805
775
|
try {
|
|
776
|
+
await this.#residency.reconcile(workspaceId);
|
|
806
777
|
const clientLoopId = await Envelope.ensureClientLoop(this.#db, workerId);
|
|
807
778
|
try {
|
|
808
|
-
const result = await this.#engine.look({ statement, workspaceId, workerId,
|
|
779
|
+
const result = await this.#engine.look({ statement, workspaceId, workerId, loopId: clientLoopId });
|
|
809
780
|
await Envelope.closeClientLoop(this.#db, clientLoopId, { status: 200 });
|
|
810
781
|
return result;
|
|
811
782
|
}
|
|
@@ -899,7 +870,7 @@ export default class Daemon {
|
|
|
899
870
|
});
|
|
900
871
|
if (row === undefined || row.workspace_id !== workspaceId)
|
|
901
872
|
return null;
|
|
902
|
-
const { workspace_id: _workspaceId, ...projection } = row;
|
|
873
|
+
const { workspace_id: _workspaceId, ...projection } = projectWorkerRow(row);
|
|
903
874
|
return projection;
|
|
904
875
|
}
|
|
905
876
|
async listWorkerLoops(args) {
|
|
@@ -916,6 +887,7 @@ export default class Daemon {
|
|
|
916
887
|
promptSource: row.promptSource,
|
|
917
888
|
terminatedAt: row.terminatedAt,
|
|
918
889
|
packetCount: row.packetCount,
|
|
890
|
+
...taskTiming(row),
|
|
919
891
|
terminalResult: row.terminalResult === null
|
|
920
892
|
? null
|
|
921
893
|
: Validator.assertOperationResult(JSON.parse(row.terminalResult))
|
|
@@ -980,9 +952,6 @@ export default class Daemon {
|
|
|
980
952
|
}
|
|
981
953
|
}
|
|
982
954
|
const worker = await Envelope.createModelWorker(this.#db, workspaceId, name);
|
|
983
|
-
if (args.settings !== undefined) {
|
|
984
|
-
await this.#mergeWorkerSettings(worker.id, args.settings);
|
|
985
|
-
}
|
|
986
955
|
return { workerId: worker.id, workerName: worker.name };
|
|
987
956
|
}
|
|
988
957
|
// {§worker-scheme-fork} — branch a worker's log while sharing the workspace world.
|
|
@@ -1009,7 +978,7 @@ export default class Daemon {
|
|
|
1009
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 });
|
|
1010
979
|
}
|
|
1011
980
|
}
|
|
1012
|
-
const branchWorkerId = await Fork.fork(this.#db, workerId, name
|
|
981
|
+
const branchWorkerId = await Fork.fork(this.#db, workerId, name);
|
|
1013
982
|
const branch = await this.#db.envelope_get_worker_by_id.get({ id: branchWorkerId });
|
|
1014
983
|
return { workerId: branchWorkerId, workerName: branch?.name ?? null, parentWorkerId: workerId };
|
|
1015
984
|
}
|
|
@@ -1095,7 +1064,7 @@ export default class Daemon {
|
|
|
1095
1064
|
}
|
|
1096
1065
|
let releaseCapabilities;
|
|
1097
1066
|
if (context.scope === "workspace") {
|
|
1098
|
-
|
|
1067
|
+
releaseCapabilities = await this.#residency.acquire(context.workspaceId);
|
|
1099
1068
|
}
|
|
1100
1069
|
else if (context.scope === "worker") {
|
|
1101
1070
|
const workspaceId = ClientInput.assertId(`module action '${name}'`, "workspaceId", context.workspaceId);
|
|
@@ -1104,25 +1073,34 @@ export default class Daemon {
|
|
|
1104
1073
|
if (worker === undefined || worker.workspace_id !== workspaceId) {
|
|
1105
1074
|
throw daemonFailure("daemon:module-action", "worker-not-found", 404, `Worker ${workerId} does not exist in workspace ${workspaceId}.`, { workspaceId, workerId, retryable: false });
|
|
1106
1075
|
}
|
|
1107
|
-
releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
1076
|
+
releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
1108
1077
|
}
|
|
1109
1078
|
try {
|
|
1079
|
+
if (context.scope === "worker") {
|
|
1080
|
+
const release = await this.#workspaceGate.acquireTurn(context.workspaceId, context.workerId);
|
|
1081
|
+
try {
|
|
1082
|
+
await this.#residency.reconcile(context.workspaceId);
|
|
1083
|
+
}
|
|
1084
|
+
finally {
|
|
1085
|
+
release();
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1110
1088
|
return await registration.handler(params, context);
|
|
1111
1089
|
}
|
|
1112
1090
|
finally {
|
|
1113
1091
|
releaseCapabilities?.();
|
|
1114
1092
|
}
|
|
1115
1093
|
}
|
|
1116
|
-
|
|
1094
|
+
registerWorkspaceCapabilityProvider(namespaceOwner, provider) {
|
|
1117
1095
|
this.#residency.registerProvider(namespaceOwner, provider);
|
|
1118
1096
|
}
|
|
1119
1097
|
registerFunctionalityAdapter(adapter) {
|
|
1120
1098
|
return this.#functionality.register(adapter);
|
|
1121
1099
|
}
|
|
1122
|
-
async
|
|
1123
|
-
return this.#residency.readModuleState(
|
|
1100
|
+
async readWorkspaceModuleState(workspaceId, namespaceOwner) {
|
|
1101
|
+
return this.#residency.readModuleState(workspaceId, namespaceOwner);
|
|
1124
1102
|
}
|
|
1125
|
-
async
|
|
1103
|
+
async replaceWorkspaceCapabilities(replacement, options = {}) {
|
|
1126
1104
|
await this.#residency.replace(replacement, options);
|
|
1127
1105
|
}
|
|
1128
1106
|
get engine() { return this.#engine; }
|
|
@@ -1139,6 +1117,7 @@ export default class Daemon {
|
|
|
1139
1117
|
throw new Error("daemon already started");
|
|
1140
1118
|
this.#started = true;
|
|
1141
1119
|
this.#drains.start();
|
|
1120
|
+
this.#retention.start((cause) => { console.error("retention pass failed:", cause instanceof Error ? cause.message : String(cause)); });
|
|
1142
1121
|
// Mimetypes owns its own discovery scan over @plurnk/plurnk-mimetypes-*
|
|
1143
1122
|
// packages; pre-warm it so first index render doesn't pay the cost.
|
|
1144
1123
|
await this.#mimetypes.ready();
|
|
@@ -1150,9 +1129,9 @@ export default class Daemon {
|
|
|
1150
1129
|
// shell is the default runtime, so its executor must boot usable.
|
|
1151
1130
|
const executors = await ExecutorRegistry.build({ defaultRuntime: "sh", cwd: this.#discoveryCwd });
|
|
1152
1131
|
this.#engine.setExecutors(executors);
|
|
1153
|
-
this.#engine.setFunctionalityDocuments((
|
|
1132
|
+
this.#engine.setFunctionalityDocuments((workspaceId) => this.#functionality.documents(workspaceId));
|
|
1154
1133
|
// {§question-tool} — the native request-user-input runtime, process-wide;
|
|
1155
|
-
//
|
|
1134
|
+
// workspace admission gates its doc visibility and dispatch ({§workspace-capability-policy}).
|
|
1156
1135
|
await this.#engine.registerRuntimes([{
|
|
1157
1136
|
tag: "question",
|
|
1158
1137
|
entry: {
|
|
@@ -1207,7 +1186,6 @@ export default class Daemon {
|
|
|
1207
1186
|
await this.#db.recovery_fail_active_loops.run({});
|
|
1208
1187
|
await this.#db.recovery_settle_open_provider_requests.run({});
|
|
1209
1188
|
await this.#db.recovery_fail_open_model_calls.run({});
|
|
1210
|
-
await this.#db.recovery_fail_open_embedding_calls.run({});
|
|
1211
1189
|
await this.#db.recovery_fail_open_turns.run({});
|
|
1212
1190
|
await this.#db.recovery_fail_ownerless_proposals.run({});
|
|
1213
1191
|
await this.#db.recovery_remove_ownerless_client_interactions.run({});
|
|
@@ -1246,7 +1224,7 @@ export default class Daemon {
|
|
|
1246
1224
|
});
|
|
1247
1225
|
}
|
|
1248
1226
|
for (const row of parked) {
|
|
1249
|
-
await this.#drains.
|
|
1227
|
+
await this.#drains.scheduleWakes(row.workspace_id, row.worker_id, systemPrompt);
|
|
1250
1228
|
}
|
|
1251
1229
|
}
|
|
1252
1230
|
// {§crash-only-stop} — the settle deadline. Default 30s; an operator can
|
|
@@ -1267,6 +1245,7 @@ export default class Daemon {
|
|
|
1267
1245
|
// already between queue claim and activation must observe its own abort,
|
|
1268
1246
|
// not misclassify orderly shutdown as a capability failure.
|
|
1269
1247
|
const derivationAbort = new DOMException("daemon stopping", "AbortError");
|
|
1248
|
+
this.#retention.stop();
|
|
1270
1249
|
this.#engine.cancelAllProposals("daemon_stopping");
|
|
1271
1250
|
this.#engine.cancelDerivations(derivationAbort);
|
|
1272
1251
|
this.#drains.beginStop("daemon_stopping");
|
|
@@ -1328,15 +1307,22 @@ export default class Daemon {
|
|
|
1328
1307
|
// conclusion notifications. Join the supervisor-owned async tails only
|
|
1329
1308
|
// after those producers settle, before the caller may close SQLite.
|
|
1330
1309
|
const wakeResult = await settle("drains idle (wake)", () => this.#drains.idle());
|
|
1310
|
+
// {§db-maintenance-optimize} — the last database step before the caller closes SQLite:
|
|
1311
|
+
// planner statistics refreshed on the writer, bounded by SQLite's own analysis limit.
|
|
1312
|
+
// {§retention-policy} — the operator's retention runs once more before the statistics.
|
|
1313
|
+
const collectResult = await settle("retention", () => this.#retention.run());
|
|
1314
|
+
const optimizeResult = await settle("database optimize", () => this.#db.maintenance_optimize.run({}));
|
|
1331
1315
|
const closeErrors = [
|
|
1332
1316
|
moduleResult,
|
|
1333
1317
|
functionalityResult,
|
|
1334
1318
|
drainResult,
|
|
1335
1319
|
streamingResult,
|
|
1336
1320
|
derivationResult,
|
|
1321
|
+
collectResult,
|
|
1337
1322
|
...(mimetypeResult === null ? [] : [mimetypeResult]),
|
|
1338
1323
|
schemeResult,
|
|
1339
1324
|
wakeResult,
|
|
1325
|
+
optimizeResult,
|
|
1340
1326
|
]
|
|
1341
1327
|
.filter((result) => result.status === "rejected")
|
|
1342
1328
|
.flatMap((result) => result.reason instanceof AggregateError
|
|
@@ -1382,9 +1368,6 @@ export default class Daemon {
|
|
|
1382
1368
|
.filter(([key, value]) => {
|
|
1383
1369
|
if (value === undefined)
|
|
1384
1370
|
return false;
|
|
1385
|
-
if (key === "capabilities") {
|
|
1386
|
-
return !isDeepStrictEqual(CapabilityAdmission.intersect([effective.capabilities]), CapabilityAdmission.intersect([value]));
|
|
1387
|
-
}
|
|
1388
1371
|
return effective[key] !== value;
|
|
1389
1372
|
})
|
|
1390
1373
|
.map(([key, value]) => `${key}: ${JSON.stringify(effective[key])} -> ${JSON.stringify(value)}`);
|
|
@@ -1407,16 +1390,12 @@ export default class Daemon {
|
|
|
1407
1390
|
async #reconcileOrphanedPrompts(workerId, endedLoopId) {
|
|
1408
1391
|
const endedSeq = (await this.#db.engine_loop_sequence.get({ loop_id: endedLoopId }))?.sequence ?? endedLoopId;
|
|
1409
1392
|
const prefix = promptLoopPrefix(endedSeq);
|
|
1410
|
-
const frames = await this.#db.drain_orphaned_prompts_for_loop.all({ loop_id: endedLoopId,
|
|
1393
|
+
const frames = await this.#db.drain_orphaned_prompts_for_loop.all({ loop_id: endedLoopId, worker_id: workerId, pattern: `${prefix}%`, prefix_len: prefix.length });
|
|
1411
1394
|
const first = frames[0];
|
|
1412
1395
|
if (first === undefined)
|
|
1413
1396
|
return;
|
|
1414
|
-
const seqRow = await this.#db.loop_run_next_sequence.get({ worker_id: workerId });
|
|
1415
|
-
if (seqRow === undefined)
|
|
1416
|
-
throw new Error("reconcileOrphanedPrompts: next-sequence query returned no row");
|
|
1417
1397
|
const recovery = await this.#db.drain_enqueue_orphan_recovery_loop.get({
|
|
1418
1398
|
worker_id: workerId,
|
|
1419
|
-
sequence: seqRow.next,
|
|
1420
1399
|
prompt: first.body,
|
|
1421
1400
|
prompt_source: first.prompt_source,
|
|
1422
1401
|
policy: first.policy,
|
|
@@ -1432,7 +1411,7 @@ export default class Daemon {
|
|
|
1432
1411
|
if (recovery.status !== 100)
|
|
1433
1412
|
return;
|
|
1434
1413
|
const moved = await this.#db.drain_rehome_orphaned_prompt_frames.all({
|
|
1435
|
-
|
|
1414
|
+
worker_id: workerId,
|
|
1436
1415
|
source_loop_id: endedLoopId,
|
|
1437
1416
|
source_pattern: `${prefix}%`,
|
|
1438
1417
|
source_prefix_len: prefix.length,
|