@downcity/agent 1.1.408 → 1.1.437
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 +63 -51
- package/bin/agent/Agent.d.ts +39 -17
- package/bin/agent/Agent.d.ts.map +1 -1
- package/bin/agent/Agent.js +169 -71
- package/bin/agent/Agent.js.map +1 -1
- package/bin/agent/AgentInstructions.d.ts +1 -1
- package/bin/agent/AgentInstructions.js +3 -3
- package/bin/agent/AgentInstructions.js.map +1 -1
- package/bin/agent/AgentMemoryStorage.d.ts +18 -0
- package/bin/agent/AgentMemoryStorage.d.ts.map +1 -0
- package/bin/agent/AgentMemoryStorage.js +176 -0
- package/bin/agent/AgentMemoryStorage.js.map +1 -0
- package/bin/agent/AgentSessions.d.ts +32 -33
- package/bin/agent/AgentSessions.d.ts.map +1 -1
- package/bin/agent/AgentSessions.js +122 -72
- package/bin/agent/AgentSessions.js.map +1 -1
- package/bin/executor/Executor.d.ts +12 -30
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +39 -121
- package/bin/executor/Executor.js.map +1 -1
- package/bin/executor/composer/system/default/SystemPromptAssets.d.ts +0 -4
- package/bin/executor/composer/system/default/SystemPromptAssets.d.ts.map +1 -1
- package/bin/executor/composer/system/default/SystemPromptAssets.js +1 -6
- package/bin/executor/composer/system/default/SystemPromptAssets.js.map +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineContextCompaction.d.ts +3 -9
- package/bin/executor/core-engine/CoreEngineContextCompaction.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineContextCompaction.js +4 -130
- package/bin/executor/core-engine/CoreEngineContextCompaction.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineError.d.ts +1 -1
- package/bin/executor/core-engine/CoreEngineError.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineLoopDecision.d.ts +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.d.ts +3 -30
- package/bin/executor/core-engine/CoreEngineRunner.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.js +83 -245
- package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.d.ts +7 -7
- package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.js +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.js.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.d.ts +2 -2
- package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
- package/bin/executor/messages/SessionMessageLog.d.ts +3 -3
- package/bin/executor/messages/SessionMessageLog.d.ts.map +1 -1
- package/bin/executor/messages/SessionMessageLog.js.map +1 -1
- package/bin/executor/messages/SessionModelMessages.d.ts +1 -4
- package/bin/executor/messages/SessionModelMessages.d.ts.map +1 -1
- package/bin/executor/messages/SessionModelMessages.js +81 -91
- package/bin/executor/messages/SessionModelMessages.js.map +1 -1
- package/bin/executor/model/ModelGenerate.d.ts +12 -2
- package/bin/executor/model/ModelGenerate.d.ts.map +1 -1
- package/bin/executor/model/ModelGenerate.js +23 -15
- package/bin/executor/model/ModelGenerate.js.map +1 -1
- package/bin/executor/model/ModelRequestRunner.d.ts +29 -0
- package/bin/executor/model/ModelRequestRunner.d.ts.map +1 -0
- package/bin/executor/model/ModelRequestRunner.js +77 -0
- package/bin/executor/model/ModelRequestRunner.js.map +1 -0
- package/bin/executor/model/ModelStepRunner.d.ts +3 -7
- package/bin/executor/model/ModelStepRunner.d.ts.map +1 -1
- package/bin/executor/model/ModelStepRunner.js +9 -41
- package/bin/executor/model/ModelStepRunner.js.map +1 -1
- package/bin/executor/model/ModelStreamConsumer.d.ts +12 -0
- package/bin/executor/model/ModelStreamConsumer.d.ts.map +1 -0
- package/bin/executor/model/ModelStreamConsumer.js +60 -0
- package/bin/executor/model/ModelStreamConsumer.js.map +1 -0
- package/bin/executor/model/ModelStreamFailure.d.ts +4 -0
- package/bin/executor/model/ModelStreamFailure.d.ts.map +1 -1
- package/bin/executor/model/ModelStreamFailure.js +21 -0
- package/bin/executor/model/ModelStreamFailure.js.map +1 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts +7 -64
- package/bin/executor/services/ExecutorRecoveryPolicy.d.ts.map +1 -1
- package/bin/executor/services/ExecutorRecoveryPolicy.js +29 -45
- package/bin/executor/services/ExecutorRecoveryPolicy.js.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.d.ts +6 -8
- package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.js +1 -1
- package/bin/group/Group.d.ts +22 -3
- package/bin/group/Group.d.ts.map +1 -1
- package/bin/group/Group.js +54 -4
- package/bin/group/Group.js.map +1 -1
- package/bin/group/GroupDispatchRuntime.d.ts +37 -0
- package/bin/group/GroupDispatchRuntime.d.ts.map +1 -0
- package/bin/group/{GroupDispatchSession.js → GroupDispatchRuntime.js} +77 -21
- package/bin/group/GroupDispatchRuntime.js.map +1 -0
- package/bin/group/GroupSession.d.ts +20 -6
- package/bin/group/GroupSession.d.ts.map +1 -1
- package/bin/group/GroupSession.js +148 -84
- package/bin/group/GroupSession.js.map +1 -1
- package/bin/group/GroupSessions.d.ts +1 -1
- package/bin/group/GroupSessions.d.ts.map +1 -1
- package/bin/group/GroupSessions.js +11 -10
- package/bin/group/GroupSessions.js.map +1 -1
- package/bin/group/index.d.ts +1 -1
- package/bin/group/index.d.ts.map +1 -1
- package/bin/{workspace/store → group/storage}/LocalGroupSessionDataStore.d.ts +11 -3
- package/bin/group/storage/LocalGroupSessionDataStore.d.ts.map +1 -0
- package/bin/{workspace/store → group/storage}/LocalGroupSessionDataStore.js +89 -6
- package/bin/group/storage/LocalGroupSessionDataStore.js.map +1 -0
- package/bin/group/storage/LocalGroupSessionStore.d.ts.map +1 -0
- package/bin/{workspace/store → group/storage}/LocalGroupSessionStore.js +1 -1
- package/bin/group/storage/LocalGroupSessionStore.js.map +1 -0
- package/bin/index.d.ts +25 -55
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +9 -21
- package/bin/index.js.map +1 -1
- package/bin/session/DefaultSessionComposer.d.ts +13 -7
- package/bin/session/DefaultSessionComposer.d.ts.map +1 -1
- package/bin/session/DefaultSessionComposer.js +63 -24
- package/bin/session/DefaultSessionComposer.js.map +1 -1
- package/bin/session/Session.d.ts +27 -70
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +136 -446
- package/bin/session/Session.js.map +1 -1
- package/bin/session/SessionComposition.d.ts +49 -0
- package/bin/session/SessionComposition.d.ts.map +1 -0
- package/bin/session/SessionComposition.js +309 -0
- package/bin/session/SessionComposition.js.map +1 -0
- package/bin/session/SessionHookPoints.d.ts +15 -0
- package/bin/session/SessionHookPoints.d.ts.map +1 -0
- package/bin/session/SessionHookPoints.js +15 -0
- package/bin/session/SessionHookPoints.js.map +1 -0
- package/bin/session/SessionHooks.d.ts +38 -0
- package/bin/session/SessionHooks.d.ts.map +1 -0
- package/bin/session/SessionHooks.js +71 -0
- package/bin/session/SessionHooks.js.map +1 -0
- package/bin/session/SessionLoop.d.ts +18 -10
- package/bin/session/SessionLoop.d.ts.map +1 -1
- package/bin/session/SessionLoop.js +234 -213
- package/bin/session/SessionLoop.js.map +1 -1
- package/bin/session/SessionMessages.d.ts +57 -86
- package/bin/session/SessionMessages.d.ts.map +1 -1
- package/bin/session/SessionMessages.js +289 -506
- package/bin/session/SessionMessages.js.map +1 -1
- package/bin/session/SessionQueue.d.ts +1 -1
- package/bin/session/SessionQueue.d.ts.map +1 -1
- package/bin/session/SessionQueue.js +2 -1
- package/bin/session/SessionQueue.js.map +1 -1
- package/bin/session/SessionState.d.ts +7 -11
- package/bin/session/SessionState.d.ts.map +1 -1
- package/bin/session/SessionState.js +63 -95
- package/bin/session/SessionState.js.map +1 -1
- package/bin/session/SessionSystem.d.ts +6 -2
- package/bin/session/SessionSystem.d.ts.map +1 -1
- package/bin/session/SessionSystem.js +41 -1
- package/bin/session/SessionSystem.js.map +1 -1
- package/bin/session/SessionTitle.d.ts +37 -7
- package/bin/session/SessionTitle.d.ts.map +1 -1
- package/bin/session/SessionTitle.js +43 -37
- package/bin/session/SessionTitle.js.map +1 -1
- package/bin/session/browse/Browse.d.ts +34 -48
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +106 -354
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/browse/SessionMessageTimeline.d.ts +1 -1
- package/bin/session/browse/SessionMessageTimeline.d.ts.map +1 -1
- package/bin/session/browse/SessionMessageTimeline.js +61 -37
- package/bin/session/browse/SessionMessageTimeline.js.map +1 -1
- package/bin/session/composer/policies/AdaptivePartContextPolicy.d.ts +35 -0
- package/bin/session/composer/policies/AdaptivePartContextPolicy.d.ts.map +1 -0
- package/bin/session/composer/policies/AdaptivePartContextPolicy.js +256 -0
- package/bin/session/composer/policies/AdaptivePartContextPolicy.js.map +1 -0
- package/bin/session/composer/policies/FullHistoryContextPolicy.d.ts +24 -0
- package/bin/session/composer/policies/FullHistoryContextPolicy.d.ts.map +1 -0
- package/bin/session/composer/policies/FullHistoryContextPolicy.js +31 -0
- package/bin/session/composer/policies/FullHistoryContextPolicy.js.map +1 -0
- package/bin/session/composer/policies/SessionSummaryPrompts.d.ts +16 -0
- package/bin/session/composer/policies/SessionSummaryPrompts.d.ts.map +1 -0
- package/bin/session/composer/policies/SessionSummaryPrompts.js +32 -0
- package/bin/session/composer/policies/SessionSummaryPrompts.js.map +1 -0
- package/bin/session/control/SessionInteractions.d.ts +2 -2
- package/bin/session/control/SessionInteractions.d.ts.map +1 -1
- package/bin/session/execution/SessionAssistantOutputAdapter.d.ts +16 -5
- package/bin/session/execution/SessionAssistantOutputAdapter.d.ts.map +1 -1
- package/bin/session/execution/SessionAssistantOutputAdapter.js +7 -3
- package/bin/session/execution/SessionAssistantOutputAdapter.js.map +1 -1
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts +3 -3
- package/bin/session/execution/tools/SessionShellApprovalAdapter.d.ts.map +1 -1
- package/bin/session/index.d.ts +8 -0
- package/bin/session/index.d.ts.map +1 -0
- package/bin/session/index.js +7 -0
- package/bin/session/index.js.map +1 -0
- package/bin/session/messages/SessionAgentActionPartWriter.d.ts +22 -0
- package/bin/session/messages/SessionAgentActionPartWriter.d.ts.map +1 -0
- package/bin/session/messages/SessionAgentActionPartWriter.js +36 -0
- package/bin/session/messages/SessionAgentActionPartWriter.js.map +1 -0
- package/bin/session/messages/SessionAgentContent.d.ts +10 -0
- package/bin/session/messages/SessionAgentContent.d.ts.map +1 -0
- package/bin/session/messages/SessionAgentContent.js +44 -0
- package/bin/session/messages/SessionAgentContent.js.map +1 -0
- package/bin/session/messages/SessionAgentMessageState.d.ts +50 -0
- package/bin/session/messages/SessionAgentMessageState.d.ts.map +1 -0
- package/bin/session/messages/SessionAgentMessageState.js +283 -0
- package/bin/session/messages/SessionAgentMessageState.js.map +1 -0
- package/bin/session/messages/{SessionAssistantMessageWriter.d.ts → SessionAgentMessageWriter.d.ts} +23 -9
- package/bin/session/messages/SessionAgentMessageWriter.d.ts.map +1 -0
- package/bin/session/messages/{SessionAssistantMessageWriter.js → SessionAgentMessageWriter.js} +56 -44
- package/bin/session/messages/SessionAgentMessageWriter.js.map +1 -0
- package/bin/session/messages/SessionForkMessageFiles.d.ts +22 -0
- package/bin/session/messages/SessionForkMessageFiles.d.ts.map +1 -0
- package/bin/session/messages/SessionForkMessageFiles.js +52 -0
- package/bin/session/messages/SessionForkMessageFiles.js.map +1 -0
- package/bin/session/messages/SessionJsonValue.d.ts +1 -1
- package/bin/session/messages/SessionJsonValue.d.ts.map +1 -1
- package/bin/session/messages/SessionMessageInteractionWriter.d.ts +7 -12
- package/bin/session/messages/SessionMessageInteractionWriter.d.ts.map +1 -1
- package/bin/session/messages/SessionMessageInteractionWriter.js +4 -4
- package/bin/session/messages/SessionMessageInteractionWriter.js.map +1 -1
- package/bin/session/messages/SessionMessageText.d.ts +4 -4
- package/bin/session/messages/SessionMessageText.d.ts.map +1 -1
- package/bin/session/messages/SessionMessageText.js +0 -2
- package/bin/session/messages/SessionMessageText.js.map +1 -1
- package/bin/session/messages/SessionTurnFileDiffBuilder.d.ts +15 -0
- package/bin/session/messages/SessionTurnFileDiffBuilder.d.ts.map +1 -0
- package/bin/session/messages/SessionTurnFileDiffBuilder.js +180 -0
- package/bin/session/messages/SessionTurnFileDiffBuilder.js.map +1 -0
- package/bin/session/messages/SessionTurnFileDiffData.d.ts +15 -0
- package/bin/session/messages/SessionTurnFileDiffData.d.ts.map +1 -0
- package/bin/session/messages/SessionTurnFileDiffData.js +59 -0
- package/bin/session/messages/SessionTurnFileDiffData.js.map +1 -0
- package/bin/session/messages/SessionUserContext.d.ts +13 -0
- package/bin/session/messages/SessionUserContext.d.ts.map +1 -0
- package/bin/session/messages/SessionUserContext.js +38 -0
- package/bin/session/messages/SessionUserContext.js.map +1 -0
- package/bin/session/messages/SessionUserMessage.d.ts +14 -0
- package/bin/session/messages/SessionUserMessage.d.ts.map +1 -0
- package/bin/session/messages/SessionUserMessage.js +74 -0
- package/bin/session/messages/SessionUserMessage.js.map +1 -0
- package/bin/session/preview/SessionMessagePreview.d.ts +1 -1
- package/bin/session/preview/SessionMessagePreview.d.ts.map +1 -1
- package/bin/session/preview/SessionMessagePreview.js +26 -10
- package/bin/session/preview/SessionMessagePreview.js.map +1 -1
- package/bin/session/runtime/SessionEventHub.d.ts +1 -1
- package/bin/session/runtime/SessionEventHub.d.ts.map +1 -1
- package/bin/session/runtime/SessionModelRequestWarning.d.ts +17 -0
- package/bin/session/runtime/SessionModelRequestWarning.d.ts.map +1 -0
- package/bin/session/runtime/SessionModelRequestWarning.js +19 -0
- package/bin/session/runtime/SessionModelRequestWarning.js.map +1 -0
- package/bin/session/runtime/SessionTitleTask.d.ts +2 -2
- package/bin/session/runtime/SessionTitleTask.d.ts.map +1 -1
- package/bin/session/runtime/SessionTitleTask.js +1 -1
- package/bin/session/runtime/SessionTitleTask.js.map +1 -1
- package/bin/session/runtime/SessionTurnCompletion.d.ts +15 -0
- package/bin/session/runtime/SessionTurnCompletion.d.ts.map +1 -0
- package/bin/session/runtime/SessionTurnCompletion.js +126 -0
- package/bin/session/runtime/SessionTurnCompletion.js.map +1 -0
- package/bin/session/runtime/SessionTurnContext.d.ts +6 -3
- package/bin/session/runtime/SessionTurnContext.d.ts.map +1 -1
- package/bin/session/runtime/SessionTurnContext.js +73 -38
- package/bin/session/runtime/SessionTurnContext.js.map +1 -1
- package/bin/session/runtime/SessionTurnFileDiff.d.ts +12 -0
- package/bin/session/runtime/SessionTurnFileDiff.d.ts.map +1 -0
- package/bin/session/runtime/SessionTurnFileDiff.js +71 -0
- package/bin/session/runtime/SessionTurnFileDiff.js.map +1 -0
- package/bin/{workspace/store → session/storage}/LocalSessionAttachmentStore.d.ts +11 -4
- package/bin/session/storage/LocalSessionAttachmentStore.d.ts.map +1 -0
- package/bin/{workspace/store → session/storage}/LocalSessionAttachmentStore.js +17 -2
- package/bin/session/storage/LocalSessionAttachmentStore.js.map +1 -0
- package/bin/session/storage/LocalSessionDataStore.d.ts +13 -0
- package/bin/session/storage/LocalSessionDataStore.d.ts.map +1 -0
- package/bin/session/storage/LocalSessionDataStore.js +28 -0
- package/bin/session/storage/LocalSessionDataStore.js.map +1 -0
- package/bin/{workspace/store → session/storage}/LocalSessionStore.d.ts +21 -10
- package/bin/session/storage/LocalSessionStore.d.ts.map +1 -0
- package/bin/session/storage/LocalSessionStore.js +329 -0
- package/bin/session/storage/LocalSessionStore.js.map +1 -0
- package/bin/session/storage/LocalStorePaths.d.ts +27 -0
- package/bin/session/storage/LocalStorePaths.d.ts.map +1 -0
- package/bin/session/storage/LocalStorePaths.js +69 -0
- package/bin/session/storage/LocalStorePaths.js.map +1 -0
- package/bin/session/storage/Metadata.d.ts +12 -9
- package/bin/session/storage/Metadata.d.ts.map +1 -1
- package/bin/session/storage/Metadata.js +8 -30
- package/bin/session/storage/Metadata.js.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.d.ts +8 -8
- package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.js +6 -6
- package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
- package/bin/session/storage/SessionStorageCodec.d.ts +59 -0
- package/bin/session/storage/SessionStorageCodec.d.ts.map +1 -0
- package/bin/session/storage/SessionStorageCodec.js +331 -0
- package/bin/session/storage/SessionStorageCodec.js.map +1 -0
- package/bin/session/storage/SessionStorageSchema.d.ts +11 -0
- package/bin/session/storage/SessionStorageSchema.d.ts.map +1 -0
- package/bin/session/storage/SessionStorageSchema.js +131 -0
- package/bin/session/storage/SessionStorageSchema.js.map +1 -0
- package/bin/session/storage/SqliteSessionStorage.d.ts +120 -0
- package/bin/session/storage/SqliteSessionStorage.d.ts.map +1 -0
- package/bin/session/storage/SqliteSessionStorage.js +581 -0
- package/bin/session/storage/SqliteSessionStorage.js.map +1 -0
- package/bin/tools/ask/AskQuestionsTool.d.ts.map +1 -1
- package/bin/tools/ask/AskQuestionsTool.js +3 -1
- package/bin/tools/ask/AskQuestionsTool.js.map +1 -1
- package/bin/tools/ask/AskQuestionsToolSchemas.d.ts +1 -1
- package/bin/types/action/ActionResult.d.ts +13 -9
- package/bin/types/action/ActionResult.d.ts.map +1 -1
- package/bin/types/action/ActionResult.js +2 -1
- package/bin/types/action/ActionResult.js.map +1 -1
- package/bin/types/agent/AgentOptions.d.ts +25 -18
- package/bin/types/agent/AgentOptions.d.ts.map +1 -1
- package/bin/types/agent/AgentSessionCollection.d.ts +17 -13
- package/bin/types/agent/AgentSessionCollection.d.ts.map +1 -1
- package/bin/types/agent/AgentStorage.d.ts +4 -2
- package/bin/types/agent/AgentStorage.d.ts.map +1 -1
- package/bin/types/agent/SessionActor.d.ts +11 -20
- package/bin/types/agent/SessionActor.d.ts.map +1 -1
- package/bin/types/agent/SessionTypes.d.ts +29 -37
- package/bin/types/agent/SessionTypes.d.ts.map +1 -1
- package/bin/types/executor/ModelRequest.d.ts +11 -0
- package/bin/types/executor/ModelRequest.d.ts.map +1 -0
- package/bin/types/executor/ModelRequest.js +7 -0
- package/bin/types/executor/ModelRequest.js.map +1 -0
- package/bin/types/executor/SessionAssistantOutput.d.ts +16 -5
- package/bin/types/executor/SessionAssistantOutput.d.ts.map +1 -1
- package/bin/types/executor/SessionToolExecutionContext.d.ts +3 -3
- package/bin/types/executor/SessionToolExecutionContext.d.ts.map +1 -1
- package/bin/types/executor/SessionTurnContext.d.ts +57 -34
- package/bin/types/executor/SessionTurnContext.d.ts.map +1 -1
- package/bin/types/group/DispatchStrategy.d.ts +62 -36
- package/bin/types/group/DispatchStrategy.d.ts.map +1 -1
- package/bin/types/group/DispatchStrategy.js +83 -39
- package/bin/types/group/DispatchStrategy.js.map +1 -1
- package/bin/types/group/Group.d.ts +8 -8
- package/bin/types/group/Group.d.ts.map +1 -1
- package/bin/types/group/{GroupDispatchSession.d.ts → GroupDispatch.d.ts} +21 -27
- package/bin/types/group/GroupDispatch.d.ts.map +1 -0
- package/bin/types/group/GroupDispatch.js +8 -0
- package/bin/types/group/GroupDispatch.js.map +1 -0
- package/bin/types/group/GroupSession.d.ts +14 -7
- package/bin/types/group/GroupSession.d.ts.map +1 -1
- package/bin/types/group/GroupSessionStore.d.ts +9 -5
- package/bin/types/group/GroupSessionStore.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionAction.d.ts +2 -2
- package/bin/types/sdk/AgentSessionAction.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionAction.js +1 -1
- package/bin/types/sdk/AgentSessionPrompt.d.ts +16 -6
- package/bin/types/sdk/AgentSessionPrompt.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionPrompt.js +7 -3
- package/bin/types/sdk/AgentSessionPrompt.js.map +1 -1
- package/bin/types/session/AdaptivePartContextPolicy.d.ts +31 -0
- package/bin/types/session/AdaptivePartContextPolicy.d.ts.map +1 -0
- package/bin/types/session/AdaptivePartContextPolicy.js +7 -0
- package/bin/types/session/AdaptivePartContextPolicy.js.map +1 -0
- package/bin/types/session/SessionAgentMessageState.d.ts +23 -0
- package/bin/types/session/SessionAgentMessageState.d.ts.map +1 -0
- package/bin/types/session/SessionAgentMessageState.js +8 -0
- package/bin/types/session/SessionAgentMessageState.js.map +1 -0
- package/bin/types/session/SessionCommand.d.ts +19 -7
- package/bin/types/session/SessionCommand.d.ts.map +1 -1
- package/bin/types/session/SessionComposer.d.ts +47 -41
- package/bin/types/session/SessionComposer.d.ts.map +1 -1
- package/bin/types/session/SessionComposer.js +2 -2
- package/bin/types/session/SessionComposition.d.ts +51 -0
- package/bin/types/session/SessionComposition.d.ts.map +1 -0
- package/bin/types/session/SessionComposition.js +8 -0
- package/bin/types/session/SessionComposition.js.map +1 -0
- package/bin/types/session/SessionContextPolicy.d.ts +70 -0
- package/bin/types/session/SessionContextPolicy.d.ts.map +1 -0
- package/bin/types/session/SessionContextPolicy.js +8 -0
- package/bin/types/session/SessionContextPolicy.js.map +1 -0
- package/bin/types/session/SessionExecution.d.ts +6 -33
- package/bin/types/session/SessionExecution.d.ts.map +1 -1
- package/bin/types/session/SessionInteractions.d.ts +1 -1
- package/bin/types/session/SessionInteractions.d.ts.map +1 -1
- package/bin/types/session/SessionLocalState.d.ts +2 -2
- package/bin/types/session/SessionLocalState.d.ts.map +1 -1
- package/bin/types/session/SessionLoop.d.ts +10 -9
- package/bin/types/session/SessionLoop.d.ts.map +1 -1
- package/bin/types/session/SessionMessages.d.ts +29 -30
- package/bin/types/session/SessionMessages.d.ts.map +1 -1
- package/bin/types/session/SessionOptions.d.ts +30 -44
- package/bin/types/session/SessionOptions.d.ts.map +1 -1
- package/bin/types/session/SessionPort.d.ts +14 -15
- package/bin/types/session/SessionPort.d.ts.map +1 -1
- package/bin/types/session/SessionPort.js +1 -1
- package/bin/types/session/SessionState.d.ts +6 -9
- package/bin/types/session/SessionState.d.ts.map +1 -1
- package/bin/types/session/SessionSystem.d.ts +16 -2
- 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 +23 -0
- package/bin/types/session/SessionTurnCompletion.d.ts.map +1 -0
- package/bin/types/session/SessionTurnCompletion.js +8 -0
- package/bin/types/session/SessionTurnCompletion.js.map +1 -0
- package/bin/types/session/SessionTurnFileDiff.d.ts +42 -0
- package/bin/types/session/SessionTurnFileDiff.d.ts.map +1 -0
- package/bin/types/session/SessionTurnFileDiff.js +8 -0
- package/bin/types/session/SessionTurnFileDiff.js.map +1 -0
- package/bin/types/store/LocalStore.d.ts +10 -14
- package/bin/types/store/LocalStore.d.ts.map +1 -1
- package/bin/types/store/LocalStore.js +2 -2
- package/bin/types/store/SessionAttachmentStore.d.ts +17 -2
- package/bin/types/store/SessionAttachmentStore.d.ts.map +1 -1
- package/bin/types/store/SessionAttachmentStore.js +2 -1
- package/bin/types/store/SessionAttachmentStore.js.map +1 -1
- package/bin/types/store/SessionStorage.d.ts +103 -0
- package/bin/types/store/SessionStorage.d.ts.map +1 -0
- package/bin/types/store/SessionStorage.js +8 -0
- package/bin/types/store/SessionStorage.js.map +1 -0
- package/bin/types/store/SessionStore.d.ts +11 -8
- package/bin/types/store/SessionStore.d.ts.map +1 -1
- package/bin/types/tools/ToolActionExecutionContext.d.ts +1 -1
- package/bin/types/tools/ToolActionExecutionContext.d.ts.map +1 -1
- package/bin/types/tools/ask/AskQuestionsTool.d.ts +1 -1
- package/bin/types/tools/ask/AskQuestionsTool.d.ts.map +1 -1
- package/bin/utils/logger/Logger.d.ts +12 -21
- package/bin/utils/logger/Logger.d.ts.map +1 -1
- package/bin/utils/logger/Logger.js +21 -39
- package/bin/utils/logger/Logger.js.map +1 -1
- package/package.json +7 -24
- package/scripts/ModelClientMock.mjs +11 -0
- package/scripts/core-engine-context-compaction.test.mjs +160 -220
- package/scripts/core-engine-model-stream.test.mjs +94 -4
- package/scripts/executor-failure-result.test.mjs +37 -22
- package/scripts/logger-isolation.test.mjs +17 -2
- package/scripts/public-api-naming.test.mjs +9 -15
- package/scripts/session-agent-message-part-order.test.mjs +63 -0
- package/scripts/session-initialization.test.mjs +141 -0
- package/scripts/session-message-timeline.test.mjs +5 -6
- package/scripts/session-messages-error-part.test.mjs +175 -0
- package/scripts/session-messages-error.test.mjs +47 -6
- package/scripts/session-prompt-idempotency.test.mjs +91 -0
- package/scripts/session-queue.test.mjs +13 -12
- package/scripts/session-storage-sqlite.test.mjs +209 -0
- package/scripts/session-turn-context.test.mjs +90 -42
- package/src/agent/Agent.ts +212 -91
- package/src/agent/AgentInstructions.ts +3 -3
- package/src/agent/AgentMemoryStorage.ts +208 -0
- package/src/agent/AgentSessions.ts +164 -88
- package/src/executor/Executor.ts +56 -177
- package/src/executor/README.md +19 -16
- package/src/executor/composer/system/default/SystemPromptAssets.ts +0 -6
- package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/core.prompt.ts.txt +8 -8
- package/src/executor/core-engine/CoreEngineContextCompaction.ts +3 -135
- package/src/executor/core-engine/CoreEngineError.ts +1 -1
- package/src/executor/core-engine/CoreEngineRunner.ts +93 -334
- package/src/executor/core-engine/CoreEngineSignals.ts +10 -10
- package/src/executor/messages/SessionAttachmentMapper.ts +4 -4
- package/src/executor/messages/SessionMessageLog.ts +3 -3
- package/src/executor/messages/SessionModelMessages.ts +87 -99
- package/src/executor/model/ModelGenerate.ts +59 -21
- package/src/executor/model/ModelRequestRunner.ts +107 -0
- package/src/executor/model/ModelStepRunner.ts +28 -60
- package/src/executor/model/ModelStreamConsumer.ts +76 -0
- package/src/executor/model/ModelStreamFailure.ts +28 -0
- package/src/executor/services/ExecutorRecoveryPolicy.ts +34 -127
- package/src/executor/types/SessionHistoryMeta.ts +6 -8
- package/src/group/Group.ts +60 -5
- package/src/group/GroupDispatchRuntime.ts +233 -0
- package/src/group/GroupSession.ts +168 -93
- package/src/group/GroupSessions.ts +12 -11
- package/src/group/index.ts +4 -2
- package/src/{workspace/store → group/storage}/LocalGroupSessionDataStore.ts +99 -8
- package/src/{workspace/store → group/storage}/LocalGroupSessionStore.ts +2 -2
- package/src/index.ts +84 -208
- package/src/session/DefaultSessionComposer.ts +77 -32
- package/src/session/Session.ts +167 -529
- package/src/session/SessionComposition.ts +370 -0
- package/src/session/SessionHookPoints.ts +17 -0
- package/src/session/SessionHooks.ts +85 -0
- package/src/session/SessionLoop.ts +289 -226
- package/src/session/SessionMessages.ts +380 -642
- package/src/session/SessionQueue.ts +3 -2
- package/src/session/SessionState.ts +71 -110
- package/src/session/SessionSystem.ts +53 -3
- package/src/session/SessionTitle.ts +55 -42
- package/src/session/browse/Browse.ts +188 -462
- package/src/session/browse/SessionMessageTimeline.ts +64 -39
- package/src/session/composer/policies/AdaptivePartContextPolicy.ts +307 -0
- package/src/session/composer/policies/FullHistoryContextPolicy.ts +36 -0
- package/src/session/composer/policies/SessionSummaryPrompts.ts +42 -0
- package/src/session/control/SessionInteractions.ts +1 -1
- package/src/session/execution/SessionAssistantOutputAdapter.ts +25 -11
- package/src/session/execution/tools/SessionShellApprovalAdapter.ts +2 -2
- package/src/session/index.ts +17 -0
- package/src/session/messages/SessionAgentActionPartWriter.ts +54 -0
- package/src/session/messages/SessionAgentContent.ts +56 -0
- package/src/session/messages/SessionAgentMessageState.ts +378 -0
- package/src/session/messages/{SessionAssistantMessageWriter.ts → SessionAgentMessageWriter.ts} +90 -61
- package/src/session/messages/SessionForkMessageFiles.ts +79 -0
- package/src/session/messages/SessionJsonValue.ts +1 -1
- package/src/session/messages/SessionMessageInteractionWriter.ts +23 -27
- package/src/session/messages/SessionMessageText.ts +5 -6
- package/src/session/messages/SessionTurnFileDiffBuilder.ts +229 -0
- package/src/session/messages/SessionTurnFileDiffData.ts +72 -0
- package/src/session/messages/SessionUserContext.ts +47 -0
- package/src/session/messages/SessionUserMessage.ts +88 -0
- package/src/session/preview/SessionMessagePreview.ts +27 -10
- package/src/session/runtime/SessionEventHub.ts +1 -1
- package/src/session/runtime/SessionModelRequestWarning.ts +29 -0
- package/src/session/runtime/SessionTitleTask.ts +3 -3
- package/src/session/runtime/SessionTurnCompletion.ts +159 -0
- package/src/session/runtime/SessionTurnContext.ts +96 -46
- package/src/session/runtime/SessionTurnFileDiff.ts +105 -0
- package/src/{workspace/store → session/storage}/LocalSessionAttachmentStore.ts +25 -4
- package/src/session/storage/LocalSessionDataStore.ts +41 -0
- package/src/session/storage/LocalSessionStore.ts +414 -0
- package/src/session/storage/LocalStorePaths.ts +123 -0
- package/src/session/storage/Metadata.ts +19 -36
- package/src/session/storage/RuntimeSessionPort.ts +11 -11
- package/src/session/storage/SessionStorageCodec.ts +465 -0
- package/src/session/storage/SessionStorageSchema.ts +132 -0
- package/src/session/storage/SqliteSessionStorage.ts +776 -0
- package/src/tools/ask/AskQuestionsTool.ts +5 -3
- package/src/types/action/ActionResult.ts +16 -11
- package/src/types/agent/AgentOptions.ts +27 -19
- package/src/types/agent/AgentSessionCollection.ts +19 -9
- package/src/types/agent/AgentStorage.ts +3 -1
- package/src/types/agent/SessionActor.ts +8 -17
- package/src/types/agent/SessionTypes.ts +32 -41
- package/src/types/executor/ModelRequest.ts +14 -0
- package/src/types/executor/SessionAssistantOutput.ts +15 -4
- package/src/types/executor/SessionToolExecutionContext.ts +1 -1
- package/src/types/executor/SessionTurnContext.ts +76 -35
- package/src/types/group/DispatchStrategy.ts +151 -77
- package/src/types/group/Group.ts +6 -6
- package/src/types/group/{GroupDispatchSession.ts → GroupDispatch.ts} +20 -25
- package/src/types/group/GroupSession.ts +9 -4
- package/src/types/group/GroupSessionStore.ts +8 -4
- package/src/types/sdk/AgentSessionAction.ts +2 -2
- package/src/types/sdk/AgentSessionPrompt.ts +21 -8
- package/src/types/session/AdaptivePartContextPolicy.ts +37 -0
- package/src/types/session/SessionAgentMessageState.ts +30 -0
- package/src/types/session/SessionCommand.ts +21 -7
- package/src/types/session/SessionComposer.ts +51 -45
- package/src/types/session/SessionComposition.ts +52 -0
- package/src/types/session/SessionContextPolicy.ts +77 -0
- package/src/types/session/SessionExecution.ts +11 -36
- package/src/types/session/SessionInteractions.ts +1 -1
- package/src/types/session/SessionLocalState.ts +1 -1
- package/src/types/session/SessionLoop.ts +8 -10
- package/src/types/session/SessionMessages.ts +31 -31
- package/src/types/session/SessionOptions.ts +27 -41
- package/src/types/session/SessionPort.ts +13 -13
- package/src/types/session/SessionState.ts +5 -8
- package/src/types/session/SessionSystem.ts +20 -1
- package/src/types/session/SessionTool.ts +2 -2
- package/src/types/session/SessionTurnCompletion.ts +24 -0
- package/src/types/session/SessionTurnFileDiff.ts +44 -0
- package/src/types/store/LocalStore.ts +10 -15
- package/src/types/store/SessionAttachmentStore.ts +19 -2
- package/src/types/store/SessionStorage.ts +121 -0
- package/src/types/store/SessionStore.ts +11 -7
- package/src/types/tools/ToolActionExecutionContext.ts +1 -1
- package/src/types/tools/ask/AskQuestionsTool.ts +1 -1
- package/src/utils/logger/Logger.ts +24 -42
- package/tsconfig.json +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/agent/AgentModel.d.ts +0 -28
- package/bin/agent/AgentModel.d.ts.map +0 -1
- package/bin/agent/AgentModel.js +0 -57
- package/bin/agent/AgentModel.js.map +0 -1
- package/bin/agent/WorkspaceEntry.d.ts +0 -82
- package/bin/agent/WorkspaceEntry.d.ts.map +0 -1
- package/bin/agent/WorkspaceEntry.js +0 -246
- package/bin/agent/WorkspaceEntry.js.map +0 -1
- package/bin/city/host/CityHostRegistry.d.ts +0 -44
- package/bin/city/host/CityHostRegistry.d.ts.map +0 -1
- package/bin/city/host/CityHostRegistry.js +0 -225
- package/bin/city/host/CityHostRegistry.js.map +0 -1
- package/bin/city/index.d.ts +0 -22
- package/bin/city/index.d.ts.map +0 -1
- package/bin/city/index.js +0 -10
- package/bin/city/index.js.map +0 -1
- package/bin/city/runtime/City.d.ts +0 -99
- package/bin/city/runtime/City.d.ts.map +0 -1
- package/bin/city/runtime/City.js +0 -376
- package/bin/city/runtime/City.js.map +0 -1
- package/bin/city/transport/SerializedTransport.d.ts +0 -30
- package/bin/city/transport/SerializedTransport.d.ts.map +0 -1
- package/bin/city/transport/SerializedTransport.js +0 -57
- package/bin/city/transport/SerializedTransport.js.map +0 -1
- package/bin/city/transport/http/AgentHTTP.d.ts +0 -66
- package/bin/city/transport/http/AgentHTTP.d.ts.map +0 -1
- package/bin/city/transport/http/AgentHTTP.js +0 -142
- package/bin/city/transport/http/AgentHTTP.js.map +0 -1
- package/bin/city/transport/http/CityHTTP.d.ts +0 -44
- package/bin/city/transport/http/CityHTTP.d.ts.map +0 -1
- package/bin/city/transport/http/CityHTTP.js +0 -171
- package/bin/city/transport/http/CityHTTP.js.map +0 -1
- package/bin/city/transport/http/NodeHttpAdapter.d.ts +0 -27
- package/bin/city/transport/http/NodeHttpAdapter.d.ts.map +0 -1
- package/bin/city/transport/http/NodeHttpAdapter.js +0 -57
- package/bin/city/transport/http/NodeHttpAdapter.js.map +0 -1
- package/bin/city/transport/http/routes/RuntimeRoutes.d.ts +0 -15
- package/bin/city/transport/http/routes/RuntimeRoutes.d.ts.map +0 -1
- package/bin/city/transport/http/routes/RuntimeRoutes.js +0 -38
- package/bin/city/transport/http/routes/RuntimeRoutes.js.map +0 -1
- package/bin/city/transport/http/routes/SessionRoutes.d.ts +0 -17
- package/bin/city/transport/http/routes/SessionRoutes.d.ts.map +0 -1
- package/bin/city/transport/http/routes/SessionRoutes.js +0 -417
- package/bin/city/transport/http/routes/SessionRoutes.js.map +0 -1
- package/bin/city/transport/rpc/AgentRPC.d.ts +0 -47
- package/bin/city/transport/rpc/AgentRPC.d.ts.map +0 -1
- package/bin/city/transport/rpc/AgentRPC.js +0 -89
- package/bin/city/transport/rpc/AgentRPC.js.map +0 -1
- package/bin/city/transport/rpc/CityRPC.d.ts +0 -26
- package/bin/city/transport/rpc/CityRPC.d.ts.map +0 -1
- package/bin/city/transport/rpc/CityRPC.js +0 -110
- package/bin/city/transport/rpc/CityRPC.js.map +0 -1
- package/bin/city/transport/rpc/RpcServer.d.ts +0 -30
- package/bin/city/transport/rpc/RpcServer.d.ts.map +0 -1
- package/bin/city/transport/rpc/RpcServer.js +0 -125
- package/bin/city/transport/rpc/RpcServer.js.map +0 -1
- package/bin/city/transport/rpc/server/InternalHandlers.d.ts +0 -22
- package/bin/city/transport/rpc/server/InternalHandlers.d.ts.map +0 -1
- package/bin/city/transport/rpc/server/InternalHandlers.js +0 -196
- package/bin/city/transport/rpc/server/InternalHandlers.js.map +0 -1
- package/bin/city/transport/rpc/server/RequestDispatcher.d.ts +0 -27
- package/bin/city/transport/rpc/server/RequestDispatcher.d.ts.map +0 -1
- package/bin/city/transport/rpc/server/RequestDispatcher.js +0 -38
- package/bin/city/transport/rpc/server/RequestDispatcher.js.map +0 -1
- package/bin/city/transport/rpc/server/SdkSessionHandlers.d.ts +0 -25
- package/bin/city/transport/rpc/server/SdkSessionHandlers.d.ts.map +0 -1
- package/bin/city/transport/rpc/server/SdkSessionHandlers.js +0 -146
- package/bin/city/transport/rpc/server/SdkSessionHandlers.js.map +0 -1
- package/bin/city/transport/rpc/server/ServerTypes.d.ts +0 -94
- package/bin/city/transport/rpc/server/ServerTypes.d.ts.map +0 -1
- package/bin/city/transport/rpc/server/ServerTypes.js +0 -9
- package/bin/city/transport/rpc/server/ServerTypes.js.map +0 -1
- package/bin/city/transport/session/RemoteSessionConfig.d.ts +0 -15
- package/bin/city/transport/session/RemoteSessionConfig.d.ts.map +0 -1
- package/bin/city/transport/session/RemoteSessionConfig.js +0 -23
- package/bin/city/transport/session/RemoteSessionConfig.js.map +0 -1
- package/bin/city/transport/types/AgentHttpBinding.d.ts +0 -24
- package/bin/city/transport/types/AgentHttpBinding.d.ts.map +0 -1
- package/bin/city/transport/types/AgentHttpBinding.js +0 -5
- package/bin/city/transport/types/AgentHttpBinding.js.map +0 -1
- package/bin/city/transport/types/AgentHttpRuntime.d.ts +0 -12
- package/bin/city/transport/types/AgentHttpRuntime.d.ts.map +0 -1
- package/bin/city/transport/types/AgentHttpRuntime.js +0 -7
- package/bin/city/transport/types/AgentHttpRuntime.js.map +0 -1
- package/bin/city/transport/types/AgentRpcBinding.d.ts +0 -27
- package/bin/city/transport/types/AgentRpcBinding.d.ts.map +0 -1
- package/bin/city/transport/types/AgentRpcBinding.js +0 -8
- package/bin/city/transport/types/AgentRpcBinding.js.map +0 -1
- package/bin/city/transport/types/AgentRpcRuntime.d.ts +0 -18
- package/bin/city/transport/types/AgentRpcRuntime.d.ts.map +0 -1
- package/bin/city/transport/types/AgentRpcRuntime.js +0 -7
- package/bin/city/transport/types/AgentRpcRuntime.js.map +0 -1
- package/bin/city/transport/types/AgentSessionModelResolver.d.ts +0 -11
- package/bin/city/transport/types/AgentSessionModelResolver.d.ts.map +0 -1
- package/bin/city/transport/types/AgentSessionModelResolver.js +0 -7
- package/bin/city/transport/types/AgentSessionModelResolver.js.map +0 -1
- package/bin/city/transport/types/CityHttpRuntime.d.ts +0 -36
- package/bin/city/transport/types/CityHttpRuntime.d.ts.map +0 -1
- package/bin/city/transport/types/CityHttpRuntime.js +0 -8
- package/bin/city/transport/types/CityHttpRuntime.js.map +0 -1
- package/bin/city/transport/types/CityRpcRuntime.d.ts +0 -17
- package/bin/city/transport/types/CityRpcRuntime.d.ts.map +0 -1
- package/bin/city/transport/types/CityRpcRuntime.js +0 -8
- package/bin/city/transport/types/CityRpcRuntime.js.map +0 -1
- package/bin/city/transport/types/RpcProtocol.d.ts +0 -24
- package/bin/city/transport/types/RpcProtocol.d.ts.map +0 -1
- package/bin/city/transport/types/RpcProtocol.js +0 -9
- package/bin/city/transport/types/RpcProtocol.js.map +0 -1
- package/bin/city/types/City.d.ts +0 -84
- package/bin/city/types/City.d.ts.map +0 -1
- package/bin/city/types/City.js +0 -7
- package/bin/city/types/City.js.map +0 -1
- package/bin/city/types/PluginHostContext.d.ts +0 -34
- package/bin/city/types/PluginHostContext.d.ts.map +0 -1
- package/bin/city/types/PluginHostContext.js +0 -11
- package/bin/city/types/PluginHostContext.js.map +0 -1
- package/bin/city/types/SerializedTransport.d.ts +0 -16
- package/bin/city/types/SerializedTransport.d.ts.map +0 -1
- package/bin/city/types/SerializedTransport.js +0 -3
- package/bin/city/types/SerializedTransport.js.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts +0 -45
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts.map +0 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js +0 -144
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js.map +0 -1
- package/bin/executor/composer/system/SessionSystemComposer.d.ts +0 -23
- package/bin/executor/composer/system/SessionSystemComposer.d.ts.map +0 -1
- package/bin/executor/composer/system/SessionSystemComposer.js +0 -9
- package/bin/executor/composer/system/SessionSystemComposer.js.map +0 -1
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.d.ts +0 -43
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.d.ts.map +0 -1
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.js +0 -42
- package/bin/executor/composer/system/default/DefaultSessionSystemComposer.js.map +0 -1
- package/bin/executor/composer/system/default/PromptRenderer.d.ts +0 -35
- package/bin/executor/composer/system/default/PromptRenderer.d.ts.map +0 -1
- package/bin/executor/composer/system/default/PromptRenderer.js +0 -23
- package/bin/executor/composer/system/default/PromptRenderer.js.map +0 -1
- package/bin/executor/composer/system/default/SystemDomain.d.ts +0 -169
- package/bin/executor/composer/system/default/SystemDomain.d.ts.map +0 -1
- package/bin/executor/composer/system/default/SystemDomain.js +0 -201
- package/bin/executor/composer/system/default/SystemDomain.js.map +0 -1
- package/bin/executor/composer/system/default/assets/task.prompt.d.ts +0 -7
- package/bin/executor/composer/system/default/assets/task.prompt.d.ts.map +0 -1
- package/bin/executor/composer/system/default/assets/task.prompt.js +0 -8
- package/bin/executor/composer/system/default/assets/task.prompt.js.map +0 -1
- package/bin/executor/composer/system/default/variables/GeoContext.d.ts +0 -14
- package/bin/executor/composer/system/default/variables/GeoContext.d.ts.map +0 -1
- package/bin/executor/composer/system/default/variables/GeoContext.js +0 -150
- package/bin/executor/composer/system/default/variables/GeoContext.js.map +0 -1
- package/bin/executor/composer/system/default/variables/PromptTypes.d.ts +0 -36
- package/bin/executor/composer/system/default/variables/PromptTypes.d.ts.map +0 -1
- package/bin/executor/composer/system/default/variables/PromptTypes.js +0 -9
- package/bin/executor/composer/system/default/variables/PromptTypes.js.map +0 -1
- package/bin/executor/composer/system/default/variables/VariableReplacer.d.ts +0 -61
- package/bin/executor/composer/system/default/variables/VariableReplacer.d.ts.map +0 -1
- package/bin/executor/composer/system/default/variables/VariableReplacer.js +0 -93
- package/bin/executor/composer/system/default/variables/VariableReplacer.js.map +0 -1
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts +0 -63
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts.map +0 -1
- package/bin/executor/core-engine/CoreEngineMessageState.js +0 -81
- package/bin/executor/core-engine/CoreEngineMessageState.js.map +0 -1
- package/bin/group/GroupDispatchSession.d.ts +0 -36
- package/bin/group/GroupDispatchSession.d.ts.map +0 -1
- package/bin/group/GroupDispatchSession.js.map +0 -1
- package/bin/internal/AgentRuntime.d.ts +0 -43
- package/bin/internal/AgentRuntime.d.ts.map +0 -1
- package/bin/internal/AgentRuntime.js +0 -179
- package/bin/internal/AgentRuntime.js.map +0 -1
- package/bin/internal/GroupRuntime.d.ts +0 -17
- package/bin/internal/GroupRuntime.d.ts.map +0 -1
- package/bin/internal/GroupRuntime.js +0 -66
- package/bin/internal/GroupRuntime.js.map +0 -1
- package/bin/internal/index.d.ts +0 -8
- package/bin/internal/index.d.ts.map +0 -1
- package/bin/internal/index.js +0 -8
- package/bin/internal/index.js.map +0 -1
- package/bin/plugin/core/ActionScheduleExecutor.d.ts +0 -19
- package/bin/plugin/core/ActionScheduleExecutor.d.ts.map +0 -1
- package/bin/plugin/core/ActionScheduleExecutor.js +0 -58
- package/bin/plugin/core/ActionScheduleExecutor.js.map +0 -1
- package/bin/plugin/core/ActionScheduleRuntime.d.ts +0 -25
- package/bin/plugin/core/ActionScheduleRuntime.d.ts.map +0 -1
- package/bin/plugin/core/ActionScheduleRuntime.js +0 -62
- package/bin/plugin/core/ActionScheduleRuntime.js.map +0 -1
- package/bin/plugin/core/ActionScheduleStore.d.ts +0 -97
- package/bin/plugin/core/ActionScheduleStore.d.ts.map +0 -1
- package/bin/plugin/core/ActionScheduleStore.js +0 -313
- package/bin/plugin/core/ActionScheduleStore.js.map +0 -1
- package/bin/plugin/core/ActionScheduleTime.d.ts +0 -32
- package/bin/plugin/core/ActionScheduleTime.d.ts.map +0 -1
- package/bin/plugin/core/ActionScheduleTime.js +0 -108
- package/bin/plugin/core/ActionScheduleTime.js.map +0 -1
- package/bin/plugin/core/BasePlugin.d.ts +0 -59
- package/bin/plugin/core/BasePlugin.d.ts.map +0 -1
- package/bin/plugin/core/BasePlugin.js +0 -40
- package/bin/plugin/core/BasePlugin.js.map +0 -1
- package/bin/plugin/core/HookRegistry.d.ts +0 -67
- package/bin/plugin/core/HookRegistry.d.ts.map +0 -1
- package/bin/plugin/core/HookRegistry.js +0 -220
- package/bin/plugin/core/HookRegistry.js.map +0 -1
- package/bin/plugin/core/PluginActionExecution.d.ts +0 -33
- package/bin/plugin/core/PluginActionExecution.d.ts.map +0 -1
- package/bin/plugin/core/PluginActionExecution.js +0 -168
- package/bin/plugin/core/PluginActionExecution.js.map +0 -1
- package/bin/plugin/core/PluginActionFactory.d.ts +0 -93
- package/bin/plugin/core/PluginActionFactory.d.ts.map +0 -1
- package/bin/plugin/core/PluginActionFactory.js +0 -56
- package/bin/plugin/core/PluginActionFactory.js.map +0 -1
- package/bin/plugin/core/PluginCatalog.d.ts +0 -57
- package/bin/plugin/core/PluginCatalog.d.ts.map +0 -1
- package/bin/plugin/core/PluginCatalog.js +0 -117
- package/bin/plugin/core/PluginCatalog.js.map +0 -1
- package/bin/plugin/core/PluginContext.d.ts +0 -42
- package/bin/plugin/core/PluginContext.d.ts.map +0 -1
- package/bin/plugin/core/PluginContext.js +0 -35
- package/bin/plugin/core/PluginContext.js.map +0 -1
- package/bin/plugin/core/PluginHttpRoutes.d.ts +0 -24
- package/bin/plugin/core/PluginHttpRoutes.d.ts.map +0 -1
- package/bin/plugin/core/PluginHttpRoutes.js +0 -35
- package/bin/plugin/core/PluginHttpRoutes.js.map +0 -1
- package/bin/plugin/core/PluginRegistry.d.ts +0 -207
- package/bin/plugin/core/PluginRegistry.d.ts.map +0 -1
- package/bin/plugin/core/PluginRegistry.js +0 -675
- package/bin/plugin/core/PluginRegistry.js.map +0 -1
- package/bin/plugin/core/PluginStateController.d.ts +0 -16
- package/bin/plugin/core/PluginStateController.d.ts.map +0 -1
- package/bin/plugin/core/PluginStateController.js +0 -14
- package/bin/plugin/core/PluginStateController.js.map +0 -1
- package/bin/plugin/tool/PluginToolRuntime.d.ts +0 -15
- package/bin/plugin/tool/PluginToolRuntime.d.ts.map +0 -1
- package/bin/plugin/tool/PluginToolRuntime.js +0 -108
- package/bin/plugin/tool/PluginToolRuntime.js.map +0 -1
- package/bin/plugin/tool/PluginToolSchemas.d.ts +0 -36
- package/bin/plugin/tool/PluginToolSchemas.d.ts.map +0 -1
- package/bin/plugin/tool/PluginToolSchemas.js +0 -42
- package/bin/plugin/tool/PluginToolSchemas.js.map +0 -1
- package/bin/plugin/tool/PluginTools.d.ts +0 -22
- package/bin/plugin/tool/PluginTools.d.ts.map +0 -1
- package/bin/plugin/tool/PluginTools.js +0 -61
- package/bin/plugin/tool/PluginTools.js.map +0 -1
- package/bin/plugin/types/ActionSchedule.d.ts +0 -91
- package/bin/plugin/types/ActionSchedule.d.ts.map +0 -1
- package/bin/plugin/types/ActionSchedule.js +0 -10
- package/bin/plugin/types/ActionSchedule.js.map +0 -1
- package/bin/plugin/types/PluginApi.d.ts +0 -79
- package/bin/plugin/types/PluginApi.d.ts.map +0 -1
- package/bin/plugin/types/PluginApi.js +0 -9
- package/bin/plugin/types/PluginApi.js.map +0 -1
- package/bin/remote/RemoteAgent.d.ts +0 -36
- package/bin/remote/RemoteAgent.d.ts.map +0 -1
- package/bin/remote/RemoteAgent.js +0 -97
- package/bin/remote/RemoteAgent.js.map +0 -1
- package/bin/remote/RemoteSession.d.ts +0 -67
- package/bin/remote/RemoteSession.d.ts.map +0 -1
- package/bin/remote/RemoteSession.js +0 -275
- package/bin/remote/RemoteSession.js.map +0 -1
- package/bin/remote/RemoteTransport.d.ts +0 -80
- package/bin/remote/RemoteTransport.d.ts.map +0 -1
- package/bin/remote/RemoteTransport.js +0 -9
- package/bin/remote/RemoteTransport.js.map +0 -1
- package/bin/remote/TransportFactory.d.ts +0 -13
- package/bin/remote/TransportFactory.d.ts.map +0 -1
- package/bin/remote/TransportFactory.js +0 -22
- package/bin/remote/TransportFactory.js.map +0 -1
- package/bin/remote/transports/HttpRemoteAgentTransport.d.ts +0 -52
- package/bin/remote/transports/HttpRemoteAgentTransport.d.ts.map +0 -1
- package/bin/remote/transports/HttpRemoteAgentTransport.js +0 -399
- package/bin/remote/transports/HttpRemoteAgentTransport.js.map +0 -1
- package/bin/remote/transports/RpcClient.d.ts +0 -168
- package/bin/remote/transports/RpcClient.d.ts.map +0 -1
- package/bin/remote/transports/RpcClient.js +0 -484
- package/bin/remote/transports/RpcClient.js.map +0 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.d.ts +0 -51
- package/bin/remote/transports/RpcRemoteAgentTransport.d.ts.map +0 -1
- package/bin/remote/transports/RpcRemoteAgentTransport.js +0 -102
- package/bin/remote/transports/RpcRemoteAgentTransport.js.map +0 -1
- package/bin/session/SessionCommand.d.ts +0 -24
- package/bin/session/SessionCommand.d.ts.map +0 -1
- package/bin/session/SessionCommand.js +0 -35
- package/bin/session/SessionCommand.js.map +0 -1
- package/bin/session/messages/SessionAssistantMessageWriter.d.ts.map +0 -1
- package/bin/session/messages/SessionAssistantMessageWriter.js.map +0 -1
- package/bin/session/messages/SessionMessageCompaction.d.ts +0 -26
- package/bin/session/messages/SessionMessageCompaction.d.ts.map +0 -1
- package/bin/session/messages/SessionMessageCompaction.js +0 -118
- package/bin/session/messages/SessionMessageCompaction.js.map +0 -1
- package/bin/session/runtime/SessionCompactOperation.d.ts +0 -29
- package/bin/session/runtime/SessionCompactOperation.d.ts.map +0 -1
- package/bin/session/runtime/SessionCompactOperation.js +0 -66
- package/bin/session/runtime/SessionCompactOperation.js.map +0 -1
- package/bin/session/runtime/SessionHistoryCompaction.d.ts +0 -22
- package/bin/session/runtime/SessionHistoryCompaction.d.ts.map +0 -1
- package/bin/session/runtime/SessionHistoryCompaction.js +0 -31
- package/bin/session/runtime/SessionHistoryCompaction.js.map +0 -1
- package/bin/types/agent/RemoteAgentOptions.d.ts +0 -28
- package/bin/types/agent/RemoteAgentOptions.d.ts.map +0 -1
- package/bin/types/agent/RemoteAgentOptions.js +0 -9
- package/bin/types/agent/RemoteAgentOptions.js.map +0 -1
- package/bin/types/agent/RemoteAgentPluginAction.d.ts +0 -46
- package/bin/types/agent/RemoteAgentPluginAction.d.ts.map +0 -1
- package/bin/types/agent/RemoteAgentPluginAction.js +0 -9
- package/bin/types/agent/RemoteAgentPluginAction.js.map +0 -1
- package/bin/types/agent/WorkspaceEntryOptions.d.ts +0 -16
- package/bin/types/agent/WorkspaceEntryOptions.d.ts.map +0 -1
- package/bin/types/agent/WorkspaceEntryOptions.js +0 -8
- package/bin/types/agent/WorkspaceEntryOptions.js.map +0 -1
- package/bin/types/common/Json.d.ts +0 -32
- package/bin/types/common/Json.d.ts.map +0 -1
- package/bin/types/common/Json.js +0 -9
- package/bin/types/common/Json.js.map +0 -1
- package/bin/types/common/Template.d.ts +0 -9
- package/bin/types/common/Template.d.ts.map +0 -1
- package/bin/types/common/Template.js +0 -9
- package/bin/types/common/Template.js.map +0 -1
- package/bin/types/group/GroupDispatchSession.d.ts.map +0 -1
- package/bin/types/group/GroupDispatchSession.js +0 -8
- package/bin/types/group/GroupDispatchSession.js.map +0 -1
- package/bin/types/plugin/AgentPluginContext.d.ts +0 -25
- package/bin/types/plugin/AgentPluginContext.d.ts.map +0 -1
- package/bin/types/plugin/AgentPluginContext.js +0 -10
- package/bin/types/plugin/AgentPluginContext.js.map +0 -1
- package/bin/types/plugin/PluginAction.d.ts +0 -161
- package/bin/types/plugin/PluginAction.d.ts.map +0 -1
- package/bin/types/plugin/PluginAction.js +0 -9
- package/bin/types/plugin/PluginAction.js.map +0 -1
- package/bin/types/plugin/PluginActionExecution.d.ts +0 -31
- package/bin/types/plugin/PluginActionExecution.d.ts.map +0 -1
- package/bin/types/plugin/PluginActionExecution.js +0 -10
- package/bin/types/plugin/PluginActionExecution.js.map +0 -1
- package/bin/types/plugin/PluginCommand.d.ts +0 -14
- package/bin/types/plugin/PluginCommand.d.ts.map +0 -1
- package/bin/types/plugin/PluginCommand.js +0 -7
- package/bin/types/plugin/PluginCommand.js.map +0 -1
- package/bin/types/plugin/PluginContext.d.ts +0 -45
- package/bin/types/plugin/PluginContext.d.ts.map +0 -1
- package/bin/types/plugin/PluginContext.js +0 -9
- package/bin/types/plugin/PluginContext.js.map +0 -1
- package/bin/types/plugin/PluginDefinition.d.ts +0 -44
- package/bin/types/plugin/PluginDefinition.d.ts.map +0 -1
- package/bin/types/plugin/PluginDefinition.js +0 -9
- package/bin/types/plugin/PluginDefinition.js.map +0 -1
- package/bin/types/plugin/PluginExecutionContext.d.ts +0 -23
- package/bin/types/plugin/PluginExecutionContext.d.ts.map +0 -1
- package/bin/types/plugin/PluginExecutionContext.js +0 -8
- package/bin/types/plugin/PluginExecutionContext.js.map +0 -1
- package/bin/types/plugin/PluginHttp.d.ts +0 -34
- package/bin/types/plugin/PluginHttp.d.ts.map +0 -1
- package/bin/types/plugin/PluginHttp.js +0 -9
- package/bin/types/plugin/PluginHttp.js.map +0 -1
- package/bin/types/plugin/PluginNotification.d.ts +0 -31
- package/bin/types/plugin/PluginNotification.d.ts.map +0 -1
- package/bin/types/plugin/PluginNotification.js +0 -8
- package/bin/types/plugin/PluginNotification.js.map +0 -1
- package/bin/types/plugin/PluginRegistry.d.ts +0 -21
- package/bin/types/plugin/PluginRegistry.d.ts.map +0 -1
- package/bin/types/plugin/PluginRegistry.js +0 -9
- package/bin/types/plugin/PluginRegistry.js.map +0 -1
- package/bin/types/plugin/PluginRuntime.d.ts +0 -267
- package/bin/types/plugin/PluginRuntime.d.ts.map +0 -1
- package/bin/types/plugin/PluginRuntime.js +0 -9
- package/bin/types/plugin/PluginRuntime.js.map +0 -1
- package/bin/types/plugin/PluginServices.d.ts +0 -10
- package/bin/types/plugin/PluginServices.d.ts.map +0 -1
- package/bin/types/plugin/PluginServices.js +0 -3
- package/bin/types/plugin/PluginServices.js.map +0 -1
- package/bin/types/plugin/PluginState.d.ts +0 -62
- package/bin/types/plugin/PluginState.d.ts.map +0 -1
- package/bin/types/plugin/PluginState.js +0 -10
- package/bin/types/plugin/PluginState.js.map +0 -1
- package/bin/types/plugin/PluginTool.d.ts +0 -92
- package/bin/types/plugin/PluginTool.d.ts.map +0 -1
- package/bin/types/plugin/PluginTool.js +0 -9
- package/bin/types/plugin/PluginTool.js.map +0 -1
- package/bin/types/rpc/RpcProtocol.d.ts +0 -417
- package/bin/types/rpc/RpcProtocol.d.ts.map +0 -1
- package/bin/types/rpc/RpcProtocol.js +0 -10
- package/bin/types/rpc/RpcProtocol.js.map +0 -1
- package/bin/types/sdk/AgentSessionCompact.d.ts +0 -31
- package/bin/types/sdk/AgentSessionCompact.d.ts.map +0 -1
- package/bin/types/sdk/AgentSessionCompact.js +0 -8
- package/bin/types/sdk/AgentSessionCompact.js.map +0 -1
- package/bin/types/session/SessionAction.d.ts +0 -39
- package/bin/types/session/SessionAction.d.ts.map +0 -1
- package/bin/types/session/SessionAction.js +0 -8
- package/bin/types/session/SessionAction.js.map +0 -1
- package/bin/types/session/SessionContent.d.ts +0 -41
- package/bin/types/session/SessionContent.d.ts.map +0 -1
- package/bin/types/session/SessionContent.js +0 -8
- package/bin/types/session/SessionContent.js.map +0 -1
- package/bin/types/session/SessionInteraction.d.ts +0 -215
- package/bin/types/session/SessionInteraction.d.ts.map +0 -1
- package/bin/types/session/SessionInteraction.js +0 -15
- package/bin/types/session/SessionInteraction.js.map +0 -1
- package/bin/types/session/SessionMessage.d.ts +0 -268
- package/bin/types/session/SessionMessage.d.ts.map +0 -1
- package/bin/types/session/SessionMessage.js +0 -8
- package/bin/types/session/SessionMessage.js.map +0 -1
- package/bin/types/session/SessionMutation.d.ts +0 -151
- package/bin/types/session/SessionMutation.d.ts.map +0 -1
- package/bin/types/session/SessionMutation.js +0 -20
- package/bin/types/session/SessionMutation.js.map +0 -1
- package/bin/types/session/SessionOrigin.d.ts +0 -19
- package/bin/types/session/SessionOrigin.d.ts.map +0 -1
- package/bin/types/session/SessionOrigin.js +0 -8
- package/bin/types/session/SessionOrigin.js.map +0 -1
- package/bin/types/session/SessionSegment.d.ts +0 -57
- package/bin/types/session/SessionSegment.d.ts.map +0 -1
- package/bin/types/session/SessionSegment.js +0 -8
- package/bin/types/session/SessionSegment.js.map +0 -1
- package/bin/types/store/SessionDataStore.d.ts +0 -85
- package/bin/types/store/SessionDataStore.d.ts.map +0 -1
- package/bin/types/store/SessionDataStore.js +0 -9
- package/bin/types/store/SessionDataStore.js.map +0 -1
- package/bin/utils/Template.d.ts +0 -17
- package/bin/utils/Template.d.ts.map +0 -1
- package/bin/utils/Template.js +0 -24
- package/bin/utils/Template.js.map +0 -1
- package/bin/workspace/WorkspacePaths.d.ts +0 -16
- package/bin/workspace/WorkspacePaths.d.ts.map +0 -1
- package/bin/workspace/WorkspacePaths.js +0 -35
- package/bin/workspace/WorkspacePaths.js.map +0 -1
- package/bin/workspace/store/JsonlSessionMessageStore.d.ts +0 -77
- package/bin/workspace/store/JsonlSessionMessageStore.d.ts.map +0 -1
- package/bin/workspace/store/JsonlSessionMessageStore.js +0 -419
- package/bin/workspace/store/JsonlSessionMessageStore.js.map +0 -1
- package/bin/workspace/store/LocalGroupDispatchSessionDataStore.d.ts +0 -28
- package/bin/workspace/store/LocalGroupDispatchSessionDataStore.d.ts.map +0 -1
- package/bin/workspace/store/LocalGroupDispatchSessionDataStore.js +0 -102
- package/bin/workspace/store/LocalGroupDispatchSessionDataStore.js.map +0 -1
- package/bin/workspace/store/LocalGroupSessionDataStore.d.ts.map +0 -1
- package/bin/workspace/store/LocalGroupSessionDataStore.js.map +0 -1
- package/bin/workspace/store/LocalGroupSessionStore.d.ts.map +0 -1
- package/bin/workspace/store/LocalGroupSessionStore.js.map +0 -1
- package/bin/workspace/store/LocalSessionAttachmentStore.d.ts.map +0 -1
- package/bin/workspace/store/LocalSessionAttachmentStore.js.map +0 -1
- package/bin/workspace/store/LocalSessionDataStore.d.ts +0 -45
- package/bin/workspace/store/LocalSessionDataStore.d.ts.map +0 -1
- package/bin/workspace/store/LocalSessionDataStore.js +0 -100
- package/bin/workspace/store/LocalSessionDataStore.js.map +0 -1
- package/bin/workspace/store/LocalSessionStore.d.ts.map +0 -1
- package/bin/workspace/store/LocalSessionStore.js +0 -177
- package/bin/workspace/store/LocalSessionStore.js.map +0 -1
- package/bin/workspace/store/LocalStorePaths.d.ts +0 -35
- package/bin/workspace/store/LocalStorePaths.d.ts.map +0 -1
- package/bin/workspace/store/LocalStorePaths.js +0 -62
- package/bin/workspace/store/LocalStorePaths.js.map +0 -1
- package/bin/workspace/store/SessionMessageStoreFactory.d.ts +0 -12
- package/bin/workspace/store/SessionMessageStoreFactory.d.ts.map +0 -1
- package/bin/workspace/store/SessionMessageStoreFactory.js +0 -13
- package/bin/workspace/store/SessionMessageStoreFactory.js.map +0 -1
- package/city-test/agent-http.test.mjs +0 -326
- package/city-test/city-container.test.mjs +0 -156
- package/city-test/city-host-registry.test.mjs +0 -68
- package/city-test/city-transport.test.mjs +0 -282
- package/city-test/group.test.mjs +0 -990
- package/city-test/session-model.test.mjs +0 -169
- package/city-test/transport-lifecycle.test.mjs +0 -164
- package/scripts/PlatformSandbox.mjs +0 -17
- package/scripts/action-schedule-store.test.mjs +0 -171
- package/scripts/agent-env-shell-sandbox.test.mjs +0 -94
- package/scripts/agent-env.test.mjs +0 -56
- package/scripts/agent-multi-workspace.test.mjs +0 -280
- package/scripts/agent-ready.test.mjs +0 -296
- package/scripts/agent-session-maintenance.test.mjs +0 -47
- package/scripts/agent-store.test.mjs +0 -182
- package/scripts/city-model-tool-loop.test.mjs +0 -95
- package/scripts/file-tools.test.mjs +0 -282
- package/scripts/image-plugin-job.test.mjs +0 -600
- package/scripts/multi-agent-plugin-isolation.test.mjs +0 -170
- package/scripts/plugin-tools.test.mjs +0 -556
- package/scripts/remote-session-reconnect.test.mjs +0 -183
- package/scripts/rpc-url-routing.test.mjs +0 -29
- package/scripts/search-tools.test.mjs +0 -188
- package/scripts/session-ask-question.test.mjs +0 -226
- package/scripts/session-attachments.test.mjs +0 -104
- package/scripts/session-compact-handle.test.mjs +0 -118
- package/scripts/session-compaction-prompts.test.mjs +0 -49
- package/scripts/session-composer.test.mjs +0 -208
- package/scripts/session-config-turn-boundary.test.mjs +0 -921
- package/scripts/session-dynamic-interaction.test.mjs +0 -75
- package/scripts/session-fork.test.mjs +0 -35
- package/scripts/session-list-title.test.mjs +0 -202
- package/scripts/session-messages.test.mjs +0 -490
- package/scripts/session-shell-approval.test.mjs +0 -179
- package/scripts/session-title-event.test.mjs +0 -282
- package/scripts/session-tool-approval.test.mjs +0 -173
- package/scripts/session-turn-failure.test.mjs +0 -363
- package/scripts/workspace.test.mjs +0 -260
- package/src/agent/AgentModel.ts +0 -66
- package/src/agent/WorkspaceEntry.ts +0 -309
- package/src/city/host/CityHostRegistry.ts +0 -260
- package/src/city/index.ts +0 -49
- package/src/city/runtime/City.ts +0 -425
- package/src/city/transport/SerializedTransport.ts +0 -65
- package/src/city/transport/http/AgentHTTP.ts +0 -176
- package/src/city/transport/http/CityHTTP.ts +0 -196
- package/src/city/transport/http/NodeHttpAdapter.ts +0 -75
- package/src/city/transport/http/routes/RuntimeRoutes.ts +0 -51
- package/src/city/transport/http/routes/SessionRoutes.ts +0 -497
- package/src/city/transport/rpc/AgentRPC.ts +0 -111
- package/src/city/transport/rpc/CityRPC.ts +0 -138
- package/src/city/transport/rpc/RpcServer.ts +0 -158
- package/src/city/transport/rpc/server/InternalHandlers.ts +0 -223
- package/src/city/transport/rpc/server/RequestDispatcher.ts +0 -67
- package/src/city/transport/rpc/server/SdkSessionHandlers.ts +0 -166
- package/src/city/transport/rpc/server/ServerTypes.ts +0 -103
- package/src/city/transport/session/RemoteSessionConfig.ts +0 -34
- package/src/city/transport/types/AgentHttpBinding.ts +0 -25
- package/src/city/transport/types/AgentHttpRuntime.ts +0 -13
- package/src/city/transport/types/AgentRpcBinding.ts +0 -28
- package/src/city/transport/types/AgentRpcRuntime.ts +0 -20
- package/src/city/transport/types/AgentSessionModelResolver.ts +0 -13
- package/src/city/transport/types/CityHttpRuntime.ts +0 -45
- package/src/city/transport/types/CityRpcRuntime.ts +0 -27
- package/src/city/transport/types/RpcProtocol.ts +0 -32
- package/src/city/types/City.ts +0 -99
- package/src/city/types/PluginHostContext.ts +0 -44
- package/src/city/types/SerializedTransport.ts +0 -19
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.ts +0 -162
- package/src/executor/composer/system/SessionSystemComposer.ts +0 -25
- package/src/executor/composer/system/default/DefaultSessionSystemComposer.ts +0 -76
- package/src/executor/composer/system/default/PromptRenderer.ts +0 -52
- package/src/executor/composer/system/default/SystemDomain.ts +0 -350
- package/src/executor/composer/system/default/assets/task.prompt.ts +0 -9
- package/src/executor/composer/system/default/assets/task.prompt.ts.txt +0 -33
- package/src/executor/composer/system/default/variables/GeoContext.ts +0 -180
- package/src/executor/composer/system/default/variables/PromptTypes.ts +0 -37
- package/src/executor/composer/system/default/variables/VariableReplacer.ts +0 -154
- package/src/executor/core-engine/CoreEngineMessageState.ts +0 -117
- package/src/group/GroupDispatchSession.ts +0 -175
- package/src/internal/AgentRuntime.ts +0 -229
- package/src/internal/GroupRuntime.ts +0 -89
- package/src/internal/index.ts +0 -33
- package/src/plugin/core/ActionScheduleExecutor.ts +0 -68
- package/src/plugin/core/ActionScheduleRuntime.ts +0 -92
- package/src/plugin/core/ActionScheduleStore.ts +0 -414
- package/src/plugin/core/ActionScheduleTime.ts +0 -132
- package/src/plugin/core/BasePlugin.ts +0 -79
- package/src/plugin/core/HookRegistry.ts +0 -297
- package/src/plugin/core/PluginActionExecution.ts +0 -230
- package/src/plugin/core/PluginActionFactory.ts +0 -172
- package/src/plugin/core/PluginCatalog.ts +0 -153
- package/src/plugin/core/PluginContext.ts +0 -71
- package/src/plugin/core/PluginHttpRoutes.ts +0 -47
- package/src/plugin/core/PluginRegistry.ts +0 -888
- package/src/plugin/core/PluginStateController.ts +0 -19
- package/src/plugin/tool/PluginToolRuntime.ts +0 -124
- package/src/plugin/tool/PluginToolSchemas.ts +0 -44
- package/src/plugin/tool/PluginTools.ts +0 -92
- package/src/plugin/types/ActionSchedule.ts +0 -100
- package/src/plugin/types/PluginApi.ts +0 -86
- package/src/remote/RemoteAgent.ts +0 -130
- package/src/remote/RemoteSession.ts +0 -359
- package/src/remote/RemoteTransport.ts +0 -122
- package/src/remote/TransportFactory.ts +0 -29
- package/src/remote/transports/HttpRemoteAgentTransport.ts +0 -582
- package/src/remote/transports/RpcClient.ts +0 -638
- package/src/remote/transports/RpcRemoteAgentTransport.ts +0 -187
- package/src/session/SessionCommand.ts +0 -42
- package/src/session/messages/SessionMessageCompaction.ts +0 -147
- package/src/session/runtime/SessionCompactOperation.ts +0 -93
- package/src/session/runtime/SessionHistoryCompaction.ts +0 -45
- package/src/types/agent/RemoteAgentOptions.ts +0 -29
- package/src/types/agent/RemoteAgentPluginAction.ts +0 -52
- package/src/types/agent/WorkspaceEntryOptions.ts +0 -18
- package/src/types/common/Json.ts +0 -34
- package/src/types/common/Template.ts +0 -9
- package/src/types/plugin/AgentPluginContext.ts +0 -30
- package/src/types/plugin/PluginAction.ts +0 -178
- package/src/types/plugin/PluginActionExecution.ts +0 -36
- package/src/types/plugin/PluginCommand.ts +0 -15
- package/src/types/plugin/PluginContext.ts +0 -59
- package/src/types/plugin/PluginDefinition.ts +0 -54
- package/src/types/plugin/PluginExecutionContext.ts +0 -29
- package/src/types/plugin/PluginHttp.ts +0 -36
- package/src/types/plugin/PluginNotification.ts +0 -38
- package/src/types/plugin/PluginRegistry.ts +0 -25
- package/src/types/plugin/PluginRuntime.ts +0 -292
- package/src/types/plugin/PluginServices.ts +0 -11
- package/src/types/plugin/PluginState.ts +0 -65
- package/src/types/plugin/PluginTool.ts +0 -106
- package/src/types/rpc/RpcProtocol.ts +0 -464
- package/src/types/sdk/AgentSessionCompact.ts +0 -36
- package/src/types/session/SessionAction.ts +0 -41
- package/src/types/session/SessionContent.ts +0 -52
- package/src/types/session/SessionInteraction.ts +0 -268
- package/src/types/session/SessionMessage.ts +0 -306
- package/src/types/session/SessionMutation.ts +0 -183
- package/src/types/session/SessionOrigin.ts +0 -21
- package/src/types/session/SessionSegment.ts +0 -62
- package/src/types/store/SessionDataStore.ts +0 -109
- package/src/utils/Template.ts +0 -28
- package/src/workspace/WorkspacePaths.ts +0 -37
- package/src/workspace/store/JsonlSessionMessageStore.ts +0 -513
- package/src/workspace/store/LocalGroupDispatchSessionDataStore.ts +0 -118
- package/src/workspace/store/LocalSessionDataStore.ts +0 -169
- package/src/workspace/store/LocalSessionStore.ts +0 -243
- package/src/workspace/store/LocalStorePaths.ts +0 -143
- package/src/workspace/store/SessionMessageStoreFactory.ts +0 -18
- /package/bin/{workspace/store → group/storage}/LocalGroupSessionStore.d.ts +0 -0
package/city-test/group.test.mjs
DELETED
|
@@ -1,990 +0,0 @@
|
|
|
1
|
-
import test from "node:test";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
import { Agent, City, Group, Session } from "../bin/index.js";
|
|
7
|
-
import { LocalStorageProvider, Workspace } from "@downcity/workspace";
|
|
8
|
-
import { MockModelClient } from "../scripts/ModelClientMock.mjs";
|
|
9
|
-
|
|
10
|
-
async function wait_for_group_idle(group_session, timeout_ms = 1000) {
|
|
11
|
-
await new Promise((resolve) => {
|
|
12
|
-
let settled = false;
|
|
13
|
-
const finish = () => {
|
|
14
|
-
if (settled) return;
|
|
15
|
-
settled = true;
|
|
16
|
-
unsubscribe();
|
|
17
|
-
clearTimeout(timer);
|
|
18
|
-
resolve();
|
|
19
|
-
};
|
|
20
|
-
const unsubscribe = group_session.subscribe((event) => {
|
|
21
|
-
if (event.type === "status" && ["idle", "failed", "stopped"].includes(event.phase) && event.members.every((member) => !member.running)) finish();
|
|
22
|
-
});
|
|
23
|
-
const timer = setTimeout(finish, timeout_ms);
|
|
24
|
-
});
|
|
25
|
-
return await group_session.messages();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// 测试专用策略:生产代码不再提供隐式规则调度,行为测试显式注入最小策略。
|
|
29
|
-
const test_dispatch_strategy = {
|
|
30
|
-
decide_dispatch({ trigger, message, members }) {
|
|
31
|
-
if (trigger === "auto") return { nodes: [], terminal: true };
|
|
32
|
-
const collective = /你们|大家|各自|分别|同时|一起|所有人/.test(message.text);
|
|
33
|
-
return {
|
|
34
|
-
nodes: [{
|
|
35
|
-
node_id: `test-${message.id}`,
|
|
36
|
-
member_ids: collective ? members.map((member) => member.id) : [members[0].id],
|
|
37
|
-
response_mode: collective ? "parallel" : "single",
|
|
38
|
-
depends_on_node_ids: [],
|
|
39
|
-
instruction: "测试策略:只代表自己发言。",
|
|
40
|
-
}],
|
|
41
|
-
terminal: true,
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
function create_dispatch_tool_call(input, tool_call_id = "dispatch-call") {
|
|
47
|
-
return {
|
|
48
|
-
type: "tool_call",
|
|
49
|
-
tool_call_id,
|
|
50
|
-
tool_name: "dispatch_group",
|
|
51
|
-
input,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class RecordingSession extends Session {
|
|
56
|
-
static created = [];
|
|
57
|
-
|
|
58
|
-
async prompt(input) {
|
|
59
|
-
RecordingSession.created.push({ agent_id: this.agent_id, query: input.query });
|
|
60
|
-
return {
|
|
61
|
-
id: `turn-${this.id}`,
|
|
62
|
-
result: null,
|
|
63
|
-
finished: Promise.resolve({ turn_id: `turn-${this.id}`, text: `reply:${this.agent_id}`, success: true }),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
test("Group broadcasts user messages and collects member replies", async () => {
|
|
69
|
-
RecordingSession.created = [];
|
|
70
|
-
const city = new City();
|
|
71
|
-
const architect = new Agent({ id: "architect", session_class: RecordingSession });
|
|
72
|
-
const reviewer = new Agent({ id: "reviewer", session_class: RecordingSession });
|
|
73
|
-
city.agents.add(architect);
|
|
74
|
-
city.agents.add(reviewer);
|
|
75
|
-
const group = new Group({ id: "delivery", members: [architect, reviewer], dispatch_strategy: test_dispatch_strategy });
|
|
76
|
-
city.groups.add(group);
|
|
77
|
-
const group_session = await group.sessions.create();
|
|
78
|
-
const prompt_result = await group_session.prompt({ query: "大家分别 analyze payment" });
|
|
79
|
-
assert.equal(prompt_result.success, true);
|
|
80
|
-
assert.match(prompt_result.turn_id, /^group-turn-/);
|
|
81
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
82
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), ["architect", "reviewer"]);
|
|
83
|
-
assert.deepEqual((await group_session.messages()).map((message) => [message.sender_type, message.sender_id, message.text]), [
|
|
84
|
-
["user", "user", "大家分别 analyze payment"],
|
|
85
|
-
["agent", "architect", "reply:architect"],
|
|
86
|
-
["agent", "reviewer", "reply:reviewer"],
|
|
87
|
-
]);
|
|
88
|
-
const architect_sessions = await architect.sessions.list();
|
|
89
|
-
assert.equal(architect_sessions.items.length, 1);
|
|
90
|
-
assert.deepEqual(architect_sessions.items[0].origin, { type: "group", group_id: "delivery", group_session_id: group_session.id });
|
|
91
|
-
await city.close();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test("Group.model uses AI dispatch to select only the returned members", async () => {
|
|
95
|
-
RecordingSession.created = [];
|
|
96
|
-
let dispatch_calls = 0;
|
|
97
|
-
const dispatch_model = new MockModelClient({
|
|
98
|
-
modelId: "group-dispatch-model",
|
|
99
|
-
doGenerate: async () => ({
|
|
100
|
-
content: [create_dispatch_tool_call(dispatch_calls++ === 0
|
|
101
|
-
? { steps: [["reviewer"]], next: "continue" }
|
|
102
|
-
: { steps: [], next: "stop" })],
|
|
103
|
-
finishReason: { unified: "stop", raw: "stop" },
|
|
104
|
-
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
|
|
105
|
-
warnings: [],
|
|
106
|
-
}),
|
|
107
|
-
});
|
|
108
|
-
const city = new City();
|
|
109
|
-
const architect = new Agent({ id: "architect", session_class: RecordingSession });
|
|
110
|
-
const reviewer = new Agent({ id: "reviewer", session_class: RecordingSession });
|
|
111
|
-
city.agents.add(architect);
|
|
112
|
-
city.agents.add(reviewer);
|
|
113
|
-
const group = new Group({ id: "ai-delivery", model: dispatch_model, members: [architect, reviewer] });
|
|
114
|
-
city.groups.add(group);
|
|
115
|
-
const group_session = await group.sessions.create();
|
|
116
|
-
await group_session.prompt({ query: "请审查这个变更" });
|
|
117
|
-
await wait_for_group_idle(group_session);
|
|
118
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), ["reviewer"]);
|
|
119
|
-
assert.match(RecordingSession.created[0].query, /你已被 Group 调度选中,必须直接回复当前消息/);
|
|
120
|
-
assert.doesNotMatch(RecordingSession.created[0].query, /判断是否需要回复|如果不需要你发言/);
|
|
121
|
-
await city.close();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test("AI Dispatch 返回空响应图时直接结束当前调度", async () => {
|
|
125
|
-
RecordingSession.created = [];
|
|
126
|
-
const dispatch_model = new MockModelClient({
|
|
127
|
-
modelId: "empty-dispatch-model",
|
|
128
|
-
doGenerate: async () => ({
|
|
129
|
-
content: [create_dispatch_tool_call({ steps: [], next: "stop" })],
|
|
130
|
-
finishReason: { unified: "stop", raw: "stop" },
|
|
131
|
-
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
|
|
132
|
-
warnings: [],
|
|
133
|
-
}),
|
|
134
|
-
});
|
|
135
|
-
const city = new City();
|
|
136
|
-
const architect = new Agent({ id: "architect", session_class: RecordingSession });
|
|
137
|
-
const reviewer = new Agent({ id: "reviewer", session_class: RecordingSession });
|
|
138
|
-
city.agents.add(architect);
|
|
139
|
-
city.agents.add(reviewer);
|
|
140
|
-
const group = new Group({ id: "empty-dispatch", model: dispatch_model, members: [architect, reviewer] });
|
|
141
|
-
city.groups.add(group);
|
|
142
|
-
const empty_session = await group.sessions.create();
|
|
143
|
-
await empty_session.prompt({ query: "请讨论这个问题" });
|
|
144
|
-
await wait_for_group_idle(empty_session);
|
|
145
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), []);
|
|
146
|
-
assert.deepEqual((await empty_session.messages()).map((message) => message.text), ["请讨论这个问题"]);
|
|
147
|
-
await city.close();
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test("Group 没有 model 且未注入策略时记录调度失败", async () => {
|
|
151
|
-
const city = new City();
|
|
152
|
-
const agent = new Agent({ id: "model-required-agent", session_class: RecordingSession });
|
|
153
|
-
city.agents.add(agent);
|
|
154
|
-
const group = new Group({ id: "model-required-group", members: [agent] });
|
|
155
|
-
city.groups.add(group);
|
|
156
|
-
const group_session = await group.sessions.create();
|
|
157
|
-
|
|
158
|
-
await group_session.prompt({ query: "请回答" });
|
|
159
|
-
await wait_for_group_idle(group_session);
|
|
160
|
-
|
|
161
|
-
assert.deepEqual((await group_session.messages()).map((message) => message.text), [
|
|
162
|
-
"请回答",
|
|
163
|
-
"Group requires a configured model for dispatch",
|
|
164
|
-
]);
|
|
165
|
-
await city.close();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test("AI Dispatch 失败时不切换到隐式规则策略", async () => {
|
|
169
|
-
const dispatch_model = new MockModelClient({
|
|
170
|
-
modelId: "failing-dispatch-model",
|
|
171
|
-
doGenerate: async () => { throw new Error("dispatch unavailable"); },
|
|
172
|
-
});
|
|
173
|
-
const city = new City();
|
|
174
|
-
const agent = new Agent({ id: "failing-dispatch-agent", session_class: RecordingSession });
|
|
175
|
-
city.agents.add(agent);
|
|
176
|
-
const group = new Group({ id: "failing-dispatch-group", model: dispatch_model, members: [agent] });
|
|
177
|
-
city.groups.add(group);
|
|
178
|
-
const group_session = await group.sessions.create();
|
|
179
|
-
|
|
180
|
-
await group_session.prompt({ query: "请回答" });
|
|
181
|
-
await wait_for_group_idle(group_session);
|
|
182
|
-
|
|
183
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), []);
|
|
184
|
-
assert.match((await group_session.messages()).at(-1).text, /^Group dispatch model failed:/);
|
|
185
|
-
await city.close();
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
test("AI Dispatch 未调用 dispatch_group 时记录协议错误", async () => {
|
|
189
|
-
const dispatch_model = new MockModelClient({
|
|
190
|
-
modelId: "text-only-dispatch-model",
|
|
191
|
-
doGenerate: async () => ({
|
|
192
|
-
content: [{ type: "text", text: "我建议让 reviewer 回复。" }],
|
|
193
|
-
finishReason: { unified: "stop", raw: "stop" },
|
|
194
|
-
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
|
|
195
|
-
warnings: [],
|
|
196
|
-
}),
|
|
197
|
-
});
|
|
198
|
-
const city = new City();
|
|
199
|
-
const agent = new Agent({ id: "text-only-agent", session_class: RecordingSession });
|
|
200
|
-
city.agents.add(agent);
|
|
201
|
-
const group = new Group({ id: "text-only-group", model: dispatch_model, members: [agent] });
|
|
202
|
-
city.groups.add(group);
|
|
203
|
-
const group_session = await group.sessions.create();
|
|
204
|
-
|
|
205
|
-
await group_session.prompt({ query: "请回答" });
|
|
206
|
-
await wait_for_group_idle(group_session);
|
|
207
|
-
|
|
208
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), []);
|
|
209
|
-
assert.match((await group_session.messages()).at(-1).text, /did not call dispatch_group/);
|
|
210
|
-
await city.close();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
test("AI Dispatch 在同一调度 Turn 内纠正未调用工具的响应", async () => {
|
|
214
|
-
RecordingSession.created = [];
|
|
215
|
-
let dispatch_calls = 0;
|
|
216
|
-
const dispatch_model = new MockModelClient({
|
|
217
|
-
modelId: "recovering-dispatch-model",
|
|
218
|
-
doGenerate: async (call) => {
|
|
219
|
-
dispatch_calls += 1;
|
|
220
|
-
if (dispatch_calls === 1) {
|
|
221
|
-
return {
|
|
222
|
-
content: [{ type: "text", text: "我建议让 responder 回复。" }],
|
|
223
|
-
finishReason: { unified: "stop", raw: "stop" },
|
|
224
|
-
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
|
|
225
|
-
warnings: [],
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
assert.equal(call.messages.some((message) => (
|
|
229
|
-
message.role === "user" && message.content.some((part) => (
|
|
230
|
-
part.type === "text" && part.text.includes("上一响应不符合调度协议")
|
|
231
|
-
))
|
|
232
|
-
)), true);
|
|
233
|
-
return {
|
|
234
|
-
content: [create_dispatch_tool_call({ steps: [["responder"]], next: "stop" })],
|
|
235
|
-
finishReason: { unified: "tool-calls", raw: "tool_calls" },
|
|
236
|
-
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
|
|
237
|
-
warnings: [],
|
|
238
|
-
};
|
|
239
|
-
},
|
|
240
|
-
});
|
|
241
|
-
const city = new City();
|
|
242
|
-
const agent = new Agent({ id: "responder", session_class: RecordingSession });
|
|
243
|
-
city.agents.add(agent);
|
|
244
|
-
const group = new Group({ id: "recovering-dispatch-group", model: dispatch_model, members: [agent] });
|
|
245
|
-
city.groups.add(group);
|
|
246
|
-
const group_session = await group.sessions.create();
|
|
247
|
-
|
|
248
|
-
await group_session.prompt({ query: "请回答" });
|
|
249
|
-
await wait_for_group_idle(group_session);
|
|
250
|
-
|
|
251
|
-
assert.equal(dispatch_calls, 2);
|
|
252
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), ["responder"]);
|
|
253
|
-
assert.equal((await group_session.messages()).some((message) => message.sender_type === "system"), false);
|
|
254
|
-
await city.close();
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
test("AI Dispatch 拒绝未知成员并允许跨阶段重复投递", async () => {
|
|
258
|
-
const inputs = [
|
|
259
|
-
{ input: { steps: [["unknown"]], next: "stop" }, expected_agent_ids: [] },
|
|
260
|
-
{ input: { steps: [["known"], ["known"]], next: "stop" }, expected_agent_ids: ["known", "known"] },
|
|
261
|
-
];
|
|
262
|
-
for (const [index, { input, expected_agent_ids }] of inputs.entries()) {
|
|
263
|
-
RecordingSession.created = [];
|
|
264
|
-
let dispatch_calls = 0;
|
|
265
|
-
const dispatch_model = new MockModelClient({
|
|
266
|
-
modelId: `invalid-dispatch-model-${index}`,
|
|
267
|
-
doGenerate: async () => ({
|
|
268
|
-
content: [create_dispatch_tool_call(expected_agent_ids.length > 0 && dispatch_calls++ > 0
|
|
269
|
-
? { steps: [], next: "stop" }
|
|
270
|
-
: input)],
|
|
271
|
-
finishReason: { unified: "tool-calls", raw: "tool_calls" },
|
|
272
|
-
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
|
|
273
|
-
warnings: [],
|
|
274
|
-
}),
|
|
275
|
-
});
|
|
276
|
-
const city = new City();
|
|
277
|
-
const agent = new Agent({ id: "known", session_class: RecordingSession });
|
|
278
|
-
city.agents.add(agent);
|
|
279
|
-
const group = new Group({ id: `invalid-dispatch-group-${index}`, model: dispatch_model, members: [agent] });
|
|
280
|
-
city.groups.add(group);
|
|
281
|
-
const group_session = await group.sessions.create();
|
|
282
|
-
|
|
283
|
-
await group_session.prompt({ query: "请回答" });
|
|
284
|
-
await wait_for_group_idle(group_session);
|
|
285
|
-
|
|
286
|
-
if (expected_agent_ids.length === 0) {
|
|
287
|
-
assert.match((await group_session.messages()).at(-1).text, /Group dispatch model failed:/);
|
|
288
|
-
} else {
|
|
289
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), expected_agent_ids);
|
|
290
|
-
}
|
|
291
|
-
await city.close();
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test("GroupSession publishes messages and member runtime through one event stream", async () => {
|
|
296
|
-
const events = [];
|
|
297
|
-
const city = new City();
|
|
298
|
-
const agent = new Agent({ id: "status-agent", session_class: RecordingSession });
|
|
299
|
-
city.agents.add(agent);
|
|
300
|
-
const group = new Group({ id: "status-group", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
301
|
-
city.groups.add(group);
|
|
302
|
-
const group_session = await group.sessions.create();
|
|
303
|
-
const unsubscribe = group_session.subscribe((event) => events.push(event));
|
|
304
|
-
await group_session.prompt({ query: "status" });
|
|
305
|
-
await wait_for_group_idle(group_session);
|
|
306
|
-
unsubscribe();
|
|
307
|
-
const status_events = events.filter((event) => event.type === "status");
|
|
308
|
-
assert.equal(status_events[0].phase, "dispatching");
|
|
309
|
-
assert.equal(typeof status_events[0].message_id, "string");
|
|
310
|
-
const dispatch_event = status_events.find((event) => event.dispatched_member_ids);
|
|
311
|
-
assert.equal(dispatch_event.phase, "dispatched");
|
|
312
|
-
assert.deepEqual(dispatch_event.dispatched_member_ids, ["status-agent"]);
|
|
313
|
-
assert.equal(dispatch_event.message_id, status_events[0].message_id);
|
|
314
|
-
const dispatch_index = status_events.indexOf(dispatch_event);
|
|
315
|
-
const executing_index = status_events.findIndex((event, index) => index > dispatch_index && event.phase === "executing" && event.members[0].running);
|
|
316
|
-
assert.equal(executing_index > dispatch_index, true);
|
|
317
|
-
assert.equal(status_events.slice(0, dispatch_index).some((event) => event.members[0].running), false);
|
|
318
|
-
assert.equal(status_events.at(-1).phase, "idle");
|
|
319
|
-
assert.equal(status_events.at(-1).members[0].running, false);
|
|
320
|
-
await city.close();
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
test("Group 成员执行失败时把失败事实写入共享消息", async () => {
|
|
324
|
-
class FailingSession extends Session {
|
|
325
|
-
async prompt() {
|
|
326
|
-
return {
|
|
327
|
-
id: `turn-${this.id}`,
|
|
328
|
-
result: null,
|
|
329
|
-
finished: Promise.resolve({
|
|
330
|
-
turn_id: `turn-${this.id}`,
|
|
331
|
-
text: "",
|
|
332
|
-
success: false,
|
|
333
|
-
error: "模型请求被拒绝",
|
|
334
|
-
}),
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
const city = new City();
|
|
339
|
-
const agent = new Agent({ id: "failing-agent", session_class: FailingSession });
|
|
340
|
-
city.agents.add(agent);
|
|
341
|
-
const group = new Group({ id: "failure-group", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
342
|
-
city.groups.add(group);
|
|
343
|
-
const group_session = await group.sessions.create();
|
|
344
|
-
|
|
345
|
-
await group_session.prompt({ query: "请回答" });
|
|
346
|
-
await wait_for_group_idle(group_session);
|
|
347
|
-
|
|
348
|
-
assert.deepEqual((await group_session.messages()).map((message) => [message.sender_type, message.text]), [
|
|
349
|
-
["user", "请回答"],
|
|
350
|
-
["system", "failing-agent 执行失败:模型请求被拒绝"],
|
|
351
|
-
]);
|
|
352
|
-
await city.close();
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
test("Group 普通消息只投递一个成员", async () => {
|
|
356
|
-
class RejectingSession extends Session {
|
|
357
|
-
async prompt() {
|
|
358
|
-
throw new Error("成员 Session 不可用");
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
RecordingSession.created = [];
|
|
362
|
-
const city = new City();
|
|
363
|
-
const failing_agent = new Agent({ id: "failing-agent", session_class: RejectingSession });
|
|
364
|
-
const healthy_agent = new Agent({ id: "healthy-agent", session_class: RecordingSession });
|
|
365
|
-
city.agents.add(failing_agent);
|
|
366
|
-
city.agents.add(healthy_agent);
|
|
367
|
-
const group = new Group({ id: "partial-failure-group", members: [failing_agent, healthy_agent], dispatch_strategy: test_dispatch_strategy });
|
|
368
|
-
city.groups.add(group);
|
|
369
|
-
const group_session = await group.sessions.create();
|
|
370
|
-
|
|
371
|
-
const result = await group_session.prompt({ query: "请共同回答" });
|
|
372
|
-
await wait_for_group_idle(group_session);
|
|
373
|
-
|
|
374
|
-
assert.equal(result.success, true);
|
|
375
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), []);
|
|
376
|
-
assert.deepEqual((await group_session.messages()).map((message) => [message.sender_type, message.text]), [
|
|
377
|
-
["user", "请共同回答"],
|
|
378
|
-
["system", "failing-agent 执行失败:成员 Session 不可用"],
|
|
379
|
-
]);
|
|
380
|
-
await city.close();
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
test("Group 本身不绑定 Workspace,GroupSession 才绑定 Workspace", async () => {
|
|
384
|
-
const city = new City({ workspaces: [new Workspace({ id: "project", path: process.cwd() })] });
|
|
385
|
-
const agent = new Agent({ id: "builder", session_class: RecordingSession });
|
|
386
|
-
city.agents.add(agent);
|
|
387
|
-
const group = new Group({ id: "valid", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
388
|
-
city.groups.add(group);
|
|
389
|
-
const group_session = await group.sessions.create({ workspace: city.workspaces.get("project") });
|
|
390
|
-
assert.equal(group_session.workspace_id, "project");
|
|
391
|
-
await city.close();
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
test("Group 成员 Session 使用 Group 的共享 Workspace", async () => {
|
|
395
|
-
RecordingSession.created = [];
|
|
396
|
-
const workspace = new Workspace({ id: "shared-project", path: process.cwd() });
|
|
397
|
-
const city = new City({ workspaces: [workspace] });
|
|
398
|
-
const agent = new Agent({ id: "builder", session_class: RecordingSession });
|
|
399
|
-
city.agents.add(agent);
|
|
400
|
-
const group = new Group({ id: "build-team", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
401
|
-
city.groups.add(group);
|
|
402
|
-
const group_session = await group.sessions.create({ workspace });
|
|
403
|
-
await group_session.prompt({ query: "build" });
|
|
404
|
-
await wait_for_group_idle(group_session);
|
|
405
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
406
|
-
const sessions = await agent.sessions.list({ workspace_id: "shared-project" });
|
|
407
|
-
assert.equal(sessions.items.length, 1);
|
|
408
|
-
assert.deepEqual(sessions.items[0].origin, { type: "group", group_id: "build-team", group_session_id: group_session.id });
|
|
409
|
-
assert.equal((await group.sessions.list({ workspace_id: "shared-project" })).length, 1);
|
|
410
|
-
assert.equal((await group.sessions.get(group_session.id, { workspace })).workspace_id, "shared-project");
|
|
411
|
-
await city.close();
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
test("Group 从 City 释放后可以在同一 City 重新装配", async () => {
|
|
415
|
-
const group = new Group({ id: "reattachable-group", members: [new Agent({ id: "reattachable-agent", session_class: RecordingSession })], dispatch_strategy: test_dispatch_strategy });
|
|
416
|
-
const first_city = new City();
|
|
417
|
-
first_city.agents.add(group.members[0]);
|
|
418
|
-
first_city.groups.add(group);
|
|
419
|
-
await first_city.groups.remove(group.id);
|
|
420
|
-
|
|
421
|
-
first_city.groups.add(group);
|
|
422
|
-
await group.sessions.create();
|
|
423
|
-
await first_city.close();
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
test("GroupSession 使用 City Storage 持久化并可恢复", async () => {
|
|
427
|
-
RecordingSession.created = [];
|
|
428
|
-
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-group-session-"));
|
|
429
|
-
const storage = new LocalStorageProvider(root_path);
|
|
430
|
-
const city = new City({ storage });
|
|
431
|
-
const agent = new Agent({ id: "builder", session_class: RecordingSession });
|
|
432
|
-
city.agents.add(agent);
|
|
433
|
-
const group = new Group({ id: "persistent-team", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
434
|
-
city.groups.add(group);
|
|
435
|
-
const created = await group.sessions.create();
|
|
436
|
-
await created.prompt({ query: "persist this message" });
|
|
437
|
-
await wait_for_group_idle(created);
|
|
438
|
-
await city.close();
|
|
439
|
-
|
|
440
|
-
const restored_city = new City({ storage });
|
|
441
|
-
const restored_agent = new Agent({ id: "builder", session_class: RecordingSession });
|
|
442
|
-
restored_city.agents.add(restored_agent);
|
|
443
|
-
const restored_group = new Group({ id: "persistent-team", members: [restored_agent], dispatch_strategy: test_dispatch_strategy });
|
|
444
|
-
restored_city.groups.add(restored_group);
|
|
445
|
-
const restored = await restored_group.sessions.get(created.id);
|
|
446
|
-
assert.ok(restored);
|
|
447
|
-
assert.deepEqual((await restored.messages()).map((message) => message.text), [
|
|
448
|
-
"persist this message",
|
|
449
|
-
"reply:builder",
|
|
450
|
-
]);
|
|
451
|
-
const summaries = await restored_group.sessions.list();
|
|
452
|
-
assert.equal(summaries.length, 1);
|
|
453
|
-
assert.equal(summaries[0].id, created.id);
|
|
454
|
-
assert.equal(summaries[0].message_count, 2);
|
|
455
|
-
RecordingSession.created = [];
|
|
456
|
-
await restored.prompt({ query: "reuse member session" });
|
|
457
|
-
await wait_for_group_idle(restored);
|
|
458
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), ["builder"]);
|
|
459
|
-
await restored_city.close();
|
|
460
|
-
await fs.rm(root_path, { recursive: true, force: true });
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
test("GroupSession 持久化独享 Dispatch Session 的调度 Turn", async () => {
|
|
464
|
-
RecordingSession.created = [];
|
|
465
|
-
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-group-dispatch-session-"));
|
|
466
|
-
const city = new City({ storage: new LocalStorageProvider(root_path) });
|
|
467
|
-
const agent = new Agent({ id: "dispatch-member", session_class: RecordingSession });
|
|
468
|
-
city.agents.add(agent);
|
|
469
|
-
const group = new Group({ id: "dispatch-session-group", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
470
|
-
city.groups.add(group);
|
|
471
|
-
const session = await group.sessions.create();
|
|
472
|
-
|
|
473
|
-
await session.prompt({ query: "persist dispatch" });
|
|
474
|
-
await wait_for_group_idle(session);
|
|
475
|
-
|
|
476
|
-
const turns_path = path.join(
|
|
477
|
-
root_path,
|
|
478
|
-
"groups",
|
|
479
|
-
"dispatch-session-group",
|
|
480
|
-
"sessions",
|
|
481
|
-
encodeURIComponent(session.id),
|
|
482
|
-
"dispatch",
|
|
483
|
-
"turns.jsonl",
|
|
484
|
-
);
|
|
485
|
-
const records = (await fs.readFile(turns_path, "utf8"))
|
|
486
|
-
.trim()
|
|
487
|
-
.split("\n")
|
|
488
|
-
.map((line) => JSON.parse(line));
|
|
489
|
-
const user_records = records.filter((record) => record.trigger === "user");
|
|
490
|
-
assert.deepEqual(user_records.map((record) => record.status), ["queued", "running", "completed"]);
|
|
491
|
-
assert.deepEqual(user_records.at(-1).decision.nodes[0].member_ids, ["dispatch-member"]);
|
|
492
|
-
assert.equal(
|
|
493
|
-
(await session.messages()).find((message) => message.sender_type === "agent").dispatch_id,
|
|
494
|
-
user_records.at(-1).dispatch_id,
|
|
495
|
-
);
|
|
496
|
-
await city.close();
|
|
497
|
-
await fs.rm(root_path, { recursive: true, force: true });
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
test("GroupSession stop 会中断 Dispatch Session 且不记录失败消息", async () => {
|
|
501
|
-
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-group-dispatch-stop-"));
|
|
502
|
-
let dispatch_started = false;
|
|
503
|
-
let dispatch_aborted = false;
|
|
504
|
-
let dispatch_invocations = 0;
|
|
505
|
-
const strategy = {
|
|
506
|
-
async decide_dispatch({ abort_signal }) {
|
|
507
|
-
dispatch_invocations += 1;
|
|
508
|
-
dispatch_started = true;
|
|
509
|
-
await new Promise((resolve, reject) => {
|
|
510
|
-
const abort = () => {
|
|
511
|
-
dispatch_aborted = true;
|
|
512
|
-
reject(abort_signal.reason);
|
|
513
|
-
};
|
|
514
|
-
if (abort_signal.aborted) abort();
|
|
515
|
-
else abort_signal.addEventListener("abort", abort, { once: true });
|
|
516
|
-
});
|
|
517
|
-
return { nodes: [], terminal: true };
|
|
518
|
-
},
|
|
519
|
-
};
|
|
520
|
-
const city = new City({ storage: new LocalStorageProvider(root_path) });
|
|
521
|
-
const agent = new Agent({ id: "unused-member", session_class: RecordingSession });
|
|
522
|
-
city.agents.add(agent);
|
|
523
|
-
const group = new Group({ id: "dispatch-stop-group", members: [agent], dispatch_strategy: strategy });
|
|
524
|
-
city.groups.add(group);
|
|
525
|
-
const session = await group.sessions.create();
|
|
526
|
-
await session.prompt({ query: "stop dispatch" });
|
|
527
|
-
await session.prompt({ query: "cancel queued dispatch" });
|
|
528
|
-
for (let attempt = 0; attempt < 200 && !dispatch_started; attempt += 1) {
|
|
529
|
-
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
await session.stop();
|
|
533
|
-
|
|
534
|
-
assert.equal(dispatch_aborted, true);
|
|
535
|
-
assert.equal(dispatch_invocations, 1);
|
|
536
|
-
assert.deepEqual((await session.messages()).map((message) => message.text), [
|
|
537
|
-
"stop dispatch",
|
|
538
|
-
"cancel queued dispatch",
|
|
539
|
-
]);
|
|
540
|
-
const turns_path = path.join(
|
|
541
|
-
root_path,
|
|
542
|
-
"groups",
|
|
543
|
-
"dispatch-stop-group",
|
|
544
|
-
"sessions",
|
|
545
|
-
encodeURIComponent(session.id),
|
|
546
|
-
"dispatch",
|
|
547
|
-
"turns.jsonl",
|
|
548
|
-
);
|
|
549
|
-
const records = (await fs.readFile(turns_path, "utf8"))
|
|
550
|
-
.trim()
|
|
551
|
-
.split("\n")
|
|
552
|
-
.map((line) => JSON.parse(line));
|
|
553
|
-
const latest_records = new Map(records.map((record) => [record.dispatch_id, record]));
|
|
554
|
-
assert.equal(latest_records.size, 2);
|
|
555
|
-
assert.deepEqual([...latest_records.values()].map((record) => record.status), ["stopped", "stopped"]);
|
|
556
|
-
await city.close();
|
|
557
|
-
await fs.rm(root_path, { recursive: true, force: true });
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
test("GroupSession 恢复时重新执行中断的用户调度", async () => {
|
|
561
|
-
RecordingSession.created = [];
|
|
562
|
-
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-group-dispatch-recovery-"));
|
|
563
|
-
let original_abort_signal;
|
|
564
|
-
let original_dispatch_started = false;
|
|
565
|
-
const original_city = new City({ storage: new LocalStorageProvider(root_path) });
|
|
566
|
-
const original_agent = new Agent({ id: "recovery-member", session_class: RecordingSession });
|
|
567
|
-
original_city.agents.add(original_agent);
|
|
568
|
-
const original_group = new Group({
|
|
569
|
-
id: "dispatch-recovery-group",
|
|
570
|
-
members: [original_agent],
|
|
571
|
-
dispatch_strategy: {
|
|
572
|
-
async decide_dispatch({ abort_signal }) {
|
|
573
|
-
original_abort_signal = abort_signal;
|
|
574
|
-
original_dispatch_started = true;
|
|
575
|
-
await new Promise((resolve, reject) => {
|
|
576
|
-
abort_signal.addEventListener("abort", () => reject(abort_signal.reason), { once: true });
|
|
577
|
-
});
|
|
578
|
-
return { nodes: [], terminal: true };
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
});
|
|
582
|
-
original_city.groups.add(original_group);
|
|
583
|
-
const original_session = await original_group.sessions.create();
|
|
584
|
-
await original_session.prompt({ query: "recover dispatch" });
|
|
585
|
-
for (let attempt = 0; attempt < 200 && !original_dispatch_started; attempt += 1) {
|
|
586
|
-
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
const restored_city = new City({ storage: new LocalStorageProvider(root_path) });
|
|
590
|
-
const restored_agent = new Agent({ id: "recovery-member", session_class: RecordingSession });
|
|
591
|
-
restored_city.agents.add(restored_agent);
|
|
592
|
-
const restored_group = new Group({
|
|
593
|
-
id: "dispatch-recovery-group",
|
|
594
|
-
members: [restored_agent],
|
|
595
|
-
dispatch_strategy: test_dispatch_strategy,
|
|
596
|
-
});
|
|
597
|
-
restored_city.groups.add(restored_group);
|
|
598
|
-
const restored_session = await restored_group.sessions.get(original_session.id);
|
|
599
|
-
assert.ok(restored_session);
|
|
600
|
-
await wait_for_group_idle(restored_session);
|
|
601
|
-
|
|
602
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), ["recovery-member"]);
|
|
603
|
-
assert.deepEqual((await restored_session.messages()).map((message) => message.text), [
|
|
604
|
-
"recover dispatch",
|
|
605
|
-
"reply:recovery-member",
|
|
606
|
-
]);
|
|
607
|
-
await original_session.stop();
|
|
608
|
-
assert.equal(original_abort_signal.aborted, true);
|
|
609
|
-
await restored_city.close();
|
|
610
|
-
await original_city.close();
|
|
611
|
-
await fs.rm(root_path, { recursive: true, force: true });
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
test("GroupSession 持久化调度检查点并在收口后清理", async () => {
|
|
615
|
-
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-group-checkpoint-"));
|
|
616
|
-
const storage = new LocalStorageProvider(root_path);
|
|
617
|
-
let resolve_finished;
|
|
618
|
-
class BlockingSession extends Session {
|
|
619
|
-
async prompt() {
|
|
620
|
-
return {
|
|
621
|
-
id: `turn-${this.id}`,
|
|
622
|
-
result: null,
|
|
623
|
-
finished: new Promise((resolve) => { resolve_finished = resolve; }),
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
const city = new City({ storage });
|
|
628
|
-
const agent = new Agent({ id: "checkpoint-agent", session_class: BlockingSession });
|
|
629
|
-
city.agents.add(agent);
|
|
630
|
-
const group = new Group({ id: "checkpoint-group", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
631
|
-
city.groups.add(group);
|
|
632
|
-
const session = await group.sessions.create();
|
|
633
|
-
await session.prompt({ query: "checkpoint" });
|
|
634
|
-
for (let attempt = 0; attempt < 200 && typeof resolve_finished !== "function"; attempt += 1) {
|
|
635
|
-
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
636
|
-
}
|
|
637
|
-
assert.equal(typeof resolve_finished, "function");
|
|
638
|
-
const meta_path = path.join(root_path, "groups", "checkpoint-group", "sessions", encodeURIComponent(session.id), "meta.json");
|
|
639
|
-
const pending_meta = JSON.parse(await fs.readFile(meta_path, "utf8"));
|
|
640
|
-
assert.equal(pending_meta.pending_turns.length, 1);
|
|
641
|
-
resolve_finished({ turn_id: "finished", text: "done", success: true });
|
|
642
|
-
await wait_for_group_idle(session);
|
|
643
|
-
const completed_meta = JSON.parse(await fs.readFile(meta_path, "utf8"));
|
|
644
|
-
assert.deepEqual(completed_meta.pending_turns, []);
|
|
645
|
-
assert.deepEqual(completed_meta.auto_frontier_message_ids, []);
|
|
646
|
-
await city.close();
|
|
647
|
-
await fs.rm(root_path, { recursive: true, force: true });
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
test("GroupSession 列表首次读取时将 v1 metadata 原子迁移为 v2", async () => {
|
|
651
|
-
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-group-metadata-migration-"));
|
|
652
|
-
const group_id = "metadata-migration-group";
|
|
653
|
-
const session_id = "legacy-session";
|
|
654
|
-
const session_path = path.join(root_path, "groups", group_id, "sessions", session_id);
|
|
655
|
-
const meta_path = path.join(session_path, "meta.json");
|
|
656
|
-
await fs.mkdir(session_path, { recursive: true });
|
|
657
|
-
await fs.writeFile(meta_path, `${JSON.stringify({
|
|
658
|
-
v: 1,
|
|
659
|
-
session_id,
|
|
660
|
-
group_id,
|
|
661
|
-
created_at: 1,
|
|
662
|
-
updated_at: 2,
|
|
663
|
-
message_count: 1,
|
|
664
|
-
preview_text: "legacy message",
|
|
665
|
-
pending_turns: [{
|
|
666
|
-
turn_id: "legacy-turn",
|
|
667
|
-
root_message_id: "legacy-message",
|
|
668
|
-
context_message_ids: [],
|
|
669
|
-
}],
|
|
670
|
-
auto_frontier_message_ids: ["legacy-reply"],
|
|
671
|
-
}, null, 2)}\n`);
|
|
672
|
-
|
|
673
|
-
const city = new City({ storage: new LocalStorageProvider(root_path) });
|
|
674
|
-
const agent = new Agent({ id: "metadata-agent", session_class: RecordingSession });
|
|
675
|
-
city.agents.add(agent);
|
|
676
|
-
const group = new Group({ id: group_id, members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
677
|
-
city.groups.add(group);
|
|
678
|
-
|
|
679
|
-
assert.deepEqual(await group.sessions.list(), [{
|
|
680
|
-
id: session_id,
|
|
681
|
-
group_id,
|
|
682
|
-
created_at: 1,
|
|
683
|
-
updated_at: 2,
|
|
684
|
-
message_count: 1,
|
|
685
|
-
preview_text: "legacy message",
|
|
686
|
-
}]);
|
|
687
|
-
const migrated_metadata = JSON.parse(await fs.readFile(meta_path, "utf8"));
|
|
688
|
-
assert.equal(migrated_metadata.v, 2);
|
|
689
|
-
assert.deepEqual(migrated_metadata.pending_turns, [{
|
|
690
|
-
turn_id: "legacy-turn",
|
|
691
|
-
root_message_id: "legacy-message",
|
|
692
|
-
context_message_ids: [],
|
|
693
|
-
dispatch_stage: "auto",
|
|
694
|
-
}]);
|
|
695
|
-
assert.deepEqual(migrated_metadata.auto_frontier_message_ids, ["legacy-reply"]);
|
|
696
|
-
await city.close();
|
|
697
|
-
await fs.rm(root_path, { recursive: true, force: true });
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
test("GroupSession 恢复时修复尾部损坏的消息记录", async () => {
|
|
701
|
-
const root_path = await fs.mkdtemp(path.join(os.tmpdir(), "downcity-group-tail-"));
|
|
702
|
-
const storage = new LocalStorageProvider(root_path);
|
|
703
|
-
const city = new City({ storage });
|
|
704
|
-
const agent = new Agent({ id: "tail-agent", session_class: RecordingSession });
|
|
705
|
-
city.agents.add(agent);
|
|
706
|
-
const group = new Group({ id: "tail-group", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
707
|
-
city.groups.add(group);
|
|
708
|
-
const session = await group.sessions.create();
|
|
709
|
-
await session.prompt({ query: "keep this" });
|
|
710
|
-
await wait_for_group_idle(session);
|
|
711
|
-
await city.close();
|
|
712
|
-
const messages_path = path.join(root_path, "groups", "tail-group", "sessions", encodeURIComponent(session.id), "messages.jsonl");
|
|
713
|
-
await fs.appendFile(messages_path, "{\"id\":\"incomplete");
|
|
714
|
-
|
|
715
|
-
const restored_city = new City({ storage: new LocalStorageProvider(root_path) });
|
|
716
|
-
const restored_agent = new Agent({ id: "tail-agent", session_class: RecordingSession });
|
|
717
|
-
restored_city.agents.add(restored_agent);
|
|
718
|
-
const restored_group = new Group({ id: "tail-group", members: [restored_agent], dispatch_strategy: test_dispatch_strategy });
|
|
719
|
-
restored_city.groups.add(restored_group);
|
|
720
|
-
const restored = await restored_group.sessions.get(session.id);
|
|
721
|
-
assert.deepEqual((await restored.messages()).map((message) => message.text), ["keep this", "reply:tail-agent"]);
|
|
722
|
-
await restored_city.close();
|
|
723
|
-
await fs.rm(root_path, { recursive: true, force: true });
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
test("GroupSession prompt 立即返回并由 AgentSession 自己排队", async () => {
|
|
727
|
-
const calls = [];
|
|
728
|
-
class OrderedSession extends Session {
|
|
729
|
-
async prompt(input) {
|
|
730
|
-
calls.push(input.query);
|
|
731
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
732
|
-
return {
|
|
733
|
-
id: `turn-${this.id}`,
|
|
734
|
-
result: null,
|
|
735
|
-
finished: Promise.resolve({ turn_id: `turn-${this.id}`, text: `reply:${input.query}`, success: true }),
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
const city = new City();
|
|
740
|
-
const agent = new Agent({ id: "ordered", session_class: OrderedSession });
|
|
741
|
-
city.agents.add(agent);
|
|
742
|
-
const group = new Group({ id: "ordered-group", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
743
|
-
city.groups.add(group);
|
|
744
|
-
const session = await group.sessions.create();
|
|
745
|
-
const first = await session.prompt({ query: "first" });
|
|
746
|
-
const second = await session.prompt({ query: "second" });
|
|
747
|
-
assert.notEqual(first.turn_id, second.turn_id);
|
|
748
|
-
await wait_for_group_idle(session);
|
|
749
|
-
assert.equal(calls.length, 2);
|
|
750
|
-
assert.equal(calls.some((query) => query.includes("Current message from user: first")), true);
|
|
751
|
-
assert.equal(calls.some((query) => query.includes("Current message from user: second")), true);
|
|
752
|
-
assert.deepEqual((await session.messages()).filter((message) => message.sender_type === "user").map((message) => message.text), ["first", "second"]);
|
|
753
|
-
await city.close();
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
test("Dispatch 响应图按依赖传递上一个成员的回复", async () => {
|
|
757
|
-
RecordingSession.created = [];
|
|
758
|
-
const city = new City();
|
|
759
|
-
const architect = new Agent({ id: "architect", session_class: RecordingSession });
|
|
760
|
-
const reviewer = new Agent({ id: "reviewer", session_class: RecordingSession });
|
|
761
|
-
city.agents.add(architect);
|
|
762
|
-
city.agents.add(reviewer);
|
|
763
|
-
const group = new Group({
|
|
764
|
-
id: "dependency-group",
|
|
765
|
-
members: [architect, reviewer],
|
|
766
|
-
dispatch_strategy: {
|
|
767
|
-
decide_dispatch: ({ trigger }) => trigger === "user"
|
|
768
|
-
? {
|
|
769
|
-
nodes: [
|
|
770
|
-
{ node_id: "architect", member_ids: ["architect"], response_mode: "single", depends_on_node_ids: [], instruction: "先分析。" },
|
|
771
|
-
{ node_id: "reviewer", member_ids: ["reviewer"], response_mode: "single", depends_on_node_ids: ["architect"], instruction: "基于前一个成员的回复审查。" },
|
|
772
|
-
],
|
|
773
|
-
terminal: true,
|
|
774
|
-
}
|
|
775
|
-
: { nodes: [], terminal: true },
|
|
776
|
-
},
|
|
777
|
-
});
|
|
778
|
-
city.groups.add(group);
|
|
779
|
-
const group_session = await group.sessions.create();
|
|
780
|
-
await group_session.prompt({ query: "请分析并审查" });
|
|
781
|
-
await wait_for_group_idle(group_session);
|
|
782
|
-
assert.equal(RecordingSession.created.length, 2);
|
|
783
|
-
assert.equal(RecordingSession.created[0].agent_id, "architect");
|
|
784
|
-
assert.equal(RecordingSession.created[1].agent_id, "reviewer");
|
|
785
|
-
assert.match(RecordingSession.created[1].query, /architect: reply:architect/);
|
|
786
|
-
await city.close();
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
test("Dispatch 拓扑允许同一成员在不同节点重复参与", async () => {
|
|
790
|
-
RecordingSession.created = [];
|
|
791
|
-
const city = new City();
|
|
792
|
-
const members = ["a", "d", "e", "f"].map((id) => new Agent({ id, session_class: RecordingSession }));
|
|
793
|
-
for (const member of members) city.agents.add(member);
|
|
794
|
-
const group = new Group({
|
|
795
|
-
id: "repeated-member-group",
|
|
796
|
-
members,
|
|
797
|
-
dispatch_strategy: {
|
|
798
|
-
decide_dispatch: ({ trigger }) => trigger === "user"
|
|
799
|
-
? {
|
|
800
|
-
nodes: [
|
|
801
|
-
{ node_id: "step-0", member_ids: ["a"], response_mode: "single", depends_on_node_ids: [], instruction: "第一阶段。" },
|
|
802
|
-
{ node_id: "step-1", member_ids: ["d"], response_mode: "single", depends_on_node_ids: ["step-0"], instruction: "第二阶段。" },
|
|
803
|
-
{ node_id: "step-2", member_ids: ["a"], response_mode: "single", depends_on_node_ids: ["step-1"], instruction: "第三阶段。" },
|
|
804
|
-
{ node_id: "step-3", member_ids: ["e"], response_mode: "single", depends_on_node_ids: ["step-2"], instruction: "第四阶段。" },
|
|
805
|
-
{ node_id: "step-4", member_ids: ["f"], response_mode: "single", depends_on_node_ids: ["step-3"], instruction: "第五阶段。" },
|
|
806
|
-
],
|
|
807
|
-
terminal: true,
|
|
808
|
-
}
|
|
809
|
-
: { nodes: [], terminal: true },
|
|
810
|
-
},
|
|
811
|
-
});
|
|
812
|
-
city.groups.add(group);
|
|
813
|
-
const group_session = await group.sessions.create();
|
|
814
|
-
await group_session.prompt({ query: "执行多阶段流程" });
|
|
815
|
-
await wait_for_group_idle(group_session);
|
|
816
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), ["a", "d", "a", "e", "f"]);
|
|
817
|
-
assert.match(RecordingSession.created[2].query, /d: reply:d/);
|
|
818
|
-
assert.match(RecordingSession.created[4].query, /e: reply:e/);
|
|
819
|
-
await city.close();
|
|
820
|
-
});
|
|
821
|
-
|
|
822
|
-
test("唯一 auto dispatch 等待并合并并发输入批次", async () => {
|
|
823
|
-
const calls = [];
|
|
824
|
-
const auto_batches = [];
|
|
825
|
-
class DelayedSession extends Session {
|
|
826
|
-
async prompt(input) {
|
|
827
|
-
calls.push(input.query);
|
|
828
|
-
const query = input.query.includes("first") ? "first" : "second";
|
|
829
|
-
const delay_ms = query === "first" ? 5 : 25;
|
|
830
|
-
return {
|
|
831
|
-
id: `turn-${this.id}-${query}`,
|
|
832
|
-
result: null,
|
|
833
|
-
finished: new Promise((resolve) => setTimeout(() => resolve({
|
|
834
|
-
turn_id: `turn-${this.id}-${query}`,
|
|
835
|
-
text: `reply:${query}`,
|
|
836
|
-
success: true,
|
|
837
|
-
}), delay_ms)),
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
const city = new City();
|
|
842
|
-
const agent = new Agent({ id: "batch-agent", session_class: DelayedSession });
|
|
843
|
-
city.agents.add(agent);
|
|
844
|
-
const group = new Group({
|
|
845
|
-
id: "batch-group",
|
|
846
|
-
members: [agent],
|
|
847
|
-
dispatch_strategy: {
|
|
848
|
-
decide_dispatch: ({ trigger, pending_messages }) => {
|
|
849
|
-
if (trigger === "auto") {
|
|
850
|
-
auto_batches.push(pending_messages.map((message) => message.text));
|
|
851
|
-
return { nodes: [], terminal: true };
|
|
852
|
-
}
|
|
853
|
-
return {
|
|
854
|
-
nodes: [{
|
|
855
|
-
node_id: `user-${pending_messages[0]?.id || "message"}`,
|
|
856
|
-
member_ids: ["batch-agent"],
|
|
857
|
-
response_mode: "single",
|
|
858
|
-
depends_on_node_ids: [],
|
|
859
|
-
instruction: "回复当前消息。",
|
|
860
|
-
}],
|
|
861
|
-
terminal: false,
|
|
862
|
-
};
|
|
863
|
-
},
|
|
864
|
-
},
|
|
865
|
-
});
|
|
866
|
-
city.groups.add(group);
|
|
867
|
-
const group_session = await group.sessions.create();
|
|
868
|
-
await Promise.all([
|
|
869
|
-
group_session.prompt({ query: "first" }),
|
|
870
|
-
group_session.prompt({ query: "second" }),
|
|
871
|
-
]);
|
|
872
|
-
await wait_for_group_idle(group_session, 1500);
|
|
873
|
-
assert.equal(calls.length, 2);
|
|
874
|
-
assert.deepEqual(auto_batches, [["reply:first", "reply:second"]]);
|
|
875
|
-
await city.close();
|
|
876
|
-
});
|
|
877
|
-
|
|
878
|
-
test("成员返回空内容时记录失败且不继续投递下游节点", async () => {
|
|
879
|
-
RecordingSession.created = [];
|
|
880
|
-
class EmptySession extends Session {
|
|
881
|
-
async prompt() {
|
|
882
|
-
RecordingSession.created.push({ agent_id: this.agent_id, query: "architect" });
|
|
883
|
-
return {
|
|
884
|
-
id: `turn-${this.id}`,
|
|
885
|
-
result: null,
|
|
886
|
-
finished: Promise.resolve({ turn_id: `turn-${this.id}`, text: "", success: true }),
|
|
887
|
-
};
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
const city = new City();
|
|
891
|
-
const architect = new Agent({ id: "architect", session_class: EmptySession });
|
|
892
|
-
const reviewer = new Agent({ id: "reviewer", session_class: RecordingSession });
|
|
893
|
-
city.agents.add(architect);
|
|
894
|
-
city.agents.add(reviewer);
|
|
895
|
-
const group = new Group({
|
|
896
|
-
id: "dependency-empty-group",
|
|
897
|
-
members: [architect, reviewer],
|
|
898
|
-
dispatch_strategy: {
|
|
899
|
-
decide_dispatch: ({ trigger }) => trigger === "user"
|
|
900
|
-
? {
|
|
901
|
-
nodes: [
|
|
902
|
-
{ node_id: "architect", member_ids: ["architect"], response_mode: "single", depends_on_node_ids: [], instruction: "先分析。" },
|
|
903
|
-
{ node_id: "reviewer", member_ids: ["reviewer"], response_mode: "single", depends_on_node_ids: ["architect"], instruction: "仅基于分析回复。" },
|
|
904
|
-
],
|
|
905
|
-
terminal: true,
|
|
906
|
-
}
|
|
907
|
-
: { nodes: [], terminal: true },
|
|
908
|
-
},
|
|
909
|
-
});
|
|
910
|
-
city.groups.add(group);
|
|
911
|
-
const group_session = await group.sessions.create();
|
|
912
|
-
await group_session.prompt({ query: "请分析并审查" });
|
|
913
|
-
await wait_for_group_idle(group_session);
|
|
914
|
-
assert.deepEqual(RecordingSession.created.map((entry) => entry.agent_id), ["architect"]);
|
|
915
|
-
assert.deepEqual((await group_session.messages()).map((message) => [message.sender_type, message.text]), [
|
|
916
|
-
["user", "请分析并审查"],
|
|
917
|
-
["system", "architect 执行失败:未生成有效回复"],
|
|
918
|
-
]);
|
|
919
|
-
await city.close();
|
|
920
|
-
});
|
|
921
|
-
|
|
922
|
-
test("auto dispatch 检测重复路由并停止传播", async () => {
|
|
923
|
-
RecordingSession.created = [];
|
|
924
|
-
let auto_calls = 0;
|
|
925
|
-
const city = new City();
|
|
926
|
-
const agent = new Agent({ id: "loop-agent", session_class: RecordingSession });
|
|
927
|
-
city.agents.add(agent);
|
|
928
|
-
const group = new Group({
|
|
929
|
-
id: "loop-group",
|
|
930
|
-
members: [agent],
|
|
931
|
-
dispatch_strategy: {
|
|
932
|
-
decide_dispatch: ({ trigger }) => trigger === "auto"
|
|
933
|
-
? {
|
|
934
|
-
nodes: [{ node_id: "loop", member_ids: ["loop-agent"], response_mode: "single", depends_on_node_ids: [], instruction: "继续回复。" }],
|
|
935
|
-
terminal: false,
|
|
936
|
-
}
|
|
937
|
-
: {
|
|
938
|
-
nodes: [{ node_id: "initial", member_ids: ["loop-agent"], response_mode: "single", depends_on_node_ids: [], instruction: "回复一次。" }],
|
|
939
|
-
terminal: false,
|
|
940
|
-
},
|
|
941
|
-
},
|
|
942
|
-
});
|
|
943
|
-
city.groups.add(group);
|
|
944
|
-
const session = await group.sessions.create();
|
|
945
|
-
const original_messages = await session.messages();
|
|
946
|
-
await session.prompt({ query: "loop" });
|
|
947
|
-
await wait_for_group_idle(session);
|
|
948
|
-
const messages = await session.messages();
|
|
949
|
-
auto_calls = messages.filter((message) => message.sender_type === "agent").length;
|
|
950
|
-
assert.equal(auto_calls, 3);
|
|
951
|
-
assert.match(messages.at(-1).text, /repeated path/);
|
|
952
|
-
assert.equal(original_messages.length, 0);
|
|
953
|
-
await city.close();
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
test("GroupSession stop 会停止正在执行的成员,但已写入的 prompt 保留", async () => {
|
|
957
|
-
const finished = [];
|
|
958
|
-
class StoppableSession extends Session {
|
|
959
|
-
async prompt(input) {
|
|
960
|
-
finished.push(input.query);
|
|
961
|
-
return {
|
|
962
|
-
id: `turn-${this.id}`,
|
|
963
|
-
result: null,
|
|
964
|
-
finished: new Promise((resolve) => {
|
|
965
|
-
this.resolve_finished = resolve;
|
|
966
|
-
}),
|
|
967
|
-
};
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
async stop() {
|
|
971
|
-
this.resolve_finished?.({ turn_id: `turn-${this.id}`, text: "", success: false });
|
|
972
|
-
this.resolve_finished = undefined;
|
|
973
|
-
return { stopped: true };
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
const city = new City();
|
|
977
|
-
const agent = new Agent({ id: "stoppable", session_class: StoppableSession });
|
|
978
|
-
city.agents.add(agent);
|
|
979
|
-
const group = new Group({ id: "stoppable-group", members: [agent], dispatch_strategy: test_dispatch_strategy });
|
|
980
|
-
city.groups.add(group);
|
|
981
|
-
const session = await group.sessions.create();
|
|
982
|
-
const first = session.prompt({ query: "first" });
|
|
983
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
984
|
-
const second = session.prompt({ query: "second" });
|
|
985
|
-
await session.stop();
|
|
986
|
-
await Promise.all([first, second]);
|
|
987
|
-
assert.deepEqual(finished.map((query) => query.includes("Current message from user: first")), [true]);
|
|
988
|
-
assert.deepEqual((await session.messages()).filter((message) => message.sender_type === "user").map((message) => message.text), ["first", "second"]);
|
|
989
|
-
await city.close();
|
|
990
|
-
});
|