tarsk 0.4.4 → 0.4.6
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/dist/index.js +447375 -37
- package/package.json +2 -2
- package/dist/agent/agent.error-utils.d.ts +0 -14
- package/dist/agent/agent.error-utils.js +0 -52
- package/dist/agent/agent.event-transformer.d.ts +0 -55
- package/dist/agent/agent.event-transformer.js +0 -175
- package/dist/agent/agent.executor.d.ts +0 -26
- package/dist/agent/agent.executor.js +0 -286
- package/dist/agent/agent.model-resolver.d.ts +0 -22
- package/dist/agent/agent.model-resolver.js +0 -67
- package/dist/agent/agent.process-manager.d.ts +0 -57
- package/dist/agent/agent.process-manager.js +0 -262
- package/dist/agent/agent.processing-state-manager.d.ts +0 -74
- package/dist/agent/agent.processing-state-manager.js +0 -87
- package/dist/agent/agent.prompt-loader.d.ts +0 -16
- package/dist/agent/agent.prompt-loader.js +0 -227
- package/dist/agent/agent.subagent-executor.d.ts +0 -35
- package/dist/agent/agent.subagent-executor.js +0 -135
- package/dist/bun/index.d.ts +0 -2
- package/dist/bun/index.js +0 -165
- package/dist/cli.d.ts +0 -3
- package/dist/cli.js +0 -22
- package/dist/core/crypto.d.ts +0 -29
- package/dist/core/crypto.js +0 -166
- package/dist/core/dev-server-cache.d.ts +0 -46
- package/dist/core/dev-server-cache.js +0 -59
- package/dist/core/env-manager.d.ts +0 -3
- package/dist/core/env-manager.js +0 -60
- package/dist/core/error-responses.d.ts +0 -61
- package/dist/core/error-responses.js +0 -64
- package/dist/core/logger.d.ts +0 -10
- package/dist/core/logger.js +0 -47
- package/dist/core/paths.d.ts +0 -22
- package/dist/core/paths.js +0 -26
- package/dist/core/random-words.d.ts +0 -18
- package/dist/core/random-words.js +0 -135
- package/dist/core/response-builder.d.ts +0 -50
- package/dist/core/response-builder.js +0 -56
- package/dist/core/route-helpers.d.ts +0 -47
- package/dist/core/route-helpers.js +0 -54
- package/dist/core/run-command-detector.d.ts +0 -26
- package/dist/core/run-command-detector.js +0 -98
- package/dist/core/stream-helper.d.ts +0 -44
- package/dist/core/stream-helper.js +0 -50
- package/dist/core/utils.d.ts +0 -43
- package/dist/core/utils.js +0 -113
- package/dist/core/validation.d.ts +0 -10
- package/dist/core/validation.js +0 -20
- package/dist/database/database.d.ts +0 -40
- package/dist/database/database.encryption.d.ts +0 -33
- package/dist/database/database.encryption.js +0 -62
- package/dist/database/database.js +0 -480
- package/dist/database/database.state.d.ts +0 -52
- package/dist/database/database.state.js +0 -119
- package/dist/database/database.test-utils.d.ts +0 -22
- package/dist/database/database.test-utils.js +0 -39
- package/dist/database/database.types.d.ts +0 -3
- package/dist/database/database.types.js +0 -2
- package/dist/features/agents/agents.manager.d.ts +0 -24
- package/dist/features/agents/agents.manager.js +0 -200
- package/dist/features/ask-user/ask-user.routes.d.ts +0 -9
- package/dist/features/ask-user/ask-user.routes.js +0 -35
- package/dist/features/chat/chat-delete.route.d.ts +0 -15
- package/dist/features/chat/chat-delete.route.js +0 -36
- package/dist/features/chat/chat-post.route.d.ts +0 -11
- package/dist/features/chat/chat-post.route.js +0 -270
- package/dist/features/chat/chat-stop.route.d.ts +0 -21
- package/dist/features/chat/chat-stop.route.js +0 -22
- package/dist/features/chat/chat-subscribe.route.d.ts +0 -9
- package/dist/features/chat/chat-subscribe.route.js +0 -71
- package/dist/features/chat/chat.routes.d.ts +0 -22
- package/dist/features/chat/chat.routes.js +0 -29
- package/dist/features/conversations/conversations-delete.route.d.ts +0 -16
- package/dist/features/conversations/conversations-delete.route.js +0 -34
- package/dist/features/conversations/conversations-get-all.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-all.route.js +0 -39
- package/dist/features/conversations/conversations-get-by-id.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-by-id.route.js +0 -38
- package/dist/features/conversations/conversations-get-deleted.route.d.ts +0 -15
- package/dist/features/conversations/conversations-get-deleted.route.js +0 -34
- package/dist/features/conversations/conversations-get-messages.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-messages.route.js +0 -49
- package/dist/features/conversations/conversations.content.d.ts +0 -28
- package/dist/features/conversations/conversations.content.js +0 -142
- package/dist/features/conversations/conversations.database.d.ts +0 -108
- package/dist/features/conversations/conversations.database.js +0 -373
- package/dist/features/conversations/conversations.manager.d.ts +0 -130
- package/dist/features/conversations/conversations.manager.js +0 -162
- package/dist/features/conversations/conversations.routes.d.ts +0 -21
- package/dist/features/conversations/conversations.routes.js +0 -38
- package/dist/features/conversations/token-usage.route.d.ts +0 -41
- package/dist/features/conversations/token-usage.route.js +0 -419
- package/dist/features/git/git-commit.route.d.ts +0 -12
- package/dist/features/git/git-commit.route.js +0 -39
- package/dist/features/git/git-create-branch.route.d.ts +0 -28
- package/dist/features/git/git-create-branch.route.js +0 -119
- package/dist/features/git/git-create-pr.route.d.ts +0 -13
- package/dist/features/git/git-create-pr.route.js +0 -50
- package/dist/features/git/git-create-repo.route.d.ts +0 -14
- package/dist/features/git/git-create-repo.route.js +0 -108
- package/dist/features/git/git-diff.route.d.ts +0 -30
- package/dist/features/git/git-diff.route.js +0 -189
- package/dist/features/git/git-fetch.route.d.ts +0 -12
- package/dist/features/git/git-fetch.route.js +0 -31
- package/dist/features/git/git-generate-commit-message.route.d.ts +0 -12
- package/dist/features/git/git-generate-commit-message.route.js +0 -76
- package/dist/features/git/git-generate-pr-info.route.d.ts +0 -13
- package/dist/features/git/git-generate-pr-info.route.js +0 -147
- package/dist/features/git/git-github-status.route.d.ts +0 -16
- package/dist/features/git/git-github-status.route.js +0 -68
- package/dist/features/git/git-log.route.d.ts +0 -17
- package/dist/features/git/git-log.route.js +0 -33
- package/dist/features/git/git-pr-status.route.d.ts +0 -15
- package/dist/features/git/git-pr-status.route.js +0 -33
- package/dist/features/git/git-pull.route.d.ts +0 -12
- package/dist/features/git/git-pull.route.js +0 -35
- package/dist/features/git/git-push.route.d.ts +0 -12
- package/dist/features/git/git-push.route.js +0 -46
- package/dist/features/git/git-status-cache.database.d.ts +0 -7
- package/dist/features/git/git-status-cache.database.js +0 -53
- package/dist/features/git/git-status.route.d.ts +0 -15
- package/dist/features/git/git-status.route.js +0 -62
- package/dist/features/git/git-sync-branch.route.d.ts +0 -4
- package/dist/features/git/git-sync-branch.route.js +0 -208
- package/dist/features/git/git-unified-status.route.d.ts +0 -30
- package/dist/features/git/git-unified-status.route.js +0 -165
- package/dist/features/git/git-username.route.d.ts +0 -3
- package/dist/features/git/git-username.route.js +0 -24
- package/dist/features/git/git.manager.d.ts +0 -139
- package/dist/features/git/git.manager.js +0 -352
- package/dist/features/git/git.routes.d.ts +0 -4
- package/dist/features/git/git.routes.js +0 -116
- package/dist/features/git/git.utils.d.ts +0 -82
- package/dist/features/git/git.utils.js +0 -1040
- package/dist/features/mcp/mcp.config.d.ts +0 -27
- package/dist/features/mcp/mcp.config.js +0 -148
- package/dist/features/mcp/mcp.manager.d.ts +0 -61
- package/dist/features/mcp/mcp.manager.js +0 -254
- package/dist/features/mcp/mcp.popular.json +0 -103
- package/dist/features/mcp/mcp.routes.d.ts +0 -13
- package/dist/features/mcp/mcp.routes.js +0 -159
- package/dist/features/mcp/mcp.types.d.ts +0 -80
- package/dist/features/mcp/mcp.types.js +0 -8
- package/dist/features/metadata/metadata.manager.d.ts +0 -126
- package/dist/features/metadata/metadata.manager.js +0 -423
- package/dist/features/models/model-info-aihubmix.d.ts +0 -25
- package/dist/features/models/model-info-aihubmix.js +0 -117
- package/dist/features/models/model-info-openrouter.d.ts +0 -25
- package/dist/features/models/model-info-openrouter.js +0 -104
- package/dist/features/models/model-info.d.ts +0 -37
- package/dist/features/models/model-info.js +0 -39
- package/dist/features/models/models-catalog.d.ts +0 -49
- package/dist/features/models/models-catalog.js +0 -80
- package/dist/features/models/models-catalog.route.d.ts +0 -43
- package/dist/features/models/models-catalog.route.js +0 -15
- package/dist/features/models/models-get-available.route.d.ts +0 -36
- package/dist/features/models/models-get-available.route.js +0 -66
- package/dist/features/models/models-get-enabled.route.d.ts +0 -33
- package/dist/features/models/models-get-enabled.route.js +0 -45
- package/dist/features/models/models-get-model-info.route.d.ts +0 -31
- package/dist/features/models/models-get-model-info.route.js +0 -84
- package/dist/features/models/models-model-disable.route.d.ts +0 -15
- package/dist/features/models/models-model-disable.route.js +0 -20
- package/dist/features/models/models-model-enable.route.d.ts +0 -13
- package/dist/features/models/models-model-enable.route.js +0 -20
- package/dist/features/models/models-provider-refresh.route.d.ts +0 -17
- package/dist/features/models/models-provider-refresh.route.js +0 -20
- package/dist/features/models/models.manager.d.ts +0 -58
- package/dist/features/models/models.manager.js +0 -138
- package/dist/features/models/models.routes.d.ts +0 -18
- package/dist/features/models/models.routes.js +0 -83
- package/dist/features/models/open-router-models.d.ts +0 -38
- package/dist/features/models/open-router-models.js +0 -73
- package/dist/features/models/openai-models.d.ts +0 -63
- package/dist/features/models/openai-models.js +0 -150
- package/dist/features/onboarding/onboarding-get-git-check.route.d.ts +0 -11
- package/dist/features/onboarding/onboarding-get-git-check.route.js +0 -28
- package/dist/features/onboarding/onboarding-get-status.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-get-status.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-complete.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-complete.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-reset.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-reset.route.js +0 -15
- package/dist/features/onboarding/onboarding.routes.d.ts +0 -18
- package/dist/features/onboarding/onboarding.routes.js +0 -28
- package/dist/features/project-todos/project-todos.database.d.ts +0 -38
- package/dist/features/project-todos/project-todos.database.js +0 -91
- package/dist/features/project-todos/project-todos.routes.d.ts +0 -4
- package/dist/features/project-todos/project-todos.routes.js +0 -94
- package/dist/features/projects/projects-ai-files.route.d.ts +0 -148
- package/dist/features/projects/projects-ai-files.route.js +0 -425
- package/dist/features/projects/projects-commands.route.d.ts +0 -27
- package/dist/features/projects/projects-commands.route.js +0 -39
- package/dist/features/projects/projects-create.route.d.ts +0 -19
- package/dist/features/projects/projects-create.route.js +0 -37
- package/dist/features/projects/projects-delete.route.d.ts +0 -24
- package/dist/features/projects/projects-delete.route.js +0 -34
- package/dist/features/projects/projects-get.route.d.ts +0 -47
- package/dist/features/projects/projects-get.route.js +0 -36
- package/dist/features/projects/projects-list.route.d.ts +0 -58
- package/dist/features/projects/projects-list.route.js +0 -59
- package/dist/features/projects/projects-open-folder.route.d.ts +0 -10
- package/dist/features/projects/projects-open-folder.route.js +0 -11
- package/dist/features/projects/projects-open.route.d.ts +0 -26
- package/dist/features/projects/projects-open.route.js +0 -49
- package/dist/features/projects/projects-package-scripts.route.d.ts +0 -15
- package/dist/features/projects/projects-package-scripts.route.js +0 -96
- package/dist/features/projects/projects-run-command.route.d.ts +0 -8
- package/dist/features/projects/projects-run-command.route.js +0 -21
- package/dist/features/projects/projects-run.route.d.ts +0 -51
- package/dist/features/projects/projects-run.route.js +0 -74
- package/dist/features/projects/projects-update.route.d.ts +0 -24
- package/dist/features/projects/projects-update.route.js +0 -81
- package/dist/features/projects/projects.creator.d.ts +0 -33
- package/dist/features/projects/projects.creator.js +0 -555
- package/dist/features/projects/projects.database.d.ts +0 -61
- package/dist/features/projects/projects.database.js +0 -212
- package/dist/features/projects/projects.manager.d.ts +0 -291
- package/dist/features/projects/projects.manager.js +0 -426
- package/dist/features/projects/projects.open-with.d.ts +0 -27
- package/dist/features/projects/projects.open-with.js +0 -156
- package/dist/features/projects/projects.routes.d.ts +0 -20
- package/dist/features/projects/projects.routes.js +0 -255
- package/dist/features/projects/terminal-session-manager.d.ts +0 -55
- package/dist/features/projects/terminal-session-manager.js +0 -90
- package/dist/features/providers/provider-resolver.d.ts +0 -13
- package/dist/features/providers/provider-resolver.js +0 -22
- package/dist/features/providers/providers-get-credits.route.d.ts +0 -15
- package/dist/features/providers/providers-get-credits.route.js +0 -51
- package/dist/features/providers/providers-get.route.d.ts +0 -16
- package/dist/features/providers/providers-get.route.js +0 -32
- package/dist/features/providers/providers-open-external.route.d.ts +0 -15
- package/dist/features/providers/providers-open-external.route.js +0 -49
- package/dist/features/providers/providers-post-bulk-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-bulk-keys.route.js +0 -31
- package/dist/features/providers/providers-post-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-keys.route.js +0 -25
- package/dist/features/providers/providers.routes.d.ts +0 -19
- package/dist/features/providers/providers.routes.js +0 -31
- package/dist/features/rules/rules-post.route.d.ts +0 -43
- package/dist/features/rules/rules-post.route.js +0 -89
- package/dist/features/rules/rules.manager.d.ts +0 -36
- package/dist/features/rules/rules.manager.js +0 -203
- package/dist/features/rules/rules.routes.d.ts +0 -12
- package/dist/features/rules/rules.routes.js +0 -13
- package/dist/features/run/run-get-running.route.d.ts +0 -15
- package/dist/features/run/run-get-running.route.js +0 -21
- package/dist/features/run/run-post-start.route.d.ts +0 -8
- package/dist/features/run/run-post-start.route.js +0 -21
- package/dist/features/run/run-post-stop.route.d.ts +0 -15
- package/dist/features/run/run-post-stop.route.js +0 -24
- package/dist/features/run/run-post-suggest.route.d.ts +0 -15
- package/dist/features/run/run-post-suggest.route.js +0 -21
- package/dist/features/run/run-put-command.route.d.ts +0 -15
- package/dist/features/run/run-put-command.route.js +0 -24
- package/dist/features/run/run.routes.d.ts +0 -19
- package/dist/features/run/run.routes.js +0 -31
- package/dist/features/scaffold/index.d.ts +0 -7
- package/dist/features/scaffold/index.js +0 -5
- package/dist/features/scaffold/scaffold-get-templates.route.d.ts +0 -27
- package/dist/features/scaffold/scaffold-get-templates.route.js +0 -17
- package/dist/features/scaffold/scaffold-post.route.d.ts +0 -8
- package/dist/features/scaffold/scaffold-post.route.js +0 -30
- package/dist/features/scaffold/scaffold.routes.d.ts +0 -10
- package/dist/features/scaffold/scaffold.routes.js +0 -16
- package/dist/features/scaffold/scaffold.runner.d.ts +0 -48
- package/dist/features/scaffold/scaffold.runner.js +0 -475
- package/dist/features/scaffold/scaffold.types.d.ts +0 -26
- package/dist/features/scaffold/scaffold.types.js +0 -5
- package/dist/features/skills/skills.activation.d.ts +0 -31
- package/dist/features/skills/skills.activation.js +0 -155
- package/dist/features/skills/skills.manager.d.ts +0 -35
- package/dist/features/skills/skills.manager.js +0 -251
- package/dist/features/slash-commands/slash-commands-delete.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-delete.route.js +0 -36
- package/dist/features/slash-commands/slash-commands-get.route.d.ts +0 -53
- package/dist/features/slash-commands/slash-commands-get.route.js +0 -54
- package/dist/features/slash-commands/slash-commands-post.route.d.ts +0 -39
- package/dist/features/slash-commands/slash-commands-post.route.js +0 -70
- package/dist/features/slash-commands/slash-commands-put.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-put.route.js +0 -36
- package/dist/features/slash-commands/slash-commands.manager.d.ts +0 -46
- package/dist/features/slash-commands/slash-commands.manager.js +0 -265
- package/dist/features/slash-commands/slash-commands.routes.d.ts +0 -13
- package/dist/features/slash-commands/slash-commands.routes.js +0 -20
- package/dist/features/threads/threads-ai-files.route.d.ts +0 -153
- package/dist/features/threads/threads-ai-files.route.js +0 -287
- package/dist/features/threads/threads-conversation-folder-path.route.d.ts +0 -14
- package/dist/features/threads/threads-conversation-folder-path.route.js +0 -23
- package/dist/features/threads/threads-create.route.d.ts +0 -22
- package/dist/features/threads/threads-create.route.js +0 -60
- package/dist/features/threads/threads-delete.route.d.ts +0 -25
- package/dist/features/threads/threads-delete.route.js +0 -35
- package/dist/features/threads/threads-files.route.d.ts +0 -15
- package/dist/features/threads/threads-files.route.js +0 -20
- package/dist/features/threads/threads-fix-comments.route.d.ts +0 -26
- package/dist/features/threads/threads-fix-comments.route.js +0 -45
- package/dist/features/threads/threads-get.route.d.ts +0 -30
- package/dist/features/threads/threads-get.route.js +0 -38
- package/dist/features/threads/threads-list.route.d.ts +0 -56
- package/dist/features/threads/threads-list.route.js +0 -58
- package/dist/features/threads/threads-messages.route.d.ts +0 -28
- package/dist/features/threads/threads-messages.route.js +0 -110
- package/dist/features/threads/threads-open.route.d.ts +0 -26
- package/dist/features/threads/threads-open.route.js +0 -62
- package/dist/features/threads/threads-select.route.d.ts +0 -25
- package/dist/features/threads/threads-select.route.js +0 -35
- package/dist/features/threads/threads-update.route.d.ts +0 -15
- package/dist/features/threads/threads-update.route.js +0 -30
- package/dist/features/threads/threads.database.d.ts +0 -68
- package/dist/features/threads/threads.database.js +0 -215
- package/dist/features/threads/threads.manager.d.ts +0 -204
- package/dist/features/threads/threads.manager.js +0 -505
- package/dist/features/threads/threads.routes.d.ts +0 -20
- package/dist/features/threads/threads.routes.js +0 -230
- package/dist/features/todos/todos.database.d.ts +0 -14
- package/dist/features/todos/todos.database.js +0 -31
- package/dist/features/updates/updates.routes.d.ts +0 -13
- package/dist/features/updates/updates.routes.js +0 -40
- package/dist/index.d.ts +0 -3
- package/dist/project-analyzer.d.ts +0 -26
- package/dist/project-analyzer.js +0 -307
- package/dist/server.d.ts +0 -12
- package/dist/server.js +0 -142
- package/dist/tools/agent-tool.d.ts +0 -49
- package/dist/tools/agent-tool.js +0 -131
- package/dist/tools/ask-user.d.ts +0 -25
- package/dist/tools/ask-user.js +0 -74
- package/dist/tools/ast-grep.d.ts +0 -28
- package/dist/tools/ast-grep.js +0 -273
- package/dist/tools/bash.d.ts +0 -33
- package/dist/tools/bash.js +0 -186
- package/dist/tools/edit-diff.d.ts +0 -24
- package/dist/tools/edit-diff.js +0 -136
- package/dist/tools/edit.d.ts +0 -28
- package/dist/tools/edit.js +0 -78
- package/dist/tools/find.d.ts +0 -31
- package/dist/tools/find.js +0 -117
- package/dist/tools/grep.d.ts +0 -37
- package/dist/tools/grep.js +0 -231
- package/dist/tools/index.d.ts +0 -93
- package/dist/tools/index.js +0 -110
- package/dist/tools/ls.d.ts +0 -31
- package/dist/tools/ls.js +0 -108
- package/dist/tools/mcp-tools.d.ts +0 -31
- package/dist/tools/mcp-tools.js +0 -59
- package/dist/tools/path-utils.d.ts +0 -14
- package/dist/tools/path-utils.js +0 -87
- package/dist/tools/read.d.ts +0 -27
- package/dist/tools/read.js +0 -86
- package/dist/tools/resolve-bin.d.ts +0 -5
- package/dist/tools/resolve-bin.js +0 -28
- package/dist/tools/shell.d.ts +0 -7
- package/dist/tools/shell.js +0 -143
- package/dist/tools/skill-reference-tool.d.ts +0 -30
- package/dist/tools/skill-reference-tool.js +0 -171
- package/dist/tools/skill-tool.d.ts +0 -33
- package/dist/tools/skill-tool.js +0 -213
- package/dist/tools/todo.d.ts +0 -20
- package/dist/tools/todo.js +0 -168
- package/dist/tools/tool-helpers.d.ts +0 -78
- package/dist/tools/tool-helpers.js +0 -109
- package/dist/tools/truncate.d.ts +0 -31
- package/dist/tools/truncate.js +0 -164
- package/dist/tools/write.d.ts +0 -21
- package/dist/tools/write.js +0 -65
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* POST /api/models/:provider/refresh
|
|
3
|
-
* Refresh the available models for a provider
|
|
4
|
-
* Note: With provider-data.ts, this is a no-op but kept for backward compatibility
|
|
5
|
-
*/
|
|
6
|
-
export async function handleProviderRefresh(c, modelManager) {
|
|
7
|
-
try {
|
|
8
|
-
const provider = c.req.param("provider");
|
|
9
|
-
if (!provider) {
|
|
10
|
-
return c.json({ error: "provider is required" }, 400);
|
|
11
|
-
}
|
|
12
|
-
const models = await modelManager.getAvailableModels(provider);
|
|
13
|
-
return c.json({ success: true, provider, modelCount: models.length });
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
17
|
-
return c.json({ error: message }, 500);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=models-provider-refresh.route.js.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ModelManager
|
|
3
|
-
*
|
|
4
|
-
* Manages available and enabled models across different providers.
|
|
5
|
-
* Uses the remote models catalog (models.tarsk.io) as the source for
|
|
6
|
-
* model lists, names, and pricing.
|
|
7
|
-
*/
|
|
8
|
-
import { Model } from "@tarsk/shared";
|
|
9
|
-
import { MetadataManager } from "../metadata/metadata.manager.js";
|
|
10
|
-
/**
|
|
11
|
-
* ModelManager handles model availability and selection
|
|
12
|
-
*/
|
|
13
|
-
export declare class ModelManager {
|
|
14
|
-
private metadataManager;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new ModelManager
|
|
17
|
-
* @param metadataManager - MetadataManager instance for persistence
|
|
18
|
-
*/
|
|
19
|
-
constructor(metadataManager: MetadataManager);
|
|
20
|
-
/**
|
|
21
|
-
* Get available models for a provider.
|
|
22
|
-
* Uses the remote catalog as the source for model lists, names, and pricing.
|
|
23
|
-
*/
|
|
24
|
-
getAvailableModels(provider: string): Promise<Model[]>;
|
|
25
|
-
private buildModelsFromCatalog;
|
|
26
|
-
/**
|
|
27
|
-
* Get enabled models for a provider
|
|
28
|
-
* @param provider - Provider name
|
|
29
|
-
* @returns Array of Model objects that are enabled
|
|
30
|
-
*/
|
|
31
|
-
getEnabledModels(provider: string): Promise<Model[]>;
|
|
32
|
-
/**
|
|
33
|
-
* Get a specific model by ID from a provider
|
|
34
|
-
* @param provider - Provider name
|
|
35
|
-
* @param modelId - Model ID
|
|
36
|
-
* @returns Model object or null if not found
|
|
37
|
-
*/
|
|
38
|
-
getModel(provider: string, modelId: string): Promise<Model | null>;
|
|
39
|
-
/**
|
|
40
|
-
* Enable a model for a provider
|
|
41
|
-
* @param provider - Provider name
|
|
42
|
-
* @param modelId - Model ID to enable
|
|
43
|
-
* @throws Error if model is not found
|
|
44
|
-
*/
|
|
45
|
-
enableModel(provider: string, modelId: string): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Disable a model for a provider
|
|
48
|
-
* @param provider - Provider name
|
|
49
|
-
* @param modelId - Model ID to disable
|
|
50
|
-
*/
|
|
51
|
-
disableModel(provider: string, modelId: string): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Get all enabled models across all providers
|
|
54
|
-
* @returns Object mapping provider to array of enabled Models
|
|
55
|
-
*/
|
|
56
|
-
getAllEnabledModels(): Promise<Record<string, Model[]>>;
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=models.manager.d.ts.map
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ModelManager
|
|
3
|
-
*
|
|
4
|
-
* Manages available and enabled models across different providers.
|
|
5
|
-
* Uses the remote models catalog (models.tarsk.io) as the source for
|
|
6
|
-
* model lists, names, and pricing.
|
|
7
|
-
*/
|
|
8
|
-
import { getCatalogProvider } from "./models-catalog.js";
|
|
9
|
-
/**
|
|
10
|
-
* ModelManager handles model availability and selection
|
|
11
|
-
*/
|
|
12
|
-
export class ModelManager {
|
|
13
|
-
metadataManager;
|
|
14
|
-
/**
|
|
15
|
-
* Create a new ModelManager
|
|
16
|
-
* @param metadataManager - MetadataManager instance for persistence
|
|
17
|
-
*/
|
|
18
|
-
constructor(metadataManager) {
|
|
19
|
-
this.metadataManager = metadataManager;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get available models for a provider.
|
|
23
|
-
* Uses the remote catalog as the source for model lists, names, and pricing.
|
|
24
|
-
*/
|
|
25
|
-
async getAvailableModels(provider) {
|
|
26
|
-
const providerId = provider.toLowerCase();
|
|
27
|
-
// Get from catalog
|
|
28
|
-
const catalogProvider = await getCatalogProvider(providerId);
|
|
29
|
-
if (!catalogProvider) {
|
|
30
|
-
throw new Error(`Provider "${provider}" is not supported`);
|
|
31
|
-
}
|
|
32
|
-
return this.buildModelsFromCatalog(catalogProvider, providerId);
|
|
33
|
-
}
|
|
34
|
-
buildModelsFromCatalog(catalogProvider, providerId) {
|
|
35
|
-
return Object.values(catalogProvider.models).map((catalogModel) => ({
|
|
36
|
-
id: catalogModel.id,
|
|
37
|
-
name: catalogModel.name || catalogModel.id,
|
|
38
|
-
description: `${providerId} model: ${catalogModel.id}`,
|
|
39
|
-
provider: providerId,
|
|
40
|
-
pricing: catalogModel.cost
|
|
41
|
-
? {
|
|
42
|
-
prompt: catalogModel.cost.input,
|
|
43
|
-
completion: catalogModel.cost.output,
|
|
44
|
-
}
|
|
45
|
-
: undefined,
|
|
46
|
-
supportedParameters: catalogModel.tool_call !== undefined
|
|
47
|
-
? {
|
|
48
|
-
tools: catalogModel.tool_call,
|
|
49
|
-
}
|
|
50
|
-
: undefined,
|
|
51
|
-
tarsk_use: catalogModel.tarsk_use,
|
|
52
|
-
coding_index: catalogModel.coding_index,
|
|
53
|
-
supportsImages: catalogModel.modalities
|
|
54
|
-
? catalogModel.modalities.input.includes("image")
|
|
55
|
-
: undefined,
|
|
56
|
-
contextWindow: catalogModel.limit?.context,
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get enabled models for a provider
|
|
61
|
-
* @param provider - Provider name
|
|
62
|
-
* @returns Array of Model objects that are enabled
|
|
63
|
-
*/
|
|
64
|
-
async getEnabledModels(provider) {
|
|
65
|
-
const enabledModelIds = await this.metadataManager.getEnabledModels(provider);
|
|
66
|
-
if (enabledModelIds.length === 0) {
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
const availableModels = await this.getAvailableModels(provider);
|
|
71
|
-
return availableModels.filter((model) => enabledModelIds.includes(model.id));
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
// If we can't fetch available models, return empty
|
|
75
|
-
console.error(`Failed to get enabled models for ${provider}:`, error);
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get a specific model by ID from a provider
|
|
81
|
-
* @param provider - Provider name
|
|
82
|
-
* @param modelId - Model ID
|
|
83
|
-
* @returns Model object or null if not found
|
|
84
|
-
*/
|
|
85
|
-
async getModel(provider, modelId) {
|
|
86
|
-
try {
|
|
87
|
-
const availableModels = await this.getAvailableModels(provider);
|
|
88
|
-
return availableModels.find((m) => m.id === modelId) ?? null;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
console.error(`Failed to get model ${modelId} from ${provider}:`, error);
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Enable a model for a provider
|
|
97
|
-
* @param provider - Provider name
|
|
98
|
-
* @param modelId - Model ID to enable
|
|
99
|
-
* @throws Error if model is not found
|
|
100
|
-
*/
|
|
101
|
-
async enableModel(provider, modelId) {
|
|
102
|
-
// Verify the model exists
|
|
103
|
-
const model = await this.getModel(provider, modelId);
|
|
104
|
-
if (!model) {
|
|
105
|
-
throw new Error(`Model "${modelId}" not found in provider "${provider}"`);
|
|
106
|
-
}
|
|
107
|
-
await this.metadataManager.enableModel(provider, modelId);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Disable a model for a provider
|
|
111
|
-
* @param provider - Provider name
|
|
112
|
-
* @param modelId - Model ID to disable
|
|
113
|
-
*/
|
|
114
|
-
async disableModel(provider, modelId) {
|
|
115
|
-
await this.metadataManager.disableModel(provider, modelId);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Get all enabled models across all providers
|
|
119
|
-
* @returns Object mapping provider to array of enabled Models
|
|
120
|
-
*/
|
|
121
|
-
async getAllEnabledModels() {
|
|
122
|
-
const enabledByProvider = await this.metadataManager.getAllEnabledModels();
|
|
123
|
-
const result = {};
|
|
124
|
-
for (const provider of Object.keys(enabledByProvider)) {
|
|
125
|
-
try {
|
|
126
|
-
const models = await this.getEnabledModels(provider);
|
|
127
|
-
if (models.length > 0) {
|
|
128
|
-
result[provider] = models;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
console.error(`Failed to get enabled models for ${provider}:`, error);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=models.manager.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model routes for the REST API
|
|
3
|
-
*
|
|
4
|
-
* Handles all model-related operations:
|
|
5
|
-
* - GET /api/models - Get available models for a provider
|
|
6
|
-
* - POST /api/models/:provider/:modelId/enable - Enable a model
|
|
7
|
-
* - POST /api/models/:provider/:modelId/disable - Disable a model
|
|
8
|
-
* - GET /api/models/enabled - Get all enabled models
|
|
9
|
-
*/
|
|
10
|
-
import { Hono } from "hono";
|
|
11
|
-
import { MetadataManager } from "../metadata/metadata.manager.js";
|
|
12
|
-
/**
|
|
13
|
-
* Creates model routes
|
|
14
|
-
* @param metadataManager - Manager for metadata persistence
|
|
15
|
-
* @returns Hono router with model routes
|
|
16
|
-
*/
|
|
17
|
-
export declare function createModelRoutes(metadataManager: MetadataManager): Hono;
|
|
18
|
-
//# sourceMappingURL=models.routes.d.ts.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model routes for the REST API
|
|
3
|
-
*
|
|
4
|
-
* Handles all model-related operations:
|
|
5
|
-
* - GET /api/models - Get available models for a provider
|
|
6
|
-
* - POST /api/models/:provider/:modelId/enable - Enable a model
|
|
7
|
-
* - POST /api/models/:provider/:modelId/disable - Disable a model
|
|
8
|
-
* - GET /api/models/enabled - Get all enabled models
|
|
9
|
-
*/
|
|
10
|
-
import { Hono } from "hono";
|
|
11
|
-
import { ModelManager } from "../models/models.manager.js";
|
|
12
|
-
import { handleGetAvailableModels } from "./models-get-available.route.js";
|
|
13
|
-
import { handleGetEnabledModels } from "./models-get-enabled.route.js";
|
|
14
|
-
import { handleModelEnable } from "./models-model-enable.route.js";
|
|
15
|
-
import { handleModelDisable } from "./models-model-disable.route.js";
|
|
16
|
-
import { handleProviderRefresh } from "./models-provider-refresh.route.js";
|
|
17
|
-
import { handleGetModelsCatalog } from "./models-catalog.route.js";
|
|
18
|
-
import { handleGetModelInfo } from "./models-get-model-info.route.js";
|
|
19
|
-
/**
|
|
20
|
-
* Creates model routes
|
|
21
|
-
* @param metadataManager - Manager for metadata persistence
|
|
22
|
-
* @returns Hono router with model routes
|
|
23
|
-
*/
|
|
24
|
-
export function createModelRoutes(metadataManager) {
|
|
25
|
-
const router = new Hono();
|
|
26
|
-
const modelManager = new ModelManager(metadataManager);
|
|
27
|
-
/**
|
|
28
|
-
* GET /api/models?provider=openrouter&supportedTools=true
|
|
29
|
-
* Get available models for a provider
|
|
30
|
-
*
|
|
31
|
-
* Query parameters:
|
|
32
|
-
* - provider: Required. Provider name (e.g., "openrouter", "openai")
|
|
33
|
-
* - supportedTools: Optional. If "true", only return models with tools support
|
|
34
|
-
*/
|
|
35
|
-
router.get("/", async (c) => {
|
|
36
|
-
return handleGetAvailableModels(c, modelManager);
|
|
37
|
-
});
|
|
38
|
-
/**
|
|
39
|
-
* GET /api/models/info?modelId=provider/model
|
|
40
|
-
* Get detailed information about a specific model including context window
|
|
41
|
-
*/
|
|
42
|
-
router.get("/info", async (c) => {
|
|
43
|
-
return handleGetModelInfo(c, modelManager);
|
|
44
|
-
});
|
|
45
|
-
/**
|
|
46
|
-
* GET /api/models/enabled
|
|
47
|
-
* Get all enabled models across all providers
|
|
48
|
-
*/
|
|
49
|
-
router.get("/enabled", async (c) => {
|
|
50
|
-
return handleGetEnabledModels(c, modelManager);
|
|
51
|
-
});
|
|
52
|
-
/**
|
|
53
|
-
* GET /api/models/catalog
|
|
54
|
-
* Get the full models catalog (cached with SWR)
|
|
55
|
-
*/
|
|
56
|
-
router.get("/catalog", async (c) => {
|
|
57
|
-
return handleGetModelsCatalog(c);
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* POST /api/models/:provider/:modelId/enable
|
|
61
|
-
* Enable a model for a provider
|
|
62
|
-
*/
|
|
63
|
-
router.post("/:provider/:modelId/enable", async (c) => {
|
|
64
|
-
return handleModelEnable(c, modelManager);
|
|
65
|
-
});
|
|
66
|
-
/**
|
|
67
|
-
* POST /api/models/:provider/:modelId/disable
|
|
68
|
-
* Disable a model for a provider
|
|
69
|
-
*/
|
|
70
|
-
router.post("/:provider/:modelId/disable", async (c) => {
|
|
71
|
-
return handleModelDisable(c, modelManager);
|
|
72
|
-
});
|
|
73
|
-
/**
|
|
74
|
-
* POST /api/models/:provider/refresh
|
|
75
|
-
* Refresh the available models for a provider
|
|
76
|
-
* Note: With provider-data.ts, this is a no-op but kept for backward compatibility
|
|
77
|
-
*/
|
|
78
|
-
router.post("/:provider/refresh", async (c) => {
|
|
79
|
-
return handleProviderRefresh(c, modelManager);
|
|
80
|
-
});
|
|
81
|
-
return router;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=models.routes.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenRouter Models Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages available models from the OpenRouter provider
|
|
5
|
-
* using @mariozechner/pi-ai's model registry.
|
|
6
|
-
*/
|
|
7
|
-
import { Model } from "@tarsk/shared";
|
|
8
|
-
/**
|
|
9
|
-
* OpenRouterModels manages access to OpenRouter models via pi-ai
|
|
10
|
-
*/
|
|
11
|
-
export declare class OpenRouterModels {
|
|
12
|
-
private cache;
|
|
13
|
-
/**
|
|
14
|
-
* Get available models from OpenRouter via pi-ai registry
|
|
15
|
-
*
|
|
16
|
-
* @returns Array of Model objects
|
|
17
|
-
*/
|
|
18
|
-
getModels(): Promise<Model[]>;
|
|
19
|
-
/**
|
|
20
|
-
* Get a specific model by ID
|
|
21
|
-
* @param modelId - The model ID to fetch
|
|
22
|
-
* @returns Model object or null if not found
|
|
23
|
-
*/
|
|
24
|
-
getModelById(modelId: string): Promise<Model | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Clear the cache
|
|
27
|
-
*/
|
|
28
|
-
clearCache(): void;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get or create the singleton instance
|
|
32
|
-
*/
|
|
33
|
-
export declare function getOpenRouterModels(): OpenRouterModels;
|
|
34
|
-
/**
|
|
35
|
-
* Reset the singleton instance (useful for testing)
|
|
36
|
-
*/
|
|
37
|
-
export declare function resetOpenRouterModels(): void;
|
|
38
|
-
//# sourceMappingURL=open-router-models.d.ts.map
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenRouter Models Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages available models from the OpenRouter provider
|
|
5
|
-
* using @mariozechner/pi-ai's model registry.
|
|
6
|
-
*/
|
|
7
|
-
import { getModels } from "@mariozechner/pi-ai";
|
|
8
|
-
/**
|
|
9
|
-
* OpenRouterModels manages access to OpenRouter models via pi-ai
|
|
10
|
-
*/
|
|
11
|
-
export class OpenRouterModels {
|
|
12
|
-
cache = null;
|
|
13
|
-
/**
|
|
14
|
-
* Get available models from OpenRouter via pi-ai registry
|
|
15
|
-
*
|
|
16
|
-
* @returns Array of Model objects
|
|
17
|
-
*/
|
|
18
|
-
async getModels() {
|
|
19
|
-
if (this.cache) {
|
|
20
|
-
return this.cache;
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const piModels = getModels("openrouter");
|
|
24
|
-
const models = piModels
|
|
25
|
-
.map((m) => ({
|
|
26
|
-
id: m.id,
|
|
27
|
-
name: m.name || m.id,
|
|
28
|
-
description: `OpenRouter model: ${m.id}`,
|
|
29
|
-
provider: "openrouter",
|
|
30
|
-
pricing: {
|
|
31
|
-
prompt: m.cost?.input ?? 0,
|
|
32
|
-
completion: m.cost?.output ?? 0,
|
|
33
|
-
},
|
|
34
|
-
}))
|
|
35
|
-
.sort((a, b) => a.id.localeCompare(b.id));
|
|
36
|
-
this.cache = models;
|
|
37
|
-
return models;
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
throw new Error(`Failed to load OpenRouter models: ${error instanceof Error ? error.message : String(error)}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get a specific model by ID
|
|
45
|
-
* @param modelId - The model ID to fetch
|
|
46
|
-
* @returns Model object or null if not found
|
|
47
|
-
*/
|
|
48
|
-
async getModelById(modelId) {
|
|
49
|
-
this.cache ??= await this.getModels();
|
|
50
|
-
return this.cache.find((m) => m.id === modelId) ?? null;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Clear the cache
|
|
54
|
-
*/
|
|
55
|
-
clearCache() {
|
|
56
|
-
this.cache = null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
let instance = null;
|
|
60
|
-
/**
|
|
61
|
-
* Get or create the singleton instance
|
|
62
|
-
*/
|
|
63
|
-
export function getOpenRouterModels() {
|
|
64
|
-
instance ??= new OpenRouterModels();
|
|
65
|
-
return instance;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Reset the singleton instance (useful for testing)
|
|
69
|
-
*/
|
|
70
|
-
export function resetOpenRouterModels() {
|
|
71
|
-
instance = null;
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=open-router-models.js.map
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI Models Fetcher
|
|
3
|
-
*
|
|
4
|
-
* Handles fetching available models from OpenAI API
|
|
5
|
-
* with local caching and TTL management.
|
|
6
|
-
*/
|
|
7
|
-
import { Model } from "@tarsk/shared";
|
|
8
|
-
/**
|
|
9
|
-
* OpenAIModels manages fetching and caching of OpenAI models
|
|
10
|
-
*/
|
|
11
|
-
export declare class OpenAIModels {
|
|
12
|
-
private cache;
|
|
13
|
-
private cacheTTL;
|
|
14
|
-
private apiKey;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new OpenAIModels instance
|
|
17
|
-
* @param apiKey - OpenAI API key (optional, will be fetched from OPENAI_API_KEY env var)
|
|
18
|
-
*/
|
|
19
|
-
constructor(apiKey?: string);
|
|
20
|
-
/**
|
|
21
|
-
* Set the API key
|
|
22
|
-
* @param apiKey - OpenAI API key
|
|
23
|
-
*/
|
|
24
|
-
setApiKey(apiKey: string): void;
|
|
25
|
-
/**
|
|
26
|
-
* Check if cache is valid
|
|
27
|
-
* @returns true if cache exists and is not expired
|
|
28
|
-
*/
|
|
29
|
-
private isCacheValid;
|
|
30
|
-
/**
|
|
31
|
-
* Set cache TTL in milliseconds
|
|
32
|
-
* @param ttl - Time to live in milliseconds
|
|
33
|
-
*/
|
|
34
|
-
setCacheTTL(ttl: number): void;
|
|
35
|
-
/**
|
|
36
|
-
* Clear the cache
|
|
37
|
-
*/
|
|
38
|
-
clearCache(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Fetch available models from OpenAI API
|
|
41
|
-
* Uses cache if valid, otherwise fetches fresh data
|
|
42
|
-
*
|
|
43
|
-
* API Reference: https://platform.openai.com/docs/api-reference/models/list
|
|
44
|
-
*
|
|
45
|
-
* @returns Array of Model objects
|
|
46
|
-
* @throws Error if API key is not set or API call fails
|
|
47
|
-
*/
|
|
48
|
-
getModels(): Promise<Model[]>;
|
|
49
|
-
/**
|
|
50
|
-
* Format model ID to a readable name
|
|
51
|
-
* @param modelId - The model ID
|
|
52
|
-
* @returns Formatted model name
|
|
53
|
-
*/
|
|
54
|
-
private formatModelName;
|
|
55
|
-
/**
|
|
56
|
-
* Get a specific model by ID
|
|
57
|
-
* @param modelId - The model ID to fetch
|
|
58
|
-
* @returns Model object or null if not found
|
|
59
|
-
*/
|
|
60
|
-
getModelById(modelId: string): Promise<Model | null>;
|
|
61
|
-
}
|
|
62
|
-
export declare function getOpenAIModels(): OpenAIModels;
|
|
63
|
-
//# sourceMappingURL=openai-models.d.ts.map
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI Models Fetcher
|
|
3
|
-
*
|
|
4
|
-
* Handles fetching available models from OpenAI API
|
|
5
|
-
* with local caching and TTL management.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* OpenAIModels manages fetching and caching of OpenAI models
|
|
9
|
-
*/
|
|
10
|
-
export class OpenAIModels {
|
|
11
|
-
cache = null;
|
|
12
|
-
cacheTTL = 1000 * 60 * 60; // 1 hour in milliseconds
|
|
13
|
-
apiKey = null;
|
|
14
|
-
/**
|
|
15
|
-
* Create a new OpenAIModels instance
|
|
16
|
-
* @param apiKey - OpenAI API key (optional, will be fetched from OPENAI_API_KEY env var)
|
|
17
|
-
*/
|
|
18
|
-
constructor(apiKey) {
|
|
19
|
-
this.apiKey = apiKey ?? process.env.OPENAI_API_KEY ?? null;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Set the API key
|
|
23
|
-
* @param apiKey - OpenAI API key
|
|
24
|
-
*/
|
|
25
|
-
setApiKey(apiKey) {
|
|
26
|
-
this.apiKey = apiKey;
|
|
27
|
-
// Invalidate cache when API key changes
|
|
28
|
-
this.cache = null;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Check if cache is valid
|
|
32
|
-
* @returns true if cache exists and is not expired
|
|
33
|
-
*/
|
|
34
|
-
isCacheValid() {
|
|
35
|
-
if (!this.cache) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const now = Date.now();
|
|
39
|
-
return now - this.cache.timestamp < this.cacheTTL;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Set cache TTL in milliseconds
|
|
43
|
-
* @param ttl - Time to live in milliseconds
|
|
44
|
-
*/
|
|
45
|
-
setCacheTTL(ttl) {
|
|
46
|
-
this.cacheTTL = ttl;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Clear the cache
|
|
50
|
-
*/
|
|
51
|
-
clearCache() {
|
|
52
|
-
this.cache = null;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Fetch available models from OpenAI API
|
|
56
|
-
* Uses cache if valid, otherwise fetches fresh data
|
|
57
|
-
*
|
|
58
|
-
* API Reference: https://platform.openai.com/docs/api-reference/models/list
|
|
59
|
-
*
|
|
60
|
-
* @returns Array of Model objects
|
|
61
|
-
* @throws Error if API key is not set or API call fails
|
|
62
|
-
*/
|
|
63
|
-
async getModels() {
|
|
64
|
-
// Return cached data if valid
|
|
65
|
-
if (this.isCacheValid() && this.cache) {
|
|
66
|
-
return this.cache.models;
|
|
67
|
-
}
|
|
68
|
-
if (!this.apiKey) {
|
|
69
|
-
throw new Error("OpenAI API key is not set. Please set OPENAI_API_KEY environment variable or provide it to the constructor.");
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
const response = await fetch("https://api.openai.com/v1/models", {
|
|
73
|
-
method: "GET",
|
|
74
|
-
headers: {
|
|
75
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
if (!response.ok) {
|
|
79
|
-
throw new Error(`OpenAI API error: ${response.status} ${response.statusText}`);
|
|
80
|
-
}
|
|
81
|
-
const data = (await response.json());
|
|
82
|
-
// Transform OpenAI response to our Model interface
|
|
83
|
-
// Only includes models that are likely suitable for chat/completion
|
|
84
|
-
const models = data.data
|
|
85
|
-
.filter((item) => {
|
|
86
|
-
// Filter to only include gpt models and models suitable for API use
|
|
87
|
-
const id = item.id.toLowerCase();
|
|
88
|
-
return id.includes("gpt") && !id.includes("vision-request") && !id.includes("dall-e");
|
|
89
|
-
})
|
|
90
|
-
.map((item) => ({
|
|
91
|
-
id: item.id,
|
|
92
|
-
name: this.formatModelName(item.id),
|
|
93
|
-
description: `OpenAI model: ${item.id}`,
|
|
94
|
-
provider: "openai",
|
|
95
|
-
pricing: {
|
|
96
|
-
prompt: 0, // OpenAI API doesn't provide pricing in the models list
|
|
97
|
-
completion: 0, // Users should check pricing on OpenAI's website
|
|
98
|
-
},
|
|
99
|
-
}));
|
|
100
|
-
// Store in cache
|
|
101
|
-
this.cache = {
|
|
102
|
-
models,
|
|
103
|
-
timestamp: Date.now(),
|
|
104
|
-
};
|
|
105
|
-
return models;
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
throw new Error(`Failed to fetch OpenAI models: ${error instanceof Error ? error.message : String(error)}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Format model ID to a readable name
|
|
113
|
-
* @param modelId - The model ID
|
|
114
|
-
* @returns Formatted model name
|
|
115
|
-
*/
|
|
116
|
-
formatModelName(modelId) {
|
|
117
|
-
// Convert "gpt-4-turbo" to "GPT-4 Turbo"
|
|
118
|
-
return modelId
|
|
119
|
-
.split("-")
|
|
120
|
-
.map((part) => {
|
|
121
|
-
if (part === "gpt")
|
|
122
|
-
return "GPT";
|
|
123
|
-
// Handle version numbers like "4turbo"
|
|
124
|
-
if (part === part.toLowerCase() && /^\d+/.test(part)) {
|
|
125
|
-
return part.charAt(0).toUpperCase() + part.slice(1);
|
|
126
|
-
}
|
|
127
|
-
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
|
|
128
|
-
})
|
|
129
|
-
.join(" ")
|
|
130
|
-
.replace(/\s+/g, " ");
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get a specific model by ID
|
|
134
|
-
* @param modelId - The model ID to fetch
|
|
135
|
-
* @returns Model object or null if not found
|
|
136
|
-
*/
|
|
137
|
-
async getModelById(modelId) {
|
|
138
|
-
const models = await this.getModels();
|
|
139
|
-
return models.find((m) => m.id === modelId) ?? null;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Get or create a singleton OpenAIModels instance
|
|
144
|
-
*/
|
|
145
|
-
let instance = null;
|
|
146
|
-
export function getOpenAIModels() {
|
|
147
|
-
instance ??= new OpenAIModels();
|
|
148
|
-
return instance;
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=openai-models.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GET /api/onboarding/git-check
|
|
3
|
-
* Check if git is installed by running 'git --version'
|
|
4
|
-
*/
|
|
5
|
-
import type { Context } from "hono";
|
|
6
|
-
export declare function getGitCheck(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
7
|
-
gitInstalled: boolean;
|
|
8
|
-
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
9
|
-
error: string;
|
|
10
|
-
}, 500, "json">)>;
|
|
11
|
-
//# sourceMappingURL=onboarding-get-git-check.route.d.ts.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GET /api/onboarding/git-check
|
|
3
|
-
* Check if git is installed by running 'git --version'
|
|
4
|
-
*/
|
|
5
|
-
import { spawnProcess } from "../../core/utils.js";
|
|
6
|
-
export async function getGitCheck(c) {
|
|
7
|
-
try {
|
|
8
|
-
const gitInstalled = await new Promise((resolve) => {
|
|
9
|
-
const proc = spawnProcess("git", ["--version"]);
|
|
10
|
-
let _err = "";
|
|
11
|
-
proc.stderr?.on("data", (d) => {
|
|
12
|
-
_err += d.toString();
|
|
13
|
-
});
|
|
14
|
-
proc.on("close", (code) => {
|
|
15
|
-
resolve(code === 0);
|
|
16
|
-
});
|
|
17
|
-
proc.on("error", () => {
|
|
18
|
-
resolve(false);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
return c.json({ gitInstalled });
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
const message = error instanceof Error ? error.message : "Failed to check git installation";
|
|
25
|
-
return c.json({ error: message }, 500);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=onboarding-get-git-check.route.js.map
|