nolo-cli 0.1.23 → 0.1.29
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/README.md +25 -3
- package/agent-runtime/dialogStatus.ts +139 -0
- package/agent-runtime/hybridRecordStore.ts +30 -9
- package/agent-runtime/index.ts +8 -0
- package/agent-runtime/localLoop.ts +12 -4
- package/agent-runtime/localToolPolicy.ts +22 -10
- package/agent-runtime/localWorkspaceTools.ts +140 -374
- package/agent-runtime/runtimeToolPolicy.ts +43 -2
- package/agent-runtime/types.ts +5 -0
- package/agentAliases.ts +12 -15
- package/agentCommandSupport.ts +77 -0
- package/agentCreateCustomCommands.ts +273 -0
- package/agentDialogsCommands.ts +226 -0
- package/agentDoctorCommands.ts +203 -0
- package/agentInternalCommandEntries.ts +43 -0
- package/agentListCommands.ts +132 -0
- package/agentListHelpers.ts +187 -0
- package/agentMachineCommands.ts +476 -0
- package/agentPullCommand.ts +9 -9
- package/agentRecordCommands.ts +141 -0
- package/agentRecordHelpers.ts +452 -0
- package/agentRunCommand.ts +35 -411
- package/agentRunLocalWorkspace.ts +182 -0
- package/agentRunParsing.ts +279 -0
- package/agentRuntimeCommands.ts +7 -701
- package/agentSuperviseCommands.ts +8 -0
- package/agentUnpublishCommands.ts +112 -0
- package/ai/agent/_executeModel.ts +42 -16
- package/ai/agent/agentSlice.ts +8 -8
- package/ai/agent/appWorkingMemory.ts +2 -2
- package/ai/agent/avatarUtils.ts +1 -1
- package/ai/agent/buildEditingContext.ts +3 -3
- package/ai/agent/buildSystemPrompt.ts +32 -6
- package/ai/agent/cleanAgentMessages.ts +1 -1
- package/ai/agent/cliChatClient.ts +41 -7
- package/ai/agent/cliExecutor.ts +308 -27
- package/ai/agent/createAgentSchema.ts +3 -3
- package/ai/agent/executeToolCall.ts +2 -2
- package/ai/agent/fetchAgentContexts.ts +3 -3
- package/ai/agent/getFullChatContextKeys.ts +4 -4
- package/ai/agent/guidedCreation/assistant.ts +82 -0
- package/ai/agent/guidedCreation/capabilities.ts +84 -0
- package/ai/agent/guidedCreation/draft.ts +62 -0
- package/ai/agent/guidedCreation/types.ts +38 -0
- package/ai/agent/hooks/fetchPublicAgents.ts +6 -6
- package/ai/agent/hooks/useAgentConfig.ts +49 -21
- package/ai/agent/hooks/useAgentDialog.ts +1 -1
- package/ai/agent/hooks/useAgentFormValidation.ts +9 -9
- package/ai/agent/hooks/usePublicAgents.ts +9 -9
- package/ai/agent/machineRunPermissions.ts +21 -3
- package/ai/agent/persistMessageWithFixedId.ts +4 -4
- package/ai/agent/planSlice.ts +1 -1
- package/ai/agent/referenceUtils.ts +4 -4
- package/ai/agent/runAgentBackground.ts +3 -3
- package/ai/agent/runAgentClientLoop.ts +12 -12
- package/ai/agent/runtimeGuidance.ts +2 -2
- package/ai/agent/server/fetchPublicAgents.ts +12 -7
- package/ai/agent/startParallelAgentStreams.ts +12 -12
- package/ai/agent/streamAgentChatTurn.ts +509 -36
- package/ai/agent/streamAgentChatTurnUtils.ts +22 -22
- package/ai/agent/utils/imageOutput.ts +2 -2
- package/ai/agent/utils/publicImageAgentMode.ts +1 -1
- package/ai/agent/utils/sortUtils.ts +1 -1
- package/ai/agent/web/useGuidedAgentCreation.ts +238 -0
- package/ai/ai.locale.ts +14 -2
- package/ai/chat/fetchUtils.native.ts +2 -2
- package/ai/chat/fetchUtils.ts +2 -2
- package/ai/chat/sendOpenAICompletionsRequest.native.ts +11 -11
- package/ai/chat/sendOpenAICompletionsRequest.ts +40 -15
- package/ai/chat/sendOpenAIResponseRequest.ts +17 -16
- package/ai/chat/shouldUseServerProxy.ts +1 -1
- package/ai/chat/updateTotalUsage.ts +1 -1
- package/ai/context/buildReferenceContext.ts +14 -14
- package/ai/context/calculateContextUsage.ts +1 -1
- package/ai/llm/generateRequestBody.ts +3 -3
- package/ai/llm/getPricing.ts +18 -4
- package/ai/llm/hooks/useModelPricing.ts +2 -2
- package/ai/llm/imagePricing.ts +1 -1
- package/ai/llm/kimi.ts +3 -0
- package/ai/llm/modelAvatar.ts +1 -0
- package/ai/llm/models.ts +3 -3
- package/ai/llm/providers.ts +9 -9
- package/ai/memory/capture.ts +1 -1
- package/ai/memory/consolidate.ts +1 -1
- package/ai/memory/delete.ts +2 -2
- package/ai/memory/query.ts +1 -1
- package/ai/memory/queryShared.ts +1 -1
- package/ai/memory/recentRelationshipRecap.ts +2 -2
- package/ai/memory/remember.ts +1 -1
- package/ai/memory/store.ts +1 -1
- package/ai/memory/storeShared.ts +2 -2
- package/ai/memory/understanding.ts +1 -1
- package/ai/messages/type.ts +1 -1
- package/ai/policy/personalizationDialog.ts +6 -6
- package/ai/policy/runtimePolicy.ts +1 -1
- package/ai/skills/referenceRuntime.ts +1 -1
- package/ai/skills/skillDiagnostics.ts +1 -1
- package/ai/skills/skillDocBuilder.ts +1 -1
- package/ai/skills/skillReferenceSummary.ts +1 -1
- package/ai/skills/skillSummaryMarker.ts +1 -1
- package/ai/taskRun/taskRunProtocol.ts +24 -10
- package/ai/token/calculatePrice.ts +5 -5
- package/ai/token/db.ts +3 -3
- package/ai/token/externalToolCost.ts +4 -4
- package/ai/token/hooks/useRecords.ts +3 -3
- package/ai/token/modelUsageQuery.ts +19 -2
- package/ai/token/openaiImageGenerationUsage.ts +2 -2
- package/ai/token/prepareTokenUsageData.ts +1 -1
- package/ai/token/query.ts +1 -1
- package/ai/token/queryUserTokens.ts +1 -1
- package/ai/token/resolveBillingTarget.ts +1 -1
- package/ai/token/saveTokenRecord.ts +5 -5
- package/ai/token/serverDialogProjection.ts +4 -4
- package/ai/token/serverTokenWriter.ts +3 -3
- package/ai/token/tokenThunks.ts +1 -1
- package/ai/tools/agent/agentTools.ts +21 -0
- package/ai/tools/agent/agentUpdateShared.ts +4 -4
- package/ai/tools/agent/callAgentTool.ts +3 -3
- package/ai/tools/agent/createAgentTool.ts +12 -12
- package/ai/tools/agent/createDialogTool.ts +3 -3
- package/ai/tools/agent/parallelBudget.ts +2 -2
- package/ai/tools/agent/prepareAgentDraftTool.ts +173 -0
- package/ai/tools/agent/presets/appBuilderPreset.ts +1 -1
- package/ai/tools/agent/runLlmTool.ts +1 -1
- package/ai/tools/agent/skillAgentPreset.ts +6 -6
- package/ai/tools/agent/updateAgentTool.ts +4 -4
- package/ai/tools/agent/updateSelfTool.ts +8 -8
- package/ai/tools/appTools.ts +3 -3
- package/ai/tools/category/createCategoryTool.ts +2 -2
- package/ai/tools/category/queryContentsByCategoryTool.ts +2 -2
- package/ai/tools/category/updateContentCategoryTool.ts +2 -2
- package/ai/tools/checkEnvTool.ts +52 -20
- package/ai/tools/convertMarxistsBookTool.ts +103 -0
- package/ai/tools/createDocTool.ts +3 -3
- package/ai/tools/createPlanTool.ts +9 -9
- package/ai/tools/createSkillDocTool.ts +4 -4
- package/ai/tools/createWorkflowTool.ts +2 -2
- package/ai/tools/deleteSpacesTool.ts +5 -5
- package/ai/tools/deleteSpacesToolModel.ts +1 -1
- package/ai/tools/doctorSkillTool.ts +3 -3
- package/ai/tools/evalSkillTool.ts +3 -3
- package/ai/tools/{execBashTool.ts → execShellTool.ts} +44 -161
- package/ai/tools/executeSqlTool.ts +1 -1
- package/ai/tools/geminiImagePreviewTool.ts +9 -9
- package/ai/tools/importDataTool.ts +2 -2
- package/ai/tools/importSkillTool.ts +4 -4
- package/ai/tools/index.ts +61 -14
- package/ai/tools/listUserSpacesTool.ts +2 -2
- package/ai/tools/localFilesTool.ts +85 -9
- package/ai/tools/marxistsOfflineBook.ts +253 -0
- package/ai/tools/modelUsageTools.ts +4 -2
- package/ai/tools/openaiImageTool.ts +9 -9
- package/ai/tools/readDocTool.ts +3 -3
- package/ai/tools/readTool.ts +40 -9
- package/ai/tools/rememberMemoryTool.ts +3 -3
- package/ai/tools/remotionVideoTool.ts +7 -7
- package/ai/tools/searchDialogMessagesTool.ts +2 -2
- package/ai/tools/searchWorkspaceTool.ts +4 -4
- package/ai/tools/table/addTableRowTool.ts +2 -2
- package/ai/tools/table/createTableTool.ts +2 -2
- package/ai/tools/table/rowTools.ts +2 -2
- package/ai/tools/table/schemaTools.ts +3 -3
- package/ai/tools/table/shareTableTool.ts +5 -5
- package/ai/tools/table/toolShared.ts +6 -6
- package/ai/tools/toolApiClient.ts +49 -6
- package/ai/tools/toolNameAliases.ts +13 -0
- package/ai/tools/toolRunSlice.ts +2 -2
- package/ai/tools/updateContentTitleTool.ts +2 -2
- package/ai/tools/updateDocTool.ts +7 -7
- package/ai/tools/updateUserPreferenceProfileTool.ts +3 -3
- package/ai/workflow/workflowExecutor.ts +3 -3
- package/ai/workflow/workflowSlice.ts +1 -1
- package/app/actions/syncAppRecord.ts +73 -0
- package/app/admin/adminPages.ts +13 -0
- package/app/colors.ts +1 -0
- package/app/constants/animationSets.ts +21 -0
- package/app/constants/appEditor.ts +99 -0
- package/app/constants/clientDownloads.ts +54 -0
- package/app/constants/desktopReleaseManifest.ts +68 -0
- package/app/constants/homeTabs.ts +15 -0
- package/app/constants/routePaths.ts +15 -0
- package/app/email/emailApiRoutes.ts +14 -0
- package/app/favorite/favoriteSlice.ts +690 -0
- package/app/favorite/type.ts +43 -0
- package/app/favorite/useAgentFavorite.ts +43 -0
- package/app/favorite/useContentFavorite.ts +41 -0
- package/app/fetchOwnedApps.ts +269 -0
- package/app/guide/quickStartGuide.ts +128 -0
- package/app/hooks/deleteDbKey.ts +233 -0
- package/app/hooks/index.ts +4 -0
- package/app/hooks/useAppDetail.ts +208 -0
- package/app/hooks/useAppVersions.ts +52 -0
- package/app/hooks/useAutoResizeTextarea.ts +29 -0
- package/app/hooks/useChatPageTitle.ts +85 -0
- package/app/hooks/useClipboardFiles.ts +20 -0
- package/app/hooks/useDesktopLocalConnectorAutostart.ts +38 -0
- package/app/hooks/useDragResize.ts +91 -0
- package/app/hooks/useElementSizeVar.ts +24 -0
- package/app/hooks/useFileDropZone.ts +52 -0
- package/app/hooks/useHasMounted.ts +11 -0
- package/app/hooks/useImageLoadFallback.ts +19 -0
- package/app/hooks/useIsMobile.ts +46 -0
- package/app/hooks/useMyApps.ts +375 -0
- package/app/hooks/useMyContentItems.ts +91 -0
- package/app/hooks/useNewMessageNotification.ts +81 -0
- package/app/hooks/usePageMeta.ts +107 -0
- package/app/hooks/useRecentlyOpened.ts +84 -0
- package/app/hooks/useUnifiedStore.ts +11 -0
- package/app/hooks/useUserNotifications.ts +197 -0
- package/app/hooks.ts +55 -0
- package/app/i18n/clientResources.ts +65 -0
- package/app/i18n/i18n.base.ts +14 -0
- package/app/i18n/i18n.config.ts +62 -0
- package/app/i18n/i18n.server.ts +13 -0
- package/app/i18n/index.ts +15 -0
- package/app/i18n/mapLanguage.ts +11 -0
- package/app/i18n/translations/appBuilder.locale.ts +453 -0
- package/app/i18n/translations/error.locale.ts +246 -0
- package/app/i18n/translations/interface.locale.ts +2174 -0
- package/app/i18n/translations/seo.locale.ts +129 -0
- package/app/i18n/types.ts +6 -0
- package/app/notifications/formatNotification.ts +134 -0
- package/app/notifications/model.ts +77 -0
- package/app/notifications/notificationSlice.ts +141 -0
- package/app/notifications/useNotificationActions.ts +67 -0
- package/app/pages/homeTabState.ts +57 -0
- package/app/pages/quickChatFlow.ts +109 -0
- package/app/pages/rechargeCheckout.ts +23 -0
- package/app/pages/usePageArt.ts +91 -0
- package/app/realtime/sharedSse.ts +182 -0
- package/app/reducer.ts +36 -0
- package/app/seo/pageMeta.ts +123 -0
- package/app/settings/config.ts +54 -0
- package/app/settings/dbActionThunks.ts +34 -0
- package/app/settings/defaultSpacePreference.ts +87 -0
- package/app/settings/navItems.ts +73 -0
- package/app/settings/prepareUserSetting.ts +11 -0
- package/app/settings/settingsRecord.ts +8 -0
- package/app/settings/web/chat-config/useAutoSaveGlobalPrompt.ts +59 -0
- package/app/settings/web/machineStatus.ts +23 -0
- package/app/settings/web/useSettingsStylesheet.ts +28 -0
- package/app/settings/web/userSecurityUtils.ts +21 -0
- package/app/stateViews/runtime.ts +86 -0
- package/app/store.ts +53 -0
- package/app/theme/colors.ts +280 -0
- package/app/theme/fontPreference.ts +77 -0
- package/app/theme/index.ts +7 -0
- package/app/theme/theme.config.ts +120 -0
- package/app/theme/themeModeBootstrap.ts +123 -0
- package/app/theme/useSystemTheme.ts +33 -0
- package/app/types/appSummary.ts +114 -0
- package/app/types.ts +358 -0
- package/app/utils/appDeploySource.ts +50 -0
- package/app/utils/appKeys.ts +55 -0
- package/app/utils/appRuntimeUrl.ts +51 -0
- package/app/utils/async.ts +28 -0
- package/app/utils/asyncMapStatus.ts +31 -0
- package/app/utils/clipboard.ts +86 -0
- package/app/utils/credits.ts +12 -0
- package/app/utils/desktopAgentRuntimeStatusClient.ts +42 -0
- package/app/utils/desktopAgentRuntimeTurnClient.ts +70 -0
- package/app/utils/desktopLocalConnectorClient.ts +83 -0
- package/app/utils/env.ts +12 -0
- package/app/utils/excelToSlate.ts +430 -0
- package/app/utils/fileReaders.ts +12 -0
- package/app/utils/fileUtils.ts +229 -0
- package/app/utils/imageUtils.native.ts +96 -0
- package/app/utils/imageUtils.ts +244 -0
- package/app/utils/ime.ts +43 -0
- package/app/utils/myContentItems.ts +290 -0
- package/app/utils/processDateRange.ts +30 -0
- package/app/utils/retryFetch.ts +61 -0
- package/app/utils/slateToExcel.ts +58 -0
- package/app/utils/toast.native.ts +42 -0
- package/app/utils/toast.ts +3 -0
- package/app/web/spaceInitGuard.ts +28 -0
- package/auth/action/signOutAction.ts +0 -0
- package/auth/action/signUpAction.ts +227 -0
- package/auth/actor.ts +16 -0
- package/auth/authSlice.ts +517 -0
- package/auth/billing.ts +130 -0
- package/auth/client/deleteUserRequest.ts +86 -0
- package/auth/client/loginRequest.ts +14 -0
- package/auth/hooks/useAuth.ts +9 -0
- package/auth/hooks/useDeleteOwnAccount.ts +50 -0
- package/auth/hooks/useDeleteOwnAccountFlow.ts +66 -0
- package/auth/hooks/useDeleteUser.ts +45 -0
- package/auth/hooks/useEnableUser.ts +50 -0
- package/auth/hooks/useFetchUsers.ts +77 -0
- package/auth/hooks/useRechargeUser.ts +82 -0
- package/auth/index.ts +1 -0
- package/auth/invite.ts +19 -0
- package/auth/locale.ts +84 -0
- package/auth/resetAuthScopedClientState.ts +27 -0
- package/auth/rn/tokenManager.ts +72 -0
- package/auth/routes.ts +127 -0
- package/auth/server/accessActivity.ts +143 -0
- package/auth/server/billingFullChainSimulator.ts +325 -0
- package/auth/server/billingUsageReport.ts +192 -0
- package/auth/server/cliLogin.ts +198 -0
- package/auth/server/creatorEarningCreditConversion.ts +515 -0
- package/auth/server/creatorEarningsLedger.ts +165 -0
- package/auth/server/creatorEarningsReport.ts +299 -0
- package/auth/server/creatorSettlementLedger.ts +386 -0
- package/auth/server/creatorSettlementReport.ts +442 -0
- package/auth/server/creatorSplitConfig.ts +191 -0
- package/auth/server/deduct.ts +270 -0
- package/auth/server/delete.ts +887 -0
- package/auth/server/disable.ts +61 -0
- package/auth/server/emailAutomation.ts +358 -0
- package/auth/server/emailAutomationConfig.ts +88 -0
- package/auth/server/emailAutomationRules.ts +94 -0
- package/auth/server/emailAutomationTemplates.ts +131 -0
- package/auth/server/emailAutomationTypes.ts +38 -0
- package/auth/server/emailDbConfig.ts +147 -0
- package/auth/server/emailDelivery.ts +960 -0
- package/auth/server/emailDeliveryGuards.ts +282 -0
- package/auth/server/emailPolicy.ts +43 -0
- package/auth/server/emailPreferences.ts +117 -0
- package/auth/server/emailProvider.ts +277 -0
- package/auth/server/emailReport.ts +439 -0
- package/auth/server/emailRuntimeConfig.ts +86 -0
- package/auth/server/emailScenarioNotifications.ts +340 -0
- package/auth/server/enable.ts +61 -0
- package/auth/server/getRechargeHistory.ts +110 -0
- package/auth/server/getUser.ts +71 -0
- package/auth/server/inviteReward.ts +295 -0
- package/auth/server/inviteRewardEmail.ts +1 -0
- package/auth/server/ledger.ts +422 -0
- package/auth/server/ledgerAudit.ts +424 -0
- package/auth/server/ledgerWitness.ts +472 -0
- package/auth/server/listusers.ts +154 -0
- package/auth/server/locks.ts +32 -0
- package/auth/server/login.ts +184 -0
- package/auth/server/productBillingSplits.ts +166 -0
- package/auth/server/productEntitlements.ts +139 -0
- package/auth/server/productPurchase.ts +382 -0
- package/auth/server/recharge.ts +284 -0
- package/auth/server/revenueShareLedger.ts +389 -0
- package/auth/server/revenueShareReport.ts +258 -0
- package/auth/server/revenueSplitPolicy.ts +119 -0
- package/auth/server/revokeSessions.ts +59 -0
- package/auth/server/route.ts +195 -0
- package/auth/server/sendEmail.ts +176 -0
- package/auth/server/shared.ts +51 -0
- package/auth/server/signup.ts +423 -0
- package/auth/server/signupIpQuota.ts +44 -0
- package/auth/server/token.ts +109 -0
- package/auth/server/tokenUsageBilling.ts +312 -0
- package/auth/server/transfer.ts +40 -0
- package/auth/server/utils.ts +200 -0
- package/auth/sessionTokenVersion.ts +38 -0
- package/auth/token.ts +63 -0
- package/auth/tokenCookie.ts +1 -0
- package/auth/types.ts +28 -0
- package/auth/utils.ts +108 -0
- package/auth/web/bootstrapAuthState.ts +60 -0
- package/auth/web/tokenManager.ts +61 -0
- package/auth/web/useRegister.ts +70 -0
- package/build.ts +16 -0
- package/buildPublish.ts +133 -0
- package/buildPublishArtifactAssembly.ts +346 -0
- package/buildPublishImportAnalysis.ts +237 -0
- package/chat/chat.locale.ts +804 -0
- package/chat/dialog/actions/addCybotAction.ts +52 -0
- package/chat/dialog/actions/addReferenceKeysAction.ts +62 -0
- package/chat/dialog/actions/builtinDialogLlm.ts +35 -0
- package/chat/dialog/actions/cleanupCliSession.ts +40 -0
- package/chat/dialog/actions/compactDialogAndForkAction.ts +47 -0
- package/chat/dialog/actions/createDialogAction.ts +372 -0
- package/chat/dialog/actions/createScheduledTaskAction.ts +78 -0
- package/chat/dialog/actions/handleSendMessageAction.ts +197 -0
- package/chat/dialog/actions/handleSendMessageResolver.ts +29 -0
- package/chat/dialog/actions/removeCybotAction.ts +6 -0
- package/chat/dialog/actions/removeDialogAgentAction.ts +44 -0
- package/chat/dialog/actions/replacePrimaryCybotAction.ts +6 -0
- package/chat/dialog/actions/setPrimaryDialogAgentAction.ts +52 -0
- package/chat/dialog/actions/updateDialogSummaryAction.ts +405 -0
- package/chat/dialog/actions/updateDialogTitleAction.ts +151 -0
- package/chat/dialog/actions/updateDialogTitlePolicy.ts +30 -0
- package/chat/dialog/actions/updateTokensAction.ts +233 -0
- package/chat/dialog/dialogAgents.ts +54 -0
- package/chat/dialog/dialogPageRenderMode.ts +182 -0
- package/chat/dialog/dialogSlice.ts +872 -0
- package/chat/dialog/dialogTitle.ts +81 -0
- package/chat/dialog/dialogTokenStats.ts +12 -0
- package/chat/dialog/dialogUrl.ts +6 -0
- package/chat/dialog/ensureDialogSpaceAction.ts +208 -0
- package/chat/dialog/goal.ts +108 -0
- package/chat/dialog/hooks/useStreamingSymbol.ts +63 -0
- package/chat/dialog/objectAssistantRegistry.ts +286 -0
- package/chat/dialog/schedule.ts +17 -0
- package/chat/dialog/useCreateDialog.ts +52 -0
- package/chat/hooks/sendPermissionResolver.ts +128 -0
- package/chat/hooks/useChatInput.ts +99 -0
- package/chat/hooks/useChatInputSeed.ts +31 -0
- package/chat/hooks/useMessageInteraction.ts +412 -0
- package/chat/hooks/useSendPermission.ts +92 -0
- package/chat/hooks/useThinkingVisibility.ts +27 -0
- package/chat/messages/browserImageUrl.ts +48 -0
- package/chat/messages/deleteMessages.ts +47 -0
- package/chat/messages/fetchAndCacheMessages.ts +119 -0
- package/chat/messages/fetchConvMsgs.ts +51 -0
- package/chat/messages/fetchMessages.ts +84 -0
- package/chat/messages/fileUrl.ts +13 -0
- package/chat/messages/generateMessageKey.ts +21 -0
- package/chat/messages/hooks/useBase64Migration.ts +115 -0
- package/chat/messages/messageAgent.ts +8 -0
- package/chat/messages/messageContent.ts +199 -0
- package/chat/messages/messageContract.ts +88 -0
- package/chat/messages/messageSlice.ts +1191 -0
- package/chat/messages/pendingAttachmentParts.ts +117 -0
- package/chat/messages/sendFirstMessage.ts +193 -0
- package/chat/messages/toolPresentation.ts +212 -0
- package/chat/messages/toolThunks.ts +625 -0
- package/chat/messages/types.ts +176 -0
- package/chat/messages/web/ChatDisplayContext.ts +14 -0
- package/chat/messages/web/ToolMessageTypes.ts +23 -0
- package/chat/messages/web/diffViewerModel.ts +61 -0
- package/chat/messages/web/groupToolEntries.ts +44 -0
- package/chat/messages/web/groupToolMessages.ts +35 -0
- package/chat/messages/web/inlineReactArtifactParser.ts +63 -0
- package/chat/messages/web/toolDisplayName.ts +22 -0
- package/chat/messages/web/useLoopStopReason.ts +43 -0
- package/chat/messages/ziweiChartDoc.ts +94 -0
- package/chat/web/docxToSlate.ts +597 -0
- package/chat/web/fileProcessor.ts +442 -0
- package/chat/web/hooks/useProgressiveDisplayCount.ts +102 -0
- package/chat/web/messageInputAgentUi.ts +189 -0
- package/chat/web/messageInputKeyBehavior.ts +53 -0
- package/chat/web/messageInputMention.ts +102 -0
- package/chat/web/messageInputSendResolver.ts +51 -0
- package/chat/web/messageSlashCommands.ts +10 -0
- package/chat/web/pdfOcrProcessor.ts +131 -0
- package/chat/web/sidebar/allViewSearch.ts +87 -0
- package/chat/web/sidebar/types.ts +12 -0
- package/chat/web/sidebar/useChatSidebarFilteredData.ts +141 -0
- package/chat/web/sidebar/useSidebarDragAndDrop.ts +56 -0
- package/cliCommandAdapters.ts +28 -0
- package/cliCommandDispatch.ts +66 -0
- package/cliCommandFactories.ts +66 -0
- package/cliCommandTypes.ts +49 -0
- package/cliEnvHelpers.ts +130 -0
- package/cliIoTypes.ts +3 -0
- package/client/agentRun.test.ts +123 -19
- package/client/agentRun.ts +62 -226
- package/client/agentRunLocalExecution.test.ts +123 -0
- package/client/agentRunLocalExecution.ts +124 -0
- package/client/agentRunRuntimeSelection.test.ts +158 -0
- package/client/agentRunRuntimeSelection.ts +155 -0
- package/client/hybridRecordStore.test.ts +42 -0
- package/client/hybridRecordStore.ts +11 -0
- package/client/localRuntimeAdapter.test.ts +189 -21
- package/client/localRuntimeAdapter.ts +84 -8
- package/client/localRuntimeDryRun.test.ts +5 -2
- package/client/profileConfig.test.ts +66 -0
- package/client/profileConfig.ts +41 -0
- package/client/streamingOutput.ts +1 -3
- package/client/taskRunPrompt.ts +7 -23
- package/commandRegistry.ts +13 -63
- package/connector-experimental/capabilities.ts +1 -0
- package/connector-experimental/daemonLauncher.ts +189 -0
- package/core/builtinAgents.ts +58 -0
- package/core/coin.ts +42 -0
- package/core/config.ts +15 -0
- package/core/crypto.ts +51 -0
- package/core/events/types.ts +145 -0
- package/core/generateKeyPairFromSeedV1.ts +15 -0
- package/core/generateMainKey.ts +22 -0
- package/core/init.ts +41 -0
- package/core/localOrigins.ts +8 -0
- package/core/password.ts +13 -0
- package/core/prefix.ts +23 -0
- package/create/editor/blockCommands.ts +118 -0
- package/create/editor/highlightExample.ts +66 -0
- package/create/editor/imageUpload.ts +66 -0
- package/create/editor/mark.ts +15 -0
- package/create/editor/plugins/normalizeChineseTypography.ts +85 -0
- package/create/editor/plugins/withBlockStructure.ts +53 -0
- package/create/editor/plugins/withChineseTypography.ts +61 -0
- package/create/editor/plugins/withLayout.ts +30 -0
- package/create/editor/plugins/withLinks.ts +13 -0
- package/create/editor/plugins/withMentions.ts +15 -0
- package/create/editor/plugins/withTables.ts +52 -0
- package/create/editor/tableCommands.ts +270 -0
- package/create/editor/theme/prism/default.ts +145 -0
- package/create/editor/theme/prism/githubDark.ts +139 -0
- package/create/editor/theme/prism/githubLight.ts +139 -0
- package/create/editor/theme/prism/index.ts +23 -0
- package/create/editor/theme/prism/okaidia.ts +197 -0
- package/create/editor/toolMentionOptions.ts +19 -0
- package/create/editor/transforms/fromMarkdown/index.ts +260 -0
- package/create/editor/transforms/fromMarkdown/inline.ts +285 -0
- package/create/editor/transforms/fromMarkdown/table.ts +130 -0
- package/create/editor/transforms/markdownToSlate.ts +24 -0
- package/create/editor/transforms/slateToRenderMarkdown.ts +218 -0
- package/create/editor/transforms/slateToSimplifiedMarkdown.ts +224 -0
- package/create/editor/transforms/slateToText.ts +33 -0
- package/create/editor/types.ts +120 -0
- package/create/editor/utils/editorFactory.ts +54 -0
- package/create/editor/utils/hasPlainCodeBlock.ts +39 -0
- package/create/editor/utils/linkCommands.ts +63 -0
- package/create/editor/utils/pdfToSlate.ts +706 -0
- package/create/editor/utils/slateUtils.ts +233 -0
- package/create/editor/utils/txtToSlate.ts +40 -0
- package/create/hooks/category.ts +82 -0
- package/create/routePaths.ts +5 -0
- package/create/space/addSpaceAction.ts +193 -0
- package/create/space/category/categoryActions.ts +427 -0
- package/create/space/changeSpaceAction.ts +36 -0
- package/create/space/constants.ts +8 -0
- package/create/space/content/addContentAction.ts +116 -0
- package/create/space/content/contentThunks.ts +90 -0
- package/create/space/content/deleteContentFromSpaceAction.ts +187 -0
- package/create/space/content/deleteMultipleContentAction.ts +112 -0
- package/create/space/content/moveContentAction.ts +285 -0
- package/create/space/content/updateContentCategoryAction.ts +154 -0
- package/create/space/content/updateContentTitleAction.ts +106 -0
- package/create/space/content/uploadAndAddFileToSpaceAction.ts +98 -0
- package/create/space/contentKeyUtils.ts +117 -0
- package/create/space/contentLabels.ts +56 -0
- package/create/space/contentTypeMeta.ts +169 -0
- package/create/space/deleteSpaceAction.ts +276 -0
- package/create/space/fetchSpaceAction.ts +70 -0
- package/create/space/fetchSpaceSidebarStateAction.ts +26 -0
- package/create/space/hooks/agentFetchRetry.ts +19 -0
- package/create/space/hooks/useAgentFetcher.ts +149 -0
- package/create/space/hooks/useGroupedContent.ts +118 -0
- package/create/space/hooks/useSpaceEvents.ts +43 -0
- package/create/space/initialSpace.ts +78 -0
- package/create/space/loadDefaultSpaceAction.ts +57 -0
- package/create/space/member/addMemberAction.ts +79 -0
- package/create/space/member/fetchUserSpaceMembershipsAction.ts +386 -0
- package/create/space/member/memberThunks.ts +47 -0
- package/create/space/member/removeMemberAction.ts +67 -0
- package/create/space/publicCatalogSpace.ts +39 -0
- package/create/space/resolvePreferredSpaceId.ts +113 -0
- package/create/space/sidebarVisibleTypes.ts +214 -0
- package/create/space/space.locale.ts +981 -0
- package/create/space/spaceAccess.ts +182 -0
- package/create/space/spaceCollapsedState.ts +54 -0
- package/create/space/spaceKeys.ts +65 -0
- package/create/space/spaceSlice.ts +328 -0
- package/create/space/spaceThunks.ts +410 -0
- package/create/space/types.ts +27 -0
- package/create/space/updateSpaceAction.ts +107 -0
- package/create/space/utils/permissions.ts +47 -0
- package/create/space/validateSpacePermission.ts +38 -0
- package/create/types.ts +21 -0
- package/create/version/appVersionReplication.ts +160 -0
- package/create/version/versionApi.ts +142 -0
- package/customCodingAgentFlow.ts +208 -0
- package/customCodingAgentRecord.ts +179 -0
- package/database/actions/agentReadResolution.ts +33 -0
- package/database/actions/cacheMergedUserData.ts +1 -1
- package/database/actions/common.ts +44 -8
- package/database/actions/fetchUserData.ts +1 -1
- package/database/actions/fileContent.ts +3 -3
- package/database/actions/patch.ts +3 -3
- package/database/actions/read.ts +115 -76
- package/database/actions/readAndWait.ts +54 -86
- package/database/actions/readOutcome.ts +45 -0
- package/database/actions/readResolution.ts +102 -0
- package/database/actions/remove.ts +2 -2
- package/database/actions/upload.ts +4 -4
- package/database/actions/upsert.ts +2 -2
- package/database/actions/write.ts +4 -4
- package/database/client/handleError.ts +1 -1
- package/database/client/queryRequest.ts +1 -1
- package/database/dbSlice.ts +2 -2
- package/database/email.ts +1 -1
- package/database/hooks/useUserData.ts +4 -4
- package/database/keys.ts +2 -2
- package/database/runtimeServerContext.ts +3 -3
- package/database/server/actorAccess.ts +1 -1
- package/database/server/coreDataProxy.ts +43 -26
- package/database/server/cybotReadonly.ts +1 -1
- package/database/server/dataHandlers.ts +1 -1
- package/database/server/delete.ts +8 -8
- package/database/server/emailRepository.ts +7 -7
- package/database/server/fileService.ts +1 -1
- package/database/server/handleTransaction.ts +2 -2
- package/database/server/patch.ts +3 -3
- package/database/server/read.ts +5 -5
- package/database/server/resourceAccess.ts +2 -2
- package/database/server/routes.ts +3 -3
- package/database/server/write.ts +5 -5
- package/database/table/deleteTable.ts +1 -1
- package/database/userPreferenceRegister.ts +2 -2
- package/dialogDataAccess.ts +186 -0
- package/dialogInternalCommandEntries.ts +11 -0
- package/dialogReadCommands.ts +179 -0
- package/dialogReadHelpers.ts +226 -0
- package/dialogStatusCommands.ts +122 -0
- package/docInternalCommandEntries.ts +20 -0
- package/hybridReadHelpers.ts +109 -0
- package/index.ts +56 -197
- package/integrations/anthropic/anthropicModels.ts +47 -0
- package/integrations/anthropic/type.ts +41 -0
- package/integrations/deepseek/models.ts +67 -0
- package/integrations/google/models.ts +298 -0
- package/integrations/openai/chatCompletionStreamMode.ts +10 -0
- package/integrations/openai/filterAndCleanMessages.ts +284 -0
- package/integrations/openai/flexTier.ts +102 -0
- package/integrations/openai/generateOpenAIRequestBody.ts +274 -0
- package/integrations/openai/generateResponseRequestBody.ts +77 -0
- package/integrations/openai/models.ts +271 -0
- package/integrations/openai/providerBodyCompatibility.ts +23 -0
- package/integrations/openai/responsesHelpers.ts +297 -0
- package/integrations/postmark/index.ts +57 -0
- package/integrations/resend/index.ts +353 -0
- package/integrations/weather/getWeather.ts +24 -0
- package/integrations/weather/index.ts +6 -0
- package/integrations/weather/routes.ts +31 -0
- package/integrations/weather/weatherApi.ts +27 -0
- package/integrations/weather/weatherConstants.ts +2 -0
- package/integrations/weather/weatherI18n.ts +50 -0
- package/integrations/weather/weatherService.ts +50 -0
- package/integrations/weather/weatherTypes.ts +140 -0
- package/integrations/weather/weatherUtils.ts +46 -0
- package/integrations/x-reader/backends/localBrowser.ts +215 -0
- package/integrations/x-reader/backends/publicFallback.ts +31 -0
- package/integrations/x-reader/backends/rawCdp.ts +218 -0
- package/integrations/x-reader/bridge/chromeBridgeManager.ts +235 -0
- package/integrations/x-reader/bridge/readXPostWithBridge.ts +73 -0
- package/integrations/x-reader/fixtureParser.ts +101 -0
- package/integrations/x-reader/index.ts +9 -0
- package/integrations/x-reader/redaction.ts +27 -0
- package/integrations/x-reader/types.ts +109 -0
- package/integrations/x-reader/visibleTextParser.ts +108 -0
- package/integrations/xai/models.ts +13 -0
- package/internalCommandEntries.ts +20 -0
- package/machineCommandPrompts.ts +77 -0
- package/machineCommandResolution.ts +43 -0
- package/machineCommands.ts +104 -853
- package/machineDaemonCommands.ts +29 -0
- package/machineHeartbeatCommands.ts +29 -0
- package/machineStatusCommands.ts +95 -0
- package/machineWatchCommands.ts +41 -0
- package/machineWsPromptMaterialization.ts +89 -0
- package/machineWsRunDispatch.ts +570 -0
- package/machineWsSession.ts +148 -0
- package/package.json +126 -4
- package/pageCreateCommands.ts +219 -0
- package/pageDeleteCommands.ts +167 -0
- package/pageReadCommands.ts +151 -0
- package/pageUpdateCommands.ts +249 -0
- package/pageWriteHelpers.ts +209 -0
- package/publishPackage.ts +36 -0
- package/render/canvas/canvasEditContext.ts +1 -1
- package/render/layout/mainLayoutViewMode.ts +1 -1
- package/render/page/createPageAction.ts +12 -12
- package/render/page/docSlice.ts +8 -8
- package/render/page/server/createPage.ts +7 -7
- package/render/page/server/handleCreatePage.ts +2 -2
- package/render/page/types.ts +2 -2
- package/render/surf/utils/groupedWeatherData.ts +1 -1
- package/render/table/createTableAction.ts +7 -7
- package/render/table/deleteTableAction.ts +4 -4
- package/render/table/fetchAndCacheTableRows.ts +2 -2
- package/render/table/tableSlice.ts +6 -6
- package/render/table/types.ts +1 -1
- package/render/table/useCreateTable.ts +2 -2
- package/render/table/useTable.ts +2 -2
- package/render/table/utils/tableSerialization.ts +1 -1
- package/runtimeDoctorCommands.ts +118 -0
- package/runtimeInternalCommandEntries.ts +15 -0
- package/runtimePassthroughCommands.ts +22 -0
- package/scriptCommandEntries.ts +31 -0
- package/scriptPassthroughHelpers.ts +28 -0
- package/secretScanHelpers.ts +31 -0
- package/server/agentEmailRegistrationRoutes.ts +29 -0
- package/server/agentRunRouteContract.ts +9 -0
- package/server/agentRunRoutes.ts +10 -0
- package/server/api/methods.ts +333 -0
- package/server/api/tableHandlers.ts +55 -0
- package/server/api/types.ts +27 -0
- package/server/apiContract.ts +88 -0
- package/server/apiRouteAdapter.ts +218 -0
- package/server/appBundler.ts +90 -0
- package/server/appRoutes.ts +92 -0
- package/server/artifactIconsRoute.ts +89 -0
- package/server/artifactRuntimeRoute.ts +136 -0
- package/server/authenticateToken.ts +73 -0
- package/server/billingLedgerRoutes.ts +48 -0
- package/server/cliChatRoutes.ts +5 -0
- package/server/cloudflareRoutes.ts +35 -0
- package/server/coreHeaders.ts +29 -0
- package/server/coreReadiness.ts +39 -0
- package/server/coreRoutes.ts +65 -0
- package/server/coreRuntime.ts +93 -0
- package/server/createResponse.ts +68 -0
- package/server/cryptoPaymentRoutes.ts +8 -0
- package/server/databaseRoutes.ts +225 -0
- package/server/desktopRuntimeRoutes.ts +120 -0
- package/server/devBuildInfo.ts +51 -0
- package/server/devReload.ts +161 -0
- package/server/devToolPathPolicy.ts +59 -0
- package/server/devToolRoutes.ts +274 -0
- package/server/email/cloudflareEmailProvider.ts +119 -0
- package/server/email/cloudflareInboundBridge.ts +121 -0
- package/server/email/cloudflareInboundWorker.ts +28 -0
- package/server/email/provider.ts +149 -0
- package/server/email/providerRegistry.ts +22 -0
- package/server/emailInboundRoutes.ts +17 -0
- package/server/entry.ts +211 -0
- package/server/handleRPCRequest.ts +117 -0
- package/server/handlers/activityStatsHandler.ts +74 -0
- package/server/handlers/agentEmailRegistrationE2EHandler.ts +406 -0
- package/server/handlers/agentEmailRegistrationE2ERoutes.ts +6 -0
- package/server/handlers/agentRun/agentLookup.ts +77 -0
- package/server/handlers/agentRun/autonomousRuntime.ts +355 -0
- package/server/handlers/agentRun/backgroundRunDialog.ts +31 -0
- package/server/handlers/agentRun/builtinAgents.ts +347 -0
- package/server/handlers/agentRun/continueDialogContext.ts +90 -0
- package/server/handlers/agentRun/debugContext.ts +58 -0
- package/server/handlers/agentRun/dialogLookup.ts +67 -0
- package/server/handlers/agentRun/foregroundStreamDialog.ts +13 -0
- package/server/handlers/agentRun/index.ts +1630 -0
- package/server/handlers/agentRun/inheritedDialogPrompt.ts +111 -0
- package/server/handlers/agentRun/localRuntimeBootstrap.ts +69 -0
- package/server/handlers/agentRun/loop.ts +2210 -0
- package/server/handlers/agentRun/machineConnector.ts +235 -0
- package/server/handlers/agentRun/machineRunAudit.ts +49 -0
- package/server/handlers/agentRun/modelUsageToolHandlers.ts +368 -0
- package/server/handlers/agentRun/referenceRuntime.ts +50 -0
- package/server/handlers/agentRun/requestContext.ts +86 -0
- package/server/handlers/agentRun/response.ts +27 -0
- package/server/handlers/agentRun/runBilling.ts +108 -0
- package/server/handlers/agentRun/runDialogPreparation.ts +55 -0
- package/server/handlers/agentRun/runtimeBinding.ts +61 -0
- package/server/handlers/agentRun/runtimeContext.ts +143 -0
- package/server/handlers/agentRun/runtimeExecutionContext.ts +153 -0
- package/server/handlers/agentRun/runtimePreparation.ts +193 -0
- package/server/handlers/agentRun/runtimeRouting.ts +88 -0
- package/server/handlers/agentRun/runtimeSystemMessages.ts +165 -0
- package/server/handlers/agentRun/saveDialog.ts +1373 -0
- package/server/handlers/agentRun/syncRunDialog.ts +90 -0
- package/server/handlers/agentRun/tableActivityProjection.ts +132 -0
- package/server/handlers/agentRun/taskRunControlPrompt.ts +122 -0
- package/server/handlers/agentRun/taskRunToolHandler.ts +579 -0
- package/server/handlers/agentRun/toolExecutor.ts +2909 -0
- package/server/handlers/agentRun/toolPolicyGuards.ts +295 -0
- package/server/handlers/agentRun/types.ts +94 -0
- package/server/handlers/agentRun/workspaceLease.ts +58 -0
- package/server/handlers/alphaTestRouteGuard.ts +30 -0
- package/server/handlers/apifyActorHandler.ts +170 -0
- package/server/handlers/appDeployFlow.ts +876 -0
- package/server/handlers/appDeployHandler.ts +4 -0
- package/server/handlers/appDeployMutationHandlers.ts +133 -0
- package/server/handlers/appDeployReadHandlers.ts +321 -0
- package/server/handlers/appDeployShared.ts +230 -0
- package/server/handlers/appDeployStatusStore.ts +178 -0
- package/server/handlers/appDomainHandler.ts +476 -0
- package/server/handlers/appLegacyInfraCleanup.ts +7 -0
- package/server/handlers/appSandboxHandler.ts +1055 -0
- package/server/handlers/appSourceReadiness.ts +75 -0
- package/server/handlers/appSpaceAccess.ts +179 -0
- package/server/handlers/applyEditHandler.ts +544 -0
- package/server/handlers/applyLineEditsHandler.ts +1058 -0
- package/server/handlers/billingLedgerAuditHandler.ts +82 -0
- package/server/handlers/billingLedgerWitnessHandler.ts +161 -0
- package/server/handlers/billingUsageReportHandler.ts +90 -0
- package/server/handlers/browserToolHandler.ts +450 -0
- package/server/handlers/cfTextToSpeechHandler.ts +137 -0
- package/server/handlers/cfWhisperHandler.ts +206 -0
- package/server/handlers/chatBillingSse.ts +79 -0
- package/server/handlers/chatHandler.ts +797 -0
- package/server/handlers/chatProxyRouting.ts +404 -0
- package/server/handlers/chatUpstreamRetry.ts +162 -0
- package/server/handlers/checkEnvHandler.ts +250 -0
- package/server/handlers/cliChatHandler.ts +266 -0
- package/server/handlers/cloudflareBrowserHandler.ts +275 -0
- package/server/handlers/cloudflareCrawlHandler.ts +260 -0
- package/server/handlers/codeSearchHandler.ts +484 -0
- package/server/handlers/connector/connectorConnectionRegistry.ts +192 -0
- package/server/handlers/connector/connectorWebSocket.ts +117 -0
- package/server/handlers/creatorEarningsReportHandler.ts +97 -0
- package/server/handlers/creatorSettlementReportHandler.ts +98 -0
- package/server/handlers/deepseekOcrHandler.ts +114 -0
- package/server/handlers/deleteMemoryHandler.ts +115 -0
- package/server/handlers/desktopAgentRuntimeAdapter.ts +307 -0
- package/server/handlers/desktopAgentRuntimeHostFacts.ts +40 -0
- package/server/handlers/desktopAgentRuntimeStatusHandler.ts +54 -0
- package/server/handlers/desktopAgentRuntimeTurnHandler.ts +165 -0
- package/server/handlers/desktopAgentRuntimeTurnService.ts +352 -0
- package/server/handlers/desktopClipboardHandler.ts +104 -0
- package/server/handlers/desktopFiles/handler.ts +159 -0
- package/server/handlers/desktopFiles/operations.ts +202 -0
- package/server/handlers/desktopFiles/sandbox.ts +62 -0
- package/server/handlers/desktopFiles/store.ts +81 -0
- package/server/handlers/desktopLlamaRuntimeHandler.ts +360 -0
- package/server/handlers/desktopLocalConnectorHandler.ts +101 -0
- package/server/handlers/desktopUpdaterHandler.ts +132 -0
- package/server/handlers/dialogEvents.ts +10 -0
- package/server/handlers/emailInboundHandler.ts +65 -0
- package/server/handlers/eventBus.ts +160 -0
- package/server/handlers/exaSearchHandler.ts +73 -0
- package/server/handlers/execShellHandler.ts +661 -0
- package/server/handlers/favoriteHandlers.ts +417 -0
- package/server/handlers/fetchWebpageHandler.ts +117 -0
- package/server/handlers/fileOutlineHandler.ts +107 -0
- package/server/handlers/geminiImagePreviewHandler.ts +612 -0
- package/server/handlers/getDialogBillingHandler.ts +151 -0
- package/server/handlers/getTransactionsHandler.ts +107 -0
- package/server/handlers/googleNativeChat.ts +572 -0
- package/server/handlers/listFilesHandler.ts +139 -0
- package/server/handlers/machines/machineAuth.ts +149 -0
- package/server/handlers/machines/machineBinding.ts +59 -0
- package/server/handlers/machines/machineHandlers.ts +279 -0
- package/server/handlers/machines/machineInstallAssets.ts +563 -0
- package/server/handlers/machines/machineRegistry.ts +89 -0
- package/server/handlers/notificationEmitter.ts +189 -0
- package/server/handlers/notificationsHandler.ts +91 -0
- package/server/handlers/olmOcrHandler.ts +115 -0
- package/server/handlers/openaiImageHandler.ts +500 -0
- package/server/handlers/providerHealthHandler.ts +36 -0
- package/server/handlers/publicHandler.ts +209 -0
- package/server/handlers/readFileHandler.ts +300 -0
- package/server/handlers/readXPostHandler.ts +180 -0
- package/server/handlers/rememberMemoryHandler.ts +69 -0
- package/server/handlers/remotionRenderHandler.ts +236 -0
- package/server/handlers/renderMarkdownHandler.ts +66 -0
- package/server/handlers/revenueShareReportHandler.ts +96 -0
- package/server/handlers/searchRepoHandler.ts +159 -0
- package/server/handlers/tableAccess.ts +34 -0
- package/server/handlers/tableToolHandlers.ts +741 -0
- package/server/handlers/typecheckWorker.ts +54 -0
- package/server/handlers/userEvents.ts +6 -0
- package/server/handlers/userSecretsHandler.ts +210 -0
- package/server/handlers/versionHandler.ts +281 -0
- package/server/handlers/versionStore.ts +176 -0
- package/server/handlers/wereadGatewayHandler.ts +48 -0
- package/server/handlers/whisperHandler.ts +158 -0
- package/server/handlers/writeFileHandler.ts +168 -0
- package/server/html/desktopReleaseManifest.server.ts +17 -0
- package/server/html/generateErrorResponse.ts +22 -0
- package/server/html/serializeState.ts +9 -0
- package/server/html/ssrPreload.ts +247 -0
- package/server/html/template.ts +275 -0
- package/server/httpCompression.ts +102 -0
- package/server/index.ts +0 -0
- package/server/liveReloadScript.ts +105 -0
- package/server/luIconNames.ts +14 -0
- package/server/machineRoutes.ts +44 -0
- package/server/mediaRoutes.ts +25 -0
- package/server/memoryRoutes.ts +14 -0
- package/server/normalizedStatusRoutes.ts +23 -0
- package/server/payments/crypto/cryptoUsdcBaseAddressPool.ts +49 -0
- package/server/payments/crypto/cryptoUsdcBaseConfig.ts +120 -0
- package/server/payments/crypto/cryptoUsdcBasePaymentProvider.ts +134 -0
- package/server/payments/crypto/cryptoUsdcBaseScanner.ts +267 -0
- package/server/payments/crypto/cryptoUsdcBaseWatcher.ts +40 -0
- package/server/payments/crypto/cryptoUsdtTronAddressPool.ts +49 -0
- package/server/payments/crypto/cryptoUsdtTronConfig.ts +120 -0
- package/server/payments/crypto/cryptoUsdtTronPaymentProvider.ts +132 -0
- package/server/payments/crypto/cryptoUsdtTronScanner.ts +313 -0
- package/server/payments/crypto/cryptoUsdtTronWatcher.ts +40 -0
- package/server/payments/paymentProvider.ts +6 -0
- package/server/payments/paymentRoutes.ts +27 -0
- package/server/payments/rechargeCredits.ts +69 -0
- package/server/payments/waffo/waffoPaymentProvider.ts +341 -0
- package/server/preview/previewCapability.ts +90 -0
- package/server/preview/previewConfig.ts +54 -0
- package/server/preview/previewGateway.ts +71 -0
- package/server/preview/previewRealtime.ts +33 -0
- package/server/providerHealthProbe.ts +198 -0
- package/server/providerHealthRoutes.ts +19 -0
- package/server/publicPaths.ts +12 -0
- package/server/publicRequestHandler.ts +15 -0
- package/server/reactAppBuilder.ts +416 -0
- package/server/realtimeRoutes.ts +69 -0
- package/server/renderStream.ts +20 -0
- package/server/routeFactory.ts +45 -0
- package/server/routes.ts +125 -0
- package/server/safeTempFile.ts +48 -0
- package/server/scheduler/scheduledTaskRuntime.ts +228 -0
- package/server/scheduler/schedulerService.ts +290 -0
- package/server/serverDrain.ts +129 -0
- package/server/services/browserSessionManager.ts +354 -0
- package/server/shareRoutes.ts +86 -0
- package/server/sqliteRoutes.ts +141 -0
- package/server/taskRunBridgeRoutes.ts +95 -0
- package/server/tasks.ts +113 -0
- package/server/waffoPaymentRoutes.ts +5 -0
- package/server/webUtilityRoutes.ts +50 -0
- package/server/workerValidator.ts +224 -0
- package/share/action.ts +225 -0
- package/share/clientTableReplication.ts +160 -0
- package/share/helpers.ts +302 -0
- package/share/keys.ts +243 -0
- package/share/link.ts +40 -0
- package/share/loadOwnerShares.ts +154 -0
- package/share/paidAccess.ts +32 -0
- package/share/publicSharePolicy.ts +27 -0
- package/share/server/fetchCommunityShares.ts +45 -0
- package/share/server/helpers.ts +202 -0
- package/share/server/importShare.ts +148 -0
- package/share/server/listCommunityShares.ts +167 -0
- package/share/server/purchaseDoc.ts +224 -0
- package/share/server/readCommunityShareCover.ts +73 -0
- package/share/server/readSharedTable.ts +139 -0
- package/share/server/tableReplication.ts +351 -0
- package/share/shareSlice.ts +53 -0
- package/share/tableShareState.ts +74 -0
- package/share/types.ts +100 -0
- package/spaceCategoryCommands.ts +263 -0
- package/spaceCommands.ts +295 -0
- package/spaceDeleteCommands.ts +312 -0
- package/spaceInternalCommandEntries.ts +19 -0
- package/spaceMutationHelpers.ts +135 -0
- package/spaceReadCommands.ts +323 -0
- package/systemInternalCommandEntries.ts +65 -0
- package/tableCommands.ts +33 -133
- package/tableDataOutput.ts +41 -0
- package/tableDataSafety.ts +26 -0
- package/tableMetaCommands.ts +307 -0
- package/tableMutationCommands.ts +266 -0
- package/tableQueryParsing.ts +90 -0
- package/tableQueryRequest.ts +53 -0
- package/taskRunActions.ts +122 -0
- package/taskRunCommand.ts +8 -214
- package/taskRunParsing.ts +86 -0
- package/taskRunPromptShared.ts +55 -0
- package/tui/session.ts +43 -372
- package/tui/tuiCatalog.ts +22 -0
- package/tui/tuiCommandInterpreter.test.ts +169 -0
- package/tui/tuiCommandInterpreter.ts +253 -0
- package/tui/tuiPresentation.test.ts +154 -0
- package/tui/tuiPresentation.ts +146 -0
- package/workflowInternalCommandEntries.ts +31 -0
package/machineCommands.ts
CHANGED
|
@@ -1,78 +1,44 @@
|
|
|
1
1
|
import type { MachineHeartbeat } from "./connector-experimental/protocol";
|
|
2
2
|
import { detectMachineInfo } from "./connector-experimental/machineInfo";
|
|
3
|
-
import { spawn } from "node:child_process";
|
|
4
|
-
import { mkdirSync, openSync } from "node:fs";
|
|
5
|
-
import { homedir } from "node:os";
|
|
6
|
-
import { dirname, join } from "node:path";
|
|
7
|
-
import { runLocalAgentTurn, type LocalAgentToolEvent } from "./agent-runtime/localLoop";
|
|
8
|
-
import { DEFAULT_NOLO_SERVER_URL } from "./defaultServer";
|
|
9
3
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./connectorRunArtifact";
|
|
14
|
-
import {
|
|
15
|
-
type HeartbeatLoopOptions,
|
|
16
|
-
runHeartbeatLoop as defaultRunHeartbeatLoop,
|
|
17
|
-
} from "./connector-experimental/heartbeatLoop";
|
|
18
|
-
import {
|
|
19
|
-
assertMachineRunAllowed,
|
|
20
|
-
buildMachinePermissionPromptBlock,
|
|
21
|
-
resolveMachineRunPermissionPolicy,
|
|
22
|
-
} from "./ai/agent/machineRunPermissions";
|
|
4
|
+
type HeartbeatLoopOptions,
|
|
5
|
+
runHeartbeatLoop as defaultRunHeartbeatLoop,
|
|
6
|
+
} from "./connector-experimental/heartbeatLoop";
|
|
23
7
|
import { resolveConnectorWebSocketTarget } from "./connectorWebSocketTarget";
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
8
|
+
import {
|
|
9
|
+
checkConnectorWorkspaceLinks,
|
|
10
|
+
runMachineDaemonCommand,
|
|
11
|
+
} from "./machineDaemonCommands";
|
|
12
|
+
import { runMachineHeartbeatConnectCommand } from "./machineHeartbeatCommands";
|
|
13
|
+
import { runMachineWatchCommand } from "./machineWatchCommands";
|
|
14
|
+
import {
|
|
15
|
+
handleConnectorRunMessage,
|
|
16
|
+
type LocalCliExecutor,
|
|
17
|
+
} from "./machineWsRunDispatch";
|
|
18
|
+
import {
|
|
19
|
+
defaultConnectWebSocket,
|
|
20
|
+
runMachineWsSession,
|
|
21
|
+
type ConnectorWebSocketOptions,
|
|
22
|
+
} from "./machineWsSession";
|
|
23
|
+
import {
|
|
24
|
+
buildConnectorCliPrompt,
|
|
25
|
+
} from "./machineCommandPrompts";
|
|
26
|
+
import {
|
|
27
|
+
hasFlag,
|
|
28
|
+
readOption,
|
|
29
|
+
resolveConnectAuthToken,
|
|
30
|
+
resolveConnectServerUrl,
|
|
31
|
+
resolveConnectorReconnectDelayMs,
|
|
32
|
+
writeAuthMissing,
|
|
33
|
+
type EnvLike,
|
|
34
|
+
type OutputLike,
|
|
35
|
+
} from "./machineCommandResolution";
|
|
36
|
+
export {
|
|
37
|
+
formatMachineStatus,
|
|
38
|
+
runMachineStatusCommand,
|
|
39
|
+
type MachineSummary,
|
|
40
|
+
} from "./machineStatusCommands";
|
|
52
41
|
|
|
53
|
-
type ConnectorRunProgress = {
|
|
54
|
-
eventType?: LocalAgentToolEvent["type"];
|
|
55
|
-
toolCallCount?: number;
|
|
56
|
-
toolResultCount?: number;
|
|
57
|
-
lastToolNames?: string[];
|
|
58
|
-
workspaceRoot?: string;
|
|
59
|
-
workspaceKind?: string;
|
|
60
|
-
message?: string;
|
|
61
|
-
updatedAt?: number;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export type MachineSummary = {
|
|
65
|
-
machineId: string;
|
|
66
|
-
name: string;
|
|
67
|
-
platform: string;
|
|
68
|
-
arch: string;
|
|
69
|
-
connectorVersion: string | null;
|
|
70
|
-
capabilities: string[];
|
|
71
|
-
connectorStatus?: "connected" | "disconnected";
|
|
72
|
-
status: "online" | "offline";
|
|
73
|
-
lastSeenAt: number;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
42
|
type MachineCommandDeps = {
|
|
77
43
|
env?: EnvLike;
|
|
78
44
|
output?: OutputLike;
|
|
@@ -82,153 +48,19 @@ type MachineCommandDeps = {
|
|
|
82
48
|
fetchImpl?: typeof fetch;
|
|
83
49
|
machineInfo?: () => MachineHeartbeat;
|
|
84
50
|
runHeartbeatLoop?: (options: HeartbeatLoopOptions) => Promise<void>;
|
|
85
|
-
connectWebSocket?: (url: string, options: ConnectorWebSocketOptions) => Promise<void>;
|
|
86
|
-
executeCli?: LocalCliExecutor;
|
|
87
|
-
|
|
51
|
+
connectWebSocket?: (url: string, options: ConnectorWebSocketOptions) => Promise<void>;
|
|
52
|
+
executeCli?: LocalCliExecutor;
|
|
53
|
+
validateWorkspaceLinks?: (cwd: string) => string[] | Promise<string[]>;
|
|
54
|
+
spawnDaemon?: (args: {
|
|
88
55
|
cmd: string[];
|
|
89
56
|
cwd: string;
|
|
90
57
|
env: EnvLike;
|
|
91
58
|
logPath: string;
|
|
92
59
|
}) => { pid?: number };
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
function resolveServerUrl(env: EnvLike) {
|
|
96
|
-
return (env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function resolveAuthToken(env: EnvLike) {
|
|
100
|
-
return env.AUTH_TOKEN || env.AUTH || "";
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function writeAuthMissing(output: OutputLike) {
|
|
104
|
-
output.write(
|
|
105
|
-
"[nolo] Machine commands require an auth token. Run `nolo login` or set AUTH_TOKEN.\n"
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function hasFlag(args: string[], flag: string) {
|
|
110
|
-
return args.includes(flag);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function readOption(args: string[], flag: string) {
|
|
114
|
-
for (let i = 0; i < args.length; i++) {
|
|
115
|
-
const arg = args[i];
|
|
116
|
-
if (arg === flag) {
|
|
117
|
-
const next = args[i + 1];
|
|
118
|
-
if (typeof next === "string" && !next.startsWith("-")) return next;
|
|
119
|
-
return "";
|
|
120
|
-
}
|
|
121
|
-
if (arg.startsWith(flag + "=")) {
|
|
122
|
-
return arg.slice(flag.length + 1);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return "";
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function resolveConnectServerUrl(args: string[], env: EnvLike) {
|
|
129
|
-
const fromFlag = readOption(args, "--server-url") || readOption(args, "--server");
|
|
130
|
-
const raw = fromFlag || env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL;
|
|
131
|
-
return String(raw).replace(/\/+$|\s+$/g, "").replace(/\/+$/g, "").replace(/\s+$/g, "");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function resolveConnectAuthToken(args: string[], env: EnvLike) {
|
|
135
|
-
return readOption(args, "--api-key") || readOption(args, "--token") || resolveAuthToken(env);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function resolveDaemonLogPath(env: EnvLike) {
|
|
139
|
-
return env.NOLO_CONNECT_LOG || join(homedir(), ".nolo", "logs", "connector.log");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function buildDaemonCommand(cliEntrypointPath: string | undefined) {
|
|
143
|
-
return [process.execPath, cliEntrypointPath || import.meta.path, "connect", "--ws"];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function defaultSpawnDaemon(args: {
|
|
147
|
-
cmd: string[];
|
|
148
|
-
cwd: string;
|
|
149
|
-
env: EnvLike;
|
|
150
|
-
logPath: string;
|
|
151
|
-
}) {
|
|
152
|
-
mkdirSync(dirname(args.logPath), { recursive: true });
|
|
153
|
-
const out = openSync(args.logPath, "a");
|
|
154
|
-
const env = Object.fromEntries(
|
|
155
|
-
Object.entries(args.env).filter((entry): entry is [string, string] => typeof entry[1] === "string")
|
|
156
|
-
);
|
|
157
|
-
const proc = spawn(args.cmd[0], args.cmd.slice(1), {
|
|
158
|
-
cwd: args.cwd,
|
|
159
|
-
env,
|
|
160
|
-
detached: true,
|
|
161
|
-
stdio: ["ignore", out, out],
|
|
162
|
-
});
|
|
163
|
-
proc.unref();
|
|
164
|
-
return { pid: proc.pid };
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function resolveHeartbeatIntervalMs(env: EnvLike) {
|
|
168
|
-
const raw = Number(env.NOLO_CONNECT_HEARTBEAT_MS ?? "");
|
|
169
|
-
return Number.isFinite(raw) && raw > 0 ? raw : 30_000;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const CONNECTOR_WS_KEEPALIVE_MS = 25_000;
|
|
173
|
-
|
|
174
|
-
function buildConnectorKeepaliveMessage() {
|
|
175
|
-
return JSON.stringify({ type: "connector.keepalive", sentAt: Date.now() });
|
|
176
|
-
}
|
|
60
|
+
};
|
|
177
61
|
|
|
178
62
|
const defaultSleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));
|
|
179
63
|
|
|
180
|
-
function resolveConnectorReconnectDelayMs(env: EnvLike) {
|
|
181
|
-
const raw = Number(env.NOLO_CONNECT_RECONNECT_MS ?? "");
|
|
182
|
-
return Number.isFinite(raw) && raw >= 0 ? raw : 5_000;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async function defaultConnectWebSocket(url: string, options: ConnectorWebSocketOptions) {
|
|
186
|
-
const WebSocketCtor = globalThis.WebSocket;
|
|
187
|
-
if (!WebSocketCtor) {
|
|
188
|
-
throw new Error("WebSocket is not available in this runtime");
|
|
189
|
-
}
|
|
190
|
-
await new Promise<void>((resolve, reject) => {
|
|
191
|
-
const ws = new WebSocketCtor(url, {
|
|
192
|
-
headers: options.headers,
|
|
193
|
-
} as any);
|
|
194
|
-
let opened = false;
|
|
195
|
-
let keepalive: ReturnType<typeof setInterval> | null = null;
|
|
196
|
-
const clearKeepalive = () => {
|
|
197
|
-
if (keepalive) {
|
|
198
|
-
clearInterval(keepalive);
|
|
199
|
-
keepalive = null;
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
ws.addEventListener("open", () => {
|
|
203
|
-
opened = true;
|
|
204
|
-
keepalive = setInterval(() => {
|
|
205
|
-
try {
|
|
206
|
-
ws.send(buildConnectorKeepaliveMessage());
|
|
207
|
-
} catch {
|
|
208
|
-
clearKeepalive();
|
|
209
|
-
}
|
|
210
|
-
}, CONNECTOR_WS_KEEPALIVE_MS);
|
|
211
|
-
}, { once: true });
|
|
212
|
-
ws.addEventListener("error", () => {
|
|
213
|
-
clearKeepalive();
|
|
214
|
-
reject(new Error("connector websocket failed"));
|
|
215
|
-
});
|
|
216
|
-
ws.addEventListener("close", () => {
|
|
217
|
-
clearKeepalive();
|
|
218
|
-
if (opened) resolve();
|
|
219
|
-
else reject(new Error("connector websocket closed before opening"));
|
|
220
|
-
}, { once: true });
|
|
221
|
-
ws.addEventListener("message", (event) => {
|
|
222
|
-
const startIndex = options.sentMessages.length;
|
|
223
|
-
Promise.resolve(options.onMessage(String(event.data))).then(() => {
|
|
224
|
-
for (const message of options.sentMessages.slice(startIndex)) {
|
|
225
|
-
ws.send(message);
|
|
226
|
-
}
|
|
227
|
-
}).catch(() => undefined);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
64
|
async function defaultExecuteCli(
|
|
233
65
|
provider: string,
|
|
234
66
|
prompt: string,
|
|
@@ -237,562 +69,12 @@ async function defaultExecuteCli(
|
|
|
237
69
|
const { executeCli } = await import("./ai/agent/cliExecutor");
|
|
238
70
|
return executeCli(provider as any, prompt, options);
|
|
239
71
|
}
|
|
240
|
-
|
|
241
|
-
function detectLaunchableMachineInfo() {
|
|
242
|
-
return detectMachineInfo({ probeLaunchable: true });
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function inferTaskRunRole(agentKey: string, agentConfig: any) {
|
|
246
|
-
const haystack = [
|
|
247
|
-
agentKey,
|
|
248
|
-
agentConfig?.name,
|
|
249
|
-
agentConfig?.prompt,
|
|
250
|
-
].filter(Boolean).join("\n").toLowerCase();
|
|
251
|
-
if (haystack.includes("frontend") || haystack.includes("前端")) return "frontend";
|
|
252
|
-
if (haystack.includes("fullstack") || haystack.includes("全栈")) return "fullstack";
|
|
253
|
-
if (haystack.includes("review") || haystack.includes("审查")) return "reviewer";
|
|
254
|
-
if (haystack.includes("project-manager") || haystack.includes("项目经理")) return "pm";
|
|
255
|
-
return "codex";
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function buildTaskRunBridgePrompt(args: {
|
|
259
|
-
agentKey: string;
|
|
260
|
-
agentConfig: any;
|
|
261
|
-
runtimeContext: any;
|
|
262
|
-
}) {
|
|
263
|
-
const taskRun = args.runtimeContext?.taskRun;
|
|
264
|
-
const rowDbKey = typeof taskRun?.rowDbKey === "string" ? taskRun.rowDbKey.trim() : "";
|
|
265
|
-
if (!rowDbKey) return "";
|
|
266
|
-
const workItemId = typeof taskRun?.workItemId === "string" ? taskRun.workItemId.trim() : "";
|
|
267
|
-
const role = inferTaskRunRole(args.agentKey, args.agentConfig);
|
|
268
|
-
return [
|
|
269
|
-
"--- Nolo task-run tool bridge ---",
|
|
270
|
-
"This CLI runtime does not receive server-side function tools directly.",
|
|
271
|
-
"Use the local task-run bridge command for durable task state writes. Do not edit meta.taskRun with table or database commands.",
|
|
272
|
-
"Run commands from the repository root. The runner already provides server URL and auth in the environment.",
|
|
273
|
-
"Release boundary: after review passes, AI/reviewer/Codex may advance alpha for verification. Do not merge, push, or release main/release unless the human owner explicitly authorizes it in the current task context.",
|
|
274
|
-
"Cost boundary: read taskRun.control from context. Prefer low-cost/free-window models for routine work, and reserve Codex for supervision, quality gates, complex unblocking, and main/release decisions.",
|
|
275
|
-
`Read context: bun packages/cli/index.ts task-run read-context --row-dbkey ${JSON.stringify(rowDbKey)}`,
|
|
276
|
-
...(workItemId
|
|
277
|
-
? [
|
|
278
|
-
`Claim work item: bun packages/cli/index.ts task-run claim-work-item --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --agent-key ${JSON.stringify(args.agentKey)} --role ${role}`,
|
|
279
|
-
`Set blocker: bun packages/cli/index.ts task-run set-blocker --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --layer tool --code <CODE> --message <MESSAGE>`,
|
|
280
|
-
`Clear resolved blocker: bun packages/cli/index.ts task-run clear-blocker --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --blocker-id <BLOCKER_ID>`,
|
|
281
|
-
`Submit outcome: bun packages/cli/index.ts task-run submit-outcome --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --summary <SUMMARY>`,
|
|
282
|
-
`Request review: bun packages/cli/index.ts task-run request-review --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --reviewer-agent-key <AGENT_KEY> --message <MESSAGE>`,
|
|
283
|
-
`Record review: bun packages/cli/index.ts task-run record-review --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --review-status <passed|needs_changes|blocked> --reviewer-agent-key ${JSON.stringify(args.agentKey)} --findings <FINDINGS>`,
|
|
284
|
-
`Close work item: bun packages/cli/index.ts task-run close-work-item --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --summary <SUMMARY>`,
|
|
285
|
-
]
|
|
286
|
-
: []),
|
|
287
|
-
"If a bridge command fails, report the exact command and error.",
|
|
288
|
-
].join("\n");
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function buildConnectorCliPrompt(agentConfig: any, userInput: string, bridgeArgs?: {
|
|
292
|
-
agentKey: string;
|
|
293
|
-
runtimeContext: any;
|
|
294
|
-
}, permissionPolicy?: ReturnType<typeof resolveMachineRunPermissionPolicy>) {
|
|
295
|
-
const policy = permissionPolicy ?? resolveMachineRunPermissionPolicy(agentConfig);
|
|
296
|
-
return [
|
|
297
|
-
typeof agentConfig?.prompt === "string" ? agentConfig.prompt.trim() : "",
|
|
298
|
-
bridgeArgs ? buildTaskRunBridgePrompt({
|
|
299
|
-
agentKey: bridgeArgs.agentKey,
|
|
300
|
-
agentConfig,
|
|
301
|
-
runtimeContext: bridgeArgs.runtimeContext,
|
|
302
|
-
}) : "",
|
|
303
|
-
buildMachinePermissionPromptBlock(policy),
|
|
304
|
-
`--- User task ---\n${userInput}`,
|
|
305
|
-
].filter(Boolean).join("\n\n");
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function isRecord(value: unknown): value is Record<string, any> {
|
|
309
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
310
|
-
}
|
|
311
72
|
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
-
const fromAgent = parsed?.payload?.agentConfig?.runtimeToolPolicy;
|
|
315
|
-
const policy = isRecord(fromMeta) ? fromMeta : isRecord(fromAgent) ? fromAgent : null;
|
|
316
|
-
return policy ? policy as ConnectorRuntimePolicy : undefined;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function requestsTaskWorktree(policy?: ConnectorRuntimePolicy) {
|
|
320
|
-
return policy?.workspace?.mode === "task-worktree" || policy?.workspace?.mode === "lease";
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function hasExplicitMachinePermissions(agentConfig: any) {
|
|
324
|
-
const runtimeBinding = isRecord(agentConfig?.runtimeBinding) ? agentConfig.runtimeBinding : {};
|
|
325
|
-
return Boolean(
|
|
326
|
-
isRecord(agentConfig?.machinePermissions) ||
|
|
327
|
-
isRecord(runtimeBinding.permissions) ||
|
|
328
|
-
isRecord(runtimeBinding.machinePermissions) ||
|
|
329
|
-
isRecord(agentConfig?.boundRuntimeMachine?.permissions)
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function runtimeWorkspacePermissionPolicy(
|
|
334
|
-
runtimePolicy: ConnectorRuntimePolicy | undefined,
|
|
335
|
-
cwd: string
|
|
336
|
-
): ReturnType<typeof resolveMachineRunPermissionPolicy> | null {
|
|
337
|
-
if (!requestsTaskWorktree(runtimePolicy)) return null;
|
|
338
|
-
return {
|
|
339
|
-
mode: "full_access",
|
|
340
|
-
allowFilesystemRead: true,
|
|
341
|
-
allowFilesystemWrite: true,
|
|
342
|
-
allowShell: runtimePolicy?.shell?.enabled !== false,
|
|
343
|
-
writableRoots: [cwd],
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function scopePermissionPolicyToRuntimeWorkspace(
|
|
348
|
-
policy: ReturnType<typeof resolveMachineRunPermissionPolicy>,
|
|
349
|
-
runtimePolicy: ConnectorRuntimePolicy | undefined,
|
|
350
|
-
cwd: string
|
|
351
|
-
): ReturnType<typeof resolveMachineRunPermissionPolicy> {
|
|
352
|
-
if (!requestsTaskWorktree(runtimePolicy)) return policy;
|
|
353
|
-
return {
|
|
354
|
-
...policy,
|
|
355
|
-
writableRoots: policy.allowFilesystemWrite ? [cwd] : [],
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function mergeToolNames(...values: unknown[]) {
|
|
360
|
-
const names: string[] = [];
|
|
361
|
-
for (const value of values) {
|
|
362
|
-
if (!Array.isArray(value)) continue;
|
|
363
|
-
for (const item of value) {
|
|
364
|
-
const name = typeof item === "string"
|
|
365
|
-
? item
|
|
366
|
-
: isRecord(item) && typeof item.name === "string"
|
|
367
|
-
? item.name
|
|
368
|
-
: isRecord(item) && typeof item.function?.name === "string"
|
|
369
|
-
? item.function.name
|
|
370
|
-
: "";
|
|
371
|
-
if (name && !names.includes(name)) names.push(name);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
return names;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function localRuntimeEnvFromPolicy(runtimeEnv: EnvLike, policy?: ConnectorRuntimePolicy): EnvLike {
|
|
378
|
-
return {
|
|
379
|
-
...runtimeEnv,
|
|
380
|
-
...(policy?.shell?.enabled && policy.shell.mode === "worktree"
|
|
381
|
-
? { NOLO_LOCAL_SHELL_MODE: "worktree" }
|
|
382
|
-
: {}),
|
|
383
|
-
...(policy?.workspace?.cwd ? { NOLO_LOCAL_WORKTREE: policy.workspace.cwd } : {}),
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function runtimeWorkspaceRootFromTrace(trace: unknown): string | undefined {
|
|
388
|
-
if (!Array.isArray(trace)) return undefined;
|
|
389
|
-
for (const message of trace) {
|
|
390
|
-
if (!isRecord(message)) continue;
|
|
391
|
-
const metadata = isRecord(message.tool_result_metadata)
|
|
392
|
-
? message.tool_result_metadata
|
|
393
|
-
: null;
|
|
394
|
-
const workspaceRoot = metadata && typeof metadata.workspaceRoot === "string"
|
|
395
|
-
? metadata.workspaceRoot.trim()
|
|
396
|
-
: "";
|
|
397
|
-
if (workspaceRoot) return workspaceRoot;
|
|
398
|
-
}
|
|
399
|
-
return undefined;
|
|
73
|
+
function detectLaunchableMachineInfo() {
|
|
74
|
+
return detectMachineInfo({ probeLaunchable: true });
|
|
400
75
|
}
|
|
401
76
|
|
|
402
|
-
function
|
|
403
|
-
artifacts: unknown;
|
|
404
|
-
runtimePolicy?: ConnectorRuntimePolicy;
|
|
405
|
-
workspaceRoot: string;
|
|
406
|
-
workspaceKind?: string;
|
|
407
|
-
}): ConnectorRunProgress | null {
|
|
408
|
-
if (!isRecord(args.artifacts)) return null;
|
|
409
|
-
const changedFiles = Array.isArray(args.artifacts.changedFiles)
|
|
410
|
-
? args.artifacts.changedFiles
|
|
411
|
-
: [];
|
|
412
|
-
const statusShort = typeof args.artifacts.statusShort === "string"
|
|
413
|
-
? args.artifacts.statusShort.trim()
|
|
414
|
-
: "";
|
|
415
|
-
if (changedFiles.length === 0 && !statusShort) return null;
|
|
416
|
-
const runtimeTools = Array.isArray(args.runtimePolicy?.runtimeTools)
|
|
417
|
-
? args.runtimePolicy.runtimeTools
|
|
418
|
-
: [];
|
|
419
|
-
const shellTool = runtimeTools.includes("execBash")
|
|
420
|
-
? "execBash"
|
|
421
|
-
: runtimeTools.includes("execShell")
|
|
422
|
-
? "execShell"
|
|
423
|
-
: "workspaceArtifact";
|
|
424
|
-
return {
|
|
425
|
-
eventType: "tool-result",
|
|
426
|
-
toolCallCount: 1,
|
|
427
|
-
toolResultCount: 1,
|
|
428
|
-
lastToolNames: [shellTool],
|
|
429
|
-
workspaceRoot: args.workspaceRoot,
|
|
430
|
-
...(args.workspaceKind ? { workspaceKind: args.workspaceKind } : {}),
|
|
431
|
-
message: statusShort || `${changedFiles.length} changed file(s)`,
|
|
432
|
-
updatedAt: Date.now(),
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
async function runConnectorLocalRuntimeAgent(args: {
|
|
437
|
-
parsed: any;
|
|
438
|
-
runtimeEnv: EnvLike;
|
|
439
|
-
cwd: string;
|
|
440
|
-
fetchImpl?: typeof fetch;
|
|
441
|
-
onProgress?: (progress: ConnectorRunProgress) => void;
|
|
442
|
-
}): Promise<Awaited<ReturnType<typeof runLocalAgentTurn>> & { runtimeWorkspaceRoot?: string }> {
|
|
443
|
-
const agentKey = String(args.parsed.payload?.agentKey ?? "");
|
|
444
|
-
const payloadAgentConfig = isRecord(args.parsed.payload?.agentConfig)
|
|
445
|
-
? args.parsed.payload.agentConfig
|
|
446
|
-
: {};
|
|
447
|
-
const policy = runtimePolicyFromConnectorPayload(args.parsed);
|
|
448
|
-
const agentRecord = {
|
|
449
|
-
...payloadAgentConfig,
|
|
450
|
-
dbKey: agentKey,
|
|
451
|
-
id: agentKey,
|
|
452
|
-
key: agentKey,
|
|
453
|
-
apiSource: payloadAgentConfig.apiSource ?? "platform",
|
|
454
|
-
provider: payloadAgentConfig.provider ?? payloadAgentConfig.apiSource ?? "openai",
|
|
455
|
-
toolNames: mergeToolNames(
|
|
456
|
-
payloadAgentConfig.toolNames,
|
|
457
|
-
payloadAgentConfig.tools,
|
|
458
|
-
policy?.agentTools,
|
|
459
|
-
policy?.runtimeTools,
|
|
460
|
-
),
|
|
461
|
-
...(policy ? { runtimeToolPolicy: policy } : {}),
|
|
462
|
-
...(policy?.workspace?.mode === "task-worktree" || policy?.workspace?.mode === "lease"
|
|
463
|
-
? { localWorkspaceMode: "task-worktree" }
|
|
464
|
-
: {}),
|
|
465
|
-
};
|
|
466
|
-
const store = new Map<string, any>([
|
|
467
|
-
[agentKey, agentRecord],
|
|
468
|
-
[`agent-${args.runtimeEnv.NOLO_USER_ID || "local"}-${agentKey}`, agentRecord],
|
|
469
|
-
[`agent-${args.runtimeEnv.NOLO_LOCAL_USER_ID || args.runtimeEnv.NOLO_USER_ID || "local"}-${agentKey}`, agentRecord],
|
|
470
|
-
]);
|
|
471
|
-
const env = localRuntimeEnvFromPolicy(args.runtimeEnv, policy);
|
|
472
|
-
const wantsTaskWorktree = requestsTaskWorktree(policy);
|
|
473
|
-
const adapter = createCliLocalRuntimeAdapter({
|
|
474
|
-
env,
|
|
475
|
-
cwd: args.cwd,
|
|
476
|
-
useCwdAsTaskWorkspaceBase: wantsTaskWorktree,
|
|
477
|
-
...(wantsTaskWorktree
|
|
478
|
-
? {
|
|
479
|
-
prepareTaskWorktree: (input) => prepareTaskWorktree({
|
|
480
|
-
...input,
|
|
481
|
-
cwd: args.cwd,
|
|
482
|
-
}),
|
|
483
|
-
}
|
|
484
|
-
: {}),
|
|
485
|
-
fetchImpl: args.fetchImpl ?? fetch,
|
|
486
|
-
store: {
|
|
487
|
-
read: async (key) => store.get(key) ?? null,
|
|
488
|
-
batch: async (ops) => {
|
|
489
|
-
for (const op of ops) {
|
|
490
|
-
if (op.type === "put") store.set(op.key, op.value);
|
|
491
|
-
}
|
|
492
|
-
},
|
|
493
|
-
iterator: async function* (options) {
|
|
494
|
-
const keys = [...store.keys()].sort();
|
|
495
|
-
for (const key of keys) {
|
|
496
|
-
if (key < options.gte) continue;
|
|
497
|
-
if (options.lte && key > options.lte) continue;
|
|
498
|
-
if (options.lt && key >= options.lt) continue;
|
|
499
|
-
yield [key, store.get(key)];
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
},
|
|
503
|
-
});
|
|
504
|
-
let toolCallCount = 0;
|
|
505
|
-
let toolResultCount = 0;
|
|
506
|
-
const lastToolNames: string[] = [];
|
|
507
|
-
let runtimeWorkspaceRoot: string | undefined;
|
|
508
|
-
let runtimeWorkspaceKind: string | undefined;
|
|
509
|
-
const noteToolName = (toolName: string) => {
|
|
510
|
-
if (!toolName) return;
|
|
511
|
-
const existingIndex = lastToolNames.indexOf(toolName);
|
|
512
|
-
if (existingIndex >= 0) lastToolNames.splice(existingIndex, 1);
|
|
513
|
-
lastToolNames.push(toolName);
|
|
514
|
-
while (lastToolNames.length > 8) lastToolNames.shift();
|
|
515
|
-
};
|
|
516
|
-
const result = await runLocalAgentTurn({
|
|
517
|
-
adapter,
|
|
518
|
-
agentRef: agentKey,
|
|
519
|
-
input: String(args.parsed.payload?.userInput ?? ""),
|
|
520
|
-
continueDialogId: typeof args.parsed.payload?.continueDialogId === "string"
|
|
521
|
-
? args.parsed.payload.continueDialogId
|
|
522
|
-
: undefined,
|
|
523
|
-
onToolEvent: (event) => {
|
|
524
|
-
if (event.type === "tool-call") toolCallCount += 1;
|
|
525
|
-
if (event.type === "tool-result") toolResultCount += 1;
|
|
526
|
-
noteToolName(event.toolName);
|
|
527
|
-
const metadata = isRecord(event.metadata) ? event.metadata : {};
|
|
528
|
-
if (typeof metadata.workspaceRoot === "string" && metadata.workspaceRoot.trim()) {
|
|
529
|
-
runtimeWorkspaceRoot = metadata.workspaceRoot.trim();
|
|
530
|
-
}
|
|
531
|
-
if (typeof metadata.workspaceKind === "string" && metadata.workspaceKind.trim()) {
|
|
532
|
-
runtimeWorkspaceKind = metadata.workspaceKind.trim();
|
|
533
|
-
}
|
|
534
|
-
args.onProgress?.({
|
|
535
|
-
eventType: event.type,
|
|
536
|
-
toolCallCount,
|
|
537
|
-
toolResultCount,
|
|
538
|
-
lastToolNames: [...lastToolNames],
|
|
539
|
-
...(runtimeWorkspaceRoot ? { workspaceRoot: runtimeWorkspaceRoot } : {}),
|
|
540
|
-
...(runtimeWorkspaceKind ? { workspaceKind: runtimeWorkspaceKind } : {}),
|
|
541
|
-
...(event.message ? { message: event.message } : {}),
|
|
542
|
-
updatedAt: Date.now(),
|
|
543
|
-
});
|
|
544
|
-
},
|
|
545
|
-
});
|
|
546
|
-
return {
|
|
547
|
-
...result,
|
|
548
|
-
runtimeWorkspaceRoot: runtimeWorkspaceRootFromTrace(result.trace) ?? runtimeWorkspaceRoot,
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
function normalizeConnectorRunTimeoutMs(value: unknown): number | undefined {
|
|
553
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
554
|
-
return undefined;
|
|
555
|
-
}
|
|
556
|
-
return Math.floor(value);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
export async function handleConnectorRunMessage(
|
|
560
|
-
machine: MachineHeartbeat,
|
|
561
|
-
message: string,
|
|
562
|
-
send: (message: string) => void,
|
|
563
|
-
executeCli: LocalCliExecutor,
|
|
564
|
-
runtimeEnv: EnvLike,
|
|
565
|
-
fetchImpl?: typeof fetch
|
|
566
|
-
) {
|
|
567
|
-
let parsed: any;
|
|
568
|
-
try {
|
|
569
|
-
parsed = JSON.parse(message);
|
|
570
|
-
} catch {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
if (parsed?.type !== "agent.run" || typeof parsed.requestId !== "string") return;
|
|
574
|
-
const agentConfig = parsed.payload?.agentConfig ?? {};
|
|
575
|
-
const sendProgress = (progress: ConnectorRunProgress) => {
|
|
576
|
-
send(JSON.stringify({
|
|
577
|
-
type: "agent.run.progress",
|
|
578
|
-
requestId: parsed.requestId,
|
|
579
|
-
progress,
|
|
580
|
-
}));
|
|
581
|
-
};
|
|
582
|
-
try {
|
|
583
|
-
const machinePermissionPolicy = resolveMachineRunPermissionPolicy(agentConfig);
|
|
584
|
-
const runtimePolicy = runtimePolicyFromConnectorPayload(parsed);
|
|
585
|
-
const userInput = String(parsed.payload?.userInput ?? "");
|
|
586
|
-
const timeout = normalizeConnectorRunTimeoutMs(parsed.payload?.timeoutMs);
|
|
587
|
-
let cwd = resolveConnectorRunCwd({ env: runtimeEnv, policy: machinePermissionPolicy });
|
|
588
|
-
let runContent = "";
|
|
589
|
-
let runModel = agentConfig.model;
|
|
590
|
-
let runTrace: unknown[] = [];
|
|
591
|
-
let artifactCwd = cwd;
|
|
592
|
-
let baseSha: string | null = null;
|
|
593
|
-
if (agentConfig.apiSource === "cli") {
|
|
594
|
-
if (requestsTaskWorktree(runtimePolicy)) {
|
|
595
|
-
const prepared = await prepareTaskWorktree({
|
|
596
|
-
agentKey: String(parsed.payload?.agentKey ?? "agent"),
|
|
597
|
-
cwd,
|
|
598
|
-
env: runtimeEnv,
|
|
599
|
-
});
|
|
600
|
-
cwd = prepared.path;
|
|
601
|
-
artifactCwd = prepared.path;
|
|
602
|
-
}
|
|
603
|
-
const runtimePermissionPolicy = !hasExplicitMachinePermissions(agentConfig)
|
|
604
|
-
? runtimeWorkspacePermissionPolicy(runtimePolicy, cwd)
|
|
605
|
-
: null;
|
|
606
|
-
const effectivePermissionPolicy = scopePermissionPolicyToRuntimeWorkspace(
|
|
607
|
-
runtimePermissionPolicy ?? machinePermissionPolicy,
|
|
608
|
-
runtimePolicy,
|
|
609
|
-
cwd,
|
|
610
|
-
);
|
|
611
|
-
assertMachineRunAllowed(userInput, effectivePermissionPolicy);
|
|
612
|
-
baseSha = await readConnectorGitHead(artifactCwd);
|
|
613
|
-
const provider = String(agentConfig.cliProvider || "copilot");
|
|
614
|
-
const result = await executeCli(
|
|
615
|
-
provider,
|
|
616
|
-
buildConnectorCliPrompt(agentConfig, userInput, {
|
|
617
|
-
agentKey: String(parsed.payload?.agentKey ?? ""),
|
|
618
|
-
runtimeContext: parsed.payload?.runtimeContext,
|
|
619
|
-
}, effectivePermissionPolicy),
|
|
620
|
-
{
|
|
621
|
-
model: agentConfig.model || undefined,
|
|
622
|
-
timeout,
|
|
623
|
-
cwd,
|
|
624
|
-
yolo: true,
|
|
625
|
-
env: {
|
|
626
|
-
NOLO_SERVER: runtimeEnv.NOLO_SERVER || runtimeEnv.NOLO_SERVER_URL || runtimeEnv.BASE_URL,
|
|
627
|
-
NOLO_SERVER_URL: runtimeEnv.NOLO_SERVER_URL || runtimeEnv.NOLO_SERVER || runtimeEnv.BASE_URL,
|
|
628
|
-
BASE_URL: runtimeEnv.BASE_URL || runtimeEnv.NOLO_SERVER || runtimeEnv.NOLO_SERVER_URL,
|
|
629
|
-
AUTH_TOKEN: runtimeEnv.AUTH_TOKEN || runtimeEnv.AUTH || runtimeEnv.NOLO_MACHINE_API_KEY,
|
|
630
|
-
NOLO_MACHINE_API_KEY: runtimeEnv.NOLO_MACHINE_API_KEY || runtimeEnv.AUTH_TOKEN || runtimeEnv.AUTH,
|
|
631
|
-
},
|
|
632
|
-
}
|
|
633
|
-
);
|
|
634
|
-
runContent = result.text;
|
|
635
|
-
runModel = agentConfig.model ?? provider;
|
|
636
|
-
runTrace = [{ role: "assistant", content: result.text }];
|
|
637
|
-
const artifacts = await collectConnectorRunArtifact({
|
|
638
|
-
cwd: artifactCwd,
|
|
639
|
-
baseSha,
|
|
640
|
-
exitStatus: "completed",
|
|
641
|
-
});
|
|
642
|
-
const artifactProgress = buildArtifactProgress({
|
|
643
|
-
artifacts,
|
|
644
|
-
runtimePolicy,
|
|
645
|
-
workspaceRoot: artifactCwd,
|
|
646
|
-
workspaceKind: requestsTaskWorktree(runtimePolicy) ? "task-worktree" : "current",
|
|
647
|
-
});
|
|
648
|
-
if (artifactProgress && requestsTaskWorktree(runtimePolicy)) sendProgress(artifactProgress);
|
|
649
|
-
send(JSON.stringify({
|
|
650
|
-
type: "agent.run.result",
|
|
651
|
-
requestId: parsed.requestId,
|
|
652
|
-
result: {
|
|
653
|
-
content: runContent,
|
|
654
|
-
model: runModel,
|
|
655
|
-
trace: runTrace,
|
|
656
|
-
artifacts,
|
|
657
|
-
},
|
|
658
|
-
}));
|
|
659
|
-
return;
|
|
660
|
-
} else {
|
|
661
|
-
if (!runtimePolicy) {
|
|
662
|
-
throw new Error("Connector can only execute non-CLI agents when runtimeToolPolicySnapshot requests a local workspace runtime.");
|
|
663
|
-
}
|
|
664
|
-
baseSha = await readConnectorGitHead(cwd);
|
|
665
|
-
const result = await runConnectorLocalRuntimeAgent({
|
|
666
|
-
parsed,
|
|
667
|
-
runtimeEnv,
|
|
668
|
-
cwd,
|
|
669
|
-
fetchImpl,
|
|
670
|
-
onProgress: sendProgress,
|
|
671
|
-
});
|
|
672
|
-
runContent = result.content;
|
|
673
|
-
runModel = result.model;
|
|
674
|
-
runTrace = result.trace ?? [];
|
|
675
|
-
artifactCwd = result.runtimeWorkspaceRoot ?? cwd;
|
|
676
|
-
}
|
|
677
|
-
const artifacts = await collectConnectorRunArtifact({
|
|
678
|
-
cwd: artifactCwd,
|
|
679
|
-
baseSha,
|
|
680
|
-
exitStatus: "completed",
|
|
681
|
-
});
|
|
682
|
-
const artifactProgress = buildArtifactProgress({
|
|
683
|
-
artifacts,
|
|
684
|
-
runtimePolicy,
|
|
685
|
-
workspaceRoot: artifactCwd,
|
|
686
|
-
workspaceKind: requestsTaskWorktree(runtimePolicy) ? "task-worktree" : "current",
|
|
687
|
-
});
|
|
688
|
-
if (artifactProgress && requestsTaskWorktree(runtimePolicy)) sendProgress(artifactProgress);
|
|
689
|
-
send(JSON.stringify({
|
|
690
|
-
type: "agent.run.result",
|
|
691
|
-
requestId: parsed.requestId,
|
|
692
|
-
result: {
|
|
693
|
-
content: runContent,
|
|
694
|
-
model: runModel,
|
|
695
|
-
trace: runTrace,
|
|
696
|
-
artifacts,
|
|
697
|
-
},
|
|
698
|
-
}));
|
|
699
|
-
} catch (error) {
|
|
700
|
-
send(JSON.stringify({
|
|
701
|
-
type: "agent.run.result",
|
|
702
|
-
requestId: parsed.requestId,
|
|
703
|
-
error: error instanceof Error ? error.message : String(error),
|
|
704
|
-
}));
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
async function runConnectorWebSocketSession(options: {
|
|
709
|
-
env: EnvLike;
|
|
710
|
-
output: OutputLike;
|
|
711
|
-
machine: MachineHeartbeat;
|
|
712
|
-
sendHeartbeat: () => Promise<void>;
|
|
713
|
-
runHeartbeatLoop: (options: HeartbeatLoopOptions) => Promise<void>;
|
|
714
|
-
connectWebSocket: (url: string, options: ConnectorWebSocketOptions) => Promise<void>;
|
|
715
|
-
executeCli: LocalCliExecutor;
|
|
716
|
-
fetchImpl: typeof fetch;
|
|
717
|
-
serverUrl: string;
|
|
718
|
-
authToken: string;
|
|
719
|
-
}) {
|
|
720
|
-
const sentMessages: string[] = [];
|
|
721
|
-
const heartbeatAbort = new AbortController();
|
|
722
|
-
try {
|
|
723
|
-
await options.sendHeartbeat();
|
|
724
|
-
options.output.write(
|
|
725
|
-
`Connector websocket connected: ${options.machine.name} (${options.machine.machineId})\n`
|
|
726
|
-
);
|
|
727
|
-
const heartbeatLoopPromise = options.runHeartbeatLoop({
|
|
728
|
-
intervalMs: resolveHeartbeatIntervalMs(options.env),
|
|
729
|
-
sendHeartbeat: options.sendHeartbeat,
|
|
730
|
-
signal: heartbeatAbort.signal,
|
|
731
|
-
});
|
|
732
|
-
const wsTarget = await resolveConnectorWebSocketTarget({
|
|
733
|
-
serverUrl: options.serverUrl,
|
|
734
|
-
machineId: options.machine.machineId,
|
|
735
|
-
headers: { Authorization: `Bearer ${options.authToken}` },
|
|
736
|
-
fetchImpl: options.fetchImpl,
|
|
737
|
-
});
|
|
738
|
-
const runtimeServerUrl =
|
|
739
|
-
options.env.NOLO_CONNECT_RUNTIME_SERVER_URL ||
|
|
740
|
-
options.env.NOLO_RUNTIME_SERVER_URL ||
|
|
741
|
-
options.serverUrl;
|
|
742
|
-
const websocketPromise = options.connectWebSocket(
|
|
743
|
-
wsTarget,
|
|
744
|
-
{
|
|
745
|
-
headers: { Authorization: `Bearer ${options.authToken}` },
|
|
746
|
-
sentMessages,
|
|
747
|
-
onMessage: (message) => handleConnectorRunMessage(
|
|
748
|
-
options.machine,
|
|
749
|
-
message,
|
|
750
|
-
(response) => sentMessages.push(response),
|
|
751
|
-
options.executeCli,
|
|
752
|
-
{
|
|
753
|
-
...options.env,
|
|
754
|
-
NOLO_SERVER: runtimeServerUrl,
|
|
755
|
-
NOLO_SERVER_URL: runtimeServerUrl,
|
|
756
|
-
BASE_URL: runtimeServerUrl,
|
|
757
|
-
AUTH_TOKEN: options.authToken,
|
|
758
|
-
NOLO_MACHINE_API_KEY: options.authToken,
|
|
759
|
-
},
|
|
760
|
-
options.fetchImpl
|
|
761
|
-
),
|
|
762
|
-
}
|
|
763
|
-
);
|
|
764
|
-
await Promise.race([websocketPromise, heartbeatLoopPromise]);
|
|
765
|
-
heartbeatAbort.abort();
|
|
766
|
-
await Promise.allSettled([websocketPromise, heartbeatLoopPromise]);
|
|
767
|
-
return 0;
|
|
768
|
-
} catch (error) {
|
|
769
|
-
heartbeatAbort.abort();
|
|
770
|
-
options.output.write(
|
|
771
|
-
`[nolo] Connector websocket failed: ${
|
|
772
|
-
error instanceof Error ? error.message : String(error)
|
|
773
|
-
}\n`
|
|
774
|
-
);
|
|
775
|
-
return 1;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
export function formatMachineStatus(machines: MachineSummary[]) {
|
|
780
|
-
if (machines.length === 0) {
|
|
781
|
-
return "No connected machines.\nRun `nolo connect` on this computer to register it once.\n";
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
return [
|
|
785
|
-
"Connected machines:",
|
|
786
|
-
...machines.map((machine) => {
|
|
787
|
-
const caps = machine.capabilities.length ? machine.capabilities.join(", ") : "no capabilities";
|
|
788
|
-
const connector = machine.connectorStatus ? ` ws:${machine.connectorStatus}` : "";
|
|
789
|
-
return `- ${machine.name} ${machine.status}${connector} ${machine.platform}/${machine.arch} ${caps}`;
|
|
790
|
-
}),
|
|
791
|
-
"",
|
|
792
|
-
].join("\n");
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
export async function runMachineConnectCommand(
|
|
77
|
+
export async function runMachineConnectCommand(
|
|
796
78
|
args: string[],
|
|
797
79
|
deps: MachineCommandDeps = {}
|
|
798
80
|
) {
|
|
@@ -804,10 +86,10 @@ export async function runMachineConnectCommand(
|
|
|
804
86
|
return 1;
|
|
805
87
|
}
|
|
806
88
|
|
|
807
|
-
const serverUrl = resolveConnectServerUrl(args, env);
|
|
808
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
809
|
-
const machine = (deps.machineInfo ?? detectLaunchableMachineInfo)();
|
|
810
|
-
const sendHeartbeat = async () => {
|
|
89
|
+
const serverUrl = resolveConnectServerUrl(args, env);
|
|
90
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
91
|
+
const machine = (deps.machineInfo ?? detectLaunchableMachineInfo)();
|
|
92
|
+
const sendHeartbeat = async () => {
|
|
811
93
|
const res = await fetchImpl(`${serverUrl}/api/machines/heartbeat`, {
|
|
812
94
|
method: "POST",
|
|
813
95
|
headers: {
|
|
@@ -822,35 +104,62 @@ export async function runMachineConnectCommand(
|
|
|
822
104
|
throw new Error(`HTTP ${res.status}\n${text}`);
|
|
823
105
|
}
|
|
824
106
|
};
|
|
825
|
-
|
|
107
|
+
|
|
826
108
|
if (hasFlag(args, "--daemon") || hasFlag(args, "--background")) {
|
|
827
|
-
|
|
828
|
-
const result = (deps.spawnDaemon ?? defaultSpawnDaemon)({
|
|
829
|
-
cmd: buildDaemonCommand(deps.cliEntrypointPath),
|
|
830
|
-
cwd: process.cwd(),
|
|
109
|
+
return runMachineDaemonCommand({
|
|
831
110
|
env,
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
111
|
+
output,
|
|
112
|
+
cliEntrypointPath: deps.cliEntrypointPath,
|
|
113
|
+
validateWorkspaceLinks: deps.validateWorkspaceLinks,
|
|
114
|
+
spawnDaemon: deps.spawnDaemon,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
838
118
|
if (hasFlag(args, "--ws")) {
|
|
119
|
+
const validateWorkspaceLinks = deps.validateWorkspaceLinks ?? (() => []);
|
|
120
|
+
if (!(await checkConnectorWorkspaceLinks(process.cwd(), output, validateWorkspaceLinks))) {
|
|
121
|
+
return 1;
|
|
122
|
+
}
|
|
839
123
|
const maxAttempts = deps.maxConnectorAttempts ?? Infinity;
|
|
840
124
|
const sleep = deps.sleep ?? defaultSleep;
|
|
841
125
|
const reconnectDelayMs = resolveConnectorReconnectDelayMs(env);
|
|
842
126
|
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
843
|
-
const
|
|
127
|
+
const runtimeServerUrl =
|
|
128
|
+
env.NOLO_CONNECT_RUNTIME_SERVER_URL ||
|
|
129
|
+
env.NOLO_RUNTIME_SERVER_URL ||
|
|
130
|
+
serverUrl;
|
|
131
|
+
const exitCode = await runMachineWsSession({
|
|
844
132
|
env,
|
|
845
133
|
output,
|
|
846
134
|
machine,
|
|
847
135
|
sendHeartbeat,
|
|
848
136
|
runHeartbeatLoop: deps.runHeartbeatLoop ?? defaultRunHeartbeatLoop,
|
|
849
137
|
connectWebSocket: deps.connectWebSocket ?? defaultConnectWebSocket,
|
|
850
|
-
executeCli: deps.executeCli ?? defaultExecuteCli,
|
|
851
|
-
fetchImpl,
|
|
852
138
|
serverUrl,
|
|
853
139
|
authToken,
|
|
140
|
+
resolveConnectorWebSocketTarget: (options) =>
|
|
141
|
+
resolveConnectorWebSocketTarget({
|
|
142
|
+
...options,
|
|
143
|
+
fetchImpl,
|
|
144
|
+
}),
|
|
145
|
+
onMessage: (message, send) =>
|
|
146
|
+
handleConnectorRunMessage(
|
|
147
|
+
message,
|
|
148
|
+
send,
|
|
149
|
+
deps.executeCli ?? defaultExecuteCli,
|
|
150
|
+
{
|
|
151
|
+
...env,
|
|
152
|
+
NOLO_SERVER: runtimeServerUrl,
|
|
153
|
+
NOLO_SERVER_URL: runtimeServerUrl,
|
|
154
|
+
BASE_URL: runtimeServerUrl,
|
|
155
|
+
AUTH_TOKEN: authToken,
|
|
156
|
+
NOLO_MACHINE_API_KEY: authToken,
|
|
157
|
+
},
|
|
158
|
+
fetchImpl,
|
|
159
|
+
{
|
|
160
|
+
buildConnectorCliPrompt,
|
|
161
|
+
}
|
|
162
|
+
),
|
|
854
163
|
});
|
|
855
164
|
if (attempt >= maxAttempts) return exitCode;
|
|
856
165
|
output.write(`[nolo] Connector websocket disconnected. Reconnecting in ${reconnectDelayMs}ms.\n`);
|
|
@@ -859,78 +168,20 @@ export async function runMachineConnectCommand(
|
|
|
859
168
|
return 0;
|
|
860
169
|
}
|
|
861
170
|
|
|
862
|
-
if (hasFlag(args, "--watch")) {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
output.write(
|
|
872
|
-
`[nolo] Machine heartbeat loop failed: ${
|
|
873
|
-
error instanceof Error ? error.message : String(error)
|
|
874
|
-
}\n`
|
|
875
|
-
);
|
|
876
|
-
return 1;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
try {
|
|
881
|
-
await sendHeartbeat();
|
|
882
|
-
} catch (error) {
|
|
883
|
-
output.write(
|
|
884
|
-
`[nolo] Machine connect failed: ${
|
|
885
|
-
error instanceof Error ? error.message : String(error)
|
|
886
|
-
}\n`
|
|
887
|
-
);
|
|
888
|
-
return 1;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
output.write(`Connected machine: ${machine.name} (${machine.platform}/${machine.arch})\n`);
|
|
892
|
-
return 0;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
export async function runMachineStatusCommand(
|
|
896
|
-
_args: string[],
|
|
897
|
-
deps: MachineCommandDeps = {}
|
|
898
|
-
) {
|
|
899
|
-
const env = deps.env ?? process.env;
|
|
900
|
-
const output = deps.output ?? process.stdout;
|
|
901
|
-
const authToken = resolveAuthToken(env);
|
|
902
|
-
if (!authToken) {
|
|
903
|
-
writeAuthMissing(output);
|
|
904
|
-
return 1;
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
const serverUrl = resolveServerUrl(env);
|
|
908
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
909
|
-
let res: Response;
|
|
910
|
-
try {
|
|
911
|
-
res = await fetchImpl(`${serverUrl}/api/machines`, {
|
|
912
|
-
method: "GET",
|
|
913
|
-
headers: {
|
|
914
|
-
Authorization: `Bearer ${authToken}`,
|
|
915
|
-
},
|
|
916
|
-
});
|
|
917
|
-
} catch (error) {
|
|
918
|
-
output.write(
|
|
919
|
-
`[nolo] Machine status failed: ${
|
|
920
|
-
error instanceof Error ? error.message : String(error)
|
|
921
|
-
}\n`
|
|
922
|
-
);
|
|
923
|
-
return 1;
|
|
924
|
-
}
|
|
171
|
+
if (hasFlag(args, "--watch")) {
|
|
172
|
+
return runMachineWatchCommand({
|
|
173
|
+
env,
|
|
174
|
+
output,
|
|
175
|
+
machine,
|
|
176
|
+
sendHeartbeat,
|
|
177
|
+
runHeartbeatLoop: deps.runHeartbeatLoop ?? defaultRunHeartbeatLoop,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
925
180
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
181
|
+
return runMachineHeartbeatConnectCommand({
|
|
182
|
+
output,
|
|
183
|
+
machine,
|
|
184
|
+
sendHeartbeat,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
931
187
|
|
|
932
|
-
const data = await res.json().catch(() => ({ machines: [] }));
|
|
933
|
-
const machines = Array.isArray(data?.machines) ? data.machines : [];
|
|
934
|
-
output.write(formatMachineStatus(machines));
|
|
935
|
-
return 0;
|
|
936
|
-
}
|