@hold-rein/cli 0.0.0
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/cli.js +3 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/api/app.d.ts +7 -0
- package/dist/runtime/api/app.d.ts.map +1 -0
- package/dist/runtime/api/app.js +41 -0
- package/dist/runtime/api/config/const.d.ts +8 -0
- package/dist/runtime/api/config/const.d.ts.map +1 -0
- package/dist/runtime/api/config/const.js +9 -0
- package/dist/runtime/api/config/env.d.ts +10 -0
- package/dist/runtime/api/config/env.d.ts.map +1 -0
- package/dist/runtime/api/config/env.js +32 -0
- package/dist/runtime/api/db/connection.d.ts +11 -0
- package/dist/runtime/api/db/connection.d.ts.map +1 -0
- package/dist/runtime/api/db/connection.js +21 -0
- package/dist/runtime/api/db/index.d.ts +4 -0
- package/dist/runtime/api/db/index.d.ts.map +1 -0
- package/dist/runtime/api/db/index.js +3 -0
- package/dist/runtime/api/db/migrate.d.ts +4 -0
- package/dist/runtime/api/db/migrate.d.ts.map +1 -0
- package/dist/runtime/api/db/migrate.js +308 -0
- package/dist/runtime/api/db/schema.d.ts +1610 -0
- package/dist/runtime/api/db/schema.d.ts.map +1 -0
- package/dist/runtime/api/db/schema.js +148 -0
- package/dist/runtime/api/middleware/error-middleware.d.ts +3 -0
- package/dist/runtime/api/middleware/error-middleware.d.ts.map +1 -0
- package/dist/runtime/api/middleware/error-middleware.js +5 -0
- package/dist/runtime/api/middleware/not-found-middleware.d.ts +3 -0
- package/dist/runtime/api/middleware/not-found-middleware.d.ts.map +1 -0
- package/dist/runtime/api/middleware/not-found-middleware.js +4 -0
- package/dist/runtime/api/modules/agents/active-task-run-registry.d.ts +10 -0
- package/dist/runtime/api/modules/agents/active-task-run-registry.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/active-task-run-registry.js +20 -0
- package/dist/runtime/api/modules/agents/agent-approval-store.d.ts +7 -0
- package/dist/runtime/api/modules/agents/agent-approval-store.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-approval-store.js +23 -0
- package/dist/runtime/api/modules/agents/agent-event-bus.d.ts +8 -0
- package/dist/runtime/api/modules/agents/agent-event-bus.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-event-bus.js +40 -0
- package/dist/runtime/api/modules/agents/agent-message-repository.d.ts +22 -0
- package/dist/runtime/api/modules/agents/agent-message-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-message-repository.js +60 -0
- package/dist/runtime/api/modules/agents/agent-message-storage.d.ts +4 -0
- package/dist/runtime/api/modules/agents/agent-message-storage.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-message-storage.js +11 -0
- package/dist/runtime/api/modules/agents/agent-model-resolver.d.ts +4 -0
- package/dist/runtime/api/modules/agents/agent-model-resolver.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-model-resolver.js +17 -0
- package/dist/runtime/api/modules/agents/agent-runtime-messages.d.ts +12 -0
- package/dist/runtime/api/modules/agents/agent-runtime-messages.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-runtime-messages.js +19 -0
- package/dist/runtime/api/modules/agents/agent-runtime-support.d.ts +12 -0
- package/dist/runtime/api/modules/agents/agent-runtime-support.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-runtime-support.js +38 -0
- package/dist/runtime/api/modules/agents/agent-runtime.d.ts +25 -0
- package/dist/runtime/api/modules/agents/agent-runtime.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-runtime.js +371 -0
- package/dist/runtime/api/modules/agents/agent-subagents.d.ts +32 -0
- package/dist/runtime/api/modules/agents/agent-subagents.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-subagents.js +65 -0
- package/dist/runtime/api/modules/agents/agent-task-actions.d.ts +9 -0
- package/dist/runtime/api/modules/agents/agent-task-actions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-task-actions.js +33 -0
- package/dist/runtime/api/modules/agents/agent-task-title-generator.d.ts +15 -0
- package/dist/runtime/api/modules/agents/agent-task-title-generator.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-task-title-generator.js +61 -0
- package/dist/runtime/api/modules/agents/agent-tool-approval.d.ts +12 -0
- package/dist/runtime/api/modules/agents/agent-tool-approval.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-tool-approval.js +40 -0
- package/dist/runtime/api/modules/agents/agent-types.d.ts +198 -0
- package/dist/runtime/api/modules/agents/agent-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-types.js +1 -0
- package/dist/runtime/api/modules/agents/agents-router.d.ts +7 -0
- package/dist/runtime/api/modules/agents/agents-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agents-router.js +210 -0
- package/dist/runtime/api/modules/agents/agents-service.d.ts +52 -0
- package/dist/runtime/api/modules/agents/agents-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agents-service.js +282 -0
- package/dist/runtime/api/modules/agents/approval/store.d.ts +7 -0
- package/dist/runtime/api/modules/agents/approval/store.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/approval/store.js +23 -0
- package/dist/runtime/api/modules/agents/approval/tool-approval.d.ts +14 -0
- package/dist/runtime/api/modules/agents/approval/tool-approval.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/approval/tool-approval.js +43 -0
- package/dist/runtime/api/modules/agents/custom-agent-model.d.ts +16 -0
- package/dist/runtime/api/modules/agents/custom-agent-model.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/custom-agent-model.js +21 -0
- package/dist/runtime/api/modules/agents/default-agents-service.d.ts +3 -0
- package/dist/runtime/api/modules/agents/default-agents-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/default-agents-service.js +52 -0
- package/dist/runtime/api/modules/agents/event/event-bus.d.ts +8 -0
- package/dist/runtime/api/modules/agents/event/event-bus.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/event/event-bus.js +40 -0
- package/dist/runtime/api/modules/agents/index.d.ts +11 -0
- package/dist/runtime/api/modules/agents/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/index.js +9 -0
- package/dist/runtime/api/modules/agents/message/storage.d.ts +4 -0
- package/dist/runtime/api/modules/agents/message/storage.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/message/storage.js +11 -0
- package/dist/runtime/api/modules/agents/model/custom-model.d.ts +16 -0
- package/dist/runtime/api/modules/agents/model/custom-model.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/model/custom-model.js +21 -0
- package/dist/runtime/api/modules/agents/model/resolver.d.ts +4 -0
- package/dist/runtime/api/modules/agents/model/resolver.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/model/resolver.js +17 -0
- package/dist/runtime/api/modules/agents/router/browser-tool-result.d.ts +8 -0
- package/dist/runtime/api/modules/agents/router/browser-tool-result.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/router/browser-tool-result.js +35 -0
- package/dist/runtime/api/modules/agents/router/index.d.ts +10 -0
- package/dist/runtime/api/modules/agents/router/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/router/index.js +210 -0
- package/dist/runtime/api/modules/agents/router/request-parsing.d.ts +24 -0
- package/dist/runtime/api/modules/agents/router/request-parsing.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/router/request-parsing.js +78 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.d.ts +5 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.js +115 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.d.ts +13 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.js +31 -0
- package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.d.ts +21 -0
- package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.js +69 -0
- package/dist/runtime/api/modules/agents/runtime/continuation-subagent.d.ts +26 -0
- package/dist/runtime/api/modules/agents/runtime/continuation-subagent.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/continuation-subagent.js +67 -0
- package/dist/runtime/api/modules/agents/runtime/index.d.ts +3 -0
- package/dist/runtime/api/modules/agents/runtime/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/index.js +432 -0
- package/dist/runtime/api/modules/agents/runtime/messages.d.ts +12 -0
- package/dist/runtime/api/modules/agents/runtime/messages.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/messages.js +19 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-results.d.ts +22 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-results.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-results.js +39 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-tools.d.ts +49 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-tools.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-tools.js +195 -0
- package/dist/runtime/api/modules/agents/runtime/support.d.ts +19 -0
- package/dist/runtime/api/modules/agents/runtime/support.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/support.js +106 -0
- package/dist/runtime/api/modules/agents/runtime/token-collection.d.ts +28 -0
- package/dist/runtime/api/modules/agents/runtime/token-collection.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/token-collection.js +131 -0
- package/dist/runtime/api/modules/agents/runtime/token-usage-sync.d.ts +15 -0
- package/dist/runtime/api/modules/agents/runtime/token-usage-sync.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/token-usage-sync.js +46 -0
- package/dist/runtime/api/modules/agents/runtime/type.d.ts +62 -0
- package/dist/runtime/api/modules/agents/runtime/type.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/type.js +1 -0
- package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.d.ts +3 -0
- package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.js +31 -0
- package/dist/runtime/api/modules/agents/service/default.d.ts +3 -0
- package/dist/runtime/api/modules/agents/service/default.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/default.js +65 -0
- package/dist/runtime/api/modules/agents/service/index.d.ts +56 -0
- package/dist/runtime/api/modules/agents/service/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/index.js +296 -0
- package/dist/runtime/api/modules/agents/service/interrupt-task.d.ts +14 -0
- package/dist/runtime/api/modules/agents/service/interrupt-task.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/interrupt-task.js +34 -0
- package/dist/runtime/api/modules/agents/service/startup-recovery.d.ts +14 -0
- package/dist/runtime/api/modules/agents/service/startup-recovery.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/startup-recovery.js +15 -0
- package/dist/runtime/api/modules/agents/shell-command-risk.d.ts +3 -0
- package/dist/runtime/api/modules/agents/shell-command-risk.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/shell-command-risk.js +24 -0
- package/dist/runtime/api/modules/agents/shell-exec-tool.d.ts +4 -0
- package/dist/runtime/api/modules/agents/shell-exec-tool.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/shell-exec-tool.js +71 -0
- package/dist/runtime/api/modules/agents/subagent/index.d.ts +45 -0
- package/dist/runtime/api/modules/agents/subagent/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent/index.js +143 -0
- package/dist/runtime/api/modules/agents/subagent/lifecycle.d.ts +13 -0
- package/dist/runtime/api/modules/agents/subagent/lifecycle.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent/lifecycle.js +36 -0
- package/dist/runtime/api/modules/agents/subagent/repository.d.ts +12 -0
- package/dist/runtime/api/modules/agents/subagent/repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent/repository.js +93 -0
- package/dist/runtime/api/modules/agents/subagent-repository.d.ts +11 -0
- package/dist/runtime/api/modules/agents/subagent-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent-repository.js +65 -0
- package/dist/runtime/api/modules/agents/task/actions.d.ts +10 -0
- package/dist/runtime/api/modules/agents/task/actions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/actions.js +37 -0
- package/dist/runtime/api/modules/agents/task/active-run-registry.d.ts +10 -0
- package/dist/runtime/api/modules/agents/task/active-run-registry.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/active-run-registry.js +20 -0
- package/dist/runtime/api/modules/agents/task/run-monitor.d.ts +14 -0
- package/dist/runtime/api/modules/agents/task/run-monitor.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/run-monitor.js +42 -0
- package/dist/runtime/api/modules/agents/task/title-generator.d.ts +15 -0
- package/dist/runtime/api/modules/agents/task/title-generator.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/title-generator.js +61 -0
- package/dist/runtime/api/modules/agents/task-run-monitor.d.ts +14 -0
- package/dist/runtime/api/modules/agents/task-run-monitor.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task-run-monitor.js +42 -0
- package/dist/runtime/api/modules/file-system/file-system-router.d.ts +6 -0
- package/dist/runtime/api/modules/file-system/file-system-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/file-system/file-system-router.js +119 -0
- package/dist/runtime/api/modules/file-system/file-system-service.d.ts +30 -0
- package/dist/runtime/api/modules/file-system/file-system-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/file-system/file-system-service.js +209 -0
- package/dist/runtime/api/modules/file-system/index.d.ts +4 -0
- package/dist/runtime/api/modules/file-system/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/file-system/index.js +1 -0
- package/dist/runtime/api/modules/health/health-router.d.ts +3 -0
- package/dist/runtime/api/modules/health/health-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/health/health-router.js +10 -0
- package/dist/runtime/api/modules/health/index.d.ts +2 -0
- package/dist/runtime/api/modules/health/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/health/index.js +1 -0
- package/dist/runtime/api/modules/model-providers/default-model-provider-service.d.ts +3 -0
- package/dist/runtime/api/modules/model-providers/default-model-provider-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/default-model-provider-service.js +21 -0
- package/dist/runtime/api/modules/model-providers/index.d.ts +5 -0
- package/dist/runtime/api/modules/model-providers/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/index.js +4 -0
- package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.d.ts +8 -0
- package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.js +35 -0
- package/dist/runtime/api/modules/model-providers/model-provider-repository.d.ts +51 -0
- package/dist/runtime/api/modules/model-providers/model-provider-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-provider-repository.js +314 -0
- package/dist/runtime/api/modules/model-providers/model-providers-router.d.ts +9 -0
- package/dist/runtime/api/modules/model-providers/model-providers-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-providers-router.js +188 -0
- package/dist/runtime/api/modules/model-providers/model-providers-service.d.ts +52 -0
- package/dist/runtime/api/modules/model-providers/model-providers-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-providers-service.js +239 -0
- package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.d.ts +3 -0
- package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.js +22 -0
- package/dist/runtime/api/modules/model-proxies/index.d.ts +5 -0
- package/dist/runtime/api/modules/model-proxies/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/index.js +4 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-router.d.ts +7 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-router.js +55 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-service.d.ts +26 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-service.js +107 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-repository.d.ts +39 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-repository.js +146 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.d.ts +20 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.js +45 -0
- package/dist/runtime/api/modules/plugins/plugins-router.d.ts +7 -0
- package/dist/runtime/api/modules/plugins/plugins-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/plugins/plugins-router.js +11 -0
- package/dist/runtime/api/modules/skills/default-skills-service.d.ts +3 -0
- package/dist/runtime/api/modules/skills/default-skills-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/default-skills-service.js +9 -0
- package/dist/runtime/api/modules/skills/index.d.ts +5 -0
- package/dist/runtime/api/modules/skills/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/index.js +3 -0
- package/dist/runtime/api/modules/skills/skills-router.d.ts +7 -0
- package/dist/runtime/api/modules/skills/skills-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/skills-router.js +56 -0
- package/dist/runtime/api/modules/skills/skills-service.d.ts +7 -0
- package/dist/runtime/api/modules/skills/skills-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/skills-service.js +264 -0
- package/dist/runtime/api/modules/skills/skills-types.d.ts +22 -0
- package/dist/runtime/api/modules/skills/skills-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/skills-types.js +1 -0
- package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.d.ts +3 -0
- package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.js +17 -0
- package/dist/runtime/api/modules/usage-stats/index.d.ts +4 -0
- package/dist/runtime/api/modules/usage-stats/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/index.js +2 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-router.d.ts +7 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-router.js +42 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-service.d.ts +40 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-service.js +144 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-types.d.ts +39 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-types.js +1 -0
- package/dist/runtime/api/modules/workspaces/default-workspaces-service.d.ts +3 -0
- package/dist/runtime/api/modules/workspaces/default-workspaces-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/default-workspaces-service.js +20 -0
- package/dist/runtime/api/modules/workspaces/index.d.ts +6 -0
- package/dist/runtime/api/modules/workspaces/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/index.js +5 -0
- package/dist/runtime/api/modules/workspaces/workspace-repository.d.ts +41 -0
- package/dist/runtime/api/modules/workspaces/workspace-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspace-repository.js +326 -0
- package/dist/runtime/api/modules/workspaces/workspace-types.d.ts +33 -0
- package/dist/runtime/api/modules/workspaces/workspace-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspace-types.js +1 -0
- package/dist/runtime/api/modules/workspaces/workspaces-router.d.ts +7 -0
- package/dist/runtime/api/modules/workspaces/workspaces-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspaces-router.js +71 -0
- package/dist/runtime/api/modules/workspaces/workspaces-service.d.ts +24 -0
- package/dist/runtime/api/modules/workspaces/workspaces-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspaces-service.js +109 -0
- package/dist/runtime/api/plugin.d.ts +5 -0
- package/dist/runtime/api/plugin.d.ts.map +1 -0
- package/dist/runtime/api/plugin.js +48 -0
- package/dist/runtime/api/response/api-response.d.ts +11 -0
- package/dist/runtime/api/response/api-response.d.ts.map +1 -0
- package/dist/runtime/api/response/api-response.js +18 -0
- package/dist/runtime/api/response/index.d.ts +3 -0
- package/dist/runtime/api/response/index.d.ts.map +1 -0
- package/dist/runtime/api/response/index.js +2 -0
- package/dist/runtime/api/response/response-codes.d.ts +52 -0
- package/dist/runtime/api/response/response-codes.d.ts.map +1 -0
- package/dist/runtime/api/response/response-codes.js +44 -0
- package/dist/runtime/api/router/v1/index.d.ts +12 -0
- package/dist/runtime/api/router/v1/index.d.ts.map +1 -0
- package/dist/runtime/api/router/v1/index.js +26 -0
- package/dist/runtime/api/runtime.d.ts +15 -0
- package/dist/runtime/api/runtime.d.ts.map +1 -0
- package/dist/runtime/api/runtime.js +30 -0
- package/dist/runtime/api/server.d.ts +2 -0
- package/dist/runtime/api/server.d.ts.map +1 -0
- package/dist/runtime/api/server.js +14 -0
- package/dist/runtime/api/service/health-service.d.ts +7 -0
- package/dist/runtime/api/service/health-service.d.ts.map +1 -0
- package/dist/runtime/api/service/health-service.js +7 -0
- package/dist/runtime/web/assets/abap-DLDM7-KI.js +1 -0
- package/dist/runtime/web/assets/apex-DNDY2TF8.js +1 -0
- package/dist/runtime/web/assets/azcli-Y6nb8tq_.js +1 -0
- package/dist/runtime/web/assets/bat-BwHxbl9M.js +1 -0
- package/dist/runtime/web/assets/bicep-CFznDFnq.js +2 -0
- package/dist/runtime/web/assets/cameligo-Bf6VGUru.js +1 -0
- package/dist/runtime/web/assets/clojure-Dnu-v4kV.js +1 -0
- package/dist/runtime/web/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/runtime/web/assets/coffee-Bd8akH9Z.js +1 -0
- package/dist/runtime/web/assets/cpp-BbWJElDN.js +1 -0
- package/dist/runtime/web/assets/csharp-Co3qMtFm.js +1 -0
- package/dist/runtime/web/assets/csp-D-4FJmMZ.js +1 -0
- package/dist/runtime/web/assets/css-DdJfP1eB.js +3 -0
- package/dist/runtime/web/assets/css.worker-B4z49cGk.js +93 -0
- package/dist/runtime/web/assets/cssMode-w2xbbUEW.js +1 -0
- package/dist/runtime/web/assets/cypher-cTPe9QuQ.js +1 -0
- package/dist/runtime/web/assets/dart-BOtBlQCF.js +1 -0
- package/dist/runtime/web/assets/dockerfile-BG73LgW2.js +1 -0
- package/dist/runtime/web/assets/ecl-BEgZUVRK.js +1 -0
- package/dist/runtime/web/assets/elixir-BkW5O-1t.js +1 -0
- package/dist/runtime/web/assets/flow9-BeJ5waoc.js +1 -0
- package/dist/runtime/web/assets/freemarker2-mywz2bob.js +3 -0
- package/dist/runtime/web/assets/fsharp-PahG7c26.js +1 -0
- package/dist/runtime/web/assets/go-acbASCJo.js +1 -0
- package/dist/runtime/web/assets/graphql-BxJiqAUM.js +1 -0
- package/dist/runtime/web/assets/handlebars-Cy-2QN_R.js +1 -0
- package/dist/runtime/web/assets/hcl-DtV1sZF8.js +1 -0
- package/dist/runtime/web/assets/html-2WQMGvns.js +1 -0
- package/dist/runtime/web/assets/html.worker-DtiGdgqp.js +470 -0
- package/dist/runtime/web/assets/htmlMode-BznIdxOy.js +1 -0
- package/dist/runtime/web/assets/index-CQ_mZUpS.css +1 -0
- package/dist/runtime/web/assets/index-CtZcItCu.js +1512 -0
- package/dist/runtime/web/assets/ini-Kd9XrMLS.js +1 -0
- package/dist/runtime/web/assets/java-CXBNlu9o.js +1 -0
- package/dist/runtime/web/assets/javascript-BK6G_5BV.js +1 -0
- package/dist/runtime/web/assets/json.worker-leyajbqV.js +58 -0
- package/dist/runtime/web/assets/jsonMode-DI8_Cj0K.js +7 -0
- package/dist/runtime/web/assets/julia-cl7-CwDS.js +1 -0
- package/dist/runtime/web/assets/kotlin-s7OhZKlX.js +1 -0
- package/dist/runtime/web/assets/less-9HpZscsL.js +2 -0
- package/dist/runtime/web/assets/lexon-OrD6JF1K.js +1 -0
- package/dist/runtime/web/assets/liquid-CE7Qnc0w.js +1 -0
- package/dist/runtime/web/assets/lspLanguageFeatures-DKvGiYOU.js +4 -0
- package/dist/runtime/web/assets/lua-Cyyb5UIc.js +1 -0
- package/dist/runtime/web/assets/m3-B8OfTtLu.js +1 -0
- package/dist/runtime/web/assets/markdown-BFxVWTOG.js +1 -0
- package/dist/runtime/web/assets/mdx-Fk0ZjYeT.js +1 -0
- package/dist/runtime/web/assets/mips-CiqrrVzr.js +1 -0
- package/dist/runtime/web/assets/msdax-DmeGPVcC.js +1 -0
- package/dist/runtime/web/assets/mysql-C_tMU-Nz.js +1 -0
- package/dist/runtime/web/assets/objective-c-BDtDVThU.js +1 -0
- package/dist/runtime/web/assets/pascal-vHIfCaH5.js +1 -0
- package/dist/runtime/web/assets/pascaligo-DtZ0uQbO.js +1 -0
- package/dist/runtime/web/assets/perl-Ub6l9XKa.js +1 -0
- package/dist/runtime/web/assets/pgsql-BlNEE0v7.js +1 -0
- package/dist/runtime/web/assets/php-BBUBE1dy.js +1 -0
- package/dist/runtime/web/assets/pla-DSh2-awV.js +1 -0
- package/dist/runtime/web/assets/postiats-CocnycG-.js +1 -0
- package/dist/runtime/web/assets/powerquery-tScXyioY.js +1 -0
- package/dist/runtime/web/assets/powershell-COWaemsV.js +1 -0
- package/dist/runtime/web/assets/protobuf-Brw8urJB.js +2 -0
- package/dist/runtime/web/assets/pug-8SOpv6rk.js +1 -0
- package/dist/runtime/web/assets/python-xn7eKnQc.js +1 -0
- package/dist/runtime/web/assets/qsharp-Bw9ernYp.js +1 -0
- package/dist/runtime/web/assets/r-j7ic8hl3.js +1 -0
- package/dist/runtime/web/assets/razor-BjC5fot0.js +1 -0
- package/dist/runtime/web/assets/redis-Bu5POkcn.js +1 -0
- package/dist/runtime/web/assets/redshift-Bs9aos_-.js +1 -0
- package/dist/runtime/web/assets/restructuredtext-CqXO7rUv.js +1 -0
- package/dist/runtime/web/assets/ruby-zBfavPgS.js +1 -0
- package/dist/runtime/web/assets/rust-BzKRNQWT.js +1 -0
- package/dist/runtime/web/assets/sb-BBc9UKZt.js +1 -0
- package/dist/runtime/web/assets/scala-D9hQfWCl.js +1 -0
- package/dist/runtime/web/assets/scheme-BPhDTwHR.js +1 -0
- package/dist/runtime/web/assets/scss-CBJaRo0y.js +3 -0
- package/dist/runtime/web/assets/shell-DiJ1NA_G.js +1 -0
- package/dist/runtime/web/assets/solidity-Db0IVjzk.js +1 -0
- package/dist/runtime/web/assets/sophia-CnS9iZB_.js +1 -0
- package/dist/runtime/web/assets/sparql-CJmd_6j2.js +1 -0
- package/dist/runtime/web/assets/sql-ClhHkBeG.js +1 -0
- package/dist/runtime/web/assets/st-CHwy0fLd.js +1 -0
- package/dist/runtime/web/assets/swift-Bqt4WxQ4.js +3 -0
- package/dist/runtime/web/assets/systemverilog-Bs9z6M-B.js +1 -0
- package/dist/runtime/web/assets/tcl-Dm6ycUr_.js +1 -0
- package/dist/runtime/web/assets/ts.worker-59MjiAqk.js +67731 -0
- package/dist/runtime/web/assets/tsMode-8t6AIduV.js +11 -0
- package/dist/runtime/web/assets/twig-Csy3S7wG.js +1 -0
- package/dist/runtime/web/assets/typescript-DvPPogGC.js +1 -0
- package/dist/runtime/web/assets/typespec-Btyra-wh.js +1 -0
- package/dist/runtime/web/assets/vb-Db0cS2oM.js +1 -0
- package/dist/runtime/web/assets/wgsl-BTesnYfV.js +298 -0
- package/dist/runtime/web/assets/xml-CB8xdh8u.js +1 -0
- package/dist/runtime/web/assets/yaml-B4sXC4FA.js +1 -0
- package/dist/runtime/web/index.html +13 -0
- package/package.json +42 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface EncryptedApiKey {
|
|
2
|
+
ciphertext: string;
|
|
3
|
+
iv: string;
|
|
4
|
+
tag: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function decryptProviderApiKey(encryptedApiKey: EncryptedApiKey, base64EncodedKey: string): string;
|
|
7
|
+
export declare function encryptProviderApiKey(apiKey: string, base64EncodedKey: string): EncryptedApiKey;
|
|
8
|
+
//# sourceMappingURL=model-provider-api-key-crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-provider-api-key-crypto.d.ts","sourceRoot":"","sources":["../../../src/modules/model-providers/model-provider-api-key-crypto.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAgBR;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GACvB,eAAe,CAcjB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
2
|
+
const ALGORITHM = "aes-256-gcm";
|
|
3
|
+
const IV_LENGTH = 12;
|
|
4
|
+
const KEY_LENGTH = 32;
|
|
5
|
+
export function decryptProviderApiKey(encryptedApiKey, base64EncodedKey) {
|
|
6
|
+
const key = decodeEncryptionKey(base64EncodedKey);
|
|
7
|
+
const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(encryptedApiKey.iv, "base64"));
|
|
8
|
+
decipher.setAuthTag(Buffer.from(encryptedApiKey.tag, "base64"));
|
|
9
|
+
const plaintext = Buffer.concat([
|
|
10
|
+
decipher.update(Buffer.from(encryptedApiKey.ciphertext, "base64")),
|
|
11
|
+
decipher.final()
|
|
12
|
+
]);
|
|
13
|
+
return plaintext.toString("utf8");
|
|
14
|
+
}
|
|
15
|
+
export function encryptProviderApiKey(apiKey, base64EncodedKey) {
|
|
16
|
+
const key = decodeEncryptionKey(base64EncodedKey);
|
|
17
|
+
const iv = randomBytes(IV_LENGTH);
|
|
18
|
+
const cipher = createCipheriv(ALGORITHM, key, iv);
|
|
19
|
+
const ciphertext = Buffer.concat([
|
|
20
|
+
cipher.update(apiKey, "utf8"),
|
|
21
|
+
cipher.final()
|
|
22
|
+
]);
|
|
23
|
+
return {
|
|
24
|
+
ciphertext: ciphertext.toString("base64"),
|
|
25
|
+
iv: iv.toString("base64"),
|
|
26
|
+
tag: cipher.getAuthTag().toString("base64")
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function decodeEncryptionKey(base64EncodedKey) {
|
|
30
|
+
const key = Buffer.from(base64EncodedKey, "base64");
|
|
31
|
+
if (key.length !== KEY_LENGTH) {
|
|
32
|
+
throw new Error("PROVIDER_API_KEY_ENCRYPTION_KEY must be a base64-encoded 32-byte key");
|
|
33
|
+
}
|
|
34
|
+
return key;
|
|
35
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AppDatabase } from "../../db";
|
|
2
|
+
import { type CustomModelProviderRow, type CustomProviderModelRow, type ProviderApiKeyRow } from "../../db";
|
|
3
|
+
export interface CreateCustomModelProviderInput {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
provider: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateCustomProviderModelInput {
|
|
8
|
+
api: string;
|
|
9
|
+
contextWindow: number;
|
|
10
|
+
input: string[];
|
|
11
|
+
maxTokens: number;
|
|
12
|
+
modelId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
providerId: string;
|
|
15
|
+
reasoning: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface UpdateCustomModelProviderInput {
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
provider: string;
|
|
20
|
+
}
|
|
21
|
+
export interface UpdateCustomProviderModelInput {
|
|
22
|
+
api: string;
|
|
23
|
+
contextWindow: number;
|
|
24
|
+
input: string[];
|
|
25
|
+
maxTokens: number;
|
|
26
|
+
name: string;
|
|
27
|
+
reasoning: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface SaveProviderApiKeyInput {
|
|
30
|
+
apiKeyCiphertext: string;
|
|
31
|
+
apiKeyIv: string;
|
|
32
|
+
apiKeyTag: string;
|
|
33
|
+
provider: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ModelProviderRepository {
|
|
36
|
+
createCustomModelProvider: (input: CreateCustomModelProviderInput) => CustomModelProviderRow;
|
|
37
|
+
createCustomProviderModel: (input: CreateCustomProviderModelInput) => CustomProviderModelRow;
|
|
38
|
+
deleteCustomModelProvider: (provider: string) => boolean;
|
|
39
|
+
deleteCustomProviderModel: (providerId: string, modelId: string) => boolean;
|
|
40
|
+
findCustomModelProviderByProvider: (provider: string) => CustomModelProviderRow | undefined;
|
|
41
|
+
findCustomProviderModel: (providerId: string, modelId: string) => CustomProviderModelRow | undefined;
|
|
42
|
+
findProviderApiKeyByProvider: (provider: string) => ProviderApiKeyRow | undefined;
|
|
43
|
+
listCustomModelProviders: () => CustomModelProviderRow[];
|
|
44
|
+
listCustomProviderModelsByProviderId: (providerId: string) => CustomProviderModelRow[];
|
|
45
|
+
saveProviderApiKey: (input: SaveProviderApiKeyInput) => ProviderApiKeyRow;
|
|
46
|
+
updateCustomModelProvider: (provider: string, input: UpdateCustomModelProviderInput) => CustomModelProviderRow | undefined;
|
|
47
|
+
updateCustomProviderModel: (providerId: string, modelId: string, input: UpdateCustomProviderModelInput) => CustomProviderModelRow | undefined;
|
|
48
|
+
}
|
|
49
|
+
export declare function createInMemoryModelProviderRepository(): ModelProviderRepository;
|
|
50
|
+
export declare function createSqliteModelProviderRepository(database: AppDatabase): ModelProviderRepository;
|
|
51
|
+
//# sourceMappingURL=model-provider-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-provider-repository.d.ts","sourceRoot":"","sources":["../../../src/modules/model-providers/model-provider-repository.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB,EAAE,CACzB,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,CAAC;IAC5B,yBAAyB,EAAE,CACzB,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,CAAC;IAC5B,yBAAyB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACzD,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5E,iCAAiC,EAAE,CACjC,QAAQ,EAAE,MAAM,KACb,sBAAsB,GAAG,SAAS,CAAC;IACxC,uBAAuB,EAAE,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,KACZ,sBAAsB,GAAG,SAAS,CAAC;IACxC,4BAA4B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;IAClF,wBAAwB,EAAE,MAAM,sBAAsB,EAAE,CAAC;IACzD,oCAAoC,EAAE,CACpC,UAAU,EAAE,MAAM,KACf,sBAAsB,EAAE,CAAC;IAC9B,kBAAkB,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,iBAAiB,CAAC;IAC1E,yBAAyB,EAAE,CACzB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,GAAG,SAAS,CAAC;IACxC,yBAAyB,EAAE,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,qCAAqC,IAAI,uBAAuB,CA6I/E;AAED,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,WAAW,GACpB,uBAAuB,CAkNzB"}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { eq } from "drizzle-orm";
|
|
3
|
+
import { customModelProviders, customProviderModels, providerApiKeys } from "../../db/index.js";
|
|
4
|
+
export function createInMemoryModelProviderRepository() {
|
|
5
|
+
const customProviders = new Map();
|
|
6
|
+
const customModels = new Map();
|
|
7
|
+
const apiKeys = new Map();
|
|
8
|
+
return {
|
|
9
|
+
createCustomModelProvider: (input) => {
|
|
10
|
+
const now = new Date().toISOString();
|
|
11
|
+
const row = {
|
|
12
|
+
baseUrl: input.baseUrl,
|
|
13
|
+
createdAt: now,
|
|
14
|
+
id: randomUUID(),
|
|
15
|
+
provider: input.provider,
|
|
16
|
+
updatedAt: now
|
|
17
|
+
};
|
|
18
|
+
customProviders.set(row.provider, row);
|
|
19
|
+
return row;
|
|
20
|
+
},
|
|
21
|
+
createCustomProviderModel: (input) => {
|
|
22
|
+
const now = new Date().toISOString();
|
|
23
|
+
const row = {
|
|
24
|
+
api: input.api,
|
|
25
|
+
contextWindow: input.contextWindow,
|
|
26
|
+
createdAt: now,
|
|
27
|
+
id: randomUUID(),
|
|
28
|
+
input: JSON.stringify(input.input),
|
|
29
|
+
maxTokens: input.maxTokens,
|
|
30
|
+
modelId: input.modelId,
|
|
31
|
+
name: input.name,
|
|
32
|
+
providerId: input.providerId,
|
|
33
|
+
reasoning: input.reasoning,
|
|
34
|
+
updatedAt: now
|
|
35
|
+
};
|
|
36
|
+
const rows = customModels.get(row.providerId) ?? [];
|
|
37
|
+
rows.push(row);
|
|
38
|
+
customModels.set(row.providerId, rows);
|
|
39
|
+
return row;
|
|
40
|
+
},
|
|
41
|
+
deleteCustomModelProvider: (provider) => {
|
|
42
|
+
const existing = customProviders.get(provider);
|
|
43
|
+
if (!existing) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
customProviders.delete(provider);
|
|
47
|
+
customModels.delete(existing.id);
|
|
48
|
+
apiKeys.delete(provider);
|
|
49
|
+
return true;
|
|
50
|
+
},
|
|
51
|
+
deleteCustomProviderModel: (providerId, modelId) => {
|
|
52
|
+
const rows = customModels.get(providerId) ?? [];
|
|
53
|
+
const nextRows = rows.filter((model) => model.modelId !== modelId);
|
|
54
|
+
if (nextRows.length === rows.length) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
customModels.set(providerId, nextRows);
|
|
58
|
+
return true;
|
|
59
|
+
},
|
|
60
|
+
findCustomModelProviderByProvider: (provider) => customProviders.get(provider),
|
|
61
|
+
findCustomProviderModel: (providerId, modelId) => (customModels.get(providerId) ?? []).find((model) => model.modelId === modelId),
|
|
62
|
+
findProviderApiKeyByProvider: (provider) => apiKeys.get(provider),
|
|
63
|
+
listCustomModelProviders: () => Array.from(customProviders.values()),
|
|
64
|
+
listCustomProviderModelsByProviderId: (providerId) => customModels.get(providerId) ?? [],
|
|
65
|
+
saveProviderApiKey: (input) => {
|
|
66
|
+
const existing = apiKeys.get(input.provider);
|
|
67
|
+
const now = new Date().toISOString();
|
|
68
|
+
const row = {
|
|
69
|
+
apiKeyCiphertext: input.apiKeyCiphertext,
|
|
70
|
+
apiKeyIv: input.apiKeyIv,
|
|
71
|
+
apiKeyTag: input.apiKeyTag,
|
|
72
|
+
createdAt: existing?.createdAt ?? now,
|
|
73
|
+
id: existing?.id ?? randomUUID(),
|
|
74
|
+
provider: input.provider,
|
|
75
|
+
updatedAt: now
|
|
76
|
+
};
|
|
77
|
+
apiKeys.set(row.provider, row);
|
|
78
|
+
return row;
|
|
79
|
+
},
|
|
80
|
+
updateCustomModelProvider: (provider, input) => {
|
|
81
|
+
const existing = customProviders.get(provider);
|
|
82
|
+
if (!existing) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const row = {
|
|
86
|
+
...existing,
|
|
87
|
+
baseUrl: input.baseUrl,
|
|
88
|
+
provider: input.provider,
|
|
89
|
+
updatedAt: new Date().toISOString()
|
|
90
|
+
};
|
|
91
|
+
customProviders.delete(provider);
|
|
92
|
+
customProviders.set(row.provider, row);
|
|
93
|
+
const existingApiKey = apiKeys.get(provider);
|
|
94
|
+
if (existingApiKey) {
|
|
95
|
+
apiKeys.delete(provider);
|
|
96
|
+
apiKeys.set(row.provider, {
|
|
97
|
+
...existingApiKey,
|
|
98
|
+
provider: row.provider,
|
|
99
|
+
updatedAt: row.updatedAt
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return row;
|
|
103
|
+
},
|
|
104
|
+
updateCustomProviderModel: (providerId, modelId, input) => {
|
|
105
|
+
const rows = customModels.get(providerId) ?? [];
|
|
106
|
+
const index = rows.findIndex((model) => model.modelId === modelId);
|
|
107
|
+
const existingRow = rows[index];
|
|
108
|
+
if (index === -1 || !existingRow) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
const row = {
|
|
112
|
+
...existingRow,
|
|
113
|
+
api: input.api,
|
|
114
|
+
contextWindow: input.contextWindow,
|
|
115
|
+
input: JSON.stringify(input.input),
|
|
116
|
+
maxTokens: input.maxTokens,
|
|
117
|
+
name: input.name,
|
|
118
|
+
reasoning: input.reasoning,
|
|
119
|
+
updatedAt: new Date().toISOString()
|
|
120
|
+
};
|
|
121
|
+
rows[index] = row;
|
|
122
|
+
customModels.set(providerId, rows);
|
|
123
|
+
return row;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export function createSqliteModelProviderRepository(database) {
|
|
128
|
+
return {
|
|
129
|
+
createCustomModelProvider: (input) => {
|
|
130
|
+
const now = new Date().toISOString();
|
|
131
|
+
const row = {
|
|
132
|
+
baseUrl: input.baseUrl,
|
|
133
|
+
createdAt: now,
|
|
134
|
+
id: randomUUID(),
|
|
135
|
+
provider: input.provider,
|
|
136
|
+
updatedAt: now
|
|
137
|
+
};
|
|
138
|
+
database.db.insert(customModelProviders).values(row).run();
|
|
139
|
+
return row;
|
|
140
|
+
},
|
|
141
|
+
createCustomProviderModel: (input) => {
|
|
142
|
+
const now = new Date().toISOString();
|
|
143
|
+
const row = {
|
|
144
|
+
api: input.api,
|
|
145
|
+
contextWindow: input.contextWindow,
|
|
146
|
+
createdAt: now,
|
|
147
|
+
id: randomUUID(),
|
|
148
|
+
input: JSON.stringify(input.input),
|
|
149
|
+
maxTokens: input.maxTokens,
|
|
150
|
+
modelId: input.modelId,
|
|
151
|
+
name: input.name,
|
|
152
|
+
providerId: input.providerId,
|
|
153
|
+
reasoning: input.reasoning,
|
|
154
|
+
updatedAt: now
|
|
155
|
+
};
|
|
156
|
+
database.db.insert(customProviderModels).values(row).run();
|
|
157
|
+
return row;
|
|
158
|
+
},
|
|
159
|
+
deleteCustomModelProvider: (provider) => {
|
|
160
|
+
const existing = database.db
|
|
161
|
+
.select()
|
|
162
|
+
.from(customModelProviders)
|
|
163
|
+
.where(eq(customModelProviders.provider, provider))
|
|
164
|
+
.get();
|
|
165
|
+
if (!existing) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
database.db
|
|
169
|
+
.delete(customProviderModels)
|
|
170
|
+
.where(eq(customProviderModels.providerId, existing.id))
|
|
171
|
+
.run();
|
|
172
|
+
database.db
|
|
173
|
+
.delete(providerApiKeys)
|
|
174
|
+
.where(eq(providerApiKeys.provider, provider))
|
|
175
|
+
.run();
|
|
176
|
+
database.db
|
|
177
|
+
.delete(customModelProviders)
|
|
178
|
+
.where(eq(customModelProviders.id, existing.id))
|
|
179
|
+
.run();
|
|
180
|
+
return true;
|
|
181
|
+
},
|
|
182
|
+
deleteCustomProviderModel: (providerId, modelId) => {
|
|
183
|
+
const existing = database.db
|
|
184
|
+
.select()
|
|
185
|
+
.from(customProviderModels)
|
|
186
|
+
.where(eq(customProviderModels.providerId, providerId))
|
|
187
|
+
.all()
|
|
188
|
+
.find((model) => model.modelId === modelId);
|
|
189
|
+
if (!existing) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
database.db
|
|
193
|
+
.delete(customProviderModels)
|
|
194
|
+
.where(eq(customProviderModels.id, existing.id))
|
|
195
|
+
.run();
|
|
196
|
+
return true;
|
|
197
|
+
},
|
|
198
|
+
findCustomModelProviderByProvider: (provider) => database.db
|
|
199
|
+
.select()
|
|
200
|
+
.from(customModelProviders)
|
|
201
|
+
.where(eq(customModelProviders.provider, provider))
|
|
202
|
+
.get(),
|
|
203
|
+
findCustomProviderModel: (providerId, modelId) => database.db
|
|
204
|
+
.select()
|
|
205
|
+
.from(customProviderModels)
|
|
206
|
+
.where(eq(customProviderModels.providerId, providerId))
|
|
207
|
+
.all()
|
|
208
|
+
.find((model) => model.modelId === modelId),
|
|
209
|
+
findProviderApiKeyByProvider: (provider) => database.db
|
|
210
|
+
.select()
|
|
211
|
+
.from(providerApiKeys)
|
|
212
|
+
.where(eq(providerApiKeys.provider, provider))
|
|
213
|
+
.get(),
|
|
214
|
+
listCustomModelProviders: () => database.db.select().from(customModelProviders).all(),
|
|
215
|
+
listCustomProviderModelsByProviderId: (providerId) => database.db
|
|
216
|
+
.select()
|
|
217
|
+
.from(customProviderModels)
|
|
218
|
+
.where(eq(customProviderModels.providerId, providerId))
|
|
219
|
+
.all(),
|
|
220
|
+
saveProviderApiKey: (input) => {
|
|
221
|
+
const existing = database.db
|
|
222
|
+
.select()
|
|
223
|
+
.from(providerApiKeys)
|
|
224
|
+
.where(eq(providerApiKeys.provider, input.provider))
|
|
225
|
+
.get();
|
|
226
|
+
const now = new Date().toISOString();
|
|
227
|
+
const row = {
|
|
228
|
+
apiKeyCiphertext: input.apiKeyCiphertext,
|
|
229
|
+
apiKeyIv: input.apiKeyIv,
|
|
230
|
+
apiKeyTag: input.apiKeyTag,
|
|
231
|
+
createdAt: existing?.createdAt ?? now,
|
|
232
|
+
id: existing?.id ?? randomUUID(),
|
|
233
|
+
provider: input.provider,
|
|
234
|
+
updatedAt: now
|
|
235
|
+
};
|
|
236
|
+
if (existing) {
|
|
237
|
+
database.db
|
|
238
|
+
.update(providerApiKeys)
|
|
239
|
+
.set(row)
|
|
240
|
+
.where(eq(providerApiKeys.id, existing.id))
|
|
241
|
+
.run();
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
database.db.insert(providerApiKeys).values(row).run();
|
|
245
|
+
}
|
|
246
|
+
return row;
|
|
247
|
+
},
|
|
248
|
+
updateCustomModelProvider: (provider, input) => {
|
|
249
|
+
const existing = database.db
|
|
250
|
+
.select()
|
|
251
|
+
.from(customModelProviders)
|
|
252
|
+
.where(eq(customModelProviders.provider, provider))
|
|
253
|
+
.get();
|
|
254
|
+
if (!existing) {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
const row = {
|
|
258
|
+
...existing,
|
|
259
|
+
baseUrl: input.baseUrl,
|
|
260
|
+
provider: input.provider,
|
|
261
|
+
updatedAt: new Date().toISOString()
|
|
262
|
+
};
|
|
263
|
+
database.db
|
|
264
|
+
.update(customModelProviders)
|
|
265
|
+
.set(row)
|
|
266
|
+
.where(eq(customModelProviders.id, existing.id))
|
|
267
|
+
.run();
|
|
268
|
+
const existingApiKey = database.db
|
|
269
|
+
.select()
|
|
270
|
+
.from(providerApiKeys)
|
|
271
|
+
.where(eq(providerApiKeys.provider, provider))
|
|
272
|
+
.get();
|
|
273
|
+
if (existingApiKey) {
|
|
274
|
+
database.db
|
|
275
|
+
.update(providerApiKeys)
|
|
276
|
+
.set({
|
|
277
|
+
...existingApiKey,
|
|
278
|
+
provider: row.provider,
|
|
279
|
+
updatedAt: row.updatedAt
|
|
280
|
+
})
|
|
281
|
+
.where(eq(providerApiKeys.id, existingApiKey.id))
|
|
282
|
+
.run();
|
|
283
|
+
}
|
|
284
|
+
return row;
|
|
285
|
+
},
|
|
286
|
+
updateCustomProviderModel: (providerId, modelId, input) => {
|
|
287
|
+
const existing = database.db
|
|
288
|
+
.select()
|
|
289
|
+
.from(customProviderModels)
|
|
290
|
+
.where(eq(customProviderModels.providerId, providerId))
|
|
291
|
+
.all()
|
|
292
|
+
.find((model) => model.modelId === modelId);
|
|
293
|
+
if (!existing) {
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
const row = {
|
|
297
|
+
...existing,
|
|
298
|
+
api: input.api,
|
|
299
|
+
contextWindow: input.contextWindow,
|
|
300
|
+
input: JSON.stringify(input.input),
|
|
301
|
+
maxTokens: input.maxTokens,
|
|
302
|
+
name: input.name,
|
|
303
|
+
reasoning: input.reasoning,
|
|
304
|
+
updatedAt: new Date().toISOString()
|
|
305
|
+
};
|
|
306
|
+
database.db
|
|
307
|
+
.update(customProviderModels)
|
|
308
|
+
.set(row)
|
|
309
|
+
.where(eq(customProviderModels.id, existing.id))
|
|
310
|
+
.run();
|
|
311
|
+
return row;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import type { ModelProvidersService } from "./model-providers-service";
|
|
3
|
+
import type { ModelProxiesService } from "../model-proxies/model-proxies-service";
|
|
4
|
+
export interface CreateModelProvidersRouterOptions {
|
|
5
|
+
modelProxiesService?: ModelProxiesService;
|
|
6
|
+
service?: ModelProvidersService;
|
|
7
|
+
}
|
|
8
|
+
export declare function createModelProvidersRouter(options?: CreateModelProvidersRouterOptions): Router;
|
|
9
|
+
//# sourceMappingURL=model-providers-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-providers-router.d.ts","sourceRoot":"","sources":["../../../src/modules/model-providers/model-providers-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA+B,MAAM,SAAS,CAAC;AAK9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAElF,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,OAAO,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAqBD,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,iCAAsC,GAC9C,MAAM,CA8TR"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { sendError, sendSuccess } from "../../response/index.js";
|
|
3
|
+
import { RESPONSE_CODE_DEFINITIONS } from "../../response/response-codes.js";
|
|
4
|
+
import { getDefaultModelProvidersService } from "./default-model-provider-service.js";
|
|
5
|
+
import { getDefaultModelProxiesService } from "../model-proxies/default-model-proxies-service.js";
|
|
6
|
+
export function createModelProvidersRouter(options = {}) {
|
|
7
|
+
const router = Router();
|
|
8
|
+
const getService = () => options.service ?? getDefaultModelProvidersService();
|
|
9
|
+
const getProxyService = () => options.modelProxiesService ??
|
|
10
|
+
(options.service ? undefined : getDefaultModelProxiesService());
|
|
11
|
+
router.get("/model-providers", (_request, response) => {
|
|
12
|
+
const providers = getService().listModelProviders();
|
|
13
|
+
const proxyCount = getProxyService()?.listProxies().length ?? 0;
|
|
14
|
+
sendSuccess(response, [
|
|
15
|
+
...providers,
|
|
16
|
+
...(proxyCount > 0 && !providers.some((provider) => provider.id === "local")
|
|
17
|
+
? [
|
|
18
|
+
{
|
|
19
|
+
hasApiKey: true,
|
|
20
|
+
id: "local",
|
|
21
|
+
modelCount: proxyCount,
|
|
22
|
+
source: "proxy"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
: [])
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
router.post("/model-providers/custom", (request, response) => {
|
|
29
|
+
if (typeof request.body.provider !== "string" ||
|
|
30
|
+
typeof request.body.baseUrl !== "string") {
|
|
31
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "provider and baseUrl must be strings");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
sendSuccess(response, getService().createCustomModelProvider(request.body.provider, request.body.baseUrl));
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, error instanceof Error ? error.message : "Failed to create provider");
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
router.put("/model-providers/custom/:provider", (request, response) => {
|
|
42
|
+
if (typeof request.body.provider !== "string" ||
|
|
43
|
+
typeof request.body.baseUrl !== "string") {
|
|
44
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "provider and baseUrl must be strings");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const updatedProvider = getService().updateCustomModelProvider(String(request.params.provider ?? ""), request.body.provider, request.body.baseUrl);
|
|
49
|
+
if (!updatedProvider) {
|
|
50
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom provider");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
sendSuccess(response, updatedProvider);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, error instanceof Error ? error.message : "Failed to update provider");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
router.delete("/model-providers/custom/:provider", (request, response) => {
|
|
60
|
+
const provider = String(request.params.provider ?? "");
|
|
61
|
+
const deleted = getService().deleteCustomModelProvider(provider);
|
|
62
|
+
if (!deleted) {
|
|
63
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom provider");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
sendSuccess(response, { provider });
|
|
67
|
+
});
|
|
68
|
+
router.get("/model-providers/:provider/models", (request, response) => {
|
|
69
|
+
const provider = String(request.params.provider ?? "");
|
|
70
|
+
const service = getService();
|
|
71
|
+
if (provider === "local") {
|
|
72
|
+
const proxyService = getProxyService();
|
|
73
|
+
if (proxyService) {
|
|
74
|
+
sendSuccess(response, proxyService.listProxyModels());
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!service.hasProvider(provider)) {
|
|
78
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown provider");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
sendSuccess(response, service.listModelsForProvider(provider));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!service.hasProvider(provider)) {
|
|
85
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown provider");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
sendSuccess(response, service.listModelsForProvider(provider));
|
|
89
|
+
});
|
|
90
|
+
router.post("/model-providers/:provider/models", (request, response) => {
|
|
91
|
+
if (!isValidCreateModelBody(request.body)) {
|
|
92
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "api, modelId, name, input, contextWindow, maxTokens and reasoning are required");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
sendSuccess(response, getService().createCustomProviderModel(String(request.params.provider ?? ""), {
|
|
97
|
+
api: request.body.api,
|
|
98
|
+
contextWindow: request.body.contextWindow,
|
|
99
|
+
input: request.body.input,
|
|
100
|
+
maxTokens: request.body.maxTokens,
|
|
101
|
+
modelId: request.body.modelId,
|
|
102
|
+
name: request.body.name,
|
|
103
|
+
reasoning: request.body.reasoning
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const message = error instanceof Error ? error.message : "Failed to create model";
|
|
108
|
+
const code = message === "Unknown custom provider"
|
|
109
|
+
? RESPONSE_CODE_DEFINITIONS.notFound
|
|
110
|
+
: RESPONSE_CODE_DEFINITIONS.badRequest;
|
|
111
|
+
sendError(response, code, message);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
router.put("/model-providers/:provider/models/:modelId", (request, response) => {
|
|
115
|
+
if (!isValidUpdateModelBody(request.body)) {
|
|
116
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "api, name, input, contextWindow, maxTokens and reasoning are required");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const updatedModel = getService().updateCustomProviderModel(String(request.params.provider ?? ""), String(request.params.modelId ?? ""), {
|
|
120
|
+
api: request.body.api,
|
|
121
|
+
contextWindow: request.body.contextWindow,
|
|
122
|
+
input: request.body.input,
|
|
123
|
+
maxTokens: request.body.maxTokens,
|
|
124
|
+
name: request.body.name,
|
|
125
|
+
reasoning: request.body.reasoning
|
|
126
|
+
});
|
|
127
|
+
if (!updatedModel) {
|
|
128
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom model");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
sendSuccess(response, updatedModel);
|
|
132
|
+
});
|
|
133
|
+
router.delete("/model-providers/:provider/models/:modelId", (request, response) => {
|
|
134
|
+
const provider = String(request.params.provider ?? "");
|
|
135
|
+
const modelId = String(request.params.modelId ?? "");
|
|
136
|
+
const deleted = getService().deleteCustomProviderModel(provider, modelId);
|
|
137
|
+
if (!deleted) {
|
|
138
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom model");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
sendSuccess(response, {
|
|
142
|
+
modelId,
|
|
143
|
+
provider
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
router.put("/model-providers/:provider/api-key", (request, response) => {
|
|
147
|
+
const provider = String(request.params.provider ?? "");
|
|
148
|
+
const service = getService();
|
|
149
|
+
if (!service.hasProvider(provider)) {
|
|
150
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown provider");
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (typeof request.body.apiKey !== "string") {
|
|
154
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "apiKey must be a string");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const providerSummary = service.storeProviderApiKey(provider, request.body.apiKey);
|
|
159
|
+
sendSuccess(response, {
|
|
160
|
+
hasApiKey: providerSummary.hasApiKey,
|
|
161
|
+
provider: providerSummary.id
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.internalError, error instanceof Error ? error.message : "Failed to store apiKey");
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return router;
|
|
169
|
+
}
|
|
170
|
+
function isValidCreateModelBody(body) {
|
|
171
|
+
return (typeof body.api === "string" &&
|
|
172
|
+
typeof body.modelId === "string" &&
|
|
173
|
+
typeof body.name === "string" &&
|
|
174
|
+
Array.isArray(body.input) &&
|
|
175
|
+
body.input.every((item) => typeof item === "string") &&
|
|
176
|
+
typeof body.contextWindow === "number" &&
|
|
177
|
+
typeof body.maxTokens === "number" &&
|
|
178
|
+
typeof body.reasoning === "boolean");
|
|
179
|
+
}
|
|
180
|
+
function isValidUpdateModelBody(body) {
|
|
181
|
+
return (typeof body.api === "string" &&
|
|
182
|
+
typeof body.name === "string" &&
|
|
183
|
+
Array.isArray(body.input) &&
|
|
184
|
+
body.input.every((item) => typeof item === "string") &&
|
|
185
|
+
typeof body.contextWindow === "number" &&
|
|
186
|
+
typeof body.maxTokens === "number" &&
|
|
187
|
+
typeof body.reasoning === "boolean");
|
|
188
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ModelProviderRepository } from "./model-provider-repository";
|
|
2
|
+
import type { ModelProxiesService } from "../model-proxies/model-proxies-service";
|
|
3
|
+
export interface ModelProviderSummary {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
hasApiKey: boolean;
|
|
6
|
+
id: string;
|
|
7
|
+
modelCount: number;
|
|
8
|
+
source: "builtin" | "custom" | "proxy";
|
|
9
|
+
}
|
|
10
|
+
export interface CustomModelProviderSummary {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
id: string;
|
|
14
|
+
provider: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ModelSummary {
|
|
18
|
+
api: string;
|
|
19
|
+
contextWindow: number;
|
|
20
|
+
id: string;
|
|
21
|
+
input: string[];
|
|
22
|
+
maxTokens: number;
|
|
23
|
+
name: string;
|
|
24
|
+
provider: string;
|
|
25
|
+
reasoning: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface ModelProvidersServiceOptions {
|
|
28
|
+
modelProxiesService?: ModelProxiesService;
|
|
29
|
+
providerApiKeyEncryptionKey: string;
|
|
30
|
+
repository: ModelProviderRepository;
|
|
31
|
+
}
|
|
32
|
+
export interface ModelProvidersService {
|
|
33
|
+
createCustomModelProvider: (provider: string, baseUrl: string) => CustomModelProviderSummary;
|
|
34
|
+
createCustomProviderModel: (provider: string, input: Omit<ModelSummary, "id" | "provider"> & {
|
|
35
|
+
modelId: string;
|
|
36
|
+
}) => ModelSummary;
|
|
37
|
+
deleteCustomModelProvider: (provider: string) => boolean;
|
|
38
|
+
deleteCustomProviderModel: (provider: string, modelId: string) => boolean;
|
|
39
|
+
getConfiguredModelForProvider: (provider: string, modelId: string) => {
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
baseUrl: string;
|
|
42
|
+
model: ModelSummary;
|
|
43
|
+
} | null;
|
|
44
|
+
hasProvider: (provider: string) => boolean;
|
|
45
|
+
listModelsForProvider: (provider: string) => ModelSummary[];
|
|
46
|
+
listModelProviders: () => ModelProviderSummary[];
|
|
47
|
+
storeProviderApiKey: (provider: string, apiKey: string) => ModelProviderSummary;
|
|
48
|
+
updateCustomModelProvider: (provider: string, nextProvider: string, baseUrl: string) => CustomModelProviderSummary | null;
|
|
49
|
+
updateCustomProviderModel: (provider: string, modelId: string, input: Omit<ModelSummary, "id" | "provider">) => ModelSummary | null;
|
|
50
|
+
}
|
|
51
|
+
export declare function createModelProvidersService(options: ModelProvidersServiceOptions): ModelProvidersService;
|
|
52
|
+
//# sourceMappingURL=model-providers-service.d.ts.map
|