nolo-cli 0.1.40 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -12
- package/agent-runtime/agentThread.ts +222 -0
- package/agent-runtime/agentThreadAdmission.ts +74 -0
- package/agent-runtime/dialogWritePlan.ts +42 -0
- package/agent-runtime/hostAdapter.ts +1 -0
- package/agent-runtime/hybridRecordStore.ts +5 -3
- package/agent-runtime/index.ts +43 -0
- package/agent-runtime/localLoop.ts +31 -2
- package/agent-runtime/localToolPolicy.ts +1 -0
- package/agent-runtime/localWorkspaceTools.ts +1258 -78
- package/agent-runtime/noloWorkspaceTools.ts +20 -1
- package/agent-runtime/runtimeToolPolicy.ts +1 -5
- package/agent-runtime/runtimeToolSurface.ts +1 -0
- package/agentAliases.ts +29 -9
- package/agentInternalCommandEntries.ts +11 -3
- package/agentMachineCommands.ts +1 -0
- package/agentRecordCommands.ts +2 -2
- package/agentRecordHelpers.ts +59 -6
- package/agentRunCommand.ts +84 -19
- package/ai/agent/_executeModel.ts +146 -0
- package/ai/agent/agentSlice.ts +556 -1
- package/ai/agent/appWorkingMemory.ts +126 -0
- package/ai/agent/buildEditingContext.ts +378 -0
- package/ai/agent/buildSystemPrompt.ts +599 -0
- package/ai/agent/canvasEditingContext.ts +49 -0
- package/ai/agent/cleanAgentMessages.ts +140 -0
- package/ai/agent/cliChatClient.ts +153 -0
- package/ai/agent/cliExecutor.ts +264 -46
- package/ai/agent/contextCompiler.ts +107 -0
- package/ai/agent/contextLayerContract.ts +44 -0
- package/ai/agent/createAgentSchema.ts +272 -0
- package/ai/agent/currentTimeContext.ts +65 -0
- package/ai/agent/executeToolCall.ts +58 -0
- package/ai/agent/fetchAgentContexts.ts +42 -0
- package/ai/agent/generatePrompt.ts +3 -0
- package/ai/agent/getFullChatContextKeys.ts +168 -0
- package/ai/agent/guidedCreation/capabilities.ts +84 -0
- package/ai/agent/guidedCreation/types.ts +38 -0
- package/ai/agent/isLiveAudioOnlyAgent.ts +26 -0
- package/ai/agent/liveAudioModel.ts +2 -0
- package/ai/agent/pageBuilderHandoffRules.ts +75 -0
- package/ai/agent/persistMessageWithFixedId.ts +37 -0
- package/ai/agent/planSlice.ts +259 -0
- package/ai/agent/referenceUtils.ts +229 -0
- package/ai/agent/runAgentBackground.ts +310 -0
- package/ai/agent/runAgentClientLoop.ts +164 -0
- package/ai/agent/runtimeGuidance.ts +116 -0
- package/ai/agent/serverOrigin.ts +7 -0
- package/ai/agent/startParallelAgentStreams.ts +424 -0
- package/ai/agent/startupProtocol.ts +53 -0
- package/ai/agent/streamAgentChatTurn.ts +2135 -0
- package/ai/agent/streamAgentChatTurnUtils.ts +923 -0
- package/ai/agent/toolFailureGuard.ts +99 -0
- package/ai/agent/types.ts +73 -0
- package/ai/agent/utils/imageOutput.ts +37 -0
- package/ai/agent/utils/publicImageAgentMode.ts +26 -0
- package/ai/ai.locale.ts +1165 -0
- package/ai/chat/accumulateToolCallChunks.ts +126 -0
- package/ai/chat/fetchUtils.ts +143 -0
- package/ai/chat/inlineImageUrlsForCustomProvider.ts +122 -0
- package/ai/chat/parseApiError.ts +67 -0
- package/ai/chat/parseMultilineSSE.ts +95 -0
- package/ai/chat/sendOpenAICompletionsRequest.ts +921 -0
- package/ai/chat/sendOpenAIResponseRequest.ts +720 -0
- package/ai/chat/serverProxyRetry.ts +102 -0
- package/ai/chat/shouldUseServerProxy.ts +18 -0
- package/ai/chat/streamRetry.ts +46 -0
- package/ai/chat/updateTotalUsage.ts +89 -0
- package/ai/context/buildReferenceContext.ts +437 -0
- package/ai/context/retention.ts +165 -0
- package/ai/context/tokenUtils.ts +78 -0
- package/ai/llm/agentCapabilities.ts +74 -0
- package/ai/llm/deepinfra.ts +79 -0
- package/ai/llm/fireworks.ts +68 -0
- package/ai/llm/generateRequestBody.ts +165 -0
- package/ai/llm/getModelContextWindow.ts +93 -0
- package/ai/llm/getPricing.ts +252 -0
- package/ai/llm/imagePricing.ts +66 -0
- package/ai/llm/isResponseAPIModel.ts +13 -0
- package/ai/llm/kimi.ts +22 -0
- package/ai/llm/mimo.ts +99 -0
- package/ai/llm/mistral.ts +21 -0
- package/ai/llm/models.ts +45 -0
- package/ai/llm/openrouterModels.ts +31 -0
- package/ai/llm/providers.ts +313 -0
- package/ai/llm/reasoningModels.ts +27 -0
- package/ai/llm/types.ts +82 -0
- package/ai/llm/usageRequestOptions.ts +59 -0
- package/ai/memory/policy.ts +49 -0
- package/ai/memory/queryShared.ts +167 -0
- package/ai/memory/recentRelationshipRecap.ts +251 -0
- package/ai/memory/remember.ts +111 -0
- package/ai/memory/scope.ts +74 -0
- package/ai/memory/store.ts +20 -0
- package/ai/memory/storeShared.ts +76 -0
- package/ai/memory/types.ts +52 -0
- package/ai/memory/understanding.ts +341 -0
- package/ai/memory/understandingGreeting.ts +264 -0
- package/ai/policy/personalizationDialog.ts +333 -0
- package/ai/policy/runtimePolicy.ts +526 -0
- package/ai/policy/selfUpdateFields.ts +48 -0
- package/ai/policy/types.ts +64 -0
- package/ai/skills/referenceRuntime.ts +274 -0
- package/ai/skills/skillDiagnostics.ts +251 -0
- package/ai/skills/skillDocBuilder.ts +139 -0
- package/ai/skills/skillSummaryMarker.ts +26 -0
- package/ai/token/calculatePrice.ts +576 -0
- package/ai/token/missingUsageEstimate.ts +42 -0
- package/ai/token/normalizeUsage.ts +124 -0
- package/ai/token/openaiImageGenerationUsage.ts +56 -0
- package/ai/token/prepareTokenUsageData.ts +93 -0
- package/ai/token/resolveBillingTarget.ts +52 -0
- package/ai/token/saveTokenRecord.ts +53 -0
- package/ai/token/types.ts +103 -0
- package/ai/tools/agent/agentTools.ts +214 -0
- package/ai/tools/agent/agentUpdateShared.ts +311 -0
- package/ai/tools/agent/callAgentTool.ts +139 -0
- package/ai/tools/agent/createAgentTool.ts +512 -0
- package/ai/tools/agent/createDialogTool.ts +69 -0
- package/ai/tools/agent/createSkillAgentTool.ts +62 -0
- package/ai/tools/agent/parallelBudget.ts +221 -0
- package/ai/tools/agent/prepareAgentDraftTool.ts +159 -0
- package/ai/tools/agent/presets/appBuilderPreset.ts +154 -0
- package/ai/tools/agent/runLlmTool.ts +96 -0
- package/ai/tools/agent/runStreamingAgentTool.ts +73 -0
- package/ai/tools/agent/skillAgentArgs.ts +106 -0
- package/ai/tools/agent/startAgentDialogTool.ts +54 -0
- package/ai/tools/agent/streamParallelAgentsTool.ts +123 -0
- package/ai/tools/agent/updateAgentTool.ts +96 -0
- package/ai/tools/agent/updateSelfTool.ts +113 -0
- package/ai/tools/amazonProductScraperTool.ts +86 -0
- package/ai/tools/apifyActorClient.ts +45 -0
- package/ai/tools/appEditGuard.ts +372 -0
- package/ai/tools/appReadSnapshot.ts +153 -0
- package/ai/tools/appTools.ts +1549 -0
- package/ai/tools/applyEditTool.ts +259 -0
- package/ai/tools/applyLineEditsTool.ts +315 -0
- package/ai/tools/browserTools/click.ts +33 -0
- package/ai/tools/browserTools/closeSession.ts +29 -0
- package/ai/tools/browserTools/common.ts +27 -0
- package/ai/tools/browserTools/openSession.ts +48 -0
- package/ai/tools/browserTools/readContent.ts +38 -0
- package/ai/tools/browserTools/selectOption.ts +46 -0
- package/ai/tools/browserTools/typeText.ts +42 -0
- package/ai/tools/category/createCategoryTool.ts +66 -0
- package/ai/tools/category/queryContentsByCategoryTool.ts +69 -0
- package/ai/tools/category/updateContentCategoryTool.ts +75 -0
- package/ai/tools/cfBrowserTools.ts +319 -0
- package/ai/tools/cfSpeechToTextTool.ts +49 -0
- package/ai/tools/checkEnvTool.ts +102 -0
- package/ai/tools/cloudflareCrawlTool.ts +289 -0
- package/ai/tools/codeSearchTool.ts +123 -0
- package/ai/tools/codeTools.ts +101 -0
- package/ai/tools/convertMarxistsBookTool.ts +103 -0
- package/ai/tools/createDocTool.ts +132 -0
- package/ai/tools/createSkillDocTool.ts +155 -0
- package/ai/tools/createWorkflowTool.ts +154 -0
- package/ai/tools/delayTool.ts +31 -0
- package/ai/tools/deleteSpacesTool.ts +325 -0
- package/ai/tools/deleteSpacesToolModel.ts +159 -0
- package/ai/tools/devReloadUtils.ts +29 -0
- package/ai/tools/dialogMessageSearch.ts +137 -0
- package/ai/tools/doctorSkillTool.ts +72 -0
- package/ai/tools/ecommerceScraperTool.ts +86 -0
- package/ai/tools/emailTools.ts +549 -0
- package/ai/tools/evalSkillTool.ts +92 -0
- package/ai/tools/exaSearchTool.ts +63 -0
- package/ai/tools/execShellTool.ts +266 -0
- package/ai/tools/executeSqlTool.ts +192 -0
- package/ai/tools/fetchWebpageSupport.ts +333 -0
- package/ai/tools/fetchWebpageTool.ts +97 -0
- package/ai/tools/geminiImagePreviewTool.ts +386 -0
- package/ai/tools/generateDocxTool.ts +215 -0
- package/ai/tools/googleSearchScraperTool.ts +106 -0
- package/ai/tools/importDataTool.ts +133 -0
- package/ai/tools/importSkillTool.ts +162 -0
- package/ai/tools/index.ts +2290 -0
- package/ai/tools/jdProductScraperTool.ts +821 -0
- package/ai/tools/listUserSpacesTool.ts +113 -0
- package/ai/tools/localFilesTool.ts +276 -0
- package/ai/tools/marxistsOfflineBook.ts +253 -0
- package/ai/tools/modelUsageTools.ts +206 -0
- package/ai/tools/noloWorkspaceReadTools.ts +467 -0
- package/ai/tools/olmOcrTool.ts +33 -0
- package/ai/tools/openaiImageTool.ts +267 -0
- package/ai/tools/prepareTools.ts +193 -0
- package/ai/tools/readDocTool.ts +88 -0
- package/ai/tools/readFileTool.ts +214 -0
- package/ai/tools/readTool.ts +194 -0
- package/ai/tools/readXPostTool.ts +229 -0
- package/ai/tools/readXhsProfileTool.ts +638 -0
- package/ai/tools/rememberMemoryTool.ts +84 -0
- package/ai/tools/remotionVideoTool.ts +151 -0
- package/ai/tools/searchDialogMessagesTool.ts +222 -0
- package/ai/tools/searchWorkspaceTool.ts +259 -0
- package/ai/tools/skillFollowup.ts +86 -0
- package/ai/tools/surfWeatherTool.ts +169 -0
- package/ai/tools/table/addTableRowTool.ts +217 -0
- package/ai/tools/table/createTableTool.ts +326 -0
- package/ai/tools/table/rowTools.ts +386 -0
- package/ai/tools/table/schemaTools.ts +244 -0
- package/ai/tools/table/shareTableTool.ts +148 -0
- package/ai/tools/table/toolShared.ts +129 -0
- package/ai/tools/taobaoTmallProductScraperTool.ts +49 -0
- package/ai/tools/toolApiClient.ts +279 -0
- package/ai/tools/toolPacks.ts +19 -0
- package/ai/tools/toolResultError.ts +42 -0
- package/ai/tools/toolRunSlice.ts +303 -0
- package/ai/tools/toolSchemaCompatibility.ts +53 -0
- package/ai/tools/uiAskChoiceTool.ts +104 -0
- package/ai/tools/updateContentTitleTool.ts +84 -0
- package/ai/tools/updateDocTool.ts +105 -0
- package/ai/tools/updateUserPreferenceProfileTool.ts +153 -0
- package/ai/tools/wereadGatewayTool.ts +152 -0
- package/ai/tools/whisperTool.ts +76 -0
- package/ai/tools/writeFileTool.ts +213 -0
- package/ai/tools/youtubeScraperTool.ts +116 -0
- package/ai/tools/ziweiChartTool.ts +678 -0
- package/ai/types.ts +58 -0
- package/ai/workflow/workflowExecutor.ts +323 -0
- package/ai/workflow/workflowSlice.ts +73 -0
- package/ai/workflow/workflowTypes.ts +106 -0
- package/app/actions/syncAppRecord.ts +73 -0
- package/app/constants/animationSets.ts +21 -0
- package/app/constants/appEditor.ts +99 -0
- package/app/favorite/deletedFavoriteProjection.ts +31 -0
- package/app/favorite/favoriteSlice.ts +690 -0
- package/app/favorite/type.ts +43 -0
- package/app/hooks/deleteDbKey.ts +254 -0
- package/app/i18n/client.ts +13 -0
- package/app/i18n/i18n.base.ts +14 -0
- package/app/i18n/i18n.config.ts +77 -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 +2206 -0
- package/app/i18n/translations/pricing.locale.ts +397 -0
- package/app/i18n/translations/privacy.locale.ts +168 -0
- package/app/i18n/translations/seo.locale.ts +129 -0
- package/app/i18n/translations/terms.locale.ts +124 -0
- package/app/i18n/types.ts +6 -0
- package/app/notifications/model.ts +77 -0
- package/app/notifications/notificationSlice.ts +141 -0
- package/app/reducer.ts +36 -0
- package/app/settings/dbActionThunks.ts +34 -0
- package/app/settings/defaultSpacePreference.ts +87 -0
- package/app/settings/settingSlice.tsx +1212 -0
- package/app/settings/settingsRecord.ts +8 -0
- package/app/stateViews/runtime.ts +90 -0
- package/app/store.ts +55 -0
- package/app/theme/colors.ts +280 -0
- package/app/theme/fontPreference.ts +77 -0
- package/app/theme/theme.config.ts +120 -0
- package/app/theme/themeModeBootstrap.ts +123 -0
- package/app/types/appSummary.ts +118 -0
- package/app/types.ts +358 -0
- package/app/utils/appKeys.ts +55 -0
- package/app/utils/async.ts +28 -0
- package/app/utils/desktopAgentRuntimeTurnClient.ts +75 -0
- package/app/utils/env.ts +17 -0
- package/app/utils/fileUtils.ts +229 -0
- package/app/utils/imageUtils.ts +274 -0
- package/app/utils/myContentItems.ts +289 -0
- package/app/utils/retryAfter.ts +36 -0
- package/app/utils/retryFetch.ts +61 -0
- package/app/utils/toast.ts +3 -0
- package/auth/action/signUpAction.ts +227 -0
- package/auth/adminPermissions.ts +78 -0
- package/auth/authSlice.ts +531 -0
- package/auth/client/loginRequest.ts +14 -0
- package/auth/resetAuthScopedClientState.ts +27 -0
- package/auth/routes.ts +183 -0
- package/auth/token.ts +63 -0
- package/auth/types.ts +40 -0
- package/chat/chat.locale.ts +817 -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/createDialogAction.ts +379 -0
- package/chat/dialog/actions/createScheduledTaskAction.ts +78 -0
- package/chat/dialog/actions/handleSendMessageAction.ts +202 -0
- package/chat/dialog/actions/handleSendMessageResolver.ts +27 -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 +430 -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 +72 -0
- package/chat/dialog/dialogAttachmentCleanup.ts +135 -0
- package/chat/dialog/dialogSlice.ts +985 -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/goal.ts +108 -0
- package/chat/dialog/objectAssistantRegistry.ts +286 -0
- package/chat/dialog/schedule.ts +17 -0
- package/chat/messages/activityCompletion.ts +97 -0
- package/chat/messages/fetchAndCacheMessages.ts +119 -0
- package/chat/messages/fetchConvMsgs.ts +51 -0
- package/chat/messages/fileUrl.ts +13 -0
- package/chat/messages/imagePayloadPersistence.ts +22 -0
- package/chat/messages/messageAgent.ts +8 -0
- package/chat/messages/messageContent.ts +203 -0
- package/chat/messages/messageContract.ts +88 -0
- package/chat/messages/messageSlice.ts +1386 -0
- package/chat/messages/toolThunks.ts +646 -0
- package/chat/messages/types.ts +8 -1
- package/chat/messages/web/toolDisplayName.ts +686 -0
- package/cli/agentAliases.ts +29 -9
- package/cli/agentInternalCommandEntries.ts +11 -3
- package/cli/agentMachineCommands.ts +1 -0
- package/cli/agentRecordCommands.ts +2 -2
- package/cli/agentRecordHelpers.ts +59 -6
- package/cli/agentRunCommand.ts +84 -19
- package/cli/client/agentRun.ts +92 -261
- package/cli/client/localRuntimeAdapter.ts +292 -50
- package/cli/commandRegistry.ts +7 -4
- package/cli/dialogAttachmentCleanup.ts +151 -0
- package/cli/dialogCommands.ts +163 -61
- package/cli/dialogInternalCommandEntries.ts +1 -1
- package/cli/docCreateCommands.ts +345 -0
- package/cli/docInternalCommandEntries.ts +11 -0
- package/cli/docPageHelpers.ts +80 -0
- package/cli/docSkillHelpers.ts +67 -0
- package/cli/docSpaceHelpers.ts +46 -0
- package/cli/internalCommandEntries.ts +4 -0
- package/cli/machineCommands.ts +18 -34
- package/cli/memoryCommands.ts +253 -0
- package/cli/memoryInternalCommandEntries.ts +9 -0
- package/cli/qoderUsageProbe.ts +252 -0
- package/cli/scriptCommandEntries.ts +0 -3
- package/cli/secretScan.ts +31 -0
- package/cli/tableCommands.ts +248 -13
- package/cli/workflowInternalCommandEntries.ts +2 -3
- package/client/agentRun.test.ts +119 -83
- package/client/agentRun.ts +92 -261
- package/client/localRuntimeAdapter.test.ts +894 -32
- package/client/localRuntimeAdapter.ts +292 -50
- package/commandRegistry.ts +7 -4
- package/connector-experimental/capabilities.ts +10 -9
- package/core/builtinAgents.ts +209 -0
- package/core/config.ts +15 -0
- package/core/crypto.ts +51 -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/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/utils/slateUtils.ts +233 -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 +151 -0
- package/create/space/content/uploadAndAddFileToSpaceAction.ts +98 -0
- package/create/space/contentKeyUtils.ts +117 -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/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/resolvePreferredSpaceId.ts +113 -0
- package/create/space/sidebarVisibleTypes.ts +260 -0
- package/create/space/space.locale.ts +1087 -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/types.ts +21 -0
- package/database/actions/agentReadResolution.ts +33 -0
- package/database/actions/common.ts +243 -0
- package/database/actions/deleteFile.ts +40 -0
- package/database/actions/fileContent.ts +125 -0
- package/database/actions/patch.ts +155 -0
- package/database/actions/read.ts +358 -0
- package/database/actions/readAndWait.ts +260 -0
- package/database/actions/readRequestManager.ts +120 -0
- package/database/actions/readResolution.ts +125 -0
- package/database/actions/remove.ts +94 -0
- package/database/actions/replication.ts +477 -0
- package/database/actions/upload.ts +186 -0
- package/database/actions/upsert.ts +56 -0
- package/database/actions/write.ts +146 -0
- package/database/authority/ownerKey.ts +80 -0
- package/database/authority/recordAuthority.ts +67 -0
- package/database/authority/userAuthorityRegistry.ts +54 -0
- package/database/client/fetchUserData.ts +61 -0
- package/database/dbActionThunks.ts +1 -0
- package/database/dbSlice.ts +149 -0
- package/database/fileRing.ts +51 -0
- package/database/fileStorage.ts +232 -0
- package/database/fileUrl.ts +34 -0
- package/database/keys.ts +767 -0
- package/database/queryPrefixes.ts +14 -0
- package/database/requests.ts +443 -0
- package/database/runtimeServerContext.ts +54 -0
- package/database/tenantPlacement.ts +57 -0
- package/database/userPreferenceRegister.ts +131 -0
- package/database/utils/ulid.ts +1 -0
- package/dialogAttachmentCleanup.ts +151 -0
- package/dialogCommands.ts +163 -61
- package/dialogInternalCommandEntries.ts +1 -1
- package/docCreateCommands.ts +345 -0
- package/docInternalCommandEntries.ts +11 -0
- package/docPageHelpers.ts +80 -0
- package/docSkillHelpers.ts +67 -0
- package/docSpaceHelpers.ts +46 -0
- package/integrations/anthropic/anthropicModels.ts +47 -0
- package/integrations/deepseek/models.ts +37 -0
- package/integrations/google/models.ts +341 -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 +271 -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/x-reader/types.ts +109 -0
- package/integrations/xai/models.ts +13 -0
- package/integrations/xhs-reader/redaction.ts +68 -0
- package/integrations/xhs-reader/types.ts +277 -0
- package/integrations/xhs-reader/url.ts +80 -0
- package/internalCommandEntries.ts +4 -0
- package/machineCommands.ts +18 -34
- package/memoryCommands.ts +253 -0
- package/memoryInternalCommandEntries.ts +9 -0
- package/package.json +454 -9
- package/qoderUsageProbe.ts +252 -0
- package/render/contentIcon/types.ts +167 -0
- package/render/page/createPageAction.ts +183 -0
- package/render/page/docSlice.ts +495 -0
- package/render/page/types.ts +19 -0
- package/render/table/createTableAction.ts +274 -0
- package/render/table/deleteTableAction.ts +193 -0
- package/render/table/fetchAndCacheTableRows.ts +174 -0
- package/render/table/tableSlice.ts +1167 -0
- package/render/table/toolValueUtils.ts +363 -0
- package/render/table/types.ts +262 -0
- package/render/table/utils/tableSerialization.ts +50 -0
- package/scriptCommandEntries.ts +0 -3
- package/secretScan.ts +31 -0
- package/server/handlers/agentRun/types.ts +105 -0
- package/share/action.ts +225 -0
- package/share/helpers.ts +302 -0
- package/share/keys.ts +243 -0
- package/share/publicSharePolicy.ts +27 -0
- package/share/shareSlice.ts +53 -0
- package/share/types.ts +100 -0
- package/tableCommands.ts +248 -13
- package/workflowInternalCommandEntries.ts +2 -3
- package/ai/tools/agent/taskRunTool.ts +0 -112
- package/cli/client/taskRunPrompt.ts +0 -27
- package/cli/taskRunCommand.ts +0 -265
- package/client/taskRunPrompt.ts +0 -27
- package/taskRunCommand.ts +0 -265
package/cli/client/agentRun.ts
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { runLocalAgentTurn } from "../agentRuntimeLocal";
|
|
3
2
|
import { LOCAL_AGENT_CONFIG_MISSING_CODE } from "../../agent-runtime/localLoop";
|
|
4
3
|
import {
|
|
5
4
|
MIMO_MONTH_AGENT_KEY,
|
|
6
5
|
NOLO_PROJECT_MANAGER_AGENT_KEY,
|
|
7
|
-
NOLO_SENIOR_FULLSTACK_AGENT_KEY,
|
|
8
6
|
WIN_CODEX_AGENT_KEY,
|
|
9
7
|
} from "../agentAliases";
|
|
10
8
|
import type { LocalAgentToolEvent } from "../../agent-runtime/localLoop";
|
|
11
9
|
import type { AgentRuntimeHostAdapter, AgentRuntimeRequestedMode } from "../agentRuntimeLocal";
|
|
12
10
|
import { createCliLocalRuntimeAdapter, isBuiltinNoloAgentRef } from "./localRuntimeAdapter";
|
|
13
11
|
import { createStreamingTextWriter } from "./streamingOutput";
|
|
14
|
-
import { prependTaskRunPrompt, type TaskRunPromptContext } from "./taskRunPrompt";
|
|
15
12
|
|
|
16
13
|
type EnvLike = Record<string, string | undefined>;
|
|
17
14
|
|
|
18
15
|
type OutputLike = {
|
|
19
16
|
write(chunk: string): unknown;
|
|
20
17
|
};
|
|
18
|
+
type AgentRunSubjectRef = {
|
|
19
|
+
kind: string;
|
|
20
|
+
id: string;
|
|
21
|
+
role?: string;
|
|
22
|
+
};
|
|
21
23
|
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
callCount: number;
|
|
28
|
-
resultCount: number;
|
|
29
|
-
errorCount: number;
|
|
30
|
-
rounds: number;
|
|
31
|
-
};
|
|
24
|
+
type TaskContextReviewStatus = "passed" | "needs_changes" | "blocked";
|
|
25
|
+
|
|
26
|
+
export type TaskRowContext = {
|
|
27
|
+
rowDbKey: string;
|
|
28
|
+
artifactIds?: string[];
|
|
32
29
|
};
|
|
33
30
|
|
|
34
31
|
type RunAgentTurnOptions = {
|
|
@@ -42,6 +39,8 @@ type RunAgentTurnOptions = {
|
|
|
42
39
|
category?: string;
|
|
43
40
|
inheritedFromDialogKey?: string;
|
|
44
41
|
parentDialogId?: string;
|
|
42
|
+
subjectDialogKey?: string;
|
|
43
|
+
subjectRefs?: AgentRunSubjectRef[];
|
|
45
44
|
background?: boolean;
|
|
46
45
|
noStream?: boolean;
|
|
47
46
|
scriptDir: string;
|
|
@@ -54,15 +53,7 @@ type RunAgentTurnOptions = {
|
|
|
54
53
|
timeoutMs?: number;
|
|
55
54
|
traceTools?: boolean;
|
|
56
55
|
eventsMode?: "jsonl";
|
|
57
|
-
|
|
58
|
-
taskRunRecorder?: (args: {
|
|
59
|
-
options: RunAgentTurnOptions;
|
|
60
|
-
status: "running" | "completed" | "failed";
|
|
61
|
-
dialogId?: string;
|
|
62
|
-
resultSummary?: string;
|
|
63
|
-
errorCode?: string;
|
|
64
|
-
toolEvidence?: TaskRunToolEvidence;
|
|
65
|
-
}) => Promise<void>;
|
|
56
|
+
taskRowContext?: TaskRowContext;
|
|
66
57
|
fetchImpl?: typeof fetch;
|
|
67
58
|
};
|
|
68
59
|
|
|
@@ -120,7 +111,6 @@ const SERVER_PLATFORM_TOOL_NAMES = new Set([
|
|
|
120
111
|
"deleteTableRows",
|
|
121
112
|
"queryTableRows",
|
|
122
113
|
"streamParallelAgents",
|
|
123
|
-
"taskRun",
|
|
124
114
|
"updateTableRow",
|
|
125
115
|
"updateTableRows",
|
|
126
116
|
]);
|
|
@@ -129,7 +119,6 @@ const KNOWN_SERVER_PLATFORM_AGENT_KEYS = new Set([
|
|
|
129
119
|
MIMO_MONTH_AGENT_KEY,
|
|
130
120
|
NOLO_PROJECT_MANAGER_AGENT_KEY,
|
|
131
121
|
WIN_CODEX_AGENT_KEY,
|
|
132
|
-
NOLO_SENIOR_FULLSTACK_AGENT_KEY,
|
|
133
122
|
]);
|
|
134
123
|
|
|
135
124
|
const KNOWN_SERVER_PLATFORM_AGENT_ALIASES = new Set([
|
|
@@ -197,6 +186,16 @@ function isMachineBoundLocalhostCustomProvider(agentConfig: any) {
|
|
|
197
186
|
}
|
|
198
187
|
}
|
|
199
188
|
|
|
189
|
+
function isCliProviderAgentConfig(agentConfig: any) {
|
|
190
|
+
const cliProvider = typeof agentConfig?.cliProvider === "string"
|
|
191
|
+
? agentConfig.cliProvider.trim()
|
|
192
|
+
: "";
|
|
193
|
+
const provider = typeof agentConfig?.provider === "string"
|
|
194
|
+
? agentConfig.provider.trim()
|
|
195
|
+
: "";
|
|
196
|
+
return Boolean(cliProvider) || provider === "agy" || provider === "codex" || provider === "claude";
|
|
197
|
+
}
|
|
198
|
+
|
|
200
199
|
function resolveAuthToken(env: EnvLike) {
|
|
201
200
|
return env.AUTH_TOKEN || env.AUTH || env.BENCHMARK_AUTH_TOKEN || "";
|
|
202
201
|
}
|
|
@@ -234,21 +233,30 @@ async function shouldSkipAutoLocalForServerPlatformTools(options: RunAgentTurnOp
|
|
|
234
233
|
if (options.localRuntimeCwd) {
|
|
235
234
|
return false;
|
|
236
235
|
}
|
|
237
|
-
|
|
238
|
-
options.output.write(
|
|
239
|
-
`[nolo] auto runtime: skipping local runtime because ${options.agentKey} is a known platform agent. ` +
|
|
240
|
-
"Use --local explicitly to force local workspace tools.\n"
|
|
241
|
-
);
|
|
242
|
-
return true;
|
|
243
|
-
}
|
|
236
|
+
const knownServerPlatformAgent = isKnownServerPlatformAgent(options);
|
|
244
237
|
const adapter = resolveLocalRuntimeAdapter(options);
|
|
245
|
-
if (!adapter) return
|
|
238
|
+
if (!adapter) return knownServerPlatformAgent;
|
|
246
239
|
let agentConfig;
|
|
247
240
|
try {
|
|
248
241
|
agentConfig = await adapter.loadAgentConfig(options.agentKey);
|
|
249
242
|
} catch {
|
|
243
|
+
if (knownServerPlatformAgent) {
|
|
244
|
+
options.output.write(
|
|
245
|
+
`[nolo] auto runtime: skipping local runtime because ${options.agentKey} is a known platform agent. ` +
|
|
246
|
+
"Use --local explicitly to force local workspace tools.\n"
|
|
247
|
+
);
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
250
|
return false;
|
|
251
251
|
}
|
|
252
|
+
if (isCliProviderAgentConfig(agentConfig)) return false;
|
|
253
|
+
if (knownServerPlatformAgent) {
|
|
254
|
+
options.output.write(
|
|
255
|
+
`[nolo] auto runtime: skipping local runtime because ${options.agentKey} is a known platform agent. ` +
|
|
256
|
+
"Use --local explicitly to force local workspace tools.\n"
|
|
257
|
+
);
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
252
260
|
if (isMachineBoundLocalhostCustomProvider(agentConfig)) {
|
|
253
261
|
options.output.write(
|
|
254
262
|
`[nolo] auto runtime: skipping local runtime because ${options.agentKey} is a machine-bound localhost custom provider. ` +
|
|
@@ -276,6 +284,37 @@ function buildUserInputContent(message: string, imageUrls: string[] = []) {
|
|
|
276
284
|
];
|
|
277
285
|
}
|
|
278
286
|
|
|
287
|
+
function buildSubjectRefs(options: RunAgentTurnOptions) {
|
|
288
|
+
const refs: AgentRunSubjectRef[] = [];
|
|
289
|
+
const seen = new Set<string>();
|
|
290
|
+
const pushRef = (ref: AgentRunSubjectRef) => {
|
|
291
|
+
const kind = ref.kind.trim();
|
|
292
|
+
const id = ref.id.trim();
|
|
293
|
+
const role = ref.role?.trim();
|
|
294
|
+
if (!kind || !id) return;
|
|
295
|
+
const key = `${kind}\u0000${id}\u0000${role ?? ""}`;
|
|
296
|
+
if (seen.has(key)) return;
|
|
297
|
+
seen.add(key);
|
|
298
|
+
refs.push({ kind, id, ...(role ? { role } : {}) });
|
|
299
|
+
};
|
|
300
|
+
for (const ref of options.subjectRefs ?? []) pushRef(ref);
|
|
301
|
+
if (options.subjectDialogKey) {
|
|
302
|
+
pushRef({
|
|
303
|
+
kind: "dialog",
|
|
304
|
+
id: options.subjectDialogKey,
|
|
305
|
+
role: "subject",
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (options.taskRowContext?.rowDbKey) {
|
|
309
|
+
pushRef({
|
|
310
|
+
kind: "table-row",
|
|
311
|
+
id: options.taskRowContext.rowDbKey,
|
|
312
|
+
role: "task",
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
return refs.length ? refs : undefined;
|
|
316
|
+
}
|
|
317
|
+
|
|
279
318
|
function shouldTraceLocalTools(options: RunAgentTurnOptions) {
|
|
280
319
|
const setting = (options.env.NOLO_TRACE_TOOLS ?? "").trim().toLowerCase();
|
|
281
320
|
if (setting === "0" || setting === "false" || setting === "off") return false;
|
|
@@ -287,32 +326,6 @@ function resolveAgentEventMode(options: RunAgentTurnOptions): "text" | "jsonl" {
|
|
|
287
326
|
return options.env.NOLO_AGENT_EVENTS === "jsonl" ? "jsonl" : "text";
|
|
288
327
|
}
|
|
289
328
|
|
|
290
|
-
function shouldCollectLocalToolEvidence(options: RunAgentTurnOptions) {
|
|
291
|
-
return Boolean(options.taskRunContext?.rowDbKey);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function summarizeLocalToolEvidence(events: LocalAgentToolEvent[]): TaskRunToolEvidence | undefined {
|
|
295
|
-
if (events.length === 0) return undefined;
|
|
296
|
-
const toolsUsed = [
|
|
297
|
-
...new Set(
|
|
298
|
-
events
|
|
299
|
-
.filter((event) => event.type === "tool-call")
|
|
300
|
-
.map((event) => event.toolName)
|
|
301
|
-
.filter(Boolean)
|
|
302
|
-
),
|
|
303
|
-
];
|
|
304
|
-
const rounds = new Set(events.map((event) => event.round)).size;
|
|
305
|
-
return {
|
|
306
|
-
toolsUsed,
|
|
307
|
-
summary: {
|
|
308
|
-
callCount: events.filter((event) => event.type === "tool-call").length,
|
|
309
|
-
resultCount: events.filter((event) => event.type === "tool-result").length,
|
|
310
|
-
errorCount: events.filter((event) => event.type === "tool-error").length,
|
|
311
|
-
rounds,
|
|
312
|
-
},
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
329
|
function isMissingLocalAgentConfigError(error: unknown, agentRef: string) {
|
|
317
330
|
return Boolean(
|
|
318
331
|
error &&
|
|
@@ -349,6 +362,7 @@ function formatToolJsonEvent(event: LocalAgentToolEvent) {
|
|
|
349
362
|
...(typeof event.elapsedMs === "number" ? { elapsedMs: event.elapsedMs } : {}),
|
|
350
363
|
...(event.summary ? { summary: event.summary } : {}),
|
|
351
364
|
...(event.message ? { message: event.message } : {}),
|
|
365
|
+
...(event.metadata ? { metadata: event.metadata } : {}),
|
|
352
366
|
})}\n`;
|
|
353
367
|
}
|
|
354
368
|
|
|
@@ -370,21 +384,12 @@ function shouldAttemptAutoLocal(options: RunAgentTurnOptions) {
|
|
|
370
384
|
);
|
|
371
385
|
}
|
|
372
386
|
|
|
373
|
-
function
|
|
374
|
-
const normalized = agentRef.toLowerCase();
|
|
375
|
-
if (normalized.includes("project-manager") || normalized.includes("manager")) return "pm";
|
|
376
|
-
if (normalized.includes("frontend")) return "frontend";
|
|
377
|
-
if (normalized.includes("fullstack")) return "fullstack";
|
|
378
|
-
if (normalized.includes("review")) return "reviewer";
|
|
379
|
-
return "codex";
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export function classifyTaskRunReviewStatus(summary?: string): TaskRunReviewStatus | undefined {
|
|
387
|
+
export function classifyTaskContextReviewStatus(summary?: string): TaskContextReviewStatus | undefined {
|
|
383
388
|
const normalized = summary?.toLowerCase().trim();
|
|
384
389
|
if (!normalized) return undefined;
|
|
385
390
|
|
|
386
391
|
const explicit = normalized.match(/review\s+decision\s*:\s*(passed|needs_changes|blocked)/);
|
|
387
|
-
if (explicit?.[1]) return explicit[1] as
|
|
392
|
+
if (explicit?.[1]) return explicit[1] as TaskContextReviewStatus;
|
|
388
393
|
|
|
389
394
|
if (/\b(blocked|cannot review|unable to review)\b|无法审查|阻塞/.test(normalized)) {
|
|
390
395
|
return "blocked";
|
|
@@ -402,141 +407,6 @@ export function classifyTaskRunReviewStatus(summary?: string): TaskRunReviewStat
|
|
|
402
407
|
return undefined;
|
|
403
408
|
}
|
|
404
409
|
|
|
405
|
-
async function runTaskRunCli(args: {
|
|
406
|
-
options: RunAgentTurnOptions;
|
|
407
|
-
cliArgs: string[];
|
|
408
|
-
}) {
|
|
409
|
-
const scriptPath = join(args.options.scriptDir, "taskRun.ts");
|
|
410
|
-
const proc = Bun.spawn({
|
|
411
|
-
cmd: [process.execPath, scriptPath, ...args.cliArgs],
|
|
412
|
-
stdout: "pipe",
|
|
413
|
-
stderr: "pipe",
|
|
414
|
-
env: {
|
|
415
|
-
...process.env,
|
|
416
|
-
...args.options.env,
|
|
417
|
-
BASE_URL: args.options.serverUrl,
|
|
418
|
-
},
|
|
419
|
-
});
|
|
420
|
-
const [stdout, stderr, exitCode] = await Promise.all([
|
|
421
|
-
new Response(proc.stdout).text(),
|
|
422
|
-
new Response(proc.stderr).text(),
|
|
423
|
-
proc.exited,
|
|
424
|
-
]);
|
|
425
|
-
if (exitCode !== 0) {
|
|
426
|
-
throw new Error((stderr || stdout || `taskRun.ts exited ${exitCode}`).trim());
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
async function defaultTaskRunRecorder(args: {
|
|
431
|
-
options: RunAgentTurnOptions;
|
|
432
|
-
status: "running" | "completed" | "failed";
|
|
433
|
-
dialogId?: string;
|
|
434
|
-
resultSummary?: string;
|
|
435
|
-
errorCode?: string;
|
|
436
|
-
toolEvidence?: TaskRunToolEvidence;
|
|
437
|
-
}) {
|
|
438
|
-
const context = args.options.taskRunContext;
|
|
439
|
-
if (!context?.rowDbKey) return;
|
|
440
|
-
const role = inferTaskRunAgentRole(args.options.agentName || args.options.agentKey);
|
|
441
|
-
if (role === "reviewer" && args.status !== "running") {
|
|
442
|
-
await runTaskRunCli({
|
|
443
|
-
options: args.options,
|
|
444
|
-
cliArgs: [
|
|
445
|
-
"request-review",
|
|
446
|
-
"--row-dbkey",
|
|
447
|
-
context.rowDbKey,
|
|
448
|
-
"--base-url",
|
|
449
|
-
args.options.serverUrl,
|
|
450
|
-
"--reviewer-agent-key",
|
|
451
|
-
args.options.agentKey,
|
|
452
|
-
...(context.artifactIds?.length ? ["--artifact-ids", context.artifactIds.join(",")] : []),
|
|
453
|
-
...(args.dialogId ? ["--dialog-id", args.dialogId] : []),
|
|
454
|
-
],
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
await runTaskRunCli({
|
|
458
|
-
options: args.options,
|
|
459
|
-
cliArgs: [
|
|
460
|
-
"record-agent-run",
|
|
461
|
-
"--row-dbkey",
|
|
462
|
-
context.rowDbKey,
|
|
463
|
-
"--base-url",
|
|
464
|
-
args.options.serverUrl,
|
|
465
|
-
"--agent-key",
|
|
466
|
-
args.options.agentKey,
|
|
467
|
-
"--role",
|
|
468
|
-
role,
|
|
469
|
-
"--run-status",
|
|
470
|
-
args.status,
|
|
471
|
-
...(context.workItemId ? ["--work-item-id", context.workItemId] : []),
|
|
472
|
-
...(args.dialogId ? ["--dialog-id", args.dialogId] : []),
|
|
473
|
-
...(args.resultSummary ? ["--result-summary", args.resultSummary.slice(0, 240)] : []),
|
|
474
|
-
...(args.errorCode ? ["--error-code", args.errorCode] : []),
|
|
475
|
-
...(args.toolEvidence?.toolsUsed?.length
|
|
476
|
-
? ["--tools-used", args.toolEvidence.toolsUsed.join(",")]
|
|
477
|
-
: []),
|
|
478
|
-
...(args.toolEvidence?.summary
|
|
479
|
-
? ["--tool-trace-summary", JSON.stringify(args.toolEvidence.summary)]
|
|
480
|
-
: []),
|
|
481
|
-
],
|
|
482
|
-
});
|
|
483
|
-
if (context.workItemId && args.dialogId) {
|
|
484
|
-
await runTaskRunCli({
|
|
485
|
-
options: args.options,
|
|
486
|
-
cliArgs: [
|
|
487
|
-
"update-work-item",
|
|
488
|
-
"--row-dbkey",
|
|
489
|
-
context.rowDbKey,
|
|
490
|
-
"--base-url",
|
|
491
|
-
args.options.serverUrl,
|
|
492
|
-
"--id",
|
|
493
|
-
context.workItemId,
|
|
494
|
-
"--dialog-ids",
|
|
495
|
-
args.dialogId,
|
|
496
|
-
],
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
if (role === "reviewer" && args.status !== "running") {
|
|
500
|
-
const reviewStatus =
|
|
501
|
-
args.status === "failed" ? "blocked" : classifyTaskRunReviewStatus(args.resultSummary);
|
|
502
|
-
if (reviewStatus) {
|
|
503
|
-
await runTaskRunCli({
|
|
504
|
-
options: args.options,
|
|
505
|
-
cliArgs: [
|
|
506
|
-
"review-result",
|
|
507
|
-
"--row-dbkey",
|
|
508
|
-
context.rowDbKey,
|
|
509
|
-
"--base-url",
|
|
510
|
-
args.options.serverUrl,
|
|
511
|
-
"--review-status",
|
|
512
|
-
reviewStatus,
|
|
513
|
-
"--reviewer-agent-key",
|
|
514
|
-
args.options.agentKey,
|
|
515
|
-
...(context.artifactIds?.length ? ["--artifact-ids", context.artifactIds.join(",")] : []),
|
|
516
|
-
...(args.dialogId ? ["--dialog-id", args.dialogId] : []),
|
|
517
|
-
],
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
async function recordTaskRunOutcome(args: {
|
|
524
|
-
options: RunAgentTurnOptions;
|
|
525
|
-
status: "running" | "completed" | "failed";
|
|
526
|
-
dialogId?: string;
|
|
527
|
-
resultSummary?: string;
|
|
528
|
-
errorCode?: string;
|
|
529
|
-
toolEvidence?: TaskRunToolEvidence;
|
|
530
|
-
}) {
|
|
531
|
-
if (!args.options.taskRunContext?.rowDbKey) return;
|
|
532
|
-
try {
|
|
533
|
-
await (args.options.taskRunRecorder ?? defaultTaskRunRecorder)(args);
|
|
534
|
-
} catch (error) {
|
|
535
|
-
args.options.output.write(
|
|
536
|
-
`[nolo] task-run writeback failed: ${error instanceof Error ? error.message : String(error)}\n`
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
410
|
|
|
541
411
|
function formatUsage(usage: any, dialogId: unknown) {
|
|
542
412
|
const parts: string[] = [];
|
|
@@ -576,10 +446,11 @@ function buildTransportErrorHint(serverUrl: string, error: unknown) {
|
|
|
576
446
|
|
|
577
447
|
async function runHttpAgentTurn(options: RunAgentTurnOptions, authToken: string) {
|
|
578
448
|
const spinner = new Spinner(options.output, `${options.agentName} -> working`);
|
|
579
|
-
spinner.start();
|
|
580
|
-
|
|
581
|
-
const fetchImpl = options.fetchImpl ?? fetch;
|
|
582
|
-
|
|
449
|
+
spinner.start();
|
|
450
|
+
|
|
451
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
452
|
+
const subjectRefs = buildSubjectRefs(options);
|
|
453
|
+
let res: Response;
|
|
583
454
|
try {
|
|
584
455
|
res = await fetchImpl(`${options.serverUrl}/api/agent/run`, {
|
|
585
456
|
method: "POST",
|
|
@@ -590,7 +461,7 @@ async function runHttpAgentTurn(options: RunAgentTurnOptions, authToken: string)
|
|
|
590
461
|
body: JSON.stringify({
|
|
591
462
|
agentKey: options.agentKey,
|
|
592
463
|
userInput: buildUserInputContent(
|
|
593
|
-
|
|
464
|
+
options.message,
|
|
594
465
|
options.imageUrls
|
|
595
466
|
),
|
|
596
467
|
runtimeContext: {
|
|
@@ -599,22 +470,7 @@ async function runHttpAgentTurn(options: RunAgentTurnOptions, authToken: string)
|
|
|
599
470
|
runtime: "bun",
|
|
600
471
|
entrypoint: "nolo-cli",
|
|
601
472
|
capabilities: ["text-io", "streaming", "slash-commands"],
|
|
602
|
-
...(
|
|
603
|
-
? {
|
|
604
|
-
taskRun: {
|
|
605
|
-
rowDbKey: options.taskRunContext.rowDbKey,
|
|
606
|
-
...(options.taskRunContext.taskRunId
|
|
607
|
-
? { taskRunId: options.taskRunContext.taskRunId }
|
|
608
|
-
: {}),
|
|
609
|
-
...(options.taskRunContext.workItemId
|
|
610
|
-
? { workItemId: options.taskRunContext.workItemId }
|
|
611
|
-
: {}),
|
|
612
|
-
...(options.taskRunContext.artifactIds?.length
|
|
613
|
-
? { artifactIds: options.taskRunContext.artifactIds }
|
|
614
|
-
: {}),
|
|
615
|
-
},
|
|
616
|
-
}
|
|
617
|
-
: {}),
|
|
473
|
+
...(subjectRefs ? { subjectRefs } : {}),
|
|
618
474
|
},
|
|
619
475
|
...(options.continueDialogId
|
|
620
476
|
? { continueDialogId: options.continueDialogId }
|
|
@@ -640,16 +496,6 @@ async function runHttpAgentTurn(options: RunAgentTurnOptions, authToken: string)
|
|
|
640
496
|
if (contentType.includes("text/event-stream") && res.body) {
|
|
641
497
|
spinner.stop();
|
|
642
498
|
const result = await readStreamingAgentRun(options, res);
|
|
643
|
-
await recordTaskRunOutcome({
|
|
644
|
-
options,
|
|
645
|
-
status: result.streamInterrupted
|
|
646
|
-
? "running"
|
|
647
|
-
: result.exitCode === 0
|
|
648
|
-
? "completed"
|
|
649
|
-
: "failed",
|
|
650
|
-
dialogId: result.dialogId,
|
|
651
|
-
...(result.exitCode !== 0 ? { errorCode: "STREAM_FAILED" } : {}),
|
|
652
|
-
});
|
|
653
499
|
return result;
|
|
654
500
|
}
|
|
655
501
|
|
|
@@ -667,6 +513,7 @@ async function runHttpAgentTurn(options: RunAgentTurnOptions, authToken: string)
|
|
|
667
513
|
const messageText = typeof data?.message === "string" ? data.message.trim() : "";
|
|
668
514
|
const reasonText = typeof data?.reason === "string" ? data.reason.trim() : "";
|
|
669
515
|
const codeText = typeof data?.code === "string" ? data.code.trim() : "";
|
|
516
|
+
const dialogIdText = typeof data?.dialogId === "string" ? data.dialogId.trim() : "";
|
|
670
517
|
if (errorText || messageText) {
|
|
671
518
|
options.output.write(`${errorText || messageText}\n`);
|
|
672
519
|
if (messageText && messageText !== errorText) {
|
|
@@ -679,13 +526,13 @@ async function runHttpAgentTurn(options: RunAgentTurnOptions, authToken: string)
|
|
|
679
526
|
options.output.write(`reason=${reasonText}\n`);
|
|
680
527
|
}
|
|
681
528
|
}
|
|
682
|
-
|
|
683
|
-
options
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
return { exitCode: 1 };
|
|
529
|
+
if (dialogIdText) {
|
|
530
|
+
options.output.write(`[nolo] failed dialog: ${dialogIdText}\n`);
|
|
531
|
+
options.output.write(
|
|
532
|
+
`[nolo] continue with: nolo agent run ${options.agentKey} --continue ${dialogIdText} --msg "retry"\n`
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
return dialogIdText ? { exitCode: 1, dialogId: dialogIdText } : { exitCode: 1 };
|
|
689
536
|
}
|
|
690
537
|
|
|
691
538
|
const content = String(data?.content ?? data?.message ?? "").trim();
|
|
@@ -703,12 +550,6 @@ async function runHttpAgentTurn(options: RunAgentTurnOptions, authToken: string)
|
|
|
703
550
|
? { dialogId: data.dialogId }
|
|
704
551
|
: {}),
|
|
705
552
|
};
|
|
706
|
-
await recordTaskRunOutcome({
|
|
707
|
-
options,
|
|
708
|
-
status: options.background ? "running" : "completed",
|
|
709
|
-
dialogId: result.dialogId,
|
|
710
|
-
...(!options.background && content ? { resultSummary: content } : {}),
|
|
711
|
-
});
|
|
712
553
|
return result;
|
|
713
554
|
}
|
|
714
555
|
|
|
@@ -735,16 +576,14 @@ async function runLocalAgentTurnForCli(
|
|
|
735
576
|
|
|
736
577
|
const spinner = new Spinner(options.output, `${options.agentName} -> working locally`);
|
|
737
578
|
spinner.start();
|
|
738
|
-
const toolEvents: LocalAgentToolEvent[] = [];
|
|
739
579
|
try {
|
|
740
580
|
const traceLocalTools = shouldTraceLocalTools(options);
|
|
741
|
-
const collectToolEvidence = shouldCollectLocalToolEvidence(options);
|
|
742
581
|
const eventMode = resolveAgentEventMode(options);
|
|
743
582
|
const result = await runLocalAgentTurn({
|
|
744
583
|
adapter,
|
|
745
584
|
agentRef: options.agentKey,
|
|
746
585
|
input: buildUserInputContent(
|
|
747
|
-
|
|
586
|
+
options.message,
|
|
748
587
|
options.imageUrls
|
|
749
588
|
),
|
|
750
589
|
continueDialogId: options.continueDialogId,
|
|
@@ -755,10 +594,9 @@ async function runLocalAgentTurnForCli(
|
|
|
755
594
|
background: options.background,
|
|
756
595
|
noStream: options.noStream,
|
|
757
596
|
...(typeof options.timeoutMs === "number" ? { timeoutMs: options.timeoutMs } : {}),
|
|
758
|
-
...(traceLocalTools
|
|
597
|
+
...(traceLocalTools
|
|
759
598
|
? {
|
|
760
599
|
onToolEvent: (event) => {
|
|
761
|
-
if (collectToolEvidence) toolEvents.push(event);
|
|
762
600
|
if (traceLocalTools) {
|
|
763
601
|
spinner.stop();
|
|
764
602
|
options.output.write(
|
|
@@ -778,13 +616,6 @@ async function runLocalAgentTurnForCli(
|
|
|
778
616
|
} else {
|
|
779
617
|
options.output.write(`\n${options.agentName} > (no text response)\n`);
|
|
780
618
|
}
|
|
781
|
-
await recordTaskRunOutcome({
|
|
782
|
-
options,
|
|
783
|
-
status: options.background ? "running" : "completed",
|
|
784
|
-
dialogId: result.dialogId,
|
|
785
|
-
...(!options.background && content ? { resultSummary: content } : {}),
|
|
786
|
-
toolEvidence: summarizeLocalToolEvidence(toolEvents),
|
|
787
|
-
});
|
|
788
619
|
return { exitCode: 0, dialogId: result.dialogId };
|
|
789
620
|
} catch (error) {
|
|
790
621
|
spinner.stop();
|
|
@@ -795,7 +626,7 @@ async function runLocalAgentTurnForCli(
|
|
|
795
626
|
}\n`
|
|
796
627
|
);
|
|
797
628
|
}
|
|
798
|
-
return { exitCode: 1, localError: error
|
|
629
|
+
return { exitCode: 1, localError: error };
|
|
799
630
|
}
|
|
800
631
|
}
|
|
801
632
|
|