nolo-cli 0.1.29 → 0.1.31

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.
Files changed (329) hide show
  1. package/agent-runtime/agentRecordConfig.ts +0 -2
  2. package/agent-runtime/hostAdapter.ts +0 -1
  3. package/agent-runtime/hostRuntimeCapabilities.ts +7 -0
  4. package/agent-runtime/hostRuntimeConfig.ts +86 -0
  5. package/agent-runtime/index.ts +13 -0
  6. package/agent-runtime/localToolPolicy.ts +13 -6
  7. package/agent-runtime/localWorkspaceTools.ts +333 -30
  8. package/agent-runtime/platformChatProvider.ts +4 -1
  9. package/agent-runtime/runtimeToolPolicy.ts +32 -47
  10. package/agent-runtime/shellCommandPolicy.ts +117 -0
  11. package/agent-runtime/toolGate.ts +38 -0
  12. package/agentCreateCustomCommands.ts +9 -4
  13. package/agentDialogsCommands.ts +4 -3
  14. package/agentDoctorCommands.ts +3 -3
  15. package/agentListCommands.ts +3 -3
  16. package/agentMachineCommands.ts +6 -6
  17. package/agentPullCommand.ts +4 -12
  18. package/agentRecordCommands.ts +5 -3
  19. package/agentRecordHelpers.ts +42 -23
  20. package/agentRunCommand.ts +2 -6
  21. package/agentRunParsing.ts +18 -5
  22. package/agentRuntimeLocal.ts +10 -0
  23. package/agentUnpublishCommands.ts +3 -2
  24. package/ai/agent/agentRunDialogLineage.ts +56 -0
  25. package/ai/agent/agentSlice.ts +45 -10
  26. package/ai/agent/avatarUtils.ts +1 -1
  27. package/ai/agent/buildSystemPrompt.ts +1 -2
  28. package/ai/agent/cliExecutor.ts +330 -19
  29. package/ai/agent/createAgentSchema.ts +22 -0
  30. package/ai/agent/hooks/fetchPublicAgents.ts +14 -39
  31. package/ai/agent/hooks/usePublicAgents.ts +90 -192
  32. package/ai/agent/publicAgentCatalog.ts +359 -0
  33. package/ai/agent/publicAgentIdentity.ts +76 -0
  34. package/ai/agent/server/fetchPublicAgents.ts +21 -46
  35. package/ai/agent/serverOrigin.ts +7 -0
  36. package/ai/agent/streamAgentChatTurn.ts +23 -21
  37. package/ai/agent/streamAgentChatTurnUtils.ts +292 -6
  38. package/ai/agent/types.ts +2 -0
  39. package/ai/agent/web/agentDisplayUtils.ts +171 -0
  40. package/ai/agent/web/useAgentModelAvatarComponent.ts +32 -0
  41. package/ai/ai.locale.ts +8 -0
  42. package/ai/chat/sendOpenAICompletionsRequest.native.ts +15 -0
  43. package/ai/chat/sendOpenAICompletionsRequest.ts +93 -1
  44. package/ai/chat/sendOpenAIResponseRequest.ts +86 -9
  45. package/ai/chat/updateTotalUsage.ts +7 -0
  46. package/ai/llm/deepinfra.ts +30 -15
  47. package/ai/llm/mistral.ts +3 -4
  48. package/ai/llm/providers.ts +2 -0
  49. package/ai/llm/types.ts +15 -0
  50. package/ai/memory/capture.ts +3 -3
  51. package/ai/memory/consolidate.ts +2 -2
  52. package/ai/memory/delete.ts +4 -3
  53. package/ai/memory/query.ts +3 -3
  54. package/ai/memory/remember.ts +2 -2
  55. package/ai/memory/store.ts +3 -3
  56. package/ai/memory/storeShared.ts +3 -2
  57. package/ai/policy/commercialMultiplier.ts +16 -0
  58. package/ai/token/billingAdminAuditEvent.ts +68 -0
  59. package/ai/token/billingAdminAuditEventWriter.ts +41 -0
  60. package/ai/token/billingAnomaly.ts +90 -0
  61. package/ai/token/billingAnomalyLifecycle.ts +54 -0
  62. package/ai/token/billingAnomalyLifecycleWriter.ts +44 -0
  63. package/ai/token/billingAnomalyWriter.ts +41 -0
  64. package/ai/token/calculatePrice.ts +3 -2
  65. package/ai/token/deepinfraReconciliation.ts +153 -0
  66. package/ai/token/deepinfraRequestIdQuery.ts +92 -0
  67. package/ai/token/externalToolCost.ts +54 -41
  68. package/ai/token/missingUsageEstimate.ts +12 -3
  69. package/ai/token/normalizeUsage.ts +45 -5
  70. package/ai/token/openaiReconciliation.ts +188 -0
  71. package/ai/token/providerBillableEvent.ts +84 -0
  72. package/ai/token/providerBillableEventWriter.ts +36 -0
  73. package/ai/token/providerBillingAnomalyDrilldown.ts +308 -0
  74. package/ai/token/providerBillingDrilldown.ts +361 -0
  75. package/ai/token/providerBillingHealthReport.ts +366 -0
  76. package/ai/token/providerCall.ts +144 -0
  77. package/ai/token/providerCallSweeper.ts +168 -0
  78. package/ai/token/providerCallWriter.ts +33 -0
  79. package/ai/token/providerCredential.ts +89 -0
  80. package/ai/token/providerCredentialAnomaly.ts +154 -0
  81. package/ai/token/providerCredentialLifecycle.ts +59 -0
  82. package/ai/token/providerCredentialLifecycleWriter.ts +44 -0
  83. package/ai/token/providerCredentialRegistry.ts +83 -0
  84. package/ai/token/providerCredentialRegistryCommand.ts +97 -0
  85. package/ai/token/providerCredentialRegistryList.ts +124 -0
  86. package/ai/token/providerCredentialRegistryResolver.ts +150 -0
  87. package/ai/token/providerCredentialRegistryWriter.ts +41 -0
  88. package/ai/token/providerCredentialRotationCommand.ts +102 -0
  89. package/ai/token/providerCredentialRuntime.ts +56 -0
  90. package/ai/token/providerDispatchIntent.ts +67 -0
  91. package/ai/token/providerDispatchIntentWriter.ts +36 -0
  92. package/ai/token/providerGateway.ts +260 -0
  93. package/ai/token/providerReconciliation.ts +148 -0
  94. package/ai/token/providerReconciliationLocal.ts +97 -0
  95. package/ai/token/providerReconciliationRunner.ts +165 -0
  96. package/ai/token/providerReconciliationWriter.ts +41 -0
  97. package/ai/token/ratingResult.ts +202 -0
  98. package/ai/token/ratingResultWriter.ts +33 -0
  99. package/ai/token/serverDialogProjection.ts +5 -3
  100. package/ai/token/serverTokenWriter.ts +11 -3
  101. package/ai/token/types.ts +10 -0
  102. package/ai/tools/agent/callAgentTool.ts +3 -4
  103. package/ai/tools/agent/presets/appBuilderPreset.ts +5 -7
  104. package/ai/tools/agent/runStreamingAgentTool.ts +1 -2
  105. package/ai/tools/agent/streamParallelAgentsTool.ts +2 -3
  106. package/ai/tools/readXPostTool.ts +1 -5
  107. package/app/admin/adminPages.ts +9 -0
  108. package/app/i18n/i18n.config.ts +5 -0
  109. package/app/i18n/translations/pricing.locale.ts +397 -0
  110. package/app/utils/desktopAgentRuntimeStatusClient.ts +5 -4
  111. package/app/utils/desktopAgentRuntimeTurnClient.ts +4 -1
  112. package/app/utils/imageUtils.ts +64 -34
  113. package/auth/adminPermissions.ts +18 -0
  114. package/auth/authSlice.ts +26 -12
  115. package/auth/hooks/useFetchUsers.ts +3 -0
  116. package/auth/routes.ts +46 -0
  117. package/auth/server/accessActivity.ts +4 -3
  118. package/auth/server/adminPermissions.ts +43 -0
  119. package/auth/server/adminUsageReport.ts +375 -0
  120. package/auth/server/billingAnomalies.ts +235 -0
  121. package/auth/server/billingUsageReport.ts +41 -2
  122. package/auth/server/creatorEarningCreditConversion.ts +10 -2
  123. package/auth/server/deduct.ts +14 -7
  124. package/auth/server/delete.ts +10 -2
  125. package/auth/server/disable.ts +4 -3
  126. package/auth/server/emailAutomation.ts +7 -5
  127. package/auth/server/emailDbConfig.ts +4 -2
  128. package/auth/server/emailDelivery.ts +24 -20
  129. package/auth/server/emailDeliveryGuards.ts +10 -7
  130. package/auth/server/emailPreferences.ts +6 -4
  131. package/auth/server/emailReport.ts +6 -4
  132. package/auth/server/emailRuntimeConfig.ts +3 -3
  133. package/auth/server/emailScenarioNotifications.ts +9 -8
  134. package/auth/server/enable.ts +4 -3
  135. package/auth/server/getRechargeHistory.ts +3 -2
  136. package/auth/server/getUser.ts +3 -2
  137. package/auth/server/gptProAccess.ts +44 -0
  138. package/auth/server/inviteReward.ts +10 -7
  139. package/auth/server/listusers.ts +6 -4
  140. package/auth/server/login.ts +2 -2
  141. package/auth/server/productEntitlements.ts +7 -4
  142. package/auth/server/productPurchase.ts +10 -2
  143. package/auth/server/providerBillingDrilldown.ts +47 -0
  144. package/auth/server/providerBillingHealth.ts +71 -0
  145. package/auth/server/providerCredentials.ts +136 -0
  146. package/auth/server/recharge.ts +14 -8
  147. package/auth/server/revokeSessions.ts +4 -3
  148. package/auth/server/route.ts +77 -0
  149. package/auth/server/sendEmail.ts +5 -4
  150. package/auth/server/signup.ts +10 -3
  151. package/auth/server/token.ts +53 -55
  152. package/auth/server/tokenUsageBilling.ts +18 -7
  153. package/auth/server/usageManagementAccess.ts +43 -0
  154. package/auth/server/usageReport.ts +59 -0
  155. package/auth/types.ts +12 -0
  156. package/auth/utils.ts +24 -22
  157. package/authCommands.ts +36 -2
  158. package/buildPublish.ts +3 -1
  159. package/buildPublishArtifactAssembly.ts +62 -1
  160. package/buildPublishImportAnalysis.ts +21 -16
  161. package/chat/dialog/dialogLaunchScope.ts +32 -0
  162. package/chat/dialog/objectAssistantRegistry.ts +2 -2
  163. package/chat/dialog/useCreateDialog.ts +1 -1
  164. package/chat/hooks/useChatInput.ts +41 -10
  165. package/chat/messages/messageSlice.ts +5 -1
  166. package/chat/messages/pendingAttachmentParts.ts +28 -2
  167. package/chat/messages/sendFirstMessage.ts +76 -79
  168. package/chat/messages/types.ts +9 -0
  169. package/chat/messages/web/streamingMarkdownModel.ts +41 -0
  170. package/chat/messages/web/useStreamingReveal.ts +91 -0
  171. package/chat/web/messageInputAgentUi.ts +94 -6
  172. package/cliEnvHelpers.ts +68 -13
  173. package/cliRuntimeDoctorReport.ts +193 -0
  174. package/client/agentConfigResolver.test.ts +0 -2
  175. package/client/agentRun.test.ts +171 -10
  176. package/client/agentRun.ts +44 -637
  177. package/client/agentRunInput.ts +10 -0
  178. package/client/agentRunLocalExecutor.ts +179 -0
  179. package/client/agentRunServerTransport.ts +394 -0
  180. package/client/agentRunTaskRunRecorder.ts +176 -0
  181. package/client/localRuntimeAdapter.test.ts +236 -9
  182. package/client/localRuntimeAdapter.ts +221 -23
  183. package/client/localToolPolicy.test.ts +28 -4
  184. package/connector-experimental/daemonLauncher.ts +38 -4
  185. package/connectorRunArtifact.ts +34 -10
  186. package/connectorWebSocketTarget.ts +40 -15
  187. package/core/builtinAgents.ts +155 -11
  188. package/create/space/contentLabels.ts +1 -1
  189. package/create/space/contentTypeMeta.ts +3 -2
  190. package/create/space/sidebarVisibleTypes.ts +27 -0
  191. package/create/space/space.locale.ts +76 -4
  192. package/database/actions/agentReadResolution.ts +2 -8
  193. package/database/actions/read.ts +11 -9
  194. package/database/actions/readAndWait.ts +10 -5
  195. package/database/server/agentDelegation.ts +3 -2
  196. package/database/server/authorityStoreConformance.ts +209 -0
  197. package/database/server/authorityStoreTypes.ts +31 -0
  198. package/database/server/coreDataProxy.ts +1 -1
  199. package/database/server/dataHandlers.ts +13 -5
  200. package/database/server/db.ts +15 -34
  201. package/database/server/delete.ts +88 -71
  202. package/database/server/emailRepository.ts +11 -9
  203. package/database/server/fileService.ts +2 -1
  204. package/database/server/legacyServerDb.ts +58 -0
  205. package/database/server/levelAuthorityStore.ts +75 -0
  206. package/database/server/memoryAuthorityStore.ts +133 -0
  207. package/database/server/patch.ts +13 -12
  208. package/database/server/query.ts +3 -2
  209. package/database/server/read.ts +33 -30
  210. package/database/server/resourceAccess.ts +7 -5
  211. package/database/server/serverStoreFactory.ts +124 -0
  212. package/database/server/spaceMemberAuthority.ts +3 -2
  213. package/database/server/storeBatchCompat.ts +37 -0
  214. package/database/server/testAuthorityStore.ts +76 -0
  215. package/database/server/write.ts +29 -27
  216. package/dialogReadCommands.ts +2 -1
  217. package/dialogStatusCommands.ts +2 -1
  218. package/integrations/anthropic/anthropicModels.ts +12 -12
  219. package/integrations/deepseek/models.ts +67 -67
  220. package/integrations/google/models.ts +111 -53
  221. package/integrations/openai/models.ts +22 -22
  222. package/integrations/xai/models.ts +1 -1
  223. package/localRuntimeDb.ts +39 -2
  224. package/machineCommandPrompts.ts +2 -0
  225. package/machineCommands.ts +193 -62
  226. package/machineStatusCommands.ts +4 -12
  227. package/machineWsRunDispatch.ts +80 -15
  228. package/machineWsSession.ts +46 -2
  229. package/noloReadBridgePrompt.ts +16 -0
  230. package/package.json +114 -21
  231. package/pageCreateCommands.ts +2 -2
  232. package/pageDeleteCommands.ts +3 -3
  233. package/pageReadCommands.ts +3 -3
  234. package/pageUpdateCommands.ts +3 -3
  235. package/render/layout/mainLayoutViewMode.ts +25 -0
  236. package/render/page/server/createPage.ts +3 -1
  237. package/render/page/server/handleCreatePage.ts +2 -11
  238. package/runtimeDoctorCommands.ts +18 -69
  239. package/server/api/methods.ts +34 -12
  240. package/server/api/tableHandlers.ts +6 -3
  241. package/server/authenticateToken.ts +47 -2
  242. package/server/billingLedgerRoutes.ts +15 -0
  243. package/server/buildManifest.ts +54 -0
  244. package/server/coreReadiness.ts +34 -25
  245. package/server/coreRuntime.ts +15 -10
  246. package/server/handlers/activityStatsHandler.ts +5 -2
  247. package/server/handlers/agentEmailRegistrationE2EHandler.ts +25 -23
  248. package/server/handlers/agentRun/agentLookup.ts +1 -7
  249. package/server/handlers/agentRun/autonomousRuntime.ts +11 -10
  250. package/server/handlers/agentRun/builtinAgents.ts +12 -88
  251. package/server/handlers/agentRun/continueDialogContext.ts +15 -3
  252. package/server/handlers/agentRun/{inheritedDialogPrompt.ts → conversationReference.ts} +3 -3
  253. package/server/handlers/agentRun/dialogLookup.ts +4 -3
  254. package/server/handlers/agentRun/index.ts +864 -404
  255. package/server/handlers/agentRun/localRuntimeBootstrap.ts +17 -1
  256. package/server/handlers/agentRun/loop.ts +920 -508
  257. package/server/handlers/agentRun/machineConnector.ts +56 -8
  258. package/server/handlers/agentRun/machineRunAudit.ts +3 -2
  259. package/server/handlers/agentRun/modelUsageToolHandlers.ts +13 -10
  260. package/server/handlers/agentRun/requestContext.ts +12 -8
  261. package/server/handlers/agentRun/runtimeExecutionContext.ts +15 -3
  262. package/server/handlers/agentRun/runtimePreparation.ts +26 -24
  263. package/server/handlers/agentRun/runtimeRouting.ts +25 -40
  264. package/server/handlers/agentRun/runtimeSystemMessages.ts +65 -0
  265. package/server/handlers/agentRun/saveDialog.ts +97 -87
  266. package/server/handlers/agentRun/taskRunToolHandler.ts +9 -7
  267. package/server/handlers/agentRun/toolExecutor.ts +42 -78
  268. package/server/handlers/agentRun/types.ts +2 -1
  269. package/server/handlers/appDeployStatusStore.ts +17 -10
  270. package/server/handlers/appDomainHandler.ts +21 -15
  271. package/server/handlers/appLegacyInfraCleanup.ts +5 -2
  272. package/server/handlers/appSandboxHandler.ts +29 -8
  273. package/server/handlers/appSpaceAccess.ts +15 -8
  274. package/server/handlers/chatHandler.ts +22 -2
  275. package/server/handlers/chatUpstreamRetry.ts +225 -2
  276. package/server/handlers/connector/connectorConnectionRegistry.ts +55 -7
  277. package/server/handlers/connector/connectorWebSocket.ts +14 -10
  278. package/server/handlers/desktopAgentRuntimeAdapter.ts +4 -4
  279. package/server/handlers/desktopAgentRuntimeHostCapabilities.ts +25 -0
  280. package/server/handlers/desktopAgentRuntimeReadiness.ts +62 -0
  281. package/server/handlers/desktopAgentRuntimeStatusHandler.ts +38 -30
  282. package/server/handlers/desktopAgentRuntimeTurnHandler.ts +7 -3
  283. package/server/handlers/desktopAgentRuntimeTurnService.ts +39 -45
  284. package/server/handlers/desktopLlamaRuntimeHandler.ts +85 -51
  285. package/server/handlers/desktopUpdaterHandler.ts +132 -24
  286. package/server/handlers/favoriteHandlers.ts +8 -2
  287. package/server/handlers/getDialogBillingHandler.ts +4 -3
  288. package/server/handlers/getTransactionsHandler.ts +5 -2
  289. package/server/handlers/machines/machineBinding.ts +1 -0
  290. package/server/handlers/machines/machineHandlers.ts +0 -14
  291. package/server/handlers/machines/machineInstallAssets.ts +4 -2
  292. package/server/handlers/notificationEmitter.ts +5 -3
  293. package/server/handlers/notificationsHandler.ts +5 -2
  294. package/server/handlers/providerCallsRecentHandler.ts +234 -0
  295. package/server/handlers/providerReconciliationRunHandler.ts +180 -0
  296. package/server/handlers/providerRequestIdsHandler.ts +105 -0
  297. package/server/handlers/tableAccess.ts +6 -2
  298. package/server/handlers/tableToolHandlers.ts +28 -14
  299. package/server/handlers/userSecretsHandler.ts +17 -6
  300. package/server/handlers/versionHandler.ts +9 -4
  301. package/server/handlers/versionStore.ts +18 -10
  302. package/server/html/ssrPreload.ts +5 -3
  303. package/server/payments/crypto/cryptoUsdcBasePaymentProvider.ts +11 -8
  304. package/server/payments/crypto/cryptoUsdcBaseScanner.ts +12 -7
  305. package/server/payments/crypto/cryptoUsdtTronPaymentProvider.ts +11 -8
  306. package/server/payments/crypto/cryptoUsdtTronScanner.ts +9 -7
  307. package/server/payments/waffo/waffoPaymentProvider.ts +12 -9
  308. package/server/runtimeRole.ts +15 -0
  309. package/server/scheduler/scheduledTaskRuntime.ts +4 -2
  310. package/server/scheduler/schedulerService.ts +2 -2
  311. package/server/taskRunBridgeRoutes.ts +8 -5
  312. package/share/server/fetchCommunityShares.ts +1 -1
  313. package/share/server/helpers.ts +19 -17
  314. package/share/server/importShare.ts +9 -13
  315. package/share/server/listCommunityShares.ts +4 -4
  316. package/share/server/purchaseDoc.ts +8 -16
  317. package/share/server/readCommunityShareCover.ts +3 -2
  318. package/share/server/readSharedTable.ts +14 -13
  319. package/share/server/tableReplication.ts +42 -39
  320. package/spaceAttachCommands.ts +135 -0
  321. package/spaceCategoryCommands.ts +6 -6
  322. package/spaceCommands.ts +3 -3
  323. package/spaceDeleteCommands.ts +2 -2
  324. package/spaceInternalCommandEntries.ts +2 -0
  325. package/spaceReadCommands.ts +3 -3
  326. package/tableMetaCommands.ts +2 -2
  327. package/taskRunCommand.ts +11 -0
  328. package/ai/agent/runtimeServerBase.ts +0 -37
  329. package/server/handlers/desktopAgentRuntimeHostFacts.ts +0 -40
