@plurnk/plurnk-service 1.29.0 → 3.0.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 +14 -33
- package/INSTALL.md +68 -17
- package/README.md +9 -7
- package/SPEC.md +503 -741
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts.map +1 -1
- package/dist/content/body-preview.js +11 -2
- package/dist/content/body-preview.js.map +1 -1
- 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/line-marker.js +1 -1
- package/dist/content/line-marker.js.map +1 -1
- package/dist/content/path-mimetype.js +1 -1
- package/dist/content/path-mimetype.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 +4 -3
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +19 -17
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +2 -2
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts +1 -0
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +12 -0
- 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 +15 -21
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Engine.d.ts +2 -2
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +4 -3
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/EnvFlags.d.ts.map +1 -1
- package/dist/core/EnvFlags.js +4 -3
- package/dist/core/EnvFlags.js.map +1 -1
- package/dist/core/ExecutorRegistry.d.ts +3 -17
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +6 -6
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/FabricatedLog.js +1 -1
- package/dist/core/FabricatedLog.js.map +1 -1
- package/dist/core/HostPaths.d.ts +2 -1
- package/dist/core/HostPaths.d.ts.map +1 -1
- package/dist/core/HostPaths.js +14 -2
- package/dist/core/HostPaths.js.map +1 -1
- package/dist/core/KillHandler.js +1 -1
- package/dist/core/KillHandler.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.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +4 -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 +6 -6
- 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 +49 -119
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +15 -0
- 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/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 +5 -4
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +11 -12
- package/dist/core/SchemeRegistry.js.map +1 -1
- 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 +12 -6
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.js +1 -1
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +1 -7
- package/dist/core/TurnDispositionHandler.js.map +1 -1
- package/dist/core/TurnMaterialization.js +1 -1
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnOps.d.ts +1 -1
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +4 -12
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +1 -2
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +85 -81
- package/dist/core/TurnRunner.js.map +1 -1
- 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/caps/DbNotifyCaps.js +2 -2
- package/dist/core/caps/DbNotifyCaps.js.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +1 -1
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/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/env-defaults.d.ts +2 -1
- package/dist/core/env-defaults.d.ts.map +1 -1
- package/dist/core/env-defaults.js +17 -9
- package/dist/core/env-defaults.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 +2 -11
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +31 -111
- 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/scheme-types.d.ts +2 -1
- package/dist/core/scheme-types.d.ts.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 +14 -0
- package/dist/evidence/EvidenceReader.d.ts.map +1 -0
- package/dist/evidence/EvidenceReader.js +137 -0
- package/dist/evidence/EvidenceReader.js.map +1 -0
- package/dist/{digest → evidence}/digest.sql +1 -2
- 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/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +19 -26
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +11 -17
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +14 -11
- package/dist/schemes/Log.js.map +1 -1
- 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/{Skill.d.ts → ResourceTreeScheme.d.ts} +5 -6
- package/dist/schemes/ResourceTreeScheme.d.ts.map +1 -0
- package/dist/schemes/{Skill.js → ResourceTreeScheme.js} +63 -43
- package/dist/schemes/ResourceTreeScheme.js.map +1 -0
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +7 -9
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +1 -1
- package/dist/schemes/_entry-find.js +2 -2
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-find.sql +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 +1 -1
- 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/server/AgentRoots.d.ts +2 -1
- package/dist/server/AgentRoots.d.ts.map +1 -1
- package/dist/server/AgentRoots.js +13 -10
- package/dist/server/AgentRoots.js.map +1 -1
- package/dist/server/ConfigurationDiagnostics.d.ts +5 -3
- package/dist/server/ConfigurationDiagnostics.d.ts.map +1 -1
- package/dist/server/ConfigurationDiagnostics.js +24 -8
- package/dist/server/ConfigurationDiagnostics.js.map +1 -1
- package/dist/server/Daemon.d.ts +25 -16
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +137 -96
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +1 -4
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +1 -11
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts +3 -5
- package/dist/server/EnvFunctionality.d.ts.map +1 -1
- package/dist/server/EnvFunctionality.js +5 -7
- package/dist/server/EnvFunctionality.js.map +1 -1
- package/dist/server/Functionality.d.ts +3 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +43 -14
- 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 +2 -0
- package/dist/server/HttpListener.d.ts.map +1 -1
- package/dist/server/HttpListener.js +23 -9
- 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/ModuleHost.d.ts +33 -0
- package/dist/server/ModuleHost.d.ts.map +1 -0
- package/dist/server/ModuleHost.js +2 -0
- package/dist/server/ModuleHost.js.map +1 -0
- package/dist/server/PlurnkSkill.d.ts.map +1 -1
- package/dist/server/PlurnkSkill.js +54 -6
- package/dist/server/PlurnkSkill.js.map +1 -1
- package/dist/server/ServiceModules.d.ts +0 -2
- package/dist/server/ServiceModules.d.ts.map +1 -1
- package/dist/server/ServiceModules.js +5 -9
- package/dist/server/ServiceModules.js.map +1 -1
- package/dist/server/WorkspacePlugins.d.ts +2 -11
- package/dist/server/WorkspacePlugins.d.ts.map +1 -1
- package/dist/server/WorkspacePlugins.js.map +1 -1
- package/dist/server/WorkspaceResidency.d.ts +2 -1
- package/dist/server/WorkspaceResidency.d.ts.map +1 -1
- package/dist/server/WorkspaceStorage.d.ts.map +1 -1
- package/dist/server/WorkspaceStorage.js +7 -4
- 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 +2 -13
- 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 +6 -6
- 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/module-discovery.d.ts +11 -3
- package/dist/server/module-discovery.d.ts.map +1 -1
- package/dist/server/module-discovery.js +32 -18
- package/dist/server/module-discovery.js.map +1 -1
- package/dist/server/seam-proposal-list.sql +6 -4
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +58 -65
- package/dist/service.js.map +1 -1
- package/migrations/003_loops.sql +2 -2
- package/migrations/006_log.sql +1 -1
- package/migrations/016_selection_statements.sql +44 -0
- package/migrations/017_skills_module.sql +6 -0
- package/migrations/018_worker_owners.sql +102 -0
- package/migrations/019_interactive_owners.sql +6 -0
- package/migrations/020_log_projection.sql +143 -0
- package/package.json +71 -76
- package/dist/core/EmissionHead.d.ts +0 -8
- package/dist/core/EmissionHead.d.ts.map +0 -1
- package/dist/core/EmissionHead.js +0 -29
- package/dist/core/EmissionHead.js.map +0 -1
- 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/core/operation-target-groups.d.ts +0 -3
- package/dist/core/operation-target-groups.d.ts.map +0 -1
- package/dist/core/operation-target-groups.js +0 -77
- package/dist/core/operation-target-groups.js.map +0 -1
- package/dist/digest/Digest.d.ts +0 -10
- package/dist/digest/Digest.d.ts.map +0 -1
- package/dist/digest/Digest.js +0 -252
- package/dist/digest/Digest.js.map +0 -1
- package/dist/digest/DigestEvidence.d.ts +0 -11
- package/dist/digest/DigestEvidence.d.ts.map +0 -1
- package/dist/digest/DigestEvidence.js +0 -66
- package/dist/digest/DigestEvidence.js.map +0 -1
- package/dist/digest/DigestRender.d.ts +0 -18
- package/dist/digest/DigestRender.d.ts.map +0 -1
- package/dist/digest/DigestRender.js +0 -1044
- package/dist/digest/DigestRender.js.map +0 -1
- package/dist/digest/DigestRequiem.d.ts +0 -13
- package/dist/digest/DigestRequiem.d.ts.map +0 -1
- package/dist/digest/DigestRequiem.js +0 -337
- package/dist/digest/DigestRequiem.js.map +0 -1
- package/dist/digest/digest-db.d.ts +0 -3
- package/dist/digest/digest-db.d.ts.map +0 -1
- package/dist/digest/digest-db.js +0 -68
- package/dist/digest/digest-db.js.map +0 -1
- package/dist/digest/digest-paths.d.ts +0 -6
- package/dist/digest/digest-paths.d.ts.map +0 -1
- package/dist/digest/digest-paths.js +0 -14
- package/dist/digest/digest-paths.js.map +0 -1
- package/dist/digest/digest-rows.d.ts +0 -346
- package/dist/digest/digest-rows.d.ts.map +0 -1
- package/dist/digest/digest-rows.js +0 -2
- package/dist/digest/digest-rows.js.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/schemes/Skill.d.ts.map +0 -1
- package/dist/schemes/Skill.js.map +0 -1
- package/dist/server/DaemonModule.d.ts +0 -101
- package/dist/server/DaemonModule.d.ts.map +0 -1
- package/dist/server/DaemonModule.js +0 -2
- package/dist/server/DaemonModule.js.map +0 -1
- package/dist/server/SkillSource.d.ts +0 -37
- package/dist/server/SkillSource.d.ts.map +0 -1
- package/dist/server/SkillSource.js +0 -267
- package/dist/server/SkillSource.js.map +0 -1
- package/dist/server/SkillsFunctionality.d.ts +0 -45
- package/dist/server/SkillsFunctionality.d.ts.map +0 -1
- package/dist/server/SkillsFunctionality.js +0 -405
- package/dist/server/SkillsFunctionality.js.map +0 -1
- package/dist/server/skills-problems.d.ts +0 -8
- package/dist/server/skills-problems.d.ts.map +0 -1
- package/dist/server/skills-problems.js +0 -18
- package/dist/server/skills-problems.js.map +0 -1
- package/dist/share/Share.d.ts +0 -15
- package/dist/share/Share.d.ts.map +0 -1
- package/dist/share/Share.js +0 -106
- package/dist/share/Share.js.map +0 -1
- package/dist/share/share.sql +0 -6
- package/docs/skills.md +0 -73
package/dist/core/TurnRunner.js
CHANGED
|
@@ -2,7 +2,7 @@ var _a;
|
|
|
2
2
|
import NativeContent from "./NativeContent.js";
|
|
3
3
|
import { PlurnkParser } from "@plurnk/plurnk-parser";
|
|
4
4
|
import { PathSyntax, PlurnkParseError, TurnDisposition, UNKNOWN_POSITION } from "@plurnk/plurnk-contracts";
|
|
5
|
-
import
|
|
5
|
+
import WorkerOwners from "./WorkerOwners.js";
|
|
6
6
|
import { setTimeout as delay } from "node:timers/promises";
|
|
7
7
|
import { aggregateProviderAccounting } from "@plurnk/plurnk-providers";
|
|
8
8
|
const comparePosition = (a, b) => a.line - b.line || a.column - b.column;
|
|
@@ -35,7 +35,6 @@ import { RECEIPT_RESERVE, reserved } from "./ContextFit.js";
|
|
|
35
35
|
import Results, { OperationFailureError } from "./results.js";
|
|
36
36
|
import Turn from "./Turn.js";
|
|
37
37
|
import ProviderRecovery from "./ProviderRecovery.js";
|
|
38
|
-
import PacketBuilder from "./PacketBuilder.js";
|
|
39
38
|
import StoredPacket from "./StoredPacket.js";
|
|
40
39
|
import { observed, observedSync } from "../observe/spans.js";
|
|
41
40
|
import { genAiRequestName, genAiRequestOptions, settleGenAiResponse } from "../observe/genai.js";
|
|
@@ -43,7 +42,6 @@ import { PROVIDER_CALLS, recordCounter } from "../observe/metrics.js";
|
|
|
43
42
|
import ModelCall, { ModelCallPersistenceError, ProviderAccountingIntegrityError } from "./ModelCall.js";
|
|
44
43
|
import WorkerName from "./WorkerName.js";
|
|
45
44
|
import TurnOps from "./TurnOps.js";
|
|
46
|
-
import CapabilityPolicies from "./CapabilityPolicies.js";
|
|
47
45
|
import CapabilityResolver from "./CapabilityResolver.js";
|
|
48
46
|
const regexLiteral = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
49
47
|
const workerCatalogTarget = (namespace) => {
|
|
@@ -270,18 +268,15 @@ class TurnRunner {
|
|
|
270
268
|
// {§packet-attachment-parts}: native parts come from the READ's immutable snapshot,
|
|
271
269
|
// never from a source that may have changed since the observation.
|
|
272
270
|
async #wireMessages(packet, ctx, provider) {
|
|
273
|
-
// {§packet-wire-envelope} — each emission row the packet placed carries its emission as the
|
|
274
|
-
// worker's own assistant message.
|
|
275
|
-
const emissions = this.#packets.emissionsFor(packet);
|
|
276
271
|
const accepted = acceptedKinds(provider.inputModalities);
|
|
277
272
|
if (accepted.length === 0 || !(packet.attachments ?? []).some((attachment) => accepted.includes(attachment.kind))) {
|
|
278
273
|
return {
|
|
279
|
-
messages: PacketWire.packetToWireMessages(packet
|
|
274
|
+
messages: PacketWire.packetToWireMessages(packet),
|
|
280
275
|
nativeInputs: [],
|
|
281
276
|
};
|
|
282
277
|
}
|
|
283
278
|
const nativeInputs = new Set();
|
|
284
|
-
const messages = await PacketWire.wireMessages(packet,
|
|
279
|
+
const messages = await PacketWire.wireMessages(packet, async (attachment) => {
|
|
285
280
|
const bytes = await NativeContent.read(ctx.db, attachment.contentHash);
|
|
286
281
|
nativeInputs.add(attachment.coordinate);
|
|
287
282
|
return bytes;
|
|
@@ -300,8 +295,6 @@ class TurnRunner {
|
|
|
300
295
|
const createdTurnIds = [];
|
|
301
296
|
const turnSignal = this.#loopSignal(loopId) ?? signal;
|
|
302
297
|
try {
|
|
303
|
-
// {§configuration-repair-path} — a retired packet knob refuses inference before any turn opens.
|
|
304
|
-
PacketBuilder.assertConfiguration();
|
|
305
298
|
const container = await this.#openTurnContainer(args, createdTurnIds);
|
|
306
299
|
const gitStatus = await this.#deriveWorkspace(args, container.systemCtx);
|
|
307
300
|
if (container.initializationTurn !== null)
|
|
@@ -312,7 +305,7 @@ class TurnRunner {
|
|
|
312
305
|
if (admitted.overflow !== null)
|
|
313
306
|
return await this.#failCuration(admitted.request, admitted.overflow);
|
|
314
307
|
const request = admitted.request;
|
|
315
|
-
const attempts = await this.#prepareProviderAttempts(args, request);
|
|
308
|
+
const attempts = await this.#prepareProviderAttempts(args, request, admitted.wire);
|
|
316
309
|
let emission;
|
|
317
310
|
try {
|
|
318
311
|
emission = await this.#attemptProvider(args, request, attempts);
|
|
@@ -376,7 +369,7 @@ class TurnRunner {
|
|
|
376
369
|
createdTurnIds.push(initializationTurn.id);
|
|
377
370
|
const initializationPolicies = initializationTurn === null
|
|
378
371
|
? []
|
|
379
|
-
: (await
|
|
372
|
+
: (await this.#capabilities.layers(workspaceId, workerId)).map((layer) => layer.policy);
|
|
380
373
|
const modelTurn = initializationTurn === null
|
|
381
374
|
? await Turn.open(this.#db, { loopId, producer: "model", kind: "inference" })
|
|
382
375
|
: null;
|
|
@@ -473,17 +466,11 @@ class TurnRunner {
|
|
|
473
466
|
await this.#warmWorkspace(systemCtx, true, false);
|
|
474
467
|
return gitStatus;
|
|
475
468
|
}
|
|
476
|
-
// {§worker-initialization-entry}
|
|
477
|
-
// itself: the actual orienting operations and ordinary NOTEs, executed as a
|
|
478
|
-
// complete turn before the model boundary.
|
|
469
|
+
// {§worker-initialization-entry}: execute the initialization program before the model boundary.
|
|
479
470
|
async #runInitializationTurn(args, container, initializationTurn, gitStatus) {
|
|
480
471
|
const { workspaceId, workerId, loopId, onDispatch, onSettled } = args;
|
|
481
472
|
const { initializationStatements, initializationPolicies } = container;
|
|
482
|
-
//
|
|
483
|
-
// Nine bodyless FIND surveys in the worker's packetless initialization turn establish the Agent
|
|
484
|
-
// Skills, the plurnk references, the enabled tools, agents, and members, then the project, commons,
|
|
485
|
-
// named scratch, and the worker's own reasoning, in that order.
|
|
486
|
-
// Their `init` classification lets the model curate this opening survey as one log set.
|
|
473
|
+
// {§actor-boundary-catalog-preview}: `init` lets the model curate the opening surveys as one set.
|
|
487
474
|
// {§operator-config-workspace-files-items} — workspace filesItems replaces the env default.
|
|
488
475
|
const { filesItems: workspaceMI } = await WorkspaceSettings.read(this.#db, workspaceId);
|
|
489
476
|
const filesItems = workspaceMI !== null ? normalizeFilesItems(workspaceMI) : readFilesItems();
|
|
@@ -518,7 +505,7 @@ class TurnRunner {
|
|
|
518
505
|
turnId: initializationTurn.id,
|
|
519
506
|
fromSequence: 1,
|
|
520
507
|
failOnOperationError: true,
|
|
521
|
-
fit: this.#fitFor(args, { turnId: initializationTurn.id, seq: initializationTurn.sequence, gitStatus, notices: [], transientOpenLogEntryId: container.transientOpenLogEntryId, bodiless: new Set() }),
|
|
508
|
+
fit: this.#fitFor(args, { turnId: initializationTurn.id, seq: initializationTurn.sequence, gitStatus, notices: [], transientOpenLogEntryId: container.transientOpenLogEntryId, projection: { bodiless: new Set(), omitPreviousEmission: false } }),
|
|
522
509
|
signal: this.#loopSignal(loopId),
|
|
523
510
|
onDispatch,
|
|
524
511
|
onSettled,
|
|
@@ -548,8 +535,8 @@ class TurnRunner {
|
|
|
548
535
|
matcher: null, body: null, lineMarker: { marks: [1, -1] }, position: UNKNOWN_POSITION,
|
|
549
536
|
},
|
|
550
537
|
{
|
|
551
|
-
// {§tools-resource-materialization} — enabled
|
|
552
|
-
//
|
|
538
|
+
// {§tools-resource-materialization} — enabled MCP runtimes
|
|
539
|
+
// survey one row per server; each row's summary is
|
|
553
540
|
// the server one-liner or its flagship invocation form, so the
|
|
554
541
|
// discovery row itself orients. Servers named in
|
|
555
542
|
// PLURNK_MCP_EXPANDED add a second survey of their complete
|
|
@@ -598,20 +585,12 @@ class TurnRunner {
|
|
|
598
585
|
metadata: null,
|
|
599
586
|
matcher: null, body: null, lineMarker: null, position: UNKNOWN_POSITION,
|
|
600
587
|
},
|
|
601
|
-
{
|
|
602
|
-
// {§worker-initialization-entry} — the worker's own reasoning is an addressable, searchable
|
|
603
|
-
// space from the first packet: surveyed by name, never read back.
|
|
604
|
-
op: "FIND", aside: "this worker's reasoning, by loop and turn",
|
|
605
|
-
target: { kind: "url", raw: `reasoning://${workerName}/**`, scheme: "reasoning", username: null, password: null, hostname: workerName, port: null, pathname: "/**", query: null, fragment: null },
|
|
606
|
-
metadata: null,
|
|
607
|
-
matcher: null, body: null, lineMarker: null, position: UNKNOWN_POSITION,
|
|
608
|
-
},
|
|
609
588
|
];
|
|
610
589
|
return surveys.filter(({ target }) => this.#schemes.get(target?.kind === "url" ? target.scheme : "file", workspaceId) !== undefined);
|
|
611
590
|
}
|
|
612
|
-
// {§tools-resource-materialization} — expanded
|
|
591
|
+
// {§tools-resource-materialization} — expanded runtimes project complete
|
|
613
592
|
// invocation blocks, paged through ordinary FIND result ranges: one pattern FIND
|
|
614
|
-
// per
|
|
593
|
+
// per runtime, naming the admitted tools when the policy narrows them.
|
|
615
594
|
#toolExpansions(workspaceId, policies) {
|
|
616
595
|
const registry = this.#executors();
|
|
617
596
|
const expansions = [];
|
|
@@ -652,7 +631,7 @@ class TurnRunner {
|
|
|
652
631
|
const systemCtx = this.#schemeContext(args, turnId);
|
|
653
632
|
// {§context-fit} — one measure for everything this turn lands: the budget less the packet as it
|
|
654
633
|
// would render now. The drained notices join the same facts below.
|
|
655
|
-
const facts = { turnId, seq, gitStatus, notices: [], transientOpenLogEntryId: container.transientOpenLogEntryId, bodiless: new Set() };
|
|
634
|
+
const facts = { turnId, seq, gitStatus, notices: [], transientOpenLogEntryId: container.transientOpenLogEntryId, projection: { bodiless: new Set(), omitPreviousEmission: false } };
|
|
656
635
|
const fit = this.#fitFor(args, facts);
|
|
657
636
|
const messages = await this.#publishMessages(args, turnId, fit);
|
|
658
637
|
let nextActionIndex = await this.#readOpenPaths(args, turnId, messages.openPaths, messages.nextActionIndex, fit);
|
|
@@ -734,8 +713,9 @@ class TurnRunner {
|
|
|
734
713
|
}
|
|
735
714
|
return nextActionIndex;
|
|
736
715
|
}
|
|
737
|
-
#buildPacket(
|
|
738
|
-
|
|
716
|
+
async #buildPacket(args, facts) {
|
|
717
|
+
const { messages, recap, workspaceId, workerId, loopId, provider } = args;
|
|
718
|
+
const packet = await this.#packets.buildRequestPacket({
|
|
739
719
|
initialMessages: messages,
|
|
740
720
|
recap,
|
|
741
721
|
workspaceId,
|
|
@@ -747,8 +727,16 @@ class TurnRunner {
|
|
|
747
727
|
notices: facts.notices,
|
|
748
728
|
transientOpenLogEntryId: facts.transientOpenLogEntryId,
|
|
749
729
|
turnId: facts.turnId,
|
|
750
|
-
bodiless: facts.bodiless,
|
|
730
|
+
bodiless: facts.projection.bodiless,
|
|
731
|
+
omitPreviousEmission: facts.projection.omitPreviousEmission,
|
|
751
732
|
});
|
|
733
|
+
// {§previous-emission}: all builds, including result-admission probes, shed the optional
|
|
734
|
+
// replay before taking result bodies. Share the decision across this request's rebuilds.
|
|
735
|
+
if (PacketWire.sectionContent(packet, "previous-emission").length > 0 && this.#packets.windowOverflow(packet, provider) !== null) {
|
|
736
|
+
facts.projection.omitPreviousEmission = true;
|
|
737
|
+
return this.#buildPacket(args, facts);
|
|
738
|
+
}
|
|
739
|
+
return packet;
|
|
752
740
|
}
|
|
753
741
|
// {§context-fit} — the budget left for one more row, measured by building the packet as it would
|
|
754
742
|
// render now: every row landed so far, every KILL already honoured. Null without a budget.
|
|
@@ -774,41 +762,61 @@ class TurnRunner {
|
|
|
774
762
|
const packet = await this.#buildPacket(args, request);
|
|
775
763
|
return { ...request, nextActionIndex: request.nextActionIndex + 1, packet };
|
|
776
764
|
}
|
|
777
|
-
//
|
|
778
|
-
//
|
|
779
|
-
//
|
|
780
|
-
// as receipts.
|
|
765
|
+
// {§context-admission} — one request through the room: over the wall by the estimate, it sheds; over
|
|
766
|
+
// budget, it carries one row whose own weight takes the same wall ({§context-over-budget-row}); then the
|
|
767
|
+
// provider assesses the exact wire request, and an exact refusal sheds by its excess
|
|
768
|
+
// ({§context-wall-measure}). Only a packet that cannot fit even as receipts returns its overflow.
|
|
781
769
|
async #admitPacket(args, request) {
|
|
782
|
-
const
|
|
783
|
-
if (fitted.overflow !== null)
|
|
784
|
-
return fitted;
|
|
785
|
-
if (this.#packets.curationOverflow(fitted.request.packet) === null)
|
|
786
|
-
return fitted;
|
|
787
|
-
return await this.#fitOwnRows(args, await this.#noteOverBudget(args, fitted.request));
|
|
788
|
-
}
|
|
789
|
-
// {§context-own-rows-fit} — while the packet is over the wall ({§context-wall}), the newest rows still
|
|
790
|
-
// carrying a body are taken, enough of them by their rendered tokens to shed the excess, and the packet
|
|
791
|
-
// is rebuilt with them bodiless; every body stays stored. The rebuilt packet is measured again until
|
|
792
|
-
// it fits, or until no row is left to take.
|
|
793
|
-
async #fitOwnRows(args, request) {
|
|
770
|
+
const { provider, loopId, signal } = args;
|
|
794
771
|
let current = request;
|
|
772
|
+
let noted = false;
|
|
795
773
|
for (;;) {
|
|
796
|
-
const
|
|
797
|
-
if (
|
|
798
|
-
|
|
774
|
+
const estimated = this.#packets.windowOverflow(current.packet, provider);
|
|
775
|
+
if (estimated !== null) {
|
|
776
|
+
const shed = await this.#shed(args, current, estimated);
|
|
777
|
+
if (shed === null)
|
|
778
|
+
return { request: current, wire: null, overflow: estimated };
|
|
779
|
+
current = shed;
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (!noted && this.#packets.curationOverflow(current.packet) !== null) {
|
|
783
|
+
current = await this.#noteOverBudget(args, current);
|
|
784
|
+
noted = true;
|
|
785
|
+
continue;
|
|
786
|
+
}
|
|
787
|
+
const wire = await this.#wireMessages(current.packet, current.systemCtx, provider);
|
|
788
|
+
const capacity = await provider.assessRequestCapacity(wire.messages, undefined, this.#loopSignal(loopId) ?? signal);
|
|
789
|
+
const refused = this.#packets.exactOverflow(current.packet, capacity);
|
|
790
|
+
if (refused === null)
|
|
791
|
+
return { request: current, wire, overflow: null };
|
|
792
|
+
const shed = await this.#shed(args, current, refused);
|
|
793
|
+
if (shed === null)
|
|
794
|
+
return { request: current, wire: null, overflow: refused };
|
|
795
|
+
current = shed;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
// {§context-own-rows-fit} — one shedding step for whichever measure found the request over the wall: the
|
|
799
|
+
// previous program goes whole first ({§previous-emission}), then the newest rows still carrying a body,
|
|
800
|
+
// enough of them by their rendered tokens to shed the excess; every body stays stored. Null when nothing
|
|
801
|
+
// is left to take.
|
|
802
|
+
async #shed(args, request, overflow) {
|
|
803
|
+
if (!request.projection.omitPreviousEmission && PacketWire.sectionContent(request.packet, "previous-emission").length > 0) {
|
|
804
|
+
request.projection.omitPreviousEmission = true;
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
799
807
|
let shed = 0;
|
|
800
808
|
let taken = 0;
|
|
801
|
-
for (const { id, tokens } of this.#packets.bodiedRowsOf(
|
|
809
|
+
for (const { id, tokens } of this.#packets.bodiedRowsOf(request.packet).toReversed()) {
|
|
802
810
|
if (shed >= overflow.excessWeight)
|
|
803
811
|
break;
|
|
804
|
-
|
|
812
|
+
request.projection.bodiless.add(id);
|
|
805
813
|
shed += tokens;
|
|
806
814
|
taken += 1;
|
|
807
815
|
}
|
|
808
816
|
if (taken === 0)
|
|
809
|
-
return
|
|
810
|
-
current = { ...current, packet: await this.#buildPacket(args, current) };
|
|
817
|
+
return null;
|
|
811
818
|
}
|
|
819
|
+
return { ...request, packet: await this.#buildPacket(args, request) };
|
|
812
820
|
}
|
|
813
821
|
// {§context-wall} — the packet cannot fit the window even as receipts: the turn completes on the
|
|
814
822
|
// overflow and the loop rules the terminal; no provider I/O.
|
|
@@ -819,8 +827,7 @@ class TurnRunner {
|
|
|
819
827
|
}
|
|
820
828
|
// Phase 4's bookkeeping: the wire request, the recovery knobs, the signal the
|
|
821
829
|
// provider sees, the client id and the worker's provider identity.
|
|
822
|
-
async #prepareProviderAttempts({
|
|
823
|
-
const wire = await this.#wireMessages(request.packet, request.systemCtx, provider);
|
|
830
|
+
async #prepareProviderAttempts({ workerId, loopId, signal }, request, wire) {
|
|
824
831
|
// {§provider-recovery} — this turn's recovery clock: the first recoverable provider
|
|
825
832
|
// failure starts it; the budget and backoff are the operator's.
|
|
826
833
|
const recoveryBudget = ProviderRecovery.budget();
|
|
@@ -852,9 +859,8 @@ class TurnRunner {
|
|
|
852
859
|
};
|
|
853
860
|
}
|
|
854
861
|
// Phase 4 — the provider attempt loop. Each iteration is one logical call: a
|
|
855
|
-
// recoverable failure
|
|
856
|
-
//
|
|
857
|
-
// ({§invalid-emission-attempts}).
|
|
862
|
+
// recoverable failure re-issues the same emission attempt, an invalid emission
|
|
863
|
+
// spends one, and a valid emission ends the loop ({§invalid-emission-attempts}).
|
|
858
864
|
async #attemptProvider(args, request, attempts) {
|
|
859
865
|
const { provider, workspaceId, workerId, loopId, signal } = args;
|
|
860
866
|
// {§turn-lifecycle}: bracket the complete provider-attempt window with liveness notices.
|
|
@@ -913,14 +919,13 @@ class TurnRunner {
|
|
|
913
919
|
return emission;
|
|
914
920
|
}
|
|
915
921
|
// One logical provider call: its durable model call and attempt row, the exchange
|
|
916
|
-
// under the reasoning observer, and its classification.
|
|
917
|
-
//
|
|
918
|
-
//
|
|
922
|
+
// under the reasoning observer, and its classification. {§provider-recovery}
|
|
923
|
+
// re-issues the same emission attempt; the parser's admission is the one verdict
|
|
924
|
+
// on a completed exchange.
|
|
919
925
|
async #issueProviderCall(args, request, attempts, attempt, strikeStreak) {
|
|
920
926
|
const { provider, workspaceId, workerId, loopId } = args;
|
|
921
|
-
//
|
|
922
|
-
//
|
|
923
|
-
// call still receives its own durable sequence and accounting.
|
|
927
|
+
// A recovery re-issue does not consume a grammar-emission attempt. Every
|
|
928
|
+
// logical provider call still receives its own durable sequence and accounting.
|
|
924
929
|
attempts.currentEmissionAttempt = attempt;
|
|
925
930
|
attempts.modelCallSequence++;
|
|
926
931
|
const attributionContext = Object.freeze({
|
|
@@ -959,8 +964,8 @@ class TurnRunner {
|
|
|
959
964
|
await this.#recoverProviderFailure(args, request, attempts, modelCall, attemptRow.id, error);
|
|
960
965
|
return "reissued";
|
|
961
966
|
}
|
|
962
|
-
// {§context-wall} —
|
|
963
|
-
//
|
|
967
|
+
// {§context-wall-measure} — admission already shed for an exact refusal of this wire request;
|
|
968
|
+
// an upstream refusal is the provider's own 413.
|
|
964
969
|
throw error;
|
|
965
970
|
}
|
|
966
971
|
finally {
|
|
@@ -1195,14 +1200,12 @@ class TurnRunner {
|
|
|
1195
1200
|
if (attempts.parked) {
|
|
1196
1201
|
// {§provider-recovery} — the recovery budget is spent: the loop parks exactly like a
|
|
1197
1202
|
// [202] wait and resumes on the next prompt or wake; the failure stays durable.
|
|
1198
|
-
|
|
1199
|
-
// and the notice says that rather than promising a resumption nobody can deliver.
|
|
1200
|
-
const { attended } = await LoopPolicyReader.read(this.#db, loopId);
|
|
1203
|
+
const recoverable = await WorkerOwners.interactive(this.#db, loopId);
|
|
1201
1204
|
this.#notices.push(workspaceId, workerId, loopId, {
|
|
1202
1205
|
source: "engine:provider",
|
|
1203
1206
|
kind: "provider_unavailable",
|
|
1204
1207
|
level: "error",
|
|
1205
|
-
message: `${recorded.result.problem?.title ?? "Provider failure"}: the ${Math.round(attempts.recoveryBudget / 1000)}s recovery budget is spent; ${
|
|
1208
|
+
message: `${recorded.result.problem?.title ?? "Provider failure"}: the ${Math.round(attempts.recoveryBudget / 1000)}s recovery budget is spent; ${recoverable ? "the loop is parked and resumes on the next prompt or wake" : "nobody attends the worker's owner, so the loop ends here"}.`,
|
|
1206
1209
|
});
|
|
1207
1210
|
return turnResult(request, 202, { providerParked: true, providerFailure: recorded.result, emissionAttempts });
|
|
1208
1211
|
}
|
|
@@ -1377,6 +1380,7 @@ class TurnRunner {
|
|
|
1377
1380
|
async #settleAdmittedTurn(args, request, emission) {
|
|
1378
1381
|
const { childProvider, workspaceId, workerId, loopId, onDispatch, onSettled } = args;
|
|
1379
1382
|
const { split } = emission;
|
|
1383
|
+
const coordinates = { workerName: request.workerName, loopSeq: request.loopSeq, turnSeq: request.seq };
|
|
1380
1384
|
// {§operator-config-workspace-max-commands} — workspace maxCommands
|
|
1381
1385
|
// narrows the operator ceiling before the admitted program reaches the
|
|
1382
1386
|
// shared executor.
|
|
@@ -1385,10 +1389,10 @@ class TurnRunner {
|
|
|
1385
1389
|
statements: split.packetAssistant.ops,
|
|
1386
1390
|
source: split.sourceBacked ? split.packetAssistant.content : null,
|
|
1387
1391
|
emission: split.emissionStatements === null ? null : {
|
|
1388
|
-
content: TurnOps.renderEmission(split.emissionStatements
|
|
1389
|
-
|
|
1390
|
-
reasoning: split.packetAssistant.reasoning ?? null, // {§reasoning-row}
|
|
1392
|
+
content: TurnOps.renderEmission(split.emissionStatements),
|
|
1393
|
+
...coordinates,
|
|
1391
1394
|
},
|
|
1395
|
+
reasoning: split.packetAssistant.reasoning ? { content: split.packetAssistant.reasoning, ...coordinates } : null,
|
|
1392
1396
|
sourceModelCallId: emission.modelCallId,
|
|
1393
1397
|
origin: "model",
|
|
1394
1398
|
workspaceId,
|
|
@@ -1593,7 +1597,7 @@ class TurnRunner {
|
|
|
1593
1597
|
emissionStatements,
|
|
1594
1598
|
};
|
|
1595
1599
|
}
|
|
1596
|
-
// #note12 —
|
|
1600
|
+
// #note12 — extension reference docs are materialized beneath
|
|
1597
1601
|
// worker:///_plurnk/plurnk/ by LoopDocs.
|
|
1598
1602
|
// {§exec-lifetime} — a `"turn"` lifetime: abort the worker's open turn-scoped streams via their
|
|
1599
1603
|
// owning scheme (the same registry-routed abort the total reap uses). Called at each pre-turn
|