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,777 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side SVG renderer for Paperclip org charts.
|
|
3
|
+
* Supports 5 visual styles: monochrome, nebula, circuit, warmth, schematic.
|
|
4
|
+
* Pure SVG output — no browser/Playwright needed. PNG via sharp.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface OrgNode {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
role: string;
|
|
11
|
+
status: string;
|
|
12
|
+
reports: OrgNode[];
|
|
13
|
+
/** Populated by collapseTree: the flattened list of hidden descendants for avatar grid rendering. */
|
|
14
|
+
collapsedReports?: OrgNode[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type OrgChartStyle = "monochrome" | "nebula" | "circuit" | "warmth" | "schematic";
|
|
18
|
+
|
|
19
|
+
export const ORG_CHART_STYLES: OrgChartStyle[] = ["monochrome", "nebula", "circuit", "warmth", "schematic"];
|
|
20
|
+
|
|
21
|
+
interface LayoutNode {
|
|
22
|
+
node: OrgNode;
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
children: LayoutNode[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ── Style theme definitions ──────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
interface StyleTheme {
|
|
33
|
+
bgColor: string;
|
|
34
|
+
cardBg: string;
|
|
35
|
+
cardBorder: string;
|
|
36
|
+
cardRadius: number;
|
|
37
|
+
cardShadow: string | null;
|
|
38
|
+
lineColor: string;
|
|
39
|
+
lineWidth: number;
|
|
40
|
+
nameColor: string;
|
|
41
|
+
roleColor: string;
|
|
42
|
+
font: string;
|
|
43
|
+
watermarkColor: string;
|
|
44
|
+
/** Extra SVG defs (filters, patterns, gradients) */
|
|
45
|
+
defs: (svgW: number, svgH: number) => string;
|
|
46
|
+
/** Extra background elements after the main bg rect */
|
|
47
|
+
bgExtras: (svgW: number, svgH: number) => string;
|
|
48
|
+
/** Custom card renderer — if null, uses default avatar+name+role */
|
|
49
|
+
renderCard: ((ln: LayoutNode, theme: StyleTheme) => string) | null;
|
|
50
|
+
/** Per-card accent (top bar, border glow, etc.) */
|
|
51
|
+
cardAccent: ((tag: string) => string) | null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ── Role config with Twemoji SVG inlines (viewBox 0 0 36 36) ─────
|
|
55
|
+
//
|
|
56
|
+
// Each `emojiSvg` contains the inner SVG paths from Twemoji (CC-BY 4.0).
|
|
57
|
+
// These render as colorful emoji-style icons inside the avatar circle,
|
|
58
|
+
// without needing a browser or emoji font.
|
|
59
|
+
|
|
60
|
+
const ROLE_ICONS: Record<string, {
|
|
61
|
+
bg: string;
|
|
62
|
+
roleLabel: string;
|
|
63
|
+
accentColor: string;
|
|
64
|
+
/** Twemoji inner SVG content (paths only, viewBox 0 0 36 36) */
|
|
65
|
+
emojiSvg: string;
|
|
66
|
+
/** Fallback monochrome icon path (16×16 viewBox) for minimal rendering */
|
|
67
|
+
iconPath: string;
|
|
68
|
+
iconColor: string;
|
|
69
|
+
}> = {
|
|
70
|
+
ceo: {
|
|
71
|
+
bg: "#fef3c7", roleLabel: "Chief Executive", accentColor: "#f0883e", iconColor: "#92400e",
|
|
72
|
+
iconPath: "M8 1l2.2 4.5L15 6.2l-3.5 3.4.8 4.9L8 12.2 3.7 14.5l.8-4.9L1 6.2l4.8-.7z",
|
|
73
|
+
// 👑 Crown
|
|
74
|
+
emojiSvg: `<path fill="#F4900C" d="M14.174 17.075L6.75 7.594l-3.722 9.481z"/><path fill="#F4900C" d="M17.938 5.534l-6.563 12.389H24.5z"/><path fill="#F4900C" d="M21.826 17.075l7.424-9.481 3.722 9.481z"/><path fill="#FFCC4D" d="M28.669 15.19L23.887 3.523l-5.88 11.668-.007.003-.007-.004-5.88-11.668L7.331 15.19C4.197 10.833 1.28 8.042 1.28 8.042S3 20.75 3 33h30c0-12.25 1.72-24.958 1.72-24.958s-2.917 2.791-6.051 7.148z"/><circle fill="#5C913B" cx="17.957" cy="22" r="3.688"/><circle fill="#981CEB" cx="26.463" cy="22" r="2.412"/><circle fill="#DD2E44" cx="32.852" cy="22" r="1.986"/><circle fill="#981CEB" cx="9.45" cy="22" r="2.412"/><circle fill="#DD2E44" cx="3.061" cy="22" r="1.986"/><path fill="#FFAC33" d="M33 34H3c-.552 0-1-.447-1-1s.448-1 1-1h30c.553 0 1 .447 1 1s-.447 1-1 1zm0-3.486H3c-.552 0-1-.447-1-1s.448-1 1-1h30c.553 0 1 .447 1 1s-.447 1-1 1z"/><circle fill="#FFCC4D" cx="1.447" cy="8.042" r="1.407"/><circle fill="#F4900C" cx="6.75" cy="7.594" r="1.192"/><circle fill="#FFCC4D" cx="12.113" cy="3.523" r="1.784"/><circle fill="#FFCC4D" cx="34.553" cy="8.042" r="1.407"/><circle fill="#F4900C" cx="29.25" cy="7.594" r="1.192"/><circle fill="#FFCC4D" cx="23.887" cy="3.523" r="1.784"/><circle fill="#F4900C" cx="17.938" cy="5.534" r="1.784"/>`,
|
|
75
|
+
},
|
|
76
|
+
cto: {
|
|
77
|
+
bg: "#dbeafe", roleLabel: "Technology", accentColor: "#58a6ff", iconColor: "#1e40af",
|
|
78
|
+
iconPath: "M2 3l5 5-5 5M9 13h5",
|
|
79
|
+
// 💻 Laptop
|
|
80
|
+
emojiSvg: `<path fill="#CCD6DD" d="M34 29.096c-.417-.963-.896-2.008-2-2.008h-1c1.104 0 2-.899 2-2.008V8.008C33 6.899 32.104 6 31 6H5c-1.104 0-2 .899-2 2.008V25.08c0 1.109.896 2.008 2 2.008H4c-1.104 0-1.667 1.004-2 2.008l-2 4.895C0 35.101.896 36 2 36h32c1.104 0 2-.899 2-2.008l-2-4.896z"/><path fill="#9AAAB4" d="M.008 34.075l.006.057.17.692C.5 35.516 1.192 36 2 36h32c1.076 0 1.947-.855 1.992-1.925H.008z"/><path fill="#5DADEC" d="M31 24.075c0 .555-.447 1.004-1 1.004H6c-.552 0-1-.449-1-1.004V9.013c0-.555.448-1.004 1-1.004h24c.553 0 1 .45 1 1.004v15.062z"/><path fill="#AEBBC1" d="M32.906 31.042l-.76-2.175c-.239-.46-.635-.837-1.188-.837H5.11c-.552 0-.906.408-1.156 1.036l-.688 1.977c-.219.596.448 1.004 1 1.004h7.578s.937-.047 1.103-.608c.192-.648.415-1.624.463-1.796.074-.264.388-.531.856-.531h8.578c.5 0 .746.253.811.566.042.204.312 1.141.438 1.782.111.571 1.221.586 1.221.586h6.594c.551 0 1.217-.471.998-1.004z"/><path fill="#9AAAB4" d="M22.375 33.113h-7.781c-.375 0-.538-.343-.484-.675.054-.331.359-1.793.383-1.963.023-.171.274-.375.524-.375h7.015c.297 0 .49.163.55.489.059.327.302 1.641.321 1.941.019.301-.169.583-.528.583z"/>`,
|
|
81
|
+
},
|
|
82
|
+
cmo: {
|
|
83
|
+
bg: "#dcfce7", roleLabel: "Marketing", accentColor: "#3fb950", iconColor: "#166534",
|
|
84
|
+
iconPath: "M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zM1 8h14M8 1c-2 2-3 4.5-3 7s1 5 3 7c2-2 3-4.5 3-7s-1-5-3-7z",
|
|
85
|
+
// 🌐 Globe with meridians
|
|
86
|
+
emojiSvg: `<path fill="#3B88C3" d="M18 0C8.059 0 0 8.059 0 18s8.059 18 18 18 18-8.059 18-18S27.941 0 18 0zM2.05 19h3.983c.092 2.506.522 4.871 1.229 7H4.158c-1.207-2.083-1.95-4.459-2.108-7zM19 8V2.081c2.747.436 5.162 2.655 6.799 5.919H19zm7.651 2c.754 2.083 1.219 4.46 1.317 7H19v-7h7.651zM17 2.081V8h-6.799C11.837 4.736 14.253 2.517 17 2.081zM17 10v7H8.032c.098-2.54.563-4.917 1.317-7H17zM6.034 17H2.05c.158-2.54.901-4.917 2.107-7h3.104c-.705 2.129-1.135 4.495-1.227 7zm1.998 2H17v7H9.349c-.754-2.083-1.219-4.459-1.317-7zM17 28v5.919c-2.747-.437-5.163-2.655-6.799-5.919H17zm2 5.919V28h6.8c-1.637 3.264-4.053 5.482-6.8 5.919zM19 26v-7h8.969c-.099 2.541-.563 4.917-1.317 7H19zm10.967-7h3.982c-.157 2.541-.9 4.917-2.107 7h-3.104c.706-2.129 1.136-4.494 1.229-7zm0-2c-.093-2.505-.523-4.871-1.229-7h3.104c1.207 2.083 1.95 4.46 2.107 7h-3.982zm.512-9h-2.503c-.717-1.604-1.606-3.015-2.619-4.199C27.346 4.833 29.089 6.267 30.479 8zM10.643 3.801C9.629 4.985 8.74 6.396 8.023 8H5.521c1.39-1.733 3.133-3.166 5.122-4.199zM5.521 28h2.503c.716 1.604 1.605 3.015 2.619 4.198C8.654 31.166 6.911 29.733 5.521 28zm19.836 4.198c1.014-1.184 1.902-2.594 2.619-4.198h2.503c-1.39 1.733-3.133 3.166-5.122 4.198z"/>`,
|
|
87
|
+
},
|
|
88
|
+
cfo: {
|
|
89
|
+
bg: "#fef3c7", roleLabel: "Finance", accentColor: "#f0883e", iconColor: "#92400e",
|
|
90
|
+
iconPath: "M8 1v14M5 4.5C5 3.1 6.3 2 8 2s3 1.1 3 2.5S9.7 7 8 7 5 8.1 5 9.5 6.3 12 8 12s3-1.1 3-2.5",
|
|
91
|
+
// 📊 Bar chart
|
|
92
|
+
emojiSvg: `<path fill="#CCD6DD" d="M31 2H5C3.343 2 2 3.343 2 5v26c0 1.657 1.343 3 3 3h26c1.657 0 3-1.343 3-3V5c0-1.657-1.343-3-3-3z"/><path fill="#E1E8ED" d="M31 1H5C2.791 1 1 2.791 1 5v26c0 2.209 1.791 4 4 4h26c2.209 0 4-1.791 4-4V5c0-2.209-1.791-4-4-4zm0 2c1.103 0 2 .897 2 2v4h-6V3h4zm-4 16h6v6h-6v-6zm0-2v-6h6v6h-6zM25 3v6h-6V3h6zm-6 8h6v6h-6v-6zm0 8h6v6h-6v-6zM17 3v6h-6V3h6zm-6 8h6v6h-6v-6zm0 8h6v6h-6v-6zM3 5c0-1.103.897-2 2-2h4v6H3V5zm0 6h6v6H3v-6zm0 8h6v6H3v-6zm2 14c-1.103 0-2-.897-2-2v-4h6v6H5zm6 0v-6h6v6h-6zm8 0v-6h6v6h-6zm12 0h-4v-6h6v4c0 1.103-.897 2-2 2z"/><path fill="#5C913B" d="M13 33H7V16c0-1.104.896-2 2-2h2c1.104 0 2 .896 2 2v17z"/><path fill="#3B94D9" d="M29 33h-6V9c0-1.104.896-2 2-2h2c1.104 0 2 .896 2 2v24z"/><path fill="#DD2E44" d="M21 33h-6V23c0-1.104.896-2 2-2h2c1.104 0 2 .896 2 2v10z"/>`,
|
|
93
|
+
},
|
|
94
|
+
coo: {
|
|
95
|
+
bg: "#e0f2fe", roleLabel: "Operations", accentColor: "#58a6ff", iconColor: "#075985",
|
|
96
|
+
iconPath: "M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5z",
|
|
97
|
+
// ⚙️ Gear
|
|
98
|
+
emojiSvg: `<path fill="#66757F" d="M34 15h-3.362c-.324-1.369-.864-2.651-1.582-3.814l2.379-2.379c.781-.781.781-2.048 0-2.829l-1.414-1.414c-.781-.781-2.047-.781-2.828 0l-2.379 2.379C23.65 6.225 22.369 5.686 21 5.362V2c0-1.104-.896-2-2-2h-2c-1.104 0-2 .896-2 2v3.362c-1.369.324-2.651.864-3.814 1.582L8.808 4.565c-.781-.781-2.048-.781-2.828 0L4.565 5.979c-.781.781-.781 2.048-.001 2.829l2.379 2.379C6.225 12.35 5.686 13.632 5.362 15H2c-1.104 0-2 .896-2 2v2c0 1.104.896 2 2 2h3.362c.324 1.368.864 2.65 1.582 3.813l-2.379 2.379c-.78.78-.78 2.048.001 2.829l1.414 1.414c.78.78 2.047.78 2.828 0l2.379-2.379c1.163.719 2.445 1.258 3.814 1.582V34c0 1.104.896 2 2 2h2c1.104 0 2-.896 2-2v-3.362c1.368-.324 2.65-.864 3.813-1.582l2.379 2.379c.781.781 2.047.781 2.828 0l1.414-1.414c.781-.781.781-2.048 0-2.829l-2.379-2.379c.719-1.163 1.258-2.445 1.582-3.814H34c1.104 0 2-.896 2-2v-2C36 15.896 35.104 15 34 15zM18 26c-4.418 0-8-3.582-8-8s3.582-8 8-8 8 3.582 8 8-3.582 8-8 8z"/>`,
|
|
99
|
+
},
|
|
100
|
+
engineer: {
|
|
101
|
+
bg: "#f3e8ff", roleLabel: "Engineering", accentColor: "#bc8cff", iconColor: "#6b21a8",
|
|
102
|
+
iconPath: "M5 3L1 8l4 5M11 3l4 5-4 5",
|
|
103
|
+
// ⌨️ Keyboard
|
|
104
|
+
emojiSvg: `<path fill="#99AAB5" d="M36 28c0 1.104-.896 2-2 2H2c-1.104 0-2-.896-2-2V12c0-1.104.896-2 2-2h32c1.104 0 2 .896 2 2v16z"/><path d="M5.5 19c0 .553-.448 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.552 0 1 .447 1 1v1zm4 0c0 .553-.448 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.552 0 1 .447 1 1v1zm4 0c0 .553-.448 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.552 0 1 .447 1 1v1zm4 0c0 .553-.448 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.552 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h1c.553 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h1c.553 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h1c.553 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h1c.553 0 1 .447 1 1v1zm-26 4c0 .553-.448 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.552 0 1 .447 1 1v1zm4 0c0 .553-.448 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.552 0 1 .447 1 1v1zm4 0c0 .553-.448 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.552 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h1c.553 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h1c.553 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h1c.553 0 1 .447 1 1v1zm4 0c0 .553-.447 1-1 1h-1c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h1c.553 0 1 .447 1 1v1zM10 27c0 .553-.448 1-1 1H7c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h2c.552 0 1 .447 1 1v1zm20 0c0 .553-.447 1-1 1h-2c-.553 0-1-.447-1-1v-1c0-.553.447-1 1-1h2c.553 0 1 .447 1 1v1zm-5 0c0 .553-.447 1-1 1H12c-.552 0-1-.447-1-1v-1c0-.553.448-1 1-1h12c.553 0 1 .447 1 1v1zM5.5 13.083c0 .552-.448 1-1 1h-1c-.552 0-1-.448-1-1s.448-1 1-1h1c.552 0 1 .448 1 1zm4 0c0 .552-.448 1-1 1h-1c-.552 0-1-.448-1-1s.448-1 1-1h1c.552 0 1 .448 1 1zm4 0c0 .552-.448 1-1 1h-1c-.552 0-1-.448-1-1s.448-1 1-1h1c.552 0 1 .448 1 1zm4 0c0 .552-.448 1-1 1h-1c-.552 0-1-.448-1-1s.448-1 1-1h1c.552 0 1 .448 1 1zm4 0c0 .552-.447 1-1 1h-1c-.553 0-1-.448-1-1s.447-1 1-1h1c.553 0 1 .448 1 1zm4 0c0 .552-.447 1-1 1h-1c-.553 0-1-.448-1-1s.447-1 1-1h1c.553 0 1 .448 1 1zm4 0c0 .552-.447 1-1 1h-1c-.553 0-1-.448-1-1s.447-1 1-1h1c.553 0 1 .448 1 1zm4 0c0 .552-.447 1-1 1h-1c-.553 0-1-.448-1-1s.447-1 1-1h1c.553 0 1 .448 1 1z" fill="#292F33"/>`,
|
|
105
|
+
},
|
|
106
|
+
quality: {
|
|
107
|
+
bg: "#ffe4e6", roleLabel: "Quality", accentColor: "#f778ba", iconColor: "#9f1239",
|
|
108
|
+
iconPath: "M4 8l3 3 5-6M8 1L2 4v4c0 3.5 2.6 6.8 6 8 3.4-1.2 6-4.5 6-8V4z",
|
|
109
|
+
// 🔬 Microscope
|
|
110
|
+
emojiSvg: `<g fill="#66757F"><path d="M19.78 21.345l-6.341-6.342-.389 4.38 2.35 2.351z"/><path d="M15.4 22.233c-.132 0-.259-.053-.354-.146l-2.351-2.351c-.104-.104-.158-.25-.145-.397l.389-4.38c.017-.193.145-.359.327-.425.182-.067.388-.021.524.116l6.341 6.342c.138.138.183.342.116.524s-.232.31-.426.327l-4.379.389-.042.001zm-1.832-3.039l2.021 2.021 3.081-.273-4.828-4.828-.274 3.08z"/></g><path fill="#8899A6" d="M31 32h-3c0-3.314-2.63-6-5.875-6-3.244 0-5.875 2.686-5.875 6H8.73c0-1.104-.895-2-2-2-1.104 0-2 .896-2 2-1.104 0-2 .896-2 2s.896 2 2 2H31c1.104 0 2-.896 2-2s-.896-2-2-2z"/><path fill="#8899A6" d="M20 10v4c3.866 0 7 3.134 7 7s-3.134 7-7 7h-8.485c2.018 2.443 5.069 4 8.485 4 6.075 0 11-4.925 11-11s-4.925-11-11-11z"/><path fill="#67757F" d="M16.414 30.414c-.781.781-2.047.781-2.828 0l-9.899-9.9c-.781-.781-.781-2.047 0-2.828.781-.781 2.047-.781 2.829 0l9.899 9.9c.78.781.78 2.047-.001 2.828zm-7.225-1.786c.547-.077 1.052.304 1.129.851.077.547-.305 1.053-.851 1.129l-5.942.834c-.547.077-1.052-.305-1.129-.851-.077-.547.305-1.053.852-1.13l5.941-.833z"/><path fill="#66757F" d="M27.341 2.98l4.461 4.461-3.806 3.807-4.461-4.461z"/><path fill="#AAB8C2" d="M34.037 7.083c-.827.827-2.17.827-2.997 0l-3.339-3.34c-.827-.826-.827-2.169 0-2.996.827-.826 2.17-.826 2.995 0l3.342 3.34c.826.827.826 2.168-.001 2.996zm-14.56 15.026l-6.802-6.803c-.389-.389-.389-1.025 0-1.414l9.858-9.858c.389-.389 1.025-.389 1.414 0l6.801 6.803c.389.389.389 1.025 0 1.414l-9.858 9.858c-.388.389-1.024.389-1.413 0z"/><path fill="#E1E8ED" d="M13.766 12.8l1.638-1.637 8.216 8.216-1.638 1.637z"/>`,
|
|
111
|
+
},
|
|
112
|
+
design: {
|
|
113
|
+
bg: "#fce7f3", roleLabel: "Design", accentColor: "#79c0ff", iconColor: "#9d174d",
|
|
114
|
+
iconPath: "M12 2l2 2-9 9H3v-2zM9.5 4.5l2 2",
|
|
115
|
+
// 🪄 Magic wand
|
|
116
|
+
emojiSvg: `<path fill="#292F33" d="M3.651 29.852L29.926 3.576c.391-.391 2.888 2.107 2.497 2.497L6.148 32.349c-.39.391-2.888-2.107-2.497-2.497z"/><path fill="#66757F" d="M30.442 4.051L4.146 30.347l.883.883L31.325 4.934z"/><path fill="#E1E8ED" d="M34.546 2.537l-.412-.412-.671-.671c-.075-.075-.165-.123-.255-.169-.376-.194-.844-.146-1.159.169l-2.102 2.102.495.495.883.883 1.119 1.119 2.102-2.102c.391-.391.391-1.024 0-1.414zM5.029 31.23l-.883-.883-.495-.495-2.209 2.208c-.315.315-.363.783-.169 1.159.046.09.094.18.169.255l.671.671.412.412c.391.391 1.024.391 1.414 0l2.208-2.208-1.118-1.119z"/><path fill="#F5F8FA" d="M31.325 4.934l2.809-2.809-.671-.671c-.075-.075-.165-.123-.255-.169l-2.767 2.767.884.882zM4.146 30.347L1.273 33.22c.046.09.094.18.169.255l.671.671 2.916-2.916-.883-.883z"/><path d="M28.897 14.913l1.542-.571.6-2.2c.079-.29.343-.491.644-.491.3 0 .564.201.643.491l.6 2.2 1.542.571c.262.096.435.346.435.625s-.173.529-.435.625l-1.534.568-.605 2.415c-.074.296-.341.505-.646.505-.306 0-.573-.209-.647-.505l-.605-2.415-1.534-.568c-.262-.096-.435-.346-.435-.625 0-.278.173-.528.435-.625M11.961 5.285l2.61-.966.966-2.61c.16-.433.573-.72 1.035-.72.461 0 .874.287 1.035.72l.966 2.61 2.609.966c.434.161.721.573.721 1.035 0 .462-.287.874-.721 1.035l-2.609.966-.966 2.61c-.161.433-.574.72-1.035.72-.462 0-.875-.287-1.035-.72l-.966-2.61-2.61-.966c-.433-.161-.72-.573-.72-1.035.001-.462.288-.874.72-1.035M24.13 20.772l1.383-.512.512-1.382c.085-.229.304-.381.548-.381.244 0 .463.152.548.381l.512 1.382 1.382.512c.23.085.382.304.382.548 0 .245-.152.463-.382.548l-1.382.512-.512 1.382c-.085.229-.304.381-.548.381-.245 0-.463-.152-.548-.381l-.512-1.382-1.383-.512c-.229-.085-.381-.304-.381-.548 0-.245.152-.463.381-.548" fill="#FFAC33"/>`,
|
|
117
|
+
},
|
|
118
|
+
finance: {
|
|
119
|
+
bg: "#fef3c7", roleLabel: "Finance", accentColor: "#f0883e", iconColor: "#92400e",
|
|
120
|
+
iconPath: "M8 1v14M5 4.5C5 3.1 6.3 2 8 2s3 1.1 3 2.5S9.7 7 8 7 5 8.1 5 9.5 6.3 12 8 12s3-1.1 3-2.5",
|
|
121
|
+
// 📊 Bar chart (same as CFO)
|
|
122
|
+
emojiSvg: `<path fill="#CCD6DD" d="M31 2H5C3.343 2 2 3.343 2 5v26c0 1.657 1.343 3 3 3h26c1.657 0 3-1.343 3-3V5c0-1.657-1.343-3-3-3z"/><path fill="#E1E8ED" d="M31 1H5C2.791 1 1 2.791 1 5v26c0 2.209 1.791 4 4 4h26c2.209 0 4-1.791 4-4V5c0-2.209-1.791-4-4-4zm0 2c1.103 0 2 .897 2 2v4h-6V3h4zm-4 16h6v6h-6v-6zm0-2v-6h6v6h-6zM25 3v6h-6V3h6zm-6 8h6v6h-6v-6zm0 8h6v6h-6v-6zM17 3v6h-6V3h6zm-6 8h6v6h-6v-6zm0 8h6v6h-6v-6zM3 5c0-1.103.897-2 2-2h4v6H3V5zm0 6h6v6H3v-6zm0 8h6v6H3v-6zm2 14c-1.103 0-2-.897-2-2v-4h6v6H5zm6 0v-6h6v6h-6zm8 0v-6h6v6h-6zm12 0h-4v-6h6v4c0 1.103-.897 2-2 2z"/><path fill="#5C913B" d="M13 33H7V16c0-1.104.896-2 2-2h2c1.104 0 2 .896 2 2v17z"/><path fill="#3B94D9" d="M29 33h-6V9c0-1.104.896-2 2-2h2c1.104 0 2 .896 2 2v24z"/><path fill="#DD2E44" d="M21 33h-6V23c0-1.104.896-2 2-2h2c1.104 0 2 .896 2 2v10z"/>`,
|
|
123
|
+
},
|
|
124
|
+
operations: {
|
|
125
|
+
bg: "#e0f2fe", roleLabel: "Operations", accentColor: "#58a6ff", iconColor: "#075985",
|
|
126
|
+
iconPath: "M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5z",
|
|
127
|
+
// ⚙️ Gear (same as COO)
|
|
128
|
+
emojiSvg: `<path fill="#66757F" d="M34 15h-3.362c-.324-1.369-.864-2.651-1.582-3.814l2.379-2.379c.781-.781.781-2.048 0-2.829l-1.414-1.414c-.781-.781-2.047-.781-2.828 0l-2.379 2.379C23.65 6.225 22.369 5.686 21 5.362V2c0-1.104-.896-2-2-2h-2c-1.104 0-2 .896-2 2v3.362c-1.369.324-2.651.864-3.814 1.582L8.808 4.565c-.781-.781-2.048-.781-2.828 0L4.565 5.979c-.781.781-.781 2.048-.001 2.829l2.379 2.379C6.225 12.35 5.686 13.632 5.362 15H2c-1.104 0-2 .896-2 2v2c0 1.104.896 2 2 2h3.362c.324 1.368.864 2.65 1.582 3.813l-2.379 2.379c-.78.78-.78 2.048.001 2.829l1.414 1.414c.78.78 2.047.78 2.828 0l2.379-2.379c1.163.719 2.445 1.258 3.814 1.582V34c0 1.104.896 2 2 2h2c1.104 0 2-.896 2-2v-3.362c1.368-.324 2.65-.864 3.813-1.582l2.379 2.379c.781.781 2.047.781 2.828 0l1.414-1.414c.781-.781.781-2.048 0-2.829l-2.379-2.379c.719-1.163 1.258-2.445 1.582-3.814H34c1.104 0 2-.896 2-2v-2C36 15.896 35.104 15 34 15zM18 26c-4.418 0-8-3.582-8-8s3.582-8 8-8 8 3.582 8 8-3.582 8-8 8z"/>`,
|
|
129
|
+
},
|
|
130
|
+
default: {
|
|
131
|
+
bg: "#f3e8ff", roleLabel: "Agent", accentColor: "#bc8cff", iconColor: "#6b21a8",
|
|
132
|
+
iconPath: "M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM2 14c0-3.3 2.7-4 6-4s6 .7 6 4",
|
|
133
|
+
// 👤 Person silhouette
|
|
134
|
+
emojiSvg: `<path fill="#269" d="M24 26.799v-2.566c2-1.348 4.08-3.779 4.703-6.896.186.103.206.17.413.17.991 0 1.709-1.287 1.709-2.873 0-1.562-.823-2.827-1.794-2.865.187-.674.293-1.577.293-2.735C29.324 5.168 26 .527 18.541.527c-6.629 0-10.777 4.641-10.777 8.507 0 1.123.069 2.043.188 2.755-.911.137-1.629 1.352-1.629 2.845 0 1.587.804 2.873 1.796 2.873.206 0 .025-.067.209-.17C8.952 20.453 11 22.885 13 24.232v2.414c-5 .645-12 3.437-12 6.23v1.061C1 35 2.076 35 3.137 35h29.725C33.924 35 35 35 35 33.938v-1.061c0-2.615-6-5.225-11-6.078z"/>`,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
function guessRoleTag(node: OrgNode): string {
|
|
139
|
+
const name = node.name.toLowerCase();
|
|
140
|
+
const role = node.role.toLowerCase();
|
|
141
|
+
if (name === "ceo" || role.includes("chief executive")) return "ceo";
|
|
142
|
+
if (name === "cto" || role.includes("chief technology") || role.includes("technology")) return "cto";
|
|
143
|
+
if (name === "cmo" || role.includes("chief marketing") || role.includes("marketing")) return "cmo";
|
|
144
|
+
if (name === "cfo" || role.includes("chief financial")) return "cfo";
|
|
145
|
+
if (name === "coo" || role.includes("chief operating")) return "coo";
|
|
146
|
+
if (role.includes("engineer") || role.includes("eng")) return "engineer";
|
|
147
|
+
if (role.includes("quality") || role.includes("qa")) return "quality";
|
|
148
|
+
if (role.includes("design")) return "design";
|
|
149
|
+
if (role.includes("finance")) return "finance";
|
|
150
|
+
if (role.includes("operations") || role.includes("ops")) return "operations";
|
|
151
|
+
return "default";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getRoleInfo(node: OrgNode) {
|
|
155
|
+
const tag = guessRoleTag(node);
|
|
156
|
+
return { tag, ...(ROLE_ICONS[tag] || ROLE_ICONS.default) };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ── Style themes ─────────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
const THEMES: Record<OrgChartStyle, StyleTheme> = {
|
|
162
|
+
// 01 — Monochrome (Vercel-inspired, dark minimal)
|
|
163
|
+
monochrome: {
|
|
164
|
+
bgColor: "#18181b",
|
|
165
|
+
cardBg: "#18181b",
|
|
166
|
+
cardBorder: "#27272a",
|
|
167
|
+
cardRadius: 6,
|
|
168
|
+
cardShadow: null,
|
|
169
|
+
lineColor: "#3f3f46",
|
|
170
|
+
lineWidth: 1.5,
|
|
171
|
+
nameColor: "#fafafa",
|
|
172
|
+
roleColor: "#71717a",
|
|
173
|
+
font: "'Inter', system-ui, sans-serif",
|
|
174
|
+
watermarkColor: "rgba(255,255,255,0.25)",
|
|
175
|
+
defs: () => "",
|
|
176
|
+
bgExtras: () => "",
|
|
177
|
+
renderCard: null,
|
|
178
|
+
cardAccent: null,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
// 02 — Nebula (glassmorphism on cosmic gradient)
|
|
182
|
+
nebula: {
|
|
183
|
+
bgColor: "#0f0c29",
|
|
184
|
+
cardBg: "rgba(255,255,255,0.07)",
|
|
185
|
+
cardBorder: "rgba(255,255,255,0.12)",
|
|
186
|
+
cardRadius: 6,
|
|
187
|
+
cardShadow: null,
|
|
188
|
+
lineColor: "rgba(255,255,255,0.25)",
|
|
189
|
+
lineWidth: 1.5,
|
|
190
|
+
nameColor: "#ffffff",
|
|
191
|
+
roleColor: "rgba(255,255,255,0.45)",
|
|
192
|
+
font: "'Inter', system-ui, sans-serif",
|
|
193
|
+
watermarkColor: "rgba(255,255,255,0.2)",
|
|
194
|
+
defs: (_w, _h) => `
|
|
195
|
+
<linearGradient id="nebula-bg" x1="0" y1="0" x2="1" y2="1">
|
|
196
|
+
<stop offset="0%" stop-color="#0f0c29"/>
|
|
197
|
+
<stop offset="50%" stop-color="#302b63"/>
|
|
198
|
+
<stop offset="100%" stop-color="#24243e"/>
|
|
199
|
+
</linearGradient>
|
|
200
|
+
<radialGradient id="nebula-glow1" cx="25%" cy="30%" r="40%">
|
|
201
|
+
<stop offset="0%" stop-color="rgba(99,102,241,0.12)"/>
|
|
202
|
+
<stop offset="100%" stop-color="transparent"/>
|
|
203
|
+
</radialGradient>
|
|
204
|
+
<radialGradient id="nebula-glow2" cx="75%" cy="65%" r="35%">
|
|
205
|
+
<stop offset="0%" stop-color="rgba(168,85,247,0.08)"/>
|
|
206
|
+
<stop offset="100%" stop-color="transparent"/>
|
|
207
|
+
</radialGradient>`,
|
|
208
|
+
bgExtras: (w, h) => `
|
|
209
|
+
<rect width="${w}" height="${h}" fill="url(#nebula-bg)" rx="6"/>
|
|
210
|
+
<rect width="${w}" height="${h}" fill="url(#nebula-glow1)"/>
|
|
211
|
+
<rect width="${w}" height="${h}" fill="url(#nebula-glow2)"/>`,
|
|
212
|
+
renderCard: null,
|
|
213
|
+
cardAccent: null,
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
// 03 — Circuit (Linear/Raycast — indigo traces, amethyst CEO)
|
|
217
|
+
circuit: {
|
|
218
|
+
bgColor: "#0c0c0e",
|
|
219
|
+
cardBg: "rgba(99,102,241,0.04)",
|
|
220
|
+
cardBorder: "rgba(99,102,241,0.18)",
|
|
221
|
+
cardRadius: 5,
|
|
222
|
+
cardShadow: null,
|
|
223
|
+
lineColor: "rgba(99,102,241,0.35)",
|
|
224
|
+
lineWidth: 1.5,
|
|
225
|
+
nameColor: "#e4e4e7",
|
|
226
|
+
roleColor: "#6366f1",
|
|
227
|
+
font: "'Inter', system-ui, sans-serif",
|
|
228
|
+
watermarkColor: "rgba(99,102,241,0.3)",
|
|
229
|
+
defs: () => "",
|
|
230
|
+
bgExtras: () => "",
|
|
231
|
+
renderCard: (ln: LayoutNode, theme: StyleTheme) => {
|
|
232
|
+
const { tag, roleLabel, emojiSvg } = getRoleInfo(ln.node);
|
|
233
|
+
const cx = ln.x + ln.width / 2;
|
|
234
|
+
const isCeo = tag === "ceo";
|
|
235
|
+
const borderColor = isCeo ? "rgba(168,85,247,0.35)" : theme.cardBorder;
|
|
236
|
+
const bgColor = isCeo ? "rgba(168,85,247,0.06)" : theme.cardBg;
|
|
237
|
+
|
|
238
|
+
const avatarCY = ln.y + 27;
|
|
239
|
+
const nameY = ln.y + 66;
|
|
240
|
+
const roleY = ln.y + 82;
|
|
241
|
+
|
|
242
|
+
return `<g>
|
|
243
|
+
<rect x="${ln.x}" y="${ln.y}" width="${ln.width}" height="${ln.height}" rx="${theme.cardRadius}" fill="${bgColor}" stroke="${borderColor}" stroke-width="1"/>
|
|
244
|
+
${renderEmojiAvatar(cx, avatarCY, 17, "rgba(99,102,241,0.08)", emojiSvg, "rgba(99,102,241,0.15)")}
|
|
245
|
+
<text x="${cx}" y="${nameY}" text-anchor="middle" font-family="${theme.font}" font-size="13" font-weight="600" fill="${theme.nameColor}" letter-spacing="-0.005em">${escapeXml(ln.node.name)}</text>
|
|
246
|
+
<text x="${cx}" y="${roleY}" text-anchor="middle" font-family="${theme.font}" font-size="10" font-weight="500" fill="${theme.roleColor}" letter-spacing="0.07em">${escapeXml(roleLabel).toUpperCase()}</text>
|
|
247
|
+
</g>`;
|
|
248
|
+
},
|
|
249
|
+
cardAccent: null,
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
// 04 — Warmth (Airbnb — light, colored avatars, soft shadows)
|
|
253
|
+
warmth: {
|
|
254
|
+
bgColor: "#fafaf9",
|
|
255
|
+
cardBg: "#ffffff",
|
|
256
|
+
cardBorder: "#e7e5e4",
|
|
257
|
+
cardRadius: 6,
|
|
258
|
+
cardShadow: "rgba(0,0,0,0.05)",
|
|
259
|
+
lineColor: "#d6d3d1",
|
|
260
|
+
lineWidth: 2,
|
|
261
|
+
nameColor: "#1c1917",
|
|
262
|
+
roleColor: "#78716c",
|
|
263
|
+
font: "'Inter', -apple-system, BlinkMacSystemFont, sans-serif",
|
|
264
|
+
watermarkColor: "rgba(0,0,0,0.25)",
|
|
265
|
+
defs: () => "",
|
|
266
|
+
bgExtras: () => "",
|
|
267
|
+
renderCard: null,
|
|
268
|
+
cardAccent: null,
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
// 05 — Schematic (Blueprint — grid bg, monospace, colored top-bars)
|
|
272
|
+
schematic: {
|
|
273
|
+
bgColor: "#0d1117",
|
|
274
|
+
cardBg: "rgba(13,17,23,0.92)",
|
|
275
|
+
cardBorder: "#30363d",
|
|
276
|
+
cardRadius: 4,
|
|
277
|
+
cardShadow: null,
|
|
278
|
+
lineColor: "#30363d",
|
|
279
|
+
lineWidth: 1.5,
|
|
280
|
+
nameColor: "#c9d1d9",
|
|
281
|
+
roleColor: "#8b949e",
|
|
282
|
+
font: "'JetBrains Mono', 'SF Mono', monospace",
|
|
283
|
+
watermarkColor: "rgba(139,148,158,0.3)",
|
|
284
|
+
defs: (w, h) => `
|
|
285
|
+
<pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse">
|
|
286
|
+
<path d="M 20 0 L 0 0 0 20" fill="none" stroke="rgba(48,54,61,0.25)" stroke-width="1"/>
|
|
287
|
+
</pattern>`,
|
|
288
|
+
bgExtras: (w, h) => `<rect width="${w}" height="${h}" fill="url(#grid)"/>`,
|
|
289
|
+
renderCard: (ln: LayoutNode, theme: StyleTheme) => {
|
|
290
|
+
const { tag, accentColor, emojiSvg } = getRoleInfo(ln.node);
|
|
291
|
+
const cx = ln.x + ln.width / 2;
|
|
292
|
+
|
|
293
|
+
// Schematic uses monospace role labels
|
|
294
|
+
const schemaRoles: Record<string, string> = {
|
|
295
|
+
ceo: "chief_executive", cto: "chief_technology", cmo: "chief_marketing",
|
|
296
|
+
cfo: "chief_financial", coo: "chief_operating", engineer: "engineer",
|
|
297
|
+
quality: "quality_assurance", design: "designer", finance: "finance",
|
|
298
|
+
operations: "operations", default: "agent",
|
|
299
|
+
};
|
|
300
|
+
const roleText = schemaRoles[tag] || schemaRoles.default;
|
|
301
|
+
|
|
302
|
+
const avatarCY = ln.y + 27;
|
|
303
|
+
const nameY = ln.y + 66;
|
|
304
|
+
const roleY = ln.y + 82;
|
|
305
|
+
|
|
306
|
+
return `<g>
|
|
307
|
+
<rect x="${ln.x}" y="${ln.y}" width="${ln.width}" height="${ln.height}" rx="${theme.cardRadius}" fill="${theme.cardBg}" stroke="${theme.cardBorder}" stroke-width="1"/>
|
|
308
|
+
<rect x="${ln.x}" y="${ln.y}" width="${ln.width}" height="2" rx="${theme.cardRadius} ${theme.cardRadius} 0 0" fill="${accentColor}"/>
|
|
309
|
+
${renderEmojiAvatar(cx, avatarCY, 17, "rgba(48,54,61,0.3)", emojiSvg, theme.cardBorder)}
|
|
310
|
+
<text x="${cx}" y="${nameY}" text-anchor="middle" font-family="${theme.font}" font-size="12" font-weight="600" fill="${theme.nameColor}">${escapeXml(ln.node.name)}</text>
|
|
311
|
+
<text x="${cx}" y="${roleY}" text-anchor="middle" font-family="${theme.font}" font-size="10" fill="${theme.roleColor}" letter-spacing="0.02em">${escapeXml(roleText)}</text>
|
|
312
|
+
</g>`;
|
|
313
|
+
},
|
|
314
|
+
cardAccent: null,
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
// ── Layout constants ─────────────────────────────────────────────
|
|
319
|
+
|
|
320
|
+
const CARD_H = 96;
|
|
321
|
+
const CARD_MIN_W = 150;
|
|
322
|
+
const CARD_PAD_X = 22;
|
|
323
|
+
const AVATAR_SIZE = 34;
|
|
324
|
+
const GAP_X = 24;
|
|
325
|
+
const GAP_Y = 56;
|
|
326
|
+
|
|
327
|
+
// ── Collapsed avatar grid constants ─────────────────────────────
|
|
328
|
+
const MINI_AVATAR_SIZE = 14;
|
|
329
|
+
const MINI_AVATAR_GAP = 6;
|
|
330
|
+
const MINI_AVATAR_PADDING = 10;
|
|
331
|
+
const MINI_AVATAR_MAX_COLS = 8; // max avatars per row in the grid
|
|
332
|
+
const PADDING = 48;
|
|
333
|
+
const LOGO_PADDING = 16;
|
|
334
|
+
|
|
335
|
+
// ── Text measurement ─────────────────────────────────────────────
|
|
336
|
+
|
|
337
|
+
function measureText(text: string, fontSize: number): number {
|
|
338
|
+
return text.length * fontSize * 0.58;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Calculate how many rows the avatar grid needs. */
|
|
342
|
+
function avatarGridRows(count: number): number {
|
|
343
|
+
return Math.ceil(count / MINI_AVATAR_MAX_COLS);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Width needed for the avatar grid. */
|
|
347
|
+
function avatarGridWidth(count: number): number {
|
|
348
|
+
const cols = Math.min(count, MINI_AVATAR_MAX_COLS);
|
|
349
|
+
return cols * (MINI_AVATAR_SIZE + MINI_AVATAR_GAP) - MINI_AVATAR_GAP + MINI_AVATAR_PADDING * 2;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Height of the avatar grid area. */
|
|
353
|
+
function avatarGridHeight(count: number): number {
|
|
354
|
+
if (count === 0) return 0;
|
|
355
|
+
const rows = avatarGridRows(count);
|
|
356
|
+
return rows * (MINI_AVATAR_SIZE + MINI_AVATAR_GAP) - MINI_AVATAR_GAP + MINI_AVATAR_PADDING * 2;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function cardWidth(node: OrgNode): number {
|
|
360
|
+
const { roleLabel: defaultRoleLabel } = getRoleInfo(node);
|
|
361
|
+
const roleLabel = node.role.startsWith("×") ? node.role : defaultRoleLabel;
|
|
362
|
+
const nameW = measureText(node.name, 14) + CARD_PAD_X * 2;
|
|
363
|
+
const roleW = measureText(roleLabel, 11) + CARD_PAD_X * 2;
|
|
364
|
+
let w = Math.max(CARD_MIN_W, Math.max(nameW, roleW));
|
|
365
|
+
// Widen for avatar grid if needed
|
|
366
|
+
if (node.collapsedReports && node.collapsedReports.length > 0) {
|
|
367
|
+
w = Math.max(w, avatarGridWidth(node.collapsedReports.length));
|
|
368
|
+
}
|
|
369
|
+
return w;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function cardHeight(node: OrgNode): number {
|
|
373
|
+
if (node.collapsedReports && node.collapsedReports.length > 0) {
|
|
374
|
+
return CARD_H + avatarGridHeight(node.collapsedReports.length);
|
|
375
|
+
}
|
|
376
|
+
return CARD_H;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// ── Tree layout (top-down, centered) ─────────────────────────────
|
|
380
|
+
|
|
381
|
+
function subtreeWidth(node: OrgNode): number {
|
|
382
|
+
const cw = cardWidth(node);
|
|
383
|
+
if (!node.reports || node.reports.length === 0) return cw;
|
|
384
|
+
const childrenW = node.reports.reduce(
|
|
385
|
+
(sum, child, i) => sum + subtreeWidth(child) + (i > 0 ? GAP_X : 0),
|
|
386
|
+
0,
|
|
387
|
+
);
|
|
388
|
+
return Math.max(cw, childrenW);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function layoutTree(node: OrgNode, x: number, y: number): LayoutNode {
|
|
392
|
+
const w = cardWidth(node);
|
|
393
|
+
const sw = subtreeWidth(node);
|
|
394
|
+
const cardX = x + (sw - w) / 2;
|
|
395
|
+
|
|
396
|
+
const h = cardHeight(node);
|
|
397
|
+
const layoutNode: LayoutNode = {
|
|
398
|
+
node,
|
|
399
|
+
x: cardX,
|
|
400
|
+
y,
|
|
401
|
+
width: w,
|
|
402
|
+
height: h,
|
|
403
|
+
children: [],
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
if (node.reports && node.reports.length > 0) {
|
|
407
|
+
let childX = x;
|
|
408
|
+
const childY = y + h + GAP_Y;
|
|
409
|
+
for (let i = 0; i < node.reports.length; i++) {
|
|
410
|
+
const child = node.reports[i];
|
|
411
|
+
const childSW = subtreeWidth(child);
|
|
412
|
+
layoutNode.children.push(layoutTree(child, childX, childY));
|
|
413
|
+
childX += childSW + GAP_X;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return layoutNode;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// ── SVG rendering ────────────────────────────────────────────────
|
|
421
|
+
|
|
422
|
+
function escapeXml(s: string): string {
|
|
423
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Render a colorful Twemoji inside a circle at (cx, cy) with given radius */
|
|
427
|
+
function renderEmojiAvatar(cx: number, cy: number, radius: number, bgFill: string, emojiSvg: string, bgStroke?: string): string {
|
|
428
|
+
const emojiSize = radius * 1.3; // emoji fills most of the circle
|
|
429
|
+
const emojiX = cx - emojiSize / 2;
|
|
430
|
+
const emojiY = cy - emojiSize / 2;
|
|
431
|
+
const stroke = bgStroke ? `stroke="${bgStroke}" stroke-width="1"` : "";
|
|
432
|
+
return `<circle cx="${cx}" cy="${cy}" r="${radius}" fill="${bgFill}" ${stroke}/>
|
|
433
|
+
<svg x="${emojiX}" y="${emojiY}" width="${emojiSize}" height="${emojiSize}" viewBox="0 0 36 36">${emojiSvg}</svg>`;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function defaultRenderCard(ln: LayoutNode, theme: StyleTheme): string {
|
|
437
|
+
// Overflow placeholder card: just shows "+N more" text, no avatar
|
|
438
|
+
if (ln.node.role === "overflow") {
|
|
439
|
+
const cx = ln.x + ln.width / 2;
|
|
440
|
+
const cy = ln.y + ln.height / 2;
|
|
441
|
+
return `<g>
|
|
442
|
+
<rect x="${ln.x}" y="${ln.y}" width="${ln.width}" height="${ln.height}" rx="${theme.cardRadius}" fill="${theme.bgColor}" stroke="${theme.cardBorder}" stroke-width="1" stroke-dasharray="4,3"/>
|
|
443
|
+
<text x="${cx}" y="${cy + 5}" text-anchor="middle" font-family="${theme.font}" font-size="13" font-weight="600" fill="${theme.roleColor}">${escapeXml(ln.node.name)}</text>
|
|
444
|
+
</g>`;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const { roleLabel: defaultRoleLabel, bg, emojiSvg } = getRoleInfo(ln.node);
|
|
448
|
+
// Use node.role directly when it's a collapse badge (e.g. "×15 reports")
|
|
449
|
+
const roleLabel = ln.node.role.startsWith("×") ? ln.node.role : defaultRoleLabel;
|
|
450
|
+
const cx = ln.x + ln.width / 2;
|
|
451
|
+
|
|
452
|
+
const avatarCY = ln.y + 27;
|
|
453
|
+
const nameY = ln.y + 66;
|
|
454
|
+
const roleY = ln.y + 82;
|
|
455
|
+
|
|
456
|
+
const filterId = `shadow-${ln.node.id}`;
|
|
457
|
+
const shadowFilter = theme.cardShadow
|
|
458
|
+
? `filter="url(#${filterId})"`
|
|
459
|
+
: "";
|
|
460
|
+
const shadowDef = theme.cardShadow
|
|
461
|
+
? `<filter id="${filterId}" x="-4" y="-2" width="${ln.width + 8}" height="${ln.height + 6}">
|
|
462
|
+
<feDropShadow dx="0" dy="1" stdDeviation="2" flood-color="${theme.cardShadow}"/>
|
|
463
|
+
<feDropShadow dx="0" dy="1" stdDeviation="1" flood-color="rgba(0,0,0,0.03)"/>
|
|
464
|
+
</filter>`
|
|
465
|
+
: "";
|
|
466
|
+
|
|
467
|
+
// For dark themes without avatars, use a subtle circle
|
|
468
|
+
const isLight = theme.bgColor === "#fafaf9" || theme.bgColor === "#ffffff";
|
|
469
|
+
const avatarBg = isLight ? bg : "rgba(255,255,255,0.06)";
|
|
470
|
+
const avatarStroke = isLight ? undefined : "rgba(255,255,255,0.08)";
|
|
471
|
+
|
|
472
|
+
// Render collapsed avatar grid if this node has hidden reports
|
|
473
|
+
let avatarGridSvg = "";
|
|
474
|
+
const collapsed = ln.node.collapsedReports;
|
|
475
|
+
if (collapsed && collapsed.length > 0) {
|
|
476
|
+
const gridTop = ln.y + CARD_H + MINI_AVATAR_PADDING;
|
|
477
|
+
const cols = Math.min(collapsed.length, MINI_AVATAR_MAX_COLS);
|
|
478
|
+
const gridTotalW = cols * (MINI_AVATAR_SIZE + MINI_AVATAR_GAP) - MINI_AVATAR_GAP;
|
|
479
|
+
const gridStartX = ln.x + (ln.width - gridTotalW) / 2;
|
|
480
|
+
|
|
481
|
+
for (let i = 0; i < collapsed.length; i++) {
|
|
482
|
+
const col = i % MINI_AVATAR_MAX_COLS;
|
|
483
|
+
const row = Math.floor(i / MINI_AVATAR_MAX_COLS);
|
|
484
|
+
const dotCx = gridStartX + col * (MINI_AVATAR_SIZE + MINI_AVATAR_GAP) + MINI_AVATAR_SIZE / 2;
|
|
485
|
+
const dotCy = gridTop + row * (MINI_AVATAR_SIZE + MINI_AVATAR_GAP) + MINI_AVATAR_SIZE / 2;
|
|
486
|
+
const { bg: dotBg } = getRoleInfo(collapsed[i]);
|
|
487
|
+
const dotFill = isLight ? dotBg : "rgba(255,255,255,0.1)";
|
|
488
|
+
avatarGridSvg += `<circle cx="${dotCx}" cy="${dotCy}" r="${MINI_AVATAR_SIZE / 2}" fill="${dotFill}" stroke="${theme.cardBorder}" stroke-width="0.5"/>`;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
return `<g>
|
|
493
|
+
${shadowDef}
|
|
494
|
+
<rect x="${ln.x}" y="${ln.y}" width="${ln.width}" height="${ln.height}" rx="${theme.cardRadius}" fill="${theme.cardBg}" stroke="${theme.cardBorder}" stroke-width="1" ${shadowFilter}/>
|
|
495
|
+
${renderEmojiAvatar(cx, avatarCY, AVATAR_SIZE / 2, avatarBg, emojiSvg, avatarStroke)}
|
|
496
|
+
<text x="${cx}" y="${nameY}" text-anchor="middle" font-family="${theme.font}" font-size="14" font-weight="600" fill="${theme.nameColor}">${escapeXml(ln.node.name)}</text>
|
|
497
|
+
<text x="${cx}" y="${roleY}" text-anchor="middle" font-family="${theme.font}" font-size="11" font-weight="500" fill="${theme.roleColor}">${escapeXml(roleLabel)}</text>
|
|
498
|
+
${avatarGridSvg}
|
|
499
|
+
</g>`;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function renderConnectors(ln: LayoutNode, theme: StyleTheme): string {
|
|
503
|
+
if (ln.children.length === 0) return "";
|
|
504
|
+
|
|
505
|
+
const parentCx = ln.x + ln.width / 2;
|
|
506
|
+
const parentBottom = ln.y + ln.height;
|
|
507
|
+
const midY = parentBottom + GAP_Y / 2;
|
|
508
|
+
const lc = theme.lineColor;
|
|
509
|
+
const lw = theme.lineWidth;
|
|
510
|
+
|
|
511
|
+
let svg = "";
|
|
512
|
+
svg += `<line x1="${parentCx}" y1="${parentBottom}" x2="${parentCx}" y2="${midY}" stroke="${lc}" stroke-width="${lw}"/>`;
|
|
513
|
+
|
|
514
|
+
if (ln.children.length === 1) {
|
|
515
|
+
const childCx = ln.children[0].x + ln.children[0].width / 2;
|
|
516
|
+
svg += `<line x1="${childCx}" y1="${midY}" x2="${childCx}" y2="${ln.children[0].y}" stroke="${lc}" stroke-width="${lw}"/>`;
|
|
517
|
+
} else {
|
|
518
|
+
const leftCx = ln.children[0].x + ln.children[0].width / 2;
|
|
519
|
+
const rightCx = ln.children[ln.children.length - 1].x + ln.children[ln.children.length - 1].width / 2;
|
|
520
|
+
svg += `<line x1="${leftCx}" y1="${midY}" x2="${rightCx}" y2="${midY}" stroke="${lc}" stroke-width="${lw}"/>`;
|
|
521
|
+
|
|
522
|
+
for (const child of ln.children) {
|
|
523
|
+
const childCx = child.x + child.width / 2;
|
|
524
|
+
svg += `<line x1="${childCx}" y1="${midY}" x2="${childCx}" y2="${child.y}" stroke="${lc}" stroke-width="${lw}"/>`;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
for (const child of ln.children) {
|
|
529
|
+
svg += renderConnectors(child, theme);
|
|
530
|
+
}
|
|
531
|
+
return svg;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function renderCards(ln: LayoutNode, theme: StyleTheme): string {
|
|
535
|
+
const render = theme.renderCard || defaultRenderCard;
|
|
536
|
+
let svg = render(ln, theme);
|
|
537
|
+
for (const child of ln.children) {
|
|
538
|
+
svg += renderCards(child, theme);
|
|
539
|
+
}
|
|
540
|
+
return svg;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function treeBounds(ln: LayoutNode): { minX: number; minY: number; maxX: number; maxY: number } {
|
|
544
|
+
let minX = ln.x;
|
|
545
|
+
let minY = ln.y;
|
|
546
|
+
let maxX = ln.x + ln.width;
|
|
547
|
+
let maxY = ln.y + ln.height;
|
|
548
|
+
for (const child of ln.children) {
|
|
549
|
+
const cb = treeBounds(child);
|
|
550
|
+
minX = Math.min(minX, cb.minX);
|
|
551
|
+
minY = Math.min(minY, cb.minY);
|
|
552
|
+
maxX = Math.max(maxX, cb.maxX);
|
|
553
|
+
maxY = Math.max(maxY, cb.maxY);
|
|
554
|
+
}
|
|
555
|
+
return { minX, minY, maxX, maxY };
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Corporate logo: scaled icon (~16px) + wordmark (13px), vertically centered
|
|
559
|
+
const PAPERCLIP_LOGO_SVG = `<g>
|
|
560
|
+
<g transform="scale(0.72)" transform-origin="0 0">
|
|
561
|
+
<path stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" fill="none" d="m18 4-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"/>
|
|
562
|
+
</g>
|
|
563
|
+
<text x="22" y="11.5" font-family="system-ui, -apple-system, sans-serif" font-size="13" font-weight="600" fill="currentColor">Corporate</text>
|
|
564
|
+
</g>`;
|
|
565
|
+
|
|
566
|
+
// ── Public API ───────────────────────────────────────────────────
|
|
567
|
+
|
|
568
|
+
// GitHub recommended social media preview dimensions
|
|
569
|
+
const TARGET_W = 1280;
|
|
570
|
+
const TARGET_H = 640;
|
|
571
|
+
|
|
572
|
+
export interface OrgChartOverlay {
|
|
573
|
+
/** Company name displayed top-left */
|
|
574
|
+
companyName?: string;
|
|
575
|
+
/** Summary stats displayed bottom-right, e.g. "Agents: 5, Skills: 8" */
|
|
576
|
+
stats?: string;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/** Count total nodes in a tree. */
|
|
580
|
+
function countNodes(nodes: OrgNode[]): number {
|
|
581
|
+
let count = 0;
|
|
582
|
+
for (const n of nodes) {
|
|
583
|
+
count += 1 + countNodes(n.reports ?? []);
|
|
584
|
+
}
|
|
585
|
+
return count;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** Threshold: auto-collapse orgs larger than this. */
|
|
589
|
+
const COLLAPSE_THRESHOLD = 20;
|
|
590
|
+
/** Max cards that can fit across the 1280px image. */
|
|
591
|
+
const MAX_LEVEL_WIDTH = 8;
|
|
592
|
+
/** Max children shown per parent before truncation with "and N more". */
|
|
593
|
+
const MAX_CHILDREN_SHOWN = 6;
|
|
594
|
+
|
|
595
|
+
/** Flatten all descendants of a node into a single list. */
|
|
596
|
+
function flattenDescendants(nodes: OrgNode[]): OrgNode[] {
|
|
597
|
+
const result: OrgNode[] = [];
|
|
598
|
+
for (const n of nodes) {
|
|
599
|
+
result.push(n);
|
|
600
|
+
result.push(...flattenDescendants(n.reports ?? []));
|
|
601
|
+
}
|
|
602
|
+
return result;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** Collect all nodes at a given depth in the tree. */
|
|
606
|
+
function nodesAtDepth(nodes: OrgNode[], depth: number): OrgNode[] {
|
|
607
|
+
if (depth === 0) return nodes;
|
|
608
|
+
const result: OrgNode[] = [];
|
|
609
|
+
for (const n of nodes) {
|
|
610
|
+
result.push(...nodesAtDepth(n.reports ?? [], depth - 1));
|
|
611
|
+
}
|
|
612
|
+
return result;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Estimate how many cards would be shown at the next level if we expand,
|
|
617
|
+
* considering truncation (each parent shows at most MAX_CHILDREN_SHOWN + 1 placeholder).
|
|
618
|
+
*/
|
|
619
|
+
function estimateNextLevelWidth(parentNodes: OrgNode[]): number {
|
|
620
|
+
let total = 0;
|
|
621
|
+
for (const p of parentNodes) {
|
|
622
|
+
const childCount = (p.reports ?? []).length;
|
|
623
|
+
if (childCount === 0) continue;
|
|
624
|
+
total += Math.min(childCount, MAX_CHILDREN_SHOWN + 1); // +1 for "and N more" placeholder
|
|
625
|
+
}
|
|
626
|
+
return total;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Collapse a node's children to avatar dots (for wide levels that can't expand).
|
|
631
|
+
*/
|
|
632
|
+
function collapseToAvatars(node: OrgNode): OrgNode {
|
|
633
|
+
const childCount = countNodes(node.reports ?? []);
|
|
634
|
+
if (childCount === 0) return node;
|
|
635
|
+
return {
|
|
636
|
+
...node,
|
|
637
|
+
role: `×${childCount} reports`,
|
|
638
|
+
collapsedReports: flattenDescendants(node.reports ?? []),
|
|
639
|
+
reports: [],
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Truncate a node's children: keep first MAX_CHILDREN_SHOWN, replace rest with
|
|
645
|
+
* a summary "and N more" placeholder node (rendered as a count card).
|
|
646
|
+
*/
|
|
647
|
+
function truncateChildren(node: OrgNode): OrgNode {
|
|
648
|
+
const children = node.reports ?? [];
|
|
649
|
+
if (children.length <= MAX_CHILDREN_SHOWN) return node;
|
|
650
|
+
const kept = children.slice(0, MAX_CHILDREN_SHOWN);
|
|
651
|
+
const hiddenCount = children.length - MAX_CHILDREN_SHOWN;
|
|
652
|
+
const placeholder: OrgNode = {
|
|
653
|
+
id: `${node.id}-more`,
|
|
654
|
+
name: `+${hiddenCount} more`,
|
|
655
|
+
role: "overflow",
|
|
656
|
+
status: "active",
|
|
657
|
+
reports: [],
|
|
658
|
+
};
|
|
659
|
+
return { ...node, reports: [...kept, placeholder] };
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Adaptive collapse: expands levels as long as they fit, truncates or collapses
|
|
664
|
+
* when a level is too wide.
|
|
665
|
+
*/
|
|
666
|
+
function smartCollapseTree(roots: OrgNode[]): OrgNode[] {
|
|
667
|
+
// Deep clone so we can mutate
|
|
668
|
+
const clone = (nodes: OrgNode[]): OrgNode[] =>
|
|
669
|
+
nodes.map((n) => ({ ...n, reports: clone(n.reports ?? []) }));
|
|
670
|
+
const tree = clone(roots);
|
|
671
|
+
|
|
672
|
+
// Walk levels from root down
|
|
673
|
+
for (let depth = 0; depth < 10; depth++) {
|
|
674
|
+
const parents = nodesAtDepth(tree, depth);
|
|
675
|
+
const parentsWithChildren = parents.filter((p) => (p.reports ?? []).length > 0);
|
|
676
|
+
if (parentsWithChildren.length === 0) break;
|
|
677
|
+
|
|
678
|
+
const nextWidth = estimateNextLevelWidth(parentsWithChildren);
|
|
679
|
+
if (nextWidth <= MAX_LEVEL_WIDTH) {
|
|
680
|
+
// Next level fits with truncation — truncate oversized parents, then continue deeper
|
|
681
|
+
for (const p of parentsWithChildren) {
|
|
682
|
+
if ((p.reports ?? []).length > MAX_CHILDREN_SHOWN) {
|
|
683
|
+
const truncated = truncateChildren(p);
|
|
684
|
+
p.reports = truncated.reports;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// Next level is too wide — collapse all children at this level to avatars
|
|
691
|
+
for (const p of parentsWithChildren) {
|
|
692
|
+
const collapsed = collapseToAvatars(p);
|
|
693
|
+
p.role = collapsed.role;
|
|
694
|
+
p.collapsedReports = collapsed.collapsedReports;
|
|
695
|
+
p.reports = [];
|
|
696
|
+
}
|
|
697
|
+
break;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
return tree;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
export function renderOrgChartSvg(orgTree: OrgNode[], style: OrgChartStyle = "warmth", overlay?: OrgChartOverlay): string {
|
|
704
|
+
const theme = THEMES[style] || THEMES.warmth;
|
|
705
|
+
|
|
706
|
+
// Auto-collapse large orgs to keep the chart readable
|
|
707
|
+
const totalNodes = countNodes(orgTree);
|
|
708
|
+
const effectiveTree = totalNodes > COLLAPSE_THRESHOLD ? smartCollapseTree(orgTree) : orgTree;
|
|
709
|
+
|
|
710
|
+
let root: OrgNode;
|
|
711
|
+
if (effectiveTree.length === 1) {
|
|
712
|
+
root = effectiveTree[0];
|
|
713
|
+
} else {
|
|
714
|
+
root = {
|
|
715
|
+
id: "virtual-root",
|
|
716
|
+
name: "Organization",
|
|
717
|
+
role: "Root",
|
|
718
|
+
status: "active",
|
|
719
|
+
reports: effectiveTree,
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const layout = layoutTree(root, PADDING, PADDING + 24);
|
|
724
|
+
const bounds = treeBounds(layout);
|
|
725
|
+
|
|
726
|
+
const contentW = bounds.maxX + PADDING;
|
|
727
|
+
const contentH = bounds.maxY + PADDING;
|
|
728
|
+
|
|
729
|
+
// Scale content to fit within the fixed target dimensions
|
|
730
|
+
const scale = Math.min(TARGET_W / contentW, TARGET_H / contentH, 1);
|
|
731
|
+
const scaledW = contentW * scale;
|
|
732
|
+
const scaledH = contentH * scale;
|
|
733
|
+
// Center the scaled content within the target frame
|
|
734
|
+
const offsetX = (TARGET_W - scaledW) / 2;
|
|
735
|
+
const offsetY = (TARGET_H - scaledH) / 2;
|
|
736
|
+
|
|
737
|
+
const logoX = TARGET_W - 110 - LOGO_PADDING;
|
|
738
|
+
const logoY = LOGO_PADDING;
|
|
739
|
+
|
|
740
|
+
// Optional overlay elements
|
|
741
|
+
const overlayNameSvg = overlay?.companyName
|
|
742
|
+
? `<text x="${LOGO_PADDING}" y="${LOGO_PADDING + 16}" font-family="'Inter', -apple-system, BlinkMacSystemFont, sans-serif" font-size="22" font-weight="700" fill="${theme.nameColor}">${svgEscape(overlay.companyName)}</text>`
|
|
743
|
+
: "";
|
|
744
|
+
const overlayStatsSvg = overlay?.stats
|
|
745
|
+
? `<text x="${TARGET_W - LOGO_PADDING}" y="${TARGET_H - LOGO_PADDING}" text-anchor="end" font-family="'Inter', -apple-system, BlinkMacSystemFont, sans-serif" font-size="13" font-weight="500" fill="${theme.roleColor}">${svgEscape(overlay.stats)}</text>`
|
|
746
|
+
: "";
|
|
747
|
+
|
|
748
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${TARGET_W}" height="${TARGET_H}" viewBox="0 0 ${TARGET_W} ${TARGET_H}">
|
|
749
|
+
<defs>${theme.defs(TARGET_W, TARGET_H)}</defs>
|
|
750
|
+
<rect width="100%" height="100%" fill="${theme.bgColor}" rx="6"/>
|
|
751
|
+
${theme.bgExtras(TARGET_W, TARGET_H)}
|
|
752
|
+
<g transform="translate(${logoX}, ${logoY})" color="${theme.watermarkColor}">
|
|
753
|
+
${PAPERCLIP_LOGO_SVG}
|
|
754
|
+
</g>
|
|
755
|
+
${overlayNameSvg}
|
|
756
|
+
${overlayStatsSvg}
|
|
757
|
+
<g transform="translate(${offsetX}, ${offsetY}) scale(${scale})">
|
|
758
|
+
${renderConnectors(layout, theme)}
|
|
759
|
+
${renderCards(layout, theme)}
|
|
760
|
+
</g>
|
|
761
|
+
</svg>`;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
function svgEscape(s: string): string {
|
|
765
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
export async function renderOrgChartPng(orgTree: OrgNode[], style: OrgChartStyle = "warmth", overlay?: OrgChartOverlay): Promise<Buffer> {
|
|
769
|
+
const svg = renderOrgChartSvg(orgTree, style, overlay);
|
|
770
|
+
const sharpModule = await import("sharp");
|
|
771
|
+
const sharp = sharpModule.default;
|
|
772
|
+
// Render at 2x density for retina quality, resize to exact target dimensions
|
|
773
|
+
return sharp(Buffer.from(svg), { density: 144 })
|
|
774
|
+
.resize(TARGET_W, TARGET_H)
|
|
775
|
+
.png()
|
|
776
|
+
.toBuffer();
|
|
777
|
+
}
|