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,26 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_INSTANCE_SETTINGS_PATH,
|
|
4
|
+
normalizeRememberedInstanceSettingsPath,
|
|
5
|
+
} from "./instance-settings";
|
|
6
|
+
|
|
7
|
+
describe("normalizeRememberedInstanceSettingsPath", () => {
|
|
8
|
+
it("keeps known instance settings pages", () => {
|
|
9
|
+
expect(normalizeRememberedInstanceSettingsPath("/instance/settings/general")).toBe(
|
|
10
|
+
"/instance/settings/general",
|
|
11
|
+
);
|
|
12
|
+
expect(normalizeRememberedInstanceSettingsPath("/instance/settings/experimental")).toBe(
|
|
13
|
+
"/instance/settings/experimental",
|
|
14
|
+
);
|
|
15
|
+
expect(normalizeRememberedInstanceSettingsPath("/instance/settings/plugins/example?tab=config#logs")).toBe(
|
|
16
|
+
"/instance/settings/plugins/example?tab=config#logs",
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("falls back to the default page for unknown paths", () => {
|
|
21
|
+
expect(normalizeRememberedInstanceSettingsPath("/instance/settings/nope")).toBe(
|
|
22
|
+
DEFAULT_INSTANCE_SETTINGS_PATH,
|
|
23
|
+
);
|
|
24
|
+
expect(normalizeRememberedInstanceSettingsPath(null)).toBe(DEFAULT_INSTANCE_SETTINGS_PATH);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const DEFAULT_INSTANCE_SETTINGS_PATH = "/instance/settings/general";
|
|
2
|
+
|
|
3
|
+
export function normalizeRememberedInstanceSettingsPath(rawPath: string | null): string {
|
|
4
|
+
if (!rawPath) return DEFAULT_INSTANCE_SETTINGS_PATH;
|
|
5
|
+
|
|
6
|
+
const match = rawPath.match(/^([^?#]*)(\?[^#]*)?(#.*)?$/);
|
|
7
|
+
const pathname = match?.[1] ?? rawPath;
|
|
8
|
+
const search = match?.[2] ?? "";
|
|
9
|
+
const hash = match?.[3] ?? "";
|
|
10
|
+
|
|
11
|
+
if (
|
|
12
|
+
pathname === "/instance/settings/general" ||
|
|
13
|
+
pathname === "/instance/settings/heartbeats" ||
|
|
14
|
+
pathname === "/instance/settings/plugins" ||
|
|
15
|
+
pathname === "/instance/settings/experimental"
|
|
16
|
+
) {
|
|
17
|
+
return `${pathname}${search}${hash}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (/^\/instance\/settings\/plugins\/[^/?#]+$/.test(pathname)) {
|
|
21
|
+
return `${pathname}${search}${hash}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return DEFAULT_INSTANCE_SETTINGS_PATH;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type IssueDetailBreadcrumb = {
|
|
2
|
+
label: string;
|
|
3
|
+
href: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
type IssueDetailLocationState = {
|
|
7
|
+
issueDetailBreadcrumb?: IssueDetailBreadcrumb;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function isIssueDetailBreadcrumb(value: unknown): value is IssueDetailBreadcrumb {
|
|
11
|
+
if (typeof value !== "object" || value === null) return false;
|
|
12
|
+
const candidate = value as Partial<IssueDetailBreadcrumb>;
|
|
13
|
+
return typeof candidate.label === "string" && typeof candidate.href === "string";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function createIssueDetailLocationState(label: string, href: string): IssueDetailLocationState {
|
|
17
|
+
return { issueDetailBreadcrumb: { label, href } };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function readIssueDetailBreadcrumb(state: unknown): IssueDetailBreadcrumb | null {
|
|
21
|
+
if (typeof state !== "object" || state === null) return null;
|
|
22
|
+
const candidate = (state as IssueDetailLocationState).issueDetailBreadcrumb;
|
|
23
|
+
return isIssueDetailBreadcrumb(candidate) ? candidate : null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
hasLegacyWorkingDirectory,
|
|
4
|
+
shouldShowLegacyWorkingDirectoryField,
|
|
5
|
+
} from "./legacy-agent-config";
|
|
6
|
+
|
|
7
|
+
describe("legacy agent config helpers", () => {
|
|
8
|
+
it("treats non-empty cwd values as legacy working directories", () => {
|
|
9
|
+
expect(hasLegacyWorkingDirectory("/tmp/workspace")).toBe(true);
|
|
10
|
+
expect(hasLegacyWorkingDirectory(" /tmp/workspace ")).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("ignores nullish and blank cwd values", () => {
|
|
14
|
+
expect(hasLegacyWorkingDirectory("")).toBe(false);
|
|
15
|
+
expect(hasLegacyWorkingDirectory(" ")).toBe(false);
|
|
16
|
+
expect(hasLegacyWorkingDirectory(null)).toBe(false);
|
|
17
|
+
expect(hasLegacyWorkingDirectory(undefined)).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("shows the deprecated field only for edit forms with an existing cwd", () => {
|
|
21
|
+
expect(
|
|
22
|
+
shouldShowLegacyWorkingDirectoryField({
|
|
23
|
+
isCreate: true,
|
|
24
|
+
adapterConfig: { cwd: "/tmp/workspace" },
|
|
25
|
+
}),
|
|
26
|
+
).toBe(false);
|
|
27
|
+
expect(
|
|
28
|
+
shouldShowLegacyWorkingDirectoryField({
|
|
29
|
+
isCreate: false,
|
|
30
|
+
adapterConfig: { cwd: "" },
|
|
31
|
+
}),
|
|
32
|
+
).toBe(false);
|
|
33
|
+
expect(
|
|
34
|
+
shouldShowLegacyWorkingDirectoryField({
|
|
35
|
+
isCreate: false,
|
|
36
|
+
adapterConfig: { cwd: "/tmp/workspace" },
|
|
37
|
+
}),
|
|
38
|
+
).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function asNonEmptyString(value: unknown): string | null {
|
|
2
|
+
if (typeof value !== "string") return null;
|
|
3
|
+
const trimmed = value.trim();
|
|
4
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function hasLegacyWorkingDirectory(value: unknown): boolean {
|
|
8
|
+
return asNonEmptyString(value) !== null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function shouldShowLegacyWorkingDirectoryField(input: {
|
|
12
|
+
isCreate: boolean;
|
|
13
|
+
adapterConfig: Record<string, unknown> | null | undefined;
|
|
14
|
+
}): boolean {
|
|
15
|
+
if (input.isCreate) return false;
|
|
16
|
+
return hasLegacyWorkingDirectory(input.adapterConfig?.cwd);
|
|
17
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { $createLinkNode } from "@lexical/link";
|
|
3
|
+
import { createEditor } from "lexical";
|
|
4
|
+
import {
|
|
5
|
+
MentionAwareLinkNode,
|
|
6
|
+
getMentionAwareLinkNodeInit,
|
|
7
|
+
mentionAwareLinkNodeReplacement,
|
|
8
|
+
} from "./mention-aware-link-node";
|
|
9
|
+
|
|
10
|
+
function createTestEditor() {
|
|
11
|
+
return createEditor({
|
|
12
|
+
namespace: "mention-aware-link-node-test",
|
|
13
|
+
nodes: [MentionAwareLinkNode, mentionAwareLinkNodeReplacement],
|
|
14
|
+
onError(error: Error) {
|
|
15
|
+
throw error;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("getMentionAwareLinkNodeInit", () => {
|
|
21
|
+
it("copies link attributes without carrying over a node key", () => {
|
|
22
|
+
const init = getMentionAwareLinkNodeInit({
|
|
23
|
+
getURL: () => "agent://agent-123",
|
|
24
|
+
getRel: () => "noreferrer",
|
|
25
|
+
getTarget: () => "_blank",
|
|
26
|
+
getTitle: () => "Agent mention",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(Object.keys(init)).toEqual(["url", "attributes"]);
|
|
30
|
+
expect(init).toEqual({
|
|
31
|
+
url: "agent://agent-123",
|
|
32
|
+
attributes: {
|
|
33
|
+
rel: "noreferrer",
|
|
34
|
+
target: "_blank",
|
|
35
|
+
title: "Agent mention",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("replaces LinkNode creation with MentionAwareLinkNode without throwing", () => {
|
|
41
|
+
const editor = createTestEditor();
|
|
42
|
+
let created: unknown;
|
|
43
|
+
|
|
44
|
+
editor.update(() => {
|
|
45
|
+
created = $createLinkNode("agent://agent-123");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(created).toBeInstanceOf(MentionAwareLinkNode);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LinkNode,
|
|
3
|
+
type LinkAttributes,
|
|
4
|
+
type SerializedLinkNode,
|
|
5
|
+
} from "@lexical/link";
|
|
6
|
+
|
|
7
|
+
const CUSTOM_MENTION_URL_RE = /^(agent|project):\/\//;
|
|
8
|
+
|
|
9
|
+
export class MentionAwareLinkNode extends LinkNode {
|
|
10
|
+
static getType(): string {
|
|
11
|
+
return "mention-aware-link";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static clone(node: MentionAwareLinkNode): MentionAwareLinkNode {
|
|
15
|
+
return new MentionAwareLinkNode(
|
|
16
|
+
node.getURL(),
|
|
17
|
+
{
|
|
18
|
+
rel: node.getRel(),
|
|
19
|
+
target: node.getTarget(),
|
|
20
|
+
title: node.getTitle(),
|
|
21
|
+
},
|
|
22
|
+
node.getKey(),
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static importJSON(serializedNode: SerializedLinkNode): MentionAwareLinkNode {
|
|
27
|
+
return new MentionAwareLinkNode(
|
|
28
|
+
serializedNode.url ?? "",
|
|
29
|
+
{
|
|
30
|
+
rel: serializedNode.rel ?? null,
|
|
31
|
+
target: serializedNode.target ?? null,
|
|
32
|
+
title: serializedNode.title ?? null,
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor(url?: string, attributes?: LinkAttributes, key?: string) {
|
|
38
|
+
super(url, attributes, key);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
sanitizeUrl(url: string): string {
|
|
42
|
+
if (CUSTOM_MENTION_URL_RE.test(url)) return url;
|
|
43
|
+
return super.sanitizeUrl(url);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type MentionAwareLinkSource = Pick<LinkNode, "getURL" | "getRel" | "getTarget" | "getTitle">;
|
|
48
|
+
|
|
49
|
+
export function getMentionAwareLinkNodeInit(node: MentionAwareLinkSource) {
|
|
50
|
+
return {
|
|
51
|
+
url: node.getURL(),
|
|
52
|
+
attributes: {
|
|
53
|
+
rel: node.getRel(),
|
|
54
|
+
target: node.getTarget(),
|
|
55
|
+
title: node.getTitle(),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const mentionAwareLinkNodeReplacement = {
|
|
61
|
+
replace: LinkNode,
|
|
62
|
+
with: (node: LinkNode) => {
|
|
63
|
+
const { url, attributes } = getMentionAwareLinkNodeInit(node);
|
|
64
|
+
return new MentionAwareLinkNode(url, attributes);
|
|
65
|
+
},
|
|
66
|
+
withKlass: MentionAwareLinkNode,
|
|
67
|
+
} as const;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import { parseAgentMentionHref, parseProjectMentionHref } from "@corporateai/shared";
|
|
3
|
+
import { getAgentIcon } from "./agent-icons";
|
|
4
|
+
import { hexToRgb, pickTextColorForPillBg } from "./color-contrast";
|
|
5
|
+
|
|
6
|
+
export type ParsedMentionChip =
|
|
7
|
+
| {
|
|
8
|
+
kind: "agent";
|
|
9
|
+
agentId: string;
|
|
10
|
+
icon: string | null;
|
|
11
|
+
}
|
|
12
|
+
| {
|
|
13
|
+
kind: "project";
|
|
14
|
+
projectId: string;
|
|
15
|
+
color: string | null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const iconMaskCache = new Map<string, string>();
|
|
19
|
+
|
|
20
|
+
export function parseMentionChipHref(href: string): ParsedMentionChip | null {
|
|
21
|
+
const agent = parseAgentMentionHref(href);
|
|
22
|
+
if (agent) {
|
|
23
|
+
return {
|
|
24
|
+
kind: "agent",
|
|
25
|
+
agentId: agent.agentId,
|
|
26
|
+
icon: agent.icon,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const project = parseProjectMentionHref(href);
|
|
31
|
+
if (project) {
|
|
32
|
+
return {
|
|
33
|
+
kind: "project",
|
|
34
|
+
projectId: project.projectId,
|
|
35
|
+
color: project.color,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function mentionChipInlineStyle(mention: ParsedMentionChip): CSSProperties | undefined {
|
|
43
|
+
const style: CSSProperties & Record<string, string> = {};
|
|
44
|
+
|
|
45
|
+
if (mention.kind === "project" && mention.color) {
|
|
46
|
+
const projectStyle = projectMentionColors(mention.color);
|
|
47
|
+
Object.assign(style, projectStyle);
|
|
48
|
+
style["--paperclip-mention-project-color"] = mention.color;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (mention.kind === "agent") {
|
|
52
|
+
const iconMask = buildAgentIconMask(mention.icon);
|
|
53
|
+
if (iconMask) {
|
|
54
|
+
style["--paperclip-mention-icon-mask"] = iconMask;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return Object.keys(style).length > 0 ? (style as CSSProperties) : undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function applyMentionChipDecoration(element: HTMLElement, mention: ParsedMentionChip) {
|
|
62
|
+
clearMentionChipDecoration(element);
|
|
63
|
+
element.dataset.mentionKind = mention.kind;
|
|
64
|
+
element.setAttribute("contenteditable", "false");
|
|
65
|
+
element.classList.add("paperclip-mention-chip", `paperclip-mention-chip--${mention.kind}`);
|
|
66
|
+
if (mention.kind === "project") {
|
|
67
|
+
element.classList.add("paperclip-project-mention-chip");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const style = mentionChipInlineStyle(mention);
|
|
71
|
+
if (!style) return;
|
|
72
|
+
for (const [key, value] of Object.entries(style)) {
|
|
73
|
+
if (typeof value === "string") {
|
|
74
|
+
if (key.startsWith("--")) {
|
|
75
|
+
element.style.setProperty(key, value);
|
|
76
|
+
} else {
|
|
77
|
+
(element.style as CSSStyleDeclaration & Record<string, string>)[key] = value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function clearMentionChipDecoration(element: HTMLElement) {
|
|
84
|
+
delete element.dataset.mentionKind;
|
|
85
|
+
element.classList.remove(
|
|
86
|
+
"paperclip-mention-chip",
|
|
87
|
+
"paperclip-mention-chip--agent",
|
|
88
|
+
"paperclip-mention-chip--project",
|
|
89
|
+
"paperclip-project-mention-chip",
|
|
90
|
+
);
|
|
91
|
+
element.removeAttribute("contenteditable");
|
|
92
|
+
element.style.removeProperty("border-color");
|
|
93
|
+
element.style.removeProperty("background-color");
|
|
94
|
+
element.style.removeProperty("color");
|
|
95
|
+
element.style.removeProperty("--paperclip-mention-project-color");
|
|
96
|
+
element.style.removeProperty("--paperclip-mention-icon-mask");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function projectMentionColors(color: string): Pick<CSSProperties, "borderColor" | "backgroundColor" | "color"> {
|
|
100
|
+
const rgb = hexToRgb(color);
|
|
101
|
+
if (!rgb) return {};
|
|
102
|
+
return {
|
|
103
|
+
borderColor: color,
|
|
104
|
+
backgroundColor: `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0.22)`,
|
|
105
|
+
color: pickTextColorForPillBg(color),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function buildAgentIconMask(iconName: string | null): string | null {
|
|
110
|
+
const cacheKey = iconName ?? "__default__";
|
|
111
|
+
const cached = iconMaskCache.get(cacheKey);
|
|
112
|
+
if (cached) return cached;
|
|
113
|
+
|
|
114
|
+
const Icon = getAgentIcon(iconName);
|
|
115
|
+
const iconNode = resolveLucideIconNode(Icon);
|
|
116
|
+
if (!Array.isArray(iconNode) || iconNode.length === 0) return null;
|
|
117
|
+
|
|
118
|
+
const body = iconNode.map(([tag, attrs]) => {
|
|
119
|
+
const attrString = Object.entries(attrs)
|
|
120
|
+
.filter(([key]) => key !== "key")
|
|
121
|
+
.map(([key, value]) => `${key}="${escapeAttribute(String(value))}"`)
|
|
122
|
+
.join(" ");
|
|
123
|
+
return `<${tag}${attrString ? ` ${attrString}` : ""}></${tag}>`;
|
|
124
|
+
}).join("");
|
|
125
|
+
|
|
126
|
+
const svg =
|
|
127
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" ` +
|
|
128
|
+
`fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" ` +
|
|
129
|
+
`stroke-linejoin="round">${body}</svg>`;
|
|
130
|
+
const url = `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
131
|
+
iconMaskCache.set(cacheKey, url);
|
|
132
|
+
return url;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function resolveLucideIconNode(
|
|
136
|
+
icon: unknown,
|
|
137
|
+
): Array<[string, Record<string, string>]> | null {
|
|
138
|
+
const staticIconNode = (
|
|
139
|
+
icon as {
|
|
140
|
+
iconNode?: Array<[string, Record<string, string>]>;
|
|
141
|
+
}
|
|
142
|
+
).iconNode;
|
|
143
|
+
if (Array.isArray(staticIconNode) && staticIconNode.length > 0) {
|
|
144
|
+
return staticIconNode;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const render = (
|
|
148
|
+
icon as {
|
|
149
|
+
render?: (props: Record<string, unknown>, ref: unknown) => {
|
|
150
|
+
props?: { iconNode?: Array<[string, Record<string, string>]> };
|
|
151
|
+
} | null;
|
|
152
|
+
}
|
|
153
|
+
).render;
|
|
154
|
+
const rendered = typeof render === "function" ? render({}, null) : null;
|
|
155
|
+
const renderedIconNode = rendered?.props?.iconNode;
|
|
156
|
+
return Array.isArray(renderedIconNode) && renderedIconNode.length > 0
|
|
157
|
+
? renderedIconNode
|
|
158
|
+
: null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function escapeAttribute(value: string): string {
|
|
162
|
+
return value
|
|
163
|
+
.replaceAll("&", "&")
|
|
164
|
+
.replaceAll('"', """)
|
|
165
|
+
.replaceAll("<", "<")
|
|
166
|
+
.replaceAll(">", ">");
|
|
167
|
+
}
|
|
168
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { $createLinkNode, LinkNode } from "@lexical/link";
|
|
3
|
+
import { buildAgentMentionHref } from "@corporateai/shared";
|
|
4
|
+
import {
|
|
5
|
+
createEditor,
|
|
6
|
+
$createParagraphNode,
|
|
7
|
+
$createTextNode,
|
|
8
|
+
$getRoot,
|
|
9
|
+
$getSelection,
|
|
10
|
+
$isRangeSelection,
|
|
11
|
+
} from "lexical";
|
|
12
|
+
import { deleteSelectedMentionChip } from "./mention-deletion";
|
|
13
|
+
|
|
14
|
+
function createTestEditor() {
|
|
15
|
+
return createEditor({
|
|
16
|
+
namespace: "mention-deletion-test",
|
|
17
|
+
nodes: [LinkNode],
|
|
18
|
+
onError(error: Error) {
|
|
19
|
+
throw error;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe("mention deletion", () => {
|
|
25
|
+
it("removes the full mention when backspacing from inside the chip", () => {
|
|
26
|
+
const editor = createTestEditor();
|
|
27
|
+
|
|
28
|
+
editor.update(() => {
|
|
29
|
+
const root = $getRoot();
|
|
30
|
+
const paragraph = $createParagraphNode();
|
|
31
|
+
const before = $createTextNode("Hello ");
|
|
32
|
+
const mention = $createLinkNode(buildAgentMentionHref("agent-123", "code"));
|
|
33
|
+
const mentionText = $createTextNode("@QA");
|
|
34
|
+
const after = $createTextNode(" world");
|
|
35
|
+
|
|
36
|
+
mention.append(mentionText);
|
|
37
|
+
paragraph.append(before, mention, after);
|
|
38
|
+
root.append(paragraph);
|
|
39
|
+
|
|
40
|
+
mentionText.selectEnd();
|
|
41
|
+
|
|
42
|
+
expect(deleteSelectedMentionChip("backward")).toBe(true);
|
|
43
|
+
expect(root.getTextContent()).toBe("Hello world");
|
|
44
|
+
|
|
45
|
+
const selection = $getSelection();
|
|
46
|
+
expect($isRangeSelection(selection)).toBe(true);
|
|
47
|
+
if (!$isRangeSelection(selection)) {
|
|
48
|
+
throw new Error("Expected range selection after backward mention deletion");
|
|
49
|
+
}
|
|
50
|
+
expect(selection.isCollapsed()).toBe(true);
|
|
51
|
+
expect(selection.anchor.getNode().is(before)).toBe(true);
|
|
52
|
+
expect(selection.anchor.offset).toBe(before.getTextContentSize());
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("removes the full mention when deleting forward from adjacent text", () => {
|
|
57
|
+
const editor = createTestEditor();
|
|
58
|
+
|
|
59
|
+
editor.update(() => {
|
|
60
|
+
const root = $getRoot();
|
|
61
|
+
const paragraph = $createParagraphNode();
|
|
62
|
+
const before = $createTextNode("Hello ");
|
|
63
|
+
const mention = $createLinkNode(buildAgentMentionHref("agent-123", "code"));
|
|
64
|
+
const mentionText = $createTextNode("@QA");
|
|
65
|
+
const after = $createTextNode(" world");
|
|
66
|
+
|
|
67
|
+
mention.append(mentionText);
|
|
68
|
+
paragraph.append(before, mention, after);
|
|
69
|
+
root.append(paragraph);
|
|
70
|
+
|
|
71
|
+
before.selectEnd();
|
|
72
|
+
|
|
73
|
+
expect(deleteSelectedMentionChip("forward")).toBe(true);
|
|
74
|
+
expect(root.getTextContent()).toBe("Hello world");
|
|
75
|
+
|
|
76
|
+
const selection = $getSelection();
|
|
77
|
+
expect($isRangeSelection(selection)).toBe(true);
|
|
78
|
+
if (!$isRangeSelection(selection)) {
|
|
79
|
+
throw new Error("Expected range selection after forward mention deletion");
|
|
80
|
+
}
|
|
81
|
+
expect(selection.isCollapsed()).toBe(true);
|
|
82
|
+
expect(selection.anchor.getNode().is(after)).toBe(true);
|
|
83
|
+
expect(selection.anchor.offset).toBe(0);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createRootEditorSubscription$, realmPlugin } from "@mdxeditor/editor";
|
|
2
|
+
import { $isLinkNode, type LinkNode } from "@lexical/link";
|
|
3
|
+
import {
|
|
4
|
+
$getSelection,
|
|
5
|
+
$isElementNode,
|
|
6
|
+
$isNodeSelection,
|
|
7
|
+
$isRangeSelection,
|
|
8
|
+
$isTextNode,
|
|
9
|
+
COMMAND_PRIORITY_HIGH,
|
|
10
|
+
KEY_BACKSPACE_COMMAND,
|
|
11
|
+
KEY_DELETE_COMMAND,
|
|
12
|
+
type LexicalNode,
|
|
13
|
+
type PointType,
|
|
14
|
+
} from "lexical";
|
|
15
|
+
import { parseMentionChipHref } from "./mention-chips";
|
|
16
|
+
|
|
17
|
+
export type MentionDeletionDirection = "backward" | "forward";
|
|
18
|
+
|
|
19
|
+
function isMentionLinkNode(node: LexicalNode | null | undefined): node is LinkNode {
|
|
20
|
+
return Boolean(node && $isLinkNode(node) && parseMentionChipHref(node.getURL()));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function findMentionLinkNode(node: LexicalNode | null | undefined): LinkNode | null {
|
|
24
|
+
if (!node) return null;
|
|
25
|
+
if (isMentionLinkNode(node)) return node;
|
|
26
|
+
|
|
27
|
+
let parent = node.getParent();
|
|
28
|
+
while (parent) {
|
|
29
|
+
if (isMentionLinkNode(parent)) return parent;
|
|
30
|
+
parent = parent.getParent();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function findMentionLinkNodeAtPoint(point: PointType, direction: MentionDeletionDirection): LinkNode | null {
|
|
37
|
+
const node = point.getNode();
|
|
38
|
+
const directMention = findMentionLinkNode(node);
|
|
39
|
+
if (directMention) return directMention;
|
|
40
|
+
|
|
41
|
+
if (point.type === "element" && $isElementNode(node)) {
|
|
42
|
+
const childIndex = direction === "backward" ? point.offset - 1 : point.offset;
|
|
43
|
+
if (childIndex < 0) return null;
|
|
44
|
+
return findMentionLinkNode(node.getChildAtIndex(childIndex));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (point.type === "text" && $isTextNode(node)) {
|
|
48
|
+
if (direction === "backward" && point.offset === 0) {
|
|
49
|
+
return findMentionLinkNode(node.getPreviousSibling());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (direction === "forward" && point.offset === node.getTextContentSize()) {
|
|
53
|
+
return findMentionLinkNode(node.getNextSibling());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function findMentionLinkForDeletion(direction: MentionDeletionDirection): LinkNode | null {
|
|
61
|
+
const selection = $getSelection();
|
|
62
|
+
if (!selection) return null;
|
|
63
|
+
|
|
64
|
+
if ($isNodeSelection(selection)) {
|
|
65
|
+
const [selectedNode] = selection.getNodes();
|
|
66
|
+
return selectedNode ? findMentionLinkNode(selectedNode) : null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!$isRangeSelection(selection)) return null;
|
|
70
|
+
|
|
71
|
+
const anchorMention = findMentionLinkNode(selection.anchor.getNode());
|
|
72
|
+
const focusMention = findMentionLinkNode(selection.focus.getNode());
|
|
73
|
+
if (anchorMention && focusMention && anchorMention.is(focusMention)) {
|
|
74
|
+
return anchorMention;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!selection.isCollapsed()) return null;
|
|
78
|
+
|
|
79
|
+
return findMentionLinkNodeAtPoint(selection.anchor, direction);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function deleteSelectedMentionChip(direction: MentionDeletionDirection): boolean {
|
|
83
|
+
const mentionNode = findMentionLinkForDeletion(direction);
|
|
84
|
+
if (!mentionNode) return false;
|
|
85
|
+
|
|
86
|
+
const previousSibling = mentionNode.getPreviousSibling();
|
|
87
|
+
const nextSibling = mentionNode.getNextSibling();
|
|
88
|
+
const parent = mentionNode.getParentOrThrow();
|
|
89
|
+
|
|
90
|
+
mentionNode.remove();
|
|
91
|
+
|
|
92
|
+
if (direction === "backward") {
|
|
93
|
+
if (previousSibling) {
|
|
94
|
+
previousSibling.selectEnd();
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
if (nextSibling) {
|
|
98
|
+
nextSibling.selectStart();
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
parent.selectStart();
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (nextSibling) {
|
|
106
|
+
nextSibling.selectStart();
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (previousSibling) {
|
|
110
|
+
previousSibling.selectEnd();
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
parent.selectEnd();
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function handleMentionDelete(direction: MentionDeletionDirection, event: KeyboardEvent | null): boolean {
|
|
118
|
+
const didDelete = deleteSelectedMentionChip(direction);
|
|
119
|
+
if (!didDelete) return false;
|
|
120
|
+
|
|
121
|
+
event?.preventDefault();
|
|
122
|
+
event?.stopPropagation();
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const mentionDeletionPlugin = realmPlugin({
|
|
127
|
+
init(realm) {
|
|
128
|
+
realm.pub(createRootEditorSubscription$, [
|
|
129
|
+
(editor) =>
|
|
130
|
+
editor.registerCommand(
|
|
131
|
+
KEY_BACKSPACE_COMMAND,
|
|
132
|
+
(event) => handleMentionDelete("backward", event as KeyboardEvent | null),
|
|
133
|
+
COMMAND_PRIORITY_HIGH,
|
|
134
|
+
),
|
|
135
|
+
(editor) =>
|
|
136
|
+
editor.registerCommand(
|
|
137
|
+
KEY_DELETE_COMMAND,
|
|
138
|
+
(event) => handleMentionDelete("forward", event as KeyboardEvent | null),
|
|
139
|
+
COMMAND_PRIORITY_HIGH,
|
|
140
|
+
),
|
|
141
|
+
]);
|
|
142
|
+
},
|
|
143
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function extractProviderId(modelId: string): string | null {
|
|
2
|
+
const trimmed = modelId.trim();
|
|
3
|
+
if (!trimmed.includes("/")) return null;
|
|
4
|
+
const provider = trimmed.slice(0, trimmed.indexOf("/")).trim();
|
|
5
|
+
return provider || null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function extractProviderIdWithFallback(modelId: string, fallback = "other"): string {
|
|
9
|
+
return extractProviderId(modelId) ?? fallback;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function extractModelName(modelId: string): string {
|
|
13
|
+
const trimmed = modelId.trim();
|
|
14
|
+
if (!trimmed.includes("/")) return trimmed;
|
|
15
|
+
return trimmed.slice(trimmed.indexOf("/") + 1).trim();
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { parseOnboardingGoalInput } from "./onboarding-goal";
|
|
3
|
+
|
|
4
|
+
describe("parseOnboardingGoalInput", () => {
|
|
5
|
+
it("uses a single-line goal as the title only", () => {
|
|
6
|
+
expect(parseOnboardingGoalInput("Ship the MVP")).toEqual({
|
|
7
|
+
title: "Ship the MVP",
|
|
8
|
+
description: null,
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("splits a multiline goal into title and description", () => {
|
|
13
|
+
expect(
|
|
14
|
+
parseOnboardingGoalInput(
|
|
15
|
+
"Ship the MVP\nLaunch to 10 design partners\nMeasure retention",
|
|
16
|
+
),
|
|
17
|
+
).toEqual({
|
|
18
|
+
title: "Ship the MVP",
|
|
19
|
+
description: "Launch to 10 design partners\nMeasure retention",
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|