@plurnk/plurnk-service 1.16.5 → 1.18.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 +140 -246
- package/INSTALL.md +84 -138
- package/README.md +10 -6
- package/SPEC.md +2468 -1694
- 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 +4 -1
- package/dist/content/read-resolve.d.ts.map +1 -1
- package/dist/content/read-resolve.js +42 -7
- package/dist/content/read-resolve.js.map +1 -1
- package/dist/core/AdmittedTurnExecutor.d.ts +2 -5
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +96 -88
- 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 +122 -93
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +15 -11
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +12 -13
- 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 +208 -161
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +24 -26
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +381 -232
- 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 +74 -164
- 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 +21 -0
- package/dist/core/ExecutorRegistry.d.ts +11 -5
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +37 -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 +44 -12
- 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 +12 -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 +31 -36
- 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 +161 -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.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 +41 -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 +26 -23
- 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 +15 -0
- package/dist/core/RuntimeWorker.js.map +1 -0
- package/dist/core/RuntimeWorker.sql +11 -0
- package/dist/core/SchemeRegistry.d.ts +12 -16
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +59 -85
- 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 +11 -8
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +63 -114
- 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 +77 -51
- 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} +24 -18
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -0
- package/dist/core/TurnDispositionHandler.js +206 -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 +47 -24
- 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 +8 -15
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +1175 -1317
- 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 +64 -48
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +11 -12
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +40 -47
- 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 +33 -10
- 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-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/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 +15 -1
- 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 +26 -20
- 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/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.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 +381 -388
- 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 +30 -91
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +1 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +58 -62
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/digest-rows.d.ts +16 -32
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +54 -20
- package/dist/schemes/Exec.d.ts +6 -12
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +318 -215
- 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/ExecScheduler.js +2 -2
- package/dist/schemes/ExecScheduler.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 -91
- 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 +7 -15
- 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 +117 -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 +159 -45
- 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 +20 -26
- 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 +5 -3
- package/dist/schemes/_search-index.d.ts.map +1 -1
- package/dist/schemes/_search-index.js +169 -160
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/_search-index.sql +47 -0
- package/dist/schemes/exec-abort.js +1 -1
- 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-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 +2 -2
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +7 -9
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +15 -21
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +165 -168
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +29 -22
- 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/EnvFunctionality.d.ts +43 -0
- package/dist/server/EnvFunctionality.d.ts.map +1 -0
- package/dist/server/EnvFunctionality.js +194 -0
- package/dist/server/EnvFunctionality.js.map +1 -0
- package/dist/server/Functionality.d.ts +12 -11
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +279 -142
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +5 -5
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +29 -57
- 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 -38
- 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 +25 -0
- package/dist/server/Retention.d.ts.map +1 -0
- package/dist/server/Retention.js +57 -0
- package/dist/server/Retention.js.map +1 -0
- package/dist/server/Retention.sql +59 -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 +102 -106
- 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 +38 -0
- package/dist/server/WorkspaceResidency.d.ts.map +1 -0
- package/dist/server/WorkspaceResidency.js +226 -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 +5 -46
- 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 +66 -43
- package/dist/server/envelope.d.ts +8 -1
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +9 -19
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +49 -13
- package/dist/server/lifecycle-recovery.sql +18 -20
- 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 +64 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +21 -18
- package/dist/service.js.map +1 -1
- package/docs/env.md +55 -0
- package/docs/members.md +83 -0
- package/docs/skills.md +50 -0
- package/migrations/001_workspaces.sql +53 -0
- package/migrations/002_workers.sql +198 -0
- package/migrations/003_loops.sql +326 -0
- package/migrations/004_inference.sql +401 -0
- package/migrations/005_entries.sql +215 -0
- package/migrations/006_log.sql +581 -0
- package/migrations/007_subscriptions.sql +175 -0
- package/migrations/008_interactions.sql +29 -0
- package/package.json +44 -41
- 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,31 @@ 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";
|
|
26
|
+
import EnvFunctionality from "./EnvFunctionality.js";
|
|
25
27
|
import Fork from "../core/fork.js";
|
|
26
28
|
import WorkerControlAddress from "../core/WorkerControlAddress.js";
|
|
27
|
-
import LoopLifecycle from "../core/LoopLifecycle.js";
|
|
29
|
+
import LoopLifecycle, { taskTiming } from "../core/LoopLifecycle.js";
|
|
30
|
+
import LoopPolicyReader from "../core/LoopPolicyReader.js";
|
|
28
31
|
import { promptLoopPrefix } from "../core/plurnk-uri.js";
|
|
29
32
|
import { contentWeight } from "../core/content-weight.js";
|
|
30
33
|
import { parseAliasesFromEnv, resolveActiveRoute } from "@plurnk/plurnk-providers";
|
|
31
34
|
import ProviderInstantiate from "../core/ProviderInstantiate.js";
|
|
32
|
-
import LoopPolicyReader from "../core/LoopPolicyReader.js";
|
|
33
|
-
import CapabilityPolicies from "../core/CapabilityPolicies.js";
|
|
34
35
|
import Results, { OperationFailureError } from "../core/results.js";
|
|
35
36
|
import WorkspaceGate from "../core/WorkspaceGate.js";
|
|
36
|
-
import
|
|
37
|
+
import WorkspaceResidency from "./WorkspaceResidency.js";
|
|
37
38
|
import Functionality from "./Functionality.js";
|
|
38
39
|
import { observed, observedSync } from "../observe/spans.js";
|
|
39
40
|
import { listModelCatalog } from "./model-catalog.js";
|
|
@@ -67,6 +68,8 @@ export default class Daemon {
|
|
|
67
68
|
#moduleActions = new Map();
|
|
68
69
|
#residency;
|
|
69
70
|
#functionality;
|
|
71
|
+
// {§retention-policy} — the operator's retention, run on a cadence and at shutdown.
|
|
72
|
+
#retention;
|
|
70
73
|
#skills;
|
|
71
74
|
#members;
|
|
72
75
|
// {§methods-event-subscribe} — the broadcast's in-process event source. A transport
|
|
@@ -106,9 +109,9 @@ export default class Daemon {
|
|
|
106
109
|
});
|
|
107
110
|
return row !== undefined;
|
|
108
111
|
});
|
|
109
|
-
// {§module-
|
|
112
|
+
// {§module-workspace-residency} — residency, activation/cooling, and
|
|
110
113
|
// capability replacement live in their one owner; the Daemon delegates.
|
|
111
|
-
this.#residency = new
|
|
114
|
+
this.#residency = new WorkspaceResidency({
|
|
112
115
|
db,
|
|
113
116
|
engine: () => this.#engine,
|
|
114
117
|
workspaceGate: this.#workspaceGate,
|
|
@@ -118,19 +121,32 @@ export default class Daemon {
|
|
|
118
121
|
// adapter; Core hosts it, modules register adapters through the seam.
|
|
119
122
|
this.#functionality = new Functionality({
|
|
120
123
|
registerModuleAction: (registration) => this.registerModuleAction(registration),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
registerWorkspaceCapabilityProvider: (owner, provider) => this.registerWorkspaceCapabilityProvider(owner, provider),
|
|
125
|
+
readWorkspaceModuleState: (workspaceId, owner) => this.readWorkspaceModuleState(workspaceId, owner),
|
|
126
|
+
replaceWorkspaceCapabilities: (replacement, options) => this.replaceWorkspaceCapabilities(replacement, options),
|
|
127
|
+
readWorkerModuleState: (workerId, owner) => this.#residency.readWorkerModuleState(workerId, owner),
|
|
128
|
+
replaceWorkerModuleState: (workerId, owner, state) => this.#residency.replaceWorkerModuleState(workerId, owner, state),
|
|
129
|
+
mutateWorkspace: (workspaceId, owner, caller, run) => this.#residency.exclusively(workspaceId, owner, caller === "operation" ? "wait" : "try", run),
|
|
130
|
+
retainWorkspace: (workspaceId) => this.#residency.retain(workspaceId)
|
|
125
131
|
});
|
|
126
132
|
// {§skills-functionality} — Core's own family: standard Agent Skills.
|
|
127
|
-
this.#skills = new SkillsFunctionality({
|
|
133
|
+
this.#skills = new SkillsFunctionality({
|
|
134
|
+
db,
|
|
135
|
+
...skills,
|
|
136
|
+
provided: async () => {
|
|
137
|
+
const tree = await PlurnkSkill.load(this.#nodeModulesPath);
|
|
138
|
+
return new Map([[tree.document.name, tree]]);
|
|
139
|
+
},
|
|
140
|
+
});
|
|
128
141
|
this.#skills.attach(this.#functionality.register(this.#skills));
|
|
142
|
+
this.#schemes.register("skill", new Skill((workspaceId) => this.#skills.trees(workspaceId)));
|
|
129
143
|
// {§members-functionality} — Core's own family: file membership on the same surface.
|
|
130
144
|
this.#members = new MembersFunctionality({ db, engine: () => this.#engine });
|
|
131
145
|
this.#functionality.register(this.#members);
|
|
146
|
+
// {§env-functionality} — Core's own family: the environment a Worker's commands run in.
|
|
147
|
+
this.#functionality.register(new EnvFunctionality(EnvFunctionality.defaultsReader(Paths.packageRoot, this.#nodeModulesPath)));
|
|
132
148
|
this.#engine = new Engine({
|
|
133
|
-
db, schemes: this.#schemes, mimetypes: this.#mimetypes,
|
|
149
|
+
db, lifecycle: this.#lifecycle, schemes: this.#schemes, mimetypes: this.#mimetypes,
|
|
134
150
|
// {§tokenomics-agnostic-ruler} — stored and catalog curation weights
|
|
135
151
|
// are workspace-wide across concurrent models, so they remain
|
|
136
152
|
// model-independent. Request-shaped token facts stay provider-owned.
|
|
@@ -143,14 +159,18 @@ export default class Daemon {
|
|
|
143
159
|
// daemon owns provider + the law-file system prompt; the worker scheme
|
|
144
160
|
// handler carries neither. Fire-and-forget: the returned drain runs
|
|
145
161
|
// independently (the sister is its own worker). {§machine-processes}
|
|
146
|
-
injectWorker: async ({ workspaceId, workerId,
|
|
162
|
+
injectWorker: async ({ workspaceId, workerId, sourceLoopId, prompt, freshLoopPolicy, spawn, schedule, environment }) => {
|
|
147
163
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
148
|
-
const
|
|
164
|
+
const sender = await this.#db.drain_message_source.get({ loop_id: sourceLoopId });
|
|
165
|
+
if (sender === undefined || sender.workspace_id !== workspaceId) {
|
|
166
|
+
throw new Error(`injectWorker: source loop ${sourceLoopId} does not belong to workspace ${workspaceId}`);
|
|
167
|
+
}
|
|
168
|
+
const source = await this.#workerPromptSource(workspaceId, sender.worker_id, workerId);
|
|
149
169
|
const systemPrompt = await readFile(Paths.instructionsSystem, "utf8");
|
|
150
170
|
let providerSpec;
|
|
151
171
|
let childProviderSpec;
|
|
152
172
|
let reasoningPolicy;
|
|
153
|
-
if (
|
|
173
|
+
if (spawn !== true) {
|
|
154
174
|
// {§worker-model-selection} — the voice door addresses an
|
|
155
175
|
// existing worker. Its own durable generation policy is the
|
|
156
176
|
// receiver's identity; the daemon default and sender do not
|
|
@@ -164,24 +184,33 @@ export default class Daemon {
|
|
|
164
184
|
childProviderSpec = await this.#workerModels.resolveWorkerSpawnModel(workerId, undefined);
|
|
165
185
|
}
|
|
166
186
|
else {
|
|
167
|
-
const parentPolicy = await this.#providerPolicyForLoop(
|
|
187
|
+
const parentPolicy = await this.#providerPolicyForLoop(sourceLoopId);
|
|
168
188
|
providerSpec = parentPolicy.childProviderSpec ?? parentPolicy.providerSpec;
|
|
169
189
|
reasoningPolicy = parentPolicy.reasoningPolicy;
|
|
170
190
|
// {§worker-model-selection} — lineage inheritance by value:
|
|
171
191
|
// the child begins with the spawning loop's effective spawn
|
|
172
192
|
// model and no separate override of its own.
|
|
173
193
|
childProviderSpec = null;
|
|
174
|
-
|
|
175
|
-
|
|
194
|
+
// {§worker-reasoning-source} — inherited by value, chosen by nobody on this worker.
|
|
195
|
+
await this.#workerModels.persistGenerationPolicy(workerId, {
|
|
176
196
|
model_route_id: await routeForSpec(this.#db, providerSpec),
|
|
177
197
|
spawn_model_route_id: null,
|
|
178
|
-
reasoning_policy: reasoningPolicy
|
|
198
|
+
reasoning_policy: reasoningPolicy,
|
|
199
|
+
reasoning_source: "default"
|
|
179
200
|
});
|
|
201
|
+
// {§env-option} — the heading's environment lands as the child's own entries through the
|
|
202
|
+
// family's add, after the copy it inherited at creation ({§functionality-scope}); names
|
|
203
|
+
// were admitted at the operation, so a refusal here is a defect and throws.
|
|
204
|
+
for (const [alias, value] of Object.entries(environment ?? {})) {
|
|
205
|
+
await this.#functionality.invoke("env", "add", { alias, definition: { value } }, { workspaceId, workerId }, "operation");
|
|
206
|
+
}
|
|
180
207
|
}
|
|
181
|
-
const { action, loopId } = await this.inject({
|
|
208
|
+
const { action, loopId, scheduledAt, intervalMinutes, recurrenceId } = await this.inject({
|
|
182
209
|
workspaceId,
|
|
183
210
|
workerId,
|
|
184
211
|
prompt,
|
|
212
|
+
sourceLoopId,
|
|
213
|
+
...(schedule === undefined ? {} : { schedule }),
|
|
185
214
|
...(source === undefined ? {} : { source }),
|
|
186
215
|
providerSpec,
|
|
187
216
|
reasoningPolicy,
|
|
@@ -189,14 +218,14 @@ export default class Daemon {
|
|
|
189
218
|
systemPrompt,
|
|
190
219
|
...(freshLoopPolicy === undefined ? {} : { freshLoopPolicy })
|
|
191
220
|
});
|
|
192
|
-
return { action, loopId };
|
|
221
|
+
return { action, loopId, scheduledAt, intervalMinutes, recurrenceId };
|
|
193
222
|
},
|
|
194
|
-
acquireWorkspaceTurn: async (workspaceId, workerId) => this.#workspaceGate.acquireTurn(workspaceId, workerId),
|
|
223
|
+
acquireWorkspaceTurn: async (workspaceId, workerId, signal) => this.#workspaceGate.acquireTurn(workspaceId, workerId, signal),
|
|
195
224
|
// {§skills-hotload} — filesystem installers operate out of band.
|
|
196
225
|
// Republish under the workspace turn gate before packet assembly so
|
|
197
226
|
// the first subsequent model turn sees their exact result.
|
|
198
|
-
workspaceTurnStarting: async ({ workspaceId
|
|
199
|
-
await this.#skills.refreshIfChanged({ workspaceId
|
|
227
|
+
workspaceTurnStarting: async ({ workspaceId }) => {
|
|
228
|
+
await this.#skills.refreshIfChanged({ workspaceId });
|
|
200
229
|
},
|
|
201
230
|
// worker:// KILL (terminate) — cancel the addressed worker subtree and
|
|
202
231
|
// tear down its held streams before the operation completes.
|
|
@@ -207,10 +236,11 @@ export default class Daemon {
|
|
|
207
236
|
this.#broadcast({ workspaceId }, "loop/packet", payload);
|
|
208
237
|
}
|
|
209
238
|
});
|
|
239
|
+
this.#retention = new Retention(db, retentionPolicy());
|
|
210
240
|
this.#drains = new DrainSupervisor({
|
|
211
241
|
db,
|
|
212
242
|
lifecycle: this.#lifecycle,
|
|
213
|
-
injectPrompt: (
|
|
243
|
+
injectPrompt: (loopId, prompt, openPaths, source) => this.#engine.injectIntoLoop(loopId, prompt, openPaths, source),
|
|
214
244
|
assertInjectionCompatibility: async ({ workerId, loopId, providerSpec, providerSpecExplicit, reasoningPolicy, childProviderSpec, turnCeiling, policy }) => {
|
|
215
245
|
await this.#assertFoldPosture(workerId, policy, loopId);
|
|
216
246
|
// An omitted selector keeps the loop's durable provider; only an
|
|
@@ -229,12 +259,12 @@ export default class Daemon {
|
|
|
229
259
|
// The drain callback is the final provider/model boundary. Every
|
|
230
260
|
// admission path, including boot recovery, terminates here.
|
|
231
261
|
await this.#assertModelWorker(workspaceId, workerId);
|
|
232
|
-
const releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
262
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
233
263
|
try {
|
|
234
264
|
// Worker settings can change while Functionality remains
|
|
235
265
|
// resident. Reconcile the worker-private discovery surface
|
|
236
266
|
// at the same pre-inference boundary used for activation.
|
|
237
|
-
await this.#residency.reconcile(workspaceId
|
|
267
|
+
await this.#residency.reconcile(workspaceId);
|
|
238
268
|
const { provider, childProvider } = await this.#providersForLoop(loopId);
|
|
239
269
|
return await this.#engine.runLoop({
|
|
240
270
|
provider,
|
|
@@ -257,15 +287,8 @@ export default class Daemon {
|
|
|
257
287
|
},
|
|
258
288
|
loopUsage: (loopId) => this.#engine.loopUsage(loopId),
|
|
259
289
|
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
290
|
cancelSubscription: (subscriptionId) => this.#engine.cancelSubscription(subscriptionId),
|
|
266
291
|
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
292
|
readSystemPrompt: () => readFile(Paths.instructionsSystem, "utf8"),
|
|
270
293
|
emitLogEntry: async (workspaceId, logEntryId) => {
|
|
271
294
|
const entry = await LogEntry.fetchLogEntry(this.#db, logEntryId);
|
|
@@ -469,58 +492,44 @@ export default class Daemon {
|
|
|
469
492
|
}
|
|
470
493
|
// {§methods-model-worker} — the workspace's model worker (created on first use), distinct from the client
|
|
471
494
|
// 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) {
|
|
495
|
+
async ensureModelWorker(workspaceId) {
|
|
475
496
|
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);
|
|
497
|
+
return await Envelope.ensureModelWorker(this.#db, checked);
|
|
498
|
+
}
|
|
499
|
+
async readWorkspaceCapabilities(args) {
|
|
500
|
+
const workspaceId = ClientInput.assertId("workspace.capabilities.get", "workspaceId", args.workspaceId);
|
|
501
|
+
return this.#engine.capabilityProjection(workspaceId);
|
|
502
|
+
}
|
|
503
|
+
// {§workspace-capability-policy} Policy changes share the workspace's
|
|
504
|
+
// quiescent publication boundary; no in-flight proposal can change authority.
|
|
505
|
+
async setWorkspaceCapabilities(args) {
|
|
506
|
+
const workspaceId = ClientInput.assertId("workspace.capabilities.set", "workspaceId", args.workspaceId);
|
|
507
|
+
const settings = JSON.parse(ClientInput.parseSettings({ capabilities: args.policy }));
|
|
508
|
+
if (settings.capabilities === undefined)
|
|
509
|
+
throw daemonFailure("daemon:input", "capability-policy-required", 400, "policy is required.", { field: "policy", retryable: false });
|
|
510
|
+
return this.#residency.exclusively(workspaceId, "capabilities", "try", async () => {
|
|
511
|
+
const row = await this.#db.workspace_capability_policy_update.get({
|
|
512
|
+
workspace_id: workspaceId, policy: JSON.stringify(settings.capabilities),
|
|
513
|
+
});
|
|
514
|
+
if (row === undefined)
|
|
515
|
+
throw daemonFailure("daemon:workspace", "workspace-not-found", 404, `Workspace ${workspaceId} does not exist.`, { workspaceId });
|
|
516
|
+
return await this.#engine.capabilityProjection(workspaceId);
|
|
517
|
+
});
|
|
509
518
|
}
|
|
510
519
|
// {§worker-model-selection} — project a worker's durable model and spawn override
|
|
511
520
|
// for a client-interface get/set surface. Ownership is checked at this boundary.
|
|
512
521
|
async readWorkerModel(args) {
|
|
513
522
|
const workspaceId = ClientInput.assertId("worker.model.get", "workspaceId", args.workspaceId);
|
|
514
523
|
const workerId = ClientInput.assertId("worker.model.get", "workerId", args.workerId);
|
|
515
|
-
await this.#
|
|
524
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
516
525
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
517
526
|
if (row === undefined)
|
|
518
527
|
throw new Error(`worker ${workerId}: model route row missing`);
|
|
519
528
|
const modelSpec = await specForRoute(this.#db, row.model_route_id);
|
|
520
529
|
const spawnModelSpec = await specForRoute(this.#db, row.spawn_model_route_id);
|
|
521
530
|
return {
|
|
522
|
-
model: modelSpec === null ? null : projectModelRoute(modelSpec, row.reasoning_policy),
|
|
523
|
-
spawnModel: spawnModelSpec === null ? null : projectModelRoute(spawnModelSpec, row.reasoning_policy)
|
|
531
|
+
model: modelSpec === null ? null : projectModelRoute(modelSpec, row.reasoning_policy, row.reasoning_source),
|
|
532
|
+
spawnModel: spawnModelSpec === null ? null : projectModelRoute(spawnModelSpec, row.reasoning_policy, row.reasoning_source)
|
|
524
533
|
};
|
|
525
534
|
}
|
|
526
535
|
// {§worker-model-selection} — persist an explicit model selection onto the worker
|
|
@@ -528,31 +537,20 @@ export default class Daemon {
|
|
|
528
537
|
async setWorkerModel(args) {
|
|
529
538
|
const workspaceId = ClientInput.assertId("worker.model.set", "workspaceId", args.workspaceId);
|
|
530
539
|
const workerId = ClientInput.assertId("worker.model.set", "workerId", args.workerId);
|
|
531
|
-
await this.#
|
|
532
|
-
await this.#assertWorkerSelectable(workerId);
|
|
540
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
533
541
|
const selector = ClientInput.assertSelector("worker.model.set", "selector", args.selector);
|
|
534
542
|
const policy = await this.#workerModels.resolveWorkerModel(workerId, selector);
|
|
535
543
|
if (policy === null) {
|
|
536
544
|
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
545
|
}
|
|
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));
|
|
546
|
+
return projectModelRoute(policy.providerSpec, policy.reasoningPolicy, policy.reasoningSource);
|
|
549
547
|
}
|
|
550
548
|
// {§worker-reasoning-policy} — the worker's reasoning policy is durable and
|
|
551
549
|
// provider-relative. A model-less worker remains explicitly uninitialized.
|
|
552
550
|
async readWorkerReasoning(args) {
|
|
553
551
|
const workspaceId = ClientInput.assertId("worker.reasoning.get", "workspaceId", args.workspaceId);
|
|
554
552
|
const workerId = ClientInput.assertId("worker.reasoning.get", "workerId", args.workerId);
|
|
555
|
-
await this.#
|
|
553
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
556
554
|
await this.#workerModels.resolveWorkerModel(workerId, undefined);
|
|
557
555
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
558
556
|
if (row === undefined)
|
|
@@ -561,17 +559,15 @@ export default class Daemon {
|
|
|
561
559
|
if (row.reasoning_policy !== null) {
|
|
562
560
|
throw new Error(`worker ${workerId}: reasoning policy exists without a model route`);
|
|
563
561
|
}
|
|
564
|
-
return { policy: null, supportedPolicies: [] };
|
|
562
|
+
return { policy: null, source: "default", supportedPolicies: [] };
|
|
565
563
|
}
|
|
566
564
|
if (row.reasoning_policy === null) {
|
|
567
565
|
throw new Error(`worker ${workerId}: durable model has no reasoning policy`);
|
|
568
566
|
}
|
|
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
567
|
return {
|
|
573
568
|
policy: row.reasoning_policy,
|
|
574
|
-
|
|
569
|
+
source: row.reasoning_source,
|
|
570
|
+
supportedPolicies: await this.#workerModels.supportedPolicies(row)
|
|
575
571
|
};
|
|
576
572
|
}
|
|
577
573
|
// {§worker-reasoning-policy} — mutate between loops, validate against both
|
|
@@ -586,8 +582,7 @@ export default class Daemon {
|
|
|
586
582
|
catch (cause) {
|
|
587
583
|
throw daemonFailure("daemon:input", "reasoning-policy-invalid", 400, cause instanceof Error ? cause.message : "The reasoning policy is invalid.", { field: "policy", retryable: false });
|
|
588
584
|
}
|
|
589
|
-
await this.#
|
|
590
|
-
await this.#assertWorkerSelectable(workerId);
|
|
585
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
591
586
|
await this.#workerModels.resolveWorkerModel(workerId, undefined);
|
|
592
587
|
const row = await this.#db.worker_generation_policy_read.get({ id: workerId });
|
|
593
588
|
if (row === undefined)
|
|
@@ -601,41 +596,26 @@ export default class Daemon {
|
|
|
601
596
|
retryable: false
|
|
602
597
|
});
|
|
603
598
|
}
|
|
604
|
-
const supportedPolicies = await this.#
|
|
605
|
-
await this.#db.worker_generation_policy_update.run({
|
|
606
|
-
id: workerId,
|
|
599
|
+
const supportedPolicies = await this.#workerModels.persistGenerationPolicy(workerId, {
|
|
607
600
|
model_route_id: row.model_route_id,
|
|
608
601
|
spawn_model_route_id: row.spawn_model_route_id,
|
|
609
|
-
reasoning_policy: policy
|
|
602
|
+
reasoning_policy: policy,
|
|
603
|
+
reasoning_source: "explicit"
|
|
610
604
|
});
|
|
611
|
-
return { policy, supportedPolicies };
|
|
605
|
+
return { policy, source: "explicit", supportedPolicies };
|
|
612
606
|
}
|
|
613
607
|
// {§worker-model-selection} — persist the worker's spawn override; a null
|
|
614
608
|
// selector means inherit (clears the override).
|
|
615
609
|
async setWorkerSpawnModel(args) {
|
|
616
610
|
const workspaceId = ClientInput.assertId("worker.child.set", "workspaceId", args.workspaceId);
|
|
617
611
|
const workerId = ClientInput.assertId("worker.child.set", "workerId", args.workerId);
|
|
618
|
-
await this.#
|
|
619
|
-
await this.#assertWorkerSelectable(workerId);
|
|
612
|
+
await this.#assertModelWorker(workspaceId, workerId);
|
|
620
613
|
const selector = ClientInput.assertChildSelector("worker.child.set", args.selector);
|
|
621
614
|
const spec = await this.#workerModels.resolveWorkerSpawnModel(workerId, selector);
|
|
622
615
|
if (spec === null)
|
|
623
616
|
return null;
|
|
624
617
|
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
|
-
}
|
|
618
|
+
return projectModelRoute(spec, row?.reasoning_policy ?? null, row?.reasoning_source ?? "default");
|
|
639
619
|
}
|
|
640
620
|
async #assertWorkerOwned(workspaceId, workerId) {
|
|
641
621
|
const owner = await this.#db.envelope_get_worker_by_id.get({ id: workerId });
|
|
@@ -647,8 +627,9 @@ export default class Daemon {
|
|
|
647
627
|
}
|
|
648
628
|
}
|
|
649
629
|
// {§machine-processes} — provider inference is an exclusive capability of a
|
|
650
|
-
// model worker. The same assertion is used by early client admissions
|
|
651
|
-
//
|
|
630
|
+
// model worker. The same assertion is used by early client admissions, the final
|
|
631
|
+
// drain callback, and the model, reasoning, and spawn-model controls
|
|
632
|
+
// ({§worker-model-selection}), so recovery and internal callers cannot bypass it.
|
|
652
633
|
async #assertModelWorker(workspaceId, workerId) {
|
|
653
634
|
const worker = await this.#db.envelope_get_worker_by_id.get({ id: workerId });
|
|
654
635
|
if (worker === undefined) {
|
|
@@ -666,7 +647,7 @@ export default class Daemon {
|
|
|
666
647
|
throw daemonFailure("daemon:worker", "model-worker-required", 409, `Worker ${workerId} is not a model worker.`, {
|
|
667
648
|
workerId,
|
|
668
649
|
actualOrigin: worker.origin,
|
|
669
|
-
recovery: "Select or create a model worker
|
|
650
|
+
recovery: "Select or create a model worker.",
|
|
670
651
|
retryable: false
|
|
671
652
|
});
|
|
672
653
|
}
|
|
@@ -687,20 +668,19 @@ export default class Daemon {
|
|
|
687
668
|
// grammar package and hands over the statement, then fans the emitted entry out to its own clients.
|
|
688
669
|
// {§functionality-model-mutation} — await every queued Functionality
|
|
689
670
|
// publication (a Worker's accepted mutation publishes at its turn boundary).
|
|
690
|
-
async settleFunctionality(
|
|
691
|
-
await this.#functionality.settle(
|
|
671
|
+
async settleFunctionality(workspaceId) {
|
|
672
|
+
await this.#functionality.settle(workspaceId);
|
|
692
673
|
}
|
|
693
674
|
async dispatchAsClient(args) {
|
|
694
675
|
const workspaceId = ClientInput.assertId("operation.dispatch", "workspaceId", args.workspaceId);
|
|
695
676
|
const workerId = ClientInput.assertId("operation.dispatch", "workerId", args.workerId);
|
|
696
|
-
const functionalityWorkerId = ClientInput.assertId("operation.dispatch", "functionalityWorkerId", args.functionalityWorkerId);
|
|
697
677
|
const { statement } = args;
|
|
698
|
-
await this.#assertWorkerOwned(workspaceId,
|
|
699
|
-
const releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
678
|
+
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
679
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
700
680
|
try {
|
|
701
681
|
const clientLoopId = await Envelope.ensureClientLoop(this.#db, workerId);
|
|
702
682
|
try {
|
|
703
|
-
const result = await this.#dispatchClientStatement({ workspaceId, workerId,
|
|
683
|
+
const result = await this.#dispatchClientStatement({ workspaceId, workerId, loopId: clientLoopId, statement });
|
|
704
684
|
await Envelope.closeClientLoop(this.#db, clientLoopId, { status: 200 });
|
|
705
685
|
return result;
|
|
706
686
|
}
|
|
@@ -717,23 +697,25 @@ export default class Daemon {
|
|
|
717
697
|
// loop, regardless of how many statements op.parse produced. Each statement is one
|
|
718
698
|
// ordinary operation turn; a proposal may keep that turn and loop open across
|
|
719
699
|
// interrupt/resume until settlement.
|
|
700
|
+
executorTags(workspaceId) {
|
|
701
|
+
return this.#engine.executorTags(workspaceId);
|
|
702
|
+
}
|
|
720
703
|
async dispatchClientAction(args) {
|
|
721
704
|
const workspaceId = ClientInput.assertId("operation.dispatch-batch", "workspaceId", args.workspaceId);
|
|
722
705
|
const workerId = ClientInput.assertId("operation.dispatch-batch", "workerId", args.workerId);
|
|
723
|
-
const functionalityWorkerId = ClientInput.assertId("operation.dispatch-batch", "functionalityWorkerId", args.functionalityWorkerId);
|
|
724
706
|
const { statements } = args;
|
|
725
707
|
if (statements.length === 0)
|
|
726
708
|
return [];
|
|
727
|
-
await this.#assertWorkerOwned(workspaceId,
|
|
728
|
-
// {§actor-boundary-attached-functionality}
|
|
729
|
-
//
|
|
730
|
-
const releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
709
|
+
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
710
|
+
// {§actor-boundary-attached-functionality} The client retains its journal;
|
|
711
|
+
// the workspace supplies policy and the shared runtime environment.
|
|
712
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
731
713
|
try {
|
|
732
714
|
const clientLoopId = await Envelope.ensureClientLoop(this.#db, workerId);
|
|
733
715
|
try {
|
|
734
716
|
const results = [];
|
|
735
717
|
for (const statement of statements) {
|
|
736
|
-
results.push(await this.#dispatchClientStatement({ workspaceId, workerId,
|
|
718
|
+
results.push(await this.#dispatchClientStatement({ workspaceId, workerId, loopId: clientLoopId, statement }));
|
|
737
719
|
}
|
|
738
720
|
await Envelope.closeClientLoop(this.#db, clientLoopId, { status: 200 });
|
|
739
721
|
return results;
|
|
@@ -748,9 +730,10 @@ export default class Daemon {
|
|
|
748
730
|
}
|
|
749
731
|
}
|
|
750
732
|
async #dispatchClientStatement(args) {
|
|
751
|
-
const { workspaceId, workerId,
|
|
733
|
+
const { workspaceId, workerId, loopId, statement } = args;
|
|
752
734
|
const release = await this.#workspaceGate.acquireTurn(workspaceId, workerId);
|
|
753
735
|
try {
|
|
736
|
+
await this.#residency.reconcile(workspaceId);
|
|
754
737
|
const { id: turnId } = await Turn.open(this.#db, {
|
|
755
738
|
loopId,
|
|
756
739
|
producer: "client",
|
|
@@ -760,7 +743,7 @@ export default class Daemon {
|
|
|
760
743
|
try {
|
|
761
744
|
const entryIds = [];
|
|
762
745
|
const result = await this.#engine.dispatch({
|
|
763
|
-
statement, workspaceId, workerId,
|
|
746
|
+
statement, workspaceId, workerId, loopId, turnId, sequence: 1,
|
|
764
747
|
origin: "client", onDispatch: (logEntryId) => { entryIds.push(logEntryId); }
|
|
765
748
|
});
|
|
766
749
|
await Turn.complete(this.#db, turnId, result.status);
|
|
@@ -793,19 +776,25 @@ export default class Daemon {
|
|
|
793
776
|
// dispatchClientAction). Its closed observation segment supplies the numeric loop coordinate
|
|
794
777
|
// required by plugin context and relative log:/// addresses without impersonating an active
|
|
795
778
|
// client lifecycle. It creates no turn or log row. Engine.look enforces READ-only.
|
|
779
|
+
// {§op-look} — the segment is the acting worker's; the READ resolves as the perspective worker.
|
|
796
780
|
async look(args) {
|
|
797
781
|
const workspaceId = ClientInput.assertId("operation.look", "workspaceId", args.workspaceId);
|
|
798
782
|
const workerId = ClientInput.assertId("operation.look", "workerId", args.workerId);
|
|
799
|
-
const
|
|
783
|
+
const perspective = args.perspectiveWorkerId === undefined
|
|
784
|
+
? workerId
|
|
785
|
+
: ClientInput.assertId("operation.look", "perspectiveWorkerId", args.perspectiveWorkerId);
|
|
800
786
|
const { statement } = args;
|
|
801
|
-
await this.#assertWorkerOwned(workspaceId,
|
|
802
|
-
|
|
787
|
+
await this.#assertWorkerOwned(workspaceId, workerId);
|
|
788
|
+
if (perspective !== workerId)
|
|
789
|
+
await this.#assertWorkerOwned(workspaceId, perspective);
|
|
790
|
+
const releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
803
791
|
try {
|
|
804
792
|
const releaseWorkspace = await this.#workspaceGate.acquireTurn(workspaceId, workerId);
|
|
805
793
|
try {
|
|
794
|
+
await this.#residency.reconcile(workspaceId);
|
|
806
795
|
const clientLoopId = await Envelope.ensureClientLoop(this.#db, workerId);
|
|
807
796
|
try {
|
|
808
|
-
const result = await this.#engine.look({ statement, workspaceId, workerId
|
|
797
|
+
const result = await this.#engine.look({ statement, workspaceId, workerId: perspective, loopId: clientLoopId });
|
|
809
798
|
await Envelope.closeClientLoop(this.#db, clientLoopId, { status: 200 });
|
|
810
799
|
return result;
|
|
811
800
|
}
|
|
@@ -899,7 +888,7 @@ export default class Daemon {
|
|
|
899
888
|
});
|
|
900
889
|
if (row === undefined || row.workspace_id !== workspaceId)
|
|
901
890
|
return null;
|
|
902
|
-
const { workspace_id: _workspaceId, ...projection } = row;
|
|
891
|
+
const { workspace_id: _workspaceId, ...projection } = projectWorkerRow(row);
|
|
903
892
|
return projection;
|
|
904
893
|
}
|
|
905
894
|
async listWorkerLoops(args) {
|
|
@@ -916,6 +905,7 @@ export default class Daemon {
|
|
|
916
905
|
promptSource: row.promptSource,
|
|
917
906
|
terminatedAt: row.terminatedAt,
|
|
918
907
|
packetCount: row.packetCount,
|
|
908
|
+
...taskTiming(row),
|
|
919
909
|
terminalResult: row.terminalResult === null
|
|
920
910
|
? null
|
|
921
911
|
: Validator.assertOperationResult(JSON.parse(row.terminalResult))
|
|
@@ -976,13 +966,10 @@ export default class Daemon {
|
|
|
976
966
|
if (name !== undefined) {
|
|
977
967
|
const taken = await this.#db.envelope_get_worker_by_name.get({ workspace_id: workspaceId, name });
|
|
978
968
|
if (taken !== undefined) {
|
|
979
|
-
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 });
|
|
969
|
+
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 });
|
|
980
970
|
}
|
|
981
971
|
}
|
|
982
972
|
const worker = await Envelope.createModelWorker(this.#db, workspaceId, name);
|
|
983
|
-
if (args.settings !== undefined) {
|
|
984
|
-
await this.#mergeWorkerSettings(worker.id, args.settings);
|
|
985
|
-
}
|
|
986
973
|
return { workerId: worker.id, workerName: worker.name };
|
|
987
974
|
}
|
|
988
975
|
// {§worker-scheme-fork} — branch a worker's log while sharing the workspace world.
|
|
@@ -1006,10 +993,10 @@ export default class Daemon {
|
|
|
1006
993
|
if (name !== undefined) {
|
|
1007
994
|
const taken = await this.#db.envelope_get_worker_by_name.get({ workspace_id: workspaceId, name });
|
|
1008
995
|
if (taken !== undefined) {
|
|
1009
|
-
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 });
|
|
996
|
+
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 });
|
|
1010
997
|
}
|
|
1011
998
|
}
|
|
1012
|
-
const branchWorkerId = await Fork.fork(this.#db, workerId, name
|
|
999
|
+
const branchWorkerId = await Fork.fork(this.#db, workerId, name);
|
|
1013
1000
|
const branch = await this.#db.envelope_get_worker_by_id.get({ id: branchWorkerId });
|
|
1014
1001
|
return { workerId: branchWorkerId, workerName: branch?.name ?? null, parentWorkerId: workerId };
|
|
1015
1002
|
}
|
|
@@ -1095,7 +1082,7 @@ export default class Daemon {
|
|
|
1095
1082
|
}
|
|
1096
1083
|
let releaseCapabilities;
|
|
1097
1084
|
if (context.scope === "workspace") {
|
|
1098
|
-
|
|
1085
|
+
releaseCapabilities = await this.#residency.acquire(context.workspaceId);
|
|
1099
1086
|
}
|
|
1100
1087
|
else if (context.scope === "worker") {
|
|
1101
1088
|
const workspaceId = ClientInput.assertId(`module action '${name}'`, "workspaceId", context.workspaceId);
|
|
@@ -1104,25 +1091,34 @@ export default class Daemon {
|
|
|
1104
1091
|
if (worker === undefined || worker.workspace_id !== workspaceId) {
|
|
1105
1092
|
throw daemonFailure("daemon:module-action", "worker-not-found", 404, `Worker ${workerId} does not exist in workspace ${workspaceId}.`, { workspaceId, workerId, retryable: false });
|
|
1106
1093
|
}
|
|
1107
|
-
releaseCapabilities = await this.#residency.acquire(workspaceId
|
|
1094
|
+
releaseCapabilities = await this.#residency.acquire(workspaceId);
|
|
1108
1095
|
}
|
|
1109
1096
|
try {
|
|
1097
|
+
if (context.scope === "worker") {
|
|
1098
|
+
const release = await this.#workspaceGate.acquireTurn(context.workspaceId, context.workerId);
|
|
1099
|
+
try {
|
|
1100
|
+
await this.#residency.reconcile(context.workspaceId);
|
|
1101
|
+
}
|
|
1102
|
+
finally {
|
|
1103
|
+
release();
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1110
1106
|
return await registration.handler(params, context);
|
|
1111
1107
|
}
|
|
1112
1108
|
finally {
|
|
1113
1109
|
releaseCapabilities?.();
|
|
1114
1110
|
}
|
|
1115
1111
|
}
|
|
1116
|
-
|
|
1112
|
+
registerWorkspaceCapabilityProvider(namespaceOwner, provider) {
|
|
1117
1113
|
this.#residency.registerProvider(namespaceOwner, provider);
|
|
1118
1114
|
}
|
|
1119
1115
|
registerFunctionalityAdapter(adapter) {
|
|
1120
1116
|
return this.#functionality.register(adapter);
|
|
1121
1117
|
}
|
|
1122
|
-
async
|
|
1123
|
-
return this.#residency.readModuleState(
|
|
1118
|
+
async readWorkspaceModuleState(workspaceId, namespaceOwner) {
|
|
1119
|
+
return this.#residency.readModuleState(workspaceId, namespaceOwner);
|
|
1124
1120
|
}
|
|
1125
|
-
async
|
|
1121
|
+
async replaceWorkspaceCapabilities(replacement, options = {}) {
|
|
1126
1122
|
await this.#residency.replace(replacement, options);
|
|
1127
1123
|
}
|
|
1128
1124
|
get engine() { return this.#engine; }
|
|
@@ -1139,6 +1135,7 @@ export default class Daemon {
|
|
|
1139
1135
|
throw new Error("daemon already started");
|
|
1140
1136
|
this.#started = true;
|
|
1141
1137
|
this.#drains.start();
|
|
1138
|
+
this.#retention.start((cause) => { console.error("retention pass failed:", cause instanceof Error ? cause.message : String(cause)); });
|
|
1142
1139
|
// Mimetypes owns its own discovery scan over @plurnk/plurnk-mimetypes-*
|
|
1143
1140
|
// packages; pre-warm it so first index render doesn't pay the cost.
|
|
1144
1141
|
await this.#mimetypes.ready();
|
|
@@ -1150,9 +1147,9 @@ export default class Daemon {
|
|
|
1150
1147
|
// shell is the default runtime, so its executor must boot usable.
|
|
1151
1148
|
const executors = await ExecutorRegistry.build({ defaultRuntime: "sh", cwd: this.#discoveryCwd });
|
|
1152
1149
|
this.#engine.setExecutors(executors);
|
|
1153
|
-
this.#engine.setFunctionalityDocuments((
|
|
1150
|
+
this.#engine.setFunctionalityDocuments((workspaceId) => this.#functionality.documents(workspaceId));
|
|
1154
1151
|
// {§question-tool} — the native request-user-input runtime, process-wide;
|
|
1155
|
-
//
|
|
1152
|
+
// workspace admission gates its doc visibility and dispatch ({§workspace-capability-policy}).
|
|
1156
1153
|
await this.#engine.registerRuntimes([{
|
|
1157
1154
|
tag: "question",
|
|
1158
1155
|
entry: {
|
|
@@ -1166,10 +1163,10 @@ export default class Daemon {
|
|
|
1166
1163
|
detail: "in-process"
|
|
1167
1164
|
}
|
|
1168
1165
|
}]);
|
|
1169
|
-
// {§effect-policy-tunable} — invalid operator policy fails boot, not the first
|
|
1166
|
+
// {§effect-policy-tunable} — invalid operator policy fails boot, not the first execution.
|
|
1170
1167
|
EffectPolicy.validateConfiguration();
|
|
1171
1168
|
// {§exec} — mint a scheme per runtime tag so exec output entries address by tag
|
|
1172
|
-
// authority (sh:///l/t/s). The "exec" scheme stays for
|
|
1169
|
+
// authority (sh:///l/t/s). The "exec" scheme stays for execution dispatch.
|
|
1173
1170
|
this.#schemes.registerRuntimeSchemes(executors);
|
|
1174
1171
|
// Discover external @plurnk/plurnk-schemes-* siblings + register them
|
|
1175
1172
|
// (agnostic, by plurnk.kind:"scheme"). They light up http://, etc. with
|
|
@@ -1207,7 +1204,6 @@ export default class Daemon {
|
|
|
1207
1204
|
await this.#db.recovery_fail_active_loops.run({});
|
|
1208
1205
|
await this.#db.recovery_settle_open_provider_requests.run({});
|
|
1209
1206
|
await this.#db.recovery_fail_open_model_calls.run({});
|
|
1210
|
-
await this.#db.recovery_fail_open_embedding_calls.run({});
|
|
1211
1207
|
await this.#db.recovery_fail_open_turns.run({});
|
|
1212
1208
|
await this.#db.recovery_fail_ownerless_proposals.run({});
|
|
1213
1209
|
await this.#db.recovery_remove_ownerless_client_interactions.run({});
|
|
@@ -1246,7 +1242,7 @@ export default class Daemon {
|
|
|
1246
1242
|
});
|
|
1247
1243
|
}
|
|
1248
1244
|
for (const row of parked) {
|
|
1249
|
-
await this.#drains.
|
|
1245
|
+
await this.#drains.scheduleWakes(row.workspace_id, row.worker_id, systemPrompt);
|
|
1250
1246
|
}
|
|
1251
1247
|
}
|
|
1252
1248
|
// {§crash-only-stop} — the settle deadline. Default 30s; an operator can
|
|
@@ -1267,6 +1263,7 @@ export default class Daemon {
|
|
|
1267
1263
|
// already between queue claim and activation must observe its own abort,
|
|
1268
1264
|
// not misclassify orderly shutdown as a capability failure.
|
|
1269
1265
|
const derivationAbort = new DOMException("daemon stopping", "AbortError");
|
|
1266
|
+
this.#retention.stop();
|
|
1270
1267
|
this.#engine.cancelAllProposals("daemon_stopping");
|
|
1271
1268
|
this.#engine.cancelDerivations(derivationAbort);
|
|
1272
1269
|
this.#drains.beginStop("daemon_stopping");
|
|
@@ -1328,15 +1325,22 @@ export default class Daemon {
|
|
|
1328
1325
|
// conclusion notifications. Join the supervisor-owned async tails only
|
|
1329
1326
|
// after those producers settle, before the caller may close SQLite.
|
|
1330
1327
|
const wakeResult = await settle("drains idle (wake)", () => this.#drains.idle());
|
|
1328
|
+
// {§db-maintenance-optimize} — the last database step before the caller closes SQLite:
|
|
1329
|
+
// planner statistics refreshed on the writer, bounded by SQLite's own analysis limit.
|
|
1330
|
+
// {§retention-policy} — the operator's retention runs once more before the statistics.
|
|
1331
|
+
const collectResult = await settle("retention", () => this.#retention.run());
|
|
1332
|
+
const optimizeResult = await settle("database optimize", () => this.#db.maintenance_optimize.run({}));
|
|
1331
1333
|
const closeErrors = [
|
|
1332
1334
|
moduleResult,
|
|
1333
1335
|
functionalityResult,
|
|
1334
1336
|
drainResult,
|
|
1335
1337
|
streamingResult,
|
|
1336
1338
|
derivationResult,
|
|
1339
|
+
collectResult,
|
|
1337
1340
|
...(mimetypeResult === null ? [] : [mimetypeResult]),
|
|
1338
1341
|
schemeResult,
|
|
1339
1342
|
wakeResult,
|
|
1343
|
+
optimizeResult,
|
|
1340
1344
|
]
|
|
1341
1345
|
.filter((result) => result.status === "rejected")
|
|
1342
1346
|
.flatMap((result) => result.reason instanceof AggregateError
|
|
@@ -1382,9 +1386,6 @@ export default class Daemon {
|
|
|
1382
1386
|
.filter(([key, value]) => {
|
|
1383
1387
|
if (value === undefined)
|
|
1384
1388
|
return false;
|
|
1385
|
-
if (key === "capabilities") {
|
|
1386
|
-
return !isDeepStrictEqual(CapabilityAdmission.intersect([effective.capabilities]), CapabilityAdmission.intersect([value]));
|
|
1387
|
-
}
|
|
1388
1389
|
return effective[key] !== value;
|
|
1389
1390
|
})
|
|
1390
1391
|
.map(([key, value]) => `${key}: ${JSON.stringify(effective[key])} -> ${JSON.stringify(value)}`);
|
|
@@ -1407,16 +1408,12 @@ export default class Daemon {
|
|
|
1407
1408
|
async #reconcileOrphanedPrompts(workerId, endedLoopId) {
|
|
1408
1409
|
const endedSeq = (await this.#db.engine_loop_sequence.get({ loop_id: endedLoopId }))?.sequence ?? endedLoopId;
|
|
1409
1410
|
const prefix = promptLoopPrefix(endedSeq);
|
|
1410
|
-
const frames = await this.#db.drain_orphaned_prompts_for_loop.all({ loop_id: endedLoopId,
|
|
1411
|
+
const frames = await this.#db.drain_orphaned_prompts_for_loop.all({ loop_id: endedLoopId, worker_id: workerId, pattern: `${prefix}%`, prefix_len: prefix.length });
|
|
1411
1412
|
const first = frames[0];
|
|
1412
1413
|
if (first === undefined)
|
|
1413
1414
|
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
1415
|
const recovery = await this.#db.drain_enqueue_orphan_recovery_loop.get({
|
|
1418
1416
|
worker_id: workerId,
|
|
1419
|
-
sequence: seqRow.next,
|
|
1420
1417
|
prompt: first.body,
|
|
1421
1418
|
prompt_source: first.prompt_source,
|
|
1422
1419
|
policy: first.policy,
|
|
@@ -1432,7 +1429,7 @@ export default class Daemon {
|
|
|
1432
1429
|
if (recovery.status !== 100)
|
|
1433
1430
|
return;
|
|
1434
1431
|
const moved = await this.#db.drain_rehome_orphaned_prompt_frames.all({
|
|
1435
|
-
|
|
1432
|
+
worker_id: workerId,
|
|
1436
1433
|
source_loop_id: endedLoopId,
|
|
1437
1434
|
source_pattern: `${prefix}%`,
|
|
1438
1435
|
source_prefix_len: prefix.length,
|