@plurnk/plurnk-service 1.16.4 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.defaults +122 -246
- package/INSTALL.md +84 -138
- package/README.md +9 -5
- package/SPEC.md +1710 -1015
- package/dist/Paths.d.ts +2 -0
- package/dist/Paths.d.ts.map +1 -1
- package/dist/Paths.js +2 -0
- package/dist/Paths.js.map +1 -1
- package/dist/build-info.d.ts.map +1 -1
- package/dist/build-info.js +7 -1
- package/dist/build-info.js.map +1 -1
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts +8 -0
- package/dist/content/body-preview.d.ts.map +1 -0
- package/dist/content/body-preview.js +39 -0
- package/dist/content/body-preview.js.map +1 -0
- package/dist/content/byte-view.d.ts +1 -4
- package/dist/content/byte-view.d.ts.map +1 -1
- package/dist/content/byte-view.js.map +1 -1
- package/dist/content/edit-collision.d.ts.map +1 -1
- package/dist/content/edit-collision.js +3 -4
- package/dist/content/edit-collision.js.map +1 -1
- package/dist/content/line-anchors.d.ts +2 -2
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +4 -3
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/line-selection.d.ts +9 -0
- package/dist/content/line-selection.d.ts.map +1 -0
- package/dist/content/line-selection.js +29 -0
- package/dist/content/line-selection.js.map +1 -0
- package/dist/content/matcher.d.ts +0 -1
- package/dist/content/matcher.d.ts.map +1 -1
- package/dist/content/matcher.js +2 -3
- package/dist/content/matcher.js.map +1 -1
- package/dist/content/pattern-edits.d.ts +39 -0
- package/dist/content/pattern-edits.d.ts.map +1 -0
- package/dist/content/pattern-edits.js +121 -0
- package/dist/content/pattern-edits.js.map +1 -0
- package/dist/content/read-projector.d.ts +18 -9
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +132 -35
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/read-resolve.d.ts +3 -1
- package/dist/content/read-resolve.d.ts.map +1 -1
- package/dist/content/read-resolve.js +39 -7
- package/dist/content/read-resolve.js.map +1 -1
- package/dist/core/AdmittedTurnExecutor.d.ts +3 -5
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +91 -83
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +6 -1
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js +20 -5
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts +2 -3
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +23 -32
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +3 -8
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +2 -28
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +10 -10
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +87 -65
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +14 -11
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +11 -12
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +99 -9
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +7 -0
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts +13 -10
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +13 -5
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.d.ts +2 -2
- package/dist/core/DataStatementRunner.d.ts.map +1 -1
- package/dist/core/DataStatementRunner.js +36 -39
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +19 -26
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +369 -219
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +66 -0
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +2 -1
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/EditMutations.d.ts +14 -18
- package/dist/core/EditMutations.d.ts.map +1 -1
- package/dist/core/EditMutations.js +211 -280
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/EditMutations.sql +15 -0
- package/dist/core/EditSequence.d.ts +13 -0
- package/dist/core/EditSequence.d.ts.map +1 -0
- package/dist/core/EditSequence.js +73 -0
- package/dist/core/EditSequence.js.map +1 -0
- package/dist/core/Engine.d.ts +17 -23
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +73 -163
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +0 -724
- package/dist/core/EntryAddressBinding.d.ts +7 -17
- package/dist/core/EntryAddressBinding.d.ts.map +1 -1
- package/dist/core/EntryAddressBinding.js +12 -72
- package/dist/core/EntryAddressBinding.js.map +1 -1
- package/dist/core/ExecutionOutputs.d.ts +9 -0
- package/dist/core/ExecutionOutputs.d.ts.map +1 -0
- package/dist/core/ExecutionOutputs.js +36 -0
- package/dist/core/ExecutionOutputs.js.map +1 -0
- package/dist/core/ExecutionOutputs.sql +13 -0
- package/dist/core/ExecutorRegistry.d.ts +7 -5
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +36 -32
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/HostPaths.d.ts +1 -0
- package/dist/core/HostPaths.d.ts.map +1 -1
- package/dist/core/HostPaths.js +4 -0
- package/dist/core/HostPaths.js.map +1 -1
- package/dist/core/InferenceCall.d.ts.map +1 -1
- package/dist/core/InferenceCall.js +1 -2
- package/dist/core/InferenceCall.js.map +1 -1
- package/dist/core/InferenceCall.sql +29 -0
- package/dist/core/KillHandler.d.ts +1 -0
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +24 -21
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/LogBody.d.ts +8 -1
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +42 -11
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts +1 -0
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +18 -10
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LogVisibility.d.ts +1 -0
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +3 -0
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LogWriter.d.ts +2 -3
- package/dist/core/LogWriter.d.ts.map +1 -1
- package/dist/core/LogWriter.js +25 -32
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LogWriter.sql +23 -0
- package/dist/core/LoopDriver.d.ts +11 -8
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +163 -189
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopDriver.sql +11 -0
- package/dist/core/LoopLifecycle.d.ts +32 -2
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +88 -4
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +145 -28
- package/dist/core/LoopPolicyReader.sql +6 -0
- package/dist/core/MembershipMaterialization.d.ts.map +1 -1
- package/dist/core/MembershipMaterialization.js +6 -28
- package/dist/core/MembershipMaterialization.js.map +1 -1
- package/dist/core/ModelCall.sql +70 -0
- package/dist/core/MutationEffects.d.ts +5 -3
- package/dist/core/MutationEffects.d.ts.map +1 -1
- package/dist/core/MutationEffects.js +10 -28
- package/dist/core/MutationEffects.js.map +1 -1
- package/dist/core/NativeContent.d.ts +6 -0
- package/dist/core/NativeContent.d.ts.map +1 -0
- package/dist/core/NativeContent.js +16 -0
- package/dist/core/NativeContent.js.map +1 -0
- package/dist/core/NativeContent.sql +6 -0
- package/dist/core/NoticeChannel.js +1 -1
- package/dist/core/NoticeChannel.js.map +1 -1
- package/dist/core/OperatorConfig.js +5 -5
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts +8 -5
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +117 -81
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +146 -0
- package/dist/core/PatternSelection.d.ts +28 -0
- package/dist/core/PatternSelection.d.ts.map +1 -0
- package/dist/core/PatternSelection.js +42 -0
- package/dist/core/PatternSelection.js.map +1 -0
- package/dist/core/ProblemLog.d.ts.map +1 -1
- package/dist/core/ProblemLog.js +0 -1
- package/dist/core/ProblemLog.js.map +1 -1
- package/dist/core/PromptFrames.d.ts +12 -0
- package/dist/core/PromptFrames.d.ts.map +1 -0
- package/dist/core/PromptFrames.js +28 -0
- package/dist/core/PromptFrames.js.map +1 -0
- package/dist/core/ProposalLifecycle.d.ts +0 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +20 -19
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProposalLifecycle.sql +33 -0
- package/dist/core/ProviderInstantiate.d.ts +1 -1
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +7 -14
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReasoningView.d.ts +9 -0
- package/dist/core/ReasoningView.d.ts.map +1 -0
- package/dist/core/ReasoningView.js +47 -0
- package/dist/core/ReasoningView.js.map +1 -0
- package/dist/core/ResourceBindings.d.ts +16 -0
- package/dist/core/ResourceBindings.d.ts.map +1 -0
- package/dist/core/ResourceBindings.js +45 -0
- package/dist/core/ResourceBindings.js.map +1 -0
- package/dist/core/ResourceMutations.d.ts +5 -8
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +6 -7
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.d.ts +2 -2
- package/dist/core/ResourceSelector.d.ts.map +1 -1
- package/dist/core/ResourceSelector.js +122 -62
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.d.ts +4 -2
- package/dist/core/ResourceTransfers.d.ts.map +1 -1
- package/dist/core/ResourceTransfers.js +95 -26
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/RuntimeWorker.d.ts +5 -0
- package/dist/core/RuntimeWorker.d.ts.map +1 -0
- package/dist/core/RuntimeWorker.js +10 -0
- package/dist/core/RuntimeWorker.js.map +1 -0
- package/dist/core/RuntimeWorker.sql +5 -0
- package/dist/core/SchemeRegistry.d.ts +12 -16
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +58 -84
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StoredPacket.d.ts +6 -1
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +30 -10
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts +9 -6
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +60 -113
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/StrikeRail.sql +12 -0
- package/dist/core/TerminalResult.d.ts +1 -1
- package/dist/core/TerminalResult.d.ts.map +1 -1
- package/dist/core/TerminalResult.js +2 -2
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/TokenCalibration.d.ts +1 -6
- package/dist/core/TokenCalibration.d.ts.map +1 -1
- package/dist/core/TokenCalibration.js +13 -9
- package/dist/core/TokenCalibration.js.map +1 -1
- package/dist/core/TokenCalibration.sql +15 -0
- package/dist/core/ToolInputSchema.d.ts +6 -0
- package/dist/core/ToolInputSchema.d.ts.map +1 -0
- package/dist/core/ToolInputSchema.js +43 -0
- package/dist/core/ToolInputSchema.js.map +1 -0
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +76 -52
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.d.ts +5 -2
- package/dist/core/Turn.d.ts.map +1 -1
- package/dist/core/Turn.js +13 -11
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/Turn.sql +25 -39
- package/dist/core/{SendBroadcastHandler.d.ts → TurnDispositionHandler.d.ts} +25 -17
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -0
- package/dist/core/TurnDispositionHandler.js +198 -0
- package/dist/core/TurnDispositionHandler.js.map +1 -0
- package/dist/core/TurnMaterialization.d.ts +2 -3
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +40 -15
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +44 -0
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +8 -64
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +9 -12
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +232 -408
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnRunner.sql +74 -0
- package/dist/core/TurnSources.sql +39 -0
- package/dist/core/WorkerControlAddress.d.ts +1 -0
- package/dist/core/WorkerControlAddress.d.ts.map +1 -1
- package/dist/core/WorkerControlAddress.js +5 -0
- package/dist/core/WorkerControlAddress.js.map +1 -1
- package/dist/core/WorkerControlHandler.d.ts +1 -3
- package/dist/core/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +41 -48
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +8 -6
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +33 -24
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkerName.sql +7 -10
- package/dist/core/WorkspaceGate.d.ts +1 -1
- package/dist/core/WorkspaceGate.d.ts.map +1 -1
- package/dist/core/WorkspaceGate.js +29 -6
- package/dist/core/WorkspaceGate.js.map +1 -1
- package/dist/core/ambient.sql +236 -0
- package/dist/core/attachments.d.ts +2 -1
- package/dist/core/attachments.d.ts.map +1 -1
- package/dist/core/attachments.js +5 -4
- package/dist/core/attachments.js.map +1 -1
- package/dist/core/caps/CapsResolve.d.ts +2 -3
- package/dist/core/caps/CapsResolve.d.ts.map +1 -1
- package/dist/core/caps/CapsResolve.js +5 -5
- package/dist/core/caps/CapsResolve.js.map +1 -1
- package/dist/core/caps/DbChannelCaps.d.ts +1 -1
- package/dist/core/caps/DbChannelCaps.d.ts.map +1 -1
- package/dist/core/caps/DbChannelCaps.js +4 -6
- package/dist/core/caps/DbChannelCaps.js.map +1 -1
- package/dist/core/caps/DbEntryCaps.d.ts +2 -1
- package/dist/core/caps/DbEntryCaps.d.ts.map +1 -1
- package/dist/core/caps/DbEntryCaps.js +11 -17
- package/dist/core/caps/DbEntryCaps.js.map +1 -1
- package/dist/core/caps/DbNotifyCaps.d.ts +1 -1
- package/dist/core/caps/DbNotifyCaps.d.ts.map +1 -1
- package/dist/core/caps/DbNotifyCaps.js +3 -5
- package/dist/core/caps/DbNotifyCaps.js.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +1 -1
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/caps/DbSubscriptionCaps.d.ts +1 -1
- package/dist/core/caps/DbSubscriptionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbSubscriptionCaps.js +5 -7
- package/dist/core/caps/DbSubscriptionCaps.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +0 -2
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +4 -20
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/env-defaults.d.ts.map +1 -1
- package/dist/core/env-defaults.js +4 -2
- package/dist/core/env-defaults.js.map +1 -1
- package/dist/core/file-materialization.d.ts +4 -1
- package/dist/core/file-materialization.d.ts.map +1 -1
- package/dist/core/file-materialization.js +14 -0
- package/dist/core/file-materialization.js.map +1 -1
- package/dist/core/fork.d.ts +1 -6
- package/dist/core/fork.d.ts.map +1 -1
- package/dist/core/fork.js +9 -153
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +162 -185
- package/dist/core/git-env.d.ts +1 -0
- package/dist/core/git-env.d.ts.map +1 -1
- package/dist/core/git-env.js +39 -2
- package/dist/core/git-env.js.map +1 -1
- package/dist/core/git-membership.d.ts.map +1 -1
- package/dist/core/git-membership.js +64 -48
- package/dist/core/git-membership.js.map +1 -1
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +25 -19
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/glob_match.d.ts +4 -0
- package/dist/core/glob_match.d.ts.map +1 -0
- package/dist/core/glob_match.js +7 -0
- package/dist/core/glob_match.js.map +1 -0
- package/dist/core/maintenance.sql +6 -0
- package/dist/core/mutation-types.d.ts +7 -28
- package/dist/core/mutation-types.d.ts.map +1 -1
- package/dist/core/packet-inject.d.ts.map +1 -1
- package/dist/core/packet-inject.js +2 -3
- package/dist/core/packet-inject.js.map +1 -1
- package/dist/core/packet-wire.d.ts +8 -6
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +131 -163
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +1 -1
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +5 -12
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/scheme-types.d.ts +3 -3
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.d.ts.map +1 -0
- package/dist/core/sha256.js +6 -0
- package/dist/core/sha256.js.map +1 -0
- package/dist/core/teaching.js +1 -1
- package/dist/core/teaching.js.map +1 -1
- package/dist/core/turn-scheduler.d.ts.map +1 -1
- package/dist/core/turn-scheduler.js +5 -18
- package/dist/core/turn-scheduler.js.map +1 -1
- package/dist/core/turn-signals.d.ts +0 -6
- package/dist/core/turn-signals.d.ts.map +1 -1
- package/dist/core/turn-signals.js +1 -7
- package/dist/core/turn-signals.js.map +1 -1
- package/dist/core/worker-ops.sql +15 -22
- package/dist/core/workspace-settings.d.ts.map +1 -1
- package/dist/core/workspace-settings.js +18 -2
- package/dist/core/workspace-settings.js.map +1 -1
- package/dist/core/workspace-settings.sql +6 -0
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +27 -90
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +14 -54
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/digest-rows.d.ts +10 -32
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +43 -18
- package/dist/schemes/Exec.d.ts +6 -12
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +256 -188
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +8 -6
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +33 -61
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/ExecutionInput.d.ts +12 -0
- package/dist/schemes/ExecutionInput.d.ts.map +1 -0
- package/dist/schemes/ExecutionInput.js +94 -0
- package/dist/schemes/ExecutionInput.js.map +1 -0
- package/dist/schemes/File.d.ts +5 -2
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +62 -92
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +84 -79
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Log.sql +183 -15
- package/dist/schemes/Prompt.d.ts.map +1 -1
- package/dist/schemes/Prompt.js +3 -12
- package/dist/schemes/Prompt.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts +5 -0
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +6 -14
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/Skill.d.ts +12 -7
- package/dist/schemes/Skill.d.ts.map +1 -1
- package/dist/schemes/Skill.js +149 -21
- package/dist/schemes/Skill.js.map +1 -1
- package/dist/schemes/TurnSource.d.ts +12 -0
- package/dist/schemes/TurnSource.d.ts.map +1 -0
- package/dist/schemes/TurnSource.js +116 -0
- package/dist/schemes/TurnSource.js.map +1 -0
- package/dist/schemes/Worker.d.ts +3 -3
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +61 -208
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.d.ts +12 -15
- package/dist/schemes/_entry-crud.d.ts.map +1 -1
- package/dist/schemes/_entry-crud.js +63 -63
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +142 -46
- package/dist/schemes/_entry-find.d.ts +1 -3
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +111 -112
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-find.sql +22 -14
- package/dist/schemes/_entry-fts.d.ts +14 -0
- package/dist/schemes/_entry-fts.d.ts.map +1 -0
- package/dist/schemes/_entry-fts.js +82 -0
- package/dist/schemes/_entry-fts.js.map +1 -0
- package/dist/schemes/_entry-fts.sql +31 -0
- package/dist/schemes/_entry-graph.d.ts.map +1 -1
- package/dist/schemes/_entry-graph.js +6 -14
- package/dist/schemes/_entry-graph.js.map +1 -1
- package/dist/schemes/_entry-graph.sql +29 -44
- package/dist/schemes/_entry-manifest.d.ts +2 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +15 -12
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-manifest.sql +26 -0
- package/dist/schemes/_entry-ops.d.ts +3 -5
- package/dist/schemes/_entry-ops.d.ts.map +1 -1
- package/dist/schemes/_entry-ops.js +30 -43
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +5 -6
- package/dist/schemes/_entry-readable.d.ts +8 -0
- package/dist/schemes/_entry-readable.d.ts.map +1 -0
- package/dist/schemes/_entry-readable.js +38 -0
- package/dist/schemes/_entry-readable.js.map +1 -0
- package/dist/schemes/_entry-send.d.ts +1 -1
- package/dist/schemes/_entry-send.d.ts.map +1 -1
- package/dist/schemes/_entry-send.js +3 -3
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/schemes/_search-index.d.ts +1 -3
- package/dist/schemes/_search-index.d.ts.map +1 -1
- package/dist/schemes/_search-index.js +79 -110
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/_search-index.sql +30 -0
- package/dist/schemes/exec-runtime.d.ts +1 -1
- package/dist/schemes/exec-runtime.d.ts.map +1 -1
- package/dist/schemes/exec-runtime.js.map +1 -1
- package/dist/server/ClientReads.d.ts +2 -2
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +5 -8
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +14 -21
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +135 -156
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +23 -21
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +8 -21
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +278 -306
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/Functionality.d.ts +11 -12
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +129 -101
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +3 -5
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +20 -58
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/MembersFunctionality.d.ts +5 -4
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +24 -37
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/PlurnkSkill.d.ts +11 -0
- package/dist/server/PlurnkSkill.d.ts.map +1 -0
- package/dist/server/PlurnkSkill.js +41 -0
- package/dist/server/PlurnkSkill.js.map +1 -0
- package/dist/server/Retention.d.ts +22 -0
- package/dist/server/Retention.d.ts.map +1 -0
- package/dist/server/Retention.js +54 -0
- package/dist/server/Retention.js.map +1 -0
- package/dist/server/Retention.sql +36 -0
- package/dist/server/ServiceModules.d.ts +5 -0
- package/dist/server/ServiceModules.d.ts.map +1 -0
- package/dist/server/ServiceModules.js +10 -0
- package/dist/server/ServiceModules.js.map +1 -0
- package/dist/server/SkillsFunctionality.d.ts +14 -19
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +97 -104
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/WorkerModelResolver.d.ts +4 -0
- package/dist/server/WorkerModelResolver.d.ts.map +1 -1
- package/dist/server/WorkerModelResolver.js +72 -39
- package/dist/server/WorkerModelResolver.js.map +1 -1
- package/dist/server/WorkspaceCapabilities.d.ts +21 -0
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -0
- package/dist/server/{WorkerCapabilities.js → WorkspaceCapabilities.js} +40 -40
- package/dist/server/WorkspaceCapabilities.js.map +1 -0
- package/dist/server/WorkspaceResidency.d.ts +36 -0
- package/dist/server/WorkspaceResidency.d.ts.map +1 -0
- package/dist/server/WorkspaceResidency.js +199 -0
- package/dist/server/WorkspaceResidency.js.map +1 -0
- package/dist/server/client-input.d.ts +1 -4
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +4 -45
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.d.ts.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +4 -22
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +65 -42
- package/dist/server/envelope.d.ts +8 -0
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +9 -7
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +49 -13
- package/dist/server/lifecycle-recovery.sql +14 -17
- package/dist/server/logEntry.d.ts +1 -1
- package/dist/server/logEntry.d.ts.map +1 -1
- package/dist/server/logEntry.js +4 -1
- package/dist/server/logEntry.js.map +1 -1
- package/dist/server/logEntry.sql +25 -1
- package/dist/server/loopDocs.d.ts +2 -2
- package/dist/server/loopDocs.d.ts.map +1 -1
- package/dist/server/loopDocs.js +38 -31
- package/dist/server/loopDocs.js.map +1 -1
- package/dist/server/loopDocs.sql +1 -3
- package/dist/server/model-catalog.d.ts.map +1 -1
- package/dist/server/model-catalog.js +2 -1
- package/dist/server/model-catalog.js.map +1 -1
- package/dist/server/model-route.d.ts +1 -1
- package/dist/server/model-route.d.ts.map +1 -1
- package/dist/server/model-route.js +4 -2
- package/dist/server/model-route.js.map +1 -1
- package/dist/server/seam-entry-read.sql +3 -4
- package/dist/server/seam-loop.sql +2 -9
- package/dist/server/workspace-capabilities.sql +19 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +5 -17
- package/dist/service.js.map +1 -1
- package/docs/members.md +83 -0
- package/docs/skills.md +50 -0
- package/migrations/001_workspaces.sql +53 -0
- package/migrations/002_workers.sql +183 -0
- package/migrations/003_loops.sql +326 -0
- package/migrations/004_inference.sql +360 -0
- package/migrations/005_entries.sql +207 -0
- package/migrations/006_log.sql +578 -0
- package/migrations/007_subscriptions.sql +175 -0
- package/migrations/008_interactions.sql +29 -0
- package/package.json +33 -40
- package/digest-sql/channel-dispositions/dispositions.sql +0 -15
- package/digest-sql/channel-state/state.sql +0 -6
- package/digest-sql/curation/curation.sql +0 -6
- package/digest-sql/derivations/derivations.sql +0 -4
- package/digest-sql/embeddings/embeddings.sql +0 -4
- package/digest-sql/entry-dispositions/dispositions.sql +0 -15
- package/digest-sql/entry-state/state.sql +0 -6
- package/digest-sql/token-counts/token-counts.sql +0 -2
- package/dist/core/EmbeddingCall.d.ts +0 -23
- package/dist/core/EmbeddingCall.d.ts.map +0 -1
- package/dist/core/EmbeddingCall.js +0 -149
- package/dist/core/EmbeddingCall.js.map +0 -1
- package/dist/core/OverflowTurn.d.ts +0 -11
- package/dist/core/OverflowTurn.d.ts.map +0 -1
- package/dist/core/OverflowTurn.js +0 -80
- package/dist/core/OverflowTurn.js.map +0 -1
- package/dist/core/Owner.d.ts +0 -8
- package/dist/core/Owner.d.ts.map +0 -1
- package/dist/core/Owner.js +0 -46
- package/dist/core/Owner.js.map +0 -1
- package/dist/core/SendBroadcastHandler.d.ts.map +0 -1
- package/dist/core/SendBroadcastHandler.js +0 -159
- package/dist/core/SendBroadcastHandler.js.map +0 -1
- package/dist/core/VectorPump.d.ts +0 -28
- package/dist/core/VectorPump.d.ts.map +0 -1
- package/dist/core/VectorPump.js +0 -130
- package/dist/core/VectorPump.js.map +0 -1
- package/dist/core/owner.sql +0 -11
- package/dist/core/worker-settings.d.ts +0 -10
- package/dist/core/worker-settings.d.ts.map +0 -1
- package/dist/core/worker-settings.js +0 -53
- package/dist/core/worker-settings.js.map +0 -1
- package/dist/schemes/_entry-chunk.d.ts +0 -14
- package/dist/schemes/_entry-chunk.d.ts.map +0 -1
- package/dist/schemes/_entry-chunk.js +0 -165
- package/dist/schemes/_entry-chunk.js.map +0 -1
- package/dist/schemes/_entry-semantic.d.ts +0 -63
- package/dist/schemes/_entry-semantic.d.ts.map +0 -1
- package/dist/schemes/_entry-semantic.js +0 -299
- package/dist/schemes/_entry-semantic.js.map +0 -1
- package/dist/schemes/_entry-semantic.sql +0 -99
- package/dist/schemes/cosine.d.ts +0 -4
- package/dist/schemes/cosine.d.ts.map +0 -1
- package/dist/schemes/cosine.js +0 -9
- package/dist/schemes/cosine.js.map +0 -1
- package/dist/server/WorkerCapabilities.d.ts +0 -21
- package/dist/server/WorkerCapabilities.d.ts.map +0 -1
- package/dist/server/WorkerCapabilities.js.map +0 -1
- package/dist/server/WorkerResidency.d.ts +0 -40
- package/dist/server/WorkerResidency.d.ts.map +0 -1
- package/dist/server/WorkerResidency.js +0 -283
- package/dist/server/WorkerResidency.js.map +0 -1
- package/dist/server/seam-log-read.sql +0 -21
- package/dist/server/worker-capabilities.sql +0 -28
- package/migrations/001_schema.sql +0 -2207
package/dist/schemes/Exec.js
CHANGED
|
@@ -2,27 +2,28 @@ import { parsePath, PathSyntax } from "@plurnk/plurnk-contracts";
|
|
|
2
2
|
import { WebFetcher, WebMaterializationError, } from "@plurnk/plurnk-schemes-http";
|
|
3
3
|
import EffectPolicy from "./EffectPolicy.js";
|
|
4
4
|
import EntryCrud from "./_entry-crud.js";
|
|
5
|
-
import Owner from "../core/Owner.js";
|
|
6
5
|
import EntryFind from "./_entry-find.js";
|
|
7
6
|
import ChannelWrite from "../core/ChannelWrite.js";
|
|
8
7
|
import ExecEnv from "./exec-env.js";
|
|
9
8
|
import ExecAbort from "./exec-abort.js";
|
|
10
|
-
import { renderAddress } from "../core/plurnk-uri.js";
|
|
9
|
+
import { entryCoordinateOf, generatedPathname, renderAddress } from "../core/plurnk-uri.js";
|
|
11
10
|
import { writeFile, unlink, stat } from "node:fs/promises";
|
|
12
11
|
import { tmpdir } from "node:os";
|
|
13
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
12
|
+
import { extname, isAbsolute, join, resolve } from "node:path";
|
|
14
13
|
import { CoreSchemeAdapterBase } from "../core/CoreSchemeServices.js";
|
|
15
14
|
import ErrorDetail from "../core/ErrorDetail.js";
|
|
16
15
|
import Results, { OperationFailureError } from "../core/results.js";
|
|
17
|
-
import { InvalidOperationResultError, NetworkAddress, } from "@plurnk/plurnk-schemes";
|
|
16
|
+
import { InvalidOperationResultError, NetworkAddress, ResourceNames, } from "@plurnk/plurnk-schemes";
|
|
18
17
|
import DbProjectionCaps from "../core/caps/DbProjectionCaps.js";
|
|
19
18
|
import WorkerControlAddress from "../core/WorkerControlAddress.js";
|
|
20
19
|
import Turn from "../core/Turn.js";
|
|
21
20
|
import LoopLifecycle from "../core/LoopLifecycle.js";
|
|
22
21
|
import LogEntryProjection from "../core/LogEntryProjection.js";
|
|
23
22
|
import LogBody from "../core/LogBody.js";
|
|
23
|
+
import ToolResources from "../core/ToolResources.js";
|
|
24
24
|
import { setTimeout as delay } from "node:timers/promises";
|
|
25
25
|
import ExecScheduler from "./ExecScheduler.js";
|
|
26
|
+
import ExecutionInput from "./ExecutionInput.js";
|
|
26
27
|
import { execRouteOf } from "./exec-runtime.js";
|
|
27
28
|
// Executors are discovered + probed at boot into ExecutorRegistry and reach
|
|
28
29
|
// the scheme through ctx.executors ({§exec-registry-resolves}). Each runtime tag
|
|
@@ -49,68 +50,34 @@ const resourceSourceOf = (target) => {
|
|
|
49
50
|
return null;
|
|
50
51
|
return target.raw;
|
|
51
52
|
};
|
|
52
|
-
// EXEC's pathname is <runtime>/<loop_seq>/<turn_seq>/<sequence> (stamped by
|
|
53
|
-
// Dispatcher.#writeLog). Exec owns this convention, so it — not the client — turns
|
|
54
|
-
// the pathname into the entry's coordinate, mirrored onto stream payloads so
|
|
55
|
-
// clients read fields instead of parsing the URI. The
|
|
56
|
-
// coordinate is the numeric triple before the `/EXEC` op segment ({§log-coordinate-hierarchy}:
|
|
57
|
-
// every item address is loop/turn/item/OP); any other pathname yields undefined (no
|
|
58
|
-
// coordinate on the wire).
|
|
59
|
-
// {§notifications-stream-event-on-channel-change}, {§notifications-stream-concluded}
|
|
60
|
-
const coordinateFromPathname = (pathname) => {
|
|
61
|
-
const seg = pathname.split("/").filter(Boolean);
|
|
62
|
-
if (seg.length < 4 || seg.at(-1) !== "EXEC")
|
|
63
|
-
return undefined;
|
|
64
|
-
const [loop_seq, turn_seq, sequence] = seg.slice(-4, -1).map(Number);
|
|
65
|
-
if (![loop_seq, turn_seq, sequence].every(Number.isInteger))
|
|
66
|
-
return undefined;
|
|
67
|
-
return { loop_seq, turn_seq, sequence };
|
|
68
|
-
};
|
|
69
|
-
// {§stream-owner-scoped} — resolve a stream statement's authority to the owning worker and hand
|
|
70
|
-
// back the statement authority-stripped (the storage path is the bare loop coordinate; the owner
|
|
71
|
-
// rides the owner_id column, never the pathname). Empty authority = the CALLING worker — your own
|
|
72
|
-
// streams need no qualifier, so a fan-out sibling's identical coordinate can never be yours
|
|
73
|
-
// ({§stream-owner-scoped}).
|
|
74
|
-
// A named authority = that worker's streams, any worker of the workspace (#394); an unknown
|
|
75
|
-
// name resolves null → the face 404s.
|
|
76
|
-
export const resolveStreamStatement = async (statement, ctx) => {
|
|
77
|
-
const t = statement.target;
|
|
78
|
-
const hostname = t !== null && t.kind === "url" ? t.hostname : null;
|
|
79
|
-
const ownerId = await Owner.resolveStreamOwner(hostname, ctx);
|
|
80
|
-
if (ownerId === null)
|
|
81
|
-
return null;
|
|
82
|
-
if (hostname === null || t === null || t.kind !== "url")
|
|
83
|
-
return { statement, ownerId };
|
|
84
|
-
return { statement: { ...statement, target: { ...t, hostname: null } }, ownerId };
|
|
85
|
-
};
|
|
86
53
|
export default class Exec extends CoreSchemeAdapterBase {
|
|
87
54
|
// The slot contract, stated when a resource source cannot be read: the resource IS the
|
|
88
|
-
// program and the body its stdin; a
|
|
55
|
+
// program and the body its stdin; a targetless invocation takes a command body.
|
|
89
56
|
static sourceRecovery(source, upstream) {
|
|
90
|
-
const contract =
|
|
57
|
+
const contract = `The target \`${source}\` names the program resource; the body is its stdin. Without a target, the body is the command.`;
|
|
91
58
|
return typeof upstream === "string" && upstream.length > 0 ? `${contract} ${upstream}` : contract;
|
|
92
59
|
}
|
|
93
60
|
static manifest = {
|
|
94
61
|
name: "exec",
|
|
95
|
-
authority: "
|
|
62
|
+
authority: "namespace",
|
|
96
63
|
channels: { stdout: "text/stream", stderr: "text/stream" },
|
|
97
64
|
defaultChannel: "stdout",
|
|
98
65
|
category: "data",
|
|
99
|
-
entryOwner: "worker",
|
|
100
|
-
inherit: "none",
|
|
101
66
|
writableBy: ["model", "client"],
|
|
102
67
|
volatile: true,
|
|
103
68
|
modelVisible: true,
|
|
104
69
|
metadataModifier: true,
|
|
105
|
-
documentation: "
|
|
70
|
+
documentation: "The opening fence names a registered executor or MCP service; its target, body, metadata, and timing follow that tool's invocation contract. Output streams into the workspace's `<executor>:///<id>` entry on that tool's own channels. A host-effecting invocation proposes for review before it runs; a read-only or pure one runs ungated. While it runs, the packet's `## Delegation` streams list reports channel size and growth and READ can inspect any range; when it finishes, one terminal READ becomes visible automatically.",
|
|
106
71
|
};
|
|
107
72
|
// The web-fetch the entry sink calls on content:null ({§exec-entry-sink}).
|
|
108
73
|
// Default = schemes-http's checked WebFetcher; injectable for tests.
|
|
109
74
|
#fetchWeb;
|
|
110
75
|
#scheduler;
|
|
76
|
+
#inputTimeoutMs;
|
|
111
77
|
constructor(fetchWeb) {
|
|
112
78
|
super();
|
|
113
79
|
this.#scheduler = new ExecScheduler();
|
|
80
|
+
this.#inputTimeoutMs = ExecutionInput.configuredTimeout();
|
|
114
81
|
if (fetchWeb === undefined) {
|
|
115
82
|
const webFetcher = new WebFetcher();
|
|
116
83
|
this.#fetchWeb = (url, opts) => webFetcher.fetch(url, opts);
|
|
@@ -138,11 +105,6 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
138
105
|
return true;
|
|
139
106
|
return false;
|
|
140
107
|
}
|
|
141
|
-
// {§exec-timeout} — a `<-1>` spawn is nobody's obligation: terminals, joins, and optimistic
|
|
142
|
-
// settlement look past it.
|
|
143
|
-
isDetachedSpawn(subscriptionId) {
|
|
144
|
-
return this.#activeAborts.get(subscriptionId)?.detached === true;
|
|
145
|
-
}
|
|
146
108
|
// {§exec-timeout} — a `<-1>` spawn ends with the daemon: nothing else ever aborts it, so the
|
|
147
109
|
// stop sequence reaps it (bounded housekeeping) before the streaming drain barrier.
|
|
148
110
|
abortDetached() {
|
|
@@ -186,18 +148,13 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
186
148
|
async kill(pathname, scope, ctx, scheme = "exec") {
|
|
187
149
|
const core = this.coreContext(ctx);
|
|
188
150
|
for (const entry of this.#activeAborts.values()) {
|
|
189
|
-
if (entry.
|
|
151
|
+
if (entry.workspaceId === core.workspaceId && entry.pathname === pathname && (scheme === "exec" || entry.runtime === scheme)) {
|
|
190
152
|
entry.controller.abort(ExecAbort.killReason(null));
|
|
191
153
|
return { status: 200 };
|
|
192
154
|
}
|
|
193
155
|
}
|
|
194
|
-
// Not running — settle the outcome from the closed subscription's status, scoped to the
|
|
195
|
-
// caller's own subscription (coordinates duplicate across workers, {§stream-owner-scoped}).
|
|
196
|
-
// The error answers in the model's OWN runtime-tag address (sh:///…), never the retired
|
|
197
|
-
// internal `exec` machinery ({§fs-answer-in-canon}) — the model KILLs what it addressed.
|
|
198
156
|
const terminal = await ChannelWrite.execTerminalStatus(core.db, {
|
|
199
157
|
workspaceId: core.workspaceId,
|
|
200
|
-
workerId: core.workerId,
|
|
201
158
|
scheme,
|
|
202
159
|
authority: "",
|
|
203
160
|
pathname,
|
|
@@ -219,28 +176,28 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
219
176
|
});
|
|
220
177
|
}
|
|
221
178
|
// EXEC op handler — the actual model-facing entry point per plurnk.md.
|
|
222
|
-
//
|
|
179
|
+
// Named executable fences lower to runtime-owned invocation buckets.
|
|
223
180
|
//
|
|
224
181
|
// Proposes (status=202) with attrs={runtime, cwd, body, pathname}.
|
|
225
182
|
// applyResolution spawns the subprocess; output streams into the
|
|
226
183
|
// coordinate-stamped <runtime>:///<pathname> entry's stdout/stderr channels
|
|
227
|
-
// (e.g. sh:///1/1/2/
|
|
184
|
+
// (e.g. sh:///1/1/2/sh, {§exec}). The model READs that entry on a subsequent turn.
|
|
228
185
|
async exec(statement, ctx) {
|
|
229
186
|
const core = this.coreContext(ctx);
|
|
230
187
|
const body = statement.body ?? "";
|
|
231
188
|
if (core.executors === undefined)
|
|
232
189
|
throw new Error("exec dispatched without an executor registry");
|
|
233
|
-
// {§exec-executor-slot}: the
|
|
190
|
+
// {§exec-executor-slot}: the fence names the executor; the path is its program.
|
|
234
191
|
const route = execRouteOf(statement);
|
|
235
192
|
const runtime = route.runtime;
|
|
236
193
|
// {§exec-registry-resolves} — a non-empty tag selects exactly one registered executable
|
|
237
194
|
// tool. Unknown tags are not reinterpreted as shell command words: that would make the
|
|
238
195
|
// executed command differ from the authored body. Bare EXEC remains the default-shell form.
|
|
239
|
-
const resolved = core.executors.entry(runtime, core.
|
|
196
|
+
const resolved = core.executors.entry(runtime, core.workspaceId);
|
|
240
197
|
if (resolved === undefined) {
|
|
241
|
-
return Results.failure("scheme:exec", "executor-not-registered", 400,
|
|
198
|
+
return Results.failure("scheme:exec", "executor-not-registered", 400, `No executor or MCP service named \`${runtime}\` is registered for this worker.`, {}, {
|
|
242
199
|
requestedRuntime: runtime,
|
|
243
|
-
executors: core.executors.availableRuntimes(core.
|
|
200
|
+
executors: core.executors.availableRuntimes(core.workspaceId),
|
|
244
201
|
retryable: false,
|
|
245
202
|
});
|
|
246
203
|
}
|
|
@@ -251,7 +208,7 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
251
208
|
retryable: false,
|
|
252
209
|
});
|
|
253
210
|
}
|
|
254
|
-
const registry = core.executors.toolRegistry(runtime, core.
|
|
211
|
+
const registry = core.executors.toolRegistry(runtime, core.workspaceId);
|
|
255
212
|
const exactTarget = route.target === null ? null : route.target.raw;
|
|
256
213
|
const registeredTool = registry?.tools.find((tool) => tool.target === exactTarget);
|
|
257
214
|
if (registry !== null && registeredTool === undefined) {
|
|
@@ -262,7 +219,7 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
262
219
|
runtime,
|
|
263
220
|
availableTargetCount: availableTargets.length,
|
|
264
221
|
...(availableTargets.length === 0 ? {} : {
|
|
265
|
-
recovery: `Select a target documented under worker
|
|
222
|
+
recovery: `Select a target documented under worker:///_plurnk/tools/${runtime}/.`,
|
|
266
223
|
}),
|
|
267
224
|
retryable: false,
|
|
268
225
|
});
|
|
@@ -273,7 +230,7 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
273
230
|
const hasTarget = execTarget !== null;
|
|
274
231
|
const refuse = (code, detail, recovery, extensions = {}) => Results.failure("scheme:exec", code, 400, detail, {}, { runtime, recovery, retryable: false, ...extensions });
|
|
275
232
|
if (invocation.body.required && !hasBody) {
|
|
276
|
-
return refuse("body-required", `Executable tool '${runtime}' requires a ${invocation.body.role} body.`, `Provide the ${invocation.body.role} in the
|
|
233
|
+
return refuse("body-required", `Executable tool '${runtime}' requires a ${invocation.body.role} body.`, `Provide the ${invocation.body.role} in the ${runtime} body.`);
|
|
277
234
|
}
|
|
278
235
|
if (invocation.target === undefined && hasTarget) {
|
|
279
236
|
return refuse("target-not-supported", `Executable tool '${runtime}' does not accept a target.`, `Remove the target and provide the ${invocation.body.role} in the body.`);
|
|
@@ -315,34 +272,25 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
315
272
|
}
|
|
316
273
|
}
|
|
317
274
|
}
|
|
318
|
-
// {§
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
const inspected = isAbsolute(named[1]) ? named[1] : resolve(runRoot, named[1]);
|
|
330
|
-
let isDirectory = false;
|
|
331
|
-
try {
|
|
332
|
-
isDirectory = (await stat(inspected)).isDirectory();
|
|
333
|
-
}
|
|
334
|
-
catch (cause) {
|
|
335
|
-
if (cause?.code !== "ENOENT")
|
|
336
|
-
throw cause;
|
|
275
|
+
// {§executor-metadata} Options belong to the invoked executor for every source kind.
|
|
276
|
+
const executor = resolved.executor;
|
|
277
|
+
if (executor.prepare !== undefined) {
|
|
278
|
+
const prepared = Results.assert(await executor.prepare({
|
|
279
|
+
runtime, body, target: resourceSource ?? target, cwd, metadata: statement.metadata,
|
|
280
|
+
}));
|
|
281
|
+
if (prepared.status >= 400)
|
|
282
|
+
return prepared;
|
|
283
|
+
if (prepared.status !== 200 || (prepared.cwd !== null && (typeof prepared.cwd !== "string" || !isAbsolute(prepared.cwd)))) {
|
|
284
|
+
throw new InvalidOperationResultError(`Executable tool '${runtime}' returned invalid invocation preparation.`);
|
|
337
285
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
286
|
+
cwd = prepared.cwd;
|
|
287
|
+
}
|
|
288
|
+
else if ((statement.metadata?.length ?? 0) > 0) {
|
|
289
|
+
return Results.failure("scheme:exec", "metadata-unsupported", 400, `Executable tool '${runtime}' does not accept metadata.`, {}, { runtime, retryable: false });
|
|
342
290
|
}
|
|
343
291
|
// A `script` target must be an existing file; other kinds pass through as declared.
|
|
344
292
|
if (target !== null && targetDecl?.kind === "script") {
|
|
345
|
-
const inspected = isAbsolute(target) ? target : resolve(cwd, target);
|
|
293
|
+
const inspected = isAbsolute(target) ? target : resolve(cwd ?? process.cwd(), target);
|
|
346
294
|
let kind = "missing";
|
|
347
295
|
try {
|
|
348
296
|
kind = (await stat(inspected)).isDirectory() ? "directory" : "file";
|
|
@@ -350,11 +298,11 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
350
298
|
catch (cause) {
|
|
351
299
|
if (cause?.code !== "ENOENT") {
|
|
352
300
|
console.error(`EXEC target classification failed for '${inspected}':`, cause);
|
|
353
|
-
return Results.failure("scheme:exec", "target-classification-failed", 500,
|
|
301
|
+
return Results.failure("scheme:exec", "target-classification-failed", 500, `${runtime} target '${target}' could not be inspected: ${ErrorDetail.preview(cause)}`, {}, { target, stage: "target-classification" });
|
|
354
302
|
}
|
|
355
303
|
}
|
|
356
304
|
if (kind === "directory") {
|
|
357
|
-
return refuse("target-not-a-program",
|
|
305
|
+
return refuse("target-not-a-program", `${runtime} target '${target}' is a directory, not a program.`, "Run in a directory with `[{\"cwd\": \"<directory>\"}]` and put the command in the body.", { target });
|
|
358
306
|
}
|
|
359
307
|
if (kind === "missing") {
|
|
360
308
|
// The target is not a script here, but it may be a registered tool of another
|
|
@@ -362,12 +310,12 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
362
310
|
const executors = core.executors;
|
|
363
311
|
const ownerRuntimes = executors === undefined
|
|
364
312
|
? []
|
|
365
|
-
: executors.availableRuntimes(core.
|
|
366
|
-
.filter((tag) => executors.toolRegistry(tag, core.
|
|
313
|
+
: executors.availableRuntimes(core.workspaceId)
|
|
314
|
+
.filter((tag) => executors.toolRegistry(tag, core.workspaceId)?.tools.some((tool) => tool.target === target) === true);
|
|
367
315
|
const recovery = ownerRuntimes.length === 0
|
|
368
|
-
?
|
|
369
|
-
: `
|
|
370
|
-
return refuse("target-not-found",
|
|
316
|
+
? `The target must name an existing program resource. A targetless ${runtime} takes the command in its body.`
|
|
317
|
+
: `The tool \`${target}\` is registered under executor \`${ownerRuntimes[0]}\`; use that name on the opening fence.`;
|
|
318
|
+
return refuse("target-not-found", `The ${runtime} program does not resolve as a script or a registered tool for this executor.`, recovery, { target, ...(ownerRuntimes.length === 0 ? {} : { toolRuntimes: ownerRuntimes }) });
|
|
371
319
|
}
|
|
372
320
|
}
|
|
373
321
|
if (!hasBody && target === null && resourceSource === null) {
|
|
@@ -379,10 +327,7 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
379
327
|
const effect = resolved.executor.effect(effectTarget);
|
|
380
328
|
// cwd is the workspace project_root unless target routing selected a
|
|
381
329
|
// directory override. {§exec-target-routing}, {§executor-sinks}
|
|
382
|
-
//
|
|
383
|
-
// <turn_seq>/<sequence> (executor-domain + coordinate, e.g. sh/1/1/2).
|
|
384
|
-
// `pathname` is stamped into attrs at log-write time; applyResolution
|
|
385
|
-
// reads it back here.
|
|
330
|
+
// The log writer claims the workspace output address before proposal application.
|
|
386
331
|
// EXEC repurposes the `<L>` slot as `<timeout, poll>` (MINUTES, held in seconds): mark[0] caps the spawn's
|
|
387
332
|
// lifetime, mark[1] sets the hibernation poll-wake cadence ({§exec-poll}). N>0 → deadline (504);
|
|
388
333
|
// -1 / absent → unbounded (loop-life bounded); 0 → turn-scoped (reaped at the next pre-turn,
|
|
@@ -404,6 +349,69 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
404
349
|
const preview = runtime !== "" ? `[${runtime}] ${previewInput}` : `$ ${previewInput}`;
|
|
405
350
|
return { status: 202, body: preview, attrs }; // host runtime proposes with 202 — {§exec-host-proposes}
|
|
406
351
|
}
|
|
352
|
+
async #inputRecipient(statement, ctx, runtime) {
|
|
353
|
+
const core = this.coreContext(ctx);
|
|
354
|
+
const target = statement.target;
|
|
355
|
+
const failure = (code, status, detail) => ({
|
|
356
|
+
failure: Results.failure("scheme:exec", code, status, detail, {}, { retryable: false }),
|
|
357
|
+
});
|
|
358
|
+
if (target?.kind !== "url" || target.scheme !== runtime || target.fragment !== null
|
|
359
|
+
|| target.query !== null || statement.lineMarker !== null) {
|
|
360
|
+
return failure("invalid-input-target", 400, "SEND input addresses an execution, without a channel or scope.");
|
|
361
|
+
}
|
|
362
|
+
const coordinate = entryCoordinateOf(target, "namespace");
|
|
363
|
+
const found = [...this.#activeAborts.entries()].find(([, entry]) => entry.workspaceId === core.workspaceId && entry.runtime === runtime && entry.pathname === coordinate.pathname);
|
|
364
|
+
if (found !== undefined) {
|
|
365
|
+
if (core.executors?.entry(runtime, core.workspaceId)?.executor !== found[1].executor) {
|
|
366
|
+
return failure("input-unavailable", 409, "This execution's input receiver is no longer enabled.");
|
|
367
|
+
}
|
|
368
|
+
return { found };
|
|
369
|
+
}
|
|
370
|
+
const terminal = await ChannelWrite.execTerminalStatus(core.db, {
|
|
371
|
+
workspaceId: core.workspaceId, scheme: runtime, ...coordinate,
|
|
372
|
+
});
|
|
373
|
+
return terminal === null
|
|
374
|
+
? failure("stream-not-found", 404, "No execution exists at the requested address.")
|
|
375
|
+
: failure("input-closed", 410, "Execution input is closed.");
|
|
376
|
+
}
|
|
377
|
+
async sendInput(statement, ctx, runtime) {
|
|
378
|
+
const recipient = await this.#inputRecipient(statement, ctx, runtime);
|
|
379
|
+
if ("failure" in recipient)
|
|
380
|
+
return recipient.failure;
|
|
381
|
+
const [subscriptionId, entry] = recipient.found;
|
|
382
|
+
const unavailable = entry.input.unavailable();
|
|
383
|
+
if (unavailable !== null)
|
|
384
|
+
return unavailable;
|
|
385
|
+
const denied = await this.capabilityDenial(entry.invocation, ctx);
|
|
386
|
+
if (denied !== null)
|
|
387
|
+
return denied;
|
|
388
|
+
return {
|
|
389
|
+
status: 202,
|
|
390
|
+
attrs: { inputSubscription: subscriptionId, inputBody: statement.body?.raw ?? "", inputTarget: statement.target.raw, effect: entry.effect },
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
async applyInput(args, ctx, runtime) {
|
|
394
|
+
const attrs = args.attrs;
|
|
395
|
+
if (typeof attrs.inputSubscription !== "number" || typeof attrs.inputBody !== "string" || typeof attrs.inputTarget !== "string") {
|
|
396
|
+
throw new InvalidOperationResultError("Execution input proposal is missing its invocation or body.");
|
|
397
|
+
}
|
|
398
|
+
const body = args.body ?? attrs.inputBody;
|
|
399
|
+
const statement = {
|
|
400
|
+
op: "SEND", aside: null, metadata: args.metadata === null ? null : [...args.metadata],
|
|
401
|
+
target: parsePath(attrs.inputTarget), lineMarker: null, body: { raw: body, json: null }, position: { line: 1, column: 1 },
|
|
402
|
+
};
|
|
403
|
+
const recipient = await this.#inputRecipient(statement, ctx, runtime);
|
|
404
|
+
if ("failure" in recipient)
|
|
405
|
+
return recipient.failure;
|
|
406
|
+
const [subscriptionId, entry] = recipient.found;
|
|
407
|
+
if (subscriptionId !== attrs.inputSubscription) {
|
|
408
|
+
return Results.failure("scheme:exec", "input-closed", 410, "The proposed execution input is no longer live.", {}, { retryable: false });
|
|
409
|
+
}
|
|
410
|
+
const denied = await this.capabilityDenial(statement, ctx) ?? await this.capabilityDenial(entry.invocation, ctx);
|
|
411
|
+
if (denied !== null)
|
|
412
|
+
return denied;
|
|
413
|
+
return entry.input.deliver(body, args.metadata, ctx.signal);
|
|
414
|
+
}
|
|
407
415
|
async applyResolution(args, ctx) {
|
|
408
416
|
const core = this.coreContext(ctx);
|
|
409
417
|
const attrs = args.attrs;
|
|
@@ -419,24 +427,30 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
419
427
|
if (!EffectPolicy.isEffect(effect)) {
|
|
420
428
|
throw new InvalidOperationResultError("The accepted EXEC proposal is missing its canonical effect fact.");
|
|
421
429
|
}
|
|
422
|
-
|
|
423
|
-
|
|
430
|
+
const invocation = {
|
|
431
|
+
op: "EXEC", executor: runtime, aside: null, metadata: null,
|
|
432
|
+
target: attrs.resourceSource ? parsePath(attrs.resourceSource) : target === null ? null : parsePath(target),
|
|
433
|
+
lineMarker: null, body, position: { line: 1, column: 1 },
|
|
434
|
+
};
|
|
435
|
+
// {§exec-source-temporary} Admission precedes source realization. Native
|
|
436
|
+
// files retain their environment; only standalone sources need a copy.
|
|
424
437
|
let tempPath = null;
|
|
425
438
|
if (attrs.resourceSource !== undefined) {
|
|
426
439
|
const sourceTarget = parsePath(attrs.resourceSource);
|
|
427
440
|
if (sourceTarget?.kind !== "url" || sourceTarget.scheme === null || sourceTarget.scheme === "file") {
|
|
428
441
|
throw new InvalidOperationResultError("The accepted EXEC proposal has an invalid scheme source address.");
|
|
429
442
|
}
|
|
430
|
-
const
|
|
443
|
+
const source = await this.readExecSource({
|
|
431
444
|
op: "READ",
|
|
432
|
-
|
|
433
|
-
annotation: null,
|
|
445
|
+
aside: null,
|
|
434
446
|
target: sourceTarget,
|
|
435
|
-
metadata:
|
|
447
|
+
metadata: null,
|
|
436
448
|
lineMarker: { marks: [1, -1] },
|
|
449
|
+
matcher: null,
|
|
437
450
|
body: null,
|
|
438
451
|
position: { line: 0, column: 0 },
|
|
439
452
|
}, core);
|
|
453
|
+
const read = source.result;
|
|
440
454
|
if (read.status >= 400) {
|
|
441
455
|
// {§exec-target-routing} — the failure stays the owning READ's (#163); the EXEC
|
|
442
456
|
// contract rides its recovery, because a stream address in the target slot is
|
|
@@ -449,15 +463,20 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
449
463
|
}
|
|
450
464
|
const content = read.content;
|
|
451
465
|
if (typeof content !== "string") {
|
|
452
|
-
return Results.failure("scheme:exec", "source-content-unavailable", 422, `Scheme '${sourceTarget.scheme}' did not supply content for the
|
|
466
|
+
return Results.failure("scheme:exec", "source-content-unavailable", 422, `Scheme '${sourceTarget.scheme}' did not supply content for the ${runtime} source.`, { outcome: "scheme_source_content_unavailable" }, {
|
|
453
467
|
scheme: sourceTarget.scheme,
|
|
454
468
|
sourceStatus: read.status,
|
|
455
469
|
retryable: false,
|
|
456
470
|
});
|
|
457
471
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
472
|
+
if (source.nativePath !== null) {
|
|
473
|
+
target = source.nativePath;
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
tempPath = join(tmpdir(), `plurnk-exec-${crypto.randomUUID()}${extname(sourceTarget.pathname)}`);
|
|
477
|
+
await writeFile(tempPath, content, { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
478
|
+
target = tempPath;
|
|
479
|
+
}
|
|
461
480
|
}
|
|
462
481
|
if (body.length === 0 && target === null) {
|
|
463
482
|
throw new InvalidOperationResultError("The accepted EXEC proposal has neither a body nor a realized target.");
|
|
@@ -468,7 +487,7 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
468
487
|
if (core.executors === undefined) {
|
|
469
488
|
throw new InvalidOperationResultError("An accepted EXEC proposal has no executor registry.");
|
|
470
489
|
}
|
|
471
|
-
const resolved = core.executors.entry(runtime, core.
|
|
490
|
+
const resolved = core.executors.entry(runtime, core.workspaceId);
|
|
472
491
|
if (resolved === undefined) {
|
|
473
492
|
throw new InvalidOperationResultError(`The '${runtime}' executor disappeared after its EXEC proposal.`);
|
|
474
493
|
}
|
|
@@ -485,7 +504,9 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
485
504
|
const seed = { channels: seedChannels };
|
|
486
505
|
// {§exec} — the stream entry's scheme IS the runtime tag (sh/node), so it addresses by
|
|
487
506
|
// tag authority (sh:///l/t/s). The engine registers each runtime tag → this handler.
|
|
488
|
-
const { entryId } = await EntryCrud.writeEntry({ authority: "", pathname }, seed, core, runtime,
|
|
507
|
+
const { entryId } = await EntryCrud.writeEntry({ authority: "", pathname }, seed, core, runtime, {
|
|
508
|
+
defaultChannel: resolved.executor.defaultChannel, output: true,
|
|
509
|
+
});
|
|
489
510
|
if (entryId === null) {
|
|
490
511
|
return Results.failure("scheme:exec", "stream-entry-write-failed", 500, `The ${runtime} stream entry could not be created.`, {
|
|
491
512
|
outcome: "entry_write_failed",
|
|
@@ -500,6 +521,10 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
500
521
|
handle: runtime !== "" ? `${runtime}: ${body !== "" ? body : target ?? ""}` : body,
|
|
501
522
|
pollSeconds: typeof attrs.pollSec === "number" ? attrs.pollSec : null, // {§exec-poll} — hibernation wake cadence
|
|
502
523
|
turnScoped: attrs.turnScoped === true, // {§exec-poll} — `<0>` reaped at the next pre-turn
|
|
524
|
+
detached: attrs.detached === true, // {§worker-obligations} — `<-1>` is nobody's obligation
|
|
525
|
+
publishedChannel: resolved.executor.publishedChannel,
|
|
526
|
+
source: attrs.coordinate === undefined ? undefined
|
|
527
|
+
: `log:///${attrs.coordinate.loop_seq}/${attrs.coordinate.turn_seq}/${attrs.coordinate.sequence}/${runtime}`,
|
|
503
528
|
});
|
|
504
529
|
const controller = new AbortController();
|
|
505
530
|
let unlink = () => { };
|
|
@@ -521,7 +546,8 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
521
546
|
if (parent.aborted)
|
|
522
547
|
controller.abort(ExecAbort.teardownReason());
|
|
523
548
|
}
|
|
524
|
-
|
|
549
|
+
const input = new ExecutionInput(controller.signal, this.#inputTimeoutMs);
|
|
550
|
+
this.#activeAborts.set(subscriptionId, { workspaceId: core.workspaceId, workerId: core.workerId, turnId: core.turnId, pathname, runtime, effect, controller, unlink, detached: attrs.detached === true, input, invocation, executor: resolved.executor });
|
|
525
551
|
this.liveSubscriptions().register(subscriptionId, {
|
|
526
552
|
cancel: () => controller.abort(ExecAbort.teardownReason()),
|
|
527
553
|
});
|
|
@@ -530,8 +556,8 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
530
556
|
try {
|
|
531
557
|
return await this.#runExecutor({
|
|
532
558
|
executor: resolved.executor,
|
|
533
|
-
runtime, body, cwd, target, ctx: core, pathname,
|
|
534
|
-
entryId, subscriptionId, signal: controller.signal, controller, tempPath,
|
|
559
|
+
runtime, body, cwd, target, metadata: args.metadata, ctx: core, pathname, coordinate: attrs.coordinate,
|
|
560
|
+
entryId, subscriptionId, signal: controller.signal, controller, tempPath, input,
|
|
535
561
|
timeoutSec: typeof attrs.timeoutSec === "number" ? attrs.timeoutSec : null,
|
|
536
562
|
});
|
|
537
563
|
}
|
|
@@ -567,10 +593,41 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
567
593
|
// a setState("closed") that races a prior write() can flip the
|
|
568
594
|
// notify's reported state to "closed" before the chunk event fires
|
|
569
595
|
// as "active." Chain through a single promise queue to serialize.
|
|
596
|
+
// {§exec-tool-fall-through} — a bare shell command whose program is really the name of a tool
|
|
597
|
+
// of an enabled runtime (`brave_web_search {…}` under the default shell) dies with the shell's
|
|
598
|
+
// exit 127. The failure receipt states that fact at the failure site, with the invocation the
|
|
599
|
+
// registry actually publishes, so the model recovers in one turn instead of by rereading docs.
|
|
600
|
+
#namedToolFallThrough(result, runtime, body, ctx) {
|
|
601
|
+
const core = this.coreContext(ctx);
|
|
602
|
+
const executors = core.executors;
|
|
603
|
+
if (executors === undefined || result.problem === undefined)
|
|
604
|
+
return result;
|
|
605
|
+
const program = body.trim().split(/\s+/u, 1)[0] ?? "";
|
|
606
|
+
if (program.length === 0)
|
|
607
|
+
return result;
|
|
608
|
+
const owners = executors.availableRuntimes(core.workspaceId)
|
|
609
|
+
.filter((tag) => tag !== runtime
|
|
610
|
+
&& executors.toolRegistry(tag, core.workspaceId)?.tools.some((tool) => tool.target === program) === true);
|
|
611
|
+
if (owners.length === 0)
|
|
612
|
+
return result;
|
|
613
|
+
const owner = owners[0];
|
|
614
|
+
// The tool's own document, where its family publishes it ({§tools-resource-materialization}).
|
|
615
|
+
const root = executors.entry(owner, core.workspaceId)?.resourcesPath ?? "/plurnk";
|
|
616
|
+
const contract = `worker://${generatedPathname(`${root}/${owner}/${ToolResources.targetSegment(program)}.md`)}`;
|
|
617
|
+
return {
|
|
618
|
+
...result,
|
|
619
|
+
problem: {
|
|
620
|
+
...result.problem,
|
|
621
|
+
detail: `'${runtime}' exited with code 127; \`${program}\` is a registered tool of \`${owner}\`.`,
|
|
622
|
+
recovery: `Use the \`${owner}\` fence with target \`(${program})\` and JSON input in the body; contract: ${contract}.`,
|
|
623
|
+
toolRuntimes: owners,
|
|
624
|
+
tool: program,
|
|
625
|
+
},
|
|
626
|
+
};
|
|
627
|
+
}
|
|
570
628
|
async #runExecutor(opts) {
|
|
571
|
-
const { executor, runtime, body, cwd, target, ctx, pathname, entryId, subscriptionId, signal, controller, timeoutSec, tempPath } = opts;
|
|
629
|
+
const { executor, runtime, body, cwd, target, metadata, ctx, pathname, entryId, subscriptionId, signal, controller, timeoutSec, tempPath, input, coordinate } = opts;
|
|
572
630
|
const db = ctx.db;
|
|
573
|
-
const coordinate = coordinateFromPathname(pathname);
|
|
574
631
|
// grammar 0.74.20 EXEC `<T>` — kill the spawn after T seconds. unref'd so a pending timer never
|
|
575
632
|
// holds the process open; cleared in finally so a spawn that finishes first leaves no timer.
|
|
576
633
|
let timedOut = false;
|
|
@@ -607,7 +664,14 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
607
664
|
callerSource = WorkerControlAddress.render(caller.name);
|
|
608
665
|
return callerSource;
|
|
609
666
|
};
|
|
610
|
-
const
|
|
667
|
+
const publishedNames = new ResourceNames();
|
|
668
|
+
const entrySink = (requestedPath, content, opts) => {
|
|
669
|
+
let path = requestedPath;
|
|
670
|
+
if (path === null) {
|
|
671
|
+
if (content === null)
|
|
672
|
+
return Promise.reject(new Error("entry(): an invocation resource requires supplied content"));
|
|
673
|
+
path = renderAddress({ scheme: runtime, authority: "", pathname: `${pathname}/resources/${publishedNames.allocate(opts.name)}` });
|
|
674
|
+
}
|
|
611
675
|
const parsed = parsePath(path);
|
|
612
676
|
if (parsed === null || parsed.kind !== "url")
|
|
613
677
|
return Promise.reject(new Error(`entry(): '${path.slice(0, 80)}' is not a URL`));
|
|
@@ -619,7 +683,9 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
619
683
|
const fetchAddress = address !== null && (address.scheme === "http" || address.scheme === "https")
|
|
620
684
|
? address
|
|
621
685
|
: null;
|
|
622
|
-
const binding =
|
|
686
|
+
const binding = requestedPath === null
|
|
687
|
+
? Promise.resolve({ address: { scheme: runtime, authority: "", pathname: parsed.pathname }, result: null })
|
|
688
|
+
: this.bindEntryAddress(parsed, ctx);
|
|
623
689
|
// {§exec-entry-sink}/{§web-search-retrieval} — start content:null
|
|
624
690
|
// acquisition before the write chain so fetches run in parallel;
|
|
625
691
|
// only durable entry writes serialize. A null result rejects the sink.
|
|
@@ -629,12 +695,12 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
629
695
|
return Promise.reject(new Error("entry(): content:null requires an http(s):// URL"));
|
|
630
696
|
materialized = this.#fetchWeb(fetchAddress.url, { signal });
|
|
631
697
|
}
|
|
632
|
-
else {
|
|
698
|
+
else if (typeof content === "string" && requestedPath !== null) {
|
|
633
699
|
materialized = Promise.resolve({
|
|
634
700
|
url: fetchAddress?.url ?? "http://localhost",
|
|
635
701
|
body: content,
|
|
636
702
|
mimetype: opts.mimetype,
|
|
637
|
-
|
|
703
|
+
allowConfiguredMaterializer: false,
|
|
638
704
|
});
|
|
639
705
|
}
|
|
640
706
|
const op = async () => {
|
|
@@ -647,36 +713,50 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
647
713
|
if (resolved.address === null) {
|
|
648
714
|
throw new Error(`entry(): '${path.slice(0, 80)}' did not resolve to an entry address`);
|
|
649
715
|
}
|
|
650
|
-
const { authority, pathname, scheme
|
|
716
|
+
const { authority, pathname, scheme } = resolved.address;
|
|
651
717
|
const coordinate = { authority, pathname };
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
718
|
+
let channels;
|
|
719
|
+
let decisive;
|
|
720
|
+
let source;
|
|
721
|
+
if (materialized === undefined) {
|
|
722
|
+
if (content === null)
|
|
723
|
+
throw new Error("entry(): missing supplied content");
|
|
724
|
+
const body = typeof content === "string" ? { content, mimetype: opts.mimetype }
|
|
725
|
+
: { content: "", bytes: content, mimetype: opts.mimetype };
|
|
726
|
+
const channel = requestedPath === null ? executor.defaultChannel : ctx.defaultChannelFor?.(scheme);
|
|
727
|
+
if (channel === undefined)
|
|
728
|
+
throw new Error(`entry(): no default channel for '${scheme}'`);
|
|
729
|
+
channels = { [channel]: body };
|
|
730
|
+
decisive = typeof content === "string" ? content : `${opts.mimetype}; ${content.byteLength} bytes`;
|
|
731
|
+
source = decisive;
|
|
658
732
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
733
|
+
else {
|
|
734
|
+
const fetched = await materialized;
|
|
735
|
+
if (fetched === null)
|
|
736
|
+
throw new Error(`entry(): '${path.slice(0, 80)}' is dead`);
|
|
737
|
+
let web;
|
|
738
|
+
try {
|
|
739
|
+
web = await WebFetcher.materialize(fetched, new DbProjectionCaps(ctx));
|
|
662
740
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
741
|
+
catch (error) {
|
|
742
|
+
if (!signal.aborted && error instanceof WebMaterializationError) {
|
|
743
|
+
console.error("entry() web materialization failed", { path, error });
|
|
744
|
+
}
|
|
745
|
+
throw error;
|
|
746
|
+
}
|
|
747
|
+
if (web === null)
|
|
748
|
+
throw new Error(`entry(): '${path.slice(0, 80)}' has no readable projection`);
|
|
749
|
+
if (web.body === undefined)
|
|
750
|
+
throw new Error(web.bodyOutcome.failure?.detail ?? `entry(): '${path.slice(0, 80)}' produced no readable body`);
|
|
751
|
+
channels = WebFetcher.materializedChannels(web, content === null && fetchAddress !== null ? { url: fetchAddress.url, method: "GET" } : undefined);
|
|
752
|
+
decisive = web.body.content;
|
|
753
|
+
source = web.html?.content ?? decisive;
|
|
670
754
|
}
|
|
671
|
-
// {§exec-entry-sink}/{§html-materialization} The shared
|
|
672
|
-
// materializer owns the decisive projection and its provenance.
|
|
673
|
-
const channels = WebFetcher.materializedChannels(web, content === null && fetchAddress !== null
|
|
674
|
-
? { url: fetchAddress.url, method: "GET" }
|
|
675
|
-
: undefined);
|
|
676
|
-
const decisive = web.body.content;
|
|
677
|
-
const source = web.html?.content ?? decisive;
|
|
678
755
|
const causalSource = await resolveCallerSource();
|
|
679
|
-
const written = Results.assert(await EntryCrud.writeEntry(coordinate, { channels }, ctx, scheme,
|
|
756
|
+
const written = Results.assert(await EntryCrud.writeEntry(coordinate, { channels }, ctx, scheme, {
|
|
757
|
+
defaultChannel: requestedPath === null ? executor.defaultChannel : ctx.defaultChannelFor?.(scheme),
|
|
758
|
+
output: requestedPath === null,
|
|
759
|
+
}));
|
|
680
760
|
if (narration === null) {
|
|
681
761
|
const worker = await db.envelope_get_worker_by_name.get({ workspace_id: ctx.workspaceId, name: "plurnk" })
|
|
682
762
|
?? await db.envelope_insert_worker.get({ workspace_id: ctx.workspaceId, name: "plurnk", origin: "_plurnk" });
|
|
@@ -721,7 +801,7 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
721
801
|
const logRow = await db.engine_insert_log_entry.get({
|
|
722
802
|
worker_id: narration.workerId, loop_id: narration.loopId, turn_id: narration.turnId, sequence,
|
|
723
803
|
origin: "_plurnk", source: causalSource, model_call_id: null,
|
|
724
|
-
op: "EDIT",
|
|
804
|
+
op: "EDIT", signal: null,
|
|
725
805
|
scheme, username: null, password: null,
|
|
726
806
|
hostname: address === null ? null : parsed.hostname,
|
|
727
807
|
port: address === null ? null : parsed.port,
|
|
@@ -757,34 +837,35 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
757
837
|
return run;
|
|
758
838
|
};
|
|
759
839
|
const executionFailures = [];
|
|
840
|
+
const cancelled = (exitCode) => Results.failure("scheme:exec", "execution-cancelled", 499, `Execution of '${runtime}' was cancelled by the service.`, exitCode === undefined ? {} : { exitCode }, { runtime, stage: "execution", retryable: false });
|
|
760
841
|
try {
|
|
761
842
|
if (signal.aborted) {
|
|
762
|
-
result =
|
|
763
|
-
runtime,
|
|
764
|
-
stage: "execution",
|
|
765
|
-
retryable: false,
|
|
766
|
-
});
|
|
843
|
+
result = cancelled();
|
|
767
844
|
}
|
|
768
845
|
else
|
|
769
846
|
try {
|
|
770
847
|
const reported = await executor.run({
|
|
771
|
-
|
|
848
|
+
registerInput: (receiver) => input.register(receiver),
|
|
849
|
+
runtime, body, cwd, target, metadata, signal,
|
|
772
850
|
entry: entrySink,
|
|
773
851
|
interact: (request) => {
|
|
774
852
|
if (ctx.requestInteraction === undefined) {
|
|
775
853
|
throw new Error("EXEC client interaction capability is unavailable.");
|
|
776
854
|
}
|
|
777
|
-
return ctx.requestInteraction(request);
|
|
855
|
+
return ctx.requestInteraction(request, signal);
|
|
778
856
|
},
|
|
779
857
|
env: ExecEnv.scoped(), // SPEC {§exec} {§exec-env-scoped} — never plurnk's own secrets
|
|
780
858
|
write: (channel, chunk, mimetype) => enqueue(() => ChannelWrite.appendToChannel(db, {
|
|
859
|
+
producerWorkerId: ctx.workerId,
|
|
781
860
|
entryId, channel, chunk, mimetype, notify: ctx.streamEventNotify, coordinate,
|
|
782
861
|
})),
|
|
783
862
|
setState: (channel, state) => enqueue(() => ChannelWrite.setChannelState(db, {
|
|
863
|
+
producerWorkerId: ctx.workerId,
|
|
784
864
|
entryId, channel, state, notify: ctx.streamEventNotify, coordinate,
|
|
785
865
|
})),
|
|
786
866
|
emit: (event) => ctx.pushNotice?.(event),
|
|
787
867
|
});
|
|
868
|
+
input.close();
|
|
788
869
|
// Drain the queue so the subscription doesn't close before
|
|
789
870
|
// final chunk events / state transitions have committed.
|
|
790
871
|
await queue;
|
|
@@ -801,14 +882,19 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
801
882
|
}
|
|
802
883
|
}
|
|
803
884
|
catch (cause) {
|
|
804
|
-
|
|
805
|
-
//
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
885
|
+
input.close();
|
|
886
|
+
// {§executor-results} — an abort rejection is not an executor crash.
|
|
887
|
+
if (signal.aborted && (cause === signal.reason || (cause instanceof Error && cause.name === "AbortError"))) {
|
|
888
|
+
result = cancelled();
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
console.error(`Executor '${runtime}' threw outside its operation result contract:`, cause);
|
|
892
|
+
result = Results.failure("scheme:exec", "executor-threw", 500, `The '${runtime}' executor failed outside its operation result contract.`, {}, {
|
|
893
|
+
runtime,
|
|
894
|
+
stage: "execution",
|
|
895
|
+
retryable: false,
|
|
896
|
+
});
|
|
897
|
+
}
|
|
812
898
|
}
|
|
813
899
|
const exitCode = typeof result.exitCode === "number" ? result.exitCode : null;
|
|
814
900
|
// A timeout aborts the spawn → the executor reports 499; replace the
|
|
@@ -824,11 +910,10 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
824
910
|
// spawn we reaped did not succeed, whatever it resolved under abort.
|
|
825
911
|
}
|
|
826
912
|
else if (signal.aborted && result.status < 400) {
|
|
827
|
-
result =
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
});
|
|
913
|
+
result = cancelled(exitCode ?? undefined);
|
|
914
|
+
}
|
|
915
|
+
else if (result.status >= 400 && exitCode === 127 && target === null) {
|
|
916
|
+
result = this.#namedToolFallThrough(result, runtime, body, ctx);
|
|
832
917
|
}
|
|
833
918
|
exitLabel = timedOut
|
|
834
919
|
? `timed out after ${(timeoutSec ?? 0) / 60}m`
|
|
@@ -895,7 +980,7 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
895
980
|
if (ctx.wakeWorkerNotify !== undefined) {
|
|
896
981
|
ctx.wakeWorkerNotify({
|
|
897
982
|
workspaceId: ctx.workspaceId, workerId: ctx.workerId,
|
|
898
|
-
|
|
983
|
+
entryId, target: `${runtime}://${pathname}`, subscriptionId, result,
|
|
899
984
|
scheme: runtime,
|
|
900
985
|
summary: `${runtime}://${pathname} completed (${exitLabel}); stdout=${stdoutLength} bytes, stderr=${stderrLength} bytes`,
|
|
901
986
|
...coordinate,
|
|
@@ -909,44 +994,27 @@ export default class Exec extends CoreSchemeAdapterBase {
|
|
|
909
994
|
}
|
|
910
995
|
return result;
|
|
911
996
|
}
|
|
912
|
-
async resolveEntryAddress(target, ctx) {
|
|
913
|
-
if (target.kind !== "url")
|
|
914
|
-
return null;
|
|
915
|
-
const ownerId = await Owner.resolveStreamOwner(target.hostname, this.coreContext(ctx));
|
|
916
|
-
return ownerId === null
|
|
917
|
-
? Results.failure("scheme:exec", "stream-not-found", 404, "No visible stream exists at the requested address.")
|
|
918
|
-
: ownerId === ctx.workerId
|
|
919
|
-
? { authority: "", pathname: target.pathname }
|
|
920
|
-
: Results.failure("scheme:exec", "stream-not-found", 404, "The internal exec surface does not address another Worker's stream; use its runtime scheme.");
|
|
921
|
-
}
|
|
922
997
|
async find(statement, ctx) {
|
|
923
998
|
const core = this.coreContext(ctx);
|
|
924
|
-
|
|
925
|
-
if (owner === null) {
|
|
926
|
-
return Results.failure("scheme:exec", "stream-not-found", 404, "No visible stream exists at the requested address.", {
|
|
927
|
-
content: null, mimetype: null, results: [], itemsWeightTotal: 0, returnedItemsWeightTotal: 0,
|
|
928
|
-
matchingPathCount: 0, matchLocationCount: 0,
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
return EntryFind.findWorkspaceEntries(owner.statement, core, Exec.manifest, { ownerId: owner.ownerId });
|
|
999
|
+
return EntryFind.findWorkspaceEntries(statement, core, Exec.manifest, {});
|
|
932
1000
|
}
|
|
933
1001
|
async readEntry(pathname, ctx) {
|
|
934
1002
|
const core = this.coreContext(ctx);
|
|
935
1003
|
return "entries" in ctx
|
|
936
1004
|
? ctx.entries.read(pathname)
|
|
937
|
-
: EntryCrud.readEntry({ authority: "", pathname }, core, Exec.manifest.name
|
|
1005
|
+
: EntryCrud.readEntry({ authority: "", pathname }, core, Exec.manifest.name);
|
|
938
1006
|
}
|
|
939
1007
|
async writeEntry(pathname, entry, ctx) {
|
|
940
1008
|
const core = this.coreContext(ctx);
|
|
941
1009
|
return "entries" in ctx
|
|
942
1010
|
? ctx.entries.write(pathname, entry)
|
|
943
|
-
: EntryCrud.writeEntry({ authority: "", pathname }, entry, core, Exec.manifest.name
|
|
1011
|
+
: EntryCrud.writeEntry({ authority: "", pathname }, entry, core, Exec.manifest.name);
|
|
944
1012
|
}
|
|
945
1013
|
async deleteEntry(pathname, ctx) {
|
|
946
1014
|
const core = this.coreContext(ctx);
|
|
947
1015
|
return "entries" in ctx
|
|
948
1016
|
? ctx.entries.delete(pathname)
|
|
949
|
-
: EntryCrud.deleteEntry({ authority: "", pathname }, core, Exec.manifest.name
|
|
1017
|
+
: EntryCrud.deleteEntry({ authority: "", pathname }, core, Exec.manifest.name);
|
|
950
1018
|
}
|
|
951
1019
|
}
|
|
952
1020
|
//# sourceMappingURL=Exec.js.map
|