corporateai 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/.dockerignore +10 -0
- package/.env.example +3 -0
- package/.github/workflows/publish-cli.yml +49 -0
- package/.mailmap +1 -0
- package/AGENTS.md +148 -0
- package/CONTRIBUTING.md +75 -0
- package/Dockerfile +59 -0
- package/Dockerfile.onboard-smoke +42 -0
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/cli/esbuild.config.mjs +11 -0
- package/cli/package.json +24 -0
- package/cli/scripts/build-cli.mjs +5 -0
- package/cli/src/index.ts +27 -0
- package/docker-compose.quickstart.yml +18 -0
- package/docker-compose.untrusted-review.yml +33 -0
- package/docker-compose.yml +38 -0
- package/package.json +56 -0
- package/patches/embedded-postgres@18.1.0-beta.16.patch +0 -0
- package/pnpm-workspace.yaml +4 -0
- package/releases/.gitkeep +0 -0
- package/releases/v0.0.1.md +36 -0
- package/releases/v0.2.7.md +15 -0
- package/releases/v0.3.0.md +54 -0
- package/releases/v0.3.1.md +55 -0
- package/releases/v2026.318.0.md +66 -0
- package/releases/v2026.325.0.md +78 -0
- package/report/2026-03-13-08-46-token-optimization-implementation.md +48 -0
- package/scripts/backup-db.sh +17 -0
- package/scripts/build-npm.sh +80 -0
- package/scripts/check-forbidden-tokens.mjs +115 -0
- package/scripts/clean-onboard-git.sh +14 -0
- package/scripts/clean-onboard-npm.sh +13 -0
- package/scripts/clean-onboard-ref.sh +86 -0
- package/scripts/create-github-release.sh +99 -0
- package/scripts/dev-runner-paths.mjs +38 -0
- package/scripts/dev-runner.mjs +606 -0
- package/scripts/docker-onboard-smoke.sh +306 -0
- package/scripts/ensure-plugin-build-deps.mjs +47 -0
- package/scripts/generate-company-assets.ts +365 -0
- package/scripts/generate-npm-package-json.mjs +113 -0
- package/scripts/generate-org-chart-images.ts +694 -0
- package/scripts/generate-org-chart-satori-comparison.ts +225 -0
- package/scripts/generate-ui-package-json.mjs +31 -0
- package/scripts/kill-dev.sh +71 -0
- package/scripts/migrate-inline-env-secrets.ts +126 -0
- package/scripts/prepare-server-ui-dist.sh +22 -0
- package/scripts/provision-worktree.sh +333 -0
- package/scripts/release-lib.sh +306 -0
- package/scripts/release-package-map.mjs +169 -0
- package/scripts/release.sh +312 -0
- package/scripts/rollback-latest.sh +111 -0
- package/scripts/smoke/openclaw-docker-ui.sh +329 -0
- package/scripts/smoke/openclaw-gateway-e2e.sh +954 -0
- package/scripts/smoke/openclaw-join.sh +295 -0
- package/scripts/smoke/openclaw-sse-standalone.sh +146 -0
- package/scripts/workspace-compat.mjs +60 -0
- package/server/CHANGELOG.md +130 -0
- package/server/package.json +96 -0
- package/server/scripts/copy-onboarding-assets.mjs +10 -0
- package/server/scripts/dev-watch.ts +33 -0
- package/server/src/__tests__/activity-routes.test.ts +70 -0
- package/server/src/__tests__/adapter-models.test.ts +105 -0
- package/server/src/__tests__/adapter-session-codecs.test.ts +194 -0
- package/server/src/__tests__/agent-auth-jwt.test.ts +79 -0
- package/server/src/__tests__/agent-instructions-routes.test.ts +318 -0
- package/server/src/__tests__/agent-instructions-service.test.ts +361 -0
- package/server/src/__tests__/agent-permissions-routes.test.ts +275 -0
- package/server/src/__tests__/agent-shortname-collision.test.ts +69 -0
- package/server/src/__tests__/agent-skill-contract.test.ts +50 -0
- package/server/src/__tests__/agent-skills-routes.test.ts +462 -0
- package/server/src/__tests__/app-hmr-port.test.ts +19 -0
- package/server/src/__tests__/approval-routes-idempotency.test.ts +110 -0
- package/server/src/__tests__/approvals-service.test.ts +107 -0
- package/server/src/__tests__/assets.test.ts +250 -0
- package/server/src/__tests__/attachment-types.test.ts +97 -0
- package/server/src/__tests__/board-mutation-guard.test.ts +105 -0
- package/server/src/__tests__/budgets-service.test.ts +311 -0
- package/server/src/__tests__/claude-local-adapter-environment.test.ts +92 -0
- package/server/src/__tests__/claude-local-adapter.test.ts +31 -0
- package/server/src/__tests__/claude-local-skill-sync.test.ts +111 -0
- package/server/src/__tests__/cli-auth-routes.test.ts +230 -0
- package/server/src/__tests__/codex-local-adapter-environment.test.ts +143 -0
- package/server/src/__tests__/codex-local-adapter.test.ts +253 -0
- package/server/src/__tests__/codex-local-execute.test.ts +391 -0
- package/server/src/__tests__/codex-local-skill-injection.test.ts +175 -0
- package/server/src/__tests__/codex-local-skill-sync.test.ts +123 -0
- package/server/src/__tests__/companies-route-path-guard.test.ts +56 -0
- package/server/src/__tests__/company-branding-route.test.ts +196 -0
- package/server/src/__tests__/company-portability-routes.test.ts +175 -0
- package/server/src/__tests__/company-portability.test.ts +2186 -0
- package/server/src/__tests__/company-skills-routes.test.ts +113 -0
- package/server/src/__tests__/company-skills.test.ts +229 -0
- package/server/src/__tests__/costs-service.test.ts +226 -0
- package/server/src/__tests__/cursor-local-adapter-environment.test.ts +196 -0
- package/server/src/__tests__/cursor-local-adapter.test.ts +406 -0
- package/server/src/__tests__/cursor-local-execute.test.ts +263 -0
- package/server/src/__tests__/cursor-local-skill-injection.test.ts +104 -0
- package/server/src/__tests__/cursor-local-skill-sync.test.ts +145 -0
- package/server/src/__tests__/dev-runner-paths.test.ts +25 -0
- package/server/src/__tests__/dev-server-status.test.ts +66 -0
- package/server/src/__tests__/dev-watch-ignore.test.ts +42 -0
- package/server/src/__tests__/documents.test.ts +29 -0
- package/server/src/__tests__/error-handler.test.ts +53 -0
- package/server/src/__tests__/execution-workspace-policy.test.ts +170 -0
- package/server/src/__tests__/forbidden-tokens.test.ts +77 -0
- package/server/src/__tests__/gemini-local-adapter-environment.test.ts +135 -0
- package/server/src/__tests__/gemini-local-adapter.test.ts +190 -0
- package/server/src/__tests__/gemini-local-execute.test.ts +172 -0
- package/server/src/__tests__/gemini-local-skill-sync.test.ts +90 -0
- package/server/src/__tests__/health.test.ts +16 -0
- package/server/src/__tests__/heartbeat-process-recovery.test.ts +256 -0
- package/server/src/__tests__/heartbeat-run-summary.test.ts +33 -0
- package/server/src/__tests__/heartbeat-workspace-session.test.ts +334 -0
- package/server/src/__tests__/helpers/embedded-postgres.ts +7 -0
- package/server/src/__tests__/hire-hook.test.ts +181 -0
- package/server/src/__tests__/instance-settings-routes.test.ts +156 -0
- package/server/src/__tests__/invite-accept-gateway-defaults.test.ts +119 -0
- package/server/src/__tests__/invite-accept-replay.test.ts +92 -0
- package/server/src/__tests__/invite-expiry.test.ts +10 -0
- package/server/src/__tests__/invite-join-grants.test.ts +57 -0
- package/server/src/__tests__/invite-join-manager.test.ts +33 -0
- package/server/src/__tests__/invite-onboarding-text.test.ts +116 -0
- package/server/src/__tests__/issue-comment-reopen-routes.test.ts +146 -0
- package/server/src/__tests__/issue-goal-fallback.test.ts +99 -0
- package/server/src/__tests__/issues-checkout-wakeup.test.ts +48 -0
- package/server/src/__tests__/issues-goal-context-routes.test.ts +187 -0
- package/server/src/__tests__/issues-service.test.ts +317 -0
- package/server/src/__tests__/issues-user-context.test.ts +113 -0
- package/server/src/__tests__/log-redaction.test.ts +74 -0
- package/server/src/__tests__/monthly-spend-service.test.ts +90 -0
- package/server/src/__tests__/normalize-agent-mention-token.test.ts +41 -0
- package/server/src/__tests__/openclaw-gateway-adapter.test.ts +626 -0
- package/server/src/__tests__/openclaw-invite-prompt-route.test.ts +192 -0
- package/server/src/__tests__/opencode-local-adapter-environment.test.ts +97 -0
- package/server/src/__tests__/opencode-local-adapter.test.ts +226 -0
- package/server/src/__tests__/opencode-local-skill-sync.test.ts +91 -0
- package/server/src/__tests__/paperclip-env.test.ts +58 -0
- package/server/src/__tests__/paperclip-skill-utils.test.ts +63 -0
- package/server/src/__tests__/pi-local-adapter-environment.test.ts +102 -0
- package/server/src/__tests__/pi-local-skill-sync.test.ts +95 -0
- package/server/src/__tests__/plugin-dev-watcher.test.ts +68 -0
- package/server/src/__tests__/plugin-worker-manager.test.ts +43 -0
- package/server/src/__tests__/private-hostname-guard.test.ts +56 -0
- package/server/src/__tests__/project-shortname-resolution.test.ts +45 -0
- package/server/src/__tests__/quota-windows-service.test.ts +56 -0
- package/server/src/__tests__/quota-windows.test.ts +1109 -0
- package/server/src/__tests__/redaction.test.ts +66 -0
- package/server/src/__tests__/routines-e2e.test.ts +276 -0
- package/server/src/__tests__/routines-routes.test.ts +271 -0
- package/server/src/__tests__/routines-service.test.ts +424 -0
- package/server/src/__tests__/storage-local-provider.test.ts +78 -0
- package/server/src/__tests__/ui-branding.test.ts +82 -0
- package/server/src/__tests__/work-products.test.ts +95 -0
- package/server/src/__tests__/workspace-runtime.test.ts +1131 -0
- package/server/src/__tests__/worktree-config.test.ts +426 -0
- package/server/src/adapters/codex-models.ts +105 -0
- package/server/src/adapters/cursor-models.ts +171 -0
- package/server/src/adapters/http/execute.ts +42 -0
- package/server/src/adapters/http/index.ts +21 -0
- package/server/src/adapters/http/test.ts +116 -0
- package/server/src/adapters/index.ts +18 -0
- package/server/src/adapters/process/execute.ts +77 -0
- package/server/src/adapters/process/index.ts +24 -0
- package/server/src/adapters/process/test.ts +89 -0
- package/server/src/adapters/registry.ts +225 -0
- package/server/src/adapters/server-utils-compat.ts +57 -0
- package/server/src/adapters/types.ts +30 -0
- package/server/src/adapters/utils.ts +48 -0
- package/server/src/agent-auth-jwt.ts +141 -0
- package/server/src/app.ts +321 -0
- package/server/src/attachment-types.ts +74 -0
- package/server/src/auth/better-auth.ts +148 -0
- package/server/src/board-claim.ts +150 -0
- package/server/src/config-file.ts +17 -0
- package/server/src/config.ts +260 -0
- package/server/src/dev-server-status.ts +103 -0
- package/server/src/dev-watch-ignore.ts +36 -0
- package/server/src/errors.ts +34 -0
- package/server/src/home-paths.ts +95 -0
- package/server/src/index.ts +799 -0
- package/server/src/log-redaction.ts +146 -0
- package/server/src/middleware/auth.ts +178 -0
- package/server/src/middleware/board-mutation-guard.ts +66 -0
- package/server/src/middleware/error-handler.ts +71 -0
- package/server/src/middleware/index.ts +3 -0
- package/server/src/middleware/logger.ts +90 -0
- package/server/src/middleware/private-hostname-guard.ts +92 -0
- package/server/src/middleware/validate.ts +9 -0
- package/server/src/onboarding-assets/ceo/AGENTS.md +54 -0
- package/server/src/onboarding-assets/ceo/HEARTBEAT.md +72 -0
- package/server/src/onboarding-assets/ceo/SOUL.md +33 -0
- package/server/src/onboarding-assets/ceo/TOOLS.md +3 -0
- package/server/src/onboarding-assets/default/AGENTS.md +3 -0
- package/server/src/paths.ts +34 -0
- package/server/src/realtime/live-events-ws.ts +274 -0
- package/server/src/redaction.ts +59 -0
- package/server/src/routes/access.ts +2888 -0
- package/server/src/routes/activity.ts +89 -0
- package/server/src/routes/agents.ts +2313 -0
- package/server/src/routes/approvals.ts +346 -0
- package/server/src/routes/assets.ts +341 -0
- package/server/src/routes/authz.ts +52 -0
- package/server/src/routes/companies.ts +343 -0
- package/server/src/routes/company-skills.ts +300 -0
- package/server/src/routes/costs.ts +335 -0
- package/server/src/routes/dashboard.ts +19 -0
- package/server/src/routes/execution-workspaces.ts +182 -0
- package/server/src/routes/goals.ts +107 -0
- package/server/src/routes/health.ts +94 -0
- package/server/src/routes/index.ts +17 -0
- package/server/src/routes/instance-settings.ts +95 -0
- package/server/src/routes/issues-checkout-wakeup.ts +14 -0
- package/server/src/routes/issues.ts +1680 -0
- package/server/src/routes/llms.ts +86 -0
- package/server/src/routes/org-chart-svg.ts +777 -0
- package/server/src/routes/plugin-ui-static.ts +497 -0
- package/server/src/routes/plugins.ts +2220 -0
- package/server/src/routes/projects.ts +295 -0
- package/server/src/routes/routines.ts +300 -0
- package/server/src/routes/secrets.ts +166 -0
- package/server/src/routes/sidebar-badges.ts +52 -0
- package/server/src/secrets/external-stub-providers.ts +32 -0
- package/server/src/secrets/local-encrypted-provider.ts +135 -0
- package/server/src/secrets/provider-registry.ts +31 -0
- package/server/src/secrets/types.ts +23 -0
- package/server/src/services/access.ts +381 -0
- package/server/src/services/activity-log.ts +95 -0
- package/server/src/services/activity.ts +164 -0
- package/server/src/services/agent-instructions.ts +735 -0
- package/server/src/services/agent-permissions.ts +27 -0
- package/server/src/services/agents.ts +694 -0
- package/server/src/services/approvals.ts +273 -0
- package/server/src/services/assets.ts +23 -0
- package/server/src/services/board-auth.ts +355 -0
- package/server/src/services/budgets.ts +959 -0
- package/server/src/services/companies.ts +313 -0
- package/server/src/services/company-export-readme.ts +173 -0
- package/server/src/services/company-portability.ts +4263 -0
- package/server/src/services/company-skills.ts +2356 -0
- package/server/src/services/costs.ts +365 -0
- package/server/src/services/cron.ts +373 -0
- package/server/src/services/dashboard.ts +110 -0
- package/server/src/services/default-agent-instructions.ts +27 -0
- package/server/src/services/documents.ts +434 -0
- package/server/src/services/execution-workspace-policy.ts +210 -0
- package/server/src/services/execution-workspaces.ts +100 -0
- package/server/src/services/finance.ts +135 -0
- package/server/src/services/goals.ts +81 -0
- package/server/src/services/heartbeat-run-summary.ts +35 -0
- package/server/src/services/heartbeat.ts +3863 -0
- package/server/src/services/hire-hook.ts +114 -0
- package/server/src/services/index.ts +32 -0
- package/server/src/services/instance-settings.ts +138 -0
- package/server/src/services/issue-approvals.ts +175 -0
- package/server/src/services/issue-assignment-wakeup.ts +48 -0
- package/server/src/services/issue-goal-fallback.ts +56 -0
- package/server/src/services/issues.ts +1828 -0
- package/server/src/services/live-events.ts +55 -0
- package/server/src/services/plugin-capability-validator.ts +450 -0
- package/server/src/services/plugin-config-validator.ts +55 -0
- package/server/src/services/plugin-dev-watcher.ts +339 -0
- package/server/src/services/plugin-event-bus.ts +413 -0
- package/server/src/services/plugin-host-service-cleanup.ts +59 -0
- package/server/src/services/plugin-host-services.ts +1132 -0
- package/server/src/services/plugin-job-coordinator.ts +261 -0
- package/server/src/services/plugin-job-scheduler.ts +753 -0
- package/server/src/services/plugin-job-store.ts +466 -0
- package/server/src/services/plugin-lifecycle.ts +822 -0
- package/server/src/services/plugin-loader.ts +1955 -0
- package/server/src/services/plugin-log-retention.ts +87 -0
- package/server/src/services/plugin-manifest-validator.ts +164 -0
- package/server/src/services/plugin-registry.ts +683 -0
- package/server/src/services/plugin-runtime-sandbox.ts +222 -0
- package/server/src/services/plugin-secrets-handler.ts +355 -0
- package/server/src/services/plugin-state-store.ts +238 -0
- package/server/src/services/plugin-stream-bus.ts +81 -0
- package/server/src/services/plugin-tool-dispatcher.ts +449 -0
- package/server/src/services/plugin-tool-registry.ts +450 -0
- package/server/src/services/plugin-worker-manager.ts +1343 -0
- package/server/src/services/projects.ts +860 -0
- package/server/src/services/quota-windows.ts +65 -0
- package/server/src/services/routines.ts +1269 -0
- package/server/src/services/run-log-store.ts +156 -0
- package/server/src/services/secrets.ts +370 -0
- package/server/src/services/sidebar-badges.ts +56 -0
- package/server/src/services/work-products.ts +124 -0
- package/server/src/services/workspace-operation-log-store.ts +156 -0
- package/server/src/services/workspace-operations.ts +262 -0
- package/server/src/services/workspace-runtime.ts +1565 -0
- package/server/src/startup-banner.ts +176 -0
- package/server/src/storage/index.ts +35 -0
- package/server/src/storage/local-disk-provider.ts +89 -0
- package/server/src/storage/provider-registry.ts +18 -0
- package/server/src/storage/s3-provider.ts +153 -0
- package/server/src/storage/service.ts +131 -0
- package/server/src/storage/types.ts +63 -0
- package/server/src/ui-branding.ts +217 -0
- package/server/src/version.ts +10 -0
- package/server/src/worktree-config.ts +468 -0
- package/server/tsconfig.json +9 -0
- package/server/vitest.config.ts +7 -0
- package/skills/paperclip/SKILL.md +365 -0
- package/skills/paperclip/references/api-reference.md +647 -0
- package/skills/paperclip/references/company-skills.md +193 -0
- package/skills/paperclip-create-agent/SKILL.md +142 -0
- package/skills/paperclip-create-agent/references/api-reference.md +105 -0
- package/skills/paperclip-create-plugin/SKILL.md +102 -0
- package/skills/para-memory-files/SKILL.md +104 -0
- package/skills/para-memory-files/references/schemas.md +35 -0
- package/tests/e2e/onboarding.spec.ts +142 -0
- package/tests/e2e/playwright.config.ts +35 -0
- package/tests/release-smoke/docker-auth-onboarding.spec.ts +141 -0
- package/tests/release-smoke/playwright.config.ts +28 -0
- package/tsconfig.base.json +18 -0
- package/tsconfig.json +18 -0
- package/ui/README.md +12 -0
- package/ui/components.json +21 -0
- package/ui/index.html +47 -0
- package/ui/package.json +73 -0
- package/ui/public/android-chrome-192x192.png +0 -0
- package/ui/public/android-chrome-512x512.png +0 -0
- package/ui/public/apple-touch-icon.png +0 -0
- package/ui/public/brands/opencode-logo-dark-square.svg +18 -0
- package/ui/public/brands/opencode-logo-light-square.svg +18 -0
- package/ui/public/favicon-16x16.png +0 -0
- package/ui/public/favicon-32x32.png +0 -0
- package/ui/public/favicon.ico +0 -0
- package/ui/public/favicon.svg +9 -0
- package/ui/public/site.webmanifest +30 -0
- package/ui/public/sprites/1-D-1.png +0 -0
- package/ui/public/sprites/1-D-2.png +0 -0
- package/ui/public/sprites/1-D-3.png +0 -0
- package/ui/public/sprites/1-L-1.png +0 -0
- package/ui/public/sprites/1-R-1.png +0 -0
- package/ui/public/sprites/10-D-1.png +0 -0
- package/ui/public/sprites/10-D-2.png +0 -0
- package/ui/public/sprites/10-D-3.png +0 -0
- package/ui/public/sprites/10-L-1.png +0 -0
- package/ui/public/sprites/10-R-1.png +0 -0
- package/ui/public/sprites/11-D-1.png +0 -0
- package/ui/public/sprites/11-D-2.png +0 -0
- package/ui/public/sprites/11-D-3.png +0 -0
- package/ui/public/sprites/11-L-1.png +0 -0
- package/ui/public/sprites/11-R-1.png +0 -0
- package/ui/public/sprites/12-D-1.png +0 -0
- package/ui/public/sprites/12-D-2.png +0 -0
- package/ui/public/sprites/12-D-3.png +0 -0
- package/ui/public/sprites/12-L-1.png +0 -0
- package/ui/public/sprites/12-R-1.png +0 -0
- package/ui/public/sprites/13-D-1.png +0 -0
- package/ui/public/sprites/13-D-2.png +0 -0
- package/ui/public/sprites/13-D-3.png +0 -0
- package/ui/public/sprites/13-L-1.png +0 -0
- package/ui/public/sprites/13-R-1.png +0 -0
- package/ui/public/sprites/14-D-1.png +0 -0
- package/ui/public/sprites/14-D-2.png +0 -0
- package/ui/public/sprites/14-D-3.png +0 -0
- package/ui/public/sprites/14-L-1.png +0 -0
- package/ui/public/sprites/14-R-1.png +0 -0
- package/ui/public/sprites/2-D-1.png +0 -0
- package/ui/public/sprites/2-D-2.png +0 -0
- package/ui/public/sprites/2-D-3.png +0 -0
- package/ui/public/sprites/2-L-1.png +0 -0
- package/ui/public/sprites/2-R-1.png +0 -0
- package/ui/public/sprites/3-D-1.png +0 -0
- package/ui/public/sprites/3-D-2.png +0 -0
- package/ui/public/sprites/3-D-3.png +0 -0
- package/ui/public/sprites/3-L-1.png +0 -0
- package/ui/public/sprites/3-R-1.png +0 -0
- package/ui/public/sprites/4-D-1.png +0 -0
- package/ui/public/sprites/4-D-2.png +0 -0
- package/ui/public/sprites/4-D-3.png +0 -0
- package/ui/public/sprites/4-L-1.png +0 -0
- package/ui/public/sprites/4-R-1.png +0 -0
- package/ui/public/sprites/5-D-1.png +0 -0
- package/ui/public/sprites/5-D-2.png +0 -0
- package/ui/public/sprites/5-D-3.png +0 -0
- package/ui/public/sprites/5-L-1.png +0 -0
- package/ui/public/sprites/5-R-1.png +0 -0
- package/ui/public/sprites/6-D-1.png +0 -0
- package/ui/public/sprites/6-D-2.png +0 -0
- package/ui/public/sprites/6-D-3.png +0 -0
- package/ui/public/sprites/6-L-1.png +0 -0
- package/ui/public/sprites/6-R-1.png +0 -0
- package/ui/public/sprites/7-D-1.png +0 -0
- package/ui/public/sprites/7-D-2.png +0 -0
- package/ui/public/sprites/7-D-3.png +0 -0
- package/ui/public/sprites/7-L-1.png +0 -0
- package/ui/public/sprites/7-R-1.png +0 -0
- package/ui/public/sprites/8-D-1.png +0 -0
- package/ui/public/sprites/8-D-2.png +0 -0
- package/ui/public/sprites/8-D-3.png +0 -0
- package/ui/public/sprites/8-L-1.png +0 -0
- package/ui/public/sprites/8-R-1.png +0 -0
- package/ui/public/sprites/9-D-1.png +0 -0
- package/ui/public/sprites/9-D-2.png +0 -0
- package/ui/public/sprites/9-D-3.png +0 -0
- package/ui/public/sprites/9-L-1.png +0 -0
- package/ui/public/sprites/9-R-1.png +0 -0
- package/ui/public/sprites/ceo-lobster.png +0 -0
- package/ui/public/sw.js +42 -0
- package/ui/public/worktree-favicon-16x16.png +0 -0
- package/ui/public/worktree-favicon-32x32.png +0 -0
- package/ui/public/worktree-favicon.ico +0 -0
- package/ui/public/worktree-favicon.svg +9 -0
- package/ui/src/App.tsx +354 -0
- package/ui/src/adapters/claude-local/config-fields.tsx +138 -0
- package/ui/src/adapters/claude-local/index.ts +13 -0
- package/ui/src/adapters/codex-local/config-fields.tsx +104 -0
- package/ui/src/adapters/codex-local/index.ts +13 -0
- package/ui/src/adapters/cursor/config-fields.tsx +49 -0
- package/ui/src/adapters/cursor/index.ts +13 -0
- package/ui/src/adapters/gemini-local/config-fields.tsx +51 -0
- package/ui/src/adapters/gemini-local/index.ts +13 -0
- package/ui/src/adapters/http/build-config.ts +9 -0
- package/ui/src/adapters/http/config-fields.tsx +38 -0
- package/ui/src/adapters/http/index.ts +12 -0
- package/ui/src/adapters/http/parse-stdout.ts +5 -0
- package/ui/src/adapters/index.ts +9 -0
- package/ui/src/adapters/local-workspace-runtime-fields.tsx +5 -0
- package/ui/src/adapters/openclaw-gateway/config-fields.tsx +237 -0
- package/ui/src/adapters/openclaw-gateway/index.ts +13 -0
- package/ui/src/adapters/opencode-local/config-fields.tsx +72 -0
- package/ui/src/adapters/opencode-local/index.ts +13 -0
- package/ui/src/adapters/pi-local/config-fields.tsx +49 -0
- package/ui/src/adapters/pi-local/index.ts +13 -0
- package/ui/src/adapters/process/build-config.ts +18 -0
- package/ui/src/adapters/process/config-fields.tsx +77 -0
- package/ui/src/adapters/process/index.ts +12 -0
- package/ui/src/adapters/process/parse-stdout.ts +5 -0
- package/ui/src/adapters/registry.ts +34 -0
- package/ui/src/adapters/runtime-json-fields.tsx +122 -0
- package/ui/src/adapters/transcript.test.ts +30 -0
- package/ui/src/adapters/transcript.ts +62 -0
- package/ui/src/adapters/types.ts +34 -0
- package/ui/src/api/access.ts +160 -0
- package/ui/src/api/activity.ts +37 -0
- package/ui/src/api/agents.ts +194 -0
- package/ui/src/api/approvals.ts +25 -0
- package/ui/src/api/assets.ts +30 -0
- package/ui/src/api/auth.ts +74 -0
- package/ui/src/api/budgets.ts +21 -0
- package/ui/src/api/client.ts +50 -0
- package/ui/src/api/companies.ts +59 -0
- package/ui/src/api/companySkills.ts +55 -0
- package/ui/src/api/costs.ts +60 -0
- package/ui/src/api/dashboard.ts +7 -0
- package/ui/src/api/execution-workspaces.ts +27 -0
- package/ui/src/api/goals.ts +12 -0
- package/ui/src/api/health.ts +41 -0
- package/ui/src/api/heartbeats.ts +62 -0
- package/ui/src/api/index.ts +18 -0
- package/ui/src/api/instanceSettings.ts +19 -0
- package/ui/src/api/issues.ts +115 -0
- package/ui/src/api/plugins.ts +424 -0
- package/ui/src/api/projects.ts +34 -0
- package/ui/src/api/routines.ts +59 -0
- package/ui/src/api/secrets.ts +26 -0
- package/ui/src/api/sidebarBadges.ts +7 -0
- package/ui/src/components/AccountingModelCard.tsx +69 -0
- package/ui/src/components/ActiveAgentsPanel.tsx +157 -0
- package/ui/src/components/ActivityCharts.tsx +264 -0
- package/ui/src/components/ActivityRow.tsx +147 -0
- package/ui/src/components/AgentActionButtons.tsx +51 -0
- package/ui/src/components/AgentConfigForm.tsx +1468 -0
- package/ui/src/components/AgentIconPicker.tsx +81 -0
- package/ui/src/components/AgentProperties.tsx +107 -0
- package/ui/src/components/ApprovalCard.tsx +107 -0
- package/ui/src/components/ApprovalPayload.tsx +134 -0
- package/ui/src/components/AsciiArtAnimation.tsx +355 -0
- package/ui/src/components/BillerSpendCard.tsx +146 -0
- package/ui/src/components/BreadcrumbBar.tsx +113 -0
- package/ui/src/components/BudgetIncidentCard.tsx +101 -0
- package/ui/src/components/BudgetPolicyCard.tsx +220 -0
- package/ui/src/components/BudgetSidebarMarker.tsx +13 -0
- package/ui/src/components/ClaudeSubscriptionPanel.tsx +141 -0
- package/ui/src/components/CodexSubscriptionPanel.tsx +158 -0
- package/ui/src/components/CommandPalette.tsx +239 -0
- package/ui/src/components/CommentThread.tsx +503 -0
- package/ui/src/components/CompanyPatternIcon.tsx +212 -0
- package/ui/src/components/CompanyRail.tsx +329 -0
- package/ui/src/components/CompanySwitcher.tsx +81 -0
- package/ui/src/components/CopyText.tsx +56 -0
- package/ui/src/components/DevRestartBanner.tsx +89 -0
- package/ui/src/components/EmptyState.tsx +27 -0
- package/ui/src/components/EntityRow.tsx +69 -0
- package/ui/src/components/FilterBar.tsx +39 -0
- package/ui/src/components/FinanceBillerCard.tsx +45 -0
- package/ui/src/components/FinanceKindCard.tsx +44 -0
- package/ui/src/components/FinanceTimelineCard.tsx +72 -0
- package/ui/src/components/GoalProperties.tsx +165 -0
- package/ui/src/components/GoalTree.tsx +118 -0
- package/ui/src/components/Identity.tsx +39 -0
- package/ui/src/components/InlineEditor.tsx +248 -0
- package/ui/src/components/InlineEntitySelector.tsx +206 -0
- package/ui/src/components/InstanceSidebar.tsx +53 -0
- package/ui/src/components/IssueDocumentsSection.tsx +892 -0
- package/ui/src/components/IssueProperties.tsx +621 -0
- package/ui/src/components/IssueRow.tsx +149 -0
- package/ui/src/components/IssueWorkspaceCard.tsx +404 -0
- package/ui/src/components/IssuesList.tsx +889 -0
- package/ui/src/components/JsonSchemaForm.tsx +1048 -0
- package/ui/src/components/KanbanBoard.tsx +275 -0
- package/ui/src/components/Layout.tsx +441 -0
- package/ui/src/components/LiveRunWidget.tsx +160 -0
- package/ui/src/components/MarkdownBody.test.tsx +50 -0
- package/ui/src/components/MarkdownBody.tsx +152 -0
- package/ui/src/components/MarkdownEditor.tsx +622 -0
- package/ui/src/components/MetricCard.tsx +53 -0
- package/ui/src/components/MobileBottomNav.tsx +123 -0
- package/ui/src/components/NewAgentDialog.tsx +223 -0
- package/ui/src/components/NewGoalDialog.tsx +283 -0
- package/ui/src/components/NewIssueDialog.tsx +1473 -0
- package/ui/src/components/NewProjectDialog.tsx +451 -0
- package/ui/src/components/OnboardingWizard.tsx +1392 -0
- package/ui/src/components/OpenCodeLogoIcon.tsx +22 -0
- package/ui/src/components/PackageFileTree.tsx +318 -0
- package/ui/src/components/PageSkeleton.tsx +180 -0
- package/ui/src/components/PageTabBar.tsx +45 -0
- package/ui/src/components/PathInstructionsModal.tsx +143 -0
- package/ui/src/components/PriorityIcon.tsx +77 -0
- package/ui/src/components/ProjectProperties.tsx +1127 -0
- package/ui/src/components/PropertiesPanel.tsx +29 -0
- package/ui/src/components/ProviderQuotaCard.tsx +417 -0
- package/ui/src/components/QuotaBar.tsx +65 -0
- package/ui/src/components/ReportsToPicker.tsx +127 -0
- package/ui/src/components/ScheduleEditor.tsx +344 -0
- package/ui/src/components/ScrollToBottom.tsx +79 -0
- package/ui/src/components/Sidebar.tsx +130 -0
- package/ui/src/components/SidebarAgents.tsx +146 -0
- package/ui/src/components/SidebarNavItem.tsx +92 -0
- package/ui/src/components/SidebarProjects.tsx +234 -0
- package/ui/src/components/SidebarSection.tsx +17 -0
- package/ui/src/components/StatusBadge.tsx +15 -0
- package/ui/src/components/StatusIcon.tsx +71 -0
- package/ui/src/components/SwipeToArchive.tsx +152 -0
- package/ui/src/components/ToastViewport.tsx +99 -0
- package/ui/src/components/WorktreeBanner.tsx +25 -0
- package/ui/src/components/agent-config-defaults.ts +31 -0
- package/ui/src/components/agent-config-primitives.tsx +476 -0
- package/ui/src/components/transcript/RunTranscriptView.test.tsx +84 -0
- package/ui/src/components/transcript/RunTranscriptView.tsx +1015 -0
- package/ui/src/components/transcript/useLiveRunTranscripts.ts +297 -0
- package/ui/src/components/ui/avatar.tsx +107 -0
- package/ui/src/components/ui/badge.tsx +48 -0
- package/ui/src/components/ui/breadcrumb.tsx +109 -0
- package/ui/src/components/ui/button.tsx +64 -0
- package/ui/src/components/ui/card.tsx +92 -0
- package/ui/src/components/ui/checkbox.tsx +32 -0
- package/ui/src/components/ui/collapsible.tsx +33 -0
- package/ui/src/components/ui/command.tsx +194 -0
- package/ui/src/components/ui/dialog.tsx +156 -0
- package/ui/src/components/ui/dropdown-menu.tsx +257 -0
- package/ui/src/components/ui/input.tsx +21 -0
- package/ui/src/components/ui/label.tsx +22 -0
- package/ui/src/components/ui/popover.tsx +88 -0
- package/ui/src/components/ui/scroll-area.tsx +56 -0
- package/ui/src/components/ui/select.tsx +188 -0
- package/ui/src/components/ui/separator.tsx +28 -0
- package/ui/src/components/ui/sheet.tsx +143 -0
- package/ui/src/components/ui/skeleton.tsx +13 -0
- package/ui/src/components/ui/tabs.tsx +89 -0
- package/ui/src/components/ui/textarea.tsx +18 -0
- package/ui/src/components/ui/tooltip.tsx +57 -0
- package/ui/src/components/visual-office/AgentAvatar.tsx +99 -0
- package/ui/src/components/visual-office/OfficeViewExact.tsx +417 -0
- package/ui/src/components/visual-office/i18n.ts +52 -0
- package/ui/src/components/visual-office/office-view/CliUsagePanel.tsx +240 -0
- package/ui/src/components/visual-office/office-view/VirtualPadOverlay.tsx +104 -0
- package/ui/src/components/visual-office/office-view/buildScene-break-room.ts +248 -0
- package/ui/src/components/visual-office/office-view/buildScene-ceo-hallway.ts +345 -0
- package/ui/src/components/visual-office/office-view/buildScene-department-agent.ts +242 -0
- package/ui/src/components/visual-office/office-view/buildScene-departments.ts +360 -0
- package/ui/src/components/visual-office/office-view/buildScene-final-layers.ts +113 -0
- package/ui/src/components/visual-office/office-view/buildScene-types.ts +91 -0
- package/ui/src/components/visual-office/office-view/buildScene.ts +232 -0
- package/ui/src/components/visual-office/office-view/drawing-core.ts +374 -0
- package/ui/src/components/visual-office/office-view/drawing-furniture-a.ts +338 -0
- package/ui/src/components/visual-office/office-view/drawing-furniture-b.ts +241 -0
- package/ui/src/components/visual-office/office-view/model.ts +301 -0
- package/ui/src/components/visual-office/office-view/officeTicker.ts +455 -0
- package/ui/src/components/visual-office/office-view/officeTickerRoomAndDelivery.ts +133 -0
- package/ui/src/components/visual-office/office-view/themes-locale.ts +460 -0
- package/ui/src/components/visual-office/office-view/useCliUsage.ts +37 -0
- package/ui/src/components/visual-office/office-view/useOfficeDeliveryEffects.ts +465 -0
- package/ui/src/components/visual-office/office-view/useOfficePixiRuntime.ts +282 -0
- package/ui/src/components/visual-office/types.ts +123 -0
- package/ui/src/context/BreadcrumbContext.tsx +44 -0
- package/ui/src/context/CompanyContext.tsx +151 -0
- package/ui/src/context/DialogContext.tsx +135 -0
- package/ui/src/context/LiveUpdatesProvider.test.ts +119 -0
- package/ui/src/context/LiveUpdatesProvider.tsx +760 -0
- package/ui/src/context/PanelContext.tsx +73 -0
- package/ui/src/context/SidebarContext.tsx +43 -0
- package/ui/src/context/ThemeContext.tsx +83 -0
- package/ui/src/context/ToastContext.tsx +172 -0
- package/ui/src/fixtures/runTranscriptFixtures.ts +226 -0
- package/ui/src/hooks/useAgentOrder.ts +105 -0
- package/ui/src/hooks/useAutosaveIndicator.ts +72 -0
- package/ui/src/hooks/useCompanyPageMemory.test.ts +90 -0
- package/ui/src/hooks/useCompanyPageMemory.ts +79 -0
- package/ui/src/hooks/useDateRange.ts +120 -0
- package/ui/src/hooks/useInboxBadge.ts +132 -0
- package/ui/src/hooks/useKeyboardShortcuts.ts +40 -0
- package/ui/src/hooks/useProjectOrder.ts +106 -0
- package/ui/src/index.css +770 -0
- package/ui/src/lib/agent-icons.ts +99 -0
- package/ui/src/lib/agent-order.ts +107 -0
- package/ui/src/lib/agent-skills-state.test.ts +90 -0
- package/ui/src/lib/agent-skills-state.ts +41 -0
- package/ui/src/lib/assignees.test.ts +92 -0
- package/ui/src/lib/assignees.ts +82 -0
- package/ui/src/lib/color-contrast.ts +107 -0
- package/ui/src/lib/company-export-selection.test.ts +41 -0
- package/ui/src/lib/company-export-selection.ts +57 -0
- package/ui/src/lib/company-page-memory.ts +65 -0
- package/ui/src/lib/company-portability-sidebar.test.ts +101 -0
- package/ui/src/lib/company-portability-sidebar.ts +62 -0
- package/ui/src/lib/company-routes.ts +88 -0
- package/ui/src/lib/company-selection.test.ts +34 -0
- package/ui/src/lib/company-selection.ts +18 -0
- package/ui/src/lib/groupBy.ts +11 -0
- package/ui/src/lib/inbox.test.ts +404 -0
- package/ui/src/lib/inbox.ts +292 -0
- package/ui/src/lib/instance-settings.test.ts +26 -0
- package/ui/src/lib/instance-settings.ts +25 -0
- package/ui/src/lib/issueDetailBreadcrumb.ts +24 -0
- package/ui/src/lib/legacy-agent-config.test.ts +40 -0
- package/ui/src/lib/legacy-agent-config.ts +17 -0
- package/ui/src/lib/mention-aware-link-node.test.ts +50 -0
- package/ui/src/lib/mention-aware-link-node.ts +67 -0
- package/ui/src/lib/mention-chips.ts +168 -0
- package/ui/src/lib/mention-deletion.test.ts +87 -0
- package/ui/src/lib/mention-deletion.ts +143 -0
- package/ui/src/lib/model-utils.ts +16 -0
- package/ui/src/lib/onboarding-goal.test.ts +22 -0
- package/ui/src/lib/onboarding-goal.ts +18 -0
- package/ui/src/lib/onboarding-launch.test.ts +131 -0
- package/ui/src/lib/onboarding-launch.ts +54 -0
- package/ui/src/lib/onboarding-route.test.ts +80 -0
- package/ui/src/lib/onboarding-route.ts +51 -0
- package/ui/src/lib/portable-files.ts +42 -0
- package/ui/src/lib/project-order.ts +71 -0
- package/ui/src/lib/queryKeys.ts +140 -0
- package/ui/src/lib/recent-assignees.ts +36 -0
- package/ui/src/lib/router.tsx +76 -0
- package/ui/src/lib/routine-trigger-patch.test.ts +72 -0
- package/ui/src/lib/routine-trigger-patch.ts +31 -0
- package/ui/src/lib/status-colors.ts +108 -0
- package/ui/src/lib/timeAgo.ts +31 -0
- package/ui/src/lib/utils.ts +168 -0
- package/ui/src/lib/worktree-branding.ts +65 -0
- package/ui/src/lib/zip.test.ts +289 -0
- package/ui/src/lib/zip.ts +284 -0
- package/ui/src/main.tsx +67 -0
- package/ui/src/pages/Activity.tsx +141 -0
- package/ui/src/pages/AgentDetail.tsx +4053 -0
- package/ui/src/pages/Agents.tsx +415 -0
- package/ui/src/pages/ApprovalDetail.tsx +369 -0
- package/ui/src/pages/Approvals.tsx +132 -0
- package/ui/src/pages/Auth.tsx +180 -0
- package/ui/src/pages/BoardClaim.tsx +125 -0
- package/ui/src/pages/CliAuth.tsx +184 -0
- package/ui/src/pages/Companies.tsx +297 -0
- package/ui/src/pages/CompanyExport.tsx +1019 -0
- package/ui/src/pages/CompanyImport.tsx +1355 -0
- package/ui/src/pages/CompanySettings.tsx +661 -0
- package/ui/src/pages/CompanySkills.tsx +1171 -0
- package/ui/src/pages/Costs.tsx +1103 -0
- package/ui/src/pages/Dashboard.tsx +388 -0
- package/ui/src/pages/DesignGuide.tsx +1330 -0
- package/ui/src/pages/ExecutionWorkspaceDetail.tsx +82 -0
- package/ui/src/pages/GoalDetail.tsx +197 -0
- package/ui/src/pages/Goals.tsx +63 -0
- package/ui/src/pages/Inbox.tsx +1291 -0
- package/ui/src/pages/InstanceExperimentalSettings.tsx +139 -0
- package/ui/src/pages/InstanceGeneralSettings.tsx +104 -0
- package/ui/src/pages/InstanceSettings.tsx +284 -0
- package/ui/src/pages/InviteLanding.tsx +320 -0
- package/ui/src/pages/IssueDetail.tsx +1201 -0
- package/ui/src/pages/Issues.tsx +116 -0
- package/ui/src/pages/MyIssues.tsx +72 -0
- package/ui/src/pages/NewAgent.tsx +353 -0
- package/ui/src/pages/NotFound.tsx +66 -0
- package/ui/src/pages/Org.tsx +132 -0
- package/ui/src/pages/OrgChart.tsx +447 -0
- package/ui/src/pages/PluginManager.tsx +510 -0
- package/ui/src/pages/PluginPage.tsx +156 -0
- package/ui/src/pages/PluginSettings.tsx +836 -0
- package/ui/src/pages/ProjectDetail.tsx +633 -0
- package/ui/src/pages/Projects.tsx +87 -0
- package/ui/src/pages/RoutineDetail.tsx +1022 -0
- package/ui/src/pages/Routines.tsx +661 -0
- package/ui/src/pages/RunTranscriptUxLab.tsx +334 -0
- package/ui/src/pages/VisualOffice.tsx +243 -0
- package/ui/src/plugins/bridge-init.ts +69 -0
- package/ui/src/plugins/bridge.ts +476 -0
- package/ui/src/plugins/launchers.tsx +834 -0
- package/ui/src/plugins/slots.tsx +855 -0
- package/ui/tsconfig.json +21 -0
- package/ui/vite.config.ts +23 -0
- package/ui/vitest.config.ts +14 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
createContext,
|
|
4
|
+
createElement,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
type CSSProperties,
|
|
13
|
+
type ErrorInfo,
|
|
14
|
+
type KeyboardEvent as ReactKeyboardEvent,
|
|
15
|
+
type MouseEvent as ReactMouseEvent,
|
|
16
|
+
type ReactNode,
|
|
17
|
+
} from "react";
|
|
18
|
+
import { useQuery } from "@tanstack/react-query";
|
|
19
|
+
import { PLUGIN_LAUNCHER_BOUNDS } from "@corporateai/shared";
|
|
20
|
+
import type {
|
|
21
|
+
PluginLauncherBounds,
|
|
22
|
+
PluginLauncherDeclaration,
|
|
23
|
+
PluginLauncherPlacementZone,
|
|
24
|
+
PluginUiSlotEntityType,
|
|
25
|
+
} from "@corporateai/shared";
|
|
26
|
+
import { pluginsApi, type PluginUiContribution } from "@/api/plugins";
|
|
27
|
+
import { authApi } from "@/api/auth";
|
|
28
|
+
import { Button } from "@/components/ui/button";
|
|
29
|
+
import { useNavigate, useLocation } from "@/lib/router";
|
|
30
|
+
import { queryKeys } from "@/lib/queryKeys";
|
|
31
|
+
import { cn } from "@/lib/utils";
|
|
32
|
+
import {
|
|
33
|
+
PluginBridgeContext,
|
|
34
|
+
type PluginHostContext,
|
|
35
|
+
type PluginModalBoundsRequest,
|
|
36
|
+
type PluginRenderCloseEvent,
|
|
37
|
+
type PluginRenderCloseHandler,
|
|
38
|
+
type PluginRenderEnvironmentContext,
|
|
39
|
+
} from "./bridge";
|
|
40
|
+
import {
|
|
41
|
+
ensurePluginContributionLoaded,
|
|
42
|
+
resolveRegisteredPluginComponent,
|
|
43
|
+
type RegisteredPluginComponent,
|
|
44
|
+
} from "./slots";
|
|
45
|
+
|
|
46
|
+
export type PluginLauncherContext = {
|
|
47
|
+
companyId?: string | null;
|
|
48
|
+
companyPrefix?: string | null;
|
|
49
|
+
projectId?: string | null;
|
|
50
|
+
projectRef?: string | null;
|
|
51
|
+
entityId?: string | null;
|
|
52
|
+
entityType?: PluginUiSlotEntityType | null;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type ResolvedPluginLauncher = PluginLauncherDeclaration & {
|
|
56
|
+
pluginId: string;
|
|
57
|
+
pluginKey: string;
|
|
58
|
+
pluginDisplayName: string;
|
|
59
|
+
pluginVersion: string;
|
|
60
|
+
uiEntryFile: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type UsePluginLaunchersFilters = {
|
|
64
|
+
placementZones: PluginLauncherPlacementZone[];
|
|
65
|
+
entityType?: PluginUiSlotEntityType | null;
|
|
66
|
+
companyId?: string | null;
|
|
67
|
+
enabled?: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type UsePluginLaunchersResult = {
|
|
71
|
+
launchers: ResolvedPluginLauncher[];
|
|
72
|
+
contributionsByPluginId: Map<string, PluginUiContribution>;
|
|
73
|
+
isLoading: boolean;
|
|
74
|
+
errorMessage: string | null;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type PluginLauncherRuntimeContextValue = {
|
|
78
|
+
/**
|
|
79
|
+
* Open a launcher using already-discovered contribution metadata.
|
|
80
|
+
*
|
|
81
|
+
* The runtime accepts the normalized `PluginUiContribution` so callers can
|
|
82
|
+
* reuse the `/api/plugins/ui-contributions` payload they already fetched
|
|
83
|
+
* instead of issuing another request for each launcher activation.
|
|
84
|
+
*/
|
|
85
|
+
activateLauncher(
|
|
86
|
+
launcher: ResolvedPluginLauncher,
|
|
87
|
+
hostContext: PluginLauncherContext,
|
|
88
|
+
contribution: PluginUiContribution,
|
|
89
|
+
sourceEl?: HTMLElement | null,
|
|
90
|
+
): Promise<void>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type LauncherInstance = {
|
|
94
|
+
key: string;
|
|
95
|
+
launcher: ResolvedPluginLauncher;
|
|
96
|
+
hostContext: PluginLauncherContext;
|
|
97
|
+
contribution: PluginUiContribution;
|
|
98
|
+
component: RegisteredPluginComponent | null;
|
|
99
|
+
sourceElement: HTMLElement | null;
|
|
100
|
+
sourceRect: DOMRect | null;
|
|
101
|
+
bounds: PluginLauncherBounds | null;
|
|
102
|
+
beforeCloseHandlers: Set<PluginRenderCloseHandler>;
|
|
103
|
+
closeHandlers: Set<PluginRenderCloseHandler>;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const entityScopedZones = new Set<PluginLauncherPlacementZone>([
|
|
107
|
+
"detailTab",
|
|
108
|
+
"taskDetailView",
|
|
109
|
+
"contextMenuItem",
|
|
110
|
+
"commentAnnotation",
|
|
111
|
+
"commentContextMenuItem",
|
|
112
|
+
"projectSidebarItem",
|
|
113
|
+
"toolbarButton",
|
|
114
|
+
]);
|
|
115
|
+
const focusableElementSelector = [
|
|
116
|
+
"button:not([disabled])",
|
|
117
|
+
"[href]",
|
|
118
|
+
"input:not([disabled])",
|
|
119
|
+
"select:not([disabled])",
|
|
120
|
+
"textarea:not([disabled])",
|
|
121
|
+
"[tabindex]:not([tabindex='-1'])",
|
|
122
|
+
].join(",");
|
|
123
|
+
const launcherOverlayBaseZIndex = 1000;
|
|
124
|
+
const supportedLauncherBounds = new Set<PluginLauncherBounds>(
|
|
125
|
+
PLUGIN_LAUNCHER_BOUNDS,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const PluginLauncherRuntimeContext = createContext<PluginLauncherRuntimeContextValue | null>(null);
|
|
129
|
+
|
|
130
|
+
function getErrorMessage(error: unknown): string {
|
|
131
|
+
if (error instanceof Error && error.message) return error.message;
|
|
132
|
+
return "Unknown error";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function buildLauncherHostContext(
|
|
136
|
+
context: PluginLauncherContext,
|
|
137
|
+
renderEnvironment: PluginRenderEnvironmentContext | null,
|
|
138
|
+
userId: string | null,
|
|
139
|
+
): PluginHostContext {
|
|
140
|
+
return {
|
|
141
|
+
companyId: context.companyId ?? null,
|
|
142
|
+
companyPrefix: context.companyPrefix ?? null,
|
|
143
|
+
projectId: context.projectId ?? (context.entityType === "project" ? context.entityId ?? null : null),
|
|
144
|
+
entityId: context.entityId ?? null,
|
|
145
|
+
entityType: context.entityType ?? null,
|
|
146
|
+
userId,
|
|
147
|
+
renderEnvironment,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function focusFirstElement(container: HTMLElement | null): void {
|
|
152
|
+
if (!container) return;
|
|
153
|
+
const firstFocusable = container.querySelector<HTMLElement>(focusableElementSelector);
|
|
154
|
+
if (firstFocusable) {
|
|
155
|
+
firstFocusable.focus();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
container.focus();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function trapFocus(container: HTMLElement, event: KeyboardEvent): void {
|
|
162
|
+
if (event.key !== "Tab") return;
|
|
163
|
+
const focusable = Array.from(
|
|
164
|
+
container.querySelectorAll<HTMLElement>(focusableElementSelector),
|
|
165
|
+
).filter((el) => !el.hasAttribute("disabled") && el.tabIndex !== -1);
|
|
166
|
+
|
|
167
|
+
if (focusable.length === 0) {
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
container.focus();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const first = focusable[0];
|
|
174
|
+
const last = focusable[focusable.length - 1];
|
|
175
|
+
const active = document.activeElement as HTMLElement | null;
|
|
176
|
+
|
|
177
|
+
if (event.shiftKey && active === first) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
last.focus();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (!event.shiftKey && active === last) {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
first.focus();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function launcherTriggerClassName(placementZone: PluginLauncherPlacementZone): string {
|
|
190
|
+
switch (placementZone) {
|
|
191
|
+
case "projectSidebarItem":
|
|
192
|
+
return "justify-start h-auto px-3 py-1 text-[12px] font-normal text-muted-foreground hover:text-foreground";
|
|
193
|
+
case "contextMenuItem":
|
|
194
|
+
case "commentContextMenuItem":
|
|
195
|
+
return "justify-start h-7 w-full px-2 text-xs font-normal";
|
|
196
|
+
case "sidebar":
|
|
197
|
+
case "sidebarPanel":
|
|
198
|
+
return "justify-start h-8 w-full";
|
|
199
|
+
case "toolbarButton":
|
|
200
|
+
case "globalToolbarButton":
|
|
201
|
+
return "h-8";
|
|
202
|
+
default:
|
|
203
|
+
return "h-8";
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function launcherShellBoundsStyle(bounds: PluginLauncherBounds | null): CSSProperties {
|
|
208
|
+
switch (bounds) {
|
|
209
|
+
case "compact":
|
|
210
|
+
return { width: "min(28rem, calc(100vw - 2rem))" };
|
|
211
|
+
case "wide":
|
|
212
|
+
return { width: "min(64rem, calc(100vw - 2rem))" };
|
|
213
|
+
case "full":
|
|
214
|
+
return { width: "calc(100vw - 2rem)", height: "calc(100vh - 2rem)" };
|
|
215
|
+
case "inline":
|
|
216
|
+
return { width: "min(24rem, calc(100vw - 2rem))" };
|
|
217
|
+
case "default":
|
|
218
|
+
default:
|
|
219
|
+
return { width: "min(40rem, calc(100vw - 2rem))" };
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function launcherPopoverStyle(instance: LauncherInstance): CSSProperties {
|
|
224
|
+
const rect = instance.sourceRect;
|
|
225
|
+
const baseWidth = launcherShellBoundsStyle(instance.bounds).width ?? "min(24rem, calc(100vw - 2rem))";
|
|
226
|
+
if (!rect) {
|
|
227
|
+
return {
|
|
228
|
+
width: baseWidth,
|
|
229
|
+
maxHeight: "min(70vh, 36rem)",
|
|
230
|
+
top: "4rem",
|
|
231
|
+
left: "50%",
|
|
232
|
+
transform: "translateX(-50%)",
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const top = Math.min(rect.bottom + 8, window.innerHeight - 32);
|
|
237
|
+
const left = Math.min(
|
|
238
|
+
Math.max(rect.left, 16),
|
|
239
|
+
Math.max(16, window.innerWidth - 360),
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
width: baseWidth,
|
|
244
|
+
maxHeight: "min(70vh, 36rem)",
|
|
245
|
+
top,
|
|
246
|
+
left,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function isPluginLauncherBounds(value: unknown): value is PluginLauncherBounds {
|
|
251
|
+
return typeof value === "string" && supportedLauncherBounds.has(value as PluginLauncherBounds);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Discover launchers for the requested host placement zones from the normalized
|
|
256
|
+
* `/api/plugins/ui-contributions` response.
|
|
257
|
+
*
|
|
258
|
+
* This is the shared discovery path for toolbar, sidebar, detail-view, and
|
|
259
|
+
* context-menu launchers. The hook applies host-side entity filtering and
|
|
260
|
+
* returns both the sorted launcher list and a contribution map so activation
|
|
261
|
+
* can stay on cached metadata.
|
|
262
|
+
*/
|
|
263
|
+
export function usePluginLaunchers(
|
|
264
|
+
filters: UsePluginLaunchersFilters,
|
|
265
|
+
): UsePluginLaunchersResult {
|
|
266
|
+
const queryEnabled = filters.enabled ?? true;
|
|
267
|
+
const { data, isLoading, error } = useQuery({
|
|
268
|
+
queryKey: queryKeys.plugins.uiContributions,
|
|
269
|
+
queryFn: () => pluginsApi.listUiContributions(),
|
|
270
|
+
enabled: queryEnabled,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const placementZonesKey = useMemo(
|
|
274
|
+
() => [...filters.placementZones].sort().join("|"),
|
|
275
|
+
[filters.placementZones],
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const contributionsByPluginId = useMemo(() => {
|
|
279
|
+
const byPluginId = new Map<string, PluginUiContribution>();
|
|
280
|
+
for (const contribution of data ?? []) {
|
|
281
|
+
byPluginId.set(contribution.pluginId, contribution);
|
|
282
|
+
}
|
|
283
|
+
return byPluginId;
|
|
284
|
+
}, [data]);
|
|
285
|
+
|
|
286
|
+
const launchers = useMemo(() => {
|
|
287
|
+
const placementZones = new Set(
|
|
288
|
+
placementZonesKey.split("|").filter(Boolean) as PluginLauncherPlacementZone[],
|
|
289
|
+
);
|
|
290
|
+
const rows: ResolvedPluginLauncher[] = [];
|
|
291
|
+
for (const contribution of data ?? []) {
|
|
292
|
+
for (const launcher of contribution.launchers) {
|
|
293
|
+
if (!placementZones.has(launcher.placementZone)) continue;
|
|
294
|
+
if (entityScopedZones.has(launcher.placementZone)) {
|
|
295
|
+
if (!filters.entityType) continue;
|
|
296
|
+
if (!launcher.entityTypes?.includes(filters.entityType)) continue;
|
|
297
|
+
}
|
|
298
|
+
rows.push({
|
|
299
|
+
...launcher,
|
|
300
|
+
pluginId: contribution.pluginId,
|
|
301
|
+
pluginKey: contribution.pluginKey,
|
|
302
|
+
pluginDisplayName: contribution.displayName,
|
|
303
|
+
pluginVersion: contribution.version,
|
|
304
|
+
uiEntryFile: contribution.uiEntryFile,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
rows.sort((a, b) => {
|
|
310
|
+
const ao = a.order ?? Number.MAX_SAFE_INTEGER;
|
|
311
|
+
const bo = b.order ?? Number.MAX_SAFE_INTEGER;
|
|
312
|
+
if (ao !== bo) return ao - bo;
|
|
313
|
+
const pluginCmp = a.pluginDisplayName.localeCompare(b.pluginDisplayName);
|
|
314
|
+
if (pluginCmp !== 0) return pluginCmp;
|
|
315
|
+
return a.displayName.localeCompare(b.displayName);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
return rows;
|
|
319
|
+
}, [data, filters.entityType, placementZonesKey]);
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
launchers,
|
|
323
|
+
contributionsByPluginId,
|
|
324
|
+
isLoading: queryEnabled && isLoading,
|
|
325
|
+
errorMessage: error ? getErrorMessage(error) : null,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async function resolveLauncherComponent(
|
|
330
|
+
contribution: PluginUiContribution,
|
|
331
|
+
launcher: ResolvedPluginLauncher,
|
|
332
|
+
): Promise<RegisteredPluginComponent | null> {
|
|
333
|
+
const exportName = launcher.action.target;
|
|
334
|
+
const existing = resolveRegisteredPluginComponent(launcher.pluginKey, exportName);
|
|
335
|
+
if (existing) return existing;
|
|
336
|
+
await ensurePluginContributionLoaded(contribution);
|
|
337
|
+
return resolveRegisteredPluginComponent(launcher.pluginKey, exportName);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Scope bridge calls to the currently rendered launcher host context.
|
|
342
|
+
*
|
|
343
|
+
* Hooks such as `useHostContext()`, `usePluginData()`, and `usePluginAction()`
|
|
344
|
+
* consume this ambient context so the bridge can forward company/entity scope
|
|
345
|
+
* and render-environment metadata to the plugin worker.
|
|
346
|
+
*/
|
|
347
|
+
function PluginLauncherBridgeScope({
|
|
348
|
+
pluginId,
|
|
349
|
+
hostContext,
|
|
350
|
+
children,
|
|
351
|
+
}: {
|
|
352
|
+
pluginId: string;
|
|
353
|
+
hostContext: PluginHostContext;
|
|
354
|
+
children: ReactNode;
|
|
355
|
+
}) {
|
|
356
|
+
const value = useMemo(() => ({ pluginId, hostContext }), [pluginId, hostContext]);
|
|
357
|
+
|
|
358
|
+
return (
|
|
359
|
+
<PluginBridgeContext.Provider value={value}>
|
|
360
|
+
{children}
|
|
361
|
+
</PluginBridgeContext.Provider>
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
type LauncherErrorBoundaryProps = {
|
|
366
|
+
launcher: ResolvedPluginLauncher;
|
|
367
|
+
children: ReactNode;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
type LauncherErrorBoundaryState = {
|
|
371
|
+
hasError: boolean;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
class LauncherErrorBoundary extends Component<LauncherErrorBoundaryProps, LauncherErrorBoundaryState> {
|
|
375
|
+
override state: LauncherErrorBoundaryState = { hasError: false };
|
|
376
|
+
|
|
377
|
+
static getDerivedStateFromError(): LauncherErrorBoundaryState {
|
|
378
|
+
return { hasError: true };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
override componentDidCatch(error: unknown, info: ErrorInfo): void {
|
|
382
|
+
console.error("Plugin launcher render failed", {
|
|
383
|
+
pluginKey: this.props.launcher.pluginKey,
|
|
384
|
+
launcherId: this.props.launcher.id,
|
|
385
|
+
error,
|
|
386
|
+
info: info.componentStack,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
override render() {
|
|
391
|
+
if (this.state.hasError) {
|
|
392
|
+
return (
|
|
393
|
+
<div className="rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive">
|
|
394
|
+
{this.props.launcher.pluginDisplayName}: failed to render
|
|
395
|
+
</div>
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
return this.props.children;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function LauncherRenderContent({
|
|
403
|
+
instance,
|
|
404
|
+
renderEnvironment,
|
|
405
|
+
}: {
|
|
406
|
+
instance: LauncherInstance;
|
|
407
|
+
renderEnvironment: PluginRenderEnvironmentContext;
|
|
408
|
+
}) {
|
|
409
|
+
const component = instance.component;
|
|
410
|
+
const { data: session } = useQuery({
|
|
411
|
+
queryKey: queryKeys.auth.session,
|
|
412
|
+
queryFn: () => authApi.getSession(),
|
|
413
|
+
});
|
|
414
|
+
const userId = session?.user?.id ?? session?.session?.userId ?? null;
|
|
415
|
+
const hostContext = useMemo(
|
|
416
|
+
() => buildLauncherHostContext(instance.hostContext, renderEnvironment, userId),
|
|
417
|
+
[instance.hostContext, renderEnvironment, userId],
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
if (!component) {
|
|
421
|
+
if (renderEnvironment.environment === "iframe") {
|
|
422
|
+
return (
|
|
423
|
+
<iframe
|
|
424
|
+
src={`/_plugins/${encodeURIComponent(instance.launcher.pluginId)}/ui/${instance.launcher.action.target}`}
|
|
425
|
+
title={`${instance.launcher.pluginDisplayName} ${instance.launcher.displayName}`}
|
|
426
|
+
className="h-full min-h-[24rem] w-full rounded-md border border-border bg-background"
|
|
427
|
+
/>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return (
|
|
432
|
+
<div className="rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive">
|
|
433
|
+
{instance.launcher.pluginDisplayName}: could not resolve launcher target "{instance.launcher.action.target}".
|
|
434
|
+
</div>
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (component.kind === "web-component") {
|
|
439
|
+
return createElement(component.tagName, {
|
|
440
|
+
className: "block w-full",
|
|
441
|
+
pluginLauncher: instance.launcher,
|
|
442
|
+
pluginContext: hostContext,
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const node = createElement(component.component as never, {
|
|
447
|
+
launcher: instance.launcher,
|
|
448
|
+
context: hostContext,
|
|
449
|
+
} as never);
|
|
450
|
+
|
|
451
|
+
return (
|
|
452
|
+
<LauncherErrorBoundary launcher={instance.launcher}>
|
|
453
|
+
<PluginLauncherBridgeScope pluginId={instance.launcher.pluginId} hostContext={hostContext}>
|
|
454
|
+
{node}
|
|
455
|
+
</PluginLauncherBridgeScope>
|
|
456
|
+
</LauncherErrorBoundary>
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function LauncherModalShell({
|
|
461
|
+
instance,
|
|
462
|
+
stackIndex,
|
|
463
|
+
isTopmost,
|
|
464
|
+
requestBounds,
|
|
465
|
+
closeLauncher,
|
|
466
|
+
}: {
|
|
467
|
+
instance: LauncherInstance;
|
|
468
|
+
stackIndex: number;
|
|
469
|
+
isTopmost: boolean;
|
|
470
|
+
requestBounds: (key: string, request: PluginModalBoundsRequest) => Promise<void>;
|
|
471
|
+
closeLauncher: (key: string, event: PluginRenderCloseEvent) => Promise<void>;
|
|
472
|
+
}) {
|
|
473
|
+
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
474
|
+
const titleId = useId();
|
|
475
|
+
|
|
476
|
+
useEffect(() => {
|
|
477
|
+
if (!isTopmost) return;
|
|
478
|
+
const frame = requestAnimationFrame(() => {
|
|
479
|
+
focusFirstElement(contentRef.current);
|
|
480
|
+
});
|
|
481
|
+
return () => cancelAnimationFrame(frame);
|
|
482
|
+
}, [isTopmost]);
|
|
483
|
+
|
|
484
|
+
useEffect(() => {
|
|
485
|
+
if (!isTopmost) return;
|
|
486
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
487
|
+
if (!contentRef.current) return;
|
|
488
|
+
if (event.key === "Escape") {
|
|
489
|
+
event.preventDefault();
|
|
490
|
+
void closeLauncher(instance.key, { reason: "escapeKey", nativeEvent: event });
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
trapFocus(contentRef.current, event);
|
|
494
|
+
};
|
|
495
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
496
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
497
|
+
}, [closeLauncher, instance.key, isTopmost]);
|
|
498
|
+
|
|
499
|
+
const renderEnvironment = useMemo<PluginRenderEnvironmentContext>(() => ({
|
|
500
|
+
environment: instance.launcher.render?.environment ?? "hostOverlay",
|
|
501
|
+
launcherId: instance.launcher.id,
|
|
502
|
+
bounds: instance.bounds,
|
|
503
|
+
requestModalBounds: (request) => requestBounds(instance.key, request),
|
|
504
|
+
closeLifecycle: {
|
|
505
|
+
onBeforeClose: (handler) => {
|
|
506
|
+
instance.beforeCloseHandlers.add(handler);
|
|
507
|
+
return () => instance.beforeCloseHandlers.delete(handler);
|
|
508
|
+
},
|
|
509
|
+
onClose: (handler) => {
|
|
510
|
+
instance.closeHandlers.add(handler);
|
|
511
|
+
return () => instance.closeHandlers.delete(handler);
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
}), [instance, requestBounds]);
|
|
515
|
+
|
|
516
|
+
const baseZ = launcherOverlayBaseZIndex + stackIndex * 20;
|
|
517
|
+
// Keep each launcher in a deterministic z-index band so every stacked modal,
|
|
518
|
+
// drawer, or popover retains its own backdrop/panel pairing.
|
|
519
|
+
const shellType = instance.launcher.action.type;
|
|
520
|
+
const containerStyle = shellType === "openPopover"
|
|
521
|
+
? launcherPopoverStyle(instance)
|
|
522
|
+
: launcherShellBoundsStyle(instance.bounds);
|
|
523
|
+
|
|
524
|
+
const panelClassName = shellType === "openDrawer"
|
|
525
|
+
? "fixed right-0 top-0 h-full max-w-[min(44rem,100vw)] overflow-hidden border-l border-border bg-background shadow-2xl"
|
|
526
|
+
: shellType === "openPopover"
|
|
527
|
+
? "fixed overflow-hidden rounded-xl border border-border bg-background shadow-2xl"
|
|
528
|
+
: "fixed left-1/2 top-1/2 max-h-[calc(100vh-2rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-2xl border border-border bg-background shadow-2xl";
|
|
529
|
+
|
|
530
|
+
return (
|
|
531
|
+
<>
|
|
532
|
+
<div
|
|
533
|
+
className="fixed inset-0 bg-black/45"
|
|
534
|
+
style={{ zIndex: baseZ }}
|
|
535
|
+
aria-hidden="true"
|
|
536
|
+
onMouseDown={(event) => {
|
|
537
|
+
if (!isTopmost) return;
|
|
538
|
+
if (event.target !== event.currentTarget) return;
|
|
539
|
+
void closeLauncher(instance.key, { reason: "backdrop", nativeEvent: event });
|
|
540
|
+
}}
|
|
541
|
+
/>
|
|
542
|
+
<div
|
|
543
|
+
ref={contentRef}
|
|
544
|
+
role="dialog"
|
|
545
|
+
aria-modal="true"
|
|
546
|
+
aria-labelledby={titleId}
|
|
547
|
+
tabIndex={-1}
|
|
548
|
+
className={panelClassName}
|
|
549
|
+
style={{
|
|
550
|
+
zIndex: baseZ + 1,
|
|
551
|
+
...(shellType === "openDrawer"
|
|
552
|
+
? { width: containerStyle.width ?? "min(44rem, 100vw)" }
|
|
553
|
+
: containerStyle),
|
|
554
|
+
}}
|
|
555
|
+
onMouseDown={(event) => event.stopPropagation()}
|
|
556
|
+
>
|
|
557
|
+
<div className="flex items-center gap-3 border-b border-border px-4 py-3">
|
|
558
|
+
<div className="min-w-0">
|
|
559
|
+
<h2 id={titleId} className="truncate text-sm font-semibold">
|
|
560
|
+
{instance.launcher.displayName}
|
|
561
|
+
</h2>
|
|
562
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
563
|
+
{instance.launcher.pluginDisplayName}
|
|
564
|
+
</p>
|
|
565
|
+
</div>
|
|
566
|
+
<Button
|
|
567
|
+
type="button"
|
|
568
|
+
variant="ghost"
|
|
569
|
+
size="sm"
|
|
570
|
+
className="ml-auto"
|
|
571
|
+
onClick={() => void closeLauncher(instance.key, { reason: "programmatic" })}
|
|
572
|
+
>
|
|
573
|
+
Close
|
|
574
|
+
</Button>
|
|
575
|
+
</div>
|
|
576
|
+
<div
|
|
577
|
+
className={cn(
|
|
578
|
+
"overflow-auto p-4",
|
|
579
|
+
shellType === "openDrawer" ? "h-[calc(100%-3.5rem)]" : "max-h-[calc(100vh-7rem)]",
|
|
580
|
+
)}
|
|
581
|
+
>
|
|
582
|
+
<LauncherRenderContent instance={instance} renderEnvironment={renderEnvironment} />
|
|
583
|
+
</div>
|
|
584
|
+
</div>
|
|
585
|
+
</>
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
export function PluginLauncherProvider({ children }: { children: ReactNode }) {
|
|
590
|
+
const [stack, setStack] = useState<LauncherInstance[]>([]);
|
|
591
|
+
const stackRef = useRef(stack);
|
|
592
|
+
stackRef.current = stack;
|
|
593
|
+
const location = useLocation();
|
|
594
|
+
const navigate = useNavigate();
|
|
595
|
+
|
|
596
|
+
const closeLauncher = useCallback(
|
|
597
|
+
async (key: string, event: PluginRenderCloseEvent) => {
|
|
598
|
+
const instance = stackRef.current.find((entry) => entry.key === key);
|
|
599
|
+
if (!instance) return;
|
|
600
|
+
|
|
601
|
+
for (const handler of [...instance.beforeCloseHandlers]) {
|
|
602
|
+
await handler(event);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
setStack((current) => current.filter((entry) => entry.key !== key));
|
|
606
|
+
|
|
607
|
+
queueMicrotask(() => {
|
|
608
|
+
for (const handler of [...instance.closeHandlers]) {
|
|
609
|
+
void handler(event);
|
|
610
|
+
}
|
|
611
|
+
if (instance.sourceElement && document.contains(instance.sourceElement)) {
|
|
612
|
+
instance.sourceElement.focus();
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
},
|
|
616
|
+
[],
|
|
617
|
+
);
|
|
618
|
+
|
|
619
|
+
useEffect(() => {
|
|
620
|
+
if (stack.length === 0) return;
|
|
621
|
+
void Promise.all(
|
|
622
|
+
stack.map((entry) => closeLauncher(entry.key, { reason: "hostNavigation" })),
|
|
623
|
+
);
|
|
624
|
+
// Only react to navigation changes, not stack churn.
|
|
625
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
626
|
+
}, [location.key]);
|
|
627
|
+
|
|
628
|
+
const requestBounds = useCallback(
|
|
629
|
+
async (key: string, request: PluginModalBoundsRequest) => {
|
|
630
|
+
// Bounds changes are host-validated. Unsupported presets are ignored so
|
|
631
|
+
// plugin UI cannot push the shell into an undefined layout state.
|
|
632
|
+
if (!isPluginLauncherBounds(request.bounds)) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
setStack((current) =>
|
|
636
|
+
current.map((entry) =>
|
|
637
|
+
entry.key === key
|
|
638
|
+
? { ...entry, bounds: request.bounds }
|
|
639
|
+
: entry,
|
|
640
|
+
),
|
|
641
|
+
);
|
|
642
|
+
},
|
|
643
|
+
[],
|
|
644
|
+
);
|
|
645
|
+
|
|
646
|
+
const activateLauncher = useCallback(
|
|
647
|
+
async (
|
|
648
|
+
launcher: ResolvedPluginLauncher,
|
|
649
|
+
hostContext: PluginLauncherContext,
|
|
650
|
+
contribution: PluginUiContribution,
|
|
651
|
+
sourceEl?: HTMLElement | null,
|
|
652
|
+
) => {
|
|
653
|
+
switch (launcher.action.type) {
|
|
654
|
+
case "navigate":
|
|
655
|
+
navigate(launcher.action.target);
|
|
656
|
+
return;
|
|
657
|
+
case "deepLink":
|
|
658
|
+
if (/^https?:\/\//.test(launcher.action.target)) {
|
|
659
|
+
window.open(launcher.action.target, "_blank", "noopener,noreferrer");
|
|
660
|
+
} else {
|
|
661
|
+
navigate(launcher.action.target);
|
|
662
|
+
}
|
|
663
|
+
return;
|
|
664
|
+
case "performAction":
|
|
665
|
+
await pluginsApi.bridgePerformAction(
|
|
666
|
+
launcher.pluginId,
|
|
667
|
+
launcher.action.target,
|
|
668
|
+
launcher.action.params,
|
|
669
|
+
hostContext.companyId ?? null,
|
|
670
|
+
);
|
|
671
|
+
return;
|
|
672
|
+
case "openModal":
|
|
673
|
+
case "openDrawer":
|
|
674
|
+
case "openPopover": {
|
|
675
|
+
const component = await resolveLauncherComponent(contribution, launcher);
|
|
676
|
+
const sourceRect = sourceEl?.getBoundingClientRect() ?? null;
|
|
677
|
+
const nextEntry: LauncherInstance = {
|
|
678
|
+
key: `${launcher.pluginId}:${launcher.id}:${Date.now()}:${Math.random().toString(36).slice(2, 8)}`,
|
|
679
|
+
launcher,
|
|
680
|
+
hostContext,
|
|
681
|
+
contribution,
|
|
682
|
+
component,
|
|
683
|
+
sourceElement: sourceEl ?? null,
|
|
684
|
+
sourceRect,
|
|
685
|
+
bounds: launcher.render?.bounds ?? "default",
|
|
686
|
+
beforeCloseHandlers: new Set(),
|
|
687
|
+
closeHandlers: new Set(),
|
|
688
|
+
};
|
|
689
|
+
setStack((current) => [...current, nextEntry]);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
[navigate],
|
|
695
|
+
);
|
|
696
|
+
|
|
697
|
+
const value = useMemo<PluginLauncherRuntimeContextValue>(
|
|
698
|
+
() => ({ activateLauncher }),
|
|
699
|
+
[activateLauncher],
|
|
700
|
+
);
|
|
701
|
+
|
|
702
|
+
return (
|
|
703
|
+
<PluginLauncherRuntimeContext.Provider value={value}>
|
|
704
|
+
{children}
|
|
705
|
+
{stack.map((instance, index) => (
|
|
706
|
+
<LauncherModalShell
|
|
707
|
+
key={instance.key}
|
|
708
|
+
instance={instance}
|
|
709
|
+
stackIndex={index}
|
|
710
|
+
isTopmost={index === stack.length - 1}
|
|
711
|
+
requestBounds={requestBounds}
|
|
712
|
+
closeLauncher={closeLauncher}
|
|
713
|
+
/>
|
|
714
|
+
))}
|
|
715
|
+
</PluginLauncherRuntimeContext.Provider>
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
export function usePluginLauncherRuntime(): PluginLauncherRuntimeContextValue {
|
|
720
|
+
const value = useContext(PluginLauncherRuntimeContext);
|
|
721
|
+
if (!value) {
|
|
722
|
+
throw new Error("usePluginLauncherRuntime must be used within PluginLauncherProvider");
|
|
723
|
+
}
|
|
724
|
+
return value;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function DefaultLauncherTrigger({
|
|
728
|
+
launcher,
|
|
729
|
+
placementZone,
|
|
730
|
+
onClick,
|
|
731
|
+
}: {
|
|
732
|
+
launcher: ResolvedPluginLauncher;
|
|
733
|
+
placementZone: PluginLauncherPlacementZone;
|
|
734
|
+
onClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
735
|
+
}) {
|
|
736
|
+
return (
|
|
737
|
+
<Button
|
|
738
|
+
type="button"
|
|
739
|
+
variant={placementZone === "toolbarButton" || placementZone === "globalToolbarButton" ? "outline" : "ghost"}
|
|
740
|
+
size="sm"
|
|
741
|
+
className={launcherTriggerClassName(placementZone)}
|
|
742
|
+
onClick={onClick}
|
|
743
|
+
>
|
|
744
|
+
{launcher.displayName}
|
|
745
|
+
</Button>
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
type PluginLauncherOutletProps = {
|
|
750
|
+
placementZones: PluginLauncherPlacementZone[];
|
|
751
|
+
context: PluginLauncherContext;
|
|
752
|
+
entityType?: PluginUiSlotEntityType | null;
|
|
753
|
+
className?: string;
|
|
754
|
+
itemClassName?: string;
|
|
755
|
+
errorClassName?: string;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
export function PluginLauncherOutlet({
|
|
759
|
+
placementZones,
|
|
760
|
+
context,
|
|
761
|
+
entityType,
|
|
762
|
+
className,
|
|
763
|
+
itemClassName,
|
|
764
|
+
errorClassName,
|
|
765
|
+
}: PluginLauncherOutletProps) {
|
|
766
|
+
const { activateLauncher } = usePluginLauncherRuntime();
|
|
767
|
+
const { launchers, contributionsByPluginId, errorMessage } = usePluginLaunchers({
|
|
768
|
+
placementZones,
|
|
769
|
+
entityType,
|
|
770
|
+
companyId: context.companyId,
|
|
771
|
+
enabled: !!context.companyId,
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
if (errorMessage) {
|
|
775
|
+
return (
|
|
776
|
+
<div className={cn("rounded-md border border-destructive/30 bg-destructive/5 px-2 py-1 text-xs text-destructive", errorClassName)}>
|
|
777
|
+
Plugin launchers unavailable: {errorMessage}
|
|
778
|
+
</div>
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
if (launchers.length === 0) return null;
|
|
783
|
+
|
|
784
|
+
return (
|
|
785
|
+
<div className={className}>
|
|
786
|
+
{launchers.map((launcher) => (
|
|
787
|
+
<div key={`${launcher.pluginKey}:${launcher.id}`} className={itemClassName}>
|
|
788
|
+
<DefaultLauncherTrigger
|
|
789
|
+
launcher={launcher}
|
|
790
|
+
placementZone={launcher.placementZone}
|
|
791
|
+
onClick={(event) => {
|
|
792
|
+
const contribution = contributionsByPluginId.get(launcher.pluginId);
|
|
793
|
+
if (!contribution) return;
|
|
794
|
+
void activateLauncher(launcher, context, contribution, event.currentTarget);
|
|
795
|
+
}}
|
|
796
|
+
/>
|
|
797
|
+
</div>
|
|
798
|
+
))}
|
|
799
|
+
</div>
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
type PluginLauncherButtonProps = {
|
|
804
|
+
launcher: ResolvedPluginLauncher;
|
|
805
|
+
context: PluginLauncherContext;
|
|
806
|
+
contribution: PluginUiContribution;
|
|
807
|
+
className?: string;
|
|
808
|
+
onActivated?: () => void;
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
export function PluginLauncherButton({
|
|
812
|
+
launcher,
|
|
813
|
+
context,
|
|
814
|
+
contribution,
|
|
815
|
+
className,
|
|
816
|
+
onActivated,
|
|
817
|
+
}: PluginLauncherButtonProps) {
|
|
818
|
+
const { activateLauncher } = usePluginLauncherRuntime();
|
|
819
|
+
|
|
820
|
+
return (
|
|
821
|
+
<div className={className}>
|
|
822
|
+
<DefaultLauncherTrigger
|
|
823
|
+
launcher={launcher}
|
|
824
|
+
placementZone={launcher.placementZone}
|
|
825
|
+
onClick={(event) => {
|
|
826
|
+
event.preventDefault();
|
|
827
|
+
onActivated?.();
|
|
828
|
+
void activateLauncher(launcher, context, contribution, event.currentTarget);
|
|
829
|
+
}}
|
|
830
|
+
/>
|
|
831
|
+
</div>
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
|