nolo-cli 0.1.44 → 0.1.46
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 +258 -102
- package/index.js +73433 -0
- package/package.json +10 -633
- 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 -110
- package/agentCommandSupport.ts +0 -81
- package/agentInternalCommandEntries.ts +0 -44
- package/agentListCommands.ts +0 -185
- package/agentListHelpers.ts +0 -242
- package/agentMachineCommands.ts +0 -403
- package/agentPullCommand.ts +0 -142
- package/agentRecordCommands.ts +0 -226
- package/agentRecordHelpers.ts +0 -571
- package/agentRunCommand.ts +0 -556
- 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 -110
- 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 -403
- package/cli/agentPullCommand.ts +0 -142
- package/cli/agentRecordCommands.ts +0 -226
- package/cli/agentRecordHelpers.ts +0 -571
- package/cli/agentRunCommand.ts +0 -556
- 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 -795
- 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 -1104
- 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 -307
- 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 -316
- 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 -1344
- package/client/agentRun.ts +0 -795
- 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 -2804
- package/client/localRuntimeAdapter.ts +0 -1104
- 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 -307
- 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 -316
- 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,1344 +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
|
-
import { MIMO_MONTH_AGENT_KEY, NOLO_PROJECT_MANAGER_AGENT_KEY } from "../agentAliases";
|
|
11
|
-
|
|
12
|
-
class CaptureOutput extends Writable {
|
|
13
|
-
chunks: string[] = [];
|
|
14
|
-
|
|
15
|
-
_write(chunk: unknown, _encoding: BufferEncoding, callback: (error?: Error | null) => void) {
|
|
16
|
-
this.chunks.push(String(chunk));
|
|
17
|
-
callback();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
text() {
|
|
21
|
-
return this.chunks.join("");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe("cli agent run client", () => {
|
|
26
|
-
test("classifies only clear reviewer outcomes", () => {
|
|
27
|
-
expect(classifyTaskContextReviewStatus("Review decision: passed")).toBe("passed");
|
|
28
|
-
expect(classifyTaskContextReviewStatus("Review decision: needs_changes")).toBe("needs_changes");
|
|
29
|
-
expect(classifyTaskContextReviewStatus("Review decision: blocked")).toBe("blocked");
|
|
30
|
-
expect(classifyTaskContextReviewStatus("LGTM, no issues found")).toBe("passed");
|
|
31
|
-
expect(classifyTaskContextReviewStatus("Changes requested for missing test coverage")).toBe(
|
|
32
|
-
"needs_changes"
|
|
33
|
-
);
|
|
34
|
-
expect(classifyTaskContextReviewStatus("I looked at the diff and have notes")).toBeUndefined();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("identifies server platform tools that local runtime cannot provide", () => {
|
|
38
|
-
expect(findServerPlatformTools(["readFile", "queryTableRows", "updateTableRow"])).toEqual([
|
|
39
|
-
"queryTableRows",
|
|
40
|
-
"updateTableRow",
|
|
41
|
-
]);
|
|
42
|
-
expect(findServerPlatformTools(["readFile", "execShell"])).toEqual([]);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("calls the Nolo HTTP API directly when AUTH_TOKEN is present", async () => {
|
|
46
|
-
const output = new CaptureOutput();
|
|
47
|
-
const requests: Array<{ url: string; body: any; auth: string | null }> = [];
|
|
48
|
-
|
|
49
|
-
const result = await runAgentTurn({
|
|
50
|
-
agentName: "nolo",
|
|
51
|
-
agentKey: "agent-pub-test",
|
|
52
|
-
serverUrl: "https://nolo.chat",
|
|
53
|
-
message: "hello",
|
|
54
|
-
continueDialogId: "dialog-existing",
|
|
55
|
-
scriptDir: "C:/missing/scripts",
|
|
56
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
57
|
-
output,
|
|
58
|
-
fetchImpl: async (url, init) => {
|
|
59
|
-
requests.push({
|
|
60
|
-
url: String(url),
|
|
61
|
-
body: JSON.parse(String(init?.body)),
|
|
62
|
-
auth: new Headers(init?.headers).get("Authorization"),
|
|
63
|
-
});
|
|
64
|
-
return Response.json({
|
|
65
|
-
content: "hi",
|
|
66
|
-
dialogId: "dialog-1",
|
|
67
|
-
usage: { input_tokens: 2, output_tokens: 3 },
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
expect(requests).toEqual([
|
|
73
|
-
{
|
|
74
|
-
url: "https://nolo.chat/api/agent/run",
|
|
75
|
-
auth: "Bearer token-123",
|
|
76
|
-
body: {
|
|
77
|
-
agentKey: "agent-pub-test",
|
|
78
|
-
userInput: "hello",
|
|
79
|
-
continueDialogId: "dialog-existing",
|
|
80
|
-
runtimeContext: {
|
|
81
|
-
surface: "cli",
|
|
82
|
-
host: "terminal",
|
|
83
|
-
runtime: "bun",
|
|
84
|
-
entrypoint: "nolo-cli",
|
|
85
|
-
capabilities: ["text-io", "streaming", "slash-commands"],
|
|
86
|
-
},
|
|
87
|
-
stream: true,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
]);
|
|
91
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-1" });
|
|
92
|
-
expect(output.text()).toContain("nolo -> working");
|
|
93
|
-
expect(output.text()).toContain("nolo > hi");
|
|
94
|
-
expect(output.text()).not.toContain("tokens=");
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test("prints agent run error details from failed HTTP responses", async () => {
|
|
98
|
-
const output = new CaptureOutput();
|
|
99
|
-
|
|
100
|
-
const result = await runAgentTurn({
|
|
101
|
-
agentName: "win-codex",
|
|
102
|
-
agentKey: "agent-win-codex",
|
|
103
|
-
serverUrl: "https://nolo.chat",
|
|
104
|
-
message: "restart connector",
|
|
105
|
-
scriptDir: "C:/missing/scripts",
|
|
106
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
107
|
-
output,
|
|
108
|
-
fetchImpl: async () =>
|
|
109
|
-
Response.json({
|
|
110
|
-
error: "Connector execution failed",
|
|
111
|
-
reason: "connector_execution_failed",
|
|
112
|
-
code: "connector_disconnected_mid_run",
|
|
113
|
-
message: "Connector disconnected for machine: machine-win",
|
|
114
|
-
dialogId: "dialog-failed-1",
|
|
115
|
-
}, { status: 502 }),
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
expect(result).toEqual({ exitCode: 1, dialogId: "dialog-failed-1" });
|
|
119
|
-
expect(output.text()).toContain("[nolo] Agent request failed: HTTP 502");
|
|
120
|
-
expect(output.text()).toContain("Connector execution failed");
|
|
121
|
-
expect(output.text()).toContain("Connector disconnected for machine: machine-win");
|
|
122
|
-
expect(output.text()).toContain("code=connector_disconnected_mid_run");
|
|
123
|
-
expect(output.text()).toContain("reason=connector_execution_failed");
|
|
124
|
-
expect(output.text()).toContain("[nolo] failed dialog: dialog-failed-1");
|
|
125
|
-
expect(output.text()).toContain(
|
|
126
|
-
'nolo agent run agent-win-codex --continue dialog-failed-1 --msg "retry"'
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test("converts task row context to subjectRefs without legacy prompt or runtime taskRun payload", async () => {
|
|
131
|
-
const output = new CaptureOutput();
|
|
132
|
-
const requests: Array<{ body: any }> = [];
|
|
133
|
-
|
|
134
|
-
await runAgentTurn({
|
|
135
|
-
agentName: "frontend",
|
|
136
|
-
agentKey: "frontend-implementer",
|
|
137
|
-
serverUrl: "https://nolo.chat",
|
|
138
|
-
message: "Fix the filter UI",
|
|
139
|
-
scriptDir: "C:/missing/scripts",
|
|
140
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
141
|
-
output,
|
|
142
|
-
runtimeMode: "server",
|
|
143
|
-
taskRowContext: {
|
|
144
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
145
|
-
artifactIds: ["artifact-1"],
|
|
146
|
-
},
|
|
147
|
-
fetchImpl: async (_url, init) => {
|
|
148
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
149
|
-
return Response.json({ content: "ok", dialogId: "dialog-1" });
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
expect(requests[0]?.body.userInput).toBe("Fix the filter UI");
|
|
154
|
-
expect(requests[0]?.body.runtimeContext.taskRun).toBeUndefined();
|
|
155
|
-
expect(requests[0]?.body.runtimeContext.subjectRefs).toContainEqual({
|
|
156
|
-
kind: "table-row",
|
|
157
|
-
id: "row-b2e06f801f-01TASK",
|
|
158
|
-
role: "task",
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
test("does not write task-context completion after an HTTP agent run returns a dialog", async () => {
|
|
163
|
-
const output = new CaptureOutput();
|
|
164
|
-
|
|
165
|
-
const result = await runAgentTurn({
|
|
166
|
-
agentName: "frontend-implementer",
|
|
167
|
-
agentKey: "agent-frontend",
|
|
168
|
-
serverUrl: "https://nolo.chat",
|
|
169
|
-
message: "Fix the filter UI",
|
|
170
|
-
scriptDir: "C:/missing/scripts",
|
|
171
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
172
|
-
output,
|
|
173
|
-
runtimeMode: "server",
|
|
174
|
-
taskRowContext: {
|
|
175
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
176
|
-
},
|
|
177
|
-
fetchImpl: async () => {
|
|
178
|
-
return Response.json({ content: "patched", dialogId: "dialog-1" });
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-1" });
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test("sends image inputs as multimodal userInput over HTTP", async () => {
|
|
186
|
-
const output = new CaptureOutput();
|
|
187
|
-
const requests: Array<{ body: any }> = [];
|
|
188
|
-
|
|
189
|
-
await runAgentTurn({
|
|
190
|
-
agentName: "vision",
|
|
191
|
-
agentKey: "agent-pub-vision",
|
|
192
|
-
serverUrl: "https://nolo.chat",
|
|
193
|
-
message: "describe this",
|
|
194
|
-
imageUrls: ["https://example.com/a.png"],
|
|
195
|
-
scriptDir: "C:/missing/scripts",
|
|
196
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
197
|
-
output,
|
|
198
|
-
runtimeMode: "server",
|
|
199
|
-
fetchImpl: async (_url, init) => {
|
|
200
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
201
|
-
return Response.json({ content: "ok" });
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
expect(requests[0]?.body.userInput).toEqual([
|
|
206
|
-
{ type: "text", text: "describe this" },
|
|
207
|
-
{ type: "image_url", image_url: { url: "https://example.com/a.png" } },
|
|
208
|
-
]);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
test("sends CLI dialog metadata over HTTP", async () => {
|
|
212
|
-
const output = new CaptureOutput();
|
|
213
|
-
const requests: Array<{ body: any }> = [];
|
|
214
|
-
|
|
215
|
-
const result = await runAgentTurn({
|
|
216
|
-
agentName: "nolo",
|
|
217
|
-
agentKey: "agent-pub-test",
|
|
218
|
-
serverUrl: "https://nolo.chat",
|
|
219
|
-
message: "hello",
|
|
220
|
-
spaceId: "space-1",
|
|
221
|
-
category: "manual-checks",
|
|
222
|
-
inheritedFromDialogKey: "dialog-user-1-dialog-2",
|
|
223
|
-
parentDialogId: "dialog-2",
|
|
224
|
-
subjectDialogKey: "01SUBJECTDIALOG",
|
|
225
|
-
background: true,
|
|
226
|
-
noStream: true,
|
|
227
|
-
timeoutMs: 600000,
|
|
228
|
-
scriptDir: "C:/missing/scripts",
|
|
229
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
230
|
-
output,
|
|
231
|
-
runtimeMode: "server",
|
|
232
|
-
fetchImpl: async (_url, init) => {
|
|
233
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
234
|
-
return Response.json({ dialogId: "dialog-1", status: "queued" });
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
expect(requests[0]?.body).toMatchObject({
|
|
239
|
-
agentKey: "agent-pub-test",
|
|
240
|
-
userInput: "hello",
|
|
241
|
-
spaceId: "space-1",
|
|
242
|
-
category: "manual-checks",
|
|
243
|
-
inheritedFromDialogKey: "dialog-user-1-dialog-2",
|
|
244
|
-
parentDialogId: "dialog-2",
|
|
245
|
-
background: true,
|
|
246
|
-
timeoutMs: 600000,
|
|
247
|
-
stream: false,
|
|
248
|
-
});
|
|
249
|
-
expect(requests[0]?.body.runtimeContext.subjectRefs).toEqual([
|
|
250
|
-
{ kind: "dialog", id: "01SUBJECTDIALOG", role: "subject" },
|
|
251
|
-
]);
|
|
252
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-1" });
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test("sends explicit subject refs over HTTP for review evidence", async () => {
|
|
256
|
-
const output = new CaptureOutput();
|
|
257
|
-
const requests: Array<{ body: any }> = [];
|
|
258
|
-
|
|
259
|
-
await runAgentTurn({
|
|
260
|
-
agentName: "reviewer",
|
|
261
|
-
agentKey: "agent-reviewer",
|
|
262
|
-
serverUrl: "https://nolo.chat",
|
|
263
|
-
message: "Review this implementation",
|
|
264
|
-
subjectRefs: [
|
|
265
|
-
{ kind: "table-row", id: "row-user-board-task", role: "subject" },
|
|
266
|
-
{ kind: "dialog", id: "dialog-impl", role: "review-target" },
|
|
267
|
-
{ kind: "external", id: "commit:abc123", role: "commit" },
|
|
268
|
-
],
|
|
269
|
-
scriptDir: "C:/missing/scripts",
|
|
270
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
271
|
-
output,
|
|
272
|
-
runtimeMode: "server",
|
|
273
|
-
fetchImpl: async (_url, init) => {
|
|
274
|
-
requests.push({ body: JSON.parse(String(init?.body)) });
|
|
275
|
-
return Response.json({ content: "queued", dialogId: "dialog-review" });
|
|
276
|
-
},
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
expect(requests[0]?.body.runtimeContext.subjectRefs).toEqual([
|
|
280
|
-
{ kind: "table-row", id: "row-user-board-task", role: "subject" },
|
|
281
|
-
{ kind: "dialog", id: "dialog-impl", role: "review-target" },
|
|
282
|
-
{ kind: "external", id: "commit:abc123", role: "commit" },
|
|
283
|
-
]);
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
test("does not write background handoff state", async () => {
|
|
287
|
-
const output = new CaptureOutput();
|
|
288
|
-
|
|
289
|
-
const result = await runAgentTurn({
|
|
290
|
-
agentName: "frontend-implementer",
|
|
291
|
-
agentKey: "agent-frontend",
|
|
292
|
-
serverUrl: "https://nolo.chat",
|
|
293
|
-
message: "Fix settings style FOUC",
|
|
294
|
-
scriptDir: "C:/missing/scripts",
|
|
295
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
296
|
-
runtimeMode: "server",
|
|
297
|
-
background: true,
|
|
298
|
-
noStream: true,
|
|
299
|
-
taskRowContext: {
|
|
300
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
301
|
-
},
|
|
302
|
-
output,
|
|
303
|
-
fetchImpl: async () => {
|
|
304
|
-
return Response.json({ dialogId: "dialog-bg", status: "pending" }, { status: 202 });
|
|
305
|
-
},
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-bg" });
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test("runs forced local turns through the injected runtime adapter without HTTP", async () => {
|
|
312
|
-
const output = new CaptureOutput();
|
|
313
|
-
const result = await runAgentTurn({
|
|
314
|
-
agentName: "frontend",
|
|
315
|
-
agentKey: "frontend-local",
|
|
316
|
-
serverUrl: "https://nolo.chat",
|
|
317
|
-
message: "polish notifications",
|
|
318
|
-
scriptDir: "C:/missing/scripts",
|
|
319
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
320
|
-
output,
|
|
321
|
-
runtimeMode: "local",
|
|
322
|
-
localRuntimeAdapter: {
|
|
323
|
-
host: "cli",
|
|
324
|
-
capabilities: ["local-provider", "local-persistence"],
|
|
325
|
-
loadAgentConfig: async (agentRef) => ({
|
|
326
|
-
key: agentRef,
|
|
327
|
-
name: "Frontend",
|
|
328
|
-
prompt: "Fix UI",
|
|
329
|
-
model: "fake-local",
|
|
330
|
-
}),
|
|
331
|
-
loadDialogHistory: async () => [],
|
|
332
|
-
saveTurn: async () => ({ dialogId: "dialog-local" }),
|
|
333
|
-
resolveProvider: async () => ({
|
|
334
|
-
model: "fake-local",
|
|
335
|
-
complete: async (messages) => ({
|
|
336
|
-
content: `local:${messages.at(-1)?.content}`,
|
|
337
|
-
model: "fake-local",
|
|
338
|
-
trace: messages,
|
|
339
|
-
}),
|
|
340
|
-
}),
|
|
341
|
-
executeTool: async () => {
|
|
342
|
-
throw new Error("no tools expected");
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
fetchImpl: async () => {
|
|
346
|
-
throw new Error("HTTP should not be called for forced local runs");
|
|
347
|
-
},
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local" });
|
|
351
|
-
expect(output.text()).toContain("frontend -> working locally");
|
|
352
|
-
expect(output.text()).toContain("frontend > local:polish notifications");
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
test("continues forced local tool loops until the provider returns final text", async () => {
|
|
356
|
-
const output = new CaptureOutput();
|
|
357
|
-
let completeCalls = 0;
|
|
358
|
-
let toolCalls = 0;
|
|
359
|
-
|
|
360
|
-
const result = await runAgentTurn({
|
|
361
|
-
agentName: "frontend",
|
|
362
|
-
agentKey: "frontend-local",
|
|
363
|
-
serverUrl: "https://nolo.chat",
|
|
364
|
-
message: "make screenshots",
|
|
365
|
-
scriptDir: "C:/missing/scripts",
|
|
366
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
367
|
-
output,
|
|
368
|
-
runtimeMode: "local",
|
|
369
|
-
localRuntimeAdapter: {
|
|
370
|
-
host: "cli",
|
|
371
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
372
|
-
loadAgentConfig: async (agentRef) => ({
|
|
373
|
-
key: agentRef,
|
|
374
|
-
name: "Frontend",
|
|
375
|
-
prompt: "Fix UI",
|
|
376
|
-
model: "fake-local",
|
|
377
|
-
toolNames: ["readFile"],
|
|
378
|
-
}),
|
|
379
|
-
loadDialogHistory: async () => [],
|
|
380
|
-
saveTurn: async () => ({ dialogId: "dialog-local-retry" }),
|
|
381
|
-
resolveProvider: async () => ({
|
|
382
|
-
model: "fake-local",
|
|
383
|
-
complete: async () => {
|
|
384
|
-
completeCalls += 1;
|
|
385
|
-
if (completeCalls <= 3) {
|
|
386
|
-
return {
|
|
387
|
-
content: "",
|
|
388
|
-
model: "fake-local",
|
|
389
|
-
tool_calls: [{
|
|
390
|
-
id: `call-${completeCalls}`,
|
|
391
|
-
type: "function",
|
|
392
|
-
function: { name: "readFile", arguments: "{}" },
|
|
393
|
-
}],
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
return { content: "done after retry", model: "fake-local" };
|
|
397
|
-
},
|
|
398
|
-
}),
|
|
399
|
-
executeTool: async () => {
|
|
400
|
-
toolCalls += 1;
|
|
401
|
-
return { content: "ok" };
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local-retry" });
|
|
407
|
-
expect(toolCalls).toBe(3);
|
|
408
|
-
expect(output.text()).toContain("frontend > done after retry");
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
test("prints compact local tool trace by default", async () => {
|
|
412
|
-
const output = new CaptureOutput();
|
|
413
|
-
let completeCalls = 0;
|
|
414
|
-
|
|
415
|
-
const result = await runAgentTurn({
|
|
416
|
-
agentName: "frontend",
|
|
417
|
-
agentKey: "frontend-local",
|
|
418
|
-
serverUrl: "https://nolo.chat",
|
|
419
|
-
message: "inspect repo",
|
|
420
|
-
scriptDir: "C:/missing/scripts",
|
|
421
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
422
|
-
output,
|
|
423
|
-
runtimeMode: "local",
|
|
424
|
-
localRuntimeAdapter: {
|
|
425
|
-
host: "cli",
|
|
426
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
427
|
-
loadAgentConfig: async (agentRef) => ({
|
|
428
|
-
key: agentRef,
|
|
429
|
-
name: "Frontend",
|
|
430
|
-
prompt: "Fix UI",
|
|
431
|
-
model: "fake-local",
|
|
432
|
-
toolNames: ["readFile"],
|
|
433
|
-
}),
|
|
434
|
-
loadDialogHistory: async () => [],
|
|
435
|
-
saveTurn: async () => ({ dialogId: "dialog-local" }),
|
|
436
|
-
resolveProvider: async () => ({
|
|
437
|
-
model: "fake-local",
|
|
438
|
-
complete: async () => {
|
|
439
|
-
completeCalls += 1;
|
|
440
|
-
if (completeCalls === 1) {
|
|
441
|
-
return {
|
|
442
|
-
content: "",
|
|
443
|
-
model: "fake-local",
|
|
444
|
-
tool_calls: [{
|
|
445
|
-
id: "call-read",
|
|
446
|
-
type: "function",
|
|
447
|
-
function: { name: "readFile", arguments: JSON.stringify({ path: "README.md" }) },
|
|
448
|
-
}],
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
return { content: "done", model: "fake-local" };
|
|
452
|
-
},
|
|
453
|
-
}),
|
|
454
|
-
executeTool: async () => ({ content: "clean" }),
|
|
455
|
-
},
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local" });
|
|
459
|
-
expect(output.text()).toContain("[nolo:tool] #1 -> readFile README.md");
|
|
460
|
-
expect(output.text()).toContain("[nolo:tool] #1 <- readFile");
|
|
461
|
-
expect(output.text()).toContain("1 line");
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
test("does not print local tool trace when disabled by env", async () => {
|
|
465
|
-
const output = new CaptureOutput();
|
|
466
|
-
let completeCalls = 0;
|
|
467
|
-
|
|
468
|
-
const result = await runAgentTurn({
|
|
469
|
-
agentName: "frontend",
|
|
470
|
-
agentKey: "frontend-local",
|
|
471
|
-
serverUrl: "https://nolo.chat",
|
|
472
|
-
message: "inspect repo",
|
|
473
|
-
scriptDir: "C:/missing/scripts",
|
|
474
|
-
env: { AUTH_TOKEN: "token-123", NOLO_TRACE_TOOLS: "0" },
|
|
475
|
-
output,
|
|
476
|
-
runtimeMode: "local",
|
|
477
|
-
localRuntimeAdapter: {
|
|
478
|
-
host: "cli",
|
|
479
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
480
|
-
loadAgentConfig: async (agentRef) => ({
|
|
481
|
-
key: agentRef,
|
|
482
|
-
name: "Frontend",
|
|
483
|
-
prompt: "Fix UI",
|
|
484
|
-
model: "fake-local",
|
|
485
|
-
toolNames: ["readFile"],
|
|
486
|
-
}),
|
|
487
|
-
loadDialogHistory: async () => [],
|
|
488
|
-
saveTurn: async () => ({ dialogId: "dialog-local-no-trace" }),
|
|
489
|
-
resolveProvider: async () => ({
|
|
490
|
-
model: "fake-local",
|
|
491
|
-
complete: async () => {
|
|
492
|
-
completeCalls += 1;
|
|
493
|
-
if (completeCalls === 1) {
|
|
494
|
-
return {
|
|
495
|
-
content: "",
|
|
496
|
-
model: "fake-local",
|
|
497
|
-
tool_calls: [{
|
|
498
|
-
id: "call-read",
|
|
499
|
-
type: "function",
|
|
500
|
-
function: { name: "readFile", arguments: JSON.stringify({ path: "README.md" }) },
|
|
501
|
-
}],
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
return { content: "done", model: "fake-local" };
|
|
505
|
-
},
|
|
506
|
-
}),
|
|
507
|
-
executeTool: async () => ({ content: "clean" }),
|
|
508
|
-
},
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local-no-trace" });
|
|
512
|
-
expect(output.text()).not.toContain("[nolo:tool]");
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
test("prints local tool events as jsonl when requested", async () => {
|
|
516
|
-
const output = new CaptureOutput();
|
|
517
|
-
let completeCalls = 0;
|
|
518
|
-
|
|
519
|
-
const result = await runAgentTurn({
|
|
520
|
-
agentName: "frontend",
|
|
521
|
-
agentKey: "frontend-local",
|
|
522
|
-
serverUrl: "https://nolo.chat",
|
|
523
|
-
message: "inspect repo",
|
|
524
|
-
scriptDir: "C:/missing/scripts",
|
|
525
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
526
|
-
output,
|
|
527
|
-
runtimeMode: "local",
|
|
528
|
-
eventsMode: "jsonl",
|
|
529
|
-
localRuntimeAdapter: {
|
|
530
|
-
host: "cli",
|
|
531
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
532
|
-
loadAgentConfig: async (agentRef) => ({
|
|
533
|
-
key: agentRef,
|
|
534
|
-
name: "Frontend",
|
|
535
|
-
prompt: "Fix UI",
|
|
536
|
-
model: "fake-local",
|
|
537
|
-
toolNames: ["execShell"],
|
|
538
|
-
}),
|
|
539
|
-
loadDialogHistory: async () => [],
|
|
540
|
-
saveTurn: async () => ({ dialogId: "dialog-local-jsonl" }),
|
|
541
|
-
resolveProvider: async () => ({
|
|
542
|
-
model: "fake-local",
|
|
543
|
-
complete: async () => {
|
|
544
|
-
completeCalls += 1;
|
|
545
|
-
if (completeCalls === 1) {
|
|
546
|
-
return {
|
|
547
|
-
content: "",
|
|
548
|
-
model: "fake-local",
|
|
549
|
-
tool_calls: [{
|
|
550
|
-
id: "call-shell",
|
|
551
|
-
type: "function",
|
|
552
|
-
function: { name: "execShell", arguments: JSON.stringify({ command: "git status --short" }) },
|
|
553
|
-
}],
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
return { content: "done", model: "fake-local" };
|
|
557
|
-
},
|
|
558
|
-
}),
|
|
559
|
-
executeTool: async () => ({ content: "stdout:\nclean\n\nexitCode: 0", metadata: { exitCode: 0 } }),
|
|
560
|
-
},
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local-jsonl" });
|
|
564
|
-
const events = output.text()
|
|
565
|
-
.split(/\r?\n/)
|
|
566
|
-
.filter((line) => line.startsWith("{"))
|
|
567
|
-
.map((line) => JSON.parse(line))
|
|
568
|
-
.filter((event) => typeof event.type === "string" && event.type.startsWith("tool-"));
|
|
569
|
-
expect(events).toHaveLength(2);
|
|
570
|
-
expect(events[0]).toMatchObject({
|
|
571
|
-
schemaVersion: 1,
|
|
572
|
-
type: "tool-call",
|
|
573
|
-
round: 1,
|
|
574
|
-
tool: "execShell",
|
|
575
|
-
argsPreview: "git status --short",
|
|
576
|
-
});
|
|
577
|
-
expect(events[1]).toMatchObject({
|
|
578
|
-
schemaVersion: 1,
|
|
579
|
-
type: "tool-result",
|
|
580
|
-
round: 1,
|
|
581
|
-
tool: "execShell",
|
|
582
|
-
summary: expect.stringContaining("exit=0"),
|
|
583
|
-
metadata: { exitCode: 0 },
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
test("does not pass local tool evidence to an external writeback path", async () => {
|
|
588
|
-
const output = new CaptureOutput();
|
|
589
|
-
let completeCalls = 0;
|
|
590
|
-
|
|
591
|
-
const result = await runAgentTurn({
|
|
592
|
-
agentName: "frontend",
|
|
593
|
-
agentKey: "frontend-local",
|
|
594
|
-
serverUrl: "https://nolo.chat",
|
|
595
|
-
message: "inspect repo",
|
|
596
|
-
scriptDir: "C:/missing/scripts",
|
|
597
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
598
|
-
output,
|
|
599
|
-
runtimeMode: "local",
|
|
600
|
-
taskRowContext: {
|
|
601
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
602
|
-
},
|
|
603
|
-
localRuntimeAdapter: {
|
|
604
|
-
host: "cli",
|
|
605
|
-
capabilities: ["local-provider", "local-persistence", "local-tools"],
|
|
606
|
-
loadAgentConfig: async (agentRef) => ({
|
|
607
|
-
key: agentRef,
|
|
608
|
-
name: "Frontend",
|
|
609
|
-
prompt: "Fix UI",
|
|
610
|
-
model: "fake-local",
|
|
611
|
-
toolNames: ["readFile"],
|
|
612
|
-
}),
|
|
613
|
-
loadDialogHistory: async () => [],
|
|
614
|
-
saveTurn: async () => ({ dialogId: "dialog-local" }),
|
|
615
|
-
resolveProvider: async () => ({
|
|
616
|
-
model: "fake-local",
|
|
617
|
-
complete: async () => {
|
|
618
|
-
completeCalls += 1;
|
|
619
|
-
if (completeCalls === 1) {
|
|
620
|
-
return {
|
|
621
|
-
content: "",
|
|
622
|
-
model: "fake-local",
|
|
623
|
-
tool_calls: [{
|
|
624
|
-
id: "call-read",
|
|
625
|
-
type: "function",
|
|
626
|
-
function: { name: "readFile", arguments: JSON.stringify({ path: "README.md" }) },
|
|
627
|
-
}],
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
return { content: "done", model: "fake-local" };
|
|
631
|
-
},
|
|
632
|
-
}),
|
|
633
|
-
executeTool: async () => ({ content: "clean" }),
|
|
634
|
-
},
|
|
635
|
-
});
|
|
636
|
-
|
|
637
|
-
expect(result).toMatchObject({ exitCode: 0, dialogId: "dialog-local" });
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
test("does not write local background handoff state", async () => {
|
|
641
|
-
const output = new CaptureOutput();
|
|
642
|
-
|
|
643
|
-
const result = await runAgentTurn({
|
|
644
|
-
agentName: "frontend",
|
|
645
|
-
agentKey: "frontend-local",
|
|
646
|
-
serverUrl: "https://nolo.chat",
|
|
647
|
-
message: "inspect repo in background",
|
|
648
|
-
scriptDir: "C:/missing/scripts",
|
|
649
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
650
|
-
output,
|
|
651
|
-
runtimeMode: "local",
|
|
652
|
-
background: true,
|
|
653
|
-
taskRowContext: {
|
|
654
|
-
rowDbKey: "row-b2e06f801f-01TASK",
|
|
655
|
-
},
|
|
656
|
-
localRuntimeAdapter: {
|
|
657
|
-
host: "cli",
|
|
658
|
-
capabilities: ["local-provider", "local-persistence"],
|
|
659
|
-
loadAgentConfig: async (agentRef) => ({
|
|
660
|
-
key: agentRef,
|
|
661
|
-
name: "Frontend",
|
|
662
|
-
prompt: "Fix UI",
|
|
663
|
-
model: "fake-local",
|
|
664
|
-
}),
|
|
665
|
-
loadDialogHistory: async () => [],
|
|
666
|
-
saveTurn: async () => ({ dialogId: "dialog-local-bg" }),
|
|
667
|
-
resolveProvider: async () => ({
|
|
668
|
-
model: "fake-local",
|
|
669
|
-
complete: async () => ({ content: "accepted locally", model: "fake-local" }),
|
|
670
|
-
}),
|
|
671
|
-
executeTool: async () => {
|
|
672
|
-
throw new Error("no tools expected");
|
|
673
|
-
},
|
|
674
|
-
},
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local-bg" });
|
|
678
|
-
});
|
|
679
|
-
|
|
680
|
-
test("auto mode prefers a working local runtime before HTTP", async () => {
|
|
681
|
-
const output = new CaptureOutput();
|
|
682
|
-
const httpCalls: string[] = [];
|
|
683
|
-
|
|
684
|
-
const result = await runAgentTurn({
|
|
685
|
-
agentName: "frontend",
|
|
686
|
-
agentKey: "frontend-local",
|
|
687
|
-
serverUrl: "https://nolo.chat",
|
|
688
|
-
message: "polish notifications",
|
|
689
|
-
scriptDir: "C:/missing/scripts",
|
|
690
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
691
|
-
output,
|
|
692
|
-
runtimeMode: "auto",
|
|
693
|
-
localRuntimeAdapter: {
|
|
694
|
-
host: "cli",
|
|
695
|
-
capabilities: ["leveldb-agent-config", "local-provider"],
|
|
696
|
-
loadAgentConfig: async (agentRef) => ({
|
|
697
|
-
key: agentRef,
|
|
698
|
-
name: "Frontend",
|
|
699
|
-
prompt: "Fix UI",
|
|
700
|
-
model: "fake-local",
|
|
701
|
-
}),
|
|
702
|
-
loadDialogHistory: async () => [],
|
|
703
|
-
saveTurn: async () => ({ dialogId: "dialog-auto-local" }),
|
|
704
|
-
resolveProvider: async () => ({
|
|
705
|
-
model: "fake-local",
|
|
706
|
-
complete: async () => ({ content: "auto local ok", model: "fake-local" }),
|
|
707
|
-
}),
|
|
708
|
-
executeTool: async () => {
|
|
709
|
-
throw new Error("no tools expected");
|
|
710
|
-
},
|
|
711
|
-
},
|
|
712
|
-
fetchImpl: async (url) => {
|
|
713
|
-
httpCalls.push(String(url));
|
|
714
|
-
return Response.json({ content: "server" });
|
|
715
|
-
},
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-auto-local" });
|
|
719
|
-
expect(httpCalls).toEqual([]);
|
|
720
|
-
expect(output.text()).toContain("frontend -> working locally");
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
test("auto mode refreshes missing local agent config and retries local once before HTTP", async () => {
|
|
724
|
-
const output = new CaptureOutput();
|
|
725
|
-
const httpCalls: string[] = [];
|
|
726
|
-
let loadAgentConfigCalls = 0;
|
|
727
|
-
let localCompletions = 0;
|
|
728
|
-
|
|
729
|
-
const result = await runAgentTurn({
|
|
730
|
-
agentName: "frontend",
|
|
731
|
-
agentKey: "frontend-local",
|
|
732
|
-
serverUrl: "https://nolo.chat",
|
|
733
|
-
message: "polish notifications",
|
|
734
|
-
scriptDir: "C:/missing/scripts",
|
|
735
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
736
|
-
output,
|
|
737
|
-
runtimeMode: "auto",
|
|
738
|
-
localRuntimeAdapter: {
|
|
739
|
-
host: "cli",
|
|
740
|
-
capabilities: ["leveldb-agent-config", "local-provider", "leveldb-persistence"],
|
|
741
|
-
loadAgentConfig: async (agentRef) => {
|
|
742
|
-
loadAgentConfigCalls += 1;
|
|
743
|
-
if (loadAgentConfigCalls < 3) return null;
|
|
744
|
-
return {
|
|
745
|
-
key: agentRef,
|
|
746
|
-
name: "Frontend",
|
|
747
|
-
prompt: "Fix UI",
|
|
748
|
-
model: "fake-local",
|
|
749
|
-
};
|
|
750
|
-
},
|
|
751
|
-
loadDialogHistory: async () => [],
|
|
752
|
-
saveTurn: async () => ({ dialogId: "dialog-auto-local-retried" }),
|
|
753
|
-
resolveProvider: async () => ({
|
|
754
|
-
model: "fake-local",
|
|
755
|
-
complete: async () => {
|
|
756
|
-
localCompletions += 1;
|
|
757
|
-
return { content: "auto local after refresh", model: "fake-local" };
|
|
758
|
-
},
|
|
759
|
-
}),
|
|
760
|
-
executeTool: async () => {
|
|
761
|
-
throw new Error("no tools expected");
|
|
762
|
-
},
|
|
763
|
-
},
|
|
764
|
-
fetchImpl: async (url) => {
|
|
765
|
-
httpCalls.push(String(url));
|
|
766
|
-
return Response.json({ content: "server" });
|
|
767
|
-
},
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-auto-local-retried" });
|
|
771
|
-
expect(loadAgentConfigCalls).toBe(4);
|
|
772
|
-
expect(localCompletions).toBe(1);
|
|
773
|
-
expect(httpCalls).toEqual([]);
|
|
774
|
-
expect(output.text()).toContain("refreshing from the configured server and retrying local once");
|
|
775
|
-
expect(output.text().match(/working locally/g)?.length).toBe(2);
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
test("auto mode falls back to HTTP when local agent config is still missing after one refresh retry", async () => {
|
|
779
|
-
const output = new CaptureOutput();
|
|
780
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
781
|
-
let loadAgentConfigCalls = 0;
|
|
782
|
-
|
|
783
|
-
const result = await runAgentTurn({
|
|
784
|
-
agentName: "frontend",
|
|
785
|
-
agentKey: "frontend-local",
|
|
786
|
-
serverUrl: "https://nolo.chat",
|
|
787
|
-
message: "polish notifications",
|
|
788
|
-
scriptDir: "C:/missing/scripts",
|
|
789
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
790
|
-
output,
|
|
791
|
-
runtimeMode: "auto",
|
|
792
|
-
localRuntimeAdapter: {
|
|
793
|
-
host: "cli",
|
|
794
|
-
capabilities: ["leveldb-agent-config", "local-provider", "leveldb-persistence"],
|
|
795
|
-
loadAgentConfig: async () => {
|
|
796
|
-
loadAgentConfigCalls += 1;
|
|
797
|
-
return null;
|
|
798
|
-
},
|
|
799
|
-
loadDialogHistory: async () => [],
|
|
800
|
-
saveTurn: async () => {
|
|
801
|
-
throw new Error("local runtime should not save when config is missing");
|
|
802
|
-
},
|
|
803
|
-
resolveProvider: async () => {
|
|
804
|
-
throw new Error("local provider should not run when config is missing");
|
|
805
|
-
},
|
|
806
|
-
executeTool: async () => {
|
|
807
|
-
throw new Error("no tools expected");
|
|
808
|
-
},
|
|
809
|
-
},
|
|
810
|
-
fetchImpl: async (url, init) => {
|
|
811
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
812
|
-
return Response.json({ content: "server fallback", dialogId: "dialog-server-fallback" });
|
|
813
|
-
},
|
|
814
|
-
});
|
|
815
|
-
|
|
816
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server-fallback" });
|
|
817
|
-
expect(loadAgentConfigCalls).toBe(3);
|
|
818
|
-
expect(httpCalls).toHaveLength(1);
|
|
819
|
-
expect(httpCalls[0]?.body.agentKey).toBe("frontend-local");
|
|
820
|
-
expect(output.text()).toContain("refreshing from the configured server and retrying local once");
|
|
821
|
-
expect(output.text()).toContain("frontend -> working");
|
|
822
|
-
expect(output.text()).toContain("frontend > server fallback");
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
test("auto mode skips local runtime for agents that declare server platform tools", async () => {
|
|
826
|
-
const output = new CaptureOutput();
|
|
827
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
828
|
-
|
|
829
|
-
const result = await runAgentTurn({
|
|
830
|
-
agentName: "pm",
|
|
831
|
-
agentKey: "agent-custom-platform-tools",
|
|
832
|
-
serverUrl: "https://nolo.chat",
|
|
833
|
-
message: "write task rows",
|
|
834
|
-
scriptDir: "C:/missing/scripts",
|
|
835
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
836
|
-
output,
|
|
837
|
-
runtimeMode: "auto",
|
|
838
|
-
localRuntimeAdapter: {
|
|
839
|
-
host: "cli",
|
|
840
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
841
|
-
loadAgentConfig: async (agentRef) => ({
|
|
842
|
-
key: agentRef,
|
|
843
|
-
name: "PM",
|
|
844
|
-
prompt: "Manage task rows",
|
|
845
|
-
model: "fake-local",
|
|
846
|
-
toolNames: ["queryTableRows", "addTableRow", "updateTableRow"],
|
|
847
|
-
}),
|
|
848
|
-
loadDialogHistory: async () => [],
|
|
849
|
-
saveTurn: async () => {
|
|
850
|
-
throw new Error("local runtime should be skipped");
|
|
851
|
-
},
|
|
852
|
-
resolveProvider: async () => {
|
|
853
|
-
throw new Error("local provider should be skipped");
|
|
854
|
-
},
|
|
855
|
-
executeTool: async () => {
|
|
856
|
-
throw new Error("local tools should be skipped");
|
|
857
|
-
},
|
|
858
|
-
},
|
|
859
|
-
fetchImpl: async (url, init) => {
|
|
860
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
861
|
-
return Response.json({ content: "server ok", dialogId: "dialog-server" });
|
|
862
|
-
},
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server" });
|
|
866
|
-
expect(httpCalls).toHaveLength(1);
|
|
867
|
-
expect(httpCalls[0]?.body.agentKey).toBe("agent-custom-platform-tools");
|
|
868
|
-
expect(output.text()).toContain("auto runtime: skipping local runtime");
|
|
869
|
-
expect(output.text()).toContain("queryTableRows, addTableRow, updateTableRow");
|
|
870
|
-
expect(output.text()).toContain("pm -> working");
|
|
871
|
-
expect(output.text()).toContain("pm > server ok");
|
|
872
|
-
});
|
|
873
|
-
|
|
874
|
-
test("auto mode keeps local runtime for CLI provider agents even when they declare platform tools", async () => {
|
|
875
|
-
const output = new CaptureOutput();
|
|
876
|
-
const httpCalls: string[] = [];
|
|
877
|
-
let providerCalled = false;
|
|
878
|
-
|
|
879
|
-
const result = await runAgentTurn({
|
|
880
|
-
agentName: "frontend-implementer",
|
|
881
|
-
agentKey: "frontend-implementer",
|
|
882
|
-
serverUrl: "https://nolo.chat",
|
|
883
|
-
message: "polish notifications",
|
|
884
|
-
scriptDir: "C:/missing/scripts",
|
|
885
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
886
|
-
output,
|
|
887
|
-
runtimeMode: "auto",
|
|
888
|
-
localRuntimeAdapter: {
|
|
889
|
-
host: "cli",
|
|
890
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
891
|
-
loadAgentConfig: async (agentRef) => ({
|
|
892
|
-
key: agentRef,
|
|
893
|
-
name: "AGY",
|
|
894
|
-
prompt: "Implement frontend tasks.",
|
|
895
|
-
provider: "agy",
|
|
896
|
-
cliProvider: "agy",
|
|
897
|
-
toolNames: ["streamParallelAgents", "queryTableRows"],
|
|
898
|
-
}),
|
|
899
|
-
loadDialogHistory: async () => [],
|
|
900
|
-
saveTurn: async () => ({ dialogId: "dialog-agy-auto-local" }),
|
|
901
|
-
resolveProvider: async () => ({
|
|
902
|
-
model: "agy",
|
|
903
|
-
complete: async () => {
|
|
904
|
-
providerCalled = true;
|
|
905
|
-
return { content: "agy local ok", model: "agy" };
|
|
906
|
-
},
|
|
907
|
-
}),
|
|
908
|
-
executeTool: async () => {
|
|
909
|
-
throw new Error("no tools expected");
|
|
910
|
-
},
|
|
911
|
-
},
|
|
912
|
-
fetchImpl: async (url) => {
|
|
913
|
-
httpCalls.push(String(url));
|
|
914
|
-
return Response.json({ content: "server" });
|
|
915
|
-
},
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
expect(providerCalled).toBe(true);
|
|
919
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-agy-auto-local" });
|
|
920
|
-
expect(httpCalls).toEqual([]);
|
|
921
|
-
expect(output.text()).not.toContain("skipping local runtime");
|
|
922
|
-
expect(output.text()).toContain("frontend-implementer -> working locally");
|
|
923
|
-
expect(output.text()).toContain("frontend-implementer > agy local ok");
|
|
924
|
-
});
|
|
925
|
-
|
|
926
|
-
test("auto mode does not skip monthly Mimo when a local shell cwd is already bound", async () => {
|
|
927
|
-
const output = new CaptureOutput();
|
|
928
|
-
const httpCalls: string[] = [];
|
|
929
|
-
let providerCalled = false;
|
|
930
|
-
|
|
931
|
-
const result = await runAgentTurn({
|
|
932
|
-
agentName: MIMO_MONTH_AGENT_KEY,
|
|
933
|
-
agentKey: MIMO_MONTH_AGENT_KEY,
|
|
934
|
-
serverUrl: "https://us.nolo.chat",
|
|
935
|
-
message: "fix tests and commit",
|
|
936
|
-
scriptDir: "C:/missing/scripts",
|
|
937
|
-
env: {
|
|
938
|
-
AUTH_TOKEN: "token-123",
|
|
939
|
-
},
|
|
940
|
-
output,
|
|
941
|
-
runtimeMode: "auto",
|
|
942
|
-
localRuntimeCwd: "/repo/.worktrees/nolo-agent-mimo",
|
|
943
|
-
localRuntimeAdapter: {
|
|
944
|
-
host: "cli",
|
|
945
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
946
|
-
loadAgentConfig: async (agentRef) => ({
|
|
947
|
-
key: agentRef,
|
|
948
|
-
name: "包月 Mimo",
|
|
949
|
-
prompt: "Implement backend tasks.",
|
|
950
|
-
provider: "custom",
|
|
951
|
-
model: "mimo-v2.5-pro",
|
|
952
|
-
toolNames: ["queryTableRows"],
|
|
953
|
-
}),
|
|
954
|
-
loadDialogHistory: async () => [],
|
|
955
|
-
saveTurn: async () => ({ dialogId: "dialog-mimo-local" }),
|
|
956
|
-
resolveProvider: async () => ({
|
|
957
|
-
model: "mimo-v2.5-pro",
|
|
958
|
-
complete: async () => {
|
|
959
|
-
providerCalled = true;
|
|
960
|
-
return { content: "local mimo ok", model: "mimo-v2.5-pro" };
|
|
961
|
-
},
|
|
962
|
-
}),
|
|
963
|
-
executeTool: async () => ({ content: "ok" }),
|
|
964
|
-
},
|
|
965
|
-
fetchImpl: async (url) => {
|
|
966
|
-
httpCalls.push(String(url));
|
|
967
|
-
return Response.json({ content: "server" });
|
|
968
|
-
},
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
expect(providerCalled).toBe(true);
|
|
972
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-mimo-local" });
|
|
973
|
-
expect(httpCalls).toEqual([]);
|
|
974
|
-
expect(output.text()).not.toContain("skipping local runtime");
|
|
975
|
-
expect(output.text()).toContain(`${MIMO_MONTH_AGENT_KEY} -> working locally`);
|
|
976
|
-
});
|
|
977
|
-
|
|
978
|
-
test("auto mode skips local runtime for machine-bound localhost custom providers", async () => {
|
|
979
|
-
const output = new CaptureOutput();
|
|
980
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
981
|
-
|
|
982
|
-
const result = await runAgentTurn({
|
|
983
|
-
agentName: "win-qwen",
|
|
984
|
-
agentKey: "agent-win-qwen",
|
|
985
|
-
serverUrl: "https://nolo.chat",
|
|
986
|
-
message: "run on the bound Windows machine",
|
|
987
|
-
scriptDir: "C:/missing/scripts",
|
|
988
|
-
env: { AUTH_TOKEN: "token-123", OPENAI_API_KEY: "local-provider-present" },
|
|
989
|
-
output,
|
|
990
|
-
runtimeMode: "auto",
|
|
991
|
-
localRuntimeAdapter: {
|
|
992
|
-
host: "cli",
|
|
993
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
994
|
-
loadAgentConfig: async (agentRef) => ({
|
|
995
|
-
key: agentRef,
|
|
996
|
-
name: "Win Qwen",
|
|
997
|
-
prompt: "Windows local model",
|
|
998
|
-
provider: "custom",
|
|
999
|
-
model: "qwen",
|
|
1000
|
-
customProviderUrl: "http://127.0.0.1:8080/v1/chat/completions",
|
|
1001
|
-
runtimeBinding: {
|
|
1002
|
-
machineId: "machine-win",
|
|
1003
|
-
ownerUserId: "user-1",
|
|
1004
|
-
connectorSurface: "cli",
|
|
1005
|
-
},
|
|
1006
|
-
}),
|
|
1007
|
-
loadDialogHistory: async () => [],
|
|
1008
|
-
saveTurn: async () => {
|
|
1009
|
-
throw new Error("local runtime should be skipped");
|
|
1010
|
-
},
|
|
1011
|
-
resolveProvider: async () => {
|
|
1012
|
-
throw new Error("local provider should be skipped");
|
|
1013
|
-
},
|
|
1014
|
-
executeTool: async () => {
|
|
1015
|
-
throw new Error("local tools should be skipped");
|
|
1016
|
-
},
|
|
1017
|
-
},
|
|
1018
|
-
fetchImpl: async (url, init) => {
|
|
1019
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
1020
|
-
return Response.json({ content: "server connector ok", dialogId: "dialog-win" });
|
|
1021
|
-
},
|
|
1022
|
-
});
|
|
1023
|
-
|
|
1024
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-win" });
|
|
1025
|
-
expect(httpCalls).toHaveLength(1);
|
|
1026
|
-
expect(httpCalls[0]?.body.agentKey).toBe("agent-win-qwen");
|
|
1027
|
-
expect(output.text()).toContain("auto runtime: skipping local runtime");
|
|
1028
|
-
expect(output.text()).toContain("machine-bound localhost custom provider");
|
|
1029
|
-
expect(output.text()).not.toContain("win-qwen -> working locally");
|
|
1030
|
-
});
|
|
1031
|
-
|
|
1032
|
-
test("auto mode keeps builtin nolo on local runtime so CLI workspace tools are available", async () => {
|
|
1033
|
-
const output = new CaptureOutput();
|
|
1034
|
-
const httpCalls: string[] = [];
|
|
1035
|
-
let providerCalled = false;
|
|
1036
|
-
|
|
1037
|
-
const result = await runAgentTurn({
|
|
1038
|
-
agentName: "nolo",
|
|
1039
|
-
agentKey: BUILTIN_NOLO_AGENT_KEY,
|
|
1040
|
-
serverUrl: "https://nolo.chat",
|
|
1041
|
-
message: "帮我总结最近 10 个对话",
|
|
1042
|
-
scriptDir: "C:/missing/scripts",
|
|
1043
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1044
|
-
output,
|
|
1045
|
-
runtimeMode: "auto",
|
|
1046
|
-
localRuntimeAdapter: {
|
|
1047
|
-
host: "cli",
|
|
1048
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
1049
|
-
loadAgentConfig: async () => ({
|
|
1050
|
-
key: BUILTIN_NOLO_AGENT_KEY,
|
|
1051
|
-
name: "nolo",
|
|
1052
|
-
prompt: "Use workspace tools.",
|
|
1053
|
-
model: "fake-local",
|
|
1054
|
-
toolNames: ["queryTableRows", "addTableRow", "updateTableRow"],
|
|
1055
|
-
}),
|
|
1056
|
-
loadDialogHistory: async () => [],
|
|
1057
|
-
saveTurn: async () => ({ dialogId: "dialog-builtin-nolo-local" }),
|
|
1058
|
-
resolveProvider: async () => ({
|
|
1059
|
-
model: "fake-local",
|
|
1060
|
-
complete: async () => {
|
|
1061
|
-
providerCalled = true;
|
|
1062
|
-
return { content: "local nolo with tools", model: "fake-local" };
|
|
1063
|
-
},
|
|
1064
|
-
}),
|
|
1065
|
-
executeTool: async () => ({ content: "[]" }),
|
|
1066
|
-
},
|
|
1067
|
-
fetchImpl: async (url) => {
|
|
1068
|
-
httpCalls.push(String(url));
|
|
1069
|
-
return Response.json({ content: "server" });
|
|
1070
|
-
},
|
|
1071
|
-
});
|
|
1072
|
-
|
|
1073
|
-
expect(providerCalled).toBe(true);
|
|
1074
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-builtin-nolo-local" });
|
|
1075
|
-
expect(httpCalls).toEqual([]);
|
|
1076
|
-
expect(output.text()).not.toContain("skipping local runtime");
|
|
1077
|
-
expect(output.text()).toContain("nolo -> working locally");
|
|
1078
|
-
});
|
|
1079
|
-
|
|
1080
|
-
test("auto mode skips local runtime for server platform tools declared by runtime policy", async () => {
|
|
1081
|
-
const output = new CaptureOutput();
|
|
1082
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
1083
|
-
|
|
1084
|
-
const result = await runAgentTurn({
|
|
1085
|
-
agentName: "pm",
|
|
1086
|
-
agentKey: "agent-policy-platform-tools",
|
|
1087
|
-
serverUrl: "https://nolo.chat",
|
|
1088
|
-
message: "query task rows",
|
|
1089
|
-
scriptDir: "C:/missing/scripts",
|
|
1090
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1091
|
-
output,
|
|
1092
|
-
runtimeMode: "auto",
|
|
1093
|
-
localRuntimeAdapter: {
|
|
1094
|
-
host: "cli",
|
|
1095
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
1096
|
-
loadAgentConfig: async (agentRef) => ({
|
|
1097
|
-
key: agentRef,
|
|
1098
|
-
name: "PM",
|
|
1099
|
-
prompt: "Manage task rows",
|
|
1100
|
-
model: "fake-local",
|
|
1101
|
-
runtimeToolPolicy: {
|
|
1102
|
-
version: 1,
|
|
1103
|
-
agentTools: ["queryTableRows", "streamParallelAgents"],
|
|
1104
|
-
runtimeTools: ["execShell"],
|
|
1105
|
-
},
|
|
1106
|
-
}),
|
|
1107
|
-
loadDialogHistory: async () => [],
|
|
1108
|
-
saveTurn: async () => {
|
|
1109
|
-
throw new Error("local runtime should be skipped");
|
|
1110
|
-
},
|
|
1111
|
-
resolveProvider: async () => {
|
|
1112
|
-
throw new Error("local provider should be skipped");
|
|
1113
|
-
},
|
|
1114
|
-
executeTool: async () => {
|
|
1115
|
-
throw new Error("local tools should be skipped");
|
|
1116
|
-
},
|
|
1117
|
-
},
|
|
1118
|
-
fetchImpl: async (url, init) => {
|
|
1119
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
1120
|
-
return Response.json({ content: "server ok", dialogId: "dialog-server-policy" });
|
|
1121
|
-
},
|
|
1122
|
-
});
|
|
1123
|
-
|
|
1124
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server-policy" });
|
|
1125
|
-
expect(httpCalls).toHaveLength(1);
|
|
1126
|
-
expect(httpCalls[0]?.body.agentKey).toBe("agent-policy-platform-tools");
|
|
1127
|
-
expect(output.text()).toContain("auto runtime: skipping local runtime");
|
|
1128
|
-
expect(output.text()).toContain("queryTableRows, streamParallelAgents");
|
|
1129
|
-
});
|
|
1130
|
-
|
|
1131
|
-
test("auto mode skips known platform agents when local config cannot be read", async () => {
|
|
1132
|
-
const output = new CaptureOutput();
|
|
1133
|
-
const httpCalls: Array<{ url: string; body: any }> = [];
|
|
1134
|
-
|
|
1135
|
-
const result = await runAgentTurn({
|
|
1136
|
-
agentName: "nolo-project-manager",
|
|
1137
|
-
agentKey: NOLO_PROJECT_MANAGER_AGENT_KEY,
|
|
1138
|
-
serverUrl: "https://us.nolo.chat",
|
|
1139
|
-
message: "write task rows",
|
|
1140
|
-
scriptDir: "C:/missing/scripts",
|
|
1141
|
-
env: { AUTH_TOKEN: "token-123", OPENAI_API_KEY: "local-provider-present" },
|
|
1142
|
-
output,
|
|
1143
|
-
runtimeMode: "auto",
|
|
1144
|
-
localRuntimeAdapter: {
|
|
1145
|
-
host: "cli",
|
|
1146
|
-
capabilities: ["leveldb-agent-config", "local-provider", "local-tools"],
|
|
1147
|
-
loadAgentConfig: async () => {
|
|
1148
|
-
throw new Error("Database failed to open: LOCK");
|
|
1149
|
-
},
|
|
1150
|
-
loadDialogHistory: async () => {
|
|
1151
|
-
throw new Error("local runtime should be skipped");
|
|
1152
|
-
},
|
|
1153
|
-
saveTurn: async () => {
|
|
1154
|
-
throw new Error("local runtime should be skipped");
|
|
1155
|
-
},
|
|
1156
|
-
resolveProvider: async () => {
|
|
1157
|
-
throw new Error("local provider should be skipped");
|
|
1158
|
-
},
|
|
1159
|
-
executeTool: async () => {
|
|
1160
|
-
throw new Error("local tools should be skipped");
|
|
1161
|
-
},
|
|
1162
|
-
},
|
|
1163
|
-
fetchImpl: async (url, init) => {
|
|
1164
|
-
httpCalls.push({ url: String(url), body: JSON.parse(String(init?.body)) });
|
|
1165
|
-
return Response.json({ content: "server ok", dialogId: "dialog-server" });
|
|
1166
|
-
},
|
|
1167
|
-
});
|
|
1168
|
-
|
|
1169
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-server" });
|
|
1170
|
-
expect(httpCalls).toHaveLength(1);
|
|
1171
|
-
expect(httpCalls[0]?.body.agentKey).toBe(NOLO_PROJECT_MANAGER_AGENT_KEY);
|
|
1172
|
-
expect(output.text()).toContain("known platform agent");
|
|
1173
|
-
expect(output.text()).toContain("nolo-project-manager -> working");
|
|
1174
|
-
expect(output.text()).toContain("nolo-project-manager > server ok");
|
|
1175
|
-
});
|
|
1176
|
-
|
|
1177
|
-
test("builds the default local adapter when env requests local mode", async () => {
|
|
1178
|
-
const output = new CaptureOutput();
|
|
1179
|
-
const builtModes: string[] = [];
|
|
1180
|
-
|
|
1181
|
-
const result = await runAgentTurn({
|
|
1182
|
-
agentName: "frontend",
|
|
1183
|
-
agentKey: "frontend-local",
|
|
1184
|
-
serverUrl: "https://nolo.chat",
|
|
1185
|
-
message: "polish notifications",
|
|
1186
|
-
scriptDir: "C:/missing/scripts",
|
|
1187
|
-
env: { NOLO_RUNTIME_MODE: "local" },
|
|
1188
|
-
output,
|
|
1189
|
-
localRuntimeAdapterFactory: (env) => {
|
|
1190
|
-
builtModes.push(env.NOLO_RUNTIME_MODE ?? "");
|
|
1191
|
-
return {
|
|
1192
|
-
host: "cli",
|
|
1193
|
-
capabilities: ["local-provider", "local-persistence"],
|
|
1194
|
-
loadAgentConfig: async (agentRef) => ({ key: agentRef, prompt: "Fix UI" }),
|
|
1195
|
-
loadDialogHistory: async () => [],
|
|
1196
|
-
saveTurn: async () => ({ dialogId: "dialog-local-env" }),
|
|
1197
|
-
resolveProvider: async () => ({
|
|
1198
|
-
model: "fake-local",
|
|
1199
|
-
complete: async () => ({ content: "local env ok", model: "fake-local" }),
|
|
1200
|
-
}),
|
|
1201
|
-
executeTool: async () => {
|
|
1202
|
-
throw new Error("no tools expected");
|
|
1203
|
-
},
|
|
1204
|
-
};
|
|
1205
|
-
},
|
|
1206
|
-
fetchImpl: async () => {
|
|
1207
|
-
throw new Error("HTTP should not be called for env local runs");
|
|
1208
|
-
},
|
|
1209
|
-
});
|
|
1210
|
-
|
|
1211
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-local-env" });
|
|
1212
|
-
expect(builtModes).toEqual(["local"]);
|
|
1213
|
-
expect(output.text()).toContain("frontend -> working locally");
|
|
1214
|
-
});
|
|
1215
|
-
|
|
1216
|
-
test("streams agent text responses to terminal output", async () => {
|
|
1217
|
-
const output = new CaptureOutput();
|
|
1218
|
-
|
|
1219
|
-
const result = await runAgentTurn({
|
|
1220
|
-
agentName: "nolo",
|
|
1221
|
-
agentKey: "agent-pub-test",
|
|
1222
|
-
serverUrl: "https://nolo.chat",
|
|
1223
|
-
message: "hello",
|
|
1224
|
-
scriptDir: "C:/missing/scripts",
|
|
1225
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1226
|
-
output,
|
|
1227
|
-
fetchImpl: async () =>
|
|
1228
|
-
new Response(
|
|
1229
|
-
[
|
|
1230
|
-
`data: ${JSON.stringify({ type: "text", content: "你" })}`,
|
|
1231
|
-
"",
|
|
1232
|
-
`data: ${JSON.stringify({ type: "text", content: "好" })}`,
|
|
1233
|
-
"",
|
|
1234
|
-
`data: ${JSON.stringify({ type: "done", dialogId: "dialog-stream" })}`,
|
|
1235
|
-
"",
|
|
1236
|
-
].join("\n"),
|
|
1237
|
-
{
|
|
1238
|
-
status: 200,
|
|
1239
|
-
headers: { "Content-Type": "text/event-stream" },
|
|
1240
|
-
}
|
|
1241
|
-
),
|
|
1242
|
-
});
|
|
1243
|
-
|
|
1244
|
-
expect(result).toEqual({ exitCode: 0, dialogId: "dialog-stream" });
|
|
1245
|
-
expect(output.text()).toContain("nolo -> working");
|
|
1246
|
-
expect(output.text()).toContain("nolo > 你好");
|
|
1247
|
-
});
|
|
1248
|
-
|
|
1249
|
-
test("returns a recoverable dialog when a server stream drops after dialog creation", async () => {
|
|
1250
|
-
const output = new CaptureOutput();
|
|
1251
|
-
|
|
1252
|
-
const result = await runAgentTurn({
|
|
1253
|
-
agentName: "nolo",
|
|
1254
|
-
agentKey: "agent-pub-test",
|
|
1255
|
-
serverUrl: "https://nolo.chat",
|
|
1256
|
-
message: "hello",
|
|
1257
|
-
scriptDir: "C:/missing/scripts",
|
|
1258
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1259
|
-
output,
|
|
1260
|
-
fetchImpl: async () => {
|
|
1261
|
-
let sent = false;
|
|
1262
|
-
return new Response(
|
|
1263
|
-
new ReadableStream({
|
|
1264
|
-
pull(controller) {
|
|
1265
|
-
const encoder = new TextEncoder();
|
|
1266
|
-
if (!sent) {
|
|
1267
|
-
sent = true;
|
|
1268
|
-
controller.enqueue(
|
|
1269
|
-
encoder.encode(
|
|
1270
|
-
[
|
|
1271
|
-
`data: ${JSON.stringify({
|
|
1272
|
-
type: "dialog",
|
|
1273
|
-
dialogId: "dialog-recoverable",
|
|
1274
|
-
status: "running",
|
|
1275
|
-
})}`,
|
|
1276
|
-
"",
|
|
1277
|
-
`data: ${JSON.stringify({ type: "text", content: "partial" })}`,
|
|
1278
|
-
"",
|
|
1279
|
-
].join("\n")
|
|
1280
|
-
)
|
|
1281
|
-
);
|
|
1282
|
-
return;
|
|
1283
|
-
}
|
|
1284
|
-
controller.error(new Error("socket closed"));
|
|
1285
|
-
},
|
|
1286
|
-
}),
|
|
1287
|
-
{
|
|
1288
|
-
status: 200,
|
|
1289
|
-
headers: { "Content-Type": "text/event-stream" },
|
|
1290
|
-
}
|
|
1291
|
-
);
|
|
1292
|
-
},
|
|
1293
|
-
});
|
|
1294
|
-
|
|
1295
|
-
expect(result).toEqual({
|
|
1296
|
-
exitCode: 0,
|
|
1297
|
-
dialogId: "dialog-recoverable",
|
|
1298
|
-
streamInterrupted: true,
|
|
1299
|
-
});
|
|
1300
|
-
expect(output.text()).toContain("dialog dialog-recoverable was created");
|
|
1301
|
-
expect(output.text()).toContain("read the dialog before retrying");
|
|
1302
|
-
});
|
|
1303
|
-
|
|
1304
|
-
test("prints an auth hint when installed without repo scripts or AUTH_TOKEN", async () => {
|
|
1305
|
-
const output = new CaptureOutput();
|
|
1306
|
-
|
|
1307
|
-
const result = await runAgentTurn({
|
|
1308
|
-
agentName: "nolo",
|
|
1309
|
-
agentKey: "agent-pub-test",
|
|
1310
|
-
serverUrl: "https://nolo.chat",
|
|
1311
|
-
message: "hello",
|
|
1312
|
-
scriptDir: "C:/missing/scripts",
|
|
1313
|
-
env: {},
|
|
1314
|
-
output,
|
|
1315
|
-
fetchImpl: async () => {
|
|
1316
|
-
throw new Error("fetch should not be called");
|
|
1317
|
-
},
|
|
1318
|
-
});
|
|
1319
|
-
|
|
1320
|
-
expect(result.exitCode).toBe(1);
|
|
1321
|
-
expect(output.text()).toContain("Run `nolo login`");
|
|
1322
|
-
});
|
|
1323
|
-
|
|
1324
|
-
test("prints a friendly connection hint instead of crashing on transport errors", async () => {
|
|
1325
|
-
const output = new CaptureOutput();
|
|
1326
|
-
|
|
1327
|
-
const result = await runAgentTurn({
|
|
1328
|
-
agentName: "nolo",
|
|
1329
|
-
agentKey: "agent-pub-test",
|
|
1330
|
-
serverUrl: "http://127.0.0.1:38123",
|
|
1331
|
-
message: "hello",
|
|
1332
|
-
scriptDir: "C:/missing/scripts",
|
|
1333
|
-
env: { AUTH_TOKEN: "token-123" },
|
|
1334
|
-
output,
|
|
1335
|
-
fetchImpl: async () => {
|
|
1336
|
-
throw new Error("ConnectionRefused");
|
|
1337
|
-
},
|
|
1338
|
-
});
|
|
1339
|
-
|
|
1340
|
-
expect(result).toEqual({ exitCode: 1 });
|
|
1341
|
-
expect(output.text()).toContain("Could not reach http://127.0.0.1:38123/api/agent/run");
|
|
1342
|
-
expect(output.text()).toContain("set NOLO_SERVER");
|
|
1343
|
-
});
|
|
1344
|
-
});
|