nolo-cli 0.1.26 → 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/agent-runtime/dialogStatus.ts +139 -0
- package/agent-runtime/index.ts +8 -0
- package/agentAliases.ts +11 -14
- package/agentCommandSupport.ts +2 -2
- package/agentCreateCustomCommands.ts +273 -0
- package/agentDialogsCommands.ts +226 -0
- package/agentDoctorCommands.ts +203 -0
- package/agentInternalCommandEntries.ts +11 -2
- package/agentListCommands.ts +27 -18
- package/agentMachineCommands.ts +97 -23
- package/agentPullCommand.ts +9 -9
- package/agentRecordHelpers.ts +61 -4
- package/agentRunCommand.ts +35 -410
- package/agentRunLocalWorkspace.ts +182 -0
- package/agentRunParsing.ts +279 -0
- package/agentSuperviseCommands.ts +8 -0
- package/agentUnpublishCommands.ts +112 -0
- package/ai/agent/_executeModel.ts +14 -14
- 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 +16 -7
- package/ai/agent/cleanAgentMessages.ts +1 -1
- package/ai/agent/cliChatClient.ts +3 -3
- package/ai/agent/cliExecutor.ts +4 -2
- package/ai/agent/createAgentSchema.ts +1 -1
- 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/draft.ts +1 -1
- package/ai/agent/guidedCreation/types.ts +1 -1
- 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/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 +1 -1
- package/ai/agent/server/fetchPublicAgents.ts +6 -6
- package/ai/agent/startParallelAgentStreams.ts +12 -12
- package/ai/agent/streamAgentChatTurn.ts +21 -21
- 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 +29 -8
- 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 +12 -12
- package/ai/chat/sendOpenAIResponseRequest.ts +14 -14
- 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 +4 -4
- package/ai/llm/hooks/useModelPricing.ts +2 -2
- package/ai/llm/imagePricing.ts +1 -1
- package/ai/llm/models.ts +3 -3
- package/ai/llm/providers.ts +8 -8
- 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/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 +2 -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/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 +18 -4
- 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/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/execShellTool.ts +1 -1
- 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 +37 -0
- package/ai/tools/listUserSpacesTool.ts +2 -2
- package/ai/tools/localFilesTool.ts +85 -9
- package/ai/tools/openaiImageTool.ts +9 -9
- package/ai/tools/readDocTool.ts +3 -3
- package/ai/tools/readTool.ts +9 -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 +15 -6
- 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/cliCommandFactories.ts +32 -0
- package/cliEnvHelpers.ts +96 -10
- package/cliIoTypes.ts +3 -0
- package/client/agentRun.ts +26 -229
- 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/profileConfig.test.ts +66 -0
- package/client/profileConfig.ts +41 -0
- package/client/streamingOutput.ts +1 -3
- package/client/taskRunPrompt.ts +7 -24
- package/commandRegistry.ts +2 -2
- 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/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 +2 -6
- 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 +8 -0
- package/machineCommandPrompts.ts +77 -0
- package/machineCommandResolution.ts +43 -0
- package/machineCommands.ts +89 -1107
- 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 +109 -5
- 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/runtimeInternalCommandEntries.ts +15 -0
- package/runtimePassthroughCommands.ts +22 -0
- package/scriptCommandEntries.ts +5 -45
- 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 +16 -22
- 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 +20 -0
- package/offlineMarxistsAgentCommand.ts +0 -314
package/machineCommands.ts
CHANGED
|
@@ -1,86 +1,44 @@
|
|
|
1
1
|
import type { MachineHeartbeat } from "./connector-experimental/protocol";
|
|
2
2
|
import { detectMachineInfo } from "./connector-experimental/machineInfo";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
import { spawn } from "node:child_process";
|
|
5
|
-
import { existsSync, mkdirSync, openSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { homedir } from "node:os";
|
|
7
|
-
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
8
|
-
import { runLocalAgentTurn, type LocalAgentToolEvent } from "./agent-runtime/localLoop";
|
|
9
|
-
import { DEFAULT_NOLO_SERVER_URL } from "./defaultServer";
|
|
10
3
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./connectorRunArtifact";
|
|
15
|
-
import {
|
|
16
|
-
type HeartbeatLoopOptions,
|
|
17
|
-
runHeartbeatLoop as defaultRunHeartbeatLoop,
|
|
18
|
-
} from "./connector-experimental/heartbeatLoop";
|
|
19
|
-
import {
|
|
20
|
-
assertMachineRunAllowed,
|
|
21
|
-
buildMachinePermissionPromptBlock,
|
|
22
|
-
resolveMachineRunPermissionPolicy,
|
|
23
|
-
} from "./ai/agent/machineRunPermissions";
|
|
4
|
+
type HeartbeatLoopOptions,
|
|
5
|
+
runHeartbeatLoop as defaultRunHeartbeatLoop,
|
|
6
|
+
} from "./connector-experimental/heartbeatLoop";
|
|
24
7
|
import { resolveConnectorWebSocketTarget } from "./connectorWebSocketTarget";
|
|
25
|
-
import {
|
|
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
|
-
|
|
52
|
-
};
|
|
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";
|
|
53
41
|
|
|
54
|
-
type ConnectorRunProgress = {
|
|
55
|
-
eventType?: LocalAgentToolEvent["type"];
|
|
56
|
-
toolCallCount?: number;
|
|
57
|
-
toolResultCount?: number;
|
|
58
|
-
lastToolNames?: string[];
|
|
59
|
-
provider?: string;
|
|
60
|
-
promptBytes?: number;
|
|
61
|
-
promptHash?: string;
|
|
62
|
-
promptRef?: string;
|
|
63
|
-
promptPageKey?: string;
|
|
64
|
-
promptPageHash?: string;
|
|
65
|
-
requestId?: string;
|
|
66
|
-
workspaceRoot?: string;
|
|
67
|
-
workspaceKind?: string;
|
|
68
|
-
message?: string;
|
|
69
|
-
updatedAt?: number;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export type MachineSummary = {
|
|
73
|
-
machineId: string;
|
|
74
|
-
name: string;
|
|
75
|
-
platform: string;
|
|
76
|
-
arch: string;
|
|
77
|
-
connectorVersion: string | null;
|
|
78
|
-
capabilities: string[];
|
|
79
|
-
connectorStatus?: "connected" | "disconnected";
|
|
80
|
-
status: "online" | "offline";
|
|
81
|
-
lastSeenAt: number;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
42
|
type MachineCommandDeps = {
|
|
85
43
|
env?: EnvLike;
|
|
86
44
|
output?: OutputLike;
|
|
@@ -101,341 +59,8 @@ type MachineCommandDeps = {
|
|
|
101
59
|
}) => { pid?: number };
|
|
102
60
|
};
|
|
103
61
|
|
|
104
|
-
type PackageJson = {
|
|
105
|
-
name?: string;
|
|
106
|
-
workspaces?: string[] | { packages?: string[] };
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const CONNECTOR_RUNTIME_WORKSPACE_PACKAGES = new Set([
|
|
110
|
-
"connector-experimental",
|
|
111
|
-
"ai",
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
|
-
function resolveServerUrl(env: EnvLike) {
|
|
115
|
-
return (env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function resolveAuthToken(env: EnvLike) {
|
|
119
|
-
return env.AUTH_TOKEN || env.AUTH || "";
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function writeAuthMissing(output: OutputLike) {
|
|
123
|
-
output.write(
|
|
124
|
-
"[nolo] Machine commands require an auth token. Run `nolo login` or set AUTH_TOKEN.\n"
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function hasFlag(args: string[], flag: string) {
|
|
129
|
-
return args.includes(flag);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function normalizePath(path: string) {
|
|
133
|
-
const resolved = resolve(path);
|
|
134
|
-
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function isInsideOrSame(path: string, parent: string) {
|
|
138
|
-
const relativePath = relative(parent, path);
|
|
139
|
-
return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function readJsonFile<T>(path: string): T | null {
|
|
143
|
-
try {
|
|
144
|
-
return JSON.parse(readFileSync(path, "utf8")) as T;
|
|
145
|
-
} catch {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function getWorkspacePatterns(packageJson: PackageJson) {
|
|
151
|
-
if (Array.isArray(packageJson.workspaces)) return packageJson.workspaces;
|
|
152
|
-
return packageJson.workspaces?.packages ?? [];
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function findWorkspaceRoot(startPath: string) {
|
|
156
|
-
let current = resolve(startPath);
|
|
157
|
-
while (true) {
|
|
158
|
-
const packageJsonPath = join(current, "package.json");
|
|
159
|
-
if (existsSync(packageJsonPath)) {
|
|
160
|
-
const packageJson = readJsonFile<PackageJson>(packageJsonPath);
|
|
161
|
-
if (packageJson && getWorkspacePatterns(packageJson).length > 0) {
|
|
162
|
-
return current;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const parent = dirname(current);
|
|
166
|
-
if (parent === current) return null;
|
|
167
|
-
current = parent;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function validateConnectorWorkspaceLinks(cwd: string) {
|
|
172
|
-
const repoRoot = findWorkspaceRoot(cwd);
|
|
173
|
-
if (!repoRoot) return [];
|
|
174
|
-
|
|
175
|
-
const rootPackageJson = readJsonFile<PackageJson>(join(repoRoot, "package.json"));
|
|
176
|
-
if (!rootPackageJson) return [];
|
|
177
|
-
|
|
178
|
-
const normalizedRepoRoot = normalizePath(realpathSync(repoRoot));
|
|
179
|
-
const errors: string[] = [];
|
|
180
|
-
|
|
181
|
-
for (const pattern of getWorkspacePatterns(rootPackageJson)) {
|
|
182
|
-
if (!pattern.endsWith("/*")) continue;
|
|
183
|
-
const workspaceParent = join(repoRoot, pattern.slice(0, -2));
|
|
184
|
-
if (!existsSync(workspaceParent)) continue;
|
|
185
|
-
|
|
186
|
-
for (const entry of Array.from(new Bun.Glob("*/package.json").scanSync({ cwd: workspaceParent }))) {
|
|
187
|
-
const packageDir = join(workspaceParent, dirname(entry));
|
|
188
|
-
const packageJson = readJsonFile<PackageJson>(join(workspaceParent, entry));
|
|
189
|
-
if (!packageJson?.name || !CONNECTOR_RUNTIME_WORKSPACE_PACKAGES.has(packageJson.name)) {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const linkPath = join(repoRoot, "node_modules", ...packageJson.name.split("/"));
|
|
194
|
-
if (!existsSync(linkPath)) {
|
|
195
|
-
errors.push(`${linkPath} is missing. Run bun install in ${repoRoot}.`);
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const actualPath = normalizePath(realpathSync(linkPath));
|
|
200
|
-
const expectedPath = normalizePath(realpathSync(packageDir));
|
|
201
|
-
if (!isInsideOrSame(actualPath, normalizedRepoRoot)) {
|
|
202
|
-
errors.push(
|
|
203
|
-
`${linkPath} points outside this checkout: ${actualPath}. Run bun install in ${repoRoot}.`,
|
|
204
|
-
);
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
if (actualPath !== expectedPath) {
|
|
208
|
-
errors.push(
|
|
209
|
-
`${linkPath} points at ${actualPath}, expected ${expectedPath}. Run bun install in ${repoRoot}.`,
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return errors;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
async function checkConnectorWorkspaceLinks(
|
|
219
|
-
cwd: string,
|
|
220
|
-
output: OutputLike,
|
|
221
|
-
validateWorkspaceLinks: (cwd: string) => string[] | Promise<string[]>,
|
|
222
|
-
) {
|
|
223
|
-
const errors = await validateWorkspaceLinks(cwd);
|
|
224
|
-
if (errors.length === 0) return true;
|
|
225
|
-
output.write(
|
|
226
|
-
[
|
|
227
|
-
"[nolo] Connector workspace package links are unsafe.",
|
|
228
|
-
"The connector would import workspace packages from a different checkout, so machine capabilities and runtime behavior may be stale.",
|
|
229
|
-
...errors,
|
|
230
|
-
"",
|
|
231
|
-
].join("\n"),
|
|
232
|
-
);
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function readOption(args: string[], flag: string) {
|
|
237
|
-
for (let i = 0; i < args.length; i++) {
|
|
238
|
-
const arg = args[i];
|
|
239
|
-
if (arg === flag) {
|
|
240
|
-
const next = args[i + 1];
|
|
241
|
-
if (typeof next === "string" && !next.startsWith("-")) return next;
|
|
242
|
-
return "";
|
|
243
|
-
}
|
|
244
|
-
if (arg.startsWith(flag + "=")) {
|
|
245
|
-
return arg.slice(flag.length + 1);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return "";
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function resolveConnectServerUrl(args: string[], env: EnvLike) {
|
|
252
|
-
const fromFlag = readOption(args, "--server-url") || readOption(args, "--server");
|
|
253
|
-
const raw = fromFlag || env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL;
|
|
254
|
-
return String(raw).replace(/\/+$|\s+$/g, "").replace(/\/+$/g, "").replace(/\s+$/g, "");
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function resolveConnectAuthToken(args: string[], env: EnvLike) {
|
|
258
|
-
return readOption(args, "--api-key") || readOption(args, "--token") || resolveAuthToken(env);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function resolveDaemonLogPath(env: EnvLike) {
|
|
262
|
-
return env.NOLO_CONNECT_LOG || join(homedir(), ".nolo", "logs", "connector.log");
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function byteLength(value: string) {
|
|
266
|
-
return Buffer.byteLength(value, "utf8");
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function shortHash(value: string) {
|
|
270
|
-
return createHash("sha256").update(value).digest("hex").slice(0, 12);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function resolvePromptInlineMaxBytes(env: EnvLike) {
|
|
274
|
-
const raw = Number(env.NOLO_CONNECTOR_PROMPT_INLINE_MAX_BYTES);
|
|
275
|
-
return Number.isFinite(raw) && raw >= 1024 ? raw : 32_000;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function materializeLargeConnectorPrompt(args: {
|
|
279
|
-
prompt: string;
|
|
280
|
-
cwd: string;
|
|
281
|
-
env: EnvLike;
|
|
282
|
-
requestId: string;
|
|
283
|
-
runtimePromptPage?: {
|
|
284
|
-
dbKey?: string;
|
|
285
|
-
promptHash?: string;
|
|
286
|
-
contentBytes?: number;
|
|
287
|
-
} | null;
|
|
288
|
-
}) {
|
|
289
|
-
const promptBytes = byteLength(args.prompt);
|
|
290
|
-
const promptHash = shortHash(args.prompt);
|
|
291
|
-
const maxInlineBytes = resolvePromptInlineMaxBytes(args.env);
|
|
292
|
-
if (promptBytes <= maxInlineBytes) {
|
|
293
|
-
return {
|
|
294
|
-
prompt: args.prompt,
|
|
295
|
-
promptBytes,
|
|
296
|
-
promptHash,
|
|
297
|
-
promptRef: null as string | null,
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
const promptDir = join(args.cwd, ".nolo", "agent-prompts");
|
|
302
|
-
mkdirSync(promptDir, { recursive: true });
|
|
303
|
-
const promptRef = join(promptDir, `${args.requestId}-${promptHash}.md`);
|
|
304
|
-
writeFileSync(promptRef, args.prompt, "utf8");
|
|
305
|
-
|
|
306
|
-
return {
|
|
307
|
-
prompt: [
|
|
308
|
-
"A large Nolo runtime prompt has been materialized outside this command argument.",
|
|
309
|
-
...(args.runtimePromptPage?.dbKey
|
|
310
|
-
? [
|
|
311
|
-
"Cloud prompt page is the shared audit/context source.",
|
|
312
|
-
`Cloud prompt page: ${args.runtimePromptPage.dbKey}`,
|
|
313
|
-
`Read cloud page: bun packages/cli/index.ts doc read ${JSON.stringify(args.runtimePromptPage.dbKey)}`,
|
|
314
|
-
...(args.runtimePromptPage.promptHash
|
|
315
|
-
? [`Cloud prompt sha256 prefix: ${args.runtimePromptPage.promptHash}`]
|
|
316
|
-
: []),
|
|
317
|
-
"",
|
|
318
|
-
]
|
|
319
|
-
: []),
|
|
320
|
-
"Local prompt file is the execution-machine fallback and should match the cloud page content at run start.",
|
|
321
|
-
`Prompt file: ${promptRef}`,
|
|
322
|
-
`Prompt bytes: ${promptBytes}`,
|
|
323
|
-
`Prompt sha256 prefix: ${promptHash}`,
|
|
324
|
-
"",
|
|
325
|
-
"Prefer the cloud prompt page for shared context when readable; use the local prompt file as fallback.",
|
|
326
|
-
"Local repository edits, diffs, test output, and commits are still authoritative for local execution facts.",
|
|
327
|
-
"If neither source is readable, stop and report PROMPT_REF_UNREADABLE with both references.",
|
|
328
|
-
].join("\n"),
|
|
329
|
-
promptBytes,
|
|
330
|
-
promptHash,
|
|
331
|
-
promptRef,
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function readRuntimePromptPageMeta(parsed: any) {
|
|
336
|
-
const page = parsed?.payload?.meta?.runtimePromptPage;
|
|
337
|
-
if (!page || typeof page !== "object") return null;
|
|
338
|
-
return {
|
|
339
|
-
dbKey: typeof page.dbKey === "string" ? page.dbKey : undefined,
|
|
340
|
-
promptHash: typeof page.promptHash === "string" ? page.promptHash : undefined,
|
|
341
|
-
contentBytes: typeof page.contentBytes === "number" ? page.contentBytes : undefined,
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function logConnectorRun(message: string, fields: Record<string, unknown> = {}) {
|
|
346
|
-
console.error(`[nolo-connector] ${message} ${JSON.stringify(fields)}`);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
function buildDaemonCommand(cliEntrypointPath: string | undefined) {
|
|
350
|
-
return [process.execPath, cliEntrypointPath || import.meta.path, "connect", "--ws"];
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function defaultSpawnDaemon(args: {
|
|
354
|
-
cmd: string[];
|
|
355
|
-
cwd: string;
|
|
356
|
-
env: EnvLike;
|
|
357
|
-
logPath: string;
|
|
358
|
-
}) {
|
|
359
|
-
mkdirSync(dirname(args.logPath), { recursive: true });
|
|
360
|
-
const out = openSync(args.logPath, "a");
|
|
361
|
-
const env = Object.fromEntries(
|
|
362
|
-
Object.entries(args.env).filter((entry): entry is [string, string] => typeof entry[1] === "string")
|
|
363
|
-
);
|
|
364
|
-
const proc = spawn(args.cmd[0], args.cmd.slice(1), {
|
|
365
|
-
cwd: args.cwd,
|
|
366
|
-
env,
|
|
367
|
-
detached: true,
|
|
368
|
-
stdio: ["ignore", out, out],
|
|
369
|
-
});
|
|
370
|
-
proc.unref();
|
|
371
|
-
return { pid: proc.pid };
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function resolveHeartbeatIntervalMs(env: EnvLike) {
|
|
375
|
-
const raw = Number(env.NOLO_CONNECT_HEARTBEAT_MS ?? "");
|
|
376
|
-
return Number.isFinite(raw) && raw > 0 ? raw : 30_000;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const CONNECTOR_WS_KEEPALIVE_MS = 25_000;
|
|
380
|
-
|
|
381
|
-
function buildConnectorKeepaliveMessage() {
|
|
382
|
-
return JSON.stringify({ type: "connector.keepalive", sentAt: Date.now() });
|
|
383
|
-
}
|
|
384
|
-
|
|
385
62
|
const defaultSleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));
|
|
386
63
|
|
|
387
|
-
function resolveConnectorReconnectDelayMs(env: EnvLike) {
|
|
388
|
-
const raw = Number(env.NOLO_CONNECT_RECONNECT_MS ?? "");
|
|
389
|
-
return Number.isFinite(raw) && raw >= 0 ? raw : 5_000;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
async function defaultConnectWebSocket(url: string, options: ConnectorWebSocketOptions) {
|
|
393
|
-
const WebSocketCtor = globalThis.WebSocket;
|
|
394
|
-
if (!WebSocketCtor) {
|
|
395
|
-
throw new Error("WebSocket is not available in this runtime");
|
|
396
|
-
}
|
|
397
|
-
await new Promise<void>((resolve, reject) => {
|
|
398
|
-
const ws = new WebSocketCtor(url, {
|
|
399
|
-
headers: options.headers,
|
|
400
|
-
} as any);
|
|
401
|
-
let opened = false;
|
|
402
|
-
let keepalive: ReturnType<typeof setInterval> | null = null;
|
|
403
|
-
const clearKeepalive = () => {
|
|
404
|
-
if (keepalive) {
|
|
405
|
-
clearInterval(keepalive);
|
|
406
|
-
keepalive = null;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
ws.addEventListener("open", () => {
|
|
410
|
-
opened = true;
|
|
411
|
-
keepalive = setInterval(() => {
|
|
412
|
-
try {
|
|
413
|
-
ws.send(buildConnectorKeepaliveMessage());
|
|
414
|
-
} catch {
|
|
415
|
-
clearKeepalive();
|
|
416
|
-
}
|
|
417
|
-
}, CONNECTOR_WS_KEEPALIVE_MS);
|
|
418
|
-
}, { once: true });
|
|
419
|
-
ws.addEventListener("error", () => {
|
|
420
|
-
clearKeepalive();
|
|
421
|
-
reject(new Error("connector websocket failed"));
|
|
422
|
-
});
|
|
423
|
-
ws.addEventListener("close", () => {
|
|
424
|
-
clearKeepalive();
|
|
425
|
-
if (opened) resolve();
|
|
426
|
-
else reject(new Error("connector websocket closed before opening"));
|
|
427
|
-
}, { once: true });
|
|
428
|
-
ws.addEventListener("message", (event) => {
|
|
429
|
-
const startIndex = options.sentMessages.length;
|
|
430
|
-
Promise.resolve(options.onMessage(String(event.data))).then(() => {
|
|
431
|
-
for (const message of options.sentMessages.slice(startIndex)) {
|
|
432
|
-
ws.send(message);
|
|
433
|
-
}
|
|
434
|
-
}).catch(() => undefined);
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
64
|
async function defaultExecuteCli(
|
|
440
65
|
provider: string,
|
|
441
66
|
prompt: string,
|
|
@@ -444,617 +69,12 @@ async function defaultExecuteCli(
|
|
|
444
69
|
const { executeCli } = await import("./ai/agent/cliExecutor");
|
|
445
70
|
return executeCli(provider as any, prompt, options);
|
|
446
71
|
}
|
|
447
|
-
|
|
448
|
-
function detectLaunchableMachineInfo() {
|
|
449
|
-
return detectMachineInfo({ probeLaunchable: true });
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
function inferTaskRunRole(agentKey: string, agentConfig: any) {
|
|
453
|
-
const haystack = [
|
|
454
|
-
agentKey,
|
|
455
|
-
agentConfig?.name,
|
|
456
|
-
agentConfig?.prompt,
|
|
457
|
-
].filter(Boolean).join("\n").toLowerCase();
|
|
458
|
-
if (haystack.includes("frontend") || haystack.includes("前端")) return "frontend";
|
|
459
|
-
if (haystack.includes("fullstack") || haystack.includes("全栈")) return "fullstack";
|
|
460
|
-
if (haystack.includes("review") || haystack.includes("审查")) return "reviewer";
|
|
461
|
-
if (haystack.includes("project-manager") || haystack.includes("项目经理")) return "pm";
|
|
462
|
-
return "codex";
|
|
463
|
-
}
|
|
464
72
|
|
|
465
|
-
function
|
|
466
|
-
|
|
467
|
-
agentConfig: any;
|
|
468
|
-
runtimeContext: any;
|
|
469
|
-
}) {
|
|
470
|
-
const taskRun = args.runtimeContext?.taskRun;
|
|
471
|
-
const rowDbKey = typeof taskRun?.rowDbKey === "string" ? taskRun.rowDbKey.trim() : "";
|
|
472
|
-
if (!rowDbKey) return "";
|
|
473
|
-
const workItemId = typeof taskRun?.workItemId === "string" ? taskRun.workItemId.trim() : "";
|
|
474
|
-
const role = inferTaskRunRole(args.agentKey, args.agentConfig);
|
|
475
|
-
return [
|
|
476
|
-
"--- Nolo task-run tool bridge ---",
|
|
477
|
-
"This CLI runtime does not receive server-side function tools directly.",
|
|
478
|
-
"Use the local task-run bridge command for durable task state writes. Do not edit meta.taskRun with table or database commands.",
|
|
479
|
-
"Run commands from the repository root. The runner already provides server URL and auth in the environment.",
|
|
480
|
-
"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.",
|
|
481
|
-
"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.",
|
|
482
|
-
"Handoff context: start from read-context, then inspect existing refs such as workItems.dialogIds, workItems.outcome, review.dialogId, activityRefs, agentRuns.dialogId/resultSummary, and artifactRefs. Use dialog read/search for exact evidence; do not infer completion from handoff text alone.",
|
|
483
|
-
`Read context: bun packages/cli/index.ts task-run read-context --row-dbkey ${JSON.stringify(rowDbKey)}`,
|
|
484
|
-
...(workItemId
|
|
485
|
-
? [
|
|
486
|
-
`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}`,
|
|
487
|
-
`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>`,
|
|
488
|
-
`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>`,
|
|
489
|
-
`Submit outcome: bun packages/cli/index.ts task-run submit-outcome --row-dbkey ${JSON.stringify(rowDbKey)} --work-item-id ${JSON.stringify(workItemId)} --summary <SUMMARY>`,
|
|
490
|
-
`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>`,
|
|
491
|
-
`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>`,
|
|
492
|
-
`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>`,
|
|
493
|
-
]
|
|
494
|
-
: []),
|
|
495
|
-
"If a bridge command fails, report the exact command and error.",
|
|
496
|
-
].join("\n");
|
|
73
|
+
function detectLaunchableMachineInfo() {
|
|
74
|
+
return detectMachineInfo({ probeLaunchable: true });
|
|
497
75
|
}
|
|
498
76
|
|
|
499
|
-
function
|
|
500
|
-
agentKey: string;
|
|
501
|
-
runtimeContext: any;
|
|
502
|
-
}, permissionPolicy?: ReturnType<typeof resolveMachineRunPermissionPolicy>) {
|
|
503
|
-
const policy = permissionPolicy ?? resolveMachineRunPermissionPolicy(agentConfig);
|
|
504
|
-
return [
|
|
505
|
-
typeof agentConfig?.prompt === "string" ? agentConfig.prompt.trim() : "",
|
|
506
|
-
bridgeArgs ? buildTaskRunBridgePrompt({
|
|
507
|
-
agentKey: bridgeArgs.agentKey,
|
|
508
|
-
agentConfig,
|
|
509
|
-
runtimeContext: bridgeArgs.runtimeContext,
|
|
510
|
-
}) : "",
|
|
511
|
-
buildMachinePermissionPromptBlock(policy),
|
|
512
|
-
`--- User task ---\n${userInput}`,
|
|
513
|
-
].filter(Boolean).join("\n\n");
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
function isRecord(value: unknown): value is Record<string, any> {
|
|
517
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
function runtimePolicyFromConnectorPayload(parsed: any): ConnectorRuntimePolicy | undefined {
|
|
521
|
-
const fromMeta = parsed?.payload?.meta?.runtimeToolPolicySnapshot;
|
|
522
|
-
const fromAgent = parsed?.payload?.agentConfig?.runtimeToolPolicy;
|
|
523
|
-
const policy = isRecord(fromMeta) ? fromMeta : isRecord(fromAgent) ? fromAgent : null;
|
|
524
|
-
return policy ? policy as ConnectorRuntimePolicy : undefined;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
function requestsTaskWorktree(policy?: ConnectorRuntimePolicy) {
|
|
528
|
-
return policy?.workspace?.mode === "task-worktree" || policy?.workspace?.mode === "lease";
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function hasExplicitMachinePermissions(agentConfig: any) {
|
|
532
|
-
const runtimeBinding = isRecord(agentConfig?.runtimeBinding) ? agentConfig.runtimeBinding : {};
|
|
533
|
-
return Boolean(
|
|
534
|
-
isRecord(agentConfig?.machinePermissions) ||
|
|
535
|
-
isRecord(runtimeBinding.permissions) ||
|
|
536
|
-
isRecord(runtimeBinding.machinePermissions) ||
|
|
537
|
-
isRecord(agentConfig?.boundRuntimeMachine?.permissions)
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
function runtimeWorkspacePermissionPolicy(
|
|
542
|
-
runtimePolicy: ConnectorRuntimePolicy | undefined,
|
|
543
|
-
cwd: string
|
|
544
|
-
): ReturnType<typeof resolveMachineRunPermissionPolicy> | null {
|
|
545
|
-
if (!requestsTaskWorktree(runtimePolicy)) return null;
|
|
546
|
-
return {
|
|
547
|
-
mode: "full_access",
|
|
548
|
-
allowFilesystemRead: true,
|
|
549
|
-
allowFilesystemWrite: true,
|
|
550
|
-
allowShell: runtimePolicy?.shell?.enabled !== false,
|
|
551
|
-
writableRoots: [cwd],
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
function scopePermissionPolicyToRuntimeWorkspace(
|
|
556
|
-
policy: ReturnType<typeof resolveMachineRunPermissionPolicy>,
|
|
557
|
-
runtimePolicy: ConnectorRuntimePolicy | undefined,
|
|
558
|
-
cwd: string
|
|
559
|
-
): ReturnType<typeof resolveMachineRunPermissionPolicy> {
|
|
560
|
-
if (!requestsTaskWorktree(runtimePolicy)) return policy;
|
|
561
|
-
return {
|
|
562
|
-
...policy,
|
|
563
|
-
writableRoots: policy.allowFilesystemWrite ? [cwd] : [],
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
function mergeToolNames(...values: unknown[]) {
|
|
568
|
-
const names: string[] = [];
|
|
569
|
-
for (const value of values) {
|
|
570
|
-
if (!Array.isArray(value)) continue;
|
|
571
|
-
for (const item of value) {
|
|
572
|
-
const name = typeof item === "string"
|
|
573
|
-
? item
|
|
574
|
-
: isRecord(item) && typeof item.name === "string"
|
|
575
|
-
? item.name
|
|
576
|
-
: isRecord(item) && typeof item.function?.name === "string"
|
|
577
|
-
? item.function.name
|
|
578
|
-
: "";
|
|
579
|
-
if (name && !names.includes(name)) names.push(name);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
return names;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
function localRuntimeEnvFromPolicy(runtimeEnv: EnvLike, policy?: ConnectorRuntimePolicy): EnvLike {
|
|
586
|
-
return {
|
|
587
|
-
...runtimeEnv,
|
|
588
|
-
...(policy?.shell?.enabled && policy.shell.mode === "worktree"
|
|
589
|
-
? { NOLO_LOCAL_SHELL_MODE: "worktree" }
|
|
590
|
-
: {}),
|
|
591
|
-
...(policy?.workspace?.cwd ? { NOLO_LOCAL_WORKTREE: policy.workspace.cwd } : {}),
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
function runtimeWorkspaceRootFromTrace(trace: unknown): string | undefined {
|
|
596
|
-
if (!Array.isArray(trace)) return undefined;
|
|
597
|
-
for (const message of trace) {
|
|
598
|
-
if (!isRecord(message)) continue;
|
|
599
|
-
const metadata = isRecord(message.tool_result_metadata)
|
|
600
|
-
? message.tool_result_metadata
|
|
601
|
-
: null;
|
|
602
|
-
const workspaceRoot = metadata && typeof metadata.workspaceRoot === "string"
|
|
603
|
-
? metadata.workspaceRoot.trim()
|
|
604
|
-
: "";
|
|
605
|
-
if (workspaceRoot) return workspaceRoot;
|
|
606
|
-
}
|
|
607
|
-
return undefined;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
function buildArtifactProgress(args: {
|
|
611
|
-
artifacts: unknown;
|
|
612
|
-
runtimePolicy?: ConnectorRuntimePolicy;
|
|
613
|
-
workspaceRoot: string;
|
|
614
|
-
workspaceKind?: string;
|
|
615
|
-
}): ConnectorRunProgress | null {
|
|
616
|
-
if (!isRecord(args.artifacts)) return null;
|
|
617
|
-
const changedFiles = Array.isArray(args.artifacts.changedFiles)
|
|
618
|
-
? args.artifacts.changedFiles
|
|
619
|
-
: [];
|
|
620
|
-
const statusShort = typeof args.artifacts.statusShort === "string"
|
|
621
|
-
? args.artifacts.statusShort.trim()
|
|
622
|
-
: "";
|
|
623
|
-
if (changedFiles.length === 0 && !statusShort) return null;
|
|
624
|
-
const runtimeTools = Array.isArray(args.runtimePolicy?.runtimeTools)
|
|
625
|
-
? args.runtimePolicy.runtimeTools
|
|
626
|
-
: [];
|
|
627
|
-
const shellTool = runtimeTools.includes("execShell")
|
|
628
|
-
? "execShell"
|
|
629
|
-
: "workspaceArtifact";
|
|
630
|
-
return {
|
|
631
|
-
eventType: "tool-result",
|
|
632
|
-
toolCallCount: 1,
|
|
633
|
-
toolResultCount: 1,
|
|
634
|
-
lastToolNames: [shellTool],
|
|
635
|
-
workspaceRoot: args.workspaceRoot,
|
|
636
|
-
...(args.workspaceKind ? { workspaceKind: args.workspaceKind } : {}),
|
|
637
|
-
message: statusShort || `${changedFiles.length} changed file(s)`,
|
|
638
|
-
updatedAt: Date.now(),
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
async function runConnectorLocalRuntimeAgent(args: {
|
|
643
|
-
parsed: any;
|
|
644
|
-
runtimeEnv: EnvLike;
|
|
645
|
-
cwd: string;
|
|
646
|
-
fetchImpl?: typeof fetch;
|
|
647
|
-
onProgress?: (progress: ConnectorRunProgress) => void;
|
|
648
|
-
}): Promise<Awaited<ReturnType<typeof runLocalAgentTurn>> & { runtimeWorkspaceRoot?: string }> {
|
|
649
|
-
const agentKey = String(args.parsed.payload?.agentKey ?? "");
|
|
650
|
-
const payloadAgentConfig = isRecord(args.parsed.payload?.agentConfig)
|
|
651
|
-
? args.parsed.payload.agentConfig
|
|
652
|
-
: {};
|
|
653
|
-
const policy = runtimePolicyFromConnectorPayload(args.parsed);
|
|
654
|
-
const agentRecord = {
|
|
655
|
-
...payloadAgentConfig,
|
|
656
|
-
dbKey: agentKey,
|
|
657
|
-
id: agentKey,
|
|
658
|
-
key: agentKey,
|
|
659
|
-
apiSource: payloadAgentConfig.apiSource ?? "platform",
|
|
660
|
-
provider: payloadAgentConfig.provider ?? payloadAgentConfig.apiSource ?? "openai",
|
|
661
|
-
toolNames: mergeToolNames(
|
|
662
|
-
payloadAgentConfig.toolNames,
|
|
663
|
-
payloadAgentConfig.tools,
|
|
664
|
-
policy?.agentTools,
|
|
665
|
-
policy?.runtimeTools,
|
|
666
|
-
),
|
|
667
|
-
...(policy ? { runtimeToolPolicy: policy } : {}),
|
|
668
|
-
...(policy?.workspace?.mode === "task-worktree" || policy?.workspace?.mode === "lease"
|
|
669
|
-
? { localWorkspaceMode: "task-worktree" }
|
|
670
|
-
: {}),
|
|
671
|
-
};
|
|
672
|
-
const store = new Map<string, any>([
|
|
673
|
-
[agentKey, agentRecord],
|
|
674
|
-
[`agent-${args.runtimeEnv.NOLO_USER_ID || "local"}-${agentKey}`, agentRecord],
|
|
675
|
-
[`agent-${args.runtimeEnv.NOLO_LOCAL_USER_ID || args.runtimeEnv.NOLO_USER_ID || "local"}-${agentKey}`, agentRecord],
|
|
676
|
-
]);
|
|
677
|
-
const env = localRuntimeEnvFromPolicy(args.runtimeEnv, policy);
|
|
678
|
-
const wantsTaskWorktree = requestsTaskWorktree(policy);
|
|
679
|
-
const adapter = createCliLocalRuntimeAdapter({
|
|
680
|
-
env,
|
|
681
|
-
cwd: args.cwd,
|
|
682
|
-
useCwdAsTaskWorkspaceBase: wantsTaskWorktree,
|
|
683
|
-
...(wantsTaskWorktree
|
|
684
|
-
? {
|
|
685
|
-
prepareTaskWorktree: (input) => prepareTaskWorktree({
|
|
686
|
-
...input,
|
|
687
|
-
cwd: args.cwd,
|
|
688
|
-
}),
|
|
689
|
-
}
|
|
690
|
-
: {}),
|
|
691
|
-
fetchImpl: args.fetchImpl ?? fetch,
|
|
692
|
-
store: {
|
|
693
|
-
read: async (key) => store.get(key) ?? null,
|
|
694
|
-
batch: async (ops) => {
|
|
695
|
-
for (const op of ops) {
|
|
696
|
-
if (op.type === "put") store.set(op.key, op.value);
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
iterator: async function* (options) {
|
|
700
|
-
const keys = [...store.keys()].sort();
|
|
701
|
-
for (const key of keys) {
|
|
702
|
-
if (key < options.gte) continue;
|
|
703
|
-
if (options.lte && key > options.lte) continue;
|
|
704
|
-
if (options.lt && key >= options.lt) continue;
|
|
705
|
-
yield [key, store.get(key)];
|
|
706
|
-
}
|
|
707
|
-
},
|
|
708
|
-
},
|
|
709
|
-
});
|
|
710
|
-
let toolCallCount = 0;
|
|
711
|
-
let toolResultCount = 0;
|
|
712
|
-
const lastToolNames: string[] = [];
|
|
713
|
-
let runtimeWorkspaceRoot: string | undefined;
|
|
714
|
-
let runtimeWorkspaceKind: string | undefined;
|
|
715
|
-
const noteToolName = (toolName: string) => {
|
|
716
|
-
if (!toolName) return;
|
|
717
|
-
const existingIndex = lastToolNames.indexOf(toolName);
|
|
718
|
-
if (existingIndex >= 0) lastToolNames.splice(existingIndex, 1);
|
|
719
|
-
lastToolNames.push(toolName);
|
|
720
|
-
while (lastToolNames.length > 8) lastToolNames.shift();
|
|
721
|
-
};
|
|
722
|
-
const result = await runLocalAgentTurn({
|
|
723
|
-
adapter,
|
|
724
|
-
agentRef: agentKey,
|
|
725
|
-
input: String(args.parsed.payload?.userInput ?? ""),
|
|
726
|
-
continueDialogId: typeof args.parsed.payload?.continueDialogId === "string"
|
|
727
|
-
? args.parsed.payload.continueDialogId
|
|
728
|
-
: undefined,
|
|
729
|
-
onToolEvent: (event) => {
|
|
730
|
-
if (event.type === "tool-call") toolCallCount += 1;
|
|
731
|
-
if (event.type === "tool-result") toolResultCount += 1;
|
|
732
|
-
noteToolName(event.toolName);
|
|
733
|
-
const metadata = isRecord(event.metadata) ? event.metadata : {};
|
|
734
|
-
if (typeof metadata.workspaceRoot === "string" && metadata.workspaceRoot.trim()) {
|
|
735
|
-
runtimeWorkspaceRoot = metadata.workspaceRoot.trim();
|
|
736
|
-
}
|
|
737
|
-
if (typeof metadata.workspaceKind === "string" && metadata.workspaceKind.trim()) {
|
|
738
|
-
runtimeWorkspaceKind = metadata.workspaceKind.trim();
|
|
739
|
-
}
|
|
740
|
-
args.onProgress?.({
|
|
741
|
-
eventType: event.type,
|
|
742
|
-
toolCallCount,
|
|
743
|
-
toolResultCount,
|
|
744
|
-
lastToolNames: [...lastToolNames],
|
|
745
|
-
...(runtimeWorkspaceRoot ? { workspaceRoot: runtimeWorkspaceRoot } : {}),
|
|
746
|
-
...(runtimeWorkspaceKind ? { workspaceKind: runtimeWorkspaceKind } : {}),
|
|
747
|
-
...(event.message ? { message: event.message } : {}),
|
|
748
|
-
updatedAt: Date.now(),
|
|
749
|
-
});
|
|
750
|
-
},
|
|
751
|
-
});
|
|
752
|
-
return {
|
|
753
|
-
...result,
|
|
754
|
-
runtimeWorkspaceRoot: runtimeWorkspaceRootFromTrace(result.trace) ?? runtimeWorkspaceRoot,
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
function normalizeConnectorRunTimeoutMs(value: unknown): number | undefined {
|
|
759
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
760
|
-
return undefined;
|
|
761
|
-
}
|
|
762
|
-
return Math.floor(value);
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
export async function handleConnectorRunMessage(
|
|
766
|
-
machine: MachineHeartbeat,
|
|
767
|
-
message: string,
|
|
768
|
-
send: (message: string) => void,
|
|
769
|
-
executeCli: LocalCliExecutor,
|
|
770
|
-
runtimeEnv: EnvLike,
|
|
771
|
-
fetchImpl?: typeof fetch
|
|
772
|
-
) {
|
|
773
|
-
let parsed: any;
|
|
774
|
-
try {
|
|
775
|
-
parsed = JSON.parse(message);
|
|
776
|
-
} catch {
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
if (parsed?.type !== "agent.run" || typeof parsed.requestId !== "string") return;
|
|
780
|
-
const agentConfig = parsed.payload?.agentConfig ?? {};
|
|
781
|
-
const sendProgress = (progress: ConnectorRunProgress) => {
|
|
782
|
-
send(JSON.stringify({
|
|
783
|
-
type: "agent.run.progress",
|
|
784
|
-
requestId: parsed.requestId,
|
|
785
|
-
progress,
|
|
786
|
-
}));
|
|
787
|
-
};
|
|
788
|
-
try {
|
|
789
|
-
const machinePermissionPolicy = resolveMachineRunPermissionPolicy(agentConfig);
|
|
790
|
-
const runtimePolicy = runtimePolicyFromConnectorPayload(parsed);
|
|
791
|
-
const userInput = String(parsed.payload?.userInput ?? "");
|
|
792
|
-
const timeout = normalizeConnectorRunTimeoutMs(parsed.payload?.timeoutMs);
|
|
793
|
-
let cwd = resolveConnectorRunCwd({ env: runtimeEnv, policy: machinePermissionPolicy });
|
|
794
|
-
let runContent = "";
|
|
795
|
-
let runModel = agentConfig.model;
|
|
796
|
-
let runTrace: unknown[] = [];
|
|
797
|
-
let artifactCwd = cwd;
|
|
798
|
-
let baseSha: string | null = null;
|
|
799
|
-
if (agentConfig.apiSource === "cli") {
|
|
800
|
-
if (requestsTaskWorktree(runtimePolicy)) {
|
|
801
|
-
const prepared = await prepareTaskWorktree({
|
|
802
|
-
agentKey: String(parsed.payload?.agentKey ?? "agent"),
|
|
803
|
-
cwd,
|
|
804
|
-
env: runtimeEnv,
|
|
805
|
-
});
|
|
806
|
-
cwd = prepared.path;
|
|
807
|
-
artifactCwd = prepared.path;
|
|
808
|
-
}
|
|
809
|
-
const runtimePermissionPolicy = !hasExplicitMachinePermissions(agentConfig)
|
|
810
|
-
? runtimeWorkspacePermissionPolicy(runtimePolicy, cwd)
|
|
811
|
-
: null;
|
|
812
|
-
const effectivePermissionPolicy = scopePermissionPolicyToRuntimeWorkspace(
|
|
813
|
-
runtimePermissionPolicy ?? machinePermissionPolicy,
|
|
814
|
-
runtimePolicy,
|
|
815
|
-
cwd,
|
|
816
|
-
);
|
|
817
|
-
assertMachineRunAllowed(userInput, effectivePermissionPolicy);
|
|
818
|
-
baseSha = await readConnectorGitHead(artifactCwd);
|
|
819
|
-
const provider = String(agentConfig.cliProvider || "copilot");
|
|
820
|
-
const builtPrompt = buildConnectorCliPrompt(agentConfig, userInput, {
|
|
821
|
-
agentKey: String(parsed.payload?.agentKey ?? ""),
|
|
822
|
-
runtimeContext: parsed.payload?.runtimeContext,
|
|
823
|
-
}, effectivePermissionPolicy);
|
|
824
|
-
const materializedPrompt = materializeLargeConnectorPrompt({
|
|
825
|
-
prompt: builtPrompt,
|
|
826
|
-
cwd,
|
|
827
|
-
env: runtimeEnv,
|
|
828
|
-
requestId: parsed.requestId,
|
|
829
|
-
runtimePromptPage: readRuntimePromptPageMeta(parsed),
|
|
830
|
-
});
|
|
831
|
-
const runtimePromptPage = readRuntimePromptPageMeta(parsed);
|
|
832
|
-
const startAt = Date.now();
|
|
833
|
-
const progressBase = {
|
|
834
|
-
provider,
|
|
835
|
-
requestId: parsed.requestId,
|
|
836
|
-
promptBytes: materializedPrompt.promptBytes,
|
|
837
|
-
promptHash: materializedPrompt.promptHash,
|
|
838
|
-
...(materializedPrompt.promptRef ? { promptRef: materializedPrompt.promptRef } : {}),
|
|
839
|
-
...(runtimePromptPage?.dbKey ? { promptPageKey: runtimePromptPage.dbKey } : {}),
|
|
840
|
-
...(runtimePromptPage?.promptHash ? { promptPageHash: runtimePromptPage.promptHash } : {}),
|
|
841
|
-
workspaceRoot: artifactCwd,
|
|
842
|
-
workspaceKind: requestsTaskWorktree(runtimePolicy) ? "task-worktree" : "current",
|
|
843
|
-
};
|
|
844
|
-
logConnectorRun("agent.run.cli.start", {
|
|
845
|
-
requestId: parsed.requestId,
|
|
846
|
-
agentKey: parsed.payload?.agentKey,
|
|
847
|
-
provider,
|
|
848
|
-
cwd,
|
|
849
|
-
artifactCwd,
|
|
850
|
-
timeout,
|
|
851
|
-
promptBytes: materializedPrompt.promptBytes,
|
|
852
|
-
promptHash: materializedPrompt.promptHash,
|
|
853
|
-
promptRef: materializedPrompt.promptRef,
|
|
854
|
-
promptPageKey: runtimePromptPage?.dbKey,
|
|
855
|
-
});
|
|
856
|
-
sendProgress({
|
|
857
|
-
...progressBase,
|
|
858
|
-
message: "cli-started",
|
|
859
|
-
updatedAt: startAt,
|
|
860
|
-
});
|
|
861
|
-
const heartbeat = setInterval(() => {
|
|
862
|
-
sendProgress({
|
|
863
|
-
...progressBase,
|
|
864
|
-
message: "cli-running",
|
|
865
|
-
updatedAt: Date.now(),
|
|
866
|
-
});
|
|
867
|
-
}, 15_000);
|
|
868
|
-
const result = await executeCli(
|
|
869
|
-
provider,
|
|
870
|
-
materializedPrompt.prompt,
|
|
871
|
-
{
|
|
872
|
-
model: agentConfig.model || undefined,
|
|
873
|
-
timeout,
|
|
874
|
-
cwd,
|
|
875
|
-
yolo: true,
|
|
876
|
-
env: {
|
|
877
|
-
NOLO_SERVER: runtimeEnv.NOLO_SERVER || runtimeEnv.NOLO_SERVER_URL || runtimeEnv.BASE_URL,
|
|
878
|
-
NOLO_SERVER_URL: runtimeEnv.NOLO_SERVER_URL || runtimeEnv.NOLO_SERVER || runtimeEnv.BASE_URL,
|
|
879
|
-
BASE_URL: runtimeEnv.BASE_URL || runtimeEnv.NOLO_SERVER || runtimeEnv.NOLO_SERVER_URL,
|
|
880
|
-
AUTH_TOKEN: runtimeEnv.AUTH_TOKEN || runtimeEnv.AUTH || runtimeEnv.NOLO_MACHINE_API_KEY,
|
|
881
|
-
NOLO_MACHINE_API_KEY: runtimeEnv.NOLO_MACHINE_API_KEY || runtimeEnv.AUTH_TOKEN || runtimeEnv.AUTH,
|
|
882
|
-
},
|
|
883
|
-
}
|
|
884
|
-
).finally(() => clearInterval(heartbeat));
|
|
885
|
-
logConnectorRun("agent.run.cli.result", {
|
|
886
|
-
requestId: parsed.requestId,
|
|
887
|
-
provider,
|
|
888
|
-
elapsed: result.elapsed,
|
|
889
|
-
outputBytes: byteLength(result.raw ?? result.text ?? ""),
|
|
890
|
-
});
|
|
891
|
-
runContent = result.text;
|
|
892
|
-
runModel = String(agentConfig.model || "").trim() || provider;
|
|
893
|
-
runTrace = [{ role: "assistant", content: result.text }];
|
|
894
|
-
const artifacts = await collectConnectorRunArtifact({
|
|
895
|
-
cwd: artifactCwd,
|
|
896
|
-
baseSha,
|
|
897
|
-
exitStatus: "completed",
|
|
898
|
-
});
|
|
899
|
-
const artifactProgress = buildArtifactProgress({
|
|
900
|
-
artifacts,
|
|
901
|
-
runtimePolicy,
|
|
902
|
-
workspaceRoot: artifactCwd,
|
|
903
|
-
workspaceKind: requestsTaskWorktree(runtimePolicy) ? "task-worktree" : "current",
|
|
904
|
-
});
|
|
905
|
-
if (artifactProgress && requestsTaskWorktree(runtimePolicy)) sendProgress(artifactProgress);
|
|
906
|
-
send(JSON.stringify({
|
|
907
|
-
type: "agent.run.result",
|
|
908
|
-
requestId: parsed.requestId,
|
|
909
|
-
result: {
|
|
910
|
-
content: runContent,
|
|
911
|
-
model: runModel,
|
|
912
|
-
trace: runTrace,
|
|
913
|
-
artifacts,
|
|
914
|
-
},
|
|
915
|
-
}));
|
|
916
|
-
return;
|
|
917
|
-
} else {
|
|
918
|
-
if (!runtimePolicy) {
|
|
919
|
-
throw new Error("Connector can only execute non-CLI agents when runtimeToolPolicySnapshot requests a local workspace runtime.");
|
|
920
|
-
}
|
|
921
|
-
baseSha = await readConnectorGitHead(cwd);
|
|
922
|
-
const result = await runConnectorLocalRuntimeAgent({
|
|
923
|
-
parsed,
|
|
924
|
-
runtimeEnv,
|
|
925
|
-
cwd,
|
|
926
|
-
fetchImpl,
|
|
927
|
-
onProgress: sendProgress,
|
|
928
|
-
});
|
|
929
|
-
runContent = result.content;
|
|
930
|
-
runModel = result.model;
|
|
931
|
-
runTrace = result.trace ?? [];
|
|
932
|
-
artifactCwd = result.runtimeWorkspaceRoot ?? cwd;
|
|
933
|
-
}
|
|
934
|
-
const artifacts = await collectConnectorRunArtifact({
|
|
935
|
-
cwd: artifactCwd,
|
|
936
|
-
baseSha,
|
|
937
|
-
exitStatus: "completed",
|
|
938
|
-
});
|
|
939
|
-
const artifactProgress = buildArtifactProgress({
|
|
940
|
-
artifacts,
|
|
941
|
-
runtimePolicy,
|
|
942
|
-
workspaceRoot: artifactCwd,
|
|
943
|
-
workspaceKind: requestsTaskWorktree(runtimePolicy) ? "task-worktree" : "current",
|
|
944
|
-
});
|
|
945
|
-
if (artifactProgress && requestsTaskWorktree(runtimePolicy)) sendProgress(artifactProgress);
|
|
946
|
-
send(JSON.stringify({
|
|
947
|
-
type: "agent.run.result",
|
|
948
|
-
requestId: parsed.requestId,
|
|
949
|
-
result: {
|
|
950
|
-
content: runContent,
|
|
951
|
-
model: runModel,
|
|
952
|
-
trace: runTrace,
|
|
953
|
-
artifacts,
|
|
954
|
-
},
|
|
955
|
-
}));
|
|
956
|
-
} catch (error) {
|
|
957
|
-
logConnectorRun("agent.run.error", {
|
|
958
|
-
requestId: parsed.requestId,
|
|
959
|
-
agentKey: parsed.payload?.agentKey,
|
|
960
|
-
error: error instanceof Error ? error.message : String(error),
|
|
961
|
-
});
|
|
962
|
-
send(JSON.stringify({
|
|
963
|
-
type: "agent.run.result",
|
|
964
|
-
requestId: parsed.requestId,
|
|
965
|
-
error: error instanceof Error ? error.message : String(error),
|
|
966
|
-
}));
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
async function runConnectorWebSocketSession(options: {
|
|
971
|
-
env: EnvLike;
|
|
972
|
-
output: OutputLike;
|
|
973
|
-
machine: MachineHeartbeat;
|
|
974
|
-
sendHeartbeat: () => Promise<void>;
|
|
975
|
-
runHeartbeatLoop: (options: HeartbeatLoopOptions) => Promise<void>;
|
|
976
|
-
connectWebSocket: (url: string, options: ConnectorWebSocketOptions) => Promise<void>;
|
|
977
|
-
executeCli: LocalCliExecutor;
|
|
978
|
-
fetchImpl: typeof fetch;
|
|
979
|
-
serverUrl: string;
|
|
980
|
-
authToken: string;
|
|
981
|
-
}) {
|
|
982
|
-
const sentMessages: string[] = [];
|
|
983
|
-
const heartbeatAbort = new AbortController();
|
|
984
|
-
try {
|
|
985
|
-
await options.sendHeartbeat();
|
|
986
|
-
options.output.write(
|
|
987
|
-
`Connector websocket connected: ${options.machine.name} (${options.machine.machineId})\n`
|
|
988
|
-
);
|
|
989
|
-
const heartbeatLoopPromise = options.runHeartbeatLoop({
|
|
990
|
-
intervalMs: resolveHeartbeatIntervalMs(options.env),
|
|
991
|
-
sendHeartbeat: options.sendHeartbeat,
|
|
992
|
-
signal: heartbeatAbort.signal,
|
|
993
|
-
});
|
|
994
|
-
const wsTarget = await resolveConnectorWebSocketTarget({
|
|
995
|
-
serverUrl: options.serverUrl,
|
|
996
|
-
machineId: options.machine.machineId,
|
|
997
|
-
headers: { Authorization: `Bearer ${options.authToken}` },
|
|
998
|
-
fetchImpl: options.fetchImpl,
|
|
999
|
-
});
|
|
1000
|
-
const runtimeServerUrl =
|
|
1001
|
-
options.env.NOLO_CONNECT_RUNTIME_SERVER_URL ||
|
|
1002
|
-
options.env.NOLO_RUNTIME_SERVER_URL ||
|
|
1003
|
-
options.serverUrl;
|
|
1004
|
-
const websocketPromise = options.connectWebSocket(
|
|
1005
|
-
wsTarget,
|
|
1006
|
-
{
|
|
1007
|
-
headers: { Authorization: `Bearer ${options.authToken}` },
|
|
1008
|
-
sentMessages,
|
|
1009
|
-
onMessage: (message) => handleConnectorRunMessage(
|
|
1010
|
-
options.machine,
|
|
1011
|
-
message,
|
|
1012
|
-
(response) => sentMessages.push(response),
|
|
1013
|
-
options.executeCli,
|
|
1014
|
-
{
|
|
1015
|
-
...options.env,
|
|
1016
|
-
NOLO_SERVER: runtimeServerUrl,
|
|
1017
|
-
NOLO_SERVER_URL: runtimeServerUrl,
|
|
1018
|
-
BASE_URL: runtimeServerUrl,
|
|
1019
|
-
AUTH_TOKEN: options.authToken,
|
|
1020
|
-
NOLO_MACHINE_API_KEY: options.authToken,
|
|
1021
|
-
},
|
|
1022
|
-
options.fetchImpl
|
|
1023
|
-
),
|
|
1024
|
-
}
|
|
1025
|
-
);
|
|
1026
|
-
await Promise.race([websocketPromise, heartbeatLoopPromise]);
|
|
1027
|
-
heartbeatAbort.abort();
|
|
1028
|
-
await Promise.allSettled([websocketPromise, heartbeatLoopPromise]);
|
|
1029
|
-
return 0;
|
|
1030
|
-
} catch (error) {
|
|
1031
|
-
heartbeatAbort.abort();
|
|
1032
|
-
options.output.write(
|
|
1033
|
-
`[nolo] Connector websocket failed: ${
|
|
1034
|
-
error instanceof Error ? error.message : String(error)
|
|
1035
|
-
}\n`
|
|
1036
|
-
);
|
|
1037
|
-
return 1;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
export function formatMachineStatus(machines: MachineSummary[]) {
|
|
1042
|
-
if (machines.length === 0) {
|
|
1043
|
-
return "No connected machines.\nRun `nolo connect` on this computer to register it once.\n";
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
return [
|
|
1047
|
-
"Connected machines:",
|
|
1048
|
-
...machines.map((machine) => {
|
|
1049
|
-
const caps = machine.capabilities.length ? machine.capabilities.join(", ") : "no capabilities";
|
|
1050
|
-
const connector = machine.connectorStatus ? ` ws:${machine.connectorStatus}` : "";
|
|
1051
|
-
return `- ${machine.name} ${machine.status}${connector} ${machine.platform}/${machine.arch} ${caps}`;
|
|
1052
|
-
}),
|
|
1053
|
-
"",
|
|
1054
|
-
].join("\n");
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
export async function runMachineConnectCommand(
|
|
77
|
+
export async function runMachineConnectCommand(
|
|
1058
78
|
args: string[],
|
|
1059
79
|
deps: MachineCommandDeps = {}
|
|
1060
80
|
) {
|
|
@@ -1069,7 +89,6 @@ export async function runMachineConnectCommand(
|
|
|
1069
89
|
const serverUrl = resolveConnectServerUrl(args, env);
|
|
1070
90
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
1071
91
|
const machine = (deps.machineInfo ?? detectLaunchableMachineInfo)();
|
|
1072
|
-
const validateWorkspaceLinks = deps.validateWorkspaceLinks ?? validateConnectorWorkspaceLinks;
|
|
1073
92
|
const sendHeartbeat = async () => {
|
|
1074
93
|
const res = await fetchImpl(`${serverUrl}/api/machines/heartbeat`, {
|
|
1075
94
|
method: "POST",
|
|
@@ -1087,21 +106,17 @@ export async function runMachineConnectCommand(
|
|
|
1087
106
|
};
|
|
1088
107
|
|
|
1089
108
|
if (hasFlag(args, "--daemon") || hasFlag(args, "--background")) {
|
|
1090
|
-
|
|
1091
|
-
return 1;
|
|
1092
|
-
}
|
|
1093
|
-
const logPath = resolveDaemonLogPath(env);
|
|
1094
|
-
const result = (deps.spawnDaemon ?? defaultSpawnDaemon)({
|
|
1095
|
-
cmd: buildDaemonCommand(deps.cliEntrypointPath),
|
|
1096
|
-
cwd: process.cwd(),
|
|
109
|
+
return runMachineDaemonCommand({
|
|
1097
110
|
env,
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
111
|
+
output,
|
|
112
|
+
cliEntrypointPath: deps.cliEntrypointPath,
|
|
113
|
+
validateWorkspaceLinks: deps.validateWorkspaceLinks,
|
|
114
|
+
spawnDaemon: deps.spawnDaemon,
|
|
115
|
+
});
|
|
1102
116
|
}
|
|
1103
117
|
|
|
1104
118
|
if (hasFlag(args, "--ws")) {
|
|
119
|
+
const validateWorkspaceLinks = deps.validateWorkspaceLinks ?? (() => []);
|
|
1105
120
|
if (!(await checkConnectorWorkspaceLinks(process.cwd(), output, validateWorkspaceLinks))) {
|
|
1106
121
|
return 1;
|
|
1107
122
|
}
|
|
@@ -1109,17 +124,42 @@ export async function runMachineConnectCommand(
|
|
|
1109
124
|
const sleep = deps.sleep ?? defaultSleep;
|
|
1110
125
|
const reconnectDelayMs = resolveConnectorReconnectDelayMs(env);
|
|
1111
126
|
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
1112
|
-
const
|
|
127
|
+
const runtimeServerUrl =
|
|
128
|
+
env.NOLO_CONNECT_RUNTIME_SERVER_URL ||
|
|
129
|
+
env.NOLO_RUNTIME_SERVER_URL ||
|
|
130
|
+
serverUrl;
|
|
131
|
+
const exitCode = await runMachineWsSession({
|
|
1113
132
|
env,
|
|
1114
133
|
output,
|
|
1115
134
|
machine,
|
|
1116
135
|
sendHeartbeat,
|
|
1117
136
|
runHeartbeatLoop: deps.runHeartbeatLoop ?? defaultRunHeartbeatLoop,
|
|
1118
137
|
connectWebSocket: deps.connectWebSocket ?? defaultConnectWebSocket,
|
|
1119
|
-
executeCli: deps.executeCli ?? defaultExecuteCli,
|
|
1120
|
-
fetchImpl,
|
|
1121
138
|
serverUrl,
|
|
1122
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
|
+
),
|
|
1123
163
|
});
|
|
1124
164
|
if (attempt >= maxAttempts) return exitCode;
|
|
1125
165
|
output.write(`[nolo] Connector websocket disconnected. Reconnecting in ${reconnectDelayMs}ms.\n`);
|
|
@@ -1128,78 +168,20 @@ export async function runMachineConnectCommand(
|
|
|
1128
168
|
return 0;
|
|
1129
169
|
}
|
|
1130
170
|
|
|
1131
|
-
if (hasFlag(args, "--watch")) {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
output.write(
|
|
1141
|
-
`[nolo] Machine heartbeat loop failed: ${
|
|
1142
|
-
error instanceof Error ? error.message : String(error)
|
|
1143
|
-
}\n`
|
|
1144
|
-
);
|
|
1145
|
-
return 1;
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
try {
|
|
1150
|
-
await sendHeartbeat();
|
|
1151
|
-
} catch (error) {
|
|
1152
|
-
output.write(
|
|
1153
|
-
`[nolo] Machine connect failed: ${
|
|
1154
|
-
error instanceof Error ? error.message : String(error)
|
|
1155
|
-
}\n`
|
|
1156
|
-
);
|
|
1157
|
-
return 1;
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
output.write(`Connected machine: ${machine.name} (${machine.platform}/${machine.arch})\n`);
|
|
1161
|
-
return 0;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
export async function runMachineStatusCommand(
|
|
1165
|
-
_args: string[],
|
|
1166
|
-
deps: MachineCommandDeps = {}
|
|
1167
|
-
) {
|
|
1168
|
-
const env = deps.env ?? process.env;
|
|
1169
|
-
const output = deps.output ?? process.stdout;
|
|
1170
|
-
const authToken = resolveAuthToken(env);
|
|
1171
|
-
if (!authToken) {
|
|
1172
|
-
writeAuthMissing(output);
|
|
1173
|
-
return 1;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
const serverUrl = resolveServerUrl(env);
|
|
1177
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
1178
|
-
let res: Response;
|
|
1179
|
-
try {
|
|
1180
|
-
res = await fetchImpl(`${serverUrl}/api/machines`, {
|
|
1181
|
-
method: "GET",
|
|
1182
|
-
headers: {
|
|
1183
|
-
Authorization: `Bearer ${authToken}`,
|
|
1184
|
-
},
|
|
1185
|
-
});
|
|
1186
|
-
} catch (error) {
|
|
1187
|
-
output.write(
|
|
1188
|
-
`[nolo] Machine status failed: ${
|
|
1189
|
-
error instanceof Error ? error.message : String(error)
|
|
1190
|
-
}\n`
|
|
1191
|
-
);
|
|
1192
|
-
return 1;
|
|
1193
|
-
}
|
|
171
|
+
if (hasFlag(args, "--watch")) {
|
|
172
|
+
return runMachineWatchCommand({
|
|
173
|
+
env,
|
|
174
|
+
output,
|
|
175
|
+
machine,
|
|
176
|
+
sendHeartbeat,
|
|
177
|
+
runHeartbeatLoop: deps.runHeartbeatLoop ?? defaultRunHeartbeatLoop,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
1194
180
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
}
|
|
181
|
+
return runMachineHeartbeatConnectCommand({
|
|
182
|
+
output,
|
|
183
|
+
machine,
|
|
184
|
+
sendHeartbeat,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
1200
187
|
|
|
1201
|
-
const data = await res.json().catch(() => ({ machines: [] }));
|
|
1202
|
-
const machines = Array.isArray(data?.machines) ? data.machines : [];
|
|
1203
|
-
output.write(formatMachineStatus(machines));
|
|
1204
|
-
return 0;
|
|
1205
|
-
}
|