vessel-agent 0.0.0-stage → 2.3.0-beta.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/LICENSE +21 -0
- package/README.md +466 -2
- package/README.zh-CN.md +476 -0
- package/apps/web/dist/Vela.png +0 -0
- package/apps/web/dist/Vessel.svg +24 -0
- package/apps/web/dist/apple-touch-icon.png +0 -0
- package/apps/web/dist/assets/ConfigView-BKdxb1s5.js +1 -0
- package/apps/web/dist/assets/DesignLabContent-CY5HfVn_.js +4 -0
- package/apps/web/dist/assets/DesignLabView-DTBWv5-E.js +1 -0
- package/apps/web/dist/assets/action-menu.preview-CpIL3tay.js +1 -0
- package/apps/web/dist/assets/agent-message.preview-CSYnJxgr.js +1 -0
- package/apps/web/dist/assets/assistant-text.preview-Bc2Is6sW.js +2 -0
- package/apps/web/dist/assets/badges.preview-DP0oPcs5.js +1 -0
- package/apps/web/dist/assets/buttons.preview-Y84aT4k3.js +1 -0
- package/apps/web/dist/assets/card-shell.preview-mwRwhVb8.js +1 -0
- package/apps/web/dist/assets/chip-tones.preview-dQ_6pwft.js +1 -0
- package/apps/web/dist/assets/composer-controls.preview-CBtJVrMo.js +1 -0
- package/apps/web/dist/assets/confirm-dialog.preview-BkNEtLld.js +1 -0
- package/apps/web/dist/assets/data-table.preview-DPZ7Pnn8.js +1 -0
- package/apps/web/dist/assets/depth-color.preview-CtCbAgCH.js +1 -0
- package/apps/web/dist/assets/entity-header.preview-BxPLNUSH.js +1 -0
- package/apps/web/dist/assets/env-card.preview-Bv4UlMjr.js +1 -0
- package/apps/web/dist/assets/failure-card.preview-DD3-RMju.js +1 -0
- package/apps/web/dist/assets/filter-popover.preview-D7Q7Kws8.js +1 -0
- package/apps/web/dist/assets/form.preview-D_Qltx-j.js +1 -0
- package/apps/web/dist/assets/index-ee36IO2F.js +600 -0
- package/apps/web/dist/assets/index-uU9N5oTa.css +1 -0
- package/apps/web/dist/assets/key-value.preview-B0gzxwtK.js +1 -0
- package/apps/web/dist/assets/mention-popover.preview-Duza1RgL.js +1 -0
- package/apps/web/dist/assets/message-fold.preview-Cx-CD3Y4.js +1 -0
- package/apps/web/dist/assets/modal-shell.preview-DYKwUk2S.js +1 -0
- package/apps/web/dist/assets/nav-item.preview-FTbsBQ2g.js +1 -0
- package/apps/web/dist/assets/nav-status-legend.preview-bS4LDFbd.js +1 -0
- package/apps/web/dist/assets/page-scaffold.preview-bzBFkjZ6.js +1 -0
- package/apps/web/dist/assets/plugin-ui-BxTydP3l.js +1 -0
- package/apps/web/dist/assets/projection-card.preview-BV0P-y8e.js +6 -0
- package/apps/web/dist/assets/queued.preview-zQqFe4Zr.js +1 -0
- package/apps/web/dist/assets/react-vendor-CUu194FT.js +9 -0
- package/apps/web/dist/assets/reasoning.preview-DtHXgW_8.js +2 -0
- package/apps/web/dist/assets/section.preview-A-PRm-rh.js +1 -0
- package/apps/web/dist/assets/sidebar-shell.preview-DFKMwNoo.js +1 -0
- package/apps/web/dist/assets/stat.preview-BzChSFLL.js +1 -0
- package/apps/web/dist/assets/states.preview-CyXZWnZ-.js +1 -0
- package/apps/web/dist/assets/status-icons.preview-DHdWwUis.js +1 -0
- package/apps/web/dist/assets/tabs.preview-CHbK1Two.js +1 -0
- package/apps/web/dist/assets/tool-card.preview-Z48fekTD.js +2 -0
- package/apps/web/dist/assets/toolbar.preview-Bl6hLYXX.js +1 -0
- package/apps/web/dist/assets/tooltip.preview-GKGTGfMP.js +1 -0
- package/apps/web/dist/assets/user-bubble.preview-CHYvio9z.js +1 -0
- package/apps/web/dist/assets/vendor/jsx-runtime.mjs +7 -0
- package/apps/web/dist/assets/vendor/plugin-sdk.mjs +12 -0
- package/apps/web/dist/assets/vendor/react-dom-client.mjs +6 -0
- package/apps/web/dist/assets/vendor/react-dom.mjs +11 -0
- package/apps/web/dist/assets/vendor/react.mjs +39 -0
- package/apps/web/dist/build.json +5 -0
- package/apps/web/dist/favicon.ico +0 -0
- package/apps/web/dist/index.html +24 -0
- package/package.json +70 -4
- package/packages/agent/package.json +32 -0
- package/packages/agent/src/address-display.ts +141 -0
- package/packages/agent/src/conversation-budget.ts +651 -0
- package/packages/agent/src/conversation-store.ts +351 -0
- package/packages/agent/src/distress.ts +161 -0
- package/packages/agent/src/env-info-scope.ts +153 -0
- package/packages/agent/src/error-text.ts +28 -0
- package/packages/agent/src/inbox-source.ts +73 -0
- package/packages/agent/src/inbox.ts +2335 -0
- package/packages/agent/src/index.ts +273 -0
- package/packages/agent/src/member-cwd.ts +128 -0
- package/packages/agent/src/member-ports.ts +162 -0
- package/packages/agent/src/refs.ts +51 -0
- package/packages/agent/src/registry.ts +741 -0
- package/packages/agent/src/runtime.ts +2501 -0
- package/packages/agent/src/self-card-delta.ts +428 -0
- package/packages/agent/src/service.ts +9212 -0
- package/packages/agent/src/snapshot.ts +614 -0
- package/packages/agent/src/team-address.ts +96 -0
- package/packages/agent/src/team-log.ts +487 -0
- package/packages/agent/src/team-service.ts +1966 -0
- package/packages/agent/src/team-slug.ts +167 -0
- package/packages/agent/src/team-store.ts +619 -0
- package/packages/agent/src/tool.ts +1306 -0
- package/packages/agent/src/types/budget.ts +168 -0
- package/packages/agent/src/types/constants.ts +17 -0
- package/packages/agent/src/types/dispatch.ts +133 -0
- package/packages/agent/src/types/events.ts +132 -0
- package/packages/agent/src/types/execution.ts +289 -0
- package/packages/agent/src/types/lifecycle.ts +372 -0
- package/packages/agent/src/types/member.ts +221 -0
- package/packages/agent/src/types/message.ts +113 -0
- package/packages/agent/src/types/results.ts +64 -0
- package/packages/agent/src/types/roster.ts +137 -0
- package/packages/agent/src/types/service.ts +702 -0
- package/packages/agent/src/types/session.ts +102 -0
- package/packages/agent/src/types/team.ts +558 -0
- package/packages/agent/src/types.ts +22 -0
- package/packages/agent/tsconfig.json +8 -0
- package/packages/config/package.json +32 -0
- package/packages/config/src/auth-origins.ts +85 -0
- package/packages/config/src/auth-strategies/avatar-ref.ts +40 -0
- package/packages/config/src/auth-strategies/gitee.ts +72 -0
- package/packages/config/src/auth-strategies/github.ts +64 -0
- package/packages/config/src/auth-strategies/index.ts +47 -0
- package/packages/config/src/auth-strategies/match.ts +82 -0
- package/packages/config/src/auth-strategies/microsoft.ts +100 -0
- package/packages/config/src/auth-strategies/oauth-exchange.ts +192 -0
- package/packages/config/src/auth-strategies/password.ts +34 -0
- package/packages/config/src/auth-strategies/registry.ts +105 -0
- package/packages/config/src/auth-strategies/shapes.ts +138 -0
- package/packages/config/src/auth-strategies/types.ts +190 -0
- package/packages/config/src/auth.ts +305 -0
- package/packages/config/src/config-lock.ts +328 -0
- package/packages/config/src/defaults.ts +271 -0
- package/packages/config/src/env-file.ts +175 -0
- package/packages/config/src/env-injection.ts +117 -0
- package/packages/config/src/explain.ts +283 -0
- package/packages/config/src/gateway.ts +107 -0
- package/packages/config/src/index.ts +253 -0
- package/packages/config/src/loader.ts +871 -0
- package/packages/config/src/model-migration.ts +534 -0
- package/packages/config/src/model-registry.ts +374 -0
- package/packages/config/src/models-disk.ts +72 -0
- package/packages/config/src/models-validation.ts +467 -0
- package/packages/config/src/node-registration.ts +583 -0
- package/packages/config/src/root-secret.ts +402 -0
- package/packages/config/src/secrets.ts +452 -0
- package/packages/config/src/sources.ts +82 -0
- package/packages/config/src/team-policy.ts +422 -0
- package/packages/config/src/types/agent.ts +263 -0
- package/packages/config/src/types/attention.ts +28 -0
- package/packages/config/src/types/auth.ts +126 -0
- package/packages/config/src/types/connect.ts +21 -0
- package/packages/config/src/types/hub.ts +59 -0
- package/packages/config/src/types/models.ts +153 -0
- package/packages/config/src/types/node.ts +202 -0
- package/packages/config/src/types/observability.ts +84 -0
- package/packages/config/src/types/root.ts +240 -0
- package/packages/config/src/types/runtime.ts +123 -0
- package/packages/config/src/types/security.ts +43 -0
- package/packages/config/src/types/serve.ts +34 -0
- package/packages/config/src/types/snapshot.ts +28 -0
- package/packages/config/src/types/team.ts +112 -0
- package/packages/config/src/types/ui.ts +179 -0
- package/packages/config/src/types.ts +22 -0
- package/packages/config/src/user-config.ts +175 -0
- package/packages/config/src/utils.ts +55 -0
- package/packages/config/src/validator/auth.ts +302 -0
- package/packages/config/src/validator/hub.ts +329 -0
- package/packages/config/src/validator/models.ts +1304 -0
- package/packages/config/src/validator/serve.ts +784 -0
- package/packages/config/src/validator/settings.ts +244 -0
- package/packages/config/src/validator/shared.ts +304 -0
- package/packages/config/src/validator/tenant-keys.ts +91 -0
- package/packages/config/src/validator/unknown-keys.ts +452 -0
- package/packages/config/src/validator.ts +1146 -0
- package/packages/config/tsconfig.json +8 -0
- package/packages/core/package.json +38 -0
- package/packages/core/src/context/anchor.ts +57 -0
- package/packages/core/src/context/archive-notice.ts +283 -0
- package/packages/core/src/context/cleared-tool-result.ts +262 -0
- package/packages/core/src/context/compaction-index.ts +381 -0
- package/packages/core/src/context/composition.ts +251 -0
- package/packages/core/src/context/context-manager.ts +1585 -0
- package/packages/core/src/context/context-notice.ts +218 -0
- package/packages/core/src/context/index.ts +220 -0
- package/packages/core/src/context/model-change-notice.ts +81 -0
- package/packages/core/src/context/projection-policy.ts +719 -0
- package/packages/core/src/context/prompt-context.ts +66 -0
- package/packages/core/src/context/read-side-mask.ts +63 -0
- package/packages/core/src/context/request-sequence.ts +423 -0
- package/packages/core/src/context/request-view.ts +256 -0
- package/packages/core/src/context/session-breaker.ts +100 -0
- package/packages/core/src/context/tool-result-whitelist.ts +135 -0
- package/packages/core/src/events/event-stream.ts +271 -0
- package/packages/core/src/events/file-event-store.ts +119 -0
- package/packages/core/src/events/index.ts +15 -0
- package/packages/core/src/events/replay.ts +82 -0
- package/packages/core/src/events/summarize-event.ts +135 -0
- package/packages/core/src/index.ts +475 -0
- package/packages/core/src/kernel/cancellation.ts +54 -0
- package/packages/core/src/kernel/event-bus.ts +65 -0
- package/packages/core/src/kernel/index.ts +32 -0
- package/packages/core/src/kernel/internal.ts +32 -0
- package/packages/core/src/kernel/scheduler.ts +406 -0
- package/packages/core/src/kernel/types.ts +269 -0
- package/packages/core/src/limits/index.ts +23 -0
- package/packages/core/src/limits/limit-checker.ts +270 -0
- package/packages/core/src/limits/limit-error.ts +29 -0
- package/packages/core/src/log-format.ts +722 -0
- package/packages/core/src/log-hub.ts +278 -0
- package/packages/core/src/logging.ts +64 -0
- package/packages/core/src/observability/index.ts +24 -0
- package/packages/core/src/observability/metrics.ts +279 -0
- package/packages/core/src/observability/read-trace.ts +163 -0
- package/packages/core/src/observability/rebuild-metrics.ts +37 -0
- package/packages/core/src/observability/trace-prune.ts +248 -0
- package/packages/core/src/observability/trace-recorder.ts +484 -0
- package/packages/core/src/observability/trace-redactor.ts +93 -0
- package/packages/core/src/pii/index.ts +88 -0
- package/packages/core/src/pii/notice.ts +156 -0
- package/packages/core/src/pii/reveal.ts +198 -0
- package/packages/core/src/pii/rules.ts +545 -0
- package/packages/core/src/pii/types.ts +140 -0
- package/packages/core/src/pii/vault.ts +764 -0
- package/packages/core/src/provider/errors.ts +41 -0
- package/packages/core/src/provider/index.ts +19 -0
- package/packages/core/src/provider/providers.ts +1011 -0
- package/packages/core/src/provider/request-extras.ts +285 -0
- package/packages/core/src/provider/stream-accumulator.ts +168 -0
- package/packages/core/src/provider/usage.ts +112 -0
- package/packages/core/src/runtime/error-envelope.ts +451 -0
- package/packages/core/src/runtime/error-summary.ts +174 -0
- package/packages/core/src/runtime/execution-unit.ts +6675 -0
- package/packages/core/src/runtime/guardrail-runner.ts +86 -0
- package/packages/core/src/runtime/hook-runner.ts +137 -0
- package/packages/core/src/runtime/index.ts +123 -0
- package/packages/core/src/runtime/permission-policy.ts +267 -0
- package/packages/core/src/runtime/plugin-host.ts +489 -0
- package/packages/core/src/runtime/plugin-install.ts +144 -0
- package/packages/core/src/runtime/policy/index.ts +21 -0
- package/packages/core/src/runtime/prompt-prefix-guard.ts +166 -0
- package/packages/core/src/runtime/provider-retry.ts +220 -0
- package/packages/core/src/runtime/resume-markers.ts +114 -0
- package/packages/core/src/runtime/resume-recovery.ts +164 -0
- package/packages/core/src/runtime/run-journal.ts +382 -0
- package/packages/core/src/runtime/run-timing.ts +217 -0
- package/packages/core/src/runtime/runtime.ts +349 -0
- package/packages/core/src/runtime/safepoint-pause.ts +29 -0
- package/packages/core/src/runtime/tool-attachment.ts +170 -0
- package/packages/core/src/runtime/tool-calling-loop.ts +1219 -0
- package/packages/core/src/runtime/tool-name.ts +215 -0
- package/packages/core/src/runtime/tool-pipeline.ts +459 -0
- package/packages/core/src/runtime/tool-provenance.ts +48 -0
- package/packages/core/src/runtime/tool-result-gate.ts +329 -0
- package/packages/core/src/session/atomic-write.ts +335 -0
- package/packages/core/src/session/compaction-index-derive.ts +173 -0
- package/packages/core/src/session/compaction-index-store.ts +161 -0
- package/packages/core/src/session/compaction-recall.ts +375 -0
- package/packages/core/src/session/delete-session.ts +198 -0
- package/packages/core/src/session/file-backend.ts +1311 -0
- package/packages/core/src/session/index.ts +118 -0
- package/packages/core/src/session/message-identity.ts +272 -0
- package/packages/core/src/session/project-messages.ts +908 -0
- package/packages/core/src/session/projection-cache.ts +254 -0
- package/packages/core/src/session/prune.ts +153 -0
- package/packages/core/src/session/run-record-store.ts +307 -0
- package/packages/core/src/session/session-index.ts +158 -0
- package/packages/core/src/session/session-log-dir.ts +39 -0
- package/packages/core/src/session/session-store.ts +266 -0
- package/packages/core/src/session/sqlite-backend.ts +391 -0
- package/packages/core/src/socket-inherit-guard.ts +188 -0
- package/packages/core/src/storage/metadata-sidecar.ts +124 -0
- package/packages/core/src/tenant/index.ts +13 -0
- package/packages/core/src/tenant/resolve-tenant.ts +19 -0
- package/packages/core/src/tenant/tenant-paths.ts +83 -0
- package/packages/core/src/timeline/archive-audit.ts +316 -0
- package/packages/core/src/timeline/archive-lock.ts +124 -0
- package/packages/core/src/timeline/blocks.ts +1639 -0
- package/packages/core/src/timeline/enum-stats.ts +34 -0
- package/packages/core/src/timeline/holes.ts +431 -0
- package/packages/core/src/timeline/index.ts +387 -0
- package/packages/core/src/timeline/legacy-format.ts +97 -0
- package/packages/core/src/timeline/read-port.ts +582 -0
- package/packages/core/src/timeline/types.ts +371 -0
- package/packages/core/src/timeline/wal.ts +2485 -0
- package/packages/core/src/timeline/writer.ts +2079 -0
- package/packages/core/src/timeout.ts +93 -0
- package/packages/core/src/transport/in-process.ts +86 -0
- package/packages/core/src/transport/index.ts +6 -0
- package/packages/core/src/types/context.ts +229 -0
- package/packages/core/src/types/env-cadence.ts +35 -0
- package/packages/core/src/types/error-registry.ts +343 -0
- package/packages/core/src/types/error.ts +107 -0
- package/packages/core/src/types/event.ts +496 -0
- package/packages/core/src/types/guardrail.ts +35 -0
- package/packages/core/src/types/hook.ts +122 -0
- package/packages/core/src/types/index.ts +28 -0
- package/packages/core/src/types/lease.ts +91 -0
- package/packages/core/src/types/limits.ts +112 -0
- package/packages/core/src/types/logging.ts +54 -0
- package/packages/core/src/types/member-port.ts +194 -0
- package/packages/core/src/types/plugin.ts +392 -0
- package/packages/core/src/types/projection-cache.ts +80 -0
- package/packages/core/src/types/projection.ts +100 -0
- package/packages/core/src/types/provider.ts +319 -0
- package/packages/core/src/types/run-journal.ts +178 -0
- package/packages/core/src/types/run-record-store.ts +128 -0
- package/packages/core/src/types/run.ts +140 -0
- package/packages/core/src/types/session.ts +328 -0
- package/packages/core/src/types/source-module.ts +68 -0
- package/packages/core/src/types/tenant.ts +41 -0
- package/packages/core/src/types/tool-name.ts +57 -0
- package/packages/core/src/types/tool.ts +122 -0
- package/packages/core/src/types/trace.ts +38 -0
- package/packages/core/src/types/vision.ts +219 -0
- package/packages/core/src/vision/blobs.ts +328 -0
- package/packages/core/src/vision/index.ts +73 -0
- package/packages/core/src/vision/ingest.ts +126 -0
- package/packages/core/src/vision/notice.ts +58 -0
- package/packages/core/src/vision/plan.ts +358 -0
- package/packages/core/src/vision/staging.ts +81 -0
- package/packages/core/tsconfig.json +8 -0
- package/packages/permission/package.json +31 -0
- package/packages/permission/src/index.ts +60 -0
- package/packages/plugin-sdk/package.json +21 -0
- package/packages/plugin-sdk/src/index.ts +478 -0
- package/packages/plugin-sdk/src/semver.ts +154 -0
- package/packages/plugin-ui/package.json +33 -0
- package/packages/plugin-ui/src/Badge.tsx +41 -0
- package/packages/plugin-ui/src/Button.tsx +84 -0
- package/packages/plugin-ui/src/ComposerAttachments.tsx +87 -0
- package/packages/plugin-ui/src/ComposerContextMeter.tsx +209 -0
- package/packages/plugin-ui/src/ComposerToolbar.tsx +233 -0
- package/packages/plugin-ui/src/CountBadge.tsx +57 -0
- package/packages/plugin-ui/src/DataTable.tsx +168 -0
- package/packages/plugin-ui/src/Field.tsx +543 -0
- package/packages/plugin-ui/src/KeyValueList.tsx +32 -0
- package/packages/plugin-ui/src/Page.tsx +39 -0
- package/packages/plugin-ui/src/Pager.tsx +63 -0
- package/packages/plugin-ui/src/SearchInput.tsx +33 -0
- package/packages/plugin-ui/src/Section.tsx +47 -0
- package/packages/plugin-ui/src/Stat.tsx +25 -0
- package/packages/plugin-ui/src/TableToolbar.tsx +27 -0
- package/packages/plugin-ui/src/Tabs.tsx +77 -0
- package/packages/plugin-ui/src/card-surface.ts +11 -0
- package/packages/plugin-ui/src/cn.ts +7 -0
- package/packages/plugin-ui/src/dom-globals.d.ts +124 -0
- package/packages/plugin-ui/src/host.ts +270 -0
- package/packages/plugin-ui/src/index.ts +26 -0
- package/packages/plugin-ui/src/styles.css +386 -0
- package/packages/plugin-ui/src/useStaleWhileRevalidate.ts +211 -0
- package/packages/serve/package.json +32 -0
- package/packages/serve/src/agent-control.ts +595 -0
- package/packages/serve/src/agents-registry.ts +409 -0
- package/packages/serve/src/auth/avatar.ts +352 -0
- package/packages/serve/src/auth/bootstrap.ts +184 -0
- package/packages/serve/src/auth/credentials.ts +275 -0
- package/packages/serve/src/auth/github-oauth.ts +33 -0
- package/packages/serve/src/auth/index.ts +121 -0
- package/packages/serve/src/auth/oauth.ts +394 -0
- package/packages/serve/src/auth/origins.ts +145 -0
- package/packages/serve/src/auth/password.ts +187 -0
- package/packages/serve/src/auth/ratelimit.ts +249 -0
- package/packages/serve/src/auth/routes.ts +1757 -0
- package/packages/serve/src/auth/session.ts +407 -0
- package/packages/serve/src/auth/totp.ts +183 -0
- package/packages/serve/src/backpressure.ts +91 -0
- package/packages/serve/src/durable.ts +216 -0
- package/packages/serve/src/evals.ts +140 -0
- package/packages/serve/src/event-buffer.ts +92 -0
- package/packages/serve/src/event-summary.ts +11 -0
- package/packages/serve/src/federation.ts +1100 -0
- package/packages/serve/src/feishu.ts +51 -0
- package/packages/serve/src/gateway/auth.ts +773 -0
- package/packages/serve/src/gateway/errors.ts +21 -0
- package/packages/serve/src/gateway/frames.ts +195 -0
- package/packages/serve/src/gateway/methods/admin.ts +530 -0
- package/packages/serve/src/gateway/methods/agents.ts +1727 -0
- package/packages/serve/src/gateway/methods/attachments.ts +354 -0
- package/packages/serve/src/gateway/methods/common.ts +50 -0
- package/packages/serve/src/gateway/methods/config.ts +883 -0
- package/packages/serve/src/gateway/methods/evals.ts +87 -0
- package/packages/serve/src/gateway/methods/feishu.ts +52 -0
- package/packages/serve/src/gateway/methods/fleet.ts +225 -0
- package/packages/serve/src/gateway/methods/images.ts +196 -0
- package/packages/serve/src/gateway/methods/interactions.ts +721 -0
- package/packages/serve/src/gateway/methods/jobs.ts +148 -0
- package/packages/serve/src/gateway/methods/kanban.ts +637 -0
- package/packages/serve/src/gateway/methods/mcp.ts +82 -0
- package/packages/serve/src/gateway/methods/observability.ts +264 -0
- package/packages/serve/src/gateway/methods/permissions.ts +397 -0
- package/packages/serve/src/gateway/methods/rpc-namespaces.ts +80 -0
- package/packages/serve/src/gateway/methods/runs.ts +434 -0
- package/packages/serve/src/gateway/methods/schemas.ts +1196 -0
- package/packages/serve/src/gateway/methods/sessions.ts +2568 -0
- package/packages/serve/src/gateway/methods/subscription.ts +515 -0
- package/packages/serve/src/gateway/methods/teams.ts +638 -0
- package/packages/serve/src/gateway/sse.ts +130 -0
- package/packages/serve/src/gateway/static.ts +66 -0
- package/packages/serve/src/gateway/timeline-protocol.ts +532 -0
- package/packages/serve/src/gateway.ts +4974 -0
- package/packages/serve/src/hub-control.ts +86 -0
- package/packages/serve/src/hub-frames.ts +435 -0
- package/packages/serve/src/hub-protocol.ts +182 -0
- package/packages/serve/src/index.ts +511 -0
- package/packages/serve/src/interactions-registry.ts +1362 -0
- package/packages/serve/src/interactions-store.ts +360 -0
- package/packages/serve/src/local.ts +48 -0
- package/packages/serve/src/log-event.ts +57 -0
- package/packages/serve/src/mcp.ts +73 -0
- package/packages/serve/src/metrics.ts +137 -0
- package/packages/serve/src/platform/auth.ts +146 -0
- package/packages/serve/src/platform/index.ts +54 -0
- package/packages/serve/src/platform/listen-guard.ts +68 -0
- package/packages/serve/src/platform/metrics.ts +123 -0
- package/packages/serve/src/platform/proxy-config.ts +368 -0
- package/packages/serve/src/platform/proxy-ws.ts +737 -0
- package/packages/serve/src/platform/proxy.ts +909 -0
- package/packages/serve/src/platform/registry.ts +130 -0
- package/packages/serve/src/platform/rpc.ts +445 -0
- package/packages/serve/src/platform/server.ts +1148 -0
- package/packages/serve/src/platform/types.ts +276 -0
- package/packages/serve/src/plugin-host/catalog.ts +212 -0
- package/packages/serve/src/plugin-host/child.ts +767 -0
- package/packages/serve/src/plugin-host/dto.ts +191 -0
- package/packages/serve/src/plugin-host/errors.ts +50 -0
- package/packages/serve/src/plugin-host/events.ts +114 -0
- package/packages/serve/src/plugin-host/expose.ts +142 -0
- package/packages/serve/src/plugin-host/http.ts +823 -0
- package/packages/serve/src/plugin-host/index.ts +170 -0
- package/packages/serve/src/plugin-host/manager.ts +2027 -0
- package/packages/serve/src/plugin-host/ndjson.ts +136 -0
- package/packages/serve/src/plugin-host/proxy.ts +358 -0
- package/packages/serve/src/plugin-host/registry.ts +208 -0
- package/packages/serve/src/plugin-host/static.ts +162 -0
- package/packages/serve/src/plugin-host/types.ts +529 -0
- package/packages/serve/src/plugin-host/ws-proxy.ts +431 -0
- package/packages/serve/src/prometheus.ts +98 -0
- package/packages/serve/src/protocol.ts +332 -0
- package/packages/serve/src/replay-budget.ts +481 -0
- package/packages/serve/src/rpc.ts +614 -0
- package/packages/serve/src/run-control.ts +106 -0
- package/packages/serve/src/session-search.ts +142 -0
- package/packages/serve/src/shutdown-step.ts +128 -0
- package/packages/serve/src/team-control.ts +282 -0
- package/packages/serve/src/tenant-event-hub.ts +194 -0
- package/packages/serve/src/tenant.ts +169 -0
- package/packages/serve/src/tool-events.ts +244 -0
- package/packages/tui/package.json +40 -0
- package/packages/tui/src/commands/agents-command.ts +402 -0
- package/packages/tui/src/commands/capabilities-command.ts +356 -0
- package/packages/tui/src/commands/commands.ts +1361 -0
- package/packages/tui/src/commands/config-command.ts +541 -0
- package/packages/tui/src/commands/context-command.ts +348 -0
- package/packages/tui/src/commands/cost-command.ts +66 -0
- package/packages/tui/src/commands/details-command.ts +47 -0
- package/packages/tui/src/commands/errors-command.ts +205 -0
- package/packages/tui/src/commands/export-command.ts +193 -0
- package/packages/tui/src/commands/feishu-command.ts +101 -0
- package/packages/tui/src/commands/mcp-command.ts +319 -0
- package/packages/tui/src/commands/metrics-command.ts +314 -0
- package/packages/tui/src/commands/permissions-command.ts +117 -0
- package/packages/tui/src/commands/runs-command.ts +421 -0
- package/packages/tui/src/commands/sessions-command.ts +367 -0
- package/packages/tui/src/commands/settings-command.ts +180 -0
- package/packages/tui/src/commands/status-command.ts +30 -0
- package/packages/tui/src/commands/trace-command.ts +382 -0
- package/packages/tui/src/components/AskUserDialog.tsx +663 -0
- package/packages/tui/src/components/BottomBar.tsx +44 -0
- package/packages/tui/src/components/ConfirmDialog.tsx +175 -0
- package/packages/tui/src/components/DataTable.tsx +99 -0
- package/packages/tui/src/components/DetailPanel.tsx +80 -0
- package/packages/tui/src/components/EmptyState.tsx +27 -0
- package/packages/tui/src/components/InlineAutocomplete.tsx +319 -0
- package/packages/tui/src/components/InteractiveViewHost.tsx +652 -0
- package/packages/tui/src/components/KeyHints.tsx +41 -0
- package/packages/tui/src/components/Markdown.tsx +489 -0
- package/packages/tui/src/components/PanelFrame.tsx +113 -0
- package/packages/tui/src/components/QueuePreview.tsx +113 -0
- package/packages/tui/src/components/QuickHelp.tsx +91 -0
- package/packages/tui/src/components/ReasoningBlock.tsx +42 -0
- package/packages/tui/src/components/SessionTable.tsx +523 -0
- package/packages/tui/src/components/SpinnerWithVerb.tsx +116 -0
- package/packages/tui/src/components/StateTracker.ts +102 -0
- package/packages/tui/src/components/StatusBar.tsx +315 -0
- package/packages/tui/src/components/StreamOutput.tsx +302 -0
- package/packages/tui/src/components/SubagentActivity.tsx +57 -0
- package/packages/tui/src/components/TextViewer.tsx +100 -0
- package/packages/tui/src/components/ToolDisplay.tsx +248 -0
- package/packages/tui/src/components/ToolTrail.tsx +104 -0
- package/packages/tui/src/components/UiItemView.tsx +460 -0
- package/packages/tui/src/components/UpdateBanner.tsx +48 -0
- package/packages/tui/src/components/indicator.ts +61 -0
- package/packages/tui/src/error-classifier.ts +255 -0
- package/packages/tui/src/i18n/index.ts +67 -0
- package/packages/tui/src/i18n/messages/en.ts +543 -0
- package/packages/tui/src/i18n/messages/zh-CN.ts +528 -0
- package/packages/tui/src/index.ts +335 -0
- package/packages/tui/src/renderer/ask-user.ts +431 -0
- package/packages/tui/src/renderer/notify-user.ts +184 -0
- package/packages/tui/src/renderer/stream-renderer.ts +149 -0
- package/packages/tui/src/renderer/tool-confirm.ts +47 -0
- package/packages/tui/src/repl/agent-registry.ts +747 -0
- package/packages/tui/src/repl/cache-metrics.ts +241 -0
- package/packages/tui/src/repl/clear-on-start.ts +28 -0
- package/packages/tui/src/repl/error-archive.ts +95 -0
- package/packages/tui/src/repl/error-log.ts +212 -0
- package/packages/tui/src/repl/ink-repl.tsx +1735 -0
- package/packages/tui/src/repl/layout.ts +303 -0
- package/packages/tui/src/repl/limit-info.ts +630 -0
- package/packages/tui/src/repl/permission-pending.ts +49 -0
- package/packages/tui/src/repl/project/ui-item.ts +1307 -0
- package/packages/tui/src/repl/queue-info.ts +109 -0
- package/packages/tui/src/repl/resume-picker.ts +24 -0
- package/packages/tui/src/repl/run-turn.ts +60 -0
- package/packages/tui/src/repl/runtime-counters.ts +91 -0
- package/packages/tui/src/repl/startup-header.ts +144 -0
- package/packages/tui/src/repl/startup-notice.ts +100 -0
- package/packages/tui/src/repl/status-format.ts +513 -0
- package/packages/tui/src/repl/status-metrics.ts +88 -0
- package/packages/tui/src/repl/status-snapshot.ts +454 -0
- package/packages/tui/src/repl/use-repl-state.ts +548 -0
- package/packages/tui/src/repl-context.ts +349 -0
- package/packages/tui/src/rich-renderer.ts +63 -0
- package/packages/tui/src/rpc-events.ts +161 -0
- package/packages/tui/src/rpc.ts +149 -0
- package/packages/tui/src/theme.ts +180 -0
- package/packages/tui/src/types/events.ts +284 -0
- package/packages/tui/src/utils/dialog.ts +35 -0
- package/packages/tui/src/utils/diff.ts +124 -0
- package/packages/tui/src/utils/display-labels.ts +56 -0
- package/packages/tui/src/utils/file-reference.ts +180 -0
- package/packages/tui/src/utils/git.ts +24 -0
- package/packages/tui/src/utils/sanitize-terminal-text.ts +109 -0
- package/packages/tui/src/utils/text-layout.ts +127 -0
- package/packages/tui/src/utils/time.ts +25 -0
- package/packages/tui/src/utils/tool-input-summary.ts +70 -0
- package/packages/tui/src/views/keys.ts +344 -0
- package/packages/tui/src/views/layout.ts +224 -0
- package/packages/tui/src/views/render-text.ts +154 -0
- package/packages/tui/src/views/selection.ts +57 -0
- package/packages/tui/src/views/session-picker.ts +215 -0
- package/packages/tui/src/views/tones.ts +24 -0
- package/packages/tui/src/views/types.ts +200 -0
- package/packages/tui/src/wizard/setup-wizard.ts +439 -0
- package/packages/tui/tsconfig.json +10 -0
- package/plugins/context/doc-subscription/package.json +32 -0
- package/plugins/context/doc-subscription/src/agent.ts +151 -0
- package/plugins/context/doc-subscription/src/auto-sub.ts +80 -0
- package/plugins/context/doc-subscription/src/config.ts +358 -0
- package/plugins/context/doc-subscription/src/diff.ts +107 -0
- package/plugins/context/doc-subscription/src/friend-edges.ts +118 -0
- package/plugins/context/doc-subscription/src/health.ts +163 -0
- package/plugins/context/doc-subscription/src/hook.ts +1222 -0
- package/plugins/context/doc-subscription/src/implicit.ts +84 -0
- package/plugins/context/doc-subscription/src/index.ts +288 -0
- package/plugins/context/doc-subscription/src/lifecycle-listener.ts +58 -0
- package/plugins/context/doc-subscription/src/lifecycle.ts +186 -0
- package/plugins/context/doc-subscription/src/mute.ts +39 -0
- package/plugins/context/doc-subscription/src/notice.ts +347 -0
- package/plugins/context/doc-subscription/src/script.ts +288 -0
- package/plugins/context/doc-subscription/src/sources.ts +187 -0
- package/plugins/context/doc-subscription/src/store.ts +748 -0
- package/plugins/context/doc-subscription/src/team-log.ts +155 -0
- package/plugins/context/doc-subscription/src/tool.ts +2132 -0
- package/plugins/context/skills/package.json +182 -0
- package/plugins/context/skills/src/config.ts +178 -0
- package/plugins/context/skills/src/frontmatter.ts +166 -0
- package/plugins/context/skills/src/index.ts +144 -0
- package/plugins/context/skills/src/rpc.ts +274 -0
- package/plugins/context/skills/src/scanner.ts +262 -0
- package/plugins/context/skills/src/service.ts +277 -0
- package/plugins/context/skills/src/store.ts +333 -0
- package/plugins/context/skills/src/tool.ts +354 -0
- package/plugins/context/skills/src/trust.ts +71 -0
- package/plugins/context/skills/src/types.ts +130 -0
- package/plugins/context/skills/src/watch.ts +83 -0
- package/plugins/context/skills/tsconfig.web.json +29 -0
- package/plugins/context/skills/vite.config.embed.ts +107 -0
- package/plugins/context/skills/vite.config.ts +121 -0
- package/plugins/context/skills/web/assets/skills-8su2cNqF.css +2 -0
- package/plugins/context/skills/web/assets/skills-BhiDTAac.js +10 -0
- package/plugins/context/skills/web/embed/index.css +3 -0
- package/plugins/context/skills/web/embed/index.mjs +4251 -0
- package/plugins/context/skills/web/skills.html +13 -0
- package/plugins/context/skills/web-src/App.tsx +47 -0
- package/plugins/context/skills/web-src/SkillsView.tsx +649 -0
- package/plugins/context/skills/web-src/embed.css +153 -0
- package/plugins/context/skills/web-src/embed.tsx +36 -0
- package/plugins/context/skills/web-src/env.d.ts +2 -0
- package/plugins/context/skills/web-src/i18n.ts +195 -0
- package/plugins/context/skills/web-src/main.tsx +14 -0
- package/plugins/context/skills/web-src/shared.tsx +226 -0
- package/plugins/context/skills/web-src/skills.html +12 -0
- package/plugins/context/skills/web-src/styles.css +62 -0
- package/plugins/context/skills/web-src/types.ts +85 -0
- package/plugins/context/thinking-intensity/package.json +201 -0
- package/plugins/context/thinking-intensity/src/index.ts +285 -0
- package/plugins/context/thinking-intensity/src/mapping.ts +175 -0
- package/plugins/context/thinking-intensity/src/state.ts +134 -0
- package/plugins/evals/harness/package.json +32 -0
- package/plugins/evals/harness/src/assertions.ts +99 -0
- package/plugins/evals/harness/src/errors.ts +23 -0
- package/plugins/evals/harness/src/index.ts +48 -0
- package/plugins/evals/harness/src/mock-provider.ts +64 -0
- package/plugins/evals/harness/src/plugin.ts +48 -0
- package/plugins/evals/harness/src/report.ts +66 -0
- package/plugins/evals/harness/src/runner.ts +417 -0
- package/plugins/evals/harness/src/suite.ts +352 -0
- package/plugins/evals/harness/src/types.ts +154 -0
- package/plugins/fleet/compose/README.md +40 -0
- package/plugins/fleet/compose/package.json +172 -0
- package/plugins/fleet/compose/src/cli.ts +347 -0
- package/plugins/fleet/compose/src/i18n.ts +99 -0
- package/plugins/fleet/compose/src/index.ts +3 -0
- package/plugins/fleet/compose/src/manifest.ts +194 -0
- package/plugins/im/feishu/FEISHU.md +142 -0
- package/plugins/im/feishu/package.json +33 -0
- package/plugins/im/feishu/src/channel.ts +360 -0
- package/plugins/im/feishu/src/config.ts +133 -0
- package/plugins/im/feishu/src/dedupe.ts +30 -0
- package/plugins/im/feishu/src/errors.ts +21 -0
- package/plugins/im/feishu/src/index.ts +47 -0
- package/plugins/im/feishu/src/messages.ts +41 -0
- package/plugins/im/feishu/src/queue.ts +71 -0
- package/plugins/im/feishu/src/runner.ts +356 -0
- package/plugins/im/feishu/src/sdk-transport.ts +220 -0
- package/plugins/im/feishu/src/text.ts +56 -0
- package/plugins/im/feishu/src/types.ts +150 -0
- package/plugins/marketplace/marketplace/package.json +166 -0
- package/plugins/marketplace/marketplace/registry-template/README.md +105 -0
- package/plugins/marketplace/marketplace/registry-template/index.sample.json +71 -0
- package/plugins/marketplace/marketplace/registry-template/validate.mjs +272 -0
- package/plugins/marketplace/marketplace/registry-template/validate.yml +35 -0
- package/plugins/marketplace/marketplace/src/config-lock.ts +325 -0
- package/plugins/marketplace/marketplace/src/config.ts +432 -0
- package/plugins/marketplace/marketplace/src/errors.ts +79 -0
- package/plugins/marketplace/marketplace/src/index.ts +364 -0
- package/plugins/marketplace/marketplace/src/install.ts +930 -0
- package/plugins/marketplace/marketplace/src/jobs.ts +155 -0
- package/plugins/marketplace/marketplace/src/registry.ts +508 -0
- package/plugins/marketplace/marketplace/src/semver.ts +162 -0
- package/plugins/marketplace/marketplace/src/settings.ts +108 -0
- package/plugins/marketplace/marketplace/src/tar.ts +269 -0
- package/plugins/marketplace/marketplace/tsconfig.ui.json +26 -0
- package/plugins/marketplace/marketplace/vite.config.ts +107 -0
- package/plugins/marketplace/marketplace/web/assets/index-B2V7bx73.css +2 -0
- package/plugins/marketplace/marketplace/web/assets/index-B4NAz59m.js +13 -0
- package/plugins/marketplace/marketplace/web/index.html +13 -0
- package/plugins/marketplace/marketplace/web-src/App.tsx +193 -0
- package/plugins/marketplace/marketplace/web-src/api.ts +153 -0
- package/plugins/marketplace/marketplace/web-src/catalog.ts +27 -0
- package/plugins/marketplace/marketplace/web-src/components/ConfirmDialog.tsx +96 -0
- package/plugins/marketplace/marketplace/web-src/components/InstalledTable.tsx +152 -0
- package/plugins/marketplace/marketplace/web-src/components/JobStatus.tsx +70 -0
- package/plugins/marketplace/marketplace/web-src/components/Permissions.tsx +116 -0
- package/plugins/marketplace/marketplace/web-src/components/RegistryBanners.tsx +22 -0
- package/plugins/marketplace/marketplace/web-src/components/RegistrySetup.tsx +69 -0
- package/plugins/marketplace/marketplace/web-src/components/States.tsx +97 -0
- package/plugins/marketplace/marketplace/web-src/i18n.ts +337 -0
- package/plugins/marketplace/marketplace/web-src/index.html +12 -0
- package/plugins/marketplace/marketplace/web-src/main.tsx +17 -0
- package/plugins/marketplace/marketplace/web-src/styles.css +37 -0
- package/plugins/marketplace/marketplace/web-src/types.ts +175 -0
- package/plugins/marketplace/marketplace/web-src/views/InstalledView.tsx +150 -0
- package/plugins/marketplace/marketplace/web-src/views/MarketplaceView.tsx +479 -0
- package/plugins/marketplace/marketplace/web-src/views/UpdatesView.tsx +207 -0
- package/plugins/marketplace/marketplace/web-src/vite-env.d.ts +1 -0
- package/plugins/mcp/client/package.json +31 -0
- package/plugins/mcp/client/src/config-validate.ts +37 -0
- package/plugins/mcp/client/src/http-transport.ts +369 -0
- package/plugins/mcp/client/src/index.ts +35 -0
- package/plugins/mcp/client/src/json-rpc.ts +104 -0
- package/plugins/mcp/client/src/logging.ts +51 -0
- package/plugins/mcp/client/src/naming.ts +36 -0
- package/plugins/mcp/client/src/plugin.ts +310 -0
- package/plugins/mcp/client/src/registration.ts +143 -0
- package/plugins/mcp/client/src/server-connection.ts +556 -0
- package/plugins/mcp/client/src/stdio-transport.ts +377 -0
- package/plugins/mcp/client/src/transport.ts +11 -0
- package/plugins/mcp/client/src/types.ts +147 -0
- package/plugins/media/media/package.json +33 -0
- package/plugins/media/media/src/binaries.ts +88 -0
- package/plugins/media/media/src/config.ts +184 -0
- package/plugins/media/media/src/exec.ts +172 -0
- package/plugins/media/media/src/index.ts +125 -0
- package/plugins/media/media/src/tool.ts +640 -0
- package/plugins/observability/hook-logging/package.json +31 -0
- package/plugins/observability/hook-logging/src/index.ts +286 -0
- package/plugins/observability/usage/package.json +163 -0
- package/plugins/observability/usage/src/aggregate.ts +919 -0
- package/plugins/observability/usage/src/index.ts +362 -0
- package/plugins/observability/usage/src/query.ts +322 -0
- package/plugins/observability/usage/src/store.ts +1455 -0
- package/plugins/observability/usage/src/worker-client.ts +263 -0
- package/plugins/observability/usage/src/worker.ts +87 -0
- package/plugins/observability/usage/tsconfig.web.json +29 -0
- package/plugins/observability/usage/vite.config.embed.ts +105 -0
- package/plugins/observability/usage/vite.config.ts +121 -0
- package/plugins/observability/usage/web/assets/main-DD4g5VDL.css +2 -0
- package/plugins/observability/usage/web/assets/main-DVmWaf73.js +10 -0
- package/plugins/observability/usage/web/embed/index.css +3 -0
- package/plugins/observability/usage/web/embed/index.mjs +4560 -0
- package/plugins/observability/usage/web/logs.html +13 -0
- package/plugins/observability/usage/web/usage.html +13 -0
- package/plugins/observability/usage/web-src/App.tsx +54 -0
- package/plugins/observability/usage/web-src/LogsView.tsx +505 -0
- package/plugins/observability/usage/web-src/ModelTable.tsx +102 -0
- package/plugins/observability/usage/web-src/UsageView.tsx +210 -0
- package/plugins/observability/usage/web-src/embed.css +96 -0
- package/plugins/observability/usage/web-src/embed.tsx +75 -0
- package/plugins/observability/usage/web-src/env.d.ts +2 -0
- package/plugins/observability/usage/web-src/format.ts +88 -0
- package/plugins/observability/usage/web-src/i18n.ts +261 -0
- package/plugins/observability/usage/web-src/logs.html +12 -0
- package/plugins/observability/usage/web-src/main.tsx +19 -0
- package/plugins/observability/usage/web-src/shared.tsx +187 -0
- package/plugins/observability/usage/web-src/styles.css +22 -0
- package/plugins/observability/usage/web-src/usage.html +12 -0
- package/plugins/provider/anthropic/package.json +31 -0
- package/plugins/provider/anthropic/src/index.ts +75 -0
- package/plugins/provider/anthropic/src/retry.ts +266 -0
- package/plugins/provider/anthropic/src/timeout.ts +84 -0
- package/plugins/provider/model-registry/package.json +167 -0
- package/plugins/provider/model-registry/src/connectivity.ts +123 -0
- package/plugins/provider/model-registry/src/credential-store.ts +219 -0
- package/plugins/provider/model-registry/src/index.ts +453 -0
- package/plugins/provider/model-registry/src/registry-store.ts +223 -0
- package/plugins/provider/model-registry/tsconfig.web.json +29 -0
- package/plugins/provider/model-registry/vite.config.embed.ts +105 -0
- package/plugins/provider/model-registry/vite.config.ts +122 -0
- package/plugins/provider/model-registry/web/assets/main-BofPzD0n.js +10 -0
- package/plugins/provider/model-registry/web/assets/main-DkpGgdsZ.css +2 -0
- package/plugins/provider/model-registry/web/credentials.html +13 -0
- package/plugins/provider/model-registry/web/embed/index.css +3 -0
- package/plugins/provider/model-registry/web/embed/index.mjs +4887 -0
- package/plugins/provider/model-registry/web/models.html +13 -0
- package/plugins/provider/model-registry/web-src/App.tsx +54 -0
- package/plugins/provider/model-registry/web-src/CredentialsView.tsx +357 -0
- package/plugins/provider/model-registry/web-src/ModelForm.tsx +489 -0
- package/plugins/provider/model-registry/web-src/ModelsView.tsx +383 -0
- package/plugins/provider/model-registry/web-src/credentials.html +12 -0
- package/plugins/provider/model-registry/web-src/embed.css +96 -0
- package/plugins/provider/model-registry/web-src/embed.tsx +43 -0
- package/plugins/provider/model-registry/web-src/env.d.ts +2 -0
- package/plugins/provider/model-registry/web-src/i18n.ts +323 -0
- package/plugins/provider/model-registry/web-src/main.tsx +21 -0
- package/plugins/provider/model-registry/web-src/models.html +12 -0
- package/plugins/provider/model-registry/web-src/shared.tsx +147 -0
- package/plugins/provider/model-registry/web-src/styles.css +22 -0
- package/plugins/provider/model-registry/web-src/types.ts +120 -0
- package/plugins/provider/openai/package.json +31 -0
- package/plugins/provider/openai/src/index.ts +104 -0
- package/plugins/provider/openai/src/retry.ts +266 -0
- package/plugins/provider/openai/src/timeout.ts +84 -0
- package/plugins/provider/openai/src/vision.ts +121 -0
- package/plugins/security/guardrail-pii/package.json +31 -0
- package/plugins/security/guardrail-pii/src/index.ts +285 -0
- package/plugins/security/guardrail-pii/src/rules.ts +197 -0
- package/plugins/security/redact-secrets/package.json +31 -0
- package/plugins/security/redact-secrets/src/index.ts +145 -0
- package/plugins/security/redact-secrets/src/redactor.ts +83 -0
- package/plugins/security/redact-secrets/src/rules.ts +137 -0
- package/plugins/security/tool-policy/package.json +31 -0
- package/plugins/security/tool-policy/src/index.ts +184 -0
- package/plugins/tools/basic-tools/package.json +32 -0
- package/plugins/tools/basic-tools/src/background-jobs.ts +356 -0
- package/plugins/tools/basic-tools/src/bash-source.ts +58 -0
- package/plugins/tools/basic-tools/src/call-scope.ts +80 -0
- package/plugins/tools/basic-tools/src/config.ts +130 -0
- package/plugins/tools/basic-tools/src/index.ts +202 -0
- package/plugins/tools/basic-tools/src/path-boundary.ts +258 -0
- package/plugins/tools/basic-tools/src/shared.ts +221 -0
- package/plugins/tools/basic-tools/src/text.ts +49 -0
- package/plugins/tools/basic-tools/src/tools/bash-async.ts +1830 -0
- package/plugins/tools/basic-tools/src/tools/bash-exec.ts +567 -0
- package/plugins/tools/basic-tools/src/tools/bash.ts +300 -0
- package/plugins/tools/basic-tools/src/tools/edit.ts +160 -0
- package/plugins/tools/basic-tools/src/tools/grep.ts +601 -0
- package/plugins/tools/basic-tools/src/tools/read.ts +151 -0
- package/plugins/tools/basic-tools/src/tools/write.ts +494 -0
- package/plugins/tools/basic-tools/src/write-coord.ts +291 -0
- package/plugins/tools/basic-tools/src/write-lock.ts +353 -0
- package/plugins/tools/engine-client/package.json +34 -0
- package/plugins/tools/engine-client/src/client.ts +276 -0
- package/plugins/tools/engine-client/src/forward.ts +164 -0
- package/plugins/tools/engine-client/src/index.ts +18 -0
- package/plugins/tools/engine-client/src/pending.ts +101 -0
- package/plugins/tools/engine-client/src/pool.ts +1173 -0
- package/plugins/tools/engine-client/src/protocol.ts +249 -0
- package/plugins/tools/engine-client/src/registry.ts +138 -0
- package/plugins/tools/file-refs/README.md +68 -0
- package/plugins/tools/file-refs/package.json +135 -0
- package/plugins/tools/file-refs/src/index.ts +24 -0
- package/plugins/tools/file-refs/tsconfig.web.json +27 -0
- package/plugins/tools/file-refs/vite.config.embed.ts +88 -0
- package/plugins/tools/file-refs/web/embed/index.css +3 -0
- package/plugins/tools/file-refs/web/embed/index.mjs +879 -0
- package/plugins/tools/file-refs/web-src/AttachSheet.tsx +613 -0
- package/plugins/tools/file-refs/web-src/FileRefCard.tsx +206 -0
- package/plugins/tools/file-refs/web-src/FileRefLinkCard.tsx +90 -0
- package/plugins/tools/file-refs/web-src/attach-handler.tsx +116 -0
- package/plugins/tools/file-refs/web-src/attach-paths.ts +69 -0
- package/plugins/tools/file-refs/web-src/drop-handler.ts +15 -0
- package/plugins/tools/file-refs/web-src/embed.css +518 -0
- package/plugins/tools/file-refs/web-src/embed.tsx +18 -0
- package/plugins/tools/file-refs/web-src/env.d.ts +2 -0
- package/plugins/tools/file-refs/web-src/i18n.ts +137 -0
- package/plugins/tools/file-refs/web-src/icons.tsx +122 -0
- package/plugins/tools/file-refs/web-src/staging.ts +120 -0
- package/plugins/tools/file-refs/web-src/thumbnail.tsx +36 -0
- package/plugins/tools/recall/package.json +31 -0
- package/plugins/tools/recall/src/config.ts +74 -0
- package/plugins/tools/recall/src/index.ts +151 -0
- package/plugins/tools/recall/src/tool.ts +307 -0
- package/plugins/tools/web-tools/README.md +330 -0
- package/plugins/tools/web-tools/package.json +184 -0
- package/plugins/tools/web-tools/src/backends.ts +61 -0
- package/plugins/tools/web-tools/src/budget.ts +80 -0
- package/plugins/tools/web-tools/src/cache.ts +94 -0
- package/plugins/tools/web-tools/src/config.ts +412 -0
- package/plugins/tools/web-tools/src/deepseek-client.ts +406 -0
- package/plugins/tools/web-tools/src/deepseek-fetch.ts +168 -0
- package/plugins/tools/web-tools/src/extract.ts +373 -0
- package/plugins/tools/web-tools/src/fetch/local.ts +36 -0
- package/plugins/tools/web-tools/src/fetch/provider.ts +56 -0
- package/plugins/tools/web-tools/src/http.ts +415 -0
- package/plugins/tools/web-tools/src/index.ts +649 -0
- package/plugins/tools/web-tools/src/limits.ts +388 -0
- package/plugins/tools/web-tools/src/provider-http.ts +102 -0
- package/plugins/tools/web-tools/src/render.ts +248 -0
- package/plugins/tools/web-tools/src/robots.ts +187 -0
- package/plugins/tools/web-tools/src/search/custom.ts +595 -0
- package/plugins/tools/web-tools/src/search/deepseek.ts +111 -0
- package/plugins/tools/web-tools/src/search/index.ts +725 -0
- package/plugins/tools/web-tools/src/search/provider.ts +200 -0
- package/plugins/tools/web-tools/src/search/serper.ts +157 -0
- package/plugins/tools/web-tools/src/search/tavily.ts +146 -0
- package/plugins/tools/web-tools/src/secrets.ts +87 -0
- package/plugins/tools/web-tools/src/ssrf.ts +287 -0
- package/plugins/tools/web-tools/src/types.ts +137 -0
- package/skills/code-writing.md +33 -0
- package/src/agent/agent-control.ts +409 -0
- package/src/agent/agent-owner-client.ts +150 -0
- package/src/agent/agent-owner-server.ts +689 -0
- package/src/agent/agent-service-wiring.ts +675 -0
- package/src/agent/agent-wiring.ts +48 -0
- package/src/agent/ask-answer-delivery.ts +215 -0
- package/src/agent/local-run-adapter.ts +335 -0
- package/src/agent/peer-notices.ts +459 -0
- package/src/agent/peer-source.ts +63 -0
- package/src/agent/self-card.ts +52 -0
- package/src/agent/team-human-delivery.ts +144 -0
- package/src/assembly/collect.ts +161 -0
- package/src/assembly/feature.ts +133 -0
- package/src/assembly/features/attachments.ts +38 -0
- package/src/assembly/features/fleet.ts +31 -0
- package/src/assembly/features/jobs.ts +32 -0
- package/src/assembly/features/kanban.ts +56 -0
- package/src/assembly/features/restart.ts +35 -0
- package/src/assembly/features/subscription.ts +32 -0
- package/src/assembly/features.ts +30 -0
- package/src/cli/agent-call.ts +107 -0
- package/src/cli/args.ts +551 -0
- package/src/cli/ask-channel.ts +447 -0
- package/src/cli/command-spec/agent.ts +306 -0
- package/src/cli/command-spec/config.ts +179 -0
- package/src/cli/command-spec/define.ts +86 -0
- package/src/cli/command-spec/federation.ts +333 -0
- package/src/cli/command-spec/flags.ts +668 -0
- package/src/cli/command-spec/gateway.ts +350 -0
- package/src/cli/command-spec/hub.ts +290 -0
- package/src/cli/command-spec/kanban.ts +134 -0
- package/src/cli/command-spec/misc.ts +1032 -0
- package/src/cli/command-spec/model.ts +338 -0
- package/src/cli/command-spec/node.ts +160 -0
- package/src/cli/command-spec/plugin.ts +148 -0
- package/src/cli/command-spec/shared.ts +86 -0
- package/src/cli/command-spec/team.ts +582 -0
- package/src/cli/command-spec/token.ts +111 -0
- package/src/cli/command-spec.ts +270 -0
- package/src/cli/command-support.ts +53 -0
- package/src/cli/commands/agent/agent-command.ts +279 -0
- package/src/cli/commands/agent/agent-inbox-command.ts +141 -0
- package/src/cli/commands/agent/agents-command.ts +145 -0
- package/src/cli/commands/attention.ts +896 -0
- package/src/cli/commands/cli-update.ts +283 -0
- package/src/cli/commands/completion-command.ts +29 -0
- package/src/cli/commands/config-command.ts +545 -0
- package/src/cli/commands/dev-command.ts +429 -0
- package/src/cli/commands/doctor-command.ts +873 -0
- package/src/cli/commands/doctor-fleet.ts +410 -0
- package/src/cli/commands/errors-command.ts +469 -0
- package/src/cli/commands/eval-command.ts +168 -0
- package/src/cli/commands/federation-pair.ts +426 -0
- package/src/cli/commands/federation-peer.ts +445 -0
- package/src/cli/commands/federation.ts +527 -0
- package/src/cli/commands/fleet/fleet-inventory.ts +222 -0
- package/src/cli/commands/fleet/fleet-status-command.ts +433 -0
- package/src/cli/commands/fleet/ps-command.ts +387 -0
- package/src/cli/commands/fleet/restart-command.ts +745 -0
- package/src/cli/commands/fleet/start-command.ts +176 -0
- package/src/cli/commands/fleet/status-command.ts +318 -0
- package/src/cli/commands/fleet/stop-command.ts +548 -0
- package/src/cli/commands/gateway/gateway-command.ts +4204 -0
- package/src/cli/commands/gateway/gateway-nodes-command.ts +401 -0
- package/src/cli/commands/hub-command.ts +1007 -0
- package/src/cli/commands/kanban-command.ts +204 -0
- package/src/cli/commands/logs-command.ts +148 -0
- package/src/cli/commands/migrate-command.ts +131 -0
- package/src/cli/commands/model.ts +427 -0
- package/src/cli/commands/node-command.ts +805 -0
- package/src/cli/commands/permission/permission-show-command.ts +189 -0
- package/src/cli/commands/plugin/plugin-cli-command.ts +831 -0
- package/src/cli/commands/plugin/plugin-cli-local.ts +267 -0
- package/src/cli/commands/plugin/plugin-command.ts +407 -0
- package/src/cli/commands/prune-command.ts +233 -0
- package/src/cli/commands/resume-command.ts +100 -0
- package/src/cli/commands/rpc-command.ts +226 -0
- package/src/cli/commands/session/session-status-command.ts +352 -0
- package/src/cli/commands/team-command.ts +722 -0
- package/src/cli/commands/token-command.ts +494 -0
- package/src/cli/commands/trace-command.ts +133 -0
- package/src/cli/completion-script.ts +627 -0
- package/src/cli/completion-spec.ts +101 -0
- package/src/cli/control-plane-target.ts +295 -0
- package/src/cli/control-plane-types.ts +189 -0
- package/src/cli/feishu-command.ts +45 -0
- package/src/cli/headless-runner.ts +354 -0
- package/src/cli/help-search.ts +320 -0
- package/src/cli/help.ts +489 -0
- package/src/cli/output.ts +141 -0
- package/src/cli/parse-engine.ts +701 -0
- package/src/cli/parse-validators.ts +155 -0
- package/src/cli/project.ts +355 -0
- package/src/cli/registry.ts +25 -0
- package/src/cli.ts +2272 -0
- package/src/config/cli-overrides.ts +74 -0
- package/src/config/config-error-format.ts +44 -0
- package/src/config/config-snapshot.ts +15 -0
- package/src/config/config-watch.ts +436 -0
- package/src/config/config-write-apply.ts +98 -0
- package/src/config/empty-response-settings.ts +49 -0
- package/src/config/hot-apply-appliers.ts +527 -0
- package/src/config/hot-apply-assembly.ts +317 -0
- package/src/config/legacy-tool-names.ts +48 -0
- package/src/config/permission-defaults.ts +26 -0
- package/src/config/ui-settings.ts +568 -0
- package/src/config/vision-settings.ts +98 -0
- package/src/data/attachment-ingest.ts +101 -0
- package/src/data/attachment-staging.ts +377 -0
- package/src/data/attachments-list.ts +240 -0
- package/src/data/auto-prune.ts +342 -0
- package/src/data/data-lock.ts +580 -0
- package/src/data/data-paths.ts +265 -0
- package/src/data/image-blob-gc.ts +341 -0
- package/src/data/migrate.ts +480 -0
- package/src/data/path-resolution.ts +172 -0
- package/src/data/permission-store.ts +322 -0
- package/src/data/prune-wiring.ts +1037 -0
- package/src/data/refs-notice-hook.ts +417 -0
- package/src/federation/attention-client.ts +196 -0
- package/src/federation/attention-nodes.ts +142 -0
- package/src/federation/federation-address.ts +276 -0
- package/src/federation/federation-client.ts +620 -0
- package/src/federation/federation-config.ts +222 -0
- package/src/federation/federation-outbox.ts +374 -0
- package/src/federation/federation-pair-store.ts +236 -0
- package/src/federation/federation-pairing.ts +176 -0
- package/src/federation/federation-peer-store.ts +145 -0
- package/src/federation/federation-secrets.ts +140 -0
- package/src/federation/federation-send-port.ts +436 -0
- package/src/gateway/clean-spawn.ts +260 -0
- package/src/gateway/daemon.ts +336 -0
- package/src/gateway/fleet-index.ts +262 -0
- package/src/gateway/gateway-banner.ts +199 -0
- package/src/gateway/gateway-config-control.ts +53 -0
- package/src/gateway/gateway-reload-wiring.ts +512 -0
- package/src/gateway/gateway-wiring.ts +113 -0
- package/src/gateway/handoff.ts +131 -0
- package/src/gateway/instance-lock.ts +244 -0
- package/src/gateway/interactions-dir.ts +27 -0
- package/src/gateway/node-listen.ts +123 -0
- package/src/gateway/node-registry.ts +401 -0
- package/src/gateway/node-supervisor.ts +2226 -0
- package/src/gateway/pid.ts +827 -0
- package/src/gateway/pool-supervisor.ts +1150 -0
- package/src/gateway/reload.ts +238 -0
- package/src/gateway/restart-stop-exemption.ts +43 -0
- package/src/gateway/self-restart.ts +147 -0
- package/src/gateway/serve-auth.ts +184 -0
- package/src/gateway/serve-config.ts +135 -0
- package/src/gateway/service.ts +361 -0
- package/src/gateway/shutdown-report.ts +47 -0
- package/src/gateway/shutdown-sequence.ts +70 -0
- package/src/gateway/stop-drain.ts +299 -0
- package/src/gateway/stop-nodes-marker.ts +151 -0
- package/src/gateway/transport-factory.ts +53 -0
- package/src/gateway/watchdog.ts +622 -0
- package/src/gateway/web-dist.ts +1155 -0
- package/src/hub/client-protocol.ts +43 -0
- package/src/hub/derive-origins.ts +193 -0
- package/src/hub/hub-wiring.ts +310 -0
- package/src/hub/inbound-control.ts +432 -0
- package/src/hub/join-policy.ts +75 -0
- package/src/hub/join-store.ts +243 -0
- package/src/hub/node-credential-store.ts +295 -0
- package/src/hub/node-state.ts +279 -0
- package/src/hub/node-url.ts +33 -0
- package/src/hub/outbound-client.ts +509 -0
- package/src/hub/outbound-wiring.ts +168 -0
- package/src/hub/pairing-code.ts +27 -0
- package/src/hub/registry.ts +575 -0
- package/src/hub/runtime.ts +599 -0
- package/src/hub/secret-store.ts +571 -0
- package/src/hub/server.ts +1032 -0
- package/src/hub/snapshot-policy.ts +67 -0
- package/src/hub/types.ts +258 -0
- package/src/i18n/index.ts +94 -0
- package/src/i18n/messages/en.ts +1462 -0
- package/src/i18n/messages/zh-CN.ts +1323 -0
- package/src/mock/scenarios.ts +165 -0
- package/src/node/node-auto-resume.ts +264 -0
- package/src/node/node-drain.ts +520 -0
- package/src/node/node-identity.ts +240 -0
- package/src/node/node-resume.ts +511 -0
- package/src/node/resume-scan.ts +97 -0
- package/src/node/token-derive.ts +504 -0
- package/src/observability/logging.ts +72 -0
- package/src/observability/observability-wiring.ts +82 -0
- package/src/observability/startup-timing.ts +151 -0
- package/src/observability/trace-wiring.ts +250 -0
- package/src/observability/usage-pricing.ts +80 -0
- package/src/plugin/eval-wiring.ts +175 -0
- package/src/plugin/feishu-wiring.ts +250 -0
- package/src/plugin/mcp-wiring.ts +200 -0
- package/src/plugin/plugin-config.ts +491 -0
- package/src/plugin/plugin-host-assembly.ts +448 -0
- package/src/plugin/plugin-lifecycle.ts +130 -0
- package/src/plugin/plugin-loader.ts +788 -0
- package/src/plugin/plugin-manifest.ts +1936 -0
- package/src/plugin/plugin-selection.ts +200 -0
- package/src/plugin/plugin-surface.ts +207 -0
- package/src/plugin/plugin-watch.ts +114 -0
- package/src/rpc/http-client.ts +579 -0
- package/src/rpc/index.ts +34 -0
- package/src/rpc/local-client.ts +55 -0
- package/src/rpc/types.ts +125 -0
- package/src/run/connect-run-wait.ts +544 -0
- package/src/run/durable-wiring.ts +133 -0
- package/src/run/lease-service.ts +510 -0
- package/src/run/run-control.ts +160 -0
- package/src/run/run-record-store-factory.ts +89 -0
- package/src/runtime/agent-activity-watch.ts +335 -0
- package/src/runtime/agent-assembly.ts +818 -0
- package/src/runtime/agent-events-bridge.ts +86 -0
- package/src/runtime/bash-job-delivery.ts +291 -0
- package/src/runtime/bootstrap-connect.ts +644 -0
- package/src/runtime/bootstrap-types.ts +303 -0
- package/src/runtime/bootstrap.ts +1020 -0
- package/src/runtime/bus-source.ts +62 -0
- package/src/runtime/gc-assembly.ts +214 -0
- package/src/runtime/local-rpc-surface.ts +301 -0
- package/src/runtime/model-registry-wiring.ts +653 -0
- package/src/runtime/node-health-watch.ts +484 -0
- package/src/runtime/node-restart.ts +444 -0
- package/src/runtime/process-handlers.ts +164 -0
- package/src/runtime/provider-factory.ts +86 -0
- package/src/runtime/reasoning.ts +47 -0
- package/src/runtime/repl-context.ts +234 -0
- package/src/runtime/runtime-notice-hook.ts +357 -0
- package/src/runtime/runtime-notice.ts +273 -0
- package/src/runtime/session-id.ts +15 -0
- package/src/runtime/shutdown-sequence.ts +429 -0
- package/src/runtime/subscription-mute-bridge.ts +99 -0
- package/src/runtime/subscription-rpc-port.ts +597 -0
- package/src/runtime/team-log-bridge.ts +46 -0
- package/src/runtime/tenant-runtime-factory.ts +1838 -0
- package/src/runtime/thinking-agent-bridge.ts +57 -0
- package/src/runtime/tool-output-env.ts +80 -0
- package/src/runtime/vessel-meta.ts +338 -0
- package/src/session/context-composition.ts +147 -0
- package/src/session/context-ratio-source.ts +165 -0
- package/src/session/context-usage.ts +346 -0
- package/src/session/image-delivery.ts +297 -0
- package/src/session/session-control.ts +135 -0
- package/src/session/session-events.ts +144 -0
- package/src/session/session-factory.ts +73 -0
- package/src/session/session-liveness.ts +405 -0
- package/src/session/session-lock-runtime.ts +64 -0
- package/src/session/session-lock.ts +399 -0
- package/src/session/session-resume.ts +282 -0
- package/src/session/system-context.ts +235 -0
- package/src/session/timeline-dual-write.ts +2129 -0
- package/src/session/timeline-session-log.ts +140 -0
- package/src/shared/port-in-use.ts +27 -0
- package/src/shared/socket-inherit-guard.ts +13 -0
- package/src/shared/version.ts +38 -0
- package/src/tools-engine/engine.ts +286 -0
- package/src/tools-engine/entry.ts +757 -0
- package/src/tools-engine/mcp-engine-wiring.ts +354 -0
- package/src/tools-engine/mcp.ts +324 -0
- package/src/tools-engine/supervisor.ts +234 -0
- package/src/tools-engine/tools-list.ts +148 -0
- package/src/tools-engine/validate.ts +395 -0
- package/src/tools-engine/wiring.ts +88 -0
- package/src/tools-engine/worker.ts +110 -0
- package/src/update/background.ts +64 -0
- package/src/update/cache.ts +70 -0
- package/src/update/check.ts +138 -0
- package/src/update/gateway-check.ts +231 -0
- package/src/update/install-detect.ts +125 -0
- package/src/update/manifest.ts +132 -0
- package/src/update/semver.ts +70 -0
- package/src/update/stage.ts +219 -0
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DesignLabContent-CY5HfVn_.js","assets/react-vendor-CUu194FT.js","assets/plugin-ui-BxTydP3l.js","assets/ConfigView-BKdxb1s5.js","assets/DesignLabView-DTBWv5-E.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as u,j as o,R as ka,a as fr,J as ix,b as ax,c as lx,d as cx,e as dx}from"./react-vendor-CUu194FT.js";import{B as G,c as be,S as Tn,F as We,I as Xe,a as Re,C as Hn,b as $t,T as Hi,d as et,K as Gt,e as Nn,f as En,P as Ct,g as Kh,h as ux,i as mx,j as fx,k as hx,D as $n,l as jt}from"./plugin-ui-BxTydP3l.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();const px=/^(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,gx=/^(\d+)(?:\.(\d+))?(?:\.(\d+))?$/,bx=/^(>=|<=|>|<|=|\^|~)?(\d+(?:\.\d+)?(?:\.\d+)?)$/;function xc(e){const t=px.exec(e.trim());return t?{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}:null}function Wh(e){const t=gx.exec(e.trim());return t?{major:Number(t[1]),minor:t[2]!==void 0?Number(t[2]):0,patch:t[3]!==void 0?Number(t[3]):0}:null}function vx(e){return xc(e)!==null}function Uh(e,t){return e.major!==t.major?e.major-t.major:e.minor!==t.minor?e.minor-t.minor:e.patch-t.patch}function yx(e,t,n){let s;return e==="~"?s=n>=1?{major:t.major,minor:t.minor+1,patch:0}:{major:t.major+1,minor:0,patch:0}:t.major>0||n===0?s={major:t.major+1,minor:0,patch:0}:t.minor>0||n===1?s={major:0,minor:t.minor+1,patch:0}:s={major:0,minor:0,patch:t.patch+1},[{op:">=",version:t},{op:"<",version:s}]}function zh(e){const t=[];for(const n of e.split("||")){const s=n.trim();if(s==="")return null;const r=[];for(const i of s.split(/\s+/)){const l=bx.exec(i);if(!l)return null;const c=Wh(l[2]??"");if(!c)return null;const d=l[1]??"=";if(d==="^"||d==="~"){const m=((l[2]??"").match(/\./g)??[]).length;r.push(...yx(d,c,m))}else r.push({op:d,version:c})}t.push(r)}return t.length>0?t:null}function Vh(e,t){const n=Uh(e,t.version);switch(t.op){case">=":return n>=0;case"<=":return n<=0;case">":return n>0;case"<":return n<0;default:return n===0}}function vl(e,t){const n=xc(e),s=zh(t);return!n||!s?!1:s.some(r=>r.every(i=>Vh(n,i)))}function xx(e,t){return t.some(n=>n==="*"||n===e||n.endsWith(".*")&&e.startsWith(n.slice(0,-1)))}function wx(e,t){switch(t){case"process":return e.process===!0;case"secrets":return e.secrets===!0;case"fs":return(e.fs?.length??0)>0;case"net":return(e.net?.length??0)>0;case"events":return(e.events?.length??0)>0;case"rpc":return(e.rpc?.length??0)>0;default:return!1}}function Gh(e){const t={pluginId:e.pluginId,sdkVersion:e.sdkVersion,rpc(n,s){return e.rpcMethods.includes(n)?e.rpc(`plugin.${e.pluginId}.${n}`,s):Promise.reject(new Error(`plugin_rpc_denied: "${n}" is not declared in contributes.rpc`))},events:Object.freeze({subscribe(n,s){if(!xx(n,e.eventPatterns))throw new Error(`plugin_permission_denied: event "${n}" is not allowed by permissions.events`);return e.subscribeEvent(n,s)}}),theme:Object.freeze({get:()=>e.theme.get(),subscribe:n=>e.theme.subscribe(n)}),toast:n=>e.toast(n),i18n:Object.freeze({t:(n,s)=>e.i18n.t(n,s)}),log:(n,s,r)=>e.log(n,s,r),permissions:Object.freeze({has:n=>wx(e.permissions,n)}),attachments:Object.freeze({preview:n=>e.attachments===void 0?Promise.reject(new Error("attachments_unavailable: host adapter has no attachments")):e.attachments.preview(n),stage:n=>e.attachments===void 0?Promise.reject(new Error("attachments_unavailable: host adapter has no attachments")):e.attachments.stage(n),openPreview:n=>e.attachments===void 0?Promise.reject(new Error("attachments_unavailable: host adapter has no attachments")):e.attachments.openPreview(n)})};return Object.freeze(t)}const kx=Object.freeze(Object.defineProperty({__proto__:null,compareSemver:Uh,createPluginHost:Gh,isValidSemver:vx,parseRangeVersion:Wh,parseSemver:xc,parseVersionRange:zh,satisfiesComparator:Vh,satisfiesVersionRange:vl},Symbol.toStringTag,{value:"Module"})),Sx={"entity.scopeIn":"in","entity.currentNode":"current","entity.details":"Details","entity.unnamed":"Unnamed","nav.domain.chat":"Sessions","nav.domain.pending":"Messages","nav.domain.runs":"Runs","nav.domain.integrations":"Integrations","nav.domain.capabilities":"Capabilities","nav.domain.visual":"Visuals","nav.domain.tools":"Tools","nav.domain.mcp":"MCP servers","nav.domain.channels":"Channels","nav.domain.observe":"Observe","nav.domain.plugins":"Plugins","nav.domain.settings":"Settings","nav.domain.designLab":"Design Lab","nav.group.chat":"Chat","nav.group.items":"Items","nav.group.current":"Current page is in this group","nav.group.runs":"RUNS","nav.group.plugins":"PLUGINS","nav.group.observe":"OBSERVE","nav.group.top":"TOP","nav.group.settings":"SETTINGS","nav.settings":"Settings","nav.group.integrations":"Integrations","nav.group.core":"Core","nav.mainLabel":"Main navigation","nav.bottomLabel":"Main navigation (mobile)","nav.openNav":"Open navigation","nav.closeNav":"Close navigation","nav.openSessions":"Open session list","nav.closeSessions":"Close session list","nav.collapseNav":"Collapse sidebar","nav.expandNav":"Expand sidebar","nav.jumpToMain":"Skip to main content","webBuild.outdated":"Front-end update available, reload to load the new version","webBuild.building":"Front-end update is being built…","webBuild.buildingHint":"A new front-end version is being prepared in the background. This banner switches to a reload prompt when it is ready — reloading now still shows the old UI.","webBuild.stale":"Front-end update failed. Restart to retry","webBuild.autobuildOff":"Front-end auto-rebuild is off (nothing will rebuild it)","webBuild.reload":"Reload","rotateFollow.countdown":"Switching to the new session of {name} in {seconds}s","rotateFollow.ready":"New session ready ({name})","rotateFollow.switch":"Switch now","nav.more":"More","nav.diagnostics":"Diagnostics","nav.moreSheet":"More navigation","nav.connectionNamed":"Connection: {value}","nav.conn.online":"online","nav.conn.connecting":"Connecting…","nav.conn.connectingShort":"Connecting","nav.conn.reconnecting":"Reconnecting…","nav.conn.reconnectingShort":"Reconnecting","nav.conn.closed":"Disconnected","nav.conn.error":"Connection failed","nav.conn.idle":"Not connected","nav.status.online":"Online","nav.status.connecting":"Connecting","nav.status.error":"Error","nav.status.offline":"Not connected","nav.status.unknown":"Unknown","nav.status.hubConnected":"Hub connected","nav.status.hubUnauthorized":"Hub token rejected","nav.status.hubIncompatible":"Hub protocol incompatible","nav.status.hubNetwork":"Hub unreachable","nav.status.hubNotConfigured":"Hub not configured","nav.status.pluginHostNoMarketplace":"Marketplace plugin not installed","nav.status.pluginHostLoading":"Reading plugin list","nav.status.pluginHostListError":"Failed to read plugin list","nav.connStatusTitle":"Gateway connection status; click to open connection settings","nav.searchOrCommand":"Search or type a command","nav.opened":"Opened {path}","nav.openNamed":"Open {domain}","nav.count":"{count} pending","nav.hintNavigation":"Navigation","breadcrumb.chat":"Sessions","breadcrumb.chat.conversation":"Conversation","breadcrumb.pending":"Approvals","breadcrumb.runs.live":"Live","breadcrumb.runs.durable":"Recoverable","breadcrumb.runs":"Runs","breadcrumb.runs.details":"Details","breadcrumb.tools":"Tools","breadcrumb.mcp":"MCP servers","breadcrumb.channels":"Channels","breadcrumb.kanban":"Kanban","breadcrumb.plugins":"Plugins","pluginHost.noTokenReason":"Connect to a gateway to inspect the plugin host.","pluginHost.disconnectedReason":"Connect to a gateway to inspect the plugin host.","pluginHost.loading":"Loading plugins…","pluginHost.status.title":"Marketplace status","pluginHost.field.enabled":"Enabled","pluginHost.field.status":"Status","pluginHost.field.version":"Version","pluginHost.field.mode":"Mode","pluginHost.field.plugins":"Plugins","pluginHost.enabled.on":"Enabled","pluginHost.enabled.off":"Disabled","pluginHost.status.active":"Active","pluginHost.status.inactive":"Inactive","pluginHost.status.lazy":"Host connected, plugin idle until used","pluginHost.status.hostConnected":"Host connected","pluginHost.status.unhealthy":"Unhealthy","pluginHost.status.disabled":"Disabled","pluginHost.status.invalid":"Invalid","pluginHost.mode.in-process":"In process","pluginHost.mode.child":"Child process","pluginHost.marketplaceMissing":"Marketplace plugin not found.","pluginHost.registry.title":"Registry","pluginHost.registry.hint":"HTTPS registry index URL; http is allowed for localhost only.","pluginHost.registry.label":"Registry URL","pluginHost.registry.placeholder":"https://example.com/registry/index.json","pluginHost.registry.save":"Save","pluginHost.registry.saving":"Saving…","pluginHost.registry.saved":"Registry URL saved.","pluginHost.registry.invalid":"Enter an HTTPS URL (http is allowed for localhost).","pluginHost.registry.disabledHint":"Enable the marketplace plugin to edit this setting.","pluginHost.registry.disconnectedHint":"Connect to the gateway to edit this setting.","breadcrumb.observe":"Observe","breadcrumb.observe.metrics":"Metrics","breadcrumb.observe.evals":"Evals","breadcrumb.settings":"Settings","breadcrumb.capabilities":"Capabilities","breadcrumb.designLab":"Design Lab","settings.title":"Settings","settings.category.visual":"Visual","settings.category.display":"Display & Visibility","settings.category.runtime":"Runtime","settings.category.logs":"Logs","settings.category.connection":"Connection","settings.category.advancedConfig":"Advanced","settings.category.extensions":"Extensions","settings.item.local.navCollapsed.title":"Collapse sidebar by default","settings.item.local.navCollapsed.desc":"Default collapsed state of the left nav when the WebUI opens; the sidebar toggle writes the same storage key.","settings.item.local.navGroups.title":"Group expansion state","settings.item.local.navGroups.desc":"Expanded state of left-nav groups (read-only); reset = collapse all.","settings.item.local.settingsTree.title":"Settings tree collapse state","settings.item.local.settingsTree.desc":"Collapsed categories of the settings dialog tree (JSON array, this browser only).","settings.item.local.settingsTab.title":"Default settings tab","settings.item.local.settingsTab.desc":"Scope tab selected when the settings dialog opens (User / Workspace / Browser).","settings.item.view.designLab.title":"Design Lab","settings.item.view.designLab.desc":"Design tokens and component previews (static samples, no gateway needed).","settings.item.view.connection.title":"Connection summary","settings.item.view.connection.desc":"Gateway connection state / node / version (read-only diagnostics).","settings.item.view.advancedConfig.title":"Advanced configuration","settings.item.view.advancedConfig.desc":"Resolved configuration JSON, key/value table and sources (read-only).","settings.item.verbosity.title":"Verbosity","settings.item.showInternalEvents.title":"Show system info (internal events)","settings.item.showInternalEvents.desc":"Off keeps only replies, tool calls, errors and permission/ask cards. On adds runtime notices, hook / LLM context and other system messages; the vessel:* transcript messages follow this key too, and verbosity=debug shows them as well.","settings.group.messageVisibility":"Message display","settings.group.envNotice":"Environment notices","settings.env.default.title":"Default cadence","settings.env.default.desc":"Fallback detection cadence for scopes not listed below. Per-scope settings override this.","settings.env.cadence.request":"Every request","settings.env.cadence.run":"Every run","settings.env.cadence.off":"Off","settings.env.delivery.desc":"How often the model is told about this kind of environment change. Off silences it entirely (no card, no model injection).","settings.env.pinned.desc":'Pinned to "Every run" to keep the request prefix stable; "Every request" is not allowed. Off silences it (the model will no longer be told about this change).',"settings.env.files.desc":"How often subscribed-file changes are reported. Side-channel writes (bash / builds / git) cannot be attributed to an editor and still notify.","settings.env.channel.desc":'Delivery channel. "Model + UI" injects into the model context and shows a card; "UI only" shows the card but the model is not injected.',"settings.env.channel.modelUi":"Model + UI","settings.env.channel.uiOnly":"UI only","settings.item.tools.title":"Tool cards","settings.item.tools.desc":"Show tool call cards. Off keeps only a one-line running status; failed tool cards always show (failures are never silent).","settings.item.environment.title":"Environment info","settings.item.environment.desc":"Environment cards: config hot-apply, permission, tool, MCP, update and peer notices — the model context hints (vessel:notice).","settings.item.source.title":"Source cards","settings.item.source.desc":"Projection source cards (principal / node / team). Source lines absorbed into agent cards are unaffected.","settings.item.system.title":"System info","settings.item.system.desc":"Internal events and system context messages (runtime notices, hook / LLM context and other vessel:* messages); verbosity=debug shows them too. When unset, the legacy ui.showInternalEvents value applies.","settings.item.showArchived.title":"Show archived / closed (pending removal)","settings.item.showArchived.desc":'Archived Teams and closed agents are hidden by default (both are waiting to be pruned). On brings them back to the Team list, Agent list and member sidebar with an "archived / closed · pending removal" badge. Direct links are unaffected and always open.',"settings.item.showRetiredSessions.title":"Show retired sessions","settings.item.showRetiredSessions.desc":"Retired sessions (old bodies from before a rotate, grey subtitle) are hidden from the session card list by default. On brings them back unchanged. Hiding is not deleting: search and direct links always open them.","settings.item.errorLevel.title":"Error level","settings.item.showProcessErrors.title":"Show process errors","settings.item.askUser.title":"Allow ask","settings.item.askUser.desc":"Registration setting: takes effect on a new connection or after a gateway restart.","settings.item.showReasoning.title":"Thinking process","settings.item.showReasoning.desc":"Show the model reasoning (live stream and history). Off by default (explicit opt-in); turning it on applies immediately without restart. verbosity=minimal still hides reasoning.","settings.item.expandCards.title":"Expand cards by default","settings.item.expandCards.desc":"Tool, system and queued cards start expanded; permission and ask cards always do. A manual toggle on a card wins over the default.","settings.item.addressStyle.title":"Address display style","settings.item.addressStyle.desc":"How addresses render in source lines and route sublines: name = use names where available (main@soulkiller:vessel); compact = short node id; full = full uuid. Display only — routing always uses the full address.","settings.item.statusBars.title":"Status bar position","settings.item.language.title":"UI language","settings.item.logLevel.title":"Log level","settings.item.logColor.title":"Log color","settings.item.logFormat.title":"Log format","settings.item.logTime.title":"Log time","settings.item.emptyResponseEnabled.title":"Empty-response fallback","settings.item.emptyResponseEnabled.desc":"When the model returns an empty reply (no content, no tool calls), retry instead of ending the run with zero output (seamless re-call by default; see below).","settings.item.emptyResponseSeamless.title":"Seamless retry (no nudge scar)","settings.item.emptyResponseSeamless.desc":"On: discard the empty turn and re-call the model with the existing transcript — no injected message, no scar. If still empty after the retry budget, one nudge is injected as a last resort. Off: always inject the nudge.","settings.item.emptyResponseMaxRetries.title":"Empty-response retries","settings.item.emptyResponseMaxRetries.desc":"Max retries per run (integer 0–10), shared by seamless re-calls and nudges. When exhausted the run ends gracefully with a logged notice.","settings.item.emptyResponseNudge.title":"Empty-response nudge text","settings.item.emptyResponseNudge.desc":"Custom nudge injected as a user message. Leave unset to keep the built-in wording.","settings.group.depthColor":"Depth color","settings.item.depthColorEnabled.title":"Color by tree depth","settings.item.depthColorEnabled.desc":"Rotate the hue of the session-card address subtitle (name@node:team) by agent tree depth (root=0, +1 per level); off = all back to the theme accent. Retired bodies / primary badges stay grey (state semantics first).","settings.item.depthColorRootHue.title":"Root hue","settings.item.depthColorRootHue.desc":"Hue of the root (depth 0) address, degrees [0, 360). Default 172.6 = current brand accent hue (zero regression in light).","settings.item.depthColorHueStep.title":"Hue step per level","settings.item.depthColorHueStep.desc":"Hue increment per deeper level, degrees [0, 360]. Default 137.508 ≈ golden angle (360/φ²): irrational rotation never repeats exactly, endless rotation without saturation; 0/360 = no rotation (monochrome).","settings.item.depthColorLightnessLight.title":"Light lightness (OKLCH L)","settings.item.depthColorLightnessLight.desc":"Light-theme perceptual lightness [0.30, 0.51]; upper bound locked by WCAG contrast evidence (all hues ≥4.5:1). Default 0.4714 = exact L of the current accent.","settings.item.depthColorChromaLight.title":"Light chroma (OKLCH C)","settings.item.depthColorChromaLight.desc":"Light-theme chroma [0, 0.37]; out-of-gamut hues are automatically desaturated by the browser (L/H preserved). Default 0.0887 = exact C of the current accent.","settings.item.depthColorLightnessDark.title":"Dark lightness (OKLCH L)","settings.item.depthColorLightnessDark.desc":"Dark-theme perceptual lightness [0.73, 0.95]; lower bound locked by full-chroma WCAG contrast evidence (≥4.5:1). Default 0.85 (distinctiveness first).","settings.item.depthColorChromaDark.title":"Dark chroma (OKLCH C)","settings.item.depthColorChromaDark.desc":"Dark-theme chroma [0, 0.37]; default 0.13. Higher chroma = more vivid rotation; out-of-gamut hues are automatically desaturated.","settings.item.teamMemberLimit.title":"Team member limit","settings.item.teamMemberLimit.desc":"Max present members (peers + contractors, including closed-but-not-departed) per team; positive integer ≥ 1, default 100. Spawns beyond the limit fail with team_full. Requires a node restart to apply.","settings.item.imageTokenBudgetRatio.title":"Image token budget ratio","settings.item.imageTokenBudgetRatio.desc":"Share of the context window reserved for inlined images (0–1, default 0.05). The image count cap is derived from this budget divided by per-image tokens, clamped to the backend safety cap (32). Larger windows allow more images; overflow drops the newest images with a notice to the model. Requires a node restart to apply.","settings.item.toolResultWhitelist.title":"Tool result trim whitelist","settings.item.toolResultWhitelist.desc":"Tool results matching a rule ({tool, action?}) keep their original text in the request view instead of being turned into placeholders (trim-exempt). Segment-boundary compaction still summarizes them as usual. Unset = built-in default (inbox read + agent read); explicit [] = disabled; an explicit list replaces the default. YAML-only (context.tool_result_whitelist); read-only here. Requires a node restart to apply.","settings.dialog.searchPlaceholder":"Search settings… (@modified / @plugin:<id> / @local / @user)","settings.dialog.tabUser":"User","settings.dialog.tabProject":"Workspace","settings.dialog.tabLocal":"Browser","settings.dialog.filterModified":"Modified (@modified)","settings.dialog.filterPlugin":"Plugin (@plugin:<id>)","settings.dialog.filterScope":"Scope (@local / @user / @project)","settings.dialog.clearFilters":"Clear filters","settings.dialog.noMatches":"No matching settings","settings.dialog.resetDefault":"Reset to default","settings.dialog.resetDone":"Reset to default: {key}","settings.dialog.saved":"Saved: {key}","settings.dialog.saveFailed":"Save failed: {detail}","settings.dialog.saveUnconfirmed":"Written but unconfirmed: {key}","settings.dialog.writeUnavailable":"This gateway has no settings write face; read-only","settings.dialog.configUnavailable":"This gateway has no config control plane.","settings.dialog.scopeUser":"User","settings.dialog.scopeProject":"Workspace","settings.dialog.scopeLocal":"Local","settings.dialog.modified":"Modified","settings.dialog.readOnly":"Read-only","settings.dialog.envOverride":"Overridden by environment variable {env}","settings.dialog.restartRequired":"Takes effect after reloading the plugin","settings.dialog.reloadPlugin":"Reload","settings.dialog.copyKey":"Copy key path","settings.dialog.loading":"Loading settings…","settings.dialog.openGateway":"Open Gateway page","settings.dialog.openDesignLab":"Expand Design Lab","settings.dialog.fullscreen":"Open fullscreen","settings.dialog.collapseTree":"Collapse category tree","settings.dialog.expandTree":"Expand category tree","settings.dialog.editInYaml":"Edit in vessel.yaml","settings.dialog.expandAll":"Expand all","settings.dialog.pluginReloaded":"Plugin reloaded","settings.connection.devProxyNotice":"Dev proxy auth is enabled: connecting to the same-origin gateway forwarded by the Vite dev server. No token is stored in the browser.","settings.multinode.name":"Name","settings.multinode.namePlaceholder":"e.g. office-gw","settings.multinode.url":"Gateway URL","settings.multinode.urlPlaceholder":"https://gw.example.com:8642","settings.multinode.token":"Token","settings.multinode.tokenPlaceholder":"gateway / team token","settings.multinode.add":"Add node","settings.multinode.added":"Added node {name}","settings.multinode.storageHint":"Name, URL and token are kept in sessionStorage only; tokens are never echoed after adding.","settings.multinode.error.name_required":"Enter a node name","settings.multinode.error.name_duplicate":"A node with this name already exists","settings.multinode.error.url_invalid":"Enter a valid gateway URL","settings.multinode.error.token_required":"Enter a token","appearance.theme.title":"Theme","appearance.theme.desc":"Dark by default; System follows prefers-color-scheme. Your choice persists across reloads.","appearance.theme.system":"System","appearance.theme.light":"Light","appearance.theme.dark":"Dark","appearance.motion.title":"Motion","appearance.motion.desc":"Motion follows the system prefers-reduced-motion setting; there is no separate switch. When reduced motion is on, drawers, the command palette and status pulses are disabled.","appearance.language.zh":"简体中文","appearance.language.en":"English","language.toggleTo":"Switch interface language to {language}","language.short.zh":"中文","language.short.en":"EN","common.cancel":"Cancel","common.close":"Close","common.expand":"Expand","common.collapse":"Collapse","common.confirm":"Confirm","common.loading":"Loading…","common.processing":"Working…","common.retry":"Retry","common.refresh":"Refresh","common.loadFailed":"Failed to load","permission.busy":"Submitting…","permission.expired":"Request expired; removed from the pending list.","permission.allowOnce":"Allow once","permission.allowSession":"Allow for session","permission.always":"Always allow","permission.deny":"Deny","permission.inline.waiting":"Waiting for approval","permission.expand":"Show full arguments","permission.collapse":"Collapse to 12 lines","permission.truncated":"Arguments truncated (20,000 character limit)","permission.runEnded":"The run has ended; this permission request is no longer valid.","permission.goTo":"Review","pending.bar.summary":"{count} pending request(s) in other sessions","pending.bar.unresolved":"Owning session not found","pending.bar.goPending":"Open pending","chat.prompt.label":"Conversation input slot","chat.composer.input":"Message input","chat.prompt.permission":"Permission request","chat.prompt.question":"Answer required","chat.prompt.blocking":"Conversation paused until resolved","chat.prompt.more":"{count} more pending","chat.prompt.disconnected":"Disconnected; reconnect to continue","chat.restoringSession":"Restoring the last session…","chat.welcome.brand":"Vessel","chat.welcome.question":"What do you want to do today?","chat.draft.title":"New session","chat.draft.meta":"The session is created when you send the first message","chat.draft.pickSession":"Pick a session on the left, or start a new one","pending.queue.permission":"Permission · {tool}","pending.queue.ask":"Question · Q{index}","chat.session.running":"Running","chat.session.queued":"Queued","chat.session.pending":"{count} pending request(s)","chat.session.copyId":"Copy session ID","chat.session.copiedId":"Session ID copied","chat.session.copyIdTitle":"Copy session ID: {title}","chat.memberModel.button":"Model","chat.memberModel.tooltip":"Switch member model (applies to the next body)","chat.memberModel.title":"Switch model · {name}","chat.memberModel.currentPin":"Currently pinned: {model}","chat.memberModel.currentBody":"This body currently runs: {model}","chat.memberModel.currentUnknown":"Current model of this body is unknown (no run yet, or older gateway).","chat.memberModel.hint":"Picking a registered model pins it for this member: the live body and current run stay unchanged; it applies to the next body / resumed run, when an environment notice is appended to the session. Empty = no change.","chat.memberModel.saved":"Model updated for {name}; applies to the next body / resumed run","chat.memberModel.failed":"Model switch failed","chat.memberModel.draftTooltip":"Pick a model for the new session (pinned at creation)","chat.memberModel.draftTitle":"New session model","chat.memberModel.draftHint":"Picking a registered model pins it for the agent when the new session is created; empty = follow the node default. The choice is held in the draft and persisted on first send.","chat.thinking.label":"Thinking:","chat.thinking.draftHint":"Available after creation","time.today":"Today","time.yesterday":"Yesterday","time.justNow":"just now","time.minutesAgo":"{count}m ago","time.hoursAgo":"{count}h ago","time.hoursMinutesAgo":"{count}h{minutes}m ago","time.daysAgo":"{count}d ago","chat.context.tokens":"{used} tokens","chat.context.percentOf":"{percent}% / {used}","resize.nav":"Resize navigation","resize.sessions":"Resize session list","resize.chat":"Resize content width","resize.teams":"Resize team list","chat.reasoning.summary":"Thinking","chat.run.cancelling":"Cancelling…","chat.run.cancelQueue":"Cancel queued run","chat.run.queuedPosition":"Queued · position {position}","chat.run.stop":"Stop","chat.run.stopping":"Stopping…","chat.run.detail":"View run details","chat.run.noError":"(no error details)","chat.run.retryable":"Retryable","chat.run.hiddenEarlier":"Showing the latest {shown} runs; open run details for the earlier {hidden}.","chat.run.reason.lease":"Session lease lost (machine sleep or another instance took over); this run was interrupted","chat.run.reason.locked":"Session held by another instance; this run was interrupted","chat.run.reason.rateLimited":"Model rate limit or quota exhausted; this run was interrupted","chat.run.reason.contextTooLong":"Prompt exceeded the model context window; this run was interrupted","chat.run.failed":"Run failed","chat.run.failure.aria":"Run failure details","chat.run.failure.run":"Run {id}","chat.run.failure.fromRecord":"From the session record: this turn’s live events are no longer buffered, so only the error summary is kept.","chat.reasoning.thinking":"Thinking…","chat.reasoning.expand":"Show all","chat.reasoning.collapse":"Collapse","chat.reasoning.copy":"Copy thinking","chat.reasoning.copyBody":"Copy body","chat.reasoning.copied":"Thinking copied","chat.tool.input":"Input","chat.tool.output":"Output","chat.tool.diff":"Changes","chat.tool.error":"Error","chat.tool.copy":"Copy","chat.tool.meta":"Metadata","chat.tool.retryable":"Retryable","chat.tool.truncated":"Output truncated","chat.tool.route":"Route","chat.tool.resolvedTo":"Resolved to {target}","chat.projection.badge.placeholder":"Model saw: placeholder","chat.projection.badge.placeholderHint":"This tool result was replaced by a placeholder ([cleared …]): the model sees the placeholder, the original is still on this card.","chat.projection.badge.externalize":"Model saw: handle","chat.projection.badge.externalizeHint":"This tool result was replaced by a handle reference: the model sees the handle, the body has to be read back.","chat.projection.badge.reason.readback":"The original is no longer in the messages, only in the event log.","chat.projection.badge.reason.gone":"The original is unrecoverable.","chat.projection.tabsLabel":"Projection view","chat.projection.tab.original":"Original","chat.projection.tab.model":"Model view","chat.projection.original":"Original","chat.projection.modelView":"Model view","chat.projection.copyOriginal":"Copy original","chat.projection.copyModel":"Copy what the model saw","chat.projection.readbackTail":"Recover the truncated tail","chat.projection.readbackFromLog":"Recover the original behind the placeholder","chat.projection.readbackUnsupported":"Reading this kind of original back is not wired up yet.","chat.projection.notInMessage":"The original is not in the messages (only the placeholder is).","chat.projection.gone":"The original is unrecoverable.","chat.projection.truncatedWarn":"Truncated to the first {limit} of {bytes} B.","chat.projection.truncatedWarnUnknown":"Truncated to the first {limit}; original size unknown.","chat.projection.meta.tool":"tool","chat.projection.meta.bytes":"original","chat.projection.meta.sinceSeq":"since seq","chat.projection.meta.unknown":"unknown","chat.projection.bytes":"{bytes} B","chat.projection.summary.total":"Session total: {total} projected · {saved} B saved","chat.projection.summary.lowerBound":"({count} without a known original size, so this is a lower bound)","chat.tool.previewLines":"Preview {shown}/{total} lines","chat.tool.loadMore":"Load more ({loaded}/{total} KB)","chat.tool.showAll":"Show all {total} lines","chat.tool.description":"Description","chat.tool.descriptionUnavailable":"Description unavailable","chat.tool.status.running":"Running","chat.tool.status.history":"From history","chat.tool.outputMissing":"This call has no recorded output in history (it may have been truncated).","chat.tool.status.done":"Done","chat.tool.status.error":"Failed","chat.tool.duration.millis":"{value}ms","chat.tool.duration.minutes":"{minutes}m {seconds}s","ask.title":"Agent question","ask.asyncBadge":"Deferred (the answer starts a new run)","ask.goTo":"Answer","ask.pendingMore":"{count} more pending","ask.progress":"Question {current} of {total}","ask.next":"Next","ask.previous":"Previous","ask.answerRequired":"Answer this question first","ask.submit":"Submit","ask.customPlaceholder.options":"Or type a custom answer","ask.customPlaceholder.open":"Type an answer","pending.title":"Messages","pending.subtitle":"Permission approvals, ask questions and notices share one clustered list (grouped by agent), ordered by priority: requests blocking a run come first, notices last. Permissions are decided one by one, each question answered on its own, notices just read and acknowledged.","pending.empty":"No pending requests","pending.empty.hint":"Permission requests, ask questions and notices show up here as soon as an agent raises them.","pending.kind.notify":"Notice","pending.notice.empty":"No unread notices","pending.notice.ack":"Acknowledge","pending.notice.ackAll":"Mark all read","pending.notice.high":"Important","pending.notice.count":"{count} unread","pending.notice.refs":"Attachments","pending.fetch.failed":"Could not load the pending list: {detail}","pending.fetch.failedHint":"Empty here does not mean nothing is pending — the list never arrived. It is restored automatically after you sign in again or fix the connection.","pending.fetch.blocked":"The gateway rejected the request, so the pending list is unavailable: {detail}","pending.fetch.shortFailed":"Pending list unavailable","pending.fetch.shortBlocked":"Pending list unavailable (request rejected)","pending.fetch.retry":"Retry","pending.entry":"Pending","pending.entry.label":"{count} pending request(s) in this session","pending.cluster.agent":"Agent {id}","pending.cluster.session":"Session {id}","pending.cluster.run":"Run {id}","pending.cluster.home":"Home {id}","pending.cluster.count":"{count} pending","pending.cluster.expand":"Show details","pending.cluster.collapse":"Collapse","pending.source.session":"Session","pending.source.team":"Team","pending.item.include":"Reply to this","pending.item.answered":"Already answered","pending.answeredGroup.expand":"Answered ({count}) · show","pending.answeredGroup.collapse":"Answered ({count}) · hide","pending.item.includeAll":"Select all","pending.item.responding":"Replying…","pending.submit":"Reply","pending.submit.busy":"Replying…","pending.submit.count":"{count} selected","pending.submit.note":"Only the questions you answered are submitted; the rest stay in the pending queue for later.","pending.answerRequired":"Checked questions without an answer are skipped in this reply.","chat.subagents.title":"Subagents","chat.subagents.running":"{count} running","chat.subagents.details":"Details","chat.subagents.view":"View transcript","chat.subagents.back":"Back to session","chat.subagents.emptyRun":"No child run events yet","chat.subagents.crumb":"Subagent","chat.subagents.queuePosition":"Queue #{position}","chat.subagents.context":"Context {used}/{max}","plugins.page.loading":"Loading plugin page…","plugins.page.notConnected":"Not connected","plugins.page.notConnectedReason":"Connect to the gateway to load plugin pages.","plugins.page.notFound":"Plugin page unavailable","plugins.page.notFoundReason":"This plugin is not installed, is disabled, or does not contribute this page.","plugins.frame.loading":"Loading plugin UI…","plugins.frame.loadError":"Plugin UI failed to load","plugins.frame.invalidEntry":"Invalid plugin page entry","plugins.embed.loading":"Loading plugin component…","plugins.embed.errorTitle":"Plugin component failed to render","plugins.embed.errorBody":"{plugin}: {error}","plugins.embed.useIsolated":"Switch to isolated mode","plugins.embed.incompatibleTitle":"Plugin version incompatible","plugins.embed.incompatibleBody":"Host runtime does not satisfy the plugin declaration: {detail}","plugins.embed.failedTitle":"Plugin component failed to load","plugins.embed.failedBody":"Could not load the embedded component: {detail}","plugins.panel.label":"{title} (plugin {plugin})","observe.title":"Observe","observe.description":"Metrics, evals, diagnostics and attention. Event history lives in run details.","observe.tabsLabel":"Observe sections","observe.panelLabel":"Observe content","observe.tab.metrics":"Metrics","observe.tab.evals":"Evals","observe.tab.diagnostics":"Diagnostics","observe.tab.attention":"Attention","breadcrumb.observe.diagnostics":"Diagnostics","breadcrumb.observe.attention":"Attention","observe.attention.noToken":"Not connected","observe.attention.noTokenReason":"Connect to read pending and orphaned interactions.","observe.attention.forbidden":"This token cannot read interactions (401/403)","observe.attention.forbiddenReason":"Use a gateway token or a team-scoped control token with read access.","observe.attention.hint":"Read-only inbox across Teams on this node. Respond in the owning session card; this page never answers requests.","observe.attention.statusLabel":"Attention status","observe.attention.status.pending":"Pending","observe.attention.status.orphaned":"Orphaned","observe.attention.panelLabel":"Attention inbox","observe.attention.total":"{count} items","observe.attention.refresh":"Refresh","observe.attention.refreshing":"Refreshing…","observe.attention.loading":"Loading interactions…","observe.attention.loadingMore":"Loading…","observe.attention.loadMore":"Load more","observe.attention.stale":"Update failed; showing the last loaded page.","observe.attention.empty.pending":"No pending interactions","observe.attention.empty.orphaned":"No orphaned interactions","observe.attention.emptyHint":"Interactions appear here while an agent waits for a human decision.","observe.attention.col.kind":"Kind","observe.attention.col.request":"Request","observe.attention.col.tool":"Tool","observe.attention.col.agent":"Agent","observe.attention.col.team":"Team","observe.attention.col.time":"Created","observe.attention.nodesHint":"Grouped by node, read-only. A failing node only affects its own group.","observe.attention.currentNode":"Current","observe.attention.remoteReadonly":"Read-only aggregate; only sessions on the current node can be opened.","observe.attention.remoteRowHint":"This request belongs to another node; read-only here.","observe.diagnostics.noToken":"Not connected","observe.diagnostics.noTokenReason":"Connect to read runtime state and diagnostic events.","observe.diagnostics.disconnected":"Disconnected; showing the last snapshot.","observe.diagnostics.queueTitle":"Run queue","observe.diagnostics.errorsTitle":"Diagnostic errors","observe.diagnostics.refresh":"Refresh","observe.diagnostics.loading":"Loading runtime…","observe.diagnostics.queueEmpty":"Queue is empty","observe.diagnostics.empty":"No matching diagnostic errors","observe.diagnostics.gateHint":"process / shutdown / hook / plugin errors are hidden by default; set ui.errorLevel: all or observability.showProcessErrors: true.","observe.diagnostics.col.status":"Status","observe.diagnostics.col.session":"Session","observe.diagnostics.col.queuePosition":"Position","observe.diagnostics.col.waitReason":"Wait reason","observe.diagnostics.noWaitReason":"—","observe.diagnostics.activeRun":"active run","observe.diagnostics.stats":"queued {queued} · running {running}","observe.diagnostics.retryable":"retryable","observe.diagnostics.fatal":"not retryable","observe.diagnostics.runtimeTitle":"Runtime","observe.diagnostics.nodeStatus":"Node status","observe.diagnostics.provider":"Provider","observe.diagnostics.model":"Model","observe.diagnostics.uptime":"Uptime","observe.diagnostics.clients":"Clients","observe.diagnostics.mcpTitle":"MCP servers","observe.diagnostics.mcpNotEnabled":"MCP is not enabled","observe.diagnostics.mcpNotEnabledReason":"No MCP servers are configured for this node.","observe.diagnostics.mcpEmpty":"No MCP servers","observe.diagnostics.col.mcpServer":"Server","observe.diagnostics.col.mcpStatus":"Status","observe.diagnostics.col.mcpTools":"Tools","observe.diagnostics.col.mcpError":"Error","observe.diagnostics.pluginsTitle":"Plugins","observe.diagnostics.pluginsCount":"{enabled}/{total} enabled","observe.diagnostics.pluginsEmpty":"No enabled plugins","observe.diagnostics.capabilitiesTitle":"Capabilities","observe.diagnostics.version":"Version","observe.diagnostics.methods":"Methods","observe.diagnostics.tools":"Tools","observe.diagnostics.sourcesTitle":"Config sources","observe.diagnostics.userPath":"User config","observe.diagnostics.projectPath":"Project config","observe.diagnostics.overlayKeys":"Overlay keys","observe.diagnostics.notAvailable":"Not available","observe.diagnostics.doctorTitle":"Self-check","observe.diagnostics.doctorHint":"Nine self-checks read from existing RPC data. Checks the gateway cannot observe state why instead of guessing.","observe.diagnostics.doctorColCheck":"Check","observe.diagnostics.doctorColStatus":"Status","observe.diagnostics.doctorColSource":"Source","observe.diagnostics.doctorColDetail":"Detail","observe.diagnostics.doctor.status.ok":"ok","observe.diagnostics.doctor.status.warn":"warn","observe.diagnostics.doctor.status.fail":"fail","observe.diagnostics.doctor.status.info":"info","observe.diagnostics.doctor.status.unavailable":"unavailable","observe.diagnostics.doctor.pending":"Waiting for data","observe.diagnostics.doctor.set":"<set>","observe.diagnostics.doctor.unset":"<unset>","observe.diagnostics.doctor.config.detail":"user={user} · project={project}","observe.diagnostics.doctor.config.unverified":"Config validation errors/warnings are not exposed by gateway RPC; run a self-check on the machine hosting the app","observe.diagnostics.doctor.provider.detail":"{provider} / {model} / api key {key}","observe.diagnostics.doctor.dataDir.configured":"{path} (source: {source})","observe.diagnostics.doctor.dataDir.gatewayDecided":"decided by the gateway (not reported; remote or older gateway)","observe.diagnostics.doctor.session.relative":"relative to the gateway data dir","observe.diagnostics.doctor.dataDir.unverified":"Writability can only be confirmed by a self-check on the host","observe.diagnostics.doctor.session.memory":"backend=memory (no persistence)","observe.diagnostics.doctor.session.detail":"backend={backend} · path={path}","observe.diagnostics.doctor.session.derived":"derived from the data dir; the resolved path was not confirmed on the host","observe.diagnostics.doctor.writability":"writability not verified (needs a host self-check)","observe.diagnostics.doctor.plugins.ok":"{enabled} enabled / {total} discovered","observe.diagnostics.doctor.plugins.missing":"unknown configured plugin(s): {names}","observe.diagnostics.doctor.mcp.invalid":"invalid server config: {names}","observe.diagnostics.doctor.mcp.rpc":"{servers} server(s) via RPC / {configured} configured","observe.diagnostics.doctor.mcp.disabled":"MCP is not enabled on this gateway","observe.diagnostics.doctor.mcp.unavailable":"MCP status unavailable","observe.diagnostics.doctor.servePort.notConfigured":"node.port is not configured; doctor skips this check","observe.diagnostics.doctor.servePort.systemPort":"{host}:0 (system-assigned) · endpoint {endpoint}","observe.diagnostics.doctor.servePort.detail":"{host}:{port} configured · endpoint {endpoint}","observe.diagnostics.doctor.servePort.unverified":"Port bindability needs a host self-check; the browser cannot bind","observe.diagnostics.doctor.attach.disconnected":"Gateway is not attached","observe.diagnostics.doctor.feishu.disabled":"Feishu is not enabled","observe.diagnostics.doctor.feishu.detail":"app id {appId}, app secret {appSecret}","team.list.search":"Search Teams","team.list.clearSearch":"Clear search","team.chat.members":"Members","team.chat.empty":"No messages yet","team.chat.emptyHint":"Mention a member with @ to notify that agent.","team.chat.loadedEarlier":"Loaded earlier messages","team.chat.historyOutOfWindow":"Older history is outside the local retention window; keeping what is already loaded.","team.chat.historyChanged":"Earlier team history was rewritten; the newest page has been reloaded.","team.chat.backToList":"Back to Teams","team.chat.loadMoreMembers":"Load more members","team.chat.membersCapped":"Only the first {shown} of {total} members are shown","team.members.open":"View member list","team.members.close":"Hide member list","team.members.matches":"Matched {matched} of {total} loaded","team.members.search":"Search by name or role","team.members.empty":"No matching members","team.composer.input":"Message the Team","team.composer.send":"Send","team.composer.sending":"Sending…","team.composer.hint":"Enter to send · Shift+Enter for a new line","team.composer.noMention":"No @ mention · message is only logged and notifies no agent","team.composer.disconnected":"Disconnected; reconnect to send","team.composer.tooLarge":"Message exceeds the {limit} KiB limit","team.mention.title":"Mention members","team.mention.empty":"No matching members","team.mention.hint":"Only present members of this Team are suggested","team.mention.remove":"Remove {name}","team.message.you":"You","team.message.agentTag":"agent","team.message.replyTag":"Reply","team.message.toHumanTag":"For you","team.message.toHumanHint":"This log is a message from an agent to the human","team.message.systemTag":"System","team.message.viewBody":"View member session","team.message.edit":"Edit","team.message.editRecallFailed":"Could not recall the copy in the member inbox; draft not refilled: {detail}","team.message.resend":"Resend","team.message.delete":"Delete","team.message.deleteTitle":"Delete message","team.message.deleteBody":"This message will be hidden from the Team view and the copies in member inboxes will be deleted (except any already running); the log keeps a deletion marker and later replies remain. This cannot be undone.","team.message.deleteConfirm":"Delete","team.message.deleteDone":"Deleted","team.federation.from":"federation from","team.federation.reply":"Reply by address","team.federation.replyHint":'Copied {addr}. Web does not send federation directly; use the agent tool send with to="{addr}".',"team.system.join":"{name} joined the Team","team.system.leave":"{name} left the Team","team.system.archive":"The Team was archived","team.system.create":"{name} created a new session","team.system.fork":"agent forked (legacy record)","team.system.retract":"{name} deleted a message","team.system.unknown":"Team system event","team.delivery.queued":"Queued","team.delivery.queuedRotating":"Waiting for the next session","team.delivery.queuedCreated":"Created and queued","team.delivery.queuedForked":"Forked and queued (legacy record)","team.delivery.rejected":"Rejected","team.delivery.error":"Delivery failed","team.delivery.retry":"Send again","team.delivery.retryHint":"This writes a new log entry","team.delivery.failed":"Send failed","team.state.idle":"Idle","team.state.running":"Working","team.state.waitingPermission":"Waiting for approval","team.state.completed":"Completed","team.state.failed":"Failed","team.state.cancelled":"Cancelled","team.state.closed":"Closed","team.state.unknown":"Unknown","team.presence.live":"Live","team.presence.gone":"Offline","team.membership.present":"Present","team.membership.left":"Left","team.attention.pending":"Pending","team.attention.count":"{count} pending","team.pending.title":"Pending approvals ({count})","team.pending.hint":"From this Team's member sessions","team.pending.permission":"Permission","team.pending.ask":"Question","team.member.title":"Member","team.member.currentBody":"Current session","team.member.liveBodies":"Active sessions ({count})","team.member.primaryBadge":"primary","team.member.openBody":"Open this session","team.member.retiredBodies":"Past sessions","team.member.subs.tabLabel":"Member detail view","team.member.subs.tab.overview":"Overview","team.member.subs.tab.subscriptions":"Subscriptions","team.member.subs.title":"Explicit subscriptions","team.member.subs.empty":"No explicit subscriptions yet; add below or use the subscribe tool.","team.member.subs.implicitTitle":"Implicit sources (default on)","team.member.subs.muted":"muted","team.member.subs.on":"on","team.member.subs.mute":"Mute","team.member.subs.unmute":"Unmute","team.member.subs.friend":"friend ({origin})","team.member.subs.origin":"origin {origin}","team.member.subs.remove":"Remove","team.member.subs.removeTitle":"Remove subscription","team.member.subs.removeBody":"Changes to this target will no longer notify this member.","team.member.subs.removeFriendHint":"Entries with a friend edge are muted, not deleted (unfollow ≠ unfriend).","team.member.subs.removeSuccess":"Subscription removed","team.member.subs.removeMuted":"Muted (friend edge kept)","team.member.subs.addTitle":"Add subscription","team.member.subs.addSource":"Source","team.member.subs.addTarget":"Target","team.member.subs.addPlaceholder":"file path / node / script name / member / team","team.member.subs.add":"Subscribe","team.member.subs.addSuccess":"Subscribed to {target}","team.member.subs.poolTitle":"Subscribable pool","team.member.subs.pool.implicitHint":"inbox / bash-job / bus are on by default; manage them in the implicit section above.","team.member.subs.pool.scripts":"Scripts (user-config declared)","team.member.subs.pool.nodes":"Nodes","team.member.subs.pool.agents":"Members","team.member.subs.pool.teams":"Team logs","team.member.subs.pool.file":"File allowed roots","team.member.subs.schedule.run":"per run","team.member.subs.schedule.request":"per request","team.member.subs.schedule.interval":"every {seconds}s","team.member.subs.truncated":"Catalog exceeded the cap and was truncated.","team.member.subs.degraded":"This node does not support the catalog projection (old gateway); free-form targets still work.","team.member.subs.error":"Subscription operation failed","team.member.sessionNumber":"Session #","team.member.sessionIndex":"Session {n}","team.member.startedAt":"Started {time}","team.member.retiredAt":"Retired {time}","team.member.observedAt":"Observed {time}","team.member.empty":"No past sessions","team.member.viewTranscript":"View read-only transcript","team.member.observedOnly":"Observed during this page session; after a refresh only the current session is shown.","team.member.currentSession":"View current session","team.member.rotate.open":"New session","team.member.rotate.title":"Start a new session","team.member.rotate.description":"Creates a new empty session for {name} and makes it primary. The previous session is retired but kept; history is not deleted.","team.member.rotate.startupLabel":"Startup prompt (first message of the new session)","team.member.rotate.confirm":"Create session","team.member.rotate.success":"Created a new session for {name}; the previous one is kept read-only.","team.member.rotate.defaultPrompt":"You are {name}. Continue with your previous responsibilities and the current task.","team.member.rotate.error.notFound":"Member not found. Refresh and try again.","team.member.rotate.error.conflict":"This member cannot start a new session right now (running, closed, or Team limit).","team.member.rotate.error.invalid":"Invalid parameters for the new session. Refresh and try again.","team.member.rotate.error.quota":"Session quota is exhausted; cannot create a new session.","team.role.member":"member","team.role.temporary":"temporary","team.role.label":"Role","team.role.convert":"Convert role","team.role.toMember":"Convert to member","team.role.toTemporary":"Convert to temporary","team.role.memberTeam":"Team","team.role.memberRequiresTeam":"Converting to member requires a Team.","team.role.forbidden":"This token cannot convert the member.","team.role.failed":"Conversion failed","team.role.success":"Converted {name} to {role}","team.role.busy":"Converting…","team.error.notFound":"Team not found","team.error.notEnabled":"Team is not enabled","team.error.notEnabledReason":"This gateway does not expose teams.*.","team.error.notEnabledHint":"Upgrade the gateway or switch to a node with Team enabled.","team.error.noToken":"Not connected to a gateway","team.error.noTokenReason":"Connect to read Teams.","team.error.stale":"Refresh failed; showing the last data read.","team.error.loadFailed":"Failed to load the Team","team.a11y.memberList":"Member list","team.a11y.mentionList":"Mention suggestions","team.a11y.deliveryQueued":"Delivery queued","team.a11y.closeMembers":"Close member list","nav.domain.hub":"Hub","nav.domain.gateway":"Gateway","nav.domain.pluginHost":"Plugin Host","nav.domain.nodes":"Nodes","nav.domain.teams":"Teams","nav.domain.kanban":"Kanban","nav.domain.agents":"Agents","nav.group.network":"ORCHESTRATION","breadcrumb.hub":"Hub","breadcrumb.gateway":"Gateway","breadcrumb.pluginHost":"Plugin Host","breadcrumb.nodes":"Nodes","breadcrumb.teams":"Teams","breadcrumb.teams.agent":"Agent","breadcrumb.agents":"Agents","common.edit":"Edit","common.archive":"Archive","common.remove":"Remove","common.copy":"Copy","common.copied":"Copied","hub.title":"Hub","hub.subtitle":"Direct browser view of a Hub directory. Pairing and token management stay in Nodes / CLI.","hub.connect.title":"Connect to a Hub","hub.connect.description":"Enter the Hub service URL and its read token. The token is kept in this browser tab only.","hub.connect.url":"Hub URL","hub.connect.urlHint":"Use the Hub origin (for example http://127.0.0.1:8643). This page origin is {origin}; add it to the Hub hub.allowedOrigins value.","hub.connect.token":"Hub read token","hub.connect.tokenHint":"Optional for a loopback Hub, required remotely. A saved token is never shown again.","hub.connect.tokenPlaceholder":"Hub read token","hub.connect.submit":"Connect","hub.connect.connecting":"Checking…","hub.connect.clear":"Clear connection","hub.connect.error.invalid":"Enter a valid http(s) Hub URL without path, query, or credentials.","hub.connect.error.mixed":"This page is served over HTTPS, so the Hub URL must use https.","hub.connect.error.origin":"Cannot reach the Hub. Check the URL and that the Hub hub.allowedOrigins includes {origin}.","hub.connect.error.http":"The Hub rejected the connection. Check the Hub URL and token.","hub.directory.loading":"Loading Hub directory…","hub.directory.title":"Directory","hub.directory.description":"Hub {hub} at {url}. Metadata only; the Hub does not proxy content.","hub.directory.empty":"No nodes in this Hub directory yet","hub.directory.emptyHint":"This node has not joined any Hub yet; the directory appears here once it does.","hub.directory.connecting":"Connecting to the Hub for live updates…","hub.directory.reconnecting":"Hub connection lost; reconnecting…","hub.directory.pointer":"Node {node} has updates.","hub.directory.col.name":"Node","hub.directory.col.status":"Status","hub.directory.col.teams":"Teams","hub.directory.col.agents":"Agents","hub.directory.col.liveAgents":"Live agents","hub.directory.col.lastSeen":"Last seen","hub.directory.col.dataPlane":"Data plane","hub.directory.dataPlane.direct":"direct","hub.directory.dataPlane.unreachable":"control only","hub.node.status.connecting":"Connecting","hub.node.status.healthy":"Healthy","hub.node.status.unreachable":"Unreachable","hub.node.status.incompatible":"Incompatible","hub.node.status.unauthorized":"Unauthorized","hub.node.status.identityMismatch":"Identity mismatch","hub.error.unauthorized":"Hub token rejected","hub.error.unauthorizedReason":"The saved Hub read token is invalid or expired. Enter a new one.","hub.error.incompatible":"Hub protocol is not compatible","hub.error.incompatibleReason":"This page speaks vessel.hub/2. Update the Hub or the Platform.","hub.error.origin":"Cannot reach the Hub at this address. Confirm the URL and that the Hub hub.allowedOrigins includes {origin}.","gateway.title":"Gateway","gateway.field.status":"Status","gateway.field.connection":"Connection","gateway.field.endpoint":"endpoint","gateway.field.node":"Node","gateway.field.version":"Version","gateway.field.startedAt":"Started","gateway.field.uptime":"Uptime","gateway.diagnosticsHint":"Runtime queue and diagnostic events.","gateway.state.ok":"OK","gateway.state.error":"Error","gateway.state.connecting":"Loading…","gateway.noToken":"Not connected to a gateway","gateway.noTokenReason":"Connect to read gateway status.","duration.seconds":"{seconds}s","duration.minutes":"{minutes}m","duration.hours":"{hours}h","duration.hoursMinutes":"{hours}h {minutes}m","duration.daysHours":"{days}d {hours}h","nodes.title":"Nodes","nodes.empty":"No reachable node","nodes.notFound":"Node is not in this page’s node list","nodes.notFoundHint":"It may have been removed; go back and choose another node.","nodes.back":"All nodes","nodes.section.health":"Health","nodes.section.dataPlane":"Data plane","nodes.field.nodeId":"node_id","nodes.field.pid":"PID","nodes.field.startedAt":"Started","nodes.field.endpoint":"endpoint","nodes.field.protocol":"Protocol","nodes.field.incarnation":"incarnation","nodes.field.teams":"teams","nodes.field.agents":"agents","nodes.field.online":"online","nodes.field.role":"Role","nodes.health.ok":"Reachable","nodes.health.error":"Unreachable","nodes.health.loading":"Loading…","nodes.health.unknown":"Unknown","nodes.select":"Connect to this node","nodes.platform.empty":"No nodes are registered on this Gateway","nodes.selection.fallback.missing":"The node selected last time is no longer registered; connected to {node} instead.","nodes.selection.fallback.down":"The node selected last time is down; connected to {node} instead.","nodes.dataPlane.direct":"direct (health.get reachable)","nodes.dataPlane.unreachable":"unreachable (health.get failed)","nodes.teams.create":"Create Team","nodes.teams.archived":"Archived","nodes.teams.archiveTitle":"Archive Team?","nodes.teams.archiveBody":"An archived Team is read-only (no post / dispatch / member add); logs and history are kept. It is rejected while present members remain.","team.form.createTitle":"Create Team","team.form.editTitle":"Edit Team","team.form.workspace":"Workspace","team.form.workspaceHint":"Required; normalized to an absolute path. Immutable after creation.","team.form.name":"Name","team.form.status":"Frozen state","team.form.statusHint":"Toggle it from the card menu (freeze spawning); read-only here.","team.form.statusFrozen":"Frozen (no new members)","team.form.statusActive":"Active","team.form.description":"Description","team.form.required":"Required","team.form.submitCreate":"Create","team.form.submitEdit":"Save","team.form.createFailed":"Create failed","team.form.updateFailed":"Update failed","team.form.forbidden":"This token cannot create / update Teams.","team.form.archivedReadonly":"Archived Teams are read-only.","archive.hidden.teams":"{count} archived Team(s) hidden by default: turn on ui.showArchived in Settings → Display & visibility to show them.","archive.empty.teams":"Every Team here is archived (hidden by default)","archive.empty.agents":"Every agent here is closed (hidden by default)","archive.empty.members":"Every member here is closed (hidden by default)","archive.hidden.agents":"{count} closed agent(s) hidden by default: turn on ui.showArchived in Settings → Display & visibility to show them.","archive.hidden.members":"{count} closed member(s) hidden by default: turn on ui.showArchived in Settings → Display & visibility to show them.","archive.notice.team":"This Team is archived · pending removal: its log is read-only and it no longer shows in the default list. Direct links keep working until it is pruned.","archive.notice.agent":"This agent is closed · pending removal: it no longer shows in the default list. Direct links keep working until it is pruned.","archive.session.agentClosedHint":"Its agent is closed · pending removal; the session is kept and its history stays readable.","kanban.subtitle":"Red-blue development task board (docs/dev/kanban/board.json). Read-only; checking a card accepts it and moves it to archive.json.","kanban.noTokenReason":"Connect to the gateway to read the board.","kanban.notFound":"Board file not found","kanban.refresh":"Refresh","kanban.updated":"Updated {time}","kanban.taskCount":"{count} tasks","kanban.warnings":"{count} normalization warnings (bad tasks skipped; the rest still shown)","kanban.empty":"No tasks on the board","kanban.emptyHint":"The board is maintained by main; newly dispatched tasks will appear here.","kanban.emptyColumn":"Empty","kanban.uncategorized":"Uncategorized","kanban.accept":"Accept & archive","kanban.acceptAria":"Accept task: {title}","kanban.expandProgress":"Expand progress","kanban.collapseProgress":"Collapse progress","kanban.confirmTitle":"Archive task?","kanban.confirmBody":'"{title}" will be removed from the board and appended to archive.json in the same directory (append-only, history stays readable). Archiving is triggered by your acceptance check, never automatically.',"kanban.confirmAction":"Accept & archive","kanban.archived":"Archived: {title}","kanban.archiveFailed":"Archive failed: {message}","inbox.asyncJob.running":"Running","inbox.asyncJob.done":"Done","inbox.asyncJob.failed":"Failed","inbox.asyncJob.input":"Input","inbox.asyncJob.output":"Output","teams.title":"Teams","teams.empty":"No Team yet","teams.filter.node":"Node","teams.filter.all":"All nodes","teams.card.archived":"Archived · pending removal","teams.card.copyId":"Copy team ID","teams.card.members":"{members} members","teams.card.online":"{online} online","teams.card.running":"Members running","teams.card.open":"Open chat","teams.detail.emptyTitle":"Open a team first","teams.detail.emptyDesc":"Pick a team from the list to chat with its members.","teams.openList":"Open team list","teams.partialError":"Some nodes failed to list Teams","teams.error.forbidden":"This token cannot read Teams on that node","teams.error.notEnabled":"That node does not expose teams.*","teams.chat.archived":"Archived · pending removal","teams.freeze":"Freeze spawning","teams.unfreeze":"Unfreeze spawning","teams.frozen":"Frozen","teams.unfrozen":"Unfrozen","teams.nodeMissing":"The node in this link is not in the page’s node list","agents.title":"Agents","agents.staleNode":"Showing last successful data","agents.empty":"No Agent yet","agents.filter.node":"Node","agents.filter.team":"Team","agents.filter.state":"State","agents.filter.presence":"Presence","agents.filter.clear":"Clear filters","agents.count":"Showing {shown} / {total}","agents.card.closed":"Closed · pending removal","agents.presence.live":"live","agents.presence.gone":"gone","agents.partialErrors":"{count} Team details failed to load","agents.loadingRosters":"Aggregating node rosters…","breadcrumb.team.member":"Member","hub.add.title":"Add node","hub.add.description":"Run these commands on the other machine to pair or join; the Web does not manage hub tokens.","hub.nodes.heartbeat":"Heartbeat {time}","hub.remove.title":"Remove node?","hub.remove.body":"Removes it from this browser’s connection list and clears its token; the node keeps running.","nodes.search":"Search nodes","nodes.add.commands":"Pair or join","nodes.add.connect":"Connect from this browser","nodes.emptyFiltered":"No node matches “{query}”","nodes.lastHeartbeat":"Last heartbeat","nodes.advanced":"Advanced details","nodes.viewTeams":"View teams","nodes.viewAgents":"View agents","teams.form.policy":"Policy","teams.form.policyHint":"Optional; empty fields are not written. Unknown existing policy keys are preserved on save.","team.form.policyPermission":"Permission","team.form.policyUnattended":"Unattended","team.form.policyUnset":"Not set","team.form.policyHold":"hold (wait for human)","team.form.policyDenyAfter":"deny-after (timeout deny)","team.form.policyDenyAfterSeconds":"Deny after (seconds)","team.form.policyErrorDenyAfterRequired":"Required when unattended is deny-after","team.form.policyErrorDenyAfterRange":"Must be an integer between 1 and 86400","team.form.policyBudget":"Budget","team.form.policyMaxHops":"Max hops","team.form.policyMaxTurns":"Max turns","team.form.policyMaxTokens":"Max tokens","team.form.policyMaxWallClockSeconds":"Max wall clock (seconds)","team.form.policyWarningThreshold":"Warning threshold","team.form.policyWarningThresholdHint":"Between 0 and 1 (exclusive); empty = default 0.8.","team.form.policyErrorThreshold":"Must be a number between 0 and 1 (exclusive)","team.form.policyErrorIntegerMin":"Must be an integer >= {min}","team.form.policyCycle":"Cycle","team.form.policyCycleMaxRepeats":"Max repeats","team.form.policyCycleCooldownSeconds":"Cooldown (seconds)","team.form.policyFederation":"Federation","team.form.policyFederationAccept":"Accept","team.form.policyAcceptPrincipal":"principal (one member)","team.form.policyAcceptLog":"log (log only)","team.form.policyAllowAutoCreate":"Allow auto-create","team.form.policyAllowAutoCreateHint":"Checked writes the key; unchecked leaves it unset (default off).","teams.edit.back":"Back to Team","agents.search":"Search agents","agents.create":"Create agent","agents.create.title":"Create agent","agents.edit.title":"Edit agent","agents.back":"Back to Agents","agents.form.model":"Model","agents.form.modelHint":"Takes effect in the next body (after rotate or a restart); the current body keeps the old value and only gets an environment notice. Leave blank to keep unchanged.","agents.form.modelCreateHint":"Empty = follow the node default model; picking one pins it for this member, used from its first body.","agents.form.systemPrompt":"System prompt","agents.form.systemPromptHint":"Takes effect in the next body (after rotate or a restart); the current body keeps the old value and only gets an environment notice. Leave blank to keep unchanged.","agents.form.kind":"Type","agents.form.kindPeer":"Member (requires Team)","agents.form.kindContractor":"Temporary (Team optional)","agents.form.roleHint":"Member maps to role member; Temporary maps to role temporary.","agents.form.peerRequiresTeam":"A member must be bound to a Team. Select a Team or switch to Temporary.","agents.form.unbound":"Unbound","agents.form.noChange":"Change at least one field.","agents.form.created":"Created agent {name}","agents.form.updated":"Updated agent {name}","agents.form.createFailed":"Create failed","agents.form.updateFailed":"Update failed","modelPicker.followDefault":"Follow default","modelPicker.keepUnchanged":"Keep unchanged","modelPicker.emptyWithCurrent":"{label} (current: {model})","modelPicker.unregistered":"unregistered","modelPicker.groupAliases":"Aliases","modelPicker.groupEntries":"Model entries","modelPicker.unavailable":"Model registry unavailable (plugin not loaded or request failed); selection is disabled.","agents.detail.title":"Agent","agents.detail.advanced":"Advanced details","agents.detail.agentId":"Agent id","agents.detail.membership":"Membership","agents.detail.visibility":"Visibility","agents.detail.session":"Session","agents.close":"Close agent","agents.close.title":"Close agent?","agents.close.body":"The agent is archived. Its history and Team logs are kept; this cannot be undone from the Web.","agents.close.success":"Closed agent {name}","agents.close.failed":"Close failed","agents.error.forbidden":"This token cannot create / update / close agents.","agents.error.notFound":"Agent not found","agents.error.candidates":"Did you mean: {list}?","agents.error.nodeMissing":"The node in this link is not in the page's node list","common.configureConnection":"Configure connection","common.clearSearch":"Clear search","common.clearFilters":"Clear filters","common.writesDisabled":"Disconnected; writes are disabled.","common.staleData":"Update failed; showing the last data: {detail}","common.notConnected":"Not connected to a gateway","common.clipboardUnsupported":"Clipboard is not available in this environment","common.moreActions":"More actions","common.rawData":"Raw data","common.closeNotice":"Close notification","common.showMore":"Show more ({count} more)","common.newSession":"New session","status.queued":"Queued","status.running":"Running","status.waiting":"Waiting for approval","status.cancelling":"Cancelling","status.interrupted":"Interrupted","status.completed":"Completed","status.failed":"Failed","status.cancelled":"Cancelled","status.skipped":"Skipped","status.pending":"Pending","status.connected":"Connected","status.disconnected":"Disconnected","status.unreachable":"Unreachable","status.disabled":"Disabled","status.unavailable":"Unavailable","palette.group.navigation":"Navigation","palette.group.settings":"Settings","palette.group.entity":"Entities","palette.group.action":"Actions","palette.group.help":"Help","palette.label":"Command palette","palette.searchPlaceholder":"Search navigation, sessions, runs, or type > for actions","palette.searchLabel":"Search the command palette","palette.resultsLabel":"Command results","palette.needConfirm":"Confirm","palette.empty":"No results match “{query}”.","palette.footer":"↑↓ select · Enter run · Esc close","palette.count":"{count} results","palette.action.newSession":"New session","palette.action.resumeRun":"Resume recoverable run","palette.action.connectionSettings":"Connection settings","palette.action.viewConfig":"View config","palette.action.viewCapabilities":"View capabilities","palette.action.refresh":"Refresh current view","palette.action.shortcuts":"Keyboard shortcuts","palette.action.checkConnection":"Check connection","palette.action.reconnect":"Reconnect","palette.hint.action":"Action","palette.hint.settings":"Setting","palette.hint.help":"Help","palette.hint.session":"Session","palette.hint.run":"Run","palette.hint.confirm":"Confirm","palette.hint.cancel":"Cancel","palette.hint.resume":"Resume","palette.action.cancelRun":"Cancel run {id}","palette.action.cancelRunLabel":"Cancel run","palette.action.resumeRunNamed":"Resume run {id}","palette.action.openRun":"Open run {id}","palette.action.openDurableRun":"Open recoverable run {id}","palette.action.reconnectMcp":"Reconnect MCP {name}","palette.confirm.cancelRunTitle":"Cancel the run?","palette.confirm.cancelRunBody":"In-progress tool calls are cancelled; output already produced is kept.","palette.confirm.executeTitle":"Run “{label}”?","palette.confirm.executeBody":"This action may not be reversible.","palette.confirm.execute":"Run","palette.toast.refreshed":"Requested a refresh of the current view","palette.toast.reconnecting":"Reconnecting to the gateway","app.announce.run":"Run {id} {status}","app.openConnection":"Open connection settings","app.retryNow":"Retry now","app.connectionSettings":"Connection settings","app.reconnecting":"Disconnected; reconnecting (attempt {count})…","app.stale":"Disconnected; the data shown may be stale.","app.help.title":"Keyboard shortcuts","app.help.openClose":"Open / close the command palette","app.help.actionMode":"Open action mode outside an input","app.help.move":"Move through palette results","app.help.execute":"Run the selected command / send a message","app.help.close":"Close a palette, drawer, or dialog","chat.notFound":"Session not found or deleted","chat.sessionList.title":"Sessions","chat.sessionList.new":"+ New","chat.sessionList.search":"Search sessions","chat.sessionList.renameEmpty":"The title cannot be empty and must be at most 512 characters","chat.sessionList.renameFailed":"Rename failed; try again","chat.sessionList.noConnection":"Connect to a gateway to see sessions","chat.sessionList.loading":"Loading sessions…","chat.sessionList.noMatch":"No session matches “{query}”.","chat.sessionList.empty":"No sessions yet.","chat.sessionList.idLabel":"Session title","chat.sessionList.named":"Named: you set this title, so automatic naming leaves it alone","chat.sessionList.actions":"Actions for session {title}","chat.sessionList.rename":"Rename","chat.sessionList.viewRuns":"View runs","chat.sessionList.delete":"Delete session","chat.sessionList.showMore":"Show more ({count} remaining)","chat.palette.rename":"Rename session “{title}”","chat.palette.delete":"Delete session “{title}” (confirm)","chat.main.sessionsLabel":"Session list","chat.main.conversationLabel":"Conversation","chat.main.heading":"Sessions","chat.empty.noConnectionTitle":"Connect to a gateway to start.","chat.empty.noConnectionDesc":"The gateway URL and token now live in Settings. Once connected, create a session and send your first message.","chat.loadingHistory":"Loading session history…","chat.empty.noHistoryTitle":"This session has no messages yet.","chat.empty.noHistoryDesc":"Enter a prompt below to continue this session.","chat.staleHistory":"History refresh failed; showing the loaded records: {detail}","chat.historyChanged":"Earlier history was rewritten; the older pages were reloaded from the server.","chat.earlierLoadFailed":"Earlier messages could not be loaded; you can retry: {detail}","chat.toBottom":"Back to bottom ↓","chat.index.label":"Conversation index","chat.index.jump":"Jump to item {index}","chat.pending.title":"Inbox · {count}","chat.awaitingJobs":"Awaiting {count} async job(s)","chat.pending.identity.human":"human","chat.pending.identity.ask":"ask answer","chat.pending.identity.bash":"bash job","chat.pending.identity.system":"system","chat.pending.identity.agent":"agent:{name}","chat.pending.sameSource":"{count} items","chat.pending.expandAll":"Show all ({count} more)","chat.pending.collapseList":"Collapse","chat.pendingSend.offline":"Offline — not sent","chat.pendingSend.sending":"Sending…","chat.pendingSend.queued":"Queued · one round ahead","chat.pendingSend.queuedLong":"Queued {minutes} min · one round ahead","chat.pendingSend.queueTimeout":"Queued too long — not sent","chat.pendingSend.deferred":"Accepted · {reason}","chat.pendingSend.deferredLong":"Accepted · {reason} · waiting {minutes} min","chat.pendingSend.deferred.rotate":"session is rotating, the message is in the inbox","chat.pendingSend.deferred.stopped":"blocked by a hard error, continues after unblocking","chat.pendingSend.deferred.other":"waiting for the server to pick it up","chat.pendingSend.deferTimeout":"Accepted, but never picked up","chat.pendingSend.failed":"Not sent","chat.pendingSend.retry":"Retry","chat.pendingSend.dismiss":"Discard","chat.pendingSend.edit":"Edit","chat.pendingSend.echoTimeout":"no echo yet","chat.pendingSend.recallUnknown":"Not sure which member owns this one yet — nothing was recalled","chat.pendingSend.recallRejected":"Could not recall the queued copy; the strip was reloaded","chat.pending.edit":"Take back to edit","chat.pending.editTaken":"Taken back into the input box","chat.pending.editPeekFailed":"Could not read the full text of that item; nothing was changed","chat.pending.peekFailed":"Could not read the full text; showing the summary","chat.pending.editRecallRejected":"Put back into the input box, but the queue entry stayed: it may have started running","chat.pending.editRecallFailed":"Put back into the input box, but removing the entry failed: {detail}","chat.pending.claim":"Mark as handled","chat.pending.claimInFlight":"Marking as handled…","chat.pending.claimTaken":"Marked as handled — it will not be sent","chat.pending.claimSkipped":"That item could not be claimed ({reason}); the strip was reloaded","chat.pending.claimSkipped.notFound":"it is no longer in the inbox","chat.pending.claimSkipped.consumed":"it was already taken","chat.pending.unhold":"Archive (release hold)","chat.pending.unholding":"Archiving…","chat.pending.unheld":"Hold released — the message stays here as unread and can still be read","chat.pending.unholdRejected":"The server did not release the hold; the strip was reloaded (the item may already be gone)","chat.pending.unholdFailed":"Could not release the hold: {detail}","chat.toast.queued":"Queued","chat.toast.deferred":"Accepted — waiting to be picked up","chat.toast.cancelRequested":"Requested cancellation of the run","chat.toast.queueCancelled":"Removed from the queue","chat.toast.cancelNotAccepted":"The cancellation was not accepted; the run may have started","chat.toast.disconnectedRename":"Disconnected; cannot rename the session right now","chat.toast.renameFailed":"Rename failed: {detail}","chat.toast.disconnectedDelete":"Disconnected; cannot delete the session right now","chat.toast.activeRuns":"This session still has running or interrupted runs and cannot be deleted yet.","chat.toast.deleted":"Session deleted (runs: {runs}, events: {events})","chat.target.new":"+ New session","chat.target.session":"→ {title}","chat.delete.title":"Delete session “{title}”?","chat.delete.body":"This deletes the persisted history, related runs, and events. It cannot be undone.","chat.delete.counts":"This session has {messages} messages","chat.delete.runsCount":" and {count} related run record(s)","chat.delete.counting":"; counting related runs…","chat.delete.activeRuns":"{count} runs are still running or interrupted; finish or resume them before deleting.","chat.delete.statsFailed":"Failed to count related runs: {detail}","chat.delete.serverReject":"The server rejects deletion while runs are running or interrupted.","chat.delete.disconnected":"Disconnected; writes are disabled.","chat.delete.confirm":"Delete session","chat.delete.viewRuns":"View this session’s runs","chat.composer.placeholderNoToken":"Configure a gateway token in Settings → Connection first","chat.composer.placeholderDisconnected":"Disconnected; reconnect to send","chat.composer.placeholder":"Enter a prompt","chat.composer.sending":"Sending","chat.composer.send":"Send","chat.composer.hint":"Enter to send · Shift+Enter for a new line","chat.sessionRef.note":"Referenced session","chat.sessionRef.remove":"Remove session reference {name}","chat.sessionRef.reject.tooMany":"At most {max} session references","chat.sessionRef.header":"Referenced sessions","chat.refs.label":"Referenced files","chat.refs.remove":"Remove reference {name}","chat.refs.kind.file":"File","chat.refs.kind.image":"Image","chat.refs.kind.document":"Document","chat.refs.image.sent":"Sent · {provider} · {tokens} tok","chat.refs.image.sentPlain":"Sent","chat.refs.image.dropped":"Dropped · {reason}","chat.refs.image.notSent":"Not sent · {reason}","chat.refs.image.noRecord":"No record","chat.refs.image.reason.no_delivery_record":"no delivery record kept","chat.refs.image.reason.budget":"over per-request budget","chat.refs.image.reason.bytes_budget":"over per-request byte budget","chat.refs.image.reason.unsupported_format":"unsupported format","chat.refs.image.reason.not_an_image":"not an image","chat.refs.image.reason.too_large":"image too large","chat.refs.image.reason.blob_missing":"attachment bytes missing","chat.refs.image.reason.not_ingested":"not ingested (no sha256)","chat.refs.image.reason.vision_disabled":"vision disabled","chat.refs.image.reason.no_vision":"model has no vision","chat.refs.image.reason.placeholder":"placeholder cleanup","chat.refs.image.reason.compaction":"compaction","chat.refs.image.reason.no_delivery_event":"no delivery record","chat.refs.image.reason.unknown":"unknown reason","chat.toolImage.group":"Tool image attachments","chat.toolImage.title":"Tool image","chat.toolImage.count":"{count} images","chat.toolImage.dimensions":"{width}×{height}","chat.toolImage.preview":"Click to enlarge","chat.toolImage.previewNamed":"Enlarge {name}","chat.toolImage.loading":"Loading image…","chat.toolImage.unavailable":"Preview unavailable","chat.toolImage.raw":"Raw notice","chat.toolImage.close":"Close preview","chat.toolImage.copyPath":"Copy path","chat.toolImage.pathCopied":"Path copied","chat.toolImage.staging":"temp (not ingested)","chat.toolMedia.group":"Tool attachments","chat.toolMedia.title":"Tool attachments","chat.toolMedia.count":"{count} items","chat.pdf.previewNamed":"Preview {name}","chat.refCard.copyPath":"Copy path","chat.refCard.pathCopied":"Path copied","chat.refCard.expired":"expired","chat.refCard.temporary":"temp","chat.refs.reject.absolute":"Only absolute paths can be referenced: {path}","chat.refs.reject.tooLong":"The reference path is longer than {max} characters","chat.refs.reject.tooMany":"A message can carry at most {max} references","chat.refs.reject.invalid":"Invalid reference path: {name}","composer.toolbar.label":"Composer toolbar","composer.refs.label":"References","composer.refs.remove":"Remove {name}","chat.event.truncated":"(truncated)","chat.event.expand":"Expand","chat.event.collapse":"Collapse","chat.event.raw":"Raw event","chat.event.rawData":"Raw payload","chat.event.meta":"Event details","chat.event.type":"Type","chat.event.time":"Time","chat.event.runId":"Run","chat.event.empty":"No payload","chat.notice.contextPressure":"context at {percent}% · {used}/{max}","chat.notice.contextCompacted":"context compacted · removed {removed} · remaining {remaining} · {reason}","chat.notice.contextTrimmed":"context trimmed · {added} added this run ({cleared} cleared in this session) · {kept} kept","chat.notice.limitWarning":"limit warning · {key} {current}/{max}","chat.notice.restarting":"context restarting · {session} · epoch {from} → {epoch}","chat.notice.restarted":"context restarted · {session} · epoch {from} → {epoch}","chat.notice.compactForked":"context compact-forked · {from} → {to} · epoch {epoch}","chat.notice.hook":"hook · {name}","chat.notice.finalizeFailed":"run finalize failed · phase {phase} · {error}","chat.notice.guardrailError":"guardrail error · {name} · phase {stage} · {error}","chat.notice.runtime":"System notice · {kind}","chat.notice.replyStale":"reply not used · old body retired · epoch {epoch} · message {message}","chat.notice.handoffNoReply":"handoff committed, but this turn left no closing reply · {outcome} · epoch {epoch}","chat.notice.retired":"old body retired · {reason} · epoch {epoch} · body {body}","chat.notice.rotateDenied":"context rotate denied · {reason} · at {percent}%","chat.notice.unknownEvent":"unknown event type · collapsed · {type}","chat.env.aria":"Environment","chat.env.title":"Environment","chat.env.scope.config":"Config","chat.env.scope.permission":"Permission","chat.env.scope.tools":"Tools","chat.env.scope.mcp":"MCP","chat.env.scope.update":"Update","chat.env.scope.peer":"Peer","chat.env.scope.inbox":"Inbox","chat.env.scope.restart":"Restart","chat.env.scope.identity":"Identity","chat.env.scope.fields":"Fields","chat.env.scope.lock":"Write lock","chat.env.scope.conflict":"Write conflict","chat.env.scope.files":"File changes","chat.env.scope.health":"Node health","chat.env.scope.agent":"Agent activity","chat.env.scope.script":"Subscription scripts","chat.env.scope.doc-lag":"Doc lag","chat.env.scope.code-heaviness":"Code heaviness","chat.env.scope.team-log":"Team log","chat.env.scope.model":"Model","chat.env.scope.selfcard":"Base info","chat.env.scope.context":"Context","chat.env.scope.trim":"Trimmed","chat.env.scope.pii":"PII","chat.env.scope.source":"Source","chat.env.source.raw":"Original source line","chat.env.count":"{count} items","chat.env.notApplied":"not applied","chat.env.moreLines":"{count} more lines not shown","chat.env.changed.count":"{count} items changed","chat.env.changed.title":"Changed","chat.env.changed.from":"from #{hash}","chat.env.changed.systemPrompt":"System prompt","chat.env.changed.selfCard":"Self Card","chat.env.changed.model":"Model","chat.env.changed.tools":"Tools","chat.env.changed.added":"added","chat.env.changed.removed":"removed","chat.env.changed.replaced":"replaced","chat.modelContext.system":"System prompt","chat.modelContext.selfCard":"Self Card","chat.modelContext.messages":"{count} messages","chat.modelContext.tools":"{count} tools","chat.modelContext.tokens":"{count} tokens","chat.modelContext.hash":"context {hash}","chat.modelContext.contextMax":"window {count}","chat.askAnswer.title":"Approval answer","chat.askAnswer.aria":"Answer to a deferred question","chat.askAnswer.source":"from approvals","chat.askAnswered.title":"Question answer","chat.askAnswered.aria":"Answered questions (server record, survives refresh)","chat.askAnswered.source":"recorded answer on the server","chat.rotateHandoff.title":"⟳ rotate handoff","chat.rotateHandoff.aria":"rotate handoff · epoch {epoch}","chat.rotateHandoff.epoch":"epoch {epoch}","chat.rotateHandoff.source":"handover brief written by the agent that started the rotate","chat.agentMessage.from":"from agent {name}","chat.agentMessage.group":"Message from agent {name}","chat.toolMessage.from":"from {name}","chat.toolMessage.group":"Delivery from {name}","chat.message.actions":"Message actions","chat.message.fold.expand":"Show full text","chat.message.fold.collapse":"Collapse","chat.message.copy":"Copy","chat.message.copied":"Copied","chat.code.copy":"Copy code","chat.table.copy":"Copy table","chat.message.edit":"Edit","chat.message.retry":"Retry","chat.quote.action":"Quote","chat.quote.label":"Quoted message","chat.quote.jump":"Jump to original message","chat.quote.remove":"Remove quote","chat.quote.source.user":"User","chat.quote.source.assistant":"Assistant","chat.message.create.editTitle":"Edit message","chat.message.create.editBody":"Creates a new session from the history before this message and puts the text back in the composer. The current session is kept read-only; history is not deleted.","chat.message.create.retryTitle":"Regenerate","chat.message.create.retryBody":"Creates a new session from the history before this reply and resends the previous user message. The current session is kept read-only; history is not deleted.","chat.message.create.confirm":"Create session","chat.message.create.editDone":"New session created","runs.title":"Runs","runs.sourceLabel":"Run source","runs.source.live":"Live (in process)","runs.source.durable":"Recoverable","runs.filter.all":"All","runs.filter.queued":"Queued","runs.filter.running":"Running","runs.filter.completed":"Completed","runs.filter.failed":"Failed","runs.filter.cancelled":"Cancelled","runs.filter.interrupted":"Interrupted","runs.searchPlaceholder":"Search run id / session / output / error","runs.searchLabel":"Search runs","runs.noTokenTitle":"Connect to a gateway to see runs.","runs.durableDisabledTitle":"Recoverable runs are not enabled","runs.durableDisabledReason":"This gateway does not have durable run recovery enabled.","runs.durableDisabledHint":"Enable checkpoint storage and resume, then restart the gateway.","runs.disconnected":"Disconnected; showing the last loaded run list. Writes are disabled.","runs.emptyLiveTitle":"The current gateway process has no run records yet.","runs.emptyLiveDesc":"Send a prompt in a session and the run will appear here.","runs.emptyDurableTitle":"No recoverable runs match.","runs.emptyDurableDesc":"Adjust the status filter or clear the session filter and try again.","runs.noMatchTitle":"No runs match.","runs.noMatchDesc":"Clear the search, status, or session filter and try again.","runs.col.state":"Status","runs.col.runId":"Run ID","runs.col.session":"Session","runs.col.started":"Started","runs.col.duration":"Duration","runs.col.actions":"Actions","runs.col.agent":"Agent","runs.col.iter":"Iter","runs.col.cacheHit":"Cache hit","runs.col.updated":"Updated","runs.cancel":"Cancel","runs.cancelling":"Cancelling…","runs.resume":"Resume run","runs.resuming":"Resuming…","runs.notFound":"Run not found","runs.loading":"Loading runs…","runs.detailLoading":"Loading run details…","runs.palette.live":"Run {id}","runs.palette.durable":"Recoverable {id}","runs.toast.disconnectedCancel":"Disconnected; cannot cancel the run","runs.toast.cancelRequested":"Requested cancellation of the run","runs.toast.cancelNotAccepted":"The cancellation was not accepted; the run may have started","runs.toast.disconnectedResume":"Disconnected; cannot resume the run","runs.toast.resumed":"Queued the resume","runs.toast.resuming":"This run is already resuming","runs.detail.label":"Run details","runs.detail.title":"Run details","runs.detail.copyId":"Copy run ID","runs.detail.copiedId":"Run ID copied","runs.detail.exportJson":"Export JSON","runs.detail.close":"Close run details","runs.detail.session":"Session","runs.detail.started":"Started","runs.detail.ended":"Ended","runs.detail.duration":"Duration","runs.detail.cancel":"Cancel run","runs.detail.cancelling":"Cancelling…","runs.detail.resume":"Resume run","runs.detail.resuming":"Resuming…","runs.detail.disconnected":"Disconnected; the data below is from the last read.","runs.detail.filtersLabel":"Filter by event category","runs.detail.filter.all":"All","runs.detail.filter.llm":"LLM","runs.detail.filter.tools":"Tools","runs.detail.filter.errors":"Errors","runs.detail.filter.internal":"Internal","runs.detail.filter.other":"Other","runs.detail.typePrefix":"Type prefix, e.g. tool.call.","runs.detail.typePrefixLabel":"Filter by event type prefix","runs.detail.refreshEvents":"Refresh events","runs.detail.traceDisabledTitle":"Event trace is not enabled or has no records.","runs.detail.traceDisabledHint":"The run summary and output are still available; enable the event trace in the gateway config and restart to see the full timeline.","runs.detail.traceStale":"Event trace is unavailable; showing {count} events from the live buffer.","runs.detail.loadingTrace":"Loading event trace…","runs.detail.emptyTraceTitle":"No event trace.","runs.detail.emptyTraceQueued":"This run is not mapped to a core run yet (it may still be queued), so there is no event trace.","runs.detail.emptyTraceDesc":"The event trace has no events for this run; output and Raw JSON are still available.","runs.detail.noMatchTitle":"No events match.","runs.detail.loadingMore":"Loading…","runs.detail.loadMore":"Load more events ({count} shown)","runs.detail.missingSeq":"Events are missing seq; cannot paginate. Refresh to read again.","runs.detail.errorTitle":"Error","runs.detail.outputTitle":"Output","runs.detail.checkpointPreview":"Last message (checkpoint preview)","runs.detail.checkpoint":"Last message (checkpoint)","runs.detail.emptyOutputTitle":"No output to display.","runs.detail.emptyOutputDesc":"The run may still be in progress or may have been cancelled.","runs.detail.rawLabel":"Raw JSON","runs.detail.copyJson":"Copy JSON","runs.detail.copiedJson":"Run JSON copied","runs.detail.metaTitle":"Run summary","runs.detailPage.subtitle":"Run details are a dedicated page: the summary sits on top, the raw event log below.","runs.detailPage.back":"Back to runs","runs.log.title":"Raw event log","runs.log.hint":"One event per row. Click a row to expand the full JSON (copyable). Filters apply to the events already loaded.","runs.log.col.time":"Timestamp","runs.log.col.type":"Type","runs.log.col.summary":"Summary","runs.log.seqFrom":"Lower seq bound (inclusive)","runs.log.seqTo":"Upper seq bound (inclusive)","runs.log.keyword":"Search type or payload","runs.log.keywordLabel":"Search event type or payload","runs.log.rowLabel":"Expand event {type} (seq {seq})","runs.log.prev":"Previous page","runs.log.next":"Next page","runs.log.pageOf":"Page {page} / {pages}","runs.log.loadedOnly":"Only loaded events are filtered; load more to widen the search.","runs.log.noMatchDesc":"Adjust the category, type prefix, seq range or keyword; then clear the filters to see everything.","runs.detail.loadMoreFailed":"Failed to load more events: {detail}","integrations.tools.noTokenReason":"Connect to read the tool catalog.","integrations.tools.loading":"Loading tools…","integrations.tools.searchPlaceholder":"Search tool name or description","integrations.tools.searchLabel":"Search tools","integrations.tools.onlyConfirm":"Confirmation required ({count})","integrations.tools.empty":"The gateway has not registered any tools.","integrations.tools.noMatch":"No tools match.","integrations.tools.openDetails":"Open details for {name}","integrations.tools.dialogLabel":"Tool details: {name}","integrations.tools.details":"Tool details","integrations.tools.schema":"Input schema","integrations.tools.stale":"Disconnected; showing the last loaded tool catalog.","integrations.tools.policyLabel":"Confirmation policy","integrations.tools.policyAuto":"Allow automatically","integrations.tools.policyAsk":"Confirm every time","integrations.tools.policyNever":"Always confirm","integrations.tools.policyAutoHint":"Calls run without asking; the tool is added to permission.autoApprove.","integrations.tools.policyAskHint":"Default: each call asks for approval; the tool is in neither list.","integrations.tools.policyNeverHint":"Always asks even when allowed automatically; the tool is added to permission.neverAutoApprove.","integrations.tools.policyScopedNever":"Some actions confirm even when auto-approved","integrations.tools.policyScopedHint":"Some actions (e.g. agent.close) confirm even when auto-approved; set each one separately below.","integrations.tools.policyScopedLabel":"Per-action overrides","integrations.tools.policyScopedNeverOn":"Confirm even when auto-approved","integrations.tools.policyScopedNeverHint":"Blocks automatic approval only; an explicit tool allow still runs.","integrations.tools.policyApplied":"Applied.","integrations.tools.policyFailed":"Not applied: {detail}","integrations.tools.policySaving":"Saving…","integrations.tools.policyChecking":"Checking gateway capabilities…","integrations.tools.policyUnsupported":"Requires a newer gateway.","integrations.tools.policyLoadFailed":"Could not read the permission config: {detail}","integrations.tools.policyAlwaysAvailableNote":'inbox is the core message channel shared by every member and stays available by default (neither the default tier nor auto blocks it). "Always confirm" does not disable the tool — it asks on every call, which can block message delivery when nobody is watching, so set it with care. You can also narrow individual actions with per-action entries such as inbox.read.',"integrations.mcp.globalDesc":"The MCP control plane is gateway-global.","integrations.mcp.counts":"{total} servers · {failed} failed","integrations.mcp.reconnectAll":"Reconnect all failed ({count})","integrations.mcp.reconnectAllBusy":"Reconnecting…","integrations.mcp.noTokenReason":"Connect to read MCP status.","integrations.mcp.disabledTitle":"MCP is not enabled","integrations.mcp.disabledReason":"This gateway has no MCP control plane.","integrations.mcp.disabledHint":"This is normal when no MCP server is configured; configure mcp_servers and restart the gateway when needed.","integrations.mcp.stale":"Disconnected; showing the last loaded MCP status. Writes are disabled.","integrations.mcp.staleDetail":"MCP status update failed: {detail}","integrations.mcp.loading":"Loading MCP servers…","integrations.mcp.emptyTitle":"No MCP server configured.","integrations.mcp.emptyDesc":"Enable mcp_servers in the config and restart the gateway.","integrations.mcp.toolsCount":"{count} tools","integrations.mcp.reconnect":"Reconnect","integrations.mcp.reconnecting":"Reconnecting…","integrations.mcp.reconnectSuccess":"Reconnected {name}","integrations.mcp.reconnectFailed":"Failed to reconnect {name}: {detail}","integrations.mcp.reconnectDisconnected":"Disconnected; cannot reconnect MCP","integrations.mcp.reconnectAllSuccess":"Reconnected {count} MCP servers","integrations.mcp.reconnectAllFailed":"Reconnect failed: {detail}","integrations.mcp.reconnectPartial":"Reconnected {count}; failed: {detail}","integrations.channels.noTokenReason":"Connect to read channel status.","integrations.channels.disabledTitle":"Feishu channel is not enabled","integrations.channels.disabledReason":"This gateway has no Feishu channel.","integrations.channels.disabledHint":"Enable the feishu plugin, configure credentials, and restart the gateway.","integrations.channels.loading":"Loading Feishu status…","integrations.channels.empty":"No channel data.","integrations.channels.globalDesc":"This control plane is gateway-global and read-only.","integrations.channels.stale":"Disconnected; showing the last loaded channel status.","integrations.channels.title":"Feishu","integrations.channels.activeChats":"Active chats","integrations.channels.queuedMessages":"Queued messages","integrations.channels.lastError":"Last error","integrations.channels.noToggle":"Channels have no start/stop API, so no fake toggle is offered here.","observe.metrics.noTokenReason":"Connect to read metrics.","observe.metrics.disabledTitle":"Metrics are not enabled","observe.metrics.disabledReason":"This gateway has no metrics provider.","observe.metrics.disabledHint":"Enable metrics and restart the gateway.","observe.metrics.traceDisabledTitle":"Trace rebuild is unavailable","observe.metrics.traceDisabledHint":"Inject metrics.rebuild (event trace) into the gateway and restart.","observe.metrics.switchLive":"Switch to Live","observe.metrics.sourceLabel":"Metrics source","observe.metrics.source.live":"Live","observe.metrics.source.trace":"Trace rebuild","observe.metrics.refresh":"Refresh","observe.metrics.panelLabel":"Metrics content","observe.metrics.stale":"Disconnected; showing the last loaded metrics snapshot. Writes are disabled.","observe.metrics.loading":"Loading metrics…","observe.metrics.stat.runsStarted":"Runs started","observe.metrics.stat.completed":"Completed","observe.metrics.stat.failed":"Failed","observe.metrics.stat.cancelled":"Cancelled","observe.metrics.stat.toolCalls":"Tool calls (failed {failed})","observe.metrics.stat.tokens":"Tokens ({prompt}+{completion})","observe.metrics.stat.cacheInputShare":"Cache input share (read / all input)","observe.metrics.stat.cachePrefixHealth":"Prefix health (read / read+write)","observe.metrics.stat.cacheUnavailable":"Unavailable","observe.metrics.stat.cacheNoFieldsHint":"The provider reports no cache fields in usage (the endpoint or relay may not forward cache details).","observe.metrics.stat.cacheHint":"read {read} / write {write}, {prompt} input total","observe.metrics.stat.avgDuration":"Average duration (max {max}ms)","observe.metrics.stat.updatedAt":"Updated at","observe.metrics.sourceDesc":"Current source: {source}. Metrics are in-process counters, not a time series; usage history lives in usage stats.","observe.evals.noTokenReason":"Connect to read eval reports.","observe.evals.disabledTitle":"Evals are not enabled","observe.evals.disabledReason":"This gateway has no evals runner.","observe.evals.disabledHint":"Enable the evals plugin and restart the gateway.","observe.evals.disconnectedRun":"Disconnected; cannot run evals","observe.evals.completed":"Eval completed: {suite}","observe.evals.intro":"Evals run offline by default; network mode is gated by server `evals.allowNetwork` and CLI `--allow-network`, with no client switch. A run can take a while; you may leave this page.","observe.evals.suitePlaceholder":"suite (default smoke)","observe.evals.suiteLabel":"Eval suite","observe.evals.loadLatest":"Load latest report","observe.evals.run":"Run evals","observe.evals.running":"Running… (you can leave this page)","observe.evals.recent":"Recent:","observe.evals.retry":"Retry","observe.evals.disconnectedReport":"Disconnected; showing the last loaded eval report.","observe.evals.notFoundTitle":"Evals are not enabled or this suite has no report","observe.evals.notFoundHint":"Check the suite name; running evals can generate a new report.","observe.evals.loadingReport":"Loading eval report…","observe.evals.emptyTitle":"Load an eval report.","observe.evals.emptyDesc":"The backend has no suite-list API; enter a suite name or choose from recent suites.","observe.evals.stat.total":"Total cases","observe.evals.stat.passed":"Passed","observe.evals.stat.failed":"Failed","observe.evals.stat.errors":"Errors","observe.evals.stat.skipped":"Skipped","observe.evals.stat.duration":"Duration","observe.evals.stat.network":"Network mode","observe.evals.generatedAt":"Report generated at {time}. {network}","observe.evals.networkOn":"Network mode was enabled for this run.","observe.evals.offline":"This run was offline.","observe.evals.casesTitle":"Cases","observe.evals.failedOnly":"Failed only","observe.evals.emptyFailed":"No failed cases.","observe.evals.emptyCases":"No cases.","observe.evals.col.status":"Status","observe.evals.col.case":"Case","observe.evals.col.duration":"Duration","observe.evals.col.assertions":"Assertions","observe.evals.col.output":"Output / error","observe.evals.assertions":"Assertion details","observe.evals.showMore":"Show more cases ({count} remaining)","connection.title":"Connect to gateway","connection.description":"The token is stored only in sessionStorage; the URL is stored in localStorage. Non-loopback addresses must use HTTPS.","connection.reconnecting":"Reconnecting to the gateway…","connection.connecting":"Connecting to the gateway…","connection.urlPlaceholder":"Empty = same origin (recommended)","connection.current":"Current: {url}","connection.tokenPlaceholder":"gateway token","connection.platformUrl":"Platform URL","connection.nodeUrl":"Node URL","connection.platformToken":"Platform token","connection.platformTokenPlaceholder":"platform token","connection.nodeToken":"Node token","connection.nodeTokenOptional":"Node token (optional; empty = use platform credentials)","connection.nodeTokenPlaceholder":"node token (empty = credentials / anonymous)","connection.mode":"Connection mode","connection.modePending":"Detecting the platform…","connection.modePlatform":"Platform gateway","connection.modeLegacy":"Legacy node-hosted UI","connection.reconnect":"Reconnect","connection.connect":"Connect","connection.retryNow":"Retry now","connection.disconnect":"Disconnect and clear token","connection.disconnected":"Disconnected and cleared the token","connection.diagnostics":"Diagnostics","connection.state":"Connection state","connection.protocol":"Protocol version","connection.node":"Node","connection.latestSeq":"Latest seq","connection.featureCount":"Feature count","connection.featureList":" ({features})","connection.closeCodeToken":" · invalid token","connection.closeCodeForbidden":" · no access","connection.closeCodeProtocol":" · incompatible protocol","connection.failureHint":"When connecting fails, check in order: the address is reachable, the Origin is in node.allowed_origins, the token is valid, and non-loopback uses HTTPS.","connection.connected":"Connected to gateway","config.noTokenReason":"Connect to read config.","config.disabledTitle":"Config API is not enabled","config.disabledReason":"This gateway has no config control plane.","config.disabledHint":"Enable the config control plane and restart the gateway.","config.loading":"Loading config…","config.stale":"Disconnected; showing the last loaded config snapshot.","config.title":"Config snapshot","config.copyJson":"Copy JSON","config.copiedJson":"Config JSON copied","config.schemaVersion":"schema version","config.userPath":"User config path","config.projectPath":"Project config path","config.overlayKeys":"Overlay keys","config.redactedJson":"Redacted config JSON (redacted by the server)","config.itemsTitle":"Config entries","config.itemsDesc":"A flattened read-only view; secret fields are redacted by the server before returning (the client never guesses or displays secrets).","config.searchPlaceholder":"Search paths or values","config.searchLabel":"Search config entries","config.empty":"Config is empty.","config.noMatch":"No config entry matches “{query}”.","config.col.path":"Path","config.col.value":"Value","config.col.type":"Type","config.sourcesTitle":"Config sources","config.noSources":"No source information.","config.col.key":"Key","config.col.source":"Source","capabilities.noTokenReason":"Connect to read the capability manifest.","capabilities.loading":"Loading capabilities…","capabilities.noManifest":"No capability manifest","capabilities.stale":"Disconnected; showing the last loaded capability manifest.","capabilities.subtitle":"Protocol methods, tools, and the plugins currently loaded by the gateway runtime. Installable plugin packages are listed in the Plugins → Marketplace tab.","capabilities.methodsCount":"Protocol methods (read {read} / write {write} / admin {admin})","capabilities.tools":"Tools","capabilities.pluginsEnabled":"Enabled plugins","capabilities.tabsLabel":"Capability categories","capabilities.tab.methods":"Methods","capabilities.tab.tools":"Tools","capabilities.tab.plugins":"Runtime plugins","capabilities.tab.methodsCount":"Methods · {count}","capabilities.tab.toolsCount":"Tools · {count}","capabilities.tab.pluginsCount":"Runtime plugins · {enabled}/{total}","capabilities.search.methods":"Search protocol methods","capabilities.search.tools":"Search tools","capabilities.search.plugins":"Search plugins","capabilities.searchLabel":"Search capabilities","capabilities.noMatchMethods":"No protocol method matches.","capabilities.methodsTitle":"Methods · {permission}","capabilities.col.method":"Method","capabilities.col.permission":"Permission","capabilities.toolsTitle":"Tools","capabilities.noMatchTools":"No tool matches.","capabilities.pluginsTitle":"Runtime plugins","capabilities.pluginsDescription":`Loaded by the gateway runtime: tools, providers and guardrails. This is not the set of installable plugin packages; the marketplace's "My plugins" lists on-machine plugin packages (built-in and installed); it uses a different set.`,"capabilities.noMatchPlugins":"No plugin matches.","capabilities.enabled":"enabled","capabilities.disabled":"disabled","capabilities.col.plugin":"Plugin","capabilities.col.scope":"Scope","capabilities.col.mode":"Mode","capabilities.col.state":"State","capabilities.col.restart":"Takes effect","capabilities.scope.builtin":"built-in","capabilities.scope.user":"user","capabilities.scope.project":"project","capabilities.scope.node_modules":"node_modules","capabilities.mode.in-process":"in-process","capabilities.mode.child":"child","capabilities.restartRequired":"After restart","capabilities.catalogUnavailable":"Plugin catalog is unavailable; showing the runtime plugin snapshot from the capability manifest (no local directory scan).","gateway.url.wildcard":"Wildcard gateway addresses are not supported","gateway.url.incomplete":"Enter a complete gateway address (e.g. https://host:8642)","gateway.url.scheme":"Gateway addresses support only http(s)/ws(s)","gateway.url.credentials":"A gateway address cannot contain a username or password","gateway.url.path":"Use only scheme://host[:port]; do not include a path or query","gateway.url.https":"Non-loopback gateways must use HTTPS (wss)","gateway.url.mixed":"An HTTPS page cannot connect to an http:// gateway (mixed content)","gateway.connection.invalidUrl":"Invalid gateway address","gateway.connection.authFailed":"Authentication failed: the token is invalid or expired","gateway.connection.originRejected":"The gateway rejected this Origin/Host: {detail}. For cross-origin deployments, add this site to node.allowed_origins.","gateway.connection.unreachable":"Cannot reach the gateway (check the address/TLS/network): {detail}. Cross-origin deployments also need node.allowed_origins.","gateway.connection.forbiddenTenant":"Access denied (admin token required)","gateway.connection.protocolMismatch":"Incompatible protocol version (vessel.gateway/1 required)","gateway.connection.tokenRequired":"Enter a gateway token","gateway.rpc.sessionInvalid":"Session expired (401)","gateway.rpc.sessionInvalidHint":'Every request from this page is rejected, so pending requests and permission cards never arrive. Use "Sign in again"; if it still returns 401, check that this page origin is listed in http.allowed_origins.',"gateway.rpc.relogin":"Sign in again","gateway.rpc.connectInstead":"Open connection settings","gateway.rpc.originBlocked":"Origin rejected (not in the allowlist)","gateway.rpc.originBlockedHint":'The gateway answered "{detail}". Cross-origin access needs this site in http.allowed_origins, otherwise every RPC is rejected and permission cards never reach the UI.',"gateway.rpc.unreachable":"Cannot reach the node (origin rejected or service not running)","gateway.rpc.unreachableHint":"No request from this page has ever succeeded ({count} consecutive failures: {detail}), so pending requests and permission cards cannot arrive. If the node is actually running, the usual cause is this site missing from http.allowed_origins. This clears itself once a request succeeds.","gateway.platform.tokenRequired":"Platform token required: /platform/rpc returned 401. Enter the platform token in connection settings.","gateway.platform.noNodes":"The platform gateway returned no nodes.","gateway.platform.credentialsUnavailable":"Node credentials are unavailable; enter a node token manually.","auth.login.title":"Sign in to VESSEL","auth.login.passwordSubtitle":"This WebUI requires a password (single-user deployment; TOTP adds a one-time code).","auth.login.username":"Login name","auth.login.password":"Password","auth.login.submit":"Sign in","auth.login.codeLabel":"Verification code / recovery code","auth.login.submitCode":"Verify","auth.login.backToPassword":"Enter the password again","auth.login.codeHint":"Enter the 6-digit code from your authenticator; a one-time recovery code also works (it burns on use).","auth.login.codeHintNoRecovery":"Enter the 6-digit code from your authenticator (no recovery codes left; issue new ones in settings).","auth.login.totpHint":"A TOTP code is required after the password; clock drift tolerance ±30s.","auth.login.bootstrapHint":"No password is set yet: open this page with the one-time bootstrap code printed at startup (#token=<code>, valid for 10 minutes, single use).","auth.signedInAs":"Signed in as {user}","auth.signedInAsTitle":"Current session identity: {user}","auth.logout":"Sign out","auth.sessionRequired":"Session expired or missing: sign in again.","auth.csrfRejected":"The request had no valid CSRF token (another tab may have rotated it): reload and retry.","auth.error.state_invalid":"Login state rejected (mismatched, expired or already used): sign in again.","auth.error.code_missing":"The login provider returned no authorization code: sign in again.","auth.error.secret_missing":"The server could not read the client secret env var of this login backend (auth.backends[].clientSecretEnv): ask the operator to set it.","auth.error.token_exchange_failed":"Exchanging the code for an access token failed: sign in again.","auth.error.user_fetch_failed":"Reading the signed-in user failed: sign in again.","auth.error.not_allowlisted":"This account is not on the allowlist (this deployment only allows specific accounts / ids).","auth.error.public_origin_missing":"The server has no auth.publicOrigin / auth.publicOrigins configured; sign-in cannot start.","auth.error.backend_not_configured":"The server has this login backend disabled.","auth.error.invalid_credentials":"Wrong login name or password.","auth.error.invalid_code":"Wrong or expired code: try the current 6-digit code again.","auth.error.code_replayed":"That code was already used: the same code cannot be accepted twice — wait for the next 30-second step.","auth.error.ticket_invalid":"The verification step expired: enter the password again.","auth.error.rate_limited":"Too many failures: temporarily rate limited. Wait for the timer.","auth.error.password_not_set":"No password is configured on the server: use the one-time bootstrap code from the startup log.","auth.error.password_unsupported":"This runtime has no argon2id support, so the password cannot be verified.","auth.error.bootstrap_disabled":"This deployment has no password backend, so bootstrap codes are not accepted.","auth.error.bootstrap_invalid":"Invalid bootstrap code: restart the gateway for a fresh one.","auth.error.bootstrap_expired":"The bootstrap code expired (10 minutes): restart the gateway for a fresh one.","auth.error.bootstrap_replayed":"That bootstrap code was already used: the session it minted has been revoked. Sign in with the password.","auth.error.setup_session_required":"This step needs a setup session: open the page with the one-time bootstrap code.","auth.error.password_too_short":"Password too short: at least 10 characters.","auth.error.password_too_long":"Password too long (200 characters max).","auth.error.password_from_env":"The password hash comes from an environment variable: change it in the deployment config.","auth.error.totp_already_enrolled":"TOTP is already enrolled.","auth.error.totp_not_enrolled":"TOTP is not enrolled, so there are no recovery codes to issue.","auth.error.json_required":"The login endpoints accept application/json only.","auth.error.forbidden_origin":"This request origin is not allowed.","auth.error.unknown":"Sign-in failed: please retry.","auth.setup.title":"Set up sign-in credentials","auth.setup.subtitle":"This session came from a one-time bootstrap code (already burned). Set a password, then enroll TOTP — both steps are short.","auth.setup.password":"New password","auth.setup.passwordConfirm":"Repeat it","auth.setup.passwordHint":"At least 10 characters; stored as an argon2id hash, the plaintext never hits disk.","auth.setup.passwordMismatch":"The two entries do not match.","auth.setup.savePassword":"Save password","auth.setup.totpIntro":"Next, enroll TOTP: the next step shows the pairing URI and a batch of one-time recovery codes.","auth.setup.enrollTotp":"Generate a TOTP secret","auth.setup.skipTotp":"Skip for now (enroll later in settings)","auth.setup.totpSecret":"Add this otpauth URI to your authenticator:","auth.setup.secretFallback":"Manual secret: {secret}","auth.setup.recoveryTitle":"Recovery codes (shown once, each works once)","auth.setup.recoveryHint":"Store them in a password manager now: after you leave this page only hashes remain and they cannot be shown again.","auth.setup.finish":"Done","gateway.client.timeout":"Timed out connecting to the gateway","gateway.client.tokenRequired":"The token cannot be empty","gateway.client.tokenRequiredHttp":"Missing gateway token","gateway.client.wsFailed":"WebSocket connection failed","gateway.client.closedWithCode":"Connection closed ({code})","gateway.client.notConnected":"The gateway is not connected yet","gateway.client.requestTimeout":"Request timed out: {method}","gateway.client.closed":"Connection closed","gateway.client.stopped":"The gateway has stopped","gateway.client.unreachable":"Cannot reach the gateway (not started or wrong address)","gateway.error.unauthorized":"The token is invalid or expired; enter it again in connection settings.","gateway.error.forbidden":"This token cannot perform the operation.","gateway.error.forbidden_origin":"The request origin is not in node.allowed_origins.","gateway.error.invalid_host":"The Host header is not allowed by the gateway.","gateway.error.not_found":"The target does not exist or was deleted.","gateway.error.method_not_found":"This gateway does not expose the method (older build or wrong target). Check the connection address and gateway version.","gateway.error.invalid_params":"The request parameters are invalid.","gateway.error.invalid_request":"The request format is invalid.","gateway.error.conflict":"The operation conflicts with the current state; refresh and try again.","gateway.error.quota_exceeded":"The quota is exceeded.","gateway.error.rate_limited":"Too many requests; try again later.","gateway.error.timeout":"The request timed out; try again.","gateway.error.unsupported_protocol":"The gateway protocol is incompatible; upgrade the client or server.","gateway.error.internal":"Internal gateway error; check the server log.","gateway.error.no_runtime":"The gateway has no runtime configured.","gateway.error.durable_disabled":"Durable runs are not enabled.","gateway.error.mcp_disabled":"MCP is not enabled.","gateway.error.evals_disabled":"Evals are not enabled.","designLab.title":"Design Lab","designLab.subtitle":"Tokens and reusable components are discovered at runtime: add a token or a *.preview.tsx and it appears here; the inventory section audits shared-component reuse.","designLab.tokens.autoNote":"The list is enumerated from the custom properties that actually exist on :root and grouped by prefix, so a new token needs no change here.","designLab.tokens.colors":"Colors","designLab.tokens.count":"{count} tokens","designLab.tokens.filter":"Filter tokens","designLab.tokens.filterEmpty":"No token matches.","designLab.tokens.filterPlaceholder":"Filter by name or value, e.g. amber","designLab.tokens.fonts":"Fonts","designLab.tokens.layers":"Layers","designLab.tokens.legend":"Colors always show two columns: left = light-theme value, right = dark-theme value; neither follows the active theme.","designLab.tokens.motion":"Motion","designLab.tokens.other":"Other","designLab.tokens.radii":"Radii","designLab.tokens.runtimeNote":'Non-color values are read from getComputedStyle(document.documentElement) under the active theme; the light and dark color columns come straight from the :root and :root[data-theme="dark"] declarations in tokens.css, independent of the active theme.',"designLab.tokens.shadows":"Shadows","designLab.tokens.sizes":"Sizes","designLab.tokens.spacing":"Spacing","designLab.tokens.subtitle":"Every custom property comes from the active theme, grouped by prefix into colors, type, spacing, radii, shadows, fonts, motion, sizes and layers.","designLab.tokens.themeDark":"Dark","designLab.tokens.themeLight":"Light","designLab.tokens.title":"Tokens","designLab.tokens.typeSample":"Type Aa 123","designLab.tokens.typography":"Type scale","designLab.tokens.undefined":"Undefined","designLab.gallery.autoNote":"Every *.preview.tsx under apps/web/src is collected automatically (lazy import.meta.glob); drop in a file and it shows up in its group (preview.group, else the directory name).","designLab.gallery.count":"{count} samples","designLab.gallery.empty":"No sample matches.","designLab.gallery.filter":"Filter samples","designLab.gallery.filterPlaceholder":"Filter by title, description or source path","designLab.gallery.loading":"Loading samples…","designLab.gallery.none":"No *.preview.tsx sample files were found.","designLab.gallery.renderError":"This sample failed to render; the others are unaffected.","designLab.gallery.sourcePath":"source","designLab.gallery.subtitle":"Living samples of components, cards and dialogs: one per *.preview.tsx, static data only, no requests.","designLab.gallery.title":"Components & dialogs","designLab.groups.chat":"Chat stream cards","designLab.groups.nav":"Navigation and status","designLab.groups.overlays":"Dialogs and overlays","designLab.groups.ui":"Primitives","designLab.inventory.title":"Component Inventory","designLab.inventory.subtitle":"Reuse first: check components/ui before building new UI. One consumer = likely one-off (share it or retire it); zero consumers = retirement candidate.","designLab.inventory.snapshotNote":"Build-time snapshot ({commit}); consumer counts exclude previews. Regenerate: bun apps/web/scripts/gen-component-inventory.ts.","designLab.inventory.colComponent":"Component","designLab.inventory.colPurpose":"Purpose","designLab.inventory.colReuse":"Reuse","designLab.inventory.colPreview":"Preview","designLab.inventory.kind.component":"component","designLab.inventory.kind.hook":"hook","designLab.inventory.kind.util":"util","designLab.inventory.reexport":"re-exports plugin-ui","designLab.inventory.flagZero":"retire candidate","designLab.inventory.flagSingle":"likely one-off","designLab.inventory.flagShared":"shared","designLab.inventory.previewCovered":"{count} sample(s)","designLab.inventory.previewMissing":"no preview","designLab.inventory.total":"{count} total","designLab.inventory.shared":"{count} shared","designLab.inventory.single":"{count} single-consumer","designLab.inventory.zero":"{count} zero-consumer","designLab.inventory.noPreview":"{count} missing preview","designLab.inventory.purpose.Badge":"Status / label badge (semantic tones)","designLab.inventory.purpose.Button":"Unified button (variant / size)","designLab.inventory.purpose.CardShell":"Card shell (border / surface / radius)","designLab.inventory.purpose.CountBadge":"Count badge (nav / list corners)","designLab.inventory.purpose.DataTable":"Semantic data table (sorting / responsive columns)","designLab.inventory.purpose.EntityHeader":"Entity page header (icon / title / scope / actions)","designLab.inventory.purpose.Field":"Form fields (Input / Select / Textarea)","designLab.inventory.purpose.FilterPopover":"Filter popover (table column filters)","designLab.inventory.purpose.Icon":"Unified icon entry (name → SVG)","designLab.inventory.purpose.KeyValueList":"Key-value list (detail views)","designLab.inventory.purpose.MessageActions":"Message action bar (copy, etc.)","designLab.inventory.purpose.MessageFold":"Message fold / expand","designLab.inventory.purpose.RichComposer":"Rich composer (mentions / attachments / atomic blocks)","designLab.inventory.purpose.SearchInput":"Search input","designLab.inventory.purpose.Section":"Section container (title / description / actions)","designLab.inventory.purpose.SidebarShell":"Sidebar shell (desktop sidebar / mobile drawer)","designLab.inventory.purpose.Stat":"Stat value card","designLab.inventory.purpose.card-surface":"Card surface class constants","designLab.inventory.purpose.clipboard":"Clipboard write helper","designLab.inventory.purpose.cn":"Class merge (clsx + tailwind-merge)","designLab.inventory.purpose.ghost-control":"Ghost control class constants","designLab.inventory.purpose.useEnteringItemKeys":"List entrance-animation key hook","designLab.inventory.purpose.useTypewriterText":"Typewriter text hook","designLab.preview.actionMenu.archive":"Archive (unavailable)","designLab.preview.actionMenu.delete":"Delete","designLab.preview.actionMenu.desc":"Row action menu: arrow keys / Home / End / Esc; clicking outside closes it and restores focus.","designLab.preview.actionMenu.duplicate":"Duplicate","designLab.preview.actionMenu.rename":"Rename","designLab.preview.agentMessage.desc":"Agent delivery card: the header says which agent sent it; the expanded body starts with the source address and time; collapsed is one summary line.","designLab.preview.assistant.desc":"Assistant body: Markdown text with a left-aligned copy action below it that appears on hover or focus.","designLab.preview.badge.desc":"Every tone: neutral, accent, info, warn, danger and success.","designLab.preview.badge.title":"Badge","designLab.preview.button.desc":"Every variant: plain, primary, danger, dangerGhost, link and chip.","designLab.preview.button.title":"Button","designLab.preview.chipTones.desc":"One chip per tone in CHIP_TONES: muted, info, warn, ok, danger and band. A chip tone is still derived from the status, so each one shows the first status that uses it; band is the onBand variant (opaque ground, ink text).","designLab.preview.chipTones.note":"The glyph never changes between tones — only the ground and the text color do, so color is never the only carrier of meaning.","designLab.preview.chipTones.onBandTitle":"band on a colored band","designLab.preview.chipTones.title":"StatusChip tones","designLab.preview.composerIcon.desc":"One shape layer (32px circle, sunken ground, strong border) with both tone slots: primary borrows the accent, quiet stays muted and turns ink on hover; disabled keeps the circle and only greys the icon.","designLab.preview.composerIcon.disabled":"disabled","designLab.preview.composerIcon.note":"Left to right: send plane (16px), paperclip (14px, same ink area), disabled send. Hover the enabled ones to see the hover tone — the box never changes, only the icon color.","designLab.preview.composerIcon.sampleLabel":"Sample {tone} icon button","designLab.preview.composerIcon.title":"Composer icon button","designLab.preview.depthColor.title":"Depth palette","designLab.preview.depthColor.desc":"Tree-depth coloring for the session-card address subtitle: hue = (root hue + depth × step) mod 360 (golden-angle rotation, endless without saturation), OKLCH fixed L/C with native browser gamut mapping. Reads current settings; the two rows are light/dark (depth 0–9) for before/after comparison while tuning.","designLab.preview.depthColor.lightRow":"Light","designLab.preview.depthColor.darkRow":"Dark","designLab.preview.depthColor.depthLabel":"depth {depth}","designLab.preview.depthColor.params":"root hue {rootHue}° · step {hueStep}° · L/C light {lLight}/{cLight} · dark {lDark}/{cDark}","designLab.preview.depthColor.disabled":"Depth color is off (address slots all use the theme accent)","designLab.preview.depthColor.swatchLabel":"depth {depth}, hue {hue}°","designLab.preview.confirm.body":"Sample copy: confirming only closes the dialog.","designLab.preview.confirm.dangerBody":"Sample copy: a danger primary button that needs an explicit confirmation.","designLab.preview.confirm.dangerConfirm":"Delete","designLab.preview.confirm.dangerTitle":"Delete this session?","designLab.preview.confirm.desc":"Confirm dialog: initial focus sits on Cancel so Enter cannot trigger the dangerous action.","designLab.preview.confirm.openDanger":"Open danger confirm","designLab.preview.confirm.openPlain":"Open confirm dialog","designLab.preview.confirm.title":"Save these changes?","designLab.preview.dataTable.colName":"Name","designLab.preview.dataTable.colOwner":"Owner","designLab.preview.dataTable.colStatus":"Status","designLab.preview.dataTable.desc":"A 1px gap between rows lets the page background through; the table keeps a small outer radius.","designLab.preview.dataTable.title":"DataTable","designLab.preview.cardShell.desc":"Unified surface for static content cards: header (status/title) → body → footer (actions). No hover lift; clickable list cards use card-surface.","designLab.preview.cardShell.sampleAction":"View details","designLab.preview.cardShell.sampleBody":"Async job cards / tool image cards share this one class string and the same slots, so surface styles never drift apart.","designLab.preview.cardShell.sampleStatus":"Done","designLab.preview.cardShell.sampleTitle":"Sample job card","designLab.preview.cardShell.title":"CardShell","designLab.preview.filterPopover.desc":"Header filter: trigger + dropdown panel with arrow-key navigation; a search box appears when options exceed the threshold (default 8).","designLab.preview.filterPopover.sampleLabel":"Status","designLab.preview.filterPopover.sampleSearch":"Search options","designLab.preview.filterPopover.title":"FilterPopover","designLab.preview.messageFold.desc":"Above the threshold (--msg-fold-max-h) it collapses by default with a bottom fade and a toggle button; the DOM always holds the full text (copy gets everything), and streaming never folds.","designLab.preview.messageFold.sample":`This is a long message used to demonstrate folding. It exceeds the threshold height, so it collapses by default with a bottom fade and an "expand" button.
|
|
3
|
+
|
|
4
|
+
Folding only changes display: max-height + overflow + mask; the DOM always holds the full text. The copy button gets the original, and manual selection sees the same text.
|
|
5
|
+
|
|
6
|
+
During streaming nothing is clipped and no button appears — otherwise the body would fold/unfold with every new chunk. Overflow is judged by scrollHeight only: while clipped it still reports the full content height.
|
|
7
|
+
|
|
8
|
+
The threshold comes from a CSS variable (single source), with a fallback matching tokens.css. Without ResizeObserver it measures once at mount.
|
|
9
|
+
|
|
10
|
+
User bubbles on the chat page and team-page bubbles share this one component and the same classes — never copy the threshold or width rules.
|
|
11
|
+
|
|
12
|
+
Rule of thumb: fold only inside tinted bubbles, never plain body text. Assistant prose and cards do not mount this component.
|
|
13
|
+
|
|
14
|
+
One more paragraph so the height clearly exceeds the threshold: every design-lab sample is read-only static data, no RPC, viewable while disconnected.
|
|
15
|
+
|
|
16
|
+
Last paragraph: after expanding, the button never suddenly disappears, and the fold never oscillates between expanded and collapsed.`,"designLab.preview.messageFold.title":"MessageFold","designLab.preview.sidebarShell.desc":"Sidebar container shell: header (title + actions) / controls row / scrollable children; optional drawer mode at ≤1023px (this sample is a plain column).","designLab.preview.sidebarShell.sampleRow":"Sample row {index}","designLab.preview.sidebarShell.sampleSearch":"Search sessions","designLab.preview.sidebarShell.sampleTitle":"Sessions","designLab.preview.sidebarShell.title":"SidebarShell","designLab.preview.entityHeader.desc":"Both size steps side by side: page = 22px serif (the one h1 per screen), panel = 16px sans (a panel heading). Size only changes type, never color; ancestors always stay smaller and dimmer.","designLab.preview.entityHeader.sampleAction":"Back","designLab.preview.entityHeader.sampleDetails":"Details","designLab.preview.entityHeader.sampleNode":"Sample node","designLab.preview.entityHeader.sampleStatus":"Archived","designLab.preview.entityHeader.sampleTitle":"Sample team","designLab.preview.entityHeader.title":"EntityHeader","designLab.preview.env.desc":"Environment card: the header carries the scope label (plus a danger note when not applied) and the line count; expand for the raw context lines.","designLab.preview.failure.desc":"Failure cards: collapsed keeps only the dot and a one-line error; status and run id live in the expanded body, never in the header. Both states are shown.","designLab.preview.form.desc":"Field labels, input wells and selects; focus uses the focus ring, never a border.","designLab.preview.form.fast":"Fast","designLab.preview.form.mode":"Mode","designLab.preview.form.name":"Name","designLab.preview.form.nameHint":"The control well uses --surface-sunken.","designLab.preview.form.namePlaceholder":"e.g. nightly-report","designLab.preview.form.thorough":"Thorough","designLab.preview.form.title":"Field / Input / Select","designLab.preview.keyValue.desc":"Two-column definition list with wrapping values.","designLab.preview.keyValue.gateway":"Gateway","designLab.preview.keyValue.protocol":"Protocol","designLab.preview.keyValue.tenant":"Identity","designLab.preview.keyValue.title":"KeyValueList","designLab.preview.mention.desc":"Mention list: the listbox half of the combobox; arrow keys move aria-activedescendant.","designLab.preview.mention.hint":"Sample members: hover highlights; picking only moves the highlight and sends nothing.","designLab.preview.modal.body":"Sample body: the panel scrolls on its own and the scrim also closes it.","designLab.preview.modal.desc":"Dialog shell: scrim, centered panel, Esc to close and a focus ring; sm / md / lg widths.","designLab.preview.modal.hint":"Pick a width, then open it.","designLab.preview.modal.open":"Open dialog","designLab.preview.modal.title":"Dialog title","designLab.preview.navItem.collapsed":"Collapsed shows only the icon; hover for 300 ms to see the tooltip (title, status, count, version).","designLab.preview.navItem.desc":"Menu buttons: group header, the four status dots (accent / amber / danger / muted), the collapsed form, and the group open/close animation.","designLab.preview.navItem.groupCollapsed":"Collapsed group header: the aggregated count badge (the pending backlog stays visible) plus an accent dot when the current page is inside; not duplicated while expanded.","designLab.preview.navItem.groupToggle":"Click the header to toggle the group: grid 0fr↔1fr transition at 200 ms (--motion-base); collapsed content ends inert, so Tab never lands on hidden items.","designLab.preview.navItem.plain":"An item with no status signal: no dot, and no placeholder version.","designLab.preview.navStatus.colStatus":"Status","designLab.preview.navStatus.colValue":"Value in the active theme","designLab.preview.navStatus.desc":"The four-tone scale against color tokens: labels come from the nav-status.ts helpers, and the dots are rendered by NavItem itself.","designLab.preview.navStatus.note":"The hub is probed as soon as the WebUI opens; unconfigured and unknown both fall back to muted (--faint is the default dot). hub, gateway and pluginHost all share this same four-tone scale.","designLab.preview.pageScaffold.desc":"Title, subtitle and content; the page header holds only those two lines.","designLab.preview.pageScaffold.sampleBody":"Content starts below the header; PageScaffold owns the spacing.","designLab.preview.pageScaffold.sampleSubtitle":"The header holds only a title and subtitle.","designLab.preview.pageScaffold.sampleTitle":"Sample page","designLab.preview.pageScaffold.title":"PageScaffold","designLab.preview.queued.desc":"Queued card: amber band with a waiting chip; the round icon keys (take back to edit, cancel, mark as handled) sit on the line below the message text, on a translucent white 10% fill; an agent-source card has no keys at all.","designLab.preview.reasoning.desc":"Reasoning card: title, a copy button on its left, and the time at the far right; more than 12 lines expand, and it collapses when streaming ends.","designLab.preview.section.desc":"Raised panel with a title, description and optional actions.","designLab.preview.section.sampleBody":"Spacing groups content under the header; there are no divider lines.","designLab.preview.section.sampleDesc":"Description: one surface per region, never a card inside a card.","designLab.preview.section.sampleTitle":"Section title","designLab.preview.section.title":"Section","designLab.preview.stat.agents":"Online agents","designLab.preview.stat.agentsHint":"Current node","designLab.preview.stat.desc":"Metric block: a mono value with a muted label.","designLab.preview.stat.runs":"Active runs","designLab.preview.stat.runsHint":"Last 5 minutes","designLab.preview.stat.title":"Stat","designLab.preview.states.action":"Create","designLab.preview.states.desc":"Unified empty, loading and error states.","designLab.preview.states.emptyDesc":"Sample data: the first record will show up here.","designLab.preview.states.emptyTitle":"Nothing here yet","designLab.preview.states.error":"Sample: the request failed; check the gateway connection.","designLab.preview.states.loading":"Loading samples…","designLab.preview.states.title":"States","designLab.preview.statusIcons.chips":"Full form (StatusChip: glyph, text, tone background) for the five states a session can be in","designLab.preview.statusIcons.desc":"Status cross-reference: every StatusKind as glyph, localized label and the raw status literal the API and config use. Session lists only use five of them; the rest come from runs, nodes and plugins. Color is only an enhancement, so glyph and text always carry the meaning.","designLab.preview.statusIcons.list":"Every status: glyph, label, raw value (the literal the API and config use)","designLab.preview.statusIcons.title":"StatusChip / StatusGlyph","designLab.preview.tabs.desc":"In-domain tabs with arrow-key navigation.","designLab.preview.tabs.details":"Details","designLab.preview.tabs.history":"History","designLab.preview.tabs.label":"Sample tabs","designLab.preview.tabs.overview":"Overview","designLab.preview.tabs.title":"SegmentedTabs","designLab.preview.tool.desc":"Tool card: the header holds only the name and duration; expand for description, input and output. Errors stay visible while collapsed.","designLab.preview.projection.desc":"Projection card (0.54): a badge stays in the header (visible while collapsed); the first body section switches between the original and what the model saw. The original is the default when it lives in the message body; when it only exists in the event log the card lands on the model view and offers a read-back (an empty read-back degrades to “the original is unrecoverable”).","designLab.preview.toolbar.desc":"Control strip directly above a table or Section: filters, search and batch actions.","designLab.preview.toolbar.label":"Sample table toolbar","designLab.preview.toolbar.placeholder":"Filter rows","designLab.preview.toolbar.refresh":"Refresh","designLab.preview.toolbar.title":"TableToolbar","designLab.preview.tooltip.bottom":"Tooltip placed below","designLab.preview.tooltip.bottomTrigger":"Hover for the one below","designLab.preview.tooltip.desc":"Tooltip: shows after 300 ms of hover or focus, closes on Esc and flips below when space runs out.","designLab.preview.tooltip.icon":"Icon button tooltip","designLab.preview.tooltip.label":"Tooltip placed above","designLab.preview.tooltip.trigger":"Hover for the tooltip","designLab.preview.userBubble.desc":"User bubble: bubble plus attachment chips, with the time in the hover meta slot (always visible on touch).","gateway.subtitle":"The gateway this browser is connected to: endpoint, node identity, version, and uptime.","pluginHost.subtitle":"Marketplace runtime status and the registry this host loads plugins from.","nodes.subtitle":"Nodes this gateway can reach, with health and workload counts.","nodes.detailActions":"Node actions","agents.subtitle":"Agents across connected nodes, with their team, state, and presence.","agents.edit.subtitle":"Change this agent's name, model, and system prompt.","agents.detailActions":"Agent actions","runs.subtitle":"Live and recoverable runs from every connected node.","integrations.tools.subtitle":"Tools the model can call, with their approval policy.","integrations.mcp.subtitle":"MCP servers this gateway connects to, and their tool availability.","integrations.channels.subtitle":"External channel connectivity and message delivery status.","account.trigger.signedIn":"Account menu: {user}","account.trigger.anonymous":"Not signed in: open sign-in","account.panel":"Account","account.anonymous":"Not signed in","account.role":"Role: {role}","account.team":"Team: {team}","account.node.title":"Current node","account.node.none":"No node connected yet","account.node.switch":"Switch node","account.node.state.up":"online","account.node.state.connecting":"connecting","account.node.state.down":"offline","account.node.state.unknown":"state unknown","account.auth.title":"Sign-in method","account.auth.relogin":"Sign in again / switch account","account.auth.empty":"This deployment has no sign-in method enabled.","account.auth.signOutFirst":"signs you out first","account.settings":"Settings","error.hint.unauthorized":`What happened: the RPC request was rejected (unauthenticated).
|
|
17
|
+
Why: the token is missing, expired, or does not match the target node.
|
|
18
|
+
How to fix: re-enter the correct token in connection settings; check fingerprints with vessel token list.
|
|
19
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.forbidden":`What happened: the request was rejected by the permission policy.
|
|
20
|
+
Why: the token permission level is insufficient for this method.
|
|
21
|
+
How to fix: use a token with sufficient permission, or adjust the method requirement.
|
|
22
|
+
Where to look: vessel errors --id <error_id>; vessel doctor.`,"error.hint.not_found":`What happened: the target resource does not exist.
|
|
23
|
+
Why: the id is wrong or the resource was deleted.
|
|
24
|
+
How to fix: verify the id in the matching list; pick from candidates when present.
|
|
25
|
+
Where to look: vessel errors --id <error_id> for details.candidates.`,"error.hint.invalid_params":`What happened: RPC parameters failed validation.
|
|
26
|
+
Why: a required field is missing, a type is wrong, or exclusive fields were both given.
|
|
27
|
+
How to fix: check the schema with vessel rpc list <method> and fix the parameters.
|
|
28
|
+
Where to look: vessel errors --id <error_id> for details.`,"error.hint.data_locked":`What happened: the data is locked by another process.
|
|
29
|
+
Why: another instance holds the lock on the same dataDir.
|
|
30
|
+
How to fix: inspect processes with vessel gateway ps; stop the duplicate or use another dataDir.
|
|
31
|
+
Where to look: vessel doctor (lock check).`,"error.hint.quota_exceeded":`What happened: quota exceeded.
|
|
32
|
+
Why: a platform/team quota cap was reached.
|
|
33
|
+
How to fix: check the quota config or ask an admin to raise the cap.
|
|
34
|
+
Where to look: vessel errors --id <error_id> for details.`,"error.hint.conflict":`What happened: state conflict; the request was rejected.
|
|
35
|
+
Why: concurrent modification or an unmet precondition.
|
|
36
|
+
How to fix: refresh state and retry.
|
|
37
|
+
Where to look: vessel errors --id <error_id>; vessel status.`,"error.hint.internal":`What happened: gateway internal error.
|
|
38
|
+
Why: an unclassified server-side exception.
|
|
39
|
+
How to fix: check logs with vessel logs tail; vessel doctor --errors for drift.
|
|
40
|
+
Where to look: vessel errors --id <error_id> for the cause chain.`,"error.hint.not_supported":`What happened: the gateway does not support this capability.
|
|
41
|
+
Why: the target build is too old or the capability is not wired.
|
|
42
|
+
How to fix: upgrade the target node/gateway; check methods with vessel rpc list.
|
|
43
|
+
Where to look: vessel errors --id <error_id> for details.method.`,"error.hint.expired":`What happened: the credential or session expired.
|
|
44
|
+
Why: the token/session is past its TTL.
|
|
45
|
+
How to fix: re-authenticate or rotate the token (vessel token rotate).
|
|
46
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.run_ended":`What happened: the run ended and can no longer be operated on.
|
|
47
|
+
Why: the run completed/failed/was cancelled.
|
|
48
|
+
How to fix: start a new run, or resume a resumable one (vessel --resume-run).
|
|
49
|
+
Where to look: vessel errors --run <run_id>.`,"error.hint.session_not_found":`What happened: the session does not exist.
|
|
50
|
+
Why: the session_id is wrong, or the session was deleted / lives in another dataDir.
|
|
51
|
+
How to fix: list sessions with vessel --resume; verify dataDir/tenant.
|
|
52
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.compact_unavailable":`What happened: session compaction is unavailable.
|
|
53
|
+
Why: the store does not support compact, or the state is insufficient.
|
|
54
|
+
How to fix: upgrade to a timeline-capable version; or start a new session.
|
|
55
|
+
Where to look: vessel errors --id <error_id>; vessel doctor.`,"error.hint.gateway_restarting":`What happened: the gateway is restarting; request temporarily rejected.
|
|
56
|
+
Why: the node is in a restart/drain window.
|
|
57
|
+
How to fix: retry shortly (retryable); watch progress with vessel node status.
|
|
58
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.no_active_run":`What happened: there is no active run.
|
|
59
|
+
Why: the operation requires an active run, but none exists.
|
|
60
|
+
How to fix: start a run first.
|
|
61
|
+
Where to look: vessel status; vessel errors --id <error_id>.`,"error.hint.run_mismatch":`What happened: run mismatch.
|
|
62
|
+
Why: the requested run_id does not match the active run.
|
|
63
|
+
How to fix: verify the run_id (vessel status / runs.list).
|
|
64
|
+
Where to look: vessel errors --run <run_id>.`,"error.hint.marker_failed":`What happened: writing the run marker failed.
|
|
65
|
+
Why: run store write anomaly (disk/permission).
|
|
66
|
+
How to fix: check dataDir disk and permissions; vessel doctor.
|
|
67
|
+
Where to look: vessel errors --id <error_id> for the cause chain.`,"error.hint.restart_reserve_failed":`What happened: restart reservation failed.
|
|
68
|
+
Why: the restart slot is taken or the state does not allow it.
|
|
69
|
+
How to fix: check state with vessel node status; retry or vessel gateway restart.
|
|
70
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.legacy_session_unsupported":`What happened: legacy session format is not supported.
|
|
71
|
+
Why: the session predates timeline.
|
|
72
|
+
How to fix: start a new session; old data stays in dataDir but cannot be read here.
|
|
73
|
+
Where to look: vessel errors --id <error_id>; vessel doctor.`,"error.hint.timeline_unavailable":`What happened: the timeline is unavailable.
|
|
74
|
+
Why: the timeline store is not wired or the read failed.
|
|
75
|
+
How to fix: verify the root layout (vessel doctor); upgrade/restart the gateway.
|
|
76
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.method_not_found":`What happened: unknown RPC method.
|
|
77
|
+
Why: the method name is wrong or the target lacks it.
|
|
78
|
+
How to fix: check methods with vessel rpc list; upgrade the target for new methods.
|
|
79
|
+
Where to look: vessel errors --id <error_id> for details.method.`,"error.hint.run_already_running":`What happened: a run is already active; duplicate start rejected.
|
|
80
|
+
Why: the same session already has an active run.
|
|
81
|
+
How to fix: wait for it to finish or cancel with vessel stop, then start again.
|
|
82
|
+
Where to look: vessel status; vessel errors --id <error_id>.`,"error.hint.run_not_found":`What happened: the run does not exist.
|
|
83
|
+
Why: the run_id is wrong or the record was cleaned up.
|
|
84
|
+
How to fix: verify the run_id (runs.list / vessel status).
|
|
85
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.run_not_resumable":`What happened: the run cannot be resumed.
|
|
86
|
+
Why: the run state does not meet resume conditions.
|
|
87
|
+
How to fix: start a new run; list resumable sessions with vessel --resume.
|
|
88
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.run_store_required":`What happened: a run store is required.
|
|
89
|
+
Why: the operation needs a durable run store, but none is wired.
|
|
90
|
+
How to fix: check the run store config (dataDir layout); upgrade the gateway.
|
|
91
|
+
Where to look: vessel doctor; vessel errors --id <error_id>.`,"error.hint.agent_not_found":`What happened: the agent does not exist.
|
|
92
|
+
Why: the member id is wrong or the member was closed.
|
|
93
|
+
How to fix: list members with vessel agents; pick from candidates when present.
|
|
94
|
+
Where to look: vessel errors --id <error_id> for details.candidates.`,"error.hint.session_corrupt":`What happened: session data is corrupt.
|
|
95
|
+
Why: the session file is damaged or malformed.
|
|
96
|
+
How to fix: back up, then start a new session; do not hand-edit session files.
|
|
97
|
+
Where to look: vessel errors --id <error_id> for the cause chain.`,"error.hint.atomic_write_failed":`What happened: atomic write failed.
|
|
98
|
+
Why: disk full, insufficient permissions, or the file is locked.
|
|
99
|
+
How to fix: check dataDir disk and permissions; retry (retryable).
|
|
100
|
+
Where to look: vessel doctor; vessel errors --id <error_id>.`,"error.hint.limit_blocked":`What happened: blocked by a limit.
|
|
101
|
+
Why: a run iteration/token limit was reached.
|
|
102
|
+
How to fix: adjust the limit config or split the task.
|
|
103
|
+
Where to look: vessel errors --id <error_id> for details.`,"error.hint.empty_response_exhausted":`What happened: empty-response retries exhausted.
|
|
104
|
+
Why: the model returned empty content several times in a row.
|
|
105
|
+
How to fix: test with vessel model test; switch model (vessel model set-default).
|
|
106
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.invalid_input":`What happened: invalid agent input.
|
|
107
|
+
Why: a request field is missing or malformed.
|
|
108
|
+
How to fix: check the schema with vessel rpc list <method> and fix the input.
|
|
109
|
+
Where to look: vessel errors --id <error_id> for details.`,"error.hint.unknown_member":`What happened: unknown member.
|
|
110
|
+
Why: the member id is not on this team roster.
|
|
111
|
+
How to fix: verify the id with vessel agents; pick from candidates when present.
|
|
112
|
+
Where to look: vessel errors --id <error_id> for details.candidates.`,"error.hint.member_closed":`What happened: the member is closed.
|
|
113
|
+
Why: the target was released and no longer accepts messages.
|
|
114
|
+
How to fix: send to an active member, or recreate the member.
|
|
115
|
+
Where to look: vessel agents; vessel errors --id <error_id>.`,"error.hint.member_stale":`What happened: member state is stale.
|
|
116
|
+
Why: the referenced member snapshot is no longer current.
|
|
117
|
+
How to fix: refresh the member list (vessel agents) and retry.
|
|
118
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.member_not_visible":`What happened: the member is not visible.
|
|
119
|
+
Why: the member is private and outside your visibility.
|
|
120
|
+
How to fix: verify the id and visibility; ask the owner to adjust visibility.
|
|
121
|
+
Where to look: vessel agents; vessel errors --id <error_id>.`,"error.hint.no_parent":`What happened: no parent agent.
|
|
122
|
+
Why: the operation requires a parent (e.g. hire), but this member has none.
|
|
123
|
+
How to fix: operate from a context with a parent, or use create instead.
|
|
124
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.spawn_failed":`What happened: agent startup failed.
|
|
125
|
+
Why: startup prompt delivery or body initialization failed (record not rolled back).
|
|
126
|
+
How to fix: find the root cause via vessel errors --id <error_id>, then retry.
|
|
127
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.team_full":`What happened: the team is full.
|
|
128
|
+
Why: the member count reached the team cap.
|
|
129
|
+
How to fix: close unneeded members (agents.close) to free slots.
|
|
130
|
+
Where to look: vessel agents; vessel errors --id <error_id>.`,"error.hint.team_frozen":`What happened: the team is frozen.
|
|
131
|
+
Why: a frozen team accepts no new operations.
|
|
132
|
+
How to fix: check the team state; unfreeze or use another team.
|
|
133
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.invalid_state_transition":`What happened: invalid state transition.
|
|
134
|
+
Why: the operation is incompatible with the current member/team state.
|
|
135
|
+
How to fix: refresh state (vessel agents) and choose a valid operation.
|
|
136
|
+
Where to look: vessel errors --id <error_id> for details.`,"error.hint.budget_exceeded":`What happened: conversation budget exceeded.
|
|
137
|
+
Why: one of hops/turns/tokens/wall-clock hit the teams[].budget cap.
|
|
138
|
+
How to fix: adjust teams[].budget (maxHops/maxTurns/maxTokens/maxWallClockSeconds) or split the task.
|
|
139
|
+
Where to look: vessel errors --id <error_id> for the dimension in details.`,"error.hint.budget_unavailable":`What happened: the budget store is unavailable.
|
|
140
|
+
Why: budget counter store read/write failed.
|
|
141
|
+
How to fix: check dataDir disk and permissions; vessel doctor; retry.
|
|
142
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.conversation_team_mismatch":`What happened: conversation/team mismatch.
|
|
143
|
+
Why: the conversation belongs to another team and cannot be reused across teams.
|
|
144
|
+
How to fix: operate within the owning team, or start a new conversation.
|
|
145
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.body_limit":`What happened: body count limit reached.
|
|
146
|
+
Why: each agent allows at most 1 live body.
|
|
147
|
+
How to fix: wait for the current body to finish or close it before creating.
|
|
148
|
+
Where to look: vessel agents; vessel errors --id <error_id>.`,"error.hint.node_draining":`What happened: the node is draining.
|
|
149
|
+
Why: the drain window temporarily accepts no new work.
|
|
150
|
+
How to fix: retry shortly (retryable); watch progress with vessel node status.
|
|
151
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.team_not_found":`What happened: the team does not exist.
|
|
152
|
+
Why: the team_id is wrong or the team was deleted.
|
|
153
|
+
How to fix: verify the team_id (teams.list); pick from candidates when present.
|
|
154
|
+
Where to look: vessel errors --id <error_id> for details.candidates.`,"error.hint.team_conversation_not_found":`What happened: the team conversation does not exist.
|
|
155
|
+
Why: the conversation id is wrong or does not belong to this team.
|
|
156
|
+
How to fix: verify the id and team ownership; create a new team conversation.
|
|
157
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.team_log_write_failed":`What happened: team log write failed.
|
|
158
|
+
Why: team log store write anomaly (disk/permission).
|
|
159
|
+
How to fix: check dataDir disk and permissions; retry.
|
|
160
|
+
Where to look: vessel errors --id <error_id> for the cause chain; vessel doctor.`,"error.hint.team_binding_requires_name":`What happened: team binding requires a name.
|
|
161
|
+
Why: the binding operation is missing the required name field.
|
|
162
|
+
How to fix: provide the name field and retry.
|
|
163
|
+
Where to look: vessel errors --id <error_id>; vessel rpc list <method>.`,"error.hint.team_already_in_team":`What happened: the member is already in the team.
|
|
164
|
+
Why: duplicate join of the same team.
|
|
165
|
+
How to fix: no need to join again; check the member's current team.
|
|
166
|
+
Where to look: vessel agents; vessel errors --id <error_id>.`,"error.hint.team_not_member":`What happened: not a team member.
|
|
167
|
+
Why: the operation requires membership, but the caller is not on the roster.
|
|
168
|
+
How to fix: join the team first (teams.join), or use a member with permission.
|
|
169
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.team_private_member":`What happened: the target is a private member.
|
|
170
|
+
Why: private members are outside team visibility.
|
|
171
|
+
How to fix: ask the owner to adjust visibility, or use a team-visible member.
|
|
172
|
+
Where to look: vessel agents; vessel errors --id <error_id>.`,"error.hint.team_no_team":`What happened: no team context.
|
|
173
|
+
Why: the operation requires a team, but this member is not bound to one.
|
|
174
|
+
How to fix: create or join a team first.
|
|
175
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.team_self_mention":`What happened: cannot @ yourself.
|
|
176
|
+
Why: the message mentions its own sender, forming a self-loop.
|
|
177
|
+
How to fix: mention a different member.
|
|
178
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.team_owner_not_rosterable":`What happened: the owner cannot be rostered.
|
|
179
|
+
Why: the owner identity cannot be added as a regular member.
|
|
180
|
+
How to fix: use a non-owner member for this operation.
|
|
181
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.team_not_empty":`What happened: the team is not empty.
|
|
182
|
+
Why: delete/archive requires an empty team.
|
|
183
|
+
How to fix: close/remove all members first (agents.close), then delete.
|
|
184
|
+
Where to look: vessel agents; vessel errors --id <error_id>.`,"error.hint.team_archived":`What happened: the team is archived.
|
|
185
|
+
Why: archived teams are read-only.
|
|
186
|
+
How to fix: use an active team; contact an admin to restore if needed.
|
|
187
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.not_visible":`What happened: the resource is not visible.
|
|
188
|
+
Why: the resource is private or outside your visibility.
|
|
189
|
+
How to fix: verify the id and visibility; ask the owner to adjust visibility.
|
|
190
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.message_not_found":`What happened: the message does not exist.
|
|
191
|
+
Why: the message_id is wrong or the message was cleaned up.
|
|
192
|
+
How to fix: verify the message_id (inbox / team log).
|
|
193
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.cursor_out_of_window":`What happened: cursor out of window.
|
|
194
|
+
Why: the paging cursor points beyond the retention window.
|
|
195
|
+
How to fix: list again without since to get an in-window cursor.
|
|
196
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.unknown_ref":`What happened: unknown model reference.
|
|
197
|
+
Why: the provider/model ref is not in the model registry.
|
|
198
|
+
How to fix: list refs with vessel model list; set default with vessel model set-default; pick from candidates when present.
|
|
199
|
+
Where to look: vessel errors --id <error_id> for details.candidates; vessel doctor.`,"error.hint.pii_unknown_handle":`What happened: unknown PII placeholder.
|
|
200
|
+
Why: the handle does not exist or was never issued.
|
|
201
|
+
How to fix: verify the handle comes from this session's redacted output; never guess.
|
|
202
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.pii_expired_handle":`What happened: the PII placeholder expired.
|
|
203
|
+
Why: the handle is past its TTL.
|
|
204
|
+
How to fix: re-fetch the redacted content for a fresh handle.
|
|
205
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.pii_invalidated_handle":`What happened: the PII placeholder was invalidated.
|
|
206
|
+
Why: the original value changed or the session ended.
|
|
207
|
+
How to fix: re-fetch the redacted content for a fresh handle.
|
|
208
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.pii_reveal_denied":`What happened: PII reveal was denied.
|
|
209
|
+
Why: human approval was not granted or policy forbids it.
|
|
210
|
+
How to fix: request human approval and retry; do not bypass.
|
|
211
|
+
Where to look: vessel errors --id <error_id>; permission logs.`,"error.hint.provider_auth":`What happened: model provider authentication failed.
|
|
212
|
+
Why: the API key is missing, invalid, or expired.
|
|
213
|
+
How to fix: configure credentials with vessel model credential set; verify the env var named by provider.apiKeyEnv has a value.
|
|
214
|
+
Where to look: vessel model test; vessel errors --id <error_id>.`,"error.hint.provider_rate_limit":`What happened: provider rate limit.
|
|
215
|
+
Why: request frequency exceeded the provider rate limit.
|
|
216
|
+
How to fix: retry shortly (retryable, automatic backoff); reduce concurrency or raise the limit if persistent.
|
|
217
|
+
Where to look: vessel errors --id <error_id>; vessel logs tail.`,"error.hint.provider_quota_exceeded":`What happened: provider quota exhausted.
|
|
218
|
+
Why: account quota/balance is used up.
|
|
219
|
+
How to fix: top up or raise the quota; switch model (vessel model set-default).
|
|
220
|
+
Where to look: vessel model test; vessel errors --id <error_id>.`,"error.hint.provider_timeout":`What happened: provider request timed out.
|
|
221
|
+
Why: the model response exceeded the timeout threshold.
|
|
222
|
+
How to fix: retry (retryable); check the network or switch model if persistent.
|
|
223
|
+
Where to look: vessel model test; vessel errors --id <error_id>.`,"error.hint.provider_context_overflow":`What happened: context overflow.
|
|
224
|
+
Why: the prompt exceeds the model context window.
|
|
225
|
+
How to fix: compact the session or start a new one; switch to a larger-context model.
|
|
226
|
+
Where to look: vessel errors --id <error_id> for details.`,"error.hint.provider_unavailable":`What happened: provider unavailable.
|
|
227
|
+
Why: the provider service is temporarily unavailable (5xx/maintenance).
|
|
228
|
+
How to fix: retry shortly (retryable); switch model if persistent.
|
|
229
|
+
Where to look: vessel model test; vessel errors --id <error_id>.`,"error.hint.provider_http_error":`What happened: provider HTTP error.
|
|
230
|
+
Why: the provider returned an unexpected HTTP status.
|
|
231
|
+
How to fix: check http_status and cause with vessel errors --id <error_id>; verify baseUrl and credentials.
|
|
232
|
+
Where to look: vessel model test; vessel logs tail.`,"error.hint.provider_network":`What happened: provider network error.
|
|
233
|
+
Why: network-layer failure (DNS/connection/TLS).
|
|
234
|
+
How to fix: check network and proxy; verify provider.baseUrl; retry (retryable).
|
|
235
|
+
Where to look: vessel model test; vessel errors --id <error_id>.`,"error.hint.provider_error":`What happened: other provider error.
|
|
236
|
+
Why: a provider error not covered by the subclasses above.
|
|
237
|
+
How to fix: inspect the cause chain with vessel errors --id <error_id>; report if needed.
|
|
238
|
+
Where to look: vessel logs tail; vessel model test.`,"error.hint.tool_timeout":`What happened: tool call timed out.
|
|
239
|
+
Why: tool execution exceeded the timeout threshold.
|
|
240
|
+
How to fix: retry (retryable); split long tasks or inspect the tool implementation.
|
|
241
|
+
Where to look: vessel errors --id <error_id> for tool_name; vessel logs tail.`,"error.hint.tool_not_found":`What happened: the tool does not exist.
|
|
242
|
+
Why: the tool name is wrong or the tool is not wired.
|
|
243
|
+
How to fix: verify the tool name and wiring (tools config); pick from candidates when present.
|
|
244
|
+
Where to look: vessel errors --id <error_id> for details.candidates.`,"error.hint.tool_invalid_arguments":`What happened: invalid tool arguments.
|
|
245
|
+
Why: arguments do not match the tool schema.
|
|
246
|
+
How to fix: fix the arguments per the tool schema and retry.
|
|
247
|
+
Where to look: vessel errors --id <error_id> for details.`,"error.hint.tool_blocked":`What happened: tool call blocked.
|
|
248
|
+
Why: the permission policy forbids this tool call.
|
|
249
|
+
How to fix: check permission.neverAutoApprove / tool whitelist; adjust the policy if it should be allowed.
|
|
250
|
+
Where to look: vessel errors --id <error_id>; permission logs.`,"error.hint.tool_error":`What happened: tool execution error.
|
|
251
|
+
Why: an internal tool exception.
|
|
252
|
+
How to fix: inspect the cause chain with vessel errors --id <error_id>; fix the tool or input and retry.
|
|
253
|
+
Where to look: vessel logs tail; vessel errors --run <run_id>.`,"error.hint.permission_timeout":`What happened: permission approval timed out.
|
|
254
|
+
Why: unattended approval exceeded the wait window.
|
|
255
|
+
How to fix: adjust teams[].permission.unattended / denyAfterSeconds; or approve promptly.
|
|
256
|
+
Where to look: vessel errors --id <error_id>; permission logs.`,"error.hint.permission_cancelled":`What happened: permission approval was cancelled.
|
|
257
|
+
Why: the approval request was actively cancelled.
|
|
258
|
+
How to fix: re-issue the operation and approve it.
|
|
259
|
+
Where to look: vessel errors --id <error_id>.`,"error.hint.permission_denied":`What happened: permission denied.
|
|
260
|
+
Why: the approver denied it or policy says deny.
|
|
261
|
+
How to fix: check the denial reason; adjust the operation or policy and retry — do not bypass.
|
|
262
|
+
Where to look: vessel errors --id <error_id>; permission logs.`,"error.hint.permission_error":`What happened: permission system error.
|
|
263
|
+
Why: internal anomaly in approval/policy execution.
|
|
264
|
+
How to fix: inspect the cause chain with vessel errors --id <error_id>; vessel doctor; report if persistent.
|
|
265
|
+
Where to look: vessel logs tail; permission logs.`,"error.hint.config_error":`What happened: configuration error.
|
|
266
|
+
Why: config validation failed or loading anomaly.
|
|
267
|
+
How to fix: fix the config at the reported path (locate with vessel doctor); hot-reload with vessel gateway reload.
|
|
268
|
+
Where to look: vessel doctor; vessel errors --id <error_id>.`,"error.hint.gateway_error":`What happened: gateway error.
|
|
269
|
+
Why: an unclassified gateway-layer anomaly.
|
|
270
|
+
How to fix: check logs with vessel logs tail; vessel doctor --errors; vessel gateway restart if needed.
|
|
271
|
+
Where to look: vessel errors --id <error_id> for the cause chain.`,"error.hint.internal_error":`What happened: internal error.
|
|
272
|
+
Why: an unclassified internal anomaly.
|
|
273
|
+
How to fix: inspect the cause chain with vessel errors --id <error_id>; vessel doctor --errors for drift; report.
|
|
274
|
+
Where to look: vessel logs tail.`,"error.hint.checkpoint_failed":`What happened: checkpoint write failed.
|
|
275
|
+
Why: run checkpoint persistence anomaly.
|
|
276
|
+
How to fix: check dataDir disk and permissions; retry (retryable); report if persistent.
|
|
277
|
+
Where to look: vessel errors --id <error_id>; vessel doctor.`},jx={"entity.scopeIn":"in","entity.currentNode":"当前","entity.details":"详情","entity.unnamed":"未命名","nav.domain.chat":"会话","nav.domain.pending":"消息","nav.domain.runs":"运行","nav.domain.integrations":"能力","nav.domain.capabilities":"能力清单","nav.domain.visual":"视觉效果","nav.domain.tools":"工具","nav.domain.mcp":"MCP 服务","nav.domain.channels":"渠道","nav.domain.observe":"可观测","nav.domain.plugins":"插件","nav.domain.settings":"设置","nav.domain.designLab":"设计实验室","nav.group.chat":"会话","nav.group.items":"事项","nav.group.current":"当前页在此分组","nav.group.runs":"运行","nav.group.plugins":"插件","nav.group.observe":"OBSERVE","nav.group.top":"顶部","nav.group.settings":"设置","nav.settings":"设置","nav.group.integrations":"能力","nav.group.core":"核心","nav.mainLabel":"主导航","nav.bottomLabel":"主导航(移动端)","nav.openNav":"打开导航","nav.closeNav":"关闭导航","nav.openSessions":"打开会话列表","nav.closeSessions":"关闭会话列表","nav.collapseNav":"折叠侧栏","nav.expandNav":"展开侧栏","nav.jumpToMain":"跳到主内容","webBuild.outdated":"前端更新可用,刷新以加载新版本","webBuild.building":"前端更新正在构建中…","webBuild.buildingHint":"新的前端版本正在后台准备,完成后这里会自动提示刷新 —— 现在刷新看到的还是旧界面。","webBuild.stale":"前端更新失败 若要重试请重启","webBuild.autobuildOff":"前端更新已关闭(不会自动重建)","webBuild.reload":"刷新","rotateFollow.countdown":"{name} 将在 {seconds}s 后切换到新会话","rotateFollow.ready":"新会话已就绪({name})","rotateFollow.switch":"立即切换","nav.more":"更多","nav.diagnostics":"诊断","nav.moreSheet":"更多导航","nav.connectionNamed":"连接:{value}","nav.conn.online":"在线","nav.conn.connecting":"连接中…","nav.conn.connectingShort":"连接中","nav.conn.reconnecting":"重连中…","nav.conn.reconnectingShort":"重连中","nav.conn.closed":"已断开","nav.conn.error":"连接失败","nav.conn.idle":"未连接","nav.status.online":"在线","nav.status.connecting":"连接中","nav.status.error":"异常","nav.status.offline":"未连接","nav.status.unknown":"未知","nav.status.hubConnected":"Hub 已连接","nav.status.hubUnauthorized":"Hub token 无效","nav.status.hubIncompatible":"Hub 协议不兼容","nav.status.hubNetwork":"Hub 连接失败","nav.status.hubNotConfigured":"hub 未启用","nav.status.pluginHostNoMarketplace":"未安装 marketplace 插件","nav.status.pluginHostLoading":"正在读取插件列表","nav.status.pluginHostListError":"读取插件列表失败","nav.connStatusTitle":"gateway 连接状态;点击打开连接设置","nav.searchOrCommand":"搜索或输入命令","nav.opened":"已打开 {path}","nav.openNamed":"打开{domain}","nav.count":"{count} 个待处理","nav.hintNavigation":"导航","breadcrumb.chat":"会话","breadcrumb.chat.conversation":"对话","breadcrumb.pending":"待批","breadcrumb.runs.live":"实时","breadcrumb.runs.durable":"可恢复","breadcrumb.runs":"运行","breadcrumb.runs.details":"详情","breadcrumb.tools":"工具","breadcrumb.mcp":"MCP 服务","breadcrumb.channels":"渠道","breadcrumb.kanban":"看板","breadcrumb.plugins":"插件","pluginHost.noTokenReason":"连接 gateway 后查看插件宿主。","pluginHost.disconnectedReason":"连接 gateway 后查看插件宿主。","pluginHost.loading":"正在读取插件…","pluginHost.status.title":"Marketplace 状态","pluginHost.field.enabled":"启用","pluginHost.field.status":"状态","pluginHost.field.version":"版本","pluginHost.field.mode":"运行模式","pluginHost.field.plugins":"插件数","pluginHost.enabled.on":"已启用","pluginHost.enabled.off":"未启用","pluginHost.status.active":"活跃","pluginHost.status.inactive":"未激活","pluginHost.status.lazy":"宿主已连接,插件待激活","pluginHost.status.hostConnected":"宿主已连接","pluginHost.status.unhealthy":"异常","pluginHost.status.disabled":"已禁用","pluginHost.status.invalid":"无效","pluginHost.mode.in-process":"进程内","pluginHost.mode.child":"子进程","pluginHost.marketplaceMissing":"未找到 marketplace 插件。","pluginHost.registry.title":"Registry","pluginHost.registry.hint":"HTTPS registry index 地址;仅 localhost 允许 http。","pluginHost.registry.label":"Registry URL","pluginHost.registry.placeholder":"https://example.com/registry/index.json","pluginHost.registry.save":"保存","pluginHost.registry.saving":"正在保存…","pluginHost.registry.saved":"Registry URL 已保存。","pluginHost.registry.invalid":"请输入 HTTPS URL(localhost 可用 http)。","pluginHost.registry.disabledHint":"启用 marketplace 插件后才能修改。","pluginHost.registry.disconnectedHint":"连接 gateway 后才能修改。","breadcrumb.observe":"可观测","breadcrumb.observe.metrics":"指标","breadcrumb.observe.evals":"评测","breadcrumb.settings":"设置","breadcrumb.capabilities":"能力清单","breadcrumb.designLab":"设计实验室","settings.title":"设置","settings.category.visual":"视觉","settings.category.display":"显示与可见性","settings.category.runtime":"运行期","settings.category.logs":"日志","settings.category.connection":"连接","settings.category.advancedConfig":"高级","settings.category.extensions":"扩展","settings.item.local.navCollapsed.title":"侧栏默认折叠","settings.item.local.navCollapsed.desc":"打开 WebUI 时左侧导航栏的默认折叠态;左栏折叠按钮即时写同一存储键。","settings.item.local.navGroups.title":"分组展开状态","settings.item.local.navGroups.desc":"左侧导航各分组的展开态(只读展示);重置 = 全部收起。","settings.item.local.settingsTree.title":"设置分类树折叠态","settings.item.local.settingsTree.desc":"设置弹窗分类树的折叠状态(JSON 数组,本浏览器)。","settings.item.local.settingsTab.title":"设置默认层级","settings.item.local.settingsTab.desc":"打开设置弹窗时默认选中的层级 tab(用户 / 工作区 / 浏览器)。","settings.item.view.designLab.title":"设计实验室","settings.item.view.designLab.desc":"设计 token 与组件预览(纯静态样例,不连 gateway)。","settings.item.view.connection.title":"连接摘要","settings.item.view.connection.desc":"gateway 连接状态 / 节点 / 版本(只读诊断面)。","settings.item.view.advancedConfig.title":"高级配置","settings.item.view.advancedConfig.desc":"解析后的配置 JSON、键值表与来源表(只读)。","settings.item.verbosity.title":"输出详略","settings.item.showInternalEvents.title":"显示系统信息(内部事件)","settings.item.showInternalEvents.desc":"关闭时只保留正文、工具调用、错误与权限/ask 卡片;打开后额外显示运行提示、hook / LLM 上下文等系统消息(会话里的 vessel:* 上下文消息同受此键控制);verbosity=debug 也会显示这些系统消息。","settings.group.messageVisibility":"消息显示","settings.group.envNotice":"环境通知","settings.env.default.title":"缺省节奏","settings.env.default.desc":"下方未单列 scope 的兜底检测节奏;单 scope 设置优先于此。","settings.env.cadence.request":"每请求","settings.env.cadence.run":"每 run","settings.env.cadence.off":"关闭","settings.env.delivery.desc":"模型多久被告知一次这类环境变化。关闭 = 完全静默(不出卡、不注入模型)。","settings.env.pinned.desc":"为保持请求前缀稳定钉死「每 run」,不允许「每请求」。关闭可静默(模型将不再收到此类变化)。","settings.env.files.desc":"订阅文件变更多久报告一次。旁路写(bash / 构建 / git)不可归因到编辑者,仍会通知。","settings.env.channel.desc":"投递通道。「模型 + UI」注入模型上下文并出卡;「仅 UI」只出卡,模型不注入。","settings.env.channel.modelUi":"模型 + UI","settings.env.channel.uiOnly":"仅 UI","settings.item.tools.title":"工具卡片","settings.item.tools.desc":"显示工具调用卡片;关闭后只保留一行「正在运行」状态,失败的工具卡始终显示(失败永不静默)。","settings.item.environment.title":"环境信息","settings.item.environment.desc":"环境信息卡:配置热应用、权限、工具、MCP、更新、peer 通知等模型上下文提示(vessel:notice)。","settings.item.source.title":"来源卡片","settings.item.source.desc":"投射来源卡(principal / node / team);被 agent 卡吸收的来源行不受此开关影响。","settings.item.system.title":"系统信息","settings.item.system.desc":"内部事件与系统上下文消息(运行提示、hook / LLM 上下文等 vessel:* 消息);verbosity=debug 也会显示。未配置时沿用旧键 ui.showInternalEvents 的值。","settings.item.showArchived.title":"显示已归档 / 已停用(待移除)","settings.item.showArchived.desc":"默认隐藏已归档 Team 与已停用 agent(它们都在等待被清理);打开后它们回到 Team 列表、Agent 列表与成员侧栏,并带「已归档 · 待移除 / 已停用 · 待移除」标记。直接链接不受此开关影响,始终可打开。","settings.item.showRetiredSessions.title":"显示退休会话","settings.item.showRetiredSessions.desc":"默认不在会话卡片列表显示退休会话(rotate 之前的旧身体,子标题灰色);打开后它们回到列表,样式不变。隐藏不是删除:搜索与直接链接始终可打开。","settings.item.errorLevel.title":"错误层级","settings.item.showProcessErrors.title":"显示 process 错误","settings.item.askUser.title":"允许 ask","settings.item.askUser.desc":"注册类设置:保存后需新连接或重启 gateway 才生效。","settings.item.showReasoning.title":"思考过程","settings.item.showReasoning.desc":"显示模型的思考过程(实时流与历史);默认关闭(显式开启),打开后即时生效无需重启。输出详略 minimal 档仍会隐藏思考。","settings.item.expandCards.title":"卡片默认展开","settings.item.expandCards.desc":"工具 / 系统消息 / 排队卡片默认展开;权限与提问卡片始终展开。某张卡片手动开合后以手动状态为准。","settings.item.addressStyle.title":"地址显示格式","settings.item.addressStyle.desc":"来源行 / 路由副行里地址的显示档位:name = 各段能用名就用名(main@soulkiller:vessel);compact = 节点用短 id;full = 完整 uuid。只影响显示,发送路由始终用完整地址。","settings.item.statusBars.title":"状态栏位置","settings.item.language.title":"界面语言","settings.item.logLevel.title":"日志级别","settings.item.logColor.title":"日志颜色","settings.item.logFormat.title":"日志格式","settings.item.logTime.title":"日志时间","settings.item.emptyResponseEnabled.title":"空响应兜底","settings.item.emptyResponseEnabled.desc":"模型返回空回复(无内容、无工具调用)时重试而不是零输出早退(缺省无感重调,见下)。","settings.item.emptyResponseSeamless.title":"无感重试(不留疤)","settings.item.emptyResponseSeamless.desc":"开:丢弃空轮,用已有 transcript 原样重调模型——不注入新消息、零疤痕;重试耗尽仍空才注入一次 nudge 兜底。关:直接注入 nudge。","settings.item.emptyResponseMaxRetries.title":"空响应重试上限","settings.item.emptyResponseMaxRetries.desc":"每次 run 的重试上限(0–10 整数),无感重调与 nudge 共用。耗尽后优雅终止并落日志注记。","settings.item.emptyResponseNudge.title":"空响应提示文案","settings.item.emptyResponseNudge.desc":"自定义 nudge(以 user 消息注入)。不设置则用内置文案。","settings.group.depthColor":"深度配色","settings.item.depthColorEnabled.title":"按树深度着色","settings.item.depthColorEnabled.desc":"会话卡地址子标题(name@node:team)按 agent 树深度轮转色相(根=0,每层+1);关闭后全部回主题强调色。退役身体 / primary 徽标保持灰档(状态语义优先)。","settings.item.depthColorRootHue.title":"根色相","settings.item.depthColorRootHue.desc":"根(深度 0)地址的色相,度 [0, 360)。默认 172.6 = 现品牌强调色色相(亮色档零回归)。","settings.item.depthColorHueStep.title":"每层色相步进","settings.item.depthColorHueStep.desc":"每深一层色相增量,度 [0, 360]。默认 137.508 ≈ 黄金角(360/φ²):无理旋转永不精确重复,无限轮转不饱和;0/360 = 不轮转(单色)。","settings.item.depthColorLightnessLight.title":"亮色亮度(OKLCH L)","settings.item.depthColorLightnessLight.desc":"亮色档感知亮度 [0.30, 0.51];上界由 WCAG 对比度实证锁定(全色相 ≥4.5:1)。默认 0.4714 = 现强调色精确 L。","settings.item.depthColorChromaLight.title":"亮色色度(OKLCH C)","settings.item.depthColorChromaLight.desc":"亮色档色度 [0, 0.37];超 gamut 部分浏览器自动降色度(保亮度/色相)。默认 0.0887 = 现强调色精确 C。","settings.item.depthColorLightnessDark.title":"暗色亮度(OKLCH L)","settings.item.depthColorLightnessDark.desc":"暗色档感知亮度 [0.73, 0.95];下界由全色度值域 WCAG 对比度实证锁定(≥4.5:1)。默认 0.85(区分度优先)。","settings.item.depthColorChromaDark.title":"暗色色度(OKLCH C)","settings.item.depthColorChromaDark.desc":"暗色档色度 [0, 0.37];默认 0.13。色度越高轮转色越鲜艳,超 gamut 色相自动降色度。","settings.item.teamMemberLimit.title":"Team 成员上限","settings.item.teamMemberLimit.desc":"单个 Team 内 present 成员(peer + contractor,含已关闭未离册)的数量上限;正整数 ≥1,缺省 100。超限 spawn 报 team_full。修改后需重启节点生效。","settings.item.imageTokenBudgetRatio.title":"图片 token 预算比例","settings.item.imageTokenBudgetRatio.desc":"内联图片占上下文窗口的 token 预算比例(0–1,缺省 0.05)。张数上限 = 预算 ÷ 单图 token,再夹后端安全上限(32)。窗口越大允许图越多;预算溢出丢最新图并向模型注记。修改后需重启节点生效。","settings.item.toolResultWhitelist.title":"工具结果压缩白名单","settings.item.toolResultWhitelist.desc":"命中规则({tool, action?})的工具结果在请求视图中保持原文,不被换成占位符(抗 trim);段边界 compaction 仍照常摘要收尾。缺省 = 内置默认(inbox read + agent read);显式 [] = 关闭;显式列表整体替换默认。一期仅 YAML 编辑(context.tool_result_whitelist),此处只读展示。修改后需重启节点生效。","settings.dialog.searchPlaceholder":"搜索设置…(@modified / @plugin:<id> / @local / @user)","settings.dialog.tabUser":"用户","settings.dialog.tabProject":"工作区","settings.dialog.tabLocal":"浏览器","settings.dialog.filterModified":"已修改 (@modified)","settings.dialog.filterPlugin":"插件域 (@plugin:<id>)","settings.dialog.filterScope":"层级 (@local / @user / @project)","settings.dialog.clearFilters":"清除筛选","settings.dialog.noMatches":"没有匹配的设置","settings.dialog.resetDefault":"恢复默认","settings.dialog.resetDone":"已恢复默认:{key}","settings.dialog.saved":"已保存:{key}","settings.dialog.saveFailed":"保存失败:{detail}","settings.dialog.saveUnconfirmed":"已写入但未确认:{key}","settings.dialog.writeUnavailable":"当前 gateway 无设置写面,只读","settings.dialog.configUnavailable":"该 gateway 没有注入 config 控制面。","settings.dialog.scopeUser":"用户","settings.dialog.scopeProject":"工作区","settings.dialog.scopeLocal":"本地","settings.dialog.modified":"已修改","settings.dialog.readOnly":"只读","settings.dialog.envOverride":"被环境变量 {env} 覆盖","settings.dialog.restartRequired":"重载插件后生效","settings.dialog.reloadPlugin":"重载","settings.dialog.copyKey":"复制键路径","settings.dialog.loading":"加载设置…","settings.dialog.openGateway":"打开 Gateway 页","settings.dialog.openDesignLab":"展开设计实验室","settings.dialog.fullscreen":"全屏打开","settings.dialog.collapseTree":"折叠分类树","settings.dialog.expandTree":"展开分类树","settings.dialog.editInYaml":"在 vessel.yaml 中编辑","settings.dialog.expandAll":"全部展开","settings.dialog.pluginReloaded":"插件已重载","settings.connection.devProxyNotice":"开发代理鉴权已启用:连接同源 gateway(由 Vite 开发服务器转发),前端不保存 token。","settings.multinode.name":"名称","settings.multinode.namePlaceholder":"如 office-gw","settings.multinode.url":"Gateway URL","settings.multinode.urlPlaceholder":"https://gw.example.com:8642","settings.multinode.token":"Token","settings.multinode.tokenPlaceholder":"gateway / team token","settings.multinode.add":"添加节点","settings.multinode.added":"已添加节点 {name}","settings.multinode.storageHint":"名称、URL 与 token 只保存在 sessionStorage;token 添加后不回显。","settings.multinode.error.name_required":"请输入节点名称","settings.multinode.error.name_duplicate":"节点名称已存在","settings.multinode.error.url_invalid":"请输入有效的 gateway 地址","settings.multinode.error.token_required":"请输入 token","appearance.theme.title":"主题","appearance.theme.desc":"默认深色;选择跟随系统会使用 prefers-color-scheme,选择会保留到刷新后。","appearance.theme.system":"跟随系统","appearance.theme.light":"浅色","appearance.theme.dark":"深色","appearance.motion.title":"动效","appearance.motion.desc":"动效跟随系统的 prefers-reduced-motion,不提供单独开关。减少动效时抽屉、命令面板与状态脉冲都会关闭。","appearance.language.zh":"简体中文","appearance.language.en":"English","language.toggleTo":"切换界面语言为 {language}","language.short.zh":"中文","language.short.en":"EN","common.cancel":"取消","common.close":"关闭","common.expand":"展开","common.collapse":"折叠","common.confirm":"确认","common.loading":"正在加载…","common.processing":"处理中…","common.retry":"重试","common.refresh":"刷新","common.loadFailed":"加载失败","permission.busy":"提交中…","permission.expired":"请求已过期,已从待处理列表移除。","permission.allowOnce":"本次允许","permission.allowSession":"本会话允许","permission.always":"始终允许","permission.deny":"拒绝","permission.inline.waiting":"等待确认","permission.expand":"展开完整参数","permission.collapse":"收起到 12 行","permission.truncated":"参数已截断(上限 20,000 字符)","permission.runEnded":"run 已结束,该权限请求已失效。","permission.goTo":"前往处理","pending.bar.summary":"其他会话有 {count} 个待处理请求","pending.bar.unresolved":"无法定位所属会话","pending.bar.goPending":"去待批页","chat.prompt.label":"对话输入槽位","chat.composer.input":"输入 prompt","chat.prompt.permission":"权限请求","chat.prompt.question":"需要你回答","chat.prompt.blocking":"对话已暂停,处理完继续","chat.prompt.more":"还有 {count} 个待处理","chat.prompt.disconnected":"连接断开,恢复后可继续处理","chat.restoringSession":"正在恢复上次会话…","chat.welcome.brand":"Vessel","chat.welcome.question":"今天想干啥?","chat.draft.title":"新会话","chat.draft.meta":"发送第一条消息后创建会话","chat.draft.pickSession":"从左侧选择会话,或新建一个","pending.queue.permission":"权限 · {tool}","pending.queue.ask":"提问 · 第 {index} 题","chat.session.running":"运行中","chat.session.queued":"排队中","chat.session.pending":"有 {count} 个待处理请求","chat.session.copyId":"复制会话 ID","chat.session.copiedId":"已复制会话 ID","chat.session.copyIdTitle":"复制会话 ID:{title}","chat.memberModel.button":"模型","chat.memberModel.tooltip":"切换成员模型(下一具 body 生效)","chat.memberModel.title":"切换模型 · {name}","chat.memberModel.currentPin":"当前固定(pin):{model}","chat.memberModel.currentBody":"本具 body 当前使用:{model}","chat.memberModel.currentUnknown":"本具 body 当前模型未知(尚未跑过 run 或旧 gateway)。","chat.memberModel.hint":"选择注册模型 = 为该成员固定(pin):活体 body 与当前 run 不变,下一具 body / 续接 run 生效,届时会话会追加一条环境信息卡。留空 = 不修改。","chat.memberModel.saved":"已更新 {name} 的模型,下一具 body / 续接 run 生效","chat.memberModel.failed":"模型切换失败","chat.memberModel.draftTooltip":"为新会话选择模型(创建时固定)","chat.memberModel.draftTitle":"新会话模型","chat.memberModel.draftHint":"选择注册模型 = 创建新会话时为该 agent 固定(pin);留空 = 跟随节点默认。选择先存草稿,首次发送时随创建落盘。","chat.thinking.label":"思考:","chat.thinking.draftHint":"创建后可设","time.today":"今天","time.yesterday":"昨天","time.justNow":"刚刚","time.minutesAgo":"{count} 分钟前","time.hoursAgo":"{count} 小时前","time.hoursMinutesAgo":"{count} 小时 {minutes} 分钟前","time.daysAgo":"{count} 天前","chat.context.tokens":"{used} tokens","chat.context.percentOf":"{percent}% / {used}","resize.nav":"调整导航宽度","resize.sessions":"调整会话列表宽度","resize.chat":"调整内容宽度","resize.teams":"调整团队列表宽度","chat.reasoning.summary":"思考过程","chat.run.cancelling":"取消中…","chat.run.cancelQueue":"取消排队","chat.run.queuedPosition":"排队中 · 第 {position} 位","chat.run.stop":"停止","chat.run.stopping":"停止中…","chat.run.detail":"查看运行详情","chat.run.noError":"(无错误详情)","chat.run.retryable":"可重试","chat.run.hiddenEarlier":"已显示最近 {shown} 个运行;更早的 {hidden} 个请在运行详情中查看。","chat.run.failed":"运行失败","chat.run.reason.lease":"会话租约丢失(通常是机器休眠 / 另一实例接管),本轮已中断","chat.run.reason.locked":"会话被另一实例占用,本轮已中断","chat.run.reason.rateLimited":"模型侧限流或额度不足,本轮已中断","chat.run.reason.contextTooLong":"上下文超出模型窗口,本轮已中断","chat.run.failure.aria":"运行失败详情","chat.run.failure.run":"运行 {id}","chat.run.failure.fromRecord":"来自会话记录:该轮的实时事件已不在缓冲区,这里只保留错误摘要。","chat.reasoning.thinking":"正在思考","chat.reasoning.expand":"展开全文","chat.reasoning.collapse":"收起","chat.reasoning.copy":"复制思考","chat.reasoning.copyBody":"复制正文","chat.reasoning.copied":"已复制思考","chat.tool.input":"输入","chat.tool.output":"输出","chat.tool.diff":"变更","chat.tool.error":"错误","chat.tool.copy":"复制","chat.tool.meta":"元数据","chat.tool.retryable":"可重试","chat.tool.truncated":"输出已截断","chat.tool.route":"路由","chat.tool.resolvedTo":"实际投递给 {target}","chat.projection.badge.placeholder":"模型看到:占位","chat.projection.badge.placeholderHint":"这条工具结果已被替换成占位符([cleared …]):模型看到的是占位那一段,原文仍在本卡里。","chat.projection.badge.externalize":"模型看到:句柄","chat.projection.badge.externalizeHint":"这条工具结果已被替换成句柄引用:模型看到的是句柄,正文要靠读回取。","chat.projection.badge.reason.readback":"原文已不在消息里,只在事件日志里。","chat.projection.badge.reason.gone":"原文已不可恢复。","chat.projection.tabsLabel":"投影视角","chat.projection.tab.original":"原文视角","chat.projection.tab.model":"模型视角","chat.projection.original":"原文","chat.projection.modelView":"模型视角","chat.projection.copyOriginal":"复制原文","chat.projection.copyModel":"复制模型看到的文本","chat.projection.readbackTail":"取回被截掉的尾巴","chat.projection.readbackFromLog":"取回占位之前的原文","chat.projection.readbackUnsupported":"这类原文的读回还没接上。","chat.projection.notInMessage":"原文不在消息里(只剩占位)。","chat.projection.gone":"原文已不可恢复。","chat.projection.truncatedWarn":"已截到前 {limit},共 {bytes} B。","chat.projection.truncatedWarnUnknown":"已截到前 {limit},原文体量未知。","chat.projection.meta.tool":"工具","chat.projection.meta.bytes":"原文","chat.projection.meta.sinceSeq":"发生 seq","chat.projection.meta.unknown":"未知","chat.projection.bytes":"{bytes} B","chat.projection.summary.total":"本会话累计:{total} 条被投影 · 省 {saved} B","chat.projection.summary.lowerBound":"(有 {count} 条原文体量未知,这是下界)","chat.tool.previewLines":"预览 {shown}/{total} 行","chat.tool.loadMore":"加载更多({loaded}/{total} KB)","chat.tool.showAll":"展开全部 {total} 行","chat.tool.description":"描述","chat.tool.descriptionUnavailable":"描述不可用","chat.tool.status.running":"运行中","chat.tool.status.history":"历史记录","chat.tool.outputMissing":"历史里没有这次调用的输出(可能已被截断)。","chat.tool.status.done":"完成","chat.tool.status.error":"失败","chat.tool.duration.millis":"{value} 毫秒","chat.tool.duration.minutes":"{minutes} 分 {seconds} 秒","ask.title":"Agent 提问","ask.asyncBadge":"异步投放(回答会起一次新 run)","ask.goTo":"前往回答","ask.pendingMore":"还有 {count} 个待处理","ask.progress":"第 {current} / {total} 题","ask.next":"下一题","ask.previous":"上一题","ask.answerRequired":"请先回答当前问题","ask.submit":"提交","ask.customPlaceholder.options":"或输入自定义回答","ask.customPlaceholder.open":"输入回答","pending.title":"消息","pending.subtitle":"权限审批、ask 提问与通知统一聚簇(同一个 Agent 聚在一起),按优先级排序:卡着 run 的审批/提问在前,通知在后。权限逐条裁决、提问每题独立作答、通知查看后确认已读。","pending.empty":"没有待处理的请求","pending.empty.hint":"Agent 一请求权限、提问或发通知,这里就会出现。","pending.kind.notify":"通知","pending.notice.empty":"没有未读通知","pending.notice.ack":"确认已读","pending.notice.ackAll":"全部标记已读","pending.notice.high":"重要","pending.notice.count":"{count} 条未读","pending.notice.refs":"附件","pending.fetch.failed":"待批列表拉取失败:{detail}","pending.fetch.failedHint":"这里的「空」不代表没有待批请求 —— 列表根本没拉到。重新登录 / 修好连接后会自动补回。","pending.fetch.blocked":"请求被 gateway 拒绝,待批列表拉不到:{detail}","pending.fetch.shortFailed":"待批列表拉不到","pending.fetch.shortBlocked":"待批列表拉不到(请求被拒)","pending.fetch.retry":"重新拉取","pending.entry":"待批","pending.entry.label":"本会话有 {count} 条待批请求","pending.cluster.agent":"Agent {id}","pending.cluster.session":"会话 {id}","pending.cluster.run":"Run {id}","pending.cluster.home":"归属 {id}","pending.cluster.count":"{count} 条待批","pending.cluster.expand":"展开详情","pending.cluster.collapse":"收起","pending.source.session":"会话","pending.source.team":"团队","pending.item.include":"回复这题","pending.item.answered":"已答","pending.answeredGroup.expand":"已答 {count} 题 · 展开","pending.answeredGroup.collapse":"已答 {count} 题 · 收起","pending.item.includeAll":"全选","pending.item.responding":"回复中…","pending.submit":"回复","pending.submit.busy":"回复中…","pending.submit.count":"已选 {count} 题","pending.submit.note":"只提交答了的题;没答的题继续留在待批,可以稍后再答。","pending.answerRequired":"勾了还没作答的题,回复时会被跳过","chat.subagents.title":"子 agent","chat.subagents.running":"{count} 运行中","chat.subagents.details":"详情","chat.subagents.view":"查看 transcript","chat.subagents.back":"返回主会话","chat.subagents.emptyRun":"尚未产生子运行事件","chat.subagents.crumb":"子 agent","chat.subagents.queuePosition":"队列 #{position}","chat.subagents.context":"上下文 {used}/{max}","plugins.page.loading":"正在加载插件页面…","plugins.page.notConnected":"未连接 gateway","plugins.page.notConnectedReason":"连接 gateway 后才能加载插件页面。","plugins.page.notFound":"插件页面不可用","plugins.page.notFoundReason":"插件未安装、已禁用,或未提供这个页面。","plugins.frame.loading":"正在加载插件界面…","plugins.frame.loadError":"插件界面加载失败","plugins.frame.invalidEntry":"插件页面入口非法","plugins.embed.loading":"正在加载插件组件…","plugins.embed.errorTitle":"插件组件渲染出错","plugins.embed.errorBody":"{plugin}:{error}","plugins.embed.useIsolated":"改用隔离模式","plugins.embed.incompatibleTitle":"插件版本不兼容","plugins.embed.incompatibleBody":"宿主运行时版本不满足插件声明:{detail}","plugins.embed.failedTitle":"插件组件加载失败","plugins.embed.failedBody":"无法加载内嵌组件:{detail}","plugins.panel.label":"{title}(插件 {plugin})","observe.title":"可观测","observe.description":"指标、评测、诊断与待处理。事件记录在运行详情中查看。","observe.tabsLabel":"可观测分区","observe.panelLabel":"可观测内容","observe.tab.metrics":"指标","observe.tab.evals":"评测","observe.tab.diagnostics":"诊断","observe.tab.attention":"待处理","breadcrumb.observe.diagnostics":"诊断","breadcrumb.observe.attention":"待处理","observe.attention.noToken":"未连接 gateway","observe.attention.noTokenReason":"连接后才能读取 pending / orphaned 交互。","observe.attention.forbidden":"当前 token 不能读取交互(401/403)","observe.attention.forbiddenReason":"需要 gateway token 或具备读权限的 team-scoped control token。","observe.attention.hint":"本节点跨 Team 的只读收件箱。应答请在请求所属会话卡片中完成;此页不会直接应答。","observe.attention.statusLabel":"交互状态","observe.attention.status.pending":"待处理","observe.attention.status.orphaned":"已失效","observe.attention.panelLabel":"待处理收件箱","observe.attention.total":"{count} 条","observe.attention.refresh":"刷新","observe.attention.refreshing":"正在刷新…","observe.attention.loading":"正在读取交互…","observe.attention.loadingMore":"加载中…","observe.attention.loadMore":"加载更多","observe.attention.stale":"更新失败;显示最近一次加载的页面。","observe.attention.empty.pending":"没有 pending 交互","observe.attention.empty.orphaned":"没有 orphaned 交互","observe.attention.emptyHint":"agent 等待人工决定时,请求会出现在这里。","observe.attention.col.kind":"类型","observe.attention.col.request":"请求","observe.attention.col.tool":"工具","observe.attention.col.agent":"Agent","observe.attention.col.team":"Team","observe.attention.col.time":"创建时间","observe.attention.nodesHint":"按节点只读聚合;某个节点失败只影响它自己的分组。","observe.attention.currentNode":"当前","observe.attention.remoteReadonly":"只读聚合;只有当前节点的会话可以打开。","observe.attention.remoteRowHint":"该请求属于其它节点;此处只读。","observe.diagnostics.noToken":"未连接 gateway","observe.diagnostics.noTokenReason":"连接后才能读取 runtime 与诊断事件。","observe.diagnostics.disconnected":"连接已断开;显示最近一次读取的快照。","observe.diagnostics.queueTitle":"运行队列","observe.diagnostics.errorsTitle":"诊断错误","observe.diagnostics.refresh":"刷新","observe.diagnostics.loading":"正在读取 runtime…","observe.diagnostics.queueEmpty":"队列为空","observe.diagnostics.empty":"没有匹配的诊断错误","observe.diagnostics.gateHint":"process / shutdown / hook / plugin 错误默认隐藏;需要 ui.errorLevel: all 或 observability.showProcessErrors: true。","observe.diagnostics.col.status":"状态","observe.diagnostics.col.session":"会话","observe.diagnostics.col.queuePosition":"队列位置","observe.diagnostics.col.waitReason":"等待原因","observe.diagnostics.noWaitReason":"—","observe.diagnostics.activeRun":"活动运行","observe.diagnostics.stats":"排队 {queued} · 运行 {running}","observe.diagnostics.retryable":"可重试","observe.diagnostics.fatal":"不可重试","observe.diagnostics.runtimeTitle":"运行时","observe.diagnostics.nodeStatus":"节点状态","observe.diagnostics.provider":"Provider","observe.diagnostics.model":"模型","observe.diagnostics.uptime":"运行时长","observe.diagnostics.clients":"客户端","observe.diagnostics.mcpTitle":"MCP 服务","observe.diagnostics.mcpNotEnabled":"MCP 未启用","observe.diagnostics.mcpNotEnabledReason":"该节点没有配置 MCP server。","observe.diagnostics.mcpEmpty":"没有 MCP 服务","observe.diagnostics.col.mcpServer":"服务","observe.diagnostics.col.mcpStatus":"状态","observe.diagnostics.col.mcpTools":"工具","observe.diagnostics.col.mcpError":"错误","observe.diagnostics.pluginsTitle":"插件","observe.diagnostics.pluginsCount":"已启用 {enabled}/{total}","observe.diagnostics.pluginsEmpty":"没有已启用的插件","observe.diagnostics.capabilitiesTitle":"能力","observe.diagnostics.version":"版本","observe.diagnostics.methods":"方法","observe.diagnostics.tools":"工具","observe.diagnostics.sourcesTitle":"配置来源","observe.diagnostics.userPath":"用户配置","observe.diagnostics.projectPath":"项目配置","observe.diagnostics.overlayKeys":"覆盖键","observe.diagnostics.notAvailable":"不可用","observe.diagnostics.doctorTitle":"自检","observe.diagnostics.doctorHint":"九类自检,数据来自现有 RPC。gateway 观察不到的项会标明原因,不猜。","observe.diagnostics.doctorColCheck":"检查","observe.diagnostics.doctorColStatus":"状态","observe.diagnostics.doctorColSource":"来源","observe.diagnostics.doctorColDetail":"详情","observe.diagnostics.doctor.status.ok":"ok","observe.diagnostics.doctor.status.warn":"warn","observe.diagnostics.doctor.status.fail":"fail","observe.diagnostics.doctor.status.info":"info","observe.diagnostics.doctor.status.unavailable":"unavailable","observe.diagnostics.doctor.pending":"等待数据","observe.diagnostics.doctor.set":"<set>","observe.diagnostics.doctor.unset":"<unset>","observe.diagnostics.doctor.config.detail":"user={user} · project={project}","observe.diagnostics.doctor.config.unverified":"gateway RPC 不下发配置校验错误/警告;在应用所在的机器上跑一次自检可看到","observe.diagnostics.doctor.provider.detail":"{provider} / {model} / api key {key}","observe.diagnostics.doctor.dataDir.configured":"{path}(来源:{source})","observe.diagnostics.doctor.dataDir.gatewayDecided":"由网关决定(未下发;远程或旧 gateway)","observe.diagnostics.doctor.session.relative":"相对网关数据目录","observe.diagnostics.doctor.dataDir.unverified":"目录可写性只能在本机自检中确认","observe.diagnostics.doctor.session.memory":"backend=memory(不持久化)","observe.diagnostics.doctor.session.detail":"backend={backend} · path={path}","observe.diagnostics.doctor.session.derived":"由数据目录推导,未在本机核对实际路径","observe.diagnostics.doctor.writability":"可写性未校验(需本机自检)","observe.diagnostics.doctor.plugins.ok":"已启用 {enabled} / 发现 {total}","observe.diagnostics.doctor.plugins.missing":"配置中启用但未发现:{names}","observe.diagnostics.doctor.mcp.invalid":"无效的 server 配置:{names}","observe.diagnostics.doctor.mcp.rpc":"RPC 返回 {servers} 个 server / 配置 {configured} 个","observe.diagnostics.doctor.mcp.disabled":"该 gateway 未启用 MCP","observe.diagnostics.doctor.mcp.unavailable":"MCP 状态不可用","observe.diagnostics.doctor.servePort.notConfigured":"node.port 未显式配置;doctor 会跳过该项","observe.diagnostics.doctor.servePort.systemPort":"{host}:0(系统分配)· endpoint {endpoint}","observe.diagnostics.doctor.servePort.detail":"{host}:{port} 已配置 · endpoint {endpoint}","observe.diagnostics.doctor.servePort.unverified":"端口可绑定性需本机自检;浏览器无法 bind","observe.diagnostics.doctor.attach.disconnected":"未连接 gateway","observe.diagnostics.doctor.feishu.disabled":"飞书未启用","observe.diagnostics.doctor.feishu.detail":"app id {appId},app secret {appSecret}","team.list.search":"搜索 Team","team.list.clearSearch":"清除搜索","team.chat.members":"成员","team.chat.empty":"还没有消息","team.chat.emptyHint":"用 @ 提及成员才会通知对应 agent。","team.chat.loadedEarlier":"已加载更早消息","team.chat.historyOutOfWindow":"更早的历史已超出本地保留窗口,保留已加载内容。","team.chat.historyChanged":"更早的团队历史已被改写,已重新加载最新一页。","team.chat.backToList":"返回 Team 列表","team.chat.loadMoreMembers":"加载更多成员","team.chat.membersCapped":"仅显示前 {shown} / {total} 成员","team.members.open":"查看成员列表","team.members.close":"收起成员列表","team.members.matches":"匹配 {matched} / 已加载 {total}","team.members.search":"按名字或角色搜索","team.members.empty":"没有匹配的成员","team.composer.input":"给 Team 发消息","team.composer.send":"发送","team.composer.sending":"发送中…","team.composer.hint":"Enter 发送 · Shift+Enter 换行","team.composer.noMention":"未 @ 成员 · 仅记录,不会通知任何 agent","team.composer.disconnected":"连接已断开,恢复后才能发送","team.composer.tooLarge":"消息超过 {limit} KiB 上限","team.mention.title":"@ 成员","team.mention.empty":"没有匹配的成员","team.mention.hint":"只从当前 Team 的 present 成员中选择","team.mention.remove":"移除 {name}","team.message.you":"我","team.message.agentTag":"agent","team.message.replyTag":"回复","team.message.toHumanTag":"给你","team.message.toHumanHint":"这条日志是 agent 发给人类的消息","team.message.systemTag":"系统","team.message.viewBody":"查看成员会话","team.message.edit":"编辑","team.message.editRecallFailed":"没能撤回成员收件箱里的那份,草稿未回填:{detail}","team.message.resend":"重发","team.message.delete":"删除","team.message.deleteTitle":"删除消息","team.message.deleteBody":"这条消息会从 Team 视图中隐藏,成员收件箱里的副本一并删除(已开始执行的除外);日志保留删除标记,后续回复不删除。此操作不可撤销。","team.message.deleteConfirm":"删除","team.message.deleteDone":"已删除","team.federation.from":"federation 来自","team.federation.reply":"按地址回复","team.federation.replyHint":'已复制 {addr}。Web 暂不直接发送 federation;请用 agent 工具 send,to="{addr}"。',"team.system.join":"{name} 加入了 Team","team.system.leave":"{name} 离开了 Team","team.system.archive":"Team 已归档","team.system.create":"{name} 创建了新会话","team.system.fork":"agent 已 fork(旧记录)","team.system.retract":"{name} 删除了一条消息","team.system.unknown":"Team 系统事件","team.delivery.queued":"排队中","team.delivery.queuedRotating":"等待新会话","team.delivery.queuedCreated":"已创建并排队","team.delivery.queuedForked":"已 fork 并排队(旧记录)","team.delivery.rejected":"已拒绝","team.delivery.error":"投递失败","team.delivery.retry":"再次发送","team.delivery.retryHint":"将写入一条新记录","team.delivery.failed":"发送失败","team.state.idle":"空闲","team.state.running":"正在工作","team.state.waitingPermission":"等批准","team.state.completed":"已完成","team.state.failed":"失败","team.state.cancelled":"已取消","team.state.closed":"已停用","team.state.unknown":"未知","team.presence.live":"在线","team.presence.gone":"离线","team.membership.present":"在队","team.membership.left":"已移出","team.attention.pending":"待处理","team.attention.count":"{count} 个待处理","team.pending.title":"待确认({count})","team.pending.hint":"来自本 Team 成员的会话","team.pending.permission":"权限","team.pending.ask":"提问","team.member.title":"成员","team.member.currentBody":"当前会话","team.member.liveBodies":"活动会话({count})","team.member.primaryBadge":"primary","team.member.openBody":"打开该会话","team.member.retiredBodies":"历史会话","team.member.subs.tabLabel":"成员详情视图","team.member.subs.tab.overview":"概览","team.member.subs.tab.subscriptions":"订阅","team.member.subs.title":"显式订阅","team.member.subs.empty":"暂无显式订阅;可在下方增订,或用 subscribe 工具订阅。","team.member.subs.implicitTitle":"隐式源(默认开)","team.member.subs.muted":"已静音","team.member.subs.on":"开","team.member.subs.mute":"静音","team.member.subs.unmute":"恢复","team.member.subs.friend":"好友({origin})","team.member.subs.origin":"来源 {origin}","team.member.subs.remove":"删除","team.member.subs.removeTitle":"删除订阅","team.member.subs.removeBody":"删除后该目标的变更不再通知此成员。","team.member.subs.removeFriendHint":"带好友边的条目删除=静音保留(取关≠删好友)。","team.member.subs.removeSuccess":"订阅已删除","team.member.subs.removeMuted":"已静音(好友边保留)","team.member.subs.addTitle":"增订","team.member.subs.addSource":"源","team.member.subs.addTarget":"目标","team.member.subs.addPlaceholder":"文件路径 / node / 脚本名 / 成员 / team","team.member.subs.add":"订阅","team.member.subs.addSuccess":"已订阅 {target}","team.member.subs.poolTitle":"可订阅信息池","team.member.subs.pool.implicitHint":"inbox / bash-job / bus 默认开,静音在上方隐式源区管理。","team.member.subs.pool.scripts":"脚本(用户配置声明)","team.member.subs.pool.nodes":"节点","team.member.subs.pool.agents":"成员","team.member.subs.pool.teams":"Team 日志","team.member.subs.pool.file":"文件允许根","team.member.subs.schedule.run":"每 run","team.member.subs.schedule.request":"每请求","team.member.subs.schedule.interval":"每 {seconds}s","team.member.subs.truncated":"目录超出上限,已截断。","team.member.subs.degraded":"当前节点不支持目录投影(旧 gateway);仍可自由输入目标增订。","team.member.subs.error":"订阅操作失败","team.member.sessionNumber":"会话序号","team.member.sessionIndex":"第 {n} 次会话","team.member.startedAt":"开始 {time}","team.member.retiredAt":"退役 {time}","team.member.observedAt":"观察到 {time}","team.member.empty":"没有历史会话","team.member.viewTranscript":"查看只读 transcript","team.member.observedOnly":"本次页面观察到的历史;刷新后仅显示当前会话。","team.member.currentSession":"查看当前会话","team.member.rotate.open":"新会话","team.member.rotate.title":"新建会话","team.member.rotate.description":"为 {name} 新建一个空 session 并设为 primary;原 session 退役但保留,历史不会被删除。","team.member.rotate.startupLabel":"启动提示(新 session 的第一条消息)","team.member.rotate.confirm":"新建会话","team.member.rotate.success":"已为 {name} 新建 session;原 session 保留为只读。","team.member.rotate.defaultPrompt":"你是 {name}。继续之前的职责,接着当前任务。","team.member.rotate.error.notFound":"找不到该成员;请刷新后重试。","team.member.rotate.error.conflict":"该成员当前不可新建会话(运行中 / 已关闭 / Team 限制)。","team.member.rotate.error.invalid":"新建会话参数无效;请刷新后重试。","team.member.rotate.error.quota":"会话配额已用尽,无法新建。","team.role.member":"成员","team.role.temporary":"临时","team.role.label":"角色","team.role.convert":"转换角色","team.role.toMember":"转为成员","team.role.toTemporary":"转为临时","team.role.memberTeam":"团队","team.role.memberRequiresTeam":"转为成员必须选择团队。","team.role.forbidden":"当前凭据无权转换该成员。","team.role.failed":"转换失败","team.role.success":"已将 {name} 转为 {role}","team.role.busy":"正在转换…","team.error.notFound":"Team 不存在","team.error.notEnabled":"Team 未启用","team.error.notEnabledReason":"该 gateway 没有提供 teams.* 接口。","team.error.notEnabledHint":"升级 gateway 或切换到启用了 Team 的节点。","team.error.noToken":"未连接 gateway","team.error.noTokenReason":"连接后才能读取 Team。","team.error.stale":"刷新失败;显示最近一次读取的数据。","team.error.loadFailed":"Team 加载失败","team.a11y.memberList":"成员列表","team.a11y.mentionList":"提及成员建议","team.a11y.deliveryQueued":"投递排队中","team.a11y.closeMembers":"关闭成员列表","nav.domain.hub":"枢纽","nav.domain.gateway":"网关","nav.domain.pluginHost":"插件宿主","nav.domain.nodes":"节点","nav.domain.teams":"团队","nav.domain.kanban":"看板","nav.domain.agents":"智能体","nav.group.network":"智能体编排","breadcrumb.hub":"面板核心","breadcrumb.gateway":"网关","breadcrumb.pluginHost":"插件宿主","breadcrumb.nodes":"节点","breadcrumb.teams":"团队","breadcrumb.teams.agent":"成员","breadcrumb.agents":"智能体","common.edit":"编辑","common.archive":"归档","common.remove":"移除","common.copy":"复制","common.copied":"已复制","hub.title":"Hub","hub.subtitle":"浏览器直连 Hub 的目录与状态;节点配对与 token 管理仍在 Nodes / CLI。","hub.connect.title":"连接 Hub","hub.connect.description":"填写 Hub 服务地址与 read token;token 只保存在当前浏览器标签页。","hub.connect.url":"Hub 地址","hub.connect.urlHint":"填写 Hub origin(例如 http://127.0.0.1:8643)。当前页面 origin 是 {origin},需加入 Hub 的 hub.allowedOrigins。","hub.connect.token":"Hub read token","hub.connect.tokenHint":"回环 Hub 可留空,远程 Hub 必填;已保存的 token 不会再次显示。","hub.connect.tokenPlaceholder":"Hub read token","hub.connect.submit":"连接","hub.connect.connecting":"检查中…","hub.connect.clear":"清除连接","hub.connect.error.invalid":"请输入有效的 http(s) Hub 地址,不能带 path、query 或 credentials。","hub.connect.error.mixed":"当前页面使用 HTTPS,Hub 地址必须使用 https。","hub.connect.error.origin":"无法连接 Hub。请检查地址,并确认 Hub 的 hub.allowedOrigins 包含 {origin}。","hub.connect.error.http":"Hub 拒绝了连接,请检查地址与 token。","hub.directory.loading":"正在加载 Hub 目录…","hub.directory.title":"目录","hub.directory.description":"Hub {hub}({url});只展示元数据,Hub 不代理正文。","hub.directory.empty":"这个 Hub 目录还没有节点","hub.directory.emptyHint":"这个节点还没加入任何 Hub;加入后目录会出现在这里。","hub.directory.connecting":"正在连接 Hub 以获取实时更新…","hub.directory.reconnecting":"Hub 连接已断开,正在重连…","hub.directory.pointer":"节点 {node} 有更新。","hub.directory.col.name":"节点","hub.directory.col.status":"状态","hub.directory.col.teams":"团队","hub.directory.col.agents":"Agent","hub.directory.col.liveAgents":"在线 Agent","hub.directory.col.lastSeen":"最后可见","hub.directory.col.dataPlane":"数据面","hub.directory.dataPlane.direct":"直连","hub.directory.dataPlane.unreachable":"仅控制面","hub.node.status.connecting":"连接中","hub.node.status.healthy":"健康","hub.node.status.unreachable":"不可达","hub.node.status.incompatible":"不兼容","hub.node.status.unauthorized":"未授权","hub.node.status.identityMismatch":"身份不匹配","hub.error.unauthorized":"Hub token 被拒绝","hub.error.unauthorizedReason":"已保存的 Hub read token 无效或已过期,请重新输入。","hub.error.incompatible":"Hub 协议不兼容","hub.error.incompatibleReason":"本页面使用 vessel.hub/2,请升级 Hub 或 Platform。","hub.error.origin":"无法访问该地址的 Hub。请确认地址,并确保 Hub 的 hub.allowedOrigins 包含 {origin}。","gateway.title":"网关","gateway.field.status":"状态","gateway.field.connection":"连接","gateway.field.endpoint":"endpoint","gateway.field.node":"节点","gateway.field.version":"版本","gateway.field.startedAt":"启动时间","gateway.field.uptime":"运行时长","gateway.diagnosticsHint":"运行队列与诊断事件。","gateway.state.ok":"正常","gateway.state.error":"错误","gateway.state.connecting":"读取中…","gateway.noToken":"未连接 gateway","gateway.noTokenReason":"连接后才能读取 gateway 状态。","duration.seconds":"{seconds} 秒","duration.minutes":"{minutes} 分钟","duration.hours":"{hours} 小时","duration.hoursMinutes":"{hours} 小时 {minutes} 分钟","duration.daysHours":"{days} 天 {hours} 小时","nodes.title":"节点","nodes.empty":"没有可用节点","nodes.notFound":"节点不在本页的节点列表中","nodes.notFoundHint":"可能已被移除;回到节点列表重新选择。","nodes.back":"所有节点","nodes.section.health":"健康","nodes.section.dataPlane":"数据面","nodes.field.nodeId":"node_id","nodes.field.pid":"PID","nodes.field.startedAt":"启动时间","nodes.field.endpoint":"endpoint","nodes.field.protocol":"协议","nodes.field.incarnation":"incarnation","nodes.field.teams":"teams","nodes.field.agents":"agents","nodes.field.online":"online","nodes.field.role":"角色","nodes.health.ok":"可达","nodes.health.error":"不可达","nodes.health.loading":"读取中…","nodes.health.unknown":"未知","nodes.select":"连接到此节点","nodes.platform.empty":"此 Gateway 还没有注册节点","nodes.selection.fallback.missing":"上次选中的节点已不在 Gateway registry 中,已连接到 {node}。","nodes.selection.fallback.down":"上次选中的节点已离线,已连接到 {node}。","nodes.dataPlane.direct":"direct(health.get 可达)","nodes.dataPlane.unreachable":"unreachable(health.get 失败)","nodes.teams.create":"创建团队","nodes.teams.archived":"已归档","nodes.teams.archiveTitle":"归档 Team?","nodes.teams.archiveBody":"归档后 Team 只读(不能 post / dispatch / 加成员),日志与历史保留。有 present 成员时会被拒绝。","team.form.createTitle":"创建团队","team.form.editTitle":"编辑团队","team.form.workspace":"Workspace","team.form.workspaceHint":"必填;归一化为绝对路径。创建后不可改。","team.form.name":"名称","team.form.status":"冻结状态","team.form.statusHint":"切换入口在卡片菜单的「冻结创建成员」,这里只读。","team.form.statusFrozen":"已冻结(不再新建成员)","team.form.statusActive":"正常","team.form.description":"描述","team.form.required":"必填","team.form.submitCreate":"创建","team.form.submitEdit":"保存","team.form.createFailed":"创建失败","team.form.updateFailed":"更新失败","team.form.forbidden":"当前 token 没有创建 / 更新 Team 的权限。","team.form.archivedReadonly":"已归档 Team 只读。","archive.hidden.teams":"默认隐藏了 {count} 个已归档 Team:在 设置 → 显示与可见性 里打开 ui.showArchived 即可显示。","archive.empty.teams":"这里的 Team 都已归档(默认隐藏)","archive.empty.agents":"这里的 Agent 都已停用(默认隐藏)","archive.empty.members":"这里的成员都已停用(默认隐藏)","archive.hidden.agents":"默认隐藏了 {count} 个已停用 agent:在 设置 → 显示与可见性 里打开 ui.showArchived 即可显示。","archive.hidden.members":"默认隐藏了 {count} 个已停用成员:在 设置 → 显示与可见性 里打开 ui.showArchived 即可显示。","archive.notice.team":"这个 Team 已归档 · 等待被移除:日志只读、默认列表里不再显示;直接链接仍可随时打开,直到它被清理。","archive.notice.agent":"这个 agent 已停用 · 等待被移除:默认列表里不再显示;直接链接仍可随时打开,直到它被清理。","archive.session.agentClosedHint":"所属 agent 已停用 · 等待被移除;会话保留,历史仍可查看。","kanban.subtitle":"红蓝开发任务看板(docs/dev/kanban/board.json)。只读展示;勾选卡片验收后移入 archive.json 归档。","kanban.noTokenReason":"连接网关后才能读取看板。","kanban.notFound":"看板文件不存在","kanban.refresh":"刷新","kanban.updated":"更新于 {time}","kanban.taskCount":"{count} 项任务","kanban.warnings":"板文件有 {count} 条降级警告(坏任务已跳过,不影响其余展示)","kanban.empty":"板上暂无任务","kanban.emptyHint":"看板由 main 维护;新任务派单后会出现在这里。","kanban.emptyColumn":"空","kanban.uncategorized":"未分类","kanban.accept":"验收归档","kanban.acceptAria":"验收任务:{title}","kanban.expandProgress":"展开进展","kanban.collapseProgress":"收起进展","kanban.confirmTitle":"归档任务?","kanban.confirmBody":"「{title}」将从看板移除,并追加到同目录 archive.json(append-only,历史可查)。归档由你的验收勾选触发,不会自动发生。","kanban.confirmAction":"验收并归档","kanban.archived":"已归档:{title}","kanban.archiveFailed":"归档失败:{message}","inbox.asyncJob.running":"运行中","inbox.asyncJob.done":"已完成","inbox.asyncJob.failed":"失败","inbox.asyncJob.input":"输入","inbox.asyncJob.output":"输出","teams.title":"团队","teams.empty":"还没有 Team","teams.filter.node":"节点","teams.filter.all":"全部节点","teams.card.archived":"已归档 · 待移除","teams.card.copyId":"复制团队 ID","teams.card.members":"{members} 成员","teams.card.online":"{online} 在线","teams.card.running":"有成员在跑","teams.card.open":"打开群聊","teams.detail.emptyTitle":"先打开一个 Team","teams.detail.emptyDesc":"从团队列表选择一个 Team,进入群聊与成员详情。","teams.openList":"打开团队列表","teams.partialError":"部分节点的 Team 读取失败","teams.error.forbidden":"当前 token 无权读取该节点的 Team","teams.error.notEnabled":"该节点没有提供 teams.*","teams.chat.archived":"已归档 · 待移除","teams.freeze":"冻结创建成员","teams.unfreeze":"解冻创建成员","teams.frozen":"已冻结","teams.unfrozen":"已解冻","teams.nodeMissing":"路由中的节点不在本页节点列表中","agents.title":"智能体","agents.staleNode":"显示上次成功的数据","agents.empty":"还没有 Agent","agents.filter.node":"节点","agents.filter.team":"团队","agents.filter.state":"状态","agents.filter.presence":"在线状态","agents.filter.clear":"清除过滤","agents.count":"显示 {shown} / {total}","agents.card.closed":"已停用 · 待移除","agents.presence.live":"在线","agents.presence.gone":"离线","agents.partialErrors":"{count} 个 Team 详情读取失败","agents.loadingRosters":"正在聚合节点 roster…","breadcrumb.team.member":"成员","hub.add.title":"添加节点","hub.add.description":"在另一台机器上执行以下命令完成配对或加入;Web 不代管 hub token。","hub.nodes.heartbeat":"心跳 {time}","hub.remove.title":"移除节点?","hub.remove.body":"仅从当前浏览器的连接列表移除,并清除该节点的 token;不会停止节点本身。","nodes.search":"搜索节点","nodes.add.commands":"配对 / 加入","nodes.add.connect":"从浏览器连接","nodes.emptyFiltered":"没有匹配“{query}”的节点","nodes.lastHeartbeat":"最近心跳","nodes.advanced":"高级信息","nodes.viewTeams":"查看团队","nodes.viewAgents":"查看智能体","teams.form.policy":"策略","teams.form.policyHint":"可选;留空字段不写入。保存时保留现有 policy 的未知键。","team.form.policyPermission":"权限","team.form.policyUnattended":"无人值守","team.form.policyUnset":"未设置","team.form.policyHold":"hold(挂起等待)","team.form.policyDenyAfter":"deny-after(超时拒绝)","team.form.policyDenyAfterSeconds":"超时拒绝(秒)","team.form.policyErrorDenyAfterRequired":"选择 deny-after 时必填","team.form.policyErrorDenyAfterRange":"必须是 1–86400 的整数","team.form.policyBudget":"预算","team.form.policyMaxHops":"最大跳数","team.form.policyMaxTurns":"最大轮数","team.form.policyMaxTokens":"最大 tokens","team.form.policyMaxWallClockSeconds":"最大墙钟时间(秒)","team.form.policyWarningThreshold":"预警阈值","team.form.policyWarningThresholdHint":"0 与 1 之间(不含);留空 = 默认 0.8。","team.form.policyErrorThreshold":"必须是 0 与 1 之间的小数(不含)","team.form.policyErrorIntegerMin":"必须是 >= {min} 的整数","team.form.policyCycle":"环检测","team.form.policyCycleMaxRepeats":"最大重复次数","team.form.policyCycleCooldownSeconds":"冷却(秒)","team.form.policyFederation":"联邦","team.form.policyFederationAccept":"接收方式","team.form.policyAcceptPrincipal":"principal(单成员投递)","team.form.policyAcceptLog":"log(仅写日志)","team.form.policyAllowAutoCreate":"允许自动创建","team.form.policyAllowAutoCreateHint":"勾选才写入;不勾选 = 不写(默认关闭)。","teams.edit.back":"返回团队","agents.search":"搜索智能体","agents.create":"创建智能体","agents.create.title":"创建智能体","agents.edit.title":"编辑智能体","agents.back":"返回智能体","agents.form.model":"模型","agents.form.modelHint":"下一具 body 才用新值(rotate 或重启后);当前 body 仍是旧值,只会收到一条环境信息告知。留空表示不修改。","agents.form.modelCreateHint":"留空 = 跟随节点默认模型;显式选择 = 为该成员固定模型,从第一具 body 起使用。","agents.form.systemPrompt":"系统提示词","agents.form.systemPromptHint":"下一具 body 才用新值(rotate 或重启后);当前 body 仍是旧值,只会收到一条环境信息告知。留空表示不修改。","agents.form.kind":"类型","agents.form.kindPeer":"成员(需要 Team)","agents.form.kindContractor":"临时(可不绑 Team)","agents.form.roleHint":"成员对应 role member;临时对应 role temporary。","agents.form.peerRequiresTeam":"成员必须绑定 Team;请选择 Team,或改为「临时」。","agents.form.unbound":"不绑定团队","agents.form.noChange":"请至少修改一个字段。","agents.form.created":"已创建智能体 {name}","agents.form.updated":"已更新智能体 {name}","agents.form.createFailed":"创建失败","agents.form.updateFailed":"更新失败","modelPicker.followDefault":"跟随默认","modelPicker.keepUnchanged":"不修改","modelPicker.emptyWithCurrent":"{label}(当前:{model})","modelPicker.unregistered":"未注册","modelPicker.groupAliases":"别名","modelPicker.groupEntries":"模型条目","modelPicker.unavailable":"模型注册表不可用(插件未加载或请求失败),暂无法选择。","agents.detail.title":"智能体","agents.detail.advanced":"高级信息","agents.detail.agentId":"智能体 ID","agents.detail.membership":"成员状态","agents.detail.visibility":"可见性","agents.detail.session":"会话","agents.close":"关闭智能体","agents.close.title":"关闭智能体?","agents.close.body":"智能体将被归档;历史与团队日志保留,Web 端无法撤销。","agents.close.success":"已关闭智能体 {name}","agents.close.failed":"关闭失败","agents.error.forbidden":"当前 token 无权创建 / 更新 / 关闭智能体。","agents.error.notFound":"智能体不存在","agents.error.candidates":"你是不是想选:{list}?","agents.error.nodeMissing":"链接中的节点不在本页节点列表中","common.configureConnection":"配置连接","common.clearSearch":"清除搜索","common.clearFilters":"清除过滤","common.writesDisabled":"连接断开,写操作已禁用","common.staleData":"更新失败,显示旧数据:{detail}","common.notConnected":"未连接 gateway","common.clipboardUnsupported":"当前环境不支持剪贴板","common.moreActions":"更多操作","common.rawData":"原始数据","common.closeNotice":"关闭提示","common.showMore":"显示更多(还有 {count} 条)","common.newSession":"新建会话","status.queued":"排队","status.running":"运行中","status.waiting":"等待确认","status.cancelling":"取消中","status.interrupted":"已中断","status.completed":"已完成","status.failed":"失败","status.cancelled":"已取消","status.skipped":"已跳过","status.pending":"待执行","status.connected":"已连接","status.disconnected":"未连接","status.unreachable":"不可达","status.disabled":"已停用","status.unavailable":"不可用","palette.group.navigation":"导航","palette.group.settings":"设置","palette.group.entity":"实体","palette.group.action":"动作","palette.group.help":"帮助","palette.label":"命令面板","palette.searchPlaceholder":"搜索导航、会话、运行或输入 > 执行动作","palette.searchLabel":"命令面板搜索","palette.resultsLabel":"命令结果","palette.needConfirm":"需确认","palette.empty":"没有匹配“{query}”的结果。","palette.footer":"↑↓ 选择 · Enter 执行 · Esc 关闭","palette.count":"{count} 项结果","palette.action.newSession":"新建会话","palette.action.resumeRun":"恢复可恢复运行","palette.action.connectionSettings":"连接设置","palette.action.viewConfig":"查看配置","palette.action.viewCapabilities":"查看能力清单","palette.action.refresh":"刷新当前视图","palette.action.shortcuts":"键盘快捷键","palette.action.checkConnection":"检查连接","palette.action.reconnect":"重新连接","palette.hint.action":"动作","palette.hint.settings":"设置项","palette.hint.help":"帮助","palette.hint.session":"会话","palette.hint.run":"运行","palette.hint.confirm":"需确认","palette.hint.cancel":"取消","palette.hint.resume":"恢复","palette.action.cancelRun":"取消运行 {id}","palette.action.cancelRunLabel":"取消运行","palette.action.resumeRunNamed":"恢复运行 {id}","palette.action.openRun":"打开运行 {id}","palette.action.openDurableRun":"打开可恢复运行 {id}","palette.action.reconnectMcp":"重连 MCP {name}","palette.confirm.cancelRunTitle":"取消运行?","palette.confirm.cancelRunBody":"运行中的工具调用会被取消,已产生的输出仍会保留。","palette.confirm.executeTitle":"执行「{label}」?","palette.confirm.executeBody":"该操作可能无法撤销。","palette.confirm.execute":"确认执行","palette.toast.refreshed":"已请求刷新当前视图","palette.toast.reconnecting":"正在重新连接 gateway","app.announce.run":"运行 {id} {status}","app.openConnection":"打开连接设置","app.retryNow":"立即重试","app.connectionSettings":"连接设置","app.reconnecting":"连接已断开,正在重连(第 {count} 次)…","app.stale":"连接已断开;当前显示的数据可能已过期。","app.help.title":"键盘快捷键","app.help.openClose":"打开/关闭命令面板","app.help.actionMode":"在非输入框中打开动作模式","app.help.move":"移动命令面板结果","app.help.execute":"执行选中命令 / 发送消息","app.help.close":"关闭面板、抽屉或对话框","chat.notFound":"会话不存在或已删除","chat.sessionList.title":"会话","chat.sessionList.new":"+ 新建","chat.sessionList.search":"搜索会话","chat.sessionList.renameEmpty":"标题不能为空,且不超过 512 个字符","chat.sessionList.renameFailed":"重命名失败,请重试","chat.sessionList.noConnection":"连接 gateway 后显示会话","chat.sessionList.loading":"正在加载会话…","chat.sessionList.noMatch":"没有匹配“{query}”的会话。","chat.sessionList.empty":"还没有会话。","chat.sessionList.idLabel":"会话标题","chat.sessionList.named":"已命名:标题由你设定,自动命名不会覆盖","chat.sessionList.actions":"会话 {title} 的操作","chat.sessionList.rename":"重命名","chat.sessionList.viewRuns":"查看运行","chat.sessionList.delete":"删除会话","chat.sessionList.showMore":"显示更多(还有 {count} 个)","chat.palette.rename":"重命名会话“{title}”","chat.palette.delete":"删除会话“{title}”(需确认)","chat.main.sessionsLabel":"会话列表","chat.main.conversationLabel":"对话","chat.main.heading":"会话","chat.empty.noConnectionTitle":"连接 gateway 后开始。","chat.empty.noConnectionDesc":"gateway URL 与 token 已移入设置;连接后可新建会话并发送第一条消息。","chat.loadingHistory":"正在加载会话历史…","chat.empty.noHistoryTitle":"该会话暂无对话记录。","chat.empty.noHistoryDesc":"在下方输入 prompt 继续这个会话。","chat.staleHistory":"历史刷新失败,显示已加载的记录:{detail}","chat.historyChanged":"更早的历史已被改写,已从服务端重新加载更早页面。","chat.earlierLoadFailed":"更早的消息没能加载,可以重试:{detail}","chat.toBottom":"回到底部 ↓","chat.index.label":"会话索引","chat.index.jump":"跳到第 {index} 条","chat.pending.title":"收件箱 · {count}","chat.awaitingJobs":"等待异步任务 {count}","chat.pending.identity.human":"human","chat.pending.identity.ask":"ask 答复","chat.pending.identity.bash":"bash 作业","chat.pending.identity.system":"系统","chat.pending.identity.agent":"agent:{name}","chat.pending.sameSource":"{count} 条","chat.pending.expandAll":"展开全部(还有 {count} 条)","chat.pending.collapseList":"收起","chat.pendingSend.offline":"连不上网关,没发出","chat.pendingSend.sending":"发送中…","chat.pendingSend.queued":"已排队,前面还有一轮","chat.pendingSend.queuedLong":"已排队 {minutes} 分钟,前面还有一轮","chat.pendingSend.queueTimeout":"已排队超时","chat.pendingSend.deferred":"服务端已收下 · {reason}","chat.pendingSend.deferredLong":"服务端已收下 · {reason} · 已等 {minutes} 分钟","chat.pendingSend.deferred.rotate":"会话正在换代,消息已落在收件箱","chat.pendingSend.deferred.stopped":"被硬错误闸住,解闸后自动继续","chat.pendingSend.deferred.other":"等待服务端接单","chat.pendingSend.deferTimeout":"服务端已收下,但一直没接单","chat.pendingSend.failed":"未发送","chat.pendingSend.retry":"重试","chat.pendingSend.dismiss":"删除这条","chat.pendingSend.edit":"编辑","chat.pendingSend.echoTimeout":"等待回显超时","chat.pendingSend.recallUnknown":"还不知道这条属于哪个成员,没能撤回","chat.pendingSend.recallRejected":"没能撤回服务端那条,条带已重读","chat.pending.edit":"收回编辑","chat.pending.editTaken":"已收回,内容放回输入框","chat.pending.editPeekFailed":"没能读到这条的原文,条带保持原样","chat.pending.peekFailed":"全文读取失败,当前显示的是摘要","chat.pending.editRecallRejected":"已放回输入框,但这条仍留在条带:它可能已经开始执行","chat.pending.editRecallFailed":"已放回输入框,但撤下这条失败:{detail}","chat.pending.claim":"我已处理","chat.pending.claimInFlight":"标记中…","chat.pending.claimTaken":"已标记为处理:这条不会再发送","chat.pending.claimSkipped":"没能拿走这一条({reason}),条带已重读对齐","chat.pending.claimSkipped.notFound":"它已经不在收件箱里了","chat.pending.claimSkipped.consumed":"它早就被拿走了","chat.pending.unhold":"留档(取消 hold)","chat.pending.unholding":"留档中…","chat.pending.unheld":"已取消 hold:这条按未读留档,仍留在条带上、模型仍能读到","chat.pending.unholdRejected":"服务端没有解除 hold,条带已重读对齐(这条可能已经不在了)","chat.pending.unholdFailed":"取消 hold 失败:{detail}","chat.toast.queued":"已排队","chat.toast.deferred":"服务端已收下,等待接单","chat.toast.cancelRequested":"已请求取消 run","chat.toast.queueCancelled":"已取消排队","chat.toast.cancelNotAccepted":"取消请求未被受理,run 可能已经开始执行","chat.toast.disconnectedRename":"连接断开,暂时无法重命名会话","chat.toast.renameFailed":"重命名失败:{detail}","chat.toast.disconnectedDelete":"连接断开,暂时无法删除会话","chat.toast.activeRuns":"该会话仍有运行中或中断的 run,暂时无法删除。","chat.toast.deleted":"已删除会话(runs: {runs}, events: {events})","chat.target.new":"+ 新会话","chat.target.session":"→ {title}","chat.delete.title":"删除会话“{title}”?","chat.delete.body":"将同时删除该会话的持久历史、关联 runs 与事件,无法撤销。","chat.delete.counts":"该会话有 {messages} 条消息","chat.delete.runsCount":"、{count} 个关联运行记录","chat.delete.counting":";正在统计关联运行…","chat.delete.activeRuns":"当前有 {count} 个运行中/中断的 run,需先结束或恢复后再删除。","chat.delete.statsFailed":"关联运行统计失败:{detail}","chat.delete.serverReject":"存在运行中或中断的 run 时服务端会拒绝删除。","chat.delete.disconnected":"连接已断开,写操作已禁用。","chat.delete.confirm":"删除会话","chat.delete.viewRuns":"查看该会话的运行","chat.composer.placeholderNoToken":"请先在设置 → 连接中配置 gateway token","chat.composer.placeholderDisconnected":"连接断开,重连后可继续发送","chat.composer.placeholder":"输入 prompt","chat.composer.sending":"发送中","chat.composer.send":"发送","chat.composer.hint":"Enter 发送 · Shift+Enter 换行","chat.sessionRef.note":"引用会话","chat.sessionRef.remove":"移除会话引用 {name}","chat.sessionRef.reject.tooMany":"会话引用最多 {max} 条","chat.sessionRef.header":"引用会话","chat.refs.label":"引用的文件","chat.refs.remove":"移除引用 {name}","chat.refs.kind.file":"文件","chat.refs.kind.image":"图片","chat.refs.kind.document":"文档","chat.refs.image.sent":"已发送 · {provider} · {tokens} tok","chat.refs.image.sentPlain":"已发送","chat.refs.image.dropped":"已丢弃 · {reason}","chat.refs.image.notSent":"未发送 · {reason}","chat.refs.image.noRecord":"无记录","chat.refs.image.reason.no_delivery_record":"没有留下投递记录","chat.refs.image.reason.budget":"超出单次预算","chat.refs.image.reason.bytes_budget":"超出单次字节预算","chat.refs.image.reason.unsupported_format":"格式不支持","chat.refs.image.reason.not_an_image":"不是图片","chat.refs.image.reason.too_large":"图片过大","chat.refs.image.reason.blob_missing":"附件字节缺失","chat.refs.image.reason.not_ingested":"未入池(无 sha256)","chat.refs.image.reason.vision_disabled":"视觉已关闭","chat.refs.image.reason.no_vision":"模型无视觉能力","chat.refs.image.reason.placeholder":"占位清理","chat.refs.image.reason.compaction":"压缩","chat.refs.image.reason.no_delivery_event":"没有投递记录","chat.refs.image.reason.unknown":"未知原因","chat.toolImage.group":"工具图片附件","chat.toolImage.title":"工具图片","chat.toolImage.count":"{count} 张","chat.toolImage.dimensions":"{width}×{height}","chat.toolImage.preview":"点击放大","chat.toolImage.previewNamed":"放大查看 {name}","chat.toolImage.loading":"加载图片…","chat.toolImage.unavailable":"预览不可用","chat.toolImage.raw":"原始通知","chat.toolImage.close":"关闭预览","chat.toolImage.copyPath":"复制路径","chat.toolImage.pathCopied":"路径已复制","chat.toolImage.staging":"临时(未入池)","chat.toolMedia.group":"工具附件","chat.toolMedia.title":"工具附件","chat.toolMedia.count":"{count} 项","chat.pdf.previewNamed":"预览 {name}","chat.refCard.copyPath":"复制路径","chat.refCard.pathCopied":"路径已复制","chat.refCard.expired":"已过期","chat.refCard.temporary":"临时","chat.refs.reject.absolute":"只能引用绝对路径:{path}","chat.refs.reject.tooLong":"引用路径超过 {max} 个字符","chat.refs.reject.tooMany":"单条消息最多带 {max} 个引用","chat.refs.reject.invalid":"引用路径不合法:{name}","composer.toolbar.label":"输入框工具栏","composer.refs.label":"已引用","composer.refs.remove":"移除 {name}","chat.event.truncated":"(已截断)","chat.event.expand":"展开","chat.event.collapse":"收起","chat.event.raw":"原始事件","chat.event.rawData":"原始载荷","chat.event.meta":"事件信息","chat.event.type":"类型","chat.event.time":"时间","chat.event.runId":"运行","chat.event.empty":"无载荷","chat.notice.contextPressure":"上下文水位 {percent}% · {used}/{max}","chat.notice.contextCompacted":"上下文压缩 · 移除 {removed} · 剩余 {remaining} · {reason}","chat.notice.contextTrimmed":"上下文裁剪 · 本轮新增 {added} 条(会话内累计 {cleared} 条)· 保留 {kept} 条","chat.notice.limitWarning":"限额预警 · {key} {current}/{max}","chat.notice.restarting":"上下文重启中 · {session} · epoch {from} → {epoch}","chat.notice.restarted":"上下文已重启 · {session} · epoch {from} → {epoch}","chat.notice.compactForked":"上下文已压缩分叉 · {from} → {to} · epoch {epoch}","chat.notice.hook":"hook · {name}","chat.notice.finalizeFailed":"run 收尾失败 · 阶段 {phase} · {error}","chat.notice.guardrailError":"guardrail 异常 · {name} · 阶段 {stage} · {error}","chat.notice.runtime":"系统提示 · {kind}","chat.notice.replyStale":"这次回复未被采用 · 旧身体已退役 · epoch {epoch} · 消息 {message}","chat.notice.handoffNoReply":"已交棒,但这一轮没有留下收尾 · {outcome} · epoch {epoch}","chat.notice.retired":"旧身体已退役 · {reason} · epoch {epoch} · body {body}","chat.notice.rotateDenied":"上下文切换未获批 · {reason} · 水位 {percent}%","chat.notice.unknownEvent":"未知事件类型 · 已折叠 · {type}","chat.env.aria":"环境信息","chat.env.title":"环境信息","chat.env.scope.config":"配置","chat.env.scope.permission":"权限","chat.env.scope.tools":"工具","chat.env.scope.mcp":"MCP","chat.env.scope.update":"更新","chat.env.scope.peer":"成员","chat.env.scope.inbox":"收件箱","chat.env.scope.restart":"重启","chat.env.scope.identity":"身份","chat.env.scope.fields":"字段","chat.env.scope.lock":"写锁争用","chat.env.scope.conflict":"写冲突","chat.env.scope.files":"文件变更","chat.env.scope.health":"节点健康","chat.env.scope.agent":"成员活动","chat.env.scope.script":"订阅脚本","chat.env.scope.doc-lag":"文档滞后","chat.env.scope.code-heaviness":"代码厚重","chat.env.scope.team-log":"团队日志","chat.env.scope.model":"模型","chat.env.scope.selfcard":"基础信息","chat.env.scope.context":"上下文","chat.env.scope.trim":"已裁剪上下文","chat.env.scope.pii":"PII 脱敏","chat.env.scope.source":"来源","chat.env.source.raw":"来源原文","chat.env.count":"{count} 条","chat.env.notApplied":"未生效","chat.env.moreLines":"还有 {count} 行未显示","chat.env.changed.count":"{count} 项变更","chat.env.changed.title":"变更","chat.env.changed.from":"来自 #{hash}","chat.env.changed.systemPrompt":"系统提示词","chat.env.changed.selfCard":"自卡","chat.env.changed.model":"模型","chat.env.changed.tools":"工具","chat.env.changed.added":"新增","chat.env.changed.removed":"移除","chat.env.changed.replaced":"已替换","chat.modelContext.system":"System prompt","chat.modelContext.selfCard":"Self Card","chat.modelContext.messages":"{count} 条消息","chat.modelContext.tools":"{count} 个工具","chat.modelContext.tokens":"{count} tokens","chat.modelContext.hash":"上下文 {hash}","chat.modelContext.contextMax":"窗口 {count}","chat.askAnswer.title":"待批答复","chat.askAnswer.aria":"待批答复(异步提问的回答)","chat.askAnswer.source":"来自待批页","chat.askAnswered.title":"提问答复","chat.askAnswered.aria":"已答提问(服务端记录,刷新后仍在)","chat.askAnswered.source":"服务端已答记录","chat.rotateHandoff.title":"⟳ rotate 交接","chat.rotateHandoff.aria":"rotate 交接 · epoch {epoch}","chat.rotateHandoff.epoch":"epoch {epoch}","chat.rotateHandoff.source":"发起 rotate 的 agent 写的交接嘱托 · 不是人在这里打的字","chat.agentMessage.from":"来自 agent {name}","chat.agentMessage.group":"来自 agent {name} 的消息","chat.toolMessage.from":"来自 {name}","chat.toolMessage.group":"来自 {name} 的投递","chat.message.actions":"消息操作","chat.message.fold.expand":"展开全文","chat.message.fold.collapse":"收起","chat.message.copy":"复制","chat.message.copied":"已复制","chat.code.copy":"复制代码","chat.table.copy":"复制表格","chat.message.edit":"编辑","chat.message.retry":"重试","chat.quote.action":"引用","chat.quote.label":"引用消息","chat.quote.jump":"跳转到原消息","chat.quote.remove":"取消引用","chat.quote.source.user":"用户","chat.quote.source.assistant":"助手","chat.message.create.editTitle":"编辑消息","chat.message.create.editBody":"将以这条消息之前的历史新建一个 session,并把原文放回输入框。当前 session 会保留为只读,历史不会被删除。","chat.message.create.retryTitle":"重新生成","chat.message.create.retryBody":"将以这条回复之前的历史新建一个 session,并重新发送上一条用户消息。当前 session 会保留为只读,历史不会被删除。","chat.message.create.confirm":"新建会话","chat.message.create.editDone":"已新建 session","runs.title":"运行","runs.sourceLabel":"运行来源","runs.source.live":"Live(进程内)","runs.source.durable":"可恢复","runs.filter.all":"全部","runs.filter.queued":"排队","runs.filter.running":"运行中","runs.filter.completed":"已完成","runs.filter.failed":"失败","runs.filter.cancelled":"已取消","runs.filter.interrupted":"已中断","runs.searchPlaceholder":"搜索 run id / session / 输出 / 错误","runs.searchLabel":"搜索运行","runs.noTokenTitle":"连接 gateway 后显示运行。","runs.durableDisabledTitle":"可恢复运行未启用","runs.durableDisabledReason":"此 gateway 没有启用持久运行恢复。","runs.durableDisabledHint":"需要启用 checkpoint 存储与 resume 后重启 gateway。","runs.disconnected":"连接已断开;显示最近一次读取的运行列表,写操作已禁用。","runs.emptyLiveTitle":"当前 gateway 进程还没有运行记录。","runs.emptyLiveDesc":"在会话中发送一条 prompt 后,运行会出现在这里。","runs.emptyDurableTitle":"没有匹配的可恢复运行。","runs.emptyDurableDesc":"调整状态过滤或清除会话过滤后重试。","runs.noMatchTitle":"没有匹配的运行。","runs.noMatchDesc":"清除搜索、状态或会话过滤后重试。","runs.col.state":"状态","runs.col.runId":"运行 ID","runs.col.session":"会话","runs.col.started":"开始","runs.col.duration":"耗时","runs.col.actions":"操作","runs.col.agent":"Agent","runs.col.iter":"Iter","runs.col.cacheHit":"缓存命中","runs.col.updated":"更新","runs.cancel":"取消","runs.cancelling":"取消中…","runs.resume":"恢复运行","runs.resuming":"恢复中…","runs.notFound":"运行不存在","runs.loading":"正在加载运行…","runs.detailLoading":"正在加载运行详情…","runs.palette.live":"运行 {id}","runs.palette.durable":"可恢复 {id}","runs.toast.disconnectedCancel":"连接断开,无法取消运行","runs.toast.cancelRequested":"已请求取消 run","runs.toast.cancelNotAccepted":"取消请求未被受理,run 可能已开始执行","runs.toast.disconnectedResume":"连接断开,无法恢复运行","runs.toast.resumed":"已排队恢复运行","runs.toast.resuming":"该运行已在恢复中","runs.detail.label":"运行详情","runs.detail.title":"运行详情","runs.detail.copyId":"复制运行 ID","runs.detail.copiedId":"已复制运行 ID","runs.detail.exportJson":"导出 JSON","runs.detail.close":"关闭运行详情","runs.detail.session":"会话","runs.detail.started":"开始","runs.detail.ended":"结束","runs.detail.duration":"耗时","runs.detail.cancel":"取消 run","runs.detail.cancelling":"取消中…","runs.detail.resume":"恢复运行","runs.detail.resuming":"恢复中…","runs.detail.disconnected":"连接已断开;以下数据为最近一次读取的结果。","runs.detail.filtersLabel":"按事件类别过滤","runs.detail.filter.all":"全部","runs.detail.filter.llm":"LLM","runs.detail.filter.tools":"工具","runs.detail.filter.errors":"错误","runs.detail.filter.internal":"内部","runs.detail.filter.other":"其它","runs.detail.typePrefix":"类型前缀,如 tool.call.","runs.detail.typePrefixLabel":"按事件类型前缀过滤","runs.detail.refreshEvents":"刷新事件","runs.detail.traceDisabledTitle":"事件记录未启用或无记录。","runs.detail.traceDisabledHint":"run 摘要与输出仍可用;在 gateway 配置中启用事件记录后重启即可查看完整时间线。","runs.detail.traceStale":"事件记录不可用;仅显示实时缓冲中的 {count} 条事件。","runs.detail.loadingTrace":"正在读取事件记录…","runs.detail.emptyTraceTitle":"没有事件记录。","runs.detail.emptyTraceQueued":"该运行尚未映射到核心运行(可能仍在排队),暂时没有事件记录。","runs.detail.emptyTraceDesc":"事件记录中没有该 run 的事件;输出与 Raw JSON 仍可查看。","runs.detail.noMatchTitle":"没有匹配的事件。","runs.detail.loadingMore":"加载中…","runs.detail.loadMore":"加载更多事件(已显示 {count} 条)","runs.detail.missingSeq":"事件缺少 seq,无法继续分页;可刷新重新读取。","runs.detail.errorTitle":"错误","runs.detail.outputTitle":"输出","runs.detail.checkpointPreview":"最后一条消息(checkpoint 预览)","runs.detail.checkpoint":"最后一条消息(checkpoint)","runs.detail.emptyOutputTitle":"没有可显示的输出。","runs.detail.emptyOutputDesc":"运行可能仍在进行或已取消。","runs.detail.rawLabel":"原始 JSON","runs.detail.copyJson":"复制 JSON","runs.detail.copiedJson":"已复制运行 JSON","runs.detail.metaTitle":"运行摘要","runs.detailPage.subtitle":"运行详情是独立页面:上面是运行摘要,下面是原始事件日志。","runs.detailPage.back":"返回运行列表","runs.log.title":"原始事件日志","runs.log.hint":"一行一事件;点击行展开完整 JSON(可复制)。过滤只作用于已加载的事件。","runs.log.col.time":"时间戳","runs.log.col.type":"类型","runs.log.col.summary":"摘要","runs.log.seqFrom":"seq 下界(含)","runs.log.seqTo":"seq 上界(含)","runs.log.keyword":"搜索类型或载荷","runs.log.keywordLabel":"搜索事件类型或载荷","runs.log.rowLabel":"展开事件 {type}(seq {seq})","runs.log.prev":"上一页","runs.log.next":"下一页","runs.log.pageOf":"第 {page} / {pages} 页","runs.log.loadedOnly":"只过滤已加载的事件;查看更多需继续加载。","runs.log.noMatchDesc":"调整类别、类型前缀、seq 范围或关键字;清空过滤可看全部事件。","runs.detail.loadMoreFailed":"加载更多事件失败:{detail}","integrations.tools.noTokenReason":"连接后才能读取工具目录。","integrations.tools.loading":"正在读取工具…","integrations.tools.searchPlaceholder":"搜索工具名称或描述","integrations.tools.searchLabel":"搜索工具","integrations.tools.onlyConfirm":"仅需确认({count})","integrations.tools.empty":"gateway 没有注册工具。","integrations.tools.noMatch":"没有匹配的工具。","integrations.tools.openDetails":"打开 {name} 详情","integrations.tools.dialogLabel":"工具详情:{name}","integrations.tools.details":"工具详情","integrations.tools.schema":"Input schema","integrations.tools.stale":"连接已断开;显示最近一次读取的工具目录。","integrations.tools.policyLabel":"确认策略","integrations.tools.policyAuto":"自动允许","integrations.tools.policyAsk":"每次确认","integrations.tools.policyNever":"强制确认","integrations.tools.policyAutoHint":"调用不再询问;该工具写入 permission.autoApprove。","integrations.tools.policyAskHint":"默认:每次调用都需要确认;该工具不在任何免确认列表中。","integrations.tools.policyNeverHint":"即使被自动放行也必须确认;该工具写入 permission.neverAutoApprove。","integrations.tools.policyScopedNever":"部分动作即使自动放行也会确认","integrations.tools.policyScopedHint":"某些动作(例如 agent.close)即使被自动放行也会确认;可在下方逐项单独设置。","integrations.tools.policyScopedLabel":"按动作覆盖","integrations.tools.policyScopedNeverOn":"即使自动放行也确认","integrations.tools.policyScopedNeverHint":"只阻止自动放行;工具显式允许时仍会执行。","integrations.tools.policyApplied":"已生效。","integrations.tools.policyFailed":"未生效:{detail}","integrations.tools.policySaving":"正在保存…","integrations.tools.policyChecking":"正在检查 gateway 能力…","integrations.tools.policyUnsupported":"需要更新的 gateway。","integrations.tools.policyLoadFailed":"读取权限配置失败:{detail}","integrations.tools.policyAlwaysAvailableNote":"inbox 是所有成员共用的收消息核心通道,默认始终可用(缺省档与自动允许都不拦截)。设为「强制确认」不会禁用工具,而是每次调用都要确认——无人值守时可能阻塞消息接收,请谨慎设置;也可用 inbox.read 等按动作条目只收窄个别动作。","integrations.mcp.globalDesc":"MCP 控制面为 gateway 全局状态。","integrations.mcp.counts":"{total} 个服务 · {failed} 个失败","integrations.mcp.reconnectAll":"重连全部失败({count})","integrations.mcp.reconnectAllBusy":"重连中…","integrations.mcp.noTokenReason":"连接后才能读取 MCP 状态。","integrations.mcp.disabledTitle":"MCP 未启用","integrations.mcp.disabledReason":"该 gateway 没有注入 MCP 控制面。","integrations.mcp.disabledHint":"未配置 MCP server 时属正常;需要时在 mcp_servers 配置后重启 gateway。","integrations.mcp.stale":"连接已断开;显示最近一次读取的 MCP 状态。写操作已禁用。","integrations.mcp.staleDetail":"MCP 状态更新失败:{detail}","integrations.mcp.loading":"正在读取 MCP 服务…","integrations.mcp.emptyTitle":"未配置 MCP server。","integrations.mcp.emptyDesc":"在配置中启用 mcp_servers 后重启 gateway。","integrations.mcp.toolsCount":"{count} 个工具","integrations.mcp.reconnect":"重连","integrations.mcp.reconnecting":"重连中…","integrations.mcp.reconnectSuccess":"已重连 {name}","integrations.mcp.reconnectFailed":"重连 {name} 失败:{detail}","integrations.mcp.reconnectDisconnected":"连接断开,无法重连 MCP","integrations.mcp.reconnectAllSuccess":"已重连 {count} 个 MCP 服务","integrations.mcp.reconnectAllFailed":"重连失败:{detail}","integrations.mcp.reconnectPartial":"已重连 {count} 个;失败:{detail}","integrations.channels.noTokenReason":"连接后才能读取渠道状态。","integrations.channels.disabledTitle":"飞书渠道未启用","integrations.channels.disabledReason":"该 gateway 没有注入 feishu 渠道。","integrations.channels.disabledHint":"需要启用 feishu 插件并配置凭据后重启 gateway。","integrations.channels.loading":"正在读取飞书状态…","integrations.channels.empty":"没有渠道数据。","integrations.channels.globalDesc":"该控制面为 gateway 全局状态,只读。","integrations.channels.stale":"连接已断开;显示最近一次读取的渠道状态。","integrations.channels.title":"飞书","integrations.channels.activeChats":"活跃会话","integrations.channels.queuedMessages":"排队消息","integrations.channels.lastError":"最近错误","integrations.channels.noToggle":"渠道没有启停接口,因此此处不提供伪造的开关。","observe.metrics.noTokenReason":"连接后才能读取指标。","observe.metrics.disabledTitle":"指标未启用","observe.metrics.disabledReason":"该 gateway 没有注入 metrics provider。","observe.metrics.disabledHint":"需要启用 metrics 后重启 gateway。","observe.metrics.traceDisabledTitle":"事件记录重建不可用","observe.metrics.traceDisabledHint":"需要 gateway 注入 metrics.rebuild(事件记录)后重启。","observe.metrics.switchLive":"切回 Live","observe.metrics.sourceLabel":"指标来源","observe.metrics.source.live":"Live","observe.metrics.source.trace":"事件记录重建","observe.metrics.refresh":"刷新","observe.metrics.panelLabel":"指标内容","observe.metrics.stale":"连接已断开;显示最近一次读取的指标快照。写操作已禁用。","observe.metrics.loading":"正在读取指标…","observe.metrics.stat.runsStarted":"Runs 已启动","observe.metrics.stat.completed":"已完成","observe.metrics.stat.failed":"失败","observe.metrics.stat.cancelled":"已取消","observe.metrics.stat.toolCalls":"工具调用(失败 {failed})","observe.metrics.stat.tokens":"Tokens({prompt}+{completion})","observe.metrics.stat.cacheInputShare":"缓存输入占比(读 / 全部输入)","observe.metrics.stat.cachePrefixHealth":"前缀健康度(读 / 读+写)","observe.metrics.stat.cacheUnavailable":"不可用","observe.metrics.stat.cacheNoFieldsHint":"provider 未在 usage 中上报缓存字段(该端点或中转可能未透传缓存明细)","observe.metrics.stat.cacheHint":"读 {read} / 写 {write},输入共 {prompt}","observe.metrics.stat.avgDuration":"平均耗时(最大 {max}ms)","observe.metrics.stat.updatedAt":"更新于","observe.metrics.sourceDesc":"当前来源:{source}。指标是进程内计数器,不是时间序列;历史用量另见用量统计。","observe.evals.noTokenReason":"连接后才能读取评测报告。","observe.evals.disabledTitle":"评测未启用","observe.evals.disabledReason":"该 gateway 没有注入 evals runner。","observe.evals.disabledHint":"需要启用 evals 插件后重启 gateway。","observe.evals.disconnectedRun":"连接断开,无法运行评测","observe.evals.completed":"评测完成:{suite}","observe.evals.intro":"评测默认离线运行;网络模式由服务端 `evals.allowNetwork` 与 CLI `--allow-network` 双门控,客户端不提供开关。运行评测可能需要较长时间,可以离开此页。","observe.evals.suitePlaceholder":"suite(默认 smoke)","observe.evals.suiteLabel":"评测 suite","observe.evals.loadLatest":"加载最近报告","observe.evals.run":"运行评测","observe.evals.running":"运行中…(可离开页面)","observe.evals.recent":"最近使用:","observe.evals.retry":"重试","observe.evals.disconnectedReport":"连接已断开;显示最近一次读取的评测报告。","observe.evals.notFoundTitle":"Evals 未启用或没有该 suite 的报告","observe.evals.notFoundHint":"确认 suite 名称;运行评测可生成新报告。","observe.evals.loadingReport":"正在读取评测报告…","observe.evals.emptyTitle":"加载一个评测报告。","observe.evals.emptyDesc":"后端没有 suite 列表接口;输入 suite 名称或从最近使用中选择。","observe.evals.stat.total":"用例总数","observe.evals.stat.passed":"通过","observe.evals.stat.failed":"失败","observe.evals.stat.errors":"错误","observe.evals.stat.skipped":"跳过","observe.evals.stat.duration":"耗时","observe.evals.stat.network":"网络模式","observe.evals.generatedAt":"报告生成于 {time}。{network}","observe.evals.networkOn":"本次启用了网络模式。","observe.evals.offline":"本次为离线评测。","observe.evals.casesTitle":"用例","observe.evals.failedOnly":"只看失败","observe.evals.emptyFailed":"没有失败用例。","observe.evals.emptyCases":"没有用例。","observe.evals.col.status":"状态","observe.evals.col.case":"用例","observe.evals.col.duration":"耗时","observe.evals.col.assertions":"断言","observe.evals.col.output":"输出 / 错误","observe.evals.assertions":"断言详情","observe.evals.showMore":"显示更多用例(还有 {count} 条)","connection.title":"连接 gateway","connection.description":"token 只保存在 sessionStorage;URL 保存在 localStorage。非回环地址必须使用 HTTPS。","connection.reconnecting":"正在重新连接 gateway…","connection.connecting":"正在连接 gateway…","connection.urlPlaceholder":"留空 = 同源(推荐)","connection.current":"当前:{url}","connection.tokenPlaceholder":"gateway token","connection.platformUrl":"平台 URL","connection.nodeUrl":"节点 URL","connection.platformToken":"平台 token","connection.platformTokenPlaceholder":"平台 token","connection.nodeToken":"节点 token","connection.nodeTokenOptional":"节点 token(可选;留空使用平台凭据)","connection.nodeTokenPlaceholder":"节点 token(留空 = 凭据/匿名)","connection.mode":"连接模式","connection.modePending":"正在探测平台…","connection.modePlatform":"平台 gateway","connection.modeLegacy":"legacy node 宿主 UI","connection.reconnect":"重新连接","connection.connect":"连接","connection.retryNow":"立即重试","connection.disconnect":"断开并清除 token","connection.disconnected":"已断开并清除 token","connection.diagnostics":"诊断","connection.state":"连接状态","connection.protocol":"协议版本","connection.node":"节点","connection.latestSeq":"最新 seq","connection.featureCount":"Feature 数","connection.featureList":"({features})","connection.closeCodeToken":" · token 无效","connection.closeCodeForbidden":" · 无权访问","connection.closeCodeProtocol":" · 协议不兼容","connection.failureHint":"连接失败时请依次检查:地址是否可达、Origin 是否在 node.allowed_origins、token 是否有效、非回环是否使用 HTTPS。","connection.connected":"已连接 gateway","config.noTokenReason":"连接后才能读取配置。","config.disabledTitle":"配置接口未启用","config.disabledReason":"该 gateway 没有注入 config 控制面。","config.disabledHint":"需要 gateway 启用 config 控制面后重启。","config.loading":"正在读取配置…","config.stale":"连接已断开;显示最近一次读取的配置快照。","config.title":"配置快照","config.copyJson":"复制 JSON","config.copiedJson":"已复制配置 JSON","config.schemaVersion":"schema 版本","config.userPath":"用户配置路径","config.projectPath":"项目配置路径","config.overlayKeys":"覆盖键","config.redactedJson":"脱敏配置 JSON(服务端已完成脱敏)","config.itemsTitle":"配置项","config.itemsDesc":"展平后的只读视图;密钥字段由服务端在返回前脱敏(前端不猜测、不展示密钥)。","config.searchPlaceholder":"搜索路径或值","config.searchLabel":"搜索配置项","config.empty":"配置为空。","config.noMatch":"没有匹配“{query}”的配置项。","config.col.path":"路径","config.col.value":"值","config.col.type":"类型","config.sourcesTitle":"配置来源","config.noSources":"无来源信息。","config.col.key":"键","config.col.source":"来源","capabilities.noTokenReason":"连接后才能读取能力清单。","capabilities.loading":"正在读取能力清单…","capabilities.noManifest":"没有能力清单","capabilities.stale":"连接已断开;显示最近一次读取的能力清单。","capabilities.subtitle":"协议方法、工具,以及 gateway 运行时当前加载的插件。可安装的插件包见插件页的插件市场。","capabilities.methodsCount":"协议方法(read {read} / write {write} / admin {admin})","capabilities.tools":"工具","capabilities.pluginsEnabled":"已启用插件","capabilities.tabsLabel":"能力类别","capabilities.tab.methods":"方法","capabilities.tab.tools":"工具","capabilities.tab.plugins":"运行时插件","capabilities.tab.methodsCount":"方法 · {count}","capabilities.tab.toolsCount":"工具 · {count}","capabilities.tab.pluginsCount":"运行时插件 · {enabled}/{total}","capabilities.search.methods":"搜索协议方法","capabilities.search.tools":"搜索工具","capabilities.search.plugins":"搜索插件","capabilities.searchLabel":"搜索能力","capabilities.noMatchMethods":"没有匹配的协议方法。","capabilities.methodsTitle":"方法 · {permission}","capabilities.col.method":"方法","capabilities.col.permission":"权限","capabilities.toolsTitle":"工具","capabilities.noMatchTools":"没有匹配的工具。","capabilities.pluginsTitle":"运行时插件","capabilities.pluginsDescription":"由 gateway 运行时加载,含工具、Provider 与 Guardrail;不等于可安装的插件包。Marketplace 的「我的插件」列出的是本机插件包(内置与已安装),口径不同。","capabilities.noMatchPlugins":"没有匹配的插件。","capabilities.enabled":"已启用","capabilities.disabled":"已停用","capabilities.col.plugin":"插件","capabilities.col.scope":"来源","capabilities.col.mode":"运行方式","capabilities.col.state":"状态","capabilities.col.restart":"生效方式","capabilities.scope.builtin":"内置","capabilities.scope.user":"用户","capabilities.scope.project":"项目","capabilities.scope.node_modules":"node_modules","capabilities.mode.in-process":"进程内","capabilities.mode.child":"子进程","capabilities.restartRequired":"重启后生效","capabilities.catalogUnavailable":"插件 catalog 不可用;显示能力清单中的运行时插件快照(未扫描本机插件目录)。","gateway.url.wildcard":"不支持通配符 gateway 地址","gateway.url.incomplete":"请输入完整的 gateway 地址(如 https://host:8642)","gateway.url.scheme":"gateway 地址只支持 http(s)/ws(s)","gateway.url.credentials":"gateway 地址不能包含用户名或密码","gateway.url.path":"只填写 scheme://host[:port],不要带路径或参数","gateway.url.https":"非回环 gateway 必须使用 HTTPS(wss)","gateway.url.mixed":"HTTPS 页面不能连接 http:// gateway(mixed content)","gateway.connection.invalidUrl":"无效的 gateway 地址","gateway.connection.authFailed":"鉴权失败:token 错误或已失效","gateway.connection.originRejected":"gateway 拒绝该 Origin/Host:{detail}。跨 Origin 部署需把本站加入 node.allowed_origins。","gateway.connection.unreachable":"无法连接 gateway(检查地址/TLS/网络):{detail}。跨 Origin 时还需配置 node.allowed_origins。","gateway.connection.forbiddenTenant":"无权访问(需要 admin token)","gateway.connection.protocolMismatch":"协议版本不兼容(需要 vessel.gateway/1)","gateway.connection.tokenRequired":"请输入 gateway token","gateway.rpc.sessionInvalid":"会话已失效(401)","gateway.rpc.sessionInvalidHint":"这个页面发出的请求都被拒,待批与权限卡因此拿不到。点「重新登录」;登录后仍是 401 的话,确认当前页面地址在 http.allowed_origins 里。","gateway.rpc.relogin":"重新登录","gateway.rpc.connectInstead":"打开连接设置","gateway.rpc.originBlocked":"来源被拒(Origin 不在白名单)","gateway.rpc.originBlockedHint":"gateway 的回应是「{detail}」。跨 Origin 访问要把本站加进 http.allowed_origins,否则所有 RPC 都被拒、权限卡到不了界面。","gateway.rpc.unreachable":"连不上 node(来源被拒或服务未运行)","gateway.rpc.unreachableHint":"这个页面发出的请求一次都没成功过(最近 {count} 次全部失败:{detail}),待批与权限卡都到不了界面。若 node 其实在跑,多半是本站没进 http.allowed_origins。网络或配置恢复、有请求成功之后,这条会自己消失。","gateway.platform.tokenRequired":"需要平台 token:/platform/rpc 返回 401;请在连接设置中输入平台 token。","gateway.platform.noNodes":"平台 gateway 没有返回任何节点。","gateway.platform.credentialsUnavailable":"无法读取节点凭据;请手动输入节点 token。","auth.login.title":"登录 VESSEL","auth.login.passwordSubtitle":"这个 WebUI 需要口令登录(单用户部署;配了 TOTP 时还要一次性验证码)。","auth.login.username":"登录名","auth.login.password":"口令","auth.login.submit":"登录","auth.login.codeLabel":"验证码 / 恢复码","auth.login.submitCode":"验证","auth.login.backToPassword":"重新输入口令","auth.login.codeHint":"输入认证器里的 6 位码;也可以用一次性恢复码(用过即废)。","auth.login.codeHintNoRecovery":"输入认证器里的 6 位码(恢复码已用完,可在设置里重新签发)。","auth.login.totpHint":"口令通过后还要 TOTP 验证码;时钟漂移容忍 ±30 秒。","auth.login.bootstrapHint":"还没有设置口令:请用启动日志里打印的一次性引导码打开这个页面(#token=<引导码>,10 分钟内有效、只能用一次)。","auth.signedInAs":"已登录为 {user}","auth.signedInAsTitle":"当前会话身份:{user}","auth.logout":"登出","auth.sessionRequired":"会话已失效或未登录:请重新登录。","auth.csrfRejected":"请求缺少有效的 CSRF 令牌(可能是另一个标签页轮换了它):请刷新页面后重试。","auth.error.state_invalid":"登录状态校验失败(state 不匹配、已过期或已被使用):请重新登录。","auth.error.code_missing":"登录服务没有返回授权码:请重新登录。","auth.error.secret_missing":"服务端没有读到登录后端的 client secret 环境变量(auth.backends[].clientSecretEnv):请让部署者设置它。","auth.error.token_exchange_failed":"用授权码换 access token 失败:请重新登录。","auth.error.user_fetch_failed":"读取登录用户信息失败:请重新登录。","auth.error.not_allowlisted":"这个账号不在允许登录的名单里(本部署只允许指定的账号 / id)。","auth.error.public_origin_missing":"服务端没有配置 auth.publicOrigin / auth.publicOrigins,无法发起登录。","auth.error.backend_not_configured":"服务端没有启用这个登录后端。","auth.error.invalid_credentials":"登录名或口令不对。","auth.error.invalid_code":"验证码不对(或已过期):请用当前 6 位码再试一次。","auth.error.code_replayed":"这个验证码已经用过了:同一个码不能重复使用,请等下一个 30 秒。","auth.error.ticket_invalid":"验证步骤已过期:请重新输入口令。","auth.error.rate_limited":"失败次数太多,已被临时限速:请等提示的时间再试。","auth.error.password_not_set":"服务端还没有设置口令:请用启动日志里的一次性引导码。","auth.error.password_unsupported":"这个运行时没有 argon2id 支持,无法校验口令。","auth.error.bootstrap_disabled":"这个部署没有启用口令后端,引导码不可用。","auth.error.bootstrap_invalid":"引导码无效:请重启 gateway 重新获取一枚。","auth.error.bootstrap_expired":"引导码已过期(10 分钟):请重启 gateway 重新获取一枚。","auth.error.bootstrap_replayed":"这个引导码已经用过:它签发的会话已被撤销,请用口令登录。","auth.error.setup_session_required":"这一步需要一个引导会话:请用一次性引导码打开页面。","auth.error.password_too_short":"口令太短:正文至少 10 个字符。","auth.error.password_too_long":"口令太长(上限 200 个字符)。","auth.error.password_from_env":"口令 hash 由环境变量提供,请在部署配置里改。","auth.error.totp_already_enrolled":"已经绑定过 TOTP 了。","auth.error.totp_not_enrolled":"还没有绑定 TOTP,没有恢复码可签发。","auth.error.json_required":"登录接口只接受 application/json。","auth.error.forbidden_origin":"请求来源不被允许。","auth.error.unknown":"登录失败:请重试。","auth.setup.title":"设置登录凭据","auth.setup.subtitle":"这个会话来自一次性引导码(已作废)。先设口令,再绑定 TOTP —— 两步都很短。","auth.setup.password":"新口令","auth.setup.passwordConfirm":"再输一次","auth.setup.passwordHint":"至少 10 个字符;用 argon2id 存 hash,明文不落盘。","auth.setup.passwordMismatch":"两次输入不一致。","auth.setup.savePassword":"保存口令","auth.setup.totpIntro":"接着绑定 TOTP:下一步会显示配对 URI 与一批一次性恢复码。","auth.setup.enrollTotp":"生成 TOTP 密钥","auth.setup.skipTotp":"先跳过(之后可在设置里绑定)","auth.setup.totpSecret":"把下面这串加进认证器(otpauth URI):","auth.setup.secretFallback":"手动输入密钥:{secret}","auth.setup.recoveryTitle":"恢复码(只显示这一次,每个只能用一次)","auth.setup.recoveryHint":"请现在存到密码管理器里:离开这个页面后服务端只剩 hash,无法再显示。","auth.setup.finish":"完成","gateway.client.timeout":"连接 gateway 超时","gateway.client.tokenRequired":"token 不能为空","gateway.client.tokenRequiredHttp":"缺少 gateway token","gateway.client.wsFailed":"WebSocket 连接失败","gateway.client.closedWithCode":"连接已关闭({code})","gateway.client.notConnected":"gateway 尚未连接","gateway.client.requestTimeout":"请求超时:{method}","gateway.client.closed":"连接已关闭","gateway.client.stopped":"gateway 已停止","gateway.client.unreachable":"无法连接 gateway(未启动或地址错误)","gateway.error.unauthorized":"token 无效或已过期,请在连接设置中重新输入。","gateway.error.forbidden":"当前 token 没有执行该操作的权限。","gateway.error.forbidden_origin":"请求来源不在 node.allowed_origins 中。","gateway.error.invalid_host":"Host 头不被 gateway 允许。","gateway.error.not_found":"目标不存在或已被删除。","gateway.error.method_not_found":"该 gateway 不支持此方法(版本较旧或打错了目标)。请核对连接地址与 gateway 版本。","gateway.error.invalid_params":"请求参数不合法。","gateway.error.invalid_request":"请求格式不合法。","gateway.error.conflict":"操作与当前状态冲突,请刷新后重试。","gateway.error.quota_exceeded":"已超出配额。","gateway.error.rate_limited":"请求过于频繁,请稍后重试。","gateway.error.timeout":"请求超时,请重试。","gateway.error.unsupported_protocol":"gateway 协议版本不兼容,请升级客户端或服务端。","gateway.error.internal":"gateway 内部错误,请查看服务端日志。","gateway.error.no_runtime":"gateway 未配置运行 runtime。","gateway.error.durable_disabled":"durable run 未启用。","gateway.error.mcp_disabled":"MCP 未启用。","gateway.error.evals_disabled":"evals 未启用。","designLab.title":"设计实验室","designLab.subtitle":"token 与可复用组件都在运行时自动发现:新增 token 或 *.preview.tsx 就会出现在这里;组件清单区审计共享组件的复用度。","designLab.tokens.autoNote":"清单由 :root 上实际存在的自定义属性自动枚举(按前缀分组):新增一个 token 不需要改本页代码。","designLab.tokens.colors":"颜色","designLab.tokens.count":"{count} 个","designLab.tokens.filter":"过滤 token","designLab.tokens.filterEmpty":"没有匹配的 token。","designLab.tokens.filterPlaceholder":"按名称或值过滤,如 amber","designLab.tokens.fonts":"字体","designLab.tokens.layers":"层级","designLab.tokens.legend":"颜色固定两列:左 = 亮色主题的值,右 = 暗色主题的值 —— 两者都与当前主题无关。","designLab.tokens.motion":"动效","designLab.tokens.other":"其它","designLab.tokens.radii":"圆角","designLab.tokens.runtimeNote":'非颜色 token 的数值由 getComputedStyle(document.documentElement) 在当前主题下读取;颜色的亮 / 暗两列直接取自 tokens.css 的 :root 与 :root[data-theme="dark"] 声明,与当前主题无关。',"designLab.tokens.shadows":"阴影","designLab.tokens.sizes":"尺寸","designLab.tokens.spacing":"间距","designLab.tokens.subtitle":"全部自定义属性都来自当前主题,按前缀分成颜色、字号、间距、圆角、阴影、字体、动效、尺寸与层级。","designLab.tokens.themeDark":"暗","designLab.tokens.themeLight":"亮","designLab.tokens.title":"设计令牌","designLab.tokens.typeSample":"字体 Aa 123","designLab.tokens.typography":"字号","designLab.tokens.undefined":"未定义","designLab.gallery.autoNote":"页面自动收集 apps/web/src 下所有 *.preview.tsx(import.meta.glob 懒加载);新增一个文件即出现在对应分组(preview.group,缺省取目录名)。","designLab.gallery.count":"{count} 个","designLab.gallery.empty":"没有匹配的样例。","designLab.gallery.filter":"过滤样例","designLab.gallery.filterPlaceholder":"按标题、说明或源码路径过滤","designLab.gallery.loading":"正在加载样例…","designLab.gallery.none":"没有发现 *.preview.tsx 样例文件。","designLab.gallery.renderError":"这个样例渲染失败;其它样例不受影响。","designLab.gallery.sourcePath":"源码","designLab.gallery.subtitle":"组件、卡片与弹窗的活样例:每个 *.preview.tsx 一个样例,静态数据,不发任何请求。","designLab.gallery.title":"组件与弹窗","designLab.groups.chat":"会话流卡片","designLab.groups.nav":"导航与状态","designLab.groups.overlays":"弹窗与浮层","designLab.groups.ui":"基础组件","designLab.inventory.title":"组件清单","designLab.inventory.subtitle":"复用第一原则:新 UI 先查 components/ui 共享组件。单消费方 = 疑似一次性(应复用共享或退役候选);零消费方 = 退役候选。","designLab.inventory.snapshotNote":"数据为构建期快照({commit}):消费方计数不含样例;再生成运行 bun apps/web/scripts/gen-component-inventory.ts。","designLab.inventory.colComponent":"组件","designLab.inventory.colPurpose":"用途","designLab.inventory.colReuse":"复用度","designLab.inventory.colPreview":"预览","designLab.inventory.kind.component":"组件","designLab.inventory.kind.hook":"Hook","designLab.inventory.kind.util":"工具","designLab.inventory.reexport":"转口 plugin-ui","designLab.inventory.flagZero":"退役候选","designLab.inventory.flagSingle":"疑似一次性","designLab.inventory.flagShared":"共享中","designLab.inventory.previewCovered":"{count} 个样例","designLab.inventory.previewMissing":"缺预览","designLab.inventory.total":"共 {count} 个","designLab.inventory.shared":"共享中 {count}","designLab.inventory.single":"单消费方 {count}","designLab.inventory.zero":"零消费方 {count}","designLab.inventory.noPreview":"缺预览 {count}","designLab.inventory.purpose.Badge":"状态 / 标签徽标(tone 语义色)","designLab.inventory.purpose.Button":"统一按钮(variant / size)","designLab.inventory.purpose.CardShell":"卡片外壳(统一边框 / 背景 / 圆角)","designLab.inventory.purpose.CountBadge":"计数徽标(导航 / 列表角标)","designLab.inventory.purpose.DataTable":"语义数据表(排序 / 断点隐藏列)","designLab.inventory.purpose.EntityHeader":"实体页头(图标 / 标题 / 范围 / 动作)","designLab.inventory.purpose.Field":"表单字段(Input / Select / Textarea)","designLab.inventory.purpose.FilterPopover":"过滤浮层(表格列筛选)","designLab.inventory.purpose.Icon":"统一图标入口(名称 → SVG)","designLab.inventory.purpose.KeyValueList":"键值列表(详情展示)","designLab.inventory.purpose.MessageActions":"消息动作条(复制等)","designLab.inventory.purpose.MessageFold":"消息折叠 / 展开","designLab.inventory.purpose.RichComposer":"富输入器(提及 / 附件 / 原子块)","designLab.inventory.purpose.SearchInput":"搜索输入框","designLab.inventory.purpose.Section":"分区容器(标题 / 说明 / 动作)","designLab.inventory.purpose.SidebarShell":"侧栏壳(桌面侧栏 / 移动抽屉)","designLab.inventory.purpose.Stat":"统计数值卡","designLab.inventory.purpose.card-surface":"卡片表面样式常量","designLab.inventory.purpose.clipboard":"剪贴板写入工具","designLab.inventory.purpose.cn":"类名合并(clsx + tailwind-merge)","designLab.inventory.purpose.ghost-control":"幽灵控件样式常量","designLab.inventory.purpose.useEnteringItemKeys":"列表入场动画键 hook","designLab.inventory.purpose.useTypewriterText":"打字机文本 hook","designLab.preview.actionMenu.archive":"归档(不可用)","designLab.preview.actionMenu.delete":"删除","designLab.preview.actionMenu.desc":"行级菜单:方向键 / Home / End / Esc,点外部关闭并把焦点还给触发按钮。","designLab.preview.actionMenu.duplicate":"复制一份","designLab.preview.actionMenu.rename":"重命名","designLab.preview.agentMessage.desc":"agent 投递卡:卡头是「来自 agent」,展开体首行是来源地址与时刻;折叠时只有一行摘要。","designLab.preview.assistant.desc":"助手正文:Markdown 正文,复制按钮在正文下方左对齐,hover / 聚焦时才出现。","designLab.preview.badge.desc":"全部 tone:neutral、accent、info、warn、danger、success。","designLab.preview.badge.title":"Badge","designLab.preview.button.desc":"全部变体:plain、primary、danger、dangerGhost、link、chip。","designLab.preview.button.title":"Button","designLab.preview.chipTones.desc":"CHIP_TONES 一档一颗胶囊:muted、info、warn、ok、danger、band。胶囊的 tone 仍由状态派生,所以每颗出图用「该档的第一颗状态」;band 是 onBand 变体(不透明底 + ink 文字)。","designLab.preview.chipTones.note":"字形不随档变化,只有底与文字色变 —— 颜色始终不是唯一的含义载体。","designLab.preview.chipTones.onBandTitle":"band 档落在有色卡带上","designLab.preview.chipTones.title":"StatusChip 色档","designLab.preview.composerIcon.desc":"一个形状层(32px 正圆 + 凹陷底 + 强描边)配两档色调:primary 借主题色,quiet 静止灰、hover 转 ink;禁用态保留圆形,只把图标转灰。","designLab.preview.composerIcon.disabled":"禁用","designLab.preview.composerIcon.note":"左起:发送纸飞机(16px)、回形针(14px,墨迹与纸飞机同占地)、禁用态发送键。把鼠标停在可用的两颗上看 hover 档 —— 盒子不变,只有图标颜色变。","designLab.preview.composerIcon.sampleLabel":"样例 {tone} 图标按钮","designLab.preview.composerIcon.title":"Composer 图标按钮","designLab.preview.depthColor.title":"深度色板","designLab.preview.depthColor.desc":"会话卡地址子标题的树深度配色:色相 = (根色相 + 深度 × 步进) mod 360(黄金角轮转,无限不饱和),OKLCH 固定 L/C、浏览器原生 gamut 映射。读当前设置;两行分别是亮/暗档(深度 0–9),调参前后在此可视对比。","designLab.preview.depthColor.lightRow":"亮色档","designLab.preview.depthColor.darkRow":"暗色档","designLab.preview.depthColor.depthLabel":"深度 {depth}","designLab.preview.depthColor.params":"根色相 {rootHue}° · 步进 {hueStep}° · L/C 亮 {lLight}/{cLight} · 暗 {lDark}/{cDark}","designLab.preview.depthColor.disabled":"深度配色已关闭(地址档全部用主题强调色)","designLab.preview.depthColor.swatchLabel":"深度 {depth},色相 {hue}°","designLab.preview.confirm.body":"样例文案:确认后只关掉弹窗,不发起任何请求。","designLab.preview.confirm.dangerBody":"样例文案:危险色主按钮,需要用户明确确认。","designLab.preview.confirm.dangerConfirm":"删除","designLab.preview.confirm.dangerTitle":"删除这个会话?","designLab.preview.confirm.desc":"确认弹窗:初始焦点在「取消」,Enter 不会误触发危险动作。","designLab.preview.confirm.openDanger":"打开危险确认框","designLab.preview.confirm.openPlain":"打开确认框","designLab.preview.confirm.title":"保存这次修改?","designLab.preview.dataTable.colName":"名称","designLab.preview.dataTable.colOwner":"负责人","designLab.preview.dataTable.colStatus":"状态","designLab.preview.dataTable.desc":"行间 1px 间隙透出页面底色,整体小圆角;表头与末行的外角跟随圆角。","designLab.preview.dataTable.title":"DataTable","designLab.preview.cardShell.desc":"静态内容卡的统一表面:header(状态/标题)→ 卡体 → footer(操作)。无 hover 抬起;可点列表卡走 card-surface。","designLab.preview.cardShell.sampleAction":"查看详情","designLab.preview.cardShell.sampleBody":"异步作业卡 / 工具图片卡共用这一条 class 串与同一组槽位,避免各造一套表面样式漂移。","designLab.preview.cardShell.sampleStatus":"已完成","designLab.preview.cardShell.sampleTitle":"样例作业卡","designLab.preview.cardShell.title":"CardShell","designLab.preview.filterPopover.desc":"表头筛选:触发器 + 下拉面板,方向键导航;选项超过阈值(默认 8)时出搜索框。","designLab.preview.filterPopover.sampleLabel":"状态","designLab.preview.filterPopover.sampleSearch":"搜索选项","designLab.preview.filterPopover.title":"FilterPopover","designLab.preview.messageFold.desc":"超过阈值(--msg-fold-max-h)默认收起 + 底部渐隐 + 开合按钮;DOM 始终是全文(复制拿全文),流式中不折。","designLab.preview.messageFold.sample":`这是一段用于演示折叠的长消息。它超过阈值高度,因此默认收起,底部渐隐,并出现「展开全文」按钮。
|
|
278
|
+
|
|
279
|
+
折叠只改显示:max-height + overflow + mask,DOM 里始终是全文。复制按钮拿的是原文,鼠标手动选中也是同一份文本。
|
|
280
|
+
|
|
281
|
+
流式输出期间不裁切、不出按钮——否则正文每长一段就折/展一次。溢出判定只看 scrollHeight:裁切状态下它仍是内容全高。
|
|
282
|
+
|
|
283
|
+
阈值从 CSS 变量读(唯一来源),读不到时用与 tokens.css 同值的兜底。没有 ResizeObserver 时只按挂载时那一帧判定。
|
|
284
|
+
|
|
285
|
+
会话页用户气泡与团队页气泡共用这一个组件与同一套 class——不要各自复制一份阈值或宽度口径。
|
|
286
|
+
|
|
287
|
+
判定口径:有底色气泡包裹才折,纯正文不折。助手正文与卡片都不挂这个组件。
|
|
288
|
+
|
|
289
|
+
再补一段让高度足够超过阈值:设计实验室的样例都是只读静态数据,不发任何 RPC,断连时也能看。
|
|
290
|
+
|
|
291
|
+
最后一段:展开后按钮不会突然消失,也不会在展开/收起之间反复折。`,"designLab.preview.messageFold.title":"MessageFold","designLab.preview.sidebarShell.desc":"侧栏容器外壳:header(标题+动作)/ controls 行 / 可滚动 children;≤1023px 可选抽屉模式(本样例为普通列)。","designLab.preview.sidebarShell.sampleRow":"样例行 {index}","designLab.preview.sidebarShell.sampleSearch":"搜索会话","designLab.preview.sidebarShell.sampleTitle":"会话","designLab.preview.sidebarShell.title":"SidebarShell","designLab.preview.entityHeader.desc":"两个尺寸档并排:page = 22px 衬线(一屏唯一的 h1),panel = 16px 无衬线(面板标题)。改尺寸只碰字号与字族、不碰颜色;祖先永远更小更暗。","designLab.preview.entityHeader.sampleAction":"返回","designLab.preview.entityHeader.sampleDetails":"详情","designLab.preview.entityHeader.sampleNode":"样例节点","designLab.preview.entityHeader.sampleStatus":"已归档","designLab.preview.entityHeader.sampleTitle":"样例 Team","designLab.preview.entityHeader.title":"EntityHeader","designLab.preview.env.desc":"环境信息卡:卡头是 scope 标签(未生效时加 danger 文案)与条数,展开看上下文原文。","designLab.preview.failure.desc":"失败卡:折叠态只留红点 + 一行错误摘要;状态与 run id 都在展开体里,卡头不重复。两张卡各演示一态。","designLab.preview.form.desc":"表单标签、输入井与选择器;聚焦用焦点环,不用描边。","designLab.preview.form.fast":"快速","designLab.preview.form.mode":"模式","designLab.preview.form.name":"名称","designLab.preview.form.nameHint":"控件底色来自 --surface-sunken。","designLab.preview.form.namePlaceholder":"如 nightly-report","designLab.preview.form.thorough":"详尽","designLab.preview.form.title":"Field / Input / Select","designLab.preview.keyValue.desc":"两列定义列表,值可断行。","designLab.preview.keyValue.gateway":"网关","designLab.preview.keyValue.protocol":"协议","designLab.preview.keyValue.tenant":"标识","designLab.preview.keyValue.title":"KeyValueList","designLab.preview.mention.desc":"@ 补全列表:combobox 的 listbox,方向键移动 aria-activedescendant。","designLab.preview.mention.hint":"样例成员:悬停高亮;选中回调只改高亮,不发消息。","designLab.preview.modal.body":"样例正文:面板内部自己滚动,点遮罩也能关。","designLab.preview.modal.desc":"对话框壳:遮罩 + 居中面板 + Esc 关闭 + 焦点圈;sm / md / lg 三种宽度。","designLab.preview.modal.hint":"先选宽度,再打开。","designLab.preview.modal.open":"打开对话框","designLab.preview.modal.title":"对话框标题","designLab.preview.navItem.collapsed":"折叠态只留图标;悬停 300ms 出 Tooltip(标题 + 状态 + 计数 + 版本)。","designLab.preview.navItem.desc":"菜单按钮:分组头 + 四档状态点(accent / amber / danger / muted)+ 折叠态 + 分区开合动画。","designLab.preview.navItem.groupCollapsed":"收起态组头:聚合计数徽标(待批积压不因收起隐藏)+ 当前页所在组的 accent 圆点;展开时不重复显示。","designLab.preview.navItem.groupToggle":"点击组头开合分区:grid 0fr↔1fr 过渡 200ms(--motion-base),收起终态内容 inert,Tab 不落入隐藏项。","designLab.preview.navItem.plain":"没有状态信号的项:不渲染状态点,也不留占位版本号。","designLab.preview.navStatus.colStatus":"状态","designLab.preview.navStatus.colValue":"当前主题下的值","designLab.preview.navStatus.desc":"四档语义与颜色 token 对照:文案来自 nav-status.ts 的推导函数,圆点由 NavItem 自己渲染。","designLab.preview.navStatus.note":"Hub 在打开 WebUI 时就探测;未配置与未知都落 muted(--faint 是 NavItem 的默认圆点色)。hub / gateway / pluginHost 三个来源共用这同一套四档色。","designLab.preview.pageScaffold.desc":"标题 + 副标题 + 内容;页面头部只放这两行。","designLab.preview.pageScaffold.sampleBody":"内容从头部下方开始,间距由 PageScaffold 统一。","designLab.preview.pageScaffold.sampleSubtitle":"头部只放标题与副标题。","designLab.preview.pageScaffold.sampleTitle":"样例页面","designLab.preview.pageScaffold.title":"PageScaffold","designLab.preview.queued.desc":"排队卡:琥珀语义带 +「等待中」胶囊;圆形图标键(收回编辑 / 取消排队 / 我已处理)在正文下面一行、纯白 10% 半透明底;agent 源那张一颗键都不给。","designLab.preview.reasoning.desc":"思考卡:卡头是「思考过程」+ 左侧复制按钮 + 最右时刻;超过 12 行可展开,收字结束自动折叠。","designLab.preview.section.desc":"带标题、说明与可选动作的抬升面板。","designLab.preview.section.sampleBody":"内容与标题之间用间距分组,不画分隔线。","designLab.preview.section.sampleDesc":"说明文字:同一区域只叠一层表面。","designLab.preview.section.sampleTitle":"区块标题","designLab.preview.section.title":"Section","designLab.preview.stat.agents":"在线智能体","designLab.preview.stat.agentsHint":"当前节点","designLab.preview.stat.desc":"指标块:mono 数值配弱化标签。","designLab.preview.stat.runs":"活跃运行","designLab.preview.stat.runsHint":"最近 5 分钟","designLab.preview.stat.title":"Stat","designLab.preview.states.action":"新建","designLab.preview.states.desc":"空态、加载与错误态的统一样式。","designLab.preview.states.emptyDesc":"样例数据:创建第一条记录后会出现在这里。","designLab.preview.states.emptyTitle":"还没有内容","designLab.preview.states.error":"样例:请求失败,请检查网关连接。","designLab.preview.states.loading":"正在加载样例…","designLab.preview.states.title":"States","designLab.preview.statusIcons.chips":"完整形态(StatusChip:字形 + 文案 + 语义色底),即会话五种状态","designLab.preview.statusIcons.desc":"状态图标对照:每个 StatusKind 一行,给出字形、本地化文案与 API / 配置里使用的原始状态值。会话列表只用到其中五个(会话五态),其余来自运行、节点与插件状态。颜色只是增强,语义始终由字形 + 文案承担。","designLab.preview.statusIcons.list":"全部状态:字形、文案、原始值(API / 配置里的字面量)","designLab.preview.statusIcons.title":"StatusChip / StatusGlyph","designLab.preview.tabs.desc":"域内一级 tab,支持方向键切换。","designLab.preview.tabs.details":"详情","designLab.preview.tabs.history":"历史","designLab.preview.tabs.label":"样例标签页","designLab.preview.tabs.overview":"概览","designLab.preview.tabs.title":"SegmentedTabs","designLab.preview.tool.desc":"工具卡:卡头只有工具名与耗时,点开看描述 / 输入 / 输出;失败档折叠时也保留错误摘要。","designLab.preview.projection.desc":"投影卡(0.54):卡头 badge 常驻(折叠也看得见),卡体首段在「原文视角」与「模型视角」之间切换 —— 原文在正文里就默认原文,原文只剩事件日志时自动落模型视角并可读回;读回为空会降级成「原文已不可恢复」。","designLab.preview.toolbar.desc":"表格或 Section 正上方的控件条,筛选、搜索与批量动作都放这里。","designLab.preview.toolbar.label":"样例表格工具栏","designLab.preview.toolbar.placeholder":"筛选行","designLab.preview.toolbar.refresh":"刷新","designLab.preview.toolbar.title":"TableToolbar","designLab.preview.tooltip.bottom":"这是下方 Tooltip","designLab.preview.tooltip.bottomTrigger":"悬停看下方 Tooltip","designLab.preview.tooltip.desc":"轻提示:hover / 聚焦 300ms 后出现,Esc 关闭,空间不足自动翻到下方。","designLab.preview.tooltip.icon":"图标按钮的 Tooltip","designLab.preview.tooltip.label":"这是上方 Tooltip","designLab.preview.tooltip.trigger":"悬停看 Tooltip","designLab.preview.userBubble.desc":"用户气泡:气泡 + 附件 chip,时间在 hover 的元信息位(触屏常显)。","gateway.subtitle":"本浏览器当前连接的 gateway:端点、节点身份、版本与运行时长。","pluginHost.subtitle":"Marketplace 运行状态,以及本宿主加载插件所用的 registry。","nodes.subtitle":"本 gateway 可访问的节点,以及健康状态与负载计数。","nodes.detailActions":"节点操作","agents.subtitle":"跨已连接节点的 Agent,以及所属团队、状态与在线情况。","agents.edit.subtitle":"修改该 Agent 的名称、模型与系统提示词。","agents.detailActions":"Agent 操作","runs.subtitle":"所有已连接节点的实时运行与可恢复运行。","integrations.tools.subtitle":"模型可调用的工具及其审批策略。","integrations.mcp.subtitle":"本 gateway 连接的 MCP 服务及其工具可用性。","integrations.channels.subtitle":"外部渠道的连接状态与消息投递情况。","account.trigger.signedIn":"账号菜单:{user}","account.trigger.anonymous":"未登录:打开登录入口","account.panel":"账号","account.anonymous":"未登录","account.role":"角色:{role}","account.team":"团队:{team}","account.node.title":"当前节点","account.node.none":"还没有连接节点","account.node.switch":"切换节点","account.node.state.up":"在线","account.node.state.connecting":"连接中","account.node.state.down":"离线","account.node.state.unknown":"状态未知","account.auth.title":"登录方式","account.auth.relogin":"重新登录 / 切换账号","account.auth.empty":"这个部署没有启用登录方式。","account.auth.signOutFirst":"会先登出","account.settings":"设置","error.hint.unauthorized":`发生了什么:RPC 请求被网关拒绝(未认证)。
|
|
292
|
+
为什么:token 缺失、过期或与目标节点不匹配。
|
|
293
|
+
怎么修:在连接设置中重新输入正确 token;核对 vessel token list 指纹。
|
|
294
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.forbidden":`发生了什么:请求被权限策略拒绝。
|
|
295
|
+
为什么:token 权限级不足以调用该方法。
|
|
296
|
+
怎么修:换用权限足够的 token,或调整方法权限要求。
|
|
297
|
+
去哪看:vessel errors --id <error_id>;vessel doctor。`,"error.hint.not_found":`发生了什么:目标资源不存在。
|
|
298
|
+
为什么:id 错误或资源已删除。
|
|
299
|
+
怎么修:用对应列表核对 id;有候选时从候选中选。
|
|
300
|
+
去哪看:vessel errors --id <error_id> 看 details.candidates。`,"error.hint.invalid_params":`发生了什么:RPC 参数未通过校验。
|
|
301
|
+
为什么:缺必填字段、类型不符或互斥字段同给。
|
|
302
|
+
怎么修:vessel rpc list <method> 查 schema 修正参数。
|
|
303
|
+
去哪看:vessel errors --id <error_id> 看 details。`,"error.hint.data_locked":`发生了什么:数据被另一进程锁定。
|
|
304
|
+
为什么:另一实例持有同一 dataDir 的锁。
|
|
305
|
+
怎么修:vessel gateway ps 查进程,停重复实例或换 dataDir。
|
|
306
|
+
去哪看:vessel doctor(锁检查)。`,"error.hint.quota_exceeded":`发生了什么:配额超限。
|
|
307
|
+
为什么:达到平台/团队配额上限。
|
|
308
|
+
怎么修:核对配额配置或联系管理员提额。
|
|
309
|
+
去哪看:vessel errors --id <error_id> 看 details。`,"error.hint.conflict":`发生了什么:状态冲突,请求被拒。
|
|
310
|
+
为什么:并发修改或前置条件不满足。
|
|
311
|
+
怎么修:刷新状态后重试。
|
|
312
|
+
去哪看:vessel errors --id <error_id>;vessel status。`,"error.hint.internal":`发生了什么:网关内部错误。
|
|
313
|
+
为什么:服务端未分类异常。
|
|
314
|
+
怎么修:vessel logs tail 看日志;vessel doctor --errors 查漂移。
|
|
315
|
+
去哪看:vessel errors --id <error_id> 看 cause 链。`,"error.hint.not_supported":`发生了什么:网关不支持该能力。
|
|
316
|
+
为什么:目标构建过旧或能力未装配。
|
|
317
|
+
怎么修:升级目标 node/gateway;vessel rpc list 查可用方法。
|
|
318
|
+
去哪看:vessel errors --id <error_id> 看 details.method。`,"error.hint.expired":`发生了什么:凭证或会话已过期。
|
|
319
|
+
为什么:token/会话超过有效期。
|
|
320
|
+
怎么修:重新认证或轮换 token(vessel token rotate)。
|
|
321
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.run_ended":`发生了什么:run 已结束,无法再操作。
|
|
322
|
+
为什么:run 已完成/失败/取消。
|
|
323
|
+
怎么修:发起新 run,或恢复可恢复的 run(vessel --resume-run)。
|
|
324
|
+
去哪看:vessel errors --run <run_id>。`,"error.hint.session_not_found":`发生了什么:会话不存在。
|
|
325
|
+
为什么:session_id 错误或会话已删除/不在当前 dataDir。
|
|
326
|
+
怎么修:vessel --resume 列出会话再选;核对 dataDir/tenant。
|
|
327
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.compact_unavailable":`发生了什么:会话压缩不可用。
|
|
328
|
+
为什么:会话存储不支持 compact 或状态不足。
|
|
329
|
+
怎么修:升级到支持 timeline 的版本;或新开会话。
|
|
330
|
+
去哪看:vessel errors --id <error_id>;vessel doctor。`,"error.hint.gateway_restarting":`发生了什么:网关正在重启,请求暂被拒。
|
|
331
|
+
为什么:节点处于重启/drain 窗口。
|
|
332
|
+
怎么修:稍后重试(可重试);vessel node status 看进度。
|
|
333
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.no_active_run":`发生了什么:没有活跃 run。
|
|
334
|
+
为什么:操作要求活跃 run,但当前没有。
|
|
335
|
+
怎么修:先发起 run 再操作。
|
|
336
|
+
去哪看:vessel status;vessel errors --id <error_id>。`,"error.hint.run_mismatch":`发生了什么:run 不匹配。
|
|
337
|
+
为什么:请求 run_id 与当前活跃 run 不一致。
|
|
338
|
+
怎么修:核对 run_id(vessel status / runs.list)。
|
|
339
|
+
去哪看:vessel errors --run <run_id>。`,"error.hint.marker_failed":`发生了什么:run 标记写入失败。
|
|
340
|
+
为什么:run 存储写入异常(磁盘/权限)。
|
|
341
|
+
怎么修:检查 dataDir 磁盘与权限;vessel doctor。
|
|
342
|
+
去哪看:vessel errors --id <error_id> 看 cause 链。`,"error.hint.restart_reserve_failed":`发生了什么:重启预留失败。
|
|
343
|
+
为什么:重启名额被占用或状态不允许。
|
|
344
|
+
怎么修:vessel node status 查状态;稍后重试或 vessel gateway restart。
|
|
345
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.legacy_session_unsupported":`发生了什么:旧格式会话不被支持。
|
|
346
|
+
为什么:会话是 timeline 之前的旧格式。
|
|
347
|
+
怎么修:新开会话;旧数据仍在 dataDir 但此路径读不了。
|
|
348
|
+
去哪看:vessel errors --id <error_id>;vessel doctor。`,"error.hint.timeline_unavailable":`发生了什么:timeline 不可用。
|
|
349
|
+
为什么:timeline 存储未装配或读取失败。
|
|
350
|
+
怎么修:核对 dataDir 根布局(vessel doctor);升级/重启 gateway。
|
|
351
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.method_not_found":`发生了什么:未知 RPC 方法。
|
|
352
|
+
为什么:方法名错误或目标网关没有该方法。
|
|
353
|
+
怎么修:vessel rpc list 查可用方法;新方法需升级目标。
|
|
354
|
+
去哪看:vessel errors --id <error_id> 看 details.method。`,"error.hint.run_already_running":`发生了什么:run 已在运行,重复发起被拒。
|
|
355
|
+
为什么:同一会话已有活跃 run。
|
|
356
|
+
怎么修:等当前 run 结束或 vessel stop 取消后再发起。
|
|
357
|
+
去哪看:vessel status;vessel errors --id <error_id>。`,"error.hint.run_not_found":`发生了什么:run 不存在。
|
|
358
|
+
为什么:run_id 错误或记录已清理。
|
|
359
|
+
怎么修:核对 run_id(runs.list / vessel status)。
|
|
360
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.run_not_resumable":`发生了什么:run 不可恢复。
|
|
361
|
+
为什么:run 状态不满足恢复条件。
|
|
362
|
+
怎么修:发起新 run;vessel --resume 列出可恢复会话。
|
|
363
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.run_store_required":`发生了什么:需要 run 存储。
|
|
364
|
+
为什么:操作要求 durable run 存储但未装配。
|
|
365
|
+
怎么修:核对 run 存储配置(dataDir 布局);升级 gateway。
|
|
366
|
+
去哪看:vessel doctor;vessel errors --id <error_id>。`,"error.hint.agent_not_found":`发生了什么:agent 不存在。
|
|
367
|
+
为什么:成员 id 错误或已关闭。
|
|
368
|
+
怎么修:vessel agents 列出成员再选;有候选时从候选中选。
|
|
369
|
+
去哪看:vessel errors --id <error_id> 看 details.candidates。`,"error.hint.session_corrupt":`发生了什么:会话数据损坏。
|
|
370
|
+
为什么:会话文件损坏或格式异常。
|
|
371
|
+
怎么修:备份后新开会话;不要手工编辑会话文件。
|
|
372
|
+
去哪看:vessel errors --id <error_id> 看 cause 链。`,"error.hint.atomic_write_failed":`发生了什么:原子写入失败。
|
|
373
|
+
为什么:磁盘满、权限不足或文件被占用。
|
|
374
|
+
怎么修:检查 dataDir 磁盘与权限;重试(可重试)。
|
|
375
|
+
去哪看:vessel doctor;vessel errors --id <error_id>。`,"error.hint.limit_blocked":`发生了什么:被限额拦截。
|
|
376
|
+
为什么:达到 run 迭代/token 限额。
|
|
377
|
+
怎么修:调整限额配置或拆分任务。
|
|
378
|
+
去哪看:vessel errors --id <error_id> 看 details。`,"error.hint.empty_response_exhausted":`发生了什么:空响应重试耗尽。
|
|
379
|
+
为什么:模型连续多次返回空内容。
|
|
380
|
+
怎么修:vessel model test 测连通;换模型(vessel model set-default)。
|
|
381
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.invalid_input":`发生了什么:agent 输入非法。
|
|
382
|
+
为什么:请求字段缺失或格式不符。
|
|
383
|
+
怎么修:vessel rpc list <method> 查 schema 修正输入。
|
|
384
|
+
去哪看:vessel errors --id <error_id> 看 details。`,"error.hint.unknown_member":`发生了什么:未知成员。
|
|
385
|
+
为什么:成员 id 不在本团队名册。
|
|
386
|
+
怎么修:vessel agents 核对 id;有候选时从候选中选。
|
|
387
|
+
去哪看:vessel errors --id <error_id> 看 details.candidates。`,"error.hint.member_closed":`发生了什么:成员已关闭。
|
|
388
|
+
为什么:目标成员已被 release,不再接受消息。
|
|
389
|
+
怎么修:改向活跃成员发送,或重新创建成员。
|
|
390
|
+
去哪看:vessel agents;vessel errors --id <error_id>。`,"error.hint.member_stale":`发生了什么:成员状态过期。
|
|
391
|
+
为什么:引用的成员快照已不是最新。
|
|
392
|
+
怎么修:刷新成员列表(vessel agents)后重试。
|
|
393
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.member_not_visible":`发生了什么:成员不可见。
|
|
394
|
+
为什么:成员私有且不在你的可见范围。
|
|
395
|
+
怎么修:核对 id 与可见性;请所有者调整 visibility。
|
|
396
|
+
去哪看:vessel agents;vessel errors --id <error_id>。`,"error.hint.no_parent":`发生了什么:没有父 agent。
|
|
397
|
+
为什么:操作要求父级(如 hire),但当前成员无父。
|
|
398
|
+
怎么修:在有父级的上下文操作,或改用 create。
|
|
399
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.spawn_failed":`发生了什么:agent 启动失败。
|
|
400
|
+
为什么:启动 prompt 投递或 body 初始化失败(不回滚记录)。
|
|
401
|
+
怎么修:vessel errors --id <error_id> 看 cause 链定位根因后重试。
|
|
402
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.team_full":`发生了什么:团队已满。
|
|
403
|
+
为什么:成员数达到团队上限。
|
|
404
|
+
怎么修:关闭不需要的成员(agents.close)腾名额。
|
|
405
|
+
去哪看:vessel agents;vessel errors --id <error_id>。`,"error.hint.team_frozen":`发生了什么:团队已冻结。
|
|
406
|
+
为什么:团队冻结态不接受新操作。
|
|
407
|
+
怎么修:核对团队状态;解冻或改用其他团队。
|
|
408
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.invalid_state_transition":`发生了什么:非法状态迁移。
|
|
409
|
+
为什么:操作与成员/团队当前状态不兼容。
|
|
410
|
+
怎么修:刷新状态(vessel agents)后选合法操作。
|
|
411
|
+
去哪看:vessel errors --id <error_id> 看 details。`,"error.hint.budget_exceeded":`发生了什么:会话预算超限。
|
|
412
|
+
为什么:hops/turns/tokens/墙钟之一达到 teams[].budget 上限。
|
|
413
|
+
怎么修:调整 teams[].budget(maxHops/maxTurns/maxTokens/maxWallClockSeconds)或拆分任务。
|
|
414
|
+
去哪看:vessel errors --id <error_id> 看 details 维度。`,"error.hint.budget_unavailable":`发生了什么:预算存储不可用。
|
|
415
|
+
为什么:预算计数器存储读写失败。
|
|
416
|
+
怎么修:检查 dataDir 磁盘与权限;vessel doctor;重试。
|
|
417
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.conversation_team_mismatch":`发生了什么:会话与团队不匹配。
|
|
418
|
+
为什么:会话属于另一团队,不能跨团队续用。
|
|
419
|
+
怎么修:在会话所属团队内操作,或新开会话。
|
|
420
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.body_limit":`发生了什么:body 数量超限。
|
|
421
|
+
为什么:每个 agent 最多 1 个活 body。
|
|
422
|
+
怎么修:等当前 body 结束或关闭后再创建。
|
|
423
|
+
去哪看:vessel agents;vessel errors --id <error_id>。`,"error.hint.node_draining":`发生了什么:节点正在 drain。
|
|
424
|
+
为什么:节点排空窗口暂不接受新工作。
|
|
425
|
+
怎么修:稍后重试(可重试);vessel node status 看进度。
|
|
426
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.team_not_found":`发生了什么:团队不存在。
|
|
427
|
+
为什么:team_id 错误或团队已删除。
|
|
428
|
+
怎么修:核对 team_id(teams.list);有候选时从候选中选。
|
|
429
|
+
去哪看:vessel errors --id <error_id> 看 details.candidates。`,"error.hint.team_conversation_not_found":`发生了什么:团队会话不存在。
|
|
430
|
+
为什么:会话 id 错误或不属于该团队。
|
|
431
|
+
怎么修:核对会话 id 与团队归属;新建团队会话。
|
|
432
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.team_log_write_failed":`发生了什么:团队日志写入失败。
|
|
433
|
+
为什么:团队日志存储写入异常(磁盘/权限)。
|
|
434
|
+
怎么修:检查 dataDir 磁盘与权限;重试。
|
|
435
|
+
去哪看:vessel errors --id <error_id> 看 cause 链;vessel doctor。`,"error.hint.team_binding_requires_name":`发生了什么:团队绑定需要名称。
|
|
436
|
+
为什么:绑定操作缺必填 name 字段。
|
|
437
|
+
怎么修:补上 name 字段后重试。
|
|
438
|
+
去哪看:vessel errors --id <error_id>;vessel rpc list <method>。`,"error.hint.team_already_in_team":`发生了什么:成员已在团队中。
|
|
439
|
+
为什么:重复加入同一团队。
|
|
440
|
+
怎么修:无需重复加入;核对成员当前团队。
|
|
441
|
+
去哪看:vessel agents;vessel errors --id <error_id>。`,"error.hint.team_not_member":`发生了什么:不是团队成员。
|
|
442
|
+
为什么:操作要求成员身份,但调用者不在名册。
|
|
443
|
+
怎么修:先加入团队(teams.join)或改用有权限的成员。
|
|
444
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.team_private_member":`发生了什么:目标是私有成员。
|
|
445
|
+
为什么:私有成员不在团队可见范围。
|
|
446
|
+
怎么修:请所有者调整 visibility,或改用团队可见成员。
|
|
447
|
+
去哪看:vessel agents;vessel errors --id <error_id>。`,"error.hint.team_no_team":`发生了什么:没有团队上下文。
|
|
448
|
+
为什么:操作要求团队,但当前成员未绑定团队。
|
|
449
|
+
怎么修:先创建/加入团队再操作。
|
|
450
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.team_self_mention":`发生了什么:不能 @ 自己。
|
|
451
|
+
为什么:消息提及发送者自身,形成自环。
|
|
452
|
+
怎么修:改 @ 其他成员。
|
|
453
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.team_owner_not_rosterable":`发生了什么:所有者不可入册。
|
|
454
|
+
为什么:所有者身份不能当普通成员加入名册。
|
|
455
|
+
怎么修:改用非所有者成员执行该操作。
|
|
456
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.team_not_empty":`发生了什么:团队非空。
|
|
457
|
+
为什么:删除/归档要求团队无成员。
|
|
458
|
+
怎么修:先关闭/移出全部成员(agents.close)再删除。
|
|
459
|
+
去哪看:vessel agents;vessel errors --id <error_id>。`,"error.hint.team_archived":`发生了什么:团队已归档。
|
|
460
|
+
为什么:归档团队只读,不接受新操作。
|
|
461
|
+
怎么修:改用活跃团队;如需恢复请联系管理员。
|
|
462
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.not_visible":`发生了什么:资源不可见。
|
|
463
|
+
为什么:资源私有或不在你的可见范围。
|
|
464
|
+
怎么修:核对 id 与可见性;请所有者调整 visibility。
|
|
465
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.message_not_found":`发生了什么:消息不存在。
|
|
466
|
+
为什么:message_id 错误或消息已清理。
|
|
467
|
+
怎么修:核对 message_id(inbox / 团队日志)。
|
|
468
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.cursor_out_of_window":`发生了什么:游标超出窗口。
|
|
469
|
+
为什么:分页游标指向的事件已超出保留窗口。
|
|
470
|
+
怎么修:不带 since 重新列表取窗口内游标。
|
|
471
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.unknown_ref":`发生了什么:模型引用未知。
|
|
472
|
+
为什么:provider/model 引用不在模型注册表。
|
|
473
|
+
怎么修:vessel model list 查可用引用;vessel model set-default 设默认;有候选时从候选中选。
|
|
474
|
+
去哪看:vessel errors --id <error_id> 看 details.candidates;vessel doctor。`,"error.hint.pii_unknown_handle":`发生了什么:未知 PII 占位符。
|
|
475
|
+
为什么:handle 不存在或从未签发。
|
|
476
|
+
怎么修:核对 handle 来自本会话脱敏输出;不要猜测。
|
|
477
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.pii_expired_handle":`发生了什么:PII 占位符已过期。
|
|
478
|
+
为什么:handle 超过有效期。
|
|
479
|
+
怎么修:重新获取脱敏内容以取得新 handle。
|
|
480
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.pii_invalidated_handle":`发生了什么:PII 占位符已失效。
|
|
481
|
+
为什么:原值变更或会话结束,handle 作废。
|
|
482
|
+
怎么修:重新获取脱敏内容以取得新 handle。
|
|
483
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.pii_reveal_denied":`发生了什么:PII 还原被拒绝。
|
|
484
|
+
为什么:人工审批未通过或策略禁止。
|
|
485
|
+
怎么修:请求人工审批后重试;不要绕过。
|
|
486
|
+
去哪看:vessel errors --id <error_id>;权限日志。`,"error.hint.provider_auth":`发生了什么:模型供应商认证失败。
|
|
487
|
+
为什么:API key 缺失/无效/过期。
|
|
488
|
+
怎么修:vessel model credential set 配置凭证;核对 provider.apiKeyEnv 环境变量有值。
|
|
489
|
+
去哪看:vessel model test;vessel errors --id <error_id>。`,"error.hint.provider_rate_limit":`发生了什么:供应商限流。
|
|
490
|
+
为什么:请求频率超过供应商速率限制。
|
|
491
|
+
怎么修:稍后重试(可重试,自动退避);持续限流降并发或提额。
|
|
492
|
+
去哪看:vessel errors --id <error_id>;vessel logs tail。`,"error.hint.provider_quota_exceeded":`发生了什么:供应商配额耗尽。
|
|
493
|
+
为什么:账户配额/余额用尽。
|
|
494
|
+
怎么修:充值或提额;换模型(vessel model set-default)。
|
|
495
|
+
去哪看:vessel model test;vessel errors --id <error_id>。`,"error.hint.provider_timeout":`发生了什么:供应商请求超时。
|
|
496
|
+
为什么:模型响应超过超时阈值。
|
|
497
|
+
怎么修:重试(可重试);持续超时查网络或换模型。
|
|
498
|
+
去哪看:vessel model test;vessel errors --id <error_id>。`,"error.hint.provider_context_overflow":`发生了什么:上下文超长。
|
|
499
|
+
为什么:prompt 超过模型上下文窗口。
|
|
500
|
+
怎么修:压缩会话(compact)或新开会话;换更大上下文模型。
|
|
501
|
+
去哪看:vessel errors --id <error_id> 看 details。`,"error.hint.provider_unavailable":`发生了什么:供应商不可用。
|
|
502
|
+
为什么:供应商服务暂时不可用(5xx/维护)。
|
|
503
|
+
怎么修:稍后重试(可重试);持续不可用换模型。
|
|
504
|
+
去哪看:vessel model test;vessel errors --id <error_id>。`,"error.hint.provider_http_error":`发生了什么:供应商 HTTP 错误。
|
|
505
|
+
为什么:供应商返回非预期 HTTP 状态。
|
|
506
|
+
怎么修:vessel errors --id <error_id> 看 http_status 与 cause;核对 baseUrl 与凭证。
|
|
507
|
+
去哪看:vessel model test;vessel logs tail。`,"error.hint.provider_network":`发生了什么:供应商网络错误。
|
|
508
|
+
为什么:DNS/连接/TLS 等网络层失败。
|
|
509
|
+
怎么修:检查网络与代理;核对 provider.baseUrl;重试(可重试)。
|
|
510
|
+
去哪看:vessel model test;vessel errors --id <error_id>。`,"error.hint.provider_error":`发生了什么:供应商其他错误。
|
|
511
|
+
为什么:未归入上述子类的供应商错误。
|
|
512
|
+
怎么修:vessel errors --id <error_id> 看 cause 链定位;必要时上报。
|
|
513
|
+
去哪看:vessel logs tail;vessel model test。`,"error.hint.tool_timeout":`发生了什么:工具调用超时。
|
|
514
|
+
为什么:工具执行超过超时阈值。
|
|
515
|
+
怎么修:重试(可重试);拆分长任务或检查工具实现。
|
|
516
|
+
去哪看:vessel errors --id <error_id> 看 tool_name;vessel logs tail。`,"error.hint.tool_not_found":`发生了什么:工具不存在。
|
|
517
|
+
为什么:工具名错误或未装配。
|
|
518
|
+
怎么修:核对工具名与装配(tools 配置);有候选时从候选中选。
|
|
519
|
+
去哪看:vessel errors --id <error_id> 看 details.candidates。`,"error.hint.tool_invalid_arguments":`发生了什么:工具参数非法。
|
|
520
|
+
为什么:参数不符合工具 schema。
|
|
521
|
+
怎么修:按工具 schema 修正参数后重试。
|
|
522
|
+
去哪看:vessel errors --id <error_id> 看 details。`,"error.hint.tool_blocked":`发生了什么:工具被拦截。
|
|
523
|
+
为什么:权限策略禁止该工具调用。
|
|
524
|
+
怎么修:核对 permission.neverAutoApprove / 工具白名单;确需放行请调整策略。
|
|
525
|
+
去哪看:vessel errors --id <error_id>;权限日志。`,"error.hint.tool_error":`发生了什么:工具执行错误。
|
|
526
|
+
为什么:工具内部异常。
|
|
527
|
+
怎么修:vessel errors --id <error_id> 看 cause 链;修复工具或输入后重试。
|
|
528
|
+
去哪看:vessel logs tail;vessel errors --run <run_id>。`,"error.hint.permission_timeout":`发生了什么:权限审批超时。
|
|
529
|
+
为什么:无人值守审批超过等待窗口。
|
|
530
|
+
怎么修:调整 teams[].permission.unattended / denyAfterSeconds;或人工及时审批。
|
|
531
|
+
去哪看:vessel errors --id <error_id>;权限日志。`,"error.hint.permission_cancelled":`发生了什么:权限审批被取消。
|
|
532
|
+
为什么:审批请求被主动取消。
|
|
533
|
+
怎么修:重新发起操作并审批。
|
|
534
|
+
去哪看:vessel errors --id <error_id>。`,"error.hint.permission_denied":`发生了什么:权限被拒绝。
|
|
535
|
+
为什么:审批人拒绝或策略 deny。
|
|
536
|
+
怎么修:核对拒绝理由;调整操作或策略后重试,不要绕过。
|
|
537
|
+
去哪看:vessel errors --id <error_id>;权限日志。`,"error.hint.permission_error":`发生了什么:权限系统错误。
|
|
538
|
+
为什么:权限审批/策略执行内部异常。
|
|
539
|
+
怎么修:vessel errors --id <error_id> 看 cause 链;vessel doctor;持续出现请上报。
|
|
540
|
+
去哪看:vessel logs tail;权限日志。`,"error.hint.config_error":`发生了什么:配置错误。
|
|
541
|
+
为什么:配置校验失败或加载异常。
|
|
542
|
+
怎么修:按报错路径修正配置(vessel doctor 定位);vessel gateway reload 热加载。
|
|
543
|
+
去哪看:vessel doctor;vessel errors --id <error_id>。`,"error.hint.gateway_error":`发生了什么:网关错误。
|
|
544
|
+
为什么:网关层未细分异常。
|
|
545
|
+
怎么修:vessel logs tail 看日志;vessel doctor --errors;必要时 vessel gateway restart。
|
|
546
|
+
去哪看:vessel errors --id <error_id> 看 cause 链。`,"error.hint.internal_error":`发生了什么:内部错误。
|
|
547
|
+
为什么:未分类内部异常。
|
|
548
|
+
怎么修:vessel errors --id <error_id> 看 cause 链;vessel doctor --errors 查漂移;上报。
|
|
549
|
+
去哪看:vessel logs tail。`,"error.hint.checkpoint_failed":`发生了什么:检查点写入失败。
|
|
550
|
+
为什么:run 检查点落盘异常。
|
|
551
|
+
怎么修:检查 dataDir 磁盘与权限;重试(可重试);持续失败请上报。
|
|
552
|
+
去哪看:vessel errors --id <error_id>;vessel doctor。`},wc="vessel.ui.language",kc="zh-CN",di={"zh-CN":jx,en:Sx},yl=new Set;let Zr=null;function ui(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="en"||t.startsWith("en-")||t.startsWith("en_")?"en":t==="zh"||t.startsWith("zh-")||t.startsWith("zh_")?"zh-CN":null}function _x(e,t){return ui(e)??ui(t)??kc}function Sc(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Nx(){let e=null;try{e=Sc()?.getItem(wc)??null}catch{e=null}const t=typeof navigator>"u"?void 0:navigator.language??void 0;return _x(e,t)}function ss(){return Zr===null&&(Zr=Nx()),Zr}function jc(e,t){if(e!=="zh-CN"&&e!=="en")return;const n=ss()!==e;if(Zr=e,t?.persist!==!1)try{Sc()?.setItem(wc,e)}catch{}try{globalThis.document?.documentElement?.setAttribute?.("lang",e)}catch{}if(n)for(const s of[...yl])s()}function Yh(e){const t=ui(e);if(t===null)return;let n=null;try{n=Sc()?.getItem(wc)??null}catch{n=null}ui(n)===null&&jc(t,{persist:!1})}function Cx(e){return yl.add(e),()=>{yl.delete(e)}}function He(){return u.useSyncExternalStore(Cx,ss,ss)}function Tx(e,t){return t?e.replace(/\{(\w+)\}/g,(n,s)=>{const r=t[s];return r===void 0?n:String(r)}):e}function Jh(e){return di[ss()][e]!==void 0||di[kc][e]!==void 0}function a(e,t){const n=ss(),s=di[n][e]??di[kc][e]??e;return Tx(s,t)}const Ex={neutral:"bg-sunken text-muted",info:"bg-info-soft text-info",success:"bg-success-soft text-success",warn:"bg-warn-soft text-warn",error:"bg-danger-soft text-danger"};function Qh({items:e}){const t=u.useRef(null),n=e[e.length-1]?.id;return u.useEffect(()=>{if(n===void 0)return;const s=t.current;if(!s)return;const r=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;s.scrollTo({left:s.scrollWidth,behavior:r?"auto":"smooth"})},[n]),e.length===0?null:o.jsx("div",{ref:t,className:"message-bar-scroll flex min-w-0 items-center justify-start gap-2 overflow-x-auto py-1",role:"status","aria-live":"polite",children:e.map(s=>o.jsxs("div",{role:s.tone==="error"?"alert":void 0,className:be("message-chip flex flex-none items-center gap-1.5 rounded-full px-2.5 py-1 text-sm leading-tight pointer-coarse:min-h-touch",Ex[s.tone]),children:[o.jsx("span",{className:"size-1.5 flex-none rounded-full bg-current","aria-hidden":"true"}),s.tone==="error"&&s.hint!==void 0&&s.hint!==""?o.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[o.jsx("span",{className:"max-w-search overflow-hidden text-ellipsis whitespace-nowrap max-compact:max-w-40",title:s.text,children:s.text}),o.jsx("span",{className:"max-w-search text-xs leading-tight opacity-80",children:s.hint})]}):o.jsx("span",{className:"max-w-search overflow-hidden text-ellipsis whitespace-nowrap max-compact:max-w-40",title:s.hint??s.text,children:s.text}),s.actions&&s.actions.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"h-3 w-px flex-none bg-line-strong","aria-hidden":"true"}),s.actions.map(r=>o.jsx(G,{variant:"link",size:"small",className:"shrink-0 px-0.5 py-0 text-sm font-medium text-inherit decoration-1 underline-offset-2 hover:text-inherit",onClick:r.onClick,children:r.label},r.label))]}),s.onDismiss&&o.jsx("button",{type:"button",className:"-mr-0.5 flex size-5 flex-none items-center justify-center rounded-full bg-transparent text-base leading-none opacity-60 transition duration-150 hover:bg-hover hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 focus-visible:ring-offset-surface pointer-coarse:size-control","aria-label":a("common.closeNotice"),onClick:s.onDismiss,children:o.jsx("span",{"aria-hidden":"true",children:"×"})})]},s.id))})}const Xh=u.createContext(null);function Ix({register:e,children:t}){return o.jsx(Xh.Provider,{value:e,children:t})}function mi(e,t,n={}){const s=u.useContext(Xh),r=n.clearOnUnmount===!0;u.useEffect(()=>(s?.(e,t),()=>{r&&s?.(e,[])}),[s,e,t,r])}const _c=u.createContext(null),Zh=u.createContext(null),Rx={success:4e3,info:4e3,error:5e3},Sa=3;function ja(e,t){return`${e}\0${t}`}function Lx({children:e}){const[t,n]=u.useState([]),s=u.useRef(new Map),r=u.useRef(new Map),i=u.useRef([]),l=u.useCallback(h=>{const p=s.current.get(h);p!==void 0&&(window.clearTimeout(p),s.current.delete(h))},[]),c=u.useCallback(h=>{l(h);const p=i.current.find(g=>g.id===h);p&&r.current.delete(ja(p.kind,p.message)),i.current=i.current.filter(g=>g.id!==h),n(i.current)},[l]),d=u.useCallback((h,p)=>{const g=ja(h,p),b=r.current.get(g),x=b??crypto.randomUUID();l(x);let y=i.current;if(b===void 0&&(r.current.set(g,x),y=[...y,{id:x,kind:h,message:p}]),y.length>Sa){const j=y.slice(0,y.length-Sa);y=y.slice(-Sa);for(const _ of j)l(_.id),r.current.delete(ja(_.kind,_.message))}i.current=y,n(y);const v=window.setTimeout(()=>c(x),Rx[h]);s.current.set(x,v)},[l,c]);u.useEffect(()=>{const h=s.current;return()=>{for(const p of h.values())window.clearTimeout(p);h.clear()}},[]);const m=u.useMemo(()=>({success:h=>d("success",h),error:h=>d("error",h),info:h=>d("info",h),dismiss:c}),[d,c]),f=u.useMemo(()=>({items:t,dismiss:c}),[t,c]);return o.jsx(_c.Provider,{value:m,children:o.jsx(Zh.Provider,{value:f,children:e})})}function Ax(){const e=u.useContext(Zh);if(!e)throw new Error("useToastFeed must be used inside <ToastProvider>");return e}function ot(){const e=u.useContext(_c);if(!e)throw new Error("useToast must be used inside <ToastProvider>");return e}function $i(){return u.useContext(_c)}const uo=new Map,Mx=8;function Px(e){const t=new Map;for(const n of e){const s=n.agent_id??n.id;typeof s!="string"||s.length===0||t.set(s,n)}return t}function Nc(e){const t=[];for(const n of e){for(const s of n.agents??[])t.push(s);for(const s of n.rosters)for(const r of s.members)t.push(r)}return Px(t)}function nu(e,t){if(e===void 0||e.length===0||t.size===0)return;const n=new Set;let s=e;for(let r=0;r<Mx;r+=1){if(s===void 0||n.has(s))return;n.add(s);const i=t.get(s);if(i===void 0)return;const l=i.session_id;if(typeof l=="string"&&l.length>0)return l;s=i.parent_id}}function qx(e,t=uo){if(e.parentAgentId!==void 0&&e.parentAgentId.length>0){const s=nu(e.parentAgentId,t);if(s!==void 0)return s}const n=e.parentSessionId;if(!(n===void 0||n.length===0))return t.has(n)?nu(n,t):n}function ep(e,t=uo){const n=qx(e,t);if(e.parentSessionId!==void 0&&e.parentSessionId.length>0||e.parentAgentId!==void 0&&e.parentAgentId.length>0){const r=e.agentId!==void 0&&e.agentId.length>0?e.agentId:e.parentAgentId;return{kind:"agent",...r!==void 0&&r.length>0?{agentId:r}:{},...n!==void 0?{sessionId:n}:{}}}return e.sessionId!==void 0&&e.sessionId.length>0?{kind:"session",sessionId:e.sessionId}:{kind:"unknown"}}function Cc(e,t=uo){const n=ep(e,t);if(n.kind==="session"||n.kind==="agent")return n.sessionId}function tp(e,t,n){return t===null?!1:e.sessionId!==void 0&&e.sessionId.length>0?e.sessionId===t:n.has(e.runId)}function Ox(e){return e&&e!=="new"?e:null}function su(e,t){if(t.domain!=="chat")return[...e];const n=Ox(t.sessionId);if(!n)return[...e];const s=new Set;return e.filter(r=>!tp(r,n,s))}function Dx(e,t,n=uo){const s=[...e.map(c=>({at:c.requestedAt,rank:0,requestId:c.requestId,kind:"permission",request:c})),...t.map(c=>({at:c.requestedAt,rank:1,requestId:c.requestId,kind:"ask",request:c}))];s.sort(np);const r=s[0];if(!r)return{count:e.length+t.length,earliest:null};const i=ep(r.request,n),l=Cc(r.request,n);return{count:e.length+t.length,earliest:{kind:r.kind,requestId:r.requestId,runId:r.request.runId,...l!==void 0?{sessionId:l}:{},home:i,requestedAt:r.at}}}function Hx(e){const t=e.earliest?.home;return t===void 0?null:t.kind==="session"?{domain:"chat",sessionId:t.sessionId}:t.kind==="agent"?{domain:"pending",...t.sessionId!==void 0?{sessionId:t.sessionId}:{}}:null}function ou(e,t,n){return t?e.filter(s=>tp(s,t,n)):[]}function np(e,t){return e.at!==t.at?e.at-t.at:e.rank!==t.rank?e.rank-t.rank:e.requestId===t.requestId?0:e.requestId<t.requestId?-1:1}function $x(e,t){const n=[...e.map(s=>({at:s.requestedAt,rank:0,requestId:s.requestId,kind:"permission",request:s})),...t.map(s=>({at:s.requestedAt,rank:1,requestId:s.requestId,kind:"ask",request:s}))];return n.sort(np),n.flatMap(s=>{if(s.kind==="permission"){const l=s.request;return[{kind:"permission",request:l,key:`perm:${l.requestId}`}]}const r=s.request,i=Math.max(1,r.questions.length);return Array.from({length:i},(l,c)=>({kind:"ask",request:r,questionIndex:c,key:`${r.requestId}:${c}`}))})}const ru=e=>{let t;const n=new Set,s=(m,f)=>{const h=typeof m=="function"?m(t):m;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,p))}},r=()=>t,c={setState:s,getState:r,getInitialState:()=>d,subscribe:m=>(n.add(m),()=>n.delete(m))},d=t=e(s,r,c);return c},Fx=(e=>e?ru(e):ru),Bx=e=>e;function Kx(e,t=Bx){const n=ka.useSyncExternalStore(e.subscribe,ka.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return ka.useDebugValue(n),n}const iu=e=>{const t=Fx(e),n=s=>Kx(t,s);return Object.assign(n,t),n},vn=(e=>e?iu(e):iu),fi="vessel.gateway-url";function Tc(e){const n=(e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e).toLowerCase();return n==="localhost"||n==="::1"?!0:n.startsWith("127.")}function Fi(e,t="http:"){const n=e.trim();if(n==="")return{ok:!0,value:""};if(n==="*")return{ok:!1,value:"",error:a("gateway.url.wildcard")};let s;try{s=new URL(n)}catch{return{ok:!1,value:"",error:a("gateway.url.incomplete")}}const r=s.protocol.toLowerCase();if(r!=="http:"&&r!=="https:"&&r!=="ws:"&&r!=="wss:")return{ok:!1,value:"",error:a("gateway.url.scheme")};if(s.username!==""||s.password!=="")return{ok:!1,value:"",error:a("gateway.url.credentials")};if(s.pathname!=="/"||s.search!==""||s.hash!=="")return{ok:!1,value:"",error:a("gateway.url.path")};const i=r==="ws:"?"http:":r==="wss:"?"https:":r,l=`${i}//${s.host}`;return i==="http:"&&!Tc(s.hostname)?{ok:!1,value:"",error:a("gateway.url.https")}:t==="https:"&&i==="http:"?{ok:!1,value:"",error:a("gateway.url.mixed")}:{ok:!0,value:l}}function Wx(e,t,n="http:"){const s=e?.trim()??"";return s!==""?Fi(s,n):{ok:!0,value:""}}function Ec(e){return e.trim().replace(/\/+$/,"")}function sp(){const e=globalThis.location;return typeof e?.origin=="string"&&e.origin!==""?e.origin:""}function Yo(e,t){return`${Ec(e)}${t}`}function Ux(e){return e===""?"":e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e}function Pn(e,t){return e===""?t:e}const op="vessel.nodes",zx="vessel.node-token.";class Oo extends Error{constructor(t,n,s){super(n),this.code=t,this.status=s,this.name="NodeRpcError"}code;status}function An(e){return e.nodeId??e.name}function Ic(e){return`${zx}${e}`}function Vx(){return typeof window>"u"?"http:":window.location.protocol}function hr(){try{return typeof globalThis.sessionStorage>"u"?null:globalThis.sessionStorage}catch{return null}}function Gx(e,t){const n=e.trim();return n?t.some(s=>s.name===n)?"name_duplicate":null:"name_required"}function Yx(e,t,n=Vx()){const s=e.name.trim(),r=Gx(s,t);if(r)return{ok:!1,error:r};const i=Fi(e.url,n);if(!i.ok)return{ok:!1,error:"url_invalid",...i.error?{detail:i.error}:{}};const l=e.token.trim();return l?{ok:!0,value:{name:s,url:i.value,token:l}}:{ok:!1,error:"token_required"}}function yo(){const e=hr();if(!e)return[];try{const t=e.getItem(op);if(!t)return[];const n=JSON.parse(t);if(!Array.isArray(n))return[];const s=[],r=new Set;for(const i of n){if(!i||typeof i!="object")continue;const l=i.name,c=i.url,d=i.nodeId;typeof l!="string"||!l.trim()||typeof c!="string"||r.has(l)||(r.add(l),s.push({name:l,url:c,...typeof d=="string"&&d?{nodeId:d}:{}}))}return s}catch{return[]}}function au(e){const t=hr();if(t)try{t.setItem(op,JSON.stringify(e.map(n=>({name:n.name,url:n.url,...n.nodeId?{nodeId:n.nodeId}:{}}))))}catch{}}function Rc(e,t){const n=hr();if(n)try{n.setItem(Ic(e),t)}catch{}}function ei(e){const t=hr();if(!t)return null;try{const n=t.getItem(Ic(e));return n?.trim()?n:null}catch{return null}}function Qs(e){const t=hr();if(t)try{t.removeItem(Ic(e))}catch{}}function Jx(e){const t=e.trim().replace(/\/+$/,"");return t!==""?t:typeof window>"u"?"":window.location.origin}function Qx(e){return e===401?"unauthorized":e===403?"forbidden":e===404?"not_found":"internal"}async function Bi(e,t,n,s){const r=s?.trim()||ei(An(e))||"",i={"Content-Type":"application/json"};r!==""&&(i.Authorization=`Bearer ${r}`);let l;try{l=await fetch(`${Jx(e.url)}/v1/rpc`,{method:"POST",headers:i,body:JSON.stringify({v:1,id:crypto.randomUUID(),method:t,...n!==void 0?{params:n}:{}})})}catch(d){throw new Oo("network",d instanceof Error?d.message:String(d))}let c=null;try{c=await l.json()}catch{c=null}if(!l.ok||!c||c.ok!==!0){const d=c?.error?.code??Qx(l.status),m=c?.error?.message??`HTTP ${l.status}`;throw new Oo(d,m,l.status)}return c.result}async function Xx(e,t={},n){const s=await Bi(e,"interactions.list",t,n),r=Array.isArray(s?.interactions)?s.interactions:[];return{interactions:r,total:typeof s?.total=="number"?s.total:r.length,...typeof s?.next_cursor=="string"&&s.next_cursor.length>0?{next_cursor:s.next_cursor}:{}}}function ge(e){return e.nodeId??e.name}function rp(e){const t=e.code;if(typeof t=="string")return t;const n=e instanceof Error?e.message:String(e);return/^([a-z_]+):/.exec(n)?.[1]}const lu={status:"idle"};function Se(e){if(e&&(e.status==="success"||e.status==="loading"||e.status==="error"))return e.data}function ip(e){return e.status==="success"?{status:"loading",data:e.data}:e.status==="error"&&e.data!==void 0?{status:"loading",data:e.data}:{status:"loading"}}function xl(e,t=Date.now()){return{status:"success",data:e,updatedAt:t}}function Zx(e,t){const n=e.status==="success"||e.status==="loading"||e.status==="error"?e.data:void 0,s=e.status==="success"||e.status==="error"?e.updatedAt:void 0,r=typeof t=="string"?t:t.message,i=typeof t=="string"?void 0:t.code;return{status:"error",error:r,...i!==void 0?{code:i}:{},...n!==void 0?{data:n}:{},...s!==void 0?{updatedAt:s}:{}}}function cu(e,t){return e===t}function du(e,t,n="visible"){return!(!e||e<=0||t&&n==="hidden")}function Ft({load:e,enabled:t=!0,pollMs:n,pauseWhenHidden:s=!0,resyncOnVisible:r=!1,deps:i=[],initialData:l}){const[c,d]=u.useState(()=>l!==void 0?xl(l):lu),m=u.useRef(0),f=u.useRef(!0),h=u.useRef(c);h.current=c;const p=u.useRef(e);p.current=e;const g=u.useRef(void 0),b=JSON.stringify(i),x=u.useCallback(()=>{const v=++m.current;d(j=>ip(j)),p.current().then(j=>{!f.current||!cu(v,m.current)||d(xl(j))}).catch(j=>{if(!f.current||!cu(v,m.current))return;const _=j instanceof Error?j.message:String(j),S=rp(j);d(w=>Zx(w,S?{message:_,code:S}:_))})},[]),y=u.useCallback(()=>{t&&x()},[t,x]);return u.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),u.useEffect(()=>{if(window.clearInterval(g.current),g.current=void 0,!t){m.current+=1,d(lu);return}x();const v=document.visibilityState==="hidden"?"hidden":"visible";if(du(n,s,v)&&(g.current=window.setInterval(x,n)),!(s&&n)&&!r)return;const j=()=>{window.clearInterval(g.current),g.current=void 0,document.visibilityState!=="hidden"&&(x(),du(n,s,"visible")&&(g.current=window.setInterval(x,n)))};return document.addEventListener("visibilitychange",j),()=>{document.removeEventListener("visibilitychange",j),window.clearInterval(g.current),g.current=void 0}},[t,n,s,r,b,x]),{state:c,reload:y,refreshing:c.status==="loading"&&c.data!==void 0}}const Jo=new Map;function gn(e){const t=(Jo.get(e)??0)+1;return Jo.set(e,t),t}function kt(e,t){return Jo.get(e)===t}function rn(e){Jo.set(e,(Jo.get(e)??0)+1)}function Qo(e){return e===void 0?{status:"loading"}:ip(e)}function bs(e,t){const n=t instanceof Error?t.message:String(t),s=rp(t),r=e?.status==="success"||e?.status==="loading"||e?.status==="error"?e.data:void 0,i=e?.status==="success"||e?.status==="error"?e.updatedAt:void 0;return{status:"error",error:n,...s!==void 0?{code:s}:{},...r!==void 0?{data:r}:{},...i!==void 0?{updatedAt:i}:{}}}function qn(e){return xl(e)}function ew(){return typeof window>"u"?"":window.location.origin}function tw(e){return e.map(t=>({...t,current:!1}))}function nw(e){if(!e.hasToken)return null;const t=e.hello?.node;return{name:t?.name?.trim()||t?.node_id||Pn(e.nodeUrl,ew()),url:e.nodeUrl,...t?.node_id?{nodeId:t.node_id}:{},current:!0}}const Dt=vn()((e,t)=>({extras:[],nodes:[],current:null,health:{},selectedKey:null,setConnection:n=>{const s=nw(n),r=t().extras;e({current:s,nodes:s?[s,...r]:[...r]})},setExtras:n=>{const s=tw(n),r=t().current;e({extras:s,nodes:r?[r,...s]:[...s]})},setPlatformNodes:n=>{const s=n.map(r=>({...r}));e({extras:[],nodes:s,current:s.find(r=>r.current)??null})},addExtra:n=>{const r=[...t().extras.filter(l=>l.name!==n.name),{...n,current:!1}],i=t().current;e({extras:r,nodes:i?[i,...r]:[...r]})},removeExtra:n=>{const s=t().extras.filter(i=>i.name!==n),r=t().current;e({extras:s,nodes:r?[r,...s]:[...s]})},select:n=>e({selectedKey:n}),loadHealth:async(n,s)=>{if(n.length===0)return;const r=gn("node:health");e(l=>{const c={...l.health};for(const d of n){const m=ge(d);c[m]={node:d,...c[m]?.health?{health:c[m].health}:{}}}return{health:c}});const i=await Promise.all(n.map(async l=>{try{const c=await s(l);return{node:l,health:c,updatedAt:Date.now()}}catch(c){return{node:l,error:c instanceof Error?c.message:String(c)}}}));kt("node:health",r)&&e(l=>{const c={...l.health};for(const d of i)c[ge(d.node)]=d;return{health:c}})},reset:()=>{rn("node:health"),e({extras:[],nodes:[],current:null,health:{},selectedKey:null})}}));function Xo(e,t){return e[ge(t)]}function sw(e){const t=new Map;for(const[n,s]of Object.entries(e)){const r=s.health?.node.name?.trim();r&&t.set(n,r)}return t}function qt(e,t={}){const{enabled:n=!0,pollMs:s,pauseWhenHidden:r=!0,deps:i=[]}=t,l=u.useRef(e);l.current=e;const c=JSON.stringify(i);u.useEffect(()=>{if(!n||(l.current(),s===void 0||s<=0))return;let m=r&&document.visibilityState==="hidden"?void 0:window.setInterval(()=>l.current(),s);if(!r)return()=>window.clearInterval(m);const f=()=>{window.clearInterval(m),m=void 0,document.visibilityState!=="hidden"&&(l.current(),m=window.setInterval(()=>l.current(),s))};return document.addEventListener("visibilitychange",f),()=>{document.removeEventListener("visibilitychange",f),window.clearInterval(m)}},[n,s,r,c])}function Xt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function ap(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const s=n;!Xt(s.from_seq)||!Xt(s.to_seq)||s.to_seq<s.from_seq||t.push({from_seq:s.from_seq,to_seq:s.to_seq})}return t}function ow(e){if(typeof e!="object"||e===null)return;const t=e,n=t.start_seq,s=t.end_seq,r=t.count,i=t.timeline_head,l=t.wal_head;if(!(!Xt(n)||!Xt(s)||!Xt(r))&&!(!Xt(i)||!Xt(l)))return{start_seq:n,end_seq:s,count:r,timeline_head:i,wal_head:l,holes:ap(t.holes),tainted:t.tainted===!0,...t.reset===!0?{reset:!0}:{}}}function rw(e,t,n){return{...n!==void 0&&n!==""?{session_id:n}:{},...e.expectedCount!==void 0?{expected:e.expectedCount}:{},...e.receivedCount!==void 0?{received:e.receivedCount}:{},start_seq:e.from_seq,end_seq:e.to_seq,...t!==void 0?{after_timeline_seq:t}:{},...e.rule!==void 0?{check:e.rule}:{}}}function uu(e){if(typeof e!="object"||e===null)return;const t=e;if(!(!Xt(t.timeline_head)||!Xt(t.wal_head))&&!(t.timeline_head>t.wal_head))return{timeline_head:t.timeline_head,wal_head:t.wal_head,holes:ap(t.holes),tainted:t.tainted===!0,...Xt(t.published_head)?{published_head:Math.min(t.published_head,t.wal_head)}:{}}}function lp(e){const t=e.published_head??e.wal_head;return Math.min(e.wal_head,t)}function mo(e,t){for(const n of t)if(e>=n.from_seq&&e<=n.to_seq)return!0;return!1}function iw(e,t,n){let s=0;for(const r of n){const i=Math.max(e,r.from_seq),l=Math.min(t,r.to_seq);l>=i&&(s+=l-i+1)}return s}function aw(e,t,n=dw){const s=Number.isInteger(t)&&t>0?t:0,r=lp(e);if(s>e.wal_head)return{...no(e.wal_head>0?1:0,e.wal_head,e),reset:!0};if(s>=r)return;const i=s+1;let l=i-1,c=Math.max(1,Math.floor(n));for(let d=i;d<=r&&(l=d,!(!mo(d,e.holes)&&(c-=1,c<=0)));d+=1);return no(i,Math.min(l,e.wal_head),e)}function no(e,t,n){const s=Number.isInteger(e)?Math.max(0,e):0,r=Number.isInteger(t)?Math.max(s,t):s,i=n.holes.filter(l=>l.to_seq>=s&&l.from_seq<=r);return{start_seq:s,end_seq:r,count:r>=s?r-s+1-iw(s,r,i):0,timeline_head:n.timeline_head,wal_head:n.wal_head,holes:i,tainted:n.tainted}}function Lc(e){for(let t=e.start_seq;t<=e.end_seq;t+=1)if(!mo(t,e.holes))return t}function lw(e){for(let t=e.end_seq;t>=e.start_seq;t-=1)if(!mo(t,e.holes))return t}function cp(e,t){if(t.length===0)return;const n=Lc(e);if(n===void 0||t[0]!==n)return;let s=n;for(let r=0;r<t.length;r+=1){if(t[r]!==s)return;if(r===t.length-1)return s;let i=s+1;for(;i<=e.end_seq&&mo(i,e.holes);)i+=1;if(i>e.end_seq)return;s=i}}function mu(e,t){const n=e.start_seq,s=e.end_seq,r=(f,h,p,g)=>({from_seq:n,to_seq:s,source:"range",rule:f,expected:h,received:p,...g!==void 0?{expectedCount:g.expected,receivedCount:g.received}:{},at:Date.now()}),i=Lc(e),l=lw(e);if(i===void 0||l===void 0)return t.length===0?void 0:r(3,"0 条(整段已声明为洞)",`${t.length} 条`);const c=t[0],d=t[t.length-1];if(c!==i||d!==l)return r(3,`首 ${i} / 末 ${l}`,`首 ${String(c)} / 末 ${String(d)}`,{expected:e.count,received:t.length});let m=Number.NEGATIVE_INFINITY;for(const f of t){if(f===m)return r(4,"无重复 seq",`重复 seq=${f}`);if(f<m)return r(1,"严格升序",`${m} → ${f}`);if(m!==Number.NEGATIVE_INFINITY&&f!==m+1){let h=m+1;for(;h<f&&mo(h,e.holes);)h+=1;if(h!==f)return r(1,`接在 ${m} 之后的是 ${h}`,`实收 ${f}`)}m=f}if(t.length!==e.count)return r(2,`${e.count} 条`,`${t.length} 条`,{expected:e.count,received:t.length})}function cw(e){if(typeof e!="object"||e===null)return;const t=e;if(!(!Xt(t.seq)||t.seq<1)&&!(typeof t.type!="string"||t.type.length===0)&&!(typeof t.ts!="number"||!Number.isFinite(t.ts)))return{seq:t.seq,type:t.type,ts:t.ts,...typeof t.run_id=="string"?{run_id:t.run_id}:{},...t.data!==void 0?{data:t.data}:{}}}const dw=2e3,dp=2e3;function _a(e){return!Number.isInteger(e)||e<1?1:Math.max(1,e-dp+1)}function uw(e,t){const n=Number.isInteger(t)&&t>0?t:0;if(!(n<=1))return no(Math.max(1,n-dp),n-1,e)}const Na=200,up=1e3,Ca=500;async function mw(e,t,n=up){const s=[];let r=e.start_seq-1,i=0;const l=Math.ceil(e.count/Math.max(1,n))+2;for(;i<l&&r<e.end_seq;i+=1){let d;try{d=await t(r,n)}catch(f){return{events:s,pages:i,error:f instanceof Error?f.message:String(f)}}if(d.error!==void 0)return{events:s,pages:i,error:d.error};let m=r;for(const f of d.events)f.seq<=r||f.seq>e.end_seq||(s.push(f),f.seq>m&&(m=f.seq));if(m<=r||m>=e.end_seq||d.has_more!==!0)return{events:s,pages:i};r=m}return r>=e.end_seq&&i<l?{events:s,pages:i}:{events:s,pages:i,error:"page bound hit"}}function fw(e){const t=e.data;return{type:e.type,run_id:typeof e.run_id=="string"?e.run_id:"",ts:e.ts,data:typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}}function hw(e){return typeof e!="object"||e===null?!1:e.code==="invalid_params"}function fu(e){if(typeof e!="object"||e===null)return{events:[]};const t=e,n=[];for(const s of Array.isArray(t.events)?t.events:[]){const r=cw(s);r!==void 0&&n.push(r)}return{events:n,...Xt(t.next_seq)?{next_seq:t.next_seq}:{},...Xt(t.latest_seq)?{latest_seq:t.latest_seq}:{},...t.has_more===!0?{has_more:!0}:{}}}function hu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ki(e){return e==="error"||e==="guardrail.blocked"||e.endsWith(".failed")||e.endsWith(".error")}function mp(e){return e.startsWith("run.")?"run":e.startsWith("tool.")?"tool":e.startsWith("permission.")||e.startsWith("ask.")?"permission":e.startsWith("guardrail.")?"tool":"internal"}function pw(e,t,n){return n||t==="all"?!1:Ki(e)&&mp(e)==="internal"}function gw(e,t,n=!1){return!pw(e.type,t,n)}function ts(e){if(!hu(e))return;const t={},n=e.error_code??e.errorCode,s=e.category,r=e.phase,i=e.retryable,l=e.http_status??e.httpStatus;typeof n=="string"&&n.length>0&&(t.code=n),typeof s=="string"&&s.length>0&&(t.category=s),typeof r=="string"&&r.length>0&&(t.phase=r),typeof i=="boolean"&&(t.retryable=i),typeof l=="number"&&Number.isFinite(l)&&(t.httpStatus=l);const c=e.error_id??e.errorId;typeof c=="string"&&c.length>0&&(t.errorId=c);const d=hu(e.details)?e.details:void 0;if(d!==void 0&&Array.isArray(d.candidates)){const m=d.candidates.filter(f=>typeof f=="string"&&f.length>0);m.length>0&&(t.candidates=m)}return Object.keys(t).length>0?t:void 0}function Do(e){if(!e)return"";const t=[e.code,e.category,e.phase].filter(n=>typeof n=="string"&&n.length>0);return e.errorId!==void 0&&t.push(e.errorId),t.join(" · ")}const fp={"run.started":{tier:"content",live:!0,承接:"card"},"run.completed":{tier:"content",live:!0,承接:"card",teamLog:"reply"},"run.failed":{tier:"content",live:!0,承接:"card",teamLog:"system"},"run.cancelled":{tier:"content",live:!0,承接:"card",teamLog:"system"},"run.finalize.failed":{tier:"content",live:!0,承接:"notice"},"user.message":{tier:"content",live:!0,承接:"card"},"prompt.system_context":{tier:"content",live:!0,承接:"card"},"llm.stream.chunk":{tier:"content",live:!0,承接:"card"},"tool.call.started":{tier:"content",live:!0,承接:"card"},"tool.call.completed":{tier:"content",live:!0,承接:"card"},"tool.call.failed":{tier:"content",live:!0,承接:"card"},"guardrail.blocked":{tier:"content",live:!0,rawCard:!0},"guardrail.error":{tier:"content",live:!0,承接:"notice"},"agent.limit.warning":{tier:"content",live:!0,承接:"notice"},"agent.reply.stale":{tier:"content",live:!0,承接:"notice"},error:{tier:"internal",live:!1},"hook.failed":{tier:"internal",live:!0},"hook.error":{tier:"internal",live:!0},"hook.started":{tier:"internal",live:!0,承接:"notice"},"hook.completed":{tier:"internal",live:!0,承接:"notice"},"hook.system_prompt_ignored":{tier:"internal",live:!0,承接:"notice"},"hook.additional_context_deprecated":{tier:"internal",live:!0,承接:"notice"},"llm.request":{tier:"internal",live:!0},"llm.response":{tier:"internal",live:!0},"llm.stream.summary":{tier:"internal",live:!0},"llm.retry":{tier:"internal",live:!0},"llm.empty_response":{tier:"internal",live:!0},"run.checkpoint":{tier:"internal",live:!0},"run.resumed":{tier:"internal",live:!0},"context.changed":{tier:"internal",live:!0},"context.pressure":{tier:"internal",live:!0,承接:"notice"},"context.compacted":{tier:"internal",live:!0,承接:"notice"},"context.cleared_tool_result":{tier:"observe",live:!0,承接:"card"},"context.archive_notice":{tier:"observe",live:!0,承接:"card"},"context.projection_applied":{tier:"observe",live:!0},"context.projection_degraded":{tier:"observe",live:!0},"context.projection_pressure":{tier:"observe",live:!0},"timeline.gap_reported":{tier:"observe",live:!0},"message.injected":{tier:"internal",live:!0},"message.compaction":{tier:"internal",live:!0},"limit.blocked":{tier:"internal",live:!0},"prompt.prefix_changed":{tier:"internal",live:!0},"replay.started":{tier:"internal",live:!0},"replay.completed":{tier:"internal",live:!0},"session.saved":{tier:"internal",live:!0},"session.log.failed":{tier:"internal",live:!0},"process.error":{tier:"internal",live:!0},"shutdown.failed":{tier:"internal",live:!0},"trace.write.failed":{tier:"internal",live:!0},"trace.overflow":{tier:"internal",live:!0},"plugin.failed":{tier:"internal",live:!0},"plugin.init.failed":{tier:"internal",live:!0},"plugin.dispose.failed":{tier:"internal",live:!0},"runtime.notice":{tier:"internal",live:!0},"runtime.notice.injected":{tier:"observe",live:!0,承接:"card"},"team.budget.warning":{tier:"internal",live:!0},"team.budget.blocked":{tier:"internal",live:!0},"team.budget.override":{tier:"internal",live:!0},"agent.retired":{tier:"internal",live:!0,承接:"notice"},"agent.rotate.approved":{tier:"observe",live:!0},"agent.rotate.denied":{tier:"observe",live:!0},"agent.updated":{tier:"observe",live:!0,承接:"dto"},"agent.role.changed":{tier:"observe",live:!0,承接:"dto"},"agent.rejoined":{tier:"observe",live:!0,承接:"dto",teamLog:"system"},"agent.permission.cancelled":{tier:"observe",live:!0},"agent.spawned":{tier:"observe",live:!0,承接:"team-log",teamLog:"system"},"agent.closed":{tier:"observe",live:!0,承接:"team-log",teamLog:"system"},"agent.message.queued":{tier:"observe",live:!0},"agent.inbox.changed":{tier:"observe",live:!0},"bash.job.started":{tier:"observe",live:!0},"bash.job.completed":{tier:"observe",live:!0},"bash.job.failed":{tier:"observe",live:!0},"agent.message.notified":{tier:"observe",live:!1},"agent.message.sent":{tier:"observe",live:!1},"agent.stale":{tier:"observe",live:!0},"agent.permission.requested":{tier:"observe",live:!1},"agent.permission.responded":{tier:"observe",live:!1},"agent.session.activated":{tier:"observe",live:!0},"agent.queue.entered":{tier:"observe",live:!0},"agent.queue.left":{tier:"observe",live:!0},"agent.compact_forked":{tier:"internal",live:!1,承接:"notice"},"agent.restarting":{tier:"internal",live:!0,承接:"notice"},"agent.restarted":{tier:"internal",live:!0,承接:"notice"},"agent.create.failed":{tier:"internal",live:!0},"agent.forked":{tier:"observe",live:!1,承接:"team-log",teamLog:"system"},"session.created":{tier:"observe",live:!0},"session.activated":{tier:"observe",live:!1},"session.rewound":{tier:"observe",live:!1},"session.forked":{tier:"observe",live:!1},"session.titled":{tier:"observe",live:!0},"session.deleted":{tier:"observe",live:!0},"tool.permission.request":{tier:"observe",live:!0,承接:"card"},"tool.permission.response":{tier:"observe",live:!0,承接:"card"},"tool.permission.expired":{tier:"observe",live:!1,承接:"card"},"ask.user.requested":{tier:"observe",live:!0,承接:"card"},"ask.user.answered":{tier:"observe",live:!0,承接:"card"},"ask.user.timeout":{tier:"observe",live:!0,承接:"card"},"notify.user.requested":{tier:"observe",live:!0,承接:"card"},"notify.user.acked":{tier:"observe",live:!0,承接:"card"},"config.loaded":{tier:"observe",live:!0},"plugin.loaded":{tier:"observe",live:!0},"plugin.changed":{tier:"observe",live:!0},"update.available":{tier:"observe",live:!0},"rpc.result_invalid":{tier:"observe",live:!0},"federation.received":{tier:"observe",live:!0},"federation.rejected":{tier:"observe",live:!0},"guardrail.modified":{tier:"observe",live:!1},"mcp.server.connected":{tier:"observe",live:!0},"mcp.server.disconnected":{tier:"observe",live:!0},"mcp.resource.read":{tier:"observe",live:!0},"mcp.tool.called":{tier:"observe",live:!0},"mcp.warning":{tier:"observe",live:!0},"mcp.server.failed":{tier:"internal",live:!0},"mcp.tool.failed":{tier:"internal",live:!0},"channel.feishu.connected":{tier:"observe",live:!0},"channel.feishu.disconnected":{tier:"observe",live:!0},"channel.feishu.message.received":{tier:"observe",live:!0},"channel.feishu.reply.sent":{tier:"observe",live:!0},"channel.feishu.error":{tier:"internal",live:!0},"eval.run.started":{tier:"observe",live:!0},"eval.run.completed":{tier:"observe",live:!0},"delegate.started":{tier:"internal",live:!1},"delegate_task.started":{tier:"internal",live:!1},"delegate.completed":{tier:"internal",live:!1},"delegate.failed":{tier:"internal",live:!1}},hp=[{prefix:"subagent.",tier:"internal"},{prefix:"tool.call.",tier:"content"},{prefix:"mcp.",tier:"observe"},{prefix:"channel.feishu.",tier:"observe"},{prefix:"eval.run.",tier:"observe"},{prefix:"pii.",tier:"observe"}];function Ac(e){const t=fp[e];if(t!==void 0)return t.tier;for(const n of hp)if(e.startsWith(n.prefix))return n.tier}function bw(e){const t=fp[e];if(t!==void 0)return t;for(const n of hp)if(e.startsWith(n.prefix))return{tier:n.tier,live:!0}}function vw(e,t){if(e!=="message.injected"||t===null||typeof t!="object")return!1;const n=t.message;if(n===null||typeof n!="object")return!1;const{name:s,message_id:r,content:i}=n;return!(typeof s!="string"||!s.startsWith("vessel:")||typeof r!="string"||r.length===0||typeof i!="string"||i.trim().length===0)}function yw(e,t,n){if(n!==void 0&&vw(e,n))return!0;const s=Ac(e);return s==="observe"?!1:s==="content"||t.showInternal?!0:(t.errorLevel??"user")==="all"&&Ki(e)&&mp(e)==="internal"}function wl(e){const t={runId:e,status:"running",hasRunEvent:!1,items:[]};let n="",s=0,r,i,l,c="",d=0,m,f,h;const p=[],g=()=>{if(n){const E={kind:"text",text:n,key:`text-${e}-${s}`,segmentIndex:s++,...r!==void 0?{startedAt:r}:{},...i!==void 0?{endedAt:i}:{},...l!==void 0?{anchorSeq:l}:{}};t.items.push(E),p.push(E),n="",r=void 0,i=void 0,l=void 0}},b=()=>{if(c){const E={kind:"reasoning",text:c,key:`reasoning-${e}-${d++}`,...m!==void 0?{startedAt:m}:{},...f!==void 0?{endedAt:f}:{},...h!==void 0?{anchorSeq:h}:{}};t.items.push(E),p.push(E),c="",m=void 0,f=void 0,h=void 0}};let x;const y=()=>{x&&(t.items.push({kind:"notice",event:x.event,key:x.key,anchorSeq:x.seq}),x=void 0)},v=()=>{y(),b(),g()},j=[],_=new Map;return{runId:e,get itemCount(){return t.items.length},apply:E=>{const I=E.event;t.firstTs===void 0&&(t.firstTs=I.ts),t.firstSeq===void 0&&(t.firstSeq=E.seq),(t.lastTs===void 0||I.ts>t.lastTs)&&(t.lastTs=I.ts),E.jobId&&(t.jobId=E.jobId);const $=I.data.run_id;if(typeof $=="string"&&$===I.run_id&&(t.hasRunEvent=!0),t.sessionId===void 0)if(E.sessionId!==void 0&&E.sessionId.length>0)t.sessionId=E.sessionId;else{const C=I.data;typeof C.session_id=="string"&&C.session_id.length>0&&(t.sessionId=C.session_id)}switch(I.type){case"run.started":{const C=I.data;t.input=C.input,t.inputName===void 0&&typeof C.input_name=="string"&&C.input_name.length>0&&(t.inputName=C.input_name),C.session_id!==void 0&&(t.sessionId=C.session_id),t.startedAt=I.ts;return}case"run.completed":{v();const C=I.data;t.output=C.output,t.durationMs=C.duration_ms,t.iterations=C.iterations,t.status="completed",t.completedAt=I.ts,t.error=void 0,t.errorMeta=void 0,delete t.reconciled;return}case"run.failed":{v();const C=I.data;t.error=C.error,t.errorMeta=ts(I.data),t.durationMs=C.duration_ms,t.status="failed",t.completedAt=I.ts,delete t.reconciled;return}case"run.cancelled":{v();const C=I.data;t.durationMs=C.duration_ms,t.status="cancelled",t.completedAt=I.ts,delete t.reconciled;return}case"user.message":{const C=I.data,L=typeof C.message=="object"&&C.message!==null&&!Array.isArray(C.message)?C.message:void 0;if(t.inputName===void 0&&L!==void 0){const A=L.name;typeof A=="string"&&A.length>0&&(t.inputName=A)}if(L?.role==="user"&&typeof L.content=="string"&&L.content.length>0?t.input=L.content:typeof C.content=="string"&&C.content.length>0&&(t.input=C.content),t.inputRefs===void 0&&L!==void 0){const A=Sw(L.refs);A.length>0&&(t.inputRefs=A)}if(t.inputMessageId===void 0&&L!==void 0){const A=L.message_id;typeof A=="string"&&A.length>0&&(t.inputMessageId=A)}t.sessionId===void 0&&typeof C.session_id=="string"&&(t.sessionId=C.session_id);return}case"context.pressure":case"context.compacted":case"context.cleared_tool_result":case"agent.limit.warning":case"agent.restarting":case"agent.restarted":case"agent.compact_forked":case"hook.system_prompt_ignored":case"hook.additional_context_deprecated":{v(),t.items.push({kind:"notice",event:I,key:`notice-${E.seq}`,anchorSeq:E.seq});return}case"run.finalize.failed":case"guardrail.error":{v(),t.items.push({kind:"notice",event:I,key:`notice-${E.seq}`,anchorSeq:E.seq});return}case"agent.retired":case"agent.reply.stale":{v(),t.items.push({kind:"notice",event:I,key:`notice-${E.seq}`,anchorSeq:E.seq});return}case"hook.started":{v();const C=I.data.hook_name;x={event:I,key:`notice-${E.seq}`,name:typeof C=="string"?C:"",seq:E.seq};return}case"hook.completed":{const C=I.data.hook_name;typeof C=="string"&&x?.name===C&&(x=void 0),v(),t.items.push({kind:"notice",event:I,key:`notice-${E.seq}`,anchorSeq:E.seq});return}case"tool.call.started":{v();const C=bu(I.data),L=vu(I.data)??gu;t.items.push({kind:"tool",key:`ev-${E.seq}`,...C!==void 0?{callId:C}:{},name:L,status:"running",...I.data.arguments!==void 0?{args:I.data.arguments}:{},...I.data.truncated===!0?{truncated:!0}:{},startedAt:I.ts,anchorSeq:E.seq}),j.push({index:t.items.length-1,callId:C,name:L}),C!==void 0&&_.set(C,t.items.length-1);return}case"tool.call.completed":case"tool.call.failed":{v();const C=I.type==="tool.call.completed",L=bu(I.data),A=vu(I.data),D=ww(I.data),O=I.data.truncated===!0,F=kw(j,L,A),V=L!==void 0?_.get(L)??-1:-1,B=F>=0?F:V,W=B>=0?t.items[B]:void 0;if(W!==void 0&&W.kind==="tool"){t.items[B]={...W,status:C?"done":"error",...W.callId===void 0&&L!==void 0?{callId:L}:{},...C?{result:I.data.result}:{},...C?{}:{error:yu(I.data),errorMeta:ts(I.data)},...D!==void 0?{durationMs:D}:{},...O?{truncated:!0}:{}};return}t.items.push({kind:"tool",key:`ev-${E.seq}`,...L!==void 0?{callId:L}:{},name:A??gu,status:C?"done":"error",...C?{result:I.data.result}:{},...C?{}:{error:yu(I.data),errorMeta:ts(I.data)},...D!==void 0?{durationMs:D}:{},...O?{truncated:!0}:{},startedAt:I.ts,anchorSeq:E.seq}),L!==void 0&&_.set(L,t.items.length-1);return}case"llm.stream.chunk":{if(t.reconciled!==void 0)return;const C=I.data.chunk;C?.type==="text_delta"&&C.delta?(b(),r===void 0&&(r=I.ts),l===void 0&&(l=E.seq),i=I.ts,n+=C.delta):C?.type==="reasoning_delta"&&C.delta?(g(),m===void 0&&(m=I.ts),h===void 0&&(h=E.seq),f=I.ts,c+=C.delta):C?.type==="finish"&&v();return}case"llm.response":{const C=I.data.message_id;if(v(),typeof C=="string"&&C.length>0)for(const L of p){const A=t.items.indexOf(L);A>=0&&(t.items[A]={...L,messageId:C})}p.length=0,t.items.push({kind:"event",event:I,key:`ev-${E.seq}`,anchorSeq:E.seq});return}default:v(),bw(I.type)===void 0?t.items.push({kind:"notice",event:I,key:`unknown-${E.seq}`,anchorSeq:E.seq}):t.items.push({kind:"event",event:I,key:`ev-${E.seq}`,anchorSeq:E.seq})}},toGroup:()=>{const E={...t,items:[...t.items]};return x!==void 0&&E.items.push({kind:"notice",event:x.event,key:x.key,anchorSeq:x.seq}),c&&(E.liveReasoning=c,h!==void 0&&(E.liveReasoningAnchorSeq=h)),n&&(E.liveText=n,l!==void 0&&(E.liveTextAnchorSeq=l),E.liveTextSegmentIndex=s),E},summary:()=>({status:t.status,hasRunEvent:t.hasRunEvent,...t.sessionId!==void 0?{sessionId:t.sessionId}:{},...t.startedAt!==void 0?{startedAt:t.startedAt}:{},...t.firstTs!==void 0?{firstTs:t.firstTs}:{},...t.lastTs!==void 0?{lastTs:t.lastTs}:{}}),trim:E=>{const I=t.items.splice(0,Math.max(0,t.items.length-Math.max(0,E)));if(I.length===0)return{removed:0};for(const L of j)L.index-=I.length;for(let L=j.length-1;L>=0;L-=1)(j[L]?.index??-1)<0&&j.splice(L,1);for(const[L,A]of[..._]){const D=A-I.length;D<0?_.delete(L):_.set(L,D)}const $=I[0]?.anchorSeq,C=I[I.length-1]?.anchorSeq;return{removed:I.length,...$!==void 0?{fromSeq:$}:{},...C!==void 0?{toSeq:C}:{}}},drop:E=>{if(E.size===0)return 0;const I=[],$=new Map;t.items.forEach((L,A)=>{(L.kind==="text"||L.kind==="reasoning")&&L.anchorSeq!==void 0&&E.has(L.anchorSeq)||($.set(A,I.length),I.push(L))});const C=t.items.length-I.length;if(C===0)return 0;t.items.splice(0,t.items.length,...I);for(const L of j)L.index=$.get(L.index)??-1;for(let L=j.length-1;L>=0;L-=1)(j[L]?.index??-1)<0&&j.splice(L,1);for(const[L,A]of[..._]){const D=$.get(A);D===void 0?_.delete(L):_.set(L,D)}return C},close:(E,I,$)=>t.status!=="running"?!1:(v(),t.status=E,t.completedAt=I,t.startedAt!==void 0&&(t.durationMs=Math.max(0,I-t.startedAt)),$?.error!==void 0&&(t.error=$.error),$?.via!==void 0&&(t.reconciled=$.via),!0)}}function xw(e,t){const n=wl(e);for(const s of t)n.apply(s);return n.toGroup()}function pu(e){if(e.type!=="llm.stream.chunk")return!0;const t=e.data?.chunk;return t?.type!=="text_delta"&&t?.type!=="reasoning_delta"?!1:typeof t.delta=="string"&&t.delta.length>0}const gu="tool";function bu(e){const t=e.tool_call_id;return typeof t=="string"&&t.length>0?t:void 0}function vu(e){const t=e.tool_name;return typeof t=="string"&&t.length>0?t:void 0}function ww(e){const t=e.duration_ms;return typeof t=="number"?t:void 0}function yu(e){const t=e.error;return typeof t=="string"?t:t===void 0?"":String(t)}function kw(e,t,n){if(t!==void 0){const i=e.findIndex(c=>c.callId===t),l=i>=0?e.splice(i,1)[0]:void 0;if(l!==void 0)return l.index}if(n===void 0)return-1;const s=e.findIndex(i=>i.name===n&&(t===void 0||i.callId===void 0));return(s>=0?e.splice(s,1)[0]:void 0)?.index??-1}function Sw(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=32)break;if(typeof n!="object"||n===null)continue;const s=n,r=s.kind,i=s.path;if(r!=="file"&&r!=="image"&&r!=="document"||typeof i!="string"||i.length===0)continue;const l={kind:r,path:i};typeof s.name=="string"&&(l.name=s.name),typeof s.mime=="string"&&(l.mime=s.mime),typeof s.bytes=="number"&&Number.isFinite(s.bytes)&&s.bytes>=0&&(l.bytes=Math.floor(s.bytes)),t.push(l)}return t}function jw(e,t,n="user"){return yw(e.event.type,{showInternal:t,errorLevel:n},e.event.data)}function _w(e){let t=Number.NEGATIVE_INFINITY,n=!1,s=0,r;for(const i of e){const l=i.event.ts;Number.isFinite(l)&&l>0&&(n&&l<t&&(s+=1,r===void 0&&(r=`seq ${String(i.seq)} ts ${String(l)} < ${String(t)}`)),t=l,n=!0)}return s===0?[...e]:(console.warn("[timeline] seq order != event time order",{inversions:s,entries:e.length,first:r}),e.map((i,l)=>({entry:i,index:l})).sort((i,l)=>{const c=i.entry.event.ts,d=l.entry.event.ts,m=Number.isFinite(c)&&c>0,f=Number.isFinite(d)&&d>0;return m&&f&&c!==d?c-d:m!==f?m?-1:1:i.index-l.index}).map(i=>i.entry))}function Nw(e){return e.startsWith("tool.call.")?e.endsWith(".failed")?{label:"tool.fail",cls:"tag-tool-fail"}:e.endsWith(".completed")?{label:"tool.ok",cls:"tag-tool-done"}:{label:"tool",cls:"tag-tool-start"}:e.startsWith("guardrail.")?{label:e,cls:"tag-guard"}:e.startsWith("llm.")?{label:e,cls:"tag-llm"}:e==="error"?{label:"error",cls:"tag-error"}:{label:e,cls:"tag-raw"}}const Cw=2e3,Tw=2e4,Ew=200,Iw=20,Rw=0,Lw="vessel.ui.condensed";function Aw(){return{groups:[],version:0,stats:{refolds:0,replaySkipped:0,condensed:0,released:0,releasedRuns:0,reconciled:0,overBudget:!1}}}function Mw(e,t){return(e.anchorSeq??Number.MAX_SAFE_INTEGER)-(t.anchorSeq??Number.MAX_SAFE_INTEGER)}function Pw(e,t){const n={...e,hasRunEvent:e.hasRunEvent||t.hasRunEvent,...e.jobId===void 0&&t.jobId!==void 0?{jobId:t.jobId}:{},...e.sessionId===void 0&&t.sessionId!==void 0?{sessionId:t.sessionId}:{},...e.input===void 0&&t.input!==void 0?{input:t.input}:{},...e.inputName===void 0&&t.inputName!==void 0?{inputName:t.inputName}:{},...e.inputRefs===void 0&&t.inputRefs!==void 0?{inputRefs:t.inputRefs}:{},...e.startedAt===void 0&&t.startedAt!==void 0?{startedAt:t.startedAt}:{},...e.firstTs===void 0&&t.firstTs!==void 0?{firstTs:t.firstTs}:{},...e.firstSeq===void 0&&t.firstSeq!==void 0?{firstSeq:t.firstSeq}:{},...e.lastTs===void 0&&t.lastTs!==void 0?{lastTs:t.lastTs}:{}};return e.status!=="running"||t.status==="running"?n:{...n,status:t.status,...n.output===void 0&&t.output!==void 0?{output:t.output}:{},...n.error===void 0&&t.error!==void 0?{error:t.error}:{},...n.errorMeta===void 0&&t.errorMeta!==void 0?{errorMeta:t.errorMeta}:{},...n.completedAt===void 0&&t.completedAt!==void 0?{completedAt:t.completedAt}:{},...n.durationMs===void 0&&t.durationMs!==void 0?{durationMs:t.durationMs}:{},...n.iterations===void 0&&t.iterations!==void 0?{iterations:t.iterations}:{}}}function qw(e,t,n){const s={type:Lw,run_id:e,ts:n??0,data:{run_id:e,count:t.count,...t.fromSeq!==void 0?{from_seq:t.fromSeq}:{},...t.toSeq!==void 0?{to_seq:t.toSeq}:{}}};return{kind:"notice",key:`run:${e}:condensed:${t.fromSeq??0}`,event:s,...t.fromSeq!==void 0?{anchorSeq:t.fromSeq}:{}}}function Ow(e,t){return t.startsWith(`run:${e}:condensed:`)}function Dw(e,t){return t.kind!=="text"&&t.kind!=="reasoning"?!1:t.anchorSeq!==void 0&&e.anchors.has(t.anchorSeq)}class Hw{folds=new Map;groups=new Map;kept=new Map;bases=new Map;condensed=new Map;released=new Map;releasedRuns=new Set;sessionClosed=new Map;closedRuns=new Map;dirty=new Set;listeners=new Set;stats={refolds:0,replaySkipped:0,condensed:0,released:0,releasedRuns:0,reconciled:0,overBudget:!1};snapshot=Aw();version=0;ingestedSeq=0;frozen=!1;structureDirty=!1;overBudget=!1;showInternal;errorLevel;maxItemsPerRun;maxItemsTotal;constructor(t={}){this.showInternal=t.showInternal??!1,this.errorLevel=t.errorLevel??"user",this.maxItemsPerRun=t.maxItemsPerRun??Cw,this.maxItemsTotal=t.maxItemsTotal??Tw}subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t));getSnapshot=()=>this.snapshot;get view(){return{showInternal:this.showInternal,errorLevel:this.errorLevel}}ingest(t){if(this.frozen)return;if(t.seq<=this.ingestedSeq){this.stats.replaySkipped+=1;return}if(this.ingestedSeq=t.seq,this.reconcileLifecycle(t),!this.visible(t))return;const n=t.event.run_id;let s=this.folds.get(n),r=!1;s===void 0&&(s=wl(n),this.folds.set(n,s),this.structureDirty=!0,r=!0),s.apply(t),(this.closedRuns.has(n)||r&&this.sessionClosed.size>0)&&this.applyCloses(n,s),this.dirty.add(n)}freeze(){this.frozen=!0}resume(t){this.frozen=!1,this.refold(t,!0),this.flush()}setVisibility(t,n,s){this.showInternal===t&&this.errorLevel===n||(this.showInternal=t,this.errorLevel=n,this.refold(s,!1),this.flush())}release(t){let n=0;for(const[s,r]of t){const i=this.released.get(s)??{anchors:new Set};for(const c of r.segments)i.anchors.add(c);if(this.released.set(s,i),i.anchors.size===0)continue;this.releasedRuns.add(s);const l=this.folds.get(s);l!==void 0&&(n+=l.drop(i.anchors)),this.dirty.add(s)}this.stats.released+=n,this.stats.releasedRuns=this.releasedRuns.size,this.flush()}closeRuns(t,n){const s=n.notAfter??n.at,r=n.runIds===void 0?void 0:new Set(n.runIds);if(r===void 0){const c=this.sessionClosed.get(t);(c===void 0||n.at>=c.at)&&this.sessionClosed.set(t,{at:n.at,via:n.via,status:n.status,...n.error!==void 0?{error:n.error}:{}})}const i=[];for(const[c,d]of this.folds){const m=this.groups.get(c)??d.toGroup();m.sessionId===t&&m.status==="running"&&(r!==void 0&&!r.has(c)||m.lastTs!==void 0&&m.lastTs>s||i.push(c))}let l=0;for(const c of i){const d=this.folds.get(c);d===void 0||!d.close(n.status,n.at,{error:n.error,via:n.via})||(this.closedRuns.set(c,{status:n.status,at:n.at,error:n.error,via:n.via}),this.dirty.add(c),l+=1)}if(r!==void 0)for(const c of r)this.folds.has(c)||this.closedRuns.set(c,{status:n.status,at:n.at,error:n.error,via:n.via});return this.stats.reconciled+=l,l>0&&this.flush(),l}reconcileLifecycle(t){const n=this.recordLifecycle(t);n!==void 0&&this.closeRuns(n.sessionId,{status:"cancelled",at:n.at,via:"agent-closed",notAfter:n.at})}recordLifecycle(t){if(t.event.type!=="agent.closed")return;const n=t.event.data,r=(typeof n.session_id=="string"?n.session_id:void 0)??t.sessionId??t.event.run_id;if(typeof r!="string"||r.length===0)return;const i=typeof t.event.ts=="number"?t.event.ts:void 0;if(i===void 0)return;const l=this.sessionClosed.get(r);return(l===void 0||i>=l.at)&&this.sessionClosed.set(r,{at:i,via:"agent-closed",status:"cancelled"}),{sessionId:r,at:i}}applyCloses(t,n){const s=this.closedRuns.get(t);if(s!==void 0){n.close(s.status,s.at,{error:s.error,via:s.via})&&this.dirty.add(t);return}if(this.sessionClosed.size===0)return;const r=n.toGroup();if(r.status!=="running"||r.sessionId===void 0)return;const i=this.sessionClosed.get(r.sessionId);i!==void 0&&(r.lastTs!==void 0&&r.lastTs>i.at||n.close(i.status,i.at,{error:i.error,via:i.via})&&(this.closedRuns.set(t,{status:i.status,at:i.at,...i.error!==void 0?{error:i.error}:{},via:i.via}),this.dirty.add(t)))}dropSession(t,n=[]){const s=new Set(n);for(const[r,i]of this.groups)i.sessionId===t&&s.add(r);if(s.size!==0){this.sessionClosed.delete(t);for(const r of s)this.folds.delete(r),this.groups.delete(r),this.kept.delete(r),this.bases.delete(r),this.condensed.delete(r),this.released.delete(r),this.releasedRuns.delete(r),this.closedRuns.delete(r),this.dirty.delete(r);this.structureDirty=!0}}clear(){this.folds.clear(),this.groups.clear(),this.kept.clear(),this.bases.clear(),this.condensed.clear(),this.released.clear(),this.releasedRuns.clear(),this.dirty.clear(),this.structureDirty=!1,this.ingestedSeq=0,this.frozen=!1,this.overBudget=!1,this.publish()}reset(){this.frozen||this.ingestedSeq===0&&this.folds.size===0||this.clear()}flush(){if(!(this.dirty.size===0&&!this.structureDirty)){this.structureDirty=!1,this.supersedeStaleRuns();for(const t of this.dirty)this.materialize(t);this.dirty.clear(),this.enforceBudget();for(const t of this.dirty)this.materialize(t);this.dirty.clear(),this.publish()}}supersedeStaleRuns(){if(this.folds.size<2)return;const t=new Map;for(const n of this.folds.values()){const s=n.summary();if(s.sessionId===void 0)continue;const r=s.startedAt??s.firstTs;if(r===void 0)continue;const i=t.get(s.sessionId);(i===void 0||r>i)&&t.set(s.sessionId,r)}if(t.size!==0)for(const[n,s]of this.folds){const r=s.summary();if(r.status!=="running"||!r.hasRunEvent||r.sessionId===void 0)continue;const i=t.get(r.sessionId);if(i===void 0)continue;const l=r.lastTs;l===void 0||i<=l||s.close("interrupted",l,{via:"superseded"})&&(this.closedRuns.set(n,{status:"interrupted",at:l,via:"superseded"}),this.dirty.add(n))}}visible(t){return jw(t,this.showInternal,this.errorLevel)}refold(t,n){const s=new Map;for(const r of t)this.recordLifecycle(r);for(const r of t){if(!this.visible(r))continue;const i=r.event.run_id,l=s.get(i);l===void 0?s.set(i,[r]):l.push(r)}for(const[r,i]of s)this.refoldRun(r,_w(i),n);for(const r of t)r.seq>this.ingestedSeq&&(this.ingestedSeq=r.seq)}refoldRun(t,n,s){const r=this.groups.get(t);r!==void 0&&this.bases.set(t,r);const i=wl(t);for(const c of n)i.apply(c);this.applyCloses(t,i),this.folds.set(t,i);const l=new Set(i.toGroup().items.map(c=>c.key));this.kept.set(t,s?(r?.items??[]).filter(c=>!l.has(c.key)&&!Ow(t,c.key)):[]),this.dirty.add(t),this.stats.refolds+=1}materialize(t){const n=this.folds.get(t);if(n===void 0){this.groups.delete(t);return}const s=n.toGroup(),r=this.bases.get(t),i=r===void 0?s:Pw(s,r),l=[],c=this.condensed.get(t);c!==void 0&&l.push(qw(t,c,i.firstTs));const d=this.kept.get(t)??[];if(d.length>0){const f=new Set(i.items.map(h=>h.key));for(const h of d)f.has(h.key)||l.push(h)}l.length>0&&(i.items=[...l,...i.items].sort(Mw));const m=this.released.get(t);m!==void 0&&i.items.length>0&&(i.items=i.items.filter(f=>!Dw(m,f))),this.groups.set(t,i)}enforceBudget(){for(const t of[...this.folds.keys()]){const n=this.folds.get(t);n===void 0||n.itemCount<=this.maxItemsPerRun||this.condense(t,Math.min(Ew,this.maxItemsPerRun))}if(this.totalItems()<=this.maxItemsTotal){this.overBudget=!1;return}for(const t of["completed","cancelled","failed","running"])for(const n of[...this.folds.keys()]){if(this.totalItems()<=this.maxItemsTotal)break;this.groups.get(n)?.status===t&&this.condense(n,Iw)}for(const t of[...this.folds.keys()]){if(this.totalItems()<=this.maxItemsTotal)break;this.releasedRuns.has(t)&&this.condense(t,Rw)}this.overBudget=this.totalItems()>this.maxItemsTotal}condense(t,n){const s=this.folds.get(t);if(s===void 0)return;const r=s.trim(n);if(r.removed===0)return;const i=this.condensed.get(t),l={count:(i?.count??0)+r.removed},c=i?.fromSeq??r.fromSeq;c!==void 0&&(l.fromSeq=c);const d=r.toSeq??i?.toSeq;d!==void 0&&(l.toSeq=d),this.condensed.set(t,l),this.stats.condensed+=r.removed,this.dirty.add(t)}totalItems(){let t=0;for(const n of this.folds.values())t+=n.itemCount;return t}publish(){this.version+=1;const t=[...this.groups.values()].sort((n,s)=>(n.startedAt??n.firstTs??0)-(s.startedAt??s.firstTs??0));this.snapshot={groups:t,version:this.version,stats:{...this.stats,overBudget:this.overBudget}};for(const n of[...this.listeners])n()}}const $w=5e3,xu=512,Fw=2e4,Bw=50,Ta=new Set(["run.started","user.message","run.completed","run.failed","run.cancelled","subagent.delegate.started","subagent.delegate.completed","subagent.delegate.failed","subagent.run.completed","subagent.run.cancelled","subagent.run.failed"]);function wu(){return{reports:0,tainted:!1}}function xo(e){const t=e.session_id;if(typeof t=="string"&&t.length>0)return t;const n=e.data.session_id;return typeof n=="string"&&n.length>0?n:void 0}function Kw(){return{entries:[],lastSeq:0,hasEarlier:!1,version:0}}class Ww{constructor(t=Bw,n={}){this.notifyDelayMs=t,this.maxEventsPerRun=n.maxEventsPerRun??$w,this.maxEventsTotal=n.maxEventsTotal??Fw,this.items=new Hw({...n.maxItemsPerRun!==void 0?{maxItemsPerRun:n.maxItemsPerRun}:{},...n.maxItemsTotal!==void 0?{maxItemsTotal:n.maxItemsTotal}:{}})}notifyDelayMs;entries=[];runCounts=new Map;runAnchorCounts=new Map;runSessions=new Map;scopeSession;clientTimelineSeq=0;earliestSeq=0;suppressLegacyFrames=!1;seqFloor=0;gap=wu();epoch;epochEndHook;gapReporter;droppedNoiseCount=0;droppedForeignCount=0;foreignWarned=!1;version=0;listeners=new Set;notifyTimer;snapshot=Kw();maxEventsPerRun;maxEventsTotal;items;get sink(){return this.items}subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t));getSnapshot=()=>this.snapshot;get currentSeq(){return this.clientTimelineSeq}get hasEarlier(){return this.earliestSeq>1}get earliestLoadedSeq(){return this.earliestSeq}get timelineGap(){return this.gap}get droppedNoise(){return this.droppedNoiseCount}get droppedForeign(){return this.droppedForeignCount}reportTimelineGap(t){return this.gap={reports:this.gap.reports+1,tainted:!0,last:t},console.warn(`[timeline_gap_reported] seq ${t.from_seq}..${t.to_seq} source=${t.source}${t.rule===void 0?"":` rule=${t.rule}`} expected=${t.expected} received=${t.received}`),this.flush(),this.gapReporter?.(t),t}setGapReporter(t){this.gapReporter=t}beginTimelineEpoch(t){this.epoch={header:t,seqs:[]},this.suppressLegacyFrames=!1}setSuppressLegacyFrames(t){this.suppressLegacyFrames=t}setSeqFloor(t){this.seqFloor=Number.isInteger(t)&&t>0?t:0}endTimelineEpoch(){this.epoch=void 0}get timelineEpoch(){return this.epoch!==void 0}endTimelineEpochPass(t){const n=this.closeEpoch();n!==void 0&&this.epochEndHook?.(n,{hasMore:t.has_more===!0})}settleTimelineEpochIfOpen(){return this.closeEpoch()}recordEpochSeq(t){const n=this.epoch;n!==void 0&&(t<n.header.start_seq||t>n.header.end_seq||n.seqs.push(t))}closeEpoch(){const t=this.epoch;if(t===void 0)return;this.epoch=void 0;const{header:n,seqs:s}=t,r=s.length>0?s[s.length-1]:void 0;if(r!==void 0&&r>=n.end_seq||s.length>=n.count){const c=mu(n,s);return c!==void 0&&this.reportTimelineGap(c),n}const l=cp(n,s);if(l===void 0){this.reportTimelineGap({from_seq:n.start_seq,to_seq:n.end_seq,source:"range",rule:3,expected:`首 ${String(Lc(n)??n.start_seq)} / 末 ${String(n.end_seq)}`,received:s.length===0?"这一段一条都没收到":`首 ${String(s[0])} / 末 ${String(s[s.length-1])}(不是连续前缀)`,expectedCount:n.count,receivedCount:s.length,at:Date.now()});return}return no(n.start_seq,l,{timeline_head:n.timeline_head,wal_head:n.wal_head,holes:n.holes,tainted:n.tainted})}setEpochEndHook(t){this.epochEndHook=t}clearTimelineGap(){this.gap.tainted&&this.gap.last?.source!=="holes"&&(this.gap={reports:this.gap.reports,tainted:!1},this.scheduleNotify())}get scopeSessionId(){return this.scopeSession}setScopeSession(t){this.scopeSession!==t&&(this.scopeSession=t)}push(t,n){if(!Number.isFinite(n.seq)||n.seq<this.seqFloor)return!1;if(this.suppressLegacyFrames&&this.epoch===void 0)return this.droppedNoiseCount+=1,!1;if(this.epoch!==void 0&&this.recordEpochSeq(n.seq),n.seq<=this.clientTimelineSeq)return this.reportTimelineGap({from_seq:n.seq,to_seq:n.seq,source:"range",rule:4,expected:`> ${this.clientTimelineSeq}`,received:String(n.seq),at:Date.now()}),!1;if(this.clientTimelineSeq=n.seq,!pu(t))return this.droppedNoiseCount+=1,!0;if(!this.acceptOwner(t))return!1;const s=t.run_id,r=xo(t);r!==void 0&&this.runSessions.set(s,r);const i=this.runSessions.get(s)??this.scopeSession,l={event:t,seq:n.seq,...i!==void 0?{sessionId:i}:{},...n.jobId?{jobId:n.jobId}:{}};return this.entries.push(l),this.sink.ingest(l),this.noteEntry(s,t.type,1),this.trimEntries(s),this.scheduleNotify(),!0}applyTimelineRange(t,n,s){const r=s??this.scopeSession,i=[...n].sort((y,v)=>y.seq-v.seq),l=mu(t,i.map(y=>y.seq));if(l!==void 0)return this.reportTimelineGap(l),{merged:0,duplicates:0,evicted:0,violation:l};const c=new Set;for(const y of this.entries)c.add(y.seq);let d=0,m=0,f=!1;for(const y of i){if(c.has(y.seq)){m+=1;continue}if(c.add(y.seq),mo(y.seq,t.holes))continue;const v=fw(y);if(!pu(v)){this.droppedNoiseCount+=1;continue}this.acceptOwner(v,r)&&(y.seq<=this.clientTimelineSeq&&(f=!0),this.appendEntry(v,y.seq,s),d+=1)}const h=t.end_seq>this.clientTimelineSeq;this.clientTimelineSeq=Math.max(this.clientTimelineSeq,t.end_seq),d>0&&(f&&(this.entries=[...this.entries].sort((y,v)=>y.seq-v.seq)),this.rebuildCounts());const p=this.trimEntries(),g=this.earliestSeq;this.noteCoveredRange(t.start_seq,t.end_seq);const b=this.earliestSeq!==g,x=t.holes.filter(y=>y.to_seq>=t.start_seq&&y.from_seq<=t.end_seq);return x.length>0&&this.reportTimelineGap({from_seq:x[0]?.from_seq??t.start_seq,to_seq:x[x.length-1]?.to_seq??t.end_seq,source:"holes",expected:`[${String(t.start_seq)}, ${String(t.end_seq)}] 可读`,received:`已声明 ${String(x.length)} 段不可读(holes)`,at:Date.now()}),(d>0||!h||b)&&(this.sink.resume(this.entries),this.flush()),{merged:d,duplicates:m,evicted:p}}noteCoveredRange(t,n){const s=Number.isInteger(t)&&t>0?t:1;if(this.earliestSeq===0){this.earliestSeq=s;return}n<this.earliestSeq-1||(this.earliestSeq=Math.min(this.earliestSeq,s))}acceptOwner(t,n){const s=n??this.scopeSession;if(s===void 0)return!0;const r=xo(t);if(r!==void 0)return r===s?!0:(this.runSessions.set(t.run_id,r),this.noteForeignFrame(t.type,r,s),!1);const i=this.runSessions.get(t.run_id);return i!==void 0&&i!==s?(this.noteForeignFrame(t.type,i,s),!1):!0}noteForeignFrame(t,n,s){this.droppedForeignCount+=1,!this.foreignWarned&&(this.foreignWarned=!0,console.warn("[vessel] events: 丢弃不属于当前会话的帧(claimed="+n+", scope="+s+", type="+t+");跨会话帧累计计数见 EventStore#droppedForeign。"))}appendEntry(t,n,s){const r=t.run_id,i=xo(t);i!==void 0&&this.runSessions.set(r,i);const l=this.runSessions.get(r)??this.scopeSession??s,c={event:t,seq:n,...l!==void 0?{sessionId:l}:{}};this.entries.push(c),this.sink.ingest(c),this.noteEntry(r,t.type,1)}trimEntries(t){let n=0;for(const s of t===void 0?[...this.runCounts.keys()]:[t]){let r=(this.runCounts.get(s)??0)-this.maxEventsPerRun;for(;r>0;){const i=this.oldestEvictableIndex(s);if(i<0)break;this.removeEntryAt(i),r-=1,n+=1}}for(;this.entries.length>this.maxEventsTotal;){const s=this.oldestEvictableTotalIndex(xu);if(s>=0){this.removeEntryAt(s),n+=1;continue}const r=this.dropOldestRunGroup(xu);if(r===0)break;n+=r}return n}removeEntryAt(t){const n=this.entries.splice(t,1)[0];return n===void 0?!1:(this.noteEntry(n.event.run_id,n.event.type,-1),!0)}noteEntry(t,n,s){const r=(this.runCounts.get(t)??0)+s;if(r<=0?this.runCounts.delete(t):this.runCounts.set(t,r),!Ta.has(n))return;const i=(this.runAnchorCounts.get(t)??0)+s;i<=0?this.runAnchorCounts.delete(t):this.runAnchorCounts.set(t,i)}rebuildCounts(){this.runCounts.clear(),this.runAnchorCounts.clear();for(const t of this.entries)this.noteEntry(t.event.run_id,t.event.type,1)}runHasContent(t){return(this.runCounts.get(t)??0)>(this.runAnchorCounts.get(t)??0)}newestRunId(){return this.entries[this.entries.length-1]?.event.run_id}oldestEvictableTotalIndex(t){const n=this.newestRunId(),s=Math.min(this.entries.length,t);for(let r=0;r<s;r+=1){const i=this.entries[r];if(i===void 0)continue;if(!Ta.has(i.event.type))return r;const l=i.event.run_id;if(l!==n&&!this.runHasContent(l))return r}return-1}dropOldestRunGroup(t){const n=this.newestRunId(),s=Math.min(this.entries.length,t);let r;for(let c=0;c<s;c+=1){const d=this.entries[c];if(d!==void 0&&d.event.run_id!==n){r=d.event.run_id;break}}if(r===void 0)return 0;const i=[];let l=0;for(const c of this.entries){if(c.event.run_id===r){l+=1;continue}i.push(c)}return l===0?0:(this.entries=i,this.runCounts.delete(r),this.runAnchorCounts.delete(r),l)}dropSession(t){const n=new Set;for(const l of this.entries)this.ownerOf(l)===t&&n.add(l.event.run_id);if(this.sink.dropSession(t,[...n]),n.size===0)return this.sink.flush(),0;const s=this.entries.length,r=new Set;this.entries=this.entries.filter(l=>{const c=this.ownerOf(l),d=c===t||c===void 0&&n.has(l.event.run_id);return d&&r.add(l.event.run_id),!d});const i=s-this.entries.length;if(i===0)return this.sink.flush(),0;this.rebuildCounts();for(const l of r)this.runCounts.has(l)||this.runSessions.delete(l);return this.flush(),i}truncateAfter(t){t===0&&this.sink.reset(),this.earliestSeq>t+1&&(this.earliestSeq=t===0?0:t+1);let n=0,s=this.entries.length;for(;n<s;){const i=n+s>>>1;(this.entries[i]?.seq??0)<=t?n=i+1:s=i}const r=this.entries.slice(n);if(this.clientTimelineSeq=t,r.length===0)return this.flush(),0;this.entries=this.entries.slice(0,n),this.rebuildCounts(),this.runSessions.clear();for(const i of this.entries){const l=i.event.run_id,c=i.sessionId??xo(i.event);c!==void 0&&this.runSessions.set(l,c)}for(const i of r){const l=i.event.run_id;this.runCounts.has(l)||this.runSessions.delete(l)}return this.flush(),r.length}setItemVisibility(t,n){this.sink.setVisibility(t,n,this.entries)}refold(){this.sink.resume(this.entries)}clear(t=0){this.entries=[],this.runAnchorCounts.clear(),this.runCounts.clear(),this.runSessions.clear(),this.clientTimelineSeq=t,this.gap=wu(),this.earliestSeq=0,this.suppressLegacyFrames=!1,this.seqFloor=0,this.sink.clear(),this.epoch=void 0,this.version+=1,this.snapshot={entries:[],lastSeq:t,hasEarlier:!1,version:this.version},this.cancelTimer(),this.notify()}flush(){this.cancelTimer(),this.sink.flush(),this.version+=1,this.snapshot={entries:[...this.entries],lastSeq:this.clientTimelineSeq,hasEarlier:this.hasEarlier,version:this.version},this.notify()}destroy(){this.cancelTimer(),this.listeners.clear()}ownerOf(t){return t.sessionId??xo(t.event)}oldestEvictableIndex(t){let n=-1;for(let s=0;s<this.entries.length;s+=1){const r=this.entries[s];if(!(!r||r.event.run_id!==t)&&(n<0&&(n=s),!Ta.has(r.event.type)))return s}return n}scheduleNotify(){this.notifyTimer===void 0&&(this.notifyTimer=setTimeout(()=>{this.notifyTimer=void 0,this.flush()},this.notifyDelayMs))}cancelTimer(){this.notifyTimer!==void 0&&(clearTimeout(this.notifyTimer),this.notifyTimer=void 0)}notify(){for(const t of[...this.listeners])t()}}const Uw=new Set(["session_required","platform_unauthorized","csrf_failed"]),zw=new Set(["forbidden_origin","invalid_host"]),Vw=new Set(["method_not_allowed","method_not_found"]);function Mc(e){return typeof e=="object"&&e!==null?e:null}function pp(e){const t=Mc(e)?.code;return typeof t=="string"?t:""}function gp(e){const t=Mc(e)?.status;return typeof t=="number"?t:void 0}function bp(e){const t=Mc(e);return typeof t?.message=="string"&&t.message.length>0?t.message:e instanceof Error&&e.message.length>0?e.message:""}function vp(e){const t=pp(e),n=gp(e),s=bp(e);return zw.has(t)?{kind:"origin",code:t,...n!==void 0?{status:n}:{},message:s}:n===401||Uw.has(t)?{kind:"session",code:t===""?"unauthorized":t,...n!==void 0?{status:n}:{},message:s}:null}function Gw(e){const t=gp(e);return t===404||t===405?!0:Vw.has(pp(e))}const Yw=3e4,Jw=3,Qw=3e4,Xw={block:null,revision:0};function Zw(e,t){return e===null||t===null?e===t:e.kind===t.kind&&e.code===t.code&&e.status===t.status&&e.message===t.message&&e.method===t.method&&e.at===t.at}function e0(e={}){const t=e.repeatMs??Yw,n=e.now??(()=>Date.now()),s=e.networkFailureThreshold??Jw,r=e.networkFailureWindowMs??Qw;let i=Xw,l=0;const c=new Set;let d=0,m,f=!1,h=!1,p=!1;const g=()=>{for(const y of[...c])y()},b=(y,v)=>{i={block:y,revision:v},g()},x=()=>{i.block!==null&&(l=0,i={block:null,revision:i.revision+1},g())};return{snapshot:()=>i,observe(y,v={}){const j=vp(y);if(j===null)return null;const _=v.now??n(),S=i.block,w=S!==null&&S.kind===j.kind&&S.code===j.code,k=_-l,N=!w||k>=t||k<0,T={...j,...v.method!==void 0?{method:v.method}:{},at:w&&S!==null?S.at:_};return Zw(S,T)||b(T,w?i.revision:i.revision+1),N?(l=_,T):null},observeNetworkFailure(y={}){if(!p||h||f)return null;const v=y.now??n();if((m===void 0||v-m>r||v<m)&&(m=v,d=0),d+=1,d<s)return null;f=!0;const j={kind:"connection",code:"unreachable",...y.method!==void 0?{method:y.method}:{},message:y.message??"",at:m,attempts:d};return b(j,i.revision+1),j},noteSuccess(){h=!0,d=0,m=void 0,x()},beginEpoch(){d=0,m=void 0,f=!1,h=!1,p=!0,i.block?.kind==="connection"&&x()},clear(){x()},subscribe(y){return c.add(y),()=>{c.delete(y)}}}}const Zn=e0();let yp=null;function t0(e){yp=e}function n0(e,t){const n=Zn.observe(e,t===void 0?{}:{method:t});return n!==null&&n.kind==="session"&&yp?.(),n}function s0(){Zn.noteSuccess()}function o0(e,t){return Zn.observeNetworkFailure({...t!==void 0?{method:t}:{},message:bp(e)})}function r0(){Zn.beginEpoch()}const i0={permissions:[],asks:[],notices:[]},a0={status:"unknown",kind:null,message:null,at:0};function l0(e){if(e instanceof Error&&e.message.length>0)return e.message;const t=e?.message;return typeof t=="string"&&t.length>0?t:String(e)}function c0(e,t,n=Date.now()){const s=t.status==="fulfilled"?t.value:[];if(e.status==="fulfilled"){const i=e.value;return{pending:Array.isArray(i?.interactions)?i.interactions:[],orphaned:s,pendingUsable:!0,pendingComplete:i?.next_cursor===void 0,state:{status:"ok",kind:null,message:null,at:n}}}if(Gw(e.reason))return{pending:[],orphaned:s,pendingUsable:!1,pendingComplete:!1,state:{status:"unsupported",kind:null,message:null,at:n}};const r=vp(e.reason);return{pending:[],orphaned:s,pendingUsable:!1,pendingComplete:!1,state:{status:"failed",kind:r?.kind??"other",message:l0(e.reason),at:n}}}const xp=new Set;function d0(e){if(!Array.isArray(e))return null;const t=e.filter(n=>!!n&&typeof n=="object"&&typeof n.question=="string");return t.length>0?t:null}function u0(e){if(typeof e!="object"||e===null)return null;const t=e;return typeof t.title!="string"||typeof t.body!="string"?null:{title:t.title,body:t.body,...Array.isArray(t.refs)?{refs:t.refs.filter(n=>typeof n=="string")}:{},...t.salience==="high"?{salience:"high"}:{}}}function m0(e){const t=e.settled??xp,n=[],s=[],r=[],i=[],l=new Set;for(const d of e.orphaned)d.status!=="orphaned"||!d.request_id||l.has(d.request_id)||(l.add(d.request_id),t.has(d.request_id)||i.push(d.request_id));const c=new Set(l);for(const d of e.pending){if(d.status!=="pending"||!d.request_id||c.has(d.request_id)||t.has(d.request_id))continue;const m=d.session_id;if(d.kind==="notify"){const h=u0(d.input);if(!h)continue;c.add(d.request_id),r.push({requestId:d.request_id,title:h.title,body:h.body,...h.refs!==void 0?{refs:h.refs}:{},...h.salience==="high"?{salience:"high"}:{},runId:d.run_id,requestedAt:d.created_at,...m!==void 0?{sessionId:m}:{},...d.parent_agent_id?{parentAgentId:d.parent_agent_id}:{},...d.agent_id!==void 0&&d.agent_id.length>0?{agentId:d.agent_id}:{},...d.team_id!==void 0&&d.team_id.length>0?{teamId:d.team_id}:{}});continue}if(d.kind==="permission"){c.add(d.request_id),n.push({requestId:d.request_id,tool:d.tool??"tool",input:d.input,runId:d.run_id,requestedAt:d.created_at,...m!==void 0?{sessionId:m}:{},...d.parent_session_id?{parentSessionId:d.parent_session_id}:{},...d.parent_agent_id?{parentAgentId:d.parent_agent_id}:{},...d.tool_call_id!==void 0&&d.tool_call_id.length>0?{toolCallId:d.tool_call_id}:{},...d.agent_id!==void 0&&d.agent_id.length>0?{agentId:d.agent_id}:{},...d.team_id!==void 0&&d.team_id.length>0?{teamId:d.team_id}:{}});continue}const f=d0(d.questions);f&&(c.add(d.request_id),s.push({requestId:d.request_id,questions:f,runId:d.run_id,requestedAt:d.created_at,...m!==void 0?{sessionId:m}:{},...d.parent_session_id?{parentSessionId:d.parent_session_id}:{},...d.parent_agent_id?{parentAgentId:d.parent_agent_id}:{},...d.agent_id!==void 0&&d.agent_id.length>0?{agentId:d.agent_id}:{},...d.team_id!==void 0&&d.team_id.length>0?{teamId:d.team_id}:{},...d.mode==="async"?{mode:"async"}:{},...d.answered_questions!==void 0&&d.answered_questions.length>0?{answeredQuestionIds:d.answered_questions}:{}}))}return{permissions:n,asks:s,notices:r,terminalIds:i}}function f0(e,t,n){if(t===null)return[];const s=new Set(t.filter(r=>r.status==="pending").map(r=>r.request_id));return[...new Set(e)].filter(r=>!s.has(r)&&!n.has(r))}function Ea(e,t){return e.some(n=>n.requestId===t)?e.filter(n=>n.requestId!==t):e}function Ia(e,t){return e.permissions.some(n=>n.requestId===t)||e.asks.some(n=>n.requestId===t)||e.notices.some(n=>n.requestId===t)}function h0(e,t){const n=e??[],s=t??[];if(n.length!==s.length)return!1;const r=new Set(n);return s.every(i=>r.has(i))}function ku(e,t){switch(t.type){case"permission-request":return Ia(e,t.request.requestId)?e:{...e,permissions:[...e.permissions,t.request]};case"ask-request":return Ia(e,t.request.requestId)?e:{...e,asks:[...e.asks,t.request]};case"notice-request":return Ia(e,t.request.requestId)?e:{...e,notices:[...e.notices,t.request]};case"settle":{const n=Ea(e.permissions,t.requestId),s=Ea(e.asks,t.requestId),r=Ea(e.notices,t.requestId);return n===e.permissions&&s===e.asks&&r===e.notices?e:{permissions:n,asks:s,notices:r}}case"run-finished":{const n=e.permissions.filter(r=>r.runId!==t.runId),s=e.asks.filter(r=>r.runId!==t.runId||r.mode==="async");return n.length===e.permissions.length&&s.length===e.asks.length?e:{...e,permissions:n,asks:s}}case"reset":return i0;case"hydrate":{const n=t.settled??xp,s=new Set(t.snapshot.terminalIds.filter(b=>!n.has(b))),r=new Set((t.snapshot.staleIds??[]).filter(b=>!n.has(b))),i=e.permissions.filter(b=>!n.has(b.requestId)&&!s.has(b.requestId)&&!r.has(b.requestId)),l=e.asks.filter(b=>!n.has(b.requestId)&&!s.has(b.requestId)&&!r.has(b.requestId)),c=e.notices.filter(b=>!n.has(b.requestId)&&!s.has(b.requestId)&&!r.has(b.requestId)),d=new Set;for(const b of i)d.add(b.requestId);for(const b of l)d.add(b.requestId);for(const b of c)d.add(b.requestId);const m=[...i];for(const b of t.snapshot.permissions)n.has(b.requestId)||d.has(b.requestId)||(d.add(b.requestId),m.push(b));const f=[...l];for(const b of t.snapshot.asks)n.has(b.requestId)||d.has(b.requestId)||(d.add(b.requestId),f.push(b));const h=[...c];for(const b of t.snapshot.notices)n.has(b.requestId)||d.has(b.requestId)||(d.add(b.requestId),h.push(b));const p=new Map(t.snapshot.asks.map(b=>[b.requestId,b.answeredQuestionIds])),g=f.map(b=>{const x=p.get(b.requestId);return x===void 0||h0(b.answeredQuestionIds,x)?b:{...b,answeredQuestionIds:x}});return{permissions:m,asks:g,notices:h}}default:return e}}const Su=new Set,ju=[],dt=vn()((e,t)=>({permissions:[],asks:[],notices:[],responding:Su,orphanedIds:ju,setSnapshot:n=>{e(s=>({permissions:n.permissions??s.permissions,asks:n.asks??s.asks,notices:n.notices??s.notices,orphanedIds:n.orphanedIds??s.orphanedIds}))},dispatch:n=>{e(s=>ku(s,n))},hydrate:(n,s,r)=>{e(i=>({...ku(i,{type:"hydrate",snapshot:n,settled:s}),orphanedIds:[...r]}))},setResponding:(n,s)=>{const r=t().responding;if(s){if(r.has(n))return;const l=new Set(r);l.add(n),e({responding:l});return}if(!r.has(n))return;const i=new Set(r);i.delete(n),e({responding:i})},reset:()=>{e({permissions:[],asks:[],notices:[],responding:Su,orphanedIds:ju})}})),p0={unauthorized:"error.hint.unauthorized",forbidden:"error.hint.forbidden",not_found:"error.hint.not_found",invalid_params:"error.hint.invalid_params",data_locked:"error.hint.data_locked",quota_exceeded:"error.hint.quota_exceeded",conflict:"error.hint.conflict",internal:"error.hint.internal",not_supported:"error.hint.not_supported",expired:"error.hint.expired",run_ended:"error.hint.run_ended",session_not_found:"error.hint.session_not_found",compact_unavailable:"error.hint.compact_unavailable",gateway_restarting:"error.hint.gateway_restarting",no_active_run:"error.hint.no_active_run",run_mismatch:"error.hint.run_mismatch",marker_failed:"error.hint.marker_failed",restart_reserve_failed:"error.hint.restart_reserve_failed",legacy_session_unsupported:"error.hint.legacy_session_unsupported",timeline_unavailable:"error.hint.timeline_unavailable",method_not_found:"error.hint.method_not_found",run_already_running:"error.hint.run_already_running",run_not_found:"error.hint.run_not_found",run_not_resumable:"error.hint.run_not_resumable",run_store_required:"error.hint.run_store_required",agent_not_found:"error.hint.agent_not_found",session_corrupt:"error.hint.session_corrupt",atomic_write_failed:"error.hint.atomic_write_failed",limit_blocked:"error.hint.limit_blocked",empty_response_exhausted:"error.hint.empty_response_exhausted",invalid_input:"error.hint.invalid_input",unknown_member:"error.hint.unknown_member",member_closed:"error.hint.member_closed",member_stale:"error.hint.member_stale",member_not_visible:"error.hint.member_not_visible",no_parent:"error.hint.no_parent",spawn_failed:"error.hint.spawn_failed",team_full:"error.hint.team_full",team_frozen:"error.hint.team_frozen",invalid_state_transition:"error.hint.invalid_state_transition",budget_exceeded:"error.hint.budget_exceeded",budget_unavailable:"error.hint.budget_unavailable",conversation_team_mismatch:"error.hint.conversation_team_mismatch",body_limit:"error.hint.body_limit",node_draining:"error.hint.node_draining",team_not_found:"error.hint.team_not_found",team_conversation_not_found:"error.hint.team_conversation_not_found",team_log_write_failed:"error.hint.team_log_write_failed",team_binding_requires_name:"error.hint.team_binding_requires_name",team_already_in_team:"error.hint.team_already_in_team",team_not_member:"error.hint.team_not_member",team_private_member:"error.hint.team_private_member",team_no_team:"error.hint.team_no_team",team_self_mention:"error.hint.team_self_mention",team_owner_not_rosterable:"error.hint.team_owner_not_rosterable",team_not_empty:"error.hint.team_not_empty",team_archived:"error.hint.team_archived",not_visible:"error.hint.not_visible",message_not_found:"error.hint.message_not_found",cursor_out_of_window:"error.hint.cursor_out_of_window",unknown_ref:"error.hint.unknown_ref",pii_unknown_handle:"error.hint.pii_unknown_handle",pii_expired_handle:"error.hint.pii_expired_handle",pii_invalidated_handle:"error.hint.pii_invalidated_handle",pii_reveal_denied:"error.hint.pii_reveal_denied",provider_auth:"error.hint.provider_auth",provider_rate_limit:"error.hint.provider_rate_limit",provider_quota_exceeded:"error.hint.provider_quota_exceeded",provider_timeout:"error.hint.provider_timeout",provider_context_overflow:"error.hint.provider_context_overflow",provider_unavailable:"error.hint.provider_unavailable",provider_http_error:"error.hint.provider_http_error",provider_network:"error.hint.provider_network",provider_error:"error.hint.provider_error",tool_timeout:"error.hint.tool_timeout",tool_not_found:"error.hint.tool_not_found",tool_invalid_arguments:"error.hint.tool_invalid_arguments",tool_blocked:"error.hint.tool_blocked",tool_error:"error.hint.tool_error",permission_timeout:"error.hint.permission_timeout",permission_cancelled:"error.hint.permission_cancelled",permission_denied:"error.hint.permission_denied",permission_error:"error.hint.permission_error",config_error:"error.hint.config_error",gateway_error:"error.hint.gateway_error",internal_error:"error.hint.internal_error",checkpoint_failed:"error.hint.checkpoint_failed",forbidden_origin:"gateway.error.forbidden_origin",invalid_host:"gateway.error.invalid_host",invalid_request:"gateway.error.invalid_request",rate_limited:"gateway.error.rate_limited",timeout:"gateway.error.timeout",unsupported_protocol:"gateway.error.unsupported_protocol",no_runtime:"gateway.error.no_runtime",durable_disabled:"gateway.error.durable_disabled",mcp_disabled:"gateway.error.mcp_disabled",evals_disabled:"gateway.error.evals_disabled"};function g0(e){if(!e)return null;const t=p0[e];return t?a(t):null}function wp(e){return e?/^([a-z][a-z0-9_]*):/.exec(e.trim())?.[1]??null:null}function b0(e){return g0(wp(e))}function v0(e){if(typeof e!="object"||e===null)return null;const t=e.code;return typeof t=="string"?t:null}function kp(e){if(typeof e!="object"||e===null)return null;const t=e.details;if(typeof t!="object"||t===null)return null;const n=t.reason;return typeof n=="string"?n:null}function Pc(e){return e instanceof Error?e.message:typeof e=="string"?e:""}function Sp(e){return v0(e)==="conflict"?!0:wp(Pc(e))==="conflict"}function jp(e){return Sp(e)?kp(e)==="history_changed"?!0:Pc(e).toLowerCase().includes("history changed"):!1}function y0(e){return Sp(e)?kp(e)==="cursor_out_of_window"?!0:Pc(e).includes("cursor_out_of_window"):!1}function on(e,t){return String(e).padStart(t,"0")}function vs(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":`${on(t.getFullYear(),4)}-${on(t.getMonth()+1,2)}-${on(t.getDate(),2)}`}function Wi(e,t=Date.now()){const n=vs(e);if(!n)return"";const s=new Date(t),r=new Date(t);return r.setDate(s.getDate()-1),n===vs(t)?a("time.today"):n===vs(r.getTime())?a("time.yesterday"):n}function cn(e){if(e===void 0)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":`${on(t.getHours(),2)}:${on(t.getMinutes(),2)}`}function _u(e){const t=Math.max(0,e);if(t<1e3)return a("chat.tool.duration.millis",{value:Math.max(1,Math.round(t))});const n=t/1e3;if(n<60)return a("duration.seconds",{seconds:n.toFixed(1)});const s=Math.floor(n/60);if(s<60){const l=Math.round(n-s*60);return l>0?a("chat.tool.duration.minutes",{minutes:s,seconds:l}):a("duration.minutes",{minutes:s})}const r=Math.floor(s/60),i=s-r*60;return i>0?a("duration.hoursMinutes",{hours:r,minutes:i}):a("duration.hours",{hours:r})}function x0(e){if(e===void 0)return"";if(e<1024)return`${e} B`;const t=e/1024;if(t<1024)return`${t<10?t.toFixed(1):Math.round(t)} KiB`;const n=t/1024;return`${n<10?n.toFixed(1):Math.round(n)} MiB`}function hi(e){return!Number.isFinite(e)||e<0?"":e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`}function bt(e,t){if(e===void 0)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const s=new Date(t?.now??Date.now()),r=n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate(),i=`${on(n.getHours(),2)}:${on(n.getMinutes(),2)}:${on(n.getSeconds(),2)}`,l=t?.withMs===!0?`.${on(n.getMilliseconds(),3)}`:"";return r?`${i}${l}`:`${`${on(n.getFullYear(),4)}-${on(n.getMonth()+1,2)}-${on(n.getDate(),2)}`} ${i}${l}`}const w0=512,Ra=50;function _p(e,t){const n=e.map(s=>{const r=t(s);return{item:s,rank:Number.isFinite(r.rank)?r.rank:Number.MAX_SAFE_INTEGER,activity:Number.isFinite(r.activity)?r.activity:0,id:r.id}});return n.sort((s,r)=>s.rank!==r.rank?s.rank-r.rank:s.activity!==r.activity?r.activity-s.activity:s.id===r.id?0:s.id<r.id?-1:1),n.map(s=>s.item)}function k0(e,t={}){const n=t.inflight,s=t.now??Number.POSITIVE_INFINITY;return _p(e,r=>({rank:S0(n?.get(r.session_id)),activity:j0(r,s),id:r.session_id}))}function S0(e){return e==="running"?0:e==="queued"?1:2}function j0(e,t){const n=e.updated_at||e.started_at||0;return Number.isFinite(n)?n>t?t:n:0}function _0(e,t){const n=new Map;t.forEach((d,m)=>{n.set(d,m)});const s=new Set(e),r=e.filter(d=>n.has(d)),i=new Set(r),l=t.filter(d=>!i.has(d)&&!s.has(d));if(l.length===0)return r;const c=[...r];for(const d of l){const m=n.get(d)??Number.POSITIVE_INFINITY;let f=0;for(let h=0;h<c.length;h+=1){const p=c[h];if(p===void 0)continue;const g=n.get(p);g!==void 0&&g<m&&(f=h+1)}c.splice(f,0,d)}return c}function N0(e){const t=new Map;for(const n of e?.queued??[])typeof n.session_id=="string"&&n.session_id!==""&&t.set(n.session_id,"queued");for(const n of e?.running??[])typeof n.session_id=="string"&&n.session_id!==""&&t.set(n.session_id,"running");return t}function Zo(e){const t=e?.trim()??"";if(t==="")return"";const n=t.toLowerCase();return n==="undefined"||n==="null"?"":t}function Sn(e){return Zo(e.title)||Zo(e.preview)||e.session_id}function C0(e){const t=e.trim();return!t||t.length>w0?null:t}function T0(e,{query:t=""}={}){const n=t.trim().toLowerCase();return e.filter(s=>n?[s.title,s.preview,s.session_id].some(r=>(r??"").toLowerCase().includes(n)):!0)}function E0(e,t=Date.now()){const n=[];for(const s of e){const r=vs(s.updated_at),i=n[n.length-1];if(i&&i.key===r){i.sessions.push(s);continue}n.push({key:r,label:Wi(s.updated_at,t),sessions:[s]})}return n}function I0(e,t){return t<=0?{shown:[],hiddenCount:e.length}:t>=e.length?{shown:e.slice(),hiddenCount:0}:{shown:e.slice(0,t),hiddenCount:e.length-t}}function R0(e,t,n){return e.map(s=>s.session_id===t?{...s,title:n}:s)}function L0(e,t){return e.filter(n=>n.session_id!==t)}function A0(e,t,n){return e===n?{selectedId:null,draftId:null}:t===n?{selectedId:e,draftId:null}:{selectedId:e,draftId:t}}const pi="chat.notFound",M0=50,P0="chat.historyChanged";function q0(e){return e!==null&&(e.start>0||e.next_before!==void 0)}const ti="session:list",Xn="session:detail",Nu=new WeakMap;let O0=1,kl=null,hn=null,zs=null,Mn=null,Vs=null;const D0=50,Vt=new Map;function La(e){const t=Vt.get(e);return t!==void 0&&(Vt.delete(e),Vt.set(e,t)),t}function Aa(e,t){for(Vt.delete(e),Vt.set(e,t);Vt.size>D0;){const n=Vt.keys().next().value;if(n===void 0)break;Vt.delete(n)}}function H0(e){for(const t of[...Vt.keys()]){const[,n]=t.split("|");n===e&&Vt.delete(t)}hn!==null&&hn.split("|")[1]===e&&(hn=null),Mn!==null&&Mn.key.split("|")[1]===e&&(Mn=null),rn(Xn)}function $0(e,t){const n=t.messages_total,s=typeof n=="number"&&Number.isInteger(n)&&n>=t.messages.length?n:t.messages.length,r=Math.max(0,s-t.messages.length),i=r>0&&typeof t.next_before=="string"&&t.next_before.length>0?t.next_before:void 0;return{sessionId:e,start:r,end:s,...i!==void 0?{next_before:i}:{}}}function F0(e,t,n){const s=$0(e,t);if(n===void 0||n.window.sessionId!==e)return{detail:t,window:s,notice:n?.notice??null};const r=n.window;if(s.end<r.end||s.start>r.end||s.start<r.start)return{detail:t,window:s,notice:n.notice};const i=n.detail.messages.slice(0,s.start-r.start),l=n.detail.messages.slice(s.start-r.start),c=l.length===t.messages.length&&l.every((m,f)=>{const h=t.messages[f];return h!==void 0&&JSON.stringify(m)===JSON.stringify(h)}),d={...t,messages:c?n.detail.messages:i.concat(t.messages),messages_total:s.end};return r.next_before===void 0?delete d.next_before:d.next_before=r.next_before,{detail:d,window:{sessionId:e,start:r.start,end:s.end,...r.next_before!==void 0?{next_before:r.next_before}:{}},notice:n.notice}}function B0(e,t,n){const s=n.window;if(s.sessionId!==e||typeof t.messages_total=="number"&&t.messages_total<s.end||t.messages.length===0)return null;const r=Math.max(0,s.start-t.messages.length);if(r===s.start)return null;const i={...n.detail,messages:t.messages.concat(n.detail.messages)};typeof t.messages_total=="number"&&(i.messages_total=t.messages_total);const l=r>0&&typeof t.next_before=="string"&&t.next_before.length>0?t.next_before:void 0;return l===void 0?delete i.next_before:i.next_before=l,{detail:i,window:{sessionId:e,start:r,end:s.end,...l!==void 0?{next_before:l}:{}},notice:n.notice}}function Cu(e){const t=Nu.get(e);if(t!==void 0)return t;const n=O0++;return Nu.set(e,n),n}function ni(e){return e instanceof Error?e.message:String(e)}function K0(e){return e.code==="not_found"?!0:ni(e).startsWith("not_found:")}function W0(){rn(ti),rn(Xn),kl=null,hn=null,zs=null,Mn=null,Vs=null,Vt.clear()}const Tu={sessions:[],selectedId:null,detail:null,detailWindow:null,loading:!1,error:null,loaded:!1,detailLoading:!1,detailError:null,earlierLoading:!1,earlierError:null,detailNotice:null,detailId:null},it=vn()((e,t)=>({...Tu,loadSessions:async(n,s={})=>{const{force:r=!1,epoch:i=0}=s,l=`${Cu(n)}|${i}`;if(!r&&kl===l)return;if(zs?.key===l)return zs.promise;const c=gn(ti);e({loading:!0,error:null});const d=(async()=>{try{const m=await n.listSessions();if(!kt(ti,c))return;kl=l,e({sessions:m,loading:!1,error:null,loaded:!0})}catch(m){if(!kt(ti,c))return;e({loading:!1,error:ni(m)})}})();return zs={key:l,promise:d},d.finally(()=>{zs?.promise===d&&(zs=null)}),d},select:n=>{t().selectedId!==n&&e({selectedId:n,detailNotice:null,detailLoading:!1,detailError:null,earlierLoading:!1,earlierError:null})},loadDetail:async(n,s,r={})=>{const{force:i=!1,epoch:l=0,allowMissing:c=!1,message_limit:d,before:m}=r,f=`${Cu(n)}|${s}|${l}`,h=d??M0;if(m!==void 0){const b=`${f}|${m}`;if(Vs?.key===b)return Vs.promise;const x=gn(Xn);e({earlierLoading:!0,earlierError:null});const y=(async()=>{try{const v=await n.getSession(s,{message_limit:h,before:m});if(!kt(Xn,x)||t().selectedId!==s)return;const j=La(f),_=j===void 0?null:B0(s,v,j);if(_===null){Vt.delete(f),hn=null,await t().loadDetail(n,s,{force:!0,epoch:l,message_limit:h});return}Aa(f,_),hn=f,e({detail:_.detail,detailWindow:_.window,detailNotice:_.notice,detailId:s,earlierLoading:!1,earlierError:null})}catch(v){if(!kt(Xn,x)||t().selectedId!==s)return;if(jp(v)){e(j=>({earlierLoading:!1,earlierError:null,detailNotice:j.detailNotice??P0})),Vt.delete(f),hn=null,await t().loadDetail(n,s,{force:!0,epoch:l,message_limit:h});return}e({earlierLoading:!1,earlierError:ni(v)})}})();return Vs={key:b,promise:y},y.finally(()=>{Vs?.promise===y&&(Vs=null,t().earlierLoading&&e({earlierLoading:!1}))}),y}if(!i){if(hn===f&&t().detailId===s&&t().detailError===null)return;const b=La(f);if(b!==void 0){hn=f,e({detail:b.detail,detailWindow:b.window,detailNotice:b.notice,detailId:s,detailLoading:!1,detailError:null,earlierError:null});return}}if(Mn?.key===f)return Mn.promise;const p=gn(Xn);e({detailId:s,detailLoading:!0,detailError:null});const g=(async()=>{try{const b=await n.getSession(s,{message_limit:h});if(!kt(Xn,p)||t().selectedId!==s)return;const x=F0(s,b,La(f));x.notice=x.notice??t().detailNotice,hn=f,Aa(f,x),e({detail:x.detail,detailWindow:x.window,detailNotice:x.notice,detailId:s,detailLoading:!1,detailError:null,earlierError:null})}catch(b){if(!kt(Xn,p)||t().selectedId!==s)return;if(Vt.delete(f),K0(b)){if(c){hn=f;const x={session_id:s,messages:[]},y={sessionId:s,start:0,end:0};Aa(f,{detail:x,window:y,notice:null}),e({detail:x,detailWindow:y,detailId:s,detailLoading:!1,detailError:null,earlierError:null});return}e({detailId:s,detailLoading:!1,detailError:pi});return}e({detailId:s,detailLoading:!1,detailError:ni(b)})}})();return Mn={key:f,promise:g},g.finally(()=>{Mn?.promise===g&&(Mn=null)}),g},loadEarlier:async(n,s,r={})=>{const i=t().detailWindow;i===null||i.sessionId!==s||i.next_before===void 0||await t().loadDetail(n,s,{...r,before:i.next_before})},reloadAfterHistoryChange:async(n,s)=>{H0(s),t().selectedId===s&&await t().loadDetail(n,s,{force:!0})},dismissDetailNotice:()=>e({detailNotice:null}),dismissEarlierError:()=>e({earlierError:null}),refresh:async(n,s={})=>{const{selectedId:r}=t(),i=[t().loadSessions(n,{...s,force:!0})];r&&i.push(t().loadDetail(n,r,{...s,force:!0})),await Promise.all(i)},renameSession:(n,s)=>{e(r=>({sessions:R0(r.sessions,n,s)}))},removeSession:n=>{e(s=>({sessions:L0(s.sessions,n)}))},setSessions:n=>e({sessions:n}),reset:()=>{W0(),e({...Tu})}})),U0=500,Np=8e3,Eu=.8,z0=1.2;function V0(e){const t=Number.isFinite(e)?e:0,n=Math.min(16,Math.max(0,Math.floor(t)));return Math.min(Np,U0*2**n)}function Cp(e,t=Math.random){const n=t(),s=Number.isFinite(n)?Math.min(1,Math.max(0,n)):.5,r=Eu+s*(z0-Eu);return Math.min(Np,Math.round(V0(e)*r))}const Sl="vessel.node-selection";function Tp(){try{return typeof globalThis.sessionStorage>"u"?null:globalThis.sessionStorage}catch{return null}}function G0(){const e=Tp();if(!e)return null;try{const t=e.getItem(Sl)?.trim();return t||null}catch{return null}}function Iu(e){const t=Tp();if(t)try{e===null?t.removeItem(Sl):t.setItem(Sl,e)}catch{}}function Y0(e){return e.find(t=>t.status==="up")}function J0(e,t,n=!0){if(e.length===0)return null;let s=null;if(t){const i=e.find(l=>l.node_id===t);if(i&&(!n||i.status==="up"))return{node:i,fallback:null};s=i?"down":"missing"}const r=Y0(e)??e[0];return r===void 0?null:{node:r,fallback:s}}const pr="x-vessel-csrf",jl="vessel.csrf-token",Q0=8e3,_l="vessel:auth-required";let Gs=null;function Ep(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}function gr(){if(Gs!==null)return Gs;try{Gs=Ep()?.getItem(jl)??null}catch{Gs=null}return Gs??""}function js(e){Gs=e;try{const t=Ep();if(t===null)return;e===null||e===""?t.removeItem(jl):t.setItem(jl,e)}catch{}}function qc(){typeof window>"u"||window.dispatchEvent(new CustomEvent(_l))}function _s(e,t=""){const n=t.trim().replace(/\/+$/,"");return(n!==""?n:window.location.origin)+e}async function Ns(e){const t=new AbortController,n=window.setTimeout(()=>t.abort(),Q0);try{return await e(t.signal)}finally{window.clearTimeout(n)}}async function Ip(e=""){const t=await Ns(r=>fetch(_s("/auth/status",e),{method:"GET",credentials:"same-origin",headers:{accept:"application/json"},cache:"no-store",signal:r}));if(!t.ok)throw new Error(`auth_status_http_${String(t.status)}`);const n=await t.json(),s={authEnabled:n.authEnabled===!0,authenticated:n.authenticated===!0,user:n.user??null,csrfToken:typeof n.csrfToken=="string"?n.csrfToken:null,loginBackends:Array.isArray(n.loginBackends)?n.loginBackends:[],publicOrigin:typeof n.publicOrigin=="string"?n.publicOrigin:null,...typeof n.username=="string"?{username:n.username}:{},...typeof n.passwordSet=="boolean"?{passwordSet:n.passwordSet}:{},...n.passwordSource==="env"||n.passwordSource==="file"?{passwordSource:n.passwordSource}:{passwordSource:null},...typeof n.totpRequired=="boolean"?{totpRequired:n.totpRequired}:{},...typeof n.recoveryCodesLeft=="number"?{recoveryCodesLeft:n.recoveryCodesLeft}:{}};return js(s.csrfToken),s}async function Rp(e=""){const t=await Ns(r=>fetch(_s("/auth/csrf",e),{method:"GET",credentials:"same-origin",headers:{accept:"application/json"},cache:"no-store",signal:r}));if(!t.ok)return null;const n=await t.json(),s=typeof n.csrfToken=="string"?n.csrfToken:null;return js(s),s}async function X0(e=""){const t=gr(),n=await Ns(s=>fetch(_s("/auth/logout",e),{method:"POST",credentials:"same-origin",headers:{accept:"application/json",...t!==""?{[pr]:t}:{}},cache:"no-store",signal:s}));return js(null),n.ok}async function Oc(e,t,n=""){const s=await Ns(l=>fetch(_s(e,n),{method:"POST",credentials:"same-origin",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify(t),cache:"no-store",signal:l})),r=await s.json().catch(()=>null),i=typeof r=="object"&&r!==null?r:{};return{status:s.status,body:i}}function Ui(e,t){const n=typeof t.error=="string"?t.error:void 0;return{ok:e===200&&t.ok===!0,...typeof t.totpRequired=="boolean"?{totpRequired:t.totpRequired}:{},...typeof t.ticket=="string"?{ticket:t.ticket}:{},...typeof t.expiresAt=="number"?{expiresAt:t.expiresAt}:{},...typeof t.recoveryAllowed=="boolean"?{recoveryAllowed:t.recoveryAllowed}:{},...n!==void 0?{error:n}:{},...typeof t.message=="string"?{message:t.message}:{},...typeof t.retryAfterSeconds=="number"?{retryAfterSeconds:t.retryAfterSeconds}:{},...typeof t.locked=="boolean"?{locked:t.locked}:{}}}async function Z0(e,t,n=""){const{status:s,body:r}=await Oc("/auth/login",{username:e,password:t},n);return s===200&&js(null),Ui(s,r)}async function ek(e,t,n=""){const{status:s,body:r}=await Oc("/auth/login/totp",{ticket:e,code:t},n);return s===200&&js(null),Ui(s,r)}async function tk(e,t=""){const{status:n,body:s}=await Oc("/auth/bootstrap",{code:e},t),r=typeof s.error=="string"?s.error:void 0;return{ok:n===200&&s.ok===!0,...typeof s.bootstrap=="boolean"?{bootstrap:s.bootstrap}:{},...Array.isArray(s.capabilities)?{capabilities:s.capabilities.filter(i=>typeof i=="string")}:{},...typeof s.passwordSet=="boolean"?{passwordSet:s.passwordSet}:{},...r!==void 0?{error:r}:{},...typeof s.message=="string"?{message:s.message}:{}}}async function nk(e,t=""){const n=gr(),s=await Ns(l=>fetch(_s("/auth/password/set",t),{method:"POST",credentials:"same-origin",headers:{accept:"application/json","content-type":"application/json",...n!==""?{[pr]:n}:{}},body:JSON.stringify({password:e}),cache:"no-store",signal:l})),r=await s.json().catch(()=>null),i=typeof r=="object"&&r!==null?r:{};return js(null),s.ok&&await Rp(t).catch(()=>null),Ui(s.status,i)}async function sk(e=""){const t=gr(),n=await Ns(i=>fetch(_s("/auth/setup/finish",e),{method:"POST",credentials:"same-origin",headers:{accept:"application/json","content-type":"application/json",...t!==""?{[pr]:t}:{}},body:"{}",cache:"no-store",signal:i})),s=await n.json().catch(()=>null),r=typeof s=="object"&&s!==null?s:{};return js(null),Ui(n.status,r)}async function ok(e=""){const t=gr(),n=await Ns(l=>fetch(_s("/auth/totp/enroll",e),{method:"POST",credentials:"same-origin",headers:{accept:"application/json","content-type":"application/json",...t!==""?{[pr]:t}:{}},body:"{}",cache:"no-store",signal:l})),s=await n.json().catch(()=>null),r=typeof s=="object"&&s!==null?s:{},i=typeof r.error=="string"?r.error:void 0;return{ok:n.status===200&&r.ok===!0,...typeof r.secret=="string"?{secret:r.secret}:{},...typeof r.otpauthUri=="string"?{otpauthUri:r.otpauthUri}:{},...Array.isArray(r.recoveryCodes)?{recoveryCodes:r.recoveryCodes.filter(l=>typeof l=="string")}:{},...i!==void 0?{error:i}:{},...typeof r.message=="string"?{message:r.message}:{}}}class jn extends Error{constructor(t,n,s){super(n),this.code=t,this.status=s,this.name="PlatformRpcError"}code;status}const rk=1e4;class ik{constructor(t="",n=""){this.baseUrl=t,this.token=n}baseUrl;token;origin(){const t=this.baseUrl.trim().replace(/\/+$/,"");return t!==""?t:window.location.origin}originUrl(){return this.origin()}async rpc(t,n){const s=new AbortController,r=window.setTimeout(()=>s.abort(),rk),i=gr();let l;try{l=await fetch(`${this.origin()}/platform/rpc`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",...i!==""?{[pr]:i}:{},...this.token!==""?{Authorization:`Bearer ${this.token}`}:{}},body:JSON.stringify({v:1,id:crypto.randomUUID(),method:t,...n!==void 0?{params:n}:{}}),signal:s.signal})}catch(d){throw new jn("network",d instanceof Error&&d.name==="AbortError"?"platform request timeout":d instanceof Error?d.message:String(d))}finally{window.clearTimeout(r)}let c=null;try{c=await l.json()}catch{c=null}if(!l.ok){const d=c?.error?.code??`http_${l.status}`;throw(d==="session_required"||d==="csrf_failed")&&qc(),new jn(d,c?.error?.message??`HTTP ${l.status}`,l.status)}if(c?.ok!==!0)throw new jn(c?.error?.code??"internal",c?.error?.message??`RPC failed: ${t}`);return c.result}whoami(){return this.rpc("platform.whoami")}async listNodes(){const t=await this.rpc("platform.nodes.list");return Array.isArray(t?.nodes)?t.nodes:[]}credentials(t){return t===void 0?this.rpc("platform.nodes.credentials"):this.rpc("platform.nodes.credentials",{node_id:t})}}function ak(e){return e.code==="network"?!0:e.status===404||e.status===405}async function lk(e){try{return{kind:"platform",whoami:await e.whoami()}}catch(t){const n=t instanceof jn?t:new jn("internal",t instanceof Error?t.message:String(t));return ak(n)?{kind:"legacy"}:{kind:"error",error:n}}}const Ma="vessel.hub.url",wo="vessel.hub.token";function Ru(e,t){try{return e.getItem(t)??""}catch{return""}}function Lu(e,t,n){try{e.setItem(t,n)}catch{}}function Er(e,t){try{e.removeItem(t)}catch{}}function ck(e){return{read(){return{url:Ru(e,Ma),token:Ru(e,wo)}},save(t,n){Lu(e,Ma,t),n!==""?Lu(e,wo,n):Er(e,wo)},clearToken(){Er(e,wo)},clear(){Er(e,Ma),Er(e,wo)}}}function Au(){const e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}let Pa=null;function Lp(){if(Pa===null){let e;try{e=typeof sessionStorage>"u"?Au():sessionStorage}catch{e=Au()}Pa=ck(e)}return Pa}function Dc(){return Lp().read()}const Ap="vessel.web.hubVersion";function dk(){try{const t=globalThis.sessionStorage?.getItem(Ap)?.trim();return t!==void 0&&t.length>0?t:void 0}catch{return}}function uk(e){try{globalThis.sessionStorage?.setItem(Ap,e)}catch{}}let si=null;const Nl=new Set;function gi(){if(si===null){const e=Dc().url!==""?"unknown":"unconfigured",t=dk();si=t!==void 0?{status:e,version:t}:{status:e}}return si}function er(e,t){const n=gi(),s=t??n.version;if(!(n.status===e&&n.version===s)){si=s!==void 0?{status:e,version:s}:{status:e},s!==void 0&&uk(s);for(const r of[...Nl])r()}}function mk(e){return Nl.add(e),()=>{Nl.delete(e)}}const bi="vessel.hub/2",fk=1e4,hk=8643,pk=1e3,gk=3e4,bk=4e3,vk="/v1/hub/events",yk="/v1/hub/directory",xk="/health",wk=e=>new globalThis.WebSocket(e);function Mp(e={}){return{fetch:(t,n)=>globalThis.fetch(t,n),WebSocket:wk,setTimeout:(t,n)=>globalThis.setTimeout(t,n),clearTimeout:t=>globalThis.clearTimeout(t),storage:Lp(),...e}}class fs extends Error{constructor(t,n,s){super(n),this.kind=t,this.status=s,this.name="HubClientError"}kind;status}function Pp(e){const t=e.trim();if(t==="")return null;let n;try{n=new URL(t)}catch{return null}return n.protocol!=="http:"&&n.protocol!=="https:"||n.username!==""||n.password!==""||n.pathname!=="/"||n.search!==""||n.hash!==""?null:n.origin}function kk(e){try{return Tc(new URL(e).hostname)}catch{return!1}}function Cl(){const e=globalThis.location;return e===void 0||e.protocol==="https:"||!Tc(e.hostname)?null:`http://${e.hostname}:${hk}`}function Sk(e){return(typeof globalThis.location>"u"?"":globalThis.location.protocol)==="https:"&&e.startsWith("http:")}function jk(e){return e.replace(/^https:/,"wss:").replace(/^http:/,"ws:")}function br(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vt(e){return typeof e=="string"?e:void 0}function bn(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const _k=new Set(["connecting","healthy","unreachable","incompatible","unauthorized","identity_mismatch"]);function Nk(e){return br(e)?{teams:bn(e.teams)??0,agents:bn(e.agents)??0,live_agents:bn(e.live_agents)??0}:{teams:0,agents:0,live_agents:0}}function Ck(e){if(!br(e))return null;const t=vt(e.node_id),n=vt(e.status);if(!t||!n||!_k.has(n))return null;const s=e.data_plane==="direct"||e.data_plane==="unreachable"?e.data_plane:void 0,r=e.direction==="hub"||e.direction==="node"?e.direction:void 0;return{node_id:t,status:n,truncated:e.truncated===!0,counts:Nk(e.counts),...vt(e.name)!==void 0?{name:vt(e.name)}:{},...vt(e.alias)!==void 0?{alias:vt(e.alias)}:{},...vt(e.url)!==void 0?{url:vt(e.url)}:{},...vt(e.public_url)!==void 0?{public_url:vt(e.public_url)}:{},...s!==void 0?{data_plane:s}:{},...r!==void 0?{direction:r}:{},...bn(e.last_seen)!==void 0?{last_seen:bn(e.last_seen)}:{},...vt(e.last_error)!==void 0?{last_error:vt(e.last_error)}:{}}}function qp(e){if(!br(e)||!Array.isArray(e.nodes))return null;const t=vt(e.hub_id);if(t===void 0)return null;const n=bn(e.updated_at)??bn(e.observed_at)??Date.now(),s=e.nodes.map(Ck).filter(i=>i!==null),r=vt(e.version);return{v:1,hub_id:t,updated_at:n,nodes:s,...r!==void 0?{version:r}:{}}}function Tk(e){const t=vt(e.node_id),n=vt(e.hub_id),s=vt(e.team_id),r=vt(e.reason);if(!t||!n||!s||!r)return null;const i=vt(e.request_id);return{v:1,kind:"pointer",protocol:bi,dialer:vt(e.dialer)??"hub",node_id:t,hub_id:n,team_id:s,reason:r,ts:bn(e.ts)??Date.now(),...i!==void 0?{request_id:i}:{}}}function Ek(e){let t;try{t=JSON.parse(e)}catch{return null}if(!br(t)||t.v!==1)return null;if(typeof t.protocol=="string"&&t.protocol!==bi)return{kind:"incompatible"};switch(t.kind){case"hello":{const n=vt(t.hub_id);return n===void 0?null:{kind:"hello",hubId:n,revision:bn(t.revision)}}case"directory":{const n=qp(t);return n===null?null:{kind:"directory",directory:n}}case"pointer":{const n=Tk(t);return n===null?null:{kind:"pointer",pointer:n}}case"ping":return{kind:"ping"};default:return null}}function Op(e,t,n,s){let r=null,i=!1,l=0,c;function d(){l+=1;const f=Math.min(gk,pk*2**(l-1));s.onDisconnected?.({attempt:l,retryInMs:f}),c=n.setTimeout(m,f)}function m(){if(i)return;let f;try{f=n.WebSocket(`${jk(e)}${vk}`)}catch{d();return}r=f,f.addEventListener("open",()=>{l=0,s.onOpen?.();const h={v:1,kind:"auth",protocol:bi,dialer:"hub",...t!==""?{token:t}:{}};f.send(JSON.stringify(h))}),f.addEventListener("message",h=>{if(typeof h.data!="string")return;const p=Ek(h.data);if(p!==null)switch(p.kind){case"hello":s.onHello?.({hubId:p.hubId,revision:p.revision});break;case"directory":s.onDirectory?.(p.directory);break;case"pointer":s.onPointer?.(p.pointer);break;case"ping":f.readyState===1&&f.send(JSON.stringify({v:1,kind:"pong",protocol:bi,dialer:"hub"}));break;case"incompatible":s.onIncompatible?.();try{f.close(4400,"incompatible")}catch{}break}}),f.addEventListener("error",()=>{}),f.addEventListener("close",h=>{if(r===f&&(r=null),!i){if(h.code===4401){s.onUnauthorized?.();return}if(h.code===4400){s.onIncompatible?.();return}d()}})}return m(),{close(){i=!0,c!==void 0&&(n.clearTimeout(c),c=void 0);const f=r;r=null,f?.close(1e3,"client closed")}}}class Mu{baseUrl;token;deps;constructor(t){const n=Pp(t.baseUrl);if(n===null)throw new fs("invalid_url","invalid hub url");this.baseUrl=n,this.token=t.token?.trim()??"",this.deps=Mp(t.deps)}async request(t,n){const s=new AbortController,r=this.deps.setTimeout(()=>s.abort(),fk),i=n&&this.token!==""&&!kk(this.baseUrl);let l;try{l=await this.deps.fetch(`${this.baseUrl}${t}`,{method:"GET",headers:i?{Authorization:`Bearer ${this.token}`}:{},signal:s.signal})}catch(d){throw new fs("network",d instanceof Error&&d.name==="AbortError"?"hub request timeout":d instanceof Error?d.message:String(d))}finally{this.deps.clearTimeout(r)}let c=null;try{c=await l.json()}catch{c=null}if(!l.ok){const d=l.status===401?"unauthorized":l.status===403?"forbidden":"http";throw new fs(d,`HTTP ${l.status}`,l.status)}return c}async health(){const t=await this.request(xk,!1);if(!br(t)||t.ok!==!0)throw new fs("http","invalid hub health response");const n=vt(t.version);return{ok:!0,hub_id:vt(t.hub_id)??"",nodes:bn(t.nodes)??0,now:bn(t.now)??Date.now(),...n!==void 0?{version:n}:{}}}async directory(){const t=qp(await this.request(yk,!0));if(t===null)throw new fs("http","invalid hub directory response");return t}events(t){return Op(this.baseUrl,this.token,this.deps,t)}}class Dp{deps;state;listeners=new Set;events=null;pointerTimer;epoch=0;stopped=!1;constructor(t={}){this.deps=Mp(t.deps);const n=this.deps.storage.read(),s=n.url===""?Cl():null;this.state={status:n.url!==""||s!==null?"loading":"unconfigured",url:n.url!==""?n.url:s??"",hasToken:n.token!=="",directory:null,pointer:null,live:!1,reconnecting:!1,connecting:!1,connectError:null}}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;patch(t){this.state={...this.state,...t};for(const n of[...this.listeners])n()}clearPointerTimer(){this.pointerTimer!==void 0&&(this.deps.clearTimeout(this.pointerTimer),this.pointerTimer=void 0)}stopEvents(){this.events?.close(),this.events=null}handleUnauthorized(t){t===this.epoch&&(this.stopped=!0,this.epoch+=1,this.stopEvents(),this.clearPointerTimer(),this.deps.storage.clearToken(),this.patch({status:"unauthorized",hasToken:!1,directory:null,pointer:null,live:!1,reconnecting:!1,connecting:!1,connectError:null}))}async loadDirectory(t,n,s){try{const r=await new Mu({baseUrl:t,token:n,deps:this.deps}).directory();if(s!==this.epoch||this.stopped||this.state.status==="incompatible")return;this.patch({directory:r,status:r.nodes.length===0?"empty":"connected"})}catch(r){if(s!==this.epoch||this.stopped)return;const i=r instanceof fs?r.kind:"http";if(i==="unauthorized"||i==="forbidden"){this.handleUnauthorized(s);return}this.state.directory===null&&this.patch({status:"network"})}}openEvents(t,n,s){this.stopped||s!==this.epoch||(this.events=Op(t,n,this.deps,{onOpen:()=>{s!==this.epoch||this.stopped||this.patch({live:!0,reconnecting:!1})},onDirectory:r=>{s!==this.epoch||this.stopped||this.patch({directory:r,status:r.nodes.length===0?"empty":"connected",live:!0,reconnecting:!1})},onPointer:r=>{s!==this.epoch||this.stopped||(this.clearPointerTimer(),this.patch({pointer:r}),this.pointerTimer=this.deps.setTimeout(()=>{this.pointerTimer=void 0,this.patch({pointer:null})},bk))},onUnauthorized:()=>{this.handleUnauthorized(s)},onIncompatible:()=>{s!==this.epoch||this.stopped||this.patch({status:"incompatible",live:!1,reconnecting:!1})},onDisconnected:()=>{s!==this.epoch||this.stopped||(this.state.directory===null?this.patch({status:"network",live:!1,reconnecting:!1}):this.patch({live:!1,reconnecting:!0}))}}))}async connect(t){const n=this.deps.storage.read(),s=t===void 0&&n.url===""?Cl():null,r=t??(s!==null?{url:s,token:""}:n),i=Pp(r.url);if(i===null||Sk(i))return t!==void 0?this.patch({connectError:"invalid_url",connecting:!1}):this.patch({status:"unconfigured",url:"",hasToken:!1}),{ok:!1,error:"invalid_url"};const l=r.token.trim();this.stopped=!1,this.epoch+=1;const c=this.epoch;this.stopEvents(),this.clearPointerTimer(),this.patch({status:"loading",url:i,hasToken:l!=="",directory:null,pointer:null,live:!1,reconnecting:!1,connecting:!0,connectError:null});try{await new Mu({baseUrl:i,token:l,deps:this.deps}).health()}catch(d){if(c!==this.epoch||this.stopped)return{ok:!1,error:"network"};const m=d instanceof fs?d.kind:"network",f=m==="network"||m==="forbidden"?"network":m==="invalid_url"?"invalid_url":m==="unauthorized"?"unauthorized":"http";return this.patch({status:"unconfigured",url:i,connecting:!1,connectError:f}),{ok:!1,error:m}}return c!==this.epoch||this.stopped?{ok:!1,error:"network"}:(this.deps.storage.save(i,l),this.patch({connecting:!1,connectError:null}),this.openEvents(i,l,c),this.loadDirectory(i,l,c),{ok:!0})}async retry(){return this.connect()}disconnect(){this.stopped=!0,this.epoch+=1,this.stopEvents(),this.clearPointerTimer(),this.deps.storage.clear(),this.patch({status:"unconfigured",url:"",hasToken:!1,directory:null,pointer:null,live:!1,reconnecting:!1,connecting:!1,connectError:null})}close(){this.stopped=!0,this.epoch+=1,this.stopEvents(),this.clearPointerTimer()}}function Pu(e){return e instanceof jn?e:new jn("internal",e instanceof Error?e.message:String(e))}async function Ik(e,t={}){const n=await lk(e);if(n.kind!=="platform")return n;let s;try{s=await e.listNodes()}catch(y){return{kind:"error",error:Pu(y)}}const r=t.preferredNodeId??null,i=J0(s,r,t.requirePreferredUp??!0);if(i===null)return{kind:"error",error:new jn("no_nodes","Platform returned no nodes")};const l=i.node,c=n.whoami.proxy;if(c?.enabled===!0){const y=c.base_path??"/nodes",v=e.originUrl();return{kind:"platform",connection:{whoami:n.whoami,node:l,nodes:s,nodeCredentials:[],nodeToken:"",anonymous:!1,credentialsError:null,proxy:{baseUrl:`${v}${y}/${encodeURIComponent(l.node_id)}`,platformOrigin:v},selection:{preferredNodeId:r,fallback:i.fallback}}}}const d=s.length>1,m=await Promise.all(s.map(async y=>{try{const v=d?await e.credentials(y.node_id):await e.credentials(),j=v.mode==="token"&&typeof v.token=="string"?v.token:"";return{node_id:y.node_id,token:j,anonymous:v.mode==="none",error:null}}catch(v){return{node_id:y.node_id,token:"",anonymous:!1,error:Pu(v)}}})),f=m.find(y=>y.node_id===l.node_id),h=f?.error??null,p=f?.anonymous??!1,g=f?.token??"",b=(t.manualNodeToken??"").trim(),x=b!==""?b:p?"":g;return{kind:"platform",connection:{whoami:n.whoami,node:l,nodes:s,nodeCredentials:m,nodeToken:x,anonymous:p,credentialsError:h,proxy:null,selection:{preferredNodeId:r,fallback:i.fallback}}}}const vr=u.createContext(null),Rk=3e4,qu=1e4;function Ir(e){return typeof e=="string"&&e.length>0}function qa(e){return typeof e=="number"&&Number.isFinite(e)}function Lk(e,t,n){if(e.type!=="agent.retired")return null;const s=e.data;if(s.reason!=="rotation"||!Ir(s.new_session_id)||!Ir(s.agent_id)||!Ir(s.session_id)||!qa(s.epoch))return null;const r=qa(e.ts)?e.ts:qa(s.ts)?s.ts:void 0;if(r===void 0||t-r>Rk)return null;const i=n.get(s.agent_id);return i!==void 0&&s.epoch<=i?null:(n.set(s.agent_id,s.epoch),{agentId:s.agent_id,epoch:s.epoch,oldSessionId:s.session_id,newSessionId:s.new_session_id,...Ir(s.name)?{name:s.name}:{}})}function Ou(e,t){return e.domain==="chat"&&e.sessionId===t}function Du(e){return e===void 0?!1:e.text.length>0||e.chips.length>0||e.refs.length>0||e.sessionRefs.length>0||e.quote!==void 0||e.model!==void 0}const tr={phase:"idle"};function Ak(e,t,n){return{phase:"countdown",candidate:e,deadline:t+qu,manual:n,secondsLeft:Math.ceil(qu/1e3)}}function Mk(e,t){if(e.phase!=="countdown"||e.manual)return{state:e,effect:"none"};if(t.now<e.deadline){const n=Math.max(1,Math.ceil((e.deadline-t.now)/1e3));return n===e.secondsLeft?{state:e,effect:"none"}:{state:{...e,secondsLeft:n},effect:"none"}}return!t.viewingOldSession||t.composerNonEmpty?{state:tr,effect:"dismiss"}:{state:tr,effect:"switch"}}function Pk(e){return e.phase!=="countdown"?{state:e,effect:"none"}:{state:tr,effect:"switch"}}function qk(e){return e.phase==="countdown"?tr:e}const Hp="vessel.gateway.expired-interactions",Ok=500;function $p(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}function Fp(e=$p()){if(e===null)return[];try{const t=e.getItem(Hp);if(t===null||t==="")return[];const n=JSON.parse(t);return Array.isArray(n)?n.filter(s=>typeof s=="string"&&s.length>0):[]}catch{return[]}}function Dk(e,t=$p()){if(t===null||e.length===0)return[];const n=[...new Set([...Fp(t),e])],s=n.slice(Math.max(0,n.length-Ok));try{t.setItem(Hp,JSON.stringify(s))}catch{}return s}function Hc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ms(e){return typeof e=="string"&&e.length>0?e:void 0}function $c(e){return Ms(e.delegate_id)??Ms(e.delegateId)??Ms(e.agent_id)??Ms(e.agentId)??Ms(e.parent_delegate_id)??Ms(e.parentDelegateId)}function Hk(e,t=Date.now()){const n=e.data,s=n.requestId??n.request_id;if(typeof s!="string"||s.length===0)return null;const r=$c(n);return{requestId:s,tool:typeof n.tool=="string"?n.tool:"tool",input:n.input,runId:e.run_id,...typeof n.session_id=="string"&&n.session_id.length>0?{sessionId:n.session_id}:{},...typeof n.parent_session_id=="string"&&n.parent_session_id.length>0?{parentSessionId:n.parent_session_id}:{},...typeof n.parent_agent_id=="string"&&n.parent_agent_id.length>0?{parentAgentId:n.parent_agent_id}:{},...typeof n.team_id=="string"&&n.team_id.length>0?{teamId:n.team_id}:{},...typeof n.tool_call_id=="string"&&n.tool_call_id.length>0?{toolCallId:n.tool_call_id}:{},...typeof n.source=="string"&&n.source.length>0?{source:n.source}:{},...r!==void 0?{agentId:r}:{},requestedAt:Hc(e.ts)?e.ts:t}}function $k(e,t=Date.now()){const n=e.data,s=n.requestId??n.request_id;if(typeof s!="string"||s.length===0||!Array.isArray(n.questions))return null;const r=n.questions.filter(l=>!!l&&typeof l=="object"&&typeof l.question=="string");if(r.length===0)return null;const i=$c(e.data);return{requestId:s,questions:r,runId:e.run_id,requestedAt:Hc(e.ts)?e.ts:t,...typeof n.session_id=="string"&&n.session_id.length>0?{sessionId:n.session_id}:{},...typeof n.parent_session_id=="string"&&n.parent_session_id.length>0?{parentSessionId:n.parent_session_id}:{},...typeof n.parent_agent_id=="string"&&n.parent_agent_id.length>0?{parentAgentId:n.parent_agent_id}:{},...typeof n.team_id=="string"&&n.team_id.length>0?{teamId:n.team_id}:{},...i!==void 0?{agentId:i}:{},...n.mode==="async"?{mode:"async"}:{}}}function Fk(e,t=Date.now()){const n=e.data,s=n.requestId??n.request_id;if(typeof s!="string"||s.length===0||typeof n.title!="string"||typeof n.body!="string")return null;const r=$c(e.data);return{requestId:s,title:n.title,body:n.body,...Array.isArray(n.refs)?{refs:n.refs.filter(i=>typeof i=="string")}:{},...n.salience==="high"?{salience:"high"}:{},runId:e.run_id,requestedAt:Hc(e.ts)?e.ts:t,...typeof n.session_id=="string"&&n.session_id.length>0?{sessionId:n.session_id}:{},...typeof n.parent_agent_id=="string"&&n.parent_agent_id.length>0?{parentAgentId:n.parent_agent_id}:{},...typeof n.team_id=="string"&&n.team_id.length>0?{teamId:n.team_id}:{},...r!==void 0?{agentId:r}:{}}}function Oa(e){return typeof e=="object"&&e!==null&&e.code==="not_found"?!0:e instanceof Error&&e.message.startsWith("not_found:")}function Da(e){return typeof e=="object"&&e!==null&&e.code==="expired"?!0:e instanceof Error&&e.message.startsWith("expired:")}function Ha(e){if(typeof e=="object"&&e!==null){const t=e.code;if(t==="run_ended"||t==="orphaned")return!0}return e instanceof Error&&e.message.startsWith("run_ended:")}function Tl(){return a("permission.expired")}function Hu(){return a("permission.runEnded")}function Bk(e,t="once"){return{decision:e,scope:t,...t==="always"?{remember:!0}:{}}}class Kk{inFlight=new Set;begin(t){return!t||this.inFlight.has(t)?!1:(this.inFlight.add(t),!0)}end(t){this.inFlight.delete(t)}has(t){return this.inFlight.has(t)}}const Wk=2e3,Uk=3e4,zk={phase:"connected",visible:!1,disconnectedAt:null};function Vk(e={}){const t=e.graceMs??Wk,n=e.now??(()=>Date.now());let s="connected",r=null,i=zk;const l=(c,d)=>(c===s&&d===r||(s=c,r=d,i={phase:c,visible:c==="offline",disconnectedAt:d}),i);return{snapshot:()=>i,onConnectionState(c){return c==="open"?l("connected",null):r!==null?i:l("grace",n())},onWake(){return s!=="grace"||r===null||n()-r<t?i:l("offline",r)},noticeAt(){return s!=="grace"||r===null?null:r+t}}}function Gk(){let e=!1;return{onConnectionHello(){return e?!0:(e=!0,!1)},reset(){e=!1}}}function Yk(e){return e.detector.onConnectionHello()?(e.onReconnected(),!0):!1}class Pt extends Error{constructor(t,n,s,r){super(n),this.code=t,this.status=s,this.details=r,this.name="GatewayHttpError"}code;status;details}function Jk(e){const t=c=>typeof c=="number"&&Number.isInteger(c)&&c>=0,{start_seq:n,end_seq:s,count:r,timeline_head:i,wal_head:l}=e;if(!(!t(n)||!t(s)||!t(r))&&!(!t(i)||!t(l)))return{start_seq:n,end_seq:s,count:r,timeline_head:i,wal_head:l,...t(e.published_head)?{published_head:Math.min(e.published_head,l)}:{},holes:Array.isArray(e.holes)?e.holes:[],tainted:e.tainted===!0,...e.reset===!0?{reset:!0}:{}}}const Qk=3e4;class Xk{baseUrl;proxyMode;token=null;ws=null;state="idle";helloInfo=null;lastCloseCode=null;eventListeners=new Set;stateListeners=new Set;helloListeners=new Set;epochEndListeners=new Set;closeListeners=new Set;pending=new Map;connectResolve=null;connectReject=null;constructor(t="",n={}){this.baseUrl=Ec(t),this.proxyMode=n.proxy===!0}get connectionState(){return this.state}get protocol(){return this.helloInfo}get closedWithCode(){return this.lastCloseCode}setState(t){if(this.state!==t){this.state=t;for(const n of[...this.stateListeners])n(t)}}onState(t){return this.stateListeners.add(t),t(this.state),()=>this.stateListeners.delete(t)}onEvent(t){return this.eventListeners.add(t),()=>this.eventListeners.delete(t)}onHello(t){return this.helloListeners.add(t),()=>this.helloListeners.delete(t)}onEpochEnd(t){return this.epochEndListeners.add(t),()=>this.epochEndListeners.delete(t)}onClose(t){return this.closeListeners.add(t),()=>this.closeListeners.delete(t)}httpBase(){return this.baseUrl||sp()||"http://127.0.0.1"}wsUrl(t){return Yo(Ux(this.httpBase()),`/v1/events?since=${t}`)}async probeHealth(t=5e3){const n=new AbortController,s=globalThis.setTimeout(()=>n.abort(),t);try{const r=await fetch(Yo(this.httpBase(),"/health"),{method:"GET",credentials:this.proxyMode?"same-origin":"omit",signal:n.signal});if(r.ok)return;let i="internal",l=`HTTP ${r.status}`;try{const c=await r.json();c?.error?.code&&(i=c.error.code,l=c.error.message||l)}catch{console.warn("[vessel] degradation.used",{component:"web.protocol.error-body",from:"json-error-body",to:"http-status-only",reason:"non-JSON error body; HTTP status preserved",status:r.status})}throw new Pt(i,l,r.status)}catch(r){throw r instanceof Pt?r:r instanceof Error&&r.name==="AbortError"?new Pt("network",a("gateway.client.timeout")):new Pt("network",r instanceof Error?r.message:String(r))}finally{globalThis.clearTimeout(s)}}connect(t,n=0){const s=t.trim();return this.state==="open"?Promise.resolve():this.state==="connecting"&&this.connectResolve?new Promise((r,i)=>{const l=this.connectResolve,c=this.connectReject;this.connectResolve=()=>{l?.(),r()},this.connectReject=d=>{c?.(d),i(d)}}):(this.close(),this.token=s,new Promise((r,i)=>{this.connectResolve=r,this.connectReject=i,this.setState("connecting"),this.lastCloseCode=null;let l;try{l=new WebSocket(this.wsUrl(n))}catch(c){this.failConnect(c instanceof Error?c.message:String(c));return}this.ws=l,l.addEventListener("open",()=>{l.send(JSON.stringify({v:1,kind:"auth",token:s,since:n}))}),l.addEventListener("message",c=>{this.ws===l&&this.handleFrame(String(c.data))}),l.addEventListener("error",()=>{this.state==="connecting"&&this.failConnect(a("gateway.client.wsFailed"))}),l.addEventListener("close",c=>{if(this.ws!==l)return;this.ws=null,this.lastCloseCode=c.code,this.rejectPending(new Error(a("gateway.client.closedWithCode",{code:c.code})));const d=Zk(c.code);this.state==="connecting"?this.failConnect(d):this.setState(c.code===1e3?"closed":"error");for(const m of[...this.closeListeners])m(c.code)})}))}restart(t,n=0){return this.close(),this.connect(t,n)}failConnect(t){const n=this.connectReject;this.connectResolve=null,this.connectReject=null,this.setState("error"),n?.(new Error(t))}handleFrame(t){let n;try{n=JSON.parse(t)}catch{return}switch(n.kind){case"hello":{const s=Jk(n),r=this.connectResolve!==null;this.helloInfo={protocol:n.protocol,node:n.node,from_seq:n.from_seq,latest_seq:n.latest_seq,...r?{connectionLevel:!0}:{},...s!==void 0?{timeline:s}:{}},this.setState("open");const i=this.connectResolve;this.connectResolve=null,this.connectReject=null,i?.();for(const l of[...this.helloListeners])l(this.helloInfo);return}case"event":{for(const s of[...this.eventListeners])s(n.event,{seq:n.seq,...n.job_id?{jobId:n.job_id}:{}});return}case"timeline-epoch-end":{if(typeof n.end_seq!="number"||!Number.isFinite(n.end_seq)||typeof n.count!="number"||!Number.isFinite(n.count)||typeof n.has_more!="boolean")return;for(const s of[...this.epochEndListeners])s(n);return}case"res":{const s=this.pending.get(n.id);if(!s)return;this.pending.delete(n.id),globalThis.clearTimeout(s.timer),n.ok?s.resolve(n.result):s.reject(new Pt(n.error.code,`${n.error.code}: ${n.error.message}`,void 0,n.error.details));return}case"ping":{this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({v:1,kind:"pong"}));return}default:return}}rejectPending(t){for(const[,n]of this.pending)globalThis.clearTimeout(n.timer),n.reject(t);this.pending.clear()}request(t,n,s=Qk){const r=this.ws;if(!r||r.readyState!==WebSocket.OPEN||!this.helloInfo)return Promise.reject(new Error(a("gateway.client.notConnected")));const i=crypto.randomUUID();return new Promise((l,c)=>{const d=globalThis.setTimeout(()=>{this.pending.delete(i),c(new Error(a("gateway.client.requestTimeout",{method:t})))},s);this.pending.set(i,{resolve:m=>l(m),reject:c,timer:d}),r.send(JSON.stringify({v:1,kind:"req",id:i,method:t,params:n}))})}reportTimelineGap(t){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({v:1,kind:"timeline_gap",...t}))}close(){const t=this.ws;this.ws=null,this.token=null,this.helloInfo=null,this.rejectPending(new Error(a("gateway.client.closed"))),t&&t.close(),this.state!=="idle"&&this.setState("closed")}}function Zk(e){switch(e){case 4400:return a("gateway.connection.protocolMismatch");case 4401:return a("gateway.connection.authFailed");case 4403:return a("gateway.connection.forbiddenTenant");case 1001:return a("gateway.client.stopped");case 1006:return a("gateway.client.unreachable");default:return a("gateway.client.closedWithCode",{code:e})}}class eS extends Xk{async rpc(t,n){const s=await this.httpJson("/v1/rpc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({v:1,id:crypto.randomUUID(),method:t,...n!==void 0?{params:n}:{}})},t);if(!s.ok)throw new Pt(s.error?.code??"internal",s.error?.message??`RPC failed: ${t}`);return s.result}async httpJson(t,n={},s){const r=this.token;if(!r&&!this.proxyMode)throw new Pt("unauthorized",a("gateway.client.tokenRequiredHttp"));const i=new Headers(n.headers);r&&i.set("Authorization",`Bearer ${r}`);let l;try{l=await fetch(Yo(this.httpBase(),t),{...n,headers:i,...this.proxyMode?{credentials:"same-origin"}:{}})}catch(c){const d=new Pt("network",c instanceof Error?c.message:String(c));throw o0(d,s??t),d}if(!l.ok){let c="internal",d=`HTTP ${l.status}`,m;try{const h=await l.json();h?.error?.code&&(c=h.error.code,d=h.error.message||d),m=h?.error?.details}catch{console.warn("[vessel] degradation.used",{component:"web.rpc.error-body",from:"json-error-body",to:"http-status-only",reason:"non-JSON error body; HTTP status preserved",status:l.status,path:s??t})}const f=new Pt(c,d,l.status,m);throw n0(f,s??t),f}return s0(),await l.json()}}function tS(e){return e instanceof Pt?e.code==="not_found":e instanceof Error&&e.message.startsWith("not_found:")}function ko(e){return e instanceof Pt?e.status===404||e.status===405?!0:e.code==="method_not_allowed"||e.code==="method_not_found":!1}function us(e){return e instanceof Pt?e.status===404||e.status===405?!0:e.code==="method_not_allowed"||e.code==="method_not_found":!1}function $u(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&typeof t.role=="string"&&typeof t.content=="string"):[]}class Fu extends Error{constructor(t,n){super(n),this.code=t,this.name="AgentActionResultError"}code}function Xs(e){const t=e?.results?.[0];if(!t)throw new Fu("invalid_response","agents.* returned no results");if(!t.ok)throw new Fu(t.code??"internal",t.error??"Agent action failed");return t.agent??{}}class nS extends eS{async listSessions(){try{return(await this.rpc("sessions.list")).sessions??[]}catch(t){if(!us(t))throw t;return(await this.request("sessions.list")).sessions??[]}}async searchSessions(t,n){const s=t.trim();if(!s)return[];try{return(await this.rpc("sessions.search",{query:s,...n!==void 0?{limit:n}:{}})).sessions??[]}catch{return null}}deleteSession(t){return this.rpc("sessions.delete",{session_id:t})}createSession(t){return this.rpc("sessions.create",t)}activateSession(t){return this.rpc("sessions.activate",t)}renameSession(t,n){return this.rpc("sessions.rename",{session_id:t,title:n})}async listInteractions(t={}){return(await this.listInteractionsPage(t)).interactions}async listInteractionsPage(t={}){const n=await this.rpc("interactions.list",t),s=n.interactions??[];return{interactions:s,total:typeof n.total=="number"?n.total:s.length,...typeof n.next_cursor=="string"&&n.next_cursor.length>0?{next_cursor:n.next_cursor}:{}}}async getSession(t,n={}){const s={session_id:t,...n.message_limit!==void 0?{message_limit:n.message_limit}:{},...n.before!==void 0?{before:n.before}:{}};if(this.state==="open"&&this.helloInfo)try{const c=(await this.request("sessions.get",s)).session;if(!c)throw new Pt("not_found","Session not found");return{...c,messages:$u(c.messages)}}catch(l){if(tS(l))throw l}const i=(await this.rpc("sessions.get",s)).session;if(!i)throw new Pt("not_found","Session not found");return{...i,messages:$u(i.messages)}}async respondPermission(t,n,s="once"){await this.request("permission.respond",{request_id:t,...Bk(n,s)})}async respondAsk(t,n,s){return await this.request("ask.respond",{request_id:t,answers:n,...s!==void 0&&s!==""?{batch_id:s}:{}})??{}}async ackNotify(t){await this.request("notify.ack",{request_id:t})}}class sS extends nS{async submitRun(t,n,s,r){const i={input:t,...n?{session_id:n}:{},...s?{agent_id:s}:{},...r!==void 0&&r.length>0?{refs:r}:{}};try{return await this.rpc("runs.start",i)}catch(l){if(s||r!==void 0&&r.length>0||!ko(l))throw l;return this.request("run.submit",{input:t,...n?{session_id:n}:{}})}}async cancelRun(t){try{return await this.rpc("runs.cancel",{run_id:t})}catch(n){if(!ko(n))throw n;return this.request("run.cancel",{run_id:t})}}getRun(t){return this.request("run.get",{run_id:t})}async getRunStatus(t){try{return(await this.rpc("runs.get",{run_id:t})).run}catch(n){if(!ko(n))throw n;return this.request("run.get",{run_id:t})}}async listRuns(t={}){return(await this.rpc("runs.list",t)).runs??[]}async getRunCanonical(t){try{return(await this.rpc("runs.get",{run_id:t})).run}catch(n){if(!ko(n))throw n;return this.request("run.get",{run_id:t})}}async resumeRun(t){try{return await this.rpc("runs.resume",{run_id:t})}catch(n){if(!ko(n))throw n;return this.resumeDurableRun(t)}}async readEvents(t){return(await this.rpc("events.list",t)).events??[]}async listDurableRuns(t={}){const n=new URLSearchParams;t.status&&n.set("status",t.status),t.session_id&&n.set("session_id",t.session_id),t.agent_id&&n.set("agent_id",t.agent_id),t.limit!==void 0&&n.set("limit",String(t.limit));const s=n.toString();return(await this.httpJson(`/v1/durable/runs${s?`?${s}`:""}`)).runs??[]}resumeDurableRun(t){return this.httpJson(`/v1/durable/runs/${encodeURIComponent(t)}/resume`,{method:"POST"})}}class oS extends sS{listAgentsTree(t={}){return this.rpc("agents.tree",t)}async listAgents(){const t=await this.rpc("agents.list",{});return Array.isArray(t?.agents)?t.agents:[]}inbox(t){return this.rpc("agents.inbox",t)}async pinInboxMessage(t,n){return(await this.rpc("agents.send",{messages:[{to:t,message_id:n,interrupt:!0}]}))?.results?.[0]??{ok:!1,code:"internal",error:"empty result"}}async createAgent(t){return Xs(await this.rpc("agents.create",{agents:[t]}))}async updateAgent(t){return Xs(await this.rpc("agents.update",{agents:[t]}))}async closeAgent(t){return Xs(await this.rpc("agents.close",{agents:[{agent_id:t}]}))}}class rS extends oS{async listTeams(){return(await this.rpc("teams.list")).teams??[]}getTeam(t,n){return this.rpc("teams.get",{team_id:t,...n?.limit!==void 0?{limit:n.limit}:{},...n?.members_limit!==void 0?{members_limit:n.members_limit}:{},...n?.before!==void 0?{before:n.before}:{}})}postTeam(t){return this.rpc("teams.post",t)}createTeam(t){return this.rpc("teams.create",t)}updateTeam(t){return this.rpc("teams.update",t)}archiveTeam(t){return this.rpc("teams.archive",{team_id:t})}setSpawnFrozen(t,n){return this.rpc("teams.spawnFrozen",{team_id:t,frozen:n})}retractTeam(t){return this.rpc("teams.retract",t)}recallTeamDelivery(t){return this.rpc("teams.recall_delivery",t)}}class iS extends rS{listSubscriptions(t){return this.rpc("subscription.list",{...t!==void 0?{agent_id:t}:{}})}muteSubscription(t,n,s){return this.rpc("subscription.mute",{agent_id:t,source:n,...s!==void 0?{target:s}:{}})}unmuteSubscription(t,n,s){return this.rpc("subscription.unmute",{agent_id:t,source:n,...s!==void 0?{target:s}:{}})}addSubscription(t,n,s){return this.rpc("subscription.add",{agent_id:t,source:n,target:s})}removeSubscription(t,n,s){return this.rpc("subscription.remove",{agent_id:t,source:n,target:s})}subscriptionCatalog(){return this.rpc("subscription.catalog",{})}}class aS extends iS{async listTools(){return(await this.listToolsRaw()).tools??[]}async listToolsForAgent(t){return(await this.listToolsRaw({agent_id:t})).tools??[]}async listToolsRaw(t){try{return await this.rpc("tools.list",t)}catch(n){if(!us(n))throw n;return await this.request("tools.list",t)}}getCapabilities(){return this.rpc("capabilities.list")}async listPlugins(){try{return(await this.rpc("plugins.list",{})).plugins??[]}catch(t){if(!us(t))throw t;return(await this.request("plugins.list")).plugins??[]}}async getConfig(){return this.rpc("config.get",{})}async getConfigSources(){return this.rpc("config.sources",{})}setConfigValue(t,n,s){return this.rpc("config.set",s===void 0?{key:t,value:n}:{key:t,value:n,scope:s})}setPluginConfigValue(t,n,s){return this.rpc("plugins.config.set",{plugin:t,key:n,value:s})}reloadPlugins(){return this.rpc("plugins.reload",{})}setToolPolicy(t,n){return this.rpc("permissions.setToolPolicy",{tool:t,policy:n})}reload(t){return this.rpc("gateway.reload",{scopes:t})}async getHealth(){return this.rpc("health.get")}async getMetricsSnapshot(t="live"){try{return await this.rpc("metrics.get",{source:t})}catch(n){if(t==="live"&&us(n))return{metrics:(await this.httpJson("/v1/metrics")).metrics,source:"live"};throw n}}resetMetrics(){return this.rpc("metrics.reset",{})}reconnectMcp(t){return this.rpc("mcp.reconnect",{name:t})}runEval(t){return this.rpc("evals.run",{suite:t}).then(n=>n.report)}async listMcpServers(){try{return(await this.rpc("mcp.list",{})).servers??[]}catch(t){if(!us(t))throw t;return(await this.httpJson("/v1/mcp/servers")).servers??[]}}async getMetrics(t="live"){return(await this.getMetricsSnapshot(t)).metrics}async getFeishuStatus(){try{return(await this.rpc("feishu.status",{})).channel}catch(t){if(!us(t))throw t;return(await this.httpJson("/v1/channels/feishu")).channel}}async getLatestEval(t){try{return(await this.rpc("evals.latest",{suite:t})).report}catch(n){if(!us(n))throw n;const s=new URLSearchParams({suite:t});return(await this.httpJson(`/v1/evals/latest?${s.toString()}`)).report}}}function lS(e){let t="";for(let s=0;s<e.length;s+=32768)t+=String.fromCharCode(...e.subarray(s,s+32768));return btoa(t)}async function Bp(e,t){const n=[];for(const s of t)try{const r=new Uint8Array(await s.arrayBuffer()),i=await e.rpc("attachments.stage",{name:s.name,...s.type!==""?{mime:s.type}:{},data:lS(r)});n.push({ok:!0,...i})}catch(r){n.push({ok:!1,name:s.name,error:r instanceof Error?r.message:String(r)})}return n}class cS extends aS{listAttachments(t={}){return this.rpc("attachments.list",t)}previewAttachment(t){return this.rpc("attachments.preview",{path:t})}}class dS extends cS{imageBlob(t,n){return this.rpc("images.blob",{sha256:t,session_id:n})}}class uS extends dS{}function Ho(e){return e instanceof Error?e.message:String(e)}function Bu(e){return e===4401?{kind:"terminal",tokenError:a("gateway.connection.authFailed")}:e===4403?{kind:"terminal",lastError:a("gateway.connection.forbiddenTenant")}:e===4400?{kind:"terminal",lastError:a("gateway.connection.protocolMismatch")}:{kind:"reconnect"}}function Kp(e){return e instanceof Pt?e.status===401||e.code==="unauthorized"?{kind:"terminal",reason:"auth"}:e.status===403||e.code==="forbidden_origin"||e.code==="invalid_host"?{kind:"terminal",reason:"origin"}:e.code==="network"?{kind:"retryable"}:e.code==="node_unreachable"||e.code==="node_timeout"||e.code==="proxy_busy"||e.code==="node_not_found"?{kind:"retryable"}:e.status===502||e.status===503||e.status===504||e.status===404?{kind:"retryable"}:{kind:"terminal",reason:"other"}:{kind:"terminal",reason:"other"}}function Wp(e){return e instanceof Pt&&e.code==="network"?a("gateway.connection.unreachable",{detail:e.message}):Ho(e)}function El(e,t,n,s){e.probeHealth().then(()=>e.connect(t,n().since)).catch(s)}const $a=Number.MAX_SAFE_INTEGER;function Ku(e){const t=e.session_id;if(typeof t=="string"&&t.length>0)return t;const n=e.data.session_id;return typeof n=="string"&&n.length>0?n:void 0}function mS(e){const{client:t,token:n,eventStore:s,toast:r,subscription:i,recovery:l,settledRef:c,recordSettled:d,reportConnectError:m,setConnectionState:f,setHello:h,setReconnectAttempt:p,setTokenError:g,setGatewayError:b,setLastError:x,setEpoch:y,deferredErrorRef:v,startupGraceActive:j}=e;let _=!1,S,w=0;const k=Gk();s.clear();const N=new Map;s.setGapReporter(W=>{t.reportTimelineGap(rw(W,s.currentSeq,s.scopeSessionId))}),h(null),f("connecting"),p(0);const T=W=>{const Z=Hk(W);Z&&(c.current.has(Z.requestId)||dt.getState().dispatch({type:"permission-request",request:Z}))},R=(W,Z)=>{const ee=W.data,ie=ee.requestId??ee.request_id;if(typeof ie!="string"||ie.length===0)return;const le=dt.getState().permissions.some(J=>J.requestId===ie);d(ie),Z&&Dk(ie),dt.getState().dispatch({type:"settle",requestId:ie}),Z&&le&&r.info(Tl())},E=W=>{const Z=$k(W);Z&&(c.current.has(Z.requestId)||dt.getState().dispatch({type:"ask-request",request:Z}))},I=W=>{const Z=W.data;if(Z.final===!1)return;const ee=Z.requestId??Z.request_id;typeof ee!="string"||ee.length===0||(d(ee),dt.getState().dispatch({type:"settle",requestId:ee}))},$=W=>{const Z=Fk(W);Z&&(c.current.has(Z.requestId)||dt.getState().dispatch({type:"notice-request",request:Z}))},C=W=>{const Z=W.data,ee=Z.requestId??Z.request_id;typeof ee!="string"||ee.length===0||(d(ee),dt.getState().dispatch({type:"settle",requestId:ee}))},L=t.onEvent((W,Z)=>{if(s.push(W,Z)){if(W.type==="session.rewound"){const ee=Ku(W);ee!==void 0&&(s.dropSession(ee),l.onSessionHistoryChanged(ee))}if(W.type==="message.compaction"){const ee=Ku(W);ee!==void 0&&l.onSessionHistoryChanged(ee)}if(W.type==="tool.permission.request"&&T(W),W.type==="tool.permission.response"&&R(W,!1),W.type==="tool.permission.expired"&&R(W,!0),W.type==="ask.user.requested"&&E(W),W.type==="ask.user.answered"&&I(W),W.type==="notify.user.requested"&&$(W),W.type==="notify.user.acked"&&C(W),W.type==="agent.retired"){const ee=Lk(W,Date.now(),N);ee!==null&&l.onRotateCandidate?.(ee)}if(W.type==="run.completed"||W.type==="run.failed"||W.type==="run.cancelled"){const ee=dt.getState();for(const ie of ee.permissions)ie.runId===W.run_id&&d(ie.requestId);for(const ie of ee.asks)ie.mode!=="async"&&((ie.answeredQuestionIds?.length??0)>0||ie.runId===W.run_id&&d(ie.requestId));ee.dispatch({type:"run-finished",runId:W.run_id})}}}),A=t.onEpochEnd(W=>{s.endTimelineEpochPass(W)}),D=t.onHello(W=>{const Z=i.consumeHello(W);g(null),b(null),x(null),v.current=null,Z!=="subscribe"&&(w=0,p(0),h(W),y(ee=>ee+1),r0(),i.onConnectionHello(W.latest_seq),Yk({detector:k,onReconnected:l.onReconnected}))}),O=t.onState(W=>{_||f(W)}),F=W=>{const Z=Cp(w);w+=1,p(w),f("reconnecting"),S=window.setTimeout(()=>{_||W()},Z)},V=W=>{if(_)return;const Z=t.closedWithCode;if(Z!==null){if(Bu(Z).kind==="terminal"){m(W);return}j()&&(v.current=W);return}if(Kp(W).kind==="retryable"){j()&&(v.current=W),F(()=>{El(t,n,()=>({since:$a}),V)});return}m(W)},B=t.onClose(W=>{if(_)return;i.onDisconnect();const Z=Bu(W);if(Z.kind==="terminal"){Z.tokenError!==void 0&&g(Z.tokenError),Z.lastError!==void 0&&x(Z.lastError);return}F(()=>{t.connect(n,$a).catch(V)})});return El(t,n,()=>({since:$a}),V),()=>{_=!0,i.onDisconnect(),L(),D(),A(),O(),B(),window.clearTimeout(S),t.close()}}const Up={domain:"chat"},fS=new Set(["live","durable"]),hS=new Set(["tools","mcp","channels"]),pS=new Set(["metrics","evals","diagnostics","attention"]);function fn(e){try{return decodeURIComponent(e)}catch{return e}}function yn(e,t){const n=e.get(t);if(!(n===null||n===""))return fn(n)}function Fa(e,t,n){return e!==null&&t.has(e)?e:n}function Wu(e){const t=e.startsWith("#")?e.slice(1):e,n=t.startsWith("/")?t.slice(1):t,[s="",r=""]=n.split("?",2),i=s.split("/"),l=i.filter(Boolean),c=new URLSearchParams(r);switch(l[0]){case"chat":{const m=l[1]!==void 0?fn(l[1]):void 0,f=c.get("agent")!==null?fn(c.get("agent")??""):void 0;return{domain:"chat",...m?{sessionId:m}:{},...f?{agent:f}:{}}}case"pending":{const m=yn(c,"session");return{domain:"pending",...m?{sessionId:m}:{}}}case"runs":{const m=Fa(c.get("tab"),fS,"live"),f=l[1]!==void 0?fn(l[1]):yn(c,"run"),h=yn(c,"session");return{domain:"runs",tab:m,...f?{runId:f}:{},...h?{sessionId:h}:{}}}case"integrations":return{domain:Fa(l[1]??c.get("tab"),hS,"tools")};case"tools":return{domain:"tools"};case"mcp":return{domain:"mcp"};case"channels":return{domain:"channels"};case"kanban":return{domain:"kanban"};case"observe":return{domain:"observe",tab:Fa(l[1]??c.get("tab"),pS,"metrics")};case"plugins":{const m=l[1]!==void 0?fn(l[1]):void 0,f=l.length>2?fn(l.slice(2).join("/")):void 0;return{domain:"plugins",...m?{pluginId:m}:{},...f?{entry:f}:{}}}case"hub":return{domain:"hub"};case"gateway":return{domain:"gateway"};case"plugin-host":return{domain:"pluginHost"};case"nodes":{const m=l[1]!==void 0?fn(l[1]):void 0;return m?{domain:"nodes",nodeKey:m}:{domain:"nodes"}}case"teams":{if(i[1]==="")return{domain:"teams"};const m=l[1]!==void 0?fn(l[1]):void 0,f=l[2]!==void 0?fn(l[2]):void 0;if(!m||!f)return{domain:"teams"};const h=l[3]==="agents"&&l[4]!==void 0?fn(l[4]):void 0,p=h&&c.get("body")!==null?fn(c.get("body")??""):void 0;return{domain:"teams",nodeKey:m,teamId:f,...h?{agentId:h}:{},...p?{bodyId:p}:{}}}case"agents":{const m=yn(c,"node"),f=yn(c,"team"),h=yn(c,"state"),p=yn(c,"presence");return{domain:"agents",...m?{nodeKey:m}:{},...f?{teamId:f}:{},...h?{state:h}:{},...p?{presence:p}:{}}}case"capabilities":return{domain:"capabilities"};case"visual":return{domain:"settings",category:"visual"};case"designLab":return{domain:"designLab"};case"settings":{const m=l[1]??c.get("tab");if(m==="connection")return{domain:"gateway"};if(m==="capabilities")return{domain:"capabilities"};if(m==="appearance"||m==="display")return{domain:"settings",category:"visual"};const f=yn(c,"focus"),h=yn(c,"q"),p=yn(c,"category");return{domain:"settings",...f?{focusKey:f}:{},...h?{query:h}:{},...p?{category:p}:{}}}default:return{...Up}}}function Fn(e){switch(e.domain){case"chat":{const t=new URLSearchParams;e.agent&&t.set("agent",e.agent);const n=t.toString(),s=e.sessionId?`#/chat/${encodeURIComponent(e.sessionId)}`:"#/chat";return n?`${s}?${n}`:s}case"pending":return e.sessionId?`#/pending?${new URLSearchParams({session:e.sessionId}).toString()}`:"#/pending";case"runs":{if(e.runId){const n=new URLSearchParams;e.tab!=="live"&&n.set("tab",e.tab),e.sessionId&&n.set("session",e.sessionId);const s=n.toString(),r=`#/runs/${encodeURIComponent(e.runId)}`;return s?`${r}?${s}`:r}const t=new URLSearchParams({tab:e.tab});return e.sessionId&&t.set("session",e.sessionId),`#/runs?${t.toString()}`}case"tools":return"#/tools";case"mcp":return"#/mcp";case"channels":return"#/channels";case"kanban":return"#/kanban";case"observe":return`#/observe/${e.tab}`;case"plugins":{if(!e.pluginId)return"#/plugins";const t=`#/plugins/${encodeURIComponent(e.pluginId)}`;return e.entry?`${t}/${encodeURIComponent(e.entry)}`:t}case"hub":return"#/hub";case"gateway":return"#/gateway";case"pluginHost":return"#/plugin-host";case"nodes":return e.nodeKey?`#/nodes/${encodeURIComponent(e.nodeKey)}`:"#/nodes";case"teams":{if(!("teamId"in e))return"#/teams";const t=`#/teams/${encodeURIComponent(e.nodeKey)}/${encodeURIComponent(e.teamId)}`;if(!e.agentId)return t;const n=`${t}/agents/${encodeURIComponent(e.agentId)}`;return e.bodyId?`${n}?${new URLSearchParams({body:e.bodyId}).toString()}`:n}case"agents":{const t=new URLSearchParams;e.nodeKey&&t.set("node",e.nodeKey),e.teamId&&t.set("team",e.teamId),e.state&&t.set("state",e.state),e.presence&&t.set("presence",e.presence);const n=t.toString();return n?`#/agents?${n}`:"#/agents"}case"capabilities":return"#/capabilities";case"designLab":return"#/designLab";case"settings":{const t=new URLSearchParams;e.focusKey&&t.set("focus",e.focusKey),e.query&&t.set("q",e.query),e.category&&t.set("category",e.category);const n=t.toString();return n?`#/settings?${n}`:"#/settings"}}}function gS(e){const t=e.startsWith("#")?e.slice(1):e;if(!t.startsWith("token=")&&!t.startsWith("bootstrap="))return{restHash:e};const n=new URLSearchParams(t),s=n.get("token")??n.get("bootstrap")??void 0;return s?{token:s,restHash:""}:{restHash:e}}const bS="vessel-dev-proxy";function vS(e){const t=e.explicitToken.trim(),n=e.storedUrl?.trim()??"",s="";return t!==""||n!==""?{gatewayUrl:n!==""?n:s,token:e.explicitToken,devProxyAuth:!1}:{gatewayUrl:"",token:e.explicitToken,devProxyAuth:!1}}const Il="vessel.platform-token",$o="vessel.token";let Fc="";function yS(){return Fc}function xS(){Fc=""}function wS(){const{token:e,restHash:t}=gS(window.location.hash);return e?(Fc=e,window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}${t}`),e):""}function kS(){try{return sessionStorage.getItem(Il)??""}catch{return""}}function SS(){return sessionStorage.getItem($o)??""}function jS(){const e=Wx(localStorage.getItem(fi),void 0,window.location.protocol);return e.ok?{url:e.value,error:null}:{url:"",error:e.error??a("gateway.connection.invalidUrl")}}function _S(){const e=wS(),t=kS(),n=SS(),s=vS({explicitToken:t!==""?t:n,storedUrl:localStorage.getItem(fi)}),r=s.devProxyAuth?{url:"",error:null}:jS();return{platformUrl:r.url,platformUrlError:r.error,platformToken:t,bootstrapCode:e,legacyNodeToken:s.devProxyAuth?bS:n,devProxyAuth:s.devProxyAuth}}const Rl=new Set;function zp(e){return Rl.add(e),()=>{Rl.delete(e)}}function Uu(){for(const e of[...Rl])e()}const NS="events.session-filter",Rr=8e3;function CS(e,t){switch(e.kind){case"chat":return t.sessionFilter?{filter:{since:t.currentSeq,session_id:e.sessionId}}:{filter:{since:t.currentSeq},clientSessionFilter:e.sessionId};case"team":return{filter:{since:t.currentSeq,types:["run.*","agent.*"]}};case"runs":return{filter:{since:0,types:["run.*"]}};case"run":return{filter:{since:0,run_id:e.runId}};case"none":return{filter:{since:t.currentSeq,allow_global:!0}}}}function zu(e){switch(e.kind){case"chat":return`chat:${e.sessionId}`;case"run":return`run:${e.runId}`;default:return e.kind}}class TS{constructor(t,n){this.client=t,this.eventStore=n,this.eventStore.setEpochEndHook((s,r)=>{if(!this.advanceEpoch(s,r))return;const i=this.desired;i!==null&&(this.continuationPending=!0,this.appliedKey=null,this.apply(i))})}client;eventStore;desired=null;appliedKey=null;appliedScopeKey=null;pendingHello=null;running=null;clientFilter;lastBackfill=null;legacyScopes=new Set;backfilling=!1;loadingEarlier=!1;seqOverride=null;epochTarget=0;epochSubscribeFrom=0;epochStalls=0;continuationPending=!1;tailWindowFloor=0;timelineCursorUnavailable=!1;resetReanchor=!1;advanceEpoch(t,n){return n.hasMore===!1?(this.epochStalls=0,!1):t.end_seq>=this.epochTarget?(this.epochStalls=0,!1):(this.epochStalls=this.eventStore.currentSeq>this.epochSubscribeFrom?0:this.epochStalls+1,this.epochStalls<2)}apply(t){if(this.desired=t,this.running!==null)return this.running;const n=this.run();return this.running=n,n.then(()=>{this.running===n&&(this.running=null)},()=>{this.running===n&&(this.running=null)}),n}consumeHello(t){const n=ow(t.timeline);if((t.connectionLevel===!0||this.pendingHello===null)&&n===void 0&&this.supportsTimeline()&&this.desired?.kind==="chat")return this.epochTarget=0,this.eventStore.endTimelineEpoch(),this.eventStore.setSuppressLegacyFrames(!0),"connection";if(n!==void 0){const r=t.timeline?.published_head;if(this.epochTarget=typeof r=="number"?Math.min(n.wal_head,Math.min(r,n.wal_head)):n.wal_head,n.reset===!0)return this.eventStore.endTimelineEpoch(),this.eventStore.truncateAfter(0),this.eventStore.setSuppressLegacyFrames(!1),this.tailWindowFloor=_a(this.epochTarget)-1,this.eventStore.setSeqFloor(this.tailWindowFloor),this.resetReanchor=!0,this.pendingHello===null?"connection":(this.pendingHello=null,"subscribe");this.eventStore.beginTimelineEpoch(n)}else this.epochTarget=0,this.eventStore.endTimelineEpoch(),this.eventStore.setSuppressLegacyFrames(!1),t.from_seq>0&&this.eventStore.truncateAfter(Math.max(0,t.from_seq-1));return this.pendingHello===null?"connection":(this.pendingHello=null,"subscribe")}supportsTimeline(){return this.client.protocol?.protocol.features.includes("timeline.cursor")??!1}onConnectionHello(t){this.appliedKey=null,this.pendingHello=null;const n=this.desired;if(n===null){this.seqOverride=null;return}this.seqOverride=typeof t=="number"?t:null,this.apply(n)}onDisconnect(){this.pendingHello=null,this.appliedKey=null,this.eventStore.setScopeSession(void 0)}get fallbackSessionId(){return this.clientFilter}supportsSessionFilter(){return this.client.protocol?.protocol.features.includes(NS)??!1}eventsPageLimit=up;async readCursor(t){const n=await this.client.request("sessions.get",{session_id:t,message_limit:1},Rr);return uu(n?.session?.event_cursor)}async fetchTimelinePage(t,n,s){try{const r=await this.client.request("sessions.events",{session_id:t,since_seq:n,limit:s},Rr);return fu(r)}catch(r){if(s<=Ca||!hw(r))throw r;this.eventsPageLimit=Ca;const i=await this.client.request("sessions.events",{session_id:t,since_seq:n,limit:Ca},Rr);return fu(i)}}async pullRange(t,n){const s=await mw(n,(c,d)=>this.fetchTimelinePage(t,c,d),this.eventsPageLimit),r=s.events.map(c=>c.seq);let i=n,l=this.eventStore.applyTimelineRange(n,s.events,t);if(l.violation?.rule===3){const c=cp(n,[...r].sort((d,m)=>d-m));c!==void 0&&c>=n.start_seq&&(i=no(n.start_seq,c,{timeline_head:n.timeline_head,wal_head:n.wal_head,holes:n.holes,tainted:n.tainted}),l=this.eventStore.applyTimelineRange(i,s.events,t))}return{ok:l.violation===void 0,merged:l.merged,duplicates:l.duplicates,fetched:s.events.length,end:i.end_seq}}async runTimelineBackfill(t,n){if(this.backfilling)return;this.backfilling=!0;const s={segments:0,declared:0,fetched:0,received:0,end:0,target:0};try{let r;try{r=await this.readCursor(t)}catch{this.timelineCursorUnavailable=!0;return}if(r===void 0){this.timelineCursorUnavailable=!0;return}if(this.timelineCursorUnavailable=!1,this.scopeChanged(n))return;const i=lp(r);s.target=i,s.end=this.eventStore.currentSeq,i>0&&this.eventStore.earliestLoadedSeq===0&&this.eventStore.currentSeq>0&&(this.eventStore.truncateAfter(0),s.end=this.eventStore.currentSeq),this.tailWindowFloor=i>0?_a(i)-1:0,this.eventStore.currentSeq>r.wal_head&&this.eventStore.truncateAfter(0);const l=_a(i)-1;for(let c=0;c<Na;c+=1){let d=this.eventStore.currentSeq;if((d<l||this.eventStore.earliestLoadedSeq===0)&&(d=l),d>=i)break;const m=aw(r,d);if(m===void 0)break;s.declared+=m.count,s.segments+=1;let f=await this.pullRange(t,m);f.ok===!1&&!this.scopeChanged(n)&&(f=await this.pullRange(t,m)),s.fetched+=f.fetched,s.received+=f.merged+f.duplicates;const h=this.eventStore.currentSeq>d;if(f.ok===!1){if(!h){this.eventStore.reportTimelineGap({from_seq:d+1,to_seq:m.end_seq,source:"fetch",rule:3,expected:`[${String(m.start_seq)}, ${String(m.end_seq)}] 可读`,received:`这一段没有任何前进(停在 ${String(d)})`,expectedCount:m.count,receivedCount:f.fetched,at:Date.now()});break}continue}if(this.eventStore.clearTimelineGap(),this.scopeChanged(n))break}s.end=this.eventStore.currentSeq,s.segments>=Na&&s.end<i&&this.eventStore.reportTimelineGap({from_seq:s.end+1,to_seq:i,source:"fetch",rule:3,expected:`追平到 ${String(i)}`,received:`停在 ${String(s.end)}(${String(Na)} 段上限)`,expectedCount:i-s.end,receivedCount:0,at:Date.now()})}finally{this.backfilling=!1,this.lastBackfill=s,s.segments>0&&console.info(`[timeline-backfill] session=${t} segments=${String(s.segments)} declared=${String(s.declared)} fetched=${String(s.fetched)} entries=${String(s.received)} end=${String(s.end)} target=${String(s.target)} items=${String(this.itemCount())}`)}}async loadEarlier(){if(this.loadingEarlier)return;const t=this.eventStore.scopeSessionId;if(!(t===void 0||!this.eventStore.hasEarlier)){this.loadingEarlier=!0;try{let n;try{n=await this.readCursor(t)}catch{return}if(n===void 0||this.eventStore.scopeSessionId!==t)return;const s=this.eventStore.earliestLoadedSeq,r=uw(n,s);if(r===void 0)return;let i=await this.pullRange(t,r);if(i.ok===!1&&(i=await this.pullRange(t,r)),i.ok===!1){this.eventStore.reportTimelineGap({from_seq:r.start_seq,to_seq:r.end_seq,source:"fetch",rule:3,expected:`[${String(r.start_seq)}, ${String(r.end_seq)}] 可读`,received:`这一段要了两次都没通过(实收 ${String(i.fetched)})`,expectedCount:r.count,receivedCount:i.fetched,at:Date.now()});return}this.eventStore.clearTimelineGap(),console.info(`[timeline-earlier] session=${t} from=${String(s)} start=${String(r.start_seq)} end=${String(r.end_seq)} fetched=${String(i.fetched)} merged=${String(i.merged)} floor=${String(this.eventStore.earliestLoadedSeq)} hasEarlier=${String(this.eventStore.hasEarlier)} items=${String(this.itemCount())}`)}finally{this.loadingEarlier=!1}}}itemCount(){let t=0;for(const n of this.eventStore.items.getSnapshot().groups)t+=n.items.length;return t}async fillTimelineGap(t,n,s){if(!(s>=n)||n<1)return;let r;try{const l=await this.client.request("sessions.get",{session_id:t,message_limit:1},Rr),c=uu(l?.session?.event_cursor);if(c===void 0)return;r=no(n,s,c)}catch{return}(await this.pullRange(t,r)).ok&&this.eventStore.clearTimelineGap()}scopeChanged(t){return this.desired===null||zu(this.desired)!==t}async subscribeOnce(t,n,s,r,i=!1){if(this.epochSubscribeFrom=s,!i&&(n===void 0||!this.legacyScopes.has(t))){this.pendingHello="subscribe";try{await this.client.request("events.subscribe",{session_id:n,after_timeline_seq:s});return}catch{if(n===void 0)throw new Error("subscribe failed");this.legacyScopes.add(t)}}this.pendingHello="subscribe",await this.client.request("events.subscribe",r)}async run(){for(await Promise.resolve(),this.continuationPending=!1,this.timelineCursorUnavailable=!1;;){const t=this.desired;if(t===null)return;const n=this.seqOverride??this.eventStore.currentSeq;this.seqOverride=null;const s=zu(t),r=t.kind==="chat"&&this.supportsSessionFilter()?t.sessionId:void 0;if(this.eventStore.scopeSessionId!==void 0&&this.eventStore.setScopeSession(void 0),this.appliedScopeKey!==null&&this.appliedScopeKey!==s&&(this.eventStore.clear(),this.tailWindowFloor=0,this.timelineCursorUnavailable=!1),this.appliedScopeKey=s,this.appliedKey===s)return;if(r!==void 0&&(await this.runTimelineBackfill(r,s),this.desired!==t))continue;const i=r!==void 0&&!this.timelineCursorUnavailable;r!==void 0&&this.timelineCursorUnavailable&&(this.eventStore.endTimelineEpoch(),this.eventStore.truncateAfter(0));const l=CS(t,{currentSeq:t.kind==="chat"?this.eventStore.currentSeq:n,sessionFilter:this.supportsSessionFilter()}),c=t.kind==="chat"?Math.max(this.eventStore.currentSeq,this.tailWindowFloor):this.eventStore.currentSeq,d=r!==void 0&&!i?{...l.filter,since:0}:l.filter;this.appliedKey=s,this.clientFilter=l.clientSessionFilter,this.pendingHello="subscribe";try{await this.subscribeOnce(s,i?r:void 0,c,d,!i),this.eventStore.setScopeSession(r),this.pendingHello==="subscribe"&&(this.pendingHello=null)}catch{this.appliedKey=null,this.eventStore.setScopeSession(void 0),this.pendingHello==="subscribe"&&(this.pendingHello=null)}if(this.resetReanchor){this.resetReanchor=!1,this.timelineCursorUnavailable=!1,this.appliedKey=null;continue}const m=this.eventStore.settleTimelineEpochIfOpen();if(m!==void 0&&this.advanceEpoch(m,{})){this.appliedKey=null;continue}if(this.continuationPending){this.continuationPending=!1,this.appliedKey=null;continue}if(this.desired===t)return}}}function Vu(e){const t=e?.nodeId??e?.name??"";return t===""?null:t}function ES({client:e,eventStore:t,nodeToken:n,mode:s,nodeIdentity:r,canConnect:i,reportConnectError:l,setPlatformUrl:c,setPlatformToken:d,setGatewayError:m,setPlatformError:f,setUrlInvalid:h,setBootstrapSeq:p,setNodeToken:g,setAnonymousNode:b,setTokenError:x,setLastError:y,setConnectSeq:v,manualNodeTokenRef:j,legacyTokenRef:_}){const S=u.useCallback(N=>{if(N.platformUrl!==void 0||N.token!==void 0){const T=Fi(N.platformUrl??"",window.location.protocol);if(!T.ok)return m(T.error??a("gateway.connection.invalidUrl")),!1;const R=(N.token??"").trim();return N.nodeToken!==void 0&&(j.current=N.nodeToken.trim()),T.value?localStorage.setItem(fi,T.value):localStorage.removeItem(fi),R?sessionStorage.setItem(Il,R):sessionStorage.removeItem(Il),c(T.value),d(R),h(!1),m(null),f(null),x(null),y(null),p(E=>E+1),!0}if(N.nodeToken!==void 0){const T=N.nodeToken.trim();if(j.current=T,s==="legacy")T?sessionStorage.setItem($o,T):sessionStorage.removeItem($o),_.current=T;else{const R=Vu(r);R!==null&&(T?Rc(R,T):Qs(R))}return g(T),b(!1),x(null),y(null),v(R=>R+1),!0}return!1},[s,r]),w=u.useCallback(()=>{if(s==="legacy")sessionStorage.removeItem($o),_.current="";else{const N=Vu(r);N!==null&&Qs(N)}j.current="",g(""),b(!1),e.close(),t.clear()},[e,t,s,r]),k=u.useCallback(()=>{i&&(y(null),El(e,n,()=>({since:t.currentSeq}),l))},[e,t,n,i,l]);return{connect:S,disconnect:w,retry:k}}function IS({client:e,recordSettled:t,settledRef:n,tokenRef:s,canConnectRef:r,hydrationGenerationRef:i,onFetchState:l}){return u.useCallback(async()=>{if(e.connectionState!=="open")return;const c=s.current;if(!c.trim()&&!r?.current)return;const d=e,m=i.current+1;i.current=m;const f=()=>i.current===m&&e===d&&s.current===c,h=[...dt.getState().permissions.map(j=>j.requestId),...dt.getState().asks.map(j=>j.requestId),...dt.getState().notices.map(j=>j.requestId)],[p,g]=await Promise.allSettled([e.listInteractionsPage({status:"pending",limit:100}),e.listInteractions({status:"orphaned",limit:100})]),b=c0(p,g);if(!f())return;l?.(b.state);const x=[...new Set(b.orphaned.filter(j=>j.status==="orphaned"&&j.request_id.length>0).map(j=>j.request_id))],y=new Set(n.current.keys()),v={...m0({pending:b.pending,orphaned:b.orphaned,settled:y}),...b.pendingComplete?{staleIds:f0(h,b.pending,y)}:{}};if(f()){for(const j of v.terminalIds)t(j);for(const j of v.staleIds??[])t(j);dt.getState().hydrate(v,new Set(n.current.keys()),x)}},[e,t,l])}const RS=" · ";function yr(e,t){const n=typeof e.id=="string"?e.id.trim():"";return n===""?`q${t+1}`:n}function Vp(e,t,n){const s=t.custom.trim(),r=[...t.selected],i=[...r,...s===""?[]:[s]];return{question_id:yr(e,n),header:e.header,question:e.question,answer:i.join(RS),...r.length>0?{selected:r}:{}}}function Gp(e,t,n){return e===void 0||e.length===0?!1:e.includes(yr(t,n))}function LS(e){return e===void 0?!1:Array.isArray(e.remaining_questions)?e.remaining_questions.length>0:e.final===!1}function AS({client:e,hydrateInteractions:t,recordSettled:n,toast:s,submitGuard:r}){const i=u.useCallback((m,f)=>{dt.getState().setResponding(m,f)},[]),l=u.useCallback(async(m,f,h="once")=>{if(r.current.begin(m)){i(m,!0);try{await e.respondPermission(m,f,h),n(m),dt.getState().dispatch({type:"settle",requestId:m})}catch(p){if(Ha(p)){n(m),dt.getState().dispatch({type:"settle",requestId:m}),s.info(Hu());return}if(Oa(p)||Da(p)){n(m),dt.getState().dispatch({type:"settle",requestId:m}),s.info(Tl());return}t(),s.error(Ho(p))}finally{r.current.end(m),i(m,!1)}}},[e,t,n,s,i]),c=u.useCallback(async(m,f,h)=>{if(r.current.begin(m)){i(m,!0);try{const p=await e.respondAsk(m,f,h);if(LS(p)){t();return}n(m),dt.getState().dispatch({type:"settle",requestId:m})}catch(p){if(Ha(p)){n(m),dt.getState().dispatch({type:"settle",requestId:m}),s.info(Hu());return}if(Oa(p)||Da(p)){n(m),dt.getState().dispatch({type:"settle",requestId:m}),s.info(Tl());return}t(),s.error(Ho(p))}finally{r.current.end(m),i(m,!1)}}},[e,t,n,s,i]),d=u.useCallback(async m=>{if(r.current.begin(m)){i(m,!0);try{await e.ackNotify(m),n(m),dt.getState().dispatch({type:"settle",requestId:m})}catch(f){if(Ha(f)||Oa(f)||Da(f)){n(m),dt.getState().dispatch({type:"settle",requestId:m});return}t(),s.error(Ho(f))}finally{r.current.end(m),i(m,!1)}}},[e,t,n,s,i]);return{respondPermission:l,respondAsk:c,ackNotify:d}}function Gu(e,t){const[n]=u.useState(()=>Vk(t)),[s,r]=u.useState(()=>n.snapshot());return u.useEffect(()=>{r(n.onConnectionState(e))},[n,e]),u.useEffect(()=>{const i=n.noticeAt();if(i===null)return;const l=setTimeout(()=>{r(n.onWake())},Math.max(0,i-Date.now()));return()=>clearTimeout(l)},[n,e,s]),s}function MS(e,t,n,s,r){return u.useCallback(i=>{const l=Kp(i);if(l.kind==="retryable"&&r?.shouldDefer()){r.defer(i);return}if(t("error"),e.closedWithCode===4401){n(a("gateway.connection.authFailed"));return}if(i instanceof Pt){if(l.kind==="terminal"&&l.reason==="origin"){s(a("gateway.connection.originRejected",{detail:i.message}));return}if(l.kind==="terminal"&&l.reason==="auth"){n(a("gateway.connection.authFailed"));return}s(Wp(i));return}s(Ho(i))},[e,r])}const PS="flex flex-col gap-2 rounded-md bg-raised px-4 py-3.5 shadow-elev-1 forced-colors:border";function Yp({header:e,children:t,footer:n,className:s,ariaLabel:r}){return o.jsxs("article",{className:be(PS,s),...r!==void 0?{"aria-label":r}:{},children:[e,t,n]})}async function Bc(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function Jp(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Jp(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function qS(){for(var e,t,n=0,s="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Jp(e))&&(s&&(s+=" "),s+=t);return s}const Yu=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ju=qS,zi=(e,t)=>n=>{var s;if(t?.variants==null)return Ju(e,n?.class,n?.className);const{variants:r,defaultVariants:i}=t,l=Object.keys(r).map(m=>{const f=n?.[m],h=i?.[m];if(f===null)return null;const p=Yu(f)||Yu(h);return r[m][p]}),c=n&&Object.entries(n).reduce((m,f)=>{let[h,p]=f;return p===void 0||(m[h]=p),m},{}),d=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((m,f)=>{let{class:h,className:p,...g}=f;return Object.entries(g).every(b=>{let[x,y]=b;return Array.isArray(y)?y.includes({...i,...c}[x]):{...i,...c}[x]===y})?[...m,h,p]:m},[]);return Ju(e,l,d,n?.class,n?.className)},i$=["page","panel"],OS=zi("flex min-w-0 items-start justify-between gap-4 max-compact:flex-col max-compact:items-start"),DS={page:"font-serif text-title",panel:"font-sans text-lg"},HS=zi("break-words font-semibold leading-tight tracking-wide text-ink",{variants:{size:DS},defaultVariants:{size:"page"}}),$S="min-w-0 max-w-80 truncate font-medium text-md text-muted",FS="min-w-0 max-w-60 truncate text-2xs text-faint";function BS({item:e,first:t}){const n=be(t?$S:FS);return e.onOpen?o.jsx("button",{type:"button",className:be(n,"cursor-pointer border-0 bg-transparent p-0 text-left underline-offset-2 hover:underline"),onClick:e.onOpen,title:e.label,children:e.label}):o.jsx("span",{className:n,title:e.label,children:e.label})}function xr({title:e,titleAs:t="h1",size:n="page",scope:s=[],current:r=!1,status:i,actions:l,onOpenDetails:c,detailsLabel:d,className:m}){He();const f=s.slice(0,2),h=f.length>0||r;return o.jsxs("div",{className:be(OS(),m),children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx(t,{className:be(HS({size:n})),children:e}),h&&o.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 text-md leading-normal",children:[f.length>0&&o.jsx("span",{className:"text-faint",children:a("entity.scopeIn")}),f.map((p,g)=>o.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[g>0&&o.jsx("span",{"aria-hidden":"true",className:"text-2xs text-faint",children:"·"}),o.jsx(BS,{item:p,first:g===0})]},`${p.label}-${g}`)),r&&o.jsxs("span",{className:"text-2xs text-faint",title:a("entity.currentNode"),children:[f.length>0&&o.jsx("span",{"aria-hidden":"true",className:"mr-1",children:"·"}),a("entity.currentNode")]})]}),i&&o.jsx("div",{className:"mt-1.5 flex flex-none flex-wrap items-center gap-1.5",children:i}),c&&o.jsx("button",{type:"button",className:"mt-1.5 cursor-pointer border-0 bg-transparent p-0 text-left text-md text-accent underline-offset-2 hover:underline",onClick:c,children:d??a("entity.details")})]}),l&&o.jsx("div",{className:"flex flex-none flex-wrap items-start justify-end gap-2 max-compact:w-full",children:l})]})}const Wn=8;function Qu({label:e,allValue:t,value:n,options:s,onChange:r,searchThreshold:i=8,searchPlaceholder:l,searchLabel:c,className:d}){const m=u.useMemo(()=>[{value:t,label:e},...s],[t,e,s]),f=m.length>i+1,[h,p]=u.useState(!1),[g,b]=u.useState(""),[x,y]=u.useState(0),[v,j]=u.useState(null),_=u.useRef(null),S=u.useRef(null),w=u.useRef(null),k=u.useRef([]),N=u.useId(),T=O=>`${N}-option-${O}`,R=g.trim().toLowerCase(),E=u.useMemo(()=>{if(!f||R==="")return m;const O=m[0],F=m.slice(1).filter(V=>V.label.toLowerCase().includes(R));return O?[O,...F]:F},[m,f,R]),I=m.find(O=>O.value===n),$=E.length===0?-1:Math.min(Math.max(x,0),E.length-1),C=u.useCallback(O=>{p(!1),y(0),b(""),O&&_.current?.focus()},[]),L=u.useCallback(()=>{const O=m.findIndex(F=>F.value===n);b(""),y(O>=0?O:0),p(!0)},[m,n]),A=u.useCallback(O=>{O.value!==n&&r(O.value),C(!0)},[C,r,n]);u.useEffect(()=>{h&&(f?w.current?.focus():_.current?.focus())},[h,f]),u.useLayoutEffect(()=>{if(!h){j(null);return}const O=()=>{const F=_.current;if(!F)return;const V=F.getBoundingClientRect(),B=window.innerWidth,W=window.innerHeight,Z=Math.min(B*.3,B-Wn*2),ee=Math.min(W*.3,W-Wn*2),ie=W-V.bottom-Wn-4,le=V.top-Wn-4,J=ie<ee&&le>ie,z=Math.max(64,J?le:ie),me=Math.min(ee,z),K=Math.max(Wn,Math.min(V.left,B-Z-Wn));j({left:K,...J?{bottom:Math.max(Wn,W-V.top+4)}:{top:Math.min(V.bottom+4,W-Wn-4)},maxWidth:Z,maxHeight:me,minWidth:Math.min(V.width,Z)})};return O(),window.addEventListener("scroll",O,!0),window.addEventListener("resize",O),()=>{window.removeEventListener("scroll",O,!0),window.removeEventListener("resize",O)}},[h]),u.useEffect(()=>{if(!h)return;const O=F=>{const V=F.target;V instanceof Node&&(_.current?.contains(V)||S.current?.contains(V)||C(!1))};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[h,C]),u.useEffect(()=>{!h||$<0||k.current[$]?.scrollIntoView({block:"nearest"})},[h,$]);const D=O=>{if(!h){(O.key==="ArrowDown"||O.key==="ArrowUp")&&(O.preventDefault(),L());return}const F=E.length;if(O.key==="Escape"){O.preventDefault(),O.stopPropagation(),C(!0);return}if(F===0)return;if(O.key==="ArrowDown"){O.preventDefault(),y(B=>(Math.min(Math.max(B,0),F-1)+1)%F);return}if(O.key==="ArrowUp"){O.preventDefault(),y(B=>(Math.min(Math.max(B,0),F-1)-1+F)%F);return}const V=O.target instanceof HTMLInputElement;if(O.key==="Home"&&!V){O.preventDefault(),y(0);return}if(O.key==="End"&&!V){O.preventDefault(),y(F-1);return}if(O.key==="Enter"){O.preventDefault();const B=E[Math.min(Math.max(x,0),F-1)];B&&A(B)}};return o.jsxs(o.Fragment,{children:[o.jsxs("button",{ref:_,type:"button",className:be("-mx-2 inline-flex max-w-full appearance-none items-center gap-1 rounded-sm border-0 bg-transparent px-2 py-1 text-left text-xs font-mono tracking-wide text-inherit uppercase transition-colors hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface",d),role:"combobox","aria-haspopup":"listbox","aria-expanded":h,"aria-controls":h?N:void 0,"aria-activedescendant":h&&$>=0?T($):void 0,"aria-label":e,onClick:()=>{h?C(!0):L()},onKeyDown:D,children:[o.jsx("span",{className:"truncate",children:I?I.label:e}),o.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 12 12",className:be("size-3 flex-none text-faint transition-transform",h&&"rotate-180"),fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5"})})]}),h&&v!==null?fr.createPortal(o.jsxs("div",{ref:S,role:"dialog","aria-label":e,className:"fixed z-tooltip flex flex-col overflow-hidden rounded-md bg-raised shadow-elev-3 forced-colors:border",style:{left:v.left,top:v.top,bottom:v.bottom,maxWidth:v.maxWidth,maxHeight:v.maxHeight,minWidth:v.minWidth},onKeyDown:D,children:[f&&o.jsx("div",{className:"sticky top-0 z-1 border-b border-line bg-raised p-1.5",children:o.jsx(Tn,{ref:w,value:g,onChange:O=>{b(O),y(0)},placeholder:l??e,ariaLabel:c??e})}),o.jsx("div",{id:N,role:"listbox","aria-label":e,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-1",children:E.map((O,F)=>{const V=O.value===n;return o.jsx("div",{ref:B=>{k.current[F]=B},id:T(F),role:"option","aria-selected":V,className:be("flex min-h-8 cursor-pointer items-center rounded-sm px-2.5 py-1.75 text-sm text-ink transition-colors pointer-coarse:min-h-touch",F===$&&"bg-hover",V&&"bg-accent-soft text-accent-ink"),onMouseDown:B=>B.preventDefault(),onPointerEnter:()=>y(F),onClick:()=>A(O),children:o.jsx("span",{className:"truncate",children:O.label})},`${O.value}:${O.label}`)})})]}),document.body):null]})}const Vi="border border-line-strong bg-transparent shadow-none",es="border border-line-strong bg-transparent",Ll="border border-line bg-transparent",Al="border border-line bg-transparent",Xu=o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M13.5 2.5 2.5 7.25l4.75 1.5 1.5 4.75z"}),o.jsx("path",{d:"M7.25 8.75 13.5 2.5"})]}),KS={send:Xu,copy:o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"5.25",y:"5.25",width:"8.5",height:"8.5",rx:"1.5"}),o.jsx("path",{d:"M10.75 3.75v-1a1 1 0 0 0-1-1h-6.5a1 1 0 0 0-1 1v6.5a1 1 0 0 0 1 1h1"})]}),edit:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M10.9 2.4a1.55 1.55 0 0 1 2.2 2.2L5.6 12.1l-3 .9.9-3z"}),o.jsx("path",{d:"M9.9 3.4l2.2 2.2"})]}),retry:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M13.25 8a5.25 5.25 0 1 1-1.55-3.72"}),o.jsx("path",{d:"M13.25 2.75v3.25H10"})]}),transcript:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M4 2.25h5.5l3 3v8.5a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3.25a1 1 0 0 1 1-1Z"}),o.jsx("path",{d:"M9.25 2.5v3h3"}),o.jsx("path",{d:"M5.75 8.5h4.5M5.75 11h4.5"})]}),reply:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M6.25 3.5 2.75 7l3.5 3.5"}),o.jsx("path",{d:"M2.75 7h6.5A3.75 3.75 0 0 1 13 10.75v2"})]}),quote:o.jsx("path",{fill:"currentColor",stroke:"none",d:"M6.9 3.2C4.2 4.3 2.6 6.3 2.6 8.9c0 2.1 1.3 3.6 3.1 3.6 1.6 0 2.8-1.2 2.8-2.8 0-1.5-1.1-2.7-2.6-2.7-.3 0-.6.05-.85.15.35-1.3 1.35-2.4 2.75-3.15l-.9-.8Zm6.5 0c-2.7 1.1-4.3 3.1-4.3 5.7 0 2.1 1.3 3.6 3.1 3.6 1.6 0 2.8-1.2 2.8-2.8 0-1.5-1.1-2.7-2.6-2.7-.3 0-.6.05-.85.15.35-1.3 1.35-2.4 2.75-3.15l-.9-.8Z"}),retract:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M2.75 6.25h7.5a3 3 0 0 1 0 6H7"}),o.jsx("path",{d:"M5.25 3.5 2.5 6.25l2.75 2.75"})]}),delete:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M2.75 4.25h10.5"}),o.jsx("path",{d:"M6.25 4.25V3a.75.75 0 0 1 .75-.75h2a.75.75 0 0 1 .75.75v1.25"}),o.jsx("path",{d:"M4.25 4.25l.6 8.5a1 1 0 0 0 1 .95h4.3a1 1 0 0 0 1-.95l.6-8.5"}),o.jsx("path",{d:"M6.75 7v4M9.25 7v4"})]}),resend:Xu,chevron:o.jsx("path",{d:"M6.5 4.5 10.5 8l-4 3.5"}),attach:o.jsx("path",{d:"M15.01 7.74 8.58 14.17a4.2 4.2 0 0 1-5.95-5.95l6.44-6.44a2.8 2.8 0 0 1 3.96 3.96l-6.44 6.44a1.4 1.4 0 0 1-1.98-1.98l5.94-5.94"}),check:o.jsx("path",{d:"M3 8.5 6.25 11.75 13 4.75"}),archive:o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"2",y:"2.75",width:"12",height:"3",rx:"0.75"}),o.jsx("path",{d:"M3.25 5.75v6.25a1.25 1.25 0 0 0 1.25 1.25h7a1.25 1.25 0 0 0 1.25-1.25V5.75"}),o.jsx("path",{d:"M6.5 8.75h3"})]}),github:o.jsx("path",{fill:"currentColor",stroke:"none",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8Z"}),microsoft:o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"1",y:"1",width:"6",height:"6",fill:"currentColor",stroke:"none"}),o.jsx("rect",{x:"9",y:"1",width:"6",height:"6",fill:"currentColor",stroke:"none"}),o.jsx("rect",{x:"1",y:"9",width:"6",height:"6",fill:"currentColor",stroke:"none"}),o.jsx("rect",{x:"9",y:"9",width:"6",height:"6",fill:"currentColor",stroke:"none"})]}),gitee:o.jsx("g",{transform:"scale(0.6666667)",children:o.jsx("path",{fill:"currentColor",stroke:"none",d:"M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"})})};function yt({name:e,size:t,className:n}){return o.jsx("svg",{viewBox:"0 0 16 16",className:be("flex-none",t===void 0&&"size-4",n),style:t===void 0?void 0:{width:t,height:t},fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:KS[e]})}const WS=300,Lr=8,So=8,Ba=10;function Ar(e,t){typeof e=="function"&&e(t)}function US(e,t){e&&(typeof e=="function"?e(t):typeof e=="object"&&(e.current=t))}function xt({label:e,children:t,placement:n="top",className:s}){const r=u.useId(),i=u.useRef(null),l=u.useRef(null),c=u.useRef(null),[d,m]=u.useState(!1),[f,h]=u.useState(null),p=t.props??{},g=p.ref,b=u.useRef(g);b.current=g;const x=u.useCallback(R=>{i.current=R,US(b.current,R)},[]),y=u.useCallback(()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]),v=u.useCallback(()=>{y(),c.current=window.setTimeout(()=>{c.current=null,m(!0)},WS)},[y]),j=u.useCallback(()=>{y(),m(!1)},[y]),_=u.useCallback(()=>{const R=i.current,E=l.current;if(!R||!E)return;const I=R.getBoundingClientRect(),$=E.getBoundingClientRect(),C=window.innerWidth,L=window.innerHeight;let A=n;A==="top"&&I.top-$.height-Lr<So?A="bottom":A==="bottom"&&I.bottom+Lr+$.height>L-So&&(A="top");const D=A==="top"?I.top-$.height-Lr:I.bottom+Lr,O=I.left+I.width/2-$.width/2,F=Math.min(Math.max(O,So),Math.max(So,C-$.width-So)),V=Math.min(Math.max(I.left+I.width/2-F,Ba),Math.max(Ba,$.width-Ba));h({top:D,left:F,side:A,arrow:V})},[n]);u.useLayoutEffect(()=>{d&&_()},[d,_]),u.useEffect(()=>{if(!d)return;const R=E=>{E.key==="Escape"&&(E.stopPropagation(),j())};return document.addEventListener("keydown",R,!0),window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{document.removeEventListener("keydown",R,!0),window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[d,j]),u.useEffect(()=>y,[y]);const S=p["aria-describedby"],w=typeof S=="string"&&S.length>0?S:void 0,k={ref:x,onPointerEnter:R=>{Ar(p.onPointerEnter,R),v()},onPointerLeave:R=>{Ar(p.onPointerLeave,R),j()},onFocus:R=>{Ar(p.onFocus,R),v()},onBlur:R=>{Ar(p.onBlur,R),j()}};d?k["aria-describedby"]=w?`${w} ${r}`:r:w&&(k["aria-describedby"]=w);const N=u.cloneElement(t,k),T={top:f?.top??0,left:f?.left??0,visibility:f?"visible":"hidden"};return o.jsxs(o.Fragment,{children:[N,d?fr.createPortal(o.jsxs("div",{ref:l,id:r,role:"tooltip",className:"tooltip-fade pointer-events-none fixed z-tooltip max-w-60 rounded-sm bg-raised px-2 py-1 text-xs leading-relaxed text-ink shadow-elev-2","data-placement":f?.side??n,style:T,children:[o.jsx("span",{className:be("absolute size-2 -translate-x-1/2 rotate-45 rounded-xs bg-raised",(f?.side??n)==="top"?"-bottom-1":"-top-1"),"aria-hidden":"true",style:{left:f?.arrow??0}}),o.jsx("span",{className:s,children:e})]}),document.body):null]})}const Kc="inline-flex size-control flex-none items-center justify-center rounded-full bg-transparent text-lg leading-none text-faint transition-colors hover:bg-hover hover:text-ink pointer-coarse:min-h-touch pointer-coarse:min-w-touch forced-colors:border disabled:opacity-45 disabled:cursor-not-allowed";function Cn({label:e,children:t,className:n,...s}){return o.jsx(xt,{label:e,children:o.jsx("button",{type:"button",className:be(Kc,n),"aria-label":e,...s,children:t})})}function Gi({label:e=a("common.moreActions"),items:t,disabled:n=!1,className:s,trigger:r}){const[i,l]=u.useState(!1),c=u.useRef(null),d=u.useRef(null),m=u.useId();return u.useEffect(()=>{if(!i)return;const f=d.current,h=()=>[...f?.querySelectorAll("button:not([disabled])")??[]];h()[0]?.focus();const p=b=>{const x=b.target;x instanceof Node&&(f?.contains(x)||c.current?.contains(x)||l(!1))},g=b=>{if(b.key==="Escape"){b.preventDefault(),l(!1),c.current?.focus();return}const x=h();if(x.length===0)return;const y=x.indexOf(document.activeElement);b.key==="ArrowDown"?(b.preventDefault(),x[(y+1+x.length)%x.length]?.focus()):b.key==="ArrowUp"?(b.preventDefault(),x[(y-1+x.length)%x.length]?.focus()):b.key==="Home"?(b.preventDefault(),x[0]?.focus()):b.key==="End"&&(b.preventDefault(),x[x.length-1]?.focus())};return document.addEventListener("mousedown",p),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",g)}},[i]),o.jsxs("span",{className:be("relative inline-flex flex-none",s),children:[o.jsx(xt,{label:e,children:o.jsx("button",{ref:c,type:"button",className:Kc,"aria-label":e,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?m:void 0,disabled:n,onClick:()=>l(f=>!f),children:r??o.jsx("span",{"aria-hidden":"true",children:"⋯"})})}),i&&o.jsx("div",{ref:d,id:m,className:"absolute right-0 top-full z-20 mt-1 flex min-w-40 flex-col rounded-lg bg-raised p-1 shadow-elev-3",role:"menu","aria-label":e,children:t.map(f=>o.jsx("button",{type:"button",className:be("rounded-md bg-transparent px-2.5 py-2 text-left text-sm text-ink transition-colors hover:bg-hover disabled:opacity-45",f.danger&&"text-danger hover:bg-danger-soft"),role:"menuitem",disabled:f.disabled,onClick:()=>{l(!1),f.onSelect()},children:f.label},f.id))})]})}function is(e=a("chat.message.copied")){const t=$i();return u.useCallback(n=>{Bc(n).then(()=>t?.success(e)).catch(s=>{t?.error(s instanceof Error?s.message:String(s))})},[t,e])}function os({actions:e,meta:t,className:n,placement:s="bottom"}){const r=t!=null&&t!==!1,i=e.length>0;if(!i&&!r)return null;const l=o.jsxs("div",{...i?{role:"group","aria-label":a("chat.message.actions")}:{},className:be("flex w-fit flex-row flex-nowrap items-center gap-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100",n),children:[r&&o.jsx("span",{className:"mr-0.5 shrink-0 font-mono text-2xs tabular-nums text-faint",children:t}),e.map(c=>c.menu!==void 0?o.jsx(Gi,{label:c.label,items:c.menu,disabled:c.disabled,trigger:o.jsx(yt,{name:c.id})},c.id):o.jsx(Cn,{label:c.label,disabled:c.disabled,onClick:c.onSelect,children:o.jsx(yt,{name:c.id})},c.id))]});return s==="bottom"?l:o.jsx("div",{className:"absolute right-0 top-0 z-10 rounded-md bg-surface/90 p-0.5 opacity-0 shadow-elev-1 backdrop-blur-sm transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100",children:l})}const zS="--msg-fold-max-h",VS=400,GS=2;function YS(e){const t=getComputedStyle(e).getPropertyValue(zS).trim(),n=Number.parseFloat(t);return Number.isFinite(n)&&n>0?n:VS}function Wc({children:e,streaming:t=!1}){const n=u.useRef(null),[s,r]=u.useState(!1),[i,l]=u.useState(!1),c=u.useId();u.useLayoutEffect(()=>{const m=n.current;if(m===null)return;const f=()=>{r(m.scrollHeight>YS(m)+GS)};if(f(),typeof ResizeObserver>"u")return;const h=new ResizeObserver(f);return h.observe(m),()=>h.disconnect()},[]);const d=s&&!i&&!t;return o.jsxs("div",{className:"msg-fold",children:[o.jsx("div",{id:c,ref:n,className:d?"msg-fold-body msg-fold-clipped":"msg-fold-body",children:e}),s&&!t&&o.jsx(G,{variant:"link",className:"msg-fold-toggle","aria-expanded":i,"aria-controls":c,onClick:()=>l(m=>!m),children:a(i?"chat.message.fold.collapse":"chat.message.fold.expand")})]})}const Qp=200,Fo=/\[([^\]\n]*)\]\(<([A-Za-z][A-Za-z0-9+.-]*):([^>\n]*)>\)/g;function Xp(e,t,n){return n.length===0||/[>\n]/.test(n)?null:`[${e.replace(/[[\]\n]/g,"").trim()||n}](<${t}:${n}>)`}function Yi(e,t){if(t.size===0||e.length===0)return[{type:"text",text:e}];const n=[];let s=0;Fo.lastIndex=0;for(let r=Fo.exec(e);r!==null;r=Fo.exec(e)){const i=r[0],l=r[1]??"",c=r[2]??"",d=r[3]??"";t.has(c)&&(r.index>s&&n.push({type:"text",text:e.slice(s,r.index)}),n.push({type:"atomic",token:i,scheme:c,name:l,target:d}),s=r.index+i.length)}return s<e.length&&n.push({type:"text",text:e.slice(s)}),n}function nr(e,t){return Yi(e,new Set(t.map(n=>n.scheme)))}function Zu(e){Fo.lastIndex=0;const t=Fo.exec(e);return t===null||t[0]!==e?null:{scheme:t[2]??"",name:t[1]??"",target:t[3]??""}}function ws(e){return e instanceof HTMLSpanElement&&e.dataset.token!==void 0}function fo(e){return e instanceof HTMLSpanElement&&e.dataset.transient!==void 0}function Zs(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent?.length??0;if(ws(e))return e.dataset.token?.length??0;if(fo(e))return 0;if(e instanceof HTMLBRElement)return 1;let t=0;return e.childNodes.forEach(n=>{t+=Zs(n)}),t}function Ml(e){const t=[],n=s=>{if(s.nodeType===Node.TEXT_NODE){t.push(s.textContent??"");return}if(ws(s)){t.push(s.dataset.token??"");return}if(!fo(s)){if(s instanceof HTMLBRElement){t.push(`
|
|
553
|
+
`);return}if(s instanceof HTMLDivElement||s instanceof HTMLParagraphElement){const r=t.join("");r.length>0&&!r.endsWith(`
|
|
554
|
+
`)&&t.push(`
|
|
555
|
+
`)}s.childNodes.forEach(n)}};return e.childNodes.forEach(n),t.join("")}function Ka(e,t){const n=window.getSelection();let s=t;if(n!==null&&n.rangeCount>0){const r=n.anchorNode;if(r!==null&&e.contains(r)){let i=0,l=!1;const c=d=>{if(!l){if(d===r){if(d.nodeType===Node.TEXT_NODE)i+=Math.min(n.anchorOffset,d.textContent?.length??0);else{const m=Math.min(n.anchorOffset,d.childNodes.length);for(let f=0;f<m;f+=1){const h=d.childNodes[f];h!==void 0&&(i+=Zs(h))}}l=!0;return}if(d.nodeType===Node.TEXT_NODE||ws(d)||d instanceof HTMLBRElement){i+=Zs(d);return}fo(d)||d.childNodes.forEach(c)}};e.childNodes.forEach(c),l&&(s=i)}}return{text:Ml(e),caret:s}}function jo(e,t){const n=window.getSelection();if(n===null)return;const s=document.createRange();let r=Math.max(0,t),i=!1;const l=c=>{if(!i){if(c.nodeType===Node.TEXT_NODE){const d=c.textContent?.length??0;if(r<=d){s.setStart(c,r),i=!0;return}r-=d;return}if(ws(c)){const d=c.dataset.token?.length??0;if(r<=0){s.setStartBefore(c),i=!0;return}if(r<d){s.setStartAfter(c),i=!0;return}r-=d;return}if(!fo(c)){if(c instanceof HTMLBRElement){if(r<=0){s.setStartBefore(c),i=!0;return}r-=1;return}c.childNodes.forEach(l)}}};e.childNodes.forEach(l),i?s.collapse(!0):(s.selectNodeContents(e),s.collapse(!1)),n.removeAllRanges(),n.addRange(s)}function em(e,t,n){let s=null,r=0;const i=document;if(typeof i.caretRangeFromPoint=="function"){const m=i.caretRangeFromPoint(t,n);if(m===null)return null;s=m.startContainer,r=m.startOffset}else if(typeof i.caretPositionFromPoint=="function"){const m=i.caretPositionFromPoint(t,n);if(m===null)return null;s=m.offsetNode,r=m.offset}if(s===null||!e.contains(s))return null;let l=0,c=!1;const d=m=>{if(!c){if(m===s){if(m.nodeType===Node.TEXT_NODE)l+=Math.min(r,m.textContent?.length??0);else if(ws(m))l+=Zs(m);else{const f=Math.min(r,m.childNodes.length);for(let h=0;h<f;h+=1){const p=m.childNodes[h];p!==void 0&&(l+=Zs(p))}}c=!0;return}if(m.nodeType===Node.TEXT_NODE||ws(m)||m instanceof HTMLBRElement){l+=Zs(m);return}fo(m)||m.childNodes.forEach(d)}};return e.childNodes.forEach(d),c?l:null}function tm(e){const t=e.trim();if(!t.endsWith("px"))return null;const n=Number.parseFloat(t);return Number.isFinite(n)&&n>=0?n:null}function JS(e,t){const n=getComputedStyle(e).getPropertyValue(t),s=tm(n);return s!==null?s:tm(getComputedStyle(e).maxHeight)??Qp}const QS=800,XS=200,Zp=u.forwardRef(function({value:t,onChange:n,onCaretChange:s,caretRequest:r=null,placeholder:i,disabled:l=!1,className:c,maxHeightVar:d="--composer-input-max-h",spellCheck:m=!1,enterKeyHint:f,onKeyDown:h,onCompositionStart:p,onCompositionEnd:g,onPasteFiles:b,atomicSchemes:x=[],atomicPort:y,...v},j){const _=u.useRef(null),S=u.useRef(!1),w=u.useRef(null),k=u.useRef(null),N=u.useRef(0),T=u.useRef(0),R=u.useRef(0),E=u.useRef({entries:[],index:-1,lastPush:0}),[I,$]=u.useState([]),C=u.useRef(new Map),L=u.useRef({onChange:n,onCaretChange:s,onKeyDown:h,onPasteFiles:b,atomicSchemes:x,disabled:l});L.current={onChange:n,onCaretChange:s,onKeyDown:h,onPasteFiles:b,atomicSchemes:x,disabled:l};const A=u.useCallback(()=>{const U=_.current;if(U===null)return;U.style.height="auto";const q=U.offsetHeight-U.clientHeight,M=JS(U,d);U.style.height=`${Math.min(U.scrollHeight+q+1,M)}px`},[d]),D=u.useCallback(()=>{const U=_.current;U!==null&&(U.dataset.empty=Ml(U)===""?"true":"false")},[]),O=u.useCallback(U=>{C.current.set(U.key,U),$(q=>[...q,U])},[]),F=u.useCallback(U=>{C.current.delete(U),$(q=>q.filter(M=>M.key!==U))},[]),V=u.useCallback(U=>{const q=document.createElement("span");q.contentEditable="false",q.className="rich-atomic",q.dataset.token=U.token,q.dataset.scheme=U.scheme,R.current+=1;const M={key:`a${String(R.current)}`,el:q,scheme:U.scheme,name:U.name,target:U.target};return{el:q,entry:M}},[]),B=u.useCallback((U,q)=>{const M=_.current;if(M===null)return;M.textContent="",C.current.clear();const H=[];for(const X of nr(U,L.current.atomicSchemes))if(X.type==="text")M.appendChild(document.createTextNode(X.text));else{const{el:Y,entry:re}=V(X);M.appendChild(Y),H.push(re),C.current.set(re.key,re)}$(H),k.current=U,N.current=q,jo(M,q),D(),A()},[V,A,D]),W=u.useCallback((U,q,M)=>{const H=E.current,X=Date.now(),Y=H.entries[H.index];M&&H.index===H.entries.length-1&&Y!==void 0&&X-H.lastPush<QS?H.entries[H.index]={value:U,caret:q}:(H.entries=H.entries.slice(0,H.index+1),H.entries.push({value:U,caret:q}),H.entries.length>XS&&H.entries.shift(),H.index=H.entries.length-1),H.lastPush=X,k.current=U,N.current=q,L.current.onChange(U),L.current.onCaretChange?.(q),D(),A()},[A,D]),Z=u.useCallback(U=>{const q=_.current;if(q===null)return;const{text:M,caret:H}=Ka(q,N.current);W(M,H,U)},[W]),ee=u.useCallback(U=>{B(U.value,U.caret),L.current.onChange(U.value),L.current.onCaretChange?.(U.caret)},[B]),ie=u.useCallback(()=>{const U=E.current;if(U.index<=0)return;U.index-=1;const q=U.entries[U.index];q!==void 0&&ee(q)},[ee]),le=u.useCallback(()=>{const U=E.current;if(U.index>=U.entries.length-1)return;U.index+=1;const q=U.entries[U.index];q!==void 0&&ee(q)},[ee]),J=u.useCallback((U,q,M,H)=>{const X=_.current;if(X===null)return;X.focus(),jo(X,U);const Y=window.getSelection();if(Y!==null&&Y.rangeCount>0){const re=Y.getRangeAt(0);re.deleteContents();const _e=document.createDocumentFragment();for(const fe of q)_e.appendChild(fe);re.insertNode(_e)}else for(const re of q)X.appendChild(re);for(const re of H)O(re);jo(X,U+M),Z(!1)},[Z,O]),z=u.useCallback((U,q)=>{if(U.length===0)return;const M=q??N.current;J(M,[document.createTextNode(U)],U.length,[])},[J]),me=u.useCallback((U,q)=>{const M=Zu(U),H=M!==null&&L.current.atomicSchemes.some(re=>re.scheme===M.scheme);if(M===null||!H){z(U,q);return}const{el:X,entry:Y}=V({token:U,...M});J(q??N.current,[X],U.length,[Y])},[J,z,V]),K=u.useCallback(U=>{const q=C.current.get(U);q!==void 0&&(q.el.remove(),F(U),Z(!1))},[Z,F]),ne=u.useCallback((U,q,M)=>{const H=_.current;if(H===null||!L.current.atomicSchemes.some(fe=>fe.scheme===U))return null;const X=document.createElement("span");X.contentEditable="false",X.className="rich-atomic",R.current+=1;const Y=`t${String(R.current)}`;X.dataset.transient=Y,X.dataset.scheme=U;const re={key:Y,el:X,scheme:U,name:"",target:"",data:q};jo(H,M??N.current);const _e=window.getSelection();if(_e!==null&&_e.rangeCount>0){const fe=_e.getRangeAt(0);fe.deleteContents(),fe.insertNode(X),fe.setStartAfter(X),fe.collapse(!0),_e.removeAllRanges(),_e.addRange(fe)}else H.appendChild(X);return O(re),D(),A(),{settle(fe){const Pe=Zu(fe);if(Pe===null||!X.isConnected)return;delete X.dataset.transient,X.dataset.token=fe;const ke=C.current.get(Y);ke!==void 0&&(ke.name=Pe.name,ke.target=Pe.target,ke.data=void 0,$(Ge=>[...Ge])),Z(!1)},update(fe){const Pe=C.current.get(Y);Pe!==void 0&&(Pe.data=fe,$(ke=>[...ke]))},remove(){K(Y)}}},[Z,O,K,A,D]);u.useImperativeHandle(j,()=>({focus(){_.current?.focus()},element(){return _.current},getCaretOffset(){const U=_.current;if(U===null)return N.current;const{caret:q}=Ka(U,N.current);return q},caretOffsetFromPoint(U,q){const M=_.current;return M===null?null:em(M,U,q)},insertText:z,insertAtomic:me,insertTransient:ne}),[z,me,ne]),u.useLayoutEffect(()=>{const U=_.current;if(U===null)return;if(r!==null&&r.nonce!==T.current&&(T.current=r.nonce,t===k.current)){jo(U,r.offset),N.current=r.offset;return}if(t===k.current)return;if(S.current){w.current=t;return}const q=k.current===null,M=r!==null&&r.nonce===T.current?r.offset:Math.min(N.current,t.length);B(t,M),q&&(E.current={entries:[{value:t,caret:M}],index:0,lastPush:0})},[t,r,B]);const Ne=x.map(U=>U.scheme).join(","),ce=u.useRef(!0);u.useLayoutEffect(()=>{if(ce.current){ce.current=!1;return}k.current!==null&&B(k.current,N.current)},[Ne,B]),u.useLayoutEffect(()=>{A()},[t,A]),u.useEffect(()=>{const U=_.current;if(U===null)return;const q=new ResizeObserver(()=>A());return q.observe(U),()=>q.disconnect()},[A]),u.useEffect(()=>{const U=_.current;if(U===null)return;const q=()=>{Ml(U)===""&&(U.dataset.empty="false")};return U.addEventListener("beforeinput",q),()=>U.removeEventListener("beforeinput",q)},[]);const se=u.useCallback(()=>{const U=_.current;if(U===null)return;const{caret:q}=Ka(U,N.current);N.current=q,L.current.onCaretChange?.(q)},[]),we=u.useCallback(()=>{S.current||Z(!0)},[Z]),he=u.useCallback(()=>{S.current=!0,p?.()},[p]),pe=u.useCallback(()=>{S.current=!1,g?.();const U=w.current;if(w.current=null,U!==null&&U!==k.current){B(U,Math.min(N.current,U.length));return}Z(!1)},[Z,g,B]),Me=u.useCallback(U=>{if(L.current.disabled)return;const q=U.ctrlKey||U.metaKey,M=U.key.toLowerCase();if(q&&!U.shiftKey&&M==="z"){U.preventDefault(),ie();return}if(q&&M==="y"||q&&U.shiftKey&&M==="z"){U.preventDefault(),le();return}if(L.current.onKeyDown?.(U),!U.defaultPrevented){if(U.key==="Enter"&&!U.nativeEvent.isComposing&&!S.current){U.shiftKey&&(U.preventDefault(),z(`
|
|
556
|
+
`));return}if(U.key==="Backspace"&&!q){const H=_.current,X=window.getSelection();if(H===null||X===null||X.rangeCount===0||!X.isCollapsed)return;const Y=X.getRangeAt(0);let re=null;const _e=Y.startContainer,fe=Y.startOffset;if(_e.nodeType===Node.TEXT_NODE&&fe===0?re=_e.previousSibling:_e===H&&fe>0&&(re=H.childNodes[fe-1]??null),re!==null&&(ws(re)||fo(re))){U.preventDefault();const Pe=[...C.current.values()].find(ke=>ke.el===re);Pe!==void 0?K(Pe.key):(re.parentNode?.removeChild(re),Z(!1))}}}},[Z,z,le,K,ie]),oe=u.useCallback(U=>{if(L.current.disabled)return;const q=U.clipboardData?.files;if(q!==void 0&&q.length>0&&L.current.onPasteFiles!==void 0){U.preventDefault(),L.current.onPasteFiles(Array.from(q));return}const M=U.clipboardData?.getData("text/plain");if(M===void 0||M===""||(U.preventDefault(),_.current===null))return;const X=N.current,Y=[],re=[];let _e=0;for(const fe of nr(M,L.current.atomicSchemes))if(fe.type==="text")Y.push(document.createTextNode(fe.text)),_e+=fe.text.length;else{const{el:Pe,entry:ke}=V(fe);Y.push(Pe),re.push(ke),_e+=fe.token.length}J(X,Y,_e,re)},[J,V]),je=u.useCallback(U=>{if(U.dataTransfer.files.length>0||Array.from(U.dataTransfer.types).some(X=>X.startsWith("application/")))return;const q=U.dataTransfer.getData("text/plain");if(q==="")return;U.preventDefault();const M=_.current,H=M!==null?em(M,U.clientX,U.clientY)??N.current:N.current;z(q,H)},[z]),{role:Ee,...Ce}=v;return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:_,className:`rich-composer${c!==void 0&&c!==""?` ${c}`:""}`,contentEditable:!l,suppressContentEditableWarning:!0,role:Ee??"textbox","aria-multiline":"true","aria-disabled":l||void 0,tabIndex:l?-1:0,spellCheck:m,enterKeyHint:f,"data-rich-composer":"","data-placeholder":i,"data-empty":"true",style:{maxHeight:`var(${d}, ${Qp}px)`,overflowY:"auto"},onInput:we,onKeyDown:Me,onCompositionStart:he,onCompositionEnd:pe,onPaste:oe,onDrop:je,onSelect:se,onClick:se,onKeyUp:se,onFocus:se,...Ce}),I.map(U=>{const M=x.find(H=>H.scheme===U.scheme)?.render;return fr.createPortal(M!==void 0?o.jsx(M,{scheme:U.scheme,name:U.name,target:U.target,data:U.data,port:y,onRemove:()=>K(U.key)}):o.jsx("span",{className:"rich-atomic-fallback",children:U.name||U.target}),U.el,U.key)})]})});function eg({as:e="aside",title:t,actions:n,controls:s,children:r,label:i,id:l,className:c,shellRef:d,drawer:m}){const f=h=>{typeof d=="function"?d(h):d&&(d.current=h)};return o.jsxs(o.Fragment,{children:[o.jsxs(e,{...m?{role:"dialog","aria-modal":m.open}:{},ref:f,id:l,className:be("sidebar-shell",m&&"is-drawer",m?.open&&"open",c),"aria-label":i,inert:m&&!m.open?!0:void 0,"aria-hidden":m&&!m.open?!0:void 0,children:[o.jsxs("header",{className:"sidebar-head",children:[o.jsx("h2",{className:"sidebar-title",children:t}),o.jsxs("div",{className:"sidebar-actions",children:[n,m?.open&&o.jsx(Cn,{label:m.closeLabel,onClick:m.onClose,children:"×"})]})]}),s!=null&&o.jsx("div",{className:"sidebar-controls",children:s}),o.jsx("div",{className:"sidebar-scroll",children:r})]}),m?.open&&o.jsx("button",{type:"button",className:"drawer-backdrop","aria-label":m.backdropLabel,onClick:m.onClose})]})}const ZS=()=>!1;function Uc(e,t,n){const s=u.useRef(null);let r=s.current;r===null||r.reset!==n?(r={reset:n,initial:e.length===0?null:nm(e,t)},s.current=r):r.initial===null&&e.length>0&&(r.initial=nm(e,t));const i=r.initial;return i===null?ZS:l=>!i.has(l)}function nm(e,t){const n=new Set;for(const s of e)n.add(t(s));return n}const ej=.5,tj=30,nj=1200,sj=4e3,oj=100;let sm;function rj(){return typeof window>"u"?!1:(sm??=window.matchMedia("(prefers-reduced-motion: reduce)"),sm.matches)}function tg(e,t){const[n,s]=u.useState(e),r=u.useRef(e),i=u.useRef(e),l=u.useRef(void 0),c=u.useRef(0),d=u.useRef(0),m=rj(),f=!t||m,h=u.useCallback(p=>{const g=i.current,b=r.current,x=g.length-b.length;if(x<=0){l.current=void 0;return}if(x>sj){r.current=g,d.current=0,s(g),l.current=void 0;return}const y=Math.min(Math.max(p-c.current,0),oj);c.current=p;const v=Math.min(nj,Math.max(tj,x/ej));d.current+=v*y/1e3;const j=Math.floor(d.current);if(j>0){d.current-=j;const _=g.slice(0,b.length+Math.min(j,x));r.current=_,s(_)}l.current=requestAnimationFrame(h)},[]);return u.useEffect(()=>{i.current=e;const p=()=>{l.current!==void 0&&(cancelAnimationFrame(l.current),l.current=void 0)};if(f){p(),d.current=0,r.current!==e&&(r.current=e,s(e));return}(e.length<r.current.length||!e.startsWith(r.current))&&(r.current=e,d.current=0,s(e)),r.current.length<e.length&&l.current===void 0&&(c.current=performance.now(),l.current=requestAnimationFrame(h))},[e,f,h]),u.useEffect(()=>()=>{l.current!==void 0&&cancelAnimationFrame(l.current)},[]),f?e:n}const ij=["state_invalid","code_missing","secret_missing","token_exchange_failed","user_fetch_failed","not_allowlisted","public_origin_missing","backend_not_configured","bootstrap_replayed","bootstrap_expired","bootstrap_invalid"],aj=["invalid_credentials","invalid_code","code_replayed","ticket_invalid","rate_limited","password_not_set","password_unsupported","bootstrap_disabled"],lj={github:"github",microsoft:"microsoft",gitee:"gitee"};function Pl(e){return e==null||e===""?null:ij.includes(e)?{code:e,message:a(`auth.error.${e}`)}:aj.includes(e)?{code:e,message:a(`auth.error.${e}`)}:{code:e,message:a("auth.error.unknown")}}function cj(){try{return Pl(new URLSearchParams(window.location.search).get("error"))}catch{return null}}function dj({backends:e,passwordSet:t,username:n,totpRequired:s,recoveryCodesLeft:r,bootstrapError:i,onDone:l}){const c=e.find(T=>T.kind==="password")??null,d=e.filter(T=>T.kind!=="password"),[m,f]=u.useState(n),[h,p]=u.useState(""),[g,b]=u.useState(""),[x,y]=u.useState(null),[v,j]=u.useState(!1),[_,S]=u.useState(Pl(i)??cj()),w=T=>{if(T.ok&&T.totpRequired===!0&&typeof T.ticket=="string"){y(T.ticket),b(""),S(null);return}if(T.ok){S(null),l();return}S(Pl(T.error))},k=async T=>{if(T.preventDefault(),!v){j(!0);try{w(await Z0(m,h))}catch{S({code:"network",message:a("auth.error.unknown")})}finally{j(!1),p("")}}},N=async T=>{if(T.preventDefault(),!(v||x===null)){j(!0);try{w(await ek(x,g))}catch{S({code:"network",message:a("auth.error.unknown")})}finally{j(!1)}}};return o.jsx("main",{className:"flex min-h-dvh flex-col items-center justify-center bg-bg px-6 text-ink",children:o.jsxs("div",{className:"w-full max-w-sm rounded-lg bg-surface p-6 shadow-elev-1 forced-colors:border",children:[o.jsx("h1",{className:"text-center font-serif text-title font-semibold leading-tight tracking-wide text-ink",children:a("auth.login.title")}),c!==null&&o.jsx("p",{className:"mt-2.5 max-w-prose text-md leading-normal text-muted",children:a("auth.login.passwordSubtitle")}),_!==null&&o.jsxs("div",{className:"mt-4 rounded-sm border border-danger/40 bg-danger-soft px-3 py-2",role:"alert",children:[o.jsx("p",{className:"text-sm text-danger",children:_.message}),o.jsx("p",{className:"mt-1 break-all font-mono text-2xs text-danger/80",children:_.code})]}),c!==null&&!t&&o.jsx("p",{className:"mt-4 rounded-sm border border-line bg-sunken px-3 py-2 text-xs text-muted",children:a("auth.login.bootstrapHint")}),c!==null&&t&&x===null&&o.jsxs("form",{onSubmit:T=>{k(T)},className:"mt-5 flex flex-col gap-3",children:[o.jsx(We,{label:a("auth.login.username"),htmlFor:"login-username",children:o.jsx(Xe,{id:"login-username",name:"username",autoComplete:"username",value:m,onChange:T=>f(T.target.value)})}),o.jsx(We,{label:a("auth.login.password"),htmlFor:"login-password",children:o.jsx(Xe,{id:"login-password",name:"password",type:"password",autoComplete:"current-password",value:h,onChange:T=>p(T.target.value)})}),o.jsx(G,{type:"submit",variant:"primary",disabled:v,className:"mt-1 w-full",children:a("auth.login.submit")})]}),s&&x!==null&&o.jsxs("form",{onSubmit:T=>{N(T)},className:"mt-5 flex flex-col gap-3",children:[o.jsx(We,{label:a("auth.login.codeLabel"),htmlFor:"login-code",hint:r>0?a("auth.login.codeHint"):a("auth.login.codeHintNoRecovery"),children:o.jsx(Xe,{id:"login-code",name:"code",inputMode:"numeric",autoComplete:"one-time-code",className:"font-mono tracking-widest",value:g,onChange:T=>b(T.target.value)})}),o.jsx(G,{type:"submit",variant:"primary",disabled:v,className:"mt-1 w-full",children:a("auth.login.submitCode")}),o.jsx(G,{type:"button",variant:"plain",className:"w-full",onClick:()=>{y(null),b(""),S(null)},children:a("auth.login.backToPassword")})]}),d.length>0&&x===null&&o.jsx("div",{className:`${c===null?"mt-5":"mt-3"} flex flex-col gap-3`,children:d.map((T,R)=>{const E=lj[T.id];return o.jsxs(G,{type:"button",variant:c===null&&R===0?"primary":"plain",className:"w-full",onClick:()=>{window.location.assign(T.startPath)},children:[E!==void 0&&o.jsx(yt,{name:E,size:16}),T.label]},T.id)})}),c!==null&&t&&o.jsx("p",{className:"mt-4 break-all text-xs text-faint",children:a("auth.login.totpHint")})]})})}function uj({username:e,passwordSet:t,onDone:n}){const[s,r]=u.useState(t?"totp":"password"),[i,l]=u.useState(""),[c,d]=u.useState(""),[m,f]=u.useState(null),[h,p]=u.useState(null),[g,b]=u.useState([]),[x,y]=u.useState(null),[v,j]=u.useState(!1),_=async T=>{if(T.preventDefault(),!v){if(i!==c){y(a("auth.setup.passwordMismatch"));return}j(!0);try{const R=await nk(i);if(!R.ok){y(a(`auth.error.${R.error??"unknown"}`));return}y(null),l(""),d(""),r("totp")}catch{y(a("auth.error.unknown"))}finally{j(!1)}}},S=async()=>{if(!v){j(!0);try{const T=await sk();if(!T.ok){y(a(`auth.error.${T.error??"unknown"}`));return}y(null),n()}catch{y(a("auth.error.unknown"))}finally{j(!1)}}},w=async()=>{if(!v){j(!0);try{const T=await ok();if(!T.ok){y(a(`auth.error.${T.error??"unknown"}`));return}y(null),f(T.otpauthUri??null),p(T.secret??null),b(T.recoveryCodes??[]),r("done")}catch{y(a("auth.error.unknown"))}finally{j(!1)}}},k="mt-4 inline-flex w-full items-center justify-center rounded-full bg-ink px-4 py-2.5 text-sm font-medium text-surface transition-opacity duration-150 hover:opacity-90 pointer-coarse:min-h-touch disabled:opacity-50";return o.jsx("main",{className:"flex min-h-dvh flex-col items-center justify-center bg-bg px-6 text-ink",children:o.jsxs("div",{className:"w-full max-w-md rounded-xl bg-surface p-8 shadow-elev-1 forced-colors:border",children:[o.jsx("h1",{className:"font-serif text-2xl font-semibold",children:a("auth.setup.title")}),o.jsx("p",{className:"mt-2 text-sm text-muted",children:a("auth.setup.subtitle",{user:e})}),x!==null&&o.jsx("p",{className:"mt-4 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-sm text-danger",role:"alert",children:x}),s==="password"&&o.jsxs("form",{onSubmit:T=>{_(T)},className:"mt-6",children:[o.jsx("label",{className:"block text-xs font-medium text-muted",htmlFor:"setup-password",children:a("auth.setup.password")}),o.jsx("input",{id:"setup-password",type:"password",autoComplete:"new-password",value:i,onChange:T=>l(T.target.value),className:"mt-1 w-full rounded-lg border border-line bg-transparent px-3 py-2 text-sm text-ink outline-none focus:border-ink"}),o.jsx("label",{className:"mt-3 block text-xs font-medium text-muted",htmlFor:"setup-confirm",children:a("auth.setup.passwordConfirm")}),o.jsx("input",{id:"setup-confirm",type:"password",autoComplete:"new-password",value:c,onChange:T=>d(T.target.value),className:"mt-1 w-full rounded-lg border border-line bg-transparent px-3 py-2 text-sm text-ink outline-none focus:border-ink"}),o.jsx("p",{className:"mt-2 text-xs text-faint",children:a("auth.setup.passwordHint")}),o.jsx("button",{type:"submit",disabled:v,className:k,children:a("auth.setup.savePassword")})]}),s==="totp"&&o.jsxs("div",{className:"mt-6",children:[o.jsx("p",{className:"text-sm text-muted",children:a("auth.setup.totpIntro")}),o.jsx("button",{type:"button",disabled:v,onClick:()=>{w()},className:k,children:a("auth.setup.enrollTotp")}),o.jsx("button",{type:"button",disabled:v,className:"mt-3 inline-flex w-full items-center justify-center rounded-full bg-transparent border border-line px-4 py-2 text-sm text-muted transition-opacity duration-150 hover:opacity-90 disabled:opacity-50",onClick:()=>{S()},children:a("auth.setup.skipTotp")})]}),s==="done"&&o.jsxs("div",{className:"mt-6",children:[o.jsx("p",{className:"text-sm text-muted",children:a("auth.setup.totpSecret")}),m!==null&&o.jsx("p",{className:"mt-2 break-all rounded-lg border border-line bg-sunken px-3 py-2 text-xs text-ink",children:m}),h!==null&&o.jsx("p",{className:"mt-2 break-all text-xs text-faint",children:a("auth.setup.secretFallback",{secret:h})}),o.jsx("p",{className:"mt-4 text-sm font-medium text-danger",children:a("auth.setup.recoveryTitle")}),o.jsx("ul",{className:"mt-2 grid grid-cols-2 gap-1 text-xs text-ink",children:g.map(T=>o.jsx("li",{className:"rounded border border-line bg-sunken px-2 py-1 font-mono",children:T},T))}),o.jsx("p",{className:"mt-2 text-xs text-faint",children:a("auth.setup.recoveryHint")}),o.jsx("button",{type:"button",disabled:v,className:k,onClick:()=>{S()},children:a("auth.setup.finish")})]})]})})}const oi=u.createContext(null);function ng(){const e=u.useContext(oi);if(e===null)throw new Error("useAuth must be used inside <AuthProvider>");return e}const mj="GitHub";function fj(e){return e.authEnabled?e.authenticated?e.user?.backend==="bootstrap"?"setup":"authenticated":"anonymous":"disabled"}function hj({children:e}){const[t,n]=u.useState(null),[s,r]=u.useState("loading"),[i,l]=u.useState(null),c=u.useCallback(async()=>{const p=yS();if(p!==""){xS();try{const g=await tk(p);g.ok||l(g.error??"bootstrap_invalid")}catch{l("bootstrap_invalid")}}},[]),d=u.useCallback(async()=>{try{const p=await Ip();p.authEnabled&&p.authenticated&&p.csrfToken===null&&await Rp().catch(()=>null),n(p),r(fj(p))}catch{n(null),r("unknown")}},[]);u.useEffect(()=>{let p=!1;return(async()=>(await c(),!p&&await d()))(),()=>{p=!0}},[c,d]),u.useEffect(()=>{const p=()=>{d()};return window.addEventListener(_l,p),()=>window.removeEventListener(_l,p)},[d]);const m=u.useCallback(async()=>{try{await X0()}catch{}await d()},[d]),f=t?.loginBackends[0],h=u.useMemo(()=>({phase:s,authEnabled:t?.authEnabled===!0,user:t?.user??null,loginLabel:f?.label??mj,startPath:f?.startPath??"/auth/github/start",refresh:d,logout:m}),[s,t,f,d,m]);return s==="anonymous"?o.jsx(oi.Provider,{value:h,children:o.jsx(dj,{backends:t?.loginBackends??[],passwordSet:t?.passwordSet!==!1,username:t?.username??"",totpRequired:t?.totpRequired===!0,recoveryCodesLeft:t?.recoveryCodesLeft??0,bootstrapError:i,onDone:()=>{l(null),d()}})}):s==="setup"?o.jsx(oi.Provider,{value:h,children:o.jsx(uj,{username:t?.user?.username??t?.username??"admin",passwordSet:t?.passwordSet===!0,onDone:()=>{d()}})}):s==="loading"?o.jsx("div",{className:"flex min-h-dvh items-center justify-center bg-bg","aria-busy":"true",children:o.jsx("span",{className:"text-sm text-faint",children:"…"})}):o.jsx(oi.Provider,{value:h,children:e})}t0(qc);function om(e){return e!=="disabled"&&e!=="unknown"}function pj(e){console.info(`[vessel] auth.relogin skipped: auth_${e}`)}function gj(){const e=u.useSyncExternalStore(Zn.subscribe,Zn.snapshot,Zn.snapshot),{phase:t}=ng(),n=om(t),s=u.useCallback(()=>{if(!om(t)){pj(t);return}qc(),Zn.clear()},[t]);return{block:e.block,relogin:s,canRelogin:n}}const Un=_S();function bj(e){const t=Fi(e,window.location.protocol);return t.ok?t.value:e.trim().replace(/\/+$/,"")}function rm(e){return e.code==="session_required"?a("auth.sessionRequired"):e.code==="csrf_failed"?a("auth.csrfRejected"):e.status===401||e.code==="platform_unauthorized"?a("gateway.platform.tokenRequired"):e.code==="no_nodes"?a("gateway.platform.noNodes"):e.code==="network"?a("gateway.connection.unreachable",{detail:e.message}):e.status===403?a("gateway.connection.originRejected",{detail:e.message}):e.message}function im(e){return e.code==="session_required"||e.code==="csrf_failed"||e.status===401||e.code==="platform_unauthorized"||e.status===403?!1:e.code==="network"||e.code==="no_nodes"?!0:e.code==="node_timeout"||e.code==="node_unreachable"}function vj({children:e}){const t=ot(),n=u.useMemo(()=>new Ww,[]),[s,r]=u.useState(Un.platformUrl),[i,l]=u.useState(Un.platformToken),[c,d]=u.useState(Un.platformUrlError),[m,f]=u.useState(Un.platformUrlError!==null),[h,p]=u.useState(null),[g,b]=u.useState(""),[x,y]=u.useState(!1),[v,j]=u.useState(!1),[_,S]=u.useState(null),[w,k]=u.useState("pending"),[N,T]=u.useState(0),[R,E]=u.useState([]),[I,$]=u.useState(null),[C,L]=u.useState({preferredNodeId:null,fallback:null}),[A,D]=u.useState(0),{devProxyAuth:O}=Un,[F,V]=u.useState(Un.platformUrlError),[B,W]=u.useState(null),[Z,ee]=u.useState(null),[ie,le]=u.useState("idle"),[J,z]=u.useState(null),[me,K]=u.useState(0),[ne,Ne]=u.useState(0),[ce,se]=u.useState(null),[we,he]=u.useState(a0),pe=gj(),Me=dt(te=>te.permissions),oe=dt(te=>te.asks),je=dt(te=>te.notices),Ee=dt(te=>te.responding),[Ce,U]=u.useState(0),q=u.useRef(new Kk),M=u.useRef(new Map(Fp().map(te=>[te,Date.now()]))),H=u.useRef(0),X=u.useRef(Un.legacyNodeToken),Y=u.useRef(""),re=u.useRef(G0()),_e=u.useRef(!0),fe=u.useRef(new Set),Pe=u.useRef(null),ke=u.useRef(!1),Ge=u.useRef(0),mt=u.useRef(J);mt.current=J;const lt=u.useRef(!1),de=u.useMemo(()=>new uS(h??"",v?{proxy:!0}:{}),[h,v]),qe=u.useMemo(()=>new TS(de,n),[de,n]),Oe=u.useRef(g);Oe.current=g;const ue=h!==null&&(v||g.trim()!==""||x),xe=ue,De=u.useRef(ue);De.current=ue,u.useEffect(()=>{if(m){k("platform"),E([]),$(null),le("error");return}if(Un.devProxyAuth){k("legacy"),E([]),$(null),S(null),j(!1),p(s),b(X.current),y(!1),d(null);return}let te=!1,Ie;const Ze=()=>{const gt=Cp(Ge.current);Ge.current+=1,Ie=window.setTimeout(()=>{te||T(nt=>nt+1)},gt)};le("connecting"),d(null);const at=new ik(s,i);return Ik(at,{preferredNodeId:re.current,requirePreferredUp:_e.current,manualNodeToken:Y.current}).then(gt=>{if(te)return;if(gt.kind==="legacy"){Ge.current=0;const rt=i.trim(),vo=rt!==""?rt:X.current;rt!==""&&(sessionStorage.setItem($o,rt),X.current=rt),k("legacy"),E([]),$(null),S(null),j(!1),p(s),b(vo),y(!1),d(null);return}if(gt.kind==="error"){if(im(gt.error)){Pe.current=gt.error,Ze();return}Ge.current=0,k("platform"),E([]),$(null),p(null),d(rm(gt.error)),le("error");return}Ge.current=0;const{connection:nt}=gt,Cr={nodeId:nt.node.node_id,name:nt.node.name};if(nt.proxy!==null){for(const rt of fe.current)Qs(An({name:rt,nodeId:rt}));fe.current=new Set(nt.nodes.map(rt=>rt.node_id)),re.current=nt.node.node_id,_e.current=!0,Iu(nt.node.node_id),k("platform"),E(nt.nodes),$(nt.node.node_id),L(nt.selection),S(Cr),j(!0),p(nt.proxy.baseUrl),b(i.trim()),y(!1),d(null);return}j(!1);const xa=new Map(nt.nodes.map(rt=>[rt.node_id,rt.name])),Tr=new Set(nt.nodes.map(rt=>rt.node_id));for(const rt of nt.nodeCredentials){const vo=An({name:xa.get(rt.node_id)??rt.node_id,nodeId:rt.node_id}),ve=rt.node_id===nt.node.node_id?nt.nodeToken:rt.token;if(ve===""){Qs(vo);continue}Rc(vo,ve)}for(const rt of fe.current)Tr.has(rt)||Qs(An({name:rt,nodeId:rt}));fe.current=Tr,re.current=nt.node.node_id,_e.current=!0,Iu(nt.node.node_id),k("platform"),E(nt.nodes),$(nt.node.node_id),L(nt.selection),S(Cr),p(bj(nt.node.api_url)),b(nt.nodeToken),y(nt.anonymous),d(nt.credentialsError!==null&&nt.nodeToken===""?a("gateway.platform.credentialsUnavailable"):null)}).catch(gt=>{if(!te){if(gt instanceof jn&&im(gt)){Pe.current=gt,Ze();return}Ge.current=0,k("platform"),E([]),$(null),p(null),d(gt instanceof Error?gt.message:String(gt)),le("error")}}),()=>{te=!0,window.clearTimeout(Ie)}},[s,i,N,m,A]);const Je=u.useCallback(te=>{const Ie=te.trim();Ie!==""&&(Y.current="",re.current=Ie,_e.current=!1,D(Ze=>Ze+1))},[]),ht=u.useCallback(te=>{if(!te)return;const Ie=M.current;for(Ie.delete(te),Ie.set(te,Date.now());Ie.size>500;){const Ze=Ie.keys().next().value;if(Ze===void 0)break;Ie.delete(Ze)}},[]),ft=IS({client:de,recordSettled:ht,settledRef:M,tokenRef:Oe,canConnectRef:De,hydrationGenerationRef:H,onFetchState:he}),pt=u.useMemo(()=>({shouldDefer:()=>De.current&&mt.current===null&&!ke.current&&!lt.current,defer:te=>{Pe.current=te}}),[]),Q=MS(de,le,W,ee,pt),ye=u.useMemo(()=>({invalidateRouteSnapshot:()=>{Uu();const te=it.getState();te.selectedId!==null&&te.loadDetail(de,te.selectedId,{force:!0})},hydrateInteractions:()=>{ft()},onSessionHistoryChanged:te=>{it.getState().reloadAfterHistoryChange(de,te)},onReconnected:()=>{Uu(),it.getState().refresh(de,{force:!0}),ft()},onRotateCandidate:te=>se(te)}),[de,ft]);u.useEffect(()=>{if(!ue){de.close(),n.clear(),le("idle"),z(null),dt.getState().reset(),M.current.clear(),H.current+=1,K(0),Pe.current=null,ke.current=!1,Ge.current=0;return}return mS({client:de,token:g,eventStore:n,toast:t,subscription:qe,recovery:ye,settledRef:M,recordSettled:ht,reportConnectError:Q,setConnectionState:le,setHello:z,setReconnectAttempt:K,setTokenError:W,setGatewayError:V,setLastError:ee,setEpoch:Ne,deferredErrorRef:Pe,startupGraceActive:()=>mt.current===null})},[de,g,ue,Ce,n,qe,ye,Q,ht,t]),u.useEffect(()=>{xe&&ft()},[ne,xe,ft]);const{connect:Te,disconnect:Ue,retry:Be}=ES({client:de,eventStore:n,nodeToken:g,mode:w,nodeIdentity:_,canConnect:ue,reportConnectError:Q,setPlatformUrl:r,setPlatformToken:l,setGatewayError:V,setPlatformError:d,setUrlInvalid:f,setBootstrapSeq:T,setNodeToken:b,setAnonymousNode:y,setTokenError:W,setLastError:ee,setConnectSeq:U,manualNodeTokenRef:Y,legacyTokenRef:X}),{respondPermission:tt,respondAsk:Kt,ackNotify:dn}=AS({client:de,hydrateInteractions:ft,recordSettled:ht,toast:t,submitGuard:q}),P=Gu(ie),ae=Gu(ie,{graceMs:Uk});lt.current=ae.visible,u.useEffect(()=>{if(!ae.visible||J!==null||!ue||ke.current)return;ke.current=!0;const te=Pe.current;Pe.current=null,te!==null&&(ee(te instanceof jn?rm(te):Wp(te)),le("error"))},[ae.visible,J,ue]),u.useEffect(()=>{J!==null&&(ke.current=!1,Pe.current=null,Ge.current=0)},[J]);const Le=u.useMemo(()=>({client:de,eventStore:n,subscription:qe,connectionState:ie,hello:J,features:J?.protocol.features??[],nodeLabel:J?.node.name??J?.node.node_id?.slice(0,12)??"",platformUrl:s,nodeUrl:h??"",platformToken:i,nodeToken:g,mode:w,platformNodes:R,selectedNodeId:I,nodeSelection:C,selectPlatformNode:Je,platformError:c,hasToken:xe,devProxyAuth:O,gatewayError:F,tokenError:B,lastError:Z,reconnectAttempt:me,epoch:ne,stale:J!==null&&P.visible&&B===null&&Z===null&&F===null,closeCode:de.closedWithCode,permissions:Me,asks:oe,notices:je,pendingFetch:we,sessionInvalid:pe.block,relogin:pe.relogin,canRelogin:pe.canRelogin,hydrateInteractions:ft,responding:Ee,connect:Te,disconnect:Ue,clearToken:Ue,retry:Be,dismissError:()=>ee(null),clearTokenError:()=>W(null),respondPermission:tt,respondAsk:Kt,ackNotify:dn,rotateCandidate:ce}),[de,n,qe,ie,J,P.visible,s,h,i,g,w,R,I,C,Je,c,xe,F,B,Z,me,ne,Me,oe,je,we,pe.block,pe.relogin,pe.canRelogin,ft,Ee,Te,Ue,Be,tt,Kt,dn,ce]);return o.jsx(vr.Provider,{value:Le,children:e})}function Ae(){const e=u.useContext(vr);if(!e)throw new Error("useConnection must be used inside <ConnectionProvider>");return e}function Ji(){const{eventStore:e}=Ae();return u.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function yj(e,t){const n=(s,r)=>Bi(e,s,r,t());return{async listTeams(){const s=await n("teams.list",{});return Array.isArray(s?.teams)?s.teams:[]},getTeam(s,r){return n("teams.get",{team_id:s,...r?.limit!==void 0?{limit:r.limit}:{},...r?.members_limit!==void 0?{members_limit:r.members_limit}:{},...r?.before!==void 0?{before:r.before}:{}})},postTeam(s){return n("teams.post",s)},createTeam(s){return n("teams.create",s)},updateTeam(s){return n("teams.update",s)},archiveTeam(s){return n("teams.archive",{team_id:s})},retractTeam(s){return n("teams.retract",s)},recallTeamDelivery(s){return n("teams.recall_delivery",s)},listAttachments(s={}){return n("attachments.list",s)},setSpawnFrozen(s,r){return n("teams.spawnFrozen",{team_id:s,frozen:r})},async getSession(s,r){const i=await n("sessions.get",{session_id:s,...r?.message_limit!==void 0?{message_limit:r.message_limit}:{},...r?.before!==void 0?{before:r.before}:{}});if(!i?.session)throw new Error(`Session not found: ${s}`);return i.session},async listAgents(){const s=await n("agents.list",{});return Array.isArray(s?.agents)?s.agents:[]},async createAgent(s){return Xs(await n("agents.create",{agents:[s]}))},async updateAgent(s){return Xs(await n("agents.update",{agents:[s]}))},async closeAgent(s){return Xs(await n("agents.close",{agents:[{agent_id:s}]}))},createSession(s){return n("sessions.create",s)},listSubscriptions(s){return n("subscription.list",{...s!==void 0?{agent_id:s}:{}})},muteSubscription(s,r,i){return n("subscription.mute",{agent_id:s,source:r,...i!==void 0?{target:i}:{}})},unmuteSubscription(s,r,i){return n("subscription.unmute",{agent_id:s,source:r,...i!==void 0?{target:i}:{}})},addSubscription(s,r,i){return n("subscription.add",{agent_id:s,source:r,target:i})},removeSubscription(s,r,i){return n("subscription.remove",{agent_id:s,source:r,target:i})},subscriptionCatalog(){return n("subscription.catalog",{})}}}const sg=u.createContext(null);function xj(){return typeof window>"u"?"http:":window.location.protocol}const wj=15e3;function kj({children:e}){const{client:t,nodeToken:n,nodeUrl:s,hello:r,hasToken:i,epoch:l,mode:c,platformNodes:d,selectedNodeId:m}=Ae(),f=u.useRef(n);f.current=n;const h=Dt(C=>C.extras),p=Dt(C=>C.nodes),g=Dt(C=>C.current),b=Dt(C=>C.loadHealth),x=u.useMemo(()=>d.map(C=>({name:C.name,url:C.api_url,nodeId:C.node_id,current:C.node_id===m,status:C.status})),[d,m]);u.useEffect(()=>{c==="legacy"&&Dt.getState().setExtras(yo())},[c]),u.useEffect(()=>{c==="platform"&&Dt.getState().setPlatformNodes(x)},[c,x]),u.useEffect(()=>{c!=="platform"&&Dt.getState().setConnection({hasToken:i,hello:r,nodeUrl:s})},[c,i,r,s]);const y=u.useCallback(C=>C.current?f.current:ei(An(C))??void 0,[]),v=u.useCallback(C=>C.current?t.getHealth():Bi(C,"health.get",{},y(C)),[y,t]),j=c==="platform"?g?[g]:[]:p,_=j.map(C=>C.nodeId??C.name).join(",");qt(()=>{j.length>0&&b(j,v)},{enabled:j.length>0,pollMs:wj,deps:[l,i,_,c,m]});const S=u.useCallback(()=>{c!=="platform"&&Dt.getState().setExtras(yo())},[c]),w=u.useCallback(C=>{if(c==="platform")return{ok:!1};const L=Yx(C,p,xj());if(!L.ok||!L.value)return{ok:!1,...L.error?{error:L.error}:{}};const A={name:L.value.name,url:L.value.url},D=[...yo().filter(O=>O.name!==A.name),A];return au(D),Rc(An(A),L.value.token),Dt.getState().addExtra(A),{ok:!0}},[c,p]),k=u.useCallback(C=>{if(c==="platform")return;const L=yo().find(D=>D.name===C);Qs(L?An(L):C);const A=yo().filter(D=>D.name!==C);au(A),Dt.getState().removeExtra(C)},[c]),N=u.useCallback((C,L={})=>C.current?t.listInteractionsPage(L):Xx(C,L,y(C)),[y,t]),T=u.useCallback((C={})=>Promise.all(p.map(async L=>{try{return{node:L,ok:!0,page:await N(L,C)}}catch(A){return A instanceof Oo?{node:L,ok:!1,error:A}:A instanceof Pt?{node:L,ok:!1,error:new Oo(A.code,A.message,A.status)}:{node:L,ok:!1,error:new Oo("internal",A instanceof Error?A.message:String(A))}}})),[p,N]),R=u.useCallback(C=>C.current?t:yj(C,()=>ei(An(C))??void 0),[t]),E=u.useCallback(C=>C.current?i:ei(An(C))!==null,[i]),I=u.useCallback(C=>R(C).listTeams(),[R]),$=u.useMemo(()=>({nodes:p,extras:h,current:g,addNode:w,removeNode:k,refresh:S,fetchAttention:N,fetchAllAttention:T,fetchHealth:v,fetchTeams:I,teamControl:R,hasTokenFor:E}),[p,h,g,w,k,S,N,T,v,I,R,E]);return o.jsx(sg.Provider,{value:$,children:e})}function ut(){const e=u.useContext(sg);if(!e)throw new Error("useNodes must be used inside <NodeProvider>");return e}function Sj(e){const t=new Set;return e.map(n=>{const s=n.trim()===""?n:n.trim();let r=s,i=1;for(;t.has(r);)r=`${s}-${i}`,i+=1;return t.add(r),r})}function am(e){const t=e.trim();return t===""||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(t)||t.includes(":")?!0:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}function jj(e,t=""){const n=e.healthName?.trim()||e.name?.trim()||"";return n!==""&&n!==e.nodeId&&!am(n)?n:e.url!==void 0?Pn(e.url,t):e.nodeId??(am(n)?"—":n)}function _j(e,t=""){const n=Sj(e.map(s=>jj(s,t)));return new Map(e.map((s,r)=>[s.key,n[r]??s.name]))}function Nj(e,t,n,s){const r=s.trim().toLowerCase();return r===""?!0:[e,t??"",n].some(i=>i.toLowerCase().includes(r))}const og="vessel.node-names";function Cj(){try{if(typeof sessionStorage>"u")return{};const e=sessionStorage.getItem(og),t=e?JSON.parse(e):{};if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,r]of Object.entries(t))typeof r=="string"&&r.trim()!==""&&(n[s]=r);return n}catch{return{}}}function Tj(e){try{typeof sessionStorage<"u"&&sessionStorage.setItem(og,JSON.stringify(e))}catch{}}function Ej(){return typeof window>"u"?"":window.location.origin}function Ij(e,t){const n=e?.trim();if(!(!n||n===t))return n}function Bt(e){const{nodes:t}=ut(),n=Dt(l=>l.health),[s,r]=u.useState(Cj),i=u.useMemo(()=>sw(n),[n]);return u.useEffect(()=>{if(i.size===0)return;const l={};for(const[c,d]of i){const m=t.find(h=>ge(h)===c),f=Ij(d,m?.nodeId);f&&(l[c]=f)}Object.keys(l).length!==0&&r(c=>{const d={...c,...l};return Tj(d),d})},[i,t]),u.useMemo(()=>_j(t.map(l=>{const c=ge(l),d=e?.get(c)??i.get(c)??s[c];return{key:c,name:l.name,url:l.url,...l.nodeId?{nodeId:l.nodeId}:{},...d?{healthName:d}:{}}}),Ej()),[t,e,i,s])}const Rj={restart:"request",identity:"request",fields:"request",model:"request",tools:"request",lock:"request",conflict:"request",files:"run",health:"run",agent:"run",script:"run","doc-lag":"run","code-heaviness":"run","team-log":"run",context:"request",trim:"run",pii:"request",config:"request",permission:"request",mcp:"request",update:"request",peer:"request"},zc=Rj,Lj=["trim","model"],rg=[{id:"visual",titleKey:"settings.category.visual",order:10},{id:"display",titleKey:"settings.category.display",order:20},{id:"runtime",titleKey:"settings.category.runtime",order:30},{id:"logs",titleKey:"settings.category.logs",order:40},{id:"connection",titleKey:"settings.category.connection",order:50},{id:"advancedConfig",titleKey:"settings.category.advancedConfig",order:60},{id:"extensions",titleKey:"settings.category.extensions",order:70}],vi="observability.log.",ig="emptyResponse.",ag="ui.depthColor.";function lg(e){for(const[t,n]of[[vi,"log"],[ig,"emptyResponse"],[ag,"depthColor"]])if(e.startsWith(t)){const s=e.slice(t.length);return`${n}${s.charAt(0).toUpperCase()}${s.slice(1)}`}return e.split(".").pop()??e}const Aj=[{key:"ui.verbosity",type:"enum",options:["minimal","normal","debug"],default:"normal"},{key:"ui.showReasoning",type:"boolean",default:"false",fallback:"false",group:"messageVisibility",keywords:["思考","thinking","reasoning","思考流","消息显示","message display"]},{key:"ui.messageVisibility.tools",type:"boolean",default:"true",fallback:"true",group:"messageVisibility",keywords:["工具","tool","消息显示","message display"]},{key:"ui.messageVisibility.environment",type:"boolean",default:"true",fallback:"true",group:"messageVisibility",keywords:["环境","notice","消息显示","message display"]},{key:"ui.messageVisibility.source",type:"boolean",default:"true",fallback:"true",group:"messageVisibility",keywords:["来源","from","消息显示","message display"]},{key:"ui.messageVisibility.system",type:"boolean",default:"false",fallback:"false",group:"messageVisibility",keywords:["系统","internal","showInternalEvents","内部事件","消息显示","message display"]},{key:"ui.showArchived",type:"boolean",default:"false"},{key:"ui.showRetiredSessions",type:"boolean",default:"false",fallback:"false",keywords:["退休","退役","旧身体","retired","rotate","会话列表","session list"]},{key:"ui.errorLevel",type:"enum",options:["user","all"],default:"user"},{key:"observability.showProcessErrors",type:"boolean",default:"false"},{key:"ui.askUser",type:"boolean",default:"true"},{key:"ui.expandCards",type:"boolean",default:"false"},{key:"ui.addressStyle",type:"enum",options:["name","compact","full"],default:"name",fallback:"name",keywords:["地址","address","显示格式","节点名","short-id","uuid"]},{key:"ui.statusBars",type:"enum",options:["top","bottom","both","none"]},{key:"ui.language",type:"enum",options:["zh-CN","en"],default:"zh-CN"},{key:"observability.log.level",type:"enum",options:["debug","info","warn","error"],default:"info",fallback:"info"},{key:"observability.log.color",type:"enum",options:["auto","always","never"],default:"auto",fallback:"auto"},{key:"observability.log.format",type:"enum",options:["pretty","json"],default:"pretty",fallback:"pretty"},{key:"observability.log.time",type:"enum",options:["auto","none","clock","iso"],default:"auto",fallback:"auto"},{key:"emptyResponse.enabled",type:"boolean",default:"true",fallback:"true"},{key:"emptyResponse.seamless",type:"boolean",default:"true",fallback:"true"},{key:"emptyResponse.maxRetries",type:"number",min:0,max:10,default:"2",fallback:"2"},{key:"emptyResponse.nudge",type:"string"},{key:"ui.depthColor.enabled",type:"boolean",default:"true",fallback:"true",group:"depthColor",keywords:["深度","层级","depth","配色","color","色相"]},{key:"ui.depthColor.rootHue",type:"number",float:!0,min:0,max:360,maxExclusive:!0,default:"172.6",fallback:"172.6",group:"depthColor",keywords:["根色相","root hue","色相","hue","品牌","黄金角"]},{key:"ui.depthColor.hueStep",type:"number",float:!0,min:0,max:360,default:"137.508",fallback:"137.508",group:"depthColor",keywords:["步进","黄金角","golden","轮转","step","色相"]},{key:"ui.depthColor.lightnessLight",type:"number",float:!0,min:.3,max:.51,default:"0.4714",fallback:"0.4714",group:"depthColor",keywords:["亮度","lightness","OKLCH","light","亮色"]},{key:"ui.depthColor.chromaLight",type:"number",float:!0,min:0,max:.37,default:"0.0887",fallback:"0.0887",group:"depthColor",keywords:["色度","chroma","饱和度","light","亮色"]},{key:"ui.depthColor.lightnessDark",type:"number",float:!0,min:.73,max:.95,default:"0.85",fallback:"0.85",group:"depthColor",keywords:["亮度","lightness","OKLCH","dark","暗色"]},{key:"ui.depthColor.chromaDark",type:"number",float:!0,min:0,max:.37,default:"0.13",fallback:"0.13",group:"depthColor",keywords:["色度","chroma","饱和度","dark","暗色"]},{key:"agent.teamMemberLimit",type:"number",min:1,default:"100",fallback:"100",keywords:["成员上限","团队人数","team limit","team_full"]},{key:"vision.imageTokenBudgetRatio",type:"number",float:!0,min:0,max:1,default:"0.05",fallback:"0.05",keywords:["图片预算","视觉","图片上限","image budget","vision","token"]},{key:"context.toolResultWhitelist",type:"array",default:'[{"tool":"inbox","action":"read"},{"tool":"agent","action":"read"}]',fallback:'[{"tool":"inbox","action":"read"},{"tool":"agent","action":"read"}]',keywords:["白名单","whitelist","trim","占位","placeholder","inbox","压缩","豁免"]}];function Mj(e){return e==="ui.language"||e==="ui.statusBars"||e.startsWith(ag)?"visual":e.startsWith(vi)?"logs":e.startsWith(ig)||e==="agent.teamMemberLimit"||e==="vision.imageTokenBudgetRatio"||e==="context.toolResultWhitelist"?"runtime":"display"}function Pj(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}const qj=Object.keys(zc),Oj=new Set(Lj),lm={request:"settings.env.cadence.request",run:"settings.env.cadence.run",off:"settings.env.cadence.off"},Dj={"model+ui":"settings.env.channel.modelUi","ui-only":"settings.env.channel.uiOnly"};function Hj(){const e=[{id:"envInjection.default",key:"envInjection.default",scope:"user",type:"enum",source:"core",titleKey:"settings.env.default.title",descriptionKey:"settings.env.default.desc",category:"runtime",group:"envNotice",order:0,options:["run","request"],optionLabelKeys:lm,fallback:"run",keywords:["env","环境","粒度","cadence","default","缺省"]}];return qj.forEach((t,n)=>{const s=Oj.has(t),r=s?"run":zc[t]??"request",i=t==="files"?"settings.env.files.desc":s?"settings.env.pinned.desc":"settings.env.delivery.desc";e.push({id:`envInjection.scopes.${t}`,key:`envInjection.scopes.${t}`,scope:"user",type:"enum",source:"core",titleKey:`chat.env.scope.${t}`,descriptionKey:i,category:"runtime",group:"envNotice",order:10+n,options:s?["run","off"]:["request","run","off"],optionLabelKeys:lm,default:r,fallback:r,keywords:["env","环境","粒度","cadence",t,"delivery"]}),e.push({id:`envInjection.channels.${t}`,key:`envInjection.channels.${t}`,scope:"user",type:"enum",source:"core",titleKey:`chat.env.scope.${t}`,descriptionKey:"settings.env.channel.desc",category:"runtime",group:"envNotice",order:100+n,options:["model+ui","ui-only"],optionLabelKeys:Dj,default:"model+ui",fallback:"model+ui",keywords:["env","环境","通道","channel",t,"ui-only"]})}),e}const $j=Hj(),Fj=Aj.map(e=>{const t=lg(e.key);return{id:e.key,key:e.key,scope:"user",type:e.type,source:"core",titleKey:`settings.item.${t}.title`,descriptionKey:`settings.item.${t}.desc`,category:Mj(e.key),...e.group!==void 0?{group:e.group}:{},options:e.options,min:e.min,max:e.max,...e.float!==void 0?{float:e.float}:{},...e.maxExclusive!==void 0?{maxExclusive:e.maxExclusive}:{},default:e.default,fallback:e.fallback,keywords:[t,Pj(t),...e.keywords??[]],...e.type==="array"?{readOnly:!0}:{}}}),Vc=[...Fj,...$j],Bj=[{id:"local.theme",key:"vessel.theme",scope:"local",type:"enum",source:"core",titleKey:"appearance.theme.title",descriptionKey:"appearance.theme.desc",category:"visual",options:["system","light","dark"],optionLabelKeys:{system:"appearance.theme.system",light:"appearance.theme.light",dark:"appearance.theme.dark"},default:"dark",keywords:["theme","主题","dark","light","配色"]},{id:"local.motion",key:"local.motion",scope:"local",type:"string",source:"core",titleKey:"appearance.motion.title",descriptionKey:"appearance.motion.desc",category:"visual",readOnly:!0,keywords:["motion","动效","animation","reduced-motion"]},{id:"local.nav.collapsed",key:"vessel.nav.collapsed",scope:"local",type:"boolean",source:"core",titleKey:"settings.item.local.navCollapsed.title",descriptionKey:"settings.item.local.navCollapsed.desc",category:"visual",default:"false",keywords:["nav","sidebar","侧栏","折叠","collapse"]},{id:"local.nav.groups",key:"vessel.nav.expanded-groups",scope:"local",type:"object",source:"core",titleKey:"settings.item.local.navGroups.title",descriptionKey:"settings.item.local.navGroups.desc",category:"visual",readOnly:!0,resettable:!0,keywords:["nav","groups","分组","展开","折叠"]},{id:"local.settings.tree.collapsed",key:"vessel.settings.tree.collapsed",scope:"local",type:"object",source:"core",titleKey:"settings.item.local.settingsTree.title",descriptionKey:"settings.item.local.settingsTree.desc",category:"advancedConfig",keywords:["settings","tree","分类树","折叠"]},{id:"local.settings.tab",key:"vessel.settings.tab",scope:"local",type:"enum",source:"core",titleKey:"settings.item.local.settingsTab.title",descriptionKey:"settings.item.local.settingsTab.desc",category:"advancedConfig",options:["user","project","local"],default:"user",keywords:["settings","tab","层级","scope"]}],Kj=[{id:"local.designLab",key:"local.designLab",scope:"local",type:"view",view:"designLab",source:"core",titleKey:"settings.item.view.designLab.title",descriptionKey:"settings.item.view.designLab.desc",category:"visual",keywords:["design","设计实验室","token","preview","lab"]},{id:"view.connection",key:"view.connection",scope:"user",type:"view",view:"connection",source:"core",titleKey:"settings.item.view.connection.title",descriptionKey:"settings.item.view.connection.desc",category:"connection",keywords:["gateway","连接","connection","节点","版本"]},{id:"view.advancedConfig",key:"view.advancedConfig",scope:"user",type:"view",view:"advancedConfig",source:"core",titleKey:"settings.item.view.advancedConfig.title",descriptionKey:"settings.item.view.advancedConfig.desc",category:"advancedConfig",keywords:["config","yaml","json","高级","来源","sources"]}];function cg(e=[]){return[...Vc,...Bj,...Kj,...e]}function cm(e){if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number"&&Number.isFinite(e))return String(e);if(typeof e=="string")return e}function Wj(e){const t=[];for(const n of e)for(const s of n.items){const r=s.type==="integer"?"number":s.type;t.push({id:s.id,key:s.key,scope:"user",type:r,source:`plugin:${n.pluginId}`,title:s.title,...s.description!==void 0?{description:s.description}:{},category:"extensions",order:s.order,...s.enum!==void 0?{options:s.enum}:{},...s.minimum!==void 0?{min:s.minimum}:{},...s.maximum!==void 0?{max:s.maximum}:{},...cm(s.default)!==void 0?{default:cm(s.default)}:{},keywords:[n.pluginId,n.pluginName,...s.keywords??[]],pluginId:n.pluginId,...r==="object"||r==="array"?{readOnly:!0}:{}})}return t}function dg(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Uj(e){if(!e)return"dark";try{return ug(e.getItem(Qi))}catch{return"dark"}}function zj(e=dg()){return{theme:Uj(e),settingsPending:{}}}const Vj=/^[a-z0-9][a-z0-9-]{0,63}\.[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/;function Gj(e){const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string")continue;const r=Vc.find(i=>i.key===n);if(!r){Vj.test(n)&&s!==""&&(t[n]=s);continue}if(s===""){t[n]=s;continue}if(r.type==="boolean")(s==="true"||s==="false")&&(t[n]=s);else if(r.type==="enum")r.options?.includes(s)===!0&&(t[n]=s);else if(r.type==="number"){const i=Number(s),l=r.min??Number.NEGATIVE_INFINITY,c=r.max??Number.POSITIVE_INFINITY;Number.isInteger(i)&&i>=l&&i<=c&&(t[n]=s)}else r.type==="string"&&(t[n]=s)}return t}const _n=vn()((e,t)=>({...zj(),setTheme:n=>{const s=dg();s?Qj(n,s):e({theme:n})},setSettingsPending:n=>{const s=Gj(n);Object.keys(s).length!==0&&e({settingsPending:{...t().settingsPending,...s}})},clearSettingsPending:n=>{const s=t().settingsPending;if(n.length===0)return;const r={...s};let i=!1;for(const{key:l,value:c}of n)r[l]===c&&(delete r[l],i=!0);i&&e({settingsPending:r})}})),Qi="vessel.theme";function Yj(e){return e==="light"||e==="dark"?e:"system"}function ug(e){return e==="light"||e==="dark"||e==="system"?e:"dark"}function Jj(e){return e==="system"?null:e}function mg(e,t){return e==="system"?t?"dark":"light":e}function Gc(e,t=document.documentElement){const n=Jj(e);n===null?t.removeAttribute("data-theme"):t.dataset.theme=n}function fg(e){try{return ug(e.getItem(Qi))}catch{return"dark"}}function Qj(e,t){try{t.setItem(Qi,e)}catch{}Gc(e),_n.setState({theme:e})}function hg(){const e=_n(n=>n.theme),t=_n(n=>n.setTheme);return{theme:e,setTheme:t}}function dm(e){const t=e.code;return typeof t=="string"?t:void 0}function Xj(e){return e instanceof Error?e.message:String(e)}async function pg(e,t){try{return{node:e,ok:!0,teams:await t.listTeams()}}catch(n){return{node:e,ok:!1,teams:[],error:Xj(n),...dm(n)?{code:dm(n)}:{}}}}async function Zj(e,t){const n=Promise.resolve().then(()=>t.listAgents()).catch(()=>[]),s=await pg(e,t),r=await n;if(!s.ok)return{...s,rosters:[],agents:r,partialErrors:0};const i=await Promise.allSettled(s.teams.map(async d=>({team:d,members:(await t.getTeam(d.team_id,{members_limit:100})).members}))),l=[];let c=0;for(const d of i)d.status==="fulfilled"?l.push(d.value):c+=1;return{...s,rosters:l,agents:r,partialErrors:c}}function um(e){return e?e.teams.length>0||e.rosters.length>0:!1}function e_(e,t){const n=new Map(e.map(s=>[ge(s.node),s]));return t.map(s=>{const r=n.get(ge(s.node));if(s.ok){if(s.partialErrors>0&&um(r)){const i=new Set(s.rosters.map(d=>d.team.team_id)),l=new Set(s.teams.map(d=>d.team_id)),c=r.rosters.filter(d=>l.has(d.team.team_id)&&!i.has(d.team.team_id));if(c.length>0)return{...s,rosters:[...s.rosters,...c],stale:!0}}return{...s,stale:!1}}return um(r)?{...r,node:s.node,ok:!1,error:s.error,...s.code?{code:s.code}:{},partialErrors:r.partialErrors,stale:!0}:{...s,stale:!1}})}function t_(e){const t=e.id??e.agent_id;if(t)return{agent_id:t,...e.name!==void 0?{name:e.name}:{},...e.session_id!==void 0?{session_id:e.session_id}:{},membership:e.membership??"present",presence:e.presence??"gone",visibility:e.visibility??"private",...e.state!==void 0?{state:e.state}:{},...e.role!==void 0?{role:e.role}:{},...e.owner!==void 0?{owner:e.owner}:{},...e.model!==void 0?{model:e.model}:{},...e.depth!==void 0?{depth:e.depth}:{}}}function ql(e){const t=[],n=new Set;for(const s of e)for(const r of s.rosters)for(const i of r.members)n.add(`${ge(s.node)}:${i.agent_id}`),t.push({node:s.node,team:r.team,member:i});for(const s of e){const r=ge(s.node);for(const i of s.agents??[]){if(!n_(i,n,r))continue;const l=t_(i);if(!l)continue;const c=`${r}:${l.agent_id}`;n.has(c)||(n.add(c),t.push({node:s.node,member:l}))}}return t}function n_(e,t,n){const s=e.id??e.agent_id;return s!==void 0&&!t.has(`${n}:${s}`)}function s_(e,t){return!(t.nodeKey&&ge(e.node)!==t.nodeKey||t.teamId&&e.team?.team_id!==t.teamId||t.state&&e.member.state!==t.state||t.presence&&e.member.presence!==t.presence)}function o_(e,t){return e.filter(n=>s_(n,t))}function r_(e){const t=new Map,n=new Map,s=new Set;for(const r of e)t.set(ge(r.node),r.node.name),r.team&&n.set(r.team.team_id,r.team.name||r.team.team_id),r.member.state&&s.add(r.member.state);return{nodes:[...t].map(([r,i])=>({key:r,label:i})).sort((r,i)=>r.label.localeCompare(i.label)),teams:[...n].map(([r,i])=>({id:r,label:i})).sort((r,i)=>r.label.localeCompare(i.label)),states:[...s].sort()}}const Mr="agent:roster",Yt=vn()((e,t)=>({roster:{status:"idle"},currentAgentId:null,loadRoster:async(n,s)=>{if(n.length===0){e({roster:qn([])});return}const r=t().roster,i=Se(r)??[],l=gn(Mr);e({roster:Qo(r)});try{const c=await Promise.all(n.map(d=>Zj(d,s(d))));if(!kt(Mr,l))return;e({roster:qn(e_(i,c))})}catch(c){if(!kt(Mr,l))return;e({roster:bs(r,c)})}},selectAgent:n=>e({currentAgentId:n}),reset:()=>{rn(Mr),e({roster:{status:"idle"},currentAgentId:null})}}));function i_(e,t,n){for(const s of e)if(ge(s.node)===t)for(const r of s.rosters){const i=r.members.find(l=>l.agent_id===n);if(i)return{node:s.node,team:r.team,member:i}}}function gg(e){return e>=55296&&e<=56319}function Ol(e,t){if(e.length<=t)return e;let n=t;return gg(e.charCodeAt(n-1))&&(n-=1),`${e.slice(0,n)}…`}function bg(e,t){const n=i=>i.replace(/\|/g,"\\|"),s=i=>`| ${i.map(n).join(" | ")} |`,r=`| ${e.map(()=>"---").join(" | ")} |`;return[s(e),r,...t.map(s)].join(`
|
|
557
|
+
`)}function Xi(e){const t=new Map;return e.map(n=>{const s=t.get(n)??0;return t.set(n,s+1),`${n}#${s}`})}const vg=Object.freeze([]),zn=Object.freeze({text:"",chips:vg,refs:Object.freeze([]),sessionRefs:Object.freeze([])}),Dl="chat:new";function Ut(e){return!e||e==="new"?Dl:`chat:${e}`}function a_(e,t){return`team:${e}:${t}`}const Hl="vessel.composerDraft.v2",yg=2,l_=32*1024,yi=32,xi=8,c_=300,wi=new Map;let mm=0;function xg(){try{return typeof window>"u"?null:window.sessionStorage??null}catch{return null}}function so(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wg(e){let t=0;for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);if(t+=s<128?1:s<2048?2:3,t>l_){const r=n>0&&gg(e.charCodeAt(n-1))?n-1:n;return e.slice(0,r)}}return e}function sn(e){mm+=1,wi.set(e,mm)}function Rn(e){wi.delete(e)}function d_(){const{drafts:e}=Qe.getState(),t=[];for(const[n,s]of Object.entries(e))Yc(s)||t.push({key:n,text:wg(s.text),chips:s.chips.map(r=>({agentId:r.agentId,label:r.label})),...s.refs.length>0?{refs:s.refs.map(r=>({...r}))}:{},...s.sessionRefs.length>0?{sessionRefs:s.sessionRefs.map(r=>({...r}))}:{},...s.quote!==void 0?{quote:{...s.quote}}:{},...s.model!==void 0?{model:s.model}:{}});return t.sort((n,s)=>(wi.get(n.key)??0)-(wi.get(s.key)??0)),t.slice(-50)}function u_(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=yi)break;if(!so(n))continue;const{kind:s,path:r}=n;if(s!=="file"&&s!=="image"&&s!=="document"||typeof r!="string"||r.length===0)continue;const i={kind:s,path:r};typeof n.name=="string"&&(i.name=n.name),typeof n.mime=="string"&&(i.mime=n.mime),typeof n.bytes=="number"&&Number.isFinite(n.bytes)&&n.bytes>=0&&(i.bytes=Math.floor(n.bytes)),n.inline===!0&&(i.inline=!0),t.push(i)}return t}function m_(e){if(!Array.isArray(e))return[];const t=[],n=new Set;for(const s of e){if(t.length>=xi)break;if(!so(s))continue;const{sessionId:r,title:i}=s;if(typeof r!="string"||r.length===0||typeof i!="string"||i.length===0||n.has(r))continue;n.add(r);const l={sessionId:r,title:i};for(const c of["agentName","agentId","team","node"]){const d=s[c];typeof d=="string"&&d.length>0&&(l[c]=d)}t.push(l)}return t}function f_(e){if(!so(e))return;const{snippet:t,source:n}=e;if(typeof t!="string"||t.length===0||t.length>160||n!=="user"&&n!=="assistant")return;const s={snippet:t,source:n};return typeof e.messageId=="string"&&e.messageId.length>0&&(s.messageId=e.messageId),s}function h_(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!so(n))continue;const{agentId:s,label:r}=n;typeof s!="string"||typeof r!="string"||t.push({agentId:s,label:r})}return t}function p_(e){if(e===null||e==="")return null;let t;try{t=JSON.parse(e)}catch{return null}if(!so(t)||t.v!==yg)return null;const n=t.slots;if(!Array.isArray(n))return null;const s={};for(const r of n){if(!so(r))continue;const{key:i,text:l}=r;if(typeof i!="string"||i.length===0||typeof l!="string")continue;const c={text:wg(l),chips:h_(r.chips),refs:u_(r.refs),sessionRefs:m_(r.sessionRefs),quote:f_(r.quote),...typeof r.model=="string"&&r.model!==""?{model:r.model}:{}};Yc(c)||(s[i]=c)}return s}let hs;function ki(){hs!==void 0&&(window.clearTimeout(hs),hs=void 0);const e=xg();if(e===null)return;const t=d_();try{if(t.length===0){e.removeItem(Hl);return}const n={v:yg,slots:t};e.setItem(Hl,JSON.stringify(n))}catch{}}function nn(){typeof window>"u"||(hs!==void 0&&window.clearTimeout(hs),hs=window.setTimeout(()=>{hs=void 0,ki()},c_))}let fm=!1;function g_(){document.visibilityState==="hidden"&&ki()}function Rt(){if(fm||typeof window>"u")return;fm=!0,window.addEventListener("pagehide",ki),window.addEventListener("beforeunload",ki),document.addEventListener("visibilitychange",g_);const e=xg();if(e===null)return;let t=null;try{t=e.getItem(Hl)}catch{return}const n=p_(t);if(n===null)return;const s=Object.keys(n);if(s.length!==0){for(const r of s)sn(r);Qe.setState(r=>({drafts:{...n,...r.drafts}}))}}function Yc(e){return e.text.length===0&&e.chips.length===0&&e.refs.length===0&&e.sessionRefs.length===0&&e.quote===void 0&&e.model===void 0}function mn(e,t,n){if(!Yc(n))return{...e,[t]:n};const s={...e};return delete s[t],s}const Qe=vn()((e,t)=>({drafts:{},setText:(n,s)=>{Rt();const r=t().drafts[n]??zn,i=typeof s=="function"?s(r.text):s;if(i===r.text)return;const l=mn(t().drafts,n,{text:i,chips:r.chips,refs:r.refs,sessionRefs:r.sessionRefs,quote:r.quote,model:r.model});e({drafts:l}),l[n]===void 0?Rn(n):sn(n),nn()},setChips:(n,s)=>{Rt();const r=t().drafts[n]??zn,i=mn(t().drafts,n,{text:r.text,chips:s,refs:r.refs,sessionRefs:r.sessionRefs,quote:r.quote,model:r.model});e({drafts:i}),i[n]===void 0?Rn(n):sn(n),nn()},setRefs:(n,s)=>{Rt();const r=t().drafts[n]??zn,i=s.slice(0,yi),l=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:i,sessionRefs:r.sessionRefs,quote:r.quote,model:r.model});e({drafts:l}),l[n]===void 0?Rn(n):sn(n),nn()},addRef:(n,s)=>{Rt();const r=t().drafts[n]??zn;if(r.refs.length>=yi)return!1;const i=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:[...r.refs,s],sessionRefs:r.sessionRefs,quote:r.quote,model:r.model});return e({drafts:i}),sn(n),nn(),!0},removeRef:(n,s)=>{Rt();const r=t().drafts[n];if(r===void 0)return;const i=r.refs.filter((c,d)=>d!==s);if(i.length===r.refs.length)return;const l=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:i,sessionRefs:r.sessionRefs,quote:r.quote,model:r.model});e({drafts:l}),l[n]===void 0?Rn(n):sn(n),nn()},updateRef:(n,s,r)=>{Rt();const i=t().drafts[n];if(i===void 0)return!1;const l=i.refs[s];if(l===void 0)return!1;if(r.inline===void 0)return!0;const c={...l};if(r.inline===!0?c.inline=!0:delete c.inline,c.inline===l.inline)return!0;const d=i.refs.map((f,h)=>h===s?c:f),m=mn(t().drafts,n,{text:i.text,chips:i.chips,refs:d,sessionRefs:i.sessionRefs,quote:i.quote,model:i.model});return e({drafts:m}),sn(n),nn(),!0},setSessionRefs:(n,s)=>{Rt();const r=t().drafts[n]??zn,i=s.slice(0,xi),l=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:r.refs,sessionRefs:i,quote:r.quote,model:r.model});e({drafts:l}),l[n]===void 0?Rn(n):sn(n),nn()},addSessionRef:(n,s)=>{Rt();const r=t().drafts[n]??zn;if(r.sessionRefs.length>=xi||r.sessionRefs.some(l=>l.sessionId===s.sessionId))return!1;const i=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:r.refs,sessionRefs:[...r.sessionRefs,s],quote:r.quote,model:r.model});return e({drafts:i}),sn(n),nn(),!0},removeSessionRef:(n,s)=>{Rt();const r=t().drafts[n];if(r===void 0)return;const i=r.sessionRefs.filter((c,d)=>d!==s);if(i.length===r.sessionRefs.length)return;const l=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:r.refs,sessionRefs:i,quote:r.quote,model:r.model});e({drafts:l}),l[n]===void 0?Rn(n):sn(n),nn()},setQuote:(n,s)=>{Rt();const r=t().drafts[n]??zn;if(r.quote===s||r.quote!==void 0&&s!==void 0&&r.quote.messageId===s.messageId&&r.quote.snippet===s.snippet&&r.quote.source===s.source)return;const i=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:r.refs,sessionRefs:r.sessionRefs,quote:s,model:r.model});e({drafts:i}),i[n]===void 0?Rn(n):sn(n),nn()},setModel:(n,s)=>{Rt();const r=t().drafts[n]??zn;if(r.model===s)return;const i=mn(t().drafts,n,{text:r.text,chips:r.chips,refs:r.refs,sessionRefs:r.sessionRefs,quote:r.quote,model:s});e({drafts:i}),i[n]===void 0?Rn(n):sn(n),nn()},clear:n=>{if(Rt(),t().drafts[n]===void 0)return;const s={...t().drafts};delete s[n],e({drafts:s}),Rn(n),nn()}}));function kg(e){return Rt(),Qe(t=>t.drafts[e]?.text??"")}function b_(e){return Rt(),Qe(t=>t.drafts[e]?.chips??vg)}const $l=Object.freeze([]);function Sg(e){return Rt(),Qe(t=>t.drafts[e]?.refs??$l)}const v_=yi,Fl=Object.freeze([]);function y_(e){return Rt(),Qe(t=>t.drafts[e]?.sessionRefs??Fl)}const x_=xi;function w_(e){return Rt(),Qe(t=>t.drafts[e]?.quote)}function k_(e){return Rt(),Qe(t=>t.drafts[e]?.model)}function S_(e){Rt();const{drafts:t,setText:n,setRefs:s,setSessionRefs:r,clear:i}=Qe.getState(),l=t[Dl],c=l?.text??"";if(c.length===0)return;const d=Ut(e);if((t[d]?.text??"").length>0)return;n(d,c);const m=l?.refs??$l;m.length>0&&(t[d]?.refs??$l).length===0&&s(d,m);const f=l?.sessionRefs??Fl;f.length>0&&(t[d]?.sessionRefs??Fl).length===0&&r(d,f);const h=l?.quote;h!==void 0&&t[d]?.quote===void 0&&Qe.getState().setQuote(d,h),i(Dl)}function jg(e){return e.startsWith("#")?e.slice(1):e}function Wa(e){if(e!==void 0)try{return decodeURIComponent(e)}catch{return e}}function Si(e){const[t="",n=""]=jg(e).split("?",2),s=t.split("/").filter(Boolean);if(s[0]!=="agents"||s.length<3)return;const r=Wa(s[1]),i=Wa(s[2]);if(!r||!i)return;const l=Wa(new URLSearchParams(n).get("body")??void 0);return{nodeKey:r,agentId:i,mode:s[3]==="edit"?"edit":"detail",...l?{bodyId:l}:{}}}function oo(e,t){return`#/agents/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function _g(e,t){return`${oo(e,t)}/edit`}function Jc(e,t,n){return`${oo(e,t)}?${new URLSearchParams({body:n}).toString()}`}function j_(e){return e.bodyId?Jc(e.nodeKey,e.agentId,e.bodyId):e.mode==="edit"?_g(e.nodeKey,e.agentId):oo(e.nodeKey,e.agentId)}function __(e){const[,t=""]=jg(e).split("?",2),n=new URLSearchParams(t);n.delete("body");const s=n.toString();return s?`#/agents?${s}`:"#/agents"}function Ua(e,t){const n=t.startsWith("?")?t.slice(1):t;return n===""?e:`${e}${e.includes("?")?"&":"?"}${n}`}function wr(e){const t=e.name?.trim();return t&&t.length>0?t:a("entity.unnamed")}function N_(e,t){const n=t.trim().toLowerCase();return n===""?!0:[e.member.name??"",e.member.agent_id].some(s=>s.toLowerCase().includes(n))}function C_(e,t){return e.filter(n=>N_(n,t))}function T_(){const[e,t]=u.useState(()=>Si(window.location.hash));u.useEffect(()=>{const s=()=>t(Si(window.location.hash));return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]);const n=Yt(s=>s.roster);return u.useMemo(()=>{if(!e)return;const s=i_(Se(n)??[],e.nodeKey,e.agentId);return{target:e,name:s?wr(s.member):e.agentId}},[e,n])}const hm=/^[a-zA-Z]$/,E_=/[\s._-]+/;function pm(e){const t=Array.from(e)[0];return t===void 0?"?":Array.from(t.toUpperCase())[0]??t}function I_(e,t){const n=(e??"").trim()||(t??"").trim();if(n==="")return null;const s=Array.from(n)[0];if(s===void 0)return null;if(!hm.test(s))return pm(n);const i=n.split(E_).filter(l=>l!=="")[1];if(i!==void 0){const l=Array.from(i)[0];if(l!==void 0&&hm.test(l))return`${s}${l}`.toUpperCase()}return pm(n)}const _o="135deg";function No(e,t){return`color-mix(in srgb, var(${e}) ${t}%, var(--ink))`}const gm=[{id:"accent",solid:"var(--accent)",backgroundImage:`linear-gradient(${_o}, var(--accent), ${No("--accent",70)})`},{id:"accent-deep",solid:"var(--accent-ink)",backgroundImage:`linear-gradient(${_o}, var(--accent-ink), ${No("--accent-ink",45)})`},{id:"amber",solid:"var(--amber)",backgroundImage:`linear-gradient(${_o}, var(--amber), ${No("--amber",70)})`},{id:"amber-deep",solid:"var(--amber-ink)",backgroundImage:`linear-gradient(${_o}, var(--amber-ink), ${No("--amber-ink",50)})`},{id:"coral",solid:"var(--danger)",backgroundImage:`linear-gradient(${_o}, var(--danger), ${No("--danger",65)})`}];function R_(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function L_(e,t){const n=(e??"").trim();if(n!=="")return n;const s=(t??"").trim();return s!==""?s:null}function A_(e,t){const n=L_(e,t);return n===null?null:gm[R_(n)%gm.length]??null}const bm="/auth/avatar";function M_(e){const t=(e??"").trim();if(t===""||t.startsWith("//"))return null;const n=/^([a-z][a-z0-9+.-]*):/i.exec(t);if(n===null)return t;const s=(n[1]??"").toLowerCase();return s==="http"||s==="https"?t:null}function P_({avatarUrl:e,endpoint:t}){const n=[],s=M_(e);return s!==null&&n.push(s),t&&!n.includes(bm)&&n.push(bm),n}const q_={trigger:"size-9",identity:"size-10"},O_={trigger:"text-sm",identity:"text-base"},D_={trigger:18,identity:20},vm=new Set;function H_({size:e}){return o.jsxs("svg",{viewBox:"0 0 16 16",width:e,height:e,className:"flex-none",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:[o.jsx("circle",{cx:"8",cy:"5.5",r:"2.75"}),o.jsx("path",{d:"M2.75 14c0-2.9 2.35-4.75 5.25-4.75s5.25 1.85 5.25 4.75"})]})}function Ng({name:e,id:t=null,avatarUrl:n=null,endpoint:s=!1,size:r="trigger"}){const i=I_(e,t),l=A_(t,e),c=P_({avatarUrl:n,endpoint:s}),d=(e??"").trim()||(t??"").trim(),m=`${t??""}\0${e??""}`,[f,h]=u.useState(m),[p,g]=u.useState(vm),[b,x]=u.useState(null);f!==m&&(h(m),g(vm),x(null));const v=(b!==null&&c.includes(b)&&!p.has(b)?b:null)??c.find(_=>!p.has(_))??null,j=v!==null&&b===v;return o.jsxs("span",{className:be("relative inline-flex flex-none items-center justify-center overflow-hidden rounded-full font-mono font-medium select-none",q_[r],l===null?"bg-sunken text-muted":"text-surface"),style:l===null?void 0:{backgroundColor:l.solid,backgroundImage:l.backgroundImage},"aria-hidden":"true",children:[i===null?o.jsx(H_,{size:D_[r]}):o.jsx("span",{className:O_[r],children:i}),v!==null&&o.jsx("img",{src:v,alt:d,referrerPolicy:"no-referrer",decoding:"async",className:be("absolute inset-0 size-full object-cover transition-opacity duration-[var(--motion-base)] ease-[var(--ease)]",j?"opacity-100":"opacity-0"),onLoad:()=>{x(v)},onError:()=>{g(_=>{const S=new Set(_);return S.add(v),S})}},v)]})}const $_={up:"accent",connecting:"amber",down:"danger",unknown:"muted"},Bl={up:"account.node.state.up",connecting:"account.node.state.connecting",down:"account.node.state.down",unknown:"account.node.state.unknown"},Pr="flex w-full items-center gap-2 rounded-md bg-transparent px-2.5 py-2 text-left text-sm text-ink transition-colors duration-150 hover:bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-raised pointer-coarse:min-h-touch",ym="px-2.5 font-mono text-2xs uppercase tracking-widest text-faint select-none";function xm({state:e}){return o.jsx("span",{className:"size-1.5 flex-none rounded-full bg-faint data-[tone=accent]:bg-accent data-[tone=amber]:bg-amber data-[tone=amber]:pulse-soft data-[tone=danger]:bg-danger","data-tone":$_[e],role:"img","aria-label":a(Bl[e])})}function F_({panelId:e,panelRef:t,position:n,identity:s,signedIn:r,authVisible:i,strategies:l,currentNode:c,nodes:d,onSelectNode:m,onLogin:f,onSignOut:h,onSettings:p}){const g=d.filter(x=>x.id!==c?.id),b=s.name!==""?s.name:a("account.anonymous");return o.jsxs("div",{ref:t,id:e,role:"dialog","aria-label":a("account.panel"),tabIndex:-1,className:"fixed z-tooltip flex w-72 max-w-[calc(100vw-1rem)] flex-col gap-3 overflow-y-auto overscroll-contain rounded-lg bg-raised p-2 shadow-elev-3 modal-rise",style:{right:n.right,top:n.top,bottom:n.bottom,maxHeight:n.maxHeight},children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 px-2.5 py-1",children:[o.jsx(Ng,{name:s.name,id:s.id,avatarUrl:s.avatarUrl,endpoint:r,size:"identity"}),o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[o.jsx("span",{className:"truncate text-sm font-medium text-ink",children:b}),s.id!==null&&o.jsx("span",{className:"truncate font-mono text-2xs text-faint",children:s.id})]})]}),(s.role!==null||s.team!==null)&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1 px-2.5",children:[s.role!==null&&o.jsx(Re,{tone:"neutral",children:a("account.role",{role:s.role})}),s.team!==null&&o.jsx(Re,{tone:"neutral",children:a("account.team",{team:s.team})})]})]}),o.jsxs("section",{className:"flex flex-col gap-0.5","aria-label":a("account.node.title"),children:[o.jsx("h3",{className:ym,children:a("account.node.title")}),c===null?o.jsx("p",{className:"px-2.5 py-1 text-sm text-muted",children:a("account.node.none")}):o.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2.5 py-1.5",children:[o.jsx(xm,{state:c.state}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-ink",children:c.name}),o.jsx("span",{className:"flex-none text-xs text-muted",children:a(Bl[c.state])})]}),g.length>0&&o.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0","aria-label":a("account.node.switch"),children:g.map(x=>o.jsx("li",{className:"flex",children:o.jsxs("button",{type:"button",className:Pr,onClick:()=>{m(x.id)},children:[o.jsx(xm,{state:x.state}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:x.name}),o.jsx("span",{className:"flex-none text-xs text-muted",children:a(Bl[x.state])})]})},x.id))})]}),i&&o.jsxs("section",{className:"flex flex-col gap-0.5","aria-label":a("account.auth.title"),children:[o.jsx("h3",{className:ym,children:a(r?"account.auth.relogin":"account.auth.title")}),l!==null&&(l.length===0?o.jsx("p",{className:"px-2.5 py-1 text-sm text-muted",children:a("account.auth.empty")}):l.map(x=>o.jsxs("button",{type:"button",className:Pr,onClick:()=>{f(x)},children:[o.jsx("span",{className:"min-w-0 flex-1 truncate",children:x.label}),x.startPath===null&&o.jsx("span",{className:"flex-none text-2xs text-faint",children:a("account.auth.signOutFirst")})]},x.id)))]}),o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("button",{type:"button",className:Pr,onClick:p,children:o.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("account.settings")})}),r&&o.jsx("button",{type:"button",className:be(Pr,"text-danger hover:bg-danger-soft"),onClick:h,children:o.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("auth.logout")})})]})]})}const B_="auth.whoami";function Cs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function _t(e){if(typeof e!="string")return null;const t=e.trim();return t===""?null:t}function K_(e){switch(_t(e)?.toLowerCase()){case"up":case"online":case"connected":case"healthy":return"up";case"down":case"offline":case"unreachable":case"error":return"down";default:return"unknown"}}function W_(e){const t=Cs(e);if(t===null)return null;const n=_t(t.id)??_t(t.user_id)??_t(t.userId);return n===null?null:{id:n,name:_t(t.name)??_t(t.username)??_t(t.display_name)??n,role:_t(t.role),avatarUrl:_t(t.avatar_url)??_t(t.avatarUrl)}}function U_(e){const t=Cs(e);if(t===null)return null;const n=_t(t.id)??_t(t.node_id);return n===null?null:{id:n,name:_t(t.name)??n,state:K_(t.state)}}function z_(e){const t=Cs(e);if(t===null)return null;const n=_t(t.id),s=_t(t.name);return n===null||s===null?null:{id:n,name:s}}function V_(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const s of e){const r=Cs(s);if(r===null)continue;const i=_t(r.id);i===null||t.has(i)||(t.add(i),n.push({id:i,label:_t(r.label)??i,kind:_t(r.kind)?.toLowerCase()??"unknown"}))}return n}function wm(e){const t=_t(e)?.toLowerCase();return t==="cookie"||t==="bearer"||t==="none"?t:null}function G_(e){const t=Cs(e);if(t===null)return null;const n=W_(t.identity);return n===null?null:{identity:n,node:U_(t.node),team:z_(t.team),backends:V_(t.backends),authMode:wm(t.auth_mode)??wm(t.authMode)}}function Y_(e){const t=Cs(e),n=t===null?null:_t(t.code);if(n!==null)return n.toLowerCase();const s=e instanceof Error?e.message:"";return/^([a-z_]+):/.exec(s)?.[1]??null}function J_(e){const t=Cs(e);return typeof t?.status=="number"?t.status:null}function Q_(e){const t=Y_(e);if(t==="not_found"||t==="method_not_found"||t==="method_not_allowed"||t==="unsupported_method")return!0;const n=J_(e);if(n===404||n===405)return!0;const s=e instanceof Error?e.message.toLowerCase():"";return s.startsWith("not_found")||s.includes("method not found")}async function X_(e){try{const t=G_(await e(B_));return t===null?{kind:"degraded",failure:"invalid"}:{kind:"ok",summary:t}}catch(t){return{kind:"degraded",failure:Q_(t)?"missing":"unreachable"}}}const Cg="/login";function Z_(e,t){return e.map(n=>{const r=(t.find(l=>l.id===n.id)??t.find(l=>l.kind===n.kind)??null)?.startPath??null,i=n.kind==="password"||r===null||r===Cg?null:r;return{id:n.id,label:n.label,kind:n.kind,startPath:i}})}function eN(e,t){const n=(t??"").trim();return n===""?null:{id:"primary",label:e,kind:"unknown",startPath:n===Cg?null:n}}async function tN(){try{return(await Ip()).loginBackends.map(t=>({id:t.id,kind:t.kind,label:t.label,startPath:t.startPath}))}catch{return[]}}function nN(e){const{client:t,hasToken:n}=Ae(),[s,r]=u.useState("idle"),[i,l]=u.useState(null),[c,d]=u.useState(null),[m,f]=u.useState([]),[h,p]=u.useState(0),g=u.useRef(!1),b=u.useRef(0);u.useEffect(()=>{if(!e||g.current)return;g.current=!0;const y=b.current+1;b.current=y,r("loading"),(async()=>{const v=n?await X_((_,S)=>t.rpc(_,S)):{kind:"degraded",failure:"unreachable"};if(b.current!==y)return;if(v.kind==="degraded"){l(v.failure),d(null),f([]),r("degraded");return}const j=v.summary.backends.length===0?[]:await tN();b.current===y&&(l(null),d(v.summary),f(Z_(v.summary.backends,j)),r("ok"))})()},[e,n,t,h]),u.useEffect(()=>()=>{b.current+=1},[]);const x=u.useCallback(()=>{g.current=!1,p(y=>y+1)},[]);return{status:s,failure:i,summary:c,strategies:m,retry:x}}const sN='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',qr=8,Or=6,oN=240;function rN({open:e,onClose:t}){const n=u.useRef(null),s=u.useRef(null),[r,i]=u.useState(null),l=u.useRef(t);l.current=t,u.useLayoutEffect(()=>{if(!e){i(null);return}const m=()=>{const f=n.current;if(!f)return;const h=f.getBoundingClientRect(),p=window.innerWidth,g=window.innerHeight,b=g-h.bottom-Or-qr,x=h.top-Or-qr,y=b<oN&&x>b,v=Math.max(120,y?x:b);i({right:Math.max(qr,p-h.right),...y?{bottom:g-h.top+Or}:{top:h.bottom+Or},maxHeight:Math.min(v,g-qr*2)})};return m(),window.setTimeout(m,0),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[e]);const c=u.useCallback(()=>s.current?[...s.current.querySelectorAll(sN)].filter(m=>m.offsetParent!==null||m===document.activeElement):[],[]),d=r!==null;return u.useEffect(()=>{if(!e||!d)return;c()[0]?.focus();const m=h=>{const p=h.target;p instanceof Node&&(s.current?.contains(p)||n.current?.contains(p)||l.current())},f=h=>{if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),l.current();return}const p=c();if(p.length===0)return;const g=p[0],b=p[p.length-1],x=document.activeElement;if(h.key==="Tab"){if(g===void 0||b===void 0)return;h.shiftKey&&(x===g||!s.current?.contains(x))?(h.preventDefault(),b.focus()):!h.shiftKey&&x===b&&(h.preventDefault(),g.focus());return}if(h.key!=="ArrowDown"&&h.key!=="ArrowUp")return;h.preventDefault();const y=p.indexOf(x),v=h.key==="ArrowDown"?1:-1,j=y===-1?0:(y+v+p.length)%p.length;p[j]?.focus()};return document.addEventListener("mousedown",m),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",f),n.current?.focus()}},[e,d,c]),{triggerRef:n,panelRef:s,position:r}}function iN(e){switch(e){case"open":return"up";case"connecting":case"reconnecting":return"connecting";case"closed":case"error":return"down";default:return"unknown"}}function aN({navigate:e}){const{phase:t,authEnabled:n,user:s,loginLabel:r,startPath:i,logout:l}=ng(),{mode:c,connectionState:d,selectPlatformNode:m}=Ae(),{nodes:f}=ut(),[h,p]=u.useState(!1),g=u.useCallback(()=>p(!1),[]),b=nN(h),{triggerRef:x,panelRef:y,position:v}=rN({open:h,onClose:g}),j=u.useId(),_=t==="authenticated"&&s!==null,S=n||_,w=u.useMemo(()=>{const A=b.summary;if(A!==null)return{name:A.identity.name,id:A.identity.id,role:A.identity.role,team:A.team?.name??null,avatarUrl:A.identity.avatarUrl};const D=(s?.username??"").trim();return{name:D!==""?D:s?.id??"",id:s?.id??null,role:null,team:null,avatarUrl:null}},[b.summary,s]),k=u.useMemo(()=>{if(b.status==="ok")return b.strategies;if(b.status==="idle"||b.status==="loading")return null;const A=eN(r,i);return A===null?[]:[A]},[b.status,b.strategies,r,i]),N=u.useMemo(()=>{const A=f.find(O=>O.current)??null;if(A!==null)return{id:A.nodeId??A.name,name:A.name,state:iN(d)};const D=b.summary?.node??null;return D!==null?{id:D.id,name:D.name,state:D.state}:null},[f,d,b.summary]),T=u.useMemo(()=>c!=="platform"?[]:f.map(A=>({id:A.nodeId??A.name,name:A.name,state:A.status??"unknown"})),[c,f]),R=u.useCallback(A=>{if(g(),A.startPath!==null){window.location.assign(A.startPath);return}l()},[g,l]),E=u.useCallback(()=>{g(),l()},[g,l]),I=u.useCallback(()=>{g(),e({domain:"settings"})},[g,e]),$=u.useCallback(A=>{g(),m(A)},[g,m]),C=w.name!==""?w.name:null,L=_?a("account.trigger.signedIn",{user:C??a("account.anonymous")}):a("account.trigger.anonymous");return o.jsxs(o.Fragment,{children:[o.jsx(xt,{label:L,children:o.jsx("button",{ref:x,type:"button",className:"inline-flex size-9 flex-none items-center justify-center rounded-full bg-transparent text-base transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface focus-visible:outline-none pointer-coarse:size-touch","aria-label":L,"aria-haspopup":"dialog","aria-expanded":h,"aria-controls":h?j:void 0,onClick:()=>{p(A=>!A)},children:o.jsx(Ng,{name:w.name,id:w.id,avatarUrl:w.avatarUrl,endpoint:_})})}),h&&v!==null?fr.createPortal(o.jsx(F_,{panelId:j,panelRef:y,position:v,identity:w,signedIn:_,authVisible:S,strategies:k,currentNode:N,nodes:T,onSelectNode:$,onLogin:R,onSignOut:E,onSettings:I}),document.body):null]})}function lN({segments:e,navigate:t}){return o.jsx(o.Fragment,{children:e.map((n,s)=>o.jsxs(u.Fragment,{children:[s>0&&o.jsx("span",{"aria-hidden":"true",className:"mx-1.5 text-faint",children:"›"}),o.jsx("button",{type:"button",className:"cursor-pointer bg-transparent p-0 text-muted underline-offset-4 hover:text-ink hover:underline focus-visible:text-ink focus-visible:underline","aria-current":s===e.length-1?"page":void 0,onClick:()=>{n.route?t(n.route):n.hash&&(window.location.hash=n.hash)},children:n.label})]},`${n.label}:${n.route?Fn(n.route):n.hash??""}`))})}function cN(e){return e==="zh-CN"?"en":"zh-CN"}function dN(){const e=He(),t=cN(e),n=a(t==="en"?"appearance.language.en":"appearance.language.zh"),s=a("language.toggleTo",{language:n}),r=a(t==="en"?"language.short.en":"language.short.zh");return o.jsx(G,{className:"min-w-10 flex-none rounded-full font-mono text-xs tracking-wide pointer-coarse:min-h-touch",size:"small","aria-label":s,title:s,onClick:()=>jc(t),children:r})}const uN=[{id:"chat"},{id:"pending"},{id:"agents"},{id:"teams"},{id:"kanban"},{id:"nodes"},{id:"runs"},{id:"tools"},{id:"mcp"},{id:"channels"},{id:"hub"},{id:"gateway"},{id:"pluginHost"},{id:"capabilities"},{id:"settings"},{id:"visual"},{id:"designLab"}],za=[{id:"chat",domains:["chat","teams"]},{id:"items",domains:["pending","kanban"]},{id:"network",domains:["agents","nodes"]},{id:"runs",domains:["runs"]},{id:"integrations",domains:["capabilities","tools","mcp","channels"]},{id:"core",domains:["hub","gateway","pluginHost"]}];function Wt(e){switch(e){case"chat":return{domain:"chat"};case"pending":return{domain:"pending"};case"hub":return{domain:"hub"};case"gateway":return{domain:"gateway"};case"pluginHost":return{domain:"pluginHost"};case"nodes":return{domain:"nodes"};case"teams":return{domain:"teams"};case"kanban":return{domain:"kanban"};case"agents":return{domain:"agents"};case"runs":return{domain:"runs",tab:"live"};case"tools":return{domain:"tools"};case"mcp":return{domain:"mcp"};case"channels":return{domain:"channels"};case"capabilities":return{domain:"capabilities"};case"visual":return{domain:"settings",category:"visual"};case"designLab":return{domain:"designLab"};case"settings":return{domain:"settings"};case"observe":return{domain:"observe",tab:"metrics"}}}function Ht(e){return a(`nav.domain.${e}`)}function Va(e){return a(`nav.group.${e}`)}function Tg(e,t){return e.domain===t}function Eg(e,t){switch(e.domain){case"chat":return e.sessionId?[{label:a("breadcrumb.chat"),route:{domain:"chat"}},{label:a("breadcrumb.chat.conversation"),route:e}]:[{label:a("breadcrumb.chat"),route:e}];case"pending":return[{label:a("breadcrumb.pending"),route:e}];case"runs":{const n={domain:"runs",tab:e.tab},s=e.tab==="durable"?a("breadcrumb.runs.durable"):a("breadcrumb.runs.live"),r=[{label:a("breadcrumb.runs"),route:n},{label:s,route:e.runId?n:e}];return e.runId&&r.push({label:a("breadcrumb.runs.details"),route:e}),r}case"hub":return[{label:a("breadcrumb.hub"),route:e}];case"gateway":return[{label:a("breadcrumb.gateway"),route:e}];case"pluginHost":return[{label:a("breadcrumb.pluginHost"),route:e}];case"nodes":return e.nodeKey?[{label:a("breadcrumb.nodes"),route:{domain:"nodes"}},{label:t?.get(e.nodeKey)??e.nodeKey,route:e}]:[{label:a("breadcrumb.nodes"),route:e}];case"teams":return"teamId"in e?[{label:a("breadcrumb.teams"),route:{domain:"teams"}},{label:e.agentId?a("breadcrumb.teams.agent"):e.teamId,route:e}]:[{label:a("breadcrumb.teams"),route:e}];case"agents":return[{label:a("breadcrumb.agents"),route:e}];case"tools":return[{label:a("breadcrumb.tools"),route:e}];case"mcp":return[{label:a("breadcrumb.mcp"),route:e}];case"channels":return[{label:a("breadcrumb.channels"),route:e}];case"kanban":return[{label:a("breadcrumb.kanban"),route:e}];case"observe":return[{label:a("breadcrumb.observe"),route:{domain:"observe",tab:"metrics"}},{label:a(`breadcrumb.observe.${e.tab}`),route:e}];case"plugins":return[{label:a("breadcrumb.plugins"),route:e}];case"capabilities":return[{label:a("breadcrumb.capabilities"),route:e}];case"designLab":return[{label:a("breadcrumb.designLab"),route:e}];case"settings":return[{label:a("breadcrumb.settings"),route:e}]}}function km(e,t){return Eg(e,t).map(n=>n.label).join(" › ")}function mN({route:e,onOpenPalette:t,onToggleSessions:n,sessionsOpen:s=!1,onToggleNav:r,navOpen:i=!1,navigate:l,center:c}){He();const d=Bt(),m=T_(),f=m?[{label:a("breadcrumb.agents"),hash:__(window.location.hash)},{label:m.name,hash:j_(m.target)}]:Eg(e,d),h=n?{id:"sessions-toggle",controls:"chat-sessions",label:a(s?"nav.closeSessions":"nav.openSessions"),open:s,onClick:n}:r?{id:"nav-toggle",controls:"domain-nav",label:a(i?"nav.closeNav":"nav.openNav"),open:i,onClick:r}:null;return o.jsxs("header",{className:"flex h-[var(--appbar-h)] flex-none items-center gap-3 bg-surface px-5 max-compact:gap-2 max-compact:px-3",children:[h&&o.jsx(xt,{label:h.label,children:o.jsx("button",{id:h.id,type:"button",className:"hidden size-9 flex-none items-center justify-center rounded-full bg-transparent text-base text-muted transition-colors duration-150 hover:bg-hover max-wide:inline-flex pointer-coarse:size-touch","aria-label":h.label,"aria-expanded":h.open,"aria-controls":h.controls,onClick:h.onClick,children:o.jsx("span",{"aria-hidden":"true",children:"☰"})})}),o.jsx("img",{src:"/Vessel.svg",alt:"","aria-hidden":"true",className:"h-6 w-auto flex-none max-compact:h-5"}),o.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-serif text-xl font-semibold text-ink","aria-live":"polite",children:o.jsx(lN,{segments:f,navigate:l})}),o.jsx("div",{className:"flex min-w-0 flex-1 justify-center px-2 max-compact:px-1",children:c}),o.jsx(dN,{}),o.jsx(xt,{label:"Ctrl/Cmd+K",children:o.jsxs("button",{type:"button",className:"inline-flex min-w-45 items-center gap-2 rounded-full bg-sunken py-1.5 pl-3 pr-2 text-sm text-muted transition-colors duration-150 hover:bg-hover hover:text-ink max-compact:min-w-0 max-compact:px-2.5 pointer-coarse:min-h-touch",onClick:t,"aria-keyshortcuts":"Control+K Meta+K",children:[o.jsx("span",{className:"font-mono text-md","aria-hidden":"true",children:"⌕"}),o.jsx("span",{className:"flex-1 text-left max-compact:hidden",children:a("nav.searchOrCommand")}),o.jsx("kbd",{className:"kbd max-compact:hidden",children:"⌘K"})]})}),o.jsx(xt,{label:`${a("nav.settings")} (Ctrl+,)`,children:o.jsx("button",{type:"button",className:"inline-flex size-9 flex-none items-center justify-center rounded-full bg-transparent text-base text-muted transition-colors duration-150 hover:bg-hover hover:text-ink pointer-coarse:size-touch","aria-label":a("nav.settings"),"aria-keyshortcuts":"Control+, Meta+,",onClick:()=>l({domain:"settings"}),children:o.jsx("span",{"aria-hidden":"true",children:"⚙"})})}),o.jsx(aN,{navigate:l})]})}function Ot({domain:e}){const t={width:18,height:18,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false"};switch(e){case"chat":return o.jsx("svg",{...t,children:o.jsx("path",{d:"M3.5 4.5h13v9h-7l-4 3v-3h-2z"})});case"pending":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M3.2 11.5 5.6 4.5h8.8l2.4 7v4H3.2z"}),o.jsx("path",{d:"M3.2 11.5h3.6l.9 1.8h4.6l.9-1.8h3.6"})]});case"hub":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),o.jsx("circle",{cx:"10",cy:"10",r:"5.2"}),o.jsx("circle",{cx:"10",cy:"10",r:"8"})]});case"gateway":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"10",cy:"10",r:"3"}),o.jsx("path",{d:"M10 2.5v4.5M10 13v4.5M2.5 10H7M13 10h4.5"})]});case"nodes":return o.jsxs("svg",{...t,children:[o.jsx("rect",{x:"4",y:"3.5",width:"12",height:"5",rx:"1"}),o.jsx("rect",{x:"4",y:"11.5",width:"12",height:"5",rx:"1"}),o.jsx("path",{d:"M6.8 6h.01M6.8 14h.01"})]});case"teams":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"7.5",cy:"7",r:"2.6"}),o.jsx("path",{d:"M3.2 16.2c0-2.4 1.9-4.2 4.3-4.2s4.3 1.8 4.3 4.2"}),o.jsx("circle",{cx:"14.2",cy:"8",r:"1.9"}),o.jsx("path",{d:"M12.8 12.5c1.9.3 3.3 1.8 3.3 3.7"})]});case"agents":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"10",cy:"7",r:"2.8"}),o.jsx("path",{d:"M4.5 16.2c0-3 2.5-5.4 5.5-5.4s5.5 2.4 5.5 5.4"})]});case"runs":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"10",cy:"10",r:"6.5"}),o.jsx("path",{d:"M9 7.4 12.6 10 9 12.6z",fill:"currentColor",stroke:"none"})]});case"tools":return o.jsx("svg",{...t,children:o.jsx("path",{d:"M12.2 3.2a3.8 3.8 0 0 0-4.9 4.9L3.6 11.8a1.6 1.6 0 0 0 2.2 2.2l3.7-3.7a3.8 3.8 0 0 0 4.9-4.9l-2 2-1.9-.5-.5-1.9z"})});case"mcp":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"5",cy:"10",r:"2.2"}),o.jsx("circle",{cx:"15",cy:"5.5",r:"2.2"}),o.jsx("circle",{cx:"15",cy:"14.5",r:"2.2"}),o.jsx("path",{d:"M7.1 9.2 12.9 6.3M7.1 10.8l5.8 2.9"})]});case"channels":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M3.5 6.5h4l9 3.5-9 3.5h-4z"}),o.jsx("path",{d:"M6.5 13.5v3l3-2"})]});case"pluginHost":return o.jsxs("svg",{...t,children:[o.jsx("rect",{x:"3.5",y:"4.5",width:"13",height:"11",rx:"1.2"}),o.jsx("path",{d:"M3.5 10h13"}),o.jsx("path",{d:"M6 7.2h3M6 12.8h3"}),o.jsx("path",{d:"M13.5 7.2h.01M13.5 12.8h.01"})]});case"capabilities":return o.jsx("svg",{...t,children:o.jsx("path",{d:"M11 2.5 4.5 11h4.5l-1 6.5 6.5-8.5h-4.5z"})});case"visual":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M2.8 10C4.6 6.8 7 5.2 10 5.2s5.4 1.6 7.2 4.8c-1.8 3.2-4.2 4.8-7.2 4.8S4.6 13.2 2.8 10Z"}),o.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]});case"designLab":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M10 3.2a6.8 6.8 0 1 0 0 13.6h1.4a1.6 1.6 0 0 0 1.6-1.6c0-.5-.2-.9-.5-1.2-.3-.3-.5-.7-.5-1.1 0-.9.7-1.6 1.6-1.6h1.8a3.6 3.6 0 0 0 3.6-3.6C18.2 5.1 14.6 3.2 10 3.2Z"}),o.jsx("circle",{cx:"6.6",cy:"8.1",r:"0.9",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"9.6",cy:"5.9",r:"0.9",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"13",cy:"6.7",r:"0.9",fill:"currentColor",stroke:"none"})]});case"plugins":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M7.5 3.5h5v2.2a1.8 1.8 0 1 0 0 3.6v2.2h-5z"}),o.jsx("path",{d:"M3.5 7.5v5h2.2a1.8 1.8 0 1 1 3.6 0h2.2v-5"}),o.jsx("path",{d:"M11.5 16.5v-2.2h2.2a1.8 1.8 0 1 0 0-3.6h-2.2"})]});case"observe":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M3 16.5h14"}),o.jsx("path",{d:"M5.5 13.5V9"}),o.jsx("path",{d:"M10 13.5V5"}),o.jsx("path",{d:"M14.5 13.5V7.5"})]});case"kanban":return o.jsxs("svg",{...t,children:[o.jsx("rect",{x:"3",y:"3.5",width:"14",height:"13",rx:"1.2"}),o.jsx("path",{d:"M7.7 3.5v13M12.3 3.5v13"}),o.jsx("path",{d:"M4.8 6.5h1.4M9.3 6.5h1.4M13.8 6.5h1.4"}),o.jsx("path",{d:"M4.8 9.5h1.4M9.3 9.5h1.4"})]});case"settings":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M4 6h12"}),o.jsx("path",{d:"M4 14h12"}),o.jsx("circle",{cx:"8",cy:"6",r:"1.8",fill:"var(--surface)"}),o.jsx("circle",{cx:"13",cy:"14",r:"1.8",fill:"var(--surface)"})]})}}const fN='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';let Bo=0,Ig="";function hN(){typeof document>"u"||(Bo===0&&(Ig=document.body.style.overflow,document.body.style.overflow="hidden"),Bo+=1)}function pN(){typeof document>"u"||Bo===0||(Bo-=1,Bo===0&&(document.body.style.overflow=Ig))}function gN(e){const t=u.useRef(null),n=u.useRef(e);return n.current=e,u.useEffect(()=>{const s=document.activeElement instanceof HTMLElement?document.activeElement:null,r=t.current;hN();const i=()=>r?[...r.querySelectorAll(fN)].filter(d=>d.offsetParent!==null||d===document.activeElement):[];(r?.querySelector("[data-autofocus]")??i()[0]??r)?.focus();const c=d=>{if(d.key==="Escape"){d.preventDefault(),n.current();return}if(d.key!=="Tab")return;const m=i();if(m.length===0)return;const f=m[0],h=m[m.length-1];!f||!h||(d.shiftKey&&document.activeElement===f?(d.preventDefault(),h.focus()):!d.shiftKey&&document.activeElement===h&&(d.preventDefault(),f.focus()))};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),s?.focus(),pN()}},[]),t}const bN={sm:"max-w-modal-sm",md:"max-w-modal-md",lg:"max-w-modal-lg",xl:"max-w-modal-xl"};function tn({id:e,label:t,describedBy:n,onClose:s,closeOnBackdrop:r=!0,closeLabel:i,size:l="md",className:c="",bodyClassName:d="",children:m}){const f=gN(s),h=o.jsx("div",{className:"modal-fade fixed inset-0 z-modal flex h-dvh w-screen items-center justify-center overflow-y-auto overscroll-contain bg-scrim modal-pad",onMouseDown:p=>{r&&p.target===p.currentTarget&&s()},children:o.jsxs("div",{ref:f,id:e,className:be("modal-rise relative flex max-h-[min(86dvh,var(--modal-max-h))] w-full flex-col gap-3 overflow-hidden rounded-lg bg-raised p-5 shadow-elev-4 forced-colors:border max-compact:p-4",bN[l],c),role:"dialog","aria-modal":"true","aria-label":t,"aria-describedby":n,tabIndex:-1,children:[o.jsx("div",{className:be("flex min-h-0 flex-col gap-3 overflow-y-auto overscroll-contain p-1 -m-1",d),children:m}),i?o.jsx(Cn,{className:"absolute right-2 top-2",label:i,onClick:s,children:"×"}):null]})});return typeof document>"u"?h:fr.createPortal(h,document.body)}const Rg=["chat","hub","gateway","nodes","teams","agents","runs","tools","mcp","channels","plugins","observe","settings"],vN=[...Rg,"attach"],yN=new Set(["top","plugins","observe","settings","chat","network","runs","integrations","core","status"]),xN=new Set(Rg),wN=new Set(vN),kN=new Set(["run-detail","session-detail","nav"]),SN=new Set(["composer"]),jN=/^[a-z0-9][a-z0-9-]{0,63}$/,Sm=/^[a-z][a-z0-9_-]*$/,Kl=/^[A-Za-z_$][A-Za-z0-9_$]*$/,_N=/^[A-Za-z0-9][A-Za-z0-9_.-]*$/,Qc=new Set(["__proto__","constructor","prototype"]),NN=200,CN=200,TN=["en","zh-CN"];function Lg(e){const t=Ye(e);if(t!=="")return xN.has(t)?t:null}function EN(e){const t=Ye(e);if(t!=="")return wN.has(t)?t:null}function jm(e){if(e===null||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,r]of Object.entries(e)){if(n>=NN)break;if(!_N.test(s)||Qc.has(s)||typeof r!="string")continue;const i=r.trim();i===""||i.length>CN||(t[s]=i,n+=1)}return t}function IN(e){const t=e.contributions?.i18n;if(t===null||typeof t!="object")return;const n=jm(t.en),s=jm(t["zh-CN"]),r=Object.keys(n).length>0,i=Object.keys(s).length>0;if(!(!r&&!i))return{...r?{en:n}:{},...i?{"zh-CN":s}:{}}}function On(e,t,n,s,r,i){const l=e.get(t),c=n?.trim()??"";if(c!==""&&!Qc.has(c)){const d=TN.includes(s)?l?.[s]?.[c]:void 0;if(d)return d;const m=l?.en?.[c];if(m)return m;const f=a(c);if(f!==c)return f}return r?.trim()||i||c}function RN(e){return e.enabled}function Ye(e){return typeof e=="string"?e.trim():""}function ho(e,t=100){return typeof e=="number"&&Number.isFinite(e)?e:t}function LN(e){const t=Ye(e.entry);if(t!=="")return t;const s=(Ye(e.route).split("?",1)[0]??"").split("/").filter(Boolean).pop();return s!==void 0&&s!==""?s:"index.html"}function Xc(e){return jN.test(e)}function Ag(e){const t=e.trim();if(t===""||t.startsWith("/")||t.includes("\\")||t.includes("\0"))return null;const n=t.split("/");for(const s of n)if(s===""||s==="."||s==="..")return null;return n.map(s=>encodeURIComponent(s)).join("/")}function Mg(e){return Ec(e)||sp()}function AN(e,t,n,s){if(!Xc(t))return null;const r=Ag(n);if(r===null)return null;const i=Mg(e);if(i==="")return null;const l=new URL(Yo(i,`/plugins/${encodeURIComponent(t)}/${r}`));return s?.run&&l.searchParams.set("run",s.run),s?.session&&l.searchParams.set("session",s.session),s?.lang&&l.searchParams.set("lang",s.lang),s?.theme&&l.searchParams.set("theme",s.theme),l.toString()}function ji(e,t,n){if(!Xc(t))return null;const s=Ag(n);if(s===null)return null;const r=Mg(e);return r===""?null:Yo(r,`/plugins/${encodeURIComponent(t)}/ui/${s}`)}function MN(e){const t=`plugin:${e.name}`,s=(e.contributions?.navGroups??[]).find(c=>Ye(c.id)===t);if(!s)return null;const r=Ye(s.title)||t,i=Ye(s.titleKey),l=Lg(s.icon);return l===null?null:{pluginId:e.name,pluginName:e.name,id:t,title:r,...i!==""?{titleKey:i}:{},...l!==void 0?{icon:l}:{},order:ho(s.order)}}function PN(e,t,n){const s=Ye(t.id),r=Ye(t.title)||s;if(s===""||r==="")return null;const i=Ye(t.nav)||"top";if(!yN.has(i)&&i!==n)return null;const l=Lg(t.icon);if(l===null)return null;const c=Ye(t.titleKey),d=Ye(t.component);return{pluginId:e.name,pluginName:e.name,id:s,title:r,...c!==""?{titleKey:c}:{},nav:i,...l!==void 0?{icon:l}:{},order:ho(t.order),entry:LN(t),...d!==""&&Kl.test(d)?{component:d}:{}}}function qN(e,t){const n=Ye(t.slot),s=Ye(t.id);if(!kN.has(n)||s==="")return null;const r=Ye(t.title);return{pluginId:e.name,pluginName:e.name,slot:n,id:s,...r!==""?{title:r}:{},order:ho(t.order),entry:Ye(t.entry)||"index.html"}}function Lo(e,t){return e.order-t.order||(e.title??e.id).localeCompare(t.title??t.id)}function ON(e,t){const n=Ye(t.slot),s=Ye(t.id);if(!SN.has(n)||s==="")return null;const r=EN(t.icon);if(r===null)return null;const i=Ye(t.titleKey),l=FN(e,t.menu),c=Ye(t.action),d=c!==""&&DN.test(c)&&l===void 0?c:void 0;return{pluginId:e.name,pluginName:e.name,slot:n,id:s,label:Ye(t.label)||s,...i!==""?{titleKey:i}:{},...r!==void 0?{icon:r}:{},order:ho(t.order),...l!==void 0?{menu:l}:{},...d!==void 0?{action:d}:{}}}const DN=/^[A-Za-z_$][A-Za-z0-9_$]*$/,HN=16,$N=64;function FN(e,t){if(t===null||typeof t!="object")return;const n=Ye(t.read),s=Ye(t.write),r=Ye(t.valueKey);if(n===""||s===""||r==="")return;const i=new Map;for(const c of e.contributions?.rpc??[])if(typeof c=="string"){const d=Ye(c);d!==""&&i.set(d,"read")}else if(c!==null&&typeof c=="object"){const d=Ye(c.name);d!==""&&i.set(d,c.permission==="write"?"write":"read")}if(i.get(n)!=="read"||i.get(s)!=="write"||!Array.isArray(t.items)||t.items.length===0)return;const l=[];for(const c of t.items){if(l.length>=HN)break;if(c===null||typeof c!="object")continue;const d=Ye(c.value);if(d===""||d.length>$N)continue;const m=Ye(c.labelKey),f=Ye(c.label);l.push({value:d,...m!==""?{labelKey:m}:{},...f!==""?{label:f}:{}})}if(l.length!==0)return{read:n,write:s,valueKey:r,...t.sessionScoped===!0?{sessionScoped:!0}:{},items:l}}function BN(e,t){const n=t.slot;if(n!=="refs"&&n!=="drop"&&n!=="link")return null;const s=ho(t.order);if(n==="drop"){const l=Ye(t.handler);return l===""||!Kl.test(l)?null:{pluginId:e.name,pluginName:e.name,slot:n,handler:l,order:s}}const r=Ye(t.scheme),i=Ye(t.component);return!/^[a-z][a-z0-9-]{0,31}$/.test(r)||i===""||!Kl.test(i)?null:{pluginId:e.name,pluginName:e.name,slot:n,scheme:r,component:i,order:s}}function _m(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.enabled=="boolean"}function KN(e){if(Array.isArray(e))return e.filter(_m);if(e===null||typeof e!="object")return null;const t=e.plugins;return Array.isArray(t)?t.filter(_m):null}const WN=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/,UN=new Set(["string","number","integer","boolean","object","array"]),zN=64,VN=32,Nm=64,Wl=200,GN=16;function YN(e,t){switch(e){case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"integer":return typeof t=="number"&&Number.isInteger(t);case"boolean":return typeof t=="boolean";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);case"array":return Array.isArray(t)}}function Cm(e){return Ye(e).slice(0,Wl)}function JN(e,t,n,s,r){const i=[];for(const[l,c]of Object.entries(t)){if(i.length>=zN)break;if(!WN.test(l)||Qc.has(l)||c===null||typeof c!="object")continue;const d=Ye(c.type);if(!UN.has(d))continue;const m=d,f=On(n,e.name,Ye(c.titleKey)||void 0,s,Cm(c.title),l).slice(0,Wl)||l,h=Cm(c.description),p=Ye(c.descriptionKey);let g=h;if(p!==""){const j=On(n,e.name,p,s,h||void 0);g=j===p?h:j.slice(0,Wl)}let b;if(m==="string"&&Array.isArray(c.enum)){const j=c.enum.filter(_=>typeof _=="string").map(_=>_.trim()).filter(_=>_!==""&&_.length<=Nm).slice(0,VN);j.length>0&&(b=j)}let x;if(Array.isArray(c.keywords)){const j=c.keywords.filter(_=>typeof _=="string").map(_=>_.trim()).filter(_=>_!==""&&_.length<=Nm).slice(0,GN);j.length>0&&(x=j)}const y=(m==="number"||m==="integer")&&typeof c.minimum=="number"&&Number.isFinite(c.minimum)?c.minimum:void 0,v=(m==="number"||m==="integer")&&typeof c.maximum=="number"&&Number.isFinite(c.maximum)?c.maximum:void 0;i.push({key:l,id:`${e.name}.${l}`,type:m,title:f,...g!==""?{description:g}:{},...b!==void 0?{enum:b}:{},...YN(m,c.default)?{default:c.default}:{},...x!==void 0?{keywords:x}:{},order:ho(c.order),...y!==void 0?{minimum:y}:{},...v!==void 0?{maximum:v}:{}})}return i.length===0?null:(i.sort(Lo),{pluginId:e.name,pluginName:r,items:i})}function QN(e){const t=[],n=[],s=[],r=[],i=[],l=[],c=new Map,d=new Map,m=ss();for(const f of e){if(!RN(f)||!Xc(f.name))continue;const h=f.contributions;if(!h)continue;const p=IN(f);p!==void 0&&c.set(f.name,p);const g=MN(f);g!==null&&n.push(g);const b=h.settings;if(b!==null&&typeof b=="object"){const y=g?On(c,f.name,g.titleKey,m,g.title,f.name):f.name,v=JN(f,b,c,m,y);v!==null&&l.push(v)}for(const y of h.pages??[]){const v=PN(f,y,g?.id);v!==null&&t.push(v)}for(const y of h.panels??[]){const v=qN(f,y);v!==null&&s.push(v)}for(const y of h.toolbar??[]){const v=ON(f,y);v!==null&&r.push(v)}for(const y of h.composer??[]){const v=BN(f,y);v!==null&&i.push(v)}const x=new Set;for(const y of h.rpc??[]){const v=Ye(typeof y=="string"?y:y.name);Sm.test(v)&&x.add(v)}for(const y of h.commands??[]){const v=Ye(y.name);Sm.test(v)&&x.add(v)}x.size>0&&d.set(f.name,x)}return t.sort(Lo),n.sort(Lo),s.sort(Lo),r.sort(Lo),i.sort((f,h)=>f.order-h.order||f.pluginId.localeCompare(h.pluginId)),l.sort((f,h)=>f.pluginName.localeCompare(h.pluginName)),{pages:t,navGroups:n,panels:s,toolbar:r,composer:i,settings:l,i18nByPlugin:c,methodsByPlugin:d}}const XN=[],Pg=200;function Bn(){const{client:e,connectionState:t,hasToken:n,epoch:s,eventStore:r}=Ae(),i=He(),l=Ft({load:()=>e.listPlugins(),enabled:n&&t==="open",deps:[s]}),c=u.useRef(l.reload);c.current=l.reload;const[d,m]=u.useState(null),f=u.useRef(!1);u.useEffect(()=>{let g=r.getSnapshot().version,b;const x=r.subscribe(()=>{const y=r.getSnapshot();if(y.version===g)return;g=y.version;const v=y.entries.slice(-20);let j=!1;for(let _=v.length-1;_>=0;_-=1){const S=v[_]?.event;if(S?.type!=="plugin.changed")continue;j=!0;const w=KN(S.data);w!==null&&m(w);break}j&&(f.current=!0,window.clearTimeout(b),b=window.setTimeout(()=>c.current(),Pg))});return()=>{x(),window.clearTimeout(b)}},[r]),u.useEffect(()=>{f.current&&l.state.status==="success"&&(f.current=!1,m(null))},[l.state]);const h=d??Se(l.state)??XN,p=u.useMemo(()=>QN(h),[h,i]);return{plugins:h,...p,state:l.state,reload:l.reload}}function qg(e,t){return e.filter(n=>n.slot===t)}function Og(e,t){return e.filter(n=>n.slot===t)}const ZN=["chat","runs","tools"],Tm="flex min-h-14 flex-1 flex-col items-center justify-center gap-1 border-0 bg-transparent text-xs text-muted",Em="rounded-sm bg-accent-soft text-accent-ink";function eC({route:e,navigate:t}){He();const[n,s]=u.useState(!1),{connectionState:r,hasToken:i}=Ae(),{pages:l}=Bn(),c=e.domain==="hub"||e.domain==="gateway"||e.domain==="pluginHost"||e.domain==="nodes"||e.domain==="teams"||e.domain==="kanban"||e.domain==="agents"||e.domain==="capabilities"||e.domain==="mcp"||e.domain==="channels"||e.domain==="observe"||e.domain==="plugins"||e.domain==="designLab"||e.domain==="settings",d=a(i?r==="open"?"nav.conn.online":r==="reconnecting"?"nav.conn.reconnectingShort":r==="connecting"?"nav.conn.connectingShort":"nav.conn.closed":"nav.conn.idle");return o.jsxs(o.Fragment,{children:[o.jsxs("nav",{className:"hidden flex-none items-stretch justify-around bg-surface shadow-elev-1 [padding-bottom:env(safe-area-inset-bottom)] forced-colors:border max-compact:flex","aria-label":a("nav.bottomLabel"),children:[ZN.map(m=>{const f=Tg(e,m);return o.jsxs("button",{type:"button",className:be(Tm,f&&Em),"aria-current":f?"page":void 0,onClick:()=>t(Wt(m)),children:[o.jsx(Ot,{domain:m}),o.jsx("span",{children:Ht(m)})]},m)}),o.jsxs("button",{type:"button",className:be(Tm,c&&Em),"aria-current":c?"page":void 0,"aria-expanded":n,onClick:()=>s(!0),children:[o.jsx("span",{className:"text-lg leading-none","aria-hidden":"true",children:"⋯"}),o.jsx("span",{children:a("nav.more")})]})]}),n&&o.jsxs(tn,{label:a("nav.moreSheet"),onClose:()=>s(!1),className:"more-sheet mt-auto mb-0 max-w-modal-sm self-center rounded-t-lg rounded-b-sm max-compact:sheet-bottom-pad",children:[o.jsx("h2",{className:"modal-title",children:a("nav.more")}),o.jsxs("div",{className:"more-list",children:[o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("agents"))},children:[o.jsx(Ot,{domain:"agents"})," ",Ht("agents")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("teams"))},children:[o.jsx(Ot,{domain:"teams"})," ",Ht("teams")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("kanban"))},children:[o.jsx(Ot,{domain:"kanban"})," ",Ht("kanban")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("nodes"))},children:[o.jsx(Ot,{domain:"nodes"})," ",Ht("nodes")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("capabilities"))},children:[o.jsx(Ot,{domain:"capabilities"})," ",Ht("capabilities")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("designLab"))},children:[o.jsx(Ot,{domain:"designLab"})," ",Ht("designLab")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("mcp"))},children:[o.jsx(Ot,{domain:"mcp"})," ",Ht("mcp")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("channels"))},children:[o.jsx(Ot,{domain:"channels"})," ",Ht("channels")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("hub"))},children:[o.jsx(Ot,{domain:"hub"})," ",Ht("hub")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("gateway"))},children:[o.jsx(Ot,{domain:"gateway"})," ",Ht("gateway")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t(Wt("pluginHost"))},children:[o.jsx(Ot,{domain:"pluginHost"})," ",Ht("pluginHost")]}),l.map(m=>o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t({domain:"plugins",pluginId:m.pluginId,entry:m.entry})},children:[o.jsx(Ot,{domain:"plugins"})," ",m.title]},`${m.pluginId}:${m.id}`)),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t({domain:"observe",tab:"diagnostics"})},children:[o.jsx(Ot,{domain:"observe"})," ",a("nav.diagnostics")]}),o.jsxs("button",{type:"button",className:"more-item",onClick:()=>{s(!1),t({domain:"settings"})},children:[o.jsx(Ot,{domain:"settings"})," ",Ht("settings")]})]}),o.jsx("div",{className:"more-meta",children:o.jsx("span",{children:a("nav.connectionNamed",{value:d})})})]})]})}function Zi(){const[e,t]=u.useState(()=>window.innerWidth);return u.useEffect(()=>{const n=()=>{t(s=>s===window.innerWidth?s:window.innerWidth)};return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}const Dg="vessel.ui.layout.v1",an={nav:{min:200,max:360,default:256},sessions:{min:220,max:420,default:280},chat:{min:560,max:1200,default:860},teamList:{min:220,max:420,default:280}},_i={nav:an.nav.default,sessions:an.sessions.default,chat:an.chat.default,teamList:an.teamList.default};function Im(e,t){return e==="chat"?[["--chat-content-w",`${t}px`],["--dock-width",`${t}px`],["--chat-half-w",`${t/2}px`]]:[[e==="nav"?"--nav-w":e==="sessions"?"--sessions-w":"--team-list-w",`${t}px`]]}const tC=680,nC=48;function Ni(e,t){const n=an[e];return Number.isFinite(t)?Math.min(n.max,Math.max(n.min,t)):n.default}function sC(e,t,n){return Ni(e,t+(e==="chat"?2:1)*n)}function Hg(e,t,n){return Math.max(an.chat.min,e-t-n-nC)}function oC(e,t,n,s){return Math.min(e,an.chat.max,Hg(t,n,s))}function rC(e){let t;try{t=typeof e=="string"&&e.length>0?JSON.parse(e):null}catch{return{..._i}}if(t===null||typeof t!="object"||Array.isArray(t))return{..._i};const n=t,s=r=>{const i=n[r];return typeof i!="number"||!Number.isFinite(i)?an[r].default:Ni(r,i)};return{nav:s("nav"),sessions:s("sessions"),chat:s("chat"),teamList:s("teamList")}}function iC(e){return{"--nav-w":`${e.nav}px`,"--sessions-w":`${e.sessions}px`,"--team-list-w":`${e.teamList}px`,"--chat-content-w":`${e.chat}px`,"--dock-width":`${e.chat}px`,"--chat-half-w":`${e.chat/2}px`}}function aC(){try{return rC(localStorage.getItem(Dg))}catch{return{..._i}}}function lC(e){try{localStorage.setItem(Dg,JSON.stringify(e))}catch{}}function cC(){try{return window.matchMedia("(pointer: coarse)").matches}catch{return!1}}function dC(e){const t=Zi(),[n,s]=u.useState(aC),r=u.useRef(null),i=u.useRef(n);i.current=n;const l=u.useRef(new Map),c=u.useRef(null),d=n[e],m=t<=tC||cC(),f=u.useCallback(()=>{c.current=null;const y=r.current,v=l.current;if(y)for(const[j,_]of v)for(const[S,w]of Im(j,_))y.style.setProperty(S,w);v.clear()},[]);u.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),c.current=null,l.current.clear()},[]);const h=u.useCallback((y,v)=>{l.current.set(y,Ni(y,v)),c.current===null&&(c.current=requestAnimationFrame(f))},[f]),p=u.useCallback((y,v)=>{const j={...i.current,[y]:Ni(y,v)};i.current=j,l.current.delete(y);const _=r.current;if(_)for(const[S,w]of Im(y,j[y]))_.style.setProperty(S,w);s(j),lC(j)},[]),g=u.useCallback(y=>{p(y,an[y].default)},[p]),b=u.useCallback(y=>m?!0:y==="chat"?Hg(t,n.nav,d)<=an.chat.min:t<=an[y].min,[m,t,n.nav,d]),x=u.useMemo(()=>m?_i:{...n,chat:oC(n.chat,t,n.nav,d)},[m,t,n,d]);return u.useMemo(()=>({layout:x,shellRef:r,preview:h,commit:p,reset:g,disabled:b}),[x,h,p,g,b])}const Rm=16;function kr({pane:e,api:t,label:n,className:s=""}){const r=u.useRef(null),[i,l]=u.useState(!1),c=an[e],d=t.disabled(e),m=t.layout[e],f=b=>{d||(b.currentTarget.setPointerCapture(b.pointerId),r.current={pointerId:b.pointerId,startX:b.clientX,startValue:m,value:m},l(!0))},h=b=>{const x=r.current;if(!x||x.pointerId!==b.pointerId)return;const y=sC(e,x.startValue,b.clientX-x.startX);x.value=y,t.preview(e,y)},p=b=>{const x=r.current;!x||x.pointerId!==b.pointerId||(r.current=null,l(!1),b.currentTarget.hasPointerCapture(b.pointerId)&&b.currentTarget.releasePointerCapture(b.pointerId),t.commit(e,x.value))},g=b=>{if(d)return;let x;switch(b.key){case"ArrowLeft":x=m-Rm;break;case"ArrowRight":x=m+Rm;break;case"Home":x=c.min;break;case"End":x=c.max;break;default:return}b.preventDefault(),t.commit(e,x)};return o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":n,"aria-valuenow":m,"aria-valuemin":c.min,"aria-valuemax":c.max,tabIndex:d?-1:0,className:s,"data-dragging":i?"true":void 0,onPointerDown:f,onPointerMove:h,onPointerUp:p,onPointerCancel:p,onKeyDown:g,onDoubleClick:()=>{d||t.reset(e)}})}const ea="flex flex-col gap-2 rounded-md bg-sunken px-5 py-7",Zc="items-center text-center",ed="flex-none text-lg leading-none text-muted",td="font-serif text-lg leading-snug text-ink",ta="max-w-prose text-md leading-relaxed text-muted wrap-anywhere",nd="mt-1 flex flex-wrap gap-2";function $e({title:e,description:t,action:n}){return o.jsxs("div",{className:be("state-empty",ea,Zc),children:[o.jsx("span",{className:ed,"aria-hidden":"true",children:"○"}),o.jsx("p",{className:td,children:e}),t&&o.jsx("p",{className:ta,children:t}),n&&o.jsx("div",{className:nd,children:n})]})}function Ke({label:e,rows:t=3}){return o.jsxs("div",{className:be("state-loading",ea),"aria-busy":"true","aria-live":"polite",children:[o.jsx("p",{className:ta,children:e??a("common.loading")}),o.jsx("div",{className:"mt-1.5 flex flex-col gap-2","aria-hidden":"true",children:Array.from({length:Math.max(1,t)},(n,s)=>o.jsx("span",{className:"skeleton-pulse h-3 rounded-full bg-sunken"},s))})]})}function Ve({message:e,onRetry:t,retryLabel:n,action:s,title:r}){return o.jsxs("div",{className:be("state-error",ea,Zc,"bg-danger-soft text-danger"),role:"alert",children:[o.jsx("span",{className:be(ed,"text-danger"),"aria-hidden":"true",children:"!"}),o.jsx("p",{className:be(td,"text-danger"),children:r??a("common.loadFailed")}),o.jsx("p",{className:be(ta,"font-mono text-sm text-danger"),children:e}),(t||s)&&o.jsxs("div",{className:nd,children:[t&&o.jsx(G,{onClick:t,children:n??a("common.retry")}),s]})]})}function Fe({title:e,reason:t,hint:n,action:s,variant:r="inline"}){const i=r==="page";return o.jsxs("div",{className:be("state-not-enabled",ea,Zc,i&&"min-h-60 justify-center px-6 py-12"),children:[o.jsx("span",{className:be(ed,i&&"text-3xl"),"aria-hidden":"true",children:"?"}),o.jsx("p",{className:be(td,i&&"text-xl"),children:e}),t&&o.jsx("p",{className:ta,children:t}),n&&o.jsx("p",{className:"font-mono text-sm text-faint",children:n}),s&&o.jsx("div",{className:nd,children:s})]})}function st({message:e,onRetry:t,onDismiss:n}){return o.jsxs("div",{className:"stale-notice flex flex-wrap items-center gap-2.5 rounded-sm bg-warn-soft px-3 py-2 text-sm text-warn",role:"status",children:[o.jsx("span",{className:"flex-none text-lg leading-none text-warn","aria-hidden":"true",children:"!"}),o.jsx("span",{className:"min-w-0 wrap-anywhere",children:e}),t&&o.jsx(G,{variant:"link",className:"text-warn hover:text-warn",onClick:t,children:a("common.refresh")}),n&&o.jsx(G,{variant:"link",className:"text-warn hover:text-warn",onClick:n,"aria-label":a("common.closeNotice"),children:a("common.close")})]})}const uC="vessel.catalog",mC="vessel.catalog.request";function fC(e,t){if(t.window===null||e.source!==t.window||e.origin!=="null"&&e.origin!==t.origin)return!1;const n=e.data;return n===null||typeof n!="object"?!1:n.type===mC}async function sd(e){try{const t=await e.rpc("plugins.catalog",{});if(t===null||typeof t!="object")return null;const n=t.items;return Array.isArray(n)?n:null}catch{return null}}async function hC(e,t){const n=await sd(e);return n===null?!1:(t({type:uC,items:n}),!0)}const pC="vessel.plugin.rpc",Lm="vessel.plugin.rpc.result",Am="vessel.plugin.refresh",gC="vessel.theme",bC="vessel.lang",vC=128;function yC(e){const t=e.code,n=e instanceof Error?e.message:String(e);return{code:typeof t=="string"?t:"internal",message:n}}function od({pluginId:e,entry:t,title:n,methods:s,context:r,className:i}){const l=He(),{theme:c}=hg(),[d,m]=u.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches);u.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const F=window.matchMedia("(prefers-color-scheme: dark)"),V=()=>m(F.matches);return V(),F.addEventListener("change",V),()=>F.removeEventListener("change",V)},[]);const f=mg(c,d),{client:h,nodeUrl:p,eventStore:g,mode:b,platformNodes:x,selectedNodeId:y}=Ae(),v=u.useRef(null),[j,_]=u.useState(0),[S,w]=u.useState(!1),[k,N]=u.useState(null),T=r?.run,R=r?.session,E=u.useMemo(()=>{if(b==="platform"){const F=x.find(V=>V.node_id===y)?.api_url??"";if(F.trim()!=="")return F}return p},[b,x,y,p]),I=u.useRef(l),$=u.useRef(f),C=u.useMemo(()=>AN(E,e,t,{run:T,session:R,lang:I.current,theme:$.current}),[E,e,t,T,R]),L=u.useCallback(F=>{v.current?.contentWindow?.postMessage(F,"*")},[]),A=u.useRef(0),D=u.useCallback(async()=>{const F=++A.current;await hC(h,V=>{F===A.current&&L(V)})},[h,L]);u.useEffect(()=>{S&&L({type:gC,theme:f})},[f,S,L]),u.useEffect(()=>{S&&L({type:bC,lang:l})},[l,S,L]),u.useEffect(()=>{if(C===null)return;const F=new URL(C).origin,V=new Set,B=W=>{const Z=v.current?.contentWindow;if(fC(W,{window:Z,origin:F})){D();return}if(W.source!==Z||W.origin!=="null"&&W.origin!==F)return;const ee=W.data;if(ee===null||typeof ee!="object")return;const ie=ee;if(ie.type!==pC)return;const le=ie.id,J=ie.method;typeof le!="string"||le===""||le.length>vC||typeof J!="string"||!s.has(J)||V.has(le)||(V.add(le),h.rpc(`plugin.${e}.${J}`,ie.params).then(z=>L({type:Lm,id:le,result:z})).catch(z=>L({type:Lm,id:le,error:yC(z)})).finally(()=>V.delete(le)))};return window.addEventListener("message",B),()=>window.removeEventListener("message",B)},[h,e,s,L,D,C]),u.useEffect(()=>{if(C===null)return;let F=g.getSnapshot().version,V;const B=g.subscribe(()=>{const W=g.getSnapshot();if(W.version===F)return;F=W.version;const Z=W.entries.slice(-20);for(let ee=Z.length-1;ee>=0;ee-=1){const ie=Z[ee]?.event;if(!ie)continue;if(ie.type==="plugin.changed"){L({type:Am}),window.clearTimeout(V),V=window.setTimeout(()=>{D()},Pg);break}if(ie.type!=="plugin.ready")continue;const le=ie.data,J=le.plugin_id??le.pluginId??le.id??le.name;if(!(typeof J=="string"&&J!==e)){L({type:Am});break}}});return()=>{B(),window.clearTimeout(V)}},[g,e,L,D,C]);const O=u.useCallback(()=>{N(null),w(!1),_(F=>F+1)},[]);return C===null?o.jsx(Ve,{message:a("plugins.frame.invalidEntry")}):o.jsxs("div",{className:be("relative min-h-0",i??"h-90"),children:[!S&&k===null&&o.jsx(Ke,{label:a("plugins.frame.loading"),rows:3}),k!==null&&o.jsx(Ve,{message:k,onRetry:O}),o.jsx("iframe",{ref:v,title:n,src:C,sandbox:"allow-scripts allow-forms",referrerPolicy:"no-referrer",className:be("h-full w-full border-0 bg-surface",(!S||k!==null)&&"hidden"),onLoad:()=>{w(!0),N(null),D()},onError:()=>N(a("plugins.frame.loadError"))},j)]})}const xC=new Set;function $g({items:e,methodsByPlugin:t,context:n,className:s,dense:r=!1}){return e.length===0?null:o.jsx("div",{className:be("plugin-panels flex flex-col",r?"gap-2":"gap-3",s),children:e.map(i=>{const l=i.title??i.id;return o.jsxs("section",{className:r?"rounded-md bg-sunken p-2":"panel","aria-label":a("plugins.panel.label",{title:l,plugin:i.pluginId}),children:[o.jsx("h3",{className:be("font-semibold text-ink",r?"text-sm":"text-md"),children:l}),o.jsx(od,{pluginId:i.pluginId,entry:i.entry,title:l,methods:t.get(i.pluginId)??xC,context:n,className:r?"mt-1 h-35":"mt-2 h-80"})]},`${i.pluginId}:${i.id}`)})})}function Fg({slot:e,context:t,className:n,dense:s=!1}){const{panels:r,methodsByPlugin:i}=Bn(),l=u.useMemo(()=>qg(r,e),[r,e]);return o.jsx($g,{items:l,methodsByPlugin:i,context:t,className:n,dense:s})}const wC="flex min-h-control w-full items-center rounded-sm bg-transparent text-left text-md text-muted transition-colors duration-150 hover:bg-hover hover:text-ink",kC="bg-accent-soft text-accent-ink hover:bg-accent-soft hover:text-accent-ink";function SC({item:e,collapsed:t,onNavigate:n}){const s=e.status,r=s?a(s.labelKey):"",i=s?.version&&s.version!=="unknown"?`v${s.version}`:void 0,l=e.count!==void 0?a("nav.count",{count:e.count}):void 0,c=[e.title,r,l,i].filter(m=>m!==void 0&&m!=="").join(" · "),d=o.jsxs("button",{type:"button",className:be(wC,t?"justify-center gap-0 px-0 py-1":"gap-2.5 px-3 py-1",e.active&&kC),"aria-current":e.active?"page":void 0,"aria-label":e.title,onClick:()=>n(e.route),children:[o.jsx("span",{className:"inline-flex flex-none",children:o.jsx(Ot,{domain:e.icon})}),!t&&o.jsx("span",{className:be("min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",(s!==void 0||e.count!==void 0)&&"flex-1"),children:e.title}),!t&&s&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"size-1.5 flex-none rounded-full bg-faint data-[tone=accent]:bg-accent data-[tone=amber]:bg-amber data-[tone=amber]:pulse-soft data-[tone=danger]:bg-danger","data-tone":s.tone,role:"img","aria-label":r,title:r}),i!==void 0&&o.jsx("span",{className:"flex-none whitespace-nowrap font-mono text-2xs text-faint",children:i})]}),!t&&e.count!==void 0&&o.jsx(Hn,{className:"ml-auto",count:e.count,label:l??e.title,tone:e.active?"accent":"muted"})]});return t?o.jsx(xt,{label:c,children:d}):d}const jC={"--motion-panel-duration":"var(--motion-base)"};function _C({group:e,collapsed:t,expanded:n,onToggle:s,onNavigate:r,className:i}){const l=!t&&e.collapsible,c=e.items.map(g=>o.jsx(SC,{item:g,collapsed:t,onNavigate:r},g.id)),d=!t&&!n,m=d?e.count:void 0,f=d&&e.items.some(g=>g.active),h=m!==void 0&&m>0?a("nav.count",{count:m}):void 0,p=[e.title,h,f?a("nav.group.current"):void 0].filter(g=>g!==void 0).join(" · ");return o.jsxs("div",{className:be("flex flex-col",i),children:[!t&&o.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 overflow-hidden rounded-sm bg-transparent px-3 pt-1 pb-0.5 text-left font-mono text-2xs tracking-[var(--tracking-wide)] text-faint uppercase transition-colors hover:bg-transparent hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface","aria-expanded":n,"aria-label":p,onClick:s,children:[o.jsx("span",{className:"min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:e.title}),f&&o.jsx("span",{"aria-hidden":"true",className:"size-1.5 flex-none rounded-full bg-accent"}),m!==void 0&&o.jsx(Hn,{count:m,label:h,tone:"muted"}),o.jsx("span",{"aria-hidden":"true",className:"flex-none text-2xs",children:n?"▾":"▸"})]}),l?o.jsx("div",{className:"motion-panel",style:jC,"data-motion-open":n?"":void 0,children:o.jsx("div",{className:"motion-panel-inner",inert:n?void 0:!0,"aria-hidden":n?void 0:!0,children:o.jsx("div",{className:"flex flex-col gap-0.5 pt-0.5",children:c})})}):o.jsx("div",{className:"flex flex-col gap-0.5",children:c})]})}const NC={chat:"chat",items:"pending",network:"agents",runs:"runs",integrations:"tools",core:"hub",settings:"settings"};function CC(e,t){if(e==="hub")return t.hub;if(e==="gateway")return t.gateway;if(e==="pluginHost")return t.pluginHost}function TC(e,t,n,s){const r=CC(e,n),i=s?.[e];return{id:`domain:${e}`,title:Ht(e),icon:e,route:Wt(e),active:Tg(t,e),...r?{status:r}:{},...i!==void 0&&i>0?{count:i}:{}}}function EC(e,t,n,s){return{id:`plugin:${e.pluginId}:${e.id}`,title:On(n,e.pluginId,e.titleKey,s,e.title,e.id),icon:e.icon??"plugins",route:{domain:"plugins",pluginId:e.pluginId,entry:e.entry},active:t.domain==="plugins"&&t.pluginId===e.pluginId&&(t.entry===void 0||t.entry===e.entry)}}function Ps(e,t,n,s,r){return e.filter(i=>i.nav===t).sort((i,l)=>i.order-l.order||i.title.localeCompare(l.title)).map(i=>EC(i,n,s,r))}function IC({route:e,pluginPages:t,pluginNavGroups:n,i18nByPlugin:s,locale:r,statuses:i,counts:l}){const c=[],d=g=>{if(g.items.length===0)return;const b=g.items.reduce((x,y)=>x+(y.count??0),0);c.push(b>0?{...g,count:b}:g)},m=(g,b)=>{const x=g.domains.map(y=>TC(y,e,i,l));return g.id==="network"&&x.push(...Ps(t,"observe",e,s,r)),g.id==="core"&&x.push(...Ps(t,"status",e,s,r)),x.push(...Ps(t,g.id,e,s,r)),{id:g.id,title:Va(g.id),icon:NC[g.id],order:b,collapsible:!0,items:x}};d({id:"top",title:Va("top"),icon:"plugins",order:0,collapsible:!0,items:Ps(t,"top",e,s,r)}),za.forEach((g,b)=>{g.id!=="core"&&d(m(g,b+1))});const f=c.length;d({id:"plugins",title:Va("plugins"),icon:"plugins",order:f,collapsible:!0,items:Ps(t,"plugins",e,s,r)});const h=[...n].sort((g,b)=>g.order-b.order).map(g=>({id:g.id,title:On(s,g.pluginId,g.titleKey,r,g.title,g.id),icon:g.icon??"plugins",order:g.order,collapsible:!0,items:Ps(t,g.id,e,s,r)}));for(const g of h)d(g);const p=za.find(g=>g.id==="core");return p&&d(m(p,za.length+1)),c}const Mm=new WeakMap;let RC=1;function Bg(e){const t=Mm.get(e);if(t!==void 0)return t;const n=RC++;return Mm.set(e,n),n}function Pm(e,t){return`${Bg(e)}|${t}`}let qs=null,Os=null,Ds=null;function LC(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const wt=vn()((e,t)=>{const n=s=>s.status==="idle"?s:Qo(s);return{config:{status:"idle"},sources:{status:"idle"},capabilities:{status:"idle"},configLoadedFor:null,sourcesLoadedFor:null,capabilitiesLoadedFor:null,loadConfig:async(s,r={})=>{const{epoch:i=0,force:l=!1}=r,c=Pm(s,i),d=t();if(!l&&d.configLoadedFor?.key===c)return;if(qs?.key===c)return qs.promise;const m=d.config,f=gn("config");e({config:n(m)});const h=(async()=>{try{const p=await s.getConfig();if(!kt("config",f))return;e({config:qn(p),configLoadedFor:{key:c}})}catch(p){if(!kt("config",f))return;e({config:bs(m,p)})}})();return qs={key:c,promise:h},h.finally(()=>{qs?.promise===h&&(qs=null)}),h},loadSources:async(s,r={})=>{const{force:i=!1}=r,l=Pm(s,0),c=t();if(!i&&c.sourcesLoadedFor?.key===l)return;if(Os?.key===l)return Os.promise;const d=c.sources,m=gn("config:sources");e({sources:n(d)});const f=(async()=>{try{const h=await s.getConfigSources();if(!kt("config:sources",m))return;e({sources:qn(h),sourcesLoadedFor:{key:l}})}catch(h){if(!kt("config:sources",m))return;e({sources:bs(d,h)})}})();return Os={key:l,promise:f},f.finally(()=>{Os?.promise===f&&(Os=null)}),f},loadCapabilities:async(s,r={})=>{const{force:i=!1}=r,l=`capabilities|${Bg(s)}`;if(!i&&t().capabilitiesLoadedFor?.key===l)return;if(Ds?.key===l)return Ds.promise;const c=t().capabilities,d=gn("capabilities");e({capabilities:n(c)});const m=(async()=>{try{const f=await s.getCapabilities();if(!kt("capabilities",d))return;e({capabilities:qn(f),capabilitiesLoadedFor:{key:l}})}catch(f){if(!kt("capabilities",d))return;e({capabilities:bs(c,f)})}})();return Ds={key:l,promise:m},m.finally(()=>{Ds?.promise===m&&(Ds=null)}),m},applyPermissionLists:s=>{e(r=>{const i=Se(r.config);if(!i)return r;const l=LC(i.config.permission)?i.config.permission:{},c={...i,config:{...i.config,permission:{...l,autoApprove:[...s.autoApprove],neverAutoApprove:[...s.neverAutoApprove]}}};return{config:r.config.status==="success"?qn(c):{...r.config,data:c}}})},reset:()=>{rn("config"),rn("config:sources"),rn("capabilities"),qs=null,Os=null,Ds=null,e({config:{status:"idle"},sources:{status:"idle"},capabilities:{status:"idle"},configLoadedFor:null,sourcesLoadedFor:null,capabilitiesLoadedFor:null})}}});function Qt(e={}){const{client:t,hasToken:n,epoch:s}=Ae(),r=e.config!==!1,i=e.capabilities===!0,l=e.sources===!0,c=e.pollMs,d=wt(x=>x.config),m=wt(x=>x.sources),f=wt(x=>x.capabilities);u.useEffect(()=>{!n||!r||wt.getState().loadConfig(t,{epoch:s})},[t,s,n,r]),qt(()=>{n&&wt.getState().loadCapabilities(t)},{enabled:n&&i,deps:[s,n]}),qt(()=>{n&&wt.getState().loadSources(t)},{enabled:n&&l,deps:[s,n]}),qt(()=>{n&&wt.getState().loadConfig(t,{epoch:s,force:!0})},{enabled:n&&r&&c!==void 0,...c!==void 0?{pollMs:c}:{},deps:[s,n]});const h=u.useCallback(async()=>{if(n)return await wt.getState().loadConfig(t,{epoch:s,force:!0}),Se(wt.getState().config)},[t,s,n]),p=u.useCallback(()=>{h()},[h]),g=u.useCallback(()=>{n&&wt.getState().loadSources(t,{force:!0})},[t,n]),b=u.useCallback(()=>{n&&wt.getState().loadCapabilities(t,{force:!0})},[t,n]);return{config:d,sources:m,capabilities:f,reloadConfig:p,reloadConfigAsync:h,reloadSources:g,reloadCapabilities:b,applyPermissionLists:wt.getState().applyPermissionLists}}const a$=["accent","amber","danger","muted"];function AC(e,t){return t?e==="open"?{tone:"accent",labelKey:"nav.status.online"}:e==="connecting"||e==="reconnecting"?{tone:"amber",labelKey:"nav.status.connecting"}:e==="closed"||e==="error"?{tone:"danger",labelKey:"nav.status.error"}:{tone:"muted",labelKey:"nav.status.unknown"}:{tone:"muted",labelKey:"nav.status.offline"}}function MC(e){switch(e){case"unconfigured":return{tone:"muted",labelKey:"nav.status.hubNotConfigured"};case"loading":return{tone:"amber",labelKey:"nav.status.connecting"};case"connected":case"empty":return{tone:"accent",labelKey:"nav.status.hubConnected"};case"unauthorized":return{tone:"danger",labelKey:"nav.status.hubUnauthorized"};case"incompatible":return{tone:"danger",labelKey:"nav.status.hubIncompatible"};case"network":return{tone:"danger",labelKey:"nav.status.hubNetwork"};default:return{tone:"muted",labelKey:"nav.status.unknown"}}}function PC(e){const{connectionState:t,hasToken:n,marketplace:s,read:r}=e,i=s?.version!==void 0?{version:s.version}:{};if(!n)return{tone:"muted",labelKey:"nav.status.offline",...i};if(t==="closed"||t==="error")return{tone:"danger",labelKey:"nav.status.error",...i};if(t==="connecting"||t==="reconnecting")return{tone:"amber",labelKey:"nav.status.connecting",...i};if(t!=="open")return{tone:"muted",labelKey:"nav.status.unknown",...i};if(r==="error")return{tone:"danger",labelKey:"nav.status.pluginHostListError",...i};if(r==="loading")return{tone:"amber",labelKey:"nav.status.pluginHostLoading",...i};if(!s)return{tone:"muted",labelKey:"nav.status.pluginHostNoMarketplace",...i};if(!s.enabled)return{tone:"muted",labelKey:"pluginHost.enabled.off",...i};switch(s.status){case"unhealthy":case"invalid":return{tone:"danger",labelKey:`pluginHost.status.${s.status}`,...i};case"disabled":return{tone:"muted",labelKey:"pluginHost.status.disabled",...i};case"active":return{tone:"accent",labelKey:"pluginHost.status.active",...i};case"inactive":return{tone:"accent",labelKey:"pluginHost.status.lazy",...i};default:return{tone:"accent",labelKey:"pluginHost.status.hostConnected",...i}}}function qC(e){return e.status==="success"?"ready":e.status==="error"?"error":e.status==="loading"&&e.data!==void 0?"ready":"loading"}function OC(e,t){const{connectionState:n,hasToken:s}=Ae(),{config:r}=Qt({pollMs:6e4}),i=u.useSyncExternalStore(mk,gi,gi),l=Se(r),c=AC(n,s),d=l?.version,m=e.find(h=>h.name==="marketplace"),f=MC(i.status);return{hub:i.version!==void 0?{...f,version:i.version}:f,gateway:d!==void 0?{...c,version:d}:c,pluginHost:PC({connectionState:n,hasToken:s,marketplace:m,read:qC(t)})}}const DC=12e3,HC=1500;function $C(e){return e==="unauthorized"?"unauthorized":e==="incompatible"?"incompatible":"network"}let Co=null;function FC(){return Co!==null?Co:Dc().url===""&&Cl()===null?(er("unconfigured"),Promise.resolve()):(Co=BC().finally(()=>{Co=null}),Co)}async function BC(){const e=new Dp;let t=!1,n,s,r=null;function i(c,d){if(t)return;t=!0,n!==void 0&&clearTimeout(n),s!==void 0&&clearTimeout(s),r?.();const m=gi().status;(m==="loading"||m==="unknown")&&er(c,d),e.close()}r=e.subscribe(()=>{const c=e.getSnapshot();if(!(c.status==="loading"||c.status==="unconfigured")){if(c.status==="network"){s===void 0&&(s=setTimeout(()=>i("network"),HC));return}i(c.status,c.directory?.version)}}),er("loading"),n=setTimeout(()=>i("network"),DC);const l=await e.connect();l.ok||i($C(l.error??"network"))}const Kg="vessel.nav.expanded-groups",KC="vessel.nav.collapsed-groups";function WC(){try{const e=localStorage.getItem(Kg);if(e===null)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function qm(e){try{localStorage.setItem(Kg,JSON.stringify([...e])),localStorage.removeItem(KC)}catch{}}function UC({route:e,navigate:t,mode:n,open:s=!1,onClose:r,onToggleCollapsed:i,navRef:l,panes:c,counts:d}){const m=He(),{plugins:f,state:h,pages:p,navGroups:g,i18nByPlugin:b,panels:x,methodsByPlugin:y}=Bn(),v=OC(f,h),[j,_]=u.useState(WC),S=qg(x,"nav"),w=IC({route:e,pluginPages:p,pluginNavGroups:g,i18nByPlugin:b,locale:m,statuses:v,...d!==void 0?{counts:d}:{}}),k=w.find(A=>A.items.some(D=>D.active))?.id;u.useEffect(()=>{k!==void 0&&_(A=>{if(A.has(k))return A;const D=new Set(A);return D.add(k),qm(D),D})},[k]);const N=n==="drawer",T=n==="collapsed"||n==="rail",R=!T,E=n==="expanded"||n==="collapsed",I=a(T?"nav.expandNav":"nav.collapseNav"),$=N?{role:"dialog","aria-modal":s}:{},C=A=>{_(D=>{const O=new Set(D);return O.has(A)?O.delete(A):O.add(A),qm(O),O})},L=be("flex flex-none flex-col overflow-hidden bg-surface shadow-elev-1",N?"fixed inset-y-0 left-0 z-[var(--z-drawer)] min-h-0 w-[min(86vw,var(--drawer-w))] shadow-elev-3 transition-[transform,translate,visibility] duration-[var(--motion-ui)] ease-[var(--ease)]":"relative min-h-0 transition-[width] duration-[var(--motion-base)] ease-[var(--ease)] has-[[data-dragging]]:transition-none motion-reduce:transition-none",N&&(s?"visible translate-x-0 transition-[transform,translate]":"invisible -translate-x-full"),!N&&(n==="collapsed"?"w-[var(--nav-w-collapsed)]":n==="rail"?"w-[var(--nav-w-rail)]":"w-[var(--nav-w)]"));return o.jsxs("nav",{...$,ref:l,id:"domain-nav",className:L,"aria-label":a("nav.mainLabel"),inert:N&&!s?!0:void 0,"aria-hidden":N&&!s?!0:void 0,children:[n!=="rail"&&o.jsxs("div",{className:be("flex flex-none items-center gap-2 px-4 pt-3 pb-2",n==="collapsed"&&"justify-center gap-0.5 px-0"),children:[o.jsx("span",{className:"font-serif text-xl font-semibold text-accent","aria-hidden":"true",children:"V"}),E&&o.jsx(Cn,{className:be("size-6 text-xs",T?"ml-0":"ml-auto"),label:I,"aria-label":I,"aria-expanded":!T,onClick:i,children:T?"»":"«"}),N&&o.jsx(Cn,{className:"ml-auto",label:a("nav.closeNav"),"aria-label":a("nav.closeNav"),onClick:r,children:"×"})]}),o.jsxs("div",{className:be("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain py-1.5",T?"px-2":"px-2.5"),children:[w.map((A,D)=>o.jsx(_C,{group:A,collapsed:T,expanded:j.has(A.id),onToggle:()=>C(A.id),onNavigate:t,...D>0?{className:"mt-3"}:{}},A.id)),R&&o.jsx($g,{items:S,methodsByPlugin:y,dense:!0,className:"mt-2 mb-2"})]}),n==="expanded"&&!c.disabled("nav")&&o.jsx(kr,{pane:"nav",api:c,label:a("resize.nav"),className:"resize-handle resize-handle-nav"})]})}const zC=680,na=1023,VC=1200;function GC(e,t){return e<=zC?"drawer":e<=na?"rail":t?"collapsed":"expanded"}function Om(e){return e<VC}function YC(e){return e==="1"?!0:e==="0"?!1:null}const Wg="vessel.nav.collapsed";function JC(){try{return YC(localStorage.getItem(Wg))}catch{return null}}function Ug(e){try{localStorage.setItem(Wg,e?"1":"0")}catch{}}const Ul="vessel:refresh";function rd(){window.dispatchEvent(new Event(Ul))}function Lt(e){u.useEffect(()=>{const t=()=>e();return window.addEventListener(Ul,t),()=>window.removeEventListener(Ul,t)},[e])}function QC({hasToken:e,connectionState:t,navigate:n,retry:s,toast:r,openHelp:i}){const l=[...uN.map(c=>({id:`nav-${c.id}`,group:"navigation",label:a("nav.openNamed",{domain:Ht(c.id)}),keywords:[c.id,Ht(c.id)],hint:a("nav.hintNavigation"),run:()=>n(Wt(c.id))})),...cg().map(c=>({id:`setting-${c.id}`,group:"settings",label:c.titleKey?a(c.titleKey):c.title??c.id,keywords:[c.id,c.key,...c.keywords??[]],hint:a("palette.hint.settings"),searchOnly:!0,run:()=>n({domain:"settings",focusKey:c.id})})),{id:"action-new-session",group:"action",label:a("palette.action.newSession"),keywords:["new","session","chat"],hint:a("palette.hint.action"),run:()=>{n({domain:"chat"}),window.setTimeout(()=>n({domain:"chat",sessionId:"new"}),0)}},{id:"action-resume-run",group:"action",label:a("palette.action.resumeRun"),keywords:["resume","durable","interrupted","恢复"],hint:a("palette.hint.action"),run:()=>n({domain:"runs",tab:"durable"})},{id:"action-connection",group:"action",label:a("palette.action.connectionSettings"),keywords:["gateway","token","url","connect"],hint:a("palette.hint.action"),run:()=>n({domain:"gateway"})},{id:"action-config",group:"action",label:a("palette.action.viewConfig"),keywords:["config","sources"],hint:a("palette.hint.action"),run:()=>n({domain:"settings"})},{id:"action-capabilities",group:"action",label:a("palette.action.viewCapabilities"),keywords:["capabilities","methods"],hint:a("palette.hint.action"),run:()=>n({domain:"capabilities"})},{id:"action-refresh",group:"action",label:a("palette.action.refresh"),keywords:["refresh","reload"],hint:a("palette.hint.action"),run:()=>{rd(),r.info(a("palette.toast.refreshed"))}},{id:"help-shortcuts",group:"help",label:a("palette.action.shortcuts"),keywords:["help","keyboard","shortcut"],hint:a("palette.hint.help"),run:i}];return e&&l.push({id:"action-retry",group:"action",label:a(t==="open"?"palette.action.checkConnection":"palette.action.reconnect"),keywords:["reconnect","retry"],hint:a("palette.hint.action"),run:()=>{s(),r.info(a("palette.toast.reconnecting"))}}),l}const Ao=["navigation","settings","entity","action","help"],XC={navigation:"palette.group.navigation",settings:"palette.group.settings",entity:"palette.group.entity",action:"palette.group.action",help:"palette.group.help"};function ZC(e){const t=e.trim();return t.startsWith(">")?{actionMode:!0,needle:t.slice(1).trim().toLowerCase()}:{actionMode:!1,needle:t.toLowerCase()}}function eT(e,t){if(!t)return 0;const n=e.label.toLowerCase();return n===t?0:n.startsWith(t)?1:n.split(/\s+/).some(s=>s.startsWith(t))?2:n.includes(t)?3:e.keywords?.some(s=>s.toLowerCase().includes(t))?4:-1}function tT(e,t){const n=typeof t=="string"?ZC(t):t,s=n.actionMode?e.filter(r=>r.group==="action"||r.group==="help"):[...e];return n.needle?s.map((r,i)=>({item:r,index:i,score:eT(r,n.needle)})).filter(r=>r.score>=0).sort((r,i)=>{if(r.score!==i.score)return r.score-i.score;const l=Ao.indexOf(r.item.group)-Ao.indexOf(i.item.group);return l!==0?l:r.index-i.index}).map(({item:r})=>r):s.filter(r=>r.searchOnly!==!0).map((r,i)=>({item:r,index:i})).sort((r,i)=>{const l=Ao.indexOf(r.item.group)-Ao.indexOf(i.item.group);return l!==0?l:r.index-i.index}).map(({item:r})=>r)}function nT(e){return Ao.map(t=>({group:t,label:a(XC[t]),items:e.filter(n=>n.group===t)})).filter(t=>t.items.length>0)}function Dm(e,t,n){if(n<=0)return-1;const r=((e<0?t>0?-1:0:e)+t)%n;return r<0?r+n:r}function sT({items:e,entities:t,initialQuery:n="",onClose:s,onExecute:r}){const[i,l]=u.useState(n),[c,d]=u.useState(0),m=u.useRef(null),f=u.useId(),h=u.useMemo(()=>tT([...e,...t],i),[e,t,i]),p=u.useMemo(()=>nT(h),[h]),g=u.useMemo(()=>p.flatMap(v=>v.items),[p]),b=g.length===0?-1:Math.min(c,g.length-1),x=b>=0?g[b]:void 0;u.useEffect(()=>{d(0)},[i]);const y=v=>{s(),window.setTimeout(()=>{r?r(v):v.run()},0)};return o.jsxs(tn,{label:a("palette.label"),onClose:s,closeLabel:a("common.close"),className:"palette mt-16 max-w-palette self-start gap-0 overflow-hidden p-0 z-palette",bodyClassName:"gap-0 overflow-x-hidden overflow-y-hidden",children:[o.jsxs("div",{className:"palette-input-row",children:[o.jsx("span",{className:"palette-prefix","aria-hidden":"true",children:"⌘K"}),o.jsx("input",{ref:m,className:"palette-input",value:i,onChange:v=>l(v.target.value),placeholder:a("palette.searchPlaceholder"),role:"combobox","aria-expanded":"true","aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":x?`palette-${x.id}`:void 0,"aria-label":a("palette.searchLabel"),spellCheck:!1,autoComplete:"off","data-autofocus":!0,onKeyDown:v=>{v.key==="ArrowDown"?(v.preventDefault(),d(Dm(b,1,g.length))):v.key==="ArrowUp"?(v.preventDefault(),d(Dm(b,-1,g.length))):v.key==="Home"?(v.preventDefault(),d(g.length>0?0:-1)):v.key==="End"?(v.preventDefault(),d(g.length-1)):v.key==="Enter"&&!v.nativeEvent.isComposing&&x&&(v.preventDefault(),y(x))}})]}),o.jsxs("div",{className:"palette-results",id:f,role:"listbox","aria-label":a("palette.resultsLabel"),children:[p.map(v=>o.jsxs("div",{className:"palette-group",role:"group","aria-label":v.label,children:[o.jsx("div",{className:"palette-group-title","aria-hidden":"true",children:v.label}),v.items.map(j=>{const _=g.indexOf(j),S=_===b;return o.jsxs("button",{id:`palette-${j.id}`,type:"button",role:"option","aria-selected":S,className:`palette-option ${S?"active":""}`.trim(),onMouseMove:()=>d(_),onClick:()=>y(j),children:[o.jsx("span",{className:"palette-label",children:j.label}),j.danger&&o.jsx("span",{className:"palette-danger",children:a("palette.needConfirm")}),j.hint&&o.jsx("span",{className:"palette-hint",children:j.hint})]},j.id)})]},v.group)),g.length===0&&o.jsx("p",{className:"palette-empty",children:a("palette.empty",{query:i.trim()})})]}),o.jsxs("div",{className:"palette-footer",children:[o.jsx("span",{children:a("palette.footer")}),o.jsx("span",{"aria-live":"polite",className:"palette-count",children:a("palette.count",{count:g.length})})]})]})}function In({title:e,body:t,confirmLabel:n,cancelLabel:s,danger:r=!1,busy:i=!1,confirmDisabled:l=!1,onConfirm:c,onCancel:d,extra:m}){const f=u.useId(),h=n??a("common.confirm"),p=s??a("common.cancel");return o.jsxs(tn,{label:e,describedBy:f,onClose:d,closeOnBackdrop:!i,size:"sm",children:[o.jsx("h2",{className:"modal-title",children:e}),o.jsx("div",{id:f,className:"flex flex-col gap-3 text-md leading-relaxed text-muted text-pretty",children:t}),m,o.jsxs("div",{className:"modal-actions","aria-busy":i||void 0,children:[o.jsx(G,{onClick:d,disabled:i,"data-autofocus":!0,children:p}),o.jsx(G,{variant:r?"danger":"primary",onClick:c,disabled:i||l,children:i?a("common.processing"):h})]})]})}const oT="modulepreload",rT=function(e){return"/"+e},Hm={},sa=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){let d=function(m){return Promise.all(m.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");r=d(n.map(m=>{if(m=rT(m),m in Hm)return;Hm[m]=!0;const f=m.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${h}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":oT,f||(p.as="script"),p.crossOrigin="",p.href=m,c&&p.setAttribute("nonce",c),document.head.appendChild(p),f)return new Promise((g,b)=>{p.addEventListener("load",g),p.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return r.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};function iT(e){return e.type}const zg=Vc.map(e=>({key:e.key,type:iT(e),id:lg(e.key),options:e.options,min:e.min,max:e.max,fallback:e.fallback}));function aT(e){if(!Ko(e)||!Array.isArray(e.logEnvOverrides))return[];const t=[];for(const n of e.logEnvOverrides)Ko(n)&&typeof n.env=="string"&&typeof n.key=="string"&&typeof n.value=="string"&&t.push({env:n.env,key:n.key,value:n.value});return t}const lT=new Map(zg.map(e=>[e.key,e]));function Ko(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zl(e,t){if(!Ko(e))return;let s=Ko(e.config)?e.config:e;for(const r of t.split(".")){if(!Ko(s))return;const i=r.replace(/[A-Z]/g,l=>`_${l.toLowerCase()}`);s=s[r]!==void 0?s[r]:s[i]}return s}function as(e,t){const n=zl(e,t);if(typeof n=="boolean")return n?"true":"false";if(typeof n=="string")return n;if(typeof n=="number"&&Number.isFinite(n))return String(n);if(n===void 0){if(t==="ui.messageVisibility.system"){const s=zl(e,"ui.showInternalEvents");if(typeof s=="boolean")return s?"true":"false"}return lT.get(t)?.fallback??""}return""}function cT(e,t){return zl(e,t)!==void 0}function dT(e,t){const n={};for(const s of zg)n[s.key]=as(e,s.key);return{...n,...t}}const uT=new Set(["local","user","project"]);function mT(e){const t=[],n=[];for(const s of e.trim().split(/\s+/))if(s)if(s==="@modified")t.push({kind:"modified"});else if(s.startsWith("@plugin:")){const r=s.slice(8);r&&t.push({kind:"plugin",pluginId:r})}else s.startsWith("@")&&uT.has(s.slice(1))?t.push({kind:"scope",scope:s.slice(1)}):n.push(s);return{text:n.join(" ").toLowerCase(),filters:t}}function fT(e,t,n){return[t,n,e.id,e.key,...e.keywords??[],...e.options??[]].join(" ").toLowerCase()}function hT(e,t,n){for(const r of t.filters)if(r.kind==="modified"&&!n.isModified(e)||r.kind==="plugin"&&e.pluginId!==r.pluginId||r.kind==="scope"&&e.scope!==r.scope)return!1;if(!t.text)return!0;const s=n.haystacks.get(e.id)??"";return t.text.split(/\s+/).every(r=>s.includes(r))}function pT(e,t){if(e.type==="view"||e.readOnly)return!1;const n=e.default??e.fallback;return n===void 0?t!==void 0&&t!=="":(t??"")!==n}function gT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bT(e,t){const n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0||!e)return[{text:e,hit:!1}];const s=new RegExp(`(${n.map(gT).join("|")})`,"gi"),r=[];let i=0;for(const l of e.matchAll(s)){const c=l.index??0;c>i&&r.push({text:e.slice(i,c),hit:!1}),r.push({text:l[0],hit:!0}),i=c+l[0].length}return i<e.length&&r.push({text:e.slice(i),hit:!1}),r}function $m({nodes:e,activeId:t,onSelect:n,compact:s=!1,collapsedIds:r,onToggleCollapse:i}){return s?o.jsx("div",{className:"flex gap-1.5 overflow-x-auto pb-1",role:"tablist","aria-label":a("settings.title"),children:e.map(l=>o.jsxs("button",{type:"button",role:"tab","aria-selected":t===l.id,className:`shrink-0 rounded-full px-3 py-1 text-sm transition-colors ${t===l.id?"bg-accent-soft text-accent-ink":"bg-transparent text-muted hover:bg-hover"}`,onClick:()=>n(l.id),children:[l.label,l.count!==void 0&&l.count>0?` (${l.count})`:""]},l.id))}):o.jsx("nav",{className:"flex flex-col gap-0.5","aria-label":a("settings.title"),children:e.map(l=>{const c=r.has(l.id),d=(l.children?.length??0)>0;return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:"flex items-center",children:[d&&o.jsx("button",{type:"button",className:"bg-transparent px-1 text-xs text-faint","aria-expanded":!c,"aria-label":a(c?"settings.dialog.expandTree":"settings.dialog.collapseTree"),onClick:()=>i(l.id),children:c?"▸":"▾"}),o.jsxs("button",{type:"button",className:`flex grow items-center justify-between gap-2 rounded-sm px-2 py-1.5 text-left text-sm transition-colors ${t===l.id?"bg-accent-soft text-accent-ink":"bg-transparent text-ink hover:bg-hover"} ${d?"":"ml-4"}`,"aria-current":t===l.id?"true":void 0,onClick:()=>n(l.id),children:[o.jsx("span",{className:"truncate",children:l.label}),l.count!==void 0&&l.count>0&&o.jsx(Hn,{count:l.count})]})]}),d&&!c&&o.jsx("div",{className:"ml-4 flex flex-col gap-0.5 border-l border-line pl-2",children:(l.children??[]).map(m=>o.jsxs("button",{type:"button",className:`flex items-center justify-between gap-2 rounded-sm px-2 py-1 text-left text-sm transition-colors ${t===m.id?"bg-accent-soft text-accent-ink":"bg-transparent text-muted hover:bg-hover"}`,"aria-current":t===m.id?"true":void 0,onClick:()=>n(m.id),children:[o.jsx("span",{className:"truncate",children:m.label}),m.count!==void 0&&m.count>0&&o.jsx(Hn,{count:m.count})]},m.id))})]},l.id)})})}function vT({onOpenGateway:e}){const{connectionState:t,hasToken:n,nodeLabel:s}=Ae(),{config:r}=Qt(),i=Se(r),l=n?t:"no-token",c=t==="open"&&n?"success":"warn";return o.jsxs("div",{className:"flex flex-col gap-2 rounded-sm border border-line bg-transparent p-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[o.jsx(Re,{tone:c,children:l}),s&&o.jsx("span",{className:"text-muted",children:s}),i?.config?.schema_version!==void 0&&o.jsxs("span",{className:"font-mono text-xs text-faint",children:["schema v",String(i.config.schema_version)]})]}),o.jsxs(G,{variant:"link",className:"self-start text-sm",onClick:e,children:[a("settings.dialog.openGateway")," →"]})]})}const yT=u.lazy(()=>sa(()=>import("./DesignLabContent-CY5HfVn_.js").then(e=>e.a),__vite__mapDeps([0,1,2])).then(e=>({default:e.DesignLabContent})));function xT({defaultExpanded:e=!1}){const[t,n]=u.useState(e),[s,r]=u.useState(!1);u.useEffect(()=>{if(!s)return;const l=c=>{c.key==="Escape"&&(c.stopImmediatePropagation(),r(!1))};return document.addEventListener("keydown",l,!0),()=>document.removeEventListener("keydown",l,!0)},[s]);const i=o.jsx(u.Suspense,{fallback:o.jsx(Ke,{label:a("settings.dialog.loading")}),children:o.jsx(yT,{})});return o.jsxs("div",{className:"flex flex-col gap-2 rounded-sm border border-line p-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium",children:a("settings.item.view.designLab.title")}),o.jsx(G,{variant:"link",className:"text-sm",onClick:()=>n(l=>!l),children:a(t?"common.collapse":"common.expand")}),o.jsxs(G,{variant:"link",className:"ml-auto text-sm",onClick:()=>r(!0),children:[a("settings.dialog.fullscreen")," →"]})]}),t&&o.jsx("div",{className:"max-h-[60dvh] overflow-y-auto overscroll-contain",children:i}),s&&o.jsx(tn,{size:"lg",label:a("designLab.title"),closeLabel:a("common.close"),onClose:()=>r(!1),className:"h-[min(86dvh,var(--modal-max-h))]",bodyClassName:"grow overflow-hidden",children:o.jsx("div",{className:"min-h-0 grow overflow-y-auto overscroll-contain",children:i})})]})}function ls({text:e,label:t=a("common.copy"),toast:n=a("common.copied"),className:s="link-btn"}){const r=ot(),[i,l]=u.useState(!1);return o.jsx(xt,{label:t,children:o.jsx(G,{variant:"link",className:s,"aria-label":t,onClick:()=>{Bc(e).then(()=>{l(!0),r.success(n),window.setTimeout(()=>l(!1),1500)}).catch(c=>{r.error(c instanceof Error?c.message:String(c))})},children:i?a("common.copied"):t})})}function id({value:e,label:t=a("common.rawData"),open:n=!1,maxHeight:s=360,className:r}){let i;try{i=JSON.stringify(e,null,2)??String(e)}catch{i=String(e)}return o.jsxs("details",{className:be("json-view",r),open:n,children:[o.jsx("summary",{children:t}),o.jsx("pre",{className:"json-body",style:{maxHeight:s},children:i})]})}function Fm({text:e,query:t}){const n=bT(e,t);let s=0;const r=n.map(i=>{const l=`${s}:${i.hit?"hit":"text"}`;return s+=i.text.length,i.hit?o.jsx("mark",{children:i.text},l):o.jsx("span",{children:i.text},l)});return o.jsx(o.Fragment,{children:r})}function wT({disabled:e,kind:t,max:n,min:s,onCommit:r,placeholder:i,step:l,value:c}){const[d,m]=u.useState(c),[f,h]=u.useState(!1);u.useEffect(()=>{f||m(c)},[c,f]);const p=()=>{d!==c&&r(d)};return o.jsx(Xe,{type:t==="number"?"number":"text",className:be(Vi,"max-w-80 font-mono"),disabled:e,min:s,max:n,...l!==void 0?{step:l}:{},placeholder:i,value:d,onFocus:()=>h(!0),onBlur:()=>{h(!1),p()},onChange:g=>m(g.target.value),onKeyDown:g=>{g.key==="Enter"&&g.currentTarget.blur()}})}function kT({def:e,value:t,modified:n,disabled:s,disabledReason:r,saving:i,query:l,envOverride:c,configured:d=!0,onSave:m,onReset:f,onReloadPlugin:h,children:p}){const g=e.titleKey?a(e.titleKey):e.title??e.id,b=e.descriptionKey&&Jh(e.descriptionKey)?a(e.descriptionKey):e.description??"",x=a(e.scope==="local"?"settings.dialog.scopeLocal":e.scope==="project"?"settings.dialog.scopeProject":"settings.dialog.scopeUser"),y=!s&&(e.resettable===!0||!e.readOnly&&e.default!==void 0),v=e.id==="local.nav.groups"?a("settings.dialog.expandAll"):a("settings.dialog.resetDefault"),j=s||e.readOnly===!0||i,_=e.default??e.fallback,S=t===""&&_!==void 0?_:t;let w=null;if(e.type==="view")w=p;else if(e.type==="boolean")w=o.jsxs("label",{className:"flex items-center gap-1.5 text-md",children:[o.jsx("input",{type:"checkbox",checked:S==="true",disabled:j,onChange:k=>m(e,k.target.checked?"true":"false")}),o.jsx("span",{className:"font-mono",children:S==="true"?"true":"false"})]});else if(e.type==="enum"){const k=e.options??[];w=k.length>4?o.jsx($t,{className:be(Vi,"max-w-80"),disabled:j,value:S,onChange:N=>m(e,N.target.value),children:k.map(N=>o.jsx("option",{value:N,children:e.optionLabelKeys?.[N]?a(e.optionLabelKeys[N]):N},N))}):o.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:k.map(N=>o.jsxs("label",{className:"flex items-center gap-1.5 text-md",children:[o.jsx("input",{type:"radio",name:`setting-${e.id}`,value:N,checked:S===N,disabled:j,onChange:()=>m(e,N)}),o.jsx("span",{className:e.optionLabelKeys?.[N]?"":"font-mono",children:e.optionLabelKeys?.[N]?a(e.optionLabelKeys[N]):N})]},N))})}else if(e.type==="string"||e.type==="number")w=o.jsx(wT,{disabled:j,kind:e.type,max:e.max,min:e.min,onCommit:k=>m(e,k),placeholder:_,...e.type==="number"&&e.float===!0?{step:"any"}:{},value:d?t:""});else{let k=t;try{k=t?JSON.parse(t):{}}catch{k=t}w=o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(id,{value:k,label:e.key,maxHeight:200,className:Al}),o.jsx("span",{className:"text-sm text-muted",children:a("settings.dialog.editInYaml")})]})}return o.jsxs("div",{className:"group/row relative flex flex-col gap-1.5 py-3 pl-3","data-setting-id":e.id,children:[n&&o.jsx("span",{role:"img","aria-label":a("settings.dialog.modified"),className:"absolute top-3 bottom-3 left-0 w-0.5 rounded-full bg-accent"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"font-medium text-md",children:o.jsx(Fm,{text:g,query:l})}),o.jsx(Re,{tone:"neutral",className:Ll,children:x}),e.readOnly&&o.jsx(Re,{tone:"neutral",className:Ll,children:a("settings.dialog.readOnly")}),i&&o.jsx(Re,{tone:"accent",children:"…"}),y&&o.jsxs(G,{variant:"link",className:"ml-auto text-sm opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",onClick:()=>f(e),children:["↺ ",v]})]}),b&&o.jsx("p",{className:"text-sm text-muted",children:o.jsx(Fm,{text:b,query:l})}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("code",{className:"font-mono text-xs text-muted",children:e.id}),o.jsx(ls,{text:e.id,label:a("settings.dialog.copyKey"),className:"link-btn text-xs"})]}),w,c&&o.jsx("p",{className:"text-sm text-warn",children:a("settings.dialog.envOverride",{env:c})}),e.restartRequired&&o.jsxs("p",{className:"flex items-center gap-2 text-sm text-warn",children:[a("settings.dialog.restartRequired"),h&&o.jsx(G,{variant:"link",className:"text-sm",onClick:h,children:a("settings.dialog.reloadPlugin")})]}),r&&o.jsx("p",{className:"text-sm text-muted",children:r})]})}function ST({query:e,onQueryChange:t,pluginIds:n}){const s=u.useRef(null),r=l=>{const c=e.trim();c.split(/\s+/).includes(l)||(t(c?`${c} ${l}`:l),s.current&&(s.current.open=!1))},i=/(^|\s)@(modified|plugin:|local|user|project)/.test(e);return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Tn,{className:be("grow",Vi),value:e,onChange:t,placeholder:a("settings.dialog.searchPlaceholder"),ariaLabel:a("settings.dialog.searchPlaceholder")}),o.jsxs("details",{ref:s,className:"relative shrink-0",children:[o.jsx("summary",{className:be("cursor-pointer list-none rounded-sm px-2.5 py-1.5 text-sm text-muted select-none tint-hover",es),children:"@ ▾"}),o.jsxs("div",{className:"absolute right-0 z-10 mt-1 flex w-56 flex-col gap-0.5 rounded-sm bg-surface p-1.5 shadow-elev-2 forced-colors:border",children:[o.jsx("button",{type:"button",className:"rounded-sm bg-transparent px-2 py-1 text-left text-sm hover:bg-hover",onClick:()=>r("@modified"),children:a("settings.dialog.filterModified")}),o.jsx("button",{type:"button",className:"rounded-sm bg-transparent px-2 py-1 text-left text-sm hover:bg-hover",onClick:()=>r("@local"),children:"@local"}),o.jsx("button",{type:"button",className:"rounded-sm bg-transparent px-2 py-1 text-left text-sm hover:bg-hover",onClick:()=>r("@user"),children:"@user"}),o.jsx("button",{type:"button",className:"rounded-sm bg-transparent px-2 py-1 text-left text-sm hover:bg-hover",onClick:()=>r("@project"),children:"@project"}),n.map(l=>o.jsxs("button",{type:"button",className:"rounded-sm bg-transparent px-2 py-1 text-left text-sm hover:bg-hover",onClick:()=>r(`@plugin:${l}`),children:["@plugin:",l]},l))]})]}),(e||i)&&o.jsx(G,{variant:"link",className:"shrink-0 text-sm",onClick:()=>t(""),children:a("settings.dialog.clearFilters")})]})}const Dr=8,Bm=250;function Ga(e){return e instanceof Error?e.message:String(e)}function Km(e){const t=e.code;return t==="not_found"||t==="method_not_allowed"}function Wm(e,t){if(e.type==="boolean")return t==="true"?!0:t==="false"?!1:void 0;if(e.type==="number"){const n=Number(t),s=e.min??Number.NEGATIVE_INFINITY,r=e.max??Number.POSITIVE_INFINITY,i=e.float===!0?Number.isFinite(n):Number.isInteger(n),l=e.maxExclusive===!0?n<r:n<=r;return t.trim()===""||!i||n<s||!l?void 0:n}if(e.type==="string"){const n=t.trim();return n.length>0?n:void 0}if(e.type==="enum")return e.options?.includes(t)===!0?t:void 0}function jT(e){try{return localStorage.getItem(e.key)??e.fallback??""}catch{return e.fallback??""}}function _T(e,t){return typeof e=="boolean"?(e?"true":"false")===t:typeof e=="number"?String(e)===t:typeof e=="string"?e===t:!1}function NT(){const e=ot(),{client:t}=Ae(),{reloadConfig:n,reloadConfigAsync:s}=Qt(),r=_n(w=>w.setSettingsPending),i=_n(w=>w.clearSettingsPending),l=_n(w=>w.setTheme),[c,d]=u.useState(),[m,f]=u.useState(!1),[h,p]=u.useState(0),[g,b]=u.useState(),x=u.useCallback(()=>p(w=>w+1),[]),y=u.useCallback((w,k)=>{if(w.id==="local.theme")l(Yj(k));else if(w.id==="local.nav.collapsed")Ug(k==="true");else try{localStorage.setItem(w.key,k)}catch{}x(),e.success(a("settings.dialog.saved",{key:w.id}))},[x,l,e]),v=u.useCallback(async(w,k,N)=>{if(w.readOnly||w.type==="view"||w.type==="object"||w.type==="array")return;if(w.scope==="local"){y(w,k);return}if(w.pluginId!==void 0){const R=Wm(w,k);if(R===void 0)return;r({[w.id]:k}),d(w.id);try{let E;try{E=await t.setPluginConfigValue(w.pluginId,w.key,R)}catch($){i([{key:w.id,value:k}]),Km($)?(f(!0),e.error(a("settings.dialog.writeUnavailable"))):e.error(a("settings.dialog.saveFailed",{detail:Ga($)}));return}let I=!1;for(let $=0;$<Dr;$+=1){const L=(await t.listPlugins().catch(()=>{}))?.find(A=>A.name===w.pluginId);if(L!==void 0&&_T(L.config?.[w.key],k)){I=!0;break}$<Dr-1&&await new Promise(A=>setTimeout(A,Bm))}i([{key:w.id,value:k}]),I?e.success(a("settings.dialog.saved",{key:w.id})):e.error(a("settings.dialog.saveUnconfirmed",{key:w.id})),E.restartRequired&&b(w.pluginId)}finally{d(void 0)}return}const T=Wm(w,k);if(T!==void 0){r({[w.key]:k}),d(w.id);try{try{await t.setConfigValue(w.key,T,N)}catch(E){i([{key:w.key,value:k}]),Km(E)?(f(!0),e.error(a("settings.dialog.writeUnavailable"))):e.error(a("settings.dialog.saveFailed",{detail:Ga(E)}));return}w.key==="ui.language"&&(T==="zh-CN"||T==="en")&&jc(T);let R=!1;for(let E=0;E<Dr;E+=1){const I=await s().catch(()=>{});if(I!==void 0&&as(I,w.key)===k){R=!0;break}E<Dr-1&&await new Promise($=>setTimeout($,Bm))}i([{key:w.key,value:k}]),R?e.success(a("settings.dialog.saved",{key:w.id})):e.error(a("settings.dialog.saveUnconfirmed",{key:w.id}))}finally{d(void 0)}}},[i,t,s,y,r,e]),j=u.useCallback(async(w,k)=>{if(w.scope==="local"){if(w.id==="local.theme")l(w.default??"dark");else try{localStorage.removeItem(w.key)}catch{}x(),e.success(a("settings.dialog.resetDone",{key:w.id}));return}w.default!==void 0&&await v(w,w.default,k)},[x,v,l,e]),_=u.useCallback(()=>{f(!1),n()},[n]),S=u.useCallback(async()=>{try{const w=await t.reloadPlugins();if(w.errors.length>0){for(const k of w.errors)e.error(`${k.id}: ${k.message}`);return}b(void 0),e.success(a("settings.dialog.pluginReloaded"))}catch(w){e.error(a("settings.dialog.saveFailed",{detail:Ga(w)}))}},[t,e]);return{save:v,reset:j,savingKey:c,writeUnavailable:m,refresh:_,localRevision:h,restartPluginId:g,reloadPlugin:S}}const CT=u.lazy(()=>sa(()=>import("./ConfigView-BKdxb1s5.js"),__vite__mapDeps([3,1,2])).then(e=>({default:e.ConfigView}))),Vl="vessel.settings.tab",Vg="vessel.settings.tree.collapsed",TT=150,ET=2e3,IT=rg[0]?.id??"visual";function Um(e){if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number"&&Number.isFinite(e))return String(e);if(typeof e=="string")return e;if(e!==null&&typeof e=="object")try{return JSON.stringify(e)}catch{return}}function RT(){try{const e=localStorage.getItem(Vl);return e==="local"||e==="project"?e:"user"}catch{return"user"}}function LT(){try{const e=localStorage.getItem(Vg),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function AT({focusKey:e,initialQuery:t,initialCategory:n,onClose:s,onNavigate:r}){He();const{connectionState:i,hasToken:l,features:c}=Ae(),{config:d,reloadConfig:m}=Qt(),f=Se(d),h=_n(M=>M.settingsPending),p=_n(M=>M.theme),g=NT(),{settings:b,plugins:x}=Bn(),[y,v]=u.useState(RT),[j,_]=u.useState(t??""),[S,w]=u.useState(t??""),[k,N]=u.useState(n&&n!=="common"?n:IT),[T,R]=u.useState(LT),[E,I]=u.useState(),$=u.useRef({}),C=u.useRef(null);u.useEffect(()=>{const M=setTimeout(()=>w(j),TT);return()=>clearTimeout(M)},[j]);const L=u.useMemo(()=>{const M=new Map;for(const H of x)H.mode!==void 0&&M.set(H.name,H.mode);return M},[x]),A=u.useMemo(()=>cg(Wj(b).map(M=>M.pluginId!==void 0&&L.get(M.pluginId)==="child"?{...M,restartRequired:!0}:M)),[b,L]),D=u.useMemo(()=>dT(f,h),[f,h]),O=u.useMemo(()=>aT(f),[f]),F=u.useMemo(()=>{const M=new Map;for(const H of x)H.config&&M.set(H.name,H.config);return M},[x]),V=u.useMemo(()=>{const M={};for(const H of A)if(H.type==="view")M[H.id]="";else if(H.scope==="local")M[H.id]=H.id==="local.theme"?p:H.id==="local.motion"?"":jT(H);else if(H.pluginId!==void 0){const X=F.get(H.pluginId)?.[H.key];M[H.id]=h[H.id]??Um(X)??H.default??""}else M[H.id]=h[H.key]??D[H.key]??H.fallback??"";return M},[A,p,h,D,F,g.localRevision]),B=u.useMemo(()=>{const M=new Map;for(const H of A){const X=H.titleKey?a(H.titleKey):H.title??H.id,Y=H.descriptionKey&&Jh(H.descriptionKey)?a(H.descriptionKey):H.description??"";M.set(H.id,fT(H,X,Y))}return M},[A]),W=u.useMemo(()=>mT(S),[S]),Z=S.trim()!=="",ee=u.useMemo(()=>M=>pT(M,V[M.id]),[V]),ie=u.useMemo(()=>A.filter(M=>y==="project"?(M.scope==="user"||M.scope==="project")&&M.pluginId===void 0&&M.type!=="view":M.scope===y),[A,y]),le=u.useMemo(()=>ie.filter(M=>hT(M,W,{haystacks:B,isModified:ee})),[ie,W,B,ee]),J=u.useMemo(()=>rg.filter(M=>M.id!=="extensions").map(M=>({category:M,items:le.filter(H=>H.category===M.id)})).filter(M=>M.items.length>0),[le]),z=u.useMemo(()=>b.map(M=>({id:`ext:${M.pluginId}`,label:M.pluginName,items:le.filter(H=>H.pluginId===M.pluginId)})).filter(M=>M.items.length>0),[b,le]),me=u.useMemo(()=>{const M=[];for(const H of J)M.push({id:H.category.id,label:a(H.category.titleKey),count:Z?H.items.length:void 0});return z.length>0&&M.push({id:"extensions",label:a("settings.category.extensions"),children:z.map(H=>({id:H.id,label:H.label,count:Z?H.items.length:void 0}))}),M},[J,z,Z]),K=l&&i==="open",ne=l&&c.includes("config"),Ne=!K||!ne||g.writeUnavailable,ce=g.writeUnavailable?a("settings.dialog.writeUnavailable"):ne&&K?void 0:a("settings.dialog.configUnavailable"),se=M=>{if(!M.key.startsWith(vi))return;const H=M.key.slice(vi.length);return O.find(X=>X.key===H)?.env},we=M=>{if(M.type==="view")return!1;if(M.scope==="local"){if(M.id==="local.theme")return!0;try{return localStorage.getItem(M.key)!==null}catch{return!1}}return M.pluginId!==void 0?h[M.id]!==void 0||Um(F.get(M.pluginId)?.[M.key])!==void 0:h[M.key]!==void 0||cT(f,M.key)},he=M=>{v(M);try{localStorage.setItem(Vl,M)}catch{}},pe=M=>{R(H=>{const X=new Set(H);X.has(M)?X.delete(M):X.add(M);try{localStorage.setItem(Vg,JSON.stringify([...X]))}catch{}return X})},Me=M=>{N(M),$.current[M]?.scrollIntoView({behavior:"smooth",block:"start"})};u.useEffect(()=>{if(!e)return;const M=A.find(re=>re.id===e);if(!M)return;N(M.pluginId!==void 0?`ext:${M.pluginId}`:M.category);const H=M.scope;v(re=>{if(re===H)return re;try{localStorage.setItem(Vl,H)}catch{}return H});const X=setTimeout(()=>{C.current?.querySelector(`[data-setting-id="${CSS.escape(e)}"]`)?.scrollIntoView({behavior:"smooth",block:"center"}),I(e)},100),Y=setTimeout(()=>I(void 0),ET+100);return()=>{clearTimeout(X),clearTimeout(Y)}},[e,A]);const oe=()=>{if(j){_("");return}s()},je=M=>M.view==="connection"?o.jsx(vT,{onOpenGateway:()=>r({domain:"gateway"})}):M.view==="advancedConfig"?o.jsx(u.Suspense,{fallback:o.jsx(Ke,{label:a("settings.dialog.loading")}),children:o.jsx(CT,{})}):o.jsx(xT,{defaultExpanded:e==="local.designLab"}),Ee=M=>o.jsx("div",{className:E===M.id?"rounded-sm ring-2 ring-accent transition-shadow":void 0,children:o.jsx(kT,{def:M,value:V[M.id]??"",modified:ee(M),disabled:M.scope!=="local"&&Ne,disabledReason:M.scope!=="local"?ce:void 0,saving:g.savingKey===M.id,query:W.text,envOverride:se(M),configured:we(M),onSave:(H,X)=>{g.save(H,X,y==="project"?"project":"user")},onReset:H=>{g.reset(H,y==="project"?"project":"user")},onReloadPlugin:M.restartRequired===!0?()=>{g.reloadPlugin()}:void 0,children:M.type==="view"?je(M):void 0})},M.id),Ce=M=>{const H=[];let X;for(const Y of M)Y.group!==void 0&&Y.group!==X&&H.push(o.jsx("h4",{className:"mt-3 mb-1 border-t border-line pt-2 text-xs font-medium tracking-wider text-muted uppercase",children:a(`settings.group.${Y.group}`)},`group-${Y.group}`)),X=Y.group,H.push(Ee(Y));return H},U=()=>y!=="local"&&ne&&!f?d.status==="error"?o.jsx(Ve,{message:d.error,onRetry:m}):o.jsx(Ke,{label:a("settings.dialog.loading")}):le.length===0?o.jsxs("div",{className:"flex flex-col items-start gap-2 p-4",children:[o.jsx("p",{className:"text-sm text-muted",children:a("settings.dialog.noMatches")}),o.jsx(G,{variant:"link",className:"text-sm",onClick:()=>_(""),children:a("settings.dialog.clearFilters")})]}):o.jsxs(o.Fragment,{children:[!K&&l&&o.jsx(st,{message:a("settings.dialog.configUnavailable"),onRetry:m}),J.filter(M=>Z||M.category.id===k).map(M=>o.jsxs("div",{ref:H=>{$.current[M.category.id]=H},children:[o.jsx("h3",{className:"sticky top-0 bg-raised py-1 text-sm font-medium text-muted",children:a(M.category.titleKey)}),Ce(M.items)]},M.category.id)),z.filter(M=>Z||k==="extensions"||M.id===k).map(M=>o.jsxs("div",{ref:H=>{$.current[M.id]=H},children:[o.jsxs("h3",{className:"sticky top-0 bg-raised py-1 text-sm font-medium text-muted",children:[a("settings.category.extensions")," › ",M.label]}),M.items.map(Ee)]},M.id))]}),q=[{id:"user",label:a("settings.dialog.tabUser")},{id:"project",label:a("settings.dialog.tabProject")},{id:"local",label:a("settings.dialog.tabLocal")}];return o.jsxs(tn,{size:"xl",label:a("settings.title"),closeLabel:a("common.close"),onClose:oe,className:"h-[min(86dvh,var(--modal-max-h))] max-compact:-m-3 max-compact:h-dvh max-compact:max-h-none max-compact:max-w-none max-compact:rounded-none",bodyClassName:"grow overflow-hidden",children:[o.jsx("div",{className:"flex items-center gap-1",role:"tablist","aria-label":a("settings.title"),children:q.map(M=>o.jsx("button",{type:"button",role:"tab","aria-selected":y===M.id,className:`rounded-sm px-3 py-1 text-sm transition-colors ${y===M.id?"bg-accent-soft text-accent-ink":"bg-transparent text-muted hover:bg-hover"}`,onClick:()=>he(M.id),children:M.label},M.id))}),o.jsx(ST,{query:j,onQueryChange:_,pluginIds:b.map(M=>M.pluginId)}),o.jsxs("div",{className:"flex min-h-0 grow gap-4 max-compact:flex-col max-compact:gap-2",children:[o.jsx("aside",{className:"w-48 shrink-0 overflow-y-auto border-r border-line pr-2 max-compact:hidden",children:o.jsx($m,{nodes:me,activeId:k,onSelect:Me,collapsedIds:T,onToggleCollapse:pe})}),o.jsxs("div",{className:"flex min-w-0 grow flex-col gap-2",children:[o.jsx("div",{className:"compact:hidden",children:o.jsx($m,{nodes:me,activeId:k,onSelect:Me,compact:!0,collapsedIds:T,onToggleCollapse:pe})}),o.jsx("div",{ref:C,className:"min-h-0 grow overflow-y-auto overscroll-contain pr-1",children:U()})]})]})]})}function MT({paletteOpen:e,paletteItems:t,entities:n,paletteQuery:s,onClosePalette:r,onExecutePalette:i,helpOpen:l,onCloseHelp:c,pendingAction:d,onClearPending:m,onConfirmPending:f,settingsRoute:h,onCloseSettings:p,onNavigate:g}){return o.jsxs(o.Fragment,{children:[h&&o.jsx(AT,{focusKey:h.focusKey,initialQuery:h.query,initialCategory:h.category,onClose:p,onNavigate:g}),e&&o.jsx(sT,{items:t,entities:n,initialQuery:s,onClose:r,onExecute:i}),l&&o.jsxs(tn,{label:a("app.help.title"),onClose:c,children:[o.jsx("h2",{className:"modal-title",children:a("app.help.title")}),o.jsxs("dl",{className:"shortcut-list",children:[o.jsxs("dt",{children:[o.jsx("kbd",{className:"kbd",children:"Ctrl/Cmd"})," + ",o.jsx("kbd",{className:"kbd",children:"K"})]}),o.jsx("dd",{children:a("app.help.openClose")}),o.jsx("dt",{children:o.jsx("kbd",{className:"kbd",children:"/"})}),o.jsx("dd",{children:a("app.help.actionMode")}),o.jsxs("dt",{children:[o.jsx("kbd",{className:"kbd",children:"↑"})," / ",o.jsx("kbd",{className:"kbd",children:"↓"})]}),o.jsx("dd",{children:a("app.help.move")}),o.jsx("dt",{children:o.jsx("kbd",{className:"kbd",children:"Enter"})}),o.jsx("dd",{children:a("app.help.execute")}),o.jsx("dt",{children:o.jsx("kbd",{className:"kbd",children:"Esc"})}),o.jsx("dd",{children:a("app.help.close")})]}),o.jsx("div",{className:"modal-actions",children:o.jsx(G,{variant:"primary","data-autofocus":!0,onClick:c,children:a("common.close")})})]}),d?.confirm&&o.jsx(In,{title:d.confirm.title,body:o.jsx("p",{children:d.confirm.body}),confirmLabel:d.confirm.confirmLabel,danger:!0,onConfirm:f,onCancel:m})]})}function Ya(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function PT(e){if(!Ya(e))return!1;const t=Ya(e.config)?e.config:e,n=Ya(t.ui)?t.ui:void 0;return(n?.showArchived??n?.show_archived)===!0}function oa(e){return e!=null&&e.archived_at!==void 0}function Ts(e){return(e?.state??"").trim().toLowerCase()==="closed"}function ad(e,t,n){return t?[...e]:e.filter(s=>!n(s))}function qT(e,t){return e.reduce((n,s)=>t(s)?n+1:n,0)}function ld(e,t,n){return t?0:qT(e,n)}function OT(e,t){return ad(e,t,oa)}function DT(e,t){return ad(e,t,n=>Ts(n.member))}function HT(e,t){return ad(e,t,Ts)}function cd(e){return e==="team"?"teams.card.archived":"agents.card.closed"}function Gg(e,t){if(t)return e==="team"?"archive.notice.team":"archive.notice.agent"}function $T(e){const t=new Set;for(const n of e)if(n.node.current)for(const s of n.rosters)for(const r of s.members)r.session_id&&Ts(r)&&t.add(r.session_id);return t}const FT=250;function dd(e){return e.type.startsWith("agent.")||e.type.startsWith("run.")}function Sr(e,t,n=""){const[s,r]=u.useState(0),i=u.useRef(t);i.current=t;const l=u.useRef(-1),c=u.useRef(void 0);return u.useEffect(()=>{window.clearTimeout(c.current),c.current=void 0;const{entries:d}=e.getSnapshot();let m=-1;for(const f of d)f.seq>m&&(m=f.seq);l.current=m},[n,e]),u.useEffect(()=>{const d=()=>{const{entries:f}=e.getSnapshot();if(f.length===0)return;let h=-1;for(const b of f)b.seq>h&&(h=b.seq);h<l.current&&(l.current=-1);let p=l.current,g=!1;for(const b of f)b.seq<=l.current||(b.seq>p&&(p=b.seq),i.current(b)&&(g=!0));l.current=p,g&&(window.clearTimeout(c.current),c.current=window.setTimeout(()=>{c.current=void 0,r(b=>b+1)},FT))},m=e.subscribe(d);return()=>{m(),window.clearTimeout(c.current),c.current=void 0}},[e]),s}function ra(){return Qt(),wt(e=>PT(Se(e.config)))}const sr=new Map,Gl=new Set;let ia=0;function ud(){ia+=1;for(const e of[...Gl])e()}const Yg=new Map;function BT(e,t){Yg.set(e,t),ud()}function KT(e){u.useSyncExternalStore(md,()=>ia);const t=Jg(e);return t===""?void 0:Yg.get(t)}function WT(e,t){sr.set(e,t),ud()}function UT(e){let t=!1;for(const[n,s]of[...sr])s.pluginId===e&&(sr.delete(n),t=!0);t&&ud()}function Jg(e){return/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(e.trim())?.[1]?.toLowerCase()??""}function md(e){return Gl.add(e),()=>Gl.delete(e)}function Qg(e){u.useSyncExternalStore(md,()=>ia);const t=Jg(e);return t===""?void 0:sr.get(t)}function zT(){return u.useSyncExternalStore(md,()=>ia),[...sr.keys()]}const Xg=/^\s*(```+|~~~+)\s*([A-Za-z0-9_+-]*)\s*$/,Zg=/^\s{0,3}(#{1,6})\s+(.*)$/,eb=/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/,ri=/^\s{0,3}([-*+]|\d+[.)])\s+(.*)$/,Yl=/^\s{0,3}>\s?(.*)$/,VT=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/;function tb(e){return e.includes("|")&&VT.test(e)}function zm(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let s="",r=!1;for(let i=0;i<t.length;i+=1){const l=t[i];if(l==="\\"&&t[i+1]==="|"){s+="|",i+=1;continue}if(l==="`"){r=!r,s+=l;continue}if(l==="|"&&!r){n.push(s.trim()),s="";continue}s+=l}return n.push(s.trim()),n}function Vm(e,t){const n=e[t]??"";if(n.trim()===""||Xg.test(n)||Zg.test(n)||eb.test(n)||ri.test(n)||Yl.test(n))return!0;const s=e[t+1];return n.includes("|")&&s!==void 0&&tb(s)}function To(e){return(/^\s*/.exec(e)?.[0]??"").length}function Ci(e,t,n){const s=e.replace(/\r\n?/g,`
|
|
558
|
+
`).split(`
|
|
559
|
+
`),r=[];let i=0,l;if(n){l=[];let c=0;for(const d of s)l.push(c),c+=d.length+1}for(;i<s.length;){const c=s[i]??"";if(c.trim()===""){i+=1;continue}const d=l?.[i]??0,m=y=>{r.push(y),n?.push(d)},f=Xg.exec(c);if(f){const y=f[1]??"```",v=f[2]??"",j=[];for(i+=1;i<s.length;){const _=s[i]??"";if(_.trim().startsWith(y.slice(0,3))&&_.trim().length===y.length){i+=1;break}j.push(_),i+=1}m({type:"code",...v?{lang:v}:{},text:j.join(`
|
|
560
|
+
`)});continue}const h=Zg.exec(c);if(h){m({type:"heading",level:(h[1]??"#").length,text:(h[2]??"").trim()}),i+=1;continue}if(eb.test(c)){m({type:"hr"}),i+=1;continue}const p=s[i+1];if(c.includes("|")&&p!==void 0&&tb(p)){const y=i,v=zm(c),j=[];for(i+=2;i<s.length;){const S=s[i]??"";if(S.trim()===""||!S.includes("|"))break;j.push(zm(S)),i+=1}let _=i;for(;_<s.length&&(s[_]??"").trim()==="";)_+=1;if(t?.streaming===!0&&_>=s.length){m({type:"paragraph",text:s.slice(y,_).join(`
|
|
561
|
+
`)}),i=_;continue}m({type:"table",header:v,rows:j});continue}if(Yl.exec(c)){const y=[];for(;i<s.length;){const v=Yl.exec(s[i]??"");if(!v)break;y.push(v[1]??""),i+=1}m({type:"blockquote",text:y.join(`
|
|
562
|
+
`)});continue}const b=ri.exec(c);if(b){const y=To(c),v=/^\d/.test(b[1]??""),j=v?Number.parseInt(b[1]??"1",10):1,_=E=>{if(To(E)>=y+2)return!1;const I=ri.exec(E);return I!==null&&/^\d/.test(I[1]??"")===v},S=[];for(;i<s.length;){const E=s[i]??"";if(E.trim()===""){let I=i+1;for(;I<s.length&&(s[I]??"").trim()==="";)I+=1;const $=s[I];if($===void 0)break;if(To($)>=y+2||_($)){S.push(E),i+=1;continue}break}if(To(E)>=y+2||_(E)){S.push(E),i+=1;continue}break}const w=[];let k="",N=[],T=!1;const R=()=>{if(!T)return;const E=N.filter(D=>D.trim()!==""),I=E.length>0?E.reduce((D,O)=>Math.min(D,To(O)),Number.POSITIVE_INFINITY):0,$=N.map(D=>D.slice(I));let C=0;for(;C<$.length;){const D=$[C]??"";if(D.trim()===""){C+=1;continue}if(Vm($,C))break;k=`${k} ${D.trim()}`,C+=1}const L=$.slice(C),A=L.length>0?Ci(L.join(`
|
|
563
|
+
`),t):[];w.push({text:k,...A.length>0?{children:A}:{}})};for(const E of S){if(_(E)){R(),k=ri.exec(E)?.[2]??"",N=[],T=!0;continue}N.push(E)}R(),m({type:"list",ordered:v,...v&&j!==1?{start:j}:{},items:w});continue}const x=[];for(;i<s.length&&!Vm(s,i);)x.push((s[i]??"").trimEnd()),i+=1;x.length>0?m({type:"paragraph",text:x.join(`
|
|
564
|
+
`)}):i+=1}return r}function GT(e,t){const n=e.replace(/\r\n?/g,`
|
|
565
|
+
`);if(t&&t.blocks.length>0&&n.startsWith(t.source)){const i=t.starts[t.starts.length-2]??0,l=[],c=Ci(n.slice(i),{streaming:!0},l);if(c.length>0){const d=Math.max(0,t.blocks.length-2),m=[...t.blocks.slice(0,d),...c],f=[...t.starts.slice(0,d),...l.map(h=>i+h)];return{blocks:m,cache:{source:n,blocks:m,starts:f}}}}const s=[],r=Ci(n,{streaming:!0},s);return{blocks:r,cache:{source:n,blocks:r,starts:s}}}function nb(e){const t=e.trim();return t===""||t.includes("\\")||t.startsWith("//")?!1:/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)?/^(https?|mailto):/i.test(t):!0}const YT=2e4;function JT(e){if(e.length>YT)return[{type:"text",text:e}];const t=[];let n="";const s=()=>{n!==""&&(t.push({type:"text",text:n}),n="")};let r,i,l=0;for(;l<e.length;){const c=e[l];if(c==="`"){const d=e.indexOf("`",l+1);if(d===-1){n+=e.slice(l);break}s(),t.push({type:"code",text:e.slice(l+1,d)}),l=d+1;continue}if(c==="["){(r===void 0||r!==-1&&r<=l)&&(r=e.indexOf("]",l+1));const d=r;if(d===-1){n+=e.slice(l);break}if(e[d+1]==="("){if(e[d+2]==="<"){const f=e.indexOf(">",d+3);if(f!==-1&&e[f+1]===")"){const h=e.slice(d+3,f);if(h.length>0&&!/[\n]/.test(h)){s(),t.push({type:"link",text:e.slice(l+1,d),href:h}),l=f+2,r=void 0,i=void 0;continue}}}(i===void 0||i!==-1&&i<=d+1)&&(i=e.indexOf(")",d+2));const m=i;if(m!==-1&&m>d+2){const f=e.slice(d+2,m);if(!/\s/.test(f)){s();const h=e.slice(l+1,d);nb(f)||/^[A-Za-z][A-Za-z0-9+.-]*:/.test(f)?t.push({type:"link",text:h,href:f}):t.push({type:"text",text:h}),l=m+1,r=void 0,i=void 0;continue}}}n+=c,l+=1;continue}if(e.startsWith("**",l)){const d=e.indexOf("**",l+2);if(d>=l+3){const m=e.slice(l+2,d);if(!m.includes("*")){s(),t.push({type:"strong",text:m}),l=d+2;continue}}n+="**",l+=2;continue}if(c==="*"){const d=e.indexOf("*",l+1);if(d===-1){n+=e.slice(l);break}if(d>=l+2){const m=e.slice(l+1,d);if(!m.includes("*")){s(),t.push({type:"em",text:m}),l=d+1;continue}}n+=c,l+=1;continue}n+=c,l+=1}return s(),t}function QT({href:e,text:t}){const n=KT(e),s=Qg(e);if(n!==void 0)return o.jsx(n,{href:e,text:t});if(s!==void 0){const r=s.component;return o.jsx(r,{href:e,text:t,host:s.host})}return nb(e)?o.jsx("a",{href:e,target:e.startsWith("#")?void 0:"_blank",rel:"noreferrer noopener",children:t}):o.jsxs("span",{className:"markdown-link-plain",children:[t," (",e,")"]})}function XT({nodes:e}){return e.map((t,n)=>{switch(t.type){case"code":return o.jsx("code",{className:"rounded-xs bg-sunken px-1 py-px font-mono text-md",children:t.text},n);case"strong":return o.jsx("strong",{children:t.text},n);case"em":return o.jsx("em",{children:t.text},n);case"link":return o.jsx(QT,{href:t.href,text:t.text},n);default:return o.jsx(u.Fragment,{children:t.text},n)}})}function Hs(){return o.jsx("span",{className:"stream-caret pulse-soft","aria-hidden":"true"})}function Gm({text:e,label:t,hoverClass:n}){const s=is();return o.jsx("span",{className:be("absolute right-1 top-0.5 z-10 opacity-0 transition-opacity duration-150 focus-within:opacity-100 pointer-coarse:opacity-100",n),children:o.jsx(Cn,{label:t,className:"size-5 rounded-md bg-surface/90 shadow-elev-1 hover:bg-surface",onClick:()=>s(e),children:o.jsx(yt,{name:"copy",size:13})})})}const ZT=u.memo(function e({block:t,caret:n=!1}){switch(t.type){case"heading":{const s=`h${Math.min(6,Math.max(1,t.level))}`;return o.jsxs(s,{children:[$s(t.text),n&&o.jsx(Hs,{})]})}case"code":return o.jsxs("div",{className:"group/code relative mb-2.5 overflow-hidden rounded-sm bg-sunken",children:[t.lang&&o.jsx("span",{className:"block bg-deep px-2.5 py-1 font-mono text-2xs uppercase tracking-wider text-muted",children:t.lang}),o.jsx("pre",{className:"m-0 max-h-95 overflow-auto px-3 py-2.5 font-mono text-sm leading-normal whitespace-pre",children:o.jsxs("code",{children:[t.text,n&&o.jsx(Hs,{})]})}),o.jsx(Gm,{text:t.text,label:a("chat.code.copy"),hoverClass:"group-hover/code:opacity-100"})]});case"list":{const s=t.ordered?"ol":"ul";return o.jsx(s,{className:"pl-5",...t.start!==void 0?{start:t.start}:{},children:t.items.map((r,i)=>o.jsxs("li",{className:"my-0.75",children:[$s(r.text),r.children?.map((l,c)=>o.jsx(e,{block:l},c)),n&&i===t.items.length-1&&o.jsx(Hs,{})]},i))})}case"blockquote":return o.jsxs("blockquote",{className:"py-0.5 pl-2.5 text-muted",children:[$s(t.text),n&&o.jsx(Hs,{})]});case"table":return o.jsxs("div",{className:"group/table relative w-fit max-w-full",children:[o.jsx("div",{className:"max-w-full overflow-x-auto",children:o.jsxs("table",{className:"border-collapse text-md",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.header.map((s,r)=>o.jsx("th",{className:"bg-sunken px-2.25 py-1.25 text-left align-top font-semibold text-faint",children:$s(s)},r))})}),o.jsx("tbody",{children:t.rows.map((s,r)=>o.jsx("tr",{className:"hover:bg-hover",children:s.map((i,l)=>o.jsxs("td",{className:"px-2.25 py-1.25 text-left align-top",children:[$s(i),n&&r===t.rows.length-1&&l===s.length-1&&o.jsx(Hs,{})]},l))},r))})]})}),o.jsx(Gm,{text:bg(t.header,t.rows),label:a("chat.table.copy"),hoverClass:"group-hover/table:opacity-100"})]});case"hr":return o.jsx("hr",{className:"my-3 h-px border-0 bg-line"});default:return o.jsxs("p",{children:[$s(t.text),n&&o.jsx(Hs,{})]})}});function $s(e){return e.split(`
|
|
566
|
+
`).map((n,s)=>o.jsxs(u.Fragment,{children:[s>0&&o.jsx("br",{}),o.jsx(XT,{nodes:JT(n)})]},s))}function jr({text:e,className:t,streaming:n=!1}){const s=tg(e,n);return o.jsx(eE,{text:s,className:t,streaming:n})}const eE=u.memo(function({text:t,className:n,streaming:s}){const r=u.useRef(null),i=u.useMemo(()=>{if(!s)return r.current=null,Ci(t);const l=GT(t,r.current);return r.current=l.cache,l.blocks},[t,s]);return o.jsx("div",{className:`markdown${n?` ${n}`:""}`,children:i.map((l,c)=>o.jsx(ZT,{block:l,caret:s&&c===i.length-1},c))})}),Mo={reasoning:!1,tools:!0,environment:!0,source:!0,system:!1};function ii(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function tE(e){if(!ii(e))return;const t=ii(e.config)?e.config:e;return ii(t.ui)?t.ui:void 0}function Eo(e,t){return typeof e=="boolean"?e:t}function sb(e){const t=tE(e),n=t?.messageVisibility??t?.message_visibility,s=ii(n)?n:void 0,r=t?.showInternalEvents??t?.show_internal_events,i=typeof r=="boolean"?r:!1;return{reasoning:Eo(t?.showReasoning??t?.show_reasoning,Mo.reasoning),tools:Eo(s?.tools,Mo.tools),environment:Eo(s?.environment,Mo.environment),source:Eo(s?.source,Mo.source),system:Eo(s?.system,i)}}const nE=["source","notice","subscription","limit","compaction","other"];function ob(e){return nE.includes(e)}function sE(e){return{source:e.source===!0,notice:e.environment===!0,subscription:e.system===!0,limit:e.system===!0,compaction:e.system===!0,other:e.system===!0}}const Ym="vessel:";function Dn(e){const t=e.name;if(typeof t!="string"||!t.startsWith(Ym))return;const n=t.slice(Ym.length);return ob(n)?n:"other"}function oE(e){return ob(e)?e:Dn({name:e})}function ro(e,t){const n=oE(t);return n===void 0||e[n]}function eo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fd(e){if(!eo(e))return;const t=eo(e.config)?e.config:e;return eo(t.ui)?t.ui:void 0}function rb(e){const t=fd(e)?.verbosity;return t==="minimal"||t==="debug"?t:"normal"}function rE(e){const t=fd(e);return(t?.showInternalEvents??t?.show_internal_events)===!0}function hd(e){const t=fd(e),n=t?.errorLevel??t?.error_level;return{verbosity:rb(e),showInternalEvents:rE(e),errorLevel:n==="all"?"all":"user",messageVisibility:sb(e)}}function iE(e){if(!eo(e))return!1;const t=eo(e.config)?e.config:e,n=eo(t.observability)?t.observability:void 0;return(n?.showProcessErrors??n?.show_process_errors)===!0}function ib(e){return e.messageVisibility.system||e.verbosity==="debug"}function aa(){const e=wt(r=>Se(r.config)),t=u.useMemo(()=>{const r=sb(e);return{...r,system:r.system||rb(e)==="debug"}},[e]),n=u.useMemo(()=>sE(t),[t]),s=u.useCallback(r=>ro(n,r),[n]);return{visibility:n,isVisible:s,messageVisibility:t}}const aE=8;function pd({entries:e,activeKey:t=null,onJump:n,className:s}){const r=u.useRef(null),i=u.useRef(null),l=e.length>0;return u.useEffect(()=>{const c=r.current,d=i.current;if(!c||!d)return;const m=()=>{const h=Math.max(0,(c.clientHeight-aE)/2);d.style.paddingBlock=`${h}px`};if(m(),typeof ResizeObserver>"u")return;const f=new ResizeObserver(m);return f.observe(c),()=>f.disconnect()},[l]),u.useEffect(()=>{const c=r.current,d=i.current;if(!c||!d||t===null)return;let m=null;for(const h of d.children){const p=h;if(p.dataset.indexEntryKey===t){m=p;break}}if(!m)return;const f=m.offsetTop-(c.clientHeight-m.offsetHeight)/2;c.scrollTo({top:f})},[t]),e.length===0?null:o.jsx("nav",{ref:r,className:s?`conversation-index ${s}`:"conversation-index","aria-label":a("chat.index.label"),children:o.jsx("div",{ref:i,className:"conversation-index-track",children:e.map(c=>{const d=c.key===t;return o.jsx(xt,{label:c.preview||c.label,className:"line-clamp-5 break-words",children:o.jsx("button",{type:"button",className:"conversation-index-dot","data-index-entry-key":c.key,"data-active":d?"true":void 0,"aria-label":c.label,"aria-current":d?"true":void 0,onClick:()=>n?.(c.key)})},c.key)})})})}const Jm="agent:",Qm="tool:";function la(e){if(typeof e=="string"){if(e.startsWith(Jm)){const t=e.slice(Jm.length);return t.length>0?{kind:"agent",alias:t}:void 0}if(e.startsWith(Qm)){const t=e.slice(Qm.length);return t.length>0?{kind:"tool",alias:t}:void 0}}}function ca(e){return la(e)?.alias}const ab="ask:answer",lE="[ask answer ",cE="[ask_user answer ",dE=[lE,cE];function uE(e){return e.role==="user"&&e.name===ab}const mE=/^\d+\.\s+([^:\n]{1,400}):\s*([\s\S]*)$/,fE="(",hE=")";function pE(e){if(!e.endsWith(hE))return{label:e};const t=e.indexOf(fE);if(t<=0)return{label:e};const n=e.slice(t+1,-1).trim();return n.length===0?{label:e}:{label:e.slice(0,t).trim(),question:n}}function lb(e){const t=e.trim();if(t.length===0)return;const n=t.split(/\r?\n/);let s,r;const i=n[0]??"",l=dE.find(f=>i.startsWith(f));if(l!==void 0){const f=i.indexOf("]",l.length),p=(f===-1?void 0:i.slice(l.length,f))?.trim();if(p!==void 0&&p.length>0){const g=p.split(",").map(b=>b.trim()).filter(b=>b.length>0);s=g[0],g.length>1&&(r=g.length-1)}}const c=[];for(const f of n){const h=mE.exec(f.trim());if(h===null)continue;const{label:p,question:g}=pE((h[1]??"").trim()),b=(h[2]??"").trim();p.length===0||b.length===0||c.push({label:p,text:b,...g!==void 0?{question:g}:{}})}if(c.length===0)return;const d=c[0];if(d===void 0)return;const m=d.label.length>40?`${d.label.slice(0,40)}…`:d.label;return{...s!==void 0?{requestId:s}:{},...r!==void 0?{extraRequestIds:r}:{},summary:m,rows:c}}const cb="name";function gE(e){return e==="name"||e==="compact"||e==="full"?e:cb}const bE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function db(e){return bE.test(e)}function Ja(e){return db(e)?e.slice(0,8):e}function Xm(e,t,n,s,r){if(n==="full"||!db(e))return e;if(t==="node"){if(n==="compact")return Ja(e);const l=s?.node?.get(e);return l!==void 0&&l!==""?l:Ja(e)}const i=s?.principal?.get(e);return i!==void 0&&i!==""?i:r?e:Ja(e)}function Ti(e,t=cb,n,s){const r=s?.replyable===!0,i=e.principal!==void 0&&e.principal!==""?Xm(e.principal,"principal",t,n,r):void 0,l=e.node!==void 0&&e.node!==""?Xm(e.node,"node",t,n,r):void 0,c=e.team!==void 0&&e.team!==""?e.team:void 0,d=[l,c].filter(m=>m!==void 0).join(":");return i===void 0?d:d===""?i:`${i}@${d}`}const ub=[...Object.keys(zc),"inbox","selfcard"],gd=11,vE="notice",yE="source";function or(e,t){if(e===vE)return jE(t);if(e===yE)return EE(t)}const xE=/^\[runtime\]\s*/i,Zm=/^\(not applied\)\s*/i,ef=/^·\s*/,tf=ub.join("|"),wE=new RegExp(`^(?:\\[(${tf})\\]|(${tf})\\b)`,"i");function kE(e){let t=e.trim();if(t.length===0)return;t=t.replace(xE,"");const n=ef.test(t);t=t.replace(ef,"");let s=!0;if(Zm.test(t)&&(s=!1,t=t.replace(Zm,"")),t=t.trim(),t.length!==0)return{id:"",scope:n?"context":SE(t),ok:s,text:t}}function SE(e){const t=wE.exec(e),n=t?.[1]??t?.[2];if(n===void 0)return"context";const s=n.toLowerCase();return ub.includes(s)?s:"context"}function jE(e){const t=[];for(const i of e.split(`
|
|
567
|
+
`)){const l=kE(i);l!==void 0&&t.push(l)}const n=t[0];if(n===void 0)return;const s=t.slice(0,gd),r=t.length-s.length;return{scope:n.scope,ok:s.every(i=>i.ok),lines:s.map((i,l)=>({...i,id:String(l)})),count:1,...r>0?{droppedLines:r}:{}}}const _E=/location="([^"]+)"/,NE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function da(e){const t=e.trim().replace(/^federation:/,"");if(t.length===0)return;const n=t.indexOf("@");if(n<0)return{principal:t};const s=t.slice(0,n),r=t.slice(n+1);if(s.length===0||r.length===0)return;const i=r.indexOf(":");if(i>=0){const l=r.slice(0,i),c=r.slice(i+1);return{principal:s,...l.length>0?{node:l}:{},...c.length>0?{team:c}:{}}}return NE.test(r)?{principal:s,node:r}:{principal:s,team:r}}function CE(e,t,n){return e.scope!=="source"?e:{...e,lines:e.lines.map(s=>({...s,text:TE(s.text,t,n)}))}}function TE(e,t,n){for(const r of["principal","node","team"]){const i=`${r}: `;if(e.startsWith(i)){const l=e.slice(i.length);return i+Ti(r==="principal"?{principal:l}:r==="node"?{node:l}:{team:l},t,n)}}if(e.includes("<")||e.includes('"'))return e;const s=da(e);return s!==void 0?Ti(s,t,n):e}function EE(e){const t=e.trim();if(t.length===0)return;const n=_E.exec(e)?.[1],s=[];if(n!==void 0&&n.length>0){s.push(n);const r=da(n);r!==void 0&&(s.push(`principal: ${r.principal}`),r.node!==void 0&&s.push(`node: ${r.node}`),r.team!==void 0&&s.push(`team: ${r.team}`))}else s.push(t);return{scope:"source",ok:!0,lines:s.map((r,i)=>({id:String(i),scope:"source",ok:!0,text:r})),count:1,blocks:[{labelKey:"chat.env.source.raw",text:e}]}}function IE(e,t){const n=[...e.lines,...t.lines],s=n.slice(0,gd),r=(e.droppedLines??0)+(t.droppedLines??0)+(n.length-s.length),i=[...e.blocks??[],...t.blocks??[]];return{scope:e.scope,ok:e.ok&&t.ok,lines:s.map((l,c)=>({...l,id:String(c)})),count:e.count+t.count,...r>0?{droppedLines:r}:{},...i.length>0?{blocks:i}:{}}}function RE(e,t){const n=e.trim();if(n.length===0)return;const s=n.indexOf(":"),r=(s<0?n:n.slice(0,s)).trim();if(r.length===0)return;const i=s<0?void 0:n.slice(s+1).trim();return{id:String(t),key:r,...i!==void 0&&i.length>0?{value:i}:{}}}function LE(e){const t=[];for(const[n,s]of e.entries()){const r=RE(s,n);r!==void 0&&t.push(r)}return t}function AE(e,t){const n=[...e],s=n.slice(0,gd);return{scope:"context",ok:!0,lines:s.map((r,i)=>({id:String(i),scope:"context",ok:!0,text:r})),count:1,...n.length>s.length?{droppedLines:n.length-s.length}:{},...t.length>0?{blocks:[...t]}:{}}}function ME(e){return e.scope!=="inbox"||e.lines.length===0?!1:e.lines.every(t=>/^\[inbox\] \d+ pending$/i.test(t.text.trim()))}function PE(e){const t=[],n=new Map;return e.forEach((s,r)=>{if(s.role==="assistant"){for(const m of s.tool_calls??[]){const f=typeof m.id=="string"&&m.id.length>0?m.id:void 0,h=typeof m.function?.name=="string"&&m.function.name.length>0?m.function.name:"tool",p={key:`history-tool-${f??r}`,...f!==void 0?{callId:f}:{},name:h,...m.function?.arguments!==void 0?{args:m.function.arguments}:{},status:"neutral",paired:!1,...s.timestamp!==void 0?{startedAt:s.timestamp}:{}};t.push(p),f!==void 0&&n.set(f,p)}return}if(s.role!=="tool")return;const i=typeof s.tool_call_id=="string"&&s.tool_call_id.length>0?s.tool_call_id:void 0,l=typeof s.content=="string"?s.content:"",c=i===void 0?void 0:n.get(i);if(c!==void 0&&!c.paired){c.output=l,c.paired=!0,s.timestamp!==void 0&&(c.endedAt=s.timestamp);const m=s.truncated?.content?.limit;typeof m=="number"&&Number.isFinite(m)&&m>0&&(c.truncatedLimitBytes=m),c.name==="tool"&&typeof s.name=="string"&&s.name.length>0&&(c.name=s.name);return}const d=s.truncated?.content?.limit;t.push({key:`history-tool-${r}`,...i!==void 0?{callId:i}:{},name:typeof s.name=="string"&&s.name.length>0?s.name:"tool",output:l,status:"neutral",paired:!1,...typeof d=="number"&&Number.isFinite(d)&&d>0?{truncatedLimitBytes:d}:{}})}),t}function qE(e,t,n){if(e!=="inbox"&&e!=="tool")return[];if(t!==null&&typeof t=="object"){const l=t.action;if(typeof l=="string"&&l!=="read"&&l!=="claim")return[]}let s=n;if(typeof n=="string")try{s=JSON.parse(n)}catch{return[]}if(s===null||typeof s!="object")return[];const r=s;if(typeof r.read!="number"||!Array.isArray(r.messages))return[];const i=[];for(const l of r.messages){if(l===null||typeof l!="object")continue;const c=l;typeof c.id!="string"||typeof c.text!="string"||i.push({id:c.id,text:c.text,source:typeof c.source=="string"?c.source:"system",...typeof c.ts=="number"?{ts:c.ts}:{}})}return i}const ns="human",mb="ask",Jl="bash",fb="system";function nf(e){return e.from!==ns&&e.status==="held"}const OE="agent:",sf=8;function Ql(e){if(typeof e!="string")return;const t=e.trim();return t===""?void 0:t}function kn(e){const t=e.trim();return t.length<=sf?t:`${t.slice(0,sf)}…`}const Xl="federation:",hb=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function DE(e){return e.startsWith(Xl)?e.slice(Xl.length):e}function HE(e){const t=DE(e.trim()).split("@")[0]?.trim();return t!==void 0&&t!==""?t:void 0}function $E(e){return hb.test(e)?kn(e):e}function FE(e,t){const n=typeof e.from=="string"?e.from.trim():"";if(n==="")return;if(n===ns)return t.humanLabel;if(n===mb)return t.askLabel??kn(n);if(n===Jl)return t.bashLabel??kn(n);if(n===fb)return t.systemLabel??kn(n);const s=Ql(e.from_name)??Ql(t.fallbackName);if(s!==void 0)return(t.agentLabel??of)(s);if(n.startsWith(Xl)){const r=HE(n);if(r!==void 0)return hb.test(r)?kn(r):(t.agentLabel??of)(r)}return kn(n)}function of(e){return`${OE}${e}`}function BE(e){for(const t of e.entries){const n=Ql(t.from_name);if(n!==void 0)return n}}const pb=3;function KE(e){return[...e].sort((t,n)=>{const s=t.status==="held",r=n.status==="held";return s!==r?s?-1:1:t.ts!==n.ts?t.ts-n.ts:t.message_id<n.message_id?-1:t.message_id>n.message_id?1:0})}function WE(e,t){if(e.from!==t.from||e.status!==t.status)return!1;const n=e.summary.trim(),s=t.summary.trim();if(n.length===0||s.length===0)return!1;if(n===s)return!0;const r=n.length<=s.length?n:s;return(n.length<=s.length?s:n).includes(r)}function UE(e){const t=[];let n,s;for(const r of e){if(n!==void 0&&s!==void 0&&WE(s,r)){n.entries.push(r),s=r;continue}n={key:r.message_id,head:r,entries:[r]},t.push(n),s=r}return t}function zE(e,t=pb){const n=KE(e),s=UE(n).slice(0,t),r=s.reduce((i,l)=>i+l.entries.length,0);return{ordered:n,preview:s,hidden:Math.max(0,n.length-r),total:n.length}}const bd=new Map,VE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function GE(e){return VE.test(e.trim())}function Ei(e){if(typeof e!="string")return;const t=e.trim();return t===""?void 0:t}function YE(e){const t=new Map,n=(r,i)=>{const l=Ei(r);l!==void 0&&(t.has(l)||t.set(l,i))},s=r=>{const i=Ei(r.name);if(i!==void 0){n(r.id,i),n(r.agent_id,i),n(r.session_id,i);for(const l of r.bodies??[])n(l?.session_id,i),n(l?.body_id,i);for(const l of r.body_history??[])n(l?.session_id,i)}};for(const r of e){for(const i of r.agents??[])s(i);for(const i of r.rosters??[])for(const l of i.members??[])s(l)}return t}function gb(e){const t=Ei(e);if(t!==void 0)return GE(t)?kn(t):t}function ys(e,t=bd){const n=Ei(e);if(n!==void 0)return t.get(n)??gb(n)}const bb=3;function JE(e,t=bd){const n=[];for(const s of e){const r=ys(s,t);r!==void 0&&n.push(r)}if(n.length!==0)return n.length<=bb?n.join("、"):`${String(n.length)} 名成员(${n[0]}、${n[1]} 等)`}function rf(e){const t=e.tool_call_id;return typeof t=="string"&&t.length>0?t:void 0}function af(e){const t=e.tool_name;return typeof t=="string"&&t.length>0?t:void 0}function QE(e){const t=e.duration_ms;return typeof t=="number"?t:void 0}function lf(e){const t=e.error;if(typeof t=="string")return t;if(t!==void 0)return String(t)}function XE(e,t,n){if(t!==void 0){const r=e.findIndex(i=>i.callId===t);if(r>=0)return e.splice(r,1)[0]}if(n===void 0)return;const s=e.findIndex(r=>r.card.name===n&&(t===void 0||r.callId===void 0));return s>=0?e.splice(s,1)[0]:void 0}function ZE(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}function vd(e){if(e!=null){if(typeof e=="string"){const t=e.trim();if(!t.startsWith("{"))return e;try{const n=JSON.parse(t);return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:e}catch{return e}}return typeof e=="object"&&!Array.isArray(e)?e:ZE(e)}}function Qa(e,t){for(const n of t){const s=e[n];if(typeof s=="string"&&s.trim().length>0)return s;if(typeof s=="number"&&Number.isFinite(s))return String(s)}}function vb(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zt(e,t){if(typeof e!="string")return;const n=e.replace(/\s+/g," ").trim();if(n.length!==0)return n.length>t?`${n.slice(0,t)}…`:n}function eI(e){if(typeof e=="number"&&Number.isFinite(e))return Math.trunc(e);if(typeof e!="string")return;const t=e.trim();return/^\d+$/.test(t)?Number(t):void 0}function cf(e){return Array.isArray(e)?e.length:void 0}function io(e){if(!Array.isArray(e))return[];const t=[];for(const n of e)typeof n=="string"&&n.trim().length>0&&t.push(n.trim());return t}function tI(e){if(e===void 0)return;const t=e.indexOf("@");return t>0?e.slice(0,t):e}function yb(e){if(typeof e!="string")return;const t=e.trim(),n=t.indexOf("@");if(n<=0)return;const s=t.slice(n+1),r=s.indexOf(":");if(!(r<=0||r===s.length-1))return{principal:t.slice(0,n),node:s.slice(0,r),team:s.slice(r+1),raw:t}}function nI(e){const t=vd(e);if(t===void 0||typeof t=="string")return;const n=[typeof t.to=="string"?t.to:void 0,typeof t.member=="string"?t.member:void 0,io(t.members)[0],typeof t.name=="string"?t.name:void 0];for(const s of n){const r=yb(s);if(r!==void 0)return r}}function sI(e){let t=e;if(typeof e=="string"){const s=e.trim();if(!s.startsWith("{"))return;try{t=JSON.parse(s)}catch{return}}if(!vb(t))return;const n=t.resolved_to;return typeof n=="string"&&n.trim()!==""?n:void 0}function Xa(e,t){return ys(tI(e),t)}function oI(e,t){const n=Zt(e.action,16);if(n===void 0)return;if(n==="create"||n==="hire"){const c=cf(e.members),d=Zt(e.name,48);return c!==void 0&&c>1?`${n} → ${c} 名成员`:d!==void 0?`${n} → ${d}`:c===1?`${n} → 1 名成员`:n}const s=io(e.members),r=Xa(Zt(e.to,64),t)??Xa(Zt(e.member,64),t)??ys(s[0],t)??Xa(Zt(e.name,64),t),i=r===void 0?n:`${n} → ${r}`,l=cf(e.messages);if(l!==void 0&&l>0)return`${i}(${l} 条)`;if(n!=="close")return i;if(s.length>bb){const c=JE(s,t);if(c!==void 0)return`${n} → ${c}`}return s.length>1?`${i}(共 ${s.length} 名)`:i}function rI(e,t){const n=Zt(e.action,16);if(n===void 0)return;if(n==="insert"){const l=Zt(e.content,40);return l===void 0?n:`${n} → ${l}`}const s=[...io(e.ids),...io(e.message_ids)],r=s[0];if(r!==void 0)return s.length>1?`${n} → ${s.length} 条`:`${n} → ${ys(r,t)??r}`;const i=eI(e.limit);return i!==void 0&&i>0?`${n} → 最多 ${i} 条`:n}function iI(e){const t=Zt(e.action,16);if(t===void 0)return;if(t==="list")return t;const n=Zt(e.node,96),s=io(e.nodes),r=n===void 0?s:[n,...s];if(r.length>0)return r.length===1?`${t} → ${r[0]} (health)`:`${t} → ${r.length} 个节点(health)`;const i=Zt(e.path,96),l=io(e.paths),c=i===void 0?l:[i,...l],d=c[0];if(c.length===0){const m=gb(Zt(e.id,96));return m===void 0?t:`${t} → ${m}`}return c.length===1?`${t} → ${d}`:`${t} → ${c.length} 个文件(${d} 等)`}function aI(e){const t=Array.isArray(e.questions)?e.questions:[],n=t.length;if(n===0)return;const s=t[0],r=vb(s)?Zt(s.header,24)??Zt(s.question,32):void 0;return r===void 0?`ask → ${n} 个问题`:n>1?`ask → ${r}(共 ${n} 个问题)`:`ask → ${r}`}const lI={agent:oI,inbox:rI,subscribe:iI,ask:aI},cI=["command","cmd","script","path","file_path","pattern","query","regex","task","prompt","url","name"],xb=96;function dI(e,t,n=xb,s=bd){const r=vd(t);if(r===void 0)return"";let i;if(typeof r=="string")i=r;else{const d={bash:["command","cmd","script"],read:["path","file_path"],edit:["path","file_path"],write:["path","file_path"],grep:["pattern","query","regex"],search:["query","pattern"]};i=lI[e]?.(r,s)??Qa(r,d[e]??[])??Qa(r,["command","path","pattern","query","task","url","name"])??Qa(r,cI)}if(!i)return"";const c=(e==="bash"?i.split(`
|
|
568
|
+
`)[0]??"":i.replace(/\s+/g," ")).trim();return c.length>n?`${c.slice(0,n)}…`:c}function df(e){return e.replace(/\r\n/g,`
|
|
569
|
+
`).split(`
|
|
570
|
+
`)}function uI(e,{context:t=2,maxLines:n=200}={}){const s=vd(e);if(!s||typeof s=="string")return null;const r=s.old_string,i=s.new_string;if(typeof r!="string"||typeof i!="string")return null;const l=df(r),c=df(i);let d=0;for(;d<l.length&&d<c.length&&l[d]===c[d];)d+=1;let m=0;for(;m<l.length-d&&m<c.length-d&&l[l.length-1-m]===c[c.length-1-m];)m+=1;const f=[];for(const g of l.slice(Math.max(0,d-t),d))f.push({kind:"context",text:g});for(const g of l.slice(d,l.length-m))f.push({kind:"remove",text:g});for(const g of c.slice(d,c.length-m))f.push({kind:"add",text:g});for(const g of l.slice(l.length-m,l.length-m+t))f.push({kind:"context",text:g});if(!(r!==i))return null;const p=f.length>n;return{...typeof s.path=="string"?{path:s.path}:{},lines:p?f.slice(0,n):f,truncated:p}}const wb=20,mI=8*1024,uf=200*1024;function yd(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}function fI(e,t=wb,n=mI){const s=e===""?[]:e.split(`
|
|
571
|
+
`),r=s.length,i=s.slice(0,t).join(`
|
|
572
|
+
`),l=i.length>n?i.slice(0,n):i;return{preview:l,truncated:r>t||e.length>l.length,totalLines:r,totalBytes:e.length}}function kb(e){const t=[],n=[];for(const s of e){if(s.kind!=="event"){t.push(s);continue}const{event:r}=s;if(r.type==="tool.call.started"){const i=rf(r.data),l={kind:"tool",key:s.key,callId:i,name:af(r.data)??"tool",status:"running",args:r.data.arguments,truncated:r.data.truncated===!0?!0:void 0,startedAt:r.ts};t.push(l),n.push({card:l,callId:i});continue}if(r.type==="tool.call.completed"||r.type==="tool.call.failed"){const i=r.type==="tool.call.completed",l=rf(r.data),c=af(r.data),d=QE(r.data),m=XE(n,l,c);if(m){m.card.status=i?"done":"error",m.card.callId===void 0&&l!==void 0&&(m.card.callId=l),i?m.card.result=r.data.result:(m.card.error=lf(r.data),m.card.errorMeta=ts(r.data)),d!==void 0&&(m.card.durationMs=d),r.data.truncated===!0&&(m.card.truncated=!0);continue}t.push({kind:"tool",key:`tool-${s.key}`,callId:l,name:c??"tool",status:i?"done":"error",result:i?r.data.result:void 0,error:i?void 0:lf(r.data),errorMeta:i?void 0:ts(r.data),durationMs:d,truncated:r.data.truncated===!0?!0:void 0,startedAt:r.ts});continue}t.push(s)}return t}const Sb={placeholder:{labelKey:"chat.projection.badge.placeholder",hintKey:"chat.projection.badge.placeholderHint"},externalize:{labelKey:"chat.projection.badge.externalize",hintKey:"chat.projection.badge.externalizeHint"}},hI={readback:"chat.projection.badge.reason.readback",gone:"chat.projection.badge.reason.gone"};function pI(e){const t=Sb[e.mode];if(t===void 0)return null;const n=hI[e.original_available];return{labelKey:t.labelKey,hintKey:t.hintKey,...n!==void 0?{reasonKey:n}:{},danger:e.original_available==="gone"}}function gI(e){return Sb[e.mode]!==void 0}function bI(e,t){const n=[{labelKey:"chat.projection.meta.tool",value:t,unit:"text"},{labelKey:"chat.projection.meta.bytes",value:e.original_bytes===null?null:String(e.original_bytes),unit:"bytes"}];return e.since_event_seq!==void 0&&n.push({labelKey:"chat.projection.meta.sinceSeq",value:String(e.since_event_seq),unit:"text"}),n}function vI(e,t){if(e.original_available!=="inline"&&e.original_available!=="inline_truncated")return;const n=yd(t);return n.length>0?n:void 0}function yI(e){return e===void 0}const xI=8*1024;function wI(e){return e>0&&e%1024===0?`${e/1024} KiB`:`${e} B`}function kI(e){if(jb(e)!==void 0)return e.original_available==="inline_truncated"?"chat.projection.readbackTail":"chat.projection.readbackFromLog"}function SI(e){return e.original_available==="inline"||e.original_available==="inline_truncated"?"original":"model"}function jI(e){return e.placeholder_text}function jb(e){const t=e.readback;if(t!==void 0)return t.kind==="events"?{toolCallId:t.tool_call_id,sinceSeq:t.since_seq}:void 0;if(e.original_available==="inline_truncated")return{toolCallId:e.tool_call_id,sinceSeq:0}}function _I(e){const t=e.data;if(!(typeof t!="object"||t===null))return t}function NI(e,t){let n;for(const s of e){const r=_I(s);if(!(r===void 0||r.tool_call_id!==t)){if(s.type==="tool.call.completed"&&typeof r.result=="string")return r.result;s.type==="tool.call.failed"&&n===void 0&&typeof r.error=="string"&&(n=r.error)}}return n}function CI(e){return typeof e=="string"&&e.length>0?{kind:"text",text:e}:{kind:"gone",labelKey:"chat.projection.gone"}}function TI(e){return Math.max(0,Math.trunc(e.bytes_saved))}function EI(e){return e.unknown_original_count>0?e.unknown_original_count:0}function II(e){const t=new Map;for(const n of e){const s=n.projection;if(s===void 0)continue;const r=s.tool_call_id;typeof r!="string"||r.length===0||t.has(r)||t.set(r,s)}return t}const mf="rotate:handoff";function xd(e){if(typeof e!="string"||!e.startsWith(mf))return;const t=e.slice(mf.length);if(t.length===0)return{};if(!t.startsWith(":"))return;const n=t.slice(1);if(!/^\d+$/.test(n))return;const s=Number(n);return Number.isSafeInteger(s)?{epoch:s}:{}}function RI(e,t,n,s){const r=e.ts,i=t.ts;if(r!==void 0&&i!==void 0&&r!==i)return r-i;if(r===void 0&&i!==void 0)return 1;if(r!==void 0&&i===void 0)return-1;const l=e.seq,c=t.seq;return l!==void 0&&c!==void 0&&l!==c?l-c:n-s}function LI(e){if(e.type!=="prompt.system_context")return;const t=e.data;if(t===null||typeof t!="object")return;const n=t.hash;if(typeof n!="string"||n.length===0)return;const s=t.system_prompt,r=t.self_card,i=typeof s=="string"&&s.length>0?s:void 0,l=typeof r=="string"&&r.length>0?r:void 0;if(i===void 0&&l===void 0)return;const c=x=>typeof x=="number"&&Number.isFinite(x)&&x>=0?Math.floor(x):void 0,d=t.model,m=c(t.message_count),f=c(t.tools_count),h=c(t.estimated_tokens),p=c(t.context_max),g=_b(t.changed),b=typeof t.previous_hash=="string"&&t.previous_hash.length>0?t.previous_hash:void 0;return{hash:n,...i!==void 0?{systemPrompt:i}:{},...l!==void 0?{selfCard:l}:{},...typeof d=="string"&&d.length>0?{model:d}:{},...m!==void 0?{messageCount:m}:{},...f!==void 0?{toolsCount:f}:{},...h!==void 0?{estimatedTokens:h}:{},...p!==void 0?{contextMax:p}:{},...g!==void 0?{changed:g}:{},...b!==void 0?{previousHash:b}:{}}}function AI(e){if(e.type!=="message.injected")return;const t=e.data;if(t===null||typeof t!="object")return;const n=t.message;if(n===null||typeof n!="object")return;const s=n;if(typeof s.content!="string"||s.content.trim().length===0)return;const r=Cb(s.name);if(r!==void 0&&rr(s)!==void 0)return{message:s,noticeKind:r}}function _b(e){if(!Array.isArray(e)||e.length===0)return;const t=[];for(const n of e){if(typeof n!="string"||n.length===0)return;t.push(n)}return t}function Nb(e){if(e.status==="failed")return{runId:e.runId,...e.sessionId!==void 0?{sessionId:e.sessionId}:{},...e.error!==void 0?{error:e.error}:{},...e.errorMeta!==void 0?{errorMeta:e.errorMeta}:{},...e.completedAt!==void 0?{completedAt:e.completedAt}:{},source:"event"}}function MI(e){if(e==null||e.status!=="failed")return;const t=e.run_id;if(typeof t!="string"||t.length===0)return;const n=e.completed_at??e.updated_at,s=e.error;return{runId:t,sessionId:e.session_id,...typeof s=="string"&&s.length>0?{error:s}:{},...typeof n=="number"&&Number.isFinite(n)?{completedAt:n}:{},source:"session"}}function PI(e){if(e==null)return;const t=e.status;if(t!=="completed"&&t!=="failed"&&t!=="cancelled"&&t!=="interrupted")return;const n=e.completed_at??e.updated_at;if(typeof n!="number"||!Number.isFinite(n))return;const s=e.run_id,r=e.error;return{sessionId:e.session_id,...typeof s=="string"&&s.length>0?{runId:s}:{},status:t,at:n,...typeof r=="string"&&r.length>0?{error:r}:{}}}function qI(e){if(e==null)return;const t=e.system_context;if(t==null||typeof t!="object"||typeof t.hash!="string"||t.hash.length===0)return;const n=typeof t.system_prompt=="string"&&t.system_prompt.length>0?t.system_prompt:void 0,s=typeof t.self_card=="string"&&t.self_card.length>0?t.self_card:void 0;if(n===void 0&&s===void 0)return;const r=b=>typeof b=="number"&&Number.isFinite(b)&&b>=0?Math.floor(b):void 0,i=t.model,l=t.run_id,c=r(t.message_count),d=r(t.tools_count),m=r(t.estimated_tokens),f=r(t.context_max),h=typeof t.at=="number"&&Number.isFinite(t.at)?t.at:void 0,p=_b(t.changed),g=typeof t.previous_hash=="string"&&t.previous_hash.length>0?t.previous_hash:void 0;return{hash:t.hash,...n!==void 0?{systemPrompt:n}:{},...s!==void 0?{selfCard:s}:{},...typeof i=="string"&&i.length>0?{model:i}:{},...c!==void 0?{messageCount:c}:{},...d!==void 0?{toolsCount:d}:{},...m!==void 0?{estimatedTokens:m}:{},...f!==void 0?{contextMax:f}:{},...typeof l=="string"&&l.length>0?{runId:l}:{},...h!==void 0?{at:h}:{},...p!==void 0?{changed:p}:{},...g!==void 0?{previousHash:g}:{}}}const ff="\r",Io=`
|
|
573
|
+
`;function Po(e){const t=(e??"").split(ff+Io).join(Io).split(ff).join(Io),n=[];let s=0;for(const r of t.split(Io)){const i=r.trimEnd();if(i.length===0){if(s+=1,s>1)continue}else s=0;n.push(i)}return n.join(Io).trim()}function ln(e){return(e??"").trim()}const Ii="vessel:",OI=`${Ii}source`;function Zl(e){const t=e.name;return typeof t=="string"&&t.startsWith(Ii)}function Cb(e){if(typeof e!="string"||!e.startsWith(Ii))return;const t=e.slice(Ii.length);return t.length>0?t:"other"}function DI(e){const n=/location="([^"]+)"/.exec(e)?.[1];return n!==void 0&&n.length>0?n:void 0}function Za(e){return e.name===OI}function HI(e){return ca(e.name)!==void 0}function Tb(e,t){if(!(typeof e!="string"||e.length===0))return`${e}\0${t}`}function $I(e){const t=e.run_id;return typeof t=="string"&&t.length>0?t:void 0}const Eb="[tool image] ",Ib="[tool media] ";function po(e){if(e.role!=="user")return;const t=e.refs;if(t!==void 0){if(e.content.startsWith(Eb))return t.some(n=>n.kind==="image")?t:void 0;if(e.content.startsWith(Ib))return t.length>0?t:void 0}}function FI(e){const t=e.indexOf(`
|
|
574
|
+
`),n=t>=0?e.slice(0,t):e,r=/ from tool ([^:(\n]+)/.exec(n)?.[1]?.trim();return r!==void 0&&r.length>0?r:void 0}function Rb(e){return ca(e.name)!==void 0||xd(e.name)!==void 0?!0:po(e)!==void 0}function hf(e){const t=e.message_id;if(typeof t=="string"&&t.length>0)return`id:${t}`;const n=e.run_id;if(typeof n!="string"||n.length===0)return;const s=e.timestamp;if(!(typeof s!="number"||!Number.isFinite(s)))return`${n}:${e.role}:${String(s)}`}function rr(e){const t=e.message_id;if(!(typeof t!="string"||t.length===0))return t}const xs={duplicates:0,duplicatesLegacy:0,byIdentity:0};let pf=!1,gf=!1;function Lb(e,t){xs.duplicates+=1,xs.sample===void 0&&(xs.sample=`${e}:${t}`,!pf&&(pf=!0,console.warn(`[transcript] 同一条消息出现两次(已丢弃后者,不影响渲染):来源 ${e},message_id ${t}。这是上游重复写入的信号,不是渲染层该猜的事。`)))}function BI(e,t){xs.duplicatesLegacy+=1,xs.sampleLegacy===void 0&&(xs.sampleLegacy=`history-legacy:${e}:${String(t)}`,!gf&&(gf=!0,console.warn(`[transcript] 无 id 旧数据出现同 run 同正文的相邻两份(已丢弃后者):run ${e},下标 ${String(t)}。这是 0.56 之前落盘双写的残留信号(probe-message-dedup),不是新写入的重复。`)))}const KI=2;function WI(e){if(rr(e)!==void 0)return;const t=e.run_id;if(typeof t!="string"||t.length===0)return;const n=ln(e.content);if(n.length!==0)return`${t}\0${e.role}\0${e.name??""}\0${n}`}function UI(e,t){const n=e.run_segment,s=t.run_segment;if(typeof n=="number"&&Number.isFinite(n)&&typeof s=="number"&&Number.isFinite(s)&&n!==s||ln(e.reasoning_content)!==ln(t.reasoning_content))return!1;const r=l=>(l.tool_calls??[]).map(c=>`${c.id}:${c.function.name}:${c.function.arguments}`).join("|");if(r(e)!==r(t))return!1;const i=l=>(l.refs??[]).map(c=>`${c.kind}:${c.path}`).join("|");return i(e)===i(t)}function Ab(e,t,n,s){const r=[],i=new Map,l=new Map,c=new Map,d=new Map,m=new Set,f=new Map,h=new Set,p=new Map,g=new Map,b=new Set,x=new Map,y=new Map,v=new Map;for(const C of e){const L=hf(C);L===void 0||L.startsWith("id:")||v.set(L,(v.get(L)??0)+1)}const j=(C,L,A)=>{const D=hf(C);if(D===void 0)return`${A}:${String(L)}`;if(D.startsWith("id:")){const O=rr(C);return O!==void 0&&g.set(O,`${A}:${D}`),`${A}:${D}`}return(v.get(D)??0)>1?`${A}:${String(L)}`:`${A}:${D}`},_=new Set;n!==void 0&&e.forEach((C,L)=>{n(C)&&_.add(t+L)});const S=new Map,w=new Set;let k;for(let C=e.length-1;C>=0;C-=1){const L=e[C];if(L===void 0)continue;const A=t+C,D=_.has(A);if(Za(L)){if(k!==void 0&&HI(k.message)){const O=DI(L.content);O!==void 0&&S.set(k.absIndex,O),w.add(A);continue}D||(k={absIndex:A,message:L});continue}D||Zl(L)||(k={absIndex:A,message:L})}const N=PE(e),T=II(e),R=new Map,E=[];for(const C of N){if(C.callId===void 0)continue;m.add(C.callId);const L=R.get(C.callId);(L===void 0||!L.paired&&C.paired)&&R.set(C.callId,C)}const I=new Map;e.forEach((C,L)=>{const A=t+L;if(C.role!=="system"&&!_.has(A)&&!(Za(C)&&w.has(A)))for(const D of C.tool_calls??[]){const O=typeof D.id=="string"&&D.id.length>0?D.id:void 0;O!==void 0&&I.set(O,(I.get(O)??0)+1)}});let $;e.forEach((C,L)=>{const A=t+L;d.set(A,C),C.timestamp!==void 0&&($=C.timestamp);const D=C.timestamp??$;if(C.role==="system"||_.has(A)||Za(C)&&w.has(A))return;if(C.role==="tool"){const z=typeof C.tool_call_id=="string"&&C.tool_call_id.length>0?C.tool_call_id:void 0;if(z!==void 0&&C.timestamp!==void 0&&y.set(z,C.timestamp),z!==void 0){const me=I.get(z)??0;if(me>0){I.set(z,me-1);return}}E.push({item:N.find(me=>me.key===`history-tool-${L}`)??{key:`history-tool-${L}`,name:C.name??"tool",output:C.content,status:"neutral",paired:!1},index:L});return}const O=WI(C);if(O!==void 0){const z=x.get(O),me=z===void 0?void 0:d.get(z);if(z!==void 0&&me!==void 0&&A-z<=KI&&UI(me,C)){BI(C.run_id??"",A);return}x.set(O,A)}if(C.role==="user"){const z=ln(C.content),me=i.get(z);me===void 0?i.set(z,[A]):me.push(A);const K=Zl(C)||po(C)!==void 0?void 0:$I(C);if(K!==void 0){const ne=p.get(K);ne===void 0?p.set(K,[A]):ne.push(A)}}const F=(C.tool_calls??[]).map(z=>z.id).filter(z=>typeof z=="string"&&z.length>0);F.length>0&&l.set(A,F);for(const z of F)m.add(z);if(C.role==="assistant"){const z=ln(C.content);c.set(A,z);const me=C.run_segment;if(z.length>0&&typeof me=="number"&&Number.isFinite(me)){const K=Tb(C.run_id,me);K!==void 0&&(f.has(K)?h.add(K):f.set(K,z))}}const V=ln(C.content).length>0,B=C.role==="assistant"&&ln(C.reasoning_content).length>0,W=ca(C.name)!==void 0;if(C.role==="assistant"&&!V&&F.length>0&&!B||!V&&C.role!=="user"&&!W&&!B)return;const Z=rr(C);if(Z!==void 0){if(b.has(Z)){Lb("history",Z);return}b.add(Z)}const ee=S.get(A),ie=xd(C.name);if(ie!==void 0){r.push({kind:"rotate-handoff",key:j(C,A,"msg"),text:C.content,...ie,...D!==void 0?{ts:D}:{}});return}const le=uE(C)?lb(C.content):void 0;if(le!==void 0){r.push({kind:"ask-answer",key:j(C,A,"msg"),text:C.content,card:le,...D!==void 0?{ts:D}:{}});return}const J=s?.(C);if(J!==void 0){const z=or(J,C.content);r.push({kind:"runtime-notice",key:j(C,A,"notice"),noticeKind:J,text:C.content,absIndex:A,...z!==void 0?{env:z}:{},...D!==void 0?{ts:D}:{}});return}r.push({kind:"message",key:j(C,A,"msg"),absIndex:A,message:C,...ee!==void 0?{sourceText:ee}:{},...D!==void 0?{ts:D}:{}})});for(const[C,L]of l){const A=d.get(C);for(const D of L){const O=R.get(D);if(O===void 0)continue;const F=O.startedAt!==void 0&&O.endedAt!==void 0?Math.max(0,O.endedAt-O.startedAt):void 0,V=T.get(D);r.push({kind:"tool",key:`tool:${D}`,callId:D,name:O.name,...O.args!==void 0?{args:O.args}:{},...O.output!==void 0?{output:O.output}:{},status:"done",startedAt:A?.timestamp??0,paired:O.paired,...V!==void 0?{projection:V}:{},...O.truncatedLimitBytes!==void 0?{truncatedLimitBytes:O.truncatedLimitBytes}:{},...F!==void 0?{durationMs:F}:{},...(y.get(D)??A?.timestamp)!==void 0?{ts:y.get(D)??A?.timestamp}:{}})}}for(const{item:C,index:L}of E){const A=t+L,D=C.callId===void 0?void 0:T.get(C.callId),O=d.get(A)?.timestamp,F=C.callId!==void 0&&C.callId.length>0?`tool:orphan:${C.callId}:${String(O??0)}`:`tool:orphan:${String(A)}`;r.push({kind:"tool",key:F,...C.callId!==void 0?{callId:C.callId}:{},name:C.name,...C.output!==void 0?{output:C.output}:{},status:"done",startedAt:d.get(A)?.timestamp??0,paired:!1,...D!==void 0?{projection:D}:{},...C.truncatedLimitBytes!==void 0?{truncatedLimitBytes:C.truncatedLimitBytes}:{},...d.get(A)?.timestamp!==void 0?{ts:d.get(A)?.timestamp}:{}})}return{items:r,userByContent:i,callIdsByIndex:l,contentByIndex:c,messageByIndex:d,callIds:m,textBySegment:f,ambiguousSegments:h,inputsByRun:p,messageIds:g}}function zI(e){if(e.kind==="tool"||e.kind==="reasoning")return e.startedAt;if(e.kind==="notice"||e.kind==="event")return e.event.ts}const bf=new WeakMap;function VI(e){const t=[];for(const n of e){let s=bf.get(n);s===void 0&&(s=GI(n),bf.set(n,s));for(const r of s)t.push(r)}return t}function GI(e){const t=[],n=kb(e.items);let s=e.startedAt??e.firstTs;if(s===void 0)for(const g of n){const b=zI(g);b!==void 0&&(s===void 0||b<s)&&(s=b)}const r=e.firstSeq!==void 0?{seq:e.firstSeq}:{},i=new Map,l=new Map,c=new Map;for(const g of e.items)g.anchorSeq!==void 0&&i.set(g.key,g.anchorSeq),g.kind==="text"&&g.segmentIndex!==void 0&&l.set(g.key,g.segmentIndex),(g.kind==="text"||g.kind==="reasoning")&&g.messageId!==void 0&&c.set(g.key,g.messageId);let d;const m=g=>{const b=g??s;return b===void 0||(d=d===void 0?b:Math.max(d,b)),d};if(ln(e.input).length>0){const g=e.input,b=m(void 0),x=b!==void 0?{ts:b}:{},y=xd(e.inputName),v=e.inputName===ab?lb(g):void 0,j=Cb(e.inputName),_=e.inputMessageId!==void 0?{messageId:e.inputMessageId}:{};if(y!==void 0)t.push({kind:"rotate-handoff",key:`run:${e.runId}:input`,runId:e.runId,text:g,...y,..._,...x,...r});else if(v!==void 0)t.push({kind:"ask-answer",key:`run:${e.runId}:input`,runId:e.runId,text:g,card:v,..._,...x,...r});else if(j!==void 0){const S=or(j,g);t.push({kind:"runtime-notice",key:`run:${e.runId}:input`,runId:e.runId,noticeKind:j,text:g,...S!==void 0?{env:S}:{},..._,...x,...r})}else{const S=la(e.inputName);t.push({kind:"run-input",key:`run:${e.runId}:input`,runId:e.runId,text:g,...S!==void 0?{sender:S.alias,senderKind:S.kind}:{},...e.inputRefs!==void 0?{refs:e.inputRefs}:{},..._,...x,...r})}}let f=0,h=0;for(const g of n){if(g.kind==="text"){const x=i.get(g.key),y=l.get(g.key),v=c.get(g.key);t.push({kind:"run-text",key:`run:${e.runId}:text:${x??f}`,runId:e.runId,text:g.text,streaming:!1,...x!==void 0?{anchorSeq:x}:{},segmentIndex:y??f,...v!==void 0?{messageId:v}:{},...m(g.endedAt??g.startedAt)!==void 0?{ts:m(g.endedAt??g.startedAt)}:{},...r}),f+=1;continue}if(g.kind==="reasoning"){const x=i.get(g.key),y=c.get(g.key);t.push({kind:"run-reasoning",key:`run:${e.runId}:reasoning:${x??h}`,runId:e.runId,text:g.text,streaming:!1,...x!==void 0?{anchorSeq:x}:{},...y!==void 0?{messageId:y}:{},...g.startedAt!==void 0?{startedAt:g.startedAt}:{},...g.endedAt!==void 0?{endedAt:g.endedAt}:{},...m(g.endedAt??g.startedAt)!==void 0?{ts:m(g.endedAt??g.startedAt)}:{},...r}),h+=1;continue}if(g.kind==="tool"){t.push({kind:"tool",key:g.callId!==void 0?`tool:${g.callId}`:`tool:run:${e.runId}:${g.key}`,...g.callId!==void 0?{callId:g.callId}:{},runId:e.runId,name:g.name,...g.args!==void 0?{args:g.args}:{},...g.result!==void 0?{output:g.result}:{},status:g.status,...g.error!==void 0?{error:g.error}:{},...g.durationMs!==void 0?{durationMs:g.durationMs}:{},...g.truncated===!0?{truncated:!0}:{},startedAt:g.startedAt,paired:g.status!=="running",...g.anchorSeq!==void 0?{anchorSeq:g.anchorSeq}:{},...m(g.startedAt)!==void 0?{ts:m(g.startedAt)}:{},...r});continue}if(g.event.type==="prompt.system_context"){const x=LI(g.event);if(x!==void 0){const y=m(g.event.ts);t.push({kind:"prompt-context",key:`prompt:${g.key}`,runId:e.runId,...x,...y!==void 0?{ts:y}:{},...r});continue}}const b=AI(g.event);if(b!==void 0){const{message:x,noticeKind:y}=b,v=or(y,x.content),j=rr(x),_=m(g.event.ts);t.push({kind:"runtime-notice",key:`inject:${g.key}`,noticeKind:y,text:x.content,...v!==void 0?{env:v}:{},...j!==void 0?{messageId:j}:{},..._!==void 0?{ts:_}:{},...r});continue}t.push({kind:"notice",key:`notice:${g.key}`,event:g.event,ts:g.event.ts,...e.firstSeq!==void 0?{seq:e.firstSeq}:{}})}e.liveText!==void 0&&e.liveText.length>0&&t.push({kind:"run-text",key:`run:${e.runId}:text:${e.liveTextAnchorSeq??f}`,runId:e.runId,text:e.liveText,streaming:!0,...e.liveTextAnchorSeq!==void 0?{anchorSeq:e.liveTextAnchorSeq}:{},...m(e.lastTs)!==void 0?{ts:m(e.lastTs)}:{},...r}),e.liveReasoning!==void 0&&e.liveReasoning.length>0&&t.push({kind:"run-reasoning",key:`run:${e.runId}:reasoning:${e.liveReasoningAnchorSeq??h}`,runId:e.runId,text:e.liveReasoning,streaming:!0,...e.liveReasoningAnchorSeq!==void 0?{anchorSeq:e.liveReasoningAnchorSeq}:{},...m(e.lastTs)!==void 0?{ts:m(e.lastTs)}:{},...r});const p=Nb(e);if(p!==void 0){const g=m(p.completedAt);t.push({kind:"run-failure",key:`run:${e.runId}:failure`,...p,...g!==void 0?{ts:g}:{},...r})}return t.map(g=>g.anchorSeq!==void 0&&g.seq!==g.anchorSeq?{...g,seq:g.anchorSeq}:g)}function Mb(e){return e.map(n=>{const s=vf.get(n);if(s!==void 0)return s;const r=YI(n);return vf.set(n,r),r}).sort((n,s)=>(n.startTs??0)-(s.startTs??0))}const vf=new WeakMap;function YI(e){const t=[],n=[];let s="";for(const i of e.items){if(i.kind==="tool"){i.callId!==void 0&&t.push(i.callId);continue}i.kind!=="text"&&i.kind!=="reasoning"||(n.push({kind:i.kind,text:i.text,...i.anchorSeq!==void 0?{anchorSeq:i.anchorSeq}:{},...i.kind==="text"&&i.segmentIndex!==void 0?{segmentIndex:i.segmentIndex}:{},...i.messageId!==void 0?{messageId:i.messageId}:{}}),i.kind==="text"&&s.length===0&&(s=i.text))}e.liveText!==void 0&&e.liveText.length>0&&n.push({kind:"text",text:e.liveText,...e.liveTextAnchorSeq!==void 0?{anchorSeq:e.liveTextAnchorSeq}:{},...e.liveTextSegmentIndex!==void 0?{segmentIndex:e.liveTextSegmentIndex}:{}}),e.liveReasoning!==void 0&&e.liveReasoning.length>0&&n.push({kind:"reasoning",text:e.liveReasoning,...e.liveReasoningAnchorSeq!==void 0?{anchorSeq:e.liveReasoningAnchorSeq}:{}});const r=e.startedAt??e.firstTs;return{runId:e.runId,status:e.status,input:ln(e.input),...e.inputMessageId!==void 0?{inputMessageId:e.inputMessageId}:{},output:ln(e.output).length>0?ln(e.output):ln(s),running:e.status==="running",...r!==void 0?{startTs:r}:{},callIds:t,segments:n}}function Pb(){return{decisions:0,userMisses:0,assistantMisses:0,unclaimedSegments:0,rewrittenSegments:0}}function qb(e,t,n){const s=new Set,r=new Map;let i=-1/0;for(const h of t){if(h.input.length===0||h.inputMessageId!==void 0)continue;const p=JI(e,h.runId,s);if(p!==void 0){s.add(p),r.set(h.runId,p),i=Math.max(i,p);continue}const b=(e.userByContent.get(h.input)??[]).find(x=>x>=i&&!s.has(x));if(b===void 0){n.userMisses+=1;continue}s.add(b),r.set(h.runId,b),i=b}const l=new Set;for(const h of t){const p=r.get(h.runId)??i;if(h.output.length===0)continue;let g=0;for(const[b,x]of e.contentByIndex)b<=p||l.has(b)||x!==h.output&&!(x.length>=8&&h.output.includes(x))||(l.add(b),g+=1);for(const[b,x]of e.callIdsByIndex)b<=p||l.has(b)||x.length>0&&x.every(y=>h.callIds.includes(y))&&(l.add(b),g+=1);g===0&&(n.assistantMisses+=1)}const c=new Set;for(const h of l){const p=e.contentByIndex.get(h);p!==void 0&&p.length>0&&c.add(Po(p))}const d=new Set;for(const h of e.messageByIndex.values()){const p=h.reasoning_content;typeof p=="string"&&p.trim().length>0&&d.add(Po(p))}const m=new Set,f=new Set;for(const h of t){const p=XI(h.segments);let g=0;for(const b of h.segments){if(b.messageId!==void 0)continue;const x=Po(b.text);if(x.length===0)continue;const y=b.kind==="text"?QI(e,h.runId,b,p):void 0,v=b.kind==="text"?c.has(x):d.has(x);if(!v&&y===void 0){b.kind==="text"&&(g+=1);continue}v&&f.add(x),b.anchorSeq!==void 0&&m.add(b.anchorSeq),y!==void 0&&Po(y)!==x&&(n.rewrittenSegments+=1)}h.running||h.output.length===0||(n.unclaimedSegments+=g)}return{claimedUserByRun:r,claimedAssistant:l,yieldedAnchors:m,yieldedTexts:f}}function JI(e,t,n){const s=e.inputsByRun.get(t);if(s===void 0||s.length!==1)return;const r=s[0];if(!(r===void 0||n.has(r)))return r}function QI(e,t,n,s){const r=n.segmentIndex;if(r===void 0||s.has(r))return;const i=Tb(t,r);if(!(i===void 0||e.ambiguousSegments.has(i)))return e.textBySegment.get(i)}function XI(e){const t=new Set,n=new Set;for(const s of e)s.kind!=="text"||s.segmentIndex===void 0||(t.has(s.segmentIndex)?n.add(s.segmentIndex):t.add(s.segmentIndex));return n}function ZI(e,t,n){const s=new Map;if(!n.detailReady)return s;for(const r of e){if(r.status==="running"||r.status==="failed"&&n.failureRunId!==r.runId)continue;const i=[];for(const l of r.segments)l.anchorSeq!==void 0&&t.has(l.anchorSeq)&&i.push(l.anchorSeq);i.length>0&&s.set(r.runId,{segments:i})}return s}function eR(e,t){const n=Pb();return n.decisions=1,{...qb(e,t,n),handover:new Map,stats:n}}class tR{identity=null;decision=null;seen=new Set;settled=new Set;fed=new Set;counters=Pb();get stats(){return this.counters}decide(t,n){const s=this.identity===null||!nR(this.identity,t);if(s&&(this.seen.clear(),this.settled.clear(),this.fed.clear()),!(s||this.needsRunRerun(n.facts))&&this.decision!==null)return this.decision;this.counters.decisions+=1;const i=qb(n.history,n.facts,this.counters),l=ZI(n.facts,i.yieldedAnchors,n),c={...i,handover:l,stats:this.counters};this.decision=s||this.decision===null?c:sR(this.decision,c),this.identity=t;for(const d of n.facts)this.seen.add(d.runId),d.status!=="running"&&this.settled.add(d.runId),d.input.length>0&&this.fed.add(d.runId);return this.decision}needsRunRerun(t){for(const n of t)if(!this.seen.has(n.runId)||n.status!=="running"&&!this.settled.has(n.runId)||n.input.length>0&&!this.fed.has(n.runId))return!0;return!1}}function nR(e,t){return e.history===t.history&&e.sessionId===t.sessionId&&e.epoch===t.epoch&&e.windowStart===t.windowStart&&e.windowEnd===t.windowEnd}function sR(e,t){const n=new Map(e.claimedUserByRun);for(const[l,c]of t.claimedUserByRun)n.has(l)||n.set(l,c);const s=new Set(e.yieldedAnchors);for(const l of t.yieldedAnchors)s.add(l);const r=new Set(e.yieldedTexts);for(const l of t.yieldedTexts)r.add(l);const i=new Map(e.handover);for(const[l,c]of t.handover){const d=i.get(l);i.set(l,{segments:[...new Set([...d?.segments??[],...c.segments])]})}return{claimedUserByRun:n,claimedAssistant:new Set([...e.claimedAssistant,...t.claimedAssistant]),yieldedAnchors:s,yieldedTexts:r,handover:i,stats:t.stats}}const yf=new WeakMap;function oR(e,t){if(t.anchorSeq!==void 0&&e.yieldedAnchors.has(t.anchorSeq))return!0;if(e.yieldedTexts.size===0)return!1;let n=yf.get(t);return n===void 0&&(n=Po(t.text),yf.set(t,n)),e.yieldedTexts.has(n)}function rR(e,t,n){const s=new Set;for(let r=t;r<e.length;r+=1){const i=e[r];if(i!==void 0){if(n.has(i.key)||s.has(i.key))return!0;s.add(i.key)}}return!1}function iR(e,t){const n=new Map,s=[];for(const r of e){const i=n.get(r.key);if(i===void 0){n.set(r.key,r),s.push(r.key);continue}n.set(r.key,lR(i,r,t))}return s.map(r=>n.get(r)).filter(r=>r!==void 0)}const aR="tool";function xf(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;const r=e,i=t;for(const l of n)if(r[l]!==i[l])return!1;return!0}function lR(e,t,n){const s=n?.has(e.key)===!0;if(e.kind==="tool"&&t.kind==="tool"){const i=e.name===aR?t.name:e.name,l=e.args!==void 0?e.args:t.args,c=e.output!==void 0?e.output:t.output,d={...e,name:i,...t.runId!==void 0?{runId:t.runId}:{},...l!==void 0?{args:l}:{},...c!==void 0?{output:c}:{},status:t.status,...t.durationMs!==void 0?{durationMs:t.durationMs}:{},...t.error!==void 0?{error:t.error}:{},...t.truncated===!0?{truncated:!0}:{},startedAt:t.startedAt>0?t.startedAt:e.startedAt,paired:e.paired||t.paired,ts:s?e.ts:e.ts??t.ts};return xf(e,d)?e:d}const r={...e,...t,key:e.key};return xf(e,r)?e:r}const wf=new WeakMap;function Ob(e){const t=wf.get(e);if(t!==void 0)return t;const n=[];if(e.kind==="tool")for(const s of qE(e.name,e.args,e.output))n.push({kind:"inbox-read",key:`inbox-read:${s.id}`,messageId:s.id,text:s.text,source:s.source,...e.runId!==void 0?{runId:e.runId}:{},...e.ts!==void 0?{ts:e.ts}:{}});return wf.set(e,n),n}function cR(e,t){const n=new Set;for(const i of e)i.kind==="run-input"&&i.messageId!==void 0&&n.add(i.messageId);const s=i=>t.has(i)||n.has(i),r=[];for(const i of e){if(i.kind==="inbox-read"){if(s(i.messageId))continue;n.add(i.messageId),r.push(i);continue}if(r.push(i),i.kind==="tool")for(const l of Ob(i))s(l.messageId)||(n.add(l.messageId),r.push(l))}return r}const kf=new WeakMap;function dR(e){const t=kf.get(e);if(t!==void 0)return t;let n;for(const[,i]of e.messageByIndex)i.role!=="user"||Zl(i)||po(i)!==void 0||i.timestamp!==void 0&&(n===void 0||i.timestamp>n)&&(n=i.timestamp);const s=new Set(e.items.map(i=>i.key)),r={historyKeys:s,historyKeysUnique:s.size===e.items.length,lastUserTs:n,messageIds:new Set(e.messageIds.keys())};return kf.set(e,r),r}function uR(e){const t=e.historyIndex??Ab(e.messages,e.messageIndexOffset,e.isHidden,e.noticeKindOf),n=e.liveItems??VI(e.liveGroups),s=e.claims??t.claims??eR(t,Mb(e.liveGroups)),{claimedUserByRun:r}=s,i=new Map;for(const v of e.liveGroups)i.set(v.runId,{running:v.status==="running"});const l=dR(t),c=l.lastUserTs,d=[];for(const v of t.items)d.push(v);const m=e.messageIndexOffset>0&&e.windowStartTs!==void 0?e.windowStartTs:void 0,f=new Set;for(const v of n){const j="runId"in v?v.runId:void 0;if(v.kind==="runtime-notice"&&e.runtimeVisibility!==void 0&&!ro(e.runtimeVisibility,`vessel:${v.noticeKind}`))continue;const _="messageId"in v?v.messageId:void 0;if(_!==void 0){if(t.messageIds.has(_)){xs.byIdentity+=1;continue}if(v.kind!=="run-text"&&v.kind!=="run-reasoning"){if(f.has(_)){Lb("live",_);continue}f.add(_)}}if(m!==void 0&&v.ts!==void 0&&v.ts<m){if(v.kind==="tool")for(const I of Ob(v))d.push(I);continue}if(j!==void 0&&r.has(j)&&(v.kind==="run-input"||v.kind==="runtime-notice"||v.kind==="ask-answer"||v.kind==="rotate-handoff"))continue;const S=j===void 0?void 0:i.get(j);if(S===void 0){d.push(v);continue}if((v.kind==="run-text"||v.kind==="run-reasoning")&&v.messageId===void 0&&oR(s,v))continue;const w=j===void 0?void 0:r.get(j),k=w===void 0?void 0:t.messageByIndex.get(w)?.timestamp,N=k!==void 0?k+1:void 0,T=S.running&&v.ts===void 0&&c!==void 0?c+1:void 0,R=N??T,E=R===void 0?v.ts:v.ts===void 0?R:Math.max(v.ts,R);d.push(E===v.ts?v:{...v,ts:E})}const h=e.sessionFailure;h!==void 0&&!e.liveGroups.some(v=>v.runId===h.runId)&&d.push({kind:"run-failure",key:`run:${h.runId}:failure`,...h,...h.completedAt!==void 0?{ts:h.completedAt}:{}});const p=e.sessionSystemContext;if(p!==void 0&&!n.some(v=>v.kind==="prompt-context"&&v.hash===p.hash)){const{runId:v,at:j,..._}=p;d.push({kind:"prompt-context",key:`prompt:session:${p.hash}`,..._,...v!==void 0?{runId:v}:{},...j!==void 0?{ts:j}:{}})}const g=e.answeredAsks;if(g!==void 0&&g.length>0){const v=new Set;for(const j of d)j.kind==="ask-answer"&&j.card.requestId!==void 0&&v.add(j.card.requestId);for(const j of g)v.has(j.requestId)||d.push({kind:"ask-answered",key:`ask-answered:${j.requestId}`,requestId:j.requestId,card:j.card,ts:j.answeredAt})}const b=l.historyKeys,y=(l.historyKeysUnique&&!rR(d,t.items.length,b)?d:iR(d,b)).map((v,j)=>({item:v,index:j})).sort((v,j)=>RI(v.item,j.item,v.index,j.index)).map(({item:v})=>v);return fR(hR(cR(y,l.messageIds)))}const Sf=new WeakMap;function mR(e){const t=e[0];if(t===void 0)throw new Error("empty env notice run");const n=Sf.get(t);if(n!==void 0&&n.members.length===e.length&&n.members.every((r,i)=>r===e[i]))return n.result;let s=t;for(let r=1;r<e.length;r+=1){const i=e[r];i===void 0||i.kind!=="runtime-notice"||i.env===void 0||s.kind!=="runtime-notice"||s.env===void 0||(s={...s,env:IE(s.env,i.env)})}return Sf.set(t,{members:[...e],result:s}),s}function fR(e){const t=[];let n=0;for(;n<e.length;){const s=e[n];if(s!==void 0&&s.kind==="runtime-notice"&&s.env!==void 0){let r=n+1;for(;r<e.length;){const i=e[r];if(i===void 0||i.kind!=="runtime-notice"||i.env===void 0||i.env.scope!==s.env.scope)break;r+=1}if(r>n+1){t.push(mR(e.slice(n,r))),n=r;continue}}s!==void 0&&t.push(s),n+=1}return t}const jf=new WeakMap;function hR(e){let t;return e.map(n=>{const s=pR(n);if(s===void 0)return n;const r=s!==t;t=s;const i=jf.get(n);if(i!==void 0&&i.speaker===s&&i.groupStart===r)return i.annotated;const l={...n,speaker:s,groupStart:r};return jf.set(n,{speaker:s,groupStart:r,annotated:l}),l})}function pR(e){if(e.kind==="run-text")return"assistant";if(e.kind!=="message")return;const t=e.message.name;return typeof t=="string"&&ca(t)!==void 0?t:e.message.role}const _f=100;function gR(e){const t=e.replace(/\s+/g," ").trim();return t.length>_f?`${t.slice(0,_f)}…`:t}function ua(e){return e.role!=="user"||Dn(e)!==void 0?!1:!Rb(e)}function Db(e){return e.from==="human"&&e.kind!=="system"}function wd(e){return e.slice(-50).map((t,n)=>({key:t.key,label:a("chat.index.jump",{index:n+1}),preview:gR(t.content)}))}function bR(e){const t=[];for(const n of e)n.kind==="message"&&ua(n.message)&&t.push({key:n.key,content:n.message.content});return wd(t)}function vR(e){const t=[];for(const n of e)Db(n)&&t.push({key:n.message_id,content:n.content});return wd(t)}function yR(e,t){const n=[];let s=0;for(const r of e){const i=Dn(r);if(i!==void 0&&!ro(t,i))continue;const l=`message-${s++}`;ua(r)&&n.push({key:l,content:r.content})}return wd(n)}function kd(){const e=wt(t=>Se(t.config));return gE(as(e,"ui.addressStyle"))}const Hb=u.createContext(null);function xR({names:e,children:t}){return o.jsx(Hb.Provider,{value:e,children:t})}function ma(){return u.useContext(Hb)??void 0}const $b=u.createContext(null);function wR({names:e,children:t}){return o.jsx($b.Provider,{value:e,children:t})}function Sd(){return u.useContext($b)??void 0}const kR={neutral:"",info:"notice-block info",ok:"notice-block ok",warn:"notice-block warn",danger:"notice-block danger"};function Jt({title:e,meta:t,summary:n,tone:s="neutral",defaultOpen:r,actions:i,ariaLabel:l,className:c,entering:d=!1,onOpenChange:m,children:f}){const h=f!==void 0,[p,g]=u.useState(r),[b,x]=u.useState(!1);u.useEffect(()=>{b||g(r)},[r,b]),u.useEffect(()=>{m?.(p)},[p]);const y=["event-block","stream-card",kR[s],c??"",d?"motion-appear":"",h?"motion-disclosure":""].filter(j=>j.length>0).join(" "),v=o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-card-title",children:e}),t!==void 0&&o.jsx("span",{className:"shrink-0 font-mono text-2xs tabular-nums text-faint",children:t}),n!==void 0&&o.jsx("span",{className:"event-block-preview",children:n}),h&&o.jsx(SR,{})]});return h?o.jsxs("details",{className:y,"aria-label":l,open:p,onToggle:j=>{const _=j.currentTarget.open;_!==p&&(x(!0),g(_))},children:[o.jsx("summary",{className:"event-block-summary",children:v}),i,o.jsx("div",{className:"event-block-body",children:f})]}):o.jsxs("div",{className:y,...l!==void 0?{role:"group","aria-label":l}:{},children:[o.jsx("div",{className:"event-block-summary",children:v}),i]})}function SR(){return o.jsxs("span",{className:"event-block-toggle",children:[o.jsx("span",{className:"event-toggle-expand sr-only",children:a("chat.event.expand")}),o.jsx("span",{className:"event-toggle-collapse sr-only",children:a("chat.event.collapse")}),o.jsx(yt,{name:"chevron",className:"event-toggle-icon"})]})}function fa({env:e,ts:t,defaultOpen:n=!1,entering:s,meta:r,footnote:i,facts:l,blocks:c}){const d=cn(t),m=kd(),f=Sd(),h=ma(),p=e.scope==="source"?CE(e,m,{node:f,principal:h}):e;return o.jsxs(Jt,{className:"env-notice-card w-full min-w-0 max-w-full",ariaLabel:a("chat.env.aria"),defaultOpen:n,...s!==void 0?{entering:s}:{},title:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"shrink-0 font-mono text-2xs tracking-wider text-accent",children:a("chat.env.title")}),o.jsx("span",{className:"max-w-56 truncate font-mono text-2xs tracking-wider text-ink",children:a(`chat.env.scope.${e.scope}`)}),!e.ok&&o.jsx("span",{className:"font-mono text-2xs text-danger",children:a("chat.env.notApplied")})]}),meta:r??(e.count>1?a("chat.env.count",{count:e.count}):void 0),summary:l&&l.length>0?l.join(" · "):p.lines[0]?.text,children:[d!==""&&o.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline gap-x-2 font-mono text-2xs text-faint",children:[o.jsx("time",{className:"shrink-0 tabular-nums",dateTime:new Date(t??0).toISOString(),children:d}),i]}),o.jsxs("ul",{className:"m-0 flex min-w-0 list-none flex-col gap-1 p-0",children:[p.lines.map(g=>o.jsxs("li",{className:"min-w-0 break-words whitespace-pre-wrap wrap-anywhere text-sm leading-relaxed text-ink",children:[!g.ok&&o.jsx("span",{className:"mr-1.5 text-danger",children:a("chat.env.notApplied")}),g.text]},g.id)),e.droppedLines!==void 0&&o.jsx("li",{className:"min-w-0 text-2xs text-faint",children:a("chat.env.moreLines",{count:e.droppedLines})})]}),(c??e.blocks)?.map(g=>o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"event-raw-label",children:a(g.labelKey)}),o.jsx("pre",{className:"run-error-body",children:g.text})]},g.labelKey))]})}const jR=.3,_R=12;function jd({getElement:e,entryKeys:t,resetKey:n}){const[s,r]=u.useState(null),i=u.useRef(()=>{});u.useEffect(()=>{const d=e();if(!d){i.current=()=>{},r(null);return}const m=()=>{const b=d.querySelectorAll("[data-index-entry-key]");if(b.length===0){r(null);return}const x=d.getBoundingClientRect().top+d.clientHeight*jR;let y=null;for(const v of b){if(v.getBoundingClientRect().top>x)break;y=v.dataset.indexEntryKey??null}r(y??b[0]?.dataset.indexEntryKey??null)};i.current=m;let f;const h=()=>{f===void 0&&(f=requestAnimationFrame(()=>{f=void 0,m()}))};d.addEventListener("scroll",h,{passive:!0});const p=typeof ResizeObserver<"u"?new ResizeObserver(h):null;p?.observe(d);const g=typeof MutationObserver<"u"?new MutationObserver(h):null;return g?.observe(d,{childList:!0,subtree:!0,characterData:!0}),m(),()=>{f!==void 0&&cancelAnimationFrame(f),d.removeEventListener("scroll",h),p?.disconnect(),g?.disconnect(),i.current=()=>{}}},[e,n]);const l=`${t.length}:${t[t.length-1]??""}`;u.useEffect(()=>{i.current()},[l]);const c=u.useCallback(d=>{const m=e();if(!m)return;const f=m.querySelector(`[data-index-entry-key="${CSS.escape(d)}"]`);if(!f)return;const h=f.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop-_R;m.scrollTo({top:Math.max(0,h),behavior:"smooth"})},[e]);return{activeKey:s,jumpTo:c}}function NR({messages:e}){const{visibility:t}=aa(),n=[];let s=null,r=0;for(const i of e){const l=Dn(i);if(l!==void 0&&!ro(t,l))continue;const c=`message-${r++}`,d=i.timestamp,m=d!==void 0?vs(d):null;if(m&&m!==s&&(n.push(o.jsx("div",{className:"day-divider mt-1.5 mb-0.5",children:o.jsx("span",{children:Wi(d??0)})},`day-${m}`)),s=m),i.role==="system"){n.push(o.jsx("div",{children:o.jsxs("div",{className:"mx-auto my-0.5 max-w-180 rounded-r-sm border-l-2 border-l-line-strong bg-sunken px-3 py-1.25 text-center text-sm text-muted",role:"status",children:[o.jsx("span",{className:"mr-1.5 font-mono text-2xs uppercase text-faint",children:a("team.message.systemTag")}),o.jsx("span",{children:i.content})]})},c));continue}const f=or(l,i.content);if(f!==void 0){n.push(o.jsx("div",{children:o.jsx(fa,{env:f,ts:d,defaultOpen:!0})},c));continue}n.push(o.jsx("div",{"data-index-entry-key":ua(i)?c:void 0,children:o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-faint",children:[o.jsx("span",{className:"font-medium text-muted",children:i.name||i.role}),d!==void 0&&o.jsx("time",{className:"font-mono tabular-nums",dateTime:new Date(d).toISOString(),children:cn(d)})]}),i.role==="tool"?o.jsx("pre",{className:"m-0 max-w-180 rounded-sm border border-line bg-sunken px-2.5 py-2 font-mono text-xs whitespace-pre-wrap wrap-anywhere",children:i.content}):o.jsx("div",{className:"team-message-bubble",children:o.jsx(jr,{className:"text-base leading-relaxed wrap-anywhere",text:i.content})})]})},c))}return o.jsx("div",{className:"mx-auto flex w-full max-w-180 flex-col gap-3",children:n})}function CR({client:e,hasToken:t,epoch:n,bodyId:s,memberName:r,teamName:i,initialSession:l,onBackToMember:c}){const d=Ft({load:()=>e.getSession(s),enabled:t,deps:[s,n],...l!==void 0?{initialData:l}:{}}),m=Se(d.state),f=d.state.status==="error"?{message:d.state.error,code:d.state.code}:void 0,h=Zo(m?.title)||Zo(m?.preview)||s,{visibility:p}=aa(),g=u.useRef(null),b=u.useCallback(()=>g.current,[]),x=u.useMemo(()=>m?yR(m.messages,p):[],[m,p]),{activeKey:y,jumpTo:v}=jd({getElement:b,entryKeys:x.map(j=>j.key),resetKey:`${s}:${t?"1":"0"}`});return t?o.jsxs("div",{className:"team-body-view flex min-h-0 min-w-0 flex-col",children:[o.jsx("header",{className:"team-body-head",children:o.jsx(xr,{title:r,scope:i?[{label:i}]:[],actions:o.jsx(G,{onClick:c,children:a("breadcrumb.team.member")})})}),o.jsxs("div",{className:"transcript-stage",children:[o.jsx("div",{className:"team-transcript-scroll pt-4",ref:g,children:!m&&!f?o.jsx(Ke,{rows:3}):m?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mx-auto flex w-full max-w-180 min-w-0 items-center gap-2 text-2xs text-faint",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate",title:h,children:h}),o.jsx(ls,{text:s,className:"shrink-0 text-2xs"})]}),m.messages.length===0?o.jsx($e,{title:a("team.chat.empty")}):o.jsx(NR,{messages:m.messages})]}):o.jsx(Ve,{message:f?.message??a("team.error.loadFailed"),onRetry:d.reload})}),o.jsx(pd,{entries:x,activeKey:y,onJump:v,className:"conversation-index-rail"})]})]}):o.jsx(Fe,{title:a("team.error.noToken"),reason:a("team.error.noTokenReason")})}function TR(e){if(typeof e!="object"||e===null)return;const t=e;if(!Array.isArray(t.entries))return;const n=[],s=[];for(const l of t.entries){if(typeof l!="object"||l===null)continue;const c=l;if(typeof c.id!="string"||c.id==="")continue;const d=typeof c.name=="string"&&c.name!==""?c.name:c.id;n.push({id:c.id,name:d,legacy:c.legacy===!0}),typeof c.alias=="string"&&c.alias!==""&&s.push({alias:c.alias,target:c.id})}let r;const i=t.effective;if(typeof i=="object"&&i!==null){const l=i;typeof l.entryId=="string"&&typeof l.wireModel=="string"&&(r=`${l.entryId} (${l.wireModel})`)}return{entries:n,aliases:s,...r!==void 0?{effective:r}:{}}}function _d({node:e,value:t,onChange:n,id:s,disabled:r,"aria-label":i,emptyLabel:l}){He();const{client:c,epoch:d}=Ae(),[m,f]=u.useState({status:"loading"}),h=e?ge(e):"",p=e?.url??"",g=e?.current??!1;u.useEffect(()=>{if(h===""||p===""){f({status:"failed"});return}let _=!1;return f({status:"loading"}),(g?c.rpc("plugin.model-registry.list",{}):Bi({name:h,url:p},"plugin.model-registry.list",{})).then(w=>{if(_)return;const k=TR(w);f(k?{status:"ready",registry:k}:{status:"failed"})}).catch(()=>{_||f({status:"failed"})}),()=>{_=!0}},[c,d,h,p,g]);const b=m.status==="ready"?m.registry:void 0,x=new Set;for(const{alias:_}of b?.aliases??[])x.add(_);for(const _ of b?.entries??[])x.add(_.id);const y=t!==""&&!x.has(t),v=l??a("modelPicker.followDefault"),j=b?.effective!==void 0?a("modelPicker.emptyWithCurrent",{label:v,model:b.effective}):v;return o.jsxs(o.Fragment,{children:[o.jsxs($t,{id:s,value:t,onChange:_=>n(_.target.value),disabled:r||m.status!=="ready","aria-label":i,children:[o.jsx("option",{value:"",children:j}),y&&o.jsxs("option",{value:t,children:[o.jsx("span",{className:"font-mono",children:t}),m.status==="ready"&&o.jsxs("span",{className:"text-warn",children:[" · ",a("modelPicker.unregistered")]})]}),b!==void 0&&b.aliases.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("option",{value:"",disabled:!0,children:a("modelPicker.groupAliases")}),b.aliases.map(({alias:_,target:S})=>o.jsxs("option",{value:_,children:[o.jsx("span",{className:"font-mono",children:_}),o.jsxs("span",{className:"text-faint",children:[" → ",S]})]},_))]}),b!==void 0&&b.entries.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("option",{value:"",disabled:!0,children:a("modelPicker.groupEntries")}),b.entries.map(_=>o.jsxs("option",{value:_.id,children:[o.jsx("span",{className:"font-mono",children:_.id}),_.name!==_.id&&o.jsxs("span",{className:"text-faint",children:[" → ",_.name]}),_.legacy&&o.jsx("span",{className:"text-faint",children:" · legacy"})]},_.id))]})]}),m.status==="failed"&&o.jsx("p",{className:"mt-1 mb-0 text-xs text-faint",children:a("modelPicker.unavailable")})]})}function ER(e){if(typeof e!="object"||e===null)return[];const t=e.details;if(typeof t!="object"||t===null)return[];const n=t.candidates;return Array.isArray(n)?n.filter(s=>typeof s=="string"&&s.length>0):[]}function ps(e,t){const n=e.code;let s;if(n==="forbidden")s=a("agents.error.forbidden");else if(n==="not_found")s=a("agents.error.notFound");else{const i=e instanceof Error?e.message:String(e);s=`${a(t)}: ${i}`}const r=ER(e);return r.length>0&&(s+=` ${a("agents.error.candidates",{list:r.join(", ")})}`),s}function IR(e){return(e.kind??"peer")==="peer"&&pn(e.teamId)===""?"peer_requires_team":void 0}function pn(e){return e.trim()}function RR(e){const t=pn(e.name),n=pn(e.model),s=pn(e.systemPrompt),r=pn(e.teamId);return{kind:e.kind??"peer",...t!==""?{name:t}:{},...n!==""?{model:n}:{},...s!==""?{system_prompt:s}:{},...r!==""?{team_id:r}:{}}}function LR(e,t,n){const s={agent_id:e};let r=0;const i=pn(n.name);i!==""&&i!==pn(t.name)&&(s.name=i,r+=1);const l=pn(n.model);l!==""&&l!==pn(t.model)&&(s.model=l,r+=1);const c=pn(n.systemPrompt);return c!==""&&c!==pn(t.systemPrompt)&&(s.system_prompt=c,r+=1),r===0?{ok:!1,error:"no_change"}:{ok:!0,input:s}}const AR={name:"",model:"",systemPrompt:"",teamId:"",kind:"peer"};function MR({nodes:e,teamsForNode:t,initialNodeKey:n,onClose:s,onSaved:r}){He();const i=ot(),{teamControl:l}=ut(),c=Bt(),d=n!==void 0&&e.some(N=>ge(N)===n)?n:void 0,[m,f]=u.useState(d??(e[0]?ge(e[0]):"")),[h,p]=u.useState(AR),[g,b]=u.useState(!1),[x,y]=u.useState(null),v=e.find(N=>ge(N)===m),j=v?t(ge(v)):[],_=a("agents.create.title"),S=IR(h)==="peer_requires_team",w=N=>T=>{p(R=>({...R,[N]:T})),y(null)},k=async N=>{if(N.preventDefault(),!(g||!v||S)){b(!0),y(null);try{const T=await l(v).createAgent(RR(h)),R=T.name?.trim()||T.agent_id||T.id||h.name.trim();i.success(a("agents.form.created",{name:R||"—"})),r(),s()}catch(T){y(ps(T,"agents.form.createFailed"))}finally{b(!1)}}};return o.jsxs(tn,{label:_,onClose:()=>{g||s()},closeOnBackdrop:!g,closeLabel:a("common.close"),children:[o.jsx("h2",{className:"modal-title",children:_}),o.jsxs("form",{className:"flex flex-col gap-2",onSubmit:k,children:[o.jsxs("div",{className:"form-grid mt-1",children:[o.jsx(We,{label:a("agents.filter.node"),htmlFor:"agent-create-node",children:o.jsx($t,{id:"agent-create-node",value:m,onChange:N=>{f(N.target.value),p(T=>({...T,teamId:""})),y(null)},"aria-label":a("agents.filter.node"),children:e.map(N=>o.jsx("option",{value:ge(N),children:c.get(ge(N))??"—"},ge(N)))})}),o.jsx(We,{label:a("agents.form.kind"),htmlFor:"agent-create-kind",hint:a("agents.form.roleHint"),children:o.jsxs($t,{id:"agent-create-kind",value:h.kind??"peer",onChange:N=>{p(T=>({...T,kind:N.target.value})),y(null)},"aria-label":a("agents.form.kind"),children:[o.jsx("option",{value:"peer",children:a("agents.form.kindPeer")}),o.jsx("option",{value:"contractor",children:a("agents.form.kindContractor")})]})}),o.jsx(We,{label:a("agents.filter.team"),htmlFor:"agent-create-team",required:(h.kind??"peer")==="peer",hint:S?a("agents.form.peerRequiresTeam"):void 0,children:o.jsxs($t,{id:"agent-create-team",value:h.teamId,onChange:N=>w("teamId")(N.target.value),"aria-label":a("agents.filter.team"),children:[o.jsx("option",{value:"",children:a("agents.form.unbound")}),j.map(N=>o.jsx("option",{value:N.team_id,children:N.name||N.team_id},N.team_id))]})}),o.jsx(We,{label:a("team.form.name"),htmlFor:"agent-create-name",children:o.jsx(Xe,{id:"agent-create-name",value:h.name,onChange:N=>w("name")(N.target.value),spellCheck:!1,autoComplete:"off"})}),o.jsx(We,{label:a("agents.form.model"),htmlFor:"agent-create-model",hint:a("agents.form.modelCreateHint"),children:o.jsx(_d,{id:"agent-create-model",node:v,value:h.model,onChange:w("model"),"aria-label":a("agents.form.model")})}),o.jsx(We,{className:"col-span-full",label:a("agents.form.systemPrompt"),htmlFor:"agent-create-system-prompt",hint:a("agents.form.systemPromptHint"),children:o.jsx(Hi,{id:"agent-create-system-prompt",className:"min-h-24 resize-y text-sm leading-normal",value:h.systemPrompt,onChange:N=>w("systemPrompt")(N.target.value),rows:5,spellCheck:!1})})]}),x&&o.jsx("p",{className:"form-error",role:"alert",children:x}),o.jsxs("div",{className:"modal-actions",children:[o.jsx(G,{onClick:s,disabled:g,children:a("common.cancel")}),o.jsx(G,{type:"submit",variant:"primary",disabled:g||!v||S,children:a(g?"common.processing":"team.form.submitCreate")})]})]})]})}const l$=["muted","info","warn","ok","danger","band"],el={queued:"status.queued",running:"status.running",waiting:"status.waiting",cancelling:"status.cancelling",interrupted:"status.interrupted",completed:"status.completed",failed:"status.failed",cancelled:"status.cancelled",skipped:"status.skipped",pending:"status.pending",connected:"status.connected",disconnected:"status.disconnected",unreachable:"status.unreachable",disabled:"status.disabled",unavailable:"status.unavailable"},Nd={queued:{glyph:"○",tone:"muted"},running:{glyph:"◐",tone:"info"},waiting:{glyph:"!",tone:"warn"},cancelling:{glyph:"◑",tone:"warn"},interrupted:{glyph:"‖",tone:"warn"},completed:{glyph:"✓",tone:"ok"},failed:{glyph:"✗",tone:"danger"},cancelled:{glyph:"–",tone:"muted"},skipped:{glyph:"·",tone:"muted"},pending:{glyph:"·",tone:"muted"},connected:{glyph:"✓",tone:"ok"},disconnected:{glyph:"✗",tone:"danger"},unreachable:{glyph:"!",tone:"danger"},disabled:{glyph:"–",tone:"muted"},unavailable:{glyph:"?",tone:"muted"}},ec={error:"failed",passed:"completed",pass:"completed",ok:"completed",active:"running",waiting_permission:"waiting",idle:"pending",on:"connected",off:"disabled",open:"connected",closed:"disabled"},Fb=new Set(Object.keys(Nd)),PR={muted:"bg-sunken text-faint",info:"bg-info-soft text-info",warn:"bg-warn-soft text-warn",ok:"bg-success-soft text-success",danger:"bg-danger-soft text-danger",band:"bg-raised text-ink"},qR=zi("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5 font-mono text-xs tracking-wide",{variants:{tone:PR},defaultVariants:{tone:"muted"}}),OR={muted:"bg-sunken text-faint",info:"bg-info-soft text-info",warn:"bg-warn-soft text-warn",ok:"bg-success-soft text-success",danger:"bg-danger-soft text-danger"},DR=zi("inline-flex size-4 flex-none items-center justify-center rounded-full font-mono text-2xs leading-none",{variants:{tone:OR},defaultVariants:{tone:"muted"}});function Bb(e){return e?Fb.has(e)?e:ec[e]??"pending":"pending"}function Ri(e){return e?Fb.has(e)?a(el[e]):ec[e]?a(el[ec[e]]):e:a(el.pending)}function Kb({status:e,showCompleted:t=!1,label:n}){const s=Bb(e);if(s==="completed"&&!t)return null;const r=Nd[s],i=n??Ri(e);return o.jsx(xt,{label:i,children:o.jsx("span",{className:be(DR({tone:r.tone}),s==="running"&&"pulse-soft"),"data-status":s,role:"img","aria-label":i,children:r.glyph})})}function Tt({status:e,label:t,title:n,variant:s="default"}){const r=Bb(e),i=Nd[r],l=t??Ri(e),c=s==="onBand"?"band":i.tone;return o.jsx(xt,{label:n??Ri(e),children:o.jsxs("span",{className:qR({tone:c}),"data-status":r,children:[o.jsx("span",{className:be("text-2xs",r==="running"&&"pulse-soft"),"aria-hidden":"true",children:i.glyph}),o.jsx("span",{children:l})]})})}function Wb(){return{lastAppliedSeq:0,fallbackBodyHistory:{},rosterDirty:!1}}function HR(e,t){return e.ts!==t.ts?e.ts-t.ts:e.message_id===t.message_id?0:e.message_id<t.message_id?-1:1}function ai(e){return[...e].sort(HR)}function Li(e,t){const n=new Map;for(const s of e)n.set(s.message_id,s);for(const s of t)n.set(s.message_id,s);return ai([...n.values()])}function $R(e,t){return{messages:Li(e,t.messages),hasMore:t.messages_has_more===!0}}function Wo(e){return typeof e=="string"&&e.length>0?e:void 0}function FR(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function BR(e,t,n){const s=e[t]??[];return s.some(r=>r.session_id===n.session_id)?e:{...e,[t]:[...s,n].slice(-20)}}function KR(e,t,n){const s=Wo(e.data.team_id);if(s!==void 0)return s===t;const r=Wo(e.data.session_id);return r===void 0||n===void 0?!1:n.has(r)}function Ub(e,t,n,s){if(t.seq!==void 0&&t.seq<=e.lastAppliedSeq)return e;const r=t.seq!==void 0?{...e,lastAppliedSeq:t.seq}:e;if(!KR(t,n,s))return r;switch(t.type){case"agent.retired":{const i=Wo(t.data.agent_id),l=Wo(t.data.body_id);if(!i||!l)return r;const c=Wo(t.data.reason),d=BR(r.fallbackBodyHistory,i,{session_id:l,epoch:FR(t.data.epoch)??0,observed_at:t.ts,...c!==void 0?{reason:c}:{}});return d===r.fallbackBodyHistory?r:{...r,fallbackBodyHistory:d}}case"agent.restarting":case"agent.restarted":case"agent.compact_forked":return{...r,rosterDirty:!0};default:return t.type.startsWith("run.")||t.type.startsWith("agent.")?{...r,rosterDirty:!0}:r}}function WR(e){return!e||e.body_history===void 0?null:[...e.body_history].sort((t,n)=>t.epoch-n.epoch)}function UR(e,t){return[...e.fallbackBodyHistory[t]??[]].sort((n,s)=>n.observed_at-s.observed_at)}function zR(e,t){return e!==null?{source:"server",server:e,observed:[]}:{source:"observed",server:[],observed:[...t]}}function go(e,t,n){return`${e}:${t}:${n}`}function tl(e){return`team:list:${e}`}function nl(e){return`team:detail:${e}`}const St=vn()((e,t)=>({lists:{},details:{},loadList:async(n,s)=>{const r=ge(n),i=t().lists[r],l=gn(tl(r));e(c=>({lists:{...c.lists,[r]:Qo(i)}}));try{const c=await pg(n,s);if(!kt(tl(r),l))return;e(d=>({lists:{...d.lists,[r]:qn(c)}}))}catch(c){if(!kt(tl(r),l))return;e(d=>({lists:{...d.lists,[r]:bs(i,c)}}))}},loadAllLists:async(n,s)=>{await Promise.all(n.map(r=>t().loadList(r,s(r))))},loadDetail:async(n,s,r,i={},l="chat")=>{const c=go(n,s,l),d=t().details[c],m=gn(nl(c));e(f=>({details:{...f.details,[c]:Qo(d)}}));try{const f=await r.getTeam(s,i);if(!kt(nl(c),m))return;e(h=>({details:{...h.details,[c]:qn(f)}}))}catch(f){if(!kt(nl(c),m))return;e(h=>({details:{...h.details,[c]:bs(d,f)}}))}},post:(n,s)=>n.postTeam(s),update:(n,s)=>n.updateTeam(s),create:(n,s)=>n.createTeam(s),archive:(n,s)=>n.archiveTeam(s),setSpawnFrozen:(n,s,r)=>n.setSpawnFrozen(s,r),reset:()=>{e({lists:{},details:{}})}}));function VR(e){return St(t=>t.lists[ge(e)])}function Cd(e){return e===void 0?void 0:Se(e)}function GR({entries:e,observed:t,onOpenBody:n}){return t.length>0?o.jsx("ul",{className:"m-0 flex list-none flex-col gap-1.5 p-0",children:t.map(s=>o.jsxs("li",{className:"team-body-history-item tint-hover",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[o.jsx("span",{className:"font-medium text-ink",children:a("team.member.sessionIndex",{n:s.epoch})}),s.reason&&o.jsx("span",{className:"font-mono text-xs text-muted",children:s.reason})]}),o.jsx("span",{className:"truncate font-mono text-xs text-faint",title:s.session_id,children:s.session_id})]}),o.jsx("div",{className:"team-body-history-meta flex flex-none flex-col gap-0.5 text-xs text-muted tabular-nums",children:o.jsx("span",{children:a("team.member.observedAt",{time:bt(s.observed_at)})})}),o.jsx(Cn,{label:a("team.member.viewTranscript"),onClick:()=>n(s.session_id),children:o.jsx(yt,{name:"transcript"})})]},s.session_id))}):e.length===0?o.jsx($e,{title:a("team.member.empty")}):o.jsx("ul",{className:"m-0 flex list-none flex-col gap-1.5 p-0",children:e.map(s=>o.jsxs("li",{className:"team-body-history-item tint-hover",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[o.jsx("span",{className:"truncate text-sm font-medium text-ink",children:a("team.member.sessionIndex",{n:s.epoch})}),o.jsx("span",{className:"truncate font-mono text-xs text-faint",title:s.session_id,children:s.session_id})]}),o.jsxs("div",{className:"team-body-history-meta flex flex-none flex-col gap-0.5 text-xs text-muted tabular-nums",children:[o.jsx("span",{children:a("team.member.startedAt",{time:bt(s.started_at)})}),o.jsx("span",{children:a("team.member.retiredAt",{time:bt(s.retired_at)})})]}),o.jsx(Cn,{label:a("team.member.viewTranscript"),onClick:()=>n(s.session_id),children:o.jsx(yt,{name:"transcript"})})]},s.session_id))})}function YR({member:e,onOpenSession:t}){const n=(e.bodies??[]).filter(s=>s.retired_at===void 0);return n.length===0?null:o.jsxs("div",{className:"mt-4 flex flex-col gap-1.5 border-t border-line pt-3",children:[o.jsx("h3",{className:"m-0 text-sm font-semibold text-muted",children:a("team.member.liveBodies",{count:n.length})}),o.jsx("ul",{className:"m-0 flex list-none flex-col gap-1.5 p-0",children:n.map((s,r)=>{const i=s.session_id??s.body_id??"",l=s.primary??(i.length>0&&i===e.session_id);return o.jsxs("li",{className:"team-body-item flex items-center gap-3 rounded-md bg-sunken px-3 py-2 text-sm",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[o.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"font-medium text-ink",children:s.epoch!==void 0?a("team.member.sessionIndex",{n:s.epoch}):"—"}),l&&o.jsx(Re,{className:"text-muted",children:a("team.member.primaryBadge")})]}),o.jsx("span",{className:"truncate font-mono text-xs text-faint",title:i,children:i||"—"})]}),s.state&&o.jsx("span",{className:"flex-none font-mono text-xs text-muted",children:s.state}),o.jsx(Cn,{label:a("team.member.openBody"),disabled:!i,onClick:()=>{i&&t(i)},children:o.jsx(yt,{name:"transcript"})})]},i||`body-${r}`)})})]})}const JR={completed:"team.state.completed",failed:"team.state.failed",cancelled:"team.state.cancelled"},Nf={kind:"idle",labelKey:"team.state.idle",chipStatus:"idle",tone:"muted"},Cf={kind:"unknown",labelKey:"team.state.unknown",chipStatus:"unknown",tone:"muted"};function ha(e){if(e?.membership==="left")return{kind:"left",labelKey:"team.membership.left",chipStatus:"disabled",tone:"muted"};if(!e)return Cf;if(e.presence==="gone")return{kind:"gone",labelKey:"team.presence.gone",chipStatus:"unavailable",tone:"muted"};const t=(e.state??"").trim().toLowerCase();switch(t){case"running":return{kind:"running",labelKey:"team.state.running",chipStatus:"running",tone:"info"};case"waiting_permission":return{kind:"waiting",labelKey:"team.state.waitingPermission",chipStatus:"waiting",tone:"warn"};case"closed":return{kind:"closed",labelKey:"team.state.closed",chipStatus:"closed",tone:"muted"};case"created":case"idle":return Nf;default:{const n=JR[t];return n?{...Nf,titleKey:n}:Cf}}}function QR(e){return e.membership==="present"&&e.presence==="live"}const zb=64*1024,XR=/[A-Za-z0-9._%+/-]/,ZR=/[./][A-Za-z0-9]/;function Tf(e,t){if(!Number.isFinite(t)||t<0||t>e.length)return null;const n=e.slice(0,t),s=n.lastIndexOf("@");if(s<0)return null;const r=n.slice(s+1);if(/\s/.test(r))return null;if(s>0){const i=n[s-1]??"";if(XR.test(i)&&ZR.test(r))return null}return{start:s,query:r}}function Vb(e){const t=e.name?.trim();return t&&t.length>0?t:e.agent_id}function Es(e){return e.length>8?e.slice(0,8):e}function eL(e){const t=new Map;for(const n of e){if(n.membership!=="present")continue;const s=n.name?.trim();s&&t.set(s,(t.get(s)??0)+1)}return t}function tL(e,t,n=8){const s=t.trim().toLowerCase(),r=eL(e),i=[];for(const l of e){if(l.membership!=="present")continue;const c=l.name?.trim(),d=`${c??""} ${l.agent_id}`.toLowerCase();if(s.length>0&&!d.includes(s))continue;let m;c?(r.get(c)??0)>1?m=`${c} (${Es(l.agent_id)})`:m=c:m=l.agent_id,i.push({agentId:l.agent_id,label:m,member:l})}return i.sort((l,c)=>l.label===c.label?l.agentId<c.agentId?-1:1:l.label<c.label?-1:1),i.slice(0,Math.max(0,n))}function nL(e,t,n){const s=t.start+1+t.query.length;return{value:`${e.slice(0,t.start)}@${n} ${e.slice(s)}`,caret:t.start+1+n.length+1}}function sL(e){const t=new Set,n=[];for(const s of e)t.has(s.agentId)||(t.add(s.agentId),n.push(s.agentId));return n}function oL(e){return new TextEncoder().encode(e).length}function rL(e){return oL(e)>zb}function ks(e){const t=e.role;return t!==void 0?t==="single"?"member":t:e.owner===void 0?"member":"temporary"}function Ss(e){return`team.role.${e}`}function iL(e){const t=[],n=[];for(const s of e)ks(s)==="temporary"?n.push(s):t.push(s);return[...t,...n]}function aL(e){return["member","temporary"].filter(t=>t!==e)}function lL(e,t){return e==="member"&&(t?.trim()??"")===""?"member_requires_team":void 0}const cL={member:"team.role.toMember",temporary:"team.role.toTemporary"};function dL(e){const t=e.code;return typeof t=="string"?t:void 0}function uL({member:e,teamId:t,nodeKey:n,client:s,hasToken:r,onConverted:i}){const l=$i(),c=ks(e),d=aL(c),m=St(N=>N.lists[n]),f=Cd(m)?.teams??[],h=f.filter(N=>N.archived_at===void 0),[p,g]=u.useState(t),[b,x]=u.useState(null),[y,v]=u.useState(null),[j,_]=u.useState(!1),S=d.includes("member"),w=r&&!j,k=async N=>{if(!w||b)return;if(lL(N,p)){v(a("team.role.memberRequiresTeam"));return}x(N),v(null);const R={agent_id:e.agent_id,role:N};N==="member"&&(R.team_id=p.trim());try{await s.updateAgent(R),l?.success(a("team.role.success",{name:e.name?.trim()||Es(e.agent_id),role:a(Ss(N))})),i()}catch(E){if(dL(E)==="forbidden")_(!0),v(a("team.role.forbidden"));else{const I=E instanceof Error?E.message:String(E);v(`${a("team.role.failed")}: ${I}`)}}finally{x(null)}};return o.jsx(et,{title:a("team.role.convert"),actions:o.jsx("div",{className:"ml-auto flex flex-wrap gap-2",children:d.map(N=>o.jsx(G,{size:"small",disabled:!w||b!==null,onClick:()=>{k(N)},children:a(b===N?"team.role.busy":cL[N])},N))}),children:o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsx(Gt,{className:"mt-0 gap-y-2.5",items:[{key:"role",label:a("team.role.label"),value:o.jsx(Re,{children:a(Ss(c))})},...S?[{key:"team",label:a("team.role.memberTeam"),value:o.jsxs($t,{id:"member-role-team",value:p,onChange:N=>g(N.target.value),"aria-label":a("team.role.memberTeam"),disabled:!w||b!==null,children:[h.length===0&&o.jsx("option",{value:t,children:f.find(N=>N.team_id===t)?.name||t}),h.map(N=>o.jsx("option",{value:N.team_id,children:N.name||N.team_id},N.team_id))]})}]:[]]}),!r&&o.jsx("p",{className:"m-0 text-xs text-muted",children:a("common.writesDisabled")}),y&&o.jsx("p",{className:"m-0 rounded-sm bg-danger-soft px-2.5 py-1.5 text-xs text-danger",role:"alert",children:y})]})})}const Gb=["file","health","script","agent","team-log"];function mL(e){return Gb.includes(e.source)}function fL(e,t){return e===null?[]:t==="script"?e.scripts.map(n=>n.name):t==="health"?e.nodes.map(n=>n.node_id):t==="agent"?e.agents.map(n=>n.id):t==="team-log"?e.teams.map(n=>n.team_id):[]}function Yb({client:e,agentId:t,hasToken:n}){const s=ot(),[r,i]=u.useState(null),[l,c]=u.useState(null),[d,m]=u.useState(!1),[f,h]=u.useState(null),[p,g]=u.useState(!1),[b,x]=u.useState("file"),[y,v]=u.useState(""),[j,_]=u.useState(!1),[S,w]=u.useState(null),[k,N]=u.useState(null),[T,R]=u.useState(!1),[E,I]=u.useState(null),[$,C]=u.useState(null),L=u.useCallback(async()=>{try{const B=await e.listSubscriptions(t);i(B),h(null)}catch(B){h(ps(B,"team.member.subs.error"))}finally{g(!0)}try{c(await e.subscriptionCatalog()),m(!1)}catch{c(null),m(!0)}},[e,t]);qt(()=>{L()},{enabled:n,pollMs:1e4,deps:[t]});const A=u.useMemo(()=>(r?.entries??[]).filter(mL),[r]),D=async()=>{const B=y.trim();if(!(B===""||j)){_(!0),w(null);try{await e.addSubscription(t,b,B),s.success(a("team.member.subs.addSuccess",{target:B})),v(""),await L()}catch(W){w(ps(W,"team.member.subs.error"))}finally{_(!1)}}},O=async()=>{if(!(k===null||T)){R(!0),I(null);try{const B=await e.removeSubscription(t,k.source,k.target);s.success(B.outcome==="muted"?a("team.member.subs.removeMuted"):a("team.member.subs.removeSuccess")),N(null),await L()}catch(B){I(ps(B,"team.member.subs.error"))}finally{R(!1)}}},F=async(B,W,Z)=>{const ee=`${B}:${W}`;if($===null){C(ee);try{Z?await e.unmuteSubscription(t,B,W):await e.muteSubscription(t,B,W),await L()}catch(ie){s.error(ps(ie,"team.member.subs.error"))}finally{C(null)}}};if(!n)return o.jsx(Ve,{message:a("team.error.noToken")});if(!p)return o.jsx(Ke,{rows:3});if(r===null)return o.jsx(Ve,{message:f??a("team.member.subs.error"),onRetry:()=>{L()}});const V=fL(l,b);return o.jsxs("div",{className:"flex w-full flex-col gap-5",children:[o.jsx(et,{title:a("team.member.subs.title"),actions:o.jsx("span",{className:"ml-auto text-sm tabular-nums text-muted",children:A.length}),children:A.length===0?o.jsx("p",{className:"m-0 text-sm text-faint",children:a("team.member.subs.empty")}):o.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:A.map(B=>o.jsxs("li",{className:"flex flex-wrap items-center gap-2 rounded-md border border-line bg-surface px-3 py-2",children:[o.jsx(Re,{children:B.source}),B.tier!==void 0&&o.jsx(Re,{children:B.tier}),o.jsx("span",{className:"min-w-0 break-all font-mono text-sm",children:B.target}),B.muted&&o.jsx(Re,{children:a("team.member.subs.muted")}),B.friend!==void 0&&o.jsx(Re,{children:a("team.member.subs.friend",{origin:B.friend.origin})}),o.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.origin",{origin:B.origin})}),o.jsx(G,{variant:"dangerGhost",onClick:()=>{I(null),N(B)},children:a("team.member.subs.remove")})]})]},B.key))})}),o.jsx(et,{title:a("team.member.subs.implicitTitle"),children:o.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:r.implicit.map(B=>{const W=`${B.source}:${B.target}`;return o.jsxs("li",{className:"flex flex-wrap items-center gap-2 rounded-md border border-line bg-surface px-3 py-2",children:[o.jsx(Re,{children:B.source}),o.jsx("span",{className:"font-mono text-sm",children:B.target}),o.jsx("span",{className:"text-xs text-faint",children:B.muted?a("team.member.subs.muted"):a("team.member.subs.on")}),o.jsx(G,{className:"ml-auto",disabled:$!==null,onClick:()=>{F(B.source,B.target,B.muted)},children:B.muted?a("team.member.subs.unmute"):a("team.member.subs.mute")})]},W)})})})," ",o.jsxs(et,{title:a("team.member.subs.addTitle"),children:[o.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[o.jsxs("label",{className:"flex flex-col gap-1.5",htmlFor:"subscription-add-source",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.addSource")}),o.jsx($t,{id:"subscription-add-source","aria-label":a("team.member.subs.addSource"),value:b,onChange:B=>{x(B.target.value),w(null)},children:Gb.map(B=>o.jsx("option",{value:B,children:B},B))})]}),o.jsxs("label",{className:"flex min-w-52 grow flex-col gap-1.5",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.addTarget")}),o.jsx("input",{className:"rounded-md border border-line bg-surface px-2.5 py-2 font-mono text-sm text-ink",value:y,list:"subscription-add-candidates",placeholder:a("team.member.subs.addPlaceholder"),onChange:B=>v(B.target.value)}),o.jsx("datalist",{id:"subscription-add-candidates",children:V.map(B=>o.jsx("option",{value:B},B))})]}),o.jsx(G,{variant:"primary",disabled:j||y.trim()==="",onClick:()=>{D()},children:a("team.member.subs.add")})]}),S&&o.jsx("p",{className:"mt-2 mb-0 text-xs text-danger",role:"alert",children:S})]}),o.jsx(et,{title:a("team.member.subs.poolTitle"),children:d||l===null?o.jsx("p",{className:"m-0 text-sm text-faint",children:a("team.member.subs.degraded")}):o.jsxs("div",{className:"flex flex-col gap-3 text-sm",children:[o.jsx("p",{className:"m-0 text-xs text-faint",children:a("team.member.subs.pool.implicitHint")}),l.scripts.length>0&&o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.pool.scripts")}),o.jsx("ul",{className:"m-0 flex list-none flex-wrap gap-1.5 p-0",children:l.scripts.map(B=>o.jsx("li",{children:o.jsxs(Re,{children:[B.name," · ",B.scope," ·"," ",B.schedule==="interval"?a("team.member.subs.schedule.interval",{seconds:B.interval_seconds??0}):a(`team.member.subs.schedule.${B.schedule}`)]})},B.name))})]}),l.nodes.length>0&&o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.pool.nodes")}),o.jsx("ul",{className:"m-0 flex list-none flex-wrap gap-1.5 p-0",children:l.nodes.map(B=>o.jsx("li",{children:o.jsx(Re,{children:B.name||B.node_id})},B.node_id))})]}),l.agents.length>0&&o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.pool.agents")}),o.jsx("ul",{className:"m-0 flex list-none flex-wrap gap-1.5 p-0",children:l.agents.map(B=>o.jsx("li",{children:o.jsx(Re,{children:B.name?.trim()||B.id})},B.id))})]}),l.teams.length>0&&o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.pool.teams")}),o.jsx("ul",{className:"m-0 flex list-none flex-wrap gap-1.5 p-0",children:l.teams.map(B=>o.jsx("li",{children:o.jsx(Re,{children:B.name||B.team_id})},B.team_id))})]}),l.file.allowed_roots.length>0&&o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-xs text-faint",children:a("team.member.subs.pool.file")}),o.jsx("ul",{className:"m-0 flex list-none flex-wrap gap-1.5 p-0",children:l.file.allowed_roots.map(B=>o.jsx("li",{children:o.jsx(Re,{children:B})},B))})]}),l.truncated&&o.jsx("p",{className:"m-0 text-xs text-faint",children:a("team.member.subs.truncated")})]})}),k!==null&&o.jsx(In,{title:a("team.member.subs.removeTitle"),body:o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"m-0",children:a("team.member.subs.removeBody")}),o.jsxs("p",{className:"m-0 font-mono text-sm",children:[k.source,": ",k.target]}),k.friend!==void 0&&o.jsx("p",{className:"m-0 text-xs text-faint",children:a("team.member.subs.removeFriendHint")}),E&&o.jsx("p",{className:"m-0 text-xs text-danger",role:"alert",children:E})]}),confirmLabel:a("team.member.subs.remove"),danger:!0,busy:T,onConfirm:()=>{O()},onCancel:()=>{T||N(null)}})]})}function hL(e){const t=e?.code;return t==="not_found"||t==="not_visible"?a("team.member.rotate.error.notFound"):t==="conflict"?a("team.member.rotate.error.conflict"):t==="invalid_params"?a("team.member.rotate.error.invalid"):t==="quota_exceeded"?a("team.member.rotate.error.quota"):e instanceof Error?e.message:String(e)}function pL({client:e,hasToken:t,epoch:n,teamId:s,memberId:r,nodeKey:i="local",events:l,onBack:c,onOpenSession:d,onOpenBody:m,initialDetail:f,initialError:h}){const p=go(i,s,"member"),g=St(z=>z.details[p]),b=St(z=>z.loadDetail),x=()=>{b(i,s,e,{limit:1},"member")},y=u.useRef(x);y.current=x;const v=u.useCallback(()=>{y.current()},[]);Lt(v);const j=u.useMemo(()=>{let z=Wb();for(const me of l)me.seq<=z.lastAppliedSeq||(z=Ub(z,{...me.event,seq:me.seq},s));return z},[l,s]),_=Se(g)??f,S=u.useMemo(()=>_?.members.find(z=>z.agent_id===r),[_,r]),w=u.useMemo(()=>UR(j,r),[j,r]),k=u.useMemo(()=>zR(WR(S),w),[S,w]),{eventStore:N}=Ae(),T=u.useMemo(()=>{const z=new Set;S?.session_id&&z.add(S.session_id);for(const me of S?.bodies??[]){const K=me.session_id??me.body_id;K&&z.add(K)}return z},[S]),R=Sr(N,z=>{const me=z.event.type;if(!me.startsWith("agent.")&&!me.startsWith("run."))return!1;const K=z.event.data??{};if(K.agent_id===r)return!0;const ne=typeof K.session_id=="string"?K.session_id:z.sessionId;return ne!==void 0&&T.has(ne)},`${n}:${i}:${s}:${r}`);qt(()=>{b(i,s,e,{limit:1},"member")},{enabled:t,pollMs:1e4,deps:[n,s,i,R]});const E=ot(),[I,$]=u.useState("overview"),[C,L]=u.useState(!1),[A,D]=u.useState(""),[O,F]=u.useState(!1),[V,B]=u.useState(null),W=g?.status==="error"?{message:g.error,code:g.code}:h;if(!t)return o.jsx(Fe,{title:a("team.error.noToken"),reason:a("team.error.noTokenReason")});if(!_&&W)return W.code==="not_found"?o.jsx(Fe,{title:a("team.error.notEnabled"),reason:a("team.error.notEnabledReason"),hint:a("team.error.notEnabledHint")}):o.jsx(Ve,{message:W.message,onRetry:x});if(!_)return o.jsx(Ke,{rows:3});if(!S)return o.jsx($e,{title:a("team.error.notFound"),action:o.jsx(G,{onClick:c,children:a("team.chat.backToList")})});const Z=ha(S),ee=S.name?.trim()||Es(S.agent_id),ie=k.source==="observed",le=()=>{D(a("team.member.rotate.defaultPrompt",{name:ee})),B(null),L(!0)},J=async()=>{const z=A.trim();if(!(!z||O)){F(!0),B(null);try{await e.createSession({agent_id:S.agent_id,startup_prompt:z}),E.success(a("team.member.rotate.success",{name:ee})),L(!1),x(),b(i,s,e,{limit:1},"chat")}catch(me){B(hL(me))}finally{F(!1)}}};return o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col",children:[W&&o.jsx(st,{message:a("team.error.stale"),onRetry:x}),o.jsx(Nn,{className:"mt-0",label:a("team.member.subs.tabLabel"),tabs:[{id:"overview",label:a("team.member.subs.tab.overview")},{id:"subscriptions",label:a("team.member.subs.tab.subscriptions")}],value:I,onChange:$,panelId:"member-detail-panel"}),I==="subscriptions"?o.jsx(Yb,{client:e,agentId:S.agent_id,hasToken:t}):o.jsxs("div",{className:"flex w-full flex-col gap-5",children:[o.jsxs(et,{title:a("team.member.currentBody"),actions:o.jsxs("div",{className:"ml-auto flex flex-wrap gap-2",children:[o.jsx(G,{variant:"primary",disabled:!S.session_id,onClick:()=>{S.session_id&&d(S.session_id)},children:a("team.member.currentSession")}),o.jsx(G,{onClick:le,children:a("team.member.rotate.open")})]}),children:[o.jsxs("div",{className:"grid gap-x-8 gap-y-4 md:grid-cols-2",children:[o.jsx(Gt,{className:"mt-0 gap-y-2.5",items:[{key:"sessionNumber",label:a("team.member.sessionNumber"),value:o.jsx("span",{className:"font-mono tabular-nums",children:S.epoch!==void 0?a("team.member.sessionIndex",{n:S.epoch}):"—"})},{key:"session",label:a("agents.detail.session"),value:o.jsx("span",{className:"font-mono",children:S.session_id??"—"})},{key:"state",label:a("agents.filter.state"),value:a(Z.labelKey)}]}),o.jsx(Gt,{className:"mt-0 gap-y-2.5",items:[{key:"presence",label:a("agents.filter.presence"),value:S.presence==="live"?a("team.presence.live"):a("team.presence.gone")},{key:"agentId",label:a("agents.detail.agentId"),value:o.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"font-mono",children:S.agent_id}),o.jsx(ls,{text:S.agent_id})]})},{key:"visibility",label:a("agents.detail.visibility"),value:o.jsx("span",{className:"font-mono",children:S.visibility})}]})]}),o.jsx(YR,{member:S,onOpenSession:d})]}),o.jsx(uL,{member:S,teamId:s,nodeKey:i,client:e,hasToken:t,onConverted:x},`${i}:${s}:${S.agent_id}`),o.jsx(et,{title:a("team.member.retiredBodies"),actions:o.jsx("span",{className:"ml-auto text-sm tabular-nums text-muted",children:w.length>0?w.length:k.server.length}),children:o.jsxs("div",{className:"flex flex-col gap-2.5",children:[ie&&w.length>0&&o.jsx("p",{className:"m-0 text-xs text-muted",children:a("team.member.observedOnly")}),o.jsx(GR,{entries:k.server,observed:k.observed,onOpenBody:m})]})})]}),C&&o.jsx(In,{title:a("team.member.rotate.title"),body:o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"m-0",children:a("team.member.rotate.description",{name:ee})}),o.jsxs("label",{className:"flex flex-col gap-1.5",htmlFor:"rotate-startup-prompt",children:[o.jsx("span",{className:"text-faint",children:a("team.member.rotate.startupLabel")}),o.jsx("textarea",{id:"rotate-startup-prompt",className:"min-h-28 w-full rounded-md border border-line bg-surface p-2.5 font-mono text-sm leading-relaxed text-ink",value:A,disabled:O,onChange:z=>D(z.target.value)})]}),V&&o.jsx("p",{className:"m-0 text-danger",children:V})]}),confirmLabel:a("team.member.rotate.confirm"),busy:O,confirmDisabled:A.trim().length===0,onConfirm:()=>{J()},onCancel:()=>{O||L(!1)}})]})}function gL({node:e,agent:t,onBack:n,onEdit:s,onSaved:r,onOpenSession:i,onOpenBody:l}){He();const c=ot(),{epoch:d}=Ae(),{teamControl:m,hasTokenFor:f}=ut(),h=Ji(),p=Bt(),[g,b]=u.useState(!1),[x,y]=u.useState(!1),[v,j]=u.useState(null),_=t.member,S=wr(_),w=_.membership==="left",k=ha(_),N=Gg("agent",Ts(_)),T=async()=>{y(!0),j(null);try{const R=await m(e).closeAgent(_.agent_id);c.success(a("agents.close.success",{name:R.name?.trim()||_.name?.trim()||S})),b(!1),r()}catch(R){j(ps(R,"agents.close.failed"))}finally{y(!1)}};return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain p-6 pb-10 max-compact:px-3 max-compact:pt-4 max-compact:pb-7 [&>*]:mx-auto [&>*]:w-full [&>*]:max-w-[var(--content-max)]",children:[o.jsx(xr,{title:S,scope:[...t.team?[{label:t.team.name||t.team.team_id}]:[],{label:p.get(ge(e))??"—"}],current:e.current,status:o.jsxs(o.Fragment,{children:[o.jsx(Tt,{status:k.chipStatus,label:a(k.labelKey),title:k.titleKey?a(k.titleKey):void 0}),o.jsx(Re,{children:a(Ss(ks(_)))})]})}),N&&o.jsx("p",{className:"mt-3 mb-0 rounded-sm border border-line-strong bg-warn-soft px-3 py-2 text-sm text-warn",role:"status",children:a(N)}),o.jsxs(En,{label:a("agents.detailActions"),className:"mt-3",children:[o.jsx(G,{onClick:s,disabled:w,children:a("common.edit")}),o.jsx(G,{variant:"dangerGhost",disabled:w,onClick:()=>{j(null),b(!0)},children:a("agents.close")}),o.jsx(G,{onClick:n,children:a("agents.back")})]}),o.jsx("div",{className:"mt-5 flex flex-col gap-4",children:t.team?o.jsx(pL,{client:m(e),hasToken:f(e),epoch:d,teamId:t.team.team_id,memberId:_.agent_id,nodeKey:ge(e),events:e.current?h.entries:[],onBack:n,onOpenSession:i,onOpenBody:l}):o.jsxs(o.Fragment,{children:[o.jsxs(et,{title:a("agents.detail.title"),children:[o.jsx(Gt,{items:[{key:"node",label:a("agents.filter.node"),value:p.get(ge(e))??"—"},{key:"team",label:a("agents.filter.team"),value:"—"},{key:"role",label:a("team.role.label"),value:a(Ss(ks(_)))},{key:"state",label:a("agents.filter.state"),value:o.jsx(Tt,{status:_.state})},{key:"presence",label:a("agents.filter.presence"),value:a(`agents.presence.${_.presence}`)},{key:"membership",label:a("agents.detail.membership"),value:a(`team.membership.${_.membership}`)},{key:"visibility",label:a("agents.detail.visibility"),value:o.jsx("span",{className:"font-mono",children:_.visibility})},{key:"session",label:a("agents.detail.session"),value:_.session_id?o.jsx(G,{variant:"link",onClick:i,disabled:!e.current,children:a("team.member.currentSession")}):"—"}]}),o.jsxs("details",{className:"mt-3 border-t border-line pt-2",children:[o.jsx("summary",{className:"cursor-pointer text-sm text-faint",children:a("agents.detail.advanced")}),o.jsx(Gt,{className:"mt-2",items:[{key:"agentId",label:a("agents.detail.agentId"),value:o.jsx("span",{className:"font-mono",children:_.agent_id})}]})]})]}),o.jsx(Yb,{client:m(e),agentId:_.agent_id,hasToken:f(e)})]})}),g&&o.jsx(In,{title:a("agents.close.title"),body:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:a("agents.close.body")}),o.jsx("p",{className:"font-mono",children:S}),v&&o.jsx("p",{className:"text-xs text-danger leading-snug",role:"alert",children:v})]}),confirmLabel:a("agents.close"),danger:!0,busy:x,onConfirm:()=>{T()},onCancel:()=>{x||(b(!1),j(null))}})]})}function bL({node:e,agent:t,onBack:n,onSaved:s}){He();const r=ot(),{teamControl:i}=ut(),l=Bt(),c=t.member,d=wr(c),[m,f]=u.useState({name:c.name?.trim()??"",model:c.model??"",systemPrompt:"",teamId:""}),[h,p]=u.useState(!1),[g,b]=u.useState(null),x=v=>j=>{f(_=>({..._,[v]:j})),b(null)},y=async v=>{if(v.preventDefault(),h)return;const j=LR(c.agent_id,{name:c.name??"",model:c.model??"",systemPrompt:""},m);if(!j.ok||!j.input){b(a("agents.form.noChange"));return}p(!0),b(null);try{const _=await i(e).updateAgent(j.input);r.success(a("agents.form.updated",{name:_.name?.trim()||m.name.trim()||d})),s(),n()}catch(_){b(ps(_,"agents.form.updateFailed"))}finally{p(!1)}};return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsxs(Ct,{title:a("agents.edit.title"),subtitle:a("agents.edit.subtitle"),children:[o.jsx(En,{label:a("agents.detailActions"),children:o.jsx(G,{onClick:n,children:a("agents.back")})}),o.jsxs(et,{children:[o.jsxs("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:[l.get(ge(e))??"—",t.team?` · ${t.team.name||t.team.team_id}`:""," · ",d]}),o.jsxs("form",{className:"flex flex-col gap-2",onSubmit:y,children:[o.jsxs("div",{className:"form-grid mt-1",children:[o.jsx(We,{label:a("team.form.name"),htmlFor:"agent-edit-name",children:o.jsx(Xe,{id:"agent-edit-name",value:m.name,onChange:v=>x("name")(v.target.value),spellCheck:!1,autoComplete:"off"})}),o.jsx(We,{label:a("agents.form.model"),htmlFor:"agent-edit-model",hint:a("agents.form.modelHint"),children:o.jsx(_d,{id:"agent-edit-model",node:e,value:m.model,onChange:x("model"),emptyLabel:a("modelPicker.keepUnchanged"),"aria-label":a("agents.form.model")})}),o.jsx(We,{className:"col-span-full",label:a("agents.form.systemPrompt"),htmlFor:"agent-edit-system-prompt",hint:a("agents.form.systemPromptHint"),children:o.jsx(Hi,{id:"agent-edit-system-prompt",className:"min-h-24 resize-y text-sm leading-normal",value:m.systemPrompt,onChange:v=>x("systemPrompt")(v.target.value),rows:6,spellCheck:!1})})]}),g&&o.jsx("p",{className:"form-error",role:"alert",children:g}),o.jsxs("div",{className:"form-actions",children:[o.jsx(G,{onClick:n,disabled:h,children:a("common.cancel")}),o.jsx(G,{type:"submit",variant:"primary",disabled:h,children:a(h?"common.processing":"team.form.submitEdit")})]})]})]})]})})}function vL({agent:e,nodeName:t,onOpen:n}){const s=e.member,r=wr(s),i=s.presence==="live"?a("agents.presence.live"):a("agents.presence.gone"),l=Ts(s);return o.jsx("li",{className:"min-w-0",children:o.jsxs("button",{type:"button",className:Kh,onClick:n,children:[o.jsxs("span",{className:"flex min-w-0 items-start justify-between gap-2",children:[o.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2 wrap-anywhere text-md font-semibold text-ink",children:[r,o.jsx(Re,{children:a(Ss(ks(s)))}),l&&o.jsx(Re,{tone:"warn",className:"flex-none",children:a(cd("agent"))})]}),o.jsx(Tt,{status:s.state})]}),o.jsxs("span",{className:"min-w-0 wrap-anywhere text-xs text-faint",children:[t,e.team?` · ${e.team.name||e.team.team_id}`:""]}),o.jsxs("span",{className:"mt-auto inline-flex items-center gap-1 whitespace-nowrap text-sm text-muted",children:[o.jsx("span",{className:`size-1.75 rounded-full ${s.presence==="live"?"bg-success":"bg-faint"}`,"aria-hidden":"true"}),i]})]})})}const yL=2e4,xL=["live","gone"];function Ef(e){return e.code==="forbidden"?a("teams.error.forbidden"):e.code==="not_supported"?a("teams.error.notEnabled"):e.error??a("common.loadFailed")}function Hr(e,t,n){const s={domain:"agents",...e.nodeKey?{nodeKey:e.nodeKey}:{},...e.teamId?{teamId:e.teamId}:{},...e.state?{state:e.state}:{},...e.presence?{presence:e.presence}:{}};return n?s[t]=n:delete s[t],s}function wL(e){const[,t=""]=Fn(e).split("?",2);return t}function kL({route:e,navigate:t}){He();const{epoch:n,eventStore:s}=Ae(),{nodes:r,teamControl:i,hasTokenFor:l}=ut(),c=Bt(),[d,m]=u.useState(""),[f,h]=u.useState(!1),[p,g]=u.useState(()=>Si(window.location.hash)),b=r.some(z=>l(z)),x=r.filter(z=>l(z)),y=wL(e);u.useEffect(()=>{const z=()=>g(Si(window.location.hash));return window.addEventListener("hashchange",z),()=>window.removeEventListener("hashchange",z)},[]);const v=r.map(z=>ge(z)).join(","),j=Yt(z=>z.roster),_=Yt(z=>z.loadRoster),S=Yt(z=>z.selectAgent),w=u.useCallback(()=>{_(r,i)},[_,r,i]);Lt(w);const k=Sr(s,z=>dd(z.event),n);qt(()=>{_(r,i)},{enabled:b&&r.length>0,pollMs:yL,deps:[n,v,k]});const N=Se(j),T=N!==void 0,R=N??[],E=u.useMemo(()=>new Map(R.map(z=>[ge(z.node),z])),[R]),I=u.useMemo(()=>ql(R),[R]),$=ra(),C=u.useMemo(()=>DT(I,$),[I,$]),L=u.useMemo(()=>ld(I,$,z=>Ts(z.member)),[I,$]),A=u.useMemo(()=>r_(C),[C]),D=u.useMemo(()=>C_(o_(C,e),d),[C,e,d]),O=R.filter(z=>!z.ok),F=R.length>0&&O.length===R.length,V=R.reduce((z,me)=>z+me.partialErrors,0),B=!!(e.nodeKey||e.teamId||e.state||e.presence||d.trim()),W=z=>E.get(z)?.teams.filter(me=>me.archived_at===void 0)??[],Z=(z,me)=>{S(me),window.location.hash=Ua(oo(z,me),y)},ee=(z,me)=>{window.location.hash=Ua(_g(z,me),y)},ie=()=>{window.location.hash=y?`#/agents?${y}`:"#/agents"},le=()=>{m(""),t({domain:"agents"})};if(!b)return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("agents.title"),subtitle:a("agents.subtitle"),children:o.jsx(Fe,{title:a("team.error.noToken"),reason:a("team.error.noTokenReason")})})});if(p){const z=r.find(ne=>ge(ne)===p.nodeKey);if(!z)return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("agents.title"),subtitle:a("agents.subtitle"),children:o.jsx(Fe,{title:a("agents.error.nodeMissing"),action:o.jsx(G,{onClick:ie,children:a("agents.back")})})})});const me=E.get(p.nodeKey),K=me?ql([me]).find(ne=>ne.member.agent_id===p.agentId):void 0;return T?K?p.mode==="edit"?o.jsx(bL,{node:z,agent:K,onBack:()=>Z(p.nodeKey,p.agentId),onSaved:w}):p.bodyId?o.jsx(CR,{client:i(z),hasToken:l(z),epoch:n,bodyId:p.bodyId,memberName:wr(K.member),teamName:K.team?.name?.trim()||void 0,onBackToMember:()=>Z(p.nodeKey,p.agentId)}):o.jsx(gL,{node:z,agent:K,onBack:ie,onEdit:()=>ee(p.nodeKey,p.agentId),onSaved:w,onOpenSession:()=>{const ne=K.member.session_id;ne&&t({domain:"chat",sessionId:ne})},onOpenBody:ne=>{window.location.hash=Ua(Jc(p.nodeKey,p.agentId,ne),y)}}):o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("agents.title"),subtitle:a("agents.subtitle"),children:me&&!me.ok?o.jsx(Fe,{title:a("teams.error.notEnabled"),reason:Ef(me)}):o.jsx(Fe,{title:a("agents.error.notFound"),action:o.jsx(G,{onClick:ie,children:a("agents.back")})})})}):o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("agents.title"),subtitle:a("agents.subtitle"),children:o.jsx(Ke,{label:a("agents.loadingRosters"),rows:2})})})}if(r.length===0)return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("agents.title"),subtitle:a("agents.subtitle"),children:o.jsx($e,{title:a("agents.empty")})})});let J;return T?I.length===0&&F&&R[0]?.code==="not_supported"?J=o.jsx(Fe,{title:a("teams.error.notEnabled"),reason:a("team.error.notEnabledReason"),hint:a("team.error.notEnabledHint")}):I.length===0&&F?J=null:I.length===0?J=o.jsx($e,{title:a("agents.empty")}):C.length===0&&!B?J=o.jsx($e,{title:a("archive.empty.agents"),description:a("archive.hidden.agents",{count:L})}):D.length===0?J=o.jsx($e,{title:a("agents.empty"),action:o.jsx(G,{onClick:le,children:a("agents.filter.clear")})}):J=o.jsx("ul",{className:"entity-card-grid",children:D.map(z=>o.jsx(vL,{agent:z,nodeName:c.get(ge(z.node))??"—",onOpen:()=>Z(ge(z.node),z.member.agent_id)},`${ge(z.node)}:${z.team?.team_id??"-"}:${z.member.agent_id}`))}):J=o.jsx(Ke,{label:a("agents.loadingRosters"),rows:3}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:[o.jsxs(Ct,{title:a("agents.title"),subtitle:a("agents.subtitle"),children:[o.jsxs(En,{label:a("agents.search"),children:[o.jsx(Tn,{value:d,onChange:m,placeholder:a("agents.search"),ariaLabel:a("agents.search"),className:"grow basis-60 max-w-search"}),o.jsxs($t,{className:"net-select w-auto min-w-32 h-control py-0",value:e.nodeKey??"","aria-label":a("agents.filter.node"),onChange:z=>t(Hr(e,"nodeKey",z.target.value)),children:[o.jsx("option",{value:"",children:a("agents.filter.node")}),A.nodes.map(z=>o.jsx("option",{value:z.key,children:z.label},z.key))]}),o.jsxs($t,{className:"net-select w-auto min-w-32 h-control py-0",value:e.teamId??"","aria-label":a("agents.filter.team"),onChange:z=>t(Hr(e,"teamId",z.target.value)),children:[o.jsx("option",{value:"",children:a("agents.filter.team")}),A.teams.map(z=>o.jsx("option",{value:z.id,children:z.label},z.id))]}),o.jsxs($t,{className:"net-select w-auto min-w-32 h-control py-0",value:e.state??"","aria-label":a("agents.filter.state"),onChange:z=>t(Hr(e,"state",z.target.value)),children:[o.jsx("option",{value:"",children:a("agents.filter.state")}),A.states.map(z=>o.jsx("option",{value:z,children:z},z))]}),o.jsxs($t,{className:"net-select w-auto min-w-32 h-control py-0",value:e.presence??"","aria-label":a("agents.filter.presence"),onChange:z=>t(Hr(e,"presence",z.target.value)),children:[o.jsx("option",{value:"",children:a("agents.filter.presence")}),xL.map(z=>o.jsx("option",{value:z,children:a(`agents.presence.${z}`)},z))]}),o.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[o.jsx("span",{className:"text-sm tabular-nums text-muted",children:a("agents.count",{shown:D.length,total:C.length})}),B&&o.jsx(G,{size:"small",onClick:le,children:a("agents.filter.clear")}),o.jsx(G,{size:"small",onClick:rd,children:a("common.refresh")}),o.jsx(G,{variant:"primary",disabled:x.length===0,onClick:()=>h(!0),children:a("agents.create")})]})]}),(O.length>0||V>0)&&o.jsxs("div",{className:"flex flex-col gap-2",children:[O.map(z=>o.jsxs("p",{className:"m-0 flex flex-wrap gap-2 rounded-sm border border-line-strong bg-danger-soft px-3 py-2 text-sm text-danger",role:"alert",children:[o.jsx("span",{className:"flex-none font-semibold",children:c.get(ge(z.node))??"—"}),o.jsx("span",{children:Ef(z)}),z.stale&&o.jsx("span",{className:"flex-none text-faint",children:a("agents.staleNode")})]},ge(z.node))),V>0&&o.jsx("p",{className:"m-0 rounded-sm border border-line-strong bg-warn-soft px-3 py-2 text-sm text-warn",role:"status",children:a("agents.partialErrors",{count:V})})]}),J]}),f&&o.jsx(MR,{nodes:x,teamsForNode:W,...e.nodeKey?{initialNodeKey:e.nodeKey}:{},onClose:()=>h(!1),onSaved:w})]})}const If='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function pa({open:e,onClose:t,enabled:n=!0,returnFocusId:s}){const r=u.useRef(null),i=u.useRef(!1),l=u.useRef(null),c=u.useRef(t);return c.current=t,u.useEffect(()=>{if(!n){i.current=e;return}if(e){const d=document.activeElement;l.current=d instanceof HTMLElement&&d!==document.body?d:null,r.current?.querySelector(If)?.focus(),i.current=!0;const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=f}}if(i.current){i.current=!1;const m=(s===void 0?null:document.getElementById(s))??l.current;m?.isConnected&&m.focus(),l.current=null}},[n,e,s]),u.useEffect(()=>{if(!n||!e)return;const d=m=>{if(m.key==="Escape"){c.current();return}if(m.key!=="Tab")return;const f=r.current;if(!f)return;const h=[...f.querySelectorAll(If)].filter(b=>b.offsetParent!==null),p=h[0],g=h[h.length-1];!p||!g||(m.shiftKey&&document.activeElement===p?(m.preventDefault(),g.focus()):!m.shiftKey&&document.activeElement===g&&(m.preventDefault(),p.focus()))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e]),r}function SL(){u.useEffect(()=>{const e=window.visualViewport;if(!e)return;const t=document.documentElement,n=()=>{t.style.setProperty("--vvh",`${Math.round(e.height)}px`)};return n(),e.addEventListener("resize",n),()=>{e.removeEventListener("resize",n),t.style.removeProperty("--vvh")}},[])}const jL="inbox",_L=["tool.call.completed","tool.call.failed"],NL="agent.message.queued",CL="agent.inbox.changed";function TL(e,t,n){const s=e.event,r=s.data??{};if(s.type===CL||s.type===NL)return r.agent_id===t;if(!_L.includes(s.type)||r.tool_name!==jL)return!1;if(r.agent_id===t)return!0;const i=e.sessionId??(typeof r.session_id=="string"?r.session_id:void 0);return i!==void 0&&n.has(i)}function EL(e,t,n){const[s,r]=u.useState(0),i=u.useRef(-1),l=u.useRef(null);return u.useEffect(()=>{if(t===void 0||(l.current!==t&&(l.current=t,i.current=-1),e.length===0))return;let c=-1;for(const f of e)f.seq>c&&(c=f.seq);c<i.current&&(i.current=-1);let d=i.current,m=!1;for(const f of e)f.seq<=i.current||(f.seq>d&&(d=f.seq),TL(f,t,n)&&(m=!0));i.current=d,m&&r(f=>f+1)},[e,t,n]),s}const IL="vessel.chat.lastSession.v1.default";function Td(){return IL}function en(){try{return typeof window>"u"?null:window.sessionStorage??null}catch{return null}}function Ed(e){if(!e)return null;try{const n=e.getItem(Td())?.trim();return!n||n==="new"?null:n}catch{return null}}function RL(e,t){if(!e)return;const n=t.trim();if(!(!n||n==="new"))try{e.setItem(Td(),n)}catch{}}function Id(e){if(e)try{e.removeItem(Td())}catch{}}function LL(e){const{routeSessionId:t,storedSessionId:n,knownSessionIds:s}=e;return t?{kind:"keep"}:!n||n==="new"?{kind:"new",clear:n==="new"}:s===null?{kind:"wait"}:s.includes(n)?{kind:"restore",sessionId:n}:{kind:"new",clear:!0}}const Jb="#",Qb=1,AL=32,Rf=2048,Xb=10080*60*1e3,ML=Object.freeze([]),PL=Object.freeze({selected:ML,custom:"",include:!1}),qL=Object.freeze({});function Zb(e,t){return`${e}${Jb}${t}`}function Rd(e){const t=e.lastIndexOf(Jb);if(t<=0||t===e.length-1)return;const n=e.slice(t+1);if(!/^[0-9]+$/.test(n))return;const s=Number(n);if(Number.isSafeInteger(s))return{requestId:e.slice(0,t),index:s}}function li(e){return e.selected.length>0||e.custom.trim().length>0}function Ld(e){return e.selected.length===0&&e.custom.length===0&&!e.include}function tc(e,t,n){return e[Zb(t,n)]??PL}function OL(e,t,n){if(Ld(n)){if(e[t]===void 0)return e;const s={...e};return delete s[t],s}return{...e,[t]:n}}function DL(e,t){const n=new Set(t);if(n.size===0)return e;const s={};let r=!1;for(const[i,l]of Object.entries(e)){const c=Rd(i);if(c!==void 0&&n.has(c.requestId)){r=!0;continue}s[i]=l}return r?s:e}function HL(e,t){const n=new Set(t);return[...new Set(e)].filter(s=>!n.has(s))}function $L(e,t){return!(e===null||t.length===0&&e.length>0)}function Uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ev(e){if(!Array.isArray(e))return[];const t=[],n=new Set;for(const s of e){if(t.length>=AL)break;typeof s!="string"||s.length===0||n.has(s)||(n.add(s),t.push(s))}return t}function tv(e){return typeof e!="string"?"":e.length>Rf?e.slice(0,Rf):e}function FL(e,t,n){const s=[];for(const[r,i]of Object.entries(e)){if(Ld(i))continue;const l=t[r]??n;!Number.isFinite(l)||n-l>Xb||s.push({key:r,selected:ev(i.selected),custom:tv(i.custom),include:i.include,savedAt:l})}return s.sort((r,i)=>r.savedAt-i.savedAt),s.slice(-200)}function BL(e,t){if(e===null||e==="")return;let n;try{n=JSON.parse(e)}catch{return}if(!Uo(n)||n.v!==Qb)return;const s=n.slots;if(!Array.isArray(s))return;const r={};for(const i of s){if(!Uo(i))continue;const{key:l,savedAt:c}=i;if(typeof l!="string"||Rd(l)===void 0||typeof c!="number"||!Number.isFinite(c)||t-c>Xb)continue;const d={selected:ev(i.selected),custom:tv(i.custom),include:i.include===!0};Ld(d)||(r[l]=d)}return r}const nv=1,KL=200,sv=10080*60*1e3,nc=Object.freeze({});function Lf(e,t){const n=e[t];return n===void 0?void 0:n.questionId}function WL(e,t,n,s){if(t===""||n==="")return e;const r={...e,[t]:{questionId:n,savedAt:s}},i=Object.keys(r);if(i.length<=KL)return r;const l=i.reduce((c,d)=>(r[c]?.savedAt??0)<=(r[d]?.savedAt??0)?c:d);return delete r[l],r}function UL(e,t,n){const s=new Set(t),r={};let i=!1;for(const[l,c]of Object.entries(e)){const d=n-c.savedAt<=sv;s.has(l)&&d?r[l]=c:i=!0}return i?r:e}function Af(e,t,n=0){const s=e.length===0?0:Math.min(Math.max(n,0),e.length-1);if(t===void 0||t==="")return s;const r=e.indexOf(t);return r>=0?r:s}function zL(e){const t={version:nv,cursors:{...e}};return JSON.stringify(t)}function VL(e,t){if(e===null||e==="")return;let n;try{n=JSON.parse(e)}catch{return}if(!Uo(n)||n.version!==nv)return;const s=n.cursors;if(!Uo(s))return;const r={};for(const[l,c]of Object.entries(s)){if(l===""||!Uo(c))continue;const d=c.questionId,m=c.savedAt;typeof d!="string"||d===""||typeof m!="number"||!Number.isFinite(m)||t-m>sv||(r[l]={questionId:d,savedAt:m})}if(Object.keys(r).length!==0)return r}const ov="vessel.askCursor.v1";let Mf=!1;const rs=vn(()=>({cursors:nc}));function rv(e){try{const t=en();if(t===null)return;t.setItem(ov,zL(e))}catch{}}function sc(e=Date.now()){if(Mf)return rs.getState().cursors;Mf=!0;let t=nc;try{const n=en(),s=n===null?void 0:VL(n.getItem(ov),e);s!==void 0&&(t=s)}catch{t=nc}return rs.setState({cursors:t}),t}function GL(e,t,n=Date.now()){const{cursors:s}=rs.getState(),r=WL(s,e,t,n);r!==s&&(rs.setState({cursors:r}),rv(r))}function YL(e,t=!0){u.useEffect(()=>{if(!t)return;sc();const{cursors:n}=rs.getState(),s=UL(n,e,Date.now());s!==n&&(rs.setState({cursors:s}),rv(s))},[e,t])}function JL(e,t){const n=u.useRef(t);n.current=t;const[s,r]=u.useState(()=>(sc(),Af(t,Lf(rs.getState().cursors,e))));u.useEffect(()=>{sc(),r(Af(n.current,Lf(rs.getState().cursors,e)))},[e]);const i=u.useCallback(l=>{const c=n.current,d=c.length===0?0:Math.min(Math.max(l,0),c.length-1);r(d);const m=c[d];m!==void 0&&GL(e,m)},[e]);return[s,i]}const oc="vessel.askDraft.v1",QL=300,Ys={},gs={};let Pf=!1;function Ai(){gs.persist!==void 0&&typeof window<"u"&&(window.clearTimeout(gs.persist),gs.persist=void 0);const e=en();if(e===null)return;const t=Date.now(),n=FL(_r.getState().drafts,Ys,t);try{if(n.length===0){e.removeItem(oc);return}const s={v:Qb,slots:n};e.setItem(oc,JSON.stringify(s))}catch{}}function qf(){typeof window>"u"||(gs.persist!==void 0&&window.clearTimeout(gs.persist),gs.persist=window.setTimeout(()=>{gs.persist=void 0,Ai()},QL))}function XL(){document.visibilityState==="hidden"&&Ai()}function ir(){if(Pf||typeof window>"u")return;Pf=!0,window.addEventListener("pagehide",Ai),window.addEventListener("beforeunload",Ai),document.addEventListener("visibilitychange",XL);const e=en();if(e===null)return;let t=null;try{t=e.getItem(oc)}catch{return}const n=BL(t,Date.now());if(n===void 0)return;const s=Object.keys(n);if(s.length!==0){for(const r of s)Ys[r]=Date.now();_r.setState(r=>({drafts:{...n,...r.drafts}}))}}const _r=vn()((e,t)=>({drafts:qL,setDraft:(n,s,r)=>{ir();const i=Zb(n,s),l=t().drafts[i],d=r(l??{selected:[],custom:"",include:!1});if(l!==void 0&&d.selected===l.selected&&d.custom===l.custom&&d.include===l.include)return;const m=OL(t().drafts,i,d);m!==t().drafts&&(e({drafts:m}),m[i]===void 0?delete Ys[i]:Ys[i]=Date.now(),qf())},dropRequests:n=>{ir();const s=[...n];if(s.length===0)return;const r=DL(t().drafts,s);if(r===t().drafts)return;e({drafts:r});const i=new Set(s);for(const l of Object.keys(Ys)){const c=Rd(l);c!==void 0&&i.has(c.requestId)&&delete Ys[l]}qf()}}));function Ad(){return ir(),_r(e=>e.drafts)}function Md(){return ir(),_r(e=>e.setDraft)}function iv(){return ir(),_r(e=>e.dropRequests)}function av(e,t=!0){const n=iv(),s=u.useRef(null),r=e.join(" ");u.useEffect(()=>{if(!t)return;const i=s.current;if(i===null){e.length>0&&(s.current=e);return}if(!$L(i,e))return;s.current=e;const l=HL(i,e);l.length>0&&n(l)},[r,t,n])}function Of(e){switch(e.kind){case"permission":return 0;case"ask":return e.request.mode==="async"?2:1;case"notify":return e.request.salience==="high"?3:4}}function Df(e,t){const n=Of(e)-Of(t);if(n!==0)return n;const s=e.request.requestedAt-t.request.requestedAt;return s!==0?s:e.request.requestId===t.request.requestId?0:e.request.requestId<t.request.requestId?-1:1}function ZL(e){return e.agentId!==void 0&&e.agentId!==""?`agent:${e.agentId}`:e.sessionId!==void 0&&e.sessionId!==""?`session:${e.sessionId}`:`run:${e.runId}`}function eA(e){return e.agentId!==void 0&&e.agentId!==""?"agent":e.sessionId!==void 0&&e.sessionId!==""?"session":"run"}function Hf(e){return e.teamId!==void 0&&e.teamId!==""?"team":"session"}function lv(e,t){return[...e.map(n=>({kind:"permission",request:n})),...t.map(n=>({kind:"ask",request:n}))]}function tA(e,t){const n=e.request.requestedAt-t.request.requestedAt;if(n!==0)return n;const s=l=>l.kind==="permission"?0:l.kind==="ask"?1:2;if(s(e)!==s(t))return s(e)-s(t);const r=e.request.requestId,i=t.request.requestId;return r===i?0:r<i?-1:1}function nA(e,t,n,s=uo){const r=new Map,i=[...lv(e,t),...n.map(d=>({kind:"notify",request:d}))];for(const d of i){const m=d.request,f=ZL(m),h=Cc(m,s),p=r.get(f);if(p===void 0){r.set(f,{key:f,scope:eA(m),...m.agentId!==void 0?{agentId:m.agentId}:{},...m.sessionId!==void 0?{sessionId:m.sessionId}:{},...h!==void 0?{homeSessionId:h}:{},...m.teamId!==void 0?{teamId:m.teamId}:{},source:Hf(m),latestAt:m.requestedAt,items:[d]});continue}p.items.push(d),m.requestedAt>p.latestAt&&(p.latestAt=m.requestedAt),p.source==="session"&&Hf(m)==="team"&&(p.source="team"),p.sessionId===void 0&&m.sessionId!==void 0&&(p.sessionId=m.sessionId),p.homeSessionId===void 0&&h!==void 0&&(p.homeSessionId=h),p.teamId===void 0&&m.teamId!==void 0&&(p.teamId=m.teamId)}const l=[...r.values()];for(const d of l)d.items.sort(tA);const c=l.map(d=>({cluster:d,top:d.items.reduce((m,f)=>Df(f,m)<0?f:m)}));return c.sort((d,m)=>Df(d.top,m.top)),c.map(d=>d.cluster)}function cv(e,t,n=uo){return t==null||t===""?[]:e.filter(s=>s.request.sessionId===t||Cc(s.request,n)===t)}function sA({count:e,jobIds:t}){if(e<=0)return null;const n=t.map(s=>kn(s)).join(", ");return o.jsx("div",{className:"px-[var(--content-pad-inline)] pb-1",children:o.jsx("div",{className:"mx-auto max-w-[var(--chat-content-w,860px)]",children:o.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-info-soft px-2.5 py-0.5 font-mono text-2xs text-info",title:n,children:[o.jsx("span",{className:"inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-info"}),a("chat.awaitingJobs",{count:e})]})})})}function dv(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Et(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function Js(e,t){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:void 0}function $f(e){const t=e.usage;if(!dv(t))return;const n={},s=Js(t,"prompt_tokens"),r=Js(t,"completion_tokens"),i=Js(t,"total_tokens"),l=Js(t,"total_cost");return s!==void 0&&(n.prompt_tokens=s),r!==void 0&&(n.completion_tokens=r),i!==void 0&&(n.total_tokens=i),l!==void 0&&(n.total_cost=l),Object.keys(n).length>0?n:void 0}function oA(e){const t=Js(e,"depth");return t!==void 0&&t>=0?Math.floor(t):void 0}function rA(e){const t=new Map,n=new Map,s=new Map;function r(l,c={}){let d=t.get(l);return d||(d={id:l,depth:c.depth??0,state:c.state??"running"},t.set(l,d)),c.role!==void 0&&d.role===void 0&&(d.role=c.role),c.parentId!==void 0&&d.parentId===void 0&&(d.parentId=c.parentId),c.depth!==void 0&&(d.depth=Math.max(d.depth,c.depth)),c.state!==void 0&&(d.state=c.state),c.currentTool!==void 0&&(d.currentTool=c.currentTool),c.sessionId!==void 0&&(d.sessionId=c.sessionId),c.usage!==void 0&&(d.usage=c.usage),c.task!==void 0&&d.task===void 0&&(d.task=c.task),c.runId!==void 0&&(d.runId=c.runId),c.startedAt!==void 0&&d.startedAt===void 0&&(d.startedAt=c.startedAt),c.completedAt!==void 0&&(d.completedAt=c.completedAt),c.lastError!==void 0&&(d.lastError=c.lastError),c.nodeId!==void 0&&d.nodeId===void 0&&(d.nodeId=c.nodeId),c.queuePosition!==void 0&&(d.queuePosition=c.queuePosition),c.waitReason!==void 0&&(d.waitReason=c.waitReason),c.contextUsed!==void 0&&(d.contextUsed=c.contextUsed),c.contextMax!==void 0&&(d.contextMax=c.contextMax),c.lastSeen!==void 0&&(d.lastSeen=d.lastSeen===void 0?c.lastSeen:Math.max(d.lastSeen,c.lastSeen)),c.artifactRefs!==void 0&&(d.artifactRefs=[...new Set([...d.artifactRefs??[],...c.artifactRefs])]),d}function i(l){const c=l.type;if(!c.startsWith("run.")&&!c.startsWith("subagent.")&&!c.startsWith("agent."))return;const d=dv(l.data)?l.data:{};if(c==="agent.queue.entered"||c==="agent.queue.left"){const h=Et(d,"agent_id")??Et(d,"agentId");if(!h)return;const p=c==="agent.queue.entered",g=Js(d,"position"),b=Et(d,"wait_reason")??Et(d,"waitReason"),x=r(h,{state:p?"queued":"running",lastSeen:l.ts});p?(g!==void 0&&g>=1&&(x.queuePosition=Math.floor(g)),b!==void 0&&(x.waitReason=b)):(x.queuePosition=void 0,x.waitReason=void 0);return}if(!c.startsWith("run.")&&!c.startsWith("subagent."))return;if(c==="run.started"||c==="run.completed"||c==="run.failed"){const h=Et(d,"session_id");l.run_id&&h&&s.set(l.run_id,h);return}if(c==="run.cancelled"||!c.startsWith("subagent."))return;if(c==="subagent.delegate.started"){const h=Et(d,"delegateId");if(!h)return;const p=l.run_id,g=p?n.get(p):void 0,b=p?s.get(p):void 0,x=Et(d,"task");r(h,{role:"subagent",...g!==void 0?{parentId:g}:{},depth:oA(d)??0,state:"running",...x!==void 0?{task:x}:{},...b!==void 0?{sessionId:b}:{},startedAt:l.ts,lastSeen:l.ts,...l.node_id!==void 0?{nodeId:l.node_id}:{}});return}if(c==="subagent.delegate.completed"||c==="subagent.delegate.failed"){const h=Et(d,"delegateId");if(!h)return;const p=c==="subagent.delegate.failed",g=$f(d),b=p?Et(d,"error")??Et(d,"message"):void 0,x=r(h,{role:"subagent",state:p?"failed":"completed",completedAt:l.ts,lastSeen:l.ts,...g!==void 0?{usage:g}:{},...b!==void 0?{lastError:b}:{}});x.currentTool=void 0,p||(x.lastError=void 0);return}const m=Et(d,"agentId");if(!m)return;const f=l.run_id;if(c==="subagent.run.started"){f&&n.set(f,m);const h=Et(d,"session_id")??(f?s.get(f):void 0);r(m,{role:"subagent",state:"running",lastSeen:l.ts,...h!==void 0?{sessionId:h}:{},...f?{runId:f}:{}});return}if(c==="subagent.run.completed"||c==="subagent.run.cancelled"){const h=Et(d,"session_id")??(f?s.get(f):void 0),p=$f(d),g=r(m,{role:"subagent",state:c==="subagent.run.completed"?"completed":"cancelled",completedAt:l.ts,lastSeen:l.ts,...h!==void 0?{sessionId:h}:{},...p!==void 0?{usage:p}:{}});g.currentTool=void 0,c==="subagent.run.completed"&&(g.lastError=void 0);return}if(c==="subagent.run.failed"){const h=Et(d,"session_id")??(f?s.get(f):void 0),p=Et(d,"error")??Et(d,"message"),g=r(m,{role:"subagent",state:"failed",completedAt:l.ts,lastSeen:l.ts,...h!==void 0?{sessionId:h}:{},...p!==void 0?{lastError:p}:{}});g.currentTool=void 0;return}if(c==="subagent.tool.call.started"){const h=Et(d,"tool_name");r(m,{state:"running",lastSeen:l.ts,...h!==void 0?{currentTool:h}:{}});return}if(c==="subagent.tool.call.completed"||c==="subagent.tool.call.failed"){const h=t.get(m);h&&(h.lastSeen=Math.max(h.lastSeen??0,l.ts));const p=Et(d,"tool_name");h&&(p===void 0||h.currentTool===p)&&(h.currentTool=void 0),c==="subagent.tool.call.failed"&&h&&(h.lastError=Et(d,"error"))}}for(const l of e)i(l.event);return[...t.values()].sort((l,c)=>(l.startedAt??0)-(c.startedAt??0)||l.depth-c.depth||(l.id<c.id?-1:l.id>c.id?1:0)).map(l=>({...l}))}function iA(e,t){const n=new Set(e.filter(r=>r.sessionId===t).map(r=>r.id));let s=!0;for(;s;){s=!1;for(const r of e)n.has(r.id)||r.parentId!==void 0&&n.has(r.parentId)&&(n.add(r.id),s=!0)}return e.filter(r=>n.has(r.id))}function aA(e){const t=new Map(e.map(c=>[c.id,c])),n=new Map,s=[];for(const c of e)if(c.parentId!==void 0&&t.has(c.parentId)&&c.parentId!==c.id){const d=n.get(c.parentId);d?d.push(c):n.set(c.parentId,[c])}else s.push(c);const r=new Set;function i(c){r.add(c.id);const d=(n.get(c.id)??[]).filter(m=>!r.has(m.id));return{node:c,children:d.map(i)}}const l=s.map(i);for(const c of e)r.has(c.id)||l.push(i(c));return l}function lA(e,t){const n=new Map(e.map(l=>[l.id,l])),s=[],r=new Set;let i=n.get(t);for(;i&&!r.has(i.id);){r.add(i.id),s.unshift(i);const l=i.parentId?n.get(i.parentId):void 0;if(l?.id===t)break;i=l}return s}function cA(e,t){return e.find(n=>n.id===t)}function Pd(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function uv(e){return e.task?.trim()||Pd(e.id,16)}function dA(e){const t=e.usage?.total_tokens;if(t!==void 0)return`${t} tok`}function mv({entry:e,activeAgentId:t,onSelectAgent:n}){const s=e.node,r=s.startedAt!==void 0&&s.completedAt!==void 0?`${s.completedAt-s.startedAt}ms`:void 0,i=dA(s);return o.jsxs("li",{className:"subagent-row",children:[o.jsxs("div",{className:"subagent-row-main",style:{paddingLeft:`${s.depth*12}px`},children:[o.jsx(Tt,{status:s.state}),o.jsx(xt,{label:s.id,children:o.jsx("button",{type:"button",className:`subagent-link ${s.id===t?"active":""}`.trim(),"aria-pressed":s.id===t,onClick:()=>n?.(s.id),children:uv(s)})}),s.currentTool&&o.jsx("span",{className:"text-muted font-mono",children:s.currentTool}),s.queuePosition!==void 0&&o.jsx("span",{className:"text-muted",children:a("chat.subagents.queuePosition",{position:s.queuePosition})}),s.waitReason&&o.jsx("span",{className:"text-muted",children:s.waitReason}),r&&o.jsx("span",{className:"text-muted tabular-nums",children:r}),o.jsxs("details",{className:"subagent-node-details",children:[o.jsx("summary",{children:a("chat.subagents.details")}),o.jsxs("dl",{className:"subagent-details",children:[o.jsx("dt",{children:"id"}),o.jsx("dd",{className:"font-mono",children:s.id}),o.jsx("dt",{children:"depth"}),o.jsx("dd",{children:s.depth}),s.runId&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"run"}),o.jsx("dd",{className:"font-mono",children:s.runId})]}),s.sessionId&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"session"}),o.jsx("dd",{className:"font-mono",children:s.sessionId})]}),i&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"usage"}),o.jsx("dd",{children:i})]}),e.children.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"children"}),o.jsx("dd",{children:e.children.length})]}),s.queuePosition!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"queue"}),o.jsxs("dd",{children:[s.queuePosition,s.waitReason?` · ${s.waitReason}`:""]})]}),s.contextUsed!==void 0&&s.contextMax!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"context"}),o.jsxs("dd",{children:[s.contextUsed," / ",s.contextMax]})]}),s.lastSeen!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"last seen"}),o.jsx("dd",{children:bt(s.lastSeen)})]}),s.lastError&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"error"}),o.jsx("dd",{className:"text-danger",children:Pd(s.lastError,240)})]})]}),o.jsx(G,{type:"button",size:"small",onClick:()=>n?.(s.id),children:a("chat.subagents.view")})]})]}),e.children.length>0&&o.jsx("ul",{className:"subagent-children",children:e.children.map(l=>o.jsx(mv,{entry:l,activeAgentId:t,onSelectAgent:n},l.node.id))})]})}function uA({session:e,sessionId:t,detail:n,agents:s=[],activeAgentId:r,onSelectAgent:i}){const l=ot(),c=e?Sn(e):Zo(n?.title)||t,d=aA(s),m=s.filter(p=>p.state==="running").length,f=r?lA(s,r):[],h=()=>{if(!navigator.clipboard?.writeText){l.error(a("common.clipboardUnsupported"));return}navigator.clipboard.writeText(t).then(()=>l.success(a("chat.session.copiedId"))).catch(p=>l.error(p instanceof Error?p.message:String(p)))};return o.jsx("div",{className:"conversation-head",children:o.jsxs("div",{className:"conversation-heading",children:[o.jsx("div",{className:"conversation-title-row",children:o.jsx(xt,{label:a("chat.session.copyId"),children:o.jsx("h2",{className:"conversation-title",role:"button",tabIndex:0,"aria-label":a("chat.session.copyIdTitle",{title:c}),onClick:h,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),h())},children:e?c:Pd(c,42)})})}),r&&o.jsxs("nav",{className:"subagent-breadcrumb","aria-label":a("chat.subagents.title"),children:[o.jsx(G,{type:"button",variant:"link",className:"no-underline text-accent-ink",onClick:()=>i?.(void 0),children:a("chat.subagents.back")}),o.jsx("span",{className:"text-muted",children:"/"}),f.map((p,g)=>o.jsxs("span",{className:"subagent-crumb",children:[g>0&&o.jsx("span",{className:"text-muted",children:"/"}),o.jsxs(G,{type:"button",variant:"link",className:`no-underline text-accent-ink ${p.id===r?"font-semibold":""}`.trim(),onClick:()=>i?.(p.id),children:[a("chat.subagents.crumb")," · ",uv(p)]})]},p.id))]}),s.length>0&&o.jsxs("details",{className:"subagent-tree",open:r!==void 0,children:[o.jsxs("summary",{className:"subagent-tree-summary",children:[a("chat.subagents.title")," · ",s.length,m>0?` · ${a("chat.subagents.running",{count:m})}`:""]}),o.jsx("ul",{className:"subagent-tree-list",children:d.map(p=>o.jsx(mv,{entry:p,activeAgentId:r,onSelectAgent:i},p.node.id))})]})]})})}function mA({selectedId:e,selectedSession:t,sessionDetail:n,agents:s,activeAgentId:r,draftActive:i,onSelectAgent:l}){return e?o.jsx(uA,{session:t??null,sessionId:e,detail:n,agents:s,activeAgentId:r,onSelectAgent:l}):o.jsx("div",{className:"conversation-head draft-head",children:o.jsxs("div",{className:"conversation-heading",children:[o.jsx("h2",{className:"conversation-title",children:a(i?"chat.draft.title":"nav.domain.chat")}),o.jsx("div",{className:"conversation-meta text-muted",children:a(i?"chat.draft.meta":"chat.draft.pickSession")})]})})}const ar=new Map,rc=new Set;let fv=0;function hv(){fv+=1;for(const e of[...rc])e()}function cs(e){ar.set(e.type,e),hv()}function fA(e){let t=!1;for(const[n,s]of[...ar])s.owner===e&&(ar.delete(n),t=!0);t&&hv()}function hA(){return[...ar.values()].sort((e,t)=>e.order-t.order)}function pA(e){return u.useSyncExternalStore(t=>(rc.add(t),()=>rc.delete(t)),()=>fv),ar.get(e)}function gA(e){return e instanceof Error?e.message:String(e)}async function pv(e){if(!vl(u.version,e.runtime.react))return{status:"incompatible",detail:`react ${u.version} does not satisfy "${e.runtime.react}"`};if(!vl("1.0.0",e.runtime.sdk))return{status:"incompatible",detail:`sdk 1.0.0 does not satisfy "${e.runtime.sdk}"`};let t;try{t=await sa(()=>import(`${e.url}?v=${e.hash}`),[])}catch(s){return{status:"failed",detail:gA(s)}}const n=t[e.component];return typeof n!="function"?{status:"failed",detail:`named export "${e.component}" is not a component function`}:{status:"ready",module:t,component:n}}function gv(e){if(!(e===null||typeof e.dispose!="function"))try{e.dispose()}catch{}}const bA=64,vA=6e4,Vn=new Map,sl=new Map;function yA(e){if(e.status==="gone")return Number.POSITIVE_INFINITY;if(e.status!=="ok"||e.dataUrl===void 0)return;const t=Date.now()+vA;return e.staging===!0&&e.expiresAt!==void 0?Math.min(t,e.expiresAt):t}function xA(e,t){const n=Vn.get(t);if(n!==void 0){if(Date.now()<n.until)return Vn.delete(t),Vn.set(t,n),Promise.resolve(n.result);Vn.delete(t)}const s=sl.get(t);if(s!==void 0)return s;const r=(async()=>{try{const i=await e.previewAttachment(t),l=yA(i);if(l!==void 0)for(Vn.set(t,{result:i,until:l});Vn.size>bA;){const c=Vn.keys().next().value;if(c===void 0)break;Vn.delete(c)}return i}finally{sl.delete(t)}})();return sl.set(t,r),r}const wA=64,ds=new Map,ol=new Map;function kA(e,t,n){const s=ds.get(t);if(s!==void 0)return ds.delete(t),ds.set(t,s),Promise.resolve(s);const r=ol.get(t);if(r!==void 0)return r;const i=(async()=>{try{const l=await e.imageBlob(t,n);if(!l.found||l.base64===void 0||l.base64.length===0)return;const c=`data:${l.mime??"application/octet-stream"};base64,${l.base64}`;for(ds.set(t,c);ds.size>wA;){const d=ds.keys().next().value;if(d===void 0)break;ds.delete(d)}return c}catch{return}finally{ol.delete(t)}})();return ol.set(t,i),i}const $r={status:"unavailable"};function SA(e,t,n=!0){const r=u.useContext(vr)?.client,[i,l]=u.useState($r);return u.useEffect(()=>{if(!n||e===void 0||e.length===0||t===void 0||t.length===0||r===void 0){l($r);return}let c=!1;return l({status:"loading"}),(async()=>{const d=await kA(r,e,t);if(c)return;if(d===void 0){l($r);return}l({status:"ready",url:d});const m=new Image;m.onload=()=>{c||l({status:"ready",url:d,width:m.naturalWidth,height:m.naturalHeight})},m.onerror=()=>{c||l($r)},m.src=d})(),()=>{c=!0}},[r,n,e,t]),i}function jA(e,t){const s=u.useContext(vr)?.client,[r,i]=u.useState({status:"unavailable"});return u.useEffect(()=>{if(!t||e===void 0||e.length===0||s===void 0){i({status:"unavailable"});return}let l=!1;return i({status:"loading"}),xA(s,e).then(c=>{if(!l){if(c.status==="ok"&&c.dataUrl!==void 0){i({status:"ready",url:c.dataUrl,...c.staging===!0?{staging:!0}:{}});return}i({status:c.status==="gone"?"gone":"unavailable"})}}).catch(()=>{l||i({status:"unavailable"})}),()=>{l=!0}},[s,t,e]),r}function bv({name:e,path:t,staging:n}){const s=is(a("chat.toolImage.pathCopied"));return o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"m-0 w-full truncate text-center font-mono text-2xs text-faint",title:e,children:[e,n===!0&&o.jsx("span",{className:"tool-image-lightbox-staging",children:a("chat.toolImage.staging")})]}),t!==void 0&&o.jsxs("div",{className:"tool-image-lightbox-path",children:[o.jsx("code",{className:"tool-image-lightbox-path-text",title:t,children:t}),o.jsx("button",{type:"button",className:"tool-image-lightbox-copy",onClick:()=>s(t),"aria-label":a("chat.toolImage.copyPath"),title:a("chat.toolImage.copyPath"),children:o.jsx(yt,{name:"copy",size:13})})]})]})}function vv({url:e,name:t,onClose:n,path:s,staging:r}){return o.jsxs(tn,{label:a("chat.toolImage.previewNamed",{name:t}),closeLabel:a("chat.toolImage.close"),onClose:n,size:"xl",className:"tool-image-lightbox",bodyClassName:"items-center",children:[o.jsx("img",{src:e,alt:t,className:"tool-image-lightbox-img"}),o.jsx(bv,{name:t,path:s,staging:r})]})}function qd({kind:e,size:t=13}){const n={width:t,height:t,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false"};return e==="image"?o.jsxs("svg",{...n,children:[o.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),o.jsx("circle",{cx:"7.5",cy:"8",r:"1.3"}),o.jsx("path",{d:"M4 14.5 8.5 10l3 3 2-2 2.5 2.5"})]}):e==="document"?o.jsxs("svg",{...n,children:[o.jsx("path",{d:"M5 3.5h6.5L15.5 8v8.5H5z"}),o.jsx("path",{d:"M11.5 3.5V8h4"}),o.jsx("path",{d:"M7.5 11h5M7.5 13.5h3.5"})]}):o.jsxs("svg",{...n,children:[o.jsx("path",{d:"M5 3.5h6.5L15.5 8v8.5H5z"}),o.jsx("path",{d:"M11.5 3.5V8h4"})]})}function bo(e){const t=e.name?.trim();if(t!==void 0&&t.length>0)return t;const n=e.path.split(/[\\/]/).filter(s=>s.length>0);return n[n.length-1]??e.path}function yv(e){switch(e.kind){case"image":return a("chat.refs.kind.image");case"document":return a("chat.refs.kind.document");default:return a("chat.refs.kind.file")}}function xv(e){if(e===void 0)return a("chat.composer.sending");if(e.status==="sent"){const n=e.backend??e.model;return n!==void 0&&e.tokens!==void 0?a("chat.refs.image.sent",{provider:n,tokens:e.tokens}):a("chat.refs.image.sentPlain")}if(e.status==="unknown")return a("chat.refs.image.noRecord");const t=a(`chat.refs.image.reason.${_A(e.reason)}`);return e.status==="dropped"?a("chat.refs.image.dropped",{reason:t}):a("chat.refs.image.notSent",{reason:t})}function _A(e){if(e===void 0||e.length===0)return"unknown";switch(e.trim().toLowerCase().replace(/[\s-]+/g,"_")){case"budget":case"over_per_request_budget":return"budget";case"bytes_budget":case"over_per_request_byte_budget":return"bytes_budget";case"unsupported_format":return"unsupported_format";case"not_an_image":return"not_an_image";case"too_large":return"too_large";case"blob_missing":case"attachment_blob_missing":return"blob_missing";case"not_ingested":return"not_ingested";case"vision_disabled":return"vision_disabled";case"no_vision":case"no_vision_backend":return"no_vision";case"placeholder":return"placeholder";case"compaction":return"compaction";case"no_delivery_event":return"no_delivery_event";case"no_delivery_record":return"no_delivery_record";default:return"unknown"}}function wv(e){return e===void 0?"msg-ref-delivery pending":`msg-ref-delivery ${e.status.replace("_","-")}`}function kv({refs:e,imageDelivery:t,onRemove:n,className:s=""}){if(e===void 0||e.length===0)return null;const r=Xi(e.map(l=>l.path));let i=0;return o.jsx("ul",{className:`msg-refs ${s}`.trim(),"aria-label":a("chat.refs.label"),children:e.map((l,c)=>{const d=bo(l),m=l.kind==="image"&&t!==void 0?t[i++]:void 0,f=m===void 0?void 0:xv(m);return o.jsxs("li",{className:"msg-ref",title:l.path,children:[o.jsx("span",{className:"msg-ref-icon","aria-hidden":"true",children:o.jsx(qd,{kind:l.kind})}),o.jsx("span",{className:"sr-only",children:yv(l)}),o.jsx("span",{className:"msg-ref-name",children:d}),f!==void 0&&o.jsx("span",{className:wv(m),title:f,children:f}),n!==void 0&&o.jsx("button",{type:"button",className:"msg-ref-remove",onClick:()=>n(c),"aria-label":a("chat.refs.remove",{name:d}),title:a("chat.refs.remove",{name:d}),children:o.jsx("svg",{width:11,height:11,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M5.5 5.5l9 9M14.5 5.5l-9 9"})})})]},r[c]??`${l.path}#${c}`)})})}function NA(e){const[t,n]=u.useState(void 0);return u.useEffect(()=>{let s;try{const r=e.indexOf(",");if(r<0)throw new Error("malformed data url");const i=atob(e.slice(r+1)),l=new Uint8Array(i.length);for(let c=0;c<i.length;c+=1)l[c]=i.charCodeAt(c);s=URL.createObjectURL(new Blob([l],{type:"application/pdf"})),n(s)}catch{n(void 0)}return()=>{s!==void 0&&URL.revokeObjectURL(s)}},[e]),t}function CA({url:e,name:t,onClose:n,path:s,staging:r}){const i=NA(e),l=a("chat.pdf.previewNamed",{name:t});return o.jsxs(tn,{label:l,closeLabel:a("chat.toolImage.close"),onClose:n,size:"xl",className:"tool-image-lightbox pdf-lightbox",children:[i!==void 0?o.jsx("iframe",{src:i,title:l,className:"pdf-lightbox-frame"}):o.jsx("p",{className:"m-0 w-full text-center text-2xs text-faint",children:a("chat.toolImage.unavailable")}),o.jsx(bv,{name:t,path:s,staging:r})]})}let Mi=null;const ic=new Set;function Sv(){for(const e of[...ic])e()}function TA(e){Mi=e,Sv()}function Ff(){Mi!==null&&(Mi=null,Sv())}function EA(e){return ic.add(e),()=>{ic.delete(e)}}async function jv(e,t){const n=await e.previewAttachment(t);if(n.status!=="ok"||n.dataUrl===void 0)throw new Error(`attachment_preview_unavailable: ${n.status}`);return TA({url:n.dataUrl,name:bo({path:t}),path:t,staging:n.staging===!0,kind:n.mime==="application/pdf"?"pdf":"image"}),n}function IA(){const e=u.useSyncExternalStore(EA,()=>Mi);return e===null?null:e.kind==="pdf"?o.jsx(CA,{url:e.url,name:e.name,path:e.path,staging:e.staging,onClose:Ff}):o.jsx(vv,{url:e.url,name:e.name,path:e.path,staging:e.staging,onClose:Ff})}function Fr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Bf(e,t,n){const s=e?.find(l=>l.id===t)?.manifest,r=s!==null&&typeof s=="object"&&typeof s.permissions=="object"?s.permissions:null,i=Fr(r?.events);return{rpcMethods:n,eventPatterns:i,permissions:{fs:Fr(r?.fs),net:Fr(r?.net),process:r?.process===!0,secrets:r?.secrets===!0,events:i,rpc:Fr(r?.rpc)}}}const zo=new Map;function Kf(e,t){let n=zo.get(e);n===void 0&&(n=new Set,zo.set(e,n));const s=()=>{t(),n.delete(s),n.size===0&&zo.delete(e)};return n.add(s),s}function _v(e){const t=zo.get(e);if(t!==void 0){zo.delete(e);for(const n of[...t])try{n()}catch{}}}function Nv(e,t){const{client:n,eventStore:s}=Ae(),r=ot(),i=He(),{theme:l}=hg(),[c,d]=u.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches);u.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const p=window.matchMedia("(prefers-color-scheme: dark)"),g=()=>d(p.matches);return g(),p.addEventListener("change",g),()=>p.removeEventListener("change",g)},[]);const m=mg(l,c),f=u.useRef({client:n,eventStore:s,toast:r,mode:m,locale:i,surface:t});f.current={client:n,eventStore:s,toast:r,mode:m,locale:i,surface:t};const h=u.useRef(new Set);return u.useEffect(()=>{const p={mode:m,lang:i};for(const g of[...h.current])try{g(p)}catch{}},[m,i]),u.useMemo(()=>Gh({pluginId:e,sdkVersion:"1.0.0",get rpcMethods(){return f.current.surface.rpcMethods},get eventPatterns(){return f.current.surface.eventPatterns},get permissions(){return f.current.surface.permissions},rpc:(g,b)=>f.current.client.rpc(g,b),attachments:{preview:g=>f.current.client.previewAttachment(g),stage:g=>Bp(f.current.client,g),openPreview:async g=>{await jv(f.current.client,g)}},subscribeEvent:(g,b)=>{const x=f.current.eventStore;let y=x.getSnapshot().lastSeq;const v=()=>{const j=x.getSnapshot();j.lastSeq<y&&(y=0);const _=[];for(let S=j.entries.length-1;S>=0;S-=1){const w=j.entries[S];if(w===void 0||w.seq<=y)break;_.push({seq:w.seq,type:w.event.type,data:w.event.data})}_.reverse();for(const S of _)if(y=S.seq,S.type===g)try{b({type:S.type,payload:S.data})}catch{}};return Kf(e,x.subscribe(v))},theme:{get:()=>({mode:f.current.mode,lang:f.current.locale}),subscribe:g=>{const b=h.current;return b.add(g),Kf(e,()=>{b.delete(g)})}},toast:g=>{f.current.toast[g.kind](g.text)},i18n:{t:(g,b)=>a(g,b)},log:(g,b,x)=>{const y=`[vessel-plugin:${e}]`;g==="error"?console.error(y,b,x):g==="warn"?console.warn(y,b,x):g==="info"?console.info(y,b,x):console.debug(y,b,x)}}),[e])}function Cv(e,t){const{client:n}=Ae(),[s,r]=u.useState(()=>Bf(null,e,[...t])),[i,l]=u.useState(!1);return u.useEffect(()=>{let c=!0;return l(!1),sd(n).then(d=>{c&&(r(Bf(d,e,[...t])),l(!0))}),()=>{c=!1}},[n,e,t]),{surface:s,ready:i}}const RA={atomicSchemes:[],dropHandlers:[],toolbarActions:[]},Tv=u.createContext(RA);function ga(){return u.useContext(Tv)}function LA({plugin:e,items:t,toolbarItems:n,onRegister:s}){const r=e.name,{nodeUrl:i}=Ae(),l=u.useMemo(()=>{const S=new Set;for(const w of e.contributions?.rpc??[]){const k=typeof w=="string"?w:w.name??"";k!==""&&S.add(k)}return S},[e]),{surface:c,ready:d}=Cv(r,l),m=Nv(r,c),f=e.ui_embed,h=e.ui_bundle_hash??"",p=f?.entry,g=f?.css,b=f?.runtime.react,x=f?.runtime.sdk,y=p!==void 0?ji(i,r,p):null,v=t[0]?.component??t[0]?.handler??n[0]?.action??"",[j,_]=u.useState(null);return u.useEffect(()=>{if(p===void 0||b===void 0||x===void 0||h===""||y===null||v==="")return;let S=!0,w=null;return pv({url:y,hash:h,component:v,runtime:{react:b,sdk:x}}).then(k=>{S&&k.status==="ready"&&(w=k.module,_(k.module))}),()=>{S=!1,gv(w),_(null),_v(r)}},[p,b,x,h,y,v,r]),u.useEffect(()=>{if(g===void 0||h==="")return;const S=ji(i,r,g);if(S===null)return;const w=`${S}?v=${h}`;for(const N of document.head.querySelectorAll('link[rel="stylesheet"]'))if(N.getAttribute("href")===w)return;const k=document.createElement("link");return k.rel="stylesheet",k.href=w,k.setAttribute("data-plugin-css",r),document.head.appendChild(k),()=>{k.remove()}},[g,h,i,r]),u.useEffect(()=>{if(j===null||!d)return;const S=[],w=[],k=[];for(const N of n){const T=N.action;if(T===void 0)continue;const R=j[T];typeof R=="function"&&k.push({id:`${r}:${N.id}`,handler:R,host:m})}for(const N of t){const T=N.component??N.handler??"",R=j[T];if(typeof R!="function")continue;if(N.slot==="drop"){w.push(R);continue}if(N.scheme===void 0)continue;if(N.slot==="link"){const $=R;WT(N.scheme,{pluginId:r,component:$,host:m}),cs({type:`x:${r}:${N.scheme}`,surface:"inline",order:100,owner:r,lift:()=>[],component:({payload:C})=>o.jsx($,{href:C.href,text:C.text,host:m})});continue}const E=R,I=N.scheme;S.push({scheme:I,render:$=>o.jsx(E,{scheme:$.scheme,name:$.name,target:$.target,data:$.data,onRemove:$.onRemove,port:$.port,host:m})})}return s(r,{schemes:S,drops:w,toolbarActions:k}),()=>{s(r,null),UT(r),fA(r)}},[j,d,t,n,m,s,r]),null}function AA({children:e}){const{plugins:t,composer:n,toolbar:s}=Bn(),[r,i]=u.useState({}),l=u.useCallback((f,h)=>{i(p=>{if(h===null){if(!(f in p))return p;const g={...p};return delete g[f],g}return{...p,[f]:h}})},[]),c=u.useMemo(()=>{const f=new Map;for(const h of n){const p=f.get(h.pluginId);p===void 0?f.set(h.pluginId,[h]):p.push(h)}return f},[n]),d=u.useMemo(()=>{const f=new Map;for(const h of s){if(h.slot!=="composer"||h.action===void 0)continue;const p=f.get(h.pluginId);p===void 0?f.set(h.pluginId,[h]):p.push(h)}return f},[s]),m=u.useMemo(()=>{const f=[],h=[],p=[];for(const g of Object.values(r))f.push(...g.schemes),h.push(...g.drops),p.push(...g.toolbarActions);return{atomicSchemes:f,dropHandlers:h,toolbarActions:p}},[r]);return o.jsxs(Tv.Provider,{value:m,children:[t.filter(f=>f.enabled&&(c.has(f.name)||d.has(f.name))).map(f=>o.jsx(LA,{plugin:f,items:c.get(f.name)??[],toolbarItems:d.get(f.name)??[],onRegister:l},f.name)),e]})}function MA({children:e,className:t=""}){return o.jsx("footer",{className:`composer-area ${t}`.trim(),children:e})}const Od="size-control flex-none rounded-full border border-line-strong p-0 bg-sunken pointer-coarse:min-w-touch disabled:opacity-100",c$=["primary","quiet"],Ev={primary:"text-accent enabled:hover:bg-accent-soft enabled:hover:text-accent-ink disabled:text-faint",quiet:"text-muted enabled:hover:text-ink disabled:text-faint"},PA=Ev.primary,Dd=Ev.quiet;function qA(e){return e==="attach"?u.createElement(yt,{name:"attach",size:14}):u.createElement(Ot,{domain:e})}const Wf=be(Od,Dd);function OA(e,t,n=new Map,s=ss(),r=[],i){const l=[];for(const c of e){const d=`${c.pluginId}:${c.id}`,m=On(n,c.pluginId,c.titleKey,s,c.label,c.id),f=c.icon===void 0?void 0:qA(c.icon);if(c.action!==void 0){const p=r.find(y=>y.id===d);if(p===void 0||i===void 0)continue;const g=p.handler,b=i,x=p.host;l.push({id:d,label:m,text:m,...f!==void 0?{icon:f,className:Wf}:{},onSelect:()=>{g(b,x)}});continue}const h=t[c.id];h!==void 0&&l.push({id:d,label:m,text:m,...f!==void 0?{icon:f,className:Wf}:{},onSelect:h})}return l}function DA(e,t){const{toolbar:n,i18nByPlugin:s}=Bn(),{toolbarActions:r}=ga(),i=He();return u.useMemo(()=>OA(Og(n,"composer"),e,s,i,r,t),[n,e,s,i,r,t])}function HA(){return a("composer.toolbar.label")}function $A(e){const{toolbar:t,i18nByPlugin:n}=Bn(),s=He(),{client:r,hasToken:i,connectionState:l}=Ae(),c=u.useMemo(()=>Og(t,"composer").filter(h=>h.menu!==void 0),[t]),[d,m]=u.useState({}),f=i&&l==="open";return u.useEffect(()=>{if(!f||c.length===0)return;let h=!1;for(const p of c){const g=p.menu;if(g===void 0)continue;const b=`${p.pluginId}:${p.id}`,x=g.sessionScoped===!0&&e!==void 0?{session_id:e}:{};r.rpc(`plugin.${p.pluginId}.${g.read}`,x).then(y=>{if(h||y===null||typeof y!="object")return;const v=y[g.valueKey],j=y.options,_=y.hint;m(S=>({...S,[b]:{...typeof v=="string"?{current:v}:{},...typeof y.enabled=="boolean"?{enabled:y.enabled}:{},...Array.isArray(j)?{options:j.filter(w=>typeof w=="string")}:{},...typeof _=="string"?{hint:_}:{}}}))}).catch(()=>{})}return()=>{h=!0}},[r,f,e,c]),u.useMemo(()=>{const h=[];for(const p of c){const g=p.menu;if(g===void 0)continue;const b=`${p.pluginId}:${p.id}`,x=d[b],y=On(n,p.pluginId,p.titleKey,s,p.label,p.id),v=x?.options,j=v!==void 0?g.items.filter(k=>k.value==="auto"||v.includes(k.value)):g.items,_=j.map(k=>({value:k.value,label:On(n,p.pluginId,k.labelKey,s,k.label,k.value)})),S=g.sessionScoped===!0&&e===void 0,w=!f||S||x?.enabled===!1||v!==void 0&&j.length===0;h.push({id:b,label:y,disabled:w,onSelect:()=>{},menu:{items:_,prefix:a("chat.thinking.label"),...S?{current:a("chat.thinking.draftHint")}:x?.current!==void 0?{current:x.current}:{},...S?{hint:a("chat.thinking.draftHint")}:x?.hint!==void 0?{hint:On(n,p.pluginId,x.hint,s,x.hint)}:{},onSelect:k=>{m(T=>({...T,[b]:{...T[b],current:k}}));const N={[g.valueKey]:k};g.sessionScoped===!0&&e!==void 0&&(N.session_id=e),r.rpc(`plugin.${p.pluginId}.${g.write}`,N).then(()=>{const T=g.sessionScoped===!0&&e!==void 0?{session_id:e}:{};return r.rpc(`plugin.${p.pluginId}.${g.read}`,T)}).then(T=>{if(T===null||typeof T!="object")return;const R=T[g.valueKey];typeof R=="string"&&m(E=>({...E,[b]:{...E[b],current:R}}))}).catch(()=>{})}}})}return h},[c,d,n,s,f,r,e])}function FA(e){return e==="image"?"img":e==="document"?"doc":"file"}function Iv(e,t){const n=t.lastIndexOf("#");if(n>0){const s=Number(t.slice(n+1)),r=e[s];if(Number.isInteger(s)&&r!==void 0&&r.path===t.slice(0,n))return s}return e.findIndex(s=>s.path===t)}function Rv(e,t){const n=Xi(e.map(i=>i.path)),s=new Map(t),r=[];return e.forEach((i,l)=>{const c=s.get(i.path)??0;if(c>0){s.set(i.path,c-1);return}r.push({id:n[l]??`${i.path}#${l}`,label:bo(i),kind:FA(i.kind),note:yv(i),description:i.path})}),r}function Lv({items:e,onRemove:t,removeLabel:n,className:s}){return o.jsx(ux,{items:e,onRemove:t,label:a("composer.refs.label"),removeLabel:n??(r=>a("composer.refs.remove",{name:r.label})),className:s})}function BA({usage:e}){if(e===void 0)return null;const t=hi(e.used),n=fx(e.used,e.max),s=n!==void 0?a("chat.context.percentOf",{percent:n,used:t}):a("chat.context.tokens",{used:t});return o.jsx(xt,{label:s,children:o.jsx("span",{className:"inline-flex items-center",children:o.jsx(hx,{used:e.used,max:e.max,title:s,text:t})})})}const KA=be(Od,PA);function Av({label:e,disabled:t=!1,onClick:n}){return o.jsx(xt,{label:e,children:o.jsx(G,{variant:"plain","aria-label":e,disabled:t,onClick:n,className:KA,children:o.jsx(yt,{name:"send"})})})}const Mv={};function WA({contextUsage:e,primary:t,hostActions:n=Mv,children:s,className:r,sessionId:i,port:l}){const c=DA(n,l),d=$A(i);return o.jsx(mx,{label:HA(),actions:c,trailingActions:d,wrapAction:(m,f)=>o.jsx(xt,{label:m.label,children:f}),meta:o.jsx(BA,{usage:e}),primary:t,className:be("composer-toolbar mt-0",r),children:s})}const UA='button, [role="button"], [role="option"], [role="menuitem"], [role="checkbox"], [role="switch"], [role="tab"], [role="dialog"], a[href], input, select, textarea, [contenteditable="true"]';function Hd(e){const t=e.target;if(!(t instanceof Element)||t.closest(UA)!==null)return;const n=e.currentTarget.querySelector("textarea");if(n instanceof HTMLTextAreaElement){n.disabled||n.focus();return}const s=e.currentTarget.querySelector("[data-rich-composer]");s instanceof HTMLElement&&s.getAttribute("aria-disabled")!=="true"&&s.focus()}function Pv({children:e,contextUsage:t,primary:n,hostActions:s=Mv,slot:r,sessionId:i,port:l}){return o.jsxs("div",{className:"composer-field",onClick:Hd,children:[e,o.jsx(WA,{contextUsage:t,primary:n,hostActions:s,sessionId:i,port:l,children:r})]})}function zt(e){return e instanceof Error?e.message:String(e)}const zA=be("h-control max-w-36 flex-none gap-1 rounded-full border border-line-strong bg-sunken px-2.5 py-0 text-xs disabled:opacity-100","focus-visible:ring-line-strong focus-visible:ring-offset-0",Dd);function VA({agentId:e,agentName:t,currentModel:n,draftModel:s,onDraftModelChange:r}){He();const i=ot(),{client:l,hasToken:c,connectionState:d}=Ae(),{current:m}=ut(),[f,h]=u.useState(!1),[p,g]=u.useState(""),[b,x]=u.useState(void 0),[y,v]=u.useState(!1),[j,_]=u.useState(null),S=u.useRef(0),w=e===void 0,k=t?.trim()||e||"",N=c&&d==="open",T=w?s:n,R=T!==void 0&&T!==""?T:void 0,E=a(w?"chat.memberModel.draftTooltip":"chat.memberModel.tooltip"),I=R!==void 0?`${E} · ${R}`:E,$=()=>{const L=++S.current;g(w?s??"":""),x(void 0),_(null),h(!0),!w&&l.rpc("agents.get",{agent_id:e}).then(A=>{if(L!==S.current)return;const D=A.agent?.model;typeof D=="string"&&D!==""&&(x(D),g(D))}).catch(()=>{})},C=async()=>{if(w){if(r===void 0||p===(s??""))return;r(p===""?void 0:p),h(!1);return}if(!(y||p===""||p===b)){v(!0),_(null);try{await l.updateAgent({agent_id:e,model:p}),i.success(a("chat.memberModel.saved",{name:k})),h(!1),g("")}catch(L){_(`${a("chat.memberModel.failed")}: ${zt(L)}`)}finally{v(!1)}}};return o.jsxs(o.Fragment,{children:[o.jsx(xt,{label:I,children:o.jsxs(G,{variant:"plain",disabled:!N,"aria-label":I,"aria-haspopup":"dialog","aria-expanded":f,onClick:$,className:zA,children:[o.jsx("span",{className:"min-w-0 truncate font-mono",children:R??a("chat.memberModel.button")}),o.jsx(yt,{name:"chevron",size:12,className:"rotate-90 text-faint"})]})}),f&&o.jsxs(tn,{label:w?a("chat.memberModel.draftTitle"):a("chat.memberModel.title",{name:k}),onClose:()=>{y||h(!1)},closeOnBackdrop:!y,closeLabel:a("common.close"),size:"sm",children:[o.jsx("h2",{className:"modal-title",children:w?a("chat.memberModel.draftTitle"):a("chat.memberModel.title",{name:k})}),o.jsxs("div",{className:"flex flex-col gap-2",children:[b!==void 0&&o.jsx("p",{className:"mt-1 mb-0 text-sm text-muted",children:a("chat.memberModel.currentPin",{model:b})}),!w&&o.jsx("p",{className:"mt-1 mb-0 text-sm text-muted",children:R!==void 0?a("chat.memberModel.currentBody",{model:R}):a("chat.memberModel.currentUnknown")}),o.jsx(We,{label:a("agents.form.model"),htmlFor:"member-model-picker",hint:a(w?"chat.memberModel.draftHint":"chat.memberModel.hint"),children:o.jsx(_d,{id:"member-model-picker",node:m??void 0,value:p,onChange:g,"aria-label":a("agents.form.model")})}),j&&o.jsx("p",{className:"form-error",role:"alert",children:j}),o.jsxs("div",{className:"modal-actions",children:[o.jsx(G,{onClick:()=>h(!1),disabled:y,children:a("common.cancel")}),o.jsx(G,{variant:"primary",disabled:y||(w?r===void 0||p===(s??""):p===""||p===b),onClick:()=>{C()},children:a(y?"common.processing":w?"common.confirm":"team.form.submitEdit")})]})]})]})]})}function GA({messageId:e,snippet:t,onJump:n,className:s}){const r=e!==void 0&&n!==void 0,i=o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"msg-quote-icon","aria-hidden":"true",children:o.jsx(yt,{name:"quote",size:11})}),o.jsx("span",{className:"msg-quote-snippet",children:t})]});return r?o.jsx("button",{type:"button",className:be("msg-quote msg-quote-jump",s),title:a("chat.quote.jump"),"aria-label":a("chat.quote.jump"),onClick:()=>{e!==void 0&&n?.(e)},children:i}):o.jsxs("div",{className:be("msg-quote",s),children:[o.jsx("span",{className:"sr-only",children:a("chat.quote.label")}),i]})}function qv({quote:e,onJump:t}){const n=e.messageId!==void 0&&t!==void 0,s=e.source==="user"?a("chat.quote.source.user"):a("chat.quote.source.assistant");return o.jsxs("div",{className:be("composer-quote-body",n&&"composer-quote-jump"),title:n?a("chat.quote.jump"):void 0,onClick:n?()=>{e.messageId!==void 0&&t?.(e.messageId)}:void 0,children:[o.jsx("span",{className:"msg-quote-icon","aria-hidden":"true",children:o.jsx(yt,{name:"quote",size:11})}),o.jsx("span",{className:"composer-quote-source",children:s}),o.jsx("span",{className:"composer-quote-snippet",children:e.snippet})]})}function YA({onRemove:e}){return o.jsx("button",{type:"button",className:"composer-quote-remove",onClick:e,"aria-label":a("chat.quote.remove"),title:a("chat.quote.remove"),children:o.jsx("svg",{width:11,height:11,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M5.5 5.5l9 9M14.5 5.5l-9 9"})})})}function JA({quote:e,onRemove:t,onJump:n}){return o.jsxs("div",{className:"composer-quote-bar",children:[o.jsx(qv,{quote:e,onJump:n}),o.jsx(YA,{onRemove:t})]})}const ac="application/x-vessel-session-ref";function QA(e,t,n){const s=e.agent?.id,r=s!==void 0?t?.get(s):void 0;let i=e.agent?.name?.trim()||void 0,l=r?.node,c=r?.team;const d=n?.get(e.session_id);if(d!==void 0&&(i===void 0||l===void 0)){const m=d.indexOf("@");if(m>0&&(i===void 0&&(i=d.slice(0,m)),l===void 0)){const f=d.slice(m+1),h=f.indexOf(":");l=h>=0?f.slice(0,h):f,c===void 0&&h>=0&&(c=f.slice(h+1))}}return{sessionId:e.session_id,title:Sn(e),...i!==void 0&&i!==""?{agentName:i}:{},...s!==void 0?{agentId:s}:{},...c!==void 0&&c!==""?{team:c}:{},...l!==void 0&&l!==""?{node:l}:{}}}function XA(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ZA(e){let t;try{t=JSON.parse(e)}catch{return null}if(!XA(t))return null;const{sessionId:n}=t;if(typeof n!="string"||n.length===0)return null;const s=typeof t.title=="string"&&t.title.length>0?t.title:n,r={sessionId:n,title:s};for(const i of["agentName","agentId","team","node"]){const l=t[i];typeof l=="string"&&l.length>0&&(r[i]=l)}return r}function $d(e,t){const n=[];return e.agentName&&n.push(e.agentName),e.team&&e.team!==t?.team&&n.push(e.team),e.node&&e.node!==t?.node&&n.push(e.node),[...new Set(n)]}function Ov(e){const t=e.node&&e.team?`${e.node}:${e.team}`:e.node??e.team;return e.agentName&&t?`${e.agentName}@${t}`:e.agentName??t}function Fd(e){const t=Ov(e),n=`session: ${e.sessionId}`;return t!==void 0?`${t} · ${n}`:n}function Dv(e,t){if(t.length===0)return e;const n=t.map(s=>{const r=[`「${s.title}」`];return s.agentName&&r.push(`agent: ${s.agentName}`),s.team&&r.push(`team: ${s.team}`),s.node&&r.push(`node: ${s.node}`),r.push(`session_id: ${s.sessionId}`),`- ${r.join(" · ")}`});return`${Hv[0]}
|
|
575
|
+
${n.join(`
|
|
576
|
+
`)}
|
|
577
|
+
|
|
578
|
+
${e}`}const Hv=["[引用会话]","[Referenced sessions]"];function e1(e){const t=/^- 「(.*?)」(?: · (.*))?$/.exec(e);if(t===null)return null;const n=t[1]??"",s=new Map;for(const d of(t[2]??"").split(" · ")){const m=d.indexOf(": ");m<=0||s.set(d.slice(0,m),d.slice(m+2))}const r=s.get("session_id");if(r===void 0||r.length===0)return null;const i=s.get("agent"),l=s.get("team")??s.get("团队"),c=s.get("node")??s.get("节点");return{sessionId:r,title:n.length>0?n:r,...i!==void 0&&i.length>0?{agentName:i}:{},...l!==void 0&&l.length>0?{team:l}:{},...c!==void 0&&c.length>0?{node:c}:{}}}function t1(e){const t=Hv.find(l=>e.startsWith(`${l}
|
|
579
|
+
`));if(t===void 0)return null;const n=e.slice(t.length+1),s=n.indexOf(`
|
|
580
|
+
|
|
581
|
+
`);if(s<0)return null;const r=n.slice(0,s).split(`
|
|
582
|
+
`);if(r.length===0)return null;const i=[];for(const l of r){const c=e1(l);if(c===null)return null;i.push(c)}return{chips:i,body:n.slice(s+2)}}function n1(e){return t1(e)}const ao="vessel-quote",lr="vessel-session",s1=new Set([ao,lr]);function o1(e){return e.messageId===void 0||e.messageId.length===0?null:Xp(e.snippet,ao,e.messageId)}function r1(e){return Xp(e.title,lr,e.sessionId)}function i1(e,t){if(e.length===0)return e;let n="",s=!1;for(const r of Yi(e,t))r.type==="text"?n+=r.text:s=!0;return s?n:e}function $v(e){return i1(e,s1)}function a1(e,t,n){const s=new Set([ao]);let r="",i=0,l=0,c=!1;for(const f of Yi(e,s)){const h=f.type==="text"?f.text.length:f.token.length;!c&&n<=i+h&&(l=r.length+(f.type==="text"?n-i:0),c=!0),f.type==="text"&&(r+=f.text),i+=h}c||(l=r.length);const d=o1(t);if(d===null)return r;const m=Math.max(0,Math.min(l,r.length));return r.slice(0,m)+d+r.slice(m)}const Bd=u.createContext({sessionRefs:[]});function l1({value:e,children:t}){return o.jsx(Bd.Provider,{value:e,children:t})}function Fv({label:e,onRemove:t}){return o.jsx("button",{type:"button",className:"reference-card-remove",onClick:t,"aria-label":e,title:e,children:o.jsx("svg",{width:11,height:11,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M5.5 5.5l9 9M14.5 5.5l-9 9"})})})}function c1({target:e,onRemove:t}){const n=u.useContext(Bd),s=n.quote;if(s===void 0||s.messageId!==e)return o.jsx("span",{className:"rich-atomic-fallback",children:e});const r=()=>{n.onRemoveQuote?.(),t()};return o.jsxs("span",{className:"reference-card quote-ref-card",title:s.snippet,children:[o.jsx(qv,{quote:s,onJump:n.onJumpQuote})," ",o.jsx(Fv,{label:a("chat.quote.remove"),onRemove:r})]})}function d1({target:e,onRemove:t}){const n=u.useContext(Bd),s=n.sessionRefs.findIndex(c=>c.sessionId===e),r=s>=0?n.sessionRefs[s]:void 0;if(r===void 0)return o.jsx("span",{className:"rich-atomic-fallback",children:e});const i=$d(r,n.currentScope),l=()=>{n.onRemoveSessionRef?.(s),t()};return o.jsxs("span",{className:"reference-card session-ref-card",title:Fd(r),"data-session-ref":r.sessionId,children:[o.jsx("span",{className:"reference-card-marker","aria-hidden":"true",children:"ref"}),o.jsx("span",{className:"reference-card-name",children:r.title}),i.map(c=>o.jsx("span",{className:"reference-card-badge",children:c},c)),o.jsx(Fv,{label:a("chat.sessionRef.remove",{name:r.title}),onRemove:l})]})}const u1=[{scheme:ao,render:c1},{scheme:lr,render:d1}];function Bv({editorRef:e,refs:t,onAddRef:n,onRemoveRef:s,onUpdateRef:r,listClient:i}){const{client:l}=Ae(),c=u.useRef({refs:t,onAddRef:n,onRemoveRef:s,onUpdateRef:r,client:l,listClient:i});c.current={refs:t,onAddRef:n,onRemoveRef:s,onUpdateRef:r,client:l,listClient:i};const d=n!==void 0&&s!==void 0,m=i!==void 0;return u.useMemo(()=>d?{refs:()=>c.current.refs,addRef:h=>c.current.onAddRef?.(h)??!1,removeRef:h=>c.current.onRemoveRef?.(h),updateRef:(h,p)=>c.current.onUpdateRef?.(h,p)??!1,insertText:(h,p)=>e.current?.insertText(h,p),insertAtomic:(h,p)=>e.current?.insertAtomic(h,p),insertTransient:(h,p,g)=>e.current?.insertTransient(h,p,g)??null,getCaretOffset:()=>e.current?.getCaretOffset()??0,caretOffsetFromPoint:(h,p)=>e.current?.caretOffsetFromPoint(h,p)??null,stage:h=>Bp(c.current.client,h),preview:h=>c.current.client.previewAttachment(h),...m?{listAttachments:h=>c.current.listClient?.listAttachments(h)??Promise.reject(new Error("list client gone"))}:{}}:void 0,[e,d,m])}function m1({value:e,onChange:t,onSubmit:n,disabled:s,submitting:r,targetLabel:i,hasToken:l,connected:c,onOpenConnection:d,focusSignal:m=0,onStop:f,stopping:h=!1,refs:p,onRemoveRef:g,onAddRef:b,onUpdateRef:x,client:y,contextUsage:v,memberModel:j,sessionRefs:_,onRemoveSessionRef:S,onAddSessionRef:w,currentScope:k,sessionId:N,quote:T,onRemoveQuote:R,onJumpQuote:E,quoteSignal:I=0}){const $=u.useRef(null),C=u.useRef(!0),L=u.useRef(r),A=u.useRef(0),[D,O]=u.useState(!1),F=l&&c&&!s&&!r&&$v(e).trim().length>0,{atomicSchemes:V,dropHandlers:B}=ga(),W=u.useMemo(()=>[...u1,...V],[V]),Z=Bv({editorRef:$,refs:p??[],onAddRef:b,onRemoveRef:g,onUpdateRef:x,listClient:y}),ee=u.useRef(e);ee.current=e;const ie=u.useRef(T);ie.current=T;const le=u.useRef(t);le.current=t;const J=u.useRef(_);J.current=_;const z=u.useRef(I);u.useEffect(()=>{if(I===z.current||(z.current=I,I===0))return;const oe=ee.current,je=ie.current,Ee=$.current?.getCaretOffset()??oe.length,Ce=je===void 0?oe:a1(oe,je,Ee);Ce!==oe&&(le.current(Ce),ee.current=Ce)},[I]),u.useEffect(()=>{const oe=ee.current,je=ie.current,Ee=J.current??[];let Ce="",U=!1;for(const q of nr(oe,W)){if(q.type==="text"){Ce+=q.text;continue}(q.scheme===ao?je?.messageId!==q.target:q.scheme===lr?!Ee.some(H=>H.sessionId===q.target):!1)?U=!0:Ce+=q.token}U&&(le.current(Ce),ee.current=Ce)},[e,T,_,W]);const me=(oe,je)=>{if(!(Z===void 0||B.length===0))for(const Ee of B)try{Ee(oe,Z,{offset:je})}catch{}};u.useEffect(()=>(C.current=!0,()=>{C.current=!1}),[]),u.useEffect(()=>{m>0&&$.current?.focus()},[m]),u.useEffect(()=>{if(L.current&&!r&&C.current){const oe=document.activeElement;(oe===document.body||oe instanceof Element&&oe.closest(".composer-field")!==null)&&l&&c&&!s&&$.current?.focus()}L.current=r},[r,l,c,s]);const K=a(l?c?"chat.composer.placeholder":"chat.composer.placeholderDisconnected":"chat.composer.placeholderNoToken"),ne=new Map,Ne=new Set,ce=new Set;for(const oe of nr(e,W))oe.type==="atomic"&&(ne.set(oe.target,(ne.get(oe.target)??0)+1),oe.scheme===ao?Ne.add(oe.target):oe.scheme===lr&&ce.add(oe.target));const se=(_??[]).filter(oe=>!ce.has(oe.sessionId)).map(oe=>({id:`session-ref:${oe.sessionId}`,label:oe.title,kind:"ref",note:a("chat.sessionRef.note"),description:Fd(oe),badges:$d(oe,k)})),we=[...Rv(p??[],ne),...se],he=T?.messageId!==void 0&&Ne.has(T.messageId),pe=u.useMemo(()=>({quote:T,sessionRefs:_??[],currentScope:k,onJumpQuote:E,onRemoveQuote:R,onRemoveSessionRef:S}),[T,_,k,E,R,S]),Me=oe=>{if(oe.startsWith("session-ref:")){const Ee=oe.slice(12),Ce=(_??[]).findIndex(U=>U.sessionId===Ee);Ce>=0&&S?.(Ce);return}const je=Iv(p??[],oe);je>=0&&g?.(je)};return o.jsx(MA,{children:o.jsxs("div",{className:`w-full max-w-[var(--dock-width)] mx-auto px-3.5 pt-2.25 pb-3 rounded-lg bg-raised shadow-elev-2${D?" ring-2 ring-accent":""}`,onClick:Hd,onDragOver:oe=>{const je=w!==void 0&&oe.dataTransfer.types.includes(ac),Ee=Z!==void 0&&B.length>0&&oe.dataTransfer.types.includes("Files");!je&&!Ee||(oe.preventDefault(),oe.dataTransfer.dropEffect="copy",O(!0))},onDragLeave:oe=>{oe.relatedTarget instanceof Node&&oe.currentTarget.contains(oe.relatedTarget)||O(!1)},onDrop:oe=>{if(O(!1),oe.dataTransfer.files.length>0){if(Z===void 0||B.length===0)return;oe.preventDefault();const q=$.current?.caretOffsetFromPoint(oe.clientX,oe.clientY)??null;me(Array.from(oe.dataTransfer.files),q),$.current?.focus();return}if(w===void 0)return;const je=oe.dataTransfer.getData(ac);if(je==="")return;oe.preventDefault();const Ee=ZA(je);if(Ee===null)return;const Ce=$.current?.caretOffsetFromPoint(oe.clientX,oe.clientY)??null;if(w(Ee)){const q=r1(Ee);q!==null&&$.current?.insertAtomic(q,Ce??void 0)}$.current?.focus()},children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1.5 text-xs text-faint",children:[o.jsx(xt,{label:i,children:o.jsx("span",{className:"composer-target",children:i})}),o.jsxs("span",{className:"flex-none flex items-center gap-2.5",children:[f&&o.jsx(G,{type:"button",variant:"link",className:"text-danger hover:text-danger disabled:opacity-60",onClick:f,disabled:h,children:a(h?"chat.run.stopping":"chat.run.stop")}),o.jsx("span",{className:"flex-none font-mono text-xs text-muted",children:a("chat.composer.hint")})]})]}),T!==void 0&&R!==void 0&&!he&&o.jsx(JA,{quote:T,onRemove:R,onJump:E}),o.jsx(Lv,{className:"composer-refs-row",items:we,onRemove:g===void 0&&S===void 0?void 0:Me,removeLabel:oe=>oe.kind==="ref"?a("chat.sessionRef.remove",{name:oe.label}):a("composer.refs.remove",{name:oe.label})}),o.jsx(l1,{value:pe,children:o.jsx(Pv,{contextUsage:v,sessionId:N,port:Z,slot:j!==void 0?o.jsx(VA,{...j}):void 0,primary:!l||!c?o.jsx(G,{variant:"primary",onClick:d,children:a("common.configureConnection")}):o.jsx(Av,{label:a(r?"chat.composer.sending":"chat.composer.send"),disabled:!F,onClick:n}),children:o.jsx(Zp,{ref:$,className:"composer-input",value:e,onChange:t,onCompositionEnd:()=>{A.current=Date.now()},onKeyDown:oe=>{oe.key!=="Enter"||oe.nativeEvent.isComposing||oe.target.closest("button")||!(oe.ctrlKey||oe.metaKey)&&oe.shiftKey||(oe.preventDefault(),!(Date.now()-A.current<50)&&F&&n())},onPasteFiles:oe=>{me(oe,$.current?.getCaretOffset()??null)},placeholder:K,disabled:!l||!c||r||s,spellCheck:!1,"aria-label":a("chat.composer.input"),enterKeyHint:"send",atomicSchemes:W,atomicPort:Z})})})]})})}function Kd(e,t,n){if(n){const s=new Set(e);return s.has(t)?s.delete(t):s.add(t),[...s]}return e.includes(t)?[]:[t]}function Kv({count:e,children:t}){const[n,s]=u.useState(!1),r=u.useId();return e===0?null:o.jsxs("div",{className:"mt-2 border-t border-line pt-2",children:[o.jsx(G,{variant:"link",size:"small","aria-expanded":n,"aria-controls":n?r:void 0,onClick:()=>s(i=>!i),children:n?a("pending.answeredGroup.collapse",{count:e}):a("pending.answeredGroup.expand",{count:e})}),n?o.jsx("div",{id:r,children:t}):null]})}function Wd({options:e,selected:t,multi:n,disabled:s,name:r,onToggle:i}){return o.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(l=>o.jsx(f1,{option:l,picked:t.includes(l),multi:n,disabled:s,name:r,onToggle:i},l))})}function Uf(e,t){setTimeout(()=>{e.checked=t()},0)}function f1({option:e,picked:t,multi:n,disabled:s,name:r,onToggle:i}){const l=u.useRef(null),c=u.useRef(t);c.current=t;const d=()=>c.current;return o.jsxs("label",{className:be("inline-flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-md pointer-coarse:min-h-touch",t?"bg-accent-soft text-accent-ink":"bg-raised text-ink hover:bg-hover",!n&&"has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-accent has-[:focus-visible]:ring-offset-2 has-[:focus-visible]:ring-offset-surface"),children:[o.jsx("input",{ref:l,className:be(n?"accent-accent":"sr-only"),type:n?"checkbox":"radio",name:r,checked:t,disabled:s,onClick:m=>{n||!t||(m.preventDefault(),i(e),Uf(m.currentTarget,d))},onChange:()=>i(e),onKeyDown:m=>{n||m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),i(e),l.current&&Uf(l.current,d))}}),n?null:o.jsx("span",{"aria-hidden":"true",className:be("grid size-4 flex-none place-items-center rounded-full border-2 transition-colors",t?"border-accent":"border-line-strong",s&&"opacity-60"),children:o.jsx("span",{className:be("size-2 rounded-full transition-colors",t?"bg-accent":"bg-transparent")})}),o.jsx("span",{children:e})]})}const h1=4e3,lo=new Map;function Wv(e){const t=lo.get(e);t!==void 0&&(clearTimeout(t.timer),lo.delete(e))}function Uv(e,t,n=h1){const s=t.filter(l=>l.length>0);if(s.length===0)return;Wv(e);const r=new Set(s),i=setTimeout(()=>{lo.delete(e)},n);i.unref?.(),lo.set(e,{ids:r,timer:i})}function zv(e){return[...lo.get(e)?.ids??[]]}function p1(e,t){const n=lo.get(e);if(n!==void 0&&t!==void 0){for(const s of t)n.ids.delete(s);n.ids.size===0&&Wv(e)}}function Vv(e,t){const n=[];for(const s of e){p1(s.requestId,s.answeredQuestionIds);const r=zv(s.requestId);(s.questions??[]).forEach((l,c)=>{const d=tc(t,s.requestId,c),m=yr(l,c),f=Gp(s.answeredQuestionIds,l,c),h=r.includes(m);n.push({requestId:s.requestId,index:c,questionId:m,question:l,draft:d,answered:li(d),settled:f||h})})}return n}function Gv(e){return e.filter(t=>!t.settled)}function Yv(e){return e.filter(t=>!t.settled&&t.answered)}function g1(e){return e.filter(t=>t.settled)}function Jv(e){return{open:Gv(e),answered:g1(e)}}function Qv(e){return Vp(e.question,e.draft,e.index)}function b1(e){return Yv(e).map(Qv)}function v1(e){return Yv(e).filter(t=>t.draft.include).map(Qv)}function y1(e){return Gv(e).every(t=>t.answered)}function Xv(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function x1(e){return e.selected.length>0||e.custom.trim().length>0}function w1({request:e,pendingCount:t=1,busy:n=!1,onSubmit:s,onCancel:r}){const i=Ad(),l=Md(),c=`ask-card-${e.requestId}`,d=(b,x,y)=>{l(e.requestId,b,v=>({...v,selected:Kd(v.selected,x,y)}))},m=Vv([e],i),f=Jv(m),h=b1(m),p=h.length>0&&y1(m),g=b=>o.jsxs("div",{className:be("flex flex-col gap-2 rounded-md bg-sunken p-3.5",b.settled&&"opacity-70"),children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsx("div",{className:"font-mono text-2xs font-semibold uppercase tracking-widest text-accent-ink",children:b.question.header}),b.settled&&o.jsx(Re,{tone:"neutral",children:a("pending.item.answered")})]}),o.jsx("div",{className:"leading-relaxed whitespace-pre-wrap wrap-anywhere",children:b.question.question}),o.jsx(Wd,{options:b.question.options??[],selected:b.draft.selected,multi:b.question.multi_select===!0,disabled:n||b.settled,name:`ask-${e.requestId}-${b.index}`,onToggle:x=>d(b.index,x,b.question.multi_select===!0)}),o.jsx(Xe,{value:b.draft.custom,disabled:n||b.settled,onChange:x=>{const y=x.target.value;l(e.requestId,b.index,v=>({...v,custom:y}))},placeholder:b.question.options?a("ask.customPlaceholder.options"):a("ask.customPlaceholder.open")})]},`${e.requestId}-${b.question.header}-${b.question.question}`);return o.jsxs("fieldset",{className:"ask-card","aria-labelledby":c,"data-request-id":e.requestId,children:[o.jsxs("div",{className:"ask-card-head",id:c,children:[o.jsx("span",{className:"ask-card-title",children:a("ask.title")}),o.jsxs("span",{className:"ask-card-meta font-mono text-muted tabular-nums",children:["run ",Xv(e.runId,16)]}),e.mode==="async"&&o.jsx("span",{className:"ask-card-meta font-mono text-2xs text-accent",children:a("ask.asyncBadge")}),t>1&&o.jsx("span",{className:"text-muted",children:a("ask.pendingMore",{count:t-1})})]}),o.jsxs("div",{className:"ask-list flex flex-col gap-3 pr-1",children:[f.open.map(g),o.jsx(Kv,{count:f.answered.length,children:f.answered.map(g)})]}),o.jsxs("div",{className:"ask-card-actions mt-2 flex justify-end gap-2",children:[o.jsx(G,{variant:"dangerGhost",disabled:n,onClick:r,children:a("common.cancel")}),o.jsx(G,{variant:"primary",disabled:!p||n,onClick:()=>{Uv(e.requestId,h.map(b=>b.question_id??"")),s(h)},children:a(n?"permission.busy":"ask.submit")})]})]})}function k1({request:e,questionIndex:t,selected:n,custom:s,busy:r=!1,connected:i=!0,canAdvance:l,isLast:c,onToggle:d,onCustom:m,onPrev:f,onNext:h,onCancel:p}){const g=`ask-card-${e.requestId}-${t}`,b=e.questions[t],x=zv(e.requestId),y=b!==void 0&&(Gp(e.answeredQuestionIds,b,t)||x.includes(yr(b,t))),v=r||!i||y,j=y||(b?x1({selected:[...n],custom:s}):!0);return o.jsxs("fieldset",{className:"ask-card ask-card-single","aria-labelledby":g,"data-request-id":e.requestId,children:[o.jsxs("div",{className:"ask-card-head",id:g,children:[o.jsx("span",{className:"ask-card-title",children:a("ask.title")}),o.jsxs("span",{className:"ask-card-meta font-mono text-muted tabular-nums",children:["run ",Xv(e.runId,16)]}),b&&o.jsx("span",{className:"ask-card-meta text-muted tabular-nums",children:a("ask.progress",{current:t+1,total:e.questions.length})}),y&&o.jsx(Re,{tone:"neutral",children:a("pending.item.answered")})]}),b&&o.jsx("div",{className:"ask-list flex flex-col gap-3 pr-1",children:o.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-sunken p-3.5",children:[o.jsx("div",{className:"font-mono text-2xs font-semibold uppercase tracking-widest text-accent-ink",children:b.header}),o.jsx("div",{className:"leading-relaxed whitespace-pre-wrap wrap-anywhere",children:b.question}),o.jsx(Wd,{options:b.options??[],selected:n,multi:b.multi_select===!0,disabled:v,name:`${e.requestId}-${t}`,onToggle:d}),o.jsx(Xe,{value:s,disabled:v,onChange:_=>m(_.target.value),placeholder:b.options?a("ask.customPlaceholder.options"):a("ask.customPlaceholder.open"),"aria-label":`${b.header}: ${b.question}`})]},`${e.requestId}-${t}`)}),!j&&o.jsx("p",{className:"mt-2 text-sm text-muted",role:"status",children:a("ask.answerRequired")}),o.jsxs("div",{className:"ask-card-actions mt-2 flex justify-end gap-2",children:[o.jsx(G,{variant:"dangerGhost",disabled:v,onClick:p,children:a("common.cancel")}),f&&o.jsx(G,{disabled:v,onClick:f,children:a("ask.previous")}),o.jsx(G,{variant:"primary",disabled:!l||v,onClick:h,children:a(r?"permission.busy":c?"ask.submit":"ask.next")})]})]})}const zf=2e4,Zv=12;function S1(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function ey(e){let t;try{t=JSON.stringify(e,null,2)??String(e)}catch{t=String(e)}return t.length>zf?{text:S1(t,zf),truncated:!0}:{text:t,truncated:!1}}function j1(e,t,n=Zv){if(t)return e;const s=e.split(`
|
|
583
|
+
`);return s.length<=n?e:s.slice(0,n).join(`
|
|
584
|
+
`)}function Ud({request:e,busy:t=!1,connected:n=!0,onDecide:s}){const r=`permission-${e.requestId}`,[i,l]=u.useState(!1),c=ey(e.input),d=c.text.split(`
|
|
585
|
+
`),m=c.truncated||d.length>Zv,f=t||!n,h=j1(c.text,i);return u.useEffect(()=>{l(!1)},[e.requestId]),o.jsxs("fieldset",{className:"permission-card","aria-labelledby":r,"data-request-id":e.requestId,children:[o.jsxs("div",{className:"permission-card-head",id:r,children:[o.jsx("span",{className:"self-start rounded-full bg-accent-soft px-2.5 py-1 font-mono text-sm text-accent-ink",children:e.tool}),o.jsx("span",{className:"text-sm text-muted",children:a(t?"permission.busy":"permission.inline.waiting")})]}),o.jsx("pre",{className:"permission-input m-0 rounded-sm bg-sunken px-3.5 py-3 font-mono text-sm leading-relaxed text-muted whitespace-pre-wrap wrap-anywhere",children:h}),m&&o.jsx(G,{variant:"link",className:"self-start text-xs","aria-expanded":i,onClick:()=>l(p=>!p),children:a(i?"permission.collapse":"permission.expand")}),c.truncated&&o.jsx("span",{className:"self-start text-xs text-muted",children:a("permission.truncated")}),o.jsxs("div",{className:"permission-card-actions flex flex-wrap justify-end gap-2",children:[o.jsx(G,{variant:"dangerGhost",disabled:f,onClick:()=>s("deny","once"),children:a("permission.deny")}),o.jsx(G,{variant:"primary",disabled:f,onClick:()=>s("allow","once"),children:a("permission.allowOnce")}),o.jsx(G,{disabled:f,onClick:()=>s("allow","session"),children:a("permission.allowSession")}),o.jsx(G,{disabled:f,onClick:()=>s("allow","always"),children:a("permission.always")})]})]})}function ty({label:e,more:t,focusKey:n,onStop:s,stopping:r=!1,connected:i=!0,queue:l,children:c}){const d=u.useRef(null);return u.useEffect(()=>{d.current?.focus()},[n]),o.jsx("footer",{className:"composer-area",children:o.jsxs("section",{ref:d,tabIndex:-1,className:"prompt-slot motion-appear mx-auto flex w-full max-w-[var(--chat-content-w,860px)] flex-col gap-2 overflow-y-auto overscroll-contain rounded-lg bg-raised px-3.5 py-3","aria-label":a("chat.prompt.label"),children:[o.jsxs("div",{className:"prompt-slot-head sticky top-0 z-1 flex flex-wrap items-baseline gap-2.5 bg-raised py-0.5 text-sm",children:[o.jsx("span",{className:"prompt-slot-kind text-md text-ink",children:e}),t>0&&o.jsx("span",{className:"text-muted",children:a("chat.prompt.more",{count:t})}),o.jsx("span",{className:"prompt-slot-hint text-muted",children:a("chat.prompt.blocking")}),s&&o.jsx(G,{variant:"link",className:"prompt-slot-stop",onClick:s,disabled:r,children:a(r?"chat.run.stopping":"chat.run.stop")}),l&&l.length>0&&o.jsx("div",{className:"flex basis-full flex-wrap gap-2",children:l.slice(0,3).map(m=>o.jsx("span",{className:"inline-flex items-center rounded-full bg-sunken px-2.5 py-0.5 text-2xs leading-relaxed text-muted",children:m.label},m.key))}),o.jsxs("span",{className:"sr-only","aria-live":"polite",children:[e,t>0?` ${a("chat.prompt.more",{count:t})}`:""]})]}),i===!1&&o.jsx("p",{className:"prompt-slot-hint ml-0 text-danger",role:"status",children:a("chat.prompt.disconnected")}),c]})})}function _1({request:e,more:t=0,busy:n=!1,connected:s=!0,onStop:r,stopping:i=!1,queue:l,onDecide:c}){return o.jsx(ty,{label:a("chat.prompt.permission"),more:t,focusKey:e.requestId,onStop:r,stopping:i,connected:s,queue:l,children:o.jsx(Ud,{request:e,busy:n,connected:s,onDecide:c})})}function N1({request:e,otherPending:t=0,busy:n=!1,connected:s=!0,onStop:r,stopping:i=!1,queue:l,onSubmit:c,onCancel:d}){const m=u.useMemo(()=>e.questions.map((R,E)=>yr(R,E)),[e.questions]),[f,h]=JL(e.requestId,m),p=Ad(),g=Md(),b=u.useRef(!1);u.useEffect(()=>{b.current=!1},[e.requestId]),u.useEffect(()=>{n||(b.current=!1)},[n]);const x=tc(p,e.requestId,f),y=e.questions[f],v=e.questions.map((R,E)=>Vp(R,tc(p,e.requestId,E),E)),j=y?x.selected.length>0||x.custom.trim().length>0:!1,_=e.questions.length>0&&v.every(R=>R.answer.length>0),S=f>=e.questions.length-1,w=Math.max(0,e.questions.length-f-1),k=(R,E)=>{g(e.requestId,R,E)},N=R=>{if(!y)return;const E=y.multi_select===!0;k(f,I=>({...I,selected:Kd(I.selected,R,E)}))},T=()=>{if(S){if(!_||b.current)return;b.current=!0,c(v);return}j&&h(f+1)};return o.jsx(ty,{label:a("chat.prompt.question"),more:t+w,focusKey:`${e.requestId}:${f}`,onStop:r,stopping:i,connected:s,queue:l?.slice(f,f+3),children:o.jsx(k1,{request:e,questionIndex:f,selected:x.selected,custom:x.custom,busy:n,connected:s,canAdvance:S?_:j,isLast:S,onToggle:N,onCustom:R=>k(f,E=>({...E,custom:R})),onPrev:f>0?()=>h(f-1):void 0,onNext:T,onCancel:d})})}function C1({pendingFetch:e,onRetry:t}){if(e.status!=="failed")return null;const n=e.kind==="session"||e.kind==="origin",s={id:"composer-pending-fetch",tone:"error",text:a(n?"pending.fetch.shortBlocked":"pending.fetch.shortFailed"),hint:n?a("pending.fetch.blocked",{detail:e.message??""}):a("pending.fetch.failed",{detail:e.message??""}),...t?{actions:[{label:a("pending.fetch.retry"),onClick:t}]}:{}};return o.jsx(Qh,{items:[s]})}function T1({pendingItem:e,pendingItems:t,queueChips:n,responding:s,connected:r,onStop:i,stopping:l,onDecide:c,onRespondAsk:d,value:m,onChange:f,onSubmit:h,submitting:p,targetLabel:g,hasToken:b,onOpenConnection:x,focusSignal:y,refs:v,onRemoveRef:j,onAddRef:_,onUpdateRef:S,client:w,contextUsage:k,memberModel:N,sessionId:T,pendingFetch:R,onRetryPendingFetch:E,sessionRefs:I,onRemoveSessionRef:$,onAddSessionRef:C,currentScope:L,quote:A,onRemoveQuote:D,onJumpQuote:O,quoteSignal:F}){const V=R?o.jsx(C1,{pendingFetch:R,onRetry:E}):null,B=e&&e.kind==="permission"?o.jsx(_1,{request:e.request,more:t.length-1,busy:s.has(e.request.requestId),connected:r,onStop:i,stopping:l,queue:n,onDecide:(W,Z)=>c(e.request.requestId,W,Z)},e.request.requestId):e&&e.kind==="ask"?o.jsx(N1,{request:e.request,otherPending:Math.max(0,t.length-Math.max(1,e.request.questions.length)),busy:s.has(e.request.requestId),connected:r,onStop:i,stopping:l,queue:n,onSubmit:W=>d(e.request.requestId,W),onCancel:()=>d(e.request.requestId,[])},e.request.requestId):o.jsx(m1,{value:m,onChange:f,onSubmit:h,submitting:p,targetLabel:g,hasToken:b,connected:r,onOpenConnection:x,focusSignal:y,onStop:i,stopping:l,refs:v,onRemoveRef:j,onAddRef:_,onUpdateRef:S,client:w,contextUsage:k,memberModel:N,sessionRefs:I,onRemoveSessionRef:$,onAddSessionRef:C,currentScope:L,sessionId:T,quote:A,onRemoveQuote:D,onJumpQuote:O,quoteSignal:F});return V===null?B:o.jsxs(o.Fragment,{children:[V,B]})}function E1({target:e,counts:t,error:n,connected:s,busy:r,onConfirm:i,onCancel:l,onViewRuns:c}){return o.jsx(In,{title:a("chat.delete.title",{title:Sn(e)}),body:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:a("chat.delete.body")}),o.jsxs("p",{className:"text-muted",children:[a("chat.delete.counts",{messages:e.message_count}),t&&!t.loading?a("chat.delete.runsCount",{count:t.live+t.durable}):t?.loading?a("chat.delete.counting"):""]}),t&&t.active>0&&o.jsx("p",{className:"text-danger",role:"alert",children:a("chat.delete.activeRuns",{count:t.active})}),t?.error&&o.jsx("p",{className:"text-muted",children:a("chat.delete.statsFailed",{detail:t.error})}),o.jsx("p",{className:"text-muted",children:a("chat.delete.serverReject")}),!s&&o.jsx("p",{className:"text-danger",children:a("chat.delete.disconnected")}),n&&o.jsx("p",{className:"text-danger",role:"alert",children:n})]}),confirmLabel:a("chat.delete.confirm"),danger:!0,busy:r,confirmDisabled:!s||!!t?.loading||(t?.active??0)>0,onConfirm:i,onCancel:l,extra:n?o.jsx(G,{type:"button",variant:"link",onClick:c,children:a("chat.delete.viewRuns")}):void 0})}const Vf="main";function cr(e){const t=e.session_id??e.body_id;return(typeof t=="string"?t.trim():"")||void 0}function I1(e){const t=e.find(l=>(l.id??l.agent_id)===Vf);if(!t)return null;const n=(t.bodies??[]).map(l=>cr(l)).filter(l=>l!==void 0),s=(t.bodies??[]).find(l=>l.primary===!0),i=(s?cr(s):void 0)??t.session_id?.trim()??"";return i?{sessionId:i,name:t.name?.trim()||Vf,bodies:[i,...n.filter(l=>l!==i)]}:null}function R1(e){const t=new Set,n=(s,r)=>{const i=s?.trim()??"",l=(r??[]).find(d=>d.primary===!0),c=(l?cr(l):void 0)??(i||void 0);c&&t.add(c)};for(const s of e){for(const r of s.agents??[])n(r.session_id,r.bodies);for(const r of s.rosters)for(const i of r.members)n(i.session_id,i.bodies)}return t}function L1(e){const t=new Map,n=(s,r)=>{const i=s?.trim()??"",l=r?.trim()??"";!i||!l||t.has(i)||t.set(i,l)};for(const s of e){for(const r of s.agents??[]){const i=r.agent_id??r.id;n(r.session_id,i);for(const l of r.bodies??[])n(cr(l),i)}for(const r of s.rosters)for(const i of r.members){n(i.session_id,i.agent_id);for(const l of i.bodies??[])n(cr(l),i.agent_id)}}for(const s of e)for(const r of s.rosters)for(const i of r.members)for(const l of i.body_history??[])n(l.session_id,i.agent_id);return t}function A1(e){return e==="running"?"info":e==="done"?"success":"danger"}const M1={info:"bg-info",success:"bg-success",danger:"bg-danger"};function P1(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),s=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h${String(s).padStart(2,"0")}m`:s>0?`${s}m${String(r).padStart(2,"0")}s`:`${r}s`}function q1(e,t){const[n,s]=u.useState(()=>Date.now());return u.useEffect(()=>{if(!t)return;const r=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(r)},[t]),n-e}function lc({label:e,copyText:t,children:n}){return o.jsxs("section",{className:"tool-section",children:[o.jsxs("div",{className:"tool-section-head",children:[o.jsx("span",{className:"tool-section-label",children:e}),t!==void 0&&t!==""&&o.jsx(ls,{text:t,className:"tool-section-copy"})]}),n]})}function ny({summary:e}){return e?o.jsx("p",{className:"m-0 whitespace-pre-wrap break-words text-sm leading-relaxed text-ink",children:e}):null}function sy(){return o.jsxs("span",{className:"text-xs text-faint",children:[a("inbox.asyncJob.running"),"…"]})}function O1({job:e,entry:t}){const n=e.status==="running",s=e.payload??{},r=typeof s.command=="string"?s.command:void 0,i=typeof s.exit_code=="number"||s.exit_code===null?s.exit_code:void 0;return o.jsxs("div",{className:"flex flex-col gap-2",children:[r!==void 0&&o.jsx(lc,{label:a("inbox.asyncJob.input"),copyText:r,children:o.jsx("pre",{className:"tool-section-body",children:r})}),o.jsx(lc,{label:a("inbox.asyncJob.output"),copyText:t.summary,children:o.jsxs("div",{className:"tool-section-body flex flex-col gap-1",children:[i!=null&&o.jsxs("span",{className:"font-mono text-xs text-faint",children:["exit ",i]}),n?o.jsx(sy,{}):o.jsx(ny,{summary:t.summary})]})})]})}function D1({job:e,entry:t}){return o.jsx(lc,{label:a("inbox.asyncJob.output"),copyText:t.summary,children:o.jsx("div",{className:"tool-section-body",children:e.status==="running"?o.jsx(sy,{}):o.jsx(ny,{summary:t.summary})})})}function H1({entry:e}){const t=e.async_job,n=t.status==="running",s=q1(t.started_at,n),r=n?s:(t.ended_at??Date.now())-t.started_at,i=t.payload??{},l=typeof i.command=="string"?i.command:void 0,c=typeof i.exit_code=="number"||i.exit_code===null?i.exit_code:void 0;return o.jsx(Jt,{className:"notice-block stream-card-job w-full min-w-0 max-w-full",defaultOpen:!1,ariaLabel:`${t.kind} ${kn(t.job_id)}`,title:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${M1[A1(t.status)]}${n?" animate-pulse":""}`}),t.kind]}),meta:o.jsxs("span",{className:"inline-flex items-center gap-2",children:[o.jsx("span",{title:`${t.kind}:${t.job_id}`,children:kn(t.job_id)}),o.jsx("span",{children:P1(r)}),c!=null&&o.jsxs("span",{children:["exit ",c]})]}),summary:t.kind==="bash"&&l!==void 0?o.jsxs("span",{className:"font-mono text-xs",children:["$ ",l]}):e.summary,children:t.kind==="bash"?o.jsx(O1,{job:t,entry:e}):o.jsx(D1,{job:t,entry:e})})}const Gf=160;function oy(e){const t=e.trim().replace(/\s+/g," ");return t.length>Gf?`${t.slice(0,Gf)}…`:t}const $1="agent.message.queued";function F1(e){const t=e.event;if(t.type!==$1)return;const n=t.data??{},s=typeof n.message_id=="string"?n.message_id:void 0;if(s===void 0||s==="")return;const r=e.sessionId??(typeof n.session_id=="string"?n.session_id:void 0)??void 0;return{messageId:s,...r!==void 0?{sessionId:r}:{},...typeof n.from=="string"?{from:n.from}:{},...typeof n.delivery=="string"?{delivery:n.delivery}:{}}}function B1(e){return e.state==="sending"}function K1(e){return e.state==="queued"||e.state==="deferred"||e.state==="failed"}function W1(e,t){const n=oy(t);return e===n?!0:e.endsWith("…")?n.startsWith(e.slice(0,-1)):!1}function U1(e,t){return e.messageId!==void 0?e.messageId===t.message_id:t.from!==ns||t.session_id===void 0||e.sessionId!==null&&e.sessionId!==t.session_id?!1:W1(t.summary,e.text)}function ry(e,t){const n=new Set,s=new Map;for(const r of e)for(const i of t)if(!n.has(i.message_id)&&U1(r,i)){n.add(i.message_id),s.set(r.id,i.message_id);break}return s}function Yf(e,t){return new Set(ry(e,t).values())}function Jf(e,t,n){return ry(t,n).get(e.id)}function z1(e){return la(e.name)}function Vo({sender:e,senderKind:t="agent",content:n,ts:s,source:r,defaultOpen:i=!1,entering:l=!1}){const c=cn(s),d=kd(),m=Sd(),f=ma(),h=r!==void 0?Ti(da(r)??{principal:r},d,{node:m,principal:f}):void 0,p=t==="tool"?"chat.toolMessage.from":"chat.agentMessage.from",g=t==="tool"?"chat.toolMessage.group":"chat.agentMessage.group";return o.jsxs(Jt,{className:be("agent-message",l&&"msg-enter"),ariaLabel:a(g,{name:e}),defaultOpen:i,title:o.jsx("span",{className:"max-w-56 truncate font-mono text-2xs tracking-wider text-accent",children:a(p,{name:e})}),summary:n,children:[(r!==void 0||c!=="")&&o.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline gap-x-2 font-mono text-2xs text-faint",children:[r!==void 0&&o.jsx("span",{className:"break-all select-all",title:r,children:h}),c!==""&&o.jsx("time",{className:"shrink-0 tabular-nums",dateTime:new Date(s??0).toISOString(),children:c})]}),o.jsx("p",{className:"m-0 whitespace-pre-wrap wrap-anywhere text-sm leading-relaxed text-ink",children:n})]})}function iy(e,t,n=!0){return e==="error"?!0:t!=="minimal"&&n}function V1(e,t){return t!=="minimal"||Ki(e)}function G1(e,t){if((t.verbosity==="minimal"||t.tools===!1)&&t.running===!0)for(let s=e.length-1;s>=0;s-=1){const r=e[s];if(!(r===void 0||r.kind!=="tool"))return r.status==="running"?{key:r.key,name:r.name}:void 0}}function zd(e,t=!1){return e!=="minimal"&&t}function Y1(e,t){const n=t.verbosity,s=t.tools!==!1,r=t.reasoning===!0;return n!=="minimal"&&s&&r?e.slice():e.filter(i=>i.kind==="text"||i.kind==="notice"?!0:i.kind==="reasoning"?zd(n,r):i.kind==="tool"?iy(i.status,n,s):V1(i.event.type,n))}function wn(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function cc(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}function J1(e){return typeof e.message_count=="number"?e.message_count:Array.isArray(e.messages)?e.messages.length:null}function Q1(e){switch(e.type){case"tool.call.started":{const t=e.data,n=t.arguments!==void 0?t.arguments:t.args;return o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono text-md",children:t.tool_name??"tool"}),n!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted",children:wn(cc(n),160)}),t.truncated===!0&&o.jsx("span",{className:"text-muted",children:a("chat.event.truncated")})]})]})}case"tool.call.completed":{const t=e.data;return o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono text-md",children:t.tool_name??"tool"}),t.duration_ms!=null&&o.jsxs("span",{className:"text-muted",children:[t.duration_ms,"ms"]}),t.result!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted",children:wn(cc(t.result),160)}),t.truncated===!0&&o.jsx("span",{className:"text-muted",children:a("chat.event.truncated")})]})]})}case"tool.call.failed":{const t=e.data,n=Do(ts(e.data));return o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono text-md",children:t.tool_name??"tool"}),n&&o.jsx("span",{className:"error-meta font-mono tabular-nums",children:n}),o.jsx("span",{className:"text-danger",children:wn(t.error??"error",240)})]})}case"guardrail.blocked":{const t=e.data;return o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono text-md",children:t.guardrail_name??"guardrail"}),o.jsx("span",{className:"text-muted",children:wn(t.reason??"",160)})]})}case"guardrail.modified":{const t=e.data;return o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono text-md",children:t.guardrail_name??"guardrail"}),o.jsx("span",{className:"text-muted",children:t.stage??""})]})}case"llm.request":{const t=e.data,n=J1(e.data),s=Array.isArray(t.tools)?t.tools.length:0,r=[];return n!==null&&r.push(`${n} msgs`),s>0&&r.push(`${s} tools`),o.jsx("span",{className:"text-muted",children:r.join(" · ")})}case"llm.response":{const t=e.data;return o.jsxs("span",{className:"text-muted",children:[t.finish_reason??"",t.usage?.total_tokens!=null?` · ${t.usage.total_tokens} tok`:""]})}case"error":{const t=e.data,n=Do(ts(e.data));return o.jsxs(o.Fragment,{children:[n&&o.jsx("span",{className:"error-meta font-mono tabular-nums",children:n}),o.jsx("span",{className:"text-danger",children:wn(t.error??"error",240)})]})}default:{const t=e.data;if(e.type.endsWith(".failed")&&typeof t.error=="string"&&t.error.length>0){const n=Do(ts(e.data));return o.jsxs(o.Fragment,{children:[n&&o.jsx("span",{className:"error-meta font-mono tabular-nums",children:n}),o.jsx("span",{className:"text-danger",children:wn(t.error,240)})]})}return o.jsx("span",{className:"text-muted",children:wn(X1(e.data),200)})}}}const Qf=new WeakMap;function X1(e){if(typeof e!="object"||e===null)return JSON.stringify(e)??String(e);const t=Qf.get(e);if(t!==void 0)return t;const n=JSON.stringify(e)??String(e);return Qf.set(e,n),n}const Z1={"tag-tool-start":"bg-info-soft text-info","tag-tool-done":"bg-success-soft text-success","tag-tool-fail":"bg-danger-soft text-danger","tag-error":"bg-danger-soft text-danger","tag-guard":"bg-warn-soft text-warn","tag-llm":"text-accent","tag-raw":"text-muted"};function It(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Fs(e){return typeof e=="string"&&e.length>0?wn(e,12):"?"}function eM(e){const t=e.data;switch(e.type){case"context.pressure":{const n=It(t.used),s=It(t.max),r=It(t.ratio),i=r!==void 0?Math.round(r*100):n!==void 0&&s!==void 0&&s>0?Math.round(n/s*100):void 0;return{tone:"warn",text:a("chat.notice.contextPressure",{percent:i??"?",used:n!==void 0?hi(n):"?",max:s!==void 0?hi(s):"?"})}}case"context.compacted":return{tone:"info",text:a("chat.notice.contextCompacted",{removed:It(t.removed)??0,remaining:It(t.remaining)??0,reason:typeof t.reason=="string"&&t.reason.length>0?t.reason:"auto"})};case"context.cleared_tool_result":return{tone:"info",text:a("chat.notice.contextTrimmed",{cleared:It(t.cleared)??0,added:It(t.added)??0,kept:It(t.kept)??0})};case"agent.limit.warning":return{tone:"warn",text:a("chat.notice.limitWarning",{key:typeof t.key=="string"&&t.key.length>0?t.key:"limit",current:It(t.current)??"?",max:It(t.max)??"?"})};case"agent.restarting":return{tone:"info",text:a("chat.notice.restarting",{session:Fs(t.from_session_id??t.session_id),from:It(t.from_epoch)??"?",epoch:It(t.epoch)??"?"})};case"agent.restarted":return{tone:"info",text:a("chat.notice.restarted",{session:Fs(t.from_session_id??t.session_id),from:It(t.from_epoch)??"?",epoch:It(t.epoch)??"?"})};case"agent.compact_forked":return{tone:"info",text:a("chat.notice.compactForked",{from:Fs(t.from_session_id),to:Fs(t.to_session_id),epoch:It(t.epoch)??"?"})};case"run.finalize.failed":{const n=typeof t.error=="string"&&t.error.length>0?t.error:"error",s=typeof t.phase=="string"&&t.phase.length>0?t.phase:"finalize";return{tone:"danger",text:a("chat.notice.finalizeFailed",{phase:s,error:wn(n,240)})}}case"guardrail.error":{const n=typeof t.guardrail_name=="string"&&t.guardrail_name.length>0?t.guardrail_name:"guardrail",s=typeof t.stage=="string"&&t.stage.length>0?t.stage:"?",r=typeof t.error=="string"&&t.error.length>0?t.error:"error";return{tone:"danger",text:a("chat.notice.guardrailError",{name:n,stage:s,error:wn(r,240)})}}case"hook.started":case"hook.completed":case"hook.system_prompt_ignored":case"hook.additional_context_deprecated":{const n=typeof t.hook_name=="string"&&t.hook_name.length>0?t.hook_name:e.type;return{tone:"info",text:a("chat.notice.hook",{name:n})}}case"agent.reply.stale":return t.reason==="handoff_no_reply"?{tone:"info",text:a("chat.notice.handoffNoReply",{outcome:typeof t.outcome=="string"?t.outcome:"?",epoch:It(t.epoch)??"?"})}:{tone:"warn",text:a("chat.notice.replyStale",{message:Fs(t.message_id),epoch:It(t.epoch)??"?"})};case"agent.retired":return{tone:"info",text:a("chat.notice.retired",{reason:typeof t.reason=="string"&&t.reason.length>0?t.reason:"?",epoch:It(t.epoch)??"?",body:Fs(t.body_id)})};case"agent.rotate.denied":return{tone:"warn",text:a("chat.notice.rotateDenied",{reason:typeof t.reason=="string"&&t.reason.length>0?t.reason:"?",percent:It(t.context_percent)??"?"})};default:return Ac(e.type)===void 0?{tone:"info",text:a("chat.notice.unknownEvent",{type:e.type})}:null}}function ay({event:e}){const t=e.data,n=t==null?"":cc(t);return o.jsxs("div",{className:"event-block-body",children:[o.jsx("div",{className:"event-raw-label",children:a("chat.event.raw")}),o.jsxs("dl",{className:"event-meta-list","aria-label":a("chat.event.meta"),children:[o.jsx("dt",{children:a("chat.event.type")}),o.jsx("dd",{className:"font-mono wrap-anywhere",children:e.type}),o.jsx("dt",{children:a("chat.event.time")}),o.jsx("dd",{className:"font-mono tabular-nums",children:bt(e.ts,{withMs:!0})}),o.jsx("dt",{children:a("chat.event.runId")}),o.jsx("dd",{className:"font-mono wrap-anywhere",children:e.run_id})]}),o.jsx("div",{className:"event-raw-label",children:a("chat.event.rawData")}),o.jsx("pre",{className:"event-raw-pre",children:n||a("chat.event.empty")})]})}function ly({event:e,defaultOpen:t=!1,entering:n=!1}){const s=eM(e);return s?o.jsx(Jt,{tone:s.tone,defaultOpen:t,entering:n,title:o.jsx("span",{className:"notice-block-text",role:"status",children:s.text}),children:o.jsx(ay,{event:e})}):o.jsx(cy,{event:e,defaultOpen:t,entering:n})}function cy({event:e,defaultOpen:t=!1,entering:n=!1}){const s=Nw(e.type);return o.jsx(Jt,{defaultOpen:t,entering:n,title:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"shrink-0 font-mono text-sm tabular-nums text-faint",children:bt(e.ts,{withMs:!0})}),o.jsx("span",{className:"shrink-0 rounded-xs px-1.5 font-mono text-sm leading-4 tracking-wide whitespace-nowrap "+(Z1[s.cls]??"text-faint"),children:s.label})]}),summary:Q1(e),children:o.jsx(ay,{event:e})})}const tM=[{pattern:/\b(lease_expired|stale_fence)\b/u,key:"chat.run.reason.lease"},{pattern:/\b(session_locked|binding_locked)\b/u,key:"chat.run.reason.locked"},{pattern:/\b(quota|rate_limit|429)\b/u,key:"chat.run.reason.rateLimited"},{pattern:/\b(context_(overflow|exceeded)|prompt_too_long)\b/u,key:"chat.run.reason.contextTooLong"}];function nM(e){if(e===void 0)return;const t=e.trim();if(t!==""){for(const n of tM)if(n.pattern.test(t))return{key:n.key,raw:t};return{raw:t}}}function sM({chips:e,className:t}){return e.length===0?null:o.jsxs(Yp,{className:t,ariaLabel:a("chat.sessionRef.header"),children:[o.jsx("div",{className:"flex flex-wrap items-center gap-2",children:o.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-muted",children:[o.jsx("span",{"aria-hidden":"true",className:"inline-flex text-faint",children:o.jsx(yt,{name:"transcript",size:14})}),a("chat.sessionRef.header")]})}),o.jsx("div",{className:"flex flex-col gap-1",children:e.map(n=>o.jsxs("a",{href:Fn({domain:"chat",sessionId:n.sessionId}),className:"flex min-w-0 flex-wrap items-center gap-1.5 rounded-md px-2 py-1.5 text-xs transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",title:Fd(n),children:[o.jsx("span",{className:"min-w-0 truncate font-medium text-ink",children:n.title}),$d(n,void 0).map(s=>o.jsx("span",{className:"rounded bg-sunken px-1.5 py-0.5 font-mono text-2xs text-faint",children:s},s))]},n.sessionId))})]})}function oM(e="200px"){const t=u.useRef(null),[n,s]=u.useState(()=>typeof IntersectionObserver>"u");return u.useEffect(()=>{if(n)return;const r=t.current;if(r===null)return;const i=new IntersectionObserver(l=>{l.some(c=>c.isIntersecting)&&(s(!0),i.disconnect())},{rootMargin:e});return i.observe(r),()=>i.disconnect()},[n,e]),{ref:t,inView:n}}const Br=/\[([^\]\n]*)\]\(<vessel-ref:([^>\n]*)>\)/g;function Nr(e){const t=e.split(/[\\/]/).filter(n=>n.length>0);return t[t.length-1]??e}const rM=new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif","ico"]),iM=new Set(["pdf","doc","docx","rtf","txt","md","csv","tsv","xls","xlsx","ppt","pptx","json","yaml","yml","html","xml"]);function aM(e){const t=Nr(e),n=t.lastIndexOf("."),s=n>0?t.slice(n+1).toLowerCase():"";return rM.has(s)?"image":iM.has(s)?"document":"file"}function lM(e){const t=Nr(e),n=t.lastIndexOf(".");return n>0&&t.slice(n+1).toLowerCase()==="pdf"}function dy(e){const t=[];Br.lastIndex=0;for(let n=Br.exec(e);n!==null;n=Br.exec(e)){const s=n[1]??"",r=n[2]??"";r.length!==0&&t.push({name:s.trim()||Nr(r),path:r})}return Br.lastIndex=0,t}function uy(e,t,n){const s=e.map(c=>({...c})),r=[],i=[];let l=0;for(const c of t){const d=c.kind==="image"&&n!==void 0?n[l++]:void 0,m=s.find(f=>f.ref===void 0&&f.path===c.path);if(m!==void 0){m.ref=c,d!==void 0&&(m.delivery=d);continue}r.push(c),d!==void 0&&i.push(d)}return{cards:s,refs:r,...n!==void 0?{imageDelivery:i}:{}}}function cM(e,t=!0){const n=e.ref?.kind??aM(e.path),s=e.ref!==void 0?bo(e.ref):e.name,r=it(T=>T.detailId)??void 0,i=n==="image"?e.ref?.sha256:void 0,l=SA(i,r,t),c=jA(e.path,t&&n==="image"&&i===void 0),[d,m]=u.useState(!1),f=is(a("chat.refCard.pathCopied")),p=u.useContext(vr)?.client,g=n!=="image"&&lM(e.path),[b,x]=u.useState(!1),[y,v]=u.useState(!1),j=i!==void 0?l.url:c.url,_=t&&(i!==void 0?l.status==="loading":c.status==="loading")||b,S=i===void 0&&c.status==="gone"||y,w=i===void 0&&c.staging===!0,k=e.delivery!==void 0?xv(e.delivery):void 0;return{kind:n,name:s,url:j,loading:_,expired:S,staging:w,deliveryText:k,isPdf:g,lightbox:d,closeLightbox:()=>m(!1),onClick:()=>{if(j!==void 0){m(!0);return}if(g&&p!==void 0&&!b&&!y){x(!0),jv(p,e.path).catch(T=>{T instanceof Error&&T.message.endsWith(": gone")?v(!0):f(e.path)}).finally(()=>{x(!1)});return}f(e.path)}}}function Pi({card:e,titleMeta:t}){const{ref:n,inView:s}=oM(),r=cM(e,s),{kind:i,name:l,url:c,loading:d,expired:m,staging:f,deliveryText:h,onClick:p}=r,g=t!==void 0&&t!==""?`${e.path}
|
|
586
|
+
${t}`:e.path;return o.jsxs("span",{ref:n,className:`inline-ref-chip${m?" is-expired":""}`,"data-kind":i,"data-path":e.path,children:[o.jsxs("button",{type:"button",className:"inline-ref-chip-body",title:g,"aria-label":c!==void 0?a("chat.toolImage.previewNamed",{name:l}):`${l} — ${a("chat.refCard.copyPath")}`,onClick:p,children:[c!==void 0?o.jsx("img",{className:"inline-ref-thumb",src:c,alt:"",loading:"lazy",decoding:"async"}):d?o.jsx("span",{className:"inline-ref-thumb inline-ref-thumb-loading animate-pulse","aria-busy":"true",children:o.jsx("span",{className:"sr-only",children:a("chat.toolImage.loading")})}):o.jsx("span",{className:"inline-ref-icon","aria-hidden":"true",children:o.jsx(qd,{kind:i,size:12})}),o.jsx("span",{className:"inline-ref-name",children:l}),m&&o.jsx("span",{className:"ref-card-badge is-expired",children:a("chat.refCard.expired")}),f&&o.jsx("span",{className:"ref-card-badge is-temp",children:a("chat.refCard.temporary")}),h!==void 0&&o.jsx("span",{className:wv(e.delivery),title:h,children:h})]}),r.lightbox&&c!==void 0&&o.jsx(vv,{url:c,name:l,onClose:r.closeLightbox,path:e.path,staging:f})]})}function dM({refs:e,imageDelivery:t,note:n,ts:s}){const r=e.filter(m=>m.kind==="image"),i=e.filter(m=>m.kind!=="image"),l=cn(s);let c=0;const d=Xi(r.map(m=>m.path));return o.jsxs(Yp,{className:"tool-image-card",ariaLabel:a("chat.toolImage.group"),children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-muted",children:[o.jsx(qd,{kind:"image",size:14}),a("chat.toolImage.title")]}),r.length>1&&o.jsx("span",{className:"font-mono text-2xs tabular-nums text-faint",children:a("chat.toolImage.count",{count:r.length})}),l!==""&&o.jsx("span",{className:"ml-auto font-mono text-2xs tabular-nums text-faint",children:l})]}),o.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:r.map((m,f)=>{const h=t!==void 0?t[c++]:void 0,p=x0(m.bytes);return o.jsx(Pi,{card:{name:bo(m),path:m.path,ref:m,...h!==void 0?{delivery:h}:{}},...p!==""?{titleMeta:p}:{}},d[f]??`${m.path}#${f}`)})}),i.length>0&&o.jsx(kv,{refs:i}),o.jsxs("details",{className:"tool-image-raw",children:[o.jsx("summary",{className:"cursor-pointer text-2xs text-faint",children:a("chat.toolImage.raw")}),o.jsx("pre",{className:"m-0 mt-1 whitespace-pre-wrap break-words font-mono text-2xs leading-relaxed text-faint",children:n})]})]})}const Xf="vessel-ref";function uM({segment:e}){const t=`${e.scheme}:${e.target}`,n=Qg(t);if(n===void 0)return o.jsx(o.Fragment,{children:e.token});const s=n.component;return o.jsx(s,{href:t,text:e.name,host:n.host})}function Vd({text:e,match:t}){const{atomicSchemes:n}=ga(),s=zT(),r=u.useMemo(()=>{const m=new Set([Xf]);for(const f of n)m.add(f.scheme);for(const f of s)m.add(f);return m},[n,s]),i=t?.cards??[],l=u.useMemo(()=>{const m=Yi(e,r),f=new Set;let h=0;return m.map(p=>{const g=`s${h}`;if(h+=p.type==="text"?p.text.length:p.token.length,p.type==="text")return o.jsx("span",{className:"whitespace-pre-wrap",children:p.text},g);if(p.scheme!==Xf)return o.jsx(uM,{segment:p},g);if(p.target.length===0)return o.jsx("span",{children:p.token},g);const b=i.findIndex((v,j)=>!f.has(j)&&v.path===p.target),x=b>=0?i[b]:void 0,y=x??{name:p.name.trim()||Nr(p.target),path:p.target};return x!==void 0&&f.add(b),o.jsx(Pi,{card:y},g)})},[e,r,i]),c=t?.refs??[],d=Xi(c.map(m=>m.path));return o.jsxs(o.Fragment,{children:[l,c.length>0&&o.jsx("span",{className:"inline-ref-tail",children:c.map((m,f)=>o.jsx(Pi,{card:{name:bo(m),path:m.path,ref:m,...t?.imageDelivery?.[f]!==void 0?{delivery:t.imageDelivery[f]}:{}}},d[f]??`${m.path}#${f}`))})]})}function dr({lifted:e,messageRole:t,render:n,streaming:s=!1,bodyClassName:r,wrapBody:i}){const{blocks:l,body:c,inline:d}=e,m=t==="user",f=m?c.length>0||(d?.refs.length??0)>0:c.length>0;let h=null;return f&&(h=m?o.jsx(Vd,{text:c,match:d}):o.jsx(jr,{className:r,text:c,streaming:s}),i!==void 0&&(h=i(h))),o.jsxs(o.Fragment,{children:[o.jsx(Yd,{blocks:l,render:n}),h]})}function mM({slot:e,tool:t,refCount:n,ts:s}){const r=cn(s),i=a("chat.toolMedia.count",{count:n}),l=r!==""?`${i} · ${r}`:i;return o.jsx(Jt,{className:"tool-result-card",title:t??a("chat.toolMedia.title"),meta:l,defaultOpen:!0,ariaLabel:a("chat.toolMedia.group"),children:o.jsx(dr,{lifted:e,messageRole:"user"})})}function Gd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fM(e){if(!Gd(e)||e.type!=="table")return null;const{columns:t,rows:n,caption:s}=e;if(!Array.isArray(t)||t.length===0||!t.every(r=>typeof r=="string")||!Array.isArray(n))return null;for(const r of n)if(!Array.isArray(r)||r.length!==t.length||!r.every(i=>typeof i=="string"))return null;return s!==void 0&&(typeof s!="string"||s.length===0)?null:{type:"table",...s!==void 0?{caption:s}:{},columns:t,rows:n}}function hM(e){if(!Gd(e)||e.type!=="code")return null;const{code:t,language:n}=e;return typeof t!="string"||t.length===0||n!==void 0&&(typeof n!="string"||n.length===0)?null:{type:"code",...n!==void 0?{language:n}:{},code:t}}function pM(e){const t=e.trim().split(`
|
|
587
|
+
`);if(t.length<3||t[0]!=="```vessel-block"||t[t.length-1]?.trim()!=="```")return null;for(let s=1;s<t.length-1;s+=1)if(t[s]?.trim()==="```")return null;let n;try{n=JSON.parse(t.slice(1,-1).join(`
|
|
588
|
+
`))}catch{return null}return Gd(n)&&n.type==="code"?hM(n):fM(n)}function gM(e){if(e.type==="code"){let n=0;for(const r of e.code.match(/`+/g)??[])r.length>n&&(n=r.length);const s="`".repeat(Math.max(3,n+1));return`${s}${e.language??""}
|
|
589
|
+
${e.code}
|
|
590
|
+
${s}`}const t=bg(e.columns,e.rows);return e.caption!==void 0?`**${e.caption}**
|
|
591
|
+
|
|
592
|
+
${t}`:t}function bM({payload:e,render:t}){return o.jsx(GA,{messageId:e.messageId,snippet:e.snippet,onJump:t.onJumpQuote,className:t.className})}function vM({payload:e,render:t}){return o.jsx(sM,{chips:e.chips,className:t.className})}function yM({payload:e}){return o.jsx(dM,{refs:e.refs,imageDelivery:e.imageDelivery,note:e.note,ts:e.ts})}function xM(e){return null}function wM({payload:e}){return o.jsx(fa,{env:e.env,ts:e.ts})}function kM({payload:e}){return o.jsx(mM,{slot:e.slot,tool:e.tool,refCount:e.refCount,ts:e.ts})}function SM({payload:e,render:t}){return o.jsx(jr,{text:gM(e),className:t.className})}const Is={quote:bM,"session-ref":vM,image:yM,"tool-media":kM,file:xM,notice:wM,"vessel-block":SM};function dc({block:e,render:t}){const n=pA(e.type);if(n===void 0)return null;const s=n.component;return o.jsx(s,{payload:e.payload,render:t??{}})}function Yd({blocks:e,render:t}){return o.jsx(o.Fragment,{children:e.map(n=>o.jsx(dc,{block:n,render:t},n.type))})}const Zf="vessel-ref:";function jM({href:e,text:t}){const n=e.startsWith(Zf)?e.slice(Zf.length):"";return n.length===0?o.jsx(o.Fragment,{children:t}):o.jsx(Pi,{card:{name:t.trim()||Nr(n),path:n}})}BT("vessel-ref",jM);const _M=120,uc="[引用消息";function NM(e){const t=e.replace(/\s+/g," ").trim();return Ol(t,_M)}function my(e,t){return t===void 0||t.snippet.length===0?e:`${t.messageId!==void 0&&t.messageId.length>0?`${uc} ${t.messageId}]`:`${uc}]`}
|
|
593
|
+
> ${t.snippet}
|
|
594
|
+
|
|
595
|
+
${e}`}function ba(e){if(!e.startsWith(uc))return null;const t=/^\[引用消息(?: ([^\]\n]{1,128}))?\]\n> ([^\n]+)\n\n/.exec(e);if(t===null)return null;const n=t[1],s=t[2];return s===void 0||s.length===0?null:{...n!==void 0?{messageId:n}:{},snippet:s,body:e.slice(t[0].length)}}function CM(e){const t=ba(e.content),n=NM(t!==null?t.body:e.content);if(n.length!==0)return{...e.message_id!==void 0&&e.message_id.length>0?{messageId:e.message_id}:{},snippet:n,source:e.role==="user"?"user":"assistant"}}function TM(e,t){const n=e.replace(/\s+/g," ").replace(/…$/,"").trim();if(n.length!==0)for(let s=t.length-1;s>=0;s-=1){const r=t[s];if(r===void 0||r.message_id===void 0)continue;const i=ba(r.content),l=i!==null?[i.body,r.content]:[r.content];for(const c of l)if(c.replace(/\s+/g," ").trim().startsWith(n))return r.message_id}}function EM(e,t){const n=ba(e);if(n===null)return null;if(n.messageId===void 0&&t!==void 0){const s=TM(n.snippet,t);if(s!==void 0)return{...n,messageId:s}}return n}function co(e,t={}){let n=e.content;const s=[];let r;for(const i of hA())for(const l of i.lift({message:e,body:n},t)){if(l.type==="file"){const c=l.payload;r={cards:c.cards??[],refs:c.refs,...c.imageDelivery!==void 0?{imageDelivery:c.imageDelivery}:{}};continue}s.push(l),l.body!==void 0&&(n=l.body)}return{blocks:s,body:n,...r!==void 0?{inline:r}:{}}}cs({type:"quote",surface:"light",order:10,owner:"host",component:Is.quote,compose:my,lift:({body:e},t)=>{const n=EM(e,t.messages);return n===null?[]:[{type:"quote",payload:n,body:n.body}]}});cs({type:"session-ref",surface:"card",order:20,owner:"host",component:Is["session-ref"],compose:Dv,lift:({body:e})=>{const t=n1(e);return t===null?[]:[{type:"session-ref",payload:t,body:t.body}]}});cs({type:"image",surface:"card",order:30,owner:"host",component:Is.image,lift:({message:e})=>{if(!e.content.startsWith(Eb))return[];const t=po(e);return t===void 0?[]:[{type:"image",payload:{refs:t,...e.image_delivery!==void 0?{imageDelivery:e.image_delivery}:{},note:e.content,...e.timestamp!==void 0?{ts:e.timestamp}:{}},body:""}]}});cs({type:"tool-media",surface:"card",order:35,owner:"host",component:Is["tool-media"],lift:({message:e})=>{if(!e.content.startsWith(Ib))return[];const t=po(e);if(t===void 0)return[];const n=e.content.indexOf(`
|
|
596
|
+
`),s=n>=0?e.content.slice(n+1):"",r=co({role:"user",content:s,refs:[...t],...e.image_delivery!==void 0?{image_delivery:[...e.image_delivery]}:{}}),i=FI(e.content);return[{type:"tool-media",payload:{slot:r,...i!==void 0?{tool:i}:{},refCount:t.length,...e.timestamp!==void 0?{ts:e.timestamp}:{}},body:""}]}});cs({type:"notice",surface:"card",order:40,owner:"host",component:Is.notice,lift:({message:e})=>{if(e.role!=="user")return[];const t=Dn(e);if(t===void 0)return[];const n=or(t,e.content);return n===void 0?[]:[{type:"notice",payload:{env:n,...e.timestamp!==void 0?{ts:e.timestamp}:{}},body:""}]}});cs({type:"file",surface:"card",order:50,owner:"host",component:Is.file,lift:({message:e,body:t})=>{if(e.role!=="user")return[];if(po(e)!==void 0)return[];const n=dy(t),s=e.refs??[];if(n.length===0&&s.length===0)return[];const r=uy(n,s,e.image_delivery);return[{type:"file",payload:{refs:r.refs,...r.imageDelivery!==void 0?{imageDelivery:r.imageDelivery}:{},...r.cards.length>0?{cards:r.cards}:{}}}]}});cs({type:"vessel-block",surface:"card",order:60,owner:"host",component:Is["vessel-block"],lift:({body:e})=>{const t=pM(e);return t===null?[]:[{type:"vessel-block",payload:t,body:""}]}});const rl=12;function Jd(e){return typeof e=="string"&&e.trim().length>0}function qi({text:e,streaming:t,entering:n=!1,time:s,actions:r,onCopyBody:i}){const[l,c]=u.useState(t),[d,m]=u.useState(!1),[f,h]=u.useState(!1),p=is(a("chat.reasoning.copied"));u.useEffect(()=>{d||c(t)},[t,d]);const g=tg(e,t),b=g.split(`
|
|
597
|
+
`),x=b.slice(0,rl).join(`
|
|
598
|
+
`),y=!f&&b.length>rl,v=Jd(e),j=cn(s),_=[];return v&&_.push(i!==void 0?{id:"copy",label:a("chat.message.copy"),onSelect:()=>p(e),menu:[{id:"copy-reasoning",label:a("chat.reasoning.copy"),onSelect:()=>p(e)},{id:"copy-body",label:a("chat.reasoning.copyBody"),onSelect:i}]}:{id:"copy",label:a("chat.reasoning.copy"),onSelect:()=>p(e)}),r!==void 0&&_.push(...r),o.jsxs("details",{className:`reasoning-block motion-disclosure${n?" motion-appear":""}`,open:l,onToggle:S=>{const w=S.currentTarget.open;w!==l&&(m(!0),c(w))},children:[o.jsxs("summary",{className:"group cursor-pointer select-none px-2.5 py-1.5 text-sm text-faint hover:text-muted",children:[a("chat.reasoning.summary"),t?o.jsxs("span",{className:"reasoning-live text-info",children:[" · ",a("chat.reasoning.thinking")]}):null,(_.length>0||j!=="")&&o.jsxs("span",{className:"reasoning-actions ml-1 inline-flex items-center gap-1 align-middle opacity-0 group-hover:opacity-100 group-has-[button:focus-visible]:opacity-100 pointer-coarse:opacity-100",onClick:S=>{S.preventDefault(),S.stopPropagation()},children:[_.length>0&&o.jsx(os,{actions:_}),j!==""&&o.jsx("time",{className:"font-mono text-2xs tabular-nums",dateTime:new Date(s??0).toISOString(),children:j})]})]}),o.jsxs("div",{className:"px-2.5 py-2 text-md leading-relaxed whitespace-pre-wrap wrap-anywhere",children:[y?x:g,t&&o.jsx("span",{className:"stream-caret pulse-soft","aria-hidden":"true"})]}),b.length>rl&&o.jsx(G,{variant:"link",className:"mx-2.5 mb-2 text-xs",onClick:()=>h(S=>!S),children:a(f?"chat.reasoning.collapse":"chat.reasoning.expand")})]})}function Go({label:e,value:t,defaultOpen:n=!1,tone:s,verbosity:r,copyLabel:i}){const l=u.useMemo(()=>yd(t),[t]),[c,d]=u.useState(n),[m,f]=u.useState(uf),h=u.useId();if(!l)return null;const p=fI(l),g=c?l.slice(0,m):p.preview,b=c&&l.length>m,x=p.truncated&&!c;return o.jsxs("section",{className:`tool-section ${s==="error"?"tool-section-error":""}`.trim(),children:[o.jsxs("div",{className:"tool-section-head",children:[o.jsxs("button",{type:"button",className:"tool-section-toggle","aria-expanded":c,"aria-controls":h,onClick:()=>d(y=>!y),children:[o.jsx("span",{"aria-hidden":"true",children:c?"▾":"▸"}),o.jsx("span",{className:"tool-section-label",children:e}),!c&&x&&o.jsx("span",{className:"tool-section-meta",children:a("chat.tool.previewLines",{shown:Math.min(p.totalLines,wb),total:p.totalLines})})]}),o.jsx(ls,{text:l,label:i??a("chat.tool.copy"),className:"tool-section-copy"})]}),o.jsx("pre",{className:`tool-section-body ${c?"":"tool-section-preview"}`.trim(),id:h,children:g}),b&&o.jsx(G,{variant:"link",className:"tool-section-more",onClick:()=>f(y=>y+uf),children:a("chat.tool.loadMore",{loaded:Math.round(m/1024),total:Math.round(l.length/1024)})}),!c&&p.truncated&&o.jsx(G,{variant:"link",className:"tool-section-more",onClick:()=>d(!0),children:a("chat.tool.showAll",{total:p.totalLines})}),r==="debug"&&o.jsxs("div",{className:"tool-section-debug font-mono tabular-nums",children:[p.totalLines," lines · ",p.totalBytes," bytes"]})]})}const IM=50,RM=15e3,LM=["tool.call.completed","tool.call.failed"],fy=u.createContext(null);function AM({client:e,sessionId:t,children:n}){const s=u.useMemo(()=>t===void 0||t.length===0?null:async({toolCallId:r,sinceSeq:i})=>{try{const l=await e.request("sessions.events",{session_id:t,since_seq:i,limit:IM,types:[...LM],tool_call_id:r},RM),c=[];for(const d of l?.events??[]){if(typeof d!="object"||d===null)continue;const m=d;typeof m.type=="string"&&c.push({type:m.type,...m.data!==void 0?{data:m.data}:{}})}return NI(c,r)}catch{return}},[e,t]);return o.jsx(fy.Provider,{value:s,children:n})}function MM(){return u.useContext(fy)??void 0}function PM({view:e}){const t=pI(e);if(t===null)return null;const n=[a(t.hintKey),...t.reasonKey!==void 0?[a(t.reasonKey)]:[]];return o.jsx("span",{className:`projection-badge${t.danger?" projection-badge-danger":""}`,title:n.join(" "),children:a(t.labelKey)})}function eh({view:e,toolName:t}){return o.jsx("dl",{className:"projection-meta font-mono tabular-nums",children:bI(e,t).map(n=>{const s=n.value===null?a("chat.projection.meta.unknown"):n.unit==="bytes"?a("chat.projection.bytes",{bytes:n.value}):n.value;return o.jsxs(u.Fragment,{children:[o.jsx("dt",{children:a(n.labelKey)}),o.jsx("dd",{children:s})]},n.labelKey)})})}function qM({view:e,toolName:t,original:n,verbosity:s,defaultOpen:r,summary:i,truncatedLimitBytes:l}){const[c,d]=u.useState(()=>SI(e)),[m,f]=u.useState({kind:"idle"}),h=MM(),p=u.useId();if(!gI(e))return null;const g=jb(e),b=m.kind==="loaded"?m.text:void 0,x=wI(l??xI),y=n!==void 0&&n.length>0?n:void 0,v=b??y,j=m.kind==="gone"||e.original_available==="gone"?a("chat.projection.gone"):void 0,_=()=>{if(g===void 0||h===void 0){f({kind:"gone"});return}f({kind:"loading"}),h(g).then(k=>{const N=CI(k);f(N.kind==="text"?{kind:"loaded",text:N.text}:{kind:"gone"})})},S=()=>{if(g===void 0||j!==void 0)return null;const k=kI(e);return k===void 0?null:o.jsx(G,{variant:"link",className:"projection-action",disabled:m.kind==="loading",onClick:_,children:a(k)})},w=()=>v!==void 0?o.jsxs(o.Fragment,{children:[o.jsx(Go,{label:a("chat.projection.original"),value:v,defaultOpen:r||b!==void 0,copyLabel:a("chat.projection.copyOriginal"),verbosity:s}),e.original_available==="inline_truncated"&&b===void 0&&o.jsx("p",{className:"projection-warn",children:e.original_bytes===null?a("chat.projection.truncatedWarnUnknown",{limit:x}):a("chat.projection.truncatedWarn",{limit:x,bytes:e.original_bytes})}),m.kind==="gone"&&o.jsx("p",{className:"projection-gone",children:a("chat.projection.gone")}),S()]}):j!==void 0?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"projection-gone",children:j}),o.jsx(eh,{view:e,toolName:t})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"projection-missing",children:a("chat.projection.notInMessage")}),o.jsx(eh,{view:e,toolName:t}),g===void 0?o.jsx("p",{className:"projection-note",children:a("chat.projection.readbackUnsupported")}):S()]});return o.jsxs("section",{className:"projection-panes",children:[o.jsx(Nn,{label:a("chat.projection.tabsLabel"),tabs:[{id:"original",label:a("chat.projection.tab.original")},{id:"model",label:a("chat.projection.tab.model")}],value:c,onChange:d,panelId:p,className:"mt-0"}),o.jsx("div",{className:"projection-panel",role:"tabpanel",id:p,"aria-labelledby":`${p}-tab-${c}`,children:c==="original"?w():o.jsx(Go,{label:a("chat.projection.modelView"),value:jI(e),defaultOpen:!1,copyLabel:a("chat.projection.copyModel"),verbosity:s})}),i!==void 0&&o.jsx(OM,{summary:i})]})}function OM({summary:e}){const t=EI(e);return o.jsxs("p",{className:"projection-summary font-mono tabular-nums",children:[a("chat.projection.summary.total",{total:e.total,saved:TI(e)}),t>0&&` ${a("chat.projection.summary.lowerBound",{count:t})}`]})}const hy=u.createContext(null);function DM({client:e,enabled:t,epoch:n,agentId:s,children:r}){const[i,l]=u.useState(()=>new Map);u.useEffect(()=>{if(!t)return;let d=!1;return(s!==void 0?e.listToolsForAgent(s):e.listTools()).then(m=>{d||l(new Map(m.filter(f=>f.name.length>0&&f.description.length>0).map(f=>[f.name,f.description])))}).catch(()=>{}),()=>{d=!0}},[e,t,n,s]);const c=u.useMemo(()=>i,[i]);return o.jsx(hy.Provider,{value:c,children:r})}function HM(e){return u.useContext(hy)?.get(e)}const $M={running:"●",done:"✓",error:"✗"},FM={running:"chat.tool.status.running",done:"chat.tool.status.done",error:"chat.tool.status.error"},BM={running:"tone-info",done:"tone-ok",error:"tone-danger"};function KM({lines:e,path:t}){return e.length===0?null:o.jsxs("section",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-head",children:o.jsxs("span",{className:"tool-section-label",children:[a("chat.tool.diff"),t?` · ${t}`:""]})}),o.jsx("pre",{className:"tool-section-body whitespace-pre wrap-normal",children:e.map((n,s)=>o.jsxs("span",{className:`block ${n.kind==="add"?"text-success":n.kind==="remove"?"text-danger":"text-faint"}`,children:[n.kind==="add"?"+":n.kind==="remove"?"-":" ",n.text,`
|
|
599
|
+
`]},s))})]})}function WM(e){const[t,n]=u.useState(()=>Date.now());return u.useEffect(()=>{if(!e)return;n(Date.now());const s=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(s)},[e]),t}function py({card:e,verbosity:t="normal",defaultOpen:n=!1,entering:s=!1,projectionSummary:r}){const i=HM(e.name),l=ma(),c=dI(e.name,e.args,xb,l),d=e.name==="edit"?uI(e.args):null,m=e.error!==void 0?yd(e.error):"",f=Do(e.errorMeta),h=e.projection,p=Sd(),g=e.name==="agent"?nI(e.args):void 0,b=e.name==="agent"?sI(e.result):void 0,x=b!==void 0?yb(b):void 0,y=kd(),v=S=>Ti({node:S},y,p!==void 0?{node:p}:void 0),j=WM(e.status==="running"),_=e.durationMs??(e.status==="running"?Math.max(0,j-e.startedAt):void 0);return o.jsxs(Jt,{className:"tool-card",defaultOpen:n,entering:s,title:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`tool-card-glyph ${BM[e.status]}`,role:"img","aria-label":a(FM[e.status]),children:$M[e.status]}),o.jsx("span",{className:"font-mono text-sm text-ink",children:e.name})]}),meta:_===void 0&&h===void 0?void 0:o.jsxs(o.Fragment,{children:[_!==void 0&&o.jsx("span",{className:"tabular-nums",children:_u(_)}),h!==void 0&&o.jsxs(o.Fragment,{children:[_!==void 0&&o.jsx("span",{"aria-hidden":"true",children:" · "}),o.jsx(PM,{view:h})]})]}),summary:c.length>0?c:void 0,actions:o.jsxs(o.Fragment,{children:[g!==void 0&&o.jsx("p",{className:"m-0 break-all px-2.5 pb-1 font-mono text-2xs leading-snug text-faint",title:g.raw,children:`→ ${v(g.node)} : ${g.team}`}),e.status==="error"&&m?o.jsx("p",{className:"m-0 line-clamp-3 whitespace-pre-wrap break-words px-2.5 pb-2 font-mono text-xs text-danger",children:m}):void 0]}),children:[h!==void 0&&o.jsx(qM,{view:h,toolName:e.name,original:vI(h,e.result),verbosity:t,defaultOpen:n,...e.truncatedLimitBytes!==void 0?{truncatedLimitBytes:e.truncatedLimitBytes}:{},...r!==void 0?{summary:r}:{}}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"font-mono text-xs uppercase tracking-wide text-faint",children:a("chat.tool.description")}),o.jsx("p",{className:"m-0 text-md leading-relaxed text-muted",children:i??a("chat.tool.descriptionUnavailable")})]}),g!==void 0&&o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"font-mono text-xs uppercase tracking-wide text-faint",children:a("chat.tool.route")}),o.jsx("p",{className:"m-0 break-all font-mono text-xs text-muted",children:g.raw}),o.jsx("p",{className:"m-0 text-xs text-faint",children:`${v(g.node)} · ${g.team} · ${ys(g.principal,l)??g.principal}`})]}),b!==void 0&&o.jsxs("p",{className:"m-0 break-all font-mono text-xs text-faint",children:[a("chat.tool.resolvedTo",{target:x!==void 0?ys(x.principal,l)??x.principal:ys(b,l)??b}),x!==void 0&&` · ${v(x.node)} : ${x.team}`]}),o.jsx(Go,{label:a("chat.tool.input"),value:e.args,defaultOpen:!0,verbosity:t}),yI(h)&&o.jsx(Go,{label:a("chat.tool.output"),value:e.result,verbosity:t}),d&&o.jsx(KM,{lines:d.lines,path:d.path}),o.jsx(Go,{label:a("chat.tool.error"),value:m||void 0,defaultOpen:e.status==="error",tone:"error",verbosity:t}),f&&o.jsxs("p",{className:"error-meta font-mono tabular-nums",children:[f,e.errorMeta?.retryable===!0?` · ${a("chat.tool.retryable")}`:""]}),e.errorMeta?.httpStatus!==void 0&&o.jsxs("p",{className:"error-meta font-mono tabular-nums",children:["HTTP ",e.errorMeta.httpStatus]}),e.truncated&&o.jsx("p",{className:"text-xs text-warn",children:a("chat.tool.truncated")}),t==="debug"&&o.jsxs("section",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-label",children:a("chat.tool.meta")}),o.jsxs("dl",{className:"tool-meta-list font-mono tabular-nums",children:[e.callId&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"call"}),o.jsx("dd",{children:e.callId})]}),o.jsx("dt",{children:"status"}),o.jsx("dd",{children:e.status}),o.jsx("dt",{children:"started"}),o.jsx("dd",{children:bt(e.startedAt)}),e.durationMs!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"duration"}),o.jsx("dd",{children:_u(e.durationMs)})]})]})]})]})}function UM(e){return Fn({domain:"runs",tab:"live",runId:e.runId,...e.sessionId?{sessionId:e.sessionId}:{}})}const zM=[];function ci({text:e,streaming:t=!1,actions:n,entering:s=!1,onJumpQuote:r}){const[i]=u.useState(()=>t?"stream":s?"enter":"none"),l=co({role:"assistant",content:e});return o.jsxs("div",{className:be("msg-assistant group relative max-w-full",i==="enter"&&"msg-enter",i==="stream"&&s&&"motion-appear",i==="stream"&&t&&"motion-stream"),children:[o.jsx(dr,{lifted:l,messageRole:"assistant",render:{onJumpQuote:r},streaming:t,bodyClassName:"msg-text"}),n]})}function gy(){return o.jsxs("div",{className:"run-waiting motion-appear text-muted",role:"status",children:[o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent pulse-soft","aria-hidden":"true"}),a("chat.reasoning.thinking")]})}function mc({text:e,ts:t,entering:n=!1,refs:s,onJumpQuote:r}){const i=cn(t),l=co({role:"user",content:e,...s!==void 0?{refs:[...s]}:{}});return o.jsxs("div",{className:be("msg-user group flex max-w-full flex-col items-end gap-1",n&&"msg-enter"),children:[o.jsx(dr,{lifted:l,messageRole:"user",render:{onJumpQuote:r},wrapBody:c=>o.jsx("div",{className:"msg-bubble",children:o.jsx(Wc,{children:c})})}),o.jsx(os,{className:"justify-end",actions:zM,meta:i===""?void 0:o.jsx("time",{dateTime:new Date(t??0).toISOString(),children:i})})]})}function by({failure:e,defaultOpen:t=!1}){const n=Do(e.errorMeta),s=b0(e.error),r=e.errorMeta?.candidates,i=r!==void 0&&r.length>0,l=e.error!==void 0&&e.error.trim().length>0?e.error:void 0,c=l!==void 0||s!==null||e.source==="session"||i,{config:d}=Qt(),m=nM(l),f=ib(hd(d.status==="success"?d.data:null)),h=c?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col items-start gap-1 pt-1",children:[o.jsx(Tt,{status:"failed",label:a("chat.run.failed")}),o.jsx("span",{className:"text-2xs text-muted font-mono tabular-nums",title:e.runId,children:a("chat.run.failure.run",{id:Ol(e.runId,12)})})]}),o.jsx("pre",{className:"run-error-body",children:m!==void 0&&m.key!==void 0?a(m.key):l??a("chat.run.noError")}),m?.key!==void 0&&f&&l!==void 0&&o.jsx("pre",{className:"run-error-body text-2xs text-muted",children:l}),s!==null&&o.jsx("p",{className:"run-error-hint",children:s}),i&&o.jsx("p",{className:"run-error-hint",children:a("agents.error.candidates",{list:r.join(", ")})}),e.source==="session"&&o.jsx("p",{className:"run-error-hint",children:a("chat.run.failure.fromRecord")})]}):void 0;return o.jsx(Jt,{className:"run-failure-card w-full min-w-0 max-w-full",tone:"danger",defaultOpen:t,ariaLabel:a("chat.run.failure.aria"),title:null,summary:l===void 0?a("chat.run.noError"):o.jsx("span",{className:"text-danger",children:Ol(l,240)}),actions:o.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-1",children:[n!==""&&o.jsxs("span",{className:"error-meta font-mono tabular-nums",children:[n,e.errorMeta?.retryable===!0?` · ${a("chat.run.retryable")}`:""]}),o.jsx("a",{className:"ml-auto inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-sm border border-line-strong bg-transparent px-2.5 py-1 text-sm tracking-wide text-ink no-underline transition-colors duration-150 tint-hover tint-press",href:UM(e),children:a("chat.run.detail")})]}),children:h})}function VM({context:e,defaultOpen:t=!1,entering:n=!1}){const s=LE(e.changed??[]),r=s.length>0,i=new Set(s.map(h=>h.key)),l=e.previousHash!==void 0&&e.previousHash!==e.hash&&!i.has("system_prompt")&&!i.has("self_card"),c=!r||l,d=c||i.has("system_prompt"),m=c||i.has("self_card"),f=r?s.map(h=>JM(h)):[e.model,e.messageCount!==void 0?a("chat.modelContext.messages",{count:e.messageCount}):void 0,e.toolsCount!==void 0?a("chat.modelContext.tools",{count:e.toolsCount}):void 0,e.estimatedTokens!==void 0?a("chat.modelContext.tokens",{count:th(e.estimatedTokens)}):void 0].filter(h=>h!==void 0&&h.length>0);return o.jsx(fa,{env:AE(r?f:[],[...d&&e.systemPrompt!==void 0?[{labelKey:"chat.modelContext.system",text:e.systemPrompt}]:[],...m&&e.selfCard!==void 0?[{labelKey:"chat.modelContext.selfCard",text:e.selfCard}]:[]]),ts:e.ts,defaultOpen:t,entering:n,meta:r?a("chat.env.changed.count",{count:s.length}):void 0,facts:r?void 0:f,footnote:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"shrink-0 tabular-nums",title:e.hash,children:a("chat.modelContext.hash",{hash:e.hash})}),e.previousHash!==void 0&&o.jsx("span",{className:"shrink-0 tabular-nums",title:e.previousHash,children:a("chat.env.changed.from",{hash:e.previousHash})}),e.contextMax!==void 0&&o.jsx("span",{className:"shrink-0 tabular-nums",children:a("chat.modelContext.contextMax",{count:th(e.contextMax)})})]})})}const GM={system_prompt:"chat.env.changed.systemPrompt",self_card:"chat.env.changed.selfCard",model:"chat.env.changed.model",tools:"chat.env.changed.tools"},YM={added:"chat.env.changed.added",removed:"chat.env.changed.removed",replaced:"chat.env.changed.replaced"};function JM(e){const t=GM[e.key],n=t!==void 0?a(t):e.key;if(e.value===void 0)return n;const s=YM[e.value],r=s!==void 0?a(s):e.value;return`${n}: ${r}`}function th(e){if(e<1e3)return String(Math.round(e));const t=e/1e3;return`${t>=100?Math.round(t):Math.round(t*10)/10}k`}const QM=u.memo(function({group:t,cancelled:n=!1,hideInput:s=!1,verbosity:r="normal",cardsDefaultOpen:i=!1,messageVisibility:l=Mo}){const c=is(),d=t.status==="cancelled"||t.status==="interrupted"||n&&t.status==="failed"?"cancelled":t.status,m=t.status==="running",f=!m&&d!=="cancelled",h=t.items.filter(E=>E.kind==="text").map(E=>E.text).join("").trim(),p=t.output!==void 0&&h.includes(t.output.trim()),g=t.status==="completed"?t.output:void 0,b=u.useMemo(()=>kb(t.items),[t.items]),x=t.status==="running",y=u.useMemo(()=>Y1(b,{verbosity:r,tools:l.tools,reasoning:l.reasoning}),[b,r,x,l.tools,l.reasoning]),v=u.useMemo(()=>G1(b,{verbosity:r,running:x,tools:l.tools}),[b,r,x,l.tools]),j=u.useMemo(()=>{for(let E=y.length-1;E>=0;E-=1){const I=y[E];if(I?.kind==="reasoning")return I.key}},[y]),_=u.useMemo(()=>{for(let E=y.length-1;E>=0;E-=1){const I=y[E];if(I?.kind==="text")return I.key}},[y]),S=t.status==="running"?t.liveText:void 0,w=t.status==="running"&&zd(r,l.reasoning)?t.liveReasoning:void 0,k=y.some(E=>E.kind==="text"||E.kind==="reasoning"||E.kind==="tool"),N=x&&!k&&!S&&!w&&v===void 0,T=la(t.inputName),R=d==="failed"?Nb(t):void 0;return o.jsxs(o.Fragment,{children:[t.input&&!s&&(T!==void 0?o.jsx(Vo,{sender:T.alias,senderKind:T.kind,content:t.input,ts:t.startedAt,defaultOpen:i}):o.jsx(mc,{text:t.input,ts:t.startedAt,refs:t.inputRefs})),y.map(E=>{if(E.kind==="reasoning")return o.jsx(qi,{text:E.text,streaming:t.status==="running"&&E.key===j,...E.startedAt!==void 0?{time:E.startedAt}:{}},E.key);if(E.kind==="text"){const I=E.key===_;return o.jsx(ci,{text:E.text,streaming:m,actions:f&&E.text.trim().length>0?o.jsx(os,{className:I?"mt-1":void 0,placement:I?"bottom":"side",actions:[{id:"copy",label:a("chat.message.copy"),onSelect:()=>c(E.text)}]}):void 0},E.key)}return E.kind==="tool"?o.jsx(py,{card:E,verbosity:r,defaultOpen:i},E.key):E.kind==="notice"?o.jsx(ly,{event:E.event,defaultOpen:i},E.key):o.jsx(cy,{event:E.event,defaultOpen:i},E.key)}),w&&o.jsx(qi,{text:w,streaming:!0}),S&&o.jsx(ci,{text:S,streaming:!0}),v&&o.jsxs("div",{className:"run-waiting text-muted",role:"status",children:[o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent pulse-soft","aria-hidden":"true"}),o.jsx("span",{className:"font-mono text-sm text-ink",children:v.name}),o.jsx("span",{"aria-hidden":"true",children:"·"}),a("chat.tool.status.running")]}),N&&o.jsx(gy,{}),g!==void 0&&!p&&o.jsx(ci,{text:g,actions:o.jsx(os,{className:"mt-1",actions:[{id:"copy",label:a("chat.message.copy"),onSelect:()=>c(g)}]})}),R!==void 0&&o.jsx(by,{failure:R,defaultOpen:i}),d==="cancelled"&&o.jsx("div",{className:"stream-notice cancelled",role:"status",children:o.jsx(Kb,{status:"cancelled"})})]})}),XM="bg-white/10 enabled:hover:bg-white/20";function ZM({item:e,onCancel:t,onEdit:n,onClaim:s,onUnhold:r,onRetry:i,label:l,identity:c,defaultOpen:d=!1,entering:m=!1,fullText:f,peekFailed:h=!1,onExpand:p}){const g="stream-card-queued-waiting",b=be(Od,Dd,XM),x=e.cancelling;let y=null;return(i!==void 0||t!==void 0||n!==void 0||s!==void 0||r!==void 0)&&(y=o.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5",children:[i!==void 0&&o.jsx(G,{variant:"plain",className:b,"aria-label":a("chat.pendingSend.retry"),title:a("chat.pendingSend.retry"),disabled:x,onClick:()=>i(e.id),children:o.jsx(yt,{name:"retry",size:14})}),n!==void 0&&o.jsx(G,{variant:"plain",className:b,"aria-label":a("chat.pending.edit"),title:a("chat.pending.edit"),disabled:x,onClick:()=>n(e.id),children:o.jsx(yt,{name:"edit",size:14})}),t!==void 0&&o.jsx(G,{variant:"plain",className:b,"aria-label":a(x?"chat.run.cancelling":"chat.run.cancelQueue"),title:a(x?"chat.run.cancelling":"chat.run.cancelQueue"),disabled:x,onClick:()=>t(e.id),children:o.jsx(yt,{name:"retract",size:14})}),s!==void 0&&o.jsx(G,{variant:"plain",className:b,"aria-label":a(x?"chat.pending.claimInFlight":"chat.pending.claim"),title:a(x?"chat.pending.claimInFlight":"chat.pending.claim"),disabled:x,onClick:()=>s(e.id),children:o.jsx(yt,{name:"check",size:14})}),r!==void 0&&o.jsx(G,{variant:"plain",className:b,"aria-label":a(x?"chat.pending.unholding":"chat.pending.unhold"),title:a(x?"chat.pending.unholding":"chat.pending.unhold"),disabled:x,onClick:()=>r(e.id),children:o.jsx(yt,{name:"archive",size:14})})]})),o.jsxs(Jt,{className:`notice-block stream-card-queued w-full min-w-0 max-w-full ${g}`.trim(),defaultOpen:d,entering:m,onOpenChange:p===void 0?void 0:v=>{v&&p()},title:l??null,summary:e.input,meta:c===void 0?void 0:o.jsxs("span",{className:"text-amber",children:[c,":"]}),children:[o.jsx("div",{className:"max-h-[240px] min-w-0 overflow-y-auto overscroll-contain",children:o.jsx("p",{className:"m-0 min-w-0 break-words whitespace-pre-wrap wrap-anywhere text-sm text-ink",children:f??e.input})}),h&&o.jsx("p",{className:"m-0 pt-1 font-mono text-2xs text-danger",children:a("chat.pending.peekFailed")}),y]})}function nh(e,t){return FE(e,{humanLabel:a("chat.pending.identity.human"),askLabel:a("chat.pending.identity.ask"),bashLabel:a("chat.pending.identity.bash"),systemLabel:a("chat.pending.identity.system"),agentLabel:n=>a("chat.pending.identity.agent",{name:n}),...t!==void 0?{fallbackName:t}:{}})}const eP=250;function tP(e){return{message_id:e.message_id,from:e.from,summary:e.summary,status:e.status,ts:e.ts,...e.from_name!==void 0?{from_name:e.from_name}:{},...e.async_job!==void 0?{async_job:e.async_job}:{}}}function il(e,t,n){return e.map(s=>s.message_id===t?{...s,status:n}:s)}function sh({item:e,identity:t,human:n,claimable:s=!1,label:r,onCancel:i,onEdit:l,onClaim:c,onUnhold:d,onRetry:m,fold:f,entering:h=!1,fullText:p,peekFailed:g,onExpand:b}){return o.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[o.jsx(ZM,{item:e,identity:t,entering:h,fullText:p,peekFailed:g,onExpand:b,onCancel:n?i:void 0,onEdit:n?l:void 0,onClaim:n||s?c:void 0,onUnhold:d,onRetry:n?m:void 0,...r!==void 0?{label:r}:{}}),f&&o.jsx("button",{type:"button",className:"bg-transparent self-start font-mono text-2xs text-faint hover:text-ink",onClick:f.onToggle,"aria-expanded":f.open,children:a("chat.pending.sameSource",{count:f.count})})]})}function nP(e){return e.messageId??`pending:${e.id}`}function sP(e,t){const n=nP(e),s=oy(e.text);return{entry:{message_id:n,from:ns,summary:s,status:"held",ts:e.createdAt},item:{id:n,input:e.text,submittedAt:e.createdAt,cancelling:t.has(n)},pending:e}}function oP(e){const t=a("chat.pendingSend.failed");return e.failure===void 0?t:e.failure==="queue_timeout"?`${t} · ${a("chat.pendingSend.queueTimeout")}`:e.failure==="defer_timeout"?`${t} · ${a("chat.pendingSend.deferTimeout")}`:e.failure==="timeout"?`${t} · ${a("chat.pendingSend.echoTimeout")}`:e.failure==="offline"?`${t} · ${a("chat.pendingSend.offline")}`:`${t} · ${e.failure}`}function rP(e){if(e.deferredReason!=="draining")return a("chat.pendingSend.deferred",{reason:iP(e.deferredReason)})}function iP(e){return a(e==="rotate"?"chat.pendingSend.deferred.rotate":e==="stopped"?"chat.pendingSend.deferred.stopped":"chat.pendingSend.deferred.other")}function aP(e,t){return e.entries.flatMap(n=>{const s=t.get(n.message_id);return s===void 0?[]:[s]})}function lP({sessionId:e,agentId:t,client:n,epoch:s,refreshKey:r,pendings:i=[],sentMessageIds:l=[],onRefillDraft:c,onRetryPending:d,onEditPending:m,onDismissPending:f,onReconcile:h,onAttachMessage:p,previewCount:g=pb}){const b=ot(),[x,y]=u.useState(null),[v,j]=u.useState(new Set),[_,S]=u.useState(0),[w,k]=u.useState(new Set),[N,T]=u.useState("default"),[R,E]=u.useState(new Map),[I,$]=u.useState(new Set),C=u.useRef(new Set),L=u.useCallback(async q=>{const M=Date.now();try{const H=await n.rpc("agents.inbox",{agent_id:q,include_held:!0}),X=Array.isArray(H?.entries)?H.entries:[];y({agentId:q,entries:X}),e!==null&&h?.({sessionId:e,presentIds:new Set(X.map(Y=>Y.message_id)),readStartedAt:M})}catch{}},[n,e,h]);u.useEffect(()=>{if(t===void 0){y(null);return}const q=window.setTimeout(()=>{L(t)},eP);return()=>window.clearTimeout(q)},[t,s,r,_,L]),u.useEffect(()=>{E(new Map),$(new Set),C.current.clear()},[t]);const A=t!==void 0&&x?.agentId===t?x:null,D=A?.entries??[],O=Uc(D,q=>q.message_id,t??null);u.useEffect(()=>{if(!(p===void 0||D.length===0))for(const q of i){if(q.messageId!==void 0)continue;const M=Jf(q,i,D);M!==void 0&&p(q.id,M)}},[D,i,p]);const F=u.useMemo(()=>{const q=Yf(i,D),M=new Set(l),H=D.filter(Y=>!q.has(Y.message_id)&&!M.has(Y.message_id)&&Y.async_job?.status!=="running").map(Y=>({entry:tP(Y),item:{id:Y.message_id,input:Y.summary,submittedAt:Y.ts,cancelling:v.has(Y.message_id)}})),X=i.filter(K1).map(Y=>sP(Y,v));return[...H,...X]},[D,i,l,v]),V=u.useMemo(()=>{const q=Yf(i,D),M=new Set(l);return D.filter(H=>H.async_job?.status==="running"&&!q.has(H.message_id)&&!M.has(H.message_id))},[D,i,l]);u.useEffect(()=>{const q=()=>{document.visibilityState==="visible"&&S(M=>M+1)};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[]),Lt(u.useCallback(()=>S(q=>q+1),[]));const B=u.useMemo(()=>zE(F.map(q=>q.entry),N==="expanded"?Number.MAX_SAFE_INTEGER:g),[F,N,g]),W=u.useMemo(()=>new Map(F.map(q=>[q.entry.message_id,q])),[F]),Z=q=>{k(M=>{const H=new Set(M);return H.has(q)?H.delete(q):H.add(q),H})},ee=u.useCallback(q=>{const M=A?.agentId;if(M===void 0)return;const H=D.find(Y=>Y.message_id===q);if(H===void 0)return;const X=R.get(q);X!==void 0&&X.summary===H.summary||C.current.has(q)||(C.current.add(q),(async()=>{try{const Y=await n.rpc("agents.inbox",{agent_id:M,message_ids:[q]}),re=(Array.isArray(Y?.entries)?Y.entries:[]).find(fe=>fe.message_id===q);if(typeof re?.text!="string")throw new Error("peek: no text");const _e=re.text;E(fe=>new Map(fe).set(q,{summary:H.summary,text:_e})),$(fe=>{if(!fe.has(q))return fe;const Pe=new Set(fe);return Pe.delete(q),Pe})}catch{$(Y=>new Set(Y).add(q))}finally{C.current.delete(q)}})())},[n,A?.agentId,D,R]),ie=q=>{if(q.pending!==void 0)return{};const M=R.get(q.entry.message_id);return{fullText:M!==void 0&&M.summary===q.entry.summary?M.text:void 0,peekFailed:I.has(q.entry.message_id),onExpand:()=>ee(q.entry.message_id)}},le=u.useCallback(async q=>{const M=A?.agentId;if(M!==void 0){j(H=>new Set(H).add(q));try{const H=await n.rpc("agents.recall",{agent_id:M,message_ids:[q]});(Array.isArray(H?.deleted)?H.deleted:[]).includes(q)?(y(Y=>Y===null?Y:{...Y,entries:Y.entries.filter(re=>re.message_id!==q)}),b.success(a("chat.toast.queueCancelled")),S(Y=>Y+1)):(b.error(a("chat.toast.cancelNotAccepted")),S(Y=>Y+1))}catch(H){b.error(zt(H)),S(X=>X+1)}finally{j(H=>{const X=new Set(H);return X.delete(q),X})}}},[n,A?.agentId,b]),J=u.useCallback(async q=>{const M=A?.agentId;if(M!==void 0){j(H=>new Set(H).add(q)),y(H=>H===null?H:{...H,entries:il(H.entries,q,"unread")});try{const H=await n.rpc("agents.recall",{agent_id:M,message_ids:[q]});(Array.isArray(H?.deleted)?H.deleted:[]).includes(q)?(b.success(a("chat.pending.unheld")),S(Y=>Y+1)):(y(Y=>Y===null?Y:{...Y,entries:il(Y.entries,q,"held")}),b.error(a("chat.pending.unholdRejected")),S(Y=>Y+1))}catch(H){y(X=>X===null?X:{...X,entries:il(X.entries,q,"held")}),b.error(a("chat.pending.unholdFailed",{detail:zt(H)})),S(X=>X+1)}finally{j(H=>{const X=new Set(H);return X.delete(q),X})}}},[n,A?.agentId,b]),z=u.useCallback(async q=>{const M=A?.agentId,H=e;if(M===void 0||H===null||c===void 0)return;j(Y=>new Set(Y).add(q));let X=!1;try{const Y=await n.rpc("agents.inbox",{agent_id:M,message_ids:[q]}),re=(Array.isArray(Y?.entries)?Y.entries:[]).find(ke=>ke.message_id===q),_e=re?.text;if(typeof _e!="string"||re?.from!==ns||re?.session_id!==H){b.error(a("chat.pending.editPeekFailed")),S(ke=>ke+1);return}_e.length>0&&(c(_e),X=!0);const fe=await n.rpc("agents.recall",{agent_id:M,message_ids:[q]});(Array.isArray(fe?.deleted)?fe.deleted:[]).includes(q)?(y(ke=>ke===null?ke:{...ke,entries:ke.entries.filter(Ge=>Ge.message_id!==q)}),b.success(a("chat.pending.editTaken")),S(ke=>ke+1)):(b.error(a("chat.pending.editRecallRejected")),S(ke=>ke+1))}catch(Y){b.error(X?a("chat.pending.editRecallFailed",{detail:zt(Y)}):zt(Y)),S(re=>re+1)}finally{j(Y=>{const re=new Set(Y);return re.delete(q),re})}},[n,A?.agentId,e,c,b]),me=u.useCallback(async q=>{const M=A?.agentId;if(M!==void 0){j(H=>new Set(H).add(q));try{const H=await n.rpc("agents.claim",{agent_id:M,message_ids:[q]});if((Array.isArray(H?.claimed)?H.claimed:[]).includes(q))y(Y=>Y===null?Y:{...Y,entries:Y.entries.filter(re=>re.message_id!==q)}),b.success(a("chat.pending.claimTaken")),S(Y=>Y+1);else{const re=(H?.skipped??[]).find(_e=>_e.message_id===q)?.reason==="consumed"?a("chat.pending.claimSkipped.consumed"):a("chat.pending.claimSkipped.notFound");b.error(a("chat.pending.claimSkipped",{reason:re})),S(_e=>_e+1)}}catch(H){b.error(zt(H)),S(X=>X+1)}finally{j(H=>{const X=new Set(H);return X.delete(q),X})}}},[n,A?.agentId,b]),K=u.useCallback(async q=>{const M=A?.agentId;if(M===void 0)return b.error(a("chat.pendingSend.recallUnknown")),!1;try{const H=await n.rpc("agents.recall",{agent_id:M,message_ids:[q]});return(Array.isArray(H?.deleted)?H.deleted:[]).includes(q)?(y(Y=>Y===null?Y:{...Y,entries:Y.entries.filter(re=>re.message_id!==q)}),S(Y=>Y+1),!0):(b.error(a("chat.pendingSend.recallRejected")),S(Y=>Y+1),!1)}catch(H){return b.error(zt(H)),S(X=>X+1),!1}},[n,A?.agentId,b]),ne=q=>W.get(q)?.pending,Ne=q=>q.messageId??Jf(q,i,D),ce=q=>{q!==void 0&&f?.(q)};if(B.total===0&&V.length===0)return null;const se=a("chat.pending.title",{count:B.total+V.length}),we=q=>{const M=ne(q);if(M===void 0){le(q);return}const H=Ne(M);if(H===void 0){ce(M);return}le(H).then(()=>ce(M))},he=q=>{const M=ne(q);if(M===void 0){z(q);return}(async()=>{const H=Ne(M);if(!(H!==void 0&&!await K(H))){if(m!==void 0){m(M);return}c?.(M.text),ce(M)}})()},pe=q=>{const M=ne(q);M!==void 0&&(async()=>{const H=Ne(M);H!==void 0&&!await K(H)||d?.(M)})()},Me=q=>{const M=ne(q);if(M===void 0){me(q);return}const H=Ne(M);H!==void 0&&me(H).then(()=>ce(M))},oe=q=>{J(q)},je=q=>q.pending?.state==="failed"?oP(q.pending):q.pending?.state==="deferred"?rP(q.pending):void 0,Ee=q=>q.pending?.state==="failed"?pe:void 0,Ce=q=>q.pending===void 0||Ne(q.pending)!==void 0?Me:void 0,U=q=>q.pending!==void 0||c!==void 0?he:void 0;return o.jsx("section",{className:"flex-none pb-2","aria-label":se,children:o.jsx("div",{className:"px-[var(--content-pad-inline)]",children:o.jsxs("div",{className:"mx-auto flex max-w-[var(--chat-content-w,860px)] flex-col",children:[o.jsxs("button",{type:"button",className:"bg-transparent m-0 flex items-center gap-1 self-start font-mono text-2xs tracking-wide text-faint hover:text-ink",onClick:()=>{N==="collapsed"&&S(q=>q+1),T(q=>q==="collapsed"?"default":"collapsed")},"aria-expanded":N!=="collapsed",children:[o.jsx(yt,{name:"chevron",className:`event-toggle-icon h-3 w-3 ${N==="collapsed"?"":"rotate-90"}`}),se]}),o.jsx("div",{className:"motion-collapse","data-motion-open":N!=="collapsed",inert:N==="collapsed"?!0:void 0,children:o.jsxs("div",{children:[o.jsx("div",{className:"pt-1.5",children:o.jsx("div",{className:N==="expanded"?"max-h-[40vh] overflow-y-auto":void 0,children:o.jsx("ul",{className:"m-0 flex list-none flex-col gap-1.5 p-0",children:B.preview.map(q=>{const[M,...H]=aP(q,W);if(M===void 0)return null;const X=q.entries.length>1,Y=X&&w.has(q.key),re=X?{count:q.entries.length,open:Y,onToggle:()=>Z(q.key)}:void 0,_e=BE(q);return o.jsxs("li",{className:"flex flex-col gap-1.5",children:[o.jsx(sh,{item:M.item,identity:nh(M.entry,_e),entering:O(M.entry.message_id),...ie(M),human:M.entry.from===ns,claimable:M.entry.async_job!==void 0,...je(M)!==void 0?{label:je(M)}:{},onCancel:we,onEdit:U(M),onClaim:Ce(M),onUnhold:M.pending===void 0&&nf(M.entry)?oe:void 0,onRetry:Ee(M),fold:re}),Y&&o.jsx("ul",{className:"m-0 flex list-none flex-col gap-1.5 border-l border-line pl-2",children:H.map(fe=>o.jsx("li",{children:o.jsx(sh,{item:fe.item,identity:nh(fe.entry,_e),entering:O(fe.entry.message_id),...ie(fe),human:fe.entry.from===ns,claimable:fe.entry.async_job!==void 0,...je(fe)!==void 0?{label:je(fe)}:{},onCancel:we,onEdit:U(fe),onClaim:Ce(fe),onUnhold:fe.pending===void 0&&nf(fe.entry)?oe:void 0,onRetry:Ee(fe)})},fe.entry.message_id))})]},q.key)})})})}),V.length>0&&o.jsx("div",{className:"mt-1.5 flex flex-col gap-1.5",children:V.map(q=>o.jsx(H1,{entry:q},q.message_id))})]})}),N==="default"&&B.hidden>0&&o.jsx("button",{type:"button",className:"bg-transparent m-0 mt-1.5 self-start font-mono text-2xs text-faint hover:text-ink",onClick:()=>T("expanded"),children:a("chat.pending.expandAll",{count:B.hidden})}),N==="expanded"&&o.jsx("button",{type:"button",className:"bg-transparent m-0 mt-1.5 self-start font-mono text-2xs text-faint hover:text-ink",onClick:()=>T("default"),children:a("chat.pending.collapseList")})]})})})}const cP={enabled:!0,rootHue:172.6,hueStep:137.508,lightnessLight:.4714,chromaLight:.0887,lightnessDark:.85,chromaDark:.13},dP={rootHue:{min:0,max:360,maxExclusive:!0},hueStep:{min:0,max:360},lightnessLight:{min:.3,max:.51},chromaLight:{min:0,max:.37},lightnessDark:{min:.73,max:.95},chromaDark:{min:0,max:.37}};function Bs(e,t){const n=cP[t],s=as(e,`ui.depthColor.${t}`);if(s==="")return n;const r=Number(s),i=dP[t],l=i.maxExclusive===!0?r<i.max:r<=i.max;return!Number.isFinite(r)||r<i.min||!l?n:r}function vy(e){return{enabled:as(e,"ui.depthColor.enabled")!=="false",rootHue:Bs(e,"rootHue"),hueStep:Bs(e,"hueStep"),lightnessLight:Bs(e,"lightnessLight"),chromaLight:Bs(e,"chromaLight"),lightnessDark:Bs(e,"lightnessDark"),chromaDark:Bs(e,"chromaDark")}}function uP(e,t){const n=((t.rootHue+e*t.hueStep)%360+360)%360;return Math.round(n*1e3)/1e3}function mP(){const e=wt(s=>Se(s.config)),t=vy(e),n=s=>!t.enabled||s===void 0||!Number.isFinite(s)||s<0?void 0:uP(s,t);return{enabled:t.enabled,params:t,hueOf:n}}function yy(e,t=document.documentElement){const n=vy(e);t.style.setProperty("--depth-l-light",String(n.lightnessLight)),t.style.setProperty("--depth-c-light",String(n.chromaLight)),t.style.setProperty("--depth-l-dark",String(n.lightnessDark)),t.style.setProperty("--depth-c-dark",String(n.chromaDark))}function fP(e){const t=new Map;for(const n of e)if(!(!n.node.current||!n.node.name))for(const s of n.rosters){const r=s.team.team_id;if(r)for(const i of s.members)i.role==="member"&&(!i.session_id||!i.name||t.set(i.session_id,`${i.name}@${n.node.name}:${r}`))}return t}function hP({sessions:e,hiddenCount:t,listReset:n,selectedId:s,draftActive:r,pendingBySession:i,pendingAskCount:l,onOpenPending:c,agentAddresses:d,agentAddressesById:m,agentDepths:f,agentRoles:h,agentLabels:p,agentRetiredLabels:g,defaultSession:b,primarySessionIds:x,query:y,onQueryChange:v,searchSnippets:j,loading:_,error:S,onRetry:w,hasToken:k,onSelect:N,onNew:T,onRename:R,onDelete:E,onViewRuns:I,onShowMore:$,compact:C,onCloseDrawer:L,onOpenConnection:A,writesDisabled:D,renameSignal:O}){He();const F=ot(),{hueOf:V}=mP(),[B,W]=u.useState(null),[Z,ee]=u.useState(""),[ie,le]=u.useState(null),J=u.useRef(!1),z=u.useRef(null),me=b!==void 0&&!y.trim(),K=Uc(e,he=>he.session_id,n);u.useEffect(()=>{B&&(z.current?.focus(),z.current?.select())},[B]);const ne=he=>{W(he.session_id),ee(Sn(he)),le(null)},Ne=u.useRef(0);u.useEffect(()=>{if(O===Ne.current||(Ne.current=O,D||!s))return;const he=e.find(pe=>pe.session_id===s);he&&(W(he.session_id),ee(Sn(he)),le(null))},[O,e,s,D]);const ce=()=>{W(null),ee(""),le(null)},se=async he=>{if(J.current)return;const pe=C0(Z);if(!pe){le(a("chat.sessionList.renameEmpty"));return}J.current=!0;const Me=await R(he,pe);J.current=!1,Me?ce():le(a("chat.sessionList.renameFailed"))},we=he=>{if(!navigator.clipboard?.writeText){F.error(a("common.clipboardUnsupported"));return}navigator.clipboard.writeText(he).then(()=>F.success(a("chat.session.copiedId"))).catch(pe=>F.error(pe instanceof Error?pe.message:String(pe)))};return o.jsxs(eg,{as:"div",title:a("chat.sessionList.title"),actions:o.jsxs(o.Fragment,{children:[l!==void 0&&l>0&&c!==void 0&&o.jsxs(G,{type:"button",size:"small",onClick:c,"aria-label":a("pending.entry.label",{count:l}),children:[a("pending.entry"),o.jsx(Hn,{count:l})]}),o.jsx(G,{type:"button",size:"small",variant:"primary",onClick:T,children:a("chat.sessionList.new")}),C&&o.jsx(Cn,{label:a("nav.closeSessions"),onClick:L,children:"×"})]}),controls:o.jsx(Tn,{value:y,onChange:v,placeholder:a("chat.sessionList.search"),ariaLabel:a("chat.sessionList.search")}),children:[S&&e.length>0&&o.jsx(st,{message:a("common.staleData",{detail:S}),onRetry:w}),S&&e.length===0?o.jsx(Ve,{message:S,onRetry:w}):k?_&&e.length===0?o.jsx(Ke,{label:a("chat.sessionList.loading")}):e.length===0&&!me?y.trim()?o.jsx($e,{title:a("chat.sessionList.noMatch",{query:y.trim()}),action:o.jsx(G,{type:"button",onClick:()=>v(""),children:a("common.clearSearch")})}):o.jsx($e,{title:a("chat.sessionList.empty"),action:o.jsx(G,{type:"button",variant:"primary",onClick:T,children:a("common.newSession")})}):o.jsxs(o.Fragment,{children:[me&&b&&o.jsx("div",{className:`session-row default ${b.sessionId===s?"active":""}`.trim(),children:o.jsxs("button",{type:"button",className:"session-main","aria-current":b.sessionId===s?"true":void 0,onClick:()=>N(b.sessionId),children:[o.jsx("span",{className:"session-title",children:o.jsx("span",{className:"session-title-text",children:b.label})}),o.jsx("span",{className:"session-agent",children:b.bodyCount>1?a("team.member.liveBodies",{count:b.bodyCount}):a("team.member.currentBody")})]})}),r&&o.jsx("div",{className:"session-row draft active motion-appear",children:o.jsxs("div",{className:"session-main",children:[o.jsx("span",{className:"session-title",children:a("chat.draft.title")}),o.jsx("span",{className:"session-preview",children:a("chat.draft.meta")})]})}),E0(e).map(he=>o.jsxs(u.Fragment,{children:[he.label&&o.jsx("div",{className:"sidebar-group-label",children:he.label}),he.sessions.map(pe=>{const Me=pe.session_id===s,oe=B===pe.session_id,je=Sn(pe),Ee=i?.get(pe.session_id)??0,Ce=d?.get(pe.session_id),U=pe.agent,q=U?.name?.trim(),M=Ce||q?void 0:p?.get(pe.session_id),H=U===void 0?void 0:m?.get(U.id),X=H===void 0?a("team.member.primaryBadge"):`${H.node}:${H.team??a("team.member.primaryBadge")}`,Y=Ce||q===void 0?void 0:`${q}@${X}`,re=U?.primary===!0,_e=Ce||Y||M?void 0:g?.get(pe.session_id),fe=!Ce&&!Y&&!M&&!_e&&x?.has(pe.session_id)===!0,Pe=pe.agent?.depth??f?.get(pe.session_id),ke=V(Pe),Ge=ke===void 0?{}:{"data-depth":Pe,style:{"--depth-h":String(ke)}},mt=Pe!==void 0&&Pe>0?{paddingLeft:`calc(min(${Pe}, 4) * var(--session-depth-step))`}:void 0,de=(pe.agent?.role??h?.get(pe.session_id))==="temporary"?{"data-role":"temporary"}:{},Oe=(y.trim()?j?.get(pe.session_id):void 0)??(pe.preview&&pe.preview!==pe.title?pe.preview:""),ue=Oe?`${je} — ${Oe}`:je;return o.jsx("div",{className:`session-row group ${Me?"active":""} ${K(pe.session_id)?"motion-appear":""}`.trim(),style:mt,draggable:!oe,onDragStart:xe=>{const De=QA(pe,m,d);xe.dataTransfer.setData(ac,JSON.stringify(De));const Je=Ov(De);xe.dataTransfer.setData("text/plain",Je!==void 0?`${De.title} (${Je})`:De.title),xe.dataTransfer.effectAllowed="copy"},children:oe?o.jsxs("div",{className:"session-rename",children:[o.jsx(Xe,{ref:z,value:Z,"aria-label":a("chat.sessionList.idLabel"),onFocus:xe=>xe.currentTarget.select(),onChange:xe=>{ee(xe.target.value),le(null)},onKeyDown:xe=>{xe.key==="Enter"?(xe.preventDefault(),se(pe.session_id)):xe.key==="Escape"&&(xe.preventDefault(),ce())},onBlur:()=>{se(pe.session_id)}}),ie&&o.jsx("span",{className:"text-xs text-danger leading-snug",role:"alert",children:ie})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"session-main","aria-current":Me?"true":void 0,onClick:()=>N(pe.session_id),children:[o.jsxs("span",{className:"session-title",children:[o.jsx(Kb,{status:pe.status}),o.jsx(xt,{label:ue,children:o.jsx("span",{className:"session-title-text",children:je})}),pe.title_source==="manual"&&o.jsx(xt,{label:a("chat.sessionList.named"),children:o.jsx("span",{className:"flex-none text-muted",role:"img","aria-label":a("chat.sessionList.named"),children:o.jsx(yt,{name:"edit",size:12})})}),Ee>0&&o.jsx(xt,{label:a("chat.session.pending",{count:Ee}),children:o.jsxs("span",{className:"session-pending-badge",children:[o.jsx("span",{"aria-hidden":"true",children:Ee}),o.jsx("span",{className:"sr-only",children:a("chat.session.pending",{count:Ee})})]})})]}),Ce&&o.jsx("span",{className:"session-agent session-agent-address",...Ge,...de,children:Ce}),Y&&o.jsx("span",{className:re?"session-agent session-agent-address":"session-agent session-agent-primary",...re?{...Ge,...de}:{},children:Y}),M&&o.jsx("span",{className:"session-agent session-agent-address",...Ge,...de,children:M}),_e&&o.jsx("span",{className:"session-agent session-agent-primary",children:_e}),fe&&o.jsx("span",{className:"session-agent session-agent-primary",children:a("team.member.primaryBadge")})]}),o.jsx(Gi,{className:"items-center pr-1 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 max-compact:opacity-100",label:a("chat.sessionList.actions",{title:je}),items:[{id:"rename",label:a("chat.sessionList.rename"),disabled:D,onSelect:()=>ne(pe)},{id:"copy",label:a("chat.session.copyId"),onSelect:()=>we(pe.session_id)},{id:"runs",label:a("chat.sessionList.viewRuns"),onSelect:()=>I(pe.session_id)},{id:"delete",label:a("chat.sessionList.delete"),danger:!0,disabled:D,onSelect:()=>E(pe)}]})]})},pe.session_id)})]},he.key||"unknown")),t>0&&o.jsx("button",{type:"button",className:"load-more",onClick:$,children:a("chat.sessionList.showMore",{count:t})})]}):o.jsx($e,{title:a("chat.sessionList.noConnection"),action:o.jsx(G,{type:"button",onClick:A,children:a("common.configureConnection")})})]})}const pP=u.memo(function({sessions:t,hiddenCount:n,listReset:s,selectedId:r,draftActive:i,pendingBySession:l,inflightBySession:c,pendingAskCount:d,onOpenPending:m,agentAddresses:f,agentAddressesById:h,agentDepths:p,agentRoles:g,agentLabels:b,agentRetiredLabels:x,defaultSession:y,primarySessionIds:v,query:j,onQueryChange:_,searchSnippets:S,loading:w,error:k,onRetry:N,hasToken:T,onSelect:R,onNew:E,onRename:I,onDelete:$,onViewRuns:C,onShowMore:L,compact:A,onCloseDrawer:D,onOpenConnection:O,writesDisabled:F,renameSignal:V,sessionsOpen:B,drawerRef:W,panes:Z}){const ee=A?{role:"dialog","aria-modal":B}:{};return o.jsxs(o.Fragment,{children:[o.jsxs("aside",{...ee,ref:W,id:"chat-sessions",className:`chat-session-column ${B?"open":""}`.trim(),"aria-label":a("chat.main.sessionsLabel"),inert:A&&!B?!0:void 0,"aria-hidden":A&&!B?!0:void 0,children:[o.jsx(hP,{sessions:t,hiddenCount:n,listReset:s,selectedId:r,draftActive:i,pendingBySession:l,inflightBySession:c,...d!==void 0?{pendingAskCount:d}:{},...m!==void 0?{onOpenPending:m}:{},agentAddresses:f,agentAddressesById:h,agentDepths:p,agentRoles:g,agentLabels:b,agentRetiredLabels:x,defaultSession:y,primarySessionIds:v,query:j,onQueryChange:_,searchSnippets:S,loading:w,error:k,onRetry:N,hasToken:T,onSelect:R,onNew:E,onRename:I,onDelete:$,onViewRuns:C,onShowMore:L,compact:A,onCloseDrawer:D,onOpenConnection:O,writesDisabled:F,renameSignal:V}),!Z.disabled("sessions")&&o.jsx(kr,{pane:"sessions",api:Z,label:a("resize.sessions"),className:"resize-handle resize-handle-sessions"})]}),A&&B&&o.jsx("button",{type:"button",className:"drawer-backdrop","aria-label":a("nav.closeSessions"),onClick:D})]})});function gP(e){if(e.requestId===void 0)return;const t=`#${e.requestId.slice(0,8)}`;return e.extraRequestIds!==void 0?`${t} +${e.extraRequestIds}`:t}function oh({card:e,ts:t,defaultOpen:n=!1,titleLabel:s,sourceLabel:r,ariaLabel:i}){const l=cn(t);return o.jsxs(Jt,{className:"ask-answer-card w-full min-w-0 max-w-full",ariaLabel:i??a("chat.askAnswer.aria"),defaultOpen:n,title:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono text-2xs tracking-wider text-accent",children:s??a("chat.askAnswer.title")}),o.jsx("span",{className:"max-w-56 truncate text-sm text-ink",children:e.summary})]}),meta:gP(e),summary:e.rows[0]?.text,children:[(l!==""||e.requestId!==void 0)&&o.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline gap-x-2 font-mono text-2xs text-faint",children:[o.jsx("span",{className:"shrink-0",children:r??a("chat.askAnswer.source")}),e.requestId!==void 0&&o.jsx("span",{className:"break-all select-all",children:e.requestId}),l!==""&&o.jsx("time",{className:"shrink-0 tabular-nums",dateTime:new Date(t??0).toISOString(),children:l})]}),o.jsx("ul",{className:"m-0 flex min-w-0 list-none flex-col gap-1.5 p-0",children:e.rows.map(c=>o.jsx("li",{className:"min-w-0 break-words text-sm leading-relaxed text-ink",children:c.question===void 0?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mr-1.5 font-mono text-2xs tracking-wider text-accent-ink",children:c.label}),o.jsx("span",{className:"whitespace-pre-wrap wrap-anywhere",children:c.text})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-0.5 flex min-w-0 flex-wrap items-baseline gap-x-2",children:[o.jsx("span",{className:"font-mono text-2xs tracking-wider text-accent-ink",children:c.label}),o.jsx("span",{className:"min-w-0 text-2xs break-words text-muted",children:c.question})]}),o.jsx("div",{className:"whitespace-pre-wrap wrap-anywhere",children:c.text})]})},`${c.label}\0${c.question??""}\0${c.text}`))})]})}function bP(){return o.jsx("div",{className:"chat-welcome",children:o.jsxs("div",{className:"chat-welcome-inner",children:[o.jsx("p",{className:"chat-welcome-brand",children:a("chat.welcome.brand")}),o.jsx("p",{className:"chat-welcome-question",children:a("chat.welcome.question")})]})})}function vP({pending:e,onRetry:t,onDismiss:n,onJumpQuote:s}){const r=e.state==="failed",i=e.failure===void 0||e.failure==="timeout"||e.failure==="queue_timeout"||e.failure==="defer_timeout"||e.failure==="offline"?void 0:e.failure,l=e.state==="queued"||e.state==="deferred"?Math.floor((Date.now()-e.createdAt)/6e4):0,{blocks:c,body:d,inline:m}=co({role:"user",content:e.text,...e.refs!==void 0?{refs:[...e.refs]}:{}});return o.jsxs("div",{className:"msg-user msg-pending msg-enter",children:[o.jsx(Yd,{blocks:c,render:{onJumpQuote:s}}),(d.length>0||(m?.refs.length??0)>0)&&o.jsx("div",{className:"msg-bubble msg-pending-bubble",children:o.jsx(Vd,{text:d,match:m})}),o.jsx("div",{className:"msg-pending-meta",children:r?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"msg-pending-status is-failed",children:a("chat.pendingSend.failed")}),i!==void 0&&o.jsx("span",{className:"msg-pending-reason",title:i,children:i}),t!==void 0&&o.jsx("button",{type:"button",className:"msg-pending-action",onClick:()=>t(e),children:a("chat.pendingSend.retry")}),n!==void 0&&o.jsx("button",{type:"button",className:"msg-pending-action",onClick:()=>n(e),children:a("chat.pendingSend.dismiss")})]}):o.jsx("span",{className:"msg-pending-status",role:"status",children:e.state==="queued"||e.state==="deferred"?yP(e,l):a("chat.pendingSend.sending")})})]})}function yP(e,t){if(e.state==="deferred"){const n=e.deferredReason==="rotate"?a("chat.pendingSend.deferred.rotate"):e.deferredReason==="stopped"?a("chat.pendingSend.deferred.stopped"):a("chat.pendingSend.deferred.other");return t>=1?a("chat.pendingSend.deferredLong",{reason:n,minutes:t}):a("chat.pendingSend.deferred",{reason:n})}return t>=1?a("chat.pendingSend.queuedLong",{minutes:t}):a("chat.pendingSend.queued")}function xP({handoff:e,content:t,ts:n,defaultOpen:s=!0,entering:r=!1}){const i=cn(n);return o.jsxs(Jt,{className:be("rotate-handoff-card w-full min-w-0 max-w-full",r&&"msg-enter"),ariaLabel:e.epoch!==void 0?a("chat.rotateHandoff.aria",{epoch:e.epoch}):a("chat.rotateHandoff.title"),defaultOpen:s,title:o.jsx("span",{className:"max-w-56 truncate font-mono text-2xs tracking-wider text-accent",children:a("chat.rotateHandoff.title")}),meta:e.epoch!==void 0?a("chat.rotateHandoff.epoch",{epoch:e.epoch}):void 0,summary:t,children:[o.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline gap-x-2 font-mono text-2xs text-faint",children:[o.jsx("span",{className:"min-w-0 break-words",children:a("chat.rotateHandoff.source")}),i!==""&&o.jsx("time",{className:"shrink-0 tabular-nums",dateTime:new Date(n??0).toISOString(),children:i})]}),o.jsx("p",{className:"m-0 whitespace-pre-wrap wrap-anywhere text-sm leading-relaxed text-ink",children:t})]})}function wP(e){if(!e.type.startsWith("subagent."))return e;const t=e.type.slice(9);return t.startsWith("run.")||t.startsWith("tool.call.")||t.startsWith("llm.")?{...e,type:t}:e}function kP(e,t,n="user"){return t.runId?e.filter(s=>s.event.run_id===t.runId).filter(s=>gw(s.event,n,!1)).map(s=>({...s,event:wP(s.event)})):[]}function SP({agent:e,entries:t,errorLevel:n="user",verbosity:s="normal",messageVisibility:r}){const i=u.useMemo(()=>kP(t,e,n),[t,e,n]),l=u.useMemo(()=>e.runId?xw(e.runId,i):void 0,[e.runId,i]);return o.jsxs("section",{className:"subagent-transcript my-2.5 ml-3 flex flex-col gap-2","aria-label":a("chat.subagents.title"),children:[o.jsxs("div",{className:"subagent-summary",children:[o.jsx(Tt,{status:e.state}),o.jsx("strong",{className:"subagent-summary-task",children:e.task?.trim()||e.id}),e.currentTool&&o.jsx("span",{className:"font-mono text-muted",children:e.currentTool}),e.queuePosition!==void 0&&o.jsx("span",{className:"text-muted tabular-nums",children:a("chat.subagents.queuePosition",{position:e.queuePosition})}),e.waitReason&&o.jsx("span",{className:"text-muted",children:e.waitReason}),e.contextUsed!==void 0&&e.contextMax!==void 0&&o.jsx("span",{className:"text-muted tabular-nums",children:a("chat.subagents.context",{used:e.contextUsed,max:e.contextMax})}),e.usage?.total_tokens!==void 0&&o.jsxs("span",{className:"text-muted tabular-nums",children:[e.usage.total_tokens," tok"]}),o.jsx(xt,{label:e.id,children:o.jsx("span",{className:"subagent-summary-id font-mono text-muted",children:e.id})})]}),l?o.jsx(QM,{group:l,verbosity:s,...r!==void 0?{messageVisibility:r}:{}}):o.jsx("p",{className:"subagent-empty text-muted",children:a("chat.subagents.emptyRun")})]})}function jP(e){if(e.role!=="assistant")return;const t=e.reasoning_content;return Jd(t)?t:void 0}function _P(e,t,n,s){if(e.role!=="assistant"||!t)return;const r=s.get(e)??-1;if(!(r<0))for(let i=r-1;i>=0;i-=1){const l=t[i];if(l?.role==="user"&&Dn(l)===void 0&&!Rb(l))return{text:l.content,index:i+n}}}const NP=u.memo(function({message:t,messageIndex:n,previousUser:s,source:r,cardsDefaultOpen:i,showReasoning:l=!1,onCopy:c,onEdit:d,onRetry:m,onQuote:f,onJumpQuote:h,quoteTargets:p}){if(t.role==="system"||t.role==="tool")return null;const g=cn(t.timestamp);if(t.role==="user"){const k=g!==""?g:void 0,N=k!==void 0,T=z1(t);if(T!==void 0)return o.jsx(Vo,{sender:T.alias,senderKind:T.kind,content:t.content,ts:t.timestamp,...r!==void 0?{source:r}:{},defaultOpen:i});const R=co(t,{messages:p}),{blocks:E}=R,I=[],$=E.find(L=>L.type==="image");if($!==void 0)return o.jsx(dc,{block:$});const C=E.find(L=>L.type==="tool-media");return C!==void 0?o.jsx(dc,{block:C}):(t.content.trim().length>0&&(I.push({id:"copy",label:a("chat.message.copy"),onSelect:()=>c(t.content)}),n!==void 0&&I.push({id:"edit",label:a("chat.message.edit"),onSelect:()=>d(n,t.content)}),f!==void 0&&I.push({id:"quote",label:a("chat.quote.action"),onSelect:()=>f(t)})),o.jsxs("div",{className:"msg-user group flex max-w-full flex-col items-end gap-1",children:[o.jsx(dr,{lifted:R,messageRole:"user",render:{onJumpQuote:h},wrapBody:L=>o.jsx("div",{className:"msg-bubble",children:o.jsx(Wc,{children:L})})}),N||I.length>0?o.jsx(os,{className:"justify-end",actions:I,meta:k}):null]}))}const b=t.tool_calls??[],x=co(t,{messages:p}),{blocks:y,body:v}=x,j=l?jP(t):void 0;if(j!==void 0){const k=t.content.trim().length>0,N=[];return k&&f!==void 0&&N.push({id:"quote",label:a("chat.quote.action"),onSelect:()=>f(t)}),b.length===0&&s!==void 0&&s.text.trim().length>0&&N.push({id:"retry",label:a("chat.message.retry"),onSelect:()=>m(s.index,s.text)}),o.jsxs("div",{className:"msg-assistant group relative max-w-full",children:[o.jsx(Yd,{blocks:y,render:{onJumpQuote:h}}),o.jsx(qi,{text:j,streaming:!1,time:t.timestamp,actions:N,...k?{onCopyBody:()=>c(t.content)}:{}}),v&&o.jsx(jr,{className:"msg-text",text:v})]})}const _=g!==""?g:void 0,S=[];t.content.trim().length>0&&(S.push({id:"copy",label:a("chat.message.copy"),onSelect:()=>c(t.content)}),f!==void 0&&S.push({id:"quote",label:a("chat.quote.action"),onSelect:()=>f(t)})),b.length===0&&s!==void 0&&s.text.trim().length>0&&S.push({id:"retry",label:a("chat.message.retry"),onSelect:()=>m(s.index,s.text)});const w=b.length===0;return o.jsxs("div",{className:"msg-assistant group relative max-w-full",children:[o.jsx(dr,{lifted:x,messageRole:"assistant",render:{onJumpQuote:h},bodyClassName:"msg-text"}),_!==void 0||S.length>0?o.jsx(os,{className:w?"mt-1":void 0,placement:w?"bottom":"side",actions:S,meta:_}):null]})}),CP=u.memo(function({item:t,render:n}){const s=n(t);return s==null?null:o.jsx("div",{className:"transcript-row",children:s})}),rh=new WeakMap;function TP(e){if(e.ts===void 0)return null;const t=rh.get(e);if(t!==void 0)return t;const n=vs(e.ts);return rh.set(e,n),n}function EP({items:e,allMessages:t,messageIndexOffset:n=0,cardsDefaultOpen:s=!1,showReasoning:r=!1,renderItem:i,onEditMessage:l,onRetryMessage:c,onQuoteMessage:d,onJumpQuote:m}){const f=is(),h=u.useMemo(()=>{const x=new Map,y=t??[];for(let v=0;v<y.length;v+=1){const j=y[v];j!==void 0&&x.set(j,v)}return x},[t]),p=u.useMemo(()=>{const x=new Map,y=t??[];for(const v of y)v.role==="assistant"&&x.set(v,_P(v,t,n,h));return x},[t,n,h]);if(e.length===0)return null;const g=[];let b=null;for(const x of e){const y=TP(x);if(y&&y!==b&&(g.push(o.jsx("div",{className:"mt-3.5 mb-2.5 flex items-center justify-center gap-2.5 py-1 font-mono text-2xs uppercase tracking-widest text-faint",children:o.jsx("span",{children:Wi(x.ts??0)})},`day-${y}`)),b=y),x.kind==="message"){const v=x.message;if(v.role==="system"||v.role==="tool")continue;const j=h.get(v),_=j!==void 0&&j>=0?j+n:void 0,S=p.get(v);g.push(o.jsx("div",{className:"transcript-row","data-index-entry-key":ua(v)?x.key:void 0,"data-quote-anchor":v.message_id,children:o.jsx(NP,{message:v,messageIndex:_,...S!==void 0?{previousUser:S}:{},...x.sourceText!==void 0?{source:x.sourceText}:{},cardsDefaultOpen:s,showReasoning:r,onCopy:f,onEdit:l,onRetry:c,onQuote:d,onJumpQuote:m,quoteTargets:t})},x.key));continue}g.push(o.jsx(CP,{item:x,render:i},x.key))}return o.jsx("div",{className:"flex flex-col gap-2 py-1.5 pb-2.5",children:g})}const xy=96,wy=100,IP=30;function RP(e){return Math.max(0,e.scrollHeight-e.scrollTop-e.clientHeight)}class LP{constructor(t,n={}){this.box=t,this.options=n,this.lastScrollTop=t.scrollTop,this.lastHeight=t.scrollHeight}box;options;pinnedValue=!0;lastFollowAt=0;settling=!1;smoothActive=!1;lastScrollTop;lastHeight;lastJumpTop=null;get pinned(){return this.pinnedValue}threshold(){return this.options.threshold??xy}now(){return(this.options.now??Date.now)()}onScroll(t=!1){const n=this.box.scrollTop,s=this.box.scrollHeight,r=s!==this.lastHeight;if(this.lastHeight=s,t)this.lastJumpTop=null;else{if(r)return this.lastScrollTop=n,this.pinnedValue;if(this.lastJumpTop!==null&&Math.abs(n-this.lastJumpTop)<=1)return this.lastJumpTop=null,this.lastScrollTop=n,this.pinnedValue}this.smoothActive&&n<this.lastScrollTop&&(this.smoothActive=!1),this.lastScrollTop=n;const i=RP(this.box);if(this.smoothActive)if(i<=this.threshold())this.smoothActive=!1;else return this.pinnedValue=!0,!0;return this.pinnedValue=i<=this.threshold(),this.pinnedValue}beginFollow(t=this.now()){if(!this.pinnedValue||this.settling)return{jump:!1,delayMs:0};const s=(this.options.followIntervalMs??wy)-(t-this.lastFollowAt);return s<=0?(this.lastFollowAt=t,{jump:!0,delayMs:0}):{jump:!1,delayMs:s}}jump(){this.pinnedValue=!0,this.smoothActive=!1,this.box.scrollTop=this.box.scrollHeight,this.lastScrollTop=this.box.scrollTop,this.lastJumpTop=this.box.scrollTop,this.lastHeight=this.box.scrollHeight,this.lastFollowAt=this.now()}jumpIfPinned(){return this.pinnedValue?(this.jump(),!0):!1}stickToBottom(t="send"){this.jump()}smoothToBottom(){this.pinnedValue=!0,this.smoothActive=!0,this.lastFollowAt=this.now(),this.box.scrollTo({top:this.box.scrollHeight,behavior:"smooth"})}settle(t){this.pinnedValue=!0,this.smoothActive=!1,this.settling=!0;let n,s=0,r=-1,i=0;const l=()=>{if(n=void 0,!this.pinnedValue){this.settling=!1;return}const c=this.box.scrollHeight;if(c===r?i+=1:(r=c,i=0),s+=1,s>=2&&i>=1||s>=IP){this.settling=!1,this.jump();return}n=t.request(l)};return n=t.request(l),()=>{n!==void 0&&t.cancel(n),this.settling=!1}}onResize(){this.lastHeight=this.box.scrollHeight,!(this.settling||!this.pinnedValue)&&(this.box.scrollTop=this.box.scrollHeight,this.lastScrollTop=this.box.scrollTop,this.lastJumpTop=this.box.scrollTop)}}const AP=500;function ky({resetKey:e,followKey:t,sendTick:n=0,threshold:s=xy,followIntervalMs:r=wy}){const i=u.useRef(null),l=u.useRef(null),[c,d]=u.useState(!0),m=u.useRef(void 0),f=u.useRef(0),h=u.useCallback(w=>{i.current=w},[]),p=u.useCallback(()=>i.current,[]),g=u.useCallback(()=>{const w=i.current;if(!w)return null;const k=l.current;if(k&&k.element===w)return k.controller;const N=new LP(w,{threshold:s,followIntervalMs:r});return l.current={element:w,controller:N},N},[s,r]),b=u.useCallback(()=>{m.current!==void 0&&(window.clearTimeout(m.current),m.current=void 0)},[]);u.useEffect(()=>{if(!e)return;const w=g();if(w)return b(),d(!0),w.settle({request:k=>window.requestAnimationFrame(k),cancel:k=>window.cancelAnimationFrame(k)})},[e,g,b]),u.useEffect(()=>{const w=g();if(!w)return;const{jump:k,delayMs:N}=w.beginFollow();if(k){w.jump(),d(!0);return}N>0&&m.current===void 0&&(m.current=window.setTimeout(()=>{m.current=void 0,g()?.jumpIfPinned()&&d(!0)},N))},[t,g]),u.useEffect(()=>{const w=i.current;if(!w||typeof ResizeObserver>"u")return;let k;const N=new ResizeObserver(()=>{k!==void 0&&cancelAnimationFrame(k),k=requestAnimationFrame(()=>{k=void 0,g()?.onResize()})});return N.observe(w),()=>{k!==void 0&&cancelAnimationFrame(k),N.disconnect()}},[g]),u.useEffect(()=>b,[b]);const x=u.useCallback(()=>{f.current=Date.now()+AP},[]),y=u.useMemo(()=>({onWheel:x,onTouchStart:x,onTouchMove:x,onKeyDown:x,onPointerDown:x}),[x]),v=u.useCallback(()=>{const w=g();w&&d(w.onScroll(Date.now()<f.current))},[g]),j=u.useCallback(()=>{const w=g();w&&(w.smoothToBottom(),d(!0))},[g]),_=u.useCallback((w="send")=>{const k=g();k&&(b(),k.stickToBottom(w),d(!0))},[g,b]),S=u.useRef(n);return u.useEffect(()=>{n!==S.current&&(S.current=n,_("send"))},[n,_]),{scrollRef:h,getElement:p,pinned:c,onScroll:v,scrollToBottom:j,stickToBottom:_,userIntentProps:y}}const MP=200,PP=20;function qP(e){switch(e){case mb:return a("chat.pending.identity.ask");case Jl:return Jl;case fb:return a("chat.pending.identity.system");default:return}}const OP=2;function DP(e,t){const n=u.useRef(null);let s=n.current;if(s===null?(s={reset:t,seen:new Set,first:!0,entering:new Set},n.current=s):s.reset!==t&&(s.reset=t,s.first=!0),e.length>0)if(s.first){if(s.first=!1,e.length<=OP)for(const r of e)s.seen.has(r.key)||s.entering.add(r.key);for(const r of e)s.seen.add(r.key)}else for(const r of e)s.seen.has(r.key)||(s.seen.add(r.key),s.entering.add(r.key));return u.useCallback(r=>n.current?.entering.has(r)??!1,[])}function HP({hasToken:e,selectedId:t,activeAgent:n,draftActive:s,restorePending:r,hydrateError:i,hydrating:l,hydrateStale:c,hasTranscript:d,hasEarlier:m,visibleGroups:f,renderedGroups:h,transcriptWindow:p,transcriptMessages:g,historyIndex:b,isHiddenMessage:x,noticeKindOf:y,messageIndexOffset:v,sessionFailure:j,sessionSystemContext:_,projectionSummary:S,answeredAsks:w,detailNotice:k,onDismissDetailNotice:N,earlierError:T,onDismissEarlierError:R,onRetryEarlier:E,verbosity:I,cardsDefaultOpen:$,errorLevel:C,entries:L,snapshotVersion:A,detailSessionId:D,sendTick:O,onRetryDetail:F,onLoadEarlier:V,onConfigureConnection:B,onGoChat:W,onEditMessage:Z,onRetryMessage:ee,onQuoteMessage:ie,quoteJumpRef:le,pendingSends:J,onRetryPending:z,onDismissPending:me}){const{messageVisibility:K,visibility:ne}=aa(),Ne=zd(I,K.reasoning),ce=p.shown[0]?.timestamp,se=u.useMemo(()=>uR({messages:g,messageIndexOffset:v,liveGroups:n?[]:h,windowStartTs:ce,historyIndex:b,isHidden:x,noticeKindOf:y,runtimeVisibility:ne,...n?{}:{sessionFailure:j,sessionSystemContext:_,answeredAsks:w}}),[g,v,n,h,ce,b,x,y,ne,j,_,w]),we=t?`${t}:${D??""}`:null,he=se.length>0?se[se.length-1]?.key??"":"",pe=`${A}:${h.length}:${se.length}:${he}`,{scrollRef:Me,getElement:oe,pinned:je,onScroll:Ee,scrollToBottom:Ce,userIntentProps:U}=ky({resetKey:we,followKey:pe,sendTick:O}),q=u.useMemo(()=>bR(se),[se]),{activeKey:M,jumpTo:H}=jd({getElement:oe,entryKeys:q.map(Q=>Q.key),resetKey:we}),X=u.useCallback(Q=>{const ye=oe();if(!ye)return;const Te=ye.querySelector(`[data-quote-anchor="${CSS.escape(Q)}"]`);if(!Te)return;const Ue=Te.getBoundingClientRect().top-ye.getBoundingClientRect().top+ye.scrollTop-12,Be=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;ye.scrollTo({top:Math.max(0,Ue),behavior:Be?"auto":"smooth"}),Te.classList.remove("quote-flash"),Te.offsetWidth,Te.classList.add("quote-flash"),window.setTimeout(()=>Te.classList.remove("quote-flash"),1300)},[oe]);le!==void 0&&(le.current=X);const Y=u.useRef(null),re=u.useRef(void 0),_e=u.useRef(0),fe=u.useCallback(()=>{if(!m||Y.current!==null)return;const Q=oe();if(!Q)return;const ye={height:Q.scrollHeight,top:Q.scrollTop};Y.current=ye,window.clearTimeout(re.current),re.current=window.setTimeout(()=>{Y.current===ye&&(Y.current=null)},3e3);const Te=V();if(!(Te instanceof Promise))return;const Ue=()=>{window.setTimeout(()=>{window.requestAnimationFrame(()=>{if(Y.current!==ye)return;Y.current=null,window.clearTimeout(re.current);const Be=oe();if(!Be)return;const tt=Be.scrollHeight-ye.height;tt<=0||(Be.scrollTop=ye.top+tt,_e.current+=1)})},0)};Te.then(Ue,Ue)},[m,oe,V]),Pe=se[0]?.key??"";u.useLayoutEffect(()=>{const Q=Y.current;if(Q===null)return;Y.current=null,window.clearTimeout(re.current);const ye=oe();if(!ye)return;const Te=ye.scrollHeight-Q.height;ye.scrollTop=Q.top+Math.max(0,Te),_e.current+=1,_e.current<PP&&ye.scrollHeight<=ye.clientHeight+1&&fe()},[p.shown.length,Pe,oe,fe]);const ke=DP(se,we),Ge=u.useRef(new Set),mt=u.useMemo(()=>{const Q=new Set;if(Ne)for(const Te of se)Te.kind==="run-reasoning"&&Jd(Te.text)&&Q.add(Te.runId);const ye=Ge.current;return ye.size===Q.size&&[...Q].every(Te=>ye.has(Te))?ye:(Ge.current=Q,Q)},[se,Ne]),lt=u.useRef(new Map),de=u.useMemo(()=>{const Q=new Map;for(const Te of se)Te.kind==="run-text"&&Q.set(Te.runId,Te.key);const ye=lt.current;return ye.size===Q.size&&[...Q].every(([Te,Ue])=>ye.get(Te)===Ue)?ye:(lt.current=Q,Q)},[se]),qe=u.useRef(new Map),Oe=u.useMemo(()=>{const Q=new Map,ye=new Map;for(let Ue=se.length-1;Ue>=0;Ue-=1){const Be=se[Ue];if(Be===void 0)continue;if(Be.kind==="run-text"){ye.set(Be.runId,{key:Be.key,text:Be.text,streaming:Be.streaming});continue}if(Be.kind!=="run-reasoning")continue;const tt=ye.get(Be.runId);tt!==void 0&&Q.set(Be.key,{body:tt.text,bodyStreaming:tt.streaming,isRunEnd:de.get(Be.runId)===tt.key})}const Te=qe.current;return Te.size===Q.size&&[...Q].every(([Ue,Be])=>{const tt=Te.get(Ue);return tt!==void 0&&tt.body===Be.body&&tt.bodyStreaming===Be.bodyStreaming&&tt.isRunEnd===Be.isRunEnd})?Te:(qe.current=Q,Q)},[se,de]),ue=u.useMemo(()=>{if(n)return!1;const Q=h.filter(Te=>Te.status==="running"),ye=Q[Q.length-1];return ye===void 0?!1:!se.some(Te=>Te.kind==="run-text"||Te.kind==="run-reasoning"?Te.runId===ye.runId:Te.kind==="tool"?I!=="minimal"&&K.tools&&Te.runId===ye.runId:Te.kind==="inbox-read"?Te.runId===ye.runId:!1)},[n,se,h,I,K.tools]),xe=is(),De=u.useCallback(Q=>{const ye=b.claims?.claimedUserByRun.get(Q),Te=ye!==void 0?[ye]:b.inputsByRun.get(Q);if(Te===void 0||Te.length!==1)return;const Ue=Te[0];if(Ue===void 0)return;const Be=b.messageByIndex.get(Ue);if(!(Be===void 0||Be.content.trim().length===0))return{index:Ue,text:Be.content}},[b]),Je=ma(),ht=J.some(Q=>Q.state==="queued"||Q.state==="deferred"),ft=u.useCallback(Q=>{switch(Q.kind){case"run-input":return Q.sender!==void 0?o.jsx(Vo,{sender:Q.sender,...Q.senderKind!==void 0?{senderKind:Q.senderKind}:{},content:Q.text,ts:Q.ts,defaultOpen:$,entering:ke(Q.key)}):o.jsx(mc,{text:Q.text,ts:Q.ts,entering:ke(Q.key),refs:Q.refs,onJumpQuote:X});case"inbox-read":{if(Q.source===ns)return o.jsx(mc,{text:Q.text,ts:Q.ts,entering:ke(Q.key),onJumpQuote:X});const ye=qP(Q.source);if(ye!==void 0)return o.jsx(Vo,{sender:ye,senderKind:"tool",content:Q.text,ts:Q.ts,defaultOpen:$,entering:ke(Q.key)});const Te=da(Q.source)?.principal??Q.source;return o.jsx(Vo,{sender:Je?.get(Te)??$E(Te),content:Q.text,ts:Q.ts,source:Q.source,defaultOpen:$,entering:ke(Q.key)})}case"ask-answer":return o.jsx(oh,{card:Q.card,ts:Q.ts,defaultOpen:$});case"ask-answered":return o.jsx(oh,{card:Q.card,ts:Q.ts,defaultOpen:$,titleLabel:a("chat.askAnswered.title"),sourceLabel:a("chat.askAnswered.source"),ariaLabel:a("chat.askAnswered.aria")});case"rotate-handoff":return o.jsx(xP,{handoff:Q,content:Q.text,ts:Q.ts,defaultOpen:!0,entering:ke(Q.key)});case"run-text":{const ye=mt.has(Q.runId),Te=ye?"":cn(Q.ts),Ue=de.get(Q.runId)===Q.key;return o.jsx(ci,{text:Q.text,streaming:Q.streaming,entering:ke(Q.key),onJumpQuote:X,actions:!ye&&Q.text.trim().length>0?o.jsx(os,{className:Ue?"mt-1":void 0,placement:Ue?"bottom":"side",actions:[{id:"copy",label:a("chat.message.copy"),onSelect:()=>xe(Q.text)}],meta:Te===""?void 0:o.jsx("time",{dateTime:new Date(Q.ts??0).toISOString(),children:Te})}):void 0})}case"run-reasoning":{if(!Ne)return null;const ye=Oe.get(Q.key),Te=ye?.body??"",Ue=Te.trim().length>0,Be=[];if(Ue&&ie!==void 0&&Be.push({id:"quote",label:a("chat.quote.action"),onSelect:()=>ie({role:"assistant",content:Te})}),ye?.isRunEnd===!0&&!ye.bodyStreaming&&!Q.streaming){const tt=De(Q.runId);tt!==void 0&&Be.push({id:"retry",label:a("chat.message.retry"),onSelect:()=>ee(tt.index,tt.text)})}return o.jsx(qi,{text:Q.text,streaming:Q.streaming,entering:ke(Q.key),...Q.startedAt!==void 0?{time:Q.startedAt}:{},actions:Be,...Ue?{onCopyBody:()=>xe(Te)}:{}})}case"tool":return iy(Q.status,I,K.tools)?o.jsx(py,{card:{kind:"tool",key:Q.key,...Q.callId!==void 0?{callId:Q.callId}:{},name:Q.name,status:Q.status,...Q.args!==void 0?{args:Q.args}:{},...Q.output!==void 0?{result:Q.output}:{},...Q.error!==void 0?{error:Q.error}:{},...Q.durationMs!==void 0?{durationMs:Q.durationMs}:{},...Q.truncated===!0?{truncated:!0}:{},...Q.truncatedLimitBytes!==void 0?{truncatedLimitBytes:Q.truncatedLimitBytes}:{},...Q.projection!==void 0?{projection:Q.projection}:{},startedAt:Q.startedAt},verbosity:I,defaultOpen:$,entering:ke(Q.key),...S!==void 0?{projectionSummary:S}:{}}):null;case"notice":return o.jsx(ly,{event:Q.event,defaultOpen:$,entering:ke(Q.key)});case"prompt-context":return o.jsx(VM,{context:Q,defaultOpen:$,entering:ke(Q.key)});case"run-failure":return o.jsx(by,{failure:Q,defaultOpen:$});case"runtime-notice":{const ye=Q.env;return ye!==void 0?ht&&ME(ye)?null:o.jsx(fa,{env:ye,ts:Q.ts,defaultOpen:$,entering:ke(Q.key)}):o.jsx(Jt,{className:"runtime-notice-card w-full min-w-0 max-w-full",tone:"info",defaultOpen:$,entering:ke(Q.key),title:o.jsx("span",{className:"font-mono text-2xs tracking-wider text-accent",children:a("chat.notice.runtime",{kind:Q.noticeKind})}),summary:Q.text,children:o.jsx("p",{className:"m-0 min-w-0 px-2.5 pb-2 break-words whitespace-pre-wrap wrap-anywhere text-sm text-muted",children:Q.text})})}default:return null}},[$,ke,xe,X,mt,de,Oe,De,ie,ee,Je,I,K,Ne,ht,S]),pt=u.useCallback(()=>{Ee();const Q=oe();Q&&Q.scrollTop<=MP&&fe()},[Ee,oe,fe]);return o.jsxs("div",{className:"transcript-stage",children:[o.jsxs("div",{className:"conversation-scroll",ref:Me,onScroll:pt,...U,children:[e?t?o.jsxs(o.Fragment,{children:[i?o.jsx(Ve,{message:i===pi?a("chat.notFound"):i,onRetry:F,action:i===pi?o.jsx(G,{type:"button",onClick:W,children:a("breadcrumb.chat")}):void 0}):l&&!d&&se.length===0?o.jsx(Ke,{label:a("chat.loadingHistory")}):!d&&f.length===0&&!n?o.jsx($e,{title:a("chat.empty.noHistoryTitle"),description:a("chat.empty.noHistoryDesc")}):null,c&&o.jsx(st,{message:a("chat.staleHistory",{detail:c}),onRetry:F}),k&&o.jsx(st,{message:a(k),onDismiss:N}),T&&o.jsx(st,{message:a("chat.earlierLoadFailed",{detail:T}),onRetry:E,onDismiss:R}),se.length>0?o.jsx(EP,{items:se,allMessages:g,messageIndexOffset:v,cardsDefaultOpen:$,showReasoning:Ne,renderItem:ft,onEditMessage:Z,onRetryMessage:ee,onQuoteMessage:ie,onJumpQuote:X}):null,J.filter(B1).map(Q=>o.jsx(vP,{pending:Q,onRetry:z,onDismiss:me,onJumpQuote:X},Q.id)),ue&&o.jsx(gy,{}),n&&o.jsx(SP,{agent:n,entries:L,errorLevel:C,verbosity:I,messageVisibility:K})]}):s?o.jsx(bP,{}):r?o.jsx(Ke,{label:a("chat.restoringSession")}):null:o.jsx($e,{title:a("chat.empty.noConnectionTitle"),description:a("chat.empty.noConnectionDesc"),action:o.jsx(G,{type:"button",variant:"primary",onClick:B,children:a("common.configureConnection")})}),!je&&o.jsx("button",{type:"button",className:"to-bottom",onClick:Ce,children:a("chat.toBottom")})]}),!n&&o.jsx(pd,{entries:q,activeKey:M,onJump:H,className:"conversation-index-rail"})]})}const ih=40;function ah(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ms(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function lh(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function $P(e,t){if(!Array.isArray(e))return[];const n=new Map;if(Array.isArray(t))for(const r of t){if(!ah(r))continue;const i=ms(r.header),l=ms(r.question);i!==void 0&&l!==void 0&&!n.has(i)&&n.set(i,l)}const s=[];for(const r of e){if(!ah(r))continue;const i=ms(r.answer);if(i===void 0)continue;const l=ms(r.header)??ms(r.question);if(l===void 0)continue;const d=ms(r.question)??n.get(l);s.push({label:l,text:i,...d!==void 0?{question:d}:{}})}return s}function FP(e){if(e.kind!=="ask"||e.status!=="answered"||e.mode==="async")return;const t=ms(e.request_id);if(t===void 0)return;const n=$P(e.answer?.answers,e.questions);if(n.length===0)return;const s=n[0];if(s===void 0)return;const r=s.label.trim(),i=r.length>ih?`${r.slice(0,ih)}…`:r,l=lh(e.answer?.answered_at)??lh(e.created_at);if(l!==void 0)return{requestId:t,answeredAt:l,card:{requestId:t,summary:i,rows:n}}}function BP(e,t){const n=new Set,s=[];for(const r of e){if(t!==void 0&&r.session_id!==t)continue;const i=FP(r);i===void 0||n.has(i.requestId)||(n.add(i.requestId),s.push(i))}return s.sort((r,i)=>r.answeredAt===i.answeredAt?0:r.answeredAt-i.answeredAt),s}const KP=50,WP=250,ch=[];function UP({sessionId:e,client:t,epoch:n,connected:s,refreshKey:r}){const[i,l]=u.useState(null);return u.useEffect(()=>{if(!s||e===null||e==="")return;let c=!1;const d=window.setTimeout(()=>{t.listInteractions({session_id:e,status:"answered",limit:KP}).then(m=>{c||l({sessionId:e,cards:BP(m,e)})}).catch(()=>{c||l({sessionId:e,cards:ch})})},WP);return()=>{c=!0,window.clearTimeout(d)}},[t,s,e,n,r]),i===null||i.sessionId!==e?ch:i.cards}const zP=new Set(["bash.job.started","bash.job.completed","bash.job.failed"]);function VP(e){const{sessionId:t,client:n,epoch:s,entries:r,enabled:i}=e,[l,c]=u.useState({session:null,running:new Set});return u.useEffect(()=>{if(!i||t===null){c({session:null,running:new Set});return}let d=!1;return(async()=>{try{const m=await n.rpc("jobs.list",{session_id:t});if(d)return;const f=new Set((Array.isArray(m?.jobs)?m.jobs:[]).filter(h=>h.status==="running").map(h=>h.job_id));c({session:t,running:f})}catch{d||c({session:t,running:new Set})}})(),()=>{d=!0}},[t,s,i,n]),u.useMemo(()=>{if(t===null)return{count:0,jobIds:[]};const d=new Set(l.session===t?l.running:[]);for(const f of r){const h=f.event;if(!zP.has(h.type))continue;const p=h.data;p.session_id!==t||typeof p.job_id!="string"||(h.type==="bash.job.started"?d.add(p.job_id):d.delete(p.job_id))}const m=[...d];return{count:m.length,jobIds:m}},[t,l,r])}function al(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function GP(e){if(!al(e))return!1;const t=al(e.config)?e.config:e,n=al(t.ui)?t.ui:void 0;return(n?.showRetiredSessions??n?.show_retired_sessions)===!0}function YP(e,t){return e.agent?.primary===!0?!1:e.agent?.primary===!1||t.has(e.session_id)}function JP(e,t,n){return t?[...e]:e.filter(s=>!YP(s,n))}function QP(){return Qt(),wt(e=>GP(Se(e.config)))}function XP(e){const t=new Map,n=(s,r,i)=>{s!==void 0&&(!i&&t.has(s)||t.set(s,r))};for(const s of e){const r=Nt(s.node?.name);if(r){for(const i of s.agents??[]){const l=Nt(i.team_id);n(Nt(i.id)??Nt(i.agent_id),l?{node:r,team:l}:{node:r},!1)}if(s.node?.current)for(const i of s.rosters??[]){const l=Nt(i.team?.team_id);for(const c of i.members??[])n(Nt(c.id)??Nt(c.agent_id),l?{node:r,team:l}:{node:r},!0)}}}return t}function Nt(e){const t=typeof e=="string"?e.trim():"";return t===""?void 0:t}function va(e){return Nt(e.session_id)??Nt(e.body_id)}function ur(e){const t=(e.bodies??[]).find(s=>s.primary===!0);return(t?va(t):void 0)??Nt(e.session_id)}function ZP(e){const t=e.role??void 0;return t!==void 0?t==="member"||t==="single":e.owner==null}function eq(e){const t=e.role??void 0;return t!==void 0?t==="member"||t==="single":e.owner!=null?!1:e.team_id!=null}function tq(e,t,n){const s=t?new Set(t.map(c=>Nt(c.session_id)).filter(c=>c!==void 0)):void 0,r=new Set,i=new Map,l=[];for(const c of e){for(const d of c.agents??[])l.push(d);for(const d of c.rosters??[])for(const m of d.members??[])l.push(m)}for(const c of l){for(const m of c.bodies??[]){const f=va(m);f&&r.add(f)}const d=ur(c);d&&r.add(d)}for(const c of l){const d=Nt(c.name);if(d)for(const m of c.body_history??[]){const f=Nt(m.session_id);f!==void 0&&(r.has(f)||s&&!s.has(f)||i.has(f)||i.set(f,n(d)))}}return i}function nq(e,t,n){const s=Nt(n)??"primary",r=new Set;for(const c of e)for(const d of c.rosters??[])for(const m of d.members??[]){if(!ZP(m))continue;const f=ur(m);f&&r.add(f)}const i=t?new Set(t.map(c=>Nt(c.session_id)).filter(c=>c!==void 0)):void 0,l=new Map;for(const c of e)for(const d of c.agents??[]){if(eq(d))continue;const m=ur(d);if(!m||r.has(m)||i&&!i.has(m))continue;const f=Nt(d.name);f&&(l.has(m)||l.set(m,`${f}@${s}`))}return l}function sq(e,t){const n=t?new Set(t.map(i=>Nt(i.session_id)).filter(i=>i!==void 0)):void 0,s=new Map,r=(i,l)=>{i!==void 0&&(n&&!n.has(i)||s.has(i)||s.set(i,l))};for(const i of e){const l=[...i.agents??[]];for(const c of i.rosters??[])l.push(...c.members??[]);for(const c of l){const d=c.depth;if(!(typeof d!="number"||!Number.isFinite(d)||d<0)){for(const m of c.bodies??[])r(va(m),d);r(ur(c),d);for(const m of c.body_history??[])r(Nt(m.session_id),d)}}}return s}function oq(e,t){const n=t?new Set(t.map(i=>Nt(i.session_id)).filter(i=>i!==void 0)):void 0,s=new Map,r=(i,l)=>{i!==void 0&&(n&&!n.has(i)||s.has(i)||s.set(i,l))};for(const i of e){const l=[...i.agents??[]];for(const c of i.rosters??[])l.push(...c.members??[]);for(const c of l){const d=c.role,m=d==="temporary"?"temporary":d==="member"||d==="single"?"member":void 0;if(m!==void 0){for(const f of c.bodies??[])r(va(f),m);r(ur(c),m);for(const f of c.body_history??[])r(Nt(f.session_id),m)}}}return s}function rq({client:e,durableFeature:t,connected:n,epoch:s,selectedId:r,loadSessions:i,navigate:l}){const c=ot(),[d,m]=u.useState(null),[f,h]=u.useState(!1),[p,g]=u.useState(null),[b,x]=u.useState(null),y=it(S=>S.removeSession);u.useEffect(()=>{if(!d){x(null);return}let S=!1;const w=d.session_id;return x({live:0,durable:0,active:0,loading:!0,error:null}),(async()=>{let k=0,N=0,T=0,R=null;try{const E=await e.listRuns({session_id:w});k=E.length,N=E.filter(I=>I.status==="queued"||I.status==="running").length}catch(E){R=zt(E)}if(t)try{const E=await e.listDurableRuns({session_id:w,limit:200});T=E.length,N+=E.filter(I=>I.status==="running"||I.status==="interrupted").length}catch{}S||x({live:k,durable:T,active:N,loading:!1,error:R})})(),()=>{S=!0}},[d,e,t]);const v=u.useCallback(S=>{g(null),m(S)},[]),j=u.useCallback(()=>m(null),[]);return{deleteTarget:d,deleteBusy:f,deleteError:p,deleteCounts:b,openDelete:v,closeDelete:j,handleDelete:async()=>{if(d){if(!n){g(a("chat.toast.disconnectedDelete"));return}if((b?.active??0)>0){g(a("chat.toast.activeRuns"));return}h(!0),g(null);try{const S=await e.deleteSession(d.session_id),w=A0(r,null,d.session_id),k=en();Ed(k)===d.session_id&&Id(k),y(d.session_id),m(null),w.selectedId===null&&w.draftId===null&&l({domain:"chat",sessionId:"new"}),c.success(a("chat.toast.deleted",{runs:S.runs_deleted,events:S.events_deleted})),i(e,{epoch:s,force:!0})}catch(S){const w=S.code;g(w==="conflict"?a("chat.toast.activeRuns"):zt(S))}finally{h(!1)}}}}}function Sy(e,t){const{keyOf:n,order:s,resetKey:r,promoteToken:i}=t,l=u.useRef(Date.now()),c=u.useMemo(()=>s(e,l.current),[e,s]),d=u.useMemo(()=>c.map(x=>n(x)),[c,n]),m=u.useRef(new Set),f=u.useMemo(()=>{if(i===void 0)return new Set;const x=new Set;for(const y of e){const v=i(y);v!==null&&v!==""&&x.add(v)}return x},[e,i]),h=u.useMemo(()=>{for(const x of f)if(!m.current.has(x))return!0;return!1},[f]),[p,g]=u.useState(()=>({resetKey:r,keys:d})),b=u.useMemo(()=>_0(p.keys,d),[p.keys,d]);return u.useEffect(()=>{const x=p.resetKey!==r||h,y=x?d:b,v=y.length===p.keys.length&&y.every((j,_)=>j===p.keys[_]);m.current=f,!(!x&&v)&&(l.current=Date.now(),g({resetKey:r,keys:y}))},[h,f,r,b,d,p]),u.useMemo(()=>{const x=new Map(e.map(v=>[n(v),v])),y=[];for(const v of b){const j=x.get(v);j!==void 0&&y.push(j)}return y},[e,n,b])}function iq(e){return e.session_id}function aq(e,t){const{inflight:n,resetKey:s}=t,r=u.useCallback((l,c)=>k0(l,{...n!==void 0?{inflight:n}:{},now:c}),[n]),i=u.useCallback(l=>n?.has(l.session_id)===!0?l.session_id:null,[n]);return Sy(e,{keyOf:iq,order:r,resetKey:s,promoteToken:i})}const lq=2e4;function cq(e,t){const[n,s]=u.useState(e);return u.useEffect(()=>{const r=window.setTimeout(()=>s(e),t);return()=>window.clearTimeout(r)},[e,t]),n}function dq({client:e,hasToken:t,epoch:n,selectedId:s,routeSessionId:r,durableFeature:i,connected:l,navigate:c,permissions:d,asks:m,nodes:f,teamControl:h,loadRoster:p,pendingNewSessions:g}){const b=ot(),{eventStore:x}=Ae(),[y,v]=u.useState(""),j=cq(y,350),[_,S]=u.useState(null),[w,k]=u.useState(Ra),[N,T]=u.useState(0),[R,E]=u.useState(!1),I=it(P=>P.sessions),$=it(P=>P.loading),C=it(P=>P.error),L=it(P=>P.loaded),A=it(P=>P.detail),D=it(P=>P.detailId),O=it(P=>P.detailWindow),F=it(P=>P.detailNotice),V=it(P=>P.dismissDetailNotice),B=it(P=>P.earlierError),W=it(P=>P.dismissEarlierError),Z=it(P=>P.loadEarlier),ee=it(P=>P.detailLoading),ie=it(P=>P.detailError),le=Yt(P=>P.roster),J=u.useMemo(()=>Se(le)??[],[le]),z=u.useMemo(()=>fP(J),[J]),me=u.useMemo(()=>XP(J),[J]),K=u.useMemo(()=>sq(J,I),[J,I]),ne=u.useMemo(()=>oq(J,I),[J,I]),Ne=u.useMemo(()=>$T(J),[J]),ce=ra(),se=QP(),we=u.useMemo(()=>{const P=J.find(ae=>ae.node.current)??J[0];return I1(P?.agents??[])},[J]),he=u.useMemo(()=>R1(J),[J]),pe=u.useMemo(()=>nq(J,I,a("team.member.primaryBadge")),[J,I]),Me=u.useMemo(()=>tq(J,I,P=>`${P}@${a("team.member.primaryBadge")}`),[J,I,a]),oe=u.useMemo(()=>{if(we&&!I.some(P=>P.session_id===we.sessionId))return{sessionId:we.sessionId,label:we.name,bodyCount:we.bodies.length}},[we,I]),je=it(P=>P.loadSessions),Ee=it(P=>P.loadDetail),Ce=it(P=>P.select),U=it(P=>P.refresh),q=it(P=>P.reset),M=it(P=>P.renameSession),H=it(P=>P.setSessions),X=rq({client:e,durableFeature:i,connected:l,epoch:n,selectedId:s,loadSessions:je,navigate:c});u.useEffect(()=>{Ce(s)},[s,Ce]);const Y=u.useRef(!0);qt(()=>{if(!t)return;const P=!Y.current;Y.current=!1,je(e,{epoch:n,force:P})},{enabled:t,pollMs:6e4,deps:[n,t]});const re=f.map(P=>P.nodeId??P.name).join(","),_e=Sr(x,P=>dd(P.event),n);qt(()=>{t&&p(f,h)},{enabled:t&&f.length>0,pollMs:lq,deps:[n,t,re,_e]}),u.useEffect(()=>{t||q()},[t,q]),u.useEffect(()=>()=>q(),[q]);const fe=u.useMemo(()=>L?I.map(P=>P.session_id):null,[I,L]),Pe=C!==null&&!L;u.useEffect(()=>{s&&RL(en(),s)},[s]),u.useEffect(()=>{if(!t){E(!1);return}const P=LL({routeSessionId:r,storedSessionId:Ed(en()),knownSessionIds:fe});if(P.kind==="keep"){E(!1);return}if(P.kind==="wait"){E(!Pe);return}if(E(!1),P.kind==="restore"){S_(P.sessionId),c({domain:"chat",sessionId:P.sessionId});return}P.clear&&Id(en()),c({domain:"chat",sessionId:"new"})},[t,r,fe,c,Pe]),u.useEffect(()=>{const P=j.trim();if(P.length<2||!t){S(null);return}let ae=!1;return e.searchSessions(P).then(Le=>{if(!ae){if(Le===null){S(null);return}S({query:P,ids:new Set(Le.map(te=>te.session_id)),snippets:new Map(Le.map(te=>[te.session_id,te.snippet]))})}}),()=>{ae=!0}},[e,j,t]),u.useEffect(()=>{!t||!s||(Ce(s),Ee(e,s,{epoch:n,allowMissing:g.current.has(s)}))},[e,n,t,s,Ee,Ce]),u.useEffect(()=>{if(g.current.size!==0)for(const P of I)g.current.delete(P.session_id)},[I]);const ke=u.useMemo(()=>{const P=new Map;for(const ae of[...d,...m])ae.sessionId&&P.set(ae.sessionId,(P.get(ae.sessionId)??0)+1);return P},[d,m]),Ge=u.useMemo(()=>I.slice(0,20).map(P=>({id:`session-${P.session_id}`,group:"entity",label:Sn(P),keywords:[P.session_id,P.preview??""],hint:a("palette.hint.session"),run:()=>c({domain:"chat",sessionId:P.session_id})})),[I,c]);mi("chat-entities",Ge);const mt=u.useMemo(()=>{const P=s?I.find(Le=>Le.session_id===s):void 0;if(!P)return[];const ae=Sn(P);return[{id:"action-rename-session",group:"action",label:a("chat.palette.rename",{title:ae}),keywords:["rename","title",P.session_id],hint:a("palette.hint.session"),run:()=>T(Le=>Le+1)},{id:"action-delete-session",group:"action",label:a("chat.palette.delete",{title:ae}),keywords:["delete","remove",P.session_id],hint:a("palette.hint.confirm"),run:()=>X.openDelete(P)}]},[I,s,X.openDelete]);mi("chat-actions",mt,{clearOnUnmount:!0});const lt=Dt(P=>P.health),de=u.useMemo(()=>f.find(P=>P.current)??f[0],[f]),qe=u.useMemo(()=>N0((de===void 0?void 0:Xo(lt,de))?.health?.runtime?.scheduler),[lt,de]),[Oe,ue]=u.useState(0),xe=aq(I,{inflight:qe,resetKey:[String(n),j,String(ce),String(se),String(Oe)].join("|")}),De=j.trim(),Je=_?.query===De?_:null,ht=u.useMemo(()=>{const P=Je?xe.filter(Le=>Je.ids.has(Le.session_id)):T0(xe,{query:j}),ae=ce?P:P.filter(Le=>Le.agent?.state!=="closed"&&!Ne.has(Le.session_id));return De?ae:JP(ae,se,Me)},[Je,xe,j,ce,Ne,De,se,Me]);u.useEffect(()=>{k(Ra)},[j]);const ft=I0(ht,w),pt=s?I.find(P=>P.session_id===s):void 0,Q=s&&D===s&&A?.session_id===s?A:null,ye=s&&O?.sessionId===s?O:null,Te=s&&D===s?F:null,Ue=s&&D===s?B:null,Be=u.useCallback(()=>{U(e,{epoch:n,allowMissing:s?g.current.has(s):!1})},[e,n,U,s]);Lt(u.useCallback(()=>{Be(),ue(P=>P+1)},[Be]));const tt=u.useCallback(()=>{je(e,{epoch:n,force:!0})},[e,n,je]),Kt=u.useCallback(async(P,ae)=>{if(!l)return b.error(a("chat.toast.disconnectedRename")),!1;const Le=I;M(P,ae);try{return await e.renameSession(P,ae),je(e,{epoch:n,force:!0}),!0}catch(te){return H(Le),b.error(a("chat.toast.renameFailed",{detail:zt(te)})),!1}},[l,I,e,n,je,M,H,b]),dn=u.useCallback(()=>k(P=>P+Ra),[]);return{sessions:I,sessionsLoading:$,sessionsError:C,selectedSession:pt,sessionDetail:Q,sessionDetailId:D,detailWindow:ye,detailNotice:Te,dismissDetailNotice:V,earlierError:Ue,dismissEarlierError:W,loadEarlierDetail:Z,sessionDetailLoading:ee,sessionDetailError:ie,sessionWindow:ft,renderLimit:w,sessionInflight:qe,query:y,setQuery:v,debouncedQuery:j,activeServerSearch:Je,agentAddresses:z,agentAddressesById:me,agentDepths:K,agentRoles:ne,agentLabels:pe,agentRetiredLabels:Me,closedAgentSessions:Ne,defaultSessionEntry:oe,primarySessionIds:he,pendingBySession:ke,restorePending:R,renameSignal:N,loadSessions:je,loadSessionDetail:Ee,refreshSessions:U,retryLoad:tt,showMore:dn,handleRename:Kt,...X}}const dh=4096,uq=/^[A-Za-z0-9_-]{1,64}$/,mq=new Set(["human","system"]);function fq(e=()=>crypto.randomUUID()){const t=`chat-${e().toLowerCase()}`;if(uq.test(t)&&!mq.has(t))return t;let n=0;for(const s of t)n=n*31+s.charCodeAt(0)>>>0;return`chat-${n.toString(16).padStart(8,"0")}`}async function hq(e,t,n,s,r,i=fq()){const l=await e.createAgent({name:i,...r!==void 0&&r!==""?{model:r}:{}}),c=l.id??l.agent_id;if(!c)throw new Error("agents.create returned no agent id");try{const d=await t(n,void 0,c,s);if(!d.session_id)throw new Error("runs.start returned no session_id");return{agentId:c,sessionId:d.session_id,run:d}}catch(d){try{await e.closeAgent(c)}catch{}throw d}}const pq=15e3,gq=18e4,bq=18e4,vq=["user.message","run.started"];function uh(e,t){return e.trim()===t.trim()}const yq=["timeout","queue_timeout","defer_timeout"];function mh(e){return e!==void 0&&yq.includes(e)}class xq{items=[];sentIds=[];messageIdAt=new Map;listeners=new Set;nextSequence=1;now;idFactory;constructor(t){this.now=t?.now??(()=>Date.now()),this.idFactory=t?.idFactory??(()=>{const n=this.nextSequence;return this.nextSequence+=1,`pending-${String(this.now())}-${String(n)}`})}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});list=()=>this.items;create(t){const n=t.reuseId??this.idFactory(),s=this.now();return t.reuseId!==void 0?(this.items=this.items.map(r=>r.id===n?{...r,text:t.text,...t.refs!==void 0?{refs:t.refs}:{},createdAt:s,state:"sending",failure:void 0,runId:void 0,deferredReason:void 0,retryAfterMs:void 0,messageId:void 0}:r),this.messageIdAt.delete(n),this.emit(),n):(this.items=[...this.items,{id:n,sessionId:t.sessionId,text:t.text,...t.refs!==void 0?{refs:t.refs}:{},createdAt:s,state:"sending"}],this.emit(),n)}attachSession(t,n){let s=!1;this.items=this.items.map(r=>r.id!==t||r.sessionId!==null?r:(s=!0,{...r,sessionId:n})),s&&this.emit()}attachRun(t,n,s){let r=!1;this.items=this.items.map(i=>i.id!==t?i:(r=!0,{...i,runId:n,state:s==="queued"?"queued":"sending",failure:void 0})),r&&this.emit()}attachMessage(t,n){let s=!1;this.items=this.items.map(r=>r.id!==t||r.messageId===n?r:(s=!0,{...r,messageId:n})),s&&(this.messageIdAt.set(t,this.now()),this.emit())}noteQueued(t){if(t.from!=="human"||t.delivery!=="input")return;const n=this.items.find(s=>s.messageId===void 0&&s.state!=="failed"&&(s.sessionId===null||t.sessionId===void 0||s.sessionId===t.sessionId));if(n!==void 0)return this.attachMessage(n.id,t.messageId),n.id}attachDeferred(t,n){let s=!1,r=!1;this.items=this.items.map(i=>i.id!==t?i:(s=!0,n.messageId!==void 0&&i.messageId!==n.messageId&&(r=!0),{...i,state:"deferred",runId:void 0,failure:void 0,...n.reason!==void 0?{deferredReason:n.reason}:{},...n.retryAfterMs!==void 0?{retryAfterMs:n.retryAfterMs}:{},...n.messageId!==void 0?{messageId:n.messageId}:{}})),s&&(r&&this.messageIdAt.set(t,this.now()),this.emit())}markFailed(t,n){let s=!1;this.items=this.items.map(r=>r.id!==t?r:(s=!0,{...r,state:"failed",failure:n,runId:void 0})),s&&this.emit()}remove(t){const n=this.items.filter(s=>s.id!==t);n.length!==this.items.length&&(this.items=n,this.messageIdAt.delete(t),this.emit())}clearSession(t){const n=this.items.filter(s=>s.sessionId!==t);if(n.length!==this.items.length){for(const s of this.items)s.sessionId===t&&this.messageIdAt.delete(s.id);this.items=n,this.emit()}}reset(){this.items.length!==0&&(this.items=[],this.messageIdAt.clear(),this.emit())}reconcileWithServer(t){const n=this.items.filter(r=>r.sessionId===t.sessionId&&r.messageId!==void 0&&!t.presentIds.has(r.messageId)&&(r.state==="queued"||r.state==="deferred"&&(r.deferredReason==="draining"||r.deferredReason==="stopped"))&&(this.messageIdAt.get(r.id)??Number.POSITIVE_INFINITY)<=t.readStartedAt);if(n.length===0)return 0;const s=new Set(n.map(r=>r.id));this.items=this.items.filter(r=>!s.has(r.id));for(const r of n)this.messageIdAt.delete(r.id),this.noteSent(r.messageId);return this.emit(),n.length}noteEvent(t){if(!vq.includes(t.type)||this.items.length===0)return;const n=this.items.filter(r=>r.state!=="failed"||mh(r.failure));if(t.runId!==void 0&&t.runId!==""){const r=n.find(i=>i.runId===t.runId);return r===void 0?this.claimByEchoText(t):(this.noteSent(r.messageId),this.remove(r.id),r.id)}const s=n.find(r=>r.state==="sending"&&(r.sessionId===null||t.sessionId===void 0||r.sessionId===t.sessionId)&&(t.text===void 0||uh(r.text,t.text)));return s===void 0?this.claimByEchoText(t):(this.noteSent(s.messageId),this.remove(s.id),s.id)}claimByEchoText(t){if(t.text===void 0)return;const n=this.items.find(s=>(s.state==="deferred"||s.state==="failed"&&mh(s.failure))&&(s.sessionId===null||t.sessionId===void 0||s.sessionId===t.sessionId)&&uh(s.text,t.text??""));if(n!==void 0)return this.noteSent(n.messageId),this.remove(n.id),n.id}sweep(t,n){const s=t??this.now();let r=0;return this.items=this.items.map(i=>{if(n!==void 0&&i.sessionId!==null&&(i.state==="sending"||i.state==="queued")&&n.has(i.sessionId))return i;const l=i.state==="sending"?pq:i.state==="queued"?gq:i.state==="deferred"?bq:void 0;return l===void 0||s-i.createdAt<l?i:(r+=1,{...i,state:"failed",failure:i.state==="queued"?"queue_timeout":i.state==="deferred"?"defer_timeout":"timeout"})}),r>0&&this.emit(),r}find(t){return this.items.find(n=>n.id===t)}sentMessageIds=()=>this.sentIds;noteSent(t){t!==void 0&&(this.sentIds.includes(t)||(this.sentIds=[...this.sentIds,t].slice(-32)))}emit(){for(const t of this.listeners)t()}}const Mt=new xq,wq="refs_invalid";function kq(e){if(typeof e!="object"||e===null||e.code!=="invalid_params")return null;const n=e.details;if(typeof n!="object"||n===null)return null;const s=n.reason;if(typeof s!="string"||s!==wq)return null;const r=n.path;return typeof r=="string"?{reason:s,path:r}:{reason:s}}function jy(e){const t=kq(e);return t===null?null:a("chat.refs.reject.invalid",{name:t.path??""})}function Sq(e,t){return e.length!==t.length?!1:e.every((n,s)=>{const r=t[s];return r!==void 0&&r.path===n.path&&r.kind===n.kind})}function jq(e,t){return e.length!==t.length?!1:e.every((n,s)=>{const r=t[s];return r!==void 0&&r.sessionId===n.sessionId})}function _q(e,t){return e===void 0||t===void 0?e===t:e.messageId===t.messageId&&e.snippet===t.snippet&&e.source===t.source}function Nq({client:e,connected:t,selectedId:n,epoch:s,navigate:r,loadSessions:i,loadRoster:l,nodes:c,teamControl:d,pendingNewSessions:m}){const f=ot(),h=Ut(n),p=kg(h),g=Sg(h),b=y_(h),x=w_(h),y=k_(h),v=Qe(K=>K.setRefs),j=Qe(K=>K.setSessionRefs),_=Qe(K=>K.setQuote),S=Qe(K=>K.setModel),w=Qe(K=>K.setText),k=u.useCallback(K=>S(h,K),[S,h]),N=u.useCallback((K,ne)=>{w(Ut(K),ne)},[w]),T=u.useCallback(K=>w(h,K),[w,h]),[R,E]=u.useState(!1),[I,$]=u.useState(0),[C,L]=u.useState(new Set),[A,D]=u.useState(new Set),O=async(K,ne,Ne,ce,se,we)=>{const he=K.trim(),pe=$v(K).trim();if(!pe||R||!t)return!1;const Me=Ne??[],oe=Me.length>0?Me:void 0,je=se??[],Ee=we,Ce=my(Dv(pe,je),Ee),U=Ut(ne??n),q=Qe.getState().drafts[U]?.model,M=ne??n;E(!0),$(X=>X+1);const H=Mt.create({sessionId:M??null,text:Ce,...oe!==void 0?{refs:oe}:{},...ce!==void 0?{reuseId:ce}:{}});try{let X,Y;if(M)Y=await e.submitRun(Ce,M,void 0,oe),X=M;else{const re=await hq({createAgent:_e=>e.createAgent(_e),closeAgent:_e=>e.closeAgent(_e)},(_e,fe,Pe)=>e.submitRun(_e,fe,Pe,oe),Ce,oe,q);Y=re.run,X=re.sessionId}if(!X)throw new Error("runs.start returned no session_id");if(Mt.attachSession(H,X),Y.status==="deferred"?Mt.attachDeferred(H,{...Y.reason!==void 0?{reason:Y.reason}:{},...Y.retry_after_ms!==void 0?{retryAfterMs:Y.retry_after_ms}:{},...Y.message_id!==void 0?{messageId:Y.message_id}:{}}):Y.run_id!==void 0&&Mt.attachRun(H,Y.run_id,Y.status),M||m.current.add(X),w(U,re=>re.trim()===he?"":re),Me.length>0){const re=Qe.getState().drafts[U]?.refs??[];Sq(re,Me)&&v(U,[])}if(je.length>0){const re=Qe.getState().drafts[U]?.sessionRefs??[];jq(re,je)&&j(U,[])}if(Ee!==void 0){const re=Qe.getState().drafts[U]?.quote;_q(re,Ee)&&_(U,void 0)}return!M&&q!==void 0&&Qe.getState().drafts[U]?.model===q&&S(U,void 0),M||r({domain:"chat",sessionId:X}),Y.status==="queued"&&f.info(a("chat.toast.queued")),Y.status==="deferred"&&Y.reason!=="draining"&&f.info(a("chat.toast.deferred")),i(e,{epoch:s,force:!0}),M||l(c,d),!0}catch(X){const Y=Me.length>0?jy(X):null;return f.error(Y??zt(X)),w(U,re=>re.trim()===he?"":re),Mt.markFailed(H,Y??zt(X)),!1}finally{E(!1)}},F=async()=>{await O(p,void 0,g,void 0,b,x)},V=u.useCallback(K=>{const ne=Ut(n);if(K.path.length>dh)return f.error(a("chat.refs.reject.tooLong",{max:dh})),!1;if(!/^(?:[\\/]|[A-Za-z]:[\\/])/.test(K.path))return f.error(a("chat.refs.reject.absolute",{path:K.path})),!1;const Ne=Qe.getState().addRef(ne,K);return Ne||f.error(a("chat.refs.reject.tooMany",{max:v_})),Ne},[n,f]),B=u.useCallback(K=>{Qe.getState().removeRef(Ut(n),K)},[n]),W=u.useCallback((K,ne)=>Qe.getState().updateRef(Ut(n),K,ne),[n]),Z=u.useCallback(K=>{const ne=Ut(n);if((Qe.getState().drafts[ne]?.sessionRefs??[]).some(se=>se.sessionId===K.sessionId))return!1;const ce=Qe.getState().addSessionRef(ne,K);return ce||f.error(a("chat.sessionRef.reject.tooMany",{max:x_})),ce},[n,f]),ee=u.useCallback(K=>{Qe.getState().removeSessionRef(Ut(n),K)},[n]),ie=u.useCallback(K=>{const ne=CM(K);ne!==void 0&&Qe.getState().setQuote(Ut(n),ne)},[n]),le=u.useCallback(()=>{Qe.getState().setQuote(Ut(n),void 0)},[n]),J=async(K,ne)=>{await O(K,ne)},z=async K=>{if(!t){Mt.markFailed(K.id,"offline");return}await O(K.text,K.sessionId??void 0,K.refs,K.id)},me=u.useCallback(async K=>{const ne=K.runId;if(ne){L(Ne=>new Set(Ne).add(ne));try{(await e.cancelRun(ne)).cancelled&&(D(ce=>new Set(ce).add(ne)),f.success(a("chat.toast.cancelRequested")))}catch(Ne){f.error(zt(Ne))}finally{L(Ne=>{const ce=new Set(Ne);return ce.delete(ne),ce})}}},[e,f]);return{input:p,setInput:T,setInputForSession:N,draftModel:y,setDraftModel:k,submitting:R,refs:g,addRef:V,removeRef:B,updateRef:W,sessionRefs:b,addSessionRef:Z,removeSessionRef:ee,quote:x,quoteMessage:ie,removeQuote:le,sendTick:I,cancelling:C,cancelledJobs:A,handleSend:F,handleRetry:J,handleRetryPending:z,handleCancel:me}}function Cq(e,t){if(t<=0)return{shown:[],hiddenCount:e.length};if(t>=e.length)return{shown:e.slice(),hiddenCount:0};const n=e.length-t;return{shown:e.slice(n),hiddenCount:n}}const ll=50,fh=200;function Tq({client:e,hasToken:t,epoch:n,selectedId:s,routeAgentId:r,snapshot:i,runtimeVisibility:l,sessions:c,sessionDetail:d,sessionDetailId:m,detailWindow:f,detailNotice:h,dismissDetailNotice:p,earlierError:g,dismissEarlierError:b,loadEarlierDetail:x,sessionDetailLoading:y,sessionDetailError:v,cancelling:j,cancelledJobs:_,pendingNewSessions:S,loadSessionDetail:w,refreshSessions:k,permissions:N,asks:T}){const[R,E]=u.useState(ll);u.useEffect(()=>{E(ll)},[s]);const{config:I}=Qt(),$=u.useMemo(()=>hd(I.status==="success"?I.data:null),[I]),C=$.errorLevel,L=ib($),A=as(I.status==="success"?I.data:null,"ui.expandCards")==="true"||$.verbosity==="debug",{eventStore:D,subscription:O}=Ae(),F=D.items,B=u.useSyncExternalStore(F.subscribe,F.getSnapshot,F.getSnapshot).groups;u.useEffect(()=>{D.setItemVisibility(L,C)},[D,L,C]);const W=u.useMemo(()=>rA(i.entries),[i.entries]),Z=u.useMemo(()=>s?iA(W,s):[],[W,s]),ee=s&&r?cA(Z,r):void 0,ie=s!==null&&(c.some(P=>P.session_id===s&&P.status==="running")||Z.some(P=>P.state==="running")),le=Sr(D,P=>P.event.type.startsWith("context.")&&P.event.data.session_id===s,`${n}:${s??""}`),J=Ft({load:async()=>{if(!s)return null;const ae=(await e.listAgentsTree({session_id:s})).nodes.filter(Le=>Le.id===s||Le.session_id===s).sort((Le,te)=>Le.depth-te.depth)[0];return!ae||ae.context_used===void 0?null:{sessionId:s,used:ae.context_used,...ae.context_max!==void 0?{max:ae.context_max}:{}}},enabled:t&&!!s,...ie?{pollMs:15e3}:{},deps:[s,n,ie,le]}),z=Se(J.state),me=s!==null&&z!=null&&z.sessionId===s?z:void 0,K=s!==null&&m===s?d?.context_usage:void 0,ne=u.useMemo(()=>{if(me){const P=me.max??K?.max;return{used:me.used,...P!==void 0?{max:P}:{}}}if(K)return{used:K.used,...K.max!==void 0?{max:K.max}:{}}},[me,K]),Ne=m===s?v:null,ce=d?null:Ne,se=d?Ne:null,we=!!s&&m===s&&y&&!d;u.useEffect(()=>{if(ce!==pi||!s)return;const P=en();Ed(P)===s&&Id(P)},[ce,s]);const he=u.useMemo(()=>s?B.filter(P=>P.sessionId===s):[],[B,s]),pe=u.useMemo(()=>MI(d),[d]),Me=u.useMemo(()=>qI(d),[d]),oe=u.useMemo(()=>{if(!s||m!==s)return;const P=PI(d);if(!(P===void 0||P.sessionId!==s))return P},[s,d,m]),je=u.useMemo(()=>{const P=he.length>fh?he.slice(-fh):he;return oe===void 0?P:P.map(ae=>ae.status==="running"&&oe.at>=(ae.startedAt??0)?{...ae,status:"interrupted",reconciled:"session-snapshot"}:ae)},[he,oe]),Ee=u.useMemo(()=>je.find(P=>P.status==="running"&&P.hasRunEvent&&!_.has(P.runId))??null,[je,_]),Ce=Ee?j.has(Ee.runId):!1;u.useEffect(()=>{if(!s)return;const P=oe;P!==void 0&&F.closeRuns(s,{status:P.status,at:P.at,...P.error!==void 0?{error:P.error}:{},via:"session-snapshot"})},[F,s,oe]);const U=u.useMemo(()=>new Set(he.map(P=>P.runId)),[he]),q=u.useMemo(()=>ou(N,s,U),[N,s,U]),M=u.useMemo(()=>ou(T,s,U),[T,s,U]),H=u.useMemo(()=>$x(q,M),[q,M]),X=H[0]??null,Y=H.slice(1,13).map(P=>P.kind==="permission"?{key:P.key,label:a("pending.queue.permission",{tool:P.request.tool})}:{key:P.key,label:a("pending.queue.ask",{index:P.questionIndex+1})}),re=u.useRef(void 0),_e=u.useRef(0),fe=u.useRef(0);u.useEffect(()=>{fe.current=0,window.clearTimeout(re.current),re.current=void 0},[s,n]),u.useEffect(()=>{if(i.version===_e.current)return;_e.current=i.version;const P=i.entries.slice(-40);let ae=0;for(const te of P)te.seq>ae&&(ae=te.seq);ae<fe.current&&(fe.current=0);let Le=fe.current;for(const{event:te,seq:Ie}of P){if(Ie<=fe.current)continue;const Ze=te.type==="run.completed"||te.type==="run.failed"||te.type==="run.cancelled",at=te.type==="session.saved"&&te.data.session_id===s;(Ze||at)&&Ie>Le&&(Le=Ie)}Le<=fe.current||(fe.current=Le,window.clearTimeout(re.current),re.current=window.setTimeout(()=>{re.current=void 0,k(e,{epoch:n,allowMissing:s?S.current.has(s):!1})},150))},[i.version,s,e,n,k]),u.useEffect(()=>()=>{window.clearTimeout(re.current)},[]);const Pe=u.useCallback(()=>{s&&w(e,s,{epoch:n,force:!0,allowMissing:S.current.has(s)})},[e,n,w,s]),ke=d?.messages??[],Ge=u.useMemo(()=>ke.filter(P=>{if(P.role==="system")return!1;const ae=Dn(P);return ae===void 0||ro(l,ae)}),[ke,l]),mt=u.useMemo(()=>Cq(Ge,R),[Ge,R]),lt=Ge.length-mt.shown.length,de=f!==null&&f.sessionId===s?f:null,qe=de?.next_before,Oe=de?.start??0,ue=u.useCallback(P=>{const ae=Dn(P);return ae!==void 0&&!ro(l,ae)},[l]),xe=u.useCallback(P=>Dn(P),[]),De=u.useMemo(()=>Ab(ke,Oe,ue,xe),[ke,Oe,ue,xe]),Je=u.useRef(null);Je.current??=new tR;const ht=Je.current,ft=u.useMemo(()=>Mb(he),[he]),pt=u.useMemo(()=>({sessionId:s,epoch:n,...de?.start!==void 0?{windowStart:de.start}:{},...de?.end!==void 0?{windowEnd:de.end}:{},history:De}),[s,n,de,De]),Q=s!==null&&m===s&&d!==null&&Ne===null,ye=ht.decide(pt,{history:De,facts:ft,detailReady:Q,...pe!==void 0?{failureRunId:pe.runId}:{}}),Te=u.useMemo(()=>De.claims===ye?De:{...De,claims:ye},[De,ye]),Ue=ye.handover;u.useEffect(()=>{!Q||Ue.size===0||F.release(Ue)},[F,Ue,Q]);const Be=u.useRef({localHidden:0,nextBefore:void 0});Be.current={localHidden:lt,nextBefore:qe};const tt=u.useCallback(async()=>{const{localHidden:P,nextBefore:ae}=Be.current;E(Ie=>Ie+ll);const Le=P>0||ae===void 0||!s?void 0:x(e,s,{epoch:n}),te=O.loadEarlier();await Promise.all([Le,te])},[e,n,x,s,O]),Kt=lt>0||q0(de)||i.hasEarlier,dn=Ge.length>0;return{visibility:$,errorLevel:C,sessionAgents:Z,activeAgent:ee,contextUsage:ne,hydrateError:ce,hydrateStale:se,hydrating:we,visibleGroups:he,sessionFailure:pe,sessionSystemContext:Me,renderedGroups:je,runningGroup:Ee,stopBusy:Ce,pendingItems:H,pendingItem:X,queueChips:Y,pendingActive:H.length>0,transcriptMessages:ke,historyIndex:Te,claimStats:ht.stats,isHiddenMessage:ue,noticeKindOf:xe,transcriptWindow:mt,messageIndexOffset:Oe,cardsDefaultOpen:A,detailNotice:h,dismissDetailNotice:p,earlierError:g,dismissEarlierError:b,hasEarlier:Kt,hasTranscript:dn,reloadDetail:Pe,loadEarlier:tt}}const Eq=["user.message","run.started"];function Iq(e){const t=e.event;if(!Eq.includes(t.type))return;const n=t.data??{},s=e.sessionId??(typeof n.session_id=="string"?n.session_id:void 0)??void 0,r=typeof n.text=="string"?n.text:typeof n.input=="string"?n.input:void 0;return{type:t.type,...typeof t.run_id=="string"&&t.run_id!==""?{runId:t.run_id}:{},...s!==void 0?{sessionId:s}:{},...r!==void 0?{text:r}:{}}}function Rq(e){const t=u.useSyncExternalStore(Mt.subscribe,Mt.list,Mt.list),n=u.useSyncExternalStore(Mt.subscribe,Mt.sentMessageIds,Mt.sentMessageIds),s=u.useMemo(()=>t.filter(l=>l.sessionId===null||e.sessionId===null||l.sessionId===e.sessionId),[t,e.sessionId]),r=u.useRef(-1),i=u.useRef(null);return u.useEffect(()=>{if(i.current!==e.sessionId&&(i.current=e.sessionId,r.current=-1),e.entries.length===0)return;let l=-1;for(const d of e.entries)d.seq>l&&(l=d.seq);l<r.current&&(r.current=-1);let c=r.current;for(const d of e.entries){if(d.seq<=r.current)continue;d.seq>c&&(c=d.seq);const m=Iq(d);if(m!==void 0){Mt.noteEvent(m);continue}const f=F1(d);f!==void 0&&Mt.noteQueued(f)}r.current=c},[e.entries,e.sessionId]),{pending:s,sentMessageIds:n,retry:l=>{Mt.create({sessionId:l.sessionId,text:l.text,reuseId:l.id}),e.onRetry?.(l)},dismiss:l=>{Mt.remove(l.id)},reconcile:l=>{Mt.reconcileWithServer(l)},attachMessage:(l,c)=>{Mt.attachMessage(l,c)}}}const Lq=[],hh=[],Aq=[];function Mq(e,t,n,s){return e!==void 0?e:n===null?void 0:t.filter(i=>i.sessionId===n).sort((i,l)=>i.depth-l.depth)[0]?.id??s.get(n)}function Pq({route:e,navigate:t,sessionsOpen:n,onCloseSessions:s,panes:r}){const{client:i,hasToken:l,connectionState:c,epoch:d,features:m,permissions:f,asks:h,pendingFetch:p,hydrateInteractions:g,responding:b,respondPermission:x,respondAsk:y}=Ae(),v=Ji(),j=ot(),{visibility:_}=aa();SL();const S=c==="open"&&l,w=m.includes("durable-resume"),{nodes:k,teamControl:N}=ut(),T=Yt(ue=>ue.loadRoster),R=e.sessionId&&e.sessionId!=="new"?e.sessionId:null,E=e.sessionId==="new",I=Yt(ue=>ue.roster),$=u.useMemo(()=>Nc(Se(I)??[]),[I]),C=u.useMemo(()=>YE(Se(I)??[]),[I]),L=Bt(),A=u.useMemo(()=>cv(lv(f,h),R,$).length,[f,h,R,$]),D=u.useMemo(()=>h.map(ue=>ue.requestId),[h]);av(D,S),YL(D,S);const O=u.useRef(new Set),F=u.useRef(void 0),V=Zi()<=na,[B,W]=u.useState(0),[Z,ee]=u.useState(0),[ie,le]=u.useState(null),[J,z]=u.useState(!1),me=pa({open:n,onClose:s,enabled:V,returnFocusId:"sessions-toggle"});u.useEffect(()=>{E&&W(ue=>ue+1)},[E]),u.useEffect(()=>{!R||!S||g()},[R,S,d,g]);const K=dq({client:i,hasToken:l,epoch:d,selectedId:R,routeSessionId:e.sessionId,durableFeature:w,connected:S,navigate:t,permissions:f,asks:h,nodes:k,teamControl:N,loadRoster:T,pendingNewSessions:O}),ne=Nq({client:i,connected:S,selectedId:R,epoch:d,navigate:t,loadSessions:K.loadSessions,loadRoster:T,nodes:k,teamControl:N,pendingNewSessions:O}),Ne=u.useMemo(()=>{const ue=K.selectedSession?.agent,xe=ue?K.agentAddressesById.get(ue.id):void 0;if(xe)return{node:xe.node,...xe.team?{team:xe.team}:{}};const De=Se(I)??[],ht=(De.find(ft=>ft.node.current)??De[0])?.node.name;return ht?{node:ht}:{}},[K.selectedSession,K.agentAddressesById,I]),ce=Tq({client:i,hasToken:l,epoch:d,selectedId:R,routeAgentId:e.agent,snapshot:v,runtimeVisibility:_,sessions:K.sessions,sessionDetail:K.sessionDetail,sessionDetailId:K.sessionDetailId,detailWindow:K.detailWindow,detailNotice:K.detailNotice,dismissDetailNotice:K.dismissDetailNotice,earlierError:K.earlierError,dismissEarlierError:K.dismissEarlierError,loadEarlierDetail:K.loadEarlierDetail,sessionDetailLoading:K.sessionDetailLoading,sessionDetailError:K.sessionDetailError,cancelling:ne.cancelling,cancelledJobs:ne.cancelledJobs,pendingNewSessions:O,loadSessionDetail:K.loadSessionDetail,refreshSessions:K.refreshSessions,permissions:f,asks:h}),se=u.useMemo(()=>new Set(K.sessionInflight.keys()),[K.sessionInflight]),we=Rq({entries:v.entries,sessionId:R,busySessions:se,onRetry:ue=>{ne.handleRetryPending(ue)}}),he=UP({sessionId:ce.activeAgent?null:R,client:i,epoch:d,connected:S,refreshKey:ne.sendTick+ce.visibleGroups.length+h.length}),pe=u.useRef(!1);u.useEffect(()=>{pe.current&&!ce.pendingActive&&W(ue=>ue+1),pe.current=ce.pendingActive},[ce.pendingActive]);const Me=u.useCallback(ue=>{R&&(ne.setInputForSession(R,xe=>xe.trim().length===0?ue:`${xe}
|
|
600
|
+
${ue}`),W(xe=>xe+1))},[R,ne.setInputForSession]),oe=u.useCallback(ue=>{t({domain:"chat",sessionId:ue}),s()},[t,s]),je=u.useCallback(()=>{t({domain:"chat",sessionId:"new"}),s()},[t,s]),Ee=u.useCallback(()=>{t({domain:"pending",...R?{sessionId:R}:{}})},[t,R]),Ce=u.useCallback(ue=>t({domain:"runs",tab:"live",sessionId:ue}),[t]),U=u.useCallback(()=>t({domain:"gateway"}),[t]),q=u.useCallback((ue,xe,De)=>{x(ue,xe,De)},[x]),M=u.useCallback((ue,xe)=>{y(ue,xe)},[y]),H=R?a("chat.target.session",{title:K.selectedSession?Sn(K.selectedSession):R}):a("chat.target.new"),X=ce.runningGroup,Y=S&&X?()=>{ne.handleCancel(X)}:void 0,re=VP({sessionId:ce.activeAgent?null:R,client:i,epoch:d,entries:v.entries,enabled:S}),_e=u.useCallback((ue,xe,De)=>{R&&le({kind:ue,sessionId:R,keepMessages:xe,text:De})},[R]),fe=u.useCallback((ue,xe)=>{_e("edit",ue,xe)},[_e]),Pe=u.useCallback((ue,xe)=>{_e("retry",ue,xe)},[_e]),ke=u.useCallback(ue=>{ne.quoteMessage(ue),W(xe=>xe+1),ee(xe=>xe+1)},[ne.quoteMessage]),Ge=async ue=>{const xe=K.primarySessionIds;xe.size===0||xe.has(ue)||await i.activateSession({session_id:ue})},mt=async()=>{const ue=ie;if(!ue||J)return;if(ue.sessionId!==R){le(null);return}z(!0);let xe;try{await Ge(ue.sessionId),xe=(await i.createSession({from_session_id:ue.sessionId,keep_messages:ue.keepMessages})).session_id,K.loadSessions(i,{epoch:d,force:!0})}catch(De){j.error(zt(De)),z(!1);return}if(le(null),z(!1),t({domain:"chat",sessionId:xe}),ue.kind==="edit"){const De=ba(ue.text);if(De!==null){ne.setInputForSession(xe,De.body);const Je=De.messageId!==void 0?ce.transcriptMessages.find(ht=>ht.message_id===De.messageId):void 0;Qe.getState().setQuote(Ut(xe),{...De.messageId!==void 0?{messageId:De.messageId}:{},snippet:De.snippet,source:Je?.role==="assistant"?"assistant":"user"})}else ne.setInputForSession(xe,ue.text);W(Je=>Je+1),j.success(a("chat.message.create.editDone"))}else ne.setInputForSession(xe,ue.text),await ne.handleRetry(ue.text,xe)},lt=u.useMemo(()=>L1(Se(I)??[]),[I]),de=Mq(ce.activeAgent?.id,ce.sessionAgents,R,lt),qe=u.useMemo(()=>{const ue=new Set;if(de===void 0)return ue;for(const[xe,De]of lt)De===de&&ue.add(xe);return ue},[lt,de]),Oe=EL(v.entries,de,qe);return o.jsx(DM,{client:i,enabled:S,epoch:d,...de!==void 0?{agentId:de}:{},children:o.jsxs("div",{className:"chat-workspace",children:[o.jsx(pP,{sessions:K.sessionWindow.shown,hiddenCount:K.sessionWindow.hiddenCount,listReset:`${d}:${K.renderLimit}:${K.query}`,selectedId:R,draftActive:E,pendingBySession:K.pendingBySession,inflightBySession:K.sessionInflight,pendingAskCount:A,onOpenPending:Ee,agentAddresses:K.agentAddresses,agentAddressesById:K.agentAddressesById,agentDepths:K.agentDepths,agentRoles:K.agentRoles,agentLabels:K.agentLabels,agentRetiredLabels:K.agentRetiredLabels,defaultSession:K.defaultSessionEntry,primarySessionIds:K.primarySessionIds,query:K.query,onQueryChange:K.setQuery,searchSnippets:K.activeServerSearch?.snippets,loading:K.sessionsLoading,error:K.sessionsError,onRetry:K.retryLoad,hasToken:l,onSelect:oe,onNew:je,onRename:K.handleRename,onDelete:K.openDelete,onViewRuns:Ce,onShowMore:K.showMore,compact:V,onCloseDrawer:s,onOpenConnection:U,writesDisabled:!S,renameSignal:K.renameSignal,sessionsOpen:n,drawerRef:me,panes:r}),o.jsxs("section",{className:"conversation","aria-label":a("chat.main.conversationLabel"),inert:V&&n?!0:void 0,children:[o.jsx("h1",{className:"sr-only",children:a("chat.main.heading")}),o.jsxs("div",{className:"content-stage",children:[!r.disabled("chat")&&o.jsx(kr,{pane:"chat",api:r,label:a("resize.chat"),className:"resize-handle resize-handle-content"}),o.jsx(mA,{selectedId:R,selectedSession:K.selectedSession,sessionDetail:K.sessionDetail,agents:ce.sessionAgents,activeAgentId:ce.activeAgent?.id,draftActive:E,onSelectAgent:ue=>{R&&t({domain:"chat",sessionId:R,...ue?{agent:ue}:{}})}}),R&&o.jsx(Fg,{slot:"session-detail",context:{session:R},className:"flex-none px-4 pb-2"}),o.jsx(xR,{names:C,children:o.jsx(wR,{names:L,children:o.jsx(AM,{client:i,sessionId:K.sessionDetail?.session_id??R??void 0,children:o.jsx(HP,{hasToken:l,selectedId:R,activeAgent:ce.activeAgent,draftActive:E,restorePending:K.restorePending,hydrateError:ce.hydrateError,hydrating:ce.hydrating,hydrateStale:ce.hydrateStale,hasTranscript:ce.hasTranscript,hasEarlier:ce.hasEarlier,visibleGroups:ce.visibleGroups,renderedGroups:ce.renderedGroups,transcriptWindow:ce.transcriptWindow,transcriptMessages:ce.transcriptMessages,historyIndex:ce.historyIndex,isHiddenMessage:ce.isHiddenMessage,noticeKindOf:ce.noticeKindOf,messageIndexOffset:ce.messageIndexOffset,sessionFailure:ce.sessionFailure,sessionSystemContext:ce.sessionSystemContext,projectionSummary:K.sessionDetail?.projection_summary,detailNotice:ce.detailNotice,onDismissDetailNotice:ce.dismissDetailNotice,earlierError:ce.earlierError,onDismissEarlierError:ce.dismissEarlierError,onRetryEarlier:()=>{R&&K.loadEarlierDetail(i,R,{epoch:d})},verbosity:ce.visibility.verbosity,cardsDefaultOpen:ce.cardsDefaultOpen,errorLevel:ce.errorLevel,entries:ce.activeAgent?v.entries:Aq,snapshotVersion:v.version,detailSessionId:K.sessionDetail?.session_id,sendTick:ne.sendTick,onRetryDetail:ce.reloadDetail,onLoadEarlier:ce.loadEarlier,onConfigureConnection:()=>t({domain:"gateway"}),onGoChat:()=>t({domain:"chat"}),onEditMessage:fe,onRetryMessage:Pe,onQuoteMessage:ke,quoteJumpRef:F,answeredAsks:ce.activeAgent?Lq:he,pendingSends:ce.activeAgent?hh:we.pending,onRetryPending:we.retry,onDismissPending:we.dismiss})})})}),!X&&o.jsx(sA,{count:re.count,jobIds:re.jobIds}),o.jsx(lP,{sessionId:R,agentId:de,client:i,epoch:d,refreshKey:ne.sendTick+ce.visibleGroups.length+Oe,pendings:ce.activeAgent?hh:we.pending,sentMessageIds:we.sentMessageIds,onRefillDraft:Me,onRetryPending:ue=>{ne.handleRetryPending(ue)},onEditPending:ue=>{Me(ue.text),we.dismiss(ue)},onDismissPending:we.dismiss,onReconcile:we.reconcile,onAttachMessage:we.attachMessage})]}),o.jsx(T1,{pendingItem:ce.pendingItem,pendingItems:ce.pendingItems,queueChips:ce.queueChips,responding:b,connected:S,onStop:Y,stopping:ce.stopBusy,onDecide:q,onRespondAsk:M,value:ne.input,onChange:ne.setInput,onSubmit:()=>{ne.handleSend()},submitting:ne.submitting,targetLabel:H,hasToken:l,onOpenConnection:()=>t({domain:"gateway"}),focusSignal:B,refs:ne.refs,onRemoveRef:ne.removeRef,onAddRef:ne.addRef,onUpdateRef:ne.updateRef,client:i,contextUsage:ce.contextUsage,memberModel:K.selectedSession?.agent?{agentId:K.selectedSession.agent.id,agentName:K.selectedSession.agent.name,currentModel:K.sessionDetail?.system_context?.model}:E?{draftModel:ne.draftModel,onDraftModelChange:ne.setDraftModel}:void 0,pendingFetch:p,onRetryPendingFetch:()=>{g()},sessionRefs:ne.sessionRefs,onRemoveSessionRef:ne.removeSessionRef,onAddSessionRef:ne.addSessionRef,quote:ne.quote,onRemoveQuote:ne.removeQuote,onJumpQuote:ue=>F.current?.(ue),quoteSignal:Z,currentScope:Ne,sessionId:R??void 0})]}),ie&&o.jsx(In,{title:ie.kind==="edit"?a("chat.message.create.editTitle"):a("chat.message.create.retryTitle"),body:ie.kind==="edit"?a("chat.message.create.editBody"):a("chat.message.create.retryBody"),confirmLabel:a("chat.message.create.confirm"),busy:J,onConfirm:()=>{mt()},onCancel:()=>{J||le(null)}}),K.deleteTarget&&o.jsx(E1,{target:K.deleteTarget,counts:K.deleteCounts,error:K.deleteError,connected:S,busy:K.deleteBusy,onConfirm:()=>{K.handleDelete()},onCancel:K.closeDelete,onViewRuns:()=>{const ue=K.deleteTarget;ue&&(K.closeDelete(),t({domain:"runs",tab:"durable",sessionId:ue.session_id}))}})]})})}function qq(e){switch(e){case"open":return a("nav.conn.online");case"connecting":return a("nav.conn.connecting");case"reconnecting":return a("nav.conn.reconnecting");case"closed":return a("nav.conn.closed");case"error":return a("nav.conn.error");default:return a("nav.conn.idle")}}function Oq(e){switch(e){case"connecting":return a("nav.conn.connecting");case"open":return a("status.connected");case"reconnecting":return a("nav.conn.reconnecting");case"closed":return a("nav.conn.closed");case"error":return a("nav.conn.error");default:return a("nav.conn.idle")}}function Dq(e){return a(e==="platform"?"connection.modePlatform":e==="legacy"?"connection.modeLegacy":"connection.modePending")}function Hq(){He();const{platformUrl:e,platformToken:t,nodeUrl:n,nodeToken:s,mode:r,platformError:i,devProxyAuth:l,gatewayError:c,tokenError:d,lastError:m,connectionState:f,hello:h,epoch:p,closeCode:g,hasToken:b,connect:x,disconnect:y,retry:v,clearTokenError:j}=Ae(),{current:_}=ut(),S=Bt(),w=ot(),k=r==="legacy",[N,T]=u.useState(e),[R,E]=u.useState(t),[I,$]=u.useState("");u.useEffect(()=>{r==="legacy"&&E(s)},[r]);const C=c??i,L=()=>{if(f==="open"&&N.trim()===e&&R.trim()===t&&I.trim()===""){v(),w.info(a("connection.reconnecting"));return}x(k?{platformUrl:N,token:R}:{platformUrl:N,token:R,nodeToken:I})&&w.info(a("connection.connecting"))};return o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsxs(et,{title:a("connection.title"),description:a(l?"settings.connection.devProxyNotice":"connection.description"),children:[o.jsxs("div",{className:"form-grid",children:[o.jsx(We,{label:a(k?"connection.nodeUrl":"connection.platformUrl"),htmlFor:"connection-url",error:!l&&C?o.jsx("span",{id:"connection-url-error",children:C}):void 0,hint:o.jsx("span",{className:"font-mono",children:a("connection.current",{url:Pn(k?n:e,window.location.origin)})}),children:o.jsx(Xe,{id:"connection-url",invalid:!l&&!!C,value:l?Pn(e,window.location.origin):N,onChange:A=>{l||(T(A.target.value),j())},readOnly:l,placeholder:a("connection.urlPlaceholder"),spellCheck:!1,autoComplete:"off","aria-describedby":!l&&C?"connection-url-error":void 0,onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),L())}})}),!l&&o.jsx(We,{label:a(k?"connection.nodeToken":"connection.platformToken"),htmlFor:"connection-token",error:d?o.jsx("span",{id:"connection-token-error",children:d}):void 0,children:o.jsx(Xe,{id:"connection-token",invalid:!!d,type:"password",value:R,onChange:A=>{E(A.target.value),j()},placeholder:a(k?"connection.nodeTokenPlaceholder":"connection.platformTokenPlaceholder"),spellCheck:!1,autoComplete:"off","aria-describedby":d?"connection-token-error":void 0,onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),L())}})}),!l&&!k&&o.jsx(We,{label:a("connection.nodeTokenOptional"),htmlFor:"connection-node-token",children:o.jsx(Xe,{id:"connection-node-token",type:"password",value:I,onChange:A=>{$(A.target.value),j()},placeholder:a("connection.nodeTokenPlaceholder"),spellCheck:!1,autoComplete:"off",onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),L())}})})]}),o.jsxs("div",{className:"form-actions",children:[!l&&o.jsx(G,{variant:"primary",onClick:L,children:a(f==="open"?"connection.reconnect":"connection.connect")}),o.jsx(G,{onClick:v,disabled:f==="open"||!b,children:a("connection.retryNow")}),!l&&o.jsx(G,{variant:"dangerGhost",onClick:()=>{y(),E(""),$(""),w.info(a("connection.disconnected"))},disabled:!b,children:a("connection.disconnect")})]}),m&&o.jsx("p",{className:"form-error",role:"alert",children:m}),i&&o.jsx("p",{className:"form-error",role:"alert",children:i})]}),o.jsxs(et,{title:a("connection.diagnostics"),children:[o.jsx(Gt,{items:[{key:"state",label:a("connection.state"),value:Oq(f)},{key:"mode",label:a("connection.mode"),value:Dq(r)},{key:"platform",label:a("connection.platformUrl"),value:o.jsx("span",{className:"font-mono",children:Pn(e,window.location.origin)})},{key:"node-url",label:a("connection.nodeUrl"),value:o.jsx("span",{className:"font-mono",children:Pn(n,window.location.origin)})},{key:"protocol",label:a("connection.protocol"),value:o.jsxs("span",{className:"font-mono",children:[h?`v${h.protocol.version}`:"—",h?.protocol.features.includes("tls")?" · TLS":""]})},{key:"node",label:a("connection.node"),value:o.jsx("span",{className:"font-mono",children:_?S.get(ge(_))??"—":"—"})},{key:"latestSeq",label:a("connection.latestSeq"),value:o.jsx("span",{className:"font-mono",children:h?h.latest_seq:"—"})},{key:"featureCount",label:a("connection.featureCount"),value:o.jsxs("span",{className:"font-mono",children:[h?.protocol.features.length??"—",h?a("connection.featureList",{features:h.protocol.features.join(", ")}):""]})},{key:"closeCode",label:"Close code",value:o.jsxs("span",{className:"font-mono",children:[g===null?"—":g,g===4401?a("connection.closeCodeToken"):g===4403?a("connection.closeCodeForbidden"):g===4400?a("connection.closeCodeProtocol"):""]})}]}),!h&&o.jsx("p",{className:"mt-1.5 max-w-prose text-md text-muted",children:a("connection.failureHint")})]}),o.jsx("p",{className:"sr-only","aria-live":"polite",children:p>0&&f==="open"?a("connection.connected"):""})]})}function $q(e,t=Date.now()){if(e===void 0||!Number.isFinite(e))return null;const n=t-e;if(n<0)return null;const s=Math.floor(n/1e3);if(s<60)return{key:"duration.seconds",params:{seconds:s}};const r=Math.floor(s/60);if(r<60)return{key:"duration.minutes",params:{minutes:r}};const i=Math.floor(r/60),l=r%60;return i<24?l===0?{key:"duration.hours",params:{hours:i}}:{key:"duration.hoursMinutes",params:{hours:i,minutes:l}}:{key:"duration.daysHours",params:{days:Math.floor(i/24),hours:i%24}}}function Fq(){return typeof window>"u"?"":window.location.origin}function Bq({navigate:e}){He();const{client:t,connectionState:n,hasToken:s,epoch:r,nodeUrl:i}=Ae(),{current:l}=ut(),{config:c,reloadConfig:d}=Qt(),m=Ft({load:()=>t.getHealth(),enabled:s,deps:[r],pollMs:15e3});Lt(()=>{d(),m.reload()});const f=Se(c),h=Se(m.state),p=new Map(l&&h?.node.name?[[ge(l),h.node.name]]:[]),g=Bt(p),b=l?g.get(ge(l))??h?.node.name?.trim()??"—":h?.node.name?.trim()||"—",x=m.state.status==="error"&&!h,y=x?"unreachable":h?"connected":"pending",v=a(x?"gateway.state.error":h?"gateway.state.ok":"gateway.state.connecting"),j=f?.version,_=$q(h?.node.started_at);return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsxs(Ct,{title:a("gateway.title"),subtitle:a("gateway.subtitle"),children:[o.jsx(Hq,{}),s?o.jsx("div",{className:"hub-view",children:o.jsxs("section",{className:"panel",children:[o.jsxs("dl",{className:"diag-list",children:[o.jsx("dt",{children:a("gateway.field.status")}),o.jsx("dd",{children:o.jsx(Tt,{status:y,label:v})}),o.jsx("dt",{children:a("gateway.field.connection")}),o.jsx("dd",{children:qq(n)}),o.jsx("dt",{children:a("gateway.field.endpoint")}),o.jsx("dd",{className:"mono",children:h?.node.endpoint||Pn(i,Fq())}),o.jsx("dt",{children:a("gateway.field.node")}),o.jsx("dd",{children:b}),o.jsx("dt",{children:a("gateway.field.version")}),o.jsx("dd",{className:"mono",children:j?`v${j}`:"—"}),o.jsx("dt",{children:a("gateway.field.startedAt")}),o.jsx("dd",{className:"mono",children:h&&bt(h.node.started_at)||"—"}),o.jsx("dt",{children:a("gateway.field.uptime")}),o.jsx("dd",{className:"mono",children:_?a(_.key,_.params):"—"})]}),m.state.status==="error"&&o.jsx("p",{className:"field-error",role:"alert",children:m.state.error}),c.status==="error"&&!f&&o.jsx("p",{className:"field-error",role:"alert",children:c.error}),o.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o.jsx(G,{size:"small",onClick:()=>e({domain:"observe",tab:"diagnostics"}),children:a("nav.diagnostics")}),o.jsx("span",{className:"text-sm text-muted",children:a("gateway.diagnosticsHint")})]})]})}):o.jsx(Fe,{title:a("gateway.noToken"),reason:a("gateway.noTokenReason")})]})})}function Kq(e,t){switch(e){case"invalid_url":return a("hub.connect.error.invalid");case"network":case"forbidden":return a("hub.connect.error.origin",{origin:t});default:return a("hub.connect.error.http")}}function Wq({defaultUrl:e,connecting:t,error:n,canClear:s,onSubmit:r,onClear:i}){const[l,c]=u.useState(e),[d,m]=u.useState(""),f=window.location.origin,h=()=>{t||r(l,d)};return o.jsx(et,{title:a("hub.connect.title"),description:a("hub.connect.description"),children:o.jsxs("div",{className:"flex max-w-xl flex-col gap-3",children:[o.jsx(We,{label:a("hub.connect.url"),htmlFor:"hub-url",hint:a("hub.connect.urlHint",{origin:f}),children:o.jsx(Xe,{id:"hub-url",value:l,onChange:p=>c(p.target.value),placeholder:"http://127.0.0.1:8643",spellCheck:!1,autoComplete:"off",invalid:n==="invalid_url",onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),h())}})}),o.jsx(We,{label:a("hub.connect.token"),htmlFor:"hub-token",hint:a("hub.connect.tokenHint"),error:n!==null?o.jsx("span",{children:Kq(n,f)}):void 0,children:o.jsx(Xe,{id:"hub-token",type:"password",value:d,onChange:p=>m(p.target.value),placeholder:a("hub.connect.tokenPlaceholder"),spellCheck:!1,autoComplete:"off",onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),h())}})}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(G,{variant:"primary",onClick:h,disabled:t,children:a(t?"hub.connect.connecting":"hub.connect.submit")}),s&&o.jsx(G,{onClick:i,disabled:t,children:a("hub.connect.clear")})]})]})})}const Uq={connecting:{kind:"pending",labelKey:"hub.node.status.connecting"},healthy:{kind:"connected",labelKey:"hub.node.status.healthy"},unreachable:{kind:"unreachable",labelKey:"hub.node.status.unreachable"},incompatible:{kind:"unavailable",labelKey:"hub.node.status.incompatible"},unauthorized:{kind:"failed",labelKey:"hub.node.status.unauthorized"},identity_mismatch:{kind:"failed",labelKey:"hub.node.status.identityMismatch"}};function zq(e){return e.name??e.alias??e.node_id}function Vq(e){return e.data_plane==="direct"?a("hub.directory.dataPlane.direct"):e.data_plane==="unreachable"?a("hub.directory.dataPlane.unreachable"):"—"}function Gq({directory:e,url:t,live:n,reconnecting:s,pointer:r,onDisconnect:i,onRetry:l}){return o.jsxs("div",{className:"flex flex-col gap-3",children:[!n&&o.jsx(st,{message:a(s?"hub.directory.reconnecting":"hub.directory.connecting"),onRetry:l}),r!==null&&o.jsx("p",{className:"text-sm text-info",role:"status","aria-live":"polite",children:a("hub.directory.pointer",{node:r.node_id})}),o.jsx(et,{title:a("hub.directory.title"),description:a("hub.directory.description",{url:t,hub:e.hub_id}),actions:o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(G,{onClick:l,children:a("common.retry")}),o.jsx(G,{onClick:i,children:a("hub.connect.clear")})]}),children:e.nodes.length===0?o.jsx($e,{title:a("hub.directory.empty"),description:a("hub.directory.emptyHint")}):o.jsx($n,{columns:[{key:"name",header:a("hub.directory.col.name"),cellClassName:"font-mono",cell:c=>zq(c)},{key:"status",header:a("hub.directory.col.status"),cell:c=>{const d=Uq[c.status];return o.jsx(Tt,{status:d.kind,label:a(d.labelKey)})}},{key:"teams",header:a("hub.directory.col.teams"),hide:"compact",cellClassName:"font-mono",cell:c=>c.counts.teams},{key:"agents",header:a("hub.directory.col.agents"),hide:"compact",cellClassName:"font-mono",cell:c=>c.counts.agents},{key:"liveAgents",header:a("hub.directory.col.liveAgents"),hide:"compact",cellClassName:"font-mono",cell:c=>c.counts.live_agents},{key:"lastSeen",header:a("hub.directory.col.lastSeen"),hide:"wide",cellClassName:"font-mono",cell:c=>bt(c.last_seen)||"—"},{key:"dataPlane",header:a("hub.directory.col.dataPlane"),hide:"compact",cell:Vq}],rows:e.nodes,rowKey:c=>c.node_id})})]})}function Yq(){const[e]=u.useState(()=>new Dp),t=u.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot);u.useEffect(()=>(e.connect(),()=>{e.close(),er(Dc().url!==""?"unknown":"unconfigured")}),[e]);const n=t.status,s=t.directory?.version;u.useEffect(()=>{er(n,s)},[n,s]);const r=u.useCallback(async c=>(await e.connect(c)).ok,[e]),i=u.useCallback(()=>e.disconnect(),[e]),l=u.useCallback(()=>{e.retry()},[e]);return{...t,connect:r,disconnect:i,retry:l}}function Jq(){He();const e=Yq(),t=window.location.origin;return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("hub.title"),subtitle:a("hub.subtitle"),children:e.status==="loading"?o.jsx(Ke,{label:a("hub.directory.loading")}):e.status==="connected"||e.status==="empty"?e.directory!==null?o.jsx(Gq,{directory:e.directory,url:e.url,live:e.live,reconnecting:e.reconnecting,pointer:e.pointer,onDisconnect:e.disconnect,onRetry:e.retry}):o.jsx($e,{title:a("hub.directory.empty"),description:a("hub.directory.emptyHint")}):e.status==="incompatible"?o.jsx(Fe,{title:a("hub.error.incompatible"),reason:a("hub.error.incompatibleReason"),action:o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(G,{onClick:e.retry,children:a("common.retry")}),o.jsx(G,{onClick:e.disconnect,children:a("hub.connect.clear")})]})}):e.status==="network"?o.jsx(Ve,{message:a("hub.error.origin",{origin:t}),onRetry:e.retry,action:o.jsx(G,{onClick:e.disconnect,children:a("hub.connect.clear")})}):o.jsxs("div",{className:"flex flex-col gap-3",children:[e.status==="unauthorized"&&o.jsx(Fe,{title:a("hub.error.unauthorized"),reason:a("hub.error.unauthorizedReason")}),o.jsx(Wq,{defaultUrl:e.url,connecting:e.connecting,error:e.connectError,canClear:e.url!=="",onSubmit:(n,s)=>{e.connect({url:n,token:s})},onClear:e.disconnect})]})})})}function Qq(){const{client:e,connectionState:t,hasToken:n,features:s,epoch:r}=Ae(),i=n&&t==="open",l=n&&s.includes("feishu"),c=Ft({load:()=>e.getFeishuStatus(),enabled:l,pollMs:1e4,deps:[r]});Lt(c.reload);const d=Se(c.state);if(!n)return o.jsx(Fe,{variant:"page",title:a("common.notConnected"),reason:a("integrations.channels.noTokenReason")});if(!s.includes("feishu"))return o.jsx(Fe,{variant:"page",title:a("integrations.channels.disabledTitle"),reason:a("integrations.channels.disabledReason"),hint:a("integrations.channels.disabledHint")});const m=c.state.status==="error"?c.state:null,f=m?.error??null;if(f&&!d){const h=m?.code;return h==="not_supported"||h==="channel_disabled"||h==="forbidden"?o.jsx(Fe,{variant:"page",title:a("integrations.channels.disabledTitle"),reason:a("integrations.channels.disabledReason"),hint:a("integrations.channels.disabledHint")}):o.jsx(Ve,{message:f,onRetry:c.reload})}return c.state.status==="idle"||c.state.status==="loading"&&!d?o.jsx(Ke,{label:a("integrations.channels.loading")}):d?o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("integrations.channels.globalDesc")}),!i&&o.jsx(st,{message:a("integrations.channels.stale"),onRetry:c.reload}),f&&o.jsx(st,{message:a("common.staleData",{detail:f}),onRetry:c.reload}),o.jsxs(et,{title:a("integrations.channels.title"),actions:o.jsx(Tt,{status:d.connected?"connected":"disconnected",label:Ri(d.connected?"connected":"disconnected")}),children:[o.jsx(Gt,{items:[{key:"app-id",label:"App ID",value:o.jsx("span",{className:"font-mono",children:d.appIdMasked||"—"})},{key:"active-chats",label:a("integrations.channels.activeChats"),value:o.jsx("span",{className:"font-mono",children:d.active_chats})},{key:"queued-messages",label:a("integrations.channels.queuedMessages"),value:o.jsx("span",{className:"font-mono",children:d.queued_messages})},{key:"last-error",label:a("integrations.channels.lastError"),value:d.last_error?o.jsx("span",{className:"text-danger",children:d.last_error}):o.jsx("span",{className:"text-muted",children:"—"})}]}),d.last_error&&o.jsx("p",{className:"mt-2.5 rounded-sm bg-danger-soft px-2.75 py-2 text-md text-danger",role:"alert",children:d.last_error}),o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("integrations.channels.noToggle")})]})]}):o.jsx($e,{title:a("integrations.channels.empty")})}function Qd(e){return e==="queued"||e==="running"}function Xd(e){return e==="interrupted"}function Xq(e){return[...e].sort((t,n)=>(n.started_at??0)-(t.started_at??0)||n.run_id.localeCompare(t.run_id))}function Zq(e){return[...e].sort((t,n)=>n.updated_at-t.updated_at||n.run_id.localeCompare(t.run_id))}function _y(e,t){return t==="all"||e===t}function Zd(e){return e.agent_id??e.session_id}function eO(e,{query:t="",status:n="all",sessionId:s,agentId:r}={}){const i=t.trim().toLowerCase();return e.filter(l=>!_y(l.status,n)||s&&l.session_id!==s||r&&Zd(l)!==r?!1:i?[l.run_id,l.session_id,l.output,l.error].some(c=>(c??"").toLowerCase().includes(i)):!0)}function tO(e,{query:t="",status:n="all",sessionId:s,agentId:r}={}){const i=t.trim().toLowerCase();return e.filter(l=>!_y(l.status,n)||s&&l.session_id!==s||r&&Zd(l)!==r?!1:i?[l.run_id,l.session_id,l.agent_id,l.preview].some(c=>(c??"").toLowerCase().includes(i)):!0)}function ph(e,t){return t<=0?{shown:[],hiddenCount:e.length}:t>=e.length?{shown:e.slice(),hiddenCount:0}:{shown:e.slice(0,t),hiddenCount:e.length-t}}function nO(e){const t=e instanceof Error?e.message:String(e);return e.code==="conflict"||t.includes("run_already_running")||t.includes("conflict")}const sO=5;function Kr(e,t=14){return e.length>t?`${e.slice(0,t)}…`:e}function oO({live:e,durable:t,openRun:n,cancel:s,resume:r,limit:i=sO}){const l=[];for(const d of e.filter(m=>Qd(m.status)).slice(0,i))l.push({id:`run-cancel-${d.run_id}`,group:"action",label:a("palette.action.cancelRun",{id:Kr(d.run_id)}),keywords:["cancel","run",d.session_id],hint:a("palette.hint.cancel"),danger:!0,confirm:{title:a("palette.confirm.cancelRunTitle"),body:a("palette.confirm.cancelRunBody"),confirmLabel:a("palette.action.cancelRunLabel")},run:()=>s(d.run_id)});for(const d of t.filter(m=>Xd(m.status)).slice(0,i))l.push({id:`run-resume-${d.run_id}`,group:"action",label:a("palette.action.resumeRunNamed",{id:Kr(d.run_id)}),keywords:["resume","durable","interrupted",d.session_id],hint:a("palette.hint.resume"),run:()=>r(d.run_id)});const c=new Set;for(const d of e.slice(0,i))c.has(d.session_id)||(c.add(d.session_id),l.push({id:`run-open-live-${d.run_id}`,group:"action",label:a("palette.action.openRun",{id:Kr(d.run_id)}),keywords:["open","run","detail",d.session_id],hint:a("palette.hint.run"),run:()=>n(d.run_id,"live",d.session_id)}));for(const d of t.slice(0,i))c.has(d.session_id)||(c.add(d.session_id),l.push({id:`run-open-durable-${d.run_id}`,group:"action",label:a("palette.action.openDurableRun",{id:Kr(d.run_id)}),keywords:["open","durable","run",d.session_id],hint:a("palette.hint.run"),run:()=>n(d.run_id,"durable",d.session_id)}));return l}function rO({servers:e,reconnect:t}){return e.filter(n=>n.status==="failed").map(n=>({id:`mcp-reconnect-${n.name}`,group:"action",label:a("palette.action.reconnectMcp",{name:n.name}),keywords:["mcp","reconnect","failed",n.name],hint:"MCP",run:()=>t(n.name)}))}function gh(e){return e instanceof Error?e.message:String(e)}function iO(){const{client:e,connectionState:t,hasToken:n,features:s,epoch:r}=Ae(),i=ot(),l=n&&t==="open",c=n&&s.includes("mcp-status"),[d,m]=u.useState(new Set),[f,h]=u.useState(!1),p=Ft({load:()=>e.listMcpServers(),enabled:c,pollMs:1e4,deps:[r]});Lt(p.reload);const g=u.useMemo(()=>Se(p.state)??[],[p.state]),b=g.filter(S=>S.status==="failed"),x=u.useCallback(async S=>{if(!l){i.error(a("integrations.mcp.reconnectDisconnected"));return}m(w=>new Set(w).add(S));try{await e.reconnectMcp(S),i.success(a("integrations.mcp.reconnectSuccess",{name:S})),p.reload()}catch(w){i.error(a("integrations.mcp.reconnectFailed",{name:S,detail:gh(w)}))}finally{m(w=>{const k=new Set(w);return k.delete(S),k})}},[e,l,p.reload,i]),y=u.useCallback(async()=>{if(!l||b.length===0)return;h(!0);let S=0;const w=[];for(const k of b){m(N=>new Set(N).add(k.name));try{await e.reconnectMcp(k.name),S+=1}catch(N){w.push(`${k.name}: ${gh(N)}`)}finally{m(N=>{const T=new Set(N);return T.delete(k.name),T})}}h(!1),p.reload(),w.length===0?i.success(a("integrations.mcp.reconnectAllSuccess",{count:S})):S===0?i.error(a("integrations.mcp.reconnectAllFailed",{detail:w.join("; ")})):i.error(a("integrations.mcp.reconnectPartial",{count:S,detail:w.join("; ")}))},[e,l,b,p.reload,i]),v=u.useMemo(()=>rO({servers:g,reconnect:S=>{x(S)}}),[g,x]);if(mi("integrations-mcp",v),!n)return o.jsx(Fe,{variant:"page",title:a("common.notConnected"),reason:a("integrations.mcp.noTokenReason")});if(!s.includes("mcp-status"))return o.jsx(Fe,{variant:"page",title:a("integrations.mcp.disabledTitle"),reason:a("integrations.mcp.disabledReason"),hint:a("integrations.mcp.disabledHint")});const j=p.state.status==="error"?p.state:null,_=j?.error??null;return o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("integrations.mcp.globalDesc")}),!l&&g.length>0&&o.jsx(st,{message:a("integrations.mcp.stale")}),_&&g.length>0&&o.jsx(st,{message:a("integrations.mcp.staleDetail",{detail:_}),onRetry:p.reload}),o.jsxs(En,{label:a("nav.domain.mcp"),children:[o.jsx(Re,{children:a("integrations.mcp.counts",{total:g.length,failed:b.length})}),o.jsx(G,{size:"small",disabled:!l||b.length===0||f,title:l?void 0:a("common.writesDisabled"),onClick:()=>{y()},children:f?a("integrations.mcp.reconnectAllBusy"):a("integrations.mcp.reconnectAll",{count:b.length})}),o.jsx(G,{size:"small",onClick:p.reload,children:a("common.refresh")})]}),_&&g.length===0?j?.code==="mcp_disabled"||j?.code==="not_supported"?o.jsx(Fe,{variant:"page",title:a("integrations.mcp.disabledTitle"),reason:a("integrations.mcp.disabledReason"),hint:a("integrations.mcp.disabledHint")}):o.jsx(Ve,{message:_,onRetry:p.reload}):p.state.status==="idle"||p.state.status==="loading"&&g.length===0?o.jsx(Ke,{label:a("integrations.mcp.loading")}):g.length===0?o.jsx($e,{title:a("integrations.mcp.emptyTitle"),description:a("integrations.mcp.emptyDesc")}):o.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3",children:g.map(S=>o.jsxs("article",{className:"flex flex-col gap-1.5 rounded-md bg-raised px-4 py-3.5 shadow-elev-1 forced-colors:border",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("h3",{className:"min-w-0 wrap-anywhere font-mono text-md font-medium text-ink",children:S.name}),o.jsx(Tt,{status:S.status})]}),o.jsx("p",{className:"text-sm leading-normal text-muted",children:a("integrations.mcp.toolsCount",{count:S.tools.length})}),S.tools.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:S.tools.map(w=>o.jsx(Re,{children:w},w))}),S.error&&o.jsx("p",{className:"text-danger",role:"alert",children:S.error}),S.status==="failed"&&o.jsx(G,{size:"small",className:"mt-1 self-start",disabled:!l||d.has(S.name),title:l?void 0:a("common.writesDisabled"),onClick:()=>{x(S.name)},children:d.has(S.name)?a("integrations.mcp.reconnecting"):a("integrations.mcp.reconnect")})]},S.name))})]})}function bh(e){if(!e.startsWith("mcp__"))return;const t=e.slice(5),n=t.indexOf("__");if(!(n<=0))return t.slice(0,n)}const aO="permissions.setToolPolicy",vh={autoApprove:[],neverAutoApprove:[]},fc=[{id:"auto",labelKey:"integrations.tools.policyAuto",hintKey:"integrations.tools.policyAutoHint"},{id:"ask",labelKey:"integrations.tools.policyAsk",hintKey:"integrations.tools.policyAskHint"},{id:"never",labelKey:"integrations.tools.policyNever",hintKey:"integrations.tools.policyNeverHint"}];function yh(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!==""):[]}function Ny(e){if(e===null||typeof e!="object")return vh;const t=e.permission;if(t===null||typeof t!="object")return vh;const n=t;return{autoApprove:yh(n.autoApprove),neverAutoApprove:yh(n.neverAutoApprove)}}function lO(e,t){const n=`${t}.`;return e.some(s=>s.startsWith(n))}function to(e,t){return e.neverAutoApprove.includes(t)?"never":e.autoApprove.includes(t)?"auto":"ask"}function Cy(e,t){return lO(e.neverAutoApprove,t)}function cO(e,t){const n=`${t}.`,s=new Set;for(const r of[...e.autoApprove,...e.neverAutoApprove])r.startsWith(n)&&s.add(r);return[...s].sort()}const dO=new Set(["inbox"]);function uO(e){return e?e.methods.some(t=>t.name===aO):!1}function Ty(e){return fc.find(t=>t.id===e)?.hintKey??"integrations.tools.policyAskHint"}const Ey={auto:"integrations.tools.policyAuto",ask:"integrations.tools.policyAsk",never:"integrations.tools.policyNever"},mO={...Ey,never:"integrations.tools.policyScopedNeverOn"};function Iy(e,t=!1){return(t?mO:Ey)[e]}function fO(e){return e==="never"?"integrations.tools.policyScopedNeverHint":Ty(e)}function xh(e){return e instanceof Error?e.message:String(e)}function hO({tool:e}){const{client:t,connectionState:n,hasToken:s}=Ae(),r=s&&n==="open",[i,l]=u.useState(!1),[c,d]=u.useState(null),{config:m,capabilities:f,reloadConfig:h,applyPermissionLists:p}=Qt({capabilities:!0}),g=Se(m),b=u.useMemo(()=>Ny(g?.config),[g]),x=g!==void 0,y=to(b,e.name),v=Cy(b,e.name),j=cO(b,e.name),_=f.status==="success"?uO(f.data):!1,S=f.status==="idle"||f.status==="loading",w=_&&r&&x&&!i,k=async(E,I)=>{if(!(!w||I===to(b,E))){l(!0),d(null);try{const $=await t.setToolPolicy(E,I);p({autoApprove:$.auto_approve,neverAutoApprove:$.never_auto_approve})}catch($){d({kind:"error",text:a("integrations.tools.policyFailed",{detail:xh($)})}),l(!1);return}try{await t.reload(["permission"]),d({kind:"ok",text:a("integrations.tools.policyApplied")})}catch($){d({kind:"error",text:a("integrations.tools.policyFailed",{detail:xh($)})})}finally{l(!1),h()}}},N=S?a("integrations.tools.policyChecking"):_?r?!x&&m.status==="error"?a("integrations.tools.policyLoadFailed",{detail:m.error}):dO.has(e.name)?a("integrations.tools.policyAlwaysAvailableNote"):a(v&&y==="ask"?"integrations.tools.policyScopedHint":Ty(y)):a("common.writesDisabled"):a("integrations.tools.policyUnsupported"),T=fc.map(E=>({id:E.id,label:a(E.labelKey)})),R=fc.map(E=>({id:E.id,label:a(Iy(E.id,!0))}));return o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("span",{className:"font-mono text-2xs uppercase tracking-widest text-faint",children:a("integrations.tools.policyLabel")}),o.jsx("div",{"aria-busy":i||void 0,children:o.jsx(Nn,{label:a("integrations.tools.policyLabel"),tabs:T,value:y,onChange:E=>{k(e.name,E)},disabled:!w})}),o.jsx("p",{className:"m-0 text-xs leading-snug text-muted wrap-anywhere",children:i?a("integrations.tools.policySaving"):N}),j.length>0&&o.jsxs("div",{className:"mt-1 flex flex-col gap-2",children:[o.jsx("span",{className:"font-mono text-2xs uppercase tracking-widest text-faint",children:a("integrations.tools.policyScopedLabel")}),j.map(E=>{const I=to(b,E);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"font-mono text-xs break-words text-ink",children:E}),o.jsx(Nn,{label:E,tabs:R,value:I,onChange:$=>{k(E,$)},disabled:!w}),I==="never"&&o.jsx("p",{className:"m-0 text-xs leading-snug text-muted wrap-anywhere",children:a(fO("never"))})]},E)})]}),c&&o.jsx("p",{className:c.kind==="ok"?"m-0 rounded-sm bg-success-soft px-2.5 py-1.5 text-xs text-success":"m-0 rounded-sm bg-danger-soft px-2.5 py-1.5 text-xs text-danger",role:c.kind==="ok"?"status":"alert",children:c.text})]})}function wh({tool:e,lists:t}){const n=to(t,e),s=Cy(t,e),r=n==="auto"?"success":n==="never"?"warn":"neutral";return o.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1",children:[o.jsx(Re,{tone:r,children:a(Iy(n))}),s&&o.jsx(Re,{tone:"warn",children:a("integrations.tools.policyScopedNever")})]})}function pO(){const{client:e,connectionState:t,hasToken:n,epoch:s}=Ae(),r=n&&t==="open",[i,l]=u.useState(""),[c,d]=u.useState(!1),[m,f]=u.useState(null),h=Ft({load:()=>e.listTools(),enabled:n,deps:[s]}),{config:p,reloadConfig:g}=Qt();Lt(h.reload),Lt(g);const b=u.useMemo(()=>Se(h.state)??[],[h.state]),x=Se(p),y=u.useMemo(()=>Ny(x?.config),[x]),v=x!==void 0,j=u.useMemo(()=>v?b.filter(k=>to(y,k.name)!=="auto").length:0,[b,y,v]),_=u.useMemo(()=>{const k=i.trim().toLowerCase();return b.filter(N=>c&&v&&to(y,N.name)==="auto"?!1:k?N.name.toLowerCase().includes(k)||N.description.toLowerCase().includes(k):!0)},[b,i,c,y,v]),S=h.state.status==="error"?h.state.error:null,w=m?bh(m.name):void 0;return n?S&&b.length===0?o.jsx(Ve,{message:S,onRetry:h.reload}):h.state.status==="idle"||h.state.status==="loading"&&b.length===0?o.jsx(Ke,{label:a("integrations.tools.loading")}):o.jsxs("div",{className:"flex flex-col gap-6",children:[!r&&b.length>0&&o.jsx(st,{message:a("integrations.tools.stale"),onRetry:h.reload}),S&&b.length>0&&o.jsx(st,{message:a("common.staleData",{detail:S}),onRetry:h.reload}),o.jsxs(En,{label:a("integrations.tools.searchLabel"),children:[o.jsx(Tn,{value:i,onChange:l,placeholder:a("integrations.tools.searchPlaceholder"),ariaLabel:a("integrations.tools.searchLabel"),className:"grow basis-60 max-w-search"}),v&&o.jsx(G,{variant:"chip",size:"small","aria-pressed":c,onClick:()=>d(k=>!k),children:a("integrations.tools.onlyConfirm",{count:j})}),o.jsxs("span",{className:"ml-1.5 inline-block rounded-full bg-sunken px-1.5 py-0.5 font-mono text-xs text-muted",children:[_.length,"/",b.length]})]}),b.length===0?o.jsx($e,{title:a("integrations.tools.empty")}):_.length===0?o.jsx($e,{title:a("integrations.tools.noMatch"),action:o.jsx(G,{onClick:()=>{l(""),d(!1)},children:a("common.clearFilters")})}):o.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3",children:_.map(k=>{const N=bh(k.name);return o.jsx("article",{className:"flex",children:o.jsxs("button",{type:"button",className:"flex min-h-control w-full items-center gap-2 rounded-md border border-transparent bg-raised px-3 py-2.5 text-left text-muted shadow-elev-1 transition-colors duration-150 hover:bg-surface-hover hover:shadow-elev-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface pointer-coarse:min-h-touch forced-colors:border","aria-haspopup":"dialog",title:a("integrations.tools.openDetails",{name:k.name}),onClick:()=>f(k),children:[o.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[o.jsx("span",{className:"min-w-0 break-words font-mono text-sm font-medium text-ink",children:k.name}),v&&o.jsx(wh,{tool:k.name,lists:y}),N&&o.jsxs(Re,{children:["MCP · ",N]})]}),o.jsx("span",{className:"flex-none font-mono text-sm leading-none text-faint","aria-hidden":"true",children:"›"}),o.jsx("span",{className:"sr-only",children:a("integrations.tools.openDetails",{name:k.name})})]})},k.name)})}),m&&o.jsxs(tn,{label:a("integrations.tools.dialogLabel",{name:m.name}),onClose:()=>f(null),closeLabel:a("common.close"),size:"md",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 pr-8",children:[o.jsx("h2",{className:"m-0 min-w-0 break-words font-mono text-lg font-medium text-ink",children:m.name}),v&&o.jsx(wh,{tool:m.name,lists:y}),w&&o.jsxs(Re,{children:["MCP · ",w]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"font-mono text-xs uppercase tracking-wide text-faint",children:a("integrations.tools.details")}),m.description&&o.jsx("p",{className:"m-0 text-md leading-relaxed text-muted",children:m.description})]}),o.jsx(hO,{tool:m}),o.jsx(id,{value:m.input_schema,label:a("integrations.tools.schema"),maxHeight:320,open:!0})]})]}):o.jsx(Fe,{variant:"page",title:a("common.notConnected"),reason:a("integrations.tools.noTokenReason")})}const gO={tools:"integrations.tools.subtitle",mcp:"integrations.mcp.subtitle",channels:"integrations.channels.subtitle"};function bO({domain:e}){return He(),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsxs(Ct,{title:a(`nav.domain.${e}`),subtitle:a(gO[e]),children:[e==="tools"&&o.jsx(pO,{}),e==="mcp"&&o.jsx(iO,{}),e==="channels"&&o.jsx(Qq,{})]})})}const vO=120;function yO({task:e,archiving:t,onAccept:n}){const[s,r]=u.useState(!1),i=(e.progress?.length??0)>vO;return o.jsxs("article",{className:"flex flex-col gap-2 rounded-md bg-raised px-4 py-3.5 shadow-elev-1 forced-colors:border",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 flex-none accent-accent",checked:!1,disabled:t,onChange:()=>n(e),"aria-label":a("kanban.acceptAria",{title:e.title}),title:a("kanban.accept")}),o.jsx("h3",{className:"min-w-0 text-md font-medium leading-snug text-ink",children:e.title})]}),(e.owner||e.branch)&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[e.owner&&o.jsx(Re,{children:e.owner}),e.branch&&o.jsx(Re,{children:e.branch})]}),e.progress&&o.jsxs("div",{className:"pl-6",children:[o.jsx("p",{className:be("whitespace-pre-wrap text-sm leading-relaxed text-muted",!s&&i&&"line-clamp-3"),children:e.progress}),i&&o.jsx(G,{variant:"link",className:"mt-1 text-xs",onClick:()=>r(l=>!l),"aria-expanded":s,children:a(s?"kanban.collapseProgress":"kanban.expandProgress")})]})]})}const xO=3e4,wO="__uncategorized__";function kO(e){if(!e)return;const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function SO(){const e=He(),{client:t,hasToken:n,epoch:s}=Ae(),r=ot(),i=u.useRef(void 0),l=u.useRef(void 0),c=u.useRef(!0),d=Ft({load:async()=>{const w=c.current;c.current=!0;const k=R=>{const E={board:R.board,path:R.path,mtimeMs:R.mtime_ms,sizeBytes:R.size_bytes};return i.current={mtimeMs:R.mtime_ms,sizeBytes:R.size_bytes},l.current=E,E},N=i.current;if(w&&N){const R=await t.rpc("kanban.get",{if_mtime_ms:N.mtimeMs,if_size_bytes:N.sizeBytes});if(R.unchanged){const E=l.current;if(E)return{...E,mtimeMs:R.mtime_ms,sizeBytes:R.size_bytes}}else return k(R)}const T=await t.rpc("kanban.get",{});if(T.unchanged)throw new Error("kanban.get: unexpected unchanged on unconditional read");return k(T)},enabled:n,pollMs:xO,pauseWhenHidden:!0,deps:[s]}),m=u.useCallback(()=>{c.current=!1,d.reload()},[d.reload]);Lt(m);const[f,h]=u.useState(null),[p,g]=u.useState(!1),b=u.useCallback(async()=>{const w=f;if(!(!w||p)){g(!0);try{const k=await t.rpc("kanban.archive",{id:w.id}),N={board:k.board,path:l.current?.path??"",mtimeMs:k.mtime_ms,sizeBytes:k.size_bytes};i.current={mtimeMs:k.mtime_ms,sizeBytes:k.size_bytes},l.current=N,h(null),r.success(a("kanban.archived",{title:w.title})),c.current=!1,d.reload()}catch(k){r.error(a("kanban.archiveFailed",{message:k instanceof Error?k.message:String(k)}))}finally{g(!1)}}},[f,p,t,r,d.reload]),x=Se(d.state),y=x?.board,v=u.useMemo(()=>{if(!y)return[];const w=new Set(y.columns),k=y.columns.map(T=>({key:T,title:T,tasks:y.tasks.filter(R=>R.column===T)})),N=y.tasks.filter(T=>!w.has(T.column));return N.length>0&&k.push({key:wO,title:a("kanban.uncategorized"),tasks:N}),k},[y,e]);if(!n)return o.jsx(Fe,{variant:"page",title:a("common.notConnected"),reason:a("kanban.noTokenReason")});const j=d.state.status==="error"?d.state.error:null,_=d.state.status==="error"?d.state.code:void 0,S=kO(y?.updated);return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsxs(Ct,{title:a("nav.domain.kanban"),subtitle:a("kanban.subtitle"),children:[d.state.status==="loading"&&!x&&o.jsx(Ke,{}),j&&!x&&(_==="not_found"||_==="not_supported")&&o.jsx($e,{title:a("kanban.notFound"),description:j,action:o.jsx(G,{onClick:m,children:a("common.retry")})}),j&&!x&&_!=="not_found"&&_!=="not_supported"&&o.jsx(Ve,{message:j,onRetry:m}),y&&o.jsxs(o.Fragment,{children:[j&&o.jsx(st,{message:j,onRetry:m}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[o.jsx("span",{className:"text-md font-medium text-ink",children:y.board}),S&&o.jsx("span",{className:"text-sm text-faint",children:a("kanban.updated",{time:S})}),o.jsx(Hn,{count:y.tasks.length,label:a("kanban.taskCount",{count:y.tasks.length})}),o.jsx("span",{className:"flex-1"}),o.jsx(G,{onClick:m,disabled:d.state.status==="loading",children:a("kanban.refresh")})]}),y.warnings.length>0&&o.jsxs("details",{className:"rounded-sm bg-warn-soft px-3 py-2 text-sm text-warn",children:[o.jsx("summary",{className:"cursor-pointer",children:a("kanban.warnings",{count:y.warnings.length})}),o.jsx("ul",{className:"mt-2 flex flex-col gap-1 font-mono text-xs",children:y.warnings.map(w=>o.jsx("li",{children:w},w))})]}),y.tasks.length===0?o.jsx($e,{title:a("kanban.empty"),description:a("kanban.emptyHint")}):o.jsx("div",{className:"grid grid-cols-1 items-start gap-4 md:grid-cols-3",children:v.map(w=>o.jsxs("section",{className:"flex min-w-0 flex-col gap-2.5",children:[o.jsxs("header",{className:"flex items-center gap-2",children:[o.jsx("h2",{className:"text-sm font-semibold text-ink",children:w.title}),o.jsx(Hn,{count:w.tasks.length})]}),o.jsx("div",{className:"flex flex-col gap-2.5",children:w.tasks.length===0?o.jsx("p",{className:"rounded-md bg-sunken p-3 text-sm text-faint",children:a("kanban.emptyColumn")}):w.tasks.map(k=>o.jsx(yO,{task:k,archiving:p,onAccept:h},k.id))})]},w.key))})]}),f&&o.jsx(In,{title:a("kanban.confirmTitle"),body:a("kanban.confirmBody",{title:f.title}),confirmLabel:a("kanban.confirmAction"),busy:p,onConfirm:()=>{b()},onCancel:()=>h(null)})]})})}const jO=[{id:"pair",label:"hub.add.pairNode",command:"hub.add.pairCommand"},{id:"add",label:"hub.add.addToHub",command:"hub.add.addCommand"},{id:"join-code",label:"hub.add.joinCode",command:"hub.add.joinCodeCommand"},{id:"join",command:"hub.add.joinCommand"}];function _O({onClose:e}){He();const t=ot(),{addNode:n}=ut(),[s,r]=u.useState(""),[i,l]=u.useState(""),[c,d]=u.useState(""),[m,f]=u.useState(null),h=p=>{p.preventDefault();const g=n({name:s,url:i,token:c});if(!g.ok){f(g.error??null);return}t.info(a("settings.multinode.added",{name:s.trim()})),e()};return o.jsxs(tn,{label:a("hub.add.title"),onClose:e,closeLabel:a("common.close"),children:[o.jsx("h2",{className:"modal-title",children:a("hub.add.title")}),o.jsx("p",{className:"mt-2 max-w-prose text-md leading-relaxed text-muted",children:a("hub.add.description")}),o.jsxs("section",{className:"mt-5 flex flex-col gap-2","aria-label":a("nodes.add.commands"),children:[o.jsx("h3",{className:"m-0 text-sm font-semibold text-ink",children:a("nodes.add.commands")}),o.jsx("ul",{className:"net-commands",children:jO.map(p=>o.jsxs("li",{className:"net-command",children:[o.jsx("span",{className:"net-command-label",children:p.label?a(p.label):""}),o.jsx("code",{className:"net-command-text font-mono",children:a(p.command)}),o.jsx(ls,{text:a(p.command),label:a("common.copy"),toast:a("common.copied")})]},p.id))})]}),o.jsxs("section",{className:"mt-5 flex flex-col gap-2","aria-label":a("nodes.add.connect"),children:[o.jsx("h3",{className:"m-0 text-sm font-semibold text-ink",children:a("nodes.add.connect")}),o.jsxs("form",{className:"form-grid mt-0",onSubmit:h,children:[o.jsx(We,{label:a("settings.multinode.name"),htmlFor:"add-node-name",children:o.jsx(Xe,{id:"add-node-name",invalid:m==="name_required"||m==="name_duplicate",value:s,onChange:p=>{r(p.target.value),f(null)},placeholder:a("settings.multinode.namePlaceholder"),spellCheck:!1,autoComplete:"off"})}),o.jsx(We,{label:a("settings.multinode.url"),htmlFor:"add-node-url",children:o.jsx(Xe,{id:"add-node-url",invalid:m==="url_invalid",value:i,onChange:p=>{l(p.target.value),f(null)},placeholder:a("settings.multinode.urlPlaceholder"),spellCheck:!1,autoComplete:"off"})}),o.jsx(We,{label:a("settings.multinode.token"),htmlFor:"add-node-token",hint:a("settings.multinode.storageHint"),children:o.jsx(Xe,{id:"add-node-token",invalid:m==="token_required",type:"password",value:c,onChange:p=>{d(p.target.value),f(null)},placeholder:a("settings.multinode.tokenPlaceholder"),spellCheck:!1,autoComplete:"new-password"})}),o.jsxs("div",{className:"form-actions col-span-full justify-end mt-0",children:[o.jsx(G,{onClick:e,children:a("common.cancel")}),o.jsx(G,{type:"submit",variant:"primary",disabled:!s.trim()||!c.trim(),children:a("settings.multinode.add")})]})]}),m&&o.jsx("p",{className:"text-xs text-danger leading-snug",role:"alert",children:a(`settings.multinode.error.${m}`)})]})]})}function NO(e){return e.startsWith("#")?e.slice(1):e}function Ry(e){const[t="",n=""]=NO(e).split("?",2);return{segments:t.split("/").filter(Boolean),query:new URLSearchParams(n)}}function hc(e){if(e!==void 0)try{return decodeURIComponent(e)}catch{return e}}function CO(e,t){return`#/teams/${encodeURIComponent(e)}/${encodeURIComponent(t)}/edit`}function kh(e,t,n){const{segments:s}=Ry(e);return!(s[0]!=="teams"||s[3]!=="edit"||t!==void 0&&hc(s[1])!==t||n!==void 0&&hc(s[2])!==n)}function TO(e){return`#/teams?${new URLSearchParams({node:e}).toString()}`}function cl(e){const{query:t}=Ry(e),n=t.get("node");if(!(n===null||n===""))return hc(n)}function Ly(e,t){return e?.health?"connected":e?.error?"unreachable":t.status==="up"?"connected":t.status==="down"?"unreachable":"pending"}function Ay(e,t){return e?.health?a("nodes.health.ok"):e?.error?a("nodes.health.error"):t.status==="up"?a("nodes.health.ok"):t.status==="down"?a("nodes.health.error"):t.status==="unknown"?a("nodes.health.unknown"):a("nodes.health.loading")}function EO({nodeKey:e,navigate:t}){He();const{hello:n,mode:s,selectPlatformNode:r}=Ae(),i=s==="platform",{nodes:l,fetchHealth:c}=ut(),d=l.find(N=>ge(N)===e),m=Dt(N=>N.health),f=Dt(N=>N.select),h=d?Xo(m,d):void 0,p=h?.health,g=h?.error;u.useEffect(()=>{f(e)},[e,f]);const b=Bt();if(!d)return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("nodes.title"),children:o.jsx(Fe,{title:a("nodes.notFound"),reason:a("nodes.notFoundHint"),action:o.jsx(G,{variant:"primary",onClick:()=>t({domain:"nodes"}),children:a("nodes.back")})})})});const x=b.get(e)??"—",y=Ly(h,d),v=Ay(h,d),j=p?a("nodes.dataPlane.direct"):g?a("nodes.dataPlane.unreachable"):d.status!==void 0?v:a("nodes.health.loading"),_=p?bt(h?.updatedAt)||"—":g?a("nodes.health.error"):d.status!==void 0?v:a("nodes.health.loading"),S=()=>{d&&Dt.getState().loadHealth([d],c)},w=p?.node.node_id??d.nodeId??"—",k=d.current?n?.incarnation??"—":"—";return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain p-6 pb-10 max-compact:px-3 max-compact:pt-4 max-compact:pb-7 [&>*]:mx-auto [&>*]:w-full [&>*]:max-w-[var(--content-max)]",children:[o.jsx(xr,{title:x,current:d.current,status:o.jsx(Tt,{status:y,label:v})}),o.jsxs(En,{label:a("nodes.detailActions"),className:"mt-3",children:[i&&!d.current&&o.jsx(G,{variant:"primary",onClick:()=>{d.nodeId&&r(d.nodeId)},children:a("nodes.select")}),o.jsx(G,{onClick:()=>{window.location.hash=TO(e)},children:a("nodes.viewTeams")}),o.jsx(G,{onClick:()=>t({domain:"agents",nodeKey:e}),children:a("nodes.viewAgents")}),o.jsx(G,{onClick:()=>t({domain:"nodes"}),children:a("nodes.back")})]}),o.jsxs("div",{className:"mt-5 flex flex-col gap-4",children:[o.jsxs(et,{title:a("nodes.section.health"),children:[o.jsx(Gt,{items:[{key:"dataPlane",label:a("nodes.section.dataPlane"),value:j},{key:"heartbeat",label:a("nodes.lastHeartbeat"),value:o.jsx("span",{className:"font-mono",children:_})}]}),g&&o.jsx("p",{className:"text-xs text-danger leading-snug",role:"alert",children:g})]}),o.jsx(et,{children:p?o.jsxs("details",{className:"mt-3 border-t border-line pt-2",children:[o.jsx("summary",{className:"cursor-pointer text-sm text-faint",children:a("nodes.advanced")}),o.jsx(Gt,{className:"mt-2",items:[{key:"nodeId",label:a("nodes.field.nodeId"),value:o.jsx("span",{className:"font-mono",children:w})},{key:"endpoint",label:a("nodes.field.endpoint"),value:o.jsx("span",{className:"font-mono",children:p.node.endpoint||"—"})},{key:"pid",label:a("nodes.field.pid"),value:o.jsx("span",{className:"font-mono",children:p.node.pid})},{key:"startedAt",label:a("nodes.field.startedAt"),value:o.jsx("span",{className:"font-mono",children:bt(p.node.started_at)||"—"})},{key:"role",label:a("nodes.field.role"),value:o.jsx("span",{className:"font-mono",children:p.node.role})},{key:"protocol",label:a("nodes.field.protocol"),value:o.jsxs("span",{className:"font-mono",children:[p.protocol.name," v",p.protocol.version]})},{key:"incarnation",label:a("nodes.field.incarnation"),value:o.jsx("span",{className:"font-mono",children:k})}]})]}):g?o.jsx(Ve,{message:g,onRetry:S}):o.jsx(Ke,{label:a("nodes.health.loading"),rows:2})})]})]})}function IO(){return typeof window>"u"?"":window.location.origin}const RO=2e4;function LO({route:e,navigate:t}){He();const{nodes:n}=ut();return e.nodeKey!==void 0?o.jsx(EO,{nodeKey:e.nodeKey,navigate:t}):o.jsx(AO,{nodes:n,navigate:t})}function AO({nodes:e,navigate:t}){He();const{removeNode:n}=ut(),{mode:s,nodeSelection:r,selectPlatformNode:i}=Ae(),l=s==="platform",c=Dt(k=>k.health),[d,m]=u.useState(""),[f,h]=u.useState(!1),[p,g]=u.useState(null),b=e.map(k=>Xo(c,k)).filter(k=>k!==void 0),x=e.length>0&&e.every(k=>{const N=Xo(c,k);return N?.health!==void 0||N?.error!==void 0||k.status!==void 0}),y=u.useMemo(()=>new Map(b.map(k=>[ge(k.node),k])),[b]),v=Bt(),j=e.find(k=>k.current),_=u.useMemo(()=>e.filter(k=>{const N=ge(k);return Nj(v.get(N)??"—",k.nodeId??N,k.name,d)}),[e,v,d]),S=k=>t({domain:"nodes",nodeKey:ge(k)});let w;return e.length===0?w=l?o.jsx($e,{title:a("nodes.platform.empty")}):o.jsx($e,{title:a("nodes.empty"),action:o.jsx(G,{variant:"primary",onClick:()=>h(!0),children:a("hub.add.title")})}):x?_.length===0?w=o.jsx($e,{title:a("nodes.emptyFiltered",{query:d.trim()}),action:o.jsx(G,{onClick:()=>{m("")},children:a("team.list.clearSearch")})}):w=o.jsx("ul",{className:"entity-card-grid",children:_.map(k=>o.jsx(MO,{node:k,displayName:v.get(ge(k))??"—",entry:y.get(ge(k)),platformMode:l,onOpen:()=>S(k),...k.current?{}:l?{onSelect:()=>{k.nodeId&&i(k.nodeId)}}:{onRemove:()=>g(k)}},ge(k)))}):w=o.jsx(Ke,{label:a("common.loading"),rows:2}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:[o.jsxs(Ct,{title:a("nodes.title"),subtitle:a("nodes.subtitle"),children:[l&&r.fallback!==null&&j&&o.jsx("p",{className:"mb-3 text-sm text-warn",role:"status",children:a(`nodes.selection.fallback.${r.fallback}`,{node:v.get(ge(j))??j.name})}),e.length>0&&o.jsxs(En,{label:a("nodes.search"),children:[o.jsx(Tn,{value:d,onChange:m,placeholder:a("nodes.search"),ariaLabel:a("nodes.search"),className:"grow basis-60 max-w-search"}),!l&&o.jsx(G,{variant:"primary",className:"ml-auto",onClick:()=>h(!0),children:a("hub.add.title")})]}),w]}),f&&o.jsx(_O,{onClose:()=>h(!1)}),p&&o.jsx(In,{title:a("hub.remove.title"),body:o.jsx("p",{children:a("hub.remove.body")}),confirmLabel:a("common.remove"),danger:!0,onConfirm:()=>{n(p.name),g(null)},onCancel:()=>g(null)})]})}function MO({node:e,displayName:t,entry:n,platformMode:s,onOpen:r,onRemove:i,onSelect:l}){He();const{epoch:c}=Ae(),{teamControl:d}=ut(),m=ge(e),f=VR(e),h=St(v=>v.loadList);qt(()=>{h(e,d(e))},{enabled:!s||e.current,pollMs:RO,deps:[c,m]});const p=Cd(f)?.teams,g=p?{teams:p.length,agents:p.reduce((v,j)=>v+j.member_count,0),online:p.reduce((v,j)=>v+(j.online_count??0),0)}:null,b=Ly(n,e),x=Ay(n,e),y=n?.health?a("hub.nodes.heartbeat",{time:bt(n.updatedAt)||a("nodes.health.loading")}):n?.error?a("nodes.health.error"):"";return o.jsxs("li",{className:"min-w-0",children:[o.jsxs("button",{type:"button",className:Kh,onClick:r,children:[o.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[o.jsxs("span",{className:"inline-flex min-w-0 flex-wrap items-center gap-2 wrap-anywhere text-md font-semibold text-ink",children:[t,e.current&&o.jsxs("span",{className:"text-2xs text-faint",title:a("entity.currentNode"),children:[o.jsx("span",{"aria-hidden":"true",children:"· "}),a("entity.currentNode")]})]}),o.jsx("span",{className:"min-w-0 wrap-anywhere font-mono text-xs text-faint",children:Pn(e.url,IO())})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-sm tabular-nums text-muted",children:[o.jsx(Tt,{status:b,label:x}),(!s||e.current)&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{children:[o.jsx("strong",{className:"font-semibold text-ink",children:g?g.teams:"—"})," ",a("nodes.field.teams")]}),o.jsxs("span",{children:[o.jsx("strong",{className:"font-semibold text-ink",children:g?g.agents:"—"})," ",a("nodes.field.agents")]}),o.jsxs("span",{children:[o.jsx("strong",{className:"font-semibold text-ink",children:g?g.online:"—"})," ",a("nodes.field.online")]})]})]}),y!==""&&o.jsx("span",{className:"min-w-0 wrap-anywhere text-xs text-faint",children:y})]}),i&&o.jsx(G,{size:"small",variant:"dangerGhost",className:"mt-1.5 ml-4",onClick:i,children:a("common.remove")}),l&&o.jsx(G,{size:"small",className:"mt-1.5 ml-4",onClick:l,children:a("nodes.select")})]})}function My({item:e,onOpen:t,readonly:n}){const s=new Date(e.created_at),r=Number.isNaN(s.getTime())?void 0:s.toISOString(),i=o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"attention-kind mono",children:e.kind}),o.jsx("span",{className:"attention-request mono",title:e.request_id,children:e.request_id}),o.jsx("span",{className:"attention-cell mono",children:e.tool??"—"}),o.jsx("span",{className:"attention-cell mono",children:e.agent_id??"—"}),o.jsx("span",{className:"attention-cell mono",children:e.team_id??"—"}),o.jsx("time",{className:"attention-time mono",...r?{dateTime:r}:{},children:bt(e.created_at)||"—"})]});return o.jsx("li",{className:"attention-item",children:t?o.jsx("button",{type:"button",className:"attention-row attention-row-open",onClick:t,children:i}):o.jsx("div",{className:"attention-row",...n?{title:a("observe.attention.remoteRowHint")}:{},children:i})})}const Oi=20;function Di(e,t){const n=new Set(e.map(r=>r.request_id)),s=[...e];for(const r of t)!r.request_id||n.has(r.request_id)||(n.add(r.request_id),s.push(r));return s}function Py(e,t){if(e==="unauthorized"||e==="forbidden")return!0;const n=t?.trim()??"";return n==="HTTP 401"||n==="HTTP 403"}function PO(){return typeof window>"u"?"":window.location.origin}function qy(e,t){return e.session_id?{domain:"chat",sessionId:e.session_id}:e.team_id?{domain:"teams",nodeKey:ge(t),teamId:e.team_id}:null}function qO({node:e,displayName:t,status:n,refreshSeq:s,navigate:r}){He();const{hasToken:i,epoch:l}=Ae(),{fetchAttention:c}=ut(),[d,m]=u.useState(null),[f,h]=u.useState(null),[p,g]=u.useState(!1),b=u.useRef(!1),x=`${e.name}:${l}:${n}:${s}`,y=u.useRef(x);y.current=x;const v=Ft({load:()=>c(e,{status:n,limit:Oi,order:"newest"}),enabled:i,deps:[e.name,e.url,l,n,s]});Lt(()=>{m(null),h(null),v.reload()}),u.useEffect(()=>{m(null),h(null)},[x]);const[j,_]=u.useState(x);u.useEffect(()=>{(v.state.status==="success"||v.state.status==="error")&&_(x)},[v.state,x]);const S=j===x,w=S?Se(v.state):void 0,k=u.useMemo(()=>S?Di(w?.interactions??[],d?.items??[]):[],[S,w,d]),N=d?d.nextCursor:w?.next_cursor,T=w?.total??k.length,R=S&&v.state.status==="error"?v.state:void 0,E=R!==void 0&&Py(R.code,R.error),I=async()=>{if(!N||b.current)return;const C=y.current;b.current=!0,g(!0),h(null);try{const L=await c(e,{status:n,limit:Oi,order:"newest",cursor:N});if(y.current!==C)return;m(A=>({items:Di(A?.items??[],L.interactions),...L.next_cursor!==void 0?{nextCursor:L.next_cursor}:{}}))}catch(L){h(L instanceof Error?L.message:String(L))}finally{b.current=!1,g(!1)}},$=!S||k.length===0&&(v.state.status==="loading"||v.state.status==="idle");return o.jsxs("section",{className:"flex flex-col gap-2","aria-label":t,children:[o.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[o.jsx("span",{className:"font-semibold",children:t}),e.current&&o.jsx("span",{className:"rounded-full border border-line px-1.5 py-px text-xs uppercase tracking-wider text-muted",children:a("observe.attention.currentNode")}),o.jsx("span",{className:"truncate font-mono text-muted",children:Pn(e.url,PO())}),o.jsx("span",{className:"ml-auto tabular-nums text-muted",children:a("observe.attention.total",{count:T})})]}),!e.current&&o.jsx("p",{className:"m-0 text-sm text-faint",children:a("observe.attention.remoteReadonly")}),$?o.jsx(Ke,{label:a("observe.attention.loading"),rows:2}):E?o.jsx(Fe,{title:a("observe.attention.forbidden"),reason:a("observe.attention.forbiddenReason")}):R&&k.length===0?o.jsx(Ve,{message:R.error,onRetry:v.reload}):o.jsxs(o.Fragment,{children:[R&&o.jsx(st,{message:a("observe.attention.stale"),onRetry:v.reload}),k.length===0?o.jsx($e,{title:a(n==="pending"?"observe.attention.empty.pending":"observe.attention.empty.orphaned"),description:a("observe.attention.emptyHint")}):o.jsxs("div",{className:"attention-list",children:[o.jsxs("div",{className:"attention-head","aria-hidden":"true",children:[o.jsx("span",{children:a("observe.attention.col.kind")}),o.jsx("span",{children:a("observe.attention.col.request")}),o.jsx("span",{children:a("observe.attention.col.tool")}),o.jsx("span",{children:a("observe.attention.col.agent")}),o.jsx("span",{children:a("observe.attention.col.team")}),o.jsx("span",{children:a("observe.attention.col.time")})]}),o.jsx("ul",{className:"attention-items",children:k.map(C=>{const L=e.current?qy(C,e):null;return o.jsx(My,{item:C,readonly:!e.current,...L?{onOpen:()=>r(L)}:{}},C.request_id)})})]}),N&&o.jsx(G,{variant:"plain",className:"mx-auto mt-2 rounded-full px-3.5 py-2 text-xs text-muted",onClick:()=>{I()},disabled:p,children:a(p?"observe.attention.loadingMore":"observe.attention.loadMore")}),f&&o.jsx(Ve,{message:f,onRetry:()=>{I()}})]})]})}function OO({navigate:e}){He();const{hasToken:t}=Ae(),{nodes:n}=ut(),s=Bt(),[r,i]=u.useState("pending"),[l,c]=u.useState(0);return t?o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("observe.attention.nodesHint")}),o.jsxs("div",{className:"mt-3.5 flex flex-wrap items-center gap-2",children:[o.jsx(Nn,{label:a("observe.attention.statusLabel"),tabs:[{id:"pending",label:a("observe.attention.status.pending")},{id:"orphaned",label:a("observe.attention.status.orphaned")}],value:r,onChange:i,panelId:"attention-panel"}),o.jsx(G,{size:"small",onClick:()=>c(d=>d+1),children:a("observe.attention.refresh")})]}),o.jsx("div",{id:"attention-panel",role:"tabpanel","aria-label":a("observe.attention.panelLabel"),className:"flex flex-col gap-4.5",children:n.map(d=>o.jsx(qO,{node:d,displayName:s.get(ge(d))??"—",status:r,refreshSeq:l,navigate:e},`${d.current?"current":"extra"}:${d.name}`))})]}):o.jsx(Fe,{title:a("observe.attention.noToken"),reason:a("observe.attention.noTokenReason")})}function DO({navigate:e}){He();const{hasToken:t,epoch:n}=Ae(),{current:s,fetchAttention:r}=ut(),[i,l]=u.useState("pending"),[c,d]=u.useState(null),[m,f]=u.useState(null),[h,p]=u.useState(!1),g=u.useRef(!1),b=`${n}:${i}:${s?.name??""}`,x=u.useRef(b);x.current=b;const y=Ft({load:()=>s?r(s,{status:i,limit:Oi,order:"newest"}):Promise.reject(new Error("no current node")),enabled:t&&s!==null,deps:[n,i,s?.name??""]}),v=u.useCallback(()=>{d(null),f(null),y.reload()},[y.reload]);Lt(v),u.useEffect(()=>{d(null),f(null)},[n,i]);const[j,_]=u.useState(b);u.useEffect(()=>{(y.state.status==="success"||y.state.status==="error")&&_(b)},[y.state,b]);const S=j===b,w=S?Se(y.state):void 0,k=u.useMemo(()=>S?Di(w?.interactions??[],c?.items??[]):[],[S,w,c]),N=c?c.nextCursor:w?.next_cursor,T=w?.total??k.length,R=S&&y.state.status==="error"?y.state:void 0,E=R!==void 0&&Py(R.code,R.error),I=async()=>{if(!s||!N||g.current)return;const C=x.current;g.current=!0,p(!0),f(null);try{const L=await r(s,{status:i,limit:Oi,order:"newest",cursor:N});if(x.current!==C)return;d(A=>({items:Di(A?.items??[],L.interactions),...L.next_cursor!==void 0?{nextCursor:L.next_cursor}:{}}))}catch(L){f(L instanceof Error?L.message:String(L))}finally{g.current=!1,p(!1)}};if(!t)return o.jsx(Fe,{title:a("observe.attention.noToken"),reason:a("observe.attention.noTokenReason")});if(E)return o.jsx(Fe,{title:a("observe.attention.forbidden"),reason:a("observe.attention.forbiddenReason")});const $=!S||k.length===0&&(y.state.status==="loading"||y.state.status==="idle");return o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("observe.attention.hint")}),o.jsxs("div",{className:"mt-3.5 flex flex-wrap items-center gap-2",children:[o.jsx(Nn,{label:a("observe.attention.statusLabel"),tabs:[{id:"pending",label:a("observe.attention.status.pending")},{id:"orphaned",label:a("observe.attention.status.orphaned")}],value:i,onChange:l,panelId:"attention-panel"}),o.jsx(G,{size:"small",onClick:v,disabled:y.refreshing,children:y.refreshing?a("observe.attention.refreshing"):a("observe.attention.refresh")}),o.jsx("span",{className:"text-muted",children:a("observe.attention.total",{count:T})})]}),o.jsx("div",{id:"attention-panel",role:"tabpanel","aria-label":a("observe.attention.panelLabel"),children:$?o.jsx(Ke,{label:a("observe.attention.loading")}):R&&k.length===0?o.jsx(Ve,{message:R.error,onRetry:y.reload}):o.jsxs(o.Fragment,{children:[R&&o.jsx(st,{message:a("observe.attention.stale"),onRetry:y.reload}),k.length===0?o.jsx($e,{title:a(i==="pending"?"observe.attention.empty.pending":"observe.attention.empty.orphaned"),description:a("observe.attention.emptyHint")}):o.jsxs("div",{className:"attention-list",children:[o.jsxs("div",{className:"attention-head","aria-hidden":"true",children:[o.jsx("span",{children:a("observe.attention.col.kind")}),o.jsx("span",{children:a("observe.attention.col.request")}),o.jsx("span",{children:a("observe.attention.col.tool")}),o.jsx("span",{children:a("observe.attention.col.agent")}),o.jsx("span",{children:a("observe.attention.col.team")}),o.jsx("span",{children:a("observe.attention.col.time")})]}),o.jsx("ul",{className:"attention-items",children:k.map(C=>{const L=s?qy(C,s):null;return o.jsx(My,{item:C,...L?{onOpen:()=>e(L)}:{}},C.request_id)})})]}),N&&o.jsx(G,{variant:"plain",className:"mx-auto mt-2 rounded-full px-3.5 py-2 text-xs text-muted",onClick:()=>{I()},disabled:h,children:a(h?"observe.attention.loadingMore":"observe.attention.loadMore")}),m&&o.jsx(Ve,{message:m,onRetry:()=>{I()}})]})})]})}function HO({navigate:e}){He();const{nodes:t}=ut();return t.length>1?o.jsx(OO,{navigate:e}):o.jsx(DO,{navigate:e})}const Oy=["run.failed","tool.call.failed"],$O=["process.error","shutdown.failed","hook.error","hook.failed","plugin.failed","plugin.init.failed","plugin.dispose.failed","mcp.warning"],Dy=[...Oy,...$O];function Hy(e){return e.errorLevel==="all"||e.showProcessErrors}function FO(e){return e.startsWith("process.")?"process":e.startsWith("shutdown.")?"shutdown":e.startsWith("hook.")?"hook":e.startsWith("plugin.")||e.startsWith("mcp.")?"plugin":e.startsWith("tool.")?"tool":e.startsWith("agent.")?"agent":"run"}function BO(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ks(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function KO(e){const t=BO(e.data)?e.data:{},n=t.http_status??t.httpStatus;return{type:e.type,ts:e.ts,run_id:e.run_id||"-",category:FO(e.type),...Ks(t,"error")!==void 0?{message:Ks(t,"error")}:{},...Ks(t,"error_code")!==void 0?{errorCode:Ks(t,"error_code")}:{},...Ks(t,"phase")!==void 0?{phase:Ks(t,"phase")}:{},...typeof t.retryable=="boolean"?{retryable:t.retryable}:{},...typeof n=="number"&&Number.isFinite(n)?{httpStatus:n}:{}}}function WO(e,t){const n=new Set(Hy(t)?Dy:[...Oy]);return e.filter(s=>n.has(s.type)).map(KO).sort((s,r)=>r.ts-s.ts||(s.run_id<r.run_id?1:s.run_id>r.run_id?-1:0))}function UO(e){return e?[...e.scheduler.queued,...e.scheduler.running]:[]}function Wr(e,t){return`run:${t}:${e}`}function Ur(e,t){return`diagnostics:${t}:${e}`}function Sh(){return{live:{status:"idle"},durable:{status:"idle"}}}function jh(){return{health:{status:"idle"},events:{status:"idle"}}}async function zr(e,t,n,s,r){const i=gn(t);e(l=>s(l,Qo(n)));try{const l=await r();if(!kt(t,i))return;e(c=>s(c,qn(l)))}catch(l){if(!kt(t,i))return;e(c=>s(c,bs(n,l)))}}const ya=vn()((e,t)=>{const n=(r,i,l)=>{const c=t().diagnosticsByNode[i]?.health;return zr(e,l,c,(d,m)=>{const f=d.diagnosticsByNode[i]??jh();return{diagnosticsByNode:{...d.diagnosticsByNode,[i]:{...f,health:m}}}},()=>r.getHealth())},s=(r,i,l)=>{const c=t().diagnosticsByNode[i]?.events;return zr(e,l,c,(d,m)=>{const f=d.diagnosticsByNode[i]??jh();return{diagnosticsByNode:{...d.diagnosticsByNode,[i]:{...f,events:m}}}},()=>r.readEvents({types:[...Dy],limit:200}))};return{runsByNode:{},diagnosticsByNode:{},loadRuns:async(r,i,l="live")=>{const c=ge(i);if(l==="durable"){const m=t().runsByNode[c]?.durable;await zr(e,Wr(c,"durable"),m,(f,h)=>{const p=f.runsByNode[c]??Sh();return{runsByNode:{...f.runsByNode,[c]:{...p,durable:h}}}},()=>r.listDurableRuns({limit:200}));return}const d=t().runsByNode[c]?.live;await zr(e,Wr(c,"live"),d,(m,f)=>{const h=m.runsByNode[c]??Sh();return{runsByNode:{...m.runsByNode,[c]:{...h,live:f}}}},()=>r.listRuns())},loadDiagnostics:async(r,i,l="both")=>{const c=ge(i),d=[];l!=="events"&&d.push(n(r,c,Ur(c,"health"))),l!=="health"&&d.push(s(r,c,Ur(c,"events"))),await Promise.all(d)},reset:()=>{const r=t();for(const i of Object.keys(r.runsByNode))rn(Wr(i,"live")),rn(Wr(i,"durable"));for(const i of Object.keys(r.diagnosticsByNode))rn(Ur(i,"health")),rn(Ur(i,"events"));e({runsByNode:{},diagnosticsByNode:{}})}}});function zO(e){return ya(t=>e?t.runsByNode[ge(e)]:void 0)}function VO(e){return ya(t=>e?t.diagnosticsByNode[ge(e)]:void 0)}const GO="observe.diagnostics.doctor.dataDir.gatewayDecided";function Gn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function xn(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function Vr(e){return typeof e=="string"&&e!==""&&e!=="<unset>"}function dl(e){return a(e?"observe.diagnostics.doctor.set":"observe.diagnostics.doctor.unset")}function Yn(e){return e??a("observe.diagnostics.doctor.pending")}function YO(e){const t=Gn(e.config?.config),n=e.configError,s=n!==void 0,r=[];if(!t||s?r.push({name:"config",status:n?"unavailable":"info",source:"config.get",detail:Yn(n)}):r.push({name:"config",status:"unavailable",source:"config.get",detail:`${a("observe.diagnostics.doctor.config.detail",{user:e.config?.paths.user||"—",project:e.config?.paths.project||"—"})} · ${a("observe.diagnostics.doctor.config.unverified")}`}),!t||s)r.push({name:"provider",status:n?"unavailable":"info",source:"config.get",detail:Yn(n)});else{const i=Gn(t.provider),l=Vr(i?.apiKey)||Vr(t.apiKey);r.push({name:"provider",status:l?"ok":"fail",source:"config.get",detail:a("observe.diagnostics.doctor.provider.detail",{provider:xn(i?.name)??"—",model:xn(i?.model)??"—",key:dl(l)})})}if(!t||s)r.push({name:"data_dir",status:n?"unavailable":"info",source:"config.get",detail:Yn(n)});else{const i=xn(t.dataDir),l=e.sources?.sources.dataDir;r.push({name:"data_dir",status:"info",source:"config.get",detail:i?`${a("observe.diagnostics.doctor.dataDir.configured",{path:i,source:l??"—"})} · ${a("observe.diagnostics.doctor.dataDir.unverified")}`:`${a(GO)} · ${a("observe.diagnostics.doctor.dataDir.unverified")}`})}if(!t||s)r.push({name:"session",status:n?"unavailable":"info",source:"config.get",detail:Yn(n)});else{const i=Gn(t.session),l=xn(i?.backend)??"file",c=xn(i?.storagePath);if(l==="memory")r.push({name:"session",status:"info",source:"config.get",detail:a("observe.diagnostics.doctor.session.memory")});else{const d=l==="sqlite"?"sessions.db":"sessions",m=xn(t.dataDir),f=m===void 0,h=c??(f?d:`${m}/${d}`),p=[];c===void 0&&p.push(a("observe.diagnostics.doctor.session.derived")),f&&c===void 0&&p.push(a("observe.diagnostics.doctor.session.relative"));const g=p.length>0?` (${p.join(" · ")})`:"";r.push({name:"session",status:"info",source:"config.get",detail:`${a("observe.diagnostics.doctor.session.detail",{backend:l,path:`${h}${g}`})} · ${a("observe.diagnostics.doctor.writability")}`})}}if(!t||s)r.push({name:"plugins",status:n?"unavailable":"info",source:"config.get · capabilities.list",detail:Yn(n)});else if(e.capabilitiesError)r.push({name:"plugins",status:"unavailable",source:"capabilities.list",detail:e.capabilitiesError});else if(!e.capabilities)r.push({name:"plugins",status:"info",source:"capabilities.list",detail:a("observe.diagnostics.doctor.pending")});else{const l=(Array.isArray(t.plugins)?t.plugins.map(f=>Gn(f)).filter(f=>f!==void 0):[]).filter(f=>f.enabled!==!1).map(f=>xn(f.name)).filter(f=>f!==void 0),c=e.capabilities.plugins,d=new Set(c.map(f=>f.name)),m=l.filter(f=>!d.has(f));r.push({name:"plugins",status:m.length>0?"fail":"ok",source:"config.get · capabilities.list",detail:m.length>0?a("observe.diagnostics.doctor.plugins.missing",{names:m.join(", ")}):a("observe.diagnostics.doctor.plugins.ok",{enabled:c.filter(f=>f.enabled).length,total:c.length})})}if(!t||s)r.push({name:"mcp",status:n?"unavailable":"info",source:"config.get · mcp.list",detail:Yn(n)});else{const i=Gn(t.mcpServers),l=(i?Object.entries(i):[]).map(([d,m])=>({name:d,server:Gn(m)})).filter(({server:d})=>d?.enabled!==!1),c=l.filter(({server:d})=>d?.transport==="stdio"?xn(d?.command)===void 0:xn(d?.url)===void 0).map(({name:d})=>d);if(c.length>0)r.push({name:"mcp",status:"fail",source:"config.get",detail:a("observe.diagnostics.doctor.mcp.invalid",{names:c.join(", ")})});else if(e.mcpError!==void 0){const d=e.mcpErrorCode==="not_found"||e.mcpErrorCode==="mcp_disabled";r.push({name:"mcp",status:l.length>0?"warn":"info",source:"config.get · mcp.list",detail:d?a("observe.diagnostics.doctor.mcp.disabled"):`${a("observe.diagnostics.doctor.mcp.unavailable")}: ${e.mcpError}`})}else if(e.mcpServers!==void 0){const d=e.mcpServers.length!==l.length;r.push({name:"mcp",status:d?"warn":"ok",source:"config.get · mcp.list",detail:a("observe.diagnostics.doctor.mcp.rpc",{servers:e.mcpServers.length,configured:l.length})})}else r.push({name:"mcp",status:"info",source:"config.get · mcp.list",detail:a("observe.diagnostics.doctor.pending")})}if(!t||s)r.push({name:"serve_port",status:n?"unavailable":"info",source:"config.get · health.get",detail:Yn(n)});else{const i=Gn(t.node),l=i?.port,c=e.health?.node.endpoint??e.nodeUrl;if(typeof l!="number")r.push({name:"serve_port",status:"info",source:"config.get",detail:a("observe.diagnostics.doctor.servePort.notConfigured")});else{const d=xn(i?.hostname)??"127.0.0.1";r.push({name:"serve_port",status:"info",source:"config.get · health.get",detail:`${l===0?a("observe.diagnostics.doctor.servePort.systemPort",{host:d,endpoint:c}):a("observe.diagnostics.doctor.servePort.detail",{host:d,port:l,endpoint:c})} · ${a("observe.diagnostics.doctor.servePort.unverified")}`})}}if(e.healthError)r.push({name:"attach",status:"fail",source:"health.get",detail:e.healthError});else if(!e.connected)r.push({name:"attach",status:"warn",source:"health.get",detail:a("observe.diagnostics.doctor.attach.disconnected")});else if(e.health){const i=e.health.node;r.push({name:"attach",status:"ok",source:"health.get",detail:`${i.endpoint||e.nodeUrl} (${i.role}, ${i.status}, pid ${i.pid})`})}else r.push({name:"attach",status:"info",source:"health.get",detail:a("observe.diagnostics.doctor.pending")});if(!t||s)r.push({name:"feishu_credentials",status:n?"unavailable":"info",source:"config.get",detail:Yn(n)});else{const i=Gn(t.feishu);if(i?.enabled!==!0)r.push({name:"feishu_credentials",status:"info",source:"config.get",detail:a("observe.diagnostics.doctor.feishu.disabled")});else{const l=Vr(i.appId),c=Vr(i.appSecret);r.push({name:"feishu_credentials",status:l&&c?"ok":"fail",source:"config.get",detail:a("observe.diagnostics.doctor.feishu.detail",{appId:dl(l),appSecret:dl(c)})})}}return r}const JO={ok:"success",warn:"warn",fail:"danger",info:"info",unavailable:"neutral"};function QO({config:e,sources:t,health:n,capabilities:s,mcp:r,nodeUrl:i,connected:l,onRefresh:c}){const d=Se(e),m=Se(n),f=Se(s),h=Se(r),p=r.status==="error"?r:void 0,g=YO({config:d,sources:Se(t),health:m,capabilities:f,mcpServers:h,mcpError:p?.error,mcpErrorCode:p?.code,configError:e.status==="error"?e.error:void 0,capabilitiesError:s.status==="error"?s.error:void 0,healthError:n?.status==="error"?n.error:void 0,nodeUrl:i,connected:l});return o.jsx(et,{title:a("observe.diagnostics.doctorTitle"),description:a("observe.diagnostics.doctorHint"),actions:o.jsx(G,{size:"small",onClick:c,children:a("observe.diagnostics.refresh")}),children:o.jsx($n,{columns:[{key:"check",header:a("observe.diagnostics.doctorColCheck"),cellClassName:"font-mono",cell:b=>b.name},{key:"status",header:a("observe.diagnostics.doctorColStatus"),cell:b=>o.jsx(Re,{tone:JO[b.status],children:a(`observe.diagnostics.doctor.status.${b.status}`)})},{key:"source",header:a("observe.diagnostics.doctorColSource"),hide:"compact",cellClassName:"font-mono text-muted",cell:b=>b.source},{key:"detail",header:a("observe.diagnostics.doctorColDetail"),cell:b=>b.detail}],rows:g,rowKey:b=>b.name})})}function XO(e){const t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}function ZO(e){if(e===void 0)return"—";const t=Date.now()-e;if(!Number.isFinite(t)||t<0)return"—";const n=Math.floor(t/1e3),s=Math.floor(n/86400),r=Math.floor(n%86400/3600),i=Math.floor(n%3600/60),l=n%60;return s>0?`${s}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:i>0?`${i}m ${l}s`:`${l}s`}function eD(e){return e==="connected"?"success":e==="failed"?"danger":"neutral"}function tD(){He();const{client:e,connectionState:t,hasToken:n,epoch:s,nodeUrl:r}=Ae(),{current:i}=ut(),l=n&&t==="open",c=ya(J=>J.loadDiagnostics),d=VO(i),m=d?.health,f=d?.events,h=i?ge(i):"",{config:p,sources:g,capabilities:b,reloadConfig:x,reloadSources:y,reloadCapabilities:v}=Qt({capabilities:!0,sources:!0}),j=()=>{i&&l&&c(e,i,"health")},_=()=>{i&&l&&c(e,i,"events")},S=()=>{i&&l&&c(e,i,"both")};qt(j,{enabled:l&&i!==null,deps:[s,h],pollMs:5e3}),qt(_,{enabled:l&&i!==null,deps:[s,h]});const w=Ft({load:()=>e.listMcpServers(),enabled:l&&i!==null,pollMs:1e4,deps:[s,h]}),k=()=>{S(),x(),y(),v(),w.reload()};Lt(k);const N=u.useMemo(()=>({errorLevel:hd(Se(p)).errorLevel,showProcessErrors:iE(Se(p))}),[p]),T=Hy(N),R=u.useMemo(()=>WO(Se(f)??[],N),[f,N]),E=u.useMemo(()=>UO(Se(m)?.runtime),[m]),I=Se(m),$=I?.runtime,C=u.useMemo(()=>Se(w.state)??[],[w.state]),L=w.state.status==="error"?w.state:null,A=L?.code==="not_supported"||L?.code==="mcp_disabled",D=Se(b),O=u.useMemo(()=>D?D.plugins.filter(J=>J.enabled):[],[D]),F=Se(g),V=Se(p),B=g.status==="error"?g:null,W=B?.code==="not_found"||B?.code==="method_not_allowed"||B?.code==="not_supported",Z=F?.tenant_overlay_keys??V?.tenant_overlay_keys??[];if(!n)return o.jsx(Fe,{title:a("observe.diagnostics.noToken"),reason:a("observe.diagnostics.noTokenReason")});const ee=m?.status==="error"?m.error:null,ie=f?.status==="error"?f.error:null,le=b.status==="error"?b.error:null;return o.jsxs("div",{className:"flex flex-col gap-6",children:[!l&&o.jsx("p",{className:"text-muted",children:a("observe.diagnostics.disconnected")}),ee&&!I&&o.jsx(Ve,{message:ee,onRetry:j}),ie&&o.jsx(Ve,{message:ie,onRetry:_}),o.jsx(QO,{config:p,sources:g,health:m,capabilities:b,mcp:w.state,nodeUrl:r,connected:l,onRefresh:k}),o.jsx(et,{title:a("observe.diagnostics.runtimeTitle"),actions:o.jsx(G,{size:"small",onClick:j,children:a("observe.diagnostics.refresh")}),children:I?o.jsx(Gt,{items:[{key:"status",label:a("observe.diagnostics.nodeStatus"),value:o.jsx("span",{className:"font-mono",children:I.node.status})},{key:"provider",label:a("observe.diagnostics.provider"),value:o.jsx("span",{className:"font-mono",children:I.node.capabilities.provider??"—"})},{key:"model",label:a("observe.diagnostics.model"),value:o.jsx("span",{className:"font-mono",children:I.node.capabilities.model??"—"})},{key:"uptime",label:a("observe.diagnostics.uptime"),value:o.jsx("span",{className:"font-mono",children:ZO(I.started_at)})},{key:"clients",label:a("observe.diagnostics.clients"),value:o.jsx("span",{className:"font-mono",children:I.clients})},{key:"activeRun",label:a("observe.diagnostics.activeRun"),value:o.jsx("span",{className:"font-mono",children:$?.active_run_id??"—"})}]}):ee?o.jsx("p",{className:"text-muted",children:ee}):o.jsx(Ke,{label:a("observe.diagnostics.loading"),rows:2})}),o.jsxs(et,{title:a("observe.diagnostics.queueTitle"),actions:o.jsx(G,{size:"small",onClick:j,children:a("observe.diagnostics.refresh")}),children:[I&&ee&&o.jsx(st,{message:ee,onRetry:j}),I?E.length===0?o.jsx($e,{title:a("observe.diagnostics.queueEmpty")}):o.jsx($n,{columns:[{key:"run",header:"run",cellClassName:"font-mono",cell:J=>J.run_id},{key:"status",header:a("observe.diagnostics.col.status"),cell:J=>J.status},{key:"session",header:a("observe.diagnostics.col.session"),cellClassName:"font-mono",cell:J=>J.session_id??"—"},{key:"queuePosition",header:a("observe.diagnostics.col.queuePosition"),cell:J=>J.queue_position??"—"},{key:"waitReason",header:a("observe.diagnostics.col.waitReason"),cell:J=>J.wait_reason??a("observe.diagnostics.noWaitReason")}],rows:E,rowKey:J=>`${J.status}:${J.run_id}`}):ee?o.jsx("p",{className:"text-muted",children:ee}):o.jsx(Ke,{label:a("observe.diagnostics.loading"),rows:2}),Se(m)?.runtime&&o.jsxs("p",{className:"text-muted",children:[a("observe.diagnostics.activeRun"),":"," ",o.jsx("span",{className:"font-mono",children:Se(m)?.runtime?.active_run_id??"—"})," ","·"," ",a("observe.diagnostics.stats",{queued:Se(m)?.runtime?.scheduler.stats.queued??0,running:Se(m)?.runtime?.scheduler.stats.running??0})]})]}),o.jsx(et,{title:a("observe.diagnostics.mcpTitle"),actions:o.jsx(G,{size:"small",onClick:w.reload,children:a("observe.diagnostics.refresh")}),children:A?o.jsx(Fe,{title:a("observe.diagnostics.mcpNotEnabled"),reason:a("observe.diagnostics.mcpNotEnabledReason")}):L?o.jsx(Ve,{message:L.error,onRetry:w.reload}):(w.state.status==="idle"||w.state.status==="loading")&&C.length===0?o.jsx(Ke,{label:a("common.loading"),rows:2}):C.length===0?o.jsx($e,{title:a("observe.diagnostics.mcpEmpty")}):o.jsx($n,{columns:[{key:"name",header:a("observe.diagnostics.col.mcpServer"),cellClassName:"font-mono",cell:J=>J.name},{key:"status",header:a("observe.diagnostics.col.mcpStatus"),cell:J=>o.jsx(Re,{tone:eD(J.status),children:J.status})},{key:"tools",header:a("observe.diagnostics.col.mcpTools"),cell:J=>J.tools.length===0?"0":o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono",children:J.tools.length})," ",o.jsx("span",{className:"text-muted",children:J.tools.join(", ")})]})},{key:"error",header:a("observe.diagnostics.col.mcpError"),cell:J=>J.error?o.jsx("span",{className:"text-danger",children:J.error}):"—"}],rows:C,rowKey:J=>J.name})}),o.jsx(et,{title:a("observe.diagnostics.pluginsTitle"),actions:o.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[D&&o.jsx(Re,{children:a("observe.diagnostics.pluginsCount",{enabled:O.length,total:D.plugins.length})}),o.jsx(G,{size:"small",onClick:v,children:a("observe.diagnostics.refresh")})]}),children:D?O.length===0?o.jsx($e,{title:a("observe.diagnostics.pluginsEmpty")}):o.jsx("ul",{className:"plain-list",children:O.map(J=>o.jsx("li",{children:o.jsx("span",{className:"font-mono",children:J.name})},J.name))}):le?o.jsx(Ve,{message:le,onRetry:v}):o.jsx(Ke,{label:a("common.loading"),rows:2})}),o.jsx(et,{title:a("observe.diagnostics.capabilitiesTitle"),actions:o.jsx(G,{size:"small",onClick:v,children:a("observe.diagnostics.refresh")}),children:D?o.jsx(Gt,{items:[{key:"version",label:a("observe.diagnostics.version"),value:o.jsx("span",{className:"font-mono",children:D.version})},{key:"methods",label:a("observe.diagnostics.methods"),value:o.jsx("span",{className:"font-mono",children:D.methods.length})},{key:"tools",label:a("observe.diagnostics.tools"),value:o.jsx("span",{className:"font-mono",children:D.tools.length})}]}):le?o.jsx(Ve,{message:le,onRetry:v}):o.jsx(Ke,{label:a("common.loading"),rows:2})}),o.jsx(et,{title:a("observe.diagnostics.sourcesTitle"),actions:o.jsx(G,{size:"small",onClick:y,children:a("observe.diagnostics.refresh")}),children:!F&&!V?B&&!W?o.jsx(Ve,{message:B.error,onRetry:y}):o.jsx(Ke,{label:a("common.loading"),rows:2}):o.jsxs(o.Fragment,{children:[o.jsx(Gt,{items:[{key:"user",label:a("observe.diagnostics.userPath"),value:o.jsx("span",{className:"font-mono",children:V?.paths.user||"—"})},{key:"project",label:a("observe.diagnostics.projectPath"),value:o.jsx("span",{className:"font-mono",children:V?.paths.project||"—"})},{key:"overlay",label:a("observe.diagnostics.overlayKeys"),value:o.jsx("span",{className:"font-mono",children:Z.length>0?Z.join(", "):"—"})}]}),W&&o.jsx("p",{className:"text-muted",children:a("observe.diagnostics.notAvailable")}),B&&!W&&o.jsx("p",{className:"text-muted",children:B.error})]})}),o.jsxs(et,{title:a("observe.diagnostics.errorsTitle"),actions:o.jsx(G,{size:"small",onClick:_,children:a("observe.diagnostics.refresh")}),children:[!T&&o.jsx("p",{className:"text-muted",children:a("observe.diagnostics.gateHint")}),R.length===0?o.jsx($e,{title:a("observe.diagnostics.empty")}):o.jsx("ul",{className:"m-0 flex list-none flex-col gap-1.5 p-0 text-md",children:R.map(J=>o.jsxs("li",{children:[o.jsx("span",{className:"text-muted",children:XO(J.ts)})," ",o.jsx("span",{className:"font-mono",children:J.type})," ",o.jsxs("span",{className:"text-muted",children:["[",J.category,"]"]}),J.errorCode&&o.jsxs("span",{className:"font-mono",children:[" · ",J.errorCode]}),J.phase&&o.jsxs("span",{className:"text-muted",children:[" · ",J.phase]}),J.retryable!==void 0&&o.jsxs("span",{className:"text-muted",children:[" ","·"," ",a(J.retryable?"observe.diagnostics.retryable":"observe.diagnostics.fatal")]}),J.message&&o.jsx("div",{children:J.message}),o.jsx("span",{className:"font-mono text-muted",children:J.run_id})]},`${J.type}:${J.run_id}:${J.ts}`))})]})]})}function nD({report:e,caseLimit:t,caseFilter:n,onCaseFilter:s,onShowMore:r}){const i=u.useMemo(()=>n==="failed"?e.cases.filter(c=>c.status==="failed"||c.status==="error"):e.cases,[e.cases,n]),l=i.slice(0,t);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"my-3 flex flex-wrap gap-2.5",children:[o.jsx(jt,{className:"min-w-40 flex-1",value:e.total,label:a("observe.evals.stat.total")}),o.jsx(jt,{className:"min-w-40 flex-1",value:e.passed,label:a("observe.evals.stat.passed")}),o.jsx(jt,{className:"min-w-40 flex-1",value:e.failed,label:a("observe.evals.stat.failed")}),o.jsx(jt,{className:"min-w-40 flex-1",value:e.errors,label:a("observe.evals.stat.errors")}),o.jsx(jt,{className:"min-w-40 flex-1",value:e.skipped,label:a("observe.evals.stat.skipped")}),o.jsx(jt,{className:"min-w-40 flex-1",value:`${e.duration_ms}ms`,label:a("observe.evals.stat.duration")}),o.jsx(jt,{className:"min-w-40 flex-1",value:e.network?"on":"off",label:a("observe.evals.stat.network")})]}),o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("observe.evals.generatedAt",{time:bt(e.finished_at),network:e.network?a("observe.evals.networkOn"):a("observe.evals.offline")})}),o.jsxs(et,{title:a("observe.evals.casesTitle"),actions:o.jsxs(o.Fragment,{children:[o.jsx(G,{variant:"chip",size:"small","aria-pressed":n==="failed",onClick:()=>s(n==="failed"?"all":"failed"),children:a("observe.evals.failedOnly")}),o.jsxs(Re,{children:[i.length,"/",e.cases.length]})]}),children:[i.length===0?o.jsx($e,{title:a(n==="failed"?"observe.evals.emptyFailed":"observe.evals.emptyCases")}):o.jsx($n,{columns:[{key:"status",header:a("observe.evals.col.status"),cell:c=>o.jsx(Tt,{status:c.status})},{key:"case",header:a("observe.evals.col.case"),cellClassName:"font-mono",cell:c=>c.id},{key:"duration",header:a("observe.evals.col.duration"),hide:"wide",cellClassName:"font-mono tabular-nums",cell:c=>`${c.duration_ms}ms`},{key:"assertions",header:a("observe.evals.col.assertions"),hide:"wide",cellClassName:"font-mono tabular-nums",cell:c=>`${c.assertions.filter(d=>d.ok).length}/${c.assertions.length}`},{key:"output",header:a("observe.evals.col.output"),cell:c=>o.jsxs(o.Fragment,{children:[c.error?o.jsx("span",{className:"text-danger",children:c.error}):o.jsx("span",{className:"text-muted",children:c.output??"—"}),c.assertions.length>0&&o.jsxs("details",{className:"mt-1",open:c.status==="failed",children:[o.jsx("summary",{className:"cursor-pointer font-mono text-xs text-muted",children:a("observe.evals.assertions")}),o.jsx("ul",{className:"plain-list",children:c.assertions.map((d,m)=>o.jsxs("li",{children:[o.jsxs("span",{className:d.ok?"text-success":"text-danger",children:[d.ok?"✓":"✗"," ",d.type]}),d.detail&&o.jsxs("span",{className:"text-muted",children:[" — ",d.detail]})]},`${d.type}-${m}`))})]})]})}],rows:l,rowKey:c=>c.id}),l.length<i.length&&o.jsx(G,{variant:"plain",className:"mx-auto mt-2 rounded-full px-3.5 py-2 text-xs text-muted",onClick:r,children:a("observe.evals.showMore",{count:i.length-l.length})})]})]})}function sD(e){return e instanceof Error?e.message:String(e)}const $y="vessel.eval-suites",ul=100;function oD(){try{const e=localStorage.getItem($y),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(n=>typeof n=="string").slice(0,8):[]}catch{return[]}}function rD(){const{client:e,connectionState:t,hasToken:n,features:s,epoch:r}=Ae(),i=ot(),l=n&&t==="open",c=n&&s.includes("evals"),[d,m]=u.useState("smoke"),[f,h]=u.useState(0),[p,g]=u.useState(null),[b,x]=u.useState(!1),[y,v]=u.useState(null),[j,_]=u.useState(oD),[S,w]=u.useState(ul),[k,N]=u.useState("all"),T=Ft({load:()=>e.getLatestEval(d),enabled:c&&f>0,deps:[r,d,f]});Lt(T.reload);const R=Se(T.state),E=R&&R.suite===d?R:void 0,I=p??E??null;u.useEffect(()=>{g(null),v(null),w(ul),N("all")},[d,f]);const $=O=>{const F=[O,...j.filter(V=>V!==O)].slice(0,8);_(F);try{localStorage.setItem($y,JSON.stringify(F))}catch{}};if(!n)return o.jsx(Fe,{title:a("common.notConnected"),reason:a("observe.evals.noTokenReason")});if(!s.includes("evals"))return o.jsx(Fe,{title:a("observe.evals.disabledTitle"),reason:a("observe.evals.disabledReason"),hint:a("observe.evals.disabledHint")});const C=()=>{g(null),v(null),$(d),h(O=>O+1)},L=async()=>{if(!l){i.error(a("observe.evals.disconnectedRun"));return}x(!0),v(null);try{const O=await e.runEval(d);g(O),$(d),i.success(a("observe.evals.completed",{suite:O.suite}))}catch(O){v(sD(O))}finally{x(!1)}},A=T.state.status==="error"&&(T.state.error.includes("not_found")||T.state.error.includes("eval_not_found")||T.state.error.includes("Eval report not found")),D=T.state.status==="error"?T.state.error:null;return o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("observe.evals.intro")}),o.jsxs("div",{className:"mt-3.5 flex flex-wrap items-center gap-2",children:[o.jsx(Xe,{className:"grow basis-60 max-w-search",value:d,onChange:O=>m(O.target.value),placeholder:a("observe.evals.suitePlaceholder"),"aria-label":a("observe.evals.suiteLabel"),list:"eval-suites",spellCheck:!1}),o.jsx("datalist",{id:"eval-suites",children:j.map(O=>o.jsx("option",{value:O},O))}),o.jsx(G,{size:"small",onClick:C,disabled:!d.trim()||T.state.status==="loading",children:a("observe.evals.loadLatest")}),o.jsx(G,{size:"small",variant:"primary",onClick:()=>{L()},disabled:!l||!d.trim()||b,title:l?void 0:a("common.writesDisabled"),children:a(b?"observe.evals.running":"observe.evals.run")})]}),j.length>0&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-muted",children:a("observe.evals.recent")}),j.map(O=>o.jsx(G,{variant:"chip",size:"small","aria-pressed":O===d,onClick:()=>m(O),children:O},O))]}),y&&o.jsx(Ve,{message:y,onRetry:()=>{L()},retryLabel:a("observe.evals.retry")}),!l&&I&&o.jsx(st,{message:a("observe.evals.disconnectedReport")}),!p&&A&&o.jsx(Fe,{title:a("observe.evals.notFoundTitle"),reason:D??void 0,hint:a("observe.evals.notFoundHint")}),!p&&!A&&D&&o.jsx(Ve,{message:D,onRetry:T.reload}),!I&&!y&&!A?T.state.status==="loading"?o.jsx(Ke,{label:a("observe.evals.loadingReport")}):o.jsx($e,{title:a("observe.evals.emptyTitle"),description:a("observe.evals.emptyDesc")}):I?o.jsx(nD,{report:I,caseLimit:S,caseFilter:k,onCaseFilter:N,onShowMore:()=>w(O=>O+ul)}):null]})}function _h(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function Nh(e,t){if(e!==void 0&&!(!Number.isFinite(t)||t<=0))return e/t}function iD(e){const t=_h(e.cache_read_tokens),n=_h(e.cache_creation_tokens),s=t!==void 0||n!==void 0,r=Nh(t,e.prompt_tokens),i=t===void 0||n===void 0?void 0:Nh(t,t+n);return{available:s,...t!==void 0?{cacheRead:t}:{},...n!==void 0?{cacheCreation:n}:{},...r!==void 0?{inputShare:r}:{},...i!==void 0?{prefixHealth:i}:{}}}function Ch(e){if(e===void 0||!Number.isFinite(e)||e<0)return;const t=e*100;return`${(t>=99.95?100:Math.round(t*10)/10).toFixed(1).replace(/\.0$/,"")}%`}const aD="—";function ml(e){return e===void 0?aD:hi(e)}function lD(e){const t=iD(e),n=Ch(t.inputShare),s=Ch(t.prefixHealth);return{...t,...n!==void 0?{inputShareText:n}:{},...s!==void 0?{prefixHealthText:s}:{},cacheReadText:ml(t.cacheRead),cacheCreationText:ml(t.cacheCreation),promptTokens:e.prompt_tokens,promptTokensText:ml(e.prompt_tokens)}}function cD(){const{client:e,connectionState:t,hasToken:n,features:s,epoch:r}=Ae(),i=n&&t==="open",l=n&&s.includes("metrics"),[c,d]=u.useState("live"),m=Ft({load:()=>e.getMetricsSnapshot(c),enabled:l,pollMs:1e4,deps:[r,c]}),f=Se(m.state),h=f?.metrics;Lt(m.reload);const p=u.useMemo(()=>h?lD(h.llm):void 0,[h]),g=h!==void 0&&h.llm.requests>0,b=p?.available?a("observe.metrics.stat.cacheHint",{read:p.cacheReadText,write:p.cacheCreationText,prompt:p.promptTokensText}):a("observe.metrics.stat.cacheNoFieldsHint");if(!n)return o.jsx(Fe,{title:a("common.notConnected"),reason:a("observe.metrics.noTokenReason")});if(!s.includes("metrics"))return o.jsx(Fe,{title:a("observe.metrics.disabledTitle"),reason:a("observe.metrics.disabledReason"),hint:a("observe.metrics.disabledHint")});if(c==="trace"&&m.state.status==="error")return o.jsx(Fe,{title:a("observe.metrics.traceDisabledTitle"),reason:m.state.error,hint:a("observe.metrics.traceDisabledHint"),action:o.jsx(G,{onClick:()=>d("live"),children:a("observe.metrics.switchLive")})});const x=m.state.status==="error"?m.state.error:null;return o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsxs("div",{className:"mt-3.5 flex flex-wrap items-center gap-2",children:[o.jsx(Nn,{label:a("observe.metrics.sourceLabel"),tabs:[{id:"live",label:a("observe.metrics.source.live")},{id:"trace",label:a("observe.metrics.source.trace")}],value:c,onChange:d,panelId:"metrics-source-panel"}),o.jsx(G,{size:"small",onClick:m.reload,children:a("observe.metrics.refresh")})]}),o.jsxs("div",{id:"metrics-source-panel",role:"tabpanel","aria-label":a("observe.metrics.panelLabel"),children:[!i&&h&&o.jsx(st,{message:a("observe.metrics.stale"),onRetry:m.reload}),x&&h&&o.jsx(st,{message:a("common.staleData",{detail:x}),onRetry:m.reload}),h?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"my-3 flex flex-wrap gap-2.5",children:[o.jsx(jt,{className:"min-w-40 flex-1",value:h.runs.started,label:a("observe.metrics.stat.runsStarted")}),o.jsx(jt,{className:"min-w-40 flex-1",value:h.runs.completed,label:a("observe.metrics.stat.completed")}),o.jsx(jt,{className:"min-w-40 flex-1",value:h.runs.failed,label:a("observe.metrics.stat.failed")}),o.jsx(jt,{className:"min-w-40 flex-1",value:h.runs.cancelled,label:a("observe.metrics.stat.cancelled")}),o.jsx(jt,{className:"min-w-40 flex-1",value:h.tool_calls.total,label:a("observe.metrics.stat.toolCalls",{failed:h.tool_calls.failed})}),o.jsx(jt,{className:"min-w-40 flex-1",value:h.llm.total_tokens,label:a("observe.metrics.stat.tokens",{prompt:h.llm.prompt_tokens,completion:h.llm.completion_tokens})}),g&&o.jsxs(o.Fragment,{children:[o.jsx(jt,{className:"min-w-40 flex-1",value:p?.inputShareText??a("observe.metrics.stat.cacheUnavailable"),label:a("observe.metrics.stat.cacheInputShare"),hint:b}),o.jsx(jt,{className:"min-w-40 flex-1",value:p?.prefixHealthText??a("observe.metrics.stat.cacheUnavailable"),label:a("observe.metrics.stat.cachePrefixHealth"),hint:b})]}),o.jsx(jt,{className:"min-w-40 flex-1",value:`${Math.round(h.duration_ms.avg)}ms`,label:a("observe.metrics.stat.avgDuration",{max:Math.round(h.duration_ms.max)})}),o.jsx(jt,{className:"min-w-40 flex-1",value:bt(h.updated_at),label:a("observe.metrics.stat.updatedAt")})]}),o.jsx("p",{className:"mt-1.5 max-w-prose text-md leading-relaxed text-muted",children:a("observe.metrics.sourceDesc",{source:f?.source==="trace"?a("observe.metrics.source.trace"):a("observe.metrics.source.live")})})]}):x?o.jsx(Ve,{message:x,onRetry:m.reload}):o.jsx(Ke,{label:a("observe.metrics.loading")})]})]})}function dD(){return[{id:"metrics",label:a("observe.tab.metrics")},{id:"evals",label:a("observe.tab.evals")},{id:"diagnostics",label:a("observe.tab.diagnostics")},{id:"attention",label:a("observe.tab.attention")}]}function uD({route:e,navigate:t}){He();const n=u.useRef(null),s=r=>{n.current?.scrollTo?.({top:0}),t({domain:"observe",tab:r})};return o.jsx("div",{ref:n,className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsxs(Ct,{title:a("observe.title"),subtitle:a("observe.description"),children:[o.jsx(En,{label:a("observe.tabsLabel"),children:o.jsx(Nn,{label:a("observe.tabsLabel"),tabs:dD(),value:e.tab,onChange:s,panelId:"observe-panel"})}),o.jsxs("div",{className:"flex flex-col gap-4",id:"observe-panel",role:"tabpanel","aria-label":a("observe.panelLabel"),children:[e.tab==="metrics"&&o.jsx(cD,{}),e.tab==="evals"&&o.jsx(rD,{}),e.tab==="diagnostics"&&o.jsx(tD,{}),e.tab==="attention"&&o.jsx(HO,{navigate:t})]})]})})}function Fy({title:e,subtitle:t,children:n}){return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:e,subtitle:t,children:n})})}const Th=120;function By(e){const t=e.replace(/\s+/g," ").trim();return t.length>Th?`${t.slice(0,Th)}…`:t}function Ky(e){return By(ey(e).text)}function mD(e){const t=e.questions[0];return t?By(`${t.header}: ${t.question}`):""}function Eh(e){return e.name?.trim()?Vb(e):Es(e.agent_id)}function fD({members:e,permissions:t,asks:n,responding:s,connected:r,onDecidePermission:i,onRespondAsk:l}){const c=u.useMemo(()=>{const h=new Map;for(const p of e)p.session_id&&h.set(p.session_id,p);return h},[e]),d=u.useMemo(()=>t.flatMap(h=>{const p=h.sessionId?c.get(h.sessionId):void 0;return p?[{request:h,member:p}]:[]}),[t,c]),m=u.useMemo(()=>n.flatMap(h=>{const p=h.sessionId?c.get(h.sessionId):void 0;return p?[{request:h,member:p}]:[]}),[n,c]),f=d.length+m.length;return f===0?null:o.jsxs("section",{className:"team-pending-bar mb-2 flex min-w-0 flex-col gap-1.5","aria-label":a("team.pending.title",{count:f}),children:[o.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-ink",children:a("team.pending.title",{count:f})}),o.jsx("span",{className:"text-xs text-faint",children:a("team.pending.hint")})]}),o.jsxs("ul",{className:"m-0 flex max-h-80 min-w-0 list-none flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain p-0",children:[d.map(({request:h,member:p})=>{const g=Ky(h.input);return o.jsx("li",{className:"flex min-w-0 flex-col",children:o.jsx(Jt,{className:"stream-card-pending w-full min-w-0 max-w-full",defaultOpen:!0,title:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-sans text-xs font-medium text-ink",children:Eh(p)}),o.jsx("span",{className:"rounded-full bg-warn-soft px-1.5 py-0.5 text-xs text-warn",children:a("team.pending.permission")})]}),summary:g,children:o.jsx(Ud,{request:h,busy:s.has(h.requestId),connected:r,onDecide:(b,x)=>{i?.(h.requestId,b,x)}})})},`perm:${h.requestId}`)}),m.map(({request:h,member:p})=>{const g=mD(h);return o.jsx("li",{className:"flex min-w-0 flex-col",children:o.jsx(Jt,{className:"stream-card-pending w-full min-w-0 max-w-full",defaultOpen:!0,title:o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-sans text-xs font-medium text-ink",children:Eh(p)}),o.jsx(Re,{tone:"warn",children:a("team.pending.ask")})]}),summary:g.length>0?g:void 0,children:o.jsx(w1,{request:h,busy:s.has(h.requestId),onSubmit:b=>{l?.(h.requestId,b)},onCancel:()=>{l?.(h.requestId,[])}})})},`ask:${h.requestId}`)})]})]})}function hD(e){return e.length>16?`${e.slice(0,16)}…`:e}function pD({request:e}){const{ackNotify:t,responding:n}=Ae(),s=n.has(e.requestId);return o.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-raised p-3 shadow-elev-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-2xs text-faint",children:[o.jsxs("span",{className:"font-mono tabular-nums",children:["run ",hD(e.runId)]}),o.jsx("span",{className:"tabular-nums",children:bt(e.requestedAt)}),s&&o.jsx("span",{children:a("pending.item.responding")})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(Re,{tone:"neutral",children:a("pending.kind.notify")}),o.jsx("span",{className:"text-sm font-medium text-ink wrap-anywhere",children:e.title}),e.salience==="high"&&o.jsx(Re,{tone:"warn",children:a("pending.notice.high")})]}),o.jsx("div",{className:"whitespace-pre-wrap text-sm text-muted leading-relaxed wrap-anywhere",children:e.body}),e.refs!==void 0&&e.refs.length>0&&o.jsxs("div",{className:"flex flex-col gap-1 text-2xs text-faint",children:[o.jsx("span",{className:"font-semibold uppercase tracking-widest",children:a("pending.notice.refs")}),e.refs.map(r=>o.jsx("span",{className:"font-mono wrap-anywhere",children:r},r))]}),o.jsx("div",{className:"flex justify-end",children:o.jsx(G,{variant:"primary",size:"small",disabled:s,onClick:()=>{t(e.requestId)},children:a("pending.notice.ack")})})]})}const fl=/!\[([^\]\n]*)\]\(([^)\s]+)\)/g,hl=/https?:\/\/[^\s<>()"']+/g;function gD(e){return e.toLowerCase().startsWith("data:image/")?!0:e.startsWith("/")&&!e.startsWith("//")}function Ih(e){const t=[];let n=0;hl.lastIndex=0;let s=hl.exec(e);for(;s!==null;){s.index>n&&t.push({kind:"text",text:e.slice(n,s.index)});const r=s[0]??"";t.push({kind:"link",href:r,label:r}),n=s.index+r.length,s=hl.exec(e)}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function bD(e){const t=[];let n=0;fl.lastIndex=0;let s=fl.exec(e);for(;s!==null;){s.index>n&&t.push(...Ih(e.slice(n,s.index)));const r=s[1]??"",i=s[2]??"";gD(i)?t.push({kind:"image",src:i,alt:r}):t.push({kind:"link",href:i,label:r===""?i:r}),n=s.index+(s[0]??"").length,s=fl.exec(e)}return n<e.length&&t.push(...Ih(e.slice(n))),t}function vD(){return`b${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`}function yD(e){const t=u.useRef(new Set),[n,s]=u.useState(null),r=u.useCallback(async(i,l)=>{if(l.length!==0&&!t.current.has(i)){t.current.add(i),s(i);for(const c of l)Uv(c.requestId,c.answers.map(d=>d.question_id??"").filter(d=>d.length>0));try{const c=l.length>1?vD():void 0;await Promise.all(l.map(d=>e(d.requestId,d.answers,c)))}finally{t.current.delete(i),s(null)}}},[e]);return{busyKey:n,submit:r}}function Ws(e){return e.length>16?`${e.slice(0,16)}…`:e}function xD(e){const t=e.items[0];if(t===void 0)return"";if(t.kind==="permission"){const s=Ky(t.request.input),r=a("pending.queue.permission",{tool:t.request.tool});return s.length>0?`${r}: ${s}`:r}if(t.kind==="notify")return`${t.request.title}: ${t.request.body}`;const n=t.request.questions[0];return n===void 0?"":`${n.header}: ${n.question}`}function wD({text:e}){const t=u.useMemo(()=>bD(e),[e]);return o.jsx("div",{className:"flex flex-col gap-1.5 leading-relaxed wrap-anywhere",children:t.map((n,s)=>{const r=`${n.kind}-${s}`;return n.kind==="image"?o.jsx("img",{alt:n.alt,className:"max-h-64 w-auto max-w-full rounded-sm",loading:"lazy",referrerPolicy:"no-referrer",src:n.src},r):n.kind==="link"?o.jsx("a",{className:"text-accent-ink underline underline-offset-2 wrap-anywhere",href:n.href,rel:"noreferrer noopener",target:"_blank",children:n.label},r):o.jsx("span",{className:"whitespace-pre-wrap",children:n.text},r)})})}function kD({question:e,groupId:t,index:n,include:s,settled:r,draft:i,disabled:l,onToggleInclude:c,onChange:d}){const m=l||r;return o.jsxs("div",{className:be("flex flex-col gap-2 rounded-md bg-sunken p-3.5",s&&!r&&"outline-2 outline-offset-2 outline-accent-soft",r&&"opacity-70"),children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[o.jsx("div",{className:"font-mono text-2xs font-semibold uppercase tracking-widest text-accent-ink",children:e.header}),r?o.jsx("span",{className:"inline-flex items-center gap-1.5 text-sm text-muted",children:o.jsx(Re,{tone:"neutral",children:a("pending.item.answered")})}):o.jsxs("label",{className:be("inline-flex cursor-pointer items-center gap-1.5 text-sm",s?"text-ink":"text-muted"),children:[o.jsx("input",{className:"accent-accent",type:"checkbox",checked:s,disabled:l,onChange:c}),a("pending.item.include")]})]}),o.jsx(wD,{text:e.question}),o.jsx(Wd,{options:e.options??[],selected:i.selected,multi:e.multi_select===!0,disabled:m,name:`${t}-${n}`,onToggle:f=>{d({...i,selected:Kd(i.selected,f,e.multi_select===!0)})}}),o.jsx(Xe,{value:i.custom,disabled:m,onChange:f=>d({...i,custom:f.target.value}),placeholder:e.options?a("ask.customPlaceholder.options"):a("ask.customPlaceholder.open"),"aria-label":`${e.header}: ${e.question}`})]})}function SD({cluster:e,expanded:t,onToggle:n}){const{respondAsk:s,respondPermission:r,responding:i,connectionState:l,hasToken:c}=Ae(),{busyKey:d,submit:m}=yD(s),f=d===e.key,h=l==="open"&&c,p=Ad(),g=Md(),b=iv(),x=u.useMemo(()=>e.items.flatMap(O=>O.kind==="ask"?[O.request]:[]),[e.items]),y=u.useMemo(()=>Vv(x,p),[x,p]),v=u.useMemo(()=>{const O=new Map;for(const F of x)O.set(F.requestId,Jv(y.filter(V=>V.requestId===F.requestId)));return O},[x,y]),j=u.useMemo(()=>{const O=new Map;for(const F of y){if(F.settled||!F.answered||!F.draft.include)continue;const V=O.get(F.requestId);V===void 0?O.set(F.requestId,[F]):V.push(F)}return[...O.entries()].map(([F,V])=>({requestId:F,answers:v1(V)}))},[y]),_=y.filter(O=>!O.settled),S=_.filter(O=>O.answered),w=y.filter(O=>!O.settled&&O.answered&&O.draft.include).length,k=S.length>0&&S.every(O=>O.draft.include),N=_.some(O=>O.draft.include&&!O.answered),T=j.length>0&&!f,R=(O,F,V)=>{g(O,F,V)},E=(O,F,V)=>{R(O,F,B=>{const W=li(B)!==li(V);return{...B,...V,...W?{include:li(V)}:{}}})},I=(O,F)=>{R(O,F,V=>({...V,include:!V.include}))},$=()=>{const O=!k;for(const F of S)R(F.requestId,F.index,V=>({...V,include:O}))},C=()=>{if(!T)return;const O=j.map(F=>F.requestId);m(e.key,j).then(()=>{b(O)})},L=e.scope==="agent"?a("pending.cluster.agent",{id:Ws(e.agentId??"")}):e.scope==="session"?a("pending.cluster.session",{id:Ws(e.sessionId??"")}):a("pending.cluster.run",{id:Ws(e.items[0]?.request.runId??"")}),A=e.homeSessionId,D=A!==void 0&&A.length>0&&A!==e.sessionId?Ws(A):void 0;return o.jsx(et,{title:o.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[L,o.jsx(Hn,{count:e.items.length,label:a("pending.cluster.count",{count:e.items.length})}),o.jsx(Re,{tone:e.source==="team"?"info":"neutral",children:e.source==="team"?a("pending.source.team"):a("pending.source.session")}),D!==void 0&&o.jsx("span",{className:"font-mono text-2xs text-faint",children:a("pending.cluster.home",{id:D})})]}),description:bt(e.latestAt),actions:o.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[o.jsx(G,{size:"small",onClick:n,"aria-expanded":t,children:a(t?"pending.cluster.collapse":"pending.cluster.expand")}),t&&x.length>0&&o.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-1.5 text-sm text-muted",children:[o.jsx("input",{className:"accent-accent",type:"checkbox",checked:k,disabled:f||S.length===0,onChange:$}),a("pending.item.includeAll")]}),t&&w>0&&o.jsx("span",{className:"text-sm text-muted tabular-nums",children:a("pending.submit.count",{count:w})}),t&&x.length>0&&o.jsx(G,{variant:"primary",size:"small",disabled:!T,onClick:C,children:a(f?"pending.submit.busy":"pending.submit")})]}),children:t?o.jsxs("div",{className:"flex flex-col gap-3",children:[e.items.map(O=>{if(O.kind==="permission"){const ee=O.request,ie=i.has(ee.requestId);return o.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-raised p-3 shadow-elev-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-2xs text-faint",children:[o.jsxs("span",{className:"font-mono tabular-nums",children:["run ",Ws(ee.runId)]}),o.jsx("span",{className:"tabular-nums",children:bt(ee.requestedAt)}),ie&&o.jsx("span",{children:a("pending.item.responding")})]}),o.jsx(Ud,{request:ee,busy:ie,connected:h,onDecide:(le,J)=>{r(ee.requestId,le,J)}})]},ee.requestId)}if(O.kind==="notify")return o.jsx(pD,{request:O.request},O.request.requestId);const F=O.request,V=i.has(F.requestId),B=f||V,W=v.get(F.requestId)??{open:[],answered:[]},Z=ee=>o.jsx(kD,{question:ee.question,groupId:ee.requestId,index:ee.index,include:ee.draft.include,settled:ee.settled,draft:{selected:ee.draft.selected,custom:ee.draft.custom},disabled:B,onToggleInclude:()=>I(ee.requestId,ee.index),onChange:ie=>E(ee.requestId,ee.index,ie)},`${ee.requestId}:${ee.question.header}:${ee.question.question}`);return o.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-raised p-3 shadow-elev-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-2xs text-faint",children:[o.jsxs("span",{className:"font-mono tabular-nums",children:["run ",Ws(F.runId)]}),F.mode==="async"&&o.jsx("span",{className:"font-mono text-accent",children:a("ask.asyncBadge")}),o.jsx("span",{className:"tabular-nums",children:bt(F.requestedAt)}),V&&o.jsx("span",{children:a("pending.item.responding")})]}),W.open.map(Z),o.jsx(Kv,{count:W.answered.length,children:W.answered.map(Z)})]},F.requestId)}),N&&o.jsx("p",{className:"text-sm text-muted",role:"status",children:a("pending.answerRequired")}),S.length>0&&o.jsx("p",{className:"text-sm text-muted",children:a("pending.submit.note")})]}):o.jsx("p",{className:"text-sm text-muted wrap-anywhere",children:xD(e)})})}const jD="";function _D({sessionId:e}){He();const{permissions:t,asks:n,notices:s,ackNotify:r,responding:i,connectionState:l,hasToken:c,pendingFetch:d,hydrateInteractions:m,relogin:f}=Ae(),h=l==="open"&&c,p=u.useMemo(()=>n.map(T=>T.requestId),[n]);av(p,h);const[g,b]=u.useState(null),x=Yt(T=>T.roster),y=u.useMemo(()=>Se(x)??[],[x]),v=u.useMemo(()=>Nc(y),[y]),j=u.useMemo(()=>nA(t,n,s,v),[t,n,s,v]),_=()=>{for(const T of s)i.has(T.requestId)||r(T.requestId)},S=u.useMemo(()=>e===void 0||e===""?null:j.find(R=>R.homeSessionId===e||R.sessionId===e||cv(R.items,e,v).length>0)?.key??null,[j,e,v]),w=g??S,k=d.status==="failed",N=d.kind==="session"||d.kind==="origin"?a("pending.fetch.blocked",{detail:d.message??""}):a("pending.fetch.failed",{detail:d.message??""});return o.jsxs(Fy,{title:a("pending.title"),subtitle:a("pending.subtitle"),children:[k&&o.jsx("div",{className:"mb-3",children:o.jsx(Ve,{message:N,onRetry:()=>{m()},retryLabel:a("pending.fetch.retry"),action:d.kind==="session"?o.jsx(G,{onClick:f,children:a("gateway.rpc.relogin")}):void 0})}),j.length===0&&!k?o.jsx("div",{className:"flex min-h-60 flex-col justify-center",children:o.jsx($e,{title:a("pending.empty"),description:a("pending.empty.hint")})}):o.jsxs(o.Fragment,{children:[s.length>0&&o.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[o.jsx(Hn,{count:s.length,label:a("pending.notice.count",{count:s.length})}),o.jsx(G,{size:"small",onClick:_,children:a("pending.notice.ackAll")})]}),j.map(T=>o.jsx(SD,{cluster:T,expanded:T.key===w,onToggle:()=>b(w===T.key?jD:T.key)},T.key))]})]})}function ND(e){return e.find(t=>t.name==="marketplace")}function CD(e){const t=e?.config?.registry_url;return typeof t=="string"?t:""}function TD(e){if(Array.isArray(e?.plugins))return e.plugins;const t=e?.config;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const n=t.plugins;if(Array.isArray(n))return n}return[]}function ED(e){const t=TD(e).find(n=>n?.name==="marketplace");return CD(t)}function ID(e,t){return t?ED(e):""}function RD(e){const t=e.trim();if(t==="")return!1;try{const n=new URL(t);return n.protocol==="https:"?!0:n.protocol!=="http:"?!1:n.hostname==="localhost"||n.hostname==="127.0.0.1"||n.hostname==="[::1]"||n.hostname==="::1"}catch{return!1}}function LD(e,t){return t&&e?.enabled===!0}async function AD(e,t){await e.rpc("plugin.marketplace.configure",{registry_url:t.trim()})}const MD={active:"success",inactive:"neutral",unhealthy:"danger",disabled:"warn",invalid:"danger"};function PD(){He();const{client:e,hasToken:t,connectionState:n}=Ae(),s=t&&n==="open",r=ot(),{plugins:i,state:l,reload:c}=Bn(),{config:d,reloadConfig:m}=Qt(),f=Se(d),h=u.useMemo(()=>ND(i),[i]),p=ID({plugins:f?.plugins,config:f?.config},h?.enabled===!0),[g,b]=u.useState(p),x=u.useRef(p),[y,v]=u.useState(!1),[j,_]=u.useState(null);u.useEffect(()=>{x.current!==p&&(x.current=p,b(p))},[p]);const S=LD(h,s),w=async()=>{if(!RD(g)){_(a("pluginHost.registry.invalid"));return}v(!0),_(null);try{await AD(e,g),r.success(a("pluginHost.registry.saved")),c(),m()}catch(k){_(k instanceof Error?k.message:String(k))}finally{v(!1)}};return t?o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("nav.domain.pluginHost"),subtitle:a("pluginHost.subtitle"),children:!s&&i.length===0?o.jsx(Fe,{variant:"page",title:a("common.notConnected"),reason:a("pluginHost.disconnectedReason")}):l.status==="error"&&i.length===0?o.jsx(Ve,{message:l.error,onRetry:c}):l.status==="loading"&&i.length===0?o.jsx(Ke,{label:a("pluginHost.loading")}):o.jsxs(o.Fragment,{children:[o.jsx(et,{title:a("pluginHost.status.title"),children:h?o.jsx(Gt,{items:[{label:a("pluginHost.field.enabled"),value:o.jsx(Re,{tone:h.enabled?"success":"neutral",children:a(h.enabled?"pluginHost.enabled.on":"pluginHost.enabled.off")})},{label:a("pluginHost.field.status"),value:h.status?o.jsx(Re,{tone:MD[h.status],children:a(`pluginHost.status.${h.status}`)}):"—"},{label:a("pluginHost.field.version"),value:h.version??"—"},{label:a("pluginHost.field.mode"),value:h.mode?a(`pluginHost.mode.${h.mode}`):"—"},{label:a("pluginHost.field.plugins"),value:i.length}]}):o.jsx("p",{className:"m-0 text-md text-muted",children:a("pluginHost.marketplaceMissing")})}),o.jsxs(et,{title:a("pluginHost.registry.title"),description:a("pluginHost.registry.hint"),children:[o.jsx(We,{label:a("pluginHost.registry.label"),htmlFor:"plugin-host-registry-url",error:j??void 0,children:o.jsx(Xe,{id:"plugin-host-registry-url",value:g,placeholder:a("pluginHost.registry.placeholder"),disabled:!S||y,onChange:k=>{b(k.target.value),_(null)}})}),o.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o.jsx(G,{variant:"primary",size:"small",disabled:!S||y,onClick:()=>{w()},children:a(y?"pluginHost.registry.saving":"pluginHost.registry.save")}),!S&&o.jsx("span",{className:"text-sm text-faint",children:h===void 0?a("pluginHost.marketplaceMissing"):h.enabled?a("pluginHost.registry.disconnectedHint"):a("pluginHost.registry.disabledHint")})]})]})]})})}):o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:a("nav.domain.pluginHost"),subtitle:a("pluginHost.subtitle"),children:o.jsx(Fe,{variant:"page",title:a("common.notConnected"),reason:a("pluginHost.noTokenReason")})})})}class qD extends u.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error(`[vessel-plugin:${this.props.pluginId}] render error`,t,n.componentStack)}render(){const{error:t}=this.state;return t===null?this.props.children:o.jsx(Ve,{title:a("plugins.embed.errorTitle"),message:a("plugins.embed.errorBody",{plugin:this.props.pluginName,error:t.message}),onRetry:this.props.onRetry,action:o.jsx(G,{onClick:this.props.onIsolate,children:a("plugins.embed.useIsolated")})})}}function OD({plugin:e,page:t,methods:n,className:s,context:r}){const i=e.name,l=e.ui_embed,c=e.ui_bundle_hash??"",d=t.component??"",{nodeUrl:m}=Ae(),{surface:f,ready:h}=Cv(i,n),p=Nv(i,f),[g,b]=u.useState({status:"loading"}),[x,y]=u.useState(!1),[v,j]=u.useState(0),[_,S]=u.useState(0),w=u.useRef(null),k=l?.entry,N=l?.css,T=l?.runtime.react,R=l?.runtime.sdk,E=k!==void 0?ji(m,i,k):null;if(u.useEffect(()=>{if(k===void 0||T===void 0||R===void 0||c===""||d===""||E===null)return;let L=!0;return b({status:"loading"}),pv({url:E,hash:c,component:d,runtime:{react:T,sdk:R}}).then(A=>{L&&(A.status==="ready"&&(w.current=A.module),b(A))}),()=>{L=!1,gv(w.current),w.current=null,_v(i)}},[k,T,R,c,d,E,i,_]),u.useEffect(()=>{if(N===void 0||c==="")return;const L=ji(m,i,N);if(L===null)return;const A=document.createElement("link");return A.rel="stylesheet",A.href=`${L}?v=${c}`,document.head.appendChild(A),()=>{A.remove()}},[N,c,m,i]),x||l===void 0||c===""||d==="")return o.jsx(od,{pluginId:i,entry:t.entry,title:t.title,methods:n,context:r,className:s});const I=g.status==="ready"&&h?g:null,$=g.status==="ready"&&!h,C=o.jsx(G,{onClick:()=>y(!0),children:a("plugins.embed.useIsolated")});return o.jsxs("div",{className:be("relative min-h-0",s),children:[(g.status==="loading"||$)&&o.jsx(Ke,{label:a("plugins.embed.loading"),rows:3}),g.status==="incompatible"&&o.jsx(Ve,{title:a("plugins.embed.incompatibleTitle"),message:a("plugins.embed.incompatibleBody",{detail:g.detail}),action:C}),g.status==="failed"&&o.jsx(Ve,{title:a("plugins.embed.failedTitle"),message:a("plugins.embed.failedBody",{detail:g.detail}),onRetry:()=>S(L=>L+1),action:C}),I!==null&&o.jsx("div",{"data-vessel-plugin":i,"data-mount":"page",className:"h-full min-h-0 overflow-auto",children:o.jsx(qD,{pluginId:i,pluginName:e.name,onRetry:()=>j(L=>L+1),onIsolate:()=>y(!0),children:o.jsx(u.Suspense,{fallback:o.jsx(Ke,{label:a("plugins.embed.loading"),rows:3}),children:o.jsx(I.component,{host:p,mount:"page",context:{pageId:t.id,run:r?.run,session:r?.session}})})},`${i}:${c}:${v}`)})]})}const DD=new Set;function HD({route:e}){He();const{hasToken:t}=Ae(),{plugins:n,pages:s,methodsByPlugin:r,state:i,reload:l}=Bn(),c=e.pluginId??"",d=n.find(g=>g.name===c&&g.enabled),m=s.find(g=>g.pluginId===c&&(e.entry===void 0||g.entry===e.entry)),f=g=>{if(d===void 0||m===void 0)return null;const b=r.get(d.name)??DD;return m.component!==void 0&&d.ui_trust==="embedded"&&d.ui_embed!==void 0&&d.ui_bundle_hash!==void 0?o.jsx(OD,{plugin:d,page:m,methods:b,className:g}):o.jsx(od,{pluginId:d.name,entry:m.entry,title:m.title,methods:b,className:g})},h=t?c===""?o.jsx($e,{title:a("plugins.page.notFound")}):i.status==="loading"&&n.length===0?o.jsx(Ke,{label:a("plugins.page.loading")}):i.status==="error"&&n.length===0?o.jsx(Ve,{message:i.error,onRetry:l}):d===void 0||m===void 0?o.jsx($e,{title:a("plugins.page.notFound")}):f("flex-1 min-h-0"):o.jsx(Fe,{title:a("plugins.page.notConnected"),reason:a("plugins.page.notConnectedReason")});if(d!==void 0&&m!==void 0)return o.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden focus:outline-none",children:f("min-h-0 w-full flex-1")});const p=(i.status==="loading"||i.status==="error")&&n.length===0;return o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain",children:o.jsx(Ct,{title:m?.title??a("nav.domain.plugins"),subtitle:t&&!p?a("plugins.page.notFoundReason"):void 0,children:h})})}const $D=[{id:"all",labelKey:"runs.detail.filter.all"},{id:"llm",labelKey:"runs.detail.filter.llm"},{id:"tools",labelKey:"runs.detail.filter.tools"},{id:"errors",labelKey:"runs.detail.filter.errors"},{id:"internal",labelKey:"runs.detail.filter.internal"},{id:"other",labelKey:"runs.detail.filter.other"}];function FD(e){return Ac(e)==="internal"}function BD(e){return e==="error"||e==="guardrail.blocked"||e.endsWith(".failed")}function KD(e){return FD(e)?"internal":e.startsWith("llm.")?"llm":e.startsWith("tool.")?"tools":BD(e)?"errors":"other"}function pl(e){return`${e.type}@${e.ts}`}function Rh(e,t){const n=new Set(e.map(pl)),s=new Set(e.map(i=>i.seq).filter(i=>typeof i=="number"&&Number.isFinite(i))),r=[...e];for(const i of t)typeof i.seq=="number"&&s.has(i.seq)||n.has(pl(i))||(n.add(pl(i)),typeof i.seq=="number"&&s.add(i.seq),r.push(i));return r}function WD(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t]?.seq;if(typeof n=="number"&&Number.isFinite(n))return n}}function UD(e,t,n,s){if(e==="durable")return t?.run_id??s??n;if(t)return t.core_run_id??t.run_id}function zD(e){const t=e.message.toLowerCase();return e.code==="not_found"||e.code==="method_not_allowed"||t.includes("trace reader is not available")||t.includes("method_not_allowed")||t.includes("not_found")||t.includes("not available")}function Wy(e){try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}function VD(e,t,n=!1){if(e===void 0)return"—";const s=t??(n?Date.now():void 0);if(s===void 0)return"—";const r=Math.max(0,s-e);return r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`}function GD(e,t){const n=new Blob([Wy(e)],{type:"application/json"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=`run-${t.replace(/[^A-Za-z0-9_.-]+/g,"_")}.json`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)}const YD=200;function Ln(e){return typeof e=="string"&&e.length>0?e:void 0}function Uy(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function gl(e,t=240){const n=Uy(e).replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t)}…`:n}function JD(e){if(typeof e.message_count=="number")return e.message_count;if(Array.isArray(e.messages))return e.messages.length}function QD(e){const t=e.data;switch(e.type){case"tool.call.started":{const n=t.arguments!==void 0?t.arguments:t.args,s=[Ln(t.tool_name)??"tool"];return n!==void 0&&s.push(gl(n,200)),s.join(" ")}case"tool.call.completed":{const n=[Ln(t.tool_name)??"tool"];return typeof t.duration_ms=="number"&&n.push(`${t.duration_ms}ms`),t.result!==void 0&&n.push(gl(t.result,200)),n.join(" · ")}case"tool.call.failed":return[Ln(t.tool_name)??"tool",Ln(t.error)??"error"].join(" · ");case"llm.request":{const n=[],s=JD(t);return s!==void 0&&n.push(`${s} msgs`),Array.isArray(t.tools)&&t.tools.length>0&&n.push(`${t.tools.length} tools`),n.join(" · ")}case"llm.response":{const n=t.usage,s=[Ln(t.finish_reason)??""];return typeof n?.total_tokens=="number"&&s.push(`${n.total_tokens} tok`),s.filter(Boolean).join(" · ")}case"guardrail.blocked":return[Ln(t.guardrail_name)??"guardrail",Ln(t.reason)??""].filter(Boolean).join(" · ");default:{if(e.type==="error"||e.type.endsWith(".failed")||e.type.endsWith(".error")){const n=Ln(t.error)??Ln(t.message);if(n!==void 0)return n}return gl(t)}}}const Lh=new WeakMap;function XD(e){const t=Lh.get(e);if(t!==void 0)return t;const n=QD(e),s={key:`${e.seq??""}:${e.type}@${e.ts}`,event:e,summary:n,search:`${e.type} ${n} ${Uy(e.data)}`.toLowerCase()};return Lh.set(e,s),s}function ZD(e){return e.map(XD)}function Ah(e){const t=e.trim();if(t==="")return;const n=Number(t);return Number.isFinite(n)?Math.trunc(n):void 0}function e2(e,t={}){const n=t.category??"all",s=(t.typePrefix??"").trim().toLowerCase(),r=(t.keyword??"").trim().toLowerCase(),{fromSeq:i,toSeq:l}=t;return n==="all"&&s===""&&r===""&&i===void 0&&l===void 0?e:e.filter(c=>{if(i!==void 0){const d=c.event.seq;if(typeof d!="number"||d<i)return!1}if(l!==void 0){const d=c.event.seq;if(typeof d!="number"||d>l)return!1}return!(s!==""&&!c.event.type.toLowerCase().startsWith(s)||n!=="all"&&KD(c.event.type)!==n||r!==""&&!c.search.includes(r))})}function t2(e,t,n=YD){const s=e.length,r=Math.max(1,Math.ceil(s/n)),i=Math.min(Math.max(1,Math.trunc(t)||1),r),l=(i-1)*n;return{rows:e.slice(l,l+n),page:i,pageCount:r,total:s}}const n2="grid w-full grid-cols-[minmax(0,1fr)] gap-x-3 gap-y-0.5 bg-transparent px-2.5 py-1.5 text-left font-mono text-xs tint-hover tint-press wide:grid-cols-[11.5rem_4.5rem_minmax(8rem,15rem)_minmax(0,1fr)] wide:items-baseline",s2="hidden grid-cols-[11.5rem_4.5rem_minmax(8rem,15rem)_minmax(0,1fr)] gap-x-3 px-2.5 py-1.5 font-mono text-2xs tracking-widest text-faint uppercase wide:grid",Gr=be("w-auto px-2.25 py-1.25 text-xs font-mono",Vi);function o2({trace:e,tab:t,coreRunId:n}){const[s,r]=u.useState("all"),[i,l]=u.useState(""),[c,d]=u.useState(""),[m,f]=u.useState(""),[h,p]=u.useState(""),[g,b]=u.useState(1),[x,y]=u.useState(()=>new Set),v=u.useMemo(()=>ZD(e.events),[e.events]),j=u.useMemo(()=>({category:s,typePrefix:i,keyword:h,fromSeq:Ah(c),toSeq:Ah(m)}),[s,i,h,c,m]),_=u.useMemo(()=>e2(v,j),[v,j]),S=u.useMemo(()=>t2(_,g),[_,g]);u.useEffect(()=>{b(1)},[j]);const w=k=>{y(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T})};return o.jsxs("div",{children:[o.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o.jsxs("fieldset",{className:"flex flex-wrap gap-1",children:[o.jsx("legend",{className:"sr-only",children:a("runs.detail.filtersLabel")}),$D.map(k=>o.jsx(G,{variant:"chip",size:"small","aria-pressed":s===k.id,onClick:()=>r(k.id),children:a(k.labelKey)},k.id))]}),o.jsx(Xe,{className:be(Gr,"max-w-56"),value:i,onChange:k=>l(k.target.value),placeholder:a("runs.detail.typePrefix"),"aria-label":a("runs.detail.typePrefixLabel"),spellCheck:!1}),o.jsx(Xe,{className:be(Gr,"max-w-20"),value:c,onChange:k=>d(k.target.value),placeholder:"seq ≥","aria-label":a("runs.log.seqFrom"),inputMode:"numeric",spellCheck:!1}),o.jsx(Xe,{className:be(Gr,"max-w-20"),value:m,onChange:k=>f(k.target.value),placeholder:"seq ≤","aria-label":a("runs.log.seqTo"),inputMode:"numeric",spellCheck:!1}),o.jsx(Xe,{className:be(Gr,"max-w-64 grow basis-40"),value:h,onChange:k=>p(k.target.value),placeholder:a("runs.log.keyword"),"aria-label":a("runs.log.keywordLabel"),spellCheck:!1}),o.jsx(G,{size:"small",className:es,onClick:()=>{e.loadFirstPage()},children:a("runs.detail.refreshEvents")}),o.jsx(Re,{className:Ll,children:o.jsxs("span",{className:"tabular-nums",children:[_.length,"/",v.length]})})]}),e.traceError&&e.events.length===0?zD(e.traceError)?o.jsx(Fe,{title:a("runs.detail.traceDisabledTitle"),reason:e.traceError.message,hint:a("runs.detail.traceDisabledHint")}):o.jsx(Ve,{message:e.traceError.message,onRetry:()=>{e.loadFirstPage()}}):o.jsxs(o.Fragment,{children:[e.traceError&&o.jsx(st,{message:a("runs.detail.traceStale",{count:e.liveEvents.length}),onRetry:()=>{e.loadFirstPage()}}),e.traceLoading&&e.events.length===0?o.jsx(Ke,{label:a("runs.detail.loadingTrace")}):v.length===0?o.jsx($e,{title:a("runs.detail.emptyTraceTitle"),description:a(t==="live"&&!n?"runs.detail.emptyTraceQueued":"runs.detail.emptyTraceDesc")}):_.length===0?o.jsx($e,{title:a("runs.detail.noMatchTitle"),description:a("runs.log.noMatchDesc")}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mt-2 overflow-hidden rounded-md border border-line bg-transparent",children:[o.jsxs("div",{className:s2,children:[o.jsx("span",{children:a("runs.log.col.time")}),o.jsx("span",{children:"seq"}),o.jsx("span",{children:a("runs.log.col.type")}),o.jsx("span",{children:a("runs.log.col.summary")})]}),o.jsx("ul",{className:"m-0 flex list-none flex-col p-0",children:S.rows.map(k=>{const N=x.has(k.key),T=bt(k.event.ts,{withMs:!0}),R=N?Wy(k.event):"";return o.jsxs("li",{className:"border-t border-line first:border-t-0",children:[o.jsxs("button",{type:"button",className:n2,"aria-expanded":N,"aria-label":a("runs.log.rowLabel",{type:k.event.type,seq:k.event.seq??"—"}),onClick:()=>w(k.key),children:[o.jsxs("span",{className:"text-muted tabular-nums",children:[o.jsx("span",{className:"block",children:T===""?"—":T}),o.jsx("span",{className:"block text-2xs text-faint",children:k.event.ts})]}),o.jsx("span",{className:"text-faint tabular-nums",children:k.event.seq??"—"}),o.jsx("span",{className:be("wrap-anywhere",Ki(k.event.type)?"text-danger":"text-ink"),children:k.event.type}),o.jsx("span",{className:"truncate text-muted",children:k.summary})]}),N&&o.jsxs("div",{className:"border-t border-line px-2.5 py-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"font-mono text-2xs text-faint uppercase",children:"event json"}),o.jsx(ls,{text:R,label:a("runs.detail.copyJson"),toast:a("runs.detail.copiedJson")})]}),o.jsx("pre",{className:"json-body mt-1.5",children:R})]})]},k.key)})})]}),o.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2.5 text-sm",children:[S.pageCount>1&&o.jsxs(o.Fragment,{children:[o.jsx(G,{size:"small",className:es,disabled:S.page<=1,onClick:()=>b(S.page-1),children:a("runs.log.prev")}),o.jsx("span",{className:"text-muted tabular-nums",children:a("runs.log.pageOf",{page:S.page,pages:S.pageCount})}),o.jsx(G,{size:"small",className:es,disabled:S.page>=S.pageCount,onClick:()=>b(S.page+1),children:a("runs.log.next")})]}),e.hasMore&&o.jsxs(o.Fragment,{children:[o.jsx(G,{size:"small",className:es,disabled:e.loadingMore||e.sinceSeq===void 0,onClick:()=>{e.loadMore()},children:e.loadingMore?a("runs.detail.loadingMore"):a("runs.detail.loadMore",{count:e.trace.length})}),e.sinceSeq===void 0&&o.jsx("span",{className:"text-muted",children:a("runs.detail.missingSeq")}),o.jsx("span",{className:"text-muted",children:a("runs.log.loadedOnly")})]})]})]})]})]})}const Yr=500;function r2(e,t,n,s,r){const{client:i,hasToken:l}=Ae(),c=ot(),d=Ji(),[m,f]=u.useState([]),[h,p]=u.useState(null),[g,b]=u.useState(!1),[x,y]=u.useState(!1),[v,j]=u.useState(!1),[_,S]=u.useState(0),w=u.useRef(r),k=u.useRef(0),N=UD(t,n,e,s?.run_id),T=u.useMemo(()=>N?d.entries.filter(C=>C.event.run_id===N).map(C=>C.event):[],[d.entries,N]),R=u.useCallback(async()=>{if(!N||!l)return;k.current+=1;const C=k.current;b(!0),p(null);try{const L=await i.readEvents({run_id:N,limit:Yr});if(C!==k.current)return;f(L),j(L.length>=Yr)}catch(L){if(C!==k.current)return;f([]),j(!1),p({code:L.code,message:L instanceof Error?L.message:String(L)})}finally{C===k.current&&b(!1)}},[i,N,l]);u.useEffect(()=>{k.current+=1,f([]),j(!1),p(null)},[e,N]),u.useEffect(()=>{R()},[R,_]),u.useEffect(()=>{w.current&&!r&&S(C=>C+1),w.current=r},[r]);const E=u.useMemo(()=>Rh(m,T),[m,T]),I=WD(m);return{trace:m,traceError:h,traceLoading:g,loadingMore:x,hasMore:v,events:E,sinceSeq:I,liveEvents:T,coreRunId:N,loadFirstPage:R,loadMore:async()=>{if(!N||I===void 0||x)return;const C=k.current;y(!0);try{const L=await i.readEvents({run_id:N,since_seq:I,limit:Yr});if(C!==k.current)return;f(A=>Rh(A,L)),j(L.length>=Yr)}catch(L){C===k.current&&c.error(a("runs.detail.loadMoreFailed",{detail:L instanceof Error?L.message:String(L)}))}finally{C===k.current&&y(!1)}}}}function i2({runId:e,tab:t,run:n,durable:s,active:r,canWrite:i,connected:l,loading:c,missing:d,detailError:m,busy:f=!1,onBack:h,onCancel:p,onResume:g,onRetry:b}){He();const x=r2(e,t,n,s,r),{coreRunId:y}=x,v=n?.status??s?.status,j=n?.session_id??s?.session_id,_=n?.started_at,S=n?.completed_at,w=n?.usage,k=n??s,N=t==="live"&&v!==void 0&&Qd(v),T=t==="durable"&&v!==void 0&&Xd(v),R=n?.messages&&n.messages.length>0?n.messages[n.messages.length-1]?.content:void 0,E=n?.output,I=s?.preview??R;return o.jsxs(Ct,{title:a("runs.detail.title"),subtitle:a("runs.detailPage.subtitle"),children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(G,{size:"small",className:es,onClick:h,children:a("runs.detailPage.back")}),o.jsx(Tt,{status:v}),o.jsx("span",{className:"min-w-0 wrap-anywhere font-mono text-muted",title:e,children:e}),o.jsx(ls,{text:e,label:a("runs.detail.copyId"),toast:a("runs.detail.copiedId")}),k!==null&&o.jsx(G,{size:"small",className:es,onClick:()=>GD(k,e),children:a("runs.detail.exportJson")}),N&&o.jsx(G,{size:"small",variant:"dangerGhost",disabled:!i||f,title:i?void 0:a("common.writesDisabled"),onClick:()=>p(e),children:a(f?"runs.detail.cancelling":"runs.detail.cancel")}),T&&o.jsx(G,{size:"small",className:es,disabled:!i||f,title:i?void 0:a("common.writesDisabled"),onClick:()=>g(e),children:a(f?"runs.detail.resuming":"runs.detail.resume")})]}),!l&&o.jsx(st,{message:a("runs.detail.disconnected"),onRetry:b}),d?o.jsx(Ve,{message:m??a("runs.notFound"),onRetry:b}):c&&k===null?o.jsx(Ke,{label:a("runs.detailLoading")}):o.jsxs(o.Fragment,{children:[o.jsxs(et,{title:a("runs.detail.metaTitle"),children:[o.jsx(Gt,{items:[{key:"session",label:a("runs.detail.session"),value:j?o.jsx("a",{className:"font-mono text-accent underline underline-offset-2 hover:text-accent-ink",href:Fn({domain:"chat",sessionId:j}),children:j}):o.jsx("span",{className:"font-mono",children:"—"})},{key:"started",label:a("runs.detail.started"),value:o.jsx("span",{className:"font-mono tabular-nums",children:bt(_)})},{key:"ended",label:a("runs.detail.ended"),value:o.jsx("span",{className:"font-mono tabular-nums",children:bt(S)})},{key:"duration",label:a("runs.detail.duration"),value:o.jsx("span",{className:"font-mono tabular-nums",children:VD(_,S,v==="running"||v==="queued")})},...n?.iteration!==void 0||s?.iteration!==void 0?[{key:"iteration",label:"Iteration",value:o.jsx("span",{className:"font-mono tabular-nums",children:n?.iteration??s?.iteration})}]:[],...n?.agent_id||s?.agent_id?[{key:"agent",label:"Agent",value:o.jsx("span",{className:"font-mono",children:n?.agent_id??s?.agent_id})}]:[],...w?[{key:"tokens",label:"Tokens",value:o.jsxs("span",{className:"font-mono tabular-nums",children:[w.prompt_tokens??0," + ",w.completion_tokens??0," ="," ",w.total_tokens??0]})}]:[]]}),n?.error!==void 0&&n.error.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"mt-3 text-md font-semibold text-danger",children:a("runs.detail.errorTitle")}),o.jsx("pre",{className:"run-output text-danger",children:n.error})]})]}),o.jsx(et,{title:a("runs.log.title"),description:a("runs.log.hint"),children:o.jsx(o2,{trace:x,tab:t,coreRunId:y})}),o.jsxs("details",{className:`json-view ${Al}`,children:[o.jsx("summary",{children:a("runs.detail.outputTitle")}),E!==void 0&&E.length>0?o.jsx("pre",{className:"json-body",children:E}):I!==void 0&&I.length>0?o.jsxs("div",{className:"px-3 py-2",children:[o.jsx("span",{className:"font-mono text-2xs text-faint uppercase",children:a("runs.detail.checkpointPreview")}),o.jsx("pre",{className:"json-body mt-1 rounded-sm border border-line bg-transparent",children:I})]}):o.jsx("div",{className:"px-3 py-2",children:o.jsx($e,{title:a("runs.detail.emptyOutputTitle"),description:a("runs.detail.emptyOutputDesc")})})]}),k!==null&&o.jsx(id,{value:k,label:a("runs.detail.rawLabel"),maxHeight:520,className:Al}),o.jsx(Fg,{slot:"run-detail",context:{run:e,session:j},className:"mt-1"})]})]})}function a2({query:e,onQueryChange:t,tab:n,onTabChange:s}){return o.jsxs(En,{label:a("runs.searchLabel"),children:[o.jsx(Tn,{value:e,onChange:t,placeholder:a("runs.searchPlaceholder"),ariaLabel:a("runs.searchLabel"),className:"grow basis-60 max-w-search"}),o.jsx(Nn,{className:"mt-0 ml-auto",label:a("runs.sourceLabel"),tabs:[{id:"live",label:a("runs.source.live")},{id:"durable",label:a("runs.source.durable")}],value:n,onChange:s,panelId:"runs-panel"})]})}function l2(e,t,n=!1){if(e===void 0)return"—";const s=t??(n?Date.now():void 0);if(s===void 0)return"—";const r=Math.max(0,s-e);return r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`}function zy(e){const t=e?.cache_read_input_tokens,n=e?.prompt_tokens;if(!(t===void 0||n===void 0||n<=0))return{read:t,prompt:n}}function Mh(e){const t=zy(e);if(!t)return"—";const n=t.read/t.prompt;if(n>=1)return"100%";const s=Math.round(n*1e3)/10;return`${Math.min(s,99.9).toFixed(1)}%`}function Ph(e){const t=zy(e);if(!t)return;const n=new Intl.NumberFormat("en-US").format;return`${n(t.read)} / ${n(t.prompt)}`}function qh(e){if(typeof e!="object"||e===null)return;const t=e.usage;return typeof t=="object"&&t!==null?t:void 0}function Ro(e){return e.length>12?e.slice(0,12):e}function c2({tab:e,windowed:t,connected:n,busy:s,activeKey:r,status:i,onStatusChange:l,filterList:c,agentId:d,onAgentIdChange:m,agentOptions:f,sessionNames:h,agentNames:p,onCancel:g,onResume:b,onOpenRun:x,onOpenSession:y,onSelectAgent:v,onShowMore:j}){const _=w=>o.jsx(Qu,{label:String(w),allValue:"all",value:i,options:c.filter(k=>k.id!=="all").map(k=>({value:k.id,label:a(k.labelKey)})),onChange:k=>l(k)}),S=w=>o.jsx(Qu,{label:String(w),allValue:"",value:d,searchThreshold:0,options:f.map(k=>({value:k,label:p.get(k)??Ro(k)})),onChange:m});return o.jsxs(o.Fragment,{children:[e==="live"?o.jsx($n,{columns:[{key:"runId",header:a("runs.col.runId"),cell:w=>o.jsx(G,{variant:"link",className:"font-mono",title:w.run_id,onClick:()=>x(w.run_id,w.session_id),children:w.run_id.slice(0,16)})},{key:"status",header:a("runs.col.state"),headerFilter:_,cell:w=>o.jsx(Tt,{status:w.status,label:w.status==="queued"&&w.queue_position!==void 0?a("chat.run.queuedPosition",{position:w.queue_position}):void 0})},{key:"session",header:a("runs.col.session"),hide:"compact",cell:w=>{const k=h.get(w.session_id);return o.jsx(G,{variant:"link",className:k?void 0:"font-mono",title:k??w.session_id,onClick:()=>y(w.session_id),children:k??Ro(w.session_id)})}},{key:"agent",header:a("runs.col.agent"),hide:"wide",headerFilter:S,cell:w=>{const k=Zd(w);if(!k)return o.jsx("span",{className:"text-muted",children:"—"});const N=p.get(k);return o.jsx(G,{variant:"link",className:N?void 0:"font-mono",title:N??k,onClick:()=>v(k),children:N??Ro(k)})}},{key:"started",header:a("runs.col.started"),cellClassName:"font-mono tabular-nums",cell:w=>bt(w.started_at)},{key:"duration",header:a("runs.col.duration"),hide:"compact",cellClassName:"font-mono tabular-nums",cell:w=>l2(w.started_at,w.completed_at,w.status==="running"||w.status==="queued")},{key:"tokens",header:"Tokens",hide:"wide",cellClassName:"font-mono tabular-nums",cell:w=>w.usage?.total_tokens??"—"},{key:"cache",header:a("runs.col.cacheHit"),hide:"wide",cellClassName:"font-mono tabular-nums",cell:w=>{const k=qh(w);return o.jsx("span",{title:Ph(k),children:Mh(k)})}},{key:"actions",header:a("runs.col.actions"),cell:w=>Qd(w.status)?o.jsx(G,{size:"small",variant:"dangerGhost",disabled:!n||s.has(w.run_id),title:n?void 0:a("common.writesDisabled"),onClick:()=>g(w.run_id),children:s.has(w.run_id)?a("runs.cancelling"):a("runs.cancel")}):o.jsx("span",{className:"text-muted",children:"—"})}],rows:t.shown,rowKey:w=>w.run_id,activeKey:r}):o.jsx($n,{columns:[{key:"runId",header:a("runs.col.runId"),cell:w=>o.jsx(G,{variant:"link",className:"font-mono",title:w.run_id,onClick:()=>x(w.run_id,w.session_id),children:w.run_id.slice(0,16)})},{key:"status",header:a("runs.col.state"),headerFilter:_,cell:w=>o.jsx(Tt,{status:w.status})},{key:"session",header:a("runs.col.session"),hide:"compact",cell:w=>{const k=h.get(w.session_id);return o.jsx(G,{variant:"link",className:k?void 0:"font-mono",title:k??w.session_id,onClick:()=>y(w.session_id),children:k??Ro(w.session_id)})}},{key:"agent",header:a("runs.col.agent"),hide:"wide",headerFilter:S,cell:w=>{if(!w.agent_id)return o.jsx("span",{className:"text-muted",children:"—"});const k=p.get(w.agent_id);return o.jsx(G,{variant:"link",className:k?void 0:"font-mono",title:k??w.agent_id,onClick:()=>v(w.agent_id??""),children:k??Ro(w.agent_id)})}},{key:"iteration",header:a("runs.col.iter"),hide:"compact",cellClassName:"font-mono tabular-nums",cell:w=>w.iteration??"—"},{key:"cache",header:a("runs.col.cacheHit"),hide:"wide",cellClassName:"font-mono tabular-nums",cell:w=>{const k=qh(w);return o.jsx("span",{title:Ph(k),children:Mh(k)})}},{key:"updated",header:a("runs.col.updated"),cellClassName:"font-mono tabular-nums",cell:w=>bt(w.updated_at)},{key:"actions",header:a("runs.col.actions"),cell:w=>Xd(w.status)?o.jsx(G,{size:"small",disabled:!n||s.has(w.run_id),title:n?void 0:a("common.writesDisabled"),onClick:()=>b(w.run_id),children:s.has(w.run_id)?a("runs.resuming"):a("runs.resume")}):o.jsx("span",{className:"text-muted",children:"—"})}],rows:t.shown,rowKey:w=>w.run_id,activeKey:r}),t.hiddenCount>0&&o.jsx(G,{variant:"plain",className:"mx-auto mt-2 rounded-full px-3.5 py-2 text-xs text-muted",onClick:j,children:a("common.showMore",{count:t.hiddenCount})})]})}const d2=[{id:"all",labelKey:"runs.filter.all"},{id:"queued",labelKey:"runs.filter.queued"},{id:"running",labelKey:"runs.filter.running"},{id:"completed",labelKey:"runs.filter.completed"},{id:"failed",labelKey:"runs.filter.failed"},{id:"cancelled",labelKey:"runs.filter.cancelled"}],u2=[{id:"all",labelKey:"runs.filter.all"},{id:"interrupted",labelKey:"runs.filter.interrupted"},{id:"running",labelKey:"runs.filter.running"},{id:"completed",labelKey:"runs.filter.completed"},{id:"failed",labelKey:"runs.filter.failed"},{id:"cancelled",labelKey:"runs.filter.cancelled"}];function Oh(e){return e instanceof Error?e.message:String(e)}function m2(e,t){const{client:n,connectionState:s,hasToken:r,features:i,epoch:l,eventStore:c}=Ae(),d=ot(),m=r&&s==="open",f=r&&i.includes("durable-resume"),[h,p]=u.useState(""),[g,b]=u.useState("all"),[x,y]=u.useState(100),[v,j]=u.useState(""),[_,S]=u.useState(new Set),{nodes:w,teamControl:k,current:N}=ut(),T=zO(N),R=T?.live,E=T?.durable,I=ya(de=>de.loadRuns),$=N?ge(N):"",C=it(de=>de.sessions),L=it(de=>de.loadSessions),A=Yt(de=>de.roster),D=Yt(de=>de.loadRoster),O=w.map(de=>ge(de)).join(",");u.useEffect(()=>{r&&(L(n,{epoch:l}),w.length>0&&D(w,k))},[n,r,l,O]);const F=u.useCallback(()=>{N&&r&&I(n,N,"live")},[n,N,r,I]),V=u.useCallback(()=>{N&&f&&I(n,N,"durable")},[n,N,f,I]);u.useEffect(()=>zp(()=>{F(),V()}),[F,V]),qt(F,{enabled:r&&N!==null,deps:[l,$],pollMs:1e4}),qt(V,{enabled:f&&N!==null,deps:[l,$],pollMs:15e3});const B=u.useMemo(()=>Xq(Se(R)??[]),[R]),W=u.useMemo(()=>Zq(Se(E)??[]),[E]),Z=eO(B,{query:h,status:g,...e.sessionId?{sessionId:e.sessionId}:{},...v?{agentId:v}:{}}),ee=tO(W,{query:h,status:g,...e.sessionId?{sessionId:e.sessionId}:{},...v?{agentId:v}:{}}),ie=ph(Z,x),le=ph(ee,x),J=u.useMemo(()=>{const de=new Set;for(const qe of e.tab==="live"?B:W)qe.agent_id&&de.add(qe.agent_id);return[...de].sort((qe,Oe)=>qe.localeCompare(Oe))},[e.tab,B,W]),z=u.useMemo(()=>new Map(C.map(de=>[de.session_id,Sn(de)])),[C]),me=u.useMemo(()=>{const de=new Map;for(const qe of ql(Se(A)??[])){const Oe=qe.member.name?.trim();Oe&&de.set(qe.member.agent_id,Oe)}return de},[A]);u.useEffect(()=>{y(100),b("all"),j("")},[e.tab]);const K=e.runId?B.find(de=>de.run_id===e.runId):void 0,ne=e.runId?W.find(de=>de.run_id===e.runId):void 0,[Ne,ce]=u.useState(!1),se=Ft({load:async()=>{if(!e.runId)return null;try{return await n.getRunCanonical(e.runId)}catch{return e.tab==="live"?K??null:null}},enabled:r&&!!e.runId,...m&&Ne?{pollMs:2e3}:{},deps:[e.runId,e.tab,l]}),we=Se(se.state),he=we&&we.run_id===e.runId?we:K??null,pe=he?.status??ne?.status,Me=pe==="queued"||pe==="running";u.useEffect(()=>{ce(!1)},[e.runId,e.tab]),u.useEffect(()=>{he&&ce(pe==="queued"||pe==="running")},[he,pe]);const oe=u.useCallback(()=>{F(),V(),se.reload()},[F,V,se.reload]);Lt(oe);const je=u.useRef(-1),Ee=u.useRef(void 0);u.useEffect(()=>{const de=c.subscribe(()=>{const qe=c.getSnapshot();qe.version===je.current||(je.current=qe.version,!qe.entries.slice(-100).some(({event:ue})=>ue.type.startsWith("run.")))||(window.clearTimeout(Ee.current),Ee.current=window.setTimeout(()=>{F(),f&&V(),e.runId&&se.reload()},500))});return()=>{de(),window.clearTimeout(Ee.current)}},[c,F,V,se.reload,f,e.runId]);const Ce=u.useCallback(async(de,qe)=>{S(Oe=>new Set(Oe).add(de));try{await qe()}finally{S(Oe=>{const ue=new Set(Oe);return ue.delete(de),ue})}},[]),U=u.useCallback(de=>{if(!m){d.error(a("runs.toast.disconnectedCancel"));return}Ce(de,async()=>{try{(await n.cancelRun(de)).cancelled?(d.success(a("runs.toast.cancelRequested")),F(),e.runId===de&&se.reload()):d.error(a("runs.toast.cancelNotAccepted"))}catch(qe){d.error(Oh(qe))}})},[n,m,se.reload,F,e.runId,d,Ce]),q=u.useCallback(de=>{if(!m){d.error(a("runs.toast.disconnectedResume"));return}Ce(de,async()=>{try{await n.resumeRun(de),d.success(a("runs.toast.resumed")),V()}catch(qe){nO(qe)?(d.info(a("runs.toast.resuming")),V()):d.error(Oh(qe))}})},[n,m,V,d,Ce]),M=u.useMemo(()=>{const de=B.slice(0,10),qe=W.slice(0,10);return[...de.map(Oe=>({id:`run-${Oe.run_id}`,group:"entity",label:a("runs.palette.live",{id:Oe.run_id.slice(0,14)}),keywords:[Oe.session_id,Oe.status],hint:a("palette.hint.run"),run:()=>t({domain:"runs",tab:"live",runId:Oe.run_id,sessionId:Oe.session_id})})),...qe.map(Oe=>({id:`durable-${Oe.run_id}`,group:"entity",label:a("runs.palette.durable",{id:Oe.run_id.slice(0,14)}),keywords:[Oe.session_id,Oe.status,Oe.agent_id??""],hint:a("palette.hint.run"),run:()=>t({domain:"runs",tab:"durable",runId:Oe.run_id,sessionId:Oe.session_id})}))]},[B,W,t]),H=u.useMemo(()=>oO({live:B,durable:W,openRun:(de,qe,Oe)=>t({domain:"runs",tab:qe,runId:de,sessionId:Oe}),cancel:U,resume:q}),[B,W,t,U,q]);mi("runs",[...M,...H]);const X=e.tab==="live"?d2:u2,Y=e.tab==="live"?B:W,re=e.tab==="live"?Z:ee,_e=e.tab==="live"?ie:le,fe=e.tab==="live"?R:E,Pe=e.tab==="live"?F:V,ke=fe?.status==="error"?fe.error:null,Ge=fe===void 0||fe.status==="idle"||fe.status==="loading"&&Y.length===0,mt=!!e.runId&&!he&&!ne&&se.state.status!=="idle"&&se.state.status!=="loading",lt=!!e.runId&&(se.state.status==="idle"||se.state.status==="loading")&&!he&&!ne;return{hasToken:r,connected:m,durableAvailable:f,query:h,setQuery:p,status:g,setStatus:b,limit:x,setLimit:y,agentId:v,setAgentId:j,busy:_,filterList:X,current:Y,filtered:re,windowed:_e,resourceState:fe,reloadResource:Pe,resourceError:ke,loading:Ge,agentOptions:J,sessionNames:z,agentNames:me,reloadAll:oe,detailResource:se,detailRun:he,knownDurable:ne,detailMissing:mt,detailLoading:lt,activeDetail:Me,cancel:U,resume:q}}const Dh="flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain";function f2({route:e,navigate:t}){He();const{hasToken:n,connected:s,durableAvailable:r,query:i,setQuery:l,status:c,setStatus:d,setLimit:m,agentId:f,setAgentId:h,busy:p,filterList:g,current:b,filtered:x,windowed:y,reloadResource:v,resourceError:j,loading:_,agentOptions:S,sessionNames:w,agentNames:k,reloadAll:N,detailResource:T,detailRun:R,knownDurable:E,detailMissing:I,detailLoading:$,activeDetail:C,cancel:L,resume:A}=m2(e,t),D=W=>{t({...e,...W})},O=u.useRef(null),F=W=>{O.current?.scrollTo?.({top:0}),t({domain:"runs",tab:W})},V=()=>{O.current?.scrollTo?.({top:0}),t({domain:"runs",tab:e.tab,...e.sessionId?{sessionId:e.sessionId}:{}})},B=e.runId;return B?o.jsx("div",{ref:O,className:Dh,children:o.jsx(i2,{runId:B,tab:e.tab,run:R,durable:E??null,active:C,canWrite:s,connected:s,loading:$,missing:I,detailError:T.state.status==="error"?T.state.error:null,busy:p.has(B),onBack:V,onCancel:L,onResume:A,onRetry:T.reload})}):o.jsx("div",{ref:O,className:Dh,children:o.jsxs(Ct,{title:a("runs.title"),subtitle:a("runs.subtitle"),children:[o.jsx(a2,{query:i,onQueryChange:l,tab:e.tab,onTabChange:F}),o.jsx("div",{className:"flex flex-col gap-4",id:"runs-panel",role:"tabpanel","aria-label":a("runs.title"),children:n?e.tab==="durable"&&!r?o.jsx(Fe,{title:a("runs.durableDisabledTitle"),reason:a("runs.durableDisabledReason"),hint:a("runs.durableDisabledHint")}):o.jsxs(o.Fragment,{children:[!s&&b.length>0&&o.jsx(st,{message:a("runs.disconnected"),onRetry:N}),j&&b.length>0&&o.jsx(st,{message:a("common.staleData",{detail:j}),onRetry:N}),j&&b.length===0?o.jsx(Ve,{message:j,onRetry:v}):_?o.jsx(Ke,{label:a("runs.loading")}):b.length===0?o.jsx($e,{title:a(e.tab==="live"?"runs.emptyLiveTitle":"runs.emptyDurableTitle"),description:a(e.tab==="live"?"runs.emptyLiveDesc":"runs.emptyDurableDesc"),action:e.tab==="live"?o.jsx(G,{variant:"primary",onClick:()=>t({domain:"chat",sessionId:"new"}),children:a("common.newSession")}):void 0}):x.length===0?o.jsx($e,{title:a("runs.noMatchTitle"),description:a("runs.noMatchDesc"),action:o.jsx(G,{onClick:()=>{l(""),d("all"),h(""),D({sessionId:void 0})},children:a("common.clearFilters")})}):o.jsx(c2,{tab:e.tab,windowed:y,connected:s,busy:p,status:c,onStatusChange:d,filterList:g,agentId:f,onAgentIdChange:h,agentOptions:S,sessionNames:w,agentNames:k,onCancel:L,onResume:A,onOpenRun:(W,Z)=>D({runId:W,sessionId:Z}),onOpenSession:W=>t({domain:"chat",sessionId:W}),onSelectAgent:h,onShowMore:()=>m(W=>W+100)})]}):o.jsx($e,{title:a("runs.noTokenTitle"),action:o.jsx(G,{onClick:()=>t({domain:"gateway"}),children:a("common.configureConnection")})})})]})})}function h2(e){return e.map(t=>({id:t.id,name:t.name,enabled:t.enabled,version:t.version,scope:t.scope,kind:t.kind,mode:t.mode,restartRequired:t.restartRequired,pendingRestart:t.pendingRestart??t.restartRequired,...t.lifecycle!==void 0?{lifecycle:t.lifecycle}:{},...t.status!==void 0?{status:t.status}:{}}))}function p2(e){return e.map(t=>({id:t.name,name:t.name,enabled:t.enabled}))}const g2=[{id:"methods",labelKey:"capabilities.tab.methods"},{id:"tools",labelKey:"capabilities.tab.tools"},{id:"plugins",labelKey:"capabilities.tab.plugins"}];function b2(e,t){const n={methods:e.methods.length,tools:e.tools.length,plugins:t.length,enabledPlugins:t.filter(s=>s.enabled).length,read:0,write:0,admin:0};for(const s of e.methods)n[s.permission]+=1;return n}function v2(e){return(e??"").trim().toLowerCase()}function y2(e,t,{tab:n,query:s}){const r=v2(s),i=n==="methods"?e.methods.filter(d=>!r||d.name.toLowerCase().includes(r)):[],l=n==="tools"?e.tools.filter(d=>!r||d.name.toLowerCase().includes(r)||(d.description??"").toLowerCase().includes(r)):[],c=n==="plugins"?t.filter(d=>!r||d.name.toLowerCase().includes(r)||d.id.toLowerCase().includes(r)):[];return{tab:n,methods:i,tools:l,plugins:c}}function x2(e){return["read","write","admin"].map(n=>({permission:n,methods:e.filter(s=>s.permission===n).sort((s,r)=>s.name.localeCompare(r.name))})).filter(n=>n.methods.length>0)}function w2(e,t){return e==="methods"?a("capabilities.tab.methodsCount",{count:t.methods}):e==="tools"?a("capabilities.tab.toolsCount",{count:t.tools}):a("capabilities.tab.pluginsCount",{enabled:t.enabledPlugins,total:t.plugins})}function k2(){He();const{client:e,connectionState:t,hasToken:n,epoch:s}=Ae(),r=n&&t==="open",[i,l]=u.useState("methods"),[c,d]=u.useState(""),{capabilities:m,reloadCapabilities:f}=Qt({config:!1,capabilities:!0}),h=Ft({load:()=>sd(e),enabled:n&&t==="open",deps:[s,t]});Lt(f),Lt(h.reload);const p=Se(m),g=h.state.status==="success"?h.state.data:void 0,b=h.state.status==="success"&&g===null,x=u.useMemo(()=>Array.isArray(g)?h2(g):p?p2(p.plugins):[],[g,p]),y=u.useMemo(()=>p?b2(p,x):null,[p,x]),v=u.useMemo(()=>p?y2(p,x,{tab:i,query:c}):null,[p,x,i,c]),j=u.useMemo(()=>v?x2(v.methods):[],[v]);if(!n)return o.jsx(Fe,{title:a("common.notConnected"),reason:a("capabilities.noTokenReason")});if(m.status==="idle"||m.status==="loading"&&!p)return o.jsx(Ke,{label:a("capabilities.loading")});if(!p)return o.jsx(Ve,{message:m.status==="error"?m.error:a("capabilities.noManifest"),onRetry:f});const _=g2.map(S=>({id:S.id,label:y?w2(S.id,y):a(S.labelKey)}));return o.jsxs("div",{className:"flex flex-col gap-6",children:[!r&&o.jsx(st,{message:a("capabilities.stale"),onRetry:f}),m.status==="error"&&o.jsx(st,{message:a("common.staleData",{detail:m.error}),onRetry:f}),b&&o.jsx(st,{message:a("capabilities.catalogUnavailable"),onRetry:h.reload}),o.jsxs("div",{className:"flex flex-col gap-3",children:[y&&o.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[o.jsx(jt,{className:"min-w-40 flex-1",value:y.methods,label:a("capabilities.methodsCount",{read:y.read,write:y.write,admin:y.admin})}),o.jsx(jt,{className:"min-w-40 flex-1",value:y.tools,label:a("capabilities.tools")}),o.jsx(jt,{className:"min-w-40 flex-1",value:`${y.enabledPlugins}/${y.plugins}`,label:a("capabilities.pluginsEnabled")})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsx(Nn,{label:a("capabilities.tabsLabel"),tabs:_,value:i,onChange:l}),o.jsxs("span",{className:"font-mono text-md text-muted",children:["v",p.version," · schema ",p.config_schema_version]})]}),o.jsxs(En,{label:a("capabilities.searchLabel"),children:[o.jsx(Tn,{value:c,onChange:d,placeholder:a(`capabilities.search.${i}`),ariaLabel:a("capabilities.searchLabel"),className:"grow basis-60 max-w-search"}),o.jsx(Re,{children:i==="methods"?v?.methods.length:i==="tools"?v?.tools.length:v?.plugins.length})]})]}),i==="methods"&&(j.length===0?o.jsx("p",{className:"text-md text-muted",children:a("capabilities.noMatchMethods")}):j.map(S=>o.jsx(et,{titleAs:"h3",title:o.jsxs(o.Fragment,{children:[a("capabilities.methodsTitle",{permission:S.permission})," ",o.jsx(Re,{children:S.methods.length})]}),children:o.jsx($n,{columns:[{key:"method",header:a("capabilities.col.method"),cellClassName:"font-mono",cell:w=>w.name},{key:"permission",header:a("capabilities.col.permission"),cell:()=>o.jsx("span",{className:`perm-badge perm-${S.permission}`,children:S.permission})}],rows:S.methods,rowKey:w=>w.name})},S.permission))),i==="tools"&&o.jsx(et,{title:o.jsxs(o.Fragment,{children:[a("capabilities.toolsTitle")," ",o.jsx(Re,{children:v?.tools.length??0})]}),children:v&&v.tools.length===0?o.jsx("p",{className:"text-md text-muted",children:a("capabilities.noMatchTools")}):o.jsx("ul",{className:"plain-list",children:v?.tools.map(S=>o.jsxs("li",{children:[o.jsx("span",{className:"font-mono",children:S.name}),S.description&&o.jsxs("span",{className:"text-muted",children:[" — ",S.description]})]},S.name))})}),i==="plugins"&&o.jsx(et,{title:o.jsxs(o.Fragment,{children:[a("capabilities.pluginsTitle")," ",o.jsx(Re,{children:v?.plugins.length??0})]}),description:a("capabilities.pluginsDescription"),children:v&&v.plugins.length===0?o.jsx("p",{className:"text-md text-muted",children:a("capabilities.noMatchPlugins")}):o.jsx($n,{columns:[{key:"plugin",header:a("capabilities.col.plugin"),cell:S=>o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono",children:S.name}),S.version&&o.jsx("span",{className:"ml-1.5 text-sm text-muted",children:S.version})]})},{key:"scope",header:a("capabilities.col.scope"),hide:"compact",cell:S=>S.scope?o.jsx(Re,{children:a(`capabilities.scope.${S.scope}`)}):"—"},{key:"mode",header:a("capabilities.col.mode"),hide:"wide",cell:S=>S.mode?o.jsx(Re,{tone:S.mode==="in-process"?"neutral":"info",children:a(`capabilities.mode.${S.mode}`)}):"—"},{key:"state",header:a("capabilities.col.state"),cell:S=>o.jsx(Re,{tone:S.enabled?"success":"neutral",children:a(S.enabled?"capabilities.enabled":"capabilities.disabled")})},{key:"restart",header:a("capabilities.col.restart"),hide:"compact",cell:S=>S.pendingRestart?o.jsx(Re,{tone:"warn",children:a("capabilities.restartRequired")}):"—"}],rows:v?.plugins??[],rowKey:S=>S.id})})]})}function S2(){return He(),o.jsx(Fy,{title:a("nav.domain.capabilities"),subtitle:a("capabilities.subtitle"),children:o.jsx(k2,{})})}function j2({team:e,archived:t,nodeName:n,nodeCurrent:s=!1,frozen:r=!1,onBackToList:i}){return o.jsx("header",{className:"team-chat-head",children:o.jsx(xr,{title:e?.name?.trim()||a("entity.unnamed"),scope:n?[{label:n}]:[],current:s,status:t||r?o.jsxs(o.Fragment,{children:[t&&o.jsx(Re,{tone:"warn",children:a("teams.chat.archived")}),r&&o.jsx(Re,{tone:"warn",children:a("teams.frozen")})]}):void 0,actions:o.jsx(G,{className:"team-chat-back hidden max-wide:inline-flex",onClick:i,children:a("team.chat.backToList")})})})}function _2({candidates:e,activeIndex:t,listId:n,onPick:s,onHover:r}){return o.jsxs("div",{className:"mb-1.5 overflow-hidden rounded-md bg-surface shadow-elev-2 forced-colors:border",children:[o.jsx("p",{className:"m-0 px-2.5 pt-2 pb-1 font-mono text-2xs uppercase tracking-wider text-faint",children:a("team.mention.title")}),o.jsxs("div",{className:"team-mention-list overflow-y-auto px-1 pb-1",id:n,role:"listbox","aria-label":a("team.a11y.mentionList"),children:[e.length===0&&o.jsx("p",{className:"m-0 px-2.5 py-2 text-sm text-muted",role:"status",children:a("team.mention.empty")}),e.map((i,l)=>{const c=ha(i.member),d=l===t;return o.jsxs("button",{id:`${n}-option-${l}`,type:"button",role:"option",tabIndex:-1,"aria-selected":d,className:`flex w-full cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent px-2 py-1.5 text-left text-inherit hover:bg-hover ${d?"bg-hover":""}`.trim(),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>r(l),onClick:()=>s(i),children:[o.jsx("span",{className:"grid size-7 flex-none place-items-center rounded-full bg-sunken font-mono text-xs uppercase text-muted","aria-hidden":"true",children:i.label.slice(0,1).toUpperCase()}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:i.label}),o.jsx(Tt,{status:c.chipStatus,label:a(c.labelKey),title:c.titleKey?a(c.titleKey):void 0}),o.jsx("span",{role:"img",className:`size-1.5 flex-none rounded-full ${i.member.presence==="live"?"bg-success":"border border-faint bg-transparent"}`,"aria-label":i.member.presence==="live"?a("team.presence.live"):a("team.presence.gone")})]},i.agentId)})]}),o.jsx("p",{className:"m-0 px-2.5 pt-1 pb-2 text-xs text-faint",children:a("team.mention.hint")})]})}const N2=Math.floor(zb/1024);function C2({value:e,onChange:t,mentions:n,onMentionsChange:s,onSend:r,sending:i,hasToken:l,connected:c,members:d,targetLabel:m,retryHint:f=!1,disabled:h=!1,refs:p=[],onRemoveRef:g,onAddRef:b,onUpdateRef:x,client:y,contextUsage:v}){const j=u.useRef(null),_=u.useRef(!1),S=u.useRef(0),[w,k]=u.useState(0),[N,T]=u.useState(null),R=u.useRef(0),[E,I]=u.useState(0),[$,C]=u.useState(null),L=u.useId(),{atomicSchemes:A,dropHandlers:D}=ga(),O=Bv({editorRef:j,refs:p,onAddRef:b,onRemoveRef:g,onUpdateRef:x,listClient:y}),F=(se,we)=>{if(!(O===void 0||D.length===0))for(const he of D)try{he(se,O,{offset:we})}catch{}},V=Tf(e,w),B=V!==null&&V.start!==$,W=B?tL(d,V.query):[],Z=W.length===0?-1:Math.min(E,W.length-1),ee=V?`${V.start}:${V.query}`:null;u.useEffect(()=>{I(0)},[ee]);const ie=rL(e),le=l&&c&&!h&&!i&&!ie&&e.trim().length>0,J=se=>{k(se)},z=se=>{const we=V??Tf(e,j.current?.getCaretOffset()??w);if(!we)return;const he=nL(e,we,se.label);t(he.value),n.some(pe=>pe.agentId===se.agentId)||s([...n,{agentId:se.agentId,label:se.label}]),C(null),k(he.caret),R.current+=1,T({offset:he.caret,nonce:R.current}),j.current?.focus()},me=a(l?c?"team.composer.input":"team.composer.disconnected":"team.error.noToken"),K=n.map(se=>({id:`mention:${se.agentId}`,label:se.label,kind:"@",note:a("team.mention.title")})),ne=new Map;for(const se of nr(e,A))se.type==="atomic"&&ne.set(se.target,(ne.get(se.target)??0)+1);const Ne=[...Rv(p,ne),...K],ce=se=>{if(se.startsWith("mention:")){const he=se.slice(8);s(n.filter(pe=>pe.agentId!==he));return}const we=Iv(p,se);we>=0&&g?.(we)};return o.jsxs("div",{className:"composer team-composer relative",onClick:Hd,onDragOver:se=>{O===void 0||D.length===0||se.dataTransfer.types.includes("Files")&&(se.preventDefault(),se.dataTransfer.dropEffect="copy")},onDrop:se=>{if(se.dataTransfer.files.length===0||O===void 0||D.length===0)return;se.preventDefault();const we=j.current?.caretOffsetFromPoint(se.clientX,se.clientY)??null;F(Array.from(se.dataTransfer.files),we),j.current?.focus()},children:[o.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-3 text-xs text-faint",children:[o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-accent",title:m,children:m}),o.jsx("span",{className:"flex flex-none items-center gap-2.5",children:o.jsx("span",{className:"flex-none font-mono text-xs",children:a("team.composer.hint")})})]}),o.jsx(Lv,{items:Ne,onRemove:ce,removeLabel:se=>se.kind==="@"?a("team.mention.remove",{name:se.label}):a("composer.refs.remove",{name:se.label})}),B&&o.jsx(_2,{candidates:W,activeIndex:Z,listId:L,onPick:z,onHover:I}),o.jsxs("div",{className:"mb-1 flex flex-col gap-0.5",children:[n.length===0&&o.jsx("p",{className:"m-0 text-xs text-faint",children:a("team.composer.noMention")}),(!l||!c)&&o.jsx("p",{className:"m-0 text-xs text-faint",role:"status",children:a("team.composer.disconnected")}),ie&&o.jsx("p",{className:"m-0 text-xs text-danger",role:"alert",children:a("team.composer.tooLarge",{limit:N2})}),f&&o.jsx("p",{className:"m-0 text-xs text-faint",role:"status",children:a("team.delivery.retryHint")})]}),o.jsx(Pv,{contextUsage:v,port:O,primary:o.jsx(Av,{label:a(i?"team.composer.sending":"team.composer.send"),disabled:!le,onClick:r}),children:o.jsx(Zp,{ref:j,className:"composer-input",value:e,onChange:t,onCaretChange:J,caretRequest:N,onCompositionStart:()=>{_.current=!0},onCompositionEnd:()=>{_.current=!1,S.current=Date.now()},onKeyDown:se=>{if(!(se.nativeEvent.isComposing||_.current)){if(B&&V){if(se.key==="ArrowDown"){se.preventDefault(),I(W.length===0?-1:(Z+1)%W.length);return}if(se.key==="ArrowUp"){se.preventDefault(),I(W.length===0?-1:(Z-1+W.length)%W.length);return}if(se.key==="Home"){se.preventDefault(),I(W.length>0?0:-1);return}if(se.key==="End"){se.preventDefault(),I(W.length-1);return}if((se.key==="Enter"||se.key==="Tab")&&W.length>0){se.preventDefault();const we=W[Z]??W[0];we!==void 0&&z(we);return}if(se.key==="Tab"){se.preventDefault(),C(V.start);return}if(se.key==="Escape"){se.preventDefault(),C(V.start);return}}if(se.key==="Enter"){if(!(se.ctrlKey||se.metaKey)&&se.shiftKey||(se.preventDefault(),Date.now()-S.current<50))return;le&&r()}}},placeholder:me,disabled:!l||!c||i||h,spellCheck:!1,"aria-label":a("team.composer.input"),role:"combobox","aria-expanded":B,"aria-controls":B?L:void 0,"aria-autocomplete":"list","aria-activedescendant":B&&Z>=0?`${L}-option-${Z}`:void 0,enterKeyHint:"send",onPasteFiles:se=>{F(se,j.current?.getCaretOffset()??null)},atomicSchemes:A,atomicPort:O})})]})}const T2={join:"team.system.join",leave:"team.system.leave",archive:"team.system.archive",create:"team.system.create",fork:"team.system.fork",retract:"team.system.retract"};function Vy(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function E2({ts:e}){const t=cn(e);if(!t)return null;const n=new Date(e).toISOString();return o.jsx("time",{className:"font-mono tabular-nums",dateTime:n,children:t})}function I2({deliveries:e}){if(e.length===0)return null;const t=e.filter(s=>s.status==="queued"),n=e.filter(s=>s.status!=="queued");return o.jsxs(o.Fragment,{children:[t.map(s=>o.jsxs("span",{className:"team-delivery-queued self-start font-mono text-2xs text-faint",role:"status","aria-label":a("team.a11y.deliveryQueued"),children:["○"," ",s.resolution==="rotating"?a("team.delivery.queuedRotating"):s.resolution==="created"?a("team.delivery.queuedCreated"):s.resolution==="forked"?a("team.delivery.queuedForked"):a("team.delivery.queued"),o.jsxs("span",{className:"font-mono",children:[" · ",s.agent_id]})]},`queued-${s.agent_id}`)),n.map((s,r)=>o.jsxs("div",{className:"team-delivery-error self-start flex max-w-180 flex-wrap items-center gap-1.5 rounded-r-sm border-l-2 border-danger bg-danger-soft px-2.5 py-1.25 text-xs text-danger",role:r===0?"alert":"status",children:[o.jsx(Tt,{status:"failed",label:s.status==="rejected"?a("team.delivery.rejected"):a("team.delivery.error")}),o.jsx("span",{className:"font-mono text-xs",children:s.code??s.status}),o.jsx("span",{className:"font-mono text-xs",children:s.agent_id}),s.reason&&o.jsx("span",{children:Vy(s.reason,160)})]},`failed-${s.agent_id}-${s.code??s.status}`))]})}function R2({message:e,senderLabel:t}){const n=e.system_event?T2[e.system_event]:void 0,s=t??e.from,r=s==="human"?a("team.message.you"):s,i=n?a(n,{name:r}):e.content||a("team.system.unknown");return o.jsxs("div",{className:"mx-auto my-0.5 max-w-180 rounded-r-sm border-l-2 border-l-line-strong bg-sunken px-3 py-1.25 text-center text-sm text-muted",role:"status",children:[o.jsx("span",{className:"mr-1.5 font-mono text-2xs uppercase text-faint",children:a("team.message.systemTag")}),o.jsx("span",{children:i})]})}function L2({message:e,senderLabel:t,recipientLabels:n,entering:s=!1,canViewSession:r,onViewSession:i,onRetry:l,onEdit:c,onResend:d,onRetract:m}){const f=$i(),h=is(a("common.copied")),p=u.useMemo(()=>e.from==="human"?uy(dy(e.content),e.refs??[]):void 0,[e.from,e.content,e.refs]);if(e.kind==="system")return o.jsx(R2,{message:e,senderLabel:t});const g=e.federation?.from_addr,b=()=>{if(g){try{navigator.clipboard?.writeText(g).catch(()=>{})}catch{}f?.info(a("team.federation.replyHint",{addr:g}))}},x=e.kind==="reply",y=e.from==="human",v=!y&&!x,j=!y&&Array.isArray(e.to)&&e.to.includes("human"),_=n??[],S=_.length-1,w=e.sendStatus==="failed"?" team-message-failed":e.sendStatus==="sending"?" opacity-70":"",k=e.sendStatus===void 0||e.sendStatus==="sent",N=e.content.trim().length>0,T=[];return N&&e.sendStatus!=="sending"&&T.push({id:"copy",label:a("common.copy"),onSelect:()=>h(e.content)}),y&&k&&(N&&c&&T.push({id:"edit",label:a("team.message.edit"),onSelect:c}),N&&d&&T.push({id:"resend",label:a("team.message.resend"),onSelect:d}),m&&T.push({id:"delete",label:a("team.message.delete"),onSelect:m})),(x||v)&&r&&i&&T.push({id:"transcript",label:a("team.message.viewBody"),onSelect:i}),g&&T.push({id:"reply",label:a("team.federation.reply"),onSelect:b}),y&&e.sendStatus==="failed"&&l&&T.push({id:"retry",label:a("team.delivery.retry"),onSelect:l}),o.jsxs("div",{className:`group mx-auto flex w-full max-w-[var(--chat-content-w,860px)] flex-col gap-1 ${y?"team-message-self":"team-message-agent"}${w}${s?" msg-enter":""}`,"data-kind":e.kind,children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-faint",children:[o.jsx("span",{className:"font-medium text-muted",children:y?a("team.message.you"):t??e.from}),_.length>0&&o.jsxs("span",{className:"flex items-center gap-1",title:_.join(", "),children:[o.jsx("span",{"aria-hidden":"true",children:"→"}),o.jsx("span",{className:"font-medium text-muted",children:_[0]}),S>0&&o.jsxs("span",{className:"font-mono text-2xs",children:["+",S]})]}),v&&o.jsx("span",{className:"rounded-full border border-line-strong px-1.25 font-mono text-2xs text-muted",children:a("team.message.agentTag")}),x&&o.jsx("span",{className:"rounded-full border border-line-strong px-1.25 font-mono text-2xs text-muted",children:a("team.message.replyTag")}),j&&o.jsx(Re,{tone:"accent",title:a("team.message.toHumanHint"),children:a("team.message.toHumanTag")}),g&&o.jsxs("span",{className:"max-w-80 truncate font-mono text-muted",title:g,children:[a("team.federation.from")," ",g]}),o.jsx(E2,{ts:e.ts}),e.sendStatus==="sending"&&o.jsx("span",{className:"text-muted",children:a("team.composer.sending")})]}),!y&&o.jsx(kv,{refs:e.refs}),o.jsx("div",{className:"team-message-bubble",children:o.jsx(Wc,{children:y?o.jsx(Vd,{text:e.content,match:p}):o.jsx(jr,{className:"text-base leading-relaxed wrap-anywhere",text:e.content})})}),o.jsx(os,{className:y?"self-end":"self-start",actions:T}),e.deliveries&&o.jsx(I2,{deliveries:e.deliveries}),e.sendStatus==="failed"&&o.jsxs("div",{className:"team-delivery-error self-start flex max-w-180 flex-wrap items-center gap-1.5 rounded-r-sm border-l-2 border-danger bg-danger-soft px-2.5 py-1.25 text-xs text-danger",role:"alert",children:[o.jsx(Tt,{status:"failed",label:a("team.delivery.failed")}),e.sendError&&o.jsx("span",{className:"font-mono text-xs",children:Vy(e.sendError,160)})]})]})}const Gy="local:";function A2(e){return e.startsWith(Gy)}function M2(e,t){return!(e&&t)}function P2(e,t){if(e.length!==t.length)return!1;const n=[...e].sort(),s=[...t].sort();return n.every((r,i)=>r===s[i])}function q2(e,t,n,s){return e.find(r=>r.from==="human"&&r.content===t&&r.ts>=s&&P2(r.mentions,n))}function O2(e,t,n){const s=new Set;for(const d of e)d.kind==="system"&&d.system_event==="retract"&&typeof d.retracted_message_id=="string"&&s.add(d.retracted_message_id);const r=s.size?e.filter(d=>!s.has(d.message_id)):e,i=new Set(r.map(d=>d.message_id)),l=new Map,c=[];for(const d of t){const m=d.messageId??d.localId;l.set(m,d),!(i.has(m)||s.has(m))&&c.push({message_id:m,team_id:n,from:"human",to:[],mentions:d.mentions,content:d.content,ts:d.ts,kind:d.mentions.length>0?"mention":"post",...d.refs!==void 0&&d.refs.length>0?{refs:[...d.refs]}:{}})}return Li(r,c).map(d=>{const m=l.get(d.message_id);return m?{...d,...m.status==="failed"?{sendStatus:"failed",sendError:m.error}:m.status==="sending"?{sendStatus:"sending"}:{sendStatus:"sent"},...m.deliveries?{deliveries:m.deliveries}:{}}:d})}function D2(e){if(!Array.isArray(e.to))return[];const t=[];for(const n of e.to)typeof n!="string"||n.length===0||n==="human"||n==="system"||n.includes("@")||n.startsWith("federation:")||n!==e.from&&(t.includes(n)||t.push(n));return t}function H2({messages:e,resolveMember:t,resolveMemberLabel:n,onViewMemberSession:s,onRetrySend:r,onEditMessage:i,onResendMessage:l,onRetractMessage:c,motionResetKey:d=null}){const m=Uc(e,p=>p.message_id,d);if(e.length===0)return null;const f=[];let h=null;for(const p of e){const g=vs(p.ts);g&&g!==h&&(f.push(o.jsx("div",{className:"day-divider mx-auto mt-1.5 mb-0.5 w-full max-w-[var(--chat-content-w,860px)]",children:o.jsx("span",{children:Wi(p.ts)})},`day-${g}`)),h=g);const b=p.kind==="system"?p.to[0]??p.mentions[0]??p.from:p.from,x=t?.(b),y=x?.session_id,j=(p.kind==="system"||p.from==="human"?[]:D2(p)).map(_=>n?.(_)??t?.(_)?.name??_);f.push(o.jsx("div",{"data-index-entry-key":Db(p)?p.message_id:void 0,children:o.jsx(L2,{message:p,entering:p.kind!=="system"&&!A2(p.message_id)&&m(p.message_id),senderLabel:n?.(b)??x?.name??b,recipientLabels:j,canViewSession:!!(x&&y),onViewSession:x&&y&&s?()=>s(x.agent_id,y):void 0,onRetry:p.sendStatus==="failed"?()=>r?.(p):void 0,onEdit:i?()=>i(p):void 0,onResend:l?()=>l(p):void 0,onRetract:c?()=>c(p):void 0})},p.message_id))}return o.jsx("div",{className:"mx-auto flex w-full flex-col gap-3",children:f})}function $2(e,t){return`${t??e}:${t?"ready":"loading"}`}function F2(e){const t=e.length>0?e[e.length-1]:void 0;return t?`${t.message_id}:${t.ts}:${t.sendStatus??""}`:"empty"}const Yy=120;function B2(e,t=Yy){return e<=t}function Jy(e){return{scrollTop:e.scrollTop,scrollHeight:e.scrollHeight}}function Qy(e,t){const n=e.scrollHeight-t.scrollHeight;if(n<=0)return!1;const s=t.scrollTop+n;return Math.abs(s-e.scrollTop)>1&&(e.scrollTop=s),!0}function K2({box:e,hasMore:t,loading:n,scope:s,onLoadEarlier:r}){const i=u.useRef(!0),l=u.useRef(null),c=u.useRef(null),[d,m]=u.useState(0);u.useEffect(()=>{i.current=!0,l.current=null,c.current=null},[s]);const f=u.useCallback(()=>{const p=e.current;!p||!t||n||(i.current=!1,l.current=Jy(p),r())},[e,t,n,r]);return u.useLayoutEffect(()=>{const p=e.current;if(!p)return;const g=l.current;if(g){Qy(p,g)?(l.current=null,m(b=>b+1)):n||(l.current=null);return}if(!t||n||p.scrollHeight>p.clientHeight+Yy){c.current=null;return}c.current!==p.scrollHeight&&(c.current=p.scrollHeight,f())}),{onScroll:u.useCallback(()=>{const p=e.current;if(!p)return;const g=l.current;if(g){if(p.scrollHeight===g.scrollHeight&&Math.abs(p.scrollTop-g.scrollTop)>4){l.current=null,i.current=!0;return}return}if(!B2(p.scrollTop)){i.current=!0;return}i.current&&f()},[e,f]),loadedPages:d}}function W2({teamId:e,detail:t,error:n,hasToken:s,firstLoading:r,rows:i,resolveMember:l,agentLabel:c,onOpenSession:d,onRetrySend:m,onEditMessage:f,onResendMessage:h,onRetractMessage:p,onRefresh:g,hasEarlier:b,loadingEarlier:x,onLoadEarlier:y,historyNotice:v,onDismissHistoryNotice:j,historyReloadToken:_,members:S,permissions:w,asks:k,responding:N,connected:T,onDecidePermission:R,onRespondAsk:E,draft:I,onDraftChange:$,chips:C,onChipsChange:L,refs:A,onRemoveRef:D,onAddRef:O,onUpdateRef:F,client:V,onSend:B,sending:W,sendTick:Z,archived:ee,targetLabel:ie,retryHint:le,overlay:J}){const z=$2(e,t?.team.team_id),me=F2(i),{scrollRef:K,pinned:ne,onScroll:Ne,scrollToBottom:ce,userIntentProps:se}=ky({resetKey:z,followKey:me,sendTick:Z}),we=u.useRef(null),he=u.useCallback(M=>{we.current=M,K(M)},[K]),pe=K2({box:we,hasMore:b,loading:x,scope:z,onLoadEarlier:y}),Me=u.useMemo(()=>vR(i),[i]),oe=u.useCallback(()=>we.current,[]),{activeKey:je,jumpTo:Ee}=jd({getElement:oe,entryKeys:Me.map(M=>M.key),resetKey:z}),Ce=u.useRef(null),U=u.useRef(ne);U.current=ne,u.useEffect(()=>{if(_===0)return;const M=we.current;Ce.current=M?Jy(M):null},[_]),u.useLayoutEffect(()=>{const M=Ce.current,H=we.current;!M||!H||H.scrollHeight!==M.scrollHeight&&(Qy(H,M),Ce.current=null,U.current&&(H.scrollTop=H.scrollHeight))});const q=()=>{Ne(),pe.onScroll()};return o.jsxs("div",{className:"team-chat-main",children:[o.jsxs("div",{className:"content-stage",children:[J,t&&n&&o.jsx(st,{message:a("team.error.stale"),onRetry:g}),v&&o.jsx(st,{message:a(v),onDismiss:j}),o.jsxs("div",{className:"transcript-stage",children:[o.jsxs("div",{className:"team-transcript-scroll",ref:he,onScroll:q,...se,children:[s?r&&i.length===0?o.jsx(Ke,{rows:3}):!t&&i.length===0?n?.code==="not_found"?o.jsx(Fe,{title:a("team.error.notEnabled"),reason:a("team.error.notEnabledReason"),hint:a("team.error.notEnabledHint")}):o.jsx(Ve,{message:n?.message??a("team.error.loadFailed"),onRetry:g}):i.length===0?o.jsx($e,{title:a("team.chat.empty"),description:a("team.chat.emptyHint")}):o.jsx(H2,{messages:i,motionResetKey:z,resolveMember:l,resolveMemberLabel:c,onViewMemberSession:(M,H)=>d(H),onRetrySend:m,onEditMessage:f,onResendMessage:h,onRetractMessage:p}):o.jsx(Fe,{title:a("team.error.noToken"),reason:a("team.error.noTokenReason")}),o.jsx("span",{className:"sr-only","aria-live":"polite",children:pe.loadedPages>0?a("team.chat.loadedEarlier"):""}),!ne&&o.jsx("button",{type:"button",className:"to-bottom",onClick:ce,children:a("chat.toBottom")})]}),o.jsx(pd,{entries:Me,activeKey:je,onJump:Ee,className:"conversation-index-rail"})]})]}),o.jsxs("div",{className:"team-composer-area",children:[o.jsx(fD,{members:S,permissions:w,asks:k,responding:N,connected:T,onDecidePermission:R,onRespondAsk:E}),o.jsx(C2,{value:I,onChange:$,mentions:C,onMentionsChange:L,refs:A,onRemoveRef:D,onAddRef:O,onUpdateRef:F,client:V,onSend:B,sending:W,hasToken:s,connected:T&&!ee,disabled:ee,members:S,targetLabel:ie,retryHint:le})]})]})}function U2(e,t,n){const s=e.session_id;if(!s)return 0;const r=t.filter(l=>l.sessionId===s).length,i=n.filter(l=>l.sessionId===s).length;return r+i}function z2(e){return iL(e)}function V2(e){navigator.clipboard?.writeText(e).catch(()=>{})}function G2({members:e,total:t,permissions:n,asks:s,activeMemberId:r,onOpenMember:i,onOpenSession:l,onClose:c}){const d=t??e.length,m=u.useMemo(()=>z2(e),[e]);return o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o.jsxs("div",{className:"column-header team-members-head",children:[o.jsx("span",{className:"column-title",children:a("team.chat.members")}),o.jsxs("span",{className:"ml-0.5 font-mono text-2xs text-faint",children:[e.length," / ",d]}),c&&o.jsx("button",{type:"button",className:`${Kc} ml-auto`,"aria-label":a("team.a11y.closeMembers"),onClick:c,children:"×"})]}),o.jsx("ul",{className:"flex min-h-0 flex-1 list-none flex-col gap-0.5 overflow-y-auto overscroll-contain px-2 pb-3","aria-label":a("team.a11y.memberList"),children:m.map(f=>{const h=ha(f),p=f.session_id,g=U2(f,n,s),b=f.name?.trim()||Es(f.agent_id),x=f.membership==="left";return o.jsxs("li",{className:`team-member-row flex items-center gap-1.5 rounded-sm px-1.5 py-1.25 hover:bg-hover ${x?"opacity-70":""} ${r===f.agent_id?"bg-accent-soft":""}`.trim(),children:[o.jsx("span",{className:"grid size-7 flex-none place-items-center rounded-full bg-sunken font-mono text-xs uppercase text-muted","aria-hidden":"true",children:b.slice(0,1).toUpperCase()}),o.jsx("button",{type:"button",className:"flex min-w-0 flex-1 cursor-pointer flex-col gap-0.5 border-0 bg-transparent px-0 py-0.5 text-left text-inherit",onClick:()=>i(f.agent_id),"aria-label":b,children:o.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[o.jsx("span",{className:"min-w-0 truncate text-sm",children:b}),o.jsx(Re,{className:"flex-none",children:a(Ss(ks(f)))}),o.jsx(Tt,{status:h.chipStatus,label:a(h.labelKey),title:h.titleKey?a(h.titleKey):void 0}),h.kind==="closed"&&o.jsx(Re,{tone:"warn",className:"flex-none",children:a(cd("agent"))})]})}),g>0&&p&&o.jsx("button",{type:"button",className:"h-4.5 min-w-4.5 flex-none cursor-pointer rounded-full border border-warn bg-warn-soft px-1.25 font-mono text-2xs leading-4 text-warn",title:a("team.attention.pending"),"aria-label":a("team.attention.count",{count:g}),onClick:()=>l(p),children:g}),o.jsx(Gi,{label:a("team.member.title"),items:[{id:"details",label:a("breadcrumb.team.member"),onSelect:()=>i(f.agent_id)},...x?[]:[{id:"session",label:a("team.member.currentSession"),disabled:!p,onSelect:()=>{p&&l(p)}},{id:"copy-id",label:"agent_id",onSelect:()=>V2(f.agent_id)}]]})]},f.agent_id)})})]})}function Y2(e,t){const n=(e.name?.trim()||Es(e.agent_id)).toLowerCase(),s=ks(e);return n.includes(t)||e.agent_id.toLowerCase().includes(t)||s.includes(t)||a(Ss(s)).toLowerCase().includes(t)}function J2({members:e,memberTotal:t,permissions:n,asks:s,onOpenMember:r,onOpenSession:i,onClose:l,membersOpen:c,narrow:d,drawerRef:m,memberWindow:f,loading:h,onLoadMore:p,onCloseDrawer:g}){He();const[b,x]=u.useState(""),y=b.trim().toLowerCase(),v=ra(),j=HT(e,v),_=ld(e,v,Ts),S=y?j.filter(w=>Y2(w,y)):j;return o.jsxs(o.Fragment,{children:[o.jsxs("aside",{id:"team-members",ref:m,...d?{role:"dialog","aria-modal":c}:{},className:`team-members-column ${c?"open":""}`.trim(),"aria-label":a("team.a11y.memberList"),inert:d&&!c?!0:void 0,"aria-hidden":d&&!c?!0:void 0,children:[o.jsx("div",{className:"px-2 pb-2",children:o.jsx(Tn,{value:b,onChange:x,placeholder:a("team.members.search"),ariaLabel:a("team.members.search")})}),y!==""&&o.jsx("p",{className:"mx-2 mt-0 mb-2 font-mono text-2xs text-faint",role:"status",children:a("team.members.matches",{matched:S.length,total:j.length})}),_>0&&o.jsx("p",{className:"mx-2 mt-0 mb-2 text-xs text-muted",role:"status",children:a("archive.hidden.members",{count:_})}),h?o.jsx(Ke,{rows:4}):S.length===0?_>0&&y===""?o.jsx($e,{title:a("archive.empty.members"),description:a("archive.hidden.members",{count:_})}):o.jsx($e,{title:a("team.members.empty")}):o.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:o.jsx(G2,{members:S,total:y?S.length:t,permissions:n,asks:s,onOpenMember:r,onOpenSession:i,onClose:l})}),f.canLoadMore&&o.jsx("button",{type:"button",className:"load-more mx-3 my-2",onClick:p,children:a("team.chat.loadMoreMembers")}),f.capped&&o.jsx("p",{className:"m-0 self-center font-mono text-xs text-faint",role:"status",children:a("team.chat.membersCapped",{shown:e.length,total:t})})]}),d&&c&&o.jsx("button",{type:"button",className:"drawer-backdrop","aria-label":a("team.a11y.closeMembers"),onClick:g})]})}const Jr=100,Q2=20,X2=80,pc=100;function Z2(e){return Math.min(pc,e+X2)}function eH(e,t,n){return{canLoadMore:e<t&&n<pc,capped:e<t&&n>=pc}}const tH=4e3,nH=2e3,sH=new Set;function Qr(e){return e instanceof Error?e.message:String(e)}function oH({client:e,hasToken:t,connectionState:n,epoch:s,teamId:r,nodeKey:i="local",permissions:l,asks:c,events:d,responding:m=sH,onDecidePermission:f,onRespondAsk:h,onOpenMember:p,onOpenSession:g,onBackToList:b,membersOpen:x,onCloseMembers:y,initialDetail:v,initialError:j}){const[_,S]=u.useState(Q2),w=a_(i,r),k=kg(w),N=b_(w),T=Qe(ve=>ve.setText),R=Qe(ve=>ve.setChips),E=Qe(ve=>ve.clear),I=Sg(w),$=u.useCallback(ve=>T(w,ve),[T,w]),C=u.useCallback(ve=>R(w,ve),[R,w]),L=u.useCallback(ve=>Qe.getState().addRef(w,ve),[w]),A=u.useCallback(ve=>Qe.getState().removeRef(w,ve),[w]),D=u.useCallback((ve,ze)=>Qe.getState().updateRef(w,ve,ze),[w]),[O,F]=u.useState([]),[V,B]=u.useState(!1),[W,Z]=u.useState(0),[ee,ie]=u.useState(!1),[le,J]=u.useState(()=>v?ai(v.messages):[]),[z,me]=u.useState(v?.messages_has_more===!0),K=u.useRef(v?.messages_has_more===!0),ne=u.useRef(v!==void 0),Ne=u.useRef(!1),[ce,se]=u.useState(!1),[we,he]=u.useState(null),[pe,Me]=u.useState(0),oe=u.useRef(!1),je=u.useRef(le);je.current=le;const[Ee,Ce]=u.useState(null),[U,q]=u.useState(!1),[M,H]=u.useState(),[X,Y]=u.useState(!1),re=$i(),_e=u.useRef(Wb()),fe=u.useRef(0),Pe=u.useRef(void 0),ke=u.useRef(!1),Ge=u.useRef(v),mt=pa({open:x,onClose:y,enabled:X}),lt=go(i,r,"chat"),de=St(ve=>ve.details[lt]),qe=`${i}:${r}`,Oe=u.useRef(qe);u.useEffect(()=>{if(Oe.current===qe)return;Oe.current=qe;const ve=Se(St.getState().details[lt]);J(ve?ai(ve.messages):[]);const ze=ve?.messages_has_more===!0;K.current=ze,me(ze),ne.current=ve!==void 0,Ne.current=!1,se(!1),F([]),ie(!1),Ce(null),H(void 0),oe.current=!1,he(null)},[qe]);const ue=St(ve=>ve.loadDetail),xe=St(ve=>ve.post),De=()=>{ue(i,r,e,{limit:Jr,members_limit:_},"chat")};qt(()=>{const ve=Ge.current;(M2(ke.current,ve!==void 0)||!ve)&&ue(i,r,e,{limit:Jr,members_limit:_},"chat")},{enabled:t,pollMs:tH,deps:[s,r,_,i]});const Je=u.useRef(De);Je.current=De;const ht=u.useCallback(()=>{Je.current()},[]);Lt(ht),ke.current=V,u.useEffect(()=>zp(()=>Je.current()),[]);const ft=u.useCallback(()=>{if(!K.current||Ne.current)return;const ve=je.current[0];ve&&(Ne.current=!0,se(!0),(async()=>{try{const ze=await e.getTeam(r,{limit:Jr,before:ve.message_id,members_limit:_}),ct=$R(je.current,ze),At=ct.messages.length===je.current.length;J(ct.messages);const Rs=ct.hasMore&&!At;K.current=Rs,me(Rs)}catch(ze){y0(ze)?(K.current=!1,me(!1),re?.info(a("team.chat.historyOutOfWindow"))):jp(ze)?(he("team.chat.historyChanged"),Me(ct=>ct+1),oe.current=!0,Je.current()):re?.error(Qr(ze))}finally{Ne.current=!1,se(!1)}})())},[e,r,_,re]),pt=Se(de)??v;Ge.current=pt;const Q=pt?.team,ye=u.useMemo(()=>pt?.members??[],[pt]),Te=t&&n==="open",Ue=Q?.archived_at!==void 0;u.useEffect(()=>{const ve=()=>Y(window.innerWidth<=na);return ve(),window.addEventListener("resize",ve),()=>window.removeEventListener("resize",ve)},[]),u.useEffect(()=>()=>window.clearTimeout(Pe.current),[]),u.useEffect(()=>{const ve=Se(de);if(!ve)return;if(oe.current){oe.current=!1,J(ai(ve.messages));const ct=ve.messages_has_more===!0;K.current=ct,me(ct);return}if(ve.messages.length>0&&J(ct=>Li(ct,ve.messages)),!ne.current){ne.current=!0;const ct=ve.messages_has_more===!0;K.current=ct,me(ct)}},[de]),u.useEffect(()=>{const ve=new Set(ye.map(At=>At.session_id).filter(At=>typeof At=="string"&&At.length>0));let ze=_e.current;for(const At of d)At.seq<=ze.lastAppliedSeq||(ze=Ub(ze,{...At.event,seq:At.seq},r,ve));const ct=ze.rosterDirty;if(_e.current=ct?{...ze,rosterDirty:!1}:ze,ct){const At=Date.now();At-fe.current>=nH&&(fe.current=At,window.clearTimeout(Pe.current),Pe.current=window.setTimeout(()=>Je.current(),250))}},[d,r,ye]);const Be=u.useMemo(()=>{const ve=new Map;for(const ze of ye)ve.set(ze.agent_id,ze);return ve},[ye]),tt=ve=>Be.get(ve),Kt=ve=>{const ze=Be.get(ve);return ze?Vb(ze):Es(ve)},dn=u.useMemo(()=>O2(le,O,r),[le,O,r]),P=Q?.member_count??ye.length,ae=eH(ye.length,P,_),Le=Q?.online_count??ye.filter(QR).length,te=async(ve,ze,ct=[])=>{const At=ve.trim();if(!At||V||!t||n!=="open"||Ue)return!1;const Rs=`${Gy}${crypto.randomUUID()}`,tu=Date.now();F(un=>[...un,{localId:Rs,content:At,mentions:ze,ts:tu,status:"sending",...ct.length>0?{refs:[...ct]}:{}}]),B(!0),ke.current=!0,Z(un=>un+1);try{const un=await xe(e,{team_id:r,content:At,mentions:ze,...ct.length>0?{refs:[...ct]}:{}}),Ls=un.refs?.length?un.refs:void 0;F(wa=>wa.map(Kn=>Kn.localId===Rs?{...Kn,status:"sent",messageId:un.message_id,deliveries:un.delivered,...Ls!==void 0?{refs:Ls}:{}}:Kn)),B(!1),ke.current=!1,Je.current()}catch(un){let Ls;try{const Kn=await e.getTeam(r,{limit:Jr,members_limit:_});J(As=>Li(As,Kn.messages)),Ls=q2(Kn.messages,At,ze,tu)}catch{}const wa=(ct.length>0?jy(un):null)??Qr(un);F(Kn=>Kn.map(As=>As.localId!==Rs?As:Ls?{...As,status:"sent",messageId:Ls.message_id}:{...As,status:"failed",error:wa})),B(!1),ke.current=!1,Je.current()}finally{B(!1),ke.current=!1}return!0},Ie=async()=>{const ve=k.trim(),ze=sL(N);await te(ve,ze,I)&&(E(w),ie(!1))},Ze=ve=>{$(ve.content),C(ve.mentions.map(ze=>({agentId:ze,label:Kt(ze)}))),ie(!0)},at=ve=>{(async()=>{try{await e.recallTeamDelivery({team_id:r,message_id:ve.message_id})}catch(ze){re?.error(a("team.message.editRecallFailed",{detail:Qr(ze)}));return}$(ve.content),C(ve.mentions.map(ze=>({agentId:ze,label:Kt(ze)}))),ie(!1)})()},gt=ve=>{te(ve.content,ve.mentions)},nt=ve=>{H(void 0),Ce(ve)},Cr=()=>{U||(Ce(null),H(void 0))},xa=async()=>{const ve=Ee;if(!(!ve||U)){q(!0),H(void 0);try{await e.retractTeam({team_id:r,message_id:ve.message_id}),Ce(null),re?.success(a("team.message.deleteDone")),Je.current()}catch(ze){const ct=Qr(ze);H(ct),re?.error(ct)}finally{q(!1)}}},Tr=ve=>{y(),p(ve)},rt=de?.status==="error"?{message:de.error,code:de.code}:j;return{team:Q,teamId:r,archived:Ue,historyNotice:we,dismissHistoryNotice:()=>he(null),historyReloadToken:pe,members:ye,memberTotal:P,onlineCount:Le,narrow:X,membersDrawerRef:mt,detail:pt,error:rt,firstLoading:!pt&&!rt,rows:dn,resolveMember:tt,agentLabel:Kt,draft:k,setDraft:$,chips:N,setChips:C,refs:I,addRef:L,removeRef:A,updateRef:D,retryHint:ee,setRetryHint:ie,sending:V,sendTick:W,handleSend:Ie,handleRetry:Ze,editMessage:at,resendMessage:gt,requestRetract:nt,cancelRetract:Cr,confirmRetract:xa,retractTarget:Ee,retracting:U,retractError:M,reload:De,hasToken:t,hasEarlier:z,loadEarlier:ft,earlierLoading:ce,memberWindow:ae,membersLimit:_,setMembersLimit:S,permissions:l,asks:c,responding:m,connected:Te,onDecidePermission:f,onRespondAsk:h,onOpenSession:g,onBackToList:b,openMember:Tr}}function rH(e){const{nodeName:t,nodeCurrent:n,frozen:s}=e,{membersOpen:r,onCloseMembers:i,panes:l}=e,{team:c,teamId:d,archived:m,members:f,memberTotal:h,narrow:p,membersDrawerRef:g,detail:b,error:x,firstLoading:y,rows:v,resolveMember:j,agentLabel:_,draft:S,setDraft:w,chips:k,setChips:N,refs:T,addRef:R,removeRef:E,updateRef:I,retryHint:$,setRetryHint:C,sending:L,sendTick:A,handleSend:D,handleRetry:O,editMessage:F,resendMessage:V,requestRetract:B,cancelRetract:W,confirmRetract:Z,retractTarget:ee,retracting:ie,retractError:le,reload:J,hasToken:z,hasEarlier:me,loadEarlier:K,earlierLoading:ne,historyNotice:Ne,dismissHistoryNotice:ce,historyReloadToken:se,memberWindow:we,membersLimit:he,setMembersLimit:pe,permissions:Me,asks:oe,responding:je,connected:Ee,onDecidePermission:Ce,onRespondAsk:U,onOpenSession:q,onBackToList:M,openMember:H}=oH(e),X=Y=>{w(Y),$&&C(!1)};return o.jsxs("section",{className:"team-chat","aria-label":c?.name??d,children:[o.jsx(j2,{team:c,teamId:d,archived:m,nodeName:t,nodeCurrent:n,frozen:s,onBackToList:M}),o.jsxs("div",{className:`team-chat-body ${r?"has-members":""}`.trim(),children:[o.jsx(W2,{teamId:d,detail:b,error:x,hasToken:z,firstLoading:y,rows:v,resolveMember:j,agentLabel:_,onOpenSession:q,onRetrySend:O,onEditMessage:F,onResendMessage:V,onRetractMessage:B,onRefresh:J,hasEarlier:me,loadingEarlier:ne,onLoadEarlier:K,historyNotice:Ne,onDismissHistoryNotice:ce,historyReloadToken:se,members:f,permissions:Me,asks:oe,responding:je,connected:Ee,onDecidePermission:Ce,onRespondAsk:U,draft:S,onDraftChange:X,chips:k,onChipsChange:N,refs:T,onRemoveRef:E,onAddRef:R,onUpdateRef:I,client:e.client,onSend:()=>{D()},sending:L,sendTick:A,archived:m,targetLabel:c?.name??d,retryHint:$,overlay:!p&&!l.disabled("chat")&&o.jsx(kr,{pane:"chat",api:l,label:a("resize.chat"),className:"resize-handle resize-handle-content resize-handle-team-chat"})}),(r||p)&&o.jsx(J2,{members:f,memberTotal:h,permissions:Me,asks:oe,memberWindow:we,loading:y,membersOpen:r,narrow:p,drawerRef:g,onOpenMember:H,onOpenSession:Y=>{p&&i(),q(Y)},onLoadMore:()=>pe(Z2(he)),onClose:p?i:void 0,onCloseDrawer:i})]}),ee&&o.jsx(In,{title:a("team.message.deleteTitle"),body:o.jsx("p",{children:a("team.message.deleteBody")}),confirmLabel:a("team.message.deleteConfirm"),danger:!0,busy:ie,onConfirm:()=>{Z()},onCancel:W,extra:le?o.jsx("p",{className:"text-xs text-danger leading-snug",role:"alert",children:le}):void 0})]})}function iH({title:e,description:t,actions:n}){return o.jsxs("header",{className:"flex flex-col gap-2.5",children:[o.jsx(xr,{title:e,actions:n}),t&&o.jsx("div",{className:"max-w-prose text-md leading-normal text-muted",children:t})]})}function aH(e){if(e!==void 0)switch(e.code){case"integerMin":return a("team.form.policyErrorIntegerMin",{min:e.min});case"denyAfterRange":return a("team.form.policyErrorDenyAfterRange");case"denyAfterRequired":return a("team.form.policyErrorDenyAfterRequired");case"threshold":return a("team.form.policyErrorThreshold")}}function Jn(e,t){return aH(e[t])}function Xy({idPrefix:e,form:t,errors:n,onChange:s}){const r=i=>`${e}-policy-${i}`;return o.jsxs("div",{className:"col-span-full flex flex-col gap-2",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"font-mono text-2xs uppercase tracking-widest text-faint",children:a("teams.form.policy")}),o.jsx("p",{className:"mt-1 text-xs text-faint",children:a("teams.form.policyHint")})]}),o.jsxs("fieldset",{className:"m-0 flex min-w-0 flex-col gap-2 border-0 p-0",children:[o.jsx("legend",{className:"font-mono text-2xs uppercase tracking-widest text-faint",children:a("team.form.policyPermission")}),o.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[o.jsx(We,{label:a("team.form.policyUnattended"),htmlFor:r("unattended"),children:o.jsxs($t,{id:r("unattended"),value:t.unattended,onChange:i=>s({unattended:i.target.value}),children:[o.jsx("option",{value:"",children:a("team.form.policyUnset")}),o.jsx("option",{value:"hold",children:a("team.form.policyHold")}),o.jsx("option",{value:"deny-after",children:a("team.form.policyDenyAfter")})]})}),t.unattended==="deny-after"?o.jsx(We,{label:a("team.form.policyDenyAfterSeconds"),htmlFor:r("deny-after-seconds"),error:Jn(n,"denyAfterSeconds"),children:o.jsx(Xe,{id:r("deny-after-seconds"),type:"number",min:1,max:86400,step:1,value:t.denyAfterSeconds,onChange:i=>s({denyAfterSeconds:i.target.value})})}):null]})]}),o.jsxs("fieldset",{className:"m-0 flex min-w-0 flex-col gap-2 border-0 p-0",children:[o.jsx("legend",{className:"font-mono text-2xs uppercase tracking-widest text-faint",children:a("team.form.policyBudget")}),o.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[o.jsx(We,{label:a("team.form.policyMaxHops"),htmlFor:r("max-hops"),error:Jn(n,"maxHops"),children:o.jsx(Xe,{id:r("max-hops"),type:"number",min:1,step:1,value:t.maxHops,onChange:i=>s({maxHops:i.target.value})})}),o.jsx(We,{label:a("team.form.policyMaxTurns"),htmlFor:r("max-turns"),error:Jn(n,"maxTurns"),children:o.jsx(Xe,{id:r("max-turns"),type:"number",min:1,step:1,value:t.maxTurns,onChange:i=>s({maxTurns:i.target.value})})}),o.jsx(We,{label:a("team.form.policyMaxTokens"),htmlFor:r("max-tokens"),error:Jn(n,"maxTokens"),children:o.jsx(Xe,{id:r("max-tokens"),type:"number",min:1,step:1,value:t.maxTokens,onChange:i=>s({maxTokens:i.target.value})})}),o.jsx(We,{label:a("team.form.policyMaxWallClockSeconds"),htmlFor:r("max-wall-clock-seconds"),error:Jn(n,"maxWallClockSeconds"),children:o.jsx(Xe,{id:r("max-wall-clock-seconds"),type:"number",min:1,step:1,value:t.maxWallClockSeconds,onChange:i=>s({maxWallClockSeconds:i.target.value})})}),o.jsx(We,{label:a("team.form.policyWarningThreshold"),htmlFor:r("warning-threshold"),hint:a("team.form.policyWarningThresholdHint"),error:Jn(n,"warningThreshold"),children:o.jsx(Xe,{id:r("warning-threshold"),type:"number",min:0,max:1,step:.01,value:t.warningThreshold,onChange:i=>s({warningThreshold:i.target.value})})})]})]}),o.jsxs("fieldset",{className:"m-0 flex min-w-0 flex-col gap-2 border-0 p-0",children:[o.jsx("legend",{className:"font-mono text-2xs uppercase tracking-widest text-faint",children:a("team.form.policyCycle")}),o.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[o.jsx(We,{label:a("team.form.policyCycleMaxRepeats"),htmlFor:r("cycle-max-repeats"),error:Jn(n,"cycleMaxRepeats"),children:o.jsx(Xe,{id:r("cycle-max-repeats"),type:"number",min:1,step:1,value:t.cycleMaxRepeats,onChange:i=>s({cycleMaxRepeats:i.target.value})})}),o.jsx(We,{label:a("team.form.policyCycleCooldownSeconds"),htmlFor:r("cycle-cooldown-seconds"),error:Jn(n,"cycleCooldownSeconds"),children:o.jsx(Xe,{id:r("cycle-cooldown-seconds"),type:"number",min:1,step:1,value:t.cycleCooldownSeconds,onChange:i=>s({cycleCooldownSeconds:i.target.value})})})]})]}),o.jsxs("fieldset",{className:"m-0 flex min-w-0 flex-col gap-2 border-0 p-0",children:[o.jsx("legend",{className:"font-mono text-2xs uppercase tracking-widest text-faint",children:a("team.form.policyFederation")}),o.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:o.jsx(We,{label:a("team.form.policyFederationAccept"),htmlFor:r("federation-accept"),children:o.jsxs($t,{id:r("federation-accept"),value:t.federationAccept,onChange:i=>s({federationAccept:i.target.value}),children:[o.jsx("option",{value:"",children:a("team.form.policyUnset")}),o.jsx("option",{value:"principal",children:a("team.form.policyAcceptPrincipal")}),o.jsx("option",{value:"log",children:a("team.form.policyAcceptLog")})]})})})]}),o.jsx(We,{label:a("team.form.policyAllowAutoCreate"),htmlFor:r("allow-auto-create"),hint:a("team.form.policyAllowAutoCreateHint"),children:o.jsx("input",{id:r("allow-auto-create"),type:"checkbox",className:"h-4 w-4 accent-accent",checked:t.allowAutoCreate,onChange:i=>s({allowAutoCreate:i.target.checked})})})]})}function gc(e){const t=e.trim();return t===""?void 0:t}function lH(e,t){const n=e.trim();return n===t.trim()?{changed:!1,value:null}:{changed:!0,value:n===""?null:n}}function cH(){return{unattended:"",denyAfterSeconds:"",maxHops:"",maxTurns:"",maxTokens:"",maxWallClockSeconds:"",warningThreshold:"",cycleMaxRepeats:"",cycleCooldownSeconds:"",allowAutoCreate:!1,federationAccept:""}}function qo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xr(e){return qo(e)?{...e}:{}}function Qn(e){return typeof e=="number"&&Number.isFinite(e)?String(e):""}function dH(e){const t=qo(e?.permission)?e.permission:{},n=qo(e?.budget)?e.budget:{},s=qo(n.cycle)?n.cycle:{},r=qo(e?.federation)?e.federation:{},i=t.unattended,l=r.accept;return{unattended:i==="hold"||i==="deny-after"?i:"",denyAfterSeconds:Qn(t.denyAfterSeconds),maxHops:Qn(n.maxHops),maxTurns:Qn(n.maxTurns),maxTokens:Qn(n.maxTokens),maxWallClockSeconds:Qn(n.maxWallClockSeconds),warningThreshold:Qn(n.warningThreshold),cycleMaxRepeats:Qn(s.maxRepeats),cycleCooldownSeconds:Qn(s.cooldownSeconds),allowAutoCreate:e?.allowAutoCreate===!0,federationAccept:l==="principal"||l==="log"?l:""}}function Zy(e,t,n,s,r){const i=e.trim();if(i==="")return;const l=Number(i);if(!Number.isInteger(l)||l<n||s!==void 0&&l>s){r[t]=s===void 0?{code:"integerMin",min:n}:{code:"denyAfterRange"};return}return l}function Us(e,t,n,s,r,i,l){if(e.trim()===""){delete n[s];return}const c=Zy(e,t,r,i,l);c!==void 0&&(n[s]=c)}function ex(e,t){const n={},s={...e??{}},r=Xr(s.permission),i=Xr(s.budget),l=Xr(i.cycle),c=Xr(s.federation);if(t.unattended==="")delete r.unattended,delete r.denyAfterSeconds;else if(t.unattended==="hold")r.unattended="hold",delete r.denyAfterSeconds;else if(r.unattended="deny-after",t.denyAfterSeconds.trim()==="")n.denyAfterSeconds={code:"denyAfterRequired"};else{const d=Zy(t.denyAfterSeconds,"denyAfterSeconds",1,86400,n);d!==void 0&&(r.denyAfterSeconds=d)}if(Us(t.maxHops,"maxHops",i,"maxHops",1,void 0,n),Us(t.maxTurns,"maxTurns",i,"maxTurns",1,void 0,n),Us(t.maxTokens,"maxTokens",i,"maxTokens",1,void 0,n),Us(t.maxWallClockSeconds,"maxWallClockSeconds",i,"maxWallClockSeconds",1,void 0,n),t.warningThreshold.trim()==="")delete i.warningThreshold;else{const d=Number(t.warningThreshold.trim());!Number.isFinite(d)||d<=0||d>=1?n.warningThreshold={code:"threshold"}:i.warningThreshold=d}return Us(t.cycleMaxRepeats,"cycleMaxRepeats",l,"maxRepeats",1,void 0,n),Us(t.cycleCooldownSeconds,"cycleCooldownSeconds",l,"cooldownSeconds",1,void 0,n),Object.keys(l).length>0?i.cycle=l:delete i.cycle,Object.keys(i).length>0?s.budget=i:delete s.budget,Object.keys(r).length>0?s.permission=r:delete s.permission,t.federationAccept===""?delete c.accept:c.accept=t.federationAccept,Object.keys(c).length>0?s.federation=c:delete s.federation,t.allowAutoCreate?s.allowAutoCreate=!0:e?.allowAutoCreate!==!1&&delete s.allowAutoCreate,Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,policy:s}}function uH(e,t){return JSON.stringify(e??{})!==JSON.stringify(t)}function mH({node:e,teamId:t,onBack:n,onSaved:s}){He();const{epoch:r}=Ae(),{teamControl:i,hasTokenFor:l}=ut(),c=i(e),d=l(e),m=ge(e),f=St(y=>y.details[go(m,t,"summary")]),h=St(y=>y.loadDetail),p=St(y=>y.update),g=()=>{h(m,t,c,{limit:1,members_limit:1},"summary")};qt(()=>{h(m,t,c,{limit:1,members_limit:1},"summary")},{enabled:d,deps:[r,m,t]});const b=Se(f);let x;return d?f?.status==="error"&&!b?x=o.jsx(Ve,{message:f.error,onRetry:g}):b?b.team.archived_at!==void 0?x=o.jsx(Fe,{title:a("team.form.archivedReadonly")}):x=o.jsx(fH,{detail:b,onSave:async y=>{const v=await p(c,y);return s(),v},onBack:n},b.team.team_id):x=o.jsx(Ke,{label:a("common.loading"),rows:2}):x=o.jsx(Fe,{title:a("team.error.noToken"),reason:a("team.error.noTokenReason")}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-clip overflow-y-auto overscroll-contain p-6 pb-10 max-compact:px-3 max-compact:pt-4 max-compact:pb-7 [&>*]:mx-auto [&>*]:w-full [&>*]:max-w-[var(--content-max)]",children:[o.jsx(iH,{title:b?.team.name||t,actions:o.jsx(G,{onClick:n,children:a("teams.edit.back")})}),o.jsx("div",{className:"mt-5 flex flex-col gap-4",children:x})]})}function fH({detail:e,onSave:t,onBack:n}){He();const s=ot(),r=e.team,i=u.useRef({name:r.name??"",description:r.description??""}),[l,c]=u.useState(i.current.name),[d,m]=u.useState(i.current.description),[f,h]=u.useState(()=>dH(r.policy)),[p,g]=u.useState({}),[b,x]=u.useState(!1),[y,v]=u.useState(null),j=S=>{h(w=>({...w,...S})),g(w=>{const k={...w};for(const N of Object.keys(S))delete k[N];return k})},_=async S=>{if(S.preventDefault(),b)return;v(null);const w=ex(r.policy,f);if(!w.ok){g(w.errors);return}g({});const k={team_id:r.team_id},N=gc(l);N!==void 0&&N!==i.current.name.trim()&&(k.name=N);const T=lH(d,i.current.description);T.changed&&(k.description=T.value),uH(r.policy,w.policy)&&(k.policy=w.policy),x(!0);try{const R=await t(k);s.success(`${a("team.form.editTitle")}: ${R.name||R.team_id}`),n()}catch(R){const E=R.code;if(E==="forbidden")v(a("team.form.forbidden"));else if(E==="conflict")v(a("team.form.archivedReadonly"));else{const I=R instanceof Error?R.message:String(R);v(`${a("team.form.updateFailed")}: ${I}`)}}finally{x(!1)}};return o.jsx(et,{children:o.jsxs("form",{className:"flex flex-col gap-2",onSubmit:_,children:[o.jsxs("div",{className:"form-grid mt-1",children:[o.jsx(We,{label:a("team.form.workspace"),htmlFor:"team-edit-workspace",hint:a("team.form.workspaceHint"),children:o.jsx(Xe,{id:"team-edit-workspace",className:"bg-deep text-muted",value:r.workspace??"",readOnly:!0,placeholder:"—"})}),o.jsx(We,{label:a("team.form.status"),hint:a("team.form.statusHint"),children:o.jsx("div",{className:"flex min-h-9 items-center",children:o.jsx(Re,{tone:r.spawn_frozen===!0?"warn":"neutral",children:r.spawn_frozen===!0?a("team.form.statusFrozen"):a("team.form.statusActive")})})}),o.jsx(We,{label:a("team.form.name"),htmlFor:"team-edit-name",children:o.jsx(Xe,{id:"team-edit-name",value:l,onChange:S=>c(S.target.value),spellCheck:!1,autoComplete:"off"})}),o.jsx(We,{label:a("team.form.description"),htmlFor:"team-edit-description",children:o.jsx(Hi,{id:"team-edit-description",className:"min-h-16 resize-y font-sans",value:d,onChange:S=>m(S.target.value),rows:3})}),o.jsx(Xy,{idPrefix:"team-edit",form:f,errors:p,onChange:j})]}),y&&o.jsx("p",{className:"form-error",role:"alert",children:y}),o.jsxs("div",{className:"form-actions",children:[o.jsx(G,{type:"button",onClick:n,disabled:b,children:a("common.cancel")}),o.jsx(G,{type:"submit",variant:"primary",disabled:b,children:a(b?"common.processing":"team.form.submitEdit")})]})]})})}function hH({node:e,route:t,navigate:n,membersOpen:s,onCloseMembers:r,panes:i}){He();const{connectionState:l,epoch:c,permissions:d,asks:m,responding:f,respondPermission:h,respondAsk:p}=Ae(),{teamControl:g,hasTokenFor:b,nodes:x}=ut(),y=Ji(),v=g(e),j=b(e),[_,S]=u.useState(()=>kh(window.location.hash,t.nodeKey,t.teamId)),w=ge(e),k=Bt(),N=St(F=>F.details[go(w,t.teamId,"summary")]),T=St(F=>F.loadDetail),R=St(F=>F.loadAllLists),E=()=>{T(w,t.teamId,v,{limit:1,members_limit:1},"summary")},I=()=>{E(),R(x,g)};qt(()=>{T(w,t.teamId,v,{limit:1,members_limit:1},"summary")},{enabled:j,deps:[c,w,t.teamId]});const $=Se(N)?.team,C=Gg("team",oa($));u.useEffect(()=>{const F=()=>S(kh(window.location.hash,t.nodeKey,t.teamId));return window.addEventListener("hashchange",F),()=>window.removeEventListener("hashchange",F)},[t.nodeKey,t.teamId]),u.useEffect(()=>{if(!t.agentId)return;const F=t.bodyId?Jc(w,t.agentId,t.bodyId):oo(w,t.agentId);window.location.hash!==F&&(window.history.replaceState(null,"",F),queueMicrotask(()=>window.dispatchEvent(new Event("hashchange"))))},[t.agentId,t.bodyId,w]);const L=()=>{window.location.hash=Fn({domain:"teams",nodeKey:t.nodeKey,teamId:t.teamId})};if(_)return o.jsx(mH,{node:e,teamId:t.teamId,onBack:L,onSaved:I});const A=e.current?y.entries:[],D=e.current?d:[],O=e.current?m:[];return t.agentId?null:o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[C&&o.jsx("p",{className:"m-0 rounded-sm border border-line-strong bg-warn-soft px-3 py-2 text-sm text-warn",role:"status",children:a(C)}),o.jsx(rH,{client:v,hasToken:j,nodeName:k.get(w),nodeCurrent:e.current,frozen:$?.spawn_frozen===!0,connectionState:e.current?l:"open",epoch:c,teamId:t.teamId,nodeKey:w,permissions:D,asks:O,events:A,responding:f,onDecidePermission:(F,V,B)=>{h(F,V,B)},onRespondAsk:(F,V)=>{p(F,V)},onOpenMember:F=>{window.location.hash=oo(w,F)},onOpenSession:F=>n({domain:"chat",sessionId:F}),onBackToList:()=>n({domain:"teams"}),membersOpen:s,onCloseMembers:r,panes:i})]})}function pH({state:e,panes:t}){const{isDetail:n,restorePending:s,detailNode:r,detailRoute:i,navigate:l,compact:c,drawerOpen:d,setDrawerOpen:m,membersOpen:f,setMembersOpen:h}=e;let p;return n?r&&i?p=o.jsx(hH,{node:r,route:i,navigate:l,membersOpen:f,onCloseMembers:()=>h(!1),panes:t}):p=o.jsx("div",{className:"teams-detail-empty",children:o.jsx(Fe,{title:a("teams.nodeMissing"),action:o.jsx(G,{onClick:()=>l({domain:"teams"}),children:a("team.chat.backToList")})})}):p=s?null:o.jsx("div",{className:"teams-detail-empty",children:o.jsx($e,{title:a("teams.detail.emptyTitle"),description:a("teams.detail.emptyDesc")})}),o.jsxs("section",{className:"teams-detail-pane","aria-label":a("teams.title"),inert:c&&d?!0:void 0,children:[o.jsx("h1",{className:"sr-only",children:a("teams.title")}),c&&o.jsx("div",{className:"teams-detail-toolbar",children:o.jsx(G,{id:"teams-list-toggle",size:"small","aria-expanded":d,"aria-controls":"teams-column",onClick:()=>m(!0),children:a("teams.openList")})}),o.jsx("div",{className:"teams-detail-body",children:p})]})}function gH({node:e,team:t,active:n,menuItems:s,onOpen:r}){const i=oa(t);return o.jsxs("li",{className:`teams-card ${n?"active":""} ${i?"opacity-70":""}`.trim(),children:[o.jsxs("button",{type:"button",className:"teams-card-open",title:a("teams.card.open"),"aria-current":n?"true":void 0,onClick:()=>r(e,t),children:[o.jsxs("span",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"min-w-0 truncate font-semibold",children:t.name||t.team_id}),o.jsx("span",{className:"flex flex-none items-center gap-2",children:i&&o.jsx(Re,{tone:"warn",className:"flex-none",children:a(cd("team"))})})]}),o.jsxs("span",{className:"flex flex-wrap gap-3 text-sm text-muted",children:[o.jsx("span",{children:a("teams.card.members",{members:t.member_count})}),o.jsx("span",{children:t.online_count!==void 0?a("teams.card.online",{online:t.online_count}):"—"})]})]}),o.jsx(Gi,{className:"teams-card-menu",label:`${a("common.moreActions")}: ${t.name||t.team_id}`,items:s(e,t)})]})}function bH(e){return e.code==="forbidden"?a("teams.error.forbidden"):e.code==="not_found"?a("teams.error.notEnabled"):e.error??a("common.loadFailed")}function vH({state:e,panes:t}){const{compact:n,drawerOpen:s,setDrawerOpen:r,drawerRef:i,writableNodes:l,setCreateOpen:c,refreshCurrent:d,loaded:m,query:f,setQuery:h,nodeFilter:p,changeNodeFilter:g,nodes:b,nodeNames:x,anyNodeToken:y,allFailed:v,data:j,allTeams:_,visibleTeams:S,hiddenArchivedTeams:w,hasSearchOrFilter:k,clearSearch:N,partial:T,visible:R,openTeam:E,isActiveTeam:I,isRunningTeam:$,menuItems:C}=e,L=o.jsx(G,{variant:"primary",size:"small",onClick:()=>c(!0),disabled:l.length===0,children:a("nodes.teams.create")});let A;return y?m?v&&j[0]?.code==="not_found"?A=o.jsx(Fe,{title:a("teams.error.notEnabled"),reason:a("team.error.notEnabledReason"),hint:a("team.error.notEnabledHint")}):!v&&_===0&&w===0?A=o.jsx($e,{title:a("teams.empty"),action:l.length>0?L:void 0}):!v&&S===0&&k?A=o.jsx($e,{title:a("teams.empty"),action:o.jsx(G,{onClick:N,children:a("team.list.clearSearch")})}):!v&&S===0?A=o.jsx($e,{title:a("archive.empty.teams"),description:a("archive.hidden.teams",{count:w})}):A=o.jsxs(o.Fragment,{children:[T&&o.jsx("p",{className:"m-0 rounded-sm border border-line-strong bg-warn-soft px-3 py-2 text-sm text-warn",role:"status",children:a("teams.partialError")}),o.jsx("div",{className:"flex flex-col gap-5",children:R.map(D=>o.jsxs("section",{className:"flex min-w-0 flex-col gap-2","aria-label":x.get(ge(D.node))??"—",children:[o.jsxs("header",{className:"sidebar-group-label",children:[o.jsx("span",{children:x.get(ge(D.node))??"—"}),D.node.current&&R.length>1&&o.jsxs("span",{className:"text-2xs",title:a("entity.currentNode"),children:[o.jsx("span",{"aria-hidden":"true",children:"· "}),a("entity.currentNode")]})]}),D.ok?D.teams.length===0?o.jsx("p",{className:"m-0 py-2 text-sm text-muted",children:a("teams.empty")}):o.jsx("ul",{className:"teams-grid",children:D.teams.map(O=>o.jsx(gH,{node:D.node,team:O,active:I(D.node,O),running:$(D.node,O),menuItems:C,onOpen:E},O.team_id))}):o.jsx("p",{className:"m-0 rounded-sm border border-line-strong bg-danger-soft px-3 py-2 text-sm text-danger",role:"alert",children:bH(D)})]},ge(D.node)))})]}):A=o.jsx(Ke,{rows:3}):A=o.jsx(Fe,{title:a("team.error.noToken"),reason:a("team.error.noTokenReason")}),o.jsxs(o.Fragment,{children:[o.jsx(eg,{as:"aside",id:"teams-column",label:a("teams.title"),title:a("teams.title"),actions:o.jsxs(o.Fragment,{children:[L,o.jsx(G,{size:"small",onClick:d,disabled:!m,children:a("common.refresh")})]}),controls:o.jsxs(o.Fragment,{children:[o.jsx(Tn,{value:f,onChange:h,placeholder:a("team.list.search"),ariaLabel:a("team.list.search")}),o.jsxs($t,{className:"h-control w-full py-0",value:p,onChange:D=>g(D.target.value),"aria-label":a("teams.filter.node"),children:[o.jsx("option",{value:"",children:a("teams.filter.all")}),b.map(D=>o.jsx("option",{value:ge(D),children:x.get(ge(D))??"—"},ge(D)))]})]}),shellRef:i,drawer:n?{open:s,onClose:()=>r(!1),closeLabel:a("common.close"),backdropLabel:a("common.close")}:void 0,children:A}),!n&&!t.disabled("teamList")&&o.jsx(kr,{pane:"teamList",api:t,label:a("resize.teams"),className:"resize-handle resize-handle-team-list"})]})}function yH({nodes:e,initialNodeKey:t,onClose:n,onSaved:s}){He();const r=ot(),{teamControl:i}=ut(),l=Bt(),c=t!==void 0&&e.some($=>ge($)===t)?t:void 0,[d,m]=u.useState(c??(e[0]?ge(e[0]):"")),[f,h]=u.useState(""),[p,g]=u.useState(""),[b,x]=u.useState(""),[y,v]=u.useState(cH),[j,_]=u.useState({}),[S,w]=u.useState(null),[k,N]=u.useState(!1),T=$=>{v(C=>({...C,...$})),_(C=>{const L={...C};for(const A of Object.keys($))delete L[A];return L})},R=e.find($=>ge($)===d),E=a("team.form.createTitle"),I=async $=>{if($.preventDefault(),k||!R)return;w(null);const C=f.trim();if(C===""){w(a("team.form.required"));return}const L=ex(void 0,y);if(!L.ok){_(L.errors);return}_({});const A={workspace:C},D=gc(p),O=gc(b);D!==void 0&&(A.name=D),O!==void 0&&(A.description=O),Object.keys(L.policy).length>0&&(A.policy=L.policy),N(!0);try{const F=await i(R).createTeam(A);r.success(`${E}: ${F.name||F.team_id}`),s(F),n()}catch(F){if(F.code==="forbidden")w(a("team.form.forbidden"));else{const B=F instanceof Error?F.message:String(F);w(`${a("team.form.createFailed")}: ${B}`)}}finally{N(!1)}};return o.jsxs(tn,{label:E,onClose:()=>{k||n()},closeOnBackdrop:!k,closeLabel:a("common.close"),children:[o.jsx("h2",{className:"modal-title",children:E}),o.jsxs("form",{className:"flex flex-col gap-2",onSubmit:I,children:[o.jsxs("div",{className:"form-grid mt-1",children:[o.jsx(We,{label:a("teams.filter.node"),htmlFor:"team-create-node",children:o.jsx($t,{id:"team-create-node",value:d,onChange:$=>m($.target.value),"aria-label":a("teams.filter.node"),children:e.map($=>o.jsx("option",{value:ge($),children:l.get(ge($))??"—"},ge($)))})}),o.jsx(We,{label:a("team.form.workspace"),htmlFor:"team-create-workspace",hint:a("team.form.workspaceHint"),children:o.jsx(Xe,{id:"team-create-workspace",invalid:S===a("team.form.required"),value:f,onChange:$=>h($.target.value),placeholder:"/absolute/workspace",spellCheck:!1,autoComplete:"off",required:!0})}),o.jsx(We,{label:a("team.form.name"),htmlFor:"team-create-name",children:o.jsx(Xe,{id:"team-create-name",value:p,onChange:$=>g($.target.value),spellCheck:!1,autoComplete:"off"})}),o.jsx(We,{label:a("team.form.description"),htmlFor:"team-create-description",children:o.jsx(Hi,{id:"team-create-description",className:"min-h-16 resize-y font-sans",value:b,onChange:$=>x($.target.value),rows:2})}),o.jsx(Xy,{idPrefix:"team-create",form:y,errors:j,onChange:T})]}),S&&o.jsx("p",{className:"form-error",role:"alert",children:S}),o.jsxs("div",{className:"modal-actions",children:[o.jsx(G,{type:"button",onClick:n,disabled:k,children:a("common.cancel")}),o.jsx(G,{type:"submit",variant:"primary",disabled:k||!R,children:a(k?"common.processing":"team.form.submitCreate")})]})]})]})}function xH({state:e}){const{createOpen:t,setCreateOpen:n,writableNodes:s,nodeFilter:r,reloadLists:i,archiveTarget:l,setArchiveTarget:c,archiving:d,archiveError:m,setArchiveError:f,confirmArchive:h}=e;return o.jsxs(o.Fragment,{children:[t&&o.jsx(yH,{nodes:s,...r?{initialNodeKey:r}:{},onClose:()=>n(!1),onSaved:i}),l&&o.jsx(In,{title:a("nodes.teams.archiveTitle"),body:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:a("nodes.teams.archiveBody")}),o.jsx("p",{className:"font-mono",children:l.team.name||l.team.team_id}),m&&o.jsx("p",{className:"text-xs text-danger leading-snug",role:"alert",children:m})]}),confirmLabel:a("common.archive"),danger:!0,busy:d,onConfirm:()=>{h()},onCancel:()=>{d||(c(null),f(null))}})]})}function mr(e,t){return`${e}:${t}`}function tx(e,t){return`${e}:${t}`}function wH(e){const t=new Set;for(const n of e?.running??[])typeof n.agent_id=="string"&&n.agent_id!==""&&t.add(n.agent_id);return t}function kH(e,t){const n=new Set;if(t.size===0)return n;for(const[s,r]of e)for(const i of r.members)if(t.has(tx(r.nodeKey,i.agent_id))){n.add(s);break}return n}function SH(e){if(typeof e.last_active_at=="number"&&Number.isFinite(e.last_active_at))return e.last_active_at;if(typeof e.created_at=="number"&&Number.isFinite(e.created_at))return e.created_at}function jH(e){let t;typeof e.last_seen=="number"&&Number.isFinite(e.last_seen)&&(t=e.last_seen);for(const n of e.bodies??[]){const s=SH(n);s!==void 0&&(t===void 0||s>t)&&(t=s)}return t}function _H(e){let t;for(const n of e??[]){const s=jH(n);s!==void 0&&(t===void 0||s>t)&&(t=s)}return t}function NH(e,t,n){const s=mr(e.nodeKey,e.team.team_id),r=t.runningTeams?.has(s)===!0?0:1,i=_H(t.membersByTeam?.get(s)?.members),l=e.team.created_at,c=i??(Number.isFinite(l)?l:0);return{rank:r,activity:c>n?n:c,id:s}}function CH(e,t={}){const n=t.now??Number.POSITIVE_INFINITY;return _p(e,s=>NH(s,t,n))}const bc="vessel.team.lastTeam.v1.";function eu(e){return`LAST_TEAM_KEY_PREFIX${e?.trim()||"default"}`}function nx(e,t){return`${e}:${t}`}function Hh(e,t){if(!e)return null;try{const s=e.getItem(eu(t))?.trim();return s||null}catch{return null}}function TH(e){if(!e)return null;try{const t=[];for(let n=0;n<e.length;n+=1){const s=e.key(n);s?.startsWith(bc)&&t.push(s)}t.sort();for(const n of t){const s=e.getItem(n)?.trim();if(s)return{nodeKey:n.slice(bc.length),teamId:s}}return null}catch{return null}}function EH(e,t,n){if(!e)return;const s=n.trim(),r=t.trim();if(!(!s||!r))try{const i=eu(r);for(let l=e.length-1;l>=0;l-=1){const c=e.key(l);!c||c===i||c.startsWith(bc)&&e.removeItem(c)}e.setItem(i,s)}catch{}}function bl(e,t){if(e)try{e.removeItem(eu(t))}catch{}}function IH(e){const{routeTeamId:t,stored:n,knownTeams:s}=e;return t?{kind:"keep"}:n?s===null?{kind:"wait"}:s.includes(nx(n.nodeKey,n.teamId))?{kind:"restore",nodeKey:n.nodeKey,teamId:n.teamId}:{kind:"default",clear:!0}:{kind:"default",clear:!1}}function RH(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.name.toLowerCase().includes(n)||e.team_id.toLowerCase().includes(n)}function LH(e,t){const n=t.trim();return n===""?[...e]:e.map(s=>({...s,teams:s.teams.filter(r=>RH(r,n))})).filter(s=>!s.ok||s.teams.length>0)}function AH(e){return mr(e.nodeKey,e.team.team_id)}function MH(e,t){const{runningTeams:n,membersByTeam:s,resetKey:r}=t,i=u.useCallback((c,d)=>CH(c,{...n!==void 0?{runningTeams:n}:{},...s!==void 0?{membersByTeam:s}:{},now:d}),[n,s]),l=u.useCallback(c=>{const d=mr(c.nodeKey,c.team.team_id);return n?.has(d)===!0?d:null},[n]);return Sy(e,{keyOf:AH,order:i,resetKey:r,promoteToken:l})}const PH=2e4;function qH(e){const t=e.startsWith("#")?e.slice(1):e,[n=""]=t.split("?",2),s=n.split("/").filter(Boolean);return s.length===1&&s[0]==="teams"}function OH({route:e,navigate:t}){He();const n=ot(),{epoch:s,eventStore:r}=Ae(),{nodes:i,teamControl:l,hasTokenFor:c}=ut(),d=Bt(),m=Zi()<=na,[f,h]=u.useState(""),[p,g]=u.useState(()=>cl(window.location.hash)??""),[b,x]=u.useState(!1),[y,v]=u.useState(!1),[j,_]=u.useState(!1),[S,w]=u.useState(null),[k,N]=u.useState(!1),[T,R]=u.useState(null),[E,I]=u.useState(null),[$,C]=u.useState(!1),[L,A]=u.useState(0),D="teamId"in e,O=i.some(P=>c(P)),F=i.filter(P=>c(P)),V=pa({open:y,onClose:()=>v(!1),enabled:m,returnFocusId:"teams-list-toggle"});u.useEffect(()=>{m||v(!1)},[m]);const B=i.map(P=>ge(P)).join(","),W=St(P=>P.lists),Z=St(P=>P.loadAllLists),ee=St(P=>P.loadDetail),ie=St(P=>P.archive),le=St(P=>P.setSpawnFrozen),J=Yt(P=>P.loadRoster),z=Sr(r,P=>dd(P.event),s);qt(()=>{Z(i,l)},{enabled:O&&i.length>0,pollMs:PH,deps:[s,B,z]}),u.useEffect(()=>{const P=()=>{qH(window.location.hash)&&g(cl(window.location.hash)??"")};return window.addEventListener("hashchange",P),()=>window.removeEventListener("hashchange",P)},[]);const me=D?`${e.nodeKey}:${e.teamId}`:"";u.useEffect(()=>{me&&v(!1)},[me]);const K=D?e.nodeKey:"",ne=D?e.teamId:"";u.useEffect(()=>{ne&&EH(en(),K,ne)},[K,ne]);const Ne=ne?go(K,ne,"summary"):"",ce=St(P=>Ne?P.details[Ne]:void 0),se=ce?.status==="error"?ce.code:void 0;u.useEffect(()=>{if(!ne||se!=="not_found")return;const P=en();Hh(P,K)===ne&&bl(P,K)},[K,ne,se]);const we=P=>{if(g(P),D)return;const ae=P?`#/teams?${new URLSearchParams({node:P}).toString()}`:"#/teams";window.location.hash!==ae&&window.history.replaceState(null,"",ae)},he=u.useMemo(()=>i.map(P=>Cd(W[ge(P)])).filter(P=>P!==void 0),[i,W]),pe=i.length>0&&he.length===i.length,Me=ra(),oe=u.useMemo(()=>he.map(P=>P.ok?{...P,teams:OT(P.teams,Me)}:P),[he,Me]),je=u.useMemo(()=>ld(he.flatMap(P=>P.ok?P.teams:[]),Me,oa),[he,Me]),Ee=u.useMemo(()=>i.length===0||he.length!==i.length||he.some(P=>!P.ok)?null:he.flatMap(P=>P.teams.map(ae=>nx(ge(P.node),ae.team_id))),[i,he]),Ce=u.useRef(!1);u.useEffect(()=>{if(Ce.current||cl(window.location.hash))return;const P=en(),ae=ne?null:TH(P),Le=IH({...ne?{routeTeamId:ne}:{},stored:ae,knownTeams:ne?null:Ee});if(Le.kind==="wait"){C(ae!==null&&he.length<i.length);return}if(Ce.current=!0,C(!1),Le.kind==="restore"){t({domain:"teams",nodeKey:Le.nodeKey,teamId:Le.teamId});return}Le.kind==="default"&&Le.clear&&ae&&bl(P,ae.nodeKey)},[he.length,ne,Ee,t,i.length]);const U=u.useMemo(()=>LH(oe,f),[oe,f]),q=u.useMemo(()=>p?U.filter(P=>ge(P.node)===p):U,[U,p]),M=oe.reduce((P,ae)=>P+ae.teams.length,0),H=q.reduce((P,ae)=>P+ae.teams.length,0),X=he.filter(P=>!P.ok),Y=he.length>0&&X.length===he.length,re=X.length>0&&X.length<he.length,_e=f.trim()!==""||p!=="",fe=Dt(P=>P.health),Pe=Yt(P=>P.roster),ke=u.useMemo(()=>Se(Pe)??[],[Pe]),Ge=u.useMemo(()=>{const P=new Map;for(const ae of ke){const Le=ge(ae.node);for(const te of ae.rosters)P.set(mr(Le,te.team.team_id),{nodeKey:Le,members:te.members})}return P},[ke]),mt=u.useMemo(()=>{const P=new Set;for(const ae of i){const Le=ge(ae);for(const te of wH(Xo(fe,ae)?.health?.runtime?.scheduler))P.add(tx(Le,te))}return P},[i,fe]),lt=u.useMemo(()=>kH(Ge,mt),[Ge,mt]),de=u.useMemo(()=>q.flatMap(P=>P.ok?P.teams.map(ae=>({nodeKey:ge(P.node),team:ae})):[]),[q]),qe=MH(de,{runningTeams:lt,membersByTeam:Ge,resetKey:[String(s),f,p,String(Me),String(L)].join("|")}),Oe=u.useMemo(()=>{const P=new Map;for(const ae of qe){const Le=P.get(ae.nodeKey);Le!==void 0?Le.push(ae.team):P.set(ae.nodeKey,[ae.team])}return P},[qe]),ue=u.useMemo(()=>q.map(P=>P.ok?{...P,teams:Oe.get(ge(P.node))??P.teams}:P),[q,Oe]),xe=(P,ae)=>lt.has(mr(ge(P),ae.team_id)),De=P=>i.find(ae=>ge(ae)===P),Je=(P,ae)=>{ee(ge(P),ae,l(P),{limit:1,members_limit:1},"summary")},ht=()=>{if(Z(i,l),D){const P=De(e.nodeKey);P&&c(P)&&Je(P,e.teamId)}A(P=>P+1),rd()},ft=async(P,ae)=>{const Le=`${ge(P)}:${ae.team_id}`;if(E!==null)return;const te=ae.spawn_frozen!==!0;I(Le);try{await le(l(P),ae.team_id,te),n.success(a(te?"teams.frozen":"teams.unfrozen")),Z(i,l),Je(P,ae.team_id)}catch(Ie){n.error(Ie instanceof Error?Ie.message:String(Ie))}finally{I(null)}},pt=async()=>{if(!S||k)return;const{node:P,team:ae}=S,Le=ge(P);N(!0),R(null);try{const te=await ie(l(P),ae.team_id);n.success(`${te.name||te.team_id}: ${a("nodes.teams.archived")}`),w(null),Z(i,l),J(i,l);const Ie=en();Hh(Ie,Le)===ae.team_id&&bl(Ie,Le),D&&e.nodeKey===Le&&e.teamId===ae.team_id?t({domain:"teams"}):Je(P,ae.team_id)}catch(te){R(te instanceof Error?te.message:String(te))}finally{N(!1)}},Q=(P,ae)=>{t({domain:"teams",nodeKey:ge(P),teamId:ae.team_id}),m&&v(!1)},ye=(P,ae)=>D&&e.nodeKey===ge(P)&&e.teamId===ae.team_id,Te=(P,ae)=>{if(ye(P,ae)){_(Le=>!Le);return}Q(P,ae),_(!0)},Ue=(P,ae)=>{const Le=ae.archived_at!==void 0,te=ae.spawn_frozen===!0,Ie=c(P)&&!Le,Ze=ye(P,ae)&&j;return[{id:"edit",label:a("common.edit"),disabled:!Ie,onSelect:()=>{window.location.hash=CO(ge(P),ae.team_id),m&&v(!1)}},{id:"members",label:a(Ze?"team.members.close":"team.members.open"),disabled:!c(P),onSelect:()=>{Te(P,ae)}},{id:"freeze",label:a(te?"teams.unfreeze":"teams.freeze"),disabled:!Ie||E!==null,onSelect:()=>{ft(P,ae)}},{id:"archive",label:a("common.archive"),danger:!0,disabled:!Ie,onSelect:()=>{R(null),w({node:P,team:ae})}},{id:"refresh",label:a("common.refresh"),onSelect:ht},{id:"copyId",label:a("teams.card.copyId"),onSelect:()=>{Bc(ae.team_id).then(()=>n.success(a("common.copied"))).catch(at=>{n.error(at instanceof Error?at.message:String(at))})}}]},Be=()=>{h(""),we("")},tt=()=>{Z(i,l)},Kt=D?De(e.nodeKey):void 0;return{navigate:t,isDetail:D,restorePending:$,detailRoute:D?e:void 0,compact:m,drawerOpen:y,setDrawerOpen:v,drawerRef:V,membersOpen:j,setMembersOpen:_,query:f,setQuery:h,nodeFilter:p,changeNodeFilter:we,clearSearch:Be,createOpen:b,setCreateOpen:x,archiveTarget:S,setArchiveTarget:w,archiving:k,archiveError:T,setArchiveError:R,nodes:i,writableNodes:F,nodeNames:d,anyNodeToken:O,loaded:pe,data:he,visible:ue,allFailed:Y,allTeams:M,visibleTeams:H,hiddenArchivedTeams:je,showArchived:Me,partial:re,hasSearchOrFilter:_e,refreshCurrent:ht,openTeam:Q,isActiveTeam:ye,isRunningTeam:xe,menuItems:Ue,confirmArchive:pt,reloadLists:tt,detailNode:Kt}}function DH({route:e,navigate:t,panes:n}){const s=OH({route:e,navigate:t});return o.jsxs("div",{className:"teams-workspace",children:[o.jsx(vH,{state:s,panes:n}),o.jsx(pH,{state:s,panes:n}),o.jsx(xH,{state:s})]})}const HH=u.lazy(()=>sa(()=>import("./DesignLabView-DTBWv5-E.js"),__vite__mapDeps([4,1,2,0])).then(e=>({default:e.DesignLabView})));function $H({route:e,navigate:t,chatSessionsOpen:n,onCloseSessions:s,panes:r}){return o.jsxs(o.Fragment,{children:[e.domain==="chat"&&o.jsx(Pq,{route:e,navigate:t,sessionsOpen:n,onCloseSessions:s,panes:r}),e.domain==="hub"&&o.jsx(Jq,{}),e.domain==="pending"&&o.jsx(_D,{...e.sessionId?{sessionId:e.sessionId}:{}}),e.domain==="gateway"&&o.jsx(Bq,{navigate:t}),e.domain==="pluginHost"&&o.jsx(PD,{}),e.domain==="nodes"&&o.jsx(LO,{route:e,navigate:t}),e.domain==="teams"&&o.jsx(DH,{route:e,navigate:t,panes:r}),e.domain==="kanban"&&o.jsx(SO,{}),e.domain==="agents"&&o.jsx(kL,{route:e,navigate:t}),e.domain==="runs"&&o.jsx(f2,{route:e,navigate:t}),(e.domain==="tools"||e.domain==="mcp"||e.domain==="channels")&&o.jsx(bO,{domain:e.domain}),e.domain==="observe"&&o.jsx(uD,{route:e,navigate:t}),e.domain==="plugins"&&o.jsx(HD,{route:e}),e.domain==="capabilities"&&o.jsx(S2,{}),e.domain==="designLab"&&o.jsx(u.Suspense,{fallback:o.jsx(Ke,{label:a("settings.dialog.loading")}),children:o.jsx(HH,{})})]})}function FH(e){const t=[],n=e.sessionInvalid??null,s=n?.kind==="connection";return e.tokenError&&t.push({id:"shell-token-error",tone:"error",text:e.tokenError,actions:[{label:a("app.openConnection"),onClick:e.onOpenConnection}]}),n?.kind==="session"?t.push({id:"shell-rpc-session",tone:"error",text:a("gateway.rpc.sessionInvalid"),hint:a("gateway.rpc.sessionInvalidHint"),actions:[e.canRelogin===!1?{label:a("gateway.rpc.connectInstead"),onClick:e.onOpenConnection}:{label:a("gateway.rpc.relogin"),onClick:e.onRelogin}]}):n?.kind==="origin"?t.push({id:"shell-rpc-origin",tone:"error",text:a("gateway.rpc.originBlocked"),hint:a("gateway.rpc.originBlockedHint",{detail:n.message}),actions:[{label:a("app.openConnection"),onClick:e.onOpenConnection}]}):n?.kind==="connection"&&!e.tokenError&&t.push({id:"shell-rpc-unreachable",tone:"error",text:a("gateway.rpc.unreachable"),hint:a("gateway.rpc.unreachableHint",{count:n.attempts??0,detail:n.message}),actions:[{label:a("app.openConnection"),onClick:e.onOpenConnection}]}),e.lastError&&!s&&t.push({id:"shell-error",tone:"error",text:e.lastError,onDismiss:e.onDismissError}),e.stale&&!s&&t.push({id:"shell-stale",tone:"warn",text:e.connectionState==="reconnecting"?a("app.reconnecting",{count:Math.max(1,e.reconnectAttempt)}):a("app.stale"),actions:[{label:a("app.retryNow"),onClick:e.onRetry},{label:a("app.connectionSettings"),onClick:e.onOpenConnection}]}),t}function sx(e){if(!e||typeof e!="object")return!1;const t=e;if(t.isContentEditable===!0)return!0;const n=typeof t.tagName=="string"?t.tagName.toUpperCase():"";return n==="INPUT"||n==="TEXTAREA"||n==="SELECT"}function BH(e){return e.altKey?!1:(e.ctrlKey===!0||e.metaKey===!0)&&e.key.toLowerCase()==="k"}function KH(e){return e.ctrlKey||e.metaKey||e.altKey?!1:e.key==="/"&&!sx(e.target)}function WH(e){return e.altKey||e.shiftKey||sx(e.target)?!1:(e.ctrlKey===!0||e.metaKey===!0)&&e.key===","}function UH(){const[e,t]=u.useState(()=>Wu(window.location.hash));u.useEffect(()=>{const r=()=>t(Wu(window.location.hash));return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const n=u.useCallback(r=>{const i=Fn(r);window.location.hash!==i&&(window.location.hash=i)},[]),s=u.useCallback(r=>{const i=Fn(r);window.location.hash!==i&&(window.history.replaceState(null,"",i),t(r))},[]);return{route:e,navigate:n,replace:s}}var $h={builtAt:"2026-12-02T04:57:44.162Z",version:"2.3.0-beta.2",commit:"8883452"};const Fh=typeof $h<"u"?$h:{builtAt:"unknown",version:"unknown",commit:"unknown"};function ox(e){if(typeof e!="object"||e===null)return;const t=e;if(typeof t.builtAt!="string"||t.builtAt==="")return;const n=t.newestSource,s=t.autobuild;return{builtAt:t.builtAt,version:typeof t.version=="string"?t.version:"unknown",commit:typeof t.commit=="string"?t.commit:"unknown",...t.stale===!0?{stale:!0}:{},...t.building===!0?{building:!0}:{},...typeof s=="object"&&s!==null&&typeof s.enabled=="boolean"&&(s.lastError===void 0||typeof s.lastError=="string")?{autobuild:{enabled:s.enabled,...typeof s.lastError=="string"?{lastError:s.lastError}:{}}}:{},...typeof n=="object"&&n!==null&&typeof n.path=="string"&&typeof n.mtime=="string"?{newestSource:{path:n.path,mtime:n.mtime}}:{}}}function zH(e){try{return ox(JSON.parse(e))}catch{return}}async function VH(e){try{const t=await fetch("/build.json",{cache:"no-store",...e!==void 0?{signal:e}:{}});return t.ok?ox(await t.json()):void 0}catch{return}}function GH(e){if(e===void 0)return;if(e.building===!0)return"building";if(Fh.builtAt!=="unknown"&&e.builtAt!==Fh.builtAt)return"rebuilt";if(e.stale!==!0)return;const t=e.autobuild;return t===void 0?"stale":t.enabled?"building":t.lastError!==void 0?"stale":"disabled"}const YH="/web/build/events",Bh=[1e4,3e4,6e4],JH=5,QH=10,XH=15e3;function ZH(){const[e,t]=u.useState(void 0);return u.useEffect(()=>{let n=!1;const s=new AbortController,r=k=>{n||t(GH(k))};let i,l=0,c=0,d=!1;const m=()=>{d=!1,i!==void 0&&(clearTimeout(i),i=void 0)},f=()=>{if(n||!d)return;i!==void 0&&clearTimeout(i);const k=Bh[Math.min(l,Bh.length-1)]??6e4;i=setTimeout(()=>{h()},k)},h=async()=>{if(n||!d)return;const k=await VH(s.signal);if(!n){if(k===void 0){if(c+=1,c>=QH){m();return}l+=1}else c=0,l=0,r(k);f()}},p=()=>{n||d||(d=!0,l=0,h())};let g,b=0,x=!1,y;const v=()=>{y!==void 0&&(clearTimeout(y),y=void 0)},j=()=>{v(),g!==void 0&&(g.close(),g=void 0)},_=()=>{b+=1,b>=JH&&(x=!0,j()),p()},S=()=>{if(n||x)return;if(typeof EventSource>"u"){p();return}const k=new EventSource(YH,{withCredentials:!0});g=k,y=setTimeout(()=>{k.readyState!==EventSource.CLOSED&&(b+=1,p())},XH),k.onmessage=N=>{b=0,v();const T=zH(N.data);T!==void 0&&(r(T),m())},k.onerror=()=>{k.readyState===EventSource.CLOSED&&(x=!0),_()}};S(),p();const w=()=>{document.visibilityState==="visible"&&(g===void 0&&!x&&S(),!(g!==void 0&&g.readyState===EventSource.OPEN)&&p())};return document.addEventListener("visibilitychange",w),()=>{n=!0,s.abort(),m(),j(),document.removeEventListener("visibilitychange",w)}},[]),e}function e$(e){switch(e.domain){case"chat":return e.sessionId&&e.sessionId!=="new"?{kind:"chat",sessionId:e.sessionId}:{kind:"none"};case"teams":return{kind:"team"};case"runs":return e.runId?{kind:"run",runId:e.runId}:{kind:"runs"};default:return{kind:"none"}}}function t$(e){const{subscription:t}=Ae(),n=u.useMemo(()=>e$(e),[e]);u.useEffect(()=>{t.apply(n)},[t,n])}function n$(){const e=He(),{route:t,navigate:n,replace:s}=UH(),r=u.useRef(Up);t.domain!=="settings"&&(r.current=t);const i=t.domain==="settings"?r.current:t;t$(t);const l=ot(),c=Ax(),d=ZH(),{connectionState:m,hasToken:f,eventStore:h,lastError:p,tokenError:g,reconnectAttempt:b,stale:x,permissions:y,asks:v,notices:j,epoch:_,retry:S,dismissError:w,sessionInvalid:k,relogin:N,canRelogin:T,rotateCandidate:R}=Ae(),[E,I]=u.useState(!1),[$,C]=u.useState(""),[L,A]=u.useState(new Map),[D,O]=u.useState(!1),[F,V]=u.useState(!1),[B]=u.useState(()=>JC()),W=u.useRef(B!==null),[Z,ee]=u.useState(()=>B??Om(window.innerWidth)),[ie,le]=u.useState(!1),[J,z]=u.useState(""),[me,K]=u.useState(null),ne=u.useRef(null),Ne=u.useRef(!0),ce=Fn(t),se=u.useRef(-1),we=!!(me||D||t.domain==="settings"),he=Yt(te=>te.roster),pe=Yt(te=>te.loadRoster),{nodes:Me,teamControl:oe}=ut(),je=Bt(),Ee=u.useMemo(()=>Se(he)??[],[he]),Ce=u.useMemo(()=>Nc(Ee),[Ee]);u.useEffect(()=>{he.status!=="idle"||Me.length===0||pe(Me,oe)},[he.status,Me,oe,pe]);const U=u.useMemo(()=>su(y,t),[y,t]),q=u.useMemo(()=>su(v,t),[v,t]),M=u.useMemo(()=>({pending:y.length+v.length+j.length}),[y,v,j]),H=u.useCallback(te=>n({domain:"chat",sessionId:te}),[n]),X=u.useCallback(te=>n({domain:"pending",...te!==void 0?{sessionId:te}:{}}),[n]),[Y,re]=u.useState(tr),_e=u.useRef(Y);_e.current=Y;const fe=u.useRef(t);fe.current=t;const Pe=u.useRef(null);u.useEffect(()=>{if(R===null||Pe.current===R||(Pe.current=R,!Ou(t,R.oldSessionId)))return;const te=Qe.getState().drafts[Ut(R.oldSessionId)];re(Ak(R,Date.now(),Du(te)))},[R,t]);const ke=Y.phase==="countdown"&&!Y.manual;u.useEffect(()=>{if(!ke)return;const te=window.setInterval(()=>{const Ie=_e.current;if(Ie.phase!=="countdown"||Ie.manual)return;const Ze=Qe.getState().drafts[Ut(Ie.candidate.oldSessionId)],at=Mk(Ie,{now:Date.now(),viewingOldSession:Ou(fe.current,Ie.candidate.oldSessionId),composerNonEmpty:Du(Ze)});at.effect==="switch"&&n({domain:"chat",sessionId:Ie.candidate.newSessionId}),at.state!==Ie&&re(at.state)},1e3);return()=>window.clearInterval(te)},[ke,n]);const Ge=u.useCallback(()=>{const te=_e.current;if(te.phase!=="countdown")return;const Ie=Pk(te);Ie.effect==="switch"&&n({domain:"chat",sessionId:te.candidate.newSessionId}),re(Ie.state)},[n]),mt=u.useCallback(()=>{re(te=>qk(te))},[]),lt=FH({lastError:p,tokenError:g,stale:x,connectionState:m,reconnectAttempt:b,sessionInvalid:k,canRelogin:T,onRelogin:N,onDismissError:w,onRetry:S,onOpenConnection:()=>n({domain:"gateway"})}),de=Dx(U,q,Ce),qe=(()=>{const te=Hx(de);if(te===null)return null;if(te.domain==="pending"){const Ze=te.sessionId;return{label:a("pending.bar.goPending"),run:()=>X(Ze)}}const Ie=te.sessionId;return{label:a("permission.goTo"),run:()=>H(Ie)}})(),Oe=de.earliest?{id:"pending-requests",tone:"info",text:qe?a("pending.bar.summary",{count:de.count}):`${a("pending.bar.summary",{count:de.count})} · ${a("pending.bar.unresolved")}`,...qe?{actions:[{label:qe.label,onClick:qe.run}]}:{}}:null,ue=(()=>{if(d===void 0)return null;const te={label:a("webBuild.reload"),onClick:()=>window.location.reload()};return d==="building"?{id:"web-build-outdated",tone:"warn",text:a("webBuild.building"),hint:a("webBuild.buildingHint")}:d==="stale"?{id:"web-build-outdated",tone:"warn",text:a("webBuild.stale"),actions:[te]}:d==="disabled"?{id:"web-build-outdated",tone:"warn",text:a("webBuild.autobuildOff")}:{id:"web-build-outdated",tone:"warn",text:a("webBuild.outdated"),actions:[te]}})(),xe=(()=>{if(Y.phase!=="countdown")return null;const{candidate:te,manual:Ie,secondsLeft:Ze}=Y,at=te.name??te.agentId;return{id:"rotate-follow",tone:"info",text:Ie?a("rotateFollow.ready",{name:at}):a("rotateFollow.countdown",{seconds:Ze,name:at}),actions:[{label:a("rotateFollow.switch"),onClick:Ge},{label:a("common.cancel"),onClick:mt}],onDismiss:mt}})(),De=[...lt,...Oe?[Oe]:[],...ue?[ue]:[],...xe?[xe]:[],...c.items.map(te=>({id:`toast-${te.id}`,tone:te.kind,text:te.message,onDismiss:()=>c.dismiss(te.id)}))],Je=Zi(),ht=t.domain==="teams"?"teamList":"sessions",ft=dC(ht),pt=GC(Je,Z),Q=pa({open:ie,onClose:()=>le(!1),enabled:pt==="drawer",returnFocusId:"nav-toggle"}),ye=u.useCallback((te,Ie)=>{A(Ze=>{if(Ie.length===0){if(!Ze.has(te))return Ze;const gt=new Map(Ze);return gt.delete(te),gt}const at=new Map(Ze);return at.set(te,Ie),at})},[]),Te=u.useMemo(()=>[...L.values()].flat(),[L]);u.useEffect(()=>{const te=()=>{const at=fg(localStorage);_n.getState().theme!==at&&_n.setState({theme:at}),Gc(at)},Ie=at=>{at.key===Qi&&te()},Ze=()=>{document.hidden||te()};return window.addEventListener("storage",Ie),window.addEventListener("pageshow",te),document.addEventListener("visibilitychange",Ze),()=>{window.removeEventListener("storage",Ie),window.removeEventListener("pageshow",te),document.removeEventListener("visibilitychange",Ze)}},[]),u.useEffect(()=>{t.domain!=="hub"&&FC()},[_]),u.useEffect(()=>{W.current||ee(Om(Je))},[Je]),u.useEffect(()=>{pt!=="drawer"&&le(!1)},[pt]),u.useEffect(()=>{if(Ne.current){Ne.current=!1;return}if(t.domain==="settings"){z(a("nav.opened",{path:km(t,je)})),le(!1),V(!1);return}window.scrollTo(0,0),ne.current?.scrollTo?.(0,0),ne.current?.focus(),z(a("nav.opened",{path:km(t,je)})),le(!1),t.domain!=="chat"&&V(!1)},[ce]),u.useEffect(()=>h.subscribe(()=>{const te=h.getSnapshot();if(te.version===se.current)return;se.current=te.version;const Ze=[...te.entries.slice(-20)].reverse().find(({event:gt})=>gt.type==="run.completed"||gt.type==="run.failed"||gt.type==="run.cancelled");if(!Ze)return;const at=Ze.event.type==="run.completed"?a("status.completed"):Ze.event.type==="run.failed"?a("status.failed"):a("status.cancelled");z(a("app.announce.run",{id:Ze.event.run_id.slice(0,12),status:at}))}),[h]),u.useEffect(()=>{const te=Ie=>{if(WH(Ie)){Ie.preventDefault(),t.domain==="settings"?s({domain:"chat"}):n({domain:"settings"});return}if(!we){if(BH(Ie)){Ie.preventDefault(),C(""),I(Ze=>!Ze);return}KH(Ie)&&(Ie.preventDefault(),C(">"),I(!0))}};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[we,t.domain,n,s]);const Ue=u.useCallback(()=>O(!0),[]),Be=u.useMemo(()=>QC({hasToken:f,connectionState:m,navigate:n,retry:S,toast:l,openHelp:Ue}),[m,f,e,n,S,l,Ue]),tt=u.useCallback(()=>I(!1),[]),Kt=u.useCallback(te=>{if(te.danger||te.confirm){K(te.confirm?te:{...te,confirm:{title:a("palette.confirm.executeTitle",{label:te.label}),body:a("palette.confirm.executeBody"),confirmLabel:a("palette.confirm.execute")}});return}te.run()},[]),dn=u.useCallback(()=>{le(!1),V(!0)},[]),P=u.useCallback(()=>V(!1),[]),ae=u.useCallback(()=>{V(!1),le(te=>!te)},[]),Le=u.useCallback(()=>{W.current=!0,ee(te=>{const Ie=!te;return Ug(Ie),Ie})},[]);return o.jsx(Ix,{register:ye,children:o.jsxs("div",{className:"flex h-[var(--vvh,100dvh)] min-h-0 flex-col",ref:ft.shellRef,style:iC(ft.layout),children:[o.jsx("button",{type:"button",className:"skip-link",onClick:()=>{ne.current?.focus()},children:a("nav.jumpToMain")}),o.jsx(mN,{route:t,navigate:n,center:o.jsx(Qh,{items:De}),onOpenPalette:()=>{C(""),I(!0)},...t.domain==="chat"?{onToggleSessions:dn,sessionsOpen:F}:pt==="drawer"?{onToggleNav:ae,navOpen:ie}:{}}),o.jsxs("div",{className:"flex min-h-0 flex-auto",children:[o.jsx(UC,{route:t,navigate:n,mode:pt,open:ie,onClose:()=>le(!1),onToggleCollapsed:Le,navRef:Q,panes:ft,counts:M}),o.jsx("main",{id:"main",ref:ne,className:"flex min-h-0 min-w-0 flex-auto flex-col overflow-hidden focus:outline-none",tabIndex:-1,inert:pt==="drawer"&&ie?!0:void 0,children:o.jsx($H,{route:i,navigate:n,chatSessionsOpen:F,onCloseSessions:P,panes:ft})})]}),pt==="drawer"&&ie&&o.jsx("button",{type:"button",className:"drawer-backdrop","aria-label":a("nav.closeNav"),onClick:()=>le(!1)}),o.jsx(eC,{route:t,navigate:n}),o.jsx("div",{className:"sr-only","aria-live":"polite",children:J}),o.jsx(MT,{paletteOpen:E,paletteItems:Be,entities:Te,paletteQuery:$,onClosePalette:tt,onExecutePalette:Kt,helpOpen:D,onCloseHelp:()=>O(!1),pendingAction:me,onClearPending:()=>K(null),onConfirmPending:()=>{const te=me;K(null),te?.run()},settingsRoute:t.domain==="settings"?{focusKey:t.focusKey,query:t.query,category:t.category}:null,onCloseSettings:()=>s({domain:"chat"}),onNavigate:n})]})})}function s$(){return o.jsx(Lx,{children:o.jsx(hj,{children:o.jsx(vj,{children:o.jsx(kj,{children:o.jsxs(AA,{children:[o.jsx(n$,{}),o.jsx(IA,{})]})})})})})}globalThis.__VESSEL_SHARED__={React:cx,ReactDOM:lx,ReactDOMClient:ax,JsxRuntime:ix,PluginSdk:kx};Gc(fg(localStorage));document.documentElement.lang=ss();let vc=wt.getState().config;yy(Se(vc));wt.subscribe(e=>{e.config!==vc&&(vc=e.config,yy(Se(e.config)))});let yc=wt.getState().config;Yh(as(Se(yc),"ui.language"));wt.subscribe(e=>{e.config!==yc&&(yc=e.config,Yh(as(Se(e.config),"ui.language")))});const rx=document.getElementById("root");if(!rx)throw new Error("#root not found");dx.createRoot(rx).render(o.jsx(s$,{}));export{Kb as $,Vo as A,_C as B,ls as C,SC as D,Ve as E,Qu as F,Al as G,a$ as H,yt as I,id as J,MC as K,Ke as L,Wc as M,Fe as N,Gi as O,In as P,ZM as Q,by as R,st as S,py as T,mc as U,_2 as V,tn as W,xt as X,Cn as Y,$e as Z,sa as _,Ae as a,Ri as a0,Qt as b,Lt as c,es as d,Vi as e,Ll as f,l$ as g,Tt as h,Nd as i,Yp as j,i$ as k,xr as l,eg as m,c$ as n,Ev as o,Od as p,mP as q,Se as r,uP as s,a as t,He as u,is as v,ci as w,os as x,fa as y,qi as z};
|