@plurnk/plurnk-service 1.18.0 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.defaults +76 -13
- package/README.md +5 -3
- package/SPEC.md +925 -697
- package/dist/Paths.js +3 -3
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts +1 -0
- package/dist/content/body-preview.d.ts.map +1 -1
- package/dist/content/body-preview.js +8 -10
- package/dist/content/body-preview.js.map +1 -1
- package/dist/content/edit-receipt.d.ts.map +1 -1
- package/dist/content/edit-receipt.js +30 -29
- package/dist/content/edit-receipt.js.map +1 -1
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +17 -5
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/read-projector.d.ts +2 -2
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +79 -37
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/scope-format.d.ts +9 -0
- package/dist/content/scope-format.d.ts.map +1 -0
- package/dist/content/scope-format.js +28 -0
- package/dist/content/scope-format.js.map +1 -0
- package/dist/core/AdministrativeLoop.d.ts +8 -0
- package/dist/core/AdministrativeLoop.d.ts.map +1 -0
- package/dist/core/AdministrativeLoop.js +16 -0
- package/dist/core/AdministrativeLoop.js.map +1 -0
- package/dist/core/AdmittedTurnExecutor.d.ts +2 -1
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +19 -19
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +1 -2
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js +7 -12
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +3 -4
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +4 -2
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +23 -2
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +2 -2
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +6 -3
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +3 -6
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +8 -8
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +17 -11
- package/dist/core/ClientInteractions.d.ts +11 -1
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +26 -2
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +1 -0
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.js +6 -6
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +12 -4
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +112 -90
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +11 -26
- package/dist/core/DurableStatement.d.ts +4 -1
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +4 -4
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/EditMutations.d.ts.map +1 -1
- package/dist/core/EditMutations.js +5 -2
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/Engine.d.ts +11 -9
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +27 -65
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +2 -22
- package/dist/core/EnvFlags.d.ts.map +1 -1
- package/dist/core/EnvFlags.js +4 -2
- package/dist/core/EnvFlags.js.map +1 -1
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +2 -1
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +7 -12
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/Knob.d.ts +9 -0
- package/dist/core/Knob.d.ts.map +1 -0
- package/dist/core/Knob.js +50 -0
- package/dist/core/Knob.js.map +1 -0
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +6 -35
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +4 -0
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +2 -1
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LogWriter.js +2 -2
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LoopDriver.d.ts +1 -1
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +23 -29
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopLifecycle.d.ts +4 -17
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +20 -22
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +36 -49
- package/dist/core/LoopOutcome.d.ts +10 -0
- package/dist/core/LoopOutcome.d.ts.map +1 -0
- package/dist/core/LoopOutcome.js +28 -0
- package/dist/core/LoopOutcome.js.map +1 -0
- package/dist/core/LoopPolicies.d.ts +7 -0
- package/dist/core/LoopPolicies.d.ts.map +1 -0
- package/dist/core/LoopPolicies.js +37 -0
- package/dist/core/LoopPolicies.js.map +1 -0
- package/dist/core/MessageResources.d.ts +15 -0
- package/dist/core/MessageResources.d.ts.map +1 -0
- package/dist/core/MessageResources.js +46 -0
- package/dist/core/MessageResources.js.map +1 -0
- package/dist/core/MessageResources.sql +36 -0
- package/dist/core/OperatorConfig.d.ts +2 -1
- package/dist/core/OperatorConfig.d.ts.map +1 -1
- package/dist/core/OperatorConfig.js +14 -6
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +20 -35
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +24 -6
- package/dist/core/PatternSelection.d.ts +1 -1
- package/dist/core/PatternSelection.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.d.ts +3 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +85 -22
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProviderInstantiate.d.ts +1 -0
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +12 -7
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReasoningView.d.ts +1 -2
- package/dist/core/ReasoningView.d.ts.map +1 -1
- package/dist/core/ReasoningView.js +9 -20
- package/dist/core/ReasoningView.js.map +1 -1
- package/dist/core/ResourceBindings.d.ts.map +1 -1
- package/dist/core/ResourceBindings.js +5 -4
- package/dist/core/ResourceBindings.js.map +1 -1
- package/dist/core/ResourceMutations.d.ts +4 -4
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +2 -3
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.d.ts +10 -3
- package/dist/core/ResourceSelector.d.ts.map +1 -1
- package/dist/core/ResourceSelector.js +52 -13
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.d.ts.map +1 -1
- package/dist/core/ResourceTransfers.js +4 -2
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/SchemeRegistry.d.ts +2 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +11 -5
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StoredPacket.d.ts +3 -1
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +7 -3
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +9 -3
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/TerminalResult.d.ts +2 -2
- package/dist/core/TerminalResult.d.ts.map +1 -1
- package/dist/core/TerminalResult.js +15 -8
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/ToolInputSchema.d.ts.map +1 -1
- package/dist/core/ToolInputSchema.js +24 -8
- package/dist/core/ToolInputSchema.js.map +1 -1
- package/dist/core/ToolResources.d.ts +1 -0
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +45 -23
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.d.ts +3 -1
- package/dist/core/Turn.d.ts.map +1 -1
- package/dist/core/Turn.js +4 -1
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/Turn.sql +14 -2
- package/dist/core/TurnDispositionHandler.d.ts +13 -21
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +32 -190
- package/dist/core/TurnDispositionHandler.js.map +1 -1
- package/dist/core/TurnMaterialization.d.ts +9 -7
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +63 -41
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +23 -6
- package/dist/core/TurnOps.js +1 -1
- package/dist/core/TurnRunner.d.ts +1 -3
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +148 -189
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnRunner.sql +1 -24
- package/dist/core/TurnSources.sql +42 -11
- package/dist/core/WorkerName.d.ts +1 -1
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +3 -3
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/ambient.sql +45 -19
- package/dist/core/attachments.d.ts +3 -1
- package/dist/core/attachments.d.ts.map +1 -1
- package/dist/core/attachments.js +4 -0
- package/dist/core/attachments.js.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.js +4 -2
- package/dist/core/caps/CoreInteractionCaps.js.map +1 -1
- package/dist/core/caps/DbChannelCaps.js +6 -6
- package/dist/core/caps/DbChannelCaps.js.map +1 -1
- package/dist/core/caps/DbEntryCaps.js +1 -1
- package/dist/core/caps/DbEntryCaps.js.map +1 -1
- package/dist/core/caps/DbMessageCaps.d.ts +10 -0
- package/dist/core/caps/DbMessageCaps.d.ts.map +1 -0
- package/dist/core/caps/DbMessageCaps.js +39 -0
- package/dist/core/caps/DbMessageCaps.js.map +1 -0
- package/dist/core/caps/DbProjectionCaps.d.ts +2 -2
- package/dist/core/caps/DbProjectionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +10 -4
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +3 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +11 -0
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/fork.sql +7 -6
- package/dist/core/git-state.d.ts +3 -2
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +37 -20
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/packet-inject.js +1 -1
- package/dist/core/packet-wire.d.ts +11 -0
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +112 -88
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +4 -5
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +10 -31
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/scheme-types.d.ts +3 -1
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/teaching.d.ts.map +1 -1
- package/dist/core/teaching.js +2 -1
- package/dist/core/teaching.js.map +1 -1
- package/dist/core/types.d.ts +1 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-ops.sql +3 -8
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +35 -30
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +1 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +53 -1
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/DigestRequiem.d.ts.map +1 -1
- package/dist/digest/DigestRequiem.js +13 -15
- package/dist/digest/DigestRequiem.js.map +1 -1
- package/dist/digest/digest-db.d.ts +3 -0
- package/dist/digest/digest-db.d.ts.map +1 -0
- package/dist/digest/digest-db.js +68 -0
- package/dist/digest/digest-db.js.map +1 -0
- package/dist/digest/digest-paths.d.ts +6 -0
- package/dist/digest/digest-paths.d.ts.map +1 -0
- package/dist/digest/digest-paths.js +23 -0
- package/dist/digest/digest-paths.js.map +1 -0
- package/dist/digest/digest-rows.d.ts +15 -0
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +13 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/observe/genai.d.ts +2 -2
- package/dist/observe/genai.d.ts.map +1 -1
- package/dist/observe/genai.js +15 -5
- package/dist/observe/genai.js.map +1 -1
- package/dist/schemes/EffectPolicy.d.ts +0 -2
- package/dist/schemes/EffectPolicy.d.ts.map +1 -1
- package/dist/schemes/EffectPolicy.js +25 -36
- package/dist/schemes/EffectPolicy.js.map +1 -1
- package/dist/schemes/Exec.d.ts +4 -5
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +74 -62
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +6 -5
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +49 -16
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +28 -20
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts +4 -4
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +29 -9
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +14 -1
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/TurnSource.d.ts +3 -2
- package/dist/schemes/TurnSource.d.ts.map +1 -1
- package/dist/schemes/TurnSource.js +80 -35
- package/dist/schemes/TurnSource.js.map +1 -1
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +22 -56
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.js +6 -6
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +19 -17
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +6 -5
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-fts.d.ts.map +1 -1
- package/dist/schemes/_entry-fts.js +6 -3
- package/dist/schemes/_entry-fts.js.map +1 -1
- package/dist/schemes/_entry-fts.sql +25 -6
- package/dist/schemes/_entry-manifest.d.ts +1 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +5 -3
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-ops.js +4 -4
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +2 -2
- package/dist/schemes/_entry-readable.d.ts.map +1 -1
- package/dist/schemes/_entry-readable.js +5 -4
- package/dist/schemes/_entry-readable.js.map +1 -1
- package/dist/schemes/_entry-send.js +2 -2
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/schemes/_search-exclusion.d.ts +1 -0
- package/dist/schemes/_search-exclusion.d.ts.map +1 -1
- package/dist/schemes/_search-exclusion.js +12 -0
- package/dist/schemes/_search-exclusion.js.map +1 -1
- package/dist/schemes/_search-index.js +4 -4
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/exec-abort.d.ts.map +1 -1
- package/dist/schemes/exec-abort.js +4 -3
- package/dist/schemes/exec-abort.js.map +1 -1
- package/dist/schemes/exec-lifetime.d.ts +11 -0
- package/dist/schemes/exec-lifetime.d.ts.map +1 -0
- package/dist/schemes/exec-lifetime.js +29 -0
- package/dist/schemes/exec-lifetime.js.map +1 -0
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +3 -1
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +30 -7
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +107 -48
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +19 -5
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +13 -11
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +87 -98
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts +12 -3
- package/dist/server/EnvFunctionality.d.ts.map +1 -1
- package/dist/server/EnvFunctionality.js +19 -14
- package/dist/server/EnvFunctionality.js.map +1 -1
- package/dist/server/Functionality.d.ts +2 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +97 -62
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +3 -1
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +11 -5
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/HttpListener.d.ts +16 -0
- package/dist/server/HttpListener.d.ts.map +1 -0
- package/dist/server/HttpListener.js +81 -0
- package/dist/server/HttpListener.js.map +1 -0
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +12 -16
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/PlurnkSkill.d.ts.map +1 -1
- package/dist/server/PlurnkSkill.js +1 -0
- package/dist/server/PlurnkSkill.js.map +1 -1
- package/dist/server/Retention.d.ts +11 -0
- package/dist/server/Retention.d.ts.map +1 -1
- package/dist/server/Retention.js +47 -2
- package/dist/server/Retention.js.map +1 -1
- package/dist/server/Retention.sql +32 -1
- package/dist/server/ServiceModules.d.ts.map +1 -1
- package/dist/server/ServiceModules.js +2 -0
- package/dist/server/ServiceModules.js.map +1 -1
- package/dist/server/SkillsFunctionality.d.ts +2 -0
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +22 -15
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
- package/dist/server/WorkspaceCapabilities.js +1 -0
- package/dist/server/WorkspaceCapabilities.js.map +1 -1
- package/dist/server/WorkspaceStorage.d.ts +8 -0
- package/dist/server/WorkspaceStorage.d.ts.map +1 -0
- package/dist/server/WorkspaceStorage.js +26 -0
- package/dist/server/WorkspaceStorage.js.map +1 -0
- package/dist/server/client-input.d.ts +4 -3
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +24 -26
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +2 -2
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +69 -132
- package/dist/server/envelope.d.ts +2 -2
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +7 -9
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +10 -6
- package/dist/server/exec-poll-backoff.js +3 -3
- package/dist/server/exec-poll-backoff.js.map +1 -1
- package/dist/server/lifecycle-recovery.sql +8 -35
- package/dist/server/logEntry.sql +2 -2
- package/dist/server/loopDocs.js +3 -3
- package/dist/server/loopDocs.sql +4 -2
- package/dist/server/model-catalog.d.ts.map +1 -1
- package/dist/server/model-catalog.js +2 -2
- package/dist/server/model-catalog.js.map +1 -1
- package/dist/server/seam-loop.sql +0 -1
- package/dist/server/workspace-storage.sql +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +21 -10
- package/dist/service.js.map +1 -1
- package/docs/copy-move.md +31 -0
- package/docs/env.md +19 -7
- package/docs/skills.md +2 -2
- package/migrations/002_workers.sql +26 -17
- package/migrations/003_loops.sql +82 -28
- package/migrations/005_entries.sql +135 -22
- package/migrations/006_log.sql +77 -25
- package/migrations/007_subscriptions.sql +10 -15
- package/package.json +35 -36
- package/dist/core/PromptFrames.d.ts +0 -12
- package/dist/core/PromptFrames.d.ts.map +0 -1
- package/dist/core/PromptFrames.js +0 -28
- package/dist/core/PromptFrames.js.map +0 -1
- package/dist/schemes/Prompt.d.ts +0 -8
- package/dist/schemes/Prompt.d.ts.map +0 -1
- package/dist/schemes/Prompt.js +0 -25
- package/dist/schemes/Prompt.js.map +0 -1
package/dist/core/Dispatcher.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { PlurnkParser, parsePath } from "@plurnk/plurnk-parser";
|
|
3
3
|
import { TurnDisposition } from "@plurnk/plurnk-contracts";
|
|
4
|
-
import
|
|
4
|
+
import Turn from "./Turn.js";
|
|
5
|
+
import { foldAuthorityIntoPath, renderAddress, renderTarget, schemeNameOf } from "./plurnk-uri.js";
|
|
6
|
+
import WorkerName from "./WorkerName.js";
|
|
5
7
|
import { PathSyntax } from "@plurnk/plurnk-contracts";
|
|
6
8
|
import Namespace from "./namespace.js";
|
|
7
9
|
import CapabilityResolver from "./CapabilityResolver.js";
|
|
10
|
+
import CapabilityPolicies from "./CapabilityPolicies.js";
|
|
8
11
|
import LoopPolicyReader from "./LoopPolicyReader.js";
|
|
9
12
|
import SchemeCtxImpl from "./caps/SchemeCtxImpl.js";
|
|
10
13
|
import Results from "./results.js";
|
|
11
14
|
import { OperationFailureError } from "./results.js";
|
|
12
15
|
import EffectPolicy from "../schemes/EffectPolicy.js";
|
|
13
16
|
import { CoreSchemeAdapterBase } from "./CoreSchemeServices.js";
|
|
14
|
-
import { InvalidOperationResultError } from "@plurnk/plurnk-schemes";
|
|
17
|
+
import { InvalidOperationResultError, MessageAttachments } from "@plurnk/plurnk-schemes";
|
|
15
18
|
import ResourceMutations from "./ResourceMutations.js";
|
|
19
|
+
import ResourceSelector from "./ResourceSelector.js";
|
|
16
20
|
import { primaryTargetOf } from "./statement-primary.js";
|
|
17
21
|
import LogBody from "./LogBody.js";
|
|
18
22
|
import LogVisibility from "./LogVisibility.js";
|
|
@@ -35,11 +39,6 @@ class Dispatcher {
|
|
|
35
39
|
static #failure(code, status, detail, fields = {}, extensions = {}) {
|
|
36
40
|
return Results.failure("engine:dispatcher", code, status, detail, fields, extensions);
|
|
37
41
|
}
|
|
38
|
-
static #statusResult(status, code, detail, fields = {}) {
|
|
39
|
-
return status >= 400
|
|
40
|
-
? _a.#failure(code, status, detail, fields, { retryable: false })
|
|
41
|
-
: { ...fields, status };
|
|
42
|
-
}
|
|
43
42
|
#db;
|
|
44
43
|
#schemes;
|
|
45
44
|
#mimetypes;
|
|
@@ -58,11 +57,12 @@ class Dispatcher {
|
|
|
58
57
|
#wakeWorkerNotify;
|
|
59
58
|
#injectWorker;
|
|
60
59
|
#cancelWorker;
|
|
61
|
-
#
|
|
60
|
+
#operationSettledNotify;
|
|
62
61
|
// Per-turn running-worker READ obligations. {§join-blocking-collect}
|
|
63
62
|
#liveSubscriptions;
|
|
64
63
|
#lifecycle;
|
|
65
64
|
#resourceMutations;
|
|
65
|
+
#resourceSelector;
|
|
66
66
|
#entryAddresses;
|
|
67
67
|
#capabilities;
|
|
68
68
|
#workerControl;
|
|
@@ -70,7 +70,7 @@ class Dispatcher {
|
|
|
70
70
|
#disposition;
|
|
71
71
|
#logWriter;
|
|
72
72
|
#dataRun;
|
|
73
|
-
constructor({ db, lifecycle, schemes, mimetypes, weigh, notices, proposals, interactions, executors, loopSignal, settleDerivations, streamEventNotify, wakeWorkerNotify, injectWorker, cancelWorker,
|
|
73
|
+
constructor({ db, lifecycle, schemes, mimetypes, weigh, notices, proposals, interactions, executors, loopSignal, settleDerivations, streamEventNotify, wakeWorkerNotify, injectWorker, cancelWorker, operationSettledNotify, liveSubscriptions, entryAddresses }) {
|
|
74
74
|
this.#db = db;
|
|
75
75
|
this.#schemes = schemes;
|
|
76
76
|
this.#mimetypes = mimetypes;
|
|
@@ -85,11 +85,20 @@ class Dispatcher {
|
|
|
85
85
|
this.#wakeWorkerNotify = wakeWorkerNotify;
|
|
86
86
|
this.#injectWorker = injectWorker;
|
|
87
87
|
this.#cancelWorker = cancelWorker;
|
|
88
|
-
this.#
|
|
88
|
+
this.#operationSettledNotify = operationSettledNotify;
|
|
89
89
|
this.#liveSubscriptions = liveSubscriptions;
|
|
90
90
|
this.#entryAddresses = entryAddresses;
|
|
91
91
|
this.#capabilities = new CapabilityResolver(db, schemes, executors);
|
|
92
92
|
this.#lifecycle = lifecycle;
|
|
93
|
+
this.#resourceSelector = new ResourceSelector({
|
|
94
|
+
schemes,
|
|
95
|
+
admitRead: (statement, ctx) => this.#checkCapabilities(statement, ctx),
|
|
96
|
+
canonicalFilePath: (pathname, workspaceId) => this.#canonicalFilePath(pathname, workspaceId),
|
|
97
|
+
prepareDataRepresentation: (args) => this.#prepareDataRepresentation({
|
|
98
|
+
...args,
|
|
99
|
+
handler: args.handler,
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
93
102
|
this.#resourceMutations = new ResourceMutations({
|
|
94
103
|
schemes,
|
|
95
104
|
liveSubscriptions,
|
|
@@ -97,11 +106,7 @@ class Dispatcher {
|
|
|
97
106
|
checkWritable: (statement, origin, workspaceId) => this.#checkWritable(statement, origin, workspaceId),
|
|
98
107
|
checkCapabilities: (statement, ctx) => this.#checkCapabilities(statement, ctx),
|
|
99
108
|
editTargetIdentity: (statement, workspaceId, workerId) => this.#editTargetIdentity(statement, workspaceId, workerId),
|
|
100
|
-
|
|
101
|
-
prepareDataRepresentation: (args) => this.#prepareDataRepresentation({
|
|
102
|
-
...args,
|
|
103
|
-
handler: args.handler,
|
|
104
|
-
}),
|
|
109
|
+
selection: this.#resourceSelector,
|
|
105
110
|
resolveDataEntryAddress: (args) => this.#entryAddresses.resolve(args),
|
|
106
111
|
readEntry: (scheme, address, ctx) => this.#readEntry(scheme, address, ctx),
|
|
107
112
|
writeEntry: (scheme, address, entry, ctx) => this.#writeEntry(scheme, address, entry, ctx),
|
|
@@ -110,7 +115,7 @@ class Dispatcher {
|
|
|
110
115
|
});
|
|
111
116
|
this.#workerControl = new WorkerControlHandler({ db: this.#db, failure: _a.#failure });
|
|
112
117
|
this.#kill = new KillHandler({ db: this.#db, schemes: this.#schemes, liveSubscriptions: this.#liveSubscriptions, cancelWorker: this.#cancelWorker, resolveDataEntryAddress: this.#resolveDataEntryAddress.bind(this), boundEntryContext: this.#boundEntryContext.bind(this), handlerContext: this.#handlerContext.bind(this), deleteEntry: this.#deleteEntry.bind(this), failure: _a.#failure });
|
|
113
|
-
this.#disposition = new TurnDispositionHandler({ db: this.#db,
|
|
118
|
+
this.#disposition = new TurnDispositionHandler({ db: this.#db, lifecycle: this.#lifecycle, unobservedFailureCount: this.#unobservedFailureCount.bind(this), pendingSet: this.#pendingSet.bind(this), hasLiveWork: this.hasLiveWork.bind(this) });
|
|
114
119
|
this.#logWriter = new LogWriter({ db: this.#db, weighContent: this.#weighContent, extractTarget: this.#extractTarget.bind(this), canonColumns: this.#canonColumns.bind(this), signalToJson: this.#signalToJson.bind(this), isProposal: _a.#isProposal });
|
|
115
120
|
this.#dataRun = new DataStatementRunner({ schemes: this.#schemes, liveSubscriptions: this.#liveSubscriptions, resolveDataEntryAddress: this.#resolveDataEntryAddress.bind(this), prepareDataRepresentation: this.#prepareDataRepresentation.bind(this), failure: _a.#failure });
|
|
116
121
|
}
|
|
@@ -334,6 +339,7 @@ class Dispatcher {
|
|
|
334
339
|
turnId: context.turnId, sequence: context.sequence, origin: context.origin, curationPlan: null, modelCallId: null,
|
|
335
340
|
});
|
|
336
341
|
context.onDispatch?.(logEntryId);
|
|
342
|
+
await this.#notifySettled(context, logEntryId);
|
|
337
343
|
return result;
|
|
338
344
|
}
|
|
339
345
|
const matchingPathCount = typeof found.matchingPathCount === "number" ? found.matchingPathCount : paths.length;
|
|
@@ -356,14 +362,11 @@ class Dispatcher {
|
|
|
356
362
|
return Results.assert({ ...(results.find(({ status }) => status >= 400) ?? results[results.length - 1]), rowsWritten: results.length });
|
|
357
363
|
}
|
|
358
364
|
async #dispatchOne(context, schemeCtx) {
|
|
359
|
-
const { statement, workspaceId, workerId, loopId, turnId, sequence, origin, onDispatch,
|
|
365
|
+
const { statement, workspaceId, workerId, loopId, turnId, sequence, origin, onDispatch, } = context;
|
|
360
366
|
let result;
|
|
361
367
|
let curationPlan = null;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const ownPrompt = statement.op === "SEND" && origin === "model" && await this.#isOwnPromptAddress(statement.target, workerId, loopId);
|
|
365
|
-
const denial = ownPrompt ? null : (this.#checkWritable(statement, origin, workspaceId)
|
|
366
|
-
?? await this.#checkCapabilities(statement, schemeCtx));
|
|
368
|
+
const denial = this.#checkWritable(statement, origin, workspaceId)
|
|
369
|
+
?? await this.#checkCapabilities(statement, schemeCtx);
|
|
367
370
|
if (denial !== null) {
|
|
368
371
|
result = denial;
|
|
369
372
|
}
|
|
@@ -377,18 +380,23 @@ class Dispatcher {
|
|
|
377
380
|
if (statement.op === "EDIT") {
|
|
378
381
|
result = await this.#resourceMutations.edit(statement, schemeCtx, context.editSequence);
|
|
379
382
|
}
|
|
380
|
-
else if (statement.op === "SEND" &&
|
|
383
|
+
else if (statement.op === "SEND" && statement.target === null) {
|
|
381
384
|
result = await this.#respond(statement, schemeCtx, origin, workerId, loopId);
|
|
385
|
+
if (context.proseAnswer === true && result.status === 200)
|
|
386
|
+
result = await this.#answered(result, workerId, loopId);
|
|
387
|
+
}
|
|
388
|
+
else if (statement.op === "NOTE") {
|
|
389
|
+
await Turn.recordSource(this.#db, turnId, "note", statement.body ?? "", { sequence });
|
|
390
|
+
const coordinate = await this.#db.engine_loop_turn_seqs.get({ loop_id: loopId, turn_id: turnId });
|
|
391
|
+
if (coordinate === undefined)
|
|
392
|
+
throw new Error(`NOTE has no turn coordinate for ${turnId}`);
|
|
393
|
+
const workerName = await WorkerName.forId(this.#db, workerId);
|
|
394
|
+
result = { status: 200, resource: renderAddress({ scheme: "note", authority: workerName, pathname: `/${coordinate.loop_seq}/${coordinate.turn_seq}/${sequence}` }) };
|
|
382
395
|
}
|
|
383
396
|
else if (TurnDisposition.is(statement)) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
loopId,
|
|
388
|
-
turnId,
|
|
389
|
-
sequence,
|
|
390
|
-
origin,
|
|
391
|
-
});
|
|
397
|
+
// {§turn-disposition} — WAIT is the park; whatever it names is its label in the
|
|
398
|
+
// row, never a join: the next wake is a message, a child's end, a stream's close.
|
|
399
|
+
result = await this.#disposition.handle({ workerId, loopId, turnId, origin });
|
|
392
400
|
}
|
|
393
401
|
else if (statement.op === "KILL" && schemeNameOf(statement.target) === "log") {
|
|
394
402
|
const curation = await this.#runLogCuration(statement, schemeCtx, context.logSelectionMaxId);
|
|
@@ -461,7 +469,7 @@ class Dispatcher {
|
|
|
461
469
|
});
|
|
462
470
|
onDispatch?.(logEntryId);
|
|
463
471
|
// Proposal lifecycle (SPEC.md {§engine-rails} + {§methods-proposal-resolve}; {§proposal-202-pauses}). When a
|
|
464
|
-
// side-effecting op returns status 202 (a
|
|
472
|
+
// side-effecting op returns status 202 (a WAIT parks rather
|
|
465
473
|
// than proposing — #isProposal), the entry is written
|
|
466
474
|
// state='proposed'; dispatch then PAUSES on a per-entry waiter until
|
|
467
475
|
// resolution arrives via Engine.resolveProposal (from a client-interface resume,
|
|
@@ -471,17 +479,21 @@ class Dispatcher {
|
|
|
471
479
|
// Effect-gated auto-run (read/pure runtimes, {§exec-readpure-ungated}):
|
|
472
480
|
// An execution stores its one canonical effect fact before admission. Reuse
|
|
473
481
|
// that exact fact here; no human gate or loop/proposal notification.
|
|
482
|
+
// {§exec-host-proposes} — the rule is the effect, not the op: an execution and a
|
|
483
|
+
// runtime SEND MUST declare one, and any other proposal that declares one (an
|
|
484
|
+
// outbound HTTP mutation, {§http-outbound-proposes}) is mapped by the same panel.
|
|
474
485
|
const effect = result.attrs?.effect;
|
|
475
486
|
let autoAccept = false;
|
|
476
|
-
|
|
477
|
-
&& this.#schemes.isRuntimeScheme(schemeNameOf(statement.target) ?? "", workspaceId))
|
|
487
|
+
const mustDeclareEffect = isExecution(statement) || (statement.op === "SEND"
|
|
488
|
+
&& this.#schemes.isRuntimeScheme(schemeNameOf(statement.target) ?? "", workspaceId));
|
|
489
|
+
if (mustDeclareEffect || effect !== undefined) {
|
|
478
490
|
if (!EffectPolicy.isEffect(effect)) {
|
|
479
491
|
throw new InvalidOperationResultError("Execution proposal omitted its canonical effect fact.");
|
|
480
492
|
}
|
|
481
493
|
autoAccept = EffectPolicy.decide(effect) === "auto";
|
|
482
494
|
}
|
|
483
495
|
if (autoAccept) {
|
|
484
|
-
const initialSettlement = await this.#proposals.workerApply(statement, result, { decision: "accept" }, { workspaceId, workerId, loopId, turnId });
|
|
496
|
+
const initialSettlement = await this.#proposals.workerApply(statement, result, { decision: "accept" }, { workspaceId, workerId, loopId, turnId, resources: schemeCtx.resources });
|
|
485
497
|
const effective = await this.#resourceMutations.settleProposal({
|
|
486
498
|
statement,
|
|
487
499
|
result,
|
|
@@ -490,7 +502,7 @@ class Dispatcher {
|
|
|
490
502
|
ids: { workspaceId, workerId, loopId, turnId },
|
|
491
503
|
});
|
|
492
504
|
const post = await this.#proposals.applyResolution(logEntryId, effective);
|
|
493
|
-
await
|
|
505
|
+
await this.#notifySettled(context, logEntryId);
|
|
494
506
|
return post;
|
|
495
507
|
}
|
|
496
508
|
// Register the resolution waiter SYNCHRONOUSLY before any await
|
|
@@ -504,14 +516,14 @@ class Dispatcher {
|
|
|
504
516
|
// not an observer and cannot silently degrade into client ownership.
|
|
505
517
|
let resolutionPromise;
|
|
506
518
|
try {
|
|
507
|
-
resolutionPromise = this.#proposals.awaitResolution(logEntryId);
|
|
519
|
+
resolutionPromise = this.#proposals.awaitResolution(logEntryId, this.#loopSignal(loopId));
|
|
508
520
|
const event = await this.#proposals.pending(logEntryId);
|
|
509
521
|
this.#proposals.settleOwned(event);
|
|
510
522
|
this.#proposals.notifyPending(event);
|
|
511
523
|
}
|
|
512
524
|
catch (cause) {
|
|
513
525
|
await this.#proposals.failPreparation(logEntryId, cause);
|
|
514
|
-
await
|
|
526
|
+
await this.#notifySettled(context, logEntryId);
|
|
515
527
|
throw cause;
|
|
516
528
|
}
|
|
517
529
|
const resolution = await resolutionPromise;
|
|
@@ -519,7 +531,7 @@ class Dispatcher {
|
|
|
519
531
|
// file, spawns the process, etc.). Its operation result is
|
|
520
532
|
// preserved: an apply failure keeps its original status and
|
|
521
533
|
// Problem Details instead of masquerading as a client rejection.
|
|
522
|
-
const initialSettlement = await this.#proposals.workerApply(statement, result, resolution, { workspaceId, workerId, loopId, turnId });
|
|
534
|
+
const initialSettlement = await this.#proposals.workerApply(statement, result, resolution, { workspaceId, workerId, loopId, turnId, resources: schemeCtx.resources });
|
|
523
535
|
const effective = await this.#resourceMutations.settleProposal({
|
|
524
536
|
statement,
|
|
525
537
|
result,
|
|
@@ -528,12 +540,16 @@ class Dispatcher {
|
|
|
528
540
|
ids: { workspaceId, workerId, loopId, turnId },
|
|
529
541
|
});
|
|
530
542
|
const post = await this.#proposals.applyResolution(logEntryId, effective);
|
|
531
|
-
await
|
|
543
|
+
await this.#notifySettled(context, logEntryId);
|
|
532
544
|
return post;
|
|
533
545
|
}
|
|
534
|
-
await
|
|
546
|
+
await this.#notifySettled(context, logEntryId);
|
|
535
547
|
return result;
|
|
536
548
|
}
|
|
549
|
+
async #notifySettled(context, logEntryId) {
|
|
550
|
+
await context.onSettled?.(logEntryId);
|
|
551
|
+
await this.#operationSettledNotify?.(context.workspaceId, logEntryId);
|
|
552
|
+
}
|
|
537
553
|
// {§op-look}: resolve a READ and return its content without writing a
|
|
538
554
|
// log_entries row: the client's out-of-band inspection primitive (LOOK → READ,
|
|
539
555
|
// invisible to the model). READ never mutates and never proposes, so this is
|
|
@@ -618,7 +634,7 @@ class Dispatcher {
|
|
|
618
634
|
if (metadata !== null && manifest.metadataModifier !== true) {
|
|
619
635
|
return {
|
|
620
636
|
address: null,
|
|
621
|
-
result: _a.#failure("scheme-metadata-unsupported", 400, `
|
|
637
|
+
result: _a.#failure("scheme-metadata-unsupported", 400, `Resource acquisition from '${routedScheme}' does not accept the [metadata] modifier.`, {}, { scheme: routedScheme, retryable: false }),
|
|
622
638
|
};
|
|
623
639
|
}
|
|
624
640
|
const resolved = priorResolution ?? await this.#resolveDataEntryAddress({
|
|
@@ -697,6 +713,8 @@ class Dispatcher {
|
|
|
697
713
|
db: this.#db,
|
|
698
714
|
workspaceId, workerId, loopId, turnId,
|
|
699
715
|
writer: origin,
|
|
716
|
+
resources: { capture: (targets) => ResourceBindings.using(this.#schemes, context, (bound) => this.#resourceSelector.capture(targets, bound)) },
|
|
717
|
+
replyToMessage: (statement) => this.#respond(statement, context, origin, workerId, loopId),
|
|
700
718
|
signal: this.#loopSignal(loopId),
|
|
701
719
|
streamEventNotify: this.#streamEventNotify,
|
|
702
720
|
wakeWorkerNotify: this.#wakeWorkerNotify,
|
|
@@ -766,7 +784,7 @@ class Dispatcher {
|
|
|
766
784
|
return _a.#failure("send-target-not-a-recipient", 400, "The addressed scheme is not a SEND recipient.", {}, {
|
|
767
785
|
target: statement.target?.raw ?? String(target),
|
|
768
786
|
stage: "dispatch",
|
|
769
|
-
recovery: "A targetless SEND answers the
|
|
787
|
+
recovery: "A targetless SEND answers the open messages; a directed SEND requires a recipient that implements SEND.",
|
|
770
788
|
retryable: false,
|
|
771
789
|
});
|
|
772
790
|
}
|
|
@@ -795,7 +813,7 @@ class Dispatcher {
|
|
|
795
813
|
// owner; a known policy denial is one factual, non-presumptuous 403.
|
|
796
814
|
async #checkCapabilities(statement, ctx) {
|
|
797
815
|
await LoopPolicyReader.read(this.#db, ctx.loopId);
|
|
798
|
-
const denied = await this.#capabilities.denial(statement, ctx.workspaceId, ctx.writer, async (target) => (await ResourceBindings.resolve(target, ctx))?.manifest);
|
|
816
|
+
const denied = await this.#capabilities.denial(statement, ctx.workspaceId, ctx.writer, async (target) => (await ResourceBindings.resolve(target, ctx))?.manifest, ctx.loopId);
|
|
799
817
|
if (denied === null)
|
|
800
818
|
return null;
|
|
801
819
|
const { descriptor, scope } = denied;
|
|
@@ -808,6 +826,10 @@ class Dispatcher {
|
|
|
808
826
|
return _a.#failure("capability-denied", 403, `Capability '${route}' is denied by ${scope} policy.`, {}, {
|
|
809
827
|
...descriptor,
|
|
810
828
|
policyScope: scope,
|
|
829
|
+
// {§loop-attendance} — the innermost ring subtracts for a reason the model can act
|
|
830
|
+
// on, so it says it. Every other scope is the operator's configuration and speaks
|
|
831
|
+
// for itself.
|
|
832
|
+
...(scope === "loop" ? { recovery: CapabilityPolicies.UNATTENDED_RECOVERY } : {}),
|
|
811
833
|
retryable: false,
|
|
812
834
|
});
|
|
813
835
|
}
|
|
@@ -925,20 +947,22 @@ class Dispatcher {
|
|
|
925
947
|
modelCallId,
|
|
926
948
|
});
|
|
927
949
|
context.onDispatch?.(logEntryId);
|
|
928
|
-
await context
|
|
950
|
+
await this.#notifySettled(context, logEntryId);
|
|
929
951
|
return result;
|
|
930
952
|
}
|
|
931
|
-
// {§
|
|
932
|
-
//
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
953
|
+
// {§loop-answer} a prose answer's row names where the answer lives, ops://<worker>/<loop>, and
|
|
954
|
+
// renders under its own leaf ({§log-coordinate-hierarchy}) rather than as a SEND.
|
|
955
|
+
async #answered(result, workerId, loopId) {
|
|
956
|
+
const loop = await this.#db.engine_loop_sequence.get({ loop_id: loopId });
|
|
957
|
+
if (loop === undefined)
|
|
958
|
+
throw new Error(`prose answer has no loop sequence for loop ${loopId}`);
|
|
959
|
+
const resource = renderAddress({ scheme: "ops", authority: await WorkerName.forId(this.#db, workerId), pathname: `/${loop.sequence}` });
|
|
960
|
+
return { ...result, resource, attrs: { ...(result.attrs ?? {}), answer: "prose" } };
|
|
961
|
+
}
|
|
962
|
+
// {§send-response-receipt} {§send-looks-like-operation}
|
|
939
963
|
async #respond(statement, schemeCtx, origin, workerId, loopId) {
|
|
940
964
|
if (origin === "model") {
|
|
941
|
-
const heading = this.#operationHeading(statement.body?.raw ?? "", schemeCtx);
|
|
965
|
+
const heading = this.#operationHeading(typeof statement.body === "string" ? statement.body : statement.body?.raw ?? "", schemeCtx);
|
|
942
966
|
if (heading !== null) {
|
|
943
967
|
return _a.#failure("send-looks-like-operation", 400, `The response begins with the operation heading \`${heading}\`; nothing ran and nothing was delivered.`, {}, {
|
|
944
968
|
heading,
|
|
@@ -948,7 +972,24 @@ class Dispatcher {
|
|
|
948
972
|
});
|
|
949
973
|
}
|
|
950
974
|
}
|
|
951
|
-
|
|
975
|
+
const captured = await MessageAttachments.capture(statement.metadata, schemeCtx.resources, "message:reply");
|
|
976
|
+
if ("failure" in captured)
|
|
977
|
+
return captured.failure;
|
|
978
|
+
const target = statement.target;
|
|
979
|
+
let answers;
|
|
980
|
+
if (target === null) {
|
|
981
|
+
answers = await this.#openMessages(loopId);
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
const message = await this.#db.message_source_by_address.get({
|
|
985
|
+
workspace_id: schemeCtx.workspaceId, path: target.raw,
|
|
986
|
+
});
|
|
987
|
+
if (message === undefined)
|
|
988
|
+
return _a.#failure("message-not-found", 404, `No accepted message exists at ${target.raw}.`, {}, { retryable: false });
|
|
989
|
+
answers = [message.path];
|
|
990
|
+
}
|
|
991
|
+
return { status: 200, answers,
|
|
992
|
+
...(captured.attachments.length === 0 ? {} : { attachments: MessageAttachments.receipts(captured.attachments) }) };
|
|
952
993
|
}
|
|
953
994
|
// The first non-blank line, when it parses alone as one clean heading naming an operation
|
|
954
995
|
// this worker could perform: a Plurnk operation, or a registered executor or MCP service.
|
|
@@ -972,38 +1013,21 @@ class Dispatcher {
|
|
|
972
1013
|
return null;
|
|
973
1014
|
return line;
|
|
974
1015
|
}
|
|
975
|
-
//
|
|
976
|
-
async #
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
throw new Error(`worker ${workerId} does not exist`);
|
|
980
|
-
const loopSeq = (await this.#db.engine_loop_sequence.get({ loop_id: loopId }))?.sequence ?? loopId;
|
|
981
|
-
const prefix = promptLoopPrefix(loopSeq);
|
|
982
|
-
const rows = await this.#db.drain_get_all_prompt_bodies_for_loop.all({
|
|
983
|
-
worker_id: workerId,
|
|
984
|
-
pattern: `${prefix}%`,
|
|
985
|
-
prefix_len: prefix.length,
|
|
986
|
-
});
|
|
987
|
-
return rows.map((row) => `prompt://${worker.name}${row.pathname}`);
|
|
1016
|
+
// {§send-response-receipt}: published unanswered source addresses, oldest first.
|
|
1017
|
+
async #openMessages(loopId) {
|
|
1018
|
+
const rows = await this.#db.engine_open_messages.all({ loop_id: loopId });
|
|
1019
|
+
return rows.map((row) => row.path);
|
|
988
1020
|
}
|
|
989
|
-
async
|
|
990
|
-
|
|
991
|
-
return false;
|
|
992
|
-
const worker = await this.#db.worker_get.get({ id: workerId });
|
|
993
|
-
if (worker === undefined || target.hostname !== worker.name)
|
|
994
|
-
return false;
|
|
995
|
-
const loopSeq = (await this.#db.engine_loop_sequence.get({ loop_id: loopId }))?.sequence ?? loopId;
|
|
996
|
-
return target.pathname.startsWith(promptLoopPrefix(loopSeq));
|
|
1021
|
+
async settleProgram(ctx, wait) {
|
|
1022
|
+
return this.#disposition.settle(ctx, wait);
|
|
997
1023
|
}
|
|
998
|
-
// {§send-premature-terminate}
|
|
999
|
-
|
|
1000
|
-
// requires a new packet, independently of its result or log visibility.
|
|
1001
|
-
async #pendingSet(workerId, turnId) {
|
|
1024
|
+
// {§send-premature-terminate}: judge observation boundaries after the whole program settles.
|
|
1025
|
+
async #pendingSet(workerId, turnId, loopId) {
|
|
1002
1026
|
const pending = [];
|
|
1003
|
-
// {§worker-obligations} —
|
|
1004
|
-
const held = await this.#db.
|
|
1027
|
+
// {§worker-obligations} — all held work shares one durable projection.
|
|
1028
|
+
const held = await this.#db.loop_live_obligations.get({ loop_id: loopId });
|
|
1005
1029
|
if (held === undefined)
|
|
1006
|
-
throw new Error(`
|
|
1030
|
+
throw new Error(`loop ${loopId} does not exist`);
|
|
1007
1031
|
if (held.streams === 1)
|
|
1008
1032
|
pending.push("streams");
|
|
1009
1033
|
if (held.workers === 1)
|
|
@@ -1016,7 +1040,7 @@ class Dispatcher {
|
|
|
1016
1040
|
receipts.push("stream completion");
|
|
1017
1041
|
if (receipts.length > 0)
|
|
1018
1042
|
pending.push("receipts");
|
|
1019
|
-
//
|
|
1043
|
+
// A failed stream result is still owed to the model before ordinary completion.
|
|
1020
1044
|
if (boundaries.streamTerminations.some(({ closeStatus }) => closeStatus >= 400))
|
|
1021
1045
|
pending.push("failed-stream-results");
|
|
1022
1046
|
if (boundaries.childTerminations)
|
|
@@ -1046,11 +1070,9 @@ class Dispatcher {
|
|
|
1046
1070
|
const failedRows = await this.#db.engine_turn_failures.all({ turn_id: turnId });
|
|
1047
1071
|
return failedRows.length;
|
|
1048
1072
|
}
|
|
1049
|
-
//
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
// {§worker-obligations} — one durable row answers both legs.
|
|
1053
|
-
const held = await this.#db.worker_live_obligations.get({ worker_id: workerId });
|
|
1073
|
+
// {§wait-obligation-matrix}: retrievals land next turn; only held work permits parking.
|
|
1074
|
+
async hasLiveWork(loopId) {
|
|
1075
|
+
const held = await this.#db.loop_live_obligations.get({ loop_id: loopId });
|
|
1054
1076
|
return held !== undefined && (held.streams === 1 || held.workers === 1);
|
|
1055
1077
|
}
|
|
1056
1078
|
async #runLogCuration(statement, ctx, admittedMaxId) {
|
|
@@ -1103,7 +1125,7 @@ class Dispatcher {
|
|
|
1103
1125
|
const routedScheme = schemeNameOf(path);
|
|
1104
1126
|
const manifest = routedScheme === null
|
|
1105
1127
|
? undefined
|
|
1106
|
-
: this.#schemes.
|
|
1128
|
+
: this.#schemes.manifestAt(routedScheme, path, workspaceId);
|
|
1107
1129
|
const foldNs = scheme !== null
|
|
1108
1130
|
&& manifest !== undefined
|
|
1109
1131
|
&& (manifest.authority ?? "namespace") === "namespace";
|