@@ -1,10 +1,11 @@
1
1
  // packages/server/handlers/agentRun/saveDialog.ts
2
2
  // 将 agentRun 执行结果持久化为真实 Dialog(含完整消息轨迹),所有调用方含 localhost。
3
3
 
4
- import { formatISO } from "date-fns";
5
- import { monotonicFactory } from "ulid";
6
- import serverDb from "../../../database/server/db";
7
- import { createKey, createDialogKey, createDialogMessageKeyAndId } from "../../../database/keys";
4
+ import { formatISO } from "date-fns";
5
+ import { monotonicFactory } from "ulid";
6
+ import { getServerAuthorityStore } from "../../../database/server/db";
7
+ import { writeStoreOps } from "../../../database/server/storeBatchCompat";
8
+ import { createKey, createDialogKey, createDialogMessageKeyAndId } from "../../../database/keys";
8
9
  import { extractCustomId } from "../../../core/prefix";
9
10
  import { DataType } from "../../../create/types";
10
11
  import { createSpaceKey } from "../../../create/space/spaceKeys";
@@ -29,24 +30,27 @@ import type {
29
30
  } from "../../../app/types";
30
31
  import { buildDialogRuntimeBinding } from "./runtimeBinding";
31
32
  import type { AgentRunRuntimeContext } from "./types";
