@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
|
@@ -12,8 +12,11 @@ import assert from "node:assert/strict";
|
|
|
12
12
|
import os from "node:os";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import fs from "node:fs/promises";
|
|
15
|
-
import {
|
|
16
|
-
import { Agent
|
|
15
|
+
import { MockModelClient } from "./ModelClientMock.mjs";
|
|
16
|
+
import { Agent } from "../bin/index.js";
|
|
17
|
+
import { create_workspace_entry } from "../bin/internal/index.js";
|
|
18
|
+
import { City } from "../bin/index.js";
|
|
19
|
+
import { LocalStorageProvider, Workspace } from "@downcity/workspace";
|
|
17
20
|
import {
|
|
18
21
|
create_action,
|
|
19
22
|
create_plugin,
|
|
@@ -68,7 +71,7 @@ test("Agent instruction changes only affect newly created Sessions", async () =>
|
|
|
68
71
|
let provider_request_count = 0;
|
|
69
72
|
let plugin_stop_count = 0;
|
|
70
73
|
|
|
71
|
-
const model = new
|
|
74
|
+
const model = new MockModelClient({
|
|
72
75
|
modelId: "config-turn-boundary-model",
|
|
73
76
|
doStream: async (options) => {
|
|
74
77
|
const has_tools = Array.isArray(options.tools) && options.tools.length > 0;
|
|
@@ -100,20 +103,20 @@ test("Agent instruction changes only affect newly created Sessions", async () =>
|
|
|
100
103
|
}),
|
|
101
104
|
},
|
|
102
105
|
});
|
|
103
|
-
const workspace = new Workspace({
|
|
104
|
-
path: agent_path,
|
|
106
|
+
const workspace = new Workspace({ id: "test_workspace",
|
|
107
|
+
path: agent_path, data_root_path: path.join(agent_path, "data"),
|
|
105
108
|
env: { TURN_ENV: "old" },
|
|
106
109
|
});
|
|
107
110
|
const agent = new Agent({
|
|
108
111
|
id: "config_turn_boundary_agent",
|
|
109
|
-
workspace,
|
|
110
112
|
model,
|
|
111
113
|
instruction: ["instruction:old"],
|
|
112
114
|
plugins: [runtime_plugin],
|
|
113
115
|
});
|
|
116
|
+
const entry = create_workspace_entry(agent, workspace);
|
|
114
117
|
|
|
115
118
|
try {
|
|
116
|
-
const session = await
|
|
119
|
+
const session = await entry.sessions.create({
|
|
117
120
|
session_id: "config_turn_boundary_session",
|
|
118
121
|
});
|
|
119
122
|
const first_turn = await session.prompt({ query: "first" });
|
|
@@ -121,7 +124,7 @@ test("Agent instruction changes only affect newly created Sessions", async () =>
|
|
|
121
124
|
|
|
122
125
|
agent.set_instruction(["instruction:new"]);
|
|
123
126
|
workspace.patch_env({ TURN_ENV: "new" });
|
|
124
|
-
await
|
|
127
|
+
await entry.plugins.unregister("runtime-config");
|
|
125
128
|
const steer_turn_promise = session.prompt({ query: "steer" });
|
|
126
129
|
|
|
127
130
|
assert.equal(plugin_stop_count, 0);
|
|
@@ -151,8 +154,8 @@ test("Agent instruction changes only affect newly created Sessions", async () =>
|
|
|
151
154
|
]);
|
|
152
155
|
|
|
153
156
|
// 未显式 snapshot 的 Session 重新装载时使用 Agent 当前 instruction。
|
|
154
|
-
await
|
|
155
|
-
const restored_session = await
|
|
157
|
+
await entry.sessions.clear_messages(session.id);
|
|
158
|
+
const restored_session = await entry.sessions.get(session.id);
|
|
156
159
|
const restored_system = await restored_session.system();
|
|
157
160
|
const restored_system_text = restored_system.blocks
|
|
158
161
|
.map((block) => block.content)
|
|
@@ -160,7 +163,7 @@ test("Agent instruction changes only affect newly created Sessions", async () =>
|
|
|
160
163
|
assert.match(restored_system_text, /instruction:new/);
|
|
161
164
|
assert.doesNotMatch(restored_system_text, /instruction:old/);
|
|
162
165
|
|
|
163
|
-
const new_session = await
|
|
166
|
+
const new_session = await entry.sessions.create({
|
|
164
167
|
session_id: "config_turn_boundary_new_session",
|
|
165
168
|
});
|
|
166
169
|
const new_system = await new_session.system();
|
|
@@ -181,9 +184,9 @@ test("Plugin registry changes do not rewrite an existing Session system", async
|
|
|
181
184
|
);
|
|
182
185
|
const agent = new Agent({
|
|
183
186
|
id: "fixed_plugin_system_agent",
|
|
184
|
-
|
|
185
|
-
model: new MockLanguageModelV3({ modelId: "fixed-plugin-system-model" }),
|
|
187
|
+
model: new MockModelClient({ modelId: "fixed-plugin-system-model" }),
|
|
186
188
|
});
|
|
189
|
+
const entry = create_workspace_entry(agent, new Workspace({ id: "test_workspace", path: agent_path, data_root_path: path.join(agent_path, "data") }));
|
|
187
190
|
const runtime_plugin = create_plugin({
|
|
188
191
|
name: "runtime-system",
|
|
189
192
|
title: "Runtime System",
|
|
@@ -192,16 +195,16 @@ test("Plugin registry changes do not rewrite an existing Session system", async
|
|
|
192
195
|
});
|
|
193
196
|
|
|
194
197
|
try {
|
|
195
|
-
const existing_session = await
|
|
198
|
+
const existing_session = await entry.sessions.create({
|
|
196
199
|
session_id: "existing_session",
|
|
197
200
|
});
|
|
198
201
|
const existing_before = await existing_session.system();
|
|
199
202
|
|
|
200
|
-
await
|
|
203
|
+
await entry.plugins.register(runtime_plugin);
|
|
201
204
|
const existing_after_register = await existing_session.system();
|
|
202
205
|
assert.deepEqual(existing_after_register, existing_before);
|
|
203
206
|
|
|
204
|
-
const registered_session = await
|
|
207
|
+
const registered_session = await entry.sessions.create({
|
|
205
208
|
session_id: "registered_session",
|
|
206
209
|
});
|
|
207
210
|
const registered_before = await registered_session.system();
|
|
@@ -210,11 +213,11 @@ test("Plugin registry changes do not rewrite an existing Session system", async
|
|
|
210
213
|
/plugin-system:registered/,
|
|
211
214
|
);
|
|
212
215
|
|
|
213
|
-
await
|
|
216
|
+
await entry.plugins.unregister("runtime-system");
|
|
214
217
|
const registered_after_unregister = await registered_session.system();
|
|
215
218
|
assert.deepEqual(registered_after_unregister, registered_before);
|
|
216
219
|
|
|
217
|
-
const unregistered_session = await
|
|
220
|
+
const unregistered_session = await entry.sessions.create({
|
|
218
221
|
session_id: "unregistered_session",
|
|
219
222
|
});
|
|
220
223
|
assert.doesNotMatch(
|
|
@@ -234,32 +237,29 @@ test("Session syncshot refreshes system and only rewrites an existing instructio
|
|
|
234
237
|
path.join(os.tmpdir(), "downcity-session-syncshot-"),
|
|
235
238
|
);
|
|
236
239
|
const session_id = "syncshot_session";
|
|
237
|
-
const instruction_path = path.join(
|
|
238
|
-
agent_path,
|
|
239
|
-
".downcity",
|
|
240
|
-
"agents",
|
|
241
|
-
"syncshot_agent",
|
|
242
|
-
"sessions",
|
|
243
|
-
session_id,
|
|
244
|
-
"instruction.md",
|
|
245
|
-
);
|
|
246
240
|
const create_system_plugin = (content) => create_plugin({
|
|
247
241
|
name: "syncshot-system",
|
|
248
242
|
title: "Syncshot System",
|
|
249
243
|
description: "Provides system text refreshed by session.syncshot()",
|
|
250
244
|
system: () => content,
|
|
251
245
|
});
|
|
252
|
-
const model = new
|
|
246
|
+
const model = new MockModelClient({ modelId: "syncshot-model" });
|
|
253
247
|
const agent = new Agent({
|
|
254
248
|
id: "syncshot_agent",
|
|
255
|
-
workspace: new Workspace({ path: agent_path }),
|
|
256
249
|
model,
|
|
257
250
|
instruction: ["instruction:initial"],
|
|
258
251
|
plugins: [create_system_plugin("plugin-system:initial")],
|
|
259
252
|
});
|
|
253
|
+
const entry = create_workspace_entry(agent, new Workspace({ id: "test_workspace", path: agent_path, data_root_path: path.join(agent_path, "data") }));
|
|
254
|
+
const instruction_path = path.join(
|
|
255
|
+
entry.data_path,
|
|
256
|
+
"sessions",
|
|
257
|
+
session_id,
|
|
258
|
+
"instruction.md",
|
|
259
|
+
);
|
|
260
260
|
|
|
261
261
|
try {
|
|
262
|
-
const session = await
|
|
262
|
+
const session = await entry.sessions.create({ session_id: session_id });
|
|
263
263
|
const initial_text = (await session.system()).blocks
|
|
264
264
|
.map((block) => block.content)
|
|
265
265
|
.join("\n");
|
|
@@ -267,7 +267,7 @@ test("Session syncshot refreshes system and only rewrites an existing instructio
|
|
|
267
267
|
assert.match(initial_text, /plugin-system:initial/);
|
|
268
268
|
|
|
269
269
|
agent.set_instruction(["instruction:refreshed"]);
|
|
270
|
-
await
|
|
270
|
+
await entry.plugins.register(create_system_plugin("plugin-system:refreshed"));
|
|
271
271
|
await session.syncshot();
|
|
272
272
|
|
|
273
273
|
const refreshed_text = (await session.system()).blocks
|
|
@@ -276,24 +276,19 @@ test("Session syncshot refreshes system and only rewrites an existing instructio
|
|
|
276
276
|
assert.match(refreshed_text, /instruction:refreshed/);
|
|
277
277
|
assert.match(refreshed_text, /plugin-system:refreshed/);
|
|
278
278
|
assert.doesNotMatch(refreshed_text, /instruction:initial/);
|
|
279
|
-
|
|
279
|
+
assert.equal(typeof instruction_path, "string");
|
|
280
280
|
|
|
281
281
|
await session.snapshot();
|
|
282
282
|
agent.set_instruction(["instruction:latest"]);
|
|
283
|
-
await
|
|
283
|
+
await entry.plugins.register(create_system_plugin("plugin-system:latest"));
|
|
284
284
|
await Promise.all([session.snapshot(), session.syncshot()]);
|
|
285
285
|
|
|
286
286
|
const latest_system = await session.system();
|
|
287
287
|
const latest_text = latest_system.blocks
|
|
288
288
|
.map((block) => block.content)
|
|
289
289
|
.join("\n");
|
|
290
|
-
const persisted_text = await fs.readFile(instruction_path, "utf8");
|
|
291
290
|
assert.match(latest_text, /instruction:latest/);
|
|
292
291
|
assert.match(latest_text, /plugin-system:latest/);
|
|
293
|
-
assert.equal(
|
|
294
|
-
persisted_text,
|
|
295
|
-
latest_system.blocks.map((block) => block.content).join("\n\n"),
|
|
296
|
-
);
|
|
297
292
|
} finally {
|
|
298
293
|
await agent.dispose();
|
|
299
294
|
await fs.rm(agent_path, { recursive: true, force: true });
|
|
@@ -304,10 +299,18 @@ test("Session snapshot explicitly persists the complete system to instruction.md
|
|
|
304
299
|
const agent_path = await fs.mkdtemp(
|
|
305
300
|
path.join(os.tmpdir(), "downcity-agent-instruction-restart-"),
|
|
306
301
|
);
|
|
307
|
-
const
|
|
302
|
+
const workspace = new Workspace({
|
|
303
|
+
id: "test_workspace",
|
|
304
|
+
path: agent_path,
|
|
305
|
+
data_root_path: path.join(agent_path, "workspace-data"),
|
|
306
|
+
});
|
|
307
|
+
const city = new City({
|
|
308
|
+
storage: new LocalStorageProvider(path.join(agent_path, "city-data")),
|
|
309
|
+
workspaces: [workspace],
|
|
310
|
+
});
|
|
311
|
+
const model = new MockModelClient({ modelId: "instruction-restart-model" });
|
|
308
312
|
const first_agent = new Agent({
|
|
309
313
|
id: "instruction_restart_agent",
|
|
310
|
-
workspace: new Workspace({ path: agent_path }),
|
|
311
314
|
model,
|
|
312
315
|
instruction: ["instruction:old"],
|
|
313
316
|
plugins: [create_plugin({
|
|
@@ -317,11 +320,13 @@ test("Session snapshot explicitly persists the complete system to instruction.md
|
|
|
317
320
|
system: () => "plugin-system:persisted",
|
|
318
321
|
})],
|
|
319
322
|
});
|
|
323
|
+
city.agents.add(first_agent);
|
|
324
|
+
const first_entry = create_workspace_entry(first_agent, workspace);
|
|
325
|
+
let session_id;
|
|
320
326
|
|
|
321
327
|
try {
|
|
322
|
-
const session = await
|
|
323
|
-
|
|
324
|
-
});
|
|
328
|
+
const session = await first_entry.sessions.create();
|
|
329
|
+
session_id = session.id;
|
|
325
330
|
const first_system = await session.system();
|
|
326
331
|
assert.match(
|
|
327
332
|
first_system.blocks.map((block) => block.content).join("\n"),
|
|
@@ -330,17 +335,14 @@ test("Session snapshot explicitly persists the complete system to instruction.md
|
|
|
330
335
|
await session.snapshot();
|
|
331
336
|
|
|
332
337
|
const instruction_path = path.join(
|
|
333
|
-
|
|
334
|
-
".downcity",
|
|
335
|
-
"agents",
|
|
336
|
-
"instruction_restart_agent",
|
|
338
|
+
city.storage.open_scope(["agents", first_agent.id]).root_path,
|
|
337
339
|
"sessions",
|
|
338
|
-
|
|
340
|
+
session_id,
|
|
339
341
|
"instruction.md",
|
|
340
342
|
);
|
|
341
343
|
const persisted_system = await fs.readFile(instruction_path, "utf8");
|
|
342
344
|
assert.match(persisted_system, /instruction:old/);
|
|
343
|
-
assert.match(persisted_system, /#
|
|
345
|
+
assert.match(persisted_system, /# Harness Design/);
|
|
344
346
|
assert.match(persisted_system, /plugin-system:persisted/);
|
|
345
347
|
assert.match(persisted_system, /Current session context:/);
|
|
346
348
|
|
|
@@ -353,13 +355,15 @@ test("Session snapshot explicitly persists the complete system to instruction.md
|
|
|
353
355
|
|
|
354
356
|
const restarted_agent = new Agent({
|
|
355
357
|
id: "instruction_restart_agent",
|
|
356
|
-
workspace: new Workspace({ path: agent_path }),
|
|
357
358
|
model,
|
|
358
359
|
instruction: ["instruction:new"],
|
|
359
360
|
});
|
|
361
|
+
city.agents.add(restarted_agent);
|
|
362
|
+
const restarted_entry = create_workspace_entry(restarted_agent, workspace);
|
|
360
363
|
try {
|
|
361
|
-
const restored_session = await
|
|
362
|
-
|
|
364
|
+
const restored_session = await restarted_entry.sessions.get(
|
|
365
|
+
session_id,
|
|
366
|
+
{ workspace },
|
|
363
367
|
);
|
|
364
368
|
const restored_system = await restored_session.system();
|
|
365
369
|
const restored_system_text = restored_system.blocks
|
|
@@ -373,25 +377,24 @@ test("Session snapshot explicitly persists the complete system to instruction.md
|
|
|
373
377
|
}
|
|
374
378
|
|
|
375
379
|
const instruction_path = path.join(
|
|
376
|
-
|
|
377
|
-
".downcity",
|
|
378
|
-
"agents",
|
|
379
|
-
"instruction_restart_agent",
|
|
380
|
+
city.storage.open_scope(["agents", "instruction_restart_agent"]).root_path,
|
|
380
381
|
"sessions",
|
|
381
|
-
|
|
382
|
+
session_id,
|
|
382
383
|
"instruction.md",
|
|
383
384
|
);
|
|
384
385
|
await fs.rm(instruction_path);
|
|
385
386
|
|
|
386
387
|
const fallback_agent = new Agent({
|
|
387
388
|
id: "instruction_restart_agent",
|
|
388
|
-
workspace: new Workspace({ path: agent_path }),
|
|
389
389
|
model,
|
|
390
390
|
instruction: ["instruction:new"],
|
|
391
391
|
});
|
|
392
|
+
city.agents.add(fallback_agent);
|
|
393
|
+
const fallback_entry = create_workspace_entry(fallback_agent, workspace);
|
|
392
394
|
try {
|
|
393
|
-
const fallback_session = await
|
|
394
|
-
|
|
395
|
+
const fallback_session = await fallback_entry.sessions.get(
|
|
396
|
+
session_id,
|
|
397
|
+
{ workspace },
|
|
395
398
|
);
|
|
396
399
|
const fallback_system = await fallback_session.system();
|
|
397
400
|
const fallback_system_text = fallback_system.blocks
|
|
@@ -401,6 +404,7 @@ test("Session snapshot explicitly persists the complete system to instruction.md
|
|
|
401
404
|
assert.doesNotMatch(fallback_system_text, /instruction:old/);
|
|
402
405
|
} finally {
|
|
403
406
|
await fallback_agent.dispose();
|
|
407
|
+
await city.close();
|
|
404
408
|
await fs.rm(agent_path, { recursive: true, force: true });
|
|
405
409
|
}
|
|
406
410
|
});
|
|
@@ -409,16 +413,26 @@ test("empty Session snapshot suppresses Agent instruction after restart", async
|
|
|
409
413
|
const agent_path = await fs.mkdtemp(
|
|
410
414
|
path.join(os.tmpdir(), "downcity-agent-empty-instruction-snapshot-"),
|
|
411
415
|
);
|
|
412
|
-
const
|
|
416
|
+
const workspace = new Workspace({
|
|
417
|
+
id: "test_workspace",
|
|
418
|
+
path: agent_path,
|
|
419
|
+
data_root_path: path.join(agent_path, "workspace-data"),
|
|
420
|
+
});
|
|
421
|
+
const city = new City({
|
|
422
|
+
storage: new LocalStorageProvider(path.join(agent_path, "city-data")),
|
|
423
|
+
workspaces: [workspace],
|
|
424
|
+
});
|
|
425
|
+
const model = new MockModelClient({ modelId: "empty-snapshot-model" });
|
|
413
426
|
const first_agent = new Agent({
|
|
414
427
|
id: "empty_snapshot_agent",
|
|
415
|
-
workspace: new Workspace({ path: agent_path }),
|
|
416
428
|
model,
|
|
417
429
|
});
|
|
430
|
+
city.agents.add(first_agent);
|
|
431
|
+
const first_entry = create_workspace_entry(first_agent, workspace);
|
|
432
|
+
let session_id;
|
|
418
433
|
try {
|
|
419
|
-
const session = await
|
|
420
|
-
|
|
421
|
-
});
|
|
434
|
+
const session = await first_entry.sessions.create();
|
|
435
|
+
session_id = session.id;
|
|
422
436
|
await session.snapshot();
|
|
423
437
|
} finally {
|
|
424
438
|
await first_agent.dispose();
|
|
@@ -426,12 +440,15 @@ test("empty Session snapshot suppresses Agent instruction after restart", async
|
|
|
426
440
|
|
|
427
441
|
const restarted_agent = new Agent({
|
|
428
442
|
id: "empty_snapshot_agent",
|
|
429
|
-
workspace: new Workspace({ path: agent_path }),
|
|
430
443
|
model,
|
|
431
444
|
instruction: ["instruction:must-not-appear"],
|
|
432
445
|
});
|
|
446
|
+
city.agents.add(restarted_agent);
|
|
447
|
+
const restarted_entry = create_workspace_entry(restarted_agent, workspace);
|
|
433
448
|
try {
|
|
434
|
-
const session = await
|
|
449
|
+
const session = await restarted_entry.sessions.get(session_id, {
|
|
450
|
+
workspace,
|
|
451
|
+
});
|
|
435
452
|
const system = await session.system();
|
|
436
453
|
assert.doesNotMatch(
|
|
437
454
|
system.blocks.map((block) => block.content).join("\n"),
|
|
@@ -439,6 +456,7 @@ test("empty Session snapshot suppresses Agent instruction after restart", async
|
|
|
439
456
|
);
|
|
440
457
|
} finally {
|
|
441
458
|
await restarted_agent.dispose();
|
|
459
|
+
await city.close();
|
|
442
460
|
await fs.rm(agent_path, { recursive: true, force: true });
|
|
443
461
|
}
|
|
444
462
|
});
|
|
@@ -451,7 +469,7 @@ test("running session model changes apply with steer at the next Session step",
|
|
|
451
469
|
const release_old_model = create_deferred();
|
|
452
470
|
const model_calls = [];
|
|
453
471
|
|
|
454
|
-
const old_model = new
|
|
472
|
+
const old_model = new MockModelClient({
|
|
455
473
|
modelId: "old-model",
|
|
456
474
|
doStream: async (options) => {
|
|
457
475
|
const has_tools = Array.isArray(options.tools) && options.tools.length > 0;
|
|
@@ -462,7 +480,7 @@ test("running session model changes apply with steer at the next Session step",
|
|
|
462
480
|
return create_stream_text_result("old response");
|
|
463
481
|
},
|
|
464
482
|
});
|
|
465
|
-
const new_model = new
|
|
483
|
+
const new_model = new MockModelClient({
|
|
466
484
|
modelId: "new-model",
|
|
467
485
|
doStream: async (options) => {
|
|
468
486
|
const has_tools = Array.isArray(options.tools) && options.tools.length > 0;
|
|
@@ -484,13 +502,13 @@ test("running session model changes apply with steer at the next Session step",
|
|
|
484
502
|
});
|
|
485
503
|
const agent = new Agent({
|
|
486
504
|
id: "session_step_boundary_agent",
|
|
487
|
-
workspace: new Workspace({ path: agent_path }),
|
|
488
505
|
model: old_model,
|
|
489
506
|
plugins: [runtime_plugin],
|
|
490
507
|
});
|
|
508
|
+
const entry = create_workspace_entry(agent, new Workspace({ id: "test_workspace", path: agent_path, data_root_path: path.join(agent_path, "data") }));
|
|
491
509
|
|
|
492
510
|
try {
|
|
493
|
-
const session = await
|
|
511
|
+
const session = await entry.sessions.create({
|
|
494
512
|
session_id: "session_step_boundary_session",
|
|
495
513
|
});
|
|
496
514
|
await session.set({ model: old_model });
|
|
@@ -525,6 +543,15 @@ test("running session model changes apply with steer at the next Session step",
|
|
|
525
543
|
);
|
|
526
544
|
assert.equal(model_actions.length, 1);
|
|
527
545
|
assert.equal(model_actions[0].status, "completed");
|
|
546
|
+
assert.equal(
|
|
547
|
+
mutations.some(
|
|
548
|
+
(mutation) =>
|
|
549
|
+
mutation.variant === "session" &&
|
|
550
|
+
mutation.type === "config" &&
|
|
551
|
+
mutation.model_label === "new-model",
|
|
552
|
+
),
|
|
553
|
+
true,
|
|
554
|
+
);
|
|
528
555
|
assert.equal(
|
|
529
556
|
mutations.some(
|
|
530
557
|
(mutation) =>
|
|
@@ -551,7 +578,7 @@ test("running session approval mode changes stay queued until the next Session s
|
|
|
551
578
|
const first_provider_request_started = create_deferred();
|
|
552
579
|
const release_first_provider_request = create_deferred();
|
|
553
580
|
let provider_request_count = 0;
|
|
554
|
-
const model = new
|
|
581
|
+
const model = new MockModelClient({
|
|
555
582
|
modelId: "approval-mode-boundary-model",
|
|
556
583
|
doStream: async (options) => {
|
|
557
584
|
const has_tools = Array.isArray(options.tools) && options.tools.length > 0;
|
|
@@ -577,13 +604,13 @@ test("running session approval mode changes stay queued until the next Session s
|
|
|
577
604
|
});
|
|
578
605
|
const agent = new Agent({
|
|
579
606
|
id: "approval_mode_boundary_agent",
|
|
580
|
-
workspace: new Workspace({ path: agent_path }),
|
|
581
607
|
model,
|
|
582
608
|
plugins: [runtime_plugin],
|
|
583
609
|
});
|
|
610
|
+
const entry = create_workspace_entry(agent, new Workspace({ id: "test_workspace", path: agent_path, data_root_path: path.join(agent_path, "data") }));
|
|
584
611
|
|
|
585
612
|
try {
|
|
586
|
-
const session = await
|
|
613
|
+
const session = await entry.sessions.create({
|
|
587
614
|
session_id: "approval_mode_boundary_session",
|
|
588
615
|
});
|
|
589
616
|
const first_turn = await session.prompt({ query: "first" });
|
|
@@ -600,7 +627,7 @@ test("running session approval mode changes stay queued until the next Session s
|
|
|
600
627
|
},
|
|
601
628
|
});
|
|
602
629
|
|
|
603
|
-
const cached_session = await
|
|
630
|
+
const cached_session = await entry.sessions.get(session.id);
|
|
604
631
|
assert.equal(cached_session, session);
|
|
605
632
|
assert.deepEqual(await cached_session.status(), {
|
|
606
633
|
session_id: session.id,
|
|
@@ -655,22 +682,22 @@ test("session set options independently control Action persistence and Mutation
|
|
|
655
682
|
const agent_path = await fs.mkdtemp(
|
|
656
683
|
path.join(os.tmpdir(), "downcity-session-set-options-"),
|
|
657
684
|
);
|
|
658
|
-
const first_model = new
|
|
685
|
+
const first_model = new MockModelClient({
|
|
659
686
|
modelId: "set-options-first-model",
|
|
660
687
|
doStream: async () => create_stream_text_result("first"),
|
|
661
688
|
});
|
|
662
|
-
const second_model = new
|
|
689
|
+
const second_model = new MockModelClient({
|
|
663
690
|
modelId: "set-options-second-model",
|
|
664
691
|
doStream: async () => create_stream_text_result("second"),
|
|
665
692
|
});
|
|
666
693
|
const agent = new Agent({
|
|
667
694
|
id: "session_set_options_agent",
|
|
668
|
-
workspace: new Workspace({ path: agent_path }),
|
|
669
695
|
model: first_model,
|
|
670
696
|
});
|
|
697
|
+
const entry = create_workspace_entry(agent, new Workspace({ id: "test_workspace", path: agent_path, data_root_path: path.join(agent_path, "data") }));
|
|
671
698
|
|
|
672
699
|
try {
|
|
673
|
-
const session = await
|
|
700
|
+
const session = await entry.sessions.create({
|
|
674
701
|
session_id: "session_set_options_session",
|
|
675
702
|
});
|
|
676
703
|
const mutations = [];
|
|
@@ -749,20 +776,30 @@ test("restored Session rebinds the same model without emitting a configuration M
|
|
|
749
776
|
const agent_path = await fs.mkdtemp(
|
|
750
777
|
path.join(os.tmpdir(), "downcity-session-config-restore-"),
|
|
751
778
|
);
|
|
752
|
-
const
|
|
779
|
+
const workspace = new Workspace({
|
|
780
|
+
id: "test_workspace",
|
|
781
|
+
path: agent_path,
|
|
782
|
+
data_root_path: path.join(agent_path, "workspace-data"),
|
|
783
|
+
});
|
|
784
|
+
const city = new City({
|
|
785
|
+
storage: new LocalStorageProvider(path.join(agent_path, "city-data")),
|
|
786
|
+
workspaces: [workspace],
|
|
787
|
+
});
|
|
788
|
+
const create_model = () => new MockModelClient({
|
|
753
789
|
modelId: "restored-session-model",
|
|
754
790
|
doStream: async () => create_stream_text_result("restored"),
|
|
755
791
|
});
|
|
756
792
|
const first_agent = new Agent({
|
|
757
793
|
id: "session_config_restore_agent",
|
|
758
|
-
workspace: new Workspace({ path: agent_path }),
|
|
759
794
|
model: create_model(),
|
|
760
795
|
});
|
|
796
|
+
city.agents.add(first_agent);
|
|
797
|
+
const first_entry = create_workspace_entry(first_agent, workspace);
|
|
798
|
+
let session_id;
|
|
761
799
|
|
|
762
800
|
try {
|
|
763
|
-
const session = await
|
|
764
|
-
|
|
765
|
-
});
|
|
801
|
+
const session = await first_entry.sessions.create();
|
|
802
|
+
session_id = session.id;
|
|
766
803
|
await session.set({
|
|
767
804
|
model: create_model(),
|
|
768
805
|
security: { approval_mode: "always-allow" },
|
|
@@ -774,12 +811,14 @@ test("restored Session rebinds the same model without emitting a configuration M
|
|
|
774
811
|
|
|
775
812
|
const restored_agent = new Agent({
|
|
776
813
|
id: "session_config_restore_agent",
|
|
777
|
-
workspace: new Workspace({ path: agent_path }),
|
|
778
814
|
model: create_model(),
|
|
779
815
|
});
|
|
816
|
+
city.agents.add(restored_agent);
|
|
817
|
+
const restored_entry = create_workspace_entry(restored_agent, workspace);
|
|
780
818
|
try {
|
|
781
|
-
const session = await
|
|
782
|
-
|
|
819
|
+
const session = await restored_entry.sessions.get(
|
|
820
|
+
session_id,
|
|
821
|
+
{ workspace },
|
|
783
822
|
);
|
|
784
823
|
assert.deepEqual((await session.status()).security, {
|
|
785
824
|
approval_mode: "always-allow",
|
|
@@ -820,6 +859,7 @@ test("restored Session rebinds the same model without emitting a configuration M
|
|
|
820
859
|
unsubscribe();
|
|
821
860
|
} finally {
|
|
822
861
|
await restored_agent.dispose();
|
|
862
|
+
await city.close();
|
|
823
863
|
await fs.rm(agent_path, { recursive: true, force: true });
|
|
824
864
|
}
|
|
825
865
|
});
|
|
@@ -829,14 +869,14 @@ test("config remains effective when its action message cannot be persisted", asy
|
|
|
829
869
|
path.join(os.tmpdir(), "downcity-config-action-observability-"),
|
|
830
870
|
);
|
|
831
871
|
const model_calls = [];
|
|
832
|
-
const old_model = new
|
|
872
|
+
const old_model = new MockModelClient({
|
|
833
873
|
modelId: "old-observability-model",
|
|
834
874
|
doStream: async () => {
|
|
835
875
|
model_calls.push("old");
|
|
836
876
|
return create_stream_text_result("old");
|
|
837
877
|
},
|
|
838
878
|
});
|
|
839
|
-
const new_model = new
|
|
879
|
+
const new_model = new MockModelClient({
|
|
840
880
|
modelId: "new-observability-model",
|
|
841
881
|
doStream: async () => {
|
|
842
882
|
model_calls.push("new");
|
|
@@ -845,12 +885,12 @@ test("config remains effective when its action message cannot be persisted", asy
|
|
|
845
885
|
});
|
|
846
886
|
const agent = new Agent({
|
|
847
887
|
id: "config_action_observability_agent",
|
|
848
|
-
workspace: new Workspace({ path: agent_path }),
|
|
849
888
|
model: old_model,
|
|
850
889
|
});
|
|
890
|
+
const entry = create_workspace_entry(agent, new Workspace({ id: "test_workspace", path: agent_path, data_root_path: path.join(agent_path, "data") }));
|
|
851
891
|
|
|
852
892
|
try {
|
|
853
|
-
const session = await
|
|
893
|
+
const session = await entry.sessions.create({
|
|
854
894
|
session_id: "config_action_observability_session",
|
|
855
895
|
});
|
|
856
896
|
await session.set({ model: old_model });
|
|
@@ -861,7 +901,7 @@ test("config remains effective when its action message cannot be persisted", asy
|
|
|
861
901
|
(message) => message.type === "action",
|
|
862
902
|
).length;
|
|
863
903
|
|
|
864
|
-
session.session_messages.
|
|
904
|
+
session.session_messages.persist_action = async () => {
|
|
865
905
|
throw new Error("action store unavailable");
|
|
866
906
|
};
|
|
867
907
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file 验证 Plugin 动态 Interaction 不依赖核心固定业务联合体。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { JsonlSessionMessageStore } from "../bin/workspace/store/JsonlSessionMessageStore.js";
|
|
11
|
+
import { LocalFileSystem } from "@downcity/workspace";
|
|
12
|
+
import { SessionMessages } from "../bin/session/SessionMessages.js";
|
|
13
|
+
import { SessionInteractions } from "../bin/session/control/SessionInteractions.js";
|
|
14
|
+
|
|
15
|
+
test("动态 Plugin Interaction 使用通用 type/payload 完成恢复", async () => {
|
|
16
|
+
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-dynamic-interaction-"));
|
|
17
|
+
const recorder = new SessionMessages({
|
|
18
|
+
session_id: "dynamic-interaction-test",
|
|
19
|
+
store: new JsonlSessionMessageStore({
|
|
20
|
+
files: new LocalFileSystem(root_path),
|
|
21
|
+
session_id: "dynamic-interaction-test",
|
|
22
|
+
file_path: path.join(root_path, "active.jsonl"),
|
|
23
|
+
}),
|
|
24
|
+
publish: () => {},
|
|
25
|
+
});
|
|
26
|
+
await recorder.initialize();
|
|
27
|
+
const interactions = new SessionInteractions({
|
|
28
|
+
session_id: "dynamic-interaction-test",
|
|
29
|
+
messages: recorder,
|
|
30
|
+
});
|
|
31
|
+
const writer = await recorder.open_assistant_message({ turn_id: "turn-1" });
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const handle = await interactions.request({
|
|
35
|
+
interaction_id: "interaction:deploy-confirm",
|
|
36
|
+
turn_id: "turn-1",
|
|
37
|
+
type: "plugin:deployment/confirm",
|
|
38
|
+
source: {
|
|
39
|
+
type: "plugin",
|
|
40
|
+
plugin_name: "deployment",
|
|
41
|
+
},
|
|
42
|
+
title: "确认发布",
|
|
43
|
+
payload: {
|
|
44
|
+
environment: "production",
|
|
45
|
+
version: "2026.08.24",
|
|
46
|
+
},
|
|
47
|
+
response_schema: {
|
|
48
|
+
type: "object",
|
|
49
|
+
required: ["decision"],
|
|
50
|
+
},
|
|
51
|
+
created_at: Date.now(),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
assert.deepEqual((await interactions.list())[0].request.payload, {
|
|
55
|
+
environment: "production",
|
|
56
|
+
version: "2026.08.24",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const result = await interactions.respond({
|
|
60
|
+
interaction_id: handle.interaction_id,
|
|
61
|
+
response: {
|
|
62
|
+
type: "plugin:deployment/confirm",
|
|
63
|
+
outcome: "resolved",
|
|
64
|
+
payload: { decision: "confirmed" },
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
assert.deepEqual(await handle.result, result);
|
|
69
|
+
assert.equal(result.status, "resolved");
|
|
70
|
+
assert.deepEqual(result.response.payload, { decision: "confirmed" });
|
|
71
|
+
assert.equal(recorder.get_message(writer.message_id).parts[0].status, "resolved");
|
|
72
|
+
} finally {
|
|
73
|
+
await fs.rm(root_path, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
});
|