@downcity/agent 1.1.337 → 1.1.399
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 +29 -21
- 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 +85 -55
- 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 +39 -12
- 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 +17 -4
- package/bin/types/session/SessionMutation.d.ts.map +1 -1
- package/bin/types/session/SessionMutation.js.map +1 -1
- 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 -54
- package/bin/workspace/WorkspacePaths.d.ts.map +1 -1
- package/bin/workspace/WorkspacePaths.js +7 -74
- 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 +132 -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 +110 -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 +79 -43
- 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 +41 -12
- 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/SessionMutation.ts +17 -2
- 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 -82
- 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
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* SDK Session 元数据辅助。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - 统一负责
|
|
5
|
+
* - 统一负责 Workspace `sessions/<session_id>/meta.json` 的规范化读取。
|
|
6
6
|
* - 仅处理轻量配置摘要与索引信息,不负责消息 JSONL 的读写。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { SessionHistoryMetaV1 } from "@/executor/types/SessionHistoryMeta.js";
|
|
10
|
-
import type {
|
|
10
|
+
import type { SessionOrigin } from "@/types/session/SessionOrigin.js";
|
|
11
|
+
import type { FileSystem } from "@downcity/workspace";
|
|
11
12
|
|
|
12
13
|
function normalizeModelLabel(input: unknown): string | undefined {
|
|
13
14
|
const label = typeof input === "string" ? input.trim() : "";
|
|
@@ -61,6 +62,17 @@ function normalize_history_bytes(input: unknown): number | undefined {
|
|
|
61
62
|
: undefined;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
/** 归一化 Session 来源元数据。 */
|
|
66
|
+
function normalize_session_origin(input: unknown): SessionOrigin | undefined {
|
|
67
|
+
if (!input || typeof input !== "object") return undefined;
|
|
68
|
+
const raw = input as { type?: unknown; group_id?: unknown; group_session_id?: unknown };
|
|
69
|
+
if (raw.type === "user") return { type: "user" };
|
|
70
|
+
if (raw.type !== "group") return undefined;
|
|
71
|
+
const group_id = typeof raw.group_id === "string" ? raw.group_id.trim() : "";
|
|
72
|
+
const group_session_id = typeof raw.group_session_id === "string" ? raw.group_session_id.trim() : "";
|
|
73
|
+
return group_id && group_session_id ? { type: "group", group_id, group_session_id } : undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
/**
|
|
65
77
|
* 从指定路径读取 session meta.json。
|
|
66
78
|
*
|
|
@@ -75,17 +87,29 @@ export async function read_session_metadata_from_path(input: {
|
|
|
75
87
|
session_id: string;
|
|
76
88
|
/** 当前 agent_id。 */
|
|
77
89
|
agent_id: string;
|
|
90
|
+
/** 当前查询上下文的 workspace_id;存在时必须与 metadata 严格匹配。 */
|
|
91
|
+
workspace_id?: string;
|
|
78
92
|
/** 当前 Workspace 的统一文件能力。 */
|
|
79
93
|
files: FileSystem;
|
|
80
94
|
}): Promise<SessionHistoryMetaV1> {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
const raw = JSON.parse(
|
|
96
|
+
(await input.files.read_file(input.filePath)).toString("utf8"),
|
|
97
|
+
) as Partial<SessionHistoryMetaV1>;
|
|
98
|
+
if (
|
|
99
|
+
raw.session_id !== input.session_id ||
|
|
100
|
+
raw.agent_id !== input.agent_id
|
|
101
|
+
) {
|
|
102
|
+
throw new Error(`Invalid Session ownership metadata: ${input.session_id}`);
|
|
88
103
|
}
|
|
104
|
+
if (input.workspace_id && raw.workspace_id !== input.workspace_id) {
|
|
105
|
+
throw new Error(`Invalid Session Workspace metadata: ${input.session_id}`);
|
|
106
|
+
}
|
|
107
|
+
return normalize_session_metadata(
|
|
108
|
+
raw,
|
|
109
|
+
input.session_id,
|
|
110
|
+
input.agent_id,
|
|
111
|
+
raw.workspace_id,
|
|
112
|
+
);
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
/** 将未知 Metadata 内容规范化为当前 Session 的稳定结构。 */
|
|
@@ -93,11 +117,16 @@ export function normalize_session_metadata(
|
|
|
93
117
|
raw: Partial<SessionHistoryMetaV1>,
|
|
94
118
|
session_id: string,
|
|
95
119
|
agent_id: string,
|
|
120
|
+
workspace_id?: string,
|
|
96
121
|
): SessionHistoryMetaV1 {
|
|
97
122
|
return {
|
|
98
123
|
v: 1,
|
|
99
124
|
session_id: session_id,
|
|
100
125
|
agent_id: agent_id,
|
|
126
|
+
...(workspace_id ? { workspace_id: workspace_id } : {}),
|
|
127
|
+
...(normalize_session_origin(raw.origin)
|
|
128
|
+
? { origin: normalize_session_origin(raw.origin) }
|
|
129
|
+
: {}),
|
|
101
130
|
created_at:
|
|
102
131
|
typeof raw.created_at === "number" && Number.isFinite(raw.created_at)
|
|
103
132
|
? raw.created_at
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* 再把用户答案作为 Tool Result 交回同一 Turn 的后续模型 Step。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
define_runtime_tool,
|
|
11
|
+
type RuntimeToolExecutionOptions as ToolExecutionOptions,
|
|
12
|
+
} from "@downcity/type";
|
|
10
13
|
import { ask_questions_input_schema } from "./AskQuestionsToolSchemas.js";
|
|
11
14
|
import type {
|
|
12
15
|
AskQuestionsToolInput,
|
|
@@ -15,6 +18,8 @@ import type {
|
|
|
15
18
|
import type { SessionToolExecutionContext } from "@/types/executor/SessionToolExecutionContext.js";
|
|
16
19
|
import { generate_id } from "@/utils/Id.js";
|
|
17
20
|
import type { ActionResult } from "@/types/action/ActionResult.js";
|
|
21
|
+
import type { JsonValue } from "@/types/common/Json.js";
|
|
22
|
+
import type { SessionInteractionAnswer } from "@/types/session/SessionInteraction.js";
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* 由调用方显式注册、按当前 Session Turn 上下文执行的提问 Tool。
|
|
@@ -28,21 +33,21 @@ import type { ActionResult } from "@/types/action/ActionResult.js";
|
|
|
28
33
|
* });
|
|
29
34
|
* ```
|
|
30
35
|
*/
|
|
31
|
-
export const AskQuestionsTool =
|
|
36
|
+
export const AskQuestionsTool = define_runtime_tool<AskQuestionsToolInput, ActionResult<AskQuestionsToolOutput>>({
|
|
32
37
|
description:
|
|
33
38
|
"Ask the user one or more questions when missing information would materially change the outcome. The call waits for every answer, then returns them so you can continue the same task. Do not use it for information that can be inferred safely. For single_select and multi_select questions, every option MUST contain both a machine-readable value and a user-visible label; never omit value or use label as value. Example: { value: 'cn', label: '中国' }.",
|
|
34
|
-
|
|
39
|
+
input_schema: ask_questions_input_schema,
|
|
35
40
|
execute: async (
|
|
36
41
|
input: AskQuestionsToolInput,
|
|
37
42
|
execution_options: ToolExecutionOptions,
|
|
38
43
|
): Promise<ActionResult<AskQuestionsToolOutput>> => {
|
|
39
|
-
const execution_context = execution_options.
|
|
44
|
+
const execution_context = execution_options.context as
|
|
40
45
|
| Partial<SessionToolExecutionContext>
|
|
41
46
|
| undefined;
|
|
42
|
-
const
|
|
43
|
-
const interaction_port =
|
|
44
|
-
const turn_id = String(
|
|
45
|
-
const tool_call_id = String(
|
|
47
|
+
const action_execution = execution_context?.action_execution_context;
|
|
48
|
+
const interaction_port = action_execution?.session.interactions;
|
|
49
|
+
const turn_id = String(action_execution?.session.turn_id || "").trim();
|
|
50
|
+
const tool_call_id = String(action_execution?.call_id || "").trim();
|
|
46
51
|
if (!interaction_port || !turn_id || !tool_call_id) {
|
|
47
52
|
throw new Error(
|
|
48
53
|
"ask_question requires an active Session tool execution context",
|
|
@@ -52,19 +57,21 @@ export const AskQuestionsTool = tool({
|
|
|
52
57
|
const handle = await interaction_port.request({
|
|
53
58
|
interaction_id: `interaction:${generate_id()}`,
|
|
54
59
|
turn_id,
|
|
55
|
-
|
|
60
|
+
type: "question",
|
|
56
61
|
source: {
|
|
57
62
|
type: "tool",
|
|
58
63
|
tool_call_id,
|
|
59
64
|
tool_name: "ask_question",
|
|
60
65
|
},
|
|
61
66
|
title: input.title,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
payload: {
|
|
68
|
+
questions: input.questions.map((question) => ({
|
|
69
|
+
question_id: `question:${generate_id()}`,
|
|
70
|
+
prompt: question.question,
|
|
71
|
+
response_type: question.type,
|
|
72
|
+
...(question.options ? { options: question.options } : {}),
|
|
73
|
+
})),
|
|
74
|
+
} as unknown as JsonValue,
|
|
68
75
|
created_at: Date.now(),
|
|
69
76
|
});
|
|
70
77
|
const result = await handle.result;
|
|
@@ -74,7 +81,11 @@ export const AskQuestionsTool = tool({
|
|
|
74
81
|
if (result.status === "expired") {
|
|
75
82
|
throw new Error("ask_question expired before the user responded");
|
|
76
83
|
}
|
|
77
|
-
if (
|
|
84
|
+
if (
|
|
85
|
+
result.status !== "resolved" ||
|
|
86
|
+
result.response.type !== "question" ||
|
|
87
|
+
result.response.outcome !== "resolved"
|
|
88
|
+
) {
|
|
78
89
|
throw new Error(
|
|
79
90
|
"ask_question received an incompatible Interaction response",
|
|
80
91
|
);
|
|
@@ -82,7 +93,7 @@ export const AskQuestionsTool = tool({
|
|
|
82
93
|
return {
|
|
83
94
|
output: {
|
|
84
95
|
status: "resolved",
|
|
85
|
-
answers: result.response.answers,
|
|
96
|
+
answers: (result.response.payload as unknown as { answers: SessionInteractionAnswer[] }).answers,
|
|
86
97
|
},
|
|
87
98
|
messages: [],
|
|
88
99
|
};
|
|
@@ -2,25 +2,34 @@
|
|
|
2
2
|
* Action 与 Session Tool 共用的执行结果协议。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - `output` 是标准 Tool Result
|
|
5
|
+
* - `output` 是标准 Tool Result,原样交给模型执行器和 canonical Tool Part。
|
|
6
6
|
* - `messages` 是执行后写入 Session 的真实 User / Assistant Message 内容。
|
|
7
|
-
* - Message Parts
|
|
7
|
+
* - Message Parts 复用 Downcity Session UI 协议,不再建立文件、图片或 Plugin 专用桥接。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
SessionAssistantResultPart,
|
|
12
|
+
SessionPromptPart,
|
|
13
|
+
} from "@/types/session/SessionContent.js";
|
|
11
14
|
|
|
12
15
|
/** Action 执行后产生的一条 Session 消息。 */
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
16
|
+
export type ActionResultMessage =
|
|
17
|
+
| {
|
|
18
|
+
/** User 内容在下一 Step 生效。 */
|
|
19
|
+
role: "user";
|
|
20
|
+
/** 等待进入 canonical User Message 的内容。 */
|
|
21
|
+
parts: SessionPromptPart[];
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
/** Assistant 内容写入当前回复。 */
|
|
25
|
+
role: "assistant";
|
|
26
|
+
/** 等待进入 canonical Assistant Message 的内容。 */
|
|
27
|
+
parts: SessionAssistantResultPart[];
|
|
28
|
+
};
|
|
20
29
|
|
|
21
30
|
/** Action 或 Tool 内部实现返回的统一结果。 */
|
|
22
31
|
export interface ActionResult<TOutput = unknown> {
|
|
23
|
-
/**
|
|
32
|
+
/** 返回给调用方、模型执行器与 canonical Tool Part 的标准执行输出。 */
|
|
24
33
|
output: TOutput;
|
|
25
34
|
|
|
26
35
|
/** 执行产生的真实 Session 消息;没有附加消息时传入空数组。 */
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* - RemoteAgent 与 Session 数据结构拆到独立类型文件。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { Tool } from "
|
|
9
|
+
import type { RuntimeTool as Tool } from "@downcity/type";
|
|
10
10
|
import type { AgentModel } from "@/agent/AgentModel.js";
|
|
11
|
-
import type { WorkspaceBase } from "@/workspace/WorkspaceBase.js";
|
|
12
11
|
import type { Plugin } from "@/types/plugin/PluginDefinition.js";
|
|
12
|
+
import type { PluginWebServices } from "@/types/plugin/PluginServices.js";
|
|
13
13
|
import type {
|
|
14
14
|
AgentManagedSession,
|
|
15
15
|
SessionOptions,
|
|
@@ -34,21 +34,11 @@ export interface AgentOptions {
|
|
|
34
34
|
* 当前 agent 的稳定标识。
|
|
35
35
|
*
|
|
36
36
|
* 关键点(中文)
|
|
37
|
-
* -
|
|
37
|
+
* - 用于用户级数据根下的 `agents/<agent_id>/...` 目录分区。
|
|
38
38
|
* - 应保持稳定、可 URL 编码、尽量不要依赖展示名称。
|
|
39
39
|
*/
|
|
40
40
|
id: string;
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* 当前 Agent 可以访问的项目资源与安全边界。
|
|
44
|
-
*
|
|
45
|
-
* 关键点(中文)
|
|
46
|
-
* - Workspace 统一持有项目根目录、文件/搜索能力与可选 Shell。
|
|
47
|
-
* - 每个 Workspace 实例只能绑定一个 Agent,并由 Agent dispose 统一释放。
|
|
48
|
-
* - 多个 Agent 可以指向同一物理目录,但必须分别创建 Workspace 实例。
|
|
49
|
-
*/
|
|
50
|
-
workspace: WorkspaceBase;
|
|
51
|
-
|
|
52
42
|
/**
|
|
53
43
|
* 当前 agent 默认可用的工具集合。
|
|
54
44
|
*
|
|
@@ -77,6 +67,9 @@ export interface AgentOptions {
|
|
|
77
67
|
*/
|
|
78
68
|
model?: AgentModel;
|
|
79
69
|
|
|
70
|
+
/** 当前 Agent 持有的 Web 搜索与文档能力。 */
|
|
71
|
+
web?: PluginWebServices;
|
|
72
|
+
|
|
80
73
|
/**
|
|
81
74
|
* 当前 agent 显式持有的插件实例集合。
|
|
82
75
|
*
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent 面向 SDK 用户的 Session 集合类型。
|
|
3
|
+
*
|
|
4
|
+
* Session 归 Agent 所有;Workspace 只在创建时声明本次执行使用的资源环境。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { WorkspaceBase } from "@downcity/workspace";
|
|
8
|
+
import type { SessionOrigin } from "@/types/session/SessionOrigin.js";
|
|
9
|
+
import type { AgentSession } from "@/types/agent/SessionActor.js";
|
|
10
|
+
import type { AgentCreateSessionInput } from "@/types/agent/SessionTypes.js";
|
|
11
|
+
import type { SessionPort } from "@/types/session/SessionPort.js";
|
|
12
|
+
import type {
|
|
13
|
+
AgentArchiveSessionInput,
|
|
14
|
+
AgentArchiveSessionResult,
|
|
15
|
+
AgentArchiveSessionsInput,
|
|
16
|
+
AgentArchiveSessionsResult,
|
|
17
|
+
AgentCleanArchiveResult,
|
|
18
|
+
AgentListSessionsInput,
|
|
19
|
+
AgentSessionSummaryPage,
|
|
20
|
+
} from "@/types/agent/SessionTypes.js";
|
|
21
|
+
|
|
22
|
+
/** 创建 Agent Session 的公开参数。 */
|
|
23
|
+
export interface AgentCreateSessionOptions extends AgentCreateSessionInput {
|
|
24
|
+
/** 本次 Session 可选使用的 Workspace 资源;未传入时使用内存执行上下文。 */
|
|
25
|
+
workspace?: WorkspaceBase;
|
|
26
|
+
/** 当前 Session 的创建来源;未填写时视为用户直接创建。 */
|
|
27
|
+
origin?: SessionOrigin;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Agent 公开的 Session 创建入口。 */
|
|
31
|
+
export interface AgentSessionCollection {
|
|
32
|
+
/** 在指定 Workspace 中创建一个属于当前 Agent 的 Session。 */
|
|
33
|
+
create(options?: AgentCreateSessionOptions): Promise<AgentSession>;
|
|
34
|
+
|
|
35
|
+
/** 在指定 Workspace 中恢复一个已经属于当前 Agent 的 Session。 */
|
|
36
|
+
get(session_id: string, options?: AgentCreateSessionOptions): Promise<AgentSession>;
|
|
37
|
+
|
|
38
|
+
/** 列出当前 Agent 的活动 Session。 */
|
|
39
|
+
list(input?: AgentListSessionsInput): Promise<AgentSessionSummaryPage>;
|
|
40
|
+
|
|
41
|
+
/** 归档一个 Session。 */
|
|
42
|
+
archive(input: AgentArchiveSessionInput): Promise<AgentArchiveSessionResult>;
|
|
43
|
+
|
|
44
|
+
/** 列出已归档 Session。 */
|
|
45
|
+
archived(input?: AgentArchiveSessionsInput): Promise<AgentArchiveSessionsResult>;
|
|
46
|
+
|
|
47
|
+
/** 清空已归档 Session。 */
|
|
48
|
+
clean_archive(): Promise<AgentCleanArchiveResult>;
|
|
49
|
+
|
|
50
|
+
/** 获取 Session runtime port。 */
|
|
51
|
+
runtime(session_id: string): SessionPort;
|
|
52
|
+
|
|
53
|
+
/** 返回当前 Agent 正在执行的 Session 标识。 */
|
|
54
|
+
list_executing_session_ids(): string[];
|
|
55
|
+
|
|
56
|
+
/** 永久删除 Session。 */
|
|
57
|
+
remove(session_id: string): Promise<boolean>;
|
|
58
|
+
|
|
59
|
+
/** 清空 Session 消息。 */
|
|
60
|
+
clear_messages(session_id: string): Promise<boolean>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent 级持久化存储。
|
|
3
|
+
*
|
|
4
|
+
* Agent 在 City 中使用持久化文件系统;未加入 City 时使用进程内文件系统。
|
|
5
|
+
* Workspace 只提供执行上下文,不拥有这份存储。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { SessionStore } from "@/types/store/SessionStore.js";
|
|
9
|
+
import type { FileSystem } from "@downcity/workspace";
|
|
10
|
+
|
|
11
|
+
/** Agent 持有的 Session、日志与调度共享存储。 */
|
|
12
|
+
export interface AgentStorage {
|
|
13
|
+
/** Agent 内部数据的稳定根路径。 */
|
|
14
|
+
root_path: string;
|
|
15
|
+
/** 受当前 Agent 根路径约束的文件能力。 */
|
|
16
|
+
files: FileSystem;
|
|
17
|
+
/** 当前 Agent 的 Session 集合存储。 */
|
|
18
|
+
sessions: SessionStore;
|
|
19
|
+
}
|
|
@@ -41,6 +41,7 @@ import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js"
|
|
|
41
41
|
import type { AgentSessionStopResult } from "@/types/sdk/AgentSessionStop.js";
|
|
42
42
|
import type { AgentSessionCompactHandle } from "@/types/sdk/AgentSessionCompact.js";
|
|
43
43
|
import type { AgentSessionTurnHandle } from "@/types/sdk/AgentSessionTurn.js";
|
|
44
|
+
import type { SessionOrigin } from "@/types/session/SessionOrigin.js";
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* SDK Session 集合入口。
|
|
@@ -72,6 +73,11 @@ export interface AgentSessionActor {
|
|
|
72
73
|
/** 当前 session 稳定标识。 */
|
|
73
74
|
readonly id: string;
|
|
74
75
|
|
|
76
|
+
/** 当前 Session 创建时绑定的 Workspace ID;无 Workspace 时为空。 */
|
|
77
|
+
readonly workspace_id?: string;
|
|
78
|
+
/** 当前 Session 的创建来源。 */
|
|
79
|
+
readonly origin?: SessionOrigin;
|
|
80
|
+
|
|
75
81
|
/** 读取当前 session 详情。 */
|
|
76
82
|
get_info(): Promise<AgentSessionInfo>;
|
|
77
83
|
|
|
@@ -124,6 +130,9 @@ export interface AgentSession extends AgentSessionActor {
|
|
|
124
130
|
/** 写入当前 session 默认配置。 */
|
|
125
131
|
set(input: AgentSessionSetInput, options?: AgentSessionSetOptions): Promise<void>;
|
|
126
132
|
|
|
133
|
+
/** 修改当前 Session 的用户可见标题并发布 canonical mutation。 */
|
|
134
|
+
rename(title: string): Promise<string>;
|
|
135
|
+
|
|
127
136
|
/** 把当前 Session 首次生成后固定的完整 system 显式固化到 instruction.md。 */
|
|
128
137
|
snapshot(): Promise<void>;
|
|
129
138
|
|
|
@@ -8,27 +8,31 @@
|
|
|
8
8
|
|
|
9
9
|
import type { AgentModel } from "@/agent/AgentModel.js";
|
|
10
10
|
import type { SessionApprovalMode } from "@/types/session/SessionInteraction.js";
|
|
11
|
+
import type { SessionOrigin } from "@/types/session/SessionOrigin.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* 新建
|
|
14
|
+
* 新建 Session 的输入参数。
|
|
15
|
+
*
|
|
16
|
+
* Session ID 由 AgentSessions 在创建时生成,调用方只能在恢复时通过
|
|
17
|
+
* `sessions.get(session_id)` 指定已有 ID。
|
|
14
18
|
*/
|
|
15
19
|
export interface AgentCreateSessionInput {
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
* 关键点(中文)
|
|
20
|
-
* - 传入时表达“创建意图”。
|
|
21
|
-
* - 若该 session 已存在,SDK 应直接报错,而不是静默复用。
|
|
22
|
-
* - 省略时由 SDK 自动生成稳定且不可推导的 session_id。
|
|
23
|
-
*/
|
|
24
|
-
session_id?: string;
|
|
25
|
-
|
|
20
|
+
/** 保持创建输入为无配置字段的协议对象。 */
|
|
21
|
+
readonly __create_session_input?: never;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
/**
|
|
29
25
|
* Session 列表查询输入。
|
|
30
26
|
*/
|
|
31
27
|
export interface AgentListSessionsInput {
|
|
28
|
+
/**
|
|
29
|
+
* 只返回绑定到指定 Workspace 的 Session。
|
|
30
|
+
*
|
|
31
|
+
* 省略时查询当前 Agent 的全部 Session;传入时没有 Workspace metadata 的
|
|
32
|
+
* 历史 Session 不会匹配任何 Workspace。
|
|
33
|
+
*/
|
|
34
|
+
workspace_id?: string;
|
|
35
|
+
|
|
32
36
|
/**
|
|
33
37
|
* 当前页返回上限。
|
|
34
38
|
*
|
|
@@ -110,8 +114,17 @@ export interface AgentSessionSecurityConfig {
|
|
|
110
114
|
|
|
111
115
|
/** 远程 Session 可序列化的动态配置输入。 */
|
|
112
116
|
export interface RemoteSessionSetInput {
|
|
117
|
+
/**
|
|
118
|
+
* 当前远程 Session 使用的宿主模型 ID。
|
|
119
|
+
*
|
|
120
|
+
* 关键点(中文)
|
|
121
|
+
* - 远程边界只传递稳定、可序列化的模型 ID。
|
|
122
|
+
* - 服务端宿主负责把模型 ID 解析为运行时 AgentModel。
|
|
123
|
+
*/
|
|
124
|
+
model_id?: string;
|
|
125
|
+
|
|
113
126
|
/** 当前远程 Session 的安全策略。 */
|
|
114
|
-
security
|
|
127
|
+
security?: AgentSessionSecurityConfig;
|
|
115
128
|
}
|
|
116
129
|
|
|
117
130
|
/** Session 当前安全状态。 */
|
|
@@ -312,6 +325,8 @@ export interface AgentSessionSummary {
|
|
|
312
325
|
message_count: number;
|
|
313
326
|
/** 当前 session 绑定模型的可读标签。 */
|
|
314
327
|
model_label?: string;
|
|
328
|
+
/** 当前 Session 的创建来源。 */
|
|
329
|
+
origin?: SessionOrigin;
|
|
315
330
|
/** 当前 session 是否处于执行中。 */
|
|
316
331
|
executing?: boolean;
|
|
317
332
|
}
|
|
@@ -356,6 +371,12 @@ export interface AgentSessionForkInput {
|
|
|
356
371
|
* - 传入时复制到该消息为止(包含该消息)。
|
|
357
372
|
*/
|
|
358
373
|
message_id?: string;
|
|
374
|
+
/**
|
|
375
|
+
* 是否将 `message_id` 指向的锚点消息复制到新 Session。
|
|
376
|
+
*
|
|
377
|
+
* 省略时默认为 `true`;编辑并重新发送历史消息时传入 `false`,避免新旧消息同时出现。
|
|
378
|
+
*/
|
|
379
|
+
include_message?: boolean;
|
|
359
380
|
}
|
|
360
381
|
|
|
361
382
|
/**
|
|
@@ -376,6 +397,14 @@ export interface AgentArchiveSessionInput {
|
|
|
376
397
|
* 列出已归档 session 的输入参数。
|
|
377
398
|
*/
|
|
378
399
|
export interface AgentArchiveSessionsInput {
|
|
400
|
+
/**
|
|
401
|
+
* 只返回绑定到指定 Workspace 的归档 Session。
|
|
402
|
+
*
|
|
403
|
+
* 省略时查询当前 Agent 的全部归档 Session;传入时没有 Workspace metadata
|
|
404
|
+
* 的历史 Session 不会匹配任何 Workspace。
|
|
405
|
+
*/
|
|
406
|
+
workspace_id?: string;
|
|
407
|
+
|
|
379
408
|
/**
|
|
380
409
|
* 当前页返回上限。
|
|
381
410
|
*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkspaceEntry 装配参数。
|
|
3
|
+
*
|
|
4
|
+
* WorkspaceEntry 只表达 Agent 已进入某个 Workspace,不拥有 Agent 身份或 Plugin
|
|
5
|
+
* 定义。Workspace 资源的生命周期在离开时由该作用域统一关闭。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Agent } from "@/agent/Agent.js";
|
|
9
|
+
import type { WorkspaceBase } from "@downcity/workspace";
|
|
10
|
+
|
|
11
|
+
/** Agent 进入 Workspace 时使用的内部装配参数。 */
|
|
12
|
+
export interface WorkspaceEntryOptions {
|
|
13
|
+
/** 拥有当前作用域的 Agent。 */
|
|
14
|
+
agent: Agent;
|
|
15
|
+
|
|
16
|
+
/** 当前进入的项目资源容器。 */
|
|
17
|
+
workspace: WorkspaceBase;
|
|
18
|
+
}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Executor 到 Session
|
|
2
|
+
* Executor 到 canonical Session Assistant Message 的输出端口。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* 由 execution Adapter 完成,SessionMessages 仍是唯一 Assistant Message 事实源。
|
|
4
|
+
* 该端口直接消费 Downcity Model Protocol 事件,不定义或转发 UI-shaped chunk。
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
7
|
+
import type { ModelStreamEvent } from "@downcity/type";
|
|
8
|
+
import type { SessionAssistantResultPart } from "@/types/session/SessionContent.js";
|
|
9
|
+
import type { SessionAssistantMessagePart } from "@/types/session/SessionMessage.js";
|
|
10
|
+
import type {
|
|
11
|
+
SessionToolExecutionResult,
|
|
12
|
+
SessionToolInputReady,
|
|
13
|
+
} from "@/types/session/SessionTool.js";
|
|
11
14
|
|
|
12
|
-
/**
|
|
15
|
+
/** Executor 写入当前 Turn Assistant Message 的稳定能力。 */
|
|
13
16
|
export interface SessionAssistantOutput {
|
|
14
|
-
/**
|
|
17
|
+
/** 开始一个模型 Step 的独立 Part 作用域。 */
|
|
15
18
|
begin_step(): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
19
|
+
/** 直接写入单个标准模型流事件。 */
|
|
20
|
+
write_model_event(event: ModelStreamEvent): Promise<void>;
|
|
21
|
+
/** 在 Tool 审批或执行前提交完整输入。 */
|
|
22
|
+
prepare_tool_input(input: SessionToolInputReady): Promise<void>;
|
|
23
|
+
/** 写入 Tool 执行终态。 */
|
|
24
|
+
write_tool_result(result: SessionToolExecutionResult): Promise<void>;
|
|
25
|
+
/** 使用模型流聚合出的 canonical Parts 校验当前 Step。 */
|
|
26
|
+
finish_step(parts: SessionAssistantMessagePart[]): Promise<void>;
|
|
20
27
|
/** 放弃当前未完成 Step 的临时作用域。 */
|
|
21
28
|
abort_step(): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
prepare_tool_input(input: SessionToolInputReady): Promise<void>;
|
|
24
|
-
/** User steer 已插入会话后,关闭它之前的当前 Assistant Message。 */
|
|
29
|
+
/** User steer 插入前关闭当前连续 Assistant Message。 */
|
|
25
30
|
close_current_message(): Promise<void>;
|
|
26
|
-
/** 把 Action
|
|
27
|
-
|
|
31
|
+
/** 把 Action 产生的封闭内容追加到当前 Assistant Message。 */
|
|
32
|
+
append_result_parts(parts: readonly SessionAssistantResultPart[]): Promise<void>;
|
|
28
33
|
/** 按 Turn 最终结果收口 Assistant 输出。 */
|
|
29
34
|
finish(input: {
|
|
30
35
|
/** Assistant 最终状态。 */
|
|
@@ -3,19 +3,24 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 该对象由 Executor 在每个 Session step 绑定到 tool.execute。
|
|
6
|
-
* - Agent 工具读取 session_turn_context,Shell 工具只读取
|
|
6
|
+
* - Agent 工具读取 session_turn_context,Shell 工具只读取 shell_execution_context。
|
|
7
7
|
* - 上下文归属当前 Turn,不通过进程级或异步全局容器共享。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
ShellExecutionContext,
|
|
12
|
+
} from "@downcity/workspace/shell/types/ShellRuntime.js";
|
|
11
13
|
import type { SessionTurnContext } from "@/types/executor/SessionTurnContext.js";
|
|
14
|
+
import type { ToolActionExecutionContext } from "@/types/tools/ToolActionExecutionContext.js";
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Agent 与 Shell 工具共用的单次执行上下文。
|
|
15
18
|
*/
|
|
16
19
|
export interface SessionToolExecutionContext {
|
|
17
|
-
/**
|
|
18
|
-
|
|
20
|
+
/** 业务 Tool 读取的最小执行上下文。 */
|
|
21
|
+
action_execution_context: ToolActionExecutionContext;
|
|
22
|
+
/** 当前 Shell Tool 的 canonical 执行上下文。 */
|
|
23
|
+
shell_execution_context: ShellExecutionContext;
|
|
19
24
|
/** 当前工具调用所属的完整 Session Turn 上下文。 */
|
|
20
25
|
session_turn_context: SessionTurnContext;
|
|
21
26
|
}
|