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,4 +1,5 @@
|
|
|
1
1
|
import type { ChatMessage } from "./types";
|
|
2
|
+
import { hasMachineBoundLocalProvider } from "./localRuntimeBootstrap";
|
|
2
3
|
import { resolveMachineRunPermissionPolicy } from "../../../ai/agent/machineRunPermissions";
|
|
3
4
|
import {
|
|
4
5
|
connectorConnectionRegistry,
|
|
@@ -47,10 +48,29 @@ export function resolveAgentRuntimeMachineId(agentConfig: any): string {
|
|
|
47
48
|
return String(agentConfig?.runtimeBinding?.machineId ?? "").trim();
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
export function resolveAgentRuntimeConnectorSurface(agentConfig: any): string | undefined {
|
|
52
|
+
const runtimeBinding = isRecord(agentConfig?.runtimeBinding) ? agentConfig.runtimeBinding : {};
|
|
53
|
+
const value = runtimeBinding.connectorSurface ?? runtimeBinding.surface;
|
|
54
|
+
return typeof value === "string" && value.trim()
|
|
55
|
+
? value.trim().toLowerCase()
|
|
56
|
+
: undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
export function shouldUseMachineConnector(agentConfig: any): boolean {
|
|
51
|
-
return
|
|
60
|
+
return !!resolveAgentRuntimeMachineId(agentConfig) &&
|
|
61
|
+
(agentConfig?.apiSource === "cli" || hasMachineBoundLocalProvider(agentConfig));
|
|
52
62
|
}
|
|
53
63
|
|
|
64
|
+
export type AgentRuntimeMachineRouteResult =
|
|
65
|
+
| { ok: true; machineId: string; ownerUserId: string }
|
|
66
|
+
| {
|
|
67
|
+
ok: false;
|
|
68
|
+
machineId: string;
|
|
69
|
+
status: 400;
|
|
70
|
+
reason: "bound_machine_missing_owner";
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
54
74
|
function isRecord(value: unknown): value is Record<string, any> {
|
|
55
75
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
56
76
|
}
|
|
@@ -81,12 +101,20 @@ function shouldUseWorkspaceMachineRuntime(args: {
|
|
|
81
101
|
}
|
|
82
102
|
|
|
83
103
|
export function resolveAgentRuntimeMachineRoute(
|
|
84
|
-
agentConfig: any
|
|
85
|
-
|
|
86
|
-
): { machineId: string; ownerUserId: string } {
|
|
104
|
+
agentConfig: any
|
|
105
|
+
): AgentRuntimeMachineRouteResult {
|
|
87
106
|
const machineId = resolveAgentRuntimeMachineId(agentConfig);
|
|
88
|
-
const ownerUserId = String(agentConfig?.runtimeBinding?.ownerUserId ?? "").trim()
|
|
89
|
-
|
|
107
|
+
const ownerUserId = String(agentConfig?.runtimeBinding?.ownerUserId ?? "").trim();
|
|
108
|
+
if (machineId && !ownerUserId) {
|
|
109
|
+
return {
|
|
110
|
+
ok: false,
|
|
111
|
+
machineId,
|
|
112
|
+
status: 400,
|
|
113
|
+
reason: "bound_machine_missing_owner",
|
|
114
|
+
message: `Bound runtime machine ${machineId} is missing runtimeBinding.ownerUserId.`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return { ok: true, machineId, ownerUserId };
|
|
90
118
|
}
|
|
91
119
|
|
|
92
120
|
export class ConnectorOfflineError extends Error {
|
|
@@ -100,9 +128,22 @@ export class ConnectorOfflineError extends Error {
|
|
|
100
128
|
}
|
|
101
129
|
}
|
|
102
130
|
|
|
131
|
+
export class InvalidBoundMachineConfigError extends Error {
|
|
132
|
+
readonly machineId: string;
|
|
133
|
+
readonly reason: "bound_machine_missing_owner";
|
|
134
|
+
readonly status = 400;
|
|
135
|
+
|
|
136
|
+
constructor(machineId: string, message: string) {
|
|
137
|
+
super(message);
|
|
138
|
+
this.machineId = machineId;
|
|
139
|
+
this.reason = "bound_machine_missing_owner";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
103
143
|
export async function runViaMachineConnector(args: {
|
|
104
144
|
agentConfig: any;
|
|
105
145
|
agentKey: string;
|
|
146
|
+
authToken?: string;
|
|
106
147
|
category?: string;
|
|
107
148
|
continueDialogId?: string;
|
|
108
149
|
messages: ChatMessage[];
|
|
@@ -126,11 +167,16 @@ export async function runViaMachineConnector(args: {
|
|
|
126
167
|
return null;
|
|
127
168
|
}
|
|
128
169
|
|
|
129
|
-
const
|
|
170
|
+
const route = resolveAgentRuntimeMachineRoute(args.agentConfig);
|
|
171
|
+
if (!route.ok) {
|
|
172
|
+
throw new InvalidBoundMachineConfigError(route.machineId, route.message);
|
|
173
|
+
}
|
|
174
|
+
const { machineId, ownerUserId } = route;
|
|
130
175
|
if (!machineId) return null;
|
|
176
|
+
const connectorSurface = resolveAgentRuntimeConnectorSurface(args.agentConfig);
|
|
131
177
|
|
|
132
178
|
const connectorRegistry = args.connectorRegistry ?? connectorConnectionRegistry;
|
|
133
|
-
if (!connectorRegistry.hasConnection(ownerUserId, machineId)) {
|
|
179
|
+
if (!connectorRegistry.hasConnection(ownerUserId, machineId, connectorSurface)) {
|
|
134
180
|
throw new ConnectorOfflineError(machineId);
|
|
135
181
|
}
|
|
136
182
|
|
|
@@ -200,6 +246,7 @@ export async function runViaMachineConnector(args: {
|
|
|
200
246
|
source: "agent.run",
|
|
201
247
|
machineId,
|
|
202
248
|
machinePermissions,
|
|
249
|
+
...(args.authToken ? { userAuthToken: args.authToken } : {}),
|
|
203
250
|
...(args.runtimePromptPage
|
|
204
251
|
? { runtimePromptPage: args.runtimePromptPage }
|
|
205
252
|
: {}),
|
|
@@ -215,6 +262,7 @@ export async function runViaMachineConnector(args: {
|
|
|
215
262
|
? { requestTimeoutMs: args.requestTimeoutMs }
|
|
216
263
|
: {}),
|
|
217
264
|
...(args.onProgress ? { onProgress: args.onProgress } : {}),
|
|
265
|
+
...(connectorSurface ? { connectorSurface } : {}),
|
|
218
266
|
};
|
|
219
267
|
return await (Object.keys(connectorOptions).length > 0
|
|
220
268
|
? connectorRegistry.sendAgentRun(ownerUserId, machineId, connectorPayload, connectorOptions)
|
|
@@ -36,11 +36,12 @@ export async function recordMachineAgentAudit(event: MachineAgentAuditEvent) {
|
|
|
36
36
|
const load = new Function("specifier", "return import(specifier)") as (
|
|
37
37
|
specifier: string
|
|
38
38
|
) => Promise<any>;
|
|
39
|
-
const {
|
|
39
|
+
const { getServerAuthorityStore } = await load("database/server/db");
|
|
40
|
+
const store = getServerAuthorityStore();
|
|
40
41
|
const createdAt = event.createdAt ?? Date.now();
|
|
41
42
|
const id = crypto.randomUUID();
|
|
42
43
|
const key = `machine-agent-audit-${event.userId}-${createdAt}-${id}`;
|
|
43
|
-
await
|
|
44
|
+
await store.put(key, {
|
|
44
45
|
...event,
|
|
45
46
|
createdAt,
|
|
46
47
|
schemaVersion: 1,
|
|
@@ -6,7 +6,7 @@ import { checkSpaceMembership } from "../../../create/space/utils/permissions";
|
|
|
6
6
|
import { isAIAdmin } from "../../../core/init";
|
|
7
7
|
import { extractCustomId } from "../../../core/prefix";
|
|
8
8
|
import { createTaskKey, createUserKey } from "../../../database/keys";
|
|
9
|
-
import
|
|
9
|
+
import { getServerAuthorityStore } from "../../../database/server/db";
|
|
10
10
|
import { queryModelUsage } from "../../../ai/token/modelUsageQuery";
|
|
11
11
|
import { emitAgentNoticeNotification } from "../notificationEmitter";
|
|
12
12
|
import type { ToolExecutionContext } from "./types";
|
|
@@ -41,6 +41,7 @@ const trimString = (value: unknown): string =>
|
|
|
41
41
|
const boolValue = (value: unknown): boolean => value === true;
|
|
42
42
|
const FEEDBACK_AGENT_ID = "01NOLOFEEDBACKA000000000R1";
|
|
43
43
|
const FEEDBACK_NOTIFICATION_USER_ID = "0e95801d90";
|
|
44
|
+
const getModelUsageToolStore = () => getServerAuthorityStore();
|
|
44
45
|
|
|
45
46
|
const requireCurrentUser = (context?: ToolExecutionContext): string => {
|
|
46
47
|
const userId = trimString(context?.userId);
|
|
@@ -52,7 +53,7 @@ const requireCurrentUser = (context?: ToolExecutionContext): string => {
|
|
|
52
53
|
|
|
53
54
|
const readOptionalRecord = async (key: string): Promise<unknown | null> => {
|
|
54
55
|
try {
|
|
55
|
-
return await
|
|
56
|
+
return await getModelUsageToolStore().get(key);
|
|
56
57
|
} catch {
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
@@ -105,7 +106,7 @@ const persistDialogGoal = async (
|
|
|
105
106
|
dialog: DialogConfig,
|
|
106
107
|
goal: DialogGoalState,
|
|
107
108
|
) => {
|
|
108
|
-
await
|
|
109
|
+
await getModelUsageToolStore().put(dialogKey, {
|
|
109
110
|
...dialog,
|
|
110
111
|
goal,
|
|
111
112
|
updatedAt: new Date().toISOString(),
|
|
@@ -120,10 +121,11 @@ const attachScheduledTaskToSpace = async (args: {
|
|
|
120
121
|
now: number;
|
|
121
122
|
}) => {
|
|
122
123
|
const spaceKey = createSpaceKey.space(args.spaceId);
|
|
123
|
-
const
|
|
124
|
+
const store = getModelUsageToolStore();
|
|
125
|
+
const spaceRecord = (await store.get(spaceKey).catch(() => null)) as any;
|
|
124
126
|
checkSpaceMembership(spaceRecord, args.userId);
|
|
125
127
|
|
|
126
|
-
await
|
|
128
|
+
await store.put(spaceKey, {
|
|
127
129
|
...spaceRecord,
|
|
128
130
|
contents: {
|
|
129
131
|
...(spaceRecord.contents ?? {}),
|
|
@@ -146,7 +148,7 @@ export async function runQueryModelUsageTool(
|
|
|
146
148
|
context?: ToolExecutionContext,
|
|
147
149
|
) {
|
|
148
150
|
const requestUserId = requireCurrentUser(context);
|
|
149
|
-
return queryModelUsage(
|
|
151
|
+
return queryModelUsage(getModelUsageToolStore(), {
|
|
150
152
|
...args,
|
|
151
153
|
requestUserId,
|
|
152
154
|
isAdmin: await canManageModelUsage(requestUserId),
|
|
@@ -275,6 +277,7 @@ export async function runCreateScheduledTaskTool(
|
|
|
275
277
|
const nowMs = Date.now();
|
|
276
278
|
const title = trimString(args.title) || "Scheduled agent task";
|
|
277
279
|
const spaceId = trimString(args.spaceId) || trimString(context?.currentSpaceId);
|
|
280
|
+
const store = getModelUsageToolStore();
|
|
278
281
|
const task: ScheduledTaskConfig = {
|
|
279
282
|
id: taskId,
|
|
280
283
|
dbKey: taskKey,
|
|
@@ -294,7 +297,7 @@ export async function runCreateScheduledTaskTool(
|
|
|
294
297
|
...(spaceId ? { spaceId } : {}),
|
|
295
298
|
};
|
|
296
299
|
|
|
297
|
-
await
|
|
300
|
+
await store.put(taskKey, task);
|
|
298
301
|
if (spaceId) {
|
|
299
302
|
await attachScheduledTaskToSpace({
|
|
300
303
|
userId,
|
|
@@ -308,7 +311,7 @@ export async function runCreateScheduledTaskTool(
|
|
|
308
311
|
let runOnce: Record<string, unknown> | null = null;
|
|
309
312
|
if (boolValue(args.runOnceNow)) {
|
|
310
313
|
const startedAt = Date.now();
|
|
311
|
-
await
|
|
314
|
+
await store.put(taskKey, {
|
|
312
315
|
...task,
|
|
313
316
|
runStatus: "running",
|
|
314
317
|
updatedAt: new Date().toISOString(),
|
|
@@ -322,7 +325,7 @@ export async function runCreateScheduledTaskTool(
|
|
|
322
325
|
task,
|
|
323
326
|
startedAt,
|
|
324
327
|
});
|
|
325
|
-
await
|
|
328
|
+
await store.put(taskKey, {
|
|
326
329
|
...task,
|
|
327
330
|
runStatus: "done",
|
|
328
331
|
nextRunAt: result.nextRunAt ?? nextRunAt,
|
|
@@ -341,7 +344,7 @@ export async function runCreateScheduledTaskTool(
|
|
|
341
344
|
};
|
|
342
345
|
} catch (err: any) {
|
|
343
346
|
const errorMessage = err?.message ?? String(err);
|
|
344
|
-
await
|
|
347
|
+
await store.put(taskKey, {
|
|
345
348
|
...task,
|
|
346
349
|
runStatus: "failed",
|
|
347
350
|
lastRunAt: startedAt,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AgentRunRequest, ChatMessage } from "./types";
|
|
2
|
+
import { normalizeAgentRunDialogLineage } from "../../../ai/agent/agentRunDialogLineage";
|
|
2
3
|
|
|
3
4
|
const MAX_AGENT_RUN_TIMEOUT_MS = 30 * 60 * 1000;
|
|
4
5
|
|
|
5
6
|
export interface ParsedAgentRunRequest {
|
|
6
|
-
body: AgentRunRequest;
|
|
7
7
|
requestedAgentKey: string;
|
|
8
8
|
userInput: AgentRunRequest["userInput"];
|
|
9
|
-
|
|
9
|
+
requestHistory: ChatMessage[];
|
|
10
10
|
stream: boolean;
|
|
11
11
|
runtimeContext: AgentRunRequest["runtimeContext"];
|
|
12
12
|
effectiveMaxRounds: number;
|
|
@@ -38,7 +38,7 @@ export function parseAgentRunRequestBody(body: unknown): AgentRunRequestParseRes
|
|
|
38
38
|
const {
|
|
39
39
|
agentKey: requestedAgentKey,
|
|
40
40
|
userInput,
|
|
41
|
-
messages:
|
|
41
|
+
messages: requestHistory = [],
|
|
42
42
|
stream = false,
|
|
43
43
|
runtimeContext,
|
|
44
44
|
maxRounds,
|
|
@@ -53,6 +53,11 @@ export function parseAgentRunRequestBody(body: unknown): AgentRunRequestParseRes
|
|
|
53
53
|
continueDialogId,
|
|
54
54
|
timeoutMs,
|
|
55
55
|
} = request;
|
|
56
|
+
const dialogLineage = normalizeAgentRunDialogLineage({
|
|
57
|
+
continueDialogId,
|
|
58
|
+
inheritedFromDialogKey,
|
|
59
|
+
parentDialogId,
|
|
60
|
+
});
|
|
56
61
|
|
|
57
62
|
if (!requestedAgentKey) {
|
|
58
63
|
return { ok: false, error: { message: "agentKey is required", status: 400 } };
|
|
@@ -64,22 +69,21 @@ export function parseAgentRunRequestBody(body: unknown): AgentRunRequestParseRes
|
|
|
64
69
|
return {
|
|
65
70
|
ok: true,
|
|
66
71
|
value: {
|
|
67
|
-
body: request,
|
|
68
72
|
requestedAgentKey,
|
|
69
73
|
userInput,
|
|
70
|
-
|
|
74
|
+
requestHistory,
|
|
71
75
|
stream,
|
|
72
76
|
runtimeContext,
|
|
73
77
|
effectiveMaxRounds: maxRounds ?? 12,
|
|
74
78
|
background,
|
|
75
79
|
spaceId,
|
|
76
80
|
category,
|
|
77
|
-
inheritedFromDialogKey,
|
|
78
|
-
parentDialogId,
|
|
81
|
+
inheritedFromDialogKey: dialogLineage.inheritedFromDialogKey,
|
|
82
|
+
parentDialogId: dialogLineage.parentDialogId,
|
|
79
83
|
runtimeProfile,
|
|
80
84
|
runtimeOptions,
|
|
81
85
|
debugContextLayers,
|
|
82
|
-
continueDialogId,
|
|
86
|
+
continueDialogId: dialogLineage.continueDialogId,
|
|
83
87
|
effectiveAgentRunTimeoutMs: normalizeAgentRunTimeoutMs(timeoutMs),
|
|
84
88
|
},
|
|
85
89
|
};
|
|
@@ -10,7 +10,11 @@ type RuntimeExecutionContextOptions = {
|
|
|
10
10
|
spaceId?: string | null;
|
|
11
11
|
runtimeProfile?: any;
|
|
12
12
|
existingDialogRecord: any | null;
|
|
13
|
-
|
|
13
|
+
runtimeEntrypointBlock?: string | null;
|
|
14
|
+
taskRunPreflightBlock?: string | null;
|
|
15
|
+
referenceRuntimeBlock?: string | null;
|
|
16
|
+
conversationReferenceBlock?: string | null;
|
|
17
|
+
editingContextBlock?: string | null;
|
|
14
18
|
loadUserSettings(userId: string): Promise<any>;
|
|
15
19
|
resolveRuntimePolicy(args: {
|
|
16
20
|
agentConfig: any;
|
|
@@ -38,6 +42,11 @@ type RuntimeExecutionContextOptions = {
|
|
|
38
42
|
agentId: string;
|
|
39
43
|
agentPrompt: string;
|
|
40
44
|
tools: string[];
|
|
45
|
+
runtimeEntrypointBlock?: string | null;
|
|
46
|
+
taskRunPreflightBlock?: string | null;
|
|
47
|
+
referenceRuntimeBlock?: string | null;
|
|
48
|
+
conversationReferenceBlock?: string | null;
|
|
49
|
+
editingContextBlock?: string | null;
|
|
41
50
|
autonomousRuntimeBlock: any;
|
|
42
51
|
userPolicyContext: string;
|
|
43
52
|
memoryPromptBlock: any;
|
|
@@ -45,7 +54,6 @@ type RuntimeExecutionContextOptions = {
|
|
|
45
54
|
buildAgentRunUserMessageContent(
|
|
46
55
|
userInput: AgentRunRequest["userInput"],
|
|
47
56
|
turnInstruction?: string | null,
|
|
48
|
-
prelude?: string | null,
|
|
49
57
|
): ChatMessage["content"];
|
|
50
58
|
canonicalizeToolNames(toolNames: string[]): string[];
|
|
51
59
|
prioritizeToolNames(toolNames: string[], preferredToolNames: string[]): string[];
|
|
@@ -122,6 +130,11 @@ export async function prepareAgentRunExecutionContext(
|
|
|
122
130
|
agentId: agentConfig.dbKey ?? options.agentKey,
|
|
123
131
|
agentPrompt: agentConfig.prompt,
|
|
124
132
|
tools: agentConfig.tools ?? [],
|
|
133
|
+
runtimeEntrypointBlock: options.runtimeEntrypointBlock,
|
|
134
|
+
taskRunPreflightBlock: options.taskRunPreflightBlock,
|
|
135
|
+
referenceRuntimeBlock: options.referenceRuntimeBlock,
|
|
136
|
+
conversationReferenceBlock: options.conversationReferenceBlock,
|
|
137
|
+
editingContextBlock: options.editingContextBlock,
|
|
125
138
|
autonomousRuntimeBlock: autonomousRuntime.block,
|
|
126
139
|
userPolicyContext,
|
|
127
140
|
memoryPromptBlock: memoryRuntime.promptBlock,
|
|
@@ -130,7 +143,6 @@ export async function prepareAgentRunExecutionContext(
|
|
|
130
143
|
const modelUserInput = options.buildAgentRunUserMessageContent(
|
|
131
144
|
options.userInput,
|
|
132
145
|
autonomousRuntime.turnInstruction,
|
|
133
|
-
options.taskRunPreflightPrompt,
|
|
134
146
|
);
|
|
135
147
|
const messages: ChatMessage[] = [
|
|
136
148
|
...runtimeSystemMessages,
|
|
@@ -31,10 +31,11 @@ type RuntimePreparationOptions = {
|
|
|
31
31
|
runtimeOptions: any;
|
|
32
32
|
parentDialogId?: string;
|
|
33
33
|
inheritedFromDialogKey?: string;
|
|
34
|
+
includeConversationReference?: boolean;
|
|
34
35
|
resolveReferenceRuntime(
|
|
35
36
|
references: ReferenceItem[],
|
|
36
37
|
): Promise<ReferenceRuntimeResolution>;
|
|
37
|
-
|
|
38
|
+
buildConversationReferenceBlock(args: {
|
|
38
39
|
dialogKey?: string;
|
|
39
40
|
parentDialogId?: string;
|
|
40
41
|
}): Promise<string | undefined>;
|
|
@@ -138,11 +139,18 @@ export async function prepareAgentRunRuntimeConfig(
|
|
|
138
139
|
const referenceRuntime = await options.resolveReferenceRuntime(
|
|
139
140
|
options.agentConfig.references ?? [],
|
|
140
141
|
);
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
const conversationReferenceDraft =
|
|
143
|
+
options.includeConversationReference === false
|
|
144
|
+
? undefined
|
|
145
|
+
: await options.buildConversationReferenceBlock({
|
|
146
|
+
dialogKey: options.inheritedFromDialogKey,
|
|
147
|
+
parentDialogId: options.parentDialogId,
|
|
148
|
+
});
|
|
149
|
+
const runtimeEntrypointBlock =
|
|
150
|
+
buildRuntimeContextPrompt(normalizedRuntimeContext);
|
|
151
|
+
const taskRunPreflightBlock = options.taskRunPreflightPrompt?.trim();
|
|
152
|
+
const referenceRuntimeBlock = referenceRuntime.promptBlock?.trim();
|
|
153
|
+
const conversationReferenceBlock = conversationReferenceDraft?.trim();
|
|
146
154
|
|
|
147
155
|
let agentConfig = {
|
|
148
156
|
...options.agentConfig,
|
|
@@ -159,33 +167,27 @@ export async function prepareAgentRunRuntimeConfig(
|
|
|
159
167
|
recommendedSkillTools: referenceRuntime.recommendedTools,
|
|
160
168
|
recommendedSkillHints: referenceRuntime.recommendedSkillHints,
|
|
161
169
|
skillPromptPatches: referenceRuntime.skillPromptPatches,
|
|
162
|
-
prompt:
|
|
163
|
-
options.agentConfig.prompt?.trim(),
|
|
164
|
-
buildRuntimeContextPrompt(normalizedRuntimeContext),
|
|
165
|
-
options.taskRunPreflightPrompt,
|
|
166
|
-
referenceRuntime.promptBlock?.trim(),
|
|
167
|
-
inheritedDialogPromptBlock?.trim(),
|
|
168
|
-
]
|
|
169
|
-
.filter((item): item is string => typeof item === "string" && !!item)
|
|
170
|
-
.join("\n\n"),
|
|
170
|
+
prompt: options.agentConfig.prompt?.trim() ?? "",
|
|
171
171
|
runtimePromptAlreadyInMessages: true,
|
|
172
|
+
runtimeEntrypointBlock,
|
|
173
|
+
taskRunPreflightBlock,
|
|
174
|
+
referenceRuntimeBlock,
|
|
175
|
+
conversationReferenceBlock,
|
|
172
176
|
};
|
|
173
177
|
|
|
174
178
|
const serverEditingContext = (
|
|
175
179
|
options.buildEditingContextSummary ?? buildCanvasNodeEditingContextSummary
|
|
176
180
|
)(options.runtimeOptions);
|
|
181
|
+
const editingContextBlock = serverEditingContext
|
|
182
|
+
? [
|
|
183
|
+
"当前轮次编辑上下文(Runtime Editing Context):",
|
|
184
|
+
serverEditingContext,
|
|
185
|
+
].join("\n")
|
|
186
|
+
: undefined;
|
|
177
187
|
if (serverEditingContext) {
|
|
178
188
|
agentConfig = {
|
|
179
189
|
...agentConfig,
|
|
180
|
-
|
|
181
|
-
agentConfig.prompt?.trim(),
|
|
182
|
-
[
|
|
183
|
-
"当前轮次编辑上下文(Runtime Editing Context):",
|
|
184
|
-
serverEditingContext,
|
|
185
|
-
].join("\n"),
|
|
186
|
-
]
|
|
187
|
-
.filter((item): item is string => typeof item === "string" && !!item)
|
|
188
|
-
.join("\n\n"),
|
|
190
|
+
editingContextBlock,
|
|
189
191
|
};
|
|
190
192
|
}
|
|
191
193
|
|
|
@@ -1,49 +1,23 @@
|
|
|
1
1
|
import type { MachineRecord } from "../machines/machineRegistry";
|
|
2
2
|
import { serializeMachineSummary } from "../machines/machineRegistry";
|
|
3
3
|
import { resolveRuntimeBinding } from "../machines/machineBinding";
|
|
4
|
-
import {
|
|
5
|
-
extractAgentRuntimeServerBase,
|
|
6
|
-
resolveDelegatedServerBase,
|
|
7
|
-
} from "./toolExecutor";
|
|
8
4
|
import {
|
|
9
5
|
resolveAgentMachineCapabilities,
|
|
10
6
|
resolveAgentRuntimeMachineRoute,
|
|
11
7
|
shouldUseMachineConnector,
|
|
12
8
|
} from "./machineConnector";
|
|
13
9
|
|
|
14
|
-
export type AgentRunDelegationResult =
|
|
15
|
-
| { ok: true; route: "local" }
|
|
16
|
-
| { ok: true; route: "remote"; targetBase: string }
|
|
17
|
-
| { ok: false; status: 400; message: string };
|
|
18
|
-
|
|
19
|
-
export function resolveAgentRunDelegation(args: {
|
|
20
|
-
agentConfig: any;
|
|
21
|
-
serverBase: string;
|
|
22
|
-
}): AgentRunDelegationResult {
|
|
23
|
-
const declaredRuntimeServerBase = extractAgentRuntimeServerBase(args.agentConfig);
|
|
24
|
-
if (!declaredRuntimeServerBase) {
|
|
25
|
-
return { ok: true, route: "local" };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const delegatedTarget = resolveDelegatedServerBase(
|
|
29
|
-
declaredRuntimeServerBase,
|
|
30
|
-
args.serverBase
|
|
31
|
-
);
|
|
32
|
-
if (!delegatedTarget.ok) {
|
|
33
|
-
return { ok: false, status: 400, message: delegatedTarget.error };
|
|
34
|
-
}
|
|
35
|
-
if (delegatedTarget.base !== args.serverBase) {
|
|
36
|
-
return {
|
|
37
|
-
ok: true,
|
|
38
|
-
route: "remote",
|
|
39
|
-
targetBase: delegatedTarget.base,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return { ok: true, route: "local" };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
10
|
export type MachineBindingPreflightResult =
|
|
46
11
|
| { ok: true; route: "unbound" | "bound" }
|
|
12
|
+
| {
|
|
13
|
+
ok: false;
|
|
14
|
+
status: 400;
|
|
15
|
+
body: {
|
|
16
|
+
error: "Invalid runtime binding";
|
|
17
|
+
reason: "bound_machine_missing_owner";
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
47
21
|
| {
|
|
48
22
|
ok: false;
|
|
49
23
|
status: 409;
|
|
@@ -63,16 +37,27 @@ export function resolveMachineBindingPreflight(args: {
|
|
|
63
37
|
return { ok: true, route: "unbound" };
|
|
64
38
|
}
|
|
65
39
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
40
|
+
const route = resolveAgentRuntimeMachineRoute(args.agentConfig);
|
|
41
|
+
if (!route.ok) {
|
|
42
|
+
return {
|
|
43
|
+
ok: false,
|
|
44
|
+
status: route.status,
|
|
45
|
+
body: {
|
|
46
|
+
error: "Invalid runtime binding",
|
|
47
|
+
reason: route.reason,
|
|
48
|
+
message: route.message,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
70
52
|
const bindingResult = resolveRuntimeBinding({
|
|
71
53
|
binding: args.agentConfig.runtimeBinding,
|
|
72
54
|
requiredCapabilities: resolveAgentMachineCapabilities(args.agentConfig),
|
|
73
|
-
machines: args.listMachines(ownerUserId).map(serializeMachineSummary),
|
|
55
|
+
machines: args.listMachines(route.ownerUserId).map(serializeMachineSummary),
|
|
74
56
|
});
|
|
75
57
|
if (!bindingResult.ok) {
|
|
58
|
+
if (bindingResult.reason === "bound_machine_missing_capability") {
|
|
59
|
+
return { ok: true, route: "bound" };
|
|
60
|
+
}
|
|
76
61
|
return {
|
|
77
62
|
ok: false,
|
|
78
63
|
status: 409,
|
|
@@ -53,6 +53,11 @@ export const buildRuntimeSystemMessages = (input: {
|
|
|
53
53
|
agentPrompt?: string | null;
|
|
54
54
|
responseLanguage?: string | null;
|
|
55
55
|
tools?: string[];
|
|
56
|
+
runtimeEntrypointBlock?: string | null;
|
|
57
|
+
taskRunPreflightBlock?: string | null;
|
|
58
|
+
referenceRuntimeBlock?: string | null;
|
|
59
|
+
conversationReferenceBlock?: string | null;
|
|
60
|
+
editingContextBlock?: string | null;
|
|
56
61
|
userPolicyContext?: string | null;
|
|
57
62
|
memoryPromptBlock?: string | null;
|
|
58
63
|
autonomousRuntimeBlock?: string | null;
|
|
@@ -65,6 +70,11 @@ export const buildRuntimeSystemMessageContext = ({
|
|
|
65
70
|
agentPrompt,
|
|
66
71
|
responseLanguage,
|
|
67
72
|
tools,
|
|
73
|
+
runtimeEntrypointBlock,
|
|
74
|
+
taskRunPreflightBlock,
|
|
75
|
+
referenceRuntimeBlock,
|
|
76
|
+
conversationReferenceBlock,
|
|
77
|
+
editingContextBlock,
|
|
68
78
|
userPolicyContext,
|
|
69
79
|
memoryPromptBlock,
|
|
70
80
|
autonomousRuntimeBlock,
|
|
@@ -75,6 +85,11 @@ export const buildRuntimeSystemMessageContext = ({
|
|
|
75
85
|
agentPrompt?: string | null;
|
|
76
86
|
responseLanguage?: string | null;
|
|
77
87
|
tools?: string[];
|
|
88
|
+
runtimeEntrypointBlock?: string | null;
|
|
89
|
+
taskRunPreflightBlock?: string | null;
|
|
90
|
+
referenceRuntimeBlock?: string | null;
|
|
91
|
+
conversationReferenceBlock?: string | null;
|
|
92
|
+
editingContextBlock?: string | null;
|
|
78
93
|
userPolicyContext?: string | null;
|
|
79
94
|
memoryPromptBlock?: string | null;
|
|
80
95
|
autonomousRuntimeBlock?: string | null;
|
|
@@ -129,6 +144,56 @@ export const buildRuntimeSystemMessageContext = ({
|
|
|
129
144
|
cacheScope: "turn",
|
|
130
145
|
content: buildCurrentTimeBlock(now),
|
|
131
146
|
},
|
|
147
|
+
{
|
|
148
|
+
id: "runtime-entrypoint",
|
|
149
|
+
owner: "runtime",
|
|
150
|
+
cacheScope: "turn",
|
|
151
|
+
content:
|
|
152
|
+
typeof runtimeEntrypointBlock === "string" &&
|
|
153
|
+
runtimeEntrypointBlock.trim()
|
|
154
|
+
? runtimeEntrypointBlock.trim()
|
|
155
|
+
: null,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "taskrun-preflight",
|
|
159
|
+
owner: "runtime",
|
|
160
|
+
cacheScope: "turn",
|
|
161
|
+
content:
|
|
162
|
+
typeof taskRunPreflightBlock === "string" &&
|
|
163
|
+
taskRunPreflightBlock.trim()
|
|
164
|
+
? taskRunPreflightBlock.trim()
|
|
165
|
+
: null,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "reference-runtime",
|
|
169
|
+
owner: "runtime",
|
|
170
|
+
cacheScope: "turn",
|
|
171
|
+
content:
|
|
172
|
+
typeof referenceRuntimeBlock === "string" &&
|
|
173
|
+
referenceRuntimeBlock.trim()
|
|
174
|
+
? referenceRuntimeBlock.trim()
|
|
175
|
+
: null,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: "conversation-reference",
|
|
179
|
+
owner: "runtime",
|
|
180
|
+
cacheScope: "turn",
|
|
181
|
+
content:
|
|
182
|
+
typeof conversationReferenceBlock === "string" &&
|
|
183
|
+
conversationReferenceBlock.trim()
|
|
184
|
+
? conversationReferenceBlock.trim()
|
|
185
|
+
: null,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: "editing-context",
|
|
189
|
+
owner: "runtime",
|
|
190
|
+
cacheScope: "turn",
|
|
191
|
+
content:
|
|
192
|
+
typeof editingContextBlock === "string" &&
|
|
193
|
+
editingContextBlock.trim()
|
|
194
|
+
? editingContextBlock.trim()
|
|
195
|
+
: null,
|
|
196
|
+
},
|
|
132
197
|
{
|
|
133
198
|
id: "autonomous-runtime",
|
|
134
199
|
owner: "runtime",
|