@opengsd/gsd-pi 1.2.0 → 1.3.0-dev.72e3af2a
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/README.md +13 -7
- package/dist/cli-model-override.d.ts +15 -0
- package/dist/cli-model-override.js +21 -0
- package/dist/cli-style.d.ts +17 -0
- package/dist/cli-style.js +28 -0
- package/dist/cli-web-branch.d.ts +2 -0
- package/dist/cli-web-branch.js +9 -2
- package/dist/cli.js +30 -20
- package/dist/headless-context.js +0 -1
- package/dist/headless-events.d.ts +20 -3
- package/dist/headless-events.js +33 -36
- package/dist/headless.js +8 -1
- package/dist/help-text.js +34 -0
- package/dist/hermes-integration-install.d.ts +17 -0
- package/dist/hermes-integration-install.js +199 -0
- package/dist/jiti-workspace-aliases.d.ts +11 -2
- package/dist/jiti-workspace-aliases.js +19 -3
- package/dist/loader.js +6 -4
- package/dist/mcp-server.js +2 -1
- package/dist/models-resolver.d.ts +3 -13
- package/dist/models-resolver.js +3 -22
- package/dist/onboarding.js +9 -4
- package/dist/provider-migrations.d.ts +23 -0
- package/dist/provider-migrations.js +41 -0
- package/dist/read-cli.d.ts +23 -0
- package/dist/read-cli.js +90 -0
- package/dist/register-agent-bundles.d.ts +11 -2
- package/dist/register-agent-bundles.js +18 -4
- package/dist/resource-loader.d.ts +10 -5
- package/dist/resource-loader.js +121 -27
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/GSD-WORKFLOW.md +27 -26
- package/dist/resources/extensions/ask-user-questions.js +81 -25
- package/dist/resources/extensions/async-jobs/async-bash-tool.js +30 -64
- package/dist/resources/extensions/async-jobs/await-tool.js +80 -12
- package/dist/resources/extensions/async-jobs/index.js +65 -0
- package/dist/resources/extensions/async-jobs/job-manager.js +12 -1
- package/dist/resources/extensions/bg-shell/bg-shell-command.js +6 -6
- package/dist/resources/extensions/bg-shell/bg-shell-tool.js +10 -7
- package/dist/resources/extensions/bg-shell/overlay.js +9 -6
- package/dist/resources/extensions/bg-shell/process-manager.js +54 -25
- package/dist/resources/extensions/bg-shell/readiness-detector.js +11 -0
- package/dist/resources/extensions/bg-shell/utilities.js +5 -2
- package/dist/resources/extensions/browser-tools/engine/managed-gsd-browser.js +209 -88
- package/dist/resources/extensions/browser-tools/engine/selection.js +73 -5
- package/dist/resources/extensions/browser-tools/index.js +69 -12
- package/dist/resources/extensions/claude-code-cli/index.js +7 -1
- package/dist/resources/extensions/claude-code-cli/models.js +9 -0
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +622 -440
- package/dist/resources/extensions/claude-code-cli/turn-assembler.js +256 -0
- package/dist/resources/extensions/github-sync/templates.js +3 -3
- package/dist/resources/extensions/google-cli/stream-adapter.js +98 -16
- package/dist/resources/extensions/gsd/artifact-projection.js +14 -0
- package/dist/resources/extensions/gsd/artifact-verification.js +427 -0
- package/dist/resources/extensions/gsd/auto/closeout.js +215 -0
- package/dist/resources/extensions/gsd/auto/custom-verify-retry-store.js +17 -2
- package/dist/resources/extensions/gsd/auto/detect-stuck.js +33 -13
- package/dist/resources/extensions/gsd/auto/dispatch-history.js +125 -0
- package/dist/resources/extensions/gsd/auto/dispatch-key.js +37 -0
- package/dist/resources/extensions/gsd/auto/dispatch.js +365 -0
- package/dist/resources/extensions/gsd/auto/finalize.js +347 -0
- package/dist/resources/extensions/gsd/auto/loop.js +147 -58
- package/dist/resources/extensions/gsd/auto/milestone-lease-reclaim.js +56 -0
- package/dist/resources/extensions/gsd/auto/orchestrator.js +361 -80
- package/dist/resources/extensions/gsd/auto/phase-helpers.js +146 -0
- package/dist/resources/extensions/gsd/auto/phases.js +17 -2299
- package/dist/resources/extensions/gsd/auto/pre-dispatch.js +542 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +2 -1
- package/dist/resources/extensions/gsd/auto/session.js +9 -0
- package/dist/resources/extensions/gsd/auto/unit-phase.js +694 -0
- package/dist/resources/extensions/gsd/auto/workflow-kernel.js +15 -1
- package/dist/resources/extensions/gsd/auto/workflow-unit-dispatch.js +1 -1
- package/dist/resources/extensions/gsd/auto/worktree-safety-phase.js +125 -0
- package/dist/resources/extensions/gsd/auto-artifact-paths.js +108 -19
- package/dist/resources/extensions/gsd/auto-closeout-messaging.js +90 -0
- package/dist/resources/extensions/gsd/auto-dashboard.js +271 -435
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +26 -37
- package/dist/resources/extensions/gsd/auto-dispatch.js +122 -89
- package/dist/resources/extensions/gsd/auto-model-selection.js +56 -19
- package/dist/resources/extensions/gsd/auto-post-unit.js +85 -45
- package/dist/resources/extensions/gsd/auto-prompts.js +221 -57
- package/dist/resources/extensions/gsd/auto-recovery.js +63 -487
- package/dist/resources/extensions/gsd/auto-runtime-state.js +26 -0
- package/dist/resources/extensions/gsd/auto-start.js +116 -82
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +3 -3
- package/dist/resources/extensions/gsd/auto-timers.js +16 -2
- package/dist/resources/extensions/gsd/auto-tool-tracking.js +50 -0
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +45 -21
- package/dist/resources/extensions/gsd/auto-unit-tool-scope.js +14 -47
- package/dist/resources/extensions/gsd/auto-verification.js +34 -38
- package/dist/resources/extensions/gsd/auto-worktree-repair.js +10 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +230 -467
- package/dist/resources/extensions/gsd/auto.js +158 -50
- package/dist/resources/extensions/gsd/blocked-models.js +28 -0
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +161 -62
- package/dist/resources/extensions/gsd/bootstrap/core-session-tools.js +38 -0
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +34 -38
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +74 -50
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +4 -2
- package/dist/resources/extensions/gsd/bootstrap/fallback-continuation.js +25 -0
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +2 -2
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +42 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +431 -186
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +190 -43
- package/dist/resources/extensions/gsd/bootstrap/tool-call-loop-guard.js +68 -10
- package/dist/resources/extensions/gsd/bootstrap/tool-search-shim.js +22 -3
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +476 -83
- package/dist/resources/extensions/gsd/branch-patterns.js +2 -0
- package/dist/resources/extensions/gsd/browser-daemon-auto-prep.js +83 -0
- package/dist/resources/extensions/gsd/browser-evidence.js +8 -2
- package/dist/resources/extensions/gsd/captures.js +5 -15
- package/dist/resources/extensions/gsd/closeout-consistency-gate.js +110 -5
- package/dist/resources/extensions/gsd/closeout-recovery.js +3 -2
- package/dist/resources/extensions/gsd/closeout-wizard.js +97 -0
- package/dist/resources/extensions/gsd/codebase-generator.js +1 -0
- package/dist/resources/extensions/gsd/commands/catalog.js +12 -62
- package/dist/resources/extensions/gsd/commands/context.js +16 -2
- package/dist/resources/extensions/gsd/commands/dispatcher.js +3 -0
- package/dist/resources/extensions/gsd/commands/gsd-core-aliases-handler.js +39 -0
- package/dist/resources/extensions/gsd/commands/gsd-core-aliases.js +44 -0
- package/dist/resources/extensions/gsd/commands/handlers/auto.js +3 -0
- package/dist/resources/extensions/gsd/commands/handlers/core.js +52 -8
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +227 -3
- package/dist/resources/extensions/gsd/commands-cmux.js +3 -1
- package/dist/resources/extensions/gsd/commands-context.js +19 -1
- package/dist/resources/extensions/gsd/commands-gsd-core.js +868 -0
- package/dist/resources/extensions/gsd/commands-handlers.js +133 -4
- package/dist/resources/extensions/gsd/commands-inspect.js +4 -8
- package/dist/resources/extensions/gsd/commands-maintenance.js +140 -43
- package/dist/resources/extensions/gsd/commands-mcp-status.js +2 -2
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +30 -11
- package/dist/resources/extensions/gsd/commands-ship.js +2 -2
- package/dist/resources/extensions/gsd/commands-verdict.js +21 -5
- package/dist/resources/extensions/gsd/commands-workflow-templates.js +9 -2
- package/dist/resources/extensions/gsd/commands-worktree.js +12 -10
- package/dist/resources/extensions/gsd/compat/compat-marker.js +172 -0
- package/dist/resources/extensions/gsd/compat/index.js +3 -0
- package/dist/resources/extensions/gsd/compat/planning-compat.js +142 -0
- package/dist/resources/extensions/gsd/config-overlay.js +11 -8
- package/dist/resources/extensions/gsd/consent-question.js +365 -0
- package/dist/resources/extensions/gsd/consent-verdict.js +73 -0
- package/dist/resources/extensions/gsd/constants.js +0 -2
- package/dist/resources/extensions/gsd/crash-recovery.js +12 -15
- package/dist/resources/extensions/gsd/dashboard-overlay.js +71 -6
- package/dist/resources/extensions/gsd/db/engine.js +800 -0
- package/dist/resources/extensions/gsd/db/queries.js +542 -0
- package/dist/resources/extensions/gsd/db/sql-constants.js +11 -0
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +22 -1
- package/dist/resources/extensions/gsd/db/writers/cascades.js +194 -0
- package/dist/resources/extensions/gsd/db/writers/import-restore.js +182 -0
- package/dist/resources/extensions/gsd/db/writers/memory.js +149 -0
- package/dist/resources/extensions/gsd/db/writers/reconcile.js +476 -0
- package/dist/resources/extensions/gsd/db/writers/status.js +70 -0
- package/dist/resources/extensions/gsd/db-migration-backup.js +51 -8
- package/dist/resources/extensions/gsd/db-transaction.js +27 -23
- package/dist/resources/extensions/gsd/db-workspace.js +167 -0
- package/dist/resources/extensions/gsd/db-writer.js +8 -17
- package/dist/resources/extensions/gsd/delegation-policy.js +2 -10
- package/dist/resources/extensions/gsd/discussion-handoff.js +222 -0
- package/dist/resources/extensions/gsd/dispatch-guard.js +10 -35
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +9 -0
- package/dist/resources/extensions/gsd/doctor-engine-checks.js +5 -5
- package/dist/resources/extensions/gsd/doctor-environment.js +261 -136
- package/dist/resources/extensions/gsd/doctor-format.js +9 -6
- package/dist/resources/extensions/gsd/doctor-git-checks.js +36 -25
- package/dist/resources/extensions/gsd/doctor-providers.js +93 -9
- package/dist/resources/extensions/gsd/doctor-runtime-checks.js +34 -40
- package/dist/resources/extensions/gsd/doctor.js +43 -15
- package/dist/resources/extensions/gsd/engine-hook-contract.js +70 -0
- package/dist/resources/extensions/gsd/error-classifier.js +22 -1
- package/dist/resources/extensions/gsd/escalation.js +11 -4
- package/dist/resources/extensions/gsd/exec-sandbox.js +75 -19
- package/dist/resources/extensions/gsd/export-html.js +10 -3
- package/dist/resources/extensions/gsd/export.js +73 -0
- package/dist/resources/extensions/gsd/file-lock.js +1 -1
- package/dist/resources/extensions/gsd/files.js +33 -19
- package/dist/resources/extensions/gsd/flat-phase-migration.js +176 -0
- package/dist/resources/extensions/gsd/forensics.js +4 -33
- package/dist/resources/extensions/gsd/git-conflict-state.js +16 -1
- package/dist/resources/extensions/gsd/git-service.js +12 -8
- package/dist/resources/extensions/gsd/gitignore.js +9 -2
- package/dist/resources/extensions/gsd/gsd-command-home.js +22 -12
- package/dist/resources/extensions/gsd/gsd-db.js +185 -2054
- package/dist/resources/extensions/gsd/guidance.js +158 -0
- package/dist/resources/extensions/gsd/guided-flow-queue.js +66 -5
- package/dist/resources/extensions/gsd/guided-flow.js +184 -478
- package/dist/resources/extensions/gsd/guided-unit-completion.js +225 -0
- package/dist/resources/extensions/gsd/health-widget.js +117 -32
- package/dist/resources/extensions/gsd/layout-policy.js +77 -0
- package/dist/resources/extensions/gsd/markdown-renderer.js +408 -123
- package/dist/resources/extensions/gsd/mcp-bridge.js +10 -0
- package/dist/resources/extensions/gsd/mcp-filter.js +48 -30
- package/dist/resources/extensions/gsd/mcp-tool-name.js +18 -0
- package/dist/resources/extensions/gsd/md-importer.js +157 -54
- package/dist/resources/extensions/gsd/memory-consolidation-scanner.js +45 -22
- package/dist/resources/extensions/gsd/memory-relations.js +1 -1
- package/dist/resources/extensions/gsd/metrics.js +19 -11
- package/dist/resources/extensions/gsd/migrate/layout-detect.js +32 -0
- package/dist/resources/extensions/gsd/migrate/planning-writer.js +203 -0
- package/dist/resources/extensions/gsd/migrate/safety.js +22 -11
- package/dist/resources/extensions/gsd/migrate-external.js +51 -6
- package/dist/resources/extensions/gsd/migration-auto-check.js +54 -19
- package/dist/resources/extensions/gsd/milestone-actions.js +5 -3
- package/dist/resources/extensions/gsd/milestone-closeout-proof.js +72 -0
- package/dist/resources/extensions/gsd/milestone-closeout.js +108 -29
- package/dist/resources/extensions/gsd/milestone-ids.js +79 -18
- package/dist/resources/extensions/gsd/milestone-implementation-evidence.js +26 -20
- package/dist/resources/extensions/gsd/milestone-merge-transaction.js +10 -0
- package/dist/resources/extensions/gsd/milestone-planning-persistence.js +164 -0
- package/dist/resources/extensions/gsd/milestone-readiness.js +77 -0
- package/dist/resources/extensions/gsd/milestone-reopen-events.js +3 -5
- package/dist/resources/extensions/gsd/milestone-settlement.js +50 -0
- package/dist/resources/extensions/gsd/milestone-validation-evidence.js +73 -0
- package/dist/resources/extensions/gsd/milestone-validation-verdict.js +60 -0
- package/dist/resources/extensions/gsd/model-cost-table.js +1 -0
- package/dist/resources/extensions/gsd/model-router.js +82 -20
- package/dist/resources/extensions/gsd/native-git-bridge.js +36 -0
- package/dist/resources/extensions/gsd/notification-store.js +33 -33
- package/dist/resources/extensions/gsd/notifications.js +48 -14
- package/dist/resources/extensions/gsd/observability-validator.js +12 -4
- package/dist/resources/extensions/gsd/parallel-eligibility.js +3 -6
- package/dist/resources/extensions/gsd/parallel-merge.js +14 -11
- package/dist/resources/extensions/gsd/parallel-monitor-overlay.js +144 -42
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +3 -2
- package/dist/resources/extensions/gsd/parsers-legacy.js +56 -18
- package/dist/resources/extensions/gsd/paths.js +393 -68
- package/dist/resources/extensions/gsd/planning-depth.js +2 -1
- package/dist/resources/extensions/gsd/post-execution-checks.js +26 -3
- package/dist/resources/extensions/gsd/pre-execution-checks.js +91 -3
- package/dist/resources/extensions/gsd/preferences-diagnostics.js +67 -0
- package/dist/resources/extensions/gsd/preferences-models.js +46 -60
- package/dist/resources/extensions/gsd/preferences.js +302 -35
- package/dist/resources/extensions/gsd/projection-flush.js +7 -0
- package/dist/resources/extensions/gsd/prompts/ai-integration-phase.md +28 -0
- package/dist/resources/extensions/gsd/prompts/audit-fix.md +39 -0
- package/dist/resources/extensions/gsd/prompts/audit-milestone.md +26 -0
- package/dist/resources/extensions/gsd/prompts/audit-uat.md +24 -0
- package/dist/resources/extensions/gsd/prompts/autonomous.md +31 -0
- package/dist/resources/extensions/gsd/prompts/code-review.md +39 -0
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +8 -2
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +25 -15
- package/dist/resources/extensions/gsd/prompts/discuss-phase.md +31 -0
- package/dist/resources/extensions/gsd/prompts/docs-update.md +13 -0
- package/dist/resources/extensions/gsd/prompts/execute-phase.md +33 -0
- package/dist/resources/extensions/gsd/prompts/execute-task.md +9 -2
- package/dist/resources/extensions/gsd/prompts/explore.md +58 -0
- package/dist/resources/extensions/gsd/prompts/graphify.md +27 -0
- package/dist/resources/extensions/gsd/prompts/guided-discuss-project.md +3 -1
- package/dist/resources/extensions/gsd/prompts/health.md +37 -0
- package/dist/resources/extensions/gsd/prompts/import.md +30 -0
- package/dist/resources/extensions/gsd/prompts/inbox.md +27 -0
- package/dist/resources/extensions/gsd/prompts/ingest-docs.md +30 -0
- package/dist/resources/extensions/gsd/prompts/manager.md +21 -0
- package/dist/resources/extensions/gsd/prompts/map-codebase.md +42 -0
- package/dist/resources/extensions/gsd/prompts/milestone-summary.md +27 -0
- package/dist/resources/extensions/gsd/prompts/mvp-phase.md +23 -0
- package/dist/resources/extensions/gsd/prompts/pause-work.md +24 -0
- package/dist/resources/extensions/gsd/prompts/phase.md +22 -0
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
- package/dist/resources/extensions/gsd/prompts/plan-phase.md +34 -0
- package/dist/resources/extensions/gsd/prompts/plan-review-convergence.md +34 -0
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +3 -2
- package/dist/resources/extensions/gsd/prompts/profile-user.md +28 -0
- package/dist/resources/extensions/gsd/prompts/progress.md +30 -0
- package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -1
- package/dist/resources/extensions/gsd/prompts/reactive-execute.md +2 -2
- package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
- package/dist/resources/extensions/gsd/prompts/refine-slice.md +3 -2
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/dist/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/resume-work.md +20 -0
- package/dist/resources/extensions/gsd/prompts/review-backlog.md +21 -0
- package/dist/resources/extensions/gsd/prompts/review.md +27 -0
- package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
- package/dist/resources/extensions/gsd/prompts/run-uat.md +13 -5
- package/dist/resources/extensions/gsd/prompts/secure-phase.md +24 -0
- package/dist/resources/extensions/gsd/prompts/settings.md +24 -0
- package/dist/resources/extensions/gsd/prompts/sketch.md +59 -0
- package/dist/resources/extensions/gsd/prompts/spec-phase.md +29 -0
- package/dist/resources/extensions/gsd/prompts/spike.md +59 -0
- package/dist/resources/extensions/gsd/prompts/stats.md +43 -0
- package/dist/resources/extensions/gsd/prompts/surface.md +25 -0
- package/dist/resources/extensions/gsd/prompts/system.md +6 -3
- package/dist/resources/extensions/gsd/prompts/thread.md +24 -0
- package/dist/resources/extensions/gsd/prompts/triage-captures.md +1 -1
- package/dist/resources/extensions/gsd/prompts/ui-phase.md +29 -0
- package/dist/resources/extensions/gsd/prompts/ui-review.md +29 -0
- package/dist/resources/extensions/gsd/prompts/ultraplan-phase.md +24 -0
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/validate-phase.md +26 -0
- package/dist/resources/extensions/gsd/prompts/verify-work.md +24 -0
- package/dist/resources/extensions/gsd/prompts/workflow-start.md +2 -1
- package/dist/resources/extensions/gsd/prompts/workspace.md +22 -0
- package/dist/resources/extensions/gsd/prompts/workstreams.md +24 -0
- package/dist/resources/extensions/gsd/provider-error-guidance.js +25 -5
- package/dist/resources/extensions/gsd/provider-payload-policy.js +83 -0
- package/dist/resources/extensions/gsd/provider-switch-observer.js +1 -1
- package/dist/resources/extensions/gsd/publication.js +87 -0
- package/dist/resources/extensions/gsd/pull-request-process.js +13 -0
- package/dist/resources/extensions/gsd/quality-gate-closure.js +109 -0
- package/dist/resources/extensions/gsd/question-transport.js +86 -0
- package/dist/resources/extensions/gsd/queue-order.js +3 -2
- package/dist/resources/extensions/gsd/quick.js +45 -2
- package/dist/resources/extensions/gsd/reactive-graph.js +8 -1
- package/dist/resources/extensions/gsd/recovery-classification.js +49 -87
- package/dist/resources/extensions/gsd/roadmap-slices.js +34 -6
- package/dist/resources/extensions/gsd/safety/content-validator.js +2 -1
- package/dist/resources/extensions/gsd/safety/destructive-confirmation.js +108 -0
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +37 -4
- package/dist/resources/extensions/gsd/safety/evidence-cross-ref.js +50 -3
- package/dist/resources/extensions/gsd/safety/file-change-validator.js +10 -0
- package/dist/resources/extensions/gsd/service-tier.js +2 -1
- package/dist/resources/extensions/gsd/session-forensics.js +11 -1
- package/dist/resources/extensions/gsd/session-lock.js +12 -10
- package/dist/resources/extensions/gsd/skill-activation.js +3 -6
- package/dist/resources/extensions/gsd/skills/gsd-headless/SKILL.md +3 -0
- package/dist/resources/extensions/gsd/skills/gsd-headless/references/commands.md +51 -0
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +3 -2
- package/dist/resources/extensions/gsd/state/derive/cache.js +28 -0
- package/dist/resources/extensions/gsd/state/derive/db-open.js +39 -0
- package/dist/resources/extensions/gsd/state/derive/from-db.js +452 -0
- package/dist/resources/extensions/gsd/state/derive/index.js +75 -0
- package/dist/resources/extensions/gsd/state/derive/interrupted-work.js +21 -0
- package/dist/resources/extensions/gsd/state-reconciliation/drift/artifact-db.js +51 -10
- package/dist/resources/extensions/gsd/state-reconciliation/drift/completion.js +24 -3
- package/dist/resources/extensions/gsd/state-reconciliation/drift/external-markdown-edit.js +82 -0
- package/dist/resources/extensions/gsd/state-reconciliation/drift/external-planning-edit.js +142 -0
- package/dist/resources/extensions/gsd/state-reconciliation/drift/project-md.js +19 -6
- package/dist/resources/extensions/gsd/state-reconciliation/drift/roadmap.js +2 -2
- package/dist/resources/extensions/gsd/state-reconciliation/drift/stale-render.js +138 -19
- package/dist/resources/extensions/gsd/state-reconciliation/index.js +84 -26
- package/dist/resources/extensions/gsd/state-reconciliation/registry.js +34 -18
- package/dist/resources/extensions/gsd/state-transition-matrix.js +38 -0
- package/dist/resources/extensions/gsd/state.js +19 -589
- package/dist/resources/extensions/gsd/status-guards.js +56 -8
- package/dist/resources/extensions/gsd/stop-notice.js +57 -0
- package/dist/resources/extensions/gsd/sync-lock.js +11 -18
- package/dist/resources/extensions/gsd/templates/plan.md +7 -0
- package/dist/resources/extensions/gsd/templates/project.md +1 -0
- package/dist/resources/extensions/gsd/templates/roadmap.md +1 -1
- package/dist/resources/extensions/gsd/templates/uat.md +5 -1
- package/dist/resources/extensions/gsd/tool-contract.js +66 -11
- package/dist/resources/extensions/gsd/tool-presentation-plan.js +17 -36
- package/dist/resources/extensions/gsd/tool-surface-readiness.js +297 -0
- package/dist/resources/extensions/gsd/tool-surface-snapshot.js +17 -0
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +7 -4
- package/dist/resources/extensions/gsd/tools/complete-slice.js +58 -57
- package/dist/resources/extensions/gsd/tools/complete-task.js +118 -12
- package/dist/resources/extensions/gsd/tools/exec-tool.js +14 -114
- package/dist/resources/extensions/gsd/tools/plan-milestone.js +15 -143
- package/dist/resources/extensions/gsd/tools/plan-slice.js +13 -9
- package/dist/resources/extensions/gsd/tools/plan-task.js +18 -3
- package/dist/resources/extensions/gsd/tools/reassess-roadmap.js +50 -5
- package/dist/resources/extensions/gsd/tools/reopen-milestone.js +13 -31
- package/dist/resources/extensions/gsd/tools/reopen-slice.js +16 -35
- package/dist/resources/extensions/gsd/tools/reopen-task.js +2 -2
- package/dist/resources/extensions/gsd/tools/replan-slice.js +2 -2
- package/dist/resources/extensions/gsd/tools/skip-slice.js +18 -36
- package/dist/resources/extensions/gsd/tools/validate-milestone.js +21 -79
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +110 -6
- package/dist/resources/extensions/gsd/triage-resolution.js +14 -7
- package/dist/resources/extensions/gsd/tui/render-kit.js +38 -13
- package/dist/resources/extensions/gsd/uat-policy.js +57 -25
- package/dist/resources/extensions/gsd/uat-run.js +9 -14
- package/dist/resources/extensions/gsd/undo.js +16 -16
- package/dist/resources/extensions/gsd/unit-closeout.js +138 -0
- package/dist/resources/extensions/gsd/unit-context-composer.js +130 -21
- package/dist/resources/extensions/gsd/unit-context-manifest.js +4 -27
- package/dist/resources/extensions/gsd/unit-registry.js +419 -0
- package/dist/resources/extensions/gsd/unit-runtime.js +3 -2
- package/dist/resources/extensions/gsd/unit-tool-contracts.js +9 -181
- package/dist/resources/extensions/gsd/unmerged-milestone-guard.js +91 -5
- package/dist/resources/extensions/gsd/validation-block-guard.js +55 -3
- package/dist/resources/extensions/gsd/verdict-parser.js +1 -1
- package/dist/resources/extensions/gsd/verification-verdict.js +2 -1
- package/dist/resources/extensions/gsd/visualizer-data.js +35 -0
- package/dist/resources/extensions/gsd/visualizer-views.js +21 -2
- package/dist/resources/extensions/gsd/web-app-uat.js +117 -0
- package/dist/resources/extensions/gsd/workflow-event-ledger.js +91 -0
- package/dist/resources/extensions/gsd/workflow-event-vocabulary.js +46 -0
- package/dist/resources/extensions/gsd/workflow-events.js +6 -18
- package/dist/resources/extensions/gsd/workflow-logger.js +4 -0
- package/dist/resources/extensions/gsd/workflow-mcp-auto-prep.js +2 -0
- package/dist/resources/extensions/gsd/workflow-mcp-readiness-cache.js +105 -0
- package/dist/resources/extensions/gsd/workflow-mcp.js +24 -103
- package/dist/resources/extensions/gsd/workflow-projections.js +44 -18
- package/dist/resources/extensions/gsd/workflow-reconcile.js +25 -59
- package/dist/resources/extensions/gsd/workflow-tool-surface.js +46 -0
- package/dist/resources/extensions/gsd/workspace-git-guard.js +2 -0
- package/dist/resources/extensions/gsd/workspace-git-preflight.js +30 -1
- package/dist/resources/extensions/gsd/worktree-command.js +6 -6
- package/dist/resources/extensions/gsd/worktree-git-recovery.js +293 -0
- package/dist/resources/extensions/gsd/worktree-health.js +6 -3
- package/dist/resources/extensions/gsd/worktree-lifecycle.js +12 -3
- package/dist/resources/extensions/gsd/worktree-manager.js +204 -46
- package/dist/resources/extensions/gsd/worktree-placement.js +59 -0
- package/dist/resources/extensions/gsd/worktree-reentry.js +12 -8
- package/dist/resources/extensions/gsd/worktree-root.js +28 -6
- package/dist/resources/extensions/gsd/worktree-safety.js +48 -34
- package/dist/resources/extensions/gsd/worktree-session-state.js +12 -11
- package/dist/resources/extensions/gsd/worktree-shell-guard.js +113 -0
- package/dist/resources/extensions/gsd/worktree-state-projection.js +33 -4
- package/dist/resources/extensions/gsd/worktree-telemetry.js +12 -0
- package/dist/resources/extensions/gsd/worktree.js +8 -1
- package/dist/resources/extensions/mcp-client/manager.js +9 -4
- package/dist/resources/extensions/search-the-web/index.js +41 -9
- package/dist/resources/extensions/search-the-web/native-search.js +23 -7
- package/dist/resources/extensions/shared/browser-contract.js +59 -0
- package/dist/resources/extensions/shared/gsd-browser-cli.js +156 -8
- package/dist/resources/extensions/shared/interview-ui.js +2 -2
- package/dist/resources/extensions/subagent/index.js +20 -15
- package/dist/resources/extensions/subagent/worktree-cwd.js +31 -0
- package/dist/resources/shared/claude-runtime-floor.js +182 -0
- package/dist/resources/shared/gsd-browser-path-sync.js +214 -0
- package/dist/resources/shared/package-manager-detection.js +1 -1
- package/dist/resources/shared/package.json +3 -0
- package/dist/resources/skills/create-skill/SKILL.md +3 -0
- package/dist/resources/skills/create-skill/references/executable-code.md +1 -1
- package/dist/resources/skills/create-skill/references/skill-structure.md +1 -0
- package/dist/resources/skills/create-skill/workflows/add-reference.md +8 -3
- package/dist/resources/skills/create-skill/workflows/add-script.md +4 -2
- package/dist/resources/skills/create-skill/workflows/add-template.md +3 -1
- package/dist/resources/skills/create-skill/workflows/add-workflow.md +8 -3
- package/dist/resources/skills/create-skill/workflows/upgrade-to-router.md +10 -5
- package/dist/resources/skills/create-skill/workflows/verify-skill.md +9 -4
- package/dist/resources/skills/spike-wrap-up/SKILL.md +9 -9
- package/dist/runtime-checks.d.ts +10 -0
- package/dist/runtime-checks.js +27 -0
- package/dist/tsconfig.extensions.tsbuildinfo +1 -0
- package/dist/update-check.d.ts +2 -0
- package/dist/update-check.js +39 -5
- package/dist/update-cmd.js +40 -3
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +9 -9
- package/dist/web/standalone/.next/build-manifest.json +4 -4
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +9 -9
- package/dist/web/standalone/.next/required-server-files.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
- package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/mcp-connections/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/mcp-connections/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/mcp-connections/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/notifications/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/session/events/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +9 -9
- package/dist/web/standalone/.next/server/chunks/1128.js +2 -0
- package/dist/web/standalone/.next/server/chunks/2842.js +4 -4
- package/dist/web/standalone/.next/server/chunks/5124.js +1 -1
- package/dist/web/standalone/.next/server/chunks/8357.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware.js +3 -3
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/2659.58e950899a9bb82f.js +1 -0
- package/dist/web/standalone/.next/static/chunks/2772.a7c1fcc69a4685ef.js +1 -0
- package/dist/web/standalone/.next/static/chunks/{3616.4113d484a994e411.js → 3616.61a2af74bb8833c8.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/4283.d0d9e0a955e441cb.js +2 -0
- package/dist/web/standalone/.next/static/chunks/5826.5421d66c72b9f34e.js +1 -0
- package/dist/web/standalone/.next/static/chunks/8785.e29b3134cab1d153.js +1 -0
- package/dist/web/standalone/.next/static/chunks/8937.640dc9c2aaa1dfad.js +10 -0
- package/dist/web/standalone/.next/static/chunks/app/_not-found/page-a6fb1847f67f167c.js +1 -0
- package/dist/web/standalone/.next/static/chunks/app/{layout-b35cbfff38aaf4cf.js → layout-4ae2d68984392bbf.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/page-72a856634ad14c10.js +1 -0
- package/dist/web/standalone/.next/static/chunks/{main-app-590a74400e35f685.js → main-app-90d1d8d5e5d2dc6b.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-1115d46ac61b9823.js +1 -0
- package/dist/web/standalone/.next/static/chunks/webpack-9c401904f87ded16.js +1 -0
- package/dist/web/standalone/node_modules/@gsd/native/package.json +1 -1
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
- package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
- package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
- package/dist/web/standalone/node_modules/postcss/lib/container.js +26 -18
- package/dist/web/standalone/node_modules/postcss/lib/css-syntax-error.js +47 -14
- package/dist/web/standalone/node_modules/postcss/lib/declaration.js +4 -4
- package/dist/web/standalone/node_modules/postcss/lib/fromJSON.js +3 -3
- package/dist/web/standalone/node_modules/postcss/lib/input.js +54 -29
- package/dist/web/standalone/node_modules/postcss/lib/lazy-result.js +47 -37
- package/dist/web/standalone/node_modules/postcss/lib/map-generator.js +26 -9
- package/dist/web/standalone/node_modules/postcss/lib/no-work-result.js +57 -55
- package/dist/web/standalone/node_modules/postcss/lib/node.js +99 -31
- package/dist/web/standalone/node_modules/postcss/lib/parse.js +1 -1
- package/dist/web/standalone/node_modules/postcss/lib/parser.js +10 -9
- package/dist/web/standalone/node_modules/postcss/lib/postcss.js +12 -12
- package/dist/web/standalone/node_modules/postcss/lib/previous-map.js +30 -11
- package/dist/web/standalone/node_modules/postcss/lib/processor.js +7 -7
- package/dist/web/standalone/node_modules/postcss/lib/result.js +5 -5
- package/dist/web/standalone/node_modules/postcss/lib/rule.js +6 -6
- package/dist/web/standalone/node_modules/postcss/lib/stringifier.js +69 -28
- package/dist/web/standalone/node_modules/postcss/lib/tokenize.js +6 -2
- package/dist/web/standalone/node_modules/postcss/package.json +48 -48
- package/dist/web/standalone/package.json +1 -1
- package/dist/web/standalone/server.js +1 -1
- package/dist/web-mode.d.ts +5 -1
- package/dist/web-mode.js +27 -13
- package/dist/worktree-cli.js +3 -6
- package/dist/worktree-status-banner.js +7 -11
- package/integrations/hermes/README.md +48 -0
- package/integrations/hermes/docs/setup.md +272 -0
- package/integrations/hermes/docs/upstream-hermes-pr.md +40 -0
- package/integrations/hermes/open_gsd_hermes/__init__.py +105 -0
- package/integrations/hermes/open_gsd_hermes/binding.py +107 -0
- package/integrations/hermes/open_gsd_hermes/commands.py +186 -0
- package/integrations/hermes/open_gsd_hermes/config.py +59 -0
- package/integrations/hermes/open_gsd_hermes/credentials.py +51 -0
- package/integrations/hermes/open_gsd_hermes/cron.py +85 -0
- package/integrations/hermes/open_gsd_hermes/formatting.py +13 -0
- package/integrations/hermes/open_gsd_hermes/gsd_client.py +269 -0
- package/integrations/hermes/open_gsd_hermes/inject.py +31 -0
- package/integrations/hermes/open_gsd_hermes/memory.py +66 -0
- package/integrations/hermes/open_gsd_hermes/notifications.py +71 -0
- package/integrations/hermes/open_gsd_hermes/snapshot.py +42 -0
- package/integrations/hermes/open_gsd_hermes/supervisor.py +180 -0
- package/integrations/hermes/open_gsd_hermes/types.py +100 -0
- package/integrations/hermes/plugin.yaml +38 -0
- package/integrations/hermes/pyproject.toml +32 -0
- package/integrations/hermes/scripts/preflight.sh +92 -0
- package/integrations/hermes/tests/fixtures/minimal-project/.gsd/STATE.md +17 -0
- package/integrations/hermes/tests/golden/memory_prefetch.txt +5 -0
- package/integrations/hermes/tests/golden/snapshot.txt +8 -0
- package/integrations/hermes/tests/test_binding.py +103 -0
- package/integrations/hermes/tests/test_config.py +36 -0
- package/integrations/hermes/tests/test_cron.py +34 -0
- package/integrations/hermes/tests/test_gsd_client_cache.py +120 -0
- package/integrations/hermes/tests/test_memory.py +59 -0
- package/integrations/hermes/tests/test_read_cli_contract.py +50 -0
- package/integrations/hermes/tests/test_register.py +56 -0
- package/integrations/hermes/tests/test_snapshot.py +53 -0
- package/integrations/hermes/tests/test_supervisor_fsm.py +581 -0
- package/package.json +19 -14
- package/packages/cloud-mcp-gateway/dist/runtime-registry.d.ts +8 -0
- package/packages/cloud-mcp-gateway/dist/runtime-registry.d.ts.map +1 -1
- package/packages/cloud-mcp-gateway/dist/runtime-registry.js +19 -2
- package/packages/cloud-mcp-gateway/dist/runtime-registry.js.map +1 -1
- package/packages/cloud-mcp-gateway/dist/runtime-registry.test.js +71 -2
- package/packages/cloud-mcp-gateway/dist/runtime-registry.test.js.map +1 -1
- package/packages/cloud-mcp-gateway/package.json +2 -2
- package/packages/contracts/dist/rpc.d.ts +1 -0
- package/packages/contracts/dist/rpc.d.ts.map +1 -1
- package/packages/contracts/dist/rpc.js.map +1 -1
- package/packages/contracts/dist/workflow.d.ts +5 -0
- package/packages/contracts/dist/workflow.d.ts.map +1 -1
- package/packages/contracts/dist/workflow.js +2 -0
- package/packages/contracts/dist/workflow.js.map +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/daemon/package.json +4 -4
- package/packages/gsd-agent-core/dist/agent-session.d.ts +1 -0
- package/packages/gsd-agent-core/dist/agent-session.d.ts.map +1 -1
- package/packages/gsd-agent-core/dist/agent-session.js +3 -0
- package/packages/gsd-agent-core/dist/agent-session.js.map +1 -1
- package/packages/gsd-agent-core/dist/extension-ui-snapshot.d.ts +41 -0
- package/packages/gsd-agent-core/dist/extension-ui-snapshot.d.ts.map +1 -0
- package/packages/gsd-agent-core/dist/extension-ui-snapshot.js +62 -0
- package/packages/gsd-agent-core/dist/extension-ui-snapshot.js.map +1 -0
- package/packages/gsd-agent-core/dist/index.d.ts +2 -0
- package/packages/gsd-agent-core/dist/index.d.ts.map +1 -1
- package/packages/gsd-agent-core/dist/index.js +2 -0
- package/packages/gsd-agent-core/dist/index.js.map +1 -1
- package/packages/gsd-agent-core/dist/sdk.d.ts.map +1 -1
- package/packages/gsd-agent-core/dist/sdk.js +12 -6
- package/packages/gsd-agent-core/dist/sdk.js.map +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-events.js +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-events.js.map +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-extensions.d.ts +2 -0
- package/packages/gsd-agent-core/dist/session/agent-session-extensions.d.ts.map +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-extensions.js +14 -0
- package/packages/gsd-agent-core/dist/session/agent-session-extensions.js.map +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-host.d.ts +1 -0
- package/packages/gsd-agent-core/dist/session/agent-session-host.d.ts.map +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-host.js.map +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-prompt.d.ts +5 -0
- package/packages/gsd-agent-core/dist/session/agent-session-prompt.d.ts.map +1 -1
- package/packages/gsd-agent-core/dist/session/agent-session-prompt.js +60 -3
- package/packages/gsd-agent-core/dist/session/agent-session-prompt.js.map +1 -1
- package/packages/gsd-agent-core/dist/transcript-store.d.ts +58 -0
- package/packages/gsd-agent-core/dist/transcript-store.d.ts.map +1 -0
- package/packages/gsd-agent-core/dist/transcript-store.js +132 -0
- package/packages/gsd-agent-core/dist/transcript-store.js.map +1 -0
- package/packages/gsd-agent-core/package.json +5 -5
- package/packages/gsd-agent-modes/dist/modes/interactive/components/assistant-message.d.ts +5 -5
- package/packages/gsd-agent-modes/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/assistant-message.js +12 -24
- package/packages/gsd-agent-modes/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/bash-execution.js +5 -5
- package/packages/gsd-agent-modes/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/branch-summary-message.d.ts +3 -3
- package/packages/gsd-agent-modes/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/branch-summary-message.js +20 -11
- package/packages/gsd-agent-modes/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/chat-turn-connect.d.ts +4 -3
- package/packages/gsd-agent-modes/dist/modes/interactive/components/chat-turn-connect.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/chat-turn-connect.js +5 -54
- package/packages/gsd-agent-modes/dist/modes/interactive/components/chat-turn-connect.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -4
- package/packages/gsd-agent-modes/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/compaction-summary-message.js +2 -4
- package/packages/gsd-agent-modes/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/custom-editor.js +4 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/footer.d.ts +9 -12
- package/packages/gsd-agent-modes/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/footer.js +100 -166
- package/packages/gsd-agent-modes/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-progress-state.d.ts +2 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-progress-state.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-progress-state.js +4 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-progress-state.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-status-widget.d.ts +23 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-status-widget.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-status-widget.js +178 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/gsd-status-widget.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.d.ts +8 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.js +21 -9
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.js +10 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -3
- package/packages/gsd-agent-modes/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/skill-invocation-message.js +2 -3
- package/packages/gsd-agent-modes/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts +18 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js +110 -22
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.d.ts +71 -3
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.js +257 -37
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/user-message.d.ts +3 -3
- package/packages/gsd-agent-modes/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/user-message.js +19 -19
- package/packages/gsd-agent-modes/dist/modes/interactive/components/user-message.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.d.ts +4 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.js +7 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.d.ts +6 -24
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js +63 -777
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.d.ts +58 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.js +312 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.d.ts +31 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.js +130 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.d.ts +15 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.js +258 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.d.ts +13 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.js +118 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/extension-ui-controller.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/extension-ui-controller.js +12 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/extension-ui-controller.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.js +13 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-autocomplete.js +3 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-chat-render.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-chat-render.js +14 -6
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-chat-render.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-extension-dialogs.js +2 -2
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-extension-widgets.d.ts +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-extension-widgets.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-extension-widgets.js +31 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-key-handlers.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-key-handlers.js +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-key-handlers.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-init.d.ts +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-init.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-init.js +20 -49
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-init.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.d.ts +13 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.js +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.d.ts +54 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.js +20 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.d.ts +14 -3
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js +57 -6
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.js +4 -4
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-settings.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-settings.js +4 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-settings.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-ui-messaging.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-ui-messaging.js +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-ui-messaging.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.d.ts +56 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.js +44 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.d.ts +5 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.d.ts.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.js +77 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.js.map +1 -0
- package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.js +24 -1
- package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/packages/gsd-agent-modes/package.json +7 -7
- package/packages/mcp-server/README.md +23 -4
- package/packages/mcp-server/dist/cli-errors.d.ts +11 -0
- package/packages/mcp-server/dist/cli-errors.d.ts.map +1 -1
- package/packages/mcp-server/dist/cli-errors.js +12 -0
- package/packages/mcp-server/dist/cli-errors.js.map +1 -1
- package/packages/mcp-server/dist/cli-runner.d.ts +40 -0
- package/packages/mcp-server/dist/cli-runner.d.ts.map +1 -0
- package/packages/mcp-server/dist/cli-runner.js +170 -0
- package/packages/mcp-server/dist/cli-runner.js.map +1 -0
- package/packages/mcp-server/dist/cli.d.ts +1 -0
- package/packages/mcp-server/dist/cli.d.ts.map +1 -1
- package/packages/mcp-server/dist/cli.js +3 -50
- package/packages/mcp-server/dist/cli.js.map +1 -1
- package/packages/mcp-server/dist/moonshot-tool-schema.d.ts +29 -0
- package/packages/mcp-server/dist/moonshot-tool-schema.d.ts.map +1 -0
- package/packages/mcp-server/dist/moonshot-tool-schema.js +50 -0
- package/packages/mcp-server/dist/moonshot-tool-schema.js.map +1 -0
- package/packages/mcp-server/dist/pid-registry.d.ts +46 -0
- package/packages/mcp-server/dist/pid-registry.d.ts.map +1 -0
- package/packages/mcp-server/dist/pid-registry.js +459 -0
- package/packages/mcp-server/dist/pid-registry.js.map +1 -0
- package/packages/mcp-server/dist/probe-mode.d.ts +4 -0
- package/packages/mcp-server/dist/probe-mode.d.ts.map +1 -0
- package/packages/mcp-server/dist/probe-mode.js +10 -0
- package/packages/mcp-server/dist/probe-mode.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +40 -1
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +97 -6
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/stdio-watchdog.d.ts +8 -0
- package/packages/mcp-server/dist/stdio-watchdog.d.ts.map +1 -0
- package/packages/mcp-server/dist/stdio-watchdog.js +40 -0
- package/packages/mcp-server/dist/stdio-watchdog.js.map +1 -0
- package/packages/mcp-server/dist/workflow-tools.d.ts +62 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +243 -123
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +21 -4
- package/packages/native/package.json +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +52 -2
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/harness/env/nodejs.d.ts +1 -0
- package/packages/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/harness/env/nodejs.js +34 -3
- package/packages/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
- package/packages/pi-agent-core/dist/index.d.ts +1 -0
- package/packages/pi-agent-core/dist/index.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/index.js +3 -0
- package/packages/pi-agent-core/dist/index.js.map +1 -1
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-ai/README.md +1 -0
- package/packages/pi-ai/dist/index.d.ts +2 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +2 -0
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/models.generated.d.ts +183 -76
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.js +205 -124
- package/packages/pi-ai/dist/models.generated.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +12 -7
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.d.ts +5 -0
- package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js +12 -3
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +7 -3
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.d.ts +9 -0
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.js +34 -0
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +6 -2
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
- package/packages/pi-ai/package.json +3 -2
- package/packages/pi-coding-agent/README.md +3 -2
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +2 -2
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.js +19 -13
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/capability-patches.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/capability-patches.js +3 -1
- package/packages/pi-coding-agent/dist/core/capability-patches.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/extension-upstream-types.d.ts +28 -2
- package/packages/pi-coding-agent/dist/core/extensions/extension-upstream-types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/extension-upstream-types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +5 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +3 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/provider-readiness.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/provider-readiness.js +13 -6
- package/packages/pi-coding-agent/dist/core/provider-readiness.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager-context.d.ts +9 -0
- package/packages/pi-coding-agent/dist/core/session-manager-context.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager-context.js +94 -0
- package/packages/pi-coding-agent/dist/core/session-manager-context.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager-list.d.ts +8 -0
- package/packages/pi-coding-agent/dist/core/session-manager-list.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager-list.js +244 -0
- package/packages/pi-coding-agent/dist/core/session-manager-list.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager-migration.d.ts +12 -0
- package/packages/pi-coding-agent/dist/core/session-manager-migration.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager-migration.js +84 -0
- package/packages/pi-coding-agent/dist/core/session-manager-migration.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager-types.d.ts +135 -0
- package/packages/pi-coding-agent/dist/core/session-manager-types.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager-types.js +2 -0
- package/packages/pi-coding-agent/dist/core/session-manager-types.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +6 -154
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +22 -459
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +3 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +11 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +11 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.js +53 -11
- package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts +2 -2
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/theme/theme-schema.d.ts +75 -75
- package/packages/pi-coding-agent/dist/theme/theme-schema.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/theme/theme-schema.js +1 -1
- package/packages/pi-coding-agent/dist/theme/theme-schema.js.map +1 -1
- package/packages/pi-coding-agent/dist/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/theme/theme.js +56 -24
- package/packages/pi-coding-agent/dist/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/shell.d.ts +28 -2
- package/packages/pi-coding-agent/dist/utils/shell.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/shell.js +56 -10
- package/packages/pi-coding-agent/dist/utils/shell.js.map +1 -1
- package/packages/pi-coding-agent/package.json +8 -8
- package/packages/pi-tui/README.md +15 -0
- package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -1
- package/packages/pi-tui/dist/autocomplete.js +6 -1
- package/packages/pi-tui/dist/autocomplete.js.map +1 -1
- package/packages/pi-tui/dist/components/input.js +2 -2
- package/packages/pi-tui/dist/components/input.js.map +1 -1
- package/packages/pi-tui/dist/components/loader.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/loader.js +1 -0
- package/packages/pi-tui/dist/components/loader.js.map +1 -1
- package/packages/pi-tui/dist/components/select-list.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/select-list.js +8 -2
- package/packages/pi-tui/dist/components/select-list.js.map +1 -1
- package/packages/pi-tui/dist/index.d.ts +2 -2
- package/packages/pi-tui/dist/index.d.ts.map +1 -1
- package/packages/pi-tui/dist/index.js +2 -2
- package/packages/pi-tui/dist/index.js.map +1 -1
- package/packages/pi-tui/dist/keys.d.ts.map +1 -1
- package/packages/pi-tui/dist/keys.js +39 -30
- package/packages/pi-tui/dist/keys.js.map +1 -1
- package/packages/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
- package/packages/pi-tui/dist/stdin-buffer.js +22 -0
- package/packages/pi-tui/dist/stdin-buffer.js.map +1 -1
- package/packages/pi-tui/dist/terminal-image.d.ts +33 -0
- package/packages/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/packages/pi-tui/dist/terminal-image.js +54 -2
- package/packages/pi-tui/dist/terminal-image.js.map +1 -1
- package/packages/pi-tui/dist/terminal.d.ts +12 -0
- package/packages/pi-tui/dist/terminal.d.ts.map +1 -1
- package/packages/pi-tui/dist/terminal.js +70 -25
- package/packages/pi-tui/dist/terminal.js.map +1 -1
- package/packages/pi-tui/dist/tui.d.ts +15 -0
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +115 -21
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/dist/utils.d.ts.map +1 -1
- package/packages/pi-tui/dist/utils.js +110 -36
- package/packages/pi-tui/dist/utils.js.map +1 -1
- package/packages/pi-tui/package.json +2 -2
- package/packages/rpc-client/package.json +2 -2
- package/pkg/dist/theme/theme-schema.d.ts +75 -75
- package/pkg/dist/theme/theme-schema.d.ts.map +1 -1
- package/pkg/dist/theme/theme-schema.js +1 -1
- package/pkg/dist/theme/theme-schema.js.map +1 -1
- package/pkg/dist/theme/theme.d.ts.map +1 -1
- package/pkg/dist/theme/theme.js +56 -24
- package/pkg/dist/theme/theme.js.map +1 -1
- package/pkg/package.json +1 -1
- package/scripts/install/deps.js +10 -0
- package/scripts/link-workspace-packages.cjs +7 -40
- package/src/resources/GSD-WORKFLOW.md +27 -26
- package/src/resources/extensions/ask-user-questions.ts +94 -26
- package/src/resources/extensions/async-jobs/async-bash-cancel.test.ts +360 -0
- package/src/resources/extensions/async-jobs/async-bash-tool.ts +33 -56
- package/src/resources/extensions/async-jobs/await-tool.test.ts +139 -0
- package/src/resources/extensions/async-jobs/await-tool.ts +82 -12
- package/src/resources/extensions/async-jobs/index.ts +79 -0
- package/src/resources/extensions/async-jobs/job-manager.ts +21 -1
- package/src/resources/extensions/bg-shell/bg-shell-command.ts +6 -6
- package/src/resources/extensions/bg-shell/bg-shell-tool.ts +10 -6
- package/src/resources/extensions/bg-shell/overlay.ts +9 -5
- package/src/resources/extensions/bg-shell/process-manager.ts +50 -25
- package/src/resources/extensions/bg-shell/readiness-detector.ts +12 -0
- package/src/resources/extensions/bg-shell/tests/lifecycle-and-utilities.test.ts +48 -1
- package/src/resources/extensions/bg-shell/utilities.ts +5 -2
- package/src/resources/extensions/browser-tools/engine/managed-gsd-browser.ts +265 -98
- package/src/resources/extensions/browser-tools/engine/selection.ts +90 -4
- package/src/resources/extensions/browser-tools/index.ts +71 -13
- package/src/resources/extensions/browser-tools/tests/browser-engine-selection.test.mjs +83 -13
- package/src/resources/extensions/browser-tools/tests/gsd-browser-launch-config.test.mjs +120 -1
- package/src/resources/extensions/browser-tools/tests/managed-gsd-browser-tools.test.mjs +136 -0
- package/src/resources/extensions/claude-code-cli/index.ts +8 -1
- package/src/resources/extensions/claude-code-cli/models.ts +9 -0
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +744 -495
- package/src/resources/extensions/claude-code-cli/tests/index.test.ts +47 -0
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +1192 -7
- package/src/resources/extensions/claude-code-cli/turn-assembler.ts +324 -0
- package/src/resources/extensions/github-sync/templates.ts +3 -3
- package/src/resources/extensions/github-sync/tests/templates.test.ts +2 -2
- package/src/resources/extensions/google-cli/stream-adapter.ts +128 -20
- package/src/resources/extensions/gsd/artifact-projection.ts +31 -0
- package/src/resources/extensions/gsd/artifact-verification.ts +464 -0
- package/src/resources/extensions/gsd/auto/closeout.ts +309 -0
- package/src/resources/extensions/gsd/auto/contracts.ts +32 -2
- package/src/resources/extensions/gsd/auto/custom-verify-retry-store.ts +21 -3
- package/src/resources/extensions/gsd/auto/detect-stuck.ts +32 -9
- package/src/resources/extensions/gsd/auto/dispatch-history.ts +186 -0
- package/src/resources/extensions/gsd/auto/dispatch-key.ts +39 -0
- package/src/resources/extensions/gsd/auto/dispatch.ts +449 -0
- package/src/resources/extensions/gsd/auto/finalize.ts +445 -0
- package/src/resources/extensions/gsd/auto/loop-deps.ts +3 -1
- package/src/resources/extensions/gsd/auto/loop.ts +158 -63
- package/src/resources/extensions/gsd/auto/milestone-lease-reclaim.ts +74 -0
- package/src/resources/extensions/gsd/auto/orchestrator.ts +418 -82
- package/src/resources/extensions/gsd/auto/phase-helpers.ts +199 -0
- package/src/resources/extensions/gsd/auto/phases.ts +58 -2981
- package/src/resources/extensions/gsd/auto/pre-dispatch.ts +716 -0
- package/src/resources/extensions/gsd/auto/run-unit.ts +2 -1
- package/src/resources/extensions/gsd/auto/session.ts +12 -0
- package/src/resources/extensions/gsd/auto/unit-phase.ts +910 -0
- package/src/resources/extensions/gsd/auto/workflow-kernel.ts +25 -3
- package/src/resources/extensions/gsd/auto/workflow-unit-dispatch.ts +1 -1
- package/src/resources/extensions/gsd/auto/worktree-safety-phase.ts +149 -0
- package/src/resources/extensions/gsd/auto-artifact-paths.ts +129 -20
- package/src/resources/extensions/gsd/auto-closeout-messaging.ts +90 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +328 -458
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +33 -50
- package/src/resources/extensions/gsd/auto-dispatch.ts +147 -104
- package/src/resources/extensions/gsd/auto-model-selection.ts +74 -15
- package/src/resources/extensions/gsd/auto-post-unit.ts +107 -46
- package/src/resources/extensions/gsd/auto-prompts.ts +298 -76
- package/src/resources/extensions/gsd/auto-recovery.ts +80 -489
- package/src/resources/extensions/gsd/auto-runtime-state.ts +38 -0
- package/src/resources/extensions/gsd/auto-start.ts +146 -88
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +3 -2
- package/src/resources/extensions/gsd/auto-timers.ts +16 -2
- package/src/resources/extensions/gsd/auto-tool-tracking.ts +54 -0
- package/src/resources/extensions/gsd/auto-unit-closeout.ts +83 -28
- package/src/resources/extensions/gsd/auto-unit-tool-scope.ts +21 -49
- package/src/resources/extensions/gsd/auto-verification.ts +37 -42
- package/src/resources/extensions/gsd/auto-worktree-repair.ts +13 -2
- package/src/resources/extensions/gsd/auto-worktree.ts +180 -407
- package/src/resources/extensions/gsd/auto.ts +220 -54
- package/src/resources/extensions/gsd/blocked-models.ts +49 -0
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +194 -70
- package/src/resources/extensions/gsd/bootstrap/core-session-tools.ts +43 -0
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +35 -38
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +93 -49
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +4 -2
- package/src/resources/extensions/gsd/bootstrap/fallback-continuation.ts +31 -0
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +2 -2
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +46 -1
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +506 -202
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +219 -46
- package/src/resources/extensions/gsd/bootstrap/tool-call-loop-guard.ts +74 -10
- package/src/resources/extensions/gsd/bootstrap/tool-search-shim.ts +21 -3
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +586 -83
- package/src/resources/extensions/gsd/branch-patterns.ts +3 -0
- package/src/resources/extensions/gsd/browser-daemon-auto-prep.ts +108 -0
- package/src/resources/extensions/gsd/browser-evidence.ts +18 -2
- package/src/resources/extensions/gsd/captures.ts +5 -16
- package/src/resources/extensions/gsd/closeout-consistency-gate.ts +132 -6
- package/src/resources/extensions/gsd/closeout-recovery.ts +2 -1
- package/src/resources/extensions/gsd/closeout-wizard.ts +111 -0
- package/src/resources/extensions/gsd/codebase-generator.ts +1 -0
- package/src/resources/extensions/gsd/commands/catalog.ts +12 -68
- package/src/resources/extensions/gsd/commands/context.ts +16 -2
- package/src/resources/extensions/gsd/commands/dispatcher.ts +3 -0
- package/src/resources/extensions/gsd/commands/gsd-core-aliases-handler.ts +48 -0
- package/src/resources/extensions/gsd/commands/gsd-core-aliases.ts +63 -0
- package/src/resources/extensions/gsd/commands/handlers/auto.ts +3 -0
- package/src/resources/extensions/gsd/commands/handlers/core.ts +58 -8
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +230 -3
- package/src/resources/extensions/gsd/commands-cmux.ts +3 -0
- package/src/resources/extensions/gsd/commands-context.ts +18 -1
- package/src/resources/extensions/gsd/commands-gsd-core.ts +1142 -0
- package/src/resources/extensions/gsd/commands-handlers.ts +140 -4
- package/src/resources/extensions/gsd/commands-inspect.ts +7 -8
- package/src/resources/extensions/gsd/commands-maintenance.ts +172 -42
- package/src/resources/extensions/gsd/commands-mcp-status.ts +2 -2
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +27 -9
- package/src/resources/extensions/gsd/commands-ship.ts +2 -2
- package/src/resources/extensions/gsd/commands-verdict.ts +22 -4
- package/src/resources/extensions/gsd/commands-workflow-templates.ts +11 -4
- package/src/resources/extensions/gsd/commands-worktree.ts +12 -10
- package/src/resources/extensions/gsd/compat/compat-marker.ts +210 -0
- package/src/resources/extensions/gsd/compat/index.ts +12 -0
- package/src/resources/extensions/gsd/compat/planning-compat.ts +168 -0
- package/src/resources/extensions/gsd/config-overlay.ts +24 -9
- package/src/resources/extensions/gsd/consent-question.ts +441 -0
- package/src/resources/extensions/gsd/consent-verdict.ts +115 -0
- package/src/resources/extensions/gsd/constants.ts +0 -3
- package/src/resources/extensions/gsd/crash-recovery.ts +13 -11
- package/src/resources/extensions/gsd/dashboard-overlay.ts +73 -7
- package/src/resources/extensions/gsd/db/engine.ts +855 -0
- package/src/resources/extensions/gsd/db/queries.ts +676 -0
- package/src/resources/extensions/gsd/db/sql-constants.ts +12 -0
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +24 -0
- package/src/resources/extensions/gsd/db/writers/cascades.ts +237 -0
- package/src/resources/extensions/gsd/db/writers/import-restore.ts +310 -0
- package/src/resources/extensions/gsd/db/writers/memory.ts +220 -0
- package/src/resources/extensions/gsd/db/writers/reconcile.ts +523 -0
- package/src/resources/extensions/gsd/db/writers/status.ts +88 -0
- package/src/resources/extensions/gsd/db-migration-backup.ts +56 -7
- package/src/resources/extensions/gsd/db-transaction.ts +37 -20
- package/src/resources/extensions/gsd/db-workspace.ts +243 -0
- package/src/resources/extensions/gsd/db-writer.ts +11 -19
- package/src/resources/extensions/gsd/delegation-policy.ts +3 -11
- package/src/resources/extensions/gsd/discussion-handoff.ts +280 -0
- package/src/resources/extensions/gsd/dispatch-guard.ts +8 -31
- package/src/resources/extensions/gsd/docs/preferences-reference.md +9 -0
- package/src/resources/extensions/gsd/doctor-engine-checks.ts +5 -4
- package/src/resources/extensions/gsd/doctor-environment.ts +272 -155
- package/src/resources/extensions/gsd/doctor-format.ts +12 -7
- package/src/resources/extensions/gsd/doctor-git-checks.ts +33 -25
- package/src/resources/extensions/gsd/doctor-providers.ts +104 -10
- package/src/resources/extensions/gsd/doctor-runtime-checks.ts +34 -42
- package/src/resources/extensions/gsd/doctor-types.ts +1 -0
- package/src/resources/extensions/gsd/doctor.ts +45 -12
- package/src/resources/extensions/gsd/engine-hook-contract.ts +79 -0
- package/src/resources/extensions/gsd/error-classifier.ts +25 -1
- package/src/resources/extensions/gsd/escalation.ts +9 -4
- package/src/resources/extensions/gsd/exec-sandbox.ts +98 -18
- package/src/resources/extensions/gsd/export-html.ts +11 -4
- package/src/resources/extensions/gsd/export.ts +88 -1
- package/src/resources/extensions/gsd/file-lock.ts +1 -1
- package/src/resources/extensions/gsd/files.ts +33 -12
- package/src/resources/extensions/gsd/flat-phase-migration.ts +205 -0
- package/src/resources/extensions/gsd/forensics.ts +4 -34
- package/src/resources/extensions/gsd/git-conflict-state.ts +17 -1
- package/src/resources/extensions/gsd/git-constants.ts +1 -1
- package/src/resources/extensions/gsd/git-service.ts +13 -7
- package/src/resources/extensions/gsd/gitignore.ts +10 -3
- package/src/resources/extensions/gsd/gsd-command-home.ts +13 -3
- package/src/resources/extensions/gsd/gsd-db.ts +189 -2380
- package/src/resources/extensions/gsd/guidance.ts +217 -0
- package/src/resources/extensions/gsd/guided-flow-queue.ts +89 -4
- package/src/resources/extensions/gsd/guided-flow.ts +250 -590
- package/src/resources/extensions/gsd/guided-unit-completion.ts +275 -0
- package/src/resources/extensions/gsd/health-widget.ts +133 -32
- package/src/resources/extensions/gsd/layout-policy.ts +86 -0
- package/src/resources/extensions/gsd/markdown-renderer.ts +422 -113
- package/src/resources/extensions/gsd/mcp-bridge.ts +39 -0
- package/src/resources/extensions/gsd/mcp-filter.ts +63 -34
- package/src/resources/extensions/gsd/mcp-tool-name.ts +30 -0
- package/src/resources/extensions/gsd/md-importer.ts +218 -68
- package/src/resources/extensions/gsd/memory-consolidation-scanner.ts +52 -20
- package/src/resources/extensions/gsd/memory-relations.ts +1 -1
- package/src/resources/extensions/gsd/metrics.ts +23 -10
- package/src/resources/extensions/gsd/migrate/layout-detect.ts +38 -0
- package/src/resources/extensions/gsd/migrate/planning-writer.ts +259 -0
- package/src/resources/extensions/gsd/migrate/safety.ts +20 -9
- package/src/resources/extensions/gsd/migrate-external.ts +49 -6
- package/src/resources/extensions/gsd/migration-auto-check.ts +57 -18
- package/src/resources/extensions/gsd/milestone-actions.ts +5 -2
- package/src/resources/extensions/gsd/milestone-closeout-proof.ts +131 -0
- package/src/resources/extensions/gsd/milestone-closeout.ts +133 -29
- package/src/resources/extensions/gsd/milestone-ids.ts +78 -19
- package/src/resources/extensions/gsd/milestone-implementation-evidence.ts +35 -21
- package/src/resources/extensions/gsd/milestone-merge-transaction.ts +47 -0
- package/src/resources/extensions/gsd/milestone-planning-persistence.ts +232 -0
- package/src/resources/extensions/gsd/milestone-readiness.ts +125 -0
- package/src/resources/extensions/gsd/milestone-reopen-events.ts +3 -6
- package/src/resources/extensions/gsd/milestone-settlement.ts +81 -0
- package/src/resources/extensions/gsd/milestone-validation-evidence.ts +95 -0
- package/src/resources/extensions/gsd/milestone-validation-verdict.ts +78 -0
- package/src/resources/extensions/gsd/model-cost-table.ts +1 -0
- package/src/resources/extensions/gsd/model-router.ts +101 -18
- package/src/resources/extensions/gsd/native-git-bridge.ts +39 -0
- package/src/resources/extensions/gsd/notification-store.ts +43 -31
- package/src/resources/extensions/gsd/notifications.ts +50 -12
- package/src/resources/extensions/gsd/observability-validator.ts +12 -4
- package/src/resources/extensions/gsd/parallel-eligibility.ts +4 -5
- package/src/resources/extensions/gsd/parallel-merge.ts +12 -9
- package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +161 -38
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +6 -2
- package/src/resources/extensions/gsd/parsers-legacy.ts +58 -19
- package/src/resources/extensions/gsd/paths.ts +390 -61
- package/src/resources/extensions/gsd/planning-depth.ts +2 -1
- package/src/resources/extensions/gsd/post-execution-checks.ts +43 -3
- package/src/resources/extensions/gsd/pre-execution-checks.ts +109 -3
- package/src/resources/extensions/gsd/preferences-diagnostics.ts +98 -0
- package/src/resources/extensions/gsd/preferences-models.ts +58 -59
- package/src/resources/extensions/gsd/preferences-types.ts +16 -0
- package/src/resources/extensions/gsd/preferences.ts +372 -35
- package/src/resources/extensions/gsd/projection-flush.ts +20 -0
- package/src/resources/extensions/gsd/prompts/ai-integration-phase.md +28 -0
- package/src/resources/extensions/gsd/prompts/audit-fix.md +39 -0
- package/src/resources/extensions/gsd/prompts/audit-milestone.md +26 -0
- package/src/resources/extensions/gsd/prompts/audit-uat.md +24 -0
- package/src/resources/extensions/gsd/prompts/autonomous.md +31 -0
- package/src/resources/extensions/gsd/prompts/code-review.md +39 -0
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +8 -2
- package/src/resources/extensions/gsd/prompts/complete-slice.md +25 -15
- package/src/resources/extensions/gsd/prompts/discuss-phase.md +31 -0
- package/src/resources/extensions/gsd/prompts/docs-update.md +13 -0
- package/src/resources/extensions/gsd/prompts/execute-phase.md +33 -0
- package/src/resources/extensions/gsd/prompts/execute-task.md +9 -2
- package/src/resources/extensions/gsd/prompts/explore.md +58 -0
- package/src/resources/extensions/gsd/prompts/graphify.md +27 -0
- package/src/resources/extensions/gsd/prompts/guided-discuss-project.md +3 -1
- package/src/resources/extensions/gsd/prompts/health.md +37 -0
- package/src/resources/extensions/gsd/prompts/import.md +30 -0
- package/src/resources/extensions/gsd/prompts/inbox.md +27 -0
- package/src/resources/extensions/gsd/prompts/ingest-docs.md +30 -0
- package/src/resources/extensions/gsd/prompts/manager.md +21 -0
- package/src/resources/extensions/gsd/prompts/map-codebase.md +42 -0
- package/src/resources/extensions/gsd/prompts/milestone-summary.md +27 -0
- package/src/resources/extensions/gsd/prompts/mvp-phase.md +23 -0
- package/src/resources/extensions/gsd/prompts/pause-work.md +24 -0
- package/src/resources/extensions/gsd/prompts/phase.md +22 -0
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
- package/src/resources/extensions/gsd/prompts/plan-phase.md +34 -0
- package/src/resources/extensions/gsd/prompts/plan-review-convergence.md +34 -0
- package/src/resources/extensions/gsd/prompts/plan-slice.md +3 -2
- package/src/resources/extensions/gsd/prompts/profile-user.md +28 -0
- package/src/resources/extensions/gsd/prompts/progress.md +30 -0
- package/src/resources/extensions/gsd/prompts/quick-task.md +1 -1
- package/src/resources/extensions/gsd/prompts/reactive-execute.md +2 -2
- package/src/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
- package/src/resources/extensions/gsd/prompts/refine-slice.md +3 -2
- package/src/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/src/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/resume-work.md +20 -0
- package/src/resources/extensions/gsd/prompts/review-backlog.md +21 -0
- package/src/resources/extensions/gsd/prompts/review.md +27 -0
- package/src/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
- package/src/resources/extensions/gsd/prompts/run-uat.md +13 -5
- package/src/resources/extensions/gsd/prompts/secure-phase.md +24 -0
- package/src/resources/extensions/gsd/prompts/settings.md +24 -0
- package/src/resources/extensions/gsd/prompts/sketch.md +59 -0
- package/src/resources/extensions/gsd/prompts/spec-phase.md +29 -0
- package/src/resources/extensions/gsd/prompts/spike.md +59 -0
- package/src/resources/extensions/gsd/prompts/stats.md +43 -0
- package/src/resources/extensions/gsd/prompts/surface.md +25 -0
- package/src/resources/extensions/gsd/prompts/system.md +6 -3
- package/src/resources/extensions/gsd/prompts/thread.md +24 -0
- package/src/resources/extensions/gsd/prompts/triage-captures.md +1 -1
- package/src/resources/extensions/gsd/prompts/ui-phase.md +29 -0
- package/src/resources/extensions/gsd/prompts/ui-review.md +29 -0
- package/src/resources/extensions/gsd/prompts/ultraplan-phase.md +24 -0
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/validate-phase.md +26 -0
- package/src/resources/extensions/gsd/prompts/verify-work.md +24 -0
- package/src/resources/extensions/gsd/prompts/workflow-start.md +2 -1
- package/src/resources/extensions/gsd/prompts/workspace.md +22 -0
- package/src/resources/extensions/gsd/prompts/workstreams.md +24 -0
- package/src/resources/extensions/gsd/provider-error-guidance.ts +36 -9
- package/src/resources/extensions/gsd/provider-payload-policy.ts +140 -0
- package/src/resources/extensions/gsd/provider-switch-observer.ts +1 -1
- package/src/resources/extensions/gsd/publication.ts +122 -0
- package/src/resources/extensions/gsd/pull-request-process.ts +41 -0
- package/src/resources/extensions/gsd/quality-gate-closure.ts +140 -0
- package/src/resources/extensions/gsd/question-transport.ts +138 -0
- package/src/resources/extensions/gsd/queue-order.ts +3 -2
- package/src/resources/extensions/gsd/quick.ts +43 -2
- package/src/resources/extensions/gsd/reactive-graph.ts +11 -1
- package/src/resources/extensions/gsd/recovery-classification.ts +54 -88
- package/src/resources/extensions/gsd/roadmap-slices.ts +37 -6
- package/src/resources/extensions/gsd/safety/content-validator.ts +2 -1
- package/src/resources/extensions/gsd/safety/destructive-confirmation.ts +134 -0
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +36 -4
- package/src/resources/extensions/gsd/safety/evidence-cross-ref.ts +52 -3
- package/src/resources/extensions/gsd/safety/file-change-validator.ts +14 -0
- package/src/resources/extensions/gsd/service-tier.ts +2 -0
- package/src/resources/extensions/gsd/session-forensics.ts +11 -1
- package/src/resources/extensions/gsd/session-lock.ts +16 -14
- package/src/resources/extensions/gsd/skill-activation.ts +3 -6
- package/src/resources/extensions/gsd/skills/gsd-headless/SKILL.md +3 -0
- package/src/resources/extensions/gsd/skills/gsd-headless/references/commands.md +51 -0
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +6 -2
- package/src/resources/extensions/gsd/state/derive/cache.ts +46 -0
- package/src/resources/extensions/gsd/state/derive/db-open.ts +45 -0
- package/src/resources/extensions/gsd/state/derive/from-db.ts +561 -0
- package/src/resources/extensions/gsd/state/derive/index.ts +104 -0
- package/src/resources/extensions/gsd/state/derive/interrupted-work.ts +31 -0
- package/src/resources/extensions/gsd/state-reconciliation/drift/artifact-db.ts +58 -14
- package/src/resources/extensions/gsd/state-reconciliation/drift/completion.ts +22 -2
- package/src/resources/extensions/gsd/state-reconciliation/drift/external-markdown-edit.ts +105 -0
- package/src/resources/extensions/gsd/state-reconciliation/drift/external-planning-edit.ts +180 -0
- package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +19 -6
- package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +2 -2
- package/src/resources/extensions/gsd/state-reconciliation/drift/stale-render.ts +176 -30
- package/src/resources/extensions/gsd/state-reconciliation/index.ts +86 -27
- package/src/resources/extensions/gsd/state-reconciliation/registry.ts +45 -18
- package/src/resources/extensions/gsd/state-reconciliation/types.ts +19 -0
- package/src/resources/extensions/gsd/state-transition-matrix.ts +42 -0
- package/src/resources/extensions/gsd/state.ts +51 -705
- package/src/resources/extensions/gsd/status-guards.ts +59 -8
- package/src/resources/extensions/gsd/stop-notice.ts +75 -0
- package/src/resources/extensions/gsd/sync-lock.ts +11 -20
- package/src/resources/extensions/gsd/templates/plan.md +7 -0
- package/src/resources/extensions/gsd/templates/project.md +1 -0
- package/src/resources/extensions/gsd/templates/roadmap.md +1 -1
- package/src/resources/extensions/gsd/templates/uat.md +5 -1
- package/src/resources/extensions/gsd/tests/__fixtures__/flat-phase/.gsd/phases/01-foundation/01-01-PLAN.md +13 -0
- package/src/resources/extensions/gsd/tests/__fixtures__/flat-phase/.gsd/phases/01-foundation/01-ROADMAP.md +8 -0
- package/src/resources/extensions/gsd/tests/__fixtures__/round-trip/m001-basic/.gsd/milestones/M001/M001-ROADMAP.md +13 -0
- package/src/resources/extensions/gsd/tests/__fixtures__/round-trip/m001-basic/.gsd/milestones/M001/slices/S01/S01-PLAN.md +5 -0
- package/src/resources/extensions/gsd/tests/__fixtures__/round-trip/planning-flat-phases/.planning/PROJECT.md +1 -0
- package/src/resources/extensions/gsd/tests/__fixtures__/round-trip/planning-flat-phases/.planning/ROADMAP.md +5 -0
- package/src/resources/extensions/gsd/tests/__fixtures__/round-trip/planning-flat-phases/.planning/STATE.md +10 -0
- package/src/resources/extensions/gsd/tests/__fixtures__/round-trip/planning-flat-phases/.planning/phases/01-foundation/01-01-PLAN.md +13 -0
- package/src/resources/extensions/gsd/tests/ask-user-questions-render.test.ts +92 -0
- package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-artifact-paths.test.ts +420 -2
- package/src/resources/extensions/gsd/tests/auto-blocked-remediation-message.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-closeout-messaging.test.ts +71 -0
- package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +97 -117
- package/src/resources/extensions/gsd/tests/auto-direct-dispatch-parse.test.ts +33 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +753 -26
- package/src/resources/extensions/gsd/tests/auto-migrating-recovery.test.ts +32 -1
- package/src/resources/extensions/gsd/tests/auto-milestone-target.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/auto-model-selection-tool-poisoning.test.ts +25 -2
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +107 -1
- package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +409 -38
- package/src/resources/extensions/gsd/tests/auto-pause-double-entry-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +11 -2
- package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +100 -5
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +2 -1
- package/src/resources/extensions/gsd/tests/auto-post-unit-evidence-crossref-4909.test.ts +46 -0
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +111 -1
- package/src/resources/extensions/gsd/tests/auto-remote-session-lock-cleanup.test.ts +65 -3
- package/src/resources/extensions/gsd/tests/auto-runtime-state.test.ts +34 -0
- package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +236 -0
- package/src/resources/extensions/gsd/tests/auto-unit-closeout.test.ts +169 -1
- package/src/resources/extensions/gsd/tests/auto-verification.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/auto-worktree-auto-resolve.test.ts +17 -0
- package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-worktree-repair.test.ts +4 -2
- package/src/resources/extensions/gsd/tests/blocked-models.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/blocker-placeholder-logs.test.ts +218 -0
- package/src/resources/extensions/gsd/tests/browser-automation-contract-fixture.ts +39 -0
- package/src/resources/extensions/gsd/tests/browser-contract.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/browser-daemon-auto-prep.test.ts +144 -0
- package/src/resources/extensions/gsd/tests/canonical-milestone-root.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/checkout-branch-stash-guard.test.ts +66 -1
- package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/codebase-generator.test.ts +26 -0
- package/src/resources/extensions/gsd/tests/commands-context.test.ts +26 -0
- package/src/resources/extensions/gsd/tests/commands-dispatcher-unmerged-milestone.test.ts +89 -0
- package/src/resources/extensions/gsd/tests/commands-dispatcher-validation-block.test.ts +37 -1
- package/src/resources/extensions/gsd/tests/commands-dispatcher-workspace-git.test.ts +11 -0
- package/src/resources/extensions/gsd/tests/commands-eval-review.test.ts +31 -30
- package/src/resources/extensions/gsd/tests/commands-gsd-core.test.ts +863 -0
- package/src/resources/extensions/gsd/tests/commands-verdict.test.ts +47 -9
- package/src/resources/extensions/gsd/tests/commands-worktree-clean.test.ts +80 -0
- package/src/resources/extensions/gsd/tests/compat-health-line.test.ts +102 -0
- package/src/resources/extensions/gsd/tests/compat-marker-invalidation.test.ts +51 -0
- package/src/resources/extensions/gsd/tests/compat-marker.test.ts +105 -0
- package/src/resources/extensions/gsd/tests/complete-milestone-prompt-rendering.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/complete-slice-reopen-handoff.test.ts +82 -0
- package/src/resources/extensions/gsd/tests/complete-slice-verification-gate.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +18 -7
- package/src/resources/extensions/gsd/tests/complete-task-rollback-evidence.test.ts +48 -8
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +223 -12
- package/src/resources/extensions/gsd/tests/consent-question.test.ts +396 -0
- package/src/resources/extensions/gsd/tests/core-overlay-fallback.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/custom-verify-retry-store.test.ts +67 -0
- package/src/resources/extensions/gsd/tests/dashboard-overlay.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/db-authority-regression.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/db-engine-logs.test.ts +207 -0
- package/src/resources/extensions/gsd/tests/db-migration-backup.test.ts +68 -19
- package/src/resources/extensions/gsd/tests/db-transaction.test.ts +59 -0
- package/src/resources/extensions/gsd/tests/db-writer.test.ts +15 -4
- package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +12 -11
- package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +63 -1
- package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +111 -5
- package/src/resources/extensions/gsd/tests/destructive-confirmation.test.ts +303 -0
- package/src/resources/extensions/gsd/tests/discuss-cold-start-db-open.test.ts +10 -27
- package/src/resources/extensions/gsd/tests/discuss-routing-fixes.test.ts +12 -2
- package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +54 -4
- package/src/resources/extensions/gsd/tests/dispatch-db-degradation-logs.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/dispatch-history.test.ts +430 -0
- package/src/resources/extensions/gsd/tests/dispatch-logs.test.ts +103 -0
- package/src/resources/extensions/gsd/tests/dispatch-missing-task-plans.test.ts +38 -49
- package/src/resources/extensions/gsd/tests/dispatch-reactive-logs.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +26 -1
- package/src/resources/extensions/gsd/tests/dispatch-run-uat-browser-tools.test.ts +89 -0
- package/src/resources/extensions/gsd/tests/dist-redirect.mjs +15 -0
- package/src/resources/extensions/gsd/tests/doctor-forensics-db-open-regression.test.ts +70 -2
- package/src/resources/extensions/gsd/tests/doctor-git-checks-autoresolve.test.ts +149 -0
- package/src/resources/extensions/gsd/tests/doctor-git-checks-terminal.test.ts +73 -0
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +113 -4
- package/src/resources/extensions/gsd/tests/doctor-scope-db-unavailable.test.ts +18 -0
- package/src/resources/extensions/gsd/tests/dynamic-bash-no-cap.test.ts +132 -0
- package/src/resources/extensions/gsd/tests/engine-hook-contract.test.ts +148 -0
- package/src/resources/extensions/gsd/tests/engine-interfaces-contract.test.ts +117 -91
- package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/ensure-preconditions-guard-4996.test.ts +17 -10
- package/src/resources/extensions/gsd/tests/evidence-cross-ref.test.ts +95 -0
- package/src/resources/extensions/gsd/tests/evidence-xref-gsd-exec.test.ts +157 -0
- package/src/resources/extensions/gsd/tests/exec-graceful-kill.test.ts +231 -0
- package/src/resources/extensions/gsd/tests/exec-tool.test.ts +74 -2
- package/src/resources/extensions/gsd/tests/execute-task-rendering.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +25 -0
- package/src/resources/extensions/gsd/tests/export-memory.test.ts +179 -0
- package/src/resources/extensions/gsd/tests/extension-bootstrap-isolation.test.ts +88 -1
- package/src/resources/extensions/gsd/tests/external-markdown-edit.test.ts +137 -0
- package/src/resources/extensions/gsd/tests/external-planning-edit.test.ts +199 -0
- package/src/resources/extensions/gsd/tests/fallback-continuation.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/file-change-validator.test.ts +33 -1
- package/src/resources/extensions/gsd/tests/file-lock.test.ts +43 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-no-blockers.md +1 -5
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-with-blockers.md +1 -5
- package/src/resources/extensions/gsd/tests/flat-phase-migration.test.ts +114 -0
- package/src/resources/extensions/gsd/tests/flat-phase-renderer.test.ts +83 -0
- package/src/resources/extensions/gsd/tests/flat-phase-round-trip.test.ts +72 -0
- package/src/resources/extensions/gsd/tests/flat-phase-validation-integration.test.ts +120 -0
- package/src/resources/extensions/gsd/tests/flat-phase-validation-path.test.ts +74 -0
- package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +2 -1
- package/src/resources/extensions/gsd/tests/forensics-error-filter.test.ts +88 -0
- package/src/resources/extensions/gsd/tests/gate-state-canonicalization.test.ts +48 -1
- package/src/resources/extensions/gsd/tests/gsd-command-home.test.ts +154 -1
- package/src/resources/extensions/gsd/tests/gsd-core-parity-routing.test.ts +183 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +46 -0
- package/src/resources/extensions/gsd/tests/guidance.test.ts +173 -0
- package/src/resources/extensions/gsd/tests/guided-discuss-milestone-prompt-rendering.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +18 -6
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +268 -3
- package/src/resources/extensions/gsd/tests/integration/auto-recovery.test.ts +19 -11
- package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +133 -15
- package/src/resources/extensions/gsd/tests/integration/auto-worktree.test.ts +89 -59
- package/src/resources/extensions/gsd/tests/integration/commands-eval-review.integration.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/integration/doctor-environment-async.test.ts +104 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +122 -3
- package/src/resources/extensions/gsd/tests/integration/gitignore-tracked-gsd.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/integration/gsd-integration-fixture.ts +80 -0
- package/src/resources/extensions/gsd/tests/integration/idle-recovery.test.ts +4 -3
- package/src/resources/extensions/gsd/tests/integration/integration-proof.test.ts +11 -7
- package/src/resources/extensions/gsd/tests/integration/merge-strategy-regular.test.ts +157 -0
- package/src/resources/extensions/gsd/tests/integration/queue-active-milestone-context-budget.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/integration/quick-branch-lifecycle.test.ts +56 -9
- package/src/resources/extensions/gsd/tests/integration/run-uat.test.ts +217 -0
- package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +47 -16
- package/src/resources/extensions/gsd/tests/knowledge-cold-start.test.ts +386 -0
- package/src/resources/extensions/gsd/tests/layout-policy.test.ts +59 -0
- package/src/resources/extensions/gsd/tests/loop.test.ts +60 -0
- package/src/resources/extensions/gsd/tests/markdown-renderer-parse-cache.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/markdown-renderer.test.ts +214 -82
- package/src/resources/extensions/gsd/tests/mcp-filter.test.ts +74 -1
- package/src/resources/extensions/gsd/tests/mcp-project-config.test.ts +3 -1
- package/src/resources/extensions/gsd/tests/mcp-readiness-preflight.test.ts +205 -0
- package/src/resources/extensions/gsd/tests/mcp-status.test.ts +6 -5
- package/src/resources/extensions/gsd/tests/mcp-tool-name.test.ts +34 -0
- package/src/resources/extensions/gsd/tests/memory-consolidation-scanner.test.ts +78 -0
- package/src/resources/extensions/gsd/tests/metrics-ledger-cap.test.ts +239 -0
- package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +213 -1
- package/src/resources/extensions/gsd/tests/milestone-closeout-proof.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/milestone-closeout.test.ts +125 -4
- package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/milestone-merge-transaction.test.ts +46 -0
- package/src/resources/extensions/gsd/tests/milestone-readiness.test.ts +65 -0
- package/src/resources/extensions/gsd/tests/milestone-report-path.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/milestone-settlement.test.ts +97 -0
- package/src/resources/extensions/gsd/tests/milestone-transition-state-rebuild.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/milestone-validation-evidence.test.ts +41 -0
- package/src/resources/extensions/gsd/tests/milestone-validation-verdict.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/model-router.test.ts +343 -7
- package/src/resources/extensions/gsd/tests/model-unittype-mapping.test.ts +32 -1
- package/src/resources/extensions/gsd/tests/native-merge-regular.test.ts +139 -0
- package/src/resources/extensions/gsd/tests/notification-store.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/notifications.test.ts +97 -9
- package/src/resources/extensions/gsd/tests/oauth-api-model-routing.test.ts +179 -0
- package/src/resources/extensions/gsd/tests/observability-validator-boundary.test.ts +194 -0
- package/src/resources/extensions/gsd/tests/orchestrator-legacy-parity.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/orchestrator-logs.test.ts +381 -0
- package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +52 -1
- package/src/resources/extensions/gsd/tests/parallel-monitor-overlay.test.ts +91 -0
- package/src/resources/extensions/gsd/tests/parallel-research-dispatch.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/parallel-skill-prompt-integration.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/parsers-legacy-importers.test.ts +144 -0
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/phases-terminal-complete-idempotent.test.ts +242 -0
- package/src/resources/extensions/gsd/tests/pipeline-variant-dispatch.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/plan-gate-failed-doctor-heal-hint.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/plan-milestone-boundary-map-preservation.test.ts +7 -2
- package/src/resources/extensions/gsd/tests/plan-milestone-sketch-render.test.ts +7 -2
- package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +54 -6
- package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/plan-slice.test.ts +58 -23
- package/src/resources/extensions/gsd/tests/plan-task.test.ts +4 -4
- package/src/resources/extensions/gsd/tests/planning-crossval.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/planning-layout-detect.test.ts +84 -0
- package/src/resources/extensions/gsd/tests/planning-marker.test.ts +107 -0
- package/src/resources/extensions/gsd/tests/planning-projection-hook.test.ts +123 -0
- package/src/resources/extensions/gsd/tests/planning-round-trip-property.test.ts +164 -0
- package/src/resources/extensions/gsd/tests/planning-writer.test.ts +82 -0
- package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +63 -2
- package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +48 -1
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +193 -1
- package/src/resources/extensions/gsd/tests/preferences-diagnostics.test.ts +67 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +230 -1
- package/src/resources/extensions/gsd/tests/prefs-missing-models-crash.test.ts +35 -4
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +54 -1
- package/src/resources/extensions/gsd/tests/progress-strip-test-helpers.ts +79 -0
- package/src/resources/extensions/gsd/tests/progressive-planning.test.ts +50 -14
- package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +72 -2
- package/src/resources/extensions/gsd/tests/prompt-db.test.ts +124 -6
- package/src/resources/extensions/gsd/tests/provider-error-guidance.test.ts +18 -3
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +312 -4
- package/src/resources/extensions/gsd/tests/provider-payload-policy.test.ts +165 -0
- package/src/resources/extensions/gsd/tests/publication.test.ts +120 -0
- package/src/resources/extensions/gsd/tests/pull-request-process.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/read-uat-gate-verdict.test.ts +185 -0
- package/src/resources/extensions/gsd/tests/ready-phrase-no-files-4573.test.ts +22 -13
- package/src/resources/extensions/gsd/tests/reassess-handler.test.ts +9 -8
- package/src/resources/extensions/gsd/tests/reconcile-logs.test.ts +244 -0
- package/src/resources/extensions/gsd/tests/recovery-classification-illegal-transition.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/recovery-finalize-logs.test.ts +119 -0
- package/src/resources/extensions/gsd/tests/recovery-verify-logs.test.ts +428 -0
- package/src/resources/extensions/gsd/tests/register-extension-guard.test.ts +25 -0
- package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +508 -5
- package/src/resources/extensions/gsd/tests/remote-notification-from-desktop.test.ts +31 -81
- package/src/resources/extensions/gsd/tests/replan-handler.test.ts +4 -4
- package/src/resources/extensions/gsd/tests/resume-missing-worktree-warning.test.ts +5 -5
- package/src/resources/extensions/gsd/tests/roadmap-parse-regression.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/roadmap-slices.test.ts +68 -0
- package/src/resources/extensions/gsd/tests/round-trip-property.test.ts +137 -0
- package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +58 -2
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/session-lock-transient-read.test.ts +28 -2
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +148 -0
- package/src/resources/extensions/gsd/tests/session-switch-clears-pending-autostart.test.ts +108 -0
- package/src/resources/extensions/gsd/tests/show-config-command.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/single-writer-invariant.test.ts +301 -41
- package/src/resources/extensions/gsd/tests/skill-activation.test.ts +20 -17
- package/src/resources/extensions/gsd/tests/stale-dirlistcache-4648.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/stale-queued-milestone.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +56 -0
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +9 -4
- package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +346 -58
- package/src/resources/extensions/gsd/tests/state-transition-matrix.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/status-guards.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/stop-auto-race-null-unit.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/stop-backtrack.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/stop-notice.test.ts +70 -0
- package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/sync-lock.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +29 -1
- package/src/resources/extensions/gsd/tests/teardown-chdir-failure-clears-registry.test.ts +17 -0
- package/src/resources/extensions/gsd/tests/terminal-tool-surface-classification.test.ts +80 -0
- package/src/resources/extensions/gsd/tests/thinking-level-resolution.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +80 -2
- package/src/resources/extensions/gsd/tests/tool-availability-audit.test.ts +35 -0
- package/src/resources/extensions/gsd/tests/tool-call-loop-guard.test.ts +151 -0
- package/src/resources/extensions/gsd/tests/tool-invocation-error-loop-break.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/tool-naming.test.ts +35 -42
- package/src/resources/extensions/gsd/tests/tool-param-optionality.test.ts +26 -0
- package/src/resources/extensions/gsd/tests/tool-schema-model-fallback.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/tool-search-shim.test.ts +71 -0
- package/src/resources/extensions/gsd/tests/tool-surface-readiness.test.ts +348 -0
- package/src/resources/extensions/gsd/tests/tool-unavailable-retry.test.ts +56 -0
- package/src/resources/extensions/gsd/tests/transport-gate-double-complete.test.ts +139 -0
- package/src/resources/extensions/gsd/tests/tui-header-lifecycle.test.ts +40 -86
- package/src/resources/extensions/gsd/tests/tui-render-kit.test.ts +44 -6
- package/src/resources/extensions/gsd/tests/uat-policy.test.ts +112 -6
- package/src/resources/extensions/gsd/tests/undo.test.ts +39 -37
- package/src/resources/extensions/gsd/tests/unit-closeout.test.ts +209 -0
- package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +319 -6
- package/src/resources/extensions/gsd/tests/unit-registry.test.ts +163 -0
- package/src/resources/extensions/gsd/tests/unmerged-milestone-guard.test.ts +87 -0
- package/src/resources/extensions/gsd/tests/uok-audit-unified.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/uok-audit.test.ts +194 -0
- package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +72 -1
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +9 -1
- package/src/resources/extensions/gsd/tests/validation-block-guard.test.ts +130 -0
- package/src/resources/extensions/gsd/tests/validation-gate-patterns.test.ts +34 -6
- package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/verify-artifact-tightened.test.ts +156 -0
- package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +87 -0
- package/src/resources/extensions/gsd/tests/visualizer-views.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/web-app-uat.test.ts +193 -0
- package/src/resources/extensions/gsd/tests/workflow-events.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/workflow-kernel.test.ts +51 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp-preflight.test.ts +133 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp-readiness-cache.test.ts +119 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +227 -21
- package/src/resources/extensions/gsd/tests/workflow-phase-contract-matrix.test.ts +332 -0
- package/src/resources/extensions/gsd/tests/workflow-projections.test.ts +3 -4
- package/src/resources/extensions/gsd/tests/workflow-reconcile.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/workflow-templates.test.ts +92 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +339 -48
- package/src/resources/extensions/gsd/tests/workspace-git-preflight.test.ts +166 -2
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/worktree-health.test.ts +43 -3
- package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +41 -4
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +144 -1
- package/src/resources/extensions/gsd/tests/worktree-placement.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/worktree-projection-writers.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/worktree-reentry.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/worktree-safety-phase.test.ts +100 -0
- package/src/resources/extensions/gsd/tests/worktree-safety.test.ts +114 -19
- package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +12 -6
- package/src/resources/extensions/gsd/tests/worktree-teardown-safety.test.ts +24 -2
- package/src/resources/extensions/gsd/tests/worktree-telemetry.test.ts +22 -0
- package/src/resources/extensions/gsd/tests/worktree-write-gate.test.ts +75 -3
- package/src/resources/extensions/gsd/tests/worktree.test.ts +18 -0
- package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +4 -1
- package/src/resources/extensions/gsd/tests/write-gate-seam.test.ts +358 -0
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +291 -1
- package/src/resources/extensions/gsd/tool-contract.ts +124 -11
- package/src/resources/extensions/gsd/tool-presentation-plan.ts +18 -35
- package/src/resources/extensions/gsd/tool-surface-readiness.ts +393 -0
- package/src/resources/extensions/gsd/tool-surface-snapshot.ts +47 -0
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +7 -9
- package/src/resources/extensions/gsd/tools/complete-slice.ts +57 -79
- package/src/resources/extensions/gsd/tools/complete-task.ts +153 -13
- package/src/resources/extensions/gsd/tools/exec-tool.ts +13 -124
- package/src/resources/extensions/gsd/tools/plan-milestone.ts +19 -160
- package/src/resources/extensions/gsd/tools/plan-slice.ts +13 -9
- package/src/resources/extensions/gsd/tools/plan-task.ts +19 -3
- package/src/resources/extensions/gsd/tools/reassess-roadmap.ts +54 -12
- package/src/resources/extensions/gsd/tools/reopen-milestone.ts +13 -40
- package/src/resources/extensions/gsd/tools/reopen-slice.ts +16 -44
- package/src/resources/extensions/gsd/tools/reopen-task.ts +2 -2
- package/src/resources/extensions/gsd/tools/replan-slice.ts +2 -2
- package/src/resources/extensions/gsd/tools/skip-slice.ts +18 -44
- package/src/resources/extensions/gsd/tools/validate-milestone.ts +26 -90
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +123 -5
- package/src/resources/extensions/gsd/triage-resolution.ts +14 -7
- package/src/resources/extensions/gsd/tui/render-kit.ts +56 -13
- package/src/resources/extensions/gsd/uat-policy.ts +80 -25
- package/src/resources/extensions/gsd/uat-run.ts +10 -14
- package/src/resources/extensions/gsd/undo.ts +17 -17
- package/src/resources/extensions/gsd/unit-closeout.ts +201 -0
- package/src/resources/extensions/gsd/unit-context-composer.ts +222 -21
- package/src/resources/extensions/gsd/unit-context-manifest.ts +4 -28
- package/src/resources/extensions/gsd/unit-registry.ts +494 -0
- package/src/resources/extensions/gsd/unit-runtime.ts +3 -2
- package/src/resources/extensions/gsd/unit-tool-contracts.ts +27 -191
- package/src/resources/extensions/gsd/unmerged-milestone-guard.ts +101 -6
- package/src/resources/extensions/gsd/validation-block-guard.ts +60 -6
- package/src/resources/extensions/gsd/verdict-parser.ts +1 -1
- package/src/resources/extensions/gsd/verification-verdict.ts +4 -2
- package/src/resources/extensions/gsd/visualizer-data.ts +55 -0
- package/src/resources/extensions/gsd/visualizer-views.ts +27 -2
- package/src/resources/extensions/gsd/web-app-uat.ts +144 -0
- package/src/resources/extensions/gsd/workflow-event-ledger.ts +131 -0
- package/src/resources/extensions/gsd/workflow-event-vocabulary.ts +59 -0
- package/src/resources/extensions/gsd/workflow-events.ts +12 -20
- package/src/resources/extensions/gsd/workflow-logger.ts +5 -0
- package/src/resources/extensions/gsd/workflow-mcp-auto-prep.ts +2 -0
- package/src/resources/extensions/gsd/workflow-mcp-readiness-cache.ts +150 -0
- package/src/resources/extensions/gsd/workflow-mcp.ts +34 -111
- package/src/resources/extensions/gsd/workflow-projections.ts +44 -18
- package/src/resources/extensions/gsd/workflow-reconcile.ts +32 -65
- package/src/resources/extensions/gsd/workflow-tool-surface.ts +76 -0
- package/src/resources/extensions/gsd/workspace-git-guard.ts +1 -0
- package/src/resources/extensions/gsd/workspace-git-preflight.ts +31 -0
- package/src/resources/extensions/gsd/worktree-command.ts +6 -6
- package/src/resources/extensions/gsd/worktree-git-recovery.ts +314 -0
- package/src/resources/extensions/gsd/worktree-health.ts +6 -3
- package/src/resources/extensions/gsd/worktree-lifecycle.ts +20 -25
- package/src/resources/extensions/gsd/worktree-manager.ts +215 -45
- package/src/resources/extensions/gsd/worktree-placement.ts +63 -0
- package/src/resources/extensions/gsd/worktree-reentry.ts +10 -7
- package/src/resources/extensions/gsd/worktree-root.ts +29 -6
- package/src/resources/extensions/gsd/worktree-safety.ts +73 -48
- package/src/resources/extensions/gsd/worktree-session-state.ts +11 -11
- package/src/resources/extensions/gsd/worktree-shell-guard.ts +123 -0
- package/src/resources/extensions/gsd/worktree-state-projection.ts +55 -7
- package/src/resources/extensions/gsd/worktree-telemetry.ts +16 -0
- package/src/resources/extensions/gsd/worktree.ts +7 -1
- package/src/resources/extensions/mcp-client/manager.ts +10 -4
- package/src/resources/extensions/search-the-web/index.ts +45 -9
- package/src/resources/extensions/search-the-web/native-search.ts +21 -7
- package/src/resources/extensions/shared/browser-contract.ts +66 -0
- package/src/resources/extensions/shared/gsd-browser-cli.ts +182 -8
- package/src/resources/extensions/shared/interview-ui.ts +15 -2
- package/src/resources/extensions/subagent/index.ts +20 -15
- package/src/resources/extensions/subagent/tests/worktree-cwd.test.ts +57 -0
- package/src/resources/extensions/subagent/worktree-cwd.ts +35 -0
- package/src/resources/shared/claude-runtime-floor.ts +248 -0
- package/src/resources/shared/gsd-browser-path-sync.ts +273 -0
- package/src/resources/shared/package-manager-detection.ts +1 -1
- package/src/resources/shared/package.json +3 -0
- package/src/resources/skills/create-skill/SKILL.md +3 -0
- package/src/resources/skills/create-skill/references/executable-code.md +1 -1
- package/src/resources/skills/create-skill/references/skill-structure.md +1 -0
- package/src/resources/skills/create-skill/workflows/add-reference.md +8 -3
- package/src/resources/skills/create-skill/workflows/add-script.md +4 -2
- package/src/resources/skills/create-skill/workflows/add-template.md +3 -1
- package/src/resources/skills/create-skill/workflows/add-workflow.md +8 -3
- package/src/resources/skills/create-skill/workflows/upgrade-to-router.md +10 -5
- package/src/resources/skills/create-skill/workflows/verify-skill.md +9 -4
- package/src/resources/skills/spike-wrap-up/SKILL.md +9 -9
- package/dist/resources/extensions/gsd/user-input-boundary.js +0 -195
- package/dist/resources/skills/gsd-browser/SKILL.md +0 -41
- package/dist/web/standalone/.next/server/chunks/5047.js +0 -2
- package/dist/web/standalone/.next/static/chunks/2659.feb6499ca863ebfc.js +0 -1
- package/dist/web/standalone/.next/static/chunks/2772.151789db0edea835.js +0 -1
- package/dist/web/standalone/.next/static/chunks/4283.10a065467b5340d8.js +0 -2
- package/dist/web/standalone/.next/static/chunks/5826.960dc4634cc9b0d3.js +0 -1
- package/dist/web/standalone/.next/static/chunks/796.46f811c0fac23aab.js +0 -10
- package/dist/web/standalone/.next/static/chunks/8785.d32f7a61f55c1600.js +0 -1
- package/dist/web/standalone/.next/static/chunks/app/_not-found/page-49f565245e1e4afe.js +0 -1
- package/dist/web/standalone/.next/static/chunks/app/page-a48b7c48333b31c8.js +0 -1
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ec3eaffc9785ba48.js +0 -1
- package/dist/web/standalone/.next/static/chunks/webpack-dda80a1ef5587410.js +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.d.ts +0 -21
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.d.ts.map +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.js +0 -213
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.js.map +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-density-prototype.d.ts +0 -28
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-density-prototype.d.ts.map +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-density-prototype.js +0 -249
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-density-prototype.js.map +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-design-prototype.d.ts +0 -19
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-design-prototype.d.ts.map +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-design-prototype.js +0 -797
- package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/transcript-design-prototype.js.map +0 -1
- package/scripts/ensure-workspace-builds.cjs +0 -129
- package/src/resources/extensions/gsd/tests/user-input-boundary.test.ts +0 -88
- package/src/resources/extensions/gsd/user-input-boundary.ts +0 -198
- package/src/resources/skills/gsd-browser/SKILL.md +0 -41
- /package/dist/web/standalone/.next/static/{TA5o9SHAnCdK6Umm1MYxb → O7xDYXO0r4zFhIzY1hrWV}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{TA5o9SHAnCdK6Umm1MYxb → O7xDYXO0r4zFhIzY1hrWV}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8937],{10313:(e,t,s)=>{s.d(t,{WT:()=>n,fl:()=>i,k8:()=>a});var r=s(61415);function a(e){window.dispatchEvent(new CustomEvent("gsd:navigate-view",{detail:{view:e}}))}function n({dispatch:e}){e().catch(e=>{console.error("[workflow-action] dispatch failed:",e)}),a("vibe-coder"===(0,r.B3)()?"chat":"power")}function i({commandInFlight:e,terminalLines:t}){if(!e)return null;for(let e=t.length-1;e>=0;e-=1){let s=t[e];if("input"!==s.type)continue;let r=s.content.trim();if(r)return r}return"prompt"===e?"Sending command":`/${e}`}},14156:(e,t,s)=>{s.d(t,{x:()=>C});var r=s(18870),a=s(45110),n=s(20559),i=s(66828),o=s(18366),l=s(92525),d=s(96526),c=s(52160),u=s(46518),m=s(18833),h=s(69745);let x=/Git Ship Done v\d+\.\d+\.\d+/i;function p(e,t){if(0===t)return 0;let s=0;for(let r=0;r<e.length;r+=1)if("\n"===e[r]&&(s+=1)===t)return r+1;return null}function g(e){return!e||0===e.trim().length}function f(e){return!!e&&/[█╔╗╚╝║═]/.test(e)}var b=s(40525),v=s(83890),j=s(81462);function y(e,t){if(!e||!t)return null;let s=e.getBoundingClientRect();return s.width<180||s.height<120||t.cols<20||t.rows<8?null:{cols:t.cols,rows:t.rows}}async function w(e,t,s,r){if("u">typeof document&&"fonts"in document)try{await Promise.race([document.fonts.ready,new Promise(e=>setTimeout(e,1e3))])}catch{}for(let a=0;a<12;a++){if(r()||(await new Promise(e=>{requestAnimationFrame(()=>e())}),r()))return null;try{s?.fit()}catch{}let a=y(e,t);if(a)return a;await new Promise(e=>setTimeout(e,50))}return y(e,t)}function N({sessionId:e,visible:t,command:n,commandArgs:o,isDark:l,fontSize:d,hideInitialGsdHeader:c=!1,projectCwd:u,onConnectionChange:h}){let y=(0,a.useRef)(null),S=(0,a.useRef)(null),k=(0,a.useRef)(null),C=(0,a.useRef)(null),A=(0,a.useRef)([]),T=(0,a.useRef)(!1),P=(0,a.useRef)(null),R=(0,a.useRef)(h),E=(0,a.useRef)(!c),_=(0,a.useRef)(""),F=(o??[]).join("\0"),[I,$]=(0,a.useState)(!1),D=(0,a.useCallback)((t,s)=>{P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{(0,v.tm)((0,b.$)("/api/terminal/resize",u),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,cols:t,rows:s})})},100)},[u,e]),L=(0,a.useCallback)(async()=>{if(!T.current){for(T.current=!0;A.current.length>0;){let t=A.current.shift();try{let s=await (0,v.tm)((0,b.$)("/api/terminal/input",u),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,data:t})});if(!s.ok){s.status>=500&&A.current.unshift(t),R.current(!1),S.current?.writeln(`\r
|
|
2
|
+
Input failed (${s.status}). Reconnect the terminal and retry.`);break}}catch{A.current.unshift(t),R.current(!1);break}}T.current=!1}},[u,e]),M=(0,a.useCallback)(e=>{A.current.push(e),L()},[L]);(0,a.useEffect)(()=>{R.current=h},[h]),(0,a.useEffect)(()=>{E.current=!c,_.current=""},[c,e]),(0,a.useEffect)(()=>{S.current&&(S.current.options.theme=(0,j.E)(l))},[l]),(0,a.useEffect)(()=>{if(S.current){S.current.options.fontSize=d??13;try{k.current?.fit(),S.current&&D(S.current.cols,S.current.rows)}catch{}}},[d,D]),(0,a.useEffect)(()=>{if(t&&k.current&&S.current){let e=setTimeout(()=>{try{k.current?.fit(),S.current&&D(S.current.cols,S.current.rows)}catch{}},50);return()=>clearTimeout(e)}},[t,D]),(0,a.useEffect)(()=>{if(!y.current)return;let t=!1,r=null,a=null,i=null;return(async()=>{let[{Terminal:m},{FitAddon:h}]=await Promise.all([s.e(7110).then(s.bind(s,30493)),s.e(5027).then(s.bind(s,5027))]);if(t||(r=new m((0,j.d)(l,d)),a=new h,r.loadAddon(a),r.open(y.current),S.current=r,k.current=a,await w(y.current,r,a,()=>t),t))return;r.onData(e=>M(e)),r.onBinary(e=>M(e));let N=(0,b.Y)("/api/terminal/stream",window.location.origin,u);for(let t of(N.searchParams.set("id",e),n&&N.searchParams.set("command",n),o??[]))N.searchParams.append("arg",t);let A=new EventSource((0,v.QT)(N.toString()));C.current=A,A.onmessage=e=>{try{let s=JSON.parse(e.data);if("connected"===s.type)R.current(!0),w(y.current,r,a,()=>t).then(e=>{e&&D(e.cols,e.rows)});else if("output"===s.type&&s.data){let e=s.data;if(c&&!E.current){_.current+=e;let t=function(e){let{plainText:t,rawOffsetsByPlainIndex:s}=function(e){let t="",s=[0];for(let r=0;r<e.length;){let a=e[r];if("\x1b"===a){let t=e[r+1];if("["===t){for(r+=2;r<e.length&&!/[A-~]/.test(e[r]);)r+=1;r<e.length&&(r+=1);continue}if("]"===t){for(r+=2;r<e.length;){if("\x07"===e[r]){r+=1;break}if("\x1b"===e[r]&&"\\"===e[r+1]){r+=2;break}r+=1}continue}if("P"===t||"^"===t||"_"===t||"X"===t){for(r+=2;r<e.length;){if("\x1b"===e[r]&&"\\"===e[r+1]){r+=2;break}r+=1}continue}r+=t?2:1;continue}if("\r"===a){r+=1;continue}r+=1,s[(t+=a).length]=r}return{plainText:t,rawOffsetsByPlainIndex:s}}(e);if(!t)return{status:"needs-more",text:""};let r=t.split("\n"),a=r.find(e=>!g(e));if(a&&!f(a))return{status:"passthrough",text:e};let n=r.findIndex(e=>x.test(e));if(-1===n)return r.length>=16||t.length>=4096?{status:"passthrough",text:e}:{status:"needs-more",text:""};if(n<6)return{status:"passthrough",text:e};let i=r.slice(n-6,n);if(6!==i.length||!i.every(f))return{status:"passthrough",text:e};let o=p(t,n+1);if(null===o)return{status:"needs-more",text:""};let l=o,d=n+1;for(;g(r[d]);){let e=p(t,d+1);if(null===e)break;l=e,d+=1}let c=s[l]??e.length;return{status:"matched",text:e.slice(c)}}(_.current);if("needs-more"===t.status)return;E.current=!0,_.current="",e=t.text}e&&(r?.write(e),$(!0))}}catch{}},A.onerror=()=>R.current(!1),(i=new ResizeObserver(()=>{if(!t)try{a?.fit(),r&&D(r.cols,r.rows)}catch{}})).observe(y.current)})(),()=>{t=!0,P.current&&clearTimeout(P.current),C.current?.close(),C.current=null,i?.disconnect(),r?.dispose(),S.current=null,k.current=null}},[e,n,o,F,d,c,l,u,M,D]);let q=(0,a.useRef)(null),B=(0,a.useCallback)(()=>{S.current?.focus()},[]);return(0,a.useEffect)(()=>{let e=q.current;if(!e)return;let t=e=>{"Enter"!==e.key||!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey||(e.preventDefault(),e.stopPropagation(),M("\n"))};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[M]),(0,a.useEffect)(()=>{if(t){let e=setTimeout(()=>S.current?.focus(),80);return()=>clearTimeout(e)}},[t]),(0,r.jsxs)("div",{ref:q,className:(0,m.cn)("relative h-full w-full bg-terminal",!t&&"hidden"),onClick:B,children:[!I&&(0,r.jsxs)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 bg-terminal",children:[(0,r.jsx)(i.A,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:n?"Starting GSD…":"Connecting…"})]}),(0,r.jsx)("div",{ref:y,className:"h-full w-full",style:{padding:"8px 4px 4px 8px"}})]})}s(76490);let S=new Set(["image/jpeg","image/png","image/gif","image/webp"]);async function k(e,t,s){let r,a=(0,h.Wl)(e);if(!a.valid)return void console.warn("[terminal-upload] validation failed:",a.error);let n=new FormData;n.append("file",e);try{let e=await (0,v.tm)((0,b.$)("/api/terminal/upload",s),{method:"POST",body:n}),t=await e.json();if(!e.ok||!t.path)return void console.error("[terminal-upload] upload failed:",t.error??`HTTP ${e.status}`);r=t.path}catch(e){console.error("[terminal-upload] upload request failed:",e);return}try{let e=await (0,v.tm)((0,b.$)("/api/terminal/input",s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,data:`@${r} `})});if(!e.ok){let t=await e.json().catch(()=>({}));console.error("[terminal-upload] inject failed:",t.error??`HTTP ${e.status}`)}}catch(e){console.error("[terminal-upload] inject request failed:",e)}}function C({className:e,command:t,commandArgs:s,sessionPrefix:i,hideSidebar:h=!1,fontSize:x,hideInitialGsdHeader:p=!1,projectCwd:g}){let f,{resolvedTheme:j}=(0,n.D)(),y="light"!==j,w=(f=i??(t?"gsd-default":"default"),g?`${f}:${g}`:f),A=function(e){if(!e?.trim())return"zsh";let t=e.trim().split(/\s+/)[0]||e,s=t.replace(/\\/g,"/").split("/");return s[s.length-1]||t}(t),[T,P]=(0,a.useState)([{id:w,label:A,connected:!1}]),[R,E]=(0,a.useState)(w),[_,F]=(0,a.useState)(!1),[I,$]=(0,a.useState)(null),D=(0,a.useRef)(null),L=(0,a.useRef)(w);(0,a.useEffect)(()=>{L.current!==w&&(L.current=w,P([{id:w,label:A,connected:!1}]),E(w),$(null))},[w,A]),(0,a.useEffect)(()=>{let e=D.current;if(!e)return;let t=0,s=e=>{e.preventDefault(),e.stopPropagation(),1===(t+=1)&&F(!0)},r=e=>{e.preventDefault(),e.stopPropagation()},a=e=>{e.preventDefault(),e.stopPropagation(),(t-=1)<=0&&(t=0,F(!1))},n=e=>{if(e.preventDefault(),e.stopPropagation(),t=0,F(!1),!R)return;let s=Array.from(e.dataTransfer?.files??[]).find(e=>S.has(e.type));s&&k(s,R,g)};return e.addEventListener("dragenter",s,!0),e.addEventListener("dragover",r,!0),e.addEventListener("dragleave",a,!0),e.addEventListener("drop",n,!0),()=>{e.removeEventListener("dragenter",s,!0),e.removeEventListener("dragover",r,!0),e.removeEventListener("dragleave",a,!0),e.removeEventListener("drop",n,!0)}},[R,g]),(0,a.useEffect)(()=>{let e=D.current;if(!e)return;let t=e=>{if(!e.clipboardData)return;let t=Array.from(e.clipboardData.files).find(e=>S.has(e.type));t&&(e.preventDefault(),e.stopPropagation(),R&&k(t,R,g))};return e.addEventListener("paste",t,!0),()=>e.removeEventListener("paste",t,!0)},[R,g]);let M=(0,a.useCallback)(async()=>{try{let e=await (0,v.tm)((0,b.$)("/api/terminal/sessions",g),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{command:t}:{})});if(!e.ok)return void $(`Could not create terminal (${e.status}).`);let s=await e.json();if("string"!=typeof s.id||0===s.id.length)return void $("Could not create terminal: invalid server response.");let r={id:s.id,label:A,connected:!1};$(null),P(e=>[...e,r]),E(s.id)}catch(e){$(`Could not create terminal: ${e instanceof Error?e.message:String(e)}`)}},[t,A,g]),q=(0,a.useCallback)(e=>{if(T.length<=1)return;let t=(0,b.Y)("/api/terminal/sessions",window.location.origin,g);t.searchParams.set("id",e),(0,v.tm)(t.toString(),{method:"DELETE"});let s=T.filter(t=>t.id!==e);P(s),R===e&&E(s[s.length-1]?.id??w)},[T,R,w,g]),B=(0,a.useCallback)((e,t)=>{P(s=>s.map(s=>s.id===e?{...s,connected:t}:s))},[]);return(0,r.jsxs)("div",{className:(0,m.cn)("flex bg-terminal",e),children:[(0,r.jsxs)("div",{ref:D,className:"relative flex-1 min-w-0",children:[T.map(e=>(0,r.jsx)(N,{sessionId:e.id,visible:e.id===R,command:t,commandArgs:e.id===w?s:void 0,isDark:y,fontSize:x,hideInitialGsdHeader:p,projectCwd:g,onConnectionChange:t=>B(e.id,t)},e.id)),_&&(0,r.jsxs)("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 bg-background backdrop-blur-sm border-2 border-dashed border-primary rounded-md pointer-events-none",children:[(0,r.jsx)(o.A,{className:"h-8 w-8 text-primary"}),(0,r.jsx)("span",{className:"text-sm font-medium text-primary",children:"Drop image here"})]}),I&&(0,r.jsxs)("div",{className:"absolute left-2 right-2 top-2 z-30 flex items-center gap-2 rounded border border-destructive/40 bg-background px-2 py-1 text-xs text-destructive shadow-sm",children:[(0,r.jsx)(l.A,{className:"h-3.5 w-3.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:I})]})]}),!h&&(0,r.jsxs)("div",{className:"flex w-[34px] flex-shrink-0 flex-col border-l border-border/50 bg-terminal",children:[(0,r.jsx)("button",{onClick:M,className:"flex h-[30px] w-full items-center justify-center text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",title:"New terminal",children:(0,r.jsx)(d.A,{className:"h-3 w-3"})}),(0,r.jsx)("div",{className:"h-px bg-border/50"}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:T.map((e,t)=>(0,r.jsxs)("button",{onClick:()=>E(e.id),className:(0,m.cn)("group relative flex h-[30px] w-full items-center justify-center transition-colors",e.id===R?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground"),title:`${e.label} ${t+1}`,children:[e.id===R&&(0,r.jsx)("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-muted-foreground"}),(0,r.jsxs)("div",{className:"relative flex items-center",children:[(0,r.jsx)(c.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{className:(0,m.cn)("absolute -bottom-0.5 -right-0.5 h-1.5 w-1.5 rounded-full border border-terminal",e.connected?"bg-success":"bg-muted-foreground/40")})]}),T.length>1&&(0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),q(e.id)},className:"absolute -right-0.5 -top-0.5 z-10 hidden h-3.5 w-3.5 items-center justify-center rounded-full bg-accent text-muted-foreground hover:bg-destructive/20 hover:text-destructive group-hover:flex",title:"Kill terminal",children:(0,r.jsx)(u.A,{className:"h-2 w-2"})})]},e.id))})]})]})}},18833:(e,t,s)=>{s.d(t,{cn:()=>n});var r=s(88912),a=s(29048);function n(...e){return(0,a.QP)((0,r.$)(e))}},25847:(e,t,s)=>{s.d(t,{d:()=>i});var r=s(45110);let a="gsd-editor-font-size",n="editor-font-size-changed";function i(){let[e,t]=(0,r.useState)(()=>{try{let e=localStorage.getItem(a);if(e){let t=Number(e);if(Number.isFinite(t)&&t>=8&&t<=24)return t}}catch{}return 14}),s=(0,r.useCallback)(e=>{let s=Math.max(8,Math.min(24,Math.round(e)));t(s);try{localStorage.setItem(a,String(s))}catch{}window.dispatchEvent(new CustomEvent(n,{detail:s}))},[]);return(0,r.useEffect)(()=>{let e=e=>{if(e.key!==a)return;let s=Number(e.newValue);Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,r.useEffect)(()=>{let e=e=>{let s=e.detail;Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener(n,e),()=>window.removeEventListener(n,e)},[]),[e,s]}},37144:(e,t,s)=>{s.d(t,{Q8:()=>A,Qx:()=>T,Yc:()=>E,c0:()=>P,iE:()=>f,ll:()=>r,nU:()=>R,yC:()=>_});let r=["off","minimal","low","medium","high","xhigh"];function a(){return{phase:"idle",data:null,error:null,lastLoadedAt:null}}function n(){return{forensics:a(),doctor:{phase:"idle",data:null,error:null,lastLoadedAt:null,fixPending:!1,lastFixResult:null,lastFixError:null},skillHealth:a()}}function i(){return{knowledge:a(),captures:a(),resolveRequest:{pending:!1,lastError:null,lastResult:null}}}function o(){return{history:a(),inspect:a(),hooks:a(),exportData:a(),undo:a(),cleanup:a(),steer:a()}}let l=new Set(["settings","login","logout"]),d={set_steering_mode:"steeringMode",set_follow_up_mode:"followUpMode",set_auto_compaction:"autoCompaction",set_auto_retry:"autoRetry",abort_retry:"abortRetry"};function c(e={}){return{scope:null,projectCwd:null,projectSessionsDir:null,activeSessionPath:null,query:"",sortMode:"threaded",nameFilter:"all",totalSessions:0,returnedSessions:0,sessions:[],loaded:!1,error:null,...e}}function u(){return{pending:!1,sessionPath:null,result:null,error:null}}function m(){return{pending:!1,result:null,error:null}}function h(){return{steeringMode:m(),followUpMode:m(),autoCompaction:m(),autoRetry:m(),abortRetry:m()}}function x(){return{pending:!1,loaded:!1,result:null,error:null}}function p(){return{phase:"idle",pending:!1,loaded:!1,stale:!1,diagnostics:null,error:null,lastLoadedAt:null,lastInvalidatedAt:null,lastFailureAt:null}}function g(e){return r.includes(e??"")}function f(){return{open:!1,activeSurface:null,source:null,section:null,args:"",pendingAction:null,selectedTarget:null,lastError:null,lastResult:null,availableModels:[],forkMessages:[],sessionStats:null,lastCompaction:null,gitSummary:x(),recovery:p(),diagnostics:n(),knowledgeCaptures:i(),settingsData:a(),remainingCommands:o(),sessionBrowser:c(),resumeRequest:u(),renameRequest:u(),settingsRequests:h()}}function b(e){switch(e.surface){case"model":return"model";case"thinking":return"thinking";case"settings":return e.onboardingLocked?"auth":"general";case"git":return"git";case"login":case"logout":return"auth";case"resume":return"resume";case"name":return"name";case"fork":return"fork";case"session":case"export":return"session";case"compact":return"compact";case"gsd-visualize":return"gsd-visualize";case"gsd-forensics":return"gsd-forensics";case"gsd-doctor":return"gsd-doctor";case"gsd-skill-health":return"gsd-skill-health";case"gsd-knowledge":return"gsd-knowledge";case"gsd-capture":return"gsd-capture";case"gsd-triage":return"gsd-triage";case"gsd-quick":return"gsd-quick";case"gsd-history":return"gsd-history";case"gsd-undo":return"gsd-undo";case"gsd-inspect":return"gsd-inspect";case"gsd-prefs":return"gsd-prefs";case"gsd-config":return"gsd-config";case"gsd-hooks":return"gsd-hooks";case"gsd-mode":return"gsd-mode";case"gsd-steer":return"gsd-steer";case"gsd-report":return"gsd-report";case"gsd-export":return"gsd-export";case"gsd-cleanup":return"gsd-cleanup";case"gsd-queue":return"gsd-queue";default:return null}}function v(e){return{kind:"settings",section:e}}function j(e){let t=e.args?.trim()||void 0;return{kind:"model",provider:e.currentModel?.provider,modelId:e.currentModel?.modelId,query:t}}function y(e){let t=e.args?.trim().toLowerCase()||"";return{kind:"thinking",level:g(t)?t:g(e.currentThinkingLevel)?e.currentThinkingLevel:"off"}}function w(e){return{kind:"auth",providerId:(e.args?.trim()||void 0)??e.preferredProviderId??void 0,intent:"login"===e.surface?"login":"logout"===e.surface?"logout":"manage"}}function N(e){return{kind:"resume",sessionPath:function(e,t){if(!e?.length)return;let s=t?.trim().toLowerCase();if(!s)return e.find(e=>!e.isActive)?.path??e[0]?.path;let r=e.find(e=>[e.id,e.name,e.path].filter(Boolean).map(e=>e.toLowerCase()).includes(s));return r?r.path:e.find(e=>[e.id,e.name,e.path].filter(Boolean).map(e=>e.toLowerCase()).some(e=>e.includes(s)))?.path}(e.resumableSessions,e.args)}}function S(e){return{kind:"fork",entryId:e.args?.trim()||void 0}}function k(e){return{kind:"session",outputPath:e.args?.trim()||void 0}}function C(e){return{kind:"compact",customInstructions:e.args?.trim()??""}}function A(e,t){let s,r=b(t);return{...e,open:!0,activeSurface:t.surface,source:t.source,section:r,args:t.args?.trim()??"",pendingAction:null,selectedTarget:function(e){if(void 0!==e.selectedTarget)return e.selectedTarget;let t=b(e);if(!t)return null;if("settings"===e.surface)return v(t);if("model"===e.surface)return j(e);if("thinking"===e.surface)return y(e);if(l.has(e.surface))return w(e);if("resume"===e.surface)return N(e);if("name"===e.surface){let t;return t=e.args?.trim(),{kind:"name",sessionPath:e.currentSessionPath??void 0,name:void 0!==t&&t.length>0?t:e.currentSessionName?.trim()??""}}if("fork"===e.surface)return S(e);if("session"===e.surface||"export"===e.surface)return k(e);if("compact"===e.surface)return C(e);if(e.surface?.startsWith("gsd-")){let t=e.surface.slice(4);return{kind:"gsd",surface:e.surface,subcommand:t,args:e.args??""}}return v(t)}(t),lastError:null,lastResult:null,sessionStats:null,forkMessages:[],lastCompaction:null,gitSummary:x(),recovery:p(),diagnostics:n(),knowledgeCaptures:i(),settingsData:a(),remainingCommands:o(),sessionBrowser:(s="resume"===t.surface?t.args?.trim()??"":"",c({activeSessionPath:t.currentSessionPath??null,projectCwd:t.projectCwd??null,projectSessionsDir:t.projectSessionsDir??null,query:s,sortMode:s?"relevance":"threaded"})),resumeRequest:u(),renameRequest:u(),settingsRequests:h()}}function T(e){return{...e,open:!1,pendingAction:null}}function P(e,t,s={}){let r={surface:e.activeSurface??"settings",source:e.source??"surface",args:e.args,...s},a=e.selectedTarget?.kind==="resume"||e.selectedTarget?.kind==="name"?e.selectedTarget.sessionPath:void 0,n=e.selectedTarget?.kind==="name"?e.selectedTarget.name:void 0,i=e.selectedTarget;return"model"===t?i=j(r):"thinking"===t?i=y(r):"general"===t||"session-behavior"===t||"queue"===t||"compaction"===t||"retry"===t||"recovery"===t||"git"===t||"admin"===t?i=v(t):"auth"===t?i=w({...r,surface:"logout"===e.activeSurface?"logout":"login"===e.activeSurface?"login":"settings"}):"resume"===t?i={kind:"resume",sessionPath:a??N(r).sessionPath}:"name"===t?i={kind:"name",sessionPath:a??r.currentSessionPath??void 0,name:n??r.currentSessionName?.trim()??""}:"fork"===t?i=S(r):"session"===t?i=k(r):"compact"===t&&(i=C(r)),{...e,section:t,selectedTarget:i}}function R(e,t){let s="settings"===t.kind?t.section:"model"===t.kind?"model":"thinking"===t.kind?"thinking":"auth"===t.kind?"auth":"resume"===t.kind?"resume":"name"===t.kind?"name":"fork"===t.kind?"fork":"session"===t.kind?"session":"compact";return{...e,section:s,selectedTarget:t,lastError:null,lastResult:null}}function E(e,t,s=e.selectedTarget){let r="switch_session"===t?{pending:!0,sessionPath:s?.kind==="resume"?s.sessionPath??null:null,result:null,error:null}:e.resumeRequest,a="rename_session"===t?{pending:!0,sessionPath:s?.kind==="name"?s.sessionPath??null:null,result:null,error:null}:e.renameRequest,n=d[t],i=n?{...e.settingsRequests,[n]:{pending:!0,result:null,error:null}}:e.settingsRequests;return{...e,pendingAction:t,selectedTarget:s,lastError:null,lastResult:null,gitSummary:"load_git_summary"===t?{...e.gitSummary,pending:!0,error:null}:e.gitSummary,recovery:"load_recovery_diagnostics"===t?{...e.recovery,pending:!0,error:null,phase:e.recovery.loaded?e.recovery.phase:"loading"}:e.recovery,sessionBrowser:"load_session_browser"===t?{...e.sessionBrowser,error:null}:e.sessionBrowser,resumeRequest:r,renameRequest:a,settingsRequests:i}}function _(e,t){let s=void 0===t.selectedTarget?e.selectedTarget:t.selectedTarget,r=(s?.kind==="resume"?s.sessionPath:void 0)??e.resumeRequest.sessionPath,a=(s?.kind==="name"?s.sessionPath:void 0)??e.renameRequest.sessionPath,n=d[t.action],i=n?{...e.settingsRequests,[n]:{pending:!1,result:t.success?t.message:null,error:t.success?null:t.message}}:e.settingsRequests;return{...e,pendingAction:null,selectedTarget:s,availableModels:t.availableModels??e.availableModels,forkMessages:t.forkMessages??e.forkMessages,sessionStats:void 0===t.sessionStats?e.sessionStats:t.sessionStats,lastCompaction:void 0===t.lastCompaction?e.lastCompaction:t.lastCompaction,gitSummary:void 0===t.gitSummary?e.gitSummary:{...t.gitSummary,pending:!1,loaded:t.gitSummary.loaded||t.success},recovery:t.recovery??e.recovery,sessionBrowser:t.sessionBrowser??e.sessionBrowser,resumeRequest:"switch_session"===t.action?{pending:!1,sessionPath:r??null,result:t.success?t.message:null,error:t.success?null:t.message}:e.resumeRequest,renameRequest:"rename_session"===t.action?{pending:!1,sessionPath:a??null,result:t.success?t.message:null,error:t.success?null:t.message}:e.renameRequest,settingsRequests:i,lastError:t.success?null:t.message,lastResult:t.success?t.message:null}}},38937:(e,t,s)=>{s.r(t),s.d(t,{GSDAppShell:()=>ay});var r=s(18870),a=s(89581),n=s(23711),i=s(45110),o=s(46518),l=s(65797),d=s(66840),c=s(85429),u=s(20607),m=s(53348),h=s(32457),x=s(62970),p=s(48632),g=s(87339),f=s(48768),b=s(23189),v=s(58718),j=s(90034),y=s(8992),w=s(57818),N=s(8959),S=s(15007),k=s(25490),C=s(55285),A=s(61999),T=s(20437),P=s(87942),R=s(72852),E=s(78070),_=s(76756),F=s(51738),I=s(66828),$=s(24028),D=s(68154),L=s(35540),M=s(18833);function q({...e}){return(0,r.jsx)(L.bL,{"data-slot":"dialog",...e})}function B({...e}){return(0,r.jsx)(L.ZL,{"data-slot":"dialog-portal",...e})}function U({className:e,...t}){return(0,r.jsx)(L.hJ,{"data-slot":"dialog-overlay",className:(0,M.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function O({className:e,children:t,showCloseButton:s=!0,...a}){return(0,r.jsxs)(B,{"data-slot":"dialog-portal",children:[(0,r.jsx)(U,{}),(0,r.jsxs)(L.UC,{"data-slot":"dialog-content",className:(0,M.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...a,children:[t,s&&(0,r.jsxs)(L.bm,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,r.jsx)(o.A,{}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function z({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"dialog-header",className:(0,M.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function G({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"dialog-footer",className:(0,M.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function W({className:e,...t}){return(0,r.jsx)(L.hE,{"data-slot":"dialog-title",className:(0,M.cn)("text-lg leading-none font-semibold",e),...t})}function K({className:e,...t}){return(0,r.jsx)(L.VY,{"data-slot":"dialog-description",className:(0,M.cn)("text-muted-foreground text-sm",e),...t})}var V=s(31841),H=s(95426);let Y=(0,H.F)("relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,transform] duration-150 ease-out disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5 before:absolute before:left-1/2 before:top-1/2 before:h-10 before:w-full before:min-w-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8 before:absolute before:left-1/2 before:top-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function J({className:e,variant:t,size:s,asChild:a=!1,static:n=!1,...i}){let o=a?V.DX:"button";return(0,r.jsx)(o,{"data-slot":"button",className:(0,M.cn)(Y({variant:t,size:s}),!n&&"active:scale-[0.96]",e),...i})}var Z=s(20559),Q=s(68543),X=s(46054),ee=s(59727),et=s(10313);function es(e){let t=e.trim();if(!t)return t;let s=t.startsWith("/"),r=t.replace(/\\/g,"/").split("/"),a=[];for(let e of r)if(""!==e&&"."!==e){if(".."===e){a.length>0&&a.pop();continue}a.push(e)}return s?0===a.length?"/":`/${a.join("/")}`:a.join("/")}class er{getActiveStore(){return this.activeProjectCwd?this.stores.get(this.activeProjectCwd)??null:null}getActiveProjectCwd(){return this.activeProjectCwd}switchProject(e){let t=es(e);if(this.activeProjectCwd&&this.activeProjectCwd!==t){let e=this.stores.get(this.activeProjectCwd);e&&e.disconnectSSE()}let s=this.stores.get(t);return s?s.reconnectSSE():(s=new Q.Hu(t),this.stores.set(t,s),s.start()),this.activeProjectCwd=t,this.notify(),s}disposeAll(){for(let e of this.stores.values())e.dispose();this.stores.clear(),this.activeProjectCwd=null,this.notify()}closeProject(e){let t=es(e),s=this.stores.get(t);if(s){if(s.dispose(),this.stores.delete(t),this.activeProjectCwd===t){let e=Array.from(this.stores.keys());if(e.length>0){let t=this.stores.get(e[0]);this.activeProjectCwd=e[0],t.reconnectSSE()}else this.activeProjectCwd=null}this.notify()}}getProjectCount(){return this.stores.size}getActiveProjectPaths(){return Array.from(this.stores.keys())}notify(){for(let e of this.listeners)e()}constructor(){this.stores=new Map,this.activeProjectCwd=null,this.listeners=new Set,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.getSnapshot=()=>this.activeProjectCwd}}let ea=(0,i.createContext)(null);function en({children:e}){let[t]=(0,i.useState)(()=>new er);return(0,i.useEffect)(()=>()=>t.disposeAll(),[t]),(0,r.jsx)(ea.Provider,{value:t,children:e})}function ei(){let e=(0,i.useContext)(ea);if(!e)throw Error("useProjectStoreManager must be used within ProjectStoreManagerProvider");return e}function eo({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,M.cn)("bg-accent animate-pulse rounded-md",e),...t})}var el=s(83890);let ed=({status:e})=>"done"===e?(0,r.jsx)(u.A,{className:"h-4 w-4 shrink-0 text-success"}):"in-progress"===e?(0,r.jsx)(m.A,{className:"h-4 w-4 shrink-0 text-warning"}):"parked"===e?(0,r.jsx)(h.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"});function ec({activeView:e,onViewChange:t,isConnecting:s=!1}){let{openCommandSurface:a}=(0,Q._l)(),n=ei(),o=(0,i.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot),[l,u]=(0,i.useState)(!1),{theme:m,setTheme:h}=(0,Z.D)(),x="light"===m?p.A:"dark"===m?g.A:f.A,P="light"===m?"Light":"dark"===m?"Dark":"System",R=[{id:"dashboard",label:"Dashboard",icon:b.A},{id:"power",label:"Power Mode",icon:v.A},{id:"chat",label:"Chat",icon:j.A},{id:"roadmap",label:"Roadmap",icon:y.A},{id:"files",label:"Files",icon:w.A},{id:"activity",label:"Activity",icon:N.A},{id:"visualize",label:"Visualize",icon:S.A}];return(0,r.jsxs)("div",{className:"flex w-12 flex-col items-center gap-1 border-r border-border bg-sidebar py-3",children:[R.map(a=>(0,r.jsx)("button",{onClick:()=>t(a.id),disabled:s,className:(0,M.cn)("flex h-10 w-10 items-center justify-center rounded-md transition-colors",s?"cursor-not-allowed text-muted-foreground/50":e===a.id?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),title:s?"Connecting…":a.label,children:(0,r.jsx)(a.icon,{className:"h-5 w-5"})},a.id)),(0,r.jsxs)("div",{className:"mt-auto flex flex-col gap-1",children:[(0,r.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("gsd:open-projects")),disabled:s,className:(0,M.cn)("flex h-10 w-10 items-center justify-center rounded-md transition-colors",s?"cursor-not-allowed text-muted-foreground/50":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),title:s?"Connecting…":"Projects",children:(0,r.jsx)(k.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{className:(0,M.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-accent/50 hover:text-foreground"),title:"Git",disabled:s,onClick:()=>!s&&a("git",{source:"sidebar"}),"data-testid":"sidebar-git-button",children:(0,r.jsx)(C.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{className:(0,M.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-accent/50 hover:text-foreground"),title:"Settings",disabled:s,onClick:()=>!s&&a("settings",{source:"sidebar"}),"data-testid":"sidebar-settings-button",children:(0,r.jsx)(A.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{className:(0,M.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-accent/50 hover:text-foreground"),title:`Theme: ${P}`,disabled:s,onClick:()=>!s&&void("system"===m?h("light"):"light"===m?h("dark"):h("system")),"data-testid":"sidebar-theme-toggle",children:(0,r.jsx)("span",{className:"relative flex h-5 w-5 items-center justify-center",children:(0,r.jsx)(d.N,{mode:"wait",initial:!1,children:(0,r.jsx)(c.P.span,{className:"absolute inset-0 flex items-center justify-center",initial:{opacity:0,scale:.25,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:.25,filter:"blur(4px)"},transition:{type:"spring",duration:.3,bounce:0},children:(0,r.jsx)(x,{className:"h-5 w-5"})},P)})})}),(0,r.jsx)("button",{className:(0,M.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-destructive/15 hover:text-destructive"),title:"Exit",disabled:s,onClick:()=>!s&&u(!0),"data-testid":"sidebar-signoff-button",children:(0,r.jsx)(T.A,{className:"h-5 w-5"})}),(0,r.jsx)(eu,{open:l,onOpenChange:u,projectCount:n.getProjectCount(),activeProjectCwd:o,onCloseProject:e=>{n.closeProject(e),t("dashboard"),u(!1)},onStopServer:async()=>{await (0,el.tm)("/api/shutdown",{method:"POST"}).catch(()=>{}),setTimeout(()=>{try{window.close()}catch{}setTimeout(()=>{window.location.href="about:blank"},300)},400)}})]})]})}function eu({open:e,onOpenChange:t,projectCount:s,activeProjectCwd:a,onCloseProject:n,onStopServer:i}){let o=s>1,l=a?a.split("/").pop()??a:null;return o?(0,r.jsx)(q,{open:e,onOpenChange:t,children:(0,r.jsxs)(O,{className:"sm:max-w-md",children:[(0,r.jsxs)(z,{children:[(0,r.jsx)(W,{children:"Close project or stop server?"}),(0,r.jsxs)(K,{children:["You have ",s," projects open. You can close just the current project or stop the entire server."]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 py-2",children:[a&&(0,r.jsxs)(J,{variant:"outline",className:"h-auto justify-start gap-3 px-4 py-3 text-left",onClick:()=>n(a),children:[(0,r.jsx)(k.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"text-sm font-medium",children:["Close ",l]}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"Disconnect this project and switch to another"})]})]}),(0,r.jsxs)(J,{variant:"outline",className:"h-auto justify-start gap-3 px-4 py-3 text-left border-destructive/30 hover:bg-destructive/10 hover:text-destructive",onClick:i,children:[(0,r.jsx)(T.A,{className:"h-4 w-4 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Stop server"}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Shut down all ",s," projects and close the tab"]})]})]})]}),(0,r.jsx)(G,{children:(0,r.jsx)(J,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"})})]})}):(0,r.jsx)(q,{open:e,onOpenChange:t,children:(0,r.jsxs)(O,{className:"sm:max-w-md",children:[(0,r.jsxs)(z,{children:[(0,r.jsx)(W,{children:"Stop the GSD web server?"}),(0,r.jsxs)(K,{children:["This will shut down the server process and close this tab. Run"," ",(0,r.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs",children:"gsd --web"})," again to restart."]})]}),(0,r.jsxs)(G,{children:[(0,r.jsx)(J,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),(0,r.jsx)(J,{variant:"destructive",onClick:i,children:"Stop server"})]})]})})}function em({isConnecting:e=!1,width:t,onCollapse:s}){let a,n=(0,Q.gF)(),{openCommandSurface:o,setCommandSurfaceSection:l,sendCommand:d}=(0,Q._l)(),[c,u]=(0,i.useState)([]),[x,p]=(0,i.useState)([]),g=(0,Q.K0)(n),f=(0,i.useMemo)(()=>g?.milestones??[],[g?.milestones]),b=g?.active,v=(0,Q.cZ)(n),j=n.live.recoverySummary,y=g?.validationIssues.length??0,w=(0,Q.U4)(g),N=n.boot?.project.cwd??null,S=n.boot?.bridge??null,k=(0,ee.L)({phase:g?.active.phase??"pre-planning",autoActive:v?.active??!1,autoPaused:v?.paused??!1,onboardingLocked:n.boot?.onboarding.locked??!1,commandInFlight:n.commandInFlight,bootStatus:n.bootStatus,hasMilestones:f.length>0,stepMode:v?.stepMode??!1,projectDetectionKind:n.boot?.projectDetection?.kind??null}),C=e=>{(0,et.WT)({dispatch:()=>d((0,Q.Sf)(e,S))})},A=b?.milestoneId&&!c.includes(b.milestoneId)?[...c,b.milestoneId]:c,T=b?.milestoneId&&b.sliceId?(a=`${b.milestoneId}-${b.sliceId}`,x.includes(a)?x:[...x,a]):x,D=new Map(f.map(e=>[e.id,(0,X.Jq)(e,b??{})]));return(0,r.jsxs)("div",{className:"flex flex-col bg-sidebar",style:{width:t??256,flexShrink:0},children:[e&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-1.5 py-1",children:[(0,r.jsx)("div",{className:"px-2 py-1.5",children:(0,r.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Milestones"})}),(0,r.jsx)("div",{className:"space-y-0.5 px-1",children:[1,2].map(e=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1.5",children:[(0,r.jsx)(eo,{className:"h-4 w-4 shrink-0 rounded"}),(0,r.jsx)(eo,{className:"h-4 w-4 shrink-0 rounded-full"}),(0,r.jsx)(eo,{className:(0,M.cn)("h-4",1===e?"w-40":"w-32")})]}),1===e&&(0,r.jsx)("div",{className:"ml-4 space-y-0.5",children:[1,2,3].map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1.5",children:[(0,r.jsx)(eo,{className:"h-4 w-4 shrink-0 rounded"}),(0,r.jsx)(eo,{className:"h-4 w-4 shrink-0 rounded-full"}),(0,r.jsx)(eo,{className:(0,M.cn)("h-3.5",1===e?"w-32":2===e?"w-28":"w-24")})]},e))})]},e))})]}),!e&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-1.5 py-1",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between px-2 py-1.5",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Milestones"}),(0,r.jsx)("div",{className:"mt-1 text-xs text-foreground","data-testid":"sidebar-current-scope",children:w})]}),s&&(0,r.jsx)("button",{onClick:s,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",title:"Collapse sidebar",children:(0,r.jsx)(P.A,{className:"h-3.5 w-3.5"})})]}),"error"===n.bootStatus&&0===f.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-destructive",children:"Workspace boot failed before the explorer could load."}),"ready"===n.bootStatus&&0===f.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No milestones found for this project."}),f.map(e=>{let t=A.includes(e.id),s=b?.milestoneId===e.id,a=D.get(e.id)??"pending";return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{onClick:()=>{var t;return t=e.id,void u(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:(0,M.cn)("flex w-full items-center gap-1.5 px-2 py-1.5 text-sm transition-colors hover:bg-accent/50",s&&"bg-accent/30"),children:[t?(0,r.jsx)(R.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,r.jsx)(E.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsx)(ed,{status:a}),(0,r.jsxs)("span",{className:(0,M.cn)("truncate",("pending"===a||"parked"===a)&&"text-muted-foreground"),children:[e.id,": ",e.title]})]}),t&&(0,r.jsx)("div",{className:"ml-4",children:e.slices.map(t=>{let s=`${e.id}-${t.id}`,a=T.includes(s),n=(0,X.z3)(e.id,t,b??{}),i=b?.milestoneId===e.id&&b.sliceId===t.id;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{onClick:()=>{p(e=>e.includes(s)?e.filter(e=>e!==s):[...e,s])},className:(0,M.cn)("flex w-full items-center gap-1.5 px-2 py-1.5 text-sm transition-colors hover:bg-accent/50",i&&"bg-accent/20"),children:[a?(0,r.jsx)(R.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,r.jsx)(E.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsx)(ed,{status:n}),(0,r.jsxs)("span",{className:(0,M.cn)("truncate text-[13px]","pending"===n&&"text-muted-foreground"),children:[t.id,": ",t.title]})]}),a&&(0,r.jsxs)("div",{className:"ml-5",children:[t.branch&&(0,r.jsx)("div",{className:"px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:t.branch}),t.tasks.map(a=>{let n=(0,X.g$)(e.id,t.id,a,b??{}),o=!!(a.planPath||a.summaryPath);return(0,r.jsxs)("button",{type:"button",onClick:()=>(e=>{if(!e||!N)return;let t=`${N}/.gsd/`;if(!e.startsWith(t))return;let s=e.slice(t.length);window.dispatchEvent(new CustomEvent("gsd:open-file",{detail:{root:"gsd",path:s}}))})(a.summaryPath??a.planPath),disabled:!o,className:(0,M.cn)("flex w-full items-center gap-1.5 px-2 py-1 text-xs transition-colors",o?"cursor-pointer hover:bg-accent/50":"cursor-default opacity-70",b?.taskId===a.id&&i&&"bg-accent/10"),children:[(0,r.jsx)(_.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsx)(ed,{status:n}),(0,r.jsxs)("span",{className:(0,M.cn)("truncate text-left","pending"===n&&"text-muted-foreground"),children:[a.id,": ",a.title]})]},`${s}-${a.id}`)})]})]},s)})})]},e.id)})]}),!e&&(0,r.jsx)("div",{className:"border-t border-border px-3 py-2.5",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"font-medium text-foreground","data-testid":"sidebar-validation-count",children:[y," validation issue",1===y?"":"s"]}),(0,r.jsx)("div",{className:"truncate text-muted-foreground",children:j.label})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{o("settings",{source:"sidebar"}),l("recovery")},className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[11px] font-medium text-foreground transition-colors hover:bg-accent","data-testid":"sidebar-recovery-summary-entrypoint",children:[(0,r.jsx)(F.A,{className:"h-3.5 w-3.5"}),"Recovery"]})]})}),!e&&k.primary&&(0,r.jsx)("div",{className:"border-t border-border px-3 py-2.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:()=>{k.primary&&C(k.primary.command)},disabled:k.disabled,className:(0,M.cn)("inline-flex h-9 flex-1 items-center justify-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","destructive"===k.primary.variant?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90",k.disabled&&"cursor-not-allowed opacity-50"),title:k.disabledReason,children:[n.commandInFlight?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):k.isNewMilestone?(0,r.jsx)($.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(m.A,{className:"h-3.5 w-3.5"}),k.primary.label]}),k.secondaries.map(e=>(0,r.jsx)("button",{onClick:()=>C(e.command),disabled:k.disabled,className:(0,M.cn)("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border bg-background transition-colors hover:bg-accent",k.disabled&&"cursor-not-allowed opacity-50"),title:e.label,children:(0,r.jsx)(h.A,{className:"h-3.5 w-3.5"})},e.command))]})})]})}function eh({onExpand:e}){let t=(0,Q.gF)(),{sendCommand:s}=(0,Q._l)(),a=(0,Q.K0)(t),n=a?.milestones??[],i=(0,Q.cZ)(t),o=t.boot?.bridge??null,l=(0,ee.L)({phase:a?.active.phase??"pre-planning",autoActive:i?.active??!1,autoPaused:i?.paused??!1,onboardingLocked:t.boot?.onboarding.locked??!1,commandInFlight:t.commandInFlight,bootStatus:t.bootStatus,hasMilestones:n.length>0,stepMode:i?.stepMode??!1,projectDetectionKind:t.boot?.projectDetection?.kind??null});return(0,r.jsxs)("div",{className:"flex h-full w-10 flex-col items-center border-l border-border bg-sidebar py-3",children:[(0,r.jsx)("button",{onClick:e,className:"flex h-8 w-8 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",title:"Expand milestone sidebar",children:(0,r.jsx)(D.A,{className:"h-4 w-4"})}),l.primary&&(0,r.jsx)("div",{className:"mt-auto pb-0.5",children:(0,r.jsx)("button",{onClick:()=>{if(l.primary){var e;e=l.primary.command,(0,et.WT)({dispatch:()=>s((0,Q.Sf)(e,o))})}},disabled:l.disabled,className:(0,M.cn)("flex h-8 w-8 items-center justify-center rounded-md transition-colors","destructive"===l.primary.variant?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90",l.disabled&&"cursor-not-allowed opacity-50"),title:l.disabledReason??l.primary.label,children:t.commandInFlight?(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}):l.isNewMilestone?(0,r.jsx)($.A,{className:"h-4 w-4"}):(0,r.jsx)(m.A,{className:"h-4 w-4"})})})]})}function ex({activeView:e,onViewChange:t,isConnecting:s=!1,mobile:a=!1}){return a?(0,r.jsx)(ep,{activeView:e,onViewChange:t,isConnecting:s}):(0,r.jsx)("div",{className:"flex h-full",children:(0,r.jsx)(ec,{activeView:e,onViewChange:t,isConnecting:s})})}function ep({activeView:e,onViewChange:t,isConnecting:s=!1}){let{openCommandSurface:a}=(0,Q._l)(),{theme:n,setTheme:i}=(0,Z.D)(),o="light"===n?p.A:"dark"===n?g.A:f.A,l=[{id:"dashboard",label:"Dashboard",icon:b.A},{id:"power",label:"Power Mode",icon:v.A},{id:"chat",label:"Chat",icon:j.A},{id:"roadmap",label:"Roadmap",icon:y.A},{id:"files",label:"Files",icon:w.A},{id:"activity",label:"Activity",icon:N.A},{id:"visualize",label:"Visualize",icon:S.A}];return(0,r.jsxs)("div",{className:"flex h-full flex-col bg-sidebar pt-14","data-testid":"mobile-nav-panel",children:[(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:l.map(a=>(0,r.jsxs)("button",{onClick:()=>t(a.id),disabled:s,className:(0,M.cn)("flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm font-medium transition-colors min-h-[44px]",s?"cursor-not-allowed text-muted-foreground/50":e===a.id?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,r.jsx)(a.icon,{className:"h-5 w-5 shrink-0"}),a.label]},a.id))}),(0,r.jsxs)("div",{className:"border-t border-border px-2 py-2 space-y-1",children:[(0,r.jsxs)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("gsd:open-projects")),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,r.jsx)(k.A,{className:"h-5 w-5 shrink-0"}),"Projects"]}),(0,r.jsxs)("button",{onClick:()=>!s&&a("git",{source:"sidebar"}),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,r.jsx)(C.A,{className:"h-5 w-5 shrink-0"}),"Git"]}),(0,r.jsxs)("button",{onClick:()=>!s&&a("settings",{source:"sidebar"}),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,r.jsx)(A.A,{className:"h-5 w-5 shrink-0"}),"Settings"]}),(0,r.jsxs)("button",{onClick:()=>!s&&void("system"===n?i("light"):"light"===n?i("dark"):i("system")),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,r.jsx)(o,{className:"h-5 w-5 shrink-0"}),"Theme: ","light"===n?"Light":"dark"===n?"Dark":"System"]})]})]})}var eg=s(14156),ef=s(24896),eb=s(6742),ev=s(3733),ej=s(36542);function ey(){return(0,r.jsxs)("div",{className:"rounded-md border border-border bg-card",children:[(0,r.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("h2",{className:"text-sm font-semibold",children:"Current Slice"})}),(0,r.jsx)("div",{className:"space-y-3 p-4",children:[1,2,3].map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(eo,{className:"h-4 w-4 shrink-0 rounded-full"}),(0,r.jsx)(eo,{className:(0,M.cn)("h-4",1===e?"w-48":2===e?"w-40":"w-36")})]},e))})]})}function ew(){return(0,r.jsxs)("div",{className:"rounded-md border border-border bg-card",children:[(0,r.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("h2",{className:"text-sm font-semibold",children:"Recent Activity"})}),(0,r.jsx)("div",{className:"divide-y divide-border",children:[1,2,3,4].map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,r.jsx)(eo,{className:"h-3 w-16 shrink-0"}),(0,r.jsx)(eo,{className:"h-1.5 w-1.5 shrink-0 rounded-full"}),(0,r.jsx)(eo,{className:(0,M.cn)("h-4 flex-1",e%3==0?"max-w-xs":e%3==1?"max-w-sm":"max-w-md")})]},e))})]})}function eN(e){switch(e){case"complete":case"completed":return{label:"Complete",tone:"success"};case"executing":return{label:"Executing",tone:"active"};case"in-progress":return{label:"In Progress",tone:"active"};case"planning":return{label:"Planning",tone:"info"};case"pre-planning":return{label:"Pre-planning",tone:"muted"};case"researching":return{label:"Researching",tone:"info"};case"refining":return{label:"Refining",tone:"info"};case"summarizing":return{label:"Summarizing",tone:"info"};case"verifying":return{label:"Verifying",tone:"info"};case"blocked":return{label:"Blocked",tone:"warning"};case"paused":return{label:"Paused",tone:"warning"};case"needs-discussion":return{label:"Discussion",tone:"warning"};case"validating-milestone":return{label:"Validating",tone:"info"};case"replanning-slice":return{label:"Replanning",tone:"info"};case"escalating-task":return{label:"Escalating",tone:"warning"};case"completing-milestone":return{label:"Completing",tone:"info"};case"evaluating-gates":return{label:"Evaluating Gates",tone:"info"};default:return{label:e,tone:"muted"}}}let eS={success:"bg-success/15 text-success",active:"bg-primary/15 text-primary",warning:"bg-warning/15 text-warning",info:"bg-info/15 text-info",muted:"bg-muted text-muted-foreground"},ek={success:"bg-success",active:"bg-primary",warning:"bg-warning",info:"bg-info",muted:"bg-muted-foreground/50"};function eC(e){return e.replace(/([MST])0*(\d+)/g,"$1$2")}function eA(e){let t=e.match(/^(.+?)\s*—\s*(.+)$/);return t?{scopeId:eC(t[1].trim()),phase:t[2].trim()}:{scopeId:eC(e.trim()),phase:null}}function eT({label:e,size:t="md",className:s}){let{scopeId:a,phase:n}=eA(e);if("Project scope pending"===a)return(0,r.jsx)("span",{className:(0,M.cn)("text-muted-foreground",eP(t),s),children:"Scope pending…"});let i=n?eN(n):null;return(0,r.jsxs)("span",{className:(0,M.cn)("inline-flex items-center gap-2",s),children:[(0,r.jsx)("span",{className:(0,M.cn)("font-semibold tracking-tight tabular-nums","sm"===t?"text-sm":"text-lg"),children:a}),i&&(0,r.jsx)("span",{className:(0,M.cn)("inline-flex shrink-0 items-center rounded-full px-2 font-medium leading-snug",eS[i.tone],eP(t),"sm"===t?"py-px":"py-0.5"),children:i.label})]})}function eP(e){return"sm"===e?"text-[10px]":"text-[11px]"}function eR({label:e,className:t}){let{scopeId:s,phase:a}=eA(e);if("Project scope pending"===s)return(0,r.jsx)("span",{className:(0,M.cn)("text-muted-foreground",t),children:"Scope pending…"});let n=a?eN(a):null,i=n?ek[n.tone]:"bg-muted-foreground/50";return(0,r.jsxs)("span",{className:(0,M.cn)("inline-flex items-center gap-1.5",t),children:[(0,r.jsx)("span",{className:(0,M.cn)("h-1.5 w-1.5 shrink-0 rounded-full",i)}),(0,r.jsx)("span",{className:"tabular-nums",children:s}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-border",children:"\xb7"}),(0,r.jsx)("span",{children:n.label})]})]})}var eE=s(3445),e_=s(78564),eF=s(12601),eI=s(56478),e$=s(69558),eD=s(67504);function eL({icon:e,label:t}){return(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-2.5 py-1 text-xs text-muted-foreground",children:[e,t]})}function eM({signals:e}){let t=[];return(e.hasGitRepo&&t.push({icon:(0,r.jsx)(C.A,{className:"h-3 w-3"}),label:"Git repository"}),e.hasPackageJson&&t.push({icon:(0,r.jsx)(eI.A,{className:"h-3 w-3"}),label:"Node.js project"}),e.fileCount>0&&t.push({icon:(0,r.jsx)(e$.A,{className:"h-3 w-3"}),label:`${e.fileCount} file${1===e.fileCount?"":"s"}`}),0===t.length)?null:(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:t.map(e=>(0,r.jsx)(eL,{icon:e.icon,label:e.label},e.label))})}function eq({detection:e,onCommand:t,onSwitchView:s,disabled:a=!1}){let n=function(e){switch(e.kind){case"brownfield":return{icon:(0,r.jsx)(eE.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"Existing project detected",body:"GSD will map your codebase and ask a few questions about what you want to build. From there it generates structured milestones and deliverable slices.",primaryLabel:"Map & Initialize",primaryCommand:"/gsd",secondary:{label:"Browse files first",action:"files-view"}};case"v1-legacy":return{icon:(0,r.jsx)(e_.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"GSD v1 project found",body:"This project has a .planning/ folder from an earlier GSD version. Migration converts your existing planning data into the new .gsd/ format.",detail:"Your original files will be preserved — migration creates the new structure alongside them.",primaryLabel:"Migrate to v2",primaryCommand:"/gsd migrate",secondary:{label:"Start fresh instead",action:"command",command:"/gsd"}};case"blank":return{icon:(0,r.jsx)(eF.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"Start a new project",body:"This folder is empty. GSD will ask what you want to build, then generate a structured plan — milestones broken into deliverable slices with risk-ordered execution.",primaryLabel:"Start Project Setup",primaryCommand:"/gsd"};default:return{icon:(0,r.jsx)(w.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"Set up your project",body:"Run the GSD wizard to get started.",primaryLabel:"Get Started",primaryCommand:"/gsd"}}}(e),i="brownfield"===e.kind||"v1-legacy"===e.kind;return(0,r.jsx)("div",{className:"flex h-full items-center justify-center p-8",children:(0,r.jsxs)("div",{className:"w-full max-w-lg",children:[(0,r.jsx)("div",{className:"mb-6 flex h-16 w-16 items-center justify-center rounded-xl border border-border bg-card",children:n.icon}),(0,r.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-balance text-foreground",children:n.headline}),(0,r.jsx)("p",{className:"mt-3 text-sm leading-relaxed text-pretty text-muted-foreground",children:n.body}),n.detail&&(0,r.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-pretty text-muted-foreground",children:n.detail}),i&&(0,r.jsx)("div",{className:"mt-5",children:(0,r.jsx)(eM,{signals:e.signals})}),(0,r.jsxs)("div",{className:"mt-8 flex items-center gap-3",children:[(0,r.jsxs)("button",{onClick:()=>t(n.primaryCommand),disabled:a,className:(0,M.cn)("inline-flex items-center gap-2 rounded-md bg-foreground px-5 py-2.5 text-sm font-medium text-background transition-colors hover:bg-foreground/90",a&&"cursor-not-allowed opacity-50"),children:[n.primaryLabel,(0,r.jsx)(eD.A,{className:"h-3.5 w-3.5"})]}),n.secondary&&(0,r.jsx)("button",{onClick:()=>{"files-view"===n.secondary.action?s("files"):n.secondary.command&&t(n.secondary.command)},disabled:a,className:(0,M.cn)("inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-4 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-accent",a&&"cursor-not-allowed opacity-50"),children:n.secondary.label})]}),"blank"===e.kind&&(0,r.jsxs)("div",{className:"mt-8 rounded-lg border border-border/50 bg-card/50 p-4",children:[(0,r.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"What happens next"}),(0,r.jsx)("ul",{className:"mt-2.5 space-y-2",children:["A few questions about what you're building","Codebase analysis and context gathering","Structured milestone and slice generation"].map((e,t)=>(0,r.jsxs)("li",{className:"flex items-start gap-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-border text-[10px] font-medium text-muted-foreground",children:t+1}),e]},t))})]}),"brownfield"===e.kind&&(0,r.jsxs)("div",{className:"mt-8 rounded-lg border border-border/50 bg-card/50 p-4",children:[(0,r.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"What happens next"}),(0,r.jsx)("ul",{className:"mt-2.5 space-y-2",children:["GSD scans your codebase and asks about your goals","You discuss scope, constraints, and priorities","A milestone with risk-ordered slices is generated"].map((e,t)=>(0,r.jsxs)("li",{className:"flex items-start gap-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-border text-[10px] font-medium text-muted-foreground",children:t+1}),e]},t))})]})]})})}function eB({label:e,value:t,subtext:s,icon:a}){return(0,r.jsx)("div",{className:"rounded-md border border-border bg-card p-4",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:e}),null===t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eo,{className:"mt-2 h-7 w-20"}),(0,r.jsx)(eo,{className:"mt-1.5 h-3 w-16"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"mt-1 truncate text-2xl font-semibold tracking-tight tabular-nums",children:t}),s&&(0,r.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground tabular-nums",children:s})]})]}),(0,r.jsx)("div",{className:"shrink-0 rounded-md bg-accent p-2 text-muted-foreground",children:a})]})})}function eU({onSwitchView:e}={}){var t;let s,a,n=(0,Q.gF)(),{sendCommand:o}=(0,Q._l)(),l=n.boot,d=(0,Q.K0)(n),c=(0,Q.cZ)(n),p=l?.bridge??null,g=l?.project.cwd,[f,b]=(0,i.useState)(null),v=(0,i.useCallback)(async()=>{try{let e=await (0,el.tm)((0,Q.fL)("/api/visualizer",g));if(!e.ok)return;let t=await e.json();t.totals&&b(t.totals)}catch{}},[g]);(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{v()},0),t=window.setInterval(()=>{v()},3e4);return()=>{window.clearTimeout(e),window.clearInterval(t)}},[v]);let j=f?.duration??c?.elapsed??0,y=f?.cost??c?.totalCost??0,w=f?.tokens.total??c?.totalTokens??0,S=(0,Q.Ct)(d),k=S?.tasks.filter(e=>e.done).length??0,A=S?.tasks.length??0,T=A>0?Math.round(k/A*100):0,P=(0,Q.U4)(d),R=(0,Q.E3)(d),E=c?.active??!1,_=c?.currentUnit?.id??P,F=n.live.auto.stale?"stale":n.live.auto.status,I=(n.terminalLines??[]).slice(-6),$="idle"===n.bootStatus||"loading"===n.bootStatus,D=(t=Q._y,s=c?.rtkSavings??null,{enabled:c?.rtkEnabled===!0,label:"RTK Saved",value:$?null:t(s?.savedTokens??0),subtext:$?null:s&&s.commands>0?`${Math.round(s.savingsPct)}% saved • ${s.commands} cmd${1===s.commands?"":"s"}`:"Waiting for shell usage"}),L=l?.projectDetection;return!$&&L&&"active-gsd"!==L.kind&&"empty-gsd"!==L.kind?(0,r.jsx)("div",{className:"flex h-full flex-col overflow-hidden",children:(0,r.jsx)(eq,{detection:L,onCommand:e=>{(0,et.WT)({dispatch:()=>o((0,Q.Sf)(e,p))})},onSwitchView:t=>e?.(t),disabled:!!n.commandInFlight||l?.onboarding.locked})}):(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2 md:px-6 md:py-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("h1",{className:"text-base md:text-lg font-semibold shrink-0",children:"Dashboard"}),!$&&P&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"hidden sm:inline text-lg font-thin text-muted-foreground select-none",children:"/"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:(0,r.jsx)(eT,{label:P,size:"sm"})})]}),$&&(0,r.jsx)(eo,{className:"h-4 w-40"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 md:gap-3","data-testid":"dashboard-action-bar",children:[$?(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(eo,{className:"h-8 w-40 rounded-md"})}):null,!$&&(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm",children:[(0,r.jsx)("span",{className:(0,M.cn)("h-2 w-2 rounded-full",E?"animate-pulse bg-success":"bg-muted-foreground/50")}),(0,r.jsx)("span",{className:"font-medium",children:E?"Auto Mode Active":"Auto Mode Inactive"})]}),!$&&R&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(C.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"font-mono tabular-nums",children:R})]})]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 md:p-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-2 xl:grid-cols-4 2xl:grid-cols-5",children:[(0,r.jsx)("div",{className:"rounded-md border border-border bg-card p-4","data-testid":"dashboard-current-unit",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Current Unit"}),$?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eo,{className:"mt-2 h-7 w-20"}),(0,r.jsx)(eo,{className:"mt-1.5 h-3 w-16"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(eT,{label:_})}),(0,r.jsxs)("p",{className:"mt-1.5 text-xs text-muted-foreground","data-testid":"dashboard-current-unit-freshness",children:["Auto freshness: ",F]})]})]}),(0,r.jsx)("div",{className:"shrink-0 rounded-md bg-accent p-2 text-muted-foreground",children:(0,r.jsx)(N.A,{className:"h-5 w-5"})})]})}),(0,r.jsx)(eB,{label:"Elapsed Time",value:$?null:(0,Q.a3)(j),icon:(0,r.jsx)(ef.A,{className:"h-5 w-5"})}),(0,r.jsx)(eB,{label:"Total Cost",value:$?null:(0,Q.BD)(y),icon:(0,r.jsx)(eb.A,{className:"h-5 w-5"})}),(0,r.jsx)(eB,{label:"Tokens Used",value:$?null:(0,Q._y)(w),icon:(0,r.jsx)(ev.A,{className:"h-5 w-5"})}),D.enabled&&(0,r.jsx)(eB,{label:D.label,value:D.value,subtext:D.subtext,icon:(0,r.jsx)(ej.A,{className:"h-5 w-5"})})]}),(0,r.jsx)("div",{className:"mt-6",children:$?(0,r.jsx)(ey,{}):(0,r.jsxs)("div",{className:"flex flex-col rounded-md border border-border bg-card",children:[(0,r.jsxs)("div",{className:"border-b border-border px-4 py-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Current Slice"}),S?(0,r.jsxs)("p",{className:"mt-0.5 truncate text-sm font-medium text-foreground",children:[S.id," — ",S.title]}):(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"No active slice"})]}),S&&A>0&&(0,r.jsxs)("div",{className:"shrink-0 text-right",children:[(0,r.jsx)("span",{className:"text-2xl font-bold tabular-nums leading-none",children:T}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"%"})]})]}),S&&A>0&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-accent",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-[width,background-color] duration-500",style:{width:`${T}%`,backgroundColor:(a=Math.max(0,Math.min(100,T)),`oklch(0.65 0.16 ${(25+a/100*120).toFixed(1)})`)}})}),(0,r.jsxs)("p",{className:"mt-1.5 text-xs text-muted-foreground tabular-nums",children:[k," of ",A," tasks complete"]})]})]}),(0,r.jsx)("div",{className:"flex-1 p-3",children:S&&S.tasks.length>0?(0,r.jsx)("div",{className:"space-y-0.5",children:S.tasks.map(e=>{let t=(0,X.g$)(d.active.milestoneId,S.id,e,d.active);return(0,r.jsxs)("div",{className:(0,M.cn)("flex items-center gap-2.5 rounded px-2 py-1.5 transition-colors","in-progress"===t&&"bg-accent"),children:[function(e){switch(e){case"done":return(0,r.jsx)(u.A,{className:"h-4 w-4 text-muted-foreground"});case"in-progress":return(0,r.jsx)(m.A,{className:"h-4 w-4 text-foreground"});case"pending":return(0,r.jsx)(x.A,{className:"h-4 w-4 text-muted-foreground"});case"parked":return(0,r.jsx)(h.A,{className:"h-4 w-4 text-muted-foreground"})}}(t),(0,r.jsxs)("span",{className:(0,M.cn)("min-w-0 flex-1 truncate text-xs","done"===t&&"text-muted-foreground line-through decoration-muted-foreground/40","pending"===t&&"text-muted-foreground","in-progress"===t&&"font-medium text-foreground"),children:[(0,r.jsx)("span",{className:"font-mono text-muted-foreground",children:e.id}),(0,r.jsx)("span",{className:"mx-1.5 text-border",children:"\xb7"}),e.title]}),"in-progress"===t&&(0,r.jsx)("span",{className:"shrink-0 rounded-sm bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"active"})]},e.id)})}):(0,r.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No active slice or no tasks defined yet."})})]})}),$?(0,r.jsx)("div",{className:"mt-6",children:(0,r.jsx)(ew,{})}):(0,r.jsxs)("div",{className:"mt-6 rounded-md border border-border bg-card",children:[(0,r.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("h2",{className:"text-sm font-semibold",children:"Recent Activity"})}),I.length>0?(0,r.jsx)("div",{className:"divide-y divide-border",children:I.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,r.jsx)("span",{className:"w-16 flex-shrink-0 font-mono text-xs tabular-nums text-muted-foreground",children:e.timestamp}),(0,r.jsx)("span",{className:(0,M.cn)("h-1.5 w-1.5 flex-shrink-0 rounded-full",function(e){switch(e){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-foreground/50"}}(e.type))}),(0,r.jsx)("span",{className:"truncate text-sm",children:e.content})]},e.id))}):(0,r.jsx)("div",{className:"px-4 py-4 text-sm text-muted-foreground",children:"No activity yet."})]})]})]})}var eO=s(53199),ez=s(2652),eG=s(92893),eW=s(2354),eK=s(78300);function eV(){let e=(0,Q.gF)(),t=(0,Q.tM)(e),s=(0,Q.K0)(e),a=(0,Q.cZ)(e),n=(0,Q.E3)(s)??"project scope",o=(0,Q.iT)(e.boot?.bridge),l=a?.currentUnit?.id??(0,Q.U4)(s),d=(0,Q.QC)(e),c=e.titleOverride?.trim()||null,u=e.statusTexts,m=e.live.recoverySummary,h=(0,Q.K0)(e)?.validationIssues.length??0,x=Object.entries(u),p=x.length>0?x[x.length-1][1]:null,g="idle"===e.bootStatus||"loading"===e.bootStatus,f=e.boot?.project.cwd,[b,v]=(0,i.useState)(null),j=(0,i.useCallback)(async()=>{try{let e=await (0,el.tm)((0,Q.fL)("/api/visualizer",f));if(!e.ok)return;let t=await e.json();t.totals&&v(t.totals)}catch{}},[f]);return(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{j()},0),t=window.setInterval(()=>{j()},3e4);return()=>{window.clearTimeout(e),window.clearInterval(t)}},[j]),(0,r.jsxs)("div",{className:"flex h-7 items-center justify-between border-t border-border bg-card px-2 md:px-3 text-[10px] md:text-xs",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2 md:gap-4",children:[(0,r.jsxs)("div",{className:`flex items-center gap-1.5 ${function(e){switch(e){case"success":return"text-success";case"warning":return"text-warning";case"danger":return"text-destructive";default:return"text-muted-foreground"}}(t.tone)}`,children:[(0,r.jsx)(eO.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:t.label})]}),(0,r.jsxs)("div",{className:"hidden sm:flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(C.A,{className:"h-3 w-3"}),g?(0,r.jsx)(eo,{className:"h-3 w-20"}):(0,r.jsx)("span",{className:"font-mono tabular-nums",children:n})]}),(0,r.jsxs)("div",{className:"hidden lg:flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(ez.A,{className:"h-3 w-3"}),g?(0,r.jsx)(eo,{className:"h-3 w-24"}):(0,r.jsx)("span",{className:"font-mono",children:o})]}),!g&&(0,r.jsxs)("div",{className:"hidden max-w-xs items-center gap-1.5 truncate text-muted-foreground xl:flex","data-testid":"status-bar-retry-compaction",children:[(0,r.jsx)(F.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:m.retryInProgress?`Retry ${Math.max(1,m.retryAttempt)}`:m.isCompacting?"Compacting":m.freshness})]}),!g&&(0,r.jsxs)("div",{className:(0,M.cn)("hidden items-center gap-1.5 xl:flex",h>0?"text-warning":"text-muted-foreground"),"data-testid":"status-bar-validation-count",children:[(0,r.jsx)(eG.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsxs)("span",{children:[h," issue",1===h?"":"s"]})]}),!g&&d&&(0,r.jsxs)("div",{className:"hidden max-w-sm items-center gap-1.5 truncate text-destructive lg:flex","data-testid":"status-bar-error",children:[(0,r.jsx)(eG.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:d})]}),!g&&c&&(0,r.jsxs)("div",{className:"hidden max-w-xs items-center gap-1.5 truncate text-foreground/80 xl:flex","data-testid":"status-bar-title-override",children:[(0,r.jsx)(eW.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate",title:c,children:c})]}),!g&&p&&!d&&(0,r.jsxs)("div",{className:"hidden max-w-xs items-center gap-1.5 truncate text-muted-foreground lg:flex","data-testid":"status-bar-extension-status",children:[(0,r.jsx)(eW.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:p})]})]}),(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2 md:gap-4",children:[(0,r.jsxs)("div",{className:"hidden sm:flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(ef.A,{className:"h-3 w-3"}),g?(0,r.jsx)(eo,{className:"h-3 w-8"}):(0,r.jsx)("span",{className:"tabular-nums",children:(0,eK.a3)(b?.duration??a?.elapsed??0)})]}),(0,r.jsxs)("div",{className:"hidden sm:flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(ev.A,{className:"h-3 w-3"}),g?(0,r.jsx)(eo,{className:"h-3 w-6"}):(0,r.jsx)("span",{className:"tabular-nums",children:(0,eK.ap)(b?.tokens.total??a?.totalTokens??0)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(eb.A,{className:"h-3 w-3"}),g?(0,r.jsx)(eo,{className:"h-3 w-10"}):(0,r.jsx)("span",{className:"tabular-nums",children:(0,eK.BD)(b?.cost??a?.totalCost??0)})]}),(0,r.jsx)("span",{className:"hidden sm:inline max-w-[20rem] truncate text-muted-foreground","data-testid":"status-bar-unit",children:g?(0,r.jsx)(eo,{className:"inline-block h-3 w-28 align-middle"}):(0,r.jsx)(eR,{label:l})})]})]})}var eH=s(87895),eY=s(18239),eJ=s(53195),eZ=s(12406),eQ=s(81848),eX=s(67238),e0=s(75596);function e1({className:e,...t}){return(0,r.jsx)(e0.bL,{"data-slot":"checkbox",className:(0,M.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:(0,r.jsx)(e0.C1,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:(0,r.jsx)(eX.A,{className:"size-3.5"})})})}var e5=s(43106);function e2({...e}){return(0,r.jsx)(L.bL,{"data-slot":"sheet",...e})}function e3({...e}){return(0,r.jsx)(L.ZL,{"data-slot":"sheet-portal",...e})}function e4({className:e,...t}){return(0,r.jsx)(L.hJ,{"data-slot":"sheet-overlay",className:(0,M.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function e8({className:e,children:t,side:s="right",...a}){return(0,r.jsxs)(e3,{children:[(0,r.jsx)(e4,{}),(0,r.jsx)(L.UC,{"data-slot":"sheet-content",className:(0,M.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===s&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===s&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===s&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===s&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...a,children:t})]})}function e6({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"sheet-header",className:(0,M.cn)("flex flex-col gap-1.5 p-4",e),...t})}function e7({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"sheet-footer",className:(0,M.cn)("mt-auto flex flex-col gap-2 p-4",e),...t})}function e9({className:e,...t}){return(0,r.jsx)(L.hE,{"data-slot":"sheet-title",className:(0,M.cn)("text-foreground font-semibold",e),...t})}function te({className:e,...t}){return(0,r.jsx)(L.VY,{"data-slot":"sheet-description",className:(0,M.cn)("text-muted-foreground text-sm",e),...t})}function tt({className:e,...t}){return(0,r.jsx)("textarea",{"data-slot":"textarea",className:(0,M.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}var ts=s(94002);function tr(e){switch(e){case"select":return"Selection";case"confirm":return"Confirmation";case"input":return"Input";case"editor":return"Editor"}return e}function ta({request:e,onSubmit:t,disabled:s}){let a=!!e.allowMultiple,[n,o]=(0,i.useState)(()=>(0,ts.cv)(0,e.options.length)),[l,d]=(0,i.useState)(()=>new Set),c=(0,i.useRef)(null);(0,i.useEffect)(()=>{a||requestAnimationFrame(()=>c.current?.focus())},[a]);let u=()=>{if(a)t({value:Array.from(l)});else{let s=e.options[n];s&&t({value:s})}},m=(0,i.useCallback)(r=>{let a=e.options[r];a&&!s&&(o(r),t({value:a}))},[s,t,e.options]),h=(0,i.useCallback)(t=>{if(s)return;let r=(0,ts.cZ)(t.key,n,e.options.length);if("none"!==r.type){if(t.preventDefault(),t.stopPropagation(),"select"===r.type)return void o(r.index);m(r.index)}},[s,e.options.length,n,m]),x=a?l.size>0:n>=0;return a?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"space-y-2",children:e.options.map((e,t)=>(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5 transition-colors hover:bg-accent/40",children:[(0,r.jsx)(e1,{checked:l.has(e),onCheckedChange:t=>{let s=new Set(l);t?s.add(e):s.delete(e),d(s)},disabled:s}),(0,r.jsx)("span",{className:"text-sm",children:e})]},`${e}-${t}`))}),(0,r.jsxs)(J,{onClick:u,disabled:s||!x,className:"w-full",children:[(0,r.jsx)(eQ.A,{className:"h-4 w-4"}),"Submit selection (",l.size,")"]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{ref:c,role:"listbox",tabIndex:0,"aria-activedescendant":n>=0?`focused-select-option-${n}`:void 0,onKeyDown:h,className:"space-y-2 rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-ring",children:e.options.map((e,t)=>{let a=t===n;return(0,r.jsxs)("button",{id:`focused-select-option-${t}`,type:"button",role:"option","aria-selected":a,onClick:()=>m(t),disabled:s,className:(0,M.cn)("flex w-full cursor-pointer items-center gap-3 rounded-lg border bg-background px-3 py-2.5 text-left text-sm transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",a?"border-primary/40 bg-primary/10 text-primary":"border-border hover:bg-accent/40",s&&"cursor-not-allowed opacity-60"),children:[(0,r.jsx)("span",{className:"w-4 shrink-0 text-center font-mono text-[11px] text-muted-foreground",children:t+1}),(0,r.jsx)("span",{className:"min-w-0 flex-1",children:e}),a&&(0,r.jsx)(eX.A,{className:"h-4 w-4 shrink-0"})]},`${e}-${t}`)})}),(0,r.jsxs)(J,{onClick:u,disabled:s||!x,className:"w-full",children:[(0,r.jsx)(eQ.A,{className:"h-4 w-4"}),"Submit"]})]})}function tn({request:e,onSubmit:t,onCancel:s,disabled:a}){return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"rounded-lg border border-border bg-background px-4 py-3 text-sm leading-relaxed",children:e.message}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsx)(J,{onClick:()=>t({value:!0}),disabled:a,className:"flex-1",children:"Confirm"}),(0,r.jsx)(J,{onClick:s,disabled:a,variant:"outline",className:"flex-1",children:"Cancel"})]})]})}function ti({request:e,onSubmit:t,disabled:s}){let[a,n]=(0,i.useState)("");return(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),a.trim()&&t({value:a})},children:[(0,r.jsx)(e5.p,{value:a,onChange:e=>n(e.target.value),placeholder:e.placeholder||"Enter a value",disabled:s,autoFocus:!0}),(0,r.jsxs)(J,{type:"submit",disabled:s||!a.trim(),className:"w-full",children:[(0,r.jsx)(eQ.A,{className:"h-4 w-4"}),"Submit"]})]})}function to({request:e,onSubmit:t,disabled:s}){let[a,n]=(0,i.useState)(e.prefill||"");return(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),t({value:a})},children:[(0,r.jsx)(tt,{value:a,onChange:e=>n(e.target.value),disabled:s,className:"min-h-[200px] font-mono text-sm",autoFocus:!0}),(0,r.jsxs)(J,{type:"submit",disabled:s,className:"w-full",children:[(0,r.jsx)(eQ.A,{className:"h-4 w-4"}),"Submit"]})]})}function tl({request:e,onSubmit:t,onCancel:s,disabled:a}){switch(e.method){case"select":return(0,r.jsx)(ta,{request:e,onSubmit:t,disabled:a});case"confirm":return(0,r.jsx)(tn,{request:e,onSubmit:t,onCancel:s,disabled:a});case"input":return(0,r.jsx)(ti,{request:e,onSubmit:t,disabled:a});case"editor":return(0,r.jsx)(to,{request:e,onSubmit:t,disabled:a})}}function td(){let e=(0,Q.gF)(),{respondToUiRequest:t,dismissUiRequest:s}=(0,Q._l)(),a=e.pendingUiRequests,n=a.length>0,i=a[0]??null,o="extension_ui_response"===e.commandInFlight,l=()=>{i&&s(i.id)};return(0,r.jsx)(e2,{open:n,onOpenChange:e=>{e||o||!i||l()},children:(0,r.jsx)(e8,{side:"right",className:"flex flex-col sm:max-w-md","data-testid":"focused-panel",children:i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e6,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[function(e){switch(e){case"select":return(0,r.jsx)(eH.A,{className:"h-4 w-4"});case"confirm":return(0,r.jsx)(eY.A,{className:"h-4 w-4"});case"input":return(0,r.jsx)(eJ.A,{className:"h-4 w-4"});case"editor":return(0,r.jsx)(eZ.A,{className:"h-4 w-4"})}}(i.method),(0,r.jsx)(e9,{children:i.title||tr(i.method)})]}),(0,r.jsx)(te,{children:(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{children:[tr(i.method)," requested by the agent"]}),a.length>1&&(0,r.jsxs)("span",{className:(0,M.cn)("inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-foreground px-1.5 text-[11px] font-semibold text-background"),"data-testid":"focused-panel-queue-badge",children:["+",a.length-1]})]})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-2",children:(0,r.jsx)(tl,{request:i,onSubmit:e=>{i&&t(i.id,e)},onCancel:l,disabled:o},i.id)}),(0,r.jsx)(e7,{children:(0,r.jsx)(J,{variant:"ghost",size:"sm",onClick:l,disabled:o,className:"text-muted-foreground",children:"Dismiss"})})]})})})}let tc="1"===s(42130).env.NEXT_PUBLIC_GSD_DEV,tu=[{key:"forceOnboarding",label:"Onboarding wizard",description:"Force the onboarding gate to render even when credentials are valid",shortcutLabel:"Ctrl+Shift+1"}],tm={forceOnboarding:!1},th=(0,i.createContext)(null);function tx({children:e}){let[t,s]=(0,i.useState)(!1),[a,n]=(0,i.useState)(tm),[o,l]=(0,i.useState)(tc);(0,i.useEffect)(()=>{(0,el.tm)("/api/dev-mode",{cache:"no-store"}).then(e=>e.json()).then(e=>{e.isDevMode&&l(!0)}).catch(()=>{})},[]);let d=(0,i.useCallback)(e=>{n(t=>({...t,[e]:!t[e]}))},[]),c=(0,i.useCallback)(e=>t&&a[e],[t,a]);(0,i.useEffect)(()=>{if(o)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e);function e(e){t&&e.ctrlKey&&e.shiftKey&&"1"===e.key&&(e.preventDefault(),n(e=>({...e,forceOnboarding:!e.forceOnboarding})))}},[t,o]);let u=(0,i.useMemo)(()=>o?{isDevMode:o,enabled:t,setEnabled:s,overrides:a,toggle:d,isActive:c}:{isDevMode:!1,enabled:!1,setEnabled:()=>{},overrides:tm,toggle:()=>{},isActive:()=>!1},[o,t,s,a,d,c]);return(0,r.jsx)(th.Provider,{value:u,children:e})}function tp(){let e=(0,i.useContext)(th);if(!e)throw Error("useDevOverrides must be used within <DevOverridesProvider>");return e}var tg=s(61415);function tf({onNext:e}){return(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsxs)(c.P.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.6,bounce:0},className:"relative",children:[(0,r.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-foreground/5 blur-2xl"}),(0,r.jsxs)("div",{className:"relative mb-4 flex h-18 items-center justify-center",children:[(0,r.jsx)(a.default,{src:"/logo-white.svg",alt:"GSD-Pi Web",height:70,width:200,className:"hidden dark:block"}),(0,r.jsx)(a.default,{src:"/logo-black.svg",alt:"GSD-Pi Web",height:70,width:200,className:"dark:hidden"})]})]}),(0,r.jsx)(c.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.16,duration:.4},className:"max-w-sm text-[15px] leading-relaxed text-muted-foreground",children:"Let's get your workspace ready. This takes about a minute."}),(0,r.jsx)(c.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.24,duration:.4},className:"mt-10 flex items-center gap-3 text-xs text-muted-foreground",children:["Mode","Provider","Auth","Workspace"].map((e,t)=>(0,r.jsxs)("span",{className:"flex items-center gap-3",children:[t>0&&(0,r.jsx)("span",{className:"h-px w-5 bg-border"}),(0,r.jsx)("span",{className:"font-medium",children:e})]},e))}),(0,r.jsx)(c.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.35,duration:.4},className:"mt-10",children:(0,r.jsxs)(J,{size:"lg",className:"group gap-2.5 px-8 text-[15px] transition-transform active:scale-[0.96]",onClick:e,"data-testid":"onboarding-start",children:["Get started",(0,r.jsx)(eD.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})})]})}var tb=s(14987),tv=s(67552);let tj=[{id:"expert",label:"Expert",icon:tb.A,tagline:"Full control",description:"Dashboard metrics, dual-pane power mode, and direct /gsd command access. Built for people who want visibility into every milestone and task."},{id:"vibe-coder",label:"Vibe Coder",icon:tv.A,tagline:"Just chat",description:"Conversational interface with the AI agent. Describe what you want and let GSD handle the structure. Same engine, friendlier surface."}];function ty({selected:e,onSelect:t,onNext:s,onBack:a}){return(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsx)(c.P.h2,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",style:{textWrap:"balance"},children:"How do you want to work?"}),(0,r.jsx)(c.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.06,duration:.4},className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:"You can switch anytime from settings."}),(0,r.jsx)(c.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.12,duration:.45},className:"mt-8 grid w-full max-w-lg gap-3 sm:grid-cols-2",children:tj.map(s=>{let a=e===s.id,n=s.icon;return(0,r.jsxs)("button",{type:"button",onClick:()=>t(s.id),className:(0,M.cn)("group relative flex flex-col rounded-xl border px-5 py-5 text-left transition-[background-color,border-color,box-shadow,transform] duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.96]",a?"border-foreground/30 bg-foreground/[0.06] shadow-[0_0_0_1px_rgba(255,255,255,0.06)]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),"data-testid":`onboarding-mode-${s.id}`,children:[(0,r.jsx)("div",{className:"absolute right-3.5 top-3.5",children:(0,r.jsx)("div",{className:(0,M.cn)("flex h-5 w-5 items-center justify-center rounded-full border-[1.5px] transition-[background-color,border-color] duration-200",a?"border-foreground bg-foreground":"border-foreground/20"),children:a&&(0,r.jsx)(c.P.svg,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",duration:.3,bounce:0},viewBox:"0 0 12 12",className:"h-2.5 w-2.5 text-background",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"2.5 6 5 8.5 9.5 3.5"})})})}),(0,r.jsx)("div",{className:(0,M.cn)("mb-4 flex h-10 w-10 items-center justify-center rounded-lg transition-colors duration-200",a?"bg-foreground/10":"bg-foreground/[0.04]"),children:(0,r.jsx)(n,{className:(0,M.cn)("h-5 w-5 transition-colors duration-200",a?"text-foreground":"text-muted-foreground"),strokeWidth:1.5})}),(0,r.jsxs)("div",{className:"pr-7",children:[(0,r.jsx)("span",{className:"text-[15px] font-semibold text-foreground",children:s.label}),(0,r.jsx)("span",{className:(0,M.cn)("ml-2 text-xs font-medium transition-colors duration-200","text-muted-foreground"),children:s.tagline})]}),(0,r.jsx)("p",{className:"mt-2 text-[13px] leading-relaxed text-muted-foreground",children:s.description})]},s.id)})}),(0,r.jsxs)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2,duration:.3},className:"mt-8 flex w-full max-w-lg items-center justify-between",children:[(0,r.jsx)(J,{variant:"ghost",onClick:a,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,r.jsxs)(J,{onClick:s,disabled:!e,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-mode-continue",children:["Continue",(0,r.jsx)(eD.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tw=s(78986);let tN=(0,H.F)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function tS({className:e,variant:t,asChild:s=!1,...a}){let n=s?V.DX:"span";return(0,r.jsx)(n,{"data-slot":"badge",className:(0,M.cn)(tN({variant:t}),e),...a})}var tk=s(97019);function tC({providers:e,selectedId:t,onSelect:s,onNext:a,onBack:n}){let o=(0,i.useMemo)(()=>{let t,s,r,a;return t=e.filter(e=>e.configured),s=e.filter(e=>!e.configured&&e.recommended),r=e.filter(e=>!e.configured&&!e.recommended),a=[],t.length>0&&a.push({label:"Configured",items:t}),s.length>0&&a.push({label:"Recommended",items:s}),r.length>0&&a.push({label:"Other Providers",items:r}),a},[e]),l=e.some(e=>e.configured);return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Choose a provider"}),(0,r.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground",children:"Click a provider to configure it. Set up as many as you want, then continue."})]}),(0,r.jsx)(c.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.08,duration:.45},className:"mt-8 w-full space-y-5",children:o.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 px-0.5 text-[11px] font-medium uppercase tracking-widest text-muted-foreground",children:e.label}),(0,r.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:e.items.map(e=>{let a,n=e.id===t;return(0,r.jsxs)("button",{type:"button",onClick:()=>s(e.id),className:(0,M.cn)("group relative rounded-xl border px-4 py-3.5 text-left transition-[background-color,border-color,box-shadow,transform] duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.96]",n?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),"data-testid":`onboarding-provider-${e.id}`,children:[(0,r.jsx)("div",{className:"absolute right-3 top-3",children:(0,r.jsx)("div",{className:(0,M.cn)("flex h-5 w-5 items-center justify-center rounded-full border-[1.5px] transition-[background-color,border-color] duration-200",n?"border-foreground bg-foreground":"border-foreground/15"),children:n&&(0,r.jsx)(eX.A,{className:"h-2.5 w-2.5 text-background",strokeWidth:3})})}),(0,r.jsxs)("div",{className:"pr-8",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground",children:e.label}),e.recommended&&(0,r.jsx)(tS,{variant:"outline",className:"border-foreground/10 bg-foreground/[0.03] text-[9px] text-muted-foreground",children:"Recommended"})]}),(0,r.jsx)("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-muted-foreground",children:e.configured?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tw.A,{className:"h-3 w-3 text-success/80"}),(0,r.jsx)("span",{children:function(e){switch(e){case"auth_file":return"Saved auth";case"environment":return"Environment variable";case"runtime":return"Runtime";case"external_cli":return"CLI";default:return"Not configured"}}(e.configuredVia)})]}):(0,r.jsx)("span",{className:"text-muted-foreground",children:"Not configured"})})]}),(0,r.jsx)("div",{className:"mt-2.5 flex flex-wrap gap-1",children:(a=[],e.supports.apiKey&&a.push("API key"),e.supports.oauth&&a.push(e.supports.oauthAvailable?"Browser sign-in":"OAuth unavailable"),e.supports.externalCli&&a.push("CLI auth"),a).map(e=>(0,r.jsxs)(tk.m_,{children:[(0,r.jsx)(tk.k$,{asChild:!0,children:(0,r.jsx)(tS,{variant:"outline",className:"border-border/50 text-[10px] text-muted-foreground",children:e})}),(0,r.jsx)(tk.ZI,{side:"bottom",children:"API key"===e?"Enter an API key to authenticate":"Browser sign-in"===e?"Authenticate through your browser":"CLI auth"===e?"Authenticated via local CLI — no API key needed":"This auth method is not available"})]},e))})]},e.id)})})]},e.label))}),(0,r.jsxs)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.15,duration:.3},className:"mt-8 flex w-full items-center justify-between",children:[(0,r.jsx)(J,{variant:"ghost",onClick:n,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,r.jsxs)(J,{onClick:a,disabled:!l,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-provider-continue",children:["Continue",(0,r.jsx)(eD.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tA=s(6172),tT=s(52472),tP=s(79464),tR=s(60510),tE=s(86848),t_=s(16579),tF=s(8291),tI=s(69444);function t$({className:e,value:t,...s}){return(0,r.jsx)(tI.bL,{"data-slot":"progress",className:(0,M.cn)("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",e),...s,children:(0,r.jsx)(tI.C1,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-transform",style:{transform:`translateX(-${100-(t||0)}%)`}})})}function tD({provider:e,activeFlow:t,lastValidation:s,requestState:a,requestProviderId:n,onSaveApiKey:o,onStartFlow:l,onSubmitFlowInput:m,onCancelFlow:h,onBack:x,onNext:p,bridgeRefreshPhase:g,bridgeRefreshError:f}){let[b,v]=(0,i.useState)(""),[j,y]=(0,i.useState)(""),[w,N]=(0,i.useState)(!1),S="idle"!==a,k=n===e.id&&S,C=e.supports.externalCli,A=s?.status==="succeeded"&&s.providerId===e.id,T=C&&e.configured||A&&("succeeded"===g||"idle"===g),P=s?.status==="failed"&&s.providerId===e.id,R=P?function(e){if(!e)return{title:"Validation failed",detail:null};let t=e.match(/^\d{3}\s+[^:]+:\s*(.+)$/s),s=t?.[1]??e;try{let e=JSON.parse(s);if("object"==typeof e&&null!==e){let t=e.error_details?.message??e.error?.message??e.message??e.error??null;if("string"==typeof t&&t.length>0){if(/subscription.*(ended|expired|cancelled)/i.test(t))return{title:"Subscription expired",detail:t.replace(/\.$/,"")+". Check your plan status with this provider."};if(/rate.limit/i.test(t))return{title:"Rate limited",detail:"Too many requests. Wait a moment and try again."};if(/invalid.*key|invalid.*token|incorrect.*key/i.test(t))return{title:"Invalid credentials",detail:"The API key was rejected. Double-check and try again."};if(/quota|billing|payment/i.test(t))return{title:"Billing issue",detail:t};return{title:"Provider error",detail:t}}}}catch{}return/^401\b/i.test(e)?{title:"Unauthorized",detail:"The credentials were rejected. Double-check your API key."}:/^403\b/i.test(e)?{title:"Access denied",detail:"Your account doesn't have access. Check your subscription or permissions."}:/^429\b/i.test(e)?{title:"Rate limited",detail:"Too many requests. Wait a moment and try again."}:/^5\d{2}\b/i.test(e)?{title:"Server error",detail:"The provider returned an error. Try again in a minute."}:{title:"Validation failed",detail:e.length>200?e.slice(0,200)+"…":e}}(s.message):null;e.supports.apiKey||e.supports.oauth;let E=e.supports.oauth&&e.supports.oauthAvailable,_=e.supports.apiKey,F=t&&t.providerId===e.id&&!T,$=F&&"failed"===t.status,D=F&&("running"===t.status||"awaiting_browser_auth"===t.status),L=F&&"awaiting_input"===t.status,M=F?function(e){for(let t of[e.prompt?.message,e.auth?.instructions].filter(Boolean)){let e=t?.match(/(?:code|Code)[:\s]+([A-Z0-9]{4}[-–][A-Z0-9]{4})/i);if(e)return e[1]}return null}(t):null;return(0,i.useEffect)(()=>{if(s?.status!=="succeeded")return;let e=window.setTimeout(()=>v(""),0);return()=>window.clearTimeout(e)},[s?.checkedAt,s?.status]),(0,i.useEffect)(()=>{let e=window.setTimeout(()=>y(""),0);return()=>window.clearTimeout(e)},[t?.flowId]),(0,i.useEffect)(()=>{if(!w)return;let e=window.setTimeout(()=>N(!1),2e3);return()=>window.clearTimeout(e)},[w]),(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,r.jsxs)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:["Connect ",e.label]}),(0,r.jsx)("p",{className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:T?"Authenticated and ready to go.":C?"Authentication is handled by the Claude CLI. Make sure it is installed and signed in.":_&&E?"Paste an API key or sign in through your browser.":_?"Paste your API key to authenticate.":"Sign in through your browser to authenticate."})]}),(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.08,duration:.45},className:"mt-8 w-full max-w-md space-y-4",children:[(0,r.jsx)(d.N,{children:T&&(0,r.jsxs)(c.P.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.4,bounce:0},className:"flex flex-col items-center gap-3 rounded-xl border border-success/15 bg-success/[0.04] px-6 py-6 text-center",children:[(0,r.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-success/15",children:(0,r.jsx)(tw.A,{className:"h-5 w-5 text-success"})}),(0,r.jsxs)("div",{className:"text-sm font-medium text-foreground",children:[e.label," authenticated"]})]})}),P&&R&&(0,r.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm",children:[(0,r.jsx)(tA.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-medium text-destructive",children:R.title}),R.detail&&(0,r.jsx)("div",{className:"mt-0.5 text-muted-foreground",children:R.detail})]})]}),"pending"===g&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border border-foreground/10 bg-foreground/[0.03] px-4 py-3 text-sm text-foreground/80",children:[(0,r.jsx)(I.A,{className:"h-4 w-4 shrink-0 animate-spin"}),"Connecting to provider…"]}),(0,r.jsx)(t$,{value:66,className:"h-1"})]}),"failed"===g&&f&&(0,r.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm",children:[(0,r.jsx)(tA.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-medium text-destructive",children:"Connection failed"}),(0,r.jsx)("div",{className:"mt-0.5 text-muted-foreground",children:f})]})]}),_&&!T&&(0,r.jsxs)("div",{className:"space-y-3 rounded-xl border border-border/50 bg-card/50 p-4",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"API key"}),(0,r.jsxs)("form",{className:"space-y-3",onSubmit:async t=>{if(t.preventDefault(),!b.trim())return;let s=await o(e.id,b);s&&!s.locked&&("succeeded"===s.bridgeAuthRefresh.phase||"idle"===s.bridgeAuthRefresh.phase)&&p()},children:[(0,r.jsx)(e5.p,{"data-testid":"onboarding-api-key-input",type:"password",autoComplete:"off",value:b,onChange:e=>v(e.target.value),placeholder:`Paste your ${e.label} API key`,disabled:S,className:"font-mono text-sm"}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsxs)(J,{type:"submit",disabled:!b.trim()||S,className:"gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-save-api-key",children:[k&&"saving_api_key"===a?(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(tT.A,{className:"h-4 w-4"}),"Validate & save"]})})]})]}),E&&!T&&(0,r.jsxs)("div",{className:"space-y-3",children:[_&&(0,r.jsxs)("div",{className:"flex items-center gap-3 py-1",children:[(0,r.jsx)("div",{className:"h-px flex-1 bg-border/50"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"or"}),(0,r.jsx)("div",{className:"h-px flex-1 bg-border/50"})]}),!F&&(0,r.jsx)("div",{className:"rounded-xl border border-border/50 bg-card/50 p-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Browser sign-in"}),(0,r.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Opens a new tab to authenticate with ",e.label]})]}),(0,r.jsxs)(J,{variant:"outline",disabled:S,onClick:()=>l(e.id),className:"shrink-0 gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-start-provider-flow",children:[k&&"starting_provider_flow"===a?(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(tP.A,{className:"h-4 w-4"}),"Sign in"]})]})}),F&&(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"rounded-xl border border-border/50 bg-card/50 p-4 space-y-4","data-testid":"onboarding-active-flow",children:[M&&(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 py-2",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"Enter this code on the sign-in page"}),(0,r.jsxs)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(M).then(()=>N(!0)).catch(()=>{})},className:"group flex items-center gap-3 rounded-lg border border-border bg-background/50 px-5 py-3 transition-[border-color,transform] hover:border-foreground/20 active:scale-[0.96]",children:[(0,r.jsx)("span",{className:"font-mono text-2xl font-bold tracking-[0.15em] text-foreground",children:M}),(0,r.jsx)("span",{className:"text-muted-foreground transition-colors group-hover:text-muted-foreground",children:w?(0,r.jsx)(u.A,{className:"h-4 w-4 text-success"}):(0,r.jsx)(tR.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground",children:w?"Copied!":"Click to copy"})]}),!M&&t.auth?.instructions&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:t.auth.instructions}),t.auth?.url&&(0,r.jsx)(J,{asChild:!0,className:"w-full gap-2 transition-transform active:scale-[0.96]",children:(0,r.jsxs)("a",{href:t.auth.url,target:"_blank",rel:"noreferrer",children:[(0,r.jsx)(tE.A,{className:"h-4 w-4"}),"Open sign-in page"]})}),(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}),(0,r.jsx)("span",{children:"Waiting for authentication…"})]}),$&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t_.A,{className:"h-3 w-3 text-destructive"}),(0,r.jsx)("span",{className:"text-destructive",children:"Sign-in failed or timed out"})]}),L&&!M&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}),(0,r.jsx)("span",{children:"Waiting for input…"})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[$&&(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(e.id),disabled:S,className:"h-7 gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(tF.A,{className:"h-3 w-3"}),"Retry"]}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(t.flowId),disabled:S,className:"h-7 text-xs text-muted-foreground",children:"Cancel"})]})]}),t.prompt&&!M&&(0,r.jsxs)("form",{className:"space-y-2 border-t border-border/50 pt-3",onSubmit:e=>{e.preventDefault(),(t.prompt?.allowEmpty||j.trim())&&m(t.flowId,j)},children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:t.prompt.message}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(e5.p,{"data-testid":"onboarding-flow-input",value:j,onChange:e=>y(e.target.value),placeholder:t.prompt.placeholder||"Enter value",disabled:S,className:"text-sm"}),(0,r.jsx)(J,{type:"submit",disabled:S||!t.prompt.allowEmpty&&!j.trim(),className:"shrink-0 transition-transform active:scale-[0.96]",children:"submitting_provider_flow_input"===a?(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}):"Submit"})]})]}),t.progress.length>0&&(0,r.jsx)("div",{className:"space-y-1 border-t border-border/50 pt-3",children:t.progress.map((e,s)=>(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:e},`${t.flowId}-${s}`))})]})]}),e.supports.oauth&&!e.supports.oauthAvailable&&!_&&(0,r.jsx)("div",{className:"rounded-xl border border-border/50 bg-card/50 px-4 py-3.5 text-sm text-muted-foreground",children:"Browser sign-in is not available in this runtime. Go back and choose a provider with API-key support."})]}),(0,r.jsxs)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.15,duration:.3},className:"mt-8 flex w-full max-w-md items-center justify-between",children:[(0,r.jsx)(J,{variant:"ghost",onClick:x,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,r.jsxs)(J,{onClick:p,disabled:!T,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-auth-continue",children:["Configure another provider",(0,r.jsx)(eD.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tL=s(7747),tM=s(85221),tq=s(99237);function tB({className:e,children:t,viewportRef:s,...a}){return(0,r.jsxs)(tq.bL,{"data-slot":"scroll-area",className:(0,M.cn)("relative",e),...a,children:[(0,r.jsx)(tq.LM,{ref:s,"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),(0,r.jsx)(tU,{}),(0,r.jsx)(tq.OK,{})]})}function tU({className:e,orientation:t="vertical",...s}){return(0,r.jsx)(tq.VM,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,M.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,r.jsx)(tq.lr,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}let tO=["~/Projects","~/Developer","~/Code","~/dev"];function tz({onSelect:e,onCancel:t}){let[s,a]=(0,i.useState)(""),[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)([]),[c,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),x=(0,i.useCallback)(async e=>{u(!0),h(null);try{let t=e?`?path=${encodeURIComponent(e)}`:"",s=await (0,el.tm)(`/api/browse-directories${t}`);if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`${s.status}`)}let r=await s.json();a(r.current),o(r.parent),d(r.entries)}catch(e){h(e instanceof Error?e.message:"Failed to browse")}finally{u(!1)}},[]);return(0,i.useEffect)(()=>{x()},[x]),(0,r.jsxs)("div",{className:"rounded-xl border border-border/50 bg-card/50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border/50 px-4 py-2.5",children:[(0,r.jsx)("p",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",title:s,children:s}),(0,r.jsx)(J,{type:"button",size:"sm",onClick:()=>e(s),className:"shrink-0 h-7 gap-1.5 text-xs transition-transform active:scale-[0.96]",children:"Select this folder"})]}),(0,r.jsx)(tB,{className:"h-[240px]",children:(0,r.jsxs)("div",{className:"px-1.5 py-1",children:[c&&(0,r.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),m&&(0,r.jsx)("div",{className:"px-3 py-4 text-center text-xs text-destructive",children:m}),!c&&!m&&(0,r.jsxs)(r.Fragment,{children:[n&&(0,r.jsxs)("button",{type:"button",onClick:()=>void x(n),className:"flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50",children:[(0,r.jsx)(tL.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-muted-foreground",children:".."})]}),l.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>void x(e.path),className:"group flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50",children:[(0,r.jsx)(w.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:e.name}),(0,r.jsx)(E.A,{className:"h-3 w-3 shrink-0 text-muted-foreground/50 opacity-0 transition-opacity group-hover:opacity-100"})]},e.path)),0===l.length&&!n&&(0,r.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"No subdirectories"})]})]})}),(0,r.jsx)("div",{className:"border-t border-border/50 px-4 py-2",children:(0,r.jsx)(J,{type:"button",variant:"ghost",size:"sm",onClick:t,className:"h-7 text-xs text-muted-foreground",children:"Cancel"})})]})}function tG({onNext:e,onBack:t}){let[s,a]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[l,u]=(0,i.useState)(null),[m,x]=(0,i.useState)(!1),p=(0,i.useCallback)(e=>{a(e),u(null)},[]),g=(0,i.useCallback)(async()=>{let t=s.trim();if(!t)return void u("Enter a path or skip this step");o(!0),u(null);try{let s=await (0,el.tm)("/api/preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`Request failed (${s.status})`)}e()}catch(e){u(e instanceof Error?e.message:"Failed to save preference")}finally{o(!1)}},[s,e]);return(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsx)(c.P.div,{initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.5,bounce:0},className:"mb-8",children:(0,r.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-xl border border-border/50 bg-card/50",children:(0,r.jsx)(tM.A,{className:"h-7 w-7 text-foreground/80",strokeWidth:1.5})})}),(0,r.jsx)(c.P.h2,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.06,duration:.4},className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Dev root"}),(0,r.jsx)(c.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.12,duration:.4},className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:"The folder that contains your projects. GSD discovers and manages workspaces inside it."}),(0,r.jsx)(c.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.18,duration:.45},className:"mt-8 w-full max-w-md space-y-4",children:(0,r.jsx)(d.N,{mode:"wait",children:m?(0,r.jsx)(c.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},children:(0,r.jsx)(tz,{onSelect:e=>{a(e),x(!1),u(null)},onCancel:()=>x(!1)})},"browser"):(0,r.jsxs)(c.P.div,{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(e5.p,{value:s,onChange:e=>{a(e.target.value),l&&u(null)},placeholder:"/Users/you/Projects",className:(0,M.cn)("h-11 flex-1 font-mono text-sm",l&&"border-destructive/50 focus-visible:ring-destructive/30"),"data-testid":"onboarding-devroot-input",autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&s.trim()&&g()}}),(0,r.jsxs)(J,{type:"button",variant:"outline",onClick:()=>x(!0),className:"h-11 gap-2 shrink-0 transition-transform active:scale-[0.96]",children:[(0,r.jsx)(eE.A,{className:"h-4 w-4"}),"Browse"]})]}),l&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:l}),(0,r.jsx)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:tO.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>p(e),className:(0,M.cn)("rounded-full border px-3 py-1 font-mono text-xs transition-[background-color,border-color,color,transform] duration-150","active:scale-[0.96]",s===e?"border-foreground/25 bg-foreground/10 text-foreground":"border-border/50 text-muted-foreground hover:border-foreground/15 hover:text-foreground"),children:e},e))})]},"input")})}),(0,r.jsxs)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25,duration:.3},className:"mt-8 flex w-full max-w-md items-center justify-between",children:[(0,r.jsx)(J,{variant:"ghost",onClick:t,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(J,{variant:"ghost",onClick:e,className:"gap-1.5 text-muted-foreground transition-transform active:scale-[0.96]","data-testid":"onboarding-devroot-skip",children:["Skip",(0,r.jsx)(h.A,{className:"h-3.5 w-3.5"})]}),(0,r.jsx)(J,{onClick:()=>void g(),className:"group gap-2 transition-transform active:scale-[0.96]",disabled:n||m,"data-testid":"onboarding-devroot-continue",children:n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}),"Saving…"]}):(0,r.jsxs)(r.Fragment,{children:["Continue",(0,r.jsx)(eD.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})})]})]})]})}var tW=s(45760);function tK({sections:e,onBack:t,onNext:s}){let a=e.filter(e=>"remote_questions"!==e.id),n=a.filter(e=>e.configured).length;return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Integrations"}),(0,r.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground",children:"Optional tools. Nothing here blocks the workspace — configure later from settings."})]}),n>0&&(0,r.jsx)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.08,duration:.3},className:"mt-4",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-medium text-success",children:n})," of ",a.length," configured"]})}),(0,r.jsx)(c.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.1,duration:.45},className:"mt-8 w-full space-y-2",children:a.map(e=>(0,r.jsxs)("div",{className:(0,M.cn)("flex items-start gap-3.5 rounded-xl border px-4 py-3.5 transition-colors",e.configured?"border-success/15 bg-success/[0.03]":"border-border/50 bg-card/50"),"data-testid":`onboarding-optional-${e.id}`,children:[(0,r.jsx)("div",{className:(0,M.cn)("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full",e.configured?"bg-success/15 text-success":"bg-foreground/[0.05] text-muted-foreground"),children:e.configured?(0,r.jsx)(eX.A,{className:"h-3 w-3",strokeWidth:3}):(0,r.jsx)(tW.A,{className:"h-3 w-3"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,r.jsxs)(tk.m_,{children:[(0,r.jsx)(tk.k$,{asChild:!0,children:(0,r.jsx)(tS,{variant:"outline",className:(0,M.cn)("text-[10px]",e.configured?"border-success/15 text-success/70":"border-border/50 text-muted-foreground"),children:e.configured?"Ready":"Skipped"})}),(0,r.jsx)(tk.ZI,{children:e.configured?"This integration is configured and active":"You can set this up later from workspace settings"})]})]}),e.configuredItems.length>0&&(0,r.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1",children:e.configuredItems.map(e=>(0,r.jsx)(tS,{variant:"outline",className:"border-border/50 text-[10px] text-muted-foreground",children:e},e))}),0===e.configuredItems.length&&(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Not configured — add later from settings."})]})]},e.id))}),(0,r.jsxs)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.18,duration:.3},className:"mt-8 flex w-full items-center justify-between",children:[(0,r.jsx)(J,{variant:"ghost",onClick:t,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,r.jsxs)(J,{onClick:s,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-optional-continue",children:["Continue",(0,r.jsx)(eD.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tV=s(2959),tH=s(64791);let tY=[{value:"slack",label:"Slack",description:"Get notified in a Slack channel"},{value:"discord",label:"Discord",description:"Get notified in a Discord channel"},{value:"telegram",label:"Telegram",description:"Get notified via Telegram bot"}],tJ={slack:"Channel ID (e.g. C01ABCD2EFG)",discord:"Channel ID (17–20 digit number)",telegram:"Chat ID (numeric, may start with -)"},tZ={slack:/^[A-Z0-9]{9,12}$/,discord:/^\d{17,20}$/,telegram:/^-?\d{5,20}$/},tQ={slack:"SLACK_BOT_TOKEN",discord:"DISCORD_BOT_TOKEN",telegram:"TELEGRAM_BOT_TOKEN"};function tX({onBack:e,onNext:t}){let[s,a]=(0,i.useState)(null),[n,o]=(0,i.useState)(""),[l,d]=(0,i.useState)(!1),[m,x]=(0,i.useState)(null),[p,g]=(0,i.useState)(!1),[f,b]=(0,i.useState)(!1),[v,j]=(0,i.useState)(!0),[y,w]=(0,i.useState)(""),[N,S]=(0,i.useState)(!1),[k,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(!1),[P,R]=(0,i.useState)(null);(0,i.useEffect)(()=>{(0,el.tm)("/api/remote-questions",{cache:"no-store"}).then(e=>e.json()).then(e=>{e.tokenSet&&T(!0),"configured"===e.status&&e.config&&(b(!0),a(e.config.channel),o(e.config.channelId),g(!0))}).catch(()=>{}).finally(()=>j(!1))},[]);let E=null!==s&&n.trim().length>0&&tZ[s].test(n.trim()),_=(0,i.useCallback)(async()=>{if(s&&E){d(!0),x(null);try{let e=await (0,el.tm)("/api/remote-questions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:s,channelId:n.trim(),timeoutMinutes:5,pollIntervalSeconds:5})}),t=await e.json();if(!e.ok)return void x(t.error??`Save failed (${e.status})`);g(!0),b(!0)}catch(e){x(e instanceof Error?e.message:"Failed to save")}finally{d(!1)}}},[s,n,E]),F=(0,i.useCallback)(async()=>{if(s&&y.trim()){C(!0),x(null),R(null);try{let e=await (0,el.tm)("/api/remote-questions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:s,token:y.trim()})}),t=await e.json();if(!e.ok)return void x(t.error??`Token save failed (${e.status})`);R(`Token saved (${t.masked})`),T(!0),w(""),S(!1)}catch(e){x(e instanceof Error?e.message:"Failed to save token")}finally{C(!1)}}},[s,y]);return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)(c.P.div,{initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.5,bounce:0},className:"mb-8",children:(0,r.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-xl border border-border/50 bg-card/50",children:(0,r.jsx)(eY.A,{className:"h-7 w-7 text-foreground/80",strokeWidth:1.5})})}),(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.06,duration:.4},className:"text-center",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Remote notifications"}),(0,r.jsx)("p",{className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:"Get notified when GSD needs your input. Connect a chat channel and the agent pings you instead of waiting silently."})]}),(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.12,duration:.45},className:"mt-8 w-full max-w-md space-y-5",children:[p&&(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-3 text-sm",children:[(0,r.jsx)(u.A,{className:"h-4 w-4 shrink-0 text-success"}),(0,r.jsx)("span",{className:"text-muted-foreground",children:f&&!l?`Connected to ${s??"channel"}`:"Configuration saved"})]}),!v&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Channel"}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:tY.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{a(e.value),x(null),p&&!f&&g(!1)},disabled:l,className:(0,M.cn)("rounded-xl border px-3 py-3 text-left transition-[background-color,border-color,box-shadow,transform] duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.96]",s===e.value?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),(0,r.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:e.description})]},e.value))})]}),s&&!v&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Channel ID"}),(0,r.jsx)(e5.p,{value:n,onChange:e=>{o(e.target.value),m&&x(null)},placeholder:tJ[s],disabled:l,className:"font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&E&&_()}}),n.trim().length>0&&!tZ[s].test(n.trim())&&(0,r.jsxs)("p",{className:"text-xs text-destructive/70",children:["Doesn't match the expected format for ",s]})]}),s&&!v&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"text-xs font-medium text-muted-foreground",children:["Bot token",A&&(0,r.jsx)("span",{className:"ml-2 text-success",children:"✓ configured"})]}),P&&(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-xl border border-success/15 bg-success/[0.04] px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-success"}),P]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)(e5.p,{type:N?"text":"password",value:y,onChange:e=>w(e.target.value),placeholder:`Paste your ${tQ[s]}`,disabled:k,className:"pr-9 font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&y.trim()&&F()}}),(0,r.jsx)("button",{type:"button",onClick:()=>S(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-muted-foreground transition-colors",children:N?(0,r.jsx)(tV.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(tH.A,{className:"h-3.5 w-3.5"})})]}),(0,r.jsxs)(J,{type:"button",variant:"outline",onClick:()=>void F(),disabled:!y.trim()||k,className:"gap-1.5 transition-transform active:scale-[0.96]",children:[k?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(tT.A,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),m&&(0,r.jsx)("div",{className:"rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive",children:m}),s&&n.trim().length>0&&!p&&(0,r.jsxs)(J,{onClick:()=>void _(),disabled:!E||l,className:"gap-2 transition-transform active:scale-[0.96]",children:[l?(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(u.A,{className:"h-4 w-4"}),"Save & connect"]}),v&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),"Checking existing configuration…"]})]}),(0,r.jsxs)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2,duration:.3},className:"mt-8 flex w-full max-w-md items-center justify-between",children:[(0,r.jsx)(J,{variant:"ghost",onClick:e,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[!p&&(0,r.jsxs)(J,{variant:"ghost",onClick:t,className:"gap-1.5 text-muted-foreground transition-transform active:scale-[0.96]",children:["Skip",(0,r.jsx)(h.A,{className:"h-3.5 w-3.5"})]}),(0,r.jsxs)(J,{onClick:t,className:"group gap-2 transition-transform active:scale-[0.96]",children:["Continue",(0,r.jsx)(eD.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})]})}function t0({providerLabel:e,onFinish:t}){return(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsxs)(c.P.div,{initial:{opacity:0,scale:.7},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.6,bounce:.15},className:"relative mb-8",children:[(0,r.jsx)("div",{className:"absolute inset-0 rounded-full bg-success/10 blur-2xl"}),(0,r.jsx)("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-2xl border border-success/20 bg-success/10",children:(0,r.jsx)(u.A,{className:"h-8 w-8 text-success",strokeWidth:1.5})})]}),(0,r.jsx)(c.P.h2,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"text-3xl font-bold tracking-tight text-foreground sm:text-4xl",children:"You're all set"}),(0,r.jsxs)(c.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.18,duration:.4},className:"mt-3 max-w-sm text-[15px] leading-relaxed text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:e})," is validated. The workspace is live."]}),(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.26,duration:.4},className:"mt-8 flex items-center gap-4 rounded-xl border border-border/50 bg-card/50 px-5 py-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(a.default,{src:"/logo-icon-white.svg",alt:"",width:14,height:14,className:"hidden opacity-40 dark:block"}),(0,r.jsx)(a.default,{src:"/logo-icon-black.svg",alt:"",width:14,height:14,className:"opacity-40 dark:hidden"}),(0,r.jsx)("span",{children:"Shell unlocked"})]}),(0,r.jsx)("div",{className:"h-3 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-success"}),(0,r.jsx)("span",{children:e})]})]}),(0,r.jsx)(c.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.35,duration:.4},className:"mt-8",children:(0,r.jsxs)(J,{size:"lg",className:"group gap-2.5 px-8 text-[15px] transition-transform active:scale-[0.96]",onClick:t,"data-testid":"onboarding-finish",children:["Launch workspace",(0,r.jsx)(ev.A,{className:"h-4 w-4 transition-transform group-hover:scale-110"})]})})]})}var t1=s(86788),t5=s(96526);let t2={"active-gsd":{label:"Active",color:"text-success",icon:t1.A},"empty-gsd":{label:"Initialized",color:"text-info",icon:eE.A},brownfield:{label:"Existing",color:"text-warning",icon:C.A},"v1-legacy":{label:"Legacy",color:"text-warning",icon:C.A},blank:{label:"New",color:"text-muted-foreground",icon:eF.A}};function t3({onFinish:e,onBack:t,onBeforeSwitch:s}){let a=ei(),[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(!0),[h,x]=(0,i.useState)(null),[p,g]=(0,i.useState)(!1),[f,b]=(0,i.useState)(""),[v,j]=(0,i.useState)(!1),[y,w]=(0,i.useState)(null),N=(0,i.useRef)(null),[S,k]=(0,i.useState)(null),C=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=!1;return async function(){m(!0),x(null);try{let t=await (0,el.tm)("/api/preferences");if(!t.ok)throw Error("Failed to load preferences");let s=await t.json();if(!s.devRoot){o(null),d([]),m(!1);return}o(s.devRoot);let r=await (0,el.tm)(`/api/projects?root=${encodeURIComponent(s.devRoot)}&detail=true`);if(!r.ok)throw Error("Failed to discover projects");let a=await r.json();e||d(a)}catch(t){e||x(t instanceof Error?t.message:"Unknown error")}finally{e||m(!1)}}(),()=>{e=!0}},[]),(0,i.useEffect)(()=>()=>{C.current&&clearInterval(C.current)},[]),(0,i.useEffect)(()=>{if(p){let e=setTimeout(()=>N.current?.focus(),50);return()=>clearTimeout(e)}},[p]);let A=l.map(e=>e.name),T=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(f),P=A.includes(f),R=f.length>0&&T&&!P&&!v,E=(0,i.useCallback)(t=>{s?.(),k(t.path);let r=a.switchProject(t.path);C.current&&clearInterval(C.current);let n=Date.now();C.current=setInterval(()=>{let s=r.getSnapshot(),a=Date.now()-n;("ready"===s.bootStatus||"error"===s.bootStatus||a>3e4)&&(C.current&&clearInterval(C.current),C.current=null,k(null),e(t.path))},150)},[a,e,s]),_=(0,i.useCallback)(async()=>{if(R&&n){j(!0),w(null);try{let e=await (0,el.tm)("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:n,name:f})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Failed (${e.status})`)}let t=await e.json();d(e=>[...e,t].sort((e,t)=>e.name.localeCompare(t.name))),b(""),g(!1),E(t)}catch(e){w(e instanceof Error?e.message:"Failed to create project"),j(!1)}}},[R,n,f,E]),F=!u&&!n,$=[...l].sort((e,t)=>{let s={"active-gsd":0,"empty-gsd":1,brownfield:2,"v1-legacy":3,blank:4},r=s[e.kind]??5,a=s[t.kind]??5;return r!==a?r-a:e.name.localeCompare(t.name)});return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Open a project"}),(0,r.jsx)("p",{className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:F?"Set a dev root first to discover your projects.":"Pick a project to start working in, or create a new one."})]}),(0,r.jsxs)(c.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.08,duration:.45},className:"mt-8 w-full max-w-lg space-y-2",children:[u&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}),"Discovering projects…"]}),h&&(0,r.jsx)("div",{className:"rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive",children:h}),F&&(0,r.jsx)("div",{className:"rounded-xl border border-border/50 bg-card/50 px-4 py-6 text-center text-sm text-muted-foreground",children:"No dev root configured. Go back and set one, or finish setup to configure later."}),!u&&$.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:$.map(e=>{var t;let s,a=S===e.path,n=t2[e.kind],i=n.icon,o=(t=e.signals,s=[],t.isMonorepo&&s.push("Monorepo"),t.hasGitRepo&&s.push("Git"),t.hasPackageJson&&s.push("Node.js"),t.hasCargo&&s.push("Rust"),t.hasGoMod&&s.push("Go"),t.hasPyproject&&s.push("Python"),s),l=e.progress?function(e){if(0===e.milestonesTotal)return null;let t=[];return e.activeMilestone&&t.push(e.activeMilestone),e.activeSlice&&t.push(e.activeSlice),e.phase&&t.push(e.phase),t.join(" \xb7 ")||null}(e.progress):null,d=e.progress?`${e.progress.milestonesCompleted}/${e.progress.milestonesTotal}`:null;return(0,r.jsxs)("button",{type:"button",onClick:()=>E(e),disabled:!!S,className:(0,M.cn)("group flex w-full items-start gap-3.5 rounded-xl border px-4 py-3.5 text-left transition-[background-color,border-color,box-shadow,transform] duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.96]",a?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50",S&&!a&&"opacity-40 pointer-events-none"),children:[(0,r.jsx)("div",{className:(0,M.cn)("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg mt-0.5","active-gsd"===e.kind?"bg-success/10":"bg-foreground/[0.04]"),children:a?(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin text-muted-foreground"}):(0,r.jsx)(i,{className:(0,M.cn)("h-4 w-4",n.color)})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground truncate",children:e.name}),(0,r.jsx)("span",{className:(0,M.cn)("text-[10px] font-medium shrink-0",n.color),children:n.label})]}),o.length>0&&(0,r.jsx)("div",{className:"mt-1 flex items-center gap-1.5",children:o.map(e=>(0,r.jsx)("span",{className:"rounded bg-foreground/[0.04] px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e},e))}),l&&(0,r.jsx)("div",{className:"mt-1.5 text-[11px] text-muted-foreground",children:l}),e.progress&&e.progress.milestonesTotal>0&&(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-foreground/[0.06]",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-success/60 transition-[width]",style:{width:`${Math.round(e.progress.milestonesCompleted/e.progress.milestonesTotal*100)}%`}})}),(0,r.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground",children:d})]})]}),(0,r.jsx)(eD.A,{className:"mt-1 h-4 w-4 shrink-0 text-muted-foreground/50 transition-[color,transform] group-hover:text-muted-foreground group-hover:translate-x-0.5"})]},e.path)})}),!u&&n&&0===l.length&&!h&&(0,r.jsxs)("div",{className:"rounded-xl border border-border/50 bg-card/50 px-4 py-6 text-center text-sm text-muted-foreground",children:["No projects found in ",n]}),!u&&n&&(0,r.jsx)(r.Fragment,{children:p?(0,r.jsxs)(c.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},transition:{duration:.2},className:"rounded-xl border border-border/50 bg-card/50 p-4 space-y-3",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"New project"}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),_()},className:"space-y-2",children:[(0,r.jsx)(e5.p,{ref:N,value:f,onChange:e=>{b(e.target.value),w(null)},placeholder:"my-project",autoComplete:"off",className:"text-sm",disabled:v}),f&&!T&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:"Letters, numbers, hyphens, underscores, dots. Must start with a letter or number."}),P&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:"A project with this name already exists"}),y&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:y}),f&&T&&!P&&(0,r.jsxs)("p",{className:"font-mono text-xs text-muted-foreground",children:[n,"/",f]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,r.jsxs)(J,{type:"submit",size:"sm",disabled:!R,className:"gap-1.5 transition-transform active:scale-[0.96]",children:[v?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(t5.A,{className:"h-3.5 w-3.5"}),"Create & open"]}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>{g(!1),b(""),w(null)},disabled:v,className:"text-muted-foreground",children:"Cancel"})]})]})]}):(0,r.jsxs)("button",{type:"button",onClick:()=>g(!0),disabled:!!S,className:(0,M.cn)("flex w-full items-center gap-3.5 rounded-xl border border-dashed px-4 py-3.5 text-left transition-[background-color,border-color,color,transform] duration-200","border-border/50 text-muted-foreground hover:border-foreground/15 hover:text-foreground","active:scale-[0.96]",S&&"opacity-40 pointer-events-none"),children:[(0,r.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-foreground/[0.04]",children:(0,r.jsx)(t5.A,{className:"h-4 w-4"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Create new project"}),(0,r.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Initialize a new directory with Git"})]})]})})]}),(0,r.jsxs)(c.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.15,duration:.3},className:"mt-8 flex w-full max-w-lg items-center justify-between",children:[(0,r.jsx)(J,{variant:"ghost",onClick:t,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,r.jsxs)(J,{onClick:()=>{s?.(),e("")},className:"group gap-2 transition-transform active:scale-[0.96]",children:["Finish setup",(0,r.jsx)(ev.A,{className:"h-4 w-4 transition-transform group-hover:scale-110"})]})]})]})}let t4=[{id:"welcome",label:"Welcome"},{id:"mode",label:"Mode"},{id:"provider",label:"Provider"},{id:"authenticate",label:"Auth"},{id:"devRoot",label:"Root"},{id:"optional",label:"Extras"},{id:"remote",label:"Remote"},{id:"ready",label:"Ready"},{id:"project",label:"Project"}],t8=t4.length,t6=[],t7={enter:e=>({x:e>0?50:-50,opacity:0}),center:{x:0,opacity:1},exit:e=>({x:e<0?50:-50,opacity:0})};function t9({current:e,total:t}){return(0,r.jsx)("div",{className:"flex items-center gap-1",children:Array.from({length:t},(t,s)=>(0,r.jsx)("div",{className:(0,M.cn)("rounded-full transition-[width,background-color] duration-300",s===e?"h-1.5 w-5 bg-foreground":s<e?"h-1.5 w-1.5 bg-foreground/40":"h-1.5 w-1.5 bg-foreground/10")},s))})}function se(){let e=(0,Q.gF)(),{refreshOnboarding:t,saveApiKey:s,startProviderFlow:n,submitProviderFlowInput:o,cancelProviderFlow:l,refreshBoot:u}=(0,Q._l)(),m=tp(),h=e.boot?.onboarding,x=m.isActive("forceOnboarding"),p="idle"!==e.onboardingRequestState,[g,f]=(0,i.useState)(0),[b,v]=(0,i.useState)(0),[j,y]=(0,i.useState)(null),[w,N]=(0,i.useState)(!1),[S,k]=(0,tg.s1)(),[C,A]=(0,i.useState)(S),T=h?.required.providers??t6,P=(0,i.useMemo)(()=>{if(h?.activeFlow?.providerId)return h.activeFlow.providerId;if(j&&T.some(e=>e.id===j))return j;let e=T.find(e=>!e.configured&&e.recommended);if(e)return e.id;let t=T.find(e=>!e.configured);return t?t.id:T[0]?.id??null},[h?.activeFlow?.providerId,T,j]),R=w&&!h?.locked&&!p,[E,_]=(0,i.useState)(!1),F=(0,i.useCallback)(e=>{3===e&&h?.locked?_(!0):3!==e||h?.locked||_(!1),v(e>g?1:-1),f(e)},[g,h?.locked]);(0,i.useEffect)(()=>{if(!h||3!==g||!E)return;let e=!h.locked,t="succeeded"===h.bridgeAuthRefresh.phase||"idle"===h.bridgeAuthRefresh.phase;if(!e||!t)return;let s=window.setTimeout(()=>F(4),0);return()=>window.clearTimeout(s)},[h,F,g,E]);let I=(0,i.useMemo)(()=>T.find(e=>e.id===P)??null,[P,T]);if(!h)return null;let $=!h.locked||h.lastValidation?.status==="succeeded"&&("succeeded"===h.bridgeAuthRefresh.phase||"idle"===h.bridgeAuthRefresh.phase);if(!x&&($||R))return null;let D=t4[g]?.label??"";return(0,r.jsxs)("div",{className:"pointer-events-auto absolute inset-0 z-30 flex flex-col bg-background","data-testid":"onboarding-gate",children:[(0,r.jsxs)("header",{className:"relative z-10 flex h-12 shrink-0 items-center justify-between px-5 md:px-8",children:[(0,r.jsxs)("div",{className:"flex w-24 items-center gap-2",children:[(0,r.jsx)(a.default,{src:"/logo-white.svg",alt:"GSD-Pi Web",width:57,height:16,className:"hidden h-4 w-auto dark:block"}),(0,r.jsx)(a.default,{src:"/logo-black.svg",alt:"GSD-Pi Web",width:57,height:16,className:"h-4 w-auto dark:hidden"})]}),(0,r.jsx)("div",{className:"absolute inset-x-0 flex justify-center pointer-events-none",children:(0,r.jsx)("div",{className:"pointer-events-auto",children:(0,r.jsx)(t9,{current:g,total:t8})})}),(0,r.jsx)("div",{className:"flex w-24 justify-end",children:(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:D})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,r.jsx)("div",{className:"mx-auto flex min-h-full w-full max-w-2xl flex-col justify-center px-5 py-10 md:px-8 md:py-16",children:(0,r.jsx)(d.N,{mode:"wait",custom:b,children:(0,r.jsxs)(c.P.div,{custom:b,variants:t7,initial:"enter",animate:"center",exit:"exit",transition:{type:"spring",stiffness:400,damping:35,opacity:{duration:.15}},children:[0===g&&(0,r.jsx)(tf,{onNext:()=>F(1)}),1===g&&(0,r.jsx)(ty,{selected:C,onSelect:e=>{A(e),k(e)},onNext:()=>F(2),onBack:()=>F(0)}),2===g&&(0,r.jsx)(tC,{providers:h.required.providers,selectedId:P,onSelect:e=>{y(e),F(3)},onNext:()=>F(4),onBack:()=>F(1)}),3===g&&I&&(0,r.jsx)(tD,{provider:I,activeFlow:h.activeFlow,lastValidation:h.lastValidation,requestState:e.onboardingRequestState,requestProviderId:e.onboardingRequestProviderId,onSaveApiKey:async(e,t)=>{let r=await s(e,t);return r&&!r.locked&&("succeeded"===r.bridgeAuthRefresh.phase||"idle"===r.bridgeAuthRefresh.phase)&&(N(!0),u()),r},onStartFlow:e=>void n(e),onSubmitFlowInput:(e,t)=>void o(e,t),onCancelFlow:e=>void l(e),onBack:()=>F(2),onNext:()=>F(2),bridgeRefreshPhase:h.bridgeAuthRefresh.phase,bridgeRefreshError:h.bridgeAuthRefresh.error}),4===g&&(0,r.jsx)(tG,{onBack:()=>F(2),onNext:()=>F(5)}),5===g&&(0,r.jsx)(tK,{sections:h.optional.sections,onBack:()=>F(4),onNext:()=>F(6)}),6===g&&(0,r.jsx)(tX,{onBack:()=>F(5),onNext:()=>F(7)}),7===g&&(0,r.jsx)(t0,{providerLabel:h.lastValidation?.providerId?h.required.providers.find(e=>e.id===h.lastValidation?.providerId)?.label??"Provider":"Provider",onFinish:()=>F(8)}),8===g&&(0,r.jsx)(t3,{onBack:()=>F(7),onBeforeSwitch:()=>{m.isActive("forceOnboarding")&&m.toggle("forceOnboarding"),N(!0)},onFinish:()=>{(0,et.k8)("dashboard"),u()}})]},g)})})})]})}var st=s(12875),ss=s(85794),sr=s(18834),sa=s(37464),sn=s(57714),si=s(52160),so=s(29492),sl=s(41881),sd=s(50417),sc=s(13586),su=s(91262),sm=s(95904),sh=s(82773),sx=s(15392);function sp({className:e,...t}){return(0,r.jsx)(sx.bL,{"data-slot":"switch",className:(0,M.cn)("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:(0,r.jsx)(sx.zi,{"data-slot":"switch-thumb",className:"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"})})}var sg=s(37144),sf=s(86419);function sb({severity:e,className:t}){let s=(0,M.cn)("h-3.5 w-3.5 shrink-0",t);switch(e){case"error":case"critical":return(0,r.jsx)(t_.A,{className:(0,M.cn)(s,"text-destructive")});case"warning":return(0,r.jsx)(eG.A,{className:(0,M.cn)(s,"text-warning")});default:return(0,r.jsx)(eW.A,{className:(0,M.cn)(s,"text-info")})}}function sv(e){return"error"===e||"critical"===e?"destructive":"warning"===e?"secondary":"outline"}function sj({title:e,subtitle:t,status:s,onRefresh:a,refreshing:n}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s,t&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t})]}),(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:n,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3",n&&"animate-spin")}),"Refresh"]})]})}function sy({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function sw({label:e}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function sN({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function sS({label:e,value:t,variant:s}){return(0,r.jsxs)("div",{className:(0,M.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","error"===s&&"border-destructive/20 bg-destructive/5 text-destructive","warning"===s&&"border-warning/20 bg-warning/5 text-warning","info"===s&&"border-info/20 bg-info/5 text-info",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e}),(0,r.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function sk({anomaly:e}){return(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(sb,{severity:e.severity}),(0,r.jsx)(tS,{variant:sv(e.severity),className:"text-[10px] px-1.5 py-0",children:e.severity}),(0,r.jsx)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.type}),e.unitId&&(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground font-mono truncate",children:[e.unitType,"/",e.unitId]})]}),(0,r.jsx)("p",{className:"text-xs text-foreground",children:e.summary}),e.details&&e.details!==e.summary&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:e.details})]})}function sC(){let e=(0,Q.gF)(),{loadForensicsDiagnostics:t}=(0,Q._l)(),s=e.commandSurface.diagnostics.forensics,a=s.data,n="loading"===s.phase;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"diagnostics-forensics",children:[(0,r.jsx)(sj,{title:"Forensic Analysis",subtitle:a?new Date(a.timestamp).toLocaleString():null,status:a?(0,r.jsx)("span",{className:(0,M.cn)("inline-block h-1.5 w-1.5 rounded-full",a.anomalies.length>0?"bg-warning":"bg-success")}):null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,r.jsx)(sy,{message:s.error}),n&&!a&&(0,r.jsx)(sw,{label:"Running forensic analysis…"}),a&&(0,r.jsxs)(r.Fragment,{children:[a.metrics&&(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(sS,{label:"Units",value:a.metrics.totalUnits}),(0,r.jsx)(sS,{label:"Cost",value:(0,Q.BD)(a.metrics.totalCost)}),(0,r.jsx)(sS,{label:"Duration",value:`${Math.round(a.metrics.totalDuration/1e3)}s`}),(0,r.jsx)(sS,{label:"Traces",value:a.unitTraceCount})]}),a.crashLock?(0,r.jsxs)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(tA.A,{className:"h-3.5 w-3.5 text-destructive"}),(0,r.jsx)("span",{className:"text-xs font-medium text-destructive",children:"Crash Lock Active"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-[11px]",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"PID"}),(0,r.jsx)("span",{className:"font-mono text-foreground/80",children:a.crashLock.pid}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"Started"}),(0,r.jsx)("span",{className:"text-foreground/80",children:new Date(a.crashLock.startedAt).toLocaleString()}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"Unit"}),(0,r.jsxs)("span",{className:"font-mono text-foreground/80",children:[a.crashLock.unitType,"/",a.crashLock.unitId]})]})]}):(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 text-success"}),"No crash lock"]}),a.anomalies.length>0?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Anomalies (",a.anomalies.length,")"]}),a.anomalies.map((e,t)=>(0,r.jsx)(sk,{anomaly:e},t))]}):(0,r.jsx)(sN,{message:"No anomalies detected"}),a.recentUnits.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Recent Units (",a.recentUnits.length,")"]}),(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Model"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,r.jsx)("tbody",{children:a.recentUnits.map((e,t)=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.type}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[120px]",children:e.id}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground",children:e.model}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,Q.BD)(e.cost)}),(0,r.jsxs)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:[Math.round(e.duration/1e3),"s"]})]},t))})]})})]})]})]})}function sA({issue:e}){return(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)(sb,{severity:e.severity}),(0,r.jsx)(tS,{variant:sv(e.severity),className:"text-[10px] px-1.5 py-0",children:e.severity}),(0,r.jsx)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.code.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}),e.scope&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.scope}),e.fixable&&(0,r.jsxs)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-success/30 text-success",children:[(0,r.jsx)(sf.A,{className:"h-2.5 w-2.5 mr-0.5"}),"fixable"]})]}),(0,r.jsx)("p",{className:"text-xs text-foreground",children:e.message}),e.file&&(0,r.jsx)("p",{className:"text-[10px] font-mono text-muted-foreground truncate",children:e.file})]})}function sT(){let e=(0,Q.gF)(),{loadDoctorDiagnostics:t,applyDoctorFixes:s}=(0,Q._l)(),a=e.commandSurface.diagnostics.doctor,n=a.data,i="loading"===a.phase,o=n?.summary.fixable??0;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"diagnostics-doctor",children:[(0,r.jsx)(sj,{title:"Doctor Health Check",status:n?(0,r.jsx)("span",{className:(0,M.cn)("inline-block h-1.5 w-1.5 rounded-full",n.ok?"bg-success":"bg-destructive")}):null,onRefresh:()=>void t(),refreshing:i}),a.error&&(0,r.jsx)(sy,{message:a.error}),i&&!n&&(0,r.jsx)(sw,{label:"Running health check…"}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(sS,{label:"Total",value:n.summary.total}),n.summary.errors>0&&(0,r.jsx)(sS,{label:"Errors",value:n.summary.errors,variant:"error"}),n.summary.warnings>0&&(0,r.jsx)(sS,{label:"Warnings",value:n.summary.warnings,variant:"warning"}),n.summary.infos>0&&(0,r.jsx)(sS,{label:"Info",value:n.summary.infos,variant:"info"}),o>0&&(0,r.jsx)(sS,{label:"Fixable",value:o,variant:"info"})]}),o>0&&(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)(J,{type:"button",variant:"default",size:"sm",onClick:()=>void s(),disabled:a.fixPending,className:"h-7 gap-1.5 text-xs","data-testid":"doctor-apply-fixes",children:[a.fixPending?(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(sf.A,{className:"h-3 w-3"}),"Apply Fixes (",o,")"]}),a.lastFixError&&(0,r.jsx)("span",{className:"text-[11px] text-destructive",children:a.lastFixError})]}),a.lastFixResult&&a.lastFixResult.fixesApplied.length>0&&(0,r.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 text-success"}),(0,r.jsx)("span",{className:"text-xs font-medium text-success",children:"Fixes Applied"})]}),(0,r.jsx)("ul",{className:"space-y-0.5 pl-5",children:a.lastFixResult.fixesApplied.map((e,t)=>(0,r.jsx)("li",{className:"text-[11px] text-foreground/80 list-disc",children:e},t))})]}),n.issues.length>0?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Issues (",n.issues.length,")"]}),n.issues.map((e,t)=>(0,r.jsx)(sA,{issue:e},t))]}):(0,r.jsx)(sN,{message:"No issues found — workspace is healthy"})]})]})}function sP({suggestion:e}){return(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)(sb,{severity:e.severity}),(0,r.jsx)(tS,{variant:sv(e.severity),className:"text-[10px] px-1.5 py-0",children:e.severity}),(0,r.jsx)("span",{className:"text-[11px] font-medium text-foreground/80",children:e.skillName}),(0,r.jsx)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.trigger.replace(/_/g," ")})]}),(0,r.jsx)("p",{className:"text-xs text-foreground",children:e.message})]})}function sR(){let e=(0,Q.gF)(),{loadSkillHealthDiagnostics:t}=(0,Q._l)(),s=e.commandSurface.diagnostics.skillHealth,a=s.data,n="loading"===s.phase;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"diagnostics-skill-health",children:[(0,r.jsx)(sj,{title:"Skill Health",subtitle:a?new Date(a.generatedAt).toLocaleString():null,status:a?(0,r.jsx)("span",{className:(0,M.cn)("inline-block h-1.5 w-1.5 rounded-full",a.decliningSkills.length>0?"bg-warning":"bg-success")}):null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,r.jsx)(sy,{message:s.error}),n&&!a&&(0,r.jsx)(sw,{label:"Analyzing skill health…"}),a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(sS,{label:"Skills",value:a.skills.length}),a.staleSkills.length>0&&(0,r.jsx)(sS,{label:"Stale",value:a.staleSkills.length,variant:"warning"}),a.decliningSkills.length>0&&(0,r.jsx)(sS,{label:"Declining",value:a.decliningSkills.length,variant:"error"}),(0,r.jsx)(sS,{label:"Total units",value:a.totalUnitsWithSkills})]}),a.skills.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Skills (",a.skills.length,")"]}),(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Skill"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Uses"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Success"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Tokens"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-center font-medium text-muted-foreground",children:"Trend"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Stale"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"})]})}),(0,r.jsx)("tbody",{children:a.skills.map(e=>{var t,s;return(0,r.jsxs)("tr",{className:(0,M.cn)("border-b border-border/50 last:border-0",e.flagged&&"bg-destructive/3"),children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[e.name,e.flagged&&(0,r.jsx)(eG.A,{className:"h-3 w-3 text-warning shrink-0"})]})}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.totalUses}),(0,r.jsxs)("td",{className:(0,M.cn)("px-2.5 py-1.5 text-right tabular-nums",e.successRate>=.9?"text-success":e.successRate>=.7?"text-warning":"text-destructive"),children:[(100*e.successRate).toFixed(0),"%"]}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:Math.round(e.avgTokens)}),(0,r.jsx)("td",{className:(0,M.cn)("px-2.5 py-1.5 text-center","rising"===(t=e.tokenTrend)?"text-warning":"declining"===t?"text-destructive":"text-muted-foreground"),children:"rising"===(s=e.tokenTrend)?"↑":"declining"===s?"↓":"→"}),(0,r.jsx)("td",{className:(0,M.cn)("px-2.5 py-1.5 text-right tabular-nums",e.staleDays>30?"text-warning":"text-foreground/80"),children:e.staleDays>0?`${e.staleDays}d`:"—"}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,Q.BD)(e.avgCost)})]},e.name)})})]})})]}),a.staleSkills.length>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:"Stale Skills"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.staleSkills.map(e=>(0,r.jsx)(tS,{variant:"secondary",className:"text-[10px] font-mono",children:e},e))})]}),a.decliningSkills.length>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:"Declining Skills"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.decliningSkills.map(e=>(0,r.jsx)(tS,{variant:"destructive",className:"text-[10px] font-mono",children:e},e))})]}),a.suggestions.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Suggestions (",a.suggestions.length,")"]}),a.suggestions.map((e,t)=>(0,r.jsx)(sP,{suggestion:e},t))]}),0===a.skills.length&&0===a.suggestions.length&&(0,r.jsx)(sN,{message:"No skill usage data available"})]})]})}var sE=s(3150),s_=s(86002),sF=s(63089),sI=s(84971),s$=s(53709),sD=s(79384),sL=s(44302),sM=s(68206);function sq({title:e,subtitle:t,status:s,onRefresh:a,refreshing:n}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s,t&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t})]}),(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:n,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3",n&&"animate-spin")}),"Refresh"]})]})}function sB({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function sU({label:e}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function sO({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function sz({label:e,value:t,variant:s}){return(0,r.jsxs)("div",{className:(0,M.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","error"===s&&"border-destructive/20 bg-destructive/5 text-destructive","warning"===s&&"border-warning/20 bg-warning/5 text-warning","info"===s&&"border-info/20 bg-info/5 text-info",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e}),(0,r.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function sG({type:e,className:t}){let s=(0,M.cn)("h-3.5 w-3.5 shrink-0",t);switch(e){case"rule":return(0,r.jsx)(sE.A,{className:(0,M.cn)(s,"text-violet-400")});case"pattern":return(0,r.jsx)(s_.A,{className:(0,M.cn)(s,"text-info")});case"lesson":return(0,r.jsx)(sF.A,{className:(0,M.cn)(s,"text-warning")});case"freeform":return(0,r.jsx)(_.A,{className:(0,M.cn)(s,"text-success")})}}function sW(e){switch(e){case"quick-task":return"Quick Task";case"inject":return"Inject";case"defer":return"Defer";case"replan":return"Replan";case"note":return"Note"}}function sK({classification:e,className:t}){let s=(0,M.cn)("h-3 w-3 shrink-0",t);switch(e){case"quick-task":return(0,r.jsx)(ev.A,{className:s});case"inject":return(0,r.jsx)(sr.A,{className:s});case"defer":return(0,r.jsx)(sI.A,{className:s});case"replan":return(0,r.jsx)(s$.A,{className:s});case"note":return(0,r.jsx)(sD.A,{className:s})}}let sV=["quick-task","inject","defer","replan","note"];function sH({entry:e}){let t=function(e){switch(e){case"rule":return{label:"Rule",className:"border-violet-500/30 bg-violet-500/10 text-violet-400"};case"pattern":return{label:"Pattern",className:"border-info/30 bg-info/10 text-info"};case"lesson":return{label:"Lesson",className:"border-warning/30 bg-warning/10 text-warning"};case"freeform":return{label:"Freeform",className:"border-success/30 bg-success/10 text-success"}}}(e.type);return(0,r.jsx)("div",{className:"group rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 transition-colors hover:bg-card/50",children:(0,r.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,r.jsx)(sG,{type:e.type,className:"mt-0.5"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground truncate",children:e.title}),(0,r.jsx)(tS,{variant:"outline",className:(0,M.cn)("text-[10px] px-1.5 py-0 h-4 shrink-0",t.className),children:t.label})]}),e.content&&(0,r.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground line-clamp-2 leading-relaxed",children:e.content})]})]})})}function sY({data:e,phase:t,error:s,onRefresh:a}){return"loading"===t?(0,r.jsx)(sU,{label:"Loading knowledge base…"}):"error"===t&&s?(0,r.jsx)(sB,{message:s}):e&&0!==e.entries.length?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(sq,{title:"Knowledge Base",subtitle:`${e.entries.length} entries`,onRefresh:a,refreshing:"loading"===t}),(0,r.jsx)("div",{className:"space-y-1.5",children:e.entries.map(e=>(0,r.jsx)(sH,{entry:e},e.id))}),e.lastModified&&(0,r.jsxs)("p",{className:"pt-2 text-[10px] text-muted-foreground",children:["Last modified: ",new Date(e.lastModified).toLocaleString()]})]}):(0,r.jsx)(sO,{message:"No knowledge entries found"})}function sJ({entry:e,onResolve:t,resolvePending:s}){let a=function(e){switch(e){case"pending":return{label:"Pending",className:"border-warning/30 bg-warning/10 text-warning"};case"triaged":return{label:"Triaged",className:"border-info/30 bg-info/10 text-info"};case"resolved":return{label:"Resolved",className:"border-success/30 bg-success/10 text-success"}}}(e.status);return(0,r.jsx)("div",{className:"group rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 transition-colors hover:bg-card/50",children:(0,r.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,r.jsx)("div",{className:(0,M.cn)("mt-1 h-2 w-2 shrink-0 rounded-full","pending"===e.status&&"bg-warning","triaged"===e.status&&"bg-info","resolved"===e.status&&"bg-success")}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"text-xs text-foreground",children:e.text}),(0,r.jsx)(tS,{variant:"outline",className:(0,M.cn)("text-[10px] px-1.5 py-0 h-4 shrink-0",a.className),children:a.label}),e.classification&&(0,r.jsx)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 shrink-0 border-border/50 text-muted-foreground",children:sW(e.classification)})]}),e.timestamp&&(0,r.jsxs)("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,r.jsx)(ef.A,{className:"h-2.5 w-2.5"}),e.timestamp]}),e.resolution&&(0,r.jsx)("p",{className:"mt-1 text-[10px] text-muted-foreground italic",children:e.resolution}),"pending"===e.status&&(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:sV.map(a=>(0,r.jsxs)(J,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:()=>t(e.id,a),className:"h-6 gap-1 px-2 text-[10px] font-normal border-border/50 hover:bg-foreground/5",children:[(0,r.jsx)(sK,{classification:a}),sW(a)]},a))})]})]})})}function sZ({data:e,phase:t,error:s,resolvePending:a,resolveError:n,onRefresh:i,onResolve:o}){return"loading"===t?(0,r.jsx)(sU,{label:"Loading captures…"}):"error"===t&&s?(0,r.jsx)(sB,{message:s}):e&&0!==e.entries.length?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(sq,{title:"Captures",subtitle:`${e.entries.length} total`,status:(0,r.jsxs)("div",{className:"flex gap-1.5",children:[(0,r.jsx)(sz,{label:"Pending",value:e.pendingCount,variant:e.pendingCount>0?"warning":"default"}),(0,r.jsx)(sz,{label:"Actionable",value:e.actionableCount,variant:e.actionableCount>0?"info":"default"})]}),onRefresh:i,refreshing:"loading"===t}),n&&(0,r.jsxs)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Resolve error: ",n]}),(0,r.jsx)("div",{className:"space-y-1.5",children:e.entries.map(e=>(0,r.jsx)(sJ,{entry:e,onResolve:o,resolvePending:a},e.id))})]}):(0,r.jsx)(sO,{message:"No captures found"})}function sQ({initialTab:e}){let[t,s]=(0,i.useState)(e),a=(0,Q.gF)(),{loadKnowledgeData:n,loadCapturesData:o,resolveCaptureAction:l}=(0,Q._l)(),d=a.commandSurface.knowledgeCaptures,c=d.knowledge,u=d.captures,m=d.resolveRequest,h=u.data,x=h?.pendingCount??0;return(0,r.jsxs)("div",{className:"space-y-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-border/50 px-1",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>s("knowledge"),className:(0,M.cn)("flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-[color,border-color,background-color] border-b-2 -mb-px","knowledge"===t?"border-foreground/60 text-foreground":"border-transparent text-muted-foreground hover:text-muted-foreground"),children:[(0,r.jsx)(sL.A,{className:"h-3.5 w-3.5"}),"Knowledge"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>s("captures"),className:(0,M.cn)("flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-[color,border-color,background-color] border-b-2 -mb-px","captures"===t?"border-foreground/60 text-foreground":"border-transparent text-muted-foreground hover:text-muted-foreground"),children:[(0,r.jsx)(sM.A,{className:"h-3.5 w-3.5"}),"Captures",x>0&&(0,r.jsxs)(tS,{variant:"outline",className:"ml-1 h-4 px-1.5 py-0 text-[10px] border-warning/30 bg-warning/10 text-warning",children:[x," pending"]})]})]}),(0,r.jsx)("div",{className:"p-4",children:"knowledge"===t?(0,r.jsx)(sY,{data:c.data,phase:c.phase,error:c.error,onRefresh:()=>void n()}):(0,r.jsx)(sZ,{data:h,phase:u.phase,error:u.error,resolvePending:m.pending,resolveError:m.lastError,onRefresh:()=>void o(),onResolve:(e,t)=>{l({captureId:e,classification:t,resolution:"Manual browser triage",rationale:"Triaged via web UI"})}})})]})}var sX=s(77059),s0=s(35361),s1=s(41363),s5=s(8891),s2=s(41655),s3=s(65496),s4=s(72202),s8=s(25847);function s6({title:e,icon:t,subtitle:s,onRefresh:a,refreshing:n}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:t}),(0,r.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:s})]}),(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:n,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3",n&&"animate-spin")}),"Refresh"]})]})}function s7({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function s9({label:e}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function re({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function rt({label:e,value:t,variant:s}){return(0,r.jsxs)("div",{className:(0,M.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","info"===s&&"border-info/20 bg-info/5 text-info","warning"===s&&"border-warning/20 bg-warning/5 text-warning","success"===s&&"border-success/20 bg-success/5 text-success",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e}),(0,r.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function rs({label:e,enabled:t}){return(0,r.jsxs)(tS,{variant:t?"secondary":"outline",className:(0,M.cn)("text-[10px] px-1.5 py-0 font-mono",t?"border-success/30 text-success":"text-muted-foreground"),children:[e,": ",t?"on":"off"]})}function rr({label:e,skills:t}){return t?.length?(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:e}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:t.map(e=>(0,r.jsx)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e},e))})]}):null}function ra({models:e}){return e&&0!==Object.keys(e).length?(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"Phase Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,r.jsxs)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:[e,": ",t]},e))})]}):null}function rn({label:e,children:t}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground shrink-0",children:e}),(0,r.jsx)("span",{className:"text-foreground/80 text-right truncate",children:t})]})}function ri(){let e=(0,Q.gF)(),{loadSettingsData:t}=(0,Q._l)(),s=e.commandSurface.settingsData;return{state:s,data:s.data,busy:"loading"===s.phase,refresh:()=>void t()}}function ro(e){return"budget"===e||"burn-max"===e?"warning":"quality"===e?"success":"info"}function rl(){let{state:e,data:t,busy:s,refresh:a}=ri(),n=t?.preferences??null;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"settings-prefs",children:[(0,r.jsx)(s6,{title:"Effective Preferences",icon:(0,r.jsx)(A.A,{className:"h-3.5 w-3.5"}),subtitle:n?`${n.scope} scope`:null,onRefresh:a,refreshing:s}),e.error&&(0,r.jsx)(s7,{message:e.error}),s&&!t&&(0,r.jsx)(s9,{label:"Loading preferences…"}),t&&!n&&(0,r.jsx)(re,{message:"No preferences file found"}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rt,{label:"Mode",value:n.mode??"solo",variant:"info"}),(0,r.jsx)(rt,{label:"Token Profile",value:n.tokenProfile??"balanced",variant:ro(n.tokenProfile)}),n.customInstructions?.length?(0,r.jsx)(rt,{label:"Custom Instructions",value:n.customInstructions.length}):null]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ra,{models:n.models}),(0,r.jsx)(rr,{label:"Always use",skills:n.alwaysUseSkills}),(0,r.jsx)(rr,{label:"Prefer",skills:n.preferSkills}),(0,r.jsx)(rr,{label:"Avoid",skills:n.avoidSkills}),n.models&&0!==Object.keys(n.models).length?!n.alwaysUseSkills?.length&&!n.preferSkills?.length&&!n.avoidSkills?.length&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"No skill preferences configured"}):!n.alwaysUseSkills?.length&&!n.preferSkills?.length&&!n.avoidSkills?.length&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"No model or skill preferences configured"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-x-6 gap-y-1.5 rounded-lg border border-border/50 bg-card/50 px-3 py-2.5",children:[(0,r.jsx)(rn,{label:"Auto-Supervisor",children:n.autoSupervisor?.enabled?(0,r.jsxs)("span",{className:"text-success",children:["on",null!=n.autoSupervisor.softTimeoutMinutes&&` (${n.autoSupervisor.softTimeoutMinutes}m)`]}):(0,r.jsx)("span",{className:"text-muted-foreground",children:"off"})}),(0,r.jsx)(rn,{label:"UAT Dispatch",children:(0,r.jsx)("span",{className:n.uatDispatch?"text-success":"text-muted-foreground",children:n.uatDispatch?"on":"off"})}),(0,r.jsx)(rn,{label:"Auto-Visualize",children:(0,r.jsx)("span",{className:n.autoVisualize?"text-success":"text-muted-foreground",children:n.autoVisualize?"on":"off"})}),(0,r.jsx)(rn,{label:"Service Tier",children:(0,r.jsx)("span",{className:"font-mono text-[10px]",children:n.serviceTier??"default"})}),(0,r.jsx)(rn,{label:"Show Token Cost",children:(0,r.jsx)("span",{className:n.showTokenCost?"text-success":"text-muted-foreground",children:n.showTokenCost?"on":"off"})}),(0,r.jsx)(rn,{label:"Context Selection",children:(0,r.jsx)("span",{className:"font-mono text-[10px]",children:n.contextSelection??"full"})}),(0,r.jsx)(rn,{label:"Context Window",children:(0,r.jsx)("span",{className:"font-mono text-[10px]",children:"number"==typeof n.contextWindowOverride?n.contextWindowOverride:"auto"})}),(0,r.jsx)(rn,{label:"Language",children:(0,r.jsx)("span",{className:"font-mono text-[10px]",children:n.language??"default"})}),(0,r.jsx)(rn,{label:"Reactive Exec",children:(0,r.jsx)("span",{className:n.reactiveExecution?.enabled?"text-success":"text-muted-foreground",children:n.reactiveExecution?.enabled?"on":"off"})}),(0,r.jsx)(rn,{label:"Gate Eval",children:(0,r.jsx)("span",{className:n.gateEvaluation?.enabled?"text-success":"text-muted-foreground",children:n.gateEvaluation?.enabled?"on":"off"})}),(0,r.jsx)(rn,{label:"Slice Parallel",children:(0,r.jsx)("span",{className:n.sliceParallel?.enabled?"text-success":"text-muted-foreground",children:n.sliceParallel?.enabled?"on":"off"})}),(0,r.jsx)(rn,{label:"Phase Controls",children:(0,r.jsxs)("span",{className:"font-mono text-[10px]",children:[n.phases?Object.values(n.phases).filter(e=>!0===e).length:0," enabled"]})}),(0,r.jsx)(rn,{label:"Preference Scope",children:(0,r.jsx)("span",{className:"font-mono text-[10px]",children:n.scope})})]}),(0,r.jsxs)("div",{className:"text-[11px] text-muted-foreground truncate font-mono",children:["Source: ",n.path]}),n.warnings&&n.warnings.length>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,r.jsx)(eG.A,{className:"h-3 w-3"}),(0,r.jsxs)("span",{className:"font-medium",children:["Warnings (",n.warnings.length,")"]})]}),n.warnings.map((e,t)=>(0,r.jsx)("div",{className:"rounded border border-warning/20 bg-warning/5 px-2.5 py-1.5 text-[11px] text-warning",children:e},t))]})]})]})}function rd({tier:e,modelId:t}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground capitalize",children:e}),(0,r.jsx)("span",{className:"font-mono text-[11px] text-foreground/80 truncate max-w-[200px]",children:t??(0,r.jsx)("span",{className:"text-muted-foreground italic",children:"default"})})]})}function rc({tier:e,success:t,fail:s}){return 0===t+s?null:(0,r.jsxs)(tS,{variant:"outline",className:(0,M.cn)("text-[10px] px-1.5 py-0 font-mono",s>0?"border-destructive/20 text-destructive":"text-muted-foreground"),children:[e,": ",t,"✓",s>0&&(0,r.jsxs)("span",{children:[" ",s,"✗"]})]})}function ru(){let{state:e,data:t,busy:s,refresh:a}=ri(),n=t?.routingConfig??null,i=t?.routingHistory??null;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"settings-model-routing",children:[(0,r.jsx)(s6,{title:"Model Routing",icon:(0,r.jsx)(ez.A,{className:"h-3.5 w-3.5"}),onRefresh:a,refreshing:s}),e.error&&(0,r.jsx)(s7,{message:e.error}),s&&!t&&(0,r.jsx)(s9,{label:"Loading routing config…"}),t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsxs)(tS,{variant:n?.enabled?"secondary":"outline",className:(0,M.cn)("text-[10px] px-2 py-0.5",n?.enabled?"border-success/30 text-success":"text-muted-foreground"),children:["Dynamic Routing: ",n?.enabled?"enabled":"disabled"]})}),n?.tier_models&&(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Tier Assignments"}),(0,r.jsx)(rd,{tier:"light",modelId:n.tier_models.light}),(0,r.jsx)(rd,{tier:"standard",modelId:n.tier_models.standard}),(0,r.jsx)(rd,{tier:"heavy",modelId:n.tier_models.heavy})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,r.jsx)(rs,{label:"escalate_on_failure",enabled:n?.escalate_on_failure}),(0,r.jsx)(rs,{label:"budget_pressure",enabled:n?.budget_pressure}),(0,r.jsx)(rs,{label:"cross_provider",enabled:n?.cross_provider}),(0,r.jsx)(rs,{label:"hooks",enabled:n?.hooks})]}),i?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rt,{label:"Patterns",value:Object.keys(i.patterns).length}),(0,r.jsx)(rt,{label:"Feedback",value:i.feedback.length})]}),Object.keys(i.patterns).length>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground",children:"Top Patterns"}),(0,r.jsx)("div",{className:"space-y-2",children:(function(e,t=5){return Object.entries(e.patterns).map(([e,t])=>({name:e,total:t.light.success+t.light.fail+t.standard.success+t.standard.fail+t.heavy.success+t.heavy.fail,pattern:t})).sort((e,t)=>t.total-e.total).slice(0,t)})(i).map(({name:e,total:t,pattern:s})=>(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-mono text-foreground/80 truncate",children:e}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums shrink-0",children:[t," attempts"]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(0,r.jsx)(rc,{tier:"L",success:s.light.success,fail:s.light.fail}),(0,r.jsx)(rc,{tier:"S",success:s.standard.success,fail:s.standard.fail}),(0,r.jsx)(rc,{tier:"H",success:s.heavy.success,fail:s.heavy.fail})]})]},e))})]})]}):(0,r.jsx)(re,{message:"No routing history yet"})]})]})}function rm(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function rh(){var e;let{state:t,data:s,busy:a,refresh:n}=ri(),i=s?.preferences??null,o=s?.budgetAllocation??null,l=s?.projectTotals??null;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"settings-budget",children:[(0,r.jsx)(s6,{title:"Budget & Costs",icon:(0,r.jsx)(eb.A,{className:"h-3.5 w-3.5"}),onRefresh:n,refreshing:a}),t.error&&(0,r.jsx)(s7,{message:t.error}),a&&!s&&(0,r.jsx)(s9,{label:"Loading budget data…"}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rt,{label:"Ceiling",value:i?.budgetCeiling!=null?(0,Q.BD)(i.budgetCeiling):"Not set",variant:i?.budgetCeiling!=null?"warning":"default"}),(0,r.jsx)(rt,{label:"Enforcement",value:i?.budgetEnforcement??"Not set",variant:i?.budgetEnforcement?"halt"===(e=i.budgetEnforcement)?"warning":"pause"===e?"info":"success":"default"}),(0,r.jsx)(rt,{label:"Token Profile",value:i?.tokenProfile??"balanced",variant:ro(i?.tokenProfile)}),(0,r.jsx)(rt,{label:"Service Tier",value:i?.serviceTier??"default"}),(0,r.jsx)(rt,{label:"Token Cost",value:i?.showTokenCost?"shown":"hidden"})]}),o&&(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Context Budget Allocations"}),(0,r.jsxs)(rn,{label:"Summary Budget",children:[rm(o.summaryBudgetChars)," chars"]}),(0,r.jsxs)(rn,{label:"Inline Context",children:[rm(o.inlineContextBudgetChars)," chars"]}),(0,r.jsxs)(rn,{label:"Verification",children:[rm(o.verificationBudgetChars)," chars"]}),(0,r.jsxs)(rn,{label:"Task Count Range",children:[o.taskCountRange.min,"–",o.taskCountRange.max]}),(0,r.jsxs)(rn,{label:"Continue Threshold",children:[o.continueThresholdPercent,"%"]})]}),l?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Project Cost Totals"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rt,{label:"Units",value:l.units}),(0,r.jsx)(rt,{label:"Total Cost",value:(0,Q.BD)(l.cost),variant:"warning"}),(0,r.jsx)(rt,{label:"Duration",value:`${Math.round(l.duration/1e3)}s`})]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Token Breakdown"}),(0,r.jsx)(rn,{label:"Input",children:(0,Q._y)(l.tokens.input)}),(0,r.jsx)(rn,{label:"Output",children:(0,Q._y)(l.tokens.output)}),(0,r.jsx)(rn,{label:"Cache Read",children:(0,Q._y)(l.tokens.cacheRead)}),(0,r.jsx)(rn,{label:"Cache Write",children:(0,Q._y)(l.tokens.cacheWrite)}),(0,r.jsx)(rn,{label:"Total",children:(0,Q._y)(l.tokens.total)})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rt,{label:"Tool Calls",value:l.toolCalls}),(0,r.jsx)(rt,{label:"Assistant Msgs",value:l.assistantMessages}),(0,r.jsx)(rt,{label:"User Msgs",value:l.userMessages})]})]}):(0,r.jsx)(re,{message:"No execution metrics yet"})]})]})}let rx=[{value:"slack",label:"Slack",description:"Get pinged in a Slack channel",idPlaceholder:"Channel ID (e.g. C01ABCD2EFG)"},{value:"discord",label:"Discord",description:"Get pinged in a Discord channel",idPlaceholder:"Channel ID (17–20 digit number)"},{value:"telegram",label:"Telegram",description:"Get pinged via Telegram bot",idPlaceholder:"Chat ID (numeric, may start with -)"}],rp={slack:/^[A-Z0-9]{9,12}$/,discord:/^\d{17,20}$/,telegram:/^-?\d{5,20}$/};function rg(){let{data:e,busy:t,refresh:s}=ri(),a=e?.preferences?.remoteQuestions??null,[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)(!0),[c,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)("slack"),[p,g]=(0,i.useState)(""),[f,b]=(0,i.useState)(5),[v,j]=(0,i.useState)(5),[y,w]=(0,i.useState)(""),[N,S]=(0,i.useState)(!1),[k,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),[P,R]=(0,i.useState)(!1),[E,_]=(0,i.useState)(!1),[F,$]=(0,i.useState)(null),[D,L]=(0,i.useState)(null),[q,B]=(0,i.useState)(!1),[U,O]=(0,i.useState)(!1),z=(0,i.useCallback)(async()=>{try{d(!0);let e=await (0,el.tm)("/api/remote-questions",{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>({error:"Unknown error"}));$(t.error??`API error ${e.status}`);return}let t=await e.json();o(t.envVarName),m(t.tokenSet),B("configured"===t.status&&null!==t.config),t.config&&(x(t.config.channel),g(t.config.channelId),b(t.config.timeoutMinutes),j(t.config.pollIntervalSeconds))}catch(e){$(e instanceof Error?e.message:"Failed to fetch remote questions status")}finally{d(!1)}},[]);(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{z()},0);return()=>window.clearTimeout(e)},[z]),(0,i.useEffect)(()=>{if(!a?.channel)return;let e=a.channel,t=window.setTimeout(()=>{x(e),g(a.channelId??""),b(a.timeoutMinutes??5),j(a.pollIntervalSeconds??5)},0);return()=>window.clearTimeout(t)},[a]);let G=p.trim().length>0&&rp[h].test(p.trim())&&!P&&!E;(0,i.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>L(null),3e3);return()=>clearTimeout(e)},[D]);let W=async()=>{R(!0),$(null),L(null);try{let e=await (0,el.tm)("/api/remote-questions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:h,channelId:p.trim(),timeoutMinutes:f,pollIntervalSeconds:v})}),t=await e.json();if(!e.ok)return void $(t.error??`Save failed (${e.status})`);L("Configuration saved"),B(!0),s(),z()}catch(e){$(e instanceof Error?e.message:"Failed to save configuration")}finally{R(!1)}},K=async()=>{_(!0),$(null),L(null);try{let e=await (0,el.tm)("/api/remote-questions",{method:"DELETE"}),t=await e.json();if(!e.ok)return void $(t.error??`Disconnect failed (${e.status})`);L("Channel disconnected"),B(!1),g(""),b(5),j(5),x("slack"),m(!1),s(),z()}catch(e){$(e instanceof Error?e.message:"Failed to disconnect channel")}finally{_(!1)}},V=async()=>{if(y.trim()){C(!0),$(null),T(null);try{let e=await (0,el.tm)("/api/remote-questions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:h,token:y.trim()})}),t=await e.json();if(!e.ok)return void $(t.error??`Token save failed (${e.status})`);T(`Token saved (${t.masked})`),m(!0),w(""),S(!1),z()}catch(e){$(e instanceof Error?e.message:"Failed to save token")}finally{C(!1)}}};(0,i.useEffect)(()=>{if(!A)return;let e=setTimeout(()=>T(null),3e3);return()=>clearTimeout(e)},[A]);let H=n??`${h.toUpperCase()}_BOT_TOKEN`,Y=rx.find(e=>e.value===h);return(t||l)&&!e&&!q?(0,r.jsxs)("div",{className:"space-y-5","data-testid":"settings-remote-questions",children:[(0,r.jsx)(s6,{title:"Integrations",icon:(0,r.jsx)(sl.A,{className:"h-3.5 w-3.5"}),subtitle:"Remote notifications",onRefresh:()=>{s(),z()},refreshing:!0}),(0,r.jsx)(s9,{label:"Loading integration status…"})]}):(0,r.jsxs)("div",{className:"space-y-5","data-testid":"settings-remote-questions",children:[(0,r.jsx)(s6,{title:"Integrations",icon:(0,r.jsx)(sl.A,{className:"h-3.5 w-3.5"}),subtitle:"Remote notifications",onRefresh:()=>{s(),z()},refreshing:t||l}),(0,r.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Connect a chat channel so the agent pings you when it needs input instead of waiting silently."}),F&&(0,r.jsx)(s7,{message:F}),D&&(0,r.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-3 text-sm text-muted-foreground",children:[(0,r.jsx)(u.A,{className:"h-4 w-4 shrink-0 text-success"}),D]}),q&&(0,r.jsxs)("div",{className:"rounded-xl border border-success/15 bg-success/[0.04] px-4 py-4",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-success/20 bg-success/10",children:(0,r.jsx)(u.A,{className:"h-4.5 w-4.5 text-success"})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"text-sm font-medium text-foreground",children:["Connected to ",Y.label]}),(0,r.jsx)("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:p})]})]}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>void K(),disabled:E,className:"h-7 text-xs text-destructive/70 hover:text-destructive",children:E?(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}):"Disconnect"})]}),(0,r.jsxs)("div",{className:"mt-3 flex gap-4 border-t border-success/10 pt-3 text-[11px] text-muted-foreground",children:[(0,r.jsxs)("span",{children:["Timeout: ",f,"m"]}),(0,r.jsxs)("span",{children:["Poll: ",v,"s"]})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:q?"Switch channel":"Choose a channel"}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:rx.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{x(e.value),$(null)},disabled:P,className:(0,M.cn)("rounded-xl border px-3 py-3 text-left transition-[background-color,border-color,box-shadow,transform] duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.96]",h===e.value?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),(0,r.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:e.description})]},e.value))})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Channel ID"}),(0,r.jsx)("input",{type:"text",value:p,onChange:e=>{g(e.target.value),F&&$(null)},placeholder:Y.idPlaceholder,disabled:P,className:(0,M.cn)("w-full rounded-xl border bg-card/50 px-4 py-2.5 font-mono text-sm text-foreground","placeholder:text-muted-foreground","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","transition-colors",p.trim().length>0&&!rp[h].test(p.trim())?"border-destructive/40":"border-border/50"),onKeyDown:e=>{"Enter"===e.key&&G&&W()}}),p.trim().length>0&&!rp[h].test(p.trim())&&(0,r.jsxs)("p",{className:"text-[11px] text-destructive/70",children:["Does not match the expected format for ",Y.label]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>O(e=>!e),className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-muted-foreground transition-colors",children:[(0,r.jsx)("svg",{className:(0,M.cn)("h-3 w-3 transition-transform",U&&"rotate-90"),viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M6 4l4 4-4 4"})}),"Advanced settings"]}),U&&(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 pl-4",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("label",{className:"text-[11px] text-muted-foreground",htmlFor:"rq-timeout",children:"Timeout (min)"}),(0,r.jsx)("input",{id:"rq-timeout",type:"number",min:1,max:30,value:f,onChange:e=>b(Math.max(1,Math.min(30,Number(e.target.value)||1))),className:"w-full rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs text-foreground tabular-nums focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("label",{className:"text-[11px] text-muted-foreground",htmlFor:"rq-poll",children:"Poll interval (sec)"}),(0,r.jsx)("input",{id:"rq-poll",type:"number",min:2,max:30,value:v,onChange:e=>j(Math.max(2,Math.min(30,Number(e.target.value)||2))),className:"w-full rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs text-foreground tabular-nums focus:outline-none focus:ring-2 focus:ring-ring"})]})]}),p.trim().length>0&&(0,r.jsxs)(J,{type:"button",onClick:()=>void W(),disabled:!G,className:"gap-2 transition-transform active:scale-[0.96]",children:[P?(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(u.A,{className:"h-4 w-4"}),q?"Update connection":"Save & connect"]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Bot token"}),A&&(0,r.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-success"}),A]}),c&&!A&&(0,r.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-success"}),(0,r.jsx)("span",{className:"font-mono text-[11px]",children:H})," is configured"]}),!c&&(0,r.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-warning/15 bg-warning/[0.04] px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(eG.A,{className:"h-3.5 w-3.5 shrink-0 text-warning"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"font-mono text-[11px]",children:H})," not configured"]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:N?"text":"password",value:y,onChange:e=>w(e.target.value),placeholder:`Paste your ${Y.label} bot token`,disabled:k,className:(0,M.cn)("w-full rounded-xl border border-border/50 bg-card/50 pl-4 pr-10 py-2.5 font-mono text-sm text-foreground","placeholder:text-muted-foreground","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","transition-colors"),onKeyDown:e=>{"Enter"===e.key&&y.trim()&&V()}}),(0,r.jsx)("button",{type:"button",onClick:()=>S(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-muted-foreground transition-colors",children:N?(0,r.jsx)(tV.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(tH.A,{className:"h-3.5 w-3.5"})})]}),(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>void V(),disabled:!y.trim()||k,className:"h-[42px] gap-1.5 px-4",children:[k?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(tT.A,{className:"h-3.5 w-3.5"}),"Save"]})]})]})]})}function rf(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join("\n"):""}function rb(e){let t=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.indexOf("=");if(t<=0)throw Error(`Invalid key=value line: ${e}`);return[e.slice(0,t).trim(),e.slice(t+1)]});return t.length>0?Object.fromEntries(t):void 0}function rv(){let[e,t]=(0,i.useState)(null),[s,a]=(0,i.useState)(!0),[n,o]=(0,i.useState)(!1),[l,d]=(0,i.useState)(null),[c,m]=(0,i.useState)(null),[h,x]=(0,i.useState)(null),[p,g]=(0,i.useState)(null),[f,b]=(0,i.useState)(null),[v,j]=(0,i.useState)(""),[y,w]=(0,i.useState)("stdio"),[N,S]=(0,i.useState)(""),[k,C]=(0,i.useState)(""),[A,T]=(0,i.useState)(""),[P,R]=(0,i.useState)(""),[E,_]=(0,i.useState)(""),[F,$]=(0,i.useState)(""),D=(0,i.useCallback)(async()=>{a(!0),m(null);try{let e=await (0,el.tm)("/api/mcp-connections",{cache:"no-store"}),s=await e.json();if(!e.ok)throw Error(s.error??`MCP request failed (${e.status})`);t(s)}catch(e){m(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);function L(){b(null),j(""),w("stdio"),S(""),C(""),T(""),R(""),_(""),$("")}async function q(e){let s=await (0,el.tm)("/api/mcp-connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await s.json();if("error"===r.status)throw Error(r.error);if(!s.ok)throw Error(`MCP request failed (${s.status})`);return t(r.data),r}async function B(){o(!0),m(null),x(null);try{let e,t="stdio"===y?{name:v.trim(),transport:y,command:N.trim(),args:(e=k.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)).length>0?e:void 0,env:rb(E),cwd:A.trim()||void 0}:{name:v.trim(),transport:y,url:P.trim(),headers:rb(F)};await q({action:"save",previousName:f??void 0,server:t}),x(f?"MCP server updated":"MCP server saved"),L()}catch(e){m(e instanceof Error?e.message:String(e))}finally{o(!1)}}async function U(e){m(null);try{await q({action:e.disabled?"enable":"disable",name:e.name}),x(e.disabled?"MCP server enabled":"MCP server disabled")}catch(e){m(e instanceof Error?e.message:String(e))}}async function O(e){if(window.confirm(`Delete local MCP server "${e.name}"?`)){m(null);try{await q({action:"delete",name:e.name}),x("MCP server deleted"),f===e.name&&L()}catch(e){m(e instanceof Error?e.message:String(e))}}}async function z(e){d(e.name),m(null),g(null);try{let t=await q({action:"test",name:e.name});g(t.result??null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(null)}}async function G(e){let t=e.conflicts?window.prompt(`Rename imported MCP server "${e.name}"`,`${e.name}-local`):e.name;if(t){m(null);try{await q({action:"import",server:e,name:t}),x("MCP server imported")}catch(e){m(e instanceof Error?e.message:String(e))}}}(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{D()},0);return()=>window.clearTimeout(e)},[D]),(0,i.useEffect)(()=>{if(!h)return;let e=setTimeout(()=>x(null),3e3);return()=>clearTimeout(e)},[h]);let W=v.trim().length>0&&("stdio"===y?N.trim().length>0:P.trim().length>0);return(0,r.jsxs)("div",{className:"space-y-5","data-testid":"settings-mcp-connections",children:[(0,r.jsx)(s6,{title:"MCP Connections",icon:(0,r.jsx)(sX.A,{className:"h-3.5 w-3.5"}),subtitle:e?`${e.servers.length} configured`:null,onRefresh:()=>void D(),refreshing:s}),c&&(0,r.jsx)(s7,{message:c}),h&&(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-success/15 bg-success/[0.04] px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 text-success"}),h]}),s&&!e&&(0,r.jsx)(s9,{label:"Loading MCP connections…"}),e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rt,{label:"Local config",value:e.localConfigPath}),(0,r.jsx)(rt,{label:"Importable",value:e.importableServers.length,variant:"info"}),e.duplicates.length>0&&(0,r.jsx)(rt,{label:"Duplicates",value:e.duplicates.length,variant:"warning"})]}),e.warnings.length>0&&(0,r.jsx)("div",{className:"space-y-1 rounded-lg border border-warning/20 bg-warning/5 px-3 py-2 text-[11px] text-warning",children:e.warnings.map(e=>(0,r.jsx)("div",{children:e},e))}),(0,r.jsxs)("div",{className:"grid gap-2",children:[0===e.servers.length&&(0,r.jsx)(re,{message:"No MCP servers configured"}),e.servers.map(e=>(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-3",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(s0.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"font-mono text-xs text-foreground",children:e.name}),(0,r.jsx)(rt,{label:e.transport,value:e.disabled?"disabled":"enabled",variant:e.disabled||"unsupported"===e.transport?"warning":e.connected||e.toolCount>0?"success":"info"})]}),(0,r.jsx)("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:e.sourcePath}),e.envWarnings.length>0&&(0,r.jsx)("div",{className:"text-[11px] text-warning",children:e.envWarnings[0]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 flex-wrap justify-end gap-1",children:[(0,r.jsxs)(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>void z(e),disabled:l===e.name||e.disabled||"unsupported"===e.transport,children:[l===e.name?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(sd.A,{className:"h-3.5 w-3.5"}),"Test"]}),(0,r.jsxs)(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>void U(e),children:[e.disabled?(0,r.jsx)(s1.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(s5.A,{className:"h-3.5 w-3.5"}),e.disabled?"Enable":"Disable"]}),(0,r.jsx)(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>(function(e){if("unsupported"!==e.transport){var t;b(e.name),j(e.name),w(e.transport),S(e.command??""),C((t=e.args,t?.join("\n")??"")),T(e.cwd??""),R(e.url??""),_(rf(e.env)),$(rf(e.headers))}})(e),disabled:"unsupported"===e.transport,children:"Edit"}),(0,r.jsx)(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-destructive/80",onClick:()=>void O(e),disabled:"project-local"!==e.sourceKind,children:(0,r.jsx)(s2.A,{className:"h-3.5 w-3.5"})})]})]})},`${e.sourcePath}:${e.name}`))]}),p&&(0,r.jsx)("div",{className:(0,M.cn)("rounded-lg border px-3 py-2 text-xs",p.ok?"border-success/20 bg-success/5 text-success":"border-warning/20 bg-warning/5 text-warning"),children:p.ok?`${p.server} responded with ${p.toolCount} tools`:`${p.server} failed: ${p.error??"unknown error"}`}),(0,r.jsxs)("div",{className:"space-y-3 rounded-lg border border-border/50 bg-card/50 px-3 py-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:f?"Edit local server":"Add local server"}),f&&(0,r.jsx)(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:L,children:"Cancel"})]}),(0,r.jsxs)("div",{className:"grid gap-2 md:grid-cols-2",children:[(0,r.jsx)("input",{value:v,onChange:e=>j(e.target.value),placeholder:"server-name",className:"rounded-lg border border-border/50 bg-background px-3 py-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsxs)("select",{value:y,onChange:e=>w(e.target.value),className:"rounded-lg border border-border/50 bg-background px-3 py-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,r.jsx)("option",{value:"stdio",children:"stdio"}),(0,r.jsx)("option",{value:"http",children:"http"})]}),"stdio"===y?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{value:N,onChange:e=>S(e.target.value),placeholder:"/absolute/path/to/server",className:"rounded-lg border border-border/50 bg-background px-3 py-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("input",{value:A,onChange:e=>T(e.target.value),placeholder:"cwd (optional)",className:"rounded-lg border border-border/50 bg-background px-3 py-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("textarea",{value:k,onChange:e=>C(e.target.value),placeholder:"args, one per line",rows:3,className:"rounded-lg border border-border/50 bg-background px-3 py-2 font-mono text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("textarea",{value:E,onChange:e=>_(e.target.value),placeholder:"ENV_KEY=value",rows:3,className:"rounded-lg border border-border/50 bg-background px-3 py-2 font-mono text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{value:P,onChange:e=>R(e.target.value),placeholder:"https://server.example/mcp",className:"md:col-span-2 rounded-lg border border-border/50 bg-background px-3 py-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("textarea",{value:F,onChange:e=>$(e.target.value),placeholder:"Authorization=Bearer ${TOKEN}",rows:3,className:"md:col-span-2 rounded-lg border border-border/50 bg-background px-3 py-2 font-mono text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]})]}),(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>void B(),disabled:!W||n,className:"gap-1.5",children:[n?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(t5.A,{className:"h-3.5 w-3.5"}),f?"Update server":"Save server"]})]}),e.importableServers.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Discovered imports"}),(0,r.jsx)("div",{className:"grid gap-2",children:e.importableServers.slice(0,6).map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/50 bg-card/50 px-3 py-2",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"font-mono text-xs text-foreground",children:e.name}),(0,r.jsxs)("div",{className:"truncate text-[10px] text-muted-foreground",children:[e.sourceTool," \xb7 ",e.sourcePath]})]}),(0,r.jsx)(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-xs",disabled:"unsupported"===e.transport,onClick:()=>void G(e),children:"Import"})]},`${e.sourcePath}:${e.name}`))})]})]})]})}let rj=[11,12,13,14,15,16],ry=[11,12,13,14,15,16];function rw({label:e,description:t,presets:s,defaultSize:a,currentSize:n,onChange:i,previewFont:o}){return(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-3 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-medium text-foreground",children:e}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:t})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>i(e),className:(0,M.cn)("rounded-md border px-3 py-1.5 text-xs font-medium tabular-nums transition-colors",n===e?"border-foreground/30 bg-foreground/10 text-foreground shadow-sm":"border-border/50 bg-card/50 text-muted-foreground hover:border-foreground/20 hover:text-foreground"),children:[e,"px",e===a&&(0,r.jsx)("span",{className:"ml-1 text-[10px] text-muted-foreground",children:"(default)"})]},e))}),(0,r.jsx)("div",{className:(0,M.cn)("mt-2 rounded-md border border-border/50 bg-terminal px-3 py-2 text-foreground/80","mono"===o?"font-mono":"font-sans"),style:{fontSize:`${n}px`,lineHeight:1.35},children:"The quick brown fox jumps over the lazy dog"})]})}let rN={llm:"LLM provider & auth",model:"Default model",search:"Web search provider",remote:"Remote questions","tool-keys":"Tool API keys",prefs:"Global preferences",skills:"Skills install",doctor:"Validate setup",project:"Project init"},rS=["llm","model","search","remote","tool-keys","prefs","skills","doctor","project"];function rk(){let e=(0,Q.gF)(),t=tp(),s=e.boot?.onboarding,a=s?.completionRecord??null;if(void 0===a)return null;let n=new Set(a?.completedSteps??[]),i=new Set(a?.skippedSteps??[]),o=a?.completedAt??null,l=a?.lastResumePoint??null,d=t.isDevMode;return(0,r.jsxs)("div",{className:"space-y-3 rounded-md border border-border/50 bg-muted/20 p-4","data-testid":"settings-onboarding-status",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,r.jsx)(s3.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,r.jsx)("span",{children:"Onboarding setup"}),o?(0,r.jsx)(tS,{variant:"outline",className:"h-5 border-success/40 bg-success/10 text-[10px] text-success",children:"Complete"}):(0,r.jsx)(tS,{variant:"outline",className:"h-5 border-warning/40 bg-warning/10 text-[10px] text-warning",children:"Incomplete"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:o?`Last completed ${function(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return e}}(o)}.`:l?`Paused at "${rN[l]??l}". Re-run /gsd onboarding --resume to continue.`:"You haven't completed the onboarding wizard yet."})]}),(0,r.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,r.jsxs)(J,{size:"sm",variant:"outline",onClick:()=>{d&&t.toggle("forceOnboarding")},disabled:!d,"data-testid":"settings-onboarding-rerun",children:[(0,r.jsx)(tF.A,{className:"mr-1.5 h-3 w-3"}),"Re-run setup"]}),!d&&(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["Run ",(0,r.jsx)("code",{className:"rounded bg-muted px-1 font-mono",children:"/gsd onboarding"})," in your terminal"]})]})]}),(0,r.jsx)("ul",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:rS.map(e=>{let t=n.has(e),s=i.has(e),a=t?u.A:s?h.A:tW.A;return(0,r.jsxs)("li",{className:"flex items-center gap-2 text-[11px]","data-testid":`settings-onboarding-step-${e}`,children:[(0,r.jsx)(a,{className:(0,M.cn)("h-3 w-3 shrink-0",t?"text-success":s?"text-muted-foreground/70":"text-muted-foreground/50")}),(0,r.jsx)("span",{className:(0,M.cn)("truncate",t?"text-foreground":"text-muted-foreground"),children:rN[e]??e})]},e)})})]})}function rC(){let[e,t]=(0,s4.A)(),[s,a]=(0,s8.d)();return(0,r.jsxs)("div",{className:"space-y-5","data-testid":"settings-general",children:[(0,r.jsx)(s6,{title:"General",icon:(0,r.jsx)(st.A,{className:"h-3.5 w-3.5"}),subtitle:"Appearance & behavior",onRefresh:()=>{},refreshing:!1}),(0,r.jsx)(rk,{}),(0,r.jsx)(rw,{label:"Terminal font size",description:"Applies to all terminals and the chat mode interface",presets:rj,defaultSize:13,currentSize:e,onChange:t,previewFont:"mono"}),(0,r.jsx)(rw,{label:"Code font size",description:"Applies to the file viewer and code editor",presets:ry,defaultSize:14,currentSize:s,onChange:a,previewFont:"mono"})]})}let rA=[{key:"rtk",label:"RTK Shell Compression",description:"Wraps shell commands through the RTK binary to reduce token usage during command execution. RTK is downloaded automatically on first use.",warning:"Experimental — may change or be removed without notice."}];function rT(){let{state:e,data:t,busy:s,refresh:a}=ri(),n=t?.preferences??null,[o,l]=(0,i.useState)({}),[d,c]=(0,i.useState)({}),[u,m]=(0,i.useState)(null);async function h(e,t){c(t=>({...t,[e]:!0})),m(null);try{let s=await (0,el.tm)("/api/experimental",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({flag:e,enabled:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`HTTP ${s.status}`)}l(s=>({...s,[e]:t})),a()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(t=>({...t,[e]:!1}))}}return(0,i.useEffect)(()=>{t||s||"idle"!==e.phase||a()},[]),(0,i.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{l({rtk:n.experimental?.rtk===!0})},0);return()=>window.clearTimeout(e)},[n]),(0,r.jsxs)("div",{className:"space-y-4","data-testid":"settings-experimental",children:[(0,r.jsx)(s6,{title:"Experimental",icon:(0,r.jsx)(sd.A,{className:"h-3.5 w-3.5"}),subtitle:"Opt-in features — may change without notice",onRefresh:a,refreshing:s}),e.error&&(0,r.jsx)(s7,{message:e.error}),u&&(0,r.jsx)(s7,{message:u}),s&&!t&&(0,r.jsx)(s9,{label:"Loading preferences…"}),(0,r.jsx)("div",{className:"space-y-3",children:rA.map(e=>{let a=o[e.key]??!1,n=d[e.key]??!1;return(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-3 space-y-2",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:e.label}),(0,r.jsx)("span",{className:(0,M.cn)("rounded-full px-1.5 py-0.5 text-[10px] font-medium",a?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:a?"on":"off"})]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:e.description}),e.warning&&(0,r.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-warning",children:[(0,r.jsx)(eG.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsx)("span",{children:e.warning})]})]}),(0,r.jsxs)("button",{onClick:()=>h(e.key,!a),disabled:n||s||!t,className:(0,M.cn)("shrink-0 relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",a?"bg-success":"bg-muted-foreground/30"),role:"switch","aria-checked":a,"aria-label":`Toggle ${e.label}`,children:[(0,r.jsx)("span",{className:(0,M.cn)("inline-block h-3.5 w-3.5 rounded-full bg-white shadow-sm transition-transform",a?"translate-x-4":"translate-x-0.5")}),n&&(0,r.jsx)("span",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin text-white"})})]})]})},e.key)})}),t&&(0,r.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Changes are written to"," ",(0,r.jsx)("span",{className:"font-mono",children:n?.path??"~/.gsd/PREFERENCES.md"})," ","and take effect on the next session."]})]})}var rP=s(92525),rR=s(16521);function rE({className:e,...t}){return(0,r.jsx)(rR.b,{"data-slot":"label",className:(0,M.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}let r_={"active-gsd":{label:"Active",color:"text-success",bgClass:"bg-success/10",icon:t1.A},"empty-gsd":{label:"Initialized",color:"text-info",bgClass:"bg-info/10",icon:eE.A},brownfield:{label:"Existing",color:"text-warning",bgClass:"bg-warning/10",icon:C.A},"v1-legacy":{label:"Legacy",color:"text-warning",bgClass:"bg-warning/10",icon:e_.A},blank:{label:"New",color:"text-muted-foreground",bgClass:"bg-foreground/[0.04]",icon:eF.A}};function rF(e){let t=[];return e.isMonorepo&&t.push("Monorepo"),e.hasGitRepo&&t.push("Git"),e.hasPackageJson&&t.push("Node.js"),e.hasCargo&&t.push("Rust"),e.hasGoMod&&t.push("Go"),e.hasPyproject&&t.push("Python"),t}function rI(e){if(0===e.milestonesTotal)return null;let t=[];return e.activeMilestone&&t.push(e.activeMilestone),e.activeSlice&&t.push(e.activeSlice),e.phase&&t.push(e.phase),t.join(" \xb7 ")||null}function r$({project:e,isActive:t=!1,onClick:s,disabled:a=!1}){let n=r_[e.kind],i=n.icon,o=rF(e.signals),l=e.progress?rI(e.progress):null,d=e.progress?`${e.progress.milestonesCompleted}/${e.progress.milestonesTotal}`:null;return(0,r.jsxs)("button",{type:"button",onClick:s,disabled:a,className:(0,M.cn)("group flex w-full items-start gap-3.5 rounded-xl border px-4 py-3.5 text-left transition-[background-color,border-color,box-shadow,transform] duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.96]",t?"border-primary/30 bg-primary/[0.08]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50",a&&"opacity-40 pointer-events-none"),children:[(0,r.jsx)("div",{className:(0,M.cn)("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg mt-0.5",t?"bg-primary/15":n.bgClass),children:t?(0,r.jsx)(u.A,{className:"h-4 w-4 text-primary"}):(0,r.jsx)(i,{className:(0,M.cn)("h-4 w-4",n.color)})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground truncate",children:e.name}),(0,r.jsx)("span",{className:(0,M.cn)("text-[10px] font-medium shrink-0",t?"text-primary":n.color),children:t?"Current":n.label})]}),o.length>0&&(0,r.jsx)("div",{className:"mt-1 flex items-center gap-1.5",children:o.map(e=>(0,r.jsx)("span",{className:"rounded bg-foreground/[0.06] px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e},e))}),l&&(0,r.jsx)("div",{className:"mt-1.5 text-[11px] text-muted-foreground",children:l}),e.progress&&e.progress.milestonesTotal>0&&(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-foreground/[0.08]",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-success/70 transition-[width]",style:{width:`${Math.round(e.progress.milestonesCompleted/e.progress.milestonesTotal*100)}%`}})}),(0,r.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground",children:d})]})]}),(0,r.jsx)(eD.A,{className:"mt-1 h-4 w-4 shrink-0 text-muted-foreground/50 transition-[color,transform] group-hover:text-muted-foreground group-hover:translate-x-0.5"})]})}function rD({open:e,onOpenChange:t}){let s,a=ei(),n=(0,i.useSyncExternalStore)(a.subscribe,a.getSnapshot,a.getSnapshot),[l,d]=(0,i.useState)([]),[c,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!0),[x,p]=(0,i.useState)(null),g=(0,i.useCallback)(async e=>{let t=await (0,el.tm)(`/api/projects?root=${encodeURIComponent(e)}&detail=true`);if(!t.ok)throw Error(`Failed to discover projects: ${t.status}`);return await t.json()},[]);(0,i.useEffect)(()=>{if(!e)return;let t=!1;return async function(){h(!0),p(null);try{let e=await (0,el.tm)("/api/preferences");if(!e.ok)throw Error(`Failed to load preferences: ${e.status}`);let s=await e.json();if(!s.devRoot){u(null),d([]),h(!1);return}u(s.devRoot);let r=await g(s.devRoot);t||d(r)}catch(e){t||p(e instanceof Error?e.message:"Unknown error")}finally{t||h(!1)}}(),()=>{t=!0}},[e,g]);let f=(0,i.useCallback)(async e=>{h(!0),p(null);try{let t=await (0,el.tm)("/api/switch-root",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Request failed (${t.status})`)}let s=await t.json();u(s.devRoot),d(s.projects)}catch(e){p(e instanceof Error?e.message:"Failed to switch project root")}finally{h(!1)}},[]),[b,v]=(0,i.useState)(!1),[j,y]=(0,i.useState)(!1),w=(0,i.useCallback)(e=>{d(t=>[...t,e].sort((e,t)=>e.name.localeCompare(t.name))),v(!1),N(e)},[]);function N(e){n===e.path?t(!1):(t(!1),a.switchProject(e.path))}let S=[...l].sort((e,t)=>{let s={"active-gsd":0,"empty-gsd":1,brownfield:2,"v1-legacy":3,blank:4},r=s[e.kind]??5,a=s[t.kind]??5;return r!==a?r-a:e.name.localeCompare(t.name)});return s=m?(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-16 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}),"Discovering projects…"]}):x?(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 px-5 py-16 text-center",children:[(0,r.jsx)(rP.A,{className:"h-8 w-8 text-destructive"}),(0,r.jsx)("p",{className:"text-sm text-destructive",children:x})]}):c?0===S.length?(0,r.jsxs)("div",{className:"flex flex-col items-center gap-4 px-5 py-16 text-center",children:[(0,r.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl bg-muted",children:(0,r.jsx)(eE.A,{className:"h-7 w-7 text-muted-foreground"})}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-foreground",children:"No projects found"}),(0,r.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["No project directories discovered in"," ",(0,r.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono text-foreground",children:c})]})]})]}):(0,r.jsxs)("div",{className:"space-y-2",children:[S.map(e=>(0,r.jsx)(r$,{project:e,isActive:n===e.path,onClick:()=>N(e)},e.path)),(0,r.jsxs)("button",{type:"button",onClick:()=>v(!0),className:(0,M.cn)("flex w-full items-center gap-3.5 rounded-xl border border-dashed px-4 py-3.5 text-left transition-[background-color,border-color,color,transform] duration-200","border-border/50 text-muted-foreground hover:border-foreground/15 hover:text-foreground","active:scale-[0.96]"),children:[(0,r.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-foreground/[0.04]",children:(0,r.jsx)(t5.A,{className:"h-4 w-4"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Create new project"}),(0,r.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Initialize a new directory with Git"})]})]}),(0,r.jsx)(rL,{open:b,onOpenChange:v,devRoot:c,existingNames:l.map(e=>e.name),onCreated:w})]}):(0,r.jsx)(rq,{onSaved:f}),(0,r.jsx)(e2,{open:e,onOpenChange:t,children:(0,r.jsxs)(e8,{side:"left",className:"flex h-full w-full flex-col p-0 sm:max-w-[420px]","data-testid":"projects-panel",children:[(0,r.jsxs)(e6,{className:"sr-only",children:[(0,r.jsx)(e9,{children:"Projects"}),(0,r.jsx)(te,{children:"Switch between projects or create a new one"})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border/50 px-5 py-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"Projects"}),c&&!m&&(0,r.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[10px] truncate max-w-[200px]",children:c}),(0,r.jsx)("button",{type:"button",onClick:()=>y(!0),className:"shrink-0 text-[10px] text-primary hover:text-primary/80 transition-colors font-medium","data-testid":"projects-panel-change-root",children:"Change"}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"\xb7"}),(0,r.jsxs)("span",{children:[l.length," project",1!==l.length?"s":""]})]})]}),(0,r.jsx)(J,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>t(!1),children:(0,r.jsx)(o.A,{className:"h-4 w-4"})})]}),(0,r.jsx)(tB,{className:"min-h-0 flex-1",children:(0,r.jsx)("div",{className:"px-5 py-4",children:s})}),(0,r.jsx)(rM,{open:j,onOpenChange:y,onSelect:e=>void f(e),initialPath:c})]})})}function rL({open:e,onOpenChange:t,devRoot:s,existingNames:a,onCreated:n}){let[o,l]=(0,i.useState)(""),[d,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)(null),h=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!e)return;let t=window.setTimeout(()=>{l(""),m(null),c(!1)},0),s=window.setTimeout(()=>h.current?.focus(),100);return()=>{window.clearTimeout(t),window.clearTimeout(s)}},[e]);let x=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(o),p=a.includes(o),g=o.length>0&&x&&!p&&!d,f=o?p?"A project with this name already exists":x?null:"Use letters, numbers, hyphens, underscores, dots. Must start with a letter or number.":null;async function b(){if(g){c(!0),m(null);try{let e=await (0,el.tm)("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:s,name:o})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Failed (${e.status})`)}let t=await e.json();n(t)}catch(e){m(e instanceof Error?e.message:"Failed to create project"),c(!1)}}}return(0,r.jsx)(q,{open:e,onOpenChange:t,children:(0,r.jsxs)(O,{className:"sm:max-w-md",children:[(0,r.jsxs)(z,{children:[(0,r.jsx)(W,{children:"New Project"}),(0,r.jsxs)(K,{children:["Create a new project directory in"," ",(0,r.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 text-xs font-mono",children:s})]})]}),(0,r.jsx)("form",{onSubmit:e=>{e.preventDefault(),b()},className:"space-y-4 py-2",children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(rE,{htmlFor:"project-name",children:"Project name"}),(0,r.jsx)(e5.p,{ref:h,id:"project-name",placeholder:"my-project",value:o,onChange:e=>{l(e.target.value),m(null)},autoComplete:"off","aria-invalid":!!f}),f&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:f}),u&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:u}),o&&x&&!p&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground font-mono",children:[s,"/",o]})]})}),(0,r.jsxs)(G,{children:[(0,r.jsx)(J,{variant:"ghost",size:"sm",onClick:()=>t(!1),disabled:d,children:"Cancel"}),(0,r.jsxs)(J,{size:"sm",onClick:()=>void b(),disabled:!g,className:"gap-1.5",children:[d?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(t5.A,{className:"h-3.5 w-3.5"}),"Create"]})]})]})})}function rM({open:e,onOpenChange:t,onSelect:s,initialPath:a}){let[n,o]=(0,i.useState)(""),[l,d]=(0,i.useState)(null),[c,u]=(0,i.useState)([]),[m,h]=(0,i.useState)(!1),[x,p]=(0,i.useState)(null),[g,f]=(0,i.useState)(""),b=(0,i.useCallback)(async e=>{h(!0),p(null);try{let t=e?`?path=${encodeURIComponent(e)}`:"",s=await (0,el.tm)(`/api/browse-directories${t}`);if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`${s.status}`)}let r=await s.json();o(r.current),f(r.current),d(r.parent),u(r.entries)}catch(e){p(e instanceof Error?e.message:"Failed to browse")}finally{h(!1)}},[]);return(0,i.useEffect)(()=>{let t=window.setTimeout(()=>{e?b(a??void 0):(o(""),d(null),u([]),p(null),f(""))},0);return()=>window.clearTimeout(t)},[e,a,b]),(0,r.jsx)(q,{open:e,onOpenChange:t,children:(0,r.jsxs)(O,{className:"sm:max-w-lg gap-0 p-0 overflow-hidden",children:[(0,r.jsxs)(z,{className:"px-5 pt-5 pb-3",children:[(0,r.jsx)(W,{className:"text-base",children:"Choose Folder"}),(0,r.jsx)(K,{className:"text-xs",children:"Navigate to the folder that contains your project directories."})]}),(0,r.jsx)("div",{className:"border-y border-border/50 bg-muted/50 px-5 py-2",children:(0,r.jsx)("form",{onSubmit:e=>{e.preventDefault();let t=g.trim();t&&b(t)},children:(0,r.jsx)("input",{type:"text",value:g,onChange:e=>f(e.target.value),spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",placeholder:"/absolute/path/to/folder","aria-label":"Folder path","data-testid":"folder-picker-path-input",className:"w-full bg-transparent font-mono text-xs text-foreground placeholder:text-muted-foreground focus:outline-none"})})}),(0,r.jsx)(tB,{className:"h-[320px]",children:(0,r.jsxs)("div",{className:"px-2 py-1",children:[m&&(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(I.A,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),x&&(0,r.jsx)("div",{className:"px-3 py-4 text-center text-xs text-destructive",children:x}),!m&&!x&&(0,r.jsxs)(r.Fragment,{children:[l&&(0,r.jsxs)("button",{onClick:()=>void b(l),className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50",children:[(0,r.jsx)(tL.A,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"text-muted-foreground",children:".."})]}),c.map(e=>(0,r.jsxs)("button",{onClick:()=>void b(e.path),className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50 group",children:[(0,r.jsx)(w.A,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"text-foreground truncate flex-1",children:e.name}),(0,r.jsx)(E.A,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]},e.path)),!l&&0===c.length&&(0,r.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"No subdirectories"})]})]})}),(0,r.jsxs)(G,{className:"border-t border-border/50 px-5 py-3",children:[(0,r.jsx)(J,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),(0,r.jsxs)(J,{size:"sm",onClick:()=>{s(n),t(!1)},disabled:!n,className:"gap-1.5",children:[(0,r.jsx)(eE.A,{className:"h-3.5 w-3.5"}),"Select This Folder"]})]})]})})}function rq({onSaved:e,currentRoot:t}){let[s,a]=(0,i.useState)(!1),[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)(!1),h=(0,i.useCallback)(async t=>{a(!0),o(null),d(!1);try{let s=await (0,el.tm)("/api/preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`Request failed (${s.status})`)}d(!0),e(t)}catch(e){o(e instanceof Error?e.message:"Failed to save preference")}finally{a(!1)}},[e]);return t?(0,r.jsxs)("div",{className:"space-y-3","data-testid":"devroot-settings",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 truncate rounded border border-border/50 bg-muted/50 px-3 py-2 font-mono text-xs text-foreground",children:t}),(0,r.jsx)(J,{size:"sm",variant:"outline",onClick:()=>m(!0),disabled:s,className:"h-9 gap-1.5 shrink-0",children:s?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):l?(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 text-success"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eE.A,{className:"h-3.5 w-3.5"}),"Change"]})})]}),n&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:n}),l&&(0,r.jsx)("p",{className:"text-xs text-success",children:"Dev root updated"}),(0,r.jsx)(rM,{open:c,onOpenChange:m,onSelect:e=>void h(e),initialPath:t})]}):(0,r.jsxs)("div",{className:"rounded-md border border-border bg-card p-6",children:[(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-border bg-accent",children:(0,r.jsx)(tM.A,{className:"h-5 w-5 text-muted-foreground"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:"Set your development root"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground leading-relaxed",children:"Point GSD at the folder that contains your project directories. It scans one level deep."}),(0,r.jsx)(J,{onClick:()=>m(!0),disabled:s,size:"sm",className:"mt-3 gap-2","data-testid":"projects-devroot-browse",children:s?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eE.A,{className:"h-3.5 w-3.5"}),"Browse"]})}),n&&(0,r.jsx)("p",{className:"mt-2 text-xs text-destructive",children:n})]})]}),(0,r.jsx)(rM,{open:c,onOpenChange:m,onSelect:e=>void h(e)})]})}function rB(){let[e,t]=(0,i.useState)(null),[s,a]=(0,i.useState)(!0);return((0,i.useEffect)(()=>{(0,el.tm)("/api/preferences").then(e=>e.json()).then(e=>t(e.devRoot??null)).catch(()=>t(null)).finally(()=>a(!1))},[]),s)?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading preferences…"]}):(0,r.jsxs)("div",{className:"space-y-3","data-testid":"settings-devroot",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)(tM.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,r.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Development Root"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"The parent folder containing your project directories. GSD scans one level deep for projects."}),(0,r.jsx)(rq,{currentRoot:e??"",onSaved:e=>t(e)})]})}function rU(){let e=ei(),[t,s]=(0,i.useState)([]),[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)(!0),[c,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!1),[x,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(""),b=(0,i.useCallback)(async e=>{let t=await (0,el.tm)(`/api/projects?root=${encodeURIComponent(e)}&detail=true`);if(!t.ok)throw Error(`Failed to discover projects: ${t.status}`);return await t.json()},[]);(0,i.useEffect)(()=>{let e=!1;return async function(){d(!0),u(null);try{let t=await (0,el.tm)("/api/preferences");if(!t.ok)throw Error(`Failed to load preferences: ${t.status}`);let r=await t.json();if(!r.devRoot){o(null),s([]),d(!1);return}o(r.devRoot);let a=await b(r.devRoot);e||s(a)}catch(t){e||u(t instanceof Error?t.message:"Unknown error")}finally{e||d(!1)}}(),()=>{e=!0}},[b]);let v=(0,i.useCallback)(async e=>{d(!0),u(null);try{let t=await (0,el.tm)("/api/switch-root",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Request failed (${t.status})`)}let r=await t.json();o(r.devRoot),s(r.projects)}catch(e){u(e instanceof Error?e.message:"Failed to switch project root")}finally{d(!1)}},[]),j=(0,i.useCallback)(t=>{s(e=>[...e,t].sort((e,t)=>e.name.localeCompare(t.name))),h(!1),e.switchProject(t.path)},[e]),y=[...t].sort((e,t)=>{let s={"active-gsd":0,"empty-gsd":1,brownfield:2,"v1-legacy":3,blank:4},r=s[e.kind]??5,a=s[t.kind]??5;return r!==a?r-a:e.name.localeCompare(t.name)}),w=g.trim()?y.filter(e=>e.name.toLowerCase().includes(g.toLowerCase())):y,N=!l&&y.length>0,S=y.length>5;return(0,r.jsxs)("div",{className:"flex h-screen flex-col bg-background text-foreground","data-testid":"project-selection-gate",children:[(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,r.jsxs)("div",{className:"mx-auto max-w-2xl px-6 pt-16 pb-10 md:px-10 lg:pt-24",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center text-center mb-10",children:[(0,r.jsx)(a.default,{src:"/logo-black.svg",alt:"GSD-Pi Web",width:100,height:28,className:"h-7 w-auto dark:hidden"}),(0,r.jsx)(a.default,{src:"/logo-white.svg",alt:"GSD-Pi Web",width:100,height:28,className:"h-7 w-auto hidden dark:block"}),(0,r.jsx)("p",{className:"mt-3 text-sm text-muted-foreground",children:"Select a project to get started"})]}),l&&(0,r.jsxs)("div",{className:"flex items-center gap-3 py-20 justify-center text-sm text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-4 w-4 animate-spin"}),"Scanning for projects…"]}),c&&!l&&(0,r.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive",children:c}),!n&&!l&&!c&&(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Welcome to GSD"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Set a development root to get started. GSD will discover projects inside it."})]}),(0,r.jsx)(rq,{onSaved:v})]}),n&&!l&&0===y.length&&!c&&(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:"No projects found"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"No project directories were discovered. Create one to get started."})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 rounded-md border border-dashed border-border px-4 py-3 text-sm text-muted-foreground transition-colors hover:border-foreground/20 hover:text-foreground",children:[(0,r.jsx)(t5.A,{className:"h-4 w-4"}),"Create a new project"]})]}),N&&(0,r.jsxs)("div",{className:"space-y-5",children:[n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(tM.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground truncate",children:n}),(0,r.jsx)("button",{type:"button",onClick:()=>p(!0),className:"shrink-0 text-[11px] text-primary hover:text-primary/80 transition-colors font-medium","data-testid":"gate-change-root",children:"Change"})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,r.jsxs)("p",{className:"text-xs text-muted-foreground tabular-nums",children:[y.length," project",1!==y.length?"s":""]}),S&&(0,r.jsxs)("div",{className:"relative w-48",children:[(0,r.jsx)(sc.A,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),(0,r.jsx)("input",{type:"text",placeholder:"Filter…",value:g,onChange:e=>f(e.target.value),className:"h-8 w-full rounded-md border border-border bg-background pl-8 pr-3 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,r.jsxs)("div",{className:"rounded-md border border-border bg-card overflow-hidden divide-y divide-border",children:[w.map(t=>{let s=r_[t.kind],a=s.icon,n=rF(t.signals),i=t.progress?rI(t.progress):null,o=t.progress&&t.progress.milestonesTotal>0,l=o?Math.round(t.progress.milestonesCompleted/t.progress.milestonesTotal*100):0;return(0,r.jsxs)("button",{type:"button",onClick:()=>{e.switchProject(t.path)},className:"group flex w-full items-center gap-4 px-4 py-3 text-left transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:bg-accent/50",children:[(0,r.jsx)("div",{className:(0,M.cn)("flex h-8 w-8 shrink-0 items-center justify-center rounded-md",s.bgClass),children:(0,r.jsx)(a,{className:(0,M.cn)("h-3.5 w-3.5",s.color)})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:t.name}),(0,r.jsx)("span",{className:(0,M.cn)("text-[10px] font-medium shrink-0",s.color),children:s.label})]}),(0,r.jsxs)("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[n.length>0&&(0,r.jsx)("span",{children:n.join(" \xb7 ")}),n.length>0&&i&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"—"}),i&&(0,r.jsx)("span",{className:"truncate",children:i})]})]}),o&&(0,r.jsxs)("div",{className:"hidden sm:flex items-center gap-2 shrink-0 w-24",children:[(0,r.jsx)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-foreground/[0.08]",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-success/70 transition-[width]",style:{width:`${l}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] tabular-nums text-muted-foreground w-6 text-right",children:[t.progress.milestonesCompleted,"/",t.progress.milestonesTotal]})]}),t.lastModified>0&&(0,r.jsx)("span",{className:"hidden lg:inline text-[10px] text-muted-foreground shrink-0 w-16 text-right tabular-nums",children:function(e){let t=Date.now()-e;if(t<6e4)return"just now";let s=Math.floor(t/6e4);if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}(t.lastModified)}),(0,r.jsx)(E.A,{className:"h-4 w-4 shrink-0 text-muted-foreground/50 transition-colors group-hover:text-muted-foreground"})]},t.path)}),0===w.length&&g.trim()&&(0,r.jsxs)("div",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:['No projects matching "',g,'"']})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 rounded-md border border-dashed border-border px-4 py-2.5 text-sm text-muted-foreground transition-colors hover:border-foreground/20 hover:text-foreground w-full",children:[(0,r.jsx)(t5.A,{className:"h-3.5 w-3.5"}),"New project"]}),n&&(0,r.jsx)(rL,{open:m,onOpenChange:h,devRoot:n,existingNames:t.map(e=>e.name),onCreated:j})]}),n&&!l&&0===y.length&&!c&&(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsxs)("button",{type:"button",onClick:()=>p(!0),className:"flex items-center gap-2 text-xs text-primary hover:text-primary/80 transition-colors font-medium","data-testid":"gate-change-root-empty",children:[(0,r.jsx)(eE.A,{className:"h-3.5 w-3.5"}),"Change project root"]})})]})}),(0,r.jsx)(rM,{open:x,onOpenChange:p,onSelect:e=>void v(e),initialPath:n})]})}var rO=s(36843),rz=s(72612),rG=s(94991),rW=s(28649),rK=s(43056);function rV({title:e,icon:t,subtitle:s,status:a,onRefresh:n,refreshing:i}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:t}),(0,r.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),a,s&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:s})]}),n&&(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:n,disabled:i,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3",i&&"animate-spin")}),"Refresh"]})]})}function rH({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function rY({label:e}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function rJ({message:e}){return(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function rZ({label:e,value:t,variant:s}){return(0,r.jsxs)("div",{className:(0,M.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","info"===s&&"border-info/20 bg-info/5 text-info","warning"===s&&"border-warning/20 bg-warning/5 text-warning","success"===s&&"border-success/20 bg-success/5 text-success","error"===s&&"border-destructive/20 bg-destructive/5 text-destructive",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e}),(0,r.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function rQ(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60),r=t%60;if(s<60)return r>0?`${s}m ${r}s`:`${s}m`;let a=Math.floor(s/60),n=s%60;return n>0?`${a}h ${n}m`:`${a}h`}function rX(){return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-quick",children:[(0,r.jsx)(rV,{title:"Quick Task",icon:(0,r.jsx)(ev.A,{className:"h-3.5 w-3.5"})}),(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-4 space-y-3",children:[(0,r.jsx)("p",{className:"text-xs text-foreground",children:"Create a quick one-off task outside the current plan. Useful for small fixes, experiments, or ad-hoc work that doesn't fit into the milestone structure."}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Usage"}),(0,r.jsx)("div",{className:"rounded-md border border-border/50 bg-background/50 px-3 py-2 font-mono text-[11px] text-foreground/80",children:"/gsd quick <description>"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Examples"}),(0,r.jsx)("div",{className:"space-y-1.5",children:["Fix the typo in README.md header","Add .env.example with required keys","Update the LICENSE year to 2026","Run prettier on the whole project"].map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"$"}),(0,r.jsxs)("code",{className:"font-mono text-muted-foreground",children:["/gsd quick ",e]})]},e))})]}),(0,r.jsx)("div",{className:"rounded-md border border-info/15 bg-info/5 px-3 py-2 text-[11px] text-info/90",children:"Quick tasks run as standalone units — they don't affect milestone progress, slices, or the plan. Use them for work that should happen now without ceremony."})]})]})}function r0(){let e=(0,Q.gF)(),{loadHistoryData:t}=(0,Q._l)(),s=e.commandSurface.remainingCommands.history,a=s.data,n="loading"===s.phase,[o,l]=(0,i.useState)("phase");return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-history",children:[(0,r.jsx)(rV,{title:"History & Metrics",icon:(0,r.jsx)(ef.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>void t(),refreshing:n}),s.error&&(0,r.jsx)(rH,{message:s.error}),n&&!a&&(0,r.jsx)(rY,{label:"Loading history data…"}),a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rZ,{label:"Units",value:a.totals.units}),(0,r.jsx)(rZ,{label:"Cost",value:(0,Q.BD)(a.totals.cost),variant:"warning"}),(0,r.jsx)(rZ,{label:"Duration",value:rQ(a.totals.duration)}),(0,r.jsx)(rZ,{label:"Tool Calls",value:a.totals.toolCalls})]}),(0,r.jsx)("div",{className:"flex gap-1 rounded-lg border border-border/50 bg-card/50 p-0.5",children:["phase","slice","model","units"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>l(e),className:(0,M.cn)("flex-1 rounded-md px-2.5 py-1 text-[11px] font-medium capitalize transition-colors",o===e?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-muted-foreground"),children:"units"===e?"Recent":`By ${e}`},e))}),"phase"===o&&a.byPhase.length>0&&(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Phase"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Units"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,r.jsx)("tbody",{children:a.byPhase.map(e=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 capitalize",children:e.phase}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.units}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,Q.BD)(e.cost)}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:rQ(e.duration)})]},e.phase))})]})}),"slice"===o&&a.bySlice.length>0&&(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Slice"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Units"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,r.jsx)("tbody",{children:a.bySlice.map(e=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.sliceId}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.units}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,Q.BD)(e.cost)}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:rQ(e.duration)})]},e.sliceId))})]})}),"model"===o&&a.byModel.length>0&&(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Model"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Units"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"})]})}),(0,r.jsx)("tbody",{children:a.byModel.map(e=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[180px]",children:e.model}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.units}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,Q.BD)(e.cost)})]},e.model))})]})}),"units"===o&&(0,r.jsx)(r.Fragment,{children:a.units.length>0?(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Model"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,r.jsx)("tbody",{children:a.units.slice(0,20).map((e,t)=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.type}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[120px]",children:e.id}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground truncate max-w-[120px]",children:e.model}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,Q.BD)(e.cost)}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:rQ(e.finishedAt-e.startedAt)})]},t))})]})}):(0,r.jsx)(rJ,{message:"No unit history recorded yet"})}),"phase"===o&&0===a.byPhase.length&&(0,r.jsx)(rJ,{message:"No phase breakdown available"}),"slice"===o&&0===a.bySlice.length&&(0,r.jsx)(rJ,{message:"No slice breakdown available"}),"model"===o&&0===a.byModel.length&&(0,r.jsx)(rJ,{message:"No model breakdown available"})]})]})}function r1(){let e=(0,Q.gF)(),{loadUndoInfo:t,executeUndoAction:s}=(0,Q._l)(),a=e.commandSurface.remainingCommands.undo,n=a.data,o="loading"===a.phase,[l,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(null),p=async()=>{m(!0),x(null);try{let e=await s();x(e),d(!1)}finally{m(!1)}};return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-undo",children:[(0,r.jsx)(rV,{title:"Undo Last Unit",icon:(0,r.jsx)(rO.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>{x(null),d(!1),t()},refreshing:o}),a.error&&(0,r.jsx)(rH,{message:a.error}),o&&!n&&(0,r.jsx)(rY,{label:"Loading undo info…"}),h&&(0,r.jsxs)("div",{className:(0,M.cn)("rounded-lg border px-3 py-2.5 text-xs",h.success?"border-success/20 bg-success/5 text-success":"border-destructive/20 bg-destructive/5 text-destructive"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[h.success?(0,r.jsx)(u.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(t_.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"font-medium",children:h.success?"Undo Successful":"Undo Failed"})]}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:h.message})]}),n&&(0,r.jsx)(r.Fragment,{children:n.lastUnitType?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Last Completed Unit"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-[11px]",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Type"}),(0,r.jsx)("span",{className:"font-mono text-foreground/80",children:n.lastUnitType}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"ID"}),(0,r.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:n.lastUnitId??"—"}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"Key"}),(0,r.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:n.lastUnitKey??"—"})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rZ,{label:"Completed Units",value:n.completedCount}),n.commits.length>0&&(0,r.jsx)(rZ,{label:"Commits",value:n.commits.length,variant:"info"})]}),n.commits.length>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground",children:"Associated Commits"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:n.commits.map(e=>(0,r.jsx)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.slice(0,8)},e))})]}),l?(0,r.jsxs)("div",{className:"rounded-lg border border-warning/20 bg-warning/5 px-3 py-2.5 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-warning",children:[(0,r.jsx)(eG.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"font-medium",children:"This will revert the last unit and its git commits."})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)(J,{type:"button",variant:"destructive",size:"sm",onClick:()=>void p(),disabled:c,className:"h-7 gap-1.5 text-xs",children:[c?(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(tF.A,{className:"h-3 w-3"}),"Confirm Undo"]}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(!1),disabled:c,className:"h-7 text-xs",children:"Cancel"})]})]}):(0,r.jsxs)(J,{type:"button",variant:"destructive",size:"sm",onClick:()=>d(!0),disabled:c||!!h?.success,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(tF.A,{className:"h-3 w-3"}),"Undo Last Unit"]})]}):(0,r.jsx)(rJ,{message:"No completed units to undo"})})]})}function r5(){let e=(0,Q.gF)(),{loadSteerData:t,sendSteer:s}=(0,Q._l)(),a=e.commandSurface.remainingCommands.steer,n=a.data,o="loading"===a.phase,[l,d]=(0,i.useState)(""),[c,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(!1),p=async()=>{if(l.trim()){m(!0),x(!1);try{await s(l.trim()),x(!0),d(""),t()}finally{m(!1)}}};return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-steer",children:[(0,r.jsx)(rV,{title:"Steer",icon:(0,r.jsx)(rz.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>{x(!1),t()},refreshing:o}),a.error&&(0,r.jsx)(rH,{message:a.error}),o&&!n&&(0,r.jsx)(rY,{label:"Loading steer data…"}),h&&(0,r.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 text-xs text-success flex items-center gap-2",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5"}),"Steering message sent successfully."]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Current Overrides"}),n?.overridesContent?(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-background/50 px-3 py-2.5 text-[11px] font-mono text-foreground/80 whitespace-pre-wrap max-h-[200px] overflow-y-auto leading-relaxed",children:n.overridesContent}):(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-[11px] text-muted-foreground italic",children:"No active overrides"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Send Steering Message"}),(0,r.jsx)(tt,{value:l,onChange:e=>d(e.target.value),placeholder:"Enter steering instructions for the agent…",className:"min-h-[80px] text-xs resize-none"}),(0,r.jsxs)(J,{type:"button",variant:"default",size:"sm",onClick:()=>void p(),disabled:c||!l.trim(),className:"h-7 gap-1.5 text-xs",children:[c?(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(rz.A,{className:"h-3 w-3"}),"Send"]})]})]})}function r2(){let e=(0,Q.gF)(),{loadHooksData:t}=(0,Q._l)(),s=e.commandSurface.remainingCommands.hooks,a=s.data,n="loading"===s.phase;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-hooks",children:[(0,r.jsx)(rV,{title:"Hooks",icon:(0,r.jsx)(t1.A,{className:"h-3.5 w-3.5"}),status:a?(0,r.jsxs)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[a.entries.length," ",1===a.entries.length?"hook":"hooks"]}):null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,r.jsx)(rH,{message:s.error}),n&&!a&&(0,r.jsx)(rY,{label:"Loading hooks…"}),a&&(0,r.jsxs)(r.Fragment,{children:[a.entries.length>0?(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Name"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-center font-medium text-muted-foreground",children:"Status"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Targets"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cycles"})]})}),(0,r.jsx)("tbody",{children:a.entries.map(e=>{let t=Object.values(e.activeCycles).reduce((e,t)=>e+t,0);return(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.name}),(0,r.jsx)("td",{className:"px-2.5 py-1.5",children:(0,r.jsx)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:e.type})}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-center",children:(0,r.jsx)(tS,{variant:e.enabled?"secondary":"outline",className:(0,M.cn)("text-[10px] px-1.5 py-0",e.enabled?"border-success/30 text-success":"text-muted-foreground"),children:e.enabled?"enabled":"disabled"})}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground",children:e.targets.length>0?e.targets.join(", "):"all"}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:t})]},e.name)})})]})}):(0,r.jsx)(rJ,{message:"No hooks configured"}),a.formattedStatus&&(0,r.jsx)("div",{className:"rounded-lg border border-border/50 bg-background/50 px-3 py-2.5 text-[11px] font-mono text-muted-foreground whitespace-pre-wrap leading-relaxed",children:a.formattedStatus})]})]})}function r3(){let e=(0,Q.gF)(),{loadInspectData:t}=(0,Q._l)(),s=e.commandSurface.remainingCommands.inspect,a=s.data,n="loading"===s.phase;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-inspect",children:[(0,r.jsx)(rV,{title:"Inspect Database",icon:(0,r.jsx)(rG.A,{className:"h-3.5 w-3.5"}),subtitle:a?.schemaVersion!=null?`v${a.schemaVersion}`:null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,r.jsx)(rH,{message:s.error}),n&&!a&&(0,r.jsx)(rY,{label:"Loading database…"}),a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(rZ,{label:"Decisions",value:a.counts.decisions,variant:"info"}),(0,r.jsx)(rZ,{label:"Requirements",value:a.counts.requirements,variant:"info"}),(0,r.jsx)(rZ,{label:"Artifacts",value:a.counts.artifacts})]}),a.recentDecisions.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Recent Decisions (",a.recentDecisions.length,")"]}),(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Decision"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Choice"})]})}),(0,r.jsx)("tbody",{children:a.recentDecisions.map(e=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.id}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-foreground/80 max-w-[200px] truncate",children:e.decision}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground max-w-[150px] truncate",children:e.choice})]},e.id))})]})})]}),a.recentRequirements.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Recent Requirements (",a.recentRequirements.length,")"]}),(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Status"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Description"})]})}),(0,r.jsx)("tbody",{children:a.recentRequirements.map(e=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.id}),(0,r.jsx)("td",{className:"px-2.5 py-1.5",children:(0,r.jsx)(tS,{variant:"active"===e.status?"secondary":"outline",className:(0,M.cn)("text-[10px] px-1.5 py-0","active"===e.status&&"border-success/30 text-success","validated"===e.status&&"border-info/30 text-info","deferred"===e.status&&"text-muted-foreground"),children:e.status})}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-foreground/80 max-w-[220px] truncate",children:e.description})]},e.id))})]})})]}),0===a.recentDecisions.length&&0===a.recentRequirements.length&&(0,r.jsx)(rJ,{message:"Database is empty — no decisions or requirements recorded"})]})]})}function r4(){let e=(0,Q.gF)(),{loadExportData:t}=(0,Q._l)(),s=e.commandSurface.remainingCommands.exportData,a=s.data,n="loading"===s.phase,[o,l]=(0,i.useState)("markdown"),d=e=>{let t="json"===e.format?"application/json":"text/markdown",s=new Blob([e.content],{type:t}),r=URL.createObjectURL(s),a=document.createElement("a");a.href=r,a.download=e.filename,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)},c=async()=>{let e=await t(o);e&&d(e)};return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-export",children:[(0,r.jsx)(rV,{title:"Export",icon:(0,r.jsx)(su.A,{className:"h-3.5 w-3.5"})}),s.error&&(0,r.jsx)(rH,{message:s.error}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Format"}),(0,r.jsx)("div",{className:"flex gap-1 rounded-lg border border-border/50 bg-card/50 p-0.5",children:["markdown","json"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>l(e),className:(0,M.cn)("flex-1 rounded-md px-3 py-1.5 text-[11px] font-medium capitalize transition-colors",o===e?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-muted-foreground"),children:"markdown"===e?"Markdown":"JSON"},e))})]}),(0,r.jsxs)(J,{type:"button",variant:"default",size:"sm",onClick:()=>void c(),disabled:n,className:"h-7 gap-1.5 text-xs",children:[n?(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(su.A,{className:"h-3 w-3"}),"Generate Export"]}),a&&(0,r.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"font-medium",children:"Export Ready"})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground",children:a.filename}),(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(a),className:"h-6 gap-1 text-[10px]",children:[(0,r.jsx)(su.A,{className:"h-2.5 w-2.5"}),"Download Again"]})]})]})]})}function r8(){let e=(0,Q.gF)(),{loadCleanupData:t,executeCleanupAction:s}=(0,Q._l)(),a=e.commandSurface.remainingCommands.cleanup,n=a.data,o="loading"===a.phase,[l,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)(null),h=n?.branches.filter(e=>e.merged)??[],x=n?.snapshots??[],p=async e=>{d(!0),m(null);try{let r="branches"===e?h.map(e=>e.name):[],a="snapshots"===e?x.map(e=>e.ref):[],n=await s(r,a);m(n),t()}finally{d(!1)}};return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-cleanup",children:[(0,r.jsx)(rV,{title:"Cleanup",icon:(0,r.jsx)(s2.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>{m(null),t()},refreshing:o}),a.error&&(0,r.jsx)(rH,{message:a.error}),o&&!n&&(0,r.jsx)(rY,{label:"Scanning for cleanup targets…"}),c&&(0,r.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 text-xs text-success",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"font-medium",children:"Cleanup Complete"})]}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:c.message})]}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Branches (",n.branches.length,")"]}),h.length>0&&(0,r.jsxs)(J,{type:"button",variant:"destructive",size:"sm",onClick:()=>void p("branches"),disabled:l,className:"h-6 gap-1 text-[10px]",children:[l?(0,r.jsx)(I.A,{className:"h-2.5 w-2.5 animate-spin"}):(0,r.jsx)(rW.A,{className:"h-2.5 w-2.5"}),"Delete Merged (",h.length,")"]})]}),n.branches.length>0?(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Branch"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-center font-medium text-muted-foreground",children:"Status"})]})}),(0,r.jsx)("tbody",{children:n.branches.map(e=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[250px]",children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(C.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.name]})}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-center",children:(0,r.jsx)(tS,{variant:e.merged?"secondary":"outline",className:(0,M.cn)("text-[10px] px-1.5 py-0",e.merged?"border-success/30 text-success":"text-muted-foreground"),children:e.merged?"merged":"active"})})]},e.name))})]})}):(0,r.jsx)(rJ,{message:"No branches to clean up"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Snapshots (",n.snapshots.length,")"]}),x.length>0&&(0,r.jsxs)(J,{type:"button",variant:"destructive",size:"sm",onClick:()=>void p("snapshots"),disabled:l,className:"h-6 gap-1 text-[10px]",children:[l?(0,r.jsx)(I.A,{className:"h-2.5 w-2.5 animate-spin"}):(0,r.jsx)(sa.A,{className:"h-2.5 w-2.5"}),"Prune Snapshots (",x.length,")"]})]}),n.snapshots.length>0?(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Ref"}),(0,r.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Date"})]})}),(0,r.jsx)("tbody",{children:n.snapshots.map(e=>(0,r.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,r.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[200px]",children:e.ref}),(0,r.jsx)("td",{className:"px-2.5 py-1.5 text-right text-muted-foreground",children:e.date})]},e.ref))})]})}):(0,r.jsx)(rJ,{message:"No snapshots to prune"})]})]})]})}function r6(){let e=(0,Q.gF)(),t=(0,Q.K0)(e),s=t?.milestones??[],a=t?.active;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-queue",children:[(0,r.jsx)(rV,{title:"Queue",icon:(0,r.jsx)(rK.A,{className:"h-3.5 w-3.5"}),status:(0,r.jsxs)(tS,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[s.length," ",1===s.length?"milestone":"milestones"]})}),s.length>0?(0,r.jsx)("div",{className:"space-y-2",children:s.map(e=>{var t;let s=a?.milestoneId===e.id,n={done:(t=e.slices).filter(e=>e.done).length,total:t.length};return(0,r.jsxs)("div",{className:(0,M.cn)("rounded-lg border px-3 py-2.5 space-y-1.5",s?"border-info/25 bg-info/5":"border-border/50 bg-card/50"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-mono font-medium text-foreground/80",children:e.id}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate",children:e.title}),s&&(0,r.jsx)(tS,{variant:"secondary",className:"text-[10px] px-1.5 py-0 border-info/30 text-info",children:"active"})]}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums shrink-0",children:[n.done,"/",n.total," slices"]})]}),n.total>0&&(0,r.jsx)("div",{className:"h-1 rounded-full bg-border/50 overflow-hidden",children:(0,r.jsx)("div",{className:(0,M.cn)("h-full rounded-full transition-[width]",n.done===n.total?"bg-success":"bg-info"),style:{width:`${n.done/n.total*100}%`}})}),s&&e.slices.length>0&&(0,r.jsx)("div",{className:"space-y-0.5 pt-1",children:e.slices.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[e.done?(0,r.jsx)(u.A,{className:"h-3 w-3 text-success shrink-0"}):(0,r.jsx)("span",{className:(0,M.cn)("inline-block h-1.5 w-1.5 rounded-full shrink-0",a?.sliceId===e.id?"bg-info":"bg-border/50")}),(0,r.jsx)("span",{className:"font-mono text-muted-foreground",children:e.id}),(0,r.jsx)("span",{className:(0,M.cn)("truncate",e.done?"text-muted-foreground line-through":"text-foreground/80"),children:e.title}),a?.sliceId===e.id&&!e.done&&(0,r.jsx)(tS,{variant:"outline",className:"text-[9px] px-1 py-0 text-info",children:"current"})]},e.id))})]},e.id)})}):(0,r.jsx)(rJ,{message:"No milestones in the plan"})]})}let r7=["general","model","session-behavior","recovery","auth","integrations","workspace","experimental"],r9=["git"],ae=["resume","name","fork","session","compact"];function at(e){return({model:"Model",thinking:"Thinking",git:"Git",login:"Login",logout:"Logout",settings:"Settings",resume:"Resume",name:"Name",fork:"Fork",session:"Session",export:"Export",compact:"Compact"})[e??""]??"Settings"}function as(e){let t=Date.now()-new Date(e).getTime();if(t<6e4)return"just now";let s=Math.floor(t/6e4);if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);return`${a}d ago`}function ar({status:e}){return(0,r.jsx)("span",{className:(0,M.cn)("inline-block h-1.5 w-1.5 rounded-full","ok"===e&&"bg-success","warning"===e&&"bg-warning","error"===e&&"bg-destructive","idle"===e&&"bg-foreground/20")})}function aa({title:e,action:t,status:s}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s]}),t]})}function an({label:e,children:t,mono:s}){return(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-4 py-1.5 text-sm",children:[(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e}),(0,r.jsx)("span",{className:(0,M.cn)("text-right text-foreground",s&&"font-mono text-xs"),children:t})]})}function ai({label:e,description:t,checked:s,onCheckedChange:a,disabled:n,busy:i,testId:o}){return(0,r.jsxs)("div",{className:"flex items-start justify-between gap-4 rounded-lg border border-border/50 bg-card/50 px-4 py-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e,i&&(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),t&&(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),(0,r.jsx)(sp,{checked:s,onCheckedChange:a,disabled:n||i,"data-testid":o})]})}function ao({options:e,value:t,onChange:s,disabled:a}){return(0,r.jsx)("div",{className:"inline-flex rounded-lg border border-border bg-card/50 p-0.5",children:e.map(e=>(0,r.jsx)("button",{type:"button",className:(0,M.cn)("rounded-md px-3 py-1.5 text-xs font-medium transition-[color,background-color,box-shadow] duration-150 ease-out",t===e.value?"bg-foreground/10 text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:()=>s(e.value),disabled:a||t===e.value,children:e.label},e.value))})}function al(){var e,t;let s,a,n,l,d=(0,Q.gF)(),{closeCommandSurface:c,openCommandSurface:u,refreshBoot:m,setCommandSurfaceSection:h,selectCommandSurfaceTarget:x,loadGitSummary:p,loadRecoveryDiagnostics:g,loadForensicsDiagnostics:f,loadDoctorDiagnostics:b,loadSkillHealthDiagnostics:v,loadKnowledgeData:j,loadCapturesData:y,loadSettingsData:w,updateSessionBrowserState:N,loadSessionBrowser:S,renameSessionFromSurface:k,loadAvailableModels:A,applyModelSelection:P,applyThinkingLevel:R,setSteeringModeFromSurface:$,setFollowUpModeFromSurface:D,setAutoCompactionFromSurface:L,setAutoRetryFromSurface:q,abortRetryFromSurface:B,switchSessionFromSurface:U,loadSessionStats:O,exportSessionFromSurface:z,loadForkMessages:G,forkSessionFromSurface:W,compactSessionFromSurface:K,saveApiKeyFromSurface:V,startProviderFlowFromSurface:H,submitProviderFlowInputFromSurface:Y,cancelProviderFlowFromSurface:Z,logoutProviderFromSurface:X,loadHistoryData:ee,loadInspectData:et,loadHooksData:es,loadUndoInfo:er,loadCleanupData:ea,loadSteerData:en}=(0,Q._l)(),{commandSurface:ei}=d,eo=d.boot?.onboarding??null,el=eo?.activeFlow??null,ed=ei.gitSummary,ec=ei.recovery,eu=ei.sessionBrowser,em=d.boot?.bridge.sessionState??null,eh=ei.settingsRequests,ex=(0,Q.iT)(d.boot?.bridge),ep=(0,Q._0)(d.boot?.bridge),[eg,ef]=(0,i.useState)({}),[eb,ev]=(0,i.useState)(""),ej=(0,i.useRef)(null);(0,i.useEffect)(()=>{!ei.open||"model"!==ei.section||ei.availableModels.length>0||"loading_models"!==ei.pendingAction&&A()},[ei.open,ei.section,ei.availableModels.length,ei.pendingAction,A]),(0,i.useEffect)(()=>{!ei.open||"git"!==ei.section||"load_git_summary"===ei.pendingAction||ei.gitSummary.loaded||ei.gitSummary.error||p()},[ei.open,ei.section,ei.pendingAction,ei.gitSummary.loaded,ei.gitSummary.error,p]),(0,i.useEffect)(()=>{!ei.open||"recovery"!==ei.section||"load_recovery_diagnostics"===ei.pendingAction||ei.recovery.pending||(!ei.recovery.loaded||ei.recovery.stale||ei.recovery.error)&&g()},[ei.open,ei.section,ei.pendingAction,ei.recovery.pending,ei.recovery.loaded,ei.recovery.stale,ei.recovery.error,g]);let ey=ei.diagnostics,ew=ei.knowledgeCaptures,eN=ei.settingsData,eS=ei.remainingCommands;(0,i.useEffect)(()=>{ei.open&&("gsd-forensics"===ei.section&&"idle"===ey.forensics.phase?f():"gsd-doctor"===ei.section&&"idle"===ey.doctor.phase?b():"gsd-skill-health"===ei.section&&"idle"===ey.skillHealth.phase?v():"gsd-knowledge"===ei.section&&"idle"===ew.knowledge.phase?(j(),y()):("gsd-capture"===ei.section||"gsd-triage"===ei.section)&&"idle"===ew.captures.phase?(y(),j()):("gsd-prefs"===ei.section||"gsd-mode"===ei.section||"gsd-config"===ei.section||"experimental"===ei.section)&&"idle"===eN.phase?w():"gsd-history"===ei.section&&"idle"===eS.history.phase?ee():"gsd-inspect"===ei.section&&"idle"===eS.inspect.phase?et():"gsd-hooks"===ei.section&&"idle"===eS.hooks.phase?es():"gsd-undo"===ei.section&&"idle"===eS.undo.phase?er():"gsd-cleanup"===ei.section&&"idle"===eS.cleanup.phase?ea():"gsd-steer"===ei.section&&"idle"===eS.steer.phase&&en())},[ei.open,ei.section,ey.forensics.phase,ey.doctor.phase,ey.skillHealth.phase,ew.knowledge.phase,ew.captures.phase,eN.phase,eS.history.phase,eS.inspect.phase,eS.hooks.phase,eS.undo.phase,eS.cleanup.phase,eS.steer.phase,f,b,v,j,y,w,ee,et,es,er,ea,en]),(0,i.useEffect)(()=>{!ei.open||"resume"!==ei.section&&"name"!==ei.section||"load_session_browser"===ei.pendingAction||ei.sessionBrowser.loaded||S()},[ei.open,ei.section,ei.pendingAction,ei.sessionBrowser.loaded,S]),(0,i.useEffect)(()=>{if(!ei.open)return;let e=ej.current;e&&(e.scrollTop=0)},[ei.open,ei.activeSurface,ei.section]),(0,i.useEffect)(()=>{!ei.open||"session"!==ei.section||ei.sessionStats||"load_session_stats"!==ei.pendingAction&&O()},[ei.open,ei.section,ei.sessionStats,ei.pendingAction,O]),(0,i.useEffect)(()=>{!ei.open||"fork"!==ei.section||ei.forkMessages.length>0||"load_fork_messages"!==ei.pendingAction&&G()},[ei.open,ei.section,ei.forkMessages.length,ei.pendingAction,G]),(0,i.useEffect)(()=>{if(!ei.open||"resume"!==ei.section)return;let e=ei.selectedTarget?.kind==="resume"?ei.selectedTarget:null;if(e?.sessionPath)return;let t=eu.sessions.find(e=>!e.isActive)??eu.sessions[0];t&&x({kind:"resume",sessionPath:t.path})},[ei.open,ei.section,ei.selectedTarget,eu.sessions,x]),(0,i.useEffect)(()=>{if(!ei.open||"name"!==ei.section)return;let e=ei.selectedTarget?.kind==="name"?ei.selectedTarget:null;if(e?.sessionPath)return;let t=eu.sessions.find(e=>e.isActive)??eu.sessions[0];t&&x({kind:"name",sessionPath:t.path,name:t.name??""})},[ei.open,ei.section,ei.selectedTarget,eu.sessions,x]),(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{ev("")},0);return()=>window.clearTimeout(e)},[el?.flowId]),(0,i.useEffect)(()=>{ei.lastError&&sh.oR.error(ei.lastError)},[ei.lastError]),(0,i.useEffect)(()=>{ei.lastResult&&sh.oR.success(ei.lastResult)},[ei.lastResult]);let ek=ei.selectedTarget?.kind==="model"?ei.selectedTarget:null,eC=ei.selectedTarget?.kind==="thinking"?ei.selectedTarget:null,eA=ei.selectedTarget?.kind==="auth"?ei.selectedTarget:null,eT=ei.selectedTarget?.kind==="resume"?ei.selectedTarget:null,eP=ei.selectedTarget?.kind==="name"?ei.selectedTarget:null,eR=ei.selectedTarget?.kind==="fork"?ei.selectedTarget:null,eE=ei.selectedTarget?.kind==="session"?ei.selectedTarget:null,e_=ei.selectedTarget?.kind==="compact"?ei.selectedTarget:null,eF=(e=ei.activeSurface,t=ei.selectedTarget,t?.kind==="auth"?t.intent:"login"===e?"login":"logout"===e?"logout":"manage"),eI=eo?.required.providers.find(e=>e.id===eA?.providerId)??null,e$=(ek?.query??ei.args).trim().toLowerCase(),eD=(0,i.useMemo)(()=>e$?ei.availableModels.filter(e=>`${e.provider} ${e.modelId} ${e.name??""}`.toLowerCase().includes(e$)):ei.availableModels,[ei.availableModels,e$]),eL=(0,i.useMemo)(()=>{let e=new Map;for(let t of eD){let s=t.provider,r=e.get(s);r?r.push(t):e.set(s,[t])}return e},[eD]),eM="idle"!==d.onboardingRequestState,eq="loading_models"===ei.pendingAction||"get_available_models"===d.commandInFlight,eB="load_git_summary"===ei.pendingAction,eU="load_recovery_diagnostics"===ei.pendingAction||ec.pending,eO=ec.diagnostics,eG="load_session_browser"===ei.pendingAction,eW="load_fork_messages"===ei.pendingAction||"fork_session"===ei.pendingAction,eK="load_session_stats"===ei.pendingAction||"export_html"===ei.pendingAction,eV="switch_session"===ei.pendingAction,eH="rename_session"===ei.pendingAction,eY="compact_session"===ei.pendingAction||em?.isCompacting===!0,eJ=eh.steeringMode.pending||eh.followUpMode.pending,eZ=eh.autoCompaction.pending,eQ=eh.autoRetry.pending,e0=eh.abortRetry.pending,e1=eI?eg[eI.id]??"":"",e3=tp(),e4=function(e,t=!1){switch(e){case"git":return[...r9];case"resume":case"name":case"fork":case"session":case"export":case"compact":return[...ae];default:return t?[...r7,"admin"]:[...r7]}}(ei.activeSurface,e3.isDevMode),e7=`/${ei.activeSurface??"settings"}`,ts=e=>{let t="name"===e,s=t?eP?.sessionPath:eT?.sessionPath;return(0,r.jsxs)("div",{className:"space-y-4","data-testid":t?"command-surface-name":"command-surface-resume",children:[(0,r.jsx)(aa,{title:t?"Rename":"Resume",status:t?null:(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:ep??"pending"})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)(sc.A,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,r.jsx)(e5.p,{value:eu.query,onChange:e=>N({query:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),S())},placeholder:"Search sessions…",className:"h-8 pl-9 text-xs",disabled:eG,"data-testid":"command-surface-session-browser-query"})]}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>void S(),disabled:eG,className:"h-8 w-8 p-0",children:(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3.5 w-3.5",eG&&"animate-spin")})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(ao,{options:[{value:"threaded",label:"Threaded"},{value:"recent",label:"Recent"},{value:"relevance",label:"Relevance"}],value:eu.sortMode,onChange:e=>{N({sortMode:e}),S({sortMode:e})},disabled:eG}),(0,r.jsx)("button",{type:"button",className:(0,M.cn)("rounded-md border border-border px-2.5 py-1.5 text-[11px] font-medium transition-colors","named"===eu.nameFilter?"bg-foreground/10 text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>{let e="named"===eu.nameFilter?"all":"named";N({nameFilter:e}),S({nameFilter:e})},disabled:eG,children:"Named"})]}),eu.error&&(0,r.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:eu.error}),eG&&0===eu.sessions.length?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading sessions…"]}):eu.sessions.length>0?(0,r.jsx)("div",{className:"space-y-1","data-testid":"command-surface-session-browser-results",children:eu.sessions.map(e=>{let a=e.path===s;return(0,r.jsxs)("button",{type:"button",className:(0,M.cn)("flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",a?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),style:{paddingLeft:`${.75+.6*e.depth}rem`},onClick:()=>t?x({kind:"name",sessionPath:e.path,name:eP?.sessionPath===e.path?eP?.name??e.name??"":e.name??""}):x({kind:"resume",sessionPath:e.path}),"data-testid":`command-surface-session-browser-item-${e.id}`,children:[(0,r.jsx)("div",{className:(0,M.cn)("mt-1 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",a?"border-foreground bg-foreground":"border-foreground/25"),children:a&&(0,r.jsx)(eX.A,{className:"h-2.5 w-2.5 text-background"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.name||e.firstMessage||e.id}),e.isActive&&(0,r.jsx)(ar,{status:"ok"})]}),e.name&&e.firstMessage&&(0,r.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.firstMessage}),(0,r.jsxs)("div",{className:"mt-0.5 flex gap-3 text-[11px] text-muted-foreground",children:[(0,r.jsxs)("span",{children:[e.messageCount," msgs"]}),(0,r.jsx)("span",{children:as(e.modifiedAt)})]})]})]},e.path)})}):(0,r.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No sessions matched."}),eu.loaded&&(0,r.jsxs)("p",{className:"text-[11px] text-muted-foreground","data-testid":"command-surface-session-browser-meta",children:["Current-project sessions \xb7 ",eu.returnedSessions," of ",eu.totalSessions," \xb7 ",eu.sortMode," \xb7 ",eu.nameFilter]}),t&&(0,r.jsxs)("div",{className:"space-y-3 border-t border-border/50 pt-3",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(e5.p,{value:eP?.name??"",onChange:e=>x({kind:"name",sessionPath:eP?.sessionPath,name:e.target.value}),placeholder:"Session name",className:"h-8 flex-1 text-xs",disabled:!eP?.sessionPath||eH,"data-testid":"command-surface-rename-input"}),(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>eP?.sessionPath&&void k(eP.sessionPath,eP.name),disabled:!eP?.sessionPath||!eP.name.trim()||eH,"data-testid":"command-surface-apply-rename",className:"h-8 gap-1.5",children:[eH?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(so.A,{className:"h-3.5 w-3.5"}),"Rename"]})]}),ei.renameRequest.error&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:ei.renameRequest.error}),ei.renameRequest.result&&(0,r.jsx)("p",{className:"text-xs text-success",children:ei.renameRequest.result})]}),!t&&(0,r.jsxs)("div",{className:"flex items-center justify-between border-t border-border/50 pt-3",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"command-surface-resume-state",children:eV?"Switching…":ei.resumeRequest.error??ei.resumeRequest.result??"Select a session"}),(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>eT?.sessionPath&&void U(eT.sessionPath),disabled:!eT?.sessionPath||eV,"data-testid":"command-surface-apply-resume",className:"h-8 gap-1.5",children:[eV?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(sr.A,{className:"h-3.5 w-3.5"}),"Switch"]})]})]})},tr=e4.length<=1,ta="git"===ei.activeSurface,tn=ed.result;return(0,r.jsx)(e2,{open:ei.open,onOpenChange:e=>!e&&c(),children:(0,r.jsxs)(e8,{side:"right",className:"flex h-full w-full flex-col p-0 sm:max-w-[540px]","data-testid":"command-surface",children:[(0,r.jsxs)(e6,{className:"sr-only",children:[(0,r.jsx)(e9,{children:at(ei.activeSurface)}),(0,r.jsx)(te,{children:"Settings and controls"})]}),(0,r.jsxs)("div",{className:"flex h-full min-h-0",children:[!tr&&(0,r.jsx)("nav",{className:"flex w-12 shrink-0 flex-col items-center gap-0.5 border-r border-border/50 bg-card/50 py-3","data-testid":"command-surface-sections",children:e4.map(e=>{let t=ei.section===e;return(0,r.jsxs)(tk.m_,{children:[(0,r.jsx)(tk.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button",className:(0,M.cn)("flex h-9 w-9 items-center justify-center rounded-lg transition-colors",t?"bg-foreground/10 text-foreground":"text-muted-foreground hover:bg-foreground/[0.04] hover:text-foreground"),onClick:()=>h(e),"data-testid":`command-surface-section-${e}`,children:{general:(0,r.jsx)(st.A,{className:"h-4 w-4"}),model:(0,r.jsx)(ez.A,{className:"h-4 w-4"}),thinking:(0,r.jsx)(ss.A,{className:"h-4 w-4"}),queue:(0,r.jsx)(sr.A,{className:"h-4 w-4"}),compaction:(0,r.jsx)(sa.A,{className:"h-4 w-4"}),retry:(0,r.jsx)(sn.A,{className:"h-4 w-4"}),"session-behavior":(0,r.jsx)(sr.A,{className:"h-4 w-4"}),recovery:(0,r.jsx)(F.A,{className:"h-4 w-4"}),auth:(0,r.jsx)(tw.A,{className:"h-4 w-4"}),admin:(0,r.jsx)(si.A,{className:"h-4 w-4"}),git:(0,r.jsx)(C.A,{className:"h-4 w-4"}),resume:(0,r.jsx)(sr.A,{className:"h-4 w-4"}),name:(0,r.jsx)(so.A,{className:"h-4 w-4"}),fork:(0,r.jsx)(C.A,{className:"h-4 w-4"}),session:(0,r.jsx)(_.A,{className:"h-4 w-4"}),compact:(0,r.jsx)(sa.A,{className:"h-4 w-4"}),workspace:(0,r.jsx)(tM.A,{className:"h-4 w-4"}),integrations:(0,r.jsx)(sl.A,{className:"h-4 w-4"}),experimental:(0,r.jsx)(sd.A,{className:"h-4 w-4"})}[e]??null})}),(0,r.jsx)(tk.ZI,{side:"right",sideOffset:6,children:{general:"General",model:"Model",thinking:"Thinking",queue:"Queue",compaction:"Compaction",retry:"Retry","session-behavior":"Session",recovery:"Recovery",auth:"Auth",admin:"Admin",git:"Git",resume:"Resume",name:"Name",fork:"Fork",session:"Session",compact:"Compact",workspace:"Workspace",integrations:"Integrations",experimental:"Experimental"}[e]??e})]},e)})}),(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[ta?(s=tn?.kind==="repo"?tn.branch??"detached":null,a=tn?.kind==="repo"?tn.mainBranch:null,n=tn?.kind==="repo"&&tn.hasChanges,l=tn?.kind==="repo"&&!n,(0,r.jsx)("div",{className:"border-b border-border/50 px-5 py-4",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:(0,M.cn)("flex h-8 w-8 items-center justify-center rounded-lg",l?"bg-success/10":n?"bg-warning/10":"bg-card/50"),children:(0,r.jsx)(C.A,{className:(0,M.cn)("h-4 w-4",l?"text-success":n?"text-warning":"text-muted-foreground")})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-foreground","data-testid":"command-surface-title",children:s??"Git"}),s&&a&&s!==a&&(0,r.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["from ",a]})]}),tn?.kind==="repo"&&(0,r.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5",children:[(0,r.jsx)(ar,{status:l?"ok":n?"warning":"idle"}),(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l?"Clean":n?"Changes detected":"Loading…"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>void p(),disabled:eB,"aria-label":"Refresh",className:"h-7 w-7",children:(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3.5 w-3.5",eB&&"animate-spin")})}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"icon",onClick:c,"aria-label":"Close",className:"h-7 w-7",children:(0,r.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})]})})):(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-border/50 px-5 py-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Command surface"}),(0,r.jsx)("div",{className:"text-lg font-semibold text-foreground","data-testid":"command-surface-title",children:at(ei.activeSurface)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"rounded-full border border-border bg-card px-2.5 py-1 text-xs font-medium text-muted-foreground","data-testid":"command-surface-kind",children:e7}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"icon",onClick:c,"aria-label":"Close",className:"h-8 w-8",children:(0,r.jsx)(o.A,{className:"h-4 w-4"})})]})]}),(ei.lastResult||ei.lastError)&&(0,r.jsx)("div",{className:(0,M.cn)("border-b border-border/50 px-5 py-3 text-xs",ei.lastError?"bg-destructive/5 text-destructive":"bg-success/5 text-success"),"data-testid":"command-surface-result",children:ei.lastError??ei.lastResult}),(0,r.jsx)(tB,{className:"min-h-0 flex-1",viewportRef:ej,children:(0,r.jsx)("div",{className:"px-5 py-5",children:(()=>{switch(ei.section){case"general":return(0,r.jsx)(rC,{});case"experimental":return(0,r.jsx)(rT,{});case"model":case"thinking":return(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-models",children:[(0,r.jsx)(aa,{title:"Model",status:(0,r.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:ex}),action:(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>void A(),disabled:eq,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3",eq&&"animate-spin")}),"Refresh"]})}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(sc.A,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,r.jsx)(e5.p,{value:ek?.query??ei.args,onChange:e=>x({kind:"model",provider:ek?.provider,modelId:ek?.modelId,query:e.target.value}),placeholder:"Filter models…",className:"h-8 pl-9 text-xs"})]}),eq&&0===ei.availableModels.length?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-8 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading models…"]}):eD.length>0?(0,r.jsx)("div",{className:"space-y-4",children:Array.from(eL.entries()).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground",children:e}),(0,r.jsx)("div",{className:"space-y-0.5",children:t.map(e=>{let t=ek?.provider===e.provider&&ek?.modelId===e.modelId;return(0,r.jsxs)("button",{type:"button",className:(0,M.cn)("group flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"model",provider:e.provider,modelId:e.modelId,query:ek?.query}),children:[(0,r.jsx)("div",{className:(0,M.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,r.jsx)(eX.A,{className:"h-2.5 w-2.5 text-background"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.name||e.modelId}),e.isCurrent&&(0,r.jsx)(ar,{status:"ok"})]}),(0,r.jsx)("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:e.modelId})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.isCurrent&&(0,r.jsx)("span",{className:"rounded bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Active"}),e.reasoning&&(0,r.jsx)("span",{className:"rounded bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Thinking"})]})]},`${e.provider}/${e.modelId}`)})})]},e))}):(0,r.jsx)("p",{className:"py-6 text-center text-xs text-muted-foreground",children:"No models matched."}),(0,r.jsx)("div",{className:"flex justify-end border-t border-border/50 pt-3",children:(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>ek?.provider&&ek?.modelId&&void P(ek.provider,ek.modelId),disabled:!ek?.provider||!ek.modelId||"set_model"===ei.pendingAction,"data-testid":"command-surface-apply-model",className:"h-8 gap-1.5",children:["set_model"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(eX.A,{className:"h-3.5 w-3.5"}),"Apply model"]})})]}),(0,r.jsx)("div",{className:"border-t border-border/50 pt-6",children:(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-thinking",children:[(0,r.jsx)(aa,{title:"Thinking level",status:(0,r.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:d.boot?.bridge.sessionState?.thinkingLevel??"off"})}),(0,r.jsx)("div",{className:"space-y-1",children:sg.ll.map(e=>{let t=eC?.level===e,s=d.boot?.bridge.sessionState?.thinkingLevel===e,a="off"===e?"No reasoning overhead":"minimal"===e?"Light reasoning":"low"===e?"Basic analysis":"medium"===e?"Balanced reasoning":"high"===e?"Deep analysis":"Maximum deliberation";return(0,r.jsxs)("button",{type:"button",className:(0,M.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"thinking",level:e}),children:[(0,r.jsx)("div",{className:(0,M.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,r.jsx)(eX.A,{className:"h-2.5 w-2.5 text-background"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium capitalize text-foreground",children:e}),s&&(0,r.jsx)(ar,{status:"ok"})]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:a})]})]},e)})}),(0,r.jsx)("div",{className:"flex justify-end border-t border-border/50 pt-3",children:(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>eC&&void R(eC.level),disabled:!eC||"set_thinking_level"===ei.pendingAction,"data-testid":"command-surface-apply-thinking",className:"h-8 gap-1.5",children:["set_thinking_level"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(eX.A,{className:"h-3.5 w-3.5"}),"Apply"]})})]})})]});case"session-behavior":case"queue":case"compaction":case"retry":return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-5","data-testid":"command-surface-queue-settings",children:[(0,r.jsx)(aa,{title:"Queue modes"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Steering mode"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"How steering messages queue during streaming"})]}),eh.steeringMode.pending&&(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),(0,r.jsx)(ao,{options:[{value:"all",label:"Queue all"},{value:"one-at-a-time",label:"One at a time"}],value:em?.steeringMode??null,onChange:e=>void $(e),disabled:!em||eJ}),eh.steeringMode.error&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:eh.steeringMode.error})]}),(0,r.jsx)("div",{className:"border-t border-border/50"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Follow-up mode"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"How follow-up prompts sequence during a live turn"})]}),eh.followUpMode.pending&&(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),(0,r.jsx)(ao,{options:[{value:"all",label:"Queue all"},{value:"one-at-a-time",label:"One at a time"}],value:em?.followUpMode??null,onChange:e=>void D(e),disabled:!em||eJ}),eh.followUpMode.error&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:eh.followUpMode.error})]})]}),(0,r.jsx)("div",{className:"border-t border-border/50 pt-4",children:(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-auto-compaction-settings",children:[(0,r.jsx)(aa,{title:"Auto-compaction",status:em?.isCompacting?(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"})," Compacting"]}):null}),(0,r.jsx)(ai,{label:"Auto-compact",description:"Automatically compact when context thresholds are crossed",checked:em?.autoCompactionEnabled??!1,onCheckedChange:e=>void L(e),disabled:!em||eZ,busy:eZ,testId:"command-surface-toggle-auto-compaction"}),eh.autoCompaction.error&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:eh.autoCompaction.error}),eh.autoCompaction.result&&(0,r.jsx)("p",{className:"text-xs text-success",children:eh.autoCompaction.result})]})}),(0,r.jsx)("div",{className:"border-t border-border/50 pt-4",children:(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-retry-settings",children:[(0,r.jsx)(aa,{title:"Retry",status:em?.retryInProgress?(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,r.jsx)(sl.A,{className:"h-3 w-3"})," Attempt ",Math.max(1,em.retryAttempt)]}):null}),(0,r.jsx)(ai,{label:"Auto-retry",description:"Automatically retry on transient failures",checked:em?.autoRetryEnabled??!1,onCheckedChange:e=>void q(e),disabled:!em||eQ,busy:eQ,testId:"command-surface-toggle-auto-retry"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"command-surface-auto-retry-state",children:eQ?"Updating auto-retry…":eh.autoRetry.error?eh.autoRetry.error:eh.autoRetry.result?eh.autoRetry.result:em?.autoRetryEnabled?"Auto-retry enabled":"Auto-retry disabled"}),em?.retryInProgress&&(0,r.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-warning/20 bg-warning/5 px-4 py-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Retry in progress"}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Attempt ",Math.max(1,em.retryAttempt)," is active"]})]}),(0,r.jsxs)(J,{type:"button",variant:"destructive",size:"sm",onClick:()=>void B(),disabled:e0,"data-testid":"command-surface-abort-retry",className:"h-7 gap-1.5 text-xs",children:[e0?(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(o.A,{className:"h-3 w-3"}),"Abort"]})]}),eh.autoRetry.error&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:eh.autoRetry.error}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"command-surface-abort-retry-state",children:e0?"Aborting retry…":eh.abortRetry.error?eh.abortRetry.error:eh.abortRetry.result?eh.abortRetry.result:em?.retryInProgress?"Retry can be aborted":"No retry in progress"}),eh.abortRetry.error&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:eh.abortRetry.error})]})})]});case"recovery":return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-recovery",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground","data-testid":"command-surface-recovery-state",children:eU?"Loading recovery diagnostics…":ec.error?"Recovery diagnostics failed":ec.stale?"Recovery diagnostics stale":ec.loaded?"Recovery diagnostics loaded":"Recovery diagnostics idle"}),(0,r.jsx)(aa,{title:"Recovery",status:eO?(0,r.jsx)(ar,{status:"healthy"===eO.summary.tone?"ok":"warning"===eO.summary.tone?"warning":"error"}):null,action:(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>void g(),disabled:eU,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3",eU&&"animate-spin")}),"Refresh"]})}),ec.error&&(0,r.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive","data-testid":"command-surface-recovery-error",children:ec.error}),eU&&!eO&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading diagnostics…"]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-actions",children:(0,r.jsx)(J,{type:"button",variant:"default",size:"sm",onClick:()=>void g(),"data-testid":"command-surface-recovery-action-refresh_diagnostics",className:"h-7 text-xs",children:"Refresh diagnostics"})})]}),eO?.status==="unavailable"&&!ec.error&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-1 rounded-lg border border-border/50 bg-card/50 px-4 py-3","data-testid":"command-surface-recovery-summary",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:eO.summary.label}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:eO.summary.detail})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-actions",children:(0,r.jsx)(J,{type:"button",variant:"default",size:"sm",onClick:()=>void g(),"data-testid":"command-surface-recovery-action-refresh_diagnostics",className:"h-7 text-xs",children:"Refresh diagnostics"})})]}),eO&&"unavailable"!==eO.status&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-1","data-testid":"command-surface-recovery-summary",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:eO.summary.label}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:eO.summary.detail})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Validation"}),(0,r.jsx)("div",{className:"mt-1 text-lg font-semibold tabular-nums text-foreground",children:eO.summary.validationCount})]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Doctor"}),(0,r.jsx)("div",{className:"mt-1 text-lg font-semibold tabular-nums text-foreground",children:eO.summary.doctorIssueCount})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[eO.summary.retryInProgress&&(0,r.jsxs)(tS,{variant:"default",className:"text-[10px]",children:["Retry ",Math.max(1,eO.summary.retryAttempt)]}),eO.summary.compactionActive&&(0,r.jsx)(tS,{variant:"default",className:"text-[10px]",children:"Compacting"}),eO.summary.lastFailurePhase&&(0,r.jsxs)(tS,{variant:"destructive",className:"text-[10px]",children:["Phase ",eO.summary.lastFailurePhase]}),ec.stale&&(0,r.jsx)(tS,{variant:"outline",className:"text-[10px]",children:"Stale"})]}),eO.bridge.lastFailure&&(0,r.jsxs)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5","data-testid":"command-surface-recovery-last-failure",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-destructive",children:"Last failure"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-destructive/80",children:eO.bridge.lastFailure.message}),(0,r.jsxs)("div",{className:"mt-1.5 flex gap-3 text-[10px] text-destructive/60",children:[(0,r.jsxs)("span",{children:["Phase: ",eO.bridge.lastFailure.phase]}),(0,r.jsx)("span",{children:as(eO.bridge.lastFailure.at)})]})]}),eO.validation.topIssues.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Validation issues"}),eO.validation.topIssues.map(e=>(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(tS,{variant:"error"===e.severity?"destructive":"outline",className:"text-[10px]",children:e.code})}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.message}),e.suggestion&&(0,r.jsxs)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["→ ",e.suggestion]})]},`${e.code}:${e.file??e.message}`))]}),eO.doctor.topIssues.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Doctor issues"}),eO.doctor.topIssues.map(e=>(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2",children:[(0,r.jsx)(tS,{variant:"outline",className:"text-[10px]",children:e.code}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.message})]},`${e.code}:${e.unitId??e.message}`))]}),eO.interruptedRun.detected&&(0,r.jsxs)("div",{className:"rounded-lg border border-warning/20 bg-warning/5 px-3 py-2.5","data-testid":"command-surface-recovery-interrupted-run",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-warning",children:"Interrupted run detected"}),(0,r.jsxs)("div",{className:"mt-1 space-y-1 text-xs text-warning/80",children:[(0,r.jsx)("p",{children:"Available: yes"}),(0,r.jsx)("p",{children:"Detected: yes"}),(0,r.jsx)("p",{children:eO.interruptedRun.detail})]}),(0,r.jsxs)("div",{className:"mt-1.5 grid gap-1 text-[10px] text-warning/60",children:[(0,r.jsxs)("span",{children:["Tool calls: ",eO.interruptedRun.counts.toolCalls]}),(0,r.jsxs)("span",{children:["Files written: ",eO.interruptedRun.counts.filesWritten]}),(0,r.jsxs)("span",{children:["Commands: ",eO.interruptedRun.counts.commandsRun]}),(0,r.jsxs)("span",{children:["Errors: ",eO.interruptedRun.counts.errors]}),(0,r.jsxs)("span",{children:["Last forensic error: ",eO.interruptedRun.lastError??"[redacted]"]})]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-actions",children:eO.actions.browser.length>0?eO.actions.browser.map(e=>(0,r.jsx)(J,{type:"button",variant:"danger"===e.emphasis?"destructive":"primary"===e.emphasis?"default":"outline",size:"sm",onClick:()=>(e=>{switch(e){case"refresh_diagnostics":g();return;case"refresh_workspace":m({soft:!0});return;case"open_retry_controls":h("retry");return;case"open_resume_controls":u("resume",{source:"surface"});return;case"open_auth_controls":h("auth");return;default:return}})(e.id),"data-testid":`command-surface-recovery-action-${e.id}`,className:"h-7 text-xs",children:e.label},e.id)):(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eU?"Loading recovery actions…":"No browser recovery actions available."})}),eO.actions.commands.length>0&&(0,r.jsxs)("div",{className:"space-y-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-commands",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Suggested commands"}),eO.actions.commands.map(e=>(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs",children:[(0,r.jsx)("div",{className:"font-mono text-foreground",children:e.command}),(0,r.jsx)("p",{className:"mt-1 text-muted-foreground",children:e.label})]},e.command))]})]})]});case"auth":return eo?(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-auth",children:[(0,r.jsx)(aa,{title:"Auth",status:(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"login"===eF?"Login":"logout"===eF?"Logout":"Manage"})}),(0,r.jsx)("div",{className:"space-y-1",children:eo.required.providers.map(e=>{let t=e.id===eI?.id;return(0,r.jsxs)("button",{type:"button",className:(0,M.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"auth",providerId:e.id,intent:eF}),children:[(0,r.jsx)("div",{className:(0,M.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,r.jsx)(eX.A,{className:"h-2.5 w-2.5 text-background"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),e.configured&&(0,r.jsx)(ar,{status:"ok"})]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e.configured?`via ${e.configuredVia}`:"Not configured"})]}),e.recommended&&(0,r.jsx)("span",{className:"rounded bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Recommended"})]},e.id)})}),eI&&(0,r.jsxs)("div",{className:"space-y-4 border-t border-border/50 pt-3",children:[(0,r.jsx)("div",{className:"flex items-center justify-between",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:eI.label}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eI.configuredVia??"Not configured"})]})}),eI.supports.apiKey&&(0,r.jsx)("form",{className:"space-y-3",onSubmit:e=>{e.preventDefault(),e1.trim()&&V(eI.id,e1)},children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(e5.p,{type:"password",autoComplete:"off",value:e1,onChange:e=>ef(t=>({...t,[eI.id]:e.target.value})),placeholder:"Paste API key",className:"h-8 flex-1 text-xs",disabled:eM,"data-testid":"command-surface-api-key-input"}),(0,r.jsxs)(J,{type:"submit",size:"sm",disabled:!e1.trim()||eM,"data-testid":"command-surface-save-api-key",className:"h-8 gap-1.5",children:["save_api_key"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(tT.A,{className:"h-3.5 w-3.5"}),"Save"]})]})}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[eI.supports.oauth&&eI.supports.oauthAvailable&&(0,r.jsxs)(J,{type:"button",variant:"outline",size:"sm",disabled:eM,onClick:()=>void H(eI.id),"data-testid":"command-surface-start-provider-flow",className:"h-8 gap-1.5 text-xs",children:["start_provider_flow"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(sm.A,{className:"h-3.5 w-3.5"}),"Browser sign-in"]}),(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",disabled:eM,onClick:()=>void X(eI.id),"data-testid":"command-surface-logout-provider",className:"h-8 gap-1.5 text-xs text-destructive hover:text-destructive",children:["logout_provider"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(T.A,{className:"h-3.5 w-3.5"}),"Logout"]})]}),el&&el.providerId===eI.id&&(0,r.jsxs)("div",{className:"space-y-3 rounded-lg border border-foreground/10 bg-foreground/[0.03] px-4 py-3","data-testid":"command-surface-active-flow",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)(tS,{variant:"outline",className:"text-[10px]",children:el.status.replaceAll("_"," ")}),(0,r.jsx)("span",{className:"text-muted-foreground",children:new Date(el.updatedAt).toLocaleTimeString()})]}),el.auth?.instructions&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:el.auth.instructions}),el.auth?.url&&(0,r.jsx)(J,{asChild:!0,variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs","data-testid":"command-surface-open-auth-url",children:(0,r.jsxs)("a",{href:el.auth.url,target:"_blank",rel:"noreferrer",children:[(0,r.jsx)(tE.A,{className:"h-3 w-3"}),"Open sign-in page"]})}),el.progress.length>0&&(0,r.jsx)("div",{className:"space-y-1",children:el.progress.map((e,t)=>(0,r.jsx)("div",{className:"rounded-md border border-border/50 bg-card/50 px-2.5 py-1.5 text-xs text-muted-foreground",children:e},`${el.flowId}-${t}`))}),el.prompt&&(0,r.jsxs)("form",{className:"space-y-2",onSubmit:e=>{e.preventDefault(),(el.prompt?.allowEmpty||eb.trim())&&Y(el.flowId,eb)},children:[(0,r.jsx)(e5.p,{value:eb,onChange:e=>ev(e.target.value),placeholder:el.prompt.placeholder||"Enter value",className:"h-8 text-xs",disabled:eM,"data-testid":"command-surface-flow-input"}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:el.prompt.message}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)(J,{type:"submit",size:"sm",disabled:eM||!el.prompt.allowEmpty&&!eb.trim(),className:"h-7 gap-1.5 text-xs",children:["submit_provider_flow_input"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(tw.A,{className:"h-3 w-3"}),"Continue"]}),(0,r.jsx)(J,{type:"button",variant:"ghost",size:"sm",disabled:eM,onClick:()=>void Z(el.flowId),className:"h-7 text-xs",children:"Cancel"})]})]})]}),"idle"!==eo.bridgeAuthRefresh.phase&&(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-xs",children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:"Auth refresh"}),(0,r.jsx)("span",{className:"ml-2 text-muted-foreground",children:"pending"===eo.bridgeAuthRefresh.phase?"Refreshing…":"failed"===eo.bridgeAuthRefresh.phase?eo.bridgeAuthRefresh.error||"Failed.":"Complete."})]})]})]}):null;case"admin":return(0,r.jsxs)("div",{className:"space-y-5","data-testid":"command-surface-admin",children:[(0,r.jsx)(aa,{title:"Admin",status:(0,r.jsx)(tS,{variant:"outline",className:"border-warning/20 bg-warning/[0.06] text-[10px] text-warning",children:"Dev only"})}),(0,r.jsx)(ai,{label:"UI overrides",description:"Enable keyboard shortcuts and forced UI states for development",checked:e3.enabled,onCheckedChange:e3.setEnabled,testId:"admin-ui-overrides-master"}),e3.enabled&&(0,r.jsxs)("div",{className:"space-y-2 rounded-lg border border-border/50 bg-card/50 p-3",children:[(0,r.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Override shortcuts"}),tu.map(e=>(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-md px-3 py-2.5 transition-colors hover:bg-foreground/[0.03]",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,r.jsx)(tS,{variant:"outline",className:"border-border font-mono text-[10px] text-muted-foreground",children:e.shortcutLabel})]}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:e.description})]}),(0,r.jsx)(sp,{checked:e3.overrides[e.key],onCheckedChange:()=>e3.toggle(e.key),"data-testid":`admin-override-${e.key}`})]},e.key))]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 p-3 space-y-3",children:[(0,r.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Onboarding"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Run setup wizard"}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Opens the full onboarding flow as a new user would see it."})]}),(0,r.jsx)(J,{type:"button",size:"sm",className:"h-8 shrink-0 gap-1.5 text-xs",onClick:()=>{c(),window.setTimeout(()=>{e3.enabled||e3.setEnabled(!0),e3.overrides.forceOnboarding||e3.toggle("forceOnboarding")},150)},"data-testid":"admin-trigger-onboarding",children:"Launch"})]})]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-xs text-muted-foreground",children:["This tab is only visible when running via"," ",(0,r.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px]",children:"npm run gsd:web"}),". Overrides reset on page refresh."]})]});case"git":let e;return e=ed.result,(0,r.jsxs)("div",{className:"space-y-5","data-testid":"command-surface-git-summary",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground","data-testid":"command-surface-git-state",children:eB?"Loading git summary…":ed.error?"Git summary failed":e?.kind==="not_repo"?"No git repository":e?.kind==="repo"?`Repo ready${e.hasChanges?" — changes detected":" — clean"}`:"Git summary idle"}),eB&&!e&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-16",children:[(0,r.jsx)(I.A,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading repo state…"})]}),ed.error&&(0,r.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-xs text-destructive","data-testid":"command-surface-git-error",children:ed.error}),!ed.error&&e?.kind==="not_repo"&&(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 py-16 text-center","data-testid":"command-surface-git-not-repo",children:[(0,r.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border border-border/50 bg-card/50",children:(0,r.jsx)(C.A,{className:"h-4.5 w-4.5 text-muted-foreground"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:"No Git repository"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.message})]})]}),!ed.error&&e?.kind==="repo"&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-mono",children:(0,Q.nf)(e.project.repoRoot,3)}),e.project.repoRelativePath&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E.A,{className:"h-3 w-3 text-muted-foreground"}),(0,r.jsx)("span",{className:"font-mono",children:e.project.repoRelativePath})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-4 gap-1.5","data-testid":"command-surface-git-counts",children:[{label:"Staged",count:e.counts.staged,active:e.counts.staged>0,color:"text-success"},{label:"Modified",count:e.counts.dirty,active:e.counts.dirty>0,color:"text-warning"},{label:"Untracked",count:e.counts.untracked,active:e.counts.untracked>0,color:"text-muted-foreground"},{label:"Conflicts",count:e.counts.conflicts,active:e.counts.conflicts>0,color:"text-destructive"}].map(({label:e,count:t,active:s,color:a})=>(0,r.jsxs)("div",{className:(0,M.cn)("rounded-md border px-2 py-2 text-center transition-colors",s?"border-border bg-card":"border-border/50 bg-card/50"),children:[(0,r.jsx)("div",{className:(0,M.cn)("text-base font-semibold tabular-nums leading-none",s?a:"text-muted-foreground"),children:t}),(0,r.jsx)("div",{className:(0,M.cn)("mt-1.5 text-[10px] leading-none","text-muted-foreground"),children:e})]},e))}),e.changedFiles.length>0&&(0,r.jsxs)("div",{"data-testid":"command-surface-git-files",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:"Changes"}),(0,r.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[e.changedFiles.length,e.truncatedFileCount>0?`+${e.truncatedFileCount}`:""," files"]})]}),(0,r.jsx)("div",{className:"space-y-px rounded-lg border border-border/50 bg-card/50 overflow-hidden",children:e.changedFiles.map(e=>(0,r.jsxs)("div",{className:"group flex items-center gap-2.5 px-3 py-2 transition-colors hover:bg-foreground/[0.03]",children:[(0,r.jsx)("span",{className:(0,M.cn)("flex h-5 w-5 shrink-0 items-center justify-center rounded text-[10px] font-semibold",(e=>{switch(e){case"M":return"text-warning bg-warning/10";case"A":return"text-success bg-success/10";case"D":case"U":return"text-destructive bg-destructive/10";case"R":case"C":return"text-info bg-info/10";default:return"text-muted-foreground bg-foreground/5"}})(e.status)),children:e.status}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground/80",children:e.path}),e.conflict&&(0,r.jsx)("span",{className:"shrink-0 rounded bg-destructive/15 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-destructive",children:"conflict"})]},`${e.status}:${e.repoPath}`))}),e.truncatedFileCount>0&&(0,r.jsxs)("p",{className:"mt-1.5 text-center text-[11px] text-muted-foreground",children:["+",e.truncatedFileCount," more files not shown"]})]}),0===e.changedFiles.length&&(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2 py-8 text-center",children:[(0,r.jsx)(eX.A,{className:"h-4 w-4 text-success/60"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Working tree clean"})]})]})]});case"resume":return ts("resume");case"name":return ts("name");case"fork":return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-fork",children:[(0,r.jsx)(aa,{title:"Fork",action:(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>void G(),disabled:eW,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3","load_fork_messages"===ei.pendingAction&&"animate-spin")}),"Refresh"]})}),eW&&0===ei.forkMessages.length?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading fork points…"]}):ei.forkMessages.length>0?(0,r.jsx)("div",{className:"space-y-1",children:ei.forkMessages.map(e=>{let t=eR?.entryId===e.entryId;return(0,r.jsxs)("button",{type:"button",className:(0,M.cn)("flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"fork",entryId:e.entryId}),children:[(0,r.jsx)("div",{className:(0,M.cn)("mt-1 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,r.jsx)(eX.A,{className:"h-2.5 w-2.5 text-background"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] text-muted-foreground",children:e.entryId}),(0,r.jsx)("p",{className:"mt-0.5 text-sm text-foreground",children:e.text})]})]},e.entryId)})}):(0,r.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No fork points available yet."}),(0,r.jsx)("div",{className:"flex justify-end border-t border-border/50 pt-3",children:(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>eR?.entryId&&void W(eR.entryId),disabled:!eR?.entryId||"fork_session"===ei.pendingAction,"data-testid":"command-surface-apply-fork",className:"h-8 gap-1.5",children:["fork_session"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(C.A,{className:"h-3.5 w-3.5"}),"Create fork"]})})]});case"session":return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-session",children:[(0,r.jsx)(aa,{title:"Session",status:(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:ep??"pending"}),action:(0,r.jsxs)(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>void O(),disabled:eK,className:"h-7 gap-1.5 text-xs",children:[(0,r.jsx)(sn.A,{className:(0,M.cn)("h-3 w-3","load_session_stats"===ei.pendingAction&&"animate-spin")}),"Refresh"]})}),ei.sessionStats?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{label:"Input",value:(0,Q._y)(ei.sessionStats.tokens.input)},{label:"Output",value:(0,Q._y)(ei.sessionStats.tokens.output)},{label:"Total",value:(0,Q._y)(ei.sessionStats.tokens.total)}].map(({label:e,value:t})=>(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-center",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:e}),(0,r.jsx)("div",{className:"mt-1 text-sm font-semibold tabular-nums text-foreground",children:t})]},e))}),(0,r.jsxs)("div",{className:"divide-y divide-border/30 rounded-lg border border-border/50 bg-card/50",children:[(0,r.jsxs)("div",{className:"px-4 py-2",children:[(0,r.jsx)(an,{label:"User messages",children:ei.sessionStats.userMessages}),(0,r.jsx)(an,{label:"Assistant messages",children:ei.sessionStats.assistantMessages}),(0,r.jsx)(an,{label:"Tool calls",children:ei.sessionStats.toolCalls}),(0,r.jsx)(an,{label:"Tool results",children:ei.sessionStats.toolResults})]}),(0,r.jsxs)("div",{className:"px-4 py-2",children:[(0,r.jsx)(an,{label:"Total messages",children:ei.sessionStats.totalMessages}),(0,r.jsx)(an,{label:"Cost",children:(0,Q.BD)(ei.sessionStats.cost)}),ei.sessionStats.tokens.cacheRead>0&&(0,r.jsx)(an,{label:"Cache read",children:(0,Q._y)(ei.sessionStats.tokens.cacheRead)})]})]})]}):(0,r.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"Refresh to load session stats."}),(0,r.jsxs)("div",{className:"space-y-3 border-t border-border/50 pt-3",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Export"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(e5.p,{value:eE?.outputPath??"",onChange:e=>x({kind:"session",outputPath:e.target.value}),placeholder:"Output path (optional)",className:"h-8 flex-1 text-xs",disabled:"export_html"===ei.pendingAction,"data-testid":"command-surface-export-path"}),(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>void z(eE?.outputPath),disabled:"export_html"===ei.pendingAction,"data-testid":"command-surface-export-session",className:"h-8 gap-1.5",children:["export_html"===ei.pendingAction?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(su.A,{className:"h-3.5 w-3.5"}),"Export HTML"]})]})]})]});case"compact":return(0,r.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-compact",children:[(0,r.jsx)(aa,{title:"Manual compact",status:eY?(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,r.jsx)(I.A,{className:"h-3 w-3 animate-spin"})," Working"]}):null}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",htmlFor:"command-surface-compact-instructions",children:"Custom instructions"}),(0,r.jsx)(tt,{id:"command-surface-compact-instructions","data-testid":"command-surface-compact-instructions",value:e_?.customInstructions??"",onChange:e=>x({kind:"compact",customInstructions:e.target.value}),placeholder:"Tell compaction what to preserve or emphasize…",rows:4,disabled:eY,className:"text-xs"})]}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsxs)(J,{type:"button",size:"sm",onClick:()=>void K(e_?.customInstructions),disabled:eY,"data-testid":"command-surface-apply-compact",className:"h-8 gap-1.5",children:[eY?(0,r.jsx)(I.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(sa.A,{className:"h-3.5 w-3.5"}),"Compact now"]})}),ei.lastCompaction&&(0,r.jsxs)("div",{className:"space-y-2 rounded-lg border border-border/50 bg-card/50 px-4 py-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Last compaction"}),(0,r.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[(0,Q._y)(ei.lastCompaction.tokensBefore)," before"]})]}),(0,r.jsx)("p",{className:"whitespace-pre-wrap text-xs text-foreground",children:ei.lastCompaction.summary}),(0,r.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["First kept: ",ei.lastCompaction.firstKeptEntryId]})]})]});case"workspace":return(0,r.jsx)(rB,{});case"integrations":return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(rg,{}),(0,r.jsx)(rv,{})]});case"gsd-forensics":return(0,r.jsx)(sC,{});case"gsd-doctor":return(0,r.jsx)(sT,{});case"gsd-skill-health":return(0,r.jsx)(sR,{});case"gsd-knowledge":return(0,r.jsx)(sQ,{initialTab:"knowledge"});case"gsd-capture":case"gsd-triage":return(0,r.jsx)(sQ,{initialTab:"captures"});case"gsd-prefs":return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(rB,{}),(0,r.jsx)(rl,{}),(0,r.jsx)(ru,{}),(0,r.jsx)(rh,{}),(0,r.jsx)(rg,{}),(0,r.jsx)(rv,{}),(0,r.jsx)(rC,{}),(0,r.jsx)(rT,{})]});case"gsd-mode":return(0,r.jsx)(ru,{});case"gsd-config":return(0,r.jsx)(rh,{});case"gsd-quick":return(0,r.jsx)(rX,{});case"gsd-history":return(0,r.jsx)(r0,{});case"gsd-undo":return(0,r.jsx)(r1,{});case"gsd-steer":return(0,r.jsx)(r5,{});case"gsd-hooks":return(0,r.jsx)(r2,{});case"gsd-inspect":return(0,r.jsx)(r3,{});case"gsd-report":case"gsd-export":return(0,r.jsx)(r4,{});case"gsd-cleanup":return(0,r.jsx)(r8,{});case"gsd-queue":return(0,r.jsx)(r6,{});default:if(ei.section?.startsWith("gsd-"))return(0,r.jsxs)("div",{className:"p-4 text-sm text-muted-foreground","data-testid":`gsd-surface-${ei.section}`,children:[(0,r.jsxs)("p",{className:"font-medium text-foreground",children:["/gsd ",ei.section.slice(4)]}),(0,r.jsx)("p",{className:"mt-1",children:"Unknown GSD surface."})]});return null}})()})})]})]})]})})}function ad(){let[e,t]=(0,i.useState)(null),[s,a]=(0,i.useState)(!1),[n,o]=(0,i.useState)(!1),l=(0,i.useRef)(null),d=(0,i.useCallback)(async()=>{try{let e=await (0,el.tm)("/api/update");if(!e.ok)return;let s=await e.json();t(s)}catch{}},[]);(0,i.useEffect)(()=>{d()},[d]),(0,i.useEffect)(()=>(e?.updateStatus==="running"&&(l.current=setInterval(()=>void d(),3e3)),()=>{l.current&&(clearInterval(l.current),l.current=null)}),[e?.updateStatus,d]);let c=async()=>{a(!0);try{let e=await (0,el.tm)("/api/update",{method:"POST"});e.ok||202===e.status?await d():409===e.status&&await d()}catch{}finally{a(!1)}};if(!e||!e.updateAvailable&&"idle"===e.updateStatus||n)return null;let u="running"===e.updateStatus,m="success"===e.updateStatus,h="error"===e.updateStatus,x=e.targetVersion??e.latestVersion;return(0,r.jsxs)("div",{"data-testid":"update-banner",className:(0,M.cn)("flex items-center gap-3 border-b px-4 py-2 text-xs",m&&"border-success/20 bg-success/10 text-success",h&&"border-destructive/20 bg-destructive/10 text-destructive",!m&&!h&&"border-warning/20 bg-warning/10 text-warning"),children:[m?(0,r.jsxs)("span",{className:"flex-1","data-testid":"update-banner-message",children:["Update complete — restart GSD to use v",x]}):h?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"flex-1","data-testid":"update-banner-message",children:["Update failed",e.error?`: ${e.error}`:""]}),(0,r.jsx)("button",{onClick:()=>void c(),disabled:s,className:(0,M.cn)("flex-shrink-0 rounded border border-destructive/30 bg-background px-2 py-0.5 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",s&&"cursor-not-allowed opacity-50"),"data-testid":"update-banner-retry",children:"Retry"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"flex-1","data-testid":"update-banner-message",children:u?(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(ac,{}),"Updating to v",x,"…"]}):(0,r.jsxs)(r.Fragment,{children:["Update available: v",e.currentVersion," → v",e.latestVersion]})}),!u&&(0,r.jsx)("button",{onClick:()=>void c(),disabled:s,className:(0,M.cn)("flex-shrink-0 rounded border border-warning/30 bg-background px-2 py-0.5 text-xs font-medium text-warning transition-colors hover:bg-warning/10",s&&"cursor-not-allowed opacity-50"),"data-testid":"update-banner-action",children:"Update"})]}),(0,r.jsx)("button",{onClick:()=>o(!0),"aria-label":"Dismiss update banner",className:"flex-shrink-0 rounded p-0.5 opacity-50 transition-opacity hover:opacity-100","data-testid":"update-banner-dismiss",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function ac(){return(0,r.jsxs)("svg",{className:"h-3 w-3 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}let au=new Set(["dashboard","power","chat","roadmap","files","activity","visualize"]),am=()=>(0,r.jsx)("div",{className:"h-full w-full p-4",children:(0,r.jsx)(eo,{className:"h-full w-full"})}),ah=(0,n.default)(()=>s.e(2772).then(s.bind(s,72772)).then(e=>e.Roadmap),{loadableGenerated:{webpack:()=>[72772]},loading:am,ssr:!1}),ax=(0,n.default)(()=>Promise.all([s.e(5745),s.e(4872),s.e(3211),s.e(3050),s.e(8785),s.e(5826)]).then(s.bind(s,5826)).then(e=>e.FilesView),{loadableGenerated:{webpack:()=>[5826]},loading:am,ssr:!1}),ap=(0,n.default)(()=>s.e(2659).then(s.bind(s,82659)).then(e=>e.ActivityView),{loadableGenerated:{webpack:()=>[82659]},loading:am,ssr:!1}),ag=(0,n.default)(()=>Promise.all([s.e(4872),s.e(4283)]).then(s.bind(s,54283)).then(e=>e.VisualizerView),{loadableGenerated:{webpack:()=>[54283]},loading:am,ssr:!1}),af=(0,n.default)(()=>s.e(3616).then(s.bind(s,3616)).then(e=>e.DualTerminal),{loadableGenerated:{webpack:()=>[3616]},loading:am,ssr:!1}),ab=(0,n.default)(()=>Promise.all([s.e(3211),s.e(8785)]).then(s.bind(s,18785)).then(e=>e.ChatMode),{loadableGenerated:{webpack:()=>[18785]},loading:am,ssr:!1});function av(e){return`gsd-active-view:${e}`}function aj(){let[e,t]=(0,i.useState)("dashboard"),[s,n]=(0,i.useState)(!1),[u,m]=(0,i.useState)(300),[h,x]=(0,i.useState)(!1),p=(0,i.useRef)(!1),g=(0,i.useRef)(!1),f=(0,i.useRef)(0),b=(0,i.useRef)(0),[v,j]=(0,i.useState)(256),y=(0,i.useRef)(!1),w=(0,i.useRef)(0),N=(0,i.useRef)(0),[S,k]=(0,i.useState)(!1),[C,A]=(0,i.useState)(!1),[T,P]=(0,i.useState)(!1),[R,E]=(0,i.useState)(!1),[_,F]=(0,i.useState)(!1),I=(0,Q.gF)(),{refreshBoot:$}=(0,Q._l)(),D=(0,Q.tM)(I),L=I.boot?.project.cwd,q=(0,Q.$9)(L),B=I.titleOverride?.trim()||null,U=(0,Q.U4)(I.boot?.workspace),O=(0,Q.QC)(I);(0,i.useEffect)(()=>{if(C||!L)return;let e=window.setTimeout(()=>{try{let e=sessionStorage.getItem(av(L));e&&au.has(e)&&t(e)}catch{}A(!0)},0);return()=>window.clearTimeout(e)},[L,C]);let z=(0,i.useRef)(L);(0,i.useEffect)(()=>{z.current!==L&&(z.current=L,A(!1))},[L]),(0,i.useEffect)(()=>{if(L)try{sessionStorage.setItem(av(L),e)}catch{}},[e,L]),(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{try{let e=localStorage.getItem("gsd-sidebar-collapsed");"true"===e&&k(!0)}catch{}},0);return()=>window.clearTimeout(e)},[]),(0,i.useEffect)(()=>{try{localStorage.setItem("gsd-sidebar-collapsed",String(S))}catch{}},[S]),(0,i.useEffect)(()=>{if("u"<typeof document)return;let e=q?`GSD - ${q}`:"GSD";document.title=B?`${B} \xb7 ${e}`:e},[B,q]);let G=(0,i.useCallback)(e=>{t(e),E(!1)},[]);(0,i.useEffect)(()=>{let e=()=>{t("files")};return window.addEventListener("gsd:open-file",e),()=>window.removeEventListener("gsd:open-file",e)},[]),(0,i.useEffect)(()=>{let e=e=>{au.has(e.detail.view)&&G(e.detail.view)};return window.addEventListener("gsd:navigate-view",e),()=>window.removeEventListener("gsd:navigate-view",e)},[G]),(0,i.useEffect)(()=>{let e=()=>P(!0);return window.addEventListener("gsd:open-projects",e),()=>window.removeEventListener("gsd:open-projects",e)},[]),(0,i.useEffect)(()=>{let e=e=>{if(p.current){g.current=!0;let t=f.current-e.clientY;m(Math.max(150,Math.min(600,b.current+t)))}if(y.current){let t=w.current-e.clientX;j(Math.max(180,Math.min(480,N.current+t)))}},t=()=>{p.current=!1,y.current=!1,x(!1),document.body.style.cursor="",document.body.style.userSelect=""};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[]);let W=(0,i.useCallback)(e=>{p.current=!0,x(!0),f.current=e.clientY,b.current=u,document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[u]),K=(0,i.useCallback)(e=>{y.current=!0,w.current=e.clientX,N.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]),V=!!I.commandInFlight||"idle"!==I.onboardingRequestState,H="idle"===I.bootStatus||"loading"===I.bootStatus;(0,i.useEffect)(()=>{if(!H)return;let e=sh.oR.loading("Connecting to workspace…",{description:"Establishing the live bridge session",duration:1/0});return()=>{sh.oR.dismiss(e)}},[H]);let Y=I.boot?.projectDetection,J=!H&&"dashboard"===e&&null!=Y&&"active-gsd"!==Y.kind&&"empty-gsd"!==Y.kind;return"unauthenticated"===I.bootStatus?(0,r.jsxs)("div",{className:"flex h-dvh flex-col items-center justify-center gap-6 bg-background p-8 text-center",children:[(0,r.jsx)(a.default,{src:"/logo-black.svg",alt:"GSD-Pi Web",width:57,height:16,className:"shrink-0 h-4 w-auto dark:hidden"}),(0,r.jsx)(a.default,{src:"/logo-white.svg",alt:"GSD-Pi Web",width:57,height:16,className:"shrink-0 h-4 w-auto hidden dark:block"}),(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Authentication Required"}),(0,r.jsxs)("p",{className:"max-w-sm text-sm text-muted-foreground",children:["This workspace requires an auth token. Copy the full URL from your terminal (including the"," ",(0,r.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs",children:"#token=…"})," ","part) or restart with"," ",(0,r.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs",children:"gsd --web"}),"."]})]})]}):(0,r.jsxs)("div",{className:"relative flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[(0,r.jsxs)("header",{className:"flex h-12 flex-shrink-0 items-center justify-between border-b border-border bg-card px-2 md:px-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 md:gap-3 min-w-0",children:[(0,r.jsx)("button",{className:"flex md:hidden h-10 w-10 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",onClick:()=>E(!R),"aria-label":R?"Close navigation":"Open navigation","data-testid":"mobile-nav-toggle",children:(0,r.jsx)("span",{className:"relative flex h-5 w-5 items-center justify-center",children:(0,r.jsx)(d.N,{mode:"wait",initial:!1,children:(0,r.jsx)(c.P.span,{className:"absolute inset-0 flex items-center justify-center",initial:{opacity:0,scale:.25,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:.25,filter:"blur(4px)"},transition:{type:"spring",duration:.3,bounce:0},children:R?(0,r.jsx)(o.A,{className:"h-5 w-5"}):(0,r.jsx)(l.A,{className:"h-5 w-5"})},R?"close":"open")})})}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(a.default,{src:"/logo-black.svg",alt:"GSD-Pi Web",width:57,height:16,className:"shrink-0 h-4 w-auto dark:hidden"}),(0,r.jsx)(a.default,{src:"/logo-white.svg",alt:"GSD-Pi Web",width:57,height:16,className:"shrink-0 h-4 w-auto hidden dark:block"}),(0,r.jsx)(tS,{variant:"outline",className:"hidden sm:inline-flex text-[10px] rounded-full border-foreground/15 bg-accent/40 text-muted-foreground font-normal",children:"beta"})]}),(0,r.jsx)("span",{className:"hidden sm:inline text-2xl font-thin text-muted-foreground leading-none select-none",children:"/"}),(0,r.jsx)("span",{className:"hidden sm:inline text-sm text-muted-foreground truncate","data-testid":"workspace-project-cwd",title:L??void 0,children:H?(0,r.jsx)(eo,{className:"inline-block h-4 w-28 align-middle"}):(0,r.jsxs)(r.Fragment,{children:[q,B&&(0,r.jsx)("span",{className:"ml-2 inline-flex items-center rounded-full border border-foreground/15 bg-accent/60 px-2 py-0.5 text-[10px] font-medium text-foreground","data-testid":"workspace-title-override",title:B,children:B})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 md:gap-3",children:[(0,r.jsx)("span",{className:"sr-only","data-testid":"workspace-connection-status",children:D.label}),(0,r.jsx)("span",{className:"hidden sm:inline text-xs text-muted-foreground","data-testid":"workspace-scope-label",children:H?(0,r.jsx)(eo,{className:"inline-block h-3.5 w-40 align-middle"}):(0,r.jsx)(eT,{label:U,size:"sm"})})]})]}),(0,r.jsx)(ad,{}),!H&&O&&(0,r.jsxs)("div",{className:"flex items-center gap-3 border-b border-destructive/20 bg-destructive/10 px-4 py-2 text-xs text-destructive","data-testid":"workspace-error-banner",children:[(0,r.jsx)("span",{className:"flex-1",children:O}),(0,r.jsx)("button",{onClick:()=>void $(),disabled:V,className:(0,M.cn)("flex-shrink-0 rounded border border-destructive/30 bg-background px-2 py-0.5 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",V&&"cursor-not-allowed opacity-50"),children:"Retry"})]}),R&&(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/50 md:hidden",onClick:()=>E(!1),"data-testid":"mobile-nav-overlay"}),(0,r.jsx)("div",{className:(0,M.cn)("fixed inset-y-0 left-0 z-50 w-64 transform bg-sidebar border-r border-border transition-transform duration-200 ease-out md:hidden",R?"translate-x-0":"-translate-x-full"),"data-testid":"mobile-nav-drawer",children:(0,r.jsx)(ex,{activeView:e,onViewChange:H?()=>{}:G,isConnecting:H,mobile:!0})}),_&&(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/50 md:hidden",onClick:()=>F(!1),"data-testid":"mobile-milestone-overlay"}),!J&&(0,r.jsx)("div",{className:(0,M.cn)("fixed inset-y-0 right-0 z-50 w-72 transform bg-sidebar border-l border-border transition-transform duration-200 ease-out md:hidden",_?"translate-x-0":"translate-x-full"),"data-testid":"mobile-milestone-drawer",children:(0,r.jsx)(em,{isConnecting:H,width:288,onCollapse:()=>F(!1)})}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsx)("div",{className:"hidden md:flex",children:(0,r.jsx)(ex,{activeView:e,onViewChange:H?()=>{}:G,isConnecting:H})}),(0,r.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:(0,M.cn)("flex-1 overflow-hidden transition-[height] duration-200 ease-out",s&&"h-1/3"),children:H?(0,r.jsx)(eU,{}):(0,r.jsxs)(r.Fragment,{children:["dashboard"===e&&(0,r.jsx)(eU,{onSwitchView:G,onExpandTerminal:()=>n(!0)}),"power"===e&&(0,r.jsx)(af,{}),"roadmap"===e&&(0,r.jsx)(ah,{}),"files"===e&&(0,r.jsx)(ax,{}),"activity"===e&&(0,r.jsx)(ap,{}),"visualize"===e&&(0,r.jsx)(ag,{}),"chat"===e&&(0,r.jsx)(ab,{})]})}),"power"!==e&&"chat"!==e&&(0,r.jsxs)("div",{className:"border-t border-border flex flex-col",style:{flexShrink:0},children:[(0,r.jsx)("div",{role:"button",tabIndex:0,onClick:()=>{if(g.current){g.current=!1;return}H||n(!s)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),H||n(!s))},className:(0,M.cn)("flex h-8 w-full items-center justify-between bg-card px-3 text-xs select-none transition-colors",s&&"cursor-row-resize",!s&&!H&&"cursor-pointer hover:bg-muted/50",H&&"cursor-default"),onMouseDown:e=>{s&&W(e)},children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:"Terminal"}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:s?"▼":"▲"})]})}),(0,r.jsx)("div",{className:"overflow-hidden",style:{height:s?u:0,transition:h?"none":"height 200ms"},children:s&&(0,r.jsx)(eg.x,{className:"h-full",projectCwd:I.boot?.project.cwd})})]})]}),!J&&!S&&(0,r.jsxs)("div",{className:"relative hidden md:flex h-full items-stretch",style:{flexShrink:0},children:[(0,r.jsx)("div",{className:"w-px bg-border"}),(0,r.jsx)("div",{className:"absolute left-[-3px] top-0 bottom-0 w-[7px] cursor-col-resize z-10 hover:bg-muted-foreground/20 transition-colors",onMouseDown:K})]}),(0,r.jsx)("div",{className:"hidden md:flex",children:!J&&(S?(0,r.jsx)(eh,{onExpand:()=>k(!1)}):(0,r.jsx)(em,{isConnecting:H,width:v,onCollapse:()=>k(!0)}))})]}),(0,r.jsx)("div",{className:"hidden md:block",children:(0,r.jsx)(eV,{})}),!J&&(0,r.jsxs)("div",{className:"flex md:hidden h-12 items-center justify-between border-t border-border bg-card px-3","data-testid":"mobile-bottom-bar",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground truncate",children:[(0,r.jsx)("span",{className:"sr-only","data-testid":"workspace-connection-status-mobile",children:D.label}),(0,r.jsx)("span",{className:(0,M.cn)("h-2 w-2 rounded-full shrink-0","success"===D.tone?"bg-success":"warning"===D.tone?"bg-warning":"danger"===D.tone?"bg-destructive":"bg-muted-foreground")}),(0,r.jsx)("span",{className:"truncate",children:U})]}),(0,r.jsx)("button",{onClick:()=>F(!_),className:"flex h-10 items-center gap-2 rounded-md px-3 text-xs font-medium text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors","data-testid":"mobile-milestone-toggle",children:"Milestones"})]}),(0,r.jsx)(rD,{open:T,onOpenChange:P}),(0,r.jsx)(al,{}),(0,r.jsx)(td,{}),(0,r.jsx)(se,{})]})}function ay(){return(0,el.c4)(),(0,r.jsx)(en,{children:(0,r.jsx)(aw,{})})}function aw(){let e=ei(),t=(0,i.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),s=t?e.getActiveStore():null,a=(0,i.useRef)(!1);return((0,i.useEffect)(()=>{if(a.current||e.getActiveProjectCwd())return;let t=new AbortController;return(async()=>{try{let s=await (0,el.tm)("/api/preferences",{signal:t.signal});if(!s.ok)return;let r=await s.json();a.current=!0,r.launchCwd&&!e.getActiveProjectCwd()&&e.switchProject(r.launchCwd)}catch(e){if("AbortError"===e.name)return}})(),()=>t.abort()},[e]),(0,i.useEffect)(()=>{let e=e=>{if(e.persisted)return;let t=(0,el.c4)(),s=t?`/api/shutdown?_token=${t}`:"/api/shutdown";navigator.sendBeacon(s,"")};return window.addEventListener("pagehide",e),()=>{window.removeEventListener("pagehide",e)}},[]),t&&s)?(0,r.jsx)(Q.jg,{store:s,children:(0,r.jsx)(tx,{children:(0,r.jsx)(aj,{})})}):(0,r.jsx)(rU,{})}},40525:(e,t,s)=>{function r(e,t){if(!t)return e;let s=new URL(e,"http://localhost");return s.searchParams.set("project",t),s.pathname+s.search}function a(e,t,s){return new URL(r(e,s),t)}s.d(t,{$:()=>r,Y:()=>a})},43106:(e,t,s)=>{s.d(t,{p:()=>n});var r=s(18870);s(45110);var a=s(18833);function n({className:e,type:t,...s}){return(0,r.jsx)("input",{type:t,"data-slot":"input",className:(0,a.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...s})}},46054:(e,t,s)=>{function r(e,t){if(e.status)switch(e.status){case"complete":return"done";case"active":return"in-progress";case"pending":return"pending";case"parked":return"parked"}return e.slices.length>0&&e.slices.every(e=>e.done)?"done":t.milestoneId===e.id||e.slices.some(e=>e.done)?"in-progress":"pending"}function a(e,t,s){return t.done?"done":s.milestoneId===e&&s.sliceId===t.id?"in-progress":"pending"}function n(e,t,s,r){return s.done?"done":r.milestoneId===e&&r.sliceId===t&&r.taskId===s.id?"in-progress":"pending"}s.d(t,{Jq:()=>r,g$:()=>n,z3:()=>a})},59727:(e,t,s)=>{s.d(t,{L:()=>r});function r(e){let t,{phase:s,autoActive:r,autoPaused:a,onboardingLocked:n,commandInFlight:i,bootStatus:o,hasMilestones:l,stepMode:d=!1,projectDetectionKind:c}=e;if(c&&"active-gsd"!==c&&"empty-gsd"!==c)return{primary:null,secondaries:[],disabled:!0,disabledReason:"Project setup pending",isNewMilestone:!1};let u=!1;null!==i?(u=!0,t="Command in progress"):"ready"!==o?(u=!0,t="Workspace not ready"):n&&(u=!0,t="Setup required");let m=null,h=[],x=!1;return r&&!a?m={label:"Stop Auto",command:"/gsd stop",variant:"destructive"}:d&&l&&"complete"!==s&&"blocked"!==s?m={label:"Next Step",command:"/gsd next",variant:"default"}:a?m={label:"Resume Auto",command:"/gsd auto",variant:"default"}:("complete"===s?(m={label:"New Milestone",command:"/gsd",variant:"default"},x=!0):"planning"===s?m={label:"Plan",command:"/gsd",variant:"default"}:"executing"===s||"summarizing"===s?m={label:"Start Auto",command:"/gsd auto",variant:"default"}:"pre-planning"!==s||l?"blocked"===s?(m={label:"Blocked",command:"/gsd",variant:"default"},u=!0,t="Project is blocked — check blockers"):m="paused"===s?{label:"Resume",command:"/gsd auto",variant:"default"}:"validating-milestone"===s?{label:"Validate",command:"/gsd",variant:"default"}:"completing-milestone"===s?{label:"Complete Milestone",command:"/gsd",variant:"default"}:"needs-discussion"===s?{label:"Discuss",command:"/gsd",variant:"default"}:"replanning-slice"===s?{label:"Replan",command:"/gsd",variant:"default"}:{label:"Continue",command:"/gsd",variant:"default"}:m={label:"Initialize Project",command:"/gsd",variant:"default"},"/gsd next"===m.command||x||h.push({label:"Step",command:"/gsd next"})),{primary:m,secondaries:h,disabled:u,disabledReason:t,isNewMilestone:x}}},61415:(e,t,s)=>{s.d(t,{B3:()=>c,s1:()=>u});var r=s(45110);let a="gsd-user-mode",n="expert",i=new Set;function o(e){return i.add(e),()=>{i.delete(e)}}function l(){let e=localStorage.getItem(a);return"expert"===e||"vibe-coder"===e?e:n}function d(){return n}function c(){return l()}function u(){return[(0,r.useSyncExternalStore)(o,l,d),(0,r.useCallback)(e=>{localStorage.setItem(a,e),i.forEach(e=>e())},[])]}},68543:(e,t,s)=>{s.d(t,{jg:()=>ey,Hu:()=>ev,fL:()=>eb,Sf:()=>ek,BD:()=>ec,a3:()=>el,_y:()=>ed,E3:()=>em,U4:()=>eu,Ct:()=>eh,iT:()=>ep,$9:()=>eo,_0:()=>ex,tM:()=>ef,QC:()=>eg,cZ:()=>R,K0:()=>P,nf:()=>ei,_l:()=>eS,gF:()=>eN});var r=s(18870),a=s(45110);let n=new Map([{name:"settings",description:"Open settings menu"},{name:"model",description:"Select model (opens selector UI)"},{name:"scoped-models",description:"Enable/disable models for Ctrl+P cycling"},{name:"export",description:"Export session (HTML default, or specify path: .html/.jsonl)"},{name:"import",description:"Import and resume a session from a JSONL file"},{name:"share",description:"Share session as a secret GitHub gist"},{name:"copy",description:"Copy last agent message to clipboard"},{name:"name",description:"Set session display name"},{name:"session",description:"Show session info and stats"},{name:"changelog",description:"Show changelog entries"},{name:"hotkeys",description:"Show all keyboard shortcuts"},{name:"fork",description:"Create a new fork from a previous user message"},{name:"clone",description:"Duplicate the current session at the current position"},{name:"tree",description:"Navigate session tree (switch branches)"},{name:"login",description:"Configure provider authentication"},{name:"logout",description:"Remove provider authentication"},{name:"new",description:"Start a new session"},{name:"compact",description:"Manually compact the session context"},{name:"resume",description:"Resume a different session"},{name:"reload",description:"Reload keybindings, extensions, skills, prompts, and themes"},{name:"quit",description:"Quit pi"}].map(e=>[e.name,e.description])),i=new Set(n.keys()),o=new Map([["settings","settings"],["model","model"],["thinking","thinking"],["git","git"],["resume","resume"],["name","name"],["fork","fork"],["compact","compact"],["login","login"],["logout","logout"],["session","session"],["export","export"]]),l=new Map([["visualize","gsd-visualize"],["forensics","gsd-forensics"],["doctor","gsd-doctor"],["skill-health","gsd-skill-health"],["knowledge","gsd-knowledge"],["capture","gsd-capture"],["triage","gsd-triage"],["quick","gsd-quick"],["history","gsd-history"],["undo","gsd-undo"],["inspect","gsd-inspect"],["model","model"],["prefs","gsd-prefs"],["config","gsd-config"],["hooks","gsd-hooks"],["mode","gsd-mode"],["steer","gsd-steer"],["report","gsd-report"],["export","gsd-export"],["cleanup","gsd-cleanup"],["queue","gsd-queue"]]),d=new Set(["auto","next","stop","pause","skip","discuss","run-hook","migrate","remote"]),c=`Available /gsd subcommands:
|
|
3
|
+
|
|
4
|
+
Workflow: next \xb7 auto \xb7 stop \xb7 pause \xb7 skip \xb7 queue \xb7 quick \xb7 capture \xb7 triage
|
|
5
|
+
Diagnostics: status \xb7 visualize \xb7 forensics \xb7 doctor \xb7 skill-health \xb7 inspect
|
|
6
|
+
Context: knowledge \xb7 history \xb7 undo \xb7 discuss
|
|
7
|
+
Settings: model \xb7 prefs \xb7 config \xb7 hooks \xb7 mode \xb7 steer
|
|
8
|
+
Advanced: report \xb7 export \xb7 cleanup \xb7 run-hook \xb7 migrate \xb7 remote
|
|
9
|
+
|
|
10
|
+
Type /gsd <subcommand> to run. Use /gsd help for this message.`;function u(e){return e.isStreaming?"follow_up":"prompt"}function m(e,t={}){let s=e.trim(),r=function(e){let t=e.trim();if(!t.startsWith("!"))return null;let s=t.startsWith("!!"),r=s?t.slice(2).trim():t.slice(1).trim();return r?{command:r,excludeFromContext:s}:null}(s);if(r)return{kind:"bash",input:s,command:{type:"bash",command:r.command,...r.excludeFromContext?{excludeFromContext:!0}:{}}};let a=function(e){if(!e.startsWith("/"))return null;let t=e.slice(1).trim();if(!t)return null;let s=t.search(/\s/);return -1===s?{name:t,args:""}:{name:t.slice(0,s),args:t.slice(s+1).trim()}}(s);if("/clear"===s)return{kind:"local",input:s,commandName:"clear",action:"clear_terminal"};if("/refresh"===s)return{kind:"local",input:s,commandName:"refresh",action:"refresh_workspace"};if("/state"===s)return{kind:"rpc",input:s,commandName:"state",command:{type:"get_state"}};if("/new-session"===s)return{kind:"rpc",input:s,commandName:"new",command:{type:"new_session"}};if(!a)return{kind:"prompt",input:s,slashCommandName:null,command:{type:u(t),message:s}};if("new"===a.name)return{kind:"rpc",input:s,commandName:"new",command:{type:"new_session"}};if("gsd"===a.name)return function(e,t,s){let r=t.trim(),a=r.search(/\s/),n=-1===a?r:r.slice(0,a),i=-1===a?"":r.slice(a+1).trim();if(!n)return{kind:"prompt",input:e,slashCommandName:"gsd",command:{type:u(s),message:e}};if("help"===n)return{kind:"local",input:e,commandName:"gsd",action:"gsd_help"};if("status"===n||"visualize"===n)return{kind:"view-navigate",input:e,commandName:"gsd",view:"visualize"};let o=l.get(n);return o?{kind:"surface",input:e,commandName:"gsd",surface:o,args:i}:(d.has(n),{kind:"prompt",input:e,slashCommandName:"gsd",command:{type:u(s),message:e}})}(s,a.args,t);let c=o.get(a.name);if(c)return{kind:"surface",input:s,commandName:a.name,surface:c,args:a.args};if(i.has(a.name)){var h,x;let e;return x=h=a.name,e=n.get(x)??"Browser handling is reserved for this built-in command.",{kind:"reject",input:s,commandName:h,reason:`/${h} is a built-in pi command (${e}) that is not available in the browser yet.`,guidance:"It was blocked instead of falling through to the model."}}return{kind:"prompt",input:s,slashCommandName:a.name,command:{type:u(t),message:s}}}function h(e){switch(e.kind){case"surface":return{type:"system",message:`/${e.commandName} is reserved for browser-native handling and was not sent to the model.`};case"reject":return{type:"error",message:`${e.reason} ${e.guidance}`.trim()};default:return null}}var x=s(37144);class p{constructor(e,t=e=>new EventSource(e)){this.eventSource=null,this.lastConnectionState="idle",this.handlers=e,this.createEventSource=t}isOpen(){return null!==this.eventSource}ensure(){if(this.eventSource||!this.handlers.canConnect())return;let e=this.createEventSource(this.handlers.streamUrl());this.eventSource=e,e.onopen=()=>{let e=this.lastConnectionState;this.lastConnectionState="connected",this.handlers.onOpen({previousState:e,wasDisconnected:"reconnecting"===e||"disconnected"===e||"error"===e})},e.onmessage=e=>{this.handlers.onMessage(e.data)},e.onerror=()=>{let e="connected"===this.lastConnectionState?"reconnecting":"error",t=e!==this.lastConnectionState;this.lastConnectionState=e,this.handlers.onError({nextConnectionState:e,changed:t})}}close(){this.eventSource?.close(),this.eventSource=null}}function g(e,t){return{id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,type:e,content:t,timestamp:function(e=new Date){return e.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}()}}function f(e,t){return[...e,t].slice(-250)}var b=s(83890);let v=new Set(["ls","ll","la","pwd","cd","dir","cat","head","tail","wc","file","which","whoami","echo","date","tree","find","grep","rg","clear","env","df","du","uname","hostname","mkdir","rm","cp","mv","touch","chmod","less","more","sort","uniq","sed","awk","curl","wget","tar","zip","unzip","git","docker","npm","npx","yarn","pnpm","node","python","python3","pip","pip3","make","cargo","go","ruby","brew"]);function j(e){let t=e.trimStart(),s=t.search(/\s/);return(-1===s?t:t.slice(0,s)).toLowerCase()}let y=[{id:"shell-command-prefix",maxShows:2,evaluate(e){let t;if(!(!((t=e.input.trimStart()).startsWith("!")||t.startsWith("/")||t.includes("\n")||t.length>120)&&v.has(j(t))))return null;let s=j(e.input);return`Tip: "${s}" looks like a shell command. Prefix with ! to run locally, or !! to run without using tokens.`}},{id:"large-paste",maxShows:2,evaluate:e=>e.input.length<2e3||e.input.trimStart().startsWith("/")||e.input.trimStart().startsWith("!")?null:"Tip: Large inputs consume many tokens. Consider saving to a file and asking the agent to read it."},{id:"thinking-level-high",maxShows:1,evaluate(e){let t=e.thinkingLevel?.toLowerCase();if("high"!==t&&"xhigh"!==t)return null;let s=e.input.trim();return s.length>80||s.includes("\n")||s.startsWith("/")||s.startsWith("!")?null:`Tip: Thinking is set to ${t}. Use Ctrl+T to lower it for simple questions — saves tokens.`}},{id:"double-bang-reminder",maxShows:2,evaluate(e){if(e.bashIncludedCount<3)return null;let t=e.input.trimStart();return!t.startsWith("!")||t.startsWith("!!")?null:"Tip: Use !! instead of ! to keep command output out of agent context and save tokens."}},{id:"compaction-nudge",maxShows:1,evaluate(e){if(void 0===e.contextPercent||e.contextPercent<70)return null;let t=e.input.trimStart();return t.startsWith("/")||t.startsWith("!")?null:"Tip: Context is getting full. Use /compact to summarize the conversation and free up space."}}];class w{recordBashIncluded(){this._bashIncludedCount++}get bashIncludedCount(){return this._bashIncludedCount}evaluate(e){let t={...e,bashIncludedCount:this._bashIncludedCount};for(let e of y){let s=this.showCounts.get(e.id)??0;if(s>=e.maxShows)continue;let r=e.evaluate(t);if(r)return this.showCounts.set(e.id,s+1),r}return null}reset(){this.showCounts.clear(),this._bashIncludedCount=0}constructor(){this.showCounts=new Map,this._bashIncludedCount=0}}function N(){return{status:"idle",stale:!1,reloadCount:0,lastRequestedAt:null,lastSuccessAt:null,lastFailureAt:null,lastFailure:null,invalidatedAt:null,invalidationReason:null,invalidationSource:null}}function S(e=null){return{data:e,...N()}}function k(e){return{...F(e),data:e.data}}function C(e,t,s){return{...I(e,t,s),data:e.data}}function A(e,t){return{...$(e),data:void 0!==t?t:e.data}}function T(e,t){return{...D(e,t),data:e.data}}function P(e){return e.live.workspace.data??e.boot?.workspace??null}function R(e){return e.live.auto.data??e.boot?.auto??null}function E(e){let t=e.live.resumableSessions.data;return t&&t.length>0?t:e.boot?.resumableSessions??[]}function _(){return{visible:!1,tone:"healthy",label:"Recovery summary pending",detail:"Waiting for the first live workspace snapshot.",validationCount:0,retryInProgress:!1,retryAttempt:0,autoRetryEnabled:!1,isCompacting:!1,currentUnitId:null,freshness:"idle",entrypointLabel:"Inspect recovery",lastError:null}}function F(e){return{...e,status:"refreshing",lastRequestedAt:new Date().toISOString(),lastFailure:null}}function I(e,t,s){return{...e,status:e.lastSuccessAt?"stale":e.status,stale:!0,invalidatedAt:new Date().toISOString(),invalidationReason:t,invalidationSource:s}}function $(e){return{...e,status:"fresh",stale:!1,reloadCount:e.reloadCount+1,lastSuccessAt:new Date().toISOString(),lastFailureAt:null,lastFailure:null}}function D(e,t){return{...e,status:"error",stale:!0,lastFailureAt:new Date().toISOString(),lastFailure:t}}function L(e){let t=e.boot?.bridge??null,s=P(e),r=R(e),a=s?.validationIssues.length??0,n=!!t?.sessionState?.retryInProgress,i=t?.sessionState?.retryAttempt??0,o=!!t?.sessionState?.autoRetryEnabled,l=!!t?.sessionState?.isCompacting,d=e.live.freshness.recovery,c="error"===d.status?"error":d.stale?"stale":d.lastSuccessAt?"fresh":"idle",u=t?.lastError?{message:t.lastError.message,phase:t.lastError.phase,at:t.lastError.at}:null,m="healthy",h="Recovery summary healthy",x="No retry, compaction, bridge, or validation recovery signals are active.";return s||r||t?(u||"error"===c?(m="danger",h="Recovery attention required",x=u?.message??d.lastFailure??"A targeted live refresh failed."):a>0?(m="warning",h=`Recovery summary: ${a} validation issue${1===a?"":"s"}`,x="Workspace validation surfaced issues that may need doctor or audit follow-up."):n?(m="warning",h=`Recovery retry active (attempt ${Math.max(1,i)})`,x="The live bridge is retrying the current unit after a transient failure."):l?(m="warning",h="Recovery compaction active",x="The live session is compacting context before continuing."):"stale"===c&&(m="warning",h="Recovery summary stale",x=d.invalidationReason?`Waiting for a targeted refresh after ${d.invalidationReason.replaceAll("_"," ")}.`:"Waiting for the next targeted refresh."),{visible:!0,tone:m,label:h,detail:x,validationCount:a,retryInProgress:n,retryAttempt:i,autoRetryEnabled:o,isCompacting:l,currentUnitId:r?.currentUnit?.id??null,freshness:c,entrypointLabel:"danger"===m||"warning"===m?"Inspect recovery":"Review recovery",lastError:u}):_()}function M(e){return e instanceof Error?e.message:String(e)}function q(e,t){return e.required.providers.find(e=>e.id===t)?.label??t}function B(e){let t=e?.sessionState?.model;return t?{provider:t.provider??t.providerId,modelId:t.id}:null}function U(e){if(!e)return null;if(e.required.satisfiedBy?.providerId)return e.required.satisfiedBy.providerId;let t=e.required.providers.find(e=>!e.configured&&e.recommended);if(t)return t.id;let s=e.required.providers.find(e=>!e.configured);return s?s.id:e.required.providers[0]?.id??null}function O(e,t){return{...e,pending:!1,loaded:!1,error:t}}function z(e,t){return{...e,phase:"error",pending:!1,stale:!0,error:t,lastFailureAt:new Date().toISOString()}}function G(e){return e?.bridge.activeSessionFile??e?.bridge.sessionState?.sessionFile??null}function W(e,t){let s=G(t),r=t?.bridge.sessionState?.sessionName?.trim()||void 0;return e.map(e=>{let t=s?e.path===s:e.isActive;return{...e,isActive:t,...t&&r?{name:r}:{}}})}function K(e,t){return{...e,activeSessionPath:G(t),sessions:W(e.sessions,t)}}function V(e,t,s){return{...e,activeSessionPath:s.isActive?t:e.activeSessionPath,sessions:e.sessions.map(e=>e.path===t?{...e,...s}:s.isActive?{...e,isActive:!1}:e)}}function H(e,t){if(!e)return null;let s={...e,bridge:t};return{...s,resumableSessions:W(s.resumableSessions,s)}}function Y(e,t){return e?.bridge.sessionState?H(e,{...e.bridge,sessionState:{...e.bridge.sessionState,...t}}):e}class J{constructor(e){this.loadGitSummary=async()=>{let e={...this.host.getState().commandSurface.gitSummary,pending:!0,error:null},t={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,gitSummary:F(this.host.getState().live.freshness.gitSummary)}};this.host.patchState({live:{...t,recoverySummary:L({boot:this.host.getState().boot,live:t})},commandSurface:(0,x.Yc)({...this.host.getState().commandSurface,gitSummary:e},"load_git_summary")});try{let t=await (0,b.tm)(this.host.buildUrl("/api/git"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),s=await t.json().catch(()=>null),r=s&&"object"==typeof s&&("repo"===s.kind||"not_repo"===s.kind)&&s.project&&"object"==typeof s.project&&"current_project"===s.project.scope&&"string"==typeof s.project.cwd&&("not_repo"===s.kind?"string"==typeof s.message:"string"==typeof s.project?.repoRoot&&"boolean"==typeof s.hasChanges&&"boolean"==typeof s.hasConflicts&&!!s.counts&&"object"==typeof s.counts&&!!Array.isArray(s.changedFiles)&&"number"==typeof s.truncatedFileCount&&"number"==typeof s.counts.changed&&"number"==typeof s.counts.staged&&"number"==typeof s.counts.dirty&&"number"==typeof s.counts.untracked&&"number"==typeof s.counts.conflicts)?s:null;if(!t.ok||!r){let r=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Current-project git summary failed with ${t.status}`,a=O(e,r),n={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,gitSummary:D(this.host.getState().live.freshness.gitSummary,r)}};return this.host.patchState({live:{...n,recoverySummary:L({boot:this.host.getState().boot,live:n})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,gitSummary:a},{action:"load_git_summary",success:!1,message:r,gitSummary:a})}),null}let a={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,gitSummary:$(this.host.getState().live.freshness.gitSummary)}};return this.host.patchState({live:{...a,recoverySummary:L({boot:this.host.getState().boot,live:a})},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"load_git_summary",success:!0,message:"",gitSummary:{pending:!1,loaded:!0,result:r,error:null}})}),r}catch(a){let t=M(a),s=O(e,t),r={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,gitSummary:D(this.host.getState().live.freshness.gitSummary,t)}};return this.host.patchState({live:{...r,recoverySummary:L({boot:this.host.getState().boot,live:r})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,gitSummary:s},{action:"load_git_summary",success:!1,message:t,gitSummary:s})}),null}},this.loadRecoveryDiagnostics=async()=>{var e;let t={...e=this.host.getState().commandSurface.recovery,pending:!0,error:null,phase:e.loaded?e.phase:"loading"},s={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,recovery:F(this.host.getState().live.freshness.recovery)}};this.host.patchState({live:{...s,recoverySummary:L({boot:this.host.getState().boot,live:s})},commandSurface:(0,x.Yc)({...this.host.getState().commandSurface,recovery:t},"load_recovery_diagnostics")});try{let e=await (0,b.tm)(this.host.buildUrl("/api/recovery"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),s=await e.json().catch(()=>null),r=s&&"object"==typeof s&&("ready"===s.status||"unavailable"===s.status)&&"string"==typeof s.loadedAt&&s.project&&"string"==typeof s.project.cwd&&s.summary&&"string"==typeof s.summary.label&&"string"==typeof s.summary.detail&&s.bridge&&"string"==typeof s.bridge.phase&&s.validation&&"number"==typeof s.validation.total&&s.doctor&&"number"==typeof s.doctor.total&&s.interruptedRun&&"boolean"==typeof s.interruptedRun.available&&s.actions&&Array.isArray(s.actions.browser)&&Array.isArray(s.actions.commands)?s:null;if(!e.ok||!r){let r=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Recovery diagnostics failed with ${e.status}`,a=z(t,r),n={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,recovery:D(this.host.getState().live.freshness.recovery,r)}};return this.host.patchState({lastClientError:r,live:{...n,recoverySummary:L({boot:this.host.getState().boot,live:n})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,recovery:a},{action:"load_recovery_diagnostics",success:!1,message:r,recovery:a})}),null}let a={...{phase:"ready"===r.status?"ready":"unavailable",pending:!1,loaded:!0,stale:!1,diagnostics:r,error:null,lastLoadedAt:r.loadedAt,lastInvalidatedAt:null,lastFailureAt:null},lastInvalidatedAt:this.host.getState().commandSurface.recovery.lastInvalidatedAt},n={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,recovery:$(this.host.getState().live.freshness.recovery)}};return this.host.patchState({lastClientError:null,live:{...n,recoverySummary:L({boot:this.host.getState().boot,live:n})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,recovery:a},{action:"load_recovery_diagnostics",success:!0,message:"ready"===r.status?"Recovery diagnostics refreshed":"Recovery diagnostics are currently unavailable",recovery:a})}),r}catch(a){let e=M(a),s=z(t,e),r={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,recovery:D(this.host.getState().live.freshness.recovery,e)}};return this.host.patchState({lastClientError:e,live:{...r,recoverySummary:L({boot:this.host.getState().boot,live:r})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,recovery:s},{action:"load_recovery_diagnostics",success:!1,message:e,recovery:s})}),null}},this.loadForensicsDiagnostics=async()=>{this.patchDiagnosticsPhaseState("forensics",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/forensics"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Forensics request failed with ${e.status}`;return this.patchDiagnosticsPhaseState("forensics",{phase:"error",error:s}),null}return this.patchDiagnosticsPhaseState("forensics",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchDiagnosticsPhaseState("forensics",{phase:"error",error:e}),null}},this.loadDoctorDiagnostics=async e=>{this.patchDoctorState({phase:"loading",error:null});try{let t=e?`/api/doctor?scope=${encodeURIComponent(e)}`:"/api/doctor",s=await (0,b.tm)(t,{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),r=await s.json().catch(()=>null);if(!s.ok||!r){let e=r?.error??`Doctor request failed with ${s.status}`;return this.patchDoctorState({phase:"error",error:e}),null}return this.patchDoctorState({phase:"loaded",data:r,lastLoadedAt:new Date().toISOString()}),r}catch(t){let e=M(t);return this.patchDoctorState({phase:"error",error:e}),null}},this.applyDoctorFixes=async e=>{this.patchDoctorState({fixPending:!0,lastFixError:null,lastFixResult:null});try{let t=await (0,b.tm)(this.host.buildUrl("/api/doctor"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e?{scope:e}:{})}),s=await t.json().catch(()=>null);if(!t.ok||!s){let e=s?.error??`Doctor fix request failed with ${t.status}`;return this.patchDoctorState({fixPending:!1,lastFixError:e}),null}return this.patchDoctorState({fixPending:!1,lastFixResult:s}),this.loadDoctorDiagnostics(e),s}catch(t){let e=M(t);return this.patchDoctorState({fixPending:!1,lastFixError:e}),null}},this.loadSkillHealthDiagnostics=async()=>{this.patchDiagnosticsPhaseState("skillHealth",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/skill-health"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Skill health request failed with ${e.status}`;return this.patchDiagnosticsPhaseState("skillHealth",{phase:"error",error:s}),null}return this.patchDiagnosticsPhaseState("skillHealth",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchDiagnosticsPhaseState("skillHealth",{phase:"error",error:e}),null}},this.loadKnowledgeData=async()=>{this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/knowledge"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Knowledge request failed with ${e.status}`;return this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"error",error:s}),null}return this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"error",error:e}),null}},this.loadCapturesData=async()=>{this.patchKnowledgeCapturesPhaseState("captures",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/captures"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Captures request failed with ${e.status}`;return this.patchKnowledgeCapturesPhaseState("captures",{phase:"error",error:s}),null}return this.patchKnowledgeCapturesPhaseState("captures",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchKnowledgeCapturesPhaseState("captures",{phase:"error",error:e}),null}},this.loadSettingsData=async()=>{this.patchSettingsPhaseState({phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/settings-data"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Settings request failed with ${e.status}`;return this.patchSettingsPhaseState({phase:"error",error:s}),null}return this.patchSettingsPhaseState({phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchSettingsPhaseState({phase:"error",error:e}),null}},this.loadHistoryData=async()=>{this.patchRemainingCommandsPhaseState("history",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/history"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`History request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("history",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("history",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchRemainingCommandsPhaseState("history",{phase:"error",error:e}),null}},this.loadInspectData=async()=>{this.patchRemainingCommandsPhaseState("inspect",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/inspect"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Inspect request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("inspect",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("inspect",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchRemainingCommandsPhaseState("inspect",{phase:"error",error:e}),null}},this.loadHooksData=async()=>{this.patchRemainingCommandsPhaseState("hooks",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/hooks"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Hooks request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("hooks",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("hooks",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchRemainingCommandsPhaseState("hooks",{phase:"error",error:e}),null}},this.loadExportData=async e=>{this.patchRemainingCommandsPhaseState("exportData",{phase:"loading",error:null});try{let t=e?`/api/export-data?format=${encodeURIComponent(e)}`:"/api/export-data",s=await (0,b.tm)(t,{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),r=await s.json().catch(()=>null);if(!s.ok||!r){let e=r?.error??`Export request failed with ${s.status}`;return this.patchRemainingCommandsPhaseState("exportData",{phase:"error",error:e}),null}return this.patchRemainingCommandsPhaseState("exportData",{phase:"loaded",data:r,lastLoadedAt:new Date().toISOString()}),r}catch(t){let e=M(t);return this.patchRemainingCommandsPhaseState("exportData",{phase:"error",error:e}),null}},this.loadUndoInfo=async()=>{this.patchRemainingCommandsPhaseState("undo",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/undo"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Undo info request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("undo",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("undo",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchRemainingCommandsPhaseState("undo",{phase:"error",error:e}),null}},this.loadCleanupData=async()=>{this.patchRemainingCommandsPhaseState("cleanup",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/cleanup"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Cleanup data request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("cleanup",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("cleanup",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchRemainingCommandsPhaseState("cleanup",{phase:"error",error:e}),null}},this.loadSteerData=async()=>{this.patchRemainingCommandsPhaseState("steer",{phase:"loading",error:null});try{let e=await (0,b.tm)(this.host.buildUrl("/api/steer"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Steer data request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("steer",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("steer",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=M(t);return this.patchRemainingCommandsPhaseState("steer",{phase:"error",error:e}),null}},this.executeUndoAction=async()=>{try{let e=await (0,b.tm)(this.host.buildUrl("/api/undo"),{method:"POST",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Undo action failed with ${e.status}`;return{success:!1,message:s}}return this.loadUndoInfo(),t}catch(e){return{success:!1,message:M(e)}}},this.executeCleanupAction=async(e,t)=>{try{let s=await (0,b.tm)(this.host.buildUrl("/api/cleanup"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({branches:e,snapshots:t})}),r=await s.json().catch(()=>null);if(!s.ok||!r){let e=r?.error??`Cleanup action failed with ${s.status}`;return{deletedBranches:0,prunedSnapshots:0,message:e}}return this.loadCleanupData(),r}catch(e){return{deletedBranches:0,prunedSnapshots:0,message:M(e)}}},this.resolveCaptureAction=async e=>{this.patchKnowledgeCapturesState({resolveRequest:{pending:!0,lastError:null,lastResult:null}});try{let t=await (0,b.tm)(this.host.buildUrl("/api/captures"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),s=await t.json().catch(()=>null);if(!t.ok||!s){let e=s?.error??`Capture resolve failed with ${t.status}`;return this.patchKnowledgeCapturesState({resolveRequest:{pending:!1,lastError:e,lastResult:null}}),null}return this.patchKnowledgeCapturesState({resolveRequest:{pending:!1,lastError:null,lastResult:s}}),this.loadCapturesData(),s}catch(t){let e=M(t);return this.patchKnowledgeCapturesState({resolveRequest:{pending:!1,lastError:e,lastResult:null}}),null}},this.updateSessionBrowserState=e=>{this.host.patchState({commandSurface:{...this.host.getState().commandSurface,sessionBrowser:{...this.host.getState().commandSurface.sessionBrowser,...e,error:null},lastError:null,lastResult:null}})},this.loadSessionBrowser=async(e={})=>{let t={...this.host.getState().commandSurface.sessionBrowser,...e,error:null},s={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionBrowser:F(this.host.getState().live.freshness.sessionBrowser)}};this.host.patchState({live:{...s,recoverySummary:L({boot:this.host.getState().boot,live:s})},commandSurface:(0,x.Yc)({...this.host.getState().commandSurface,sessionBrowser:t},"load_session_browser")});let r=new URLSearchParams;t.query.trim()&&r.set("query",t.query.trim()),r.set("sortMode",t.sortMode),r.set("nameFilter",t.nameFilter);try{let e=await (0,b.tm)(this.host.buildUrl(`/api/session/browser?${r.toString()}`),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),s=await e.json().catch(()=>null),a=function(e){if(!e||"object"!=typeof e)return null;let t=e.project,s=e.query;if(!t||!s||!Array.isArray(e.sessions)||"current_project"!==t.scope||"string"!=typeof t.cwd||"string"!=typeof t.sessionsDir||"string"!=typeof s.query||"string"!=typeof s.sortMode||"string"!=typeof s.nameFilter)return null;let r=e.sessions.filter(e=>"string"==typeof e?.id&&"string"==typeof e?.path&&"string"==typeof e?.cwd&&"string"==typeof e?.createdAt&&"string"==typeof e?.modifiedAt&&"number"==typeof e?.messageCount&&"string"==typeof e?.firstMessage&&"boolean"==typeof e?.isActive&&"number"==typeof e?.depth&&"boolean"==typeof e?.isLastInThread&&Array.isArray(e?.ancestorHasNextSibling));return{scope:t.scope,projectCwd:t.cwd,projectSessionsDir:t.sessionsDir,activeSessionPath:"string"==typeof t.activeSessionPath?t.activeSessionPath:null,query:s.query,sortMode:s.sortMode,nameFilter:s.nameFilter,totalSessions:Number(e.totalSessions??r.length),returnedSessions:Number(e.returnedSessions??r.length),sessions:r,loaded:!0,error:null}}(s);if(!e.ok||!a){let r=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Current-project session browser failed with ${e.status}`,a={...t,error:r},n={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionBrowser:D(this.host.getState().live.freshness.sessionBrowser,r)}};return this.host.patchState({live:{...n,recoverySummary:L({boot:this.host.getState().boot,live:n})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,sessionBrowser:a},{action:"load_session_browser",success:!1,message:r,sessionBrowser:a})}),null}let n=K(a,this.host.getState().boot),i=this.host.getState().commandSurface.selectedTarget,o=n.sessions.find(e=>!e.isActive)?.path??n.sessions[0]?.path,l=n.sessions.find(e=>e.path===n.activeSessionPath)??n.sessions[0],d=i;if(i?.kind==="resume"||"resume"===this.host.getState().commandSurface.section){let e=i?.kind==="resume"&&i.sessionPath&&n.sessions.some(e=>e.path===i.sessionPath)?i.sessionPath:o;d={kind:"resume",sessionPath:e}}else if(i?.kind==="name"||"name"===this.host.getState().commandSurface.section){let e=i?.kind==="name"&&i.sessionPath?n.sessions.find(e=>e.path===i.sessionPath)??l:l;d={kind:"name",sessionPath:e?.path,name:i?.kind==="name"&&i.sessionPath===e?.path?i.name:e?.name??""}}let c={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionBrowser:$(this.host.getState().live.freshness.sessionBrowser)}};return this.host.patchState({live:{...c,recoverySummary:L({boot:this.host.getState().boot,live:c})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,sessionBrowser:n},{action:"load_session_browser",success:!0,message:"",selectedTarget:d,sessionBrowser:n})}),n}catch(a){let e=M(a),s={...t,error:e},r={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionBrowser:D(this.host.getState().live.freshness.sessionBrowser,e)}};return this.host.patchState({live:{...r,recoverySummary:L({boot:this.host.getState().boot,live:r})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,sessionBrowser:s},{action:"load_session_browser",success:!1,message:e,sessionBrowser:s})}),null}},this.renameSessionFromSurface=async(e,t)=>{let s=this.host.getState().commandSurface.selectedTarget,r=t??(s?.kind==="name"?s.name:""),a=r.trim(),n={kind:"name",sessionPath:e,name:r};if(!a)return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"rename_session",success:!1,message:"Session name cannot be empty",selectedTarget:n})}),null;this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"rename_session",n)});try{let t=await (0,b.tm)(this.host.buildUrl("/api/session/manage"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({action:"rename",sessionPath:e,name:a})}),s=await t.json().catch(()=>null);if(!t.ok||!s||"object"!=typeof s||!0!==s.success){let e=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Session rename failed with ${t.status}`;return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"rename_session",success:!1,message:e,selectedTarget:n})}),null}let r=function(e,t,s){if(!e)return null;let r=G(e)===t&&e.bridge.sessionState?{...e.bridge,sessionState:{...e.bridge.sessionState,sessionName:s}}:e.bridge,a={...e,bridge:r};return{...a,resumableSessions:W(a.resumableSessions.map(e=>e.path===t?{...e,name:s}:e),a)}}(this.host.getState().boot,s.sessionPath,s.name),i=K(V(this.host.getState().commandSurface.sessionBrowser,s.sessionPath,{name:s.name,...s.isActiveSession?{isActive:!0}:{}}),r),o={kind:"name",sessionPath:s.sessionPath,name:s.name},l={...this.host.getState().live,resumableSessions:A(this.host.getState().live.resumableSessions,W(E(this.host.getState()).map(e=>e.path===s.sessionPath?{...e,name:s.name}:e),r))};return this.host.patchState({...r?{boot:r}:{},live:{...l,recoverySummary:L({boot:r,live:l})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,sessionBrowser:i},{action:"rename_session",success:!0,message:`Session name set: ${s.name}`,selectedTarget:o,sessionBrowser:i})}),s}catch(t){let e=M(t);return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"rename_session",success:!1,message:e,selectedTarget:n})}),null}},this.loadAvailableModels=async()=>{this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"loading_models")});let e=await this.host.sendCommand({type:"get_available_models"},{appendInputLine:!1,appendResponseLine:!1});if(!e||!1===e.success){let t=e?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"loading_models",success:!1,message:`Couldn't load models — ${t}`})}),[]}let t=function(e,t){let s=e&&"object"==typeof e&&"models"in e&&Array.isArray(e.models)?e.models:[],r=[];for(let e of s){let s="string"==typeof e.provider?e.provider:"string"==typeof e.providerId?e.providerId:void 0,a="string"==typeof e.id?e.id:void 0;s&&a&&r.push({provider:s,modelId:a,name:"string"==typeof e.name?e.name:void 0,reasoning:!!e.reasoning,isCurrent:s===t?.provider&&a===t?.modelId})}return r.sort((e,t)=>Number(t.isCurrent)-Number(e.isCurrent)||e.provider.localeCompare(t.provider)||e.modelId.localeCompare(t.modelId))}(e.data,B(this.host.getState().boot?.bridge)),s=this.host.getState().commandSurface.selectedTarget,r=s?.kind==="model"?s:t[0]?{kind:"model",provider:t[0].provider,modelId:t[0].modelId}:s;return this.host.patchState({commandSurface:{...this.host.getState().commandSurface,pendingAction:null,lastError:null,availableModels:t,selectedTarget:r??null}}),t},this.applyModelSelection=async(e,t)=>{let s={kind:"model",provider:e,modelId:t};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"set_model",s)});let r=await this.host.sendCommand({type:"set_model",provider:e,modelId:t},{appendInputLine:!1,appendResponseLine:!1});if(!r||!1===r.success){let e=r?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_model",success:!1,message:e,selectedTarget:s})}),r}let a=this.host.getState().boot,n=a?.bridge.sessionState?{...a.bridge,sessionState:{...a.bridge.sessionState,model:r.data}}:null,i=this.host.getState().commandSurface.availableModels.map(s=>({...s,isCurrent:s.provider===e&&s.modelId===t}));return this.host.patchState({...n&&this.host.getState().boot?{boot:H(this.host.getState().boot,n)}:{},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_model",success:!0,message:`Model set to ${e}/${t}`,selectedTarget:s,availableModels:i})}),r},this.applyThinkingLevel=async e=>{let t={kind:"thinking",level:e};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"set_thinking_level",t)});let s=await this.host.sendCommand({type:"set_thinking_level",level:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_thinking_level",success:!1,message:e,selectedTarget:t})}),s}let r=this.host.getState().boot,a=r?.bridge.sessionState?{...r.bridge,sessionState:{...r.bridge.sessionState,thinkingLevel:e}}:null;return this.host.patchState({...a&&this.host.getState().boot?{boot:H(this.host.getState().boot,a)}:{},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_thinking_level",success:!0,message:`Thinking level set to ${e}`,selectedTarget:t})}),s},this.setSteeringModeFromSurface=async e=>{let t=this.host.getState().commandSurface.selectedTarget;this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"set_steering_mode",t)});let s=await this.host.sendCommand({type:"set_steering_mode",mode:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_steering_mode",success:!1,message:e,selectedTarget:t})}),s}let r=Y(this.host.getState().boot,{steeringMode:e});return this.host.patchState({...r?{boot:r}:{},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_steering_mode",success:!0,message:`Steering mode set to ${e}`,selectedTarget:t})}),s},this.setFollowUpModeFromSurface=async e=>{let t=this.host.getState().commandSurface.selectedTarget;this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"set_follow_up_mode",t)});let s=await this.host.sendCommand({type:"set_follow_up_mode",mode:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_follow_up_mode",success:!1,message:e,selectedTarget:t})}),s}let r=Y(this.host.getState().boot,{followUpMode:e});return this.host.patchState({...r?{boot:r}:{},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_follow_up_mode",success:!0,message:`Follow-up mode set to ${e}`,selectedTarget:t})}),s},this.setAutoCompactionFromSurface=async e=>{let t=this.host.getState().commandSurface.selectedTarget;this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"set_auto_compaction",t)});let s=await this.host.sendCommand({type:"set_auto_compaction",enabled:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_auto_compaction",success:!1,message:e,selectedTarget:t})}),s}let r=Y(this.host.getState().boot,{autoCompactionEnabled:e});return this.host.patchState({...r?{boot:r}:{},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_auto_compaction",success:!0,message:`Auto-compaction ${e?"enabled":"disabled"}`,selectedTarget:t})}),s},this.setAutoRetryFromSurface=async e=>{let t=this.host.getState().commandSurface.selectedTarget;this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"set_auto_retry",t)});let s=await this.host.sendCommand({type:"set_auto_retry",enabled:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_auto_retry",success:!1,message:e,selectedTarget:t})}),s}let r=Y(this.host.getState().boot,{autoRetryEnabled:e});return this.host.patchState({...r?{boot:r}:{},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"set_auto_retry",success:!0,message:`Auto-retry ${e?"enabled":"disabled"}`,selectedTarget:t})}),s},this.abortRetryFromSurface=async()=>{let e=this.host.getState().commandSurface.selectedTarget;this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"abort_retry",e)});let t=await this.host.sendCommand({type:"abort_retry"},{appendInputLine:!1,appendResponseLine:!1});if(!t||!1===t.success){let s=t?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"abort_retry",success:!1,message:s,selectedTarget:e})}),t}return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"abort_retry",success:!0,message:"Retry cancellation requested. Live retry state will update when the bridge confirms the abort.",selectedTarget:e})}),t},this.switchSessionFromSurface=async e=>{var t;let s,r={kind:"resume",sessionPath:e};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"switch_session",r)});let a=await this.host.sendCommand({type:"switch_session",sessionPath:e},{appendInputLine:!1,appendResponseLine:!1});if(!a||!1===a.success){let e=a?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"switch_session",success:!1,message:e,selectedTarget:r})}),a}if(a.data&&"object"==typeof a.data&&"cancelled"in a.data&&a.data.cancelled)return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"switch_session",success:!1,message:"Session switch was cancelled before the browser changed sessions.",selectedTarget:r})}),a;let n=this.host.getState().commandSurface.sessionBrowser.sessions.find(t=>t.path===e)?.name??this.host.getState().boot?.resumableSessions.find(t=>t.path===e)?.name,i=function(e,t,s){if(!e)return null;let r=e.resumableSessions.find(e=>e.path===t),a={...e.bridge,activeSessionFile:t,activeSessionId:r?.id??e.bridge.activeSessionId,sessionState:e.bridge.sessionState?{...e.bridge.sessionState,sessionFile:t,sessionId:r?.id??e.bridge.sessionState.sessionId,sessionName:s??r?.name??e.bridge.sessionState.sessionName}:e.bridge.sessionState},n={...e,bridge:a};return{...n,resumableSessions:W(n.resumableSessions.map(e=>({...e,isActive:e.path===t})),n)}}(this.host.getState().boot,e,n),o=K(V(this.host.getState().commandSurface.sessionBrowser,e,{isActive:!0,...n?{name:n}:{}}),i),l={...this.host.getState().live,resumableSessions:A(this.host.getState().live.resumableSessions,W(E(this.host.getState()).map(t=>({...t,isActive:t.path===e,...t.path===e&&n?{name:n}:{}})),i))};return this.host.patchState({...i?{boot:i}:{},live:{...l,recoverySummary:L({boot:i,live:l})},commandSurface:(0,x.yC)({...this.host.getState().commandSurface,sessionBrowser:o},{action:"switch_session",success:!0,message:`Switched to ${(t=i??this.host.getState().boot,s=t?.resumableSessions.find(t=>t.path===e),s?.name?.trim()?s.name.trim():s?.id?s.id:function(e,t=3){if(!e)return"—";let s=e.split(/[\\/]/).filter(Boolean);if(s.length<=t)return e.startsWith("/")?`/${s.join("/")}`:s.join("/");let r=s.slice(-t).join("/");return`…/${r}`}(e))}`,selectedTarget:r,sessionBrowser:o})}),a},this.loadSessionStats=async()=>{var e;let t={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionStats:F(this.host.getState().live.freshness.sessionStats)}};this.host.patchState({live:{...t,recoverySummary:L({boot:this.host.getState().boot,live:t})},commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"load_session_stats")});let s=await this.host.sendCommand({type:"get_session_stats"},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.host.getState().lastClientError??"Unknown error",t={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionStats:D(this.host.getState().live.freshness.sessionStats,e)}};return this.host.patchState({live:{...t,recoverySummary:L({boot:this.host.getState().boot,live:t})},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"load_session_stats",success:!1,message:`Couldn't load session details — ${e}`,sessionStats:null})}),null}let r=(e=s.data)&&"object"==typeof e?"string"!=typeof e.sessionId?null:{sessionFile:"string"==typeof e.sessionFile?e.sessionFile:void 0,sessionId:e.sessionId,userMessages:Number(e.userMessages??0),assistantMessages:Number(e.assistantMessages??0),toolCalls:Number(e.toolCalls??0),toolResults:Number(e.toolResults??0),totalMessages:Number(e.totalMessages??0),tokens:{input:Number(e.tokens?.input??0),output:Number(e.tokens?.output??0),cacheRead:Number(e.tokens?.cacheRead??0),cacheWrite:Number(e.tokens?.cacheWrite??0),total:Number(e.tokens?.total??0)},cost:Number(e.cost??0)}:null;if(!r){let e="Session details response was missing the expected fields.",t={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionStats:D(this.host.getState().live.freshness.sessionStats,e)}};return this.host.patchState({live:{...t,recoverySummary:L({boot:this.host.getState().boot,live:t})},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"load_session_stats",success:!1,message:e,sessionStats:null})}),null}let a={...this.host.getState().live,freshness:{...this.host.getState().live.freshness,sessionStats:$(this.host.getState().live.freshness.sessionStats)}};return this.host.patchState({live:{...a,recoverySummary:L({boot:this.host.getState().boot,live:a})},commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"load_session_stats",success:!0,message:`Loaded session details for ${r.sessionId}`,sessionStats:r})}),r},this.exportSessionFromSurface=async e=>{let t=e?.trim()||void 0,s={kind:"session",outputPath:t};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"export_html",s)});let r=await this.host.sendCommand(t?{type:"export_html",outputPath:t}:{type:"export_html"},{appendInputLine:!1,appendResponseLine:!1});if(!r||!1===r.success){let e=r?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"export_html",success:!1,message:`Couldn't export this session — ${e}`,selectedTarget:s})}),r}let a=r.data&&"object"==typeof r.data&&"path"in r.data&&"string"==typeof r.data.path?r.data.path:"the generated file";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"export_html",success:!0,message:`Session exported to ${a}`,selectedTarget:s})}),r},this.loadForkMessages=async()=>{var e;this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"load_fork_messages")});let t=await this.host.sendCommand({type:"get_fork_messages"},{appendInputLine:!1,appendResponseLine:!1});if(!t||!1===t.success){let e=t?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"load_fork_messages",success:!1,message:`Couldn't load fork points — ${e}`,forkMessages:[]})}),[]}let s=((e=t.data)&&"object"==typeof e&&"messages"in e&&Array.isArray(e.messages)?e.messages:[]).map(e=>{let t="string"==typeof e.entryId?e.entryId:void 0,s="string"==typeof e.text?e.text:void 0;return t&&s?{entryId:t,text:s}:null}).filter(e=>null!==e),r=this.host.getState().commandSurface.selectedTarget,a=r?.kind==="fork"&&r.entryId?r:s[0]?{kind:"fork",entryId:s[0].entryId}:r;return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"load_fork_messages",success:!0,message:s.length>0?`Loaded ${s.length} fork points.`:"No fork points are available yet.",selectedTarget:a??null,forkMessages:s})}),s},this.forkSessionFromSurface=async e=>{let t={kind:"fork",entryId:e};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"fork_session",t)});let s=await this.host.sendCommand({type:"fork",entryId:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"fork_session",success:!1,message:`Couldn't create a fork — ${e}`,selectedTarget:t})}),s}if(s.data&&"object"==typeof s.data&&"cancelled"in s.data&&s.data.cancelled)return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"fork_session",success:!1,message:"Fork creation was cancelled before a new session was created.",selectedTarget:t})}),s;let r=s.data&&"object"==typeof s.data&&"text"in s.data&&"string"==typeof s.data.text?s.data.text.trim():"";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"fork_session",success:!0,message:r?`Forked from “${r.slice(0,120)}${r.length>120?"…":""}”`:"Created a forked session.",selectedTarget:t})}),s},this.compactSessionFromSurface=async e=>{var t;let s=e?.trim()??"",r={kind:"compact",customInstructions:s};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"compact_session",r)});let a=await this.host.sendCommand(s?{type:"compact",customInstructions:s}:{type:"compact"},{appendInputLine:!1,appendResponseLine:!1});if(!a||!1===a.success){let e=a?.error??this.host.getState().lastClientError??"Unknown error";return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"compact_session",success:!1,message:`Couldn't compact the session — ${e}`,selectedTarget:r,lastCompaction:null})}),a}let n=(t=a.data)&&"object"==typeof t?"string"!=typeof t.summary||"string"!=typeof t.firstKeptEntryId?null:{summary:t.summary,firstKeptEntryId:t.firstKeptEntryId,tokensBefore:Number(t.tokensBefore??0),details:t.details}:null;return n?this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"compact_session",success:!0,message:`Compacted ${n.tokensBefore.toLocaleString()} tokens into a fresh summary${s?" with custom instructions":""}.`,selectedTarget:r,lastCompaction:n})}):this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"compact_session",success:!1,message:"Compaction finished but the browser could not read the compaction result.",selectedTarget:r,lastCompaction:null})}),a},this.saveApiKeyFromSurface=async(e,t)=>{let s={kind:"auth",providerId:e,intent:"manage"};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"save_api_key",s)});let r=await this.host.saveApiKey(e,t),a=r?q(r,e):e;return r?(r.lastValidation?.status==="failed"?this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"save_api_key",success:!1,message:r.lastValidation.message,selectedTarget:s})}):"failed"===r.bridgeAuthRefresh.phase?this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"save_api_key",success:!1,message:r.bridgeAuthRefresh.error??`${a} credentials validated but bridge auth refresh failed`,selectedTarget:s})}):this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"save_api_key",success:!0,message:`${a} credentials validated and saved.`,selectedTarget:s})}),r):(this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"save_api_key",success:!1,message:this.host.getState().lastClientError??`${a} setup failed`,selectedTarget:s})}),null)},this.startProviderFlowFromSurface=async e=>{let t={kind:"auth",providerId:e,intent:"login"};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"start_provider_flow",t)});let s=await this.host.startProviderFlow(e),r=s?q(s,e):e;return s?(this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"start_provider_flow",success:!0,message:`${r} sign-in started. Continue in the auth section.`,selectedTarget:t})}),s):(this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"start_provider_flow",success:!1,message:this.host.getState().lastClientError??`${r} sign-in failed to start`,selectedTarget:t})}),null)},this.submitProviderFlowInputFromSurface=async(e,t)=>{let s=this.host.getState().boot?.onboarding.activeFlow?.providerId??void 0,r={kind:"auth",providerId:s,intent:"login"};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"submit_provider_flow_input",r)});let a=await this.host.submitProviderFlowInput(e,t),n=a?.activeFlow?.providerLabel??(s&&a?q(a,s):s)??"Provider";if(!a)return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"submit_provider_flow_input",success:!1,message:this.host.getState().lastClientError??`${n} sign-in failed`,selectedTarget:r})}),null;if(a.activeFlow?.status==="failed")return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"submit_provider_flow_input",success:!1,message:a.activeFlow.error??`${n} sign-in failed`,selectedTarget:r})}),a;if("failed"===a.bridgeAuthRefresh.phase)return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"submit_provider_flow_input",success:!1,message:a.bridgeAuthRefresh.error??`${n} sign-in completed but bridge auth refresh failed`,selectedTarget:r})}),a;let i=a.activeFlow&&["running","awaiting_browser_auth","awaiting_input"].includes(a.activeFlow.status)?`${n} sign-in advanced. Complete the remaining step in this panel.`:`${n} sign-in complete.`;return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"submit_provider_flow_input",success:!0,message:i,selectedTarget:r})}),a},this.cancelProviderFlowFromSurface=async e=>{let t=this.host.getState().boot?.onboarding.activeFlow?.providerId??void 0,s={kind:"auth",providerId:t,intent:"login"};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"cancel_provider_flow",s)});let r=await this.host.cancelProviderFlow(e),a=r?.activeFlow?.providerLabel??(t&&r?q(r,t):t)??"Provider";return r?(this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"cancel_provider_flow",success:!0,message:`${a} sign-in cancelled.`,selectedTarget:s})}),r):(this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"cancel_provider_flow",success:!1,message:this.host.getState().lastClientError??`${a} sign-in cancellation failed`,selectedTarget:s})}),null)},this.logoutProviderFromSurface=async e=>{let t={kind:"auth",providerId:e,intent:"logout"};this.host.patchState({commandSurface:(0,x.Yc)(this.host.getState().commandSurface,"logout_provider",t)});let s=await await this.host.logoutProvider(e),r=s?q(s,e):e;if(!s)return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"logout_provider",success:!1,message:this.host.getState().lastClientError??`${r} logout failed`,selectedTarget:t})}),null;if("failed"===s.bridgeAuthRefresh.phase)return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"logout_provider",success:!1,message:s.bridgeAuthRefresh.error??`${r} logout completed but bridge auth refresh failed`,selectedTarget:t})}),s;let a=s.required.providers.find(t=>t.id===e),n=a?.configured?`${r} saved credentials were removed, but ${a.configuredVia} auth still keeps the provider available.`:s.locked?`${r} logged out — required setup is needed again.`:`${r} logged out.`;return this.host.patchState({commandSurface:(0,x.yC)(this.host.getState().commandSurface,{action:"logout_provider",success:!0,message:n,selectedTarget:t})}),s},this.host=e}patchDiagnosticsPhaseState(e,t){this.host.patchState({commandSurface:{...this.host.getState().commandSurface,diagnostics:{...this.host.getState().commandSurface.diagnostics,[e]:{...this.host.getState().commandSurface.diagnostics[e],...t}}}})}patchDoctorState(e){this.host.patchState({commandSurface:{...this.host.getState().commandSurface,diagnostics:{...this.host.getState().commandSurface.diagnostics,doctor:{...this.host.getState().commandSurface.diagnostics.doctor,...e}}}})}patchKnowledgeCapturesState(e){this.host.patchState({commandSurface:{...this.host.getState().commandSurface,knowledgeCaptures:{...this.host.getState().commandSurface.knowledgeCaptures,...e}}})}patchKnowledgeCapturesPhaseState(e,t){this.host.patchState({commandSurface:{...this.host.getState().commandSurface,knowledgeCaptures:{...this.host.getState().commandSurface.knowledgeCaptures,[e]:{...this.host.getState().commandSurface.knowledgeCaptures[e],...t}}}})}patchSettingsPhaseState(e){this.host.patchState({commandSurface:{...this.host.getState().commandSurface,settingsData:{...this.host.getState().commandSurface.settingsData,...e}}})}patchRemainingCommandsPhaseState(e,t){this.host.patchState({commandSurface:{...this.host.getState().commandSurface,remainingCommands:{...this.host.getState().commandSurface.remainingCommands,[e]:{...this.host.getState().commandSurface.remainingCommands[e],...t}}}})}}let Z=new Set(["settings","model","thinking","git","resume","name","fork","compact","login","logout","session","export","gsd-visualize","gsd-forensics","gsd-doctor","gsd-skill-health","gsd-knowledge","gsd-capture","gsd-triage","gsd-quick","gsd-history","gsd-undo","gsd-inspect","gsd-prefs","gsd-config","gsd-hooks","gsd-mode","gsd-steer","gsd-report","gsd-export","gsd-cleanup","gsd-queue"]);function Q(e){return!!(e?.activeSessionId||e?.sessionState?.sessionId)}function X(e){if("failed"===e.phase)return{type:"error",message:`Bridge failed${e.lastError?.message?` — ${e.lastError.message}`:""}`};if("starting"===e.phase)return{type:"system",message:"Bridge starting for the current project…"};if("ready"===e.phase){let t=ex(e);return{type:"success",message:t?`Live bridge ready — attached to ${t}`:"Live bridge ready — session attachment pending"}}return{type:"system",message:"Bridge idle"}}function ee(e){switch(e.type){case"bridge_status":return X(e.bridge);case"live_state_invalidation":return{type:"system",message:`[Live] Refreshing ${Array.isArray(e.domains)?e.domains.join(", "):"state"} after ${String(e.reason).replaceAll("_"," ")}`};case"agent_start":return{type:"system",message:"[Agent] Run started"};case"agent_end":return{type:"success",message:"[Agent] Run finished"};case"turn_start":return{type:"system",message:"[Agent] Turn started"};case"turn_end":return{type:"success",message:"[Agent] Turn complete"};case"tool_execution_start":return{type:"output",message:`[Tool] ${"string"==typeof e.toolName?e.toolName:"tool"} started`};case"tool_execution_update":default:return null;case"tool_execution_end":return{type:e.isError?"error":"success",message:`[Tool] ${"string"==typeof e.toolName?e.toolName:"tool"} ${e.isError?"failed":"completed"}`};case"auto_compaction_start":return{type:"system",message:"[Auto] Compaction started"};case"auto_compaction_end":return{type:e.aborted?"error":"success",message:e.aborted?"[Auto] Compaction aborted":"[Auto] Compaction finished"};case"auto_retry_start":return{type:"system",message:`[Auto] Retry ${String(e.attempt)}/${String(e.maxAttempts)} scheduled`};case"auto_retry_end":return{type:e.success?"success":"error",message:e.success?"[Auto] Retry recovered the run":"[Auto] Retry exhausted"};case"extension_ui_request":{let t="title"in e&&"string"==typeof e.title&&e.title.trim().length>0?e.title:"message"in e&&"string"==typeof e.message&&e.message.trim().length>0?e.message:e.method;return{type:"notifyType"in e&&"error"===e.notifyType?"error":"system",message:`[UI] ${t}`}}case"extension_error":return{type:"error",message:`[Extension] ${e.error}`}}}let et=new Set(["running","awaiting_browser_auth","awaiting_input"]),es=new Set(["succeeded","failed","cancelled"]);function er(e,t){return e?{...e,onboarding:t,onboardingNeeded:t.locked}:null}function ea(e){return"failed"===e.bridgeAuthRefresh.phase?{type:"error",message:e.bridgeAuthRefresh.error?`Bridge auth refresh failed — ${e.bridgeAuthRefresh.error}`:"Bridge auth refresh failed after setup"}:"pending"===e.bridgeAuthRefresh.phase?{type:"system",message:"Credentials saved — refreshing bridge auth before the workspace unlocks…"}:e.lastValidation?.status==="failed"?{type:"error",message:`Credential validation failed — ${e.lastValidation.message}`}:e.locked||e.lastValidation?.status!=="succeeded"?e.activeFlow?.status==="awaiting_browser_auth"?{type:"system",message:`${e.activeFlow.providerLabel} sign-in is waiting for browser confirmation`}:e.activeFlow?.status==="awaiting_input"?{type:"system",message:`${e.activeFlow.providerLabel} sign-in needs one more input step`}:e.activeFlow?.status==="cancelled"?{type:"system",message:`${e.activeFlow.providerLabel} sign-in was cancelled`}:e.activeFlow?.status==="failed"?{type:"error",message:e.activeFlow.error?`${e.activeFlow.providerLabel} sign-in failed — ${e.activeFlow.error}`:`${e.activeFlow.providerLabel} sign-in failed`}:"required_setup"===e.lockReason?{type:"system",message:"Onboarding is still required before model-backed prompts will run"}:null:{type:"success",message:`${q(e,e.lastValidation.providerId)} is ready — workspace unlocked`}}function en(e){let t=[g("system",`GSD web workspace attached to ${e.project.cwd}`),g("system",`Workspace scope: ${eu(e.workspace)}`)],s=X(e.bridge);t.push(g(s.type,s.message)),e.bridge.lastError&&t.push(g("error",`Bridge error: ${e.bridge.lastError.message}`));let r=ea(e.onboarding);return r&&t.push(g(r.type,r.message)),t}function ei(e,t=3){if(!e)return"—";let s=e.split(/[\\/]/).filter(Boolean);if(s.length<=t)return e.startsWith("/")?`/${s.join("/")}`:s.join("/");let r=s.slice(-t).join("/");return`…/${r}`}function eo(e){return e?e.split(/[\\/]/).filter(Boolean).at(-1)||e:"Current project"}function el(e){if(!e||e<1e3)return"0m";let t=Math.floor(e/6e4),s=Math.floor(t/60),r=t%60;return s>0?`${s}h ${r}m`:`${r}m`}function ed(e){return!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(Math.round(e))}function ec(e){return!Number.isFinite(e)||e<=0?"$0.00":`$${e.toFixed(2)}`}function eu(e){if(!e)return"Project scope pending";let t=[e.active.milestoneId,e.active.sliceId,e.active.taskId].filter(Boolean).join("/");return t?`${t} — ${e.active.phase}`:`project — ${e.active.phase}`}function em(e){if(!e?.active.milestoneId||!e.active.sliceId)return null;let t=e.milestones.find(t=>t.id===e.active.milestoneId),s=t?.slices.find(t=>t.id===e.active.sliceId);return s?.branch??null}function eh(e){if(!e?.active.milestoneId||!e.active.sliceId)return null;let t=e.milestones.find(t=>t.id===e.active.milestoneId);return t?.slices.find(t=>t.id===e.active.sliceId)??null}function ex(e){if(!e?.sessionState&&!e?.activeSessionId)return null;let t=e.sessionState?.sessionName?.trim();return t||(e.activeSessionId?`session ${e.activeSessionId}`:e.sessionState?.sessionId??null)}function ep(e){let t=e?.sessionState?.model;return t&&(t.id||t.providerId||t.provider)||"model pending"}function eg(e){let t=e.boot?.onboarding;return t?.bridgeAuthRefresh.phase==="failed"&&t.bridgeAuthRefresh.error?t.bridgeAuthRefresh.error:t?.lastValidation?.status==="failed"?t.lastValidation.message:e.lastBridgeError?.message??e.lastClientError}function ef(e){if("loading"===e.bootStatus)return{label:"Loading workspace",tone:"info"};if("error"===e.bootStatus)return{label:"Boot failed",tone:"danger"};let t=function(e){if("loading"===e.bootStatus||!e.boot)return{phase:"loading",label:"Loading setup state",detail:"Resolving the current project, bridge, and onboarding contract…",tone:"info"};let t=e.boot.onboarding;return t.activeFlow?.status==="awaiting_browser_auth"?{phase:"awaiting_browser_auth",label:"Continue sign-in in your browser",detail:`${t.activeFlow.providerLabel} is waiting for browser confirmation before the workspace can unlock.`,tone:"info"}:t.activeFlow?.status==="awaiting_input"?{phase:"awaiting_input",label:"One more sign-in step is required",detail:t.activeFlow.prompt?.message??`${t.activeFlow.providerLabel} needs one more input step.`,tone:"info"}:"bridge_refresh_pending"===t.lockReason?{phase:"refreshing",label:"Refreshing bridge auth",detail:"Credentials validated. The live bridge is restarting onto the new auth view before the shell unlocks.",tone:"info"}:"bridge_refresh_failed"===t.lockReason?{phase:"failure",label:"Setup completed, but the shell is still locked",detail:t.bridgeAuthRefresh.error??"The bridge could not reload auth after setup.",tone:"danger"}:t.lastValidation?.status==="failed"?{phase:"failure",label:"Credential validation failed",detail:t.lastValidation.message,tone:"danger"}:"saving_api_key"===e.onboardingRequestState?{phase:"validating",label:"Validating credentials",detail:"Checking the provider key and saving it only if validation succeeds.",tone:"info"}:"starting_provider_flow"===e.onboardingRequestState||"submitting_provider_flow_input"===e.onboardingRequestState?{phase:"running_flow",label:"Advancing provider sign-in",detail:"The onboarding flow is running and will update here as soon as the next step is ready.",tone:"info"}:t.locked?{phase:"locked",label:"Required setup needed",detail:"Choose a required provider, validate it here, and the workspace will unlock without restarting the host.",tone:"warning"}:{phase:"ready",label:"Workspace unlocked",detail:t.lastValidation?.status==="succeeded"?`${q(t,t.lastValidation.providerId)} is ready and the workspace is live.`:"Required setup is satisfied and the shell is ready for live commands.",tone:"success"}}(e);if("ready"!==t.phase)return{label:t.label,tone:t.tone};if(e.boot?.bridge.phase==="failed")return{label:"Bridge failed",tone:"danger"};switch(e.connectionState){case"connected":return{label:"Bridge connected",tone:"success"};case"connecting":return{label:"Connecting stream",tone:"info"};case"reconnecting":return{label:"Reconnecting stream",tone:"warning"};case"disconnected":return{label:"Stream disconnected",tone:"warning"};case"error":return{label:"Stream error",tone:"danger"};default:return{label:"Workspace idle",tone:"muted"}}}function eb(e,t){if(!t)return e;let s=new URL(e,"http://localhost");return s.searchParams.set("project",t),s.pathname+s.search}class ev{constructor(e){this.projectCwd=e,this.state={bootStatus:"idle",connectionState:"idle",boot:null,live:{auto:S(),workspace:S(),resumableSessions:S([]),recoverySummary:_(),freshness:{recovery:N(),gitSummary:N(),sessionBrowser:N(),sessionStats:N()},softBootRefreshCount:0,targetedRefreshCount:0},terminalLines:[g("system","Preparing the live GSD workspace…")],lastClientError:null,lastBridgeError:null,sessionAttached:!1,lastEventType:null,commandInFlight:null,lastSlashCommandOutcome:null,commandSurface:(0,x.iE)(),onboardingRequestState:"idle",onboardingRequestProviderId:null,pendingUiRequests:[],streamingAssistantText:"",streamingThinkingText:"",completedTurns:[],pendingUserMessage:null,currentTurnSegments:[],completedToolExecutions:[],activeToolExecution:null,statusTexts:{},widgetContents:{},titleOverride:null,editorTextBuffer:null,workingMessage:null},this.listeners=new Set,this.contextualTips=new w,this.eventStream=new p({canConnect:()=>!this.disposed&&!this.state.boot?.onboarding.locked,streamUrl:()=>(0,b.QT)(this.buildUrl("/api/session/events")),onOpen:({wasDisconnected:e})=>this.handleEventStreamOpen(e),onMessage:e=>this.handleEventStreamMessage(e),onError:({nextConnectionState:e,changed:t})=>this.handleEventStreamError(e,t)}),this.bootPromise=null,this.onboardingPollTimer=null,this.started=!1,this.disposed=!1,this.lastBridgeDigest=null,this.commandTimeoutTimer=null,this.lastBootRefreshAt=0,this.visibilityHandler=null,this.emitScheduled=!1,this.emitFrame=null,this.emitTimer=null,this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.getSnapshot=()=>this.state,this.start=()=>{this.started||this.disposed||(this.started=!0,"u">typeof document&&(this.visibilityHandler=()=>{"visible"===document.visibilityState&&Date.now()-this.lastBootRefreshAt>=3e4&&this.refreshBoot({soft:!0})},document.addEventListener("visibilitychange",this.visibilityHandler)),this.refreshBoot())},this.dispose=()=>{this.disposed=!0,this.started=!1,this.cancelScheduledEmit(),this.stopOnboardingPoller(),this.closeEventStream(),this.clearCommandTimeout(),this.visibilityHandler&&"u">typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)},this.disconnectSSE=()=>{this.closeEventStream()},this.reconnectSSE=()=>{this.disposed||(this.ensureEventStream(),this.refreshBoot({soft:!0}))},this.clearTerminalLines=()=>{let e=this.state.boot?en(this.state.boot):[g("system","Terminal cleared")];this.patchState({terminalLines:e})},this.consumeEditorTextBuffer=()=>{let e=this.state.editorTextBuffer;return null!==e&&this.patchState({editorTextBuffer:null}),e},this.openCommandSurface=(e,t={})=>{let s=E(this.state);this.patchState({commandSurface:(0,x.Q8)(this.state.commandSurface,{surface:e,source:t.source??"surface",args:t.args??"",selectedTarget:t.selectedTarget,onboardingLocked:this.state.boot?.onboarding.locked,currentModel:B(this.state.boot?.bridge),currentThinkingLevel:this.state.boot?.bridge.sessionState?.thinkingLevel??null,preferredProviderId:U(this.state.boot?.onboarding),resumableSessions:s.map(e=>({id:e.id,path:e.path,name:e.name,isActive:e.isActive})),currentSessionPath:this.state.boot?.bridge.activeSessionFile??this.state.boot?.bridge.sessionState?.sessionFile??null,currentSessionName:this.state.boot?.bridge.sessionState?.sessionName??null,projectCwd:this.state.boot?.project.cwd??null,projectSessionsDir:this.state.boot?.project.sessionsDir??null})})},this.closeCommandSurface=()=>{this.patchState({commandSurface:(0,x.Qx)(this.state.commandSurface)})},this.setCommandSurfaceSection=e=>{let t=E(this.state);this.patchState({commandSurface:(0,x.c0)(this.state.commandSurface,e,{onboardingLocked:this.state.boot?.onboarding.locked,currentModel:B(this.state.boot?.bridge),currentThinkingLevel:this.state.boot?.bridge.sessionState?.thinkingLevel??null,preferredProviderId:U(this.state.boot?.onboarding),resumableSessions:t.map(e=>({id:e.id,path:e.path,name:e.name,isActive:e.isActive})),currentSessionPath:this.state.boot?.bridge.activeSessionFile??this.state.boot?.bridge.sessionState?.sessionFile??null,currentSessionName:this.state.boot?.bridge.sessionState?.sessionName??null,projectCwd:this.state.boot?.project.cwd??null,projectSessionsDir:this.state.boot?.project.sessionsDir??null})})},this.selectCommandSurfaceTarget=e=>{this.patchState({commandSurface:(0,x.nU)(this.state.commandSurface,e)})},this.loadGitSummary=(...e)=>this.commandSurfaceActions.loadGitSummary(...e),this.loadRecoveryDiagnostics=(...e)=>this.commandSurfaceActions.loadRecoveryDiagnostics(...e),this.loadForensicsDiagnostics=(...e)=>this.commandSurfaceActions.loadForensicsDiagnostics(...e),this.loadDoctorDiagnostics=(...e)=>this.commandSurfaceActions.loadDoctorDiagnostics(...e),this.applyDoctorFixes=(...e)=>this.commandSurfaceActions.applyDoctorFixes(...e),this.loadSkillHealthDiagnostics=(...e)=>this.commandSurfaceActions.loadSkillHealthDiagnostics(...e),this.loadKnowledgeData=(...e)=>this.commandSurfaceActions.loadKnowledgeData(...e),this.loadCapturesData=(...e)=>this.commandSurfaceActions.loadCapturesData(...e),this.loadSettingsData=(...e)=>this.commandSurfaceActions.loadSettingsData(...e),this.loadHistoryData=(...e)=>this.commandSurfaceActions.loadHistoryData(...e),this.loadInspectData=(...e)=>this.commandSurfaceActions.loadInspectData(...e),this.loadHooksData=(...e)=>this.commandSurfaceActions.loadHooksData(...e),this.loadExportData=(...e)=>this.commandSurfaceActions.loadExportData(...e),this.loadUndoInfo=(...e)=>this.commandSurfaceActions.loadUndoInfo(...e),this.loadCleanupData=(...e)=>this.commandSurfaceActions.loadCleanupData(...e),this.loadSteerData=(...e)=>this.commandSurfaceActions.loadSteerData(...e),this.executeUndoAction=(...e)=>this.commandSurfaceActions.executeUndoAction(...e),this.executeCleanupAction=(...e)=>this.commandSurfaceActions.executeCleanupAction(...e),this.resolveCaptureAction=(...e)=>this.commandSurfaceActions.resolveCaptureAction(...e),this.updateSessionBrowserState=(...e)=>this.commandSurfaceActions.updateSessionBrowserState(...e),this.loadSessionBrowser=(...e)=>this.commandSurfaceActions.loadSessionBrowser(...e),this.renameSessionFromSurface=(...e)=>this.commandSurfaceActions.renameSessionFromSurface(...e),this.loadAvailableModels=(...e)=>this.commandSurfaceActions.loadAvailableModels(...e),this.applyModelSelection=(...e)=>this.commandSurfaceActions.applyModelSelection(...e),this.applyThinkingLevel=(...e)=>this.commandSurfaceActions.applyThinkingLevel(...e),this.setSteeringModeFromSurface=(...e)=>this.commandSurfaceActions.setSteeringModeFromSurface(...e),this.setFollowUpModeFromSurface=(...e)=>this.commandSurfaceActions.setFollowUpModeFromSurface(...e),this.setAutoCompactionFromSurface=(...e)=>this.commandSurfaceActions.setAutoCompactionFromSurface(...e),this.setAutoRetryFromSurface=(...e)=>this.commandSurfaceActions.setAutoRetryFromSurface(...e),this.abortRetryFromSurface=(...e)=>this.commandSurfaceActions.abortRetryFromSurface(...e),this.switchSessionFromSurface=(...e)=>this.commandSurfaceActions.switchSessionFromSurface(...e),this.loadSessionStats=(...e)=>this.commandSurfaceActions.loadSessionStats(...e),this.exportSessionFromSurface=(...e)=>this.commandSurfaceActions.exportSessionFromSurface(...e),this.loadForkMessages=(...e)=>this.commandSurfaceActions.loadForkMessages(...e),this.forkSessionFromSurface=(...e)=>this.commandSurfaceActions.forkSessionFromSurface(...e),this.compactSessionFromSurface=(...e)=>this.commandSurfaceActions.compactSessionFromSurface(...e),this.saveApiKeyFromSurface=(...e)=>this.commandSurfaceActions.saveApiKeyFromSurface(...e),this.startProviderFlowFromSurface=(...e)=>this.commandSurfaceActions.startProviderFlowFromSurface(...e),this.submitProviderFlowInputFromSurface=(...e)=>this.commandSurfaceActions.submitProviderFlowInputFromSurface(...e),this.cancelProviderFlowFromSurface=(...e)=>this.commandSurfaceActions.cancelProviderFlowFromSurface(...e),this.logoutProviderFromSurface=(...e)=>this.commandSurfaceActions.logoutProviderFromSurface(...e),this.respondToUiRequest=async(e,t)=>{this.patchState({commandInFlight:"extension_ui_response"});try{let s=await (0,b.tm)(this.buildUrl("/api/session/command"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e,...t})});if(!s.ok){let e=await s.json().catch(()=>({error:`HTTP ${s.status}`}));throw Error(e.error??`extension_ui_response failed with ${s.status}`)}this.patchState({pendingUiRequests:this.state.pendingUiRequests.filter(t=>t.id!==e)})}catch(t){let e=M(t);this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`UI response failed — ${e}`))})}finally{this.patchState({commandInFlight:null})}},this.dismissUiRequest=async e=>{this.patchState({commandInFlight:"extension_ui_response"});try{let t=await (0,b.tm)(this.buildUrl("/api/session/command"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e,cancelled:!0})});if(!t.ok){let e=await t.json().catch(()=>({error:`HTTP ${t.status}`}));throw Error(e.error??`extension_ui_response cancel failed with ${t.status}`)}this.patchState({pendingUiRequests:this.state.pendingUiRequests.filter(t=>t.id!==e)})}catch(t){let e=M(t);this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`UI dismiss failed — ${e}`))})}finally{this.patchState({commandInFlight:null})}},this.sendSteer=async e=>{await this.sendCommand({type:"steer",message:e})},this.sendAbort=async()=>{await this.sendCommand({type:"abort"})},this.pushChatUserMessage=e=>{this.patchTranscript(t=>({...t,pendingUserMessage:e}))},this.submitInput=async(e,t)=>{let s=e.trim();if(!s)return null;let r=m(s,{isStreaming:this.state.boot?.bridge.sessionState?.isStreaming});if(this.patchState({lastSlashCommandOutcome:s.startsWith("/")?r:null}),"prompt"===r.kind){let e=this.state.boot?.bridge.sessionState,t=this.contextualTips.evaluate({input:s,isStreaming:!!e?.isStreaming,thinkingLevel:e?.thinkingLevel,contextPercent:void 0});t&&this.patchState({terminalLines:f(this.state.terminalLines,g("system",`💡 ${t}`))})}switch(r.kind){case"bash":return await this.sendCommand(r.command,{displayInput:s}),r;case"prompt":case"rpc":{let e=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType})),a=e&&e.length>0?{...r.command,images:e}:r.command;return await this.sendCommand(a,{displayInput:s}),r}case"local":if("clear_terminal"===r.action)return this.clearTerminalLines(),r;if("refresh_workspace"===r.action)return await this.refreshBoot(),r;return"gsd_help"===r.action&&this.patchState({terminalLines:f(f(this.state.terminalLines,g("input",s)),g("system",c))}),r;case"surface":{if(Z.has(r.surface))return this.patchState({terminalLines:f(this.state.terminalLines,g("input",s))}),this.openCommandSurface(r.surface,{source:"slash",args:r.args}),r;let e=h(r),t=f(this.state.terminalLines,g("input",s));return e&&(t=f(t,g(e.type,e.message))),this.patchState({terminalLines:t}),r}case"reject":{let e=h(r),t=f(this.state.terminalLines,g("input",s));return e&&(t=f(t,g(e.type,e.message))),this.patchState({terminalLines:t}),r}case"view-navigate":return this.patchState({terminalLines:f(this.state.terminalLines,g("system",`Navigating to ${r.view} view`))}),window.dispatchEvent(new CustomEvent("gsd:navigate-view",{detail:{view:r.view}})),r}},this.refreshBoot=async(e={})=>{if(this.bootPromise)return await this.bootPromise;this.lastBootRefreshAt=Date.now();let t=!!(e.soft&&this.state.boot);this.bootPromise=(async()=>{t?this.patchState({lastClientError:null}):this.patchState({bootStatus:"loading",connectionState:"connected"===this.state.connectionState?"connected":"connecting",lastClientError:null});try{let e=await (0,b.tm)(this.buildUrl("/api/boot"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}});if(!e.ok){if(401===e.status)return void this.patchState({bootStatus:"unauthenticated",connectionState:"error"});throw Error(`Boot request failed with ${e.status}`)}let s=await e.json(),r=H(s,s.bridge)??s,a=function(e,t,s={}){let r={...e,auto:A(e.auto,t.auto),workspace:A(e.workspace,t.workspace),resumableSessions:A(e.resumableSessions,t.resumableSessions),freshness:{...e.freshness,recovery:$(e.freshness.recovery)},softBootRefreshCount:e.softBootRefreshCount+ +!!s.soft};return r.recoverySummary=L({boot:t,live:r}),r}(this.state.live,r,{soft:t});this.lastBridgeDigest=null,this.lastBridgeDigest=[r.bridge.phase,r.bridge.activeSessionId,r.bridge.lastError?.at,r.bridge.lastError?.message].join("::"),this.patchState({bootStatus:"ready",boot:r,live:a,connectionState:r.onboarding.locked?"idle":this.eventStream.isOpen()?this.state.connectionState:"connecting",lastBridgeError:r.bridge.lastError,sessionAttached:Q(r.bridge),lastClientError:null,...t?{}:{terminalLines:en(r)}}),r.onboarding.locked?this.closeEventStream():this.ensureEventStream()}catch(s){let e=M(s);if(t)return void this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Workspace refresh failed — ${e}`))});this.patchState({bootStatus:"error",connectionState:"error",lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Boot failed — ${e}`))})}})().finally(()=>{this.bootPromise=null}),await this.bootPromise},this.refreshOnboarding=async()=>{this.patchState({onboardingRequestState:"refreshing",onboardingRequestProviderId:null,lastClientError:null});try{return await this.fetchOnboardingState()}catch(t){let e=M(t);return this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Onboarding refresh failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.saveApiKey=async(e,t)=>{this.patchState({onboardingRequestState:"saving_api_key",onboardingRequestProviderId:e,lastClientError:null});try{let s=await this.postOnboardingAction({action:"save_api_key",providerId:e,apiKey:t});return await this.syncAfterOnboardingMutation(s),s}catch(t){let e=M(t);return this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Credential setup failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.startProviderFlow=async e=>{this.patchState({onboardingRequestState:"starting_provider_flow",onboardingRequestProviderId:e,lastClientError:null});try{let t=await this.postOnboardingAction({action:"start_provider_flow",providerId:e});return await this.syncAfterOnboardingMutation(t),t}catch(t){let e=M(t);return this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Provider sign-in failed to start — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.submitProviderFlowInput=async(e,t)=>{this.patchState({onboardingRequestState:"submitting_provider_flow_input",onboardingRequestProviderId:this.state.boot?.onboarding.activeFlow?.providerId??null,lastClientError:null});try{let s=await this.postOnboardingAction({action:"continue_provider_flow",flowId:e,input:t});return await this.syncAfterOnboardingMutation(s),s}catch(t){let e=M(t);return this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Provider sign-in input failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.cancelProviderFlow=async e=>{this.patchState({onboardingRequestState:"cancelling_provider_flow",onboardingRequestProviderId:this.state.boot?.onboarding.activeFlow?.providerId??null,lastClientError:null});try{let t=await this.postOnboardingAction({action:"cancel_provider_flow",flowId:e});return await this.syncAfterOnboardingMutation(t),t}catch(t){let e=M(t);return this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Provider sign-in cancellation failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.logoutProvider=async e=>{this.patchState({onboardingRequestState:"logging_out_provider",onboardingRequestProviderId:e,lastClientError:null});try{let t=await this.postOnboardingAction({action:"logout_provider",providerId:e});return await this.syncAfterOnboardingMutation(t),t}catch(t){let e=M(t);return this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Provider logout failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.sendCommand=async(e,t={})=>{this.clearCommandTimeout();let s={commandInFlight:e.type};!1!==t.appendInputLine&&(s.terminalLines=f(this.state.terminalLines,g("input",t.displayInput??("string"==typeof e.message?e.message:`/${e.type}`)))),this.patchState(s),this.commandTimeoutTimer=setTimeout(()=>{this.state.commandInFlight&&this.patchState({commandInFlight:null,lastClientError:"Command timed out — controls re-enabled",terminalLines:f(this.state.terminalLines,g("error","Command timed out — controls re-enabled"))})},9e4);try{let s=await (0,b.tm)(this.buildUrl("/api/session/command"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await s.json();if("ok"in r)return null;if("get_state"===r.command&&r.success&&this.state.boot){let e={...this.state.boot.bridge,sessionState:r.data,activeSessionId:r.data.sessionId,activeSessionFile:r.data.sessionFile??this.state.boot.bridge.activeSessionFile,lastCommandType:"get_state",updatedAt:new Date().toISOString()};this.patchState({boot:H(this.state.boot,e),lastBridgeError:e.lastError,sessionAttached:Q(e)})}return"new_session"===r.command&&r.success&&this.contextualTips.reset(),"onboarding_locked"===r.code&&r.details?.onboarding&&this.state.boot&&this.patchState({boot:function(e,t){var s;return e?er(e,(s=e.onboarding,{...s,...t,required:{...s.required,...t.required??{},providers:t.required?.providers??s.required.providers},optional:{...s.optional,...t.optional??{},sections:t.optional?.sections??s.optional.sections},bridgeAuthRefresh:{...s.bridgeAuthRefresh,...t.bridgeAuthRefresh??{}}})):null}(this.state.boot,r.details.onboarding)}),this.patchState({...!1===t.appendResponseLine?{}:{terminalLines:f(this.state.terminalLines,function(e){if(!e.success)return g("error",`Command failed (${e.command}) — ${e.error??"unknown error"}`);switch(e.command){case"get_state":return g("success","Session state refreshed");case"new_session":return g("success","Started a new session");case"prompt":return g("success","Prompt accepted by the live bridge");case"follow_up":return g("success","Follow-up queued on the live bridge");case"bash":{let t=e.data;if(t?.output?.trim())return g("output",t.output.trimEnd());if(t?.cancelled)return g("system","Bash command cancelled");let s=t?.exitCode??0;return g(0===s?"success":"error",0===s?"Bash command completed":`Bash command exited with code ${s}`)}default:return g("success",`Command accepted (${e.command})`)}}(r))},lastBridgeError:r.success?this.state.lastBridgeError:this.state.boot?.bridge.lastError??this.state.lastBridgeError}),r}catch(s){let t=M(s);return this.patchState({lastClientError:t,terminalLines:f(this.state.terminalLines,g("error",`Command failed (${e.type}) — ${t}`))}),{type:"response",command:e.type,success:!1,error:t}}finally{this.clearCommandTimeout(),this.patchState({commandInFlight:null})}},this.flushEmit=()=>{this.emitScheduled=!1,this.emitFrame=null,this.emitTimer=null,this.disposed||this.emit()},this.commandSurfaceActions=new J({getState:()=>this.state,patchState:e=>this.patchState(e),buildUrl:e=>this.buildUrl(e),sendCommand:(e,t)=>this.sendCommand(e,t),refreshBoot:e=>this.refreshBoot(e),refreshOnboarding:()=>this.refreshOnboarding(),logoutProvider:e=>this.logoutProvider(e),saveApiKey:(e,t)=>this.saveApiKey(e,t),startProviderFlow:e=>this.startProviderFlow(e),submitProviderFlowInput:(e,t)=>this.submitProviderFlowInput(e,t),cancelProviderFlow:e=>this.cancelProviderFlow(e)})}buildUrl(e){return eb(e,this.projectCwd)}async refreshBootAfterCurrentSettles(e={}){if(this.bootPromise)try{await this.bootPromise}catch{}await this.refreshBoot(e)}invalidateLiveFreshness(e,t,s){let r={...this.state.live,freshness:{...this.state.live.freshness}};return e.includes("auto")&&(r.auto=C(r.auto,t,s)),e.includes("workspace")&&(r.workspace=C(r.workspace,t,s),r.freshness.gitSummary=I(r.freshness.gitSummary,t,s)),e.includes("recovery")&&(r.freshness.recovery=I(r.freshness.recovery,t,s),r.freshness.sessionStats=I(r.freshness.sessionStats,t,s)),e.includes("resumable_sessions")&&(r.resumableSessions=C(r.resumableSessions,t,s),r.freshness.sessionBrowser=I(r.freshness.sessionBrowser,t,s),r.freshness.sessionStats=I(r.freshness.sessionStats,t,s)),{...r,recoverySummary:L({boot:this.state.boot,live:r})}}refreshOpenCommandSurfacesForInvalidation(e){!function(e,t,s){if(s.domains.includes("workspace")&&e.getState().commandSurface.open&&"git"===e.getState().commandSurface.section&&"load_git_summary"!==e.getState().commandSurface.pendingAction&&t.loadGitSummary(),s.domains.includes("recovery")&&e.getState().commandSurface.open&&"recovery"===e.getState().commandSurface.section&&"load_recovery_diagnostics"!==e.getState().commandSurface.pendingAction&&t.loadRecoveryDiagnostics(),s.domains.includes("resumable_sessions")&&(e.getState().commandSurface.open&&("resume"===e.getState().commandSurface.section||"name"===e.getState().commandSurface.section)&&"load_session_browser"!==e.getState().commandSurface.pendingAction&&t.loadSessionBrowser(),e.getState().commandSurface.open&&"session"===e.getState().commandSurface.section)){let s=e.getState().boot?.bridge.activeSessionFile??e.getState().boot?.bridge.sessionState?.sessionFile??null,r=e.getState().commandSurface,a=r.sessionStats;e.patchState({commandSurface:{...r,sessionStats:a&&a.sessionFile===s?a:null}}),"load_session_stats"!==e.getState().commandSurface.pendingAction&&t.loadSessionStats()}}({getState:()=>this.state,patchState:e=>this.patchState(e),buildUrl:e=>this.buildUrl(e),sendCommand:(e,t)=>this.sendCommand(e,t),refreshBoot:e=>this.refreshBoot(e),refreshOnboarding:()=>this.refreshOnboarding(),logoutProvider:e=>this.logoutProvider(e),saveApiKey:(e,t)=>this.saveApiKey(e,t),startProviderFlow:e=>this.startProviderFlow(e),submitProviderFlowInput:(e,t)=>this.submitProviderFlowInput(e,t),cancelProviderFlow:e=>this.cancelProviderFlow(e)},this.commandSurfaceActions,e)}async reloadLiveState(e,t){let s=e.filter(e=>"auto"===e||"workspace"===e||"resumable_sessions"===e);if(0===s.length){if(e.includes("recovery"))return void await this.refreshBoot({soft:!0});let t={...this.state.live,freshness:{...this.state.live.freshness,recovery:$(this.state.live.freshness.recovery)}};return void this.patchState({live:{...t,recoverySummary:L({boot:this.state.boot,live:t})}})}let r={...this.state.live.freshness},a=this.state.live.auto,n=this.state.live.workspace,i=this.state.live.resumableSessions;s.includes("auto")&&(a=k(a)),s.includes("workspace")&&(n=k(n)),s.includes("resumable_sessions")&&(i=k(i)),r.recovery=F(r.recovery);let o={...this.state.live,auto:a,workspace:n,resumableSessions:i,freshness:r,targetedRefreshCount:this.state.live.targetedRefreshCount+1};this.patchState({live:{...o,recoverySummary:L({boot:this.state.boot,live:o})}});let l=new URLSearchParams;for(let e of s)l.append("domain",e);try{let e=await (0,b.tm)(this.buildUrl(`/api/live-state?${l.toString()}`),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t)throw Error(t?.error??`Live state request failed with ${e.status}`);let r=this.state.boot,a={...this.state.live,freshness:{...this.state.live.freshness}};if(s.includes("auto")&&t.auto&&(a.auto=A(a.auto,t.auto),r=r?{...r,auto:t.auto}:r),s.includes("workspace")&&t.workspace&&(a.workspace=A(a.workspace,t.workspace),r=r?{...r,workspace:t.workspace}:r),s.includes("resumable_sessions")&&t.resumableSessions){let e=W(t.resumableSessions,r);a.resumableSessions=A(a.resumableSessions,e),r=r?{...r,resumableSessions:e}:r}a.freshness.recovery=$(a.freshness.recovery),a.recoverySummary=L({boot:r,live:a}),this.patchState({...r?{boot:r}:{},live:a})}catch(a){let e=M(a),r={...this.state.live,auto:s.includes("auto")?T(this.state.live.auto,e):this.state.live.auto,workspace:s.includes("workspace")?T(this.state.live.workspace,e):this.state.live.workspace,resumableSessions:s.includes("resumable_sessions")?T(this.state.live.resumableSessions,e):this.state.live.resumableSessions,freshness:{...this.state.live.freshness,recovery:D(this.state.live.freshness.recovery,e)}};this.patchState({lastClientError:e,live:{...r,recoverySummary:L({boot:this.state.boot,live:r})},terminalLines:f(this.state.terminalLines,g("error",`Live refresh failed (${t}) — ${e}`))})}}handleLiveStateInvalidation(e){var t;this.patchState({live:this.invalidateLiveFreshness(e.domains,e.reason,e.source),commandSurface:e.domains.includes("recovery")?{...this.state.commandSurface,recovery:(t=this.state.commandSurface.recovery).loaded||t.error?{...t,stale:!0,lastInvalidatedAt:new Date().toISOString()}:t}:this.state.commandSurface}),this.refreshOpenCommandSurfacesForInvalidation(e),this.reloadLiveState(e.domains,e.reason)}clearCommandTimeout(){this.commandTimeoutTimer&&(clearTimeout(this.commandTimeoutTimer),this.commandTimeoutTimer=null)}async fetchOnboardingState(e=!1){let t=this.state.boot?.onboarding.activeFlow?.status??null,s=await (0,b.tm)(this.buildUrl("/api/onboarding"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),r=await s.json();if(!s.ok||!r.onboarding)throw Error(r.error??`Onboarding request failed with ${s.status}`);return this.applyOnboardingState(r.onboarding),t&&et.has(t)&&r.onboarding.activeFlow&&es.has(r.onboarding.activeFlow.status)?await this.syncAfterOnboardingMutation(r.onboarding):e||this.appendOnboardingSummaryLine(r.onboarding),r.onboarding}async postOnboardingAction(e){let t=await (0,b.tm)(this.buildUrl("/api/onboarding"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok)throw s.onboarding&&this.applyOnboardingState(s.onboarding),Error(s.error??`Onboarding action failed with ${t.status}`);if(!s.onboarding)throw Error(`Onboarding action returned no state (${t.status})`);return this.applyOnboardingState(s.onboarding),s.onboarding}applyOnboardingState(e){this.state.boot&&this.patchState({boot:er(this.state.boot,e)})}async syncAfterOnboardingMutation(e){this.applyOnboardingState(e),this.appendOnboardingSummaryLine(e),(e.lastValidation?.status==="succeeded"||"idle"!==e.bridgeAuthRefresh.phase)&&this.refreshBootAfterCurrentSettles({soft:!0})}appendOnboardingSummaryLine(e){let t=ea(e);if(!t)return;let s=this.state.terminalLines.at(-1);(s?.type!==t.type||s.content!==t.message)&&this.patchState({terminalLines:f(this.state.terminalLines,g(t.type,t.message))})}emit(){for(let e of this.listeners)e()}scheduleEmit(){if(!this.emitScheduled&&0!==this.listeners.size){if(this.emitScheduled=!0,"function"==typeof requestAnimationFrame){this.emitFrame=requestAnimationFrame(this.flushEmit);return}this.emitTimer=setTimeout(this.flushEmit,0)}}cancelScheduledEmit(){this.emitScheduled&&(null!==this.emitFrame&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this.emitFrame),null!==this.emitTimer&&clearTimeout(this.emitTimer),this.emitScheduled=!1,this.emitFrame=null,this.emitTimer=null)}patchTranscript(e){var t;let s=e({completedTurns:(t=this.state).completedTurns,pendingUserMessage:t.pendingUserMessage,currentTurnSegments:t.currentTurnSegments,streamingAssistantText:t.streamingAssistantText,streamingThinkingText:t.streamingThinkingText});this.patchState({completedTurns:s.completedTurns,pendingUserMessage:s.pendingUserMessage,currentTurnSegments:s.currentTurnSegments,streamingAssistantText:s.streamingAssistantText,streamingThinkingText:s.streamingThinkingText})}patchState(e){this.state={...this.state,...e},this.syncOnboardingPoller(),this.scheduleEmit()}syncOnboardingPoller(){if(this.disposed)return void this.stopOnboardingPoller();let e=this.state.boot?.onboarding.activeFlow?.status,t=!!(e&&et.has(e));if(t&&!this.onboardingPollTimer){this.onboardingPollTimer=setInterval(()=>{"idle"===this.state.onboardingRequestState&&this.fetchOnboardingState(!0).catch(e=>{let t=M(e);this.patchState({lastClientError:t})})},1500);return}t||this.stopOnboardingPoller()}stopOnboardingPoller(){this.onboardingPollTimer&&(clearInterval(this.onboardingPollTimer),this.onboardingPollTimer=null)}ensureEventStream(){this.eventStream.ensure()}closeEventStream(){this.eventStream.close()}handleEventStreamOpen(e){e&&this.patchState({terminalLines:f(this.state.terminalLines,g("success","Live event stream reconnected"))}),this.patchState({connectionState:"connected",lastClientError:null}),e&&this.refreshBoot({soft:!0})}handleEventStreamMessage(e){try{let t=JSON.parse(e);if(null===t||"object"!=typeof t||"string"!=typeof t.type)return void this.patchState({lastClientError:"Malformed event received from stream",terminalLines:f(this.state.terminalLines,g("error","Malformed event received from stream"))});this.handleEvent(t)}catch(t){let e=M(t);this.patchState({lastClientError:e,terminalLines:f(this.state.terminalLines,g("error",`Failed to parse stream event — ${e}`))})}}handleEventStreamError(e,t){t?this.patchState({connectionState:e,terminalLines:f(this.state.terminalLines,g("reconnecting"===e?"system":"error","reconnecting"===e?"Live event stream disconnected — retrying…":"Live event stream failed before connection was established"))}):this.patchState({connectionState:e})}handleEvent(e){!function(e,t,s){if(t.onLastEventType(e.type),"bridge_status"===e.type)return t.onBridgeStatus(e);"live_state_invalidation"===e.type&&t.onLiveStateInvalidation(e),t.onLiveInteraction(e);let r=s(e);r&&t.onTerminalSummary(r)}(e,{onLastEventType:e=>this.patchState({lastEventType:e}),onBridgeStatus:e=>this.recordBridgeStatus(e.bridge),onLiveStateInvalidation:e=>this.handleLiveStateInvalidation(e),onLiveInteraction:e=>this.routeLiveInteractionEvent(e),onTerminalSummary:e=>{this.patchState({terminalLines:f(this.state.terminalLines,g(e.type,e.message))})}},ee)}routeLiveInteractionEvent(e){if("extension_ui_snapshot"===e.type)return void this.handleExtensionUiSnapshot(e.snapshot);var t=e=>this.handleExtensionUiRequest(e),s=e=>this.handleMessageUpdate(e),r=()=>this.handleTurnBoundary(),a=e=>this.handleToolExecutionStart(e),n=e=>this.handleToolExecutionUpdate(e),i=e=>this.handleToolExecutionEnd(e);switch(e.type){case"extension_ui_request":t(e);break;case"message_update":s(e);break;case"agent_end":case"turn_end":r();break;case"tool_execution_start":a(e);break;case"tool_execution_update":n(e);break;case"tool_execution_end":i(e)}}handleExtensionUiSnapshot(e){let t=function(e,t){let s={};for(let[e,r]of Object.entries(t.widgetsByKey)){let t=Array.isArray(r.content)?r.content:"string"==typeof r.content?[r.content]:void 0;s[e]={lines:t,placement:r.options?.placement}}return{statusTexts:{...t.statusByKey},widgetContents:s,titleOverride:t.title?.trim()?t.title:null,editorTextBuffer:t.editorText??null,workingMessage:t.workingMessage}}((this.state.statusTexts,this.state.widgetContents,this.state.titleOverride,this.state.editorTextBuffer,this.state.workingMessage),e);this.patchState({statusTexts:t.statusTexts,widgetContents:t.widgetContents,titleOverride:t.titleOverride,editorTextBuffer:t.editorTextBuffer,workingMessage:t.workingMessage??null})}getExtensionUiSnapshot(){var e={statusTexts:this.state.statusTexts,widgetContents:this.state.widgetContents,titleOverride:this.state.titleOverride,editorTextBuffer:this.state.editorTextBuffer,workingMessage:this.state.workingMessage};let t={};for(let[s,r]of Object.entries(e.widgetContents))t[s]={content:r.lines,options:r.placement?{placement:r.placement}:void 0};return{statusByKey:{...e.statusTexts},widgetsByKey:t,workingMessage:e.workingMessage,title:e.titleOverride??void 0,editorText:e.editorTextBuffer??void 0,hasCustomHeader:!1,hasCustomFooter:!1}}handleExtensionUiRequest(e){switch(e.method){case"select":case"confirm":case"input":case"editor":this.patchState({pendingUiRequests:[...this.state.pendingUiRequests,e]});break;case"notify":break;case"setStatus":if("setStatus"===e.method){let t={...this.state.statusTexts};void 0===e.statusText?delete t[e.statusKey]:t[e.statusKey]=e.statusText,this.patchState({statusTexts:t})}break;case"setWidget":if("setWidget"===e.method){let t={...this.state.widgetContents};void 0===e.widgetLines?delete t[e.widgetKey]:t[e.widgetKey]={lines:e.widgetLines,placement:e.widgetPlacement},this.patchState({widgetContents:t})}break;case"setTitle":if("setTitle"===e.method){let t=e.title.trim();this.patchState({titleOverride:t||null})}break;case"set_editor_text":"set_editor_text"===e.method&&this.patchState({editorTextBuffer:e.text})}}handleMessageUpdate(e){let t=e.assistantMessageEvent;t&&("text_delta"===t.type&&"string"==typeof t.delta?this.patchTranscript(e=>{var s;return s=t.delta,e.streamingThinkingText.length>0?{...e,currentTurnSegments:[...e.currentTurnSegments,{kind:"thinking",content:e.streamingThinkingText}],streamingThinkingText:"",streamingAssistantText:e.streamingAssistantText+s}:{...e,streamingAssistantText:e.streamingAssistantText+s}}):"thinking_delta"===t.type&&"string"==typeof t.delta?this.patchTranscript(e=>{var s;return s=t.delta,e.streamingAssistantText.length>0?{...e,currentTurnSegments:[...e.currentTurnSegments,{kind:"text",content:e.streamingAssistantText}],streamingAssistantText:"",streamingThinkingText:e.streamingThinkingText+s}:{...e,streamingThinkingText:e.streamingThinkingText+s}}):"thinking_end"===t.type&&this.patchTranscript(e=>0===e.streamingThinkingText.length?e:{...e,currentTurnSegments:[...e.currentTurnSegments,{kind:"thinking",content:e.streamingThinkingText}],streamingThinkingText:""}))}handleTurnBoundary(){this.patchTranscript(e=>(function(e){let t=[];e.streamingThinkingText.length>0&&t.push({kind:"thinking",content:e.streamingThinkingText}),e.streamingAssistantText.length>0&&t.push({kind:"text",content:e.streamingAssistantText});let s=t.length>0?[...e.currentTurnSegments,...t]:e.currentTurnSegments;if(0===s.filter(e=>"text"===e.kind).map(e=>e.content).join("").length&&0===s.length)return{...e,pendingUserMessage:null,streamingThinkingText:"",streamingAssistantText:"",currentTurnSegments:[]};let r=[...e.completedTurns,{userMessage:e.pendingUserMessage??void 0,segments:s}],a=r.length>100?r.length-100:0;return{completedTurns:a>0?r.slice(a):r,pendingUserMessage:null,currentTurnSegments:[],streamingAssistantText:"",streamingThinkingText:""}})(e)),this.patchState({completedToolExecutions:[]})}handleToolExecutionStart(e){this.patchState({activeToolExecution:{id:e.toolCallId,name:e.toolName,args:e.args},streamingAssistantText:"",streamingThinkingText:""})}handleToolExecutionUpdate(e){let t=this.state.activeToolExecution;t&&t.id===e.toolCallId&&this.patchState({activeToolExecution:{...t,result:e.partialResult?{content:e.partialResult.content,details:e.partialResult.details,isError:!!e.partialResult.isError}:t.result}})}handleToolExecutionEnd(e){let t=this.state.activeToolExecution;if(t){let s={id:t.id,name:t.name,args:t.args??{},result:{content:e.result?.content,details:e.result?.details,isError:e.isError}},r=[...this.state.completedToolExecutions,s];this.patchState({activeToolExecution:null,completedToolExecutions:r.length>50?r.slice(r.length-50):r}),this.patchTranscript(e=>({...e,currentTurnSegments:[...e.currentTurnSegments,{kind:"tool",tool:s}]}))}else this.patchState({activeToolExecution:null})}recordBridgeStatus(e){let t=[e.phase,e.activeSessionId,e.lastError?.at,e.lastError?.message].join("::"),s=t!==this.lastBridgeDigest;this.lastBridgeDigest=t;let r=H(this.state.boot,e),a=W(E(this.state),r),n={...this.state.live,resumableSessions:A(this.state.live.resumableSessions,a)},i={...n,recoverySummary:L({boot:r,live:n})},o={boot:r,live:i,lastBridgeError:e.lastError,sessionAttached:Q(e),commandSurface:{...this.state.commandSurface,sessionBrowser:K(this.state.commandSurface.sessionBrowser,r)}};if(s){let t=X(e);o.terminalLines=f(this.state.terminalLines,g(t.type,t.message))}this.patchState(o)}}let ej=(0,a.createContext)(null);function ey({children:e,store:t}){let[s]=(0,a.useState)(()=>new ev),n=t??s;return(0,a.useEffect)(()=>{if(!t)return n.start(),()=>n.dispose()},[n,t]),(0,r.jsx)(ej.Provider,{value:n,children:e})}function ew(){let e=(0,a.useContext)(ej);if(!e)throw Error("useWorkspaceStore must be used within GSDWorkspaceProvider");return e}function eN(){let e=ew();return(0,a.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}function eS(){let e=ew();return{sendCommand:e.sendCommand,submitInput:e.submitInput,clearTerminalLines:e.clearTerminalLines,consumeEditorTextBuffer:e.consumeEditorTextBuffer,refreshBoot:e.refreshBoot,refreshOnboarding:e.refreshOnboarding,openCommandSurface:e.openCommandSurface,closeCommandSurface:e.closeCommandSurface,setCommandSurfaceSection:e.setCommandSurfaceSection,selectCommandSurfaceTarget:e.selectCommandSurfaceTarget,loadGitSummary:e.loadGitSummary,loadRecoveryDiagnostics:e.loadRecoveryDiagnostics,loadForensicsDiagnostics:e.loadForensicsDiagnostics,loadDoctorDiagnostics:e.loadDoctorDiagnostics,applyDoctorFixes:e.applyDoctorFixes,loadSkillHealthDiagnostics:e.loadSkillHealthDiagnostics,loadKnowledgeData:e.loadKnowledgeData,loadCapturesData:e.loadCapturesData,loadSettingsData:e.loadSettingsData,loadHistoryData:e.loadHistoryData,loadInspectData:e.loadInspectData,loadHooksData:e.loadHooksData,loadExportData:e.loadExportData,loadUndoInfo:e.loadUndoInfo,loadCleanupData:e.loadCleanupData,loadSteerData:e.loadSteerData,executeUndoAction:e.executeUndoAction,executeCleanupAction:e.executeCleanupAction,resolveCaptureAction:e.resolveCaptureAction,updateSessionBrowserState:e.updateSessionBrowserState,loadSessionBrowser:e.loadSessionBrowser,renameSessionFromSurface:e.renameSessionFromSurface,loadAvailableModels:e.loadAvailableModels,applyModelSelection:e.applyModelSelection,applyThinkingLevel:e.applyThinkingLevel,setSteeringModeFromSurface:e.setSteeringModeFromSurface,setFollowUpModeFromSurface:e.setFollowUpModeFromSurface,setAutoCompactionFromSurface:e.setAutoCompactionFromSurface,setAutoRetryFromSurface:e.setAutoRetryFromSurface,abortRetryFromSurface:e.abortRetryFromSurface,switchSessionFromSurface:e.switchSessionFromSurface,loadSessionStats:e.loadSessionStats,exportSessionFromSurface:e.exportSessionFromSurface,loadForkMessages:e.loadForkMessages,forkSessionFromSurface:e.forkSessionFromSurface,compactSessionFromSurface:e.compactSessionFromSurface,saveApiKey:e.saveApiKey,saveApiKeyFromSurface:e.saveApiKeyFromSurface,startProviderFlow:e.startProviderFlow,startProviderFlowFromSurface:e.startProviderFlowFromSurface,submitProviderFlowInput:e.submitProviderFlowInput,submitProviderFlowInputFromSurface:e.submitProviderFlowInputFromSurface,cancelProviderFlow:e.cancelProviderFlow,cancelProviderFlowFromSurface:e.cancelProviderFlowFromSurface,logoutProvider:e.logoutProvider,logoutProviderFromSurface:e.logoutProviderFromSurface,respondToUiRequest:e.respondToUiRequest,dismissUiRequest:e.dismissUiRequest,sendSteer:e.sendSteer,sendAbort:e.sendAbort,pushChatUserMessage:e.pushChatUserMessage}}function ek(e,t){let s=m(e,{isStreaming:t?.sessionState?.isStreaming});if("prompt"===s.kind||"rpc"===s.kind)return s.command;throw Error(`buildPromptCommand cannot serialize ${s.input||e} because browser dispatch resolved it to ${s.kind}; use submitInput() instead.`)}},69745:(e,t,s)=>{s.d(t,{Aw:()=>l,Wl:()=>n,wN:()=>a,zF:()=>o});let r=new Set(["image/jpeg","image/png","image/gif","image/webp"]),a=5;function n(e){if(!r.has(e.type)){let t=`Unsupported image type: ${e.type||"unknown"}. Accepted: JPEG, PNG, GIF, WebP.`;return console.warn("[image-utils] validation failed:",t),{valid:!1,error:t}}if(e.size>0x1400000){let t=(e.size/1048576).toFixed(1),s=`Image too large (${t} MB). Maximum: 20 MB.`;return console.warn("[image-utils] validation failed:",s),{valid:!1,error:s}}return{valid:!0}}async function i(e,t){var s,r;let a=.75*e.length;if(("image/gif"===t||"image/webp"===t)&&a<=4718592)return{data:e,mimeType:t};let n=await (s=e,r=t,new Promise((e,t)=>{let a=new Image;a.onload=()=>e(a),a.onerror=()=>t(Error("Failed to decode image")),a.src=`data:${r};base64,${s}`})),i=n.width>2e3||n.height>2e3;if(!i&&!(a>4718592))return{data:e,mimeType:t};let o="image/gif"===t||"image/webp"===t?"image/jpeg":t,l=n.width,d=n.height;if(i){let e=Math.min(2e3/n.width,2e3/n.height);l=Math.round(n.width*e),d=Math.round(n.height*e)}let c=document.createElement("canvas");c.width=l,c.height=d;let u=c.getContext("2d");if(!u)throw Error("Canvas 2D context not available");u.drawImage(n,0,0,l,d);let m=c.toDataURL(o,"image/jpeg"===o?.85:void 0).split(",")[1],h=.75*m.length;if(h>4718592)throw Error(`Image still exceeds 4.5 MB after resize (${(h/1048576).toFixed(1)} MB). Try a smaller image.`);return{data:m,mimeType:o}}async function o(e){let t=n(e);if(!t.valid)throw Error(t.error);return i(await new Promise((t,s)=>{let r=new FileReader;r.onload=()=>{let e=new Uint8Array(r.result),s="";for(let t=0;t<e.length;t++)s+=String.fromCharCode(e[t]);t(btoa(s))},r.onerror=()=>s(Error("Failed to read image file")),r.readAsArrayBuffer(e)}),e.type)}function l(){return`img-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}},72202:(e,t,s)=>{s.d(t,{A:()=>i});var r=s(45110);let a="gsd-terminal-font-size",n="terminal-font-size-changed";function i(){let[e,t]=(0,r.useState)(()=>{try{let e=localStorage.getItem(a);if(e){let t=Number(e);if(Number.isFinite(t)&&t>=8&&t<=24)return t}}catch{}return 13}),s=(0,r.useCallback)(e=>{let s=Math.max(8,Math.min(24,Math.round(e)));t(s);try{localStorage.setItem(a,String(s))}catch{}window.dispatchEvent(new CustomEvent(n,{detail:s}))},[]);return(0,r.useEffect)(()=>{let e=e=>{if(e.key!==a)return;let s=Number(e.newValue);Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,r.useEffect)(()=>{let e=e=>{let s=e.detail;Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener(n,e),()=>window.removeEventListener(n,e)},[]),[e,s]}},78300:(e,t,s)=>{function r(e){let t=Number(e)||0;return t<.01?`$${t.toFixed(4)}`:t<1?`$${t.toFixed(3)}`:`$${t.toFixed(2)}`}function a(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}K`:`${(e/1e6).toFixed(2)}M`}function n(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60),r=t%60;if(s<60)return r>0?`${s}m ${r}s`:`${s}m`;let a=Math.floor(s/60),n=s%60;return n>0?`${a}h ${n}m`:`${a}h`}function i(e){let t={pending:0,triaged:0,resolved:0};for(let s of e.entries)t[s.status]+=1;return t}s.d(t,{BD:()=>r,a3:()=>n,ap:()=>a,vX:()=>i})},81462:(e,t,s)=>{s.d(t,{E:()=>o,d:()=>l});let r={background:"#18181e",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#18181e",selectionBackground:"#2a2f3f",selectionForeground:"#e4e4e7",black:"#1e1e24",red:"#cc6666",green:"#b5bd68",yellow:"#e6b800",blue:"#5f87ff",magenta:"#9575cd",cyan:"#00d7ff",white:"#e4e4e7",brightBlack:"#666666",brightRed:"#e07b7b",brightGreen:"#c3cf79",brightYellow:"#f0c95a",brightBlue:"#81a2ff",brightMagenta:"#b294bb",brightCyan:"#53e5ff",brightWhite:"#fafafa"},a={background:"#05070f",foreground:"#e6edf3",cursor:"#e6edf3",cursorAccent:"#05070f",selectionBackground:"#1b2440",selectionForeground:"#e6edf3",black:"#111827",red:"#ff6b8a",green:"#34d399",yellow:"#ffd166",blue:"#4f8cff",magenta:"#d266ff",cyan:"#22d3ee",white:"#e6edf3",brightBlack:"#64748b",brightRed:"#ff8fab",brightGreen:"#4ade80",brightYellow:"#ffe08a",brightBlue:"#82b1ff",brightMagenta:"#e29bff",brightCyan:"#67e8f9",brightWhite:"#ffffff"},n={background:"#f5f5f5",foreground:"#18181b",cursor:"#18181b",cursorAccent:"#f5f5f5",selectionBackground:"#d4d4d8",selectionForeground:"#18181b",black:"#18181b",red:"#b91c1c",green:"#166534",yellow:"#854d0e",blue:"#1d4ed8",magenta:"#7e22ce",cyan:"#0f766e",white:"#52525b",brightBlack:"#71717a",brightRed:"#dc2626",brightGreen:"#15803d",brightYellow:"#713f12",brightBlue:"#2563eb",brightMagenta:"#9333ea",brightCyan:"#0f766e",brightWhite:"#27272a"},i={background:"#f8fafc",foreground:"#0f172a",cursor:"#0f172a",cursorAccent:"#f8fafc",selectionBackground:"#cbd5e1",selectionForeground:"#0f172a",black:"#0f172a",red:"#be123c",green:"#166534",yellow:"#92400e",blue:"#1d4ed8",magenta:"#7e22ce",cyan:"#0f766e",white:"#334155",brightBlack:"#475569",brightRed:"#e11d48",brightGreen:"#15803d",brightYellow:"#854d0e",brightBlue:"#2563eb",brightMagenta:"#9333ea",brightCyan:"#0e7490",brightWhite:"#1e293b"};function o(e,t="classic"){return"vivid"===t?e?a:i:e?r:n}function l(e,t,s="classic"){return{cursorBlink:!0,cursorStyle:"bar",fontSize:t??13,fontFamily:"'SF Mono', 'Cascadia Code', 'Fira Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.35,letterSpacing:0,theme:o(e,s),allowProposedApi:!0,scrollback:1e4,convertEol:!1}}},83890:(e,t,s)=>{s.d(t,{QT:()=>o,c4:()=>n,tm:()=>i});let r="gsd-auth-token",a=null;function n(){if(null!==a)return a;let e=window.location.hash;if(e){let t=e.match(/token=([a-fA-F0-9]+)/);if(t){a=t[1];try{localStorage.setItem(r,a)}catch{}return window.history.replaceState(null,"",window.location.pathname+window.location.search),a}}try{let e=localStorage.getItem(r);if(e)return a=e}catch{}return null}async function i(e,t){let s=n(),r=new Headers(t?.headers);return s&&!r.has("Authorization")&&r.set("Authorization",`Bearer ${s}`),fetch(e,{...t,headers:r})}function o(e){let t=n();if(!t)return e;let s=e.includes("?")?"&":"?";return`${e}${s}_token=${t}`}window.addEventListener("storage",e=>{e.key===r&&e.newValue&&(a=e.newValue)})},94002:(e,t,s)=>{function r(e,t){return t<=0?-1:Math.max(0,Math.min(t-1,e))}function a(e,t,s){if(s<=0)return{type:"none"};let a=function(e,t){if(!/^[1-9]$/.test(e))return null;let s=Number(e)-1;return s<t?s:null}(e,s);return null!==a?{type:"select",index:a}:"ArrowUp"===e?{type:"select",index:r(t-1,s)}:"ArrowDown"===e?{type:"select",index:r(t+1,s)}:"Home"===e?{type:"select",index:0}:"End"===e?{type:"select",index:s-1}:"Enter"===e||" "===e?{type:"submit",index:r(t,s)}:{type:"none"}}s.d(t,{cZ:()=>a,cv:()=>r})},97019:(e,t,s)=>{s.d(t,{Bc:()=>i,ZI:()=>d,k$:()=>l,m_:()=>o});var r=s(18870);s(45110);var a=s(37250),n=s(18833);function i({delayDuration:e=0,...t}){return(0,r.jsx)(a.Kq,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function o({...e}){return(0,r.jsx)(i,{children:(0,r.jsx)(a.bL,{"data-slot":"tooltip",...e})})}function l({...e}){return(0,r.jsx)(a.l9,{"data-slot":"tooltip-trigger",...e})}function d({className:e,sideOffset:t=0,children:s,...i}){return(0,r.jsx)(a.ZL,{children:(0,r.jsxs)(a.UC,{"data-slot":"tooltip-content",sideOffset:t,className:(0,n.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...i,children:[s,(0,r.jsx)(a.i3,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}}}]);
|