@fidelios/server 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/codex-models.d.ts +4 -0
- package/dist/adapters/codex-models.d.ts.map +1 -0
- package/dist/adapters/codex-models.js +98 -0
- package/dist/adapters/codex-models.js.map +1 -0
- package/dist/adapters/cursor-models.d.ts +13 -0
- package/dist/adapters/cursor-models.d.ts.map +1 -0
- package/dist/adapters/cursor-models.js +148 -0
- package/dist/adapters/cursor-models.js.map +1 -0
- package/dist/adapters/http/execute.d.ts +3 -0
- package/dist/adapters/http/execute.d.ts.map +1 -0
- package/dist/adapters/http/execute.js +39 -0
- package/dist/adapters/http/execute.js.map +1 -0
- package/dist/adapters/http/index.d.ts +3 -0
- package/dist/adapters/http/index.d.ts.map +1 -0
- package/dist/adapters/http/index.js +20 -0
- package/dist/adapters/http/index.js.map +1 -0
- package/dist/adapters/http/test.d.ts +3 -0
- package/dist/adapters/http/test.d.ts.map +1 -0
- package/dist/adapters/http/test.js +106 -0
- package/dist/adapters/http/test.js.map +1 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/process/execute.d.ts +3 -0
- package/dist/adapters/process/execute.d.ts.map +1 -0
- package/dist/adapters/process/execute.js +63 -0
- package/dist/adapters/process/execute.js.map +1 -0
- package/dist/adapters/process/index.d.ts +3 -0
- package/dist/adapters/process/index.d.ts.map +1 -0
- package/dist/adapters/process/index.js +23 -0
- package/dist/adapters/process/index.js.map +1 -0
- package/dist/adapters/process/test.d.ts +3 -0
- package/dist/adapters/process/test.d.ts.map +1 -0
- package/dist/adapters/process/test.js +77 -0
- package/dist/adapters/process/test.js.map +1 -0
- package/dist/adapters/registry.d.ts +14 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +164 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/adapters/utils.d.ts +10 -0
- package/dist/adapters/utils.d.ts.map +1 -0
- package/dist/adapters/utils.js +14 -0
- package/dist/adapters/utils.js.map +1 -0
- package/dist/agent-auth-jwt.d.ts +14 -0
- package/dist/agent-auth-jwt.d.ts.map +1 -0
- package/dist/agent-auth-jwt.js +117 -0
- package/dist/agent-auth-jwt.js.map +1 -0
- package/dist/app.d.ts +25 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +265 -0
- package/dist/app.js.map +1 -0
- package/dist/attachment-types.d.ts +33 -0
- package/dist/attachment-types.d.ts.map +1 -0
- package/dist/attachment-types.js +67 -0
- package/dist/attachment-types.js.map +1 -0
- package/dist/auth/better-auth.d.ts +24 -0
- package/dist/auth/better-auth.d.ts.map +1 -0
- package/dist/auth/better-auth.js +108 -0
- package/dist/auth/better-auth.js.map +1 -0
- package/dist/board-claim.d.ts +23 -0
- package/dist/board-claim.d.ts.map +1 -0
- package/dist/board-claim.js +115 -0
- package/dist/board-claim.js.map +1 -0
- package/dist/config-file.d.ts +3 -0
- package/dist/config-file.d.ts.map +1 -0
- package/dist/config-file.js +16 -0
- package/dist/config-file.js.map +1 -0
- package/dist/config.d.ts +45 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +171 -0
- package/dist/config.js.map +1 -0
- package/dist/dev-server-status.d.ts +27 -0
- package/dist/dev-server-status.d.ts.map +1 -0
- package/dist/dev-server-status.js +70 -0
- package/dist/dev-server-status.js.map +1 -0
- package/dist/dev-watch-ignore.d.ts +2 -0
- package/dist/dev-watch-ignore.d.ts.map +1 -0
- package/dist/dev-watch-ignore.js +33 -0
- package/dist/dev-watch-ignore.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -0
- package/dist/home-paths.d.ts +17 -0
- package/dist/home-paths.d.ts.map +1 -0
- package/dist/home-paths.js +75 -0
- package/dist/home-paths.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +642 -0
- package/dist/index.js.map +1 -0
- package/dist/log-redaction.d.ts +11 -0
- package/dist/log-redaction.d.ts.map +1 -0
- package/dist/log-redaction.js +118 -0
- package/dist/log-redaction.js.map +1 -0
- package/dist/middleware/auth.d.ts +12 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +144 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/board-mutation-guard.d.ts +3 -0
- package/dist/middleware/board-mutation-guard.d.ts.map +1 -0
- package/dist/middleware/board-mutation-guard.js +59 -0
- package/dist/middleware/board-mutation-guard.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +17 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +37 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/index.d.ts +4 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +4 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/logger.d.ts +4 -0
- package/dist/middleware/logger.d.ts.map +1 -0
- package/dist/middleware/logger.js +87 -0
- package/dist/middleware/logger.js.map +1 -0
- package/dist/middleware/private-hostname-guard.d.ts +11 -0
- package/dist/middleware/private-hostname-guard.d.ts.map +1 -0
- package/dist/middleware/private-hostname-guard.js +78 -0
- package/dist/middleware/private-hostname-guard.js.map +1 -0
- package/dist/middleware/validate.d.ts +4 -0
- package/dist/middleware/validate.d.ts.map +1 -0
- package/dist/middleware/validate.js +7 -0
- package/dist/middleware/validate.js.map +1 -0
- package/dist/onboarding-assets/ceo/AGENTS.md +54 -0
- package/dist/onboarding-assets/ceo/HEARTBEAT.md +72 -0
- package/dist/onboarding-assets/ceo/SOUL.md +33 -0
- package/dist/onboarding-assets/ceo/TOOLS.md +3 -0
- package/dist/onboarding-assets/default/AGENTS.md +3 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +31 -0
- package/dist/paths.js.map +1 -0
- package/dist/realtime/live-events-ws.d.ts +28 -0
- package/dist/realtime/live-events-ws.d.ts.map +1 -0
- package/dist/realtime/live-events-ws.js +187 -0
- package/dist/realtime/live-events-ws.js.map +1 -0
- package/dist/redaction.d.ts +4 -0
- package/dist/redaction.d.ts.map +1 -0
- package/dist/redaction.js +63 -0
- package/dist/redaction.js.map +1 -0
- package/dist/routes/access.d.ts +61 -0
- package/dist/routes/access.d.ts.map +1 -0
- package/dist/routes/access.js +2265 -0
- package/dist/routes/access.js.map +1 -0
- package/dist/routes/activity.d.ts +3 -0
- package/dist/routes/activity.d.ts.map +1 -0
- package/dist/routes/activity.js +78 -0
- package/dist/routes/activity.js.map +1 -0
- package/dist/routes/agents.d.ts +3 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +1828 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/approvals.d.ts +3 -0
- package/dist/routes/approvals.d.ts.map +1 -0
- package/dist/routes/approvals.js +275 -0
- package/dist/routes/approvals.js.map +1 -0
- package/dist/routes/assets.d.ts +4 -0
- package/dist/routes/assets.d.ts.map +1 -0
- package/dist/routes/assets.js +309 -0
- package/dist/routes/assets.js.map +1 -0
- package/dist/routes/authz.d.ts +16 -0
- package/dist/routes/authz.d.ts.map +1 -0
- package/dist/routes/authz.js +47 -0
- package/dist/routes/authz.js.map +1 -0
- package/dist/routes/companies.d.ts +4 -0
- package/dist/routes/companies.d.ts.map +1 -0
- package/dist/routes/companies.js +303 -0
- package/dist/routes/companies.js.map +1 -0
- package/dist/routes/company-skills.d.ts +3 -0
- package/dist/routes/company-skills.d.ts.map +1 -0
- package/dist/routes/company-skills.js +228 -0
- package/dist/routes/company-skills.js.map +1 -0
- package/dist/routes/costs.d.ts +3 -0
- package/dist/routes/costs.d.ts.map +1 -0
- package/dist/routes/costs.js +268 -0
- package/dist/routes/costs.js.map +1 -0
- package/dist/routes/dashboard.d.ts +3 -0
- package/dist/routes/dashboard.d.ts.map +1 -0
- package/dist/routes/dashboard.js +15 -0
- package/dist/routes/dashboard.js.map +1 -0
- package/dist/routes/execution-workspaces.d.ts +3 -0
- package/dist/routes/execution-workspaces.d.ts.map +1 -0
- package/dist/routes/execution-workspaces.js +165 -0
- package/dist/routes/execution-workspaces.js.map +1 -0
- package/dist/routes/goals.d.ts +3 -0
- package/dist/routes/goals.d.ts.map +1 -0
- package/dist/routes/goals.js +95 -0
- package/dist/routes/goals.js.map +1 -0
- package/dist/routes/health.d.ts +9 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +69 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/index.d.ts +18 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +18 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/instance-settings.d.ts +3 -0
- package/dist/routes/instance-settings.d.ts.map +1 -0
- package/dist/routes/instance-settings.js +71 -0
- package/dist/routes/instance-settings.js.map +1 -0
- package/dist/routes/issues-checkout-wakeup.d.ts +9 -0
- package/dist/routes/issues-checkout-wakeup.d.ts.map +1 -0
- package/dist/routes/issues-checkout-wakeup.js +12 -0
- package/dist/routes/issues-checkout-wakeup.js.map +1 -0
- package/dist/routes/issues.d.ts +4 -0
- package/dist/routes/issues.d.ts.map +1 -0
- package/dist/routes/issues.js +1520 -0
- package/dist/routes/issues.js.map +1 -0
- package/dist/routes/llms.d.ts +3 -0
- package/dist/routes/llms.d.ts.map +1 -0
- package/dist/routes/llms.js +78 -0
- package/dist/routes/llms.js.map +1 -0
- package/dist/routes/org-chart-svg.d.ts +25 -0
- package/dist/routes/org-chart-svg.d.ts.map +1 -0
- package/dist/routes/org-chart-svg.js +656 -0
- package/dist/routes/org-chart-svg.js.map +1 -0
- package/dist/routes/plugin-ui-static.d.ts +69 -0
- package/dist/routes/plugin-ui-static.d.ts.map +1 -0
- package/dist/routes/plugin-ui-static.js +411 -0
- package/dist/routes/plugin-ui-static.js.map +1 -0
- package/dist/routes/plugins.d.ts +120 -0
- package/dist/routes/plugins.d.ts.map +1 -0
- package/dist/routes/plugins.js +1784 -0
- package/dist/routes/plugins.js.map +1 -0
- package/dist/routes/projects.d.ts +3 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +257 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/routines.d.ts +3 -0
- package/dist/routes/routines.d.ts.map +1 -0
- package/dist/routes/routines.js +277 -0
- package/dist/routes/routines.js.map +1 -0
- package/dist/routes/secrets.d.ts +3 -0
- package/dist/routes/secrets.d.ts.map +1 -0
- package/dist/routes/secrets.js +128 -0
- package/dist/routes/secrets.js.map +1 -0
- package/dist/routes/sidebar-badges.d.ts +3 -0
- package/dist/routes/sidebar-badges.d.ts.map +1 -0
- package/dist/routes/sidebar-badges.js +45 -0
- package/dist/routes/sidebar-badges.js.map +1 -0
- package/dist/secrets/external-stub-providers.d.ts +5 -0
- package/dist/secrets/external-stub-providers.d.ts.map +1 -0
- package/dist/secrets/external-stub-providers.js +21 -0
- package/dist/secrets/external-stub-providers.js.map +1 -0
- package/dist/secrets/local-encrypted-provider.d.ts +3 -0
- package/dist/secrets/local-encrypted-provider.d.ts.map +1 -0
- package/dist/secrets/local-encrypted-provider.js +116 -0
- package/dist/secrets/local-encrypted-provider.js.map +1 -0
- package/dist/secrets/provider-registry.d.ts +5 -0
- package/dist/secrets/provider-registry.d.ts.map +1 -0
- package/dist/secrets/provider-registry.js +20 -0
- package/dist/secrets/provider-registry.js.map +1 -0
- package/dist/secrets/types.d.ts +21 -0
- package/dist/secrets/types.d.ts.map +1 -0
- package/dist/secrets/types.js +2 -0
- package/dist/secrets/types.js.map +1 -0
- package/dist/services/access.d.ts +113 -0
- package/dist/services/access.d.ts.map +1 -0
- package/dist/services/access.js +247 -0
- package/dist/services/access.js.map +1 -0
- package/dist/services/activity-log.d.ts +17 -0
- package/dist/services/activity-log.d.ts.map +1 -0
- package/dist/services/activity-log.js +74 -0
- package/dist/services/activity-log.js.map +1 -0
- package/dist/services/activity.d.ts +764 -0
- package/dist/services/activity.d.ts.map +1 -0
- package/dist/services/activity.js +105 -0
- package/dist/services/activity.js.map +1 -0
- package/dist/services/agent-instructions.d.ts +91 -0
- package/dist/services/agent-instructions.d.ts.map +1 -0
- package/dist/services/agent-instructions.js +580 -0
- package/dist/services/agent-instructions.js.map +1 -0
- package/dist/services/agent-permissions.d.ts +6 -0
- package/dist/services/agent-permissions.d.ts.map +1 -0
- package/dist/services/agent-permissions.js +18 -0
- package/dist/services/agent-permissions.js.map +1 -0
- package/dist/services/agents.d.ts +1670 -0
- package/dist/services/agents.d.ts.map +1 -0
- package/dist/services/agents.js +566 -0
- package/dist/services/agents.js.map +1 -0
- package/dist/services/approvals.d.ts +546 -0
- package/dist/services/approvals.d.ts.map +1 -0
- package/dist/services/approvals.js +212 -0
- package/dist/services/approvals.js.map +1 -0
- package/dist/services/assets.d.ts +33 -0
- package/dist/services/assets.d.ts.map +1 -0
- package/dist/services/assets.js +17 -0
- package/dist/services/assets.js.map +1 -0
- package/dist/services/board-auth.d.ts +234 -0
- package/dist/services/board-auth.d.ts.map +1 -0
- package/dist/services/board-auth.js +295 -0
- package/dist/services/board-auth.js.map +1 -0
- package/dist/services/budgets.d.ts +38 -0
- package/dist/services/budgets.d.ts.map +1 -0
- package/dist/services/budgets.js +784 -0
- package/dist/services/budgets.js.map +1 -0
- package/dist/services/companies.d.ts +124 -0
- package/dist/services/companies.d.ts.map +1 -0
- package/dist/services/companies.js +256 -0
- package/dist/services/companies.js.map +1 -0
- package/dist/services/company-export-readme.d.ts +17 -0
- package/dist/services/company-export-readme.d.ts.map +1 -0
- package/dist/services/company-export-readme.js +148 -0
- package/dist/services/company-export-readme.js.map +1 -0
- package/dist/services/company-portability.d.ts +23 -0
- package/dist/services/company-portability.d.ts.map +1 -0
- package/dist/services/company-portability.js +3739 -0
- package/dist/services/company-portability.js.map +1 -0
- package/dist/services/company-skills.d.ts +77 -0
- package/dist/services/company-skills.d.ts.map +1 -0
- package/dist/services/company-skills.js +2042 -0
- package/dist/services/company-skills.js.map +1 -0
- package/dist/services/costs.d.ts +114 -0
- package/dist/services/costs.d.ts.map +1 -0
- package/dist/services/costs.js +294 -0
- package/dist/services/costs.js.map +1 -0
- package/dist/services/cron.d.ts +80 -0
- package/dist/services/cron.d.ts.map +1 -0
- package/dist/services/cron.js +300 -0
- package/dist/services/cron.js.map +1 -0
- package/dist/services/dashboard.d.ts +26 -0
- package/dist/services/dashboard.d.ts.map +1 -0
- package/dist/services/dashboard.js +98 -0
- package/dist/services/dashboard.js.map +1 -0
- package/dist/services/default-agent-instructions.d.ts +9 -0
- package/dist/services/default-agent-instructions.d.ts.map +1 -0
- package/dist/services/default-agent-instructions.js +20 -0
- package/dist/services/default-agent-instructions.js.map +1 -0
- package/dist/services/documents.d.ts +164 -0
- package/dist/services/documents.d.ts.map +1 -0
- package/dist/services/documents.js +382 -0
- package/dist/services/documents.js.map +1 -0
- package/dist/services/execution-workspace-policy.d.ts +21 -0
- package/dist/services/execution-workspace-policy.d.ts.map +1 -0
- package/dist/services/execution-workspace-policy.js +177 -0
- package/dist/services/execution-workspace-policy.js.map +1 -0
- package/dist/services/execution-workspaces.d.ts +19 -0
- package/dist/services/execution-workspaces.d.ts.map +1 -0
- package/dist/services/execution-workspaces.js +87 -0
- package/dist/services/execution-workspaces.js.map +1 -0
- package/dist/services/finance.d.ts +93 -0
- package/dist/services/finance.d.ts.map +1 -0
- package/dist/services/finance.js +120 -0
- package/dist/services/finance.js.map +1 -0
- package/dist/services/goals.d.ts +433 -0
- package/dist/services/goals.d.ts.map +1 -0
- package/dist/services/goals.js +54 -0
- package/dist/services/goals.js.map +1 -0
- package/dist/services/heartbeat-run-summary.d.ts +2 -0
- package/dist/services/heartbeat-run-summary.d.ts.map +1 -0
- package/dist/services/heartbeat-run-summary.js +30 -0
- package/dist/services/heartbeat-run-summary.js.map +1 -0
- package/dist/services/heartbeat.d.ts +812 -0
- package/dist/services/heartbeat.d.ts.map +1 -0
- package/dist/services/heartbeat.js +3156 -0
- package/dist/services/heartbeat.js.map +1 -0
- package/dist/services/hire-hook.d.ts +14 -0
- package/dist/services/hire-hook.d.ts.map +1 -0
- package/dist/services/hire-hook.js +85 -0
- package/dist/services/hire-hook.js.map +1 -0
- package/dist/services/index.d.ts +33 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +33 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/instance-settings.d.ts +11 -0
- package/dist/services/instance-settings.d.ts.map +1 -0
- package/dist/services/instance-settings.js +116 -0
- package/dist/services/instance-settings.js.map +1 -0
- package/dist/services/issue-approvals.d.ts +56 -0
- package/dist/services/issue-approvals.d.ts.map +1 -0
- package/dist/services/issue-approvals.js +153 -0
- package/dist/services/issue-approvals.js.map +1 -0
- package/dist/services/issue-assignment-wakeup.d.ts +29 -0
- package/dist/services/issue-assignment-wakeup.d.ts.map +1 -0
- package/dist/services/issue-assignment-wakeup.js +22 -0
- package/dist/services/issue-assignment-wakeup.js.map +1 -0
- package/dist/services/issue-goal-fallback.d.ts +18 -0
- package/dist/services/issue-goal-fallback.d.ts.map +1 -0
- package/dist/services/issue-goal-fallback.js +33 -0
- package/dist/services/issue-goal-fallback.js.map +1 -0
- package/dist/services/issues.d.ts +560 -0
- package/dist/services/issues.d.ts.map +1 -0
- package/dist/services/issues.js +1478 -0
- package/dist/services/issues.js.map +1 -0
- package/dist/services/live-events.d.ts +17 -0
- package/dist/services/live-events.d.ts.map +1 -0
- package/dist/services/live-events.js +33 -0
- package/dist/services/live-events.js.map +1 -0
- package/dist/services/plugin-capability-validator.d.ts +108 -0
- package/dist/services/plugin-capability-validator.d.ts.map +1 -0
- package/dist/services/plugin-capability-validator.js +268 -0
- package/dist/services/plugin-capability-validator.js.map +1 -0
- package/dist/services/plugin-config-validator.d.ts +26 -0
- package/dist/services/plugin-config-validator.d.ts.map +1 -0
- package/dist/services/plugin-config-validator.js +41 -0
- package/dist/services/plugin-config-validator.js.map +1 -0
- package/dist/services/plugin-dev-watcher.d.ts +30 -0
- package/dist/services/plugin-dev-watcher.d.ts.map +1 -0
- package/dist/services/plugin-dev-watcher.js +241 -0
- package/dist/services/plugin-dev-watcher.js.map +1 -0
- package/dist/services/plugin-event-bus.d.ts +149 -0
- package/dist/services/plugin-event-bus.d.ts.map +1 -0
- package/dist/services/plugin-event-bus.js +258 -0
- package/dist/services/plugin-event-bus.js.map +1 -0
- package/dist/services/plugin-host-service-cleanup.d.ts +14 -0
- package/dist/services/plugin-host-service-cleanup.d.ts.map +1 -0
- package/dist/services/plugin-host-service-cleanup.js +37 -0
- package/dist/services/plugin-host-service-cleanup.js.map +1 -0
- package/dist/services/plugin-host-services.d.ts +13 -0
- package/dist/services/plugin-host-services.d.ts.map +1 -0
- package/dist/services/plugin-host-services.js +969 -0
- package/dist/services/plugin-host-services.js.map +1 -0
- package/dist/services/plugin-job-coordinator.d.ts +81 -0
- package/dist/services/plugin-job-coordinator.d.ts.map +1 -0
- package/dist/services/plugin-job-coordinator.js +172 -0
- package/dist/services/plugin-job-coordinator.js.map +1 -0
- package/dist/services/plugin-job-scheduler.d.ts +163 -0
- package/dist/services/plugin-job-scheduler.d.ts.map +1 -0
- package/dist/services/plugin-job-scheduler.js +454 -0
- package/dist/services/plugin-job-scheduler.js.map +1 -0
- package/dist/services/plugin-job-store.d.ts +208 -0
- package/dist/services/plugin-job-store.d.ts.map +1 -0
- package/dist/services/plugin-job-store.js +350 -0
- package/dist/services/plugin-job-store.js.map +1 -0
- package/dist/services/plugin-lifecycle.d.ts +203 -0
- package/dist/services/plugin-lifecycle.d.ts.map +1 -0
- package/dist/services/plugin-lifecycle.js +476 -0
- package/dist/services/plugin-lifecycle.js.map +1 -0
- package/dist/services/plugin-loader.d.ts +441 -0
- package/dist/services/plugin-loader.d.ts.map +1 -0
- package/dist/services/plugin-loader.js +1192 -0
- package/dist/services/plugin-loader.js.map +1 -0
- package/dist/services/plugin-log-retention.d.ts +20 -0
- package/dist/services/plugin-log-retention.d.ts.map +1 -0
- package/dist/services/plugin-log-retention.js +63 -0
- package/dist/services/plugin-log-retention.js.map +1 -0
- package/dist/services/plugin-manifest-validator.d.ts +79 -0
- package/dist/services/plugin-manifest-validator.d.ts.map +1 -0
- package/dist/services/plugin-manifest-validator.js +84 -0
- package/dist/services/plugin-manifest-validator.js.map +1 -0
- package/dist/services/plugin-registry.d.ts +2542 -0
- package/dist/services/plugin-registry.d.ts.map +1 -0
- package/dist/services/plugin-registry.js +539 -0
- package/dist/services/plugin-registry.js.map +1 -0
- package/dist/services/plugin-runtime-sandbox.d.ts +40 -0
- package/dist/services/plugin-runtime-sandbox.d.ts.map +1 -0
- package/dist/services/plugin-runtime-sandbox.js +154 -0
- package/dist/services/plugin-runtime-sandbox.js.map +1 -0
- package/dist/services/plugin-secrets-handler.d.ts +81 -0
- package/dist/services/plugin-secrets-handler.d.ts.map +1 -0
- package/dist/services/plugin-secrets-handler.js +275 -0
- package/dist/services/plugin-secrets-handler.js.map +1 -0
- package/dist/services/plugin-state-store.d.ts +92 -0
- package/dist/services/plugin-state-store.d.ts.map +1 -0
- package/dist/services/plugin-state-store.js +190 -0
- package/dist/services/plugin-state-store.js.map +1 -0
- package/dist/services/plugin-stream-bus.d.ts +29 -0
- package/dist/services/plugin-stream-bus.d.ts.map +1 -0
- package/dist/services/plugin-stream-bus.js +48 -0
- package/dist/services/plugin-stream-bus.js.map +1 -0
- package/dist/services/plugin-tool-dispatcher.d.ts +180 -0
- package/dist/services/plugin-tool-dispatcher.d.ts.map +1 -0
- package/dist/services/plugin-tool-dispatcher.js +224 -0
- package/dist/services/plugin-tool-dispatcher.js.map +1 -0
- package/dist/services/plugin-tool-registry.d.ts +192 -0
- package/dist/services/plugin-tool-registry.d.ts.map +1 -0
- package/dist/services/plugin-tool-registry.js +224 -0
- package/dist/services/plugin-tool-registry.js.map +1 -0
- package/dist/services/plugin-worker-manager.d.ts +260 -0
- package/dist/services/plugin-worker-manager.d.ts.map +1 -0
- package/dist/services/plugin-worker-manager.js +835 -0
- package/dist/services/plugin-worker-manager.js.map +1 -0
- package/dist/services/projects.d.ts +87 -0
- package/dist/services/projects.d.ts.map +1 -0
- package/dist/services/projects.js +656 -0
- package/dist/services/projects.js.map +1 -0
- package/dist/services/quota-windows.d.ts +9 -0
- package/dist/services/quota-windows.d.ts.map +1 -0
- package/dist/services/quota-windows.js +56 -0
- package/dist/services/quota-windows.js.map +1 -0
- package/dist/services/routines.d.ts +135 -0
- package/dist/services/routines.d.ts.map +1 -0
- package/dist/services/routines.js +1105 -0
- package/dist/services/routines.js.map +1 -0
- package/dist/services/run-log-store.d.ts +34 -0
- package/dist/services/run-log-store.d.ts.map +1 -0
- package/dist/services/run-log-store.js +109 -0
- package/dist/services/run-log-store.js.map +1 -0
- package/dist/services/secrets.d.ts +511 -0
- package/dist/services/secrets.d.ts.map +1 -0
- package/dist/services/secrets.js +289 -0
- package/dist/services/secrets.js.map +1 -0
- package/dist/services/sidebar-badges.d.ts +9 -0
- package/dist/services/sidebar-badges.d.ts.map +1 -0
- package/dist/services/sidebar-badges.js +33 -0
- package/dist/services/sidebar-badges.js.map +1 -0
- package/dist/services/work-products.d.ts +14 -0
- package/dist/services/work-products.d.ts.map +1 -0
- package/dist/services/work-products.js +100 -0
- package/dist/services/work-products.js.map +1 -0
- package/dist/services/workspace-operation-log-store.d.ts +33 -0
- package/dist/services/workspace-operation-log-store.d.ts.map +1 -0
- package/dist/services/workspace-operation-log-store.js +110 -0
- package/dist/services/workspace-operation-log-store.js.map +1 -0
- package/dist/services/workspace-operations.d.ts +44 -0
- package/dist/services/workspace-operations.d.ts.map +1 -0
- package/dist/services/workspace-operations.js +211 -0
- package/dist/services/workspace-operations.js.map +1 -0
- package/dist/services/workspace-runtime.d.ts +164 -0
- package/dist/services/workspace-runtime.d.ts.map +1 -0
- package/dist/services/workspace-runtime.js +1235 -0
- package/dist/services/workspace-runtime.js.map +1 -0
- package/dist/startup-banner.d.ts +31 -0
- package/dist/startup-banner.d.ts.map +1 -0
- package/dist/startup-banner.js +117 -0
- package/dist/startup-banner.js.map +1 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +29 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/local-disk-provider.d.ts +3 -0
- package/dist/storage/local-disk-provider.d.ts.map +1 -0
- package/dist/storage/local-disk-provider.js +79 -0
- package/dist/storage/local-disk-provider.js.map +1 -0
- package/dist/storage/provider-registry.d.ts +4 -0
- package/dist/storage/provider-registry.d.ts.map +1 -0
- package/dist/storage/provider-registry.js +15 -0
- package/dist/storage/provider-registry.js.map +1 -0
- package/dist/storage/s3-provider.d.ts +11 -0
- package/dist/storage/s3-provider.d.ts.map +1 -0
- package/dist/storage/s3-provider.js +123 -0
- package/dist/storage/s3-provider.js.map +1 -0
- package/dist/storage/service.d.ts +3 -0
- package/dist/storage/service.d.ts.map +1 -0
- package/dist/storage/service.js +120 -0
- package/dist/storage/service.js.map +1 -0
- package/dist/storage/types.d.ts +55 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +2 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/ui-branding.d.ts +13 -0
- package/dist/ui-branding.d.ts.map +1 -0
- package/dist/ui-branding.js +187 -0
- package/dist/ui-branding.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/worktree-config.d.ts +19 -0
- package/dist/worktree-config.d.ts.map +1 -0
- package/dist/worktree-config.js +365 -0
- package/dist/worktree-config.js.map +1 -0
- package/package.json +95 -0
- package/ui-dist/android-chrome-192x192.png +0 -0
- package/ui-dist/android-chrome-512x512.png +0 -0
- package/ui-dist/apple-touch-icon.png +0 -0
- package/ui-dist/assets/_basePickBy-BB1S19s0.js +1 -0
- package/ui-dist/assets/_baseUniq-BNk0p-bq.js +1 -0
- package/ui-dist/assets/apl-B4CMkyY2.js +1 -0
- package/ui-dist/assets/arc-Ds13x1NW.js +1 -0
- package/ui-dist/assets/architectureDiagram-VXUJARFQ-D8Br-_jt.js +36 -0
- package/ui-dist/assets/asciiarmor-Df11BRmG.js +1 -0
- package/ui-dist/assets/asn1-EdZsLKOL.js +1 -0
- package/ui-dist/assets/asterisk-B-8jnY81.js +1 -0
- package/ui-dist/assets/blockDiagram-VD42YOAC-CCYsAhQ5.js +122 -0
- package/ui-dist/assets/brainfuck-C4LP7Hcl.js +1 -0
- package/ui-dist/assets/c4Diagram-YG6GDRKO-CsrnTJYB.js +10 -0
- package/ui-dist/assets/channel-Df4ReTUQ.js +1 -0
- package/ui-dist/assets/chunk-4BX2VUAB-s-S3bm2a.js +1 -0
- package/ui-dist/assets/chunk-55IACEB6-AlPeSG3C.js +1 -0
- package/ui-dist/assets/chunk-B4BG7PRW-Dlv3zmp0.js +165 -0
- package/ui-dist/assets/chunk-DI55MBZ5-y3Hfc2F6.js +220 -0
- package/ui-dist/assets/chunk-FMBD7UC4-ZbmFZ8uD.js +15 -0
- package/ui-dist/assets/chunk-QN33PNHL-g7XrAaL5.js +1 -0
- package/ui-dist/assets/chunk-QZHKN3VN-DQz2X_ZR.js +1 -0
- package/ui-dist/assets/chunk-TZMSLE5B-NRbDhryd.js +1 -0
- package/ui-dist/assets/classDiagram-2ON5EDUG-CdLb01dH.js +1 -0
- package/ui-dist/assets/classDiagram-v2-WZHVMYZB-CdLb01dH.js +1 -0
- package/ui-dist/assets/clike-B9uivgTg.js +1 -0
- package/ui-dist/assets/clojure-BMjYHr_A.js +1 -0
- package/ui-dist/assets/clone-ycTwxHSX.js +1 -0
- package/ui-dist/assets/cmake-BQqOBYOt.js +1 -0
- package/ui-dist/assets/cobol-CWcv1MsR.js +1 -0
- package/ui-dist/assets/coffeescript-S37ZYGWr.js +1 -0
- package/ui-dist/assets/commonlisp-DBKNyK5s.js +1 -0
- package/ui-dist/assets/cose-bilkent-S5V4N54A-CifA3UGC.js +1 -0
- package/ui-dist/assets/crystal-SjHAIU92.js +1 -0
- package/ui-dist/assets/css-BnMrqG3P.js +1 -0
- package/ui-dist/assets/cypher-C_CwsFkJ.js +1 -0
- package/ui-dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/ui-dist/assets/d-pRatUO7H.js +1 -0
- package/ui-dist/assets/dagre-6UL2VRFP-Cy4_402x.js +4 -0
- package/ui-dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/ui-dist/assets/diagram-PSM6KHXK-CUA-Vqxe.js +24 -0
- package/ui-dist/assets/diagram-QEK2KX5R-D763Ackt.js +43 -0
- package/ui-dist/assets/diagram-S2PKOQOG-Cu1xEKHt.js +24 -0
- package/ui-dist/assets/diff-DbItnlRl.js +1 -0
- package/ui-dist/assets/dockerfile-BKs6k2Af.js +1 -0
- package/ui-dist/assets/dtd-DF_7sFjM.js +1 -0
- package/ui-dist/assets/dylan-DwRh75JA.js +1 -0
- package/ui-dist/assets/ebnf-CDyGwa7X.js +1 -0
- package/ui-dist/assets/ecl-Cabwm37j.js +1 -0
- package/ui-dist/assets/eiffel-CnydiIhH.js +1 -0
- package/ui-dist/assets/elm-vLlmbW-K.js +1 -0
- package/ui-dist/assets/erDiagram-Q2GNP2WA-9RlN9oCi.js +60 -0
- package/ui-dist/assets/erlang-BNw1qcRV.js +1 -0
- package/ui-dist/assets/factor-kuTfRLto.js +1 -0
- package/ui-dist/assets/fcl-Kvtd6kyn.js +1 -0
- package/ui-dist/assets/flowDiagram-NV44I4VS-Ddv1tq-H.js +162 -0
- package/ui-dist/assets/forth-Ffai-XNe.js +1 -0
- package/ui-dist/assets/fortran-DYz_wnZ1.js +1 -0
- package/ui-dist/assets/ganttDiagram-JELNMOA3-DAw7UfVT.js +267 -0
- package/ui-dist/assets/gas-Bneqetm1.js +1 -0
- package/ui-dist/assets/gherkin-heZmZLOM.js +1 -0
- package/ui-dist/assets/gitGraphDiagram-V2S2FVAM-CLPkzwpF.js +65 -0
- package/ui-dist/assets/graph-B1ThnnK5.js +1 -0
- package/ui-dist/assets/groovy-D9Dt4D0W.js +1 -0
- package/ui-dist/assets/haskell-Cw1EW3IL.js +1 -0
- package/ui-dist/assets/haxe-H-WmDvRZ.js +1 -0
- package/ui-dist/assets/http-DBlCnlav.js +1 -0
- package/ui-dist/assets/idl-BEugSyMb.js +1 -0
- package/ui-dist/assets/index-0DYmQxT3.js +2 -0
- package/ui-dist/assets/index-1BRIjwwa.js +1 -0
- package/ui-dist/assets/index-4pxn9bje.js +1 -0
- package/ui-dist/assets/index-B02pjBpR.js +7 -0
- package/ui-dist/assets/index-BGjMkZzC.js +1 -0
- package/ui-dist/assets/index-BHsjaYJ1.js +1 -0
- package/ui-dist/assets/index-BTwpjL-6.js +1 -0
- package/ui-dist/assets/index-BZ72uG4K.js +6 -0
- package/ui-dist/assets/index-BpC8VHcj.js +3 -0
- package/ui-dist/assets/index-BrvXvCkd.js +1 -0
- package/ui-dist/assets/index-CEBcI-2f.js +1 -0
- package/ui-dist/assets/index-CkmjCahV.js +1 -0
- package/ui-dist/assets/index-Cp84QmJD.css +1 -0
- package/ui-dist/assets/index-CpVjtxma.js +1 -0
- package/ui-dist/assets/index-D3AJPUjv.js +1 -0
- package/ui-dist/assets/index-DRkeP4vs.js +13 -0
- package/ui-dist/assets/index-DXeNhnre.js +1180 -0
- package/ui-dist/assets/index-DXvXmooU.js +1 -0
- package/ui-dist/assets/index-DZdwValG.js +1 -0
- package/ui-dist/assets/index-DbWj5-qO.js +1 -0
- package/ui-dist/assets/index-DbcKBTbp.js +1 -0
- package/ui-dist/assets/index-DdAQdjTR.js +1 -0
- package/ui-dist/assets/index-DlImcHKo.js +1 -0
- package/ui-dist/assets/index-X9LdJDbl.js +1 -0
- package/ui-dist/assets/infoDiagram-HS3SLOUP-CbJm6kuq.js +2 -0
- package/ui-dist/assets/init-Gi6I4Gst.js +1 -0
- package/ui-dist/assets/javascript-iXu5QeM3.js +1 -0
- package/ui-dist/assets/journeyDiagram-XKPGCS4Q-CeNVFpGu.js +139 -0
- package/ui-dist/assets/julia-DuME0IfC.js +1 -0
- package/ui-dist/assets/kanban-definition-3W4ZIXB7-DRqPoDRI.js +89 -0
- package/ui-dist/assets/katex-O9d3_IXG.js +261 -0
- package/ui-dist/assets/layout-CZTKj8OD.js +1 -0
- package/ui-dist/assets/linear-BDJjeIco.js +1 -0
- package/ui-dist/assets/livescript-BwQOo05w.js +1 -0
- package/ui-dist/assets/lua-BgMRiT3U.js +1 -0
- package/ui-dist/assets/mathematica-DTrFuWx2.js +1 -0
- package/ui-dist/assets/mbox-CNhZ1qSd.js +1 -0
- package/ui-dist/assets/mermaid.core-B5v7dPHY.js +256 -0
- package/ui-dist/assets/mindmap-definition-VGOIOE7T-zjw0AyzL.js +68 -0
- package/ui-dist/assets/mirc-CjQqDB4T.js +1 -0
- package/ui-dist/assets/mllike-CXdrOF99.js +1 -0
- package/ui-dist/assets/modelica-Dc1JOy9r.js +1 -0
- package/ui-dist/assets/mscgen-BA5vi2Kp.js +1 -0
- package/ui-dist/assets/mumps-BT43cFF4.js +1 -0
- package/ui-dist/assets/nginx-DdIZxoE0.js +1 -0
- package/ui-dist/assets/nsis-LdVXkNf5.js +1 -0
- package/ui-dist/assets/ntriples-BfvgReVJ.js +1 -0
- package/ui-dist/assets/octave-Ck1zUtKM.js +1 -0
- package/ui-dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/ui-dist/assets/oz-BzwKVEFT.js +1 -0
- package/ui-dist/assets/pascal--L3eBynH.js +1 -0
- package/ui-dist/assets/perl-CdXCOZ3F.js +1 -0
- package/ui-dist/assets/pieDiagram-ADFJNKIX-ojNQ8Ukr.js +30 -0
- package/ui-dist/assets/pig-CevX1Tat.js +1 -0
- package/ui-dist/assets/powershell-CFHJl5sT.js +1 -0
- package/ui-dist/assets/properties-C78fOPTZ.js +1 -0
- package/ui-dist/assets/protobuf-ChK-085T.js +1 -0
- package/ui-dist/assets/pug-DeIclll2.js +1 -0
- package/ui-dist/assets/puppet-DMA9R1ak.js +1 -0
- package/ui-dist/assets/python-BuPzkPfP.js +1 -0
- package/ui-dist/assets/q-pXgVlZs6.js +1 -0
- package/ui-dist/assets/quadrantDiagram-AYHSOK5B-B8K2F86x.js +7 -0
- package/ui-dist/assets/r-B6wPVr8A.js +1 -0
- package/ui-dist/assets/requirementDiagram-UZGBJVZJ-DA_Bjcpk.js +64 -0
- package/ui-dist/assets/rpm-CTu-6PCP.js +1 -0
- package/ui-dist/assets/ruby-B2Rjki9n.js +1 -0
- package/ui-dist/assets/sankeyDiagram-TZEHDZUN-yQfMgroQ.js +10 -0
- package/ui-dist/assets/sas-B4kiWyti.js +1 -0
- package/ui-dist/assets/scheme-C41bIUwD.js +1 -0
- package/ui-dist/assets/sequenceDiagram-WL72ISMW-CWQm0UQc.js +145 -0
- package/ui-dist/assets/shell-CjFT_Tl9.js +1 -0
- package/ui-dist/assets/sieve-C3Gn_uJK.js +1 -0
- package/ui-dist/assets/simple-mode-GW_nhZxv.js +1 -0
- package/ui-dist/assets/smalltalk-CnHTOXQT.js +1 -0
- package/ui-dist/assets/solr-DehyRSwq.js +1 -0
- package/ui-dist/assets/sparql-DkYu6x3z.js +1 -0
- package/ui-dist/assets/spreadsheet-BCZA_wO0.js +1 -0
- package/ui-dist/assets/sql-D0XecflT.js +1 -0
- package/ui-dist/assets/stateDiagram-FKZM4ZOC-C9L_ELvE.js +1 -0
- package/ui-dist/assets/stateDiagram-v2-4FDKWEC3-D3i22gRM.js +1 -0
- package/ui-dist/assets/stex-C3f8Ysf7.js +1 -0
- package/ui-dist/assets/stylus-B533Al4x.js +1 -0
- package/ui-dist/assets/swift-BzpIVaGY.js +1 -0
- package/ui-dist/assets/tcl-DVfN8rqt.js +1 -0
- package/ui-dist/assets/textile-CnDTJFAw.js +1 -0
- package/ui-dist/assets/tiddlywiki-DO-Gjzrf.js +1 -0
- package/ui-dist/assets/tiki-DGYXhP31.js +1 -0
- package/ui-dist/assets/timeline-definition-IT6M3QCI-Bfva-2zq.js +61 -0
- package/ui-dist/assets/toml-Bm5Em-hy.js +1 -0
- package/ui-dist/assets/treemap-GDKQZRPO-6wTQWQt4.js +162 -0
- package/ui-dist/assets/troff-wAsdV37c.js +1 -0
- package/ui-dist/assets/ttcn-CfJYG6tj.js +1 -0
- package/ui-dist/assets/ttcn-cfg-B9xdYoR4.js +1 -0
- package/ui-dist/assets/turtle-B1tBg_DP.js +1 -0
- package/ui-dist/assets/vb-CmGdzxic.js +1 -0
- package/ui-dist/assets/vbscript-BuJXcnF6.js +1 -0
- package/ui-dist/assets/velocity-D8B20fx6.js +1 -0
- package/ui-dist/assets/verilog-C6RDOZhf.js +1 -0
- package/ui-dist/assets/vhdl-lSbBsy5d.js +1 -0
- package/ui-dist/assets/webidl-ZXfAyPTL.js +1 -0
- package/ui-dist/assets/xquery-DzFWVndE.js +1 -0
- package/ui-dist/assets/xychartDiagram-PRI3JC2R-DNsmIw3v.js +7 -0
- package/ui-dist/assets/yacas-BJ4BC0dw.js +1 -0
- package/ui-dist/assets/z80-Hz9HOZM7.js +1 -0
- package/ui-dist/brands/opencode-logo-dark-square.svg +18 -0
- package/ui-dist/brands/opencode-logo-light-square.svg +18 -0
- package/ui-dist/favicon-16x16.png +0 -0
- package/ui-dist/favicon-32x32.png +0 -0
- package/ui-dist/favicon.ico +0 -0
- package/ui-dist/favicon.svg +9 -0
- package/ui-dist/index.html +48 -0
- package/ui-dist/site.webmanifest +30 -0
- package/ui-dist/sw.js +42 -0
- package/ui-dist/worktree-favicon-16x16.png +0 -0
- package/ui-dist/worktree-favicon-32x32.png +0 -0
- package/ui-dist/worktree-favicon.ico +0 -0
- package/ui-dist/worktree-favicon.svg +9 -0
|
@@ -0,0 +1,1784 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Plugin management REST API routes
|
|
3
|
+
*
|
|
4
|
+
* This module provides Express routes for managing the complete plugin lifecycle:
|
|
5
|
+
* - Listing and filtering plugins by status
|
|
6
|
+
* - Installing plugins from npm or local paths
|
|
7
|
+
* - Uninstalling plugins (soft delete or hard purge)
|
|
8
|
+
* - Enabling/disabling plugins
|
|
9
|
+
* - Running health diagnostics
|
|
10
|
+
* - Upgrading plugins
|
|
11
|
+
* - Retrieving UI slot contributions for frontend rendering
|
|
12
|
+
* - Discovering and executing plugin-contributed agent tools
|
|
13
|
+
*
|
|
14
|
+
* All routes require board-level authentication (assertBoard middleware).
|
|
15
|
+
*
|
|
16
|
+
* @module server/routes/plugins
|
|
17
|
+
* @see doc/plugins/PLUGIN_SPEC.md for the full plugin specification
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync } from "node:fs";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { randomUUID } from "node:crypto";
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { Router } from "express";
|
|
24
|
+
import { and, desc, eq, gte } from "drizzle-orm";
|
|
25
|
+
import { companies, pluginLogs, pluginWebhookDeliveries } from "@fidelios/db";
|
|
26
|
+
import { PLUGIN_STATUSES, } from "@fidelios/shared";
|
|
27
|
+
import { pluginRegistryService } from "../services/plugin-registry.js";
|
|
28
|
+
import { pluginLifecycleManager } from "../services/plugin-lifecycle.js";
|
|
29
|
+
import { getPluginUiContributionMetadata } from "../services/plugin-loader.js";
|
|
30
|
+
import { logActivity } from "../services/activity-log.js";
|
|
31
|
+
import { publishGlobalLiveEvent } from "../services/live-events.js";
|
|
32
|
+
import { JsonRpcCallError, PLUGIN_RPC_ERROR_CODES } from "@fidelios/plugin-sdk";
|
|
33
|
+
import { assertBoard, assertCompanyAccess, getActorInfo } from "./authz.js";
|
|
34
|
+
import { validateInstanceConfig } from "../services/plugin-config-validator.js";
|
|
35
|
+
/** UUID v4 regex used for plugin ID route resolution. */
|
|
36
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
37
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
38
|
+
const REPO_ROOT = path.resolve(__dirname, "../../..");
|
|
39
|
+
const BUNDLED_PLUGIN_EXAMPLES = [
|
|
40
|
+
{
|
|
41
|
+
packageName: "@fidelios/plugin-hello-world-example",
|
|
42
|
+
pluginKey: "fidelios.hello-world-example",
|
|
43
|
+
displayName: "Hello World Widget (Example)",
|
|
44
|
+
description: "Reference UI plugin that adds a simple Hello World widget to the FideliOS dashboard.",
|
|
45
|
+
localPath: "packages/plugins/examples/plugin-hello-world-example",
|
|
46
|
+
tag: "example",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
packageName: "@fidelios/plugin-file-browser-example",
|
|
50
|
+
pluginKey: "fidelios-file-browser-example",
|
|
51
|
+
displayName: "File Browser (Example)",
|
|
52
|
+
description: "Example plugin that adds a Files link in project navigation plus a project detail file browser.",
|
|
53
|
+
localPath: "packages/plugins/examples/plugin-file-browser-example",
|
|
54
|
+
tag: "example",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
packageName: "@fidelios/plugin-kitchen-sink-example",
|
|
58
|
+
pluginKey: "fidelios-kitchen-sink-example",
|
|
59
|
+
displayName: "Kitchen Sink (Example)",
|
|
60
|
+
description: "Reference plugin that demonstrates the current FideliOS plugin API surface, bridge flows, UI extension surfaces, jobs, webhooks, tools, streams, and trusted local workspace/process demos.",
|
|
61
|
+
localPath: "packages/plugins/examples/plugin-kitchen-sink-example",
|
|
62
|
+
tag: "example",
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
function listBundledPluginExamples() {
|
|
66
|
+
return BUNDLED_PLUGIN_EXAMPLES.flatMap((plugin) => {
|
|
67
|
+
const absoluteLocalPath = path.resolve(REPO_ROOT, plugin.localPath);
|
|
68
|
+
if (!existsSync(absoluteLocalPath))
|
|
69
|
+
return [];
|
|
70
|
+
return [{ ...plugin, localPath: absoluteLocalPath }];
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Resolve a plugin by either database ID or plugin key.
|
|
75
|
+
*
|
|
76
|
+
* Lookup order:
|
|
77
|
+
* - UUID-like IDs: getById first, then getByKey.
|
|
78
|
+
* - Scoped package keys (e.g. "@scope/name"): getByKey only, never getById.
|
|
79
|
+
* - Other non-UUID IDs: try getById first (test/memory registries may allow this),
|
|
80
|
+
* then fallback to getByKey. Any UUID parse error from getById is ignored.
|
|
81
|
+
*
|
|
82
|
+
* @param registry - The plugin registry service instance
|
|
83
|
+
* @param pluginId - Either a database UUID or plugin key (manifest id)
|
|
84
|
+
* @returns Plugin record or null if not found
|
|
85
|
+
*/
|
|
86
|
+
async function resolvePlugin(registry, pluginId) {
|
|
87
|
+
const isUuid = UUID_REGEX.test(pluginId);
|
|
88
|
+
const isScopedPackageKey = pluginId.startsWith("@") || pluginId.includes("/");
|
|
89
|
+
// Scoped package IDs are valid plugin keys but invalid UUIDs.
|
|
90
|
+
// Skip getById() entirely to avoid Postgres uuid parse errors.
|
|
91
|
+
if (isScopedPackageKey && !isUuid) {
|
|
92
|
+
return registry.getByKey(pluginId);
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const byId = await registry.getById(pluginId);
|
|
96
|
+
if (byId)
|
|
97
|
+
return byId;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const maybeCode = typeof error === "object" && error !== null && "code" in error
|
|
101
|
+
? error.code
|
|
102
|
+
: undefined;
|
|
103
|
+
// Ignore invalid UUID cast errors and continue with key lookup.
|
|
104
|
+
if (maybeCode !== "22P02") {
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return registry.getByKey(pluginId);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create Express router for plugin management API.
|
|
112
|
+
*
|
|
113
|
+
* Routes provided:
|
|
114
|
+
*
|
|
115
|
+
* | Method | Path | Description |
|
|
116
|
+
* |--------|------|-------------|
|
|
117
|
+
* | GET | /plugins | List all plugins (optional ?status= filter) |
|
|
118
|
+
* | GET | /plugins/ui-contributions | Get UI slots from ready plugins |
|
|
119
|
+
* | GET | /plugins/:pluginId | Get single plugin by ID or key |
|
|
120
|
+
* | POST | /plugins/install | Install from npm or local path |
|
|
121
|
+
* | DELETE | /plugins/:pluginId | Uninstall (optional ?purge=true) |
|
|
122
|
+
* | POST | /plugins/:pluginId/enable | Enable a plugin |
|
|
123
|
+
* | POST | /plugins/:pluginId/disable | Disable a plugin |
|
|
124
|
+
* | GET | /plugins/:pluginId/health | Run health diagnostics |
|
|
125
|
+
* | POST | /plugins/:pluginId/upgrade | Upgrade to newer version |
|
|
126
|
+
* | GET | /plugins/:pluginId/jobs | List jobs for a plugin |
|
|
127
|
+
* | GET | /plugins/:pluginId/jobs/:jobId/runs | List runs for a job |
|
|
128
|
+
* | POST | /plugins/:pluginId/jobs/:jobId/trigger | Manually trigger a job |
|
|
129
|
+
* | POST | /plugins/:pluginId/webhooks/:endpointKey | Receive inbound webhook |
|
|
130
|
+
* | GET | /plugins/tools | List all available plugin tools |
|
|
131
|
+
* | GET | /plugins/tools?pluginId=... | List tools for a specific plugin |
|
|
132
|
+
* | POST | /plugins/tools/execute | Execute a plugin tool |
|
|
133
|
+
* | GET | /plugins/:pluginId/config | Get current plugin config |
|
|
134
|
+
* | POST | /plugins/:pluginId/config | Save (upsert) plugin config |
|
|
135
|
+
* | POST | /plugins/:pluginId/config/test | Test config via validateConfig RPC |
|
|
136
|
+
* | POST | /plugins/:pluginId/bridge/data | Proxy getData to plugin worker |
|
|
137
|
+
* | POST | /plugins/:pluginId/bridge/action | Proxy performAction to plugin worker |
|
|
138
|
+
* | POST | /plugins/:pluginId/data/:key | Proxy getData to plugin worker (key in URL) |
|
|
139
|
+
* | POST | /plugins/:pluginId/actions/:key | Proxy performAction to plugin worker (key in URL) |
|
|
140
|
+
* | GET | /plugins/:pluginId/bridge/stream/:channel | SSE stream from worker to UI |
|
|
141
|
+
* | GET | /plugins/:pluginId/dashboard | Aggregated health dashboard data |
|
|
142
|
+
*
|
|
143
|
+
* **Route Ordering Note:** Static routes (like /ui-contributions, /tools) must be
|
|
144
|
+
* registered before parameterized routes (like /:pluginId) to prevent Express from
|
|
145
|
+
* matching them as a plugin ID.
|
|
146
|
+
*
|
|
147
|
+
* @param db - Database connection instance
|
|
148
|
+
* @param jobDeps - Optional job scheduling dependencies
|
|
149
|
+
* @param webhookDeps - Optional webhook ingestion dependencies
|
|
150
|
+
* @param toolDeps - Optional tool dispatcher dependencies
|
|
151
|
+
* @param bridgeDeps - Optional bridge proxy dependencies for getData/performAction
|
|
152
|
+
* @returns Express router with plugin routes mounted
|
|
153
|
+
*/
|
|
154
|
+
export function pluginRoutes(db, loader, jobDeps, webhookDeps, toolDeps, bridgeDeps) {
|
|
155
|
+
const router = Router();
|
|
156
|
+
const registry = pluginRegistryService(db);
|
|
157
|
+
const lifecycle = pluginLifecycleManager(db, {
|
|
158
|
+
loader,
|
|
159
|
+
workerManager: bridgeDeps?.workerManager ?? webhookDeps?.workerManager,
|
|
160
|
+
});
|
|
161
|
+
async function resolvePluginAuditCompanyIds(req) {
|
|
162
|
+
if (typeof db.select === "function") {
|
|
163
|
+
const rows = await db
|
|
164
|
+
.select({ id: companies.id })
|
|
165
|
+
.from(companies);
|
|
166
|
+
return rows.map((row) => row.id);
|
|
167
|
+
}
|
|
168
|
+
if (req.actor.type === "agent" && req.actor.companyId) {
|
|
169
|
+
return [req.actor.companyId];
|
|
170
|
+
}
|
|
171
|
+
if (req.actor.type === "board") {
|
|
172
|
+
return req.actor.companyIds ?? [];
|
|
173
|
+
}
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
async function logPluginMutationActivity(req, action, entityId, details) {
|
|
177
|
+
const companyIds = await resolvePluginAuditCompanyIds(req);
|
|
178
|
+
if (companyIds.length === 0)
|
|
179
|
+
return;
|
|
180
|
+
const actor = getActorInfo(req);
|
|
181
|
+
await Promise.all(companyIds.map((companyId) => logActivity(db, {
|
|
182
|
+
companyId,
|
|
183
|
+
actorType: actor.actorType,
|
|
184
|
+
actorId: actor.actorId,
|
|
185
|
+
agentId: actor.agentId,
|
|
186
|
+
runId: actor.runId,
|
|
187
|
+
action,
|
|
188
|
+
entityType: "plugin",
|
|
189
|
+
entityId,
|
|
190
|
+
details,
|
|
191
|
+
})));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* GET /api/plugins
|
|
195
|
+
*
|
|
196
|
+
* List all installed plugins, optionally filtered by lifecycle status.
|
|
197
|
+
*
|
|
198
|
+
* Query params:
|
|
199
|
+
* - `status` (optional): Filter by lifecycle status. Must be one of the
|
|
200
|
+
* values in `PLUGIN_STATUSES` (`installed`, `ready`, `error`,
|
|
201
|
+
* `upgrade_pending`, `uninstalled`). Returns HTTP 400 if the value is
|
|
202
|
+
* not a recognised status string.
|
|
203
|
+
*
|
|
204
|
+
* Response: `PluginRecord[]`
|
|
205
|
+
*/
|
|
206
|
+
router.get("/plugins", async (req, res) => {
|
|
207
|
+
assertBoard(req);
|
|
208
|
+
const rawStatus = req.query.status;
|
|
209
|
+
if (rawStatus !== undefined) {
|
|
210
|
+
if (typeof rawStatus !== "string" || !PLUGIN_STATUSES.includes(rawStatus)) {
|
|
211
|
+
res.status(400).json({
|
|
212
|
+
error: `Invalid status '${String(rawStatus)}'. Must be one of: ${PLUGIN_STATUSES.join(", ")}`,
|
|
213
|
+
});
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const status = rawStatus;
|
|
218
|
+
const plugins = status
|
|
219
|
+
? await registry.listByStatus(status)
|
|
220
|
+
: await registry.listInstalled();
|
|
221
|
+
res.json(plugins);
|
|
222
|
+
});
|
|
223
|
+
/**
|
|
224
|
+
* GET /api/plugins/examples
|
|
225
|
+
*
|
|
226
|
+
* Return first-party example plugins bundled in this repo, if present.
|
|
227
|
+
* These can be installed through the normal local-path install flow.
|
|
228
|
+
*/
|
|
229
|
+
router.get("/plugins/examples", async (req, res) => {
|
|
230
|
+
assertBoard(req);
|
|
231
|
+
res.json(listBundledPluginExamples());
|
|
232
|
+
});
|
|
233
|
+
// IMPORTANT: Static routes must come before parameterized routes
|
|
234
|
+
// to avoid Express matching "ui-contributions" as a :pluginId
|
|
235
|
+
/**
|
|
236
|
+
* GET /api/plugins/ui-contributions
|
|
237
|
+
*
|
|
238
|
+
* Return UI contributions from all plugins in 'ready' state.
|
|
239
|
+
* Used by the frontend to discover plugin UI slots and launcher metadata.
|
|
240
|
+
*
|
|
241
|
+
* The response is normalized for the frontend slot host:
|
|
242
|
+
* - Only includes plugins with at least one declared UI slot or launcher
|
|
243
|
+
* - Excludes plugins with null/missing manifestJson (defensive)
|
|
244
|
+
* - Slots are extracted from manifest.ui.slots
|
|
245
|
+
* - Launchers are aggregated from legacy manifest.launchers and manifest.ui.launchers
|
|
246
|
+
*
|
|
247
|
+
* Example response:
|
|
248
|
+
* ```json
|
|
249
|
+
* [
|
|
250
|
+
* {
|
|
251
|
+
* "pluginId": "plg_123",
|
|
252
|
+
* "pluginKey": "fidelios.claude-usage",
|
|
253
|
+
* "displayName": "Claude Usage",
|
|
254
|
+
* "version": "1.0.0",
|
|
255
|
+
* "uiEntryFile": "index.js",
|
|
256
|
+
* "slots": [],
|
|
257
|
+
* "launchers": [
|
|
258
|
+
* {
|
|
259
|
+
* "id": "claude-usage-toolbar",
|
|
260
|
+
* "displayName": "Claude Usage",
|
|
261
|
+
* "placementZone": "toolbarButton",
|
|
262
|
+
* "action": { "type": "openModal", "target": "ClaudeUsageView" },
|
|
263
|
+
* "render": { "environment": "hostOverlay", "bounds": "wide" }
|
|
264
|
+
* }
|
|
265
|
+
* ]
|
|
266
|
+
* }
|
|
267
|
+
* ]
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* Response: PluginUiContribution[]
|
|
271
|
+
*/
|
|
272
|
+
router.get("/plugins/ui-contributions", async (req, res) => {
|
|
273
|
+
assertBoard(req);
|
|
274
|
+
const plugins = await registry.listByStatus("ready");
|
|
275
|
+
const contributions = plugins
|
|
276
|
+
.map((plugin) => {
|
|
277
|
+
// Safety check: manifestJson should always exist for ready plugins, but guard against null
|
|
278
|
+
const manifest = plugin.manifestJson;
|
|
279
|
+
if (!manifest)
|
|
280
|
+
return null;
|
|
281
|
+
const uiMetadata = getPluginUiContributionMetadata(manifest);
|
|
282
|
+
if (!uiMetadata)
|
|
283
|
+
return null;
|
|
284
|
+
return {
|
|
285
|
+
pluginId: plugin.id,
|
|
286
|
+
pluginKey: plugin.pluginKey,
|
|
287
|
+
displayName: manifest.displayName,
|
|
288
|
+
version: plugin.version,
|
|
289
|
+
updatedAt: plugin.updatedAt.toISOString(),
|
|
290
|
+
uiEntryFile: uiMetadata.uiEntryFile,
|
|
291
|
+
slots: uiMetadata.slots,
|
|
292
|
+
launchers: uiMetadata.launchers,
|
|
293
|
+
};
|
|
294
|
+
})
|
|
295
|
+
.filter((item) => item !== null);
|
|
296
|
+
res.json(contributions);
|
|
297
|
+
});
|
|
298
|
+
// ===========================================================================
|
|
299
|
+
// Tool discovery and execution routes
|
|
300
|
+
// ===========================================================================
|
|
301
|
+
/**
|
|
302
|
+
* GET /api/plugins/tools
|
|
303
|
+
*
|
|
304
|
+
* List all available plugin-contributed tools in an agent-friendly format.
|
|
305
|
+
*
|
|
306
|
+
* Query params:
|
|
307
|
+
* - `pluginId` (optional): Filter to tools from a specific plugin
|
|
308
|
+
*
|
|
309
|
+
* Response: `AgentToolDescriptor[]`
|
|
310
|
+
* Errors: 501 if tool dispatcher is not configured
|
|
311
|
+
*/
|
|
312
|
+
router.get("/plugins/tools", async (req, res) => {
|
|
313
|
+
assertBoard(req);
|
|
314
|
+
if (!toolDeps) {
|
|
315
|
+
res.status(501).json({ error: "Plugin tool dispatch is not enabled" });
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const pluginId = req.query.pluginId;
|
|
319
|
+
const filter = pluginId ? { pluginId } : undefined;
|
|
320
|
+
const tools = toolDeps.toolDispatcher.listToolsForAgent(filter);
|
|
321
|
+
res.json(tools);
|
|
322
|
+
});
|
|
323
|
+
/**
|
|
324
|
+
* POST /api/plugins/tools/execute
|
|
325
|
+
*
|
|
326
|
+
* Execute a plugin-contributed tool by its namespaced name.
|
|
327
|
+
*
|
|
328
|
+
* This is the primary endpoint used by the agent service to invoke
|
|
329
|
+
* plugin tools during an agent run.
|
|
330
|
+
*
|
|
331
|
+
* Request body:
|
|
332
|
+
* - `tool`: Fully namespaced tool name (e.g., "acme.linear:search-issues")
|
|
333
|
+
* - `parameters`: Parameters matching the tool's declared JSON Schema
|
|
334
|
+
* - `runContext`: Agent run context with agentId, runId, companyId, projectId
|
|
335
|
+
*
|
|
336
|
+
* Response: `ToolExecutionResult`
|
|
337
|
+
* Errors:
|
|
338
|
+
* - 400 if request validation fails
|
|
339
|
+
* - 404 if tool is not found
|
|
340
|
+
* - 501 if tool dispatcher is not configured
|
|
341
|
+
* - 502 if the plugin worker is unavailable or the RPC call fails
|
|
342
|
+
*/
|
|
343
|
+
router.post("/plugins/tools/execute", async (req, res) => {
|
|
344
|
+
assertBoard(req);
|
|
345
|
+
if (!toolDeps) {
|
|
346
|
+
res.status(501).json({ error: "Plugin tool dispatch is not enabled" });
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const body = req.body;
|
|
350
|
+
if (!body) {
|
|
351
|
+
res.status(400).json({ error: "Request body is required" });
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const { tool, parameters, runContext } = body;
|
|
355
|
+
// Validate required fields
|
|
356
|
+
if (!tool || typeof tool !== "string") {
|
|
357
|
+
res.status(400).json({ error: '"tool" is required and must be a string' });
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (!runContext || typeof runContext !== "object") {
|
|
361
|
+
res.status(400).json({ error: '"runContext" is required and must be an object' });
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (!runContext.agentId || !runContext.runId || !runContext.companyId || !runContext.projectId) {
|
|
365
|
+
res.status(400).json({
|
|
366
|
+
error: '"runContext" must include agentId, runId, companyId, and projectId',
|
|
367
|
+
});
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
assertCompanyAccess(req, runContext.companyId);
|
|
371
|
+
// Verify the tool exists
|
|
372
|
+
const registeredTool = toolDeps.toolDispatcher.getTool(tool);
|
|
373
|
+
if (!registeredTool) {
|
|
374
|
+
res.status(404).json({ error: `Tool "${tool}" not found` });
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
const result = await toolDeps.toolDispatcher.executeTool(tool, parameters ?? {}, runContext);
|
|
379
|
+
res.json(result);
|
|
380
|
+
}
|
|
381
|
+
catch (err) {
|
|
382
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
383
|
+
// Distinguish between "worker not running" (502) and other errors (500)
|
|
384
|
+
if (message.includes("not running") || message.includes("worker")) {
|
|
385
|
+
res.status(502).json({ error: message });
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
res.status(500).json({ error: message });
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
/**
|
|
393
|
+
* POST /api/plugins/install
|
|
394
|
+
*
|
|
395
|
+
* Install a plugin from npm or a local filesystem path.
|
|
396
|
+
*
|
|
397
|
+
* Request body:
|
|
398
|
+
* - packageName: npm package name or local path (required)
|
|
399
|
+
* - version: Target version for npm packages (optional)
|
|
400
|
+
* - isLocalPath: Set true if packageName is a local path
|
|
401
|
+
*
|
|
402
|
+
* The installer:
|
|
403
|
+
* 1. Downloads from npm or loads from local path
|
|
404
|
+
* 2. Validates the manifest (schema + capability consistency)
|
|
405
|
+
* 3. Registers in the database
|
|
406
|
+
* 4. Transitions to `ready` state if no new capability approval is needed
|
|
407
|
+
*
|
|
408
|
+
* Response: `PluginRecord`
|
|
409
|
+
*
|
|
410
|
+
* Errors:
|
|
411
|
+
* - `400` — validation failure or install error (package not found, bad manifest, etc.)
|
|
412
|
+
* - `500` — installation succeeded but manifest is missing (indicates a loader bug)
|
|
413
|
+
*/
|
|
414
|
+
router.post("/plugins/install", async (req, res) => {
|
|
415
|
+
assertBoard(req);
|
|
416
|
+
const { packageName, version, isLocalPath } = req.body;
|
|
417
|
+
// Input validation
|
|
418
|
+
if (!packageName || typeof packageName !== "string") {
|
|
419
|
+
res.status(400).json({ error: "packageName is required and must be a string" });
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (version !== undefined && typeof version !== "string") {
|
|
423
|
+
res.status(400).json({ error: "version must be a string if provided" });
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (isLocalPath !== undefined && typeof isLocalPath !== "boolean") {
|
|
427
|
+
res.status(400).json({ error: "isLocalPath must be a boolean if provided" });
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
// Validate package name format
|
|
431
|
+
const trimmedPackage = packageName.trim();
|
|
432
|
+
if (trimmedPackage.length === 0) {
|
|
433
|
+
res.status(400).json({ error: "packageName cannot be empty" });
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
// Basic security check for package name (prevent injection)
|
|
437
|
+
if (!isLocalPath && /[<>:"|?*]/.test(trimmedPackage)) {
|
|
438
|
+
res.status(400).json({ error: "packageName contains invalid characters" });
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
try {
|
|
442
|
+
const installOptions = isLocalPath
|
|
443
|
+
? { localPath: trimmedPackage }
|
|
444
|
+
: { packageName: trimmedPackage, version: version?.trim() };
|
|
445
|
+
const discovered = await loader.installPlugin(installOptions);
|
|
446
|
+
if (!discovered.manifest) {
|
|
447
|
+
res.status(500).json({ error: "Plugin installed but manifest is missing" });
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
// Transition to ready state
|
|
451
|
+
const existingPlugin = await registry.getByKey(discovered.manifest.id);
|
|
452
|
+
if (existingPlugin) {
|
|
453
|
+
await lifecycle.load(existingPlugin.id);
|
|
454
|
+
const updated = await registry.getById(existingPlugin.id);
|
|
455
|
+
await logPluginMutationActivity(req, "plugin.installed", existingPlugin.id, {
|
|
456
|
+
pluginId: existingPlugin.id,
|
|
457
|
+
pluginKey: existingPlugin.pluginKey,
|
|
458
|
+
packageName: updated?.packageName ?? existingPlugin.packageName,
|
|
459
|
+
version: updated?.version ?? existingPlugin.version,
|
|
460
|
+
source: isLocalPath ? "local_path" : "npm",
|
|
461
|
+
});
|
|
462
|
+
publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: existingPlugin.id, action: "installed" } });
|
|
463
|
+
res.json(updated);
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
// This shouldn't happen since installPlugin already registers in the DB
|
|
467
|
+
res.status(500).json({ error: "Plugin installed but not found in registry" });
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
catch (err) {
|
|
471
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
472
|
+
res.status(400).json({ error: message });
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
/**
|
|
476
|
+
* Map a worker RPC error to a bridge-level error code.
|
|
477
|
+
*
|
|
478
|
+
* JsonRpcCallError carries numeric codes from the plugin RPC error code space.
|
|
479
|
+
* This helper maps them to the string error codes defined in PluginBridgeErrorCode.
|
|
480
|
+
*
|
|
481
|
+
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
|
|
482
|
+
*/
|
|
483
|
+
function mapRpcErrorToBridgeError(err) {
|
|
484
|
+
if (err instanceof JsonRpcCallError) {
|
|
485
|
+
switch (err.code) {
|
|
486
|
+
case PLUGIN_RPC_ERROR_CODES.WORKER_UNAVAILABLE:
|
|
487
|
+
return {
|
|
488
|
+
code: "WORKER_UNAVAILABLE",
|
|
489
|
+
message: err.message,
|
|
490
|
+
details: err.data,
|
|
491
|
+
};
|
|
492
|
+
case PLUGIN_RPC_ERROR_CODES.CAPABILITY_DENIED:
|
|
493
|
+
return {
|
|
494
|
+
code: "CAPABILITY_DENIED",
|
|
495
|
+
message: err.message,
|
|
496
|
+
details: err.data,
|
|
497
|
+
};
|
|
498
|
+
case PLUGIN_RPC_ERROR_CODES.TIMEOUT:
|
|
499
|
+
return {
|
|
500
|
+
code: "TIMEOUT",
|
|
501
|
+
message: err.message,
|
|
502
|
+
details: err.data,
|
|
503
|
+
};
|
|
504
|
+
case PLUGIN_RPC_ERROR_CODES.WORKER_ERROR:
|
|
505
|
+
return {
|
|
506
|
+
code: "WORKER_ERROR",
|
|
507
|
+
message: err.message,
|
|
508
|
+
details: err.data,
|
|
509
|
+
};
|
|
510
|
+
default:
|
|
511
|
+
return {
|
|
512
|
+
code: "UNKNOWN",
|
|
513
|
+
message: err.message,
|
|
514
|
+
details: err.data,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
519
|
+
// Worker not running — surface as WORKER_UNAVAILABLE
|
|
520
|
+
if (message.includes("not running") || message.includes("not registered")) {
|
|
521
|
+
return {
|
|
522
|
+
code: "WORKER_UNAVAILABLE",
|
|
523
|
+
message,
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
code: "UNKNOWN",
|
|
528
|
+
message,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* POST /api/plugins/:pluginId/bridge/data
|
|
533
|
+
*
|
|
534
|
+
* Proxy a `getData` call from the plugin UI to the plugin worker.
|
|
535
|
+
*
|
|
536
|
+
* This is the server-side half of the `usePluginData(key, params)` bridge hook.
|
|
537
|
+
* The frontend sends a POST with the data key and optional params; the host
|
|
538
|
+
* forwards the call to the worker via the `getData` RPC method and returns
|
|
539
|
+
* the result.
|
|
540
|
+
*
|
|
541
|
+
* Request body:
|
|
542
|
+
* - `key`: Plugin-defined data key (e.g. `"sync-health"`)
|
|
543
|
+
* - `params`: Optional query parameters forwarded to the worker handler
|
|
544
|
+
*
|
|
545
|
+
* Response: The raw result from the worker's `getData` handler
|
|
546
|
+
*
|
|
547
|
+
* Error response body follows the `PluginBridgeError` shape:
|
|
548
|
+
* `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
|
|
549
|
+
*
|
|
550
|
+
* Errors:
|
|
551
|
+
* - 400 if request validation fails
|
|
552
|
+
* - 404 if plugin not found
|
|
553
|
+
* - 501 if bridge deps are not configured
|
|
554
|
+
* - 502 if the worker is unavailable or returns an error
|
|
555
|
+
*
|
|
556
|
+
* @see PLUGIN_SPEC.md §13.8 — `getData`
|
|
557
|
+
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
|
|
558
|
+
*/
|
|
559
|
+
router.post("/plugins/:pluginId/bridge/data", async (req, res) => {
|
|
560
|
+
assertBoard(req);
|
|
561
|
+
if (!bridgeDeps) {
|
|
562
|
+
res.status(501).json({ error: "Plugin bridge is not enabled" });
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const { pluginId } = req.params;
|
|
566
|
+
// Resolve plugin
|
|
567
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
568
|
+
if (!plugin) {
|
|
569
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
// Validate plugin is in ready state
|
|
573
|
+
if (plugin.status !== "ready") {
|
|
574
|
+
const bridgeError = {
|
|
575
|
+
code: "WORKER_UNAVAILABLE",
|
|
576
|
+
message: `Plugin is not ready (current status: ${plugin.status})`,
|
|
577
|
+
};
|
|
578
|
+
res.status(502).json(bridgeError);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
// Validate request body
|
|
582
|
+
const body = req.body;
|
|
583
|
+
if (!body || !body.key || typeof body.key !== "string") {
|
|
584
|
+
res.status(400).json({ error: '"key" is required and must be a string' });
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (body.companyId) {
|
|
588
|
+
assertCompanyAccess(req, body.companyId);
|
|
589
|
+
}
|
|
590
|
+
try {
|
|
591
|
+
const result = await bridgeDeps.workerManager.call(plugin.id, "getData", {
|
|
592
|
+
key: body.key,
|
|
593
|
+
params: body.params ?? {},
|
|
594
|
+
renderEnvironment: body.renderEnvironment ?? null,
|
|
595
|
+
});
|
|
596
|
+
res.json({ data: result });
|
|
597
|
+
}
|
|
598
|
+
catch (err) {
|
|
599
|
+
const bridgeError = mapRpcErrorToBridgeError(err);
|
|
600
|
+
res.status(502).json(bridgeError);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
/**
|
|
604
|
+
* POST /api/plugins/:pluginId/bridge/action
|
|
605
|
+
*
|
|
606
|
+
* Proxy a `performAction` call from the plugin UI to the plugin worker.
|
|
607
|
+
*
|
|
608
|
+
* This is the server-side half of the `usePluginAction(key)` bridge hook.
|
|
609
|
+
* The frontend sends a POST with the action key and optional params; the host
|
|
610
|
+
* forwards the call to the worker via the `performAction` RPC method and
|
|
611
|
+
* returns the result.
|
|
612
|
+
*
|
|
613
|
+
* Request body:
|
|
614
|
+
* - `key`: Plugin-defined action key (e.g. `"resync"`)
|
|
615
|
+
* - `params`: Optional parameters forwarded to the worker handler
|
|
616
|
+
*
|
|
617
|
+
* Response: The raw result from the worker's `performAction` handler
|
|
618
|
+
*
|
|
619
|
+
* Error response body follows the `PluginBridgeError` shape:
|
|
620
|
+
* `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
|
|
621
|
+
*
|
|
622
|
+
* Errors:
|
|
623
|
+
* - 400 if request validation fails
|
|
624
|
+
* - 404 if plugin not found
|
|
625
|
+
* - 501 if bridge deps are not configured
|
|
626
|
+
* - 502 if the worker is unavailable or returns an error
|
|
627
|
+
*
|
|
628
|
+
* @see PLUGIN_SPEC.md §13.9 — `performAction`
|
|
629
|
+
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
|
|
630
|
+
*/
|
|
631
|
+
router.post("/plugins/:pluginId/bridge/action", async (req, res) => {
|
|
632
|
+
assertBoard(req);
|
|
633
|
+
if (!bridgeDeps) {
|
|
634
|
+
res.status(501).json({ error: "Plugin bridge is not enabled" });
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
const { pluginId } = req.params;
|
|
638
|
+
// Resolve plugin
|
|
639
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
640
|
+
if (!plugin) {
|
|
641
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
// Validate plugin is in ready state
|
|
645
|
+
if (plugin.status !== "ready") {
|
|
646
|
+
const bridgeError = {
|
|
647
|
+
code: "WORKER_UNAVAILABLE",
|
|
648
|
+
message: `Plugin is not ready (current status: ${plugin.status})`,
|
|
649
|
+
};
|
|
650
|
+
res.status(502).json(bridgeError);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
// Validate request body
|
|
654
|
+
const body = req.body;
|
|
655
|
+
if (!body || !body.key || typeof body.key !== "string") {
|
|
656
|
+
res.status(400).json({ error: '"key" is required and must be a string' });
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (body.companyId) {
|
|
660
|
+
assertCompanyAccess(req, body.companyId);
|
|
661
|
+
}
|
|
662
|
+
try {
|
|
663
|
+
const result = await bridgeDeps.workerManager.call(plugin.id, "performAction", {
|
|
664
|
+
key: body.key,
|
|
665
|
+
params: body.params ?? {},
|
|
666
|
+
renderEnvironment: body.renderEnvironment ?? null,
|
|
667
|
+
});
|
|
668
|
+
res.json({ data: result });
|
|
669
|
+
}
|
|
670
|
+
catch (err) {
|
|
671
|
+
const bridgeError = mapRpcErrorToBridgeError(err);
|
|
672
|
+
res.status(502).json(bridgeError);
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
// ===========================================================================
|
|
676
|
+
// URL-keyed bridge routes (key as path parameter)
|
|
677
|
+
// ===========================================================================
|
|
678
|
+
/**
|
|
679
|
+
* POST /api/plugins/:pluginId/data/:key
|
|
680
|
+
*
|
|
681
|
+
* Proxy a `getData` call from the plugin UI to the plugin worker, with the
|
|
682
|
+
* data key specified as a URL path parameter instead of in the request body.
|
|
683
|
+
*
|
|
684
|
+
* This is a REST-friendly alternative to `POST /plugins/:pluginId/bridge/data`.
|
|
685
|
+
* The frontend bridge hooks use this endpoint for cleaner URLs.
|
|
686
|
+
*
|
|
687
|
+
* Request body (optional):
|
|
688
|
+
* - `params`: Optional query parameters forwarded to the worker handler
|
|
689
|
+
*
|
|
690
|
+
* Response: The raw result from the worker's `getData` handler wrapped as `{ data: T }`
|
|
691
|
+
*
|
|
692
|
+
* Error response body follows the `PluginBridgeError` shape:
|
|
693
|
+
* `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
|
|
694
|
+
*
|
|
695
|
+
* Errors:
|
|
696
|
+
* - 404 if plugin not found
|
|
697
|
+
* - 501 if bridge deps are not configured
|
|
698
|
+
* - 502 if the worker is unavailable or returns an error
|
|
699
|
+
*
|
|
700
|
+
* @see PLUGIN_SPEC.md §13.8 — `getData`
|
|
701
|
+
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
|
|
702
|
+
*/
|
|
703
|
+
router.post("/plugins/:pluginId/data/:key", async (req, res) => {
|
|
704
|
+
assertBoard(req);
|
|
705
|
+
if (!bridgeDeps) {
|
|
706
|
+
res.status(501).json({ error: "Plugin bridge is not enabled" });
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
const { pluginId, key } = req.params;
|
|
710
|
+
// Resolve plugin
|
|
711
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
712
|
+
if (!plugin) {
|
|
713
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
// Validate plugin is in ready state
|
|
717
|
+
if (plugin.status !== "ready") {
|
|
718
|
+
const bridgeError = {
|
|
719
|
+
code: "WORKER_UNAVAILABLE",
|
|
720
|
+
message: `Plugin is not ready (current status: ${plugin.status})`,
|
|
721
|
+
};
|
|
722
|
+
res.status(502).json(bridgeError);
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const body = req.body;
|
|
726
|
+
if (body?.companyId) {
|
|
727
|
+
assertCompanyAccess(req, body.companyId);
|
|
728
|
+
}
|
|
729
|
+
try {
|
|
730
|
+
const result = await bridgeDeps.workerManager.call(plugin.id, "getData", {
|
|
731
|
+
key,
|
|
732
|
+
params: body?.params ?? {},
|
|
733
|
+
renderEnvironment: body?.renderEnvironment ?? null,
|
|
734
|
+
});
|
|
735
|
+
res.json({ data: result });
|
|
736
|
+
}
|
|
737
|
+
catch (err) {
|
|
738
|
+
const bridgeError = mapRpcErrorToBridgeError(err);
|
|
739
|
+
res.status(502).json(bridgeError);
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
/**
|
|
743
|
+
* POST /api/plugins/:pluginId/actions/:key
|
|
744
|
+
*
|
|
745
|
+
* Proxy a `performAction` call from the plugin UI to the plugin worker, with
|
|
746
|
+
* the action key specified as a URL path parameter instead of in the request body.
|
|
747
|
+
*
|
|
748
|
+
* This is a REST-friendly alternative to `POST /plugins/:pluginId/bridge/action`.
|
|
749
|
+
* The frontend bridge hooks use this endpoint for cleaner URLs.
|
|
750
|
+
*
|
|
751
|
+
* Request body (optional):
|
|
752
|
+
* - `params`: Optional parameters forwarded to the worker handler
|
|
753
|
+
*
|
|
754
|
+
* Response: The raw result from the worker's `performAction` handler wrapped as `{ data: T }`
|
|
755
|
+
*
|
|
756
|
+
* Error response body follows the `PluginBridgeError` shape:
|
|
757
|
+
* `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
|
|
758
|
+
*
|
|
759
|
+
* Errors:
|
|
760
|
+
* - 404 if plugin not found
|
|
761
|
+
* - 501 if bridge deps are not configured
|
|
762
|
+
* - 502 if the worker is unavailable or returns an error
|
|
763
|
+
*
|
|
764
|
+
* @see PLUGIN_SPEC.md §13.9 — `performAction`
|
|
765
|
+
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
|
|
766
|
+
*/
|
|
767
|
+
router.post("/plugins/:pluginId/actions/:key", async (req, res) => {
|
|
768
|
+
assertBoard(req);
|
|
769
|
+
if (!bridgeDeps) {
|
|
770
|
+
res.status(501).json({ error: "Plugin bridge is not enabled" });
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
const { pluginId, key } = req.params;
|
|
774
|
+
// Resolve plugin
|
|
775
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
776
|
+
if (!plugin) {
|
|
777
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
// Validate plugin is in ready state
|
|
781
|
+
if (plugin.status !== "ready") {
|
|
782
|
+
const bridgeError = {
|
|
783
|
+
code: "WORKER_UNAVAILABLE",
|
|
784
|
+
message: `Plugin is not ready (current status: ${plugin.status})`,
|
|
785
|
+
};
|
|
786
|
+
res.status(502).json(bridgeError);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
const body = req.body;
|
|
790
|
+
if (body?.companyId) {
|
|
791
|
+
assertCompanyAccess(req, body.companyId);
|
|
792
|
+
}
|
|
793
|
+
try {
|
|
794
|
+
const result = await bridgeDeps.workerManager.call(plugin.id, "performAction", {
|
|
795
|
+
key,
|
|
796
|
+
params: body?.params ?? {},
|
|
797
|
+
renderEnvironment: body?.renderEnvironment ?? null,
|
|
798
|
+
});
|
|
799
|
+
res.json({ data: result });
|
|
800
|
+
}
|
|
801
|
+
catch (err) {
|
|
802
|
+
const bridgeError = mapRpcErrorToBridgeError(err);
|
|
803
|
+
res.status(502).json(bridgeError);
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
// ===========================================================================
|
|
807
|
+
// SSE stream bridge route
|
|
808
|
+
// ===========================================================================
|
|
809
|
+
/**
|
|
810
|
+
* GET /api/plugins/:pluginId/bridge/stream/:channel
|
|
811
|
+
*
|
|
812
|
+
* Server-Sent Events endpoint for real-time streaming from plugin worker to UI.
|
|
813
|
+
*
|
|
814
|
+
* The worker pushes events via `ctx.streams.emit(channel, event)` which arrive
|
|
815
|
+
* as JSON-RPC notifications to the host, get published on the PluginStreamBus,
|
|
816
|
+
* and are fanned out to all connected SSE clients matching (pluginId, channel,
|
|
817
|
+
* companyId).
|
|
818
|
+
*
|
|
819
|
+
* Query parameters:
|
|
820
|
+
* - `companyId` (required): Scope events to a specific company
|
|
821
|
+
*
|
|
822
|
+
* SSE event types:
|
|
823
|
+
* - `message`: A data event from the worker (default)
|
|
824
|
+
* - `open`: The worker opened the stream channel
|
|
825
|
+
* - `close`: The worker closed the stream channel — client should disconnect
|
|
826
|
+
*
|
|
827
|
+
* Errors:
|
|
828
|
+
* - 400 if companyId is missing
|
|
829
|
+
* - 404 if plugin not found
|
|
830
|
+
* - 501 if bridge deps or stream bus are not configured
|
|
831
|
+
*/
|
|
832
|
+
router.get("/plugins/:pluginId/bridge/stream/:channel", async (req, res) => {
|
|
833
|
+
assertBoard(req);
|
|
834
|
+
if (!bridgeDeps?.streamBus) {
|
|
835
|
+
res.status(501).json({ error: "Plugin stream bridge is not enabled" });
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
const { pluginId, channel } = req.params;
|
|
839
|
+
const companyId = req.query.companyId;
|
|
840
|
+
if (!companyId) {
|
|
841
|
+
res.status(400).json({ error: '"companyId" query parameter is required' });
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
845
|
+
if (!plugin) {
|
|
846
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
assertCompanyAccess(req, companyId);
|
|
850
|
+
// Set SSE headers
|
|
851
|
+
res.writeHead(200, {
|
|
852
|
+
"Content-Type": "text/event-stream",
|
|
853
|
+
"Cache-Control": "no-cache",
|
|
854
|
+
"Connection": "keep-alive",
|
|
855
|
+
"X-Accel-Buffering": "no",
|
|
856
|
+
});
|
|
857
|
+
res.flushHeaders();
|
|
858
|
+
// Send initial comment to establish the connection
|
|
859
|
+
res.write(":ok\n\n");
|
|
860
|
+
let unsubscribed = false;
|
|
861
|
+
const safeUnsubscribe = () => {
|
|
862
|
+
if (!unsubscribed) {
|
|
863
|
+
unsubscribed = true;
|
|
864
|
+
unsubscribe();
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
const unsubscribe = bridgeDeps.streamBus.subscribe(plugin.id, channel, companyId, (event, eventType) => {
|
|
868
|
+
if (unsubscribed || !res.writable)
|
|
869
|
+
return;
|
|
870
|
+
try {
|
|
871
|
+
if (eventType !== "message") {
|
|
872
|
+
res.write(`event: ${eventType}\n`);
|
|
873
|
+
}
|
|
874
|
+
res.write(`data: ${JSON.stringify(event)}\n\n`);
|
|
875
|
+
}
|
|
876
|
+
catch {
|
|
877
|
+
// Connection closed or write error — stop delivering
|
|
878
|
+
safeUnsubscribe();
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
req.on("close", safeUnsubscribe);
|
|
882
|
+
res.on("error", safeUnsubscribe);
|
|
883
|
+
});
|
|
884
|
+
/**
|
|
885
|
+
* GET /api/plugins/:pluginId
|
|
886
|
+
*
|
|
887
|
+
* Get detailed information about a single plugin.
|
|
888
|
+
*
|
|
889
|
+
* The :pluginId parameter accepts either:
|
|
890
|
+
* - Database UUID (e.g., "abc123-def456")
|
|
891
|
+
* - Plugin key (e.g., "acme.linear")
|
|
892
|
+
*
|
|
893
|
+
* Response: PluginRecord
|
|
894
|
+
* Errors: 404 if plugin not found
|
|
895
|
+
*/
|
|
896
|
+
router.get("/plugins/:pluginId", async (req, res) => {
|
|
897
|
+
assertBoard(req);
|
|
898
|
+
const { pluginId } = req.params;
|
|
899
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
900
|
+
if (!plugin) {
|
|
901
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
// Enrich with worker capabilities when available
|
|
905
|
+
const worker = bridgeDeps?.workerManager.getWorker(plugin.id);
|
|
906
|
+
const supportsConfigTest = worker
|
|
907
|
+
? worker.supportedMethods.includes("validateConfig")
|
|
908
|
+
: false;
|
|
909
|
+
res.json({ ...plugin, supportsConfigTest });
|
|
910
|
+
});
|
|
911
|
+
/**
|
|
912
|
+
* DELETE /api/plugins/:pluginId
|
|
913
|
+
*
|
|
914
|
+
* Uninstall a plugin.
|
|
915
|
+
*
|
|
916
|
+
* Query params:
|
|
917
|
+
* - purge: If "true", permanently delete all plugin data (hard delete)
|
|
918
|
+
* Otherwise, soft-delete with 30-day data retention
|
|
919
|
+
*
|
|
920
|
+
* Response: PluginRecord (the deleted record)
|
|
921
|
+
* Errors: 404 if plugin not found, 400 for lifecycle errors
|
|
922
|
+
*/
|
|
923
|
+
router.delete("/plugins/:pluginId", async (req, res) => {
|
|
924
|
+
assertBoard(req);
|
|
925
|
+
const { pluginId } = req.params;
|
|
926
|
+
const purge = req.query.purge === "true";
|
|
927
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
928
|
+
if (!plugin) {
|
|
929
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
try {
|
|
933
|
+
const result = await lifecycle.unload(plugin.id, purge);
|
|
934
|
+
await logPluginMutationActivity(req, "plugin.uninstalled", plugin.id, {
|
|
935
|
+
pluginId: plugin.id,
|
|
936
|
+
pluginKey: plugin.pluginKey,
|
|
937
|
+
purge,
|
|
938
|
+
});
|
|
939
|
+
publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "uninstalled" } });
|
|
940
|
+
res.json(result);
|
|
941
|
+
}
|
|
942
|
+
catch (err) {
|
|
943
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
944
|
+
res.status(400).json({ error: message });
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
/**
|
|
948
|
+
* POST /api/plugins/:pluginId/enable
|
|
949
|
+
*
|
|
950
|
+
* Enable a plugin that is currently disabled or in error state.
|
|
951
|
+
*
|
|
952
|
+
* Transitions the plugin to 'ready' state after loading and validation.
|
|
953
|
+
*
|
|
954
|
+
* Response: PluginRecord
|
|
955
|
+
* Errors: 404 if plugin not found, 400 for lifecycle errors
|
|
956
|
+
*/
|
|
957
|
+
router.post("/plugins/:pluginId/enable", async (req, res) => {
|
|
958
|
+
assertBoard(req);
|
|
959
|
+
const { pluginId } = req.params;
|
|
960
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
961
|
+
if (!plugin) {
|
|
962
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
try {
|
|
966
|
+
const result = await lifecycle.enable(plugin.id);
|
|
967
|
+
await logPluginMutationActivity(req, "plugin.enabled", plugin.id, {
|
|
968
|
+
pluginId: plugin.id,
|
|
969
|
+
pluginKey: plugin.pluginKey,
|
|
970
|
+
version: result?.version ?? plugin.version,
|
|
971
|
+
});
|
|
972
|
+
publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "enabled" } });
|
|
973
|
+
res.json(result);
|
|
974
|
+
}
|
|
975
|
+
catch (err) {
|
|
976
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
977
|
+
res.status(400).json({ error: message });
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
/**
|
|
981
|
+
* POST /api/plugins/:pluginId/disable
|
|
982
|
+
*
|
|
983
|
+
* Disable a running plugin.
|
|
984
|
+
*
|
|
985
|
+
* Request body (optional):
|
|
986
|
+
* - reason: Human-readable reason for disabling
|
|
987
|
+
*
|
|
988
|
+
* The plugin transitions to 'installed' state and stops processing events.
|
|
989
|
+
*
|
|
990
|
+
* Response: PluginRecord
|
|
991
|
+
* Errors: 404 if plugin not found, 400 for lifecycle errors
|
|
992
|
+
*/
|
|
993
|
+
router.post("/plugins/:pluginId/disable", async (req, res) => {
|
|
994
|
+
assertBoard(req);
|
|
995
|
+
const { pluginId } = req.params;
|
|
996
|
+
const body = req.body;
|
|
997
|
+
const reason = body?.reason;
|
|
998
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
999
|
+
if (!plugin) {
|
|
1000
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
try {
|
|
1004
|
+
const result = await lifecycle.disable(plugin.id, reason);
|
|
1005
|
+
await logPluginMutationActivity(req, "plugin.disabled", plugin.id, {
|
|
1006
|
+
pluginId: plugin.id,
|
|
1007
|
+
pluginKey: plugin.pluginKey,
|
|
1008
|
+
reason: reason ?? null,
|
|
1009
|
+
});
|
|
1010
|
+
publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "disabled" } });
|
|
1011
|
+
res.json(result);
|
|
1012
|
+
}
|
|
1013
|
+
catch (err) {
|
|
1014
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1015
|
+
res.status(400).json({ error: message });
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
/**
|
|
1019
|
+
* GET /api/plugins/:pluginId/health
|
|
1020
|
+
*
|
|
1021
|
+
* Run health diagnostics on a plugin.
|
|
1022
|
+
*
|
|
1023
|
+
* Performs the following checks:
|
|
1024
|
+
* 1. Registry: Plugin is registered in the database
|
|
1025
|
+
* 2. Manifest: Manifest is valid and parseable
|
|
1026
|
+
* 3. Status: Plugin is in 'ready' state
|
|
1027
|
+
* 4. Error state: Plugin has no unhandled errors
|
|
1028
|
+
*
|
|
1029
|
+
* Response: PluginHealthCheckResult
|
|
1030
|
+
* Errors: 404 if plugin not found
|
|
1031
|
+
*/
|
|
1032
|
+
router.get("/plugins/:pluginId/health", async (req, res) => {
|
|
1033
|
+
assertBoard(req);
|
|
1034
|
+
const { pluginId } = req.params;
|
|
1035
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1036
|
+
if (!plugin) {
|
|
1037
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
const checks = [];
|
|
1041
|
+
// Check 1: Plugin is registered
|
|
1042
|
+
checks.push({
|
|
1043
|
+
name: "registry",
|
|
1044
|
+
passed: true,
|
|
1045
|
+
message: "Plugin found in registry",
|
|
1046
|
+
});
|
|
1047
|
+
// Check 2: Manifest is valid
|
|
1048
|
+
const hasValidManifest = Boolean(plugin.manifestJson?.id);
|
|
1049
|
+
checks.push({
|
|
1050
|
+
name: "manifest",
|
|
1051
|
+
passed: hasValidManifest,
|
|
1052
|
+
message: hasValidManifest ? "Manifest is valid" : "Manifest is invalid or missing",
|
|
1053
|
+
});
|
|
1054
|
+
// Check 3: Plugin status
|
|
1055
|
+
const isHealthy = plugin.status === "ready";
|
|
1056
|
+
checks.push({
|
|
1057
|
+
name: "status",
|
|
1058
|
+
passed: isHealthy,
|
|
1059
|
+
message: `Current status: ${plugin.status}`,
|
|
1060
|
+
});
|
|
1061
|
+
// Check 4: No last error
|
|
1062
|
+
const hasNoError = !plugin.lastError;
|
|
1063
|
+
if (!hasNoError) {
|
|
1064
|
+
checks.push({
|
|
1065
|
+
name: "error_state",
|
|
1066
|
+
passed: false,
|
|
1067
|
+
message: plugin.lastError ?? undefined,
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
const result = {
|
|
1071
|
+
pluginId: plugin.id,
|
|
1072
|
+
status: plugin.status,
|
|
1073
|
+
healthy: isHealthy && hasValidManifest && hasNoError,
|
|
1074
|
+
checks,
|
|
1075
|
+
lastError: plugin.lastError ?? undefined,
|
|
1076
|
+
};
|
|
1077
|
+
res.json(result);
|
|
1078
|
+
});
|
|
1079
|
+
/**
|
|
1080
|
+
* GET /api/plugins/:pluginId/logs
|
|
1081
|
+
*
|
|
1082
|
+
* Query recent log entries for a plugin.
|
|
1083
|
+
*
|
|
1084
|
+
* Query params:
|
|
1085
|
+
* - limit: Maximum number of entries (default 25, max 500)
|
|
1086
|
+
* - level: Filter by log level (info, warn, error, debug)
|
|
1087
|
+
* - since: ISO timestamp to filter logs newer than this time
|
|
1088
|
+
*
|
|
1089
|
+
* Response: Array of log entries, newest first.
|
|
1090
|
+
*/
|
|
1091
|
+
router.get("/plugins/:pluginId/logs", async (req, res) => {
|
|
1092
|
+
assertBoard(req);
|
|
1093
|
+
const { pluginId } = req.params;
|
|
1094
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1095
|
+
if (!plugin) {
|
|
1096
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
const limit = Math.min(Math.max(parseInt(req.query.limit, 10) || 25, 1), 500);
|
|
1100
|
+
const level = req.query.level;
|
|
1101
|
+
const since = req.query.since;
|
|
1102
|
+
const conditions = [eq(pluginLogs.pluginId, plugin.id)];
|
|
1103
|
+
if (level) {
|
|
1104
|
+
conditions.push(eq(pluginLogs.level, level));
|
|
1105
|
+
}
|
|
1106
|
+
if (since) {
|
|
1107
|
+
const sinceDate = new Date(since);
|
|
1108
|
+
if (!isNaN(sinceDate.getTime())) {
|
|
1109
|
+
conditions.push(gte(pluginLogs.createdAt, sinceDate));
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
const rows = await db
|
|
1113
|
+
.select()
|
|
1114
|
+
.from(pluginLogs)
|
|
1115
|
+
.where(and(...conditions))
|
|
1116
|
+
.orderBy(desc(pluginLogs.createdAt))
|
|
1117
|
+
.limit(limit);
|
|
1118
|
+
res.json(rows);
|
|
1119
|
+
});
|
|
1120
|
+
/**
|
|
1121
|
+
* POST /api/plugins/:pluginId/upgrade
|
|
1122
|
+
*
|
|
1123
|
+
* Upgrade a plugin to a newer version.
|
|
1124
|
+
*
|
|
1125
|
+
* Request body (optional):
|
|
1126
|
+
* - version: Target version (defaults to latest)
|
|
1127
|
+
*
|
|
1128
|
+
* If the upgrade adds new capabilities, the plugin transitions to
|
|
1129
|
+
* 'upgrade_pending' state for board approval. Otherwise, it goes
|
|
1130
|
+
* directly to 'ready'.
|
|
1131
|
+
*
|
|
1132
|
+
* Response: PluginRecord
|
|
1133
|
+
* Errors: 404 if plugin not found, 400 for lifecycle errors
|
|
1134
|
+
*/
|
|
1135
|
+
router.post("/plugins/:pluginId/upgrade", async (req, res) => {
|
|
1136
|
+
assertBoard(req);
|
|
1137
|
+
const { pluginId } = req.params;
|
|
1138
|
+
const body = req.body;
|
|
1139
|
+
const version = body?.version;
|
|
1140
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1141
|
+
if (!plugin) {
|
|
1142
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
try {
|
|
1146
|
+
// Upgrade the plugin - this would typically:
|
|
1147
|
+
// 1. Download the new version
|
|
1148
|
+
// 2. Compare capabilities
|
|
1149
|
+
// 3. If new capabilities, mark as upgrade_pending
|
|
1150
|
+
// 4. Otherwise, transition to ready
|
|
1151
|
+
const result = await lifecycle.upgrade(plugin.id, version);
|
|
1152
|
+
await logPluginMutationActivity(req, "plugin.upgraded", plugin.id, {
|
|
1153
|
+
pluginId: plugin.id,
|
|
1154
|
+
pluginKey: plugin.pluginKey,
|
|
1155
|
+
previousVersion: plugin.version,
|
|
1156
|
+
version: result?.version ?? plugin.version,
|
|
1157
|
+
targetVersion: version ?? null,
|
|
1158
|
+
});
|
|
1159
|
+
publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "upgraded" } });
|
|
1160
|
+
res.json(result);
|
|
1161
|
+
}
|
|
1162
|
+
catch (err) {
|
|
1163
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1164
|
+
res.status(400).json({ error: message });
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
// ===========================================================================
|
|
1168
|
+
// Plugin configuration routes
|
|
1169
|
+
// ===========================================================================
|
|
1170
|
+
/**
|
|
1171
|
+
* GET /api/plugins/:pluginId/config
|
|
1172
|
+
*
|
|
1173
|
+
* Retrieve the current instance configuration for a plugin.
|
|
1174
|
+
*
|
|
1175
|
+
* Returns the `PluginConfig` record if one exists, or `null` if the plugin
|
|
1176
|
+
* has not yet been configured.
|
|
1177
|
+
*
|
|
1178
|
+
* Response: `PluginConfig | null`
|
|
1179
|
+
* Errors: 404 if plugin not found
|
|
1180
|
+
*/
|
|
1181
|
+
router.get("/plugins/:pluginId/config", async (req, res) => {
|
|
1182
|
+
assertBoard(req);
|
|
1183
|
+
const { pluginId } = req.params;
|
|
1184
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1185
|
+
if (!plugin) {
|
|
1186
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
const config = await registry.getConfig(plugin.id);
|
|
1190
|
+
res.json(config);
|
|
1191
|
+
});
|
|
1192
|
+
/**
|
|
1193
|
+
* POST /api/plugins/:pluginId/config
|
|
1194
|
+
*
|
|
1195
|
+
* Save (create or replace) the instance configuration for a plugin.
|
|
1196
|
+
*
|
|
1197
|
+
* The caller provides the full `configJson` object. The server persists it
|
|
1198
|
+
* via `registry.upsertConfig()`.
|
|
1199
|
+
*
|
|
1200
|
+
* Request body:
|
|
1201
|
+
* - `configJson`: Configuration values matching the plugin's `instanceConfigSchema`
|
|
1202
|
+
*
|
|
1203
|
+
* Response: `PluginConfig`
|
|
1204
|
+
* Errors:
|
|
1205
|
+
* - 400 if request validation fails
|
|
1206
|
+
* - 404 if plugin not found
|
|
1207
|
+
*/
|
|
1208
|
+
router.post("/plugins/:pluginId/config", async (req, res) => {
|
|
1209
|
+
assertBoard(req);
|
|
1210
|
+
const { pluginId } = req.params;
|
|
1211
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1212
|
+
if (!plugin) {
|
|
1213
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
const body = req.body;
|
|
1217
|
+
if (!body?.configJson || typeof body.configJson !== "object") {
|
|
1218
|
+
res.status(400).json({ error: '"configJson" is required and must be an object' });
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
// Strip devUiUrl unless the caller is an instance admin. devUiUrl activates
|
|
1222
|
+
// a dev-proxy in the static file route that could be abused for SSRF if any
|
|
1223
|
+
// board-level user were allowed to set it.
|
|
1224
|
+
if ("devUiUrl" in body.configJson &&
|
|
1225
|
+
!(req.actor.type === "board" && req.actor.isInstanceAdmin)) {
|
|
1226
|
+
delete body.configJson.devUiUrl;
|
|
1227
|
+
}
|
|
1228
|
+
// Validate configJson against the plugin's instanceConfigSchema (if declared).
|
|
1229
|
+
// This ensures CLI/API callers get the same validation the UI performs client-side.
|
|
1230
|
+
const schema = plugin.manifestJson?.instanceConfigSchema;
|
|
1231
|
+
if (schema && Object.keys(schema).length > 0) {
|
|
1232
|
+
const validation = validateInstanceConfig(body.configJson, schema);
|
|
1233
|
+
if (!validation.valid) {
|
|
1234
|
+
res.status(400).json({
|
|
1235
|
+
error: "Configuration does not match the plugin's instanceConfigSchema",
|
|
1236
|
+
fieldErrors: validation.errors,
|
|
1237
|
+
});
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
try {
|
|
1242
|
+
const result = await registry.upsertConfig(plugin.id, {
|
|
1243
|
+
configJson: body.configJson,
|
|
1244
|
+
});
|
|
1245
|
+
await logPluginMutationActivity(req, "plugin.config.updated", plugin.id, {
|
|
1246
|
+
pluginId: plugin.id,
|
|
1247
|
+
pluginKey: plugin.pluginKey,
|
|
1248
|
+
configKeyCount: Object.keys(body.configJson).length,
|
|
1249
|
+
});
|
|
1250
|
+
// Notify the running worker about the config change (PLUGIN_SPEC §25.4.4).
|
|
1251
|
+
// If the worker implements onConfigChanged, send the new config via RPC.
|
|
1252
|
+
// If it doesn't (METHOD_NOT_IMPLEMENTED), restart the worker so it picks
|
|
1253
|
+
// up the new config on re-initialize. If no worker is running, skip.
|
|
1254
|
+
if (bridgeDeps?.workerManager.isRunning(plugin.id)) {
|
|
1255
|
+
try {
|
|
1256
|
+
await bridgeDeps.workerManager.call(plugin.id, "configChanged", { config: body.configJson });
|
|
1257
|
+
}
|
|
1258
|
+
catch (rpcErr) {
|
|
1259
|
+
if (rpcErr instanceof JsonRpcCallError &&
|
|
1260
|
+
rpcErr.code === PLUGIN_RPC_ERROR_CODES.METHOD_NOT_IMPLEMENTED) {
|
|
1261
|
+
// Worker doesn't handle live config — restart it.
|
|
1262
|
+
try {
|
|
1263
|
+
await lifecycle.restartWorker(plugin.id);
|
|
1264
|
+
}
|
|
1265
|
+
catch {
|
|
1266
|
+
// Restart failure is non-fatal for the config save response.
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
// Other RPC errors (timeout, unavailable) are non-fatal — config is
|
|
1270
|
+
// already persisted and will take effect on next worker restart.
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
res.json(result);
|
|
1274
|
+
}
|
|
1275
|
+
catch (err) {
|
|
1276
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1277
|
+
res.status(400).json({ error: message });
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
/**
|
|
1281
|
+
* POST /api/plugins/:pluginId/config/test
|
|
1282
|
+
*
|
|
1283
|
+
* Test a plugin configuration without persisting it by calling the plugin
|
|
1284
|
+
* worker's `validateConfig` RPC method.
|
|
1285
|
+
*
|
|
1286
|
+
* Only works when the plugin's worker implements `onValidateConfig`.
|
|
1287
|
+
* If the worker does not implement the method, returns
|
|
1288
|
+
* `{ valid: false, supported: false, message: "..." }` with HTTP 200.
|
|
1289
|
+
*
|
|
1290
|
+
* Request body:
|
|
1291
|
+
* - `configJson`: Configuration values to validate
|
|
1292
|
+
*
|
|
1293
|
+
* Response: `{ valid: boolean; message?: string; supported?: boolean }`
|
|
1294
|
+
* Errors:
|
|
1295
|
+
* - 400 if request validation fails
|
|
1296
|
+
* - 404 if plugin not found
|
|
1297
|
+
* - 501 if bridge deps (worker manager) are not configured
|
|
1298
|
+
* - 502 if the worker is unavailable
|
|
1299
|
+
*/
|
|
1300
|
+
router.post("/plugins/:pluginId/config/test", async (req, res) => {
|
|
1301
|
+
assertBoard(req);
|
|
1302
|
+
if (!bridgeDeps) {
|
|
1303
|
+
res.status(501).json({ error: "Plugin bridge is not enabled" });
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
const { pluginId } = req.params;
|
|
1307
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1308
|
+
if (!plugin) {
|
|
1309
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
if (plugin.status !== "ready") {
|
|
1313
|
+
res.status(400).json({
|
|
1314
|
+
error: `Plugin is not ready (current status: ${plugin.status})`,
|
|
1315
|
+
});
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
const body = req.body;
|
|
1319
|
+
if (!body?.configJson || typeof body.configJson !== "object") {
|
|
1320
|
+
res.status(400).json({ error: '"configJson" is required and must be an object' });
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
// Fast schema-level rejection before hitting the worker RPC.
|
|
1324
|
+
const schema = plugin.manifestJson?.instanceConfigSchema;
|
|
1325
|
+
if (schema && Object.keys(schema).length > 0) {
|
|
1326
|
+
const validation = validateInstanceConfig(body.configJson, schema);
|
|
1327
|
+
if (!validation.valid) {
|
|
1328
|
+
res.status(400).json({
|
|
1329
|
+
error: "Configuration does not match the plugin's instanceConfigSchema",
|
|
1330
|
+
fieldErrors: validation.errors,
|
|
1331
|
+
});
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
try {
|
|
1336
|
+
const result = await bridgeDeps.workerManager.call(plugin.id, "validateConfig", { config: body.configJson });
|
|
1337
|
+
// The worker returns PluginConfigValidationResult { ok, warnings?, errors? }
|
|
1338
|
+
// Map to the frontend-expected shape { valid, message? }
|
|
1339
|
+
if (result.ok) {
|
|
1340
|
+
const warningText = result.warnings?.length
|
|
1341
|
+
? `Warnings: ${result.warnings.join("; ")}`
|
|
1342
|
+
: undefined;
|
|
1343
|
+
res.json({ valid: true, message: warningText });
|
|
1344
|
+
}
|
|
1345
|
+
else {
|
|
1346
|
+
const errorText = result.errors?.length
|
|
1347
|
+
? result.errors.join("; ")
|
|
1348
|
+
: "Configuration validation failed.";
|
|
1349
|
+
res.json({ valid: false, message: errorText });
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
catch (err) {
|
|
1353
|
+
// If the worker does not implement validateConfig, return a structured response
|
|
1354
|
+
if (err instanceof JsonRpcCallError &&
|
|
1355
|
+
err.code === PLUGIN_RPC_ERROR_CODES.METHOD_NOT_IMPLEMENTED) {
|
|
1356
|
+
res.json({
|
|
1357
|
+
valid: false,
|
|
1358
|
+
supported: false,
|
|
1359
|
+
message: "This plugin does not support configuration testing.",
|
|
1360
|
+
});
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
// Worker unavailable or other RPC errors
|
|
1364
|
+
const bridgeError = mapRpcErrorToBridgeError(err);
|
|
1365
|
+
res.status(502).json(bridgeError);
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
// ===========================================================================
|
|
1369
|
+
// Job scheduling routes
|
|
1370
|
+
// ===========================================================================
|
|
1371
|
+
/**
|
|
1372
|
+
* GET /api/plugins/:pluginId/jobs
|
|
1373
|
+
*
|
|
1374
|
+
* List all scheduled jobs for a plugin.
|
|
1375
|
+
*
|
|
1376
|
+
* Query params:
|
|
1377
|
+
* - `status` (optional): Filter by job status (`active`, `paused`, `failed`)
|
|
1378
|
+
*
|
|
1379
|
+
* Response: PluginJobRecord[]
|
|
1380
|
+
* Errors: 404 if plugin not found
|
|
1381
|
+
*/
|
|
1382
|
+
router.get("/plugins/:pluginId/jobs", async (req, res) => {
|
|
1383
|
+
assertBoard(req);
|
|
1384
|
+
if (!jobDeps) {
|
|
1385
|
+
res.status(501).json({ error: "Job scheduling is not enabled" });
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
const { pluginId } = req.params;
|
|
1389
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1390
|
+
if (!plugin) {
|
|
1391
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
const rawStatus = req.query.status;
|
|
1395
|
+
const validStatuses = ["active", "paused", "failed"];
|
|
1396
|
+
if (rawStatus !== undefined && !validStatuses.includes(rawStatus)) {
|
|
1397
|
+
res.status(400).json({
|
|
1398
|
+
error: `Invalid status '${rawStatus}'. Must be one of: ${validStatuses.join(", ")}`,
|
|
1399
|
+
});
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
try {
|
|
1403
|
+
const jobs = await jobDeps.jobStore.listJobs(plugin.id, rawStatus);
|
|
1404
|
+
res.json(jobs);
|
|
1405
|
+
}
|
|
1406
|
+
catch (err) {
|
|
1407
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1408
|
+
res.status(500).json({ error: message });
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
/**
|
|
1412
|
+
* GET /api/plugins/:pluginId/jobs/:jobId/runs
|
|
1413
|
+
*
|
|
1414
|
+
* List execution history for a specific job.
|
|
1415
|
+
*
|
|
1416
|
+
* Query params:
|
|
1417
|
+
* - `limit` (optional): Maximum number of runs to return (default: 50)
|
|
1418
|
+
*
|
|
1419
|
+
* Response: PluginJobRunRecord[]
|
|
1420
|
+
* Errors: 404 if plugin not found
|
|
1421
|
+
*/
|
|
1422
|
+
router.get("/plugins/:pluginId/jobs/:jobId/runs", async (req, res) => {
|
|
1423
|
+
assertBoard(req);
|
|
1424
|
+
if (!jobDeps) {
|
|
1425
|
+
res.status(501).json({ error: "Job scheduling is not enabled" });
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
const { pluginId, jobId } = req.params;
|
|
1429
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1430
|
+
if (!plugin) {
|
|
1431
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
const job = await jobDeps.jobStore.getJobByIdForPlugin(plugin.id, jobId);
|
|
1435
|
+
if (!job) {
|
|
1436
|
+
res.status(404).json({ error: "Job not found" });
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
const limit = req.query.limit ? parseInt(req.query.limit, 10) : 25;
|
|
1440
|
+
if (isNaN(limit) || limit < 1 || limit > 500) {
|
|
1441
|
+
res.status(400).json({ error: "limit must be a number between 1 and 500" });
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
try {
|
|
1445
|
+
const runs = await jobDeps.jobStore.listRunsByJob(jobId, limit);
|
|
1446
|
+
res.json(runs);
|
|
1447
|
+
}
|
|
1448
|
+
catch (err) {
|
|
1449
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1450
|
+
res.status(500).json({ error: message });
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
/**
|
|
1454
|
+
* POST /api/plugins/:pluginId/jobs/:jobId/trigger
|
|
1455
|
+
*
|
|
1456
|
+
* Manually trigger a job execution outside its cron schedule.
|
|
1457
|
+
*
|
|
1458
|
+
* Creates a run with `trigger: "manual"` and dispatches immediately.
|
|
1459
|
+
* The response returns before the job completes (non-blocking).
|
|
1460
|
+
*
|
|
1461
|
+
* Response: `{ runId: string, jobId: string }`
|
|
1462
|
+
* Errors:
|
|
1463
|
+
* - 404 if plugin not found
|
|
1464
|
+
* - 400 if job not found, not active, already running, or worker unavailable
|
|
1465
|
+
*/
|
|
1466
|
+
router.post("/plugins/:pluginId/jobs/:jobId/trigger", async (req, res) => {
|
|
1467
|
+
assertBoard(req);
|
|
1468
|
+
if (!jobDeps) {
|
|
1469
|
+
res.status(501).json({ error: "Job scheduling is not enabled" });
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
const { pluginId, jobId } = req.params;
|
|
1473
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1474
|
+
if (!plugin) {
|
|
1475
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
const job = await jobDeps.jobStore.getJobByIdForPlugin(plugin.id, jobId);
|
|
1479
|
+
if (!job) {
|
|
1480
|
+
res.status(404).json({ error: "Job not found" });
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
try {
|
|
1484
|
+
const result = await jobDeps.scheduler.triggerJob(jobId, "manual");
|
|
1485
|
+
res.json(result);
|
|
1486
|
+
}
|
|
1487
|
+
catch (err) {
|
|
1488
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1489
|
+
res.status(400).json({ error: message });
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
// ===========================================================================
|
|
1493
|
+
// Webhook ingestion route
|
|
1494
|
+
// ===========================================================================
|
|
1495
|
+
/**
|
|
1496
|
+
* POST /api/plugins/:pluginId/webhooks/:endpointKey
|
|
1497
|
+
*
|
|
1498
|
+
* Receive an inbound webhook delivery for a plugin.
|
|
1499
|
+
*
|
|
1500
|
+
* This route is called by external systems (e.g. GitHub, Linear, Stripe) to
|
|
1501
|
+
* deliver webhook payloads to a plugin. The host validates that:
|
|
1502
|
+
* 1. The plugin exists and is in 'ready' state
|
|
1503
|
+
* 2. The plugin declares the `webhooks.receive` capability
|
|
1504
|
+
* 3. The `endpointKey` matches a declared webhook in the manifest
|
|
1505
|
+
*
|
|
1506
|
+
* The delivery is recorded in the `plugin_webhook_deliveries` table and
|
|
1507
|
+
* dispatched to the worker via the `handleWebhook` RPC method.
|
|
1508
|
+
*
|
|
1509
|
+
* **Note:** This route does NOT require board authentication — webhook
|
|
1510
|
+
* endpoints must be publicly accessible for external callers. Signature
|
|
1511
|
+
* verification is the plugin's responsibility.
|
|
1512
|
+
*
|
|
1513
|
+
* Response: `{ deliveryId: string, status: string }`
|
|
1514
|
+
* Errors:
|
|
1515
|
+
* - 404 if plugin not found or endpointKey not declared
|
|
1516
|
+
* - 400 if plugin is not in ready state or lacks webhooks.receive capability
|
|
1517
|
+
* - 502 if the worker is unavailable or the RPC call fails
|
|
1518
|
+
*/
|
|
1519
|
+
router.post("/plugins/:pluginId/webhooks/:endpointKey", async (req, res) => {
|
|
1520
|
+
if (!webhookDeps) {
|
|
1521
|
+
res.status(501).json({ error: "Webhook ingestion is not enabled" });
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
const { pluginId, endpointKey } = req.params;
|
|
1525
|
+
// Step 1: Resolve the plugin
|
|
1526
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1527
|
+
if (!plugin) {
|
|
1528
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
// Step 2: Validate the plugin is in 'ready' state
|
|
1532
|
+
if (plugin.status !== "ready") {
|
|
1533
|
+
res.status(400).json({
|
|
1534
|
+
error: `Plugin is not ready (current status: ${plugin.status})`,
|
|
1535
|
+
});
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
// Step 3: Validate the plugin has webhooks.receive capability
|
|
1539
|
+
const manifest = plugin.manifestJson;
|
|
1540
|
+
if (!manifest) {
|
|
1541
|
+
res.status(400).json({ error: "Plugin manifest is missing" });
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
const capabilities = manifest.capabilities ?? [];
|
|
1545
|
+
if (!capabilities.includes("webhooks.receive")) {
|
|
1546
|
+
res.status(400).json({
|
|
1547
|
+
error: "Plugin does not have the webhooks.receive capability",
|
|
1548
|
+
});
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
// Step 4: Validate the endpointKey exists in the manifest's webhook declarations
|
|
1552
|
+
const declaredWebhooks = manifest.webhooks ?? [];
|
|
1553
|
+
const webhookDecl = declaredWebhooks.find((w) => w.endpointKey === endpointKey);
|
|
1554
|
+
if (!webhookDecl) {
|
|
1555
|
+
res.status(404).json({
|
|
1556
|
+
error: `Webhook endpoint '${endpointKey}' is not declared by this plugin`,
|
|
1557
|
+
});
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
// Step 5: Extract request data
|
|
1561
|
+
const requestId = randomUUID();
|
|
1562
|
+
const rawHeaders = {};
|
|
1563
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
1564
|
+
if (typeof value === "string") {
|
|
1565
|
+
rawHeaders[key] = value;
|
|
1566
|
+
}
|
|
1567
|
+
else if (Array.isArray(value)) {
|
|
1568
|
+
rawHeaders[key] = value.join(", ");
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
// Use the raw buffer stashed by the express.json() `verify` callback.
|
|
1572
|
+
// This preserves the exact bytes the provider signed, whereas
|
|
1573
|
+
// JSON.stringify(req.body) would re-serialize and break HMAC verification.
|
|
1574
|
+
const stashedRaw = req.rawBody;
|
|
1575
|
+
const rawBody = stashedRaw ? stashedRaw.toString("utf-8") : "";
|
|
1576
|
+
const parsedBody = req.body;
|
|
1577
|
+
const payload = req.body ?? {};
|
|
1578
|
+
// Step 6: Record the delivery in the database
|
|
1579
|
+
const startedAt = new Date();
|
|
1580
|
+
const [delivery] = await db
|
|
1581
|
+
.insert(pluginWebhookDeliveries)
|
|
1582
|
+
.values({
|
|
1583
|
+
pluginId: plugin.id,
|
|
1584
|
+
webhookKey: endpointKey,
|
|
1585
|
+
status: "pending",
|
|
1586
|
+
payload,
|
|
1587
|
+
headers: rawHeaders,
|
|
1588
|
+
startedAt,
|
|
1589
|
+
})
|
|
1590
|
+
.returning({ id: pluginWebhookDeliveries.id });
|
|
1591
|
+
// Step 7: Dispatch to the worker via handleWebhook RPC
|
|
1592
|
+
try {
|
|
1593
|
+
await webhookDeps.workerManager.call(plugin.id, "handleWebhook", {
|
|
1594
|
+
endpointKey,
|
|
1595
|
+
headers: req.headers,
|
|
1596
|
+
rawBody,
|
|
1597
|
+
parsedBody,
|
|
1598
|
+
requestId,
|
|
1599
|
+
});
|
|
1600
|
+
// Step 8: Update delivery record to success
|
|
1601
|
+
const finishedAt = new Date();
|
|
1602
|
+
const durationMs = finishedAt.getTime() - startedAt.getTime();
|
|
1603
|
+
await db
|
|
1604
|
+
.update(pluginWebhookDeliveries)
|
|
1605
|
+
.set({
|
|
1606
|
+
status: "success",
|
|
1607
|
+
durationMs,
|
|
1608
|
+
finishedAt,
|
|
1609
|
+
})
|
|
1610
|
+
.where(eq(pluginWebhookDeliveries.id, delivery.id));
|
|
1611
|
+
res.status(200).json({
|
|
1612
|
+
deliveryId: delivery.id,
|
|
1613
|
+
status: "success",
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
catch (err) {
|
|
1617
|
+
// Step 8 (error): Update delivery record to failed
|
|
1618
|
+
const finishedAt = new Date();
|
|
1619
|
+
const durationMs = finishedAt.getTime() - startedAt.getTime();
|
|
1620
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1621
|
+
await db
|
|
1622
|
+
.update(pluginWebhookDeliveries)
|
|
1623
|
+
.set({
|
|
1624
|
+
status: "failed",
|
|
1625
|
+
durationMs,
|
|
1626
|
+
error: errorMessage,
|
|
1627
|
+
finishedAt,
|
|
1628
|
+
})
|
|
1629
|
+
.where(eq(pluginWebhookDeliveries.id, delivery.id));
|
|
1630
|
+
res.status(502).json({
|
|
1631
|
+
deliveryId: delivery.id,
|
|
1632
|
+
status: "failed",
|
|
1633
|
+
error: errorMessage,
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
// ===========================================================================
|
|
1638
|
+
// Plugin health dashboard — aggregated diagnostics for the settings page
|
|
1639
|
+
// ===========================================================================
|
|
1640
|
+
/**
|
|
1641
|
+
* GET /api/plugins/:pluginId/dashboard
|
|
1642
|
+
*
|
|
1643
|
+
* Aggregated health dashboard data for a plugin's settings page.
|
|
1644
|
+
*
|
|
1645
|
+
* Returns worker diagnostics (status, uptime, crash history), recent job
|
|
1646
|
+
* runs, recent webhook deliveries, and the current health check result —
|
|
1647
|
+
* all in a single response to avoid multiple round-trips.
|
|
1648
|
+
*
|
|
1649
|
+
* Response: PluginDashboardData
|
|
1650
|
+
* Errors: 404 if plugin not found
|
|
1651
|
+
*/
|
|
1652
|
+
router.get("/plugins/:pluginId/dashboard", async (req, res) => {
|
|
1653
|
+
assertBoard(req);
|
|
1654
|
+
const { pluginId } = req.params;
|
|
1655
|
+
const plugin = await resolvePlugin(registry, pluginId);
|
|
1656
|
+
if (!plugin) {
|
|
1657
|
+
res.status(404).json({ error: "Plugin not found" });
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
// --- Worker diagnostics ---
|
|
1661
|
+
let worker = null;
|
|
1662
|
+
// Try bridgeDeps first (primary source for worker manager), fallback to webhookDeps
|
|
1663
|
+
const wm = bridgeDeps?.workerManager ?? webhookDeps?.workerManager ?? null;
|
|
1664
|
+
if (wm) {
|
|
1665
|
+
const handle = wm.getWorker(plugin.id);
|
|
1666
|
+
if (handle) {
|
|
1667
|
+
const diag = handle.diagnostics();
|
|
1668
|
+
worker = {
|
|
1669
|
+
status: diag.status,
|
|
1670
|
+
pid: diag.pid,
|
|
1671
|
+
uptime: diag.uptime,
|
|
1672
|
+
consecutiveCrashes: diag.consecutiveCrashes,
|
|
1673
|
+
totalCrashes: diag.totalCrashes,
|
|
1674
|
+
pendingRequests: diag.pendingRequests,
|
|
1675
|
+
lastCrashAt: diag.lastCrashAt,
|
|
1676
|
+
nextRestartAt: diag.nextRestartAt,
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
// --- Recent job runs (last 10, newest first) ---
|
|
1681
|
+
let recentJobRuns = [];
|
|
1682
|
+
if (jobDeps) {
|
|
1683
|
+
try {
|
|
1684
|
+
const runs = await jobDeps.jobStore.listRunsByPlugin(plugin.id, undefined, 10);
|
|
1685
|
+
// Also fetch job definitions so we can include jobKey
|
|
1686
|
+
const jobs = await jobDeps.jobStore.listJobs(plugin.id);
|
|
1687
|
+
const jobKeyMap = new Map(jobs.map((j) => [j.id, j.jobKey]));
|
|
1688
|
+
recentJobRuns = runs
|
|
1689
|
+
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
|
|
1690
|
+
.map((r) => ({
|
|
1691
|
+
id: r.id,
|
|
1692
|
+
jobId: r.jobId,
|
|
1693
|
+
jobKey: jobKeyMap.get(r.jobId) ?? undefined,
|
|
1694
|
+
trigger: r.trigger,
|
|
1695
|
+
status: r.status,
|
|
1696
|
+
durationMs: r.durationMs,
|
|
1697
|
+
error: r.error,
|
|
1698
|
+
startedAt: r.startedAt ? new Date(r.startedAt).toISOString() : null,
|
|
1699
|
+
finishedAt: r.finishedAt ? new Date(r.finishedAt).toISOString() : null,
|
|
1700
|
+
createdAt: new Date(r.createdAt).toISOString(),
|
|
1701
|
+
}));
|
|
1702
|
+
}
|
|
1703
|
+
catch {
|
|
1704
|
+
// Job data unavailable — leave empty
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
// --- Recent webhook deliveries (last 10, newest first) ---
|
|
1708
|
+
let recentWebhookDeliveries = [];
|
|
1709
|
+
try {
|
|
1710
|
+
const deliveries = await db
|
|
1711
|
+
.select({
|
|
1712
|
+
id: pluginWebhookDeliveries.id,
|
|
1713
|
+
webhookKey: pluginWebhookDeliveries.webhookKey,
|
|
1714
|
+
status: pluginWebhookDeliveries.status,
|
|
1715
|
+
durationMs: pluginWebhookDeliveries.durationMs,
|
|
1716
|
+
error: pluginWebhookDeliveries.error,
|
|
1717
|
+
startedAt: pluginWebhookDeliveries.startedAt,
|
|
1718
|
+
finishedAt: pluginWebhookDeliveries.finishedAt,
|
|
1719
|
+
createdAt: pluginWebhookDeliveries.createdAt,
|
|
1720
|
+
})
|
|
1721
|
+
.from(pluginWebhookDeliveries)
|
|
1722
|
+
.where(eq(pluginWebhookDeliveries.pluginId, plugin.id))
|
|
1723
|
+
.orderBy(desc(pluginWebhookDeliveries.createdAt))
|
|
1724
|
+
.limit(10);
|
|
1725
|
+
recentWebhookDeliveries = deliveries.map((d) => ({
|
|
1726
|
+
id: d.id,
|
|
1727
|
+
webhookKey: d.webhookKey,
|
|
1728
|
+
status: d.status,
|
|
1729
|
+
durationMs: d.durationMs,
|
|
1730
|
+
error: d.error,
|
|
1731
|
+
startedAt: d.startedAt ? d.startedAt.toISOString() : null,
|
|
1732
|
+
finishedAt: d.finishedAt ? d.finishedAt.toISOString() : null,
|
|
1733
|
+
createdAt: d.createdAt.toISOString(),
|
|
1734
|
+
}));
|
|
1735
|
+
}
|
|
1736
|
+
catch {
|
|
1737
|
+
// Webhook data unavailable — leave empty
|
|
1738
|
+
}
|
|
1739
|
+
// --- Health check (same logic as GET /health) ---
|
|
1740
|
+
const checks = [];
|
|
1741
|
+
checks.push({
|
|
1742
|
+
name: "registry",
|
|
1743
|
+
passed: true,
|
|
1744
|
+
message: "Plugin found in registry",
|
|
1745
|
+
});
|
|
1746
|
+
const hasValidManifest = Boolean(plugin.manifestJson?.id);
|
|
1747
|
+
checks.push({
|
|
1748
|
+
name: "manifest",
|
|
1749
|
+
passed: hasValidManifest,
|
|
1750
|
+
message: hasValidManifest ? "Manifest is valid" : "Manifest is invalid or missing",
|
|
1751
|
+
});
|
|
1752
|
+
const isHealthy = plugin.status === "ready";
|
|
1753
|
+
checks.push({
|
|
1754
|
+
name: "status",
|
|
1755
|
+
passed: isHealthy,
|
|
1756
|
+
message: `Current status: ${plugin.status}`,
|
|
1757
|
+
});
|
|
1758
|
+
const hasNoError = !plugin.lastError;
|
|
1759
|
+
if (!hasNoError) {
|
|
1760
|
+
checks.push({
|
|
1761
|
+
name: "error_state",
|
|
1762
|
+
passed: false,
|
|
1763
|
+
message: plugin.lastError ?? undefined,
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
const health = {
|
|
1767
|
+
pluginId: plugin.id,
|
|
1768
|
+
status: plugin.status,
|
|
1769
|
+
healthy: isHealthy && hasValidManifest && hasNoError,
|
|
1770
|
+
checks,
|
|
1771
|
+
lastError: plugin.lastError ?? undefined,
|
|
1772
|
+
};
|
|
1773
|
+
res.json({
|
|
1774
|
+
pluginId: plugin.id,
|
|
1775
|
+
worker,
|
|
1776
|
+
recentJobRuns,
|
|
1777
|
+
recentWebhookDeliveries,
|
|
1778
|
+
health,
|
|
1779
|
+
checkedAt: new Date().toISOString(),
|
|
1780
|
+
});
|
|
1781
|
+
});
|
|
1782
|
+
return router;
|
|
1783
|
+
}
|
|
1784
|
+
//# sourceMappingURL=plugins.js.map
|