@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
package/dist/cli.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{r as i}from"./index.js";import"node:fs/promises";import"node:path";import"node:url";import"node:os";import"node:child_process";import"node:util";import"node:fs";const t="0.0.0",e={version:t};async function s(){const o=await i(process.argv.slice(2),{currentWorkingDirectory:process.cwd(),packageVersion:e.version,write:r=>{process.stdout.write(r)}});process.exitCode=o.exitCode}s();
|
|
3
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["import packageJson from \"../package.json\";\n\nimport { runCli } from \"./index\";\n\nasync function main(): Promise<void> {\n const result = await runCli(process.argv.slice(2), {\n currentWorkingDirectory: process.cwd(),\n packageVersion: packageJson.version,\n write: (value: string): void => {\n process.stdout.write(value);\n }\n });\n\n process.exitCode = result.exitCode;\n}\n\nvoid main();\n"],"names":["main","result","runCli","packageJson","value"],"mappings":";sMAIA,eAAeA,GAAsB,CACnC,MAAMC,EAAS,MAAMC,EAAO,QAAQ,KAAK,MAAM,CAAC,EAAG,CACjD,wBAAyB,QAAQ,IAAA,EACjC,eAAgBC,EAAY,QAC5B,MAAQC,GAAwB,CAC9B,QAAQ,OAAO,MAAMA,CAAK,CAC5B,CAAA,CACD,EAED,QAAQ,SAAWH,EAAO,QAC5B,CAEKD,EAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import{readFile as A,mkdtemp as d,mkdir as h,rm as v,stat as N,writeFile as S,cp as D}from"node:fs/promises";import{join as s,isAbsolute as U,resolve as _,basename as L}from"node:path";import{fileURLToPath as M}from"node:url";import{tmpdir as y,homedir as G}from"node:os";import{execFile as F}from"node:child_process";import{promisify as W}from"node:util";import{existsSync as J,mkdirSync as T,writeFileSync as B}from"node:fs";function H(e){const t=e.trim(),r=/^https:\/\/github\.com\/(?<owner>[^/\s]+)\/(?<repo>[^/\s]+?)(?:\.git)?\/?$/u.exec(t)??/^git@github\.com:(?<owner>[^/\s]+)\/(?<repo>[^/\s]+?)(?:\.git)?$/u.exec(t);if(r!=null&&r.groups){const{owner:P,repo:x}=r.groups;return!P||!x?void 0:{repositoryUrl:C(P,x,t.startsWith("git@github.com:"))}}const i=/^https:\/\/github\.com\/(?<owner>[^/\s]+)\/(?<repo>[^/\s]+)\/(?<kind>tree|blob)\/(?<ref>[^/\s]+)(?:\/(?<path>.*))?\/?$/u.exec(t);if(!(i!=null&&i.groups))return;const{kind:a,owner:n,path:o,ref:u,repo:b}=i.groups;if(!a||!n||!u||!b)return;const f=z(o),k=a==="blob"&&f.at(-1)==="package.json"?f.slice(0,-1).join("/"):f.join("/");return{ref:u,repositoryUrl:C(n,b),...k.length===0?{}:{subdirectory:k}}}function z(e){if(!e)return[];const t=e.split("/").filter(r=>r.length>0);return t.some(r=>r==="."||r==="..")?[]:t}function C(e,t,r=!1){return r?`git@github.com:${e}/${t}.git`:`https://github.com/${e}/${t}.git`}const V=W(F);async function c(e,t,r,i,a){a==null||a(`Running: ${q(t,r)}
|
|
2
|
+
`);const n=e?await e(t,r,i):await V(t,[...r],{cwd:i});n!=null&&n.stdout&&(a==null||a(R(n.stdout))),n!=null&&n.stderr&&(a==null||a(R(n.stderr)))}function q(e,t){return[e,...t].join(" ")}function R(e){return e.endsWith(`
|
|
3
|
+
`)?e:`${e}
|
|
4
|
+
`}async function l(e){const t=JSON.parse(await A(s(e,"package.json"),"utf8"));if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Plugin package manifest must be an object.");const r=t,i=r.name;if(typeof i!="string"||i.length===0)throw new Error('Plugin package "name" must be a string.');if(!Q(r.exports))throw new Error('Plugin package "exports" must define "./server".');return{exports:r.exports,name:i,packageJson:r,publishConfig:r.publishConfig}}function X(e){return e.publishConfig&&typeof e.publishConfig=="object"&&!Array.isArray(e.publishConfig)?{...j(e.packageJson),...e.publishConfig,name:e.name}:j(e.packageJson)}function K(e){const t=g(e.exports["./server"]);return!!(t&&!Y(t))}function Q(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.hasOwn(e,"./server")}function j(e){const t={...e};return delete t.publishConfig,t}function Y(e){return e.startsWith("./src/")||e.includes("/src/")||e.endsWith(".ts")||e.endsWith(".tsx")}function g(e){if(typeof e=="string")return e;if(!e||typeof e!="object"||Array.isArray(e))return;const t=e;return g(t.import)??g(t.default)??g(t.module)}function Z(e){return e.replaceAll("/","__")}async function m(e){var r;const t=s(e.pluginRoot,Z(e.packageName));return await h(e.pluginRoot,{recursive:!0}),await v(t,{force:!0,recursive:!0}),(r=e.write)==null||r.call(e,`Copying plugin files: ${e.sourcePackageDir} -> ${t}
|
|
5
|
+
`),await D(e.sourcePackageDir,t,{recursive:!0}),t}async function ee(e){const t=e.tempRoot??await d(s(y(),"hold-rein-plugin-"));await h(t,{recursive:!0});const r=await d(s(t,"install-"));await S(s(r,"package.json"),JSON.stringify({private:!0,type:"module"},null,2)),await c(e.runCommand,"npm",["install",e.packageName,"--ignore-scripts"],r,e.write);const i=s(r,"node_modules",...e.packageName.split("/"));return await l(i),m({packageName:e.packageName,pluginRoot:e.pluginRoot,sourcePackageDir:i,write:e.write})}async function te(e){const t=H(e.source);if(t)return ie(e,t);const r=await E(e.source,e.currentWorkingDirectory);return r?re(e,r):ee({packageName:e.source,pluginRoot:e.pluginRoot,...e.runCommand===void 0?{}:{runCommand:e.runCommand},...e.tempRoot===void 0?{}:{tempRoot:e.tempRoot},...e.write===void 0?{}:{write:e.write}})}async function re(e,t){return await l(t),await O(e.runCommand,t,e.write),await c(e.runCommand,"pnpm",["install"],t,e.write),await c(e.runCommand,"pnpm",["build"],t,e.write),$(t,e.pluginRoot,e.write)}async function ie(e,t){const r=e.tempRoot??await d(s(y(),"hold-rein-plugin-"));await h(r,{recursive:!0});const i=await d(s(r,"github-")),a=e.installGitRepository??ae;try{t.ref?await a(t.repositoryUrl,i,t.ref):await a(t.repositoryUrl,i);const n=t.subdirectory===void 0?i:s(i,t.subdirectory),o=await l(n);return K(o)?await m({packageName:o.name,pluginRoot:e.pluginRoot,sourcePackageDir:n,write:e.write}):(await O(e.runCommand,n,e.write),await c(e.runCommand,"pnpm",["install"],n,e.write),await c(e.runCommand,"pnpm",["build"],n,e.write),await $(n,e.pluginRoot,e.write))}finally{await v(i,{force:!0,recursive:!0})}}async function $(e,t,r){const i=await E(s(e,"dist"));if(i&&await ne(i)){const o=await l(i);return m({packageName:o.name,pluginRoot:t,sourcePackageDir:i,write:r})}const a=await l(e),n=await d(s(y(),"hold-rein-plugin-package-"));try{return await S(s(n,"package.json"),`${JSON.stringify(X(a),null,2)}
|
|
6
|
+
`),await D(s(e,"dist"),s(n,"dist"),{recursive:!0}),await l(n),await m({packageName:a.name,pluginRoot:t,sourcePackageDir:n,write:r})}finally{await v(n,{force:!0,recursive:!0})}}async function ne(e){try{return await N(s(e,"package.json")),!0}catch{return!1}}async function O(e,t,r){try{await c(e,"pnpm",["--version"],t,r)}catch{try{await c(e,"npm",["install","--global","pnpm"],t,r)}catch{throw new Error("pnpm is required to build plugin sources")}}}async function E(e,t=process.cwd()){const r=U(e)?e:_(t,e);try{return(await N(r)).isDirectory()?r:void 0}catch{return}}async function ae(e,t){await c(void 0,"git",["clone","--depth","1",e,t],process.cwd())}const se={name:"@hold-rein/plugins-base",version:"0.0.0",private:!0,type:"module",main:"./src/server.ts",module:"./src/server.ts",types:"./src/server.ts",exports:{"./server":{types:"./src/server.ts",import:"./src/server.ts",require:"./src/server.ts"},"./web":{types:"./src/web.ts",style:"./dist/style.css",import:"./src/web.ts",require:"./src/web.ts"}},files:["dist"],publishConfig:{access:"restricted",main:"./dist/server.cjs",module:"./dist/server.js",types:"./dist/server.d.ts",exports:{"./server":{types:"./dist/server.d.ts",import:"./dist/server.js",require:"./dist/server.cjs"},"./web":{types:"./dist/web.d.ts",style:"./dist/style.css",default:"./dist/web.umd.cjs",require:"./dist/web.umd.cjs"}}},scripts:{build:"vite build --config vite.config.ts && vite build --config vite.web.config.ts && tsc -p tsconfig.json --emitDeclarationOnly",typecheck:"tsc -p tsconfig.json --noEmit"},peerDependencies:{"@earendil-works/pi-agent-core":"0.75.4","@earendil-works/pi-ai":"0.76.0","@hold-rein/plugin-server":"workspace:^",express:"5.2.1","@ant-design/icons":"6.2.5","@hold-rein/plugin-web":"workspace:^","@monaco-editor/react":"4.7.0",antd:"6.4.3","monaco-editor":"0.55.1",react:"19.2.6","react-dom":"19.2.6"},devDependencies:{"@earendil-works/pi-agent-core":"0.75.4","@earendil-works/pi-ai":"0.76.0","@hold-rein/plugin-server":"workspace:^",express:"5.2.1",vite:"6.3.5","@ant-design/icons":"6.2.5","@hold-rein/plugin-web":"workspace:^","@monaco-editor/react":"4.7.0","@types/react":"19.2.15",antd:"6.4.3","monaco-editor":"0.55.1",react:"19.2.6","react-dom":"19.2.6"}},oe=`{
|
|
7
|
+
"compilerOptions": {
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationMap": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"exactOptionalPropertyTypes": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"module": "ESNext",
|
|
15
|
+
"moduleResolution": "Bundler",
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"noImplicitOverride": true,
|
|
18
|
+
"noUncheckedIndexedAccess": true,
|
|
19
|
+
"resolveJsonModule": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"strict": true,
|
|
22
|
+
"target": "ES2022",
|
|
23
|
+
"useDefineForClassFields": true,
|
|
24
|
+
"verbatimModuleSyntax": true,
|
|
25
|
+
"jsx": "react-jsx",
|
|
26
|
+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
27
|
+
"outDir": "dist",
|
|
28
|
+
"rootDir": "src"
|
|
29
|
+
},
|
|
30
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
31
|
+
"exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
|
|
32
|
+
}
|
|
33
|
+
`,ce=`import { builtinModules } from "node:module";
|
|
34
|
+
|
|
35
|
+
import { defineConfig } from "vite";
|
|
36
|
+
|
|
37
|
+
const nodeBuiltins = builtinModules.flatMap((name) => [
|
|
38
|
+
name,
|
|
39
|
+
\`node:\${name}\`
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
build: {
|
|
44
|
+
lib: {
|
|
45
|
+
entry: "src/server.ts",
|
|
46
|
+
fileName: (format) => \`server.\${format === "cjs" ? "cjs" : "js"}\`,
|
|
47
|
+
formats: ["es", "cjs"]
|
|
48
|
+
},
|
|
49
|
+
rollupOptions: {
|
|
50
|
+
external: [
|
|
51
|
+
...nodeBuiltins,
|
|
52
|
+
"@hold-rein/plugin-server",
|
|
53
|
+
"@earendil-works/pi-agent-core",
|
|
54
|
+
"@earendil-works/pi-ai",
|
|
55
|
+
"express"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
sourcemap: true
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
`,ue=`import { defineConfig } from "vite";
|
|
62
|
+
|
|
63
|
+
export default defineConfig({
|
|
64
|
+
build: {
|
|
65
|
+
emptyOutDir: false,
|
|
66
|
+
lib: {
|
|
67
|
+
cssFileName: "style",
|
|
68
|
+
entry: "src/web.ts",
|
|
69
|
+
fileName: () => "web.umd.cjs",
|
|
70
|
+
formats: ["umd"],
|
|
71
|
+
name: "HoldReinPlugin"
|
|
72
|
+
},
|
|
73
|
+
sourcemap: true,
|
|
74
|
+
rollupOptions: {
|
|
75
|
+
external: [
|
|
76
|
+
"@ant-design/icons",
|
|
77
|
+
"@hold-rein/plugin-web",
|
|
78
|
+
"@monaco-editor/react",
|
|
79
|
+
"antd",
|
|
80
|
+
"monaco-editor",
|
|
81
|
+
"react",
|
|
82
|
+
"react-dom",
|
|
83
|
+
"react/jsx-runtime"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
`,le=(e,t={})=>{const r=t.path??e,i=t.name===void 0?r:s(r,t.name),a=L(i),n=`hold-rein-plugin-${a}`,o={...se,name:n};return de(i,{"package.json":`${JSON.stringify(o,null,2)}
|
|
89
|
+
`,"tsconfig.json":oe,"vite.config.ts":ce,"vite.web.config.ts":ue,"src/plugin-id.ts":`export const PLUGIN_ID = "__${a}__plugin";
|
|
90
|
+
`,"src/server.ts":pe(),"src/web.ts":ge()}),{packageName:n}};function de(e,t){for(const r of Object.keys(t)){const i=s(e,r);if(J(i))throw new Error(`Refusing to overwrite existing file: ${r}`)}T(s(e,"src"),{recursive:!0});for(const[r,i]of Object.entries(t))B(s(e,r),i)}function pe(){return`import type { ServerPlugin } from "@hold-rein/plugin-server";
|
|
91
|
+
|
|
92
|
+
import { PLUGIN_ID } from "./plugin-id";
|
|
93
|
+
|
|
94
|
+
const serverPlugin: ServerPlugin.Plugin = {
|
|
95
|
+
id: PLUGIN_ID
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default serverPlugin;
|
|
99
|
+
`}function ge(){return`import type { WebPlugin } from "@hold-rein/plugin-web";
|
|
100
|
+
|
|
101
|
+
import { PLUGIN_ID } from "./plugin-id";
|
|
102
|
+
|
|
103
|
+
const webPlugin: WebPlugin.Plugin = {
|
|
104
|
+
id: PLUGIN_ID
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default webPlugin;
|
|
108
|
+
`}const I=`Hold Rein CLI
|
|
109
|
+
|
|
110
|
+
Usage: hold-rein <command>
|
|
111
|
+
|
|
112
|
+
Aliases: hold-rein, hr
|
|
113
|
+
|
|
114
|
+
Commands:
|
|
115
|
+
run Start the bundled Hold Rein service
|
|
116
|
+
plugin init Initialize a plugin package
|
|
117
|
+
plugin install Install a plugin package
|
|
118
|
+
version Print the current CLI version
|
|
119
|
+
help Print this help message
|
|
120
|
+
|
|
121
|
+
Options:
|
|
122
|
+
run --host <host> Bind to a specific host (default: 127.0.0.1)
|
|
123
|
+
run --port <port> Bind to a specific port (default: 3001)
|
|
124
|
+
plugin init --path <path> Initialize in a specific path
|
|
125
|
+
plugin init --name <name> Initialize in a child directory
|
|
126
|
+
plugin install --target <path> Install into a specific plugin directory
|
|
127
|
+
-v, --version Print the current CLI version
|
|
128
|
+
-h, --help Print this help message
|
|
129
|
+
`,me=new Set(["version","--version","-v"]),fe=new Set(["help","--help","-h"]),we="127.0.0.1",he=3001,Se=async(e,t)=>{const[r,i,...a]=e;if(r===void 0||fe.has(r))return t.write(I),{exitCode:0};if(me.has(r))return t.write(`${t.packageVersion}
|
|
130
|
+
`),{exitCode:0};if(r==="run")try{const n=ye([i,...a]),u=await(t.startRunServer??ke)({host:n.host,port:n.port,write:t.write});return t.write(`Hold Rein is running at ${u.url}
|
|
131
|
+
`),{exitCode:0}}catch(n){return t.write(`Failed to start service: ${w(n)}
|
|
132
|
+
`),{exitCode:1}}if(r==="plugin"&&i==="init")try{const n=le(t.currentWorkingDirectory??process.cwd(),be(a));return t.write(`Initialized plugin package ${n.packageName}
|
|
133
|
+
`),{exitCode:0}}catch(n){return t.write(`Failed to initialize plugin package: ${w(n)}
|
|
134
|
+
`),{exitCode:1}}if(r==="plugin"&&i==="install")try{const n=ve(a),u=await(t.installPluginPackage??te)({currentWorkingDirectory:t.currentWorkingDirectory??process.cwd(),pluginRoot:n.target??s(G(),".hold-rein","plugins"),source:n.source,write:t.write});return t.write(`Installed plugin to ${u}
|
|
135
|
+
`),{exitCode:0}}catch(n){return t.write(`Failed to install plugin: ${w(n)}
|
|
136
|
+
`),{exitCode:1}}return t.write(`Unknown command: ${r}
|
|
137
|
+
|
|
138
|
+
${I}`),{exitCode:1}};function w(e){return e instanceof Error?e.message:String(e)}function ve(e){const t=e[0];if(t===void 0||t.startsWith("-"))throw new Error("Missing plugin source");const r={source:t},i=p(e,"--target");return i!==void 0&&(r.target=i),r}function ye(e){const t=e.filter(n=>n!==void 0),r=p(t,"--host")??we,i=p(t,"--port"),a=i===void 0?he:Number(i);if(!Number.isInteger(a)||a<1||a>65535)throw new Error("Port must be an integer between 1 and 65535");return{host:r,port:a}}function be(e){const t={},r=p(e,"--name"),i=p(e,"--path");return r!==void 0&&(t.name=r),i!==void 0&&(t.path=i),t}async function ke(e){return(await import(new URL("./runtime/api/runtime.js",import.meta.url).href)).startHoldReinServer({...e,webAssetsDirectory:M(new URL("./runtime/web",import.meta.url))})}function p(e,t){const r=e.indexOf(t);if(r===-1)return;const i=e[r+1];if(i===void 0||i.startsWith("-"))throw new Error(`Missing value for ${t}`);return i}export{Se as r};
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../packages/plugin-server/src/runtime/installer/github-source.ts","../../../packages/plugin-server/src/runtime/installer/command.ts","../../../packages/plugin-server/src/runtime/manifest/package.ts","../../../packages/plugin-server/src/runtime/installer/index.ts","../../../packages/plugin-server/src/runtime/init/index.ts","../src/index.ts"],"sourcesContent":["export interface GithubPluginSource {\n readonly ref?: string;\n readonly repositoryUrl: string;\n readonly subdirectory?: string;\n}\n\nexport function parseGithubPluginSource(\n source: string\n): GithubPluginSource | undefined {\n const trimmedSource = source.trim();\n const rootMatch =\n /^https:\\/\\/github\\.com\\/(?<owner>[^/\\s]+)\\/(?<repo>[^/\\s]+?)(?:\\.git)?\\/?$/u.exec(\n trimmedSource\n ) ??\n /^git@github\\.com:(?<owner>[^/\\s]+)\\/(?<repo>[^/\\s]+?)(?:\\.git)?$/u.exec(\n trimmedSource\n );\n\n if (rootMatch?.groups) {\n const { owner, repo } = rootMatch.groups;\n\n if (!owner || !repo) {\n return undefined;\n }\n\n return {\n repositoryUrl: toGitRepositoryUrl(\n owner,\n repo,\n trimmedSource.startsWith(\"git@github.com:\")\n )\n };\n }\n\n const webMatch =\n /^https:\\/\\/github\\.com\\/(?<owner>[^/\\s]+)\\/(?<repo>[^/\\s]+)\\/(?<kind>tree|blob)\\/(?<ref>[^/\\s]+)(?:\\/(?<path>.*))?\\/?$/u.exec(\n trimmedSource\n );\n\n if (!webMatch?.groups) {\n return undefined;\n }\n\n const { kind, owner, path, ref, repo } = webMatch.groups;\n\n if (!kind || !owner || !ref || !repo) {\n return undefined;\n }\n\n const pathSegments = normalizeGithubPathSegments(path);\n const subdirectory =\n kind === \"blob\" && pathSegments.at(-1) === \"package.json\"\n ? pathSegments.slice(0, -1).join(\"/\")\n : pathSegments.join(\"/\");\n\n return {\n ref,\n repositoryUrl: toGitRepositoryUrl(owner, repo),\n ...(subdirectory.length === 0 ? {} : { subdirectory })\n };\n}\n\nfunction normalizeGithubPathSegments(path: string | undefined): string[] {\n if (!path) {\n return [];\n }\n\n const segments = path.split(\"/\").filter((segment) => segment.length > 0);\n\n if (segments.some((segment) => segment === \".\" || segment === \"..\")) {\n return [];\n }\n\n return segments;\n}\n\nfunction toGitRepositoryUrl(\n owner: string,\n repo: string,\n useSsh = false\n): string {\n return useSsh\n ? `git@github.com:${owner}/${repo}.git`\n : `https://github.com/${owner}/${repo}.git`;\n}\n","import { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\n\nexport interface PluginInstallCommandResult {\n readonly stderr?: string;\n readonly stdout?: string;\n}\n\nexport type PluginInstallCommandRunner = (\n command: string,\n args: readonly string[],\n cwd: string\n) => Promise<PluginInstallCommandResult> | Promise<void>;\n\nexport type PluginInstallWriter = (value: string) => void;\n\nexport async function runInstallCommand(\n runner: PluginInstallCommandRunner | undefined,\n command: string,\n args: readonly string[],\n cwd: string,\n write?: PluginInstallWriter\n): Promise<void> {\n write?.(`Running: ${formatCommand(command, args)}\\n`);\n\n const result = runner\n ? ((await runner(command, args, cwd)) as PluginInstallCommandResult | undefined)\n : await execFileAsync(command, [...args], { cwd });\n\n if (result?.stdout) {\n write?.(ensureTrailingNewline(result.stdout));\n }\n if (result?.stderr) {\n write?.(ensureTrailingNewline(result.stderr));\n }\n}\n\nfunction formatCommand(command: string, args: readonly string[]): string {\n return [command, ...args].join(\" \");\n}\n\nfunction ensureTrailingNewline(value: string): string {\n return value.endsWith(\"\\n\") ? value : `${value}\\n`;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport interface PluginPackageManifest {\n readonly name: string;\n readonly exports?: unknown;\n readonly packageJson: Record<string, unknown>;\n readonly publishConfig?: unknown;\n}\n\nexport async function readValidPluginPackageManifest(\n packageDirectory: string\n): Promise<PluginPackageManifest> {\n const manifest = JSON.parse(\n await readFile(join(packageDirectory, \"package.json\"), \"utf8\")\n ) as unknown;\n\n if (!manifest || typeof manifest !== \"object\" || Array.isArray(manifest)) {\n throw new Error(\"Plugin package manifest must be an object.\");\n }\n\n const packageManifest = manifest as Record<string, unknown>;\n const name = packageManifest.name;\n\n if (typeof name !== \"string\" || name.length === 0) {\n throw new Error('Plugin package \"name\" must be a string.');\n }\n\n if (!hasServerExport(packageManifest.exports)) {\n throw new Error('Plugin package \"exports\" must define \"./server\".');\n }\n\n return {\n exports: packageManifest.exports,\n name,\n packageJson: packageManifest,\n publishConfig: packageManifest.publishConfig\n };\n}\n\nexport function createPublishedManifest(\n manifest: PluginPackageManifest\n): Record<string, unknown> {\n if (\n manifest.publishConfig &&\n typeof manifest.publishConfig === \"object\" &&\n !Array.isArray(manifest.publishConfig)\n ) {\n return {\n ...withoutPublishConfig(manifest.packageJson),\n ...(manifest.publishConfig as Record<string, unknown>),\n name: manifest.name\n };\n }\n\n return withoutPublishConfig(manifest.packageJson);\n}\n\nexport function isBuiltPackageManifest(\n manifest: PluginPackageManifest\n): boolean {\n const serverEntry = resolveExportValue(\n (manifest.exports as Record<string, unknown>)[\"./server\"]\n );\n\n return Boolean(serverEntry && !isSourceEntry(serverEntry));\n}\n\nfunction hasServerExport(exportsField: unknown): boolean {\n if (!exportsField || typeof exportsField !== \"object\" || Array.isArray(exportsField)) {\n return false;\n }\n\n return Object.hasOwn(exportsField, \"./server\");\n}\n\nfunction withoutPublishConfig(\n packageJson: Record<string, unknown>\n): Record<string, unknown> {\n const publishedManifest = { ...packageJson };\n delete publishedManifest.publishConfig;\n\n return publishedManifest;\n}\n\nfunction isSourceEntry(entry: string): boolean {\n return (\n entry.startsWith(\"./src/\") ||\n entry.includes(\"/src/\") ||\n entry.endsWith(\".ts\") ||\n entry.endsWith(\".tsx\")\n );\n}\n\nfunction resolveExportValue(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return value;\n }\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return undefined;\n }\n\n const conditions = value as Record<string, unknown>;\n\n return (\n resolveExportValue(conditions.import) ??\n resolveExportValue(conditions.default) ??\n resolveExportValue(conditions.module)\n );\n}\n","import { cp, mkdir, mkdtemp, rm, stat, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join, resolve } from \"node:path\";\n\nimport {\n type GithubPluginSource,\n parseGithubPluginSource\n} from \"./github-source\";\nimport {\n type PluginInstallCommandRunner,\n type PluginInstallWriter,\n runInstallCommand\n} from \"./command\";\nimport {\n createPublishedManifest,\n isBuiltPackageManifest,\n readValidPluginPackageManifest\n} from \"../manifest/package\";\n\nexport interface CopyInstalledPluginPackageOptions {\n readonly packageName: string;\n readonly pluginRoot: string;\n readonly sourcePackageDir: string;\n readonly write?: PluginInstallWriter | undefined;\n}\n\nexport interface InstallNpmPluginPackageOptions {\n readonly packageName: string;\n readonly pluginRoot: string;\n readonly tempRoot?: string;\n readonly runCommand?: PluginInstallCommandRunner;\n readonly write?: PluginInstallWriter | undefined;\n}\n\nexport interface InstallPluginPackageOptions {\n readonly currentWorkingDirectory?: string;\n readonly installGitRepository?: (\n repositoryUrl: string,\n targetDir: string,\n ref?: string\n ) => Promise<void>;\n readonly pluginRoot: string;\n readonly runCommand?: PluginInstallCommandRunner;\n readonly source: string;\n readonly tempRoot?: string;\n readonly write?: PluginInstallWriter | undefined;\n}\n\nexport function encodePluginDirectoryName(packageName: string): string {\n return packageName.replaceAll(\"/\", \"__\");\n}\n\nexport async function copyInstalledPluginPackage(\n options: CopyInstalledPluginPackageOptions\n): Promise<string> {\n const destination = join(\n options.pluginRoot,\n encodePluginDirectoryName(options.packageName)\n );\n\n await mkdir(options.pluginRoot, { recursive: true });\n await rm(destination, { force: true, recursive: true });\n options.write?.(\n `Copying plugin files: ${options.sourcePackageDir} -> ${destination}\\n`\n );\n await cp(options.sourcePackageDir, destination, { recursive: true });\n\n return destination;\n}\n\nexport async function installNpmPluginPackage(\n options: InstallNpmPluginPackageOptions\n): Promise<string> {\n const tempRoot =\n options.tempRoot ?? (await mkdtemp(join(tmpdir(), \"hold-rein-plugin-\")));\n\n await mkdir(tempRoot, { recursive: true });\n\n const installDir = await mkdtemp(join(tempRoot, \"install-\"));\n\n await writeFile(\n join(installDir, \"package.json\"),\n JSON.stringify({ private: true, type: \"module\" }, null, 2)\n );\n await runInstallCommand(\n options.runCommand,\n \"npm\",\n [\"install\", options.packageName, \"--ignore-scripts\"],\n installDir,\n options.write\n );\n\n const sourcePackageDir = join(\n installDir,\n \"node_modules\",\n ...options.packageName.split(\"/\")\n );\n\n await readValidPluginPackageManifest(sourcePackageDir);\n\n return copyInstalledPluginPackage({\n packageName: options.packageName,\n pluginRoot: options.pluginRoot,\n sourcePackageDir,\n write: options.write\n });\n}\n\nexport async function installPluginPackage(\n options: InstallPluginPackageOptions\n): Promise<string> {\n const githubSource = parseGithubPluginSource(options.source);\n\n if (githubSource) {\n return installGithubPluginPackage(options, githubSource);\n }\n\n const localDirectory = await resolveLocalDirectory(\n options.source,\n options.currentWorkingDirectory\n );\n\n if (localDirectory) {\n return installLocalPluginPackage(options, localDirectory);\n }\n\n return installNpmPluginPackage({\n packageName: options.source,\n pluginRoot: options.pluginRoot,\n ...(options.runCommand === undefined\n ? {}\n : { runCommand: options.runCommand }),\n ...(options.tempRoot === undefined ? {} : { tempRoot: options.tempRoot }),\n ...(options.write === undefined ? {} : { write: options.write })\n });\n}\n\nasync function installLocalPluginPackage(\n options: InstallPluginPackageOptions,\n sourceDirectory: string\n): Promise<string> {\n await readValidPluginPackageManifest(sourceDirectory);\n await ensurePnpmAvailable(options.runCommand, sourceDirectory, options.write);\n await runInstallCommand(\n options.runCommand,\n \"pnpm\",\n [\"install\"],\n sourceDirectory,\n options.write\n );\n await runInstallCommand(\n options.runCommand,\n \"pnpm\",\n [\"build\"],\n sourceDirectory,\n options.write\n );\n\n return installBuiltSourcePackage(sourceDirectory, options.pluginRoot, options.write);\n}\n\nasync function installGithubPluginPackage(\n options: InstallPluginPackageOptions,\n githubSource: GithubPluginSource\n): Promise<string> {\n const tempRoot =\n options.tempRoot ?? (await mkdtemp(join(tmpdir(), \"hold-rein-plugin-\")));\n await mkdir(tempRoot, { recursive: true });\n const cloneDir = await mkdtemp(join(tempRoot, \"github-\"));\n const installGitRepository = options.installGitRepository ?? cloneGitRepository;\n\n try {\n if (githubSource.ref) {\n await installGitRepository(\n githubSource.repositoryUrl,\n cloneDir,\n githubSource.ref\n );\n } else {\n await installGitRepository(githubSource.repositoryUrl, cloneDir);\n }\n\n const sourceDirectory =\n githubSource.subdirectory === undefined\n ? cloneDir\n : join(cloneDir, githubSource.subdirectory);\n\n const manifest = await readValidPluginPackageManifest(sourceDirectory);\n\n if (isBuiltPackageManifest(manifest)) {\n return await copyInstalledPluginPackage({\n packageName: manifest.name,\n pluginRoot: options.pluginRoot,\n sourcePackageDir: sourceDirectory,\n write: options.write\n });\n }\n\n await ensurePnpmAvailable(options.runCommand, sourceDirectory, options.write);\n await runInstallCommand(\n options.runCommand,\n \"pnpm\",\n [\"install\"],\n sourceDirectory,\n options.write\n );\n await runInstallCommand(\n options.runCommand,\n \"pnpm\",\n [\"build\"],\n sourceDirectory,\n options.write\n );\n\n return await installBuiltSourcePackage(\n sourceDirectory,\n options.pluginRoot,\n options.write\n );\n } finally {\n await rm(cloneDir, { force: true, recursive: true });\n }\n}\n\nasync function installBuiltSourcePackage(\n sourceDirectory: string,\n pluginRoot: string,\n write: PluginInstallWriter | undefined\n): Promise<string> {\n const directDistPackage = await resolveLocalDirectory(\n join(sourceDirectory, \"dist\")\n );\n\n if (directDistPackage && (await hasPackageManifest(directDistPackage))) {\n const manifest = await readValidPluginPackageManifest(directDistPackage);\n\n return copyInstalledPluginPackage({\n packageName: manifest.name,\n pluginRoot,\n sourcePackageDir: directDistPackage,\n write\n });\n }\n\n const manifest = await readValidPluginPackageManifest(sourceDirectory);\n const stagingDir = await mkdtemp(join(tmpdir(), \"hold-rein-plugin-package-\"));\n\n try {\n await writeFile(\n join(stagingDir, \"package.json\"),\n `${JSON.stringify(createPublishedManifest(manifest), null, 2)}\\n`\n );\n await cp(join(sourceDirectory, \"dist\"), join(stagingDir, \"dist\"), {\n recursive: true\n });\n await readValidPluginPackageManifest(stagingDir);\n\n return await copyInstalledPluginPackage({\n packageName: manifest.name,\n pluginRoot,\n sourcePackageDir: stagingDir,\n write\n });\n } finally {\n await rm(stagingDir, { force: true, recursive: true });\n }\n}\n\nasync function hasPackageManifest(directory: string): Promise<boolean> {\n try {\n await stat(join(directory, \"package.json\"));\n return true;\n } catch {\n return false;\n }\n}\n\nasync function ensurePnpmAvailable(\n runCommand: PluginInstallCommandRunner | undefined,\n cwd: string,\n write: PluginInstallWriter | undefined\n): Promise<void> {\n try {\n await runInstallCommand(runCommand, \"pnpm\", [\"--version\"], cwd, write);\n } catch {\n try {\n await runInstallCommand(\n runCommand,\n \"npm\",\n [\"install\", \"--global\", \"pnpm\"],\n cwd,\n write\n );\n } catch {\n throw new Error(\"pnpm is required to build plugin sources\");\n }\n }\n}\n\nasync function resolveLocalDirectory(\n source: string,\n currentWorkingDirectory = process.cwd()\n): Promise<string | undefined> {\n const directory = isAbsolute(source)\n ? source\n : resolve(currentWorkingDirectory, source);\n\n try {\n const stats = await stat(directory);\n return stats.isDirectory() ? directory : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function cloneGitRepository(\n repositoryUrl: string,\n targetDir: string\n): Promise<void> {\n await runInstallCommand(\n undefined,\n \"git\",\n [\"clone\", \"--depth\", \"1\", repositoryUrl, targetDir],\n process.cwd()\n );\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\n\nexport interface InitPluginPackageResult {\n readonly packageName: string;\n}\n\nexport interface InitPluginPackageOptions {\n readonly name?: string;\n readonly path?: string;\n}\n\nconst basePackageJson = {\n name: \"@hold-rein/plugins-base\",\n version: \"0.0.0\",\n private: true,\n type: \"module\",\n main: \"./src/server.ts\",\n module: \"./src/server.ts\",\n types: \"./src/server.ts\",\n exports: {\n \"./server\": {\n types: \"./src/server.ts\",\n import: \"./src/server.ts\",\n require: \"./src/server.ts\"\n },\n \"./web\": {\n types: \"./src/web.ts\",\n style: \"./dist/style.css\",\n import: \"./src/web.ts\",\n require: \"./src/web.ts\"\n }\n },\n files: [\"dist\"],\n publishConfig: {\n access: \"restricted\",\n main: \"./dist/server.cjs\",\n module: \"./dist/server.js\",\n types: \"./dist/server.d.ts\",\n exports: {\n \"./server\": {\n types: \"./dist/server.d.ts\",\n import: \"./dist/server.js\",\n require: \"./dist/server.cjs\"\n },\n \"./web\": {\n types: \"./dist/web.d.ts\",\n style: \"./dist/style.css\",\n default: \"./dist/web.umd.cjs\",\n require: \"./dist/web.umd.cjs\"\n }\n }\n },\n scripts: {\n build:\n \"vite build --config vite.config.ts && vite build --config vite.web.config.ts && tsc -p tsconfig.json --emitDeclarationOnly\",\n typecheck: \"tsc -p tsconfig.json --noEmit\"\n },\n peerDependencies: {\n \"@earendil-works/pi-agent-core\": \"0.75.4\",\n \"@earendil-works/pi-ai\": \"0.76.0\",\n \"@hold-rein/plugin-server\": \"workspace:^\",\n express: \"5.2.1\",\n \"@ant-design/icons\": \"6.2.5\",\n \"@hold-rein/plugin-web\": \"workspace:^\",\n \"@monaco-editor/react\": \"4.7.0\",\n antd: \"6.4.3\",\n \"monaco-editor\": \"0.55.1\",\n react: \"19.2.6\",\n \"react-dom\": \"19.2.6\"\n },\n devDependencies: {\n \"@earendil-works/pi-agent-core\": \"0.75.4\",\n \"@earendil-works/pi-ai\": \"0.76.0\",\n \"@hold-rein/plugin-server\": \"workspace:^\",\n express: \"5.2.1\",\n vite: \"6.3.5\",\n \"@ant-design/icons\": \"6.2.5\",\n \"@hold-rein/plugin-web\": \"workspace:^\",\n \"@monaco-editor/react\": \"4.7.0\",\n \"@types/react\": \"19.2.15\",\n antd: \"6.4.3\",\n \"monaco-editor\": \"0.55.1\",\n react: \"19.2.6\",\n \"react-dom\": \"19.2.6\"\n }\n} as const;\n\nconst tsconfigJson = `{\n \"compilerOptions\": {\n \"declaration\": true,\n \"declarationMap\": true,\n \"esModuleInterop\": true,\n \"exactOptionalPropertyTypes\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"isolatedModules\": true,\n \"module\": \"ESNext\",\n \"moduleResolution\": \"Bundler\",\n \"noFallthroughCasesInSwitch\": true,\n \"noImplicitOverride\": true,\n \"noUncheckedIndexedAccess\": true,\n \"resolveJsonModule\": true,\n \"skipLibCheck\": true,\n \"strict\": true,\n \"target\": \"ES2022\",\n \"useDefineForClassFields\": true,\n \"verbatimModuleSyntax\": true,\n \"jsx\": \"react-jsx\",\n \"lib\": [\"DOM\", \"DOM.Iterable\", \"ES2022\"],\n \"outDir\": \"dist\",\n \"rootDir\": \"src\"\n },\n \"include\": [\"src/**/*.ts\", \"src/**/*.tsx\"],\n \"exclude\": [\"src/**/*.test.ts\", \"src/**/*.test.tsx\"]\n}\n`;\n\nconst viteConfigTs = `import { builtinModules } from \"node:module\";\n\nimport { defineConfig } from \"vite\";\n\nconst nodeBuiltins = builtinModules.flatMap((name) => [\n name,\n \\`node:\\${name}\\`\n]);\n\nexport default defineConfig({\n build: {\n lib: {\n entry: \"src/server.ts\",\n fileName: (format) => \\`server.\\${format === \"cjs\" ? \"cjs\" : \"js\"}\\`,\n formats: [\"es\", \"cjs\"]\n },\n rollupOptions: {\n external: [\n ...nodeBuiltins,\n \"@hold-rein/plugin-server\",\n \"@earendil-works/pi-agent-core\",\n \"@earendil-works/pi-ai\",\n \"express\"\n ]\n },\n sourcemap: true\n }\n});\n`;\n\nconst viteWebConfigTs = `import { defineConfig } from \"vite\";\n\nexport default defineConfig({\n build: {\n emptyOutDir: false,\n lib: {\n cssFileName: \"style\",\n entry: \"src/web.ts\",\n fileName: () => \"web.umd.cjs\",\n formats: [\"umd\"],\n name: \"HoldReinPlugin\"\n },\n sourcemap: true,\n rollupOptions: {\n external: [\n \"@ant-design/icons\",\n \"@hold-rein/plugin-web\",\n \"@monaco-editor/react\",\n \"antd\",\n \"monaco-editor\",\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\"\n ]\n }\n }\n});\n`;\n\nexport const initPluginPackage = (\n currentWorkingDirectory: string,\n options: InitPluginPackageOptions = {}\n): InitPluginPackageResult => {\n const targetRootDirectory = options.path ?? currentWorkingDirectory;\n const targetDirectory =\n options.name === undefined\n ? targetRootDirectory\n : join(targetRootDirectory, options.name);\n const folderName = basename(targetDirectory);\n const packageName = `hold-rein-plugin-${folderName}`;\n const packageJson = {\n ...basePackageJson,\n name: packageName\n };\n\n writeFiles(targetDirectory, {\n \"package.json\": `${JSON.stringify(packageJson, null, 2)}\\n`,\n \"tsconfig.json\": tsconfigJson,\n \"vite.config.ts\": viteConfigTs,\n \"vite.web.config.ts\": viteWebConfigTs,\n \"src/plugin-id.ts\": `export const PLUGIN_ID = \"__${folderName}__plugin\";\\n`,\n \"src/server.ts\": createServerPluginSource(),\n \"src/web.ts\": createWebPluginSource()\n });\n\n return { packageName };\n};\n\nfunction writeFiles(\n currentWorkingDirectory: string,\n files: Readonly<Record<string, string>>\n): void {\n for (const relativePath of Object.keys(files)) {\n const path = join(currentWorkingDirectory, relativePath);\n\n if (existsSync(path)) {\n throw new Error(`Refusing to overwrite existing file: ${relativePath}`);\n }\n }\n\n mkdirSync(join(currentWorkingDirectory, \"src\"), { recursive: true });\n\n for (const [relativePath, contents] of Object.entries(files)) {\n writeFileSync(join(currentWorkingDirectory, relativePath), contents);\n }\n}\n\nfunction createServerPluginSource(): string {\n return `import type { ServerPlugin } from \"@hold-rein/plugin-server\";\n\nimport { PLUGIN_ID } from \"./plugin-id\";\n\nconst serverPlugin: ServerPlugin.Plugin = {\n id: PLUGIN_ID\n};\n\nexport default serverPlugin;\n`;\n}\n\nfunction createWebPluginSource(): string {\n return `import type { WebPlugin } from \"@hold-rein/plugin-web\";\n\nimport { PLUGIN_ID } from \"./plugin-id\";\n\nconst webPlugin: WebPlugin.Plugin = {\n id: PLUGIN_ID\n};\n\nexport default webPlugin;\n`;\n}\n","import {\n initPluginPackage,\n installPluginPackage as installPluginPackageDefault,\n type InstallPluginPackageOptions\n} from \"@hold-rein/plugin-server\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface CliOptions {\n readonly installPluginPackage?: (\n options: InstallPluginPackageOptions\n ) => Promise<string>;\n readonly packageVersion: string;\n readonly startRunServer?: StartRunServer;\n readonly write: (value: string) => void;\n readonly currentWorkingDirectory?: string;\n}\n\nexport interface CliResult {\n readonly exitCode: number;\n}\n\nexport interface RunServerOptions {\n readonly host: string;\n readonly port: number;\n readonly write: (value: string) => void;\n}\n\nexport interface RunServerResult {\n readonly host: string;\n readonly port: number;\n readonly url: string;\n}\n\nexport type StartRunServer = (\n options: RunServerOptions\n) => Promise<RunServerResult>;\n\nconst HELP_TEXT = `Hold Rein CLI\n\nUsage: hold-rein <command>\n\nAliases: hold-rein, hr\n\nCommands:\n run Start the bundled Hold Rein service\n plugin init Initialize a plugin package\n plugin install Install a plugin package\n version Print the current CLI version\n help Print this help message\n\nOptions:\n run --host <host> Bind to a specific host (default: 127.0.0.1)\n run --port <port> Bind to a specific port (default: 3001)\n plugin init --path <path> Initialize in a specific path\n plugin init --name <name> Initialize in a child directory\n plugin install --target <path> Install into a specific plugin directory\n -v, --version Print the current CLI version\n -h, --help Print this help message\n`;\n\nconst VERSION_ARGS = new Set([\"version\", \"--version\", \"-v\"]);\nconst HELP_ARGS = new Set([\"help\", \"--help\", \"-h\"]);\nconst DEFAULT_RUN_HOST = \"127.0.0.1\";\nconst DEFAULT_RUN_PORT = 3001;\n\nexport const getHelpText = (): string => HELP_TEXT;\n\nexport const runCli = async (\n args: readonly string[],\n options: CliOptions\n): Promise<CliResult> => {\n const [command, subcommand, ...commandArgs] = args;\n\n if (command === undefined || HELP_ARGS.has(command)) {\n options.write(HELP_TEXT);\n return { exitCode: 0 };\n }\n\n if (VERSION_ARGS.has(command)) {\n options.write(`${options.packageVersion}\\n`);\n return { exitCode: 0 };\n }\n\n if (command === \"run\") {\n try {\n const runOptions = parseRunOptions([subcommand, ...commandArgs]);\n const startRunServer = options.startRunServer ?? startBundledRunServer;\n const result = await startRunServer({\n host: runOptions.host,\n port: runOptions.port,\n write: options.write\n });\n options.write(`Hold Rein is running at ${result.url}\\n`);\n return { exitCode: 0 };\n } catch (error) {\n options.write(`Failed to start service: ${formatError(error)}\\n`);\n return { exitCode: 1 };\n }\n }\n\n if (command === \"plugin\" && subcommand === \"init\") {\n try {\n const result = initPluginPackage(\n options.currentWorkingDirectory ?? process.cwd(),\n parsePluginInitOptions(commandArgs)\n );\n options.write(`Initialized plugin package ${result.packageName}\\n`);\n return { exitCode: 0 };\n } catch (error) {\n options.write(\n `Failed to initialize plugin package: ${formatError(error)}\\n`\n );\n return { exitCode: 1 };\n }\n }\n\n if (command === \"plugin\" && subcommand === \"install\") {\n try {\n const installOptions = parsePluginInstallOptions(commandArgs);\n const installPluginPackage =\n options.installPluginPackage ?? installPluginPackageDefault;\n const destination = await installPluginPackage({\n currentWorkingDirectory: options.currentWorkingDirectory ?? process.cwd(),\n pluginRoot:\n installOptions.target ?? join(homedir(), \".hold-rein\", \"plugins\"),\n source: installOptions.source,\n write: options.write\n });\n options.write(`Installed plugin to ${destination}\\n`);\n return { exitCode: 0 };\n } catch (error) {\n options.write(`Failed to install plugin: ${formatError(error)}\\n`);\n return { exitCode: 1 };\n }\n }\n\n options.write(`Unknown command: ${command}\\n\\n${HELP_TEXT}`);\n return { exitCode: 1 };\n};\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction parsePluginInstallOptions(\n args: readonly string[]\n): { readonly source: string; readonly target?: string } {\n const source = args[0];\n\n if (source === undefined || source.startsWith(\"-\")) {\n throw new Error(\"Missing plugin source\");\n }\n\n const options: { source: string; target?: string } = { source };\n const target = readOptionValue(args, \"--target\");\n\n if (target !== undefined) {\n options.target = target;\n }\n\n return options;\n}\n\nfunction parseRunOptions(\n args: readonly (string | undefined)[]\n): { readonly host: string; readonly port: number } {\n const compactArgs = args.filter((arg): arg is string => arg !== undefined);\n const host = readOptionValue(compactArgs, \"--host\") ?? DEFAULT_RUN_HOST;\n const portValue = readOptionValue(compactArgs, \"--port\");\n const port = portValue === undefined ? DEFAULT_RUN_PORT : Number(portValue);\n\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(\"Port must be an integer between 1 and 65535\");\n }\n\n return { host, port };\n}\n\nfunction parsePluginInitOptions(\n args: readonly string[]\n): { readonly name?: string; readonly path?: string } {\n const options: { name?: string; path?: string } = {};\n const name = readOptionValue(args, \"--name\");\n const path = readOptionValue(args, \"--path\");\n\n if (name !== undefined) {\n options.name = name;\n }\n\n if (path !== undefined) {\n options.path = path;\n }\n\n return options;\n}\n\nasync function startBundledRunServer(\n options: RunServerOptions\n): Promise<RunServerResult> {\n const runtimeModule = (await import(\n new URL(\"./runtime/api/runtime.js\", import.meta.url).href\n )) as {\n readonly startHoldReinServer: (\n options: RunServerOptions & { readonly webAssetsDirectory: string }\n ) => Promise<RunServerResult>;\n };\n\n return runtimeModule.startHoldReinServer({\n ...options,\n webAssetsDirectory: fileURLToPath(new URL(\"./runtime/web\", import.meta.url))\n });\n}\n\nfunction readOptionValue(\n args: readonly string[],\n optionName: string\n): string | undefined {\n const optionIndex = args.indexOf(optionName);\n\n if (optionIndex === -1) {\n return undefined;\n }\n\n const value = args[optionIndex + 1];\n\n if (value === undefined || value.startsWith(\"-\")) {\n throw new Error(`Missing value for ${optionName}`);\n }\n\n return value;\n}\n"],"names":["parseGithubPluginSource","source","trimmedSource","rootMatch","owner","repo","toGitRepositoryUrl","webMatch","kind","path","ref","pathSegments","normalizeGithubPathSegments","subdirectory","segments","segment","useSsh","execFileAsync","promisify","execFile","runInstallCommand","runner","command","args","cwd","write","formatCommand","result","ensureTrailingNewline","value","readValidPluginPackageManifest","packageDirectory","manifest","readFile","join","packageManifest","name","hasServerExport","createPublishedManifest","withoutPublishConfig","isBuiltPackageManifest","serverEntry","resolveExportValue","isSourceEntry","exportsField","packageJson","publishedManifest","entry","conditions","encodePluginDirectoryName","packageName","copyInstalledPluginPackage","options","destination","mkdir","rm","_a","cp","installNpmPluginPackage","tempRoot","mkdtemp","tmpdir","installDir","writeFile","sourcePackageDir","installPluginPackage","githubSource","installGithubPluginPackage","localDirectory","resolveLocalDirectory","installLocalPluginPackage","sourceDirectory","ensurePnpmAvailable","installBuiltSourcePackage","cloneDir","installGitRepository","cloneGitRepository","pluginRoot","directDistPackage","hasPackageManifest","stagingDir","directory","stat","runCommand","currentWorkingDirectory","isAbsolute","resolve","repositoryUrl","targetDir","basePackageJson","tsconfigJson","viteConfigTs","viteWebConfigTs","initPluginPackage","targetRootDirectory","targetDirectory","folderName","basename","writeFiles","createServerPluginSource","createWebPluginSource","files","relativePath","existsSync","mkdirSync","contents","writeFileSync","HELP_TEXT","VERSION_ARGS","HELP_ARGS","DEFAULT_RUN_HOST","DEFAULT_RUN_PORT","runCli","subcommand","commandArgs","runOptions","parseRunOptions","startBundledRunServer","error","formatError","parsePluginInitOptions","installOptions","parsePluginInstallOptions","installPluginPackageDefault","homedir","target","readOptionValue","compactArgs","arg","host","portValue","port","fileURLToPath","optionName","optionIndex"],"mappings":"2aAMO,SAASA,EACdC,EACgC,CAChC,MAAMC,EAAgBD,EAAO,KAAA,EACvBE,EACJ,8EAA8E,KAC5ED,CAAA,GAEF,oEAAoE,KAClEA,CAAA,EAGJ,GAAIC,GAAA,MAAAA,EAAW,OAAQ,CACrB,KAAM,CAAE,MAAAC,EAAO,KAAAC,CAAAA,EAASF,EAAU,OAElC,MAAI,CAACC,GAAS,CAACC,EACb,OAGK,CACL,cAAeC,EACbF,EACAC,EACAH,EAAc,WAAW,iBAAiB,CAAA,CAC5C,CAEJ,CAEA,MAAMK,EACJ,0HAA0H,KACxHL,CAAA,EAGJ,GAAI,EAACK,GAAA,MAAAA,EAAU,QACb,OAGF,KAAM,CAAE,KAAAC,EAAM,MAAAJ,EAAO,KAAAK,EAAM,IAAAC,EAAK,KAAAL,CAAA,EAASE,EAAS,OAElD,GAAI,CAACC,GAAQ,CAACJ,GAAS,CAACM,GAAO,CAACL,EAC9B,OAGF,MAAMM,EAAeC,EAA4BH,CAAI,EAC/CI,EACJL,IAAS,QAAUG,EAAa,GAAG,EAAE,IAAM,eACvCA,EAAa,MAAM,EAAG,EAAE,EAAE,KAAK,GAAG,EAClCA,EAAa,KAAK,GAAG,EAE3B,MAAO,CACL,IAAAD,EACA,cAAeJ,EAAmBF,EAAOC,CAAI,EAC7C,GAAIQ,EAAa,SAAW,EAAI,CAAA,EAAK,CAAE,aAAAA,CAAA,CAAa,CAExD,CAEA,SAASD,EAA4BH,EAAoC,CACvE,GAAI,CAACA,EACH,MAAO,CAAA,EAGT,MAAMK,EAAWL,EAAK,MAAM,GAAG,EAAE,OAAQM,GAAYA,EAAQ,OAAS,CAAC,EAEvE,OAAID,EAAS,KAAMC,GAAYA,IAAY,KAAOA,IAAY,IAAI,EACzD,CAAA,EAGFD,CACT,CAEA,SAASR,EACP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,CACvC,GAAGA,EACH,mBAAoBgF,EAAc,IAAA,IAAA,gBAAA,YAAA,GAAA,CAAyC,CAAA,CAC5E,CACH,CAEA,SAASN,EACPvG,EACA8G,EACoB,CACpB,MAAMC,EAAc/G,EAAK,QAAQ8G,CAAU,EAE3C,GAAIC,IAAgB,GAClB,OAGF,MAAMzG,EAAQN,EAAK+G,EAAc,CAAC,EAElC,GAAIzG,IAAU,QAAaA,EAAM,WAAW,GAAG,EAC7C,MAAM,IAAI,MAAM,qBAAqBwG,CAAU,EAAE,EAGnD,OAAOxG,CACT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Express } from "express";
|
|
2
|
+
import { type CreateV1RouterOptions } from "./router/v1";
|
|
3
|
+
export interface CreateAppOptions extends CreateV1RouterOptions {
|
|
4
|
+
readonly webAssetsDirectory?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createApp(options?: CreateAppOptions): Promise<Express>;
|
|
7
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAEA,OAAgB,EAAE,KAAK,OAAO,EAAU,MAAM,SAAS,CAAC;AAKxD,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIzE,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC7D,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBhF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import express, { Router } from "express";
|
|
3
|
+
import { getApiEnv } from "./config/env.js";
|
|
4
|
+
import { errorMiddleware } from "./middleware/error-middleware.js";
|
|
5
|
+
import { notFoundMiddleware } from "./middleware/not-found-middleware.js";
|
|
6
|
+
import { createV1Router } from "./router/v1/index.js";
|
|
7
|
+
import { pluginRegistry } from './plugin.js';
|
|
8
|
+
import { sendError, sendSuccess, RESPONSE_CODE_DEFINITIONS } from './response/index.js';
|
|
9
|
+
export async function createApp(options = {}) {
|
|
10
|
+
const app = express();
|
|
11
|
+
const pluginRouter = await createPluginRouter();
|
|
12
|
+
app.use(express.json());
|
|
13
|
+
app.use("/api/v1", createV1Router(options));
|
|
14
|
+
app.use("/plugin-assets/:pluginDir", createPluginAssetsMiddleware());
|
|
15
|
+
app.use("/plugin", pluginRouter);
|
|
16
|
+
if (options.webAssetsDirectory !== undefined) {
|
|
17
|
+
const webAssetsDirectory = options.webAssetsDirectory;
|
|
18
|
+
app.use(express.static(webAssetsDirectory));
|
|
19
|
+
app.use((_request, response) => {
|
|
20
|
+
response.sendFile(join(webAssetsDirectory, "index.html"));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
app.use(notFoundMiddleware);
|
|
24
|
+
app.use(errorMiddleware);
|
|
25
|
+
return app;
|
|
26
|
+
}
|
|
27
|
+
function createPluginAssetsMiddleware() {
|
|
28
|
+
return (request, response, next) => {
|
|
29
|
+
const staticMiddleware = express.static(join(getApiEnv().pluginRoot, request.params.pluginDir, "dist"));
|
|
30
|
+
staticMiddleware(request, response, next);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function createPluginRouter() {
|
|
34
|
+
const pluginRouter = Router();
|
|
35
|
+
await pluginRegistry.registerRoutes(pluginRouter, {
|
|
36
|
+
sendError,
|
|
37
|
+
sendSuccess,
|
|
38
|
+
RESPONSE_CODE_DEFINITIONS
|
|
39
|
+
});
|
|
40
|
+
return pluginRouter;
|
|
41
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const AGENT_ROOT_DIR: string;
|
|
2
|
+
export declare const SESSION_DIR_NAME = "sessions";
|
|
3
|
+
export declare const SESSIONS_DIR: string;
|
|
4
|
+
export declare const MEMORY_DIR: string;
|
|
5
|
+
export declare const SKILL_DIR: string;
|
|
6
|
+
export declare const PLUGIN_DIR: string;
|
|
7
|
+
export declare const DB_FILE: string;
|
|
8
|
+
//# sourceMappingURL=const.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../src/config/const.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,QAAqC,CAAA;AAEhE,eAAO,MAAM,gBAAgB,aAAa,CAAA;AAE1C,eAAO,MAAM,YAAY,QAAmD,CAAA;AAE5E,eAAO,MAAM,UAAU,QAAwC,CAAA;AAE/D,eAAO,MAAM,SAAS,QAAsC,CAAA;AAE5D,eAAO,MAAM,UAAU,QAAuC,CAAA;AAE9D,eAAO,MAAM,OAAO,QAAgD,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
export const AGENT_ROOT_DIR = resolve(homedir(), './.hold-rein');
|
|
4
|
+
export const SESSION_DIR_NAME = 'sessions';
|
|
5
|
+
export const SESSIONS_DIR = resolve(AGENT_ROOT_DIR, `./${SESSION_DIR_NAME}`);
|
|
6
|
+
export const MEMORY_DIR = resolve(AGENT_ROOT_DIR, './memories');
|
|
7
|
+
export const SKILL_DIR = resolve(AGENT_ROOT_DIR, './skills');
|
|
8
|
+
export const PLUGIN_DIR = resolve(AGENT_ROOT_DIR, './plugins');
|
|
9
|
+
export const DB_FILE = resolve(AGENT_ROOT_DIR, './hold-rein.sqlite');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface LoadApiEnvOptions {
|
|
2
|
+
envDir?: string;
|
|
3
|
+
targetEnv?: NodeJS.ProcessEnv;
|
|
4
|
+
}
|
|
5
|
+
export interface ApiEnv {
|
|
6
|
+
readonly pluginRoot: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function loadApiEnv(options?: LoadApiEnvOptions): void;
|
|
9
|
+
export declare function getApiEnv(targetEnv?: NodeJS.ProcessEnv): ApiEnv;
|
|
10
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAC/B;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAID,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,IAAI,CAsBhE;AAED,wBAAgB,SAAS,CAAC,SAAS,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAI5E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { parseEnv } from "node:util";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { PLUGIN_DIR } from "./const.js";
|
|
6
|
+
const API_ENV_FILE_NAMES = [".env", ".env.local"];
|
|
7
|
+
export function loadApiEnv(options = {}) {
|
|
8
|
+
const envDir = options.envDir ?? getDefaultApiEnvDir();
|
|
9
|
+
const targetEnv = options.targetEnv ?? process.env;
|
|
10
|
+
const originalKeys = new Set(Object.keys(targetEnv));
|
|
11
|
+
for (const fileName of API_ENV_FILE_NAMES) {
|
|
12
|
+
const filePath = resolve(envDir, fileName);
|
|
13
|
+
if (!existsSync(filePath)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const parsedEntries = parseEnv(readFileSync(filePath, "utf8"));
|
|
17
|
+
for (const [key, value] of Object.entries(parsedEntries)) {
|
|
18
|
+
if (originalKeys.has(key)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
targetEnv[key] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function getApiEnv(targetEnv = process.env) {
|
|
26
|
+
return {
|
|
27
|
+
pluginRoot: targetEnv.HOLD_REIN_PLUGIN_ROOT ?? PLUGIN_DIR
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getDefaultApiEnvDir() {
|
|
31
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import { type BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
|
|
3
|
+
import * as schema from "./schema";
|
|
4
|
+
export interface AppDatabase {
|
|
5
|
+
close: () => void;
|
|
6
|
+
db: BetterSQLite3Database<typeof schema>;
|
|
7
|
+
sqlite: Database.Database;
|
|
8
|
+
}
|
|
9
|
+
export declare function ensureDatabaseDirectory(path: string): string;
|
|
10
|
+
export declare function createDatabase(path: string): AppDatabase;
|
|
11
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/db/connection.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAW,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEjF,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,EAAE,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC;IACzC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC;CAC3B;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAYxD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import Database from "better-sqlite3";
|
|
4
|
+
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
5
|
+
import * as schema from "./schema.js";
|
|
6
|
+
export function ensureDatabaseDirectory(path) {
|
|
7
|
+
const resolvedPath = resolve(path);
|
|
8
|
+
mkdirSync(dirname(resolvedPath), { recursive: true });
|
|
9
|
+
return resolvedPath;
|
|
10
|
+
}
|
|
11
|
+
export function createDatabase(path) {
|
|
12
|
+
const resolvedPath = ensureDatabaseDirectory(path);
|
|
13
|
+
const sqlite = new Database(resolvedPath);
|
|
14
|
+
return {
|
|
15
|
+
close: () => {
|
|
16
|
+
sqlite.close();
|
|
17
|
+
},
|
|
18
|
+
db: drizzle(sqlite, { schema }),
|
|
19
|
+
sqlite
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDatabase, ensureDatabaseDirectory, type AppDatabase } from "./connection";
|
|
2
|
+
export { migrateDatabase } from "./migrate";
|
|
3
|
+
export { customModelProviders, customProviderModels, modelProxies, modelProxyCandidateLimits, modelProxyCandidates, modelTokenUsageHourly, providerApiKeys, subagents, tasks, workspaces, type CustomModelProviderRow, type CustomProviderModelRow, type NewCustomModelProviderRow, type NewCustomProviderModelRow, type ModelProxyCandidateLimitRow, type ModelProxyCandidateRow, type ModelProxyRow, type NewModelProxyCandidateLimitRow, type NewModelProxyCandidateRow, type NewModelProxyRow, type NewModelTokenUsageHourlyRow, type NewProviderApiKeyRow, type NewSubagentRow, type NewTaskRow, type NewWorkspaceRow, type ProviderApiKeyRow, type ModelTokenUsageHourlyRow, type SubagentRow, type TaskRow, type WorkspaceRow } from "./schema";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,SAAS,EACT,KAAK,EACL,UAAU,EACV,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createDatabase, ensureDatabaseDirectory } from "./connection.js";
|
|
2
|
+
export { migrateDatabase } from "./migrate.js";
|
|
3
|
+
export { customModelProviders, customProviderModels, modelProxies, modelProxyCandidateLimits, modelProxyCandidates, modelTokenUsageHourly, providerApiKeys, subagents, tasks, workspaces } from "./schema.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/db/migrate.ts"],"names":[],"mappings":"AAsPA,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAAG,IAAI,CA2C7E"}
|