@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,17 @@
|
|
|
1
|
+
import { DB_FILE } from "../../config/const.js";
|
|
2
|
+
import { loadApiEnv } from "../../config/env.js";
|
|
3
|
+
import { createDatabase, migrateDatabase } from "../../db/index.js";
|
|
4
|
+
import { createSqliteUsageStatsRepository, createUsageStatsService } from "./usage-stats-service.js";
|
|
5
|
+
let service;
|
|
6
|
+
export function getDefaultUsageStatsService() {
|
|
7
|
+
if (service) {
|
|
8
|
+
return service;
|
|
9
|
+
}
|
|
10
|
+
loadApiEnv();
|
|
11
|
+
const database = createDatabase(process.env.SQLITE_DB_PATH ?? DB_FILE);
|
|
12
|
+
migrateDatabase(database.sqlite);
|
|
13
|
+
service = createUsageStatsService({
|
|
14
|
+
repository: createSqliteUsageStatsRepository(database)
|
|
15
|
+
});
|
|
16
|
+
return service;
|
|
17
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createInMemoryUsageStatsRepository, createSqliteUsageStatsRepository, createUsageStatsService, type UsageStatsRepository, type UsageStatsService } from "./usage-stats-service";
|
|
2
|
+
export { createUsageStatsRouter, type CreateUsageStatsRouterOptions } from "./usage-stats-router";
|
|
3
|
+
export type { ModelUsageBucket, ModelUsagePoint, ModelUsageRange, ModelUsageStatsResult, TaskUsageGroupBy, TaskUsageRange, TaskUsageRow, TaskUsageStatsResult } from "./usage-stats-types";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/usage-stats/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,gCAAgC,EAChC,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,EACnC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACrB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import type { UsageStatsService } from "./usage-stats-service";
|
|
3
|
+
export interface CreateUsageStatsRouterOptions {
|
|
4
|
+
usageStatsService?: UsageStatsService;
|
|
5
|
+
}
|
|
6
|
+
export declare function createUsageStatsRouter(options?: CreateUsageStatsRouterOptions): Router;
|
|
7
|
+
//# sourceMappingURL=usage-stats-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-stats-router.d.ts","sourceRoot":"","sources":["../../../src/modules/usage-stats/usage-stats-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA+B,MAAM,SAAS,CAAC;AAU9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,WAAW,6BAA6B;IAC5C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,6BAAkC,GAC1C,MAAM,CA8CR"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { getDefaultUsageStatsService } from "./default-usage-stats-service.js";
|
|
5
|
+
export function createUsageStatsRouter(options = {}) {
|
|
6
|
+
const router = Router();
|
|
7
|
+
const getService = () => options.usageStatsService ?? getDefaultUsageStatsService();
|
|
8
|
+
router.get("/usage-stats/models", (request, response) => {
|
|
9
|
+
const range = getStringQuery(request.query.range) ?? "24h";
|
|
10
|
+
if (!isModelUsageRange(range)) {
|
|
11
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "range must be 24h or 30d");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
sendSuccess(response, getService().getModelTokenUsage({ range }));
|
|
15
|
+
});
|
|
16
|
+
router.get("/usage-stats/tasks", (request, response) => {
|
|
17
|
+
const range = getStringQuery(request.query.range) ?? "7d";
|
|
18
|
+
const groupBy = getStringQuery(request.query.groupBy) ?? "task";
|
|
19
|
+
if (!isTaskUsageRange(range)) {
|
|
20
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "range must be 7d or 30d");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!isTaskUsageGroupBy(groupBy)) {
|
|
24
|
+
sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "groupBy must be task or workspace");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
sendSuccess(response, getService().getTaskTokenUsage({ groupBy, range }));
|
|
28
|
+
});
|
|
29
|
+
return router;
|
|
30
|
+
}
|
|
31
|
+
function getStringQuery(value) {
|
|
32
|
+
return typeof value === "string" ? value : null;
|
|
33
|
+
}
|
|
34
|
+
function isModelUsageRange(value) {
|
|
35
|
+
return value === "24h" || value === "30d";
|
|
36
|
+
}
|
|
37
|
+
function isTaskUsageRange(value) {
|
|
38
|
+
return value === "7d" || value === "30d";
|
|
39
|
+
}
|
|
40
|
+
function isTaskUsageGroupBy(value) {
|
|
41
|
+
return value === "task" || value === "workspace";
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AppDatabase, ModelTokenUsageHourlyRow } from "../../db";
|
|
2
|
+
import type { ModelUsageRange, ModelUsageStatsResult, TaskUsageGroupBy, TaskUsageRange, TaskUsageSourceRow, TaskUsageStatsResult } from "./usage-stats-types";
|
|
3
|
+
export interface UsageStatsRepositorySeed {
|
|
4
|
+
modelTokenUsageHourly: ModelTokenUsageHourlyRow[];
|
|
5
|
+
tasks: TaskUsageSeedTask[];
|
|
6
|
+
workspaces: TaskUsageSeedWorkspace[];
|
|
7
|
+
}
|
|
8
|
+
export interface TaskUsageSeedTask {
|
|
9
|
+
createdAt: string;
|
|
10
|
+
id: string;
|
|
11
|
+
inputToken: number;
|
|
12
|
+
outputToken: number;
|
|
13
|
+
title: string;
|
|
14
|
+
workspaceId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface TaskUsageSeedWorkspace {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}
|
|
20
|
+
export interface UsageStatsRepository {
|
|
21
|
+
listModelTokenUsageSince: (from: string) => ModelTokenUsageHourlyRow[];
|
|
22
|
+
listTasksCreatedSince: (from: string) => TaskUsageSourceRow[];
|
|
23
|
+
}
|
|
24
|
+
export interface CreateUsageStatsServiceOptions {
|
|
25
|
+
now?: () => Date;
|
|
26
|
+
repository: UsageStatsRepository;
|
|
27
|
+
}
|
|
28
|
+
export interface UsageStatsService {
|
|
29
|
+
getModelTokenUsage: (options: {
|
|
30
|
+
range: ModelUsageRange;
|
|
31
|
+
}) => ModelUsageStatsResult;
|
|
32
|
+
getTaskTokenUsage: (options: {
|
|
33
|
+
groupBy: TaskUsageGroupBy;
|
|
34
|
+
range: TaskUsageRange;
|
|
35
|
+
}) => TaskUsageStatsResult;
|
|
36
|
+
}
|
|
37
|
+
export declare function createUsageStatsService({ now, repository }: CreateUsageStatsServiceOptions): UsageStatsService;
|
|
38
|
+
export declare function createInMemoryUsageStatsRepository(seed: UsageStatsRepositorySeed): UsageStatsRepository;
|
|
39
|
+
export declare function createSqliteUsageStatsRepository(database: AppDatabase): UsageStatsRepository;
|
|
40
|
+
//# sourceMappingURL=usage-stats-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-stats-service.d.ts","sourceRoot":"","sources":["../../../src/modules/usage-stats/usage-stats-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEtE,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,wBAAwB;IACvC,qBAAqB,EAAE,wBAAwB,EAAE,CAAC;IAClD,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,UAAU,EAAE,sBAAsB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,wBAAwB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,wBAAwB,EAAE,CAAC;IACvE,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,kBAAkB,EAAE,CAAC;CAC/D;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,UAAU,EAAE,oBAAoB,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,EAAE,CAClB,OAAO,EAAE;QAAE,KAAK,EAAE,eAAe,CAAA;KAAE,KAChC,qBAAqB,CAAC;IAC3B,iBAAiB,EAAE,CACjB,OAAO,EAAE;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,KAAK,EAAE,cAAc,CAAA;KAAE,KAC1D,oBAAoB,CAAC;CAC3B;AAID,wBAAgB,uBAAuB,CAAC,EACtC,GAAsB,EACtB,UAAU,EACX,EAAE,8BAA8B,GAAG,iBAAiB,CAwDpD;AAED,wBAAgB,kCAAkC,CAChD,IAAI,EAAE,wBAAwB,GAC7B,oBAAoB,CAuBtB;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,WAAW,GACpB,oBAAoB,CA0BtB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { asc, eq, gte } from "drizzle-orm";
|
|
2
|
+
import { modelTokenUsageHourly, tasks, workspaces } from "../../db/index.js";
|
|
3
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
4
|
+
export function createUsageStatsService({ now = () => new Date(), repository }) {
|
|
5
|
+
return {
|
|
6
|
+
getModelTokenUsage: ({ range }) => {
|
|
7
|
+
const bucket = range === "24h" ? "hour" : "day";
|
|
8
|
+
const windowMs = range === "24h" ? DAY_MS : 30 * DAY_MS;
|
|
9
|
+
const from = new Date(now().getTime() - windowMs).toISOString();
|
|
10
|
+
const rows = repository.listModelTokenUsageSince(from);
|
|
11
|
+
const pointMap = new Map();
|
|
12
|
+
for (const row of rows) {
|
|
13
|
+
const period = bucket === "hour" ? normalizeHour(row.hour) : toUtcDay(row.hour);
|
|
14
|
+
const key = `${period}\0${row.provider}\0${row.modelName}`;
|
|
15
|
+
const existingPoint = pointMap.get(key);
|
|
16
|
+
pointMap.set(key, {
|
|
17
|
+
hour: period,
|
|
18
|
+
inputToken: (existingPoint?.inputToken ?? 0) + row.inputToken,
|
|
19
|
+
modelName: row.modelName,
|
|
20
|
+
outputToken: (existingPoint?.outputToken ?? 0) + row.outputToken,
|
|
21
|
+
provider: row.provider
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
bucket,
|
|
26
|
+
points: [...pointMap.values()]
|
|
27
|
+
.map((row) => ({
|
|
28
|
+
inputToken: row.inputToken,
|
|
29
|
+
modelName: row.modelName,
|
|
30
|
+
outputToken: row.outputToken,
|
|
31
|
+
period: row.hour,
|
|
32
|
+
provider: row.provider
|
|
33
|
+
}))
|
|
34
|
+
.sort(sortModelPoints),
|
|
35
|
+
range
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
getTaskTokenUsage: ({ groupBy, range }) => {
|
|
39
|
+
const windowMs = range === "7d" ? 7 * DAY_MS : 30 * DAY_MS;
|
|
40
|
+
const from = new Date(now().getTime() - windowMs).toISOString();
|
|
41
|
+
const rows = repository.listTasksCreatedSince(from);
|
|
42
|
+
if (groupBy === "task") {
|
|
43
|
+
return {
|
|
44
|
+
groupBy,
|
|
45
|
+
range,
|
|
46
|
+
rows: rows.map(toTaskUsageRow).sort(sortTaskUsageRows)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
groupBy,
|
|
51
|
+
range,
|
|
52
|
+
rows: groupRowsByWorkspace(rows).sort(sortTaskUsageRows)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function createInMemoryUsageStatsRepository(seed) {
|
|
58
|
+
const modelRows = seed.modelTokenUsageHourly.map((row) => ({ ...row }));
|
|
59
|
+
const tasksRows = seed.tasks.map((row) => ({ ...row }));
|
|
60
|
+
const workspaceRows = seed.workspaces.map((row) => ({ ...row }));
|
|
61
|
+
return {
|
|
62
|
+
listModelTokenUsageSince: (from) => modelRows
|
|
63
|
+
.filter((row) => row.hour >= from)
|
|
64
|
+
.sort((left, right) => left.hour.localeCompare(right.hour)),
|
|
65
|
+
listTasksCreatedSince: (from) => tasksRows
|
|
66
|
+
.filter((task) => task.createdAt >= from)
|
|
67
|
+
.map((task) => {
|
|
68
|
+
const workspace = workspaceRows.find((row) => row.id === task.workspaceId);
|
|
69
|
+
return {
|
|
70
|
+
...task,
|
|
71
|
+
workspaceName: workspace?.name ?? "未知工作区"
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
.sort((left, right) => left.createdAt.localeCompare(right.createdAt))
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function createSqliteUsageStatsRepository(database) {
|
|
78
|
+
return {
|
|
79
|
+
listModelTokenUsageSince: (from) => database.db
|
|
80
|
+
.select()
|
|
81
|
+
.from(modelTokenUsageHourly)
|
|
82
|
+
.where(gte(modelTokenUsageHourly.hour, from))
|
|
83
|
+
.orderBy(asc(modelTokenUsageHourly.hour))
|
|
84
|
+
.all(),
|
|
85
|
+
listTasksCreatedSince: (from) => database.db
|
|
86
|
+
.select({
|
|
87
|
+
createdAt: tasks.createdAt,
|
|
88
|
+
id: tasks.id,
|
|
89
|
+
inputToken: tasks.inputToken,
|
|
90
|
+
outputToken: tasks.outputToken,
|
|
91
|
+
title: tasks.title,
|
|
92
|
+
workspaceId: tasks.workspaceId,
|
|
93
|
+
workspaceName: workspaces.name
|
|
94
|
+
})
|
|
95
|
+
.from(tasks)
|
|
96
|
+
.innerJoin(workspaces, eq(tasks.workspaceId, workspaces.id))
|
|
97
|
+
.where(gte(tasks.createdAt, from))
|
|
98
|
+
.orderBy(asc(tasks.createdAt))
|
|
99
|
+
.all()
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function groupRowsByWorkspace(rows) {
|
|
103
|
+
const rowMap = new Map();
|
|
104
|
+
for (const row of rows) {
|
|
105
|
+
const existingRow = rowMap.get(row.workspaceId);
|
|
106
|
+
rowMap.set(row.workspaceId, {
|
|
107
|
+
id: row.workspaceId,
|
|
108
|
+
inputToken: (existingRow?.inputToken ?? 0) + row.inputToken,
|
|
109
|
+
label: row.workspaceName,
|
|
110
|
+
outputToken: (existingRow?.outputToken ?? 0) + row.outputToken,
|
|
111
|
+
workspaceId: row.workspaceId,
|
|
112
|
+
workspaceName: row.workspaceName
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return [...rowMap.values()];
|
|
116
|
+
}
|
|
117
|
+
function toTaskUsageRow(row) {
|
|
118
|
+
return {
|
|
119
|
+
id: row.id,
|
|
120
|
+
inputToken: row.inputToken,
|
|
121
|
+
label: row.title,
|
|
122
|
+
outputToken: row.outputToken,
|
|
123
|
+
workspaceId: row.workspaceId,
|
|
124
|
+
workspaceName: row.workspaceName
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function normalizeHour(value) {
|
|
128
|
+
const date = new Date(value);
|
|
129
|
+
date.setUTCMinutes(0, 0, 0);
|
|
130
|
+
return date.toISOString();
|
|
131
|
+
}
|
|
132
|
+
function toUtcDay(value) {
|
|
133
|
+
const date = new Date(value);
|
|
134
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
135
|
+
return date.toISOString();
|
|
136
|
+
}
|
|
137
|
+
function sortModelPoints(left, right) {
|
|
138
|
+
return (left.period.localeCompare(right.period) ||
|
|
139
|
+
left.provider.localeCompare(right.provider) ||
|
|
140
|
+
left.modelName.localeCompare(right.modelName));
|
|
141
|
+
}
|
|
142
|
+
function sortTaskUsageRows(left, right) {
|
|
143
|
+
return left.label.localeCompare(right.label) || left.id.localeCompare(right.id);
|
|
144
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type ModelUsageRange = "24h" | "30d";
|
|
2
|
+
export type ModelUsageBucket = "hour" | "day";
|
|
3
|
+
export type TaskUsageRange = "7d" | "30d";
|
|
4
|
+
export type TaskUsageGroupBy = "task" | "workspace";
|
|
5
|
+
export interface ModelUsagePoint {
|
|
6
|
+
inputToken: number;
|
|
7
|
+
modelName: string;
|
|
8
|
+
outputToken: number;
|
|
9
|
+
period: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ModelUsageStatsResult {
|
|
13
|
+
bucket: ModelUsageBucket;
|
|
14
|
+
points: ModelUsagePoint[];
|
|
15
|
+
range: ModelUsageRange;
|
|
16
|
+
}
|
|
17
|
+
export interface TaskUsageRow {
|
|
18
|
+
id: string;
|
|
19
|
+
inputToken: number;
|
|
20
|
+
label: string;
|
|
21
|
+
outputToken: number;
|
|
22
|
+
workspaceId: string;
|
|
23
|
+
workspaceName: string;
|
|
24
|
+
}
|
|
25
|
+
export interface TaskUsageStatsResult {
|
|
26
|
+
groupBy: TaskUsageGroupBy;
|
|
27
|
+
range: TaskUsageRange;
|
|
28
|
+
rows: TaskUsageRow[];
|
|
29
|
+
}
|
|
30
|
+
export interface TaskUsageSourceRow {
|
|
31
|
+
createdAt: string;
|
|
32
|
+
id: string;
|
|
33
|
+
inputToken: number;
|
|
34
|
+
outputToken: number;
|
|
35
|
+
title: string;
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
workspaceName: string;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=usage-stats-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-stats-types.d.ts","sourceRoot":"","sources":["../../../src/modules/usage-stats/usage-stats-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,CAAC;AAC5C,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,KAAK,CAAC;AAC9C,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,KAAK,CAAC;AAC1C,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,cAAc,CAAC;IACtB,IAAI,EAAE,YAAY,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-workspaces-service.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/default-workspaces-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAI9B,wBAAgB,2BAA2B,IAAI,iBAAiB,CAkB/D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { loadApiEnv } from "../../config/env.js";
|
|
2
|
+
import { DB_FILE } from "../../config/const.js";
|
|
3
|
+
import { createDatabase, migrateDatabase } from "../../db/index.js";
|
|
4
|
+
import { createSqliteWorkspaceRepository } from "./workspace-repository.js";
|
|
5
|
+
import { getDefaultActiveTaskRunRegistry } from "../agents/task/active-run-registry.js";
|
|
6
|
+
import { createWorkspacesService } from "./workspaces-service.js";
|
|
7
|
+
let service;
|
|
8
|
+
export function getDefaultWorkspacesService() {
|
|
9
|
+
if (service) {
|
|
10
|
+
return service;
|
|
11
|
+
}
|
|
12
|
+
loadApiEnv();
|
|
13
|
+
const database = createDatabase(process.env.SQLITE_DB_PATH ?? DB_FILE);
|
|
14
|
+
migrateDatabase(database.sqlite);
|
|
15
|
+
service = createWorkspacesService({
|
|
16
|
+
activeTaskRuns: getDefaultActiveTaskRunRegistry(),
|
|
17
|
+
repository: createSqliteWorkspaceRepository(database)
|
|
18
|
+
});
|
|
19
|
+
return service;
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getDefaultWorkspacesService } from "./default-workspaces-service";
|
|
2
|
+
export { createInMemoryWorkspaceRepository, createSqliteWorkspaceRepository, type WorkspaceRepository, type WorkspaceRepositorySeed } from "./workspace-repository";
|
|
3
|
+
export { type RecentWorkspaceTasksResult, type WorkspaceTaskPageResult, type WorkspaceTaskSummary, type WorkspaceWithTasksSummary } from "./workspace-types";
|
|
4
|
+
export { createWorkspacesRouter, type CreateWorkspacesRouterOptions } from "./workspaces-router";
|
|
5
|
+
export { createWorkspacesService, type WorkspacesService } from "./workspaces-service";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EACL,iCAAiC,EACjC,+BAA+B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,EACnC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,uBAAuB,EACvB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getDefaultWorkspacesService } from "./default-workspaces-service.js";
|
|
2
|
+
export { createInMemoryWorkspaceRepository, createSqliteWorkspaceRepository } from "./workspace-repository.js";
|
|
3
|
+
export {} from "./workspace-types.js";
|
|
4
|
+
export { createWorkspacesRouter } from "./workspaces-router.js";
|
|
5
|
+
export { createWorkspacesService } from "./workspaces-service.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AppDatabase, ModelTokenUsageHourlyRow, NewModelTokenUsageHourlyRow, NewTaskRow, NewWorkspaceRow, TaskRow, WorkspaceRow } from "../../db";
|
|
2
|
+
export interface WorkspaceRepositorySeed {
|
|
3
|
+
tasks: NewTaskRow[];
|
|
4
|
+
workspaces: NewWorkspaceRow[];
|
|
5
|
+
}
|
|
6
|
+
export interface ListWorkspaceTasksInput {
|
|
7
|
+
limit: number;
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ListWorkspaceTasksAfterInput extends ListWorkspaceTasksInput {
|
|
11
|
+
afterLastContinuedAt: string;
|
|
12
|
+
}
|
|
13
|
+
export interface WorkspaceRepository {
|
|
14
|
+
addModelTokenUsageHourly: (usage: NewModelTokenUsageHourlyRow) => ModelTokenUsageHourlyRow;
|
|
15
|
+
addTaskTokenUsage: (taskId: string, usage: Pick<TaskRow, "inputToken" | "outputToken">) => TaskRow | undefined;
|
|
16
|
+
createTask: (task: NewTaskRow) => TaskRow;
|
|
17
|
+
createWorkspace: (workspace: NewWorkspaceRow) => WorkspaceRow;
|
|
18
|
+
deleteTaskById: (taskId: string) => void;
|
|
19
|
+
deleteTasksByWorkspaceId: (workspaceId: string) => void;
|
|
20
|
+
deleteWorkspaceById: (workspaceId: string) => void;
|
|
21
|
+
findTaskById: (taskId: string) => TaskRow | undefined;
|
|
22
|
+
findWorkspaceById: (workspaceId: string) => WorkspaceRow | undefined;
|
|
23
|
+
findWorkspaceByPath: (workspacePath: string) => WorkspaceRow | undefined;
|
|
24
|
+
listTasksAfterLastContinuedAt: (input: ListWorkspaceTasksAfterInput) => TaskRow[];
|
|
25
|
+
listAllTasksByWorkspaceId: (workspaceId: string) => TaskRow[];
|
|
26
|
+
listTasksByWorkspaceId: (input: ListWorkspaceTasksInput) => TaskRow[];
|
|
27
|
+
listWorkspaces: () => WorkspaceRow[];
|
|
28
|
+
updateTaskTitle: (taskId: string, title: string, updatedAt: string) => TaskRow | undefined;
|
|
29
|
+
updateTaskContinuedAt: (taskId: string, continuedAt: string) => TaskRow | undefined;
|
|
30
|
+
updateTaskModel: (taskId: string, model: Pick<TaskRow, "lastModelId" | "lastModelName" | "lastModelProvider" | "lastModelProviderSource">, updatedAt: string) => TaskRow | undefined;
|
|
31
|
+
updateTaskOptions: (taskId: string, options: Pick<TaskRow, "approvalPolicy" | "thinkingLevel">, updatedAt: string) => TaskRow | undefined;
|
|
32
|
+
updateTaskSession: (taskId: string, session: {
|
|
33
|
+
createdAt: string;
|
|
34
|
+
id: string;
|
|
35
|
+
path: string;
|
|
36
|
+
}) => TaskRow | undefined;
|
|
37
|
+
updateTaskStatus: (taskId: string, status: TaskRow["status"], updatedAt: string) => TaskRow | undefined;
|
|
38
|
+
}
|
|
39
|
+
export declare function createInMemoryWorkspaceRepository(seed?: WorkspaceRepositorySeed): WorkspaceRepository;
|
|
40
|
+
export declare function createSqliteWorkspaceRepository(database: AppDatabase): WorkspaceRepository;
|
|
41
|
+
//# sourceMappingURL=workspace-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-repository.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/workspace-repository.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACxB,2BAA2B,EAC3B,UAAU,EACV,eAAe,EACf,OAAO,EACP,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,4BAA6B,SAAQ,uBAAuB;IAC3E,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,wBAAwB,EAAE,CACxB,KAAK,EAAE,2BAA2B,KAC/B,wBAAwB,CAAC;IAC9B,iBAAiB,EAAE,CACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAAC,KAC/C,OAAO,GAAG,SAAS,CAAC;IACzB,UAAU,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;IAC1C,eAAe,EAAE,CAAC,SAAS,EAAE,eAAe,KAAK,YAAY,CAAC;IAC9D,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,wBAAwB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,mBAAmB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAC;IACtD,iBAAiB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAC;IACrE,mBAAmB,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAC;IACzE,6BAA6B,EAAE,CAC7B,KAAK,EAAE,4BAA4B,KAChC,OAAO,EAAE,CAAC;IACf,yBAAyB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;IAC9D,sBAAsB,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,OAAO,EAAE,CAAC;IACtE,cAAc,EAAE,MAAM,YAAY,EAAE,CAAC;IACrC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAC;IAC3F,qBAAqB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAC;IACpF,eAAe,EAAE,CACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,CACT,OAAO,EACP,aAAa,GAAG,eAAe,GAAG,mBAAmB,GAAG,yBAAyB,CAClF,EACD,SAAS,EAAE,MAAM,KACd,OAAO,GAAG,SAAS,CAAC;IACzB,iBAAiB,EAAE,CACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAAC,EAC1D,SAAS,EAAE,MAAM,KACd,OAAO,GAAG,SAAS,CAAC;IACzB,iBAAiB,EAAE,CACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KACrD,OAAO,GAAG,SAAS,CAAC;IACzB,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EACzB,SAAS,EAAE,MAAM,KACd,OAAO,GAAG,SAAS,CAAC;CAC1B;AAED,wBAAgB,iCAAiC,CAC/C,IAAI,GAAE,uBAAuD,GAC5D,mBAAmB,CAwKrB;AAED,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,WAAW,GACpB,mBAAmB,CAiLrB"}
|