@downcity/agent 1.1.438 → 1.1.446
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 +25 -18
- package/bin/agent/Agent.d.ts +44 -20
- package/bin/agent/Agent.d.ts.map +1 -1
- package/bin/agent/Agent.js +114 -69
- package/bin/agent/Agent.js.map +1 -1
- package/bin/agent/AgentInstructions.d.ts +18 -4
- package/bin/agent/AgentInstructions.d.ts.map +1 -1
- package/bin/agent/AgentInstructions.js +33 -14
- package/bin/agent/AgentInstructions.js.map +1 -1
- package/bin/agent/AgentMemoryStorage.d.ts +1 -1
- package/bin/agent/AgentMemoryStorage.d.ts.map +1 -1
- package/bin/agent/AgentMemoryStorage.js.map +1 -1
- package/bin/agent/AgentSessions.d.ts +29 -16
- package/bin/agent/AgentSessions.d.ts.map +1 -1
- package/bin/agent/AgentSessions.js +42 -22
- package/bin/agent/AgentSessions.js.map +1 -1
- package/bin/group/Group.d.ts +13 -12
- package/bin/group/Group.d.ts.map +1 -1
- package/bin/group/Group.js +24 -23
- package/bin/group/Group.js.map +1 -1
- package/bin/group/GroupSession.d.ts.map +1 -1
- package/bin/group/GroupSession.js +13 -9
- package/bin/group/GroupSession.js.map +1 -1
- package/bin/group/GroupSessions.d.ts +27 -2
- package/bin/group/GroupSessions.d.ts.map +1 -1
- package/bin/group/GroupSessions.js +68 -21
- package/bin/group/GroupSessions.js.map +1 -1
- package/bin/group/storage/LocalGroupSessionDataStore.d.ts +8 -0
- package/bin/group/storage/LocalGroupSessionDataStore.d.ts.map +1 -1
- package/bin/group/storage/LocalGroupSessionDataStore.js +1 -1
- package/bin/group/storage/LocalGroupSessionDataStore.js.map +1 -1
- package/bin/group/storage/LocalGroupSessionStore.d.ts +64 -5
- package/bin/group/storage/LocalGroupSessionStore.d.ts.map +1 -1
- package/bin/group/storage/LocalGroupSessionStore.js +114 -23
- package/bin/group/storage/LocalGroupSessionStore.js.map +1 -1
- package/bin/index.d.ts +25 -30
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +14 -14
- package/bin/index.js.map +1 -1
- package/bin/{executor/model → model}/ModelGenerate.d.ts +1 -1
- package/bin/model/ModelGenerate.d.ts.map +1 -0
- package/bin/model/ModelGenerate.js.map +1 -0
- package/bin/{executor/model → model}/ModelRequestRunner.d.ts +1 -1
- package/bin/model/ModelRequestRunner.d.ts.map +1 -0
- package/bin/model/ModelRequestRunner.js.map +1 -0
- package/bin/{executor/model → model}/ModelStepRunner.d.ts +6 -7
- package/bin/model/ModelStepRunner.d.ts.map +1 -0
- package/bin/{executor/model → model}/ModelStepRunner.js +16 -10
- package/bin/model/ModelStepRunner.js.map +1 -0
- package/bin/model/ModelStreamConsumer.d.ts.map +1 -0
- package/bin/model/ModelStreamConsumer.js.map +1 -0
- package/bin/model/ModelStreamFailure.d.ts.map +1 -0
- package/bin/model/ModelStreamFailure.js.map +1 -0
- package/bin/model/ToolInputValidation.d.ts +28 -0
- package/bin/model/ToolInputValidation.d.ts.map +1 -0
- package/bin/model/ToolInputValidation.js +37 -0
- package/bin/model/ToolInputValidation.js.map +1 -0
- package/bin/model/messages/ChatMessageMarkup.d.ts.map +1 -0
- package/bin/model/messages/ChatMessageMarkup.js.map +1 -0
- package/bin/{executor → model}/messages/ChatMessageMarkupTypes.d.ts +1 -1
- package/bin/model/messages/ChatMessageMarkupTypes.d.ts.map +1 -0
- package/bin/{executor → model}/messages/ChatMessageMarkupTypes.js +1 -1
- package/bin/model/messages/ChatMessageMarkupTypes.js.map +1 -0
- package/bin/model/messages/SessionAttachmentMapper.d.ts.map +1 -0
- package/bin/model/messages/SessionAttachmentMapper.js.map +1 -0
- package/bin/model/messages/SessionMessageLog.d.ts.map +1 -0
- package/bin/model/messages/SessionMessageLog.js.map +1 -0
- package/bin/model/messages/SessionModelMessages.d.ts.map +1 -0
- package/bin/{executor → model}/messages/SessionModelMessages.js +0 -1
- package/bin/model/messages/SessionModelMessages.js.map +1 -0
- package/bin/model/prompts/SystemPromptAssets.d.ts.map +1 -0
- package/bin/{executor/composer/system/default → model/prompts}/SystemPromptAssets.js +1 -1
- package/bin/model/prompts/SystemPromptAssets.js.map +1 -0
- package/bin/model/prompts/assets/core.prompt.d.ts +7 -0
- package/bin/model/prompts/assets/core.prompt.d.ts.map +1 -0
- package/bin/model/prompts/assets/core.prompt.js +8 -0
- package/bin/model/prompts/assets/core.prompt.js.map +1 -0
- package/bin/session/Session.d.ts +29 -17
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +161 -134
- package/bin/session/Session.js.map +1 -1
- package/bin/session/input/SessionHookRunner.d.ts +52 -0
- package/bin/session/input/SessionHookRunner.d.ts.map +1 -0
- package/bin/session/input/SessionHookRunner.js +51 -0
- package/bin/session/input/SessionHookRunner.js.map +1 -0
- package/bin/session/input/SessionSystem.d.ts +26 -0
- package/bin/session/input/SessionSystem.d.ts.map +1 -0
- package/bin/session/{SessionSystem.js → input/SessionSystem.js} +27 -23
- package/bin/session/input/SessionSystem.js.map +1 -0
- package/bin/session/input/StepInput.d.ts +77 -0
- package/bin/session/input/StepInput.d.ts.map +1 -0
- package/bin/session/input/StepInput.js +429 -0
- package/bin/session/input/StepInput.js.map +1 -0
- package/bin/session/input/composer/AdaptiveContextCheckpoint.d.ts +33 -0
- package/bin/session/input/composer/AdaptiveContextCheckpoint.d.ts.map +1 -0
- package/bin/session/input/composer/AdaptiveContextCheckpoint.js +83 -0
- package/bin/session/input/composer/AdaptiveContextCheckpoint.js.map +1 -0
- package/bin/session/input/composer/AdaptiveContextParts.d.ts +26 -0
- package/bin/session/input/composer/AdaptiveContextParts.d.ts.map +1 -0
- package/bin/session/input/composer/AdaptiveContextParts.js +124 -0
- package/bin/session/input/composer/AdaptiveContextParts.js.map +1 -0
- package/bin/session/input/composer/ComposerAssembly.d.ts +21 -0
- package/bin/session/input/composer/ComposerAssembly.d.ts.map +1 -0
- package/bin/session/input/composer/ComposerAssembly.js +64 -0
- package/bin/session/input/composer/ComposerAssembly.js.map +1 -0
- package/bin/session/{composer/policies/SessionSummaryPrompts.d.ts → input/composer/ContextSummaryPrompts.d.ts} +5 -3
- package/bin/session/input/composer/ContextSummaryPrompts.d.ts.map +1 -0
- package/bin/session/{composer/policies/SessionSummaryPrompts.js → input/composer/ContextSummaryPrompts.js} +5 -3
- package/bin/session/input/composer/ContextSummaryPrompts.js.map +1 -0
- package/bin/session/input/composer/DefaultSessionComposer.d.ts +24 -0
- package/bin/session/input/composer/DefaultSessionComposer.d.ts.map +1 -0
- package/bin/session/input/composer/DefaultSessionComposer.js +108 -0
- package/bin/session/input/composer/DefaultSessionComposer.js.map +1 -0
- package/bin/session/input/composer/FullHistorySessionComposer.d.ts +19 -0
- package/bin/session/input/composer/FullHistorySessionComposer.d.ts.map +1 -0
- package/bin/session/input/composer/FullHistorySessionComposer.js +36 -0
- package/bin/session/input/composer/FullHistorySessionComposer.js.map +1 -0
- package/bin/session/{SessionLoop.d.ts → loop/SessionLoop.d.ts} +34 -7
- package/bin/session/loop/SessionLoop.d.ts.map +1 -0
- package/bin/session/{SessionLoop.js → loop/SessionLoop.js} +79 -16
- package/bin/session/loop/SessionLoop.js.map +1 -0
- package/bin/session/{SessionQueue.d.ts → loop/SessionQueue.d.ts} +9 -1
- package/bin/session/loop/SessionQueue.d.ts.map +1 -0
- package/bin/session/{SessionQueue.js → loop/SessionQueue.js} +19 -0
- package/bin/session/loop/SessionQueue.js.map +1 -0
- package/bin/session/{SessionState.d.ts → loop/SessionState.d.ts} +4 -5
- package/bin/session/loop/SessionState.d.ts.map +1 -0
- package/bin/session/{SessionState.js → loop/SessionState.js} +6 -25
- package/bin/session/loop/SessionState.js.map +1 -0
- package/bin/session/{SessionTitle.d.ts → loop/SessionTitle.d.ts} +4 -4
- package/bin/session/loop/SessionTitle.d.ts.map +1 -0
- package/bin/session/{SessionTitle.js → loop/SessionTitle.js} +3 -3
- package/bin/session/loop/SessionTitle.js.map +1 -0
- package/bin/session/loop/SessionTitleTask.d.ts.map +1 -0
- package/bin/session/loop/SessionTitleTask.js.map +1 -0
- package/bin/session/{runtime → loop}/SessionTurnCompletion.d.ts +7 -0
- package/bin/session/loop/SessionTurnCompletion.d.ts.map +1 -0
- package/bin/session/{runtime → loop}/SessionTurnCompletion.js +25 -6
- package/bin/session/loop/SessionTurnCompletion.js.map +1 -0
- package/bin/session/loop/SessionTurnContext.d.ts +12 -0
- package/bin/session/loop/SessionTurnContext.d.ts.map +1 -0
- package/bin/session/{runtime → loop}/SessionTurnContext.js +14 -67
- package/bin/session/loop/SessionTurnContext.js.map +1 -0
- package/bin/session/loop/SessionTurnFileDiff.d.ts.map +1 -0
- package/bin/session/{runtime → loop}/SessionTurnFileDiff.js +1 -1
- package/bin/session/loop/SessionTurnFileDiff.js.map +1 -0
- package/bin/session/{messages → loop}/SessionTurnFileDiffBuilder.d.ts +3 -3
- package/bin/session/loop/SessionTurnFileDiffBuilder.d.ts.map +1 -0
- package/bin/session/loop/SessionTurnFileDiffBuilder.js.map +1 -0
- package/bin/session/messages/ApprovalInteraction.d.ts +30 -0
- package/bin/session/messages/ApprovalInteraction.d.ts.map +1 -0
- package/bin/session/messages/ApprovalInteraction.js +61 -0
- package/bin/session/messages/ApprovalInteraction.js.map +1 -0
- package/bin/session/messages/SessionAgentMessageState.d.ts +47 -18
- package/bin/session/messages/SessionAgentMessageState.d.ts.map +1 -1
- package/bin/session/messages/SessionAgentMessageState.js +224 -86
- package/bin/session/messages/SessionAgentMessageState.js.map +1 -1
- package/bin/session/messages/SessionAgentMessageWriter.d.ts +15 -4
- package/bin/session/messages/SessionAgentMessageWriter.d.ts.map +1 -1
- package/bin/session/messages/SessionAgentMessageWriter.js +57 -37
- package/bin/session/messages/SessionAgentMessageWriter.js.map +1 -1
- package/bin/session/messages/SessionAgentParts.d.ts +14 -0
- package/bin/session/messages/SessionAgentParts.d.ts.map +1 -0
- package/bin/session/messages/SessionAgentParts.js +20 -0
- package/bin/session/messages/SessionAgentParts.js.map +1 -0
- package/bin/session/{execution → messages}/SessionAssistantOutputAdapter.d.ts +2 -2
- package/bin/session/messages/SessionAssistantOutputAdapter.d.ts.map +1 -0
- package/bin/session/messages/SessionAssistantOutputAdapter.js.map +1 -0
- package/bin/session/messages/SessionEventHub.d.ts.map +1 -0
- package/bin/session/messages/SessionEventHub.js.map +1 -0
- package/bin/session/messages/SessionInteractions.d.ts +57 -0
- package/bin/session/messages/SessionInteractions.d.ts.map +1 -0
- package/bin/session/messages/SessionInteractions.js +178 -0
- package/bin/session/messages/SessionInteractions.js.map +1 -0
- package/bin/session/messages/SessionJsonValue.d.ts +1 -3
- package/bin/session/messages/SessionJsonValue.d.ts.map +1 -1
- package/bin/session/messages/SessionJsonValue.js +0 -19
- package/bin/session/messages/SessionJsonValue.js.map +1 -1
- package/bin/session/messages/SessionMessageCache.d.ts +55 -0
- package/bin/session/messages/SessionMessageCache.d.ts.map +1 -0
- package/bin/session/messages/SessionMessageCache.js +133 -0
- package/bin/session/messages/SessionMessageCache.js.map +1 -0
- package/bin/session/messages/SessionMessageState.d.ts +17 -0
- package/bin/session/messages/SessionMessageState.d.ts.map +1 -0
- package/bin/session/messages/SessionMessageState.js +34 -0
- package/bin/session/messages/SessionMessageState.js.map +1 -0
- package/bin/session/messages/SessionMessageTimeline.d.ts.map +1 -0
- package/bin/session/{browse → messages}/SessionMessageTimeline.js +0 -1
- package/bin/session/messages/SessionMessageTimeline.js.map +1 -0
- package/bin/session/{SessionMessages.d.ts → messages/SessionMessages.d.ts} +35 -43
- package/bin/session/messages/SessionMessages.d.ts.map +1 -0
- package/bin/session/{SessionMessages.js → messages/SessionMessages.js} +178 -196
- package/bin/session/messages/SessionMessages.js.map +1 -0
- package/bin/session/messages/SessionModelRequestWarning.d.ts.map +1 -0
- package/bin/session/messages/SessionModelRequestWarning.js.map +1 -0
- package/bin/session/messages/SessionMutationFactory.d.ts +26 -0
- package/bin/session/messages/SessionMutationFactory.d.ts.map +1 -0
- package/bin/session/messages/SessionMutationFactory.js +38 -0
- package/bin/session/messages/SessionMutationFactory.js.map +1 -0
- package/bin/session/messages/SessionUserMessage.d.ts +5 -7
- package/bin/session/messages/SessionUserMessage.d.ts.map +1 -1
- package/bin/session/messages/SessionUserMessage.js +5 -28
- package/bin/session/messages/SessionUserMessage.js.map +1 -1
- package/bin/{executor/core-engine/CoreEngineSignals.d.ts → session/runner/AssistantParts.d.ts} +4 -9
- package/bin/session/runner/AssistantParts.d.ts.map +1 -0
- package/bin/{executor/core-engine/CoreEngineSignals.js → session/runner/AssistantParts.js} +4 -17
- package/bin/session/runner/AssistantParts.js.map +1 -0
- package/bin/session/runner/ContextPressure.d.ts +15 -0
- package/bin/session/runner/ContextPressure.d.ts.map +1 -0
- package/bin/{executor/core-engine/CoreEngineContextCompaction.js → session/runner/ContextPressure.js} +11 -11
- package/bin/session/runner/ContextPressure.js.map +1 -0
- package/bin/session/runner/ContextRetry.d.ts +39 -0
- package/bin/session/runner/ContextRetry.d.ts.map +1 -0
- package/bin/{executor/services/ExecutorRecoveryPolicy.js → session/runner/ContextRetry.js} +19 -19
- package/bin/session/runner/ContextRetry.js.map +1 -0
- package/bin/{executor/core-engine/CoreEngineError.d.ts → session/runner/ModelFailure.d.ts} +4 -4
- package/bin/session/runner/ModelFailure.d.ts.map +1 -0
- package/bin/{executor/core-engine/CoreEngineError.js → session/runner/ModelFailure.js} +4 -4
- package/bin/session/runner/ModelFailure.js.map +1 -0
- package/bin/session/runner/SessionExecutor.d.ts +108 -0
- package/bin/session/runner/SessionExecutor.d.ts.map +1 -0
- package/bin/session/runner/SessionExecutor.js +430 -0
- package/bin/session/runner/SessionExecutor.js.map +1 -0
- package/bin/session/runner/ToolLoopDecision.d.ts +60 -0
- package/bin/session/runner/ToolLoopDecision.d.ts.map +1 -0
- package/bin/{executor/core-engine/CoreEngineLoopDecision.js → session/runner/ToolLoopDecision.js} +5 -5
- package/bin/session/runner/ToolLoopDecision.js.map +1 -0
- package/bin/session/runner/ToolLoopLimits.d.ts +30 -0
- package/bin/session/runner/ToolLoopLimits.d.ts.map +1 -0
- package/bin/session/runner/ToolLoopLimits.js +46 -0
- package/bin/session/runner/ToolLoopLimits.js.map +1 -0
- package/bin/session/{browse → storage}/Browse.d.ts +1 -1
- package/bin/session/storage/Browse.d.ts.map +1 -0
- package/bin/session/{browse → storage}/Browse.js +1 -1
- package/bin/session/storage/Browse.js.map +1 -0
- package/bin/session/storage/LocalSessionStore.js +1 -1
- package/bin/session/storage/LocalSessionStore.js.map +1 -1
- package/bin/session/storage/LocalStorePaths.d.ts +0 -2
- package/bin/session/storage/LocalStorePaths.d.ts.map +1 -1
- package/bin/session/storage/LocalStorePaths.js +1 -1
- package/bin/session/storage/LocalStorePaths.js.map +1 -1
- package/bin/session/storage/Metadata.d.ts +1 -23
- package/bin/session/storage/Metadata.d.ts.map +1 -1
- package/bin/session/storage/Metadata.js +0 -18
- package/bin/session/storage/Metadata.js.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.d.ts +0 -4
- package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.js +0 -1
- package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
- package/bin/session/{preview → storage}/SessionMessagePreview.d.ts.map +1 -1
- package/bin/session/{preview → storage}/SessionMessagePreview.js +0 -1
- package/bin/session/{preview → storage}/SessionMessagePreview.js.map +1 -1
- package/bin/session/storage/SessionStorageCodec.d.ts.map +1 -1
- package/bin/session/storage/SessionStorageCodec.js +36 -18
- package/bin/session/storage/SessionStorageCodec.js.map +1 -1
- package/bin/session/storage/SessionStorageSchema.d.ts +1 -1
- package/bin/session/storage/SessionStorageSchema.js +1 -1
- package/bin/session/storage/SqliteSessionStorage.d.ts +6 -4
- package/bin/session/storage/SqliteSessionStorage.d.ts.map +1 -1
- package/bin/session/storage/SqliteSessionStorage.js +21 -18
- package/bin/session/storage/SqliteSessionStorage.js.map +1 -1
- package/bin/tools/ask/AskQuestionAnswers.d.ts +20 -0
- package/bin/tools/ask/AskQuestionAnswers.d.ts.map +1 -0
- package/bin/tools/ask/AskQuestionAnswers.js +99 -0
- package/bin/tools/ask/AskQuestionAnswers.js.map +1 -0
- package/bin/tools/ask/AskQuestionsTool.d.ts +5 -2
- package/bin/tools/ask/AskQuestionsTool.d.ts.map +1 -1
- package/bin/tools/ask/AskQuestionsTool.js +23 -31
- package/bin/tools/ask/AskQuestionsTool.js.map +1 -1
- package/bin/tools/ask/AskQuestionsToolSchemas.d.ts +1 -1
- package/bin/types/agent/AgentOptions.d.ts +16 -8
- package/bin/types/agent/AgentOptions.d.ts.map +1 -1
- package/bin/types/agent/AgentSessionCollection.d.ts +8 -0
- package/bin/types/agent/AgentSessionCollection.d.ts.map +1 -1
- package/bin/types/agent/SessionActor.d.ts +3 -3
- package/bin/types/agent/SessionActor.d.ts.map +1 -1
- package/bin/types/group/DispatchStrategy.js +1 -1
- package/bin/types/group/DispatchStrategy.js.map +1 -1
- package/bin/types/group/GroupSession.d.ts +41 -1
- package/bin/types/group/GroupSession.d.ts.map +1 -1
- package/bin/types/group/GroupSessionStore.d.ts +30 -3
- package/bin/types/group/GroupSessionStore.d.ts.map +1 -1
- package/bin/types/model/ModelRequest.d.ts.map +1 -0
- package/bin/types/model/ModelRequest.js.map +1 -0
- package/bin/types/sdk/AgentSessionAction.d.ts +1 -9
- package/bin/types/sdk/AgentSessionAction.d.ts.map +1 -1
- package/bin/types/session/{AdaptivePartContextPolicy.d.ts → ContextCheckpoint.d.ts} +10 -9
- package/bin/types/session/ContextCheckpoint.d.ts.map +1 -0
- package/bin/types/session/ContextCheckpoint.js +8 -0
- package/bin/types/session/ContextCheckpoint.js.map +1 -0
- package/bin/types/session/SessionAgentMessageState.d.ts +6 -10
- package/bin/types/session/SessionAgentMessageState.d.ts.map +1 -1
- package/bin/types/session/SessionAgentMessageState.js +3 -2
- package/bin/types/session/SessionAgentMessageState.js.map +1 -1
- package/bin/types/session/SessionComposer.d.ts +65 -36
- package/bin/types/session/SessionComposer.d.ts.map +1 -1
- package/bin/types/session/SessionComposer.js +7 -2
- package/bin/types/session/SessionComposer.js.map +1 -1
- package/bin/types/session/SessionExecution.d.ts +15 -11
- package/bin/types/session/SessionExecution.d.ts.map +1 -1
- package/bin/types/session/SessionExecution.js +1 -1
- package/bin/types/session/SessionInteractions.d.ts +0 -2
- package/bin/types/session/SessionInteractions.d.ts.map +1 -1
- package/bin/types/session/SessionLocalState.d.ts +0 -4
- package/bin/types/session/SessionLocalState.d.ts.map +1 -1
- package/bin/types/session/SessionLoop.d.ts +33 -12
- package/bin/types/session/SessionLoop.d.ts.map +1 -1
- package/bin/types/session/SessionMessages.d.ts +3 -29
- package/bin/types/session/SessionMessages.d.ts.map +1 -1
- package/bin/types/session/SessionOptions.d.ts +16 -13
- package/bin/types/session/SessionOptions.d.ts.map +1 -1
- package/bin/types/session/SessionPort.d.ts +0 -3
- package/bin/types/session/SessionPort.d.ts.map +1 -1
- package/bin/types/session/SessionState.d.ts +0 -1
- package/bin/types/session/SessionState.d.ts.map +1 -1
- package/bin/types/session/SessionSystem.d.ts +10 -12
- package/bin/types/session/SessionSystem.d.ts.map +1 -1
- package/bin/types/session/SessionTool.d.ts +2 -2
- package/bin/types/session/SessionTool.d.ts.map +1 -1
- package/bin/types/session/SessionTurnCompletion.d.ts +12 -2
- package/bin/types/session/SessionTurnCompletion.d.ts.map +1 -1
- package/bin/types/session/SessionTurnFileDiff.d.ts +4 -4
- package/bin/types/session/SessionTurnFileDiff.d.ts.map +1 -1
- package/bin/types/session/{SessionComposition.d.ts → StepInput.d.ts} +17 -15
- package/bin/types/session/StepInput.d.ts.map +1 -0
- package/bin/types/session/StepInput.js +8 -0
- package/bin/types/session/StepInput.js.map +1 -0
- package/bin/types/store/SessionHistoryMeta.d.ts.map +1 -0
- package/bin/types/store/SessionHistoryMeta.js.map +1 -0
- package/bin/types/store/SessionStorage.d.ts +17 -12
- package/bin/types/store/SessionStorage.d.ts.map +1 -1
- package/bin/types/tool/BoundAgentTool.d.ts +36 -0
- package/bin/types/tool/BoundAgentTool.d.ts.map +1 -0
- package/bin/types/tool/BoundAgentTool.js +13 -0
- package/bin/types/tool/BoundAgentTool.js.map +1 -0
- package/bin/types/tools/ask/AskQuestionsTool.d.ts +9 -13
- package/bin/types/tools/ask/AskQuestionsTool.d.ts.map +1 -1
- package/bin/types/tools/ask/AskQuestionsTool.js +3 -2
- package/bin/types/tools/ask/AskQuestionsTool.js.map +1 -1
- package/bin/types/turn/SessionAssistantOutput.d.ts.map +1 -0
- package/bin/types/turn/SessionAssistantOutput.js.map +1 -0
- package/bin/types/{executor → turn}/SessionTurnContext.d.ts +10 -28
- package/bin/types/turn/SessionTurnContext.d.ts.map +1 -0
- package/bin/types/turn/SessionTurnContext.js.map +1 -0
- package/bin/{executor/ids/resolveSessionId.d.ts → utils/ResolveSessionId.d.ts} +1 -1
- package/bin/utils/ResolveSessionId.d.ts.map +1 -0
- package/bin/{executor/ids/resolveSessionId.js → utils/ResolveSessionId.js} +1 -1
- package/bin/utils/ResolveSessionId.js.map +1 -0
- package/bin/utils/Time.d.ts +5 -8
- package/bin/utils/Time.d.ts.map +1 -1
- package/bin/utils/Time.js +5 -54
- package/bin/utils/Time.js.map +1 -1
- package/package.json +2 -2
- package/scripts/ask-question-answers.test.mjs +132 -0
- package/scripts/group-session-archive.test.mjs +193 -0
- package/scripts/{core-engine-model-stream.test.mjs → model-step-runner.test.mjs} +97 -4
- package/scripts/rewrite-build-aliases.mjs +3 -4
- package/scripts/session-action-part.test.mjs +172 -0
- package/scripts/session-agent-message-part-order.test.mjs +13 -7
- package/scripts/{core-engine-context-compaction.test.mjs → session-executor-context-pressure.test.mjs} +40 -32
- package/scripts/{executor-failure-result.test.mjs → session-executor-failure-result.test.mjs} +17 -14
- package/scripts/session-executor-max-steps.test.mjs +143 -0
- package/scripts/session-initialization.test.mjs +3 -4
- package/scripts/session-interaction-migration.test.mjs +145 -0
- package/scripts/session-interaction-mutation.test.mjs +202 -0
- package/scripts/session-messages-error-part.test.mjs +1 -1
- package/scripts/session-messages-error.test.mjs +1 -1
- package/scripts/session-prompt-idempotency.test.mjs +4 -2
- package/scripts/session-queue.test.mjs +21 -1
- package/scripts/session-storage-sqlite.test.mjs +3 -3
- package/scripts/session-system-blocks.test.mjs +61 -39
- package/scripts/session-turn-context.test.mjs +37 -40
- package/scripts/verify-build-aliases.mjs +1 -1
- package/src/agent/Agent.ts +137 -80
- package/src/agent/AgentInstructions.ts +48 -15
- package/src/agent/AgentMemoryStorage.ts +1 -1
- package/src/agent/AgentSessions.ts +60 -38
- package/src/group/Group.ts +27 -24
- package/src/group/GroupSession.ts +12 -8
- package/src/group/GroupSessions.ts +79 -20
- package/src/group/storage/LocalGroupSessionDataStore.ts +9 -1
- package/src/group/storage/LocalGroupSessionStore.ts +138 -28
- package/src/index.ts +35 -52
- package/src/{executor/model → model}/ModelGenerate.ts +3 -3
- package/src/{executor/model → model}/ModelRequestRunner.ts +2 -2
- package/src/{executor/model → model}/ModelStepRunner.ts +22 -19
- package/src/{executor/model → model}/ModelStreamConsumer.ts +1 -1
- package/src/model/README.md +117 -0
- package/src/model/ToolInputValidation.ts +58 -0
- package/src/{executor → model}/messages/ChatMessageMarkupTypes.ts +1 -1
- package/src/{executor → model}/messages/SessionModelMessages.ts +0 -1
- package/src/{executor/composer/system/default → model/prompts}/SystemPromptAssets.ts +1 -1
- package/src/model/prompts/assets/core.prompt.ts +9 -0
- package/src/{executor/composer/system/default → model/prompts}/assets/core.prompt.ts.txt +26 -25
- package/src/session/Session.ts +185 -151
- package/src/session/input/SessionHookRunner.ts +100 -0
- package/src/session/{SessionSystem.ts → input/SessionSystem.ts} +31 -29
- package/src/session/input/StepInput.ts +507 -0
- package/src/session/input/composer/AdaptiveContextCheckpoint.ts +115 -0
- package/src/session/input/composer/AdaptiveContextParts.ts +166 -0
- package/src/session/input/composer/ComposerAssembly.ts +81 -0
- package/src/session/{composer/policies/SessionSummaryPrompts.ts → input/composer/ContextSummaryPrompts.ts} +5 -2
- package/src/session/input/composer/DefaultSessionComposer.ts +147 -0
- package/src/session/input/composer/FullHistorySessionComposer.ts +55 -0
- package/src/session/loop/README.md +28 -0
- package/src/session/{SessionLoop.ts → loop/SessionLoop.ts} +100 -24
- package/src/session/{SessionQueue.ts → loop/SessionQueue.ts} +18 -0
- package/src/session/{SessionState.ts → loop/SessionState.ts} +4 -21
- package/src/session/{SessionTitle.ts → loop/SessionTitle.ts} +3 -3
- package/src/session/{runtime → loop}/SessionTurnCompletion.ts +27 -8
- package/src/session/{runtime → loop}/SessionTurnContext.ts +19 -93
- package/src/session/{runtime → loop}/SessionTurnFileDiff.ts +1 -1
- package/src/session/{messages → loop}/SessionTurnFileDiffBuilder.ts +4 -4
- package/src/session/messages/ApprovalInteraction.ts +77 -0
- package/src/session/messages/README.md +27 -0
- package/src/session/messages/SessionAgentMessageState.ts +324 -113
- package/src/session/messages/SessionAgentMessageWriter.ts +82 -45
- package/src/session/messages/SessionAgentParts.ts +39 -0
- package/src/session/{execution → messages}/SessionAssistantOutputAdapter.ts +2 -2
- package/src/session/messages/SessionInteractions.ts +227 -0
- package/src/session/messages/SessionJsonValue.ts +1 -18
- package/src/session/messages/SessionMessageCache.ts +171 -0
- package/src/session/messages/SessionMessageState.ts +42 -0
- package/src/session/{browse → messages}/SessionMessageTimeline.ts +0 -1
- package/src/session/{SessionMessages.ts → messages/SessionMessages.ts} +225 -284
- package/src/session/messages/SessionMutationFactory.ts +58 -0
- package/src/session/messages/SessionUserMessage.ts +7 -32
- package/src/{executor/core-engine/CoreEngineSignals.ts → session/runner/AssistantParts.ts} +3 -21
- package/src/{executor/core-engine/CoreEngineContextCompaction.ts → session/runner/ContextPressure.ts} +10 -10
- package/src/{executor/services/ExecutorRecoveryPolicy.ts → session/runner/ContextRetry.ts} +25 -25
- package/src/{executor/core-engine/CoreEngineError.ts → session/runner/ModelFailure.ts} +3 -3
- package/src/session/runner/SessionExecutor.ts +633 -0
- package/src/session/runner/ToolLoopDecision.ts +98 -0
- package/src/session/runner/ToolLoopLimits.ts +53 -0
- package/src/session/{browse → storage}/Browse.ts +2 -2
- package/src/session/storage/LocalSessionStore.ts +1 -1
- package/src/session/storage/LocalStorePaths.ts +1 -1
- package/src/session/storage/Metadata.ts +1 -44
- package/src/session/storage/RuntimeSessionPort.ts +0 -5
- package/src/session/{preview → storage}/SessionMessagePreview.ts +0 -1
- package/src/session/storage/SessionStorageCodec.ts +54 -28
- package/src/session/storage/SessionStorageSchema.ts +1 -1
- package/src/session/storage/SqliteSessionStorage.ts +29 -22
- package/src/tools/ask/AskQuestionAnswers.ts +125 -0
- package/src/tools/ask/AskQuestionsTool.ts +32 -37
- package/src/types/agent/AgentOptions.ts +17 -8
- package/src/types/agent/AgentSessionCollection.ts +9 -0
- package/src/types/agent/SessionActor.ts +3 -4
- package/src/types/group/DispatchStrategy.ts +1 -1
- package/src/types/group/GroupSession.ts +44 -1
- package/src/types/group/GroupSessionStore.ts +30 -3
- package/src/types/sdk/AgentSessionAction.ts +1 -14
- package/src/types/session/{AdaptivePartContextPolicy.ts → ContextCheckpoint.ts} +9 -8
- package/src/types/session/SessionAgentMessageState.ts +6 -16
- package/src/types/session/SessionComposer.ts +67 -39
- package/src/types/session/SessionExecution.ts +15 -13
- package/src/types/session/SessionInteractions.ts +0 -2
- package/src/types/session/SessionLocalState.ts +0 -5
- package/src/types/session/SessionLoop.ts +37 -12
- package/src/types/session/SessionMessages.ts +3 -34
- package/src/types/session/SessionOptions.ts +18 -13
- package/src/types/session/SessionPort.ts +0 -4
- package/src/types/session/SessionState.ts +0 -1
- package/src/types/session/SessionSystem.ts +10 -16
- package/src/types/session/SessionTool.ts +2 -2
- package/src/types/session/SessionTurnCompletion.ts +12 -2
- package/src/types/session/SessionTurnFileDiff.ts +4 -4
- package/src/types/session/{SessionComposition.ts → StepInput.ts} +22 -14
- package/src/types/store/SessionStorage.ts +17 -12
- package/src/types/tool/BoundAgentTool.ts +38 -0
- package/src/types/tools/ask/AskQuestionsTool.ts +11 -13
- package/src/types/{executor → turn}/SessionTurnContext.ts +8 -34
- package/src/utils/Time.ts +12 -64
- package/tsconfig.json +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/executor/Executor.d.ts +0 -92
- package/bin/executor/Executor.d.ts.map +0 -1
- package/bin/executor/Executor.js +0 -232
- package/bin/executor/Executor.js.map +0 -1
- package/bin/executor/composer/system/default/SystemPromptAssets.d.ts.map +0 -1
- package/bin/executor/composer/system/default/SystemPromptAssets.js.map +0 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts +0 -7
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +0 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js +0 -8
- package/bin/executor/composer/system/default/assets/core.prompt.js.map +0 -1
- package/bin/executor/core-engine/CoreEngineContextCompaction.d.ts +0 -15
- package/bin/executor/core-engine/CoreEngineContextCompaction.d.ts.map +0 -1
- package/bin/executor/core-engine/CoreEngineContextCompaction.js.map +0 -1
- package/bin/executor/core-engine/CoreEngineError.d.ts.map +0 -1
- package/bin/executor/core-engine/CoreEngineError.js.map +0 -1
- package/bin/executor/core-engine/CoreEngineLoopDecision.d.ts +0 -26
- package/bin/executor/core-engine/CoreEngineLoopDecision.d.ts.map +0 -1
- package/bin/executor/core-engine/CoreEngineLoopDecision.js.map +0 -1
- package/bin/executor/core-engine/CoreEngineRunner.d.ts +0 -48
- package/bin/executor/core-engine/CoreEngineRunner.d.ts.map +0 -1
- package/bin/executor/core-engine/CoreEngineRunner.js +0 -343
- package/bin/executor/core-engine/CoreEngineRunner.js.map +0 -1
- package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +0 -1
- package/bin/executor/core-engine/CoreEngineSignals.js.map +0 -1
- package/bin/executor/ids/resolveSessionId.d.ts.map +0 -1
- package/bin/executor/ids/resolveSessionId.js.map +0 -1
- package/bin/executor/messages/ChatMessageMarkup.d.ts.map +0 -1
- package/bin/executor/messages/ChatMessageMarkup.js.map +0 -1
- package/bin/executor/messages/ChatMessageMarkupTypes.d.ts.map +0 -1
- package/bin/executor/messages/ChatMessageMarkupTypes.js.map +0 -1
- package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +0 -1
- package/bin/executor/messages/SessionAttachmentMapper.js.map +0 -1
- package/bin/executor/messages/SessionMessageLog.d.ts.map +0 -1
- package/bin/executor/messages/SessionMessageLog.js.map +0 -1
- package/bin/executor/messages/SessionModelMessages.d.ts.map +0 -1
- package/bin/executor/messages/SessionModelMessages.js.map +0 -1
- package/bin/executor/model/ModelGenerate.d.ts.map +0 -1
- package/bin/executor/model/ModelGenerate.js.map +0 -1
- package/bin/executor/model/ModelRequestRunner.d.ts.map +0 -1
- package/bin/executor/model/ModelRequestRunner.js.map +0 -1
- package/bin/executor/model/ModelStepRunner.d.ts.map +0 -1
- package/bin/executor/model/ModelStepRunner.js.map +0 -1
- package/bin/executor/model/ModelStreamConsumer.d.ts.map +0 -1
- package/bin/executor/model/ModelStreamConsumer.js.map +0 -1
- package/bin/executor/model/ModelStreamFailure.d.ts.map +0 -1
- package/bin/executor/model/ModelStreamFailure.js.map +0 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts +0 -39
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts.map +0 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.js.map +0 -1
- package/bin/executor/types/SessionHistoryMeta.d.ts.map +0 -1
- package/bin/executor/types/SessionHistoryMeta.js.map +0 -1
- package/bin/executor/types/SessionLoop.d.ts +0 -59
- package/bin/executor/types/SessionLoop.d.ts.map +0 -1
- package/bin/executor/types/SessionLoop.js +0 -9
- package/bin/executor/types/SessionLoop.js.map +0 -1
- package/bin/executor/types/SessionPrompts.d.ts +0 -14
- package/bin/executor/types/SessionPrompts.d.ts.map +0 -1
- package/bin/executor/types/SessionPrompts.js +0 -8
- package/bin/executor/types/SessionPrompts.js.map +0 -1
- package/bin/session/DefaultSessionComposer.d.ts +0 -24
- package/bin/session/DefaultSessionComposer.d.ts.map +0 -1
- package/bin/session/DefaultSessionComposer.js +0 -99
- package/bin/session/DefaultSessionComposer.js.map +0 -1
- package/bin/session/SessionComposition.d.ts +0 -49
- package/bin/session/SessionComposition.d.ts.map +0 -1
- package/bin/session/SessionComposition.js +0 -309
- package/bin/session/SessionComposition.js.map +0 -1
- package/bin/session/SessionHookPoints.d.ts +0 -15
- package/bin/session/SessionHookPoints.d.ts.map +0 -1
- package/bin/session/SessionHookPoints.js +0 -15
- package/bin/session/SessionHookPoints.js.map +0 -1
- package/bin/session/SessionHooks.d.ts +0 -38
- package/bin/session/SessionHooks.d.ts.map +0 -1
- package/bin/session/SessionHooks.js +0 -71
- package/bin/session/SessionHooks.js.map +0 -1
- package/bin/session/SessionLoop.d.ts.map +0 -1
- package/bin/session/SessionLoop.js.map +0 -1
- package/bin/session/SessionMessages.d.ts.map +0 -1
- package/bin/session/SessionMessages.js.map +0 -1
- package/bin/session/SessionQueue.d.ts.map +0 -1
- package/bin/session/SessionQueue.js.map +0 -1
- package/bin/session/SessionState.d.ts.map +0 -1
- package/bin/session/SessionState.js.map +0 -1
- package/bin/session/SessionSystem.d.ts +0 -19
- package/bin/session/SessionSystem.d.ts.map +0 -1
- package/bin/session/SessionSystem.js.map +0 -1
- package/bin/session/SessionTitle.d.ts.map +0 -1
- package/bin/session/SessionTitle.js.map +0 -1
- package/bin/session/browse/Browse.d.ts.map +0 -1
- package/bin/session/browse/Browse.js.map +0 -1
- package/bin/session/browse/SessionMessageTimeline.d.ts.map +0 -1
- package/bin/session/browse/SessionMessageTimeline.js.map +0 -1
- package/bin/session/composer/policies/AdaptivePartContextPolicy.d.ts +0 -35
- package/bin/session/composer/policies/AdaptivePartContextPolicy.d.ts.map +0 -1
- package/bin/session/composer/policies/AdaptivePartContextPolicy.js +0 -256
- package/bin/session/composer/policies/AdaptivePartContextPolicy.js.map +0 -1
- package/bin/session/composer/policies/FullHistoryContextPolicy.d.ts +0 -24
- package/bin/session/composer/policies/FullHistoryContextPolicy.d.ts.map +0 -1
- package/bin/session/composer/policies/FullHistoryContextPolicy.js +0 -31
- package/bin/session/composer/policies/FullHistoryContextPolicy.js.map +0 -1
- package/bin/session/composer/policies/SessionSummaryPrompts.d.ts.map +0 -1
- package/bin/session/composer/policies/SessionSummaryPrompts.js.map +0 -1
- package/bin/session/control/SessionInteractions.d.ts +0 -39
- package/bin/session/control/SessionInteractions.d.ts.map +0 -1
- package/bin/session/control/SessionInteractions.js +0 -255
- package/bin/session/control/SessionInteractions.js.map +0 -1
- package/bin/session/execution/SessionAssistantOutputAdapter.d.ts.map +0 -1
- package/bin/session/execution/SessionAssistantOutputAdapter.js.map +0 -1
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts +0 -28
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts.map +0 -1
- package/bin/session/execution/tools/SessionShellApprovalAdapter.js +0 -87
- package/bin/session/execution/tools/SessionShellApprovalAdapter.js.map +0 -1
- package/bin/session/messages/SessionAgentActionPartWriter.d.ts +0 -22
- package/bin/session/messages/SessionAgentActionPartWriter.d.ts.map +0 -1
- package/bin/session/messages/SessionAgentActionPartWriter.js +0 -36
- package/bin/session/messages/SessionAgentActionPartWriter.js.map +0 -1
- package/bin/session/messages/SessionMessageInteractionWriter.d.ts +0 -46
- package/bin/session/messages/SessionMessageInteractionWriter.d.ts.map +0 -1
- package/bin/session/messages/SessionMessageInteractionWriter.js +0 -183
- package/bin/session/messages/SessionMessageInteractionWriter.js.map +0 -1
- package/bin/session/messages/SessionTurnFileDiffBuilder.d.ts.map +0 -1
- package/bin/session/messages/SessionTurnFileDiffBuilder.js.map +0 -1
- package/bin/session/runtime/SessionEventHub.d.ts.map +0 -1
- package/bin/session/runtime/SessionEventHub.js.map +0 -1
- package/bin/session/runtime/SessionModelRequestWarning.d.ts.map +0 -1
- package/bin/session/runtime/SessionModelRequestWarning.js.map +0 -1
- package/bin/session/runtime/SessionTitleTask.d.ts.map +0 -1
- package/bin/session/runtime/SessionTitleTask.js.map +0 -1
- package/bin/session/runtime/SessionTurnCompletion.d.ts.map +0 -1
- package/bin/session/runtime/SessionTurnCompletion.js.map +0 -1
- package/bin/session/runtime/SessionTurnContext.d.ts +0 -29
- package/bin/session/runtime/SessionTurnContext.d.ts.map +0 -1
- package/bin/session/runtime/SessionTurnContext.js.map +0 -1
- package/bin/session/runtime/SessionTurnFileDiff.d.ts.map +0 -1
- package/bin/session/runtime/SessionTurnFileDiff.js.map +0 -1
- package/bin/types/action/ActionResult.d.ts +0 -35
- package/bin/types/action/ActionResult.d.ts.map +0 -1
- package/bin/types/action/ActionResult.js +0 -18
- package/bin/types/action/ActionResult.js.map +0 -1
- package/bin/types/executor/ModelRequest.d.ts.map +0 -1
- package/bin/types/executor/ModelRequest.js.map +0 -1
- package/bin/types/executor/SessionAssistantOutput.d.ts.map +0 -1
- package/bin/types/executor/SessionAssistantOutput.js.map +0 -1
- package/bin/types/executor/SessionToolExecutionContext.d.ts +0 -23
- package/bin/types/executor/SessionToolExecutionContext.d.ts.map +0 -1
- package/bin/types/executor/SessionToolExecutionContext.js +0 -10
- package/bin/types/executor/SessionToolExecutionContext.js.map +0 -1
- package/bin/types/executor/SessionTurnContext.d.ts.map +0 -1
- package/bin/types/executor/SessionTurnContext.js.map +0 -1
- package/bin/types/session/AdaptivePartContextPolicy.d.ts.map +0 -1
- package/bin/types/session/AdaptivePartContextPolicy.js +0 -7
- package/bin/types/session/AdaptivePartContextPolicy.js.map +0 -1
- package/bin/types/session/SessionComposition.d.ts.map +0 -1
- package/bin/types/session/SessionComposition.js +0 -8
- package/bin/types/session/SessionComposition.js.map +0 -1
- package/bin/types/session/SessionContextPolicy.d.ts +0 -70
- package/bin/types/session/SessionContextPolicy.d.ts.map +0 -1
- package/bin/types/session/SessionContextPolicy.js +0 -8
- package/bin/types/session/SessionContextPolicy.js.map +0 -1
- package/bin/types/tools/ToolActionExecutionContext.d.ts +0 -30
- package/bin/types/tools/ToolActionExecutionContext.d.ts.map +0 -1
- package/bin/types/tools/ToolActionExecutionContext.js +0 -8
- package/bin/types/tools/ToolActionExecutionContext.js.map +0 -1
- package/src/executor/Executor.ts +0 -319
- package/src/executor/README.md +0 -92
- package/src/executor/composer/system/default/assets/core.prompt.ts +0 -9
- package/src/executor/core-engine/CoreEngineLoopDecision.ts +0 -63
- package/src/executor/core-engine/CoreEngineRunner.ts +0 -458
- package/src/executor/types/SessionLoop.ts +0 -69
- package/src/executor/types/SessionPrompts.ts +0 -14
- package/src/session/DefaultSessionComposer.ts +0 -123
- package/src/session/SessionComposition.ts +0 -370
- package/src/session/SessionHookPoints.ts +0 -17
- package/src/session/SessionHooks.ts +0 -85
- package/src/session/composer/policies/AdaptivePartContextPolicy.ts +0 -307
- package/src/session/composer/policies/FullHistoryContextPolicy.ts +0 -36
- package/src/session/control/SessionInteractions.ts +0 -311
- package/src/session/execution/tools/SessionShellApprovalAdapter.ts +0 -105
- package/src/session/messages/SessionAgentActionPartWriter.ts +0 -54
- package/src/session/messages/SessionMessageInteractionWriter.ts +0 -279
- package/src/types/action/ActionResult.ts +0 -50
- package/src/types/executor/SessionToolExecutionContext.ts +0 -26
- package/src/types/session/SessionContextPolicy.ts +0 -77
- package/src/types/tools/ToolActionExecutionContext.ts +0 -32
- /package/bin/{executor/model → model}/ModelGenerate.js +0 -0
- /package/bin/{executor/model → model}/ModelRequestRunner.js +0 -0
- /package/bin/{executor/model → model}/ModelStreamConsumer.d.ts +0 -0
- /package/bin/{executor/model → model}/ModelStreamConsumer.js +0 -0
- /package/bin/{executor/model → model}/ModelStreamFailure.d.ts +0 -0
- /package/bin/{executor/model → model}/ModelStreamFailure.js +0 -0
- /package/bin/{executor → model}/messages/ChatMessageMarkup.d.ts +0 -0
- /package/bin/{executor → model}/messages/ChatMessageMarkup.js +0 -0
- /package/bin/{executor → model}/messages/SessionAttachmentMapper.d.ts +0 -0
- /package/bin/{executor → model}/messages/SessionAttachmentMapper.js +0 -0
- /package/bin/{executor → model}/messages/SessionMessageLog.d.ts +0 -0
- /package/bin/{executor → model}/messages/SessionMessageLog.js +0 -0
- /package/bin/{executor → model}/messages/SessionModelMessages.d.ts +0 -0
- /package/bin/{executor/composer/system/default → model/prompts}/SystemPromptAssets.d.ts +0 -0
- /package/bin/session/{runtime → loop}/SessionTitleTask.d.ts +0 -0
- /package/bin/session/{runtime → loop}/SessionTitleTask.js +0 -0
- /package/bin/session/{runtime → loop}/SessionTurnFileDiff.d.ts +0 -0
- /package/bin/session/{messages → loop}/SessionTurnFileDiffBuilder.js +0 -0
- /package/bin/session/{execution → messages}/SessionAssistantOutputAdapter.js +0 -0
- /package/bin/session/{runtime → messages}/SessionEventHub.d.ts +0 -0
- /package/bin/session/{runtime → messages}/SessionEventHub.js +0 -0
- /package/bin/session/{browse → messages}/SessionMessageTimeline.d.ts +0 -0
- /package/bin/session/{runtime → messages}/SessionModelRequestWarning.d.ts +0 -0
- /package/bin/session/{runtime → messages}/SessionModelRequestWarning.js +0 -0
- /package/bin/session/{preview → storage}/SessionMessagePreview.d.ts +0 -0
- /package/bin/types/{executor → model}/ModelRequest.d.ts +0 -0
- /package/bin/types/{executor → model}/ModelRequest.js +0 -0
- /package/bin/{executor/types → types/store}/SessionHistoryMeta.d.ts +0 -0
- /package/bin/{executor/types → types/store}/SessionHistoryMeta.js +0 -0
- /package/bin/types/{executor → turn}/SessionAssistantOutput.d.ts +0 -0
- /package/bin/types/{executor → turn}/SessionAssistantOutput.js +0 -0
- /package/bin/types/{executor → turn}/SessionTurnContext.js +0 -0
- /package/src/{executor/model → model}/ModelStreamFailure.ts +0 -0
- /package/src/{executor → model}/messages/ChatMessageMarkup.ts +0 -0
- /package/src/{executor → model}/messages/SessionAttachmentMapper.ts +0 -0
- /package/src/{executor → model}/messages/SessionMessageLog.ts +0 -0
- /package/src/session/{runtime → loop}/SessionTitleTask.ts +0 -0
- /package/src/session/{runtime → messages}/SessionEventHub.ts +0 -0
- /package/src/session/{runtime → messages}/SessionModelRequestWarning.ts +0 -0
- /package/src/types/{executor → model}/ModelRequest.ts +0 -0
- /package/src/{executor/types → types/store}/SessionHistoryMeta.ts +0 -0
- /package/src/types/{executor → turn}/SessionAssistantOutput.ts +0 -0
- /package/src/{executor/ids/resolveSessionId.ts → utils/ResolveSessionId.ts} +0 -0
|
@@ -8,8 +8,30 @@ import type {
|
|
|
8
8
|
GroupSessionStore,
|
|
9
9
|
GroupSessionStoreOptions,
|
|
10
10
|
} from "@/types/group/GroupSessionStore.js";
|
|
11
|
+
import type { GroupSessionArchiveResult, GroupSessionCleanArchiveResult } from "@/types/group/GroupSession.js";
|
|
11
12
|
import { LocalGroupSessionDataStore } from "@/group/storage/LocalGroupSessionDataStore.js";
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* GroupSession 的两个存储区。
|
|
16
|
+
*
|
|
17
|
+
* ```text
|
|
18
|
+
* <group-root>/sessions/<session_id>/ 活动
|
|
19
|
+
* <group-root>/archived-sessions/<session_id>/ 归档
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* 归档是**目录搬迁**而不是打标记:活动列表因此天然只含活动项,
|
|
23
|
+
* `list_session_metadata()` 不需要加过滤条件,`metadata.v` 也不用升版本。
|
|
24
|
+
* 这与 Agent Session 的做法一致(`LocalSessionStore.archive_session`),
|
|
25
|
+
* 两处同类能力不该有两套语义。
|
|
26
|
+
*/
|
|
27
|
+
type SessionArea = "active" | "archived";
|
|
28
|
+
|
|
29
|
+
/** 各存储区的目录名。 */
|
|
30
|
+
const area_directory_name: Record<SessionArea, string> = {
|
|
31
|
+
active: "sessions",
|
|
32
|
+
archived: "archived-sessions",
|
|
33
|
+
};
|
|
34
|
+
|
|
13
35
|
/** GroupSession 的底层文件 Store。 */
|
|
14
36
|
export class LocalGroupSessionStore implements GroupSessionStore {
|
|
15
37
|
private readonly files: FileSystem;
|
|
@@ -23,48 +45,106 @@ export class LocalGroupSessionStore implements GroupSessionStore {
|
|
|
23
45
|
this.group_id = options.group_id;
|
|
24
46
|
}
|
|
25
47
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
48
|
+
/**
|
|
49
|
+
* 返回指定 GroupSession 的持久化视图。
|
|
50
|
+
*
|
|
51
|
+
* 缓存键带存储区:同一个 session_id 在活动区与归档区各有一份视图,
|
|
52
|
+
* 不分区的话归档后会拿到活动区的旧视图(路径指向已经不存在的目录)。
|
|
53
|
+
*/
|
|
54
|
+
session(session_id: string, area: SessionArea = "active"): GroupSessionDataStore {
|
|
28
55
|
const resolved_session_id = String(session_id || "").trim();
|
|
29
56
|
if (!resolved_session_id) throw new Error("GroupSessionStore.session requires a non-empty session_id");
|
|
30
|
-
const
|
|
57
|
+
const cache_key = `${area}:${resolved_session_id}`;
|
|
58
|
+
const cached = this.sessions_by_id.get(cache_key);
|
|
31
59
|
if (cached) return cached;
|
|
32
60
|
const created = new LocalGroupSessionDataStore({
|
|
33
61
|
files: this.files,
|
|
34
62
|
storage_root_path: this.storage_root_path,
|
|
35
63
|
session_id: resolved_session_id,
|
|
36
64
|
group_id: this.group_id,
|
|
65
|
+
area,
|
|
37
66
|
});
|
|
38
|
-
this.sessions_by_id.set(
|
|
67
|
+
this.sessions_by_id.set(cache_key, created);
|
|
39
68
|
return created;
|
|
40
69
|
}
|
|
41
70
|
|
|
42
|
-
/** 判断指定 GroupSession
|
|
71
|
+
/** 判断指定 GroupSession 是否存在(活动区)。 */
|
|
43
72
|
async has_session(session_id: string): Promise<boolean> {
|
|
44
|
-
return await this.files.path_exists(this.session_path(session_id));
|
|
73
|
+
return await this.files.path_exists(this.session_path(session_id, "active"));
|
|
45
74
|
}
|
|
46
75
|
|
|
47
|
-
/** 列出当前 Group
|
|
76
|
+
/** 列出当前 Group 活动区的全部 Session metadata(不含已归档)。 */
|
|
48
77
|
async list_session_metadata(): Promise<GroupSessionHistoryMeta[]> {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
metadata.push(await this.session(session_id).read_metadata());
|
|
56
|
-
}
|
|
57
|
-
return metadata.sort((left, right) => right.updated_at - left.updated_at);
|
|
78
|
+
return await this.list_area_metadata("active");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** 列出归档区的 Session metadata。 */
|
|
82
|
+
async list_archived_session_metadata(): Promise<GroupSessionHistoryMeta[]> {
|
|
83
|
+
return await this.list_area_metadata("archived");
|
|
58
84
|
}
|
|
59
85
|
|
|
60
|
-
/** 删除指定 GroupSession
|
|
86
|
+
/** 删除指定 GroupSession 的全部数据(活动区)。 */
|
|
61
87
|
async remove_session(session_id: string): Promise<boolean> {
|
|
88
|
+
return await this.remove_area_session(session_id, "active");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** 删除归档区中的指定 Session。 */
|
|
92
|
+
async remove_archived_session(session_id: string): Promise<boolean> {
|
|
93
|
+
return await this.remove_area_session(session_id, "archived");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 把一个活动 GroupSession 迁入归档区。
|
|
98
|
+
*
|
|
99
|
+
* 用 `move_path` 而不是「复制再删除」:它是原子的,且**不覆盖已有目标**——
|
|
100
|
+
* 后者正是这里要的语义(覆盖会丢掉一份真实数据)。两个方向的失败都必须报错,
|
|
101
|
+
* 不能静默成功。
|
|
102
|
+
*
|
|
103
|
+
* **先查归档区再查活动区**,顺序不能反:重复归档时活动区已经空了,
|
|
104
|
+
* 先查活动区会报「not found」——而用户明明看得到那条群聊(在归档区),
|
|
105
|
+
* 那句话只会让他以为数据丢了。报「已归档」才是他需要知道的事。
|
|
106
|
+
*/
|
|
107
|
+
async archive_session(session_id: string): Promise<GroupSessionArchiveResult> {
|
|
62
108
|
const resolved_session_id = String(session_id || "").trim();
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
109
|
+
if (!resolved_session_id) throw new Error("GroupSessionStore.archive_session requires a non-empty session_id");
|
|
110
|
+
const target_path = this.session_path(resolved_session_id, "archived");
|
|
111
|
+
if (await this.files.path_exists(target_path)) {
|
|
112
|
+
throw new Error(`Archived GroupSession "${resolved_session_id}" already exists`);
|
|
113
|
+
}
|
|
114
|
+
const source_path = this.session_path(resolved_session_id, "active");
|
|
115
|
+
if (!(await this.files.path_exists(source_path))) {
|
|
116
|
+
throw new Error(`GroupSession "${resolved_session_id}" not found`);
|
|
117
|
+
}
|
|
118
|
+
await this.files.ensure_directory(this.area_path("archived"));
|
|
119
|
+
await this.files.move_path(source_path, target_path);
|
|
120
|
+
// 运行时缓存指向的是活动区路径;搬迁后必须丢掉它,否则下次 `session()` 会拿到旧视图。
|
|
121
|
+
this.sessions_by_id.delete(`active:${resolved_session_id}`);
|
|
122
|
+
return { session_id: resolved_session_id, archived_at: Date.now() };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** 永久清空归档区。 */
|
|
126
|
+
async clean_archive(): Promise<GroupSessionCleanArchiveResult> {
|
|
127
|
+
const archived_path = this.area_path("archived");
|
|
128
|
+
if (!(await this.files.path_exists(archived_path))) return { removed_session_ids: [] };
|
|
129
|
+
const entries = await this.files.read_directory(archived_path);
|
|
130
|
+
const removed_session_ids = entries
|
|
131
|
+
.filter((entry) => entry.is_directory)
|
|
132
|
+
.map((entry) => decode_session_id(entry.name));
|
|
133
|
+
await this.files.remove_path(archived_path);
|
|
134
|
+
return { removed_session_ids };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 永久删除当前 Group 的全部 GroupSession 数据。
|
|
139
|
+
*
|
|
140
|
+
* 两个区都删:Group 被删时它的活动会话与归档一样无处可访问,留着只是磁盘泄漏。
|
|
141
|
+
* 只删两个区目录而不是整个作用域根:作用域可能还装着 Group 的其它私有数据,
|
|
142
|
+
* 那些不归这个 Store 管。
|
|
143
|
+
*/
|
|
144
|
+
async purge(): Promise<void> {
|
|
145
|
+
await this.files.remove_path(this.area_path("active"));
|
|
146
|
+
await this.files.remove_path(this.area_path("archived"));
|
|
147
|
+
this.sessions_by_id.clear();
|
|
68
148
|
}
|
|
69
149
|
|
|
70
150
|
/** 释放当前 Store 的运行时缓存。 */
|
|
@@ -72,12 +152,42 @@ export class LocalGroupSessionStore implements GroupSessionStore {
|
|
|
72
152
|
this.sessions_by_id.clear();
|
|
73
153
|
}
|
|
74
154
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
155
|
+
/** 一个存储区的根目录。 */
|
|
156
|
+
private area_path(area: SessionArea): string {
|
|
157
|
+
return path.join(path.resolve(this.storage_root_path), area_directory_name[area]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 某个区里单个 Session 的目录。
|
|
162
|
+
*
|
|
163
|
+
* 两个区共用同一段拼接:各写一遍必然分叉,而这类路径一旦分叉,
|
|
164
|
+
* 表现是「归档后找不到了」——极难归因。
|
|
165
|
+
*/
|
|
166
|
+
private session_path(session_id: string, area: SessionArea): string {
|
|
167
|
+
return path.join(this.area_path(area), encodeURIComponent(String(session_id || "").trim()));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** 列出某个区的全部 Session metadata,按最近更新倒序。 */
|
|
171
|
+
private async list_area_metadata(area: SessionArea): Promise<GroupSessionHistoryMeta[]> {
|
|
172
|
+
const area_path = this.area_path(area);
|
|
173
|
+
if (!(await this.files.path_exists(area_path))) return [];
|
|
174
|
+
const entries = await this.files.read_directory(area_path);
|
|
175
|
+
const metadata: GroupSessionHistoryMeta[] = [];
|
|
176
|
+
for (const entry of entries.filter((item) => item.is_directory)) {
|
|
177
|
+
metadata.push(await this.session(decode_session_id(entry.name), area).read_metadata());
|
|
178
|
+
}
|
|
179
|
+
return metadata.sort((left, right) => right.updated_at - left.updated_at);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** 删除某个区里的一个 Session。 */
|
|
183
|
+
private async remove_area_session(session_id: string, area: SessionArea): Promise<boolean> {
|
|
184
|
+
const resolved_session_id = String(session_id || "").trim();
|
|
185
|
+
const session_path = this.session_path(resolved_session_id, area);
|
|
186
|
+
const existed = await this.files.path_exists(session_path);
|
|
187
|
+
if (existed) await this.files.remove_path(session_path);
|
|
188
|
+
// 只清这个区的缓存:同一个 id 在另一个区可能仍有视图。
|
|
189
|
+
this.sessions_by_id.delete(`${area}:${resolved_session_id}`);
|
|
190
|
+
return existed;
|
|
81
191
|
}
|
|
82
192
|
}
|
|
83
193
|
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 这是 agent 包核心运行时的稳定公开入口;可选 Tool 通过 `@downcity/agent/tools` 导出。
|
|
6
6
|
* - 只导出 Agent SDK 与必要的 Session 协议类型。
|
|
7
|
-
* - HTTP、RPC、
|
|
7
|
+
* - HTTP、RPC、Power、Workspace 与 Sandbox 实现不从根入口暴露。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
// Agent 入口
|
|
@@ -50,19 +50,19 @@ export type {
|
|
|
50
50
|
} from "./group/index.js";
|
|
51
51
|
export { AiDispatchStrategy } from "./group/index.js";
|
|
52
52
|
export type { SessionStore } from "./types/store/SessionStore.js";
|
|
53
|
+
export type {
|
|
54
|
+
SessionDerivedStore,
|
|
55
|
+
SessionDerivedStoreTransaction,
|
|
56
|
+
} from "./types/store/SessionStorage.js";
|
|
53
57
|
export type { SessionAttachmentStore } from "./types/store/SessionAttachmentStore.js";
|
|
54
58
|
export type { AgentStorage } from "./types/agent/AgentStorage.js";
|
|
55
59
|
export { Session } from "./session/Session.js";
|
|
56
|
-
export { SessionHooks, SessionHookScope } from "./session/SessionHooks.js";
|
|
57
|
-
export type { SessionOptions } from "./types/session/SessionOptions.js";
|
|
58
60
|
export type { SessionOrigin } from "@downcity/type";
|
|
59
|
-
export { SESSION_HOOK_POINTS } from "
|
|
61
|
+
export { SESSION_HOOK_POINTS } from "@downcity/type";
|
|
60
62
|
export type {
|
|
61
63
|
SessionCommittedTurnStatus,
|
|
62
64
|
SessionHookContextBlock,
|
|
63
65
|
SessionHookUserMessage,
|
|
64
|
-
SessionHookContext,
|
|
65
|
-
SessionHookHandlers,
|
|
66
66
|
SessionSystemContextHookValue,
|
|
67
67
|
SessionTurnCommittedHookValue,
|
|
68
68
|
SessionTurnContextHookValue,
|
|
@@ -97,7 +97,7 @@ export type {
|
|
|
97
97
|
SessionAgentActionPart,
|
|
98
98
|
SessionAgentDataPart,
|
|
99
99
|
SessionAgentFilePart,
|
|
100
|
-
|
|
100
|
+
SessionAgentInteraction,
|
|
101
101
|
SessionAgentMessage,
|
|
102
102
|
SessionAgentMessagePart,
|
|
103
103
|
SessionAgentReasoningPart,
|
|
@@ -124,8 +124,8 @@ export {
|
|
|
124
124
|
read_session_turn_file_diff_data,
|
|
125
125
|
SESSION_TURN_FILE_DIFF_DATA_TYPE,
|
|
126
126
|
} from "./session/messages/SessionTurnFileDiffData.js";
|
|
127
|
-
export { to_session_message_timeline_events } from "./session/
|
|
128
|
-
export { SessionAssistantOutputAdapter } from "./session/
|
|
127
|
+
export { to_session_message_timeline_events } from "./session/messages/SessionMessageTimeline.js";
|
|
128
|
+
export { SessionAssistantOutputAdapter } from "./session/messages/SessionAssistantOutputAdapter.js";
|
|
129
129
|
export {
|
|
130
130
|
is_session_mutation,
|
|
131
131
|
} from "@downcity/type";
|
|
@@ -148,24 +148,27 @@ export type {
|
|
|
148
148
|
} from "@downcity/type";
|
|
149
149
|
export type {
|
|
150
150
|
RespondSessionInteractionInput,
|
|
151
|
+
SessionApprovalDecision,
|
|
151
152
|
SessionApprovalMode,
|
|
153
|
+
SessionApprovalPort,
|
|
154
|
+
SessionApprovalRequestInput,
|
|
152
155
|
SessionCancelledInteractionResult,
|
|
153
|
-
SessionExpiredInteractionResult,
|
|
154
156
|
SessionInteractionAnswer,
|
|
155
157
|
SessionInteractionHandle,
|
|
156
158
|
SessionInteractionLifecycle,
|
|
157
159
|
SessionInteractionOption,
|
|
158
160
|
SessionInteractionPort,
|
|
159
161
|
SessionInteractionQuestion,
|
|
160
|
-
|
|
162
|
+
SessionInteractionQuestionType,
|
|
161
163
|
SessionInteractionRequest,
|
|
164
|
+
SessionInteractionRequestInput,
|
|
162
165
|
SessionInteractionResponse,
|
|
163
166
|
SessionInteractionResult,
|
|
164
167
|
SessionInteractionSource,
|
|
165
168
|
SessionInteractionStatus,
|
|
166
|
-
SessionPendingInteraction,
|
|
167
169
|
SessionResolvedInteractionResult,
|
|
168
170
|
} from "@downcity/type";
|
|
171
|
+
export { SESSION_APPROVAL_RESPONSE_SCHEMA } from "@downcity/type";
|
|
169
172
|
export type {
|
|
170
173
|
AgentOptions,
|
|
171
174
|
AgentSessionConstructor,
|
|
@@ -184,8 +187,6 @@ export type { AgentManagedSession } from "./types/session/SessionOptions.js";
|
|
|
184
187
|
export type {
|
|
185
188
|
AgentSessionActionCallback,
|
|
186
189
|
AgentSessionActionEvent,
|
|
187
|
-
AgentSessionActionRecord,
|
|
188
|
-
AgentSessionActionState,
|
|
189
190
|
} from "./types/sdk/AgentSessionAction.js";
|
|
190
191
|
export type {
|
|
191
192
|
AgentSessionPromptContent,
|
|
@@ -207,25 +208,24 @@ export type {
|
|
|
207
208
|
AgentSessionTurnResult,
|
|
208
209
|
} from "./types/sdk/AgentSessionTurn.js";
|
|
209
210
|
export type { SessionPort } from "./types/session/SessionPort.js";
|
|
210
|
-
export
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
export {
|
|
212
|
+
is_action_result,
|
|
213
|
+
type ActionResult,
|
|
214
|
+
type ActionResultMessage,
|
|
215
|
+
type SessionSystemMessage,
|
|
216
|
+
} from "@downcity/type";
|
|
214
217
|
|
|
215
218
|
// Session 与即时执行集成
|
|
216
|
-
export {
|
|
217
|
-
export { DefaultSessionComposer } from "./session/DefaultSessionComposer.js";
|
|
218
|
-
export {
|
|
219
|
-
export {
|
|
220
|
-
export { SessionMessages } from "./session/SessionMessages.js";
|
|
219
|
+
export { SessionExecutor } from "./session/runner/SessionExecutor.js";
|
|
220
|
+
export { DefaultSessionComposer } from "./session/input/composer/DefaultSessionComposer.js";
|
|
221
|
+
export { FullHistorySessionComposer } from "./session/input/composer/FullHistorySessionComposer.js";
|
|
222
|
+
export { SessionMessages } from "./session/messages/SessionMessages.js";
|
|
221
223
|
export type {
|
|
222
|
-
AppendCompletedAgentMessageInput,
|
|
223
224
|
AppendExternalSessionAgentMessageInput,
|
|
224
225
|
AppendExternalSessionUserMessageInput,
|
|
225
226
|
AppendSessionAgentErrorPartInput,
|
|
226
227
|
AppendSessionPromptMessageInput,
|
|
227
228
|
AppendSessionUserMessageInput,
|
|
228
|
-
OpenSessionAgentActionPartInput,
|
|
229
229
|
OpenSessionAgentMessageInput,
|
|
230
230
|
SessionMessagesOptions,
|
|
231
231
|
} from "./types/session/SessionMessages.js";
|
|
@@ -236,38 +236,20 @@ export type {
|
|
|
236
236
|
SessionComposeState,
|
|
237
237
|
SessionComposeTurn,
|
|
238
238
|
SessionComposerInitializeInput,
|
|
239
|
-
|
|
239
|
+
SessionContextAdvanceInput,
|
|
240
|
+
SessionContextAdvanceTrigger,
|
|
241
|
+
SessionContextDiagnostics,
|
|
240
242
|
SessionStepInput,
|
|
241
243
|
} from "./types/session/SessionComposer.js";
|
|
242
244
|
export type {
|
|
243
|
-
SessionContextPolicy,
|
|
244
|
-
SessionContextPolicyInitializeInput,
|
|
245
|
-
SessionContextPolicyInput,
|
|
246
|
-
SessionContextPolicyRecoveryInput,
|
|
247
|
-
SessionContextRecoveryReason,
|
|
248
|
-
SessionResolvedContext,
|
|
249
|
-
SessionResolvedContextDiagnostics,
|
|
250
|
-
} from "./types/session/SessionContextPolicy.js";
|
|
251
|
-
export type {
|
|
252
|
-
SessionExecutor,
|
|
253
245
|
SessionTurnExecutionResult,
|
|
254
246
|
} from "./types/session/SessionExecution.js";
|
|
255
|
-
export { create_session_turn_context } from "./session/
|
|
247
|
+
export { create_session_turn_context } from "./session/loop/SessionTurnContext.js";
|
|
256
248
|
export type {
|
|
257
249
|
SessionTurnContext,
|
|
258
250
|
SessionTurnContextInit,
|
|
259
|
-
} from "./types/
|
|
260
|
-
export type {
|
|
261
|
-
export type {
|
|
262
|
-
ToolActionExecutionContext,
|
|
263
|
-
ToolSessionExecutionScope,
|
|
264
|
-
} from "./types/tools/ToolActionExecutionContext.js";
|
|
265
|
-
export type {
|
|
266
|
-
SessionActionEvent,
|
|
267
|
-
SessionActionEventInput,
|
|
268
|
-
SessionActionStatus,
|
|
269
|
-
} from "@downcity/type";
|
|
270
|
-
export type { SessionSystemMessage } from "./executor/types/SessionPrompts.js";
|
|
251
|
+
} from "./types/turn/SessionTurnContext.js";
|
|
252
|
+
export type { SessionActionEvent, SessionActionStatus } from "@downcity/type";
|
|
271
253
|
export {
|
|
272
254
|
extract_session_message_text,
|
|
273
255
|
extract_session_tool_calls,
|
|
@@ -278,18 +260,19 @@ export {
|
|
|
278
260
|
build_chat_message_text,
|
|
279
261
|
parse_chat_message_markup,
|
|
280
262
|
render_chat_message_file_tag,
|
|
281
|
-
} from "./
|
|
263
|
+
} from "./model/messages/ChatMessageMarkup.js";
|
|
282
264
|
export type {
|
|
283
265
|
ChatMessageFileTag,
|
|
284
266
|
ChatMessageFileType,
|
|
285
267
|
ChatMessageSegment,
|
|
286
268
|
ChatMessageSendOptions,
|
|
287
|
-
} from "./
|
|
269
|
+
} from "./model/messages/ChatMessageMarkupTypes.js";
|
|
288
270
|
|
|
289
271
|
// 日志
|
|
290
272
|
export { get_logger, type Logger } from "./utils/logger/Logger.js";
|
|
291
273
|
export { generate_id } from "./utils/Id.js";
|
|
292
274
|
export {
|
|
275
|
+
format_date_in_timezone,
|
|
293
276
|
format_date_time_in_timezone,
|
|
294
277
|
resolve_runtime_timezone,
|
|
295
278
|
} from "./utils/Time.js";
|
|
@@ -297,4 +280,4 @@ export {
|
|
|
297
280
|
// JSON 基础类型
|
|
298
281
|
export type { JsonObject, JsonPrimitive, JsonValue } from "@downcity/type";
|
|
299
282
|
|
|
300
|
-
export { resolve_session_id } from "./
|
|
283
|
+
export { resolve_session_id } from "./utils/ResolveSessionId.js";
|
|
@@ -13,11 +13,11 @@ import type {
|
|
|
13
13
|
ModelToolCallContent,
|
|
14
14
|
ModelUsage,
|
|
15
15
|
} from "@downcity/type";
|
|
16
|
-
import { execute_model_request } from "
|
|
17
|
-
import { consume_model_stream } from "
|
|
16
|
+
import { execute_model_request } from "@/model/ModelRequestRunner.js";
|
|
17
|
+
import { consume_model_stream } from "@/model/ModelStreamConsumer.js";
|
|
18
18
|
import type {
|
|
19
19
|
ModelRequestFailureReporter,
|
|
20
|
-
} from "@/types/
|
|
20
|
+
} from "@/types/model/ModelRequest.js";
|
|
21
21
|
|
|
22
22
|
/** 单次非交互模型生成结果。 */
|
|
23
23
|
export interface ModelGenerateResult {
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { ModelRequestKind } from "@downcity/type";
|
|
8
|
-
import type { ModelRequestFailureReporter } from "@/types/
|
|
8
|
+
import type { ModelRequestFailureReporter } from "@/types/model/ModelRequest.js";
|
|
9
9
|
import {
|
|
10
10
|
ModelStreamFailure,
|
|
11
11
|
is_retryable_empty_model_stream_failure,
|
|
12
|
-
} from "
|
|
12
|
+
} from "@/model/ModelStreamFailure.js";
|
|
13
13
|
|
|
14
14
|
/** 首次模型调用失败后的最大自动重试次数。 */
|
|
15
15
|
export const MAX_MODEL_REQUEST_RETRIES = 5;
|
|
@@ -14,17 +14,17 @@ import {
|
|
|
14
14
|
type ModelStreamEvent,
|
|
15
15
|
type ModelTool,
|
|
16
16
|
type ModelUsage,
|
|
17
|
-
type RuntimeTool as Tool,
|
|
18
|
-
type RuntimeToolExecutionOptions as ToolExecutionOptions,
|
|
19
17
|
} from "@downcity/type";
|
|
18
|
+
import type { BoundAgentTool, ToolCallSite } from "@/types/tool/BoundAgentTool.js";
|
|
20
19
|
import { z } from "zod";
|
|
21
|
-
import type { SessionSystemMessage } from "
|
|
22
|
-
import type { SessionAssistantOutput } from "@/types/
|
|
20
|
+
import type { SessionSystemMessage } from "@downcity/type";
|
|
21
|
+
import type { SessionAssistantOutput } from "@/types/turn/SessionAssistantOutput.js";
|
|
23
22
|
import type {
|
|
24
23
|
SessionAgentMessagePart,
|
|
25
24
|
SessionAgentToolPart,
|
|
26
25
|
} from "@downcity/type";
|
|
27
|
-
import { consume_model_stream } from "@/
|
|
26
|
+
import { consume_model_stream } from "@/model/ModelStreamConsumer.js";
|
|
27
|
+
import { validate_tool_input } from "@/model/ToolInputValidation.js";
|
|
28
28
|
|
|
29
29
|
/** 单个工具调用的执行事实。 */
|
|
30
30
|
export interface ModelStepToolCall {
|
|
@@ -70,14 +70,12 @@ export interface RunModelStepInput {
|
|
|
70
70
|
system: SessionSystemMessage[];
|
|
71
71
|
/** 当前模型上下文。 */
|
|
72
72
|
messages: ModelMessage[];
|
|
73
|
-
/**
|
|
74
|
-
tools: Record<string,
|
|
73
|
+
/** 当前可用工具运行时;上下文已在包装层绑定。 */
|
|
74
|
+
tools: Record<string, BoundAgentTool>;
|
|
75
75
|
/** 当前取消信号。 */
|
|
76
76
|
abort_signal: AbortSignal;
|
|
77
77
|
/** canonical Assistant 输出端口。 */
|
|
78
78
|
assistant_output?: SessionAssistantOutput;
|
|
79
|
-
/** 工具执行前的审批回调。 */
|
|
80
|
-
approve_tool?: (call: ModelStepToolCall, tool: Tool) => Promise<boolean>;
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
/** 执行一个 Downcity 模型 Step 并收敛工具结果。 */
|
|
@@ -261,26 +259,31 @@ async function execute_tools(
|
|
|
261
259
|
});
|
|
262
260
|
continue;
|
|
263
261
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
262
|
+
// 关键点(中文):模型输入先按工具自己的 schema 校验,非法输入在执行之前
|
|
263
|
+
// 就形成结构化失败,不会带着错误类型进入工具实现。
|
|
264
|
+
const validated = validate_tool_input({
|
|
265
|
+
tool,
|
|
266
|
+
tool_name: call.tool_name,
|
|
267
|
+
input: call.input,
|
|
268
|
+
});
|
|
269
|
+
if ("error" in validated) {
|
|
268
270
|
results.push({
|
|
269
271
|
...call,
|
|
270
272
|
success: false,
|
|
271
|
-
output: { error:
|
|
273
|
+
output: { error: validated.error },
|
|
272
274
|
});
|
|
273
275
|
continue;
|
|
274
276
|
}
|
|
275
277
|
try {
|
|
276
|
-
const
|
|
278
|
+
const site: ToolCallSite = {
|
|
277
279
|
tool_call_id: call.tool_call_id,
|
|
278
280
|
messages,
|
|
279
|
-
abort_signal: input.abort_signal,
|
|
281
|
+
...(input.abort_signal ? { abort_signal: input.abort_signal } : {}),
|
|
280
282
|
};
|
|
281
|
-
const output = await tool.execute(
|
|
283
|
+
const output = await tool.execute(validated.input, site);
|
|
282
284
|
results.push({
|
|
283
285
|
...call,
|
|
286
|
+
input: validated.input,
|
|
284
287
|
success: !is_structured_tool_failure(output),
|
|
285
288
|
output,
|
|
286
289
|
});
|
|
@@ -314,8 +317,8 @@ function convert_system_messages(messages: SessionSystemMessage[]): ModelMessage
|
|
|
314
317
|
}));
|
|
315
318
|
}
|
|
316
319
|
|
|
317
|
-
/**
|
|
318
|
-
function convert_tools(tools: Record<string,
|
|
320
|
+
/** 把已绑定工具定义转换为只含 JSON Schema 的模型协议。 */
|
|
321
|
+
function convert_tools(tools: Record<string, BoundAgentTool>): ModelTool[] {
|
|
319
322
|
return Object.entries(tools).map(([name, tool]) => ({
|
|
320
323
|
name,
|
|
321
324
|
description: tool.description ?? "",
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
ModelStreamFailure,
|
|
18
18
|
normalize_model_invocation_failure,
|
|
19
19
|
normalize_model_protocol_failure,
|
|
20
|
-
} from "
|
|
20
|
+
} from "@/model/ModelStreamFailure.js";
|
|
21
21
|
|
|
22
22
|
/** 消费并校验一次完整模型事件流。 */
|
|
23
23
|
export async function consume_model_stream(
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Execution Module
|
|
2
|
+
|
|
3
|
+
`model/` 是模型请求与 Tool Loop 的低层内核;Session 级编排在 `session/runner/`。普通 SDK 用户只通过 `Session` 调用它。
|
|
4
|
+
|
|
5
|
+
完整 Session Runtime 设计见 [`docs/session-runtime-architecture.md`](../../../../docs/session-runtime-architecture.md)。
|
|
6
|
+
|
|
7
|
+
## 边界
|
|
8
|
+
|
|
9
|
+
- `Session` 拥有输入队列并创建 Command;`SessionLoop` 负责消费、Turn Handle 与 Assistant Message 收口。
|
|
10
|
+
- `SessionTurnContext` 从 Turn 创建起唯一拥有取消信号、Step 快照和执行期资源。
|
|
11
|
+
- `SessionComposer` 根据只读 Session 快照组装 system、messages 和 tools。
|
|
12
|
+
- `StepInput` 是 SessionLoop 的「输入环境」:刷新 Hook、请求 Composer 组装、冻结并套用 system、绑定工具执行上下文。
|
|
13
|
+
- `SessionExecutor` 负责模型请求、Tool Loop、续写恢复、上下文超限重试与真实 usage 观测;它只对外提供 `execute()`,Step 输入由回调提供。
|
|
14
|
+
- `ModelRequestRunner` 唯一拥有普通模型请求的五次重试、退避和逐次失败通知。
|
|
15
|
+
- `SessionMessages` 是 Message 唯一事实源;执行层不写文件、不持有 Store。
|
|
16
|
+
|
|
17
|
+
## 执行关系
|
|
18
|
+
|
|
19
|
+
```mermaid
|
|
20
|
+
flowchart LR
|
|
21
|
+
Loop["SessionLoop"] --> Context["SessionTurnContext"]
|
|
22
|
+
Loop --> Assembly["StepInput"]
|
|
23
|
+
Assembly --> Composer["SessionComposer"]
|
|
24
|
+
Composer --> Input["system + messages + tools"]
|
|
25
|
+
Context --> Executor["SessionExecutor"]
|
|
26
|
+
Input --> Executor
|
|
27
|
+
Executor --> Request["ModelRequestRunner"]
|
|
28
|
+
Request --> Step["ModelStepRunner"]
|
|
29
|
+
Step --> Model["ModelClient"]
|
|
30
|
+
Executor --> Tools["Tools / Plugins"]
|
|
31
|
+
Model -->|"ModelStreamEvent"| Step
|
|
32
|
+
Step --> Request
|
|
33
|
+
Step -->|"ModelStreamEvent / Tool Result"| Context
|
|
34
|
+
Context --> Messages["SessionMessages"]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
每个模型 Step 前,`SessionLoop` 先消费排队的 Steer 和状态 Command。`StepInput` 随后捕获最新 effective state,并调用 Composer 生成完整 Step 输入。
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
Session.prompt()
|
|
41
|
+
-> SessionLoop 持久化 canonical User Message
|
|
42
|
+
-> StepInput 捕获只读 Session 快照
|
|
43
|
+
-> SessionComposer.compose()
|
|
44
|
+
-> SessionModelMessages: SessionMessage -> ModelMessage
|
|
45
|
+
-> SessionExecutor.execute()
|
|
46
|
+
-> Federation / Provider 返回 ModelStreamEvent
|
|
47
|
+
-> SessionAssistantOutput 直接更新 canonical Assistant Message
|
|
48
|
+
-> SessionMessages 持久化并发布 Mutation
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 旧 Composer 去向
|
|
52
|
+
|
|
53
|
+
过去的四个独立 Composer 不再构成执行管线:
|
|
54
|
+
|
|
55
|
+
| 旧能力 | 当前归属 |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `SystemComposer` | `DefaultSessionComposer.compose()` + `SessionSystem` |
|
|
58
|
+
| `HistoryComposer` | `SessionComposer.compose()` + `SessionModelMessages` |
|
|
59
|
+
| `ContextComposer` 的 tools | `Session` 装配 + `SessionComposer.compose()` |
|
|
60
|
+
| `ContextComposer` 的 Step Callback | `SessionLoop` + `StepInput` |
|
|
61
|
+
| `ContextComposer` 的 fallback Assistant | `SessionExecutor` + `ContextAdvanceRetry` |
|
|
62
|
+
| `CompactionComposer` | `SessionComposer.advance_context()` + `session/input/composer/` 内的算法与派生表 |
|
|
63
|
+
|
|
64
|
+
统一 Composer 只回答一个策略问题:
|
|
65
|
+
|
|
66
|
+
1. 当前 Step 的 system、messages 和 tools 是什么?上下文超限时能否推进派生上下文?
|
|
67
|
+
|
|
68
|
+
Queue 消费、Turn 控制、Message 写入和 Mutation 发布都不是 Composer 职责。
|
|
69
|
+
|
|
70
|
+
## Context advance
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
SessionLoop / ContextAdvanceRetry
|
|
74
|
+
-> Session.advance_context(trigger)
|
|
75
|
+
-> SessionComposer.advance_context()
|
|
76
|
+
-> 默认实现在自己的 checkpoint 派生表推进边界
|
|
77
|
+
-> 下一次 compose() 读取最新派生上下文
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Composer 只接收调用方读好的 canonical history 快照与命名空间派生存储;它可以调用模型生成摘要,
|
|
81
|
+
但不能修改 canonical Message、Metadata 或发布事件。持久化提交始终由 `SessionStorage` 事务完成。
|
|
82
|
+
|
|
83
|
+
## 目录
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
model/
|
|
87
|
+
ModelGenerate.ts 共享的一次性模型生成入口
|
|
88
|
+
ModelRequestRunner.ts 单次模型请求的重试与失败通知
|
|
89
|
+
ModelStepRunner.ts 单个 Tool Loop Step 的模型调用
|
|
90
|
+
ModelStreamConsumer.ts 模型流消费
|
|
91
|
+
ModelStreamFailure.ts 模型流错误分类
|
|
92
|
+
messages/ Session 与 Model Protocol 消息转换
|
|
93
|
+
prompts/ 默认 core system prompt 资产
|
|
94
|
+
|
|
95
|
+
types/model/
|
|
96
|
+
ModelRequest.ts 模型请求失败上报契约
|
|
97
|
+
|
|
98
|
+
types/turn/
|
|
99
|
+
SessionTurnContext.ts 一个 Turn 的执行上下文
|
|
100
|
+
SessionAssistantOutput.ts Turn 的 Assistant 输出端口
|
|
101
|
+
|
|
102
|
+
session/input/
|
|
103
|
+
StepInput.ts 每步模型输入与冻结 system
|
|
104
|
+
SessionSystem.ts 默认 system block 组装
|
|
105
|
+
SessionHooks.ts Hook 运行类
|
|
106
|
+
SessionHookPoints.ts Hook 检查点目录
|
|
107
|
+
composer/ Composer 实现与压缩算法
|
|
108
|
+
|
|
109
|
+
session/runner/
|
|
110
|
+
SessionExecutor.ts 模型请求、Tool Loop 与上下文推进重试
|
|
111
|
+
ToolLoopLimits.ts Step 上限与边界提示
|
|
112
|
+
ToolLoopDecision.ts 是否继续下一轮的纯决策
|
|
113
|
+
AssistantParts.ts Assistant 产出读取与诊断
|
|
114
|
+
ModelFailure.ts 模型调用错误归一化
|
|
115
|
+
ContextPressure.ts usage 压力阈值判断
|
|
116
|
+
ContextRetry.ts 推进上下文后重试整轮
|
|
117
|
+
```
|