@plurnk/plurnk-service 2.0.0 → 3.1.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 +27 -19
- package/INSTALL.md +21 -2
- package/README.md +4 -2
- package/SPEC.md +644 -467
- package/dist/build-info.json +1 -1
- package/dist/completions/_plurnk-service +13 -0
- package/dist/completions/plurnk-service.bash +19 -0
- package/dist/completions/plurnk-service.fish +93 -0
- package/dist/content/edit-receipt.d.ts +1 -1
- package/dist/content/edit-receipt.d.ts.map +1 -1
- package/dist/content/edit-receipt.js +1 -1
- package/dist/content/edit-receipt.js.map +1 -1
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +3 -12
- package/dist/content/read-projector.js.map +1 -1
- package/dist/core/AdministrativeLoop.d.ts +1 -1
- package/dist/core/AdministrativeLoop.d.ts.map +1 -1
- package/dist/core/AdministrativeLoop.js +2 -6
- package/dist/core/AdministrativeLoop.js.map +1 -1
- package/dist/core/AdmittedTurnExecutor.d.ts +2 -2
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +16 -24
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts +8 -2
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +48 -5
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +2 -4
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +3 -23
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +9 -2
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +34 -5
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +0 -2
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ClientInteractions.d.ts +3 -2
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +21 -12
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/ClientInteractions.sql +8 -2
- package/dist/core/CoreSchemeServices.d.ts +1 -0
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +1 -0
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.js +1 -1
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +3 -2
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +55 -52
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Engine.d.ts +1 -1
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +4 -6
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/EnvFlags.d.ts.map +1 -1
- package/dist/core/EnvFlags.js +5 -4
- package/dist/core/EnvFlags.js.map +1 -1
- package/dist/core/FabricatedLog.d.ts +1 -0
- package/dist/core/FabricatedLog.d.ts.map +1 -1
- package/dist/core/FabricatedLog.js +9 -1
- package/dist/core/FabricatedLog.js.map +1 -1
- package/dist/core/HostPaths.d.ts +0 -1
- package/dist/core/HostPaths.d.ts.map +1 -1
- package/dist/core/HostPaths.js +0 -2
- package/dist/core/HostPaths.js.map +1 -1
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +3 -1
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/LiveSubscription.d.ts.map +1 -1
- package/dist/core/LiveSubscription.js +14 -2
- package/dist/core/LiveSubscription.js.map +1 -1
- package/dist/core/LiveSubscriptions.d.ts +3 -1
- package/dist/core/LiveSubscriptions.d.ts.map +1 -1
- package/dist/core/LiveSubscriptions.js +16 -1
- package/dist/core/LiveSubscriptions.js.map +1 -1
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +3 -1
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +8 -17
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LoopDriver.js +7 -6
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +4 -9
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +7 -6
- package/dist/core/MessageResources.sql +31 -0
- package/dist/core/OperatorConfig.d.ts +1 -0
- package/dist/core/OperatorConfig.d.ts.map +1 -1
- package/dist/core/OperatorConfig.js +10 -2
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts +5 -7
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +160 -158
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +20 -6
- package/dist/core/ProposalLifecycle.d.ts +1 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +18 -20
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProposalPolicies.d.ts +6 -0
- package/dist/core/ProposalPolicies.d.ts.map +1 -0
- package/dist/core/ProposalPolicies.js +28 -0
- package/dist/core/ProposalPolicies.js.map +1 -0
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +3 -4
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReplyMetadata.d.ts +10 -0
- package/dist/core/ReplyMetadata.d.ts.map +1 -0
- package/dist/core/ReplyMetadata.js +20 -0
- package/dist/core/ReplyMetadata.js.map +1 -0
- package/dist/core/ResourceSelector.js +2 -2
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.js +3 -3
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/RuntimeWorker.sql +1 -2
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +4 -5
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/ServiceHelp.d.ts +6 -0
- package/dist/core/ServiceHelp.d.ts.map +1 -0
- package/dist/core/ServiceHelp.js +35 -0
- package/dist/core/ServiceHelp.js.map +1 -0
- package/dist/core/StoredPacket.d.ts +1 -0
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +4 -1
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +2 -2
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/TokenCalibration.d.ts +2 -2
- package/dist/core/TokenCalibration.d.ts.map +1 -1
- package/dist/core/TokenCalibration.js +12 -16
- package/dist/core/TokenCalibration.js.map +1 -1
- package/dist/core/TokenCalibration.sql +29 -6
- package/dist/core/ToolInputSchema.d.ts +1 -0
- package/dist/core/ToolInputSchema.d.ts.map +1 -1
- package/dist/core/ToolInputSchema.js +8 -2
- 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 +7 -1
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/TurnDispositionHandler.d.ts +1 -2
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +31 -33
- package/dist/core/TurnDispositionHandler.js.map +1 -1
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +12 -2
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnOps.d.ts +5 -1
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +29 -2
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +184 -103
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnSources.sql +2 -2
- package/dist/core/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +1 -8
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +1 -0
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +2 -0
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkerName.sql +2 -2
- package/dist/core/WorkerOwners.d.ts +13 -0
- package/dist/core/WorkerOwners.d.ts.map +1 -0
- package/dist/core/WorkerOwners.js +44 -0
- package/dist/core/WorkerOwners.js.map +1 -0
- package/dist/core/WorkerOwners.sql +55 -0
- package/dist/core/env-catalog.d.ts +3 -0
- package/dist/core/env-catalog.d.ts.map +1 -1
- package/dist/core/env-catalog.js +44 -9
- package/dist/core/env-catalog.js.map +1 -1
- package/dist/core/fork.sql +3 -4
- package/dist/core/packet-inject.js +0 -2
- package/dist/core/packet-inject.js.map +1 -1
- package/dist/core/packet-wire.d.ts +9 -11
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +103 -126
- 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 +4 -4
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/recap-lines.d.ts +4 -0
- package/dist/core/recap-lines.d.ts.map +1 -0
- package/dist/core/recap-lines.js +11 -0
- package/dist/core/recap-lines.js.map +1 -0
- package/dist/core/scheme-types.d.ts +2 -1
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/sql-functions.d.ts +2 -0
- package/dist/core/sql-functions.d.ts.map +1 -0
- package/dist/core/sql-functions.js +5 -0
- package/dist/core/sql-functions.js.map +1 -0
- package/dist/core/turn-scheduler.d.ts.map +1 -1
- package/dist/core/turn-scheduler.js +1 -1
- package/dist/core/turn-scheduler.js.map +1 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/unregistered-scheme.d.ts +1 -3
- package/dist/core/unregistered-scheme.d.ts.map +1 -1
- package/dist/core/unregistered-scheme.js +3 -11
- package/dist/core/unregistered-scheme.js.map +1 -1
- package/dist/evidence/EvidenceReader.d.ts.map +1 -1
- package/dist/evidence/EvidenceReader.js +18 -2
- package/dist/evidence/EvidenceReader.js.map +1 -1
- package/dist/evidence/digest.sql +2 -2
- package/dist/man/plurnk-service.1 +488 -0
- package/dist/schemes/EffectPolicy.d.ts.map +1 -1
- package/dist/schemes/EffectPolicy.js +1 -10
- package/dist/schemes/EffectPolicy.js.map +1 -1
- package/dist/schemes/Env.d.ts +26 -0
- package/dist/schemes/Env.d.ts.map +1 -0
- package/dist/schemes/Env.js +133 -0
- package/dist/schemes/Env.js.map +1 -0
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +30 -37
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +3 -2
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +9 -0
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +10 -16
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +33 -10
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Log.sql +9 -0
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +1 -3
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +6 -8
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-find.d.ts +1 -1
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +16 -9
- 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 +3 -9
- package/dist/schemes/_entry-fts.js.map +1 -1
- package/dist/schemes/_entry-manifest.js +3 -3
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-ops.js +1 -1
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/exec-abort.js +2 -2
- package/dist/schemes/exec-abort.js.map +1 -1
- package/dist/server/ConfigurationDiagnostics.d.ts +1 -0
- package/dist/server/ConfigurationDiagnostics.d.ts.map +1 -1
- package/dist/server/ConfigurationDiagnostics.js +9 -0
- package/dist/server/ConfigurationDiagnostics.js.map +1 -1
- package/dist/server/Daemon.d.ts +13 -8
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +57 -53
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +2 -4
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +5 -12
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts +6 -6
- package/dist/server/EnvFunctionality.d.ts.map +1 -1
- package/dist/server/EnvFunctionality.js +7 -6
- package/dist/server/EnvFunctionality.js.map +1 -1
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +42 -13
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +3 -4
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +17 -9
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/HttpListener.d.ts.map +1 -1
- package/dist/server/HttpListener.js +9 -3
- package/dist/server/HttpListener.js.map +1 -1
- package/dist/server/MembersFunctionality.d.ts +2 -5
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +5 -3
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/WorkspaceStorage.d.ts +0 -1
- package/dist/server/WorkspaceStorage.d.ts.map +1 -1
- package/dist/server/WorkspaceStorage.js +1 -24
- package/dist/server/WorkspaceStorage.js.map +1 -1
- package/dist/server/client-input.d.ts +1 -2
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +13 -15
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +1 -1
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +16 -15
- package/dist/server/envelope.d.ts +2 -1
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +7 -17
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +5 -5
- package/dist/server/seam-proposal-list.sql +6 -4
- package/dist/server/workspace-storage.sql +0 -5
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +28 -64
- package/dist/service.js.map +1 -1
- package/docs/env.md +22 -0
- package/migrations/003_loops.sql +2 -2
- package/migrations/006_log.sql +1 -1
- package/migrations/016_selection_statements.sql +1 -0
- package/migrations/017_skills_module.sql +1 -0
- package/migrations/018_worker_owners.sql +103 -0
- package/migrations/019_interactive_owners.sql +7 -0
- package/migrations/020_log_projection.sql +144 -0
- package/migrations/021_packet_roles.sql +86 -0
- package/migrations/022_message_completion.sql +24 -0
- package/package.json +41 -43
- package/dist/core/LegacyHome.d.ts +0 -10
- package/dist/core/LegacyHome.d.ts.map +0 -1
- package/dist/core/LegacyHome.js +0 -170
- package/dist/core/LegacyHome.js.map +0 -1
- package/dist/core/LoopPolicies.d.ts +0 -7
- package/dist/core/LoopPolicies.d.ts.map +0 -1
- package/dist/core/LoopPolicies.js +0 -42
- package/dist/core/LoopPolicies.js.map +0 -1
- package/dist/core/LoopPolicyReader.d.ts +0 -7
- package/dist/core/LoopPolicyReader.d.ts.map +0 -1
- package/dist/core/LoopPolicyReader.js +0 -33
- package/dist/core/LoopPolicyReader.js.map +0 -1
- package/dist/core/LoopPolicyReader.sql +0 -6
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-catalog.d.ts","sourceRoot":"","sources":["../../src/core/env-catalog.ts"],"names":[],"mappings":"AAWA,OAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"env-catalog.d.ts","sourceRoot":"","sources":["../../src/core/env-catalog.ts"],"names":[],"mappings":"AAWA,OAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAStE,MAAM,WAAW,eAAe;IAE5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC5B;AAKD,UAAU,WAAW;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,OAAO,UAAU;;IAI3B,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAWxD;IAGD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE/C;IAGD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErC;IAID,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAiB3E;IAWD,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,EAAE,KAAK,GAAE,eAAoB,GAAG,SAAS;QACxF,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/D,UAAU,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;KACnE,EAAE,CA0BF;IAYD,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,EAAE,KAAK,GAAE,eAAoB,GAAG,MAAM,CAcrF;CACJ"}
|
package/dist/core/env-catalog.js
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
// including names nothing declares. The catalog answers a different question — which keys have a
|
|
11
11
|
// CONSUMER. `FOO=bar` is valid and nothing reads it; `PAGER=less` is valid and something does.
|
|
12
12
|
import EnvDefaults from "./env-defaults.js";
|
|
13
|
+
// A declaration line: `KEY=value` is live, `# KEY=value` optional. A `<placeholder>` segment in the
|
|
14
|
+
// name declares a family of keys ({§operator-config-undeclared-key}), only ever written commented.
|
|
15
|
+
const DECLARATION = /^#?\s*([A-Za-z_][A-Za-z0-9_]*(?:<[^<>\s=]+>[A-Za-z0-9_]*)*)=/u;
|
|
16
|
+
const PLACEHOLDER = /<[^<>\s=]+>/gu;
|
|
17
|
+
// What a placeholder, or the scope after a declared name's `_`, stands for: an alias, a name, a tag.
|
|
18
|
+
const SEGMENT = "[\\p{L}\\p{N}_.-]+";
|
|
13
19
|
export default class EnvCatalog {
|
|
14
20
|
// Declarations in file order, each carrying the comment lines that introduce it. A commented
|
|
15
21
|
// declaration (`# PLURNK_EXECS_ONLY=sh,jq`) is an optional knob, not prose, so it is a
|
|
@@ -18,22 +24,48 @@ export default class EnvCatalog {
|
|
|
18
24
|
const out = [];
|
|
19
25
|
let pending = [];
|
|
20
26
|
for (const line of text.split("\n")) {
|
|
21
|
-
const
|
|
22
|
-
|
|
27
|
+
const name = EnvCatalog.declaredName(line);
|
|
28
|
+
// A blank line, or a comment that is not an assignment, introduces whatever comes next.
|
|
29
|
+
if (name === null) {
|
|
23
30
|
pending.push(line);
|
|
24
31
|
continue;
|
|
25
32
|
}
|
|
26
|
-
|
|
27
|
-
// A comment that is not an assignment introduces whatever comes next.
|
|
28
|
-
if (assignment === null) {
|
|
29
|
-
pending.push(line);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
out.push({ name: assignment[1], text: [...pending, line].join("\n") });
|
|
33
|
+
out.push({ name, text: [...pending, line].join("\n") });
|
|
33
34
|
pending = [];
|
|
34
35
|
}
|
|
35
36
|
return out;
|
|
36
37
|
}
|
|
38
|
+
// The name one panel line declares, or null for prose. Every reader of a panel shares it.
|
|
39
|
+
static declaredName(line) {
|
|
40
|
+
return DECLARATION.exec(line.trim())?.[1] ?? null;
|
|
41
|
+
}
|
|
42
|
+
// The declaration grammar admits `<` only to open a placeholder.
|
|
43
|
+
static isFamily(name) {
|
|
44
|
+
return name.includes("<");
|
|
45
|
+
}
|
|
46
|
+
// {§operator-config-undeclared-key} Whether an installed package declares a key: by name, as a
|
|
47
|
+
// declared name's `_` scope (a per-alias knob, `PLURNK_MODEL_<alias>`), or as a family member.
|
|
48
|
+
static declares(files) {
|
|
49
|
+
const names = new Set();
|
|
50
|
+
const families = [];
|
|
51
|
+
for (const { text } of files) {
|
|
52
|
+
for (const { name } of EnvCatalog.declarations(text)) {
|
|
53
|
+
if (EnvCatalog.isFamily(name))
|
|
54
|
+
families.push(new RegExp(`^${name.replaceAll(PLACEHOLDER, SEGMENT)}$`, "u"));
|
|
55
|
+
else
|
|
56
|
+
names.add(name);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const scope = new RegExp(`^${SEGMENT}$`, "u");
|
|
60
|
+
const scoped = (key) => {
|
|
61
|
+
for (let at = key.indexOf("_"); at !== -1; at = key.indexOf("_", at + 1)) {
|
|
62
|
+
if (names.has(key.slice(0, at)) && scope.test(key.slice(at + 1)))
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
67
|
+
return (key) => names.has(key) || scoped(key) || families.some((family) => family.test(key));
|
|
68
|
+
}
|
|
37
69
|
// The name, or the comment that documents it — a Worker looks for a variable by what it is
|
|
38
70
|
// for ("search") before it knows what it is called. Never the value: a value match would
|
|
39
71
|
// surface a value the model did not ask to see — the catalog carries shipped defaults rather
|
|
@@ -49,6 +81,9 @@ export default class EnvCatalog {
|
|
|
49
81
|
const out = [];
|
|
50
82
|
for (const file of selected) {
|
|
51
83
|
for (const declaration of EnvCatalog.declarations(file.text)) {
|
|
84
|
+
// A family is no name a Worker can set; only its members are.
|
|
85
|
+
if (EnvCatalog.isFamily(declaration.name))
|
|
86
|
+
continue;
|
|
52
87
|
if (term !== undefined && !EnvCatalog.#matches(declaration, term))
|
|
53
88
|
continue;
|
|
54
89
|
const lines = declaration.text.split("\n");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-catalog.js","sourceRoot":"","sources":["../../src/core/env-catalog.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,iGAAiG;AACjG,wDAAwD;AACxD,EAAE;AACF,+FAA+F;AAC/F,+FAA+F;AAC/F,8EAA8E;AAC9E,EAAE;AACF,gGAAgG;AAChG,iGAAiG;AACjG,+FAA+F;AAC/F,OAAO,WAAqC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"env-catalog.js","sourceRoot":"","sources":["../../src/core/env-catalog.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,iGAAiG;AACjG,wDAAwD;AACxD,EAAE;AACF,+FAA+F;AAC/F,+FAA+F;AAC/F,8EAA8E;AAC9E,EAAE;AACF,gGAAgG;AAChG,iGAAiG;AACjG,+FAA+F;AAC/F,OAAO,WAAqC,MAAM,mBAAmB,CAAC;AAEtE,oGAAoG;AACpG,mGAAmG;AACnG,MAAM,WAAW,GAAG,+DAA+D,CAAC;AACpF,MAAM,WAAW,GAAG,eAAe,CAAC;AACpC,qGAAqG;AACrG,MAAM,OAAO,GAAG,oBAAoB,C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EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;QAC9F,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACnE,MAAM,QAAQ,GAAG,QAAQ;aACpB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACZ,GAAG,IAAI;YACP,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;iBACnC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;iBAC/D,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;iBACvB,IAAI,CAAC,IAAI,CAAC;SAClB,CAAC,CAAC;aACF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnD,OAAO,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;CACJ"}
|
package/dist/core/fork.sql
CHANGED
|
@@ -14,12 +14,12 @@ BEGIN
|
|
|
14
14
|
-- Loops: inherited history, never live work — a non-terminal status is clamped to 200 and
|
|
15
15
|
-- given a plain success result ({§machine-processes-fork-copies-the-log}).
|
|
16
16
|
INSERT INTO loops (
|
|
17
|
-
worker_id, sequence, status, prompt,
|
|
17
|
+
worker_id, sequence, status, prompt, model_route_id,
|
|
18
18
|
spawn_model_route_id, effort, max_turns, terminal_result
|
|
19
19
|
)
|
|
20
20
|
SELECT NEW.id, l.sequence,
|
|
21
21
|
CASE WHEN l.status IN (200, 413, 429, 499, 500, 504, 508) THEN l.status ELSE 200 END,
|
|
22
|
-
l.prompt, l.
|
|
22
|
+
l.prompt, l.model_route_id, l.spawn_model_route_id, l.effort, l.max_turns,
|
|
23
23
|
CASE WHEN l.status IN (200, 413, 429, 499, 500, 504, 508) THEN l.terminal_result ELSE '{"status":200}' END
|
|
24
24
|
FROM loops l
|
|
25
25
|
WHERE l.worker_id = NEW.parent_worker_id
|
|
@@ -93,8 +93,7 @@ BEGIN
|
|
|
93
93
|
WHERE e.worker_id = NEW.parent_worker_id
|
|
94
94
|
ORDER BY e.id;
|
|
95
95
|
|
|
96
|
-
-- Current projection: membership and folded intervals.
|
|
97
|
-
-- ({§context-output-selection}) stay at their defaults on the fork.
|
|
96
|
+
-- Current projection: membership and folded intervals.
|
|
98
97
|
UPDATE log_entry_projections
|
|
99
98
|
SET active = source.active,
|
|
100
99
|
folded = source.folded
|
|
@@ -30,6 +30,4 @@ export const readSystemPolicy = async () => {
|
|
|
30
30
|
const env = raw?.trim();
|
|
31
31
|
return readPolicy(env ? resolveInjectPath(env) : new HostPaths().policyFile, !!env);
|
|
32
32
|
};
|
|
33
|
-
// Project policy is retired from the system slot: the project AGENTS.md now
|
|
34
|
-
// rides turn 0 as the foisted AGENTS.md entry ({§turn0-agents-stunt}).
|
|
35
33
|
//# sourceMappingURL=packet-inject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packet-inject.js","sourceRoot":"","sources":["../../src/core/packet-inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAEvC,2FAA2F;AAC3F,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAU,EAAE,CACrD,IAAI,SAAS,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;A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,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AACxF,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PacketAttachment, RequestPacket } from "./StoredPacket.ts";
|
|
2
2
|
import type { ChatMessage } from "@plurnk/plurnk-providers";
|
|
3
|
+
import { type PacketSectionDraft } from "@plurnk/plurnk-schemes";
|
|
3
4
|
interface ActionTarget {
|
|
4
5
|
kind?: unknown;
|
|
5
6
|
raw?: unknown;
|
|
@@ -86,6 +87,10 @@ interface RenderLogOptions {
|
|
|
86
87
|
readonly acceptedAttachmentKinds?: ReadonlySet<PacketAttachment["kind"]>;
|
|
87
88
|
readonly projectRoot?: string | null;
|
|
88
89
|
readonly bodiless?: ReadonlySet<number>;
|
|
90
|
+
readonly legend?: ReadonlyMap<string, ReadonlyArray<{
|
|
91
|
+
path: string;
|
|
92
|
+
tokens: number;
|
|
93
|
+
}>>;
|
|
89
94
|
}
|
|
90
95
|
interface ReclaimableLogItem {
|
|
91
96
|
readonly path: string;
|
|
@@ -100,30 +105,23 @@ export interface RenderedLog {
|
|
|
100
105
|
readonly records: readonly string[];
|
|
101
106
|
readonly curationTargets: readonly ReclaimableLogItem[];
|
|
102
107
|
readonly attachments: readonly PacketAttachment[];
|
|
103
|
-
readonly emissions: readonly RenderedEmission[];
|
|
104
108
|
readonly bodied: readonly BodiedLogRow[];
|
|
105
109
|
}
|
|
106
|
-
export interface RenderedEmission {
|
|
107
|
-
readonly coordinate: string;
|
|
108
|
-
readonly content: string;
|
|
109
|
-
readonly weight: number;
|
|
110
|
-
}
|
|
111
110
|
export default class PacketWire {
|
|
112
111
|
#private;
|
|
113
|
-
static renderSlot(sections: SectionView[], slot: "
|
|
112
|
+
static renderSlot(sections: SectionView[], slot: PacketSectionDraft["slot"]): string;
|
|
114
113
|
static renderSection(s: SectionView): string;
|
|
115
114
|
static renderFailurePointers(failures: unknown): string;
|
|
116
115
|
static renderNotices(notices: unknown): string;
|
|
117
116
|
static renderDelegation(workers: unknown, streams: unknown): string;
|
|
117
|
+
static renderRecap(lines: readonly string[], source: string): string;
|
|
118
118
|
static renderGit(git: unknown): string;
|
|
119
119
|
static renderLog(entries: unknown, weighContent: WeighContent, options?: RenderLogOptions): string;
|
|
120
120
|
static renderLogWithAccounting(entries: unknown, weighContent: WeighContent, options?: RenderLogOptions): RenderedLog;
|
|
121
121
|
static sectionContent(packet: Packet, name: string): string;
|
|
122
|
-
static packetToWireMessages(packet: Packet
|
|
122
|
+
static packetToWireMessages(packet: Packet): Array<ChatMessage & {
|
|
123
123
|
content: string;
|
|
124
124
|
}>;
|
|
125
|
-
static deliveredEmission(frozen: string): string;
|
|
126
|
-
static placedEmissions(sections: readonly SectionView[], emissions: ReadonlyMap<string, string>): string[];
|
|
127
125
|
static isArrival(e: {
|
|
128
126
|
readonly op?: unknown;
|
|
129
127
|
readonly origin?: unknown;
|
|
@@ -131,7 +129,7 @@ export default class PacketWire {
|
|
|
131
129
|
}): boolean;
|
|
132
130
|
static entryView(r: StoredLogRow, transientOpenLogEntryId?: number | null): LogEntryView;
|
|
133
131
|
static rowTokens(view: LogEntryView, weighContent: WeighContent, options?: RenderLogOptions): number;
|
|
134
|
-
static wireMessages(packet: RequestPacket,
|
|
132
|
+
static wireMessages(packet: RequestPacket, bytesOf: (attachment: PacketAttachment) => Promise<Uint8Array>, accepts?: (kind: PacketAttachment["kind"]) => boolean): Promise<ChatMessage[]>;
|
|
135
133
|
static attachmentCaption(attachment: PacketAttachment): string;
|
|
136
134
|
}
|
|
137
135
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packet-wire.d.ts","sourceRoot":"","sources":["../../src/core/packet-wire.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK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;IAID,MAAM,CAAC,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,GAAE,gBAAqB,GAAG,WAAW,CAaxH;IAKD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1D;IAsBD,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,WAAW,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAIpF;IA6LD,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAI3G;IAkHD,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,EAAE,uBAAuB,GAAE,MAAM,GAAG,IAAW,GAAG,YAAY,CA6C7F;IAID,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAIvG;IAicD,OAAa,YAAY,CACrB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,OAAO,CAAC,UAAU,CAAC,EAC9D,OAAO,GAAE,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,OAAoB,GAClE,OAAO,CAAC,WAAW,EAAE,CAAC,CA0CxB;IAID,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAM7D;CAgEJ"}
|
package/dist/core/packet-wire.js
CHANGED
|
@@ -46,21 +46,24 @@ export default class PacketWire {
|
|
|
46
46
|
.map((row) => JSON.stringify({ status: row.status, path: `log:///${row.coordinate}` }));
|
|
47
47
|
return pointers.length === 0 ? "" : `[${pointers.join(",\n")}]`;
|
|
48
48
|
}
|
|
49
|
-
//
|
|
50
|
-
//
|
|
49
|
+
// {§notice-callout} — non-terminal observations, deliberately separate from operation failures, in the
|
|
50
|
+
// card's own callout form: the level picks the callout, the directive leads, the fact follows, the kind closes.
|
|
51
51
|
static renderNotices(notices) {
|
|
52
52
|
const observations = Array.isArray(notices) ? notices : [];
|
|
53
53
|
return observations.map((notice) => {
|
|
54
54
|
const kind = typeof notice.kind === "string" ? notice.kind : "notice";
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const callout = notice.level === "error" ? "CAUTION" : notice.level === "warn" ? "WARNING" : "NOTE";
|
|
56
|
+
const text = [notice.directive, notice.message]
|
|
57
|
+
.filter((part) => typeof part === "string")
|
|
58
|
+
.map((part) => part.replace(/\s+/g, " ").trim())
|
|
59
|
+
.filter((part) => part.length > 0)
|
|
60
|
+
.join(" ");
|
|
59
61
|
const position = notice.position?.type === "content-offset"
|
|
60
62
|
? ` @ ${String(notice.position.line)}:${String(notice.position.column)}`
|
|
61
63
|
: "";
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
const body = `${text}${position}`.trim();
|
|
65
|
+
return `> [!${callout}]\n> ${body.length > 0 ? `${body} ` : ""}[${kind}]`;
|
|
66
|
+
}).join("\n\n");
|
|
64
67
|
}
|
|
65
68
|
// The Delegation section ({§child-orientation}) — the OPPOSITE of advice: terse `{status, path}`
|
|
66
69
|
// JSON pointers (same shape as the errors section) to the live things the worker holds, under the
|
|
@@ -79,6 +82,11 @@ export default class PacketWire {
|
|
|
79
82
|
}));
|
|
80
83
|
return pointers.length === 0 ? "[]" : `[${pointers.join(",\n")}]`;
|
|
81
84
|
}
|
|
85
|
+
// {§recap-lines} — each operator line is one callout, typed by its directive, ahead of the recap source.
|
|
86
|
+
static renderRecap(lines, source) {
|
|
87
|
+
const callouts = lines.map((line) => `> [!${line.startsWith("YOU MUST") ? "IMPORTANT" : "TIP"}]\n> ${line}`);
|
|
88
|
+
return [...callouts, ...(source.trim().length > 0 ? [source] : [])].join("\n\n");
|
|
89
|
+
}
|
|
82
90
|
// The git section content: the working-tree summary. "" when absent.
|
|
83
91
|
static renderGit(git) {
|
|
84
92
|
const status = git === null || git === undefined ? "" : PacketWire.#renderGitState(git);
|
|
@@ -95,7 +103,7 @@ export default class PacketWire {
|
|
|
95
103
|
static renderLogWithAccounting(entries, weighContent, options = {}) {
|
|
96
104
|
const log = Array.isArray(entries) ? entries : [];
|
|
97
105
|
if (log.length === 0)
|
|
98
|
-
return { content: "", records: [], curationTargets: [], attachments: [],
|
|
106
|
+
return { content: "", records: [], curationTargets: [], attachments: [], bodied: [] };
|
|
99
107
|
const rows = PacketWire.#renderLogEntries(log, weighContent, options);
|
|
100
108
|
const records = rows.map(({ content }) => content);
|
|
101
109
|
return {
|
|
@@ -103,7 +111,6 @@ export default class PacketWire {
|
|
|
103
111
|
records,
|
|
104
112
|
curationTargets: rows.flatMap(({ curationTarget }) => curationTarget === null ? [] : [curationTarget]),
|
|
105
113
|
attachments: rows.flatMap(({ attachment }) => attachment === null ? [] : [attachment]),
|
|
106
|
-
emissions: rows.flatMap(({ emission }) => emission === null ? [] : [emission]),
|
|
107
114
|
bodied: rows.flatMap(({ bodied }) => bodied === null ? [] : [bodied]),
|
|
108
115
|
};
|
|
109
116
|
}
|
|
@@ -111,100 +118,42 @@ export default class PacketWire {
|
|
|
111
118
|
// The legible accessor — consumers name the section they want instead of
|
|
112
119
|
// indexing a fixed shape. Missing section / non-string content → "".
|
|
113
120
|
static sectionContent(packet, name) {
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
return (packet.sections ?? [])
|
|
122
|
+
.filter((section) => PacketWire.#isSection(section, name) && typeof section.content === "string" && section.content.length > 0)
|
|
123
|
+
.map(({ content }) => content).join("\n\n");
|
|
116
124
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
125
|
+
static #isSection(section, name) {
|
|
126
|
+
return section.name === name || typeof section.name === "string" && section.name.startsWith(`${name}/`);
|
|
127
|
+
}
|
|
128
|
+
// {§packet-wire-envelope}: retained roles and order, not today's section names, define a
|
|
129
|
+
// historical request. An absent previous program leaves adjacent user sections together.
|
|
130
|
+
static #messageSections(packet) {
|
|
122
131
|
const sections = packet.sections ?? [];
|
|
123
|
-
const messages = [{ role: "system",
|
|
124
|
-
let pending = [];
|
|
132
|
+
const messages = [{ role: "system", sections: sections.filter(({ slot }) => slot === "system") }];
|
|
125
133
|
for (const section of sections) {
|
|
126
|
-
if (section.slot
|
|
127
|
-
continue;
|
|
128
|
-
const rendered = PacketWire.renderSection(section);
|
|
129
|
-
if (rendered.length === 0)
|
|
134
|
+
if (section.slot === "system" || PacketWire.renderSection(section).length === 0)
|
|
130
135
|
continue;
|
|
131
|
-
if (section.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const emission = frozen === undefined ? "" : PacketWire.deliveredEmission(frozen);
|
|
139
|
-
// {§emission-row}: an emission of only NOTE and WAIT delivers nothing; its row stands.
|
|
140
|
-
if (emission.length === 0)
|
|
141
|
-
continue;
|
|
142
|
-
messages.push({ role: "user", content: pending.join("\n\n") });
|
|
143
|
-
messages.push({ role: "assistant", content: emission });
|
|
144
|
-
pending = [];
|
|
145
|
-
}
|
|
136
|
+
if (section.slot !== "user" && section.slot !== "assistant")
|
|
137
|
+
throw new TypeError("packet section has an invalid message role");
|
|
138
|
+
const last = messages.at(-1);
|
|
139
|
+
if (last.role === section.slot)
|
|
140
|
+
last.sections.push(section);
|
|
141
|
+
else
|
|
142
|
+
messages.push({ role: section.slot, sections: [section] });
|
|
146
143
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
throw new Error("a request never ends on an emission: nothing follows the last one");
|
|
150
|
-
messages.push({ role: "user", content: closing });
|
|
144
|
+
if (messages.length === 1)
|
|
145
|
+
messages.push({ role: "user", sections: [] });
|
|
151
146
|
return messages;
|
|
152
147
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// than any backtick run inside them, so a block is read back by its fences alone, whatever era froze it.
|
|
158
|
-
static deliveredEmission(frozen) {
|
|
159
|
-
const lines = frozen.split("\n");
|
|
160
|
-
const kept = [];
|
|
161
|
-
for (let index = 0; index < lines.length;) {
|
|
162
|
-
const fence = /^`{3,}/u.exec(lines[index])?.[0];
|
|
163
|
-
if (fence === undefined)
|
|
164
|
-
throw new Error(`an emission block opens with a fence, not ${JSON.stringify(lines[index])}`);
|
|
165
|
-
const end = lines.findIndex((line, at) => at > index && (line === fence || line.startsWith(`${fence} <!-- `)));
|
|
166
|
-
if (end === -1)
|
|
167
|
-
throw new Error("an emission block closes with its own fence");
|
|
168
|
-
const heading = lines[index];
|
|
169
|
-
if (!new RegExp(`^${fence}(?:(?:NOTE|WAIT)\\b|(?:KILL|SEND)(?:\\s+<!--.*-->)?\\s*$)`, "u").test(heading)) {
|
|
170
|
-
kept.push(end > index + 1 ? `${heading}\n${fence}` : `${heading}${fence}`);
|
|
171
|
-
}
|
|
172
|
-
index = end + 2;
|
|
173
|
-
}
|
|
174
|
-
return kept.join("\n\n");
|
|
175
|
-
}
|
|
176
|
-
// {§emission-row} — the coordinates of the emission rows present in the final log section, in order.
|
|
177
|
-
// Every emission row must be announced by the render pass that built the map.
|
|
178
|
-
static placedEmissions(sections, emissions) {
|
|
179
|
-
const log = sections.find((section) => section.slot === "user" && section.name === "log");
|
|
180
|
-
if (log === undefined)
|
|
181
|
-
return [];
|
|
182
|
-
const placed = [];
|
|
183
|
-
for (const { coordinate, leaf } of PacketWire.#logRecords(PacketWire.renderSection(log))) {
|
|
184
|
-
if (coordinate === null)
|
|
185
|
-
continue;
|
|
186
|
-
if (emissions.has(coordinate)) {
|
|
187
|
-
if (placed.includes(coordinate))
|
|
188
|
-
throw new Error(`log:///${coordinate}/emission appears twice in one log section`);
|
|
189
|
-
placed.push(coordinate);
|
|
190
|
-
}
|
|
191
|
-
else if (leaf === "emission") {
|
|
192
|
-
throw new Error(`log:///${coordinate}/emission reached the log section without its emission`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return placed;
|
|
196
|
-
}
|
|
197
|
-
static #logRecords(rendered) {
|
|
198
|
-
return rendered.split(/\n\n(?=### log:\/\/\/)/u).map((content) => {
|
|
199
|
-
const match = /^### log:\/\/\/(\d+\/\d+\/\d+)(?:\/(\S*))?(?=\s|$)/mu.exec(content);
|
|
200
|
-
return { content, coordinate: match?.[1] ?? null, leaf: match?.[2] ?? null };
|
|
201
|
-
});
|
|
148
|
+
static packetToWireMessages(packet) {
|
|
149
|
+
return PacketWire.#messageSections(packet).map(({ role, sections }) => ({
|
|
150
|
+
role, content: PacketWire.renderSlot(sections, role),
|
|
151
|
+
}));
|
|
202
152
|
}
|
|
203
153
|
// Number a non-READ body line as `<N>:<line>` — `N:` followed by NO separator whitespace
|
|
204
154
|
// ({§render-rule-line-navigable-prefix}): the leading digit prevents column-zero fence collisions and gives
|
|
205
155
|
// the model line refs for free (`READ (...) <42-46>`), while the absence of any separator means a
|
|
206
|
-
// reproduced line has nothing between `N:` and the content to copy
|
|
207
|
-
// to leak into edit bodies and corrupt indentation. The content's OWN leading whitespace is
|
|
156
|
+
// reproduced line has nothing between `N:` and the content to copy. The content's OWN leading whitespace is
|
|
208
157
|
// content, preserved verbatim. `N` is left-padded to the body's line-range width so every body
|
|
209
158
|
// keeps one stable content column; FIND rows pass the complete result-set width so their pages
|
|
210
159
|
// share a column with the whole set.
|
|
@@ -294,7 +243,7 @@ export default class PacketWire {
|
|
|
294
243
|
if ("effect" in receipt) {
|
|
295
244
|
return {
|
|
296
245
|
...head,
|
|
297
|
-
change:
|
|
246
|
+
change: `${receipt.unit} -${receipt.effect.removed} +${receipt.effect.inserted}`,
|
|
298
247
|
effect: `${receipt.effect.source} -> ${receipt.effect.result}`,
|
|
299
248
|
// {§edit-receipt-removed-text} — what a deletion took, so it can be put back from the receipt.
|
|
300
249
|
...(receipt.effect.removedText === undefined ? {} : { removed: receipt.effect.removedText }),
|
|
@@ -307,7 +256,7 @@ export default class PacketWire {
|
|
|
307
256
|
...(receipt.replacement === undefined
|
|
308
257
|
? {}
|
|
309
258
|
: {
|
|
310
|
-
change:
|
|
259
|
+
change: `${receipt.unit} -${receipt.replacement.removed} +${receipt.replacement.inserted}`,
|
|
311
260
|
replacement: `${receipt.replacement.source} -> ${receipt.replacement.result}`,
|
|
312
261
|
}),
|
|
313
262
|
};
|
|
@@ -457,8 +406,11 @@ export default class PacketWire {
|
|
|
457
406
|
// Parse rx once — reused for the matcher/items enrichment and the body.
|
|
458
407
|
const rx = (typeof e.rx === "string" ? PacketWire.#safeParse(e.rx) : e.rx);
|
|
459
408
|
const facts = PacketWire.#rowResultFacts(identity, e, rx, bodies[index]);
|
|
460
|
-
const
|
|
461
|
-
|
|
409
|
+
const legend = LogEntryProjection.isEmission(e) ? options.legend?.get(String(e.coordinate).split("/").slice(0, 2).join("/")) : undefined;
|
|
410
|
+
const projected = legend !== undefined && legend.length > 0
|
|
411
|
+
? { body: PacketWire.#frameBody(legend.map(({ path, tokens }, index) => `${index + 1}:${path} · ${tokens}`).join("\n")), projectedLineCount: legend.length, display: "open" }
|
|
412
|
+
: PacketWire.#rowBody(identity, e, bodies[index], visibility[index], facts);
|
|
413
|
+
return PacketWire.#rowAccounting(identity, e, visibility[index], projected, weighContent, options);
|
|
462
414
|
});
|
|
463
415
|
}
|
|
464
416
|
static #attrsOf(e) {
|
|
@@ -604,11 +556,10 @@ export default class PacketWire {
|
|
|
604
556
|
// {§worker-wait-timing} — the accepted bound, not elapsed time or the current configuration.
|
|
605
557
|
if (op === "WAIT" && e.attrs !== null && typeof e.attrs === "object" && "waiting" in e.attrs) {
|
|
606
558
|
const seconds = e.attrs.waiting;
|
|
607
|
-
if (typeof seconds !== "number" || !Number.isFinite(seconds) ||
|
|
559
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds < 0) {
|
|
608
560
|
throw new TypeError("A WAIT receipt carries a malformed waiting bound.");
|
|
609
561
|
}
|
|
610
|
-
|
|
611
|
-
meta.waitSeconds = seconds;
|
|
562
|
+
meta.waitSeconds = seconds;
|
|
612
563
|
}
|
|
613
564
|
// An execution's output is a separate stream entry ({§exec-stream}); its address rides in a
|
|
614
565
|
// `stream` link, distinct from the runtime-owned invocation target.
|
|
@@ -717,9 +668,9 @@ export default class PacketWire {
|
|
|
717
668
|
const sparse = fullBody.lineOrdinals !== undefined
|
|
718
669
|
&& range.returned !== undefined
|
|
719
670
|
&& fullBody.lineOrdinals.length !== range.returned[1] - range.returned[0] + 1;
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
671
|
+
// A row whose Problem does not own the range retrieved successfully, even when it
|
|
672
|
+
// carries its execution's failure: its extent takes the one scope notation.
|
|
673
|
+
meta.range = ScopeFormat.range(range, sparse);
|
|
723
674
|
}
|
|
724
675
|
else if (range === null && !problemOwnsRange && op === "READ" && rx !== null && typeof rx === "object" && rx.region !== undefined) {
|
|
725
676
|
delete meta.scope;
|
|
@@ -777,8 +728,7 @@ export default class PacketWire {
|
|
|
777
728
|
};
|
|
778
729
|
}
|
|
779
730
|
// The body the row shows: the canonical full body, shared with log READ, log FIND and search
|
|
780
|
-
// derivation, whole. Whether a result fit was decided where it landed ({§context-fit})
|
|
781
|
-
// cuts nothing but the emission head ({§emission-row}).
|
|
731
|
+
// derivation, whole. Whether a result fit was decided where it landed ({§context-fit}).
|
|
782
732
|
static #rowBody(identity, e, fullBody, bodyVisibility, facts) {
|
|
783
733
|
const { meta, op } = identity;
|
|
784
734
|
const projectedBody = {
|
|
@@ -855,7 +805,7 @@ export default class PacketWire {
|
|
|
855
805
|
// The row's native attachment, a landed-unfit arrival's size, and the accounting field that
|
|
856
806
|
// participates in the row it measures: iterate until its decimal width and therefore the
|
|
857
807
|
// rendered row's curation weight are stable. {§packet-token-accounting}
|
|
858
|
-
static #rowAccounting(identity, e,
|
|
808
|
+
static #rowAccounting(identity, e, bodyVisibility, projected, weighContent, options) {
|
|
859
809
|
const { meta, op, coordinate, path, target } = identity;
|
|
860
810
|
const { body, display } = projected;
|
|
861
811
|
const nativeCandidate = op === "READ" && typeof e.status === "number" && e.status >= 200 && e.status < 300
|
|
@@ -871,11 +821,6 @@ export default class PacketWire {
|
|
|
871
821
|
const attachment = !(bodyVisibility.totalLines > 0 && bodyVisibility.fullyFolded)
|
|
872
822
|
? native
|
|
873
823
|
: null;
|
|
874
|
-
// {§emission-row}: an emission row carries its frozen emission outside its record, and charges what
|
|
875
|
-
// the wire delivers of it, as the worker's own message, exactly as a native part is charged.
|
|
876
|
-
const emission = LogEntryProjection.isEmission(e) && coordinate !== null
|
|
877
|
-
? { coordinate, content: fullBody.content, weight: weighContent(PacketWire.deliveredEmission(fullBody.content)) }
|
|
878
|
-
: null;
|
|
879
824
|
// {§log-wire-format}: one descriptive heading, the facts, the body.
|
|
880
825
|
const render = (open, tokens) => {
|
|
881
826
|
const lines = [`### ${path}${identity.description === null ? "" : ` ${identity.description}`} · ${tokens}`];
|
|
@@ -892,18 +837,18 @@ export default class PacketWire {
|
|
|
892
837
|
delete meta.tokensAttachment;
|
|
893
838
|
let tokens = 0;
|
|
894
839
|
for (let pass = 0; pass < 8; pass += 1) {
|
|
895
|
-
const next = weighContent(render(open, tokens)) + (part?.weight ?? 0)
|
|
840
|
+
const next = weighContent(render(open, tokens)) + (part?.weight ?? 0);
|
|
896
841
|
if (next === tokens)
|
|
897
842
|
return { content: render(open, tokens), tokens };
|
|
898
843
|
tokens = next;
|
|
899
844
|
}
|
|
900
845
|
throw new Error("packet log row accounting did not converge");
|
|
901
846
|
};
|
|
902
|
-
const row = (rendered, part, bodied) => ({ content: rendered.content, curationTarget: { path, tokens: rendered.tokens }, attachment: part,
|
|
847
|
+
const row = (rendered, part, bodied) => ({ content: rendered.content, curationTarget: { path, tokens: rendered.tokens }, attachment: part, bodied });
|
|
903
848
|
const whole = converge(display === "open", attachment);
|
|
904
849
|
// {§context-own-rows-fit} — a row the wall may take carries a body or a native part and is not an
|
|
905
|
-
// emission row, whose
|
|
906
|
-
if (typeof e.id !== "number" ||
|
|
850
|
+
// emission row, whose folded record carries no body.
|
|
851
|
+
if (typeof e.id !== "number" || LogEntryProjection.isEmission(e) || (display !== "open" && attachment === null))
|
|
907
852
|
return row(whole, attachment, null);
|
|
908
853
|
if (!(options.bodiless?.has(e.id) ?? false))
|
|
909
854
|
return row(whole, attachment, { id: e.id, tokens: whole.tokens });
|
|
@@ -954,21 +899,53 @@ export default class PacketWire {
|
|
|
954
899
|
}
|
|
955
900
|
return null;
|
|
956
901
|
}
|
|
957
|
-
// {§packet-attachment-parts} —
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
const
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
902
|
+
// {§packet-attachment-parts} — project retained native parts at their recorded user boundaries.
|
|
903
|
+
static async wireMessages(packet, bytesOf, accepts = () => true) {
|
|
904
|
+
const messages = PacketWire.packetToWireMessages(packet);
|
|
905
|
+
const attachments = (packet.attachments ?? []).filter(({ kind }) => accepts(kind));
|
|
906
|
+
if (attachments.length === 0)
|
|
907
|
+
return messages;
|
|
908
|
+
const groups = PacketWire.#messageSections(packet);
|
|
909
|
+
// {§packet-attachment-parts}: current packets bind each native part to the section
|
|
910
|
+
// ending at its READ. Preserve the recorded placement of older, unbound packets below.
|
|
911
|
+
if (attachments.some(({ section }) => section !== undefined)) {
|
|
912
|
+
for (const attachment of attachments) {
|
|
913
|
+
if (attachment.section === undefined || !groups.some(({ role, sections }) => role === "user" && sections.some(({ name }) => name === attachment.section))) {
|
|
914
|
+
throw new Error("native packet attachment requires its recorded user section");
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return Promise.all(groups.map(async ({ role, sections }, index) => {
|
|
918
|
+
if (!sections.some(({ name }) => attachments.some(({ section }) => section === name)))
|
|
919
|
+
return messages[index];
|
|
920
|
+
const parts = [];
|
|
921
|
+
for (const [at, section] of sections.entries()) {
|
|
922
|
+
parts.push({ type: "text", text: `${at === 0 ? "" : "\n\n"}${PacketWire.renderSection(section)}` });
|
|
923
|
+
for (const attachment of attachments.filter((attachment) => attachment.section === section.name)) {
|
|
924
|
+
parts.push({ type: "text", text: `\n\n${PacketWire.attachmentCaption(attachment)}` });
|
|
925
|
+
parts.push({ type: "file", data: await bytesOf(attachment), mediaType: attachment.mimetype });
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
return { role, content: parts };
|
|
929
|
+
}));
|
|
930
|
+
}
|
|
931
|
+
const logIndex = groups.findIndex(({ role, sections }) => role === "user" && sections.some(({ name }) => name === "log"));
|
|
932
|
+
const index = logIndex < 0 ? groups.findIndex(({ role }) => role === "user") : logIndex;
|
|
933
|
+
if (index < 0)
|
|
934
|
+
throw new Error("native packet attachments require a user message");
|
|
935
|
+
// {§packet-attachment-parts}: native evidence belongs to the log's message. A retained
|
|
936
|
+
// packet may also hold its previous program in that message; keep its recorded tail.
|
|
937
|
+
const preceding = groups[index].sections.filter(({ name }) => name !== "emission-history");
|
|
938
|
+
const previous = groups[index].sections.find(({ name }) => name === "emission-history");
|
|
939
|
+
const parts = [{ type: "text", text: PacketWire.renderSlot(preceding, "user") }];
|
|
940
|
+
for (const attachment of attachments) {
|
|
967
941
|
const bytes = await bytesOf(attachment);
|
|
968
942
|
parts.push({ type: "text", text: PacketWire.attachmentCaption(attachment) });
|
|
969
943
|
parts.push({ type: "file", data: bytes, mediaType: attachment.mimetype });
|
|
970
944
|
}
|
|
971
|
-
|
|
945
|
+
const tail = previous === undefined ? "" : PacketWire.renderSection(previous);
|
|
946
|
+
if (tail.length > 0)
|
|
947
|
+
parts.push({ type: "text", text: `\n\n${tail}` });
|
|
948
|
+
return messages.map((message, at) => at === index ? { role: "user", content: parts } : message);
|
|
972
949
|
}
|
|
973
950
|
// {§packet-attachment-parts} — the part's identity: a native part on the user turn otherwise reads as
|
|
974
951
|
// an arrival, and the model cannot tell that the READ row is what keeps it in the packet.
|