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,3 +1,6 @@
1
+ import { APP_BUILDER_PRESET } from "../ai/tools/agent/presets/appBuilderPreset";
2
+ import { FIREWORKS_KIMI_LATEST_MODEL } from "../ai/llm/kimi";
3
+
1
4
  export const BUILTIN_NOLO_AGENT_KEY = "agent-pub-01NOLOAPPBLD000000019KCKT0";
2
5
  export const BUILTIN_APP_BUILDER_AGENT_KEY =
3
6
  "agent-pub-01APPBUILDER00000001YAII3I";
@@ -5,8 +8,32 @@ export const BUILTIN_ECOMMERCE_AGENT_KEY =
5
8
  "agent-pub-01ECOMMERCEAG00000001PYQ2J";
6
9
  export const BUILTIN_AGENT_CREATOR_AGENT_KEY =
7
10
  "agent-pub-01NOLOAGENTCRT000000000001";
11
+ export const BUILTIN_NOLO_AGENT_ID = "01NOLOAPPBLD000000019KCKT0";
12
+ export const BUILTIN_APP_BUILDER_AGENT_ID = "01APPBUILDER00000001YAII3I";
13
+ export const BUILTIN_ECOMMERCE_AGENT_ID = "01ECOMMERCEAG00000001PYQ2J";
8
14
  export const BUILTIN_AGENT_CREATOR_AGENT_ID = "01NOLOAGENTCRT000000000001";
9
15
 
