@plurnk/plurnk-service 1.17.0 → 1.19.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 +95 -14
- package/README.md +5 -3
- package/SPEC.md +1756 -1442
- package/dist/Paths.js +3 -3
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts +1 -0
- package/dist/content/body-preview.d.ts.map +1 -1
- package/dist/content/body-preview.js +8 -10
- package/dist/content/body-preview.js.map +1 -1
- package/dist/content/edit-receipt.d.ts.map +1 -1
- package/dist/content/edit-receipt.js +30 -29
- package/dist/content/edit-receipt.js.map +1 -1
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +17 -5
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/read-projector.d.ts +2 -2
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +81 -39
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/read-resolve.d.ts +1 -0
- package/dist/content/read-resolve.d.ts.map +1 -1
- package/dist/content/read-resolve.js +13 -10
- package/dist/content/read-resolve.js.map +1 -1
- package/dist/content/scope-format.d.ts +9 -0
- package/dist/content/scope-format.d.ts.map +1 -0
- package/dist/content/scope-format.js +28 -0
- package/dist/content/scope-format.js.map +1 -0
- package/dist/core/AdministrativeLoop.d.ts +8 -0
- package/dist/core/AdministrativeLoop.d.ts.map +1 -0
- package/dist/core/AdministrativeLoop.js +16 -0
- package/dist/core/AdministrativeLoop.js.map +1 -0
- package/dist/core/AdmittedTurnExecutor.d.ts +2 -2
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +26 -26
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +1 -2
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js +7 -12
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +3 -4
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +4 -2
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +23 -2
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +2 -2
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +46 -36
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +4 -6
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +8 -8
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +17 -11
- package/dist/core/ClientInteractions.d.ts +11 -1
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +26 -2
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +1 -0
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.d.ts.map +1 -1
- package/dist/core/DataStatementRunner.js +198 -148
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +18 -5
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +135 -114
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +11 -26
- package/dist/core/DurableStatement.d.ts +4 -1
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +4 -4
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/EditMutations.d.ts.map +1 -1
- package/dist/core/EditMutations.js +5 -2
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/Engine.d.ts +11 -9
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +27 -65
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +2 -22
- package/dist/core/EnvFlags.d.ts.map +1 -1
- package/dist/core/EnvFlags.js +4 -2
- package/dist/core/EnvFlags.js.map +1 -1
- package/dist/core/ExecutionOutputs.sql +8 -0
- package/dist/core/ExecutorRegistry.d.ts +4 -0
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +3 -1
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +7 -12
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/Knob.d.ts +9 -0
- package/dist/core/Knob.d.ts.map +1 -0
- package/dist/core/Knob.js +50 -0
- package/dist/core/Knob.js.map +1 -0
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +8 -36
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +8 -10
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +2 -1
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LogWriter.d.ts.map +1 -1
- package/dist/core/LogWriter.js +11 -9
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LoopDriver.d.ts +1 -1
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +24 -32
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopLifecycle.d.ts +4 -17
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +20 -22
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +36 -49
- package/dist/core/LoopOutcome.d.ts +10 -0
- package/dist/core/LoopOutcome.d.ts.map +1 -0
- package/dist/core/LoopOutcome.js +28 -0
- package/dist/core/LoopOutcome.js.map +1 -0
- package/dist/core/LoopPolicies.d.ts +7 -0
- package/dist/core/LoopPolicies.d.ts.map +1 -0
- package/dist/core/LoopPolicies.js +37 -0
- package/dist/core/LoopPolicies.js.map +1 -0
- package/dist/core/MessageResources.d.ts +15 -0
- package/dist/core/MessageResources.d.ts.map +1 -0
- package/dist/core/MessageResources.js +46 -0
- package/dist/core/MessageResources.js.map +1 -0
- package/dist/core/MessageResources.sql +36 -0
- package/dist/core/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 +7 -36
- package/dist/core/OperatorConfig.d.ts +2 -1
- package/dist/core/OperatorConfig.d.ts.map +1 -1
- package/dist/core/OperatorConfig.js +14 -6
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +20 -35
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +24 -6
- package/dist/core/PatternSelection.d.ts +1 -1
- package/dist/core/PatternSelection.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.d.ts +3 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +93 -28
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProviderInstantiate.d.ts +1 -0
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +12 -7
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReasoningView.d.ts +1 -2
- package/dist/core/ReasoningView.d.ts.map +1 -1
- package/dist/core/ReasoningView.js +9 -20
- package/dist/core/ReasoningView.js.map +1 -1
- package/dist/core/ResourceBindings.d.ts.map +1 -1
- package/dist/core/ResourceBindings.js +5 -4
- package/dist/core/ResourceBindings.js.map +1 -1
- package/dist/core/ResourceMutations.d.ts +4 -4
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +2 -3
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.d.ts +10 -3
- package/dist/core/ResourceSelector.d.ts.map +1 -1
- package/dist/core/ResourceSelector.js +52 -13
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.d.ts.map +1 -1
- package/dist/core/ResourceTransfers.js +4 -2
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/RuntimeWorker.d.ts.map +1 -1
- package/dist/core/RuntimeWorker.js +6 -1
- package/dist/core/RuntimeWorker.js.map +1 -1
- package/dist/core/RuntimeWorker.sql +7 -1
- package/dist/core/SchemeRegistry.d.ts +2 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +12 -6
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StoredPacket.d.ts +3 -1
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +7 -3
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts +2 -2
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +15 -7
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/TerminalResult.d.ts +2 -2
- package/dist/core/TerminalResult.d.ts.map +1 -1
- package/dist/core/TerminalResult.js +15 -8
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/ToolInputSchema.d.ts.map +1 -1
- package/dist/core/ToolInputSchema.js +24 -8
- package/dist/core/ToolInputSchema.js.map +1 -1
- package/dist/core/ToolResources.d.ts +1 -0
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +50 -26
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.d.ts +3 -1
- package/dist/core/Turn.d.ts.map +1 -1
- package/dist/core/Turn.js +4 -1
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/Turn.sql +14 -2
- package/dist/core/TurnDispositionHandler.d.ts +13 -23
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +30 -180
- package/dist/core/TurnDispositionHandler.js.map +1 -1
- package/dist/core/TurnMaterialization.d.ts +9 -7
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +66 -46
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +23 -6
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +2 -2
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +2 -8
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +1116 -1123
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnRunner.sql +1 -24
- package/dist/core/TurnSources.sql +42 -11
- package/dist/core/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +23 -0
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +3 -6
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +10 -26
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkspaceGate.js +4 -4
- package/dist/core/WorkspaceGate.js.map +1 -1
- package/dist/core/ambient.sql +45 -19
- package/dist/core/attachments.d.ts +3 -1
- package/dist/core/attachments.d.ts.map +1 -1
- package/dist/core/attachments.js +4 -0
- package/dist/core/attachments.js.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.js +4 -2
- package/dist/core/caps/CoreInteractionCaps.js.map +1 -1
- package/dist/core/caps/DbChannelCaps.js +6 -6
- package/dist/core/caps/DbChannelCaps.js.map +1 -1
- package/dist/core/caps/DbEntryCaps.js +1 -1
- package/dist/core/caps/DbEntryCaps.js.map +1 -1
- package/dist/core/caps/DbMessageCaps.d.ts +10 -0
- package/dist/core/caps/DbMessageCaps.d.ts.map +1 -0
- package/dist/core/caps/DbMessageCaps.js +39 -0
- package/dist/core/caps/DbMessageCaps.js.map +1 -0
- package/dist/core/caps/DbProjectionCaps.d.ts +2 -2
- package/dist/core/caps/DbProjectionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +10 -4
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +3 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +11 -0
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/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/file-materialization.js +1 -1
- package/dist/core/file-materialization.js.map +1 -1
- package/dist/core/fork.sql +7 -6
- package/dist/core/git-state.d.ts +3 -2
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +38 -21
- package/dist/core/git-state.js.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.js +1 -1
- package/dist/core/packet-wire.d.ts +11 -0
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +382 -333
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +4 -5
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +10 -31
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/scheme-types.d.ts +3 -1
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/teaching.d.ts.map +1 -1
- package/dist/core/teaching.js +2 -1
- package/dist/core/teaching.js.map +1 -1
- package/dist/core/types.d.ts +1 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-ops.sql +3 -8
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +37 -30
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +2 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +97 -9
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/DigestRequiem.d.ts.map +1 -1
- package/dist/digest/DigestRequiem.js +13 -15
- package/dist/digest/DigestRequiem.js.map +1 -1
- package/dist/digest/digest-db.d.ts +3 -0
- package/dist/digest/digest-db.d.ts.map +1 -0
- package/dist/digest/digest-db.js +68 -0
- package/dist/digest/digest-db.js.map +1 -0
- package/dist/digest/digest-paths.d.ts +6 -0
- package/dist/digest/digest-paths.d.ts.map +1 -0
- package/dist/digest/digest-paths.js +23 -0
- package/dist/digest/digest-paths.js.map +1 -0
- package/dist/digest/digest-rows.d.ts +21 -0
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +24 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/observe/genai.d.ts +2 -2
- package/dist/observe/genai.d.ts.map +1 -1
- package/dist/observe/genai.js +15 -5
- package/dist/observe/genai.js.map +1 -1
- package/dist/schemes/EffectPolicy.d.ts +0 -2
- package/dist/schemes/EffectPolicy.d.ts.map +1 -1
- package/dist/schemes/EffectPolicy.js +25 -36
- package/dist/schemes/EffectPolicy.js.map +1 -1
- package/dist/schemes/Exec.d.ts +4 -5
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +129 -82
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +6 -5
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +49 -16
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/ExecScheduler.js +2 -2
- package/dist/schemes/ExecScheduler.js.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +30 -21
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts +4 -4
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +30 -10
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +15 -2
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/TurnSource.d.ts +3 -2
- package/dist/schemes/TurnSource.d.ts.map +1 -1
- package/dist/schemes/TurnSource.js +87 -41
- package/dist/schemes/TurnSource.js.map +1 -1
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +22 -56
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.js +6 -6
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +37 -17
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +6 -5
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-fts.d.ts.map +1 -1
- package/dist/schemes/_entry-fts.js +6 -3
- package/dist/schemes/_entry-fts.js.map +1 -1
- package/dist/schemes/_entry-fts.sql +25 -6
- package/dist/schemes/_entry-manifest.d.ts +1 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +10 -17
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-manifest.sql +1 -1
- package/dist/schemes/_entry-ops.js +4 -4
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +2 -2
- package/dist/schemes/_entry-readable.d.ts.map +1 -1
- package/dist/schemes/_entry-readable.js +5 -4
- package/dist/schemes/_entry-readable.js.map +1 -1
- package/dist/schemes/_entry-send.js +2 -2
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/schemes/_search-exclusion.d.ts +1 -0
- package/dist/schemes/_search-exclusion.d.ts.map +1 -1
- package/dist/schemes/_search-exclusion.js +12 -0
- package/dist/schemes/_search-exclusion.js.map +1 -1
- package/dist/schemes/_search-index.d.ts +5 -1
- package/dist/schemes/_search-index.d.ts.map +1 -1
- package/dist/schemes/_search-index.js +99 -59
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/_search-index.sql +17 -0
- package/dist/schemes/exec-abort.d.ts.map +1 -1
- package/dist/schemes/exec-abort.js +5 -4
- 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-lifetime.d.ts +11 -0
- package/dist/schemes/exec-lifetime.d.ts.map +1 -0
- package/dist/schemes/exec-lifetime.js +29 -0
- package/dist/schemes/exec-lifetime.js.map +1 -0
- package/dist/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.map +1 -1
- package/dist/server/ClientReads.js +5 -2
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +31 -7
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +137 -60
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +25 -6
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +13 -11
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +87 -98
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts +52 -0
- package/dist/server/EnvFunctionality.d.ts.map +1 -0
- package/dist/server/EnvFunctionality.js +199 -0
- package/dist/server/EnvFunctionality.js.map +1 -0
- package/dist/server/Functionality.d.ts +4 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +250 -106
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +5 -1
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +24 -8
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/HttpListener.d.ts +16 -0
- package/dist/server/HttpListener.d.ts.map +1 -0
- package/dist/server/HttpListener.js +81 -0
- package/dist/server/HttpListener.js.map +1 -0
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +12 -17
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/PlurnkSkill.d.ts.map +1 -1
- package/dist/server/PlurnkSkill.js +1 -0
- package/dist/server/PlurnkSkill.js.map +1 -1
- package/dist/server/Retention.d.ts +14 -0
- package/dist/server/Retention.d.ts.map +1 -1
- package/dist/server/Retention.js +52 -4
- package/dist/server/Retention.js.map +1 -1
- package/dist/server/Retention.sql +55 -1
- package/dist/server/ServiceModules.d.ts.map +1 -1
- package/dist/server/ServiceModules.js +2 -0
- package/dist/server/ServiceModules.js.map +1 -1
- package/dist/server/SkillsFunctionality.d.ts +2 -0
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +27 -17
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
- package/dist/server/WorkspaceCapabilities.js +1 -0
- package/dist/server/WorkspaceCapabilities.js.map +1 -1
- package/dist/server/WorkspaceResidency.d.ts +2 -0
- package/dist/server/WorkspaceResidency.d.ts.map +1 -1
- package/dist/server/WorkspaceResidency.js +27 -0
- package/dist/server/WorkspaceResidency.js.map +1 -1
- package/dist/server/WorkspaceStorage.d.ts +8 -0
- package/dist/server/WorkspaceStorage.d.ts.map +1 -0
- package/dist/server/WorkspaceStorage.js +26 -0
- package/dist/server/WorkspaceStorage.js.map +1 -0
- package/dist/server/client-input.d.ts +4 -3
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +25 -27
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +2 -2
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +69 -132
- package/dist/server/envelope.d.ts +2 -3
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +7 -21
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +10 -6
- package/dist/server/exec-poll-backoff.js +3 -3
- package/dist/server/exec-poll-backoff.js.map +1 -1
- package/dist/server/lifecycle-recovery.sql +12 -38
- package/dist/server/logEntry.sql +2 -2
- package/dist/server/loopDocs.js +3 -3
- package/dist/server/loopDocs.sql +4 -2
- package/dist/server/model-catalog.d.ts.map +1 -1
- package/dist/server/model-catalog.js +2 -2
- package/dist/server/model-catalog.js.map +1 -1
- package/dist/server/seam-loop.sql +0 -1
- package/dist/server/workspace-capabilities.sql +45 -0
- package/dist/server/workspace-storage.sql +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +37 -11
- package/dist/service.js.map +1 -1
- package/docs/copy-move.md +31 -0
- package/docs/env.md +67 -0
- package/docs/members.md +4 -4
- package/docs/skills.md +2 -2
- package/migrations/002_workers.sql +41 -17
- package/migrations/003_loops.sql +82 -28
- package/migrations/004_inference.sql +53 -12
- package/migrations/005_entries.sql +135 -14
- package/migrations/006_log.sql +79 -24
- package/migrations/007_subscriptions.sql +10 -15
- package/package.json +45 -36
- package/dist/core/PromptFrames.d.ts +0 -12
- package/dist/core/PromptFrames.d.ts.map +0 -1
- package/dist/core/PromptFrames.js +0 -28
- package/dist/core/PromptFrames.js.map +0 -1
- package/dist/schemes/Prompt.d.ts +0 -8
- package/dist/schemes/Prompt.d.ts.map +0 -1
- package/dist/schemes/Prompt.js +0 -25
- package/dist/schemes/Prompt.js.map +0 -1
package/dist/core/packet-wire.js
CHANGED
|
@@ -3,13 +3,16 @@ import { relative, sep } from "node:path";
|
|
|
3
3
|
import { Problems, Validator } from "@plurnk/plurnk-contracts";
|
|
4
4
|
import { TextCoordinates } from "@plurnk/plurnk-mimetypes";
|
|
5
5
|
import { renderTarget } from "./plurnk-uri.js";
|
|
6
|
+
import GitState from "./git-state.js";
|
|
6
7
|
import LogBody from "./LogBody.js";
|
|
7
8
|
import LogEntryProjection from "./LogEntryProjection.js";
|
|
8
9
|
import LogVisibility from "./LogVisibility.js";
|
|
9
10
|
import BodyPreview from "../content/body-preview.js";
|
|
11
|
+
import ScopeFormat from "../content/scope-format.js";
|
|
10
12
|
import { assertEditReceipt, assertResourceEffects, LineAnchors, } from "../content/index.js";
|
|
11
13
|
// {§packet-attachment-parts} — the attachment kinds and their readout weights live in one table.
|
|
12
|
-
import { imageWeight, pdfWeight } from "./attachments.js";
|
|
14
|
+
import { audioWeight, imageWeight, pdfWeight } from "./attachments.js";
|
|
15
|
+
import { isExecutionOp } from "@plurnk/plurnk-contracts";
|
|
13
16
|
export { imageWeight, pdfWeight };
|
|
14
17
|
export default class PacketWire {
|
|
15
18
|
// {§packet-markdown} Render the sections in `slot` to one ChatMessage.content
|
|
@@ -145,6 +148,9 @@ export default class PacketWire {
|
|
|
145
148
|
if (lines.length !== ordinals.length) {
|
|
146
149
|
throw new TypeError("A sparse log-body projection requires one source ordinal per rendered line.");
|
|
147
150
|
}
|
|
151
|
+
if (sourceLineNumbers !== null && ordinals.some((ordinal) => ordinal < 1 || ordinal > sourceLineNumbers.length)) {
|
|
152
|
+
throw new TypeError("A sparse log-body projection's ordinals must address its source line numbers.");
|
|
153
|
+
}
|
|
148
154
|
const displayed = ordinals.map((ordinal) => sourceLineNumbers === null ? startLine + ordinal - 1 : sourceLineNumbers[ordinal - 1]);
|
|
149
155
|
const width = lineAnchors === null
|
|
150
156
|
? numericLineNumberWidth > 0
|
|
@@ -201,7 +207,7 @@ export default class PacketWire {
|
|
|
201
207
|
static #canonicalJson(obj) {
|
|
202
208
|
const keys = Object.keys(obj).sort();
|
|
203
209
|
const sorted = {};
|
|
204
|
-
for (const key of ["
|
|
210
|
+
for (const key of ["path", "from", "to", "aside"]) {
|
|
205
211
|
if (Object.hasOwn(obj, key))
|
|
206
212
|
sorted[key] = obj[key];
|
|
207
213
|
}
|
|
@@ -223,7 +229,7 @@ export default class PacketWire {
|
|
|
223
229
|
return {
|
|
224
230
|
...head,
|
|
225
231
|
change: `-${receipt.effect.removed} +${receipt.effect.inserted}`,
|
|
226
|
-
|
|
232
|
+
effect: `${receipt.effect.source} -> ${receipt.effect.result}`,
|
|
227
233
|
// {§edit-receipt-removed-text} — what a deletion took, so it can be put back from the receipt.
|
|
228
234
|
...(receipt.effect.removedText === undefined ? {} : { removed: receipt.effect.removedText }),
|
|
229
235
|
};
|
|
@@ -236,7 +242,7 @@ export default class PacketWire {
|
|
|
236
242
|
? {}
|
|
237
243
|
: {
|
|
238
244
|
change: `-${receipt.replacement.removed} +${receipt.replacement.inserted}`,
|
|
239
|
-
replacement: `${receipt.replacement.
|
|
245
|
+
replacement: `${receipt.replacement.source} -> ${receipt.replacement.result}`,
|
|
240
246
|
}),
|
|
241
247
|
};
|
|
242
248
|
}
|
|
@@ -252,21 +258,7 @@ export default class PacketWire {
|
|
|
252
258
|
}
|
|
253
259
|
return endsWithLineBreak ? body.replace(/(?:\r\n|\r|\n)$/, "") : body;
|
|
254
260
|
}
|
|
255
|
-
//
|
|
256
|
-
// No body, no fence — every meaningful field is in the JSON. Naming
|
|
257
|
-
// follows the uniform principle: `path` is identity (this log row's
|
|
258
|
-
// own URI), `target` is the URI in the statement's target slot. COPY/MOVE
|
|
259
|
-
// retain their source and destination selections separately from ordered
|
|
260
|
-
// applied `effects`.
|
|
261
|
-
//
|
|
262
|
-
// On error, status >= 400 signals the failure; Problem Details live on
|
|
263
|
-
// this durable row and the next packet's Errors section points here.
|
|
264
|
-
//
|
|
265
|
-
// Per-entry render: one meta JSON line plus the row's canonical body.
|
|
266
|
-
// LogBody owns tx/rx storage interpretation; packet projection owns only
|
|
267
|
-
// visibility, previewing, mimetype rendering, and metadata.
|
|
268
|
-
// The log:/// handle the model sees for an entry.
|
|
269
|
-
// ({§log-kill-scope}).
|
|
261
|
+
// {§log-address-metadata} — row identity belongs to the H3, not its operand metadata.
|
|
270
262
|
static #entryPath(coordinate, leaf) {
|
|
271
263
|
if (coordinate === null)
|
|
272
264
|
throw new TypeError("A packet log row requires an addressable coordinate.");
|
|
@@ -287,30 +279,26 @@ export default class PacketWire {
|
|
|
287
279
|
chunk: cut ? PacketWire.#chunk(coordinates, physicalLines, end, text.length) : null,
|
|
288
280
|
};
|
|
289
281
|
}
|
|
290
|
-
static #formatRegion(region) {
|
|
291
|
-
return `<${region.startLine},${region.startColumn},${region.endLine},${region.endColumn}>`;
|
|
292
|
-
}
|
|
293
282
|
static #chunk(coordinates, lines, end, completeEnd) {
|
|
294
283
|
const finalCompleteLine = lines.findIndex((line) => line.separator.length > 0 && line.end === end);
|
|
295
284
|
if (finalCompleteLine !== -1) {
|
|
296
|
-
const selected =
|
|
297
|
-
|
|
298
|
-
if (selected === complete) {
|
|
285
|
+
const selected = ScopeFormat.lines(1, finalCompleteLine + 1);
|
|
286
|
+
if (finalCompleteLine + 1 === lines.length) {
|
|
299
287
|
throw new Error("a bounded body chunk must differ from its complete line extent");
|
|
300
288
|
}
|
|
301
|
-
return
|
|
289
|
+
return `${selected} of ${ScopeFormat.count("line", lines.length)}`;
|
|
302
290
|
}
|
|
303
291
|
const selectedRegion = coordinates.regionFromOffsets(0, end);
|
|
304
292
|
const completeRegion = coordinates.regionFromOffsets(0, completeEnd);
|
|
305
293
|
if (selectedRegion === null || completeRegion === null) {
|
|
306
294
|
throw new Error("a character-bound body chunk must resolve to exact text coordinates");
|
|
307
295
|
}
|
|
308
|
-
const selected =
|
|
309
|
-
const complete =
|
|
296
|
+
const selected = ScopeFormat.region(selectedRegion);
|
|
297
|
+
const complete = ScopeFormat.region(completeRegion);
|
|
310
298
|
if (selected === complete) {
|
|
311
299
|
throw new Error("a bounded body chunk must differ from its complete text extent");
|
|
312
300
|
}
|
|
313
|
-
return
|
|
301
|
+
return `${selected} of ${complete}`;
|
|
314
302
|
}
|
|
315
303
|
static #sparseChunk(completeContent, visibleContent, visibleOrdinals, projectedContent) {
|
|
316
304
|
const end = projectedContent.length;
|
|
@@ -329,8 +317,8 @@ export default class PacketWire {
|
|
|
329
317
|
previous[1] = ordinal;
|
|
330
318
|
}
|
|
331
319
|
}
|
|
332
|
-
const selected = runs.map(([start, finish]) =>
|
|
333
|
-
return
|
|
320
|
+
const selected = runs.map(([start, finish]) => ScopeFormat.lines(start, finish)).join(",");
|
|
321
|
+
return `${selected} of ${ScopeFormat.count("line", TextCoordinates.logicalLines(completeContent).length)}`;
|
|
334
322
|
}
|
|
335
323
|
const local = coordinates.regionFromOffsets(0, end);
|
|
336
324
|
const complete = new TextCoordinates(completeContent)
|
|
@@ -343,11 +331,11 @@ export default class PacketWire {
|
|
|
343
331
|
if (startLine === undefined || endLine === undefined) {
|
|
344
332
|
throw new Error("a sparse character-bound chunk must map to canonical body lines");
|
|
345
333
|
}
|
|
346
|
-
return
|
|
334
|
+
return `${ScopeFormat.region({
|
|
347
335
|
...local,
|
|
348
336
|
startLine,
|
|
349
337
|
endLine,
|
|
350
|
-
})} of ${
|
|
338
|
+
})} of ${ScopeFormat.region(complete)}`;
|
|
351
339
|
}
|
|
352
340
|
static #promptProjection(body, budget, weighContent, render = (content) => PacketWire.#renderContentBody(content, body.startLine, null)) {
|
|
353
341
|
const weightAt = (end) => weighContent(render(body.content.slice(0, end)));
|
|
@@ -421,10 +409,24 @@ export default class PacketWire {
|
|
|
421
409
|
readableContent: select(readableOrdinals),
|
|
422
410
|
readableOrdinals,
|
|
423
411
|
folded: clipped,
|
|
412
|
+
trimmed: LogVisibility.clipped(trimmed, totalLines),
|
|
424
413
|
totalLines,
|
|
425
414
|
fullyFolded: LogVisibility.fullyFolded(clipped, totalLines),
|
|
426
415
|
};
|
|
427
416
|
}
|
|
417
|
+
// {§message-arrival} — an inbound SEND row: harness-published, the sender's statement as its
|
|
418
|
+
// sent side. {§message-causal-source}: a `source` names the actor; absence is the owner.
|
|
419
|
+
static isArrival(e) {
|
|
420
|
+
if (e.op !== "SEND" || e.origin !== "_plurnk")
|
|
421
|
+
return false;
|
|
422
|
+
const attrs = typeof e.attrs === "string" ? JSON.parse(e.attrs) : e.attrs;
|
|
423
|
+
return attrs !== null && typeof attrs === "object" && attrs.kind === "message";
|
|
424
|
+
}
|
|
425
|
+
// {§message-projection} — a peer worker's message takes the ordinary bounds; every other
|
|
426
|
+
// arrival, the loop's own assignment included, shares the allowance.
|
|
427
|
+
static isExteriorArrival(e) {
|
|
428
|
+
return PacketWire.isArrival(e) && !(typeof e.source === "string" && e.source.startsWith("worker://"));
|
|
429
|
+
}
|
|
428
430
|
static #promptProjectionWeights(entries, bodies, visibility, weighContent, budget) {
|
|
429
431
|
if (budget === undefined)
|
|
430
432
|
return new Map();
|
|
@@ -432,7 +434,9 @@ export default class PacketWire {
|
|
|
432
434
|
throw new RangeError(`promptProjectionWeight must be a non-negative safe integer, got ${JSON.stringify(budget)}`);
|
|
433
435
|
}
|
|
434
436
|
const costs = entries.flatMap((entry, index) => {
|
|
435
|
-
|
|
437
|
+
// {§message-projection} — an arrival from outside the workspace shares the allowance;
|
|
438
|
+
// a peer worker's message takes the ordinary bounds.
|
|
439
|
+
if (!PacketWire.isExteriorArrival(entry) || bodies[index].content.length === 0)
|
|
436
440
|
return [];
|
|
437
441
|
const body = bodies[index];
|
|
438
442
|
const visible = visibility[index];
|
|
@@ -481,316 +485,351 @@ export default class PacketWire {
|
|
|
481
485
|
}));
|
|
482
486
|
const promptProjectionWeights = PacketWire.#promptProjectionWeights(entries, visibleBodies, visibility, weighContent, options.promptProjectionWeight);
|
|
483
487
|
return entries.map((e, index) => {
|
|
484
|
-
const
|
|
485
|
-
const coordinate = typeof e.coordinate === "string" ? e.coordinate : null;
|
|
486
|
-
const op = typeof e.op === "string" && e.op.length > 0 ? e.op : null;
|
|
487
|
-
const renderedLeaf = LogEntryProjection.leaf(e);
|
|
488
|
-
const path = PacketWire.#entryPath(coordinate, renderedLeaf);
|
|
489
|
-
// Absence = "model" — the worker's own authorship is the default,
|
|
490
|
-
// exactly as `source` absence means the owning worker (#338).
|
|
491
|
-
if (typeof e.origin === "string" && e.origin !== "model")
|
|
492
|
-
meta.origin = e.origin;
|
|
493
|
-
// {§env-delta-attribution}: render the causal worker address or
|
|
494
|
-
// subsystem token when present; absence means the owning worker.
|
|
495
|
-
if (typeof e.source === "string" && e.source.length > 0)
|
|
496
|
-
meta.source = e.source;
|
|
497
|
-
if (e.source === "file" && e.attrs !== null && typeof e.attrs === "object" && "git" in e.attrs) {
|
|
498
|
-
const git = e.attrs.git;
|
|
499
|
-
if (typeof git !== "string" || git.length !== 2) {
|
|
500
|
-
throw new TypeError("A source=file log row carries malformed Git XY metadata.");
|
|
501
|
-
}
|
|
502
|
-
meta.git = git;
|
|
503
|
-
}
|
|
504
|
-
// SEND, TASK, destructive KILL, and non-200 statuses stay explicit.
|
|
505
|
-
// Successful log-KILL rows never reach this projection
|
|
506
|
-
// ({§log-kill-meta-operation}).
|
|
507
|
-
if (typeof e.status === "number" && (op === "SEND" || op === "KILL" || typeof op === "string" && TurnDisposition.isOp(op) || e.status !== 200))
|
|
508
|
-
meta.status = e.status;
|
|
509
|
-
const tx = (typeof e.tx === "string" ? PacketWire.#safeParse(e.tx) : e.tx);
|
|
510
|
-
if (typeof tx?.aside === "string")
|
|
511
|
-
meta.aside = tx.aside;
|
|
512
|
-
const target = PacketWire.#renderActionTarget(e.target);
|
|
513
|
-
// {§exec-stream}: a terminal stream observation's address is the stream it observed,
|
|
514
|
-
// rendered under `stream` like the invocation's own link — never a `target`, which
|
|
515
|
-
// the model would otherwise author into an EXEC slot (#425 F4).
|
|
516
|
-
const terminalStream = op === "READ"
|
|
517
|
-
&& e.attrs !== null
|
|
518
|
-
&& typeof e.attrs === "object"
|
|
519
|
-
&& e.attrs.terminal === true;
|
|
520
|
-
if (op === "COPY" || op === "MOVE") {
|
|
521
|
-
const source = PacketWire.#renderSelection(tx?.source?.target, tx?.source?.lineMarker);
|
|
522
|
-
const destination = PacketWire.#renderSelection(tx?.destination?.target, tx?.destination?.lineMarker);
|
|
523
|
-
if (source !== null)
|
|
524
|
-
meta.source = source;
|
|
525
|
-
if (destination !== null)
|
|
526
|
-
meta.destination = destination;
|
|
527
|
-
if (typeof e.status === "number"
|
|
528
|
-
&& e.status < 400
|
|
529
|
-
&& (source === null || destination === null)) {
|
|
530
|
-
throw new Error(`A successful ${op} log row must retain both operand selections.`);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
else if (target !== null) {
|
|
534
|
-
meta[terminalStream ? "stream" : "target"] = target;
|
|
535
|
-
}
|
|
536
|
-
// {§worker-auto-name} The created identity is an outcome, not an authored target.
|
|
537
|
-
if ((op === "WORK" || op === "FORK") && e.attrs !== null && typeof e.attrs === "object"
|
|
538
|
-
&& typeof e.attrs.worker === "string") {
|
|
539
|
-
meta.worker = e.attrs.worker;
|
|
540
|
-
}
|
|
541
|
-
// EXEC's output is a separate stream entry ({§exec-stream}); its address rides in a
|
|
542
|
-
// `stream` link, distinct from the runtime-owned invocation target.
|
|
543
|
-
// {§exec-target-routing} {§fs-namespace} — the receipt names the working directory only
|
|
544
|
-
// when it is not the project root, and then in the model's own project-relative form;
|
|
545
|
-
// the root is the default and a host-absolute path never reaches the packet.
|
|
546
|
-
if (op === "EXEC" && e.attrs !== null && typeof e.attrs === "object" && typeof e.attrs.cwd === "string") {
|
|
547
|
-
const cwd = PacketWire.#projectRelativeCwd(e.attrs.cwd, options.projectRoot ?? null);
|
|
548
|
-
if (cwd !== null)
|
|
549
|
-
meta.cwd = cwd;
|
|
550
|
-
}
|
|
551
|
-
if (op === "EXEC" && e.attrs !== null && typeof e.attrs === "object" && typeof e.attrs.stream === "string") {
|
|
552
|
-
meta.stream = e.attrs.stream;
|
|
553
|
-
}
|
|
488
|
+
const identity = PacketWire.#rowIdentity(e, options);
|
|
554
489
|
// Parse rx once — reused for the matcher/items enrichment and the body.
|
|
555
490
|
const rx = (typeof e.rx === "string" ? PacketWire.#safeParse(e.rx) : e.rx);
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
491
|
+
const facts = PacketWire.#rowResultFacts(identity, e, rx, bodies[index]);
|
|
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). An arrival is an inbound
|
|
508
|
+
// SEND row the harness published ({§message-causal-source}): its origin says nothing, so
|
|
509
|
+
// the row carries only the causal `source` when another actor supplied one (#706).
|
|
510
|
+
if (typeof e.origin === "string" && e.origin !== "model" && !PacketWire.isArrival(e))
|
|
511
|
+
meta.origin = e.origin;
|
|
512
|
+
// {§env-delta-attribution}: render the causal worker address or
|
|
513
|
+
// subsystem token when present; absence means the owning worker.
|
|
514
|
+
// {§message-short-identity} an arrival whose source is the transport's own name for it adds
|
|
515
|
+
// nothing to its address; a peer's or an agent's source still shows.
|
|
516
|
+
const arrivalAttrs = typeof e.attrs === "string" ? PacketWire.#safeParse(e.attrs) : e.attrs;
|
|
517
|
+
const selfAddressed = arrivalAttrs !== null && typeof arrivalAttrs === "object" && arrivalAttrs.selfAddressed === true;
|
|
518
|
+
if (typeof e.source === "string" && e.source.length > 0 && !selfAddressed)
|
|
519
|
+
meta.source = e.source;
|
|
520
|
+
if (e.source === "file" && e.attrs !== null && typeof e.attrs === "object" && "git" in e.attrs) {
|
|
521
|
+
const git = e.attrs.git;
|
|
522
|
+
if (typeof git !== "string" || git.length !== 2) {
|
|
523
|
+
throw new TypeError("A source=file log row carries malformed Git XY metadata.");
|
|
567
524
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
525
|
+
meta.git = git;
|
|
526
|
+
}
|
|
527
|
+
// SEND, lifecycle verbs, destructive KILL, and non-200 statuses stay explicit.
|
|
528
|
+
// Successful log-KILL rows never reach this projection
|
|
529
|
+
// ({§log-kill-meta-operation}).
|
|
530
|
+
if (typeof e.status === "number" && (op === "SEND" || op === "KILL" || typeof op === "string" && TurnDisposition.isOp(op) || e.status !== 200))
|
|
531
|
+
meta.status = e.status;
|
|
532
|
+
const tx = (typeof e.tx === "string" ? PacketWire.#safeParse(e.tx) : e.tx);
|
|
533
|
+
if (typeof tx?.aside === "string")
|
|
534
|
+
meta.aside = tx.aside;
|
|
535
|
+
const target = PacketWire.#renderActionTarget(e.target);
|
|
536
|
+
// {§log-address-metadata}: operands are independent of record identity and attribution.
|
|
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.from = source;
|
|
542
|
+
if (destination !== null)
|
|
543
|
+
meta.to = 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.`);
|
|
578
548
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
549
|
+
}
|
|
550
|
+
else if (target !== null) {
|
|
551
|
+
meta.path = 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 };
|
|
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, fullBody) {
|
|
577
|
+
const { meta, op, tx } = identity;
|
|
578
|
+
if (op === "SEND" && rx !== null && typeof rx === "object" && Array.isArray(rx.attachments) && rx.attachments.length > 0) {
|
|
579
|
+
meta.attachments = rx.attachments.map(({ name, mediaType, target }) => ({ name, mediaType, path: target }));
|
|
580
|
+
}
|
|
581
|
+
// {§operation-resource-receipt}: preserve the returned address, not a second authored target.
|
|
582
|
+
if (rx !== null && typeof rx === "object" && typeof rx.resource === "string"
|
|
583
|
+
&& rx.resource.length > 0 && rx.resource !== meta.path && rx.resource !== meta.stream) {
|
|
584
|
+
meta.resource = rx.resource;
|
|
585
|
+
}
|
|
586
|
+
// {§exec-stream}: explicit and automatic READs preserve the same
|
|
587
|
+
// durable liveness facts, including an empty active channel.
|
|
588
|
+
if (op === "READ" && rx !== null && typeof rx === "object" && Object.hasOwn(rx, "terminal")) {
|
|
589
|
+
if (typeof rx.terminal !== "boolean") {
|
|
590
|
+
throw new TypeError("A stream READ result carries a malformed terminal flag.");
|
|
586
591
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
meta.matcher = tx.matcher.raw;
|
|
594
|
-
if (op !== "FIND" && rx !== null && typeof rx === "object" && typeof rx.matched === "number")
|
|
595
|
-
meta.matched = rx.matched;
|
|
592
|
+
meta.terminal = rx.terminal;
|
|
593
|
+
if (Object.hasOwn(rx, "exitCode")) {
|
|
594
|
+
if (typeof rx.exitCode !== "number" || !Number.isSafeInteger(rx.exitCode)) {
|
|
595
|
+
throw new TypeError("A stream READ result carries a malformed exitCode.");
|
|
596
|
+
}
|
|
597
|
+
meta.exitCode = rx.exitCode;
|
|
596
598
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
599
|
+
}
|
|
600
|
+
// {§problem-projection} — the exact durable Problem remains the
|
|
601
|
+
// failure authority; the packet carries only facts not already
|
|
602
|
+
// owned by its enclosing row. Errors remains only an index.
|
|
603
|
+
if (typeof e.status === "number" && e.status >= 400 && rx !== null && typeof rx === "object") {
|
|
604
|
+
const problem = rx.problem;
|
|
605
|
+
Validator.assertProblemDetails(problem);
|
|
606
|
+
meta.problem = Problems.project(problem, {
|
|
607
|
+
status: e.status,
|
|
608
|
+
row: { ...meta, target: identity.target },
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
// The success-side sibling (#342): a sub-problem receipt may carry one
|
|
612
|
+
// terse `detail` (e.g. the EDIT 304) so situational teaching is paid
|
|
613
|
+
// only when the situation occurs, never in the hot path.
|
|
614
|
+
if (!Object.hasOwn(meta, "problem") && rx !== null && typeof rx === "object"
|
|
615
|
+
&& typeof rx.detail === "string"
|
|
616
|
+
&& rx.detail.length > 0) {
|
|
617
|
+
meta.detail = rx.detail;
|
|
618
|
+
}
|
|
619
|
+
// {§retrieval-packet-metadata}: one extent/coordinate owner plus
|
|
620
|
+
// only FIND aggregates that add information beyond that extent.
|
|
621
|
+
let findItems = null;
|
|
622
|
+
let range = null;
|
|
623
|
+
const patterned = tx !== null && tx !== undefined && typeof tx === "object" && tx.matcher !== null && typeof tx.matcher === "object" && typeof tx.matcher.raw === "string";
|
|
624
|
+
if (patterned) {
|
|
625
|
+
meta.matcher = tx.matcher.raw;
|
|
626
|
+
if (op !== "FIND" && rx !== null && typeof rx === "object" && typeof rx.matched === "number")
|
|
627
|
+
meta.matched = rx.matched;
|
|
628
|
+
}
|
|
629
|
+
// {§channel-selection-visibility} — a READ names the resource's other channels with their
|
|
630
|
+
// tokens, so the row itself shows the choice a FIND listing would.
|
|
631
|
+
if (op === "READ" && rx !== null && typeof rx === "object" && rx.channels !== null && typeof rx.channels === "object") {
|
|
632
|
+
meta.channels = rx.channels;
|
|
633
|
+
}
|
|
634
|
+
// {§send-response-receipt} — a reply's row names the prompts it answered.
|
|
635
|
+
if (op === "SEND" && rx !== null && typeof rx === "object" && Array.isArray(rx.answers)) {
|
|
636
|
+
meta.answers = rx.answers;
|
|
637
|
+
}
|
|
638
|
+
if (op === "READ" || op === "FIND") {
|
|
639
|
+
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.content === "string") {
|
|
640
|
+
const parsed = PacketWire.#safeParse(rx.content);
|
|
641
|
+
if (Array.isArray(parsed))
|
|
642
|
+
findItems = parsed.length;
|
|
601
643
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
644
|
+
range = rx !== null && typeof rx === "object" && rx.range !== undefined
|
|
645
|
+
? Validator.assertRangeExtent(rx.range)
|
|
646
|
+
: null;
|
|
647
|
+
const problemOwnsRange = typeof e.status === "number"
|
|
648
|
+
&& e.status >= 400
|
|
649
|
+
&& meta.problem !== null
|
|
650
|
+
&& typeof meta.problem === "object"
|
|
651
|
+
&& Object.hasOwn(meta.problem, "range");
|
|
652
|
+
if (problemOwnsRange) {
|
|
653
|
+
Validator.assertRangeExtent(meta.problem.range);
|
|
605
654
|
}
|
|
606
|
-
if (
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
&& e.status >= 400
|
|
617
|
-
&& meta.problem !== null
|
|
618
|
-
&& typeof meta.problem === "object"
|
|
619
|
-
&& Object.hasOwn(meta.problem, "range");
|
|
620
|
-
if (problemOwnsRange) {
|
|
621
|
-
Validator.assertRangeExtent(meta.problem.range);
|
|
622
|
-
}
|
|
623
|
-
if (range !== undefined && !problemOwnsRange) {
|
|
624
|
-
meta.range = Validator.assertRangeExtent(range);
|
|
625
|
-
}
|
|
626
|
-
else if (op === "READ" && rx !== null && typeof rx === "object" && rx.region !== undefined) {
|
|
627
|
-
meta.region = Validator.assertTextRegion(rx.region);
|
|
628
|
-
}
|
|
629
|
-
// These are underlying selected-content weights, distinct from
|
|
630
|
-
// the emitted body's generic `tokens` measurement.
|
|
631
|
-
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.itemsWeightTotal === "number" && rx.itemsWeightTotal > 0) {
|
|
632
|
-
meta.itemsTokenTotal = rx.itemsWeightTotal;
|
|
633
|
-
}
|
|
634
|
-
if (op === "FIND"
|
|
635
|
-
&& rx !== null
|
|
636
|
-
&& typeof rx === "object"
|
|
637
|
-
&& typeof rx.returnedItemsWeightTotal === "number"
|
|
638
|
-
&& rx.returnedItemsWeightTotal > 0
|
|
639
|
-
&& rx.returnedItemsWeightTotal !== rx.itemsWeightTotal) {
|
|
640
|
-
meta.returnedItemsTokenTotal = rx.returnedItemsWeightTotal;
|
|
641
|
-
}
|
|
642
|
-
if (op === "FIND"
|
|
643
|
-
&& patterned
|
|
644
|
-
&& range !== null
|
|
645
|
-
&& typeof range === "object"
|
|
646
|
-
&& range.unit === "resource"
|
|
647
|
-
&& rx !== null
|
|
648
|
-
&& typeof rx === "object"
|
|
649
|
-
&& typeof rx.matchLocationCount === "number"
|
|
650
|
-
&& rx.matchLocationCount > 0) {
|
|
651
|
-
meta.matchLocationCount = rx.matchLocationCount;
|
|
652
|
-
}
|
|
655
|
+
if (range !== null && !problemOwnsRange) {
|
|
656
|
+
const sparse = fullBody.lineOrdinals !== undefined
|
|
657
|
+
&& range.returned !== undefined
|
|
658
|
+
&& fullBody.lineOrdinals.length !== range.returned[1] - range.returned[0] + 1;
|
|
659
|
+
meta.range = typeof e.status === "number" && e.status >= 400
|
|
660
|
+
? range
|
|
661
|
+
: ScopeFormat.range(range, sparse);
|
|
662
|
+
}
|
|
663
|
+
else if (range === null && !problemOwnsRange && op === "READ" && rx !== null && typeof rx === "object" && rx.region !== undefined) {
|
|
664
|
+
meta.range = ScopeFormat.region(Validator.assertTextRegion(rx.region));
|
|
653
665
|
}
|
|
654
|
-
//
|
|
655
|
-
//
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if ((op === "EDIT" || op === "KILL") && rx !== null && typeof rx === "object" && Object.hasOwn(rx, "receipt")) {
|
|
659
|
-
Object.assign(meta, PacketWire.#receiptMeta(rx.receipt));
|
|
660
|
-
structuredMutationReceipt = true;
|
|
666
|
+
// These are underlying selected-content weights, distinct from
|
|
667
|
+
// the emitted body's generic `tokens` measurement.
|
|
668
|
+
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.itemsWeightTotal === "number" && rx.itemsWeightTotal > 0) {
|
|
669
|
+
meta.itemsTokenTotal = rx.itemsWeightTotal;
|
|
661
670
|
}
|
|
662
|
-
if (
|
|
671
|
+
if (op === "FIND"
|
|
663
672
|
&& rx !== null
|
|
664
673
|
&& typeof rx === "object"
|
|
665
|
-
&&
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
action: effect.action,
|
|
670
|
-
...(effect.receipt === undefined
|
|
671
|
-
? {}
|
|
672
|
-
: PacketWire.#receiptMeta(effect.receipt)),
|
|
673
|
-
}));
|
|
674
|
-
structuredMutationReceipt = effects.some((effect) => effect.receipt !== undefined);
|
|
675
|
-
}
|
|
676
|
-
// The canonical full body is shared with log READ, log FIND,
|
|
677
|
-
// and search derivation. READ/FIND own selection bounds, TASK and
|
|
678
|
-
// admitted programs remain complete, and prompt rows share their packet
|
|
679
|
-
// allowance. Structured mutation receipts own their join bound;
|
|
680
|
-
// every remaining body uses the ordinary fixed preview.
|
|
681
|
-
const fullBody = bodies[index];
|
|
682
|
-
const bodyVisibility = visibility[index];
|
|
683
|
-
const projectedBody = {
|
|
684
|
-
...fullBody,
|
|
685
|
-
content: bodyVisibility.fullyFolded ? bodyVisibility.readableContent : bodyVisibility.content,
|
|
686
|
-
};
|
|
687
|
-
const emptyFind = op === "FIND" && e.status === 200 && findItems === 0;
|
|
688
|
-
const previewExempt = op === "READ"
|
|
689
|
-
|| op === "FIND"
|
|
690
|
-
|| op === "TASK"
|
|
691
|
-
|| (op === null && renderedLeaf === "ops")
|
|
692
|
-
|| structuredMutationReceipt;
|
|
693
|
-
const lineAnchors = op === "READ" ? e.lineAnchors ?? null : null;
|
|
694
|
-
const lineNumberWidth = op === "READ" ? e.lineNumberWidth ?? null : null;
|
|
695
|
-
if (lineAnchors !== null) {
|
|
696
|
-
LineAnchors.assertProjection(fullBody.content, lineAnchors);
|
|
674
|
+
&& typeof rx.returnedItemsWeightTotal === "number"
|
|
675
|
+
&& rx.returnedItemsWeightTotal > 0
|
|
676
|
+
&& rx.returnedItemsWeightTotal !== rx.itemsWeightTotal) {
|
|
677
|
+
meta.returnedItemsTokenTotal = rx.returnedItemsWeightTotal;
|
|
697
678
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
: String(findRange.total).length;
|
|
707
|
-
const sourceOrdinals = bodyVisibility.fullyFolded
|
|
708
|
-
? bodyVisibility.readableOrdinals
|
|
709
|
-
: bodyVisibility.ordinals;
|
|
710
|
-
const promptProjectionWeight = promptProjectionWeights.get(index);
|
|
711
|
-
const projection = promptProjectionWeight !== undefined
|
|
712
|
-
? PacketWire.#promptProjection(projectedBody, promptProjectionWeight, weighContent, (content) => PacketWire.#renderContentBody(content, bodyStartLine, null, null, numericLineNumberWidth, bodyStartLine === null
|
|
713
|
-
? null
|
|
714
|
-
: sourceOrdinals.slice(0, TextCoordinates.logicalLines(content).length)))
|
|
715
|
-
: previewExempt
|
|
716
|
-
? { text: projectedBody.content, cut: false, chunk: null }
|
|
717
|
-
: PacketWire.#preview(projectedBody.content);
|
|
718
|
-
const projectedLineCount = TextCoordinates.logicalLines(projection.text).length;
|
|
719
|
-
const projectedOrdinals = sourceOrdinals.slice(0, projectedLineCount);
|
|
720
|
-
const body = emptyFind || projection.text.length === 0
|
|
721
|
-
? ""
|
|
722
|
-
: PacketWire.#renderContentBody(projection.text, bodyStartLine, lineAnchors, lineNumberWidth, numericLineNumberWidth, bodyStartLine === null ? null : projectedOrdinals, fullBody.lineOrdinals ?? null);
|
|
723
|
-
// lines beside tokens on a non-retrieval row with a navigable body — the count of
|
|
724
|
-
// `N:`-numbered lines (fences and unnumbered prose don't count), so the model can plan
|
|
725
|
-
// a <start,end> slice before paying for a READ. READ/FIND own typed extents instead.
|
|
726
|
-
if (fullBody.content.length > 0 && op !== "READ" && op !== "FIND") {
|
|
727
|
-
meta.lines = bodyVisibility.totalLines;
|
|
728
|
-
}
|
|
729
|
-
if (bodyVisibility.folded.length > 0 && !bodyVisibility.fullyFolded) {
|
|
730
|
-
meta.folded = LogVisibility.format(bodyVisibility.folded);
|
|
731
|
-
}
|
|
732
|
-
const display = bodyVisibility.readableContent.length === 0
|
|
733
|
-
? "none"
|
|
734
|
-
: bodyVisibility.fullyFolded || e.output_withheld === true
|
|
735
|
-
? "folded"
|
|
736
|
-
: body.length === 0
|
|
737
|
-
? "none"
|
|
738
|
-
: "open";
|
|
739
|
-
const projectedChunk = projection.chunk !== null
|
|
740
|
-
&& bodyVisibility.folded.length > 0
|
|
741
|
-
&& !bodyVisibility.fullyFolded
|
|
742
|
-
? PacketWire.#sparseChunk(fullBody.content, projectedBody.content, sourceOrdinals, projection.text)
|
|
743
|
-
: projection.chunk;
|
|
744
|
-
if (display === "open" && projectedChunk !== null)
|
|
745
|
-
meta.chunk = projectedChunk;
|
|
746
|
-
const nativeCandidate = op === "READ" && typeof e.status === "number" && e.status >= 200 && e.status < 300
|
|
747
|
-
? PacketWire.#attachmentOf(e.rx, e.target, coordinate, target) : null;
|
|
748
|
-
const native = nativeCandidate !== null && (options.acceptedAttachmentKinds?.has(nativeCandidate.kind) ?? true)
|
|
749
|
-
? nativeCandidate : null;
|
|
750
|
-
const outputWithheld = e.output_withheld === true
|
|
751
|
-
&& ((!bodyVisibility.fullyFolded && body.length > 0) || native !== null);
|
|
752
|
-
if (outputWithheld) {
|
|
753
|
-
const omitted = body.length > 0
|
|
754
|
-
? `${projectedLineCount} output lines${native === null ? "" : " and native content"}`
|
|
755
|
-
: "native content";
|
|
756
|
-
meta.overflow = `${omitted} not shown; logTokensTotal exceeds logTokensMax`;
|
|
679
|
+
if (op === "FIND"
|
|
680
|
+
&& patterned
|
|
681
|
+
&& range?.unit === "resource"
|
|
682
|
+
&& rx !== null
|
|
683
|
+
&& typeof rx === "object"
|
|
684
|
+
&& typeof rx.matchLocationCount === "number"
|
|
685
|
+
&& rx.matchLocationCount > 0) {
|
|
686
|
+
meta.matchLocationCount = rx.matchLocationCount;
|
|
757
687
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
688
|
+
}
|
|
689
|
+
// {§edit-result-receipt-projection} {§edit-result-copy-move-effects}
|
|
690
|
+
// EDIT/scoped entry KILL own one receipt; COPY/MOVE own resource effects whose
|
|
691
|
+
// optional receipts describe scoped textual materializations.
|
|
692
|
+
let structuredMutationReceipt = false;
|
|
693
|
+
if ((op === "EDIT" || op === "KILL") && rx !== null && typeof rx === "object" && Object.hasOwn(rx, "receipt")) {
|
|
694
|
+
Object.assign(meta, PacketWire.#receiptMeta(rx.receipt));
|
|
695
|
+
structuredMutationReceipt = true;
|
|
696
|
+
}
|
|
697
|
+
if ((op === "COPY" || op === "MOVE")
|
|
698
|
+
&& rx !== null
|
|
699
|
+
&& typeof rx === "object"
|
|
700
|
+
&& Object.hasOwn(rx, "effects")) {
|
|
701
|
+
const effects = assertResourceEffects(rx.effects);
|
|
702
|
+
meta.effects = effects.map((effect) => ({
|
|
703
|
+
path: effect.target,
|
|
704
|
+
action: effect.action,
|
|
705
|
+
...(effect.receipt === undefined
|
|
706
|
+
? {}
|
|
707
|
+
: PacketWire.#receiptMeta(effect.receipt)),
|
|
708
|
+
}));
|
|
709
|
+
structuredMutationReceipt = effects.some((effect) => effect.receipt !== undefined);
|
|
710
|
+
}
|
|
711
|
+
return { findItems, range, structuredMutationReceipt };
|
|
712
|
+
}
|
|
713
|
+
// The body the row shows: the canonical full body is shared with log READ, log FIND, and
|
|
714
|
+
// search derivation. READ/FIND own selection bounds, NOTE, lifecycle bodies and admitted programs remain
|
|
715
|
+
// complete, and exterior arrivals share their packet allowance. Structured mutation receipts own
|
|
716
|
+
// their join bound; every remaining body uses the ordinary fixed preview.
|
|
717
|
+
static #rowBody(identity, e, fullBody, bodyVisibility, facts, promptProjectionWeight, weighContent) {
|
|
718
|
+
const { meta, op, renderedLeaf } = identity;
|
|
719
|
+
const projectedBody = {
|
|
720
|
+
...fullBody,
|
|
721
|
+
content: bodyVisibility.fullyFolded ? bodyVisibility.readableContent : bodyVisibility.content,
|
|
722
|
+
};
|
|
723
|
+
const emptyFind = op === "FIND" && e.status === 200 && facts.findItems === 0;
|
|
724
|
+
const previewExempt = op === "READ"
|
|
725
|
+
|| op === "FIND"
|
|
726
|
+
|| op === "NOTE" || typeof op === "string" && TurnDisposition.isOp(op)
|
|
727
|
+
|| (op === null && renderedLeaf === "ops")
|
|
728
|
+
|| facts.structuredMutationReceipt;
|
|
729
|
+
const lineAnchors = op === "READ" ? e.lineAnchors ?? null : null;
|
|
730
|
+
const lineNumberWidth = op === "READ" ? e.lineNumberWidth ?? null : null;
|
|
731
|
+
if (lineAnchors !== null) {
|
|
732
|
+
LineAnchors.assertProjection(fullBody.content, lineAnchors);
|
|
733
|
+
}
|
|
734
|
+
const findRange = op === "FIND" ? facts.range : null;
|
|
735
|
+
const bodyStartLine = findRange?.returned?.[0] ?? fullBody.startLine;
|
|
736
|
+
const numericLineNumberWidth = findRange === null
|
|
737
|
+
? bodyStartLine === null || bodyVisibility.totalLines === 0
|
|
738
|
+
? 0
|
|
739
|
+
: String(fullBody.lineOrdinals?.at(-1) ?? bodyStartLine + bodyVisibility.totalLines - 1).length
|
|
740
|
+
: String(findRange.total).length;
|
|
741
|
+
const sourceOrdinals = bodyVisibility.fullyFolded
|
|
742
|
+
? bodyVisibility.readableOrdinals
|
|
743
|
+
: bodyVisibility.ordinals;
|
|
744
|
+
const projection = promptProjectionWeight !== undefined
|
|
745
|
+
? PacketWire.#promptProjection(projectedBody, promptProjectionWeight, weighContent, (content) => PacketWire.#renderContentBody(content, bodyStartLine, null, null, numericLineNumberWidth, bodyStartLine === null
|
|
746
|
+
? null
|
|
747
|
+
: sourceOrdinals.slice(0, TextCoordinates.logicalLines(content).length)))
|
|
748
|
+
: previewExempt
|
|
749
|
+
? { text: projectedBody.content, cut: false, chunk: null }
|
|
750
|
+
: PacketWire.#preview(projectedBody.content);
|
|
751
|
+
const projectedLineCount = TextCoordinates.logicalLines(projection.text).length;
|
|
752
|
+
const projectedOrdinals = sourceOrdinals.slice(0, projectedLineCount);
|
|
753
|
+
const body = emptyFind || projection.text.length === 0
|
|
754
|
+
? ""
|
|
755
|
+
: PacketWire.#renderContentBody(projection.text, bodyStartLine, lineAnchors, lineNumberWidth, numericLineNumberWidth, bodyStartLine === null ? null : projectedOrdinals, fullBody.lineOrdinals ?? null);
|
|
756
|
+
// lines beside tokens on a non-retrieval row with a navigable body — the count of
|
|
757
|
+
// `N:`-numbered lines (fences and unnumbered prose don't count), so the model can plan
|
|
758
|
+
// a <start,end> slice before paying for a READ. READ/FIND own typed extents instead.
|
|
759
|
+
if (fullBody.content.length > 0 && op !== "READ" && op !== "FIND") {
|
|
760
|
+
meta.lines = bodyVisibility.totalLines;
|
|
761
|
+
}
|
|
762
|
+
if (bodyVisibility.trimmed.length > 0 && !bodyVisibility.fullyFolded) {
|
|
763
|
+
meta.trimmed = LogVisibility.format(bodyVisibility.trimmed);
|
|
764
|
+
}
|
|
765
|
+
const display = bodyVisibility.readableContent.length === 0
|
|
766
|
+
? "none"
|
|
767
|
+
: bodyVisibility.fullyFolded || e.output_withheld === true
|
|
768
|
+
? "folded"
|
|
769
|
+
: body.length === 0
|
|
770
|
+
? "none"
|
|
771
|
+
: "open";
|
|
772
|
+
const projectedChunk = projection.chunk !== null
|
|
773
|
+
&& bodyVisibility.folded.length > 0
|
|
774
|
+
&& !bodyVisibility.fullyFolded
|
|
775
|
+
? PacketWire.#sparseChunk(fullBody.content, projectedBody.content, sourceOrdinals, projection.text)
|
|
776
|
+
: projection.chunk;
|
|
777
|
+
if (display === "open" && projectedChunk !== null) {
|
|
778
|
+
meta.preview = projectedChunk;
|
|
779
|
+
delete meta.lines;
|
|
780
|
+
}
|
|
781
|
+
return { body, projectedLineCount, display };
|
|
782
|
+
}
|
|
783
|
+
// The row's native attachment, its withholding receipt, and the accounting field that
|
|
784
|
+
// participates in the row it measures: iterate until its decimal width and therefore the
|
|
785
|
+
// rendered row's curation weight are stable. {§packet-token-accounting}
|
|
786
|
+
static #rowAccounting(identity, e, fullBody, bodyVisibility, projected, weighContent, options) {
|
|
787
|
+
const { meta, op, coordinate, path, target } = identity;
|
|
788
|
+
const { body, projectedLineCount, display } = projected;
|
|
789
|
+
const nativeCandidate = op === "READ" && typeof e.status === "number" && e.status >= 200 && e.status < 300
|
|
790
|
+
? PacketWire.#attachmentOf(e.rx, e.target, coordinate, target) : null;
|
|
791
|
+
const native = nativeCandidate !== null && (options.acceptedAttachmentKinds?.has(nativeCandidate.kind) ?? true)
|
|
792
|
+
? nativeCandidate : null;
|
|
793
|
+
const outputWithheld = e.output_withheld === true
|
|
794
|
+
&& ((!bodyVisibility.fullyFolded && body.length > 0) || native !== null);
|
|
795
|
+
if (outputWithheld) {
|
|
796
|
+
const omitted = body.length > 0
|
|
797
|
+
? `${projectedLineCount} output lines${native === null ? "" : " and native content"}`
|
|
798
|
+
: "native content";
|
|
799
|
+
meta.overflow = `${omitted} not shown; the log exceeded logTokensMax when this row was withheld`;
|
|
800
|
+
}
|
|
801
|
+
const renderRow = () => {
|
|
802
|
+
const metadata = PacketWire.#canonicalJson(meta);
|
|
803
|
+
return display === "open"
|
|
804
|
+
? `### ${path}\n${metadata}\n${body}`
|
|
805
|
+
: `### ${path}\n${metadata}`;
|
|
806
|
+
};
|
|
807
|
+
// {§packet-attachment-parts}: retained native content shares the row's curation lifetime.
|
|
808
|
+
const attachment = e.output_withheld !== true
|
|
809
|
+
&& !(bodyVisibility.totalLines > 0 && bodyVisibility.fullyFolded)
|
|
810
|
+
? native
|
|
811
|
+
: null;
|
|
812
|
+
if (attachment !== null)
|
|
813
|
+
meta.tokensAttachment = attachment.weight;
|
|
814
|
+
meta.logTokens = 0;
|
|
815
|
+
for (let pass = 0; pass < 8; pass += 1) {
|
|
816
|
+
const logTokens = weighContent(renderRow()) + (attachment?.weight ?? 0);
|
|
817
|
+
if (meta.logTokens === logTokens) {
|
|
818
|
+
return {
|
|
819
|
+
content: renderRow(),
|
|
820
|
+
curationTarget: { path, logTokens },
|
|
821
|
+
attachment,
|
|
822
|
+
unadmittedOutput: (display === "open" || attachment !== null)
|
|
823
|
+
&& fullBody.provenance === "returned"
|
|
824
|
+
&& e.output_admission_turn_id == null
|
|
825
|
+
&& typeof e.id === "number"
|
|
826
|
+
? e.id : null,
|
|
827
|
+
newOverflow: outputWithheld && e.newOverflow === true,
|
|
828
|
+
};
|
|
791
829
|
}
|
|
792
|
-
|
|
793
|
-
}
|
|
830
|
+
meta.logTokens = logTokens;
|
|
831
|
+
}
|
|
832
|
+
throw new Error("packet log row accounting did not converge");
|
|
794
833
|
}
|
|
795
834
|
static #attachmentOf(rx, target, coordinate, path) {
|
|
796
835
|
const view = rx;
|
|
@@ -818,6 +857,15 @@ export default class PacketWire {
|
|
|
818
857
|
weight: pdfWeight(pages, document.bytes),
|
|
819
858
|
};
|
|
820
859
|
}
|
|
860
|
+
const audio = view?.audio;
|
|
861
|
+
if (audio !== undefined && typeof audio.mimetype === "string" && Number.isSafeInteger(audio.bytes)) {
|
|
862
|
+
const duration = typeof audio.duration === "number" && Number.isFinite(audio.duration) && audio.duration >= 0 ? audio.duration : null;
|
|
863
|
+
return {
|
|
864
|
+
contentHash, coordinate, path, scheme, pathname, mimetype: audio.mimetype, kind: "audio",
|
|
865
|
+
...(duration === null ? {} : { duration }),
|
|
866
|
+
weight: audioWeight(duration, audio.bytes),
|
|
867
|
+
};
|
|
868
|
+
}
|
|
821
869
|
return null;
|
|
822
870
|
}
|
|
823
871
|
// {§packet-attachment-parts} — the wire form with native parts: user text first, then each accepted
|
|
@@ -871,10 +919,10 @@ export default class PacketWire {
|
|
|
871
919
|
}
|
|
872
920
|
// {§packet-git-status}: the count line, then one bounded line per non-empty class. Untracked paths are
|
|
873
921
|
// named because they are NOT members ({§membership-baseline}) — a human `git add`s or picks them.
|
|
874
|
-
static #GIT_PATHS_PER_CLASS = 8;
|
|
875
922
|
static #renderGitState(git) {
|
|
876
923
|
const sync = git.ahead > 0 || git.behind > 0 ? ` (↑${git.ahead} ↓${git.behind})` : "";
|
|
877
|
-
const
|
|
924
|
+
const position = git.branch === null ? "detached HEAD" : `branch \`${git.branch}\`${git.unborn ? " (no commits)" : ""}`;
|
|
925
|
+
const head = `${position}${sync} — ${git.staged} staged, ${git.unstaged} unstaged, ${git.untracked} untracked`;
|
|
878
926
|
const files = git.files ?? [];
|
|
879
927
|
const path = (p) => `\`${p}\``;
|
|
880
928
|
const untracked = files.filter((f) => f.status === "??");
|
|
@@ -888,8 +936,9 @@ export default class PacketWire {
|
|
|
888
936
|
const lines = classes
|
|
889
937
|
.filter(([, items]) => items.length > 0)
|
|
890
938
|
.map(([label, items]) => {
|
|
891
|
-
const
|
|
892
|
-
const
|
|
939
|
+
const paths = GitState.renderedPaths();
|
|
940
|
+
const shown = items.slice(0, paths).join(" · ");
|
|
941
|
+
const more = items.length > paths ? ` (+${items.length - paths} more)` : "";
|
|
893
942
|
return `${label}: ${shown}${more}`;
|
|
894
943
|
});
|
|
895
944
|
return [head, ...lines].join("\n");
|