@downcity/agent 1.1.287 → 1.1.310
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 +23 -16
- package/bin/agent/Agent.d.ts +35 -45
- package/bin/agent/Agent.d.ts.map +1 -1
- package/bin/agent/Agent.js +131 -107
- package/bin/agent/Agent.js.map +1 -1
- package/bin/agent/AgentInstructions.d.ts +2 -2
- package/bin/agent/AgentInstructions.d.ts.map +1 -1
- package/bin/agent/AgentInstructions.js +2 -2
- package/bin/agent/AgentInstructions.js.map +1 -1
- package/bin/agent/AgentModel.d.ts +2 -2
- package/bin/agent/AgentModel.d.ts.map +1 -1
- package/bin/agent/AgentModel.js +2 -2
- package/bin/agent/AgentModel.js.map +1 -1
- package/bin/agent/AgentSessions.d.ts +11 -7
- package/bin/agent/AgentSessions.d.ts.map +1 -1
- package/bin/agent/AgentSessions.js +39 -97
- package/bin/agent/AgentSessions.js.map +1 -1
- package/bin/agent/AgentState.d.ts +2 -21
- package/bin/agent/AgentState.d.ts.map +1 -1
- package/bin/agent/AgentState.js +6 -50
- package/bin/agent/AgentState.js.map +1 -1
- package/bin/executor/Executor.d.ts +25 -55
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +93 -178
- 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 +9 -9
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.d.ts.map +1 -1
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.js +19 -19
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.js.map +1 -1
- package/bin/executor/composer/system/default/PromptRenderer.d.ts +2 -2
- package/bin/executor/composer/system/default/PromptRenderer.d.ts.map +1 -1
- package/bin/executor/composer/system/default/PromptRenderer.js +3 -3
- package/bin/executor/composer/system/default/PromptRenderer.js.map +1 -1
- package/bin/executor/composer/system/default/SystemDomain.d.ts +27 -27
- package/bin/executor/composer/system/default/SystemDomain.d.ts.map +1 -1
- package/bin/executor/composer/system/default/SystemDomain.js +44 -44
- 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/composer/system/default/variables/GeoContext.d.ts +1 -1
- package/bin/executor/composer/system/default/variables/GeoContext.d.ts.map +1 -1
- package/bin/executor/composer/system/default/variables/GeoContext.js +3 -3
- package/bin/executor/composer/system/default/variables/GeoContext.js.map +1 -1
- package/bin/executor/composer/system/default/variables/PromptTypes.d.ts +2 -2
- package/bin/executor/composer/system/default/variables/PromptTypes.d.ts.map +1 -1
- package/bin/executor/composer/system/default/variables/VariableReplacer.d.ts +4 -4
- package/bin/executor/composer/system/default/variables/VariableReplacer.d.ts.map +1 -1
- package/bin/executor/composer/system/default/variables/VariableReplacer.js +24 -24
- package/bin/executor/composer/system/default/variables/VariableReplacer.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineError.d.ts +2 -2
- package/bin/executor/core-engine/CoreEngineError.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineError.js +2 -2
- package/bin/executor/core-engine/CoreEngineError.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineLoopDecision.d.ts +2 -2
- package/bin/executor/core-engine/CoreEngineLoopDecision.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineLoopDecision.js +2 -2
- package/bin/executor/core-engine/CoreEngineLoopDecision.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts +2 -2
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineMessageState.js +9 -9
- package/bin/executor/core-engine/CoreEngineMessageState.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.d.ts +8 -8
- package/bin/executor/core-engine/CoreEngineRunner.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.js +94 -108
- package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.d.ts +10 -10
- package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.js +19 -19
- package/bin/executor/core-engine/CoreEngineSignals.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts +6 -6
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.js +12 -12
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.js.map +1 -1
- package/bin/executor/ids/resolveSessionId.d.ts +4 -4
- package/bin/executor/ids/resolveSessionId.d.ts.map +1 -1
- package/bin/executor/ids/resolveSessionId.js +4 -4
- package/bin/executor/ids/resolveSessionId.js.map +1 -1
- package/bin/executor/messages/ChatMessageMarkup.d.ts +10 -10
- package/bin/executor/messages/ChatMessageMarkup.d.ts.map +1 -1
- package/bin/executor/messages/ChatMessageMarkup.js +22 -22
- package/bin/executor/messages/ChatMessageMarkup.js.map +1 -1
- package/bin/executor/messages/ChatMessageMarkupTypes.d.ts +10 -10
- package/bin/executor/messages/ChatMessageMarkupTypes.d.ts.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.d.ts +4 -4
- package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.js +12 -12
- package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
- package/bin/executor/messages/SessionMessageCodec.d.ts +5 -5
- package/bin/executor/messages/SessionMessageCodec.d.ts.map +1 -1
- package/bin/executor/messages/SessionMessageCodec.js +12 -22
- package/bin/executor/messages/SessionMessageCodec.js.map +1 -1
- package/bin/executor/messages/SessionMessageLog.d.ts +2 -2
- package/bin/executor/messages/SessionMessageLog.d.ts.map +1 -1
- package/bin/executor/messages/SessionMessageLog.js +3 -3
- package/bin/executor/messages/SessionMessageLog.js.map +1 -1
- package/bin/executor/messages/SessionStepEventMapper.d.ts +4 -4
- package/bin/executor/messages/SessionStepEventMapper.d.ts.map +1 -1
- package/bin/executor/messages/SessionStepEventMapper.js +7 -7
- package/bin/executor/messages/SessionStepEventMapper.js.map +1 -1
- package/bin/executor/messages/UIMessageTransformer.d.ts +3 -3
- package/bin/executor/messages/UIMessageTransformer.d.ts.map +1 -1
- package/bin/executor/messages/UIMessageTransformer.js +6 -6
- package/bin/executor/messages/UIMessageTransformer.js.map +1 -1
- package/bin/executor/messages/UserVisibleText.d.ts +2 -2
- package/bin/executor/messages/UserVisibleText.d.ts.map +1 -1
- package/bin/executor/messages/UserVisibleText.js +5 -5
- package/bin/executor/messages/UserVisibleText.js.map +1 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts +15 -15
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts.map +1 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.js +13 -12
- package/bin/executor/services/ExecutorRecoveryPolicy.js.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.d.ts +10 -10
- package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.js +1 -1
- package/bin/executor/types/SessionRecords.d.ts +9 -9
- package/bin/executor/types/SessionRecords.d.ts.map +1 -1
- package/bin/executor/types/SessionRecords.js +4 -4
- package/bin/executor/types/SessionRecords.js.map +1 -1
- package/bin/index.d.ts +41 -55
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +24 -31
- package/bin/index.js.map +1 -1
- package/bin/plugin/core/ActionScheduleExecutor.d.ts +4 -4
- package/bin/plugin/core/ActionScheduleExecutor.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleExecutor.js +18 -20
- package/bin/plugin/core/ActionScheduleExecutor.js.map +1 -1
- package/bin/plugin/core/ActionScheduleRuntime.d.ts +2 -2
- package/bin/plugin/core/ActionScheduleRuntime.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleRuntime.js +6 -6
- package/bin/plugin/core/ActionScheduleRuntime.js.map +1 -1
- package/bin/plugin/core/ActionScheduleStore.d.ts +23 -22
- package/bin/plugin/core/ActionScheduleStore.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleStore.js +120 -117
- package/bin/plugin/core/ActionScheduleStore.js.map +1 -1
- package/bin/plugin/core/ActionScheduleTime.d.ts +5 -5
- package/bin/plugin/core/ActionScheduleTime.d.ts.map +1 -1
- package/bin/plugin/core/ActionScheduleTime.js +6 -6
- package/bin/plugin/core/ActionScheduleTime.js.map +1 -1
- package/bin/plugin/core/BasePlugin.d.ts +6 -20
- package/bin/plugin/core/BasePlugin.d.ts.map +1 -1
- package/bin/plugin/core/BasePlugin.js +0 -12
- package/bin/plugin/core/BasePlugin.js.map +1 -1
- package/bin/plugin/core/HookRegistry.d.ts +11 -11
- package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
- package/bin/plugin/core/HookRegistry.js +45 -45
- package/bin/plugin/core/HookRegistry.js.map +1 -1
- package/bin/plugin/core/PluginActionFactory.d.ts +18 -26
- package/bin/plugin/core/PluginActionFactory.d.ts.map +1 -1
- package/bin/plugin/core/PluginActionFactory.js +5 -8
- package/bin/plugin/core/PluginActionFactory.js.map +1 -1
- package/bin/plugin/core/PluginActionRunner.d.ts +15 -33
- package/bin/plugin/core/PluginActionRunner.d.ts.map +1 -1
- package/bin/plugin/core/PluginActionRunner.js +11 -147
- package/bin/plugin/core/PluginActionRunner.js.map +1 -1
- package/bin/plugin/core/PluginCatalog.d.ts +12 -12
- package/bin/plugin/core/PluginCatalog.d.ts.map +1 -1
- package/bin/plugin/core/PluginCatalog.js +18 -18
- package/bin/plugin/core/PluginCatalog.js.map +1 -1
- package/bin/plugin/core/PluginContext.d.ts +32 -0
- package/bin/plugin/core/PluginContext.d.ts.map +1 -0
- package/bin/plugin/core/PluginContext.js +26 -0
- package/bin/plugin/core/PluginContext.js.map +1 -0
- package/bin/plugin/core/PluginHttpRoutes.d.ts +5 -5
- package/bin/plugin/core/PluginHttpRoutes.d.ts.map +1 -1
- package/bin/plugin/core/PluginHttpRoutes.js +5 -5
- package/bin/plugin/core/PluginHttpRoutes.js.map +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts +35 -24
- package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
- package/bin/plugin/core/PluginRegistry.js +99 -71
- package/bin/plugin/core/PluginRegistry.js.map +1 -1
- package/bin/plugin/core/PluginStateController.d.ts +5 -13
- package/bin/plugin/core/PluginStateController.d.ts.map +1 -1
- package/bin/plugin/core/PluginStateController.js +2 -32
- package/bin/plugin/core/PluginStateController.js.map +1 -1
- package/bin/plugin/tool/PluginToolRuntime.d.ts +15 -0
- package/bin/plugin/tool/PluginToolRuntime.d.ts.map +1 -0
- package/bin/plugin/tool/PluginToolRuntime.js +105 -0
- package/bin/plugin/tool/PluginToolRuntime.js.map +1 -0
- package/bin/{executor/tools/plugin → plugin/tool}/PluginToolSchemas.d.ts +1 -1
- package/bin/plugin/tool/PluginToolSchemas.d.ts.map +1 -0
- package/bin/{executor/tools/plugin → plugin/tool}/PluginToolSchemas.js +1 -1
- package/bin/plugin/tool/PluginToolSchemas.js.map +1 -0
- package/bin/plugin/tool/PluginTools.d.ts +25 -0
- package/bin/plugin/tool/PluginTools.d.ts.map +1 -0
- package/bin/{executor/tools/plugin/PluginToolDefinition.js → plugin/tool/PluginTools.js} +19 -19
- package/bin/plugin/tool/PluginTools.js.map +1 -0
- package/bin/plugin/types/ActionSchedule.d.ts +10 -10
- package/bin/plugin/types/ActionSchedule.d.ts.map +1 -1
- package/bin/plugin/types/ActionSchedule.js +1 -1
- package/bin/plugin/types/PluginApi.d.ts +3 -3
- package/bin/plugin/types/PluginApi.d.ts.map +1 -1
- package/bin/remote/RemoteAgent.d.ts +1 -1
- package/bin/remote/RemoteAgent.d.ts.map +1 -1
- package/bin/remote/RemoteAgent.js +3 -3
- package/bin/remote/RemoteAgent.js.map +1 -1
- package/bin/remote/RemoteSession.d.ts +18 -12
- package/bin/remote/RemoteSession.d.ts.map +1 -1
- package/bin/remote/RemoteSession.js +87 -21
- package/bin/remote/RemoteSession.js.map +1 -1
- package/bin/remote/RemoteTransport.d.ts +13 -11
- package/bin/remote/RemoteTransport.d.ts.map +1 -1
- package/bin/remote/transports/HttpRemoteAgentTransport.d.ts +9 -7
- package/bin/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
- package/bin/remote/transports/HttpRemoteAgentTransport.js +36 -39
- package/bin/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
- package/bin/remote/transports/RpcClient.d.ts +14 -31
- package/bin/remote/transports/RpcClient.d.ts.map +1 -1
- package/bin/remote/transports/RpcClient.js +40 -66
- package/bin/remote/transports/RpcClient.js.map +1 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.d.ts +9 -7
- package/bin/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.js +10 -10
- package/bin/remote/transports/RpcRemoteAgentTransport.js.map +1 -1
- package/bin/session/DefaultSessionComposer.d.ts.map +1 -1
- package/bin/session/DefaultSessionComposer.js +2 -4
- package/bin/session/DefaultSessionComposer.js.map +1 -1
- package/bin/session/Session.d.ts +49 -31
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +303 -243
- package/bin/session/Session.js.map +1 -1
- package/bin/session/SessionCommand.d.ts +24 -0
- package/bin/session/SessionCommand.d.ts.map +1 -0
- package/bin/session/SessionCommand.js +35 -0
- package/bin/session/SessionCommand.js.map +1 -0
- package/bin/session/SessionLoop.d.ts +96 -0
- package/bin/session/SessionLoop.d.ts.map +1 -0
- package/bin/session/SessionLoop.js +554 -0
- package/bin/session/SessionLoop.js.map +1 -0
- package/bin/session/SessionMessages.d.ts +20 -16
- package/bin/session/SessionMessages.d.ts.map +1 -1
- package/bin/session/SessionMessages.js +102 -81
- package/bin/session/SessionMessages.js.map +1 -1
- package/bin/session/SessionQueue.d.ts +15 -25
- package/bin/session/SessionQueue.d.ts.map +1 -1
- package/bin/session/SessionQueue.js +31 -45
- package/bin/session/SessionQueue.js.map +1 -1
- package/bin/session/SessionState.d.ts +6 -6
- package/bin/session/SessionState.d.ts.map +1 -1
- package/bin/session/SessionState.js +45 -93
- package/bin/session/SessionState.js.map +1 -1
- package/bin/session/SessionSystem.js +7 -7
- package/bin/session/SessionSystem.js.map +1 -1
- package/bin/session/SessionTitle.d.ts +7 -12
- package/bin/session/SessionTitle.d.ts.map +1 -1
- package/bin/session/SessionTitle.js +15 -20
- package/bin/session/SessionTitle.js.map +1 -1
- package/bin/session/browse/Browse.d.ts +17 -26
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +106 -303
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/browse/SessionMessageTimeline.d.ts +13 -0
- package/bin/session/browse/SessionMessageTimeline.d.ts.map +1 -0
- package/bin/session/browse/SessionMessageTimeline.js +110 -0
- package/bin/session/browse/SessionMessageTimeline.js.map +1 -0
- package/bin/session/control/SessionInteractions.d.ts +39 -0
- package/bin/session/control/SessionInteractions.d.ts.map +1 -0
- package/bin/session/control/SessionInteractions.js +219 -0
- package/bin/session/control/SessionInteractions.js.map +1 -0
- package/bin/session/execution/SessionAssistantOutputAdapter.d.ts +49 -0
- package/bin/session/execution/SessionAssistantOutputAdapter.d.ts.map +1 -0
- package/bin/session/execution/SessionAssistantOutputAdapter.js +117 -0
- package/bin/session/execution/SessionAssistantOutputAdapter.js.map +1 -0
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts +28 -0
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts.map +1 -0
- package/bin/session/execution/tools/SessionShellApprovalAdapter.js +75 -0
- package/bin/session/execution/tools/SessionShellApprovalAdapter.js.map +1 -0
- package/bin/session/messages/SessionAssistantMessageWriter.d.ts +6 -4
- package/bin/session/messages/SessionAssistantMessageWriter.d.ts.map +1 -1
- package/bin/session/messages/SessionAssistantMessageWriter.js +34 -18
- package/bin/session/messages/SessionAssistantMessageWriter.js.map +1 -1
- package/bin/session/messages/SessionJsonValue.d.ts +2 -2
- package/bin/session/messages/SessionJsonValue.d.ts.map +1 -1
- package/bin/session/messages/SessionJsonValue.js.map +1 -1
- package/bin/session/messages/SessionMessageCodec.d.ts.map +1 -1
- package/bin/session/messages/SessionMessageCodec.js +30 -84
- package/bin/session/messages/SessionMessageCodec.js.map +1 -1
- package/bin/session/messages/SessionMessageCompaction.js +2 -2
- package/bin/session/messages/SessionMessageCompaction.js.map +1 -1
- package/bin/session/messages/SessionMessageInteractionWriter.d.ts +51 -0
- package/bin/session/messages/SessionMessageInteractionWriter.d.ts.map +1 -0
- package/bin/session/messages/SessionMessageInteractionWriter.js +177 -0
- package/bin/session/messages/SessionMessageInteractionWriter.js.map +1 -0
- package/bin/session/preview/SessionMessagePreview.js +2 -2
- package/bin/session/preview/SessionMessagePreview.js.map +1 -1
- package/bin/session/runtime/SessionCompactOperation.d.ts +29 -0
- package/bin/session/runtime/SessionCompactOperation.d.ts.map +1 -0
- package/bin/session/runtime/SessionCompactOperation.js +66 -0
- package/bin/session/runtime/SessionCompactOperation.js.map +1 -0
- package/bin/session/runtime/SessionHistoryCompaction.d.ts +22 -0
- package/bin/session/runtime/SessionHistoryCompaction.d.ts.map +1 -0
- package/bin/session/runtime/SessionHistoryCompaction.js +31 -0
- package/bin/session/runtime/SessionHistoryCompaction.js.map +1 -0
- package/bin/session/runtime/SessionTurnContext.d.ts +26 -0
- package/bin/session/runtime/SessionTurnContext.d.ts.map +1 -0
- package/bin/session/runtime/SessionTurnContext.js +181 -0
- package/bin/session/runtime/SessionTurnContext.js.map +1 -0
- package/bin/session/storage/Metadata.d.ts +13 -70
- package/bin/session/storage/Metadata.d.ts.map +1 -1
- package/bin/session/storage/Metadata.js +31 -116
- package/bin/session/storage/Metadata.js.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.d.ts +7 -7
- package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.js +7 -7
- package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
- package/bin/tools/ask/AskQuestionsTool.d.ts +39 -0
- package/bin/tools/ask/AskQuestionsTool.d.ts.map +1 -0
- package/bin/tools/ask/AskQuestionsTool.js +67 -0
- package/bin/tools/ask/AskQuestionsTool.js.map +1 -0
- package/bin/tools/ask/AskQuestionsToolSchemas.d.ts +29 -0
- package/bin/tools/ask/AskQuestionsToolSchemas.d.ts.map +1 -0
- package/bin/tools/ask/AskQuestionsToolSchemas.js +51 -0
- package/bin/tools/ask/AskQuestionsToolSchemas.js.map +1 -0
- package/bin/tools/index.d.ts +9 -0
- package/bin/tools/index.d.ts.map +1 -0
- package/bin/tools/index.js +8 -0
- package/bin/tools/index.js.map +1 -0
- package/bin/types/action/ActionResult.d.ts +26 -0
- package/bin/types/action/ActionResult.d.ts.map +1 -0
- package/bin/types/action/ActionResult.js +17 -0
- package/bin/types/action/ActionResult.js.map +1 -0
- package/bin/types/agent/AgentOptions.d.ts +13 -23
- package/bin/types/agent/AgentOptions.d.ts.map +1 -1
- package/bin/types/agent/AgentState.d.ts +4 -13
- package/bin/types/agent/AgentState.d.ts.map +1 -1
- package/bin/types/agent/AgentState.js +2 -2
- package/bin/types/agent/RemoteAgentPluginAction.d.ts +2 -2
- package/bin/types/agent/RemoteAgentPluginAction.d.ts.map +1 -1
- package/bin/types/agent/SessionActor.d.ts +16 -15
- package/bin/types/agent/SessionActor.d.ts.map +1 -1
- package/bin/types/agent/SessionTypes.d.ts +69 -91
- package/bin/types/agent/SessionTypes.d.ts.map +1 -1
- package/bin/types/executor/SessionAssistantOutput.d.ts +34 -0
- package/bin/types/executor/SessionAssistantOutput.d.ts.map +1 -0
- package/bin/types/executor/SessionAssistantOutput.js +8 -0
- package/bin/types/executor/SessionAssistantOutput.js.map +1 -0
- package/bin/types/executor/SessionToolExecutionContext.d.ts +5 -5
- package/bin/types/executor/SessionToolExecutionContext.d.ts.map +1 -1
- package/bin/types/executor/SessionToolExecutionContext.js +2 -2
- package/bin/types/executor/SessionTurnContext.d.ts +125 -0
- package/bin/types/executor/SessionTurnContext.d.ts.map +1 -0
- package/bin/types/executor/SessionTurnContext.js +10 -0
- package/bin/types/executor/SessionTurnContext.js.map +1 -0
- package/bin/types/plugin/PluginAction.d.ts +13 -10
- package/bin/types/plugin/PluginAction.d.ts.map +1 -1
- package/bin/types/plugin/PluginCommand.d.ts +8 -65
- package/bin/types/plugin/PluginCommand.d.ts.map +1 -1
- package/bin/types/plugin/PluginCommand.js +2 -4
- package/bin/types/plugin/PluginCommand.js.map +1 -1
- package/bin/types/plugin/PluginContext.d.ts +34 -0
- package/bin/types/plugin/PluginContext.d.ts.map +1 -0
- package/bin/types/plugin/PluginContext.js +9 -0
- package/bin/types/plugin/PluginContext.js.map +1 -0
- package/bin/types/plugin/PluginDefinition.d.ts +8 -28
- package/bin/types/plugin/PluginDefinition.d.ts.map +1 -1
- package/bin/types/plugin/PluginDefinition.js +1 -1
- package/bin/types/plugin/PluginExecutionContext.d.ts +29 -0
- package/bin/types/plugin/PluginExecutionContext.d.ts.map +1 -0
- package/bin/types/plugin/{PluginRunContext.js → PluginExecutionContext.js} +2 -2
- package/bin/types/plugin/PluginExecutionContext.js.map +1 -0
- package/bin/types/plugin/PluginHttp.d.ts +5 -5
- package/bin/types/plugin/PluginHttp.d.ts.map +1 -1
- package/bin/types/plugin/PluginRegistry.d.ts +21 -0
- package/bin/types/plugin/PluginRegistry.d.ts.map +1 -0
- package/bin/types/plugin/PluginRegistry.js +9 -0
- package/bin/types/plugin/PluginRegistry.js.map +1 -0
- package/bin/types/plugin/PluginRuntime.d.ts +28 -40
- package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
- package/bin/types/plugin/PluginState.d.ts +0 -15
- package/bin/types/plugin/PluginState.d.ts.map +1 -1
- package/bin/types/plugin/PluginTool.d.ts +90 -0
- package/bin/types/plugin/PluginTool.d.ts.map +1 -0
- package/bin/types/plugin/PluginTool.js.map +1 -0
- package/bin/types/rpc/RpcProtocol.d.ts +50 -72
- package/bin/types/rpc/RpcProtocol.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionCompact.d.ts +31 -0
- package/bin/types/sdk/AgentSessionCompact.d.ts.map +1 -0
- package/bin/types/sdk/AgentSessionCompact.js +8 -0
- package/bin/types/sdk/AgentSessionCompact.js.map +1 -0
- package/bin/types/sdk/AgentSessionPrompt.d.ts +1 -1
- package/bin/types/sdk/AgentSessionPrompt.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionPrompt.js +1 -1
- package/bin/types/sdk/AgentSessionPrompt.js.map +1 -1
- package/bin/types/sdk/AgentSessionStop.d.ts +2 -2
- package/bin/types/sdk/AgentSessionStop.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionTurn.d.ts +3 -13
- package/bin/types/sdk/AgentSessionTurn.d.ts.map +1 -1
- package/bin/types/session/SessionCommand.d.ts +26 -0
- package/bin/types/session/SessionCommand.d.ts.map +1 -0
- package/bin/types/session/SessionCommand.js +7 -0
- package/bin/types/session/SessionCommand.js.map +1 -0
- package/bin/types/session/SessionComposer.d.ts +8 -4
- package/bin/types/session/SessionComposer.d.ts.map +1 -1
- package/bin/{executor/types/SessionRun.d.ts → types/session/SessionExecution.d.ts} +37 -33
- package/bin/types/session/SessionExecution.d.ts.map +1 -0
- package/bin/types/session/SessionExecution.js +10 -0
- package/bin/types/session/SessionExecution.js.map +1 -0
- package/bin/types/session/SessionInteraction.d.ts +165 -0
- package/bin/types/session/SessionInteraction.d.ts.map +1 -0
- package/bin/types/session/SessionInteraction.js +8 -0
- package/bin/types/session/SessionInteraction.js.map +1 -0
- package/bin/types/session/SessionInteractions.d.ts +17 -0
- package/bin/types/session/SessionInteractions.d.ts.map +1 -0
- package/bin/types/session/SessionInteractions.js +8 -0
- package/bin/types/session/SessionInteractions.js.map +1 -0
- package/bin/types/session/SessionLocalState.d.ts +1 -1
- package/bin/types/session/SessionLoop.d.ts +63 -0
- package/bin/types/session/SessionLoop.d.ts.map +1 -0
- package/bin/types/session/{SessionTurn.js → SessionLoop.js} +2 -2
- package/bin/types/session/SessionLoop.js.map +1 -0
- package/bin/types/session/SessionMessage.d.ts +37 -28
- package/bin/types/session/SessionMessage.d.ts.map +1 -1
- package/bin/types/session/SessionMessages.d.ts +2 -4
- package/bin/types/session/SessionMessages.d.ts.map +1 -1
- package/bin/types/session/SessionMutation.d.ts +19 -1
- package/bin/types/session/SessionMutation.d.ts.map +1 -1
- package/bin/types/session/SessionMutation.js +1 -0
- package/bin/types/session/SessionMutation.js.map +1 -1
- package/bin/types/session/SessionOptions.d.ts +34 -20
- package/bin/types/session/SessionOptions.d.ts.map +1 -1
- package/bin/types/session/SessionPort.d.ts +6 -19
- package/bin/types/session/SessionPort.d.ts.map +1 -1
- package/bin/types/session/SessionState.d.ts +3 -13
- package/bin/types/session/SessionState.d.ts.map +1 -1
- package/bin/types/store/AgentStore.d.ts +31 -0
- package/bin/types/store/AgentStore.d.ts.map +1 -0
- package/bin/types/store/AgentStore.js +9 -0
- package/bin/types/store/AgentStore.js.map +1 -0
- package/bin/types/store/LocalStore.d.ts +36 -0
- package/bin/types/store/LocalStore.d.ts.map +1 -0
- package/bin/types/store/LocalStore.js +9 -0
- package/bin/types/store/LocalStore.js.map +1 -0
- package/bin/types/store/SessionStore.d.ts +82 -0
- package/bin/types/store/SessionStore.d.ts.map +1 -0
- package/bin/types/store/SessionStore.js +9 -0
- package/bin/types/store/SessionStore.js.map +1 -0
- package/bin/types/tools/ask/AskQuestionsTool.d.ts +22 -0
- package/bin/types/tools/ask/AskQuestionsTool.d.ts.map +1 -0
- package/bin/types/tools/ask/AskQuestionsTool.js +8 -0
- package/bin/types/tools/ask/AskQuestionsTool.js.map +1 -0
- package/bin/types/workspace/FileSystem.d.ts +55 -0
- package/bin/types/workspace/FileSystem.d.ts.map +1 -0
- package/bin/types/workspace/FileSystem.js +9 -0
- package/bin/types/workspace/FileSystem.js.map +1 -0
- package/bin/types/workspace/FileTool.d.ts +181 -0
- package/bin/types/workspace/FileTool.d.ts.map +1 -0
- package/bin/types/workspace/FileTool.js +10 -0
- package/bin/types/workspace/FileTool.js.map +1 -0
- package/bin/types/workspace/SearchTool.d.ts +131 -0
- package/bin/types/workspace/SearchTool.d.ts.map +1 -0
- package/bin/types/workspace/SearchTool.js +10 -0
- package/bin/types/workspace/SearchTool.js.map +1 -0
- package/bin/types/workspace/Workspace.d.ts +24 -0
- package/bin/types/workspace/Workspace.d.ts.map +1 -0
- package/bin/types/workspace/Workspace.js +9 -0
- package/bin/types/workspace/Workspace.js.map +1 -0
- package/bin/types/workspace/WorkspaceEnv.d.ts +16 -0
- package/bin/types/workspace/WorkspaceEnv.d.ts.map +1 -0
- package/bin/types/workspace/WorkspaceEnv.js +9 -0
- package/bin/types/workspace/WorkspaceEnv.js.map +1 -0
- package/bin/types/workspace/WorkspaceTools.d.ts +20 -0
- package/bin/types/workspace/WorkspaceTools.d.ts.map +1 -0
- package/bin/types/workspace/WorkspaceTools.js +9 -0
- package/bin/types/workspace/WorkspaceTools.js.map +1 -0
- package/bin/utils/Id.d.ts +1 -1
- package/bin/utils/Id.d.ts.map +1 -1
- package/bin/utils/Id.js +1 -1
- package/bin/utils/Id.js.map +1 -1
- package/bin/utils/Template.d.ts +1 -1
- package/bin/utils/Template.d.ts.map +1 -1
- package/bin/utils/Template.js +1 -1
- package/bin/utils/Template.js.map +1 -1
- package/bin/utils/Time.d.ts +5 -5
- package/bin/utils/Time.d.ts.map +1 -1
- package/bin/utils/Time.js +5 -5
- package/bin/utils/Time.js.map +1 -1
- package/bin/utils/cli/CliOutput.d.ts +1 -1
- package/bin/utils/cli/CliOutput.d.ts.map +1 -1
- package/bin/utils/cli/CliOutput.js +6 -6
- package/bin/utils/cli/CliOutput.js.map +1 -1
- package/bin/utils/cli/PrettyStatus.d.ts +3 -3
- package/bin/utils/cli/PrettyStatus.d.ts.map +1 -1
- package/bin/utils/cli/PrettyStatus.js +4 -4
- package/bin/utils/cli/PrettyStatus.js.map +1 -1
- package/bin/utils/logger/FormatRequest.d.ts +2 -2
- package/bin/utils/logger/FormatRequest.d.ts.map +1 -1
- package/bin/utils/logger/FormatRequest.js +49 -49
- package/bin/utils/logger/FormatRequest.js.map +1 -1
- package/bin/utils/logger/FormatResponse.d.ts +1 -1
- package/bin/utils/logger/FormatResponse.d.ts.map +1 -1
- package/bin/utils/logger/FormatResponse.js +36 -36
- package/bin/utils/logger/FormatResponse.js.map +1 -1
- package/bin/utils/logger/FormatShared.d.ts +16 -16
- package/bin/utils/logger/FormatShared.d.ts.map +1 -1
- package/bin/utils/logger/FormatShared.js +28 -28
- package/bin/utils/logger/FormatShared.js.map +1 -1
- package/bin/utils/logger/Logger.d.ts +15 -12
- package/bin/utils/logger/Logger.d.ts.map +1 -1
- package/bin/utils/logger/Logger.js +28 -26
- package/bin/utils/logger/Logger.js.map +1 -1
- package/bin/utils/object/DeepMerge.d.ts +1 -1
- package/bin/utils/object/DeepMerge.d.ts.map +1 -1
- package/bin/utils/object/DeepMerge.js +5 -5
- package/bin/utils/object/DeepMerge.js.map +1 -1
- package/bin/utils/object/ObjectGuards.d.ts +1 -1
- package/bin/utils/object/ObjectGuards.d.ts.map +1 -1
- package/bin/utils/object/ObjectGuards.js +1 -1
- package/bin/utils/object/ObjectGuards.js.map +1 -1
- package/bin/utils/path/AncestorFiles.d.ts +1 -1
- package/bin/utils/path/AncestorFiles.d.ts.map +1 -1
- package/bin/utils/path/AncestorFiles.js +2 -2
- package/bin/utils/path/AncestorFiles.js.map +1 -1
- package/bin/utils/storage/index.d.ts +2 -2
- package/bin/utils/storage/index.d.ts.map +1 -1
- package/bin/utils/storage/index.js +2 -2
- package/bin/utils/storage/index.js.map +1 -1
- package/bin/utils/string/EscapeRegExp.d.ts +1 -1
- package/bin/utils/string/EscapeRegExp.d.ts.map +1 -1
- package/bin/utils/string/EscapeRegExp.js +1 -1
- package/bin/utils/string/EscapeRegExp.js.map +1 -1
- package/bin/workspace/LocalFileSystem.d.ts +44 -0
- package/bin/workspace/LocalFileSystem.d.ts.map +1 -0
- package/bin/workspace/LocalFileSystem.js +153 -0
- package/bin/workspace/LocalFileSystem.js.map +1 -0
- package/bin/workspace/Workspace.d.ts +52 -0
- package/bin/workspace/Workspace.d.ts.map +1 -0
- package/bin/workspace/Workspace.js +153 -0
- package/bin/workspace/Workspace.js.map +1 -0
- package/bin/workspace/WorkspaceEnv.d.ts +19 -0
- package/bin/workspace/WorkspaceEnv.d.ts.map +1 -0
- package/bin/workspace/WorkspaceEnv.js +50 -0
- package/bin/workspace/WorkspaceEnv.js.map +1 -0
- package/bin/workspace/WorkspacePaths.d.ts +67 -0
- package/bin/workspace/WorkspacePaths.d.ts.map +1 -0
- package/bin/workspace/WorkspacePaths.js +102 -0
- package/bin/workspace/WorkspacePaths.js.map +1 -0
- package/bin/workspace/file/FileActionRuntime.d.ts +14 -0
- package/bin/workspace/file/FileActionRuntime.d.ts.map +1 -0
- package/bin/workspace/file/FileActionRuntime.js +386 -0
- package/bin/workspace/file/FileActionRuntime.js.map +1 -0
- package/bin/workspace/file/FileAtomicWriter.d.ts +20 -0
- package/bin/workspace/file/FileAtomicWriter.d.ts.map +1 -0
- package/bin/workspace/file/FileAtomicWriter.js +50 -0
- package/bin/workspace/file/FileAtomicWriter.js.map +1 -0
- package/bin/workspace/file/FileEncoding.d.ts +34 -0
- package/bin/workspace/file/FileEncoding.d.ts.map +1 -0
- package/bin/workspace/file/FileEncoding.js +152 -0
- package/bin/workspace/file/FileEncoding.js.map +1 -0
- package/bin/workspace/file/FilePathPolicy.d.ts +26 -0
- package/bin/workspace/file/FilePathPolicy.d.ts.map +1 -0
- package/bin/workspace/file/FilePathPolicy.js +134 -0
- package/bin/workspace/file/FilePathPolicy.js.map +1 -0
- package/bin/workspace/file/FileToolError.d.ts +30 -0
- package/bin/workspace/file/FileToolError.d.ts.map +1 -0
- package/bin/workspace/file/FileToolError.js +78 -0
- package/bin/workspace/file/FileToolError.js.map +1 -0
- package/bin/workspace/search/SearchActionRuntime.d.ts +14 -0
- package/bin/workspace/search/SearchActionRuntime.d.ts.map +1 -0
- package/bin/workspace/search/SearchActionRuntime.js +359 -0
- package/bin/workspace/search/SearchActionRuntime.js.map +1 -0
- package/bin/workspace/search/SearchToolError.d.ts +26 -0
- package/bin/workspace/search/SearchToolError.d.ts.map +1 -0
- package/bin/workspace/search/SearchToolError.js +76 -0
- package/bin/workspace/search/SearchToolError.js.map +1 -0
- package/bin/{session/messages → workspace/store}/JsonlSessionMessageStore.d.ts +4 -31
- package/bin/workspace/store/JsonlSessionMessageStore.d.ts.map +1 -0
- package/bin/{session/messages → workspace/store}/JsonlSessionMessageStore.js +28 -63
- package/bin/workspace/store/JsonlSessionMessageStore.js.map +1 -0
- package/bin/workspace/store/LocalAgentStore.d.ts +43 -0
- package/bin/workspace/store/LocalAgentStore.d.ts.map +1 -0
- package/bin/workspace/store/LocalAgentStore.js +135 -0
- package/bin/workspace/store/LocalAgentStore.js.map +1 -0
- package/bin/workspace/store/LocalSessionStore.d.ts +38 -0
- package/bin/workspace/store/LocalSessionStore.d.ts.map +1 -0
- package/bin/workspace/store/LocalSessionStore.js +70 -0
- package/bin/workspace/store/LocalSessionStore.js.map +1 -0
- package/bin/workspace/store/LocalStorePaths.d.ts +81 -0
- package/bin/workspace/store/LocalStorePaths.d.ts.map +1 -0
- package/bin/workspace/store/LocalStorePaths.js +112 -0
- package/bin/workspace/store/LocalStorePaths.js.map +1 -0
- package/bin/workspace/store/SessionMessageStoreFactory.d.ts +12 -0
- package/bin/workspace/store/SessionMessageStoreFactory.d.ts.map +1 -0
- package/bin/workspace/store/SessionMessageStoreFactory.js +13 -0
- package/bin/workspace/store/SessionMessageStoreFactory.js.map +1 -0
- package/bin/workspace/tool/FileToolSchemas.d.ts +35 -0
- package/bin/workspace/tool/FileToolSchemas.d.ts.map +1 -0
- package/bin/workspace/tool/FileToolSchemas.js +73 -0
- package/bin/workspace/tool/FileToolSchemas.js.map +1 -0
- package/bin/workspace/tool/FileTools.d.ts +11 -0
- package/bin/workspace/tool/FileTools.d.ts.map +1 -0
- package/bin/workspace/tool/FileTools.js +61 -0
- package/bin/workspace/tool/FileTools.js.map +1 -0
- package/bin/workspace/tool/SearchToolSchemas.d.ts +24 -0
- package/bin/workspace/tool/SearchToolSchemas.d.ts.map +1 -0
- package/bin/workspace/tool/SearchToolSchemas.js +60 -0
- package/bin/workspace/tool/SearchToolSchemas.js.map +1 -0
- package/bin/workspace/tool/SearchTools.d.ts +11 -0
- package/bin/workspace/tool/SearchTools.d.ts.map +1 -0
- package/bin/workspace/tool/SearchTools.js +38 -0
- package/bin/workspace/tool/SearchTools.js.map +1 -0
- package/bin/workspace/tool/WorkspaceTools.d.ts +11 -0
- package/bin/workspace/tool/WorkspaceTools.d.ts.map +1 -0
- package/bin/workspace/tool/WorkspaceTools.js +22 -0
- package/bin/workspace/tool/WorkspaceTools.js.map +1 -0
- package/package.json +11 -6
- package/scripts/action-schedule-store.test.mjs +101 -0
- package/scripts/agent-env-shell-sandbox.test.mjs +9 -19
- package/scripts/agent-env.test.mjs +10 -39
- package/scripts/agent-ready.test.mjs +16 -11
- package/scripts/agent-session-maintenance.test.mjs +9 -7
- package/scripts/agent-store.test.mjs +83 -0
- package/scripts/city-model-tool-loop.test.mjs +48 -22
- package/scripts/core-engine-context-compaction.test.mjs +29 -26
- package/scripts/core-engine-ui-stream-collector.test.mjs +4 -4
- package/scripts/executor-failure-result.test.mjs +36 -33
- package/scripts/file-tools.test.mjs +282 -0
- package/scripts/image-plugin-job.test.mjs +43 -34
- package/scripts/logger-isolation.test.mjs +6 -6
- package/scripts/multi-agent-plugin-isolation.test.mjs +8 -8
- package/scripts/{plugin-tool-bridge.test.mjs → plugin-tools.test.mjs} +106 -102
- package/scripts/public-api-naming.test.mjs +108 -0
- package/scripts/remote-session-reconnect.test.mjs +78 -9
- package/scripts/search-tools.test.mjs +188 -0
- package/scripts/session-ask-question.test.mjs +216 -0
- package/scripts/session-compact-handle.test.mjs +117 -0
- package/scripts/session-composer.test.mjs +7 -5
- package/scripts/session-config-turn-boundary.test.mjs +177 -43
- package/scripts/session-list-title.test.mjs +23 -23
- package/scripts/session-message-timeline.test.mjs +65 -0
- package/scripts/session-messages-error.test.mjs +0 -1
- package/scripts/session-messages.test.mjs +305 -68
- package/scripts/session-queue.test.mjs +75 -40
- package/scripts/session-shell-approval.test.mjs +25 -22
- package/scripts/session-system-blocks.test.mjs +3 -3
- package/scripts/session-title-event.test.mjs +7 -7
- package/scripts/session-turn-context.test.mjs +99 -0
- package/scripts/session-turn-failure.test.mjs +158 -38
- package/scripts/workspace.test.mjs +146 -0
- package/src/agent/Agent.ts +159 -109
- package/src/agent/AgentInstructions.ts +2 -2
- package/src/agent/AgentModel.ts +2 -2
- package/src/agent/AgentSessions.ts +50 -148
- package/src/agent/AgentState.ts +8 -63
- package/src/executor/Executor.ts +120 -226
- package/src/executor/README.md +13 -11
- package/src/executor/composer/system/SessionSystemComposer.ts +2 -2
- package/src/executor/composer/system/default/DefaultSessionSystemComposer.ts +24 -24
- package/src/executor/composer/system/default/PromptRenderer.ts +4 -4
- package/src/executor/composer/system/default/SystemDomain.ts +68 -68
- package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/core.prompt.ts.txt +1 -1
- package/src/executor/composer/system/default/variables/GeoContext.ts +4 -4
- package/src/executor/composer/system/default/variables/PromptTypes.ts +2 -2
- package/src/executor/composer/system/default/variables/VariableReplacer.ts +30 -30
- package/src/executor/core-engine/CoreEngineError.ts +2 -2
- package/src/executor/core-engine/CoreEngineLoopDecision.ts +2 -2
- package/src/executor/core-engine/CoreEngineMessageState.ts +16 -16
- package/src/executor/core-engine/CoreEngineRunner.ts +124 -134
- package/src/executor/core-engine/CoreEngineSignals.ts +24 -24
- package/src/executor/core-engine/CoreEngineUiStreamCollector.ts +18 -18
- package/src/executor/ids/resolveSessionId.ts +5 -5
- package/src/executor/messages/ChatMessageMarkup.ts +23 -23
- package/src/executor/messages/ChatMessageMarkupTypes.ts +10 -10
- package/src/executor/messages/SessionAttachmentMapper.ts +14 -14
- package/src/executor/messages/SessionMessageCodec.ts +17 -27
- package/src/executor/messages/SessionMessageLog.ts +3 -3
- package/src/executor/messages/SessionStepEventMapper.ts +9 -9
- package/src/executor/messages/UIMessageTransformer.ts +6 -6
- package/src/executor/messages/UserVisibleText.ts +6 -6
- package/src/executor/services/ExecutorRecoveryPolicy.ts +33 -32
- package/src/executor/types/SessionHistoryMeta.ts +10 -10
- package/src/executor/types/SessionRecords.ts +13 -13
- package/src/index.ts +108 -184
- package/src/plugin/core/ActionScheduleExecutor.ts +21 -23
- package/src/plugin/core/ActionScheduleRuntime.ts +8 -8
- package/src/plugin/core/ActionScheduleStore.ts +140 -128
- package/src/plugin/core/ActionScheduleTime.ts +6 -6
- package/src/plugin/core/BasePlugin.ts +6 -27
- package/src/plugin/core/HookRegistry.ts +56 -56
- package/src/plugin/core/PluginActionFactory.ts +20 -38
- package/src/plugin/core/PluginActionRunner.ts +21 -181
- package/src/plugin/core/PluginCatalog.ts +23 -23
- package/src/plugin/core/PluginContext.ts +52 -0
- package/src/plugin/core/PluginHttpRoutes.ts +8 -8
- package/src/plugin/core/PluginRegistry.ts +125 -88
- package/src/plugin/core/PluginStateController.ts +5 -47
- package/src/plugin/tool/PluginToolRuntime.ts +121 -0
- package/src/{executor/tools/plugin → plugin/tool}/PluginToolSchemas.ts +1 -1
- package/src/{executor/tools/plugin/PluginToolDefinition.ts → plugin/tool/PluginTools.ts} +25 -27
- package/src/plugin/types/ActionSchedule.ts +10 -10
- package/src/plugin/types/PluginApi.ts +3 -3
- package/src/remote/RemoteAgent.ts +3 -3
- package/src/remote/RemoteSession.ts +110 -28
- package/src/remote/RemoteTransport.ts +17 -20
- package/src/remote/transports/HttpRemoteAgentTransport.ts +59 -59
- package/src/remote/transports/RpcClient.ts +65 -106
- package/src/remote/transports/RpcRemoteAgentTransport.ts +21 -21
- package/src/session/DefaultSessionComposer.ts +2 -3
- package/src/session/Session.ts +352 -298
- package/src/session/SessionCommand.ts +42 -0
- package/src/session/SessionLoop.ts +661 -0
- package/src/session/SessionMessages.ts +141 -94
- package/src/session/SessionQueue.ts +31 -64
- package/src/session/SessionState.ts +48 -116
- package/src/session/SessionSystem.ts +7 -7
- package/src/session/SessionTitle.ts +24 -39
- package/src/session/browse/Browse.ts +160 -384
- package/src/session/browse/SessionMessageTimeline.ts +135 -0
- package/src/session/control/SessionInteractions.ts +290 -0
- package/src/session/execution/SessionAssistantOutputAdapter.ts +144 -0
- package/src/session/execution/tools/SessionShellApprovalAdapter.ts +94 -0
- package/src/session/messages/SessionAssistantMessageWriter.ts +33 -21
- package/src/session/messages/SessionJsonValue.ts +3 -3
- package/src/session/messages/SessionMessageCodec.ts +29 -84
- package/src/session/messages/SessionMessageCompaction.ts +2 -2
- package/src/session/messages/SessionMessageInteractionWriter.ts +277 -0
- package/src/session/preview/SessionMessagePreview.ts +2 -2
- package/src/session/runtime/SessionCompactOperation.ts +93 -0
- package/src/session/runtime/SessionHistoryCompaction.ts +45 -0
- package/src/session/runtime/SessionTurnContext.ts +222 -0
- package/src/session/storage/Metadata.ts +46 -195
- package/src/session/storage/RuntimeSessionPort.ts +13 -13
- package/src/tools/ask/AskQuestionsTool.ts +85 -0
- package/src/tools/ask/AskQuestionsToolSchemas.ts +55 -0
- package/src/tools/index.ts +12 -0
- package/src/types/action/ActionResult.ts +36 -0
- package/src/types/agent/AgentOptions.ts +13 -25
- package/src/types/agent/AgentState.ts +4 -15
- package/src/types/agent/RemoteAgentPluginAction.ts +2 -2
- package/src/types/agent/SessionActor.ts +21 -20
- package/src/types/agent/SessionTypes.ts +74 -94
- package/src/types/executor/SessionAssistantOutput.ts +35 -0
- package/src/types/executor/SessionToolExecutionContext.ts +5 -5
- package/src/types/executor/SessionTurnContext.ts +171 -0
- package/src/types/plugin/PluginAction.ts +13 -10
- package/src/types/plugin/PluginCommand.ts +8 -70
- package/src/types/plugin/PluginContext.ts +43 -0
- package/src/types/plugin/PluginDefinition.ts +8 -35
- package/src/types/plugin/PluginExecutionContext.ts +34 -0
- package/src/types/plugin/PluginHttp.ts +5 -5
- package/src/types/plugin/PluginRegistry.ts +25 -0
- package/src/types/plugin/PluginRuntime.ts +30 -43
- package/src/types/plugin/PluginState.ts +0 -17
- package/src/{executor/tools/plugin/types → types/plugin}/PluginTool.ts +42 -20
- package/src/types/rpc/RpcProtocol.ts +49 -74
- package/src/types/sdk/AgentSessionCompact.ts +36 -0
- package/src/types/sdk/AgentSessionPrompt.ts +1 -1
- package/src/types/sdk/AgentSessionStop.ts +2 -2
- package/src/types/sdk/AgentSessionTurn.ts +3 -15
- package/src/types/session/SessionCommand.ts +27 -0
- package/src/types/session/SessionComposer.ts +8 -4
- package/src/{executor/types/SessionRun.ts → types/session/SessionExecution.ts} +41 -34
- package/src/types/session/SessionInteraction.ts +209 -0
- package/src/types/session/SessionInteractions.ts +21 -0
- package/src/types/session/SessionLocalState.ts +1 -1
- package/src/types/session/SessionLoop.ts +72 -0
- package/src/types/session/SessionMessage.ts +43 -28
- package/src/types/session/SessionMessages.ts +2 -4
- package/src/types/session/SessionMutation.ts +21 -0
- package/src/types/session/SessionOptions.ts +38 -23
- package/src/types/session/SessionPort.ts +6 -24
- package/src/types/session/SessionState.ts +3 -16
- package/src/types/store/AgentStore.ts +52 -0
- package/src/types/store/LocalStore.ts +39 -0
- package/src/types/store/SessionStore.ts +105 -0
- package/src/types/tools/ask/AskQuestionsTool.ts +27 -0
- package/src/types/workspace/FileSystem.ts +76 -0
- package/src/types/workspace/FileTool.ts +225 -0
- package/src/types/workspace/SearchTool.ts +156 -0
- package/src/types/workspace/Workspace.ts +27 -0
- package/src/types/workspace/WorkspaceEnv.ts +19 -0
- package/src/types/workspace/WorkspaceTools.ts +23 -0
- package/src/utils/Id.ts +1 -1
- package/src/utils/Template.ts +1 -1
- package/src/utils/Time.ts +8 -8
- package/src/utils/cli/CliOutput.ts +7 -7
- package/src/utils/cli/PrettyStatus.ts +4 -4
- package/src/utils/logger/FormatRequest.ts +64 -64
- package/src/utils/logger/FormatResponse.ts +44 -44
- package/src/utils/logger/FormatShared.ts +28 -28
- package/src/utils/logger/Logger.ts +30 -26
- package/src/utils/object/DeepMerge.ts +5 -5
- package/src/utils/object/ObjectGuards.ts +1 -1
- package/src/utils/path/AncestorFiles.ts +3 -3
- package/src/utils/storage/index.ts +2 -2
- package/src/utils/string/EscapeRegExp.ts +1 -1
- package/src/workspace/LocalFileSystem.ts +209 -0
- package/src/workspace/Workspace.ts +180 -0
- package/src/workspace/WorkspaceEnv.ts +54 -0
- package/src/workspace/WorkspacePaths.ts +112 -0
- package/src/workspace/file/FileActionRuntime.ts +433 -0
- package/src/workspace/file/FileAtomicWriter.ts +61 -0
- package/src/workspace/file/FileEncoding.ts +175 -0
- package/src/workspace/file/FilePathPolicy.ts +162 -0
- package/src/workspace/file/FileToolError.ts +99 -0
- package/src/workspace/search/SearchActionRuntime.ts +438 -0
- package/src/workspace/search/SearchToolError.ts +94 -0
- package/src/{session/messages → workspace/store}/JsonlSessionMessageStore.ts +40 -91
- package/src/workspace/store/LocalAgentStore.ts +191 -0
- package/src/workspace/store/LocalSessionStore.ts +114 -0
- package/src/workspace/store/LocalStorePaths.ts +209 -0
- package/src/workspace/store/SessionMessageStoreFactory.ts +18 -0
- package/src/workspace/tool/FileToolSchemas.ts +77 -0
- package/src/workspace/tool/FileTools.ts +91 -0
- package/src/workspace/tool/SearchToolSchemas.ts +62 -0
- package/src/workspace/tool/SearchTools.ts +61 -0
- package/src/workspace/tool/WorkspaceTools.ts +31 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/agent/AgentContext.d.ts +0 -69
- package/bin/agent/AgentContext.d.ts.map +0 -1
- package/bin/agent/AgentContext.js +0 -56
- package/bin/agent/AgentContext.js.map +0 -1
- package/bin/config/AgentEnv.d.ts +0 -9
- package/bin/config/AgentEnv.d.ts.map +0 -1
- package/bin/config/AgentEnv.js +0 -48
- package/bin/config/AgentEnv.js.map +0 -1
- package/bin/config/AgentInitializer.d.ts +0 -31
- package/bin/config/AgentInitializer.d.ts.map +0 -1
- package/bin/config/AgentInitializer.js +0 -131
- package/bin/config/AgentInitializer.js.map +0 -1
- package/bin/config/EnvFile.d.ts +0 -31
- package/bin/config/EnvFile.d.ts.map +0 -1
- package/bin/config/EnvFile.js +0 -89
- package/bin/config/EnvFile.js.map +0 -1
- package/bin/config/ExecutionBinding.d.ts +0 -31
- package/bin/config/ExecutionBinding.d.ts.map +0 -1
- package/bin/config/ExecutionBinding.js +0 -46
- package/bin/config/ExecutionBinding.js.map +0 -1
- package/bin/config/Gitignore.d.ts +0 -21
- package/bin/config/Gitignore.d.ts.map +0 -1
- package/bin/config/Gitignore.js +0 -46
- package/bin/config/Gitignore.js.map +0 -1
- package/bin/config/Paths.d.ts +0 -122
- package/bin/config/Paths.d.ts.map +0 -1
- package/bin/config/Paths.js +0 -183
- package/bin/config/Paths.js.map +0 -1
- package/bin/config/PlatformPaths.d.ts +0 -31
- package/bin/config/PlatformPaths.d.ts.map +0 -1
- package/bin/config/PlatformPaths.js +0 -53
- package/bin/config/PlatformPaths.js.map +0 -1
- package/bin/config/ProjectSetup.d.ts +0 -11
- package/bin/config/ProjectSetup.d.ts.map +0 -1
- package/bin/config/ProjectSetup.js +0 -32
- package/bin/config/ProjectSetup.js.map +0 -1
- package/bin/executor/messages/AssistantFileResource.d.ts +0 -63
- package/bin/executor/messages/AssistantFileResource.d.ts.map +0 -1
- package/bin/executor/messages/AssistantFileResource.js +0 -352
- package/bin/executor/messages/AssistantFileResource.js.map +0 -1
- package/bin/executor/tools/file/ReadImageToolBridge.d.ts +0 -21
- package/bin/executor/tools/file/ReadImageToolBridge.d.ts.map +0 -1
- package/bin/executor/tools/file/ReadImageToolBridge.js +0 -69
- package/bin/executor/tools/file/ReadImageToolBridge.js.map +0 -1
- package/bin/executor/tools/plugin/PluginToolBridge.d.ts +0 -19
- package/bin/executor/tools/plugin/PluginToolBridge.d.ts.map +0 -1
- package/bin/executor/tools/plugin/PluginToolBridge.js +0 -181
- package/bin/executor/tools/plugin/PluginToolBridge.js.map +0 -1
- package/bin/executor/tools/plugin/PluginToolDefinition.d.ts +0 -25
- package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +0 -1
- package/bin/executor/tools/plugin/PluginToolDefinition.js.map +0 -1
- package/bin/executor/tools/plugin/PluginToolSchemas.d.ts.map +0 -1
- package/bin/executor/tools/plugin/PluginToolSchemas.js.map +0 -1
- package/bin/executor/tools/plugin/types/PluginTool.d.ts +0 -76
- package/bin/executor/tools/plugin/types/PluginTool.d.ts.map +0 -1
- package/bin/executor/tools/plugin/types/PluginTool.js.map +0 -1
- package/bin/executor/types/SessionExecutor.d.ts +0 -26
- package/bin/executor/types/SessionExecutor.d.ts.map +0 -1
- package/bin/executor/types/SessionExecutor.js +0 -9
- package/bin/executor/types/SessionExecutor.js.map +0 -1
- package/bin/executor/types/SessionRun.d.ts.map +0 -1
- package/bin/executor/types/SessionRun.js +0 -10
- package/bin/executor/types/SessionRun.js.map +0 -1
- package/bin/plugin/core/PluginCommand.d.ts +0 -17
- package/bin/plugin/core/PluginCommand.d.ts.map +0 -1
- package/bin/plugin/core/PluginCommand.js +0 -189
- package/bin/plugin/core/PluginCommand.js.map +0 -1
- package/bin/plugin/core/PluginCommandRequest.d.ts +0 -36
- package/bin/plugin/core/PluginCommandRequest.d.ts.map +0 -1
- package/bin/plugin/core/PluginCommandRequest.js +0 -53
- package/bin/plugin/core/PluginCommandRequest.js.map +0 -1
- package/bin/plugin/core/PluginLocalExecution.d.ts +0 -45
- package/bin/plugin/core/PluginLocalExecution.d.ts.map +0 -1
- package/bin/plugin/core/PluginLocalExecution.js +0 -115
- package/bin/plugin/core/PluginLocalExecution.js.map +0 -1
- package/bin/session/SessionTurn.d.ts +0 -84
- package/bin/session/SessionTurn.d.ts.map +0 -1
- package/bin/session/SessionTurn.js +0 -579
- package/bin/session/SessionTurn.js.map +0 -1
- package/bin/session/approval/SessionApprovalBroker.d.ts +0 -48
- package/bin/session/approval/SessionApprovalBroker.d.ts.map +0 -1
- package/bin/session/approval/SessionApprovalBroker.js +0 -126
- package/bin/session/approval/SessionApprovalBroker.js.map +0 -1
- package/bin/session/messages/JsonlSessionMessageStore.d.ts.map +0 -1
- package/bin/session/messages/JsonlSessionMessageStore.js.map +0 -1
- package/bin/session/storage/Instruction.d.ts +0 -16
- package/bin/session/storage/Instruction.d.ts.map +0 -1
- package/bin/session/storage/Instruction.js +0 -48
- package/bin/session/storage/Instruction.js.map +0 -1
- package/bin/session/storage/Paths.d.ts +0 -81
- package/bin/session/storage/Paths.d.ts.map +0 -1
- package/bin/session/storage/Paths.js +0 -112
- package/bin/session/storage/Paths.js.map +0 -1
- package/bin/types/common/EnvFile.d.ts +0 -30
- package/bin/types/common/EnvFile.d.ts.map +0 -1
- package/bin/types/common/EnvFile.js +0 -10
- package/bin/types/common/EnvFile.js.map +0 -1
- package/bin/types/config/AgentProject.d.ts +0 -73
- package/bin/types/config/AgentProject.d.ts.map +0 -1
- package/bin/types/config/AgentProject.js +0 -9
- package/bin/types/config/AgentProject.js.map +0 -1
- package/bin/types/config/DowncityConfig.d.ts +0 -145
- package/bin/types/config/DowncityConfig.d.ts.map +0 -1
- package/bin/types/config/DowncityConfig.js +0 -2
- package/bin/types/config/DowncityConfig.js.map +0 -1
- package/bin/types/config/ExecutionBinding.d.ts +0 -26
- package/bin/types/config/ExecutionBinding.d.ts.map +0 -1
- package/bin/types/config/ExecutionBinding.js +0 -10
- package/bin/types/config/ExecutionBinding.js.map +0 -1
- package/bin/types/config/LlmConfig.d.ts +0 -100
- package/bin/types/config/LlmConfig.d.ts.map +0 -1
- package/bin/types/config/LlmConfig.js +0 -10
- package/bin/types/config/LlmConfig.js.map +0 -1
- package/bin/types/executor/SessionRunContext.d.ts +0 -155
- package/bin/types/executor/SessionRunContext.d.ts.map +0 -1
- package/bin/types/executor/SessionRunContext.js +0 -10
- package/bin/types/executor/SessionRunContext.js.map +0 -1
- package/bin/types/platform/Store.d.ts +0 -191
- package/bin/types/platform/Store.d.ts.map +0 -1
- package/bin/types/platform/Store.js +0 -9
- package/bin/types/platform/Store.js.map +0 -1
- package/bin/types/plugin/PluginConfig.d.ts +0 -12
- package/bin/types/plugin/PluginConfig.d.ts.map +0 -1
- package/bin/types/plugin/PluginConfig.js +0 -5
- package/bin/types/plugin/PluginConfig.js.map +0 -1
- package/bin/types/plugin/PluginControl.d.ts +0 -74
- package/bin/types/plugin/PluginControl.d.ts.map +0 -1
- package/bin/types/plugin/PluginControl.js +0 -9
- package/bin/types/plugin/PluginControl.js.map +0 -1
- package/bin/types/plugin/PluginRunContext.d.ts +0 -26
- package/bin/types/plugin/PluginRunContext.d.ts.map +0 -1
- package/bin/types/plugin/PluginRunContext.js.map +0 -1
- package/bin/types/plugin/PluginSetup.d.ts +0 -133
- package/bin/types/plugin/PluginSetup.d.ts.map +0 -1
- package/bin/types/plugin/PluginSetup.js +0 -9
- package/bin/types/plugin/PluginSetup.js.map +0 -1
- package/bin/types/plugin/PluginToolRuntime.d.ts +0 -86
- package/bin/types/plugin/PluginToolRuntime.d.ts.map +0 -1
- package/bin/types/plugin/PluginToolRuntime.js +0 -9
- package/bin/types/plugin/PluginToolRuntime.js.map +0 -1
- package/bin/types/runtime/auth/AuthPermission.d.ts +0 -49
- package/bin/types/runtime/auth/AuthPermission.d.ts.map +0 -1
- package/bin/types/runtime/auth/AuthPermission.js +0 -87
- package/bin/types/runtime/auth/AuthPermission.js.map +0 -1
- package/bin/types/runtime/auth/AuthRoute.d.ts +0 -29
- package/bin/types/runtime/auth/AuthRoute.d.ts.map +0 -1
- package/bin/types/runtime/auth/AuthRoute.js +0 -8
- package/bin/types/runtime/auth/AuthRoute.js.map +0 -1
- package/bin/types/runtime/auth/AuthToken.d.ts +0 -46
- package/bin/types/runtime/auth/AuthToken.d.ts.map +0 -1
- package/bin/types/runtime/auth/AuthToken.js +0 -9
- package/bin/types/runtime/auth/AuthToken.js.map +0 -1
- package/bin/types/runtime/auth/AuthTypes.d.ts +0 -227
- package/bin/types/runtime/auth/AuthTypes.d.ts.map +0 -1
- package/bin/types/runtime/auth/AuthTypes.js +0 -9
- package/bin/types/runtime/auth/AuthTypes.js.map +0 -1
- package/bin/types/runtime/http/InlineInstant.d.ts +0 -82
- package/bin/types/runtime/http/InlineInstant.d.ts.map +0 -1
- package/bin/types/runtime/http/InlineInstant.js +0 -10
- package/bin/types/runtime/http/InlineInstant.js.map +0 -1
- package/bin/types/runtime/platform/Platform.d.ts +0 -362
- package/bin/types/runtime/platform/Platform.d.ts.map +0 -1
- package/bin/types/runtime/platform/Platform.js +0 -10
- package/bin/types/runtime/platform/Platform.js.map +0 -1
- package/bin/types/runtime/platform/PlatformGateway.d.ts +0 -41
- package/bin/types/runtime/platform/PlatformGateway.d.ts.map +0 -1
- package/bin/types/runtime/platform/PlatformGateway.js +0 -2
- package/bin/types/runtime/platform/PlatformGateway.js.map +0 -1
- package/bin/types/session/SessionApproval.d.ts +0 -63
- package/bin/types/session/SessionApproval.d.ts.map +0 -1
- package/bin/types/session/SessionApproval.js +0 -7
- package/bin/types/session/SessionApproval.js.map +0 -1
- package/bin/types/session/SessionApprovalBroker.d.ts +0 -17
- package/bin/types/session/SessionApprovalBroker.d.ts.map +0 -1
- package/bin/types/session/SessionApprovalBroker.js +0 -7
- package/bin/types/session/SessionApprovalBroker.js.map +0 -1
- package/bin/types/session/SessionInstruction.d.ts +0 -22
- package/bin/types/session/SessionInstruction.d.ts.map +0 -1
- package/bin/types/session/SessionInstruction.js +0 -9
- package/bin/types/session/SessionInstruction.js.map +0 -1
- package/bin/types/session/SessionQueue.d.ts +0 -88
- package/bin/types/session/SessionQueue.d.ts.map +0 -1
- package/bin/types/session/SessionQueue.js +0 -7
- package/bin/types/session/SessionQueue.js.map +0 -1
- package/bin/types/session/SessionTurn.d.ts +0 -52
- package/bin/types/session/SessionTurn.d.ts.map +0 -1
- package/bin/types/session/SessionTurn.js.map +0 -1
- package/scripts/assistant-file-resource.test.mjs +0 -344
- package/scripts/read-image-tool-bridge.test.mjs +0 -71
- package/src/agent/AgentContext.ts +0 -98
- package/src/config/AgentEnv.ts +0 -49
- package/src/config/AgentInitializer.ts +0 -167
- package/src/config/EnvFile.ts +0 -99
- package/src/config/ExecutionBinding.ts +0 -50
- package/src/config/Gitignore.ts +0 -52
- package/src/config/Paths.ts +0 -241
- package/src/config/PlatformPaths.ts +0 -57
- package/src/config/ProjectSetup.ts +0 -44
- package/src/executor/messages/AssistantFileResource.ts +0 -446
- package/src/executor/tools/file/ReadImageToolBridge.ts +0 -79
- package/src/executor/tools/plugin/PluginToolBridge.ts +0 -212
- package/src/executor/types/SessionExecutor.ts +0 -34
- package/src/plugin/core/PluginCommand.ts +0 -230
- package/src/plugin/core/PluginCommandRequest.ts +0 -93
- package/src/plugin/core/PluginLocalExecution.ts +0 -154
- package/src/session/SessionTurn.ts +0 -669
- package/src/session/approval/SessionApprovalBroker.ts +0 -164
- package/src/session/storage/Instruction.ts +0 -72
- package/src/session/storage/Paths.ts +0 -209
- package/src/types/common/EnvFile.ts +0 -31
- package/src/types/config/AgentProject.ts +0 -85
- package/src/types/config/DowncityConfig.ts +0 -153
- package/src/types/config/ExecutionBinding.ts +0 -27
- package/src/types/config/LlmConfig.ts +0 -115
- package/src/types/executor/SessionRunContext.ts +0 -191
- package/src/types/platform/Store.ts +0 -197
- package/src/types/plugin/PluginConfig.ts +0 -13
- package/src/types/plugin/PluginControl.ts +0 -80
- package/src/types/plugin/PluginRunContext.ts +0 -31
- package/src/types/plugin/PluginSetup.ts +0 -138
- package/src/types/plugin/PluginToolRuntime.ts +0 -98
- package/src/types/runtime/auth/AuthPermission.ts +0 -120
- package/src/types/runtime/auth/AuthRoute.ts +0 -31
- package/src/types/runtime/auth/AuthToken.ts +0 -47
- package/src/types/runtime/auth/AuthTypes.ts +0 -235
- package/src/types/runtime/http/InlineInstant.ts +0 -96
- package/src/types/runtime/platform/Platform.ts +0 -432
- package/src/types/runtime/platform/PlatformGateway.ts +0 -46
- package/src/types/session/SessionApproval.ts +0 -69
- package/src/types/session/SessionApprovalBroker.ts +0 -18
- package/src/types/session/SessionInstruction.ts +0 -24
- package/src/types/session/SessionQueue.ts +0 -102
- package/src/types/session/SessionTurn.ts +0 -56
- /package/bin/{executor/tools/plugin/types → types/plugin}/PluginTool.js +0 -0
|
@@ -92,7 +92,7 @@ function toJsonObject(value: unknown): JsonObject | null {
|
|
|
92
92
|
/**
|
|
93
93
|
* 生成日志友好的单行预览文本。
|
|
94
94
|
*/
|
|
95
|
-
export function
|
|
95
|
+
export function to_inline_preview(value: unknown): string {
|
|
96
96
|
const normalized = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
97
97
|
if (!normalized) return "";
|
|
98
98
|
return normalized.length > DEBUG_TEXT_PREVIEW_MAX_CHARS
|
|
@@ -155,8 +155,8 @@ function summarizeResponseBodyForDebug(body: unknown): JsonObject {
|
|
|
155
155
|
/**
|
|
156
156
|
* 汇总单个 step 的关键信号,便于定位“为什么没有继续下一轮”。
|
|
157
157
|
*/
|
|
158
|
-
export function
|
|
159
|
-
const record = toJsonObject(
|
|
158
|
+
export function summarize_step_for_debug(step_result: unknown): JsonObject {
|
|
159
|
+
const record = toJsonObject(step_result) || {};
|
|
160
160
|
const usage = toJsonObject(record.usage);
|
|
161
161
|
const response = toJsonObject(record.response);
|
|
162
162
|
const toolCalls = Array.isArray(record.toolCalls) ? record.toolCalls : [];
|
|
@@ -171,7 +171,7 @@ export function summarizeStepForDebug(stepResult: unknown): JsonObject {
|
|
|
171
171
|
rawFinishReason:
|
|
172
172
|
typeof record.rawFinishReason === "string" ? record.rawFinishReason : null,
|
|
173
173
|
textLength: typeof record.text === "string" ? record.text.length : 0,
|
|
174
|
-
textPreview:
|
|
174
|
+
textPreview: to_inline_preview(record.text),
|
|
175
175
|
toolCallCount: toolCalls.length,
|
|
176
176
|
toolCallNames: pickToolNames(toolCalls),
|
|
177
177
|
toolResultCount: toolResults.length,
|
|
@@ -191,7 +191,7 @@ export function summarizeStepForDebug(stepResult: unknown): JsonObject {
|
|
|
191
191
|
/**
|
|
192
192
|
* 汇总最终 assistant UI 消息的调试摘要。
|
|
193
193
|
*/
|
|
194
|
-
export function
|
|
194
|
+
export function summarize_ui_message_for_debug(
|
|
195
195
|
message: SessionMessageRecordV1 | null | undefined,
|
|
196
196
|
): JsonObject {
|
|
197
197
|
const parts = Array.isArray(message?.parts) ? message.parts : [];
|
|
@@ -217,7 +217,7 @@ export function summarizeUiMessageForDebug(
|
|
|
217
217
|
partCount: parts.length,
|
|
218
218
|
partTypes,
|
|
219
219
|
textLength: text.length,
|
|
220
|
-
textPreview:
|
|
220
|
+
textPreview: to_inline_preview(text),
|
|
221
221
|
toolPartCount: toolNames.length,
|
|
222
222
|
toolNames,
|
|
223
223
|
};
|
|
@@ -229,7 +229,7 @@ export function summarizeUiMessageForDebug(
|
|
|
229
229
|
* 关键点(中文)
|
|
230
230
|
* - 多 step 场景下,最终 assistant message 需要把各 step 的 UI part 串起来。
|
|
231
231
|
*/
|
|
232
|
-
export function
|
|
232
|
+
export function merge_assistant_ui_messages(
|
|
233
233
|
base: SessionMessageRecordV1 | null,
|
|
234
234
|
incoming: SessionMessageRecordV1,
|
|
235
235
|
): SessionMessageRecordV1 {
|
|
@@ -241,8 +241,8 @@ export function mergeAssistantUiMessages(
|
|
|
241
241
|
metadata: {
|
|
242
242
|
v: incomingMetadata?.v ?? baseMetadata?.v ?? 1,
|
|
243
243
|
ts: incomingMetadata?.ts ?? baseMetadata?.ts ?? Date.now(),
|
|
244
|
-
|
|
245
|
-
incomingMetadata?.
|
|
244
|
+
session_id:
|
|
245
|
+
incomingMetadata?.session_id ?? baseMetadata?.session_id ?? "",
|
|
246
246
|
...(baseMetadata || {}),
|
|
247
247
|
...(incomingMetadata || {}),
|
|
248
248
|
},
|
|
@@ -256,14 +256,14 @@ export function mergeAssistantUiMessages(
|
|
|
256
256
|
function pickIncompleteToolParts(
|
|
257
257
|
message: SessionMessageRecordV1 | null | undefined,
|
|
258
258
|
): Array<{
|
|
259
|
-
|
|
259
|
+
tool_name: string;
|
|
260
260
|
state: string;
|
|
261
261
|
}> {
|
|
262
262
|
const parts = Array.isArray(message?.parts) ? message.parts : [];
|
|
263
263
|
return parts
|
|
264
264
|
.filter(isToolUIPart)
|
|
265
265
|
.map((part) => ({
|
|
266
|
-
|
|
266
|
+
tool_name: String(getToolName(part) || "unknown_tool"),
|
|
267
267
|
state:
|
|
268
268
|
typeof toJsonObject(part)?.state === "string"
|
|
269
269
|
? String(toJsonObject(part)?.state)
|
|
@@ -287,7 +287,7 @@ function looksLikeIncompleteText(text: string): boolean {
|
|
|
287
287
|
/**
|
|
288
288
|
* 构造“不完整响应恢复”提示。
|
|
289
289
|
*/
|
|
290
|
-
export function
|
|
290
|
+
export function build_incomplete_response_recovery_nudge(
|
|
291
291
|
recoveryIndex: number,
|
|
292
292
|
): string {
|
|
293
293
|
const round = Math.max(1, recoveryIndex);
|
|
@@ -302,14 +302,14 @@ export function buildIncompleteResponseRecoveryNudge(
|
|
|
302
302
|
/**
|
|
303
303
|
* 检测“响应被中断但模型没有正常完成”的情况。
|
|
304
304
|
*/
|
|
305
|
-
export function
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
export function detect_incomplete_response(params: {
|
|
306
|
+
step_result: unknown;
|
|
307
|
+
assistant_message: SessionMessageRecordV1 | null | undefined;
|
|
308
308
|
}): {
|
|
309
309
|
reason: string;
|
|
310
310
|
details: JsonObject;
|
|
311
311
|
} | null {
|
|
312
|
-
const record = toJsonObject(params.
|
|
312
|
+
const record = toJsonObject(params.step_result) || {};
|
|
313
313
|
const finishReason =
|
|
314
314
|
typeof record.finishReason === "string" ? record.finishReason : "";
|
|
315
315
|
const rawFinishReason =
|
|
@@ -318,7 +318,7 @@ export function detectIncompleteResponse(params: {
|
|
|
318
318
|
const toolCalls = Array.isArray(record.toolCalls) ? record.toolCalls : [];
|
|
319
319
|
const toolResults = Array.isArray(record.toolResults) ? record.toolResults : [];
|
|
320
320
|
const usage = toJsonObject(record.usage);
|
|
321
|
-
const incompleteToolParts = pickIncompleteToolParts(params.
|
|
321
|
+
const incompleteToolParts = pickIncompleteToolParts(params.assistant_message);
|
|
322
322
|
|
|
323
323
|
if (incompleteToolParts.length > 0) {
|
|
324
324
|
return {
|
|
@@ -327,7 +327,7 @@ export function detectIncompleteResponse(params: {
|
|
|
327
327
|
finishReason: finishReason || null,
|
|
328
328
|
rawFinishReason: rawFinishReason || null,
|
|
329
329
|
incompleteToolParts,
|
|
330
|
-
textPreview:
|
|
330
|
+
textPreview: to_inline_preview(text),
|
|
331
331
|
},
|
|
332
332
|
};
|
|
333
333
|
}
|
|
@@ -353,7 +353,7 @@ export function detectIncompleteResponse(params: {
|
|
|
353
353
|
finishReason,
|
|
354
354
|
rawFinishReason: rawFinishReason || null,
|
|
355
355
|
textLength: text.length,
|
|
356
|
-
textPreview:
|
|
356
|
+
textPreview: to_inline_preview(text),
|
|
357
357
|
toolCallCount: toolCalls.length,
|
|
358
358
|
toolResultCount: toolResults.length,
|
|
359
359
|
inputTokens:
|
|
@@ -372,7 +372,7 @@ export function detectIncompleteResponse(params: {
|
|
|
372
372
|
finishReason,
|
|
373
373
|
rawFinishReason: rawFinishReason || null,
|
|
374
374
|
textLength: text.length,
|
|
375
|
-
textPreview:
|
|
375
|
+
textPreview: to_inline_preview(text),
|
|
376
376
|
},
|
|
377
377
|
};
|
|
378
378
|
}
|
|
@@ -380,10 +380,10 @@ export function detectIncompleteResponse(params: {
|
|
|
380
380
|
/**
|
|
381
381
|
* 检测“只有口头计划,没有真正执行”的续跑信号。
|
|
382
382
|
*/
|
|
383
|
-
export function
|
|
384
|
-
|
|
383
|
+
export function detect_text_only_continuation_reason(
|
|
384
|
+
step_result: unknown,
|
|
385
385
|
): string | null {
|
|
386
|
-
const record = toJsonObject(
|
|
386
|
+
const record = toJsonObject(step_result) || {};
|
|
387
387
|
const finishReason =
|
|
388
388
|
typeof record.finishReason === "string" ? record.finishReason : "";
|
|
389
389
|
const text = typeof record.text === "string" ? record.text.trim() : "";
|
|
@@ -403,7 +403,7 @@ export function detectTextOnlyContinuationReason(
|
|
|
403
403
|
/**
|
|
404
404
|
* 构造“text-only 续跑”提示。
|
|
405
405
|
*/
|
|
406
|
-
export function
|
|
406
|
+
export function build_text_only_continuation_nudge(
|
|
407
407
|
continuationIndex: number,
|
|
408
408
|
): string {
|
|
409
409
|
const round = Math.max(1, continuationIndex);
|
|
@@ -11,25 +11,25 @@ import type { streamText } from "ai";
|
|
|
11
11
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
12
12
|
import type { JsonObject } from "@/types/common/Json.js";
|
|
13
13
|
import type { SessionMessageRecordV1 } from "@/executor/types/SessionRecords.js";
|
|
14
|
-
import type { SessionUiMessageChunkCallback } from "@/
|
|
15
|
-
import {
|
|
14
|
+
import type { SessionUiMessageChunkCallback } from "@/types/session/SessionExecution.js";
|
|
15
|
+
import { generate_id } from "@/utils/Id.js";
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
summarize_ui_message_for_debug,
|
|
18
|
+
to_inline_preview,
|
|
19
19
|
} from "@executor/core-engine/CoreEngineSignals.js";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* 收敛 UI stream 中的最终 assistant 消息。
|
|
23
23
|
*/
|
|
24
|
-
export async function
|
|
24
|
+
export async function collect_final_assistant_message_from_ui_stream(params: {
|
|
25
25
|
/**
|
|
26
26
|
* 当前 `streamText` 执行结果。
|
|
27
27
|
*/
|
|
28
28
|
result: ReturnType<typeof streamText>;
|
|
29
29
|
/**
|
|
30
|
-
* 当前
|
|
30
|
+
* 当前 session_id,用于日志关联。
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
session_id: string;
|
|
33
33
|
/**
|
|
34
34
|
* 当前日志器。
|
|
35
35
|
*/
|
|
@@ -41,7 +41,7 @@ export async function collectFinalAssistantMessageFromUiStream(params: {
|
|
|
41
41
|
/**
|
|
42
42
|
* UI stream chunk 回调。
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
on_ui_message_chunk_callback?: SessionUiMessageChunkCallback;
|
|
45
45
|
/**
|
|
46
46
|
* 当前 turn 的取消信号。
|
|
47
47
|
*
|
|
@@ -49,7 +49,7 @@ export async function collectFinalAssistantMessageFromUiStream(params: {
|
|
|
49
49
|
* - stop 触发后,UI stream 可能在 onFinish 前中断。
|
|
50
50
|
* - 此时仍应尽量用已经收到的 text delta 构造可持久化 assistant 消息。
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
abort_signal?: AbortSignal;
|
|
53
53
|
}): Promise<SessionMessageRecordV1> {
|
|
54
54
|
let streamedAssistantMessage: SessionMessageRecordV1 | null = null;
|
|
55
55
|
let uiFinishSummary: JsonObject | null = null;
|
|
@@ -59,13 +59,13 @@ export async function collectFinalAssistantMessageFromUiStream(params: {
|
|
|
59
59
|
const uiStream = params.result.toUIMessageStream<SessionMessageRecordV1>({
|
|
60
60
|
// 关键点(中文):SDK stream 需要 reasoning 旁路事件时可直接消费;最终落盘仍由 responseMessage 收敛。
|
|
61
61
|
originalMessages: [],
|
|
62
|
-
generateMessageId: () => `a:${params.
|
|
62
|
+
generateMessageId: () => `a:${params.session_id}:${generate_id()}`,
|
|
63
63
|
messageMetadata: ({ part }) => {
|
|
64
64
|
if (part.type !== "start" && part.type !== "finish") return undefined;
|
|
65
65
|
return {
|
|
66
66
|
v: 1,
|
|
67
67
|
ts: Date.now(),
|
|
68
|
-
|
|
68
|
+
session_id: params.session_id,
|
|
69
69
|
source: "egress",
|
|
70
70
|
kind: "normal",
|
|
71
71
|
};
|
|
@@ -79,7 +79,7 @@ export async function collectFinalAssistantMessageFromUiStream(params: {
|
|
|
79
79
|
isAborted: event.isAborted,
|
|
80
80
|
finishReason:
|
|
81
81
|
typeof event.finishReason === "string" ? event.finishReason : null,
|
|
82
|
-
...
|
|
82
|
+
...summarize_ui_message_for_debug(event.responseMessage),
|
|
83
83
|
};
|
|
84
84
|
},
|
|
85
85
|
});
|
|
@@ -89,22 +89,22 @@ export async function collectFinalAssistantMessageFromUiStream(params: {
|
|
|
89
89
|
if (chunk.type === "text-delta") {
|
|
90
90
|
streamed_text += String(chunk.delta || "");
|
|
91
91
|
}
|
|
92
|
-
if (typeof params.
|
|
92
|
+
if (typeof params.on_ui_message_chunk_callback !== "function") continue;
|
|
93
93
|
try {
|
|
94
|
-
await params.
|
|
94
|
+
await params.on_ui_message_chunk_callback(chunk);
|
|
95
95
|
} catch (error) {
|
|
96
96
|
callback_failed = true;
|
|
97
97
|
throw error;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
} catch (error) {
|
|
101
|
-
if (callback_failed || !params.
|
|
101
|
+
if (callback_failed || !params.abort_signal?.aborted) {
|
|
102
102
|
throw error;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
await params.logger.log("info", "[agent] ui.finish", {
|
|
107
|
-
|
|
107
|
+
session_id: params.session_id,
|
|
108
108
|
...(uiFinishSummary || {
|
|
109
109
|
responseMessageMissing: true,
|
|
110
110
|
}),
|
|
@@ -123,9 +123,9 @@ export async function collectFinalAssistantMessageFromUiStream(params: {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
await params.logger.log("warn", "[agent] final.message.fallback", {
|
|
126
|
-
|
|
126
|
+
session_id: params.session_id,
|
|
127
127
|
assistantTextLength: assistantText.length,
|
|
128
|
-
assistantTextPreview:
|
|
128
|
+
assistantTextPreview: to_inline_preview(assistantText),
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
return params.buildFallbackAssistantMessage(
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 解析
|
|
2
|
+
* 解析 session_id。
|
|
3
3
|
*
|
|
4
4
|
* 优先级(中文)
|
|
5
|
-
* 1) 显式参数 `input.
|
|
5
|
+
* 1) 显式参数 `input.session_id`
|
|
6
6
|
* 2) `DC_SESSION_ID`
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
9
|
-
|
|
8
|
+
export function resolve_session_id(input?: {
|
|
9
|
+
session_id?: string;
|
|
10
10
|
}): string | undefined {
|
|
11
|
-
const explicit = String(input?.
|
|
11
|
+
const explicit = String(input?.session_id || "").trim();
|
|
12
12
|
if (explicit) return explicit;
|
|
13
13
|
|
|
14
14
|
const envSessionId = String(process.env.DC_SESSION_ID || "").trim();
|
|
@@ -46,7 +46,7 @@ function parseTagAttributes(rawAttrs: string): Record<string, string> {
|
|
|
46
46
|
/**
|
|
47
47
|
* 归一化附件类型。
|
|
48
48
|
*/
|
|
49
|
-
export function
|
|
49
|
+
export function normalize_chat_message_file_type(value: unknown): ChatMessageFileType {
|
|
50
50
|
const text = normalizeText(value).toLowerCase();
|
|
51
51
|
if (text === "photo" || text === "image") return "photo";
|
|
52
52
|
if (text === "voice") return "voice";
|
|
@@ -58,7 +58,7 @@ export function normalizeChatMessageFileType(value: unknown): ChatMessageFileTyp
|
|
|
58
58
|
/**
|
|
59
59
|
* 提取 frontmatter metadata。
|
|
60
60
|
*/
|
|
61
|
-
export function
|
|
61
|
+
export function extract_chat_message_frontmatter(params: {
|
|
62
62
|
source: string;
|
|
63
63
|
}): {
|
|
64
64
|
metadata: Record<string, unknown>;
|
|
@@ -109,7 +109,7 @@ function toFileSegment(file: ChatMessageFileTag): ChatMessageFileSegment | null
|
|
|
109
109
|
kind: "file",
|
|
110
110
|
file: {
|
|
111
111
|
path,
|
|
112
|
-
type:
|
|
112
|
+
type: normalize_chat_message_file_type(file.type),
|
|
113
113
|
...(normalizeText(file.caption)
|
|
114
114
|
? { caption: normalizeText(file.caption) }
|
|
115
115
|
: {}),
|
|
@@ -120,7 +120,7 @@ function toFileSegment(file: ChatMessageFileTag): ChatMessageFileSegment | null
|
|
|
120
120
|
/**
|
|
121
121
|
* 提取 `<file>` 标签,并保留正文/附件的真实顺序。
|
|
122
122
|
*/
|
|
123
|
-
export function
|
|
123
|
+
export function extract_chat_message_segments(source: string): ChatMessageSegment[] {
|
|
124
124
|
const out: ChatMessageSegment[] = [];
|
|
125
125
|
const text = String(source || "");
|
|
126
126
|
|
|
@@ -139,7 +139,7 @@ export function extractChatMessageSegments(source: string): ChatMessageSegment[]
|
|
|
139
139
|
const path = normalizeText(match[2] || attrs.path);
|
|
140
140
|
const fileSegment = toFileSegment({
|
|
141
141
|
path,
|
|
142
|
-
type:
|
|
142
|
+
type: normalize_chat_message_file_type(attrs.type),
|
|
143
143
|
...(normalizeText(attrs.caption) ? { caption: normalizeText(attrs.caption) } : {}),
|
|
144
144
|
});
|
|
145
145
|
if (fileSegment) out.push(fileSegment);
|
|
@@ -154,8 +154,8 @@ export function extractChatMessageSegments(source: string): ChatMessageSegment[]
|
|
|
154
154
|
/**
|
|
155
155
|
* 提取 `<file>` 标签列表。
|
|
156
156
|
*/
|
|
157
|
-
export function
|
|
158
|
-
return
|
|
157
|
+
export function extract_chat_message_file_tags(source: string): ChatMessageFileTag[] {
|
|
158
|
+
return extract_chat_message_segments(source)
|
|
159
159
|
.filter((segment): segment is ChatMessageFileSegment => segment.kind === "file")
|
|
160
160
|
.map((segment) => segment.file);
|
|
161
161
|
}
|
|
@@ -163,9 +163,9 @@ export function extractChatMessageFileTags(source: string): ChatMessageFileTag[]
|
|
|
163
163
|
/**
|
|
164
164
|
* 移除正文中的 `<file>` 标签,仅保留文本段。
|
|
165
165
|
*/
|
|
166
|
-
export function
|
|
167
|
-
return
|
|
168
|
-
segments:
|
|
166
|
+
export function strip_chat_message_file_tags(source: string): string {
|
|
167
|
+
return build_chat_message_text({
|
|
168
|
+
segments: extract_chat_message_segments(source).filter(
|
|
169
169
|
(segment): segment is ChatMessageTextSegment => segment.kind === "text",
|
|
170
170
|
),
|
|
171
171
|
});
|
|
@@ -181,10 +181,10 @@ function normalizeTagAttributeValue(value: string, quote: '"' | "'"): string {
|
|
|
181
181
|
/**
|
|
182
182
|
* 渲染一条标准化 `<file>` 标签。
|
|
183
183
|
*/
|
|
184
|
-
export function
|
|
184
|
+
export function render_chat_message_file_tag(file: ChatMessageFileTag): string {
|
|
185
185
|
const path = normalizeText(file.path);
|
|
186
186
|
if (!path) return "";
|
|
187
|
-
const type =
|
|
187
|
+
const type = normalize_chat_message_file_type(file.type);
|
|
188
188
|
const caption = normalizeText(file.caption);
|
|
189
189
|
const quote: '"' | "'" = caption.includes('"') && !caption.includes("'") ? "'" : '"';
|
|
190
190
|
const safeCaption = caption
|
|
@@ -196,15 +196,15 @@ export function renderChatMessageFileTag(file: ChatMessageFileTag): string {
|
|
|
196
196
|
|
|
197
197
|
function renderChatMessageSegment(segment: ChatMessageSegment): string {
|
|
198
198
|
if (segment.kind === "text") return normalizeText(segment.text);
|
|
199
|
-
return
|
|
199
|
+
return render_chat_message_file_tag(segment.file);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
203
|
* 把附件列表渲染回统一的 `<file>` 文本块。
|
|
204
204
|
*/
|
|
205
|
-
export function
|
|
205
|
+
export function build_chat_message_file_block(files: ChatMessageFileTag[]): string {
|
|
206
206
|
return files
|
|
207
|
-
.map((file) =>
|
|
207
|
+
.map((file) => render_chat_message_file_tag(file))
|
|
208
208
|
.filter((item) => normalizeText(item).length > 0)
|
|
209
209
|
.join("\n");
|
|
210
210
|
}
|
|
@@ -212,18 +212,18 @@ export function buildChatMessageFileBlock(files: ChatMessageFileTag[]): string {
|
|
|
212
212
|
/**
|
|
213
213
|
* 把片段重建成统一消息文本。
|
|
214
214
|
*/
|
|
215
|
-
export function
|
|
216
|
-
|
|
215
|
+
export function build_chat_message_text(params: {
|
|
216
|
+
body_text?: string;
|
|
217
217
|
files?: ChatMessageFileTag[];
|
|
218
218
|
segments?: ChatMessageSegment[];
|
|
219
219
|
}): string {
|
|
220
220
|
const segments = Array.isArray(params.segments)
|
|
221
221
|
? params.segments
|
|
222
222
|
: [
|
|
223
|
-
...(normalizeText(params.
|
|
223
|
+
...(normalizeText(params.body_text)
|
|
224
224
|
? [{
|
|
225
225
|
kind: "text",
|
|
226
|
-
text: normalizeText(params.
|
|
226
|
+
text: normalizeText(params.body_text),
|
|
227
227
|
} satisfies ChatMessageTextSegment]
|
|
228
228
|
: []),
|
|
229
229
|
...(Array.isArray(params.files)
|
|
@@ -243,14 +243,14 @@ export function buildChatMessageText(params: {
|
|
|
243
243
|
/**
|
|
244
244
|
* 统一解析一段 chat 消息文本。
|
|
245
245
|
*/
|
|
246
|
-
export function
|
|
247
|
-
const extracted =
|
|
246
|
+
export function parse_chat_message_markup(source: string): ParsedChatMessageMarkup {
|
|
247
|
+
const extracted = extract_chat_message_frontmatter({
|
|
248
248
|
source: String(source || ""),
|
|
249
249
|
});
|
|
250
|
-
const segments =
|
|
250
|
+
const segments = extract_chat_message_segments(extracted.body);
|
|
251
251
|
return {
|
|
252
252
|
metadata: extracted.metadata,
|
|
253
|
-
|
|
253
|
+
body_text: build_chat_message_text({
|
|
254
254
|
segments: segments.filter(
|
|
255
255
|
(segment): segment is ChatMessageTextSegment => segment.kind === "text",
|
|
256
256
|
),
|
|
@@ -109,7 +109,7 @@ export interface ParsedChatMessageMarkup {
|
|
|
109
109
|
* 说明(中文)
|
|
110
110
|
* - 会把多段文本按消息原始顺序合并,中间使用空行分隔。
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
body_text: string;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* 按出现顺序提取出的附件标签列表。
|
|
@@ -127,36 +127,36 @@ export interface ParsedChatMessageMarkup {
|
|
|
127
127
|
*/
|
|
128
128
|
export interface ChatMessageSendOptions {
|
|
129
129
|
/**
|
|
130
|
-
* 目标
|
|
130
|
+
* 目标 chat_key。
|
|
131
131
|
*
|
|
132
132
|
* 说明(中文)
|
|
133
133
|
* - 未提供时由调用方回退到当前上下文或显式参数。
|
|
134
134
|
*/
|
|
135
|
-
|
|
135
|
+
chat_key?: string;
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* 延迟发送毫秒数。
|
|
139
139
|
*
|
|
140
140
|
* 说明(中文)
|
|
141
|
-
* - 由 `delay/
|
|
141
|
+
* - 由 `delay/delay_ms/delay-ms` 解析得到。
|
|
142
142
|
*/
|
|
143
|
-
|
|
143
|
+
delay_ms?: number;
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* 定时发送的绝对毫秒时间戳。
|
|
147
147
|
*
|
|
148
148
|
* 说明(中文)
|
|
149
|
-
* - 由 `time/sendAt/
|
|
149
|
+
* - 由 `time/sendAt/send_at_ms` 等字段解析得到。
|
|
150
150
|
*/
|
|
151
|
-
|
|
151
|
+
send_at_ms?: number;
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
* 是否使用 reply 语义发送。
|
|
155
155
|
*
|
|
156
156
|
* 说明(中文)
|
|
157
|
-
* - 允许仅设置布尔值,也允许结合 `
|
|
157
|
+
* - 允许仅设置布尔值,也允许结合 `message_id` 一起使用。
|
|
158
158
|
*/
|
|
159
|
-
|
|
159
|
+
reply_to_message?: boolean;
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* 可选目标消息 ID。
|
|
@@ -164,5 +164,5 @@ export interface ChatMessageSendOptions {
|
|
|
164
164
|
* 说明(中文)
|
|
165
165
|
* - 当前主要用于 Telegram/Feishu reply 场景。
|
|
166
166
|
*/
|
|
167
|
-
|
|
167
|
+
message_id?: string;
|
|
168
168
|
}
|
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
SessionRecordV1,
|
|
22
22
|
SessionMessageRecordV1,
|
|
23
23
|
} from "@/executor/types/SessionRecords.js";
|
|
24
|
-
import {
|
|
24
|
+
import { parse_chat_message_markup } from "@/executor/messages/ChatMessageMarkup.js";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* 从 `<file>` 标签中解析附件描述。
|
|
@@ -33,7 +33,7 @@ function parseAttachmentLinesFromText(text: string): Array<{
|
|
|
33
33
|
}> {
|
|
34
34
|
const raw = String(text || "");
|
|
35
35
|
if (!raw.trim()) return [];
|
|
36
|
-
return
|
|
36
|
+
return parse_chat_message_markup(raw).files.map((file) => ({
|
|
37
37
|
type: file.type,
|
|
38
38
|
path: file.path,
|
|
39
39
|
...(typeof file.caption === "string" && file.caption.trim()
|
|
@@ -68,7 +68,7 @@ function buildDataUrl(mediaType: string, buffer: Buffer): string {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
function resolveHydratableFilePath(
|
|
71
|
-
|
|
71
|
+
project_root: string | undefined,
|
|
72
72
|
rawPath: string,
|
|
73
73
|
): string | null {
|
|
74
74
|
const raw = String(rawPath || "").trim();
|
|
@@ -76,7 +76,7 @@ function resolveHydratableFilePath(
|
|
|
76
76
|
if (raw.startsWith("file://")) return fileURLToPath(raw);
|
|
77
77
|
if (path.isAbsolute(raw)) return path.resolve(raw);
|
|
78
78
|
|
|
79
|
-
const root = path.resolve(String(
|
|
79
|
+
const root = path.resolve(String(project_root || "").trim() || process.cwd());
|
|
80
80
|
const absPath = path.resolve(root, raw);
|
|
81
81
|
const rel = path.relative(root, absPath);
|
|
82
82
|
if (rel === "" || rel.startsWith("..") || path.isAbsolute(rel)) return null;
|
|
@@ -85,10 +85,10 @@ function resolveHydratableFilePath(
|
|
|
85
85
|
|
|
86
86
|
async function hydrateFileUrlPart(
|
|
87
87
|
part: FileUIPart,
|
|
88
|
-
|
|
88
|
+
project_root?: string,
|
|
89
89
|
): Promise<FileUIPart> {
|
|
90
90
|
const url = String(part.url || "").trim();
|
|
91
|
-
const filePath = resolveHydratableFilePath(
|
|
91
|
+
const filePath = resolveHydratableFilePath(project_root, url);
|
|
92
92
|
if (!filePath) return part;
|
|
93
93
|
try {
|
|
94
94
|
const buffer = await fs.readFile(filePath);
|
|
@@ -139,7 +139,7 @@ async function hydrateFileUrlPartStrict(
|
|
|
139
139
|
* - 已经是 data URL 或远程 URL 的附件保持原样。
|
|
140
140
|
* - 本地文件读取失败时直接报错,避免模型请求拿到不可访问的本地路径。
|
|
141
141
|
*/
|
|
142
|
-
export async function
|
|
142
|
+
export async function hydrate_user_prompt_file_parts(
|
|
143
143
|
parts: SessionUserMessagePart[],
|
|
144
144
|
project_root?: string,
|
|
145
145
|
): Promise<SessionUserMessagePart[]> {
|
|
@@ -167,15 +167,15 @@ export async function hydrateUserPromptFileParts(
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
|
-
*
|
|
170
|
+
* 将历史中的本地 file part 临时转换为模型可消费的 data URL。
|
|
171
171
|
*
|
|
172
172
|
* 关键点(中文)
|
|
173
173
|
* - 该函数只修改本轮内存消息,不回写历史。
|
|
174
174
|
* - 新历史保留 Agent 根目录相对路径,旧历史的 `file://` 仍继续兼容。
|
|
175
175
|
*/
|
|
176
|
-
export async function
|
|
176
|
+
export async function hydrate_file_url_parts_for_model(
|
|
177
177
|
messages: SessionMessageRecordV1[],
|
|
178
|
-
|
|
178
|
+
project_root?: string,
|
|
179
179
|
): Promise<SessionMessageRecordV1[]> {
|
|
180
180
|
if (!Array.isArray(messages) || messages.length === 0) return messages;
|
|
181
181
|
|
|
@@ -194,7 +194,7 @@ export async function hydrateFileUrlPartsForModel(
|
|
|
194
194
|
nextParts.push(part);
|
|
195
195
|
continue;
|
|
196
196
|
}
|
|
197
|
-
const nextPart = await hydrateFileUrlPart(part as FileUIPart,
|
|
197
|
+
const nextPart = await hydrateFileUrlPart(part as FileUIPart, project_root);
|
|
198
198
|
if (nextPart !== part) changed = true;
|
|
199
199
|
nextParts.push(nextPart as SessionMessageRecordV1["parts"][number]);
|
|
200
200
|
}
|
|
@@ -208,13 +208,13 @@ export async function hydrateFileUrlPartsForModel(
|
|
|
208
208
|
/**
|
|
209
209
|
* 在 user 消息上注入 FileUIPart,以便多模态模型直接消费本地附件。
|
|
210
210
|
*/
|
|
211
|
-
export async function
|
|
211
|
+
export async function inject_file_parts_from_attachments(
|
|
212
212
|
messages: SessionMessageRecordV1[],
|
|
213
|
-
|
|
213
|
+
project_root?: string,
|
|
214
214
|
): Promise<SessionMessageRecordV1[]> {
|
|
215
215
|
if (!Array.isArray(messages) || messages.length === 0) return messages;
|
|
216
216
|
|
|
217
|
-
const root = path.resolve(String(
|
|
217
|
+
const root = path.resolve(String(project_root || "").trim() || process.cwd());
|
|
218
218
|
const out: SessionMessageRecordV1[] = [];
|
|
219
219
|
|
|
220
220
|
for (const message of messages) {
|