16
+ const buildBuiltinBaseAgent = (overrides: Record<string, unknown>) => {
17
+ const timestamp = Date.now();
18
+ return {
19
+ type: "agent",
20
+ isPublic: true,
21
+ userId: "builtin",
22
+ createdAt: timestamp,
23
+ updatedAt: timestamp,
24
+ references: [],
25
+ ...overrides,
26
+ };
27
+ };
28
+
29
+ const BUILTIN_NOLO_PROMPT = [
30
+ "你是 nolo,负责帮助刚进入产品的用户理解现在能做什么,并把他们带到合适的下一步。",
31
+ "优先直接回答、解释入口、帮用户开始对话、创建 AI、创建文档,或把任务交给更合适的 agent。",
32
+ "用户只是泛泛提问时,先收敛问题,不要立刻切换到重型流程。",
33
+ "当用户明确要创建自己的 AI 时,先调用 prepareAgentDraft 整理草稿,再在用户明确确认后进入创建流程。",
34
+ "不要调用 createAgent 或 deleteSpaces 这类高风险能力;如果用户要创建 AI,交给 prepareAgentDraft / 专门入口完成。",
35
+ ].join("\n");
36
+
10
37
  export const BUILTIN_AGENT_CREATOR_PROMPT = [
11
38
  "你是 Nolo 的 AI 创建助手,只负责通过对话帮助用户创建或调整一个新的 Agent。",
12
39
  "先理解用户想让这个 AI 服务谁、完成什么任务、使用什么语气、需要哪些能力、是否需要知识引用,以及是否适合公开。",
@@ -20,16 +47,68 @@ export const BUILTIN_AGENT_CREATOR_PROMPT = [
20
47
  "如果用户想手动微调模型、工具、知识引用或发布状态,可以引导用户进入 /create/agent 高级编辑页。",
21
48
  ].join("\n");
22
49
 
50
+ export const buildBuiltinNoloRecord = () =>
51
+ buildBuiltinBaseAgent({
52
+ dbKey: BUILTIN_NOLO_AGENT_KEY,
53
+ id: BUILTIN_NOLO_AGENT_ID,
54
+ name: "nolo",
55
+ introduction:
56
+ "专门用来引导用户理解 Nolo 能做什么,并把问题带到正确入口或更合适的 Agent。",
57
+ greeting:
58
+ "你好,我是 nolo。你可以直接说你想做什么,我会帮你开始、解释入口,或把任务交给更合适的能力。",
59
+ provider: "fireworks",
60
+ model: FIREWORKS_KIMI_LATEST_MODEL,
61
+ useServerProxy: true,
62
+ apiSource: "platform",
63
+ inputPrice: 0.95 * 8,
64
+ outputPrice: 4 * 8,
65
+ hasVision: true,
66
+ tags: ["nolo", "引导", "分发"],
67
+ tools: ["fetchWebpage", "runStreamingAgent", "prepareAgentDraft"],
68
+ prompt: BUILTIN_NOLO_PROMPT,
69
+ });
70
+
71
+ export const buildBuiltinAppBuilderRecord = () =>
72
+ buildBuiltinBaseAgent({
73
+ ...APP_BUILDER_PRESET,
74
+ dbKey: BUILTIN_APP_BUILDER_AGENT_KEY,
75
+ id: BUILTIN_APP_BUILDER_AGENT_ID,
76
+ tags: ["应用构建", "App Builder", "无代码"],
77
+ });
78
+
79
+ export const buildBuiltinEcommerceAgentRecord = () =>
80
+ buildBuiltinBaseAgent({
81
+ dbKey: BUILTIN_ECOMMERCE_AGENT_KEY,
82
+ id: BUILTIN_ECOMMERCE_AGENT_ID,
83
+ name: "电商商品参数助手",
84
+ introduction:
85
+ "专门获取淘宝、天猫、京东等电商商品真实参数、SKU、价格、库存和店铺信息,并做结构化对比。",
86
+ greeting: "发给我淘宝、天猫或京东商品链接,我会尽量获取真实商品参数。",
87
+ provider: "fireworks",
88
+ model: FIREWORKS_KIMI_LATEST_MODEL,
89
+ useServerProxy: true,
90
+ apiSource: "platform",
91
+ inputPrice: 0.95 * 8,
92
+ outputPrice: 4 * 8,
93
+ hasVision: false,
94
+ tags: ["电商", "商品参数", "数据抓取"],
95
+ tools: ["taobaoTmallProductScraper", "jdProductScraper"],
96
+ prompt: [
97
+ "你是电商商品参数助手,只负责获取和整理电商商品真实数据。",
98
+ "当用户给淘宝/天猫链接或商品 ID 时,先提取数字 itemId,再调用 taobaoTmallProductScraper。",
99
+ "当用户给京东链接或 SKU 时,先提取数字 skuId,再调用 jdProductScraper。",
100
+ "输出要结构化:商品标题、品牌、型号、店铺、价格、SKU/规格、库存、尺寸重量、质保、数据来源和缺失项。",
101
+ "用户问参数或详情时,必须展开工具返回的详细参数,不要只摘要基础字段。",
102
+ "只输出用户请求的数据结果;不要输出寒暄、确认、过渡句或结尾追问。",
103
+ "如果用户给多个商品,逐个调用对应工具后再做对比表。",
104
+ "如果工具返回缺失字段,如实说明缺失;不要编造参数,也不要要求用户手抄页面。",
105
+ ].join("\n"),
106
+ });
107
+
23
108
  export const buildBuiltinAgentCreatorRecord = () => {
24
- const timestamp = Date.now();
25
- return {
26
- type: "agent",
109
+ return buildBuiltinBaseAgent({
27
110
  dbKey: BUILTIN_AGENT_CREATOR_AGENT_KEY,
28
111
  id: BUILTIN_AGENT_CREATOR_AGENT_ID,
29
- isPublic: true,
30
- userId: "builtin",
31
- createdAt: timestamp,
32
- updatedAt: timestamp,
33
112
  name: "AI 创建助手",
34
113
  introduction:
35
114
  "通过对话帮你整理专属 AI 的用途、能力、Prompt、知识引用和发布建议,并在确认后创建。",
@@ -39,14 +118,43 @@ export const buildBuiltinAgentCreatorRecord = () => {
39
118
  model: "accounts/fireworks/models/kimi-latest",
40
119
  useServerProxy: true,
41
120
  apiSource: "platform",
42
- runtimeServerBase: "https://nolo.chat",
43
- inputPrice: 7.6,
44
- outputPrice: 32,
121
+ inputPrice: 0.95 * 8,
122
+ outputPrice: 4 * 8,
45
123
  hasVision: false,
46
- references: [],
47
124
  tags: ["AI 创建", "Agent 创建", "配置助手"],
48
125
  tools: ["prepareAgentDraft", "createAgent"],
49
126
  prompt: BUILTIN_AGENT_CREATOR_PROMPT,
127
+ });
128
+ };
129
+
130
+ export const normalizeBuiltinPublicAgentRecord = <T extends Record<string, any>>(
131
+ agent: T
132
+ ): T => {
133
+ if (!agent || typeof agent !== "object") return agent;
134
+ const key = typeof agent.dbKey === "string" ? agent.dbKey : "";
135
+ const id = typeof agent.id === "string" ? agent.id : "";
136
+ const isBuiltinCreator =
137
+ key === BUILTIN_AGENT_CREATOR_AGENT_KEY || id === BUILTIN_AGENT_CREATOR_AGENT_ID;
138
+
139
+ if (!isBuiltinCreator) return agent;
140
+
141
+ const builtin = buildBuiltinAgentCreatorRecord();
142
+ return {
143
+ ...agent,
144
+ name: builtin.name,
145
+ introduction: builtin.introduction,
146
+ greeting: builtin.greeting,
147
+ provider: builtin.provider,
148
+ model: builtin.model,
149
+ useServerProxy: builtin.useServerProxy,
150
+ apiSource: builtin.apiSource,
151
+ inputPrice: builtin.inputPrice,
152
+ outputPrice: builtin.outputPrice,
153
+ hasVision: builtin.hasVision,
154
+ references: builtin.references,
155
+ tags: builtin.tags,
156
+ tools: builtin.tools,
157
+ prompt: builtin.prompt,
50
158
  };
51
159
  };
52
160
 
@@ -56,3 +164,39 @@ export const BUILTIN_PLATFORM_AGENT_KEYS = [
56
164
  BUILTIN_ECOMMERCE_AGENT_KEY,
57
165
  BUILTIN_AGENT_CREATOR_AGENT_KEY,
58
166
  ] as const;
167
+
168
+ const BUILTIN_PLATFORM_AGENT_KEY_SET = new Set<string>(BUILTIN_PLATFORM_AGENT_KEYS);
169
+
170
+ export const isBuiltinPlatformAgentRecord = (agent: {
171
+ dbKey?: string | null;
172
+ id?: string | null;
173
+ }): boolean => {
174
+ const dbKey = typeof agent?.dbKey === "string" ? agent.dbKey : "";
175
+ if (dbKey && BUILTIN_PLATFORM_AGENT_KEY_SET.has(dbKey)) return true;
176
+
177
+ const id = typeof agent?.id === "string" ? agent.id : "";
178
+ if (!id) return false;
179
+
180
+ return BUILTIN_PLATFORM_AGENT_KEYS.some((key) => key.endsWith(id));
181
+ };
182
+
183
+ export const shouldHideBuiltinAgentFromPublicPlaza = (agent: {
184
+ dbKey?: string | null;
185
+ id?: string | null;
186
+ }): boolean => isBuiltinPlatformAgentRecord(agent);
187
+
188
+ export const buildBuiltinPlatformAgentRecord = (dbKey: string) => {
189
+ if (dbKey === BUILTIN_NOLO_AGENT_KEY) {
190
+ return buildBuiltinNoloRecord();
191
+ }
192
+ if (dbKey === BUILTIN_APP_BUILDER_AGENT_KEY) {
193
+ return buildBuiltinAppBuilderRecord();
194
+ }
195
+ if (dbKey === BUILTIN_ECOMMERCE_AGENT_KEY) {
196
+ return buildBuiltinEcommerceAgentRecord();
197
+ }
198
+ if (dbKey === BUILTIN_AGENT_CREATOR_AGENT_KEY) {
199
+ return buildBuiltinAgentCreatorRecord();
200
+ }
201
+ return null;
202
+ };
@@ -15,7 +15,7 @@ export const getFileCategoryLabel = (
15
15
  case "audio":
16
16
  return t("audioAttachment", "音频");
17
17
  default:
18
- return t("attachment", "附件");
18
+ return t("attachment", "其他附件");
19
19
  }
20
20
  };
21
21
 
@@ -127,9 +127,10 @@ export const CONTENT_TYPE_META: Record<SharedContentTypeId, ContentTypeMeta> = {
127
127
  id: "file",
128
128
  icon: LuFile,
129
129
  shortLabelKey: "files",
130
- shortDefaultLabel: "附件",
130
+ shortDefaultLabel: "其他附件",
131
131
  titleKey: "homeTabs.myFiles",
132
- defaultTitle: "我的附件",
132
+ defaultTitle: "我的其他附件",
133
+ sidebarType: "file",
133
134
  },
134
135
  scheduled: {
135
136
  id: "scheduled",
@@ -40,6 +40,21 @@ export const DEFAULT_SIDEBAR_VISIBLE_TYPES: SidebarVisibleType[] = [
40
40
  "app",
41
41
  ];
42
42
 
43
+ export const SPACE_HOME_TOPBAR_VISIBLE_TYPES: SidebarVisibleType[] = [
44
+ "dialog",
45
+ "page",
46
+ "app",
47
+ ];
48
+
49
+ export const SPACE_FILE_TOPBAR_VISIBLE_TYPES: SidebarVisibleType[] = [
50
+ "image",
51
+ "document",
52
+ "video",
53
+ "audio",
54
+ "table",
55
+ "file",
56
+ ];
57
+
43
58
  export const isSidebarVisibleType = (
44
59
  value: string | null | undefined
45
60
  ): value is SidebarVisibleType =>
@@ -141,6 +156,18 @@ export const areSidebarVisibleTypesEqual = (
141
156
  ): boolean =>
142
157
  left.length === right.length && left.every((value, index) => value === right[index]);
143
158
 
159
+ export const pickSidebarVisibleTypes = (
160
+ current: readonly SidebarVisibleType[] | null | undefined,
161
+ allowed: readonly SidebarVisibleType[],
162
+ fallback: readonly SidebarVisibleType[] = allowed
163
+ ): SidebarVisibleType[] => {
164
+ const allowedSet = new Set(allowed);
165
+ const filtered = normalizeSidebarVisibleTypes(current, fallback).filter((type) =>
166
+ allowedSet.has(type)
167
+ );
168
+ return filtered.length > 0 ? filtered : [...fallback];
169
+ };
170
+
144
171
  export const isAllSidebarVisibleTypesSelected = (
145
172
  visibleTypes: readonly SidebarVisibleType[]
146
173
  ): boolean =>
@@ -168,8 +168,10 @@ export default {
168
168
  documentAttachments: "Document Attachments",
169
169
  videos: "Videos",
170
170
  audios: "Audio",
171
+ files: "Other Attachments",
171
172
  file: "Files",
172
- attachment: "Attachment",
173
+ attachment: "Other Attachment",
174
+ otherAttachments: "Other Attachments",
173
175
  documentAttachment: "Document Attachment",
174
176
  videoAttachment: "Video",
175
177
  audioAttachment: "Audio",
@@ -178,6 +180,22 @@ export default {
178
180
  agents: "Agents",
179
181
  scheduled: "Scheduled",
180
182
  no_content_in_tab: "No {{type}} in this space yet.",
183
+ no_attachments_in_space: "No attachments or media files in this space yet.",
184
+ no_attachments_desc: "You can upload images, documents, videos, or audio files to reference them in chats.",
185
+ no_scheduled_in_space: "No scheduled tasks in this space yet.",
186
+ no_scheduled_desc: "This is where your scheduled automation tasks and execution history are shown. Instruct your AI or set up workflows to run automatically at your specified times.",
187
+ no_images_in_space: "No images in this space yet.",
188
+ no_images_desc: "You can upload images or generate them in AI conversations.",
189
+ no_documents_in_space: "No document attachments in this space yet.",
190
+ no_documents_desc: "You can upload PDFs, Markdown, Word documents, etc. for reference and analysis.",
191
+ no_videos_in_space: "No videos in this space yet.",
192
+ no_videos_desc: "You can upload video files to reference them as context.",
193
+ no_audios_in_space: "No audio in this space yet.",
194
+ no_audios_desc: "You can upload recordings or audio tracks for transcription or processing.",
195
+ no_tables_in_space: "No tables in this space yet.",
196
+ no_tables_desc: "Organize and analyze your data in structured views, with direct AI processing support.",
197
+ no_files_in_space: "No other attachments in this space yet.",
198
+ no_files_desc: "This is where miscellaneous files that are not categorized as images, documents, or media are shown.",
181
199
 
182
200
  // === 内容管理页面 ===
183
201
  contentManagement: "Content Management",
@@ -414,8 +432,10 @@ export default {
414
432
  documentAttachments: "文档附件",
415
433
  videos: "视频",
416
434
  audios: "音频",
435
+ files: "其他附件",
417
436
  file: "文件",
418
- attachment: "附件",
437
+ attachment: "其他附件",
438
+ otherAttachments: "其他附件",
419
439
  documentAttachment: "文档附件",
420
440
  videoAttachment: "视频",
421
441
  audioAttachment: "音频",
@@ -424,6 +444,22 @@ export default {
424
444
  agents: "AI",
425
445
  scheduled: "定时任务",
426
446
  no_content_in_tab: "当前空间暂无{{type}}",
447
+ no_attachments_in_space: "该空间下还没有任何附件或媒体文件",
448
+ no_attachments_desc: "你可以上传图片、文档、视频 or 音频等各类文件,方便在对话中引用。",
449
+ no_scheduled_in_space: "该空间下暂无定时任务",
450
+ no_scheduled_desc: "这里展示空间内的定时自动化任务与定时运行状态。你可以通过下发指令或配置工作流,让 AI 按设定时间自动运行并在此处交付成果。",
451
+ no_images_in_space: "该空间下暂无图片",
452
+ no_images_desc: "你可以上传图片,或者在 AI 对话中生成图片并保存到这里。",
453
+ no_documents_in_space: "该空间下暂无文档附件",
454
+ no_documents_desc: "你可以上传 PDF、Markdown、Word 等文件附件,方便在对话中引用和分析。",
455
+ no_videos_in_space: "该空间下暂无视频",
456
+ no_videos_desc: "你可以上传各类视频文件,方便在对话中作为上下文引用。",
457
+ no_audios_in_space: "该空间下暂无音频",
458
+ no_audios_desc: "你可以上传录音或音轨,方便 AI 提取文字或进行音频处理。",
459
+ no_tables_in_space: "该空间下暂无表格",
460
+ no_tables_desc: "用结构化视图整理和分析你的数据,支持直接在表格内进行 AI 处理。",
461
+ no_files_in_space: "该空间下暂无其他附件",
462
+ no_files_desc: "这里展示未归类到图片、文档、音视频中的其他格式文件。",
427
463
 
428
464
  // === 内容管理页面 ===
429
465
  contentManagement: "内容管理",
@@ -652,8 +688,10 @@ export default {
652
688
  documentAttachments: "文件附件",
653
689
  videos: "影片",
654
690
  audios: "音訊",
691
+ files: "其他附件",
655
692
  file: "檔案",
656
- attachment: "附件",
693
+ attachment: "其他附件",
694
+ otherAttachments: "其他附件",
657
695
  documentAttachment: "文件附件",
658
696
  videoAttachment: "影片",
659
697
  audioAttachment: "音訊",
@@ -662,6 +700,22 @@ export default {
662
700
  agents: "智能體",
663
701
  scheduled: "定時任務",
664
702
  no_content_in_tab: "目前空間暫無{{type}}",
703
+ no_attachments_in_space: "該空間下還沒有任何附件或媒體文件",
704
+ no_attachments_desc: "你可以上傳圖片、文件、影片或音訊等各類檔案,方便在對話中引用。",
705
+ no_scheduled_in_space: "該空間下暫無定時任務",
706
+ no_scheduled_desc: "這裡展示空間內的定時自動化任務與定時運行狀態。你可以透過下發指令或配置工作流,讓 AI 按設定時間自動運行並在此處交付成果。",
707
+ no_images_in_space: "該空間下暫無圖片",
708
+ no_images_desc: "你可以上傳圖片,或者在 AI 對話中生成圖片並保存到這裡。",
709
+ no_documents_in_space: "該空間下暫無文件附件",
710
+ no_documents_desc: "你可以上傳 PDF、Markdown、Word 等文件附件,方便在對話中引用 and 分析。",
711
+ no_videos_in_space: "該空間下暫無影片",
712
+ no_videos_desc: "你可以上傳各類影片檔案,方便在對話中作為上下文引用。",
713
+ no_audios_in_space: "該空間下暫無音訊",
714
+ no_audios_desc: "你可以上傳錄音或音軌,方便 AI 提取文字或進行音訊處理。",
715
+ no_tables_in_space: "該空間下暫無表格",
716
+ no_tables_desc: "用結構化視圖整理和分析你的數據,支持直接在表格內進行 AI 處理。",
717
+ no_files_in_space: "該空間下暫無其他附件",
718
+ no_files_desc: "這裡展示未歸類到圖片、文件、音視頻中的其他格式檔案。",
665
719
 
666
720
  // === 內容管理頁面 ===
667
721
  contentManagement: "內容管理",
@@ -896,8 +950,10 @@ export default {
896
950
  documentAttachments: "文書添付",
897
951
  videos: "動画",
898
952
  audios: "音声",
953
+ files: "その他の添付ファイル",
899
954
  file: "ファイル",
900
- attachment: "添付",
955
+ attachment: "その他の添付ファイル",
956
+ otherAttachments: "その他の添付ファイル",
901
957
  documentAttachment: "文書添付",
902
958
  videoAttachment: "動画",
903
959
  audioAttachment: "音声",
@@ -907,6 +963,22 @@ export default {
907
963
  cybots: "エージェント",
908
964
  scheduled: "スケジュール済み",
909
965
  no_content_in_tab: "このスペースにはまだ{{type}}がありません。",
966
+ no_attachments_in_space: "このスペースにはまだ添付ファイルやメディアファイルがありません。",
967
+ no_attachments_desc: "画像、ドキュメント、動画、または音声ファイルをアップロードして、チャットで参照できます。",
968
+ no_scheduled_in_space: "このスペースにはまだ定期タスクがありません。",
969
+ no_scheduled_desc: "ここでは、スペース内の定期自動化タスクと実行履歴が表示されます。AIに指示を出すか、ワークフローを設定して、指定した時間に自動的に実行し、ここに成果を提供します。",
970
+ no_images_in_space: "このスペースにはまだ画像がありません。",
971
+ no_images_desc: "画像をアップロードするか、AIとの会話で生成できます。",
972
+ no_documents_in_space: "このスペースにはまだドキュメント添付ファイルがありません。",
973
+ no_documents_desc: "参照や分析のために、PDF、Markdown、Wordドキュメントなどをアップロードできます。",
974
+ no_videos_in_space: "このスペースにはまだ動画がありません。",
975
+ no_videos_desc: "文脈として参照するために動画ファイルをアップロードできます。",
976
+ no_audios_in_space: "このスペースにはまだ音声がありません。",
977
+ no_audios_desc: "文字起こしや処理のために、録音や音声トラックをアップロードできます。",
978
+ no_tables_in_space: "このスペースにはまだテーブルがありません。",
979
+ no_tables_desc: "構造化されたビューでデータを整理および分析し、直接AI処理をサポートします。",
980
+ no_files_in_space: "このスペースにはまだその他の添付ファイルがありません。",
981
+ no_files_desc: "画像、ドキュメント、またはメディアとして分類されていないその他のファイルがここに表示されます。",
910
982
 
911
983
  // === コンテンツ管理ページ ===
912
984
  contentManagement: "コンテンツ管理",
@@ -1,7 +1,4 @@
1
- import {
2
- NOLO_CLUSTER_SERVERS,
3
- normalizeKnownServerOrigin,
4
- } from "../config";
1
+ import { normalizeKnownServerOrigin } from "../config";
5
2
  import { BUILTIN_PLATFORM_AGENT_KEYS as CORE_BUILTIN_PLATFORM_AGENT_KEYS } from "../../core/builtinAgents";
6
3
 
7
4
  export const BUILTIN_PLATFORM_AGENT_KEYS = [
@@ -26,8 +23,5 @@ export const resolveAgentReadServers = ({
26
23
  configuredServers: string[];
27
24
  }): string[] => {
28
25
  const normalized = configuredServers.map(normalizeServer);
29
- if (!isBuiltinPlatformAgentKey(dbKey)) {
30
- return Array.from(new Set(normalized));
31
- }
32
- return Array.from(new Set([...normalized, ...NOLO_CLUSTER_SERVERS]));
26
+ return Array.from(new Set(normalized));
33
27
  };
@@ -20,9 +20,9 @@ import { readRequestManager } from "./readRequestManager";
20
20
  import { shouldReplaceWithNextRecord } from "../tombstones";
21
21
  import { scheduleExistingRecordReplication } from "./replication";
22
22
  import {
23
- BUILTIN_AGENT_CREATOR_AGENT_KEY,
24
- buildBuiltinAgentCreatorRecord,
23
+ buildBuiltinPlatformAgentRecord,
25
24
  } from "../../core/builtinAgents";
25
+ import { isBuiltinPlatformAgentKey } from "./agentReadResolution";
26
26
 
27
27
  // --- 辅助函数 ---
28
28
 
@@ -175,6 +175,15 @@ export const readAction = async (
175
175
  }
176
176
 
177
177
  const executeRead = async (): Promise<any> => {
178
+ if (isBuiltinPlatformAgentKey(dbKey)) {
179
+ const builtinRecord = buildBuiltinPlatformAgentRecord(dbKey);
180
+ if (builtinRecord) {
181
+ await saveRemoteDataToClientDb(clientDb, dbKey, builtinRecord);
182
+ readRequestManager.clearMiss(dbKey);
183
+ return builtinRecord;
184
+ }
185
+ }
186
+
178
187
  const state = thunkApi.getState();
179
188
  const { currentToken, remoteServers: configuredServers } =
180
189
  getRuntimeServerContext(state, preferredServerOrigin);
@@ -345,13 +354,6 @@ export const readAction = async (
345
354
  : { ...validRemoteData, dbKey };
346
355
  }
347
356
 
348
- if (dbKey === BUILTIN_AGENT_CREATOR_AGENT_KEY) {
349
- const builtinRecord = buildBuiltinAgentCreatorRecord();
350
- await saveRemoteDataToClientDb(clientDb, dbKey, builtinRecord);
351
- readRequestManager.clearMiss(dbKey);
352
- return builtinRecord;
353
- }
354
-
355
357
  readRequestManager.markMiss(dbKey, Date.now());
356
358
  throw buildReadMissError({
357
359
  dbKey,
@@ -2,14 +2,14 @@
2
2
 
3
3
  import type { AppThunkApi } from "../../app/store";
4
4
  import {
5
- BUILTIN_AGENT_CREATOR_AGENT_KEY,
6
- buildBuiltinAgentCreatorRecord,
5
+ buildBuiltinPlatformAgentRecord,
7
6
  } from "../../core/builtinAgents";
8
7
  import { fetchFromClientDb, fetchFromServer } from "./common";
9
8
  import { readRequestManager } from "./readRequestManager";
10
9
  import { scheduleExistingRecordReplication } from "./replication";
11
10
  import { getRuntimeServerContext } from "../runtimeServerContext";
12
11
  import { resolveAgentReadServers } from "./agentReadResolution";
12
+ import { isBuiltinPlatformAgentKey } from "./agentReadResolution";
13
13
  import {
14
14
  compareRemoteRecordsByComparableTime,
15
15
  pickBestSettledRemoteRecord,
@@ -111,9 +111,6 @@ const processRemoteData = async (
111
111
  }
112
112
 
113
113
  // 场景 3: 远程和本地都找不到任何数据。
114
- if (dbKey === BUILTIN_AGENT_CREATOR_AGENT_KEY) {
115
- return buildBuiltinAgentCreatorRecord();
116
- }
117
114
  throw new Error("Failed to fetch data from all sources");
118
115
  } catch (err) {
119
116
  // 如果在上述过程中发生错误,且有本地数据,则优先返回本地数据,避免崩溃。
@@ -148,6 +145,14 @@ export const readAndWaitAction = async (
148
145
  const isLoggedIn = !!currentToken;
149
146
 
150
147
  const executeReadAndWait = async (): Promise<any> => {
148
+ if (isBuiltinPlatformAgentKey(dbKey)) {
149
+ const builtinRecord = buildBuiltinPlatformAgentRecord(dbKey);
150
+ if (builtinRecord) {
151
+ await db.put(dbKey, builtinRecord);
152
+ return { ...builtinRecord, dbKey };
153
+ }
154
+ }
155
+
151
156
  // 1. 准备所有需要访问的远程服务器(带去重 + 离线检测)
152
157
  // 2. 首先,尝试从本地数据库获取数据(可能为 null)
153
158
  const localData = await fetchFromClientDb(db, dbKey);
@@ -1,5 +1,5 @@
1
1
  import type { AccessAction } from "./resourceAccess";
2
- import serverDb from "./db";
2
+ import { getServerAuthorityStore } from "./db";
3
3
 
4
4
  export type AgentDelegation = {
5
5
  principalUserId: string;
@@ -64,9 +64,10 @@ export async function loadAgentDelegation(
64
64
  principalUserId: string,
65
65
  agentId: string
66
66
  ): Promise<AgentDelegation | null> {
67
+ const store = getServerAuthorityStore();
67
68
  if (!principalUserId || !agentId) return null;
68
69
  try {
69
- const delegation = await serverDb.get(
70
+ const delegation = await store.get(
70
71
  agentDelegationKey(principalUserId, agentId)
71
72
  );
72
73
  return delegation || null;