@downcity/agent 1.1.437 → 1.1.445
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
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - `SessionTurnExecutionInput` 表示上层 Turn 执行入口输入。
|
|
6
|
-
* - `SessionStepExecutionInput`
|
|
6
|
+
* - `SessionStepExecutionInput` 表示执行器收到的、已装配完成的一步输入。
|
|
7
7
|
* - 输出只返回执行结果;Assistant Message 通过显式输出端口写入唯一事实源。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
11
|
ModelClient,
|
|
12
12
|
ModelMessage,
|
|
13
|
-
RuntimeTool as Tool,
|
|
14
13
|
} from "@downcity/type";
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
14
|
+
import type { BoundAgentTool } from "@/types/tool/BoundAgentTool.js";
|
|
15
|
+
import type { SessionSystemMessage } from "@downcity/type";
|
|
16
|
+
import type { SessionTurnContext } from "@/types/turn/SessionTurnContext.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Session 执行结果。
|
|
@@ -32,6 +32,15 @@ export interface SessionTurnExecutionResult {
|
|
|
32
32
|
*/
|
|
33
33
|
error?: string;
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* 失败时的稳定错误码;缺省时由 Session 层回退为通用 Turn 失败码。
|
|
37
|
+
*
|
|
38
|
+
* 关键点(中文)
|
|
39
|
+
* - 只用于让上层写入 canonical Error Part 时保留领域语义,不参与执行分支判断。
|
|
40
|
+
* - 成功时为空。
|
|
41
|
+
*/
|
|
42
|
+
error_code?: string;
|
|
43
|
+
|
|
35
44
|
/**
|
|
36
45
|
* 本轮结束后是否需要把已完成的 canonical 历史持久化压缩。
|
|
37
46
|
*
|
|
@@ -72,19 +81,12 @@ export interface SessionStepExecutionInput {
|
|
|
72
81
|
messages: ModelMessage[];
|
|
73
82
|
|
|
74
83
|
/**
|
|
75
|
-
*
|
|
84
|
+
* 当前轮可用工具集合;上下文已在包装层绑定。
|
|
76
85
|
*/
|
|
77
|
-
tools: Record<string,
|
|
86
|
+
tools: Record<string, BoundAgentTool>;
|
|
78
87
|
|
|
79
88
|
/** 当前模型支持的上下文窗口长度。 */
|
|
80
89
|
context_window?: number;
|
|
81
90
|
|
|
82
91
|
}
|
|
83
92
|
|
|
84
|
-
/** 单个 Session 的统一 Turn 执行协议。 */
|
|
85
|
-
export interface SessionExecutor {
|
|
86
|
-
/** 执行一个已经由 SessionLoop 创建上下文的 Turn。 */
|
|
87
|
-
execute(
|
|
88
|
-
input: SessionTurnExecutionInput,
|
|
89
|
-
): Promise<SessionTurnExecutionResult>;
|
|
90
|
-
}
|
|
@@ -4,19 +4,23 @@
|
|
|
4
4
|
* 这些类型描述 Turn 编排所依赖的领域对象,不实现任何调度行为。
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {
|
|
8
|
-
import type { SessionEventHub } from "@/session/
|
|
9
|
-
import type { SessionMessages } from "@/session/SessionMessages.js";
|
|
10
|
-
import type { SessionState } from "@/session/SessionState.js";
|
|
7
|
+
import type { ToolCallContext, ToolHookSet } from "@downcity/type";
|
|
8
|
+
import type { SessionEventHub } from "@/session/messages/SessionEventHub.js";
|
|
9
|
+
import type { SessionMessages } from "@/session/messages/SessionMessages.js";
|
|
10
|
+
import type { SessionState } from "@/session/loop/SessionState.js";
|
|
11
11
|
import type { AgentSessionTurnResult } from "@/types/sdk/AgentSessionTurn.js";
|
|
12
12
|
import type {
|
|
13
13
|
SessionInteractionLifecycle,
|
|
14
14
|
SessionInteractionPort,
|
|
15
15
|
} from "@downcity/type";
|
|
16
|
-
import type {
|
|
17
|
-
|
|
16
|
+
import type {
|
|
17
|
+
SessionContextAdvanceTrigger,
|
|
18
|
+
} from "@/types/session/SessionComposer.js";
|
|
19
|
+
import type { StepInput } from "@/session/input/StepInput.js";
|
|
20
|
+
import type { SessionExecutorPort } from "@/session/runner/SessionExecutor.js";
|
|
21
|
+
import type { SessionQueue } from "@/session/loop/SessionQueue.js";
|
|
18
22
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
19
|
-
import type { SessionTurnContext } from "@/types/
|
|
23
|
+
import type { SessionTurnContext } from "@/types/turn/SessionTurnContext.js";
|
|
20
24
|
import type { SessionOrigin } from "@downcity/type";
|
|
21
25
|
|
|
22
26
|
/** Promise 延迟控制器。 */
|
|
@@ -49,10 +53,24 @@ export interface SessionLoopOptions {
|
|
|
49
53
|
session_origin: SessionOrigin;
|
|
50
54
|
/** 当前 Session 所属 Workspace 的绝对根目录。 */
|
|
51
55
|
workspace_path: string;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
/**
|
|
57
|
+
* 已装配的执行器。
|
|
58
|
+
*
|
|
59
|
+
* 关键点(中文):省略时本 Loop 自行创建默认 `SessionExecutor`;传入后只调用该实现。
|
|
60
|
+
*/
|
|
61
|
+
executor?: SessionExecutorPort;
|
|
62
|
+
/**
|
|
63
|
+
* 每步的模型输入装配者。
|
|
64
|
+
*
|
|
65
|
+
* 关键点(中文):省略时表示调用方注入了自带输入的 `executor`,本 Loop 不再装配输入。
|
|
66
|
+
*/
|
|
67
|
+
step_input?: StepInput;
|
|
68
|
+
/** Turn 结束后按需推进 Composer 派生上下文。 */
|
|
55
69
|
maintain_context: () => Promise<void>;
|
|
70
|
+
/** 请求推进派生上下文;Provider 上下文超限时由执行器调用。 */
|
|
71
|
+
advance_context: (
|
|
72
|
+
trigger: SessionContextAdvanceTrigger,
|
|
73
|
+
) => Promise<boolean>;
|
|
56
74
|
/** 当前 Session 的配置与 Metadata 状态。 */
|
|
57
75
|
state: SessionState;
|
|
58
76
|
/** 当前 Session 的 canonical Message 入口。 */
|
|
@@ -65,6 +83,13 @@ export interface SessionLoopOptions {
|
|
|
65
83
|
queue: SessionQueue;
|
|
66
84
|
/** 当前 Session 的用户异步交互运行时。 */
|
|
67
85
|
interactions: SessionInteractionLifecycle & SessionInteractionPort;
|
|
68
|
-
/**
|
|
69
|
-
|
|
86
|
+
/** 读取当前生效的扩展处理器集合。 */
|
|
87
|
+
get_hooks: () => ToolHookSet;
|
|
88
|
+
/** 构造当前 Turn 的调用环境快照。 */
|
|
89
|
+
create_call_context: (input: {
|
|
90
|
+
/** 当前 Turn 稳定标识。 */
|
|
91
|
+
readonly turn_id: string;
|
|
92
|
+
/** 当前 Turn 的取消信号。 */
|
|
93
|
+
readonly abort_signal: AbortSignal;
|
|
94
|
+
}) => ToolCallContext;
|
|
70
95
|
}
|
|
@@ -12,10 +12,7 @@ import type {
|
|
|
12
12
|
SessionAgentContent,
|
|
13
13
|
SessionUserContent,
|
|
14
14
|
} from "@downcity/type";
|
|
15
|
-
import type {
|
|
16
|
-
SessionAgentMessagePart,
|
|
17
|
-
SessionUserMessagePart,
|
|
18
|
-
} from "@downcity/type";
|
|
15
|
+
import type { SessionUserPartContent } from "@downcity/type";
|
|
19
16
|
import type { SessionMutation } from "@downcity/type";
|
|
20
17
|
|
|
21
18
|
/** SessionMessages 构造参数。 */
|
|
@@ -34,8 +31,8 @@ export interface SessionMessagesOptions {
|
|
|
34
31
|
export interface AppendSessionUserMessageInput {
|
|
35
32
|
/** 当前输入所属 Turn。 */
|
|
36
33
|
turn_id: string;
|
|
37
|
-
/** User
|
|
38
|
-
parts:
|
|
34
|
+
/** User 内容 Part;identity 与顺序由 SessionMessages 分配。 */
|
|
35
|
+
parts: SessionUserPartContent[];
|
|
39
36
|
/** 可选的稳定 Message 标识。 */
|
|
40
37
|
message_id?: string;
|
|
41
38
|
/** 当前 Message 的默认展示范围。 */
|
|
@@ -52,34 +49,6 @@ export interface OpenSessionAgentMessageInput {
|
|
|
52
49
|
message_id?: string;
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
/** 已完成 Assistant Message 的直接写入参数。 */
|
|
56
|
-
export interface AppendCompletedAgentMessageInput {
|
|
57
|
-
/** 当前 Assistant 所属 Turn。 */
|
|
58
|
-
turn_id?: string;
|
|
59
|
-
/** Assistant 完整结构化 Part。 */
|
|
60
|
-
parts: SessionAgentMessagePart[];
|
|
61
|
-
/** 当前 Message 的默认展示范围。 */
|
|
62
|
-
visibility?: "visible" | "internal";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Action Part 及其所属 Agent Message 的创建参数。 */
|
|
66
|
-
export interface OpenSessionAgentActionPartInput {
|
|
67
|
-
/** 可选的稳定 Message 标识,用于更新同一个 Action 生命周期。 */
|
|
68
|
-
message_id?: string;
|
|
69
|
-
/** 当前 Action 所属 Turn。 */
|
|
70
|
-
turn_id?: string;
|
|
71
|
-
/** 当前 Action 的业务类型。 */
|
|
72
|
-
action_type: string;
|
|
73
|
-
/** 当前 Action 标题。 */
|
|
74
|
-
title: string;
|
|
75
|
-
/** 当前 Action 描述。 */
|
|
76
|
-
description?: string;
|
|
77
|
-
/** 当前 Action 附加数据。 */
|
|
78
|
-
data?: JsonObject;
|
|
79
|
-
/** Action 创建或更新后是否发布对应 Session Mutation。 */
|
|
80
|
-
publish_mutation?: boolean;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
52
|
/** 完成 Action Part 时允许覆盖的内容。 */
|
|
84
53
|
export interface CompleteSessionAgentActionPartInput {
|
|
85
54
|
/** 完成时覆盖的可选标题。 */
|
|
@@ -7,15 +7,14 @@
|
|
|
7
7
|
* - Composer 仍然是 Session 级能力,不向 Agent 的执行策略层泄漏。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ModelClient,
|
|
10
|
+
import type { ModelClient, AgentTool as Tool, ToolHookSet, WorkspaceRuntime } from "@downcity/type";
|
|
11
11
|
import type { AgentSession } from "@/types/agent/SessionActor.js";
|
|
12
12
|
import type { SessionPort } from "@/types/session/SessionPort.js";
|
|
13
13
|
import type { AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
|
|
14
|
-
import type {
|
|
14
|
+
import type { SessionOrigin } from "@downcity/type";
|
|
15
15
|
import type { SessionComposer } from "@/types/session/SessionComposer.js";
|
|
16
16
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
17
17
|
import type { SessionStorage } from "@/types/store/SessionStorage.js";
|
|
18
|
-
import type { SessionOrigin } from "@downcity/type";
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Agent 可管理的本地 Session 实例。
|
|
@@ -50,6 +49,12 @@ export interface SessionOptions {
|
|
|
50
49
|
*/
|
|
51
50
|
agent_id: string;
|
|
52
51
|
|
|
52
|
+
/** 当前 Agent 用户可见名称;进入工具与扩展的调用环境。 */
|
|
53
|
+
agent_name: string;
|
|
54
|
+
|
|
55
|
+
/** 当前 Agent 一句话能力描述;进入工具与扩展的调用环境。 */
|
|
56
|
+
agent_description: string;
|
|
57
|
+
|
|
53
58
|
/** 当前 Session 所属 Workspace 的绝对根目录。 */
|
|
54
59
|
workspace_path: string;
|
|
55
60
|
|
|
@@ -113,20 +118,20 @@ export interface SessionOptions {
|
|
|
113
118
|
*/
|
|
114
119
|
get_workspace_env: () => Record<string, string>;
|
|
115
120
|
|
|
116
|
-
/**
|
|
117
|
-
|
|
121
|
+
/** 读取当前 Session 绑定的 Workspace 实例;未绑定时返回 undefined。 */
|
|
122
|
+
get_workspace: () => WorkspaceRuntime | undefined;
|
|
118
123
|
|
|
119
|
-
/**
|
|
120
|
-
|
|
124
|
+
/** 在每个 Step 检查点读取当前生效的扩展处理器集合。 */
|
|
125
|
+
get_hooks: () => ToolHookSet;
|
|
121
126
|
|
|
122
|
-
/**
|
|
123
|
-
* 在执行前确保当前 session 已完成宿主侧默认配置。
|
|
124
|
-
*/
|
|
125
|
-
ensure_configured?: (session: AgentManagedSession) => Promise<void>;
|
|
126
127
|
|
|
127
128
|
/** 读取 Agent 当前持有的运行时模型实例。 */
|
|
128
129
|
get_agent_model: () => ModelClient | undefined;
|
|
129
130
|
|
|
130
|
-
/**
|
|
131
|
-
|
|
131
|
+
/**
|
|
132
|
+
* 当前 Session 使用的 Composer。
|
|
133
|
+
*
|
|
134
|
+
* 关键点(中文):由 Agent 传入并在其所有 Session 间共享,因此实现必须无状态。
|
|
135
|
+
*/
|
|
136
|
+
composer?: SessionComposer;
|
|
132
137
|
}
|
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
SessionUserContent,
|
|
13
13
|
SessionMessage,
|
|
14
14
|
} from "@downcity/type";
|
|
15
|
-
import type { SessionExecutor } from "@/types/session/SessionExecution.js";
|
|
16
15
|
import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
|
|
17
16
|
import type { AgentSessionStopResult } from "@/types/sdk/AgentSessionStop.js";
|
|
18
17
|
import type { AgentSessionTurnHandle } from "@/types/sdk/AgentSessionTurn.js";
|
|
@@ -31,9 +30,6 @@ export interface SessionPort {
|
|
|
31
30
|
/** 获取当前 Session 优先解析后的运行时模型实例。 */
|
|
32
31
|
get_model(): ModelClient | undefined;
|
|
33
32
|
|
|
34
|
-
/** 获取当前 Session 的执行端口。 */
|
|
35
|
-
get_executor(): SessionExecutor;
|
|
36
|
-
|
|
37
33
|
/** 读取全部 canonical Session Message。 */
|
|
38
34
|
messages(): Promise<SessionMessage[]>;
|
|
39
35
|
|
|
@@ -26,7 +26,6 @@ export interface SessionStateOptions {
|
|
|
26
26
|
/** 当前 Session 的运行日志器。 */
|
|
27
27
|
logger: Logger;
|
|
28
28
|
/** 在执行前补齐宿主级配置的异步钩子。 */
|
|
29
|
-
ensure_configured_hook?: () => Promise<void>;
|
|
30
29
|
/** 按 Session 优先、Agent 兜底规则读取当前模型。 */
|
|
31
30
|
get_model: () => ModelClient | undefined;
|
|
32
31
|
/** 发布 Session Mutation 的函数。 */
|
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
|
|
8
|
-
import type {
|
|
9
|
-
SessionHookContext,
|
|
10
|
-
SessionHookRuntime,
|
|
11
|
-
SessionHookScopeRuntime,
|
|
12
|
-
} from "@downcity/type";
|
|
8
|
+
import type { ToolCallContext, ToolHookSet } from "@downcity/type";
|
|
13
9
|
|
|
14
10
|
/** 默认 Session System Block 的组装参数。 */
|
|
15
11
|
export interface BuildSessionSystemBlocksInput {
|
|
@@ -25,22 +21,20 @@ export interface BuildSessionSystemBlocksInput {
|
|
|
25
21
|
timezone: string;
|
|
26
22
|
/** 读取当前调用方传入的 Instruction System Block。 */
|
|
27
23
|
get_instruction_system_blocks: () => AgentSessionSystemBlock[];
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
/** 读取当前 Session Plugin 的 System Block。 */
|
|
31
|
-
get_plugin_system_blocks: () => Promise<AgentSessionSystemBlock[]>;
|
|
24
|
+
/** 读取当前 Session 扩展的 System Block。 */
|
|
25
|
+
get_power_system_blocks: () => Promise<AgentSessionSystemBlock[]>;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
|
-
/** 解析
|
|
35
|
-
export interface
|
|
28
|
+
/** 解析 Power system blocks 所需的稳定执行输入。 */
|
|
29
|
+
export interface ResolveSessionPowerSystemBlocksInput {
|
|
36
30
|
/** 当前 Session 的稳定标识。 */
|
|
37
31
|
session_id: string;
|
|
38
32
|
/** 当前 Turn 的稳定标识;控制面预览等非 Turn 调用允许为空。 */
|
|
39
33
|
turn_id?: string;
|
|
40
|
-
/**
|
|
41
|
-
hooks:
|
|
42
|
-
/**
|
|
43
|
-
context:
|
|
44
|
-
/**
|
|
34
|
+
/** 当前调用捕获的扩展处理器集合。 */
|
|
35
|
+
hooks: ToolHookSet;
|
|
36
|
+
/** 向扩展能力暴露的只读调用环境。 */
|
|
37
|
+
context: ToolCallContext;
|
|
38
|
+
/** Power system 解析失败后的可选降级观测入口。 */
|
|
45
39
|
on_error?: (error: unknown) => void | Promise<void>;
|
|
46
40
|
}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import type { SessionAgentToolPart } from "@downcity/type";
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
export interface
|
|
9
|
+
/** 当前可写 Agent Message 中的 Tool Part 定位结果。 */
|
|
10
|
+
export interface SessionOpenMessageToolLocation {
|
|
11
11
|
/** Tool Part 所属 Assistant Message。 */
|
|
12
12
|
message_id: string;
|
|
13
13
|
/** 当前 Tool Part 完整快照。 */
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* Executor,避免 Turn 结果提交反向理解调度过程。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { SessionEventHub } from "@/session/
|
|
9
|
-
import type { SessionMessages } from "@/session/SessionMessages.js";
|
|
8
|
+
import type { SessionEventHub } from "@/session/messages/SessionEventHub.js";
|
|
9
|
+
import type { SessionMessages } from "@/session/messages/SessionMessages.js";
|
|
10
10
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
11
|
+
import type { ToolCallContext, ToolHookSet } from "@downcity/type";
|
|
11
12
|
|
|
12
13
|
/** Turn 收口函数的稳定依赖。 */
|
|
13
14
|
export interface SessionTurnCompletionOptions {
|
|
@@ -19,6 +20,15 @@ export interface SessionTurnCompletionOptions {
|
|
|
19
20
|
events: SessionEventHub;
|
|
20
21
|
/** 当前 Session 的统一日志器。 */
|
|
21
22
|
logger: Logger;
|
|
23
|
+
/** 读取当前生效的扩展处理器集合。 */
|
|
24
|
+
get_hooks: () => ToolHookSet;
|
|
25
|
+
/** 构造当前 Turn 的调用环境快照。 */
|
|
26
|
+
create_call_context: (input: {
|
|
27
|
+
/** 当前 Turn 稳定标识。 */
|
|
28
|
+
readonly turn_id: string;
|
|
29
|
+
/** 当前 Turn 的取消信号。 */
|
|
30
|
+
readonly abort_signal: AbortSignal;
|
|
31
|
+
}) => ToolCallContext;
|
|
22
32
|
/** Turn 停止时对外使用的稳定错误文本。 */
|
|
23
33
|
stopped_message: string;
|
|
24
34
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* 读取 Turn effects、写入 Assistant 输出并发布摘要 Mutation。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
9
|
-
import type { SessionAssistantOutput } from "@/types/
|
|
10
|
-
import type { SessionTurnContext } from "@/types/
|
|
8
|
+
import type { ToolEffect } from "@downcity/type";
|
|
9
|
+
import type { SessionAssistantOutput } from "@/types/turn/SessionAssistantOutput.js";
|
|
10
|
+
import type { SessionTurnContext } from "@/types/turn/SessionTurnContext.js";
|
|
11
11
|
import type { SessionMutation } from "@downcity/type";
|
|
12
12
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
13
13
|
|
|
@@ -36,7 +36,7 @@ export interface PublishSessionTurnFileDiffInput {
|
|
|
36
36
|
/** 当前 Workspace 的绝对根路径。 */
|
|
37
37
|
workspace_path: string;
|
|
38
38
|
/** 当前检查点已经发生的 Tool effects。 */
|
|
39
|
-
effects: readonly
|
|
39
|
+
effects: readonly ToolEffect[];
|
|
40
40
|
/** 发布公开 Session Mutation 的函数。 */
|
|
41
41
|
publish: (mutation: SessionMutation) => void;
|
|
42
42
|
/** 当前 Session 的统一日志器。 */
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* StepInput 的构造参数类型。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Message、Store、Model 或
|
|
4
|
+
* 这些字段共同描述「为每个 Step 准备模型输入」所需的最小只读资源;StepInput 不拥有
|
|
5
|
+
* Message、Store、Model 或 Power 生命周期。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
ModelClient,
|
|
10
|
+
AgentTool as Tool,
|
|
11
|
+
SessionOrigin,
|
|
12
|
+
ToolHookSet,
|
|
13
|
+
WorkspaceRuntime,
|
|
14
|
+
} from "@downcity/type";
|
|
9
15
|
import type { AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
|
|
10
|
-
import type { SessionOrigin } from "@downcity/type";
|
|
11
16
|
import type { SessionStorage } from "@/types/store/SessionStorage.js";
|
|
12
|
-
import type { SessionHookRuntime } from "@downcity/type";
|
|
13
17
|
import type { SessionComposer } from "@/types/session/SessionComposer.js";
|
|
14
18
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
15
19
|
|
|
16
|
-
/**
|
|
17
|
-
export interface
|
|
20
|
+
/** StepInput 构造参数。 */
|
|
21
|
+
export interface StepInputOptions {
|
|
18
22
|
/** 当前 Session 所属 Agent 的稳定标识。 */
|
|
19
23
|
agent_id: string;
|
|
24
|
+
/** 当前 Agent 的用户可见名称。 */
|
|
25
|
+
agent_name: string;
|
|
26
|
+
/** 当前 Agent 的一句话能力描述。 */
|
|
27
|
+
agent_description: string;
|
|
20
28
|
/** 当前 Session 的稳定标识。 */
|
|
21
29
|
session_id: string;
|
|
22
30
|
/** 当前 Session 的创建来源。 */
|
|
@@ -29,16 +37,16 @@ export interface SessionCompositionOptions {
|
|
|
29
37
|
composer: SessionComposer;
|
|
30
38
|
/** 在每个 Step 检查点读取当前可用 Tool 集合。 */
|
|
31
39
|
get_tools: () => Record<string, Tool>;
|
|
40
|
+
/** 读取当前 Session 绑定的 Workspace 实例;未绑定时返回 undefined。 */
|
|
41
|
+
get_workspace?: () => WorkspaceRuntime | undefined;
|
|
32
42
|
/** 当前 Session 创建时捕获的 instruction system blocks。 */
|
|
33
43
|
instruction_system_blocks: AgentSessionSystemBlock[];
|
|
34
|
-
/**
|
|
44
|
+
/** 显式刷新 system 时读取 Agent 最新 instruction system blocks。 */
|
|
35
45
|
get_instruction_system_blocks: () => AgentSessionSystemBlock[];
|
|
36
|
-
/**
|
|
37
|
-
get_hooks: () =>
|
|
46
|
+
/** 在每个 Step 检查点读取当前生效的扩展处理器集合。 */
|
|
47
|
+
get_hooks: () => ToolHookSet;
|
|
38
48
|
/** 在每个 Step 检查点读取 Workspace env。 */
|
|
39
49
|
get_workspace_env: () => Record<string, string>;
|
|
40
|
-
/** 读取宿主显式注入的受托管 Plugin system blocks。 */
|
|
41
|
-
get_managed_plugin_system_blocks: () => Promise<AgentSessionSystemBlock[]>;
|
|
42
50
|
/** 读取当前 Session 实际使用的模型。 */
|
|
43
51
|
get_model: () => ModelClient | undefined;
|
|
44
52
|
/** 读取当前模型声明的上下文窗口。 */
|
|
@@ -47,6 +55,6 @@ export interface SessionCompositionOptions {
|
|
|
47
55
|
get_created_at: () => number;
|
|
48
56
|
/** 读取当前 Session 的参考时区。 */
|
|
49
57
|
get_timezone: () => string;
|
|
50
|
-
/** 记录
|
|
58
|
+
/** 记录 Power Hook 降级等可观察事件。 */
|
|
51
59
|
logger: Logger;
|
|
52
60
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 领域调用方不感知 SQLite 表、文件路径或连接实现。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { SessionHistoryMeta } from "@/
|
|
8
|
+
import type { SessionHistoryMeta } from "@/types/store/SessionHistoryMeta.js";
|
|
9
9
|
import type {
|
|
10
10
|
SessionAgentMessage,
|
|
11
11
|
SessionAgentMessagePart,
|
|
@@ -42,11 +42,11 @@ export interface SessionMessageStorageStats {
|
|
|
42
42
|
latest_message: SessionMessage | null;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/** Composer
|
|
45
|
+
/** Composer 派生 SQL 参数允许的 SQLite 标量。 */
|
|
46
46
|
export type SessionStorageValue = string | number | bigint | Uint8Array | null;
|
|
47
47
|
|
|
48
|
-
/** Composer
|
|
49
|
-
export interface
|
|
48
|
+
/** 单个 Composer 命名空间的派生表事务。 */
|
|
49
|
+
export interface SessionDerivedStoreTransaction {
|
|
50
50
|
/** 执行一条不返回数据的派生 SQL。 */
|
|
51
51
|
execute(sql: string, parameters?: readonly SessionStorageValue[]): void;
|
|
52
52
|
/** 读取第一条派生数据;没有匹配时返回空。 */
|
|
@@ -55,12 +55,15 @@ export interface SessionComposerStorageTransaction {
|
|
|
55
55
|
all<TRow>(sql: string, parameters?: readonly SessionStorageValue[]): TRow[];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Composer 的派生表存储视图。
|
|
60
|
+
*
|
|
61
|
+
* 关键点(中文):这里只暴露当前命名空间的派生表事务;canonical history 由宿主读取后
|
|
62
|
+
* 以参数传给 Composer,因此 Composer 不可能改写或绕过 canonical Message。
|
|
63
|
+
*/
|
|
64
|
+
export interface SessionDerivedStore {
|
|
65
|
+
/** 在短事务中操作当前命名空间的派生表。 */
|
|
66
|
+
transaction<T>(operation: (transaction: SessionDerivedStoreTransaction) => T): Promise<T>;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
/** 单个 Session 的结构化持久化能力。 */
|
|
@@ -112,10 +115,12 @@ export interface SessionStorage {
|
|
|
112
115
|
read_latest_agent_message(turn_id?: string): Promise<SessionAgentMessage | null>;
|
|
113
116
|
/** 读取 Message 统计。 */
|
|
114
117
|
message_stats(): Promise<SessionMessageStorageStats>;
|
|
118
|
+
/** 读取已持久化 Message 总数;只做计数,不读取内容。 */
|
|
119
|
+
message_count(): Promise<number>;
|
|
115
120
|
/** 清空 canonical Message 与依赖它们的派生数据。 */
|
|
116
121
|
clear_messages(): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
|
|
122
|
+
/** 返回指定 Composer 命名空间的派生存储视图。 */
|
|
123
|
+
derived_store(namespace: string): SessionDerivedStore;
|
|
119
124
|
/** 关闭数据库连接。 */
|
|
120
125
|
dispose(): Promise<void>;
|
|
121
126
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 已绑定工具的内部执行协议。
|
|
3
|
+
*
|
|
4
|
+
* 公开契约 `AgentTool` 的执行签名要求完整的 `ToolCallContext`;而模型 Step 只知道
|
|
5
|
+
* 本次调用自身的身份与消息。因此 Agent 在执行前把 AgentTool 包装成 BoundAgentTool:
|
|
6
|
+
* 包装层捕获 Session 级上下文,Step 侧只补本次调用信息,两者在包装层合并。
|
|
7
|
+
*
|
|
8
|
+
* 关键点(中文)
|
|
9
|
+
* - `BoundAgentTool` 不对外暴露,只存在于 Agent 内部的模型 Step 执行路径。
|
|
10
|
+
* - 这一层存在的意义是让上下文注入点唯一:工具实现永远拿到完整的 ToolCallContext。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ModelMessage } from "@downcity/type";
|
|
14
|
+
|
|
15
|
+
/** 一次模型工具调用自身携带的信息。 */
|
|
16
|
+
export interface ToolCallSite {
|
|
17
|
+
/** 当前模型工具调用的稳定唯一标识。 */
|
|
18
|
+
readonly tool_call_id: string;
|
|
19
|
+
/** 当前模型 Step 使用的完整消息快照。 */
|
|
20
|
+
readonly messages: readonly ModelMessage[];
|
|
21
|
+
/** 当前 Turn 的可选取消信号。 */
|
|
22
|
+
readonly abort_signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** 允许异构工具注册表保留每个工具自己的输入类型。 */
|
|
26
|
+
type BoundAgentToolHandler<TInput, TResult> = {
|
|
27
|
+
bivariance_handler(input: TInput, site: ToolCallSite): TResult;
|
|
28
|
+
}["bivariance_handler"];
|
|
29
|
+
|
|
30
|
+
/** 已完成 Session 上下文绑定的工具;执行时只需补充本次调用信息。 */
|
|
31
|
+
export interface BoundAgentTool<TInput = unknown, TOutput = unknown> {
|
|
32
|
+
/** 面向模型的工具用途说明。 */
|
|
33
|
+
readonly description?: string;
|
|
34
|
+
/** JSON Schema 或可转换为 JSON Schema 的输入定义。 */
|
|
35
|
+
readonly input_schema: unknown;
|
|
36
|
+
/** 可选执行实现;缺少时该工具只向模型声明能力。 */
|
|
37
|
+
readonly execute?: BoundAgentToolHandler<TInput, TOutput | Promise<TOutput>>;
|
|
38
|
+
}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ask_question Tool 的输入与输出协议。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 问题字段与 canonical Interaction 保持一致,只少一个由 Session 生成的 `question_id`;
|
|
5
|
+
* 模型写的形状就是落库与渲染的形状。Interaction 标识、Turn 标识与生命周期状态由 Session
|
|
6
|
+
* 运行时维护,不交给模型生成。
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import type {
|
|
9
10
|
SessionInteractionAnswer,
|
|
10
|
-
SessionInteractionOption,
|
|
11
11
|
SessionInteractionQuestion,
|
|
12
12
|
} from "@downcity/type";
|
|
13
13
|
|
|
14
|
-
/** 模型调用 ask_question
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type: SessionInteractionQuestion["response_type"];
|
|
20
|
-
/** 单选或多选问题允许选择的候选项。 */
|
|
21
|
-
options?: SessionInteractionOption[];
|
|
22
|
-
}
|
|
14
|
+
/** 模型调用 ask_question 时提交的一条问题;`question_id` 由 Session 生成,不由模型提供。 */
|
|
15
|
+
export type AskQuestionsToolQuestion = Omit<
|
|
16
|
+
SessionInteractionQuestion,
|
|
17
|
+
"question_id"
|
|
18
|
+
>;
|
|
23
19
|
|
|
24
20
|
/** 模型调用 ask_question 时提交的结构化输入。 */
|
|
25
21
|
export interface AskQuestionsToolInput {
|
|
@@ -33,6 +29,8 @@ export interface AskQuestionsToolInput {
|
|
|
33
29
|
export interface AskQuestionsToolOutput {
|
|
34
30
|
/** 当前提问已由用户完整回答。 */
|
|
35
31
|
status: "resolved";
|
|
36
|
-
/** 按 question_id
|
|
32
|
+
/** 按 question_id 关联的完整回答集合,顺序与提问一致。 */
|
|
37
33
|
answers: SessionInteractionAnswer[];
|
|
34
|
+
/** 用户随回答提交的可选补充说明。 */
|
|
35
|
+
note?: string;
|
|
38
36
|
}
|