@downcity/agent 1.1.237 → 1.1.258
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 +21 -20
- package/bin/agent/{local/Agent.d.ts → Agent.d.ts} +37 -27
- package/bin/agent/Agent.d.ts.map +1 -0
- package/bin/agent/Agent.js +211 -0
- package/bin/agent/Agent.js.map +1 -0
- package/bin/agent/AgentContext.d.ts +64 -0
- package/bin/agent/AgentContext.d.ts.map +1 -0
- package/bin/agent/AgentContext.js +53 -0
- package/bin/agent/AgentContext.js.map +1 -0
- package/bin/agent/{local/AgentInstructions.d.ts → AgentInstructions.d.ts} +1 -6
- package/bin/agent/AgentInstructions.d.ts.map +1 -0
- package/bin/agent/{local/AgentInstructions.js → AgentInstructions.js} +1 -10
- package/bin/agent/AgentInstructions.js.map +1 -0
- package/bin/{model/CityModelAdapter.d.ts → agent/AgentModel.d.ts} +3 -3
- package/bin/agent/AgentModel.d.ts.map +1 -0
- package/bin/{model/CityModelAdapter.js → agent/AgentModel.js} +11 -4
- package/bin/agent/AgentModel.js.map +1 -0
- package/bin/agent/{local/services/AgentSessions.d.ts → AgentSessions.d.ts} +30 -40
- package/bin/agent/AgentSessions.d.ts.map +1 -0
- package/bin/agent/{local/services/AgentSessions.js → AgentSessions.js} +62 -79
- package/bin/agent/AgentSessions.js.map +1 -0
- package/bin/agent/AgentState.d.ts +64 -0
- package/bin/agent/AgentState.d.ts.map +1 -0
- package/bin/agent/AgentState.js +118 -0
- package/bin/agent/AgentState.js.map +1 -0
- package/bin/config/Paths.d.ts +0 -43
- package/bin/config/Paths.d.ts.map +1 -1
- package/bin/config/Paths.js +0 -79
- package/bin/config/Paths.js.map +1 -1
- package/bin/config/ProjectSetup.d.ts.map +1 -0
- package/bin/{agent/local → config}/ProjectSetup.js +1 -1
- package/bin/config/ProjectSetup.js.map +1 -0
- package/bin/executor/Executor.d.ts +20 -86
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +109 -260
- package/bin/executor/Executor.js.map +1 -1
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.d.ts +1 -1
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.d.ts.map +1 -1
- package/bin/executor/composer/system/default/SystemDomain.d.ts +1 -1
- package/bin/executor/composer/system/default/SystemDomain.d.ts.map +1 -1
- package/bin/executor/composer/system/default/SystemDomain.js +4 -1
- package/bin/executor/composer/system/default/SystemDomain.js.map +1 -1
- 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/core-engine/CoreEngineRunner.d.ts +7 -13
- package/bin/executor/core-engine/CoreEngineRunner.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.js +81 -34
- package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts +6 -12
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts.map +1 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.js +20 -6
- package/bin/executor/services/ExecutorRecoveryPolicy.js.map +1 -1
- package/bin/executor/tools/file/ReadImageToolBridge.d.ts +21 -0
- package/bin/executor/tools/file/ReadImageToolBridge.d.ts.map +1 -0
- package/bin/executor/tools/file/ReadImageToolBridge.js +69 -0
- package/bin/executor/tools/file/ReadImageToolBridge.js.map +1 -0
- package/bin/executor/tools/plugin/PluginToolBridge.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolBridge.js +6 -5
- package/bin/executor/tools/plugin/PluginToolBridge.js.map +1 -1
- package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolDefinition.js +15 -2
- package/bin/executor/tools/plugin/PluginToolDefinition.js.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.d.ts +0 -2
- package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
- package/bin/index.d.ts +17 -21
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +9 -11
- package/bin/index.js.map +1 -1
- package/bin/plugin/core/ActionScheduleExecutor.d.ts +1 -1
- package/bin/plugin/core/ActionScheduleExecutor.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleRuntime.d.ts +1 -1
- package/bin/plugin/core/ActionScheduleRuntime.d.ts.map +1 -1
- package/bin/plugin/core/BasePlugin.d.ts +4 -3
- package/bin/plugin/core/BasePlugin.d.ts.map +1 -1
- package/bin/plugin/core/BasePlugin.js.map +1 -1
- package/bin/plugin/core/HookRegistry.d.ts +5 -8
- package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
- package/bin/plugin/core/HookRegistry.js +12 -12
- package/bin/plugin/core/HookRegistry.js.map +1 -1
- 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.map +1 -1
- package/bin/plugin/core/PluginActionRunner.d.ts +1 -1
- package/bin/plugin/core/PluginActionRunner.d.ts.map +1 -1
- package/bin/plugin/core/PluginCatalog.d.ts +1 -1
- package/bin/plugin/core/PluginCatalog.d.ts.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/PluginLocalExecution.d.ts +4 -5
- package/bin/plugin/core/PluginLocalExecution.d.ts.map +1 -1
- package/bin/plugin/core/PluginLocalExecution.js +4 -12
- package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts +16 -12
- package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
- package/bin/plugin/core/PluginRegistry.js +43 -22
- package/bin/plugin/core/PluginRegistry.js.map +1 -1
- package/bin/plugin/core/PluginStateController.d.ts +1 -1
- package/bin/plugin/core/PluginStateController.d.ts.map +1 -1
- package/bin/{agent/remote → remote}/RemoteAgent.d.ts +4 -4
- package/bin/remote/RemoteAgent.d.ts.map +1 -0
- package/bin/{agent/remote → remote}/RemoteAgent.js +3 -3
- package/bin/remote/RemoteAgent.js.map +1 -0
- package/bin/{agent/remote → remote}/RemoteSession.d.ts +9 -11
- package/bin/remote/RemoteSession.d.ts.map +1 -0
- package/bin/{agent/remote → remote}/RemoteSession.js +3 -33
- package/bin/remote/RemoteSession.js.map +1 -0
- package/bin/{agent/remote → remote}/RemoteTransport.d.ts +7 -9
- package/bin/remote/RemoteTransport.d.ts.map +1 -0
- package/bin/remote/RemoteTransport.js.map +1 -0
- package/bin/{agent/remote → remote}/TransportFactory.d.ts +1 -1
- package/bin/remote/TransportFactory.d.ts.map +1 -0
- package/bin/{agent/remote → remote}/TransportFactory.js +2 -2
- package/bin/remote/TransportFactory.js.map +1 -0
- package/bin/{agent/remote → remote}/transports/HttpRemoteAgentTransport.d.ts +8 -9
- package/bin/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -0
- package/bin/{agent/remote → remote}/transports/HttpRemoteAgentTransport.js +0 -13
- package/bin/remote/transports/HttpRemoteAgentTransport.js.map +1 -0
- package/bin/{rpc/Client.d.ts → remote/transports/RpcClient.d.ts} +15 -22
- package/bin/remote/transports/RpcClient.d.ts.map +1 -0
- package/bin/{rpc/Client.js → remote/transports/RpcClient.js} +2 -13
- package/bin/remote/transports/RpcClient.js.map +1 -0
- package/bin/{agent/remote → remote}/transports/RpcRemoteAgentTransport.d.ts +8 -9
- package/bin/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -0
- package/bin/{agent/remote → remote}/transports/RpcRemoteAgentTransport.js +1 -4
- package/bin/remote/transports/RpcRemoteAgentTransport.js.map +1 -0
- package/bin/session/DefaultSessionComposer.d.ts +18 -0
- package/bin/session/DefaultSessionComposer.d.ts.map +1 -0
- package/bin/session/DefaultSessionComposer.js +62 -0
- package/bin/session/DefaultSessionComposer.js.map +1 -0
- package/bin/session/Session.d.ts +44 -33
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +440 -274
- package/bin/session/Session.js.map +1 -1
- package/bin/session/SessionMessages.d.ts +117 -0
- package/bin/session/SessionMessages.d.ts.map +1 -0
- package/bin/session/{recorder/SessionRecorder.js → SessionMessages.js} +194 -284
- package/bin/session/SessionMessages.js.map +1 -0
- package/bin/session/SessionQueue.d.ts +34 -0
- package/bin/session/SessionQueue.d.ts.map +1 -0
- package/bin/session/SessionQueue.js +60 -0
- package/bin/session/SessionQueue.js.map +1 -0
- package/bin/session/SessionState.d.ts +70 -0
- package/bin/session/SessionState.d.ts.map +1 -0
- package/bin/session/SessionState.js +267 -0
- package/bin/session/SessionState.js.map +1 -0
- package/bin/session/SessionSystem.d.ts +15 -0
- package/bin/session/SessionSystem.d.ts.map +1 -0
- package/bin/session/SessionSystem.js +95 -0
- package/bin/session/SessionSystem.js.map +1 -0
- package/bin/session/SessionTurn.d.ts +84 -0
- package/bin/session/SessionTurn.d.ts.map +1 -0
- package/bin/session/SessionTurn.js +588 -0
- package/bin/session/SessionTurn.js.map +1 -0
- package/bin/session/approval/SessionApprovalBroker.d.ts +48 -0
- package/bin/session/approval/SessionApprovalBroker.d.ts.map +1 -0
- package/bin/session/approval/SessionApprovalBroker.js +126 -0
- package/bin/session/approval/SessionApprovalBroker.js.map +1 -0
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +1 -4
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/{recorder → messages}/JsonlSessionMessageStore.d.ts.map +1 -1
- package/bin/session/{recorder → messages}/JsonlSessionMessageStore.js.map +1 -1
- package/bin/session/messages/SessionAssistantMessageWriter.d.ts +62 -0
- package/bin/session/messages/SessionAssistantMessageWriter.d.ts.map +1 -0
- package/bin/session/messages/SessionAssistantMessageWriter.js +287 -0
- package/bin/session/messages/SessionAssistantMessageWriter.js.map +1 -0
- package/bin/session/messages/SessionJsonValue.d.ts +10 -0
- package/bin/session/messages/SessionJsonValue.d.ts.map +1 -0
- package/bin/session/messages/SessionJsonValue.js +23 -0
- package/bin/session/messages/SessionJsonValue.js.map +1 -0
- package/bin/session/{recorder → messages}/SessionMessageCodec.d.ts +4 -1
- package/bin/session/messages/SessionMessageCodec.d.ts.map +1 -0
- package/bin/session/{recorder → messages}/SessionMessageCodec.js +33 -19
- package/bin/session/messages/SessionMessageCodec.js.map +1 -0
- package/bin/session/messages/SessionMessageCompaction.d.ts +22 -0
- package/bin/session/messages/SessionMessageCompaction.d.ts.map +1 -0
- package/bin/session/{recorder/SessionRecorderCompaction.js → messages/SessionMessageCompaction.js} +19 -51
- package/bin/session/messages/SessionMessageCompaction.js.map +1 -0
- package/bin/session/runtime/SessionEventHub.d.ts +1 -8
- package/bin/session/runtime/SessionEventHub.d.ts.map +1 -1
- package/bin/session/runtime/SessionEventHub.js +1 -6
- package/bin/session/runtime/SessionEventHub.js.map +1 -1
- package/bin/session/storage/Metadata.d.ts +23 -5
- package/bin/session/storage/Metadata.d.ts.map +1 -1
- package/bin/session/storage/Metadata.js +32 -29
- package/bin/session/storage/Metadata.js.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.d.ts +5 -10
- package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.js +2 -4
- package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
- package/bin/types/agent/AgentOptions.d.ts +6 -35
- package/bin/types/agent/AgentOptions.d.ts.map +1 -1
- package/bin/types/agent/AgentState.d.ts +28 -0
- package/bin/types/agent/AgentState.d.ts.map +1 -0
- package/bin/types/agent/AgentState.js +9 -0
- package/bin/types/agent/AgentState.js.map +1 -0
- package/bin/types/agent/SessionActor.d.ts +0 -2
- package/bin/types/agent/SessionActor.d.ts.map +1 -1
- package/bin/types/agent/SessionTypes.d.ts +5 -18
- package/bin/types/agent/SessionTypes.d.ts.map +1 -1
- package/bin/types/executor/SessionRunContext.d.ts +8 -2
- package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
- package/bin/types/executor/SessionRunContext.js +1 -1
- package/bin/types/executor/SessionToolExecutionContext.d.ts +20 -0
- package/bin/types/executor/SessionToolExecutionContext.d.ts.map +1 -0
- package/bin/types/executor/SessionToolExecutionContext.js +10 -0
- package/bin/types/executor/SessionToolExecutionContext.js.map +1 -0
- package/bin/types/plugin/PluginAction.d.ts +10 -1
- package/bin/types/plugin/PluginAction.d.ts.map +1 -1
- package/bin/types/plugin/PluginCommand.d.ts +3 -11
- package/bin/types/plugin/PluginCommand.d.ts.map +1 -1
- package/bin/types/plugin/PluginConfig.d.ts +12 -0
- package/bin/types/plugin/PluginConfig.d.ts.map +1 -0
- package/bin/types/plugin/PluginConfig.js +5 -0
- package/bin/types/plugin/PluginConfig.js.map +1 -0
- package/bin/types/plugin/PluginDefinition.d.ts +10 -3
- package/bin/types/plugin/PluginDefinition.d.ts.map +1 -1
- package/bin/types/plugin/PluginHttp.d.ts +1 -1
- package/bin/types/plugin/PluginHttp.d.ts.map +1 -1
- package/bin/types/plugin/PluginRunContext.d.ts +26 -0
- package/bin/types/plugin/PluginRunContext.d.ts.map +1 -0
- package/bin/types/plugin/PluginRunContext.js +10 -0
- package/bin/types/plugin/PluginRunContext.js.map +1 -0
- package/bin/types/plugin/PluginRuntime.d.ts +9 -3
- package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
- package/bin/types/plugin/PluginToolRuntime.d.ts +11 -0
- package/bin/types/plugin/PluginToolRuntime.d.ts.map +1 -1
- package/bin/types/rpc/RpcProtocol.d.ts +1 -13
- package/bin/types/rpc/RpcProtocol.d.ts.map +1 -1
- package/bin/types/session/SessionApproval.d.ts +4 -38
- package/bin/types/session/SessionApproval.d.ts.map +1 -1
- package/bin/types/session/SessionApprovalBroker.d.ts +17 -0
- package/bin/types/session/SessionApprovalBroker.d.ts.map +1 -0
- package/bin/types/session/SessionApprovalBroker.js +7 -0
- package/bin/types/session/SessionApprovalBroker.js.map +1 -0
- package/bin/types/session/SessionComposer.d.ts +99 -0
- package/bin/types/session/SessionComposer.d.ts.map +1 -0
- package/bin/types/session/SessionComposer.js +8 -0
- package/bin/types/session/SessionComposer.js.map +1 -0
- package/bin/types/session/SessionLocalState.d.ts +6 -6
- package/bin/types/session/SessionLocalState.d.ts.map +1 -1
- package/bin/types/session/SessionLocalState.js +1 -1
- package/bin/types/session/SessionMessage.d.ts +3 -2
- package/bin/types/session/SessionMessage.d.ts.map +1 -1
- package/bin/types/session/SessionMessages.d.ts +115 -0
- package/bin/types/session/SessionMessages.d.ts.map +1 -0
- package/bin/types/session/SessionMessages.js +7 -0
- package/bin/types/session/SessionMessages.js.map +1 -0
- package/bin/types/session/SessionMutation.d.ts +1 -10
- 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 +8 -23
- package/bin/types/session/SessionOptions.d.ts.map +1 -1
- package/bin/types/session/SessionPort.d.ts +72 -0
- package/bin/types/session/SessionPort.d.ts.map +1 -0
- package/bin/types/session/SessionPort.js +9 -0
- package/bin/types/session/SessionPort.js.map +1 -0
- package/bin/types/session/SessionQueue.d.ts +104 -0
- package/bin/types/session/SessionQueue.d.ts.map +1 -0
- package/bin/types/session/SessionQueue.js +7 -0
- package/bin/types/session/SessionQueue.js.map +1 -0
- package/bin/types/session/SessionState.d.ts +43 -0
- package/bin/types/session/SessionState.d.ts.map +1 -0
- package/bin/types/session/SessionState.js +7 -0
- package/bin/types/session/SessionState.js.map +1 -0
- package/bin/types/session/SessionSystem.d.ts +26 -0
- package/bin/types/session/SessionSystem.d.ts.map +1 -0
- package/bin/types/session/SessionSystem.js +7 -0
- package/bin/types/session/SessionSystem.js.map +1 -0
- package/bin/types/session/SessionTool.d.ts +23 -0
- package/bin/types/session/SessionTool.d.ts.map +1 -0
- package/bin/types/session/SessionTool.js +7 -0
- package/bin/types/session/SessionTool.js.map +1 -0
- package/bin/types/session/SessionTurn.d.ts +52 -0
- package/bin/types/session/SessionTurn.d.ts.map +1 -0
- package/bin/types/session/SessionTurn.js +7 -0
- package/bin/types/session/SessionTurn.js.map +1 -0
- package/package.json +3 -3
- package/scripts/agent-env.test.mjs +4 -18
- package/scripts/agent-ready.test.mjs +33 -2
- package/scripts/agent-session-maintenance.test.mjs +52 -0
- package/scripts/city-model-tool-loop.test.mjs +3 -4
- package/scripts/core-engine-context-compaction.test.mjs +5 -22
- package/scripts/image-plugin-job.test.mjs +4 -6
- package/scripts/plugin-tool-bridge.test.mjs +44 -36
- package/scripts/read-image-tool-bridge.test.mjs +71 -0
- package/scripts/remote-session-reconnect.test.mjs +1 -34
- package/scripts/session-compaction-prompts.test.mjs +1 -49
- package/scripts/session-composer.test.mjs +163 -0
- package/scripts/session-config-turn-boundary.test.mjs +2 -5
- package/scripts/session-list-title.test.mjs +3 -2
- package/scripts/session-messages-error.test.mjs +57 -0
- package/scripts/{session-recorder.test.mjs → session-messages.test.mjs} +131 -90
- package/scripts/session-queue.test.mjs +64 -0
- package/scripts/session-shell-approval.test.mjs +171 -0
- package/scripts/session-system-blocks.test.mjs +10 -10
- package/scripts/session-title-event.test.mjs +1 -0
- package/src/agent/Agent.ts +241 -0
- package/src/agent/AgentContext.ts +92 -0
- package/src/agent/{local/AgentInstructions.ts → AgentInstructions.ts} +0 -11
- package/src/{model/CityModelAdapter.ts → agent/AgentModel.ts} +10 -3
- package/src/agent/{local/services/AgentSessions.ts → AgentSessions.ts} +81 -110
- package/src/agent/AgentState.ts +151 -0
- package/src/config/Paths.ts +0 -91
- package/src/executor/Executor.ts +180 -386
- package/src/executor/README.md +29 -89
- package/src/executor/composer/system/default/DefaultSessionSystemComposer.ts +1 -1
- package/src/executor/composer/system/default/SystemDomain.ts +4 -2
- package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/core.prompt.ts.txt +15 -2
- package/src/executor/core-engine/CoreEngineRunner.ts +95 -54
- package/src/executor/services/ExecutorRecoveryPolicy.ts +24 -19
- package/src/executor/tools/file/ReadImageToolBridge.ts +79 -0
- package/src/executor/tools/plugin/PluginToolBridge.ts +6 -8
- package/src/executor/tools/plugin/PluginToolDefinition.ts +23 -3
- package/src/executor/types/SessionHistoryMeta.ts +0 -2
- package/src/index.ts +34 -53
- package/src/plugin/core/ActionScheduleExecutor.ts +1 -1
- package/src/plugin/core/ActionScheduleRuntime.ts +1 -1
- package/src/plugin/core/BasePlugin.ts +7 -3
- package/src/plugin/core/HookRegistry.ts +15 -18
- package/src/plugin/core/PluginActionFactory.ts +9 -3
- package/src/plugin/core/PluginActionRunner.ts +1 -1
- package/src/plugin/core/PluginCatalog.ts +1 -1
- package/src/plugin/core/PluginHttpRoutes.ts +1 -1
- package/src/plugin/core/PluginLocalExecution.ts +11 -24
- package/src/plugin/core/PluginRegistry.ts +55 -32
- package/src/plugin/core/PluginStateController.ts +1 -1
- package/src/{agent/remote → remote}/RemoteAgent.ts +4 -4
- package/src/{agent/remote → remote}/RemoteSession.ts +2 -35
- package/src/{agent/remote → remote}/RemoteTransport.ts +0 -3
- package/src/{agent/remote → remote}/TransportFactory.ts +3 -3
- package/src/{agent/remote → remote}/transports/HttpRemoteAgentTransport.ts +1 -23
- package/src/{rpc/Client.ts → remote/transports/RpcClient.ts} +1 -19
- package/src/{agent/remote → remote}/transports/RpcRemoteAgentTransport.ts +2 -10
- package/src/session/DefaultSessionComposer.ts +79 -0
- package/src/session/Session.ts +496 -332
- package/src/session/{recorder/SessionRecorder.ts → SessionMessages.ts} +254 -428
- package/src/session/SessionQueue.ts +86 -0
- package/src/session/SessionState.ts +322 -0
- package/src/session/SessionSystem.ts +117 -0
- package/src/session/SessionTurn.ts +684 -0
- package/src/session/approval/SessionApprovalBroker.ts +164 -0
- package/src/session/browse/Browse.ts +1 -4
- package/src/session/messages/SessionAssistantMessageWriter.ts +345 -0
- package/src/session/messages/SessionJsonValue.ts +25 -0
- package/src/session/{recorder → messages}/SessionMessageCodec.ts +38 -20
- package/src/session/{recorder/SessionRecorderCompaction.ts → messages/SessionMessageCompaction.ts} +30 -69
- package/src/session/runtime/SessionEventHub.ts +1 -14
- package/src/session/storage/Metadata.ts +60 -34
- package/src/session/storage/RuntimeSessionPort.ts +7 -14
- package/src/types/agent/AgentOptions.ts +6 -38
- package/src/types/agent/AgentState.ts +33 -0
- package/src/types/agent/SessionActor.ts +0 -3
- package/src/types/agent/SessionTypes.ts +5 -18
- package/src/types/executor/SessionRunContext.ts +10 -2
- package/src/types/executor/SessionToolExecutionContext.ts +21 -0
- package/src/types/plugin/PluginAction.ts +10 -1
- package/src/types/plugin/PluginCommand.ts +3 -14
- package/src/types/plugin/PluginConfig.ts +13 -0
- package/src/types/plugin/PluginDefinition.ts +13 -6
- package/src/types/plugin/PluginHttp.ts +1 -1
- package/src/types/plugin/PluginRunContext.ts +31 -0
- package/src/types/plugin/PluginRuntime.ts +13 -6
- package/src/types/plugin/PluginToolRuntime.ts +13 -1
- package/src/types/rpc/RpcProtocol.ts +0 -14
- package/src/types/session/SessionApproval.ts +4 -43
- package/src/types/session/SessionApprovalBroker.ts +18 -0
- package/src/types/session/SessionComposer.ts +114 -0
- package/src/types/session/SessionLocalState.ts +6 -6
- package/src/types/session/SessionMessage.ts +3 -2
- package/src/types/session/SessionMessages.ts +127 -0
- package/src/types/session/SessionMutation.ts +0 -11
- package/src/types/session/SessionOptions.ts +8 -40
- package/src/types/session/SessionPort.ts +97 -0
- package/src/types/session/SessionQueue.ts +122 -0
- package/src/types/session/SessionState.ts +47 -0
- package/src/types/session/SessionSystem.ts +27 -0
- package/src/types/session/SessionTool.ts +25 -0
- package/src/types/session/SessionTurn.ts +56 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/agent/local/Agent.d.ts.map +0 -1
- package/bin/agent/local/Agent.js +0 -216
- package/bin/agent/local/Agent.js.map +0 -1
- package/bin/agent/local/AgentInstructions.d.ts.map +0 -1
- package/bin/agent/local/AgentInstructions.js.map +0 -1
- package/bin/agent/local/AgentPluginFactory.d.ts +0 -26
- package/bin/agent/local/AgentPluginFactory.d.ts.map +0 -1
- package/bin/agent/local/AgentPluginFactory.js +0 -33
- package/bin/agent/local/AgentPluginFactory.js.map +0 -1
- package/bin/agent/local/AgentRuntimeAssembly.d.ts +0 -10
- package/bin/agent/local/AgentRuntimeAssembly.d.ts.map +0 -1
- package/bin/agent/local/AgentRuntimeAssembly.js +0 -43
- package/bin/agent/local/AgentRuntimeAssembly.js.map +0 -1
- package/bin/agent/local/ProjectSetup.d.ts.map +0 -1
- package/bin/agent/local/ProjectSetup.js.map +0 -1
- package/bin/agent/local/services/AgentAssemblyService.d.ts +0 -105
- package/bin/agent/local/services/AgentAssemblyService.d.ts.map +0 -1
- package/bin/agent/local/services/AgentAssemblyService.js +0 -184
- package/bin/agent/local/services/AgentAssemblyService.js.map +0 -1
- package/bin/agent/local/services/AgentBackgroundService.d.ts +0 -55
- package/bin/agent/local/services/AgentBackgroundService.d.ts.map +0 -1
- package/bin/agent/local/services/AgentBackgroundService.js +0 -85
- package/bin/agent/local/services/AgentBackgroundService.js.map +0 -1
- package/bin/agent/local/services/AgentSessions.d.ts.map +0 -1
- package/bin/agent/local/services/AgentSessions.js.map +0 -1
- package/bin/agent/remote/RemoteAgent.d.ts.map +0 -1
- package/bin/agent/remote/RemoteAgent.js.map +0 -1
- package/bin/agent/remote/RemoteSession.d.ts.map +0 -1
- package/bin/agent/remote/RemoteSession.js.map +0 -1
- package/bin/agent/remote/RemoteTransport.d.ts.map +0 -1
- package/bin/agent/remote/RemoteTransport.js.map +0 -1
- package/bin/agent/remote/TransportFactory.d.ts.map +0 -1
- package/bin/agent/remote/TransportFactory.js.map +0 -1
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +0 -1
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +0 -1
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts.map +0 -1
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.js.map +0 -1
- package/bin/executor/SessionRunScope.d.ts +0 -68
- package/bin/executor/SessionRunScope.d.ts.map +0 -1
- package/bin/executor/SessionRunScope.js +0 -96
- package/bin/executor/SessionRunScope.js.map +0 -1
- package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts +0 -74
- package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts.map +0 -1
- package/bin/executor/composer/compaction/SessionCompactionComposer.js +0 -9
- package/bin/executor/composer/compaction/SessionCompactionComposer.js.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.d.ts +0 -27
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.d.ts.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js +0 -39
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +0 -44
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +0 -218
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts +0 -27
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js +0 -181
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js.map +0 -1
- package/bin/executor/composer/context/LocalSessionContextComposer.d.ts +0 -50
- package/bin/executor/composer/context/LocalSessionContextComposer.d.ts.map +0 -1
- package/bin/executor/composer/context/LocalSessionContextComposer.js +0 -108
- package/bin/executor/composer/context/LocalSessionContextComposer.js.map +0 -1
- package/bin/executor/composer/context/SessionContextComposer.d.ts +0 -67
- package/bin/executor/composer/context/SessionContextComposer.d.ts.map +0 -1
- package/bin/executor/composer/context/SessionContextComposer.js +0 -9
- package/bin/executor/composer/context/SessionContextComposer.js.map +0 -1
- package/bin/executor/composer/history/SessionHistoryComposer.d.ts +0 -54
- package/bin/executor/composer/history/SessionHistoryComposer.d.ts.map +0 -1
- package/bin/executor/composer/history/SessionHistoryComposer.js +0 -10
- package/bin/executor/composer/history/SessionHistoryComposer.js.map +0 -1
- package/bin/executor/composer/history/SessionHistoryWriter.d.ts +0 -46
- package/bin/executor/composer/history/SessionHistoryWriter.d.ts.map +0 -1
- package/bin/executor/composer/history/SessionHistoryWriter.js +0 -65
- package/bin/executor/composer/history/SessionHistoryWriter.js.map +0 -1
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts +0 -35
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +0 -1
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js +0 -105
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +0 -1
- package/bin/executor/messages/AssistantResultPersistence.d.ts +0 -66
- package/bin/executor/messages/AssistantResultPersistence.d.ts.map +0 -1
- package/bin/executor/messages/AssistantResultPersistence.js +0 -44
- package/bin/executor/messages/AssistantResultPersistence.js.map +0 -1
- package/bin/executor/services/ExecutorInflightService.d.ts +0 -34
- package/bin/executor/services/ExecutorInflightService.d.ts.map +0 -1
- package/bin/executor/services/ExecutorInflightService.js +0 -73
- package/bin/executor/services/ExecutorInflightService.js.map +0 -1
- package/bin/executor/store/history/SessionHistoryStore.d.ts +0 -140
- package/bin/executor/store/history/SessionHistoryStore.d.ts.map +0 -1
- package/bin/executor/store/history/SessionHistoryStore.js +0 -10
- package/bin/executor/store/history/SessionHistoryStore.js.map +0 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +0 -116
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +0 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +0 -709
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +0 -1
- package/bin/executor/types/SessionHistoryPaths.d.ts +0 -34
- package/bin/executor/types/SessionHistoryPaths.d.ts.map +0 -1
- package/bin/executor/types/SessionHistoryPaths.js +0 -2
- package/bin/executor/types/SessionHistoryPaths.js.map +0 -1
- package/bin/model/CityModelAdapter.d.ts.map +0 -1
- package/bin/model/CityModelAdapter.js.map +0 -1
- package/bin/rpc/Client.d.ts.map +0 -1
- package/bin/rpc/Client.js.map +0 -1
- package/bin/session/SessionSystemBuilder.d.ts +0 -107
- package/bin/session/SessionSystemBuilder.d.ts.map +0 -1
- package/bin/session/SessionSystemBuilder.js +0 -148
- package/bin/session/SessionSystemBuilder.js.map +0 -1
- package/bin/session/recorder/SessionMessageCodec.d.ts.map +0 -1
- package/bin/session/recorder/SessionMessageCodec.js.map +0 -1
- package/bin/session/recorder/SessionRecorder.d.ts +0 -217
- package/bin/session/recorder/SessionRecorder.d.ts.map +0 -1
- package/bin/session/recorder/SessionRecorder.js.map +0 -1
- package/bin/session/recorder/SessionRecorderCompaction.d.ts +0 -18
- package/bin/session/recorder/SessionRecorderCompaction.d.ts.map +0 -1
- package/bin/session/recorder/SessionRecorderCompaction.js.map +0 -1
- package/bin/session/recorder/SessionRecorderHistoryStore.d.ts +0 -66
- package/bin/session/recorder/SessionRecorderHistoryStore.d.ts.map +0 -1
- package/bin/session/recorder/SessionRecorderHistoryStore.js +0 -190
- package/bin/session/recorder/SessionRecorderHistoryStore.js.map +0 -1
- package/bin/session/runtime/SessionPromptRuntime.d.ts +0 -112
- package/bin/session/runtime/SessionPromptRuntime.d.ts.map +0 -1
- package/bin/session/runtime/SessionPromptRuntime.js +0 -357
- package/bin/session/runtime/SessionPromptRuntime.js.map +0 -1
- package/bin/session/services/SessionStateService.d.ts +0 -187
- package/bin/session/services/SessionStateService.d.ts.map +0 -1
- package/bin/session/services/SessionStateService.js +0 -467
- package/bin/session/services/SessionStateService.js.map +0 -1
- package/bin/session/services/SessionTurnService.d.ts +0 -90
- package/bin/session/services/SessionTurnService.d.ts.map +0 -1
- package/bin/session/services/SessionTurnService.js +0 -293
- package/bin/session/services/SessionTurnService.js.map +0 -1
- package/bin/session/services/SessionViewService.d.ts +0 -114
- package/bin/session/services/SessionViewService.d.ts.map +0 -1
- package/bin/session/services/SessionViewService.js +0 -204
- package/bin/session/services/SessionViewService.js.map +0 -1
- package/bin/session/storage/Persistence.d.ts +0 -73
- package/bin/session/storage/Persistence.d.ts.map +0 -1
- package/bin/session/storage/Persistence.js +0 -63
- package/bin/session/storage/Persistence.js.map +0 -1
- package/bin/types/agent/AgentRuntimeAssembly.d.ts +0 -72
- package/bin/types/agent/AgentRuntimeAssembly.d.ts.map +0 -1
- package/bin/types/agent/AgentRuntimeAssembly.js +0 -10
- package/bin/types/agent/AgentRuntimeAssembly.js.map +0 -1
- package/bin/types/runtime/agent/AgentContext.d.ts +0 -306
- package/bin/types/runtime/agent/AgentContext.d.ts.map +0 -1
- package/bin/types/runtime/agent/AgentContext.js +0 -128
- package/bin/types/runtime/agent/AgentContext.js.map +0 -1
- package/bin/types/session/SessionComposerOptions.d.ts +0 -90
- package/bin/types/session/SessionComposerOptions.d.ts.map +0 -1
- package/bin/types/session/SessionComposerOptions.js +0 -10
- package/bin/types/session/SessionComposerOptions.js.map +0 -1
- package/bin/types/session/SessionQueueCommand.d.ts +0 -68
- package/bin/types/session/SessionQueueCommand.d.ts.map +0 -1
- package/bin/types/session/SessionQueueCommand.js +0 -10
- package/bin/types/session/SessionQueueCommand.js.map +0 -1
- package/scripts/session-action-message.test.mjs +0 -410
- package/scripts/session-compaction-context-window.test.mjs +0 -96
- package/scripts/session-history-inflight.test.mjs +0 -146
- package/scripts/session-history-writer-error.test.mjs +0 -57
- package/scripts/session-prompt-runtime.test.mjs +0 -390
- package/src/agent/local/Agent.ts +0 -250
- package/src/agent/local/AgentPluginFactory.ts +0 -51
- package/src/agent/local/AgentRuntimeAssembly.ts +0 -65
- package/src/agent/local/services/AgentAssemblyService.ts +0 -307
- package/src/agent/local/services/AgentBackgroundService.ts +0 -115
- package/src/executor/SessionRunScope.ts +0 -122
- package/src/executor/composer/compaction/SessionCompactionComposer.ts +0 -84
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.ts +0 -51
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +0 -294
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.ts +0 -197
- package/src/executor/composer/context/LocalSessionContextComposer.ts +0 -175
- package/src/executor/composer/context/SessionContextComposer.ts +0 -83
- package/src/executor/composer/history/SessionHistoryComposer.ts +0 -62
- package/src/executor/composer/history/SessionHistoryWriter.ts +0 -100
- package/src/executor/composer/history/jsonl/JsonlSessionHistoryComposer.ts +0 -133
- package/src/executor/messages/AssistantResultPersistence.ts +0 -106
- package/src/executor/services/ExecutorInflightService.ts +0 -95
- package/src/executor/store/history/SessionHistoryStore.ts +0 -172
- package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +0 -879
- package/src/executor/types/SessionHistoryPaths.ts +0 -38
- package/src/session/SessionSystemBuilder.ts +0 -262
- package/src/session/recorder/SessionRecorderHistoryStore.ts +0 -256
- package/src/session/runtime/SessionPromptRuntime.ts +0 -518
- package/src/session/services/SessionStateService.ts +0 -628
- package/src/session/services/SessionTurnService.ts +0 -368
- package/src/session/services/SessionViewService.ts +0 -335
- package/src/session/storage/Persistence.ts +0 -137
- package/src/types/agent/AgentRuntimeAssembly.ts +0 -74
- package/src/types/runtime/agent/AgentContext.ts +0 -387
- package/src/types/session/SessionComposerOptions.ts +0 -107
- package/src/types/session/SessionQueueCommand.ts +0 -78
- /package/bin/{agent/local → config}/ProjectSetup.d.ts +0 -0
- /package/bin/{agent/remote → remote}/RemoteTransport.js +0 -0
- /package/bin/session/{recorder → messages}/JsonlSessionMessageStore.d.ts +0 -0
- /package/bin/session/{recorder → messages}/JsonlSessionMessageStore.js +0 -0
- /package/src/{agent/local → config}/ProjectSetup.ts +0 -0
- /package/src/session/{recorder → messages}/JsonlSessionMessageStore.ts +0 -0
|
@@ -6,13 +6,8 @@
|
|
|
6
6
|
* - lifecycle 面向 runtime 主动 start/stop 钩子。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
AgentPathRuntime,
|
|
11
|
-
AgentPluginConfigRuntime,
|
|
12
|
-
} from "@/types/agent/AgentRuntimeAssembly.js";
|
|
13
|
-
import type { AgentContext } from "@/types/runtime/agent/AgentContext.js";
|
|
9
|
+
import type { AgentContext } from "@/agent/AgentContext.js";
|
|
14
10
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
15
|
-
import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
|
|
16
11
|
import type { JsonValue } from "@/types/common/Json.js";
|
|
17
12
|
|
|
18
13
|
/**
|
|
@@ -24,14 +19,12 @@ import type { JsonValue } from "@/types/common/Json.js";
|
|
|
24
19
|
* - agent runtime 在需要复用 action 时,直接传入自身更完整的 AgentContext 即可。
|
|
25
20
|
*/
|
|
26
21
|
export interface PluginCommandContext {
|
|
27
|
-
/**
|
|
28
|
-
|
|
22
|
+
/** 当前 Agent 稳定标识。 */
|
|
23
|
+
agent_id: string;
|
|
29
24
|
/** 当前项目根目录。 */
|
|
30
25
|
rootPath: string;
|
|
31
26
|
/** 当前统一日志器。 */
|
|
32
27
|
logger: Logger;
|
|
33
|
-
/** 当前解析后的项目配置。 */
|
|
34
|
-
config: DowncityConfig;
|
|
35
28
|
/**
|
|
36
29
|
* 当前项目环境变量快照。
|
|
37
30
|
*
|
|
@@ -40,10 +33,6 @@ export interface PluginCommandContext {
|
|
|
40
33
|
* - plugin 不再区分 global env 与 agent env,避免上下文语义膨胀。
|
|
41
34
|
*/
|
|
42
35
|
env: Record<string, string>;
|
|
43
|
-
/** 当前可见的路径能力集合。 */
|
|
44
|
-
paths: AgentPathRuntime;
|
|
45
|
-
/** 当前可见的 plugin 配置持久化能力集合。 */
|
|
46
|
-
pluginConfig: AgentPluginConfigRuntime;
|
|
47
36
|
}
|
|
48
37
|
|
|
49
38
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin 配置协议类型。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { JsonValue } from "@/types/common/Json.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 允许 optional 字段的结构化 Plugin 配置对象。
|
|
9
|
+
*/
|
|
10
|
+
export type StructuredConfig = {
|
|
11
|
+
/** 当前配置字段;省略或 `undefined` 表示未配置。 */
|
|
12
|
+
[key: string]: JsonValue | undefined;
|
|
13
|
+
};
|
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
* - 细节类型分散在 State / Command / Action / Runtime / Setup / HTTP 模块。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
StructuredConfig,
|
|
12
|
-
} from "@/types/runtime/agent/AgentContext.js";
|
|
9
|
+
import type { AgentContext } from "@/agent/AgentContext.js";
|
|
10
|
+
import type { StructuredConfig } from "@/types/plugin/PluginConfig.js";
|
|
13
11
|
import type { PluginActions } from "@/types/plugin/PluginAction.js";
|
|
14
12
|
import type {
|
|
15
13
|
PluginAvailability,
|
|
@@ -26,6 +24,7 @@ import type {
|
|
|
26
24
|
PluginUsageDefinition,
|
|
27
25
|
} from "@/types/plugin/PluginSetup.js";
|
|
28
26
|
import type { PluginHttpDefinition } from "@/types/plugin/PluginHttp.js";
|
|
27
|
+
import type { PluginRunContext } from "@/types/plugin/PluginRunContext.js";
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
30
|
* Plugin 定义。
|
|
@@ -61,8 +60,16 @@ export interface Plugin {
|
|
|
61
60
|
hooks?: PluginHooks;
|
|
62
61
|
/** Plugin resolve 点集合(可选)。 */
|
|
63
62
|
resolves?: PluginResolves;
|
|
64
|
-
/**
|
|
65
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Plugin system 文本构建器(可选)。
|
|
65
|
+
*
|
|
66
|
+
* @param context Agent 稳定能力上下文。
|
|
67
|
+
* @param run_context 当前 Session run 上下文;非 Session 快照读取时可缺省。
|
|
68
|
+
*/
|
|
69
|
+
system?: (
|
|
70
|
+
context: AgentContext,
|
|
71
|
+
run_context?: PluginRunContext,
|
|
72
|
+
) => string | Promise<string>;
|
|
66
73
|
/** Plugin 生命周期定义(可选)。 */
|
|
67
74
|
lifecycle?: PluginLifecycle;
|
|
68
75
|
/** Plugin 可用性检查器(可选)。 */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Hono } from "hono";
|
|
10
|
-
import type { AgentContext } from "@/
|
|
10
|
+
import type { AgentContext } from "@/agent/AgentContext.js";
|
|
11
11
|
import type { AuthRoutePolicy } from "@/types/runtime/auth/AuthRoute.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin 单次调用的运行上下文。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - 只暴露 plugin 业务需要的只读 Session 快照。
|
|
6
|
+
* - 不暴露 Executor 内部队列、callback 或 plugin lease。
|
|
7
|
+
* - CLI、HTTP 与 scheduler 等非 Session 调用可能不提供该对象。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Plugin action 与 system provider 可读取的 Session 运行快照。
|
|
12
|
+
*/
|
|
13
|
+
export interface PluginRunContext {
|
|
14
|
+
/** 当前调用所属的 Session 标识。 */
|
|
15
|
+
readonly sessionId: string;
|
|
16
|
+
|
|
17
|
+
/** 当前调用所属的 turn 标识。 */
|
|
18
|
+
readonly turnId?: string;
|
|
19
|
+
|
|
20
|
+
/** 当前 Agent 绑定的项目根目录。 */
|
|
21
|
+
readonly projectRoot?: string;
|
|
22
|
+
|
|
23
|
+
/** 当前 Session step 已提交生效的 Agent env 快照。 */
|
|
24
|
+
readonly agentEnv?: Readonly<Record<string, string>>;
|
|
25
|
+
|
|
26
|
+
/** 当前 Session step 已提交生效的 instruction 快照。 */
|
|
27
|
+
readonly agentSystems?: readonly string[];
|
|
28
|
+
|
|
29
|
+
/** 当前 turn 的取消信号。 */
|
|
30
|
+
readonly abortSignal?: AbortSignal;
|
|
31
|
+
}
|
|
@@ -6,16 +6,15 @@
|
|
|
6
6
|
* - setup/usage UI 协议与 action 输入适配不放在这里。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
StructuredConfig,
|
|
12
|
-
} from "@/types/runtime/agent/AgentContext.js";
|
|
9
|
+
import type { AgentContext } from "@/agent/AgentContext.js";
|
|
10
|
+
import type { StructuredConfig } from "@/types/plugin/PluginConfig.js";
|
|
13
11
|
import type { JsonValue } from "@/types/common/Json.js";
|
|
14
12
|
import type { PluginActionResult } from "@/types/plugin/PluginAction.js";
|
|
15
13
|
import type { PluginActionExample } from "@/types/plugin/PluginAction.js";
|
|
16
14
|
import type { Plugin } from "@/types/plugin/PluginDefinition.js";
|
|
17
15
|
import type { AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
|
|
18
16
|
import type { PluginSnapshot } from "@/types/plugin/PluginState.js";
|
|
17
|
+
import type { SessionRunContext } from "@/types/executor/SessionRunContext.js";
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Plugin 概览视图。
|
|
@@ -134,9 +133,13 @@ export interface AgentPlugins {
|
|
|
134
133
|
action: string;
|
|
135
134
|
/** Action Payload(可选)。 */
|
|
136
135
|
payload?: JsonValue;
|
|
136
|
+
/** 当前 action 所属的显式 Session run 上下文。 */
|
|
137
|
+
run_context?: SessionRunContext;
|
|
137
138
|
}): Promise<PluginActionResult<JsonValue>>;
|
|
138
139
|
/** 读取当前生效的 plugin system blocks。 */
|
|
139
|
-
systemBlocks(
|
|
140
|
+
systemBlocks(
|
|
141
|
+
run_context?: SessionRunContext,
|
|
142
|
+
): Promise<AgentSessionSystemBlock[]>;
|
|
140
143
|
/** 运行 pipeline 点,按顺序链式变换值。 */
|
|
141
144
|
pipeline<T = JsonValue>(pointName: string, value: T): Promise<T>;
|
|
142
145
|
/** 运行 guard 点;任一插件抛错即终止。 */
|
|
@@ -171,10 +174,14 @@ export interface AgentPluginExecutionView {
|
|
|
171
174
|
action: string;
|
|
172
175
|
/** Action Payload(可选)。 */
|
|
173
176
|
payload?: JsonValue;
|
|
177
|
+
/** 当前 action 所属的显式 Session run 上下文。 */
|
|
178
|
+
run_context?: SessionRunContext;
|
|
174
179
|
}): Promise<PluginActionResult<JsonValue>>;
|
|
175
180
|
|
|
176
181
|
/** 解析当前视图中捕获的 plugin system blocks。 */
|
|
177
|
-
systemBlocks(
|
|
182
|
+
systemBlocks(
|
|
183
|
+
run_context?: SessionRunContext,
|
|
184
|
+
): Promise<AgentSessionSystemBlock[]>;
|
|
178
185
|
}
|
|
179
186
|
|
|
180
187
|
/**
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
PluginCallInput,
|
|
13
13
|
PluginReadInput,
|
|
14
14
|
} from "@/executor/tools/plugin/types/PluginTool.js";
|
|
15
|
+
import type { SessionRunContext } from "@/types/executor/SessionRunContext.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* 创建 plugin tools 的参数。
|
|
@@ -63,6 +64,15 @@ export interface InvokePluginCallToolOptions {
|
|
|
63
64
|
*/
|
|
64
65
|
plugins: AgentPlugins;
|
|
65
66
|
|
|
67
|
+
/**
|
|
68
|
+
* 当前 tool 调用所属的 Session run 上下文。
|
|
69
|
+
*
|
|
70
|
+
* 关键点(中文)
|
|
71
|
+
* - 由 Executor 在每个 step 显式绑定。
|
|
72
|
+
* - 用于选择当前 plugin lease、资源目录与 assistant file 队列。
|
|
73
|
+
*/
|
|
74
|
+
run_context: SessionRunContext;
|
|
75
|
+
|
|
66
76
|
/**
|
|
67
77
|
* 模型提交给 plugin_call 的结构化输入。
|
|
68
78
|
*/
|
|
@@ -78,9 +88,11 @@ export interface InvokePluginReadToolOptions {
|
|
|
78
88
|
*/
|
|
79
89
|
plugins: AgentPlugins;
|
|
80
90
|
|
|
91
|
+
/** 当前 tool 调用所属的 Session run 上下文。 */
|
|
92
|
+
run_context: SessionRunContext;
|
|
93
|
+
|
|
81
94
|
/**
|
|
82
95
|
* 模型提交给 plugin_read 的结构化输入。
|
|
83
96
|
*/
|
|
84
97
|
input: PluginReadInput;
|
|
85
98
|
}
|
|
86
|
-
|
|
@@ -16,7 +16,6 @@ import type {
|
|
|
16
16
|
AgentArchiveSessionsResult,
|
|
17
17
|
AgentCleanArchiveResult,
|
|
18
18
|
AgentSessionSystemSnapshot,
|
|
19
|
-
AgentSessionSetInput,
|
|
20
19
|
} from "@/types/agent/SessionTypes.js";
|
|
21
20
|
import type { SessionMutation } from "@/types/session/SessionMutation.js";
|
|
22
21
|
import type {
|
|
@@ -64,19 +63,6 @@ export type RpcRequest =
|
|
|
64
63
|
sessionId: string;
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
|
-
| {
|
|
68
|
-
/** 请求 id,用于匹配响应。 */
|
|
69
|
-
id: string;
|
|
70
|
-
/** 更新 session 模型。 */
|
|
71
|
-
method: "sdk.sessions.set";
|
|
72
|
-
/** Session 配置更新参数。 */
|
|
73
|
-
params: {
|
|
74
|
-
/** 目标 session id。 */
|
|
75
|
-
sessionId: string;
|
|
76
|
-
/** 仅包含稳定 modelId 的配置输入。 */
|
|
77
|
-
input: AgentSessionSetInput;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
66
|
| {
|
|
81
67
|
/** 请求 id,用于匹配响应。 */
|
|
82
68
|
id: string;
|
|
@@ -17,9 +17,9 @@ export interface SessionApproval {
|
|
|
17
17
|
/** 当前审批所属 Session 标识。 */
|
|
18
18
|
session_id: string;
|
|
19
19
|
/** 当前审批所属 Turn 标识。 */
|
|
20
|
-
turn_id
|
|
20
|
+
turn_id: string;
|
|
21
21
|
/** 当前审批对应的工具调用标识。 */
|
|
22
|
-
tool_call_id
|
|
22
|
+
tool_call_id: string;
|
|
23
23
|
/** 当前审批对应的工具注册名称。 */
|
|
24
24
|
tool_name: string;
|
|
25
25
|
/** 请求执行的命令或输入文本。 */
|
|
@@ -32,6 +32,8 @@ export interface SessionApproval {
|
|
|
32
32
|
operation: "exec" | "start" | "write";
|
|
33
33
|
/** 当前审批创建时间戳(ms)。 */
|
|
34
34
|
created_at: number;
|
|
35
|
+
/** 当前审批自动过期时间戳(ms)。 */
|
|
36
|
+
expires_at: number;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** 提交 Session 工具审批决策的参数。 */
|
|
@@ -65,44 +67,3 @@ export interface SetSessionApprovalModeInput {
|
|
|
65
67
|
/** 需要设置的新审批模式。 */
|
|
66
68
|
mode: SessionApprovalMode;
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
/** Shell Runtime 发给 Session 的工具审批请求。 */
|
|
70
|
-
export interface SessionToolApprovalRequest {
|
|
71
|
-
/** Runtime 事件类型固定为工具审批请求。 */
|
|
72
|
-
type: "tool-approval-request";
|
|
73
|
-
/** 当前审批所属 Turn 标识。 */
|
|
74
|
-
turn_id: string;
|
|
75
|
-
/** 当前审批对应的工具调用标识。 */
|
|
76
|
-
tool_call_id: string;
|
|
77
|
-
/** 当前审批对应的工具注册名称。 */
|
|
78
|
-
tool_name: string;
|
|
79
|
-
/** 当前审批请求的稳定唯一标识。 */
|
|
80
|
-
approval_id: string;
|
|
81
|
-
/** 请求执行的命令或输入文本。 */
|
|
82
|
-
command: string;
|
|
83
|
-
/** 当前工具执行工作目录。 */
|
|
84
|
-
cwd: string;
|
|
85
|
-
/** 工具申请 unrestricted 权限的原因。 */
|
|
86
|
-
reason: string;
|
|
87
|
-
/** 当前审批对应的工具操作类型。 */
|
|
88
|
-
operation: "exec" | "start" | "write";
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Shell Runtime 发给 Session 的工具审批结果。 */
|
|
92
|
-
export interface SessionToolApprovalResult {
|
|
93
|
-
/** Runtime 事件类型固定为工具审批结果。 */
|
|
94
|
-
type: "tool-approval-result";
|
|
95
|
-
/** 当前审批所属 Turn 标识。 */
|
|
96
|
-
turn_id: string;
|
|
97
|
-
/** 当前审批对应的工具调用标识。 */
|
|
98
|
-
tool_call_id: string;
|
|
99
|
-
/** 当前审批请求的稳定唯一标识。 */
|
|
100
|
-
approval_id: string;
|
|
101
|
-
/** 当前审批的最终结果,超时由 Runtime 标记为 expired。 */
|
|
102
|
-
decision: SessionApprovalDecision | "expired";
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** Session 内部接收的工具审批 Runtime 事件。 */
|
|
106
|
-
export type SessionApprovalRuntimeEvent =
|
|
107
|
-
| SessionToolApprovalRequest
|
|
108
|
-
| SessionToolApprovalResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Approval Broker 内部类型。
|
|
3
|
+
*
|
|
4
|
+
* Broker 是单个 Session 内 pending approval 与审批模式的唯一所有者。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { SessionApproval } from "@/types/session/SessionApproval.js";
|
|
8
|
+
import type { ShellApprovalStatus } from "@downcity/shell";
|
|
9
|
+
|
|
10
|
+
/** Broker 内部保存的单个 pending approval。 */
|
|
11
|
+
export interface SessionPendingApproval {
|
|
12
|
+
/** 对外发布的完整审批快照。 */
|
|
13
|
+
approval: SessionApproval;
|
|
14
|
+
/** 兑现 Shell 等待 Promise 的回调。 */
|
|
15
|
+
resolve: (decision: ShellApprovalStatus) => void;
|
|
16
|
+
/** 审批自动过期定时器。 */
|
|
17
|
+
timer: ReturnType<typeof setTimeout>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Composer 类型。
|
|
3
|
+
*
|
|
4
|
+
* Composer 是自定义 Session 的执行策略边界:它只读取 Session 的只读快照,
|
|
5
|
+
* 负责组装模型输入和生成压缩计划,不持久化 Message、Metadata 或事件。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
LanguageModel,
|
|
10
|
+
SystemModelMessage,
|
|
11
|
+
Tool,
|
|
12
|
+
} from "ai";
|
|
13
|
+
import type { SessionRecordV1 } from "@/executor/types/SessionRecords.js";
|
|
14
|
+
import type { AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
|
|
15
|
+
import type { SessionContextSnapshot, SessionSegmentSummary } from "@/types/session/SessionSegment.js";
|
|
16
|
+
|
|
17
|
+
/** Composer 可读取的 Session 身份快照。 */
|
|
18
|
+
export interface SessionComposeIdentity {
|
|
19
|
+
/** 当前 Agent 的稳定标识。 */
|
|
20
|
+
agent_id: string;
|
|
21
|
+
/** 当前 Session 的稳定标识。 */
|
|
22
|
+
session_id: string;
|
|
23
|
+
/** 当前 Agent 项目的绝对根目录。 */
|
|
24
|
+
project_root: string;
|
|
25
|
+
/** 当前 Session 的创建时间戳,单位为毫秒。 */
|
|
26
|
+
created_at: number;
|
|
27
|
+
/** 当前 Session 使用的参考时区。 */
|
|
28
|
+
timezone: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Composer 可读取的当前 Step 生效状态。 */
|
|
32
|
+
export interface SessionComposeState {
|
|
33
|
+
/** 当前 Step 使用的模型实例;只读查询允许为空。 */
|
|
34
|
+
model?: LanguageModel;
|
|
35
|
+
/** 当前模型声明的上下文窗口,单位为 token。 */
|
|
36
|
+
model_context_window?: number;
|
|
37
|
+
/** 当前 Step 生效的 Agent 环境变量快照。 */
|
|
38
|
+
env: Readonly<Record<string, string>>;
|
|
39
|
+
/** 当前 Step 生效的 Agent instruction 文本。 */
|
|
40
|
+
systems: readonly string[];
|
|
41
|
+
/** 当前 Step 可使用的工具集合。 */
|
|
42
|
+
tools: Readonly<Record<string, Tool>>;
|
|
43
|
+
/** 当前 Step 生效的 instruction system blocks。 */
|
|
44
|
+
instruction_system_blocks: readonly AgentSessionSystemBlock[];
|
|
45
|
+
/** 当前 Session 由宿主注入的 system blocks。 */
|
|
46
|
+
managed_plugin_system_blocks: readonly AgentSessionSystemBlock[];
|
|
47
|
+
/** 当前 Step 捕获的 Plugin system blocks。 */
|
|
48
|
+
plugin_system_blocks: readonly AgentSessionSystemBlock[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Composer 可读取的当前 Turn 快照。 */
|
|
52
|
+
export interface SessionComposeTurn {
|
|
53
|
+
/** 当前 Turn 标识;只读查询场景允许为空。 */
|
|
54
|
+
turn_id?: string;
|
|
55
|
+
/** 当前执行因上下文超限而进行的重试次数。 */
|
|
56
|
+
retry_count: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 单次模型输入组装参数。 */
|
|
60
|
+
export interface SessionComposeInput {
|
|
61
|
+
/** 当前 Session 身份快照。 */
|
|
62
|
+
session: SessionComposeIdentity;
|
|
63
|
+
/** 当前 Step 已生效的运行状态。 */
|
|
64
|
+
state: SessionComposeState;
|
|
65
|
+
/** 当前 Session 的累计 Summary 与 Active Message 快照。 */
|
|
66
|
+
history: Readonly<SessionContextSnapshot>;
|
|
67
|
+
/** 当前 Turn 快照。 */
|
|
68
|
+
turn: SessionComposeTurn;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Composer 为一次模型 Step 生成的完整输入。 */
|
|
72
|
+
export interface SessionStepInput {
|
|
73
|
+
/** 当前 Step 的 system messages。 */
|
|
74
|
+
system: SystemModelMessage[];
|
|
75
|
+
/** 当前 Step 的可解释 system block;自定义 Composer 可以省略。 */
|
|
76
|
+
system_blocks?: AgentSessionSystemBlock[];
|
|
77
|
+
/** 当前 Step 的历史与用户消息。 */
|
|
78
|
+
messages: SessionRecordV1[];
|
|
79
|
+
/** 当前 Step 可调用的工具集合。 */
|
|
80
|
+
tools: Record<string, Tool>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 持久化上下文压缩的组装参数。 */
|
|
84
|
+
export interface SessionCompactionInput extends SessionComposeInput {
|
|
85
|
+
/** 是否由调用方明确要求执行持久化压缩。 */
|
|
86
|
+
force: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Composer 生成、等待 SessionMessages 提交的压缩计划。 */
|
|
90
|
+
export interface SessionCompactionPlan {
|
|
91
|
+
/** Active 中最后一条需要移入 Segment 的 Message sequence。 */
|
|
92
|
+
through_sequence: number;
|
|
93
|
+
/** 新 Segment 使用的累计 Summary。 */
|
|
94
|
+
summary: SessionSegmentSummary;
|
|
95
|
+
/** 当前计划覆盖到的最后一条 Message 标识。 */
|
|
96
|
+
boundary_message_id: string;
|
|
97
|
+
/** Summary 是否因为模型失败而使用了确定性降级内容。 */
|
|
98
|
+
used_fallback: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Session 级可替换执行策略。 */
|
|
102
|
+
export interface SessionComposer {
|
|
103
|
+
/** Composer 的稳定可读名称。 */
|
|
104
|
+
readonly name: string;
|
|
105
|
+
|
|
106
|
+
/** 组装一次模型 Step 使用的 system、history 与 tools。 */
|
|
107
|
+
compose(input: SessionComposeInput): Promise<SessionStepInput>;
|
|
108
|
+
|
|
109
|
+
/** 根据只读历史生成压缩计划;无需压缩时返回空。 */
|
|
110
|
+
compact(input: SessionCompactionInput): Promise<SessionCompactionPlan | null>;
|
|
111
|
+
|
|
112
|
+
/** 判断给定错误是否应在持久化压缩后重试。 */
|
|
113
|
+
should_compact(error: unknown): boolean;
|
|
114
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 这里承载本地 Session 在内存中的可变运行态。
|
|
6
|
-
* -
|
|
6
|
+
* - `SessionState` 与 `Session` 共享该对象,避免重复维护配置状态。
|
|
7
7
|
* - 这里只保存运行态,不承载行为逻辑。
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -16,13 +16,13 @@ export interface SessionLocalState {
|
|
|
16
16
|
/**
|
|
17
17
|
* 当前 session 配置快照。
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
session_config: AgentSessionConfigSnapshot;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* 当前 Session step 实际使用的 Session 配置。
|
|
23
23
|
*
|
|
24
24
|
* 关键点(中文)
|
|
25
|
-
* - `
|
|
25
|
+
* - `session_config` 是配置 API 最近一次成功写入的 configured state。
|
|
26
26
|
* - 该字段只在 Session step 检查点由队列 mutation 更新。
|
|
27
27
|
*/
|
|
28
28
|
effective_session_config: AgentSessionConfigSnapshot;
|
|
@@ -30,7 +30,7 @@ export interface SessionLocalState {
|
|
|
30
30
|
/**
|
|
31
31
|
* 当前 session 创建时间(毫秒时间戳)。
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
created_at: number;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* 当前 session 参考时区。
|
|
@@ -40,10 +40,10 @@ export interface SessionLocalState {
|
|
|
40
40
|
/**
|
|
41
41
|
* initialize() 过程中的并发复用 Promise。
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
initialize_promise: Promise<void> | null;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* ensureReadyForExecution() 过程中的并发复用 Promise。
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
ensure_configured_promise: Promise<void> | null;
|
|
49
49
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { JsonObject, JsonValue } from "@/types/common/Json.js";
|
|
9
|
+
import type { SessionApproval } from "@/types/session/SessionApproval.js";
|
|
9
10
|
|
|
10
11
|
/** Message 默认展示范围。 */
|
|
11
12
|
export type SessionMessageVisibility = "visible" | "internal";
|
|
@@ -132,8 +133,8 @@ export interface SessionAssistantToolPart {
|
|
|
132
133
|
output?: JsonValue;
|
|
133
134
|
/** 工具失败信息。 */
|
|
134
135
|
error?: string;
|
|
135
|
-
/**
|
|
136
|
-
|
|
136
|
+
/** 当前 Tool 等待或已经处理过的完整审批快照。 */
|
|
137
|
+
approval?: SessionApproval;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/** Assistant 文件 part。 */
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionMessages 输入与构造类型。
|
|
3
|
+
*
|
|
4
|
+
* 这些类型只描述 canonical Message 领域入口的参数,不包含持久化行为。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { JsonObject } from "@/types/common/Json.js";
|
|
8
|
+
import type { SessionRecordV1 } from "@/executor/types/SessionRecords.js";
|
|
9
|
+
import type { JsonlSessionMessageStore } from "@/session/messages/JsonlSessionMessageStore.js";
|
|
10
|
+
import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
|
|
11
|
+
import type {
|
|
12
|
+
SessionAssistantMessagePart,
|
|
13
|
+
SessionUserMessagePart,
|
|
14
|
+
} from "@/types/session/SessionMessage.js";
|
|
15
|
+
import type { SessionMutation } from "@/types/session/SessionMutation.js";
|
|
16
|
+
|
|
17
|
+
/** SessionMessages 构造参数。 */
|
|
18
|
+
export interface SessionMessagesOptions {
|
|
19
|
+
/** 当前 Session 标识。 */
|
|
20
|
+
session_id: string;
|
|
21
|
+
/** Message 快照持久化 Store。 */
|
|
22
|
+
store: JsonlSessionMessageStore;
|
|
23
|
+
/** 持久化成功后的实时 Mutation 发布函数。 */
|
|
24
|
+
publish: (mutation: SessionMutation) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** User Message 创建参数。 */
|
|
28
|
+
export interface AppendSessionUserMessageInput {
|
|
29
|
+
/** 当前输入所属 Turn。 */
|
|
30
|
+
turn_id: string;
|
|
31
|
+
/** 当前输入是普通 Prompt 还是 Steering 输入。 */
|
|
32
|
+
input_type: "prompt" | "steer";
|
|
33
|
+
/** User 结构化 Part。 */
|
|
34
|
+
parts: SessionUserMessagePart[];
|
|
35
|
+
/** 可选的稳定 Message 标识。 */
|
|
36
|
+
message_id?: string;
|
|
37
|
+
/** 当前 Message 的默认展示范围。 */
|
|
38
|
+
visibility?: "visible" | "internal";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Assistant Message 创建参数。 */
|
|
42
|
+
export interface OpenSessionAssistantMessageInput {
|
|
43
|
+
/** 当前 Assistant 所属 Turn。 */
|
|
44
|
+
turn_id: string;
|
|
45
|
+
/** 当前 Assistant 在 Turn 内的 Segment 序号。 */
|
|
46
|
+
segment_index: number;
|
|
47
|
+
/** 当前 Assistant 是普通回复还是压缩 Summary。 */
|
|
48
|
+
kind?: "normal" | "summary";
|
|
49
|
+
/** 当前 Message 的默认展示范围。 */
|
|
50
|
+
visibility?: "visible" | "internal";
|
|
51
|
+
/** 可选的稳定 Message 标识。 */
|
|
52
|
+
message_id?: string;
|
|
53
|
+
/** Summary 已覆盖到的来源 Message 标识。 */
|
|
54
|
+
summary_through_message_id?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 已完成 Assistant Message 的直接写入参数。 */
|
|
58
|
+
export interface AppendCompletedAssistantMessageInput {
|
|
59
|
+
/** 当前 Assistant 所属 Turn。 */
|
|
60
|
+
turn_id?: string;
|
|
61
|
+
/** Assistant 完整结构化 Part。 */
|
|
62
|
+
parts: SessionAssistantMessagePart[];
|
|
63
|
+
/** 当前 Assistant 是普通回复还是压缩 Summary。 */
|
|
64
|
+
kind?: "normal" | "summary";
|
|
65
|
+
/** 当前 Message 的默认展示范围。 */
|
|
66
|
+
visibility?: "visible" | "internal";
|
|
67
|
+
/** Summary 已覆盖到的来源 Message 标识。 */
|
|
68
|
+
summary_through_message_id?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Action Message 创建参数。 */
|
|
72
|
+
export interface OpenSessionActionMessageInput {
|
|
73
|
+
/** 可选的稳定 Message 标识,用于更新同一个 Action 生命周期。 */
|
|
74
|
+
message_id?: string;
|
|
75
|
+
/** 当前 Action 所属 Turn。 */
|
|
76
|
+
turn_id?: string;
|
|
77
|
+
/** 当前 Action 的业务类型。 */
|
|
78
|
+
action_type: string;
|
|
79
|
+
/** 当前 Action 标题。 */
|
|
80
|
+
title: string;
|
|
81
|
+
/** 当前 Action 描述。 */
|
|
82
|
+
description?: string;
|
|
83
|
+
/** 当前 Action 附加数据。 */
|
|
84
|
+
data?: JsonObject;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Error Message 创建参数。 */
|
|
88
|
+
export interface AppendSessionErrorMessageInput {
|
|
89
|
+
/** 当前错误影响 Session 还是单个 Turn。 */
|
|
90
|
+
scope: "session" | "turn";
|
|
91
|
+
/** 当前错误所属 Turn。 */
|
|
92
|
+
turn_id?: string;
|
|
93
|
+
/** 当前错误的稳定业务码。 */
|
|
94
|
+
code: string;
|
|
95
|
+
/** 当前错误的用户可见文本。 */
|
|
96
|
+
message: string;
|
|
97
|
+
/** 当前错误是否允许恢复。 */
|
|
98
|
+
recoverable: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** 公开 Session API 追加 User Message 的输入。 */
|
|
102
|
+
export interface AppendExternalSessionUserMessageInput {
|
|
103
|
+
/** 可选的结构化 User Record。 */
|
|
104
|
+
message?: SessionRecordV1 | null;
|
|
105
|
+
/** 未提供结构化 Record 时使用的纯文本。 */
|
|
106
|
+
text?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 公开 Session API 追加 Assistant Message 的输入。 */
|
|
110
|
+
export interface AppendExternalSessionAssistantMessageInput {
|
|
111
|
+
/** 可选的结构化 Assistant Record。 */
|
|
112
|
+
message?: SessionRecordV1 | null;
|
|
113
|
+
/** 未提供结构化 Record 时使用的纯文本。 */
|
|
114
|
+
fallback_text?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Session Prompt 转换并持久化的输入。 */
|
|
118
|
+
export interface AppendSessionPromptMessageInput {
|
|
119
|
+
/** 当前 Agent 项目的绝对根目录,用于解析本地附件。 */
|
|
120
|
+
project_root: string;
|
|
121
|
+
/** 当前 Session Prompt 输入。 */
|
|
122
|
+
prompt: AgentSessionPromptInput;
|
|
123
|
+
/** 当前输入所属 Turn。 */
|
|
124
|
+
turn_id: string;
|
|
125
|
+
/** 当前输入是普通 Prompt 还是 Steering 输入。 */
|
|
126
|
+
input_type: "prompt" | "steer";
|
|
127
|
+
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { SessionAssistantMessagePart, SessionMessage } from "@/types/session/SessionMessage.js";
|
|
8
|
-
import type { ResolveSessionApprovalInput, SessionApprovalResult } from "@/types/session/SessionApproval.js";
|
|
9
8
|
|
|
10
9
|
/** 所有 Session Mutation 的公共字段。 */
|
|
11
10
|
export interface SessionMutationBase {
|
|
@@ -108,19 +107,9 @@ export type SessionMutation =
|
|
|
108
107
|
| SessionTurnMutation
|
|
109
108
|
| SessionStateMutation;
|
|
110
109
|
|
|
111
|
-
/** 当前 Mutation 可用的命令回复入口。 */
|
|
112
|
-
export interface SessionMutationReply {
|
|
113
|
-
/**
|
|
114
|
-
* 回复当前 Tool Part 的审批请求。
|
|
115
|
-
* 只有 approval-required Tool Part Mutation 可以成功调用。
|
|
116
|
-
*/
|
|
117
|
-
approval(input: Pick<ResolveSessionApprovalInput, "decision">): Promise<SessionApprovalResult>;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
110
|
/** Session Mutation 订阅回调。 */
|
|
121
111
|
export type SessionMutationSubscriber = (
|
|
122
112
|
mutation: SessionMutation,
|
|
123
|
-
reply: SessionMutationReply,
|
|
124
113
|
) => void | Promise<void>;
|
|
125
114
|
|
|
126
115
|
/** 取消 Session Mutation 订阅的函数。 */
|