33
+
34
+ const getSaveDialogStore = () => getServerAuthorityStore();
32
35
 
33
36
  /**
34
37
  * 将 Dialog 注册到 Space 的 contents 中,使其在侧边栏可见。
35
38
  * 如果 spaceId 不存在或 space 记录读不到,静默跳过。
36
39
  */
37
- async function addDialogToSpace(
38
- spaceId: string,
39
- dialogKey: string,
40
- title: string,
41
- categoryId?: string
42
- ): Promise<void> {
43
- const spaceKey = createSpaceKey.space(spaceId);
44
- let spaceData: any;
45
- try {
46
- spaceData = await serverDb.get(spaceKey);
47
- } catch (_) {
48
- return; // space 不存在,跳过
49
- }
40
+ async function addDialogToSpace(
41
+ spaceId: string,
42
+ dialogKey: string,
43
+ title: string,
44
+ categoryId?: string
45
+ ): Promise<void> {
46
+ const db = getSaveDialogStore();
47
+ const spaceKey = createSpaceKey.space(spaceId);
48
+ let spaceData: any;
49
+ try {
50
+ spaceData = await db.get(spaceKey);
51
+ } catch (_) {
52
+ return; // space 不存在,跳过
53
+ }
50
54
  if (!spaceData) return;
51
55
  const existingContent = spaceData?.contents?.[dialogKey];
52
56
  if (
@@ -73,23 +77,24 @@ async function addDialogToSpace(
73
77
  if (categoryId) {
74
78
  nextContent.categoryId = categoryId;
75
79
  }
76
- await serverDb.put(spaceKey, {
77
- ...spaceData,
78
- updatedAt: now,
79
- contents: {
80
+ await db.put(spaceKey, {
81
+ ...spaceData,
82
+ updatedAt: now,
83
+ contents: {
80
84
  ...(spaceData.contents ?? {}),
81
85
  [dialogKey]: nextContent,
82
86
  },
83
87
  });
84
88
  }
85
89
 
86
- async function resolveSpaceName(spaceId?: string): Promise<string | undefined> {
87
- if (!spaceId) return undefined;
88
- try {
89
- const space = await serverDb.get(createSpaceKey.space(spaceId));
90
- if (typeof space?.name === "string" && space.name.trim()) {
91
- return space.name;
92
- }
90
+ async function resolveSpaceName(spaceId?: string): Promise<string | undefined> {
91
+ if (!spaceId) return undefined;
92
+ const db = getSaveDialogStore();
93
+ try {
94
+ const space = await db.get(createSpaceKey.space(spaceId));
95
+ if (typeof space?.name === "string" && space.name.trim()) {
96
+ return space.name;
97
+ }
93
98
  } catch (_) { }
94
99
  return undefined;
95
100
  }
@@ -539,17 +544,17 @@ function parseUiAskChoiceContent(rawContent: unknown): {
539
544
  };
540
545
  }
541
546
 
542
- async function findRecentUiAskChoiceSelection(opts: {
543
- dialogId: string;
544
- userInput: string;
545
- }): Promise<UiAskChoiceSelection | null> {
547
+ async function findRecentUiAskChoiceSelection(opts: {
548
+ dialogId: string;
549
+ userInput: string;
550
+ }): Promise<UiAskChoiceSelection | null> {
546
551
  const normalizedUserInput = opts.userInput.trim();
547
552
  if (!normalizedUserInput) return null;
548
553
 
549
- const previousMessages = await fetchMessages(serverDb, opts.dialogId, {
550
- limit: 12,
551
- throwOnError: true,
552
- });
554
+ const previousMessages = await fetchMessages(getSaveDialogStore(), opts.dialogId, {
555
+ limit: 12,
556
+ throwOnError: true,
557
+ });
553
558
 
554
559
  for (const message of previousMessages) {
555
560
  if (message.role !== "tool") continue;
@@ -609,11 +614,12 @@ async function buildDialogLineageFields(opts: {
609
614
  ? { parentDialogId: explicitParentDialogId, rootDialogId: explicitParentDialogId }
610
615
  : {};
611
616
  }
612
-
617
+
613
618
  let inheritedFromDialogTitle: string | undefined;
614
619
  let parentDialog: any;
620
+ const db = getSaveDialogStore();
615
621
  try {
616
- parentDialog = await serverDb.get(inheritedFromDialogKey);
622
+ parentDialog = await db.get(inheritedFromDialogKey);
617
623
  if (typeof parentDialog?.title === "string" && parentDialog.title.trim()) {
618
624
  inheritedFromDialogTitle = parentDialog.title.trim();
619
625
  }
@@ -638,7 +644,7 @@ async function buildDialogLineageFields(opts: {
638
644
  /**
639
645
  * 立即写入 status=pending 的 Dialog 骨架,供 background 模式先返回 dialogId。
640
646
  */
641
- export async function createPendingDialog(opts: {
647
+ export async function createPendingDialog(opts: {
642
648
  agentKey: string;
643
649
  userId: string | null;
644
650
  callerType: "jwt" | "localhost";
@@ -681,14 +687,15 @@ export async function createPendingDialog(opts: {
681
687
  runtimeToolPolicySnapshot: opts.runtimeToolPolicySnapshot,
682
688
  workspaceLease: opts.workspaceLease,
683
689
  });
684
- const dialogTags = mergeDialogTags(undefined, [
685
- `trigger:${triggerType}`,
686
- "mode:background",
687
- ]);
688
-
689
- await serverDb.put(dialogKey, {
690
- id: dialogId,
691
- dbKey: dialogKey,
690
+ const dialogTags = mergeDialogTags(undefined, [
691
+ `trigger:${triggerType}`,
692
+ "mode:background",
693
+ ]);
694
+ const db = getSaveDialogStore();
695
+
696
+ await db.put(dialogKey, {
697
+ id: dialogId,
698
+ dbKey: dialogKey,
692
699
  type: DataType.DIALOG,
693
700
  cybots: [agentKey],
694
701
  primaryAgentKey: agentKey,
@@ -708,11 +715,11 @@ export async function createPendingDialog(opts: {
708
715
  ...(dialogTags ? { tags: dialogTags } : {}),
709
716
  });
710
717
 
711
- // 先写用户消息(在执行前就可见)
712
- const userMsgInfo = createDialogMessageKeyAndId(dialogId);
713
- await serverDb.put(userMsgInfo.key, {
714
- id: userMsgInfo.messageId,
715
- dbKey: userMsgInfo.key,
718
+ // 先写用户消息(在执行前就可见)
719
+ const userMsgInfo = createDialogMessageKeyAndId(dialogId);
720
+ await db.put(userMsgInfo.key, {
721
+ id: userMsgInfo.messageId,
722
+ dbKey: userMsgInfo.key,
716
723
  role: "user",
717
724
  content: userInput,
718
725
  userId: effectiveUserId,
@@ -753,13 +760,14 @@ export async function finalizeDialog(opts: {
753
760
  }): Promise<void> {
754
761
  const { dialogId, dialogKey, agentKey, result, startedAt, status = "done" } = opts;
755
762
  const defaultTraceAgentKey = opts.traceAgentKey ?? agentKey;
756
- const now = Date.now();
757
- const nowIso = formatISO(new Date(now));
758
- const durationMs = now - startedAt;
759
-
760
- // 更新 Dialog 元信息
761
- let existing: any = {};
762
- try { existing = await serverDb.get(dialogKey); } catch (_) { }
763
+ const now = Date.now();
764
+ const nowIso = formatISO(new Date(now));
765
+ const durationMs = now - startedAt;
766
+ const db = getSaveDialogStore();
767
+
768
+ // 更新 Dialog 元信息
769
+ let existing: any = {};
770
+ try { existing = await db.get(dialogKey); } catch (_) { }
763
771
  const effectiveUserId = extractDialogUserId(dialogKey, dialogId) ?? existing.userId ?? null;
764
772
  const effectiveSpaceId = existing.spaceId;
765
773
  const runtimeBinding = buildDialogRuntimeBinding({
@@ -810,7 +818,7 @@ export async function finalizeDialog(opts: {
810
818
  }
811
819
  const toolTraceFacts = buildToolTraceFacts({ trace, toolCallIdToName });
812
820
 
813
- await serverDb.put(dialogKey, {
821
+ await db.put(dialogKey, {
814
822
  ...existing,
815
823
  primaryAgentKey: existing.primaryAgentKey ?? agentKey,
816
824
  ...(taskLabel ? { taskLabel } : {}),
@@ -838,7 +846,7 @@ export async function finalizeDialog(opts: {
838
846
  ? toolCallIdToName.get((msg as any).tool_call_id)
839
847
  : undefined;
840
848
 
841
- await serverDb.put(info.key, buildPersistedTraceMessage({
849
+ await db.put(info.key, buildPersistedTraceMessage({
842
850
  info,
843
851
  msg,
844
852
  nowIso,
@@ -866,8 +874,8 @@ export async function finalizeDialog(opts: {
866
874
  })
867
875
  : undefined;
868
876
  if (runtimeCheckpoint) {
869
- await serverDb.put(dialogKey, {
870
- ...(await serverDb.get(dialogKey).catch(() => ({}))),
877
+ await db.put(dialogKey, {
878
+ ...(await db.get(dialogKey).catch(() => ({}))),
871
879
  toolCallCount: runtimeCheckpoint.toolCallCount,
872
880
  runtimeCheckpoint,
873
881
  });
@@ -892,10 +900,10 @@ export async function finalizeDialog(opts: {
892
900
  dialogId,
893
901
  userInput: opts.userInput,
894
902
  });
895
- await captureUnderstandingMemoryFromDialog({
896
- db: serverDb,
897
- userId: opts.userId ?? null,
898
- spaceId: opts.spaceId ?? effectiveSpaceId,
903
+ await captureUnderstandingMemoryFromDialog({
904
+ db,
905
+ userId: opts.userId ?? null,
906
+ spaceId: opts.spaceId ?? effectiveSpaceId,
899
907
  agentKey,
900
908
  dialogId,
901
909
  userInput: opts.userInput,
@@ -961,12 +969,13 @@ export async function saveRunAsDialog(opts: {
961
969
  runtimeToolPolicySnapshot: opts.runtimeToolPolicySnapshot,
962
970
  workspaceLease: opts.workspaceLease,
963
971
  });
964
- const dialogTags = mergeDialogTags(undefined, [
965
- `trigger:${triggerType}`,
966
- "mode:foreground",
967
- ]);
968
-
969
- // 使用单调递增 ULID 工厂保证 user + trace 消息的 key 顺序 == 写入/逻辑顺序
972
+ const dialogTags = mergeDialogTags(undefined, [
973
+ `trigger:${triggerType}`,
974
+ "mode:foreground",
975
+ ]);
976
+ const db = getSaveDialogStore();
977
+
978
+ // 使用单调递增 ULID 工厂保证 user + trace 消息的 key 顺序 == 写入/逻辑顺序
970
979
  const mono = monotonicFactory();
971
980
 
972
981
  const userMsgInfo = createDialogMessageKeyAndId(dialogId, mono);
@@ -1067,7 +1076,7 @@ export async function saveRunAsDialog(opts: {
1067
1076
  previousRuntimeCheckpoint: undefined,
1068
1077
  });
1069
1078
 
1070
- await serverDb.batch(ops);
1079
+ await writeStoreOps(db, ops);
1071
1080
 
1072
1081
  // 绑定到 Space(使 Dialog 在侧边栏可见)
1073
1082
  // 同步模式直接推 dialog.done,让前端直接跳过 running 状态
@@ -1100,10 +1109,10 @@ export async function saveRunAsDialog(opts: {
1100
1109
  dialogId,
1101
1110
  userInput,
1102
1111
  });
1103
- await captureUnderstandingMemoryFromDialog({
1104
- db: serverDb,
1105
- userId,
1106
- spaceId,
1112
+ await captureUnderstandingMemoryFromDialog({
1113
+ db,
1114
+ userId,
1115
+ spaceId,
1107
1116
  agentKey,
1108
1117
  dialogId,
1109
1118
  userInput,
@@ -1152,7 +1161,8 @@ export async function appendToExistingDialog(opts: {
1152
1161
  const now = Date.now();
1153
1162
  const nowIso = formatISO(new Date(now));
1154
1163
  const defaultTraceAgentKey = traceAgentKey ?? agentKey;
1155
- const fallbackDialogTitle = buildDialogFallbackTitleFromUserInput(userInput);
1164
+ const fallbackDialogTitle = buildDialogFallbackTitleFromUserInput(userInput);
1165
+ const db = getSaveDialogStore();
1156
1166
 
1157
1167
  // 重建 dialogKey(结构:DIALOG-{userId}-{dialogId})
1158
1168
  const dialogKey =
@@ -1163,9 +1173,9 @@ export async function appendToExistingDialog(opts: {
1163
1173
  extractDialogUserId(dialogKey, dialogId) ??
1164
1174
  "server";
1165
1175
 
1166
- // 更新 dialog 元数据(累加 toolCallCount / durationMs)
1167
- let existing: any = null;
1168
- try { existing = await serverDb.get(dialogKey); } catch (_) { }
1176
+ // 更新 dialog 元数据(累加 toolCallCount / durationMs)
1177
+ let existing: any = null;
1178
+ try { existing = await db.get(dialogKey); } catch (_) { }
1169
1179
  const existingDialog =
1170
1180
  existing && typeof existing === "object" ? existing : {};
1171
1181
  const effectiveSpaceId = existingDialog.spaceId ?? spaceId;
@@ -1313,7 +1323,7 @@ export async function appendToExistingDialog(opts: {
1313
1323
  ops[0]!.value.runtimeCheckpoint?.toolCallCount ?? 0,
1314
1324
  );
1315
1325
 
1316
- await serverDb.batch(ops);
1326
+ await writeStoreOps(db, ops);
1317
1327
 
1318
1328
  if (effectiveSpaceId) {
1319
1329
  pushEvent(`space-${effectiveSpaceId}`, { type: "dialog.done", dialogId });
@@ -1337,10 +1347,10 @@ export async function appendToExistingDialog(opts: {
1337
1347
  dialogId,
1338
1348
  userInput,
1339
1349
  });
1340
- await captureUnderstandingMemoryFromDialog({
1341
- db: serverDb,
1342
- userId,
1343
- spaceId: effectiveSpaceId,
1350
+ await captureUnderstandingMemoryFromDialog({
1351
+ db,
1352
+ userId,
1353
+ spaceId: effectiveSpaceId,
1344
1354
  agentKey,
1345
1355
  dialogId,
1346
1356
  userInput,
@@ -1,6 +1,6 @@
1
- import serverDb, { ensureServerDbOpen } from "../../../database/server/db";
1
+ import { ensureServerDbOpen, getServerAuthorityStore } from "../../../database/server/db";
2
2
  import { rowKey } from "../../../database/keys";
3
- import { handleToken } from "../../../auth/server/token";
3
+ import { readUserFromRequest } from "../../../auth/server/token";
4
4
  import { fetchMessages } from "../../../chat/messages/fetchMessages";
5
5
  import {
6
6
  clearTaskRunBlocker,
@@ -131,8 +131,9 @@ function collectDialogIdsFromRow(row: any, meta: any): string[] {
131
131
  }
132
132
 
133
133
  async function summarizeDialogEvidence(dialogId: string, userId: string) {
134
+ const store = getServerAuthorityStore();
134
135
  const dialogKey = `dialog-${userId}-${dialogId}`;
135
- const dialog = await serverDb.get(dialogKey).catch(() => null);
136
+ const dialog = await store.get(dialogKey).catch(() => null);
136
137
  if (!dialog || dialog.deletedAt) {
137
138
  return {
138
139
  dialogId,
@@ -142,7 +143,7 @@ async function summarizeDialogEvidence(dialogId: string, userId: string) {
142
143
  };
143
144
  }
144
145
 
145
- const messages = await fetchMessages(serverDb, dialogId, {
146
+ const messages = await fetchMessages(store, dialogId, {
146
147
  limit: EVIDENCE_DIALOG_LIMIT,
147
148
  });
148
149
  const ordered = [...messages].reverse();
@@ -213,7 +214,7 @@ async function getUserIdFromToken(authToken: string): Promise<string> {
213
214
  name.toLowerCase() === "authorization" ? `Bearer ${authToken}` : null,
214
215
  },
215
216
  };
216
- const user = await handleToken(req, {});
217
+ const user = await readUserFromRequest(req);
217
218
  if (!user?.userId) throw new Error("Unauthorized: userId not found");
218
219
  return user.userId;
219
220
  }
@@ -323,11 +324,12 @@ function ensureSelfWorkItem(args: {
323
324
  export async function runTaskRunToolForUser(args: TaskRunToolArgs, userId: string): Promise<string> {
324
325
  try {
325
326
  await ensureServerDbOpen();
327
+ const store = getServerAuthorityStore();
326
328
  const action = args.action;
327
329
  if (!action) throw new Error("taskRun.action is required.");
328
330
 
329
331
  const rowDbKey = resolveTaskRowDbKey(args);
330
- const row = await serverDb.get(rowDbKey).catch(() => null);
332
+ const row = await store.get(rowDbKey).catch(() => null);
331
333
  if (!row || row.deletedAt) throw new Error(`Task row not found: ${rowDbKey}`);
332
334
  if (row.tenantId !== userId) throw new Error("Forbidden: task row tenant mismatch");
333
335
 
@@ -558,7 +560,7 @@ export async function runTaskRunToolForUser(args: TaskRunToolArgs, userId: strin
558
560
  }
559
561
 
560
562
  const updated = { ...row, meta, updatedAt: now };
561
- await serverDb.put(rowDbKey, updated);
563
+ await store.put(rowDbKey, updated);
562
564
  return json({
563
565
  ok: true,
564
566
  action,
@@ -63,10 +63,9 @@ import {
63
63
  summarizeParallelBudget,
64
64
  summarizeParallelCosts,
65
65
  } from "../../../ai/tools/agent/parallelBudget";
66
- import {
67
- extractAgentRuntimeServerBase,
68
- normalizeServerOrigin,
69
- } from "../../../ai/agent/runtimeServerBase";
66
+ import {
67
+ normalizeServerOrigin,
68
+ } from "../../../ai/agent/serverOrigin";
70
69
  import { extractEmailVerificationArtifacts } from "../../../ai/tools/emailTools";
71
70
  import { convertMarxistsBookToOfflineHtml } from "../../../ai/tools/marxistsOfflineBook";
72
71
  import { formatMarxistsOfflineBookDisplayData } from "../../../ai/tools/convertMarxistsBookTool";
@@ -84,7 +83,7 @@ import {
84
83
  clampDialogSearchNumber,
85
84
  normalizeDialogSearchText,
86
85
  } from "../../../ai/tools/dialogMessageSearch";
87
- import serverDb from "../../../database/server/db";
86
+ import { getServerAuthorityStore } from "../../../database/server/db";
88
87
  import { createSpaceKey } from "../../../create/space/spaceKeys";
89
88
  import {
90
89
  buildDeleteSpacesPreview,
@@ -105,6 +104,8 @@ import {
105
104
  import { runTaskRunTool } from "./taskRunToolHandler";
106
105
  import { projectDialogActivityToSubjectRows } from "./tableActivityProjection";
107
106
  import { resolveExistingDialogRef } from "./dialogLookup";
107
+
108
+ const getToolExecutorStore = () => getServerAuthorityStore();
108
109
 
109
110
  const APP_DEPLOY_POLL_INTERVAL_MS = 250;
110
111
  const APP_DEPLOY_POLL_TIMEOUT_MS = 60_000;
@@ -451,7 +452,7 @@ export const resolveDelegatedServerBase = (
451
452
  };
452
453
  };
453
454
 
454
- export { extractAgentRuntimeServerBase, normalizeServerOrigin };
455
+ export { normalizeServerOrigin };
455
456
 
456
457
  const buildDelegatedAgentInput = (task: string, input: unknown): string => {
457
458
  if (input === undefined || input === null) return task;
@@ -701,10 +702,11 @@ async function buildReferencedDialogEvidenceLines(args: {
701
702
  }
702
703
 
703
704
  async function countDialogMessages(dialogId: string, max = 200): Promise<{ count: number; truncated: boolean }> {
705
+ const store = getToolExecutorStore();
704
706
  let count = 0;
705
707
  const gte = createKey(DataType.DIALOG, dialogId, "msg", "");
706
708
  const lte = createKey(DataType.DIALOG, dialogId, "msg", "\uffff");
707
- for await (const _ of serverDb.iterator({ gte, lte })) {
709
+ for await (const _ of store.iterator({ gte, lte })) {
708
710
  count += 1;
709
711
  if (count > max) return { count: max, truncated: true };
710
712
  }
@@ -1000,45 +1002,14 @@ export async function executeToolOnServer(
1000
1002
  idempotencyKey?: string;
1001
1003
  },
1002
1004
  ) => {
1003
- let effectiveRequestedServerBase = requestedServerBase;
1004
- let autoRouted = false;
1005
- const allowedRemoteServerBases = getAllowedRemoteServerBases();
1006
- if (
1007
- allowedRemoteServerBases.length > 0 &&
1008
- (typeof requestedServerBase !== "string" || !requestedServerBase.trim())
1009
- ) {
1010
- try {
1011
- const res = await fetch(`${mainBase}/api/v1/db/read/${encodeURIComponent(agentKey)}`, {
1012
- headers: buildAuthHeaders(),
1013
- });
1014
- if (res.ok) {
1015
- const raw = await res.json();
1016
- const agentRecord = raw?.data ?? raw;
1017
- const runtimeServerBase = extractAgentRuntimeServerBase(agentRecord);
1018
- const runtimeOrigin = runtimeServerBase
1019
- ? normalizeServerOrigin(runtimeServerBase)
1020
- : null;
1021
- const mainOrigin = normalizeServerOrigin(mainBase);
1022
- if (runtimeOrigin && runtimeOrigin !== mainOrigin) {
1023
- effectiveRequestedServerBase = runtimeOrigin;
1024
- autoRouted = true;
1025
- }
1026
- }
1027
- } catch {
1028
- // Best effort only. If metadata cannot be read, run on the current server.
1029
- }
1030
- }
1031
-
1032
- const target = resolveDelegatedServerBase(effectiveRequestedServerBase, mainBase);
1033
- if (!target.ok) {
1034
- return {
1035
- ok: false as const,
1036
- status: 400,
1037
- error: autoRouted
1038
- ? `${target.error} Target agent declares this runtime serverBase in its delegation metadata.`
1039
- : target.error,
1040
- };
1041
- }
1005
+ const target = resolveDelegatedServerBase(requestedServerBase, mainBase);
1006
+ if (!target.ok) {
1007
+ return {
1008
+ ok: false as const,
1009
+ status: 400,
1010
+ error: target.error,
1011
+ };
1012
+ }
1042
1013
 
1043
1014
  const childRunBase = resolveSameOriginChildRunBase(target.base, mainBase);
1044
1015
  const childSubjectRefs = mergeSubjectRefs(
@@ -1083,14 +1054,11 @@ export async function executeToolOnServer(
1083
1054
  };
1084
1055
  }
1085
1056
  const payload = await res.json();
1086
- return {
1087
- ok: true as const,
1088
- payload,
1089
- ...(typeof effectiveRequestedServerBase === "string" && effectiveRequestedServerBase.trim()
1090
- ? { serverBase: target.base }
1091
- : {}),
1092
- ...(autoRouted ? { autoRouted: true } : {}),
1093
- };
1057
+ return {
1058
+ ok: true as const,
1059
+ payload,
1060
+ serverBase: target.base,
1061
+ };
1094
1062
  };
1095
1063
 
1096
1064
  const waitForAppDeployResult = async (jobId: string) => {
@@ -1469,13 +1437,12 @@ export async function executeToolOnServer(
1469
1437
  });
1470
1438
  }
1471
1439
  const payload = childRun.payload;
1472
- return JSON.stringify({
1473
- success: true,
1474
- agentKey,
1475
- ...(childRun.serverBase ? { serverBase: childRun.serverBase } : {}),
1476
- ...(childRun.autoRouted ? { autoRouted: true } : {}),
1477
- dialogId: payload?.dialogId ?? null,
1478
- model: payload?.model ?? null,
1440
+ return JSON.stringify({
1441
+ success: true,
1442
+ agentKey,
1443
+ ...(childRun.serverBase ? { serverBase: childRun.serverBase } : {}),
1444
+ dialogId: payload?.dialogId ?? null,
1445
+ model: payload?.model ?? null,
1479
1446
  provider: payload?.provider ?? null,
1480
1447
  content: typeof payload?.content === "string" ? payload.content : "",
1481
1448
  usage: payload?.usage ?? null,
@@ -1503,8 +1470,7 @@ export async function executeToolOnServer(
1503
1470
  success: true,
1504
1471
  handoff: true,
1505
1472
  agentKey,
1506
- ...(childRun.serverBase ? { serverBase: childRun.serverBase } : {}),
1507
- ...(childRun.autoRouted ? { autoRouted: true } : {}),
1473
+ ...(childRun.serverBase ? { serverBase: childRun.serverBase } : {}),
1508
1474
  dialogId: payload?.dialogId ?? null,
1509
1475
  ...(payload?.dialogKey ? { dialogKey: payload.dialogKey } : {}),
1510
1476
  model: payload?.model ?? null,
@@ -1587,7 +1553,7 @@ export async function executeToolOnServer(
1587
1553
  : undefined;
1588
1554
  const activityProjection = childDialogId
1589
1555
  ? await projectDialogActivityToSubjectRows({
1590
- db: serverDb,
1556
+ db: getToolExecutorStore(),
1591
1557
  subjectRefs: childSubjectRefs,
1592
1558
  activityRef: {
1593
1559
  type: "dialog",
@@ -1611,7 +1577,6 @@ export async function executeToolOnServer(
1611
1577
  childDialogKey: childDialogKey ?? null,
1612
1578
  ...(parentDialogId ? { parentDialogId } : {}),
1613
1579
  ...(childRun.serverBase ? { serverBase: childRun.serverBase } : {}),
1614
- ...(childRun.autoRouted ? { autoRouted: true } : {}),
1615
1580
  ...(activityProjection && activityProjection.updatedRowDbKeys.length
1616
1581
  ? {
1617
1582
  activityProjection: {
@@ -1709,19 +1674,18 @@ export async function executeToolOnServer(
1709
1674
  : null,
1710
1675
  },
1711
1676
  });
1712
- return {
1713
- ok: true,
1714
- label,
1715
- branchId,
1716
- parallelSessionId,
1717
- parallelIndex: index,
1718
- agentKey,
1719
- agentName: label,
1720
- ...(childRun.serverBase ? { serverBase: childRun.serverBase } : {}),
1721
- ...(childRun.autoRouted ? { autoRouted: true } : {}),
1722
- dialogId: payload?.dialogId ?? null,
1723
- model: payload?.model ?? null,
1724
- provider: payload?.provider ?? null,
1677
+ return {
1678
+ ok: true,
1679
+ label,
1680
+ branchId,
1681
+ parallelSessionId,
1682
+ parallelIndex: index,
1683
+ agentKey,
1684
+ agentName: label,
1685
+ ...(childRun.serverBase ? { serverBase: childRun.serverBase } : {}),
1686
+ dialogId: payload?.dialogId ?? null,
1687
+ model: payload?.model ?? null,
1688
+ provider: payload?.provider ?? null,
1725
1689
  content:
1726
1690
  typeof payload?.content === "string" ? payload.content.trim() : "",
1727
1691
  usage: payload?.usage ?? null,
@@ -35,7 +35,7 @@ export interface AgentRunRequest {
35
35
  };
36
36
  }
37
37
  >;
38
- messages?: ChatMessage[]; // 历史对话,调用方自行管理(不持久化)
38
+ messages?: ChatMessage[]; // 调用方携带的消息历史;continueDialogId 存在时仅作为加载 persisted history 失败时的 fallback
39
39
  runtimeContext?: AgentRunRuntimeContext;
40
40
  stream?: boolean;
41
41
  maxRounds?: number; // 兼容旧客户端保留,服务端当前不再按工具轮次限制
@@ -74,6 +74,7 @@ export interface AgentRunRuntimeContext {
74
74
  export interface LoopResult extends Omit<AgentRuntimeResult, "policyState"> {
75
75
  policyState?: DialogPolicyState;
76
76
  artifacts?: unknown;
77
+ providerCallIds?: string[];
77
78
  }
78
79
 
79
80
  export interface ToolPolicyRuntimeState {