nolo-cli 0.1.45 → 0.1.47
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 +272 -118
- package/index.js +73946 -0
- package/package.json +10 -635
- package/LICENSE +0 -21
- package/agent-runtime/agentConfigOptions.ts +0 -12
- package/agent-runtime/agentRecordConfig.ts +0 -101
- package/agent-runtime/agentRecordKeys.ts +0 -14
- package/agent-runtime/agentThread.ts +0 -222
- package/agent-runtime/agentThreadAdmission.ts +0 -74
- package/agent-runtime/dialogMessageRecord.ts +0 -16
- package/agent-runtime/dialogWritePlan.ts +0 -211
- package/agent-runtime/hostAdapter.ts +0 -81
- package/agent-runtime/hybridRecordStore.ts +0 -170
- package/agent-runtime/index.ts +0 -184
- package/agent-runtime/localDialogRead.ts +0 -23
- package/agent-runtime/localLoop.ts +0 -334
- package/agent-runtime/localToolPolicy.ts +0 -179
- package/agent-runtime/localWorkspaceTools.ts +0 -2310
- package/agent-runtime/noloWorkspaceTools.ts +0 -390
- package/agent-runtime/openAiCompatibleProvider.ts +0 -74
- package/agent-runtime/openAiCompatibleProviderConfig.ts +0 -27
- package/agent-runtime/platformChatProvider.ts +0 -229
- package/agent-runtime/providerResolution.ts +0 -302
- package/agent-runtime/runtimeDecision.ts +0 -70
- package/agent-runtime/runtimeFacts.ts +0 -40
- package/agent-runtime/runtimeToolPolicy.ts +0 -191
- package/agent-runtime/runtimeToolSurface.ts +0 -199
- package/agent-runtime/shellCommandPolicy.ts +0 -120
- package/agent-runtime/types.ts +0 -137
- package/agentAliases.ts +0 -40
- package/agentCommandSupport.ts +0 -81
- package/agentInternalCommandEntries.ts +0 -44
- package/agentListCommands.ts +0 -185
- package/agentListHelpers.ts +0 -242
- package/agentMachineCommands.ts +0 -426
- package/agentNameResolver.ts +0 -164
- package/agentPullCommand.ts +0 -142
- package/agentRecordCommands.ts +0 -224
- package/agentRecordHelpers.ts +0 -592
- package/agentRunCommand.ts +0 -568
- package/agentRuntimeCommands.ts +0 -7
- package/agentRuntimeLocal.ts +0 -45
- package/ai/agent/_executeModel.ts +0 -146
- package/ai/agent/agentSlice.ts +0 -557
- package/ai/agent/appWorkingMemory.ts +0 -126
- package/ai/agent/buildEditingContext.ts +0 -378
- package/ai/agent/buildSystemPrompt.ts +0 -599
- package/ai/agent/canvasEditingContext.ts +0 -49
- package/ai/agent/cleanAgentMessages.ts +0 -140
- package/ai/agent/cliChatClient.ts +0 -153
- package/ai/agent/cliExecutor.ts +0 -1465
- package/ai/agent/cliPrompt.ts +0 -10
- package/ai/agent/contextCompiler.ts +0 -107
- package/ai/agent/contextLayerContract.ts +0 -44
- package/ai/agent/createAgentSchema.ts +0 -272
- package/ai/agent/currentTimeContext.ts +0 -65
- package/ai/agent/executeToolCall.ts +0 -58
- package/ai/agent/fetchAgentContexts.ts +0 -42
- package/ai/agent/generatePrompt.ts +0 -3
- package/ai/agent/getFullChatContextKeys.ts +0 -168
- package/ai/agent/guidedCreation/capabilities.ts +0 -84
- package/ai/agent/guidedCreation/types.ts +0 -38
- package/ai/agent/isLiveAudioOnlyAgent.ts +0 -26
- package/ai/agent/liveAudioModel.ts +0 -2
- package/ai/agent/machineRunPermissions.ts +0 -113
- package/ai/agent/pageBuilderHandoffRules.ts +0 -75
- package/ai/agent/persistMessageWithFixedId.ts +0 -37
- package/ai/agent/planSlice.ts +0 -259
- package/ai/agent/referenceUtils.ts +0 -229
- package/ai/agent/runAgentBackground.ts +0 -310
- package/ai/agent/runAgentClientLoop.ts +0 -164
- package/ai/agent/runtimeGuidance.ts +0 -116
- package/ai/agent/serverOrigin.ts +0 -7
- package/ai/agent/startParallelAgentStreams.ts +0 -424
- package/ai/agent/startupProtocol.ts +0 -53
- package/ai/agent/streamAgentChatTurn.ts +0 -2135
- package/ai/agent/streamAgentChatTurnUtils.ts +0 -923
- package/ai/agent/toolFailureGuard.ts +0 -99
- package/ai/agent/types.ts +0 -73
- package/ai/agent/utils/imageOutput.ts +0 -37
- package/ai/agent/utils/publicImageAgentMode.ts +0 -26
- package/ai/agent.ts +0 -2
- package/ai/ai.locale.ts +0 -1165
- package/ai/chat/accumulateToolCallChunks.ts +0 -126
- package/ai/chat/fetchUtils.ts +0 -143
- package/ai/chat/inlineImageUrlsForCustomProvider.ts +0 -122
- package/ai/chat/parseApiError.ts +0 -67
- package/ai/chat/parseMultilineSSE.ts +0 -95
- package/ai/chat/sendOpenAICompletionsRequest.ts +0 -921
- package/ai/chat/sendOpenAIResponseRequest.ts +0 -720
- package/ai/chat/serverProxyRetry.ts +0 -102
- package/ai/chat/shouldUseServerProxy.ts +0 -18
- package/ai/chat/streamRetry.ts +0 -46
- package/ai/chat/updateTotalUsage.ts +0 -89
- package/ai/context/buildReferenceContext.ts +0 -437
- package/ai/context/retention.ts +0 -165
- package/ai/context/tokenUtils.ts +0 -78
- package/ai/index.ts +0 -1
- package/ai/llm/agentCapabilities.ts +0 -74
- package/ai/llm/deepinfra.ts +0 -79
- package/ai/llm/fireworks.ts +0 -68
- package/ai/llm/generateRequestBody.ts +0 -165
- package/ai/llm/getModelContextWindow.ts +0 -93
- package/ai/llm/getPricing.ts +0 -252
- package/ai/llm/imagePricing.ts +0 -66
- package/ai/llm/isResponseAPIModel.ts +0 -13
- package/ai/llm/kimi.ts +0 -22
- package/ai/llm/mimo.ts +0 -99
- package/ai/llm/mistral.ts +0 -21
- package/ai/llm/models.ts +0 -45
- package/ai/llm/openrouterModels.ts +0 -31
- package/ai/llm/providers.ts +0 -313
- package/ai/llm/reasoningModels.ts +0 -27
- package/ai/llm/types.ts +0 -82
- package/ai/llm/usageRequestOptions.ts +0 -59
- package/ai/memory/policy.ts +0 -49
- package/ai/memory/queryShared.ts +0 -167
- package/ai/memory/recentRelationshipRecap.ts +0 -251
- package/ai/memory/remember.ts +0 -111
- package/ai/memory/scope.ts +0 -74
- package/ai/memory/store.ts +0 -20
- package/ai/memory/storeShared.ts +0 -76
- package/ai/memory/types.ts +0 -52
- package/ai/memory/understanding.ts +0 -341
- package/ai/memory/understandingGreeting.ts +0 -264
- package/ai/policy/personalizationDialog.ts +0 -333
- package/ai/policy/runtimePolicy.ts +0 -526
- package/ai/policy/selfUpdateFields.ts +0 -48
- package/ai/policy/types.ts +0 -64
- package/ai/skills/referenceRuntime.ts +0 -274
- package/ai/skills/skillDiagnostics.ts +0 -251
- package/ai/skills/skillDocBuilder.ts +0 -139
- package/ai/skills/skillDocProtocol.ts +0 -526
- package/ai/skills/skillSummaryMarker.ts +0 -26
- package/ai/token/calculatePrice.ts +0 -576
- package/ai/token/missingUsageEstimate.ts +0 -42
- package/ai/token/normalizeUsage.ts +0 -124
- package/ai/token/openaiImageGenerationUsage.ts +0 -56
- package/ai/token/prepareTokenUsageData.ts +0 -93
- package/ai/token/resolveBillingTarget.ts +0 -52
- package/ai/token/saveTokenRecord.ts +0 -53
- package/ai/token/types.ts +0 -103
- package/ai/tools/agent/agentTools.ts +0 -214
- package/ai/tools/agent/agentUpdateShared.ts +0 -311
- package/ai/tools/agent/callAgentTool.ts +0 -139
- package/ai/tools/agent/createAgentTool.ts +0 -512
- package/ai/tools/agent/createDialogTool.ts +0 -69
- package/ai/tools/agent/createSkillAgentTool.ts +0 -62
- package/ai/tools/agent/parallelBudget.ts +0 -221
- package/ai/tools/agent/prepareAgentDraftTool.ts +0 -159
- package/ai/tools/agent/presets/appBuilderPreset.ts +0 -154
- package/ai/tools/agent/runLlmTool.ts +0 -96
- package/ai/tools/agent/runStreamingAgentTool.ts +0 -73
- package/ai/tools/agent/skillAgentArgs.ts +0 -106
- package/ai/tools/agent/startAgentDialogTool.ts +0 -54
- package/ai/tools/agent/streamParallelAgentsTool.ts +0 -123
- package/ai/tools/agent/updateAgentTool.ts +0 -96
- package/ai/tools/agent/updateSelfTool.ts +0 -113
- package/ai/tools/amazonProductScraperTool.ts +0 -86
- package/ai/tools/apifyActorClient.ts +0 -45
- package/ai/tools/appEditGuard.ts +0 -372
- package/ai/tools/appReadSnapshot.ts +0 -153
- package/ai/tools/appTools.ts +0 -1549
- package/ai/tools/applyEditTool.ts +0 -259
- package/ai/tools/applyLineEditsTool.ts +0 -315
- package/ai/tools/browserTools/click.ts +0 -33
- package/ai/tools/browserTools/closeSession.ts +0 -29
- package/ai/tools/browserTools/common.ts +0 -27
- package/ai/tools/browserTools/openSession.ts +0 -48
- package/ai/tools/browserTools/readContent.ts +0 -38
- package/ai/tools/browserTools/selectOption.ts +0 -46
- package/ai/tools/browserTools/typeText.ts +0 -42
- package/ai/tools/category/createCategoryTool.ts +0 -66
- package/ai/tools/category/queryContentsByCategoryTool.ts +0 -69
- package/ai/tools/category/updateContentCategoryTool.ts +0 -75
- package/ai/tools/cfBrowserTools.ts +0 -319
- package/ai/tools/cfSpeechToTextTool.ts +0 -49
- package/ai/tools/checkEnvTool.ts +0 -102
- package/ai/tools/cloudflareCrawlTool.ts +0 -289
- package/ai/tools/codeSearchTool.ts +0 -123
- package/ai/tools/codeTools.ts +0 -101
- package/ai/tools/convertMarxistsBookTool.ts +0 -103
- package/ai/tools/createDocTool.ts +0 -132
- package/ai/tools/createSkillDocTool.ts +0 -155
- package/ai/tools/createWorkflowTool.ts +0 -154
- package/ai/tools/delayTool.ts +0 -31
- package/ai/tools/deleteSpacesTool.ts +0 -325
- package/ai/tools/deleteSpacesToolModel.ts +0 -159
- package/ai/tools/devReloadUtils.ts +0 -29
- package/ai/tools/dialogMessageSearch.ts +0 -137
- package/ai/tools/doctorSkillTool.ts +0 -72
- package/ai/tools/ecommerceScraperTool.ts +0 -86
- package/ai/tools/emailTools.ts +0 -549
- package/ai/tools/evalSkillTool.ts +0 -92
- package/ai/tools/exaSearchTool.ts +0 -63
- package/ai/tools/execShellTool.ts +0 -266
- package/ai/tools/executeSqlTool.ts +0 -192
- package/ai/tools/fetchWebpageSupport.ts +0 -333
- package/ai/tools/fetchWebpageTool.ts +0 -97
- package/ai/tools/geminiImagePreviewTool.ts +0 -386
- package/ai/tools/generateDocxTool.ts +0 -215
- package/ai/tools/googleSearchScraperTool.ts +0 -106
- package/ai/tools/importDataTool.ts +0 -133
- package/ai/tools/importSkillTool.ts +0 -162
- package/ai/tools/index.ts +0 -2290
- package/ai/tools/jdProductScraperTool.ts +0 -821
- package/ai/tools/listUserSpacesTool.ts +0 -113
- package/ai/tools/localFilesTool.ts +0 -276
- package/ai/tools/marxistsOfflineBook.ts +0 -253
- package/ai/tools/modelUsageTools.ts +0 -206
- package/ai/tools/noloWorkspaceReadTools.ts +0 -467
- package/ai/tools/olmOcrTool.ts +0 -33
- package/ai/tools/openaiImageTool.ts +0 -267
- package/ai/tools/prepareTools.ts +0 -193
- package/ai/tools/readDocTool.ts +0 -88
- package/ai/tools/readFileTool.ts +0 -214
- package/ai/tools/readTool.ts +0 -194
- package/ai/tools/readXPostTool.ts +0 -229
- package/ai/tools/readXhsProfileTool.ts +0 -638
- package/ai/tools/rememberMemoryTool.ts +0 -84
- package/ai/tools/remotionVideoTool.ts +0 -151
- package/ai/tools/searchDialogMessagesTool.ts +0 -222
- package/ai/tools/searchWorkspaceTool.ts +0 -259
- package/ai/tools/skillFollowup.ts +0 -86
- package/ai/tools/surfWeatherTool.ts +0 -169
- package/ai/tools/table/addTableRowTool.ts +0 -217
- package/ai/tools/table/createTableTool.ts +0 -326
- package/ai/tools/table/rowTools.ts +0 -386
- package/ai/tools/table/schemaTools.ts +0 -244
- package/ai/tools/table/shareTableTool.ts +0 -148
- package/ai/tools/table/toolShared.ts +0 -129
- package/ai/tools/taobaoTmallProductScraperTool.ts +0 -49
- package/ai/tools/toolApiClient.ts +0 -279
- package/ai/tools/toolNameAliases.ts +0 -70
- package/ai/tools/toolPacks.ts +0 -19
- package/ai/tools/toolResultError.ts +0 -42
- package/ai/tools/toolRunSlice.ts +0 -303
- package/ai/tools/toolSchemaCompatibility.ts +0 -53
- package/ai/tools/uiAskChoiceTool.ts +0 -104
- package/ai/tools/updateContentTitleTool.ts +0 -84
- package/ai/tools/updateDocTool.ts +0 -105
- package/ai/tools/updateUserPreferenceProfileTool.ts +0 -153
- package/ai/tools/wereadGatewayTool.ts +0 -152
- package/ai/tools/whisperTool.ts +0 -76
- package/ai/tools/writeFileTool.ts +0 -213
- package/ai/tools/youtubeScraperTool.ts +0 -116
- package/ai/tools/ziweiChartTool.ts +0 -678
- package/ai/types.ts +0 -58
- package/ai/workflow/workflowExecutor.ts +0 -323
- package/ai/workflow/workflowSlice.ts +0 -73
- package/ai/workflow/workflowTypes.ts +0 -106
- package/app/actions/syncAppRecord.ts +0 -73
- package/app/constants/animationSets.ts +0 -21
- package/app/constants/appEditor.ts +0 -99
- package/app/favorite/deletedFavoriteProjection.ts +0 -31
- package/app/favorite/favoriteSlice.ts +0 -690
- package/app/favorite/type.ts +0 -43
- package/app/hooks/deleteDbKey.ts +0 -254
- package/app/i18n/client.ts +0 -13
- package/app/i18n/i18n.base.ts +0 -14
- package/app/i18n/i18n.config.ts +0 -77
- package/app/i18n/index.ts +0 -15
- package/app/i18n/mapLanguage.ts +0 -11
- package/app/i18n/translations/appBuilder.locale.ts +0 -453
- package/app/i18n/translations/error.locale.ts +0 -246
- package/app/i18n/translations/interface.locale.ts +0 -2206
- package/app/i18n/translations/pricing.locale.ts +0 -397
- package/app/i18n/translations/privacy.locale.ts +0 -168
- package/app/i18n/translations/seo.locale.ts +0 -129
- package/app/i18n/translations/terms.locale.ts +0 -124
- package/app/i18n/types.ts +0 -6
- package/app/notifications/model.ts +0 -77
- package/app/notifications/notificationSlice.ts +0 -141
- package/app/reducer.ts +0 -36
- package/app/settings/dbActionThunks.ts +0 -34
- package/app/settings/defaultSpacePreference.ts +0 -87
- package/app/settings/settingSlice.tsx +0 -1212
- package/app/settings/settingsRecord.ts +0 -8
- package/app/stateViews/runtime.ts +0 -90
- package/app/store.ts +0 -55
- package/app/theme/colors.ts +0 -280
- package/app/theme/fontPreference.ts +0 -77
- package/app/theme/theme.config.ts +0 -120
- package/app/theme/themeModeBootstrap.ts +0 -123
- package/app/types/appSummary.ts +0 -118
- package/app/types.ts +0 -358
- package/app/utils/appKeys.ts +0 -55
- package/app/utils/async.ts +0 -28
- package/app/utils/desktopAgentRuntimeTurnClient.ts +0 -75
- package/app/utils/env.ts +0 -17
- package/app/utils/fileUtils.ts +0 -229
- package/app/utils/imageUtils.ts +0 -274
- package/app/utils/myContentItems.ts +0 -317
- package/app/utils/retryAfter.ts +0 -36
- package/app/utils/retryFetch.ts +0 -61
- package/app/utils/toast.ts +0 -3
- package/auth/action/signUpAction.ts +0 -227
- package/auth/adminPermissions.ts +0 -78
- package/auth/authSlice.ts +0 -531
- package/auth/client/loginRequest.ts +0 -14
- package/auth/resetAuthScopedClientState.ts +0 -27
- package/auth/routes.ts +0 -183
- package/auth/token.ts +0 -63
- package/auth/types.ts +0 -40
- package/authCommands.ts +0 -230
- package/chat/chat.locale.ts +0 -817
- package/chat/dialog/actions/addCybotAction.ts +0 -52
- package/chat/dialog/actions/addReferenceKeysAction.ts +0 -62
- package/chat/dialog/actions/builtinDialogLlm.ts +0 -35
- package/chat/dialog/actions/cleanupCliSession.ts +0 -40
- package/chat/dialog/actions/createDialogAction.ts +0 -379
- package/chat/dialog/actions/createScheduledTaskAction.ts +0 -78
- package/chat/dialog/actions/handleSendMessageAction.ts +0 -202
- package/chat/dialog/actions/handleSendMessageResolver.ts +0 -27
- package/chat/dialog/actions/removeCybotAction.ts +0 -6
- package/chat/dialog/actions/removeDialogAgentAction.ts +0 -44
- package/chat/dialog/actions/replacePrimaryCybotAction.ts +0 -6
- package/chat/dialog/actions/setPrimaryDialogAgentAction.ts +0 -52
- package/chat/dialog/actions/updateDialogSummaryAction.ts +0 -430
- package/chat/dialog/actions/updateDialogTitleAction.ts +0 -151
- package/chat/dialog/actions/updateDialogTitlePolicy.ts +0 -30
- package/chat/dialog/actions/updateTokensAction.ts +0 -233
- package/chat/dialog/dialogAgents.ts +0 -72
- package/chat/dialog/dialogAttachmentCleanup.ts +0 -135
- package/chat/dialog/dialogSlice.ts +0 -985
- package/chat/dialog/dialogTitle.ts +0 -81
- package/chat/dialog/dialogTokenStats.ts +0 -12
- package/chat/dialog/dialogUrl.ts +0 -6
- package/chat/dialog/goal.ts +0 -108
- package/chat/dialog/objectAssistantRegistry.ts +0 -286
- package/chat/dialog/schedule.ts +0 -17
- package/chat/messages/activityCompletion.ts +0 -97
- package/chat/messages/fetchAndCacheMessages.ts +0 -119
- package/chat/messages/fetchConvMsgs.ts +0 -51
- package/chat/messages/fetchMessages.ts +0 -84
- package/chat/messages/fileUrl.ts +0 -13
- package/chat/messages/imagePayloadPersistence.ts +0 -22
- package/chat/messages/messageAgent.ts +0 -8
- package/chat/messages/messageContent.ts +0 -203
- package/chat/messages/messageContract.ts +0 -88
- package/chat/messages/messageSlice.ts +0 -1386
- package/chat/messages/toolThunks.ts +0 -646
- package/chat/messages/types.ts +0 -192
- package/chat/messages/web/toolDisplayName.ts +0 -686
- package/cli/agentAliases.ts +0 -40
- package/cli/agentCommandSupport.ts +0 -81
- package/cli/agentInternalCommandEntries.ts +0 -44
- package/cli/agentListCommands.ts +0 -185
- package/cli/agentListHelpers.ts +0 -242
- package/cli/agentMachineCommands.ts +0 -426
- package/cli/agentNameResolver.ts +0 -164
- package/cli/agentPullCommand.ts +0 -142
- package/cli/agentRecordCommands.ts +0 -224
- package/cli/agentRecordHelpers.ts +0 -592
- package/cli/agentRunCommand.ts +0 -568
- package/cli/agentRuntimeLocal.ts +0 -45
- package/cli/authCommands.ts +0 -230
- package/cli/cliCommandAdapters.ts +0 -28
- package/cli/cliCommandDispatch.ts +0 -66
- package/cli/cliCommandFactories.ts +0 -66
- package/cli/cliCommandTypes.ts +0 -49
- package/cli/cliEnvHelpers.ts +0 -116
- package/cli/cliSpaceHelpers.ts +0 -39
- package/cli/client/agentConfigResolver.ts +0 -1
- package/cli/client/agentRun.ts +0 -735
- package/cli/client/compactDialog.ts +0 -222
- package/cli/client/hybridRecordStore.ts +0 -52
- package/cli/client/localAgentRecords.ts +0 -7
- package/cli/client/localDialogRecords.ts +0 -30
- package/cli/client/localProviderResolver.ts +0 -1
- package/cli/client/localRuntimeAdapter.ts +0 -1098
- package/cli/client/localToolPolicy.ts +0 -8
- package/cli/client/profileConfig.ts +0 -101
- package/cli/client/streamingOutput.ts +0 -38
- package/cli/commandRegistry.ts +0 -98
- package/cli/connectorRunArtifact.ts +0 -120
- package/cli/connectorWebSocketTarget.ts +0 -112
- package/cli/defaultServer.ts +0 -1
- package/cli/dialogAttachmentCleanup.ts +0 -151
- package/cli/dialogCommands.ts +0 -1120
- package/cli/dialogInternalCommandEntries.ts +0 -17
- package/cli/docCreateCommands.ts +0 -345
- package/cli/docInternalCommandEntries.ts +0 -11
- package/cli/docPageHelpers.ts +0 -80
- package/cli/docSkillHelpers.ts +0 -67
- package/cli/docSpaceHelpers.ts +0 -46
- package/cli/globalRecordOperations.ts +0 -258
- package/cli/internalCommandEntries.ts +0 -18
- package/cli/localRuntimeAuthority.ts +0 -182
- package/cli/localRuntimeDb.ts +0 -26
- package/cli/machineCommands.ts +0 -312
- package/cli/machineDaemonCommands.ts +0 -185
- package/cli/machineHeartbeatCommands.ts +0 -30
- package/cli/machineStatusCommands.ts +0 -95
- package/cli/machineWatchCommands.ts +0 -41
- package/cli/machineWsPromptMaterialization.ts +0 -89
- package/cli/machineWsRunDispatch.ts +0 -695
- package/cli/machineWsSession.ts +0 -213
- package/cli/memoryCommands.ts +0 -253
- package/cli/memoryInternalCommandEntries.ts +0 -9
- package/cli/offlineMarxistsAgentCommand.ts +0 -315
- package/cli/qoderUsageProbe.ts +0 -252
- package/cli/runtimeDoctorCommands.ts +0 -174
- package/cli/runtimeModeArgs.ts +0 -33
- package/cli/scriptCommandEntries.ts +0 -66
- package/cli/secretScan.ts +0 -31
- package/cli/systemInternalCommandEntries.ts +0 -65
- package/cli/tableCommands.ts +0 -453
- package/cli/tui/readlineWorkspace.ts +0 -210
- package/cli/tui/session.ts +0 -554
- package/cli/updateCommands.ts +0 -134
- package/cli/workflowInternalCommandEntries.ts +0 -10
- package/cliCommandAdapters.ts +0 -28
- package/cliCommandDispatch.ts +0 -66
- package/cliCommandFactories.ts +0 -66
- package/cliCommandTypes.ts +0 -49
- package/cliEnvHelpers.ts +0 -116
- package/cliSpaceHelpers.ts +0 -39
- package/client/agentConfigResolver.test.ts +0 -69
- package/client/agentConfigResolver.ts +0 -1
- package/client/agentRun.test.ts +0 -1346
- package/client/agentRun.ts +0 -735
- package/client/compactDialog.test.ts +0 -238
- package/client/compactDialog.ts +0 -222
- package/client/hybridRecordStore.test.ts +0 -157
- package/client/hybridRecordStore.ts +0 -52
- package/client/localAgentRecords.test.ts +0 -27
- package/client/localAgentRecords.ts +0 -7
- package/client/localDialogRecords.test.ts +0 -124
- package/client/localDialogRecords.ts +0 -30
- package/client/localProviderResolver.test.ts +0 -102
- package/client/localProviderResolver.ts +0 -1
- package/client/localRuntimeAdapter.test.ts +0 -2809
- package/client/localRuntimeAdapter.ts +0 -1098
- package/client/localRuntimeDryRun.test.ts +0 -135
- package/client/localToolPolicy.test.ts +0 -48
- package/client/localToolPolicy.ts +0 -8
- package/client/profileConfig.test.ts +0 -106
- package/client/profileConfig.ts +0 -101
- package/client/streamingOutput.test.ts +0 -22
- package/client/streamingOutput.ts +0 -38
- package/commandRegistry.ts +0 -98
- package/connector-experimental/capabilities.ts +0 -75
- package/connector-experimental/codexBinary.ts +0 -41
- package/connector-experimental/heartbeatLoop.ts +0 -22
- package/connector-experimental/machineInfo.ts +0 -46
- package/connector-experimental/protocol.ts +0 -54
- package/connectorRunArtifact.ts +0 -120
- package/connectorWebSocketTarget.ts +0 -112
- package/core/builtinAgents.ts +0 -209
- package/core/config.ts +0 -15
- package/core/crypto.ts +0 -51
- package/core/generateKeyPairFromSeedV1.ts +0 -15
- package/core/generateMainKey.ts +0 -22
- package/core/init.ts +0 -41
- package/core/localOrigins.ts +0 -8
- package/core/password.ts +0 -13
- package/core/prefix.ts +0 -23
- package/create/editor/transforms/fromMarkdown/index.ts +0 -260
- package/create/editor/transforms/fromMarkdown/inline.ts +0 -285
- package/create/editor/transforms/fromMarkdown/table.ts +0 -130
- package/create/editor/transforms/markdownToSlate.ts +0 -24
- package/create/editor/transforms/slateToRenderMarkdown.ts +0 -218
- package/create/editor/transforms/slateToSimplifiedMarkdown.ts +0 -224
- package/create/editor/transforms/slateToText.ts +0 -33
- package/create/editor/utils/slateUtils.ts +0 -233
- package/create/space/addSpaceAction.ts +0 -193
- package/create/space/category/categoryActions.ts +0 -427
- package/create/space/changeSpaceAction.ts +0 -36
- package/create/space/constants.ts +0 -8
- package/create/space/content/addContentAction.ts +0 -116
- package/create/space/content/contentThunks.ts +0 -90
- package/create/space/content/deleteContentFromSpaceAction.ts +0 -187
- package/create/space/content/deleteMultipleContentAction.ts +0 -112
- package/create/space/content/moveContentAction.ts +0 -285
- package/create/space/content/updateContentCategoryAction.ts +0 -154
- package/create/space/content/updateContentTitleAction.ts +0 -151
- package/create/space/content/uploadAndAddFileToSpaceAction.ts +0 -98
- package/create/space/contentKeyUtils.ts +0 -117
- package/create/space/deleteSpaceAction.ts +0 -276
- package/create/space/fetchSpaceAction.ts +0 -70
- package/create/space/fetchSpaceSidebarStateAction.ts +0 -26
- package/create/space/loadDefaultSpaceAction.ts +0 -57
- package/create/space/member/addMemberAction.ts +0 -79
- package/create/space/member/fetchUserSpaceMembershipsAction.ts +0 -386
- package/create/space/member/memberThunks.ts +0 -47
- package/create/space/member/removeMemberAction.ts +0 -67
- package/create/space/resolvePreferredSpaceId.ts +0 -113
- package/create/space/sidebarVisibleTypes.ts +0 -260
- package/create/space/space.locale.ts +0 -1087
- package/create/space/spaceAccess.ts +0 -182
- package/create/space/spaceCollapsedState.ts +0 -54
- package/create/space/spaceKeys.ts +0 -65
- package/create/space/spaceSlice.ts +0 -328
- package/create/space/spaceThunks.ts +0 -410
- package/create/space/types.ts +0 -27
- package/create/space/updateSpaceAction.ts +0 -107
- package/create/space/utils/permissions.ts +0 -47
- package/create/types.ts +0 -21
- package/database/actions/agentReadResolution.ts +0 -33
- package/database/actions/common.ts +0 -243
- package/database/actions/deleteFile.ts +0 -40
- package/database/actions/fileContent.ts +0 -125
- package/database/actions/patch.ts +0 -155
- package/database/actions/read.ts +0 -358
- package/database/actions/readAndWait.ts +0 -260
- package/database/actions/readRequestManager.ts +0 -120
- package/database/actions/readResolution.ts +0 -125
- package/database/actions/remove.ts +0 -94
- package/database/actions/replication.ts +0 -477
- package/database/actions/upload.ts +0 -186
- package/database/actions/upsert.ts +0 -56
- package/database/actions/write.ts +0 -146
- package/database/authority/ownerKey.ts +0 -80
- package/database/authority/recordAuthority.ts +0 -67
- package/database/authority/userAuthorityRegistry.ts +0 -54
- package/database/client/fetchUserData.ts +0 -61
- package/database/config.ts +0 -40
- package/database/dbActionThunks.ts +0 -1
- package/database/dbSlice.ts +0 -149
- package/database/fileRing.ts +0 -51
- package/database/fileStorage.ts +0 -232
- package/database/fileUrl.ts +0 -34
- package/database/keys.ts +0 -767
- package/database/queryPrefixes.ts +0 -14
- package/database/requests.ts +0 -443
- package/database/runtimeServerContext.ts +0 -54
- package/database/server/authorityStoreTypes.ts +0 -31
- package/database/server/cliAuthorityBrokerClient.ts +0 -227
- package/database/server/cliAuthorityBrokerServer.ts +0 -283
- package/database/server/cliAuthorityBrokerTypes.ts +0 -43
- package/database/server/cliAuthorityStoreDriver.ts +0 -98
- package/database/server/db.ts +0 -99
- package/database/server/dbPath.ts +0 -20
- package/database/server/ensureDbOpen.ts +0 -12
- package/database/server/legacyServerDb.ts +0 -58
- package/database/server/levelAuthorityStore.ts +0 -114
- package/database/server/memoryAuthorityStore.ts +0 -133
- package/database/server/serverStoreFactory.ts +0 -118
- package/database/tenantPlacement.ts +0 -57
- package/database/tombstones.ts +0 -52
- package/database/userDataMerge.ts +0 -95
- package/database/userPreferenceRegister.ts +0 -131
- package/database/utils/ulid.ts +0 -1
- package/defaultServer.ts +0 -1
- package/dialogAttachmentCleanup.ts +0 -151
- package/dialogCommands.ts +0 -1120
- package/dialogInternalCommandEntries.ts +0 -17
- package/docCreateCommands.ts +0 -345
- package/docInternalCommandEntries.ts +0 -11
- package/docPageHelpers.ts +0 -80
- package/docSkillHelpers.ts +0 -67
- package/docSpaceHelpers.ts +0 -46
- package/globalRecordOperations.ts +0 -258
- package/index.ts +0 -78
- package/integrations/anthropic/anthropicModels.ts +0 -47
- package/integrations/deepseek/models.ts +0 -37
- package/integrations/google/models.ts +0 -341
- package/integrations/openai/chatCompletionStreamMode.ts +0 -10
- package/integrations/openai/filterAndCleanMessages.ts +0 -284
- package/integrations/openai/flexTier.ts +0 -102
- package/integrations/openai/generateOpenAIRequestBody.ts +0 -271
- package/integrations/openai/generateResponseRequestBody.ts +0 -77
- package/integrations/openai/models.ts +0 -271
- package/integrations/openai/providerBodyCompatibility.ts +0 -23
- package/integrations/openai/responsesHelpers.ts +0 -297
- package/integrations/x-reader/types.ts +0 -109
- package/integrations/xai/models.ts +0 -13
- package/integrations/xhs-reader/redaction.ts +0 -68
- package/integrations/xhs-reader/types.ts +0 -277
- package/integrations/xhs-reader/url.ts +0 -80
- package/internalCommandEntries.ts +0 -18
- package/localRuntimeAuthority.ts +0 -182
- package/localRuntimeDb.ts +0 -26
- package/machineCommands.ts +0 -312
- package/machineDaemonCommands.ts +0 -185
- package/machineHeartbeatCommands.ts +0 -30
- package/machineStatusCommands.ts +0 -95
- package/machineWatchCommands.ts +0 -41
- package/machineWsPromptMaterialization.ts +0 -89
- package/machineWsRunDispatch.ts +0 -695
- package/machineWsSession.ts +0 -213
- package/memoryCommands.ts +0 -253
- package/memoryInternalCommandEntries.ts +0 -9
- package/offlineMarxistsAgentCommand.ts +0 -315
- package/qoderUsageProbe.ts +0 -252
- package/render/contentIcon/types.ts +0 -167
- package/render/page/createPageAction.ts +0 -183
- package/render/page/docSlice.ts +0 -495
- package/render/page/types.ts +0 -19
- package/render/table/activityColumns.ts +0 -6
- package/render/table/createTableAction.ts +0 -274
- package/render/table/deleteTableAction.ts +0 -193
- package/render/table/fetchAndCacheTableRows.ts +0 -174
- package/render/table/tableSlice.ts +0 -1167
- package/render/table/toolValueUtils.ts +0 -363
- package/render/table/types.ts +0 -262
- package/render/table/utils/tableSerialization.ts +0 -50
- package/runtimeDoctorCommands.ts +0 -174
- package/runtimeModeArgs.ts +0 -33
- package/scriptCommandEntries.ts +0 -66
- package/secretScan.ts +0 -31
- package/server/handlers/agentRun/types.ts +0 -105
- package/share/action.ts +0 -225
- package/share/helpers.ts +0 -302
- package/share/keys.ts +0 -243
- package/share/publicSharePolicy.ts +0 -27
- package/share/shareSlice.ts +0 -53
- package/share/types.ts +0 -100
- package/systemInternalCommandEntries.ts +0 -65
- package/tableCommands.ts +0 -453
- package/tui/readlineWorkspace.ts +0 -210
- package/tui/session.ts +0 -554
- package/updateCommands.ts +0 -134
- package/workflowInternalCommandEntries.ts +0 -10
package/client/agentRun.test.ts
DELETED
|
@@ -1,1346 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { Writable } from "node:stream";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
classifyTaskContextReviewStatus,
|
|
6
|
-
findServerPlatformTools,
|
|
7
|
-
runAgentTurn,
|
|
8
|
-
} from "./agentRun";
|
|
9
|
-
import { BUILTIN_NOLO_AGENT_KEY } from "./localRuntimeAdapter";
|
|
10
|
-
|
|
11
|
-
const TEST_MONTHLY_MIMO_AGENT_KEY = "agent-user-1-monthly-mimo";
|
|
12
|
-
const TEST_PROJECT_MANAGER_AGENT_KEY = "agent-user-1-project-manager";
|
|
13
|
-
|
|
14
|
-
class CaptureOutput extends Writable {
|
|
15
|
-
chunks: string[] = [];
|
|
16
|
-
|
|
17
|
-
_write(chunk: unknown, _encoding: BufferEncoding, callback: (error?: Error | null) => void) {
|
|
18
|
-
this.chunks.push(String(chunk));
|
|
19
|
-
callback();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
text() {
|
|
23
|
-
return this.chunks.join("");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
describe("cli agent run client", () => {
|
|
28
|
-
test("classifies only clear reviewer outcomes", () => {
|
|
29
|
-
expect(classifyTaskContextReviewStatus("Review decision: passed")).toBe("passed");
|
|
30
|
-
expect(classifyTaskContextReviewStatus("Review decision: needs_changes")).toBe("needs_changes");
|
|
31
|
-
expect(classifyTaskContextReviewStatus("Review decision: blocked")).toBe("blocked");
|
|
32
|
-
expect(classifyTaskContextReviewStatus("LGTM, no issues found")).toBe("passed");
|
|
33
|
-
expect(classifyTaskContextReviewStatus("Changes requested for missing test coverage")).toBe(
|
|
34
|
-
"needs_changes"
|
|
35
|
-
);
|
|
36
|
-
expect(classifyTaskContextReviewStatus("I looked at the diff and have notes")).toBeUndefined();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("identifies server platform tools that local runtime cannot provide", () => {
|
|
40
|
-
expect(findServerPlatformTools(["readFile", "queryTableRows", "updateTableRow"])).toEqual([
|
|
41
|
-
"queryTableRows",
|
|
42
|
-
"updateTableRow",
|
|
43
|
-
]);
|
|
44
|
-
expect(findServerPlatformTools(["readFile", "execShell"])).toEqual([]);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test("calls the Nolo HTTP API directly when AUTH_TOKEN is present", async () => {
|
|
48
|
-
const output = new CaptureOutput();
|
|
49
|
-
const requests: Array<{ url: string; body: any; auth: string | null }> = [];
|
|
50
|
-
|
|
51
|
-
const result = await runAgentTurn({
|
|
52
|
-
agentName: "nolo",
|
|
53
|
-
agentKey: "agent-pub-test",
|
|
54
|
-
serverUrl: "https://nolo.chat",
|
|
55
|
-
message: "hello",
|
|
56
|
-
continueDialogId: "dialog-existing",
|
|
57
|
-
scriptDir: "C:/missing/scripts",
|
|
58
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
59
|
-
output,
|
|
60
|
-
fetchImpl: async (url, init) => {
|
|
61
|
-
requests.push({
|
|
62
|
-
url: String(url),
|
|
63
|
-
body: JSON.parse(String(init?.body)),
|
|
64
|
-
auth: new Headers(init?.headers).get("Authorization"),
|
|
65
|
-
});
|
|
66
|
-
return Response.json({
|
|
67
|
-
content: "hi",
|
|
68
|
-
dialogId: "dialog-1",
|
|
69
|
-
usage: { input_tokens: 2, output_tokens: 3 },
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
expect(requests).toEqual([
|
|
75
|
-
{
|
|
76
|
-
url: "https://nolo.chat/api/agent/run",
|
|
77
|
-
auth: "Bearer token-123",
|
|
78
|
-
body: {
|
|
79
|
-
agentKey: "agent-pub-test",
|
|
80
|
-
userInput: "hello",
|
|
81
|
-
continueDialogId: "dialog-existing",
|
|
82
|
-
runtimeContext: {
|
|
83
|
-
surface: "cli",
|
|
84
|
-
host: "terminal",
|
|
85
|
-
runtime: "bun",
|
|
86
|
-
entrypoint: "nolo-cli",
|
|
87
|
-
capabilities: ["text-io", "streaming", "slash-commands"],
|
|
88
|
-
},
|
|
89
|
-
stream: true,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
]);
|
|
93
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-1" });
|
|
94
|
-
expect(output.text()).toContain("nolo -> working");
|
|
95
|
-
expect(output.text()).toContain("nolo > hi");
|
|
96
|
-
expect(output.text()).not.toContain("tokens=");
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test("prints agent run error details from failed HTTP responses", async () => {
|
|
100
|
-
const output = new CaptureOutput();
|
|
101
|
-
|
|
102
|
-
const result = await runAgentTurn({
|
|
103
|
-
agentName: "win-codex",
|
|
104
|
-
agentKey: "agent-win-codex",
|
|
105
|
-
serverUrl: "https://nolo.chat",
|
|
106
|
-
message: "restart connector",
|
|
107
|
-
scriptDir: "C:/missing/scripts",
|
|
108
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
109
|
-
output,
|
|
110
|
-
fetchImpl: async () =>
|
|
111
|
-
Response.json({
|
|
112
|
-
error: "Connector execution failed",
|
|
113
|
-
reason: "connector_execution_failed",
|
|
114
|
-
code: "connector_disconnected_mid_run",
|
|
115
|
-
message: "Connector disconnected for machine: machine-win",
|
|
116
|
-
dialogId: "dialog-failed-1",
|
|
117
|
-
}, { status: 502 }),
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
expect(result).toEqual({ exitCode: 1, dialogId: "dialog-failed-1" });
|
|
121
|
-
expect(output.text()).toContain("[nolo] Agent request failed: HTTP 502");
|
|
122
|
-
expect(output.text()).toContain("Connector execution failed");
|
|
123
|
-
expect(output.text()).toContain("Connector disconnected for machine: machine-win");
|
|
124
|
-
expect(output.text()).toContain("code=connector_disconnected_mid_run");
|
|
125
|
-
expect(output.text()).toContain("reason=connector_execution_failed");
|
|
126
|
-
expect(output.text()).toContain("[nolo] failed dialog: dialog-failed-1");
|
|
127
|
-
expect(output.text()).toContain(
|
|
128
|
-
'nolo agent run agent-win-codex --continue dialog-failed-1 --msg "retry"'
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
test("converts task row context to subjectRefs without legacy prompt or runtime taskRun payload", async () => {
|
|
133
|
-
const output = new CaptureOutput();
|
|
134
|
-
const requests: Array<{ body: any }> = [];
|
|
135
|
-
|
|
136
|
-
await runAgentTurn({
|
|
137
|
-
agentName: "frontend",
|
|
138
|
-
agentKey: "frontend-implementer",
|
|
139
|
-
serverUrl: "https://nolo.chat",
|
|
140
|
-
message: "Fix the filter UI",
|
|
141
|
-
scriptDir: "C:/missing/scripts",
|
|
142
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
143
|
-
output,
|
|
144
|
-
runtimeMode: "server",
|
|
145
|
-
taskRowContext: {
|
|
146
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
147
|
-
artifactIds: ["artifact-1"],
|
|
148
|
-
},
|
|
149
|
-
fetchImpl: async (_url, init) => {
|
|
150
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
151
|
-
return Response.json({ content: "ok", dialogId: "dialog-1" });
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
expect(requests[0]?.body.userInput).toBe("Fix the filter UI");
|
|
156
|
-
expect(requests[0]?.body.runtimeContext.taskRun).toBeUndefined();
|
|
157
|
-
expect(requests[0]?.body.runtimeContext.subjectRefs).toContainEqual({
|
|
158
|
-
kind: "table-row",
|
|
159
|
-
id: "row-b2e06f801f-01TASK",
|
|
160
|
-
role: "task",
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test("does not write task-context completion after an HTTP agent run returns a dialog", async () => {
|
|
165
|
-
const output = new CaptureOutput();
|
|
166
|
-
|
|
167
|
-
const result = await runAgentTurn({
|
|
168
|
-
agentName: "frontend-implementer",
|
|
169
|
-
agentKey: "agent-frontend",
|
|
170
|
-
serverUrl: "https://nolo.chat",
|
|
171
|
-
message: "Fix the filter UI",
|
|
172
|
-
scriptDir: "C:/missing/scripts",
|
|
173
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
174
|
-
output,
|
|
175
|
-
runtimeMode: "server",
|
|
176
|
-
taskRowContext: {
|
|
177
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
178
|
-
},
|
|
179
|
-
fetchImpl: async () => {
|
|
180
|
-
return Response.json({ content: "patched", dialogId: "dialog-1" });
|
|
181
|
-
},
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-1" });
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
test("sends image inputs as multimodal userInput over HTTP", async () => {
|
|
188
|
-
const output = new CaptureOutput();
|
|
189
|
-
const requests: Array<{ body: any }> = [];
|
|
190
|
-
|
|
191
|
-
await runAgentTurn({
|
|
192
|
-
agentName: "vision",
|
|
193
|
-
agentKey: "agent-pub-vision",
|
|
194
|
-
serverUrl: "https://nolo.chat",
|
|
195
|
-
message: "describe this",
|
|
196
|
-
imageUrls: ["https://example.com/a.png"],
|
|
197
|
-
scriptDir: "C:/missing/scripts",
|
|
198
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
199
|
-
output,
|
|
200
|
-
runtimeMode: "server",
|
|
201
|
-
fetchImpl: async (_url, init) => {
|
|
202
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
203
|
-
return Response.json({ content: "ok" });
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
expect(requests[0]?.body.userInput).toEqual([
|
|
208
|
-
{ type: "text", text: "describe this" },
|
|
209
|
-
{ type: "image_url", image_url: { url: "https://example.com/a.png" } },
|
|
210
|
-
]);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
test("sends CLI dialog metadata over HTTP", async () => {
|
|
214
|
-
const output = new CaptureOutput();
|
|
215
|
-
const requests: Array<{ body: any }> = [];
|
|
216
|
-
|
|
217
|
-
const result = await runAgentTurn({
|
|
218
|
-
agentName: "nolo",
|
|
219
|
-
agentKey: "agent-pub-test",
|
|
220
|
-
serverUrl: "https://nolo.chat",
|
|
221
|
-
message: "hello",
|
|
222
|
-
spaceId: "space-1",
|
|
223
|
-
category: "manual-checks",
|
|
224
|
-
inheritedFromDialogKey: "dialog-user-1-dialog-2",
|
|
225
|
-
parentDialogId: "dialog-2",
|
|
226
|
-
subjectDialogKey: "01SUBJECTDIALOG",
|
|
227
|
-
background: true,
|
|
228
|
-
noStream: true,
|
|
229
|
-
timeoutMs: 600000,
|
|
230
|
-
scriptDir: "C:/missing/scripts",
|
|
231
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
232
|
-
output,
|
|
233
|
-
runtimeMode: "server",
|
|
234
|
-
fetchImpl: async (_url, init) => {
|
|
235
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
236
|
-
return Response.json({ dialogId: "dialog-1", status: "queued" });
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
expect(requests[0]?.body).toMatchObject({
|
|
241
|
-
agentKey: "agent-pub-test",
|
|
242
|
-
userInput: "hello",
|
|
243
|
-
spaceId: "space-1",
|
|
244
|
-
category: "manual-checks",
|
|
245
|
-
inheritedFromDialogKey: "dialog-user-1-dialog-2",
|
|
246
|
-
parentDialogId: "dialog-2",
|
|
247
|
-
background: true,
|
|
248
|
-
timeoutMs: 600000,
|
|
249
|
-
stream: false,
|
|
250
|
-
});
|
|
251
|
-
expect(requests[0]?.body.runtimeContext.subjectRefs).toEqual([
|
|
252
|
-
{ kind: "dialog", id: "01SUBJECTDIALOG", role: "subject" },
|
|
253
|
-
]);
|
|
254
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-1" });
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
test("sends explicit subject refs over HTTP for review evidence", async () => {
|
|
258
|
-
const output = new CaptureOutput();
|
|
259
|
-
const requests: Array<{ body: any }> = [];
|
|
260
|
-
|
|
261
|
-
await runAgentTurn({
|
|
262
|
-
agentName: "reviewer",
|
|
263
|
-
agentKey: "agent-reviewer",
|
|
264
|
-
serverUrl: "https://nolo.chat",
|
|
265
|
-
message: "Review this implementation",
|
|
266
|
-
subjectRefs: [
|
|
267
|
-
{ kind: "table-row", id: "row-user-board-task", role: "subject" },
|
|
268
|
-
{ kind: "dialog", id: "dialog-impl", role: "review-target" },
|
|
269
|
-
{ kind: "external", id: "commit:abc123", role: "commit" },
|
|
270
|
-
],
|
|
271
|
-
scriptDir: "C:/missing/scripts",
|
|
272
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
273
|
-
output,
|
|
274
|
-
runtimeMode: "server",
|
|
275
|
-
fetchImpl: async (_url, init) => {
|
|
276
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
277
|
-
return Response.json({ content: "queued", dialogId: "dialog-review" });
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
expect(requests[0]?.body.runtimeContext.subjectRefs).toEqual([
|
|
282
|
-
{ kind: "table-row", id: "row-user-board-task", role: "subject" },
|
|
283
|
-
{ kind: "dialog", id: "dialog-impl", role: "review-target" },
|
|
284
|
-
{ kind: "external", id: "commit:abc123", role: "commit" },
|
|
285
|
-
]);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
test("does not write background handoff state", async () => {
|
|
289
|
-
const output = new CaptureOutput();
|
|
290
|
-
|
|
291
|
-
const result = await runAgentTurn({
|
|
292
|
-
agentName: "frontend-implementer",
|
|
293
|
-
agentKey: "agent-frontend",
|
|
294
|
-
serverUrl: "https://nolo.chat",
|
|
295
|
-
message: "Fix settings style FOUC",
|
|
296
|
-
scriptDir: "C:/missing/scripts",
|
|
297
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
298
|
-
runtimeMode: "server",
|
|
299
|
-
background: true,
|
|
300
|
-
noStream: true,
|
|
301
|
-
taskRowContext: {
|
|
302
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
303
|
-
},
|
|
304
|
-
output,
|
|
305
|
-
fetchImpl: async () => {
|
|
306
|
-
return Response.json({ dialogId: "dialog-bg", status: "pending" }, { status: 202 });
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-bg" });
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
test("runs forced local turns through the injected runtime adapter without HTTP", async () => {
|
|
314
|
-
const output = new CaptureOutput();
|
|
315
|
-
const result = await runAgentTurn({
|
|
316
|
-
agentName: "frontend",
|
|
317
|
-
agentKey: "frontend-local",
|
|
318
|
-
serverUrl: "https://nolo.chat",
|
|
319
|
-
message: "polish notifications",
|
|
320
|
-
scriptDir: "C:/missing/scripts",
|
|
321
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
322
|
-
output,
|
|
323
|
-
runtimeMode: "local",
|
|
324
|
-
localRuntimeAdapter: {
|
|
325
|
-
host: "cli",
|
|
326
|
-
capabilities: ["local-provider", "local-persistence"],
|
|
327
|
-
loadAgentConfig: async (agentRef) => ({
|
|
328
|
-
key: agentRef,
|
|
329
|
-
name: "Frontend",
|
|
330
|
-
prompt: "Fix UI",
|
|
331
|
-
model: "fake-local",
|
|
332
|
-
}),
|
|
333
|
-
loadDialogHistory: async () => [],
|
|
334
|
-
saveTurn: async () => ({ dialogId: "dialog-local" }),
|
|
335
|
-
resolveProvider: async () => ({
|
|
336
|
-
model: "fake-local",
|
|
337
|
-
complete: async (messages) => ({
|
|
338
|
-
content: `local:${messages.at(-1)?.content}`,
|
|
339
|
-
model: "fake-local",
|
|
340
|
-
trace: messages,
|
|
341
|
-
}),
|
|
342
|
-
}),
|
|
343
|
-
executeTool: async () => {
|
|
344
|
-
throw new Error("no tools expected");
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
fetchImpl: async () => {
|
|
348
|
-
throw new Error("HTTP should not be called for forced local runs");
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local" });
|
|
353
|
-
expect(output.text()).toContain("frontend -> working locally");
|
|
354
|
-
expect(output.text()).toContain("frontend > local:polish notifications");
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
test("continues forced local tool loops until the provider returns final text", async () => {
|
|
358
|
-
const output = new CaptureOutput();
|
|
359
|
-
let completeCalls = 0;
|
|
360
|
-
let toolCalls = 0;
|
|
361
|
-
|
|
362
|
-
const result = await runAgentTurn({
|
|
363
|
-
agentName: "frontend",
|
|
364
|
-
agentKey: "frontend-local",
|
|
365
|
-
serverUrl: "https://nolo.chat",
|
|
366
|
-
message: "make screenshots",
|
|
367
|
-
scriptDir: "C:/missing/scripts",
|
|
368
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
369
|
-
output,
|
|
370
|
-
runtimeMode: "local",
|
|
371
|
-
localRuntimeAdapter: {
|
|
372
|
-
host: "cli",
|
|
373
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
374
|
-
loadAgentConfig: async (agentRef) => ({
|
|
375
|
-
key: agentRef,
|
|
376
|
-
name: "Frontend",
|
|
377
|
-
prompt: "Fix UI",
|
|
378
|
-
model: "fake-local",
|
|
379
|
-
toolNames: ["readFile"],
|
|
380
|
-
}),
|
|
381
|
-
loadDialogHistory: async () => [],
|
|
382
|
-
saveTurn: async () => ({ dialogId: "dialog-local-retry" }),
|
|
383
|
-
resolveProvider: async () => ({
|
|
384
|
-
model: "fake-local",
|
|
385
|
-
complete: async () => {
|
|
386
|
-
completeCalls += 1;
|
|
387
|
-
if (completeCalls <= 3) {
|
|
388
|
-
return {
|
|
389
|
-
content: "",
|
|
390
|
-
model: "fake-local",
|
|
391
|
-
tool_calls: [{
|
|
392
|
-
id: `call-${completeCalls}`,
|
|
393
|
-
type: "function",
|
|
394
|
-
function: { name: "readFile", arguments: "{}" },
|
|
395
|
-
}],
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
return { content: "done after retry", model: "fake-local" };
|
|
399
|
-
},
|
|
400
|
-
}),
|
|
401
|
-
executeTool: async () => {
|
|
402
|
-
toolCalls += 1;
|
|
403
|
-
return { content: "ok" };
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local-retry" });
|
|
409
|
-
expect(toolCalls).toBe(3);
|
|
410
|
-
expect(output.text()).toContain("frontend > done after retry");
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
test("prints compact local tool trace by default", async () => {
|
|
414
|
-
const output = new CaptureOutput();
|
|
415
|
-
let completeCalls = 0;
|
|
416
|
-
|
|
417
|
-
const result = await runAgentTurn({
|
|
418
|
-
agentName: "frontend",
|
|
419
|
-
agentKey: "frontend-local",
|
|
420
|
-
serverUrl: "https://nolo.chat",
|
|
421
|
-
message: "inspect repo",
|
|
422
|
-
scriptDir: "C:/missing/scripts",
|
|
423
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
424
|
-
output,
|
|
425
|
-
runtimeMode: "local",
|
|
426
|
-
localRuntimeAdapter: {
|
|
427
|
-
host: "cli",
|
|
428
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
429
|
-
loadAgentConfig: async (agentRef) => ({
|
|
430
|
-
key: agentRef,
|
|
431
|
-
name: "Frontend",
|
|
432
|
-
prompt: "Fix UI",
|
|
433
|
-
model: "fake-local",
|
|
434
|
-
toolNames: ["readFile"],
|
|
435
|
-
}),
|
|
436
|
-
loadDialogHistory: async () => [],
|
|
437
|
-
saveTurn: async () => ({ dialogId: "dialog-local" }),
|
|
438
|
-
resolveProvider: async () => ({
|
|
439
|
-
model: "fake-local",
|
|
440
|
-
complete: async () => {
|
|
441
|
-
completeCalls += 1;
|
|
442
|
-
if (completeCalls === 1) {
|
|
443
|
-
return {
|
|
444
|
-
content: "",
|
|
445
|
-
model: "fake-local",
|
|
446
|
-
tool_calls: [{
|
|
447
|
-
id: "call-read",
|
|
448
|
-
type: "function",
|
|
449
|
-
function: { name: "readFile", arguments: JSON.stringify({ path: "README.md" }) },
|
|
450
|
-
}],
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
return { content: "done", model: "fake-local" };
|
|
454
|
-
},
|
|
455
|
-
}),
|
|
456
|
-
executeTool: async () => ({ content: "clean" }),
|
|
457
|
-
},
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local" });
|
|
461
|
-
expect(output.text()).toContain("[nolo:tool] #1 -> readFile README.md");
|
|
462
|
-
expect(output.text()).toContain("[nolo:tool] #1 <- readFile");
|
|
463
|
-
expect(output.text()).toContain("1 line");
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
test("does not print local tool trace when disabled by env", async () => {
|
|
467
|
-
const output = new CaptureOutput();
|
|
468
|
-
let completeCalls = 0;
|
|
469
|
-
|
|
470
|
-
const result = await runAgentTurn({
|
|
471
|
-
agentName: "frontend",
|
|
472
|
-
agentKey: "frontend-local",
|
|
473
|
-
serverUrl: "https://nolo.chat",
|
|
474
|
-
message: "inspect repo",
|
|
475
|
-
scriptDir: "C:/missing/scripts",
|
|
476
|
-
env: { AUTH_TOKEN: "token-123", NOLO_TRACE_TOOLS: "0" },
|
|
477
|
-
output,
|
|
478
|
-
runtimeMode: "local",
|
|
479
|
-
localRuntimeAdapter: {
|
|
480
|
-
host: "cli",
|
|
481
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
482
|
-
loadAgentConfig: async (agentRef) => ({
|
|
483
|
-
key: agentRef,
|
|
484
|
-
name: "Frontend",
|
|
485
|
-
prompt: "Fix UI",
|
|
486
|
-
model: "fake-local",
|
|
487
|
-
toolNames: ["readFile"],
|
|
488
|
-
}),
|
|
489
|
-
loadDialogHistory: async () => [],
|
|
490
|
-
saveTurn: async () => ({ dialogId: "dialog-local-no-trace" }),
|
|
491
|
-
resolveProvider: async () => ({
|
|
492
|
-
model: "fake-local",
|
|
493
|
-
complete: async () => {
|
|
494
|
-
completeCalls += 1;
|
|
495
|
-
if (completeCalls === 1) {
|
|
496
|
-
return {
|
|
497
|
-
content: "",
|
|
498
|
-
model: "fake-local",
|
|
499
|
-
tool_calls: [{
|
|
500
|
-
id: "call-read",
|
|
501
|
-
type: "function",
|
|
502
|
-
function: { name: "readFile", arguments: JSON.stringify({ path: "README.md" }) },
|
|
503
|
-
}],
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
return { content: "done", model: "fake-local" };
|
|
507
|
-
},
|
|
508
|
-
}),
|
|
509
|
-
executeTool: async () => ({ content: "clean" }),
|
|
510
|
-
},
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local-no-trace" });
|
|
514
|
-
expect(output.text()).not.toContain("[nolo:tool]");
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
test("prints local tool events as jsonl when requested", async () => {
|
|
518
|
-
const output = new CaptureOutput();
|
|
519
|
-
let completeCalls = 0;
|
|
520
|
-
|
|
521
|
-
const result = await runAgentTurn({
|
|
522
|
-
agentName: "frontend",
|
|
523
|
-
agentKey: "frontend-local",
|
|
524
|
-
serverUrl: "https://nolo.chat",
|
|
525
|
-
message: "inspect repo",
|
|
526
|
-
scriptDir: "C:/missing/scripts",
|
|
527
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
528
|
-
output,
|
|
529
|
-
runtimeMode: "local",
|
|
530
|
-
eventsMode: "jsonl",
|
|
531
|
-
localRuntimeAdapter: {
|
|
532
|
-
host: "cli",
|
|
533
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
534
|
-
loadAgentConfig: async (agentRef) => ({
|
|
535
|
-
key: agentRef,
|
|
536
|
-
name: "Frontend",
|
|
537
|
-
prompt: "Fix UI",
|
|
538
|
-
model: "fake-local",
|
|
539
|
-
toolNames: ["execShell"],
|
|
540
|
-
}),
|
|
541
|
-
loadDialogHistory: async () => [],
|
|
542
|
-
saveTurn: async () => ({ dialogId: "dialog-local-jsonl" }),
|
|
543
|
-
resolveProvider: async () => ({
|
|
544
|
-
model: "fake-local",
|
|
545
|
-
complete: async () => {
|
|
546
|
-
completeCalls += 1;
|
|
547
|
-
if (completeCalls === 1) {
|
|
548
|
-
return {
|
|
549
|
-
content: "",
|
|
550
|
-
model: "fake-local",
|
|
551
|
-
tool_calls: [{
|
|
552
|
-
id: "call-shell",
|
|
553
|
-
type: "function",
|
|
554
|
-
function: { name: "execShell", arguments: JSON.stringify({ command: "git status --short" }) },
|
|
555
|
-
}],
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
return { content: "done", model: "fake-local" };
|
|
559
|
-
},
|
|
560
|
-
}),
|
|
561
|
-
executeTool: async () => ({ content: "stdout:\nclean\n\nexitCode: 0", metadata: { exitCode: 0 } }),
|
|
562
|
-
},
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local-jsonl" });
|
|
566
|
-
const events = output.text()
|
|
567
|
-
.split(/\r?\n/)
|
|
568
|
-
.filter((line) => line.startsWith("{"))
|
|
569
|
-
.map((line) => JSON.parse(line))
|
|
570
|
-
.filter((event) => typeof event.type === "string" && event.type.startsWith("tool-"));
|
|
571
|
-
expect(events).toHaveLength(2);
|
|
572
|
-
expect(events[0]).toMatchObject({
|
|
573
|
-
schemaVersion: 1,
|
|
574
|
-
type: "tool-call",
|
|
575
|
-
round: 1,
|
|
576
|
-
tool: "execShell",
|
|
577
|
-
argsPreview: "git status --short",
|
|
578
|
-
});
|
|
579
|
-
expect(events[1]).toMatchObject({
|
|
580
|
-
schemaVersion: 1,
|
|
581
|
-
type: "tool-result",
|
|
582
|
-
round: 1,
|
|
583
|
-
tool: "execShell",
|
|
584
|
-
summary: expect.stringContaining("exit=0"),
|
|
585
|
-
metadata: { exitCode: 0 },
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
test("does not pass local tool evidence to an external writeback path", async () => {
|
|
590
|
-
const output = new CaptureOutput();
|
|
591
|
-
let completeCalls = 0;
|
|
592
|
-
|
|
593
|
-
const result = await runAgentTurn({
|
|
594
|
-
agentName: "frontend",
|
|
595
|
-
agentKey: "frontend-local",
|
|
596
|
-
serverUrl: "https://nolo.chat",
|
|
597
|
-
message: "inspect repo",
|
|
598
|
-
scriptDir: "C:/missing/scripts",
|
|
599
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
600
|
-
output,
|
|
601
|
-
runtimeMode: "local",
|
|
602
|
-
taskRowContext: {
|
|
603
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
604
|
-
},
|
|
605
|
-
localRuntimeAdapter: {
|
|
606
|
-
host: "cli",
|
|
607
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
608
|
-
loadAgentConfig: async (agentRef) => ({
|
|
609
|
-
key: agentRef,
|
|
610
|
-
name: "Frontend",
|
|
611
|
-
prompt: "Fix UI",
|
|
612
|
-
model: "fake-local",
|
|
613
|
-
toolNames: ["readFile"],
|
|
614
|
-
}),
|
|
615
|
-
loadDialogHistory: async () => [],
|
|
616
|
-
saveTurn: async () => ({ dialogId: "dialog-local" }),
|
|
617
|
-
resolveProvider: async () => ({
|
|
618
|
-
model: "fake-local",
|
|
619
|
-
complete: async () => {
|
|
620
|
-
completeCalls += 1;
|
|
621
|
-
if (completeCalls === 1) {
|
|
622
|
-
return {
|
|
623
|
-
content: "",
|
|
624
|
-
model: "fake-local",
|
|
625
|
-
tool_calls: [{
|
|
626
|
-
id: "call-read",
|
|
627
|
-
type: "function",
|
|
628
|
-
function: { name: "readFile", arguments: JSON.stringify({ path: "README.md" }) },
|
|
629
|
-
}],
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
return { content: "done", model: "fake-local" };
|
|
633
|
-
},
|
|
634
|
-
}),
|
|
635
|
-
executeTool: async () => ({ content: "clean" }),
|
|
636
|
-
},
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local" });
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
test("does not write local background handoff state", async () => {
|
|
643
|
-
const output = new CaptureOutput();
|
|
644
|
-
|
|
645
|
-
const result = await runAgentTurn({
|
|
646
|
-
agentName: "frontend",
|
|
647
|
-
agentKey: "frontend-local",
|
|
648
|
-
serverUrl: "https://nolo.chat",
|
|
649
|
-
message: "inspect repo in background",
|
|
650
|
-
scriptDir: "C:/missing/scripts",
|
|
651
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
652
|
-
output,
|
|
653
|
-
runtimeMode: "local",
|
|
654
|
-
background: true,
|
|
655
|
-
taskRowContext: {
|
|
656
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
657
|
-
},
|
|
658
|
-
localRuntimeAdapter: {
|
|
659
|
-
host: "cli",
|
|
660
|
-
capabilities: ["local-provider", "local-persistence"],
|
|
661
|
-
loadAgentConfig: async (agentRef) => ({
|
|
662
|
-
key: agentRef,
|
|
663
|
-
name: "Frontend",
|
|
664
|
-
prompt: "Fix UI",
|
|
665
|
-
model: "fake-local",
|
|
666
|
-
}),
|
|
667
|
-
loadDialogHistory: async () => [],
|
|
668
|
-
saveTurn: async () => ({ dialogId: "dialog-local-bg" }),
|
|
669
|
-
resolveProvider: async () => ({
|
|
670
|
-
model: "fake-local",
|
|
671
|
-
complete: async () => ({ content: "accepted locally", model: "fake-local" }),
|
|
672
|
-
}),
|
|
673
|
-
executeTool: async () => {
|
|
674
|
-
throw new Error("no tools expected");
|
|
675
|
-
},
|
|
676
|
-
},
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local-bg" });
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
test("auto mode prefers a working local runtime before HTTP", async () => {
|
|
683
|
-
const output = new CaptureOutput();
|
|
684
|
-
const httpCalls: string[] = [];
|
|
685
|
-
|
|
686
|
-
const result = await runAgentTurn({
|
|
687
|
-
agentName: "frontend",
|
|
688
|
-
agentKey: "frontend-local",
|
|
689
|
-
serverUrl: "https://nolo.chat",
|
|
690
|
-
message: "polish notifications",
|
|
691
|
-
scriptDir: "C:/missing/scripts",
|
|
692
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
693
|
-
output,
|
|
694
|
-
runtimeMode: "auto",
|
|
695
|
-
localRuntimeAdapter: {
|
|
696
|
-
host: "cli",
|
|
697
|
-
capabilities: ["leveldb-agent-config", "local-provider"],
|
|
698
|
-
loadAgentConfig: async (agentRef) => ({
|
|
699
|
-
key: agentRef,
|
|
700
|
-
name: "Frontend",
|
|
701
|
-
prompt: "Fix UI",
|
|
702
|
-
model: "fake-local",
|
|
703
|
-
}),
|
|
704
|
-
loadDialogHistory: async () => [],
|
|
705
|
-
saveTurn: async () => ({ dialogId: "dialog-auto-local" }),
|
|
706
|
-
resolveProvider: async () => ({
|
|
707
|
-
model: "fake-local",
|
|
708
|
-
complete: async () => ({ content: "auto local ok", model: "fake-local" }),
|
|
709
|
-
}),
|
|
710
|
-
executeTool: async () => {
|
|
711
|
-
throw new Error("no tools expected");
|
|
712
|
-
},
|
|
713
|
-
},
|
|
714
|
-
fetchImpl: async (url) => {
|
|
715
|
-
httpCalls.push(String(url));
|
|
716
|
-
return Response.json({ content: "server" });
|
|
717
|
-
},
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-auto-local" });
|
|
721
|
-
expect(httpCalls).toEqual([]);
|
|
722
|
-
expect(output.text()).toContain("frontend -> working locally");
|
|
723
|
-
});
|
|
724
|
-
|
|
725
|
-
test("auto mode refreshes missing local agent config and retries local once before HTTP", async () => {
|
|
726
|
-
const output = new CaptureOutput();
|
|
727
|
-
const httpCalls: string[] = [];
|
|
728
|
-
let loadAgentConfigCalls = 0;
|
|
729
|
-
let localCompletions = 0;
|
|
730
|
-
|
|
731
|
-
const result = await runAgentTurn({
|
|
732
|
-
agentName: "frontend",
|
|
733
|
-
agentKey: "frontend-local",
|
|
734
|
-
serverUrl: "https://nolo.chat",
|
|
735
|
-
message: "polish notifications",
|
|
736
|
-
scriptDir: "C:/missing/scripts",
|
|
737
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
738
|
-
output,
|
|
739
|
-
runtimeMode: "auto",
|
|
740
|
-
localRuntimeAdapter: {
|
|
741
|
-
host: "cli",
|
|
742
|
-
capabilities: ["leveldb-agent-config", "local-provider", "leveldb-persistence"],
|
|
743
|
-
loadAgentConfig: async (agentRef) => {
|
|
744
|
-
loadAgentConfigCalls += 1;
|
|
745
|
-
if (loadAgentConfigCalls < 3) return null;
|
|
746
|
-
return {
|
|
747
|
-
key: agentRef,
|
|
748
|
-
name: "Frontend",
|
|
749
|
-
prompt: "Fix UI",
|
|
750
|
-
model: "fake-local",
|
|
751
|
-
};
|
|
752
|
-
},
|
|
753
|
-
loadDialogHistory: async () => [],
|
|
754
|
-
saveTurn: async () => ({ dialogId: "dialog-auto-local-retried" }),
|
|
755
|
-
resolveProvider: async () => ({
|
|
756
|
-
model: "fake-local",
|
|
757
|
-
complete: async () => {
|
|
758
|
-
localCompletions += 1;
|
|
759
|
-
return { content: "auto local after refresh", model: "fake-local" };
|
|
760
|
-
},
|
|
761
|
-
}),
|
|
762
|
-
executeTool: async () => {
|
|
763
|
-
throw new Error("no tools expected");
|
|
764
|
-
},
|
|
765
|
-
},
|
|
766
|
-
fetchImpl: async (url) => {
|
|
767
|
-
httpCalls.push(String(url));
|
|
768
|
-
return Response.json({ content: "server" });
|
|
769
|
-
},
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-auto-local-retried" });
|
|
773
|
-
expect(loadAgentConfigCalls).toBe(4);
|
|
774
|
-
expect(localCompletions).toBe(1);
|
|
775
|
-
expect(httpCalls).toEqual([]);
|
|
776
|
-
expect(output.text()).toContain("refreshing from the configured server and retrying local once");
|
|
777
|
-
expect(output.text().match(/working locally/g)?.length).toBe(2);
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
test("auto mode falls back to HTTP when local agent config is still missing after one refresh retry", async () => {
|
|
781
|
-
const output = new CaptureOutput();
|
|
782
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
783
|
-
let loadAgentConfigCalls = 0;
|
|
784
|
-
|
|
785
|
-
const result = await runAgentTurn({
|
|
786
|
-
agentName: "frontend",
|
|
787
|
-
agentKey: "frontend-local",
|
|
788
|
-
serverUrl: "https://nolo.chat",
|
|
789
|
-
message: "polish notifications",
|
|
790
|
-
scriptDir: "C:/missing/scripts",
|
|
791
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
792
|
-
output,
|
|
793
|
-
runtimeMode: "auto",
|
|
794
|
-
localRuntimeAdapter: {
|
|
795
|
-
host: "cli",
|
|
796
|
-
capabilities: ["leveldb-agent-config", "local-provider", "leveldb-persistence"],
|
|
797
|
-
loadAgentConfig: async () => {
|
|
798
|
-
loadAgentConfigCalls += 1;
|
|
799
|
-
return null;
|
|
800
|
-
},
|
|
801
|
-
loadDialogHistory: async () => [],
|
|
802
|
-
saveTurn: async () => {
|
|
803
|
-
throw new Error("local runtime should not save when config is missing");
|
|
804
|
-
},
|
|
805
|
-
resolveProvider: async () => {
|
|
806
|
-
throw new Error("local provider should not run when config is missing");
|
|
807
|
-
},
|
|
808
|
-
executeTool: async () => {
|
|
809
|
-
throw new Error("no tools expected");
|
|
810
|
-
},
|
|
811
|
-
},
|
|
812
|
-
fetchImpl: async (url, init) => {
|
|
813
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
814
|
-
return Response.json({ content: "server fallback", dialogId: "dialog-server-fallback" });
|
|
815
|
-
},
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server-fallback" });
|
|
819
|
-
expect(loadAgentConfigCalls).toBe(3);
|
|
820
|
-
expect(httpCalls).toHaveLength(1);
|
|
821
|
-
expect(httpCalls[0]?.body.agentKey).toBe("frontend-local");
|
|
822
|
-
expect(output.text()).toContain("refreshing from the configured server and retrying local once");
|
|
823
|
-
expect(output.text()).toContain("frontend -> working");
|
|
824
|
-
expect(output.text()).toContain("frontend > server fallback");
|
|
825
|
-
});
|
|
826
|
-
|
|
827
|
-
test("auto mode skips local runtime for agents that declare server platform tools", async () => {
|
|
828
|
-
const output = new CaptureOutput();
|
|
829
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
830
|
-
|
|
831
|
-
const result = await runAgentTurn({
|
|
832
|
-
agentName: "pm",
|
|
833
|
-
agentKey: "agent-custom-platform-tools",
|
|
834
|
-
serverUrl: "https://nolo.chat",
|
|
835
|
-
message: "write task rows",
|
|
836
|
-
scriptDir: "C:/missing/scripts",
|
|
837
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
838
|
-
output,
|
|
839
|
-
runtimeMode: "auto",
|
|
840
|
-
localRuntimeAdapter: {
|
|
841
|
-
host: "cli",
|
|
842
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
843
|
-
loadAgentConfig: async (agentRef) => ({
|
|
844
|
-
key: agentRef,
|
|
845
|
-
name: "PM",
|
|
846
|
-
prompt: "Manage task rows",
|
|
847
|
-
model: "fake-local",
|
|
848
|
-
toolNames: ["queryTableRows", "addTableRow", "updateTableRow"],
|
|
849
|
-
}),
|
|
850
|
-
loadDialogHistory: async () => [],
|
|
851
|
-
saveTurn: async () => {
|
|
852
|
-
throw new Error("local runtime should be skipped");
|
|
853
|
-
},
|
|
854
|
-
resolveProvider: async () => {
|
|
855
|
-
throw new Error("local provider should be skipped");
|
|
856
|
-
},
|
|
857
|
-
executeTool: async () => {
|
|
858
|
-
throw new Error("local tools should be skipped");
|
|
859
|
-
},
|
|
860
|
-
},
|
|
861
|
-
fetchImpl: async (url, init) => {
|
|
862
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
863
|
-
return Response.json({ content: "server ok", dialogId: "dialog-server" });
|
|
864
|
-
},
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server" });
|
|
868
|
-
expect(httpCalls).toHaveLength(1);
|
|
869
|
-
expect(httpCalls[0]?.body.agentKey).toBe("agent-custom-platform-tools");
|
|
870
|
-
expect(output.text()).toContain("auto runtime: skipping local runtime");
|
|
871
|
-
expect(output.text()).toContain("queryTableRows, addTableRow, updateTableRow");
|
|
872
|
-
expect(output.text()).toContain("pm -> working");
|
|
873
|
-
expect(output.text()).toContain("pm > server ok");
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
test("auto mode keeps local runtime for CLI provider agents even when they declare platform tools", async () => {
|
|
877
|
-
const output = new CaptureOutput();
|
|
878
|
-
const httpCalls: string[] = [];
|
|
879
|
-
let providerCalled = false;
|
|
880
|
-
|
|
881
|
-
const result = await runAgentTurn({
|
|
882
|
-
agentName: "frontend-implementer",
|
|
883
|
-
agentKey: "frontend-implementer",
|
|
884
|
-
serverUrl: "https://nolo.chat",
|
|
885
|
-
message: "polish notifications",
|
|
886
|
-
scriptDir: "C:/missing/scripts",
|
|
887
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
888
|
-
output,
|
|
889
|
-
runtimeMode: "auto",
|
|
890
|
-
localRuntimeAdapter: {
|
|
891
|
-
host: "cli",
|
|
892
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
893
|
-
loadAgentConfig: async (agentRef) => ({
|
|
894
|
-
key: agentRef,
|
|
895
|
-
name: "AGY",
|
|
896
|
-
prompt: "Implement frontend tasks.",
|
|
897
|
-
provider: "agy",
|
|
898
|
-
cliProvider: "agy",
|
|
899
|
-
toolNames: ["streamParallelAgents", "queryTableRows"],
|
|
900
|
-
}),
|
|
901
|
-
loadDialogHistory: async () => [],
|
|
902
|
-
saveTurn: async () => ({ dialogId: "dialog-agy-auto-local" }),
|
|
903
|
-
resolveProvider: async () => ({
|
|
904
|
-
model: "agy",
|
|
905
|
-
complete: async () => {
|
|
906
|
-
providerCalled = true;
|
|
907
|
-
return { content: "agy local ok", model: "agy" };
|
|
908
|
-
},
|
|
909
|
-
}),
|
|
910
|
-
executeTool: async () => {
|
|
911
|
-
throw new Error("no tools expected");
|
|
912
|
-
},
|
|
913
|
-
},
|
|
914
|
-
fetchImpl: async (url) => {
|
|
915
|
-
httpCalls.push(String(url));
|
|
916
|
-
return Response.json({ content: "server" });
|
|
917
|
-
},
|
|
918
|
-
});
|
|
919
|
-
|
|
920
|
-
expect(providerCalled).toBe(true);
|
|
921
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-agy-auto-local" });
|
|
922
|
-
expect(httpCalls).toEqual([]);
|
|
923
|
-
expect(output.text()).not.toContain("skipping local runtime");
|
|
924
|
-
expect(output.text()).toContain("frontend-implementer -> working locally");
|
|
925
|
-
expect(output.text()).toContain("frontend-implementer > agy local ok");
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
test("auto mode does not skip monthly Mimo when a local shell cwd is already bound", async () => {
|
|
929
|
-
const output = new CaptureOutput();
|
|
930
|
-
const httpCalls: string[] = [];
|
|
931
|
-
let providerCalled = false;
|
|
932
|
-
|
|
933
|
-
const result = await runAgentTurn({
|
|
934
|
-
agentName: TEST_MONTHLY_MIMO_AGENT_KEY,
|
|
935
|
-
agentKey: TEST_MONTHLY_MIMO_AGENT_KEY,
|
|
936
|
-
serverUrl: "https://us.nolo.chat",
|
|
937
|
-
message: "fix tests and commit",
|
|
938
|
-
scriptDir: "C:/missing/scripts",
|
|
939
|
-
env: {
|
|
940
|
-
AUTH_TOKEN: "token-123",
|
|
941
|
-
},
|
|
942
|
-
output,
|
|
943
|
-
runtimeMode: "auto",
|
|
944
|
-
localRuntimeCwd: "/repo/.worktrees/nolo-agent-mimo",
|
|
945
|
-
localRuntimeAdapter: {
|
|
946
|
-
host: "cli",
|
|
947
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
948
|
-
loadAgentConfig: async (agentRef) => ({
|
|
949
|
-
key: agentRef,
|
|
950
|
-
name: "包月 Mimo",
|
|
951
|
-
prompt: "Implement backend tasks.",
|
|
952
|
-
provider: "custom",
|
|
953
|
-
model: "mimo-v2.5-pro",
|
|
954
|
-
toolNames: ["queryTableRows"],
|
|
955
|
-
}),
|
|
956
|
-
loadDialogHistory: async () => [],
|
|
957
|
-
saveTurn: async () => ({ dialogId: "dialog-mimo-local" }),
|
|
958
|
-
resolveProvider: async () => ({
|
|
959
|
-
model: "mimo-v2.5-pro",
|
|
960
|
-
complete: async () => {
|
|
961
|
-
providerCalled = true;
|
|
962
|
-
return { content: "local mimo ok", model: "mimo-v2.5-pro" };
|
|
963
|
-
},
|
|
964
|
-
}),
|
|
965
|
-
executeTool: async () => ({ content: "ok" }),
|
|
966
|
-
},
|
|
967
|
-
fetchImpl: async (url) => {
|
|
968
|
-
httpCalls.push(String(url));
|
|
969
|
-
return Response.json({ content: "server" });
|
|
970
|
-
},
|
|
971
|
-
});
|
|
972
|
-
|
|
973
|
-
expect(providerCalled).toBe(true);
|
|
974
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-mimo-local" });
|
|
975
|
-
expect(httpCalls).toEqual([]);
|
|
976
|
-
expect(output.text()).not.toContain("skipping local runtime");
|
|
977
|
-
expect(output.text()).toContain(`${TEST_MONTHLY_MIMO_AGENT_KEY} -> working locally`);
|
|
978
|
-
});
|
|
979
|
-
|
|
980
|
-
test("auto mode skips local runtime for machine-bound localhost custom providers", async () => {
|
|
981
|
-
const output = new CaptureOutput();
|
|
982
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
983
|
-
|
|
984
|
-
const result = await runAgentTurn({
|
|
985
|
-
agentName: "win-qwen",
|
|
986
|
-
agentKey: "agent-win-qwen",
|
|
987
|
-
serverUrl: "https://nolo.chat",
|
|
988
|
-
message: "run on the bound Windows machine",
|
|
989
|
-
scriptDir: "C:/missing/scripts",
|
|
990
|
-
env: { AUTH_TOKEN: "token-123", OPENAI_API_KEY: "local-provider-present" },
|
|
991
|
-
output,
|
|
992
|
-
runtimeMode: "auto",
|
|
993
|
-
localRuntimeAdapter: {
|
|
994
|
-
host: "cli",
|
|
995
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
996
|
-
loadAgentConfig: async (agentRef) => ({
|
|
997
|
-
key: agentRef,
|
|
998
|
-
name: "Win Qwen",
|
|
999
|
-
prompt: "Windows local model",
|
|
1000
|
-
provider: "custom",
|
|
1001
|
-
model: "qwen",
|
|
1002
|
-
customProviderUrl: "http://127.0.0.1:8080/v1/chat/completions",
|
|
1003
|
-
runtimeBinding: {
|
|
1004
|
-
machineId: "machine-win",
|
|
1005
|
-
ownerUserId: "user-1",
|
|
1006
|
-
connectorSurface: "cli",
|
|
1007
|
-
},
|
|
1008
|
-
}),
|
|
1009
|
-
loadDialogHistory: async () => [],
|
|
1010
|
-
saveTurn: async () => {
|
|
1011
|
-
throw new Error("local runtime should be skipped");
|
|
1012
|
-
},
|
|
1013
|
-
resolveProvider: async () => {
|
|
1014
|
-
throw new Error("local provider should be skipped");
|
|
1015
|
-
},
|
|
1016
|
-
executeTool: async () => {
|
|
1017
|
-
throw new Error("local tools should be skipped");
|
|
1018
|
-
},
|
|
1019
|
-
},
|
|
1020
|
-
fetchImpl: async (url, init) => {
|
|
1021
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
1022
|
-
return Response.json({ content: "server connector ok", dialogId: "dialog-win" });
|
|
1023
|
-
},
|
|
1024
|
-
});
|
|
1025
|
-
|
|
1026
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-win" });
|
|
1027
|
-
expect(httpCalls).toHaveLength(1);
|
|
1028
|
-
expect(httpCalls[0]?.body.agentKey).toBe("agent-win-qwen");
|
|
1029
|
-
expect(output.text()).toContain("auto runtime: skipping local runtime");
|
|
1030
|
-
expect(output.text()).toContain("machine-bound localhost custom provider");
|
|
1031
|
-
expect(output.text()).not.toContain("win-qwen -> working locally");
|
|
1032
|
-
});
|
|
1033
|
-
|
|
1034
|
-
test("auto mode keeps builtin nolo on local runtime so CLI workspace tools are available", async () => {
|
|
1035
|
-
const output = new CaptureOutput();
|
|
1036
|
-
const httpCalls: string[] = [];
|
|
1037
|
-
let providerCalled = false;
|
|
1038
|
-
|
|
1039
|
-
const result = await runAgentTurn({
|
|
1040
|
-
agentName: "nolo",
|
|
1041
|
-
agentKey: BUILTIN_NOLO_AGENT_KEY,
|
|
1042
|
-
serverUrl: "https://nolo.chat",
|
|
1043
|
-
message: "帮我总结最近 10 个对话",
|
|
1044
|
-
scriptDir: "C:/missing/scripts",
|
|
1045
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1046
|
-
output,
|
|
1047
|
-
runtimeMode: "auto",
|
|
1048
|
-
localRuntimeAdapter: {
|
|
1049
|
-
host: "cli",
|
|
1050
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
1051
|
-
loadAgentConfig: async () => ({
|
|
1052
|
-
key: BUILTIN_NOLO_AGENT_KEY,
|
|
1053
|
-
name: "nolo",
|
|
1054
|
-
prompt: "Use workspace tools.",
|
|
1055
|
-
model: "fake-local",
|
|
1056
|
-
toolNames: ["queryTableRows", "addTableRow", "updateTableRow"],
|
|
1057
|
-
}),
|
|
1058
|
-
loadDialogHistory: async () => [],
|
|
1059
|
-
saveTurn: async () => ({ dialogId: "dialog-builtin-nolo-local" }),
|
|
1060
|
-
resolveProvider: async () => ({
|
|
1061
|
-
model: "fake-local",
|
|
1062
|
-
complete: async () => {
|
|
1063
|
-
providerCalled = true;
|
|
1064
|
-
return { content: "local nolo with tools", model: "fake-local" };
|
|
1065
|
-
},
|
|
1066
|
-
}),
|
|
1067
|
-
executeTool: async () => ({ content: "[]" }),
|
|
1068
|
-
},
|
|
1069
|
-
fetchImpl: async (url) => {
|
|
1070
|
-
httpCalls.push(String(url));
|
|
1071
|
-
return Response.json({ content: "server" });
|
|
1072
|
-
},
|
|
1073
|
-
});
|
|
1074
|
-
|
|
1075
|
-
expect(providerCalled).toBe(true);
|
|
1076
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-builtin-nolo-local" });
|
|
1077
|
-
expect(httpCalls).toEqual([]);
|
|
1078
|
-
expect(output.text()).not.toContain("skipping local runtime");
|
|
1079
|
-
expect(output.text()).toContain("nolo -> working locally");
|
|
1080
|
-
});
|
|
1081
|
-
|
|
1082
|
-
test("auto mode skips local runtime for server platform tools declared by runtime policy", async () => {
|
|
1083
|
-
const output = new CaptureOutput();
|
|
1084
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
1085
|
-
|
|
1086
|
-
const result = await runAgentTurn({
|
|
1087
|
-
agentName: "pm",
|
|
1088
|
-
agentKey: "agent-policy-platform-tools",
|
|
1089
|
-
serverUrl: "https://nolo.chat",
|
|
1090
|
-
message: "query task rows",
|
|
1091
|
-
scriptDir: "C:/missing/scripts",
|
|
1092
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1093
|
-
output,
|
|
1094
|
-
runtimeMode: "auto",
|
|
1095
|
-
localRuntimeAdapter: {
|
|
1096
|
-
host: "cli",
|
|
1097
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
1098
|
-
loadAgentConfig: async (agentRef) => ({
|
|
1099
|
-
key: agentRef,
|
|
1100
|
-
name: "PM",
|
|
1101
|
-
prompt: "Manage task rows",
|
|
1102
|
-
model: "fake-local",
|
|
1103
|
-
runtimeToolPolicy: {
|
|
1104
|
-
version: 1,
|
|
1105
|
-
agentTools: ["queryTableRows", "streamParallelAgents"],
|
|
1106
|
-
runtimeTools: ["execShell"],
|
|
1107
|
-
},
|
|
1108
|
-
}),
|
|
1109
|
-
loadDialogHistory: async () => [],
|
|
1110
|
-
saveTurn: async () => {
|
|
1111
|
-
throw new Error("local runtime should be skipped");
|
|
1112
|
-
},
|
|
1113
|
-
resolveProvider: async () => {
|
|
1114
|
-
throw new Error("local provider should be skipped");
|
|
1115
|
-
},
|
|
1116
|
-
executeTool: async () => {
|
|
1117
|
-
throw new Error("local tools should be skipped");
|
|
1118
|
-
},
|
|
1119
|
-
},
|
|
1120
|
-
fetchImpl: async (url, init) => {
|
|
1121
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
1122
|
-
return Response.json({ content: "server ok", dialogId: "dialog-server-policy" });
|
|
1123
|
-
},
|
|
1124
|
-
});
|
|
1125
|
-
|
|
1126
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server-policy" });
|
|
1127
|
-
expect(httpCalls).toHaveLength(1);
|
|
1128
|
-
expect(httpCalls[0]?.body.agentKey).toBe("agent-policy-platform-tools");
|
|
1129
|
-
expect(output.text()).toContain("auto runtime: skipping local runtime");
|
|
1130
|
-
expect(output.text()).toContain("queryTableRows, streamParallelAgents");
|
|
1131
|
-
});
|
|
1132
|
-
|
|
1133
|
-
test("auto mode falls back to server when local config cannot be read", async () => {
|
|
1134
|
-
const output = new CaptureOutput();
|
|
1135
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
1136
|
-
|
|
1137
|
-
const result = await runAgentTurn({
|
|
1138
|
-
agentName: "project-manager",
|
|
1139
|
-
agentKey: TEST_PROJECT_MANAGER_AGENT_KEY,
|
|
1140
|
-
serverUrl: "https://us.nolo.chat",
|
|
1141
|
-
message: "write task rows",
|
|
1142
|
-
scriptDir: "C:/missing/scripts",
|
|
1143
|
-
env: { AUTH_TOKEN: "token-123", OPENAI_API_KEY: "local-provider-present" },
|
|
1144
|
-
output,
|
|
1145
|
-
runtimeMode: "auto",
|
|
1146
|
-
localRuntimeAdapter: {
|
|
1147
|
-
host: "cli",
|
|
1148
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
1149
|
-
loadAgentConfig: async () => {
|
|
1150
|
-
throw new Error("Database failed to open: LOCK");
|
|
1151
|
-
},
|
|
1152
|
-
loadDialogHistory: async () => {
|
|
1153
|
-
throw new Error("local runtime should be skipped");
|
|
1154
|
-
},
|
|
1155
|
-
saveTurn: async () => {
|
|
1156
|
-
throw new Error("local runtime should be skipped");
|
|
1157
|
-
},
|
|
1158
|
-
resolveProvider: async () => {
|
|
1159
|
-
throw new Error("local provider should be skipped");
|
|
1160
|
-
},
|
|
1161
|
-
executeTool: async () => {
|
|
1162
|
-
throw new Error("local tools should be skipped");
|
|
1163
|
-
},
|
|
1164
|
-
},
|
|
1165
|
-
fetchImpl: async (url, init) => {
|
|
1166
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
1167
|
-
return Response.json({ content: "server ok", dialogId: "dialog-server" });
|
|
1168
|
-
},
|
|
1169
|
-
});
|
|
1170
|
-
|
|
1171
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server" });
|
|
1172
|
-
expect(httpCalls).toHaveLength(1);
|
|
1173
|
-
expect(httpCalls[0]?.body.agentKey).toBe(TEST_PROJECT_MANAGER_AGENT_KEY);
|
|
1174
|
-
expect(output.text()).not.toContain("known platform agent");
|
|
1175
|
-
expect(output.text()).toContain("project-manager -> working");
|
|
1176
|
-
expect(output.text()).toContain("project-manager > server ok");
|
|
1177
|
-
});
|
|
1178
|
-
|
|
1179
|
-
test("builds the default local adapter when env requests local mode", async () => {
|
|
1180
|
-
const output = new CaptureOutput();
|
|
1181
|
-
const builtModes: string[] = [];
|
|
1182
|
-
|
|
1183
|
-
const result = await runAgentTurn({
|
|
1184
|
-
agentName: "frontend",
|
|
1185
|
-
agentKey: "frontend-local",
|
|
1186
|
-
serverUrl: "https://nolo.chat",
|
|
1187
|
-
message: "polish notifications",
|
|
1188
|
-
scriptDir: "C:/missing/scripts",
|
|
1189
|
-
env: { NOLO_RUNTIME_MODE: "local" },
|
|
1190
|
-
output,
|
|
1191
|
-
localRuntimeAdapterFactory: (env) => {
|
|
1192
|
-
builtModes.push(env.NOLO_RUNTIME_MODE ?? "");
|
|
1193
|
-
return {
|
|
1194
|
-
host: "cli",
|
|
1195
|
-
capabilities: ["local-provider", "local-persistence"],
|
|
1196
|
-
loadAgentConfig: async (agentRef) => ({ key: agentRef, prompt: "Fix UI" }),
|
|
1197
|
-
loadDialogHistory: async () => [],
|
|
1198
|
-
saveTurn: async () => ({ dialogId: "dialog-local-env" }),
|
|
1199
|
-
resolveProvider: async () => ({
|
|
1200
|
-
model: "fake-local",
|
|
1201
|
-
complete: async () => ({ content: "local env ok", model: "fake-local" }),
|
|
1202
|
-
}),
|
|
1203
|
-
executeTool: async () => {
|
|
1204
|
-
throw new Error("no tools expected");
|
|
1205
|
-
},
|
|
1206
|
-
};
|
|
1207
|
-
},
|
|
1208
|
-
fetchImpl: async () => {
|
|
1209
|
-
throw new Error("HTTP should not be called for env local runs");
|
|
1210
|
-
},
|
|
1211
|
-
});
|
|
1212
|
-
|
|
1213
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local-env" });
|
|
1214
|
-
expect(builtModes).toEqual(["local"]);
|
|
1215
|
-
expect(output.text()).toContain("frontend -> working locally");
|
|
1216
|
-
});
|
|
1217
|
-
|
|
1218
|
-
test("streams agent text responses to terminal output", async () => {
|
|
1219
|
-
const output = new CaptureOutput();
|
|
1220
|
-
|
|
1221
|
-
const result = await runAgentTurn({
|
|
1222
|
-
agentName: "nolo",
|
|
1223
|
-
agentKey: "agent-pub-test",
|
|
1224
|
-
serverUrl: "https://nolo.chat",
|
|
1225
|
-
message: "hello",
|
|
1226
|
-
scriptDir: "C:/missing/scripts",
|
|
1227
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1228
|
-
output,
|
|
1229
|
-
fetchImpl: async () =>
|
|
1230
|
-
new Response(
|
|
1231
|
-
[
|
|
1232
|
-
`data: ${JSON.stringify({ type: "text", content: "你" })}`,
|
|
1233
|
-
"",
|
|
1234
|
-
`data: ${JSON.stringify({ type: "text", content: "好" })}`,
|
|
1235
|
-
"",
|
|
1236
|
-
`data: ${JSON.stringify({ type: "done", dialogId: "dialog-stream" })}`,
|
|
1237
|
-
"",
|
|
1238
|
-
].join("\n"),
|
|
1239
|
-
{
|
|
1240
|
-
status: 200,
|
|
1241
|
-
headers: { "Content-Type": "text/event-stream" },
|
|
1242
|
-
}
|
|
1243
|
-
),
|
|
1244
|
-
});
|
|
1245
|
-
|
|
1246
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-stream" });
|
|
1247
|
-
expect(output.text()).toContain("nolo -> working");
|
|
1248
|
-
expect(output.text()).toContain("nolo > 你好");
|
|
1249
|
-
});
|
|
1250
|
-
|
|
1251
|
-
test("returns a recoverable dialog when a server stream drops after dialog creation", async () => {
|
|
1252
|
-
const output = new CaptureOutput();
|
|
1253
|
-
|
|
1254
|
-
const result = await runAgentTurn({
|
|
1255
|
-
agentName: "nolo",
|
|
1256
|
-
agentKey: "agent-pub-test",
|
|
1257
|
-
serverUrl: "https://nolo.chat",
|
|
1258
|
-
message: "hello",
|
|
1259
|
-
scriptDir: "C:/missing/scripts",
|
|
1260
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1261
|
-
output,
|
|
1262
|
-
fetchImpl: async () => {
|
|
1263
|
-
let sent = false;
|
|
1264
|
-
return new Response(
|
|
1265
|
-
new ReadableStream({
|
|
1266
|
-
pull(controller) {
|
|
1267
|
-
const encoder = new TextEncoder();
|
|
1268
|
-
if (!sent) {
|
|
1269
|
-
sent = true;
|
|
1270
|
-
controller.enqueue(
|
|
1271
|
-
encoder.encode(
|
|
1272
|
-
[
|
|
1273
|
-
`data: ${JSON.stringify({
|
|
1274
|
-
type: "dialog",
|
|
1275
|
-
dialogId: "dialog-recoverable",
|
|
1276
|
-
status: "running",
|
|
1277
|
-
})}`,
|
|
1278
|
-
"",
|
|
1279
|
-
`data: ${JSON.stringify({ type: "text", content: "partial" })}`,
|
|
1280
|
-
"",
|
|
1281
|
-
].join("\n")
|
|
1282
|
-
)
|
|
1283
|
-
);
|
|
1284
|
-
return;
|
|
1285
|
-
}
|
|
1286
|
-
controller.error(new Error("socket closed"));
|
|
1287
|
-
},
|
|
1288
|
-
}),
|
|
1289
|
-
{
|
|
1290
|
-
status: 200,
|
|
1291
|
-
headers: { "Content-Type": "text/event-stream" },
|
|
1292
|
-
}
|
|
1293
|
-
);
|
|
1294
|
-
},
|
|
1295
|
-
});
|
|
1296
|
-
|
|
1297
|
-
expect(result).toEqual({
|
|
1298
|
-
exitCode: 0,
|
|
1299
|
-
dialogId: "dialog-recoverable",
|
|
1300
|
-
streamInterrupted: true,
|
|
1301
|
-
});
|
|
1302
|
-
expect(output.text()).toContain("dialog dialog-recoverable was created");
|
|
1303
|
-
expect(output.text()).toContain("read the dialog before retrying");
|
|
1304
|
-
});
|
|
1305
|
-
|
|
1306
|
-
test("prints an auth hint when installed without repo scripts or AUTH_TOKEN", async () => {
|
|
1307
|
-
const output = new CaptureOutput();
|
|
1308
|
-
|
|
1309
|
-
const result = await runAgentTurn({
|
|
1310
|
-
agentName: "nolo",
|
|
1311
|
-
agentKey: "agent-pub-test",
|
|
1312
|
-
serverUrl: "https://nolo.chat",
|
|
1313
|
-
message: "hello",
|
|
1314
|
-
scriptDir: "C:/missing/scripts",
|
|
1315
|
-
env: {},
|
|
1316
|
-
output,
|
|
1317
|
-
fetchImpl: async () => {
|
|
1318
|
-
throw new Error("fetch should not be called");
|
|
1319
|
-
},
|
|
1320
|
-
});
|
|
1321
|
-
|
|
1322
|
-
expect(result.exitCode).toBe(1);
|
|
1323
|
-
expect(output.text()).toContain("Run `nolo login`");
|
|
1324
|
-
});
|
|
1325
|
-
|
|
1326
|
-
test("prints a friendly connection hint instead of crashing on transport errors", async () => {
|
|
1327
|
-
const output = new CaptureOutput();
|
|
1328
|
-
|
|
1329
|
-
const result = await runAgentTurn({
|
|
1330
|
-
agentName: "nolo",
|
|
1331
|
-
agentKey: "agent-pub-test",
|
|
1332
|
-
serverUrl: "http://127.0.0.1:38123",
|
|
1333
|
-
message: "hello",
|
|
1334
|
-
scriptDir: "C:/missing/scripts",
|
|
1335
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1336
|
-
output,
|
|
1337
|
-
fetchImpl: async () => {
|
|
1338
|
-
throw new Error("ConnectionRefused");
|
|
1339
|
-
},
|
|
1340
|
-
});
|
|
1341
|
-
|
|
1342
|
-
expect(result).toEqual({ exitCode: 1 });
|
|
1343
|
-
expect(output.text()).toContain("Could not reach http://127.0.0.1:38123/api/agent/run");
|
|
1344
|
-
expect(output.text()).toContain("set NOLO_SERVER");
|
|
1345
|
-
});
|
|
1346
|
-
});
|