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.
- package/agent-runtime/agentRecordConfig.ts +0 -2
- package/agent-runtime/hostAdapter.ts +0 -1
- package/agent-runtime/hostRuntimeCapabilities.ts +7 -0
- package/agent-runtime/hostRuntimeConfig.ts +86 -0
- package/agent-runtime/index.ts +13 -0
- package/agent-runtime/localToolPolicy.ts +13 -6
- package/agent-runtime/localWorkspaceTools.ts +333 -30
- package/agent-runtime/platformChatProvider.ts +4 -1
- package/agent-runtime/runtimeToolPolicy.ts +32 -47
- package/agent-runtime/shellCommandPolicy.ts +117 -0
- package/agent-runtime/toolGate.ts +38 -0
- package/agentCreateCustomCommands.ts +9 -4
- package/agentDialogsCommands.ts +4 -3
- package/agentDoctorCommands.ts +3 -3
- package/agentListCommands.ts +3 -3
- package/agentMachineCommands.ts +6 -6
- package/agentPullCommand.ts +4 -12
- package/agentRecordCommands.ts +5 -3
- package/agentRecordHelpers.ts +42 -23
- package/agentRunCommand.ts +2 -6
- package/agentRunParsing.ts +18 -5
- package/agentRuntimeLocal.ts +10 -0
- package/agentUnpublishCommands.ts +3 -2
- package/ai/agent/agentRunDialogLineage.ts +56 -0
- package/ai/agent/agentSlice.ts +45 -10
- package/ai/agent/avatarUtils.ts +1 -1
- package/ai/agent/buildSystemPrompt.ts +1 -2
- package/ai/agent/cliExecutor.ts +330 -19
- package/ai/agent/createAgentSchema.ts +22 -0
- package/ai/agent/hooks/fetchPublicAgents.ts +14 -39
- package/ai/agent/hooks/usePublicAgents.ts +90 -192
- package/ai/agent/publicAgentCatalog.ts +359 -0
- package/ai/agent/publicAgentIdentity.ts +76 -0
- package/ai/agent/server/fetchPublicAgents.ts +21 -46
- package/ai/agent/serverOrigin.ts +7 -0
- package/ai/agent/streamAgentChatTurn.ts +23 -21
- package/ai/agent/streamAgentChatTurnUtils.ts +292 -6
- package/ai/agent/types.ts +2 -0
- package/ai/agent/web/agentDisplayUtils.ts +171 -0
- package/ai/agent/web/useAgentModelAvatarComponent.ts +32 -0
- package/ai/ai.locale.ts +8 -0
- package/ai/chat/sendOpenAICompletionsRequest.native.ts +15 -0
- package/ai/chat/sendOpenAICompletionsRequest.ts +93 -1
- package/ai/chat/sendOpenAIResponseRequest.ts +86 -9
- package/ai/chat/updateTotalUsage.ts +7 -0
- package/ai/llm/deepinfra.ts +30 -15
- package/ai/llm/mistral.ts +3 -4
- package/ai/llm/providers.ts +2 -0
- package/ai/llm/types.ts +15 -0
- package/ai/memory/capture.ts +3 -3
- package/ai/memory/consolidate.ts +2 -2
- package/ai/memory/delete.ts +4 -3
- package/ai/memory/query.ts +3 -3
- package/ai/memory/remember.ts +2 -2
- package/ai/memory/store.ts +3 -3
- package/ai/memory/storeShared.ts +3 -2
- package/ai/policy/commercialMultiplier.ts +16 -0
- package/ai/token/billingAdminAuditEvent.ts +68 -0
- package/ai/token/billingAdminAuditEventWriter.ts +41 -0
- package/ai/token/billingAnomaly.ts +90 -0
- package/ai/token/billingAnomalyLifecycle.ts +54 -0
- package/ai/token/billingAnomalyLifecycleWriter.ts +44 -0
- package/ai/token/billingAnomalyWriter.ts +41 -0
- package/ai/token/calculatePrice.ts +3 -2
- package/ai/token/deepinfraReconciliation.ts +153 -0
- package/ai/token/deepinfraRequestIdQuery.ts +92 -0
- package/ai/token/externalToolCost.ts +54 -41
- package/ai/token/missingUsageEstimate.ts +12 -3
- package/ai/token/normalizeUsage.ts +45 -5
- package/ai/token/openaiReconciliation.ts +188 -0
- package/ai/token/providerBillableEvent.ts +84 -0
- package/ai/token/providerBillableEventWriter.ts +36 -0
- package/ai/token/providerBillingAnomalyDrilldown.ts +308 -0
- package/ai/token/providerBillingDrilldown.ts +361 -0
- package/ai/token/providerBillingHealthReport.ts +366 -0
- package/ai/token/providerCall.ts +144 -0
- package/ai/token/providerCallSweeper.ts +168 -0
- package/ai/token/providerCallWriter.ts +33 -0
- package/ai/token/providerCredential.ts +89 -0
- package/ai/token/providerCredentialAnomaly.ts +154 -0
- package/ai/token/providerCredentialLifecycle.ts +59 -0
- package/ai/token/providerCredentialLifecycleWriter.ts +44 -0
- package/ai/token/providerCredentialRegistry.ts +83 -0
- package/ai/token/providerCredentialRegistryCommand.ts +97 -0
- package/ai/token/providerCredentialRegistryList.ts +124 -0
- package/ai/token/providerCredentialRegistryResolver.ts +150 -0
- package/ai/token/providerCredentialRegistryWriter.ts +41 -0
- package/ai/token/providerCredentialRotationCommand.ts +102 -0
- package/ai/token/providerCredentialRuntime.ts +56 -0
- package/ai/token/providerDispatchIntent.ts +67 -0
- package/ai/token/providerDispatchIntentWriter.ts +36 -0
- package/ai/token/providerGateway.ts +260 -0
- package/ai/token/providerReconciliation.ts +148 -0
- package/ai/token/providerReconciliationLocal.ts +97 -0
- package/ai/token/providerReconciliationRunner.ts +165 -0
- package/ai/token/providerReconciliationWriter.ts +41 -0
- package/ai/token/ratingResult.ts +202 -0
- package/ai/token/ratingResultWriter.ts +33 -0
- package/ai/token/serverDialogProjection.ts +5 -3
- package/ai/token/serverTokenWriter.ts +11 -3
- package/ai/token/types.ts +10 -0
- package/ai/tools/agent/callAgentTool.ts +3 -4
- package/ai/tools/agent/presets/appBuilderPreset.ts +5 -7
- package/ai/tools/agent/runStreamingAgentTool.ts +1 -2
- package/ai/tools/agent/streamParallelAgentsTool.ts +2 -3
- package/ai/tools/readXPostTool.ts +1 -5
- package/app/admin/adminPages.ts +9 -0
- package/app/i18n/i18n.config.ts +5 -0
- package/app/i18n/translations/pricing.locale.ts +397 -0
- package/app/utils/desktopAgentRuntimeStatusClient.ts +5 -4
- package/app/utils/desktopAgentRuntimeTurnClient.ts +4 -1
- package/app/utils/imageUtils.ts +64 -34
- package/auth/adminPermissions.ts +18 -0
- package/auth/authSlice.ts +26 -12
- package/auth/hooks/useFetchUsers.ts +3 -0
- package/auth/routes.ts +46 -0
- package/auth/server/accessActivity.ts +4 -3
- package/auth/server/adminPermissions.ts +43 -0
- package/auth/server/adminUsageReport.ts +375 -0
- package/auth/server/billingAnomalies.ts +235 -0
- package/auth/server/billingUsageReport.ts +41 -2
- package/auth/server/creatorEarningCreditConversion.ts +10 -2
- package/auth/server/deduct.ts +14 -7
- package/auth/server/delete.ts +10 -2
- package/auth/server/disable.ts +4 -3
- package/auth/server/emailAutomation.ts +7 -5
- package/auth/server/emailDbConfig.ts +4 -2
- package/auth/server/emailDelivery.ts +24 -20
- package/auth/server/emailDeliveryGuards.ts +10 -7
- package/auth/server/emailPreferences.ts +6 -4
- package/auth/server/emailReport.ts +6 -4
- package/auth/server/emailRuntimeConfig.ts +3 -3
- package/auth/server/emailScenarioNotifications.ts +9 -8
- package/auth/server/enable.ts +4 -3
- package/auth/server/getRechargeHistory.ts +3 -2
- package/auth/server/getUser.ts +3 -2
- package/auth/server/gptProAccess.ts +44 -0
- package/auth/server/inviteReward.ts +10 -7
- package/auth/server/listusers.ts +6 -4
- package/auth/server/login.ts +2 -2
- package/auth/server/productEntitlements.ts +7 -4
- package/auth/server/productPurchase.ts +10 -2
- package/auth/server/providerBillingDrilldown.ts +47 -0
- package/auth/server/providerBillingHealth.ts +71 -0
- package/auth/server/providerCredentials.ts +136 -0
- package/auth/server/recharge.ts +14 -8
- package/auth/server/revokeSessions.ts +4 -3
- package/auth/server/route.ts +77 -0
- package/auth/server/sendEmail.ts +5 -4
- package/auth/server/signup.ts +10 -3
- package/auth/server/token.ts +53 -55
- package/auth/server/tokenUsageBilling.ts +18 -7
- package/auth/server/usageManagementAccess.ts +43 -0
- package/auth/server/usageReport.ts +59 -0
- package/auth/types.ts +12 -0
- package/auth/utils.ts +24 -22
- package/authCommands.ts +36 -2
- package/buildPublish.ts +3 -1
- package/buildPublishArtifactAssembly.ts +62 -1
- package/buildPublishImportAnalysis.ts +21 -16
- package/chat/dialog/dialogLaunchScope.ts +32 -0
- package/chat/dialog/objectAssistantRegistry.ts +2 -2
- package/chat/dialog/useCreateDialog.ts +1 -1
- package/chat/hooks/useChatInput.ts +41 -10
- package/chat/messages/messageSlice.ts +5 -1
- package/chat/messages/pendingAttachmentParts.ts +28 -2
- package/chat/messages/sendFirstMessage.ts +76 -79
- package/chat/messages/types.ts +9 -0
- package/chat/messages/web/streamingMarkdownModel.ts +41 -0
- package/chat/messages/web/useStreamingReveal.ts +91 -0
- package/chat/web/messageInputAgentUi.ts +94 -6
- package/cliEnvHelpers.ts +68 -13
- package/cliRuntimeDoctorReport.ts +193 -0
- package/client/agentConfigResolver.test.ts +0 -2
- package/client/agentRun.test.ts +171 -10
- package/client/agentRun.ts +44 -637
- package/client/agentRunInput.ts +10 -0
- package/client/agentRunLocalExecutor.ts +179 -0
- package/client/agentRunServerTransport.ts +394 -0
- package/client/agentRunTaskRunRecorder.ts +176 -0
- package/client/localRuntimeAdapter.test.ts +236 -9
- package/client/localRuntimeAdapter.ts +221 -23
- package/client/localToolPolicy.test.ts +28 -4
- package/connector-experimental/daemonLauncher.ts +38 -4
- package/connectorRunArtifact.ts +34 -10
- package/connectorWebSocketTarget.ts +40 -15
- package/core/builtinAgents.ts +155 -11
- package/create/space/contentLabels.ts +1 -1
- package/create/space/contentTypeMeta.ts +3 -2
- package/create/space/sidebarVisibleTypes.ts +27 -0
- package/create/space/space.locale.ts +76 -4
- package/database/actions/agentReadResolution.ts +2 -8
- package/database/actions/read.ts +11 -9
- package/database/actions/readAndWait.ts +10 -5
- package/database/server/agentDelegation.ts +3 -2
- package/database/server/authorityStoreConformance.ts +209 -0
- package/database/server/authorityStoreTypes.ts +31 -0
- package/database/server/coreDataProxy.ts +1 -1
- package/database/server/dataHandlers.ts +13 -5
- package/database/server/db.ts +15 -34
- package/database/server/delete.ts +88 -71
- package/database/server/emailRepository.ts +11 -9
- package/database/server/fileService.ts +2 -1
- package/database/server/legacyServerDb.ts +58 -0
- package/database/server/levelAuthorityStore.ts +75 -0
- package/database/server/memoryAuthorityStore.ts +133 -0
- package/database/server/patch.ts +13 -12
- package/database/server/query.ts +3 -2
- package/database/server/read.ts +33 -30
- package/database/server/resourceAccess.ts +7 -5
- package/database/server/serverStoreFactory.ts +124 -0
- package/database/server/spaceMemberAuthority.ts +3 -2
- package/database/server/storeBatchCompat.ts +37 -0
- package/database/server/testAuthorityStore.ts +76 -0
- package/database/server/write.ts +29 -27
- package/dialogReadCommands.ts +2 -1
- package/dialogStatusCommands.ts +2 -1
- package/integrations/anthropic/anthropicModels.ts +12 -12
- package/integrations/deepseek/models.ts +67 -67
- package/integrations/google/models.ts +111 -53
- package/integrations/openai/models.ts +22 -22
- package/integrations/xai/models.ts +1 -1
- package/localRuntimeDb.ts +39 -2
- package/machineCommandPrompts.ts +2 -0
- package/machineCommands.ts +193 -62
- package/machineStatusCommands.ts +4 -12
- package/machineWsRunDispatch.ts +80 -15
- package/machineWsSession.ts +46 -2
- package/noloReadBridgePrompt.ts +16 -0
- package/package.json +114 -21
- package/pageCreateCommands.ts +2 -2
- package/pageDeleteCommands.ts +3 -3
- package/pageReadCommands.ts +3 -3
- package/pageUpdateCommands.ts +3 -3
- package/render/layout/mainLayoutViewMode.ts +25 -0
- package/render/page/server/createPage.ts +3 -1
- package/render/page/server/handleCreatePage.ts +2 -11
- package/runtimeDoctorCommands.ts +18 -69
- package/server/api/methods.ts +34 -12
- package/server/api/tableHandlers.ts +6 -3
- package/server/authenticateToken.ts +47 -2
- package/server/billingLedgerRoutes.ts +15 -0
- package/server/buildManifest.ts +54 -0
- package/server/coreReadiness.ts +34 -25
- package/server/coreRuntime.ts +15 -10
- package/server/handlers/activityStatsHandler.ts +5 -2
- package/server/handlers/agentEmailRegistrationE2EHandler.ts +25 -23
- package/server/handlers/agentRun/agentLookup.ts +1 -7
- package/server/handlers/agentRun/autonomousRuntime.ts +11 -10
- package/server/handlers/agentRun/builtinAgents.ts +12 -88
- package/server/handlers/agentRun/continueDialogContext.ts +15 -3
- package/server/handlers/agentRun/{inheritedDialogPrompt.ts → conversationReference.ts} +3 -3
- package/server/handlers/agentRun/dialogLookup.ts +4 -3
- package/server/handlers/agentRun/index.ts +864 -404
- package/server/handlers/agentRun/localRuntimeBootstrap.ts +17 -1
- package/server/handlers/agentRun/loop.ts +920 -508
- package/server/handlers/agentRun/machineConnector.ts +56 -8
- package/server/handlers/agentRun/machineRunAudit.ts +3 -2
- package/server/handlers/agentRun/modelUsageToolHandlers.ts +13 -10
- package/server/handlers/agentRun/requestContext.ts +12 -8
- package/server/handlers/agentRun/runtimeExecutionContext.ts +15 -3
- package/server/handlers/agentRun/runtimePreparation.ts +26 -24
- package/server/handlers/agentRun/runtimeRouting.ts +25 -40
- package/server/handlers/agentRun/runtimeSystemMessages.ts +65 -0
- package/server/handlers/agentRun/saveDialog.ts +97 -87
- package/server/handlers/agentRun/taskRunToolHandler.ts +9 -7
- package/server/handlers/agentRun/toolExecutor.ts +42 -78
- package/server/handlers/agentRun/types.ts +2 -1
- package/server/handlers/appDeployStatusStore.ts +17 -10
- package/server/handlers/appDomainHandler.ts +21 -15
- package/server/handlers/appLegacyInfraCleanup.ts +5 -2
- package/server/handlers/appSandboxHandler.ts +29 -8
- package/server/handlers/appSpaceAccess.ts +15 -8
- package/server/handlers/chatHandler.ts +22 -2
- package/server/handlers/chatUpstreamRetry.ts +225 -2
- package/server/handlers/connector/connectorConnectionRegistry.ts +55 -7
- package/server/handlers/connector/connectorWebSocket.ts +14 -10
- package/server/handlers/desktopAgentRuntimeAdapter.ts +4 -4
- package/server/handlers/desktopAgentRuntimeHostCapabilities.ts +25 -0
- package/server/handlers/desktopAgentRuntimeReadiness.ts +62 -0
- package/server/handlers/desktopAgentRuntimeStatusHandler.ts +38 -30
- package/server/handlers/desktopAgentRuntimeTurnHandler.ts +7 -3
- package/server/handlers/desktopAgentRuntimeTurnService.ts +39 -45
- package/server/handlers/desktopLlamaRuntimeHandler.ts +85 -51
- package/server/handlers/desktopUpdaterHandler.ts +132 -24
- package/server/handlers/favoriteHandlers.ts +8 -2
- package/server/handlers/getDialogBillingHandler.ts +4 -3
- package/server/handlers/getTransactionsHandler.ts +5 -2
- package/server/handlers/machines/machineBinding.ts +1 -0
- package/server/handlers/machines/machineHandlers.ts +0 -14
- package/server/handlers/machines/machineInstallAssets.ts +4 -2
- package/server/handlers/notificationEmitter.ts +5 -3
- package/server/handlers/notificationsHandler.ts +5 -2
- package/server/handlers/providerCallsRecentHandler.ts +234 -0
- package/server/handlers/providerReconciliationRunHandler.ts +180 -0
- package/server/handlers/providerRequestIdsHandler.ts +105 -0
- package/server/handlers/tableAccess.ts +6 -2
- package/server/handlers/tableToolHandlers.ts +28 -14
- package/server/handlers/userSecretsHandler.ts +17 -6
- package/server/handlers/versionHandler.ts +9 -4
- package/server/handlers/versionStore.ts +18 -10
- package/server/html/ssrPreload.ts +5 -3
- package/server/payments/crypto/cryptoUsdcBasePaymentProvider.ts +11 -8
- package/server/payments/crypto/cryptoUsdcBaseScanner.ts +12 -7
- package/server/payments/crypto/cryptoUsdtTronPaymentProvider.ts +11 -8
- package/server/payments/crypto/cryptoUsdtTronScanner.ts +9 -7
- package/server/payments/waffo/waffoPaymentProvider.ts +12 -9
- package/server/runtimeRole.ts +15 -0
- package/server/scheduler/scheduledTaskRuntime.ts +4 -2
- package/server/scheduler/schedulerService.ts +2 -2
- package/server/taskRunBridgeRoutes.ts +8 -5
- package/share/server/fetchCommunityShares.ts +1 -1
- package/share/server/helpers.ts +19 -17
- package/share/server/importShare.ts +9 -13
- package/share/server/listCommunityShares.ts +4 -4
- package/share/server/purchaseDoc.ts +8 -16
- package/share/server/readCommunityShareCover.ts +3 -2
- package/share/server/readSharedTable.ts +14 -13
- package/share/server/tableReplication.ts +42 -39
- package/spaceAttachCommands.ts +135 -0
- package/spaceCategoryCommands.ts +6 -6
- package/spaceCommands.ts +3 -3
- package/spaceDeleteCommands.ts +2 -2
- package/spaceInternalCommandEntries.ts +2 -0
- package/spaceReadCommands.ts +3 -3
- package/tableMetaCommands.ts +2 -2
- package/taskRunCommand.ts +11 -0
- package/ai/agent/runtimeServerBase.ts +0 -37
- package/server/handlers/desktopAgentRuntimeHostFacts.ts +0 -40
package/core/builtinAgents.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
+
};
|
|
@@ -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
|
-
|
|
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
|
};
|
package/database/actions/read.ts
CHANGED
|
@@ -20,9 +20,9 @@ import { readRequestManager } from "./readRequestManager";
|
|
|
20
20
|
import { shouldReplaceWithNextRecord } from "../tombstones";
|
|
21
21
|
import { scheduleExistingRecordReplication } from "./replication";
|
|
22
22
|
import {
|
|
23
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
70
|
+
const delegation = await store.get(
|
|
70
71
|
agentDelegationKey(principalUserId, agentId)
|
|
71
72
|
);
|
|
72
73
|
return delegation || null;
|