@tenex-chat/backend 0.9.1
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 +194 -0
- package/dist/backend-wrapper.cjs +3 -0
- package/dist/src/index.js +331928 -0
- package/package.json +103 -0
- package/src/agents/AgentRegistry.ts +418 -0
- package/src/agents/AgentStorage.ts +1133 -0
- package/src/agents/ConfigResolver.ts +229 -0
- package/src/agents/agent-installer.ts +236 -0
- package/src/agents/agent-loader.ts +241 -0
- package/src/agents/constants.ts +82 -0
- package/src/agents/errors.ts +48 -0
- package/src/agents/execution/AgentExecutor.ts +561 -0
- package/src/agents/execution/ExecutionContextFactory.ts +112 -0
- package/src/agents/execution/MessageCompiler.ts +597 -0
- package/src/agents/execution/MessageSyncer.ts +100 -0
- package/src/agents/execution/PostCompletionChecker.ts +278 -0
- package/src/agents/execution/ProgressMonitor.ts +50 -0
- package/src/agents/execution/RALResolver.ts +177 -0
- package/src/agents/execution/SessionManager.ts +181 -0
- package/src/agents/execution/StreamCallbacks.ts +312 -0
- package/src/agents/execution/StreamExecutionHandler.ts +579 -0
- package/src/agents/execution/StreamSetup.ts +313 -0
- package/src/agents/execution/ToolEventHandlers.ts +239 -0
- package/src/agents/execution/ToolExecutionTracker.ts +498 -0
- package/src/agents/execution/ToolResultUtils.ts +97 -0
- package/src/agents/execution/ToolSupervisionWrapper.ts +174 -0
- package/src/agents/execution/constants.ts +16 -0
- package/src/agents/execution/index.ts +3 -0
- package/src/agents/execution/types.ts +96 -0
- package/src/agents/execution/utils.ts +26 -0
- package/src/agents/index.ts +4 -0
- package/src/agents/script-installer.ts +266 -0
- package/src/agents/supervision/SupervisorLLMService.ts +253 -0
- package/src/agents/supervision/SupervisorOrchestrator.ts +471 -0
- package/src/agents/supervision/heuristics/ConsecutiveToolsWithoutTodoHeuristic.ts +73 -0
- package/src/agents/supervision/heuristics/DelegationClaimHeuristic.ts +80 -0
- package/src/agents/supervision/heuristics/HeuristicRegistry.ts +114 -0
- package/src/agents/supervision/heuristics/PendingTodosHeuristic.ts +93 -0
- package/src/agents/supervision/heuristics/SilentAgentHeuristic.ts +54 -0
- package/src/agents/supervision/heuristics/index.ts +5 -0
- package/src/agents/supervision/index.ts +28 -0
- package/src/agents/supervision/registerHeuristics.ts +110 -0
- package/src/agents/supervision/supervisionHealthCheck.ts +123 -0
- package/src/agents/supervision/types.ts +171 -0
- package/src/agents/tool-names.ts +46 -0
- package/src/agents/tool-normalization.ts +184 -0
- package/src/agents/types/index.ts +2 -0
- package/src/agents/types/runtime.ts +74 -0
- package/src/agents/types/storage.ts +145 -0
- package/src/commands/agent/import/index.ts +6 -0
- package/src/commands/agent/import/openclaw-distiller.ts +57 -0
- package/src/commands/agent/import/openclaw-reader.ts +141 -0
- package/src/commands/agent/import/openclaw.ts +154 -0
- package/src/commands/agent/index.ts +6 -0
- package/src/commands/agent.ts +215 -0
- package/src/commands/daemon.ts +198 -0
- package/src/commands/doctor.ts +134 -0
- package/src/commands/setup/embed.ts +228 -0
- package/src/commands/setup/global-system-prompt.ts +223 -0
- package/src/commands/setup/image.ts +179 -0
- package/src/commands/setup/index.ts +16 -0
- package/src/commands/setup/interactive.ts +95 -0
- package/src/commands/setup/llm.ts +38 -0
- package/src/commands/setup/onboarding.ts +294 -0
- package/src/commands/setup/providers.ts +27 -0
- package/src/constants.ts +34 -0
- package/src/conversations/ConversationDiskReader.ts +148 -0
- package/src/conversations/ConversationRegistry.ts +728 -0
- package/src/conversations/ConversationStore.ts +868 -0
- package/src/conversations/MessageBuilder.ts +866 -0
- package/src/conversations/executionTime.ts +62 -0
- package/src/conversations/formatters/DelegationXmlFormatter.ts +64 -0
- package/src/conversations/formatters/ThreadedConversationFormatter.ts +303 -0
- package/src/conversations/formatters/index.ts +9 -0
- package/src/conversations/formatters/utils/MessageFormatter.ts +46 -0
- package/src/conversations/formatters/utils/TimestampFormatter.ts +56 -0
- package/src/conversations/formatters/utils/TreeBuilder.ts +131 -0
- package/src/conversations/formatters/utils/TreeRenderer.ts +49 -0
- package/src/conversations/index.ts +2 -0
- package/src/conversations/persistence/ToolMessageStorage.ts +143 -0
- package/src/conversations/search/ConversationIndexManager.ts +393 -0
- package/src/conversations/search/QueryParser.ts +114 -0
- package/src/conversations/search/SearchEngine.ts +175 -0
- package/src/conversations/search/SnippetExtractor.ts +345 -0
- package/src/conversations/search/embeddings/ConversationEmbeddingService.ts +484 -0
- package/src/conversations/search/embeddings/ConversationIndexingJob.ts +320 -0
- package/src/conversations/search/embeddings/IndexingStateManager.ts +338 -0
- package/src/conversations/search/embeddings/index.ts +18 -0
- package/src/conversations/search/index.ts +49 -0
- package/src/conversations/search/types.ts +124 -0
- package/src/conversations/services/CategoryManager.ts +160 -0
- package/src/conversations/services/ConversationResolver.ts +296 -0
- package/src/conversations/services/ConversationSummarizer.ts +234 -0
- package/src/conversations/services/MetadataDebounceManager.ts +188 -0
- package/src/conversations/services/index.ts +2 -0
- package/src/conversations/types.ts +148 -0
- package/src/conversations/utils/content-utils.ts +69 -0
- package/src/conversations/utils/image-placeholder.ts +281 -0
- package/src/conversations/utils/image-url-utils.ts +171 -0
- package/src/conversations/utils/multimodal-content.ts +90 -0
- package/src/conversations/utils/tool-result-truncator.ts +159 -0
- package/src/daemon/Daemon.ts +1883 -0
- package/src/daemon/ProjectRuntime.ts +657 -0
- package/src/daemon/RestartState.ts +152 -0
- package/src/daemon/RuntimeLifecycle.ts +268 -0
- package/src/daemon/SubscriptionManager.ts +305 -0
- package/src/daemon/UnixSocketTransport.ts +318 -0
- package/src/daemon/filters/SubscriptionFilterBuilder.ts +119 -0
- package/src/daemon/index.ts +9 -0
- package/src/daemon/routing/DaemonRouter.ts +491 -0
- package/src/daemon/types.ts +150 -0
- package/src/daemon/utils/routing-log.ts +76 -0
- package/src/daemon/utils/telemetry.ts +173 -0
- package/src/event-handler/agentDeletion.ts +383 -0
- package/src/event-handler/index.ts +749 -0
- package/src/event-handler/newConversation.ts +165 -0
- package/src/event-handler/project.ts +166 -0
- package/src/event-handler/reply.ts +18 -0
- package/src/events/NDKAgentDefinition.ts +292 -0
- package/src/events/NDKAgentLesson.ts +106 -0
- package/src/events/NDKEventMetadata.ts +34 -0
- package/src/events/NDKMCPTool.ts +60 -0
- package/src/events/NDKProjectStatus.ts +384 -0
- package/src/events/index.ts +4 -0
- package/src/index.ts +126 -0
- package/src/lib/agent-home.ts +334 -0
- package/src/lib/error-formatter.ts +200 -0
- package/src/lib/fs/filesystem.ts +128 -0
- package/src/lib/fs/index.ts +1 -0
- package/src/lib/json-parser.ts +30 -0
- package/src/lib/string.ts +15 -0
- package/src/lib/time.ts +74 -0
- package/src/llm/ChunkHandler.ts +277 -0
- package/src/llm/FinishHandler.ts +250 -0
- package/src/llm/LLMConfigEditor.ts +154 -0
- package/src/llm/LLMServiceFactory.ts +230 -0
- package/src/llm/MessageProcessor.ts +90 -0
- package/src/llm/RecordingState.ts +37 -0
- package/src/llm/StreamPublisher.ts +40 -0
- package/src/llm/TracingUtils.ts +77 -0
- package/src/llm/chunk-validators.ts +57 -0
- package/src/llm/constants.ts +6 -0
- package/src/llm/index.ts +12 -0
- package/src/llm/meta/MetaModelResolver.ts +352 -0
- package/src/llm/meta/index.ts +11 -0
- package/src/llm/middleware/flight-recorder.ts +188 -0
- package/src/llm/providers/MockProvider.ts +332 -0
- package/src/llm/providers/agent/ClaudeCodeProvider.ts +343 -0
- package/src/llm/providers/agent/ClaudeCodeToolsAdapter.ts +203 -0
- package/src/llm/providers/agent/CodexAppServerProvider.ts +214 -0
- package/src/llm/providers/agent/CodexAppServerToolsAdapter.ts +91 -0
- package/src/llm/providers/agent/index.ts +10 -0
- package/src/llm/providers/base/AgentProvider.ts +107 -0
- package/src/llm/providers/base/BaseProvider.ts +114 -0
- package/src/llm/providers/base/StandardProvider.ts +38 -0
- package/src/llm/providers/base/index.ts +9 -0
- package/src/llm/providers/index.ts +106 -0
- package/src/llm/providers/key-manager.ts +238 -0
- package/src/llm/providers/ollama-models.ts +105 -0
- package/src/llm/providers/openrouter-models.ts +102 -0
- package/src/llm/providers/provider-ids.ts +18 -0
- package/src/llm/providers/registry/ProviderRegistry.ts +414 -0
- package/src/llm/providers/registry/index.ts +7 -0
- package/src/llm/providers/standard/AnthropicProvider.ts +71 -0
- package/src/llm/providers/standard/OllamaProvider.ts +59 -0
- package/src/llm/providers/standard/OpenAIProvider.ts +44 -0
- package/src/llm/providers/standard/OpenRouterProvider.ts +103 -0
- package/src/llm/providers/standard/index.ts +10 -0
- package/src/llm/providers/types.ts +194 -0
- package/src/llm/providers/usage-metadata.ts +78 -0
- package/src/llm/service.ts +713 -0
- package/src/llm/types.ts +167 -0
- package/src/llm/utils/ConfigurationManager.ts +650 -0
- package/src/llm/utils/ConfigurationTester.ts +229 -0
- package/src/llm/utils/ModelSelector.ts +212 -0
- package/src/llm/utils/ProviderConfigUI.ts +177 -0
- package/src/llm/utils/claudeCodePromptCompiler.ts +141 -0
- package/src/llm/utils/codex-models.ts +53 -0
- package/src/llm/utils/context-window-cache.ts +30 -0
- package/src/llm/utils/models-dev-cache.ts +267 -0
- package/src/llm/utils/provider-setup.ts +50 -0
- package/src/llm/utils/tool-errors.ts +78 -0
- package/src/llm/utils/usage.ts +74 -0
- package/src/logging/EventRoutingLogger.ts +205 -0
- package/src/nostr/AgentEventDecoder.ts +357 -0
- package/src/nostr/AgentEventEncoder.ts +677 -0
- package/src/nostr/AgentProfilePublisher.ts +657 -0
- package/src/nostr/AgentPublisher.ts +437 -0
- package/src/nostr/BlossomService.ts +226 -0
- package/src/nostr/InterventionPublisher.ts +132 -0
- package/src/nostr/TagExtractor.ts +228 -0
- package/src/nostr/collectEvents.ts +83 -0
- package/src/nostr/constants.ts +38 -0
- package/src/nostr/encryption.ts +26 -0
- package/src/nostr/index.ts +31 -0
- package/src/nostr/keys.ts +17 -0
- package/src/nostr/kinds.ts +37 -0
- package/src/nostr/ndkClient.ts +72 -0
- package/src/nostr/relays.ts +43 -0
- package/src/nostr/trace-context.ts +39 -0
- package/src/nostr/types.ts +227 -0
- package/src/nostr/utils.ts +84 -0
- package/src/prompts/core/FragmentRegistry.ts +30 -0
- package/src/prompts/core/PromptBuilder.ts +98 -0
- package/src/prompts/core/index.ts +3 -0
- package/src/prompts/core/types.ts +13 -0
- package/src/prompts/fragments/00-global-system-prompt.ts +44 -0
- package/src/prompts/fragments/01-agent-identity.ts +69 -0
- package/src/prompts/fragments/02-agent-home-directory.ts +114 -0
- package/src/prompts/fragments/03-system-reminders-explanation.ts +14 -0
- package/src/prompts/fragments/04-relay-configuration.ts +38 -0
- package/src/prompts/fragments/05-delegation-chain.ts +45 -0
- package/src/prompts/fragments/06-agent-todos.ts +74 -0
- package/src/prompts/fragments/06-todo-usage-guidance.ts +34 -0
- package/src/prompts/fragments/07-meta-project-context.ts +234 -0
- package/src/prompts/fragments/08-active-conversations.ts +382 -0
- package/src/prompts/fragments/09-recent-conversations.ts +153 -0
- package/src/prompts/fragments/10-referenced-article.ts +21 -0
- package/src/prompts/fragments/11-nudges.ts +134 -0
- package/src/prompts/fragments/12-skills.ts +127 -0
- package/src/prompts/fragments/13-available-nudges.ts +122 -0
- package/src/prompts/fragments/15-available-agents.ts +53 -0
- package/src/prompts/fragments/16-stay-in-your-lane.ts +41 -0
- package/src/prompts/fragments/17-todo-before-delegation.ts +39 -0
- package/src/prompts/fragments/20-voice-mode.ts +62 -0
- package/src/prompts/fragments/22-scheduled-tasks.ts +175 -0
- package/src/prompts/fragments/24-retrieved-lessons.ts +26 -0
- package/src/prompts/fragments/25-rag-instructions.ts +333 -0
- package/src/prompts/fragments/26-mcp-resources.ts +237 -0
- package/src/prompts/fragments/27-memorized-reports.ts +77 -0
- package/src/prompts/fragments/28-agent-directed-monitoring.ts +32 -0
- package/src/prompts/fragments/29-rag-collections.ts +50 -0
- package/src/prompts/fragments/30-worktree-context.ts +98 -0
- package/src/prompts/fragments/31-agents-md-guidance.ts +96 -0
- package/src/prompts/fragments/32-process-metrics.ts +72 -0
- package/src/prompts/fragments/debug-mode.ts +48 -0
- package/src/prompts/fragments/delegation-completion.ts +44 -0
- package/src/prompts/fragments/index.ts +91 -0
- package/src/prompts/index.ts +21 -0
- package/src/prompts/utils/systemPromptBuilder.ts +777 -0
- package/src/scripts/migrate-prefix-index.ts +157 -0
- package/src/services/AgentDefinitionMonitor.ts +701 -0
- package/src/services/ConfigService.ts +723 -0
- package/src/services/CooldownRegistry.ts +199 -0
- package/src/services/LLMOperationsRegistry.ts +424 -0
- package/src/services/OwnerAgentListService.ts +354 -0
- package/src/services/PubkeyService.ts +308 -0
- package/src/services/agents/AgentMetadataStore.ts +72 -0
- package/src/services/agents/AgentResolution.ts +59 -0
- package/src/services/agents/EscalationService.ts +281 -0
- package/src/services/agents/NDKAgentDiscovery.ts +95 -0
- package/src/services/agents/index.ts +7 -0
- package/src/services/agents-md/AgentsMdService.ts +184 -0
- package/src/services/agents-md/SystemReminderInjector.ts +238 -0
- package/src/services/agents-md/index.ts +11 -0
- package/src/services/apns/APNsClient.ts +203 -0
- package/src/services/apns/APNsService.ts +358 -0
- package/src/services/apns/index.ts +11 -0
- package/src/services/apns/types.ts +80 -0
- package/src/services/compression/CompressionService.ts +445 -0
- package/src/services/compression/compression-schema.ts +28 -0
- package/src/services/compression/compression-types.ts +74 -0
- package/src/services/compression/compression-utils.ts +587 -0
- package/src/services/config/types.ts +394 -0
- package/src/services/dispatch/AgentDispatchService.ts +937 -0
- package/src/services/dispatch/AgentRouter.ts +181 -0
- package/src/services/dispatch/DelegationCompletionHandler.ts +232 -0
- package/src/services/embedding/EmbeddingProvider.ts +188 -0
- package/src/services/embedding/index.ts +5 -0
- package/src/services/event-context/EventContextService.ts +108 -0
- package/src/services/event-context/index.ts +2 -0
- package/src/services/heuristics/ContextBuilder.ts +106 -0
- package/src/services/heuristics/HeuristicEngine.ts +200 -0
- package/src/services/heuristics/formatters.ts +58 -0
- package/src/services/heuristics/index.ts +12 -0
- package/src/services/heuristics/rules/index.ts +25 -0
- package/src/services/heuristics/rules/todoBeforeDelegation.ts +69 -0
- package/src/services/heuristics/rules/todoReminderOnToolUse.ts +63 -0
- package/src/services/heuristics/types.ts +144 -0
- package/src/services/image/ImageGenerationService.ts +389 -0
- package/src/services/image/index.ts +12 -0
- package/src/services/intervention/InterventionService.ts +1352 -0
- package/src/services/intervention/index.ts +7 -0
- package/src/services/mcp/MCPManager.ts +683 -0
- package/src/services/mcp/McpNotificationDelivery.ts +139 -0
- package/src/services/mcp/McpSubscriptionService.ts +653 -0
- package/src/services/mcp/mcpInstaller.ts +130 -0
- package/src/services/nip46/Nip46SigningLog.ts +81 -0
- package/src/services/nip46/Nip46SigningService.ts +467 -0
- package/src/services/nip46/index.ts +4 -0
- package/src/services/nudge/NudgeService.ts +224 -0
- package/src/services/nudge/NudgeWhitelistService.ts +382 -0
- package/src/services/nudge/index.ts +5 -0
- package/src/services/nudge/types.ts +83 -0
- package/src/services/projects/ProjectContext.ts +672 -0
- package/src/services/projects/ProjectContextStore.ts +102 -0
- package/src/services/projects/index.ts +6 -0
- package/src/services/prompt-compiler/index.ts +15 -0
- package/src/services/prompt-compiler/prompt-compiler-service.ts +1143 -0
- package/src/services/pubkey-gate/PubkeyGateService.ts +93 -0
- package/src/services/pubkey-gate/index.ts +1 -0
- package/src/services/rag/EmbeddingProviderFactory.ts +292 -0
- package/src/services/rag/LanceDBMaintenanceService.ts +211 -0
- package/src/services/rag/RAGDatabaseService.ts +173 -0
- package/src/services/rag/RAGOperations.ts +682 -0
- package/src/services/rag/RAGService.ts +240 -0
- package/src/services/rag/RagSubscriptionService.ts +618 -0
- package/src/services/rag/rag-utils.ts +174 -0
- package/src/services/ral/PendingDelegationsRegistry.ts +168 -0
- package/src/services/ral/RALRegistry.ts +2782 -0
- package/src/services/ral/index.ts +4 -0
- package/src/services/ral/types.ts +292 -0
- package/src/services/reports/LocalReportStore.ts +380 -0
- package/src/services/reports/ReportEmbeddingService.ts +430 -0
- package/src/services/reports/ReportService.ts +440 -0
- package/src/services/reports/articleUtils.ts +52 -0
- package/src/services/reports/index.ts +7 -0
- package/src/services/scheduling/SchedulerService.ts +1057 -0
- package/src/services/scheduling/errors.ts +14 -0
- package/src/services/scheduling/index.ts +7 -0
- package/src/services/scheduling/utils.ts +77 -0
- package/src/services/search/SearchProviderRegistry.ts +78 -0
- package/src/services/search/UnifiedSearchService.ts +218 -0
- package/src/services/search/index.ts +47 -0
- package/src/services/search/projectFilter.ts +22 -0
- package/src/services/search/providers/ConversationSearchProvider.ts +48 -0
- package/src/services/search/providers/LessonSearchProvider.ts +75 -0
- package/src/services/search/providers/ReportSearchProvider.ts +49 -0
- package/src/services/search/types.ts +144 -0
- package/src/services/skill/SkillService.ts +482 -0
- package/src/services/skill/index.ts +2 -0
- package/src/services/skill/types.ts +70 -0
- package/src/services/status/OperationsStatusService.ts +276 -0
- package/src/services/status/ProjectStatusService.ts +522 -0
- package/src/services/status/index.ts +11 -0
- package/src/services/storage/PrefixKVStore.ts +242 -0
- package/src/services/storage/index.ts +1 -0
- package/src/services/system-reminder/SystemReminderUtils.ts +96 -0
- package/src/services/system-reminder/index.ts +7 -0
- package/src/services/trust-pubkeys/TrustPubkeyService.ts +325 -0
- package/src/services/trust-pubkeys/index.ts +2 -0
- package/src/telemetry/ConversationSpanManager.ts +111 -0
- package/src/telemetry/EventLoopMonitor.ts +206 -0
- package/src/telemetry/LLMSpanRegistry.ts +20 -0
- package/src/telemetry/NostrSpanProcessor.ts +89 -0
- package/src/telemetry/ToolCallSpanProcessor.ts +66 -0
- package/src/telemetry/diagnostics.ts +27 -0
- package/src/telemetry/setup.ts +120 -0
- package/src/tools/implementations/agents_discover.ts +121 -0
- package/src/tools/implementations/agents_hire.ts +127 -0
- package/src/tools/implementations/agents_list.ts +96 -0
- package/src/tools/implementations/agents_publish.ts +611 -0
- package/src/tools/implementations/agents_read.ts +173 -0
- package/src/tools/implementations/agents_write.ts +200 -0
- package/src/tools/implementations/ask.ts +411 -0
- package/src/tools/implementations/change_model.ts +141 -0
- package/src/tools/implementations/conversation_get.ts +661 -0
- package/src/tools/implementations/conversation_list.ts +377 -0
- package/src/tools/implementations/conversation_search.ts +370 -0
- package/src/tools/implementations/delegate.ts +327 -0
- package/src/tools/implementations/delegate_crossproject.ts +209 -0
- package/src/tools/implementations/delegate_followup.ts +300 -0
- package/src/tools/implementations/fs_edit.ts +162 -0
- package/src/tools/implementations/fs_glob.ts +182 -0
- package/src/tools/implementations/fs_grep.ts +513 -0
- package/src/tools/implementations/fs_read.ts +332 -0
- package/src/tools/implementations/fs_write.ts +113 -0
- package/src/tools/implementations/generate_image.ts +259 -0
- package/src/tools/implementations/home_fs.ts +515 -0
- package/src/tools/implementations/kill.ts +651 -0
- package/src/tools/implementations/learn.ts +166 -0
- package/src/tools/implementations/lesson-formatter.ts +38 -0
- package/src/tools/implementations/lesson_delete.ts +164 -0
- package/src/tools/implementations/lesson_get.ts +105 -0
- package/src/tools/implementations/lessons_list.ts +153 -0
- package/src/tools/implementations/mcp_resource_read.ts +161 -0
- package/src/tools/implementations/mcp_subscribe.ts +158 -0
- package/src/tools/implementations/mcp_subscription_stop.ts +85 -0
- package/src/tools/implementations/nostr_fetch.ts +149 -0
- package/src/tools/implementations/nostr_publish_as_user.ts +353 -0
- package/src/tools/implementations/project_list.ts +146 -0
- package/src/tools/implementations/rag_add_documents.ts +573 -0
- package/src/tools/implementations/rag_create_collection.ts +65 -0
- package/src/tools/implementations/rag_delete_collection.ts +68 -0
- package/src/tools/implementations/rag_list_collections.ts +77 -0
- package/src/tools/implementations/rag_query.ts +107 -0
- package/src/tools/implementations/rag_subscription_create.ts +105 -0
- package/src/tools/implementations/rag_subscription_delete.ts +80 -0
- package/src/tools/implementations/rag_subscription_get.ts +123 -0
- package/src/tools/implementations/rag_subscription_list.ts +128 -0
- package/src/tools/implementations/report_delete.ts +79 -0
- package/src/tools/implementations/report_read.ts +160 -0
- package/src/tools/implementations/report_write.ts +278 -0
- package/src/tools/implementations/reports_list.ts +77 -0
- package/src/tools/implementations/schedule_task.ts +104 -0
- package/src/tools/implementations/schedule_task_cancel.ts +62 -0
- package/src/tools/implementations/schedule_task_once.ts +128 -0
- package/src/tools/implementations/schedule_tasks_list.ts +79 -0
- package/src/tools/implementations/search.ts +160 -0
- package/src/tools/implementations/shell.ts +553 -0
- package/src/tools/implementations/todo.ts +260 -0
- package/src/tools/implementations/upload_blob.ts +381 -0
- package/src/tools/implementations/web_fetch.ts +153 -0
- package/src/tools/implementations/web_search.ts +250 -0
- package/src/tools/registry.ts +670 -0
- package/src/tools/types.ts +177 -0
- package/src/tools/utils.ts +256 -0
- package/src/types/event-ids.ts +320 -0
- package/src/types/index.ts +46 -0
- package/src/utils/agentFetcher.ts +107 -0
- package/src/utils/cli-error.ts +29 -0
- package/src/utils/conversation-id.ts +27 -0
- package/src/utils/conversation-utils.ts +1 -0
- package/src/utils/delegation-chain.ts +357 -0
- package/src/utils/error-handler.ts +42 -0
- package/src/utils/git/gitignore.ts +69 -0
- package/src/utils/git/index.ts +2 -0
- package/src/utils/git/initializeGitRepo.ts +204 -0
- package/src/utils/git/worktree.ts +260 -0
- package/src/utils/lessonFormatter.ts +70 -0
- package/src/utils/lessonTrust.ts +24 -0
- package/src/utils/lockfile.ts +123 -0
- package/src/utils/logger.ts +149 -0
- package/src/utils/nostr-entity-parser.ts +365 -0
- package/src/utils/process.ts +49 -0
- package/src/wrapper.ts +262 -0
- package/tsconfig.json +41 -0
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
import type { LLMConfiguration, MetaModelConfiguration, MetaModelVariant, TenexLLMs } from "@/services/config/types";
|
|
2
|
+
import { hasApiKey } from "@/llm/providers/key-manager";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extended type for editor use - includes providers
|
|
6
|
+
*/
|
|
7
|
+
type TenexLLMsWithProviders = TenexLLMs & {
|
|
8
|
+
providers: Record<string, { apiKey: string | string[] }>;
|
|
9
|
+
};
|
|
10
|
+
import chalk from "chalk";
|
|
11
|
+
import inquirer from "inquirer";
|
|
12
|
+
import { PROVIDER_IDS } from "@/llm/providers/provider-ids";
|
|
13
|
+
import type { AISdkProvider } from "../types";
|
|
14
|
+
import { ModelSelector } from "./ModelSelector";
|
|
15
|
+
import { ProviderConfigUI } from "./ProviderConfigUI";
|
|
16
|
+
import { listCodexModels, formatCodexModel } from "./codex-models";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Manages LLM configuration CRUD operations
|
|
20
|
+
*/
|
|
21
|
+
export class ConfigurationManager {
|
|
22
|
+
static async add(llmsConfig: TenexLLMsWithProviders, isFirstConfig = false): Promise<void> {
|
|
23
|
+
const configuredProviders = Object.keys(llmsConfig.providers).filter(
|
|
24
|
+
(p) => hasApiKey(llmsConfig.providers[p]?.apiKey)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if (configuredProviders.length === 0) {
|
|
28
|
+
console.log(
|
|
29
|
+
chalk.yellow("⚠️ No providers configured. Please configure API keys first.")
|
|
30
|
+
);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Select provider
|
|
35
|
+
const { provider } = await inquirer.prompt([
|
|
36
|
+
{
|
|
37
|
+
type: "select",
|
|
38
|
+
name: "provider",
|
|
39
|
+
message: "Select provider:",
|
|
40
|
+
choices: configuredProviders.map((p) => ({
|
|
41
|
+
name: ProviderConfigUI.getProviderDisplayName(p),
|
|
42
|
+
value: p,
|
|
43
|
+
})),
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
// Select model based on provider
|
|
48
|
+
let model: string;
|
|
49
|
+
let reasoningEffort: string | undefined;
|
|
50
|
+
|
|
51
|
+
if (provider === "openrouter") {
|
|
52
|
+
model = await ModelSelector.selectOpenRouterModel();
|
|
53
|
+
} else if (provider === "ollama") {
|
|
54
|
+
model = await ModelSelector.selectOllamaModel();
|
|
55
|
+
} else if (provider === PROVIDER_IDS.CODEX_APP_SERVER) {
|
|
56
|
+
// For Codex, show available models with reasoning efforts
|
|
57
|
+
const result = await ConfigurationManager.selectCodexModel();
|
|
58
|
+
model = result.model;
|
|
59
|
+
reasoningEffort = result.reasoningEffort;
|
|
60
|
+
} else {
|
|
61
|
+
const { inputModel } = await inquirer.prompt([
|
|
62
|
+
{
|
|
63
|
+
type: "input",
|
|
64
|
+
name: "inputModel",
|
|
65
|
+
message: "Enter model name:",
|
|
66
|
+
default: ConfigurationManager.getDefaultModelForProvider(
|
|
67
|
+
provider as AISdkProvider
|
|
68
|
+
),
|
|
69
|
+
validate: (input: string) => {
|
|
70
|
+
if (!input.trim()) return "Model name is required";
|
|
71
|
+
return true;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
75
|
+
model = inputModel;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Optional settings
|
|
79
|
+
const { temperature, maxTokens } = await inquirer.prompt([
|
|
80
|
+
{
|
|
81
|
+
type: "input",
|
|
82
|
+
name: "temperature",
|
|
83
|
+
message: "Temperature (0-2, press enter to skip):",
|
|
84
|
+
validate: (input: string) => {
|
|
85
|
+
if (!input) return true;
|
|
86
|
+
const num = Number.parseFloat(input);
|
|
87
|
+
if (Number.isNaN(num) || num < 0 || num > 2)
|
|
88
|
+
return "Temperature must be between 0 and 2";
|
|
89
|
+
return true;
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "input",
|
|
94
|
+
name: "maxTokens",
|
|
95
|
+
message: "Max tokens (press enter to skip):",
|
|
96
|
+
validate: (input: string) => {
|
|
97
|
+
if (!input) return true;
|
|
98
|
+
const num = Number.parseInt(input);
|
|
99
|
+
if (Number.isNaN(num) || num <= 0)
|
|
100
|
+
return "Max tokens must be a positive number";
|
|
101
|
+
return true;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
// Name the configuration
|
|
107
|
+
const { name } = await inquirer.prompt([
|
|
108
|
+
{
|
|
109
|
+
type: "input",
|
|
110
|
+
name: "name",
|
|
111
|
+
message: "Configuration name:",
|
|
112
|
+
default: isFirstConfig ? "default" : undefined,
|
|
113
|
+
validate: (input: string) => {
|
|
114
|
+
if (!input.trim()) return "Name is required";
|
|
115
|
+
if (llmsConfig.configurations[input]) return "Configuration already exists";
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
// Create configuration
|
|
122
|
+
const config: LLMConfiguration = {
|
|
123
|
+
provider,
|
|
124
|
+
model,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
if (temperature) config.temperature = Number.parseFloat(temperature);
|
|
128
|
+
if (maxTokens) config.maxTokens = Number.parseInt(maxTokens);
|
|
129
|
+
if (reasoningEffort) config.reasoningEffort = reasoningEffort as LLMConfiguration["reasoningEffort"];
|
|
130
|
+
|
|
131
|
+
llmsConfig.configurations[name] = config;
|
|
132
|
+
|
|
133
|
+
// Set as default if first or ask user
|
|
134
|
+
if (isFirstConfig || !llmsConfig.default) {
|
|
135
|
+
llmsConfig.default = name;
|
|
136
|
+
console.log(chalk.green(`✅ Configuration "${name}" created and set as default`));
|
|
137
|
+
} else {
|
|
138
|
+
const { setAsDefault } = await inquirer.prompt([
|
|
139
|
+
{
|
|
140
|
+
type: "confirm",
|
|
141
|
+
name: "setAsDefault",
|
|
142
|
+
message: "Set as default configuration?",
|
|
143
|
+
default: false,
|
|
144
|
+
},
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
if (setAsDefault) {
|
|
148
|
+
llmsConfig.default = name;
|
|
149
|
+
}
|
|
150
|
+
console.log(chalk.green(`✅ Configuration "${name}" created`));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Create a meta model configuration with multiple variants
|
|
156
|
+
*/
|
|
157
|
+
static async addMetaModel(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
158
|
+
// Get existing non-meta configurations to use as variants
|
|
159
|
+
const standardConfigs = Object.keys(llmsConfig.configurations).filter((name) => {
|
|
160
|
+
const config = llmsConfig.configurations[name];
|
|
161
|
+
return config.provider !== "meta";
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (standardConfigs.length < 2) {
|
|
165
|
+
console.log(
|
|
166
|
+
chalk.yellow(
|
|
167
|
+
"⚠️ You need at least 2 standard LLM configurations to create a meta model."
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
console.log(
|
|
171
|
+
chalk.gray(" Create more configurations first with 'Add new configuration'.")
|
|
172
|
+
);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
console.log(chalk.cyan("\n=== Create Meta Model ===\n"));
|
|
177
|
+
console.log(
|
|
178
|
+
chalk.gray(
|
|
179
|
+
"Meta models let you switch between different models using keywords.\n" +
|
|
180
|
+
"For example, starting a message with 'ultrathink' can trigger a more powerful model.\n"
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// Get meta model name
|
|
185
|
+
const { metaName } = await inquirer.prompt([
|
|
186
|
+
{
|
|
187
|
+
type: "input",
|
|
188
|
+
name: "metaName",
|
|
189
|
+
message: "Meta model name:",
|
|
190
|
+
validate: (input: string) => {
|
|
191
|
+
if (!input.trim()) return "Name is required";
|
|
192
|
+
if (llmsConfig.configurations[input]) return "Configuration already exists";
|
|
193
|
+
return true;
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
]);
|
|
197
|
+
|
|
198
|
+
// Get optional description
|
|
199
|
+
const { description } = await inquirer.prompt([
|
|
200
|
+
{
|
|
201
|
+
type: "input",
|
|
202
|
+
name: "description",
|
|
203
|
+
message: "Description (shown in system prompt, press enter to skip):",
|
|
204
|
+
},
|
|
205
|
+
]);
|
|
206
|
+
|
|
207
|
+
// Create variants
|
|
208
|
+
const variants: Record<string, MetaModelVariant> = {};
|
|
209
|
+
let addMoreVariants = true;
|
|
210
|
+
let variantCount = 0;
|
|
211
|
+
|
|
212
|
+
console.log(chalk.cyan("\nNow let's add variants to your meta model.\n"));
|
|
213
|
+
|
|
214
|
+
while (addMoreVariants) {
|
|
215
|
+
variantCount++;
|
|
216
|
+
console.log(chalk.bold(`\n--- Variant ${variantCount} ---`));
|
|
217
|
+
|
|
218
|
+
// Variant name
|
|
219
|
+
const { variantName } = await inquirer.prompt([
|
|
220
|
+
{
|
|
221
|
+
type: "input",
|
|
222
|
+
name: "variantName",
|
|
223
|
+
message: "Variant name (e.g., 'fast', 'standard', 'deep'):",
|
|
224
|
+
validate: (input: string) => {
|
|
225
|
+
if (!input.trim()) return "Name is required";
|
|
226
|
+
if (variants[input]) return "Variant already exists";
|
|
227
|
+
return true;
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
]);
|
|
231
|
+
|
|
232
|
+
// Select underlying model
|
|
233
|
+
const { model } = await inquirer.prompt([
|
|
234
|
+
{
|
|
235
|
+
type: "select",
|
|
236
|
+
name: "model",
|
|
237
|
+
message: "Select underlying model for this variant:",
|
|
238
|
+
choices: standardConfigs.map((n) => ({
|
|
239
|
+
name: n,
|
|
240
|
+
value: n,
|
|
241
|
+
})),
|
|
242
|
+
},
|
|
243
|
+
]);
|
|
244
|
+
|
|
245
|
+
// Keywords (comma-separated)
|
|
246
|
+
const { keywordsInput } = await inquirer.prompt([
|
|
247
|
+
{
|
|
248
|
+
type: "input",
|
|
249
|
+
name: "keywordsInput",
|
|
250
|
+
message: "Trigger keywords (comma-separated, e.g., 'think,ponder'):",
|
|
251
|
+
},
|
|
252
|
+
]);
|
|
253
|
+
|
|
254
|
+
const keywords = keywordsInput
|
|
255
|
+
? keywordsInput
|
|
256
|
+
.split(",")
|
|
257
|
+
.map((k: string) => k.trim().toLowerCase())
|
|
258
|
+
.filter((k: string) => k.length > 0)
|
|
259
|
+
: [];
|
|
260
|
+
|
|
261
|
+
// Variant description
|
|
262
|
+
const { variantDescription } = await inquirer.prompt([
|
|
263
|
+
{
|
|
264
|
+
type: "input",
|
|
265
|
+
name: "variantDescription",
|
|
266
|
+
message: "Variant description (shown in system prompt):",
|
|
267
|
+
},
|
|
268
|
+
]);
|
|
269
|
+
|
|
270
|
+
// Tier (priority)
|
|
271
|
+
const { tier } = await inquirer.prompt([
|
|
272
|
+
{
|
|
273
|
+
type: "number",
|
|
274
|
+
name: "tier",
|
|
275
|
+
message: "Priority tier (higher = higher priority when keywords conflict):",
|
|
276
|
+
default: variantCount,
|
|
277
|
+
},
|
|
278
|
+
]);
|
|
279
|
+
|
|
280
|
+
// Optional system prompt
|
|
281
|
+
const { variantSystemPrompt } = await inquirer.prompt([
|
|
282
|
+
{
|
|
283
|
+
type: "input",
|
|
284
|
+
name: "variantSystemPrompt",
|
|
285
|
+
message: "Additional system prompt (press enter to skip):",
|
|
286
|
+
},
|
|
287
|
+
]);
|
|
288
|
+
|
|
289
|
+
// Create variant
|
|
290
|
+
const variant: MetaModelVariant = {
|
|
291
|
+
model,
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
if (keywords.length > 0) variant.keywords = keywords;
|
|
295
|
+
if (variantDescription) variant.description = variantDescription;
|
|
296
|
+
if (tier) variant.tier = tier;
|
|
297
|
+
if (variantSystemPrompt) variant.systemPrompt = variantSystemPrompt;
|
|
298
|
+
|
|
299
|
+
variants[variantName] = variant;
|
|
300
|
+
|
|
301
|
+
console.log(chalk.green(`✓ Added variant "${variantName}" → ${model}`));
|
|
302
|
+
|
|
303
|
+
// Ask if more variants
|
|
304
|
+
if (variantCount >= 2) {
|
|
305
|
+
const { addMore } = await inquirer.prompt([
|
|
306
|
+
{
|
|
307
|
+
type: "confirm",
|
|
308
|
+
name: "addMore",
|
|
309
|
+
message: "Add another variant?",
|
|
310
|
+
default: false,
|
|
311
|
+
},
|
|
312
|
+
]);
|
|
313
|
+
addMoreVariants = addMore;
|
|
314
|
+
} else {
|
|
315
|
+
console.log(chalk.gray("(Meta models need at least 2 variants)"));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Select default variant
|
|
320
|
+
const variantNames = Object.keys(variants);
|
|
321
|
+
const { defaultVariant } = await inquirer.prompt([
|
|
322
|
+
{
|
|
323
|
+
type: "select",
|
|
324
|
+
name: "defaultVariant",
|
|
325
|
+
message: "Select default variant (used when no keyword matches):",
|
|
326
|
+
choices: variantNames.map((n) => ({
|
|
327
|
+
name: n,
|
|
328
|
+
value: n,
|
|
329
|
+
})),
|
|
330
|
+
},
|
|
331
|
+
]);
|
|
332
|
+
|
|
333
|
+
// Create meta model configuration
|
|
334
|
+
const metaConfig: MetaModelConfiguration = {
|
|
335
|
+
provider: "meta",
|
|
336
|
+
variants,
|
|
337
|
+
default: defaultVariant,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
if (description) metaConfig.description = description;
|
|
341
|
+
|
|
342
|
+
llmsConfig.configurations[metaName] = metaConfig;
|
|
343
|
+
|
|
344
|
+
// Ask if should be set as default
|
|
345
|
+
const { setAsDefault } = await inquirer.prompt([
|
|
346
|
+
{
|
|
347
|
+
type: "confirm",
|
|
348
|
+
name: "setAsDefault",
|
|
349
|
+
message: "Set as default configuration?",
|
|
350
|
+
default: false,
|
|
351
|
+
},
|
|
352
|
+
]);
|
|
353
|
+
|
|
354
|
+
if (setAsDefault) {
|
|
355
|
+
llmsConfig.default = metaName;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
console.log(chalk.green(`\n✅ Meta model "${metaName}" created with ${variantCount} variants`));
|
|
359
|
+
|
|
360
|
+
// Show summary
|
|
361
|
+
console.log(chalk.cyan("\nVariant summary:"));
|
|
362
|
+
for (const [name, variant] of Object.entries(variants)) {
|
|
363
|
+
const keywords = variant.keywords?.length ? ` (triggers: ${variant.keywords.join(", ")})` : "";
|
|
364
|
+
const isDefault = name === defaultVariant ? chalk.yellow(" [default]") : "";
|
|
365
|
+
console.log(chalk.gray(` • ${name} → ${variant.model}${keywords}${isDefault}`));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
static async delete(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
370
|
+
const configNames = Object.keys(llmsConfig.configurations);
|
|
371
|
+
|
|
372
|
+
if (configNames.length === 0) {
|
|
373
|
+
console.log(chalk.yellow("⚠️ No configurations to delete"));
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const { name } = await inquirer.prompt([
|
|
378
|
+
{
|
|
379
|
+
type: "select",
|
|
380
|
+
name: "name",
|
|
381
|
+
message: "Select configuration to delete:",
|
|
382
|
+
choices: configNames.map((n) => ({
|
|
383
|
+
name: n === llmsConfig.default ? `${n} (default)` : n,
|
|
384
|
+
value: n,
|
|
385
|
+
})),
|
|
386
|
+
},
|
|
387
|
+
]);
|
|
388
|
+
|
|
389
|
+
const { confirm } = await inquirer.prompt([
|
|
390
|
+
{
|
|
391
|
+
type: "confirm",
|
|
392
|
+
name: "confirm",
|
|
393
|
+
message: `Are you sure you want to delete "${name}"?`,
|
|
394
|
+
default: false,
|
|
395
|
+
},
|
|
396
|
+
]);
|
|
397
|
+
|
|
398
|
+
if (confirm) {
|
|
399
|
+
delete llmsConfig.configurations[name];
|
|
400
|
+
|
|
401
|
+
// Update default if needed
|
|
402
|
+
if (llmsConfig.default === name) {
|
|
403
|
+
const remaining = Object.keys(llmsConfig.configurations);
|
|
404
|
+
llmsConfig.default = remaining.length > 0 ? remaining[0] : undefined;
|
|
405
|
+
|
|
406
|
+
if (llmsConfig.default) {
|
|
407
|
+
console.log(chalk.yellow(`Default changed to "${llmsConfig.default}"`));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
console.log(chalk.green(`✅ Configuration "${name}" deleted`));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
static async setDefault(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
416
|
+
const configNames = Object.keys(llmsConfig.configurations);
|
|
417
|
+
|
|
418
|
+
if (configNames.length === 0) {
|
|
419
|
+
console.log(chalk.yellow("⚠️ No configurations available"));
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const { name } = await inquirer.prompt([
|
|
424
|
+
{
|
|
425
|
+
type: "select",
|
|
426
|
+
name: "name",
|
|
427
|
+
message: "Select default configuration:",
|
|
428
|
+
choices: configNames.map((n) => ({
|
|
429
|
+
name: n === llmsConfig.default ? `${n} (current default)` : n,
|
|
430
|
+
value: n,
|
|
431
|
+
})),
|
|
432
|
+
},
|
|
433
|
+
]);
|
|
434
|
+
|
|
435
|
+
llmsConfig.default = name;
|
|
436
|
+
console.log(chalk.green(`✅ Default configuration set to "${name}"`));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
static async setSummarizationModel(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
440
|
+
const configNames = Object.keys(llmsConfig.configurations);
|
|
441
|
+
|
|
442
|
+
if (configNames.length === 0) {
|
|
443
|
+
console.log(chalk.yellow("⚠️ No configurations available"));
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const { name } = await inquirer.prompt([
|
|
448
|
+
{
|
|
449
|
+
type: "select",
|
|
450
|
+
name: "name",
|
|
451
|
+
message: "Select summarization model:",
|
|
452
|
+
choices: configNames.map((n) => ({
|
|
453
|
+
name: n === llmsConfig.summarization ? `${n} (current)` : n,
|
|
454
|
+
value: n,
|
|
455
|
+
})),
|
|
456
|
+
},
|
|
457
|
+
]);
|
|
458
|
+
|
|
459
|
+
llmsConfig.summarization = name;
|
|
460
|
+
console.log(chalk.green(`✅ Summarization model set to "${name}"`));
|
|
461
|
+
|
|
462
|
+
// Offer to test the configuration
|
|
463
|
+
const { shouldTest } = await inquirer.prompt([
|
|
464
|
+
{
|
|
465
|
+
type: "confirm",
|
|
466
|
+
name: "shouldTest",
|
|
467
|
+
message: "Would you like to test this configuration with generateObject?",
|
|
468
|
+
default: true,
|
|
469
|
+
},
|
|
470
|
+
]);
|
|
471
|
+
|
|
472
|
+
if (shouldTest) {
|
|
473
|
+
const { ConfigurationTester } = await import("./ConfigurationTester");
|
|
474
|
+
await ConfigurationTester.testSummarization(llmsConfig, name);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
static async setSupervisionModel(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
479
|
+
const configNames = Object.keys(llmsConfig.configurations);
|
|
480
|
+
|
|
481
|
+
if (configNames.length === 0) {
|
|
482
|
+
console.log(chalk.yellow("⚠️ No configurations available"));
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
const { name } = await inquirer.prompt([
|
|
487
|
+
{
|
|
488
|
+
type: "select",
|
|
489
|
+
name: "name",
|
|
490
|
+
message: "Select supervision model:",
|
|
491
|
+
choices: configNames.map((n) => ({
|
|
492
|
+
name: n === llmsConfig.supervision ? `${n} (current)` : n,
|
|
493
|
+
value: n,
|
|
494
|
+
})),
|
|
495
|
+
},
|
|
496
|
+
]);
|
|
497
|
+
|
|
498
|
+
llmsConfig.supervision = name;
|
|
499
|
+
console.log(chalk.green(`✅ Supervision model set to "${name}"`));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
static async setSearchModel(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
503
|
+
const configNames = Object.keys(llmsConfig.configurations);
|
|
504
|
+
|
|
505
|
+
if (configNames.length === 0) {
|
|
506
|
+
console.log(chalk.yellow("⚠️ No configurations available"));
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const { name } = await inquirer.prompt([
|
|
511
|
+
{
|
|
512
|
+
type: "select",
|
|
513
|
+
name: "name",
|
|
514
|
+
message: "Select search model:",
|
|
515
|
+
choices: configNames.map((n) => ({
|
|
516
|
+
name: n === llmsConfig.search ? `${n} (current)` : n,
|
|
517
|
+
value: n,
|
|
518
|
+
})),
|
|
519
|
+
},
|
|
520
|
+
]);
|
|
521
|
+
|
|
522
|
+
llmsConfig.search = name;
|
|
523
|
+
console.log(chalk.green(`✅ Search model set to "${name}"`));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
static async setPromptCompilationModel(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
527
|
+
const configNames = Object.keys(llmsConfig.configurations);
|
|
528
|
+
|
|
529
|
+
if (configNames.length === 0) {
|
|
530
|
+
console.log(chalk.yellow("⚠️ No configurations available"));
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const { name } = await inquirer.prompt([
|
|
535
|
+
{
|
|
536
|
+
type: "select",
|
|
537
|
+
name: "name",
|
|
538
|
+
message: "Select prompt compilation model:",
|
|
539
|
+
choices: configNames.map((n) => ({
|
|
540
|
+
name: n === llmsConfig.promptCompilation ? `${n} (current)` : n,
|
|
541
|
+
value: n,
|
|
542
|
+
})),
|
|
543
|
+
},
|
|
544
|
+
]);
|
|
545
|
+
|
|
546
|
+
llmsConfig.promptCompilation = name;
|
|
547
|
+
console.log(chalk.green(`✅ Prompt compilation model set to "${name}"`));
|
|
548
|
+
console.log(chalk.gray(" This model is used to compile lessons into agent system prompts."));
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
static async setCompressionModel(llmsConfig: TenexLLMsWithProviders): Promise<void> {
|
|
552
|
+
const configNames = Object.keys(llmsConfig.configurations);
|
|
553
|
+
|
|
554
|
+
if (configNames.length === 0) {
|
|
555
|
+
console.log(chalk.yellow("⚠️ No configurations available"));
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const { name } = await inquirer.prompt([
|
|
560
|
+
{
|
|
561
|
+
type: "select",
|
|
562
|
+
name: "name",
|
|
563
|
+
message: "Select compression model:",
|
|
564
|
+
choices: configNames.map((n) => ({
|
|
565
|
+
name: n === llmsConfig.compression ? `${n} (current)` : n,
|
|
566
|
+
value: n,
|
|
567
|
+
})),
|
|
568
|
+
},
|
|
569
|
+
]);
|
|
570
|
+
|
|
571
|
+
llmsConfig.compression = name;
|
|
572
|
+
console.log(chalk.green(`✅ Compression model set to "${name}"`));
|
|
573
|
+
console.log(chalk.gray(" This model is used for conversation history compression."));
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Select a Codex model and reasoning effort interactively
|
|
578
|
+
*/
|
|
579
|
+
private static async selectCodexModel(): Promise<{ model: string; reasoningEffort?: string }> {
|
|
580
|
+
console.log(chalk.cyan("\nFetching available Codex models..."));
|
|
581
|
+
|
|
582
|
+
try {
|
|
583
|
+
const models = await listCodexModels();
|
|
584
|
+
|
|
585
|
+
if (models.length === 0) {
|
|
586
|
+
console.log(chalk.yellow("No models found. Using default."));
|
|
587
|
+
return { model: "gpt-5.1-codex-max" };
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Show models with details
|
|
591
|
+
console.log(chalk.bold("\nAvailable Codex Models:"));
|
|
592
|
+
for (const model of models) {
|
|
593
|
+
console.log(chalk.gray(formatCodexModel(model)));
|
|
594
|
+
}
|
|
595
|
+
console.log("");
|
|
596
|
+
|
|
597
|
+
// Select model
|
|
598
|
+
const { model } = await inquirer.prompt([
|
|
599
|
+
{
|
|
600
|
+
type: "select",
|
|
601
|
+
name: "model",
|
|
602
|
+
message: "Select model:",
|
|
603
|
+
choices: models.map((m) => ({
|
|
604
|
+
name: m.isDefault ? `${m.displayName} (default)` : m.displayName,
|
|
605
|
+
value: m.id,
|
|
606
|
+
})),
|
|
607
|
+
},
|
|
608
|
+
]);
|
|
609
|
+
|
|
610
|
+
// Find selected model to get its reasoning efforts
|
|
611
|
+
const selectedModel = models.find((m) => m.id === model);
|
|
612
|
+
if (!selectedModel || selectedModel.supportedReasoningEfforts.length === 0) {
|
|
613
|
+
return { model };
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Select reasoning effort
|
|
617
|
+
const { reasoningEffort } = await inquirer.prompt([
|
|
618
|
+
{
|
|
619
|
+
type: "select",
|
|
620
|
+
name: "reasoningEffort",
|
|
621
|
+
message: "Select reasoning effort:",
|
|
622
|
+
choices: [
|
|
623
|
+
{ name: "Use model default", value: undefined },
|
|
624
|
+
...selectedModel.supportedReasoningEfforts.map((e) => ({
|
|
625
|
+
name: e === selectedModel.defaultReasoningEffort ? `${e} (default)` : e,
|
|
626
|
+
value: e,
|
|
627
|
+
})),
|
|
628
|
+
],
|
|
629
|
+
},
|
|
630
|
+
]);
|
|
631
|
+
|
|
632
|
+
return { model, reasoningEffort };
|
|
633
|
+
} catch (error) {
|
|
634
|
+
console.log(chalk.yellow(`Could not fetch models: ${error}. Using default.`));
|
|
635
|
+
return { model: "gpt-5.1-codex-max" };
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
private static getDefaultModelForProvider(provider: AISdkProvider): string {
|
|
640
|
+
const defaults: Record<AISdkProvider, string> = {
|
|
641
|
+
[PROVIDER_IDS.OPENROUTER]: "openai/gpt-4",
|
|
642
|
+
[PROVIDER_IDS.ANTHROPIC]: "claude-3-5-sonnet-latest",
|
|
643
|
+
[PROVIDER_IDS.OPENAI]: "gpt-4",
|
|
644
|
+
[PROVIDER_IDS.OLLAMA]: "llama3.1:8b",
|
|
645
|
+
[PROVIDER_IDS.CLAUDE_CODE]: "claude-3-5-sonnet-20241022",
|
|
646
|
+
[PROVIDER_IDS.CODEX_APP_SERVER]: "gpt-5.1-codex-max",
|
|
647
|
+
};
|
|
648
|
+
return defaults[provider] || "";
|
|
649
|
+
}
|
|
650
|
+
}
|