@humwick/server 0.130.1 → 0.130.2
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 +5 -0
- package/docs/guides/tools-administration.md +4 -0
- package/docs/guides/tools-coordination.md +1 -0
- package/docs/guides/tools-tasks.md +8 -0
- package/docs/guides/workflows.md +58 -0
- package/docs/openapi.json +414 -1
- package/package.json +8 -17
- package/public/assets/{MessageBubble-BWpoBjl4.js → MessageBubble-BWLqMGKG.js} +2 -2
- package/public/assets/{PlanGraphPanel-C0auck3n.js → PlanGraphPanel-3TlIQpjk.js} +2 -2
- package/public/assets/{TraceView-DBnOx7AQ.js → TraceView-Wimm0Czv.js} +2 -2
- package/public/assets/{VaultDecisionCard-0kp2oNBC.js → VaultDecisionCard-Bau_vNax.js} +2 -2
- package/public/assets/{activity-yLztXEBt.js → activity-CrSurn-r.js} +2 -2
- package/public/assets/{agent-lineage-BbJDR1dW.js → agent-lineage-CknAJKcb.js} +2 -2
- package/public/assets/agent-liveness-CaNwK0Zf.js +2 -0
- package/public/assets/{agent-name-CTZBrSD9.js → agent-name-DKbiIhBo.js} +2 -2
- package/public/assets/agent-profiles-DwF6EQ4R.js +2 -0
- package/public/assets/{agent-project-badge-9TqzUUYE.js → agent-project-badge-Diz4Sjjb.js} +2 -2
- package/public/assets/{agent-tools-D4n40pn8.js → agent-tools-CRhpRQza.js} +2 -2
- package/public/assets/{agent-type-icon-D6FUarOf.js → agent-type-icon-LrUEU3lB.js} +2 -2
- package/public/assets/{agents-BYDslkJc.js → agents-B-v66C-4.js} +2 -2
- package/public/assets/{analytics-B-XSbEMC.js → analytics-BqCb-LKi.js} +2 -2
- package/public/assets/{artifact-viewer-DdWIfV6M.js → artifact-viewer-kf4pGuAR.js} +2 -2
- package/public/assets/{artifacts-oBOqks-2.js → artifacts-D32zyw4Y.js} +2 -2
- package/public/assets/{artifacts-DPN1q4pA.js → artifacts-DJevXcvg.js} +2 -2
- package/public/assets/{automation-4KcRFXEu.js → automation-BpRajx_5.js} +2 -2
- package/public/assets/{backlog-Cw9xPTCF.js → backlog-D_UjTdzX.js} +2 -2
- package/public/assets/{busy-health-CTu32MZt.js → busy-health-N3VEh4ao.js} +2 -2
- package/public/assets/{channels-BiXzg1G9.js → channels-9jopungq.js} +2 -2
- package/public/assets/{chat-Ctk2qwvA.js → chat-CSXrTB3C.js} +2 -2
- package/public/assets/{code-preview-Bm1wWqAp.js → code-preview-p1NnmqK0.js} +2 -2
- package/public/assets/{connectors-C36ax4Vw.js → connectors-CZdqlDNL.js} +2 -2
- package/public/assets/{cosmos-Jj9LK2Wf.js → cosmos-BgdsE4dG.js} +2 -2
- package/public/assets/{crate-agent-H6S7-B9T.js → crate-agent-30aXTKva.js} +2 -2
- package/public/assets/{dependency-graph-Cd1E23wa.js → dependency-graph-B_jvw2GE.js} +2 -2
- package/public/assets/{deploys-Bwfq146q.js → deploys-DoN6bAb5.js} +2 -2
- package/public/assets/{display-CfO7rTuF.js → display-BrKWFGJz.js} +2 -2
- package/public/assets/{files-DhhZI2Ih.js → files-D6XEu8Ng.js} +2 -2
- package/public/assets/{fleet-B_rFEbnL.js → fleet-C7jQWbw2.js} +2 -2
- package/public/assets/{fleet-metrics-BkHP-P3R.js → fleet-metrics-BiDs3MLx.js} +2 -2
- package/public/assets/{formatted-body-Cm1RrzmN.js → formatted-body-CQBwc1fb.js} +3 -3
- package/public/assets/{formatted-body-impl-DQiOuOD1.js → formatted-body-impl-DyG0WsQS.js} +2 -2
- package/public/assets/{host-providers-dialog-CHqwXTov.js → host-providers-dialog-DKaW31dN.js} +2 -2
- package/public/assets/index-CRHep3M9.js +15 -0
- package/public/assets/index-MYAIwYTX.css +2 -0
- package/public/assets/{insights-fH1EL-qZ.js → insights-CzrtkpOE.js} +2 -2
- package/public/assets/{integrations-C5Oix6ng.js → integrations-aVsUmigt.js} +2 -2
- package/public/assets/{issue-ref-chip-ODyondIa.js → issue-ref-chip-BnSlM_95.js} +2 -2
- package/public/assets/{log-viewer-Cvfy6PW7.js → log-viewer-qe7Ee47Z.js} +2 -2
- package/public/assets/{maintenance-D8CDH5wZ.js → maintenance-NfjqFZAk.js} +2 -2
- package/public/assets/{managed-agents-egllbpij.js → managed-agents-BiH0HgaE.js} +2 -2
- package/public/assets/{markdown-preview-CYSFgVgK.js → markdown-preview-BixaT3Xr.js} +3 -3
- package/public/assets/{markdown-preview-impl-BteVIjX4.js → markdown-preview-impl-DNGlWIS3.js} +2 -2
- package/public/assets/{memory-C8WmXsyr.js → memory-DNsCl6UX.js} +2 -2
- package/public/assets/{messages-BzQdqlO6.js → messages-DopU1L1X.js} +2 -2
- package/public/assets/{orchestrators-B1HxzkNw.js → orchestrators-Cq7ckLQT.js} +2 -2
- package/public/assets/{overview-DCUnI4Z7.js → overview-C1DCTzzV.js} +2 -2
- package/public/assets/{pairs-ftCd2XcD.js → pairs-DE_m6rrE.js} +2 -2
- package/public/assets/{profile-icon-B2zH8DMH.js → profile-icon-B3rfh77F.js} +2 -2
- package/public/assets/project-profile-instructions-DQWZE0kA.js +2 -0
- package/public/assets/projects-Br2Bd2h1.js +2 -0
- package/public/assets/{prompt-settings-Bftq9czX.js → prompt-settings-BKvFsvGD.js} +2 -2
- package/public/assets/provider-display-DsuWMvVL.js +2 -0
- package/public/assets/{registry-DWCU5c8q.js → registry-Cw38_6gW.js} +2 -2
- package/public/assets/run-card-CpKqRbhg.js +2 -0
- package/public/assets/scroll-text-BKXS1ahr.js +2 -0
- package/public/assets/{secrets-C7GIUATz.js → secrets-DxI-vzSq.js} +2 -2
- package/public/assets/{service-access-settings-C3aujqTG.js → service-access-settings-D9s_VJbd.js} +2 -2
- package/public/assets/{settings-C6sZ9eBa.js → settings-CKZTVGIx.js} +2 -2
- package/public/assets/{shipping-Bu8p1gEw.js → shipping-B9YtnwtG.js} +2 -2
- package/public/assets/{stats-V9Z-GxUd.js → stats-DyUBKyWI.js} +2 -2
- package/public/assets/{status-dot-CVv0iGHL.js → status-dot-DYqlEUhJ.js} +2 -2
- package/public/assets/{store-BvtFdlGX.js → store-DcClXLH0.js} +3 -3
- package/public/assets/{tasks-CXU75HRF.js → tasks-Bh7Chr4-.js} +2 -2
- package/public/assets/{teams-BPf976zb.js → teams-bowI7qVY.js} +2 -2
- package/public/assets/{terminal-viewer-DE9BOe-8.js → terminal-viewer-BgVLHdsU.js} +3 -3
- package/public/assets/{terminal-viewer-impl-D04pjmGh.js → terminal-viewer-impl-Dz22UPy6.js} +2 -2
- package/public/assets/token-estimate-Co-Jdphh.js +2 -0
- package/public/assets/{use-agent-terminal-B1yR456R.js → use-agent-terminal-DSQQ-iY7.js} +2 -2
- package/public/assets/{use-decisions-D-S4tpDf.js → use-decisions-samMQhQf.js} +2 -2
- package/public/assets/use-project-list-59LheVP7.js +2 -0
- package/public/assets/{use-selectors-CnrAk2YP.js → use-selectors-BZa25xEB.js} +2 -2
- package/public/assets/{user-avatar-nBFIcR4M.js → user-avatar-DHxlvUvV.js} +2 -2
- package/public/assets/versioned-prompt-editor-BmED5DnJ.js +8 -0
- package/public/assets/{work-queue-TCjJxeT-.js → work-queue-CSvpuNLz.js} +2 -2
- package/public/assets/{workflow-marker-Cf3Hf2fN.js → workflow-marker-DAZcj5qt.js} +2 -2
- package/public/assets/{workflows-CXQX20Qj.js → workflows-DdmxRSyg.js} +2 -2
- package/public/assets/{workspaces-qSYzKYMA.js → workspaces-BxeKfVuF.js} +2 -2
- package/public/cosmos.html +4 -4
- package/public/index.html +31 -29
- package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/runner/plugins/claude/hooks/gate-run-guard.provisioned.mjs +31 -1
- package/runner/src/adapters/claude-effort.ts +2 -4
- package/runner/src/adapters/codex-launch-config.ts +4 -5
- package/runner/src/adapters/codex.ts +1 -1
- package/runner/src/adapters/opencode-provider.ts +7 -22
- package/runner/src/adapters/opencode.ts +4 -4
- package/runner/src/agent-runner/credentials.ts +42 -12
- package/runner/src/agent-runner/inbox.ts +27 -0
- package/runner/src/agent-runner/lifecycle-milestones.ts +0 -2
- package/runner/src/bin/claude.ts +4 -0
- package/runner/src/bin/codex.ts +4 -0
- package/runner/src/bin/opencode.ts +4 -0
- package/runner/src/index.ts +5 -2
- package/runner/src/provider-setup.ts +34 -0
- package/runner/src/providers.ts +2 -1
- package/runner/src/runner-core.ts +18 -23
- package/runner/src/spawn-input.ts +2 -1
- package/runner/src/test-run-dedup.ts +59 -56
- package/scripts/cd-config.ts +8 -0
- package/scripts/gate-run-lease.ts +10 -7
- package/scripts/gate.sh +5 -1
- package/src/branch-land-notice.ts +93 -0
- package/src/branch-landed.ts +7 -76
- package/src/bus.ts +19 -20
- package/src/cd-deploy-notify.ts +30 -2
- package/src/cd-host-lag-notify.ts +7 -6
- package/src/ci/incidents.ts +2 -2
- package/src/ci/monitor.ts +5 -8
- package/src/ci/root-missing.ts +2 -7
- package/src/ci/transition-notify.ts +7 -39
- package/src/cli/cd-pauses.ts +19 -0
- package/src/cli/orchestrator.ts +1 -1
- package/src/cli/state.ts +2 -19
- package/src/cli/task-edit.ts +22 -0
- package/src/cli/task.ts +3 -1
- package/src/cli/workflow.ts +8 -2
- package/src/commands-db.ts +3 -3
- package/src/config-store-write.ts +13 -1
- package/src/config-store.ts +25 -14
- package/src/db/activity-async.ts +6 -1
- package/src/db/activity-write-ops.ts +12 -1
- package/src/db/activity.ts +1 -14
- package/src/db/agent-search.ts +1 -15
- package/src/db/agents-async.ts +52 -5
- package/src/db/agents-write-ops.ts +12 -3
- package/src/db/agents.ts +81 -54
- package/src/db/ci-incidents-async.ts +5 -5
- package/src/db/ci-incidents-write-ops.ts +2 -2
- package/src/db/command-row.ts +10 -2
- package/src/db/commands-list-query.ts +2 -0
- package/src/db/commands-spawn-read.ts +1 -1
- package/src/db/config-store-write-ops.ts +7 -2
- package/src/db/continuation-archives-async.ts +5 -0
- package/src/db/continuation-archives-write-ops.ts +7 -0
- package/src/db/continuations.ts +2 -2
- package/src/db/db-writer-worker.ts +8 -1
- package/src/db/deploy-events-async.ts +1 -0
- package/src/db/deploy-events-read-ops.ts +2 -1
- package/src/db/deploy-events.ts +35 -4
- package/src/db/hosts-registration.ts +10 -2
- package/src/db/hosts.ts +9 -6
- package/src/db/inbox.ts +0 -14
- package/src/db/index.ts +2 -0
- package/src/db/integrations-async.ts +8 -0
- package/src/db/integrations-ops.ts +15 -0
- package/src/db/integrations.ts +15 -21
- package/src/db/issue-lifecycle.ts +3 -4
- package/src/db/issue-refs-async.ts +20 -0
- package/src/db/issue-refs-write-ops.ts +29 -0
- package/src/db/issue-refs.ts +7 -8
- package/src/db/long-running-work.ts +2 -2
- package/src/db/main-connection-writes.ts +23 -2
- package/src/db/maintenance-job-reconcile.ts +61 -0
- package/src/db/maintenance-job-runs-async.ts +14 -0
- package/src/db/maintenance-job-write-ops.ts +9 -0
- package/src/db/mappers.ts +2 -14
- package/src/db/merge-lease.ts +1 -15
- package/src/db/migrations.ts +7 -15
- package/src/db/orchestrators.ts +4 -72
- package/src/db/pairs.ts +1 -13
- package/src/db/project-profile-instructions.ts +50 -0
- package/src/db/prompt-versions.ts +9 -2
- package/src/db/provider-config-history.ts +8 -3
- package/src/db/provider-model-seed.ts +34 -0
- package/src/db/read-op-marshaling-fixtures.ts +5 -0
- package/src/db/read-ops.ts +4 -0
- package/src/db/routing-policy.ts +2 -3
- package/src/db/schema.ts +9 -3
- package/src/db/spawn-delegation-state.ts +11 -4
- package/src/db/stats-async.ts +4 -3
- package/src/db/task-entity.ts +23 -2
- package/src/db/task-list.ts +3 -1
- package/src/db/tasks.ts +1 -17
- package/src/db/timer-ingress.ts +7 -1
- package/src/db/token-db-write-ops.ts +17 -0
- package/src/db/token-standing.ts +15 -11
- package/src/db/workflow-contact.ts +1 -1
- package/src/db/workflow-task-read-ops.ts +30 -0
- package/src/db/write-ops.ts +6 -0
- package/src/db/writer-gateway.ts +17 -11
- package/src/dispatch-availability.ts +10 -6
- package/src/ephemeral/{landing-ingress-proof-worker.ts → landing-ingress-proof.test-fixture.ts} +4 -2
- package/src/host/disk-alert.ts +121 -0
- package/src/lifecycle-manager.ts +3 -2
- package/src/maintenance/cd-watcher.ts +3 -3
- package/src/maintenance/critical-job-watchdog.ts +16 -17
- package/src/maintenance/index.ts +1 -0
- package/src/maintenance/jobs.ts +3 -2
- package/src/maintenance/scheduler.ts +84 -128
- package/src/maintenance/stalled-delivery-pager.ts +6 -5
- package/src/maintenance/workspaces.ts +1 -1
- package/src/managed-policy.ts +31 -27
- package/src/mcp/index.ts +5 -2
- package/src/mcp/output-descriptions.ts +8 -8
- package/src/mcp/presentation.ts +4 -4
- package/src/mcp/project-profile-instructions.ts +32 -0
- package/src/mcp/tool-groups.ts +1 -1
- package/src/mcp/tools-spawn.ts +4 -3
- package/src/mcp-agent-action.ts +1 -2
- package/src/mcp-issue-ref-tools.ts +12 -11
- package/src/mcp-maintenance-tools.ts +2 -2
- package/src/mcp-profile-trust-tools.ts +4 -4
- package/src/mcp-provider-catalog.ts +2 -2
- package/src/mcp-task-tools.ts +11 -5
- package/src/mcp-team-template-tools.ts +3 -3
- package/src/mcp-workflow-tools.ts +10 -3
- package/src/notification-types.ts +2 -1
- package/src/operator-alarm.ts +26 -11
- package/src/project-instructions.ts +4 -0
- package/src/project-profile-instruction-text.ts +6 -0
- package/src/project-profile-instructions.ts +20 -0
- package/src/provider-catalog-store.ts +3 -49
- package/src/provider-config-store.ts +12 -11
- package/src/provider-model-seed.ts +1 -18
- package/src/provider-quota-config-store.ts +5 -4
- package/src/provider-secrets.test-fixture.ts +3 -3
- package/src/recipe-runner.ts +2 -2
- package/src/repo-config-source.ts +10 -4
- package/src/routes/agent-profiles.ts +6 -6
- package/src/routes/agents-spawn.ts +1 -1
- package/src/routes/agents.ts +6 -6
- package/src/routes/commands-listing.ts +4 -0
- package/src/routes/commands.ts +2 -2
- package/src/routes/continuation-archives.ts +2 -2
- package/src/routes/index.ts +10 -1
- package/src/routes/integrations.ts +24 -50
- package/src/routes/issue-refs.ts +7 -7
- package/src/routes/orchestrator-bootstrap.ts +1 -1
- package/src/routes/orchestrator-host-registration.ts +2 -2
- package/src/routes/orchestrator-host-utilization.ts +3 -1
- package/src/routes/orchestrator-proxy.ts +2 -2
- package/src/routes/orchestrator.ts +2 -2
- package/src/routes/project-profile-instructions.ts +27 -0
- package/src/routes/project-trust.ts +2 -2
- package/src/routes/provider-config.ts +6 -6
- package/src/routes/provider-quota-config.ts +2 -2
- package/src/routes/settings.ts +5 -5
- package/src/routes/stats.ts +6 -6
- package/src/routes/task-http.ts +15 -1
- package/src/routes/task-issues.ts +11 -26
- package/src/routes/tasks.ts +22 -53
- package/src/routes/team-templates.ts +5 -5
- package/src/routes/teams-config.ts +2 -2
- package/src/routes/tokens.ts +12 -5
- package/src/routes/workflows.ts +20 -5
- package/src/routing-policy-normalize.ts +1 -2
- package/src/routing-step-defaults.ts +0 -2
- package/src/runner-token-mint-limit.ts +63 -0
- package/src/runtime-grant.ts +4 -2
- package/src/runtime-tokens.ts +39 -7
- package/src/security.ts +13 -20
- package/src/server-background.ts +1 -1
- package/src/server.ts +5 -2
- package/src/services/host-utilization.ts +23 -0
- package/src/services/idle-epics.ts +5 -6
- package/src/services/issue-lifecycle.ts +57 -61
- package/src/services/issue-refs.ts +9 -13
- package/src/services/kernel-timers-cutover-chaos-worker.ts +10 -7
- package/src/services/kernel-timers-ingress.ts +1 -1
- package/src/services/landed-ancestry.ts +19 -3
- package/src/services/memory-areas.ts +15 -51
- package/src/services/plan-ci-notice.ts +57 -0
- package/src/services/plan-ci-recovery.ts +2 -55
- package/src/services/plan-wake-digest.ts +1 -0
- package/src/services/profile-trust.ts +4 -3
- package/src/services/project-config-read.ts +70 -0
- package/src/services/project-profile-instructions.ts +54 -0
- package/src/services/provisioning-harness/budget-baseline.json +4 -4
- package/src/services/restart-spawn.ts +61 -49
- package/src/services/self-care-state.ts +2 -1
- package/src/services/self-effort.ts +5 -5
- package/src/services/send-message.ts +5 -1
- package/src/services/spawn-agent.ts +13 -2
- package/src/services/spawn-chain-inspector.ts +6 -13
- package/src/services/spawn-policy.ts +68 -0
- package/src/services/spawn-tree-cleanup.ts +2 -2
- package/src/services/task-dispatch.ts +3 -0
- package/src/services/task-state-reconcile.ts +6 -14
- package/src/services/team-templates.ts +9 -8
- package/src/services/transient-agent-reaper.ts +3 -1
- package/src/services/workflow-auto-start.ts +25 -13
- package/src/services/workflow-ci-main.ts +1 -1
- package/src/services/workflow-deferred-cleanup.ts +4 -2
- package/src/services/workflow-effect-driver.ts +2 -0
- package/src/services/workflow-effects.ts +18 -11
- package/src/services/workflow-land-notice.ts +10 -0
- package/src/services/workflow-pause-text.ts +43 -0
- package/src/services/workflow-reconcile.ts +13 -11
- package/src/services/workflow-run-view.ts +2 -0
- package/src/services/workflow-runs.ts +29 -13
- package/src/services/workflow-supervisor-state.ts +5 -0
- package/src/services/workflow-supervisor.ts +7 -3
- package/src/settings/registry.ts +1 -2
- package/src/spawn-command.ts +4 -4
- package/src/spawn-models.ts +10 -12
- package/src/spawn-placement.ts +1 -1
- package/src/spawn-targets.ts +1 -1
- package/src/startup-context-injection.ts +1 -0
- package/src/state-adoption/cd-cutover.ts +53 -7
- package/src/state-adoption/fleet-cutover.ts +35 -0
- package/src/state-adoption/fleet-plan.ts +36 -0
- package/src/state-adoption/index.ts +2 -2
- package/src/state-adoption/linux-plan.ts +2 -2
- package/src/state-adoption/linux.ts +2 -2
- package/src/state-adoption/macos-plan.ts +2 -2
- package/src/state-adoption/macos.ts +1 -1
- package/src/steward.ts +7 -6
- package/src/task-dispatch-live.ts +1 -1
- package/src/task-dispatcher.ts +1 -1
- package/src/teams-config-store.ts +4 -3
- package/src/token-db-write.ts +10 -0
- package/src/workspace-command-settle.ts +2 -1
- package/src/workspace-steward-wake.ts +2 -2
- package/node_modules/@humwick/kernel/LICENSE +0 -167
- package/node_modules/@humwick/kernel/async-entity-persistence.ts +0 -344
- package/node_modules/@humwick/kernel/async-event-log.ts +0 -107
- package/node_modules/@humwick/kernel/automations.pilot.ts +0 -147
- package/node_modules/@humwick/kernel/config.ts +0 -111
- package/node_modules/@humwick/kernel/contract.ts +0 -572
- package/node_modules/@humwick/kernel/control-authz.ts +0 -281
- package/node_modules/@humwick/kernel/control.ts +0 -645
- package/node_modules/@humwick/kernel/effects.ts +0 -493
- package/node_modules/@humwick/kernel/event-log.ts +0 -319
- package/node_modules/@humwick/kernel/http-transport.ts +0 -384
- package/node_modules/@humwick/kernel/identity-grammar.ts +0 -20
- package/node_modules/@humwick/kernel/identity.ts +0 -248
- package/node_modules/@humwick/kernel/index.ts +0 -28
- package/node_modules/@humwick/kernel/kernel-persistence.ts +0 -181
- package/node_modules/@humwick/kernel/landing-incident.ts +0 -306
- package/node_modules/@humwick/kernel/landing.ts +0 -953
- package/node_modules/@humwick/kernel/manifest-validation.ts +0 -460
- package/node_modules/@humwick/kernel/mcp-transport.ts +0 -109
- package/node_modules/@humwick/kernel/message-authority-chaos-worker.ts +0 -200
- package/node_modules/@humwick/kernel/message-authority.ts +0 -281
- package/node_modules/@humwick/kernel/module-host.ts +0 -722
- package/node_modules/@humwick/kernel/openapi-init.ts +0 -14
- package/node_modules/@humwick/kernel/package.json +0 -39
- package/node_modules/@humwick/kernel/persistence-schema.ts +0 -248
- package/node_modules/@humwick/kernel/persistence.ts +0 -510
- package/node_modules/@humwick/kernel/registry.ts +0 -60
- package/node_modules/@humwick/kernel/sqlite-kernel-persistence.ts +0 -499
- package/node_modules/@humwick/kernel/sqlite-module-host.ts +0 -87
- package/node_modules/@humwick/kernel/timers-chaos-worker.ts +0 -186
- package/node_modules/@humwick/kernel/timers.pilot.ts +0 -1411
- package/node_modules/@humwick/kernel/workflow-activation.ts +0 -25
- package/node_modules/@humwick/kernel/workflow-backstop.ts +0 -40
- package/node_modules/@humwick/kernel/workflow-cancel-tree.ts +0 -20
- package/node_modules/@humwick/kernel/workflow-chaos-worker.ts +0 -213
- package/node_modules/@humwick/kernel/workflow-composition.ts +0 -231
- package/node_modules/@humwick/kernel/workflow-container.ts +0 -72
- package/node_modules/@humwick/kernel/workflow-control.test-fixture.ts +0 -42
- package/node_modules/@humwick/kernel/workflow-control.ts +0 -178
- package/node_modules/@humwick/kernel/workflow-definition.ts +0 -507
- package/node_modules/@humwick/kernel/workflow-dispatch.ts +0 -60
- package/node_modules/@humwick/kernel/workflow-foreach.ts +0 -167
- package/node_modules/@humwick/kernel/workflow-journal-codec.ts +0 -339
- package/node_modules/@humwick/kernel/workflow-journal.ts +0 -922
- package/node_modules/@humwick/kernel/workflow-lane.ts +0 -48
- package/node_modules/@humwick/kernel/workflow-lease-owner.ts +0 -60
- package/node_modules/@humwick/kernel/workflow-recovery.test-fixture.ts +0 -19
- package/node_modules/@humwick/kernel/workflow-runtime.ts +0 -938
- package/node_modules/@humwick/kernel/workflow-script.ts +0 -11
- package/node_modules/@humwick/kernel/workflow-state.ts +0 -299
- package/node_modules/@humwick/kernel/workflow-step-commit.ts +0 -195
- package/node_modules/@humwick/kernel/workflow-transitions.ts +0 -317
- package/node_modules/@humwick/kernel/workflow-values.ts +0 -153
- package/node_modules/@humwick/kernel/workflow.pilot.ts +0 -376
- package/node_modules/@humwick/offload/LICENSE +0 -167
- package/node_modules/@humwick/offload/README.md +0 -57
- package/node_modules/@humwick/offload/dist/async-runner.d.ts +0 -18
- package/node_modules/@humwick/offload/dist/async-runner.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/async-runner.js +0 -158
- package/node_modules/@humwick/offload/dist/async-runner.js.map +0 -1
- package/node_modules/@humwick/offload/dist/envelope.d.ts +0 -25
- package/node_modules/@humwick/offload/dist/envelope.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/envelope.js +0 -80
- package/node_modules/@humwick/offload/dist/envelope.js.map +0 -1
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts +0 -10
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.js +0 -59
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.js.map +0 -1
- package/node_modules/@humwick/offload/dist/index.d.ts +0 -5
- package/node_modules/@humwick/offload/dist/index.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/index.js +0 -5
- package/node_modules/@humwick/offload/dist/index.js.map +0 -1
- package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts +0 -62
- package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/subprocess-runner.js +0 -295
- package/node_modules/@humwick/offload/dist/subprocess-runner.js.map +0 -1
- package/node_modules/@humwick/offload/dist/types.d.ts +0 -111
- package/node_modules/@humwick/offload/dist/types.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/types.js +0 -176
- package/node_modules/@humwick/offload/dist/types.js.map +0 -1
- package/node_modules/@humwick/offload/dist/worker-pool.d.ts +0 -23
- package/node_modules/@humwick/offload/dist/worker-pool.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/worker-pool.js +0 -435
- package/node_modules/@humwick/offload/dist/worker-pool.js.map +0 -1
- package/node_modules/@humwick/offload/dist/worker-runtime.d.ts +0 -2
- package/node_modules/@humwick/offload/dist/worker-runtime.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/worker-runtime.js +0 -27
- package/node_modules/@humwick/offload/dist/worker-runtime.js.map +0 -1
- package/node_modules/@humwick/offload/dist/worker.d.ts +0 -5
- package/node_modules/@humwick/offload/dist/worker.d.ts.map +0 -1
- package/node_modules/@humwick/offload/dist/worker.js +0 -1
- package/node_modules/@humwick/offload/dist/worker.js.map +0 -1
- package/node_modules/@humwick/offload/package.json +0 -42
- package/node_modules/@humwick/offload/src/async-runner.ts +0 -170
- package/node_modules/@humwick/offload/src/envelope.ts +0 -92
- package/node_modules/@humwick/offload/src/fixtures/worker-task.ts +0 -49
- package/node_modules/@humwick/offload/src/index.ts +0 -4
- package/node_modules/@humwick/offload/src/subprocess-runner.ts +0 -334
- package/node_modules/@humwick/offload/src/types.ts +0 -235
- package/node_modules/@humwick/offload/src/worker-pool.ts +0 -463
- package/node_modules/@humwick/offload/src/worker-runtime.ts +0 -32
- package/node_modules/@humwick/offload/src/worker.ts +0 -5
- package/public/assets/agent-liveness-DyqxfB-t.js +0 -2
- package/public/assets/agent-profiles-BpI_jTxq.js +0 -2
- package/public/assets/index-B7ZerHLY.css +0 -2
- package/public/assets/index-BU3uWo2t.js +0 -15
- package/public/assets/projects-B_lmcqfO.js +0 -2
- package/public/assets/provider-display-DbLWpP3j.js +0 -2
- package/public/assets/run-card-CO_bguQf.js +0 -2
- package/public/assets/use-project-list-B-T2Bnnn.js +0 -2
- package/public/assets/versioned-prompt-editor-Diu8BIaM.js +0 -8
- package/runner/src/gate-run-lease-probe.ts +0 -38
- package/src/db/claude-catalog-reconcile.ts +0 -27
- package/src/routing-model-aliases.ts +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{o as t,p as n,u as r}from"./dist-DeW2Y1R5.js";import{Ct as i,Et as a,Ot as o,t as s}from"./store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{o as t,p as n,u as r}from"./dist-DeW2Y1R5.js";import{Ct as i,Et as a,Ot as o,t as s}from"./store-DcClXLH0.js";import{N as c,a as l,r as u,s as d,t as f,u as p,v as m}from"./provider-display-DsuWMvVL.js";import{a as h,n as g}from"./tasks-BIyeAaPC.js";import{o as _,s as v,t as y}from"./api-CIIVBtAV.js";import{t as b}from"./themes-G5j9m1Ji.js";import{a as x,i as S,n as C,o as w,r as T,s as E,t as ee}from"./dialog-uuJ9_geR.js";import{c as D,n as te,o as ne,r as re,s as ie,t as ae}from"./dropdown-menu-BXiNephE.js";import{t as O}from"./label-BPBzm9FJ.js";import{a as k,i as A,n as j,r as M,t as N}from"./select-DTQMP4Dk.js";import{t as P}from"./switch-DuCA7mrB.js";import{a as oe,c as se,i as ce,l as le,n as ue,o as de,r as fe,s as pe,u as me}from"./service-access-settings-D9s_VJbd.js";import{t as he}from"./chevron-down-BoG3JCZn.js";import{t as ge}from"./chevron-right-iljytE0x.js";import{t as F}from"./circle-alert-CryagaZd.js";import{t as _e}from"./circle-check-CkUkN96J.js";import{t as ve}from"./eye-BAP6fHrX.js";import{t as ye}from"./gauge-BIODY-BQ.js";import{t as be}from"./key-round-CcSxl5qr.js";import{t as I}from"./loader-circle-BfPd4kOD.js";import{t as xe}from"./pencil-B1Hf2V_J.js";import{t as Se}from"./plus-D5Ek4e2S.js";import{t as Ce}from"./power-6tZOhYPg.js";import{t as we}from"./refresh-cw-CfpvQcUn.js";import{r as Te}from"./workflow-marker-DAZcj5qt.js";import{t as L}from"./save-B_PGqSm4.js";import{t as Ee}from"./trash-2-FbcSq927.js";import{t as De}from"./user-plus-D9749q73.js";import{t as Oe}from"./volume-2-XrcRKD9Z.js";import{t as R}from"./button-Do6Z3vvn.js";import{t as z}from"./badge-DqJRtj_p.js";import{t as ke}from"./copy-button-CjOj4HEf.js";import{t as B}from"./input-CsTB6jIx.js";import{t as V}from"./textarea-hs6Mpyfl.js";import{i as H,n as U,o as W,r as G,s as K,t as q}from"./card-C4QJ4hCW.js";import{t as Ae}from"./user-avatar-DHxlvUvV.js";var je={"admin:*":`system:admin`,"system:write":`system:admin`,"agents:read":`agent:read`,"agents:write":`agent:write`,"messages:read":`message:read`,"messages:write":`message:send`,"tasks:read":`task:read`,"tasks:write":`task:write`,"commands:read":`command:read`,"commands:write":`command:write`,"channels:read":`channel:read`,"channels:write":`channel:write`,"integrations:read":`integration:read`,"integrations:write":`integration:write`,"connectors:read":`integration:read`,"connectors:write":`integration:write`,"events:create":`integration:write`,"tasks:create":`task:write`};function Me(e){return je[e]??e}function Ne(e,t){let n=Me(t),r=Pe(n);if(!r)return!1;if(e?.includes(`*`))return!0;for(let t of e??[]){let e=Me(t),i=Pe(e);if(i&&(e===`system:admin`||e===n||e===`${r.category}:*`||r.category===`settings`&&r.action&&r.namespace&&i.category===`settings`&&i.action===r.action&&i.namespace===void 0))return!0}return!1}function Pe(e){if(e===`*`)return{category:`*`};let t=e.split(`:`);if(t.some(e=>!e))return null;if(t.length===2){let[e,n]=t;return{category:e,action:n}}if(t.length===3){let[e,n,r]=t;return e!==`settings`||n!==`read`&&n!==`write`||r===`*`?null:{category:e,action:n,namespace:r}}return null}var J=e(n(),1);function Fe(e){return`${e.namespace}/${e.key}`}function Ie(e){return`/settings/${encodeURIComponent(e.namespace)}/${encodeURIComponent(e.key)}`}function Le(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`settings`}function Re(e){let t=new Map;for(let n of e.filter(e=>e.readable)){let e=n.display?.group?.trim()||n.namespace;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>({group:e,slug:Le(e),settings:t.sort(ze)})).sort((e,t)=>Be(e.settings)-Be(t.settings)||e.group.localeCompare(t.group))}function ze(e,t){return(e.display?.order??2**53-1)-(t.display?.order??2**53-1)||e.display?.label?.localeCompare(t.display?.label??``)||Fe(e).localeCompare(Fe(t))}function Be(e){return Math.min(...e.map(e=>e.display?.order??2**53-1))}function Ve(e){return Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type}function He(e,t,n){if(!t.length)return n;let[r,...i]=t;if(r===void 0)return n;if(typeof r==`number`){let t=Array.isArray(e)?[...e]:[];return t[r]=He(t[r],i,n),t}let a=c(e)?{...e}:{},o=He(a[r],i,n);return o===void 0?delete a[r]:a[r]=o,a}function Ue(e){if(e.default!==void 0)return e.default;if(e.const!==void 0)return e.const;if(e.enum?.length)return e.enum[0];switch(Ve(e)){case`boolean`:return!1;case`integer`:case`number`:return 0;case`array`:return[];case`object`:return{};case`string`:return``;default:return}}function We(e){return e.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean)}function Ge(e){return Array.isArray(e)?e.map(e=>String(e)).join(`
|
|
2
2
|
`):``}function Ke(e){return c(e)?Object.entries(e).map(([e,t])=>`${e}=${String(t??``)}`).join(`
|
|
3
3
|
`):``}function qe(e){return Object.fromEntries(e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.indexOf(`=`);return t>=0?[e.slice(0,t).trim(),e.slice(t+1)]:[e,``]}))}var Y=r(),Je=`__unset__`;function Ye(e){return e===`server-runtime`?`Server runtime`:e===`bootstrap`?`Bootstrap`:`Browser`}function Xe(e){return e===`server-runtime`?`Stored by Relay and mutable while the server is running.`:e===`bootstrap`?`Read from startup configuration; restart or host config changes are required.`:`Stored only in this browser profile.`}function Ze(e){return e===`browser`?(0,Y.jsx)(de,{className:`size-3.5`}):(0,Y.jsx)(ce,{className:`size-3.5`})}function X(e){return e.details??[]}function Qe({group:e,settings:t,onSaved:n}){let r=[...new Set(t.map(e=>e.tier))];return(0,Y.jsxs)(`section`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,Y.jsxs)(z,{variant:`outline`,className:`gap-1`,title:Xe(e),children:[Ze(e),Ye(e)]},e))})]}),t.length===0?(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsx)(G,{className:`text-sm text-muted-foreground`,children:`No settings in this group.`})}):(0,Y.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,Y.jsx)($e,{setting:e,onSaved:n},Fe(e)))})]})}function $e({setting:e,onSaved:t}){let[n,r]=(0,J.useState)(()=>e.value??e.defaults??Ue(e.schema)),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)([]),u=e.writable&&e.tier===`server-runtime`;function d(e,t){r(n=>He(n,e,t)),l([]),s(``)}async function f(){if(u){a(!0),l([]),s(``);try{let i=await y(`PUT`,Ie(e),{value:n,updatedBy:`dashboard`});r(i.value),t(i),s(`Saved`)}catch(e){let t=X(e);l(t.length?t:[e.message])}finally{a(!1)}}}return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsxs)(K,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[e.display.label,(0,Y.jsxs)(z,{variant:`outline`,className:`gap-1`,title:Xe(e.tier),children:[Ze(e.tier),Ye(e.tier)]}),!e.writable&&(0,Y.jsx)(z,{variant:`secondary`,children:`Read only`})]}),e.display.description&&(0,Y.jsx)(H,{children:e.display.description}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(R,{size:`sm`,onClick:f,disabled:!u||i,children:[(0,Y.jsx)(L,{className:`size-4`}),i?`Saving`:`Save`]})})]}),(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsx)(tt,{schema:e.schema,value:n,path:[],label:e.display.label,required:!0,disabled:!u||i,onChange:d}),(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-[11px] text-muted-foreground`,children:[(0,Y.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono`,children:[e.namespace,`/`,e.key]}),(0,Y.jsxs)(`span`,{children:[`read `,(0,Y.jsx)(`span`,{className:`text-foreground/70`,children:e.scope.read})]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Y.jsxs)(`span`,{children:[`write `,(0,Y.jsx)(`span`,{className:`text-foreground/70`,children:e.scope.write})]})]}),(0,Y.jsx)(et,{errors:c,status:o})]})]})}function et({errors:e,status:t}){return(0,Y.jsxs)(Y.Fragment,{children:[e.length>0&&(0,Y.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 font-medium`,children:[(0,Y.jsx)(F,{className:`size-4`}),`Save failed`]}),(0,Y.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:e.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]}),t&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-tone-success-fg`,children:[(0,Y.jsx)(_e,{className:`size-4`}),t]})]})}function tt(e){let{schema:t,value:n,path:r,label:i,required:a,disabled:o,onChange:s}=e,l=Ve(t);if(t.enum?.length){let e=n==null||n===``?Je:String(n);return(0,Y.jsx)(Z,{label:i,description:t.description,children:(0,Y.jsxs)(N,{value:e,onValueChange:e=>s(r,e===`__unset__`?void 0:e),disabled:o,children:[(0,Y.jsx)(A,{"aria-label":i,children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[!a&&(0,Y.jsx)(M,{value:`__unset__`,children:`Not set`}),t.enum.map(e=>(0,Y.jsx)(M,{value:String(e),children:String(e)},String(e)))]})]})})}if(l===`boolean`)return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:i}),t.description&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.description})]}),(0,Y.jsx)(P,{"aria-label":i,checked:!!n,onCheckedChange:e=>s(r,e),disabled:o})]});if(l===`integer`||l===`number`)return(0,Y.jsx)(Z,{label:i,description:t.description,children:(0,Y.jsx)(B,{"aria-label":i,type:`number`,min:typeof t.minimum==`number`?t.minimum:void 0,max:typeof t.maximum==`number`?t.maximum:void 0,step:l===`integer`?1:`any`,value:typeof n==`number`?n:``,disabled:o,onChange:e=>s(r,e.target.value===``&&!a?void 0:Number(e.target.value))})});if(l===`array`)return(0,Y.jsx)(Z,{label:i,description:t.description??`One item per line.`,children:(0,Y.jsx)(V,{"aria-label":i,rows:Math.min(8,Math.max(3,Array.isArray(n)?n.length+1:3)),value:Ge(n),disabled:o,onChange:e=>s(r,We(e.target.value))})});if(l===`object`){let e=t.properties??{},a=new Set(t.required??[]);return Object.keys(e).length===0&&t.additionalProperties?(0,Y.jsx)(Z,{label:i,description:t.description??`KEY=value, one entry per line.`,children:(0,Y.jsx)(V,{"aria-label":i,rows:5,value:Ke(n),disabled:o,onChange:e=>s(r,qe(e.target.value))})}):(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[r.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:i}),t.description&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.description})]}),(0,Y.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:Object.entries(e).map(([e,t])=>{let i=c(n)?n[e]:void 0;return(0,Y.jsx)(tt,{schema:t,value:i===void 0&&a.has(e)?Ue(t):i,path:[...r,e],label:t.title||nt(e),required:a.has(e),disabled:o,onChange:s},e)})})]})}return(0,Y.jsx)(Z,{label:i,description:t.description,children:(0,Y.jsx)(B,{"aria-label":i,value:typeof n==`string`?n:n==null?``:String(n),disabled:o,onChange:e=>s(r,e.target.value===``&&!a?void 0:e.target.value)})})}function Z({label:e,description:t,children:n}){return(0,Y.jsxs)(`label`,{className:`block space-y-1.5 text-sm`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e}),n,t&&(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t})]})}function nt(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).replace(/^\w/,e=>e.toUpperCase())}function rt(){let e=s(e=>e.theme),t=s(e=>e.set);return(0,Y.jsxs)(`section`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:`Browser preferences`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`These are stored in local dashboard state, not in Relay server config.`})]}),(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{className:`text-sm`,children:`Dashboard display`}),(0,Y.jsx)(H,{className:`text-xs`,children:`Browser tier · persisted in this browser profile.`}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(z,{variant:`outline`,className:`gap-1`,children:[(0,Y.jsx)(de,{className:`size-3.5`}),`Browser`]})})]}),(0,Y.jsx)(G,{className:`grid gap-3 md:grid-cols-2`,children:(0,Y.jsx)(Z,{label:`Theme`,children:(0,Y.jsxs)(N,{value:e,onValueChange:e=>t({theme:e}),children:[(0,Y.jsx)(A,{children:(0,Y.jsx)(k,{})}),(0,Y.jsx)(j,{children:b.map(e=>(0,Y.jsx)(M,{value:e.id,children:e.label},e.id))})]})})})]}),(0,Y.jsx)(it,{})]})}function it(){let e=s(e=>e.voiceTtsEnabled),t=s(e=>e.setVoiceTtsEnabled),n=s(e=>e.voiceTtsMode),r=s(e=>e.setVoiceTtsMode),i=s(e=>e.voiceTtsKokoroVoice),c=s(e=>e.setVoiceTtsKokoroVoice),l=s(e=>e.voiceTtsBrowserVoice),u=s(e=>e.setVoiceTtsBrowserVoice),d=s(e=>e.voiceInputMode),f=s(e=>e.setVoiceInputMode),[p,m]=(0,J.useState)(()=>o());(0,J.useEffect)(()=>{if(typeof window>`u`||!(`speechSynthesis`in window))return;let e=()=>m(o());return e(),window.speechSynthesis.addEventListener?.(`voiceschanged`,e),()=>window.speechSynthesis.removeEventListener?.(`voiceschanged`,e)},[]);let h=a.some(e=>e.id===i)?a:[...a,{id:i,label:i}];return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsxs)(K,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(Oe,{className:`size-4`}),`Voice`]}),(0,Y.jsx)(H,{className:`text-xs`,children:`Browser tier TTS and push-to-talk behavior.`}),(0,Y.jsx)(U,{children:(0,Y.jsx)(P,{checked:e,onCheckedChange:t})})]}),(0,Y.jsxs)(G,{className:`grid gap-3 md:grid-cols-2`,children:[(0,Y.jsx)(Z,{label:`Speech engine`,children:(0,Y.jsxs)(N,{value:n,onValueChange:e=>r(e),children:[(0,Y.jsx)(A,{children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(M,{value:`kokoro`,children:`Kokoro (server, fallback to browser)`}),(0,Y.jsx)(M,{value:`browser`,children:`Browser Web Speech API`})]})]})}),(0,Y.jsx)(Z,{label:`Kokoro voice`,children:(0,Y.jsxs)(N,{value:i,onValueChange:c,children:[(0,Y.jsx)(A,{children:(0,Y.jsx)(k,{})}),(0,Y.jsx)(j,{children:h.map(e=>(0,Y.jsx)(M,{value:e.id,children:e.label},e.id))})]})}),(0,Y.jsx)(Z,{label:`Browser voice`,children:(0,Y.jsxs)(N,{value:l||`__unset__`,onValueChange:e=>u(e===`__unset__`?``:e),children:[(0,Y.jsx)(A,{children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(M,{value:Je,children:`System default`}),p.map(e=>(0,Y.jsx)(M,{value:e.uri,children:e.label},e.uri))]})]})}),(0,Y.jsx)(Z,{label:`Push-to-talk input`,children:(0,Y.jsxs)(N,{value:d,onValueChange:e=>f(e),children:[(0,Y.jsx)(A,{children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(M,{value:`compose`,children:`Fill message box`}),(0,Y.jsx)(M,{value:`autosend`,children:`Send immediately`})]})]})})]})]})}var at=[{value:``,label:`Until re-enabled`},{value:`1h`,label:`1 hour`,ms:60*6e4},{value:`1d`,label:`1 day`,ms:1440*6e4},{value:`7d`,label:`7 days`,ms:10080*6e4},{value:`30d`,label:`30 days`,ms:720*60*6e4}];function ot({entry:e,canWrite:t,onChanged:n,onError:r}){let[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),u=e.disabled,d=u?.source===`operator`;async function f(c){if(t){l(!0);try{let t=at.find(e=>e.value===o)?.ms;await y(`PUT`,`/providers/${encodeURIComponent(e.provider)}/enablement`,{enabled:c,...!c&&t?{disabledUntil:Date.now()+t}:{},...!c&&i.trim()?{reason:i.trim()}:{},updatedBy:`dashboard`}),a(``),s(``),await n(`${e.provider} ${c?`enabled`:`disabled`}`)}catch(e){r(e)}finally{l(!1)}}}return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsxs)(K,{className:`text-sm`,children:[`Provider `,e.label||e.provider]}),(0,Y.jsx)(U,{children:u?(0,Y.jsxs)(z,{variant:`destructive`,className:`gap-1`,children:[(0,Y.jsx)(oe,{className:`size-3.5`}),`Disabled`]}):(0,Y.jsxs)(z,{variant:`outline`,className:`gap-1`,children:[(0,Y.jsx)(Ce,{className:`size-3.5`}),`Enabled`]})})]}),(0,Y.jsxs)(G,{className:`space-y-3 text-sm`,children:[u?.source===`all-models-disabled`&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`All models are disabled, so the provider is disabled too. Enable a model below to bring it back.`}),d&&(0,Y.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Disabled by the operator`,u.disabledUntil?` until ${new Date(u.disabledUntil).toLocaleString()}`:``,u.reason?` — ${u.reason}`:``,`.`,` `,`No new spawns, routing, quota polling or quota alerts. Running agents keep running.`]}),d?(0,Y.jsx)(R,{size:`sm`,disabled:!t||c,onClick:()=>void f(!0),children:`Enable provider`}):(0,Y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1fr_auto_auto] md:items-end`,children:[(0,Y.jsx)(Z,{label:`Reason (optional)`,children:(0,Y.jsx)(B,{value:i,disabled:!t||c,placeholder:`e.g. subscription ended`,onChange:e=>a(e.target.value)})}),(0,Y.jsx)(Z,{label:`Disable for`,children:(0,Y.jsx)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm`,value:o,disabled:!t||c,onChange:e=>s(e.target.value),children:at.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,Y.jsx)(R,{size:`sm`,variant:`destructive`,disabled:!t||c,onClick:()=>void f(!1),children:`Disable provider`})]})]})]})}function st({catalog:e,error:t,canWrite:n,onCatalog:r}){let i=e[0]?.provider??``,[a,o]=(0,J.useState)(i),[s,c]=(0,J.useState)(()=>ct(i)),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)([]),p=e.some(e=>e.provider===a)?a:i,m=e.find(e=>e.provider===p)??e[0],h=e.map(e=>e.provider);function g(e){c(t=>({...t,...e})),f([]),u(``)}function _(e){o(e),c(ct(e)),f([]),u(``)}async function v(){r((await y(`GET`,`/providers`)).catalog)}async function b(){if(n){f([]),u(``);try{await y(`PUT`,`/providers/${encodeURIComponent(s.provider)}/models/${encodeURIComponent(s.alias)}`,{label:s.label,providerModel:s.providerModel,efforts:We(s.efforts),defaultEffort:s.defaultEffort.trim()||void 0,limits:ut(s),capabilities:s.capabilities,contextThreshold:ft(s),disabled:s.disabled,updatedBy:`dashboard`}),await v(),u(`${s.alias} saved`),c(ct(s.provider))}catch(e){let t=X(e);f(t.length?t:[e.message])}}}async function x(e,t){if(n){f([]),u(``);try{await y(`PATCH`,`/providers/${encodeURIComponent(p)}/models/${encodeURIComponent(e.alias)}`,{disabled:t,updatedBy:`dashboard`}),await v(),u(`${e.alias} ${t?`disabled`:`enabled`}`)}catch(e){let t=X(e);f(t.length?t:[e.message])}}}async function S(e){if(n){f([]),u(``);try{await y(`PUT`,`/providers/${encodeURIComponent(p)}/default-model`,{alias:e.alias,updatedBy:`dashboard`}),await v(),u(`${e.alias} is now the default`)}catch(e){let t=X(e);f(t.length?t:[e.message])}}}async function C(e){if(n){f([]),u(``);try{await y(`DELETE`,`/providers/${encodeURIComponent(p)}/models/${encodeURIComponent(e.alias)}`),await v(),u(`${e.alias} removed`)}catch(e){let t=X(e);f(t.length?t:[e.message])}}}function w(e){c({provider:p,alias:e.alias,label:e.label,providerModel:e.providerModel,efforts:e.efforts.join(`, `),defaultEffort:e.defaultEffort??``,contextWindowTokens:e.limits?.contextWindowTokens?.value?.toString()??``,maxOutputTokens:e.limits?.maxOutputTokens?.value?.toString()??``,selfCompactUtilization:e.contextThreshold?.selfCompactUtilization?.toString()??``,warnUtilization:e.contextThreshold?.warnUtilization?.toString()??``,hardBackstopUtilization:e.contextThreshold?.hardBackstopUtilization?.toString()??``,disabled:!!e.disabled,capabilities:e.capabilities}),f([]),u(``)}return t?(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsxs)(G,{className:`text-sm text-muted-foreground`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 font-medium text-foreground`,children:[(0,Y.jsx)(ie,{className:`size-4`}),`Model catalog`]}),t]})}):(0,Y.jsxs)(`section`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:`Model catalog`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Switch a whole provider off or on, add override models, disable unavailable models, or remove custom entries from the provider catalog.`})]}),!n&&(0,Y.jsx)(z,{variant:`secondary`,children:`Read only: needs settings:write:provider`})]}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:h.map(t=>(0,Y.jsxs)(R,{variant:t===p?`default`:`outline`,size:`sm`,onClick:()=>_(t),children:[t,e.find(e=>e.provider===t)?.disabled?` (off)`:``]},t))}),m&&(0,Y.jsx)(ot,{entry:m,canWrite:n,onChanged:async e=>{await v(),f([]),u(e)},onError:e=>{let t=X(e);f(t.length?t:[e.message])}}),(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{className:`text-sm`,children:`Add or edit model`}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(z,{variant:`outline`,className:`gap-1`,children:[(0,Y.jsx)(ce,{className:`size-3.5`}),`Server runtime`]})})]}),(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,Y.jsx)(Z,{label:`Alias`,children:(0,Y.jsx)(B,{value:s.alias,disabled:!n,placeholder:`nightly`,onChange:e=>g({alias:e.target.value.trim()})})}),(0,Y.jsx)(Z,{label:`Label`,children:(0,Y.jsx)(B,{value:s.label,disabled:!n,placeholder:`Nightly Codex`,onChange:e=>g({label:e.target.value})})}),(0,Y.jsx)(Z,{label:`Provider model`,children:(0,Y.jsx)(B,{value:s.providerModel,disabled:!n,placeholder:`codex-nightly`,onChange:e=>g({providerModel:e.target.value})})}),(0,Y.jsx)(Z,{label:`Efforts`,children:(0,Y.jsx)(B,{value:s.efforts,disabled:!n,placeholder:`low, medium, high`,onChange:e=>g({efforts:e.target.value})})}),(0,Y.jsx)(Z,{label:`Default effort`,children:(0,Y.jsx)(B,{value:s.defaultEffort,disabled:!n,placeholder:`medium`,onChange:e=>g({defaultEffort:e.target.value})})}),(0,Y.jsx)(Z,{label:`Context window tokens`,children:(0,Y.jsx)(B,{value:s.contextWindowTokens,disabled:!n,placeholder:`e.g. 256000 (OpenRouter: context_length)`,inputMode:`numeric`,onChange:e=>g({contextWindowTokens:e.target.value})})}),(0,Y.jsx)(Z,{label:`Max output tokens`,children:(0,Y.jsx)(B,{value:s.maxOutputTokens,disabled:!n,placeholder:`e.g. 32000`,inputMode:`numeric`,onChange:e=>g({maxOutputTokens:e.target.value})})}),(0,Y.jsx)(Z,{label:`Self compact utilization`,children:(0,Y.jsx)(B,{value:s.selfCompactUtilization,disabled:!n,placeholder:`0.80`,inputMode:`decimal`,onChange:e=>g({selfCompactUtilization:e.target.value})})}),(0,Y.jsx)(Z,{label:`Warn utilization`,children:(0,Y.jsx)(B,{value:s.warnUtilization,disabled:!n,placeholder:`default: self - 0.10`,inputMode:`decimal`,onChange:e=>g({warnUtilization:e.target.value})})}),(0,Y.jsx)(Z,{label:`Hard backstop utilization`,children:(0,Y.jsx)(B,{value:s.hardBackstopUtilization,disabled:!n,placeholder:`0.90`,inputMode:`decimal`,onChange:e=>g({hardBackstopUtilization:e.target.value})})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Disabled`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Keep visible but unavailable for new launches.`})]}),(0,Y.jsx)(P,{checked:s.disabled,disabled:!n,onCheckedChange:e=>g({disabled:e})})]})]}),lt(m,s.providerModel)&&(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Qualified runtime name: `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono`,children:lt(m,s.providerModel)})]}),(0,Y.jsxs)(R,{onClick:b,disabled:!n||!s.alias||!s.label||!s.providerModel,children:[(0,Y.jsx)(Se,{className:`size-4`}),`Save model`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[m&&m.models.length===0&&(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsx)(G,{className:`text-sm text-muted-foreground`,children:`No models in this provider catalog yet.`})}),m?.models.map(e=>(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsxs)(G,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:e.alias}),e.disabled&&(0,Y.jsx)(z,{variant:`secondary`,children:`Disabled`}),e.alias===m.defaultModel&&(0,Y.jsx)(z,{variant:`secondary`,children:`Default`})]}),(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.providerModel,e.efforts.length>0?` · efforts ${e.efforts.join(`, `)}`:` · no effort levels`,e.defaultEffort?` · default ${e.defaultEffort}`:``,` · context ${mt(e)}`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.alias!==m.defaultModel&&(0,Y.jsx)(R,{variant:`outline`,size:`sm`,disabled:!n||!!(e.disabled||e.unavailable),onClick:()=>void S(e),children:`Set default`}),(0,Y.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>w(e),children:[(0,Y.jsx)(xe,{className:`size-4`}),`Edit`]}),(0,Y.jsxs)(R,{variant:`outline`,size:`sm`,disabled:!n,onClick:()=>void x(e,!e.disabled),children:[e.disabled?(0,Y.jsx)(ve,{className:`size-4`}):(0,Y.jsx)(se,{className:`size-4`}),e.disabled?`Enable`:`Disable`]}),(0,Y.jsxs)(R,{variant:`outline`,size:`sm`,disabled:!n,onClick:()=>void C(e),children:[(0,Y.jsx)(Ee,{className:`size-4`}),`Remove`]})]})]})},e.alias))]}),d.length>0&&(0,Y.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:(0,Y.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:d.map(e=>(0,Y.jsx)(`li`,{children:e},e))})}),l&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-tone-success-fg`,children:[(0,Y.jsx)(_e,{className:`size-4`}),l]})]})}function ct(e){return{provider:e,alias:``,label:``,providerModel:``,efforts:``,defaultEffort:``,contextWindowTokens:``,maxOutputTokens:``,selfCompactUtilization:``,warnUtilization:``,hardBackstopUtilization:``,disabled:!1}}function lt(e,t){return p(e,t)}function ut(e){let t=dt(e.contextWindowTokens,`Context window tokens`),n=dt(e.maxOutputTokens,`Max output tokens`);if(!(!t&&!n))return{...t?{contextWindowTokens:t}:{},...n?{maxOutputTokens:n}:{}}}function dt(e,t){let n=e.trim();if(!n)return;let r=Number(n);if(!Number.isSafeInteger(r)||r<=0)throw Error(`${t} must be a positive integer`);return{value:r,source:`override`,confidence:`declared`}}function ft(e){let t=pt(e.selfCompactUtilization,`Self compact utilization`),n=pt(e.warnUtilization,`Warn utilization`),r=pt(e.hardBackstopUtilization,`Hard backstop utilization`);if(!(t===void 0&&n===void 0&&r===void 0)){if(t===void 0)throw Error(`Self compact utilization is required when setting context thresholds`);return{selfCompactUtilization:t,...n===void 0?{}:{warnUtilization:n},...r===void 0?{}:{hardBackstopUtilization:r}}}}function pt(e,t){let n=e.trim();if(!n)return;let r=Number(n);if(!Number.isFinite(r))throw Error(`${t} must be a number`);return r}function mt(e){if(e.contextThreshold)return`self ${ht(e.contextThreshold.selfCompactUtilization)}, warn ${ht(e.contextThreshold.warnUtilization??Math.max(0,e.contextThreshold.selfCompactUtilization-.1))}`;let t=d(e.limits?.contextWindowTokens?.value);return`derived self ${ht(t.selfCompactUtilization)}, warn ${ht(t.warnUtilization)}`}function ht(e){return`${Math.round(e*100)}%`}var gt=e=>e===void 0?`inherit`:e?`on`:`off`,_t=e=>e===`inherit`?void 0:e===`on`,vt=e=>({...e.defaults,...e.value,teams:{...e.value?.teams}});function yt({setting:e,teams:t,onSaved:n}){let[r,i]=(0,J.useState)(()=>vt(e)),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)([]),d=e.writable&&e.tier===`server-runtime`,f=!d||a;function p(e){i(t=>({...t,...e})),u([]),c(``)}function m(e,t){let n={...r.teams[e],...t},{[e]:i,...a}=r.teams;p({teams:Object.values(n).some(e=>e!==void 0)?{...a,[e]:n}:a})}async function h(){if(d){o(!0),u([]),c(``);try{let e=await y(`PUT`,`/settings/idle-digest/default`,{value:r,updatedBy:`dashboard`});i(vt(e)),n(e),c(`Saved`)}catch(e){let t=X(e);u(t.length?t:[e.message])}finally{o(!1)}}}let g=new Map;for(let e of t)e.status===`active`&&g.set(e.id,e.title||e.id);for(let e of Object.keys(r.teams))g.has(e)||g.set(e,e);return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsxs)(K,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[`Idle-agent digest`,(0,Y.jsxs)(z,{variant:`outline`,className:`gap-1`,children:[(0,Y.jsx)(ce,{className:`size-3.5`}),`Server runtime`]}),!d&&(0,Y.jsx)(z,{variant:`secondary`,children:`Read only`})]}),(0,Y.jsx)(H,{children:`One digest per coordinator per window listing idle children; provably safe ones can be stopped automatically.`}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void h(),disabled:f,children:[(0,Y.jsx)(L,{className:`size-4`}),a?`Saving`:`Save`]})})]}),(0,Y.jsxs)(G,{className:`space-y-4`,children:[(0,Y.jsx)(xt,{label:`Send idle-agent digests to coordinators`,checked:r.enabled,disabled:f,onChange:e=>p({enabled:e})}),(0,Y.jsx)(Z,{label:`Digest window (hours)`,description:`Default for every team (0.25–168). The server validates the range.`,children:(0,Y.jsx)(B,{"aria-label":`Digest window (hours)`,type:`number`,step:`any`,min:.25,max:168,value:r.windowHours,disabled:f,onChange:e=>p({windowHours:Number(e.target.value)})})}),(0,Y.jsx)(xt,{label:`Stop provably safe idle children automatically`,checked:r.autoReapSafe,disabled:f,onChange:e=>p({autoReapSafe:e})}),(0,Y.jsxs)(`div`,{className:`space-y-3 rounded-md border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Per-team overrides`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Leave a window empty or a switch on “Inherit” to follow the defaults above. A team switched on here is digested even while the global switch is off.`})]}),g.size===0&&(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active teams.`}),[...g].map(([e,t])=>{let n=r.teams[e];return(0,Y.jsxs)(`div`,{className:`grid items-end gap-3 md:grid-cols-[minmax(0,1fr)_140px_160px_160px]`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-medium`,children:t}),t!==e&&(0,Y.jsx)(`code`,{className:`block truncate text-[11px] text-muted-foreground`,children:e})]}),(0,Y.jsx)(Z,{label:`Window (hours)`,children:(0,Y.jsx)(B,{"aria-label":`${t} digest window (hours)`,type:`number`,step:`any`,min:.25,max:168,placeholder:String(r.windowHours),value:n?.windowHours??``,disabled:f,onChange:t=>m(e,{windowHours:t.target.value===``?void 0:Number(t.target.value)})})}),(0,Y.jsx)(bt,{label:`Digest`,ariaLabel:`${t} digest`,value:n?.enabled,inherited:r.enabled,disabled:f,onChange:t=>m(e,{enabled:t})}),(0,Y.jsx)(bt,{label:`Auto-reap`,ariaLabel:`${t} auto-reap`,value:n?.autoReapSafe,inherited:r.autoReapSafe,disabled:f,onChange:t=>m(e,{autoReapSafe:t})})]},e)})]}),(0,Y.jsx)(et,{errors:l,status:s})]})]})}function bt({label:e,ariaLabel:t,value:n,inherited:r,disabled:i,onChange:a}){return(0,Y.jsx)(Z,{label:e,children:(0,Y.jsxs)(`select`,{"aria-label":t,className:`h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm`,value:gt(n),disabled:i,onChange:e=>a(_t(e.target.value)),children:[(0,Y.jsxs)(`option`,{value:`inherit`,children:[`Inherit (`,r?`on`:`off`,`)`]}),(0,Y.jsx)(`option`,{value:`on`,children:`On`}),(0,Y.jsx)(`option`,{value:`off`,children:`Off`})]})})}function xt({label:e,checked:t,disabled:n,onChange:r}){return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:e}),(0,Y.jsx)(P,{"aria-label":e,checked:t,disabled:n,onCheckedChange:r})]})}var St=`unset`;function Ct(e){let t=e=>e?.trim()||void 0,n={communicationStyle:e.communicationStyle,responseStyle:e.responseStyle};e.communicationStyle===`custom`&&(n.communicationCustom=t(e.communicationCustom)),e.responseStyle===`custom`&&(n.responseCustom=t(e.responseCustom));for(let r of[`about`,`locale`,`timeZone`]){let i=t(e[r]);i&&(n[r]=i)}return e.dateFormat&&(n.dateFormat=e.dateFormat),Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0))}function wt({title:e,hint:t,children:n}){return(0,Y.jsxs)(`section`,{className:`space-y-2 border-b border-border pb-4 last:border-b-0 last:pb-0`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium`,children:e}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]}),n]})}function Tt({setting:e,onSaved:t}){let[n,r]=(0,J.useState)(e.value),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),u=e=>{r(t=>({...t,...e})),l(!1)},d=n.communicationStyle===`custom`&&!n.communicationCustom?.trim()||n.responseStyle===`custom`&&!n.responseCustom?.trim();async function f(){a(!0),s(``);try{let e=await y(`PUT`,`/settings/agent-prefs/default`,{value:Ct(n),updatedBy:`dashboard`});r(e.value),l(!0),t(e)}catch(e){s(e.message)}finally{a(!1)}}return(0,Y.jsx)(q,{size:`sm`,"data-testid":`agent-prefs`,children:(0,Y.jsxs)(G,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:`How agents talk to you`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Agents you own use these from their next start or context reset.`})]}),(0,Y.jsxs)(wt,{title:`Communication style`,hint:`The tone agents use with you.`,children:[(0,Y.jsxs)(N,{value:n.communicationStyle,onValueChange:e=>u({communicationStyle:e}),children:[(0,Y.jsx)(A,{className:`w-full sm:w-64`,"aria-label":`Communication style`,children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(M,{value:`neutral`,children:`Neutral`}),(0,Y.jsx)(M,{value:`warm`,children:`Warm and friendly`}),(0,Y.jsx)(M,{value:`custom`,children:`Custom`})]})]}),n.communicationStyle===`custom`&&(0,Y.jsx)(V,{"aria-label":`Custom communication style`,maxLength:300,rows:2,placeholder:`For example: direct, a little dry humor`,value:n.communicationCustom??``,onChange:e=>u({communicationCustom:e.target.value})})]}),(0,Y.jsxs)(wt,{title:`Response style`,hint:`How long and detailed replies are.`,children:[(0,Y.jsxs)(N,{value:n.responseStyle,onValueChange:e=>u({responseStyle:e}),children:[(0,Y.jsx)(A,{className:`w-full sm:w-64`,"aria-label":`Response style`,children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(M,{value:`normal`,children:`Normal`}),(0,Y.jsx)(M,{value:`brief`,children:`Brief`}),(0,Y.jsx)(M,{value:`custom`,children:`Custom`})]})]}),n.responseStyle===`custom`&&(0,Y.jsx)(V,{"aria-label":`Custom response style`,maxLength:300,rows:2,placeholder:`For example: bullet points, numbers first`,value:n.responseCustom??``,onChange:e=>u({responseCustom:e.target.value})})]}),(0,Y.jsx)(wt,{title:`About you`,hint:`What you want agents to know about you. Optional.`,children:(0,Y.jsx)(V,{"aria-label":`About you`,maxLength:600,rows:3,value:n.about??``,onChange:e=>u({about:e.target.value})})}),(0,Y.jsx)(wt,{title:`Language and time`,hint:`Optional. Leave empty to let agents decide.`,children:(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(O,{htmlFor:`agent-prefs-locale`,children:`Locale`}),(0,Y.jsx)(B,{id:`agent-prefs-locale`,placeholder:`en-GB`,maxLength:35,value:n.locale??``,onChange:e=>u({locale:e.target.value})})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(O,{htmlFor:`agent-prefs-time-zone`,children:`Time zone`}),(0,Y.jsx)(B,{id:`agent-prefs-time-zone`,placeholder:`Europe/Stockholm`,maxLength:64,value:n.timeZone??``,onChange:e=>u({timeZone:e.target.value})})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(O,{children:`Date format`}),(0,Y.jsxs)(N,{value:n.dateFormat??St,onValueChange:e=>u({dateFormat:e===St?void 0:e}),children:[(0,Y.jsx)(A,{className:`w-full`,"aria-label":`Date format`,children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(M,{value:St,children:`Not set`}),(0,Y.jsx)(M,{value:`iso`,children:`ISO (2026-11-07)`}),(0,Y.jsx)(M,{value:`locale`,children:`My locale`})]})]})]})]})}),o&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-3.5`}),(0,Y.jsx)(`span`,{children:o})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void f(),disabled:i||d||!e.writable,children:[(0,Y.jsx)(L,{className:`size-4`}),i?`Saving…`:`Save preferences`]}),d&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Describe your custom style first.`}),c&&(0,Y.jsx)(`span`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Saved`})]})]})})}var Et={decisions:{label:`Decisions`,important:`Important: only time-critical ones.`},actions:{label:`Actions`,important:`Important: only time-critical ones.`},escalations:{label:`Escalations`,important:`Important: stuck, blocked or failed agents, not passing heads-ups.`},finalReports:{label:`Final reports`,important:`Important: only replies that wait on your answer.`},failures:{label:`Failures`,important:`Important: errors and messages that gave up, not retries.`}};function Dt({setting:e,onSaved:t}){let[n,r]=(0,J.useState)(e.value),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1);async function u(){a(!0),s(``);try{let e=await y(`PUT`,`/settings/notification-prefs/default`,{value:n,updatedBy:`dashboard`});r(e.value),l(!0),t(e)}catch(e){s(e.message)}finally{a(!1)}}return(0,Y.jsx)(q,{size:`sm`,"data-testid":`notification-prefs`,children:(0,Y.jsxs)(G,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:`What notifies you`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Which events notify you in the dashboard. Other people keep their own settings.`})]}),(0,Y.jsx)(`div`,{className:`divide-y divide-border`,children:m.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-2 first:pt-0 last:pb-0`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:Et[e].label}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Et[e].important})]}),(0,Y.jsxs)(N,{value:n[e],onValueChange:t=>{r(n=>({...n,[e]:t})),l(!1)},children:[(0,Y.jsx)(A,{className:`w-full sm:w-40`,"aria-label":Et[e].label,children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(M,{value:`all`,children:`All`}),(0,Y.jsx)(M,{value:`important`,children:`Important only`}),(0,Y.jsx)(M,{value:`none`,children:`None`})]})]})]},e))}),o&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-3.5`}),(0,Y.jsx)(`span`,{children:o})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void u(),disabled:i||!e.writable,children:[(0,Y.jsx)(L,{className:`size-4`}),i?`Saving…`:`Save notifications`]}),c&&(0,Y.jsx)(`span`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Saved`})]})]})})}function Ot(){let[e,t]=(0,J.useState)([]),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(!1);async function o(){try{t(await y(`GET`,`/users/authority-denials`)),r(``),a(!0)}catch(e){r(e.message)}}return(0,Y.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Authority denials`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Authority denials`}),(0,Y.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void o(),children:i?`Refresh denials`:`Load denials`})]}),n&&(0,Y.jsx)(`p`,{role:`alert`,children:n}),i&&e.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No authority denials recorded.`}),(0,Y.jsx)(`ul`,{className:`max-h-80 space-y-2 overflow-auto text-xs`,children:e.map(e=>{let{actor:t,target:n,action:r,reason:i}=e.metadata;return(0,Y.jsxs)(`li`,{className:`rounded border border-border p-2 break-words`,children:[(0,Y.jsx)(`time`,{children:new Date(e.createdAt).toLocaleString()}),(0,Y.jsxs)(`div`,{children:[t.kind,`: `,t.id,` · `,r,` · `,n]}),(0,Y.jsx)(`p`,{children:i})]},e.id)})})]})}function kt(){let e=s(e=>e.sessionUser===null),t=s(e=>e.signIn),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(``),[o,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``);if((0,J.useEffect)(()=>{if(!e)return;let t=!0;return y(`GET`,`/users/me`).then(e=>{t&&r(e)}).catch(()=>void 0),()=>{t=!1}},[e]),!e||!n||n.hasPassword&&!l)return null;async function h(e){f(!0),m(``);try{await e()}catch(e){m(e.message)}finally{f(!1)}}function g(e){e.preventDefault(),h(async()=>{if(i!==o)throw Error(`The passwords do not match.`);await y(`PUT`,`/users/me/password`,{password:i}),u(!0)})}return(0,Y.jsx)(q,{size:`sm`,"data-testid":`set-password`,children:(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(be,{className:`mt-0.5 size-4 text-muted-foreground`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:l?`Password set`:`Set your password`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l?(0,Y.jsxs)(Y.Fragment,{children:[`You can now sign in as `,(0,Y.jsx)(`span`,{className:`font-mono`,children:n.handle}),` with your password. Signing in replaces the admin token in this browser.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`You are using the admin token. Set a password to sign in as `,(0,Y.jsx)(`span`,{className:`font-mono`,children:n.handle}),` instead.`]})})]})]}),l?(0,Y.jsx)(R,{size:`sm`,disabled:d,onClick:()=>void h(()=>t(n.handle,i)),children:`Sign in with password`}):(0,Y.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:g,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(O,{htmlFor:`admin-password`,children:`New password`}),(0,Y.jsx)(B,{id:`admin-password`,type:`password`,autoComplete:`new-password`,className:`w-48`,value:i,onChange:e=>a(e.target.value),required:!0,minLength:10})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(O,{htmlFor:`admin-password-confirm`,children:`Repeat password`}),(0,Y.jsx)(B,{id:`admin-password-confirm`,type:`password`,autoComplete:`new-password`,className:`w-48`,value:o,onChange:e=>c(e.target.value),required:!0})]}),(0,Y.jsx)(R,{type:`submit`,size:`sm`,disabled:d,children:`Set password`})]}),p&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:p})]})})}var At={admin:`Admin`,operator:`Member`,viewer:`Viewer`},jt=Object.keys(At);function Mt({value:e,onChange:t,label:n,disabled:r}){return(0,Y.jsxs)(N,{value:e,onValueChange:e=>t(e),disabled:r,children:[(0,Y.jsx)(A,{className:`w-32`,"aria-label":n,children:(0,Y.jsx)(k,{})}),(0,Y.jsx)(j,{children:jt.map(e=>(0,Y.jsx)(M,{value:e,children:At[e]},e))})]})}function Nt({onError:e}){let[t,n]=(0,J.useState)(`operator`),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null);async function l(){o(!0),e(``);try{let e=await y(`POST`,`/users/invites`,{role:t,...r.trim()?{displayName:r.trim()}:{}});c({link:new URL(e.path.replace(/^\//,``),v()).href,expiresAt:e.invite.expiresAt}),i(``)}catch(t){e(t.message)}finally{o(!1)}}return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(O,{htmlFor:`invite-name`,children:`Name`}),(0,Y.jsx)(B,{id:`invite-name`,className:`w-48`,placeholder:`Optional`,value:r,onChange:e=>i(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(O,{children:`Role`}),(0,Y.jsx)(Mt,{value:t,onChange:n,label:`Invite role`})]}),(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void l(),disabled:a,children:[(0,Y.jsx)(De,{className:`size-4`}),`Create invite link`]})]}),s&&(0,Y.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/40 p-3 text-xs`,"data-testid":`invite-link`,children:[(0,Y.jsxs)(`p`,{className:`mb-2 text-muted-foreground`,children:[`Send this link yourself. It works once and expires on `,new Date(s.expiresAt).toLocaleDateString(),`.`]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono`,children:s.link}),(0,Y.jsx)(ke,{value:s.link,label:`Copy invite link`,size:`xs`,variant:`outline`,showText:!0})]})]})]})}function Q(e){return e.displayName||e.handle}function Pt({from:e,users:t,onClose:n,onHandOver:r}){let[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(!1),c=t.filter(t=>t.id!==e?.id&&t.status===`active`),l=c.find(e=>e.id===i);async function u(){if(!(!e||!l)){s(!0);try{await r(e,l)}finally{s(!1)}a(``)}}return(0,Y.jsx)(ee,{open:e!==null,onOpenChange:e=>{e||(a(``),n())},children:(0,Y.jsxs)(T,{className:`max-w-md`,children:[(0,Y.jsxs)(w,{children:[(0,Y.jsxs)(E,{className:`text-sm`,children:[`Hand over `,e?Q(e):``,`'s agents`]}),(0,Y.jsxs)(S,{children:[`Every agent `,e?Q(e):``,` owns moves to the person you pick. They become its principal and can restart or stop it.`]})]}),(0,Y.jsxs)(C,{children:[(0,Y.jsx)(O,{htmlFor:`handover-target`,className:`mb-1.5`,children:`New owner`}),(0,Y.jsxs)(N,{value:i,onValueChange:a,children:[(0,Y.jsx)(A,{id:`handover-target`,className:`w-full`,"aria-label":`New owner`,children:(0,Y.jsx)(k,{placeholder:`Pick a person`})}),(0,Y.jsx)(j,{children:c.map(e=>(0,Y.jsxs)(M,{value:e.id,children:[Q(e),` (`,e.handle,`)`]},e.id))})]})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(R,{size:`sm`,disabled:!l||o,onClick:()=>void u(),children:`Hand over`})})]})})}function Ft(){let e=s(e=>e.users),t=s(e=>e.agents),n=s(e=>e.fetchUsers),r=s(e=>e.fetchAgents),i=s(e=>e.sessionUser?.id??`default`),[a,o]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(null),m=(0,J.useMemo)(()=>{let e=new Map;for(let n of t)n.principalUserId&&e.set(n.principalUserId,(e.get(n.principalUserId)??0)+1);return e},[t]);(0,J.useEffect)(()=>{n()},[n]);async function h(e,t){d(e.id),o(``),l(``);try{let e=await t();e&&l(e)}catch(e){o(e.message)}finally{d(``)}}let g=(e,t)=>h(e,async()=>{await y(`PATCH`,`/users/${encodeURIComponent(e.id)}`,t),await n()}),_=e=>h(e,async()=>{let{revoked:t}=await y(`DELETE`,`/users/${encodeURIComponent(e.id)}/sessions`);return`${Q(e)} is signed out everywhere (${t} ${t===1?`token`:`tokens`} revoked).`});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(kt,{}),(0,Y.jsx)(q,{size:`sm`,"data-testid":`users-admin`,children:(0,Y.jsxs)(G,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:`People`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Invite people and manage their access. Changing a role or suspending someone signs them out.`})]}),(0,Y.jsx)(Nt,{onError:o}),a&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-3.5`}),(0,Y.jsx)(`span`,{children:a})]}),c&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:c}),(0,Y.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>{let t=e.id===i,n=e.status!==`active`,r=u===e.id,a=m.get(e.id)??0;return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2`,"data-testid":`user-row-${e.handle}`,children:[(0,Y.jsx)(Ae,{user:e,distinct:!0,className:`size-7`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[Q(e),t&&(0,Y.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:`(you)`})]}),(0,Y.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.handle}),a>0&&(0,Y.jsxs)(`span`,{children:[` · `,a,` `,a===1?`agent`:`agents`]})]})]}),n&&(0,Y.jsx)(z,{variant:`outline`,className:`text-tone-warning-fg`,children:`Suspended`}),(0,Y.jsx)(Mt,{value:e.role,onChange:t=>void g(e,{role:t}),label:`Role for ${e.handle}`,disabled:t||r}),(0,Y.jsx)(R,{size:`sm`,variant:`outline`,disabled:t||r,onClick:()=>void g(e,{status:n?`active`:`suspended`}),children:n?`Reactivate`:`Suspend`}),(0,Y.jsxs)(ae,{children:[(0,Y.jsx)(ne,{asChild:!0,children:(0,Y.jsx)(R,{size:`sm`,variant:`ghost`,className:`px-2`,disabled:r,"aria-label":`More actions for ${e.handle}`,children:(0,Y.jsx)(D,{className:`size-4`})})}),(0,Y.jsxs)(te,{align:`end`,children:[(0,Y.jsx)(re,{disabled:t,onSelect:()=>void _(e),children:`Sign out everywhere`}),(0,Y.jsx)(re,{onSelect:()=>p(e),children:`Hand over agents…`})]})]})]},e.id)})}),(0,Y.jsx)(Ot,{})]})}),(0,Y.jsx)(Pt,{from:f,users:e,onClose:()=>p(null),onHandOver:(e,t)=>h(e,async()=>{let{agentIds:n}=await y(`POST`,`/users/${encodeURIComponent(e.id)}/handover`,{toUserId:t.id});return p(null),await r(),`${n.length} ${n.length===1?`agent`:`agents`} moved from ${Q(e)} to ${Q(t)}.`})})]})}var It=5,Lt=15;function Rt(e){return Math.round(e/6e4)}function zt(e){return`${Rt(e)} min`}function Bt({canWrite:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[c,d]=(0,J.useState)(null);(0,J.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await y(`GET`,`/providers/quota-config?stored=1`);e||n(t)}catch(t){e||i(t.message)}})(),()=>{e=!0}},[]);async function f(e,t){n(n=>({...n??{},[e]:t})),o(``),d(e);try{let r=await y(`PUT`,`/providers/${e}/quota-config`,t);n(t=>({...t??{},[e]:r}))}catch(t){o(`${u(e)}: ${t.message}`)}finally{d(null)}}let p=t?Object.keys(t).sort():[],m=s(e=>e.providerCatalog);return(0,Y.jsxs)(`section`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:`Quota`}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Per-provider quota collection and display. `,(0,Y.jsx)(`strong`,{children:`Enabled`}),` governs collection (disabled stops polling — no API calls);`,(0,Y.jsx)(`strong`,{children:` Show in widget`}),` governs display only.`]})]}),r&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4`}),(0,Y.jsx)(`span`,{children:r})]}),a&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4`}),(0,Y.jsx)(`span`,{children:a})]}),!t&&!r&&(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsxs)(G,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(I,{className:`size-4 animate-spin`}),`Loading quota config…`]})}),p.map(r=>{let i=t[r],a=!e||c===r;return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsxs)(K,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(ye,{className:`size-4`}),u(r),c===r&&(0,Y.jsx)(I,{className:`size-3 animate-spin text-muted-foreground`})]}),(0,Y.jsxs)(H,{className:`text-xs`,children:[i.enabled?`Polled every ${zt(i.pollIntervalMs)}`:`Collection disabled`,i.enabled&&!i.showInWidget?` · hidden from widget`:``,m.find(e=>e.provider===r)?.disabled?` · provider disabled: not polled or shown`:``]})]}),(0,Y.jsxs)(G,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Enabled`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Collect quota for this provider. Off stops all polling (no API calls, no token spend).`})]}),(0,Y.jsx)(P,{checked:i.enabled,disabled:a,onCheckedChange:e=>void f(r,{...i,enabled:e})})]}),(0,Y.jsxs)(`div`,{className:`rounded-md border bg-muted/20 p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Polling interval`}),(0,Y.jsx)(z,{variant:`outline`,className:`tabular-nums`,children:zt(i.pollIntervalMs)})]}),(0,Y.jsx)(`input`,{type:`range`,min:It,max:Lt,step:1,value:Rt(i.pollIntervalMs),disabled:a||!i.enabled,onChange:e=>{let t=Number(e.target.value)*6e4;n(e=>({...e??{},[r]:{...i,pollIntervalMs:t}}))},onPointerUp:e=>void f(r,{...i,pollIntervalMs:Number(e.target.value)*6e4}),onKeyUp:e=>void f(r,{...i,pollIntervalMs:Number(e.target.value)*6e4}),className:`w-full accent-primary disabled:opacity-50`}),(0,Y.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[It,` min`]}),(0,Y.jsxs)(`span`,{children:[Lt,` min`]})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Show in quota widget`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Display only. Off hides this provider from the dashboard widget; collection continues if enabled.`})]}),(0,Y.jsx)(P,{checked:i.showInWidget,disabled:a,onCheckedChange:e=>void f(r,{...i,showInWidget:e})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Burn-rate sparkline`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Show a mini utilization chart per window in the expanded widget.`})]}),(0,Y.jsx)(P,{checked:i.sparklineEnabled??!0,disabled:a,onCheckedChange:e=>void f(r,{...i,sparklineEnabled:e})})]}),(0,Y.jsxs)(`div`,{className:`rounded-md border bg-muted/20 p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Sparkline range`}),(0,Y.jsxs)(z,{variant:`outline`,className:`tabular-nums`,children:[i.sparklineRangeHours??8,`h`]})]}),(0,Y.jsx)(`input`,{type:`range`,min:1,max:8,step:1,value:i.sparklineRangeHours??8,disabled:a||!(i.sparklineEnabled??!0),onChange:e=>{let t=Number(e.target.value);n(e=>({...e??{},[r]:{...i,sparklineRangeHours:t}}))},onPointerUp:e=>void f(r,{...i,sparklineRangeHours:Number(e.target.value)}),onKeyUp:e=>void f(r,{...i,sparklineRangeHours:Number(e.target.value)}),className:`w-full accent-primary disabled:opacity-50`}),(0,Y.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:`1h`}),(0,Y.jsx)(`span`,{children:`8h`})]})]}),l(r)&&(0,Y.jsxs)(`div`,{className:`rounded-md border bg-muted/20 p-3 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Auto-fire banked reset`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Automatically consume a scarce banked reset when 7d usage nears exhaustion. Off by default.`})]}),(0,Y.jsx)(P,{checked:i.autoFireResetEnabled??!1,disabled:a,onCheckedChange:e=>void f(r,{...i,autoFireResetEnabled:e})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:`Trigger threshold`}),(0,Y.jsxs)(z,{variant:`outline`,className:`tabular-nums`,children:[Math.round((i.autoFireResetThreshold??.99)*100),`%`]})]}),(0,Y.jsx)(`input`,{type:`range`,min:90,max:100,step:1,value:Math.round((i.autoFireResetThreshold??.99)*100),disabled:a||!(i.autoFireResetEnabled??!1),onChange:e=>{let t=Number(e.target.value)/100;n(e=>({...e??{},[r]:{...i,autoFireResetThreshold:t}}))},onPointerUp:e=>void f(r,{...i,autoFireResetThreshold:Number(e.target.value)/100}),onKeyUp:e=>void f(r,{...i,autoFireResetThreshold:Number(e.target.value)/100}),className:`w-full accent-primary disabled:opacity-50`}),(0,Y.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:`90%`}),(0,Y.jsx)(`span`,{children:`100%`})]})]})]})]})]},r)})]})}function Vt(e,t){return y(`PUT`,`/routing-policy`,e,{headers:{"If-Match":`"${t}"`}})}function Ht({message:e}){return(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsx)(`span`,{children:e})]})}var Ut=f(),Wt={cautionAt:.15,avoidLargeAt:.5,hardAvoidAt:1},Gt=3,Kt=.99,qt=.5;function Jt(e,t){return((e??t)*100).toFixed(0)}function Yt(e){let t=e.trim();if(!t)return null;let n=Number(t);return!Number.isFinite(n)||n<0||n>100?null:n/100}function Xt(e){return String(Number(e.toFixed(2)))}function Zt(e,t){return String(e??t)}function Qt(e){let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function $t(e,t){return e.trim()?Yt(e):t}function en({policy:e,revision:t,canWrite:n,onPolicy:r}){let i=e.quotaBands,a=e.providerQuota??{},[o,s]=(0,J.useState)(Zt(i?.cautionAt,Wt.cautionAt)),[c,l]=(0,J.useState)(Zt(i?.avoidLargeAt,Wt.avoidLargeAt)),[d,f]=(0,J.useState)(Zt(i?.hardAvoidAt,Wt.hardAvoidAt)),[p,m]=(0,J.useState)(()=>{let e={};for(let t of Ut){let n=a[t]??{};e[t]={backstop:Jt(n.hardBackstopUtilization,Kt),floor:Jt(n.burnPenaltyUtilizationFloor,qt)}}return e}),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(``);async function C(){let n=Qt(o),i=Qt(c),a=Qt(d);if(n===null){S(`Caution cutoff must be a burn-penalty value of 0 or more.`);return}if(i===null){S(`Avoid-large cutoff must be a burn-penalty value of 0 or more.`);return}if(a===null){S(`Hard-avoid cutoff must be a burn-penalty value of 0 or more.`);return}if(n>=i){S(`Caution must be less than avoid-large.`);return}if(i>=a){S(`Avoid-large must be less than hard-avoid.`);return}let s={};for(let e of Ut){let t=p[e],n=$t(t.backstop,Kt),r=Yt(t.floor);if(n===null){S(`${u(e)}: hard-backstop must be 0–100%.`);return}if(r===null){S(`${u(e)}: burn-penalty floor must be 0–100%.`);return}s[e]={hardBackstopUtilization:n,burnPenaltyUtilizationFloor:r}}S(``),g(!0),v(``),b(!1);try{r(await Vt({...e,quotaBands:{cautionAt:n,avoidLargeAt:i,hardAvoidAt:a},providerQuota:s},t)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){v(e.message)}finally{g(!1)}}function w(e,t){m(n=>({...n,[e]:{...n[e],...t}})),S(``),b(!1)}function T(){S(``),b(!1)}return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{className:`text-sm`,children:`Quota thresholds`}),(0,Y.jsx)(H,{className:`text-xs`,children:`Band cutoffs act on the burn penalty (0–3): how early a provider would hit its limit at the current pace, times the window weight (3 for the 7-day window). They are not utilization percentages, so a band can fire well below the utilization shown. The hard backstop below is the real utilization gate.`})]}),(0,Y.jsxs)(G,{className:`space-y-4`,children:[(_||x)&&(0,Y.jsx)(Ht,{message:_||x}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Band cutoffs (burn penalty, 0–`,Gt,`)`]}),(0,Y.jsx)(rn,{caution:Number(o),avoidLarge:Number(c),hardAvoid:Number(d)}),(0,Y.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,Y.jsx)(an,{label:`Caution at`,hint:`Default: ${Wt.cautionAt}`,value:o,disabled:!n||h,onChange:e=>{s(e),T()}}),(0,Y.jsx)(an,{label:`Avoid-large at`,hint:`Default: ${Wt.avoidLargeAt}`,value:c,disabled:!n||h,onChange:e=>{l(e),T()}}),(0,Y.jsx)(an,{label:`Hard-avoid at`,hint:`Default: ${Wt.hardAvoidAt}`,value:d,disabled:!n||h,onChange:e=>{f(e),T()}})]})]}),Ut.map(e=>{let t=p[e];return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[u(e),` overrides`]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsx)(on,{label:`Hard-backstop utilization`,hint:`0 = disable backstop (never block on this quota); blank uses the ${(Kt*100).toFixed(0)}% default.`,value:t.backstop,disabled:!n||h,onChange:t=>w(e,{backstop:t})}),(0,Y.jsx)(on,{label:`Burn-penalty floor`,hint:`Penalties suppressed below this. Default: ${(qt*100).toFixed(0)}%`,value:t.floor,disabled:!n||h,onChange:t=>w(e,{floor:t})})]})]},e)}),n&&(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void C(),disabled:h,children:[h?(0,Y.jsx)(I,{className:`size-4 animate-spin`}):(0,Y.jsx)(L,{className:`size-4`}),y?`Saved`:`Save thresholds`]})]})]})}var tn=.9;function nn({policy:e,revision:t,canWrite:n,onPolicy:r}){let[i,a]=(0,J.useState)(e.apiOverflow?.enabled??!1),[o,s]=(0,J.useState)(Jt(e.apiOverflow?.weeklyUtilizationAt,tn)),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1);async function m(){let n=$t(o,tn);if(n===null||n===0){d(`Weekly threshold must be 1–100%.`);return}l(!0),d(``),p(!1);try{r(await Vt({...e,apiOverflow:{enabled:i,weeklyUtilizationAt:n}},t)),p(!0),setTimeout(()=>p(!1),2e3)}catch(e){d(e.message)}finally{l(!1)}}return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{className:`text-sm`,children:`Claude API overflow`}),(0,Y.jsx)(H,{className:`text-xs`,children:`Spends API credits instead of waiting for the weekly reset. Applies only to unpinned Claude work when every Claude subscription is near its weekly limit, a ready host offers Claude API, and the monthly budget has room.`})]}),(0,Y.jsxs)(G,{className:`space-y-3`,children:[u&&(0,Y.jsx)(Ht,{message:u}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(P,{checked:i,disabled:!n||c,size:`sm`,"aria-label":`Enable Claude API overflow`,onCheckedChange:e=>{a(e),d(``),p(!1)}}),`Route to Claude API when subscriptions run low`]}),(0,Y.jsx)(`div`,{className:`max-w-xs`,children:(0,Y.jsx)(on,{label:`Weekly near-limit threshold`,hint:`Default: ${(tn*100).toFixed(0)}%`,value:o,disabled:!n||c,onChange:e=>{s(e),d(``),p(!1)}})}),n&&(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void m(),disabled:c,children:[c?(0,Y.jsx)(I,{className:`size-4 animate-spin`}):(0,Y.jsx)(L,{className:`size-4`}),f?`Saved`:`Save overflow`]})]})]})}function rn({caution:e,avoidLarge:n,hardAvoid:r}){let i=e=>Math.max(0,Math.min(Gt,Number.isFinite(e)?e:0)),a=i(e),o=Math.max(a,i(n)),s=Math.max(o,i(r)),c=Xt,l=(e,t)=>`${(t-e)/Gt*100}%`,u=[{key:`normal`,label:`normal`,color:`bg-tone-success`,from:0,to:a,range:`0–${c(a)}`},{key:`caution`,label:`caution`,color:`bg-tone-warning`,from:a,to:o,range:`${c(a)}–${c(o)}`},{key:`avoid-large`,label:`avoid large`,color:`bg-tone-orange`,from:o,to:s,range:`${c(o)}–${c(s)}`},{key:`hard-avoid`,label:`hard avoid`,color:`bg-tone-danger`,from:s,to:Gt,range:`≥ ${c(s)}`}];return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-muted`,role:`img`,"aria-label":`Quota burn-penalty bands from 0 to ${Gt}`,children:u.map(e=>(0,Y.jsx)(`div`,{className:t(e.color,`transition-[width] duration-300`),style:{width:l(e.from,e.to)},title:`${e.label} · penalty ${e.range}`},e.key))}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-[10px] text-muted-foreground`,children:u.map(e=>(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:t(`size-2 shrink-0 rounded-full`,e.color)}),e.label,` `,(0,Y.jsx)(`span`,{className:`tabular-nums text-foreground/70`,children:e.range})]},e.key))})]})}function an({label:e,hint:t,value:n,disabled:r,onChange:i}){return(0,Y.jsxs)(`label`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:e}),(0,Y.jsx)(B,{value:n,onChange:e=>i(e.target.value),disabled:r,inputMode:`decimal`,className:`h-8 text-xs tabular-nums`}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:t})]})}function on({label:e,hint:t,value:n,disabled:r,onChange:i}){return(0,Y.jsxs)(`label`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:e}),(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(B,{value:n,onChange:e=>i(e.target.value),disabled:r,className:`h-8 pr-6 text-xs tabular-nums`}),(0,Y.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:`%`})]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:t})]})}function sn(){let[e,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1);async function d(e=!1){if(!(l&&!e)){i(!0),o(``);try{let[e,t]=await Promise.all([y(`GET`,`/routing-policy`),y(`GET`,`/agent-profiles/coordinator`).catch(()=>null)]);n({policy:e.policy,profile:t}),u(!0)}catch(e){o(e.message)}finally{i(!1)}}}let f=()=>d(!0);function p(){let e=!s;c(e),e&&!l&&d()}return(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:p,children:[(0,Y.jsx)(ve,{className:`size-4 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold`,children:`What your coordinator knows`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Active routing policy + coordinator profile instructions (read-only)`})]}),s?(0,Y.jsx)(he,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Y.jsx)(ge,{className:`size-4 shrink-0 text-muted-foreground`})]}),s&&(0,Y.jsxs)(`div`,{className:`space-y-4 pt-1`,children:[(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>void f(),disabled:r,children:[(0,Y.jsx)(we,{className:t(`size-3.5`,r&&`animate-spin`)}),`Refresh`]})}),a&&(0,Y.jsx)(Ht,{message:a}),r&&!e&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-2`,children:[(0,Y.jsx)(I,{className:`size-3.5 animate-spin`}),`Loading…`]}),e&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(cn,{policy:e.policy}),e.profile?(0,Y.jsx)(un,{profile:e.profile}):(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Coordinator profile not found.`})]})]})]})})}function cn({policy:e}){let n=e.quotaBands,r=e.providerQuota??{};return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Active routing policy`}),e.rules.length===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`No routing preferences — dispatch policy and quota bands decide.`}):(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-border text-xs`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-px bg-border text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:[(0,Y.jsx)(`div`,{className:`bg-muted/40 px-2 py-1.5`,children:`Match`}),(0,Y.jsx)(`div`,{className:`bg-muted/40 px-2 py-1.5`,children:`Preference`}),(0,Y.jsx)(`div`,{className:`bg-muted/40 px-2 py-1.5`,children:`Status`})]}),e.rules.map(e=>(0,Y.jsxs)(`div`,{className:t(`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-px bg-border`,e.enabled===!1&&`opacity-50`),children:[(0,Y.jsxs)(`div`,{className:`bg-card px-2 py-1.5`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:e.label??e.id}),(0,Y.jsx)(`div`,{className:`font-mono`,children:Object.entries(e.match).map(([e,t])=>`${e}=${Array.isArray(t)?t.join(`|`):t}`).join(`, `)||`all work`})]}),(0,Y.jsxs)(`div`,{className:`bg-card px-2 py-1.5`,children:[e.prefer?.length?(0,Y.jsxs)(`div`,{children:[`prefer `,e.prefer.join(`, `)]}):null,e.avoid?.length?(0,Y.jsxs)(`div`,{className:`text-muted-foreground`,children:[`avoid `,e.avoid.join(`, `)]}):null]}),(0,Y.jsx)(`div`,{className:`bg-card px-2 py-1.5`,children:e.enabled===!1?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`disabled`}):(0,Y.jsx)(`span`,{className:`text-tone-success-fg`,children:`active`})})]},e.id))]}),(n||Object.keys(r).length>0)&&(0,Y.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 text-xs space-y-1`,children:[n&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`burn penalty:`}),n.cautionAt!==void 0&&(0,Y.jsxs)(`span`,{children:[`caution ≥ `,Xt(n.cautionAt)]}),n.avoidLargeAt!==void 0&&(0,Y.jsxs)(`span`,{children:[`avoid-large ≥ `,Xt(n.avoidLargeAt)]}),n.hardAvoidAt!==void 0&&(0,Y.jsxs)(`span`,{children:[`hard-avoid ≥ `,Xt(n.hardAvoidAt)]})]}),Object.entries(r).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5 text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:u(e)}),t?.hardBackstopUtilization!==void 0&&(0,Y.jsxs)(`span`,{children:[`backstop: `,(t.hardBackstopUtilization*100).toFixed(0),`%`]}),t?.burnPenaltyUtilizationFloor!==void 0&&(0,Y.jsxs)(`span`,{children:[`floor: `,(t.burnPenaltyUtilizationFloor*100).toFixed(0),`%`]})]},e))]})]})}function ln({text:e,index:t}){return(0,Y.jsxs)(`div`,{className:`relative max-h-72 overflow-y-auto rounded-md border border-border bg-muted/20`,children:[t!==void 0&&(0,Y.jsxs)(`span`,{className:`sticky top-0 float-right m-1.5 rounded bg-muted px-1.5 py-0.5 text-[9px] font-medium tabular-nums text-muted-foreground`,children:[`#`,t]}),(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words px-3 py-2.5 font-sans text-[11px] leading-relaxed text-foreground/90`,children:e})]})}function un({profile:e}){return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[`Coordinator profile instructions`,(0,Y.jsx)(z,{variant:`secondary`,className:`ml-2 text-[10px]`,children:e.name}),e.builtIn&&(0,Y.jsx)(z,{variant:`outline`,className:`ml-1 text-[10px]`,children:`built-in`})]}),e.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[10px]`,children:[(0,Y.jsxs)(z,{variant:`outline`,children:[`base: `,e.base]}),(0,Y.jsxs)(z,{variant:`outline`,children:[`repo: `,e.instructions.repoInstructions]}),(0,Y.jsxs)(z,{variant:`outline`,children:[`global: `,e.instructions.globalInstructions]}),e.provider&&(0,Y.jsxs)(z,{variant:`outline`,children:[`provider: `,e.provider]})]}),e.instructions.system&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`System prompt`}),(0,Y.jsx)(ln,{text:e.instructions.system})]}),e.instructions.append.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:[`Appended instructions (`,e.instructions.append.length,`)`]}),e.instructions.append.map((e,t)=>(0,Y.jsx)(ln,{text:e,index:t+1},t))]}),e.instructions.append.length===0&&!e.instructions.system&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`No instruction blocks defined.`})]})}function dn({policy:e,revision:t,canWrite:n,onPolicy:r}){let[i,a]=(0,J.useState)(e.apiExpiry?.enabled??!1),[o,s]=(0,J.useState)(e.subscriptionExpiry?.enabled??!1),[c,l]=(0,J.useState)(String((e.apiExpiry?.leadTimeMs??6048e5)/36e5)),[u,d]=(0,J.useState)(String((e.subscriptionExpiry?.leadTimeMs??1728e5)/36e5)),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(``);async function g(){let n=Number(c),a=Number(u);if(!Number.isFinite(n)||n<=0||n>744||!Number.isFinite(a)||a<=0||a>168){h(`API lead must be 0–744 hours and subscription lead 0–168 hours, both greater than zero.`);return}p(!0),h(``);try{r(await Vt({...e,apiExpiry:{enabled:i,leadTimeMs:n*36e5},subscriptionExpiry:{enabled:o,leadTimeMs:a*36e5}},t)),h(`Saved`)}catch(e){h(e.message)}finally{p(!1)}}return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{className:`text-sm`,children:`Use expiring quota`}),(0,Y.jsx)(H,{className:`text-xs`,children:`Use subscription quota before its weekly reset. Pace unused API credits toward monthly expiry only when subscriptions cannot take the work. Pins and the hard dollar budget still win.`})]}),(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(P,{"aria-label":`Enable subscription expiry routing`,checked:o,disabled:!n||f,onCheckedChange:s}),`Prefer subscription quota approaching reset`]}),(0,Y.jsxs)(`label`,{className:`block text-xs`,children:[`Subscription lead (hours)`,(0,Y.jsx)(B,{"aria-label":`Subscription lead (hours)`,type:`number`,min:`0`,max:`168`,value:u,disabled:!n||f,onChange:e=>d(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(P,{"aria-label":`Enable API credit expiry routing`,checked:i,disabled:!n||f,onCheckedChange:a}),`Spend unused monthly API credits gradually`]}),(0,Y.jsxs)(`label`,{className:`block text-xs`,children:[`API credit lead (hours)`,(0,Y.jsx)(B,{"aria-label":`API credit lead (hours)`,type:`number`,min:`0`,max:`744`,value:c,disabled:!n||f,onChange:e=>l(e.target.value)})]}),m&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs`,children:m}),n&&(0,Y.jsx)(R,{size:`sm`,disabled:f,onClick:()=>void g(),children:f?`Saving…`:`Save expiry routing`})]})]})}var fn=1e6,pn=e=>String(e/fn),mn=e=>new Date(e).toISOString().slice(0,16),hn=e=>new Date(e).toISOString().slice(0,10);function gn({canWrite:e,budgetId:t=`claude-api`}){let n=t===`openai-api`,r=n?`/api-budgets/${t}`:`/claude-api-budget`,i=n?`platform.openai.com`:`platform.claude.com`,[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!0),[l,u]=(0,J.useState)(n?`100`:`200`),[d,f]=(0,J.useState)(`0`),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(!1),[b,x]=(0,J.useState)(``);function S(e){o(e),!(!e.baselineKnown||e.startsAt===void 0||e.endsAt===void 0)&&(c(e.enabled),u(pn(e.ceilingMicroUsd??200*fn)),f(pn(e.baselineMicroUsd??0)),m(n?mn(e.startsAt):hn(e.startsAt)),g(mn(e.endsAt)))}(0,J.useEffect)(()=>{let e=!0;return y(`GET`,`${r}/summary`).then(t=>{e&&S(t)}).catch(t=>{e&&x(t.message)}),()=>{e=!1}},[r]);async function C(){let e=Math.round(Number(l)*fn),t=Math.round(Number(d)*fn),i=Date.parse(n?`${p}:00Z`:`${p}T00:00:00Z`),o=Date.parse(`${h}:00Z`);if(!a||!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<0||!Number.isFinite(i)||!Number.isFinite(o)){x(`Enter an amount, spent so far, grant date and expiry.`);return}v(!0),x(``);try{S(await y(`POST`,r,{month:a.month,enabled:s,baselineMicroUsd:t,ceilingMicroUsd:e,grantedAt:i,endsAt:o,...a.marginMicroUsd===void 0?{}:{marginMicroUsd:a.marginMicroUsd},...a.allowanceMicroUsd===void 0?{}:{allowanceMicroUsd:a.allowanceMicroUsd}})),x(`Saved`)}catch(e){x(e.message)}finally{v(!1)}}let w=!e||_||!a;return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{className:`text-sm`,children:n?`OpenAI API credit grant`:`Claude API credit grant`}),(0,Y.jsxs)(H,{className:`text-xs`,children:[`The budget window and expiry pacing follow this grant, not the calendar month. Changing the grant date starts a fresh ledger with Already spent as its baseline. Copy the verified amount and expiry from `,i,`. Without a grant the window is the UTC calendar month. After expiry new input waits for a configured window. Active work drains.`]})]}),(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(P,{"aria-label":`Enable ${t} budget`,checked:s,disabled:w,onCheckedChange:c}),`Allow `,t,` spend within this grant`]}),(0,Y.jsxs)(`label`,{className:`block text-xs`,children:[`Grant amount (USD)`,(0,Y.jsx)(B,{"aria-label":`Grant amount (USD)`,type:`number`,min:`0`,step:`0.01`,value:l,disabled:w,onChange:e=>u(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`block text-xs`,children:[`Already spent (USD)`,(0,Y.jsx)(B,{"aria-label":`Already spent (USD)`,type:`number`,min:`0`,step:`0.01`,value:d,disabled:w,onChange:e=>f(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`block text-xs`,children:[n?`Granted (UTC)`:`Granted (UTC date)`,(0,Y.jsx)(B,{"aria-label":n?`Granted (UTC)`:`Granted (UTC date)`,type:n?`datetime-local`:`date`,value:p,disabled:w,onChange:e=>m(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`block text-xs`,children:[`Expires (UTC)`,(0,Y.jsx)(B,{"aria-label":`Expires (UTC)`,type:`datetime-local`,value:h,disabled:w,onChange:e=>g(e.target.value)})]}),b&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs`,children:b}),e&&(0,Y.jsx)(R,{size:`sm`,disabled:w,onClick:()=>void C(),children:_?`Saving…`:`Save credit grant`})]})]})}var _n=f(),$=`*`,vn=`keep`,yn=`Prefer this provider over quota bands until the expiry. Blocked, exhausted or unavailable providers are still excluded.`;function bn(){return{id:``,label:``,type:$,complexity:$,prefer:[],avoid:[],require:[],expires:``,enabled:!0}}function xn(e){return Array.isArray(e)?vn:e??$}var Sn=e=>String(e).padStart(2,`0`);function Cn(e){if(e===void 0)return``;let t=new Date(e);return`${t.getFullYear()}-${Sn(t.getMonth()+1)}-${Sn(t.getDate())}T${Sn(t.getHours())}:${Sn(t.getMinutes())}`}function wn(e){return{id:e.id,label:e.label??``,type:xn(e.match.type),complexity:xn(e.match.complexity),prefer:e.prefer??[],avoid:e.avoid??[],require:e.require??[],expires:Cn(e.expiresAt),enabled:e.enabled!==!1}}function Tn(e){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`rule`}-${Math.random().toString(36).slice(2,8)}`}function En(e,t){let n={...t?.match??{}};e.type!==vn&&(delete n.type,e.type!==$&&(n.type=e.type)),e.complexity!==vn&&(delete n.complexity,e.complexity!==$&&(n.complexity=e.complexity));let r=e.expires===Cn(t?.expiresAt)?t?.expiresAt:e.expires?new Date(e.expires).getTime():void 0;return{id:e.id||Tn(e.label),...e.label.trim()?{label:e.label.trim()}:{},match:n,...e.prefer.length?{prefer:e.prefer}:{},...e.avoid.length?{avoid:e.avoid}:{},...e.require.length?{require:e.require}:{},...r!==void 0&&Number.isFinite(r)?{expiresAt:r}:{},enabled:e.enabled}}var Dn={label:`Label`,type:`Work type`,complexity:`Complexity`,prefer:`Prefer`,avoid:`Avoid`,require:`Require`,expires:`Expiry`,enabled:`Enabled`},On=Object.keys(Dn),kn=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function An(e,t,n,r={}){let i=wn(e),a=wn(t),o={...a},s=[];for(let e of On){let t=!kn(n[e],i[e]),c=!kn(a[e],i[e]);!t||kn(n[e],a[e])||(!c||r[e]===`mine`?o[e]=n[e]:r[e]!==`theirs`&&s.push({key:e,mine:n[e],theirs:a[e]}))}return{form:o,conflicts:s}}function jn(e){return!e.prefer.length&&!e.avoid.length&&!e.require.length?`Prefer, avoid or require at least one provider.`:e.expires&&!Number.isFinite(new Date(e.expires).getTime())?`Enter a valid expiry date and time.`:null}function Mn({message:e}){return(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsx)(`span`,{children:e})]})}function Nn({label:e,value:n,blocked:r=[],disabled:i,onChange:a}){return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:e}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:_n.map(e=>{let o=n.includes(e);return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":o,disabled:r.includes(e),onClick:()=>a(o?n.filter(t=>t!==e):[...n,e]),className:t(`rounded border px-2 py-0.5 text-[11px] disabled:opacity-30`,o?`border-primary bg-primary/10 text-foreground`:`border-border text-muted-foreground hover:bg-accent`),children:[u(e),i.has(e)?` (disabled)`:``]},e)})})]})}function Pn(e){return Array.isArray(e)?(0,Y.jsxs)(M,{value:vn,className:`text-xs`,children:[e.join(` or `),` (unchanged)`]}):null}function Fn({form:e,original:t,error:n,disabledProviders:r,onChange:i,onSave:a,onCancel:o,isNew:s}){function c(t){i({...e,...t})}return(0,Y.jsxs)(`div`,{className:`space-y-3 rounded-md border border-primary/30 bg-primary/5 p-3`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:s?`New preference`:`Edit ${e.id}`}),(0,Y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Label (optional)`}),(0,Y.jsx)(B,{value:e.label,onChange:e=>c({label:e.target.value}),placeholder:`e.g. Prefer Codex for builds`,className:`h-8 text-xs`})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Work type`}),(0,Y.jsxs)(N,{value:e.type,onValueChange:e=>c({type:e}),children:[(0,Y.jsx)(A,{className:`h-8 text-xs`,children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[Pn(t?.match.type),(0,Y.jsx)(M,{value:$,className:`text-xs`,children:`any`}),h.map(e=>(0,Y.jsx)(M,{value:e,className:`text-xs`,children:e},e))]})]})]}),(0,Y.jsxs)(`label`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Complexity`}),(0,Y.jsxs)(N,{value:e.complexity,onValueChange:e=>c({complexity:e}),children:[(0,Y.jsx)(A,{className:`h-8 text-xs`,children:(0,Y.jsx)(k,{})}),(0,Y.jsxs)(j,{children:[Pn(t?.match.complexity),(0,Y.jsx)(M,{value:$,className:`text-xs`,children:`any`}),g.map(e=>(0,Y.jsx)(M,{value:e,className:`text-xs`,children:e},e))]})]})]})]}),(0,Y.jsx)(Nn,{label:`Prefer`,value:e.prefer,blocked:e.avoid,disabled:r,onChange:e=>c({prefer:e})}),(0,Y.jsx)(Nn,{label:`Avoid (ranks lower, never excludes)`,value:e.avoid,blocked:e.prefer,disabled:r,onChange:e=>c({avoid:e})}),(0,Y.jsx)(Nn,{label:`Require (only these providers may run matching work)`,value:e.require,disabled:r,onChange:e=>c({require:e})}),(0,Y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Use spare quota until…`}),(0,Y.jsx)(B,{type:`datetime-local`,"aria-label":`Use spare quota until…`,value:e.expires,onChange:e=>c({expires:e.target.value}),className:`h-8 text-xs`}),(0,Y.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:e.expires?yn:`Optional. Without an expiry the preference only ranks providers within a quota band.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(P,{checked:e.enabled,onCheckedChange:e=>c({enabled:e})}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Enabled`})]}),n&&(0,Y.jsx)(Mn,{message:n}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsxs)(R,{size:`sm`,onClick:a,children:[(0,Y.jsx)(L,{className:`size-4`}),s?`Add`:`Save`]}),(0,Y.jsx)(R,{size:`sm`,variant:`outline`,onClick:o,children:`Cancel`})]})]})}function In(e){let t=Object.entries(e.match).map(([e,t])=>`${e}=${Array.isArray(t)?t.join(`|`):t}`);return t.length?t.join(`, `):`all work`}function Ln(e){return e.status===412}function Rn(e,n,r){return(n??[]).map(n=>(0,Y.jsxs)(z,{variant:`outline`,className:t(`text-[10px]`,e===`avoid`?`text-tone-yellow-fg`:`text-tone-success-fg`),children:[e,` `,n,r.has(n)?` (disabled${r.get(n)?`: ${r.get(n)}`:``})`:``]},`${e}-${n}`))}function zn({policy:e,revision:n,diagnostics:r,providerCatalog:i=[],now:a=Date.now(),canWrite:o,onPolicy:s,onReload:c}){let[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(``),y=p===n,b=new Map(i.filter(e=>e.disabled).map(e=>[e.provider,e.disabled?.reason??e.disabled?.source??``])),x=new Set(b.keys());async function S(t){u(!0),f(``);try{s(await Vt({...e,rules:t},n)),g(null),m(null)}catch(e){Ln(e)&&m(n),f(e.message)}finally{u(!1)}}async function C(){f(``),await c?.()}function w(e){g({id:e?.id??null,...e?{original:e}:{},form:e?wn(e):bn(),choices:{}}),v(``)}let T=h?.id==null?void 0:e.rules.find(e=>e.id===h.id),E=h?.original&&T?An(h.original,T,h.form,h.choices):null;function ee(){if(!h)return;let t=jn(E?.form??h.form);if(t){v(t);return}if(E?.conflicts.length){v(`Choose which value to keep for the fields another editor also changed.`);return}let n=En(E?.form??h.form,T??h.original);S(e.rules.some(e=>e.id===n.id)?e.rules.map(e=>e.id===n.id?n:e):[...e.rules,n])}let D=(r??e.migration)?.notes??[],te=e=>Array.isArray(e)?e.join(`, `)||`none`:String(e===``?`none`:e),ne=(e,t)=>h&&(0,Y.jsxs)(Y.Fragment,{children:[E&&E.conflicts.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-2 rounded-md border border-tone-yellow/30 bg-tone-yellow/10 p-3 text-xs`,"data-testid":`routing-merge-conflicts`,children:[(0,Y.jsxs)(`div`,{className:`font-medium`,children:[`Another editor also changed `,h.id]}),E.conflicts.map(({key:e,mine:t,theirs:n})=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-24 text-muted-foreground`,children:Dn[e]}),(0,Y.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>g({...h,choices:{...h.choices,[e]:`mine`}}),children:[`Keep mine: `,te(t)]}),(0,Y.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>g({...h,choices:{...h.choices,[e]:`theirs`}}),children:[`Use theirs: `,te(n)]})]},e))]}),(0,Y.jsx)(Fn,{form:h.form,original:t,error:_,disabledProviders:x,isNew:e,onChange:e=>g({...h,form:e}),onSave:ee,onCancel:()=>{g(null),m(null)}},h.id??`new`)]});return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsxs)(K,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(Te,{className:`size-4`}),`Routing preferences`,(0,Y.jsxs)(z,{variant:`outline`,className:`ml-auto text-[10px]`,children:[e.rules.length,` rule`,e.rules.length===1?``:`s`]}),l&&(0,Y.jsx)(I,{className:`size-3 animate-spin text-muted-foreground`})]}),(0,Y.jsx)(H,{className:`text-xs`,children:`For matching work, prefer, avoid or require providers. Every matching enabled rule counts. The dispatcher still picks the provider, model and effort from the work shape and live quota: a preference ranks providers within a quota band, and disabled providers drop out on their own. Explicit spawn pins still win.`})]}),(0,Y.jsxs)(G,{className:`space-y-2`,children:[d&&!y&&(0,Y.jsx)(Mn,{message:d}),y&&(0,Y.jsxs)(`div`,{className:`space-y-2 rounded-md border border-tone-yellow/30 bg-tone-yellow/10 p-3 text-xs`,"data-testid":`routing-conflict-banner`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:`The routing policy changed elsewhere.`}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:h?`Your draft is kept. Reload the latest policy, then save to apply your draft on top of it.`:`Reload the latest policy and repeat your change.`}),(0,Y.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void C(),children:`Reload latest`})]}),D.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-1 rounded-md border border-tone-yellow/30 bg-tone-yellow/10 p-3 text-xs`,"data-testid":`routing-migration-banner`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,Y.jsx)(pe,{className:`size-3.5`}),`Converted from v1 routing rules`]}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`Converted rules start disabled. Model and effort now come from the work-shape dispatch policy.`}),(0,Y.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4 text-muted-foreground`,children:D.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]}),e.rules.length===0&&!h&&(0,Y.jsx)(`div`,{className:`rounded-md border border-dashed border-border py-6 text-center text-xs text-muted-foreground`,children:`No preferences — the dispatch policy and quota bands decide alone.`}),e.rules.map(n=>{if(h?.id===n.id)return(0,Y.jsx)(J.Fragment,{children:ne(!1,n)},n.id);let r=n.expiresAt!==void 0&&n.expiresAt<=a,i=n.enabled!==!1&&!r&&!!n.prefer?.length&&n.prefer.every(e=>x.has(e));return(0,Y.jsxs)(`div`,{className:t(`group flex items-start gap-3 rounded-md border bg-muted/20 p-3`,(n.enabled===!1||r)&&`opacity-60`),children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n.label&&(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:n.label}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:n.id}),Rn(`prefer`,n.prefer,b),Rn(`avoid`,n.avoid,b),Rn(`require`,n.require,b),n.expiresAt!==void 0&&(0,Y.jsxs)(z,{variant:`outline`,className:t(`text-[10px]`,r?`text-tone-yellow-fg`:`text-tone-success-fg`),children:[r?`expired`:`until`,` `,new Date(n.expiresAt).toLocaleString()]}),i&&(0,Y.jsx)(z,{variant:`outline`,className:`text-[10px] text-tone-yellow-fg`,children:`dormant: preferred providers are disabled`})]}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[`match: `,(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:In(n)})]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Y.jsx)(P,{checked:n.enabled!==!1,disabled:!o||l,onCheckedChange:t=>void S(e.rules.map(e=>e.id===n.id?{...e,enabled:t}:e)),title:n.enabled===!1?`Enable rule`:`Disable rule`}),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,title:`Edit`,onClick:()=>w(n),disabled:l,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground disabled:pointer-events-none`,children:(0,Y.jsx)(xe,{className:`size-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,title:`Remove`,onClick:()=>void S(e.rules.filter(e=>e.id!==n.id)),disabled:l,className:`rounded p-1 text-destructive hover:bg-destructive/10 disabled:pointer-events-none`,children:(0,Y.jsx)(Ee,{className:`size-3.5`})})]})]})]},n.id)}),h&&h.id!==null&&!e.rules.some(e=>e.id===h.id)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[h.id,` was removed in the latest policy. Saving adds it back.`]}),ne(!1,h.original)]}),h?.id===null&&ne(!0),o&&!h&&(0,Y.jsxs)(R,{variant:`outline`,size:`sm`,className:`w-full gap-1`,onClick:()=>w(),disabled:l,children:[(0,Y.jsx)(Se,{className:`size-4`}),`Add preference`]})]})]})}var Bn=[`provider`,`model`,`effort`,`orchestratorId`,`profile`],Vn=e=>e===`orchestratorId`?`Host`:e[0].toUpperCase()+e.slice(1),Hn=`h-8 w-full rounded-md border bg-background px-2 text-xs`;function Un({policy:e,revision:t,teams:n,canWrite:r,onPolicy:i}){let[a,o]=(0,J.useState)(e.stepDefaults??{}),[s,c]=(0,J.useState)(`global`),[l,d]=(0,J.useState)(``),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(!1),_=(s===`global`?a.global:a.teams?.[s])??{},v=[...new Set([`builder`,`reviewer`,...Object.keys(_),...Object.keys(a.global??{})])],y=[...new Set([...n.map(e=>e.id),...Object.keys(a.teams??{})])];function b(e){o(s===`global`?{...a,global:e}:{...a,teams:{...a.teams,[s]:e}}),m(``)}function x(e,t,n){let r={..._[e],[t]:n||void 0};t===`provider`&&n!==_[e]?.provider&&(r.model=void 0,r.effort=void 0),b({..._,[e]:r})}async function S(){g(!0),m(``);try{let n=await Vt({...e,stepDefaults:a},t);o(n.policy.stepDefaults??{}),i(n),m(`Saved`)}catch(e){m(e.message)}finally{g(!1)}}return(0,Y.jsxs)(q,{size:`sm`,children:[(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{className:`text-sm`,children:`Workflow role defaults`}),(0,Y.jsx)(H,{className:`text-xs`,children:`Call pins override team defaults, then global defaults, workflow and role definitions, then automatic dispatch. Blank fields inherit. Changes apply to new runs.`})]}),(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsxs)(`label`,{className:`block text-xs`,children:[`Scope`,(0,Y.jsxs)(`select`,{"aria-label":`Routing defaults scope`,className:Hn,value:s,onChange:e=>c(e.target.value),children:[(0,Y.jsx)(`option`,{value:`global`,children:`Global`}),y.map(e=>(0,Y.jsx)(`option`,{value:e,children:n.find(t=>t.id===e)?.title??e},e))]})]}),(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`text-left`,children:`Role`}),Bn.map(e=>(0,Y.jsx)(`th`,{className:`min-w-28 text-left`,children:Vn(e)},e))]})}),(0,Y.jsx)(`tbody`,{children:v.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`pr-2 text-left font-medium`,children:e}),Bn.map(t=>(0,Y.jsx)(`td`,{className:`p-1`,children:t===`provider`?(0,Y.jsxs)(`select`,{"aria-label":`${e} Provider`,className:Hn,disabled:!r||h,value:_[e]?.provider??``,onChange:n=>x(e,t,n.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`Inherit`}),f().map(e=>(0,Y.jsx)(`option`,{value:e,children:u(e)},e))]}):(0,Y.jsx)(B,{"aria-label":`${e} ${Vn(t)}`,className:`h-8 text-xs`,value:_[e]?.[t]??``,placeholder:s===`global`?`Inherit`:a.global?.[e]?.[t]??`Inherit`,disabled:!r||h,onChange:n=>x(e,t,n.target.value)})},t))]},e))})]})}),r&&(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(B,{"aria-label":`New routing role`,placeholder:`Project role`,value:l,disabled:h,onChange:e=>d(e.target.value)}),(0,Y.jsx)(R,{size:`sm`,variant:`outline`,disabled:h||!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(l)||v.includes(l),onClick:()=>{b({..._,[l]:{}}),d(``)},children:`Add role`}),(0,Y.jsx)(R,{size:`sm`,disabled:h,onClick:()=>void S(),children:h?`Saving…`:`Save role defaults`})]}),p&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs`,children:p})]})]})}function Wn({message:e}){return(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsx)(`span`,{children:e})]})}function Gn({canWrite:e,canWriteBudget:n=!1}){let[r,a]=(0,J.useState)(null),o=r?.policy,c=s(e=>e.providerCatalog),l=s(e=>e.teams),u=i(6e4),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(0);!h&&!d&&!p&&(f(!0),(async()=>{try{let e=await y(`GET`,`/routing-policy`);a(e),g(!0)}catch(e){m(e.message)}finally{f(!1)}})());async function b(){f(!0),m(``);try{let e=await y(`GET`,`/routing-policy`);a(e),v(e=>e+1),g(!0)}catch(e){m(e.message)}finally{f(!1)}}return(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:`Routing`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Routing preferences steer automatic spawns, Task dispatch and workflow steps; the dispatch policy picks model and effort. Explicit per-spawn pins always take precedence.`})]}),(0,Y.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>void b(),disabled:d,children:[(0,Y.jsx)(we,{className:t(`size-4`,d&&`animate-spin`)}),`Refresh`]})]}),p&&(0,Y.jsx)(Wn,{message:p}),d&&!o&&(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsxs)(G,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(I,{className:`size-4 animate-spin`}),`Loading routing policy…`]})}),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Un,{policy:o,revision:r.revision,teams:l,canWrite:e,onPolicy:a},_),(0,Y.jsx)(zn,{policy:o,revision:r.revision,diagnostics:r.diagnostics,providerCatalog:c,now:u,canWrite:e,onPolicy:a,onReload:b}),(0,Y.jsx)(en,{policy:o,revision:r.revision,canWrite:e,onPolicy:a}),(0,Y.jsx)(nn,{policy:o,revision:r.revision,canWrite:e,onPolicy:a}),(0,Y.jsx)(dn,{policy:o,revision:r.revision,canWrite:e,onPolicy:a},JSON.stringify([o.apiExpiry,o.subscriptionExpiry])),(0,Y.jsx)(gn,{canWrite:n}),(0,Y.jsx)(gn,{canWrite:n,budgetId:`openai-api`})]}),(0,Y.jsx)(sn,{})]})}var Kn=`browser`,qn=`models`,Jn=`profile`,Yn=`routing`,Xn=[`branch.landed`,`landed-failure`,`agent.ready`,`agent.exited`,`agent.spawn_failed`,`agent.context_threshold`,`agent.quota_threshold`,`workspace.steward_task`,`workspace.conflict`,`workspace.review_request`];function Zn(){if(typeof window>`u`)return``;let e=window.location.hash.replace(/^#/,``);return e.startsWith(`settings/`)?decodeURIComponent(e.slice(9)):``}function Qn(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=`settings/${encodeURIComponent(e)}`,window.history.pushState({},``,t)}function $n(){let[e,n]=(0,J.useState)([]),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)([]),c=s(e=>e.set),l=s(e=>e.teams),u=s(e=>e.fetchTeams),[d,f]=(0,J.useState)(()=>Zn()),[p,m]=(0,J.useState)(!0),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(``);async function b(){m(!0),g(``),v(``);try{let[e,t,r]=await Promise.all([y(`GET`,`/settings`),y(`GET`,`/tokens/me`),y(`GET`,`/providers`).catch(e=>(v(e.message),{catalog:[]})),u()]);n(e.settings),i(t),o(r.catalog)}catch(e){g(e.message)}finally{m(!1)}}(0,J.useEffect)(()=>{b()},[]),(0,J.useEffect)(()=>{let e=()=>f(Zn());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let x=(0,J.useMemo)(()=>Re(e),[e]),S=(0,J.useMemo)(()=>[...x.map(e=>({slug:e.slug,label:e.group,description:`${e.settings.length} schema setting${e.settings.length===1?``:`s`}`,kind:`descriptors`,settings:e.settings})),{slug:`service-access`,label:`Service access`,description:`Profile services and Vault application`,kind:`service-access`,settings:[]},{slug:Yn,label:`Routing`,description:`Rules, quota thresholds, coordinator view`,kind:`routing`,settings:[]},{slug:Jn,label:`Profile`,description:`Display name and avatar`,kind:`profile`,settings:[]},{slug:Kn,label:`Browser`,description:`Local dashboard preferences`,kind:`browser`,settings:[]},{slug:qn,label:`Models`,description:`Provider model catalog`,kind:`models`,settings:[]}],[x]),C=S.find(e=>e.slug===d)??S[0];function w(e){f(e),Qn(e)}function T(e){n(t=>t.map(t=>Fe(t)===Fe(e)?e:t))}let E=C?.kind===`descriptors`?C.settings.find(e=>e.namespace===`idle-digest`&&e.key==="default"):void 0,ee=C?.kind===`descriptors`?C.settings.find(e=>e.namespace===`agent-prefs`&&e.key==="default"):void 0,D=C?.kind===`descriptors`?C.settings.find(e=>e.namespace===`notification-prefs`&&e.key==="default"):void 0,te=C?.kind===`descriptors`?C.settings.filter(e=>e!==E&&e!==ee&&e!==D):[];return(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Schema-driven Relay settings, browser preferences, and model catalog controls.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r&&(0,Y.jsxs)(z,{variant:`outline`,className:`gap-1`,children:[(0,Y.jsx)(le,{className:`size-3`}),r.kind,`:`,r.actor]}),(0,Y.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>void b(),disabled:p,children:[(0,Y.jsx)(we,{className:t(`size-4`,p&&`animate-spin`)}),`Refresh`]})]})]}),h&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4`}),(0,Y.jsx)(`span`,{children:h})]}),(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[230px_minmax(0,1fr)]`,children:[(0,Y.jsx)(`nav`,{className:`space-y-1 lg:sticky lg:top-4 lg:self-start`,children:S.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:t(`w-full rounded-md border px-3 py-2 text-left text-sm transition-colors`,C?.slug===e.slug?`border-primary/50 bg-primary/10 text-foreground`:`border-transparent hover:border-border hover:bg-accent`),onClick:()=>w(e.slug),children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,Y.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.description})]},e.slug))}),(0,Y.jsx)(`div`,{className:`min-w-0 space-y-4`,children:p&&!e.length?(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsx)(G,{className:`text-sm text-muted-foreground`,children:`Loading settings…`})}):C?.kind===`service-access`?(0,Y.jsx)(ue,{}):C?.kind===`routing`?(0,Y.jsx)(Gn,{canWrite:Ne(r?.scopes,`settings:write:routing`),canWriteBudget:Ne(r?.scopes,`system:admin`)}):C?.kind===`descriptors`?(0,Y.jsxs)(Y.Fragment,{children:[ee&&(0,Y.jsx)(Tt,{setting:ee,onSaved:T}),D&&(0,Y.jsx)(Dt,{setting:D,onSaved:T}),(0,Y.jsx)(Qe,{group:C.label,settings:te,onSaved:T}),C.label===`Users`&&Ne(r?.scopes,`system:admin`)&&(0,Y.jsx)(Ft,{}),E&&(0,Y.jsx)(yt,{setting:E,teams:l,onSaved:T},`${E.version}-${E.updatedAt}`),C.label===`Providers`&&(0,Y.jsx)(Bt,{canWrite:Ne(r?.scopes,`settings:write:provider`)}),C.label===`Notifications`&&(0,Y.jsx)(er,{})]}):C?.kind===`profile`?(0,Y.jsx)(tr,{}):C?.kind===`browser`?(0,Y.jsx)(rt,{}):(0,Y.jsx)(st,{catalog:a,error:_,canWrite:Ne(r?.scopes,`settings:write:provider`),onCatalog:e=>{o(e),c({providerCatalog:e})}})})]})]})}function er(){let[e,t]=(0,J.useState)(`branch.landed`),[n,r]=(0,J.useState)(`{
|
|
4
4
|
"repoRoot": "/repo"
|
|
5
5
|
}`),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(``);async function u(){s(!0),l(``);try{let t=JSON.parse(n);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Scope must be a JSON object`);let r=await y(`POST`,`/notifications/preview`,{type:e,scope:t});a(r.preview)}catch(e){a(null),l(e.message)}finally{s(!1)}}return(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsxs)(G,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Who gets what`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Dry-run notification routing without sending.`})]}),(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void u(),disabled:o,children:[(0,Y.jsx)(Te,{className:`size-4`}),`Preview`]})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Type`}),(0,Y.jsxs)(N,{value:e,onValueChange:t,children:[(0,Y.jsx)(A,{className:`w-full`,children:(0,Y.jsx)(k,{})}),(0,Y.jsx)(j,{children:Xn.map(e=>(0,Y.jsx)(M,{value:e,children:e},e))})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Scope`}),(0,Y.jsx)(V,{value:n,onChange:e=>r(e.target.value),rows:4,className:`font-mono text-xs`})]})]}),c&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-3.5`}),(0,Y.jsx)(`span`,{children:c})]}),i&&(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-md border border-border`,children:i.recipients.length===0?(0,Y.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No recipients`}):i.recipients.map(e=>(0,Y.jsxs)(`div`,{className:`grid gap-1 border-b border-border px-3 py-2 text-xs last:border-b-0 md:grid-cols-[minmax(0,180px)_minmax(0,160px)_minmax(0,1fr)]`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.recipient}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-muted-foreground`,children:e.matchedRule}),(0,Y.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.reason})]},`${e.recipient}-${e.matchedRule}`))})]})})}function tr(){let e=s(e=>e.fetchUsers),t=(0,J.useRef)(null),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(``),[o,c]=(0,J.useState)(!0),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``);async function p(){c(!0),f(``);try{let e=await y(`GET`,`/users/me`);r(e),a(e.displayName||e.handle)}catch(e){f(e.message)}finally{c(!1)}}(0,J.useEffect)(()=>{p()},[]);async function m(){u(!0),f(``);try{let t=await y(`PATCH`,`/users/me`,{displayName:i});r(t),a(t.displayName||t.handle),await e()}catch(e){f(e.message)}finally{u(!1)}}async function h(n){if(n){u(!0),f(``);try{let t=await _(`/users/me/avatar`,n);r(t.user),a(t.user.displayName||t.user.handle),await e()}catch(e){f(e.message)}finally{u(!1),t.current&&(t.current.value=``)}}}async function g(){u(!0),f(``);try{let t=await y(`DELETE`,`/users/me/avatar`);r(t),await e()}catch(e){f(e.message)}finally{u(!1)}}return(0,Y.jsx)(q,{size:`sm`,children:(0,Y.jsxs)(G,{className:`space-y-4`,children:[d&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4`}),(0,Y.jsx)(`span`,{children:d})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Y.jsx)(Ae,{user:n??void 0,distinct:!0,className:`size-16 text-lg`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`profile-display-name`,children:`Display name`}),(0,Y.jsx)(`input`,{id:`profile-display-name`,className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm`,value:i,onChange:e=>a(e.target.value),disabled:o||l,maxLength:120})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(R,{size:`sm`,onClick:()=>void m(),disabled:o||l||!i.trim(),children:[(0,Y.jsx)(L,{className:`size-4`}),`Save`]}),(0,Y.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>t.current?.click(),disabled:o||l,children:[(0,Y.jsx)(fe,{className:`size-4`}),`Upload`]}),(0,Y.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>void g(),disabled:o||l||!n?.avatarArtifactId,children:[(0,Y.jsx)(Ee,{className:`size-4`}),`Remove`]}),l&&(0,Y.jsx)(me,{className:`size-4 animate-pulse text-muted-foreground`}),(0,Y.jsx)(`input`,{ref:t,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,className:`hidden`,onChange:e=>void h(e.target.files?.[0])})]})]})})}export{$n as SettingsView};
|
|
6
|
-
//# sourceMappingURL=settings-
|
|
6
|
+
//# sourceMappingURL=settings-CKZTVGIx.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{p as t,u as n}from"./dist-DeW2Y1R5.js";import{a as r,c as i,l as a,o,s,t as c}from"./store-BvtFdlGX.js";import{h as l}from"./display-CfO7rTuF.js";import{t as u}from"./api-CIIVBtAV.js";import{i as d,r as f,t as p}from"./tabs-jZgNvNHr.js";import{a as m,c as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./warehouse-BanzOanY.js";import{t as S}from"./chevron-right-iljytE0x.js";import{t as C}from"./eye-BAP6fHrX.js";import{t as w}from"./gauge-BIODY-BQ.js";import{t as T}from"./hourglass-txu4ax6n.js";import{t as E}from"./lock-BW8MPKw_.js";import{t as D}from"./rocket-BmO1qSu-.js";import{n as O}from"./workflow-marker-Cf3Hf2fN.js";import{t as k}from"./button-Do6Z3vvn.js";import{t as A}from"./badge-DqJRtj_p.js";import{n as j}from"./agent-name-CTZBrSD9.js";import{t as M}from"./input-CsTB6jIx.js";import{t as N}from"./crate-agent-H6S7-B9T.js";import{t as P}from"./stats-V9Z-GxUd.js";var F=e(t(),1),I=n();function L({incident:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(``);async function s(){i(!0),o(``);try{await u(`POST`,`/shipping/incidents/${encodeURIComponent(e.incidentId)}/abandon`,{reason:t}),await c.getState().openShipping()}catch(e){o(e.message)}finally{i(!1)}}return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,I.jsxs)(A,{variant:`destructive`,title:`${e.remote} lane ${e.laneKey}, incident ${e.state}`,children:[e.mainFailurePolicy===`advisory`?`advisory: red main`:`lane stopped: red main`,` `,e.sha.slice(0,12),`, incident `,e.incidentId]}),(0,I.jsx)(M,{"aria-label":`Abandon reason for ${e.incidentId}`,placeholder:`Reason to abandon incident`,value:t,maxLength:1e3,onChange:e=>n(e.target.value)}),(0,I.jsx)(k,{size:`sm`,variant:`outline`,disabled:r||!t.trim(),onClick:s,children:`Abandon incident`}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.mainFailurePolicy===`advisory`?`Lands continue. Deployment waits for a successful product check.`:`Releases the lane stop. Red CI still blocks deployment.`}),a&&(0,I.jsx)(`span`,{role:`alert`,children:a})]})}function R({incidents:e}){return e?.length?(0,I.jsx)(`div`,{role:`alert`,"aria-label":`Red main`,className:`space-y-1.5`,children:e.map(e=>(0,I.jsx)(L,{incident:e},e.incidentId))}):null}var z={implementation:{label:`Implementation`,icon:v,hue:250},review:{label:`Review`,icon:C,hue:305},gates:{label:`Gates`,icon:g,hue:85},landing:{label:`Landing`,icon:m,hue:50},main:{label:`On main`,icon:x,hue:150},deploy:{label:`Deploy`,icon:D,hue:205},validated:{label:`Validated`,icon:h,hue:170}},B=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),V={done:`Done`,cd:`Relay CD`,steward:`Steward`,landing:`Relay landing`},H={builder:`Owner`,reviewer:`No reviewer yet · owner`,closer:`To close: owner`};function U({responsible:e}){let t=c(e=>e.agentsById);return(0,I.jsxs)(`span`,{"data-testid":`shipping-card-responsible`,className:`flex min-w-0 items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`shrink-0`,children:e.kind===`relay`?V[e.role]??V.landing:H[e.role]??`Owner`}),e.id?(0,I.jsx)(j,{target:e.id,agentsById:t,className:`font-medium`}):e.kind===`owner`&&(0,I.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`unassigned`})]})}var W=e=>e.kind===`relay`?e.role===`done`?`done`:`relay`:`agent`;function G({card:e,holder:t}){let{responsible:n}=e;if(n.kind===`relay`||!t){let e=n.kind===`relay`?n.role===`done`?h:b:_;return(0,I.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-1 text-xs`,title:n.id,children:[(0,I.jsx)(e,{className:`h-3.5 w-3.5 shrink-0`,style:{color:`var(--crate)`},"aria-hidden":!0}),(0,I.jsx)(U,{responsible:n})]})}return(0,I.jsxs)(`div`,{className:`mt-1 text-xs`,children:[(0,I.jsx)(N,{holder:t,prefix:t.id===n.id&&n.role===`reviewer`?`Review:`:void 0}),n.kind===`owner`&&(0,I.jsx)(`div`,{className:`pl-5 text-[11px] text-muted-foreground`,title:n.id,children:(0,I.jsx)(U,{responsible:n})})]})}function K({card:e,holder:t,now:n,maxTokens:i,project:a}){let o=c(e=>e.openTaskDetailById),s=c(t=>t.workflowLiveIndex.byTask[e.taskId]),u=e.tokens?.total??0;return(0,I.jsxs)(`li`,{"data-testid":`shipping-card-${e.taskId}`,"data-owner":W(e.responsible),"data-live":t?.live===!0,"data-workflow":s?s.kind:void 0,onClick:()=>o(e.taskId),className:`ship-crate cursor-pointer rounded-md px-2.5 py-2 text-sm motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-left-3 motion-safe:duration-300`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,I.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-1 font-mono text-[11px] tabular-nums text-muted-foreground`,children:[`T`,e.taskId]}),e.signals.reviewHold&&(0,I.jsx)(`span`,{"data-testid":`shipping-card-review-hold`,role:`img`,"aria-label":`Review hold`,title:`Review hold: a complete delivery parks for review`,className:`shrink-0 self-center`,children:(0,I.jsx)(E,{className:`h-3 w-3`,style:{color:`var(--crate)`},"aria-hidden":!0})}),(0,I.jsx)(`button`,{type:`button`,className:`truncate rounded text-left font-medium hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,title:e.title,children:e.title})]}),s&&(0,I.jsxs)(`div`,{"data-testid":`shipping-card-workflow`,className:`mt-1 flex min-w-0 items-center gap-1 text-[11px] font-medium`,children:[(0,I.jsx)(O,{workflow:s.workflow,step:s.step}),(0,I.jsx)(`span`,{className:`truncate`,title:`Workflow run ${s.runId}`,children:r(s)})]}),e.signals.staleOwnerGone&&(0,I.jsxs)(`div`,{"data-testid":`shipping-card-stale`,className:`mt-1 flex items-center gap-1 text-[11px] text-tone-warning-fg`,title:`In progress or blocked, no change for 7 days, and its builder agent is gone`,children:[(0,I.jsx)(T,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`truncate`,children:`Idle 7d+, builder gone`})]}),(0,I.jsx)(G,{card:e,holder:t}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,title:`Tokens spent on this Task`,children:[(0,I.jsx)(`div`,{className:`ship-meter h-1.5 min-w-0 flex-1 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,I.jsx)(`span`,{className:`block h-full rounded-full`,style:{width:`${i&&u?Math.max(4,u/i*100):0}%`}})}),(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-muted-foreground`,children:e.tokens?B.format(e.tokens.total):`—`})]}),(0,I.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,title:`In ${z[e.stage].label} since ${new Date(e.stageSince).toLocaleString()}`,children:[(0,I.jsxs)(`span`,{children:[`In stage `,l(n,e.stageSince)]}),a&&(0,I.jsx)(`span`,{className:`truncate`,"data-testid":`shipping-card-project`,children:a})]})]})}function q({ci:e,all:t}){return e.length?(0,I.jsxs)(`div`,{role:`group`,"aria-label":`CI`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,"aria-hidden":!0,children:`CI`}),e.map(e=>(0,I.jsxs)(A,{variant:e.status===`failing`?`destructive`:`secondary`,title:`CI workflow ${e.workflow} on ${e.branch}, observed ${new Date(e.observedAt).toLocaleString()}`,children:[(0,I.jsx)(`span`,{className:`ship-lamp h-2 w-2 shrink-0 rounded-full`,"data-status":e.status,"aria-hidden":!0}),t?`${e.repository} `:``,e.workflow,` on `,e.branch,`: `,e.status]},`${e.repository}:${e.branch}:${e.workflow}`))]}):(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t?`No CI watches`:`No CI watch for this project`})}function J({board:e}){let t=e.projectLanes.filter(e=>e.gates.length>0);return t.length?(0,I.jsx)(`ul`,{className:`mb-2 space-y-1`,"data-testid":`shipping-gate-names`,children:t.map(t=>(0,I.jsxs)(`li`,{className:`flex flex-wrap gap-1`,children:[e.all&&(0,I.jsx)(`span`,{className:`w-full truncate text-[11px] text-muted-foreground`,children:t.title}),t.gates.map(e=>(0,I.jsx)(A,{variant:`outline`,className:`px-1.5 py-0 font-mono text-[11px] font-normal`,children:e},e))]},t.projectId))}):null}function Y({label:e,value:t,testId:n}){return(0,I.jsxs)(`div`,{"data-testid":n,className:`ship-hud min-w-0 rounded-md px-2.5 py-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:e}),(0,I.jsx)(`div`,{className:`font-mono text-lg font-semibold tabular-nums leading-tight`,children:t})]})}function X({cards:e,agentsById:t,now:n}){let r=i(e,t,n);return(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-5`,"aria-label":`Board totals`,children:[(0,I.jsx)(Y,{testId:`shipping-hud-in-flight`,label:`In flight`,value:String(r.inFlight)}),(0,I.jsx)(Y,{testId:`shipping-hud-agents`,label:`With agents`,value:String(r.withAgents)}),(0,I.jsx)(Y,{testId:`shipping-hud-stale`,label:`No live agent`,value:String(r.withoutAgent)}),(0,I.jsx)(Y,{testId:`shipping-hud-relay`,label:`With Relay`,value:String(r.withRelay)}),(0,I.jsx)(Y,{testId:`shipping-hud-tokens`,label:`Tokens spent`,value:B.format(r.tokens)})]})}function Z({stage:e,cards:t,holders:n,board:r,projectTitles:i,now:a,maxTokens:s}){let[c,l]=(0,F.useState)(!1),u=o.includes(e),d=e=>u?!n.get(e.taskId)?.live:e.signals.staleOwnerGone===!0,f=t.filter(e=>!d(e)),p=t.filter(d),{label:m,icon:h,hue:g}=z[e],_=e=>(0,I.jsx)(K,{card:e,holder:n.get(e.taskId)??null,now:a,maxTokens:s,project:r.all?i.get(e.projectId??``):void 0},e.taskId);return(0,I.jsxs)(`section`,{"data-testid":`shipping-lane-${e}`,"data-empty":t.length===0,"aria-label":m,className:`ship-lane min-w-0 rounded-lg p-2`,style:{"--stage-hue":g},children:[(0,I.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-0.5 text-sm font-semibold`,children:[(0,I.jsx)(`span`,{className:`ship-lane-badge grid h-6 w-6 shrink-0 place-items-center rounded-md`,children:(0,I.jsx)(h,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,I.jsx)(`span`,{className:`truncate`,children:m}),(0,I.jsx)(`span`,{"data-testid":`shipping-lane-count-${e}`,className:`ml-auto rounded-full bg-background/70 px-1.5 font-mono text-xs tabular-nums text-muted-foreground`,children:f.length})]}),(0,I.jsx)(`div`,{className:`ship-belt my-2`,"aria-hidden":!0}),e===`gates`&&(0,I.jsx)(J,{board:r}),f.length>0&&(0,I.jsx)(`ul`,{className:`space-y-1.5`,children:f.map(_)}),t.length===0&&(0,I.jsx)(`p`,{className:`max-lg:hidden rounded-md border border-dashed border-border/70 px-2 py-3 text-center text-[11px] text-muted-foreground`,children:`Bay clear`}),p.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,"data-testid":`shipping-stale-toggle-${e}`,"aria-expanded":c,onClick:()=>l(!c),className:`mt-1.5 flex min-h-8 w-full items-center gap-1 rounded-md px-1.5 text-left text-xs text-muted-foreground hover:bg-background/60 hover:text-foreground`,children:[(0,I.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 ${c?`rotate-90`:``}`,"aria-hidden":!0}),p.length,` `,u?`without a live agent`:`idle, builder gone`]}),c&&(0,I.jsx)(`ul`,{"data-testid":`shipping-stale-${e}`,className:`mt-1 space-y-1.5 opacity-75`,children:p.map(_)})]})]})}function Q({board:e,agentsById:t,now:n}){let r=new Map(e.projectLanes.map(e=>[e.projectId,e.title])),a=new Map(e.tasks.map(e=>[e.taskId,s(e,t,n)])),{maxTokens:o}=i(e.tasks,t,n);return(0,I.jsx)(`div`,{className:`overflow-x-auto pb-2`,children:(0,I.jsx)(`div`,{className:`ship-floor grid gap-2 rounded-xl border border-border p-2 lg:min-w-[calc(var(--lanes)*9.5rem)] lg:grid-cols-[repeat(var(--lanes),minmax(0,1fr))]`,style:{"--lanes":e.lanes.length},children:e.lanes.map(t=>(0,I.jsx)(Z,{stage:t,cards:e.tasks.filter(e=>e.stage===t),holders:a,board:e,projectTitles:r,now:n,maxTokens:o},t))})})}function $(){let e=c(e=>e.shippingBoard),t=c(e=>e.agents),n=c(e=>e.agentsById),r=Date.now(),i=e?a(e,t,r):null,o=c(e=>e.shippingLoading),s=c(e=>e.shippingError),l=c(e=>e.setShippingProject),u=c(e=>e.shippingTab),m=c(e=>e.setShippingTab),h=c(e=>e.shippingStatsProjectId),g=c(e=>e.setShippingStatsProject),_=c(e=>e.setAnalyticsTab),v=c(e=>e.switchView);return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(y,{className:`h-5 w-5 text-muted-foreground`}),(0,I.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Shipping`})]}),(0,I.jsx)(p,{value:u,onValueChange:e=>m(e),children:(0,I.jsxs)(f,{children:[(0,I.jsx)(d,{value:`realtime`,children:`Realtime`}),(0,I.jsx)(d,{value:`stats`,children:`Statistics`})]})}),(0,I.jsxs)(`button`,{type:`button`,className:`ml-auto inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>{_(`gates`),v(`analytics`)},children:[(0,I.jsx)(w,{className:`h-3.5 w-3.5`}),` Gate statistics`]}),i&&i.projects.length>0&&(0,I.jsxs)(`select`,{"aria-label":`Project`,className:`h-8 max-w-full min-w-0 rounded-md border border-border bg-background px-2 text-sm`,value:u===`stats`?h:i.all?`*`:i.projectId??``,onChange:e=>u===`stats`?g(e.target.value):l(e.target.value),children:[u===`stats`?(0,I.jsx)(`option`,{value:``,children:`All projects`}):(0,I.jsx)(`option`,{value:`*`,children:`All projects`}),i.projects.map(e=>(0,I.jsx)(`option`,{value:e.id,children:u===`stats`?e.title:`${e.title} (${e.inFlight})`},e.id))]}),u===`realtime`&&i&&(0,I.jsx)(q,{ci:i.ci,all:i.all===!0}),u===`realtime`&&i&&(0,I.jsx)(R,{incidents:i.redMain})]}),u===`stats`&&(0,I.jsx)(P,{}),u===`realtime`&&s&&(0,I.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:[`Could not load the board: `,s]}),u===`realtime`&&!i&&o&&(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`Loading the board…`}),u===`realtime`&&i&&!i.projectId&&!i.all&&(0,I.jsx)(`div`,{className:`rounded-md border border-border px-3 py-12 text-center text-sm text-muted-foreground`,children:`No project has Tasks in progress.`}),u===`realtime`&&i&&(i.projectId||i.all)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X,{cards:i.tasks,agentsById:n,now:r}),(0,I.jsx)(Q,{board:i,agentsById:n,now:r})]})]})}export{$ as ShippingView};
|
|
2
|
-
//# sourceMappingURL=shipping-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{p as t,u as n}from"./dist-DeW2Y1R5.js";import{a as r,c as i,l as a,o,s,t as c}from"./store-DcClXLH0.js";import{h as l}from"./display-BrKWFGJz.js";import{t as u}from"./api-CIIVBtAV.js";import{i as d,r as f,t as p}from"./tabs-jZgNvNHr.js";import{a as m,c as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./warehouse-BanzOanY.js";import{t as S}from"./chevron-right-iljytE0x.js";import{t as C}from"./eye-BAP6fHrX.js";import{t as w}from"./gauge-BIODY-BQ.js";import{t as T}from"./hourglass-txu4ax6n.js";import{t as E}from"./lock-BW8MPKw_.js";import{t as D}from"./rocket-BmO1qSu-.js";import{n as O}from"./workflow-marker-DAZcj5qt.js";import{t as k}from"./button-Do6Z3vvn.js";import{t as A}from"./badge-DqJRtj_p.js";import{n as j}from"./agent-name-DKbiIhBo.js";import{t as M}from"./input-CsTB6jIx.js";import{t as N}from"./crate-agent-30aXTKva.js";import{t as P}from"./stats-DyUBKyWI.js";var F=e(t(),1),I=n();function L({incident:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(``);async function s(){i(!0),o(``);try{await u(`POST`,`/shipping/incidents/${encodeURIComponent(e.incidentId)}/abandon`,{reason:t}),await c.getState().openShipping()}catch(e){o(e.message)}finally{i(!1)}}return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,I.jsxs)(A,{variant:`destructive`,title:`${e.remote} lane ${e.laneKey}, incident ${e.state}`,children:[e.mainFailurePolicy===`advisory`?`advisory: red main`:`lane stopped: red main`,` `,e.sha.slice(0,12),`, incident `,e.incidentId]}),(0,I.jsx)(M,{"aria-label":`Abandon reason for ${e.incidentId}`,placeholder:`Reason to abandon incident`,value:t,maxLength:1e3,onChange:e=>n(e.target.value)}),(0,I.jsx)(k,{size:`sm`,variant:`outline`,disabled:r||!t.trim(),onClick:s,children:`Abandon incident`}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.mainFailurePolicy===`advisory`?`Lands continue. Deployment waits for a successful product check.`:`Releases the lane stop. Red CI still blocks deployment.`}),a&&(0,I.jsx)(`span`,{role:`alert`,children:a})]})}function R({incidents:e}){return e?.length?(0,I.jsx)(`div`,{role:`alert`,"aria-label":`Red main`,className:`space-y-1.5`,children:e.map(e=>(0,I.jsx)(L,{incident:e},e.incidentId))}):null}var z={implementation:{label:`Implementation`,icon:v,hue:250},review:{label:`Review`,icon:C,hue:305},gates:{label:`Gates`,icon:g,hue:85},landing:{label:`Landing`,icon:m,hue:50},main:{label:`On main`,icon:x,hue:150},deploy:{label:`Deploy`,icon:D,hue:205},validated:{label:`Validated`,icon:h,hue:170}},B=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),V={done:`Done`,cd:`Relay CD`,steward:`Steward`,landing:`Relay landing`},H={builder:`Owner`,reviewer:`No reviewer yet · owner`,closer:`To close: owner`};function U({responsible:e}){let t=c(e=>e.agentsById);return(0,I.jsxs)(`span`,{"data-testid":`shipping-card-responsible`,className:`flex min-w-0 items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`shrink-0`,children:e.kind===`relay`?V[e.role]??V.landing:H[e.role]??`Owner`}),e.id?(0,I.jsx)(j,{target:e.id,agentsById:t,className:`font-medium`}):e.kind===`owner`&&(0,I.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`unassigned`})]})}var W=e=>e.kind===`relay`?e.role===`done`?`done`:`relay`:`agent`;function G({card:e,holder:t}){let{responsible:n}=e;if(n.kind===`relay`||!t){let e=n.kind===`relay`?n.role===`done`?h:b:_;return(0,I.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-1 text-xs`,title:n.id,children:[(0,I.jsx)(e,{className:`h-3.5 w-3.5 shrink-0`,style:{color:`var(--crate)`},"aria-hidden":!0}),(0,I.jsx)(U,{responsible:n})]})}return(0,I.jsxs)(`div`,{className:`mt-1 text-xs`,children:[(0,I.jsx)(N,{holder:t,prefix:t.id===n.id&&n.role===`reviewer`?`Review:`:void 0}),n.kind===`owner`&&(0,I.jsx)(`div`,{className:`pl-5 text-[11px] text-muted-foreground`,title:n.id,children:(0,I.jsx)(U,{responsible:n})})]})}function K({card:e,holder:t,now:n,maxTokens:i,project:a}){let o=c(e=>e.openTaskDetailById),s=c(t=>t.workflowLiveIndex.byTask[e.taskId]),u=e.tokens?.total??0;return(0,I.jsxs)(`li`,{"data-testid":`shipping-card-${e.taskId}`,"data-owner":W(e.responsible),"data-live":t?.live===!0,"data-workflow":s?s.kind:void 0,onClick:()=>o(e.taskId),className:`ship-crate cursor-pointer rounded-md px-2.5 py-2 text-sm motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-left-3 motion-safe:duration-300`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,I.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-1 font-mono text-[11px] tabular-nums text-muted-foreground`,children:[`T`,e.taskId]}),e.signals.reviewHold&&(0,I.jsx)(`span`,{"data-testid":`shipping-card-review-hold`,role:`img`,"aria-label":`Review hold`,title:`Review hold: a complete delivery parks for review`,className:`shrink-0 self-center`,children:(0,I.jsx)(E,{className:`h-3 w-3`,style:{color:`var(--crate)`},"aria-hidden":!0})}),(0,I.jsx)(`button`,{type:`button`,className:`truncate rounded text-left font-medium hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,title:e.title,children:e.title})]}),s&&(0,I.jsxs)(`div`,{"data-testid":`shipping-card-workflow`,className:`mt-1 flex min-w-0 items-center gap-1 text-[11px] font-medium`,children:[(0,I.jsx)(O,{workflow:s.workflow,step:s.step}),(0,I.jsx)(`span`,{className:`truncate`,title:`Workflow run ${s.runId}`,children:r(s)})]}),e.signals.staleOwnerGone&&(0,I.jsxs)(`div`,{"data-testid":`shipping-card-stale`,className:`mt-1 flex items-center gap-1 text-[11px] text-tone-warning-fg`,title:`In progress or blocked, no change for 7 days, and its builder agent is gone`,children:[(0,I.jsx)(T,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`truncate`,children:`Idle 7d+, builder gone`})]}),(0,I.jsx)(G,{card:e,holder:t}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,title:`Tokens spent on this Task`,children:[(0,I.jsx)(`div`,{className:`ship-meter h-1.5 min-w-0 flex-1 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,I.jsx)(`span`,{className:`block h-full rounded-full`,style:{width:`${i&&u?Math.max(4,u/i*100):0}%`}})}),(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-muted-foreground`,children:e.tokens?B.format(e.tokens.total):`—`})]}),(0,I.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,title:`In ${z[e.stage].label} since ${new Date(e.stageSince).toLocaleString()}`,children:[(0,I.jsxs)(`span`,{children:[`In stage `,l(n,e.stageSince)]}),a&&(0,I.jsx)(`span`,{className:`truncate`,"data-testid":`shipping-card-project`,children:a})]})]})}function q({ci:e,all:t}){return e.length?(0,I.jsxs)(`div`,{role:`group`,"aria-label":`CI`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,"aria-hidden":!0,children:`CI`}),e.map(e=>(0,I.jsxs)(A,{variant:e.status===`failing`?`destructive`:`secondary`,title:`CI workflow ${e.workflow} on ${e.branch}, observed ${new Date(e.observedAt).toLocaleString()}`,children:[(0,I.jsx)(`span`,{className:`ship-lamp h-2 w-2 shrink-0 rounded-full`,"data-status":e.status,"aria-hidden":!0}),t?`${e.repository} `:``,e.workflow,` on `,e.branch,`: `,e.status]},`${e.repository}:${e.branch}:${e.workflow}`))]}):(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t?`No CI watches`:`No CI watch for this project`})}function J({board:e}){let t=e.projectLanes.filter(e=>e.gates.length>0);return t.length?(0,I.jsx)(`ul`,{className:`mb-2 space-y-1`,"data-testid":`shipping-gate-names`,children:t.map(t=>(0,I.jsxs)(`li`,{className:`flex flex-wrap gap-1`,children:[e.all&&(0,I.jsx)(`span`,{className:`w-full truncate text-[11px] text-muted-foreground`,children:t.title}),t.gates.map(e=>(0,I.jsx)(A,{variant:`outline`,className:`px-1.5 py-0 font-mono text-[11px] font-normal`,children:e},e))]},t.projectId))}):null}function Y({label:e,value:t,testId:n}){return(0,I.jsxs)(`div`,{"data-testid":n,className:`ship-hud min-w-0 rounded-md px-2.5 py-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:e}),(0,I.jsx)(`div`,{className:`font-mono text-lg font-semibold tabular-nums leading-tight`,children:t})]})}function X({cards:e,agentsById:t,now:n}){let r=i(e,t,n);return(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-5`,"aria-label":`Board totals`,children:[(0,I.jsx)(Y,{testId:`shipping-hud-in-flight`,label:`In flight`,value:String(r.inFlight)}),(0,I.jsx)(Y,{testId:`shipping-hud-agents`,label:`With agents`,value:String(r.withAgents)}),(0,I.jsx)(Y,{testId:`shipping-hud-stale`,label:`No live agent`,value:String(r.withoutAgent)}),(0,I.jsx)(Y,{testId:`shipping-hud-relay`,label:`With Relay`,value:String(r.withRelay)}),(0,I.jsx)(Y,{testId:`shipping-hud-tokens`,label:`Tokens spent`,value:B.format(r.tokens)})]})}function Z({stage:e,cards:t,holders:n,board:r,projectTitles:i,now:a,maxTokens:s}){let[c,l]=(0,F.useState)(!1),u=o.includes(e),d=e=>u?!n.get(e.taskId)?.live:e.signals.staleOwnerGone===!0,f=t.filter(e=>!d(e)),p=t.filter(d),{label:m,icon:h,hue:g}=z[e],_=e=>(0,I.jsx)(K,{card:e,holder:n.get(e.taskId)??null,now:a,maxTokens:s,project:r.all?i.get(e.projectId??``):void 0},e.taskId);return(0,I.jsxs)(`section`,{"data-testid":`shipping-lane-${e}`,"data-empty":t.length===0,"aria-label":m,className:`ship-lane min-w-0 rounded-lg p-2`,style:{"--stage-hue":g},children:[(0,I.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-0.5 text-sm font-semibold`,children:[(0,I.jsx)(`span`,{className:`ship-lane-badge grid h-6 w-6 shrink-0 place-items-center rounded-md`,children:(0,I.jsx)(h,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,I.jsx)(`span`,{className:`truncate`,children:m}),(0,I.jsx)(`span`,{"data-testid":`shipping-lane-count-${e}`,className:`ml-auto rounded-full bg-background/70 px-1.5 font-mono text-xs tabular-nums text-muted-foreground`,children:f.length})]}),(0,I.jsx)(`div`,{className:`ship-belt my-2`,"aria-hidden":!0}),e===`gates`&&(0,I.jsx)(J,{board:r}),f.length>0&&(0,I.jsx)(`ul`,{className:`space-y-1.5`,children:f.map(_)}),t.length===0&&(0,I.jsx)(`p`,{className:`max-lg:hidden rounded-md border border-dashed border-border/70 px-2 py-3 text-center text-[11px] text-muted-foreground`,children:`Bay clear`}),p.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,"data-testid":`shipping-stale-toggle-${e}`,"aria-expanded":c,onClick:()=>l(!c),className:`mt-1.5 flex min-h-8 w-full items-center gap-1 rounded-md px-1.5 text-left text-xs text-muted-foreground hover:bg-background/60 hover:text-foreground`,children:[(0,I.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 ${c?`rotate-90`:``}`,"aria-hidden":!0}),p.length,` `,u?`without a live agent`:`idle, builder gone`]}),c&&(0,I.jsx)(`ul`,{"data-testid":`shipping-stale-${e}`,className:`mt-1 space-y-1.5 opacity-75`,children:p.map(_)})]})]})}function Q({board:e,agentsById:t,now:n}){let r=new Map(e.projectLanes.map(e=>[e.projectId,e.title])),a=new Map(e.tasks.map(e=>[e.taskId,s(e,t,n)])),{maxTokens:o}=i(e.tasks,t,n);return(0,I.jsx)(`div`,{className:`overflow-x-auto pb-2`,children:(0,I.jsx)(`div`,{className:`ship-floor grid gap-2 rounded-xl border border-border p-2 lg:min-w-[calc(var(--lanes)*9.5rem)] lg:grid-cols-[repeat(var(--lanes),minmax(0,1fr))]`,style:{"--lanes":e.lanes.length},children:e.lanes.map(t=>(0,I.jsx)(Z,{stage:t,cards:e.tasks.filter(e=>e.stage===t),holders:a,board:e,projectTitles:r,now:n,maxTokens:o},t))})})}function $(){let e=c(e=>e.shippingBoard),t=c(e=>e.agents),n=c(e=>e.agentsById),r=Date.now(),i=e?a(e,t,r):null,o=c(e=>e.shippingLoading),s=c(e=>e.shippingError),l=c(e=>e.setShippingProject),u=c(e=>e.shippingTab),m=c(e=>e.setShippingTab),h=c(e=>e.shippingStatsProjectId),g=c(e=>e.setShippingStatsProject),_=c(e=>e.setAnalyticsTab),v=c(e=>e.switchView);return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(y,{className:`h-5 w-5 text-muted-foreground`}),(0,I.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Shipping`})]}),(0,I.jsx)(p,{value:u,onValueChange:e=>m(e),children:(0,I.jsxs)(f,{children:[(0,I.jsx)(d,{value:`realtime`,children:`Realtime`}),(0,I.jsx)(d,{value:`stats`,children:`Statistics`})]})}),(0,I.jsxs)(`button`,{type:`button`,className:`ml-auto inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>{_(`gates`),v(`analytics`)},children:[(0,I.jsx)(w,{className:`h-3.5 w-3.5`}),` Gate statistics`]}),i&&i.projects.length>0&&(0,I.jsxs)(`select`,{"aria-label":`Project`,className:`h-8 max-w-full min-w-0 rounded-md border border-border bg-background px-2 text-sm`,value:u===`stats`?h:i.all?`*`:i.projectId??``,onChange:e=>u===`stats`?g(e.target.value):l(e.target.value),children:[u===`stats`?(0,I.jsx)(`option`,{value:``,children:`All projects`}):(0,I.jsx)(`option`,{value:`*`,children:`All projects`}),i.projects.map(e=>(0,I.jsx)(`option`,{value:e.id,children:u===`stats`?e.title:`${e.title} (${e.inFlight})`},e.id))]}),u===`realtime`&&i&&(0,I.jsx)(q,{ci:i.ci,all:i.all===!0}),u===`realtime`&&i&&(0,I.jsx)(R,{incidents:i.redMain})]}),u===`stats`&&(0,I.jsx)(P,{}),u===`realtime`&&s&&(0,I.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:[`Could not load the board: `,s]}),u===`realtime`&&!i&&o&&(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`Loading the board…`}),u===`realtime`&&i&&!i.projectId&&!i.all&&(0,I.jsx)(`div`,{className:`rounded-md border border-border px-3 py-12 text-center text-sm text-muted-foreground`,children:`No project has Tasks in progress.`}),u===`realtime`&&i&&(i.projectId||i.all)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X,{cards:i.tasks,agentsById:n,now:r}),(0,I.jsx)(Q,{board:i,agentsById:n,now:r})]})]})}export{$ as ShippingView};
|
|
2
|
+
//# sourceMappingURL=shipping-B9YtnwtG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e,u as t}from"./dist-DeW2Y1R5.js";import{t as n}from"./store-
|
|
2
|
-
//# sourceMappingURL=stats-
|
|
1
|
+
import{o as e,u as t}from"./dist-DeW2Y1R5.js";import{t as n}from"./store-DcClXLH0.js";import{t as r}from"./badge-DqJRtj_p.js";import{a as i,i as a,n as o,r as s,t as c}from"./shipping-stats-BiMTsA4A.js";var l=t(),u=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),d=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`});function f({id:e,title:t,note:n,children:r}){return(0,l.jsxs)(`section`,{"data-testid":`shipping-stat-${e}`,"aria-label":t,className:`min-w-0 rounded-lg border border-border border-t-[3px] border-t-primary/60 bg-card p-3`,children:[(0,l.jsxs)(`h3`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium`,children:[t,n]}),(0,l.jsx)(`div`,{className:`mt-2 overflow-x-auto`,children:r})]})}function p({label:t,value:n,hint:r,className:i}){return(0,l.jsxs)(`div`,{className:e(`ship-hud min-w-0 rounded-md px-2.5 py-1.5`,i),children:[(0,l.jsx)(`div`,{className:`truncate text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:`font-mono text-lg font-semibold tabular-nums`,title:r,children:n})]})}function m({label:e,dist:t,format:n}){let r=e=>e===null?`—`:n(e);return(0,l.jsxs)(`tr`,{className:`border-t border-border/60 first:border-t-0`,children:[(0,l.jsx)(`th`,{scope:`row`,className:`py-1 pr-2 text-left font-normal`,children:e}),(0,l.jsx)(`td`,{className:`px-1.5 py-1 text-right tabular-nums`,children:r(t.p50)}),(0,l.jsx)(`td`,{className:`px-1.5 py-1 text-right tabular-nums`,children:r(t.p90)}),(0,l.jsx)(`td`,{className:`py-1 pl-1.5 text-right tabular-nums text-muted-foreground`,children:t.count})]})}function h({rows:e,format:t,unit:n=`Tasks`}){return(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-[11px] text-muted-foreground`,children:[(0,l.jsx)(`th`,{className:`text-left font-normal`}),(0,l.jsx)(`th`,{className:`px-1.5 text-right font-normal`,children:`p50`}),(0,l.jsx)(`th`,{className:`px-1.5 text-right font-normal`,children:`p90`}),(0,l.jsx)(`th`,{className:`pl-1.5 text-right font-normal`,children:n})]})}),(0,l.jsx)(`tbody`,{children:e.map(e=>(0,l.jsx)(m,{...e,format:t},e.label))})]})}function g({label:e,rate:t}){return(0,l.jsx)(p,{label:e,value:o(t.rate),hint:`${t.firstPass} of ${t.total}`})}function _({stats:e}){let t=e.throughput.days,n=Math.max(1,...t.map(e=>e.landed));return(0,l.jsx)(`ul`,{"aria-label":`Landed per day`,className:`mt-2 flex h-14 items-end gap-0.5`,children:t.map(e=>(0,l.jsx)(`li`,{className:`flex h-full min-w-0 flex-1 items-end`,title:`${d.format(e.day)}: ${e.landed} landed, ${e.deployed} deployed, ${e.validated} validated`,children:(0,l.jsx)(`span`,{className:`block w-full rounded-sm bg-primary/70`,style:{height:`${e.landed?Math.max(6,e.landed/n*100):0}%`}})},e.day))})}var v=e=>u.format(e),y=.5;function b({counted:t,landed:n}){let r=n>0&&t/n<y;return(0,l.jsxs)(`p`,{"data-testid":`shipping-tokens-coverage`,className:e(`mt-1 text-[11px]`,r?`text-tone-warning-fg`:`text-muted-foreground`),children:[t,` of `,n,` landed Tasks have recorded token totals (`,o(n?t/n:null),`).`,r?` Too few to stand for the window.`:``]})}function x({stats:e}){let{throughput:t,leadTimeMs:n,tokensPerLanded:a,waitMs:c,gateTimeMs:u,failingGates:d,landOutcomes:m,firstPass:y,deploys:x}=e,S=Object.entries(m).sort((e,t)=>t[1]-e[1]),C=i[e.window]>1&&t.days.length>0;return(0,l.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,l.jsxs)(f,{id:`throughput`,title:`Throughput`,children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,l.jsx)(p,{label:`Landed`,value:String(t.landed)}),(0,l.jsx)(p,{label:`Deployed`,value:String(t.deployed)}),(0,l.jsx)(p,{label:`Validated`,value:String(t.validated)})]}),C&&(0,l.jsx)(_,{stats:e}),(0,l.jsxs)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[`Tasks reaching each stage for the first time`,C?`; bars show landed per UTC day`:``,`.`]})]}),(0,l.jsxs)(f,{id:`lead-time`,title:`Lead time`,children:[(0,l.jsx)(h,{format:s,rows:[{label:`Started → landed`,dist:n.startToLanded},{label:`Landed → deployed`,dist:n.landedToDeployed}]}),(0,l.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Validation follows a deploy within a second, so it has no lead time of its own.`})]}),(0,l.jsxs)(f,{id:`tokens`,title:`Tokens per landed Task`,children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,l.jsx)(p,{label:`p50`,value:a.p50===null?`—`:v(a.p50)}),(0,l.jsx)(p,{label:`p90`,value:a.p90===null?`—`:v(a.p90)}),(0,l.jsx)(p,{label:`Total`,value:v(a.total),hint:`${a.count} Tasks with token totals`})]}),(0,l.jsx)(b,{counted:a.count,landed:t.landed})]}),(0,l.jsx)(f,{id:`waiting`,title:`Waiting`,children:(0,l.jsx)(h,{format:s,unit:`Waits`,rows:[{label:`For review`,dist:c.review},{label:`For a land lane`,dist:c.landLane}]})}),(0,l.jsx)(f,{id:`gate-time`,title:`Gate time`,children:(0,l.jsx)(h,{format:s,unit:`Runs`,rows:[{label:`Delivery gates`,dist:u.delivery},{label:`Landing / CI`,dist:u.landing},...u.landingSteps.map(e=>({label:`· ${e.label}`,dist:e.time}))]})}),(0,l.jsxs)(f,{id:`failing-gates`,title:`Most-failing gates`,children:[d.length===0?(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No gate failures in this window.`}):(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-[11px] text-muted-foreground`,children:[(0,l.jsx)(`th`,{className:`text-left font-normal`,children:`Gate`}),(0,l.jsx)(`th`,{className:`px-1.5 text-right font-normal`,children:`Failed`}),(0,l.jsx)(`th`,{className:`px-1.5 text-right font-normal`,children:`Fail rate`}),(0,l.jsx)(`th`,{className:`pl-1.5 text-right font-normal`,title:`Passed on a commit that had failed it before`,children:`Flaky`})]})}),(0,l.jsx)(`tbody`,{children:d.map(e=>(0,l.jsxs)(`tr`,{className:`border-t border-border/60 first:border-t-0`,children:[(0,l.jsx)(`th`,{scope:`row`,className:`max-w-0 truncate py-1 pr-2 text-left font-normal`,title:e.gate,children:e.gate}),(0,l.jsxs)(`td`,{className:`px-1.5 py-1 text-right tabular-nums`,children:[e.fails,`/`,e.runs]}),(0,l.jsx)(`td`,{className:`px-1.5 py-1 text-right tabular-nums`,children:o(e.failRate)}),(0,l.jsx)(`td`,{className:`py-1 pl-1.5 text-right tabular-nums`,children:o(e.flakeRate)})]},e.gate))})]}),S.length>0&&(0,l.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-xs`,"aria-label":`Land attempts by outcome`,children:[(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:`Land attempts`}),S.map(([e,t])=>(0,l.jsxs)(r,{variant:`secondary`,children:[e,` `,t]},e))]})]}),(0,l.jsx)(f,{id:`first-pass`,title:`First-pass rates`,children:(0,l.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,l.jsx)(g,{label:`Review GO after one round`,rate:y.review}),(0,l.jsx)(g,{label:`Land, no regate`,rate:y.land})]})}),(0,l.jsxs)(f,{id:`deploys`,title:`CD deploys`,note:(0,l.jsx)(r,{variant:`outline`,title:`A deploy event names no project, so the project filter does not apply`,children:`Fleet-wide`}),children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,l.jsx)(p,{label:`Deploys`,value:String(x.total),hint:`${x.perDay.toFixed(1)} per day`}),(0,l.jsx)(p,{label:`Failed`,value:String(x.failed)}),(0,l.jsx)(p,{label:`Rolled back`,value:String(x.rolledBack)})]}),(0,l.jsxs)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[x.succeeded,` succeeded · `,x.perDay.toFixed(1),`/day · `,o(x.failureRate),` failed or rolled back.`,e.projectId?` Counts every project: a deploy names none.`:``]})]})]})}function S({keys:t,active:n,onChange:r}){return(0,l.jsx)(`div`,{role:`group`,"aria-label":`Window`,className:`inline-flex rounded-lg bg-muted p-[3px]`,children:t.map(t=>(0,l.jsx)(`button`,{type:`button`,"aria-pressed":t===n,onClick:()=>t!==n&&r(t),className:e(`h-7 rounded-md px-3 text-sm`,t===n?`bg-background font-medium shadow-sm`:`text-muted-foreground hover:text-foreground`),children:t},t))})}function C(){let e=n(e=>e.shippingStats),t=n(e=>e.shippingStatsLoading),r=n(e=>e.shippingStatsError);return(0,l.jsxs)(`div`,{className:`space-y-3`,children:[(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,l.jsx)(S,{keys:c,active:n(e=>e.shippingStatsWindow),onChange:n(e=>e.setShippingStatsWindow)}),e&&(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.computedAt===null?`Nothing rolled up yet`:`Data as of ${new Date(e.computedAt).toLocaleString()}`})]}),r&&(0,l.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:[`Could not load the statistics: `,r]}),!e&&t&&(0,l.jsx)(`div`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`Loading the statistics…`}),e&&e.missingDays>0&&(0,l.jsxs)(`div`,{role:`status`,className:`rounded-md border border-tone-warning/40 bg-tone-warning/10 px-3 py-2 text-sm`,children:[e.missingDays,` of `,a(e.window),` days in this window are not rolled up yet, so the figures below cover only the other days. The rollup is still backfilling.`]}),e&&(0,l.jsx)(x,{stats:e}),e&&(0,l.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Percentiles are estimates (about ±9 %); counts and totals are exact.`})]})}export{p as n,S as r,C as t};
|
|
2
|
+
//# sourceMappingURL=stats-DyUBKyWI.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e,u as t}from"./dist-DeW2Y1R5.js";import{Q as n,et as r}from"./display-
|
|
2
|
-
//# sourceMappingURL=status-dot-
|
|
1
|
+
import{o as e,u as t}from"./dist-DeW2Y1R5.js";import{Q as n,et as r}from"./display-BrKWFGJz.js";var i={"gate-running":`gate running`,"gate-passed":`gate passed, merging next`,merging:`merging`,"steward-claimed":`steward reconciling`};function a(e){let t=e?.landState;if(!t||t===`landed`)return null;if(e.landBackedOff)return{kind:`attention`,label:`backed off after repeated no-progress attempts`};if(t===`gate-failed`)return{kind:`attention`,label:`gate failed`};if(t===`merge-error`)return{kind:`attention`,label:`merge error`};if(t===`steward-requested`)return{kind:`attention`,label:`conflict, waiting for a steward`};let n=i[t];return n?{kind:`running`,label:n}:t===`queued`||t===`delivery:complete`?{kind:`queued`,label:e.landWaitReason??`waiting to start`}:null}var o={queued:`Land queued`,running:`Landing`,attention:`Land needs attention`};function s(e,t,n){let i=t.landStateAt?r(n,t.landStateAt).replace(` ago`,``):``;return`${o[e.kind]}: ${e.label}${i?`, ${i}`:``}`}var c=t(),l={queued:`text-tone-violet-fg`,running:`text-tone-violet-fg`,attention:`text-tone-warning-fg`};function u({agent:t,now:r,className:i}){let o=a(t),s=e(`relative inline-block w-2.5 h-2.5 rounded-full shrink-0`,n(t,r),i);return!o||!t?(0,c.jsx)(`span`,{className:s}):(0,c.jsx)(d,{agent:t,ring:o,now:r??Date.now(),className:s})}function d({agent:t,ring:n,now:r,className:i}){let a=s(n,t,r);return(0,c.jsx)(`span`,{className:e(i,l[n.kind]),"aria-label":a,title:a,"data-land-ring":n.kind,children:(0,c.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":!0,className:`pointer-events-none absolute -inset-1 h-[calc(100%+8px)] w-[calc(100%+8px)] overflow-visible`,children:(0,c.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,pathLength:16,strokeDasharray:n.kind===`queued`?`1 1`:void 0})})})}export{u as t};
|
|
2
|
+
//# sourceMappingURL=status-dot-DYqlEUhJ.js.map
|