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,1022 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Link, useLocation, useNavigate, useParams } from "@/lib/router";
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import {
|
|
5
|
+
Activity as ActivityIcon,
|
|
6
|
+
ChevronDown,
|
|
7
|
+
ChevronRight,
|
|
8
|
+
Clock3,
|
|
9
|
+
Copy,
|
|
10
|
+
Play,
|
|
11
|
+
RefreshCw,
|
|
12
|
+
Repeat,
|
|
13
|
+
Save,
|
|
14
|
+
Trash2,
|
|
15
|
+
Webhook,
|
|
16
|
+
Zap,
|
|
17
|
+
} from "lucide-react";
|
|
18
|
+
import { routinesApi, type RoutineTriggerResponse, type RotateRoutineTriggerResponse } from "../api/routines";
|
|
19
|
+
import { heartbeatsApi } from "../api/heartbeats";
|
|
20
|
+
import { LiveRunWidget } from "../components/LiveRunWidget";
|
|
21
|
+
import { agentsApi } from "../api/agents";
|
|
22
|
+
import { projectsApi } from "../api/projects";
|
|
23
|
+
import { useCompany } from "../context/CompanyContext";
|
|
24
|
+
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
|
25
|
+
import { useToast } from "../context/ToastContext";
|
|
26
|
+
import { queryKeys } from "../lib/queryKeys";
|
|
27
|
+
import { buildRoutineTriggerPatch } from "../lib/routine-trigger-patch";
|
|
28
|
+
import { timeAgo } from "../lib/timeAgo";
|
|
29
|
+
import { EmptyState } from "../components/EmptyState";
|
|
30
|
+
import { PageSkeleton } from "../components/PageSkeleton";
|
|
31
|
+
import { AgentIcon } from "../components/AgentIconPicker";
|
|
32
|
+
import { InlineEntitySelector, type InlineEntityOption } from "../components/InlineEntitySelector";
|
|
33
|
+
import { MarkdownEditor, type MarkdownEditorRef } from "../components/MarkdownEditor";
|
|
34
|
+
import { ScheduleEditor, describeSchedule } from "../components/ScheduleEditor";
|
|
35
|
+
import { RunButton } from "../components/AgentActionButtons";
|
|
36
|
+
import { getRecentAssigneeIds, sortAgentsByRecency, trackRecentAssignee } from "../lib/recent-assignees";
|
|
37
|
+
import { Button } from "@/components/ui/button";
|
|
38
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
|
39
|
+
import { Input } from "@/components/ui/input";
|
|
40
|
+
import { Label } from "@/components/ui/label";
|
|
41
|
+
import { Separator } from "@/components/ui/separator";
|
|
42
|
+
import {
|
|
43
|
+
Select,
|
|
44
|
+
SelectContent,
|
|
45
|
+
SelectItem,
|
|
46
|
+
SelectTrigger,
|
|
47
|
+
SelectValue,
|
|
48
|
+
} from "@/components/ui/select";
|
|
49
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
50
|
+
import { Badge } from "@/components/ui/badge";
|
|
51
|
+
import type { RoutineTrigger } from "@corporateai/shared";
|
|
52
|
+
|
|
53
|
+
const concurrencyPolicies = ["coalesce_if_active", "always_enqueue", "skip_if_active"];
|
|
54
|
+
const catchUpPolicies = ["skip_missed", "enqueue_missed_with_cap"];
|
|
55
|
+
const triggerKinds = ["schedule", "webhook"];
|
|
56
|
+
const signingModes = ["bearer", "hmac_sha256"];
|
|
57
|
+
const routineTabs = ["triggers", "runs", "activity"] as const;
|
|
58
|
+
const concurrencyPolicyDescriptions: Record<string, string> = {
|
|
59
|
+
coalesce_if_active: "Keep one follow-up run queued while an active run is still working.",
|
|
60
|
+
always_enqueue: "Queue every trigger occurrence, even if several runs stack up.",
|
|
61
|
+
skip_if_active: "Drop overlapping trigger occurrences while the routine is already active.",
|
|
62
|
+
};
|
|
63
|
+
const catchUpPolicyDescriptions: Record<string, string> = {
|
|
64
|
+
skip_missed: "Ignore schedule windows that were missed while the routine or scheduler was paused.",
|
|
65
|
+
enqueue_missed_with_cap: "Catch up missed schedule windows in capped batches after recovery.",
|
|
66
|
+
};
|
|
67
|
+
const signingModeDescriptions: Record<string, string> = {
|
|
68
|
+
bearer: "Expect a shared bearer token in the Authorization header.",
|
|
69
|
+
hmac_sha256: "Expect an HMAC SHA-256 signature over the request using the shared secret.",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type RoutineTab = (typeof routineTabs)[number];
|
|
73
|
+
|
|
74
|
+
type SecretMessage = {
|
|
75
|
+
title: string;
|
|
76
|
+
webhookUrl: string;
|
|
77
|
+
webhookSecret: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
function autoResizeTextarea(element: HTMLTextAreaElement | null) {
|
|
81
|
+
if (!element) return;
|
|
82
|
+
element.style.height = "auto";
|
|
83
|
+
element.style.height = `${element.scrollHeight}px`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function isRoutineTab(value: string | null): value is RoutineTab {
|
|
87
|
+
return value !== null && routineTabs.includes(value as RoutineTab);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getRoutineTabFromSearch(search: string): RoutineTab {
|
|
91
|
+
const tab = new URLSearchParams(search).get("tab");
|
|
92
|
+
return isRoutineTab(tab) ? tab : "triggers";
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function formatActivityDetailValue(value: unknown): string {
|
|
96
|
+
if (value === null) return "null";
|
|
97
|
+
if (typeof value === "string") return value;
|
|
98
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
99
|
+
if (Array.isArray(value)) return value.length === 0 ? "[]" : value.map((item) => formatActivityDetailValue(item)).join(", ");
|
|
100
|
+
try {
|
|
101
|
+
return JSON.stringify(value);
|
|
102
|
+
} catch {
|
|
103
|
+
return "[unserializable]";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getLocalTimezone(): string {
|
|
108
|
+
try {
|
|
109
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
110
|
+
} catch {
|
|
111
|
+
return "UTC";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function TriggerEditor({
|
|
116
|
+
trigger,
|
|
117
|
+
onSave,
|
|
118
|
+
onRotate,
|
|
119
|
+
onDelete,
|
|
120
|
+
}: {
|
|
121
|
+
trigger: RoutineTrigger;
|
|
122
|
+
onSave: (id: string, patch: Record<string, unknown>) => void;
|
|
123
|
+
onRotate: (id: string) => void;
|
|
124
|
+
onDelete: (id: string) => void;
|
|
125
|
+
}) {
|
|
126
|
+
const [draft, setDraft] = useState({
|
|
127
|
+
label: trigger.label ?? "",
|
|
128
|
+
cronExpression: trigger.cronExpression ?? "",
|
|
129
|
+
signingMode: trigger.signingMode ?? "bearer",
|
|
130
|
+
replayWindowSec: String(trigger.replayWindowSec ?? 300),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
setDraft({
|
|
135
|
+
label: trigger.label ?? "",
|
|
136
|
+
cronExpression: trigger.cronExpression ?? "",
|
|
137
|
+
signingMode: trigger.signingMode ?? "bearer",
|
|
138
|
+
replayWindowSec: String(trigger.replayWindowSec ?? 300),
|
|
139
|
+
});
|
|
140
|
+
}, [trigger]);
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div className="rounded-lg border border-border p-4 space-y-4">
|
|
144
|
+
<div className="flex items-center justify-between">
|
|
145
|
+
<div className="flex items-center gap-2 text-sm font-medium">
|
|
146
|
+
{trigger.kind === "schedule" ? <Clock3 className="h-3.5 w-3.5" /> : trigger.kind === "webhook" ? <Webhook className="h-3.5 w-3.5" /> : <Zap className="h-3.5 w-3.5" />}
|
|
147
|
+
{trigger.label ?? trigger.kind}
|
|
148
|
+
</div>
|
|
149
|
+
<span className="text-xs text-muted-foreground">
|
|
150
|
+
{trigger.kind === "schedule" && trigger.nextRunAt
|
|
151
|
+
? `Next: ${new Date(trigger.nextRunAt).toLocaleString()}`
|
|
152
|
+
: trigger.kind === "webhook"
|
|
153
|
+
? "Webhook"
|
|
154
|
+
: "API"}
|
|
155
|
+
</span>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<div className="grid gap-3 md:grid-cols-2">
|
|
159
|
+
<div className="space-y-1.5">
|
|
160
|
+
<Label className="text-xs">Label</Label>
|
|
161
|
+
<Input
|
|
162
|
+
value={draft.label}
|
|
163
|
+
onChange={(event) => setDraft((current) => ({ ...current, label: event.target.value }))}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
{trigger.kind === "schedule" && (
|
|
167
|
+
<div className="md:col-span-2 space-y-1.5">
|
|
168
|
+
<Label className="text-xs">Schedule</Label>
|
|
169
|
+
<ScheduleEditor
|
|
170
|
+
value={draft.cronExpression}
|
|
171
|
+
onChange={(cronExpression) => setDraft((current) => ({ ...current, cronExpression }))}
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
{trigger.kind === "webhook" && (
|
|
176
|
+
<>
|
|
177
|
+
<div className="space-y-1.5">
|
|
178
|
+
<Label className="text-xs">Signing mode</Label>
|
|
179
|
+
<Select
|
|
180
|
+
value={draft.signingMode}
|
|
181
|
+
onValueChange={(signingMode) => setDraft((current) => ({ ...current, signingMode }))}
|
|
182
|
+
>
|
|
183
|
+
<SelectTrigger>
|
|
184
|
+
<SelectValue />
|
|
185
|
+
</SelectTrigger>
|
|
186
|
+
<SelectContent>
|
|
187
|
+
{signingModes.map((mode) => (
|
|
188
|
+
<SelectItem key={mode} value={mode}>{mode}</SelectItem>
|
|
189
|
+
))}
|
|
190
|
+
</SelectContent>
|
|
191
|
+
</Select>
|
|
192
|
+
</div>
|
|
193
|
+
<div className="space-y-1.5">
|
|
194
|
+
<Label className="text-xs">Replay window (seconds)</Label>
|
|
195
|
+
<Input
|
|
196
|
+
value={draft.replayWindowSec}
|
|
197
|
+
onChange={(event) => setDraft((current) => ({ ...current, replayWindowSec: event.target.value }))}
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
</>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
205
|
+
{trigger.lastResult && <span className="text-xs text-muted-foreground">Last: {trigger.lastResult}</span>}
|
|
206
|
+
<div className="ml-auto flex items-center gap-2">
|
|
207
|
+
{trigger.kind === "webhook" && (
|
|
208
|
+
<Button variant="outline" size="sm" onClick={() => onRotate(trigger.id)}>
|
|
209
|
+
<RefreshCw className="mr-1.5 h-3.5 w-3.5" />
|
|
210
|
+
Rotate secret
|
|
211
|
+
</Button>
|
|
212
|
+
)}
|
|
213
|
+
<Button
|
|
214
|
+
variant="outline"
|
|
215
|
+
size="sm"
|
|
216
|
+
onClick={() => onSave(trigger.id, buildRoutineTriggerPatch(trigger, draft, getLocalTimezone()))}
|
|
217
|
+
>
|
|
218
|
+
<Save className="mr-1.5 h-3.5 w-3.5" />
|
|
219
|
+
Save
|
|
220
|
+
</Button>
|
|
221
|
+
<Button
|
|
222
|
+
variant="ghost"
|
|
223
|
+
size="sm"
|
|
224
|
+
className="text-muted-foreground hover:text-destructive"
|
|
225
|
+
onClick={() => onDelete(trigger.id)}
|
|
226
|
+
>
|
|
227
|
+
<Trash2 className="h-3.5 w-3.5" />
|
|
228
|
+
</Button>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function RoutineDetail() {
|
|
236
|
+
const { routineId } = useParams<{ routineId: string }>();
|
|
237
|
+
const { selectedCompanyId } = useCompany();
|
|
238
|
+
const { setBreadcrumbs } = useBreadcrumbs();
|
|
239
|
+
const queryClient = useQueryClient();
|
|
240
|
+
const navigate = useNavigate();
|
|
241
|
+
const location = useLocation();
|
|
242
|
+
const { pushToast } = useToast();
|
|
243
|
+
const hydratedRoutineIdRef = useRef<string | null>(null);
|
|
244
|
+
const titleInputRef = useRef<HTMLTextAreaElement | null>(null);
|
|
245
|
+
const descriptionEditorRef = useRef<MarkdownEditorRef>(null);
|
|
246
|
+
const assigneeSelectorRef = useRef<HTMLButtonElement | null>(null);
|
|
247
|
+
const projectSelectorRef = useRef<HTMLButtonElement | null>(null);
|
|
248
|
+
const [secretMessage, setSecretMessage] = useState<SecretMessage | null>(null);
|
|
249
|
+
const [advancedOpen, setAdvancedOpen] = useState(false);
|
|
250
|
+
const [newTrigger, setNewTrigger] = useState({
|
|
251
|
+
kind: "schedule",
|
|
252
|
+
cronExpression: "0 10 * * *",
|
|
253
|
+
signingMode: "bearer",
|
|
254
|
+
replayWindowSec: "300",
|
|
255
|
+
});
|
|
256
|
+
const [editDraft, setEditDraft] = useState({
|
|
257
|
+
title: "",
|
|
258
|
+
description: "",
|
|
259
|
+
projectId: "",
|
|
260
|
+
assigneeAgentId: "",
|
|
261
|
+
priority: "medium",
|
|
262
|
+
concurrencyPolicy: "coalesce_if_active",
|
|
263
|
+
catchUpPolicy: "skip_missed",
|
|
264
|
+
});
|
|
265
|
+
const activeTab = useMemo(() => getRoutineTabFromSearch(location.search), [location.search]);
|
|
266
|
+
|
|
267
|
+
const { data: routine, isLoading, error } = useQuery({
|
|
268
|
+
queryKey: queryKeys.routines.detail(routineId!),
|
|
269
|
+
queryFn: () => routinesApi.get(routineId!),
|
|
270
|
+
enabled: !!routineId,
|
|
271
|
+
});
|
|
272
|
+
const activeIssueId = routine?.activeIssue?.id;
|
|
273
|
+
const { data: liveRuns } = useQuery({
|
|
274
|
+
queryKey: queryKeys.issues.liveRuns(activeIssueId!),
|
|
275
|
+
queryFn: () => heartbeatsApi.liveRunsForIssue(activeIssueId!),
|
|
276
|
+
enabled: !!activeIssueId,
|
|
277
|
+
refetchInterval: 3000,
|
|
278
|
+
});
|
|
279
|
+
const hasLiveRun = (liveRuns ?? []).length > 0;
|
|
280
|
+
const { data: routineRuns } = useQuery({
|
|
281
|
+
queryKey: queryKeys.routines.runs(routineId!),
|
|
282
|
+
queryFn: () => routinesApi.listRuns(routineId!),
|
|
283
|
+
enabled: !!routineId,
|
|
284
|
+
refetchInterval: hasLiveRun ? 3000 : false,
|
|
285
|
+
});
|
|
286
|
+
const relatedActivityIds = useMemo(
|
|
287
|
+
() => ({
|
|
288
|
+
triggerIds: routine?.triggers.map((trigger) => trigger.id) ?? [],
|
|
289
|
+
runIds: routineRuns?.map((run) => run.id) ?? [],
|
|
290
|
+
}),
|
|
291
|
+
[routine?.triggers, routineRuns],
|
|
292
|
+
);
|
|
293
|
+
const { data: activity } = useQuery({
|
|
294
|
+
queryKey: [
|
|
295
|
+
...queryKeys.routines.activity(selectedCompanyId!, routineId!),
|
|
296
|
+
relatedActivityIds.triggerIds.join(","),
|
|
297
|
+
relatedActivityIds.runIds.join(","),
|
|
298
|
+
],
|
|
299
|
+
queryFn: () => routinesApi.activity(selectedCompanyId!, routineId!, relatedActivityIds),
|
|
300
|
+
enabled: !!selectedCompanyId && !!routineId && !!routine,
|
|
301
|
+
});
|
|
302
|
+
const { data: agents } = useQuery({
|
|
303
|
+
queryKey: queryKeys.agents.list(selectedCompanyId!),
|
|
304
|
+
queryFn: () => agentsApi.list(selectedCompanyId!),
|
|
305
|
+
enabled: !!selectedCompanyId,
|
|
306
|
+
});
|
|
307
|
+
const { data: projects } = useQuery({
|
|
308
|
+
queryKey: queryKeys.projects.list(selectedCompanyId!),
|
|
309
|
+
queryFn: () => projectsApi.list(selectedCompanyId!),
|
|
310
|
+
enabled: !!selectedCompanyId,
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
const routineDefaults = useMemo(
|
|
314
|
+
() =>
|
|
315
|
+
routine
|
|
316
|
+
? {
|
|
317
|
+
title: routine.title,
|
|
318
|
+
description: routine.description ?? "",
|
|
319
|
+
projectId: routine.projectId,
|
|
320
|
+
assigneeAgentId: routine.assigneeAgentId,
|
|
321
|
+
priority: routine.priority,
|
|
322
|
+
concurrencyPolicy: routine.concurrencyPolicy,
|
|
323
|
+
catchUpPolicy: routine.catchUpPolicy,
|
|
324
|
+
}
|
|
325
|
+
: null,
|
|
326
|
+
[routine],
|
|
327
|
+
);
|
|
328
|
+
const isEditDirty = useMemo(() => {
|
|
329
|
+
if (!routineDefaults) return false;
|
|
330
|
+
return (
|
|
331
|
+
editDraft.title !== routineDefaults.title ||
|
|
332
|
+
editDraft.description !== routineDefaults.description ||
|
|
333
|
+
editDraft.projectId !== routineDefaults.projectId ||
|
|
334
|
+
editDraft.assigneeAgentId !== routineDefaults.assigneeAgentId ||
|
|
335
|
+
editDraft.priority !== routineDefaults.priority ||
|
|
336
|
+
editDraft.concurrencyPolicy !== routineDefaults.concurrencyPolicy ||
|
|
337
|
+
editDraft.catchUpPolicy !== routineDefaults.catchUpPolicy
|
|
338
|
+
);
|
|
339
|
+
}, [editDraft, routineDefaults]);
|
|
340
|
+
|
|
341
|
+
useEffect(() => {
|
|
342
|
+
if (!routine) return;
|
|
343
|
+
setBreadcrumbs([{ label: "Routines", href: "/routines" }, { label: routine.title }]);
|
|
344
|
+
if (!routineDefaults) return;
|
|
345
|
+
|
|
346
|
+
const changedRoutine = hydratedRoutineIdRef.current !== routine.id;
|
|
347
|
+
if (changedRoutine || !isEditDirty) {
|
|
348
|
+
setEditDraft(routineDefaults);
|
|
349
|
+
hydratedRoutineIdRef.current = routine.id;
|
|
350
|
+
}
|
|
351
|
+
}, [routine, routineDefaults, isEditDirty, setBreadcrumbs]);
|
|
352
|
+
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
autoResizeTextarea(titleInputRef.current);
|
|
355
|
+
}, [editDraft.title, routine?.id]);
|
|
356
|
+
|
|
357
|
+
const copySecretValue = async (label: string, value: string) => {
|
|
358
|
+
try {
|
|
359
|
+
await navigator.clipboard.writeText(value);
|
|
360
|
+
pushToast({ title: `${label} copied`, tone: "success" });
|
|
361
|
+
} catch (error) {
|
|
362
|
+
pushToast({
|
|
363
|
+
title: `Failed to copy ${label.toLowerCase()}`,
|
|
364
|
+
body: error instanceof Error ? error.message : "Clipboard access was denied.",
|
|
365
|
+
tone: "error",
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const setActiveTab = (value: string) => {
|
|
371
|
+
if (!routineId || !isRoutineTab(value)) return;
|
|
372
|
+
const params = new URLSearchParams(location.search);
|
|
373
|
+
if (value === "triggers") {
|
|
374
|
+
params.delete("tab");
|
|
375
|
+
} else {
|
|
376
|
+
params.set("tab", value);
|
|
377
|
+
}
|
|
378
|
+
const search = params.toString();
|
|
379
|
+
navigate(
|
|
380
|
+
{
|
|
381
|
+
pathname: location.pathname,
|
|
382
|
+
search: search ? `?${search}` : "",
|
|
383
|
+
},
|
|
384
|
+
{ replace: true },
|
|
385
|
+
);
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
const saveRoutine = useMutation({
|
|
389
|
+
mutationFn: () => {
|
|
390
|
+
return routinesApi.update(routineId!, {
|
|
391
|
+
...editDraft,
|
|
392
|
+
description: editDraft.description.trim() || null,
|
|
393
|
+
});
|
|
394
|
+
},
|
|
395
|
+
onSuccess: async () => {
|
|
396
|
+
await Promise.all([
|
|
397
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.detail(routineId!) }),
|
|
398
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }),
|
|
399
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.activity(selectedCompanyId!, routineId!) }),
|
|
400
|
+
]);
|
|
401
|
+
},
|
|
402
|
+
onError: (error) => {
|
|
403
|
+
pushToast({
|
|
404
|
+
title: "Failed to save routine",
|
|
405
|
+
body: error instanceof Error ? error.message : "Corporate could not save the routine.",
|
|
406
|
+
tone: "error",
|
|
407
|
+
});
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const runRoutine = useMutation({
|
|
412
|
+
mutationFn: () => routinesApi.run(routineId!),
|
|
413
|
+
onSuccess: async () => {
|
|
414
|
+
pushToast({ title: "Routine run started", tone: "success" });
|
|
415
|
+
setActiveTab("runs");
|
|
416
|
+
await Promise.all([
|
|
417
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.detail(routineId!) }),
|
|
418
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.runs(routineId!) }),
|
|
419
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }),
|
|
420
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.activity(selectedCompanyId!, routineId!) }),
|
|
421
|
+
]);
|
|
422
|
+
},
|
|
423
|
+
onError: (error) => {
|
|
424
|
+
pushToast({
|
|
425
|
+
title: "Routine run failed",
|
|
426
|
+
body: error instanceof Error ? error.message : "Corporate could not start the routine run.",
|
|
427
|
+
tone: "error",
|
|
428
|
+
});
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
const updateRoutineStatus = useMutation({
|
|
433
|
+
mutationFn: (status: string) => routinesApi.update(routineId!, { status }),
|
|
434
|
+
onSuccess: async (_data, status) => {
|
|
435
|
+
pushToast({
|
|
436
|
+
title: "Routine saved",
|
|
437
|
+
body: status === "paused" ? "Automation paused." : "Automation enabled.",
|
|
438
|
+
tone: "success",
|
|
439
|
+
});
|
|
440
|
+
await Promise.all([
|
|
441
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.detail(routineId!) }),
|
|
442
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }),
|
|
443
|
+
]);
|
|
444
|
+
},
|
|
445
|
+
onError: (error) => {
|
|
446
|
+
pushToast({
|
|
447
|
+
title: "Failed to update routine",
|
|
448
|
+
body: error instanceof Error ? error.message : "Corporate could not update the routine.",
|
|
449
|
+
tone: "error",
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
const createTrigger = useMutation({
|
|
455
|
+
mutationFn: async (): Promise<RoutineTriggerResponse> => {
|
|
456
|
+
const existingOfKind = (routine?.triggers ?? []).filter((t) => t.kind === newTrigger.kind).length;
|
|
457
|
+
const autoLabel = existingOfKind > 0 ? `${newTrigger.kind}-${existingOfKind + 1}` : newTrigger.kind;
|
|
458
|
+
return routinesApi.createTrigger(routineId!, {
|
|
459
|
+
kind: newTrigger.kind,
|
|
460
|
+
label: autoLabel,
|
|
461
|
+
...(newTrigger.kind === "schedule"
|
|
462
|
+
? { cronExpression: newTrigger.cronExpression.trim(), timezone: getLocalTimezone() }
|
|
463
|
+
: {}),
|
|
464
|
+
...(newTrigger.kind === "webhook"
|
|
465
|
+
? {
|
|
466
|
+
signingMode: newTrigger.signingMode,
|
|
467
|
+
replayWindowSec: Number(newTrigger.replayWindowSec || "300"),
|
|
468
|
+
}
|
|
469
|
+
: {}),
|
|
470
|
+
});
|
|
471
|
+
},
|
|
472
|
+
onSuccess: async (result) => {
|
|
473
|
+
if (result.secretMaterial) {
|
|
474
|
+
setSecretMessage({
|
|
475
|
+
title: "Webhook trigger created",
|
|
476
|
+
webhookUrl: result.secretMaterial.webhookUrl,
|
|
477
|
+
webhookSecret: result.secretMaterial.webhookSecret,
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
await Promise.all([
|
|
481
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.detail(routineId!) }),
|
|
482
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }),
|
|
483
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.activity(selectedCompanyId!, routineId!) }),
|
|
484
|
+
]);
|
|
485
|
+
},
|
|
486
|
+
onError: (error) => {
|
|
487
|
+
pushToast({
|
|
488
|
+
title: "Failed to add trigger",
|
|
489
|
+
body: error instanceof Error ? error.message : "Corporate could not create the trigger.",
|
|
490
|
+
tone: "error",
|
|
491
|
+
});
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
const updateTrigger = useMutation({
|
|
496
|
+
mutationFn: ({ id, patch }: { id: string; patch: Record<string, unknown> }) => routinesApi.updateTrigger(id, patch),
|
|
497
|
+
onSuccess: async () => {
|
|
498
|
+
await Promise.all([
|
|
499
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.detail(routineId!) }),
|
|
500
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }),
|
|
501
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.activity(selectedCompanyId!, routineId!) }),
|
|
502
|
+
]);
|
|
503
|
+
},
|
|
504
|
+
onError: (error) => {
|
|
505
|
+
pushToast({
|
|
506
|
+
title: "Failed to update trigger",
|
|
507
|
+
body: error instanceof Error ? error.message : "Corporate could not update the trigger.",
|
|
508
|
+
tone: "error",
|
|
509
|
+
});
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
const deleteTrigger = useMutation({
|
|
514
|
+
mutationFn: (id: string) => routinesApi.deleteTrigger(id),
|
|
515
|
+
onSuccess: async () => {
|
|
516
|
+
await Promise.all([
|
|
517
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.detail(routineId!) }),
|
|
518
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }),
|
|
519
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.activity(selectedCompanyId!, routineId!) }),
|
|
520
|
+
]);
|
|
521
|
+
},
|
|
522
|
+
onError: (error) => {
|
|
523
|
+
pushToast({
|
|
524
|
+
title: "Failed to delete trigger",
|
|
525
|
+
body: error instanceof Error ? error.message : "Corporate could not delete the trigger.",
|
|
526
|
+
tone: "error",
|
|
527
|
+
});
|
|
528
|
+
},
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
const rotateTrigger = useMutation({
|
|
532
|
+
mutationFn: (id: string): Promise<RotateRoutineTriggerResponse> => routinesApi.rotateTriggerSecret(id),
|
|
533
|
+
onSuccess: async (result) => {
|
|
534
|
+
setSecretMessage({
|
|
535
|
+
title: "Webhook secret rotated",
|
|
536
|
+
webhookUrl: result.secretMaterial.webhookUrl,
|
|
537
|
+
webhookSecret: result.secretMaterial.webhookSecret,
|
|
538
|
+
});
|
|
539
|
+
await Promise.all([
|
|
540
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.detail(routineId!) }),
|
|
541
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.routines.activity(selectedCompanyId!, routineId!) }),
|
|
542
|
+
]);
|
|
543
|
+
},
|
|
544
|
+
onError: (error) => {
|
|
545
|
+
pushToast({
|
|
546
|
+
title: "Failed to rotate webhook secret",
|
|
547
|
+
body: error instanceof Error ? error.message : "Corporate could not rotate the webhook secret.",
|
|
548
|
+
tone: "error",
|
|
549
|
+
});
|
|
550
|
+
},
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
const agentById = useMemo(
|
|
554
|
+
() => new Map((agents ?? []).map((agent) => [agent.id, agent])),
|
|
555
|
+
[agents],
|
|
556
|
+
);
|
|
557
|
+
const projectById = useMemo(
|
|
558
|
+
() => new Map((projects ?? []).map((project) => [project.id, project])),
|
|
559
|
+
[projects],
|
|
560
|
+
);
|
|
561
|
+
const recentAssigneeIds = useMemo(() => getRecentAssigneeIds(), [routine?.id]);
|
|
562
|
+
const assigneeOptions = useMemo<InlineEntityOption[]>(
|
|
563
|
+
() =>
|
|
564
|
+
sortAgentsByRecency(
|
|
565
|
+
(agents ?? []).filter((agent) => agent.status !== "terminated"),
|
|
566
|
+
recentAssigneeIds,
|
|
567
|
+
).map((agent) => ({
|
|
568
|
+
id: agent.id,
|
|
569
|
+
label: agent.name,
|
|
570
|
+
searchText: `${agent.name} ${agent.role} ${agent.title ?? ""}`,
|
|
571
|
+
})),
|
|
572
|
+
[agents, recentAssigneeIds],
|
|
573
|
+
);
|
|
574
|
+
const projectOptions = useMemo<InlineEntityOption[]>(
|
|
575
|
+
() =>
|
|
576
|
+
(projects ?? []).map((project) => ({
|
|
577
|
+
id: project.id,
|
|
578
|
+
label: project.name,
|
|
579
|
+
searchText: project.description ?? "",
|
|
580
|
+
})),
|
|
581
|
+
[projects],
|
|
582
|
+
);
|
|
583
|
+
const currentAssignee = editDraft.assigneeAgentId ? agentById.get(editDraft.assigneeAgentId) ?? null : null;
|
|
584
|
+
const currentProject = editDraft.projectId ? projectById.get(editDraft.projectId) ?? null : null;
|
|
585
|
+
|
|
586
|
+
if (!selectedCompanyId) {
|
|
587
|
+
return <EmptyState icon={Repeat} message="Select a company to view routines." />;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (isLoading) {
|
|
591
|
+
return <PageSkeleton variant="issues-list" />;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (error || !routine) {
|
|
595
|
+
return (
|
|
596
|
+
<p className="pt-6 text-sm text-destructive">
|
|
597
|
+
{error instanceof Error ? error.message : "Routine not found"}
|
|
598
|
+
</p>
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const automationEnabled = routine.status === "active";
|
|
603
|
+
const automationToggleDisabled = updateRoutineStatus.isPending || routine.status === "archived";
|
|
604
|
+
const automationLabel = routine.status === "archived" ? "Archived" : automationEnabled ? "Active" : "Paused";
|
|
605
|
+
const automationLabelClassName = routine.status === "archived"
|
|
606
|
+
? "text-muted-foreground"
|
|
607
|
+
: automationEnabled
|
|
608
|
+
? "text-emerald-400"
|
|
609
|
+
: "text-muted-foreground";
|
|
610
|
+
|
|
611
|
+
return (
|
|
612
|
+
<div className="max-w-2xl space-y-6">
|
|
613
|
+
{/* Header: editable title + actions */}
|
|
614
|
+
<div className="flex items-start gap-4">
|
|
615
|
+
<textarea
|
|
616
|
+
ref={titleInputRef}
|
|
617
|
+
className="flex-1 min-w-0 resize-none overflow-hidden bg-transparent text-xl font-bold outline-none placeholder:text-muted-foreground/50"
|
|
618
|
+
placeholder="Routine title"
|
|
619
|
+
rows={1}
|
|
620
|
+
value={editDraft.title}
|
|
621
|
+
onChange={(event) => {
|
|
622
|
+
setEditDraft((current) => ({ ...current, title: event.target.value }));
|
|
623
|
+
autoResizeTextarea(event.target);
|
|
624
|
+
}}
|
|
625
|
+
onKeyDown={(event) => {
|
|
626
|
+
if (event.key === "Enter" && !event.metaKey && !event.ctrlKey && !event.nativeEvent.isComposing) {
|
|
627
|
+
event.preventDefault();
|
|
628
|
+
descriptionEditorRef.current?.focus();
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (event.key === "Tab" && !event.shiftKey) {
|
|
632
|
+
event.preventDefault();
|
|
633
|
+
if (editDraft.assigneeAgentId) {
|
|
634
|
+
if (editDraft.projectId) {
|
|
635
|
+
descriptionEditorRef.current?.focus();
|
|
636
|
+
} else {
|
|
637
|
+
projectSelectorRef.current?.focus();
|
|
638
|
+
}
|
|
639
|
+
} else {
|
|
640
|
+
assigneeSelectorRef.current?.focus();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}}
|
|
644
|
+
/>
|
|
645
|
+
<div className="flex shrink-0 items-center gap-3 pt-1">
|
|
646
|
+
<RunButton onClick={() => runRoutine.mutate()} disabled={runRoutine.isPending} />
|
|
647
|
+
<button
|
|
648
|
+
type="button"
|
|
649
|
+
role="switch"
|
|
650
|
+
data-slot="toggle"
|
|
651
|
+
aria-checked={automationEnabled}
|
|
652
|
+
aria-label={automationEnabled ? "Pause automatic triggers" : "Enable automatic triggers"}
|
|
653
|
+
disabled={automationToggleDisabled}
|
|
654
|
+
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${
|
|
655
|
+
automationEnabled ? "bg-emerald-500" : "bg-muted"
|
|
656
|
+
} ${automationToggleDisabled ? "cursor-not-allowed opacity-50" : ""}`}
|
|
657
|
+
onClick={() => updateRoutineStatus.mutate(automationEnabled ? "paused" : "active")}
|
|
658
|
+
>
|
|
659
|
+
<span
|
|
660
|
+
className={`inline-block h-5 w-5 rounded-full bg-background shadow-sm transition-transform ${
|
|
661
|
+
automationEnabled ? "translate-x-5" : "translate-x-0.5"
|
|
662
|
+
}`}
|
|
663
|
+
/>
|
|
664
|
+
</button>
|
|
665
|
+
<span className={`min-w-[3.75rem] text-sm font-medium ${automationLabelClassName}`}>
|
|
666
|
+
{automationLabel}
|
|
667
|
+
</span>
|
|
668
|
+
</div>
|
|
669
|
+
</div>
|
|
670
|
+
|
|
671
|
+
{/* Secret message banner */}
|
|
672
|
+
{secretMessage && (
|
|
673
|
+
<div className="rounded-lg border border-blue-500/30 bg-blue-500/5 p-4 space-y-3 text-sm">
|
|
674
|
+
<div>
|
|
675
|
+
<p className="font-medium">{secretMessage.title}</p>
|
|
676
|
+
<p className="text-xs text-muted-foreground">Save this now. Corporate will not show the secret value again.</p>
|
|
677
|
+
</div>
|
|
678
|
+
<div className="space-y-2">
|
|
679
|
+
<div className="flex items-center gap-2">
|
|
680
|
+
<Input value={secretMessage.webhookUrl} readOnly className="flex-1" />
|
|
681
|
+
<Button variant="outline" size="sm" onClick={() => copySecretValue("Webhook URL", secretMessage.webhookUrl)}>
|
|
682
|
+
<Copy className="h-3.5 w-3.5 mr-1" />
|
|
683
|
+
URL
|
|
684
|
+
</Button>
|
|
685
|
+
</div>
|
|
686
|
+
<div className="flex items-center gap-2">
|
|
687
|
+
<Input value={secretMessage.webhookSecret} readOnly className="flex-1" />
|
|
688
|
+
<Button variant="outline" size="sm" onClick={() => copySecretValue("Webhook secret", secretMessage.webhookSecret)}>
|
|
689
|
+
<Copy className="h-3.5 w-3.5 mr-1" />
|
|
690
|
+
Secret
|
|
691
|
+
</Button>
|
|
692
|
+
</div>
|
|
693
|
+
</div>
|
|
694
|
+
</div>
|
|
695
|
+
)}
|
|
696
|
+
|
|
697
|
+
{/* Assignment row */}
|
|
698
|
+
<div className="overflow-x-auto overscroll-x-contain">
|
|
699
|
+
<div className="inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-muted-foreground sm:min-w-max sm:flex-nowrap">
|
|
700
|
+
<span>For</span>
|
|
701
|
+
<InlineEntitySelector
|
|
702
|
+
ref={assigneeSelectorRef}
|
|
703
|
+
value={editDraft.assigneeAgentId}
|
|
704
|
+
options={assigneeOptions}
|
|
705
|
+
placeholder="Assignee"
|
|
706
|
+
noneLabel="No assignee"
|
|
707
|
+
searchPlaceholder="Search assignees..."
|
|
708
|
+
emptyMessage="No assignees found."
|
|
709
|
+
onChange={(assigneeAgentId) => {
|
|
710
|
+
if (assigneeAgentId) trackRecentAssignee(assigneeAgentId);
|
|
711
|
+
setEditDraft((current) => ({ ...current, assigneeAgentId }));
|
|
712
|
+
}}
|
|
713
|
+
onConfirm={() => {
|
|
714
|
+
if (editDraft.projectId) {
|
|
715
|
+
descriptionEditorRef.current?.focus();
|
|
716
|
+
} else {
|
|
717
|
+
projectSelectorRef.current?.focus();
|
|
718
|
+
}
|
|
719
|
+
}}
|
|
720
|
+
renderTriggerValue={(option) =>
|
|
721
|
+
option ? (
|
|
722
|
+
currentAssignee ? (
|
|
723
|
+
<>
|
|
724
|
+
<AgentIcon icon={currentAssignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
|
|
725
|
+
<span className="truncate">{option.label}</span>
|
|
726
|
+
</>
|
|
727
|
+
) : (
|
|
728
|
+
<span className="truncate">{option.label}</span>
|
|
729
|
+
)
|
|
730
|
+
) : (
|
|
731
|
+
<span className="text-muted-foreground">Assignee</span>
|
|
732
|
+
)
|
|
733
|
+
}
|
|
734
|
+
renderOption={(option) => {
|
|
735
|
+
if (!option.id) return <span className="truncate">{option.label}</span>;
|
|
736
|
+
const assignee = agentById.get(option.id);
|
|
737
|
+
return (
|
|
738
|
+
<>
|
|
739
|
+
{assignee ? <AgentIcon icon={assignee.icon} className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> : null}
|
|
740
|
+
<span className="truncate">{option.label}</span>
|
|
741
|
+
</>
|
|
742
|
+
);
|
|
743
|
+
}}
|
|
744
|
+
/>
|
|
745
|
+
<span>in</span>
|
|
746
|
+
<InlineEntitySelector
|
|
747
|
+
ref={projectSelectorRef}
|
|
748
|
+
value={editDraft.projectId}
|
|
749
|
+
options={projectOptions}
|
|
750
|
+
placeholder="Project"
|
|
751
|
+
noneLabel="No project"
|
|
752
|
+
searchPlaceholder="Search projects..."
|
|
753
|
+
emptyMessage="No projects found."
|
|
754
|
+
onChange={(projectId) => setEditDraft((current) => ({ ...current, projectId }))}
|
|
755
|
+
onConfirm={() => descriptionEditorRef.current?.focus()}
|
|
756
|
+
renderTriggerValue={(option) =>
|
|
757
|
+
option && currentProject ? (
|
|
758
|
+
<>
|
|
759
|
+
<span
|
|
760
|
+
className="h-3.5 w-3.5 shrink-0 rounded-sm"
|
|
761
|
+
style={{ backgroundColor: currentProject.color ?? "#64748b" }}
|
|
762
|
+
/>
|
|
763
|
+
<span className="truncate">{option.label}</span>
|
|
764
|
+
</>
|
|
765
|
+
) : (
|
|
766
|
+
<span className="text-muted-foreground">Project</span>
|
|
767
|
+
)
|
|
768
|
+
}
|
|
769
|
+
renderOption={(option) => {
|
|
770
|
+
if (!option.id) return <span className="truncate">{option.label}</span>;
|
|
771
|
+
const project = projectById.get(option.id);
|
|
772
|
+
return (
|
|
773
|
+
<>
|
|
774
|
+
<span
|
|
775
|
+
className="h-3.5 w-3.5 shrink-0 rounded-sm"
|
|
776
|
+
style={{ backgroundColor: project?.color ?? "#64748b" }}
|
|
777
|
+
/>
|
|
778
|
+
<span className="truncate">{option.label}</span>
|
|
779
|
+
</>
|
|
780
|
+
);
|
|
781
|
+
}}
|
|
782
|
+
/>
|
|
783
|
+
</div>
|
|
784
|
+
</div>
|
|
785
|
+
|
|
786
|
+
{/* Instructions */}
|
|
787
|
+
<MarkdownEditor
|
|
788
|
+
ref={descriptionEditorRef}
|
|
789
|
+
value={editDraft.description}
|
|
790
|
+
onChange={(description) => setEditDraft((current) => ({ ...current, description }))}
|
|
791
|
+
placeholder="Add instructions..."
|
|
792
|
+
bordered={false}
|
|
793
|
+
contentClassName="min-h-[120px] text-[15px] leading-7"
|
|
794
|
+
onSubmit={() => {
|
|
795
|
+
if (!saveRoutine.isPending && editDraft.title.trim() && editDraft.projectId && editDraft.assigneeAgentId) {
|
|
796
|
+
saveRoutine.mutate();
|
|
797
|
+
}
|
|
798
|
+
}}
|
|
799
|
+
/>
|
|
800
|
+
|
|
801
|
+
{/* Advanced delivery settings */}
|
|
802
|
+
<Collapsible open={advancedOpen} onOpenChange={setAdvancedOpen}>
|
|
803
|
+
<CollapsibleTrigger className="flex w-full items-center justify-between text-left">
|
|
804
|
+
<span className="text-sm font-medium">Advanced delivery settings</span>
|
|
805
|
+
{advancedOpen ? <ChevronDown className="h-4 w-4 text-muted-foreground" /> : <ChevronRight className="h-4 w-4 text-muted-foreground" />}
|
|
806
|
+
</CollapsibleTrigger>
|
|
807
|
+
<CollapsibleContent className="pt-3">
|
|
808
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
809
|
+
<div className="space-y-2">
|
|
810
|
+
<p className="text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground">Concurrency</p>
|
|
811
|
+
<Select
|
|
812
|
+
value={editDraft.concurrencyPolicy}
|
|
813
|
+
onValueChange={(concurrencyPolicy) => setEditDraft((current) => ({ ...current, concurrencyPolicy }))}
|
|
814
|
+
>
|
|
815
|
+
<SelectTrigger>
|
|
816
|
+
<SelectValue />
|
|
817
|
+
</SelectTrigger>
|
|
818
|
+
<SelectContent>
|
|
819
|
+
{concurrencyPolicies.map((value) => (
|
|
820
|
+
<SelectItem key={value} value={value}>{value.replaceAll("_", " ")}</SelectItem>
|
|
821
|
+
))}
|
|
822
|
+
</SelectContent>
|
|
823
|
+
</Select>
|
|
824
|
+
<p className="text-xs text-muted-foreground">{concurrencyPolicyDescriptions[editDraft.concurrencyPolicy]}</p>
|
|
825
|
+
</div>
|
|
826
|
+
<div className="space-y-2">
|
|
827
|
+
<p className="text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground">Catch-up</p>
|
|
828
|
+
<Select
|
|
829
|
+
value={editDraft.catchUpPolicy}
|
|
830
|
+
onValueChange={(catchUpPolicy) => setEditDraft((current) => ({ ...current, catchUpPolicy }))}
|
|
831
|
+
>
|
|
832
|
+
<SelectTrigger>
|
|
833
|
+
<SelectValue />
|
|
834
|
+
</SelectTrigger>
|
|
835
|
+
<SelectContent>
|
|
836
|
+
{catchUpPolicies.map((value) => (
|
|
837
|
+
<SelectItem key={value} value={value}>{value.replaceAll("_", " ")}</SelectItem>
|
|
838
|
+
))}
|
|
839
|
+
</SelectContent>
|
|
840
|
+
</Select>
|
|
841
|
+
<p className="text-xs text-muted-foreground">{catchUpPolicyDescriptions[editDraft.catchUpPolicy]}</p>
|
|
842
|
+
</div>
|
|
843
|
+
</div>
|
|
844
|
+
</CollapsibleContent>
|
|
845
|
+
</Collapsible>
|
|
846
|
+
|
|
847
|
+
{/* Save bar */}
|
|
848
|
+
<div className="flex items-center justify-between">
|
|
849
|
+
{isEditDirty ? (
|
|
850
|
+
<span className="text-xs text-amber-600">Unsaved changes</span>
|
|
851
|
+
) : (
|
|
852
|
+
<span />
|
|
853
|
+
)}
|
|
854
|
+
<Button
|
|
855
|
+
onClick={() => saveRoutine.mutate()}
|
|
856
|
+
disabled={saveRoutine.isPending || !editDraft.title.trim() || !editDraft.projectId || !editDraft.assigneeAgentId}
|
|
857
|
+
>
|
|
858
|
+
<Save className="mr-2 h-4 w-4" />
|
|
859
|
+
Save routine
|
|
860
|
+
</Button>
|
|
861
|
+
</div>
|
|
862
|
+
|
|
863
|
+
<Separator />
|
|
864
|
+
|
|
865
|
+
{/* Tabs */}
|
|
866
|
+
<Tabs value={activeTab} onValueChange={setActiveTab} className="space-y-3">
|
|
867
|
+
<TabsList variant="line" className="w-full justify-start gap-1">
|
|
868
|
+
<TabsTrigger value="triggers" className="gap-1.5">
|
|
869
|
+
<Clock3 className="h-3.5 w-3.5" />
|
|
870
|
+
Triggers
|
|
871
|
+
</TabsTrigger>
|
|
872
|
+
<TabsTrigger value="runs" className="gap-1.5">
|
|
873
|
+
<Play className="h-3.5 w-3.5" />
|
|
874
|
+
Runs
|
|
875
|
+
{hasLiveRun && <span className="h-2 w-2 rounded-full bg-blue-500 animate-pulse" />}
|
|
876
|
+
</TabsTrigger>
|
|
877
|
+
<TabsTrigger value="activity" className="gap-1.5">
|
|
878
|
+
<ActivityIcon className="h-3.5 w-3.5" />
|
|
879
|
+
Activity
|
|
880
|
+
</TabsTrigger>
|
|
881
|
+
</TabsList>
|
|
882
|
+
|
|
883
|
+
<TabsContent value="triggers" className="space-y-4">
|
|
884
|
+
{/* Add trigger form */}
|
|
885
|
+
<div className="rounded-lg border border-border p-4 space-y-3">
|
|
886
|
+
<p className="text-sm font-medium">Add trigger</p>
|
|
887
|
+
<div className="grid gap-3 md:grid-cols-2">
|
|
888
|
+
<div className="space-y-1.5">
|
|
889
|
+
<Label className="text-xs">Kind</Label>
|
|
890
|
+
<Select value={newTrigger.kind} onValueChange={(kind) => setNewTrigger((current) => ({ ...current, kind }))}>
|
|
891
|
+
<SelectTrigger>
|
|
892
|
+
<SelectValue />
|
|
893
|
+
</SelectTrigger>
|
|
894
|
+
<SelectContent>
|
|
895
|
+
{triggerKinds.map((kind) => (
|
|
896
|
+
<SelectItem key={kind} value={kind} disabled={kind === "webhook"}>
|
|
897
|
+
{kind}{kind === "webhook" ? " — COMING SOON" : ""}
|
|
898
|
+
</SelectItem>
|
|
899
|
+
))}
|
|
900
|
+
</SelectContent>
|
|
901
|
+
</Select>
|
|
902
|
+
</div>
|
|
903
|
+
{newTrigger.kind === "schedule" && (
|
|
904
|
+
<div className="md:col-span-2 space-y-1.5">
|
|
905
|
+
<Label className="text-xs">Schedule</Label>
|
|
906
|
+
<ScheduleEditor
|
|
907
|
+
value={newTrigger.cronExpression}
|
|
908
|
+
onChange={(cronExpression) => setNewTrigger((current) => ({ ...current, cronExpression }))}
|
|
909
|
+
/>
|
|
910
|
+
</div>
|
|
911
|
+
)}
|
|
912
|
+
{newTrigger.kind === "webhook" && (
|
|
913
|
+
<>
|
|
914
|
+
<div className="space-y-1.5">
|
|
915
|
+
<Label className="text-xs">Signing mode</Label>
|
|
916
|
+
<Select value={newTrigger.signingMode} onValueChange={(signingMode) => setNewTrigger((current) => ({ ...current, signingMode }))}>
|
|
917
|
+
<SelectTrigger>
|
|
918
|
+
<SelectValue />
|
|
919
|
+
</SelectTrigger>
|
|
920
|
+
<SelectContent>
|
|
921
|
+
{signingModes.map((mode) => (
|
|
922
|
+
<SelectItem key={mode} value={mode}>{mode}</SelectItem>
|
|
923
|
+
))}
|
|
924
|
+
</SelectContent>
|
|
925
|
+
</Select>
|
|
926
|
+
<p className="text-xs text-muted-foreground">{signingModeDescriptions[newTrigger.signingMode]}</p>
|
|
927
|
+
</div>
|
|
928
|
+
<div className="space-y-1.5">
|
|
929
|
+
<Label className="text-xs">Replay window (seconds)</Label>
|
|
930
|
+
<Input value={newTrigger.replayWindowSec} onChange={(event) => setNewTrigger((current) => ({ ...current, replayWindowSec: event.target.value }))} />
|
|
931
|
+
</div>
|
|
932
|
+
</>
|
|
933
|
+
)}
|
|
934
|
+
</div>
|
|
935
|
+
<div className="flex items-center justify-end">
|
|
936
|
+
<Button size="sm" onClick={() => createTrigger.mutate()} disabled={createTrigger.isPending}>
|
|
937
|
+
{createTrigger.isPending ? "Adding..." : "Add trigger"}
|
|
938
|
+
</Button>
|
|
939
|
+
</div>
|
|
940
|
+
</div>
|
|
941
|
+
|
|
942
|
+
{/* Existing triggers */}
|
|
943
|
+
{routine.triggers.length === 0 ? (
|
|
944
|
+
<p className="text-xs text-muted-foreground">No triggers configured yet.</p>
|
|
945
|
+
) : (
|
|
946
|
+
<div className="space-y-3">
|
|
947
|
+
{routine.triggers.map((trigger) => (
|
|
948
|
+
<TriggerEditor
|
|
949
|
+
key={trigger.id}
|
|
950
|
+
trigger={trigger}
|
|
951
|
+
onSave={(id, patch) => updateTrigger.mutate({ id, patch })}
|
|
952
|
+
onRotate={(id) => rotateTrigger.mutate(id)}
|
|
953
|
+
onDelete={(id) => deleteTrigger.mutate(id)}
|
|
954
|
+
/>
|
|
955
|
+
))}
|
|
956
|
+
</div>
|
|
957
|
+
)}
|
|
958
|
+
</TabsContent>
|
|
959
|
+
|
|
960
|
+
<TabsContent value="runs" className="space-y-4">
|
|
961
|
+
{hasLiveRun && activeIssueId && routine && (
|
|
962
|
+
<LiveRunWidget issueId={activeIssueId} companyId={routine.companyId} />
|
|
963
|
+
)}
|
|
964
|
+
{(routineRuns ?? []).length === 0 ? (
|
|
965
|
+
<p className="text-xs text-muted-foreground">No runs yet.</p>
|
|
966
|
+
) : (
|
|
967
|
+
<div className="border border-border rounded-lg divide-y divide-border">
|
|
968
|
+
{(routineRuns ?? []).map((run) => (
|
|
969
|
+
<div key={run.id} className="flex items-center justify-between px-3 py-2 text-sm">
|
|
970
|
+
<div className="flex items-center gap-2 min-w-0">
|
|
971
|
+
<Badge variant="outline" className="shrink-0">{run.source}</Badge>
|
|
972
|
+
<Badge variant={run.status === "failed" ? "destructive" : "secondary"} className="shrink-0">
|
|
973
|
+
{run.status.replaceAll("_", " ")}
|
|
974
|
+
</Badge>
|
|
975
|
+
{run.trigger && (
|
|
976
|
+
<span className="text-muted-foreground truncate">{run.trigger.label ?? run.trigger.kind}</span>
|
|
977
|
+
)}
|
|
978
|
+
{run.linkedIssue && (
|
|
979
|
+
<Link to={`/issues/${run.linkedIssue.identifier ?? run.linkedIssue.id}`} className="text-muted-foreground hover:underline truncate">
|
|
980
|
+
{run.linkedIssue.identifier ?? run.linkedIssue.id.slice(0, 8)}
|
|
981
|
+
</Link>
|
|
982
|
+
)}
|
|
983
|
+
</div>
|
|
984
|
+
<span className="text-xs text-muted-foreground shrink-0 ml-2">{timeAgo(run.triggeredAt)}</span>
|
|
985
|
+
</div>
|
|
986
|
+
))}
|
|
987
|
+
</div>
|
|
988
|
+
)}
|
|
989
|
+
</TabsContent>
|
|
990
|
+
|
|
991
|
+
<TabsContent value="activity">
|
|
992
|
+
{(activity ?? []).length === 0 ? (
|
|
993
|
+
<p className="text-xs text-muted-foreground">No activity yet.</p>
|
|
994
|
+
) : (
|
|
995
|
+
<div className="border border-border rounded-lg divide-y divide-border">
|
|
996
|
+
{(activity ?? []).map((event) => (
|
|
997
|
+
<div key={event.id} className="flex items-center justify-between px-3 py-2 text-xs gap-4">
|
|
998
|
+
<div className="flex items-center gap-2 min-w-0">
|
|
999
|
+
<span className="font-medium text-foreground/90 shrink-0">{event.action.replaceAll(".", " ")}</span>
|
|
1000
|
+
{event.details && Object.keys(event.details).length > 0 && (
|
|
1001
|
+
<span className="text-muted-foreground truncate">
|
|
1002
|
+
{Object.entries(event.details).slice(0, 3).map(([key, value], i) => (
|
|
1003
|
+
<span key={key}>
|
|
1004
|
+
{i > 0 && <span className="mx-1 text-border">·</span>}
|
|
1005
|
+
<span className="text-muted-foreground/70">{key.replaceAll("_", " ")}:</span>{" "}
|
|
1006
|
+
{formatActivityDetailValue(value)}
|
|
1007
|
+
</span>
|
|
1008
|
+
))}
|
|
1009
|
+
</span>
|
|
1010
|
+
)}
|
|
1011
|
+
</div>
|
|
1012
|
+
<span className="text-muted-foreground/60 shrink-0">{timeAgo(event.createdAt)}</span>
|
|
1013
|
+
</div>
|
|
1014
|
+
))}
|
|
1015
|
+
</div>
|
|
1016
|
+
)}
|
|
1017
|
+
</TabsContent>
|
|
1018
|
+
</Tabs>
|
|
1019
|
+
</div>
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
|