@downcity/agent 1.1.338 → 1.1.400
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/README.md +31 -15
- package/bin/agent/Agent.d.ts +42 -91
- package/bin/agent/Agent.d.ts.map +1 -1
- package/bin/agent/Agent.js +115 -200
- package/bin/agent/Agent.js.map +1 -1
- package/bin/agent/AgentModel.d.ts +8 -8
- package/bin/agent/AgentModel.d.ts.map +1 -1
- package/bin/agent/AgentModel.js +5 -5
- package/bin/agent/AgentModel.js.map +1 -1
- package/bin/agent/AgentSessions.d.ts +42 -28
- package/bin/agent/AgentSessions.d.ts.map +1 -1
- package/bin/agent/AgentSessions.js +80 -44
- package/bin/agent/AgentSessions.js.map +1 -1
- package/bin/agent/WorkspaceEntry.d.ts +82 -0
- package/bin/agent/WorkspaceEntry.d.ts.map +1 -0
- package/bin/agent/WorkspaceEntry.js +246 -0
- package/bin/agent/WorkspaceEntry.js.map +1 -0
- package/bin/agent/index.d.ts +5 -0
- package/bin/agent/index.d.ts.map +1 -0
- package/bin/agent/index.js +5 -0
- package/bin/agent/index.js.map +1 -0
- package/bin/city/host/CityHostRegistry.d.ts +44 -0
- package/bin/city/host/CityHostRegistry.d.ts.map +1 -0
- package/bin/city/host/CityHostRegistry.js +225 -0
- package/bin/city/host/CityHostRegistry.js.map +1 -0
- package/bin/city/index.d.ts +22 -0
- package/bin/city/index.d.ts.map +1 -0
- package/bin/city/index.js +10 -0
- package/bin/city/index.js.map +1 -0
- package/bin/city/runtime/City.d.ts +99 -0
- package/bin/city/runtime/City.d.ts.map +1 -0
- package/bin/city/runtime/City.js +376 -0
- package/bin/city/runtime/City.js.map +1 -0
- package/bin/city/transport/SerializedTransport.d.ts +30 -0
- package/bin/city/transport/SerializedTransport.d.ts.map +1 -0
- package/bin/city/transport/SerializedTransport.js +57 -0
- package/bin/city/transport/SerializedTransport.js.map +1 -0
- package/bin/city/transport/http/AgentHTTP.d.ts +66 -0
- package/bin/city/transport/http/AgentHTTP.d.ts.map +1 -0
- package/bin/city/transport/http/AgentHTTP.js +142 -0
- package/bin/city/transport/http/AgentHTTP.js.map +1 -0
- package/bin/city/transport/http/CityHTTP.d.ts +44 -0
- package/bin/city/transport/http/CityHTTP.d.ts.map +1 -0
- package/bin/city/transport/http/CityHTTP.js +171 -0
- package/bin/city/transport/http/CityHTTP.js.map +1 -0
- package/bin/city/transport/http/NodeHttpAdapter.d.ts +27 -0
- package/bin/city/transport/http/NodeHttpAdapter.d.ts.map +1 -0
- package/bin/city/transport/http/NodeHttpAdapter.js +57 -0
- package/bin/city/transport/http/NodeHttpAdapter.js.map +1 -0
- package/bin/city/transport/http/routes/RuntimeRoutes.d.ts +15 -0
- package/bin/city/transport/http/routes/RuntimeRoutes.d.ts.map +1 -0
- package/bin/city/transport/http/routes/RuntimeRoutes.js +38 -0
- package/bin/city/transport/http/routes/RuntimeRoutes.js.map +1 -0
- package/bin/city/transport/http/routes/SessionRoutes.d.ts +17 -0
- package/bin/city/transport/http/routes/SessionRoutes.d.ts.map +1 -0
- package/bin/city/transport/http/routes/SessionRoutes.js +417 -0
- package/bin/city/transport/http/routes/SessionRoutes.js.map +1 -0
- package/bin/city/transport/rpc/AgentRPC.d.ts +47 -0
- package/bin/city/transport/rpc/AgentRPC.d.ts.map +1 -0
- package/bin/city/transport/rpc/AgentRPC.js +89 -0
- package/bin/city/transport/rpc/AgentRPC.js.map +1 -0
- package/bin/city/transport/rpc/CityRPC.d.ts +26 -0
- package/bin/city/transport/rpc/CityRPC.d.ts.map +1 -0
- package/bin/city/transport/rpc/CityRPC.js +110 -0
- package/bin/city/transport/rpc/CityRPC.js.map +1 -0
- package/bin/city/transport/rpc/RpcServer.d.ts +30 -0
- package/bin/city/transport/rpc/RpcServer.d.ts.map +1 -0
- package/bin/city/transport/rpc/RpcServer.js +125 -0
- package/bin/city/transport/rpc/RpcServer.js.map +1 -0
- package/bin/city/transport/rpc/server/InternalHandlers.d.ts +22 -0
- package/bin/city/transport/rpc/server/InternalHandlers.d.ts.map +1 -0
- package/bin/city/transport/rpc/server/InternalHandlers.js +196 -0
- package/bin/city/transport/rpc/server/InternalHandlers.js.map +1 -0
- package/bin/city/transport/rpc/server/RequestDispatcher.d.ts +27 -0
- package/bin/city/transport/rpc/server/RequestDispatcher.d.ts.map +1 -0
- package/bin/city/transport/rpc/server/RequestDispatcher.js +38 -0
- package/bin/city/transport/rpc/server/RequestDispatcher.js.map +1 -0
- package/bin/city/transport/rpc/server/SdkSessionHandlers.d.ts +25 -0
- package/bin/city/transport/rpc/server/SdkSessionHandlers.d.ts.map +1 -0
- package/bin/city/transport/rpc/server/SdkSessionHandlers.js +146 -0
- package/bin/city/transport/rpc/server/SdkSessionHandlers.js.map +1 -0
- package/bin/city/transport/rpc/server/ServerTypes.d.ts +94 -0
- package/bin/city/transport/rpc/server/ServerTypes.d.ts.map +1 -0
- package/bin/city/transport/rpc/server/ServerTypes.js +9 -0
- package/bin/city/transport/rpc/server/ServerTypes.js.map +1 -0
- package/bin/city/transport/session/RemoteSessionConfig.d.ts +15 -0
- package/bin/city/transport/session/RemoteSessionConfig.d.ts.map +1 -0
- package/bin/city/transport/session/RemoteSessionConfig.js +23 -0
- package/bin/city/transport/session/RemoteSessionConfig.js.map +1 -0
- package/bin/city/transport/types/AgentHttpBinding.d.ts +24 -0
- package/bin/city/transport/types/AgentHttpBinding.d.ts.map +1 -0
- package/bin/city/transport/types/AgentHttpBinding.js +5 -0
- package/bin/city/transport/types/AgentHttpBinding.js.map +1 -0
- package/bin/city/transport/types/AgentHttpRuntime.d.ts +12 -0
- package/bin/city/transport/types/AgentHttpRuntime.d.ts.map +1 -0
- package/bin/city/transport/types/AgentHttpRuntime.js +7 -0
- package/bin/city/transport/types/AgentHttpRuntime.js.map +1 -0
- package/bin/city/transport/types/AgentRpcBinding.d.ts +27 -0
- package/bin/city/transport/types/AgentRpcBinding.d.ts.map +1 -0
- package/bin/city/transport/types/AgentRpcBinding.js +8 -0
- package/bin/city/transport/types/AgentRpcBinding.js.map +1 -0
- package/bin/city/transport/types/AgentRpcRuntime.d.ts +18 -0
- package/bin/city/transport/types/AgentRpcRuntime.d.ts.map +1 -0
- package/bin/city/transport/types/AgentRpcRuntime.js +7 -0
- package/bin/city/transport/types/AgentRpcRuntime.js.map +1 -0
- package/bin/city/transport/types/AgentSessionModelResolver.d.ts +11 -0
- package/bin/city/transport/types/AgentSessionModelResolver.d.ts.map +1 -0
- package/bin/city/transport/types/AgentSessionModelResolver.js +7 -0
- package/bin/city/transport/types/AgentSessionModelResolver.js.map +1 -0
- package/bin/city/transport/types/CityHttpRuntime.d.ts +36 -0
- package/bin/city/transport/types/CityHttpRuntime.d.ts.map +1 -0
- package/bin/city/transport/types/CityHttpRuntime.js +8 -0
- package/bin/city/transport/types/CityHttpRuntime.js.map +1 -0
- package/bin/city/transport/types/CityRpcRuntime.d.ts +17 -0
- package/bin/city/transport/types/CityRpcRuntime.d.ts.map +1 -0
- package/bin/city/transport/types/CityRpcRuntime.js +8 -0
- package/bin/city/transport/types/CityRpcRuntime.js.map +1 -0
- package/bin/city/transport/types/RpcProtocol.d.ts +24 -0
- package/bin/city/transport/types/RpcProtocol.d.ts.map +1 -0
- package/bin/city/transport/types/RpcProtocol.js +9 -0
- package/bin/city/transport/types/RpcProtocol.js.map +1 -0
- package/bin/city/types/City.d.ts +84 -0
- package/bin/city/types/City.d.ts.map +1 -0
- package/bin/city/types/City.js +7 -0
- package/bin/city/types/City.js.map +1 -0
- package/bin/city/types/PluginHostContext.d.ts +31 -0
- package/bin/city/types/PluginHostContext.d.ts.map +1 -0
- package/bin/city/types/PluginHostContext.js +11 -0
- package/bin/city/types/PluginHostContext.js.map +1 -0
- package/bin/city/types/SerializedTransport.d.ts +16 -0
- package/bin/city/types/SerializedTransport.d.ts.map +1 -0
- package/bin/city/types/SerializedTransport.js +3 -0
- package/bin/city/types/SerializedTransport.js.map +1 -0
- package/bin/executor/Executor.d.ts +4 -4
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +90 -34
- package/bin/executor/Executor.js.map +1 -1
- package/bin/executor/composer/system/SessionSystemComposer.d.ts +2 -2
- package/bin/executor/composer/system/SessionSystemComposer.d.ts.map +1 -1
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.d.ts +3 -3
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.js +1 -1
- package/bin/executor/composer/system/default/PromptRenderer.d.ts +3 -3
- package/bin/executor/composer/system/default/PromptRenderer.d.ts.map +1 -1
- package/bin/executor/composer/system/default/PromptRenderer.js +1 -1
- package/bin/executor/composer/system/default/SystemDomain.d.ts +3 -3
- package/bin/executor/composer/system/default/SystemDomain.d.ts.map +1 -1
- package/bin/executor/composer/system/default/SystemDomain.js +3 -3
- package/bin/executor/composer/system/default/SystemDomain.js.map +1 -1
- package/bin/executor/composer/system/default/SystemPromptAssets.js +2 -2
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
- package/bin/executor/composer/system/default/variables/GeoContext.d.ts +1 -1
- package/bin/executor/composer/system/default/variables/VariableReplacer.js +1 -1
- package/bin/executor/core-engine/CoreEngineContextCompaction.d.ts +6 -23
- package/bin/executor/core-engine/CoreEngineContextCompaction.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineContextCompaction.js +112 -344
- package/bin/executor/core-engine/CoreEngineContextCompaction.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineError.d.ts +1 -1
- package/bin/executor/core-engine/CoreEngineError.js +1 -1
- package/bin/executor/core-engine/CoreEngineLoopDecision.d.ts +2 -3
- package/bin/executor/core-engine/CoreEngineLoopDecision.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineLoopDecision.js +1 -15
- package/bin/executor/core-engine/CoreEngineLoopDecision.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts +16 -39
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineMessageState.js +25 -60
- package/bin/executor/core-engine/CoreEngineMessageState.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.d.ts +10 -6
- package/bin/executor/core-engine/CoreEngineRunner.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.js +146 -234
- package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.d.ts +20 -58
- package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.js +84 -304
- package/bin/executor/core-engine/CoreEngineSignals.js.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.d.ts +6 -37
- package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.js +12 -243
- package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
- package/bin/executor/messages/SessionMessageLog.d.ts +7 -14
- package/bin/executor/messages/SessionMessageLog.d.ts.map +1 -1
- package/bin/executor/messages/SessionMessageLog.js +11 -26
- package/bin/executor/messages/SessionMessageLog.js.map +1 -1
- package/bin/executor/messages/SessionModelMessages.d.ts +14 -0
- package/bin/executor/messages/SessionModelMessages.d.ts.map +1 -0
- package/bin/executor/messages/SessionModelMessages.js +187 -0
- package/bin/executor/messages/SessionModelMessages.js.map +1 -0
- package/bin/executor/model/ModelGenerate.d.ts +22 -0
- package/bin/executor/model/ModelGenerate.d.ts.map +1 -0
- package/bin/executor/model/ModelGenerate.js +54 -0
- package/bin/executor/model/ModelGenerate.js.map +1 -0
- package/bin/executor/model/ModelStepRunner.d.ts +70 -0
- package/bin/executor/model/ModelStepRunner.d.ts.map +1 -0
- package/bin/executor/model/ModelStepRunner.js +284 -0
- package/bin/executor/model/ModelStepRunner.js.map +1 -0
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts +4 -4
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.d.ts +7 -2
- package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.js +1 -1
- package/bin/executor/types/SessionLoop.d.ts +1 -21
- package/bin/executor/types/SessionLoop.d.ts.map +1 -1
- package/bin/executor/types/SessionPrompts.d.ts +8 -7
- package/bin/executor/types/SessionPrompts.d.ts.map +1 -1
- package/bin/executor/types/SessionPrompts.js +1 -2
- package/bin/executor/types/SessionPrompts.js.map +1 -1
- package/bin/group/Group.d.ts +20 -0
- package/bin/group/Group.d.ts.map +1 -0
- package/bin/group/Group.js +42 -0
- package/bin/group/Group.js.map +1 -0
- package/bin/group/GroupSession.d.ts +103 -0
- package/bin/group/GroupSession.d.ts.map +1 -0
- package/bin/group/GroupSession.js +666 -0
- package/bin/group/GroupSession.js.map +1 -0
- package/bin/group/GroupSessions.d.ts +21 -0
- package/bin/group/GroupSessions.d.ts.map +1 -0
- package/bin/group/GroupSessions.js +89 -0
- package/bin/group/GroupSessions.js.map +1 -0
- package/bin/group/index.d.ts +9 -0
- package/bin/group/index.d.ts.map +1 -0
- package/bin/group/index.js +6 -0
- package/bin/group/index.js.map +1 -0
- package/bin/index.d.ts +28 -20
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +7 -9
- package/bin/index.js.map +1 -1
- package/bin/internal/AgentRuntime.d.ts +43 -0
- package/bin/internal/AgentRuntime.d.ts.map +1 -0
- package/bin/internal/AgentRuntime.js +179 -0
- package/bin/internal/AgentRuntime.js.map +1 -0
- package/bin/internal/GroupRuntime.d.ts +17 -0
- package/bin/internal/GroupRuntime.d.ts.map +1 -0
- package/bin/internal/GroupRuntime.js +66 -0
- package/bin/internal/GroupRuntime.js.map +1 -0
- package/bin/internal/index.d.ts +8 -0
- package/bin/internal/index.d.ts.map +1 -0
- package/bin/internal/index.js +8 -0
- package/bin/internal/index.js.map +1 -0
- package/bin/plugin/core/ActionScheduleExecutor.d.ts +3 -2
- package/bin/plugin/core/ActionScheduleExecutor.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleExecutor.js +14 -3
- package/bin/plugin/core/ActionScheduleExecutor.js.map +1 -1
- package/bin/plugin/core/ActionScheduleRuntime.d.ts +3 -1
- package/bin/plugin/core/ActionScheduleRuntime.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleRuntime.js +9 -8
- package/bin/plugin/core/ActionScheduleRuntime.js.map +1 -1
- package/bin/plugin/core/ActionScheduleStore.d.ts +7 -3
- package/bin/plugin/core/ActionScheduleStore.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleStore.js +32 -9
- package/bin/plugin/core/ActionScheduleStore.js.map +1 -1
- package/bin/plugin/core/HookRegistry.d.ts +4 -6
- package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
- package/bin/plugin/core/HookRegistry.js +8 -14
- package/bin/plugin/core/HookRegistry.js.map +1 -1
- package/bin/plugin/core/PluginActionExecution.d.ts +33 -0
- package/bin/plugin/core/PluginActionExecution.d.ts.map +1 -0
- package/bin/plugin/core/PluginActionExecution.js +168 -0
- package/bin/plugin/core/PluginActionExecution.js.map +1 -0
- package/bin/plugin/core/PluginActionFactory.d.ts +6 -3
- package/bin/plugin/core/PluginActionFactory.d.ts.map +1 -1
- package/bin/plugin/core/PluginActionFactory.js +3 -0
- package/bin/plugin/core/PluginActionFactory.js.map +1 -1
- package/bin/plugin/core/PluginContext.d.ts +14 -4
- package/bin/plugin/core/PluginContext.d.ts.map +1 -1
- package/bin/plugin/core/PluginContext.js +11 -2
- package/bin/plugin/core/PluginContext.js.map +1 -1
- package/bin/plugin/core/PluginHttpRoutes.d.ts +1 -1
- package/bin/plugin/core/PluginHttpRoutes.d.ts.map +1 -1
- package/bin/plugin/core/PluginHttpRoutes.js +1 -1
- package/bin/plugin/core/PluginHttpRoutes.js.map +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts +41 -26
- package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
- package/bin/plugin/core/PluginRegistry.js +125 -107
- package/bin/plugin/core/PluginRegistry.js.map +1 -1
- package/bin/plugin/tool/PluginToolRuntime.d.ts.map +1 -1
- package/bin/plugin/tool/PluginToolRuntime.js +4 -1
- package/bin/plugin/tool/PluginToolRuntime.js.map +1 -1
- package/bin/plugin/tool/PluginToolSchemas.d.ts +22 -2
- package/bin/plugin/tool/PluginToolSchemas.d.ts.map +1 -1
- package/bin/plugin/tool/PluginToolSchemas.js +3 -4
- package/bin/plugin/tool/PluginToolSchemas.js.map +1 -1
- package/bin/plugin/tool/PluginTools.d.ts +5 -8
- package/bin/plugin/tool/PluginTools.d.ts.map +1 -1
- package/bin/plugin/tool/PluginTools.js +9 -8
- package/bin/plugin/tool/PluginTools.js.map +1 -1
- package/bin/plugin/types/ActionSchedule.d.ts +6 -0
- package/bin/plugin/types/ActionSchedule.d.ts.map +1 -1
- package/bin/remote/RemoteAgent.js +2 -2
- package/bin/remote/RemoteSession.d.ts +1 -1
- package/bin/remote/TransportFactory.d.ts +1 -1
- package/bin/remote/TransportFactory.js +2 -2
- package/bin/remote/transports/HttpRemoteAgentTransport.d.ts +1 -1
- package/bin/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
- package/bin/remote/transports/HttpRemoteAgentTransport.js +3 -3
- package/bin/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
- package/bin/remote/transports/RpcClient.d.ts +1 -0
- package/bin/remote/transports/RpcClient.d.ts.map +1 -1
- package/bin/remote/transports/RpcClient.js +16 -0
- package/bin/remote/transports/RpcClient.js.map +1 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.d.ts +1 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.js +2 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.js.map +1 -1
- package/bin/session/DefaultSessionComposer.js +4 -4
- package/bin/session/DefaultSessionComposer.js.map +1 -1
- package/bin/session/Session.d.ts +9 -3
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +62 -53
- package/bin/session/Session.js.map +1 -1
- package/bin/session/SessionLoop.d.ts.map +1 -1
- package/bin/session/SessionLoop.js +23 -25
- package/bin/session/SessionLoop.js.map +1 -1
- package/bin/session/SessionMessages.d.ts +9 -11
- package/bin/session/SessionMessages.d.ts.map +1 -1
- package/bin/session/SessionMessages.js +56 -104
- package/bin/session/SessionMessages.js.map +1 -1
- package/bin/session/SessionQueue.d.ts +1 -1
- package/bin/session/SessionState.d.ts +3 -0
- package/bin/session/SessionState.d.ts.map +1 -1
- package/bin/session/SessionState.js +42 -12
- package/bin/session/SessionState.js.map +1 -1
- package/bin/session/SessionTitle.d.ts +6 -6
- package/bin/session/SessionTitle.d.ts.map +1 -1
- package/bin/session/SessionTitle.js +11 -39
- package/bin/session/SessionTitle.js.map +1 -1
- package/bin/session/browse/Browse.d.ts +6 -4
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +25 -43
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/control/SessionInteractions.d.ts +2 -2
- package/bin/session/control/SessionInteractions.d.ts.map +1 -1
- package/bin/session/control/SessionInteractions.js +68 -32
- package/bin/session/control/SessionInteractions.js.map +1 -1
- package/bin/session/execution/SessionAssistantOutputAdapter.d.ts +20 -17
- package/bin/session/execution/SessionAssistantOutputAdapter.d.ts.map +1 -1
- package/bin/session/execution/SessionAssistantOutputAdapter.js +35 -35
- package/bin/session/execution/SessionAssistantOutputAdapter.js.map +1 -1
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts +2 -2
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts.map +1 -1
- package/bin/session/execution/tools/SessionShellApprovalAdapter.js +20 -8
- package/bin/session/execution/tools/SessionShellApprovalAdapter.js.map +1 -1
- package/bin/session/messages/SessionAssistantMessageWriter.d.ts +42 -48
- package/bin/session/messages/SessionAssistantMessageWriter.d.ts.map +1 -1
- package/bin/session/messages/SessionAssistantMessageWriter.js +225 -543
- package/bin/session/messages/SessionAssistantMessageWriter.js.map +1 -1
- package/bin/session/messages/SessionJsonValue.d.ts +0 -10
- package/bin/session/messages/SessionJsonValue.d.ts.map +1 -1
- package/bin/session/messages/SessionJsonValue.js +0 -23
- package/bin/session/messages/SessionJsonValue.js.map +1 -1
- package/bin/session/messages/SessionMessageCompaction.d.ts +7 -3
- package/bin/session/messages/SessionMessageCompaction.d.ts.map +1 -1
- package/bin/session/messages/SessionMessageCompaction.js +69 -91
- package/bin/session/messages/SessionMessageCompaction.js.map +1 -1
- package/bin/session/messages/SessionMessageInteractionWriter.d.ts.map +1 -1
- package/bin/session/messages/SessionMessageInteractionWriter.js +22 -21
- package/bin/session/messages/SessionMessageInteractionWriter.js.map +1 -1
- package/bin/session/messages/SessionMessageText.d.ts +25 -0
- package/bin/session/messages/SessionMessageText.d.ts.map +1 -0
- package/bin/session/messages/SessionMessageText.js +52 -0
- package/bin/session/messages/SessionMessageText.js.map +1 -0
- package/bin/session/preview/SessionMessagePreview.d.ts +3 -3
- package/bin/session/preview/SessionMessagePreview.d.ts.map +1 -1
- package/bin/session/preview/SessionMessagePreview.js +10 -30
- package/bin/session/preview/SessionMessagePreview.js.map +1 -1
- package/bin/session/runtime/SessionTurnContext.d.ts.map +1 -1
- package/bin/session/runtime/SessionTurnContext.js +4 -2
- package/bin/session/runtime/SessionTurnContext.js.map +1 -1
- package/bin/session/storage/Metadata.d.ts +5 -3
- package/bin/session/storage/Metadata.d.ts.map +1 -1
- package/bin/session/storage/Metadata.js +26 -7
- package/bin/session/storage/Metadata.js.map +1 -1
- package/bin/tools/ask/AskQuestionsTool.d.ts +2 -16
- package/bin/tools/ask/AskQuestionsTool.d.ts.map +1 -1
- package/bin/tools/ask/AskQuestionsTool.js +21 -17
- package/bin/tools/ask/AskQuestionsTool.js.map +1 -1
- package/bin/types/action/ActionResult.d.ts +15 -10
- package/bin/types/action/ActionResult.d.ts.map +1 -1
- package/bin/types/action/ActionResult.js +2 -2
- package/bin/types/action/ActionResult.js.map +1 -1
- package/bin/types/agent/AgentOptions.d.ts +7 -14
- package/bin/types/agent/AgentOptions.d.ts.map +1 -1
- package/bin/types/agent/AgentSessionCollection.d.ts +42 -0
- package/bin/types/agent/AgentSessionCollection.d.ts.map +1 -0
- package/bin/types/agent/AgentSessionCollection.js +7 -0
- package/bin/types/agent/AgentSessionCollection.js.map +1 -0
- package/bin/types/agent/AgentStorage.d.ts +18 -0
- package/bin/types/agent/AgentStorage.d.ts.map +1 -0
- package/bin/types/agent/AgentStorage.js +8 -0
- package/bin/types/agent/AgentStorage.js.map +1 -0
- package/bin/types/agent/RemoteAgentOptions.d.ts +1 -1
- package/bin/types/agent/RemoteAgentPluginAction.d.ts +2 -2
- package/bin/types/agent/SessionActor.d.ts +15 -8
- package/bin/types/agent/SessionActor.d.ts.map +1 -1
- package/bin/types/agent/SessionTypes.d.ts +30 -11
- package/bin/types/agent/SessionTypes.d.ts.map +1 -1
- package/bin/types/agent/WorkspaceEntryOptions.d.ts +16 -0
- package/bin/types/agent/WorkspaceEntryOptions.d.ts.map +1 -0
- package/bin/types/agent/WorkspaceEntryOptions.js +8 -0
- package/bin/types/agent/WorkspaceEntryOptions.js.map +1 -0
- package/bin/types/executor/SessionAssistantOutput.d.ts +19 -17
- package/bin/types/executor/SessionAssistantOutput.d.ts.map +1 -1
- package/bin/types/executor/SessionAssistantOutput.js +2 -3
- package/bin/types/executor/SessionAssistantOutput.js.map +1 -1
- package/bin/types/executor/SessionToolExecutionContext.d.ts +8 -5
- package/bin/types/executor/SessionToolExecutionContext.d.ts.map +1 -1
- package/bin/types/executor/SessionToolExecutionContext.js +1 -1
- package/bin/types/executor/SessionTurnContext.d.ts +16 -16
- package/bin/types/executor/SessionTurnContext.d.ts.map +1 -1
- package/bin/types/group/DispatchStrategy.d.ts +62 -0
- package/bin/types/group/DispatchStrategy.d.ts.map +1 -0
- package/bin/types/group/DispatchStrategy.js +93 -0
- package/bin/types/group/DispatchStrategy.js.map +1 -0
- package/bin/types/group/Group.d.ts +61 -0
- package/bin/types/group/Group.d.ts.map +1 -0
- package/bin/types/group/Group.js +3 -0
- package/bin/types/group/Group.js.map +1 -0
- package/bin/types/group/GroupSession.d.ts +149 -0
- package/bin/types/group/GroupSession.d.ts.map +1 -0
- package/bin/types/group/GroupSession.js +3 -0
- package/bin/types/group/GroupSession.js.map +1 -0
- package/bin/types/group/GroupSessionStore.d.ts +77 -0
- package/bin/types/group/GroupSessionStore.d.ts.map +1 -0
- package/bin/types/group/GroupSessionStore.js +3 -0
- package/bin/types/group/GroupSessionStore.js.map +1 -0
- package/bin/types/plugin/AgentPluginContext.d.ts +25 -0
- package/bin/types/plugin/AgentPluginContext.d.ts.map +1 -0
- package/bin/types/plugin/AgentPluginContext.js +10 -0
- package/bin/types/plugin/AgentPluginContext.js.map +1 -0
- package/bin/types/plugin/PluginAction.d.ts +10 -8
- package/bin/types/plugin/PluginAction.d.ts.map +1 -1
- package/bin/types/plugin/PluginActionExecution.d.ts +31 -0
- package/bin/types/plugin/PluginActionExecution.d.ts.map +1 -0
- package/bin/types/plugin/PluginActionExecution.js +10 -0
- package/bin/types/plugin/PluginActionExecution.js.map +1 -0
- package/bin/types/plugin/PluginCommand.d.ts +5 -5
- package/bin/types/plugin/PluginCommand.d.ts.map +1 -1
- package/bin/types/plugin/PluginContext.d.ts +19 -8
- package/bin/types/plugin/PluginContext.d.ts.map +1 -1
- package/bin/types/plugin/PluginContext.js +1 -1
- package/bin/types/plugin/PluginDefinition.d.ts +6 -6
- package/bin/types/plugin/PluginExecutionContext.d.ts +4 -10
- package/bin/types/plugin/PluginExecutionContext.d.ts.map +1 -1
- package/bin/types/plugin/PluginExecutionContext.js +3 -5
- package/bin/types/plugin/PluginExecutionContext.js.map +1 -1
- package/bin/types/plugin/PluginHttp.d.ts +1 -1
- package/bin/types/plugin/PluginRuntime.d.ts +13 -8
- package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
- package/bin/types/plugin/PluginServices.d.ts +10 -0
- package/bin/types/plugin/PluginServices.d.ts.map +1 -0
- package/bin/types/plugin/PluginServices.js +3 -0
- package/bin/types/plugin/PluginServices.js.map +1 -0
- package/bin/types/plugin/PluginState.d.ts +3 -3
- package/bin/types/plugin/PluginState.d.ts.map +1 -1
- package/bin/types/plugin/PluginState.js +1 -1
- package/bin/types/plugin/PluginTool.d.ts +6 -4
- package/bin/types/plugin/PluginTool.d.ts.map +1 -1
- package/bin/types/rpc/RpcProtocol.d.ts +30 -8
- package/bin/types/rpc/RpcProtocol.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionAction.d.ts +6 -7
- package/bin/types/sdk/AgentSessionAction.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionAction.js +2 -3
- package/bin/types/sdk/AgentSessionAction.js.map +1 -1
- package/bin/types/sdk/AgentSessionPrompt.d.ts +7 -7
- package/bin/types/sdk/AgentSessionPrompt.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionPrompt.js +1 -4
- package/bin/types/sdk/AgentSessionPrompt.js.map +1 -1
- package/bin/types/session/SessionAction.d.ts +39 -0
- package/bin/types/session/SessionAction.d.ts.map +1 -0
- package/bin/types/session/SessionAction.js +8 -0
- package/bin/types/session/SessionAction.js.map +1 -0
- package/bin/types/session/SessionComposer.d.ts +10 -11
- package/bin/types/session/SessionComposer.d.ts.map +1 -1
- package/bin/types/session/SessionContent.d.ts +41 -0
- package/bin/types/session/SessionContent.d.ts.map +1 -0
- package/bin/types/session/SessionContent.js +8 -0
- package/bin/types/session/SessionContent.js.map +1 -0
- package/bin/types/session/SessionExecution.d.ts +9 -68
- package/bin/types/session/SessionExecution.d.ts.map +1 -1
- package/bin/types/session/SessionInteraction.d.ts +92 -58
- package/bin/types/session/SessionInteraction.d.ts.map +1 -1
- package/bin/types/session/SessionInteraction.js +11 -4
- package/bin/types/session/SessionInteraction.js.map +1 -1
- package/bin/types/session/SessionInteractions.d.ts +1 -1
- package/bin/types/session/SessionLocalState.d.ts +2 -2
- package/bin/types/session/SessionLoop.d.ts +5 -5
- package/bin/types/session/SessionLoop.d.ts.map +1 -1
- package/bin/types/session/SessionMessage.d.ts +27 -87
- package/bin/types/session/SessionMessage.d.ts.map +1 -1
- package/bin/types/session/SessionMessages.d.ts +14 -14
- package/bin/types/session/SessionMessages.d.ts.map +1 -1
- package/bin/types/session/SessionMutation.d.ts +2 -2
- package/bin/types/session/SessionOptions.d.ts +14 -9
- package/bin/types/session/SessionOptions.d.ts.map +1 -1
- package/bin/types/session/SessionOrigin.d.ts +19 -0
- package/bin/types/session/SessionOrigin.d.ts.map +1 -0
- package/bin/types/session/SessionOrigin.js +8 -0
- package/bin/types/session/SessionOrigin.js.map +1 -0
- package/bin/types/session/SessionPort.d.ts +16 -20
- package/bin/types/session/SessionPort.d.ts.map +1 -1
- package/bin/types/session/SessionSegment.d.ts +1 -1
- package/bin/types/session/SessionState.d.ts +9 -6
- package/bin/types/session/SessionState.d.ts.map +1 -1
- package/bin/types/session/SessionSystem.d.ts +1 -1
- package/bin/types/session/SessionTool.d.ts +12 -1
- package/bin/types/session/SessionTool.d.ts.map +1 -1
- package/bin/types/store/LocalStore.d.ts +19 -11
- package/bin/types/store/LocalStore.d.ts.map +1 -1
- package/bin/types/store/LocalStore.js +2 -2
- package/bin/types/store/SessionAttachmentStore.d.ts +4 -4
- package/bin/types/store/SessionAttachmentStore.js +3 -3
- package/bin/types/store/SessionDataStore.d.ts +85 -0
- package/bin/types/store/SessionDataStore.d.ts.map +1 -0
- package/bin/types/store/SessionDataStore.js +9 -0
- package/bin/types/store/SessionDataStore.js.map +1 -0
- package/bin/types/store/SessionStore.d.ts +24 -78
- package/bin/types/store/SessionStore.d.ts.map +1 -1
- package/bin/types/store/SessionStore.js +3 -3
- package/bin/types/tools/ToolActionExecutionContext.d.ts +30 -0
- package/bin/types/tools/ToolActionExecutionContext.d.ts.map +1 -0
- package/bin/types/tools/ToolActionExecutionContext.js +8 -0
- package/bin/types/tools/ToolActionExecutionContext.js.map +1 -0
- package/bin/types/tools/ask/AskQuestionsTool.d.ts +1 -1
- package/bin/utils/logger/Logger.d.ts +21 -9
- package/bin/utils/logger/Logger.d.ts.map +1 -1
- package/bin/utils/logger/Logger.js +18 -9
- package/bin/utils/logger/Logger.js.map +1 -1
- package/bin/workspace/WorkspacePaths.d.ts +3 -32
- package/bin/workspace/WorkspacePaths.d.ts.map +1 -1
- package/bin/workspace/WorkspacePaths.js +7 -46
- package/bin/workspace/WorkspacePaths.js.map +1 -1
- package/bin/workspace/store/JsonlSessionMessageStore.d.ts +1 -1
- package/bin/workspace/store/JsonlSessionMessageStore.d.ts.map +1 -1
- package/bin/workspace/store/LocalGroupSessionDataStore.d.ts +46 -0
- package/bin/workspace/store/LocalGroupSessionDataStore.d.ts.map +1 -0
- package/bin/workspace/store/LocalGroupSessionDataStore.js +197 -0
- package/bin/workspace/store/LocalGroupSessionDataStore.js.map +1 -0
- package/bin/workspace/store/LocalGroupSessionStore.d.ts +22 -0
- package/bin/workspace/store/LocalGroupSessionStore.d.ts.map +1 -0
- package/bin/workspace/store/LocalGroupSessionStore.js +75 -0
- package/bin/workspace/store/LocalGroupSessionStore.js.map +1 -0
- package/bin/workspace/store/LocalSessionAttachmentStore.d.ts +2 -2
- package/bin/workspace/store/LocalSessionAttachmentStore.d.ts.map +1 -1
- package/bin/workspace/store/LocalSessionAttachmentStore.js +2 -2
- package/bin/workspace/store/LocalSessionAttachmentStore.js.map +1 -1
- package/bin/workspace/store/LocalSessionDataStore.d.ts +45 -0
- package/bin/workspace/store/LocalSessionDataStore.d.ts.map +1 -0
- package/bin/workspace/store/LocalSessionDataStore.js +100 -0
- package/bin/workspace/store/LocalSessionDataStore.js.map +1 -0
- package/bin/workspace/store/LocalSessionStore.d.ts +38 -28
- package/bin/workspace/store/LocalSessionStore.d.ts.map +1 -1
- package/bin/workspace/store/LocalSessionStore.js +151 -51
- package/bin/workspace/store/LocalSessionStore.js.map +1 -1
- package/bin/workspace/store/LocalStorePaths.d.ts +31 -83
- package/bin/workspace/store/LocalStorePaths.d.ts.map +1 -1
- package/bin/workspace/store/LocalStorePaths.js +43 -101
- package/bin/workspace/store/LocalStorePaths.js.map +1 -1
- package/bin/workspace/store/SessionMessageStoreFactory.d.ts +1 -1
- package/bin/workspace/store/SessionMessageStoreFactory.d.ts.map +1 -1
- package/bin/workspace/store/SessionMessageStoreFactory.js +1 -1
- package/city-test/agent-http.test.mjs +326 -0
- package/city-test/city-container.test.mjs +156 -0
- package/city-test/city-host-registry.test.mjs +68 -0
- package/city-test/city-transport.test.mjs +282 -0
- package/city-test/group.test.mjs +739 -0
- package/city-test/session-model.test.mjs +169 -0
- package/city-test/transport-lifecycle.test.mjs +164 -0
- package/package.json +30 -17
- package/scripts/ModelClientMock.mjs +165 -0
- package/scripts/action-schedule-store.test.mjs +81 -11
- package/scripts/agent-compiler.mjs +10 -6
- package/scripts/agent-env-shell-sandbox.test.mjs +10 -10
- package/scripts/agent-env.test.mjs +6 -8
- package/scripts/agent-multi-workspace.test.mjs +213 -0
- package/scripts/agent-ready.test.mjs +71 -16
- package/scripts/agent-session-maintenance.test.mjs +15 -28
- package/scripts/agent-store.test.mjs +121 -22
- package/scripts/city-model-tool-loop.test.mjs +66 -195
- package/scripts/core-engine-context-compaction.test.mjs +65 -113
- package/scripts/core-engine-model-stream.test.mjs +87 -0
- package/scripts/executor-failure-result.test.mjs +13 -29
- package/scripts/file-tools.test.mjs +6 -6
- package/scripts/image-plugin-job.test.mjs +77 -40
- package/scripts/logger-isolation.test.mjs +2 -2
- package/scripts/multi-agent-plugin-isolation.test.mjs +11 -9
- package/scripts/plugin-tools.test.mjs +153 -18
- package/scripts/public-api-naming.test.mjs +0 -1
- package/scripts/rewrite-build-aliases.mjs +49 -0
- package/scripts/rpc-url-routing.test.mjs +29 -0
- package/scripts/search-tools.test.mjs +4 -4
- package/scripts/session-ask-question.test.mjs +23 -21
- package/scripts/session-attachments.test.mjs +11 -9
- package/scripts/session-compact-handle.test.mjs +6 -5
- package/scripts/session-composer.test.mjs +61 -18
- package/scripts/session-config-turn-boundary.test.mjs +123 -92
- package/scripts/session-dynamic-interaction.test.mjs +75 -0
- package/scripts/session-fork.test.mjs +35 -0
- package/scripts/session-list-title.test.mjs +14 -56
- package/scripts/session-messages.test.mjs +306 -1681
- package/scripts/session-shell-approval.test.mjs +16 -13
- package/scripts/session-system-blocks.test.mjs +1 -1
- package/scripts/session-title-event.test.mjs +38 -24
- package/scripts/session-tool-approval.test.mjs +17 -15
- package/scripts/session-turn-context.test.mjs +31 -28
- package/scripts/session-turn-failure.test.mjs +112 -110
- package/scripts/verify-build-aliases.mjs +32 -0
- package/scripts/workspace.test.mjs +146 -32
- package/src/agent/Agent.ts +138 -238
- package/src/agent/AgentModel.ts +9 -9
- package/src/agent/AgentSessions.ts +116 -65
- package/src/agent/WorkspaceEntry.ts +309 -0
- package/src/agent/index.ts +4 -0
- package/src/city/host/CityHostRegistry.ts +260 -0
- package/src/city/index.ts +49 -0
- package/src/city/runtime/City.ts +425 -0
- package/src/city/transport/SerializedTransport.ts +65 -0
- package/src/city/transport/http/AgentHTTP.ts +176 -0
- package/src/city/transport/http/CityHTTP.ts +196 -0
- package/src/city/transport/http/NodeHttpAdapter.ts +75 -0
- package/src/city/transport/http/routes/RuntimeRoutes.ts +51 -0
- package/src/city/transport/http/routes/SessionRoutes.ts +497 -0
- package/src/city/transport/rpc/AgentRPC.ts +111 -0
- package/src/city/transport/rpc/CityRPC.ts +138 -0
- package/src/city/transport/rpc/RpcServer.ts +158 -0
- package/src/city/transport/rpc/server/InternalHandlers.ts +223 -0
- package/src/city/transport/rpc/server/RequestDispatcher.ts +67 -0
- package/src/city/transport/rpc/server/SdkSessionHandlers.ts +166 -0
- package/src/city/transport/rpc/server/ServerTypes.ts +103 -0
- package/src/city/transport/session/RemoteSessionConfig.ts +34 -0
- package/src/city/transport/types/AgentHttpBinding.ts +25 -0
- package/src/city/transport/types/AgentHttpRuntime.ts +13 -0
- package/src/city/transport/types/AgentRpcBinding.ts +28 -0
- package/src/city/transport/types/AgentRpcRuntime.ts +20 -0
- package/src/city/transport/types/AgentSessionModelResolver.ts +13 -0
- package/src/city/transport/types/CityHttpRuntime.ts +45 -0
- package/src/city/transport/types/CityRpcRuntime.ts +27 -0
- package/src/city/transport/types/RpcProtocol.ts +32 -0
- package/src/city/types/City.ts +99 -0
- package/src/city/types/PluginHostContext.ts +40 -0
- package/src/city/types/SerializedTransport.ts +19 -0
- package/src/executor/Executor.ts +101 -43
- package/src/executor/README.md +11 -8
- package/src/executor/composer/system/SessionSystemComposer.ts +2 -2
- package/src/executor/composer/system/default/PromptRenderer.ts +2 -2
- package/src/executor/composer/system/default/SystemDomain.ts +5 -5
- package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/core.prompt.ts.txt +4 -12
- package/src/executor/core-engine/CoreEngineContextCompaction.ts +113 -427
- package/src/executor/core-engine/CoreEngineError.ts +1 -1
- package/src/executor/core-engine/CoreEngineLoopDecision.ts +1 -18
- package/src/executor/core-engine/CoreEngineMessageState.ts +32 -101
- package/src/executor/core-engine/CoreEngineRunner.ts +179 -281
- package/src/executor/core-engine/CoreEngineSignals.ts +98 -346
- package/src/executor/messages/SessionAttachmentMapper.ts +15 -273
- package/src/executor/messages/SessionMessageLog.ts +12 -25
- package/src/executor/messages/SessionModelMessages.ts +223 -0
- package/src/executor/model/ModelGenerate.ts +71 -0
- package/src/executor/model/ModelStepRunner.ts +381 -0
- package/src/executor/services/ExecutorRecoveryPolicy.ts +4 -4
- package/src/executor/types/SessionHistoryMeta.ts +8 -2
- package/src/executor/types/SessionLoop.ts +0 -26
- package/src/executor/types/SessionPrompts.ts +8 -8
- package/src/group/Group.ts +45 -0
- package/src/group/GroupSession.ts +728 -0
- package/src/group/GroupSessions.ts +104 -0
- package/src/group/index.ts +29 -0
- package/src/index.ts +108 -60
- package/src/internal/AgentRuntime.ts +229 -0
- package/src/internal/GroupRuntime.ts +89 -0
- package/src/internal/index.ts +33 -0
- package/src/plugin/core/ActionScheduleExecutor.ts +17 -5
- package/src/plugin/core/ActionScheduleRuntime.ts +16 -6
- package/src/plugin/core/ActionScheduleStore.ts +43 -12
- package/src/plugin/core/HookRegistry.ts +24 -14
- package/src/plugin/core/PluginActionExecution.ts +230 -0
- package/src/plugin/core/PluginActionFactory.ts +9 -3
- package/src/plugin/core/PluginContext.ts +25 -6
- package/src/plugin/core/PluginHttpRoutes.ts +2 -2
- package/src/plugin/core/PluginRegistry.ts +193 -107
- package/src/plugin/tool/PluginToolRuntime.ts +4 -1
- package/src/plugin/tool/PluginToolSchemas.ts +3 -4
- package/src/plugin/tool/PluginTools.ts +12 -8
- package/src/plugin/types/ActionSchedule.ts +6 -0
- package/src/remote/transports/HttpRemoteAgentTransport.ts +3 -3
- package/src/remote/transports/RpcClient.ts +17 -0
- package/src/remote/transports/RpcRemoteAgentTransport.ts +1 -0
- package/src/session/DefaultSessionComposer.ts +3 -3
- package/src/session/Session.ts +54 -42
- package/src/session/SessionLoop.ts +27 -34
- package/src/session/SessionMessages.ts +63 -121
- package/src/session/SessionState.ts +46 -21
- package/src/session/SessionTitle.ts +23 -40
- package/src/session/browse/Browse.ts +35 -63
- package/src/session/control/SessionInteractions.ts +72 -51
- package/src/session/execution/SessionAssistantOutputAdapter.ts +44 -45
- package/src/session/execution/tools/SessionShellApprovalAdapter.ts +20 -9
- package/src/session/messages/SessionAssistantMessageWriter.ts +259 -637
- package/src/session/messages/SessionJsonValue.ts +0 -23
- package/src/session/messages/SessionMessageCompaction.ts +78 -103
- package/src/session/messages/SessionMessageInteractionWriter.ts +22 -22
- package/src/session/messages/SessionMessageText.ts +73 -0
- package/src/session/preview/SessionMessagePreview.ts +15 -45
- package/src/session/runtime/SessionTurnContext.ts +11 -9
- package/src/session/storage/Metadata.ts +38 -9
- package/src/tools/ask/AskQuestionsTool.ts +28 -17
- package/src/types/action/ActionResult.ts +20 -11
- package/src/types/agent/AgentOptions.ts +6 -13
- package/src/types/agent/AgentSessionCollection.ts +61 -0
- package/src/types/agent/AgentStorage.ts +19 -0
- package/src/types/agent/RemoteAgentOptions.ts +1 -1
- package/src/types/agent/SessionActor.ts +9 -0
- package/src/types/agent/SessionTypes.ts +31 -11
- package/src/types/agent/WorkspaceEntryOptions.ts +18 -0
- package/src/types/executor/SessionAssistantOutput.ts +22 -17
- package/src/types/executor/SessionToolExecutionContext.ts +9 -4
- package/src/types/executor/SessionTurnContext.ts +11 -11
- package/src/types/group/DispatchStrategy.ts +165 -0
- package/src/types/group/Group.ts +64 -0
- package/src/types/group/GroupSession.ts +154 -0
- package/src/types/group/GroupSessionStore.ts +82 -0
- package/src/types/plugin/AgentPluginContext.ts +30 -0
- package/src/types/plugin/PluginAction.ts +7 -5
- package/src/types/plugin/PluginActionExecution.ts +36 -0
- package/src/types/plugin/PluginCommand.ts +5 -5
- package/src/types/plugin/PluginContext.ts +23 -7
- package/src/types/plugin/PluginExecutionContext.ts +6 -11
- package/src/types/plugin/PluginRuntime.ts +5 -0
- package/src/types/plugin/PluginServices.ts +11 -0
- package/src/types/plugin/PluginState.ts +2 -2
- package/src/types/plugin/PluginTool.ts +4 -1
- package/src/types/rpc/RpcProtocol.ts +24 -2
- package/src/types/sdk/AgentSessionAction.ts +8 -9
- package/src/types/sdk/AgentSessionPrompt.ts +8 -11
- package/src/types/session/SessionAction.ts +41 -0
- package/src/types/session/SessionComposer.ts +8 -13
- package/src/types/session/SessionContent.ts +52 -0
- package/src/types/session/SessionExecution.ts +9 -88
- package/src/types/session/SessionInteraction.ts +106 -73
- package/src/types/session/SessionLoop.ts +1 -1
- package/src/types/session/SessionMessage.ts +27 -94
- package/src/types/session/SessionMessages.ts +12 -9
- package/src/types/session/SessionOptions.ts +11 -4
- package/src/types/session/SessionOrigin.ts +21 -0
- package/src/types/session/SessionPort.ts +12 -20
- package/src/types/session/SessionState.ts +7 -4
- package/src/types/session/SessionTool.ts +12 -0
- package/src/types/store/LocalStore.ts +19 -11
- package/src/types/store/SessionAttachmentStore.ts +4 -4
- package/src/types/store/SessionDataStore.ts +109 -0
- package/src/types/store/SessionStore.ts +37 -94
- package/src/types/tools/ToolActionExecutionContext.ts +32 -0
- package/src/utils/logger/Logger.ts +33 -12
- package/src/workspace/WorkspacePaths.ts +7 -51
- package/src/workspace/store/JsonlSessionMessageStore.ts +2 -2
- package/src/workspace/store/LocalGroupSessionDataStore.ts +232 -0
- package/src/workspace/store/LocalGroupSessionStore.ts +90 -0
- package/src/workspace/store/LocalSessionAttachmentStore.ts +3 -3
- package/src/workspace/store/LocalSessionDataStore.ts +169 -0
- package/src/workspace/store/LocalSessionStore.ts +202 -86
- package/src/workspace/store/LocalStorePaths.ts +65 -147
- package/src/workspace/store/SessionMessageStoreFactory.ts +1 -1
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/LICENSE +0 -183
- package/bin/agent/AgentState.d.ts +0 -45
- package/bin/agent/AgentState.d.ts.map +0 -1
- package/bin/agent/AgentState.js +0 -74
- package/bin/agent/AgentState.js.map +0 -1
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts +0 -48
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts.map +0 -1
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.js +0 -92
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.js.map +0 -1
- package/bin/executor/messages/SessionMessageCodec.d.ts +0 -29
- package/bin/executor/messages/SessionMessageCodec.d.ts.map +0 -1
- package/bin/executor/messages/SessionMessageCodec.js +0 -75
- package/bin/executor/messages/SessionMessageCodec.js.map +0 -1
- package/bin/executor/messages/SessionStepEventMapper.d.ts +0 -19
- package/bin/executor/messages/SessionStepEventMapper.d.ts.map +0 -1
- package/bin/executor/messages/SessionStepEventMapper.js +0 -177
- package/bin/executor/messages/SessionStepEventMapper.js.map +0 -1
- package/bin/executor/messages/UIMessageTransformer.d.ts +0 -29
- package/bin/executor/messages/UIMessageTransformer.d.ts.map +0 -1
- package/bin/executor/messages/UIMessageTransformer.js +0 -114
- package/bin/executor/messages/UIMessageTransformer.js.map +0 -1
- package/bin/executor/messages/UserVisibleText.d.ts +0 -26
- package/bin/executor/messages/UserVisibleText.d.ts.map +0 -1
- package/bin/executor/messages/UserVisibleText.js +0 -65
- package/bin/executor/messages/UserVisibleText.js.map +0 -1
- package/bin/executor/types/SessionRecords.d.ts +0 -162
- package/bin/executor/types/SessionRecords.d.ts.map +0 -1
- package/bin/executor/types/SessionRecords.js +0 -51
- package/bin/executor/types/SessionRecords.js.map +0 -1
- package/bin/plugin/core/PluginActionRunner.d.ts +0 -24
- package/bin/plugin/core/PluginActionRunner.d.ts.map +0 -1
- package/bin/plugin/core/PluginActionRunner.js +0 -19
- package/bin/plugin/core/PluginActionRunner.js.map +0 -1
- package/bin/session/messages/SessionMessageCodec.d.ts +0 -23
- package/bin/session/messages/SessionMessageCodec.d.ts.map +0 -1
- package/bin/session/messages/SessionMessageCodec.js +0 -455
- package/bin/session/messages/SessionMessageCodec.js.map +0 -1
- package/bin/types/agent/AgentState.d.ts +0 -19
- package/bin/types/agent/AgentState.d.ts.map +0 -1
- package/bin/types/agent/AgentState.js +0 -9
- package/bin/types/agent/AgentState.js.map +0 -1
- package/bin/types/store/AgentStore.d.ts +0 -31
- package/bin/types/store/AgentStore.d.ts.map +0 -1
- package/bin/types/store/AgentStore.js +0 -9
- package/bin/types/store/AgentStore.js.map +0 -1
- package/bin/types/workspace/FileSystem.d.ts +0 -55
- package/bin/types/workspace/FileSystem.d.ts.map +0 -1
- package/bin/types/workspace/FileSystem.js +0 -9
- package/bin/types/workspace/FileSystem.js.map +0 -1
- package/bin/types/workspace/FileTool.d.ts +0 -181
- package/bin/types/workspace/FileTool.d.ts.map +0 -1
- package/bin/types/workspace/FileTool.js +0 -10
- package/bin/types/workspace/FileTool.js.map +0 -1
- package/bin/types/workspace/SearchTool.d.ts +0 -131
- package/bin/types/workspace/SearchTool.d.ts.map +0 -1
- package/bin/types/workspace/SearchTool.js +0 -10
- package/bin/types/workspace/SearchTool.js.map +0 -1
- package/bin/types/workspace/Workspace.d.ts +0 -24
- package/bin/types/workspace/Workspace.d.ts.map +0 -1
- package/bin/types/workspace/Workspace.js +0 -9
- package/bin/types/workspace/Workspace.js.map +0 -1
- package/bin/types/workspace/WorkspaceEnv.d.ts +0 -16
- package/bin/types/workspace/WorkspaceEnv.d.ts.map +0 -1
- package/bin/types/workspace/WorkspaceEnv.js +0 -9
- package/bin/types/workspace/WorkspaceEnv.js.map +0 -1
- package/bin/types/workspace/WorkspaceTools.d.ts +0 -20
- package/bin/types/workspace/WorkspaceTools.d.ts.map +0 -1
- package/bin/types/workspace/WorkspaceTools.js +0 -9
- package/bin/types/workspace/WorkspaceTools.js.map +0 -1
- package/bin/utils/cli/CliOutput.d.ts +0 -14
- package/bin/utils/cli/CliOutput.d.ts.map +0 -1
- package/bin/utils/cli/CliOutput.js +0 -98
- package/bin/utils/cli/CliOutput.js.map +0 -1
- package/bin/utils/cli/PrettyStatus.d.ts +0 -25
- package/bin/utils/cli/PrettyStatus.d.ts.map +0 -1
- package/bin/utils/cli/PrettyStatus.js +0 -77
- package/bin/utils/cli/PrettyStatus.js.map +0 -1
- package/bin/utils/logger/FormatRequest.d.ts +0 -29
- package/bin/utils/logger/FormatRequest.d.ts.map +0 -1
- package/bin/utils/logger/FormatRequest.js +0 -309
- package/bin/utils/logger/FormatRequest.js.map +0 -1
- package/bin/utils/logger/FormatResponse.d.ts +0 -46
- package/bin/utils/logger/FormatResponse.d.ts.map +0 -1
- package/bin/utils/logger/FormatResponse.js +0 -186
- package/bin/utils/logger/FormatResponse.js.map +0 -1
- package/bin/utils/logger/FormatShared.d.ts +0 -33
- package/bin/utils/logger/FormatShared.d.ts.map +0 -1
- package/bin/utils/logger/FormatShared.js +0 -215
- package/bin/utils/logger/FormatShared.js.map +0 -1
- package/bin/utils/object/DeepMerge.d.ts +0 -18
- package/bin/utils/object/DeepMerge.d.ts.map +0 -1
- package/bin/utils/object/DeepMerge.js +0 -37
- package/bin/utils/object/DeepMerge.js.map +0 -1
- package/bin/utils/object/ObjectGuards.d.ts +0 -17
- package/bin/utils/object/ObjectGuards.d.ts.map +0 -1
- package/bin/utils/object/ObjectGuards.js +0 -19
- package/bin/utils/object/ObjectGuards.js.map +0 -1
- package/bin/utils/path/AncestorFiles.d.ts +0 -17
- package/bin/utils/path/AncestorFiles.d.ts.map +0 -1
- package/bin/utils/path/AncestorFiles.js +0 -36
- package/bin/utils/path/AncestorFiles.js.map +0 -1
- package/bin/utils/storage/index.d.ts +0 -4
- package/bin/utils/storage/index.d.ts.map +0 -1
- package/bin/utils/storage/index.js +0 -17
- package/bin/utils/storage/index.js.map +0 -1
- package/bin/utils/string/EscapeRegExp.d.ts +0 -17
- package/bin/utils/string/EscapeRegExp.d.ts.map +0 -1
- package/bin/utils/string/EscapeRegExp.js +0 -19
- package/bin/utils/string/EscapeRegExp.js.map +0 -1
- package/bin/workspace/LocalFileSystem.d.ts +0 -44
- package/bin/workspace/LocalFileSystem.d.ts.map +0 -1
- package/bin/workspace/LocalFileSystem.js +0 -153
- package/bin/workspace/LocalFileSystem.js.map +0 -1
- package/bin/workspace/Workspace.d.ts +0 -53
- package/bin/workspace/Workspace.d.ts.map +0 -1
- package/bin/workspace/Workspace.js +0 -151
- package/bin/workspace/Workspace.js.map +0 -1
- package/bin/workspace/WorkspaceBase.d.ts +0 -41
- package/bin/workspace/WorkspaceBase.d.ts.map +0 -1
- package/bin/workspace/WorkspaceBase.js +0 -19
- package/bin/workspace/WorkspaceBase.js.map +0 -1
- package/bin/workspace/WorkspaceEnv.d.ts +0 -19
- package/bin/workspace/WorkspaceEnv.d.ts.map +0 -1
- package/bin/workspace/WorkspaceEnv.js +0 -50
- package/bin/workspace/WorkspaceEnv.js.map +0 -1
- package/bin/workspace/file/FileActionRuntime.d.ts +0 -14
- package/bin/workspace/file/FileActionRuntime.d.ts.map +0 -1
- package/bin/workspace/file/FileActionRuntime.js +0 -386
- package/bin/workspace/file/FileActionRuntime.js.map +0 -1
- package/bin/workspace/file/FileAtomicWriter.d.ts +0 -20
- package/bin/workspace/file/FileAtomicWriter.d.ts.map +0 -1
- package/bin/workspace/file/FileAtomicWriter.js +0 -50
- package/bin/workspace/file/FileAtomicWriter.js.map +0 -1
- package/bin/workspace/file/FileEncoding.d.ts +0 -34
- package/bin/workspace/file/FileEncoding.d.ts.map +0 -1
- package/bin/workspace/file/FileEncoding.js +0 -152
- package/bin/workspace/file/FileEncoding.js.map +0 -1
- package/bin/workspace/file/FilePathPolicy.d.ts +0 -26
- package/bin/workspace/file/FilePathPolicy.d.ts.map +0 -1
- package/bin/workspace/file/FilePathPolicy.js +0 -134
- package/bin/workspace/file/FilePathPolicy.js.map +0 -1
- package/bin/workspace/file/FileToolError.d.ts +0 -30
- package/bin/workspace/file/FileToolError.d.ts.map +0 -1
- package/bin/workspace/file/FileToolError.js +0 -78
- package/bin/workspace/file/FileToolError.js.map +0 -1
- package/bin/workspace/search/SearchActionRuntime.d.ts +0 -14
- package/bin/workspace/search/SearchActionRuntime.d.ts.map +0 -1
- package/bin/workspace/search/SearchActionRuntime.js +0 -359
- package/bin/workspace/search/SearchActionRuntime.js.map +0 -1
- package/bin/workspace/search/SearchToolError.d.ts +0 -26
- package/bin/workspace/search/SearchToolError.d.ts.map +0 -1
- package/bin/workspace/search/SearchToolError.js +0 -76
- package/bin/workspace/search/SearchToolError.js.map +0 -1
- package/bin/workspace/store/LocalAgentStore.d.ts +0 -43
- package/bin/workspace/store/LocalAgentStore.d.ts.map +0 -1
- package/bin/workspace/store/LocalAgentStore.js +0 -135
- package/bin/workspace/store/LocalAgentStore.js.map +0 -1
- package/bin/workspace/tool/FileToolSchemas.d.ts +0 -35
- package/bin/workspace/tool/FileToolSchemas.d.ts.map +0 -1
- package/bin/workspace/tool/FileToolSchemas.js +0 -73
- package/bin/workspace/tool/FileToolSchemas.js.map +0 -1
- package/bin/workspace/tool/FileTools.d.ts +0 -11
- package/bin/workspace/tool/FileTools.d.ts.map +0 -1
- package/bin/workspace/tool/FileTools.js +0 -61
- package/bin/workspace/tool/FileTools.js.map +0 -1
- package/bin/workspace/tool/SearchToolSchemas.d.ts +0 -24
- package/bin/workspace/tool/SearchToolSchemas.d.ts.map +0 -1
- package/bin/workspace/tool/SearchToolSchemas.js +0 -60
- package/bin/workspace/tool/SearchToolSchemas.js.map +0 -1
- package/bin/workspace/tool/SearchTools.d.ts +0 -11
- package/bin/workspace/tool/SearchTools.d.ts.map +0 -1
- package/bin/workspace/tool/SearchTools.js +0 -38
- package/bin/workspace/tool/SearchTools.js.map +0 -1
- package/bin/workspace/tool/WorkspaceTools.d.ts +0 -11
- package/bin/workspace/tool/WorkspaceTools.d.ts.map +0 -1
- package/bin/workspace/tool/WorkspaceTools.js +0 -22
- package/bin/workspace/tool/WorkspaceTools.js.map +0 -1
- package/scripts/core-engine-ui-stream-collector.test.mjs +0 -38
- package/scripts/openai-responses-continuation.test.mjs +0 -78
- package/src/agent/AgentState.ts +0 -96
- package/src/executor/core-engine/CoreEngineUiStreamCollector.ts +0 -136
- package/src/executor/messages/SessionMessageCodec.ts +0 -106
- package/src/executor/messages/SessionStepEventMapper.ts +0 -191
- package/src/executor/messages/UIMessageTransformer.ts +0 -152
- package/src/executor/messages/UserVisibleText.ts +0 -75
- package/src/executor/types/SessionRecords.ts +0 -217
- package/src/plugin/core/PluginActionRunner.ts +0 -36
- package/src/session/messages/SessionMessageCodec.ts +0 -495
- package/src/types/agent/AgentState.ts +0 -22
- package/src/types/store/AgentStore.ts +0 -52
- package/src/types/workspace/FileSystem.ts +0 -76
- package/src/types/workspace/FileTool.ts +0 -225
- package/src/types/workspace/SearchTool.ts +0 -156
- package/src/types/workspace/Workspace.ts +0 -27
- package/src/types/workspace/WorkspaceEnv.ts +0 -19
- package/src/types/workspace/WorkspaceTools.ts +0 -23
- package/src/utils/cli/CliOutput.ts +0 -128
- package/src/utils/cli/PrettyStatus.ts +0 -94
- package/src/utils/logger/FormatRequest.ts +0 -455
- package/src/utils/logger/FormatResponse.ts +0 -265
- package/src/utils/logger/FormatShared.ts +0 -258
- package/src/utils/object/DeepMerge.ts +0 -40
- package/src/utils/object/ObjectGuards.ts +0 -19
- package/src/utils/path/AncestorFiles.ts +0 -40
- package/src/utils/storage/index.ts +0 -19
- package/src/utils/string/EscapeRegExp.ts +0 -19
- package/src/workspace/LocalFileSystem.ts +0 -209
- package/src/workspace/Workspace.ts +0 -178
- package/src/workspace/WorkspaceBase.ts +0 -62
- package/src/workspace/WorkspaceEnv.ts +0 -54
- package/src/workspace/file/FileActionRuntime.ts +0 -433
- package/src/workspace/file/FileAtomicWriter.ts +0 -61
- package/src/workspace/file/FileEncoding.ts +0 -175
- package/src/workspace/file/FilePathPolicy.ts +0 -162
- package/src/workspace/file/FileToolError.ts +0 -99
- package/src/workspace/search/SearchActionRuntime.ts +0 -438
- package/src/workspace/search/SearchToolError.ts +0 -94
- package/src/workspace/store/LocalAgentStore.ts +0 -191
- package/src/workspace/tool/FileToolSchemas.ts +0 -77
- package/src/workspace/tool/FileTools.ts +0 -91
- package/src/workspace/tool/SearchToolSchemas.ts +0 -62
- package/src/workspace/tool/SearchTools.ts +0 -61
- package/src/workspace/tool/WorkspaceTools.ts +0 -31
|
@@ -7,30 +7,18 @@
|
|
|
7
7
|
* - 保持失败返回结构稳定,避免对外 Session 行为变化。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
type FileUIPart,
|
|
13
|
-
type LanguageModel,
|
|
14
|
-
type ModelMessage,
|
|
15
|
-
type StepResult,
|
|
16
|
-
type Tool,
|
|
17
|
-
type ToolApprovalRequestOutput,
|
|
18
|
-
type ToolApprovalResponse,
|
|
19
|
-
type UIMessage,
|
|
20
|
-
} from "ai";
|
|
10
|
+
import type { ModelClient, ModelMessage } from "@downcity/type";
|
|
11
|
+
import type { RuntimeTool as Tool } from "@downcity/type";
|
|
21
12
|
import { log_assistant_message_now } from "@executor/messages/SessionMessageLog.js";
|
|
22
|
-
import { pick_last_successful_chat_send_text } from "@executor/messages/UserVisibleText.js";
|
|
23
13
|
import {
|
|
24
14
|
MAX_INCOMPLETE_RESPONSE_RECOVERIES,
|
|
25
|
-
MAX_TEXT_ONLY_CONTINUATIONS,
|
|
26
15
|
MAX_TOOL_LOOP_STEPS,
|
|
27
16
|
build_incomplete_response_recovery_nudge,
|
|
28
|
-
build_text_only_continuation_nudge,
|
|
29
17
|
detect_incomplete_response,
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
extract_assistant_text,
|
|
19
|
+
merge_assistant_parts,
|
|
20
|
+
summarize_assistant_parts_for_debug,
|
|
32
21
|
summarize_step_for_debug,
|
|
33
|
-
summarize_ui_message_for_debug,
|
|
34
22
|
to_inline_preview,
|
|
35
23
|
} from "@executor/core-engine/CoreEngineSignals.js";
|
|
36
24
|
import {
|
|
@@ -41,7 +29,11 @@ import {
|
|
|
41
29
|
resolve_effective_core_engine_error,
|
|
42
30
|
summarize_stream_error,
|
|
43
31
|
} from "@executor/core-engine/CoreEngineError.js";
|
|
44
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
run_model_step,
|
|
34
|
+
type ModelStepResult,
|
|
35
|
+
type ModelStepToolCall,
|
|
36
|
+
} from "@executor/model/ModelStepRunner.js";
|
|
45
37
|
import { CoreEngineMessageState } from "@executor/core-engine/CoreEngineMessageState.js";
|
|
46
38
|
import {
|
|
47
39
|
deep_compact_model_messages,
|
|
@@ -56,57 +48,17 @@ import type {
|
|
|
56
48
|
SessionStepExecutionInput,
|
|
57
49
|
SessionTurnExecutionResult,
|
|
58
50
|
} from "@/types/session/SessionExecution.js";
|
|
51
|
+
import type { SessionAssistantResultPart } from "@/types/session/SessionContent.js";
|
|
59
52
|
import type {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} from "@/
|
|
53
|
+
SessionAssistantMessagePart,
|
|
54
|
+
SessionUserMessage,
|
|
55
|
+
} from "@/types/session/SessionMessage.js";
|
|
63
56
|
|
|
64
57
|
const TURN_STOPPED_MESSAGE = "Turn stopped";
|
|
65
58
|
|
|
66
59
|
/** Provider context-length error 在当前 step 内最多压缩重试三次。 */
|
|
67
60
|
const MAX_CONTEXT_ERROR_COMPACTION_RETRIES = 3;
|
|
68
61
|
|
|
69
|
-
/**
|
|
70
|
-
* 生成 file part 去重 key。
|
|
71
|
-
*/
|
|
72
|
-
function build_file_part_key(part: FileUIPart): string {
|
|
73
|
-
return [
|
|
74
|
-
String(part.type || ""),
|
|
75
|
-
String(part.mediaType || ""),
|
|
76
|
-
String(part.filename || ""),
|
|
77
|
-
String(part.url || ""),
|
|
78
|
-
].join("\n");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 把 tool/plugin 运行期产生的 file parts 并入最终 assistant UIMessage。
|
|
83
|
-
*/
|
|
84
|
-
function merge_assistant_parts(
|
|
85
|
-
message: SessionMessageRecordV1,
|
|
86
|
-
parts: UIMessage["parts"],
|
|
87
|
-
): SessionMessageRecordV1 {
|
|
88
|
-
if (!Array.isArray(parts) || parts.length === 0) return message;
|
|
89
|
-
const current_parts = Array.isArray(message.parts) ? message.parts : [];
|
|
90
|
-
const seen = new Set<string>();
|
|
91
|
-
for (const part of current_parts) {
|
|
92
|
-
const candidate = part as UIMessage["parts"][number];
|
|
93
|
-
if (candidate?.type !== "file") continue;
|
|
94
|
-
seen.add(build_file_part_key(candidate as FileUIPart));
|
|
95
|
-
}
|
|
96
|
-
const next_parts = parts.filter((part) => {
|
|
97
|
-
if (part.type !== "file") return true;
|
|
98
|
-
const key = build_file_part_key(part as FileUIPart);
|
|
99
|
-
if (seen.has(key)) return false;
|
|
100
|
-
seen.add(key);
|
|
101
|
-
return true;
|
|
102
|
-
});
|
|
103
|
-
if (next_parts.length === 0) return message;
|
|
104
|
-
return {
|
|
105
|
-
...message,
|
|
106
|
-
parts: [...current_parts, ...next_parts],
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
62
|
interface CoreEngineRunnerOptions {
|
|
111
63
|
/** 当前 Session 稳定标识。 */
|
|
112
64
|
session_id: string;
|
|
@@ -131,7 +83,7 @@ interface CoreEngineTurnInput {
|
|
|
131
83
|
/**
|
|
132
84
|
* 当前轮模型实例。
|
|
133
85
|
*/
|
|
134
|
-
model:
|
|
86
|
+
model: ModelClient;
|
|
135
87
|
|
|
136
88
|
/**
|
|
137
89
|
* 当前显式运行上下文。
|
|
@@ -143,7 +95,7 @@ interface CoreEngineTurnInput {
|
|
|
143
95
|
*/
|
|
144
96
|
resolve_step_inputs: () => Promise<{
|
|
145
97
|
/** 当前 Session step 使用的模型。 */
|
|
146
|
-
model:
|
|
98
|
+
model: ModelClient;
|
|
147
99
|
/** 当前 Session step 使用的 system messages。 */
|
|
148
100
|
system: SessionStepExecutionInput["system"];
|
|
149
101
|
/** 当前 Session step 使用的工具集合。 */
|
|
@@ -152,8 +104,13 @@ interface CoreEngineTurnInput {
|
|
|
152
104
|
context_window?: number;
|
|
153
105
|
}>;
|
|
154
106
|
|
|
155
|
-
/** 持久化 compact 后重新读取 Composer
|
|
156
|
-
reload_history: () => Promise<
|
|
107
|
+
/** 持久化 compact 后重新读取 Composer 生成的模型历史与 Summary 身份。 */
|
|
108
|
+
reload_history: () => Promise<{
|
|
109
|
+
/** Composer 重新生成的标准模型消息。 */
|
|
110
|
+
messages: ModelMessage[];
|
|
111
|
+
/** 当前模型历史包含的最新持久化 Summary 标识。 */
|
|
112
|
+
summary_id?: string;
|
|
113
|
+
}>;
|
|
157
114
|
}
|
|
158
115
|
|
|
159
116
|
/**
|
|
@@ -187,28 +144,25 @@ export class CoreEngineRunner {
|
|
|
187
144
|
: [];
|
|
188
145
|
let tools = input.execute_input.tools;
|
|
189
146
|
let last_observed_stream_error: unknown = undefined;
|
|
190
|
-
|
|
191
|
-
let ui_stream_continuation_message: SessionMessageRecordV1 | null = null;
|
|
147
|
+
let final_assistant_parts: SessionAssistantMessagePart[] = [];
|
|
192
148
|
let compact_required = false;
|
|
193
149
|
|
|
194
150
|
try {
|
|
195
151
|
const message_state = await CoreEngineMessageState.create({
|
|
196
152
|
messages: input.execute_input.messages,
|
|
197
|
-
tools,
|
|
198
153
|
project_root: input.turn_context.session.project_root,
|
|
199
154
|
});
|
|
200
|
-
let persisted_compaction_summary_id =
|
|
201
|
-
input.execute_input.
|
|
202
|
-
);
|
|
155
|
+
let persisted_compaction_summary_id =
|
|
156
|
+
input.execute_input.history_summary_id || "";
|
|
203
157
|
|
|
204
|
-
const append_merged_user_messages = (messages:
|
|
205
|
-
message_state.
|
|
158
|
+
const append_merged_user_messages = (messages: SessionUserMessage[]) =>
|
|
159
|
+
message_state.append_merged_user_messages(messages);
|
|
206
160
|
|
|
207
161
|
let step_count = 0;
|
|
208
162
|
let total_tool_call_count = 0;
|
|
209
163
|
let total_tool_result_count = 0;
|
|
210
164
|
const on_step_finish = async (
|
|
211
|
-
step_result:
|
|
165
|
+
step_result: ModelStepResult,
|
|
212
166
|
): Promise<void> => {
|
|
213
167
|
step_count += 1;
|
|
214
168
|
const summary = summarize_step_for_debug(step_result);
|
|
@@ -225,7 +179,6 @@ export class CoreEngineRunner {
|
|
|
225
179
|
});
|
|
226
180
|
};
|
|
227
181
|
|
|
228
|
-
let text_only_continuation_count = 0;
|
|
229
182
|
let incomplete_response_recovery_count = 0;
|
|
230
183
|
let context_error_compaction_retries = 0;
|
|
231
184
|
let compact_pending = false;
|
|
@@ -246,11 +199,9 @@ export class CoreEngineRunner {
|
|
|
246
199
|
system = Array.isArray(step_inputs.system) ? step_inputs.system : [];
|
|
247
200
|
tools = step_inputs.tools;
|
|
248
201
|
if (input.turn_context.input.consume_history_reload()) {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
persisted_compaction_summary_id =
|
|
252
|
-
canonical_records,
|
|
253
|
-
);
|
|
202
|
+
const reloaded_history = await input.reload_history();
|
|
203
|
+
message_state.replace_model_history(reloaded_history.messages);
|
|
204
|
+
persisted_compaction_summary_id = reloaded_history.summary_id || "";
|
|
254
205
|
compact_validation_pending = Boolean(
|
|
255
206
|
persisted_compaction_summary_id &&
|
|
256
207
|
persisted_compaction_summary_id !==
|
|
@@ -258,15 +209,15 @@ export class CoreEngineRunner {
|
|
|
258
209
|
);
|
|
259
210
|
await this.logger.log("info", "[agent] context.history_reloaded", {
|
|
260
211
|
session_id: session_id,
|
|
261
|
-
recordCount:
|
|
212
|
+
recordCount: reloaded_history.messages.length,
|
|
262
213
|
compactionSummaryId: persisted_compaction_summary_id || undefined,
|
|
263
214
|
});
|
|
264
215
|
}
|
|
265
216
|
if (compact_pending) {
|
|
266
|
-
const previous_message_count = message_state.
|
|
217
|
+
const previous_message_count = message_state.model_messages.length;
|
|
267
218
|
message_state.replace_model_messages(
|
|
268
219
|
deep_compact_model_messages(
|
|
269
|
-
message_state.
|
|
220
|
+
message_state.model_messages,
|
|
270
221
|
compact_depth,
|
|
271
222
|
),
|
|
272
223
|
);
|
|
@@ -279,14 +230,13 @@ export class CoreEngineRunner {
|
|
|
279
230
|
reason: "usage_threshold",
|
|
280
231
|
compactDepth: compact_depth,
|
|
281
232
|
previousMessageCount: previous_message_count,
|
|
282
|
-
nextMessageCount: message_state.
|
|
233
|
+
nextMessageCount: message_state.model_messages.length,
|
|
283
234
|
});
|
|
284
235
|
}
|
|
285
236
|
|
|
286
237
|
last_observed_stream_error = undefined;
|
|
287
|
-
let
|
|
288
|
-
let executed_steps:
|
|
289
|
-
const observed_steps: StepResult<Record<string, Tool>>[] = [];
|
|
238
|
+
let step_assistant_parts: SessionAssistantMessagePart[];
|
|
239
|
+
let executed_steps: ModelStepResult[];
|
|
290
240
|
let canonical_step_started = false;
|
|
291
241
|
let canonical_step_finished = false;
|
|
292
242
|
try {
|
|
@@ -294,71 +244,47 @@ export class CoreEngineRunner {
|
|
|
294
244
|
await input.turn_context.output.assistant.begin_step();
|
|
295
245
|
canonical_step_started = true;
|
|
296
246
|
}
|
|
297
|
-
const result =
|
|
247
|
+
const result = await run_model_step({
|
|
298
248
|
model: step_inputs.model,
|
|
299
249
|
system,
|
|
300
|
-
|
|
301
|
-
observed_steps.push(step_result);
|
|
302
|
-
await on_step_finish(step_result);
|
|
303
|
-
},
|
|
304
|
-
messages: message_state.modelMessages,
|
|
250
|
+
messages: message_state.model_messages,
|
|
305
251
|
tools,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
252
|
+
abort_signal: input.turn_context.lifecycle.abort_signal,
|
|
253
|
+
...(input.turn_context.output.assistant
|
|
254
|
+
? { assistant_output: input.turn_context.output.assistant }
|
|
255
|
+
: {}),
|
|
256
|
+
approve_tool: async (call, tool) => await resolve_tool_approval({
|
|
257
|
+
call,
|
|
258
|
+
tool,
|
|
259
|
+
turn_context: input.turn_context,
|
|
260
|
+
}),
|
|
314
261
|
});
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
await collect_final_assistant_message_from_ui_stream({
|
|
318
|
-
result,
|
|
319
|
-
session_id: session_id,
|
|
320
|
-
original_messages: ui_stream_continuation_message
|
|
321
|
-
? [ui_stream_continuation_message]
|
|
322
|
-
: undefined,
|
|
323
|
-
logger: this.logger,
|
|
324
|
-
buildFallbackAssistantMessage: (text) =>
|
|
325
|
-
build_fallback_assistant_message(session_id, text),
|
|
326
|
-
on_ui_message_chunk_callback: input.turn_context.output.assistant
|
|
327
|
-
? async (chunk) => {
|
|
328
|
-
await input.turn_context.output.assistant?.write_chunk(chunk);
|
|
329
|
-
}
|
|
330
|
-
: undefined,
|
|
331
|
-
abort_signal: input.turn_context.lifecycle.abort_signal,
|
|
332
|
-
});
|
|
262
|
+
step_assistant_parts = result.assistant_parts;
|
|
263
|
+
await on_step_finish(result.step_result);
|
|
333
264
|
|
|
334
265
|
if (input.turn_context.output.assistant) {
|
|
335
266
|
await input.turn_context.output.assistant.finish_step(
|
|
336
|
-
|
|
267
|
+
step_assistant_parts,
|
|
337
268
|
);
|
|
338
269
|
}
|
|
339
270
|
const action_assistant_parts =
|
|
340
271
|
input.turn_context.output.take_assistant_parts();
|
|
341
272
|
if (action_assistant_parts.length > 0) {
|
|
342
|
-
await input.turn_context.output.assistant?.
|
|
273
|
+
await input.turn_context.output.assistant?.append_result_parts(
|
|
343
274
|
action_assistant_parts,
|
|
344
275
|
);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
action_assistant_parts,
|
|
276
|
+
step_assistant_parts = merge_assistant_parts(
|
|
277
|
+
step_assistant_parts,
|
|
278
|
+
action_parts_to_canonical(action_assistant_parts),
|
|
348
279
|
);
|
|
349
280
|
}
|
|
350
281
|
canonical_step_finished = true;
|
|
351
282
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
283
|
+
final_assistant_parts = merge_assistant_parts(
|
|
284
|
+
final_assistant_parts,
|
|
285
|
+
step_assistant_parts,
|
|
355
286
|
);
|
|
356
|
-
|
|
357
|
-
// 关键点(中文):先保存本 step 已收敛的 assistant 消息,再等待 Provider 终态。
|
|
358
|
-
// stop / error 时已经生成的部分内容仍会保留,但 `result.steps` 必须作为错误传播边界。
|
|
359
|
-
message_state.appendRuntimeSessionMessage(step_assistant_ui_message);
|
|
360
|
-
executed_steps = await result.steps;
|
|
361
|
-
ui_stream_continuation_message = null;
|
|
287
|
+
executed_steps = [result.step_result];
|
|
362
288
|
} catch (error) {
|
|
363
289
|
if (
|
|
364
290
|
canonical_step_started &&
|
|
@@ -376,10 +302,10 @@ export class CoreEngineRunner {
|
|
|
376
302
|
MAX_CONTEXT_ERROR_COMPACTION_RETRIES
|
|
377
303
|
) {
|
|
378
304
|
context_error_compaction_retries += 1;
|
|
379
|
-
const previous_message_count = message_state.
|
|
305
|
+
const previous_message_count = message_state.model_messages.length;
|
|
380
306
|
message_state.replace_model_messages(
|
|
381
307
|
deep_compact_model_messages(
|
|
382
|
-
message_state.
|
|
308
|
+
message_state.model_messages,
|
|
383
309
|
compact_depth,
|
|
384
310
|
),
|
|
385
311
|
);
|
|
@@ -393,7 +319,7 @@ export class CoreEngineRunner {
|
|
|
393
319
|
retryCount: context_error_compaction_retries,
|
|
394
320
|
compactDepth: compact_depth,
|
|
395
321
|
previousMessageCount: previous_message_count,
|
|
396
|
-
nextMessageCount: message_state.
|
|
322
|
+
nextMessageCount: message_state.model_messages.length,
|
|
397
323
|
...summarize_stream_error(compact_error),
|
|
398
324
|
});
|
|
399
325
|
continue;
|
|
@@ -433,36 +359,27 @@ export class CoreEngineRunner {
|
|
|
433
359
|
|
|
434
360
|
const incomplete_response = detect_incomplete_response({
|
|
435
361
|
step_result: last_step,
|
|
436
|
-
|
|
362
|
+
assistant_parts: step_assistant_parts,
|
|
437
363
|
});
|
|
438
|
-
const text_only_continuation_reason =
|
|
439
|
-
detect_text_only_continuation_reason(last_step);
|
|
440
364
|
const loop_decision = evaluate_core_engine_loop_decision({
|
|
441
365
|
hasIncompleteResponse: incomplete_response !== null,
|
|
442
366
|
incompleteRecoveryCount: incomplete_response_recovery_count,
|
|
443
367
|
maxIncompleteRecoveries: MAX_INCOMPLETE_RESPONSE_RECOVERIES,
|
|
444
|
-
|
|
445
|
-
textOnlyContinuationCount: text_only_continuation_count,
|
|
446
|
-
maxTextOnlyContinuations: MAX_TEXT_ONLY_CONTINUATIONS,
|
|
447
|
-
hasTools: Object.keys(tools).length > 0,
|
|
448
|
-
toolCallCount: last_step.toolCalls.length,
|
|
368
|
+
toolCallCount: last_step.tool_calls.length,
|
|
449
369
|
});
|
|
450
370
|
|
|
451
371
|
await this.logger.log("info", "[agent] loop.decision", {
|
|
452
372
|
session_id: session_id,
|
|
453
373
|
step_index: step_count,
|
|
454
374
|
continueForToolCalls: loop_decision.continueForToolCalls,
|
|
455
|
-
continueForTextOnly: loop_decision.continueForTextOnly,
|
|
456
375
|
continueForIncompleteRecovery:
|
|
457
376
|
loop_decision.continueForIncompleteRecovery,
|
|
458
377
|
decisionKind: loop_decision.kind,
|
|
459
|
-
textOnlyContinuationReason: text_only_continuation_reason,
|
|
460
|
-
textOnlyContinuationCount: text_only_continuation_count,
|
|
461
378
|
incompleteResponseReason: incomplete_response?.reason ?? null,
|
|
462
379
|
incompleteResponseRecoveryCount: incomplete_response_recovery_count,
|
|
463
|
-
toolCallCount: last_step.
|
|
464
|
-
toolResultCount: last_step.
|
|
465
|
-
finishReason: last_step.
|
|
380
|
+
toolCallCount: last_step.tool_calls.length,
|
|
381
|
+
toolResultCount: last_step.tool_results.length,
|
|
382
|
+
finishReason: last_step.finish_reason,
|
|
466
383
|
textPreview: to_inline_preview(last_step.text),
|
|
467
384
|
});
|
|
468
385
|
|
|
@@ -489,7 +406,7 @@ export class CoreEngineRunner {
|
|
|
489
406
|
step_index: step_count,
|
|
490
407
|
},
|
|
491
408
|
});
|
|
492
|
-
await message_state.
|
|
409
|
+
await message_state.append_user_message(recovery_message);
|
|
493
410
|
continue;
|
|
494
411
|
}
|
|
495
412
|
|
|
@@ -509,42 +426,13 @@ export class CoreEngineRunner {
|
|
|
509
426
|
const response_messages = Array.isArray(last_step.response?.messages)
|
|
510
427
|
? last_step.response.messages
|
|
511
428
|
: [];
|
|
512
|
-
|
|
513
|
-
step: last_step,
|
|
514
|
-
tools,
|
|
515
|
-
turn_context: input.turn_context,
|
|
516
|
-
});
|
|
517
|
-
message_state.appendModelMessages(response_messages);
|
|
518
|
-
if (approval_responses.length > 0) {
|
|
519
|
-
message_state.appendModelMessages([
|
|
520
|
-
{ role: "tool", content: approval_responses } as ModelMessage,
|
|
521
|
-
]);
|
|
522
|
-
// 原生审批的下一次 streamText 会先恢复上一条 Tool Part,再继续模型输出。
|
|
523
|
-
ui_stream_continuation_message = final_assistant_ui_message;
|
|
524
|
-
}
|
|
429
|
+
message_state.append_model_messages(response_messages);
|
|
525
430
|
|
|
526
431
|
if (loop_decision.continueForToolCalls) {
|
|
527
|
-
text_only_continuation_count = 0;
|
|
528
432
|
incomplete_response_recovery_count = 0;
|
|
529
433
|
continue;
|
|
530
434
|
}
|
|
531
435
|
|
|
532
|
-
if (loop_decision.continueForTextOnly) {
|
|
533
|
-
text_only_continuation_count += 1;
|
|
534
|
-
incomplete_response_recovery_count = 0;
|
|
535
|
-
const continuation_message = build_internal_user_message({
|
|
536
|
-
session_id,
|
|
537
|
-
text: build_text_only_continuation_nudge(text_only_continuation_count),
|
|
538
|
-
extra: {
|
|
539
|
-
internal: "agent_loop_auto_continue",
|
|
540
|
-
reason: text_only_continuation_reason,
|
|
541
|
-
step_index: step_count,
|
|
542
|
-
},
|
|
543
|
-
});
|
|
544
|
-
await message_state.appendUserTextMessage(continuation_message);
|
|
545
|
-
continue;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
436
|
// 关键点(中文):stop 前做 tail merge,覆盖最后一个 step 后才入队的新 user 消息。
|
|
549
437
|
const tail_merged_message_count = input.turn_context.input.has_pending()
|
|
550
438
|
? 1
|
|
@@ -554,7 +442,6 @@ export class CoreEngineRunner {
|
|
|
554
442
|
mergedUserMessageCount: tail_merged_message_count,
|
|
555
443
|
})
|
|
556
444
|
) {
|
|
557
|
-
text_only_continuation_count = 0;
|
|
558
445
|
incomplete_response_recovery_count = 0;
|
|
559
446
|
await this.logger.log("info", "[agent] loop.tail_merge_continue", {
|
|
560
447
|
session_id: session_id,
|
|
@@ -576,14 +463,15 @@ export class CoreEngineRunner {
|
|
|
576
463
|
});
|
|
577
464
|
}
|
|
578
465
|
|
|
579
|
-
const
|
|
580
|
-
|
|
466
|
+
const final_parts = final_assistant_parts.length > 0
|
|
467
|
+
? final_assistant_parts
|
|
468
|
+
: build_fallback_assistant_parts("Execution completed");
|
|
581
469
|
|
|
582
470
|
await this.logger.log("info", "[agent] final.message", {
|
|
583
471
|
session_id: session_id,
|
|
584
|
-
...
|
|
472
|
+
...summarize_assistant_parts_for_debug(final_parts),
|
|
585
473
|
});
|
|
586
|
-
await log_assistant_message_now(this.logger,
|
|
474
|
+
await log_assistant_message_now(this.logger, final_parts);
|
|
587
475
|
|
|
588
476
|
const duration = Date.now() - start_time;
|
|
589
477
|
await this.logger.log("info", "[agent] finish", {
|
|
@@ -596,7 +484,7 @@ export class CoreEngineRunner {
|
|
|
596
484
|
|
|
597
485
|
return {
|
|
598
486
|
success: true,
|
|
599
|
-
text:
|
|
487
|
+
text: extract_assistant_text(final_parts),
|
|
600
488
|
...(compact_required ? { compact_required: true } : {}),
|
|
601
489
|
deferred_persisted_user_messages: [
|
|
602
490
|
...input.turn_context.input.deferred_user_messages(),
|
|
@@ -608,12 +496,9 @@ export class CoreEngineRunner {
|
|
|
608
496
|
await this.logger.log("info", "[agent] stopped", {
|
|
609
497
|
session_id: session_id,
|
|
610
498
|
});
|
|
611
|
-
const stopped_message = final_assistant_ui_message;
|
|
612
499
|
return {
|
|
613
500
|
success: false,
|
|
614
|
-
text:
|
|
615
|
-
? pick_last_successful_chat_send_text(stopped_message)
|
|
616
|
-
: "",
|
|
501
|
+
text: extract_assistant_text(final_assistant_parts),
|
|
617
502
|
error: error_text,
|
|
618
503
|
...(compact_required ? { compact_required: true } : {}),
|
|
619
504
|
deferred_persisted_user_messages: [
|
|
@@ -637,9 +522,7 @@ export class CoreEngineRunner {
|
|
|
637
522
|
|
|
638
523
|
return {
|
|
639
524
|
success: false,
|
|
640
|
-
text:
|
|
641
|
-
? pick_last_successful_chat_send_text(final_assistant_ui_message)
|
|
642
|
-
: "",
|
|
525
|
+
text: extract_assistant_text(final_assistant_parts),
|
|
643
526
|
error: error_text,
|
|
644
527
|
...(compact_required ? { compact_required: true } : {}),
|
|
645
528
|
deferred_persisted_user_messages: [
|
|
@@ -650,55 +533,49 @@ export class CoreEngineRunner {
|
|
|
650
533
|
}
|
|
651
534
|
}
|
|
652
535
|
|
|
653
|
-
/**
|
|
654
|
-
async function
|
|
655
|
-
|
|
656
|
-
|
|
536
|
+
/** 在工具执行前接入 Session canonical Interaction 生命周期。 */
|
|
537
|
+
async function resolve_tool_approval(input: {
|
|
538
|
+
call: ModelStepToolCall;
|
|
539
|
+
tool: Tool;
|
|
657
540
|
turn_context: SessionTurnContext;
|
|
658
|
-
}): Promise<
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
541
|
+
}): Promise<boolean> {
|
|
542
|
+
const needs_approval = input.tool.needs_approval;
|
|
543
|
+
const required = typeof needs_approval === "function"
|
|
544
|
+
? await needs_approval(input.call.input as never, {
|
|
545
|
+
tool_call_id: input.call.tool_call_id,
|
|
546
|
+
messages: [],
|
|
547
|
+
})
|
|
548
|
+
: needs_approval === true;
|
|
549
|
+
if (!required) return true;
|
|
664
550
|
const interactions = input.turn_context.interactions;
|
|
665
551
|
if (!interactions) {
|
|
666
552
|
throw new Error("Tool approval requires a Session Interaction port");
|
|
667
553
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
result.response.kind === "approval" &&
|
|
694
|
-
result.response.decision === "approved";
|
|
695
|
-
return {
|
|
696
|
-
type: "tool-approval-response",
|
|
697
|
-
approvalId: request.approvalId,
|
|
698
|
-
approved,
|
|
699
|
-
};
|
|
700
|
-
}),
|
|
701
|
-
);
|
|
554
|
+
const approval_id = `approval:${input.call.tool_call_id}`;
|
|
555
|
+
const handle = await interactions.request({
|
|
556
|
+
interaction_id: `interaction:tool-approval:${approval_id}`,
|
|
557
|
+
turn_id: input.turn_context.session.turn_id,
|
|
558
|
+
type: "approval",
|
|
559
|
+
source: {
|
|
560
|
+
type: "tool",
|
|
561
|
+
tool_call_id: input.call.tool_call_id,
|
|
562
|
+
tool_name: input.call.tool_name,
|
|
563
|
+
},
|
|
564
|
+
payload: {
|
|
565
|
+
operation: "tool",
|
|
566
|
+
validated_input: to_session_json_value(input.call.input),
|
|
567
|
+
...(input.tool.description ? { tool_description: input.tool.description } : {}),
|
|
568
|
+
},
|
|
569
|
+
created_at: Date.now(),
|
|
570
|
+
});
|
|
571
|
+
const result = await handle.result;
|
|
572
|
+
const payload = result.status === "resolved" && result.response.type === "approval"
|
|
573
|
+
? result.response.payload as { decision?: unknown }
|
|
574
|
+
: undefined;
|
|
575
|
+
return result.status === "resolved" &&
|
|
576
|
+
result.response.type === "approval" &&
|
|
577
|
+
result.response.outcome === "resolved" &&
|
|
578
|
+
payload?.decision === "approved";
|
|
702
579
|
}
|
|
703
580
|
|
|
704
581
|
/** 构造仅在当前 Turn 内使用的内部 User Message。 */
|
|
@@ -706,52 +583,73 @@ function build_internal_user_message(input: {
|
|
|
706
583
|
session_id: string;
|
|
707
584
|
text: string;
|
|
708
585
|
extra: JsonObject;
|
|
709
|
-
}):
|
|
586
|
+
}): SessionUserMessage {
|
|
587
|
+
void input.extra;
|
|
588
|
+
const now = Date.now();
|
|
710
589
|
return {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
590
|
+
message_id: `runtime-user:${input.session_id}:${now}`,
|
|
591
|
+
session_id: input.session_id,
|
|
592
|
+
sequence: 0,
|
|
593
|
+
revision: 1,
|
|
594
|
+
visibility: "internal",
|
|
595
|
+
created_at: now,
|
|
596
|
+
updated_at: now,
|
|
597
|
+
type: "user",
|
|
598
|
+
input_type: "steer",
|
|
599
|
+
parts: [{
|
|
600
|
+
part_id: "runtime-text:1",
|
|
601
|
+
type: "text",
|
|
602
|
+
text: input.text,
|
|
603
|
+
state: "done",
|
|
604
|
+
}],
|
|
722
605
|
};
|
|
723
606
|
}
|
|
724
607
|
|
|
725
|
-
/**
|
|
726
|
-
function
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
)
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
608
|
+
/** 把 Action 结果内容转换为当前 Turn 使用的 canonical Assistant Parts。 */
|
|
609
|
+
function action_parts_to_canonical(
|
|
610
|
+
parts: readonly SessionAssistantResultPart[],
|
|
611
|
+
): SessionAssistantMessagePart[] {
|
|
612
|
+
return parts.map((part, index) => {
|
|
613
|
+
const sequence = index + 1;
|
|
614
|
+
if (part.type === "text") {
|
|
615
|
+
return {
|
|
616
|
+
part_id: `action-text:${sequence}`,
|
|
617
|
+
sequence,
|
|
618
|
+
type: "text",
|
|
619
|
+
text: part.text,
|
|
620
|
+
state: "done",
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
if (part.type === "file") {
|
|
624
|
+
return {
|
|
625
|
+
part_id: `action-file:${sequence}`,
|
|
626
|
+
sequence,
|
|
627
|
+
type: "file",
|
|
628
|
+
media_type: part.media_type,
|
|
629
|
+
url: part.url,
|
|
630
|
+
...(part.filename ? { filename: part.filename } : {}),
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
part_id: `action-data:${sequence}`,
|
|
635
|
+
sequence,
|
|
636
|
+
type: "data",
|
|
637
|
+
data_type: part.data_type,
|
|
638
|
+
data: part.data,
|
|
639
|
+
...(part.data_id ? { data_id: part.data_id } : {}),
|
|
640
|
+
};
|
|
641
|
+
});
|
|
742
642
|
}
|
|
743
643
|
|
|
744
|
-
/**
|
|
745
|
-
function
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
return "";
|
|
644
|
+
/** 构造成功执行但缺少最终内容时使用的 canonical Assistant Parts。 */
|
|
645
|
+
function build_fallback_assistant_parts(
|
|
646
|
+
text: string,
|
|
647
|
+
): SessionAssistantMessagePart[] {
|
|
648
|
+
return [{
|
|
649
|
+
part_id: "fallback-text:1",
|
|
650
|
+
sequence: 1,
|
|
651
|
+
type: "text",
|
|
652
|
+
text,
|
|
653
|
+
state: "done",
|
|
654
|
+
}];
|
|
757
655
|
}
|