@plurnk/plurnk-service 1.16.5 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.defaults +140 -246
- package/INSTALL.md +84 -138
- package/README.md +10 -6
- package/SPEC.md +2468 -1694
- package/dist/Paths.d.ts +2 -0
- package/dist/Paths.d.ts.map +1 -1
- package/dist/Paths.js +2 -0
- package/dist/Paths.js.map +1 -1
- package/dist/build-info.d.ts.map +1 -1
- package/dist/build-info.js +7 -1
- package/dist/build-info.js.map +1 -1
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts +8 -0
- package/dist/content/body-preview.d.ts.map +1 -0
- package/dist/content/body-preview.js +39 -0
- package/dist/content/body-preview.js.map +1 -0
- package/dist/content/byte-view.d.ts +1 -4
- package/dist/content/byte-view.d.ts.map +1 -1
- package/dist/content/byte-view.js.map +1 -1
- package/dist/content/edit-collision.d.ts.map +1 -1
- package/dist/content/edit-collision.js +3 -4
- package/dist/content/edit-collision.js.map +1 -1
- package/dist/content/line-anchors.d.ts +2 -2
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +4 -3
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/line-selection.d.ts +9 -0
- package/dist/content/line-selection.d.ts.map +1 -0
- package/dist/content/line-selection.js +29 -0
- package/dist/content/line-selection.js.map +1 -0
- package/dist/content/matcher.d.ts +0 -1
- package/dist/content/matcher.d.ts.map +1 -1
- package/dist/content/matcher.js +2 -3
- package/dist/content/matcher.js.map +1 -1
- package/dist/content/pattern-edits.d.ts +39 -0
- package/dist/content/pattern-edits.d.ts.map +1 -0
- package/dist/content/pattern-edits.js +121 -0
- package/dist/content/pattern-edits.js.map +1 -0
- package/dist/content/read-projector.d.ts +18 -9
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +132 -35
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/read-resolve.d.ts +4 -1
- package/dist/content/read-resolve.d.ts.map +1 -1
- package/dist/content/read-resolve.js +42 -7
- package/dist/content/read-resolve.js.map +1 -1
- package/dist/core/AdmittedTurnExecutor.d.ts +2 -5
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +96 -88
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +6 -1
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js +20 -5
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts +2 -3
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +23 -32
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +3 -8
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +2 -28
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +10 -10
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +122 -93
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +15 -11
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +12 -13
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +99 -9
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +7 -0
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts +13 -10
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +13 -5
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.d.ts +2 -2
- package/dist/core/DataStatementRunner.d.ts.map +1 -1
- package/dist/core/DataStatementRunner.js +208 -161
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +24 -26
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +381 -232
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +66 -0
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +2 -1
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/EditMutations.d.ts +14 -18
- package/dist/core/EditMutations.d.ts.map +1 -1
- package/dist/core/EditMutations.js +211 -280
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/EditMutations.sql +15 -0
- package/dist/core/EditSequence.d.ts +13 -0
- package/dist/core/EditSequence.d.ts.map +1 -0
- package/dist/core/EditSequence.js +73 -0
- package/dist/core/EditSequence.js.map +1 -0
- package/dist/core/Engine.d.ts +17 -23
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +74 -164
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +0 -724
- package/dist/core/EntryAddressBinding.d.ts +7 -17
- package/dist/core/EntryAddressBinding.d.ts.map +1 -1
- package/dist/core/EntryAddressBinding.js +12 -72
- package/dist/core/EntryAddressBinding.js.map +1 -1
- package/dist/core/ExecutionOutputs.d.ts +9 -0
- package/dist/core/ExecutionOutputs.d.ts.map +1 -0
- package/dist/core/ExecutionOutputs.js +36 -0
- package/dist/core/ExecutionOutputs.js.map +1 -0
- package/dist/core/ExecutionOutputs.sql +21 -0
- package/dist/core/ExecutorRegistry.d.ts +11 -5
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +37 -32
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/HostPaths.d.ts +1 -0
- package/dist/core/HostPaths.d.ts.map +1 -1
- package/dist/core/HostPaths.js +4 -0
- package/dist/core/HostPaths.js.map +1 -1
- package/dist/core/InferenceCall.d.ts.map +1 -1
- package/dist/core/InferenceCall.js +1 -2
- package/dist/core/InferenceCall.js.map +1 -1
- package/dist/core/InferenceCall.sql +29 -0
- package/dist/core/KillHandler.d.ts +1 -0
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +24 -21
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/LogBody.d.ts +8 -1
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +44 -12
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts +1 -0
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +12 -10
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LogVisibility.d.ts +1 -0
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +3 -0
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LogWriter.d.ts +2 -3
- package/dist/core/LogWriter.d.ts.map +1 -1
- package/dist/core/LogWriter.js +31 -36
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LogWriter.sql +23 -0
- package/dist/core/LoopDriver.d.ts +11 -8
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +161 -189
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopDriver.sql +11 -0
- package/dist/core/LoopLifecycle.d.ts +32 -2
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +88 -4
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +145 -28
- package/dist/core/LoopPolicyReader.sql +6 -0
- package/dist/core/MembershipMaterialization.d.ts.map +1 -1
- package/dist/core/MembershipMaterialization.js +6 -28
- package/dist/core/MembershipMaterialization.js.map +1 -1
- package/dist/core/ModelCall.d.ts.map +1 -1
- package/dist/core/ModelCall.js +2 -6
- package/dist/core/ModelCall.js.map +1 -1
- package/dist/core/ModelCall.sql +41 -0
- package/dist/core/MutationEffects.d.ts +5 -3
- package/dist/core/MutationEffects.d.ts.map +1 -1
- package/dist/core/MutationEffects.js +10 -28
- package/dist/core/MutationEffects.js.map +1 -1
- package/dist/core/NativeContent.d.ts +6 -0
- package/dist/core/NativeContent.d.ts.map +1 -0
- package/dist/core/NativeContent.js +16 -0
- package/dist/core/NativeContent.js.map +1 -0
- package/dist/core/NativeContent.sql +6 -0
- package/dist/core/NoticeChannel.js +1 -1
- package/dist/core/NoticeChannel.js.map +1 -1
- package/dist/core/OperatorConfig.js +5 -5
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts +8 -5
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +117 -81
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +146 -0
- package/dist/core/PatternSelection.d.ts +28 -0
- package/dist/core/PatternSelection.d.ts.map +1 -0
- package/dist/core/PatternSelection.js +42 -0
- package/dist/core/PatternSelection.js.map +1 -0
- package/dist/core/ProblemLog.d.ts.map +1 -1
- package/dist/core/ProblemLog.js +0 -1
- package/dist/core/ProblemLog.js.map +1 -1
- package/dist/core/PromptFrames.d.ts +12 -0
- package/dist/core/PromptFrames.d.ts.map +1 -0
- package/dist/core/PromptFrames.js +28 -0
- package/dist/core/PromptFrames.js.map +1 -0
- package/dist/core/ProposalLifecycle.d.ts +0 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +26 -23
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProposalLifecycle.sql +33 -0
- package/dist/core/ProviderInstantiate.d.ts +1 -1
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +7 -14
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReasoningView.d.ts +9 -0
- package/dist/core/ReasoningView.d.ts.map +1 -0
- package/dist/core/ReasoningView.js +47 -0
- package/dist/core/ReasoningView.js.map +1 -0
- package/dist/core/ResourceBindings.d.ts +16 -0
- package/dist/core/ResourceBindings.d.ts.map +1 -0
- package/dist/core/ResourceBindings.js +45 -0
- package/dist/core/ResourceBindings.js.map +1 -0
- package/dist/core/ResourceMutations.d.ts +5 -8
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +6 -7
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.d.ts +2 -2
- package/dist/core/ResourceSelector.d.ts.map +1 -1
- package/dist/core/ResourceSelector.js +122 -62
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.d.ts +4 -2
- package/dist/core/ResourceTransfers.d.ts.map +1 -1
- package/dist/core/ResourceTransfers.js +95 -26
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/RuntimeWorker.d.ts +5 -0
- package/dist/core/RuntimeWorker.d.ts.map +1 -0
- package/dist/core/RuntimeWorker.js +15 -0
- package/dist/core/RuntimeWorker.js.map +1 -0
- package/dist/core/RuntimeWorker.sql +11 -0
- package/dist/core/SchemeRegistry.d.ts +12 -16
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +59 -85
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StoredPacket.d.ts +6 -1
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +30 -10
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts +11 -8
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +63 -114
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/StrikeRail.sql +12 -0
- package/dist/core/TerminalResult.d.ts +1 -1
- package/dist/core/TerminalResult.d.ts.map +1 -1
- package/dist/core/TerminalResult.js +2 -2
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/TokenCalibration.d.ts +1 -6
- package/dist/core/TokenCalibration.d.ts.map +1 -1
- package/dist/core/TokenCalibration.js +13 -9
- package/dist/core/TokenCalibration.js.map +1 -1
- package/dist/core/TokenCalibration.sql +15 -0
- package/dist/core/ToolInputSchema.d.ts +6 -0
- package/dist/core/ToolInputSchema.d.ts.map +1 -0
- package/dist/core/ToolInputSchema.js +43 -0
- package/dist/core/ToolInputSchema.js.map +1 -0
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +77 -51
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.d.ts +5 -2
- package/dist/core/Turn.d.ts.map +1 -1
- package/dist/core/Turn.js +13 -11
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/Turn.sql +25 -39
- package/dist/core/{SendBroadcastHandler.d.ts → TurnDispositionHandler.d.ts} +24 -18
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -0
- package/dist/core/TurnDispositionHandler.js +206 -0
- package/dist/core/TurnDispositionHandler.js.map +1 -0
- package/dist/core/TurnMaterialization.d.ts +2 -3
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +47 -24
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +44 -0
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +8 -64
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +8 -15
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +1175 -1317
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnRunner.sql +74 -0
- package/dist/core/TurnSources.sql +39 -0
- package/dist/core/WorkerControlAddress.d.ts +1 -0
- package/dist/core/WorkerControlAddress.d.ts.map +1 -1
- package/dist/core/WorkerControlAddress.js +5 -0
- package/dist/core/WorkerControlAddress.js.map +1 -1
- package/dist/core/WorkerControlHandler.d.ts +1 -3
- package/dist/core/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +64 -48
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +11 -12
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +40 -47
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkerName.sql +7 -10
- package/dist/core/WorkspaceGate.d.ts +1 -1
- package/dist/core/WorkspaceGate.d.ts.map +1 -1
- package/dist/core/WorkspaceGate.js +33 -10
- package/dist/core/WorkspaceGate.js.map +1 -1
- package/dist/core/ambient.sql +236 -0
- package/dist/core/attachments.d.ts +2 -1
- package/dist/core/attachments.d.ts.map +1 -1
- package/dist/core/attachments.js +5 -4
- package/dist/core/attachments.js.map +1 -1
- package/dist/core/caps/CapsResolve.d.ts +2 -3
- package/dist/core/caps/CapsResolve.d.ts.map +1 -1
- package/dist/core/caps/CapsResolve.js +5 -5
- package/dist/core/caps/CapsResolve.js.map +1 -1
- package/dist/core/caps/DbChannelCaps.d.ts +1 -1
- package/dist/core/caps/DbChannelCaps.d.ts.map +1 -1
- package/dist/core/caps/DbChannelCaps.js +4 -6
- package/dist/core/caps/DbChannelCaps.js.map +1 -1
- package/dist/core/caps/DbEntryCaps.d.ts +2 -1
- package/dist/core/caps/DbEntryCaps.d.ts.map +1 -1
- package/dist/core/caps/DbEntryCaps.js +11 -17
- package/dist/core/caps/DbEntryCaps.js.map +1 -1
- package/dist/core/caps/DbNotifyCaps.d.ts +1 -1
- package/dist/core/caps/DbNotifyCaps.d.ts.map +1 -1
- package/dist/core/caps/DbNotifyCaps.js +3 -5
- package/dist/core/caps/DbNotifyCaps.js.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +1 -1
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/caps/DbSubscriptionCaps.d.ts +1 -1
- package/dist/core/caps/DbSubscriptionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbSubscriptionCaps.js +5 -7
- package/dist/core/caps/DbSubscriptionCaps.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +0 -2
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +4 -20
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/env-catalog.d.ts +28 -0
- package/dist/core/env-catalog.d.ts.map +1 -0
- package/dist/core/env-catalog.js +99 -0
- package/dist/core/env-catalog.js.map +1 -0
- package/dist/core/env-defaults.d.ts.map +1 -1
- package/dist/core/env-defaults.js +4 -2
- package/dist/core/env-defaults.js.map +1 -1
- package/dist/core/file-materialization.d.ts +4 -1
- package/dist/core/file-materialization.d.ts.map +1 -1
- package/dist/core/file-materialization.js +15 -1
- package/dist/core/file-materialization.js.map +1 -1
- package/dist/core/fork.d.ts +1 -6
- package/dist/core/fork.d.ts.map +1 -1
- package/dist/core/fork.js +9 -153
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +162 -185
- package/dist/core/git-env.d.ts +1 -0
- package/dist/core/git-env.d.ts.map +1 -1
- package/dist/core/git-env.js +39 -2
- package/dist/core/git-env.js.map +1 -1
- package/dist/core/git-membership.d.ts.map +1 -1
- package/dist/core/git-membership.js +64 -48
- package/dist/core/git-membership.js.map +1 -1
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +26 -20
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/glob_match.d.ts +4 -0
- package/dist/core/glob_match.d.ts.map +1 -0
- package/dist/core/glob_match.js +7 -0
- package/dist/core/glob_match.js.map +1 -0
- package/dist/core/maintenance.sql +6 -0
- package/dist/core/mutation-types.d.ts +7 -28
- package/dist/core/mutation-types.d.ts.map +1 -1
- package/dist/core/operation-target-groups.d.ts.map +1 -1
- package/dist/core/operation-target-groups.js +2 -1
- package/dist/core/operation-target-groups.js.map +1 -1
- package/dist/core/packet-inject.d.ts.map +1 -1
- package/dist/core/packet-inject.js +2 -3
- package/dist/core/packet-inject.js.map +1 -1
- package/dist/core/packet-wire.d.ts +8 -6
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +381 -388
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +1 -1
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +5 -12
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/scheme-types.d.ts +3 -3
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.d.ts.map +1 -0
- package/dist/core/sha256.js +6 -0
- package/dist/core/sha256.js.map +1 -0
- package/dist/core/teaching.js +1 -1
- package/dist/core/teaching.js.map +1 -1
- package/dist/core/turn-scheduler.d.ts.map +1 -1
- package/dist/core/turn-scheduler.js +5 -18
- package/dist/core/turn-scheduler.js.map +1 -1
- package/dist/core/turn-signals.d.ts +0 -6
- package/dist/core/turn-signals.d.ts.map +1 -1
- package/dist/core/turn-signals.js +1 -7
- package/dist/core/turn-signals.js.map +1 -1
- package/dist/core/worker-ops.sql +15 -22
- package/dist/core/workspace-settings.d.ts.map +1 -1
- package/dist/core/workspace-settings.js +18 -2
- package/dist/core/workspace-settings.js.map +1 -1
- package/dist/core/workspace-settings.sql +6 -0
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +30 -91
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +1 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +58 -62
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/digest-rows.d.ts +16 -32
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +54 -20
- package/dist/schemes/Exec.d.ts +6 -12
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +318 -215
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +8 -6
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +33 -61
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/ExecScheduler.js +2 -2
- package/dist/schemes/ExecScheduler.js.map +1 -1
- package/dist/schemes/ExecutionInput.d.ts +12 -0
- package/dist/schemes/ExecutionInput.d.ts.map +1 -0
- package/dist/schemes/ExecutionInput.js +94 -0
- package/dist/schemes/ExecutionInput.js.map +1 -0
- package/dist/schemes/File.d.ts +5 -2
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +62 -91
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +84 -79
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Log.sql +183 -15
- package/dist/schemes/Prompt.d.ts.map +1 -1
- package/dist/schemes/Prompt.js +3 -12
- package/dist/schemes/Prompt.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts +5 -0
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +7 -15
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/Skill.d.ts +12 -7
- package/dist/schemes/Skill.d.ts.map +1 -1
- package/dist/schemes/Skill.js +149 -21
- package/dist/schemes/Skill.js.map +1 -1
- package/dist/schemes/TurnSource.d.ts +12 -0
- package/dist/schemes/TurnSource.d.ts.map +1 -0
- package/dist/schemes/TurnSource.js +117 -0
- package/dist/schemes/TurnSource.js.map +1 -0
- package/dist/schemes/Worker.d.ts +3 -3
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +61 -208
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.d.ts +12 -15
- package/dist/schemes/_entry-crud.d.ts.map +1 -1
- package/dist/schemes/_entry-crud.js +63 -63
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +159 -45
- package/dist/schemes/_entry-find.d.ts +1 -3
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +111 -112
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-find.sql +22 -14
- package/dist/schemes/_entry-fts.d.ts +14 -0
- package/dist/schemes/_entry-fts.d.ts.map +1 -0
- package/dist/schemes/_entry-fts.js +82 -0
- package/dist/schemes/_entry-fts.js.map +1 -0
- package/dist/schemes/_entry-fts.sql +31 -0
- package/dist/schemes/_entry-graph.d.ts.map +1 -1
- package/dist/schemes/_entry-graph.js +6 -14
- package/dist/schemes/_entry-graph.js.map +1 -1
- package/dist/schemes/_entry-graph.sql +29 -44
- package/dist/schemes/_entry-manifest.d.ts +2 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +20 -26
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-manifest.sql +26 -0
- package/dist/schemes/_entry-ops.d.ts +3 -5
- package/dist/schemes/_entry-ops.d.ts.map +1 -1
- package/dist/schemes/_entry-ops.js +30 -43
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +5 -6
- package/dist/schemes/_entry-readable.d.ts +8 -0
- package/dist/schemes/_entry-readable.d.ts.map +1 -0
- package/dist/schemes/_entry-readable.js +38 -0
- package/dist/schemes/_entry-readable.js.map +1 -0
- package/dist/schemes/_entry-send.d.ts +1 -1
- package/dist/schemes/_entry-send.d.ts.map +1 -1
- package/dist/schemes/_entry-send.js +3 -3
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/schemes/_search-index.d.ts +5 -3
- package/dist/schemes/_search-index.d.ts.map +1 -1
- package/dist/schemes/_search-index.js +169 -160
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/_search-index.sql +47 -0
- package/dist/schemes/exec-abort.js +1 -1
- package/dist/schemes/exec-abort.js.map +1 -1
- package/dist/schemes/exec-env.d.ts +3 -0
- package/dist/schemes/exec-env.d.ts.map +1 -1
- package/dist/schemes/exec-env.js +66 -15
- package/dist/schemes/exec-env.js.map +1 -1
- package/dist/schemes/exec-runtime.d.ts +1 -1
- package/dist/schemes/exec-runtime.d.ts.map +1 -1
- package/dist/schemes/exec-runtime.js +1 -1
- package/dist/schemes/exec-runtime.js.map +1 -1
- package/dist/server/ClientReads.d.ts +2 -2
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +7 -9
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +15 -21
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +165 -168
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +29 -22
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +8 -21
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +278 -306
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts +43 -0
- package/dist/server/EnvFunctionality.d.ts.map +1 -0
- package/dist/server/EnvFunctionality.js +194 -0
- package/dist/server/EnvFunctionality.js.map +1 -0
- package/dist/server/Functionality.d.ts +12 -11
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +279 -142
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +5 -5
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +29 -57
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/MembersFunctionality.d.ts +5 -4
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +24 -38
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/PlurnkSkill.d.ts +11 -0
- package/dist/server/PlurnkSkill.d.ts.map +1 -0
- package/dist/server/PlurnkSkill.js +41 -0
- package/dist/server/PlurnkSkill.js.map +1 -0
- package/dist/server/Retention.d.ts +25 -0
- package/dist/server/Retention.d.ts.map +1 -0
- package/dist/server/Retention.js +57 -0
- package/dist/server/Retention.js.map +1 -0
- package/dist/server/Retention.sql +59 -0
- package/dist/server/ServiceModules.d.ts +5 -0
- package/dist/server/ServiceModules.d.ts.map +1 -0
- package/dist/server/ServiceModules.js +10 -0
- package/dist/server/ServiceModules.js.map +1 -0
- package/dist/server/SkillsFunctionality.d.ts +14 -19
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +102 -106
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/WorkerModelResolver.d.ts +4 -0
- package/dist/server/WorkerModelResolver.d.ts.map +1 -1
- package/dist/server/WorkerModelResolver.js +72 -39
- package/dist/server/WorkerModelResolver.js.map +1 -1
- package/dist/server/WorkspaceCapabilities.d.ts +21 -0
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -0
- package/dist/server/{WorkerCapabilities.js → WorkspaceCapabilities.js} +40 -40
- package/dist/server/WorkspaceCapabilities.js.map +1 -0
- package/dist/server/WorkspaceResidency.d.ts +38 -0
- package/dist/server/WorkspaceResidency.d.ts.map +1 -0
- package/dist/server/WorkspaceResidency.js +226 -0
- package/dist/server/WorkspaceResidency.js.map +1 -0
- package/dist/server/client-input.d.ts +1 -4
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +5 -46
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.d.ts.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +4 -22
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +66 -43
- package/dist/server/envelope.d.ts +8 -1
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +9 -19
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +49 -13
- package/dist/server/lifecycle-recovery.sql +18 -20
- package/dist/server/logEntry.d.ts +1 -1
- package/dist/server/logEntry.d.ts.map +1 -1
- package/dist/server/logEntry.js +4 -1
- package/dist/server/logEntry.js.map +1 -1
- package/dist/server/logEntry.sql +25 -1
- package/dist/server/loopDocs.d.ts +2 -2
- package/dist/server/loopDocs.d.ts.map +1 -1
- package/dist/server/loopDocs.js +38 -31
- package/dist/server/loopDocs.js.map +1 -1
- package/dist/server/loopDocs.sql +1 -3
- package/dist/server/model-catalog.d.ts.map +1 -1
- package/dist/server/model-catalog.js +2 -1
- package/dist/server/model-catalog.js.map +1 -1
- package/dist/server/model-route.d.ts +1 -1
- package/dist/server/model-route.d.ts.map +1 -1
- package/dist/server/model-route.js +4 -2
- package/dist/server/model-route.js.map +1 -1
- package/dist/server/seam-entry-read.sql +3 -4
- package/dist/server/seam-loop.sql +2 -9
- package/dist/server/workspace-capabilities.sql +64 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +21 -18
- package/dist/service.js.map +1 -1
- package/docs/env.md +55 -0
- package/docs/members.md +83 -0
- package/docs/skills.md +50 -0
- package/migrations/001_workspaces.sql +53 -0
- package/migrations/002_workers.sql +198 -0
- package/migrations/003_loops.sql +326 -0
- package/migrations/004_inference.sql +401 -0
- package/migrations/005_entries.sql +215 -0
- package/migrations/006_log.sql +581 -0
- package/migrations/007_subscriptions.sql +175 -0
- package/migrations/008_interactions.sql +29 -0
- package/package.json +44 -41
- package/digest-sql/channel-dispositions/dispositions.sql +0 -15
- package/digest-sql/channel-state/state.sql +0 -6
- package/digest-sql/curation/curation.sql +0 -6
- package/digest-sql/derivations/derivations.sql +0 -4
- package/digest-sql/embeddings/embeddings.sql +0 -4
- package/digest-sql/entry-dispositions/dispositions.sql +0 -15
- package/digest-sql/entry-state/state.sql +0 -6
- package/digest-sql/token-counts/token-counts.sql +0 -2
- package/dist/core/EmbeddingCall.d.ts +0 -23
- package/dist/core/EmbeddingCall.d.ts.map +0 -1
- package/dist/core/EmbeddingCall.js +0 -149
- package/dist/core/EmbeddingCall.js.map +0 -1
- package/dist/core/OverflowTurn.d.ts +0 -11
- package/dist/core/OverflowTurn.d.ts.map +0 -1
- package/dist/core/OverflowTurn.js +0 -80
- package/dist/core/OverflowTurn.js.map +0 -1
- package/dist/core/Owner.d.ts +0 -8
- package/dist/core/Owner.d.ts.map +0 -1
- package/dist/core/Owner.js +0 -46
- package/dist/core/Owner.js.map +0 -1
- package/dist/core/SendBroadcastHandler.d.ts.map +0 -1
- package/dist/core/SendBroadcastHandler.js +0 -159
- package/dist/core/SendBroadcastHandler.js.map +0 -1
- package/dist/core/VectorPump.d.ts +0 -28
- package/dist/core/VectorPump.d.ts.map +0 -1
- package/dist/core/VectorPump.js +0 -130
- package/dist/core/VectorPump.js.map +0 -1
- package/dist/core/owner.sql +0 -11
- package/dist/core/worker-settings.d.ts +0 -10
- package/dist/core/worker-settings.d.ts.map +0 -1
- package/dist/core/worker-settings.js +0 -53
- package/dist/core/worker-settings.js.map +0 -1
- package/dist/schemes/_entry-chunk.d.ts +0 -14
- package/dist/schemes/_entry-chunk.d.ts.map +0 -1
- package/dist/schemes/_entry-chunk.js +0 -165
- package/dist/schemes/_entry-chunk.js.map +0 -1
- package/dist/schemes/_entry-semantic.d.ts +0 -63
- package/dist/schemes/_entry-semantic.d.ts.map +0 -1
- package/dist/schemes/_entry-semantic.js +0 -299
- package/dist/schemes/_entry-semantic.js.map +0 -1
- package/dist/schemes/_entry-semantic.sql +0 -99
- package/dist/schemes/cosine.d.ts +0 -4
- package/dist/schemes/cosine.d.ts.map +0 -1
- package/dist/schemes/cosine.js +0 -9
- package/dist/schemes/cosine.js.map +0 -1
- package/dist/server/WorkerCapabilities.d.ts +0 -21
- package/dist/server/WorkerCapabilities.d.ts.map +0 -1
- package/dist/server/WorkerCapabilities.js.map +0 -1
- package/dist/server/WorkerResidency.d.ts +0 -40
- package/dist/server/WorkerResidency.d.ts.map +0 -1
- package/dist/server/WorkerResidency.js +0 -283
- package/dist/server/WorkerResidency.js.map +0 -1
- package/dist/server/seam-log-read.sql +0 -21
- package/dist/server/worker-capabilities.sql +0 -28
- package/migrations/001_schema.sql +0 -2207
package/dist/core/packet-wire.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Packet's ordered list of sections renders to ChatMessage.content
|
|
3
|
-
// strings the LLM receives. Engine imports this for the wire payload; the
|
|
4
|
-
// digest tool imports it to write byte-identical packetNNN.{system,user}.md
|
|
5
|
-
// files. No second implementation, no drift.
|
|
6
|
-
//
|
|
7
|
-
// Format and omission rules are owned by {§packet-markdown}. Section producers
|
|
8
|
-
// supply names and typed content; this projection preserves their ordered evidence.
|
|
1
|
+
import { TurnDisposition } from "@plurnk/plurnk-contracts";
|
|
9
2
|
import { relative, sep } from "node:path";
|
|
10
3
|
import { Problems, Validator } from "@plurnk/plurnk-contracts";
|
|
11
4
|
import { TextCoordinates } from "@plurnk/plurnk-mimetypes";
|
|
@@ -13,35 +6,16 @@ import { renderTarget } from "./plurnk-uri.js";
|
|
|
13
6
|
import LogBody from "./LogBody.js";
|
|
14
7
|
import LogEntryProjection from "./LogEntryProjection.js";
|
|
15
8
|
import LogVisibility from "./LogVisibility.js";
|
|
9
|
+
import BodyPreview from "../content/body-preview.js";
|
|
16
10
|
import { assertEditReceipt, assertResourceEffects, LineAnchors, } from "../content/index.js";
|
|
17
|
-
const editReceiptRevisionChars = () => {
|
|
18
|
-
const raw = process.env.PLURNK_SERVICE_EDIT_RECEIPT_REVISION_CHARS;
|
|
19
|
-
const value = Number(raw);
|
|
20
|
-
if (!Number.isSafeInteger(value) || value < 1 || value > 64) {
|
|
21
|
-
throw new Error(`PLURNK_SERVICE_EDIT_RECEIPT_REVISION_CHARS must be a safe integer from 1 through 64, got ${JSON.stringify(raw)}`);
|
|
22
|
-
}
|
|
23
|
-
return value;
|
|
24
|
-
};
|
|
25
|
-
const previewBounds = () => {
|
|
26
|
-
const rawLines = process.env.PLURNK_SERVICE_PREVIEW_LINES;
|
|
27
|
-
const rawChars = process.env.PLURNK_SERVICE_PREVIEW_CHARS;
|
|
28
|
-
const lines = Number(rawLines);
|
|
29
|
-
const chars = Number(rawChars);
|
|
30
|
-
if (!Number.isSafeInteger(lines) || lines < 1) {
|
|
31
|
-
throw new Error(`PLURNK_SERVICE_PREVIEW_LINES must be a positive safe integer, got ${JSON.stringify(rawLines)}`);
|
|
32
|
-
}
|
|
33
|
-
if (!Number.isSafeInteger(chars) || chars < 1) {
|
|
34
|
-
throw new Error(`PLURNK_SERVICE_PREVIEW_CHARS must be a positive safe integer, got ${JSON.stringify(rawChars)}`);
|
|
35
|
-
}
|
|
36
|
-
return { lines, chars };
|
|
37
|
-
};
|
|
38
11
|
// {§packet-attachment-parts} — the attachment kinds and their readout weights live in one table.
|
|
39
12
|
import { imageWeight, pdfWeight } from "./attachments.js";
|
|
13
|
+
import { isExecutionOp } from "@plurnk/plurnk-contracts";
|
|
40
14
|
export { imageWeight, pdfWeight };
|
|
41
15
|
export default class PacketWire {
|
|
42
16
|
// {§packet-markdown} Render the sections in `slot` to one ChatMessage.content
|
|
43
17
|
// string. Sections render in list order; empties are omitted (no empty headers on the wire);
|
|
44
|
-
//
|
|
18
|
+
// JSON follows its H2 directly; other content has one blank line (null header is bare),
|
|
45
19
|
// trailing newlines stripped, joined with a blank line.
|
|
46
20
|
static renderSlot(sections, slot) {
|
|
47
21
|
return sections
|
|
@@ -50,15 +24,15 @@ export default class PacketWire {
|
|
|
50
24
|
.filter((p) => p.length > 0)
|
|
51
25
|
.join("\n\n");
|
|
52
26
|
}
|
|
53
|
-
// One section → its markdown block
|
|
54
|
-
// content when header is null/empty), trailing newlines stripped. Empty
|
|
27
|
+
// One section → its markdown block, trailing newlines stripped. Empty
|
|
55
28
|
// content renders to "" so renderSlot drops it. This is the unit the
|
|
56
29
|
// per-section `weight` is measured over.
|
|
57
30
|
static renderSection(s) {
|
|
58
31
|
if (typeof s.content !== "string" || s.content.length === 0)
|
|
59
32
|
return "";
|
|
60
33
|
const header = typeof s.header === "string" && s.header.length > 0 ? s.header : null;
|
|
61
|
-
|
|
34
|
+
const separator = s.content.startsWith("{") || s.content.startsWith("[") ? "\n" : "\n\n";
|
|
35
|
+
return (header ? `## ${header}${separator}${s.content}` : s.content).replace(/\n+$/, "");
|
|
62
36
|
}
|
|
63
37
|
// Durable operation failures render as `{status, path}` JSON pointers to the log rows that
|
|
64
38
|
// own their exact RFC 9457 results.
|
|
@@ -88,23 +62,27 @@ export default class PacketWire {
|
|
|
88
62
|
return `* ${kind}${message.length > 0 ? `: ${message}` : ""}${position}`;
|
|
89
63
|
}).join("\n");
|
|
90
64
|
}
|
|
91
|
-
// The
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
|
|
65
|
+
// The Delegation section ({§child-orientation}) — the OPPOSITE of advice: terse `{status, path}`
|
|
66
|
+
// JSON pointers (same shape as the errors section) to the live things the worker holds, under the
|
|
67
|
+
// word the teaching uses for handing work out: its unconcluded workers and its open streams. The
|
|
68
|
+
// model SEES them each turn and reasons for itself (READ / SEND / KILL via the path). Orienting
|
|
69
|
+
// state, never an instruction; both lists render every turn, `[]` when empty ({§packet-empty-sections}).
|
|
70
|
+
static renderDelegation(workers, streams) {
|
|
71
|
+
return `{"workers":${PacketWire.#pointers(workers)},\n"streams":${PacketWire.#pointers(streams)}}`;
|
|
72
|
+
}
|
|
73
|
+
static #pointers(rows) {
|
|
96
74
|
const items = Array.isArray(rows) ? rows : [];
|
|
97
75
|
const pointers = items.map((r) => JSON.stringify({
|
|
98
76
|
status: r.status,
|
|
99
77
|
path: r.path,
|
|
100
78
|
...(typeof r.detail === "string" && r.detail.length > 0 ? { detail: r.detail } : {}),
|
|
101
79
|
}));
|
|
102
|
-
return pointers.length === 0 ? "" : `[${pointers.join(",\n")}]`;
|
|
80
|
+
return pointers.length === 0 ? "[]" : `[${pointers.join(",\n")}]`;
|
|
103
81
|
}
|
|
104
82
|
// The git section content: the working-tree summary. "" when absent.
|
|
105
83
|
static renderGit(git) {
|
|
106
84
|
const status = git === null || git === undefined ? "" : PacketWire.#renderGitState(git);
|
|
107
|
-
return status
|
|
85
|
+
return status.length === 0 ? "" : `> [!NOTE]\n${status.split("\n").map((line) => `> ${line}`).join("\n")}`;
|
|
108
86
|
}
|
|
109
87
|
// The log section's content: the model's curated rows as Markdown-framed records ({§log-wire-format}).
|
|
110
88
|
// Data only — no prose leads the records (the log carries rules for no one). Empty log → ""
|
|
@@ -117,12 +95,16 @@ export default class PacketWire {
|
|
|
117
95
|
static renderLogWithAccounting(entries, weighContent, options = {}) {
|
|
118
96
|
const log = Array.isArray(entries) ? entries : [];
|
|
119
97
|
if (log.length === 0)
|
|
120
|
-
return { content: "",
|
|
98
|
+
return { content: "", records: [], curationTargets: [], attachments: [], unadmittedOutput: [], newOverflow: false };
|
|
121
99
|
const rows = PacketWire.#renderLogEntries(log, weighContent, options);
|
|
100
|
+
const records = rows.map(({ content }) => content);
|
|
122
101
|
return {
|
|
123
|
-
content:
|
|
124
|
-
|
|
102
|
+
content: records.join("\n\n"),
|
|
103
|
+
records,
|
|
104
|
+
curationTargets: rows.flatMap(({ curationTarget }) => curationTarget === null ? [] : [curationTarget]),
|
|
125
105
|
attachments: rows.flatMap(({ attachment }) => attachment === null ? [] : [attachment]),
|
|
106
|
+
unadmittedOutput: rows.flatMap(({ unadmittedOutput }) => unadmittedOutput === null ? [] : [unadmittedOutput]),
|
|
107
|
+
newOverflow: rows.some(({ newOverflow }) => newOverflow),
|
|
126
108
|
};
|
|
127
109
|
}
|
|
128
110
|
// Read one section's content by name off a packet (Engine's or re-parsed).
|
|
@@ -144,7 +126,7 @@ export default class PacketWire {
|
|
|
144
126
|
}
|
|
145
127
|
// Number a non-READ body line as `<N>:<line>` — `N:` followed by NO separator whitespace
|
|
146
128
|
// ({§render-rule-line-navigable-prefix}): the leading digit prevents column-zero fence collisions and gives
|
|
147
|
-
// the model line refs for free (
|
|
129
|
+
// the model line refs for free (`READ (...) <42-46>`), while the absence of any separator means a
|
|
148
130
|
// reproduced line has nothing between `N:` and the content to copy — the hard-tab separator used
|
|
149
131
|
// to leak into edit bodies and corrupt indentation. The content's OWN leading whitespace is
|
|
150
132
|
// content, preserved verbatim. `N` is left-padded to the body's line-range width so every body
|
|
@@ -159,12 +141,15 @@ export default class PacketWire {
|
|
|
159
141
|
const prefix = () => `${String(line++).padStart(width, " ")}:`;
|
|
160
142
|
return `${prefix()}${body.replace(/(\r\n|\r(?!\n)|\n)(?=[\s\S])/g, (separator) => `${separator}${prefix()}`)}`;
|
|
161
143
|
}
|
|
162
|
-
static #numberSelectedLines(body, ordinals, startLine, lineAnchors, lineNumberWidth, numericLineNumberWidth) {
|
|
144
|
+
static #numberSelectedLines(body, ordinals, startLine, lineAnchors, lineNumberWidth, numericLineNumberWidth, sourceLineNumbers) {
|
|
163
145
|
const lines = TextCoordinates.logicalLines(body);
|
|
164
146
|
if (lines.length !== ordinals.length) {
|
|
165
147
|
throw new TypeError("A sparse log-body projection requires one source ordinal per rendered line.");
|
|
166
148
|
}
|
|
167
|
-
|
|
149
|
+
if (sourceLineNumbers !== null && ordinals.some((ordinal) => ordinal < 1 || ordinal > sourceLineNumbers.length)) {
|
|
150
|
+
throw new TypeError("A sparse log-body projection's ordinals must address its source line numbers.");
|
|
151
|
+
}
|
|
152
|
+
const displayed = ordinals.map((ordinal) => sourceLineNumbers === null ? startLine + ordinal - 1 : sourceLineNumbers[ordinal - 1]);
|
|
168
153
|
const width = lineAnchors === null
|
|
169
154
|
? numericLineNumberWidth > 0
|
|
170
155
|
? numericLineNumberWidth
|
|
@@ -192,14 +177,14 @@ export default class PacketWire {
|
|
|
192
177
|
// Exact READ content receives source-width-aligned `@hash N:`; other textual bodies receive `N:`.
|
|
193
178
|
// Matchers consume canonical content before this presentation projection.
|
|
194
179
|
// Empty content produces no body.
|
|
195
|
-
static #renderContentBody(content, startLine = 1, lineAnchors = null, lineNumberWidth = null, numericLineNumberWidth = 0, lineOrdinals = null) {
|
|
180
|
+
static #renderContentBody(content, startLine = 1, lineAnchors = null, lineNumberWidth = null, numericLineNumberWidth = 0, lineOrdinals = null, sourceLineNumbers = null) {
|
|
196
181
|
if (content.length === 0)
|
|
197
182
|
return "";
|
|
198
183
|
// `startLine === null` means the producer already supplied numbered
|
|
199
184
|
// content; re-numbering would duplicate its coordinates.
|
|
200
185
|
const rendered = startLine !== null
|
|
201
186
|
? lineOrdinals !== null
|
|
202
|
-
? PacketWire.#numberSelectedLines(content, lineOrdinals, startLine, lineAnchors, lineNumberWidth, numericLineNumberWidth)
|
|
187
|
+
? PacketWire.#numberSelectedLines(content, lineOrdinals, startLine, lineAnchors, lineNumberWidth, numericLineNumberWidth, sourceLineNumbers)
|
|
203
188
|
: lineAnchors === null
|
|
204
189
|
? PacketWire.#numberLines(content, startLine, numericLineNumberWidth)
|
|
205
190
|
: LineAnchors.render(content, startLine, lineAnchors, lineNumberWidth ?? 0)
|
|
@@ -216,19 +201,23 @@ export default class PacketWire {
|
|
|
216
201
|
return null;
|
|
217
202
|
}
|
|
218
203
|
}
|
|
219
|
-
//
|
|
220
|
-
// line across turns — prefix-cache friendly. The preceding H3 owns identity.
|
|
204
|
+
// {§log-wire-format} Orientation precedes telemetry on every receipt.
|
|
221
205
|
static #canonicalJson(obj) {
|
|
222
206
|
const keys = Object.keys(obj).sort();
|
|
223
207
|
const sorted = {};
|
|
208
|
+
for (const key of ["target", "aside"]) {
|
|
209
|
+
if (Object.hasOwn(obj, key))
|
|
210
|
+
sorted[key] = obj[key];
|
|
211
|
+
}
|
|
224
212
|
for (const k of keys)
|
|
225
213
|
sorted[k] = obj[k];
|
|
226
214
|
return JSON.stringify(sorted);
|
|
227
215
|
}
|
|
228
216
|
static #receiptMeta(value) {
|
|
229
217
|
const receipt = assertEditReceipt(value);
|
|
218
|
+
// The durable receipt keeps the full revision for forensics; the model gets no token it
|
|
219
|
+
// cannot use (operator, 2026-09-13: "ditch rev").
|
|
230
220
|
const head = {
|
|
231
|
-
rev: receipt.revision.slice(0, editReceiptRevisionChars()),
|
|
232
221
|
extent: `${receipt.unit} ${receipt.before}->${receipt.after}`,
|
|
233
222
|
...(receipt.parseIssues === undefined
|
|
234
223
|
? {}
|
|
@@ -287,41 +276,14 @@ export default class PacketWire {
|
|
|
287
276
|
throw new TypeError("A packet log row requires an addressable coordinate.");
|
|
288
277
|
return `log:///${coordinate}/${leaf}`;
|
|
289
278
|
}
|
|
290
|
-
static #offsetAfterCharacters(text, count) {
|
|
291
|
-
let offset = 0;
|
|
292
|
-
let consumed = 0;
|
|
293
|
-
while (offset < text.length && consumed < count) {
|
|
294
|
-
if (text.startsWith("\r\n", offset)) {
|
|
295
|
-
offset += 2;
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
const codePoint = text.codePointAt(offset);
|
|
299
|
-
if (codePoint === undefined)
|
|
300
|
-
break;
|
|
301
|
-
offset += String.fromCodePoint(codePoint).length;
|
|
302
|
-
}
|
|
303
|
-
consumed++;
|
|
304
|
-
}
|
|
305
|
-
return offset;
|
|
306
|
-
}
|
|
307
279
|
// One preview function for every bounded model-facing projection. Lines
|
|
308
280
|
// protect ordinary documents and Unicode characters protect a single-line
|
|
309
281
|
// bomb. Once a physical line is complete, a character cut retreats to that
|
|
310
282
|
// line boundary rather than exposing a partial coordinate prefix.
|
|
311
283
|
static #preview(text) {
|
|
312
|
-
const { lines: maxLines, chars: maxChars } = previewBounds();
|
|
313
284
|
const coordinates = new TextCoordinates(text);
|
|
314
285
|
const physicalLines = coordinates.logicalLines();
|
|
315
|
-
const
|
|
316
|
-
? physicalLines[maxLines - 1].end
|
|
317
|
-
: text.length;
|
|
318
|
-
const characterEnd = PacketWire.#offsetAfterCharacters(text, maxChars);
|
|
319
|
-
let end = Math.min(lineEnd, characterEnd);
|
|
320
|
-
if (characterEnd < text.length && characterEnd <= lineEnd) {
|
|
321
|
-
const completeLine = physicalLines.findLast((line) => line.separator.length > 0 && line.end <= characterEnd);
|
|
322
|
-
if (completeLine !== undefined)
|
|
323
|
-
end = completeLine.end;
|
|
324
|
-
}
|
|
286
|
+
const { end } = BodyPreview.select(text);
|
|
325
287
|
const cut = end < text.length;
|
|
326
288
|
return {
|
|
327
289
|
text: text.slice(0, end),
|
|
@@ -446,17 +408,22 @@ export default class PacketWire {
|
|
|
446
408
|
};
|
|
447
409
|
}
|
|
448
410
|
static #visibleBody(entry, body) {
|
|
449
|
-
const
|
|
411
|
+
const trimmed = LogVisibility.parse(entry.folded ?? LogVisibility.OPEN);
|
|
412
|
+
const folded = LogVisibility.combine(LogVisibility.parse(entry.initial_folded ?? LogVisibility.OPEN), trimmed);
|
|
450
413
|
const lines = TextCoordinates.logicalLines(body.content);
|
|
451
414
|
const totalLines = lines.length;
|
|
452
415
|
const clipped = LogVisibility.clipped(folded, totalLines);
|
|
453
416
|
const ordinals = LogVisibility.visibleLineOrdinals(clipped, totalLines);
|
|
417
|
+
const readableOrdinals = LogVisibility.visibleLineOrdinals(trimmed, totalLines);
|
|
418
|
+
const select = (selected) => selected.map((ordinal) => {
|
|
419
|
+
const line = lines[ordinal - 1];
|
|
420
|
+
return body.content.slice(line.start, line.end);
|
|
421
|
+
}).join("");
|
|
454
422
|
return {
|
|
455
|
-
content: ordinals
|
|
456
|
-
const line = lines[ordinal - 1];
|
|
457
|
-
return body.content.slice(line.start, line.end);
|
|
458
|
-
}).join(""),
|
|
423
|
+
content: select(ordinals),
|
|
459
424
|
ordinals,
|
|
425
|
+
readableContent: select(readableOrdinals),
|
|
426
|
+
readableOrdinals,
|
|
460
427
|
folded: clipped,
|
|
461
428
|
totalLines,
|
|
462
429
|
fullyFolded: LogVisibility.fullyFolded(clipped, totalLines),
|
|
@@ -518,315 +485,343 @@ export default class PacketWire {
|
|
|
518
485
|
}));
|
|
519
486
|
const promptProjectionWeights = PacketWire.#promptProjectionWeights(entries, visibleBodies, visibility, weighContent, options.promptProjectionWeight);
|
|
520
487
|
return entries.map((e, index) => {
|
|
521
|
-
const
|
|
522
|
-
const coordinate = typeof e.coordinate === "string" ? e.coordinate : null;
|
|
523
|
-
const op = typeof e.op === "string" && e.op.length > 0 ? e.op : null;
|
|
524
|
-
const renderedLeaf = LogEntryProjection.leaf(e);
|
|
525
|
-
const path = PacketWire.#entryPath(coordinate, renderedLeaf);
|
|
526
|
-
// Absence = "model" — the worker's own authorship is the default,
|
|
527
|
-
// exactly as `source` absence means the owning worker (#338).
|
|
528
|
-
if (typeof e.origin === "string" && e.origin !== "model")
|
|
529
|
-
meta.origin = e.origin;
|
|
530
|
-
// {§env-delta-attribution}: render the causal worker address or
|
|
531
|
-
// subsystem token when present; absence means the owning worker.
|
|
532
|
-
if (typeof e.source === "string" && e.source.length > 0)
|
|
533
|
-
meta.source = e.source;
|
|
534
|
-
if (e.source === "file" && e.attrs !== null && typeof e.attrs === "object" && "git" in e.attrs) {
|
|
535
|
-
const git = e.attrs.git;
|
|
536
|
-
if (typeof git !== "string" || git.length !== 2) {
|
|
537
|
-
throw new TypeError("A source=file log row carries malformed Git XY metadata.");
|
|
538
|
-
}
|
|
539
|
-
meta.git = git;
|
|
540
|
-
}
|
|
541
|
-
// Absence = 200 on an ordinary row — the clients' quiet grammar
|
|
542
|
-
// (plurnk#21) applied to the packet. SEND keeps its disposition,
|
|
543
|
-
// KILL keeps decisive destructive completion, a dissolving log-KILL
|
|
544
|
-
// receipt exists only to show its status ({§curation-receipt-dissolves}),
|
|
545
|
-
// and every non-200 stays explicit (#338).
|
|
546
|
-
if (typeof e.status === "number" && (op === "SEND" || op === "KILL" || e.status !== 200))
|
|
547
|
-
meta.status = e.status;
|
|
548
|
-
const tx = (typeof e.tx === "string" ? PacketWire.#safeParse(e.tx) : e.tx);
|
|
549
|
-
if (typeof tx?.annotation === "string")
|
|
550
|
-
meta.annotation = tx.annotation;
|
|
551
|
-
const target = PacketWire.#renderActionTarget(e.target);
|
|
552
|
-
// {§exec-stream}: a terminal stream observation's address is the stream it observed,
|
|
553
|
-
// rendered under `stream` like the invocation's own link — never a `target`, which
|
|
554
|
-
// the model would otherwise author into an EXEC slot (#425 F4).
|
|
555
|
-
const terminalStream = op === "READ"
|
|
556
|
-
&& e.attrs !== null
|
|
557
|
-
&& typeof e.attrs === "object"
|
|
558
|
-
&& e.attrs.terminal === true;
|
|
559
|
-
if (op === "COPY" || op === "MOVE") {
|
|
560
|
-
const source = PacketWire.#renderSelection(tx?.source?.target, tx?.source?.lineMarker);
|
|
561
|
-
const destination = PacketWire.#renderSelection(tx?.destination?.target, tx?.destination?.lineMarker);
|
|
562
|
-
if (source !== null)
|
|
563
|
-
meta.source = source;
|
|
564
|
-
if (destination !== null)
|
|
565
|
-
meta.destination = destination;
|
|
566
|
-
if (typeof e.status === "number"
|
|
567
|
-
&& e.status < 400
|
|
568
|
-
&& (source === null || destination === null)) {
|
|
569
|
-
throw new Error(`A successful ${op} log row must retain both operand selections.`);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
else if (target !== null) {
|
|
573
|
-
meta[terminalStream ? "stream" : "target"] = target;
|
|
574
|
-
}
|
|
575
|
-
// EXEC's output is a separate stream entry ({§exec-stream}); its address rides in a
|
|
576
|
-
// `stream` link, distinct from the runtime-owned invocation target.
|
|
577
|
-
// {§exec-target-routing} {§fs-namespace} — the receipt names the working directory only
|
|
578
|
-
// when it is not the project root, and then in the model's own project-relative form;
|
|
579
|
-
// the root is the default and a host-absolute path never reaches the packet.
|
|
580
|
-
if (op === "EXEC" && e.attrs !== null && typeof e.attrs === "object" && typeof e.attrs.cwd === "string") {
|
|
581
|
-
const cwd = PacketWire.#projectRelativeCwd(e.attrs.cwd, options.projectRoot ?? null);
|
|
582
|
-
if (cwd !== null)
|
|
583
|
-
meta.cwd = cwd;
|
|
584
|
-
}
|
|
585
|
-
if (op === "EXEC" && e.attrs !== null && typeof e.attrs === "object" && typeof e.attrs.stream === "string") {
|
|
586
|
-
meta.stream = e.attrs.stream;
|
|
587
|
-
}
|
|
488
|
+
const identity = PacketWire.#rowIdentity(e, options);
|
|
588
489
|
// Parse rx once — reused for the matcher/items enrichment and the body.
|
|
589
490
|
const rx = (typeof e.rx === "string" ? PacketWire.#safeParse(e.rx) : e.rx);
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
491
|
+
const facts = PacketWire.#rowResultFacts(identity, e, rx);
|
|
492
|
+
const projected = PacketWire.#rowBody(identity, e, bodies[index], visibility[index], facts, promptProjectionWeights.get(index), weighContent);
|
|
493
|
+
return PacketWire.#rowAccounting(identity, e, bodies[index], visibility[index], projected, weighContent, options);
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
// The row's identity and authored facts: who wrote it, what it addressed, and the statuses
|
|
497
|
+
// that stay explicit. `meta` is the metadata line under construction; each later stage adds
|
|
498
|
+
// to it, and {§log-wire-format}'s canonical JSON sorts the keys, so the order of stages never
|
|
499
|
+
// reaches the wire.
|
|
500
|
+
static #rowIdentity(e, options) {
|
|
501
|
+
const meta = {};
|
|
502
|
+
const coordinate = typeof e.coordinate === "string" ? e.coordinate : null;
|
|
503
|
+
const op = typeof e.op === "string" && e.op.length > 0 ? e.op : null;
|
|
504
|
+
const renderedLeaf = LogEntryProjection.leaf(e);
|
|
505
|
+
const path = PacketWire.#entryPath(coordinate, renderedLeaf);
|
|
506
|
+
// Absence = "model" — the worker's own authorship is the default,
|
|
507
|
+
// exactly as `source` absence means the owning worker (#338).
|
|
508
|
+
if (typeof e.origin === "string" && e.origin !== "model")
|
|
509
|
+
meta.origin = e.origin;
|
|
510
|
+
// {§env-delta-attribution}: render the causal worker address or
|
|
511
|
+
// subsystem token when present; absence means the owning worker.
|
|
512
|
+
if (typeof e.source === "string" && e.source.length > 0)
|
|
513
|
+
meta.source = e.source;
|
|
514
|
+
if (e.source === "file" && e.attrs !== null && typeof e.attrs === "object" && "git" in e.attrs) {
|
|
515
|
+
const git = e.attrs.git;
|
|
516
|
+
if (typeof git !== "string" || git.length !== 2) {
|
|
517
|
+
throw new TypeError("A source=file log row carries malformed Git XY metadata.");
|
|
518
|
+
}
|
|
519
|
+
meta.git = git;
|
|
520
|
+
}
|
|
521
|
+
// SEND, TASK, destructive KILL, and non-200 statuses stay explicit.
|
|
522
|
+
// Successful log-KILL rows never reach this projection
|
|
523
|
+
// ({§log-kill-meta-operation}).
|
|
524
|
+
if (typeof e.status === "number" && (op === "SEND" || op === "KILL" || typeof op === "string" && TurnDisposition.isOp(op) || e.status !== 200))
|
|
525
|
+
meta.status = e.status;
|
|
526
|
+
const tx = (typeof e.tx === "string" ? PacketWire.#safeParse(e.tx) : e.tx);
|
|
527
|
+
if (typeof tx?.aside === "string")
|
|
528
|
+
meta.aside = tx.aside;
|
|
529
|
+
const target = PacketWire.#renderActionTarget(e.target);
|
|
530
|
+
// {§exec-stream}: a terminal stream observation's address is the stream it observed,
|
|
531
|
+
// rendered under `stream` like the invocation's own link — never a `target`, which
|
|
532
|
+
// the model would otherwise author into an execution slot (#425 F4).
|
|
533
|
+
const terminalStream = op === "READ"
|
|
534
|
+
&& e.attrs !== null
|
|
535
|
+
&& typeof e.attrs === "object"
|
|
536
|
+
&& e.attrs.terminal === true;
|
|
537
|
+
if (op === "COPY" || op === "MOVE") {
|
|
538
|
+
const source = PacketWire.#renderSelection(tx?.source?.target, tx?.source?.lineMarker);
|
|
539
|
+
const destination = PacketWire.#renderSelection(tx?.destination?.target, tx?.destination?.lineMarker);
|
|
540
|
+
if (source !== null)
|
|
541
|
+
meta.source = source;
|
|
542
|
+
if (destination !== null)
|
|
543
|
+
meta.destination = destination;
|
|
544
|
+
if (typeof e.status === "number"
|
|
545
|
+
&& e.status < 400
|
|
546
|
+
&& (source === null || destination === null)) {
|
|
547
|
+
throw new Error(`A successful ${op} log row must retain both operand selections.`);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
else if (target !== null) {
|
|
551
|
+
meta[terminalStream ? "stream" : "target"] = target;
|
|
552
|
+
}
|
|
553
|
+
// {§worker-auto-name} The created identity is an outcome, not an authored target.
|
|
554
|
+
if ((op === "WORK" || op === "FORK") && e.attrs !== null && typeof e.attrs === "object"
|
|
555
|
+
&& typeof e.attrs.worker === "string") {
|
|
556
|
+
meta.worker = e.attrs.worker;
|
|
557
|
+
}
|
|
558
|
+
// An execution's output is a separate stream entry ({§exec-stream}); its address rides in a
|
|
559
|
+
// `stream` link, distinct from the runtime-owned invocation target.
|
|
560
|
+
// {§exec-target-routing} {§fs-namespace} — the receipt names the working directory only
|
|
561
|
+
// when it is not the project root, and then in the model's own project-relative form;
|
|
562
|
+
// the root is the default and a host-absolute path never reaches the packet.
|
|
563
|
+
if (isExecutionOp(op) && e.attrs !== null && typeof e.attrs === "object" && typeof e.attrs.cwd === "string") {
|
|
564
|
+
const cwd = PacketWire.#projectRelativeCwd(e.attrs.cwd, options.projectRoot ?? null);
|
|
565
|
+
if (cwd !== null)
|
|
566
|
+
meta.cwd = cwd;
|
|
567
|
+
}
|
|
568
|
+
if (isExecutionOp(op) && e.attrs !== null && typeof e.attrs === "object" && typeof e.attrs.stream === "string") {
|
|
569
|
+
meta.stream = e.attrs.stream;
|
|
570
|
+
}
|
|
571
|
+
return { meta, op, tx, coordinate, path, renderedLeaf, target, terminalStream };
|
|
572
|
+
}
|
|
573
|
+
// The row's result facts from its rx: the terminal stream's exit, the Problem or detail, the
|
|
574
|
+
// matcher, the retrieval extents, and the structured mutation receipts. Returns what the body
|
|
575
|
+
// projection needs to know about the result.
|
|
576
|
+
static #rowResultFacts(identity, e, rx) {
|
|
577
|
+
const { meta, op, tx, terminalStream } = identity;
|
|
578
|
+
// {§exec-stream}: a terminal stream observation is self-sufficient
|
|
579
|
+
// even when its selected channel is empty. Preserve exact producer
|
|
580
|
+
// facts; do not manufacture a prose completion summary.
|
|
581
|
+
if (terminalStream) {
|
|
582
|
+
meta.terminal = true;
|
|
583
|
+
if (rx !== null && typeof rx === "object" && Object.hasOwn(rx, "exitCode")) {
|
|
584
|
+
if (typeof rx.exitCode !== "number" || !Number.isSafeInteger(rx.exitCode)) {
|
|
585
|
+
throw new TypeError("A terminal stream result carries a malformed exitCode.");
|
|
600
586
|
}
|
|
587
|
+
meta.exitCode = rx.exitCode;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
// {§problem-projection} — the exact durable Problem remains the
|
|
591
|
+
// failure authority; the packet carries only facts not already
|
|
592
|
+
// owned by its enclosing row. Errors remains only an index.
|
|
593
|
+
if (typeof e.status === "number" && e.status >= 400 && rx !== null && typeof rx === "object") {
|
|
594
|
+
const problem = rx.problem;
|
|
595
|
+
Validator.assertProblemDetails(problem);
|
|
596
|
+
meta.problem = Problems.project(problem, {
|
|
597
|
+
status: e.status,
|
|
598
|
+
row: meta,
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
// The success-side sibling (#342): a sub-problem receipt may carry one
|
|
602
|
+
// terse `detail` (e.g. the EDIT 304) so situational teaching is paid
|
|
603
|
+
// only when the situation occurs, never in the hot path.
|
|
604
|
+
if (!Object.hasOwn(meta, "problem") && rx !== null && typeof rx === "object"
|
|
605
|
+
&& typeof rx.detail === "string"
|
|
606
|
+
&& rx.detail.length > 0) {
|
|
607
|
+
meta.detail = rx.detail;
|
|
608
|
+
}
|
|
609
|
+
// {§retrieval-packet-metadata}: one extent/coordinate owner plus
|
|
610
|
+
// only FIND aggregates that add information beyond that extent.
|
|
611
|
+
let findItems = null;
|
|
612
|
+
const patterned = tx !== null && tx !== undefined && typeof tx === "object" && tx.matcher !== null && typeof tx.matcher === "object" && typeof tx.matcher.raw === "string";
|
|
613
|
+
if (patterned) {
|
|
614
|
+
meta.matcher = tx.matcher.raw;
|
|
615
|
+
if (op !== "FIND" && rx !== null && typeof rx === "object" && typeof rx.matched === "number")
|
|
616
|
+
meta.matched = rx.matched;
|
|
617
|
+
}
|
|
618
|
+
// {§channel-selection-visibility} — a READ names the resource's other channels with their
|
|
619
|
+
// tokens, so the row itself shows the choice a FIND listing would.
|
|
620
|
+
if (op === "READ" && rx !== null && typeof rx === "object" && rx.channels !== null && typeof rx.channels === "object") {
|
|
621
|
+
meta.channels = rx.channels;
|
|
622
|
+
}
|
|
623
|
+
// {§send-response-receipt} — a reply's row names the prompts it answered.
|
|
624
|
+
if (op === "SEND" && rx !== null && typeof rx === "object" && Array.isArray(rx.recipients)) {
|
|
625
|
+
meta.recipients = rx.recipients;
|
|
626
|
+
}
|
|
627
|
+
if (op === "READ" || op === "FIND") {
|
|
628
|
+
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.content === "string") {
|
|
629
|
+
const parsed = PacketWire.#safeParse(rx.content);
|
|
630
|
+
if (Array.isArray(parsed))
|
|
631
|
+
findItems = parsed.length;
|
|
601
632
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
meta.problem
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
633
|
+
const range = rx !== null && typeof rx === "object" && rx.range !== undefined
|
|
634
|
+
? rx.range
|
|
635
|
+
: undefined;
|
|
636
|
+
const problemOwnsRange = typeof e.status === "number"
|
|
637
|
+
&& e.status >= 400
|
|
638
|
+
&& meta.problem !== null
|
|
639
|
+
&& typeof meta.problem === "object"
|
|
640
|
+
&& Object.hasOwn(meta.problem, "range");
|
|
641
|
+
if (problemOwnsRange) {
|
|
642
|
+
Validator.assertRangeExtent(meta.problem.range);
|
|
612
643
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
// only when the situation occurs, never in the hot path.
|
|
616
|
-
if (!Object.hasOwn(meta, "problem") && rx !== null && typeof rx === "object"
|
|
617
|
-
&& typeof rx.detail === "string"
|
|
618
|
-
&& rx.detail.length > 0) {
|
|
619
|
-
meta.detail = rx.detail;
|
|
644
|
+
if (range !== undefined && !problemOwnsRange) {
|
|
645
|
+
meta.range = Validator.assertRangeExtent(range);
|
|
620
646
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
let findItems = null;
|
|
624
|
-
if (op === "READ" || op === "FIND") {
|
|
625
|
-
const findMatcher = op === "FIND"
|
|
626
|
-
&& tx !== null
|
|
627
|
-
&& tx !== undefined
|
|
628
|
-
&& typeof tx === "object"
|
|
629
|
-
&& tx.body !== null
|
|
630
|
-
&& typeof tx.body === "object";
|
|
631
|
-
if (findMatcher) {
|
|
632
|
-
const body = tx?.body;
|
|
633
|
-
if (body !== null && typeof body === "object" && typeof body.raw === "string") {
|
|
634
|
-
meta.matcher = body.raw;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.content === "string") {
|
|
638
|
-
const parsed = PacketWire.#safeParse(rx.content);
|
|
639
|
-
if (Array.isArray(parsed))
|
|
640
|
-
findItems = parsed.length;
|
|
641
|
-
}
|
|
642
|
-
const range = rx !== null && typeof rx === "object" && rx.range !== undefined
|
|
643
|
-
? rx.range
|
|
644
|
-
: undefined;
|
|
645
|
-
const problemOwnsRange = typeof e.status === "number"
|
|
646
|
-
&& e.status >= 400
|
|
647
|
-
&& meta.problem !== null
|
|
648
|
-
&& typeof meta.problem === "object"
|
|
649
|
-
&& Object.hasOwn(meta.problem, "range");
|
|
650
|
-
if (problemOwnsRange) {
|
|
651
|
-
Validator.assertRangeExtent(meta.problem.range);
|
|
652
|
-
}
|
|
653
|
-
if (range !== undefined && !problemOwnsRange) {
|
|
654
|
-
meta.range = Validator.assertRangeExtent(range);
|
|
655
|
-
}
|
|
656
|
-
else if (op === "READ" && rx !== null && typeof rx === "object" && rx.region !== undefined) {
|
|
657
|
-
meta.region = Validator.assertTextRegion(rx.region);
|
|
658
|
-
}
|
|
659
|
-
// These are underlying selected-content weights, distinct from
|
|
660
|
-
// the emitted body's generic `tokens` measurement.
|
|
661
|
-
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.itemsWeightTotal === "number" && rx.itemsWeightTotal > 0) {
|
|
662
|
-
meta.itemsTokenTotal = rx.itemsWeightTotal;
|
|
663
|
-
}
|
|
664
|
-
if (op === "FIND"
|
|
665
|
-
&& rx !== null
|
|
666
|
-
&& typeof rx === "object"
|
|
667
|
-
&& typeof rx.returnedItemsWeightTotal === "number"
|
|
668
|
-
&& rx.returnedItemsWeightTotal > 0
|
|
669
|
-
&& rx.returnedItemsWeightTotal !== rx.itemsWeightTotal) {
|
|
670
|
-
meta.returnedItemsTokenTotal = rx.returnedItemsWeightTotal;
|
|
671
|
-
}
|
|
672
|
-
if (findMatcher
|
|
673
|
-
&& range !== null
|
|
674
|
-
&& typeof range === "object"
|
|
675
|
-
&& range.unit === "resource"
|
|
676
|
-
&& rx !== null
|
|
677
|
-
&& typeof rx === "object"
|
|
678
|
-
&& typeof rx.matchLocationCount === "number"
|
|
679
|
-
&& rx.matchLocationCount > 0) {
|
|
680
|
-
meta.matchLocationCount = rx.matchLocationCount;
|
|
681
|
-
}
|
|
647
|
+
else if (op === "READ" && rx !== null && typeof rx === "object" && rx.region !== undefined) {
|
|
648
|
+
meta.region = Validator.assertTextRegion(rx.region);
|
|
682
649
|
}
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
let structuredMutationReceipt = false;
|
|
688
|
-
if (op === "EDIT" && rx !== null && typeof rx === "object" && Object.hasOwn(rx, "receipt")) {
|
|
689
|
-
Object.assign(meta, PacketWire.#receiptMeta(rx.receipt));
|
|
690
|
-
structuredMutationReceipt = true;
|
|
650
|
+
// These are underlying selected-content weights, distinct from
|
|
651
|
+
// the emitted body's generic `tokens` measurement.
|
|
652
|
+
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.itemsWeightTotal === "number" && rx.itemsWeightTotal > 0) {
|
|
653
|
+
meta.itemsTokenTotal = rx.itemsWeightTotal;
|
|
691
654
|
}
|
|
692
|
-
if (
|
|
655
|
+
if (op === "FIND"
|
|
693
656
|
&& rx !== null
|
|
694
657
|
&& typeof rx === "object"
|
|
695
|
-
&&
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
action: effect.action,
|
|
700
|
-
...(effect.receipt === undefined
|
|
701
|
-
? {}
|
|
702
|
-
: PacketWire.#receiptMeta(effect.receipt)),
|
|
703
|
-
}));
|
|
704
|
-
structuredMutationReceipt = effects.some((effect) => effect.receipt !== undefined);
|
|
705
|
-
}
|
|
706
|
-
// The canonical full body is shared with log READ, log FIND,
|
|
707
|
-
// and search derivation. READ/FIND own selection bounds, PLAN is
|
|
708
|
-
// persistent working memory, and prompt rows share their packet
|
|
709
|
-
// allowance. Structured mutation receipts own their join bound;
|
|
710
|
-
// every remaining body uses the ordinary fixed preview.
|
|
711
|
-
const fullBody = bodies[index];
|
|
712
|
-
const bodyVisibility = visibility[index];
|
|
713
|
-
const projectedBody = bodyVisibility.fullyFolded
|
|
714
|
-
? fullBody
|
|
715
|
-
: { ...fullBody, content: bodyVisibility.content };
|
|
716
|
-
const emptyFind = op === "FIND" && e.status === 200 && findItems === 0;
|
|
717
|
-
const previewExempt = op === "READ"
|
|
718
|
-
|| op === "FIND"
|
|
719
|
-
|| op === "PLAN"
|
|
720
|
-
|| structuredMutationReceipt;
|
|
721
|
-
const lineAnchors = op === "READ" ? e.lineAnchors ?? null : null;
|
|
722
|
-
const lineNumberWidth = op === "READ" ? e.lineNumberWidth ?? null : null;
|
|
723
|
-
if (lineAnchors !== null) {
|
|
724
|
-
LineAnchors.assertProjection(fullBody.content, lineAnchors);
|
|
725
|
-
}
|
|
726
|
-
const findRange = op === "FIND" && meta.range !== null && typeof meta.range === "object"
|
|
727
|
-
? meta.range
|
|
728
|
-
: null;
|
|
729
|
-
const bodyStartLine = findRange?.returned?.[0] ?? fullBody.startLine;
|
|
730
|
-
const numericLineNumberWidth = findRange === null
|
|
731
|
-
? bodyStartLine === null || bodyVisibility.totalLines === 0
|
|
732
|
-
? 0
|
|
733
|
-
: String(bodyStartLine + bodyVisibility.totalLines - 1).length
|
|
734
|
-
: String(findRange.total).length;
|
|
735
|
-
const allOrdinals = Array.from({ length: bodyVisibility.totalLines }, (_, ordinal) => ordinal + 1);
|
|
736
|
-
const sourceOrdinals = bodyVisibility.fullyFolded
|
|
737
|
-
? allOrdinals
|
|
738
|
-
: bodyVisibility.ordinals;
|
|
739
|
-
const promptProjectionWeight = promptProjectionWeights.get(index);
|
|
740
|
-
const projection = promptProjectionWeight !== undefined
|
|
741
|
-
? PacketWire.#promptProjection(projectedBody, promptProjectionWeight, weighContent, (content) => PacketWire.#renderContentBody(content, bodyStartLine, null, null, numericLineNumberWidth, bodyStartLine === null
|
|
742
|
-
? null
|
|
743
|
-
: sourceOrdinals.slice(0, TextCoordinates.logicalLines(content).length)))
|
|
744
|
-
: previewExempt
|
|
745
|
-
? { text: projectedBody.content, cut: false, chunk: null }
|
|
746
|
-
: PacketWire.#preview(projectedBody.content);
|
|
747
|
-
const projectedLineCount = TextCoordinates.logicalLines(projection.text).length;
|
|
748
|
-
const projectedOrdinals = sourceOrdinals.slice(0, projectedLineCount);
|
|
749
|
-
const body = emptyFind || projection.text.length === 0
|
|
750
|
-
? ""
|
|
751
|
-
: PacketWire.#renderContentBody(projection.text, bodyStartLine, lineAnchors, lineNumberWidth, numericLineNumberWidth, bodyStartLine === null ? null : projectedOrdinals);
|
|
752
|
-
// {§packet-token-accounting} — tokensBody reports the projected body's weight even
|
|
753
|
-
// when that body is withheld. Active accounting happens only after every field and
|
|
754
|
-
// the final row framing are known below.
|
|
755
|
-
const renderedBodyWeight = body.length > 0 ? weighContent(body) : 0;
|
|
756
|
-
// Never tokensBody:0 — a zero-weight visible body is field absence, and
|
|
757
|
-
// tokensBody presence is what marks the folded state (#338).
|
|
758
|
-
if (fullBody.content.length > 0 && renderedBodyWeight > 0)
|
|
759
|
-
meta.tokensBody = renderedBodyWeight;
|
|
760
|
-
// lines beside tokens on a non-retrieval row with a navigable body — the count of
|
|
761
|
-
// `N:`-numbered lines (fences and unnumbered prose don't count), so the model can plan
|
|
762
|
-
// a <start,end> slice before paying for a READ. READ/FIND own typed extents instead.
|
|
763
|
-
if (fullBody.content.length > 0 && op !== "READ" && op !== "FIND") {
|
|
764
|
-
meta.lines = bodyVisibility.totalLines;
|
|
658
|
+
&& typeof rx.returnedItemsWeightTotal === "number"
|
|
659
|
+
&& rx.returnedItemsWeightTotal > 0
|
|
660
|
+
&& rx.returnedItemsWeightTotal !== rx.itemsWeightTotal) {
|
|
661
|
+
meta.returnedItemsTokenTotal = rx.returnedItemsWeightTotal;
|
|
765
662
|
}
|
|
766
|
-
if (
|
|
767
|
-
|
|
663
|
+
if (op === "FIND"
|
|
664
|
+
&& patterned
|
|
665
|
+
&& range !== null
|
|
666
|
+
&& typeof range === "object"
|
|
667
|
+
&& range.unit === "resource"
|
|
668
|
+
&& rx !== null
|
|
669
|
+
&& typeof rx === "object"
|
|
670
|
+
&& typeof rx.matchLocationCount === "number"
|
|
671
|
+
&& rx.matchLocationCount > 0) {
|
|
672
|
+
meta.matchLocationCount = rx.matchLocationCount;
|
|
768
673
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
674
|
+
}
|
|
675
|
+
// {§edit-result-receipt-projection} {§edit-result-copy-move-effects}
|
|
676
|
+
// EDIT/scoped entry KILL own one receipt; COPY/MOVE own resource effects whose
|
|
677
|
+
// optional receipts describe scoped textual materializations.
|
|
678
|
+
let structuredMutationReceipt = false;
|
|
679
|
+
if ((op === "EDIT" || op === "KILL") && rx !== null && typeof rx === "object" && Object.hasOwn(rx, "receipt")) {
|
|
680
|
+
Object.assign(meta, PacketWire.#receiptMeta(rx.receipt));
|
|
681
|
+
structuredMutationReceipt = true;
|
|
682
|
+
}
|
|
683
|
+
if ((op === "COPY" || op === "MOVE")
|
|
684
|
+
&& rx !== null
|
|
685
|
+
&& typeof rx === "object"
|
|
686
|
+
&& Object.hasOwn(rx, "effects")) {
|
|
687
|
+
const effects = assertResourceEffects(rx.effects);
|
|
688
|
+
meta.effects = effects.map((effect) => ({
|
|
689
|
+
target: effect.target,
|
|
690
|
+
action: effect.action,
|
|
691
|
+
...(effect.receipt === undefined
|
|
692
|
+
? {}
|
|
693
|
+
: PacketWire.#receiptMeta(effect.receipt)),
|
|
694
|
+
}));
|
|
695
|
+
structuredMutationReceipt = effects.some((effect) => effect.receipt !== undefined);
|
|
696
|
+
}
|
|
697
|
+
return { findItems, structuredMutationReceipt };
|
|
698
|
+
}
|
|
699
|
+
// The body the row shows: the canonical full body is shared with log READ, log FIND, and
|
|
700
|
+
// search derivation. READ/FIND own selection bounds, TASK and admitted programs remain
|
|
701
|
+
// complete, and prompt rows share their packet allowance. Structured mutation receipts own
|
|
702
|
+
// their join bound; every remaining body uses the ordinary fixed preview.
|
|
703
|
+
static #rowBody(identity, e, fullBody, bodyVisibility, facts, promptProjectionWeight, weighContent) {
|
|
704
|
+
const { meta, op, renderedLeaf } = identity;
|
|
705
|
+
const projectedBody = {
|
|
706
|
+
...fullBody,
|
|
707
|
+
content: bodyVisibility.fullyFolded ? bodyVisibility.readableContent : bodyVisibility.content,
|
|
708
|
+
};
|
|
709
|
+
const emptyFind = op === "FIND" && e.status === 200 && facts.findItems === 0;
|
|
710
|
+
const previewExempt = op === "READ"
|
|
711
|
+
|| op === "FIND"
|
|
712
|
+
|| op === "TASK"
|
|
713
|
+
|| (op === null && renderedLeaf === "ops")
|
|
714
|
+
|| facts.structuredMutationReceipt;
|
|
715
|
+
const lineAnchors = op === "READ" ? e.lineAnchors ?? null : null;
|
|
716
|
+
const lineNumberWidth = op === "READ" ? e.lineNumberWidth ?? null : null;
|
|
717
|
+
if (lineAnchors !== null) {
|
|
718
|
+
LineAnchors.assertProjection(fullBody.content, lineAnchors);
|
|
719
|
+
}
|
|
720
|
+
const findRange = op === "FIND" && meta.range !== null && typeof meta.range === "object"
|
|
721
|
+
? meta.range
|
|
722
|
+
: null;
|
|
723
|
+
const bodyStartLine = findRange?.returned?.[0] ?? fullBody.startLine;
|
|
724
|
+
const numericLineNumberWidth = findRange === null
|
|
725
|
+
? bodyStartLine === null || bodyVisibility.totalLines === 0
|
|
726
|
+
? 0
|
|
727
|
+
: String(fullBody.lineOrdinals?.at(-1) ?? bodyStartLine + bodyVisibility.totalLines - 1).length
|
|
728
|
+
: String(findRange.total).length;
|
|
729
|
+
const sourceOrdinals = bodyVisibility.fullyFolded
|
|
730
|
+
? bodyVisibility.readableOrdinals
|
|
731
|
+
: bodyVisibility.ordinals;
|
|
732
|
+
const projection = promptProjectionWeight !== undefined
|
|
733
|
+
? PacketWire.#promptProjection(projectedBody, promptProjectionWeight, weighContent, (content) => PacketWire.#renderContentBody(content, bodyStartLine, null, null, numericLineNumberWidth, bodyStartLine === null
|
|
734
|
+
? null
|
|
735
|
+
: sourceOrdinals.slice(0, TextCoordinates.logicalLines(content).length)))
|
|
736
|
+
: previewExempt
|
|
737
|
+
? { text: projectedBody.content, cut: false, chunk: null }
|
|
738
|
+
: PacketWire.#preview(projectedBody.content);
|
|
739
|
+
const projectedLineCount = TextCoordinates.logicalLines(projection.text).length;
|
|
740
|
+
const projectedOrdinals = sourceOrdinals.slice(0, projectedLineCount);
|
|
741
|
+
const body = emptyFind || projection.text.length === 0
|
|
742
|
+
? ""
|
|
743
|
+
: PacketWire.#renderContentBody(projection.text, bodyStartLine, lineAnchors, lineNumberWidth, numericLineNumberWidth, bodyStartLine === null ? null : projectedOrdinals, fullBody.lineOrdinals ?? null);
|
|
744
|
+
// lines beside tokens on a non-retrieval row with a navigable body — the count of
|
|
745
|
+
// `N:`-numbered lines (fences and unnumbered prose don't count), so the model can plan
|
|
746
|
+
// a <start,end> slice before paying for a READ. READ/FIND own typed extents instead.
|
|
747
|
+
if (fullBody.content.length > 0 && op !== "READ" && op !== "FIND") {
|
|
748
|
+
meta.lines = bodyVisibility.totalLines;
|
|
749
|
+
}
|
|
750
|
+
if (bodyVisibility.folded.length > 0 && !bodyVisibility.fullyFolded) {
|
|
751
|
+
meta.folded = LogVisibility.format(bodyVisibility.folded);
|
|
752
|
+
}
|
|
753
|
+
const display = bodyVisibility.readableContent.length === 0
|
|
754
|
+
? "none"
|
|
755
|
+
: bodyVisibility.fullyFolded || e.output_withheld === true
|
|
756
|
+
? "folded"
|
|
757
|
+
: body.length === 0
|
|
758
|
+
? "none"
|
|
759
|
+
: "open";
|
|
760
|
+
const projectedChunk = projection.chunk !== null
|
|
761
|
+
&& bodyVisibility.folded.length > 0
|
|
762
|
+
&& !bodyVisibility.fullyFolded
|
|
763
|
+
? PacketWire.#sparseChunk(fullBody.content, projectedBody.content, sourceOrdinals, projection.text)
|
|
764
|
+
: projection.chunk;
|
|
765
|
+
if (display === "open" && projectedChunk !== null)
|
|
766
|
+
meta.chunk = projectedChunk;
|
|
767
|
+
return { body, projectedLineCount, display };
|
|
768
|
+
}
|
|
769
|
+
// The row's native attachment, its withholding receipt, and the accounting field that
|
|
770
|
+
// participates in the row it measures: iterate until its decimal width and therefore the
|
|
771
|
+
// rendered row's curation weight are stable. {§packet-token-accounting}
|
|
772
|
+
static #rowAccounting(identity, e, fullBody, bodyVisibility, projected, weighContent, options) {
|
|
773
|
+
const { meta, op, coordinate, path, target } = identity;
|
|
774
|
+
const { body, projectedLineCount, display } = projected;
|
|
775
|
+
const nativeCandidate = op === "READ" && typeof e.status === "number" && e.status >= 200 && e.status < 300
|
|
776
|
+
? PacketWire.#attachmentOf(e.rx, e.target, coordinate, target) : null;
|
|
777
|
+
const native = nativeCandidate !== null && (options.acceptedAttachmentKinds?.has(nativeCandidate.kind) ?? true)
|
|
778
|
+
? nativeCandidate : null;
|
|
779
|
+
const outputWithheld = e.output_withheld === true
|
|
780
|
+
&& ((!bodyVisibility.fullyFolded && body.length > 0) || native !== null);
|
|
781
|
+
if (outputWithheld) {
|
|
782
|
+
const omitted = body.length > 0
|
|
783
|
+
? `${projectedLineCount} output lines${native === null ? "" : " and native content"}`
|
|
784
|
+
: "native content";
|
|
785
|
+
meta.overflow = `${omitted} not shown; the log exceeded logTokensMax when this row was withheld`;
|
|
786
|
+
}
|
|
787
|
+
const renderRow = () => {
|
|
788
|
+
const metadata = PacketWire.#canonicalJson(meta);
|
|
789
|
+
return display === "open"
|
|
790
|
+
? `### ${path}\n${metadata}\n${body}`
|
|
791
|
+
: `### ${path}\n${metadata}`;
|
|
792
|
+
};
|
|
793
|
+
// {§packet-attachment-parts}: retained native content shares the row's curation lifetime.
|
|
794
|
+
const attachment = e.output_withheld !== true
|
|
795
|
+
&& !(bodyVisibility.totalLines > 0 && bodyVisibility.fullyFolded)
|
|
796
|
+
? native
|
|
797
|
+
: null;
|
|
798
|
+
if (attachment !== null)
|
|
799
|
+
meta.tokensAttachment = attachment.weight;
|
|
800
|
+
meta.logTokens = 0;
|
|
801
|
+
for (let pass = 0; pass < 8; pass += 1) {
|
|
802
|
+
const logTokens = weighContent(renderRow()) + (attachment?.weight ?? 0);
|
|
803
|
+
if (meta.logTokens === logTokens) {
|
|
804
|
+
return {
|
|
805
|
+
content: renderRow(),
|
|
806
|
+
curationTarget: { path, logTokens },
|
|
807
|
+
attachment,
|
|
808
|
+
unadmittedOutput: (display === "open" || attachment !== null)
|
|
809
|
+
&& fullBody.provenance === "returned"
|
|
810
|
+
&& e.output_admission_turn_id == null
|
|
811
|
+
&& typeof e.id === "number"
|
|
812
|
+
? e.id : null,
|
|
813
|
+
newOverflow: outputWithheld && e.newOverflow === true,
|
|
814
|
+
};
|
|
824
815
|
}
|
|
825
|
-
|
|
826
|
-
}
|
|
816
|
+
meta.logTokens = logTokens;
|
|
817
|
+
}
|
|
818
|
+
throw new Error("packet log row accounting did not converge");
|
|
827
819
|
}
|
|
828
820
|
static #attachmentOf(rx, target, coordinate, path) {
|
|
829
821
|
const view = rx;
|
|
822
|
+
const contentHash = rx?.nativeContentHash;
|
|
823
|
+
if (typeof contentHash !== "string")
|
|
824
|
+
return null;
|
|
830
825
|
const pathname = typeof target?.pathname === "string" && target.pathname.length > 0
|
|
831
826
|
? target.pathname
|
|
832
827
|
: typeof target?.raw === "string" ? target.raw : null;
|
|
@@ -837,17 +832,21 @@ export default class PacketWire {
|
|
|
837
832
|
if (image !== undefined && typeof image.mimetype === "string" && Number.isSafeInteger(image.width) && Number.isSafeInteger(image.height)) {
|
|
838
833
|
const width = image.width;
|
|
839
834
|
const height = image.height;
|
|
840
|
-
return { coordinate, path, scheme, pathname, mimetype: image.mimetype, kind: "image", width, height, weight: imageWeight(width, height) };
|
|
835
|
+
return { contentHash, coordinate, path, scheme, pathname, mimetype: image.mimetype, kind: "image", width, height, weight: imageWeight(width, height) };
|
|
841
836
|
}
|
|
842
837
|
const document = view?.document;
|
|
843
|
-
if (document !== undefined && typeof document.mimetype === "string" && Number.isSafeInteger(document.
|
|
844
|
-
const pages = document.pages;
|
|
845
|
-
return {
|
|
838
|
+
if (document !== undefined && typeof document.mimetype === "string" && Number.isSafeInteger(document.bytes)) {
|
|
839
|
+
const pages = Number.isSafeInteger(document.pages) ? document.pages : null;
|
|
840
|
+
return {
|
|
841
|
+
contentHash, coordinate, path, scheme, pathname, mimetype: document.mimetype, kind: "pdf",
|
|
842
|
+
...(pages === null ? {} : { pages }),
|
|
843
|
+
weight: pdfWeight(pages, document.bytes),
|
|
844
|
+
};
|
|
846
845
|
}
|
|
847
846
|
return null;
|
|
848
847
|
}
|
|
849
848
|
// {§packet-attachment-parts} — the wire form with native parts: user text first, then each accepted
|
|
850
|
-
//
|
|
849
|
+
// retained native part in observation order.
|
|
851
850
|
static async wireMessages(packet, bytesOf, accepts = () => true) {
|
|
852
851
|
const [system, user] = PacketWire.packetToWireMessages(packet);
|
|
853
852
|
const parts = [{ type: "text", text: user.content }];
|
|
@@ -855,13 +854,7 @@ export default class PacketWire {
|
|
|
855
854
|
if (!accepts(attachment.kind))
|
|
856
855
|
continue;
|
|
857
856
|
const bytes = await bytesOf(attachment);
|
|
858
|
-
if (bytes === null)
|
|
859
|
-
continue;
|
|
860
857
|
parts.push({ type: "file", data: bytes, mediaType: attachment.mimetype });
|
|
861
|
-
parts.push({
|
|
862
|
-
type: "text",
|
|
863
|
-
text: `${attachment.path} has been ejected from context. It must be READ again to retain it in context.`,
|
|
864
|
-
});
|
|
865
858
|
}
|
|
866
859
|
return parts.length === 1 ? [system, user] : [system, { role: "user", content: parts }];
|
|
867
860
|
}
|