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
|
@@ -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
|
|
7
|
-
import {
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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(
|
|
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
|
|
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
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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
|
|
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
|
-
|
|
761
|
-
|
|
762
|
-
|
|
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
|
|
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
|
|
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
|
|
870
|
-
...(await
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1
|
+
import { ensureServerDbOpen, getServerAuthorityStore } from "../../../database/server/db";
|
|
2
2
|
import { rowKey } from "../../../database/keys";
|
|
3
|
-
import {
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
68
|
-
|
|
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
|
|
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 {
|
|
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
|
|
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
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
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
|
-
|
|
1090
|
-
|
|
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
|
-
|
|
1477
|
-
|
|
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:
|
|
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
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
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 {
|