@agimon-ai/po-core 0.0.0-alpha.2 → 0.0.0-alpha.21
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/LICENSE +149 -21
- package/NOTICE +41 -0
- package/dist/agentModel.cjs +1 -1
- package/dist/agentModel.d.mts +2 -2
- package/dist/agentModel.mjs +1 -2
- package/dist/apiContracts.cjs +623 -802
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +277 -615
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +617 -794
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/askUser.cjs +2 -2
- package/dist/askUser.d.mts +2 -2
- package/dist/askUser.mjs +1 -2
- package/dist/authorTools.mjs +1 -2
- package/dist/backgroundWork.cjs +3 -3
- package/dist/backgroundWork.d.mts +2 -2
- package/dist/backgroundWork.mjs +1 -2
- package/dist/bundleAssetPolicy.mjs +1 -2
- package/dist/chatgptAuth.cjs +3 -2
- package/dist/chatgptAuth.d.mts +3 -2
- package/dist/chatgptAuth.mjs +2 -1
- package/dist/childProcess.cjs +1 -1
- package/dist/childProcess.d.mts +2 -2
- package/dist/childProcess.mjs +1 -2
- package/dist/childSession.cjs +11 -6
- package/dist/childSession.d.mts +3 -3
- package/dist/childSession.mjs +3 -3
- package/dist/cockpitContainer.mjs +1 -2
- package/dist/config.cjs +1 -1
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -2
- package/dist/contextApi.cjs +1 -0
- package/dist/contextApi.d.mts +2 -2
- package/dist/contextApi.mjs +2 -2
- package/dist/contextContributions.cjs +4 -4
- package/dist/contextContributions.d.mts +3 -3
- package/dist/contextContributions.mjs +3 -3
- package/dist/contextDetailStore.cjs +7 -5
- package/dist/contextDetailStore.cjs.map +1 -1
- package/dist/contextDetailStore.d.mts +2 -1
- package/dist/contextDetailStore.d.mts.map +1 -1
- package/dist/contextDetailStore.mjs +6 -4
- package/dist/contextDetailStore.mjs.map +1 -1
- package/dist/contextProjection.cjs +7 -2
- package/dist/contextProjection.cjs.map +1 -1
- package/dist/contextProjection.d.mts +4 -1
- package/dist/contextProjection.d.mts.map +1 -1
- package/dist/contextProjection.mjs +5 -2
- package/dist/contextProjection.mjs.map +1 -1
- package/dist/cordisHost.cjs +11 -11
- package/dist/cordisHost.d.mts +2 -2
- package/dist/cordisHost.mjs +1 -2
- package/dist/delegation.cjs +8 -8
- package/dist/delegation.d.mts +2 -2
- package/dist/delegation.mjs +1 -2
- package/dist/executionBudget.cjs +4 -3
- package/dist/executionBudget.cjs.map +1 -1
- package/dist/executionBudget.d.mts +2 -2
- package/dist/executionBudget.d.mts.map +1 -1
- package/dist/executionBudget.mjs +4 -3
- package/dist/executionBudget.mjs.map +1 -1
- package/dist/extensionFile.cjs +5 -0
- package/dist/extensionFile.d.mts +4 -2
- package/dist/extensionFile.mjs +4 -2
- package/dist/footer.d.mts +2 -2
- package/dist/footer.mjs +1 -2
- package/dist/headless.cjs +14 -14
- package/dist/headless.d.mts +2 -2
- package/dist/headless.mjs +1 -2
- package/dist/headlessHub.cjs +308 -109
- package/dist/headlessHub.cjs.map +1 -1
- package/dist/headlessHub.d.mts +71 -36
- package/dist/headlessHub.d.mts.map +1 -1
- package/dist/headlessHub.mjs +309 -110
- package/dist/headlessHub.mjs.map +1 -1
- package/dist/headlessProtocol.cjs +327 -0
- package/dist/headlessProtocol.cjs.map +1 -0
- package/dist/headlessProtocol.d.mts +30 -0
- package/dist/headlessProtocol.d.mts.map +1 -0
- package/dist/headlessProtocol.mjs +326 -0
- package/dist/headlessProtocol.mjs.map +1 -0
- package/dist/headlessServer.cjs +166 -151
- package/dist/headlessServer.cjs.map +1 -1
- package/dist/headlessServer.d.mts +13 -5
- package/dist/headlessServer.d.mts.map +1 -1
- package/dist/headlessServer.mjs +166 -151
- package/dist/headlessServer.mjs.map +1 -1
- package/dist/headlessSessionHost.d.mts +58 -21
- package/dist/headlessSessionHost.d.mts.map +1 -1
- package/dist/help.cjs +20 -20
- package/dist/help.d.mts +2 -2
- package/dist/help.mjs +2 -2
- package/dist/history.cjs +16 -20
- package/dist/history.d.mts +9 -7
- package/dist/history.mjs +6 -7
- package/dist/historyOwnership.cjs.map +1 -1
- package/dist/historyOwnership.d.mts +1 -1
- package/dist/historyOwnership.mjs.map +1 -1
- package/dist/hubChannel.cjs +9 -0
- package/dist/hubChannel.d.mts +3 -2
- package/dist/hubChannel.mjs +3 -2
- package/dist/index.cjs +26 -28
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +6 -6
- package/dist/interop/chord.mjs +1 -0
- package/dist/interop/chordContext.mjs +1 -0
- package/dist/json.cjs +11 -5
- package/dist/json.d.mts +4 -2
- package/dist/json.mjs +4 -2
- package/dist/kernel.cjs +1 -1
- package/dist/kernel.d.mts +3 -3
- package/dist/kernel.mjs +1 -2
- package/dist/leader.d.mts +2 -2
- package/dist/leader.mjs +1 -2
- package/dist/logSinkTelemetry.mjs +1 -2
- package/dist/machineApi.cjs +80 -74
- package/dist/machineApi.cjs.map +1 -1
- package/dist/machineApi.d.mts +5 -2
- package/dist/machineApi.d.mts.map +1 -1
- package/dist/machineApi.mjs +78 -71
- package/dist/machineApi.mjs.map +1 -1
- package/dist/main.cjs +2 -1
- package/dist/main.d.mts +2 -1
- package/dist/main.mjs +2 -1
- package/dist/mcpFacet.d.mts +3 -3
- package/dist/mcpProjection.cjs +13 -13
- package/dist/mcpProjection.d.mts +2 -2
- package/dist/mcpProjection.mjs +1 -2
- package/dist/mcpSchemaCost.cjs +4 -4
- package/dist/mcpSchemaCost.cjs.map +1 -1
- package/dist/mcpSchemaCost.d.mts +2 -2
- package/dist/mcpSchemaCost.mjs +4 -4
- package/dist/mcpSchemaCost.mjs.map +1 -1
- package/dist/mcpSession.cjs +7 -7
- package/dist/mcpSession.d.mts +2 -2
- package/dist/mcpSession.mjs +1 -2
- package/dist/mcpStatus.cjs +2 -2
- package/dist/mcpStatus.d.mts +2 -2
- package/dist/mcpStatus.mjs +1 -2
- package/dist/mcpToolResolver.cjs +3 -3
- package/dist/mcpToolResolver.d.mts +2 -2
- package/dist/mcpToolResolver.mjs +1 -2
- package/dist/mcpWidget.d.mts +2 -2
- package/dist/moduleResolution.cjs +43 -8
- package/dist/moduleResolution.cjs.map +1 -1
- package/dist/moduleResolution.d.mts +10 -1
- package/dist/moduleResolution.d.mts.map +1 -1
- package/dist/moduleResolution.mjs +40 -7
- package/dist/moduleResolution.mjs.map +1 -1
- package/dist/narration.cjs +3 -3
- package/dist/narration.d.mts +2 -2
- package/dist/narration.mjs +1 -2
- package/dist/native.cjs +9 -0
- package/dist/native.d.mts +4 -3
- package/dist/native.mjs +3 -2
- package/dist/nodePlatform.cjs +77 -0
- package/dist/nodePlatform.cjs.map +1 -0
- package/dist/nodePlatform.d.mts +17 -0
- package/dist/nodePlatform.d.mts.map +1 -0
- package/dist/nodePlatform.mjs +72 -0
- package/dist/nodePlatform.mjs.map +1 -0
- package/dist/notification.cjs +15 -15
- package/dist/notification.d.mts +2 -2
- package/dist/notification.mjs +1 -2
- package/dist/packageApi.cjs +11 -11
- package/dist/packageApi.d.mts +2 -2
- package/dist/packageApi.mjs +2 -2
- package/dist/packageApiServer.cjs +45 -27
- package/dist/packageApiServer.cjs.map +1 -1
- package/dist/packageApiServer.d.mts +36 -26
- package/dist/packageApiServer.d.mts.map +1 -1
- package/dist/packageApiServer.mjs +44 -26
- package/dist/packageApiServer.mjs.map +1 -1
- package/dist/piSettings.cjs +41 -20
- package/dist/piSettings.d.mts +4 -2
- package/dist/piSettings.mjs +4 -2
- package/dist/platform.cjs +62 -0
- package/dist/platform.d.mts +10 -0
- package/dist/platform.mjs +10 -0
- package/dist/pluginProtocol.cjs +7 -8
- package/dist/pluginProtocol.d.mts +2 -2
- package/dist/pluginProtocol.mjs +1 -2
- package/dist/poPackage.cjs +12 -0
- package/dist/poPackage.d.mts +3 -0
- package/dist/poPackage.mjs +3 -0
- package/dist/profileIdentity.cjs +1 -1
- package/dist/profileIdentity.d.mts +2 -2
- package/dist/profileIdentity.mjs +1 -2
- package/dist/protocol.cjs +3 -3
- package/dist/protocol.d.mts +2 -2
- package/dist/protocol.mjs +1 -2
- package/dist/readiness.cjs +6 -6
- package/dist/readiness.d.mts +2 -2
- package/dist/readiness.mjs +1 -2
- package/dist/remoteApi.cjs.map +1 -1
- package/dist/remoteApi.d.mts +2 -2
- package/dist/remoteApi.mjs.map +1 -1
- package/dist/remoteRuntime.cjs +42 -65
- package/dist/remoteRuntime.cjs.map +1 -1
- package/dist/remoteRuntime.d.mts +3 -2
- package/dist/remoteRuntime.d.mts.map +1 -1
- package/dist/remoteRuntime.mjs +41 -62
- package/dist/remoteRuntime.mjs.map +1 -1
- package/dist/runtimeConfig.cjs +4 -4
- package/dist/runtimeConfig.cjs.map +1 -1
- package/dist/runtimeConfig.d.mts +10 -9
- package/dist/runtimeConfig.d.mts.map +1 -1
- package/dist/runtimeConfig.mjs +4 -4
- package/dist/runtimeConfig.mjs.map +1 -1
- package/dist/runtimeContextApi.cjs +10 -3
- package/dist/runtimeContextApi.cjs.map +1 -1
- package/dist/runtimeContextApi.d.mts +3 -3
- package/dist/runtimeContextApi.d.mts.map +1 -1
- package/dist/runtimeContextApi.mjs +10 -3
- package/dist/runtimeContextApi.mjs.map +1 -1
- package/dist/runtimeCordisHost.cjs +46 -46
- package/dist/runtimeCordisHost.cjs.map +1 -1
- package/dist/runtimeCordisHost.d.mts +29 -28
- package/dist/runtimeCordisHost.d.mts.map +1 -1
- package/dist/runtimeCordisHost.mjs +42 -42
- package/dist/runtimeCordisHost.mjs.map +1 -1
- package/dist/runtimeIdentity.cjs +6 -9
- package/dist/runtimeIdentity.cjs.map +1 -1
- package/dist/runtimeIdentity.d.mts +5 -1
- package/dist/runtimeIdentity.d.mts.map +1 -1
- package/dist/runtimeIdentity.mjs +5 -8
- package/dist/runtimeIdentity.mjs.map +1 -1
- package/dist/runtimeJson.cjs +10 -45
- package/dist/runtimeJson.d.mts +3 -22
- package/dist/runtimeJson.mjs +3 -39
- package/dist/runtimeLogSinkTelemetry.cjs +19 -19
- package/dist/runtimeLogSinkTelemetry.cjs.map +1 -1
- package/dist/runtimeLogSinkTelemetry.d.mts +19 -19
- package/dist/runtimeLogSinkTelemetry.mjs +19 -19
- package/dist/runtimeLogSinkTelemetry.mjs.map +1 -1
- package/dist/runtimePackages.cjs +7 -2
- package/dist/runtimePackages.cjs.map +1 -1
- package/dist/runtimePackages.d.mts +4 -1
- package/dist/runtimePackages.d.mts.map +1 -1
- package/dist/runtimePackages.mjs +7 -2
- package/dist/runtimePackages.mjs.map +1 -1
- package/dist/runtimePiSettings.cjs +40 -263
- package/dist/runtimePiSettings.d.mts +3 -72
- package/dist/runtimePiSettings.mjs +3 -241
- package/dist/runtimeProtocol.cjs +19 -19
- package/dist/runtimeProtocol.cjs.map +1 -1
- package/dist/runtimeProtocol.d.mts +7 -7
- package/dist/runtimeProtocol.d.mts.map +1 -1
- package/dist/runtimeProtocol.mjs +17 -17
- package/dist/runtimeProtocol.mjs.map +1 -1
- package/dist/runtimeTransition.cjs +9 -9
- package/dist/runtimeTransition.cjs.map +1 -1
- package/dist/runtimeTransition.d.mts +10 -10
- package/dist/runtimeTransition.d.mts.map +1 -1
- package/dist/runtimeTransition.mjs +7 -7
- package/dist/runtimeTransition.mjs.map +1 -1
- package/dist/sandboxHarness.mjs +1 -2
- package/dist/server.cjs +3 -7
- package/dist/server.d.mts +6 -6
- package/dist/server.mjs +3 -4
- package/dist/serverPlugin.cjs +39 -0
- package/dist/serverPlugin.d.mts +12 -0
- package/dist/serverPlugin.mjs +11 -0
- package/dist/serverTelemetry.cjs +1 -1
- package/dist/serverTelemetry.cjs.map +1 -1
- package/dist/serverTelemetry.d.mts +2 -2
- package/dist/serverTelemetry.mjs +2 -2
- package/dist/serverTelemetry.mjs.map +1 -1
- package/dist/sessionFilesApi.cjs +41 -37
- package/dist/sessionFilesApi.cjs.map +1 -1
- package/dist/sessionFilesApi.d.mts +6 -3
- package/dist/sessionFilesApi.d.mts.map +1 -1
- package/dist/sessionFilesApi.mjs +41 -36
- package/dist/sessionFilesApi.mjs.map +1 -1
- package/dist/sessionProtocol.cjs +31 -6
- package/dist/sessionProtocol.d.mts +8 -3
- package/dist/sessionProtocol.mjs +8 -2
- package/dist/skills.cjs +5 -5
- package/dist/skills.d.mts +2 -2
- package/dist/skills.mjs +1 -2
- package/dist/sqliteSessionStorage.cjs +28 -50
- package/dist/sqliteSessionStorage.cjs.map +1 -1
- package/dist/sqliteSessionStorage.d.mts +13 -20
- package/dist/sqliteSessionStorage.d.mts.map +1 -1
- package/dist/sqliteSessionStorage.mjs +25 -48
- package/dist/sqliteSessionStorage.mjs.map +1 -1
- package/dist/src/constants/agentSettled.cjs +7 -0
- package/dist/src/constants/agentSettled.cjs.map +1 -0
- package/dist/src/constants/agentSettled.mjs +7 -0
- package/dist/src/constants/agentSettled.mjs.map +1 -0
- package/dist/src/constants/contextApi.cjs +3 -1
- package/dist/src/constants/contextApi.cjs.map +1 -1
- package/dist/src/constants/contextApi.d.mts +2 -1
- package/dist/src/constants/contextApi.d.mts.map +1 -1
- package/dist/src/constants/contextApi.mjs +3 -2
- package/dist/src/constants/contextApi.mjs.map +1 -1
- package/dist/src/constants/voiceTools.cjs +6 -6
- package/dist/src/constants/voiceTools.cjs.map +1 -1
- package/dist/src/constants/voiceTools.d.mts +3 -3
- package/dist/src/constants/voiceTools.mjs +4 -4
- package/dist/src/constants/voiceTools.mjs.map +1 -1
- package/dist/src/extensions/extensionFile.cjs +22 -5
- package/dist/src/extensions/extensionFile.cjs.map +1 -1
- package/dist/src/extensions/extensionFile.d.mts +17 -4
- package/dist/src/extensions/extensionFile.d.mts.map +1 -1
- package/dist/src/extensions/extensionFile.mjs +22 -6
- package/dist/src/extensions/extensionFile.mjs.map +1 -1
- package/dist/src/extensions/serverPlugin.cjs +231 -92
- package/dist/src/extensions/serverPlugin.cjs.map +1 -1
- package/dist/src/extensions/serverPlugin.d.mts +2 -2
- package/dist/src/extensions/serverPlugin.d.mts.map +1 -1
- package/dist/src/extensions/serverPlugin.mjs +232 -93
- package/dist/src/extensions/serverPlugin.mjs.map +1 -1
- package/dist/src/pi/piSessionRuntime.cjs +349 -142
- package/dist/src/pi/piSessionRuntime.cjs.map +1 -1
- package/dist/src/pi/piSessionRuntime.d.mts +18 -17
- package/dist/src/pi/piSessionRuntime.d.mts.map +1 -1
- package/dist/src/pi/piSessionRuntime.mjs +342 -135
- package/dist/src/pi/piSessionRuntime.mjs.map +1 -1
- package/dist/src/schemas/agentModel.cjs +2 -2
- package/dist/src/schemas/agentModel.cjs.map +1 -1
- package/dist/src/schemas/agentModel.d.mts +1 -1
- package/dist/src/schemas/agentModel.mjs +2 -2
- package/dist/src/schemas/agentModel.mjs.map +1 -1
- package/dist/src/schemas/apiContracts.d.mts +2 -2
- package/dist/src/schemas/apiContracts.d.mts.map +1 -1
- package/dist/src/schemas/askUser.cjs +4 -4
- package/dist/src/schemas/askUser.cjs.map +1 -1
- package/dist/src/schemas/askUser.d.mts +4 -4
- package/dist/src/schemas/askUser.d.mts.map +1 -1
- package/dist/src/schemas/askUser.mjs +3 -3
- package/dist/src/schemas/askUser.mjs.map +1 -1
- package/dist/src/schemas/backgroundWork.cjs +10 -10
- package/dist/src/schemas/backgroundWork.cjs.map +1 -1
- package/dist/src/schemas/backgroundWork.d.mts +9 -9
- package/dist/src/schemas/backgroundWork.d.mts.map +1 -1
- package/dist/src/schemas/backgroundWork.mjs +8 -8
- package/dist/src/schemas/backgroundWork.mjs.map +1 -1
- package/dist/src/schemas/childProcess.cjs +5 -5
- package/dist/src/schemas/childProcess.cjs.map +1 -1
- package/dist/src/schemas/childProcess.d.mts +2 -2
- package/dist/src/schemas/childProcess.mjs +5 -5
- package/dist/src/schemas/childProcess.mjs.map +1 -1
- package/dist/src/schemas/contextContributions.cjs +10 -10
- package/dist/src/schemas/contextContributions.cjs.map +1 -1
- package/dist/src/schemas/contextContributions.d.mts +16 -16
- package/dist/src/schemas/contextContributions.d.mts.map +1 -1
- package/dist/src/schemas/contextContributions.mjs +8 -8
- package/dist/src/schemas/contextContributions.mjs.map +1 -1
- package/dist/src/schemas/delegation.cjs +17 -17
- package/dist/src/schemas/delegation.cjs.map +1 -1
- package/dist/src/schemas/delegation.d.mts +16 -16
- package/dist/src/schemas/delegation.d.mts.map +1 -1
- package/dist/src/schemas/delegation.mjs +10 -10
- package/dist/src/schemas/delegation.mjs.map +1 -1
- package/dist/src/schemas/extensionFile.d.mts +23 -19
- package/dist/src/schemas/extensionFile.d.mts.map +1 -1
- package/dist/src/schemas/footer.cjs.map +1 -1
- package/dist/src/schemas/footer.d.mts +5 -5
- package/dist/src/schemas/footer.d.mts.map +1 -1
- package/dist/src/schemas/footer.mjs.map +1 -1
- package/dist/src/schemas/headless.cjs +37 -37
- package/dist/src/schemas/headless.cjs.map +1 -1
- package/dist/src/schemas/headless.d.mts +100 -101
- package/dist/src/schemas/headless.d.mts.map +1 -1
- package/dist/src/schemas/headless.mjs +24 -24
- package/dist/src/schemas/headless.mjs.map +1 -1
- package/dist/src/schemas/help.cjs +60 -60
- package/dist/src/schemas/help.cjs.map +1 -1
- package/dist/src/schemas/help.d.mts +43 -43
- package/dist/src/schemas/help.d.mts.map +1 -1
- package/dist/src/schemas/help.mjs +41 -41
- package/dist/src/schemas/help.mjs.map +1 -1
- package/dist/src/schemas/home.cjs +127 -0
- package/dist/src/schemas/home.cjs.map +1 -0
- package/dist/src/schemas/home.d.mts +63 -0
- package/dist/src/schemas/home.d.mts.map +1 -0
- package/dist/src/schemas/home.mjs +121 -0
- package/dist/src/schemas/home.mjs.map +1 -0
- package/dist/src/schemas/httpApiContracts.cjs +441 -0
- package/dist/src/schemas/httpApiContracts.cjs.map +1 -0
- package/dist/src/schemas/httpApiContracts.d.mts +78 -0
- package/dist/src/schemas/httpApiContracts.d.mts.map +1 -0
- package/dist/src/schemas/httpApiContracts.mjs +434 -0
- package/dist/src/schemas/httpApiContracts.mjs.map +1 -0
- package/dist/src/schemas/hubChannel.cjs +3 -0
- package/dist/src/schemas/hubChannel.cjs.map +1 -1
- package/dist/src/schemas/hubChannel.d.mts +84 -60
- package/dist/src/schemas/hubChannel.d.mts.map +1 -1
- package/dist/src/schemas/hubChannel.mjs +3 -1
- package/dist/src/schemas/hubChannel.mjs.map +1 -1
- package/dist/src/schemas/leader.cjs.map +1 -1
- package/dist/src/schemas/leader.d.mts +3 -3
- package/dist/src/schemas/leader.d.mts.map +1 -1
- package/dist/src/schemas/leader.mjs.map +1 -1
- package/dist/src/schemas/mcpBundle.d.mts +3 -3
- package/dist/src/schemas/mcpFacet.cjs.map +1 -1
- package/dist/src/schemas/mcpFacet.d.mts +22 -22
- package/dist/src/schemas/mcpFacet.d.mts.map +1 -1
- package/dist/src/schemas/mcpFacet.mjs.map +1 -1
- package/dist/src/schemas/mcpProjection.cjs +41 -41
- package/dist/src/schemas/mcpProjection.cjs.map +1 -1
- package/dist/src/schemas/mcpProjection.d.mts +31 -30
- package/dist/src/schemas/mcpProjection.d.mts.map +1 -1
- package/dist/src/schemas/mcpProjection.mjs +29 -29
- package/dist/src/schemas/mcpProjection.mjs.map +1 -1
- package/dist/src/schemas/mcpSession.cjs +23 -23
- package/dist/src/schemas/mcpSession.cjs.map +1 -1
- package/dist/src/schemas/mcpSession.d.mts +12 -12
- package/dist/src/schemas/mcpSession.d.mts.map +1 -1
- package/dist/src/schemas/mcpSession.mjs +18 -18
- package/dist/src/schemas/mcpSession.mjs.map +1 -1
- package/dist/src/schemas/mcpStatus.cjs +5 -5
- package/dist/src/schemas/mcpStatus.cjs.map +1 -1
- package/dist/src/schemas/mcpStatus.d.mts +4 -4
- package/dist/src/schemas/mcpStatus.d.mts.map +1 -1
- package/dist/src/schemas/mcpStatus.mjs +4 -4
- package/dist/src/schemas/mcpStatus.mjs.map +1 -1
- package/dist/src/schemas/mcpToolResolver.cjs +9 -9
- package/dist/src/schemas/mcpToolResolver.cjs.map +1 -1
- package/dist/src/schemas/mcpToolResolver.d.mts +7 -7
- package/dist/src/schemas/mcpToolResolver.d.mts.map +1 -1
- package/dist/src/schemas/mcpToolResolver.mjs +7 -7
- package/dist/src/schemas/mcpToolResolver.mjs.map +1 -1
- package/dist/src/schemas/narration.cjs +9 -9
- package/dist/src/schemas/narration.cjs.map +1 -1
- package/dist/src/schemas/narration.d.mts +5 -5
- package/dist/src/schemas/narration.d.mts.map +1 -1
- package/dist/src/schemas/narration.mjs +7 -7
- package/dist/src/schemas/narration.mjs.map +1 -1
- package/dist/src/schemas/notification.cjs +45 -45
- package/dist/src/schemas/notification.cjs.map +1 -1
- package/dist/src/schemas/notification.d.mts +22 -22
- package/dist/src/schemas/notification.d.mts.map +1 -1
- package/dist/src/schemas/notification.mjs +31 -31
- package/dist/src/schemas/notification.mjs.map +1 -1
- package/dist/src/schemas/packageApi.cjs +28 -28
- package/dist/src/schemas/packageApi.cjs.map +1 -1
- package/dist/src/schemas/packageApi.d.mts +91 -65
- package/dist/src/schemas/packageApi.d.mts.map +1 -1
- package/dist/src/schemas/packageApi.mjs +18 -18
- package/dist/src/schemas/packageApi.mjs.map +1 -1
- package/dist/src/schemas/platform.cjs +34 -0
- package/dist/src/schemas/platform.cjs.map +1 -0
- package/dist/src/schemas/platform.d.mts +75 -0
- package/dist/src/schemas/platform.d.mts.map +1 -0
- package/dist/src/schemas/platform.mjs +27 -0
- package/dist/src/schemas/platform.mjs.map +1 -0
- package/dist/src/schemas/pluginContributions.cjs.map +1 -1
- package/dist/src/schemas/pluginContributions.d.mts +12 -12
- package/dist/src/schemas/pluginContributions.d.mts.map +1 -1
- package/dist/src/schemas/pluginContributions.mjs.map +1 -1
- package/dist/src/schemas/pluginProtocol.cjs +24 -27
- package/dist/src/schemas/pluginProtocol.cjs.map +1 -1
- package/dist/src/schemas/pluginProtocol.d.mts +21 -21
- package/dist/src/schemas/pluginProtocol.d.mts.map +1 -1
- package/dist/src/schemas/pluginProtocol.mjs +18 -20
- package/dist/src/schemas/pluginProtocol.mjs.map +1 -1
- package/dist/src/schemas/profileIdentity.cjs +2 -2
- package/dist/src/schemas/profileIdentity.cjs.map +1 -1
- package/dist/src/schemas/profileIdentity.d.mts +1 -1
- package/dist/src/schemas/profileIdentity.mjs +2 -2
- package/dist/src/schemas/profileIdentity.mjs.map +1 -1
- package/dist/src/schemas/protocolChannelsContract.cjs +27 -0
- package/dist/src/schemas/protocolChannelsContract.cjs.map +1 -0
- package/dist/src/schemas/protocolChannelsContract.d.mts +37 -0
- package/dist/src/schemas/protocolChannelsContract.d.mts.map +1 -0
- package/dist/src/schemas/protocolChannelsContract.mjs +25 -0
- package/dist/src/schemas/protocolChannelsContract.mjs.map +1 -0
- package/dist/src/schemas/protocolContracts.cjs +168 -0
- package/dist/src/schemas/protocolContracts.cjs.map +1 -0
- package/dist/src/schemas/protocolContracts.d.mts +69 -0
- package/dist/src/schemas/protocolContracts.d.mts.map +1 -0
- package/dist/src/schemas/protocolContracts.mjs +164 -0
- package/dist/src/schemas/protocolContracts.mjs.map +1 -0
- package/dist/src/schemas/protocolHubContract.cjs +51 -0
- package/dist/src/schemas/protocolHubContract.cjs.map +1 -0
- package/dist/src/schemas/protocolHubContract.d.mts +218 -0
- package/dist/src/schemas/protocolHubContract.d.mts.map +1 -0
- package/dist/src/schemas/protocolHubContract.mjs +49 -0
- package/dist/src/schemas/protocolHubContract.mjs.map +1 -0
- package/dist/src/schemas/protocolSessionContract.cjs +22 -0
- package/dist/src/schemas/protocolSessionContract.cjs.map +1 -0
- package/dist/src/schemas/protocolSessionContract.d.mts +324 -0
- package/dist/src/schemas/protocolSessionContract.d.mts.map +1 -0
- package/dist/src/schemas/protocolSessionContract.mjs +22 -0
- package/dist/src/schemas/protocolSessionContract.mjs.map +1 -0
- package/dist/src/schemas/protocolThreadContract.cjs +21 -0
- package/dist/src/schemas/protocolThreadContract.cjs.map +1 -0
- package/dist/src/schemas/protocolThreadContract.d.mts +29 -0
- package/dist/src/schemas/protocolThreadContract.d.mts.map +1 -0
- package/dist/src/schemas/protocolThreadContract.mjs +20 -0
- package/dist/src/schemas/protocolThreadContract.mjs.map +1 -0
- package/dist/src/schemas/readiness.cjs +36 -36
- package/dist/src/schemas/readiness.cjs.map +1 -1
- package/dist/src/schemas/readiness.d.mts +37 -37
- package/dist/src/schemas/readiness.d.mts.map +1 -1
- package/dist/src/schemas/readiness.mjs +31 -31
- package/dist/src/schemas/readiness.mjs.map +1 -1
- package/dist/src/schemas/serverBundle.d.mts +5 -5
- package/dist/src/schemas/serverPlugin.cjs +103 -0
- package/dist/src/schemas/serverPlugin.cjs.map +1 -0
- package/dist/src/schemas/serverPlugin.d.mts +176 -0
- package/dist/src/schemas/serverPlugin.d.mts.map +1 -0
- package/dist/src/schemas/serverPlugin.mjs +95 -0
- package/dist/src/schemas/serverPlugin.mjs.map +1 -0
- package/dist/src/schemas/serverScope.cjs +37 -0
- package/dist/src/schemas/serverScope.cjs.map +1 -0
- package/dist/src/schemas/serverScope.d.mts +77 -0
- package/dist/src/schemas/serverScope.d.mts.map +1 -0
- package/dist/src/schemas/serverScope.mjs +33 -0
- package/dist/src/schemas/serverScope.mjs.map +1 -0
- package/dist/src/schemas/sessionApiContracts.cjs +320 -0
- package/dist/src/schemas/sessionApiContracts.cjs.map +1 -0
- package/dist/src/schemas/sessionApiContracts.mjs +318 -0
- package/dist/src/schemas/sessionApiContracts.mjs.map +1 -0
- package/dist/src/schemas/sessionProtocol.cjs +20 -13
- package/dist/src/schemas/sessionProtocol.cjs.map +1 -1
- package/dist/src/schemas/sessionProtocol.d.mts +37 -54
- package/dist/src/schemas/sessionProtocol.d.mts.map +1 -1
- package/dist/src/schemas/sessionProtocol.mjs +17 -8
- package/dist/src/schemas/sessionProtocol.mjs.map +1 -1
- package/dist/src/schemas/skills.cjs +16 -16
- package/dist/src/schemas/skills.cjs.map +1 -1
- package/dist/src/schemas/skills.d.mts +7 -7
- package/dist/src/schemas/skills.d.mts.map +1 -1
- package/dist/src/schemas/skills.mjs +12 -12
- package/dist/src/schemas/skills.mjs.map +1 -1
- package/dist/src/schemas/toolOverrides.cjs +9 -9
- package/dist/src/schemas/toolOverrides.cjs.map +1 -1
- package/dist/src/schemas/toolOverrides.d.mts +8 -8
- package/dist/src/schemas/toolOverrides.d.mts.map +1 -1
- package/dist/src/schemas/toolOverrides.mjs +7 -7
- package/dist/src/schemas/toolOverrides.mjs.map +1 -1
- package/dist/src/schemas/toolSurface.cjs +9 -9
- package/dist/src/schemas/toolSurface.cjs.map +1 -1
- package/dist/src/schemas/toolSurface.d.mts +13 -13
- package/dist/src/schemas/toolSurface.d.mts.map +1 -1
- package/dist/src/schemas/toolSurface.mjs +7 -7
- package/dist/src/schemas/toolSurface.mjs.map +1 -1
- package/dist/src/schemas/uiHub.cjs +9 -9
- package/dist/src/schemas/uiHub.cjs.map +1 -1
- package/dist/src/schemas/uiHub.d.mts +12 -12
- package/dist/src/schemas/uiHub.d.mts.map +1 -1
- package/dist/src/schemas/uiHub.mjs +7 -7
- package/dist/src/schemas/uiHub.mjs.map +1 -1
- package/dist/src/server/directHarnessRuntime.cjs +691 -775
- package/dist/src/server/directHarnessRuntime.cjs.map +1 -1
- package/dist/src/server/directHarnessRuntime.d.mts +5 -1
- package/dist/src/server/directHarnessRuntime.d.mts.map +1 -0
- package/dist/src/server/directHarnessRuntime.mjs +671 -754
- package/dist/src/server/directHarnessRuntime.mjs.map +1 -1
- package/dist/src/server/largeFrameLink.cjs +47 -0
- package/dist/src/server/largeFrameLink.cjs.map +1 -0
- package/dist/src/server/largeFrameLink.mjs +47 -0
- package/dist/src/server/largeFrameLink.mjs.map +1 -0
- package/dist/src/server/liveImport.cjs +1 -1
- package/dist/src/server/liveImport.cjs.map +1 -1
- package/dist/src/server/liveImport.d.mts +1 -1
- package/dist/src/server/liveImport.mjs +1 -1
- package/dist/src/server/liveImport.mjs.map +1 -1
- package/dist/src/server/mcpBundleLoader.cjs.map +1 -1
- package/dist/src/server/mcpBundleLoader.d.mts +6 -6
- package/dist/src/server/mcpBundleLoader.d.mts.map +1 -1
- package/dist/src/server/mcpBundleLoader.mjs.map +1 -1
- package/dist/src/server/serverPackages.cjs +60 -0
- package/dist/src/server/serverPackages.cjs.map +1 -0
- package/dist/src/server/serverPackages.d.mts +44 -0
- package/dist/src/server/serverPackages.d.mts.map +1 -0
- package/dist/src/server/serverPackages.mjs +59 -0
- package/dist/src/server/serverPackages.mjs.map +1 -0
- package/dist/src/server/serverScope.cjs +510 -0
- package/dist/src/server/serverScope.cjs.map +1 -0
- package/dist/src/server/serverScope.d.mts +123 -0
- package/dist/src/server/serverScope.d.mts.map +1 -0
- package/dist/src/server/serverScope.mjs +510 -0
- package/dist/src/server/serverScope.mjs.map +1 -0
- package/dist/src/server/sessionMcpHandler.cjs +3 -3
- package/dist/src/server/sessionMcpHandler.cjs.map +1 -1
- package/dist/src/server/sessionMcpHandler.mjs +4 -4
- package/dist/src/server/sessionMcpHandler.mjs.map +1 -1
- package/dist/src/server/sessionMcpRoutes.cjs +2 -1
- package/dist/src/server/sessionMcpRoutes.cjs.map +1 -1
- package/dist/src/server/sessionMcpRoutes.mjs +2 -1
- package/dist/src/server/sessionMcpRoutes.mjs.map +1 -1
- package/dist/src/server/threadJournals.cjs +38 -107
- package/dist/src/server/threadJournals.cjs.map +1 -1
- package/dist/src/server/threadJournals.mjs +38 -104
- package/dist/src/server/threadJournals.mjs.map +1 -1
- package/dist/src/services/apiSurfaceAssert/index.cjs +1 -1
- package/dist/src/services/apiSurfaceAssert/index.cjs.map +1 -1
- package/dist/src/services/apiSurfaceAssert/index.d.mts +6 -6
- package/dist/src/services/apiSurfaceAssert/index.mjs +1 -1
- package/dist/src/services/apiSurfaceAssert/index.mjs.map +1 -1
- package/dist/src/services/chatgptAuth/index.cjs +1 -220
- package/dist/src/services/chatgptAuth/index.cjs.map +1 -1
- package/dist/src/services/chatgptAuth/index.d.mts +0 -18
- package/dist/src/services/chatgptAuth/index.d.mts.map +1 -1
- package/dist/src/services/chatgptAuth/index.mjs +1 -217
- package/dist/src/services/chatgptAuth/index.mjs.map +1 -1
- package/dist/src/services/chatgptImages/index.cjs +1 -1
- package/dist/src/services/chatgptImages/index.cjs.map +1 -1
- package/dist/src/services/chatgptImages/index.mjs +1 -1
- package/dist/src/services/chatgptImages/index.mjs.map +1 -1
- package/dist/src/services/chatgptLogin/index.cjs +230 -0
- package/dist/src/services/chatgptLogin/index.cjs.map +1 -0
- package/dist/src/services/chatgptLogin/index.d.mts +21 -0
- package/dist/src/services/chatgptLogin/index.d.mts.map +1 -0
- package/dist/src/services/chatgptLogin/index.mjs +227 -0
- package/dist/src/services/chatgptLogin/index.mjs.map +1 -0
- package/dist/src/services/chatgptWebSearch/index.cjs +1 -1
- package/dist/src/services/chatgptWebSearch/index.cjs.map +1 -1
- package/dist/src/services/chatgptWebSearch/index.mjs +1 -1
- package/dist/src/services/chatgptWebSearch/index.mjs.map +1 -1
- package/dist/src/services/contextContributions/index.cjs +8 -8
- package/dist/src/services/contextContributions/index.cjs.map +1 -1
- package/dist/src/services/contextContributions/index.d.mts +3 -3
- package/dist/src/services/contextContributions/index.d.mts.map +1 -1
- package/dist/src/services/contextContributions/index.mjs +8 -8
- package/dist/src/services/contextContributions/index.mjs.map +1 -1
- package/dist/src/services/devProxyStore/devProxyRecords.cjs +59 -0
- package/dist/src/services/devProxyStore/devProxyRecords.cjs.map +1 -0
- package/dist/src/services/devProxyStore/devProxyRecords.mjs +56 -0
- package/dist/src/services/devProxyStore/devProxyRecords.mjs.map +1 -0
- package/dist/src/services/devProxyStore/index.cjs +7 -101
- package/dist/src/services/devProxyStore/index.cjs.map +1 -1
- package/dist/src/services/devProxyStore/index.mjs +7 -101
- package/dist/src/services/devProxyStore/index.mjs.map +1 -1
- package/dist/src/services/devProxyStore/sync.cjs +66 -0
- package/dist/src/services/devProxyStore/sync.cjs.map +1 -0
- package/dist/src/services/devProxyStore/sync.mjs +63 -0
- package/dist/src/services/devProxyStore/sync.mjs.map +1 -0
- package/dist/src/services/durableNavigation/docs.cjs +15 -0
- package/dist/src/services/durableNavigation/docs.cjs.map +1 -0
- package/dist/src/services/durableNavigation/docs.mjs +16 -0
- package/dist/src/services/durableNavigation/docs.mjs.map +1 -0
- package/dist/src/services/durableNavigation/index.cjs +3 -18
- package/dist/src/services/durableNavigation/index.cjs.map +1 -1
- package/dist/src/services/durableNavigation/index.mjs +2 -17
- package/dist/src/services/durableNavigation/index.mjs.map +1 -1
- package/dist/src/services/durableQueue/docs.cjs +12 -0
- package/dist/src/services/durableQueue/docs.cjs.map +1 -0
- package/dist/src/services/durableQueue/docs.mjs +13 -0
- package/dist/src/services/durableQueue/docs.mjs.map +1 -0
- package/dist/src/services/durableQueue/index.cjs +151 -0
- package/dist/src/services/durableQueue/index.cjs.map +1 -0
- package/dist/src/services/durableQueue/index.mjs +149 -0
- package/dist/src/services/durableQueue/index.mjs.map +1 -0
- package/dist/src/services/durableRequestReceipts/docs.cjs +11 -0
- package/dist/src/services/durableRequestReceipts/docs.cjs.map +1 -0
- package/dist/src/services/durableRequestReceipts/docs.mjs +12 -0
- package/dist/src/services/durableRequestReceipts/docs.mjs.map +1 -0
- package/dist/src/services/{requestReceipts → durableRequestReceipts}/index.cjs +10 -16
- package/dist/src/services/durableRequestReceipts/index.cjs.map +1 -0
- package/dist/src/services/durableRequestReceipts/index.d.mts +12 -0
- package/dist/src/services/durableRequestReceipts/index.d.mts.map +1 -0
- package/dist/src/services/{requestReceipts → durableRequestReceipts}/index.mjs +7 -13
- package/dist/src/services/durableRequestReceipts/index.mjs.map +1 -0
- package/dist/src/services/durableSession/docs.cjs +65 -0
- package/dist/src/services/durableSession/docs.cjs.map +1 -0
- package/dist/src/services/durableSession/docs.d.mts +17 -0
- package/dist/src/services/durableSession/docs.d.mts.map +1 -0
- package/dist/src/services/durableSession/docs.mjs +60 -0
- package/dist/src/services/durableSession/docs.mjs.map +1 -0
- package/dist/src/services/durableSession/index.cjs +21 -0
- package/dist/src/services/durableSession/index.cjs.map +1 -0
- package/dist/src/services/durableSession/index.d.mts +13 -0
- package/dist/src/services/durableSession/index.d.mts.map +1 -0
- package/dist/src/services/durableSession/index.mjs +20 -0
- package/dist/src/services/durableSession/index.mjs.map +1 -0
- package/dist/src/services/durableSubagents/docs.cjs +15 -0
- package/dist/src/services/durableSubagents/docs.cjs.map +1 -0
- package/dist/src/services/durableSubagents/docs.mjs +16 -0
- package/dist/src/services/durableSubagents/docs.mjs.map +1 -0
- package/dist/src/services/durableSubagents/extension.cjs +11 -0
- package/dist/src/services/durableSubagents/extension.cjs.map +1 -0
- package/dist/src/services/durableSubagents/extension.mjs +12 -0
- package/dist/src/services/durableSubagents/extension.mjs.map +1 -0
- package/dist/src/services/durableSubagents/index.cjs +95 -0
- package/dist/src/services/durableSubagents/index.cjs.map +1 -0
- package/dist/src/services/durableSubagents/index.mjs +90 -0
- package/dist/src/services/durableSubagents/index.mjs.map +1 -0
- package/dist/src/services/durableSubagents/tasks.cjs +25 -0
- package/dist/src/services/durableSubagents/tasks.cjs.map +1 -0
- package/dist/src/services/durableSubagents/tasks.mjs +26 -0
- package/dist/src/services/durableSubagents/tasks.mjs.map +1 -0
- package/dist/src/services/headlessClient/index.cjs +20 -13
- package/dist/src/services/headlessClient/index.cjs.map +1 -1
- package/dist/src/services/headlessClient/index.mjs +21 -14
- package/dist/src/services/headlessClient/index.mjs.map +1 -1
- package/dist/src/services/historyOwnership/type.d.mts +15 -0
- package/dist/src/services/historyOwnership/type.d.mts.map +1 -0
- package/dist/src/services/hubChannelHarness/index.cjs +2 -2
- package/dist/src/services/hubChannelHarness/index.cjs.map +1 -1
- package/dist/src/services/hubChannelHarness/index.d.mts +8 -8
- package/dist/src/services/hubChannelHarness/index.d.mts.map +1 -1
- package/dist/src/services/hubChannelHarness/index.mjs +2 -2
- package/dist/src/services/hubChannelHarness/index.mjs.map +1 -1
- package/dist/src/services/json/core.cjs +30 -0
- package/dist/src/services/json/core.cjs.map +1 -0
- package/dist/src/services/json/core.d.mts +21 -0
- package/dist/src/services/json/core.d.mts.map +1 -0
- package/dist/src/services/json/core.mjs +26 -0
- package/dist/src/services/json/core.mjs.map +1 -0
- package/dist/src/services/json/sync.cjs +48 -0
- package/dist/src/services/json/sync.cjs.map +1 -0
- package/dist/src/services/json/sync.d.mts +22 -0
- package/dist/src/services/json/sync.d.mts.map +1 -0
- package/dist/src/services/json/sync.mjs +43 -0
- package/dist/src/services/json/sync.mjs.map +1 -0
- package/dist/src/services/kernel/index.cjs +2 -2
- package/dist/src/services/kernel/index.cjs.map +1 -1
- package/dist/src/services/kernel/index.d.mts +3 -3
- package/dist/src/services/kernel/index.d.mts.map +1 -1
- package/dist/src/services/kernel/index.mjs +2 -2
- package/dist/src/services/kernel/index.mjs.map +1 -1
- package/dist/src/services/nativeChildTools/index.cjs +16 -0
- package/dist/src/services/nativeChildTools/index.cjs.map +1 -0
- package/dist/src/services/nativeChildTools/index.mjs +16 -0
- package/dist/src/services/nativeChildTools/index.mjs.map +1 -0
- package/dist/src/services/nodeHost/index.cjs +30 -0
- package/dist/src/services/nodeHost/index.cjs.map +1 -0
- package/dist/src/services/nodeHost/index.d.mts +16 -0
- package/dist/src/services/nodeHost/index.d.mts.map +1 -0
- package/dist/src/services/nodeHost/index.mjs +27 -0
- package/dist/src/services/nodeHost/index.mjs.map +1 -0
- package/dist/src/services/nodeModelDependencies/index.cjs +89 -0
- package/dist/src/services/nodeModelDependencies/index.cjs.map +1 -0
- package/dist/src/services/nodeModelDependencies/index.mjs +86 -0
- package/dist/src/services/nodeModelDependencies/index.mjs.map +1 -0
- package/dist/src/services/openSessionRegistry/index.cjs +6 -128
- package/dist/src/services/openSessionRegistry/index.cjs.map +1 -1
- package/dist/src/services/openSessionRegistry/index.d.mts +5 -36
- package/dist/src/services/openSessionRegistry/index.mjs +6 -128
- package/dist/src/services/openSessionRegistry/index.mjs.map +1 -1
- package/dist/src/services/openSessionRegistry/openSessionRecords.cjs +87 -0
- package/dist/src/services/openSessionRegistry/openSessionRecords.cjs.map +1 -0
- package/dist/src/services/openSessionRegistry/openSessionRecords.d.mts +30 -0
- package/dist/src/services/openSessionRegistry/openSessionRecords.d.mts.map +1 -0
- package/dist/src/services/openSessionRegistry/openSessionRecords.mjs +81 -0
- package/dist/src/services/openSessionRegistry/openSessionRecords.mjs.map +1 -0
- package/dist/src/services/openSessionRegistry/sync.cjs +71 -0
- package/dist/src/services/openSessionRegistry/sync.cjs.map +1 -0
- package/dist/src/services/openSessionRegistry/sync.d.mts +14 -0
- package/dist/src/services/openSessionRegistry/sync.d.mts.map +1 -0
- package/dist/src/services/openSessionRegistry/sync.mjs +68 -0
- package/dist/src/services/openSessionRegistry/sync.mjs.map +1 -0
- package/dist/src/services/packageApiHarness/index.cjs +1 -1
- package/dist/src/services/packageApiHarness/index.cjs.map +1 -1
- package/dist/src/services/packageApiHarness/index.d.mts +6 -6
- package/dist/src/services/packageApiHarness/index.d.mts.map +1 -1
- package/dist/src/services/packageApiHarness/index.mjs +2 -2
- package/dist/src/services/packageApiHarness/index.mjs.map +1 -1
- package/dist/src/services/piArgs/index.cjs +53 -0
- package/dist/src/services/piArgs/index.cjs.map +1 -0
- package/dist/src/services/piArgs/index.d.mts +6 -0
- package/dist/src/services/piArgs/index.d.mts.map +1 -0
- package/dist/src/services/piArgs/index.mjs +53 -0
- package/dist/src/services/piArgs/index.mjs.map +1 -0
- package/dist/src/services/piExtensionHost/index.cjs +47 -39
- package/dist/src/services/piExtensionHost/index.cjs.map +1 -1
- package/dist/src/services/piExtensionHost/index.d.mts +83 -0
- package/dist/src/services/piExtensionHost/index.d.mts.map +1 -0
- package/dist/src/services/piExtensionHost/index.mjs +47 -38
- package/dist/src/services/piExtensionHost/index.mjs.map +1 -1
- package/dist/src/services/piHelpTools/index.cjs +5 -5
- package/dist/src/services/piHelpTools/index.cjs.map +1 -1
- package/dist/src/services/piHelpTools/index.d.mts.map +1 -1
- package/dist/src/services/piHelpTools/index.mjs +7 -7
- package/dist/src/services/piHelpTools/index.mjs.map +1 -1
- package/dist/src/services/piMessages/index.cjs +106 -0
- package/dist/src/services/piMessages/index.cjs.map +1 -0
- package/dist/src/services/piMessages/index.mjs +105 -0
- package/dist/src/services/piMessages/index.mjs.map +1 -0
- package/dist/src/services/piSessionEntries/index.cjs +4 -4
- package/dist/src/services/piSessionEntries/index.cjs.map +1 -1
- package/dist/src/services/piSessionEntries/index.mjs +3 -3
- package/dist/src/services/piSessionEntries/index.mjs.map +1 -1
- package/dist/src/services/piSettings/core.cjs +308 -0
- package/dist/src/services/piSettings/core.cjs.map +1 -0
- package/dist/src/services/piSettings/core.d.mts +102 -0
- package/dist/src/services/piSettings/core.d.mts.map +1 -0
- package/dist/src/services/piSettings/core.mjs +276 -0
- package/dist/src/services/piSettings/core.mjs.map +1 -0
- package/dist/src/services/piSettings/sync.cjs +119 -0
- package/dist/src/services/piSettings/sync.cjs.map +1 -0
- package/dist/src/services/piSettings/sync.d.mts +44 -0
- package/dist/src/services/piSettings/sync.d.mts.map +1 -0
- package/dist/src/services/piSettings/sync.mjs +110 -0
- package/dist/src/services/piSettings/sync.mjs.map +1 -0
- package/dist/src/services/piSummary/index.cjs +7 -0
- package/dist/src/services/piSummary/index.cjs.map +1 -0
- package/dist/src/services/piSummary/index.mjs +7 -0
- package/dist/src/services/piSummary/index.mjs.map +1 -0
- package/dist/src/services/platformFiles/index.cjs +44 -0
- package/dist/src/services/platformFiles/index.cjs.map +1 -0
- package/dist/src/services/platformFiles/index.d.mts +16 -0
- package/dist/src/services/platformFiles/index.d.mts.map +1 -0
- package/dist/src/services/platformFiles/index.mjs +39 -0
- package/dist/src/services/platformFiles/index.mjs.map +1 -0
- package/dist/src/services/pluginLifecycle/index.cjs +19 -13
- package/dist/src/services/pluginLifecycle/index.cjs.map +1 -1
- package/dist/src/services/pluginLifecycle/index.d.mts +2 -0
- package/dist/src/services/pluginLifecycle/index.d.mts.map +1 -1
- package/dist/src/services/pluginLifecycle/index.mjs +19 -14
- package/dist/src/services/pluginLifecycle/index.mjs.map +1 -1
- package/dist/src/services/poPackage/core.cjs +73 -0
- package/dist/src/services/poPackage/core.cjs.map +1 -0
- package/dist/src/services/poPackage/core.d.mts +32 -0
- package/dist/src/services/poPackage/core.d.mts.map +1 -0
- package/dist/src/services/poPackage/core.mjs +66 -0
- package/dist/src/services/poPackage/core.mjs.map +1 -0
- package/dist/src/services/poPackage/sync.cjs +55 -0
- package/dist/src/services/poPackage/sync.cjs.map +1 -0
- package/dist/src/services/poPackage/sync.d.mts +21 -0
- package/dist/src/services/poPackage/sync.d.mts.map +1 -0
- package/dist/src/services/poPackage/sync.mjs +50 -0
- package/dist/src/services/poPackage/sync.mjs.map +1 -0
- package/dist/src/services/providerAuth/index.cjs +11 -7
- package/dist/src/services/providerAuth/index.cjs.map +1 -1
- package/dist/src/services/providerAuth/index.mjs +11 -7
- package/dist/src/services/providerAuth/index.mjs.map +1 -1
- package/dist/src/services/publicFileShares/index.cjs +1 -1
- package/dist/src/services/publicFileShares/index.cjs.map +1 -1
- package/dist/src/services/publicFileShares/index.d.mts +2 -2
- package/dist/src/services/publicFileShares/index.mjs +2 -2
- package/dist/src/services/publicFileShares/index.mjs.map +1 -1
- package/dist/src/services/remoteAccess/index.d.mts +1 -0
- package/dist/src/services/remoteAccess/index.d.mts.map +1 -1
- package/dist/src/services/remoteAccessStore/index.cjs +8 -190
- package/dist/src/services/remoteAccessStore/index.cjs.map +1 -1
- package/dist/src/services/remoteAccessStore/index.d.mts +2 -0
- package/dist/src/services/remoteAccessStore/index.mjs +7 -187
- package/dist/src/services/remoteAccessStore/index.mjs.map +1 -1
- package/dist/src/services/remoteAccessStore/remoteAccessRecords.cjs +98 -0
- package/dist/src/services/remoteAccessStore/remoteAccessRecords.cjs.map +1 -0
- package/dist/src/services/remoteAccessStore/remoteAccessRecords.mjs +88 -0
- package/dist/src/services/remoteAccessStore/remoteAccessRecords.mjs.map +1 -0
- package/dist/src/services/remoteAccessStore/sync.cjs +111 -0
- package/dist/src/services/remoteAccessStore/sync.cjs.map +1 -0
- package/dist/src/services/remoteAccessStore/sync.mjs +108 -0
- package/dist/src/services/remoteAccessStore/sync.mjs.map +1 -0
- package/dist/src/services/runtimeIdentity/sync.cjs +23 -0
- package/dist/src/services/runtimeIdentity/sync.cjs.map +1 -0
- package/dist/src/services/runtimeIdentity/sync.d.mts +9 -0
- package/dist/src/services/runtimeIdentity/sync.d.mts.map +1 -0
- package/dist/src/services/runtimeIdentity/sync.mjs +20 -0
- package/dist/src/services/runtimeIdentity/sync.mjs.map +1 -0
- package/dist/src/services/serialRunner/index.cjs +25 -0
- package/dist/src/services/serialRunner/index.cjs.map +1 -0
- package/dist/src/services/serialRunner/index.d.mts +10 -0
- package/dist/src/services/serialRunner/index.d.mts.map +1 -0
- package/dist/src/services/serialRunner/index.mjs +25 -0
- package/dist/src/services/serialRunner/index.mjs.map +1 -0
- package/dist/src/services/{serverFacet → serverHost}/index.cjs +5 -5
- package/dist/src/services/serverHost/index.cjs.map +1 -0
- package/dist/src/services/serverHost/index.d.mts +31 -0
- package/dist/src/services/serverHost/index.d.mts.map +1 -0
- package/dist/src/services/{serverFacet → serverHost}/index.mjs +5 -5
- package/dist/src/services/serverHost/index.mjs.map +1 -0
- package/dist/src/services/sessionAttachments/index.cjs +4 -3
- package/dist/src/services/sessionAttachments/index.cjs.map +1 -1
- package/dist/src/services/sessionAttachments/index.d.mts +1 -6
- package/dist/src/services/sessionAttachments/index.d.mts.map +1 -1
- package/dist/src/services/sessionAttachments/index.mjs +3 -2
- package/dist/src/services/sessionAttachments/index.mjs.map +1 -1
- package/dist/src/services/sessionAttachments/type.d.mts +9 -0
- package/dist/src/services/sessionAttachments/type.d.mts.map +1 -0
- package/dist/src/services/sessionFiles/index.cjs +96 -0
- package/dist/src/services/sessionFiles/index.cjs.map +1 -0
- package/dist/src/services/sessionFiles/index.d.mts +33 -0
- package/dist/src/services/sessionFiles/index.d.mts.map +1 -0
- package/dist/src/services/sessionFiles/index.mjs +89 -0
- package/dist/src/services/sessionFiles/index.mjs.map +1 -0
- package/dist/src/services/sessionFiles/sessionDirectory.cjs +66 -0
- package/dist/src/services/sessionFiles/sessionDirectory.cjs.map +1 -0
- package/dist/src/services/sessionFiles/sessionDirectory.mjs +62 -0
- package/dist/src/services/sessionFiles/sessionDirectory.mjs.map +1 -0
- package/dist/src/services/sessionGitStatus/index.cjs +31 -33
- package/dist/src/services/sessionGitStatus/index.cjs.map +1 -1
- package/dist/src/services/sessionGitStatus/index.mjs +31 -33
- package/dist/src/services/sessionGitStatus/index.mjs.map +1 -1
- package/dist/src/services/sessionPresentation/index.cjs +3 -27
- package/dist/src/services/sessionPresentation/index.cjs.map +1 -1
- package/dist/src/services/sessionPresentation/index.mjs +3 -27
- package/dist/src/services/sessionPresentation/index.mjs.map +1 -1
- package/dist/src/services/skillPrompt/index.cjs +11 -0
- package/dist/src/services/skillPrompt/index.cjs.map +1 -0
- package/dist/src/services/skillPrompt/index.mjs +11 -0
- package/dist/src/services/skillPrompt/index.mjs.map +1 -0
- package/dist/src/services/sqliteSessionHistory/index.cjs +44 -30
- package/dist/src/services/sqliteSessionHistory/index.cjs.map +1 -1
- package/dist/src/services/sqliteSessionHistory/index.d.mts +7 -4
- package/dist/src/services/sqliteSessionHistory/index.d.mts.map +1 -1
- package/dist/src/services/sqliteSessionHistory/index.mjs +43 -28
- package/dist/src/services/sqliteSessionHistory/index.mjs.map +1 -1
- package/dist/src/services/sqliteTranscriptReader/index.cjs +21 -45
- package/dist/src/services/sqliteTranscriptReader/index.cjs.map +1 -1
- package/dist/src/services/sqliteTranscriptReader/index.d.mts +3 -2
- package/dist/src/services/sqliteTranscriptReader/index.d.mts.map +1 -1
- package/dist/src/services/sqliteTranscriptReader/index.mjs +16 -38
- package/dist/src/services/sqliteTranscriptReader/index.mjs.map +1 -1
- package/dist/src/services/testMode/index.cjs +162 -0
- package/dist/src/services/testMode/index.cjs.map +1 -0
- package/dist/src/services/testMode/index.d.mts +17 -0
- package/dist/src/services/testMode/index.d.mts.map +1 -0
- package/dist/src/services/testMode/index.mjs +155 -0
- package/dist/src/services/testMode/index.mjs.map +1 -0
- package/dist/src/services/toolOverrides/index.cjs +6 -6
- package/dist/src/services/toolOverrides/index.cjs.map +1 -1
- package/dist/src/services/toolOverrides/index.d.mts +3 -3
- package/dist/src/services/toolOverrides/index.d.mts.map +1 -1
- package/dist/src/services/toolOverrides/index.mjs +6 -6
- package/dist/src/services/toolOverrides/index.mjs.map +1 -1
- package/dist/src/services/toolPrompt/index.d.mts +17 -0
- package/dist/src/services/toolPrompt/index.d.mts.map +1 -0
- package/dist/src/services/toolSurface/index.cjs +3 -3
- package/dist/src/services/toolSurface/index.cjs.map +1 -1
- package/dist/src/services/toolSurface/index.d.mts +3 -3
- package/dist/src/services/toolSurface/index.d.mts.map +1 -1
- package/dist/src/services/toolSurface/index.mjs +4 -4
- package/dist/src/services/toolSurface/index.mjs.map +1 -1
- package/dist/src/services/traceContext/index.cjs.map +1 -1
- package/dist/src/services/traceContext/index.mjs.map +1 -1
- package/dist/src/services/transcriptPages/index.cjs +159 -33
- package/dist/src/services/transcriptPages/index.cjs.map +1 -1
- package/dist/src/services/transcriptPages/index.mjs +158 -34
- package/dist/src/services/transcriptPages/index.mjs.map +1 -1
- package/dist/src/services/voiceToolsContract/index.cjs +7 -7
- package/dist/src/services/voiceToolsContract/index.cjs.map +1 -1
- package/dist/src/services/voiceToolsContract/index.d.mts +4 -4
- package/dist/src/services/voiceToolsContract/index.d.mts.map +1 -1
- package/dist/src/services/voiceToolsContract/index.mjs +7 -7
- package/dist/src/services/voiceToolsContract/index.mjs.map +1 -1
- package/dist/src/services/workspaceRegistry/index.cjs +9 -179
- package/dist/src/services/workspaceRegistry/index.cjs.map +1 -1
- package/dist/src/services/workspaceRegistry/index.d.mts +5 -47
- package/dist/src/services/workspaceRegistry/index.mjs +7 -176
- package/dist/src/services/workspaceRegistry/index.mjs.map +1 -1
- package/dist/src/services/workspaceRegistry/sync.cjs +148 -0
- package/dist/src/services/workspaceRegistry/sync.cjs.map +1 -0
- package/dist/src/services/workspaceRegistry/sync.d.mts +34 -0
- package/dist/src/services/workspaceRegistry/sync.d.mts.map +1 -0
- package/dist/src/services/workspaceRegistry/sync.mjs +140 -0
- package/dist/src/services/workspaceRegistry/sync.mjs.map +1 -0
- package/dist/src/services/workspaceRegistry/workspaceRecords.cjs +114 -0
- package/dist/src/services/workspaceRegistry/workspaceRecords.cjs.map +1 -0
- package/dist/src/services/workspaceRegistry/workspaceRecords.d.mts +31 -0
- package/dist/src/services/workspaceRegistry/workspaceRecords.d.mts.map +1 -0
- package/dist/src/services/workspaceRegistry/workspaceRecords.mjs +101 -0
- package/dist/src/services/workspaceRegistry/workspaceRecords.mjs.map +1 -0
- package/dist/src/systems/child/adapters/headlessChildSessionService.cjs +339 -202
- package/dist/src/systems/child/adapters/headlessChildSessionService.cjs.map +1 -1
- package/dist/src/systems/child/adapters/headlessChildSessionService.d.mts +16 -21
- package/dist/src/systems/child/adapters/headlessChildSessionService.d.mts.map +1 -1
- package/dist/src/systems/child/adapters/headlessChildSessionService.mjs +329 -191
- package/dist/src/systems/child/adapters/headlessChildSessionService.mjs.map +1 -1
- package/dist/src/systems/child/services/childSession/index.cjs +94 -20
- package/dist/src/systems/child/services/childSession/index.cjs.map +1 -1
- package/dist/src/systems/child/services/childSession/index.d.mts +12 -3
- package/dist/src/systems/child/services/childSession/index.d.mts.map +1 -1
- package/dist/src/systems/child/services/childSession/index.mjs +94 -20
- package/dist/src/systems/child/services/childSession/index.mjs.map +1 -1
- package/dist/src/systems/child/types/childSession.cjs +33 -13
- package/dist/src/systems/child/types/childSession.cjs.map +1 -1
- package/dist/src/systems/child/types/childSession.d.mts +143 -80
- package/dist/src/systems/child/types/childSession.d.mts.map +1 -1
- package/dist/src/systems/child/types/childSession.mjs +24 -9
- package/dist/src/systems/child/types/childSession.mjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessHost.cjs +30 -27
- package/dist/src/systems/main/adapters/headlessHost.cjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessHost.d.mts +22 -22
- package/dist/src/systems/main/adapters/headlessHost.d.mts.map +1 -1
- package/dist/src/systems/main/adapters/headlessHost.mjs +33 -30
- package/dist/src/systems/main/adapters/headlessHost.mjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs +248 -229
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.d.mts +4 -5
- package/dist/src/systems/main/adapters/headlessSessionHost.d.mts.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs +239 -219
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
- package/dist/src/systems/main/types/headlessHost.d.mts +16 -14
- package/dist/src/systems/main/types/headlessHost.d.mts.map +1 -1
- package/dist/src/testing/pi/testHost.cjs +2 -2
- package/dist/src/testing/pi/testHost.cjs.map +1 -1
- package/dist/src/testing/pi/testHost.d.mts +3 -2
- package/dist/src/testing/pi/testHost.mjs +3 -3
- package/dist/src/testing/pi/testHost.mjs.map +1 -1
- package/dist/src/types/config.d.mts +1 -1
- package/dist/src/types/config.d.mts.map +1 -1
- package/dist/src/types/kernel.d.mts +3 -3
- package/dist/src/types/server/directHarnessRuntime.d.mts +54 -25
- package/dist/src/types/server/directHarnessRuntime.d.mts.map +1 -1
- package/dist/src/types/server/sessionToolSurface.d.mts +9 -9
- package/dist/src/web/services/apiClient/index.d.mts +1 -0
- package/dist/src/web/services/apiPaths/index.cjs.map +1 -1
- package/dist/src/web/services/apiPaths/index.d.mts +1 -1
- package/dist/src/web/services/apiPaths/index.mjs.map +1 -1
- package/dist/src/web/services/mcpWidget.cjs.map +1 -1
- package/dist/src/web/services/mcpWidget.d.mts +2 -2
- package/dist/src/web/services/mcpWidget.d.mts.map +1 -1
- package/dist/src/web/services/mcpWidget.mjs.map +1 -1
- package/dist/src/web/services/testing/templateRail.cjs +3 -0
- package/dist/src/web/services/testing/templateRail.cjs.map +1 -1
- package/dist/src/web/services/testing/templateRail.mjs +3 -0
- package/dist/src/web/services/testing/templateRail.mjs.map +1 -1
- package/dist/src/web/types/mcpWidget.d.mts +1 -1
- package/dist/src/web/types/nativeTemplate.d.mts +1 -1
- package/dist/src/web/types/nativeTemplate.d.mts.map +1 -1
- package/dist/src/web/types/template.d.mts +8 -0
- package/dist/src/web/types/template.d.mts.map +1 -1
- package/dist/src/web/types/webPlugin.d.mts +17 -5
- package/dist/src/web/types/webPlugin.d.mts.map +1 -1
- package/dist/testMode.cjs +4 -0
- package/dist/testMode.d.mts +2 -0
- package/dist/testMode.mjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +2 -2
- package/dist/toolInventory.cjs.map +1 -1
- package/dist/toolInventory.mjs.map +1 -1
- package/dist/toolNames.mjs +1 -2
- package/dist/toolOverrides.cjs +4 -4
- package/dist/toolOverrides.d.mts +3 -3
- package/dist/toolOverrides.mjs +3 -3
- package/dist/toolSurface.cjs +4 -4
- package/dist/toolSurface.d.mts +3 -3
- package/dist/toolSurface.mjs +3 -3
- package/dist/transition.cjs +3 -3
- package/dist/transition.d.cjs +3 -3
- package/dist/transition.d.mts +2 -2
- package/dist/transition.mjs +1 -2
- package/dist/transitionClassifier.cjs.map +1 -1
- package/dist/transitionClassifier.d.mts +2 -2
- package/dist/transitionClassifier.d.mts.map +1 -1
- package/dist/transitionClassifier.mjs.map +1 -1
- package/dist/transitionCoordinator.cjs +3 -3
- package/dist/transitionCoordinator.cjs.map +1 -1
- package/dist/transitionCoordinator.d.mts +4 -4
- package/dist/transitionCoordinator.d.mts.map +1 -1
- package/dist/transitionCoordinator.mjs +3 -3
- package/dist/transitionCoordinator.mjs.map +1 -1
- package/dist/typesContextApi.d.mts +2 -1
- package/dist/typesContextApi.d.mts.map +1 -1
- package/dist/uiHub.cjs +3 -3
- package/dist/uiHub.d.mts +2 -2
- package/dist/uiHub.mjs +1 -2
- package/dist/voiceTools.cjs +5 -5
- package/dist/voiceTools.d.mts +3 -3
- package/dist/voiceTools.mjs +3 -3
- package/dist/web.cjs +8 -0
- package/dist/web.d.mts +3 -2
- package/dist/web.mjs +2 -1
- package/dist/webCompositions.cjs.map +1 -1
- package/dist/webCompositions.d.mts +7 -7
- package/dist/webCompositions.d.mts.map +1 -1
- package/dist/webCompositions.mjs.map +1 -1
- package/licenses/Codex-Apache-2.0.txt +201 -0
- package/package.json +58 -53
- package/dist/doomPackage.cjs +0 -61
- package/dist/doomPackage.cjs.map +0 -1
- package/dist/doomPackage.d.mts +0 -17
- package/dist/doomPackage.d.mts.map +0 -1
- package/dist/doomPackage.mjs +0 -54
- package/dist/doomPackage.mjs.map +0 -1
- package/dist/jsonlSessionRepo.cjs +0 -44
- package/dist/jsonlSessionRepo.cjs.map +0 -1
- package/dist/jsonlSessionRepo.d.mts +0 -7
- package/dist/jsonlSessionRepo.d.mts.map +0 -1
- package/dist/jsonlSessionRepo.mjs +0 -42
- package/dist/jsonlSessionRepo.mjs.map +0 -1
- package/dist/runtimeJson.cjs.map +0 -1
- package/dist/runtimeJson.d.mts.map +0 -1
- package/dist/runtimeJson.mjs.map +0 -1
- package/dist/runtimePiSettings.cjs.map +0 -1
- package/dist/runtimePiSettings.d.mts.map +0 -1
- package/dist/runtimePiSettings.mjs.map +0 -1
- package/dist/serverFacet.cjs +0 -34
- package/dist/serverFacet.d.mts +0 -10
- package/dist/serverFacet.mjs +0 -9
- package/dist/src/pi/piWebSocketListener.cjs +0 -115
- package/dist/src/pi/piWebSocketListener.cjs.map +0 -1
- package/dist/src/pi/piWebSocketListener.mjs +0 -115
- package/dist/src/pi/piWebSocketListener.mjs.map +0 -1
- package/dist/src/schemas/serverFacet.cjs +0 -111
- package/dist/src/schemas/serverFacet.cjs.map +0 -1
- package/dist/src/schemas/serverFacet.d.mts +0 -152
- package/dist/src/schemas/serverFacet.d.mts.map +0 -1
- package/dist/src/schemas/serverFacet.mjs +0 -101
- package/dist/src/schemas/serverFacet.mjs.map +0 -1
- package/dist/src/schemas/sessionUpdates.d.mts +0 -34
- package/dist/src/schemas/sessionUpdates.d.mts.map +0 -1
- package/dist/src/server/headlessProtocol.cjs +0 -382
- package/dist/src/server/headlessProtocol.cjs.map +0 -1
- package/dist/src/server/headlessProtocol.mjs +0 -382
- package/dist/src/server/headlessProtocol.mjs.map +0 -1
- package/dist/src/server/nativeChildTranscriptReader.cjs +0 -20
- package/dist/src/server/nativeChildTranscriptReader.cjs.map +0 -1
- package/dist/src/server/nativeChildTranscriptReader.mjs +0 -18
- package/dist/src/server/nativeChildTranscriptReader.mjs.map +0 -1
- package/dist/src/server/serverFacetLoader.cjs +0 -214
- package/dist/src/server/serverFacetLoader.cjs.map +0 -1
- package/dist/src/server/serverFacetLoader.d.mts +0 -72
- package/dist/src/server/serverFacetLoader.d.mts.map +0 -1
- package/dist/src/server/serverFacetLoader.mjs +0 -212
- package/dist/src/server/serverFacetLoader.mjs.map +0 -1
- package/dist/src/services/acpSessionUpdates/index.cjs +0 -129
- package/dist/src/services/acpSessionUpdates/index.cjs.map +0 -1
- package/dist/src/services/acpSessionUpdates/index.mjs +0 -129
- package/dist/src/services/acpSessionUpdates/index.mjs.map +0 -1
- package/dist/src/services/historyImport/index.cjs +0 -8
- package/dist/src/services/historyImport/index.cjs.map +0 -1
- package/dist/src/services/historyImport/index.d.mts +0 -68
- package/dist/src/services/historyImport/index.d.mts.map +0 -1
- package/dist/src/services/historyImport/index.mjs +0 -8
- package/dist/src/services/historyImport/index.mjs.map +0 -1
- package/dist/src/services/openSessionRegistry/index.d.mts.map +0 -1
- package/dist/src/services/requestReceipts/index.cjs.map +0 -1
- package/dist/src/services/requestReceipts/index.d.mts +0 -11
- package/dist/src/services/requestReceipts/index.d.mts.map +0 -1
- package/dist/src/services/requestReceipts/index.mjs.map +0 -1
- package/dist/src/services/rpcTranscript/index.cjs +0 -633
- package/dist/src/services/rpcTranscript/index.cjs.map +0 -1
- package/dist/src/services/rpcTranscript/index.d.mts +0 -50
- package/dist/src/services/rpcTranscript/index.d.mts.map +0 -1
- package/dist/src/services/rpcTranscript/index.mjs +0 -632
- package/dist/src/services/rpcTranscript/index.mjs.map +0 -1
- package/dist/src/services/serverFacet/index.cjs.map +0 -1
- package/dist/src/services/serverFacet/index.d.mts +0 -31
- package/dist/src/services/serverFacet/index.d.mts.map +0 -1
- package/dist/src/services/serverFacet/index.mjs.map +0 -1
- package/dist/src/services/workspaceRegistry/index.d.mts.map +0 -1
- package/dist/src/systems/child/adapters/nativeChildRuntimes.cjs +0 -28
- package/dist/src/systems/child/adapters/nativeChildRuntimes.cjs.map +0 -1
- package/dist/src/systems/child/adapters/nativeChildRuntimes.mjs +0 -25
- package/dist/src/systems/child/adapters/nativeChildRuntimes.mjs.map +0 -1
- package/dist/terminalPiChildSessionService.cjs +0 -324
- package/dist/terminalPiChildSessionService.cjs.map +0 -1
- package/dist/terminalPiChildSessionService.d.mts +0 -46
- package/dist/terminalPiChildSessionService.d.mts.map +0 -1
- package/dist/terminalPiChildSessionService.mjs +0 -318
- package/dist/terminalPiChildSessionService.mjs.map +0 -1
- package/dist/v3Export.cjs +0 -10
- package/dist/v3Export.cjs.map +0 -1
- package/dist/v3Export.d.mts +0 -35
- package/dist/v3Export.d.mts.map +0 -1
- package/dist/v3Export.mjs +0 -9
- package/dist/v3Export.mjs.map +0 -1
|
@@ -1,46 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SessionIdentityDoc, SessionMetadataDoc
|
|
3
|
-
import
|
|
1
|
+
import { PoHeadlessToolBusyError } from "../schemas/headless.mjs";
|
|
2
|
+
import { AgentLockDoc, FastModeDoc, IdentityHistoryDoc, LabelsDoc, SessionIdentityDoc, SessionMetadataDoc } from "../services/durableSession/docs.mjs";
|
|
3
|
+
import "../schemas/profileIdentity.mjs";
|
|
4
4
|
import { projectDurableEntries } from "../services/transcriptPages/index.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { formatSkillsForSystemPrompt } from "../services/
|
|
5
|
+
import { SESSION_GROUPS_CHANGED_FRAME } from "../schemas/sessionProtocol.mjs";
|
|
6
|
+
import { formatSkillsForSystemPrompt } from "../services/skillPrompt/index.mjs";
|
|
7
|
+
import { AGENT_SETTLED_ENTRY_TYPE } from "../constants/agentSettled.mjs";
|
|
8
|
+
import { contextTokensOf, contextUsageOf } from "../services/contextUsage/index.mjs";
|
|
9
|
+
import { initializeDurableNavigation, navigateDurableConversation } from "../services/durableNavigation/index.mjs";
|
|
10
|
+
import { HeldQueueDoc } from "../services/durableQueue/docs.mjs";
|
|
11
|
+
import { admitSelected, heldContent, heldRequestId } from "../services/durableQueue/index.mjs";
|
|
12
|
+
import { SubagentsExtension } from "../services/durableSubagents/extension.mjs";
|
|
13
|
+
import { subagentConversations } from "../services/durableSubagents/index.mjs";
|
|
14
|
+
import { convertToLlm } from "../services/piMessages/index.mjs";
|
|
7
15
|
import { randomUUID } from "node:crypto";
|
|
8
|
-
import {
|
|
9
|
-
import { AgentDoc, CompactionTask, GenerationTask, Harness, InboxDoc, LiveDoc, ToolTask, UsageDoc, UserEntry, createRegistry, defineDoc, hook, watchEvents } from "@earendil-works/pi-durable";
|
|
16
|
+
import { AgentDoc, CompactionTask, DEFAULT_COMPACTION_POLICY, GenerationTask, Harness, InboxDoc, LiveDoc, ProviderDoc, ToolTask, UsageDoc, createRegistry, hook, watchEvents } from "@earendil-works/pi-durable";
|
|
10
17
|
import { BACKGROUND_CONTEXT, awaitWithContext, withAbortSignal } from "@earendil-works/chord/context";
|
|
11
|
-
import { isDeepStrictEqual } from "node:util";
|
|
12
18
|
import { createAssistantMessageEventStream, createModels, getSupportedThinkingLevels } from "@earendil-works/pi-ai";
|
|
19
|
+
import { isDeepStrictEqual } from "node:util";
|
|
13
20
|
import { getCurrentSystemPrompt, getCurrentTools } from "@earendil-works/pi-ai/utils/transcript";
|
|
14
|
-
import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
|
|
15
21
|
//#region src/server/directHarnessRuntime.ts
|
|
16
|
-
const AGENT_SETTLED_ENTRY_TYPE = "po.agent-settled";
|
|
17
|
-
const LifecycleDoc = defineDoc({
|
|
18
|
-
kind: "po.server.lifecycle",
|
|
19
|
-
version: 1,
|
|
20
|
-
scope: "session",
|
|
21
|
-
initial: () => ({ json: "{\"revision\":0,\"paused\":false,\"queue\":[]}" })
|
|
22
|
-
});
|
|
23
|
-
const FastModeDoc = defineDoc({
|
|
24
|
-
kind: "po.fast-mode",
|
|
25
|
-
version: 1,
|
|
26
|
-
scope: "session",
|
|
27
|
-
initial: () => ({ enabled: false })
|
|
28
|
-
});
|
|
29
|
-
const AgentLockDoc = defineDoc({
|
|
30
|
-
kind: "po.agent-lock",
|
|
31
|
-
version: 1,
|
|
32
|
-
scope: "session",
|
|
33
|
-
initial: () => ({ locked: false })
|
|
34
|
-
});
|
|
35
22
|
const AGENT_LOCKED_ERROR = "The local agent is locked. Unlock it to start a turn.";
|
|
36
23
|
const CODEX_API = "openai-codex-responses";
|
|
37
24
|
const CODEX_PROVIDER = "openai-codex";
|
|
38
|
-
const LabelsDoc = defineDoc({
|
|
39
|
-
kind: "po.labels",
|
|
40
|
-
version: 1,
|
|
41
|
-
scope: "session",
|
|
42
|
-
initial: () => ({ labels: {} })
|
|
43
|
-
});
|
|
44
25
|
function nativeId(id) {
|
|
45
26
|
const value = Number(id);
|
|
46
27
|
if (!Number.isSafeInteger(value) || value < 0 || String(value) !== id) throw new Error(`Invalid durable identifier: ${id}`);
|
|
@@ -54,12 +35,26 @@ function text(message) {
|
|
|
54
35
|
if (!("content" in message)) return "summary" in message ? message.summary : "output" in message ? message.output : "";
|
|
55
36
|
return typeof message.content === "string" ? message.content : message.content.map((p) => p.type === "text" ? p.text : "").join("");
|
|
56
37
|
}
|
|
38
|
+
function fromContent(content) {
|
|
39
|
+
const images = (typeof content === "string" ? [{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: content
|
|
42
|
+
}] : content).filter((part) => part.type === "image");
|
|
43
|
+
return {
|
|
44
|
+
text: text({
|
|
45
|
+
role: "user",
|
|
46
|
+
content,
|
|
47
|
+
timestamp: 0
|
|
48
|
+
}),
|
|
49
|
+
...images.length ? { images } : {}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
57
52
|
/** Compatibility projection keeps protocol identities strings and retains fork ancestry. */
|
|
58
|
-
async function projectDurableConversationEntries(conversation, context) {
|
|
53
|
+
async function projectDurableConversationEntries(conversation, context, minEntryId) {
|
|
59
54
|
const records = [];
|
|
60
55
|
let cursor;
|
|
61
56
|
do {
|
|
62
|
-
const page = await conversation.entries({}, 256, cursor, context);
|
|
57
|
+
const page = await conversation.entries(minEntryId === void 0 ? {} : { minEntryId }, 256, cursor, context);
|
|
63
58
|
records.push(...page.items);
|
|
64
59
|
cursor = page.next;
|
|
65
60
|
} while (cursor);
|
|
@@ -69,30 +64,51 @@ async function projectDurableConversationEntries(conversation, context) {
|
|
|
69
64
|
/**
|
|
70
65
|
* Runs one prompt and returns the newest assistant text it produced. `hold` keeps the run open
|
|
71
66
|
* across later turns started by intercom delivery: while it resolves true, wait for the lane to
|
|
72
|
-
* go idle and ask again. The returned text is the newest one across all of those turns.
|
|
67
|
+
* go idle and ask again. The returned text is the newest one across all of those turns. With a
|
|
68
|
+
* `requestId` the prompt is admitted once: a later call, such as one after a restart, waits for it.
|
|
73
69
|
*/
|
|
74
|
-
async function promptForAssistantText(runtime, prompt, hold) {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
async function promptForAssistantText(runtime, prompt, hold, requestId) {
|
|
71
|
+
const lane = runtime.lane;
|
|
72
|
+
const receipt = requestId === void 0 ? void 0 : await runtime.harness.commit((tx) => tx.submissionByRequest(lane.id, requestId), BACKGROUND_CONTEXT);
|
|
73
|
+
const before = (await runtime.readEntries()).entries;
|
|
74
|
+
const previous = new Set((receipt?.entry === void 0 ? before : before.filter((e) => Number(e.id) <= receipt.entry)).map((e) => e.id));
|
|
75
|
+
if (receipt) {
|
|
76
|
+
const settled = await (await runtime.harness.submission(receipt.id, BACKGROUND_CONTEXT))?.wait(BACKGROUND_CONTEXT);
|
|
77
|
+
if (settled?.status === "unanswered" && settled.reason === "aborted") throw Object.assign(/* @__PURE__ */ new Error("The prompt was stopped before it was answered"), { name: "AbortError" });
|
|
78
|
+
} else await (await runtime.submitInternalMessage(prompt, void 0, requestId)).settled;
|
|
79
|
+
while (hold && await hold()) await lane.waitForIdle(BACKGROUND_CONTEXT);
|
|
78
80
|
return (await runtime.readEntries()).entries.toReversed().filter((e) => !previous.has(e.id)).flatMap((e) => e.type === "message" && e.message.role === "assistant" ? [text(e.message).trim()] : [])[0] || void 0;
|
|
79
81
|
}
|
|
80
|
-
|
|
82
|
+
function createDirectHarnessRuntime(options) {
|
|
83
|
+
return createLaneRuntime(options, void 0);
|
|
84
|
+
}
|
|
85
|
+
/** The extension holding one lane's tools, prompt and hooks. */
|
|
86
|
+
function laneExtensionName(conversationId) {
|
|
87
|
+
return `po.lane-${conversationId}`;
|
|
88
|
+
}
|
|
89
|
+
/** The main lane opens its Harness; a further lane runs on the main lane's Harness as one more conversation. */
|
|
90
|
+
async function createLaneRuntime(options, attached) {
|
|
81
91
|
if (options.initialFastMode !== void 0 && typeof options.initialFastMode !== "boolean") throw new Error("Initial Fast mode must be a boolean.");
|
|
82
92
|
if (options.initialAgentLocked !== void 0 && typeof options.initialAgentLocked !== "boolean") throw new Error("Initial agent lock must be a boolean.");
|
|
83
93
|
const context = options.context ?? BACKGROUND_CONTEXT;
|
|
84
|
-
if (options.storage === "jsonl" || options.legacySessionPath !== void 0) throw new Error("Legacy JSONL direct storage is unsupported; use durable-v1 SQLite");
|
|
85
94
|
if (options.session && !options.durableStorage) throw new Error("A durable Session injection requires its raw durableStorage");
|
|
86
|
-
const
|
|
95
|
+
const platform = options.platform;
|
|
96
|
+
const storage = attached?.storage ?? (options.durableStorage ? {
|
|
87
97
|
storage: options.durableStorage,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
assertWritable() {},
|
|
99
|
+
release: async () => {}
|
|
100
|
+
} : await platform.sessions.open({
|
|
101
|
+
sessionId: options.sessionId,
|
|
102
|
+
parentSessionId: options.parentSessionId,
|
|
103
|
+
existing: options.resume
|
|
104
|
+
}, context));
|
|
92
105
|
let startupHarness;
|
|
93
106
|
try {
|
|
94
|
-
const registry = createRegistry();
|
|
95
|
-
const environment =
|
|
107
|
+
const registry = attached?.registry ?? createRegistry();
|
|
108
|
+
const environment = attached ? void 0 : platform.env(options.cwd);
|
|
109
|
+
const laneProviderSessions = attached?.laneProviderSessions ?? /* @__PURE__ */ new Set();
|
|
110
|
+
const manualCompaction = attached?.manualCompaction ?? {};
|
|
111
|
+
const extensionName = attached ? laneExtensionName(attached.conversation.id) : "po.host";
|
|
96
112
|
let disposed = false;
|
|
97
113
|
let quarantined = false;
|
|
98
114
|
let failure;
|
|
@@ -107,6 +123,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
107
123
|
let tools = options.tools ?? [];
|
|
108
124
|
let activeNames = new Set(options.activeToolNames ?? tools.map((t) => t.name));
|
|
109
125
|
let settings = {
|
|
126
|
+
extensions: [{ name: "po.host" }],
|
|
110
127
|
stream: options.streamOptions,
|
|
111
128
|
retry: options.retry,
|
|
112
129
|
compaction: options.compaction,
|
|
@@ -117,6 +134,17 @@ async function createDirectHarnessRuntime(options) {
|
|
|
117
134
|
const listeners = /* @__PURE__ */ new Set();
|
|
118
135
|
const eventListeners = /* @__PURE__ */ new Set();
|
|
119
136
|
const checkpointBoundaries = /* @__PURE__ */ new Set();
|
|
137
|
+
const toolBoundaryQueue = [];
|
|
138
|
+
let toolBoundaryDrain;
|
|
139
|
+
const flushToolBoundary = () => {
|
|
140
|
+
if (toolBoundaryDrain) return toolBoundaryDrain;
|
|
141
|
+
toolBoundaryDrain = (async () => {
|
|
142
|
+
while (toolBoundaryQueue.length && !disposed && !disposePromise) await toolBoundaryQueue.shift().run();
|
|
143
|
+
})().finally(() => {
|
|
144
|
+
toolBoundaryDrain = void 0;
|
|
145
|
+
});
|
|
146
|
+
return toolBoundaryDrain;
|
|
147
|
+
};
|
|
120
148
|
const emit = (frame) => {
|
|
121
149
|
for (const listener of listeners) try {
|
|
122
150
|
listener(frame);
|
|
@@ -130,7 +158,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
130
158
|
const writable = async (work) => {
|
|
131
159
|
if (disposed || quarantined) throw new Error("Direct harness writes are unavailable", { cause: failure });
|
|
132
160
|
try {
|
|
133
|
-
await storage.
|
|
161
|
+
await storage.assertWritable();
|
|
134
162
|
return await work();
|
|
135
163
|
} catch (error) {
|
|
136
164
|
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
@@ -179,22 +207,23 @@ async function createDirectHarnessRuntime(options) {
|
|
|
179
207
|
"fetchDeferred"
|
|
180
208
|
].includes(String(key))) return value.bind(target);
|
|
181
209
|
return (...args) => {
|
|
182
|
-
if (disposed || quarantined || preparationFailure) throw new Error("Model dispatch unavailable", { cause: preparationFailure });
|
|
183
|
-
options.guardModelRequest?.();
|
|
184
|
-
const request = args[1];
|
|
185
|
-
if (!["complete", "completeSimple"].includes(String(key)) && request?.tools?.some((t) => !activeNames.has(t.name))) throw new Error("Model request contains disabled tools");
|
|
186
210
|
const requestOptions = args[2];
|
|
211
|
+
const lane = typeof requestOptions?.sessionId === "string" && laneProviderSessions.has(requestOptions.sessionId);
|
|
212
|
+
if (disposed || quarantined || !lane && preparationFailure) throw new Error("Model dispatch unavailable", { cause: preparationFailure });
|
|
213
|
+
if (!lane) options.guardModelRequest?.();
|
|
214
|
+
const request = args[1];
|
|
215
|
+
if (!lane && !["complete", "completeSimple"].includes(String(key)) && request?.tools?.some((t) => !activeNames.has(t.name))) throw new Error("Model request contains disabled tools");
|
|
187
216
|
const usePriority = fastMode && args[0].api === CODEX_API && args[0].provider === CODEX_PROVIDER;
|
|
188
217
|
const originalOnPayload = requestOptions?.onPayload;
|
|
189
218
|
args[2] = {
|
|
190
219
|
...requestOptions,
|
|
191
|
-
sessionId: key === "complete" ? requestOptions?.sessionId ?? sessionId : sessionId,
|
|
220
|
+
sessionId: lane ? requestOptions.sessionId : key === "complete" ? requestOptions?.sessionId ?? sessionId : sessionId,
|
|
192
221
|
...usePriority ? { serviceTier: "priority" } : {},
|
|
193
222
|
onPayload: async (payload, model) => {
|
|
194
|
-
options.guardModelRequest?.();
|
|
223
|
+
if (!lane) options.guardModelRequest?.();
|
|
195
224
|
const original = typeof originalOnPayload === "function" ? await originalOnPayload(payload, model) : void 0;
|
|
196
225
|
const transformed = original === void 0 ? payload : original;
|
|
197
|
-
const patch = await options.beforePayload?.({
|
|
226
|
+
const patch = lane ? void 0 : await options.beforePayload?.({
|
|
198
227
|
payload: transformed,
|
|
199
228
|
model
|
|
200
229
|
}, context);
|
|
@@ -302,8 +331,12 @@ async function createDirectHarnessRuntime(options) {
|
|
|
302
331
|
executionMode: tool.executionMode,
|
|
303
332
|
async execute(args, api, ctx) {
|
|
304
333
|
if (!activeNames.has(tool.name)) throw new Error(`Tool '${tool.name}' is no longer active`);
|
|
334
|
+
let reported = "";
|
|
305
335
|
const pending = tool.execute(api.callId, args, (partial) => {
|
|
306
|
-
|
|
336
|
+
const snapshot = partial.content.map((part) => part.type === "text" ? part.text : "").join("");
|
|
337
|
+
const chunk = snapshot.startsWith(reported) ? snapshot.slice(reported.length) : `\n${snapshot}`;
|
|
338
|
+
reported = snapshot;
|
|
339
|
+
if (chunk) api.output(chunk);
|
|
307
340
|
if (partial.details !== void 0) api.details(json(partial.details), ctx).catch((error) => emit({
|
|
308
341
|
type: "error",
|
|
309
342
|
error: String(error)
|
|
@@ -320,14 +353,14 @@ async function createDirectHarnessRuntime(options) {
|
|
|
320
353
|
}, ctx);
|
|
321
354
|
const result = await awaitWithContext(pending, ctx);
|
|
322
355
|
return {
|
|
323
|
-
|
|
356
|
+
output: result.content,
|
|
324
357
|
isError: result.isError,
|
|
325
358
|
...result.details === void 0 ? {} : { details: json(result.details) }
|
|
326
359
|
};
|
|
327
360
|
}
|
|
328
361
|
});
|
|
329
362
|
const install = () => registry.install({
|
|
330
|
-
name:
|
|
363
|
+
name: extensionName,
|
|
331
364
|
tools: tools.map(nativeTool),
|
|
332
365
|
sections: [{
|
|
333
366
|
key: "po",
|
|
@@ -347,6 +380,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
347
380
|
async afterTools(_assistant, _results, api, ctx) {
|
|
348
381
|
const lane = conversation;
|
|
349
382
|
if (lane.id !== api.conversationId) return;
|
|
383
|
+
await flushToolBoundary();
|
|
350
384
|
for (const registration of checkpointBoundaries) {
|
|
351
385
|
if (!registration.active || disposed || ctx.abortSignal?.aborted || external) continue;
|
|
352
386
|
let open = true;
|
|
@@ -360,13 +394,9 @@ async function createDirectHarnessRuntime(options) {
|
|
|
360
394
|
}
|
|
361
395
|
}
|
|
362
396
|
},
|
|
363
|
-
async beforeRequest(request,
|
|
397
|
+
async beforeRequest(request, _api, ctx) {
|
|
364
398
|
assertUnlocked();
|
|
365
399
|
try {
|
|
366
|
-
const live = await api.snapshot(LiveDoc, api.conversationId, ctx);
|
|
367
|
-
const retained = await api.snapshot(LifecycleDoc, ctx);
|
|
368
|
-
const queue = JSON.parse(retained?.json ?? "{\"queue\":[]}");
|
|
369
|
-
if (live?.run && queue.queue.some((item) => item.operationId !== void 0 && item.submissionId !== void 0 && live.run.inputs.includes(item.submissionId) && item.operationId !== String(live.run.inputs[0]))) throw new Error("Steering target changed before model admission");
|
|
370
400
|
const agent = await conversation.agent(ctx);
|
|
371
401
|
const model = agent.model ? models.getModel(agent.model.provider, agent.model.modelId) : void 0;
|
|
372
402
|
await options.beforeModelRequest?.({
|
|
@@ -376,7 +406,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
376
406
|
resources
|
|
377
407
|
}, ctx);
|
|
378
408
|
const systemPrompt = getCurrentSystemPrompt(request.messages);
|
|
379
|
-
const contextMessages = options.transformContext ?
|
|
409
|
+
const contextMessages = options.transformContext ? restoreCustomContextMessages(request.messages, await conversation.context(ctx)) : request.messages.filter((message) => message.role !== "system");
|
|
380
410
|
const originalContext = structuredClone(contextMessages);
|
|
381
411
|
const patch = await options.transformContext?.({
|
|
382
412
|
messages: contextMessages,
|
|
@@ -419,14 +449,16 @@ async function createDirectHarnessRuntime(options) {
|
|
|
419
449
|
toolCallId: call.id,
|
|
420
450
|
toolName: call.name,
|
|
421
451
|
args: call.arguments,
|
|
422
|
-
content: result.
|
|
452
|
+
content: result.output ?? [],
|
|
423
453
|
details: result.details,
|
|
424
454
|
isError: result.isError ?? false,
|
|
425
455
|
usage: result.usage
|
|
426
456
|
}, ctx);
|
|
457
|
+
const { content: patchedOutput, terminate: _terminate, ...patchFields } = patch ?? {};
|
|
427
458
|
return patch ? {
|
|
428
459
|
...result,
|
|
429
|
-
...
|
|
460
|
+
...patchFields,
|
|
461
|
+
...patchedOutput === void 0 ? {} : { output: patchedOutput },
|
|
430
462
|
control: patch.terminate || terminatingCalls.delete(call.id) ? {
|
|
431
463
|
...result.control,
|
|
432
464
|
terminate: true
|
|
@@ -440,7 +472,9 @@ async function createDirectHarnessRuntime(options) {
|
|
|
440
472
|
} : void 0;
|
|
441
473
|
}
|
|
442
474
|
}),
|
|
443
|
-
hook(CompactionTask, { async beforeCompact(input,
|
|
475
|
+
hook(CompactionTask, { async beforeCompact(input, api, ctx) {
|
|
476
|
+
const swapped = manualCompaction.conversationId;
|
|
477
|
+
if (input.reason === "threshold" && swapped !== void 0 && swapped !== String(api.conversationId)) return { decline: true };
|
|
444
478
|
if (!options.beforeCompaction) return;
|
|
445
479
|
const entries = projectDurableEntries(input.entries);
|
|
446
480
|
const patch = await options.beforeCompaction({
|
|
@@ -461,9 +495,9 @@ async function createDirectHarnessRuntime(options) {
|
|
|
461
495
|
edited: /* @__PURE__ */ new Set()
|
|
462
496
|
},
|
|
463
497
|
settings: {
|
|
464
|
-
enabled: options.compaction?.enabled ??
|
|
465
|
-
reserveTokens: options.compaction?.reserveTokens ??
|
|
466
|
-
keepRecentTokens: options.compaction?.keepRecentTokens ??
|
|
498
|
+
enabled: options.compaction?.enabled ?? DEFAULT_COMPACTION_POLICY.enabled,
|
|
499
|
+
reserveTokens: options.compaction?.reserveTokens ?? DEFAULT_COMPACTION_POLICY.reserveTokens,
|
|
500
|
+
keepRecentTokens: options.compaction?.keepRecentTokens ?? DEFAULT_COMPACTION_POLICY.keepRecentTokens
|
|
467
501
|
}
|
|
468
502
|
}
|
|
469
503
|
}, ctx);
|
|
@@ -473,7 +507,8 @@ async function createDirectHarnessRuntime(options) {
|
|
|
473
507
|
]
|
|
474
508
|
});
|
|
475
509
|
install();
|
|
476
|
-
|
|
510
|
+
if (!attached) registry.install(SubagentsExtension);
|
|
511
|
+
const harness = attached?.harness ?? await Harness.open(storage.storage, {
|
|
477
512
|
models,
|
|
478
513
|
registry,
|
|
479
514
|
get settings() {
|
|
@@ -485,71 +520,109 @@ async function createDirectHarnessRuntime(options) {
|
|
|
485
520
|
error: String(error)
|
|
486
521
|
})
|
|
487
522
|
}, context);
|
|
488
|
-
startupHarness = harness;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
523
|
+
if (!attached) startupHarness = harness;
|
|
524
|
+
let conversation;
|
|
525
|
+
let sessionId;
|
|
526
|
+
if (attached) {
|
|
527
|
+
conversation = attached.conversation;
|
|
528
|
+
if (!options.sessionId) throw new Error("A lane requires its session identity.");
|
|
529
|
+
sessionId = options.sessionId;
|
|
530
|
+
await writable(() => conversation.configure({
|
|
531
|
+
extensions: [{ name: extensionName }],
|
|
532
|
+
tools: tools.filter((t) => activeNames.has(t.name)).map(nativeTool),
|
|
533
|
+
modelTools: null,
|
|
534
|
+
instructions: null,
|
|
535
|
+
cwd: options.cwd,
|
|
536
|
+
...options.model ? { model: {
|
|
537
|
+
provider: options.model.provider,
|
|
538
|
+
modelId: options.model.id
|
|
539
|
+
} } : {},
|
|
540
|
+
...options.thinkingLevel ? { thinkingLevel: options.thinkingLevel } : {}
|
|
541
|
+
}, context));
|
|
542
|
+
const provider = await harness.snapshot(ProviderDoc, conversation.id, context);
|
|
543
|
+
if (provider) laneProviderSessions.add(provider.sessionId);
|
|
544
|
+
} else {
|
|
545
|
+
const root = await harness.root(context, { agent: {
|
|
546
|
+
cwd: options.cwd,
|
|
547
|
+
...options.model ?? models.getModels()[0] ? { model: {
|
|
548
|
+
provider: (options.model ?? models.getModels()[0]).provider,
|
|
549
|
+
modelId: (options.model ?? models.getModels()[0]).id
|
|
550
|
+
} } : {},
|
|
551
|
+
...options.thinkingLevel ? { thinkingLevel: options.thinkingLevel } : {}
|
|
552
|
+
} });
|
|
553
|
+
const activeId = await initializeDurableNavigation(harness, root.id, context);
|
|
554
|
+
conversation = await harness.conversation(activeId, context);
|
|
555
|
+
const storedAgent = await harness.snapshot(AgentDoc, conversation.id, context);
|
|
556
|
+
const initialModel = options.model ?? models.getModels()[0];
|
|
557
|
+
await conversation.configure({
|
|
558
|
+
...!storedAgent?.model && initialModel ? { model: {
|
|
559
|
+
provider: initialModel.provider,
|
|
560
|
+
modelId: initialModel.id
|
|
561
|
+
} } : {},
|
|
562
|
+
...!storedAgent?.thinkingLevel && options.thinkingLevel ? { thinkingLevel: options.thinkingLevel } : {},
|
|
563
|
+
tools: tools.filter((t) => activeNames.has(t.name)).map(nativeTool)
|
|
564
|
+
}, context);
|
|
565
|
+
const storedFastMode = await harness.snapshot(FastModeDoc, context);
|
|
566
|
+
fastMode = storedFastMode?.enabled ?? options.initialFastMode ?? false;
|
|
567
|
+
const storedAgentLock = await harness.snapshot(AgentLockDoc, context);
|
|
568
|
+
agentLocked = storedAgentLock?.locked ?? options.initialAgentLocked ?? false;
|
|
569
|
+
const storedIdentity = await harness.snapshot(SessionIdentityDoc, context);
|
|
570
|
+
const mainSessionId = storedIdentity?.id || options.sessionId || randomUUID();
|
|
571
|
+
sessionId = mainSessionId;
|
|
572
|
+
const lane = conversation;
|
|
573
|
+
await writable(() => harness.commit(async (tx) => {
|
|
574
|
+
const identity = await tx.doc(SessionIdentityDoc);
|
|
575
|
+
if (!identity.id) {
|
|
576
|
+
identity.id = mainSessionId;
|
|
577
|
+
identity.createdAt = Date.now();
|
|
578
|
+
identity.parentSessionId = options.parentSessionId ?? "";
|
|
579
|
+
}
|
|
580
|
+
if (!storedAgentLock && options.initialAgentLocked !== void 0) (await tx.doc(AgentLockDoc)).locked = agentLocked;
|
|
581
|
+
if (!storedFastMode) {
|
|
582
|
+
(await tx.doc(FastModeDoc)).enabled = fastMode;
|
|
583
|
+
if (options.initialFastMode !== void 0) await tx.appendEntry(lane.id, {
|
|
584
|
+
kind: "po.fast-mode",
|
|
585
|
+
data: {
|
|
586
|
+
version: 1,
|
|
587
|
+
enabled: fastMode,
|
|
588
|
+
sessionId: mainSessionId
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
const metadata = await tx.doc(SessionMetadataDoc);
|
|
593
|
+
metadata.workspaceRoot ||= options.cwd;
|
|
594
|
+
if (options.lane !== void 0) metadata.laneName = options.lane;
|
|
595
|
+
if (!storedIdentity?.id && options.sessionName !== void 0) metadata.name = options.sessionName;
|
|
596
|
+
}, context));
|
|
597
|
+
}
|
|
539
598
|
const laneName = options.lane ?? "main";
|
|
540
599
|
let resolveExited;
|
|
541
600
|
const exited = new Promise((resolve) => {
|
|
542
601
|
resolveExited = resolve;
|
|
543
602
|
});
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
603
|
+
let laneRecord = {
|
|
604
|
+
revision: 0,
|
|
605
|
+
paused: false,
|
|
606
|
+
held: []
|
|
607
|
+
};
|
|
608
|
+
const readRecord = async () => attached ? structuredClone(laneRecord) : JSON.parse((await harness.snapshot(HeldQueueDoc, context))?.json ?? "{\"revision\":0,\"paused\":false,\"held\":[]}");
|
|
609
|
+
const changeRecord = async (change) => {
|
|
610
|
+
if (attached) {
|
|
611
|
+
const record = structuredClone(laneRecord);
|
|
612
|
+
const result = change(record);
|
|
613
|
+
record.revision++;
|
|
614
|
+
laneRecord = record;
|
|
615
|
+
return result;
|
|
616
|
+
}
|
|
617
|
+
return writable(() => harness.commit(async (tx) => {
|
|
618
|
+
const doc = await tx.doc(HeldQueueDoc);
|
|
619
|
+
const record = JSON.parse(doc.json);
|
|
620
|
+
const result = change(record);
|
|
621
|
+
record.revision++;
|
|
622
|
+
doc.json = JSON.stringify(record);
|
|
623
|
+
return result;
|
|
624
|
+
}, context));
|
|
625
|
+
};
|
|
553
626
|
let userAdmission = false;
|
|
554
627
|
let promptAdmissions = 0;
|
|
555
628
|
let userAdmissionSettled = Promise.resolve();
|
|
@@ -582,12 +655,54 @@ async function createDirectHarnessRuntime(options) {
|
|
|
582
655
|
kind: "run",
|
|
583
656
|
status: "open"
|
|
584
657
|
} : null);
|
|
658
|
+
const runAtToolBoundary = (callback) => {
|
|
659
|
+
if (disposed || disposePromise) return Promise.reject(/* @__PURE__ */ new Error("Direct harness is disposed"));
|
|
660
|
+
return new Promise((resolve, reject) => {
|
|
661
|
+
const pending = {
|
|
662
|
+
async run() {
|
|
663
|
+
try {
|
|
664
|
+
resolve(await callback());
|
|
665
|
+
} catch (error) {
|
|
666
|
+
reject(error);
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
reject
|
|
670
|
+
};
|
|
671
|
+
toolBoundaryQueue.push(pending);
|
|
672
|
+
nativeExecution().then(async (active) => {
|
|
673
|
+
if (!active && !external) await flushToolBoundary();
|
|
674
|
+
}).catch((error) => {
|
|
675
|
+
const index = toolBoundaryQueue.indexOf(pending);
|
|
676
|
+
if (index !== -1) {
|
|
677
|
+
toolBoundaryQueue.splice(index, 1);
|
|
678
|
+
reject(error);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
};
|
|
585
683
|
const readLifecycle = async () => {
|
|
586
684
|
const record = await readRecord();
|
|
685
|
+
const inbox = await harness.snapshot(InboxDoc, conversation.id, context);
|
|
686
|
+
const handedOff = [];
|
|
687
|
+
for (const item of inbox?.items ?? []) {
|
|
688
|
+
if (item.mode === "write") continue;
|
|
689
|
+
const requestId = (await storage.storage.submission(item.id, context))?.requestId;
|
|
690
|
+
if (!requestId?.startsWith(heldRequestId(""))) continue;
|
|
691
|
+
handedOff.push({
|
|
692
|
+
id: requestId.slice(heldRequestId("").length),
|
|
693
|
+
...fromContent(item.content),
|
|
694
|
+
delivery: item.mode,
|
|
695
|
+
scheduling: "automatic",
|
|
696
|
+
disposition: "handoff"
|
|
697
|
+
});
|
|
698
|
+
}
|
|
587
699
|
return {
|
|
588
700
|
revision: record.revision,
|
|
589
701
|
paused: record.paused,
|
|
590
|
-
queue: record.
|
|
702
|
+
queue: [...handedOff, ...record.held.filter((item) => item.explicitQueue).map(({ explicitQueue: _q, message: _m, entry: _e, ...item }) => ({
|
|
703
|
+
...item,
|
|
704
|
+
disposition: "pending"
|
|
705
|
+
}))],
|
|
591
706
|
operation: await execution()
|
|
592
707
|
};
|
|
593
708
|
};
|
|
@@ -645,33 +760,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
645
760
|
if (watcher) await watcher.stop();
|
|
646
761
|
watcher = await watchEvents(harness, conversation.id, context);
|
|
647
762
|
let predecessor = watcher.snapshot.entries.at(-1)?.id;
|
|
648
|
-
const
|
|
649
|
-
const generatedSources = /* @__PURE__ */ new Map();
|
|
650
|
-
const rememberCustom = (raw) => {
|
|
651
|
-
const projected = projectDurableEntries([raw])[0];
|
|
652
|
-
const data = raw.data && typeof raw.data === "object" && !Array.isArray(raw.data) ? raw.data : void 0;
|
|
653
|
-
if (projected?.type === "message" && projected.message.role === "custom" && typeof data?.inputRequestId === "string") customSources.set(data.inputRequestId, projected.message);
|
|
654
|
-
};
|
|
655
|
-
for (const raw of watcher.snapshot.entries) rememberCustom(raw);
|
|
656
|
-
for (const requestId of customSources.keys()) {
|
|
657
|
-
const receipt = await storage.storage.submissionByRequest(conversation.id, requestId, context);
|
|
658
|
-
if (receipt && receipt.status !== "queued") customSources.delete(requestId);
|
|
659
|
-
}
|
|
660
|
-
const generatedEntrySource = async (raw, ctx) => {
|
|
661
|
-
if (generatedSources.has(raw.id)) return generatedSources.get(raw.id);
|
|
662
|
-
let source;
|
|
663
|
-
if (raw.model?.[0]?.role === "user") for (const [requestId, custom] of customSources) {
|
|
664
|
-
const receipt = await storage.storage.submissionByRequest(conversation.id, requestId, ctx);
|
|
665
|
-
if (receipt && "entry" in receipt && receipt.entry === raw.id) {
|
|
666
|
-
source = custom;
|
|
667
|
-
customSources.delete(requestId);
|
|
668
|
-
break;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
generatedSources.set(raw.id, source);
|
|
672
|
-
while (generatedSources.size > 128) generatedSources.delete(generatedSources.keys().next().value);
|
|
673
|
-
return source;
|
|
674
|
-
};
|
|
763
|
+
const toolOutputs = /* @__PURE__ */ new Map();
|
|
675
764
|
lastAssistant = void 0;
|
|
676
765
|
partial = void 0;
|
|
677
766
|
toolResults = [];
|
|
@@ -684,13 +773,11 @@ async function createDirectHarnessRuntime(options) {
|
|
|
684
773
|
toolResults = [];
|
|
685
774
|
}
|
|
686
775
|
if (event.type === "message_end" || event.type === "entry_appended") {
|
|
687
|
-
rememberCustom(event.entry);
|
|
688
776
|
const entry = projectDurableEntries([event.entry])[0];
|
|
689
|
-
await generatedEntrySource(event.entry, eventContext);
|
|
690
777
|
if (entry) {
|
|
691
778
|
entry.parentId = predecessor === void 0 ? null : String(predecessor);
|
|
692
779
|
const added = {
|
|
693
|
-
type: "
|
|
780
|
+
type: "entry_appended",
|
|
694
781
|
entry
|
|
695
782
|
};
|
|
696
783
|
emit({
|
|
@@ -716,8 +803,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
716
803
|
}
|
|
717
804
|
if (event.type === "message_end" && event.entry.model?.[0]) {
|
|
718
805
|
const projected = projectDurableEntries([event.entry])[0];
|
|
719
|
-
|
|
720
|
-
const message = await generatedEntrySource(event.entry, eventContext) ?? (projected?.type === "message" && projected.message.role === "custom" ? projected.message : event.entry.model[0]);
|
|
806
|
+
const message = projected?.type === "message" && projected.message.role === "custom" ? projected.message : event.entry.model[0];
|
|
721
807
|
if (message.role === "assistant") lastAssistant = message;
|
|
722
808
|
if (message.role === "toolResult") toolResults.push(message);
|
|
723
809
|
mapped = {
|
|
@@ -729,12 +815,13 @@ async function createDirectHarnessRuntime(options) {
|
|
|
729
815
|
}
|
|
730
816
|
if (event.type === "tool_execution_start") mapped = {
|
|
731
817
|
...event,
|
|
732
|
-
type: "
|
|
818
|
+
type: "tool_execution_start"
|
|
733
819
|
};
|
|
734
820
|
if (event.type === "tool_execution_end") {
|
|
821
|
+
toolOutputs.delete(event.toolCallId);
|
|
735
822
|
const result = event.entry?.model?.find((m) => m.role === "toolResult");
|
|
736
823
|
mapped = {
|
|
737
|
-
type: "
|
|
824
|
+
type: "tool_execution_end",
|
|
738
825
|
toolCallId: event.toolCallId,
|
|
739
826
|
toolName: event.toolName,
|
|
740
827
|
result: {
|
|
@@ -775,24 +862,29 @@ async function createDirectHarnessRuntime(options) {
|
|
|
775
862
|
}
|
|
776
863
|
};
|
|
777
864
|
emit({
|
|
778
|
-
|
|
779
|
-
|
|
865
|
+
type: "message_update",
|
|
866
|
+
message: update.message
|
|
780
867
|
});
|
|
781
868
|
eventsSettled = eventsSettled.then(() => deliver(update, eventContext));
|
|
782
869
|
}
|
|
783
870
|
}
|
|
784
|
-
if (event.type === "tool_execution_update")
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
871
|
+
if (event.type === "tool_execution_update") {
|
|
872
|
+
const previous = toolOutputs.get(event.toolCallId) ?? "";
|
|
873
|
+
const output = !event.output ? previous : "set" in event.output ? event.output.set : previous.slice(event.output.trimStart ?? 0) + (event.output.append ?? "");
|
|
874
|
+
toolOutputs.set(event.toolCallId, output);
|
|
875
|
+
mapped = {
|
|
876
|
+
type: "tool_execution_update",
|
|
877
|
+
toolCallId: event.toolCallId,
|
|
878
|
+
toolName: event.toolName,
|
|
879
|
+
partialResult: {
|
|
880
|
+
content: [{
|
|
881
|
+
type: "text",
|
|
882
|
+
text: output
|
|
883
|
+
}],
|
|
884
|
+
details: event.details
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
}
|
|
796
888
|
if (event.type === "compaction_end") {
|
|
797
889
|
const outcome = (await harness.waitForTask(event.taskId, eventContext)).state.outcome;
|
|
798
890
|
const result = outcome.status === "completed" ? outcome.result : void 0;
|
|
@@ -803,7 +895,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
803
895
|
status: outcome.status === "completed" ? result?.entryId !== void 0 || result?.submissionId !== void 0 ? "completed" : "aborted" : outcome.status === "aborted" ? "aborted" : "failed",
|
|
804
896
|
reason: event.reason,
|
|
805
897
|
entryId: entryId === void 0 ? void 0 : String(entryId),
|
|
806
|
-
error:
|
|
898
|
+
error: event.error === void 0 ? void 0 : new Error(event.error)
|
|
807
899
|
};
|
|
808
900
|
}
|
|
809
901
|
if (event.type === "inbox_update") mapped = {
|
|
@@ -820,10 +912,6 @@ async function createDirectHarnessRuntime(options) {
|
|
|
820
912
|
}, eventContext));
|
|
821
913
|
}
|
|
822
914
|
if (!mapped) continue;
|
|
823
|
-
const publishMapped = (event) => emit({
|
|
824
|
-
...event,
|
|
825
|
-
type: event.type === "tool_start" ? "tool_execution_start" : event.type === "tool_update" ? "tool_execution_update" : event.type === "tool_end" ? "tool_execution_end" : event.type === "entry_added" ? "entry_appended" : event.type
|
|
826
|
-
});
|
|
827
915
|
if (mapped.type === "run_end") {
|
|
828
916
|
const settledEvent = {
|
|
829
917
|
runId: String(event.type === "run_end" ? event.inputs[0] : conversation.id),
|
|
@@ -838,6 +926,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
838
926
|
}
|
|
839
927
|
};
|
|
840
928
|
eventsSettled = eventsSettled.then(async () => {
|
|
929
|
+
if (!await nativeExecution() && !external) await flushToolBoundary();
|
|
841
930
|
await reconcile();
|
|
842
931
|
try {
|
|
843
932
|
await writable(() => harness.commit((tx) => tx.appendEntry(conversation.id, {
|
|
@@ -864,7 +953,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
864
953
|
successorActive,
|
|
865
954
|
aborted
|
|
866
955
|
};
|
|
867
|
-
|
|
956
|
+
emit(mapped);
|
|
868
957
|
await deliver(mapped, eventContext);
|
|
869
958
|
release();
|
|
870
959
|
const lifecycle = await readLifecycle();
|
|
@@ -903,14 +992,14 @@ async function createDirectHarnessRuntime(options) {
|
|
|
903
992
|
error: String(error)
|
|
904
993
|
});
|
|
905
994
|
}
|
|
906
|
-
|
|
995
|
+
dispatch().catch((error) => emit({
|
|
907
996
|
type: "error",
|
|
908
|
-
code: "
|
|
997
|
+
code: "dispatch",
|
|
909
998
|
error: String(error)
|
|
910
999
|
}));
|
|
911
1000
|
});
|
|
912
1001
|
} else {
|
|
913
|
-
|
|
1002
|
+
emit(mapped);
|
|
914
1003
|
if (mapped.type === "run_start") {
|
|
915
1004
|
if (!logicalLoopActive) emit({ type: "agent_start" });
|
|
916
1005
|
logicalLoopActive = true;
|
|
@@ -927,6 +1016,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
927
1016
|
});
|
|
928
1017
|
};
|
|
929
1018
|
await attach();
|
|
1019
|
+
const internalDeliveries = /* @__PURE__ */ new Map();
|
|
930
1020
|
const reconcileInternal = (requestId, item) => {
|
|
931
1021
|
const existing = reconcilingInternal.get(requestId);
|
|
932
1022
|
if (existing) return existing;
|
|
@@ -942,50 +1032,17 @@ async function createDirectHarnessRuntime(options) {
|
|
|
942
1032
|
if (receipt?.status === "queued") return;
|
|
943
1033
|
if (!receipt || receipt.status === "unanswered" && receipt.entry === void 0) {
|
|
944
1034
|
if ((await harness.snapshot(LiveDoc, target.id, context))?.run) return;
|
|
945
|
-
let envelope = item.message.role === "custom" ? await storage.storage.submissionByRequest(target.id, `${requestId}:message`, context) : void 0;
|
|
946
|
-
if (item.message.role === "custom" && !envelope) {
|
|
947
|
-
await (await writable(() => target.submit({
|
|
948
|
-
type: "write",
|
|
949
|
-
requestId: `${requestId}:message`,
|
|
950
|
-
entry: {
|
|
951
|
-
kind: "po.entry",
|
|
952
|
-
data: json({
|
|
953
|
-
type: "message",
|
|
954
|
-
message: item.message,
|
|
955
|
-
timestamp: item.message.timestamp,
|
|
956
|
-
inputRequestId: requestId
|
|
957
|
-
})
|
|
958
|
-
}
|
|
959
|
-
}, context))).wait(context);
|
|
960
|
-
envelope = await storage.storage.submissionByRequest(target.id, `${requestId}:message`, context);
|
|
961
|
-
}
|
|
962
|
-
if (envelope?.status === "queued") {
|
|
963
|
-
await (await writable(() => target.submit({
|
|
964
|
-
type: "write",
|
|
965
|
-
requestId: `${requestId}:message-placement`,
|
|
966
|
-
entry: { kind: "po.internal-delivery" }
|
|
967
|
-
}, context))).wait(context);
|
|
968
|
-
envelope = await storage.storage.submissionByRequest(target.id, `${requestId}:message`, context);
|
|
969
|
-
}
|
|
970
|
-
const envelopeId = envelope && "entry" in envelope ? envelope.entry : void 0;
|
|
971
1035
|
const draft = {
|
|
972
1036
|
type: "write",
|
|
973
1037
|
requestId: `${requestId}:context`,
|
|
974
1038
|
entry: {
|
|
975
1039
|
kind: "po.entry",
|
|
976
|
-
data: json(
|
|
977
|
-
type: "custom",
|
|
978
|
-
customType: "po.internal-context",
|
|
979
|
-
data: { inputRequestId: requestId }
|
|
980
|
-
} : {
|
|
1040
|
+
data: json({
|
|
981
1041
|
type: "message",
|
|
982
|
-
message: item.message
|
|
1042
|
+
message: item.message,
|
|
1043
|
+
timestamp: item.message.timestamp
|
|
983
1044
|
}),
|
|
984
|
-
|
|
985
|
-
target: envelopeId,
|
|
986
|
-
action: "replace",
|
|
987
|
-
messages: convertToLlm([item.message])
|
|
988
|
-
}] }
|
|
1045
|
+
model: convertToLlm([item.message])
|
|
989
1046
|
}
|
|
990
1047
|
};
|
|
991
1048
|
let fallback;
|
|
@@ -998,9 +1055,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
998
1055
|
}
|
|
999
1056
|
if ((await fallback.wait(context)).status !== "done") throw new Error("Internal context write failed");
|
|
1000
1057
|
}
|
|
1001
|
-
|
|
1002
|
-
delete r.internalDeliveries?.[requestId];
|
|
1003
|
-
});
|
|
1058
|
+
internalDeliveries.delete(requestId);
|
|
1004
1059
|
})().finally(() => {
|
|
1005
1060
|
reconcilingInternal.delete(requestId);
|
|
1006
1061
|
});
|
|
@@ -1008,156 +1063,83 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1008
1063
|
return work;
|
|
1009
1064
|
};
|
|
1010
1065
|
const reconcile = async () => {
|
|
1011
|
-
const
|
|
1012
|
-
for (const [requestId, item] of Object.entries(record.internalDeliveries ?? {})) {
|
|
1066
|
+
for (const [requestId, item] of internalDeliveries) {
|
|
1013
1067
|
if (admittingInternal.has(requestId)) continue;
|
|
1014
1068
|
if ((await harness.snapshot(LiveDoc, item.conversationId, context))?.run) continue;
|
|
1015
1069
|
const receipt = await storage.storage.submissionByRequest(item.conversationId, requestId, context);
|
|
1016
1070
|
if (receipt?.status === "queued") await harness.abortSubmission(receipt.id, context);
|
|
1017
1071
|
}
|
|
1018
|
-
for (const [requestId, item] of
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
delete q.submissionId;
|
|
1029
|
-
} else {
|
|
1030
|
-
q.disposition = "consumed";
|
|
1031
|
-
q.text = "";
|
|
1032
|
-
delete q.message;
|
|
1033
|
-
delete q.images;
|
|
1034
|
-
}
|
|
1035
|
-
const receipts = r.queue.filter((q) => q.disposition === "consumed" || q.disposition === "removed");
|
|
1036
|
-
if (receipts.length > 128) {
|
|
1037
|
-
const expired = new Set(receipts.slice(0, receipts.length - 128).map((q) => q.id));
|
|
1038
|
-
r.queue = r.queue.filter((q) => !expired.has(q.id));
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
else if (!status && !handingOff.has(item.id) && !userClaims.has(item.id)) await changeRecord((r) => {
|
|
1042
|
-
const q = r.queue.find((q) => q.id === item.id);
|
|
1043
|
-
if (q) q.disposition = "uncertain";
|
|
1044
|
-
});
|
|
1072
|
+
for (const [requestId, item] of internalDeliveries) await reconcileInternal(requestId, item);
|
|
1073
|
+
};
|
|
1074
|
+
const submitInput = async (draft) => {
|
|
1075
|
+
try {
|
|
1076
|
+
return await writable(() => conversation.submit(draft, context));
|
|
1077
|
+
} catch (error) {
|
|
1078
|
+
const accepted = await storage.storage.submissionByRequest(conversation.id, draft.requestId, context);
|
|
1079
|
+
const submission = accepted && await harness.submission(accepted.id, context);
|
|
1080
|
+
if (!submission) throw error;
|
|
1081
|
+
return submission;
|
|
1045
1082
|
}
|
|
1046
1083
|
};
|
|
1047
1084
|
const handingOff = /* @__PURE__ */ new Set();
|
|
1048
|
-
|
|
1049
|
-
let
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
return drainPromise;
|
|
1085
|
+
let dispatching;
|
|
1086
|
+
let dispatchRequested = false;
|
|
1087
|
+
const dispatch = () => {
|
|
1088
|
+
if (dispatching) {
|
|
1089
|
+
dispatchRequested = true;
|
|
1090
|
+
return dispatching;
|
|
1055
1091
|
}
|
|
1056
|
-
return
|
|
1057
|
-
await reconcile();
|
|
1092
|
+
return dispatching = (async () => {
|
|
1058
1093
|
while (!disposed) {
|
|
1059
1094
|
const record = await readRecord();
|
|
1060
|
-
if (agentLocked || userAdmission || record.paused
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1095
|
+
if (agentLocked || userAdmission || external || record.paused) break;
|
|
1096
|
+
const idle = !await execution();
|
|
1097
|
+
const item = record.held.find((q) => idle || !q.explicitQueue);
|
|
1098
|
+
if (!item || userAdmission || external) break;
|
|
1099
|
+
try {
|
|
1100
|
+
if (!await changeRecord((r) => {
|
|
1101
|
+
if (!r.held.some((q) => q.id === item.id)) return false;
|
|
1102
|
+
handingOff.add(item.id);
|
|
1103
|
+
return true;
|
|
1104
|
+
})) continue;
|
|
1105
|
+
await submitInput({
|
|
1106
|
+
type: "input",
|
|
1107
|
+
content: heldContent(item.message ?? item.text, item.images),
|
|
1108
|
+
whenBusy: "followUp",
|
|
1109
|
+
requestId: heldRequestId(item.id),
|
|
1110
|
+
...item.entry ? { entry: item.entry } : {}
|
|
1111
|
+
});
|
|
1112
|
+
await changeRecord((r) => {
|
|
1113
|
+
r.held = r.held.filter((q) => q.id !== item.id);
|
|
1114
|
+
});
|
|
1115
|
+
} finally {
|
|
1116
|
+
handingOff.delete(item.id);
|
|
1117
|
+
}
|
|
1068
1118
|
await publish();
|
|
1069
1119
|
}
|
|
1070
1120
|
})().finally(() => {
|
|
1071
|
-
|
|
1072
|
-
if (
|
|
1073
|
-
|
|
1074
|
-
|
|
1121
|
+
dispatching = void 0;
|
|
1122
|
+
if (dispatchRequested) {
|
|
1123
|
+
dispatchRequested = false;
|
|
1124
|
+
dispatch().catch((error) => emit({
|
|
1075
1125
|
type: "error",
|
|
1076
|
-
code: "
|
|
1126
|
+
code: "dispatch",
|
|
1077
1127
|
error: String(error)
|
|
1078
1128
|
}));
|
|
1079
1129
|
}
|
|
1080
1130
|
});
|
|
1081
1131
|
};
|
|
1082
|
-
const
|
|
1083
|
-
if (external || handingOff.has(item.id)) return void 0;
|
|
1084
|
-
handingOff.add(item.id);
|
|
1085
|
-
try {
|
|
1086
|
-
const claimed = await changeRecord((r) => {
|
|
1087
|
-
const q = r.queue.find((q) => q.id === item.id);
|
|
1088
|
-
if (!q || r.paused && !recovering && !allowPaused) return void 0;
|
|
1089
|
-
if (recovering ? q.disposition !== "handoff" || q.submissionId !== void 0 : q.disposition !== "pending") return void 0;
|
|
1090
|
-
q.disposition = "handoff";
|
|
1091
|
-
q.conversationId = conversation.id;
|
|
1092
|
-
q.submissionMode = mode;
|
|
1093
|
-
if (item.operationId !== void 0) {
|
|
1094
|
-
q.delivery = item.delivery;
|
|
1095
|
-
q.operationId = item.operationId;
|
|
1096
|
-
}
|
|
1097
|
-
return q;
|
|
1098
|
-
});
|
|
1099
|
-
if (!claimed) return void 0;
|
|
1100
|
-
const content = input(claimed.message ?? claimed.text, claimed.images);
|
|
1101
|
-
const requestId = `${claimed.id}:${claimed.attempt ?? 0}`;
|
|
1102
|
-
const submit = () => writable(() => conversation.submit(mode === "write" ? {
|
|
1103
|
-
type: "write",
|
|
1104
|
-
requestId,
|
|
1105
|
-
entry: {
|
|
1106
|
-
kind: "po.message",
|
|
1107
|
-
model: [{
|
|
1108
|
-
role: "user",
|
|
1109
|
-
content,
|
|
1110
|
-
timestamp: Date.now()
|
|
1111
|
-
}]
|
|
1112
|
-
}
|
|
1113
|
-
} : {
|
|
1114
|
-
type: "input",
|
|
1115
|
-
content,
|
|
1116
|
-
whenBusy: mode,
|
|
1117
|
-
requestId
|
|
1118
|
-
}, context));
|
|
1119
|
-
let submission;
|
|
1120
|
-
try {
|
|
1121
|
-
submission = await submit();
|
|
1122
|
-
} catch (error) {
|
|
1123
|
-
const accepted = await storage.storage.submissionByRequest(conversation.id, requestId, context);
|
|
1124
|
-
if (!accepted) throw error;
|
|
1125
|
-
submission = await harness.submission(accepted.id, context);
|
|
1126
|
-
if (!submission) throw error;
|
|
1127
|
-
}
|
|
1128
|
-
await changeRecord((r) => {
|
|
1129
|
-
const q = r.queue.find((q) => q.id === item.id);
|
|
1130
|
-
if (q) q.submissionId = submission.id;
|
|
1131
|
-
});
|
|
1132
|
-
await reconcile();
|
|
1133
|
-
await publish();
|
|
1134
|
-
return submission;
|
|
1135
|
-
} finally {
|
|
1136
|
-
handingOff.delete(item.id);
|
|
1137
|
-
}
|
|
1138
|
-
};
|
|
1139
|
-
const input = (message, images) => {
|
|
1140
|
-
if (typeof message !== "string") {
|
|
1141
|
-
if (message.role !== "user") throw new Error("Only user messages can admit an agent run");
|
|
1142
|
-
return message.content;
|
|
1143
|
-
}
|
|
1144
|
-
return images?.length ? [{
|
|
1145
|
-
type: "text",
|
|
1146
|
-
text: message
|
|
1147
|
-
}, ...images] : message;
|
|
1148
|
-
};
|
|
1149
|
-
const enqueue = async (message, images, delivery, scheduling, explicitQueue = false) => {
|
|
1132
|
+
const enqueue = async (message, images, delivery, explicitQueue) => {
|
|
1150
1133
|
const id = randomUUID();
|
|
1151
1134
|
await changeRecord((r) => {
|
|
1152
|
-
r.
|
|
1135
|
+
r.held.push({
|
|
1153
1136
|
id,
|
|
1154
1137
|
text: text(message),
|
|
1155
1138
|
...images ? { images } : {},
|
|
1156
1139
|
...typeof message === "string" ? {} : { message },
|
|
1157
1140
|
delivery,
|
|
1158
|
-
scheduling,
|
|
1159
|
-
explicitQueue
|
|
1160
|
-
disposition: "pending"
|
|
1141
|
+
scheduling: "automatic",
|
|
1142
|
+
explicitQueue
|
|
1161
1143
|
});
|
|
1162
1144
|
});
|
|
1163
1145
|
await publish();
|
|
@@ -1166,11 +1148,17 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1166
1148
|
const queued = async (message, images, delivery) => {
|
|
1167
1149
|
guardUserAdmission();
|
|
1168
1150
|
assertUnlocked();
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1151
|
+
if (external || (await readRecord()).paused) {
|
|
1152
|
+
await enqueue(message, images, delivery, false);
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
await submitInput({
|
|
1156
|
+
type: "input",
|
|
1157
|
+
content: heldContent(message, images),
|
|
1158
|
+
whenBusy: "followUp",
|
|
1159
|
+
requestId: randomUUID()
|
|
1160
|
+
});
|
|
1161
|
+
await publish();
|
|
1174
1162
|
};
|
|
1175
1163
|
const dispatchCommand = async (value) => options.dispatchCommand?.(value) ?? false;
|
|
1176
1164
|
const admit = async (message, images, mode) => {
|
|
@@ -1185,11 +1173,14 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1185
1173
|
promptAdmissions++;
|
|
1186
1174
|
try {
|
|
1187
1175
|
assertUnlocked();
|
|
1188
|
-
const record = await readRecord();
|
|
1189
1176
|
await flushNextTurn();
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1192
|
-
|
|
1177
|
+
const submission = await submitInput({
|
|
1178
|
+
type: "input",
|
|
1179
|
+
content: heldContent(message, images),
|
|
1180
|
+
whenBusy: mode ?? "reject",
|
|
1181
|
+
requestId: randomUUID()
|
|
1182
|
+
});
|
|
1183
|
+
await publish();
|
|
1193
1184
|
let resolveDelivery;
|
|
1194
1185
|
const delivered = new Promise((resolve) => {
|
|
1195
1186
|
resolveDelivery = resolve;
|
|
@@ -1207,7 +1198,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1207
1198
|
await reconcile();
|
|
1208
1199
|
await publish();
|
|
1209
1200
|
if (status.status === "unanswered" && status.reason !== "aborted") throw new Error(`Agent submission failed: ${status.reason}${typeof status.detail === "string" && status.detail ? `: ${status.detail}` : ""}`);
|
|
1210
|
-
await
|
|
1201
|
+
await dispatch();
|
|
1211
1202
|
} finally {
|
|
1212
1203
|
internalDelivery.delete(submission.id);
|
|
1213
1204
|
}
|
|
@@ -1228,17 +1219,51 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1228
1219
|
externalAbort?.abort();
|
|
1229
1220
|
return;
|
|
1230
1221
|
}
|
|
1231
|
-
const
|
|
1232
|
-
await changeRecord((r) => {
|
|
1233
|
-
r.paused = true;
|
|
1234
|
-
r.abortOperationId = current.id;
|
|
1235
|
-
r.abortTaskId = taskId;
|
|
1236
|
-
});
|
|
1237
|
-
await publish();
|
|
1238
|
-
await writable(async () => {
|
|
1222
|
+
const stop = () => writable(async () => {
|
|
1239
1223
|
if (current.kind === "run") await conversation.abort(context);
|
|
1240
|
-
else await harness.abortTask(
|
|
1224
|
+
else await harness.abortTask(nativeId(current.id), context);
|
|
1241
1225
|
});
|
|
1226
|
+
if (attached) {
|
|
1227
|
+
await stop();
|
|
1228
|
+
await reconcile();
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
const captured = /* @__PURE__ */ new Set();
|
|
1232
|
+
if (current.kind === "run") for (const item of (await harness.snapshot(InboxDoc, conversation.id, context))?.items ?? []) {
|
|
1233
|
+
if (item.mode === "write") continue;
|
|
1234
|
+
const requestId = (await storage.storage.submission(item.id, context))?.requestId;
|
|
1235
|
+
if (requestId === void 0 || !internalDeliveries.has(requestId)) captured.add(item.id);
|
|
1236
|
+
}
|
|
1237
|
+
await writable(() => harness.commit(async (tx) => {
|
|
1238
|
+
const doc = await tx.doc(HeldQueueDoc);
|
|
1239
|
+
const record = JSON.parse(doc.json);
|
|
1240
|
+
record.paused = true;
|
|
1241
|
+
record.abortOperationId = current.id;
|
|
1242
|
+
const items = (await tx.doc(InboxDoc, conversation.id)).items;
|
|
1243
|
+
const moved = [];
|
|
1244
|
+
for (let index = items.length - 1; index >= 0; index--) {
|
|
1245
|
+
const item = items[index];
|
|
1246
|
+
if (item.mode === "write" || !captured.has(item.id)) continue;
|
|
1247
|
+
moved.unshift({
|
|
1248
|
+
id: randomUUID(),
|
|
1249
|
+
...fromContent(item.content),
|
|
1250
|
+
...item.entry ? { entry: item.entry } : {},
|
|
1251
|
+
delivery: item.mode,
|
|
1252
|
+
scheduling: "automatic",
|
|
1253
|
+
explicitQueue: true
|
|
1254
|
+
});
|
|
1255
|
+
tx.settleSubmission(item.id, {
|
|
1256
|
+
status: "unanswered",
|
|
1257
|
+
reason: "aborted"
|
|
1258
|
+
});
|
|
1259
|
+
items.splice(index, 1);
|
|
1260
|
+
}
|
|
1261
|
+
record.held.unshift(...moved);
|
|
1262
|
+
record.revision++;
|
|
1263
|
+
doc.json = JSON.stringify(record);
|
|
1264
|
+
}, context));
|
|
1265
|
+
await publish();
|
|
1266
|
+
await stop();
|
|
1242
1267
|
await reconcile();
|
|
1243
1268
|
};
|
|
1244
1269
|
const interrupt = async () => {
|
|
@@ -1246,220 +1271,51 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1246
1271
|
await writable(() => conversation.abort(context));
|
|
1247
1272
|
await eventsSettled;
|
|
1248
1273
|
};
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
const live = await tx.doc(LiveDoc, conversation.id);
|
|
1261
|
-
const task = live.run ? await tx.task(live.run.taskId) : void 0;
|
|
1262
|
-
if ((live.run ? String(live.run.inputs[0]) : void 0) !== selection.operationId || task?.abortRequested || live.run && record.abortOperationId === selection.operationId) return "target_changed";
|
|
1263
|
-
if (!live.run) {
|
|
1264
|
-
let page = await tx.scanTasks({
|
|
1265
|
-
conversationId: conversation.id,
|
|
1266
|
-
kind: CompactionTask.definition.name,
|
|
1267
|
-
background: false
|
|
1268
|
-
}, 128);
|
|
1269
|
-
while (true) {
|
|
1270
|
-
if (page.items.some((task) => task.state.status !== "terminal")) return "target_changed";
|
|
1271
|
-
if (!page.next) break;
|
|
1272
|
-
page = await tx.scanTasks({
|
|
1273
|
-
conversationId: conversation.id,
|
|
1274
|
-
kind: CompactionTask.definition.name,
|
|
1275
|
-
background: false
|
|
1276
|
-
}, 128, page.next);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
const content = input(q.message ?? q.text, q.images);
|
|
1280
|
-
const inbox = await tx.doc(InboxDoc, conversation.id);
|
|
1281
|
-
let head = live.run ? void 0 : (await tx.latestHeadMarker(conversation.id))?.head;
|
|
1282
|
-
const now = Date.now();
|
|
1283
|
-
let id;
|
|
1284
|
-
if (!live.run && inbox.items.length === 0) {
|
|
1285
|
-
const entry = await tx.appendEntry(UserEntry, conversation.id, { model: [{
|
|
1286
|
-
role: "user",
|
|
1287
|
-
content,
|
|
1288
|
-
timestamp: now
|
|
1289
|
-
}] });
|
|
1290
|
-
id = (await tx.createSubmission({
|
|
1291
|
-
conversationId: conversation.id,
|
|
1292
|
-
requestId,
|
|
1293
|
-
type: "input",
|
|
1294
|
-
status: "placed",
|
|
1295
|
-
entry: entry.id
|
|
1296
|
-
})).id;
|
|
1297
|
-
live.run = {
|
|
1298
|
-
taskId: await tx.createTask(GenerationTask, {}, {
|
|
1299
|
-
ownership: { kind: "conversation" },
|
|
1300
|
-
conversationId: conversation.id
|
|
1301
|
-
}),
|
|
1302
|
-
inputs: [id]
|
|
1303
|
-
};
|
|
1304
|
-
} else {
|
|
1305
|
-
id = (await tx.createSubmission({
|
|
1306
|
-
conversationId: conversation.id,
|
|
1307
|
-
requestId,
|
|
1308
|
-
type: "input",
|
|
1309
|
-
status: "queued"
|
|
1310
|
-
})).id;
|
|
1311
|
-
inbox.items.push({
|
|
1312
|
-
id,
|
|
1313
|
-
mode: "steer",
|
|
1314
|
-
content: json(content)
|
|
1315
|
-
});
|
|
1316
|
-
if (!live.run) {
|
|
1317
|
-
const writes = inbox.items.flatMap((item, index) => item.mode === "write" ? [index] : []);
|
|
1318
|
-
const pick = (mode) => {
|
|
1319
|
-
const indexes = inbox.items.flatMap((item, index) => item.mode === mode ? [index] : []);
|
|
1320
|
-
return (mode === "steer" ? settings.steeringMode : settings.followUpMode) === "all" ? indexes : indexes.slice(0, 1);
|
|
1321
|
-
};
|
|
1322
|
-
const users = [...pick("steer"), ...pick("followUp")].sort((a, b) => a - b);
|
|
1323
|
-
for (const index of writes) {
|
|
1324
|
-
const item = inbox.items[index];
|
|
1325
|
-
if (item.mode !== "write") continue;
|
|
1326
|
-
const draft = item.entry;
|
|
1327
|
-
if (typeof draft.head === "number" && head !== void 0 && draft.head < head) {
|
|
1328
|
-
tx.settleSubmission(item.id, {
|
|
1329
|
-
status: "unanswered",
|
|
1330
|
-
reason: "stale"
|
|
1331
|
-
});
|
|
1332
|
-
continue;
|
|
1333
|
-
}
|
|
1334
|
-
const entry = await tx.appendEntry(conversation.id, draft);
|
|
1335
|
-
if (draft.head !== void 0) head = draft.head === "self" ? entry.id : draft.head;
|
|
1336
|
-
tx.placeSubmission(item.id, entry.id);
|
|
1337
|
-
}
|
|
1338
|
-
const inputs = [];
|
|
1339
|
-
for (const index of users) {
|
|
1340
|
-
const item = inbox.items[index];
|
|
1341
|
-
if (item.mode === "write") continue;
|
|
1342
|
-
const entry = await tx.appendEntry(UserEntry, conversation.id, { model: [{
|
|
1343
|
-
role: "user",
|
|
1344
|
-
content: item.content,
|
|
1345
|
-
timestamp: now
|
|
1346
|
-
}] });
|
|
1347
|
-
tx.placeSubmission(item.id, entry.id);
|
|
1348
|
-
inputs.push(item.id);
|
|
1349
|
-
}
|
|
1350
|
-
for (const index of [...writes, ...users].sort((a, b) => b - a)) inbox.items.splice(index, 1);
|
|
1351
|
-
if (inputs.length) live.run = {
|
|
1352
|
-
taskId: await tx.createTask(GenerationTask, {}, {
|
|
1353
|
-
ownership: { kind: "conversation" },
|
|
1354
|
-
conversationId: conversation.id
|
|
1355
|
-
}),
|
|
1356
|
-
inputs
|
|
1357
|
-
};
|
|
1358
|
-
}
|
|
1274
|
+
const admitUser = async (work) => {
|
|
1275
|
+
userAdmission = true;
|
|
1276
|
+
userAdmissionSettled = new Promise((resolve) => {
|
|
1277
|
+
releaseUserAdmission = resolve;
|
|
1278
|
+
});
|
|
1279
|
+
try {
|
|
1280
|
+
return await work();
|
|
1281
|
+
} finally {
|
|
1282
|
+
userAdmission = false;
|
|
1283
|
+
releaseUserAdmission?.();
|
|
1284
|
+
releaseUserAdmission = void 0;
|
|
1359
1285
|
}
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
q.submissionMode = "steer";
|
|
1363
|
-
q.submissionId = id;
|
|
1364
|
-
record.revision++;
|
|
1365
|
-
doc.json = JSON.stringify(record);
|
|
1366
|
-
return id;
|
|
1367
|
-
}, context));
|
|
1368
|
-
const submitUserPrompt = async (message, images, selection, submissionMode = "reject") => {
|
|
1286
|
+
};
|
|
1287
|
+
const submitUserPrompt = async (message, images, submissionMode = "reject") => {
|
|
1369
1288
|
guardUserAdmission();
|
|
1370
1289
|
if (external) throw new Error("An operation is already running");
|
|
1371
|
-
if (
|
|
1372
|
-
if (
|
|
1290
|
+
if (typeof message === "string" ? !message && !images?.length : !message.content.length) throw new Error("User input must contain text or an image");
|
|
1291
|
+
if (typeof message === "string" && await dispatchCommand(message)) return {
|
|
1373
1292
|
settled: Promise.resolve(),
|
|
1374
1293
|
handledCommand: true
|
|
1375
1294
|
};
|
|
1376
1295
|
assertUnlocked();
|
|
1377
1296
|
guardUserAdmission();
|
|
1378
1297
|
if (external) throw new Error("An operation is already running");
|
|
1379
|
-
|
|
1380
|
-
userAdmissionSettled = new Promise((resolve) => {
|
|
1381
|
-
releaseUserAdmission = resolve;
|
|
1382
|
-
});
|
|
1383
|
-
let claimed;
|
|
1384
|
-
try {
|
|
1385
|
-
if (selection && submissionMode === "steer") {
|
|
1386
|
-
let admitted;
|
|
1387
|
-
try {
|
|
1388
|
-
admitted = await admitSelected(selection);
|
|
1389
|
-
} catch (error) {
|
|
1390
|
-
if (!await storage.storage.submissionByRequest(conversation.id, `${selection.id}:${(await readRecord()).queue.find((q) => q.id === selection.id)?.attempt ?? 0}`, context)) throw error;
|
|
1391
|
-
admitted = await admitSelected(selection, true);
|
|
1392
|
-
}
|
|
1393
|
-
if (typeof admitted === "string") return {
|
|
1394
|
-
settled: Promise.resolve(),
|
|
1395
|
-
queueOutcome: admitted
|
|
1396
|
-
};
|
|
1397
|
-
const submission = await harness.submission(admitted, context);
|
|
1398
|
-
if (!submission) throw new Error("Accepted promotion submission is missing");
|
|
1399
|
-
const settled = (async () => {
|
|
1400
|
-
const status = await submission.wait(context);
|
|
1401
|
-
await eventsSettled;
|
|
1402
|
-
await reconcile();
|
|
1403
|
-
await publish();
|
|
1404
|
-
if (status.status === "unanswered" && status.reason !== "aborted") throw new Error(`Agent submission failed: ${status.reason}`);
|
|
1405
|
-
await drain();
|
|
1406
|
-
})();
|
|
1407
|
-
settled.catch((error) => emit({
|
|
1408
|
-
type: "error",
|
|
1409
|
-
code: "user_prompt",
|
|
1410
|
-
error: String(error)
|
|
1411
|
-
}));
|
|
1412
|
-
await reconcile();
|
|
1413
|
-
await publish();
|
|
1414
|
-
return { settled };
|
|
1415
|
-
}
|
|
1416
|
-
const current = await execution();
|
|
1417
|
-
if (selection) {
|
|
1418
|
-
const outcome = await changeRecord((r) => {
|
|
1419
|
-
const q = r.queue.find((q) => q.id === selection.id);
|
|
1420
|
-
if (!q || q.explicitQueue !== true || q.disposition === "removed" || q.disposition === "consumed") return "not_found";
|
|
1421
|
-
if (q.disposition !== "pending") return "in_flight";
|
|
1422
|
-
if (current?.id !== selection.operationId || current?.status === "aborting") return "target_changed";
|
|
1423
|
-
if (q.message && q.message.role !== "user") throw new Error("Only user input can interrupt and respond");
|
|
1424
|
-
userClaims.add(q.id);
|
|
1425
|
-
if (submissionMode === "reject") r.paused = true;
|
|
1426
|
-
q.disposition = "handoff";
|
|
1427
|
-
q.conversationId = conversation.id;
|
|
1428
|
-
q.submissionMode = submissionMode;
|
|
1429
|
-
return { ...q };
|
|
1430
|
-
});
|
|
1431
|
-
if (typeof outcome === "string") return {
|
|
1432
|
-
settled: Promise.resolve(),
|
|
1433
|
-
queueOutcome: outcome
|
|
1434
|
-
};
|
|
1435
|
-
claimed = outcome;
|
|
1436
|
-
}
|
|
1298
|
+
return admitUser(async () => {
|
|
1437
1299
|
if (submissionMode === "reject") {
|
|
1300
|
+
const current = await execution();
|
|
1438
1301
|
if (current) await abort(current.id);
|
|
1439
1302
|
await conversation.waitForIdle(context);
|
|
1440
1303
|
await eventsSettled;
|
|
1441
1304
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
q.conversationId = conversation.id;
|
|
1450
|
-
q.submissionMode = submissionMode;
|
|
1451
|
-
return { ...q };
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
const submission = await handoff(claimed, submissionMode, true);
|
|
1455
|
-
if (!submission) throw new Error("User admission ownership changed");
|
|
1305
|
+
await flushNextTurn();
|
|
1306
|
+
const submission = await submitInput({
|
|
1307
|
+
type: "input",
|
|
1308
|
+
content: heldContent(message, images),
|
|
1309
|
+
whenBusy: submissionMode,
|
|
1310
|
+
requestId: randomUUID()
|
|
1311
|
+
});
|
|
1456
1312
|
const settled = (async () => {
|
|
1457
1313
|
const status = await submission.wait(context);
|
|
1458
1314
|
await eventsSettled;
|
|
1459
1315
|
await reconcile();
|
|
1460
1316
|
await publish();
|
|
1461
1317
|
if (status.status === "unanswered" && status.reason !== "aborted") throw new Error(`Agent submission failed: ${status.reason}`);
|
|
1462
|
-
await
|
|
1318
|
+
await dispatch();
|
|
1463
1319
|
})();
|
|
1464
1320
|
settled.catch((error) => emit({
|
|
1465
1321
|
type: "error",
|
|
@@ -1468,32 +1324,21 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1468
1324
|
}));
|
|
1469
1325
|
await publish();
|
|
1470
1326
|
return { settled };
|
|
1471
|
-
}
|
|
1472
|
-
if (claimed) userClaims.delete(claimed.id);
|
|
1473
|
-
if (selection) userClaims.delete(selection.id);
|
|
1474
|
-
userAdmission = false;
|
|
1475
|
-
releaseUserAdmission?.();
|
|
1476
|
-
releaseUserAdmission = void 0;
|
|
1477
|
-
}
|
|
1327
|
+
});
|
|
1478
1328
|
};
|
|
1479
1329
|
const recover = async () => {
|
|
1480
1330
|
const r = await readRecord();
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
if (
|
|
1484
|
-
|
|
1485
|
-
for (const item of r.queue.filter((q) => q.disposition === "handoff" && !q.submissionId)) {
|
|
1486
|
-
if (item.conversationId !== conversation.id) {
|
|
1487
|
-
await changeRecord((record) => {
|
|
1488
|
-
const q = record.queue.find((q) => q.id === item.id);
|
|
1489
|
-
if (q) q.disposition = "uncertain";
|
|
1490
|
-
});
|
|
1491
|
-
continue;
|
|
1492
|
-
}
|
|
1493
|
-
await handoff(item, item.submissionMode ?? (item.delivery === "steer" ? "steer" : "followUp"), true);
|
|
1331
|
+
const current = r.abortOperationId ? await nativeExecution() : null;
|
|
1332
|
+
if (current?.id === r.abortOperationId) {
|
|
1333
|
+
if (current?.kind === "run") await conversation.abort(context);
|
|
1334
|
+
else if (current) await harness.abortTask(nativeId(current.id), context);
|
|
1494
1335
|
}
|
|
1336
|
+
const accepted = /* @__PURE__ */ new Set();
|
|
1337
|
+
for (const item of r.held) if (await storage.storage.submissionByRequest(conversation.id, heldRequestId(item.id), context)) accepted.add(item.id);
|
|
1495
1338
|
await reconcile();
|
|
1496
|
-
await changeRecord(() =>
|
|
1339
|
+
await changeRecord((record) => {
|
|
1340
|
+
record.held = record.held.filter((q) => !accepted.has(q.id));
|
|
1341
|
+
});
|
|
1497
1342
|
};
|
|
1498
1343
|
const admissionBusy = () => userAdmission || promptAdmissions > 0 || settling > 0 || handingOff.size > 0 || admittingInternal.size > 0 || compactionAdmission;
|
|
1499
1344
|
const runExternalOperation = async (work, { signal, waitMs = 0 } = {}) => {
|
|
@@ -1502,7 +1347,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1502
1347
|
const pendingFollowUp = async () => {
|
|
1503
1348
|
if (waitMs === 0 || agentLocked) return false;
|
|
1504
1349
|
const record = await readRecord();
|
|
1505
|
-
return !record.paused && record.
|
|
1350
|
+
return !record.paused && record.held.length > 0;
|
|
1506
1351
|
};
|
|
1507
1352
|
for (;;) {
|
|
1508
1353
|
if (waitMs === 0) guardUserAdmission();
|
|
@@ -1518,12 +1363,13 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1518
1363
|
const changed = await nativeExecution() || await pendingFollowUp();
|
|
1519
1364
|
signal?.throwIfAborted();
|
|
1520
1365
|
if (disposed || disposePromise) throw new Error("Direct harness is disposed");
|
|
1521
|
-
if (waitMs > 0 && Date.now() >= deadline) throw new
|
|
1366
|
+
if (waitMs > 0 && Date.now() >= deadline) throw new PoHeadlessToolBusyError();
|
|
1522
1367
|
admitted = !changed && !admissionBusy();
|
|
1523
1368
|
} finally {
|
|
1524
1369
|
if (!admitted) {
|
|
1525
1370
|
external = void 0;
|
|
1526
|
-
|
|
1371
|
+
if (!await nativeExecution()) await flushToolBoundary();
|
|
1372
|
+
dispatch().catch((error) => emit({
|
|
1527
1373
|
type: "error",
|
|
1528
1374
|
error: String(error)
|
|
1529
1375
|
}));
|
|
@@ -1532,7 +1378,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1532
1378
|
if (admitted) break;
|
|
1533
1379
|
}
|
|
1534
1380
|
const remaining = deadline - Date.now();
|
|
1535
|
-
if (remaining <= 0) throw new
|
|
1381
|
+
if (remaining <= 0) throw new PoHeadlessToolBusyError();
|
|
1536
1382
|
let timer;
|
|
1537
1383
|
try {
|
|
1538
1384
|
await awaitWithContext(new Promise((resolve) => {
|
|
@@ -1549,8 +1395,9 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1549
1395
|
} finally {
|
|
1550
1396
|
external = void 0;
|
|
1551
1397
|
externalAbort = void 0;
|
|
1398
|
+
await flushToolBoundary();
|
|
1552
1399
|
await publish();
|
|
1553
|
-
|
|
1400
|
+
dispatch().catch((error) => emit({
|
|
1554
1401
|
type: "error",
|
|
1555
1402
|
error: String(error)
|
|
1556
1403
|
}));
|
|
@@ -1562,29 +1409,17 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1562
1409
|
if (receipt.status !== "done") throw new Error(`Entry write failed: ${receipt.reason}`);
|
|
1563
1410
|
return String(receipt.entry);
|
|
1564
1411
|
};
|
|
1565
|
-
const restoreCustomContextMessages =
|
|
1412
|
+
const restoreCustomContextMessages = (messages, view) => {
|
|
1566
1413
|
const contextContributions = /* @__PURE__ */ new Map();
|
|
1567
|
-
const customByEntry = /* @__PURE__ */ new Map();
|
|
1568
|
-
for (const raw of view.entries) {
|
|
1569
|
-
const entry = projectDurableEntries([raw])[0];
|
|
1570
|
-
if (entry?.type !== "message" || entry.message.role !== "custom") continue;
|
|
1571
|
-
const data = raw.data && typeof raw.data === "object" && !Array.isArray(raw.data) ? raw.data : void 0;
|
|
1572
|
-
const receipt = typeof data?.inputRequestId === "string" ? await storage.storage.submissionByRequest(conversationId, data.inputRequestId, ctx) : void 0;
|
|
1573
|
-
const placed = (receipt?.status === "unanswered" && !("entry" in receipt && receipt.entry !== void 0) && typeof data?.inputRequestId === "string" ? await storage.storage.submissionByRequest(conversationId, `${data.inputRequestId}:context`, ctx) : void 0) ?? receipt;
|
|
1574
|
-
const placedEntry = placed && "entry" in placed && placed.entry !== void 0 ? view.entries.find((candidate) => candidate.id === placed.entry) : void 0;
|
|
1575
|
-
const target = placedEntry?.edits?.some((edit) => edit.target === raw.id) ? raw.id : placedEntry?.id ?? raw.id;
|
|
1576
|
-
const contributions = view.contributions[view.entries.findIndex((candidate) => candidate.id === target)];
|
|
1577
|
-
const model = (placedEntry?.edits?.find((edit) => edit.target === raw.id && edit.action === "replace"))?.messages ?? view.entries.find((candidate) => candidate.id === target)?.model;
|
|
1578
|
-
if (model?.length === 1 && contributions?.length === 1 && JSON.stringify(model[0]) === JSON.stringify(contributions[0])) customByEntry.set(target, entry.message);
|
|
1579
|
-
}
|
|
1580
1414
|
for (const [index, raw] of view.entries.entries()) {
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1415
|
+
const entry = projectDurableEntries([raw])[0];
|
|
1416
|
+
const contributions = view.contributions[index] ?? [];
|
|
1417
|
+
const custom = entry?.type === "message" && entry.message.role === "custom" && raw.model?.length === 1 && contributions.length === 1 && JSON.stringify(raw.model[0]) === JSON.stringify(contributions[0]) ? entry.message : void 0;
|
|
1418
|
+
for (const native of contributions) {
|
|
1583
1419
|
const key = JSON.stringify(native);
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
contextContributions.set(key, contributions);
|
|
1420
|
+
const restored = contextContributions.get(key) ?? [];
|
|
1421
|
+
restored.push(custom ?? native);
|
|
1422
|
+
contextContributions.set(key, restored);
|
|
1588
1423
|
}
|
|
1589
1424
|
}
|
|
1590
1425
|
return messages.filter((message) => message.role !== "system").map((message) => contextContributions.get(JSON.stringify(message))?.shift() ?? message);
|
|
@@ -1596,14 +1431,20 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1596
1431
|
leafId: entries.at(-1)?.id ?? null
|
|
1597
1432
|
};
|
|
1598
1433
|
};
|
|
1434
|
+
let statsCache;
|
|
1599
1435
|
const getSessionStats = async () => {
|
|
1600
|
-
const
|
|
1436
|
+
const lane = conversation;
|
|
1437
|
+
const cached = statsCache;
|
|
1438
|
+
const previous = cached?.conversation === lane ? cached : void 0;
|
|
1439
|
+
const entries = (await projectDurableConversationEntries(lane, context, previous?.seq)).filter((entry) => previous?.seq === void 0 || entry.seq > previous.seq);
|
|
1601
1440
|
const messages = entries.flatMap((e) => e.type === "message" ? [e.message] : []);
|
|
1602
1441
|
const agent = await conversation.agent(context);
|
|
1603
1442
|
const selected = agent.model ? models.getModel(agent.model.provider, agent.model.modelId) : void 0;
|
|
1604
|
-
const
|
|
1605
|
-
const
|
|
1606
|
-
const
|
|
1443
|
+
const latest = messages.findLast((message) => message.role === "assistant");
|
|
1444
|
+
const contextTokens = latest?.role === "assistant" ? contextTokensOf(latest.usage) : previous?.contextTokens ?? null;
|
|
1445
|
+
const contextUsage = contextUsageOf(contextTokens, selected?.contextWindow);
|
|
1446
|
+
const usage = attached ? await harness.snapshot(UsageDoc, conversation.id, context) : await harness.usage(context);
|
|
1447
|
+
const children = attached ? [] : await Promise.all((await subagentConversations(harness, context)).map((id) => harness.snapshot(UsageDoc, id, context)));
|
|
1607
1448
|
const tokens = {
|
|
1608
1449
|
input: 0,
|
|
1609
1450
|
output: 0,
|
|
@@ -1612,24 +1453,39 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1612
1453
|
total: 0
|
|
1613
1454
|
};
|
|
1614
1455
|
let cost = 0;
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1456
|
+
const add = (ledger, sign) => {
|
|
1457
|
+
const rows = [...Object.values(ledger?.models ?? {}), ...Object.values(ledger?.tools ?? {})];
|
|
1458
|
+
for (const u of rows) {
|
|
1459
|
+
tokens.input += sign * u.input;
|
|
1460
|
+
tokens.output += sign * u.output;
|
|
1461
|
+
tokens.cacheRead += sign * u.cacheRead;
|
|
1462
|
+
tokens.cacheWrite += sign * u.cacheWrite;
|
|
1463
|
+
tokens.total += sign * u.totalTokens;
|
|
1464
|
+
cost += sign * u.cost.total;
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
add(usage, 1);
|
|
1468
|
+
for (const child of children) add(child, -1);
|
|
1469
|
+
const next = {
|
|
1470
|
+
conversation: lane,
|
|
1471
|
+
seq: entries.at(-1)?.seq ?? previous?.seq,
|
|
1472
|
+
contextTokens,
|
|
1473
|
+
messageCount: (previous?.messageCount ?? 0) + messages.length,
|
|
1474
|
+
userMessages: (previous?.userMessages ?? 0) + messages.filter((m) => m.role === "user").length,
|
|
1475
|
+
assistantMessages: (previous?.assistantMessages ?? 0) + messages.filter((m) => m.role === "assistant").length,
|
|
1476
|
+
toolCalls: (previous?.toolCalls ?? 0) + messages.flatMap((m) => m.role === "assistant" ? m.content.filter((c) => c.type === "toolCall") : []).length,
|
|
1477
|
+
toolResults: (previous?.toolResults ?? 0) + messages.filter((m) => m.role === "toolResult").length
|
|
1478
|
+
};
|
|
1479
|
+
if (conversation === lane && statsCache === cached) statsCache = next;
|
|
1623
1480
|
return {
|
|
1624
1481
|
sessionId,
|
|
1625
|
-
sessionFile: storage.sessionFile,
|
|
1626
1482
|
...contextUsage === void 0 ? {} : { contextUsage },
|
|
1627
|
-
messageCount:
|
|
1628
|
-
totalMessages:
|
|
1629
|
-
userMessages:
|
|
1630
|
-
assistantMessages:
|
|
1631
|
-
toolCalls:
|
|
1632
|
-
toolResults:
|
|
1483
|
+
messageCount: next.messageCount,
|
|
1484
|
+
totalMessages: next.messageCount,
|
|
1485
|
+
userMessages: next.userMessages,
|
|
1486
|
+
assistantMessages: next.assistantMessages,
|
|
1487
|
+
toolCalls: next.toolCalls,
|
|
1488
|
+
toolResults: next.toolResults,
|
|
1633
1489
|
tokens,
|
|
1634
1490
|
cost,
|
|
1635
1491
|
totalCost: cost,
|
|
@@ -1651,6 +1507,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1651
1507
|
};
|
|
1652
1508
|
let disposePromise;
|
|
1653
1509
|
const dispose = () => disposePromise ??= (async () => {
|
|
1510
|
+
for (const pending of toolBoundaryQueue.splice(0)) pending.reject(/* @__PURE__ */ new Error("Direct harness is disposed"));
|
|
1654
1511
|
const failures = [];
|
|
1655
1512
|
const attempt = async (cleanup) => {
|
|
1656
1513
|
try {
|
|
@@ -1661,14 +1518,15 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1661
1518
|
return false;
|
|
1662
1519
|
}
|
|
1663
1520
|
};
|
|
1664
|
-
await attempt(interrupt);
|
|
1521
|
+
if (!attached) await attempt(interrupt);
|
|
1665
1522
|
disposed = true;
|
|
1666
1523
|
await attempt(() => watcher.stop());
|
|
1667
1524
|
await attempt(() => eventsSettled);
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1525
|
+
if (!attached) {
|
|
1526
|
+
const harnessClosed = await attempt(() => harness.close(context));
|
|
1527
|
+
await attempt(() => environment.cleanup(context));
|
|
1528
|
+
if (harnessClosed) await attempt(() => storage.release(context));
|
|
1529
|
+
}
|
|
1672
1530
|
resolveExited(failures.length ? 1 : 0);
|
|
1673
1531
|
if (failures.length) throw new AggregateError(failures, "Direct harness cleanup failed");
|
|
1674
1532
|
})();
|
|
@@ -1706,29 +1564,21 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1706
1564
|
return entryId;
|
|
1707
1565
|
};
|
|
1708
1566
|
const removeQueued = async (id) => {
|
|
1709
|
-
const
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
const result = await harness.abortSubmission(item.submissionId, context, conversation.id);
|
|
1715
|
-
if (result === "already_placed") return "in_flight";
|
|
1716
|
-
if (result === "settled") return "already_consumed";
|
|
1717
|
-
} else if (item.disposition !== "pending") return "in_flight";
|
|
1718
|
-
const result = await changeRecord((r) => {
|
|
1719
|
-
const q = r.queue.find((q) => q.id === id);
|
|
1720
|
-
if (!q || q.explicitQueue !== true) return "not_found";
|
|
1721
|
-
if (q.disposition === "consumed") return "already_consumed";
|
|
1722
|
-
if (q.disposition === "removed") return "removed";
|
|
1723
|
-
if (q.submissionId !== item.submissionId || item.submissionId === void 0 && q.disposition !== "pending") return "in_flight";
|
|
1724
|
-
q.disposition = "removed";
|
|
1725
|
-
q.text = "";
|
|
1726
|
-
delete q.message;
|
|
1727
|
-
delete q.images;
|
|
1567
|
+
const held = await changeRecord((r) => {
|
|
1568
|
+
if (handingOff.has(id)) return "in_flight";
|
|
1569
|
+
const index = r.held.findIndex((q) => q.id === id && q.explicitQueue);
|
|
1570
|
+
if (index === -1) return "not_held";
|
|
1571
|
+
r.held.splice(index, 1);
|
|
1728
1572
|
return "removed";
|
|
1729
1573
|
});
|
|
1574
|
+
if (held === "in_flight") return held;
|
|
1575
|
+
if (held === "not_held") {
|
|
1576
|
+
const accepted = await storage.storage.submissionByRequest(conversation.id, heldRequestId(id), context);
|
|
1577
|
+
if (!accepted) return "not_found";
|
|
1578
|
+
return accepted.status === "queued" ? "in_flight" : "already_consumed";
|
|
1579
|
+
}
|
|
1730
1580
|
await publish();
|
|
1731
|
-
return
|
|
1581
|
+
return "removed";
|
|
1732
1582
|
};
|
|
1733
1583
|
const commitCheckpointMessage = async (registration, lane, message, ctx, scopeIsOpen = () => true, taskId) => {
|
|
1734
1584
|
const usable = () => registration.active && scopeIsOpen() && !disposed && !quarantined && !external && conversation.id === lane.id && !ctx.abortSignal?.aborted;
|
|
@@ -1753,8 +1603,9 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1753
1603
|
}, ctx);
|
|
1754
1604
|
});
|
|
1755
1605
|
};
|
|
1756
|
-
const appendMessage = (message) => appendEntry({
|
|
1606
|
+
const appendMessage = (message, requestId) => appendEntry({
|
|
1757
1607
|
type: "write",
|
|
1608
|
+
...requestId === void 0 ? {} : { requestId },
|
|
1758
1609
|
entry: {
|
|
1759
1610
|
kind: "po.entry",
|
|
1760
1611
|
data: json({
|
|
@@ -1765,9 +1616,11 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1765
1616
|
model: convertToLlm([message])
|
|
1766
1617
|
}
|
|
1767
1618
|
});
|
|
1619
|
+
const mainOnly = () => {
|
|
1620
|
+
if (attached) throw new Error("Session state belongs to the main lane.");
|
|
1621
|
+
};
|
|
1768
1622
|
return {
|
|
1769
1623
|
sessionId,
|
|
1770
|
-
sessionFile: storage.sessionFile,
|
|
1771
1624
|
laneName,
|
|
1772
1625
|
harnessId: options.harnessId ?? `${sessionId}:${laneName}`,
|
|
1773
1626
|
session: harness,
|
|
@@ -1795,15 +1648,33 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1795
1648
|
}));
|
|
1796
1649
|
},
|
|
1797
1650
|
readEntries,
|
|
1651
|
+
async readEntriesFrom(seq) {
|
|
1652
|
+
const lane = conversation;
|
|
1653
|
+
const minEntryId = nativeId(String(seq));
|
|
1654
|
+
const entries = await projectDurableConversationEntries(lane, context, minEntryId);
|
|
1655
|
+
if (entries.length > 0 && minEntryId > 0) {
|
|
1656
|
+
const previous = await lane.entries({ maxEntryId: minEntryId - 1 }, 1, void 0, context);
|
|
1657
|
+
const parentId = previous.items[0] === void 0 ? null : String(previous.items[0].id);
|
|
1658
|
+
for (const entry of entries) {
|
|
1659
|
+
if (entry.seq !== entries[0].seq) break;
|
|
1660
|
+
entry.parentId = parentId;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
return {
|
|
1664
|
+
entries,
|
|
1665
|
+
leafId: entries.at(-1)?.id ?? null
|
|
1666
|
+
};
|
|
1667
|
+
},
|
|
1668
|
+
scanEntries: (query, limit, cursor, scanContext) => conversation.entries(query, limit, cursor, scanContext),
|
|
1669
|
+
readIdentities: (readContext) => harness.snapshot(IdentityHistoryDoc, conversation.id, readContext),
|
|
1798
1670
|
async getContextMessages() {
|
|
1799
1671
|
const assertReadable = () => {
|
|
1800
1672
|
if (disposed || quarantined) throw new Error("Direct harness context is unavailable", { cause: failure });
|
|
1801
1673
|
};
|
|
1802
1674
|
assertReadable();
|
|
1803
|
-
const
|
|
1804
|
-
const view = await lane.context(context);
|
|
1675
|
+
const view = await conversation.context(context);
|
|
1805
1676
|
assertReadable();
|
|
1806
|
-
const messages =
|
|
1677
|
+
const messages = restoreCustomContextMessages(view.messages, view);
|
|
1807
1678
|
assertReadable();
|
|
1808
1679
|
return structuredClone(messages);
|
|
1809
1680
|
},
|
|
@@ -1816,12 +1687,10 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1816
1687
|
const metadata = await harness.snapshot(SessionMetadataDoc, context);
|
|
1817
1688
|
const stats = await getSessionStats();
|
|
1818
1689
|
const inbox = await harness.snapshot(InboxDoc, conversation.id, context);
|
|
1819
|
-
const
|
|
1820
|
-
const
|
|
1821
|
-
const nativePending = inbox?.items.filter((item) => item.mode !== "write" && !retainedSubmissions.has(item.id)).length ?? 0;
|
|
1690
|
+
const held = (await readRecord()).held.length;
|
|
1691
|
+
const nativePending = inbox?.items.filter((item) => item.mode !== "write").length ?? 0;
|
|
1822
1692
|
return json({
|
|
1823
1693
|
sessionId,
|
|
1824
|
-
sessionFile: storage.sessionFile,
|
|
1825
1694
|
sessionName: metadata?.name,
|
|
1826
1695
|
model: agent.model ? {
|
|
1827
1696
|
provider: agent.model.provider,
|
|
@@ -1841,13 +1710,13 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1841
1710
|
followUpMode: settings.followUpMode ?? "one-at-a-time",
|
|
1842
1711
|
autoCompactionEnabled: settings.compaction?.enabled ?? true,
|
|
1843
1712
|
messageCount: stats.messageCount,
|
|
1844
|
-
pendingMessageCount:
|
|
1713
|
+
pendingMessageCount: held + nativePending + nextTurnMessages.length + deferredInternalCount
|
|
1845
1714
|
});
|
|
1846
1715
|
},
|
|
1847
1716
|
enqueueAutomatic: async (value, images) => {
|
|
1848
1717
|
assertUnlocked();
|
|
1849
|
-
const result = await enqueue(value, images, "nextRun",
|
|
1850
|
-
|
|
1718
|
+
const result = await enqueue(value, images, "nextRun", true);
|
|
1719
|
+
dispatch().catch((error) => emit({
|
|
1851
1720
|
type: "error",
|
|
1852
1721
|
error: String(error)
|
|
1853
1722
|
}));
|
|
@@ -1855,26 +1724,43 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1855
1724
|
},
|
|
1856
1725
|
removeQueued,
|
|
1857
1726
|
async promoteQueued(id, operationId) {
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1727
|
+
guardUserAdmission();
|
|
1728
|
+
assertUnlocked();
|
|
1729
|
+
if (handingOff.has(id)) return "in_flight";
|
|
1730
|
+
const result = await admitUser(() => writable(async () => {
|
|
1731
|
+
try {
|
|
1732
|
+
return await harness.commit((tx) => admitSelected(tx, conversation.id, {
|
|
1733
|
+
id,
|
|
1734
|
+
operationId
|
|
1735
|
+
}, settings, false), context);
|
|
1736
|
+
} catch (error) {
|
|
1737
|
+
if (await storage.storage.submissionByRequest(conversation.id, heldRequestId(id), context)) return "promoted";
|
|
1738
|
+
throw error;
|
|
1739
|
+
}
|
|
1740
|
+
}));
|
|
1741
|
+
if (typeof result === "string" && result !== "promoted") {
|
|
1742
|
+
await publish();
|
|
1743
|
+
return result;
|
|
1744
|
+
}
|
|
1745
|
+
harness.resume();
|
|
1746
|
+
await publish();
|
|
1747
|
+
return "promoted";
|
|
1862
1748
|
},
|
|
1863
1749
|
async resumeQueue() {
|
|
1864
1750
|
guardUserAdmission();
|
|
1865
1751
|
await changeRecord((r) => {
|
|
1866
1752
|
r.paused = false;
|
|
1867
1753
|
delete r.abortOperationId;
|
|
1868
|
-
delete r.abortTaskId;
|
|
1869
1754
|
});
|
|
1870
1755
|
await publish();
|
|
1871
|
-
|
|
1756
|
+
dispatch().catch((error) => emit({
|
|
1872
1757
|
type: "error",
|
|
1873
1758
|
error: String(error)
|
|
1874
1759
|
}));
|
|
1875
1760
|
},
|
|
1876
1761
|
recover,
|
|
1877
1762
|
async setFastMode(enabled) {
|
|
1763
|
+
mainOnly();
|
|
1878
1764
|
if (enabled) {
|
|
1879
1765
|
const selected = (await conversation.agent(context)).model;
|
|
1880
1766
|
const model = selected ? models.getModel(selected.provider, selected.modelId) : void 0;
|
|
@@ -1899,6 +1785,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1899
1785
|
},
|
|
1900
1786
|
agentLocked: () => agentLocked,
|
|
1901
1787
|
async setAgentLock(locked) {
|
|
1788
|
+
mainOnly();
|
|
1902
1789
|
if (typeof locked !== "boolean") throw new Error("Agent lock must be a boolean.");
|
|
1903
1790
|
await writable(() => harness.commit(async (tx) => {
|
|
1904
1791
|
(await tx.doc(AgentLockDoc)).locked = locked;
|
|
@@ -1954,6 +1841,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
1954
1841
|
};
|
|
1955
1842
|
},
|
|
1956
1843
|
navigateTree: (targetId, navigationOptions) => runExternalOperation(async () => {
|
|
1844
|
+
mainOnly();
|
|
1957
1845
|
try {
|
|
1958
1846
|
const expected = conversation.id;
|
|
1959
1847
|
if (targetId !== null && !await storage.storage.entry(conversation.id, nativeId(targetId), context)) throw new Error("Navigation target is not in the selected conversation");
|
|
@@ -2046,6 +1934,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2046
1934
|
} } : void 0);
|
|
2047
1935
|
const agent = await conversation.agent(context);
|
|
2048
1936
|
conversation = await harness.conversation(id, context);
|
|
1937
|
+
statsCache = void 0;
|
|
2049
1938
|
if (targetId === null) await conversation.configure({
|
|
2050
1939
|
model: agent.model,
|
|
2051
1940
|
thinkingLevel: agent.thinkingLevel,
|
|
@@ -2059,7 +1948,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2059
1948
|
(await tx.doc(LabelsDoc)).labels[targetId] = navigationOptions.label;
|
|
2060
1949
|
}, context);
|
|
2061
1950
|
for (const entry of result.entries) if (entry.type === "branch_summary") await deliver({
|
|
2062
|
-
type: "
|
|
1951
|
+
type: "entry_appended",
|
|
2063
1952
|
entry
|
|
2064
1953
|
}, context);
|
|
2065
1954
|
const event = {
|
|
@@ -2091,7 +1980,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2091
1980
|
}
|
|
2092
1981
|
}),
|
|
2093
1982
|
async clearQueue() {
|
|
2094
|
-
const selected = (await
|
|
1983
|
+
const selected = (await readLifecycle()).queue;
|
|
2095
1984
|
for (const item of selected) await removeQueued(item.id);
|
|
2096
1985
|
await publish();
|
|
2097
1986
|
return {
|
|
@@ -2100,6 +1989,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2100
1989
|
};
|
|
2101
1990
|
},
|
|
2102
1991
|
async setName(name) {
|
|
1992
|
+
mainOnly();
|
|
2103
1993
|
await writable(() => harness.commit(async (tx) => {
|
|
2104
1994
|
(await tx.doc(SessionMetadataDoc)).name = name;
|
|
2105
1995
|
}, context));
|
|
@@ -2108,6 +1998,16 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2108
1998
|
name
|
|
2109
1999
|
});
|
|
2110
2000
|
},
|
|
2001
|
+
async setGroups(groups) {
|
|
2002
|
+
mainOnly();
|
|
2003
|
+
await writable(() => harness.commit(async (tx) => {
|
|
2004
|
+
(await tx.doc(SessionMetadataDoc)).groups = [...groups];
|
|
2005
|
+
}, context));
|
|
2006
|
+
emit({
|
|
2007
|
+
type: SESSION_GROUPS_CHANGED_FRAME,
|
|
2008
|
+
groups: [...groups]
|
|
2009
|
+
});
|
|
2010
|
+
},
|
|
2111
2011
|
getSessionStats,
|
|
2112
2012
|
async replaceTools(replacement) {
|
|
2113
2013
|
tools = replacement;
|
|
@@ -2123,23 +2023,35 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2123
2023
|
return resources;
|
|
2124
2024
|
},
|
|
2125
2025
|
runExternalOperation,
|
|
2026
|
+
runAtToolBoundary,
|
|
2126
2027
|
appendCustomEntry: async (customType, data) => {
|
|
2127
2028
|
const lane = conversation;
|
|
2128
|
-
return String((await writable(() => lane.commit((tx) =>
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2029
|
+
return String((await writable(() => lane.commit(async (tx) => {
|
|
2030
|
+
const entry = await tx.appendEntry(lane.id, {
|
|
2031
|
+
kind: customType,
|
|
2032
|
+
...data === void 0 ? {} : { data: json(data) },
|
|
2033
|
+
...options.entryProjectors?.[customType] ? { model: convertToLlm(options.entryProjectors[customType]({
|
|
2034
|
+
type: "custom",
|
|
2035
|
+
id: "",
|
|
2036
|
+
parentId: null,
|
|
2037
|
+
timestamp: Date.now(),
|
|
2038
|
+
seq: 0,
|
|
2039
|
+
customType,
|
|
2040
|
+
...data === void 0 ? {} : { data: json(data) }
|
|
2041
|
+
})) } : {}
|
|
2042
|
+
});
|
|
2043
|
+
if (customType === "po-profile-identity") {
|
|
2044
|
+
const history = await tx.doc(IdentityHistoryDoc, lane.id);
|
|
2045
|
+
const identity = json(data ?? {});
|
|
2046
|
+
if (JSON.stringify(history.items.at(-1)?.data) !== JSON.stringify(identity)) history.items.push({
|
|
2047
|
+
seq: Number(entry.id),
|
|
2048
|
+
data: identity
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
return entry;
|
|
2052
|
+
}, context))).id);
|
|
2141
2053
|
},
|
|
2142
|
-
appendMessage,
|
|
2054
|
+
appendMessage: (message) => appendMessage(message),
|
|
2143
2055
|
registerCheckpointBoundary(callback) {
|
|
2144
2056
|
const registration = {
|
|
2145
2057
|
active: true,
|
|
@@ -2154,11 +2066,14 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2154
2066
|
}
|
|
2155
2067
|
};
|
|
2156
2068
|
},
|
|
2157
|
-
setLabel: (targetId, label) => writable(() =>
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2069
|
+
setLabel: (targetId, label) => writable(() => {
|
|
2070
|
+
mainOnly();
|
|
2071
|
+
return harness.commit(async (tx) => {
|
|
2072
|
+
const labels = (await tx.doc(LabelsDoc)).labels;
|
|
2073
|
+
if (label === void 0) delete labels[targetId];
|
|
2074
|
+
else labels[targetId] = label;
|
|
2075
|
+
}, context);
|
|
2076
|
+
}),
|
|
2162
2077
|
recordUsage,
|
|
2163
2078
|
submitPrompt: admit,
|
|
2164
2079
|
submitUserPrompt,
|
|
@@ -2182,7 +2097,11 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2182
2097
|
timestamp: Date.now()
|
|
2183
2098
|
} : message;
|
|
2184
2099
|
if (agentLocked) {
|
|
2185
|
-
|
|
2100
|
+
try {
|
|
2101
|
+
await appendMessage(preserved, requestId);
|
|
2102
|
+
} catch (error) {
|
|
2103
|
+
if (!await storage.storage.submissionByRequest(conversation.id, requestId, context)) throw error;
|
|
2104
|
+
}
|
|
2186
2105
|
return { settled: Promise.resolve() };
|
|
2187
2106
|
}
|
|
2188
2107
|
const deliveryRecord = {
|
|
@@ -2192,68 +2111,44 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2192
2111
|
if (userAdmission) {
|
|
2193
2112
|
deferredInternalCount++;
|
|
2194
2113
|
admittingInternal.add(requestId);
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
(r.internalDeliveries ??= {})[requestId] = deliveryRecord;
|
|
2198
|
-
});
|
|
2199
|
-
} catch (error) {
|
|
2114
|
+
internalDeliveries.set(requestId, deliveryRecord);
|
|
2115
|
+
const admission = userAdmissionSettled.then(() => {
|
|
2200
2116
|
deferredInternalCount--;
|
|
2201
2117
|
admittingInternal.delete(requestId);
|
|
2202
|
-
|
|
2203
|
-
}
|
|
2204
|
-
const settled = userAdmissionSettled.then(async () => {
|
|
2205
|
-
deferredInternalCount--;
|
|
2206
|
-
admittingInternal.delete(requestId);
|
|
2207
|
-
await (await submitInternalMessage(preserved, delivery, requestId)).settled;
|
|
2118
|
+
return submitInternalMessage(preserved, delivery, requestId);
|
|
2208
2119
|
});
|
|
2120
|
+
const settled = admission.then((submission) => submission.settled);
|
|
2209
2121
|
settled.catch((error) => emit({
|
|
2210
2122
|
type: "error",
|
|
2211
2123
|
code: "internal_message",
|
|
2212
2124
|
error: String(error)
|
|
2213
2125
|
}));
|
|
2214
|
-
|
|
2126
|
+
const admitted = admission.then((submission) => submission.admitted);
|
|
2127
|
+
admitted.catch(() => void 0);
|
|
2128
|
+
return {
|
|
2129
|
+
settled,
|
|
2130
|
+
admitted
|
|
2131
|
+
};
|
|
2215
2132
|
}
|
|
2216
2133
|
if (external) throw new Error("An operation is already running");
|
|
2217
2134
|
const content = typeof message === "string" ? message : message.content;
|
|
2218
|
-
const submit = async (draft) => {
|
|
2219
|
-
try {
|
|
2220
|
-
return await writable(() => conversation.submit(draft, context));
|
|
2221
|
-
} catch (error) {
|
|
2222
|
-
const accepted = await storage.storage.submissionByRequest(conversation.id, draft.requestId, context);
|
|
2223
|
-
const submission = accepted && await harness.submission(accepted.id, context);
|
|
2224
|
-
if (!submission) throw error;
|
|
2225
|
-
return submission;
|
|
2226
|
-
}
|
|
2227
|
-
};
|
|
2228
2135
|
admittingInternal.add(requestId);
|
|
2229
|
-
let envelope;
|
|
2230
2136
|
let submission;
|
|
2231
2137
|
try {
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
requestId
|
|
2238
|
-
entry: {
|
|
2138
|
+
internalDeliveries.set(requestId, deliveryRecord);
|
|
2139
|
+
submission = await submitInput({
|
|
2140
|
+
type: "input",
|
|
2141
|
+
content,
|
|
2142
|
+
whenBusy: delivery,
|
|
2143
|
+
requestId,
|
|
2144
|
+
...preserved.role === "custom" ? { entry: {
|
|
2239
2145
|
kind: "po.entry",
|
|
2240
2146
|
data: json({
|
|
2241
2147
|
type: "message",
|
|
2242
|
-
message,
|
|
2243
|
-
timestamp:
|
|
2244
|
-
inputRequestId: requestId
|
|
2148
|
+
message: preserved,
|
|
2149
|
+
timestamp: preserved.timestamp
|
|
2245
2150
|
})
|
|
2246
|
-
}
|
|
2247
|
-
}) : void 0;
|
|
2248
|
-
submission = await submit({
|
|
2249
|
-
type: "input",
|
|
2250
|
-
content,
|
|
2251
|
-
whenBusy: delivery,
|
|
2252
|
-
requestId
|
|
2253
|
-
});
|
|
2254
|
-
await changeRecord((r) => {
|
|
2255
|
-
const item = r.internalDeliveries?.[requestId];
|
|
2256
|
-
if (item) item.submissionId = submission.id;
|
|
2151
|
+
} } : {}
|
|
2257
2152
|
});
|
|
2258
2153
|
} finally {
|
|
2259
2154
|
admittingInternal.delete(requestId);
|
|
@@ -2278,7 +2173,6 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2278
2173
|
await conversation.waitForIdle(context);
|
|
2279
2174
|
await reconcileInternal(requestId, deliveryRecord);
|
|
2280
2175
|
}
|
|
2281
|
-
if (envelope && (await envelope.wait(context)).status !== "done") throw new Error("Internal message journal write failed");
|
|
2282
2176
|
if (status.status === "done" || status.entry !== void 0) {
|
|
2283
2177
|
if (!(await harness.snapshot(LiveDoc, deliveryRecord.conversationId, context))?.run?.inputs.some((id) => String(id) === String(submission.id))) pendingDelivery.resolve();
|
|
2284
2178
|
await delivered;
|
|
@@ -2298,13 +2192,14 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2298
2192
|
},
|
|
2299
2193
|
steer: async (message, images) => {
|
|
2300
2194
|
if (typeof message !== "string" && message.role !== "user") throw new Error("Only user messages can steer an agent run");
|
|
2301
|
-
await submitUserPrompt(message, images,
|
|
2195
|
+
await submitUserPrompt(message, images, "steer");
|
|
2302
2196
|
},
|
|
2303
2197
|
followUp: (message, images) => queued(message, images, "followUp"),
|
|
2304
2198
|
nextRun: (message, images) => queued(message, images, "nextRun"),
|
|
2305
2199
|
abort,
|
|
2306
2200
|
interrupt,
|
|
2307
2201
|
async compact(instructions) {
|
|
2202
|
+
if (attached) throw new Error("Manual compaction runs on the main lane only.");
|
|
2308
2203
|
guardUserAdmission();
|
|
2309
2204
|
if (external || compactionAdmission) throw new Error("An operation is already running");
|
|
2310
2205
|
compactionAdmission = true;
|
|
@@ -2318,17 +2213,20 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2318
2213
|
keepRecentTokens: 0
|
|
2319
2214
|
}
|
|
2320
2215
|
};
|
|
2216
|
+
manualCompaction.conversationId = String(conversation.id);
|
|
2321
2217
|
const task = await writable(() => conversation.compact(instructions, context));
|
|
2322
2218
|
const receipt = await harness.waitForTask(task, context);
|
|
2323
2219
|
await eventsSettled;
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
"
|
|
2327
|
-
|
|
2328
|
-
|
|
2220
|
+
const outcome = receipt.state.outcome;
|
|
2221
|
+
if (outcome.status === "failed" || outcome.status === "faulted" || outcome.status === "orphaned") {
|
|
2222
|
+
const reason = outcome.status === "orphaned" ? outcome.reason : outcome.error.message;
|
|
2223
|
+
throw new Error(`Compaction failed: ${reason.trim() || outcome.status}`, { cause: outcome });
|
|
2224
|
+
}
|
|
2329
2225
|
} finally {
|
|
2330
2226
|
settings = previous;
|
|
2227
|
+
delete manualCompaction.conversationId;
|
|
2331
2228
|
compactionAdmission = false;
|
|
2229
|
+
if (!await nativeExecution()) await flushToolBoundary();
|
|
2332
2230
|
}
|
|
2333
2231
|
},
|
|
2334
2232
|
async admitResume() {
|
|
@@ -2338,7 +2236,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2338
2236
|
const settled = (async () => {
|
|
2339
2237
|
await conversation.waitForIdle(context);
|
|
2340
2238
|
await eventsSettled;
|
|
2341
|
-
await
|
|
2239
|
+
await dispatch();
|
|
2342
2240
|
})();
|
|
2343
2241
|
settled.catch((error) => emit({
|
|
2344
2242
|
type: "error",
|
|
@@ -2358,15 +2256,35 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2358
2256
|
await conversation.waitForIdle(context);
|
|
2359
2257
|
await eventsSettled;
|
|
2360
2258
|
}
|
|
2361
|
-
|
|
2259
|
+
dispatch().catch((error) => emit({
|
|
2362
2260
|
type: "error",
|
|
2363
2261
|
error: String(error)
|
|
2364
2262
|
}));
|
|
2365
2263
|
return resumed;
|
|
2366
2264
|
},
|
|
2265
|
+
openLane(laneConversation, laneOptions) {
|
|
2266
|
+
if (attached) return Promise.reject(/* @__PURE__ */ new Error("Lanes open on the main lane."));
|
|
2267
|
+
return createLaneRuntime({
|
|
2268
|
+
...laneOptions,
|
|
2269
|
+
platform,
|
|
2270
|
+
models: sourceModels
|
|
2271
|
+
}, {
|
|
2272
|
+
harness,
|
|
2273
|
+
storage,
|
|
2274
|
+
registry,
|
|
2275
|
+
conversation: laneConversation,
|
|
2276
|
+
laneProviderSessions,
|
|
2277
|
+
manualCompaction
|
|
2278
|
+
});
|
|
2279
|
+
},
|
|
2280
|
+
closeLane(conversationId) {
|
|
2281
|
+
if (attached) throw new Error("Lanes close on the main lane.");
|
|
2282
|
+
registry.uninstall({ name: laneExtensionName(conversationId) });
|
|
2283
|
+
},
|
|
2367
2284
|
dispose
|
|
2368
2285
|
};
|
|
2369
2286
|
} catch (error) {
|
|
2287
|
+
if (attached) throw error;
|
|
2370
2288
|
const failures = [error];
|
|
2371
2289
|
try {
|
|
2372
2290
|
if (startupHarness) await startupHarness.close(context);
|
|
@@ -2375,8 +2293,7 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2375
2293
|
failures.push(closeError);
|
|
2376
2294
|
}
|
|
2377
2295
|
if (failures.length === 1) try {
|
|
2378
|
-
await storage.
|
|
2379
|
-
await storage.historyLease?.release();
|
|
2296
|
+
await storage.release(context);
|
|
2380
2297
|
} catch (closeError) {
|
|
2381
2298
|
failures.push(closeError);
|
|
2382
2299
|
}
|
|
@@ -2385,6 +2302,6 @@ async function createDirectHarnessRuntime(options) {
|
|
|
2385
2302
|
}
|
|
2386
2303
|
}
|
|
2387
2304
|
//#endregion
|
|
2388
|
-
export {
|
|
2305
|
+
export { createDirectHarnessRuntime, projectDurableConversationEntries, promptForAssistantText };
|
|
2389
2306
|
|
|
2390
2307
|
//# sourceMappingURL=directHarnessRuntime.mjs.map
|