agentroam-runtime-darwin-arm64 0.2.0-preview.71 → 0.2.0-preview.72
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/manifest.json +3 -2
- package/package.json +1 -1
- package/runtime/.next/BUILD_ID +1 -1
- package/runtime/.next/app-build-manifest.json +10 -10
- package/runtime/.next/app-path-routes-manifest.json +1 -1
- package/runtime/.next/build-manifest.json +5 -5
- package/runtime/.next/prerender-manifest.json +1 -1
- package/runtime/.next/required-server-files.json +1 -1
- package/runtime/.next/server/app/_not-found/page.js +1 -1
- package/runtime/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app/_not-found.html +1 -1
- package/runtime/.next/server/app/_not-found.rsc +1 -1
- package/runtime/.next/server/app/api/agent/abort/route.js +1 -1
- package/runtime/.next/server/app/api/agent/answer/route.js +1 -1
- package/runtime/.next/server/app/api/agent/codex-sharing/route.js +1 -1
- package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
- package/runtime/.next/server/app/api/agent/model/route.js +1 -1
- package/runtime/.next/server/app/api/agent/models/route.js +1 -1
- package/runtime/.next/server/app/api/agent/run/route.js +1 -1
- package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
- package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
- package/runtime/.next/server/app/api/agent/stream/route.js +4 -4
- package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
- package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
- package/runtime/.next/server/app/api/auth/verify/route.js +1 -1
- package/runtime/.next/server/app/api/business/route.js +1 -1
- package/runtime/.next/server/app/api/client-logs/route.js +1 -1
- package/runtime/.next/server/app/api/collaboration/route.js +11 -11
- package/runtime/.next/server/app/api/collaboration/route.js.nft.json +1 -1
- package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +3 -3
- package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
- package/runtime/.next/server/app/api/flow-studio/config/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/connect/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/disconnect/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/servers/route.js +1 -1
- package/runtime/.next/server/app/api/memory/[key]/route.js +1 -1
- package/runtime/.next/server/app/api/memory/route.js +1 -1
- package/runtime/.next/server/app/api/messaging/route.js +1 -0
- package/runtime/.next/server/app/api/messaging/route.js.nft.json +1 -0
- package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
- package/runtime/.next/server/app/api/projects/[id]/route.js +1 -1
- package/runtime/.next/server/app/api/projects/check/route.js +1 -1
- package/runtime/.next/server/app/api/projects/directories/route.js +1 -1
- package/runtime/.next/server/app/api/projects/roots/route.js +1 -1
- package/runtime/.next/server/app/api/projects/route.js +1 -1
- package/runtime/.next/server/app/api/push/subscribe/route.js +2 -2
- package/runtime/.next/server/app/api/push/unsubscribe/route.js +3 -3
- package/runtime/.next/server/app/api/push/vapid/route.js +2 -2
- package/runtime/.next/server/app/api/push/vapid.body +1 -1
- package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/stop/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/background-jobs/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +2 -2
- package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/native-goal/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/parallel/route.js +1 -0
- package/runtime/.next/server/app/api/sessions/parallel/route.js.nft.json +1 -0
- package/runtime/.next/server/app/api/sessions/route.js +1 -1
- package/runtime/.next/server/app/api/settings/route.js +1 -1
- package/runtime/.next/server/app/api/skills/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
- package/runtime/.next/server/app/api/tools/route.js +1 -1
- package/runtime/.next/server/app/api/update/check/route.js +1 -1
- package/runtime/.next/server/app/api/update/install/route.js +1 -1
- package/runtime/.next/server/app/api/update/status/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/login/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/logout/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/revoke-all/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/setup/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/status/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/bootstrap/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/computer-settings/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/computers/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/device-state/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/history/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/preferences/route.js +1 -1
- package/runtime/.next/server/app/web/page.js +13 -21
- package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app-paths-manifest.json +39 -37
- package/runtime/.next/server/chunks/1614.js +1 -1
- package/runtime/.next/server/chunks/1973.js +1 -0
- package/runtime/.next/server/chunks/5303.js +2 -2
- package/runtime/.next/server/chunks/6977.js +1 -1
- package/runtime/.next/server/chunks/732.js +1 -1
- package/runtime/.next/server/chunks/7519.js +3 -3
- package/runtime/.next/server/middleware-build-manifest.js +1 -1
- package/runtime/.next/server/pages/404.html +1 -1
- package/runtime/.next/server/pages/500.html +1 -1
- package/runtime/.next/server/server-reference-manifest.json +1 -1
- package/runtime/.next/static/chunks/50-0b6604ece6278dc2.js +1 -0
- package/runtime/.next/static/chunks/app/web/{error-6470e38a145095eb.js → error-36b287ca40eab041.js} +1 -1
- package/runtime/.next/static/chunks/app/web/layout-62386960d8601cc2.js +1 -0
- package/runtime/.next/static/chunks/app/web/page-6b37d8153e607928.js +1 -0
- package/runtime/.next/static/chunks/{main-0de4062ff39c4193.js → main-94a733696db11b91.js} +1 -1
- package/runtime/.next/static/chunks/{main-app-41078426602904fd.js → main-app-07b9ccbb642d9b9d.js} +1 -1
- package/runtime/.next/static/css/50f255aa50ec70d1.css +1 -0
- package/runtime/lib/browser-live/viewer-frame-flow.mjs +10 -2
- package/runtime/lib/browser-live/viewer-video-flow.mjs +11 -0
- package/runtime/lib/remote-control/application/compound-video-session.mjs +383 -0
- package/runtime/lib/remote-control/application/paced-video-sender.mjs +261 -0
- package/runtime/lib/remote-control/application/remote-hover-dispatch.mjs +26 -0
- package/runtime/lib/remote-control/application/remote-video-session.mjs +232 -37
- package/runtime/lib/remote-control/helper-manager.mjs +5 -1
- package/runtime/lib/remote-control/infrastructure/compound-compression.mjs +20 -0
- package/runtime/lib/remote-control/infrastructure/native-compound-video.mjs +44 -0
- package/runtime/lib/remote-control/infrastructure/native-video-encoder.mjs +62 -8
- package/runtime/lib/remote-control/infrastructure/werift-video-feedback.mjs +98 -0
- package/runtime/lib/remote-control/infrastructure/werift-video-recovery.mjs +108 -0
- package/runtime/lib/remote-control/infrastructure/werift-video-transport.mjs +310 -24
- package/runtime/lib/remote-control/remote-authorization.mjs +55 -12
- package/runtime/lib/remote-control/remote-video-signal.mjs +25 -1
- package/runtime/lib/remote-control/webrtc-video.mjs +3 -1
- package/runtime/lib/remote-control/windows-helper.mjs +11 -2
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/Resources/agentroam-component.json +1 -1
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/native/Support.noindex/WeComSendBridge.app/Contents/Info.plist +13 -0
- package/runtime/native/Support.noindex/WeComSendBridge.app/Contents/MacOS/NativeAXBridge +0 -0
- package/runtime/native/Support.noindex/WeComSendBridge.app/Contents/Resources/agentroam-component.json +4 -0
- package/runtime/native/Support.noindex/WeComSendBridge.app/Contents/_CodeSignature/CodeResources +128 -0
- package/runtime/node_modules/.package-lock.json +26 -20
- package/runtime/node_modules/@agent/core/dist/index.js +2775 -154
- package/runtime/node_modules/@agent/messaging/dist/assets/wecom/NativeAXBridge.swift +240 -0
- package/runtime/node_modules/@agent/messaging/dist/assets/wecom/codec.py +133 -0
- package/runtime/node_modules/@agent/messaging/dist/assets/wecom/native_sender.py +445 -0
- package/runtime/node_modules/@agent/messaging/dist/assets/wecom/reader.py +309 -0
- package/runtime/node_modules/@agent/messaging/dist/index.js +1219 -0
- package/runtime/node_modules/@agent/messaging/package.json +7 -0
- package/runtime/node_modules/@agent/native-runtime/dist/index.js +6299 -808
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +88 -82
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +61 -61
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-8zdh6hy9.mjs +45 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-b5da77cd.mjs +34 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-f2yzhw4m.mjs +18 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-j29a9c1a.mjs +17 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +11 -11
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +33 -25
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +37 -29
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/package.json +14 -14
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +84 -81
- package/runtime/node_modules/caniuse-lite/data/agents.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/browserVersions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/aac.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/abortcontroller.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ac3-ec3.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/accelerometer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/addeventlistener.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/alternate-stylesheet.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ambient-light.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/apng.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/array-find-index.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/array-find.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/array-flat.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/array-includes.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/arrow-functions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/asmjs.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/async-clipboard.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/async-functions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/atob-btoa.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/audio-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/audio.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/audiotracks.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/autofocus.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/auxclick.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/av1.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/avif.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/background-attachment.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/background-clip-text.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/background-img-opts.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/background-position-x-y.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/background-repeat-round-space.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/background-sync.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/battery-status.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/beacon.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/beforeafterprint.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/bigint.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/blobbuilder.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/bloburls.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/border-image.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/border-radius.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/broadcastchannel.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/brotli.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/calc.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/canvas-blending.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/canvas-text.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/canvas.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ch-unit.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/chacha20-poly1305.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/channel-messaging.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/childnode-remove.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/classlist.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/client-hints-dpr-width-viewport.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/clipboard.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/colr-v1.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/colr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/comparedocumentposition.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/console-basic.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/console-time.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/const.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/constraint-validation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/contenteditable.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/contentsecuritypolicy.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/contentsecuritypolicy2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/cookie-store-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/cors.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/createimagebitmap.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/credential-management.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/cross-document-view-transitions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/cryptography.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-all.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-anchor-positioning.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-animation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-any-link.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-appearance.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-at-counter-style.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-autofill.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-backdrop-filter.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-background-offsets.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-backgroundblendmode.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-boxdecorationbreak.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-boxshadow.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-canvas.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-caret-color.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-cascade-layers.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-cascade-scope.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-case-insensitive.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-clip-path.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-color-adjust.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-color-function.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-conic-gradients.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-container-queries-style.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-container-queries.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-container-query-units.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-containment.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-content-visibility.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-counters.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-crisp-edges.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-cross-fade.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-default-pseudo.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-descendant-gtgt.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-deviceadaptation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-dir-pseudo.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-display-contents.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-element-function.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-env-function.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-exclusions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-featurequeries.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-file-selector-button.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-filter-function.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-filters.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-first-letter.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-first-line.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-fixed.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-focus-visible.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-focus-within.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-font-palette.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-font-rendering-controls.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-font-stretch.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-gencontent.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-gradients.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-grid-animation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-grid-lanes.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-grid.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-hanging-punctuation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-has.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-hyphens.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-if.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-image-orientation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-image-set.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-in-out-of-range.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-indeterminate-pseudo.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-initial-letter.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-initial-value.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-lch-lab.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-letter-spacing.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-line-clamp.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-logical-props.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-marker-pseudo.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-masks.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-matches-pseudo.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-math-functions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-media-interaction.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-media-range-syntax.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-media-resolution.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-media-scripting.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-mediaqueries.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-mixblendmode.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-module-scripts.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-motion-paths.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-namespaces.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-nesting.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-not-sel-list.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-nth-child-of.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-opacity.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-optional-pseudo.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-overflow-anchor.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-overflow-overlay.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-overflow.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-overscroll-behavior.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-page-break.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-paged-media.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-paint-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-placeholder-shown.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-placeholder.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-print-color-adjust.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-read-only-write.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-rebeccapurple.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-reflections.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-regions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-relative-colors.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-repeating-gradients.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-resize.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-revert-value.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-rrggbbaa.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-scroll-behavior.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-scrollbar.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-sel2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-sel3.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-selection.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-shapes.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-snappoints.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-sticky.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-subgrid.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-supports-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-table.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-text-align-last.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-text-box-trim.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-text-indent.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-text-justify.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-text-orientation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-text-spacing.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-text-wrap-balance.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-textshadow.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-touch-action.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-transitions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-unicode-bidi.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-unset-value.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-variables.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-when-else.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-widows-orphans.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-width-stretch.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-writing-mode.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css-zoom.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css3-attr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css3-boxsizing.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css3-colors.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css3-cursors-grab.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css3-cursors-newer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css3-cursors.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/css3-tabsize.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/currentcolor.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/custom-elements.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/custom-elementsv1.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/customevent.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/customizable-select.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/datalist.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dataset.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/datauri.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/date-tolocaledatestring.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/declarative-shadow-dom.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/decorators.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/details.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/deviceorientation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/devicepixelratio.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dialog.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dispatchevent.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dnssec.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/do-not-track.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/document-currentscript.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/document-evaluate-xpath.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/document-execcommand.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/document-policy.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/document-scrollingelement.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/documenthead.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dom-manip-convenience.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dom-range.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/domcontentloaded.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dommatrix.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/download.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/dragndrop.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/element-closest.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/element-from-point.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/element-scroll-methods.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/eme.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/eot.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es5.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es6-class.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es6-generators.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es6-module-dynamic-import.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es6-module.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es6-number.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es6-string-includes.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/es6.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/eventsource.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/extended-system-fonts.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/feature-policy.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/fetch.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/fieldset-disabled.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/fileapi.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/filereader.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/filereadersync.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/filesystem.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/flac.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/flexbox-gap.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/flexbox.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/flow-root.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/focusin-focusout-events.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-family-system-ui.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-feature.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-kerning.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-loading.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-size-adjust.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-smooth.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-unicode-range.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-variant-alternates.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/font-variant-numeric.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/fontface.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/form-attribute.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/form-submit-attributes.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/form-validation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/forms.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/fullscreen.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/gamepad.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/geolocation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/getboundingclientrect.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/getcomputedstyle.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/getelementsbyclassname.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/getrandomvalues.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/gyroscope.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/hardwareconcurrency.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/hashchange.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/heif.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/hevc.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/hidden.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/high-resolution-time.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/history.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/html-media-capture.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/html5semantic.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/http-live-streaming.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/http2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/http3.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/iframe-sandbox.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/iframe-seamless.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/iframe-srcdoc.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/imagecapture.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ime.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/img-naturalwidth-naturalheight.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/import-maps.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/imports.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/indeterminate-checkbox.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/indexeddb.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/indexeddb2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/inline-block.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/innertext.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-autocomplete-onoff.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-color.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-datetime.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-email-tel-url.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-event.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-file-accept.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-file-directory.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-file-multiple.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-inputmode.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-minlength.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-number.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-pattern.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-placeholder.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-range.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-search.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/input-selection.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/insert-adjacent.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/insertadjacenthtml.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/internationalization.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/intersectionobserver-v2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/intersectionobserver.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/intl-pluralrules.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/intrinsic-width.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/jpeg2000.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/jpegxl.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/jpegxr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/js-regexp-lookbehind.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/json.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/justify-content-space-evenly.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/kerning-pairs-ligatures.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/keyboardevent-charcode.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/keyboardevent-code.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/keyboardevent-getmodifierstate.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/keyboardevent-key.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/keyboardevent-location.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/keyboardevent-which.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/lazyload.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/let.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-icon-png.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-icon-svg.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-rel-dns-prefetch.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-rel-modulepreload.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-rel-preconnect.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-rel-prefetch.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-rel-preload.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/link-rel-prerender.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/loading-lazy-attr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/loading-lazy-media.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/localecompare.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/magnetometer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/matchesselector.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/matchmedia.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mathml.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/maxlength.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-css-backdrop-pseudo-element.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-css-unicode-bidi-isolate-override.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-css-unicode-bidi-isolate.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-css-unicode-bidi-plaintext.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-text-decoration-color.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-text-decoration-line.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-text-decoration-shorthand.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mdn-text-decoration-style.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/media-fragments.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mediacapture-fromelement.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mediarecorder.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mediasource.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/menu.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/meta-theme-color.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/meter.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/midi.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/minmaxwh.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mp3.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mpeg-dash.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mpeg4.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/multibackgrounds.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/multicolumn.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mutation-events.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/mutationobserver.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/namevalue-storage.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/native-filesystem-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/nav-timing.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/netinfo.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/notifications.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/object-entries.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/object-fit.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/object-observe.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/object-values.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/objectrtc.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/offline-apps.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/offscreencanvas.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ogg-vorbis.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ogv.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ol-reversed.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/once-event-listener.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/online-status.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/opus.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/orientation-sensor.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/outline.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/pad-start-end.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/page-transition-events.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/pagevisibility.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/passive-event-listener.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/passkeys.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/passwordrules.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/path2d.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/payment-request.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/pdf-viewer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/permissions-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/permissions-policy.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/picture-in-picture.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/picture.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ping.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/png-alpha.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/pointer-events.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/pointer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/pointerlock.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/portals.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/prefers-color-scheme.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/prefers-reduced-motion.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/progress.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/promise-finally.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/promises.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/proximity.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/proxy.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/publickeypinning.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/push-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/queryselector.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/readonly-attr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/referrer-policy.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/registerprotocolhandler.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/rel-noopener.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/rel-noreferrer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/rellist.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/rem.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/requestanimationframe.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/requestidlecallback.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/resizeobserver.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/resource-timing.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/rest-parameters.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/rtcpeerconnection.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ruby.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/run-in.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/same-site-cookie-attribute.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/screen-orientation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/script-async.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/script-defer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/scrollintoview.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/scrollintoviewifneeded.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/sdch.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/selection-api.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/server-timing.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/serviceworkers.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/setimmediate.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/shadowdom.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/shadowdomv1.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/sharedarraybuffer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/sharedworkers.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/sni.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/spdy.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/speech-recognition.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/speech-synthesis.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/spellcheck-attribute.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/sql-storage.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/srcset.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/stream.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/streams.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/stricttransportsecurity.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/style-scoped.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/subresource-bundling.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/subresource-integrity.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-css.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-filters.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-fonts.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-fragment.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-html.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-html5.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-img.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg-smil.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/svg.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/sxg.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/tabindex-attr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/template-literals.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/template.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/temporal.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/testfeat.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/text-decoration.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/text-emphasis.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/text-overflow.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/text-size-adjust.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/text-stroke.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/textcontent.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/textencoder.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/tls1-1.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/tls1-2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/tls1-3.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/touch.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/transforms2d.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/transforms3d.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/trusted-types.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/ttf.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/typedarrays.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/u2f.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/unhandledrejection.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/upgradeinsecurerequests.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/url-scroll-to-text-fragment.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/url.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/urlsearchparams.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/use-strict.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/user-select-none.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/user-timing.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/variable-fonts.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/vector-effect.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/vibration.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/video.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/videotracks.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/view-transitions.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/viewport-unit-variants.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/viewport-units.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wai-aria.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wake-lock.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-bigint.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-bulk-memory.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-extended-const.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-gc.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-multi-memory.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-multi-value.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-mutable-globals.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-nontrapping-fptoint.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-reference-types.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-relaxed-simd.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-signext.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-simd.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-tail-calls.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm-threads.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wasm.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wav.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wbr-element.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/web-animation.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/web-app-manifest.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/web-bluetooth.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/web-serial.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/web-share.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webauthn.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webcodecs.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webgl.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webgl2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webgpu.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webhid.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webkit-user-drag.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webm.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webnfc.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webp.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/websockets.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webtransport.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webusb.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webvr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webvtt.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webworkers.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/webxr.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/will-change.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/woff.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/woff2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/word-break.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/wordwrap.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/x-doc-messaging.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/x-frame-options.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/xhr2.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/xhtml.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/xhtmlsmil.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/xml-serializer.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/features/zstd.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AD.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AF.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AX.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/AZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BB.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BD.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BF.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BJ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/BZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CD.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CF.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CV.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CX.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/CZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/DE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/DJ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/DK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/DM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/DO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/DZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/EC.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/EE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/EG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ER.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ES.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ET.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/FI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/FJ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/FK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/FM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/FO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/FR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GB.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GD.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GF.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GP.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GQ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/GY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/HK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/HN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/HR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/HT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/HU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ID.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IQ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/IT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/JE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/JM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/JO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/JP.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KP.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/KZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LB.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LC.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LV.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/LY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MC.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MD.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ME.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ML.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MP.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MQ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MV.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MX.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/MZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NC.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NF.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NP.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/NZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/OM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PF.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/PY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/QA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/RE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/RO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/RS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/RU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/RW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SB.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SC.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SD.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SK.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ST.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SV.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/SZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TC.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TD.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TH.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TJ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TL.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TO.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TR.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TV.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/TZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/UA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/UG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/US.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/UY.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/UZ.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/VA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/VC.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/VE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/VG.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/VI.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/VN.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/VU.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/WF.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/WS.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/YE.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/YT.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ZA.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ZM.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/ZW.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-af.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-an.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-as.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-eu.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-na.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-oc.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-sa.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/regions/alt-ww.js +1 -1
- package/runtime/node_modules/caniuse-lite/data/versionGroups.js +1 -1
- package/runtime/node_modules/caniuse-lite/package.json +1 -1
- package/runtime/node_modules/mediabunny/README.md +1 -5
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +312 -260
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +12 -12
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +12 -12
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +312 -260
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +312 -260
- package/runtime/node_modules/mediabunny/dist/modules/src/aes.js +53 -40
- package/runtime/node_modules/mediabunny/dist/modules/src/conversion.js +38 -10
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-boxes.js +3 -2
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-demuxer.js +78 -78
- package/runtime/node_modules/mediabunny/dist/modules/src/matroska/matroska-demuxer.js +109 -110
- package/runtime/node_modules/mediabunny/dist/modules/src/media-source.js +23 -11
- package/runtime/node_modules/mediabunny/dist/modules/src/muxer.js +41 -22
- package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/version.js +1 -1
- package/runtime/node_modules/mediabunny/package.json +14 -6
- package/runtime/node_modules/mediabunny/src/aes.ts +52 -39
- package/runtime/node_modules/mediabunny/src/conversion.ts +49 -10
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-boxes.ts +3 -1
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-demuxer.ts +88 -96
- package/runtime/node_modules/mediabunny/src/matroska/matroska-demuxer.ts +137 -146
- package/runtime/node_modules/mediabunny/src/media-source.ts +24 -9
- package/runtime/node_modules/mediabunny/src/muxer.ts +52 -33
- package/runtime/node_modules/mediabunny/src/version.ts +1 -1
- package/runtime/node_modules/ws/README.md +2 -3
- package/runtime/node_modules/ws/lib/receiver.js +8 -0
- package/runtime/node_modules/ws/lib/websocket.js +20 -6
- package/runtime/node_modules/ws/package.json +1 -1
- package/runtime/node_modules/zstd-codec/index.js +4 -0
- package/runtime/node_modules/zstd-codec/lib/constants.js +2 -0
- package/runtime/node_modules/zstd-codec/lib/helpers.js +60 -0
- package/runtime/node_modules/zstd-codec/lib/module.js +27 -0
- package/runtime/node_modules/zstd-codec/lib/zstd-codec-binding-wasm.js +21 -0
- package/runtime/node_modules/zstd-codec/lib/zstd-codec-binding.js +63 -0
- package/runtime/node_modules/zstd-codec/lib/zstd-codec.js +363 -0
- package/runtime/node_modules/zstd-codec/lib/zstd-stream.js +116 -0
- package/runtime/node_modules/zstd-codec/package.json +29 -0
- package/runtime/package-lock.json +52 -45
- package/runtime/package.json +1 -0
- package/runtime/server.js +1 -1
- package/runtime/webapp/dist/assets/AiHubPane-DBuhzcId.js +1 -0
- package/runtime/webapp/dist/assets/App-CrZstnCH.css +1 -0
- package/runtime/webapp/dist/assets/App-D3-qxUjs.js +187 -0
- package/runtime/webapp/dist/assets/BrowserLivePanel-BywwOAML.js +76 -0
- package/runtime/webapp/dist/assets/CollaborationDashboard-DQeiZyu9.js +1 -0
- package/runtime/webapp/dist/assets/CollaborationPage-CGymkv8f.js +16 -0
- package/runtime/webapp/dist/assets/{FilePreview-BjbfWw2s.js → FilePreview-CkY_jNql.js} +5 -5
- package/runtime/webapp/dist/assets/FileTree-W85iiqhO.js +11 -0
- package/runtime/webapp/dist/assets/FlowStudioPane-Ccp0FhYn.js +5 -0
- package/runtime/webapp/dist/assets/MessagingBridge-D_cArR8-.js +6 -0
- package/runtime/webapp/dist/assets/MessagingPage-BIgDwGgU.js +7 -0
- package/runtime/webapp/dist/assets/MessagingPage-CpRafjqY.css +1 -0
- package/runtime/webapp/dist/assets/RemoteDesktopPage-Di31a6s4.js +1 -0
- package/runtime/webapp/dist/assets/{smartphone-D7oS3YTz.js → RunningSessionsIcon-BbgfV3Y9.js} +8 -18
- package/runtime/webapp/dist/assets/SessionDashboard-D3n4eFut.css +1 -0
- package/runtime/webapp/dist/assets/SessionDashboard-a7HETCwZ.js +16 -0
- package/runtime/webapp/dist/assets/{SessionDashboardBridge-DYsMZhuH.js → SessionDashboardBridge-DEUcW6SI.js} +1 -1
- package/runtime/webapp/dist/assets/{TerminalPane-CPOiBcye.js → TerminalPane-BLqkE0Sr.js} +2 -2
- package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-DCFFqJUU.js → abnfDiagram-VCTEODGH-DeYUTKWn.js} +1 -1
- package/runtime/webapp/dist/assets/arc-Fb_TLw7m.js +1 -0
- package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-DoK3A_n1.js → architectureDiagram-5GKGNRK7-CuFeRT7v.js} +1 -1
- package/runtime/webapp/dist/assets/arrow-left-ChO37N0V.js +6 -0
- package/runtime/webapp/dist/assets/{arrow-right-B0uCZ1Pd.js → arrow-right-CBoNjLZc.js} +1 -1
- package/runtime/webapp/dist/assets/{artifact-links-nzx7joYs.js → artifact-links-DPEFlv87.js} +1 -1
- package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-DgXszyX7.js → blockDiagram-I7D4REHJ-CSQFiZW1.js} +1 -1
- package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-q7KO4v1Q.js → c4Diagram-7LVT6UL2-Dp0yNsZN.js} +1 -1
- package/runtime/webapp/dist/assets/channel-CcOPsanj.js +1 -0
- package/runtime/webapp/dist/assets/chevron-down-DqV6YJGE.js +6 -0
- package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-CH8lOKmL.js → chunk-2Q5K7J3B-HGRodfIv.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-DwP7xEWd.js → chunk-5VM5RSS4-CBrQNVFD.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-F27PBJKO-BV3TTaxI.js → chunk-F27PBJKO-DB6uGYpD.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-BbaiG4yG.js → chunk-IMKFNOWR-Dedjjkdt.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-Dv9x27hI.js → chunk-JWPE2WC7-CFqPSTPh.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-Uk-GiSLP.js → chunk-POPQ4Y6H-3acvfPpy.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-SVP7TREG-lFcKEwyL.js → chunk-SVP7TREG-Bn9tMxLG.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-TICWLB2K-DFZALWPC.js → chunk-TICWLB2K-BjPHa9Ep.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-8jLPZkMb.js → chunk-XXDRQBXY-pSIpAtkj.js} +1 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-De9Vn3qI.js +1 -0
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-De9Vn3qI.js +1 -0
- package/runtime/webapp/dist/assets/clipboard-BvwmdR4z.js +1 -0
- package/runtime/webapp/dist/assets/{codeSyntax-Dgv0FfoZ.js → codeSyntax-Bs__ElW1.js} +3 -3
- package/runtime/webapp/dist/assets/collaboration-DkVTQ-wS.css +1 -0
- package/runtime/webapp/dist/assets/{collaboration-f29NaKWy.js → collaboration-xcnZxf7i.js} +2 -2
- package/runtime/webapp/dist/assets/copilot-7BoBRmFo.png +0 -0
- package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-86P-lxD4.js → cose-bilkent-JH36ORCC-Cc1ea8TO.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-mtRVdchl.js → cynefin-OW5HDTMX-B2IeHhVa.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-DhqAIoq6.js → cynefinDiagram-5FMLGOSQ-BeZhQnWx.js} +1 -1
- package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-DD9olCTy.js → dagre-GXQ25YYZ-DF08UpVJ.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-CLGKipLp.js → diagram-S7CK7UJ4-Cx_tPRJp.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-Dm7uGpUO.js → diagram-UQ7AKVKN-Cb6fFvJt.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-OZYfwAth.js → diagram-VSXAHHWV-CvuweBru.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VX7I27RA-BpQqNFxQ.js → diagram-VX7I27RA-BYouVdoe.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-BrWsMYCU.js → diagram-Z3DM3KII-DRBjsxYw.js} +1 -1
- package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-BRH-K-J7.js → ebnfDiagram-PWID7BFC-CxHOPzwg.js} +1 -1
- package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-BDNSVr6H.js → erDiagram-RLTQ6QDP-tUK9K8ZD.js} +1 -1
- package/runtime/webapp/dist/assets/external-link-DpecT7Vm.js +6 -0
- package/runtime/webapp/dist/assets/{file-types-XHMBkbNr.js → file-types-CfFmgvNi.js} +4 -9
- package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-DseLK02Y.js → flowDiagram-HODETNUW-BFd8shzR.js} +1 -1
- package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-v_uNZx1g.js → ganttDiagram-EL5Y4UJY-Dt3qJ3nR.js} +1 -1
- package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-EdvVYEMk.js → gitGraphDiagram-WWUBYQGX-L22kw422.js} +1 -1
- package/runtime/webapp/dist/assets/image-plus-Bzr6FXFm.js +6 -0
- package/runtime/webapp/dist/assets/index-C165MF0E.js +489 -0
- package/runtime/webapp/dist/assets/index-IYQjHlQx.css +1 -0
- package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-Ck26xp1i.js → infoDiagram-27XIBGKW-DBrWW4hh.js} +1 -1
- package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-DGnOVObq.js → ishikawaDiagram-5VMMS53U-BiQERurn.js} +1 -1
- package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-S7oKAQs8.js → journeyDiagram-3NMN7TZE-CbuOAsvy.js} +1 -1
- package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-DcrYA4VY.js → kanban-definition-UXKFOSKX-BS0cpYtD.js} +1 -1
- package/runtime/webapp/dist/assets/{layout-CYHINS_I.js → layout-C6lzLyIZ.js} +1 -1
- package/runtime/webapp/dist/assets/{linear-B-lEfto_.js → linear-DOnDPVCl.js} +1 -1
- package/runtime/webapp/dist/assets/{loader-circle-DMWQZenY.js → loader-circle-DzxGeGeP.js} +1 -1
- package/runtime/webapp/dist/assets/{mermaid.core-B3fzlEw9.js → mermaid.core-CIbk74HW.js} +6 -6
- package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-wJkCh55V.js → mindmap-definition-YA3MSWOX-BXA3aIva.js} +1 -1
- package/runtime/webapp/dist/assets/page-oP1ftgSe.js +91 -0
- package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-H4uk2OUO.js → pegDiagram-XKGWAZYB-oUTq5zGX.js} +1 -1
- package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-yLnU_MCb.js → pieDiagram-E7YTZNPT-CES_HFyS.js} +1 -1
- package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-DyD93O4P.js → quadrantDiagram-AXDQQJYC-BDJl9Tah.js} +1 -1
- package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-DZ833xbw.js → railroadDiagram-O6MQD6OU-BCu1VCKA.js} +1 -1
- package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-DJV4nGui.js → requirementDiagram-BXWQKSXE-CqUIqsRU.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-ccw-CKqo62Ra.js → rotate-ccw-Bjr9jTxM.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-cw-D-M3ZDSa.js → rotate-cw-A1YTnj9Q.js} +1 -1
- package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-BeOYMFTR.js → sankeyDiagram-P5KCCOFB-DaveIjpG.js} +1 -1
- package/runtime/webapp/dist/assets/search-rB9Vl5Kd.js +6 -0
- package/runtime/webapp/dist/assets/{send-LvtpJMkk.js → send-BEl9srBG.js} +1 -1
- package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-BBcgqG33.js → sequenceDiagram-WJ2MYXX4-C7zRgFw8.js} +1 -1
- package/runtime/webapp/dist/assets/{shield-check-SeEkz1Nd.js → shield-check-C79GaqpX.js} +1 -1
- package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-B0GJZjw0.js → sizeCapture-INFHLROL-BKOrYnP1.js} +1 -1
- package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-BmSvB3vd.js → stateDiagram-D77RDMKH-Cz_WH93D.js} +1 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-Dw9aybAU.js +1 -0
- package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-BAZdMUD6.js → swimlanes-42K2YHIH-CbDMTwgn.js} +1 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-CZrm7vi4.js +8 -0
- package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-BSgVFMNG.js → timeline-definition-24CTP7MA-CanMvfCK.js} +1 -1
- package/runtime/webapp/dist/assets/{trash-2-CHYPyYDY.js → trash-2-RnFgAyKW.js} +5 -10
- package/runtime/webapp/dist/assets/types-DguAd3Ud.js +6 -0
- package/runtime/webapp/dist/assets/use-error-notice-CAYVDT8Z.css +1 -0
- package/runtime/webapp/dist/assets/use-error-notice-_MLy2aPZ.js +11 -0
- package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-C-brvbkB.js → vennDiagram-4TSXK5OY-CR-V0-y3.js} +1 -1
- package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-CeqqVR1s.js → wardleyDiagram-VM6X3IG4-CjTtvx6s.js} +1 -1
- package/runtime/webapp/dist/assets/{web-aLPH3xFw.js → web-DPag1EjS.js} +1 -1
- package/runtime/webapp/dist/assets/{web-Dzd7NW_F.js → web-DedGjdA8.js} +1 -1
- package/runtime/webapp/dist/assets/x-Bx8qOEL4.js +6 -0
- package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-mPizwpXM.js → xychartDiagram-S5SC5T6Z-D2959gYR.js} +1 -1
- package/runtime/webapp/dist/index.html +2 -2
- package/runtime/ws-server.mjs +19 -5
- package/runtime/.next/static/chunks/113-b9b8fc001b7cd590.js +0 -1
- package/runtime/.next/static/chunks/app/web/layout-ecfb758d244808a4.js +0 -1
- package/runtime/.next/static/chunks/app/web/page-27145471bd2171c2.js +0 -1
- package/runtime/.next/static/css/afa521adcec25f87.css +0 -1
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-07pvccxf.mjs +0 -43
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-0rjxgk9e.mjs +0 -18
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-fpeb751h.mjs +0 -33
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-jf0rbr11.mjs +0 -17
- package/runtime/webapp/dist/assets/AiHubPane-Cp_tNJNR.js +0 -6
- package/runtime/webapp/dist/assets/App-Cs8U1u-X.js +0 -175
- package/runtime/webapp/dist/assets/App-QWoPBMW0.css +0 -1
- package/runtime/webapp/dist/assets/BrowserLivePanel-B1zYRS_7.js +0 -76
- package/runtime/webapp/dist/assets/CollaborationDashboard-DIVa26zk.js +0 -1
- package/runtime/webapp/dist/assets/CollaborationPage-Fsvkw8ZM.js +0 -16
- package/runtime/webapp/dist/assets/FileTree-C6gg9p4m.js +0 -11
- package/runtime/webapp/dist/assets/FlowStudioPane-CCuxZBVJ.js +0 -5
- package/runtime/webapp/dist/assets/RemoteDesktopPage-DpoYuKhA.js +0 -1
- package/runtime/webapp/dist/assets/SessionDashboard-CAoW5-uN.css +0 -1
- package/runtime/webapp/dist/assets/SessionDashboard-DOWjUIY1.js +0 -26
- package/runtime/webapp/dist/assets/arc-vjNW9DYV.js +0 -1
- package/runtime/webapp/dist/assets/channel-CsnhvX8S.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-Bed40USf.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-Bed40USf.js +0 -1
- package/runtime/webapp/dist/assets/clipboard-BteN9-AC.js +0 -6
- package/runtime/webapp/dist/assets/collaboration-BiaML8jX.css +0 -1
- package/runtime/webapp/dist/assets/crown-y1qmM0NZ.js +0 -6
- package/runtime/webapp/dist/assets/index--zKd3rTs.js +0 -507
- package/runtime/webapp/dist/assets/index-D0gsdpeQ.css +0 -1
- package/runtime/webapp/dist/assets/page-Cc56wyOt.js +0 -91
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-CQ9wpJCJ.js +0 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-8XTJp3Fr.js +0 -8
- /package/runtime/.next/static/{mGwTFWK2dzlY3HjsjZGzh → ngVhkJylacc9Set69K3lG}/_buildManifest.js +0 -0
- /package/runtime/.next/static/{mGwTFWK2dzlY3HjsjZGzh → ngVhkJylacc9Set69K3lG}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-CIbk74HW.js","./index-C165MF0E.js","./index-IYQjHlQx.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as st,a8 as pf,j as t,r as c,a9 as qt,A as _r,aa as Al,ab as cu,ac as ff,ad as du,d as Wt,h as Dt,a7 as gf,ae as hf,R as go,af as mf,u as xt,U as xf,L as bf,f as ns,g as _l,ag as Wc,ah as yf,ai as vf,i as fl,e as gl,aj as Ua,ak as uu,F as wf,al as jf,am as Sf,an as kf}from"./index-C165MF0E.js";import{C as ua}from"./chevron-down-DqV6YJGE.js";import{i as If,d as Ml}from"./file-types-CfFmgvNi.js";import{F as pu,C as Ii,P as Ll,T as Bs}from"./trash-2-RnFgAyKW.js";import{C as er,i as zl,r as pa,p as Cf}from"./artifact-links-DPEFlv87.js";import{S as no,M as fu,p as Ef,n as $c,a as Rf,b as Nf,C as Tf,H as Af}from"./CollaborationPage-CGymkv8f.js";import{c as ji}from"./clipboard-BvwmdR4z.js";import{X as tr}from"./x-Bx8qOEL4.js";import{C as Si,a as _f,G as Mf,S as Lf,R as zf,M as Pf,b as Bc,P as Df}from"./RunningSessionsIcon-BbgfV3Y9.js";import{Z as Wf,a as $f,B as Bf,V as Of,M as Ff}from"./BrowserLivePanel-BywwOAML.js";import{R as qf}from"./rotate-ccw-Bjr9jTxM.js";import{D as gu,F as Uf}from"./FilePreview-CkY_jNql.js";import{L as bt}from"./loader-circle-DzxGeGeP.js";import{S as fa}from"./search-rB9Vl5Kd.js";import{I as Hf,a as na,b as Gf}from"./MessagingBridge-D_cArR8-.js";import{a as hu,p as mu}from"./use-error-notice-_MLy2aPZ.js";import{c as lo,U as Vf}from"./collaboration-xcnZxf7i.js";import{C as Qf,a as Kf,H as Jf}from"./CollaborationDashboard-DQeiZyu9.js";import{D as Yf,S as Xf}from"./SessionDashboard-a7HETCwZ.js";import Zf from"./MessagingPage-BIgDwGgU.js";import{S as eg,c as Vi,a as tg,r as Oc}from"./SessionDashboardBridge-DEUcW6SI.js";import{a as ng,f as rg}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{A as xu}from"./arrow-left-ChO37N0V.js";import{S as sg}from"./send-BEl9srBG.js";import{R as ig}from"./rotate-cw-A1YTnj9Q.js";import og from"./FileTree-W85iiqhO.js";import"./shield-check-C79GaqpX.js";import"./types-DguAd3Ud.js";import"./image-plus-Bzr6FXFm.js";import"./external-link-DpecT7Vm.js";import"./arrow-right-CBoNjLZc.js";/**
|
|
3
|
+
* @license lucide-react v0.468.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const ag=st("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/**
|
|
8
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const Fc=st("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/**
|
|
13
|
+
* @license lucide-react v0.468.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const lg=st("Bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);/**
|
|
18
|
+
* @license lucide-react v0.468.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const cg=st("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/**
|
|
23
|
+
* @license lucide-react v0.468.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const Pl=st("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
|
|
28
|
+
* @license lucide-react v0.468.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const Ci=st("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
33
|
+
* @license lucide-react v0.468.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const dg=st("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
38
|
+
* @license lucide-react v0.468.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const ug=st("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
43
|
+
* @license lucide-react v0.468.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const pg=st("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
48
|
+
* @license lucide-react v0.468.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const qc=st("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/**
|
|
53
|
+
* @license lucide-react v0.468.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const fg=st("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/**
|
|
58
|
+
* @license lucide-react v0.468.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const gg=st("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
|
63
|
+
* @license lucide-react v0.468.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const hg=st("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
|
|
68
|
+
* @license lucide-react v0.468.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const mg=st("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
73
|
+
* @license lucide-react v0.468.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const xg=st("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
78
|
+
* @license lucide-react v0.468.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const bg=st("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
|
|
83
|
+
* @license lucide-react v0.468.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const yg=st("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/**
|
|
88
|
+
* @license lucide-react v0.468.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const vg=st("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/**
|
|
93
|
+
* @license lucide-react v0.468.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const bu=st("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
|
|
98
|
+
* @license lucide-react v0.468.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const wg=st("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
|
|
103
|
+
* @license lucide-react v0.468.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const jg=st("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
|
|
108
|
+
* @license lucide-react v0.468.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const eo=st("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
113
|
+
* @license lucide-react v0.468.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const Sg=st("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
118
|
+
* @license lucide-react v0.468.0 - ISC
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the ISC license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/const yu=st("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/**
|
|
123
|
+
* @license lucide-react v0.468.0 - ISC
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the ISC license.
|
|
126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/const kg=st("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/**
|
|
128
|
+
* @license lucide-react v0.468.0 - ISC
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the ISC license.
|
|
131
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
+
*/const Ig=st("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function Cg(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[s,i]of e)if(!Object.is(i,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(n).length)return!1;for(const s of r)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}const{useRef:Eg}=pf;function Rg(e){const n=Eg();return r=>{const s=e(r);return Cg(n.current,s)?n.current:n.current=s}}function Ha(e,n){var r;if((r=e.presentation)!=null&&r.forkPoint)return e.presentation.forkPoint;if(!n.startsWith("runtime:")&&e.id.startsWith("history-message.v1."))return{messageId:e.id}}function Ng(e,n){return!e.ctrlKey&&e.deltaY<0&&Math.abs(e.deltaX)<-e.deltaY&&n<=240}class Tg{constructor(){this.origin=null}start(n){this.origin=n.length===1?{clientX:n[0].clientX,clientY:n[0].clientY}:null}reset(){this.origin=null}move(n,r){if(n.length!==1)return this.reset(),!1;if(!this.origin)return!1;const s=n[0].clientX-this.origin.clientX,i=n[0].clientY-this.origin.clientY;return i<48||Math.abs(s)>=i||r>240?!1:(this.reset(),!0)}}const ra={completionEnabled:!0,soundEnabled:!0,notifyWhileForeground:!1};function Uc(e,n){const r=Array.from(e.trim());return r.length<=n?r.join(""):`${r.slice(0,n-1).join("")}…`}function Ag(e){return{completionEnabled:(e==null?void 0:e.completionEnabled)??ra.completionEnabled,soundEnabled:(e==null?void 0:e.soundEnabled)??ra.soundEnabled,notifyWhileForeground:(e==null?void 0:e.notifyWhileForeground)??ra.notifyWhileForeground}}function _g(e,n){return!n.completionEnabled||e.outcome!=="completed"||e.stale||!e.sessionId||!e.runId?null:{notificationId:`${e.sessionId}:${e.runId}:completed`,sessionId:e.sessionId,runId:e.runId,title:Uc(e.title,80)||"任务已完成",body:Uc(e.finalText??"",160)||"运行已结束"}}function vu({className:e="",label:n="正在加载会话"}){return t.jsx("div",{className:`session-loading ${e}`,role:"status","aria-live":"polite","aria-label":n,children:t.jsxs("div",{className:"session-loading-content",children:[t.jsxs("span",{className:"session-loading-orbit","aria-hidden":"true",children:[t.jsx("span",{className:"session-loading-track"}),t.jsxs("span",{className:"session-loading-dots",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),t.jsx("span",{className:"session-loading-core"})]}),t.jsx("span",{className:"session-loading-label","aria-hidden":"true",children:n})]})})}function wu(e,n){const[r,s]=c.useState(420);return c.useEffect(()=>{if(!e)return;const i=window.visualViewport,o=()=>{const l=n.current;if(!l)return;const u=l.getBoundingClientRect().top-((i==null?void 0:i.offsetTop)??0)-24;s(Math.max(0,Math.min(420,Math.floor(u))))};return o(),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),i==null||i.addEventListener("resize",o),i==null||i.addEventListener("scroll",o),()=>{window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),i==null||i.removeEventListener("resize",o),i==null||i.removeEventListener("scroll",o)}},[e,n]),r}function Mg(e=[]){return Al.map(n=>{const r=cu(n,e);return r?{agentType:n,label:qt[n],unavailableMessage:r}:{agentType:n,label:qt[n]}})}function Hc({value:e,health:n=[],onChange:r,values:s,onValuesChange:i,allowedAgentTypes:o,purpose:l="participants",defaultOpen:u=!1}){const[d,g]=c.useState(u),h=s!==void 0&&i!==void 0,p=c.useRef(null),k=wu(d,p);c.useEffect(()=>{if(!d)return;const j=A=>{var L;(L=p.current)!=null&&L.contains(A.target)||g(!1)},C=A=>{A.key==="Escape"&&g(!1)};return document.addEventListener("pointerdown",j),document.addEventListener("keydown",C),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",C)}},[d]);const x=j=>{var z;if(j.key!=="ArrowDown"&&j.key!=="ArrowUp")return;const C=Array.from(j.currentTarget.querySelectorAll('button[role^="menuitem"]:not([aria-disabled="true"])'));if(!C.length)return;j.preventDefault();const A=C.indexOf(document.activeElement),L=j.key==="ArrowDown"?1:-1;(z=C[(A+L+C.length)%C.length])==null||z.focus()},y=Mg(n).filter(j=>!o||o.includes(j.agentType)),S=s??[e],v=!h||S.length===1?qt[S[0]??e]:l==="participants"?`Agent · ${S.length}`:S.length===y.length?`全部(${S.length})`:`已选 ${S.length}/${y.length}`,w=l==="recipients"?"这条消息发给谁":"选择 Agent";return t.jsxs("div",{className:"composer-agent-picker",ref:p,"data-composer-agent-picker":e,children:[t.jsxs("button",{type:"button",className:"composer-agent-picker-button","aria-haspopup":"menu","aria-expanded":d,"aria-label":h?`${l==="recipients"?"发送对象":"参与 Agent"}:${v}`:`Agent:${qt[e]},点击切换`,title:h?`${w}:${S.map(j=>qt[j]).join("、")}`:`Agent:${qt[e]}(点击切换)`,onClick:()=>g(j=>!j),children:[t.jsx(_r,{agentType:S[0]??e,size:16}),t.jsx("span",{className:"composer-picker-label",children:v}),t.jsx(ua,{className:"composer-picker-chevron",size:14,strokeWidth:2,"aria-hidden":"true"})]}),d&&t.jsxs("div",{className:"composer-agent-picker-menu",role:"menu","aria-label":w,style:{maxHeight:k},onKeyDown:x,children:[h&&t.jsxs("div",{className:"composer-agent-picker-heading",children:[t.jsx("span",{children:w}),t.jsx("small",{children:"点名称单选,勾选框多选 · 立即生效"})]}),h&&l==="recipients"&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>i(y.map(j=>j.agentType)),children:[t.jsx("span",{className:"composer-picker-check","aria-hidden":"true",children:S.length===y.length?"✓":""}),t.jsx("span",{className:"composer-picker-copy",children:t.jsx("strong",{children:"全部 Agent"})})]}),y.map(j=>{const C=l!=="recipients"&&j.unavailableMessage!==void 0,A=h?S.includes(j.agentType):j.agentType===e,L=[A?"is-active":"",C?"is-unavailable":""].filter(Boolean).join(" ")||void 0,z=t.jsxs(t.Fragment,{children:[t.jsx(_r,{agentType:j.agentType,size:18}),t.jsxs("span",{className:"composer-picker-copy",children:[t.jsx("strong",{children:j.label}),C&&t.jsx("small",{children:j.unavailableMessage})]})]});if(h){const R=A&&S.length===1;return t.jsxs("div",{role:"none",className:`composer-agent-option${L?` ${L}`:""}`,children:[t.jsx("button",{type:"button",role:"menuitem",className:"composer-agent-option-main","data-agent-type":j.agentType,"aria-label":`仅使用 ${j.label}`,"aria-disabled":C||void 0,title:C?j.unavailableMessage:`仅使用 ${j.label}`,onClick:()=>{C||(i([j.agentType]),g(!1))},children:z}),t.jsx("button",{type:"button",role:"menuitemcheckbox",className:"composer-agent-option-toggle","aria-label":`${A?"取消选择":"添加"} ${j.label}`,"aria-checked":A,"aria-disabled":C||R||void 0,title:C?j.unavailableMessage:R?"至少保留一个 Agent":`${A?"取消选择":"添加"} ${j.label}`,onClick:()=>{C||R||i(A?S.filter(N=>N!==j.agentType):[...S,j.agentType])},children:t.jsx("span",{className:"composer-agent-checkbox","aria-hidden":"true",children:A?"✓":""})})]},j.agentType)}return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":A,"aria-disabled":C||void 0,"data-agent-type":j.agentType,title:C?j.unavailableMessage:j.label,className:L,onClick:()=>{C||(r(j.agentType),g(!1))},children:[t.jsx("span",{className:"composer-picker-check","aria-hidden":"true",children:A?"✓":""}),z]},j.agentType)})]})]})}const Lg={idle:"待发送",running:"执行中","needs-input":"待确认",completed:"已完成",failed:"失败"};function zg({members:e,selectedId:n,onSelect:r}){return t.jsx("div",{className:"parallel-agent-tabs",role:"tablist","aria-label":"Agent 会话",onKeyDown:s=>{var d;if(!["ArrowLeft","ArrowRight","Home","End"].includes(s.key))return;const i=Array.from(s.currentTarget.querySelectorAll('button[role="tab"]')),o=i.indexOf(s.target),l=s.key==="Home"?0:s.key==="End"?i.length-1:(o+(s.key==="ArrowRight"?1:-1)+i.length)%i.length;s.preventDefault(),(d=i[l])==null||d.focus();const u=e[l];u&&r(u.id)},children:e.map(s=>{const i=`${qt[s.agentType]} · ${Lg[s.status]}`;return t.jsxs("button",{type:"button",role:"tab",className:"parallel-agent-tab","aria-label":i,title:i,"aria-selected":s.id===n,onClick:()=>r(s.id),children:[t.jsx(_r,{agentType:s.agentType,size:18}),t.jsx("span",{className:`parallel-agent-status is-${s.status}`,"aria-hidden":"true"})]},s.id)})})}const ju="webapp.nativeAgentRunPrefs.v1";function Su(){try{const e=JSON.parse(localStorage.getItem(ju)??"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Fs(e){return ff(e)}function Dl(e,n){return Fs(e)?n!=null&&n.length?[...n]:e==="claude-code"?["low","medium","high","xhigh"]:[]:[]}function ro(e){return Fs(e)?Su()[e]??{}:{}}function hl(e,n){if(!Fs(e))return;const r=Su();r[e]=n;try{localStorage.setItem(ju,JSON.stringify(r))}catch{}}function Wl(e,n,r){var o;if(!r||!((o=e.model)!=null&&o.id))return e;const s=Sn(e.model),i=n.find(l=>Sn(l)===s);return i?i.id===e.model.id&&i.providerID===e.model.providerID?e:{...e,model:{id:i.id,...i.providerID?{providerID:i.providerID}:{}}}:{}}function Sn(e){return e.providerID?`${e.providerID}/${e.id}`:e.id}function ku(e,n){const r=n.find(s=>Sn(s)===e);return r!=null&&r.providerID?{id:r.id,providerID:r.providerID}:{id:(r==null?void 0:r.id)??e}}function Pg(e){var r,s;const n=new Map;for(const i of e){const o=(r=i.providerID)==null?void 0:r.trim(),l=((s=i.providerDisplayName)==null?void 0:s.trim())||o||"其他供应商",u=o||"__other__",d=n.get(u)??{key:u,label:o==="opencode-go"?`${l}(需订阅)`:l,models:[]};d.models.push({...i,optionLabel:i.displayName||i.id}),n.set(u,d)}return[...n.values()]}const Iu="context-compaction";function co(e,n){const r=e??[],s=r.findIndex(o=>o.itemId===n.itemId&&o.sectionIndex===n.sectionIndex);return(s<0?[...r,{itemId:n.itemId,sectionIndex:n.sectionIndex,text:n.delta}]:r.map((o,l)=>l===s?{...o,text:o.text+n.delta}:o)).sort((o,l)=>o.sectionIndex-l.sectionIndex)}function Gc(e){let n=[];for(const r of e)if(r.type==="runtime_progress"){const{type:s,...i}=r;n=Cu(n,i)}else r.type==="context_usage"?n=n.filter(s=>s.progressId!==Iu):(r.type==="done"||r.type==="turn_aborted"||r.type==="error")&&(n=[]);return n}function Cu(e,n){n.progressId==="codex:status"&&n.phase==="status"&&n.label==="正在开始处理"&&(n={...n,phase:"thinking",label:"正在思考"});const r=e.findIndex(s=>s.progressId===n.progressId);return r<0?[...e,n]:e.map((s,i)=>i===r?n:s)}function Eu(e,n){return[...e].reverse().find(r=>r.toolCallId===n)}function Dg(e){return[...e].reverse().find(n=>!n.toolCallId)}function Ru(e,n){const r=new Map(n.filter(l=>{var u,d;return((u=l.presentation)==null?void 0:u.agentMessagePhase)==="commentary"&&((d=l.presentation.executionTrace)==null?void 0:d.turnId)&&l.id.startsWith(`codex-trace:${l.presentation.executionTrace.turnId}:agent:`)}).map(l=>[l.id,l])),s=e.filter(l=>l.role==="assistant"&&r.has(l.id)),i=new Set(s.map(l=>l.id)),o=e.filter(l=>!i.has(l.id));return s.reduce((l,u)=>{const g=r.get(u.id).presentation.executionTrace.turnId,h=u.id.slice(`codex-trace:${g}:agent:`.length);return l.some(x=>{var y,S;return(S=(y=x.executionTrace)==null?void 0:y.liveMessages)==null?void 0:S.some(v=>v.id===u.id)})?l.map(x=>{var y;return x.executionTrace?{...x,executionTrace:{...x.executionTrace,liveMessages:(y=x.executionTrace.liveMessages)==null?void 0:y.map(S=>S.id===u.id&&u.content.length>S.content.length?{...S,content:u.content}:S)}}:x}):sa(l,g,{type:"text_chunk",text:u.content,turnId:g,itemId:h,messagePhase:"commentary"},u.timestamp).map(x=>{var y;return((y=x.executionTrace)==null?void 0:y.turnId)===g?{...x,executionTrace:{...x.executionTrace,liveMessages:[...x.executionTrace.liveMessages??[]].sort((S,v)=>S.timestamp-v.timestamp)}}:x})},o)}function Wg(e,n){var i,o;const r=[],s=new Map;for(let l=0;l<e.length;l+=1){const u=e[l];r.push(u);const d=u.role==="user"?(i=u.presentation)==null?void 0:i.executionTrace:void 0,g=d==null?void 0:d.turnId;if(!g)continue;const h=d.segmentIndex??s.get(g)??0;s.set(g,Math.max(s.get(g)??0,h+1));const p=e[l+1];((o=p==null?void 0:p.executionTrace)==null?void 0:o.turnId)===g&&(p.executionTrace.segmentIndex??0)===h?(r.push({...p,executionTrace:{...p.executionTrace,turnId:g,revision:n,segmentIndex:h}}),l+=1):r.push({id:Tu(g,h),role:"assistant",content:"",executionTrace:{turnId:g,revision:n,segmentIndex:h},timestamp:u.timestamp})}return r}function $g(e){var n,r,s,i;return e.role==="assistant"&&!!((n=e.toolCalls)!=null&&n.length||(s=(r=e.presentation)==null?void 0:r.reasoning)!=null&&s.length||((i=e.presentation)==null?void 0:i.agentMessagePhase)==="commentary")}function Nu(e,n,r,s){return e.map(i=>{var o;return(o=i.toolCalls)!=null&&o.some(l=>l.id===n)?{...i,toolCalls:i.toolCalls.map(l=>l.id===n?{...l,result:r,isError:s}:l)}:i})}function Bg(e,n,r,s){if(n.type==="text_chunk"){if(!n.text||n.messagePhase!=="commentary")return[...e];const i=n.itemId?`codex-trace:${s}:agent:${n.itemId}`:`codex-live-commentary:${s}`,o=e.findIndex(l=>l.id===i);return o<0?[...e,{id:i,role:"assistant",content:n.text,presentation:{agentMessagePhase:"commentary"},timestamp:r}]:e.map((l,u)=>u===o?{...l,content:l.content+n.text}:l)}if(n.type==="reasoning_summary_delta"){const i=e.findIndex(o=>{var l,u;return(u=(l=o.presentation)==null?void 0:l.reasoning)==null?void 0:u.some(d=>d.itemId===n.itemId)});return i<0?[...e,{id:`codex-live-reasoning:${n.itemId}`,role:"assistant",content:"",presentation:{reasoning:co(void 0,n)},timestamp:r}]:e.map((o,l)=>{var u;return l===i?{...o,presentation:{...o.presentation,reasoning:co((u=o.presentation)==null?void 0:u.reasoning,n)}}:o})}if(n.type==="tool_call"){const i=e.findIndex(o=>{var l;return(l=o.toolCalls)==null?void 0:l.some(u=>u.id===n.toolCall.id)});return i>=0?e.map((o,l)=>{var u;return l===i?{...o,toolCalls:(u=o.toolCalls)==null?void 0:u.map(d=>d.id===n.toolCall.id?{...d,name:n.toolCall.name,arguments:n.toolCall.arguments}:d)}:o}):[...e,{id:`codex-live-tool:${n.toolCall.id}`,role:"assistant",content:"",toolCalls:[{...n.toolCall}],timestamp:r}]}return e.some(i=>{var o;return(o=i.toolCalls)==null?void 0:o.some(l=>l.id===n.result.toolCallId)})?Nu(e,n.result.toolCallId,n.result.content,n.result.isError):[...e]}function sa(e,n,r,s=Date.now()){var x,y;if(r.type==="tool_call"){const S=e.filter(v=>{var w;return v.role==="assistant"&&!v.executionTrace&&!((w=v.presentation)!=null&&w.agentMessagePhase)&&v.id.startsWith(`codex-trace:${n}:agent:`)});S.length>0&&(e=Ru(e,S.map(v=>({...v,presentation:{...v.presentation,agentMessagePhase:"commentary",executionTrace:{turnId:n}}}))))}const i=e.findLastIndex(S=>{var v;return((v=S.executionTrace)==null?void 0:v.turnId)===n&&Og(S.executionTrace.liveMessages??[],r)}),o=e.findLastIndex(S=>{var v;return((v=S.executionTrace)==null?void 0:v.turnId)===n}),l=e.findLastIndex(S=>S.role==="user"&&!S.isQueued),u=i>=0?i:o>l||o>=0&&!((x=e[l])!=null&&x.isSteered)?o:-1,d=u>=0?((y=e[u].executionTrace)==null?void 0:y.liveMessages)??[]:[],g=Bg(d,r,s,n);if(g.length===0&&d.length===0)return[...e];if(u>=0)return e.map((S,v)=>v===u?{...S,executionTrace:{...S.executionTrace,liveMessages:g}}:S);if(g===d)return[...e];const h=l;if(h<0)return[...e];const p=e.reduce((S,v)=>{var w;return((w=v.executionTrace)==null?void 0:w.turnId)===n?Math.max(S,v.executionTrace.segmentIndex??0):S},-1)+1,k={id:Tu(n,p),role:"assistant",content:"",executionTrace:{turnId:n,revision:`live:${n}`,segmentIndex:p,liveMessages:g},timestamp:s};return[...e.slice(0,h+1),k,...e.slice(h+1)]}function Tu(e,n){return n===0?`codex-execution-trace:${e}`:`codex-execution-trace:${e}:${n}`}function Og(e,n){if(n.type==="text_chunk")return n.itemId?e.some(s=>s.id===`codex-trace:${n.turnId}:agent:${n.itemId}`):!1;if(n.type==="reasoning_summary_delta")return e.some(s=>{var i,o;return(o=(i=s.presentation)==null?void 0:i.reasoning)==null?void 0:o.some(l=>l.itemId===n.itemId)});const r=n.type==="tool_call"?n.toolCall.id:n.result.toolCallId;return e.some(s=>{var i;return(i=s.toolCalls)==null?void 0:i.some(o=>o.id===r)})}function Fg(e,n){return e.some(s=>{var i,o;return((o=(i=s.presentation)==null?void 0:i.executionTrace)==null?void 0:o.segmentIndex)!==void 0})?e.filter(s=>{var i,o;return((o=(i=s.presentation)==null?void 0:i.executionTrace)==null?void 0:o.segmentIndex)===n}):n===0?[...e]:[]}function ml(e,n){const r=new Map(e.map(s=>[`${s.itemId}:${s.sectionIndex}`,s]));for(const s of n){const i=`${s.itemId}:${s.sectionIndex}`,o=r.get(i),l=o?s.text.startsWith(o.text)?s.text:o.text.startsWith(s.text)?o.text:s.text:s.text;r.set(i,{...s,text:l})}return[...r.values()]}function Vc(e){var n,r;return[...((n=e.presentation)==null?void 0:n.agentMessagePhase)==="commentary"?[`agent:${e.id}`]:[],...(((r=e.presentation)==null?void 0:r.reasoning)??[]).map(s=>`reasoning:${s.itemId}:${s.sectionIndex}`),...(e.toolCalls??[]).map(s=>`tool:${s.id}`)]}function qg(e,n){var r,s;return((r=e.presentation)==null?void 0:r.agentMessagePhase)==="commentary"&&((s=n.presentation)==null?void 0:s.agentMessagePhase)==="commentary"&&(e.id.startsWith("codex-live-commentary:")||n.id.startsWith("codex-live-commentary:"))&&(e.content.startsWith(n.content)||n.content.startsWith(e.content))}function Ug(e){var o,l,u,d,g,h,p,k,x,y,S;const n=[],r=new Map,s=new Map,i=new Map;for(const v of e){if(((o=v.presentation)==null?void 0:o.agentMessagePhase)==="commentary"){const z=r.get(v.id);if(z!==void 0){const R=n[z],N=v.content.startsWith(R.content)?v.content:R.content.startsWith(v.content)?R.content:v.content;n[z]={...R,...v,id:R.id,content:N};continue}}const w={...v,toolCalls:v.toolCalls?[]:void 0,presentation:(l=v.presentation)!=null&&l.reasoning?{...v.presentation,reasoning:[]}:v.presentation};for(const z of((u=v.presentation)==null?void 0:u.reasoning)??[]){const R=`${z.itemId}:${z.sectionIndex}`,N=s.get(R);if(N){const T=n[N.messageIndex],F=[...((d=T.presentation)==null?void 0:d.reasoning)??[]],O=F[N.sectionIndex];F[N.sectionIndex]=ml([O],[z])[0],n[N.messageIndex]={...T,presentation:{...T.presentation,reasoning:F}}}else{const T=w.presentation.reasoning.findIndex(F=>F.itemId===z.itemId&&F.sectionIndex===z.sectionIndex);T>=0?w.presentation.reasoning[T]=ml([w.presentation.reasoning[T]],[z])[0]:w.presentation.reasoning.push(z)}}for(const z of v.toolCalls??[]){const R=i.get(z.id);if(R){const N=n[R.messageIndex],T=[...N.toolCalls??[]];T[R.toolIndex]={...T[R.toolIndex],...z},n[R.messageIndex]={...N,toolCalls:T}}else{const N=w.toolCalls.findIndex(T=>T.id===z.id);N>=0?w.toolCalls[N]={...w.toolCalls[N],...z}:w.toolCalls.push(z)}}const j=((g=w.presentation)==null?void 0:g.agentMessagePhase)==="commentary",C=!!((p=(h=w.presentation)==null?void 0:h.reasoning)!=null&&p.length),A=!!((k=w.toolCalls)!=null&&k.length);if(!j&&!C&&!A)continue;const L=n.length;n.push(w),j&&r.set(w.id,L);for(let z=0;z<(((y=(x=w.presentation)==null?void 0:x.reasoning)==null?void 0:y.length)??0);z+=1){const R=w.presentation.reasoning[z];s.set(`${R.itemId}:${R.sectionIndex}`,{messageIndex:L,sectionIndex:z})}for(let z=0;z<(((S=w.toolCalls)==null?void 0:S.length)??0);z+=1)i.set(w.toolCalls[z].id,{messageIndex:L,toolIndex:z})}return n}function Hg(e,n,r){if(e.length<2)return e;const s=new Map;e.forEach((v,w)=>{for(const j of Vc(v))s.set(j,w)});const i=v=>{for(const w of Vc(v)){const j=s.get(w);if(j!==void 0)return j}return e.findIndex(w=>qg(w,v))},o=v=>{const w=[];for(const j of v){const C=i(j);C<0||w.at(-1)===C||w.push(C)}return w},l=o(n),u=o(r),d=Array.from({length:e.length},()=>new Set),g=Array.from({length:e.length},()=>0),h=v=>{for(let w=1;w<v.length;w+=1){const j=v[w-1],C=v[w];j===C||d[j].has(C)||(d[j].add(C),g[C]+=1)}};h(l),h(u);const p=new Map(l.map((v,w)=>[v,w])),k=new Map(u.map((v,w)=>[v,w])),x=(v,w)=>{const j=p.get(v)??Number.POSITIVE_INFINITY,C=p.get(w)??Number.POSITIVE_INFINITY;if(j!==C)return j-C;const A=k.get(v)??Number.POSITIVE_INFINITY,L=k.get(w)??Number.POSITIVE_INFINITY;return A!==L?A-L:v-w},y=g.flatMap((v,w)=>v===0?[w]:[]).sort(x),S=[];for(;y.length>0;){const v=y.shift();S.push(e[v]);for(const w of d[v])g[w]-=1,g[w]===0&&(y.push(w),y.sort(x))}return S.length===e.length?S:e}function Gg(e,n){var s,i,o,l,u;const r=e.map(d=>{var g,h;return{...d,toolCalls:(g=d.toolCalls)==null?void 0:g.map(p=>({...p})),presentation:(h=d.presentation)!=null&&h.reasoning?{...d.presentation,reasoning:[...d.presentation.reasoning]}:d.presentation}});for(const d of n){if(((s=d.presentation)==null?void 0:s.agentMessagePhase)==="commentary"){const h=r.findIndex(p=>{var k;return p.id===d.id||((k=p.presentation)==null?void 0:k.agentMessagePhase)==="commentary"&&(p.id.startsWith("codex-live-commentary:")||d.id.startsWith("codex-live-commentary:"))&&(d.content.startsWith(p.content)||p.content.startsWith(d.content))});if(h<0)r.push(d);else{const p=r[h],k=d.content.startsWith(p.content)?d.content:p.content.startsWith(d.content)?p.content:d.content;r[h]={...p,content:k,presentation:{...p.presentation,agentMessagePhase:"commentary"}}}continue}const g=(i=d.presentation)==null?void 0:i.reasoning;if(g!=null&&g.length){const h=r.findIndex(p=>{var k,x;return(x=(k=p.presentation)==null?void 0:k.reasoning)==null?void 0:x.some(y=>g.some(S=>S.itemId===y.itemId))});if(h>=0){const p=r[h];r[h]={...p,presentation:{...p.presentation,reasoning:ml(((o=p.presentation)==null?void 0:o.reasoning)??[],g)}}}else r.push(d)}for(const h of d.toolCalls??[]){const p=r.findIndex(k=>{var x;return(x=k.toolCalls)==null?void 0:x.some(y=>y.id===h.id)});if(p>=0){const k=r[p];r[p]={...k,toolCalls:(l=k.toolCalls)==null?void 0:l.map(x=>x.id===h.id?{...x,...h}:x)}}else r.push({...d,id:(((u=d.toolCalls)==null?void 0:u.length)??0)>1?`${d.id}:tool:${h.id}`:d.id,presentation:void 0,toolCalls:[h]})}}return Hg(Ug(r),e,n)}function uo(e){const n=new Set,r=[];for(let s=e.length-1;s>=0;s-=1){const i=e[s];n.has(i.id)||(n.add(i.id),r.push(i))}return r.length===e.length?e:r.reverse()}const Qc={completed:"已完成",user_cancelled:"用户已停止",auth_required:"需要重新登录或检查凭据",quota_exceeded:"额度不足",rate_limited:"请求过于频繁",permission_denied:"权限被拒绝",context_limit:"上下文超出限制",output_limit:"输出达到限制",timeout:"请求超时",network_error:"网络连接失败",runtime_unavailable:"运行环境不可用",provider_error:"模型服务异常",runtime_interrupted:"运行环境中断",protocol_error:"运行协议异常",iteration_limit:"已达到执行轮数限制",tool_cycle:"已停止重复的工具调用",unknown_error:"原因未识别,请查看错误详情"};function po(e){if(!e||typeof e!="object")return;const n=e,r=i=>typeof i=="number"&&Number.isSafeInteger(i)&&i>=0;if(!r(n.inputTokens)||!r(n.outputTokens))return;const s=n.inputTokens+n.outputTokens;if(Number.isSafeInteger(s))return{inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:s,...r(n.cacheReadTokens)&&n.cacheReadTokens<=n.inputTokens?{cacheReadTokens:n.cacheReadTokens}:{},...r(n.cacheWriteTokens)&&n.cacheWriteTokens<=n.inputTokens?{cacheWriteTokens:n.cacheWriteTokens}:{},...n.source==="provider"||n.source==="runtime"?{source:n.source}:{},...n.coverage==="complete"||n.coverage==="partial"?{coverage:n.coverage}:{}}}function Vg(e,n){const r=`${n??""}
|
|
133
|
+
${e}`;return/\b(?:native_aborted|user_aborted|user_cancelled|run_cancelled)\b/i.test(n??"")?"user_cancelled":/insufficient[_\s-]*quota|quota[_\s-]*(?:exceeded|exhausted)|out of (?:credits|quota)|credit balance|usage limit|billing|额度.*(?:不足|耗尽|用尽|超限)|余额不足|套餐.*(?:不足|耗尽|用尽)/i.test(r)?"quota_exceeded":/\b401\b|http_401|unauthori[sz]ed|authentication|auth[_\s-]*(?:required|expired|failed)|invalid[_\s-]*(?:api[_\s-]*)?(?:key|token)|not logged in|login required|sign[ -]?in required|登录.*(?:失效|过期)|未登录/i.test(r)?"auth_required":/\b429\b|http_429|rate[_\s-]*limit|too many requests|限流|请求.*频繁/i.test(r)?"rate_limited":/\b403\b|http_403|permission[_\s-]*(?:denied|rejected)|access[_\s-]*denied|forbidden|tool_(?:policy|approval)_(?:denied|rejected)|权限.*(?:拒绝|不足)|审批.*拒绝/i.test(r)?"permission_denied":/context[_\s-]*(?:limit|length|window)|maximum context|上下文.*(?:限制|上限|超)/i.test(r)?"context_limit":/max[_\s-]*tokens|output[_\s-]*limit|输出.*(?:截断|限制|上限)/i.test(r)?"output_limit":/iteration[_\s-]*limit|max[_\s-]*turns|执行轮数/i.test(r)?"iteration_limit":/repeated_tool_cycle|重复.*工具/i.test(r)?"tool_cycle":/timeout|timed out|etimedout|超时/i.test(r)?"timeout":/runtime[_\s-]*(?:restarted|interrupted)|(?:runtime|broker|process|connection|transport|socket).*(?:restarted|interrupted|disconnected|closed|exited)|\bturn was interrupted\b|服务.*重启|运行.*中断/i.test(r)?"runtime_interrupted":/econn(?:refused|reset)|enotfound|eai_again|fetch failed|network[_\s-]*(?:error|failed|unavailable)|网络.*(?:失败|异常|不可用)/i.test(r)?"network_error":/runtime[_\s-]*unavailable|engine[_\s-]*unavailable|enoent|cli.*not found|executable.*not found|运行.*不可用/i.test(r)?"runtime_unavailable":/protocol[_\s-]*error|invalid.*json|malformed|tool_arguments_(?:invalid|incomplete)|协议.*异常/i.test(r)?"protocol_error":/MODEL_HTTP_5\d{2}|\b(?:api|http)\b.*\b5\d{2}\b|overloaded|service unavailable|服务.*(?:过载|暂不可用)/i.test(r)?"provider_error":"unknown_error"}function Au(e){const n=Qc[e.reason]??Qc.unknown_error;return e.status==="cancelled"?"已停止":e.status==="interrupted"?"已中断:运行环境中断":e.status==="failed"?`运行失败:${n}`:e.reason==="completed"?"已完成":`已结束:${n}`}function $l(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function _u(e){const n=$l(e);return n===void 0?void 0:`${Math.round(n/1e3)} 秒`}function Qg(e){return e.role==="user"&&!e.isQueued&&!e.isSteered}function Kg(e){var n,r,s;return e.role==="assistant"&&!!(e.content.trim()||(n=e.toolCalls)!=null&&n.length||(s=(r=e.presentation)==null?void 0:r.reasoning)!=null&&s.length||e.askUser||e.widget)}function Jg(e,n,r){var o;const s=e[n];if((s==null?void 0:s.role)!=="assistant"||!s.content.trim()||(o=s.toolCalls)!=null&&o.length||s.isCompactionSummary)return!1;let i=!r;for(let l=n+1;l<e.length;l++){const u=e[l];if(!u.isCompactionSummary){if(Qg(u)){i=!0;break}if(Kg(u))return!1}}return i}function Yg(e,n,r){const s=e[n];if(!s)return{showCopy:!1,showSpeak:!1,showCompletion:!1,compact:!1};if(s.role==="user")return{showCopy:!!s.content,showSpeak:!1,showCompletion:!1,compact:!1};const i=Jg(e,n,r);return{showCopy:i,showSpeak:i,showCompletion:i,compact:s.role==="assistant"&&!i&&!s.isCompactionSummary}}function Bl(e){if(!e||typeof e!="object")return!1;const n=e;return["completed","failed","cancelled","interrupted"].includes(n.status??"")&&typeof n.reason=="string"&&$l(n.durationMs)!==void 0}function Ol(e){return["done","error","turn_aborted"].includes(e.type??"")&&!e._preserveActiveRun&&!["SESSION_OCCUPIED","SESSION_ALREADY_RUNNING","CANCEL_CONFIRMATION_TIMEOUT"].includes(e.code??"")}function ss(e){return(Bl(e.result)?e.result.runId:void 0)??e.runId??e._runId??e._nativeRunId??e.turnId}function ia(e){if(!Ol(e)||!Bl(e.result))return;const n=po(e.result.usage)??po(e.usage),{usage:r,...s}=e.result,i=ss(e);return{...s,...i?{runId:i}:{},...n?{usage:n}:{}}}function Mu(e,n){if(!e||e.runId&&n.runId&&e.runId!==n.runId)return n;const r=po(e.usage)??po(n.usage);return{...e,...r?{usage:r}:{}}}function xl(e,n){const r=n!=null&&n.runResult?Mu(e==null?void 0:e.runResult,n.runResult):e==null?void 0:e.runResult;return r?{...e,...n,runResult:r}:n??e}function Lu(e,n){var i,o;const r=n?e.find(l=>{var u,d;return((d=(u=l.presentation)==null?void 0:u.runResult)==null?void 0:d.runId)===n}):void 0;if(r)return r;let s=-1;for(let l=e.length-1;l>=0;l-=1){const u=e[l];if(u.role==="user"&&!u.isQueued&&!u.isSteered&&!u.isCompactionSummary){s=l;break}}if(!(s<0)){for(let l=e.length-1;l>s;l-=1){const u=e[l];if(u.role==="assistant"&&!u.executionTrace&&!((i=u.toolCalls)!=null&&i.length)&&!u.isCompactionSummary&&!u.askUser&&!u.widget&&((o=u.presentation)==null?void 0:o.agentMessagePhase)!=="commentary"&&u.content.trim())return u}return e[s]}}function Xg(e,n){const r=ia(n);if(!r)return e;const s=Lu(e,r.runId);return s?e.map(i=>{var o;return i.id===s.id?{...i,presentation:{...i.presentation,runResult:Mu((o=i.presentation)==null?void 0:o.runResult,r)}}:i}):e}function Zg(e,n){const r=ia(n);if(!r||ia(e)||e===n)return n;const s=e.type==="error"?Vg(e.message??"",e.code):e.type==="turn_aborted"?"user_cancelled":"completed",i=s==="user_cancelled"?"cancelled":s==="runtime_interrupted"?"interrupted":e.type==="error"?"failed":"completed";return{...n,result:{...r,status:i,reason:s}}}function eh(e,n){if(!e)return n;const r=ss(e),s=ss(n);return r&&s&&r!==s?n:e}function th(e){const n=new Set;let r;for(const s of e){if(s.type==="run_admitted"){r=void 0;continue}if(!Ol(s))continue;const i=ss(s);if(i){if(n.has(i))continue;n.add(i)}else if((r==null?void 0:r.type)==="error"&&!ss(r)&&s.type!=="error")continue;r=s}return r}function oa(e){var r;const n=ia(e);return n&&n.status!=="failed"&&n.status!=="interrupted"||e.type!=="error"&&!n?null:((r=e.message)==null?void 0:r.trim())||(n?Au(n):"运行失败,但未记录具体错误")}function nh(e){const n=_u(e.durationMs),r=po(e.usage);return[Au(e),n?`总耗时 ${n}`:"耗时未知",r?`输入 ${r.inputTokens} / 输出 ${r.outputTokens} token${r.coverage==="partial"?"(部分统计)":""}`:"token 未知"].join(" · ")}function Kc(e){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.type==="context_usage"&&r.usage&&"segments"in r.usage)return r.usage}}function Jc(e){var r;const n=new Map;for(const s of e)s.type==="native_subagent_update"&&((r=s.activity)!=null&&r.parentToolCallId)&&n.set(s.activity.parentToolCallId,s.activity);return[...n.values()]}function rh(e,n,r,s){return s!==void 0&&!(s!=null&&s.trim())?[]:uo(s!==void 0&&s!==r?s?n[s]??[]:[]:e)}function zu(e){var n;return!!(e&&e.role==="assistant"&&!((n=e.toolCalls)!=null&&n.length)&&!e.widget&&!e.askUser&&!e.isCompactionSummary&&!e.executionTrace)}function Yc(e,n){var r;if(n.role==="assistant"&&((r=n.toolCalls)!=null&&r.length)){const s=e[e.length-1];if(zu(s))return[...e.slice(0,-1),{...s,content:s.content,toolCalls:n.toolCalls}]}return[...e,n]}function sh(e,n){if(!n)return e;const r=e[e.length-1];if(zu(r)){const s=[...e];return s[s.length-1]={...r,content:r.content+n},s}return[...e,{id:crypto.randomUUID(),role:"assistant",content:n,timestamp:Date.now()}]}function Xc(e,n,r,s){return e.map(i=>{if(!i.toolCalls)return i;const o=i.toolCalls.map(l=>l.id===n?{...l,result:r,isError:s}:l);return{...i,toolCalls:o}})}function Zc(e,n,r,s){return e.map(i=>{if(!i.toolCalls)return i;const o=i.toolCalls.map(l=>l.name==="dispatch_agent"&&l.arguments.subSessionId===n?{...l,arguments:{...l.arguments,subAgentStatus:r,subAgentDetail:s}}:l);return{...i,toolCalls:o}})}function ed(e,n,r){return e.map(s=>{if(!s.toolCalls)return s;const i=s.toolCalls.map(o=>o.name==="dispatch_agent"&&o.arguments.subSessionId===n?{...o,arguments:{...o.arguments,subAgentProgress:(o.arguments.subAgentProgress?o.arguments.subAgentProgress+`
|
|
134
|
+
`+r:r).split(`
|
|
135
|
+
`).slice(-30).join(`
|
|
136
|
+
`)}}:o);return{...s,toolCalls:i}})}function td(e,n,r){return e.map(s=>s.id===n?r(s):s)}function nd(e,n){const r=e.findIndex(s=>{var i,o;return(o=(i=s.presentation)==null?void 0:i.reasoning)==null?void 0:o.some(l=>l.itemId===n.itemId)});return r<0?[...e,{id:`native-reasoning:${n.itemId}`,role:"assistant",content:"",presentation:{reasoning:co(void 0,n)},timestamp:Date.now()}]:e.map((s,i)=>{var o;return i===r?{...s,presentation:{...s.presentation,reasoning:co((o=s.presentation)==null?void 0:o.reasoning,n)}}:s})}const Re=du((e,n)=>({messages:[],messagesBySession:{},historyWindowsBySession:{},contextUsageBySession:{},runtimeProgressBySession:{},nativeSubagentsBySession:{},runningSessionId:null,currentText:"",sessionId:null,todos:[],cronTasks:[],addMessage:(r,s)=>e(i=>{const o=s??i.sessionId??void 0,l=o&&o!==i.sessionId?i.messages:Yc(i.messages,r),u=o?{...i.messagesBySession,[o]:Yc(i.messagesBySession[o]??(o===i.sessionId?i.messages:[]),r)}:i.messagesBySession;return{messages:l,messagesBySession:u,currentText:o&&o!==i.sessionId?i.currentText:""}}),appendText:(r,s)=>e(i=>{if(!r)return i;const o=s??i.sessionId??void 0,l=!o||o===i.sessionId,u=sh(l?i.messages:i.messagesBySession[o]??[],r),d=o?{...i.messagesBySession,[o]:u}:i.messagesBySession;return{messages:l?u:i.messages,messagesBySession:d,currentText:o&&o!==i.sessionId?i.currentText:i.currentText+r}}),setRunningSession:r=>e({runningSessionId:r}),setSessionId:r=>e(s=>s.sessionId===r?s:{sessionId:r,messages:s.messagesBySession[r]??[],currentText:""}),updateToolResult:(r,s,i,o)=>e(l=>{const u=o??l.sessionId??void 0,d=u&&u!==l.sessionId?l.messages:Xc(l.messages,r,s,i),g=u?{...l.messagesBySession,[u]:Xc(l.messagesBySession[u]??(u===l.sessionId?l.messages:[]),r,s,i)}:l.messagesBySession;return{messages:d,messagesBySession:g}}),setMessages:(r,s,i)=>e(o=>{const l=s??o.sessionId??void 0,u=!l||l===o.sessionId;return{messages:u?r:o.messages,messagesBySession:l?{...o.messagesBySession,[l]:r}:o.messagesBySession,historyWindowsBySession:l&&i?{...o.historyWindowsBySession,[l]:i}:o.historyWindowsBySession,currentText:u?"":o.currentText}}),getMessagesForSession:r=>n().messagesBySession[r]??[],getSessionHistoryWindow:r=>n().historyWindowsBySession[r],setContextUsage:(r,s)=>e(i=>{const o=s??i.sessionId??void 0;return o?{contextUsageBySession:{...i.contextUsageBySession,[o]:r}}:i}),getContextUsageForSession:r=>n().contextUsageBySession[r],applyRunResult:(r,s)=>e(i=>{const o=s??i.sessionId;if(!o)return i;const l=o===i.sessionId,u=l?i.messages:i.messagesBySession[o]??[],d=Xg(u,r);return d===u?i:{messages:l?d:i.messages,messagesBySession:{...i.messagesBySession,[o]:d}}}),applyRuntimeProgress:(r,s)=>e(i=>{const o=s??i.sessionId??void 0;return o?{runtimeProgressBySession:{...i.runtimeProgressBySession,[o]:Cu(i.runtimeProgressBySession[o]??[],r)}}:i}),setRuntimeProgress:(r,s)=>e(i=>{const o=s??i.sessionId??void 0;return o?{runtimeProgressBySession:{...i.runtimeProgressBySession,[o]:r}}:i}),clearRuntimeProgress:r=>e(s=>{var u;const i=r??s.sessionId??void 0;if(!i||!((u=s.runtimeProgressBySession[i])!=null&&u.length))return s;const{[i]:o,...l}=s.runtimeProgressBySession;return{runtimeProgressBySession:l}}),applyNativeSubagentActivity:(r,s)=>e(i=>{const o=s??i.sessionId??void 0;return o?{nativeSubagentsBySession:{...i.nativeSubagentsBySession,[o]:{...i.nativeSubagentsBySession[o]??{},[r.parentToolCallId]:r}}}:i}),setNativeSubagentActivities:(r,s)=>e(i=>{const o=s??i.sessionId??void 0;return o?{nativeSubagentsBySession:{...i.nativeSubagentsBySession,[o]:Object.fromEntries(r.map(l=>[l.parentToolCallId,l]))}}:i}),applyReasoningSummary:(r,s)=>e(i=>{const o=s??i.sessionId??void 0,l=o&&o!==i.sessionId?i.messages:nd(i.messages,r),u=o?{...i.messagesBySession,[o]:nd(i.messagesBySession[o]??(o===i.sessionId?i.messages:[]),r)}:i.messagesBySession;return{messages:l,messagesBySession:u}}),applyCodexExecutionEvent:(r,s,i)=>e(o=>{const l=i??o.sessionId??void 0,u=Date.now(),d=l&&l!==o.sessionId?o.messages:sa(o.messages,r,s,u),g=l?{...o.messagesBySession,[l]:sa(o.messagesBySession[l]??(l===o.sessionId?o.messages:[]),r,s,u)}:o.messagesBySession;return{messages:d,messagesBySession:g}}),updateMessage:(r,s,i)=>e(o=>{const l=i??o.sessionId??void 0,u=l&&l!==o.sessionId?o.messages:td(o.messages,r,s),d=l?{...o.messagesBySession,[l]:td(o.messagesBySession[l]??(l===o.sessionId?o.messages:[]),r,s)}:o.messagesBySession;return{messages:u,messagesBySession:d}}),updateSubAgentStatus:(r,s,i,o)=>e(l=>{const u=o??l.sessionId??void 0,d=u&&u!==l.sessionId?l.messages:Zc(l.messages,r,s,i),g=u?{...l.messagesBySession,[u]:Zc(l.messagesBySession[u]??(u===l.sessionId?l.messages:[]),r,s,i)}:l.messagesBySession;return{messages:d,messagesBySession:g}}),updateSubAgentProgress:(r,s,i)=>e(o=>{const l=i??o.sessionId??void 0,u=l&&l!==o.sessionId?o.messages:ed(o.messages,r,s),d=l?{...o.messagesBySession,[l]:ed(o.messagesBySession[l]??(l===o.sessionId?o.messages:[]),r,s)}:o.messagesBySession;return{messages:u,messagesBySession:d}}),clearMessages:r=>e(s=>{const i=r??s.sessionId??void 0;if(!i)return{messages:[],currentText:""};const{[i]:o,...l}=s.messagesBySession,{[i]:u,...d}=s.historyWindowsBySession,{[i]:g,...h}=s.contextUsageBySession,{[i]:p,...k}=s.runtimeProgressBySession,{[i]:x,...y}=s.nativeSubagentsBySession;return{messages:i===s.sessionId?[]:s.messages,messagesBySession:l,historyWindowsBySession:d,contextUsageBySession:h,runtimeProgressBySession:k,nativeSubagentsBySession:y,currentText:i===s.sessionId?"":s.currentText}}),setTodos:r=>e({todos:r}),setCronTasks:r=>e({cronTasks:r})})),Ga={systemBase:{label:"系统基础提示",group:"system"},environment:{label:"运行环境",group:"system"},projectContext:{label:"项目上下文",group:"system"},skills:{label:"技能指令",group:"system"},memory:{label:"Memory",group:"system"},embeddedTools:{label:"系统内嵌工具定义",group:"system"},conversationHistory:{label:"历史用户消息",group:"messages"},currentUserMessage:{label:"当前用户消息",group:"messages"},assistantMessages:{label:"AI 历史回复",group:"messages"},compactionSummary:{label:"上下文压缩摘要",group:"messages"},toolCalls:{label:"工具调用",group:"tools"},toolResults:{label:"工具结果",group:"tools"},nativeToolDefinitions:{label:"原生工具定义",group:"tools"},images:{label:"图片",group:"images"},messageOverhead:{label:"协议与消息开销",group:"overhead"}},Va={system:{label:"系统",color:"#8b5cf6"},messages:{label:"消息",color:"#4f6ef7"},tools:{label:"工具",color:"#f59e0b"},images:{label:"图片",color:"#ec4899"},overhead:{label:"协议开销",color:"#94a3b8"}},rd=["system","messages","tools","images","overhead"];function ih(e,n){const r=(e==null?void 0:e.maxTokens)??Math.max(1,n*1e3),s=(e==null?void 0:e.totalTokens)??0,i=Object.fromEntries(rd.map(d=>[d,0]));for(const d of(e==null?void 0:e.segments)??[]){const g=Ga[d.category];g&&(i[g.group]+=d.tokens)}const o=Math.min(s/r,1),l=o*100,u=l===0?"0%":l<1?`${l.toFixed(2)}%`:l<10?`${l.toFixed(1)}%`:`${Math.round(l)}%`;return{hasUsage:!!e,totalTokens:s,maxTokens:r,ratio:o,percent:Math.round(o*100),percentLabel:u,groups:rd.map(d=>({key:d,label:Va[d].label,color:Va[d].color,tokens:i[d]})),details:((e==null?void 0:e.segments)??[]).filter(d=>d.tokens>0).map(d=>{var g,h;return{category:d.category,label:((g=Ga[d.category])==null?void 0:g.label)??d.category,color:Va[((h=Ga[d.category])==null?void 0:h.group)??"overhead"].color,tokens:d.tokens}}),requestLabel:e?`${e.providerId} · ${e.modelId} · 第 ${e.requestIndex} 次请求`:void 0}}function bl(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}K`:`${e}`}function sd(e,n){return n?e.percentLabel:e.hasUsage?`${bl(e.totalTokens)} / ${bl(e.maxTokens)} · ${e.percentLabel}`:"尚无模型请求"}function Pu({usage:e,contextWindowK:n,compact:r=!1}){const[s,i]=c.useState(!1),[o,l]=c.useState(null),u=c.useRef(null),d=c.useMemo(()=>ih(e,n),[e,n]),g=d.ratio>=.85?"var(--danger)":d.ratio>=.6?"#f59e0b":"var(--accent)",h=typeof window>"u"?1024:window.innerWidth;return t.jsxs("div",{className:"context-usage-ribbon",style:{position:"relative",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("button",{className:"context-usage-ribbon__button",ref:u,type:"button",onClick:()=>{var k;const p=((k=u.current)==null?void 0:k.getBoundingClientRect())??null;l(p),i(x=>!x)},title:"查看完整请求上下文占用估算",style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"6px 10px",border:0,background:"transparent",cursor:"pointer",fontFamily:"var(--font-body)"},children:r?t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"context-usage-ribbon__ring",width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",children:[t.jsx("circle",{cx:"14",cy:"14",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.14"}),t.jsx("circle",{cx:"14",cy:"14",r:"10",fill:"none",stroke:d.hasUsage?g:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:`${d.ratio*62.832} 62.832`,transform:"rotate(-90 14 14)"})]}),t.jsx("span",{className:"context-usage-ribbon__summary context-usage-ribbon__summary--compact",children:sd(d,!0)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"context-usage-ribbon__label",style:{fontSize:11,color:"var(--text-muted)",whiteSpace:"nowrap"},children:"上下文"}),t.jsx("div",{className:"context-usage-ribbon__meter",style:{flex:1,height:6,borderRadius:999,overflow:"hidden",background:"rgba(0,0,0,0.06)",display:"flex"},children:d.groups.map(p=>t.jsx("div",{style:{width:`${Math.max(0,Math.min(p.tokens/d.maxTokens*100,100))}%`,background:p.color,opacity:p.key==="overhead"?.65:1,minWidth:p.tokens>0?1:0}},p.key))}),t.jsx("span",{className:"context-usage-ribbon__summary",style:{fontSize:11,color:d.hasUsage?g:"var(--text-muted)",fontVariantNumeric:"tabular-nums",minWidth:110,textAlign:"right"},children:sd(d,!1)})]})}),s&&o&&t.jsxs(t.Fragment,{children:[t.jsx("div",{onClick:()=>i(!1),style:{position:"fixed",inset:0,zIndex:9998,background:"transparent"}}),t.jsxs("div",{style:{position:"fixed",left:r?Math.min(Math.max(8,o.left),Math.max(8,h-Math.min(340,h-16)-8)):Math.max(8,o.left),top:o.top-8,transform:"translateY(-100%)",width:Math.min(r?340:o.width,h-16),maxHeight:"min(520px, calc(100vh - 32px))",overflowY:"auto",zIndex:9999,padding:12,borderRadius:12,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",boxShadow:"var(--shadow-lg)"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)"},children:"完整请求上下文估算"}),t.jsx("div",{style:{fontSize:11,color:d.hasUsage?g:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:d.hasUsage?d.percentLabel:"暂无"})]}),d.requestLabel&&t.jsx("div",{style:{marginBottom:10,fontSize:10,color:"var(--text-muted)",wordBreak:"break-all"},children:d.requestLabel}),d.hasUsage?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:d.details.map(p=>{const k=d.totalTokens>0?Math.round(p.tokens/d.totalTokens*100):0;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p.color}}),t.jsx("span",{style:{flex:1,fontSize:12,color:"var(--text-secondary)"},children:p.label}),t.jsxs("span",{style:{fontSize:12,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:[bl(p.tokens)," · ",k,"%"]})]},p.category)})}):t.jsx("div",{style:{padding:"8px 0",fontSize:12,color:"var(--text-muted)"},children:"发送第一条消息后,将显示最新一次模型请求的完整上下文组成。"})]})]})]})}function oh({agentType:e,onChange:n}){const[r,s]=c.useState([]),[i,o]=c.useState(!1),[l,u]=c.useState(""),[d,g]=c.useState(0),[h,p]=c.useState(()=>ro(e));c.useEffect(()=>{let v=!1;return u(""),o(!1),window.agentApi.listAgentModels(e).then(w=>{v||(s(w.models??[]),o(!0))}).catch(w=>{v||u(w instanceof Error?w.message:"模型列表加载失败")}),()=>{v=!0}},[e,d]);const k=Wl(h,r,i),x=k.model?r.find(v=>Sn(v)===Sn(k.model)):void 0,y=Dl(e,x==null?void 0:x.reasoningEfforts),S=v=>{const w={...k,...v};p(w),hl(e,w),n()};return t.jsxs(t.Fragment,{children:[t.jsxs("label",{children:["模型",t.jsxs("select",{"aria-label":`${qt[e]} 模型`,value:k.model?Sn(k.model):"",disabled:!i,onChange:v=>S({model:v.target.value?ku(v.target.value,r):void 0}),children:[t.jsx("option",{value:"",children:i?"默认模型":"加载中"}),r.map(v=>t.jsxs("option",{value:Sn(v),children:[v.providerDisplayName?`${v.providerDisplayName} / `:"",v.displayName||v.id]},Sn(v)))]})]}),y.length>0&&t.jsxs("label",{children:["思考强度",t.jsxs("select",{"aria-label":`${qt[e]} 思考强度`,value:k.reasoningEffort&&y.includes(k.reasoningEffort)?k.reasoningEffort:"",onChange:v=>S({reasoningEffort:v.target.value?v.target.value:void 0}),children:[t.jsx("option",{value:"",children:"默认"}),y.map(v=>t.jsx("option",{value:v,children:{low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"}[v]},v))]})]}),l&&t.jsxs("div",{className:"parallel-settings-error",role:"alert",children:[l,t.jsx("button",{type:"button",onClick:()=>g(v=>v+1),children:"重试"})]})]})}function ah({agentTypes:e,sessions:n,onChange:r,onOpenSession:s,customerProfiles:i,customerProfileId:o,onCustomerProfileChange:l,customerEffort:u,contextWindowK:d}){const[g,h]=c.useState(!1),p=c.useRef(null),k=c.useRef(null),x=c.useRef(null),[y,S]=c.useState(null),v=Re(w=>w.contextUsageBySession);return c.useEffect(()=>{if(!g)return;const w=C=>{var A,L;!((A=p.current)!=null&&A.contains(C.target))&&!((L=x.current)!=null&&L.contains(C.target))&&h(!1)},j=C=>{C.key==="Escape"&&h(!1)};return document.addEventListener("pointerdown",w),document.addEventListener("keydown",j),()=>{document.removeEventListener("pointerdown",w),document.removeEventListener("keydown",j)}},[g]),c.useLayoutEffect(()=>{var L;if(!g)return;const w=()=>{var se,we,Y;const z=(se=k.current)==null?void 0:se.getBoundingClientRect();if(!z)return;const R=window.visualViewport,N=(R==null?void 0:R.offsetLeft)??0,T=(R==null?void 0:R.offsetTop)??0,F=(R==null?void 0:R.width)??window.innerWidth,O=((Y=(we=p.current)==null?void 0:we.closest(".composer-shell"))==null?void 0:Y.getBoundingClientRect().top)??z.top,q=Math.max(T+16,O-8),ae=Math.max(0,Math.min(320,F-32));S({width:ae,left:Math.max(N+16,Math.min(z.left,N+F-ae-16)),bottom:window.innerHeight-q,maxHeight:Math.max(0,Math.min(420,q-T-16))})},j=window.visualViewport,C=new ResizeObserver(w);p.current&&C.observe(p.current);const A=(L=p.current)==null?void 0:L.closest(".composer-shell");return A&&C.observe(A),w(),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),j==null||j.addEventListener("resize",w),j==null||j.addEventListener("scroll",w),()=>{window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),j==null||j.removeEventListener("resize",w),j==null||j.removeEventListener("scroll",w),C.disconnect()}},[g]),t.jsxs("div",{className:"parallel-agent-settings web-native-model-control",ref:p,children:[t.jsxs("button",{ref:k,type:"button",className:"parallel-agent-settings-trigger","aria-haspopup":"dialog","aria-expanded":g,"aria-label":"按 Agent 分别配置模型",onClick:()=>h(w=>!w),children:["分别配置",t.jsx(ua,{size:12})]}),g&&y&&Wt.createPortal(t.jsx("div",{ref:x,className:"parallel-agent-settings-menu",role:"dialog","aria-label":"按 Agent 分别配置",style:{position:"fixed",right:"auto",...y},children:e.map(w=>{const j=n==null?void 0:n.find(C=>C.agentType===w);return t.jsxs("section",{className:"parallel-agent-settings-row",children:[t.jsxs("div",{className:"parallel-agent-settings-heading",children:[t.jsx(_r,{agentType:w,size:17}),qt[w]]}),w==="customer-agent"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{children:["模型",t.jsxs("select",{"aria-label":"Customer Agent 模型",value:o,disabled:!i.length,onChange:C=>l(C.target.value),children:[!i.length&&t.jsx("option",{value:"",children:"未配置模型"}),i.map(C=>t.jsx("option",{value:C.id,children:C.name||C.modelId},C.id))]})]}),t.jsxs("label",{children:["思考强度",t.jsx("select",{"aria-label":"Customer Agent 思考强度",value:u.value,onChange:C=>u.onChange(C.target.value),children:u.options.map(C=>t.jsx("option",{value:C.value,children:C.label},C.value))})]})]}):Fs(w)&&(j==null?void 0:j.nativeModelSelectionSupported)!==!1?t.jsx(oh,{agentType:w,onChange:r}):t.jsx("span",{children:"沿用原生模型配置"}),j&&t.jsxs(t.Fragment,{children:[t.jsx(Pu,{usage:v[j.id],contextWindowK:d,compact:!0}),t.jsx("button",{type:"button",className:"parallel-settings-open",onClick:()=>{s(j),h(!1)},children:"切换到此 Agent 会话"})]})]},w)})}),document.body)]})}function yl(e){return e.some(({askUser:n})=>n&&!n.answered&&!n.cancelled)}function so(e){return e==="idle"?"completed":e}const io={"needs-input":"需要输入",running:"运行中",completed:"执行完成",stale:"状态待刷新",error:"执行错误"};async function lh(e,n){const r=e.map(i=>({...i})),s=await Promise.allSettled(r.map(async i=>{var l;n.prepare&&(i.message=await n.prepare(i.member,i.message));const o=await n.enqueue(i.member.id,i.message);(l=n.admitted)==null||l.call(n,i.member,o)}));return{accepted:e.filter((i,o)=>s[o].status==="fulfilled").map(i=>i.member.id),failed:s.flatMap((i,o)=>i.status==="rejected"?[{...r[o],error:i.reason instanceof Error?i.reason.message:String(i.reason)}]:[])}}async function ch(e,n,r){var d;if(!Fs(n.agentType))return r?{profileId:r}:void 0;if(n.nativeModelSelectionSupported===!1)return;const s=ro(n.agentType);if(!((d=s.model)!=null&&d.id)&&!s.reasoningEffort)return;const i=(await e.listAgentModels(n.agentType)).models,o=Wl(s,i,!0),l=o.model?i.find(g=>Sn(g)===Sn(o.model)):void 0,u=Dl(n.agentType,l==null?void 0:l.reasoningEfforts);return{...o.model?{model:o.model}:{},...o.reasoningEffort&&u.includes(o.reasoningEffort)?{reasoningEffort:o.reasoningEffort}:{}}}const vl="agentroam.parallel-failed.v1:",Qi=(e,n)=>`${vl}${e}:${n.sessionId}:${n.message.sourceMessageId}`;class dh{constructor(n,r){this.storage=n,this.images=r}entries(n){try{const r=JSON.parse(this.storage.getItem(vl+n)||"[]");return Array.isArray(r)?r.filter(s=>!!(s&&typeof s=="object"&&typeof s.sessionId=="string"&&typeof s.error=="string"&&s.message&&typeof s.message.content=="string"&&typeof s.message.sourceMessageId=="string")):[]}catch{return[]}}async read(n){return(await Promise.all(this.entries(n.id).map(async r=>{const s=n.members.find(l=>l.id===r.sessionId);if(!s)return null;const i=r.hasImages?await this.images.read(Qi(n.id,r)):[],o=r.hasImages&&!i.length;return{member:s,message:{...r.message,...i.length?{images:i}:{}},error:o?`${r.error};附件未恢复,请重新添加后发送`:r.error,...o?{blocked:o}:{}}}))).filter(r=>r!==null)}async write(n,r){const s=this.entries(n.id),i=[];for(const l of r){const{images:u,...d}=l.message,g={sessionId:l.member.id,message:d,error:l.error,hasImages:!!(u!=null&&u.length||l.blocked)};l.blocked||await this.images.write(Qi(n.id,g),u??[]),i.push(g)}this.storage.setItem(vl+n.id,JSON.stringify(i));const o=new Set(i.map(l=>Qi(n.id,l)));await Promise.all(s.filter(l=>!o.has(Qi(n.id,l))).map(l=>this.images.clear(Qi(n.id,l))))}}const uh="agentroam-composer-drafts",ph=1,xi="session-image-drafts";function id(e){if(!e||typeof e!="object")return[];const n=e.images;return Array.isArray(n)?n.filter(r=>typeof r=="string"&&r.startsWith("data:image/")):[]}class Du{constructor(n){this.databasePromise=null,this.mutationQueue=Promise.resolve(),this.factory=n===void 0?typeof indexedDB>"u"?null:indexedDB:n}async read(n){if(!n||!this.factory)return[];await this.mutationQueue;const r=await this.openDatabase();return r?await new Promise(s=>{try{const i=r.transaction(xi,"readonly"),o=i.objectStore(xi).get(n);o.onsuccess=()=>s(id(o.result)),o.onerror=()=>s([]),i.onabort=()=>s([])}catch{s([])}}):[]}write(n,r){if(!n||!this.factory)return Promise.resolve();const s=id({images:r});return this.enqueueMutation(async()=>{const i=await this.openDatabase();i&&await this.runMutation(i,o=>{s.length===0?o.delete(n):o.put({sessionId:n,images:s})})})}clear(n){return!n||!this.factory?Promise.resolve():this.enqueueMutation(async()=>{const r=await this.openDatabase();r&&await this.runMutation(r,s=>s.delete(n))})}enqueueMutation(n){const r=this.mutationQueue.then(n,n).catch(()=>{});return this.mutationQueue=r,r}openDatabase(){return this.databasePromise?this.databasePromise:this.factory?(this.databasePromise=new Promise(n=>{try{const r=this.factory.open(uh,ph);r.onupgradeneeded=()=>{const s=r.result;s.objectStoreNames.contains(xi)||s.createObjectStore(xi,{keyPath:"sessionId"})},r.onsuccess=()=>n(r.result),r.onerror=()=>n(null),r.onblocked=()=>n(null)}catch{n(null)}}),this.databasePromise):Promise.resolve(null)}runMutation(n,r){return new Promise(s=>{try{const i=n.transaction(xi,"readwrite");r(i.objectStore(xi)),i.oncomplete=()=>s(),i.onerror=()=>s(),i.onabort=()=>s()}catch{s()}})}}class fh{constructor(n){this.repository=n,this.selectedSessionId=null,this.selectionGeneration=0}async restore(n){const r=++this.selectionGeneration;if(this.selectedSessionId=n??null,!n)return null;const s=await this.repository.read(n);return r!==this.selectionGeneration||this.selectedSessionId!==n?null:{sessionId:n,images:s}}adopt(n,r){return this.selectionGeneration+=1,this.selectedSessionId=n,this.repository.write(n,r)}save(n,r){return this.invalidatePendingRestore(n),this.repository.write(n,r)}saveSelected(n,r){return this.selectedSessionId!==n?Promise.resolve():this.repository.write(n,r)}clear(n){return this.invalidatePendingRestore(n),this.repository.clear(n)}invalidatePendingRestore(n){this.selectedSessionId===n&&(this.selectionGeneration+=1)}}function gh({sessionId:e,onSelect:n,onQueueState:r,profileId:s}){const[i,o]=c.useState(null),l=e&&(i!=null&&i.members.some(Y=>Y.id===e))?i:null,[u,d]=c.useState([]),[g,h]=c.useState({}),[p,k]=c.useState([]),[x,y]=c.useState(!1),[S,v]=c.useState(null),w=c.useRef(!1),j=c.useRef([]),C=c.useRef(0),A=c.useRef(null);if(!A.current)try{typeof localStorage<"u"&&(A.current=new dh(localStorage,new Du))}catch{}const L=c.useRef(new Map),z=c.useRef(null),R=c.useRef(0),N=c.useRef(r);N.current=r;const T=c.useRef(new Map),F=c.useCallback(Y=>{var K;for(const Q of Y.members)L.current.set(Q.id,Y);if(z.current!==Y.id){z.current=Y.id;let Q=Y.members.map(Pe=>Pe.id);try{const Pe=JSON.parse(localStorage.getItem(`agentroam.parallel-recipients.v1:${Y.id}`)||"null");if(Array.isArray(Pe)){const oe=Q.filter(Ne=>Pe.includes(Ne));oe.length&&(Q=oe)}}catch{}d(Q),k([]),j.current=[];const Se=++C.current;(K=A.current)==null||K.read(Y).then(Pe=>{z.current!==Y.id||C.current!==Se||(j.current=Pe,k(Pe))}).catch(()=>{})}o(Y)},[]);c.useEffect(()=>{var Q;if(R.current+=1,!e){o(null),z.current=null,v(null);return}const Y=L.current.get(e);if(Y){F(Y);return}o(null);let K=!1;if(typeof((Q=window.agentApi)==null?void 0:Q.getParallelSessionGroup)=="function")return window.agentApi.getParallelSessionGroup(e).then(Se=>{K||(Se?F(Se):z.current=null)}).catch(()=>{}),()=>{K=!0}},[e,F]);const O=c.useCallback((Y,K)=>{T.current.set(Y,(T.current.get(Y)??0)+1),h(Q=>Q[Y]===K?Q:{...Q,[Y]:K})},[]);c.useEffect(()=>{if(!l)return;const Y=new Set(l.members.map(K=>K.id));return window.agentApi.onEvent(K=>{const Q=K;!Q._sid||!Y.has(Q._sid)||(Q.type==="ask_user"?O(Q._sid,"needs-input"):Q.type==="error"?O(Q._sid,Q._preserveActiveRun?"running":"failed"):Q.type==="done"||Q.type==="turn_aborted"?O(Q._sid,Q.type==="turn_aborted"||Q.result&&"status"in Q.result&&Q.result.status!=="completed"?"failed":"completed"):["run_admitted","thinking","text_chunk","tool_call","approval_resolved"].includes(Q.type)&&O(Q._sid,yl(Re.getState().getMessagesForSession(Q._sid))?"needs-input":"running"))})},[l==null?void 0:l.id,O]),c.useEffect(()=>{if(!l)return;let Y=!1,K=!1;const Q=async()=>{if(!(K||!Dt())){K=!0;try{await Promise.allSettled(l.members.map(async Pe=>{const oe=T.current.get(Pe.id)??0,Ne=await window.agentApi.getSessionGoals(Pe.id);if(Y||oe!==(T.current.get(Pe.id)??0))return;const at=yl(Re.getState().getMessagesForSession(Pe.id)),W=Ne.history.reduce((X,ke)=>!X||ke.updatedAt>X.updatedAt?ke:X,void 0);O(Pe.id,at?"needs-input":Ne.active?"running":W?W.status==="completed"?"completed":"failed":"idle")}))}finally{K=!1}}};Q();const Se=setInterval(()=>{Q()},5e3);return()=>{Y=!0,clearInterval(Se)}},[l==null?void 0:l.id,O]);const q=async Y=>{const K=await window.agentApi.createParallelSessions(Y);for(const Q of K.members)L.current.set(Q.id,K);return K},ae=async(Y,K)=>{if(Y.id===e)return;const Q=++R.current;v(null);try{const Se=await window.agentApi.getSession(Y.id,{limit:1,view:"core"});if(!Se||Se.id!==Y.id||Se.agentType!==Y.agentType)throw new Error("该 Agent 的会话已不可访问");if(Q!==R.current||(await(K==null?void 0:K()),Q!==R.current))return;await(n==null?void 0:n(Se))}catch(Se){if(Q!==R.current)return;v(Se instanceof Error?Se.message:"切换 Agent 会话失败")}},se=async Y=>{var Se,Pe;if(w.current)return{accepted:[],failed:[]};w.current=!0,y(!0);const K=Y[0]?L.current.get(Y[0].member.id):void 0;let Q=z.current===(K==null?void 0:K.id)?j.current:[];C.current+=1;try{K&&!Q.length&&(Q=await((Se=A.current)==null?void 0:Se.read(K))??[]);const oe=Re.getState();for(const{member:X,message:ke}of Y){const _e=oe.getMessagesForSession(X.id).find(Je=>Je.id===ke.sourceMessageId);_e?oe.updateMessage(_e.id,Je=>({...Je,sendState:"pending"}),X.id):oe.addMessage({id:ke.sourceMessageId,role:"user",content:ke.content,images:ke.images,agentName:ke.agentName,timestamp:Date.now(),sendState:"pending",awaitingHistory:!0},X.id)}const Ne=await lh(Y,{enqueue:(X,ke)=>window.agentApi.enqueueSessionMessage(X,ke),prepare:async(X,ke)=>({...ke,runOptions:ke.runOptions??await ch(window.agentApi,X,s)}),admitted:(X,ke)=>{N.current(ke,X.id),O(X.id,ke.active?"running":"idle"),oe.updateMessage(Y.find(_e=>_e.member.id===X.id).message.sourceMessageId,_e=>({..._e,sendState:void 0}),X.id)}}),at=new Set(Y.map(X=>`${X.member.id}:${X.message.sourceMessageId}`)),W=[...Q.filter(X=>!at.has(`${X.member.id}:${X.message.sourceMessageId}`)),...Ne.failed];if(z.current===(K==null?void 0:K.id)&&(j.current=W,k(W)),K)try{await((Pe=A.current)==null?void 0:Pe.write(K,W))}catch{z.current===K.id&&v("未能保存失败消息,请保持此页面并重试发送")}for(const X of Ne.failed)oe.updateMessage(X.message.sourceMessageId,ke=>({...ke,sendState:"failed"}),X.member.id);return Ne}finally{w.current=!1,y(!1)}};return{group:l,recipients:u,setRecipients:Y=>{if(!l)return;const K=l.members.filter(Q=>Y.includes(Q.id)).map(Q=>Q.id);if(K.length){d(K);try{localStorage.setItem(`agentroam.parallel-recipients.v1:${l.id}`,JSON.stringify(K))}catch{}}},statuses:g,failed:p,submitting:x,error:S,create:q,activate:F,select:ae,submit:se,retry:Y=>se([Y]),isRunning:Y=>!!(Y&&["running","needs-input"].includes(g[Y]))}}function hh(e,n){return JSON.stringify([e,e==="qoder"?n:null])}function wl(e){return{scope:e,models:[],status:"loading",error:null}}function mh(e,n){return n.status==="ready"||e!=="qoder"&&(n.status==="empty"||n.status==="unsupported")}function xh(e,n,r,s){let i=!1;return s(wl(e)),Promise.resolve().then(()=>r(n)).then(o=>{if(i)return;const l=o.supported===!1?[]:o.models??[];s({scope:e,models:l,status:o.supported===!1?"unsupported":l.length?"ready":"empty",error:null})}).catch(o=>{i||s({scope:e,models:[],status:"error",error:o instanceof Error?o.message:"模型列表加载失败"})}),()=>{i=!0}}function bh(e){var n;if(!((n=window.agentApi)!=null&&n.listAgentModels))throw new Error("当前服务未提供模型列表接口,请更新服务");return window.agentApi.listAgentModels(e)}function yh(e,n,r){const s=hh(e,r),[i,o]=c.useState(()=>wl(s)),[l,u]=c.useState(0),d=c.useCallback(()=>u(h=>h+1),[]);c.useEffect(()=>{if(n)return xh(s,e,bh,o)},[e,n,s,l]);const g=n&&i.scope===s?i:wl(s);return{...g,catalogReady:n&&mh(e,g),retry:d}}function vh({status:e,error:n,onRetry:r}){if(e==="ready")return null;const s=e==="loading"?"模型加载中":e==="error"?"模型加载失败":e==="unsupported"?"暂不支持选择模型":"暂无可选模型";return t.jsxs("span",{className:"web-native-model-notice",children:[t.jsx("span",{role:e==="error"?"alert":"status",title:n??s,children:s}),e!=="loading"&&t.jsx("button",{type:"button","aria-label":"重新加载模型列表",onClick:r,children:"重试"})]})}const od=c.forwardRef(function({value:n,options:r,disabled:s,onChange:i},o){const[l,u]=c.useState(!1),[d,g]=c.useState({top:-1e3,left:0,width:280,maxHeight:360}),h=c.useRef(null),p=c.useRef(null),k=c.useId(),x=r.find(S=>S.value===n),y=()=>{var S;u(!1),(S=h.current)==null||S.focus({preventScroll:!0})};return c.useImperativeHandle(o,()=>({focus:S=>{var v;return(v=h.current)==null?void 0:v.focus(S)},showPicker:()=>{s||u(!0)}}),[s]),c.useLayoutEffect(()=>{if(!l)return;const S=window.visualViewport,v=()=>{var ae,se;const j=(ae=h.current)==null?void 0:ae.getBoundingClientRect();if(!j)return;const C=((S==null?void 0:S.offsetTop)??0)+8,A=((S==null?void 0:S.offsetLeft)??0)+8,L=C+((S==null?void 0:S.height)??innerHeight)-16,z=A+((S==null?void 0:S.width)??innerWidth)-16,R=j.top-C-6,N=L-j.bottom-6,T=R>=Math.min(320,N),F=Math.max(0,Math.min(360,T?R:N)),O=Math.min(((se=p.current)==null?void 0:se.scrollHeight)??360,F),q=Math.min(Math.max(j.width,280),z-A);g({top:T?Math.max(C,j.top-O-6):j.bottom+6,left:Math.max(A,Math.min(j.left,z-q)),width:q,maxHeight:F})};v();const w=new ResizeObserver(v);return h.current&&w.observe(h.current),p.current&&w.observe(p.current),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),S==null||S.addEventListener("resize",v),S==null||S.addEventListener("scroll",v),()=>{w.disconnect(),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),S==null||S.removeEventListener("resize",v),S==null||S.removeEventListener("scroll",v)}},[l]),c.useEffect(()=>{var j,C;if(!l)return;const S=((j=p.current)==null?void 0:j.querySelector('[aria-selected="true"]'))??((C=p.current)==null?void 0:C.querySelector('[role="option"]'));S==null||S.focus({preventScroll:!0}),S==null||S.scrollIntoView({block:"nearest"});const v=A=>{var L,z;!((L=p.current)!=null&&L.contains(A.target))&&!((z=h.current)!=null&&z.contains(A.target))&&u(!1)},w=A=>{A.key==="Escape"&&(A.preventDefault(),y())};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",w)}},[l]),c.useEffect(()=>{u(!1)},[s]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:h,type:"button",className:"web-native-model-picker-trigger","aria-label":"当前模型",title:(x==null?void 0:x.label)??"切换模型","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":l?k:void 0,disabled:s,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="ArrowDown"||S.key==="ArrowUp")&&(S.preventDefault(),u(!0))},children:(x==null?void 0:x.label)??"默认模型"}),l&&Wt.createPortal(t.jsx("div",{ref:p,id:k,className:"composer-model-menu",role:"listbox","aria-label":"选择模型",style:d,onKeyDown:S=>{var C;if(S.key==="Tab"){u(!1);return}if(!["ArrowDown","ArrowUp","Home","End"].includes(S.key))return;S.preventDefault();const v=Array.from(S.currentTarget.querySelectorAll('[role="option"]')),w=v.indexOf(document.activeElement),j=S.key==="Home"?0:S.key==="End"?v.length-1:(w+(S.key==="ArrowDown"?1:-1)+v.length)%v.length;(C=v[j])==null||C.focus()},children:r.map((S,v)=>{var w;return t.jsxs("div",{children:[S.group&&S.group!==((w=r[v-1])==null?void 0:w.group)&&t.jsx("div",{className:"composer-model-group",children:S.group}),t.jsxs("button",{type:"button",role:"option","aria-selected":S.value===n,tabIndex:-1,title:S.label,onClick:()=>{i(S.value),y()},children:[t.jsx("span",{className:"composer-model-check","aria-hidden":"true",children:S.value===n?"✓":""}),t.jsx("span",{children:S.label})]})]},S.value)})}),document.body)]})});function ad(e){return e.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).pop()??""}function wh(e,n){const r=n.find(i=>i.id===e);if(r)return{label:r.name||ad(r.path)||"选择目录",path:r.path};const s=e?ad(e):"";return s?{label:s,path:e??void 0}:{label:"选择目录"}}function jh({value:e,workspaces:n,onChange:r,onPickFolder:s,defaultOpen:i=!1}){const[o,l]=c.useState(i),u=c.useRef(null),d=wu(o,u);c.useEffect(()=>{if(!o)return;const x=S=>{var v;(v=u.current)!=null&&v.contains(S.target)||l(!1)},y=S=>{S.key==="Escape"&&l(!1)};return document.addEventListener("pointerdown",x),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",y)}},[o]);const g=x=>{var w;if(x.key!=="ArrowDown"&&x.key!=="ArrowUp")return;const y=Array.from(x.currentTarget.querySelectorAll('button:not([aria-disabled="true"]):not(:disabled)'));if(!y.length)return;x.preventDefault();const S=y.indexOf(document.activeElement),v=x.key==="ArrowDown"?1:-1;(w=y[(S+v+y.length)%y.length])==null||w.focus()},{label:h,path:p}=wh(e,n),k=n.length>0;return t.jsxs("div",{className:"composer-workspace-picker",ref:u,"data-composer-workspace-picker":e??"",children:[t.jsxs("button",{type:"button",className:"composer-workspace-picker-button","aria-haspopup":"menu","aria-expanded":o,"aria-label":`目录:${h},点击切换`,title:h,onClick:()=>l(x=>!x),children:[t.jsx(If,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),t.jsx("span",{className:"composer-picker-label",title:p?`${h}(${p})`:void 0,children:h}),t.jsx(ua,{className:"composer-picker-chevron",size:14,strokeWidth:2,"aria-hidden":"true"})]}),o&&t.jsxs("div",{className:"composer-workspace-picker-menu",role:"menu","aria-label":"选择目录",style:{maxHeight:d},onKeyDown:g,children:[n.map(x=>{const y=x.canCreateSession===!1,S=x.id===e;return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":S,"aria-disabled":y||void 0,"data-workspace-id":x.id,title:y?`${x.path}(仅历史会话,无法新建)`:x.path,className:[S?"is-active":"",y?"is-unavailable":""].filter(Boolean).join(" ")||void 0,onClick:()=>{y||(r(x.id),l(!1))},children:[t.jsx("span",{className:"composer-picker-check","aria-hidden":"true",children:S?"✓":""}),t.jsxs("span",{className:"composer-picker-copy",children:[t.jsx("strong",{children:x.name}),t.jsx("small",{children:x.path||"仅历史会话"})]})]},x.id)}),t.jsxs("button",{type:"button",role:"menuitem",className:"composer-workspace-picker-action",disabled:!s,onClick:()=>{l(!1),s==null||s()},children:[t.jsx(pu,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),k?"选择其他文件夹…":"选择文件夹…"]})]})]})}function Fl({message:e,type:n}){return e?Wt.createPortal(t.jsxs("div",{className:`app-action-notice is-${n}`,role:n==="error"?"alert":"status","aria-live":n==="error"?"assertive":"polite",children:[t.jsx("span",{className:"app-action-notice-mark","aria-hidden":"true",children:n==="success"?"✓":n==="info"?"i":"!"}),t.jsx("span",{children:e})]}),document.body):null}function ld(e){var i,o,l;if(!e||e.status==="running"||e.status==="active"||(i=e.history)!=null&&i.newerCursor||((o=e.history)==null?void 0:o.delivery)==="trace")return null;const n=e.messages??[],r=Math.max(0,n.findLastIndex(u=>{var d;return u.role==="user"&&u.name!=="__compaction_checkpoint__"&&u.name!=="__native_steering_pending"&&!((d=u.name)!=null&&d.startsWith("__native_steered:"))})),s=th(e.events??[]);if(s){const u=ss(s),d=u?n.findLastIndex(g=>{var h,p;return((p=(h=g.presentation)==null?void 0:h.runResult)==null?void 0:p.runId)===u||g.name===`__native_run:${u}`}):-1;if(d<0||d>=r)return oa(s)}for(let u=n.length-1;u>=r;u-=1){const d=(l=n[u].presentation)==null?void 0:l.runResult;if(Bl(d))return oa({type:"done",result:d})}return e.status==="failed"?"运行失败,但未记录具体错误":null}function Sh(e){return/^terminated$|OpenCode 2 .*response read failed: terminated|fetch failed|failed to fetch|load failed|network (?:request|connection)|ECONNREFUSED|ECONNRESET|ENOTFOUND|ETIMEDOUT|连接.*(?:失败|超时)|事件流连接/i.test(e)?"connection":/\b(?:429|402)\b|quota|rate.?limit|usage.*(?:limit|exceed)|credit|insufficient.*(?:balance|fund)|额度|限流|频率|余额|model.*(?:not found|unavailable|unsupported)|unsupported.*model/i.test(e)?"model":"other"}function kh(e){var n;e==null||e.focus();try{(n=e==null?void 0:e.showPicker)==null||n.call(e)}catch{}}function Ih({message:e,historical:n,onSwitchModel:r,children:s}){const i=Sh(e),o=i==="model"?"模型请求失败":i==="connection"?"连接失败":"操作失败";return t.jsxs("div",{role:"alert",style:{padding:12,margin:"8px 0",borderRadius:"var(--radius-sm)",background:"rgba(248,113,113,0.08)",border:"1px solid rgba(248,113,113,0.2)",color:"var(--danger)",fontSize:13,animation:"fadeIn 0.2s var(--ease-out)",display:"flex",alignItems:"center",flexWrap:"wrap",gap:10},children:[t.jsxs("div",{style:{flex:"1 1 240px",minWidth:0,overflowWrap:"anywhere"},children:[t.jsxs("strong",{children:[n?"上次执行失败 · ":"",o]}),t.jsx("div",{style:{marginTop:4,whiteSpace:"pre-wrap",fontFamily:"var(--font-mono)"},children:e}),i==="model"&&t.jsx("div",{style:{marginTop:6},children:"可以切换下方模型,再手动继续;不会自动重试。"}),i==="connection"&&t.jsx("div",{style:{marginTop:6},children:"请先检查执行服务连接再重试,切换模型不能解决此连接错误。"})]}),i==="model"&&r&&t.jsx("button",{type:"button",onClick:r,style:{flexShrink:0,minHeight:32,padding:"5px 10px",borderRadius:5,border:"1px solid rgba(248,113,113,0.35)",background:"var(--bg-workspace)",color:"var(--danger)",cursor:"pointer",fontSize:12},children:"切换模型"}),s]})}function Ch({result:e}){const n=e.status==="completed"&&e.reason==="completed"?er:e.status==="cancelled"?no:Ci;return t.jsxs("span",{className:`msg-completion-status msg-run-result msg-run-result--${e.status}${e.status==="completed"&&e.reason!=="completed"?" msg-run-result--limited":""}`,role:"status",children:[t.jsx(n,{size:13,strokeWidth:2,"aria-hidden":"true"}),t.jsx("span",{children:nh(e)})]})}function cd({href:e,children:n,code:r=!1}){const[s,i]=c.useState(!1),[o,l]=c.useState(!1),[u,d]=c.useState(!1),g=c.useRef(null),h=c.useRef(null),p=c.useRef(null),k=c.useRef(!1),x=c.useRef(!1),y=()=>{h.current&&clearTimeout(h.current),h.current=null,p.current=null},S=()=>{k.current=!0,l(!1),d(!1),i(!0)},v=()=>{var w;k.current=!1,i(!1),(w=g.current)==null||w.focus({preventScroll:!0})};return c.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),c.useEffect(()=>{if(!s)return;const w=j=>{var C;j.key==="Escape"&&(j.preventDefault(),k.current=!1,i(!1),(C=g.current)==null||C.focus({preventScroll:!0}))};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[s]),t.jsxs(t.Fragment,{children:[t.jsx("a",{ref:g,className:`chat-message-link${r?" chat-message-link--code":""}`,href:e,target:"_blank",rel:"noopener noreferrer",title:"长按复制地址",onPointerDown:w=>{y(),k.current=!1,!(!w.isPrimary||w.button!==0||w.pointerType==="mouse")&&(p.current={x:w.clientX,y:w.clientY},h.current=setTimeout(S,550))},onPointerMove:w=>{p.current&&Math.hypot(w.clientX-p.current.x,w.clientY-p.current.y)>10&&y()},onPointerUp:w=>{y(),k.current&&w.preventDefault()},onPointerCancel:y,onContextMenu:w=>{w.preventDefault(),y(),S()},onClick:w=>{k.current&&(w.preventDefault(),k.current=!1)},children:n}),s&&typeof document<"u"&&Wt.createPortal(t.jsx("div",{className:"message-link-actions-backdrop","data-tab-swipe-ignore":!0,onPointerDown:w=>{x.current=w.target===w.currentTarget},onClick:w=>{x.current&&w.target===w.currentTarget&&v()},children:t.jsxs("section",{className:"message-link-actions",role:"dialog","aria-modal":"true","aria-label":"链接操作",children:[t.jsxs("div",{className:"message-link-actions-heading",children:[t.jsx("strong",{children:"链接地址"}),t.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"关闭链接操作",onClick:v,children:t.jsx(tr,{size:16})})]}),t.jsx("input",{"aria-label":"原始链接地址",value:e,readOnly:!0,onFocus:w=>w.target.select()}),t.jsxs("button",{type:"button",className:"message-link-copy-button",autoFocus:!0,onClick:()=>{ji(e).then(w=>{l(w),d(!w)})},children:[o?t.jsx(er,{size:16}):t.jsx(Si,{size:16}),o?"已复制地址":"复制地址"]}),t.jsx("span",{role:"status",children:u?"请长按上方地址,使用系统菜单复制":o?"可在远程桌面点击“粘贴”":""})]})}),document.body)]})}function Wu(e){let n=e;if(/^https?:\/\//i.test(e)){if(!zl(e))return null;n=new URL(e).pathname}else if(/^[A-Za-z][\w+.-]*:/.test(e)&&!/^[A-Za-z]:[\\/]/.test(e)||/[\0\r\n?#]/.test(e))return null;return/\.(png|jpe?g|gif|webp|bmp|ico|svg)$/i.test(n)?"image":/\.(mp4|webm|mov|m4v)$/i.test(n)?"video":null}function Eh(e,n){if(/^(?:https?:\/\/|\/|~\/|[A-Za-z]:[\\/])/i.test(e))return e;if(!n||!Wu(e))return null;const r=/^[A-Za-z]:\\/.test(n)?"\\":"/";return`${n.replace(/[\\/]+$/,"")}${r}${e}`}const $u=c.createContext(null);function Rh({path:e,label:n,kind:r,onOpenArtifact:s}){const i=c.useContext($u),o=Eh(e,i),l=zl(e),[u,d]=c.useState(null),[g,h]=c.useState(null),[p,k]=c.useState(!1),x=c.useRef(null),y=l?e:(u==null?void 0:u.path)===e?u.url:null,S=n&&n!==e?n.replace(/^`|`$/g,""):e.split(/[\\/]/).pop()||"媒体";return c.useEffect(()=>{if(k(!1),h(null),l)return;const v=window.agentApi;let w=!1,j=!1,C=null;const A=R=>{v.fileWorkspaceRequest("fs:preview-close",{ticketId:R}).catch(()=>{})},L=()=>{if(!(j||w)){if(j=!0,!(v!=null&&v.fileWorkspaceRequest)||!o){h(e);return}v.fileWorkspaceRequest("fs:preview-open",{path:o}).then(R=>{if(w){A(R.ticketId);return}C=R.ticketId,d({path:e,url:R.url})}).catch(()=>{w||h(e)})}},z=typeof IntersectionObserver>"u"?null:new IntersectionObserver(R=>{R.some(N=>N.isIntersecting)&&(z==null||z.disconnect(),L())},{rootMargin:"300px"});return z&&x.current?z.observe(x.current):L(),()=>{w=!0,z==null||z.disconnect(),C&&A(C)}},[e,l,o]),t.jsxs("span",{ref:x,className:"chat-message-media","data-tab-swipe-ignore":!0,children:[g===e?t.jsxs("span",{role:"status",children:["媒体加载失败 ",s&&o&&t.jsx("button",{type:"button",className:"chat-message-artifact-link",onClick:()=>s(o),children:"打开预览"})]}):y?r==="video"?t.jsx("video",{src:y,controls:!0,playsInline:!0,preload:"metadata","aria-label":S,onError:()=>h(e)}):t.jsx("button",{type:"button",className:"chat-message-media__image","aria-label":`放大图片 ${S}`,onClick:()=>k(!0),children:t.jsx("img",{src:y,alt:S,loading:"lazy",onError:()=>h(e)})}):t.jsxs("span",{role:"status",children:["正在加载",S,"…"]}),t.jsx(fu,{image:p&&y?{src:y,alt:S}:null,onClose:()=>k(!1)})]})}let dd=Promise.resolve(),Nh=0;function Bu(e,n=!1){const r=dd.then(async()=>{if(e.length>5e4)throw new Error("图表源码过长,请查看源码");const s=(await gf(async()=>{const{default:o}=await import("./mermaid.core-CIbk74HW.js").then(l=>l.cb);return{default:o}},__vite__mapDeps([0,1,2]),import.meta.url)).default;s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral",suppressErrorRendering:!0,maxTextSize:5e4,maxEdges:500,...n?{htmlLabels:!1,flowchart:{htmlLabels:!1}}:{},secure:["secure","securityLevel","startOnLoad","maxTextSize","maxEdges","suppressErrorRendering",...n?["htmlLabels","flowchart"]:[]]});const i=document.createElement("div");i.style.cssText="position:fixed;left:-100000px;top:0;visibility:hidden;pointer-events:none",document.body.appendChild(i);try{const{svg:o}=await s.render(`agentroam-mermaid-${++Nh}`,e,i);return o}finally{i.remove()}});return dd=r.catch(()=>{}),r}function Ou(e){var r;const n=(r=e.match(/<svg\b[^>]*\bviewBox=["']([^"']+)["']/i))==null?void 0:r[1].trim().split(/[\s,]+/).map(Number);return!n||n.length!==4||!n.every(Number.isFinite)||n[2]<=0||n[3]<=0?{width:640,height:480}:{width:n[2],height:n[3]}}function Th(e,n,r){return Math.max(.001,Math.min(1,Math.max(1,n)/e.width,r===void 0?1:Math.max(1,r)/e.height))}function ud(e,n){return Math.min(4,Math.max(Math.min(.1,n),e))}function Ah(e){const n=Math.min(2,4096/e.width,4096/e.height);return{width:Math.max(1,Math.round(e.width*n)),height:Math.max(1,Math.round(e.height*n))}}async function _h(e){const n=await Bu(e,!0),r=new DOMParser().parseFromString(n,"image/svg+xml");if(r.querySelector("parsererror, foreignObject"))throw new Error("此图包含暂不支持导出的内容,请查看源码。");if([...r.querySelectorAll("image")].some(l=>!String(l.getAttribute("href")??l.getAttribute("xlink:href")??"").startsWith("data:")))throw new Error("此图包含外部图片,暂不能导出 PNG。");const s=Ah(Ou(n)),i=r.documentElement;i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width",String(s.width)),i.setAttribute("height",String(s.height)),i.style.maxWidth="none",i.style.width=`${s.width}px`,i.style.height=`${s.height}px`;const o=URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(i)],{type:"image/svg+xml;charset=utf-8"}));try{const l=new Image;await new Promise((g,h)=>{l.onload=()=>g(),l.onerror=()=>h(new Error("图表图片转换失败,请重试。")),l.src=o});const u=window.document.createElement("canvas");u.width=s.width,u.height=s.height;const d=u.getContext("2d");if(!d)throw new Error("当前浏览器无法导出图片。");return d.fillStyle="#fff",d.fillRect(0,0,s.width,s.height),d.drawImage(l,0,0,s.width,s.height),await new Promise((g,h)=>{u.toBlob(p=>p?g(p):h(new Error("图片导出失败,请重试。")),"image/png")})}finally{URL.revokeObjectURL(o)}}function pd({label:e,onClose:n,children:r}){const s=c.useRef(null);return c.useEffect(()=>{var l,u;const i=document.activeElement,o=document.body.style.overflow;return document.body.style.overflow="hidden",(u=(l=s.current)==null?void 0:l.querySelector("button"))==null||u.focus(),()=>{document.body.style.overflow=o,i instanceof HTMLElement&&i.isConnected&&i.focus()}},[]),Wt.createPortal(t.jsxs("div",{className:"mermaid-dialog","data-tab-swipe-ignore":!0,ref:s,role:"dialog","aria-modal":"true","aria-label":e,onKeyDown:i=>{var d;if(i.key==="Escape"&&(i.stopPropagation(),n()),i.key!=="Tab")return;const o=[...((d=s.current)==null?void 0:d.querySelectorAll('button:not(:disabled), a[href], [tabindex="0"]'))??[]],l=o[0],u=o[o.length-1];i.shiftKey&&document.activeElement===l?(i.preventDefault(),u==null||u.focus()):!i.shiftKey&&document.activeElement===u&&(i.preventDefault(),l==null||l.focus())},children:[t.jsxs("div",{className:"mermaid-dialog-header",children:[t.jsx("strong",{children:e}),t.jsx("button",{type:"button",className:"mermaid-control","aria-label":`关闭${e}`,onClick:n,children:t.jsx(tr,{size:20})})]}),r]}),document.body)}function Mh({svg:e,fullscreen:n,onFullscreen:r,onExport:s,exporting:i}){const o=c.useMemo(()=>Ou(e),[e]),l=c.useRef(null),[u,d]=c.useState(o),[g,h]=c.useState(null),p=Th(o,u.width,n?u.height:void 0),k=g===null?p:ud(g,p),x=c.useRef(k);x.current=k;const y=c.useRef(!1),S=c.useRef(null);c.useLayoutEffect(()=>{const w=l.current;if(!w)return;const j=()=>d({width:Math.max(1,w.clientWidth-24),height:Math.max(1,w.clientHeight-24)});j();const C=new ResizeObserver(j);return C.observe(w),()=>C.disconnect()},[]);const v=c.useCallback((w,j)=>{const C=l.current;if(!C)return;const A=ud(w,p),L=A/x.current,z=j??{x:C.clientWidth/2,y:C.clientHeight/2},R=(C.scrollLeft+z.x)*L-z.x,N=(C.scrollTop+z.y)*L-z.y;x.current=A,h(A),requestAnimationFrame(()=>{C.scrollLeft=R,C.scrollTop=N})},[p]);return c.useEffect(()=>{const w=l.current;if(!w)return;let j=null;const C=N=>Math.hypot(N[0].clientX-N[1].clientX,N[0].clientY-N[1].clientY),A=N=>{y.current=!1,N.touches.length===2&&(j={distance:Math.max(1,C(N.touches)),scale:x.current},y.current=!0)},L=N=>{if(y.current=!0,!j||N.touches.length!==2)return;N.preventDefault();const T=w.getBoundingClientRect();v(j.scale*C(N.touches)/j.distance,{x:(N.touches[0].clientX+N.touches[1].clientX)/2-T.left,y:(N.touches[0].clientY+N.touches[1].clientY)/2-T.top})},z=()=>{j=null},R=N=>{if(!N.ctrlKey&&!N.metaKey)return;N.preventDefault();const T=w.getBoundingClientRect();v(x.current*Math.exp(-N.deltaY*.01),{x:N.clientX-T.left,y:N.clientY-T.top})};return w.addEventListener("touchstart",A,{passive:!0}),w.addEventListener("touchmove",L,{passive:!1}),w.addEventListener("touchend",z),w.addEventListener("touchcancel",z),w.addEventListener("wheel",R,{passive:!1}),()=>{w.removeEventListener("touchstart",A),w.removeEventListener("touchmove",L),w.removeEventListener("touchend",z),w.removeEventListener("touchcancel",z),w.removeEventListener("wheel",R)}},[v]),t.jsxs("div",{className:`mermaid-viewer${n?" mermaid-viewer-fullscreen":""}`,children:[t.jsxs("div",{className:"mermaid-toolbar",role:"toolbar","aria-label":"图表操作",children:[t.jsx("button",{type:"button",className:"mermaid-control","aria-label":"缩小图表",title:"缩小",disabled:k<=Math.min(.1,p),onClick:()=>v(k/1.25),children:t.jsx(Wf,{size:18})}),t.jsxs("span",{className:"mermaid-zoom-value","aria-label":"缩放比例",children:[Math.round(k*100),"%"]}),t.jsx("button",{type:"button",className:"mermaid-control","aria-label":"放大图表",title:"放大",disabled:k>=4,onClick:()=>v(k*1.25),children:t.jsx($f,{size:18})}),t.jsx("button",{type:"button",className:"mermaid-control","aria-label":"自适应图表",title:"自适应",onClick:()=>{var w;h(null),(w=l.current)==null||w.scrollTo(0,0)},children:t.jsx(qf,{size:18})}),t.jsx("button",{type:"button",className:"mermaid-control","aria-label":n?"退出图表全屏":"全屏查看图表",title:n?"退出全屏":"全屏",onClick:r,children:n?t.jsx(xg,{size:18}):t.jsx(mg,{size:18})}),t.jsx("button",{type:"button",className:"mermaid-control","aria-label":"导出图表 PNG",title:"导出 PNG",disabled:i,onClick:s,children:t.jsx(gu,{size:18})})]}),t.jsx("div",{className:"mermaid-block-preview",ref:l,tabIndex:0,"aria-label":"图表预览,可滚动或双指缩放",onPointerDown:w=>{if(w.pointerType!=="mouse"||w.button!==0)return;const j=w.currentTarget;y.current=!1,S.current={x:w.clientX,y:w.clientY,left:j.scrollLeft,top:j.scrollTop}},onPointerMove:w=>{const j=S.current;j&&(Math.hypot(w.clientX-j.x,w.clientY-j.y)>4&&(y.current||w.currentTarget.setPointerCapture(w.pointerId),y.current=!0),w.currentTarget.scrollLeft=j.left-(w.clientX-j.x),w.currentTarget.scrollTop=j.top-(w.clientY-j.y))},onPointerUp:()=>{S.current=null},onPointerCancel:()=>{S.current=null},children:t.jsx("div",{className:"mermaid-diagram-canvas",style:{width:o.width*k,height:o.height*k},role:n?"img":"button","aria-label":n?"Mermaid 图表":"点击全屏查看 Mermaid 图表",tabIndex:n?void 0:0,onClick:()=>{!n&&!y.current&&r()},onKeyDown:w=>{!n&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),r())},dangerouslySetInnerHTML:{__html:e}})}),t.jsx("div",{className:"mermaid-viewer-hint",children:i?"正在生成完整 PNG…":n?"双指缩放 · 滑动查看 · 导出完整图片":"点击图表全屏 · 双指缩放"})]})}function Lh({code:e,svg:n}){const r=c.useRef(null),[s,i]=c.useState(!1),[o,l]=c.useState(!1),[u,d]=c.useState(null),[g,h]=c.useState(null),p=c.useRef(0),k=c.useCallback(()=>{i(!1),requestAnimationFrame(()=>{var v,w;return(w=(v=r.current)==null?void 0:v.querySelector('button[aria-label="全屏查看图表"]'))==null?void 0:w.focus()})},[]),x=c.useCallback(()=>d(null),[]);c.useEffect(()=>()=>{p.current++},[e]),c.useEffect(()=>()=>{u&&URL.revokeObjectURL(u)},[u]);const y=async()=>{if(o)return;const v=p.current;l(!0),h(null);try{const w=await _h(e);v===p.current&&d(URL.createObjectURL(w))}catch(w){v===p.current&&h(w instanceof Error?w.message:"图片导出失败,请重试。")}finally{v===p.current&&l(!1)}},S=t.jsx(Mh,{svg:n,fullscreen:s,onFullscreen:()=>s?k():i(!0),onExport:()=>void y(),exporting:o});return t.jsxs("div",{className:"mermaid-diagram","data-tab-swipe-ignore":!0,ref:r,children:[s?t.jsxs(pd,{label:"图表全屏",onClose:k,children:[S,g&&t.jsx("div",{className:"mermaid-block-status",role:"alert",children:g})]}):S,!s&&g&&t.jsx("div",{className:"mermaid-block-status",role:"alert",children:g}),u&&t.jsxs(pd,{label:"导出图表图片",onClose:x,children:[t.jsxs("div",{className:"mermaid-export-actions",children:[t.jsx("span",{children:"手机可长按图片保存,或下载 PNG"}),t.jsx("a",{href:u,download:"mermaid-diagram.png",children:"下载 PNG"})]}),t.jsx("div",{className:"mermaid-export-preview",children:t.jsx("img",{src:u,alt:"完整 Mermaid 图表 PNG"})})]})]})}function zh({code:e,complete:n}){const[r,s]=c.useState(!1),[i,o]=c.useState(null),l=n&&(i==null?void 0:i.code)===e?i:null;c.useEffect(()=>{if(!n||!e.trim())return;let d=!1;const g=setTimeout(()=>{Bu(e).then(h=>{d||o({code:e,svg:h})},()=>{d||o({code:e,error:"图表暂时无法渲染,请查看源码。"})})},150);return()=>{d=!0,clearTimeout(g)}},[e,n]);const u=n?e.trim()?(l==null?void 0:l.error)??(l!=null&&l.svg?null:"正在渲染图表…"):"暂无图表内容":"图表生成中…";return t.jsxs("div",{className:"mermaid-block",children:[t.jsxs("div",{className:"mermaid-block-header",children:[t.jsx("span",{children:"Mermaid"}),t.jsx("button",{type:"button","aria-pressed":r,onClick:()=>s(!r),children:r?"图表":"源码"})]}),u&&t.jsx("div",{className:"mermaid-block-status",role:"status",children:u}),r||!(l!=null&&l.svg)?t.jsx("pre",{className:"mermaid-block-source",children:t.jsx("code",{children:e})}):t.jsx(Lh,{code:e,svg:l.svg},e)]})}const Fu=2e5,Ph=24,Dh=12,Wh=80,$h=30,Bh=500,Oh=160,Fh=1e3,aa=200,qh={"/help":"使用帮助","/whoami":"关于我","/works":"项目与作品","/jobs":"求职信息","/timeline":"经历时间线","/contact":"联系方式"};function jl(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Os(e,n){if(typeof e!="string")return;const r=e.trim();return r?r.slice(0,n):void 0}function fd(e,n,r){return Array.isArray(e)?e.slice(0,n).filter(s=>typeof s=="string").map(s=>s.trim().slice(0,r)).filter(Boolean):[]}function Uh(e){if(jl(e)){const n=Os(e.type,aa)??"unknown";if(n==="text"){const r=Os(e.text,Fu);if(r){const s=Os(e.tone,aa);return{kind:"text",text:r,...s?{tone:s}:{}}}}return{kind:"unknown",blockType:n,value:e}}return{kind:"unknown",blockType:"unknown",value:e}}function Hh(e){if(typeof e.schemaVersion!="number"||!Number.isFinite(e.schemaVersion))return null;const n=Os(e.title,Oh);if(!n||!Array.isArray(e.blocks))return null;const r=Os(e.skill,aa),s=Os(e.summary,Fh),i=Os(e.generatedAt,aa);return{schemaVersion:e.schemaVersion,title:n,...r?{skill:r}:{},...s?{summary:s}:{},...i?{generatedAt:i}:{},blocks:e.blocks.slice(0,Ph).map(Uh),suggestions:fd(e.suggestions,Dh,Wh),sources:fd(e.sources,$h,Bh),original:e}}function Gh(e,n=!0){const r=e.trim();if(!n||r.length===0||r.length>Fu||r.startsWith("```"))return null;let s;try{s=JSON.parse(r)}catch{return null}if(!jl(s)&&!Array.isArray(s))return null;if(jl(s)){const i=Hh(s);if(i)return{kind:"envelope",raw:r,value:i}}return{kind:"json",raw:r,value:s}}function gd(e){const n=e.trim(),r=qh[n.toLowerCase()];if(r)return r;const s=n.match(/^\/project\s+([a-z0-9-]+)$/i);return s?`查看项目:${s[1]}`:n}const Vh=40,hd=8;function Qh(e){return Array.isArray(e)?e.map((n,r)=>[String(r),n]):Object.entries(e)}function Kh({value:e}){return e===null?t.jsx("span",{className:"json-tree__value json-tree__value--null",children:"null"}):typeof e=="boolean"?t.jsx("span",{className:"json-tree__value json-tree__value--boolean",children:String(e)}):typeof e=="number"?t.jsx("span",{className:"json-tree__value json-tree__value--number",children:e}):t.jsxs("span",{className:"json-tree__value json-tree__value--string",children:[t.jsx("span",{"aria-hidden":"true",children:'"'}),e,t.jsx("span",{"aria-hidden":"true",children:'"'})]})}function ql({value:e,label:n,depth:r=0}){const[s,i]=c.useState(!1);if(e===null||typeof e!="object")return t.jsxs("div",{className:"json-tree__row",children:[n!==void 0&&t.jsx("span",{className:"json-tree__key",children:n}),n!==void 0&&t.jsx("span",{className:"json-tree__separator",children:":"}),t.jsx(Kh,{value:e})]});const o=Qh(e),l=Array.isArray(e)?`数组 · ${o.length} 项`:`对象 · ${o.length} 项`;if(r>=hd)return t.jsxs("div",{className:"json-tree__row json-tree__row--limit",children:[n!==void 0&&t.jsx("span",{className:"json-tree__key",children:n}),t.jsxs("span",{className:"json-tree__limit",children:[l,",已折叠至深度 ",hd]})]});const u=s?o:o.slice(0,Vh),d=o.length-u.length;return t.jsxs("details",{className:"json-tree",open:r===0,children:[t.jsxs("summary",{className:"json-tree__summary",children:[n!==void 0&&t.jsx("span",{className:"json-tree__key",children:n}),t.jsx("span",{className:"json-tree__container-label",children:l})]}),t.jsxs("div",{className:"json-tree__children",children:[o.length===0&&t.jsx("div",{className:"json-tree__empty",children:"空"}),u.map(([g,h])=>t.jsx(ql,{value:h,label:g,depth:r+1},g)),d>0&&t.jsxs("button",{type:"button",className:"json-tree__more",onClick:()=>i(!0),children:["显示其余 ",d," 项"]})]})]})}function Jh(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function qu({raw:e,onCopyFailed:n}){const r=async()=>{await ji(e)||n==null||n()};return t.jsxs("details",{className:"structured-agent-message__raw",children:[t.jsx("summary",{children:"查看原始 JSON"}),t.jsx("div",{className:"structured-agent-message__raw-toolbar",children:t.jsx("button",{type:"button",title:"复制原始 JSON","aria-label":"复制原始 JSON",onClick:()=>{r()},children:t.jsx(Si,{size:14,strokeWidth:1.8,"aria-hidden":"true"})})}),t.jsx("pre",{children:Jh(e)})]})}function Yh({envelope:e,raw:n,renderText:r,suggestionsEnabled:s,onSuggestionSend:i,onCopyFailed:o}){return t.jsxs("section",{className:"structured-agent-message","data-kind":"envelope",children:[t.jsxs("header",{className:"structured-agent-message__header",children:[t.jsx("h3",{className:"structured-agent-message__title",children:e.title}),e.summary&&t.jsx("p",{className:"structured-agent-message__summary",children:e.summary})]}),t.jsx("div",{className:"structured-agent-message__blocks",children:e.blocks.map((l,u)=>l.kind==="text"?t.jsx("div",{className:"structured-agent-message__text","data-tone":l.tone??"body",children:r(l.text)},u):t.jsxs("details",{className:"structured-agent-message__unknown-block",children:[t.jsxs("summary",{children:[l.blockType," 内容"]}),t.jsx(ql,{value:l.value})]},u))}),e.suggestions.length>0&&t.jsx("div",{className:"structured-agent-message__suggestions","aria-label":"继续提问",children:e.suggestions.map(l=>t.jsx("button",{type:"button",className:"structured-agent-suggestion",disabled:!s,title:`发送 ${l}`,"aria-label":`${gd(l)},发送 ${l}`,onClick:()=>i(l),children:gd(l)},l))}),e.sources.length>0&&t.jsxs("details",{className:"structured-agent-message__details",children:[t.jsxs("summary",{children:["参考来源 ",e.sources.length]}),t.jsx("ul",{children:e.sources.map(l=>t.jsx("li",{children:l},l))})]}),t.jsxs("details",{className:"structured-agent-message__details",children:[t.jsx("summary",{children:"消息信息"}),t.jsxs("dl",{children:[t.jsxs("div",{children:[t.jsx("dt",{children:"格式版本"}),t.jsx("dd",{children:e.schemaVersion})]}),e.skill&&t.jsxs("div",{children:[t.jsx("dt",{children:"能力"}),t.jsx("dd",{children:e.skill})]}),e.generatedAt&&t.jsxs("div",{children:[t.jsx("dt",{children:"生成时间"}),t.jsx("dd",{children:e.generatedAt})]})]})]}),t.jsx(qu,{raw:n,onCopyFailed:o})]})}function Xh({message:e,renderText:n,suggestionsEnabled:r,onSuggestionSend:s,onCopyFailed:i}){return e.kind==="envelope"?t.jsx(Yh,{envelope:e.value,raw:e.raw,renderText:n,suggestionsEnabled:r,onSuggestionSend:s,onCopyFailed:i}):t.jsxs("section",{className:"structured-agent-message","data-kind":"json",children:[t.jsxs("div",{className:"structured-agent-message__data-title",children:[t.jsx(cg,{size:15,strokeWidth:1.8,"aria-hidden":"true"}),t.jsx("span",{children:"结构化数据"})]}),t.jsx(ql,{value:e.value}),t.jsx(qu,{raw:e.raw,onCopyFailed:i})]})}function Zh({text:e,complete:n,renderText:r,suggestionsEnabled:s,onSuggestionSend:i,onCopyFailed:o}){const l=c.useMemo(()=>Gh(e,n),[n,e]);return l?t.jsx(Xh,{message:l,renderText:r,suggestionsEnabled:s,onSuggestionSend:i,onCopyFailed:o}):t.jsx(t.Fragment,{children:r(e)})}function Ul(){const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Uu(){if(typeof window>"u")return null;const e=window.agentApi;return typeof(e==null?void 0:e.dictationStart)!="function"||typeof e.dictationStop!="function"||typeof e.onDictation!="function"||typeof e.onDictationError!="function"?null:e}function em(){return Uu()!==null||Ul()!==null}function tm(e){var o,l,u;const n=Uu();if(n){let d=!1,g=()=>{},h=()=>{};const p=()=>{var k;d||(d=!0,g(),h(),(k=e.onEnd)==null||k.call(e))};return g=n.onDictation(({text:k,isFinal:x})=>{const y=k.trim();x?(y&&e.onFinal(y),p()):y&&e.onInterim(y)}),h=n.onDictationError(k=>{var x;(x=e.onError)==null||x.call(e,k),p()}),n.dictationStart().then(k=>{var x,y;d||(k.ok?(y=e.onStart)==null||y.call(e):((x=e.onError)==null||x.call(e,k.reason||"无法启动语音识别"),p()))}).catch(()=>{var k;d||((k=e.onError)==null||k.call(e,"无法启动语音识别"),p())}),{stop:()=>{n.dictationStop().catch(()=>{var k;(k=e.onError)==null||k.call(e,"无法停止语音输入"),p()})},cancel:()=>{p(),n.dictationStop().catch(()=>{})}}}const r=Ul();if(!r)return(o=e.onError)==null||o.call(e,"当前环境不支持语音识别"),null;const s=new r;s.lang=e.lang??"zh-CN",s.continuous=!1,s.interimResults=!0;let i="";s.onresult=d=>{let g="";for(let h=d.resultIndex;h<d.results.length;h++){const p=d.results[h];p.isFinal?i+=p[0].transcript:g+=p[0].transcript}g&&e.onInterim(i+g)},s.onerror=d=>{var g;d.error!=="no-speech"&&d.error!=="aborted"&&((g=e.onError)==null||g.call(e,`语音识别失败:${d.error??"未知错误"}`))},s.onend=()=>{var d;i&&e.onFinal(i.trim()),(d=e.onEnd)==null||d.call(e)};try{s.start(),(l=e.onStart)==null||l.call(e)}catch{return(u=e.onEnd)==null||u.call(e),null}return{stop:()=>s.stop(),cancel:()=>{var d;s.onresult=null,s.onend=null,s.onerror=null,s.abort(),(d=e.onEnd)==null||d.call(e)}}}function nm(e){var l;const n=Ul();if(!n)return(l=e.onError)==null||l.call(e,"当前环境不支持语音唤醒"),null;let r=!1,s=null,i=null;const o=()=>{if(!r){s=new n,s.lang=e.lang??"zh-CN",s.continuous=!0,s.interimResults=!0,s.onresult=u=>{var h,p,k;const d=u.results[u.results.length-1],g=(p=(h=d==null?void 0:d[0])==null?void 0:h.transcript)==null?void 0:p.trim();g&&(d.isFinal&&((k=e.onHeard)==null||k.call(e,g)),g.includes(e.wakeWord)&&e.onWake(g))},s.onerror=u=>{var d;u.error==="not-allowed"&&((d=e.onError)==null||d.call(e,"麦克风权限被拒绝,语音唤醒已停用"),r=!0)},s.onend=()=>{r||(i=setTimeout(o,400))};try{s.start()}catch{i=setTimeout(o,800)}}};return o(),{stop:()=>{r=!0,i&&clearTimeout(i);try{s==null||s.abort()}catch{}}}}function Ki(){typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}function Qo(e,n){return n(),typeof(e==null?void 0:e.ttsStop)=="function"?e.ttsStop().then(()=>{}):Promise.resolve()}function rm(e){let n=null,r=null;const s=(l,u)=>{queueMicrotask(()=>{var d;return(d=o.onmessage)==null?void 0:d.call(o,{data:{type:l,generation:u}})})},i=(l,u)=>{if(r===l){r=null;for(const d of l.sources)d.onended=null,d.stop(),d.disconnect();l.sources.clear(),s(u,l.generation)}},o={onmessage:null,postMessage(l){const u=l;if(u.type==="start"){r&&i(r,"stopped"),r={generation:u.generation,sampleRate:u.sampleRate,until:e.currentTime,pendingSamples:0,finished:!1,sources:new Set};return}const d=r;if(!d||u.generation!==d.generation)return;if(u.type==="flush"){i(d,"stopped");return}if(u.type==="finish"){d.finished=!0,d.sources.size===0&&i(d,"drained");return}if(u.type!=="chunk"||d.finished)return;const g=u.samples;if(!(g instanceof Float32Array)||d.pendingSamples+g.length>d.sampleRate){i(d,"overflow");return}if(g.length===0)return;const h=e.createBuffer(1,g.length,d.sampleRate);h.copyToChannel(g,0);const p=e.createBufferSource();p.buffer=h,p.connect(n),d.sources.add(p),d.pendingSamples+=g.length,p.onended=()=>{p.disconnect(),r===d&&(d.sources.delete(p),d.pendingSamples-=g.length,d.finished&&d.sources.size===0&&i(d,"drained"))};const k=Math.max(d.until,e.currentTime+.02);d.until=k+h.duration,p.start(k)}};return{port:o,connect(l){n=l},disconnect(){r&&i(r,"stopped"),n=null}}}const sm={createContext:()=>new AudioContext,createNode:e=>new AudioWorkletNode(e,"pcm-stream-player",{numberOfInputs:0,numberOfOutputs:1,outputChannelCount:[1]}),workletUrl:"./pcm-audio-worklet.js",createFallbackNode:e=>rm(e)};function im(e){const n=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength%2!==0)throw new Error("PCM chunk contains an incomplete int16 sample");const r=new Float32Array(n.byteLength/2),s=new DataView(n.buffer,n.byteOffset,n.byteLength);for(let i=0;i<r.length;i+=1)r[i]=s.getInt16(i*2,!0)/32768;return r}class om{constructor(n,r=sm){this.api=n,this.dependencies=r,this.context=null,this.node=null,this.ready=null,this.current=null}prepare(){return this.ensureReady()}start(n){var s;this.current&&!this.current.acknowledged&&((s=this.node)==null||s.port.postMessage({type:"flush",generation:this.current.metadata.generation}));const r={metadata:n,pending:[],pendingSamples:0,finished:!1,acknowledged:!1};this.current=r,this.ensureReady().then(()=>{if(!(this.current!==r||!this.node)){this.node.port.postMessage({type:"start",generation:n.generation,sampleRate:n.sampleRate});for(const i of r.pending)this.postSamples(n.generation,i);r.pending=[],r.pendingSamples=0,r.finished&&this.node.port.postMessage({type:"finish",generation:n.generation})}}).catch(i=>this.fail(r,i))}enqueue(n,r){const s=this.current;if(!s||s.metadata.generation!==n||s.acknowledged)return;let i;try{i=im(r)}catch(o){this.fail(s,o);return}if(this.node){this.postSamples(n,i);return}if(s.pendingSamples+i.length>s.metadata.sampleRate){this.fail(s,new Error("TTS PCM queue overflow"));return}s.pending.push(i),s.pendingSamples+=i.length}finish(n){var s;const r=this.current;!r||r.metadata.generation!==n||r.acknowledged||(r.finished=!0,(s=this.node)==null||s.port.postMessage({type:"finish",generation:n}))}flush(n){var s;const r=this.current;!r||r.metadata.generation!==n||r.acknowledged||((s=this.node)==null||s.port.postMessage({type:"flush",generation:n}),r.pending=[],r.pendingSamples=0,this.acknowledge(r))}dispose(){var n,r;this.current&&this.flush(this.current.metadata.generation),(n=this.node)==null||n.disconnect(),this.node=null,(r=this.context)==null||r.close(),this.context=null,this.ready=null}ensureReady(){return this.ready?this.ready:(this.ready=(async()=>{const n=this.dependencies.createContext();this.context=n;const r=n.state!=="running"?n.resume():Promise.resolve();r.catch(()=>{});let s,i;try{if(await Promise.race([n.audioWorklet.addModule(this.dependencies.workletUrl),new Promise((o,l)=>{i=setTimeout(()=>l(new Error("TTS AudioWorklet initialization timed out")),this.dependencies.workletTimeoutMs??1500)})]),this.context!==n)return;s=this.dependencies.createNode(n)}catch(o){if(this.context!==n)return;if(!this.dependencies.createFallbackNode)throw o;s=this.dependencies.createFallbackNode(n)}finally{clearTimeout(i)}s.port.onmessage=o=>this.onWorkletMessage(o.data),s.connect(n.destination),this.node=s,await r})(),this.ready)}postSamples(n,r){var s;(s=this.node)==null||s.port.postMessage({type:"chunk",generation:n,samples:r},[r.buffer])}onWorkletMessage(n){const r=this.current;if(!(!r||n.generation!==r.metadata.generation)){if(n.type==="drained"||n.type==="stopped"){this.acknowledge(r);return}n.type==="overflow"&&this.fail(r,new Error("TTS AudioWorklet buffer overflow"))}}fail(n,r){this.current!==n||n.acknowledged||(console.error("[tts] PCM playback failed",r),n.acknowledged=!0,this.current=null,this.api.ttsStop(),this.api.ttsPlaybackEnded(n.metadata.generation))}acknowledge(n){this.current!==n||n.acknowledged||(n.acknowledged=!0,this.current=null,this.api.ttsPlaybackEnded(n.metadata.generation))}}const pr=50;async function am(e,n,r,s=50){var u;const i=d=>e.getSession(n,{view:"trace",revision:d,turnId:r.turnId});try{return{detail:await i(r.revision),revision:r.revision,recovered:!1}}catch(d){if(d.code!=="STALE_SESSION_ANCHOR")throw d}const o=await e.getSession(n,{view:"core",limit:s}),l=(u=o==null?void 0:o.history)==null?void 0:u.revision;if(!l)throw new Error("会话内容已更新,请刷新后重试");return{detail:await i(l),revision:l,recovered:!0}}async function bi(e,n,r,s,i,o,l){if(r!=="codex"){const d=l?await l():await e.getSession(n,s);o()&&i(d,"full");return}const u=l?await l():await e.getSession(n,{...s,view:"core"});o()&&i(u,"core")}function lm(e,n,r){var i,o;const s=((i=n==null?void 0:n.history)==null?void 0:i.nextCursor)??null;return((o=n==null?void 0:n.history)==null?void 0:o.hasMore)===!1||!s||r===0&&s===e?null:s}function cm(e,n,r,s){const i=r==="core"&&(s==null?void 0:s.delivery)!=="legacy-full"&&!!(s!=null&&s.revision),o=e.some(l=>!l.isQueued);return i&&o?dm(e,n):Gu(e,n)}function md(e,n,r,s,i){const o=(i==null?void 0:i.kind)==="anchored"?e.filter(l=>l.isQueued):uo(e);return{messages:cm(o,n,r,s),window:{kind:"latest",olderCursor:(i==null?void 0:i.kind)==="latest"&&o.some(l=>!l.isQueued)?i.olderCursor:(s==null?void 0:s.nextCursor)??null}}}function xd(e,n,r){const s=uo(e),i=new Set(s.map(l=>l.id)),o=uo(n).filter(l=>!i.has(l.id));return o.length===0?s:r==="older"?[...o,...s]:[...s,...o]}function dm(e,n){var C,A;if(n.length===0)return e;if(e.length===0)return n;let r=e.filter(L=>!L.isQueued);const s=e.filter(L=>L.isQueued),i=n.findLastIndex(L=>L.role==="user"&&!L.isCompactionSummary);if(i<0)return e;const o=n[i],l=r.findIndex(L=>L.role==="user"&&L.id===o.id);let u=l>=0?l:r.findLastIndex(L=>L.role==="user"&&!L.isCompactionSummary&&Zn(L)===Zn(o));if(u<0)return[...r,...n.slice(i),...s];const d=(r[u].sendState||r[u].awaitingHistory)&&Vu(r,n,Qu(r,n,Math.max(0,r.length-n.length))??0,u),g=Gu(r.slice(0,u),n.slice(0,i));r=[...g,...r.slice(u)],u=g.length;const h=r.findIndex((L,z)=>z>u&&L.role==="user"&&!L.isCompactionSummary),p=h<0?r.length:h,k=[];for(let L=u+1;L<p;L+=1)bd(r[L])&&k.push(L);const x=n.slice(i+1).filter(bd),y=(A=(C=n.find(L=>L.executionTrace))==null?void 0:C.executionTrace)==null?void 0:A.revision,S=r.map(L=>L.executionTrace&&y?{...L,executionTrace:{...L.executionTrace,revision:y}}:L);S[u]={...S[u],presentation:xl(S[u].presentation,o.presentation)},d&&(S[u]={...S[u],id:o.id.startsWith("history-message.v1.")?o.id:S[u].id,sendState:void 0,awaitingHistory:void 0});const v=n.slice(i+1).find(L=>L.executionTrace),w=r.findIndex((L,z)=>{var R,N;return z>u&&z<p&&((R=L.executionTrace)==null?void 0:R.turnId)===((N=v==null?void 0:v.executionTrace)==null?void 0:N.turnId)});if(v&&w>=0){const L=r[w].executionTrace;S[w]={...v,id:r[w].id,timestamp:r[w].timestamp,executionTrace:{...v.executionTrace,...L!=null&&L.liveMessages?{liveMessages:L.liveMessages}:{}}}}const j=Math.min(k.length,x.length);for(let L=0;L<j;L+=1){const z=k[L],R=S[z],N=x[L];S[z]={...R,...N,id:N.id.startsWith("history-message.v1.")?N.id:R.id,timestamp:R.timestamp,images:N.images??R.images,presentation:xl(R.presentation,N.presentation)}}return x.length>j&&S.splice(p,0,...x.slice(j)),[...S,...s]}function bd(e){var n,r,s;return e.role==="assistant"&&!e.executionTrace&&!((n=e.toolCalls)!=null&&n.length)&&!e.askUser&&!e.isCompactionSummary&&!((s=(r=e.presentation)==null?void 0:r.reasoning)!=null&&s.length)}function Ds(e){var i,o;const n=((i=e==null?void 0:e.history)==null?void 0:i.delivery)==="core",r=Hu(e,!n),s=(o=e==null?void 0:e.history)==null?void 0:o.revision;return!n||!s?r:mm(Wg(r,s),(e==null?void 0:e.events)??[])}function yd(e,n,r){return(e==="deepseek-harness"||e==="codex")&&n===r}function um(e){return Hu(e).filter($g)}function Hu(e,n=!0){var k;const r=(e==null?void 0:e.messages)??[],s=(e==null?void 0:e.events)??[],i=new Set(s.filter(x=>x.type==="approval_resolved"&&x.questionId).map(x=>x.questionId)),o=new Map;for(const x of s)x.type==="tool_result"&&x.result&&"toolCallId"in x.result&&x.result.toolCallId&&o.set(x.result.toolCallId,{content:x.result.content??"",isError:x.result.isError});const l=r.filter(x=>(x.role==="user"||x.role==="assistant"||x.role==="tool")&&x.name!=="__interrupt__").map(hm),u=new Map;for(const x of l)x.role==="tool"&&x.toolCallId&&u.set(x.toolCallId,x);let d=l.filter(x=>x.role!=="tool").map(x=>{var y;if(x.isCompactionSummary)return x;if(x.role==="assistant"&&((y=x.toolCalls)!=null&&y.length)){const S=x.toolCalls.filter(v=>v.name!=="ask_user");return S.length===0&&!x.content.trim()?null:{...x,toolCalls:S.map(v=>{const w=u.get(v.id);if(w)return{...v,...w.toolResultRef?{resultRef:w.toolResultRef,isError:w.toolResultRef.isError}:{result:w.content}};const j=o.get(v.id);return j?{...v,result:j.content,isError:j.isError}:v})}}return x.role==="user"&&x.name&&x.name!=="__compaction_checkpoint__"&&!x.name.startsWith("__native_")?{...x,agentName:x.name}:x}).filter(x=>x!==null);const g=((k=e==null?void 0:e.history)==null?void 0:k.delivery)==="core"?s.filter(x=>x.type==="text_chunk"&&x.messagePhase==="final_answer"):s,h=xm(g,n);if(!d.some(x=>x.role==="assistant"&&!x.isCompactionSummary)&&h){const x=d.findLastIndex(y=>y.role==="user"&&!y.isCompactionSummary);d=x>=0?[...d.slice(0,x+1),h,...d.slice(x+1)]:[...d,h]}const p=new Set(d.flatMap(x=>{var y;return(y=x.askUser)!=null&&y.questionId?[x.askUser.questionId]:[]}));for(const x of s)x.type!=="ask_user"||!x.questionId||i.has(x.questionId)||p.has(x.questionId)||(p.add(x.questionId),d.push({id:`question:${x.questionId}`,role:"assistant",content:"",askUser:{questionId:x.questionId,question:x.question??"",options:x.options,fields:x.fields,multiSelect:x.multiSelect},timestamp:Date.now()}));return d}function Gu(e,n){if(n.length===0)return e;if(e.length===0)return n;const r=e.map(Sl),s=n.map(Sl),i=Math.max(0,e.length-n.length),o=Qu(e,n,i);let l={currentStart:i,length:0,distance:1/0};for(let y=0;y<r.length;y++)for(let S=0;S<s.length;S++){if(r[y]!==s[S])continue;const v=y-S;if(v<0)continue;let w=0;for(;y+w<r.length&&S+w<s.length&&r[y+w]===s[S+w];)w+=1;const j=Math.abs(v-i);(w>l.length||w===l.length&&j<l.distance)&&(l={currentStart:v,length:w,distance:j})}const u=o??(l.length>0?l.currentStart:i),d=n.map((y,S)=>{var A,L,z;const v=e[u+S];if(!v||!gm(v,y,s[S]))return y;const w=(L=(A=y.presentation)==null?void 0:A.attachments)==null?void 0:L.some(R=>R.dataUrl),j=(z=y.toolCalls)==null?void 0:z.map(R=>{var T;const N=(T=v.toolCalls)==null?void 0:T.find(F=>F.id===R.id);return(N==null?void 0:N.result)===void 0?R:{...R,result:N.result,isError:N.isError}}),C=pm(v,y);return{...C,id:y.id.startsWith("history-message.v1.")?y.id:v.id,timestamp:v.timestamp,images:w?void 0:y.images??v.images,presentation:xl(v.presentation,C.presentation),...j?{toolCalls:j}:{}}}),g=e.filter(y=>y.isQueued),h=e.slice(u).filter(y=>!y.isQueued),p=fm(h,d),k=e.findLastIndex((y,S)=>S>=u&&y.role==="user"&&(y.awaitingHistory||y.sendState==="pending"||y.sendState==="failed")&&!y.isQueued&&!Vu(e,d,u,S)),x=k<0?[]:e.slice(k).filter(y=>!y.isQueued);return[...e.slice(0,u).filter(y=>!y.isQueued),...p,...x,...g]}function Vu(e,n,r,s){const i=e[s];if(!i||i.role!=="user")return!1;if(n.some(d=>d.id===i.id))return!0;const o=Zn(i),l=e.slice(r,s+1).filter(d=>d.role==="user"&&!d.isQueued&&Zn(d)===o).length;return n.filter(d=>d.role==="user"&&Zn(d)===o).length>=l}function pm(e,n){var o,l;const r=(o=n.presentation)==null?void 0:o.attachments,s=(l=e==null?void 0:e.presentation)==null?void 0:l.attachments;if(!(r!=null&&r.length)||!(s!=null&&s.length)||r.every(u=>u.dataUrl||u.unavailable))return n;const i=r.map(u=>{if(u.dataUrl||u.unavailable||!u.omitted)return u;const d=s.find(g=>g.name===u.name&&g.dataUrl);return d?{...u,dataUrl:d.dataUrl,omitted:void 0}:u});return{...n,presentation:{...n.presentation,attachments:i}}}function fm(e,n){const r=n.findLastIndex(y=>y.role==="user"&&!y.isQueued);if(r<0)return n;const s=Zn(n[r]);let i=-1,o=1/0;for(let y=0;y<e.length;y+=1){const S=e[y];if(S.role!=="user"||S.isQueued||Zn(S)!==s)continue;const v=Math.abs(y-r);v<o&&(i=y,o=v)}if(i<0)return n;const l=e.findIndex((y,S)=>S>i&&y.role==="user"&&!y.isQueued),u=e.slice(i+1,l<0?e.length:l),d=n.slice(r+1),g=vd(u),h=vd(d);if(g.length<=h.length||!g.startsWith(h))return n;const p=g.slice(h.length),k=n.findLastIndex((y,S)=>{var v;return S>r&&y.role==="assistant"&&!((v=y.toolCalls)!=null&&v.length)&&!y.askUser&&!y.isCompactionSummary});if(k>=0)return n.map((y,S)=>S===k?{...y,content:y.content+p}:y);const x=u.findLast(y=>y.role==="assistant"&&!!y.content&&!y.isCompactionSummary);return[...n,{id:(x==null?void 0:x.id)??crypto.randomUUID(),role:"assistant",content:p,timestamp:(x==null?void 0:x.timestamp)??Date.now()}]}function vd(e){return e.filter(n=>n.role==="assistant"&&!n.isCompactionSummary).map(n=>n.content).join("")}function Qu(e,n,r){const s=n[0];if((s==null?void 0:s.role)!=="user")return null;const i=Zn(s);let o=null;for(let l=0;l<e.length;l+=1){if(e[l].role!=="user"||e[l].isQueued||Zn(e[l])!==i)continue;const u=Math.abs(l-r);(!o||u<o.distance)&&(o={start:l,distance:u})}return(o==null?void 0:o.start)??null}function gm(e,n,r){var s,i;return Sl(e)===r||e.role==="assistant"&&n.role==="assistant"&&e.content===n.content&&JSON.stringify(((s=e.toolCalls)==null?void 0:s.map(o=>o.id))??[])===JSON.stringify(((i=n.toolCalls)==null?void 0:i.map(o=>o.id))??[])?!0:e.role==="user"&&n.role==="user"&&Zn(e)===Zn(n)}function Zn(e){var n;return JSON.stringify({role:e.role,content:e.content,name:(n=e.name)!=null&&n.startsWith("__native_")?void 0:e.name,agentName:e.agentName,isCompactionSummary:e.isCompactionSummary})}function Sl(e){return JSON.stringify({role:e.role,content:e.content,toolCalls:e.toolCalls,toolCallId:e.toolCallId,toolResultRef:e.toolResultRef,name:e.name,agentName:e.agentName,presentation:e.role==="user"?void 0:e.presentation,isCompactionSummary:e.isCompactionSummary})}function hm(e){var n,r,s,i;if(e.name==="__compaction_checkpoint__"){let o="";try{o=JSON.parse(e.content??"{}").summary??""}catch{}return{id:crypto.randomUUID(),role:"user",content:o,name:e.name,isCompactionSummary:!0,timestamp:Date.now()}}return{id:(e.role==="assistant"?(n=e.presentation)==null?void 0:n.nativeMessageId:void 0)??e.historyId??crypto.randomUUID(),role:e.role,content:e.content??"",toolCalls:(r=e.toolCalls)!=null&&r.length?e.toolCalls:void 0,toolCallId:e.toolCallId,toolResultRef:e.toolResultRef,name:e.name,...(s=e.name)!=null&&s.startsWith("__native_steered:")||e.name==="__native_steering_pending"?{isSteered:!0}:{},presentation:e.presentation,...(i=e.presentation)!=null&&i.question?{askUser:{...e.presentation.question,answered:e.presentation.question.status==="answered",cancelled:e.presentation.question.status==="cancelled"}}:{},timestamp:Date.now()}}function mm(e,n){return n.reduce((r,s)=>{if(!s.turnId)return r;let i=null;return s.type==="text_chunk"&&s.messagePhase==="commentary"&&typeof s.text=="string"&&s.text?i={type:"text_chunk",text:s.text,turnId:s.turnId,itemId:s.itemId,messagePhase:"commentary"}:s.type==="reasoning_summary_delta"&&s.itemId&&Number.isSafeInteger(s.sectionIndex)&&typeof s.delta=="string"?i={type:"reasoning_summary_delta",turnId:s.turnId,itemId:s.itemId,sectionIndex:s.sectionIndex,delta:s.delta}:s.type==="tool_call"&&s.toolCall?i={type:"tool_call",turnId:s.turnId,toolCall:s.toolCall}:s.type==="tool_result"&&s.result&&"toolCallId"in s.result&&s.result.toolCallId&&(i={type:"tool_result",turnId:s.turnId,result:{toolCallId:s.result.toolCallId,content:s.result.content??"",isError:s.result.isError}}),i?sa(r,s.turnId,i):r},e)}function xm(e,n=!0){let r="";const s=[],i=new Map;for(const o of e){if(o.type==="text_chunk"&&o.text&&(r+=o.text),n&&o.type==="tool_call"&&o.toolCall){const l={id:o.toolCall.id,name:o.toolCall.name,arguments:o.toolCall.arguments};s.push(l),i.set(l.id,l)}if(n&&o.type==="tool_result"&&o.result&&"toolCallId"in o.result&&o.result.toolCallId){const l=i.get(o.result.toolCallId);l&&(l.result=o.result.content??"",l.isError=o.result.isError)}}return!r.trim()&&s.length===0?null:{id:crypto.randomUUID(),role:"assistant",content:r.trim(),toolCalls:s.length>0?s:void 0,timestamp:Date.now()}}class bm{constructor(){this.slot=null}prefetch(n,r,s){return this.getOrStart(n,r,s).promise}async consume(n,r,s){const i=this.getOrStart(n,r,s);try{return await i.promise}finally{this.slot===i&&(this.slot=null)}}invalidate(){this.slot=null}getOrStart(n,r,s){var l;if(((l=this.slot)==null?void 0:l.sessionId)===n&&this.slot.cursor===r)return this.slot;let i;try{i=s()}catch(u){i=Promise.reject(u)}const o={sessionId:n,cursor:r,promise:i};return this.slot=o,i.catch(()=>{this.slot===o&&(this.slot=null)}),o}}function ym(e,n){const r=globalThis.setInterval(()=>{n()&&e()},2e3);return()=>globalThis.clearInterval(r)}class vm{constructor(){this.generations=new Map}capture(n){const r=this.generations.get(n)??0;return()=>(this.generations.get(n)??0)===r}invalidate(n){this.generations.set(n,(this.generations.get(n)??0)+1)}}function wm(e){const n=/^关于“([\s\S]+?)”的回答:\r?\n([\s\S]+)$/.exec(e);if(n)return n[1].trim()&&n[2].trim()?[{question:n[1],answer:n[2]}]:[];const r=/^\s*<send_user_message_question_reply>\s*([\s\S]*?)\s*<\/send_user_message_question_reply>\s*$/.exec(e);if(!r)return[];try{const s=JSON.parse(r[1]);if(!Array.isArray(s)||s.length===0)return[];const i=[];for(const o of s){if(!o||typeof o!="object")return[];const{questionItemId:l,question:u,answer:d}=o;if(typeof l!="string"||typeof u!="string"||!u.trim()||typeof d!="string"||!d.trim())return[];const g=JSON.parse(l);if(!Array.isArray(g)||g.length!==3||g[0]!=="request_user_input_async"||typeof g[1]!="string"||!g[1].trim()||!Number.isSafeInteger(g[2])||g[2]<0)return[];i.push({question:u,answer:d,itemId:g[1],questionIndex:g[2]})}return i}catch{return[]}}function jm(e,n,r){return e.question!==r||!n.includes(":async:")?!1:e.itemId===void 0||n.endsWith(`:async:${e.itemId}:${e.questionIndex}`)}function Sm(e,n){const r=km(e);if(!n)return r;const s=[...r],i=new Map,o=new Set;return r.forEach((l,u)=>{var h,p,k;if(l.role!=="user"||l.askUser||l.isQueued||l.isCompactionSummary||(h=l.images)!=null&&h.length||(k=(p=l.presentation)==null?void 0:p.attachments)!=null&&k.length)return;const d=wm(l.content);if(!d.length)return;const g=[];d.forEach((x,y)=>{var v;const S=r.findLastIndex((w,j)=>{const C=w.askUser;return C&&!o.has(j)&&(x.itemId!==void 0||j<u)&&jm(x,C.questionId,C.question)&&(!C.answered||!C.answer||C.answer==="已处理"||C.answer.trim()===x.answer.trim())});if(S>=0){o.add(S);const w=s[S];(!((v=w.askUser)!=null&&v.answered)||w.askUser.answer!==x.answer)&&(s[S]={...w,askUser:{...w.askUser,answered:!0,answer:x.answer}});return}g.push({...l,id:y===0?l.id:`${l.id}:question-reply:${y}`,askUser:{questionId:`answered-history:${l.id}:${y}`,question:x.question,answered:!0,answer:x.answer}})}),d.length===1&&g.length===1&&(g[0].askUser.questionId=`answered-history:${l.id}`),i.set(u,g)}),s.flatMap((l,u)=>i.get(u)??[l])}function km(e){var s,i,o,l;const n=new Map;for(let u=0;u<e.length;u+=1){const d=e[u];if(d.role!=="user"||d.isQueued||(s=d.images)!=null&&s.length||(o=(i=d.presentation)==null?void 0:i.attachments)!=null&&o.length)continue;const g=n.get(d.content)??[];g.push(u),n.set(d.content,g)}const r=new Set;for(let u=0;u<e.length;u+=1){const d=e[u].askUser;if(!(d!=null&&d.answered)||!d.questionId.includes(":async:")||!((l=d.answer)!=null&&l.trim()))continue;const g=`关于“${d.question}”的回答:
|
|
137
|
+
${d.answer.trim()}`,h=n.get(g),p=h==null?void 0:h.find(k=>k>u&&!r.has(k));p!==void 0&&r.add(p)}return e.filter((u,d)=>!r.has(d))}const Ku=60,Im=32,Cm=240,Em=6,Rm=10;function wd(e,n,r,s){if(s<=1||r<=0)return 0;const i=Math.max(0,Math.min(1,(e-n)/r));return Math.round(i*(s-1))}function Nm(e){const n=Math.min(Math.max(0,e),Ku);return n<=1?n===1?[0]:[]:Array.from({length:n},(r,s)=>Math.round(s/(n-1)*(e-1)))}function jd(e,n=Em){return Math.min(Cm,Math.max(Im,Math.min(Math.max(0,e),Ku)*n))}function Tm(e,n,r){if(r<=0)return null;const s=Math.max(5,Math.round(r/10));return n==="ArrowUp"||n==="ArrowLeft"?Math.max(0,e-1):n==="ArrowDown"||n==="ArrowRight"?Math.min(r-1,e+1):n==="PageUp"?Math.max(0,e-s):n==="PageDown"?Math.min(r-1,e+s):n==="Home"?0:n==="End"?r-1:null}function Am({entries:e,activeMessageId:n,loadingMessageId:r,onActivate:s}){const i=e.findIndex(v=>v.messageId===n),o=i>=0?i:Math.max(0,e.length-1),[l,u]=c.useState(o),[d,g]=c.useState(!1),h=c.useRef(!1),p=c.useMemo(()=>Nm(e.length),[e.length]);if(c.useEffect(()=>u(o),[o]),e.length<2)return null;const k=Math.min(l,e.length-1),x=e[k],y=r===x.messageId,S=(v,w)=>{const j=w.getBoundingClientRect();u(wd(v,j.top,j.height,e.length))};return t.jsxs("div",{className:`query-navigation-rail${d?" query-navigation-rail--open":""}`,style:{"--query-navigation-rail-height":`${jd(e.length)}px`,"--query-navigation-rail-web-height":`${jd(e.length,Rm)}px`},role:"slider",tabIndex:0,"aria-label":"用户消息导航","aria-orientation":"vertical","aria-valuemin":1,"aria-valuemax":e.length,"aria-valuenow":x.ordinal,"aria-valuetext":`第 ${x.ordinal} 条:${x.preview}`,"aria-busy":y||void 0,onPointerEnter:v=>{g(!0),S(v.clientY,v.currentTarget)},onPointerMove:v=>{v.pointerType==="touch"&&!h.current||S(v.clientY,v.currentTarget)},onPointerLeave:()=>{h.current||g(!1)},onPointerDown:v=>{h.current=!0,g(!0),v.currentTarget.setPointerCapture(v.pointerId),S(v.clientY,v.currentTarget)},onPointerUp:v=>{S(v.clientY,v.currentTarget);const w=wd(v.clientY,v.currentTarget.getBoundingClientRect().top,v.currentTarget.getBoundingClientRect().height,e.length);h.current=!1,v.currentTarget.releasePointerCapture(v.pointerId),s(e[w]),v.pointerType==="touch"&&g(!1)},onPointerCancel:()=>{h.current=!1,g(!1)},onFocus:()=>g(!0),onBlur:()=>g(!1),onKeyDown:v=>{if(v.key==="Enter"){v.preventDefault(),s(x);return}const w=Tm(k,v.key,e.length);w!==null&&(v.preventDefault(),u(w))},children:[t.jsxs("div",{className:"query-navigation-rail__track","aria-hidden":"true",children:[p.map(v=>t.jsx("span",{className:`query-navigation-rail__tick${v===k?" is-selected":""}${e[v].messageId===n?" is-active":""}`},v)),t.jsx("span",{className:"query-navigation-rail__marker",style:{top:`${k/Math.max(1,e.length-1)*100}%`}})]}),y&&t.jsx("span",{className:"query-navigation-rail__loading",role:"status","aria-label":"正在定位消息",children:t.jsx(bt,{size:14,"aria-hidden":"true"})}),d&&t.jsxs("div",{className:"query-navigation-rail__preview",role:"status",children:[t.jsxs("span",{children:[x.ordinal," / ",e.length]}),t.jsx("p",{children:x.preview})]})]})}const _m=/^(?:load failed|failed to fetch|network request failed|networkerror when attempting to fetch resource\.?|the network connection was lost\.?|fetch failed)$/i;function Ju(e){return e instanceof Error&&e.name!=="AbortError"&&_m.test(e.message.trim())}function Mm(e){return Ju(e)?"网络连接中断,会话加载失败,请重新加载":e instanceof Error?e.message:"会话加载失败"}async function Lm(e,n={}){const r=Math.max(1,Math.floor(n.maxAttempts??4)),s=Math.max(0,n.baseDelayMs??500),i=n.sleep??(o=>new Promise(l=>{setTimeout(l,o)}));for(let o=1;o<=r;o+=1)try{return await e()}catch(l){if(o===r||!Ju(l))throw l;await i(s*2**(o-1))}throw new Error("会话加载失败")}function Sd(e){return(e==null?void 0:e.agentType)==="zcode"&&e.occupancy==="owned-externally"&&e.status==="running"&&e.readOnly!==!0&&e.externalGuideSupported===!0}function zm(e){return e==="customer-agent"||e==="codex"||e==="claude-code"||e==="deepseek-harness"||e==="opencode"||e==="copilot"||e==="zcode"}function kd(e){return e==="deepseek-harness"||e==="copilot"}function Id(e){return e!=null&&e.length?[...e]:void 0}function Pm(e){const n=Id(e.agentIds),r=Id(e.images);return{text:e.text.trim()||(r?"请查看图片。":""),origin:"composer",applyGoalMode:!0,clearComposer:!0,restoreDraftOnFailure:!0,...n?{agentIds:n}:{},...e.agentName?{agentName:e.agentName}:{},...r?{images:r}:{}}}function Qa(e,n){return{text:e.text?e.text===n.content||e.text.startsWith(`${n.content}
|
|
138
|
+
|
|
139
|
+
`)?e.text:`${n.content}
|
|
140
|
+
|
|
141
|
+
${e.text}`:n.content,images:[...new Set([...n.images??[],...e.images])]}}function Dm(e){return{text:e.trim(),origin:"suggestion",applyGoalMode:!1,clearComposer:!1,restoreDraftOnFailure:!1}}const Wm="agentroam:draft:";function la(e){return`${Wm}${e}`}function Ko(e){if(!e||typeof window>"u")return"";try{return window.localStorage.getItem(la(e))??""}catch{return""}}function dn(e,n){if(!(!e||typeof window>"u"))try{n?window.localStorage.setItem(la(e),n):window.localStorage.removeItem(la(e))}catch{}}function Zr(e){if(!(!e||typeof window>"u"))try{window.localStorage.removeItem(la(e))}catch{}}function $m(e,n,r){return n?e!==n?{type:"restore",ownerSessionId:n}:{type:"persist",ownerSessionId:n,value:r}:{type:"inactive",ownerSessionId:null}}function Bm(e){var n;return((n=[...e].reverse().find(r=>r.role==="user"&&!r.isQueued))==null?void 0:n.id)??null}function Om(e){var n;return((n=[...e].reverse().find(r=>r.role==="user"&&!r.isQueued&&r.sendState==="pending"))==null?void 0:n.id)??null}function Fm(e,n){const r=new Set(n.flatMap(s=>s.sourceMessageId?[s.sourceMessageId]:[]));return r.size===0?e:e.filter(s=>!r.has(s.id))}function qm(e,n,r=Date.now()){const s=e.findIndex(l=>l.id===n);if(s<0)return e;const o={...e[s],timestamp:r,isQueued:!1,isSteering:void 0,isSteered:!0,queueItemId:void 0,sendState:void 0};return[...e.slice(0,s),...e.slice(s+1),o]}function Um(e,n,r){var o,l,u;const s=e.findLastIndex(d=>{var g;return d.role==="user"&&((g=d.presentation)==null?void 0:g.executionTrace)}),i=(u=(l=(o=e[s])==null?void 0:o.presentation)==null?void 0:l.executionTrace)==null?void 0:u.turnId;return!i||e.slice(s+1).some(d=>d.role==="user"&&d.id!==r&&d.queueItemId!==n.id)||e.some(d=>{var g,h;return d.role==="assistant"&&((h=(g=d.presentation)==null?void 0:g.forkPoint)==null?void 0:h.turnId)===i})?-1:e.findIndex(d=>{var g,h,p;return d.role==="user"&&((h=(g=d.presentation)==null?void 0:g.executionTrace)==null?void 0:h.turnId)===i&&(d.presentation.executionTrace.segmentIndex??0)===0&&d.content===n.objective&&(d.agentName===void 0||d.agentName===((p=n.messagePayload)==null?void 0:p.agentName))})}function Ka(e,n){var p,k,x;const r=n.history.filter(y=>y.kind==="message"&&y.status==="completed"),s=new Map(r.map(y=>[y.sourceMessageId||y.id,y]));let i=e.flatMap(y=>{if(!y.isQueued)return[y];const S=s.get(y.id)??r.find(w=>w.id===y.queueItemId);return S?e.some(w=>w!==y&&!w.isQueued&&w.role==="user"&&(w.id===S.sourceMessageId||w.queueItemId===S.id||w.content===S.objective&&w.timestamp>=y.timestamp))?[]:[{...y,isQueued:!1,queueItemId:void 0,sendState:void 0}]:[]});const o=new Set(i.filter(y=>y.role==="user"&&y.isSteered).map(y=>y.id)),l=new Map(e.filter(y=>y.isQueued&&y.queueItemId).map(y=>[y.queueItemId,y])),u=((p=n.active)==null?void 0:p.kind)==="message"&&!o.has(n.active.sourceMessageId||n.active.id)?n.active:null;if(u){const y=l.get(u.id),S=u.sourceMessageId||(y==null?void 0:y.id)||u.id,v=y?-1:Um(i,u,S),w=i.findLastIndex(R=>R.role==="user"),j=v>=0?v:i.findLastIndex((R,N)=>{var T;return R.id===S||R.queueItemId===u.id||!y&&N===w&&R.role==="user"&&!((T=R.presentation)!=null&&T.executionTrace)&&R.content===u.objective}),C=j>=0?i[j]:y,A=y??i.find(R=>R.id===S),L=j>=0&&i.slice(j+1).some(R=>R.role==="assistant"),z={...C??{},id:(C==null?void 0:C.id)||S,role:"user",content:u.objective,timestamp:(C==null?void 0:C.timestamp)??u.createdAt,agentName:(C==null?void 0:C.agentName)??(A==null?void 0:A.agentName)??((k=u.messagePayload)==null?void 0:k.agentName),images:(C==null?void 0:C.images)??(A==null?void 0:A.images)??((x=u.messagePayload)==null?void 0:x.images),isQueued:!1,queueItemId:void 0,...C&&"sendState"in C?{sendState:C.sendState}:L?{}:{sendState:"pending"}};j>=0?i[j]=z:i.push(z),v>=0&&(i=i.filter((R,N)=>{var T;return N===v||R.role!=="user"||((T=R.presentation)==null?void 0:T.executionTrace)||R.content!==u.objective||R.id!==S&&R.queueItemId!==u.id}))}const d=n.queued.filter(y=>y.kind==="message"&&!o.has(y.sourceMessageId||y.id)).map(y=>{var v,w;const S=l.get(y.id);return{...S??{},id:y.sourceMessageId||(S==null?void 0:S.id)||y.id,role:"user",content:y.objective,timestamp:(S==null?void 0:S.timestamp)??y.createdAt,agentName:(v=y.messagePayload)==null?void 0:v.agentName,images:(w=y.messagePayload)==null?void 0:w.images,isQueued:!0,queueItemId:y.id}}),g=new Set([n.active,...n.queued,...n.history].flatMap(y=>y?[y.id,y.sourceMessageId].filter(Boolean):[])),h=e.filter(y=>y.isQueued&&(!y.queueItemId||y.isSteering)&&!g.has(y.id)&&!g.has(y.queueItemId)&&!i.some(S=>S.id===y.id));return[...i,...d,...h]}function Cd(e){var n;return{active:((n=e.active)==null?void 0:n.kind)==="message"?null:e.active,queued:e.queued.filter(r=>r.kind!=="message"),history:e.history.filter(r=>r.kind!=="message")}}function Hm(e,n,r){if(n===r)return e;const s=e.filter(g=>g.isQueued),i=s.findIndex(g=>g.id===n),o=s.findIndex(g=>g.id===r);if(i<0||o<0)return e;const l=[...s],[u]=l.splice(i,1);l.splice(o,0,u);let d=0;return e.map(g=>g.isQueued?l[d++]:g)}function to(e,n){return e.isQueued===!0&&(!n||!!e.queueItemId)}async function Gm(e,n,r,s){if(!to(e,r))throw new Error("排队消息正在保存,请稍后再引导");if(e.queueItemId)return s.steerSessionMessage(n,e.queueItemId);if(!await s.steer(e.content,n,e.agentName))throw new Error("当前运行不支持插队消息")}function Vm(e,n){return e.defaultPrevented||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229?null:e.key==="Escape"?e.repeat?null:n.pickerOpen?"dismiss-picker":n.running?"abort":null:e.key==="Enter"&&!e.shiftKey?"send":null}function Ja(e,n,r=Date.now()){var d,g;if(!n.turnId)return null;const s=n.type==="tool_call"?`${n.toolCall.id}:call`:n.itemId;if(!s)return null;const i=`${n.turnId}:${s}`,o=e.findIndex(h=>h.id===i),l=o>=0?e[o]:void 0;let u=l??{id:i,role:"assistant",content:"",timestamp:r,presentation:{nativeMessageId:i}};return n.type==="text_chunk"?u={...u,content:u.content+n.text}:n.type==="reasoning_summary_delta"?u={...u,presentation:{...u.presentation,reasoning:co((d=u.presentation)==null?void 0:d.reasoning,n)}}:u={...u,toolCalls:[{...(g=l==null?void 0:l.toolCalls)==null?void 0:g.find(h=>h.id===n.toolCall.id),...n.toolCall}]},o<0?[...e,u]:e.map((h,p)=>p===o?u:h)}function Qm(e){let n=!0,r=!1;return{onScroll(s){const i=s>e;return i?r||(n=!1):(n=!0,r=!1),i},requestReturn(){n=!0,r=!0},reset(){n=!0,r=!1},shouldFollow(s){return s==="skip"?!1:(s==="instant"&&(n=!0,r=!1),n)},isFollowing(){return n}}}function Km(e,n,r){return e.createSession(n,r.workspaceSource==="imported"?void 0:r.projectId,r.agentType,r.agentType!=="customer-agent"?r.workspacePath??void 0:void 0)}function Jm(e,n,r){return e?(n==null?void 0:n.id)!==e?{agentType:r,ready:!1}:{agentType:n.agentType,ready:!0}:{agentType:r,ready:!0}}function Ym(e){return typeof e=="string"&&e.trim().length>0?e:null}function Xm(e){return!["run_admitted","done","error","turn_aborted","goal_updated","goal_cleared"].includes(e)}function Zm(e,n){return((e==null?void 0:e.agentType)??n)!=="customer-agent"}function Hl(e){return(e==null?void 0:e.agentType)!==void 0&&e.agentType!=="customer-agent"&&e.status==="running"}function Gl(e){return Hl(e)&&((e==null?void 0:e.occupancy)==="owned-externally"||(e==null?void 0:e.agentType)==="copilot"&&(e==null?void 0:e.occupancy)==="available")}function ex(e,n,r,s){return r||((s==null?void 0:s.sessionId)===n?s.running:Gl(e))}function Yu(e){return Hl(e)&&!Gl(e)}function tx(e){return(e==null?void 0:e.agentType)==="customer-agent"&&e.status==="active"}function nx(e,n){return n||Yu(e)}function rx(e,n,r){return!!(n&&e&&e.agentType!=="customer-agent")}function sx(e){return(e==null?void 0:e.agentType)==="customer-agent"||(e==null?void 0:e.agentType)==="deepseek-harness"||Xu(e)||(e==null?void 0:e.occupancy)==="owned-externally"||(e==null?void 0:e.status)==="running"}function Xu(e){return(e==null?void 0:e.agentType)==="qoder"||(e==null?void 0:e.agentType)==="zcode"||(e==null?void 0:e.agentType)==="workbuddy"||(e==null?void 0:e.agentType)==="copilot"}const Zu=["modelProvider","modelId","apiKey","baseUrl","maxIterations","contextWindow","workingDirectory","isConfigured","profiles","activeProfileId","reasoningEffort","taskNotifications"];let Ed=null;function Rd(e){return Object.fromEntries(Zu.map(n=>[n,e[n]]))}function ix(e,n){return e?Object.fromEntries(Zu.filter(r=>JSON.stringify(e[r])!==JSON.stringify(n[r])).map(r=>[r,n[r]])):n}function Jo(e,n){return e.find(r=>r.id===n)??null}function Ya(e){return e.provider==="aihub"?!!e.modelId:!!(e.apiKey&&e.modelId)}const ga=du((e,n)=>({modelProvider:"anthropic",modelId:"claude-sonnet-4-6",apiKey:"",baseUrl:"",maxIterations:10,contextWindow:100,workingDirectory:"/",isConfigured:!1,profiles:[],activeProfileId:"",reasoningEffort:"off",taskNotifications:ra,setField:(r,s)=>e(i=>{const o={...i,[r]:s};return o.isConfigured=o.modelProvider==="aihub"?!!o.modelId:!!(o.apiKey&&o.modelId),o}),loadFromSystem:async()=>{if(window.agentApi)try{const r=await window.agentApi.getSettings(),s=r.profiles??[],i=r.activeProfileId??"",o=Jo(s,i),l={revision:r.revision,modelProvider:(o==null?void 0:o.provider)??r.modelProvider??"anthropic",modelId:(o==null?void 0:o.modelId)??r.modelId??"claude-sonnet-4-6",apiKey:(o==null?void 0:o.apiKey)??r.apiKey??"",baseUrl:(o==null?void 0:o.baseUrl)??r.baseUrl??"",maxIterations:r.maxIterations??10,contextWindow:r.contextWindow??100,workingDirectory:r.workingDirectory??"/",isConfigured:((o==null?void 0:o.provider)??r.modelProvider)==="aihub"?!!((o==null?void 0:o.modelId)??r.modelId):!!(((o==null?void 0:o.apiKey)??r.apiKey)&&((o==null?void 0:o.modelId)??r.modelId)),profiles:s,activeProfileId:i,reasoningEffort:["off","low","medium","high"].includes(r.reasoningEffort??"")?r.reasoningEffort:"off",taskNotifications:Ag(r.taskNotifications)};Ed=Rd(l),e(l)}catch(r){console.error("Failed to load settings:",r)}},saveToSystem:async()=>{if(!window.agentApi)return;const r=n(),s=Rd(r),i=ix(Ed,s);try{await window.agentApi.saveSettings({...i,revision:r.revision})}catch(o){if((o==null?void 0:o.status)!==409)throw o;const l=await window.agentApi.getSettings();await window.agentApi.saveSettings({...i,revision:l.revision})}await n().loadFromSystem()},addProfile:r=>{const i={id:crypto.randomUUID(),...r};e(o=>({profiles:[...o.profiles,i]}))},updateProfile:(r,s)=>{e(o=>({profiles:o.profiles.map(l=>l.id===r?{...l,...s}:l)}));const i=n();if(i.activeProfileId===r){const o=Jo(i.profiles,r);o&&e({modelProvider:o.provider,modelId:o.modelId,apiKey:o.apiKey,baseUrl:o.baseUrl,isConfigured:Ya(o)})}},deleteProfile:r=>{e(s=>{var u;const i=s.profiles.filter(d=>d.id!==r),o=s.activeProfileId===r?((u=i[0])==null?void 0:u.id)??"":s.activeProfileId,l=Jo(i,o);return{profiles:i,activeProfileId:o,...l?{modelProvider:l.provider,modelId:l.modelId,apiKey:l.apiKey,baseUrl:l.baseUrl,isConfigured:Ya(l)}:{},...l?{}:{modelProvider:"anthropic",modelId:"",apiKey:"",baseUrl:"",isConfigured:!1}}})},setActiveProfileLocal:r=>{const s=n(),i=Jo(s.profiles,r);i&&e({activeProfileId:r,modelProvider:i.provider,modelId:i.modelId,apiKey:i.apiKey,baseUrl:i.baseUrl,isConfigured:Ya(i)})},switchActiveProfile:async r=>{window.agentApi&&(await window.agentApi.setActiveProfile(r),await n().loadFromSystem())}}));function is(e){if(!e)return[];const n=e.replace(/\r\n/g,`
|
|
142
|
+
`).split(`
|
|
143
|
+
`);return n.at(-1)===""&&n.pop(),n}function Vl(e){var r;const n=typeof e.kind=="string"?e.kind:(r=e.kind)==null?void 0:r.type;return n==="add"||n==="update"||n==="delete"?n:null}function ep(e){if(!e||typeof e!="object")return!1;const n=e;return Number.isSafeInteger(n.added)&&n.added>=0&&Number.isSafeInteger(n.removed)&&n.removed>=0}function tp(e){if(ep(e.lineStats))return e.lineStats;if(typeof e.diff!="string")return null;const n=Vl(e);if(n==="add")return{added:is(e.diff).length,removed:0};if(n==="delete")return{added:0,removed:is(e.diff).length};if(n!=="update")return null;let r=!1;const s={added:0,removed:0};for(const i of e.diff.split(`
|
|
144
|
+
`))/^@@(?: |$)/.test(i)?r=!0:r&&i.startsWith("+")?s.added+=1:r&&i.startsWith("-")?s.removed+=1:i.startsWith("diff --git ")&&(r=!1);return r?s:null}function ox(e){if(!e.length)return null;const n=e.map(Vl),r=n.every(i=>i==="add")?"add":n.every(i=>i==="delete")?"delete":"update",s=e.map(tp);return{operation:r,fileCount:e.length,lineStats:s.every(i=>i!==null)?s.reduce((i,o)=>({added:i.added+o.added,removed:i.removed+o.removed}),{added:0,removed:0}):null}}function np(e,n){const r=is(e),s=is(n);let i=0;for(;i<r.length&&i<s.length&&r[i]===s[i];)i+=1;let o=r.length,l=s.length;for(;o>i&&l>i&&r[o-1]===s[l-1];)o-=1,l-=1;const u=o-i,d=l-i;if(u*d>2e5)return null;const g=new Uint32Array(d+1);for(let h=i;h<o;h+=1){let p=0;for(let k=1;k<=d;k+=1){const x=g[k];g[k]=r[h]===s[i+k-1]?p+1:Math.max(g[k],g[k-1]),p=x}}return{added:d-g[d],removed:u-g[d]}}function Ei(e){return e.result!==void 0||e.resultRef!==void 0}function Nd(e){return e.every(Ei)}const Ql=new Set(["shell","bash","Bash","execute_command","run_command","BashOutput","KillShell"]),rp=new Set(["Read","read_file","Write","write_file","Edit","MultiEdit","str_replace","apply_patch","NotebookEdit"]),sp=new Set(["Glob","glob_search","Grep","grep_search","WebSearch","WebFetch"]),ax=new Set(["Read","read_file"]),lx=new Set(["Write","write_file"]),cx=new Set(["Edit","MultiEdit","str_replace","apply_patch","NotebookEdit"]);function Kl(e){return Ql.has(e)?"command":rp.has(e)?"file":sp.has(e)?"search":"generic"}function Jl(e){switch(e){case"shell":case"bash":case"Bash":case"execute_command":case"run_command":return{done:"运行了命令",doing:"运行命令中"};case"BashOutput":case"KillShell":return{done:"查看了命令输出",doing:"查看输出中"};case"Read":case"read_file":return{done:"读取了文件",doing:"读取文件中"};case"Write":case"write_file":return{done:"写入了文件",doing:"写入文件中"};case"Edit":case"MultiEdit":case"str_replace":case"apply_patch":return{done:"修改了文件",doing:"修改文件中"};case"Glob":case"glob_search":return{done:"搜索了文件",doing:"搜索文件中"};case"Grep":case"grep_search":return{done:"搜索了内容",doing:"搜索内容中"};case"Skill":return{done:"调用了技能",doing:"调用技能中"};case"Task":return{done:"启动了子任务",doing:"启动子任务中"};case"WebSearch":return{done:"搜索了网络",doing:"搜索网络中"};case"WebFetch":return{done:"读取了网页",doing:"读取网页中"};case"TodoWrite":return{done:"更新了任务清单",doing:"更新任务清单中"};case"NotebookEdit":return{done:"编辑了 Notebook",doing:"编辑 Notebook 中"};default:return e.startsWith("mcp__")||e.includes(":")?{done:"调用了工具",doing:"调用工具中"}:null}}function dx(e){var n;return((n=Jl(e))==null?void 0:n.done)??null}function ip(e){return Ql.has(e)?"终端":ax.has(e)?"查阅":lx.has(e)?"写入":cx.has(e)?"编辑":sp.has(e)?"查阅":e==="Skill"?"技能":e==="Task"||e==="dispatch_agent"||e==="Agent"?"子任务":e==="TodoWrite"?"任务":e.startsWith("mcp__")||e.includes(":")?"工具":null}function Td(e){return e.replace(/\\/g,"/").split("/").pop()??e}function Xa(e,n=60){const r=(e??"").split(`
|
|
145
|
+
`)[0].trim();return r.length>n?r.slice(0,n)+"…":r}function ux(e,n){var r;if(Ql.has(e))return Xa(String(n.command??""));if(e==="apply_patch"){const i=(Array.isArray(n.changes)?n.changes:[]).map(l=>Td(String((l==null?void 0:l.path)??""))).filter(Boolean),o=((r=n.fileChangeSummary)==null?void 0:r.fileCount)??i.length;return i.length?o<=3?i.join("、"):`${i.slice(0,3).join("、")} 等 ${o} 个文件`:o?`${o} 个文件`:null}return rp.has(e)?n.file_path?Td(String(n.file_path)):null:e==="Glob"||e==="glob_search"?String(n.pattern??"")||null:e==="Grep"||e==="grep_search"?String(n.pattern??n.query??"")||null:e==="Skill"?String(n.skill??"")||null:e==="Task"?Xa(String(n.description??n.task??""),80)||null:e==="WebSearch"?Xa(String(n.query??"")):e==="WebFetch"?String(n.url??"")||null:e.startsWith("mcp__")?e.split("__").slice(1).join("/"):e.includes(":")?e.split(":").slice(1).join(":"):null}function px(e,n){return Math.max(0,Math.floor((n-e)/1e3))}function ha({startedAt:e}){const[n,r]=c.useState(()=>Date.now());return c.useEffect(()=>{r(Date.now());const s=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(s)},[e]),t.jsxs("span",{className:"activity-elapsed-time",children:[" · 持续了 ",px(e,n)," 秒"]})}function Yl({progress:e,compact:n=!1,startedAt:r}){const s=e.detail??(e.elapsedSeconds===void 0?void 0:`${Math.round(e.elapsedSeconds)} 秒`),i=[e.label,s].filter(Boolean).join(","),o=!n&&e.phase==="thinking",l=!n&&e.phase==="status",u=e.status&&!["running","stopping"].includes(e.status),d=e.startedAt??(o&&!s?r:void 0),g=e.status==="failed"||e.status==="killed";return t.jsxs("div",{className:"runtime-progress","data-status":e.status,children:[t.jsxs("div",{className:`runtime-progress-row${n?" runtime-progress-row--compact":""}`,role:"status","aria-live":"polite","aria-label":i,children:[u?g?t.jsx(Ci,{size:14,"aria-hidden":"true"}):t.jsx(dg,{size:14,"aria-hidden":"true"}):o?t.jsx("span",{className:"runtime-progress-row__brain","aria-hidden":"true",children:t.jsx(Pl,{size:17,strokeWidth:1.8})}):l?t.jsx("span",{className:"runtime-progress-row__status-icon","aria-hidden":"true",children:t.jsx(bt,{size:17,strokeWidth:1.8})}):t.jsx("span",{className:"runtime-progress-row__spinner","aria-hidden":"true"}),t.jsx("span",{className:"runtime-progress-row__label",title:e.label,children:e.label}),s&&t.jsx("span",{className:"runtime-progress-row__detail",title:s,children:s}),d!==void 0&&!u&&t.jsx(ha,{startedAt:d}),u&&e.elapsedSeconds!==void 0&&t.jsxs("span",{className:"runtime-progress-row__elapsed",children:[Math.round(e.elapsedSeconds)," 秒"]})]}),e.output!==void 0&&t.jsxs("details",{className:"runtime-progress-output",children:[t.jsx("summary",{children:"实时输出"}),t.jsx("pre",{children:e.output||"暂无输出"})]})]})}function Xl(e,n){const r=Array.isArray(e.changes)?e.changes.filter(s=>!!s&&typeof s=="object"):[];if(n&&(!r.length||e.__truncated&&!e.fileChangeSummary))try{const s=JSON.parse(n);if(Array.isArray(s))return s.filter(i=>!!i&&typeof i=="object")}catch{}return r}function fx(e,n){const r=e.fileChangeSummary;return r&&["add","update","delete"].includes(r.operation)&&Number.isSafeInteger(r.fileCount)&&r.fileCount>0&&(r.lineStats===null||ep(r.lineStats))?r:ox(Xl(e,n))}function gx(e){return(e==null?void 0:e.operation)==="add"?"写入":(e==null?void 0:e.operation)==="delete"?"删除":"编辑"}function op(e){return e.__truncated||e.replace_all===!0||typeof e.old_string!="string"||typeof e.new_string!="string"?null:np(e.old_string,e.new_string)}function hx(e){if(e.__truncated||!Array.isArray(e.edits)||!e.edits.length)return null;const n=e.edits.map(r=>r&&typeof r=="object"?op(r):null);return n.every(r=>r!==null)?n.reduce((r,s)=>({added:r.added+s.added,removed:r.removed+s.removed}),{added:0,removed:0}):null}function mx(e){return!e.__truncated&&typeof e.content=="string"?is(e.content).length:null}function Ri({isDone:e,isError:n,color:r,size:s=11}){return e?n?t.jsx(pg,{size:s,color:r,strokeWidth:2.5,"aria-hidden":"true"}):t.jsx(er,{size:s,color:r,strokeWidth:2.5,"aria-hidden":"true"}):t.jsx(bt,{size:s,color:r,strokeWidth:2.5,style:{animation:"spin 1s linear infinite",flexShrink:0},"aria-hidden":"true"})}function ho({name:e,color:n,size:r=14}){const s=Kl(e);return s==="command"?t.jsx(jg,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):s==="search"?t.jsx(fa,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):s==="file"?e==="Read"||e==="read_file"?t.jsx(Ml,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(Ll,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):e==="Skill"?t.jsx(wg,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):e==="TodoWrite"?t.jsx(gg,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):e==="Task"||e==="dispatch_agent"||e==="Agent"?t.jsx(kg,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(hf,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"})}function ma({visibilityRef:e,statusColor:n,isDone:r,expanded:s,onToggle:i,header:o,children:l,maxBodyHeight:u=600,primaryAction:d,primaryActionLabel:g,primaryActionTitle:h}){const p=t.jsxs("button",{type:"button",className:"tool-call-shell__header",...d?{onClick:d,"aria-label":g,title:h}:{onClick:i,"aria-expanded":s},style:{flex:1,border:"none",background:"var(--bg-deep)",cursor:"pointer",padding:"7px 10px 7px 9px",display:"flex",alignItems:"center",gap:7,fontFamily:"var(--font-body)",transition:"background 0.12s",textAlign:"left",minWidth:0},onMouseEnter:k=>k.currentTarget.style.background="var(--bg-elevated)",onMouseLeave:k=>k.currentTarget.style.background="var(--bg-deep)",children:[o,!d&&t.jsx(Ii,{className:"tool-call-shell__chevron",size:12,color:"var(--text-muted)",strokeWidth:2.2,style:{transition:"transform 0.25s var(--ease-out)",transform:s?"rotate(90deg)":"rotate(0deg)",flexShrink:0},"aria-hidden":"true"})]});return t.jsxs("div",{ref:e,className:"tool-call-shell",style:{marginTop:4,borderRadius:9,border:"1px solid var(--border-subtle)",overflow:"hidden",background:"var(--bg-deepest)",fontSize:12,minWidth:0},children:[t.jsxs("div",{className:"tool-call-shell__row",style:{display:"flex",alignItems:"stretch"},children:[t.jsx("div",{className:"tool-call-shell__status",style:{width:3,flexShrink:0,background:n,animation:r?"none":"statusBarPulse 1.8s ease-in-out infinite",borderRadius:"9px 0 0 0"}}),p,d&&t.jsx("button",{type:"button",className:"tool-call-shell__disclosure",onClick:i,"aria-expanded":s,"aria-label":s?"收起工具详情":"展开工具详情",title:s?"收起工具详情":"展开工具详情",children:t.jsx(Ii,{className:"tool-call-shell__chevron",size:12,strokeWidth:2.2,style:{transition:"transform 0.25s var(--ease-out)",transform:s?"rotate(90deg)":"rotate(0deg)"},"aria-hidden":"true"})})]}),s&&t.jsx("div",{className:"tool-call-shell__body",style:{overflow:"hidden",maxHeight:u,opacity:1,transition:"max-height 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease"},children:t.jsx("div",{className:"tool-call-shell__body-content",style:{borderTop:"1px solid var(--border-subtle)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,boxSizing:"border-box",maxWidth:"100%"},children:l})})]})}function fo({label:e,color:n="var(--text-muted)",bg:r="var(--bg-surface)"}){return t.jsx("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:20,background:r,color:n,fontWeight:500,flexShrink:0,whiteSpace:"nowrap"},children:e})}function Ar(e){return e.replace(/\\/g,"/").split("/").pop()??e}function xx(e){return is(e).length}function ca({stats:e,pending:n=!1}){return e?t.jsxs("span",{className:"tool-call-line-stats","aria-label":`${n?"预计":""}新增 ${e.added} 行,删除 ${e.removed} 行`,style:{display:"inline-flex",gap:5,fontSize:11,fontFamily:"var(--font-mono)",flexShrink:0,whiteSpace:"nowrap"},children:[(e.added>0||e.removed===0)&&t.jsxs("span",{style:{color:"var(--success)"},children:["+",e.added]}),e.removed>0&&t.jsxs("span",{style:{color:"var(--danger)"},children:["−",e.removed]})]}):null}function xa(e,n,r=!1){const[s,i]=c.useState(r),[o,l]=c.useState(!1),[u,d]=c.useState(null),g=async()=>{if(!(!e.resultRef||e.result!==void 0||o||!n)){l(!0),d(null);try{await n(e.resultRef)}catch(p){d(p instanceof Error?p.message:"工具结果加载失败")}finally{l(!1)}}};return{expanded:s,setExpanded:i,toggle:()=>{const p=!s;i(p),p&&g()},loadingResult:o,resultError:u,loadResult:g}}function ba({toolCall:e,loading:n,error:r,retry:s}){return!e.resultRef||e.result!==void 0?null:r?t.jsx("button",{type:"button",onClick:()=>void s(),className:"ui-text-button",children:"重新加载工具结果"}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--text-muted)",fontSize:11},children:[t.jsx(bt,{size:11,strokeWidth:2.2,style:{animation:n?"spin 1s linear infinite":"none"},"aria-hidden":"true"}),n?"正在加载工具结果":`${e.resultRef.byteSize.toLocaleString()} 字节,展开后加载`]})}function ap(e,n){const r=is(e),s=is(n);if(r.length*s.length>2e5)return s.map((x,y)=>({type:"added",text:x,lineNo:y+1}));const i=r.length,o=s.length,l=Array.from({length:i+1},()=>new Array(o+1).fill(0));for(let x=1;x<=i;x++)for(let y=1;y<=o;y++)l[x][y]=r[x-1]===s[y-1]?l[x-1][y-1]+1:Math.max(l[x-1][y],l[x][y-1]);const u=[];let d=i,g=o;for(;d>0&&g>0;)r[d-1]===s[g-1]?(u.unshift([d-1,g-1]),d--,g--):l[d-1][g]>=l[d][g-1]?d--:g--;const h=[];let p=0,k=0;for(const[x,y]of u){for(;p<x;)h.push({type:"removed",text:r[p],lineNo:p+1}),p++;for(;k<y;)h.push({type:"added",text:s[k],lineNo:k+1}),k++;h.push({type:"same",text:r[p],lineNo:p+1}),p++,k++}for(;p<i;)h.push({type:"removed",text:r[p],lineNo:p+1}),p++;for(;k<o;)h.push({type:"added",text:s[k],lineNo:k+1}),k++;return h}function lp({content:e,maxHeight:n=320}){const r=e.split(`
|
|
146
|
+
`);return t.jsx("div",{style:{background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:n,fontFamily:"var(--font-mono)",fontSize:11,lineHeight:1.65},children:t.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",tableLayout:"fixed"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:40}}),t.jsx("col",{})]}),t.jsx("tbody",{children:r.map((s,i)=>t.jsxs("tr",{children:[t.jsx("td",{style:{padding:"0 8px",color:"var(--text-muted)",textAlign:"right",userSelect:"none",borderRight:"1px solid var(--border-subtle)",background:"var(--bg-deep)",fontSize:10,minWidth:36},children:i+1}),t.jsx("td",{style:{padding:"0 12px",color:"var(--text-secondary)",wordBreak:"break-all",whiteSpace:"pre-wrap"},children:s||" "})]},i))})]})})}function cp({diff:e,maxHeight:n=360}){if(e.filter(u=>u.type!=="same").length===0)return t.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",padding:"10px 12px",fontFamily:"var(--font-mono)"},children:"内容未变化"});const s=new Set(e.map((u,d)=>u.type!=="same"?d:-1).filter(u=>u>=0)),i=new Set;s.forEach(u=>{for(let d=Math.max(0,u-3);d<=Math.min(e.length-1,u+3);d++)i.add(d)});const o=[];let l=-1;return[...i].sort((u,d)=>u-d).forEach(u=>{l>=0&&u>l+1&&o.push("ellipsis"),o.push({diffLine:e[u],diffIdx:u}),l=u}),t.jsx("div",{style:{background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:n,fontFamily:"var(--font-mono)",fontSize:11,lineHeight:1.65},children:t.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",tableLayout:"fixed"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:24}}),t.jsx("col",{style:{width:36}}),t.jsx("col",{})]}),t.jsx("tbody",{children:o.map((u,d)=>{if(u==="ellipsis")return t.jsx("tr",{children:t.jsx("td",{colSpan:3,style:{padding:"2px 12px",color:"var(--text-muted)",fontSize:10,background:"var(--bg-deep)",textAlign:"center"},children:"⋯"})},`e${d}`);const{diffLine:g}=u,h=g.type==="added"?"rgba(5,150,105,0.08)":g.type==="removed"?"rgba(220,38,38,0.07)":"transparent",p=g.type==="added"?"+":g.type==="removed"?"−":" ",k=g.type==="added"?"var(--success)":g.type==="removed"?"var(--danger)":"transparent",x=g.type==="added"?"#059669":g.type==="removed"?"var(--danger)":"var(--text-secondary)";return t.jsxs("tr",{style:{background:h},children:[t.jsx("td",{style:{padding:"0 4px",textAlign:"center",color:k,fontWeight:700,userSelect:"none"},children:p}),t.jsx("td",{style:{padding:"0 6px",color:"var(--text-muted)",textAlign:"right",fontSize:10,borderRight:"1px solid var(--border-subtle)",userSelect:"none"},children:g.lineNo}),t.jsx("td",{style:{padding:"0 12px",color:x,wordBreak:"break-all",whiteSpace:"pre-wrap"},children:g.text||" "})]},d)})})]})})}function bx({toolCall:e,beforeContent:n,previewPath:r,onOpenArtifact:s,onLoadResult:i}){const o=xa(e,i),{expanded:l}=o,[u,d]=c.useState("content"),g=e.arguments.file_path??"",h=e.arguments.content??"",p=mx(e.arguments),k=e.isError,x=Ei(e),y=x?k?"var(--danger)":"var(--success)":"var(--accent)",S=c.useMemo(()=>n!==void 0&&!e.arguments.__truncated?ap(n,h):null,[n,h,e.arguments.__truncated]),v=c.useMemo(()=>n!==void 0&&p!==null?np(n,h):null,[n,h,p]),w=k?"var(--danger)":x?"var(--text-muted)":"var(--accent)",j=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"tool-call-shell__icon",children:t.jsx(ho,{name:e.name,color:w})}),t.jsx("span",{className:"tool-call-shell__label",children:n!==void 0?"编辑":"写入"}),t.jsx("span",{className:"tool-call-shell__preview",style:{flex:1},title:g,children:Ar(g)}),p!==null&&t.jsx(fo,{label:`${p} 行`,color:"var(--accent)",bg:"var(--accent-dim)"}),!k&&t.jsx(ca,{stats:v,pending:!x}),(!x||k)&&t.jsxs("span",{className:"tool-call-shell__state",style:{color:y},children:[t.jsx(Ri,{isDone:x,isError:k,color:y}),k&&t.jsx("span",{children:"错误"})]})]});return t.jsxs(ma,{statusColor:y,isDone:x,expanded:l,onToggle:o.toggle,header:j,primaryAction:r&&s?()=>s(r):void 0,primaryActionLabel:r?`预览文件 ${Ar(r)}`:void 0,primaryActionTitle:r?`预览 ${r}`:void 0,children:[t.jsx(ba,{toolCall:e,loading:o.loadingResult,error:o.resultError,retry:o.loadResult}),t.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:g}),S&&t.jsx("div",{style:{display:"flex",gap:3},children:["content","diff"].map(C=>t.jsx("button",{onClick:()=>d(C),style:{padding:"2px 9px",borderRadius:5,border:"none",cursor:"pointer",fontSize:11,fontWeight:500,background:u===C?"var(--accent-dim)":"transparent",color:u===C?"var(--accent)":"var(--text-muted)",transition:"background 0.12s"},children:C==="content"?"文件内容":"变更行"},C))}),u==="diff"&&S?t.jsx(cp,{diff:S}):t.jsx(lp,{content:h}),k&&e.result&&t.jsx("div",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 12px",background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.15)",borderLeft:"3px solid var(--danger)",borderRadius:7},children:e.result})]})}function yx({toolCall:e,previewPath:n,onOpenArtifact:r,onLoadResult:s}){const i=xa(e,s),{expanded:o}=i,l=e.arguments.file_path??"",u=e.arguments.startLine,d=e.arguments.endLine,g=e.arguments.offset,h=e.arguments.limit,p=e.result??"",k=xx(p),x=e.isError,y=Ei(e),S=y?x?"var(--danger)":"var(--success)":"var(--accent)",v=u!==void 0?`L${u}–${d??"?"}`:g!==void 0?`第${g}行起${h?` ×${h}`:""}`:null,w=x?"var(--danger)":y?"var(--text-muted)":"var(--accent)",j=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"tool-call-shell__icon",children:t.jsx(ho,{name:e.name,color:w})}),t.jsx("span",{className:"tool-call-shell__label",children:"查阅"}),t.jsx("span",{className:"tool-call-shell__preview",style:{flex:1},title:l,children:Ar(l)}),v&&t.jsx(fo,{label:v,color:"var(--accent)",bg:"var(--accent-dim)"}),y&&!x&&t.jsx(fo,{label:`${k} 行`,color:"var(--text-muted)",bg:"var(--bg-surface)"}),(!y||x)&&t.jsxs("span",{className:"tool-call-shell__state",style:{color:S},children:[t.jsx(Ri,{isDone:y,isError:x,color:S}),x&&t.jsx("span",{children:"错误"})]})]});return t.jsxs(ma,{statusColor:S,isDone:y,expanded:o,onToggle:i.toggle,header:j,maxBodyHeight:480,primaryAction:n&&r?()=>r(n):void 0,primaryActionLabel:n?`预览文件 ${Ar(n)}`:void 0,primaryActionTitle:n?`预览 ${n}`:void 0,children:[t.jsx(ba,{toolCall:e,loading:i.loadingResult,error:i.resultError,retry:i.loadResult}),t.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:l}),y&&!x?t.jsx(lp,{content:p}):y&&x&&t.jsx("div",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 12px",background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.15)",borderLeft:"3px solid var(--danger)",borderRadius:7},children:p})]})}function vx({toolCall:e,previewPath:n,onOpenArtifact:r,onLoadResult:s}){const i=xa(e,s),{expanded:o}=i,l=e.arguments.file_path??"",u=e.arguments.old_string??"",d=e.arguments.new_string??"",g=e.isError,h=Ei(e),p=h?g?"var(--danger)":"var(--success)":"var(--accent)",k=g?"var(--danger)":h?"var(--text-muted)":"var(--accent)",x=c.useMemo(()=>!e.arguments.__truncated&&typeof e.arguments.old_string=="string"&&typeof e.arguments.new_string=="string"?ap(u,d):null,[u,d,e.arguments]),y=c.useMemo(()=>op(e.arguments),[e.arguments]),S=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"tool-call-shell__icon",children:t.jsx(ho,{name:e.name,color:k})}),t.jsx("span",{className:"tool-call-shell__label",children:"编辑"}),t.jsx("span",{className:"tool-call-shell__preview",style:{flex:1},title:l,children:Ar(l)}),!g&&t.jsx(ca,{stats:y,pending:!h}),(!h||g)&&t.jsxs("span",{className:"tool-call-shell__state",style:{color:p},children:[t.jsx(Ri,{isDone:h,isError:g,color:p}),g&&t.jsx("span",{children:"错误"})]})]});return t.jsxs(ma,{statusColor:p,isDone:h,expanded:o,onToggle:i.toggle,header:S,maxBodyHeight:480,primaryAction:n&&r?()=>r(n):void 0,primaryActionLabel:n?`预览文件 ${Ar(n)}`:void 0,primaryActionTitle:n?`预览 ${n}`:void 0,children:[t.jsx(ba,{toolCall:e,loading:i.loadingResult,error:i.resultError,retry:i.loadResult}),t.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:l}),x?t.jsx(cp,{diff:x}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("pre",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 10px",borderRadius:6,background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.12)",borderLeft:"3px solid var(--danger)",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:u}),t.jsx("pre",{style:{fontSize:11,color:"var(--success)",fontFamily:"var(--font-mono)",padding:"8px 10px",borderRadius:6,background:"rgba(5,150,105,0.04)",border:"1px solid rgba(5,150,105,0.12)",borderLeft:"3px solid var(--success)",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:d})]}),g&&e.result&&t.jsx("div",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 10px",background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.15)",borderLeft:"3px solid var(--danger)",borderRadius:7},children:e.result})]})}function ki({label:e,content:n,error:r,maxPreviewLines:s=8,maxPreviewHeight:i=200,maxExpandedHeight:o=2e3}){const[l,u]=c.useState(!1),d=n.split(`
|
|
147
|
+
`),g=d.length>s,h=g&&!l?d.slice(0,s).join(`
|
|
148
|
+
`)+`
|
|
149
|
+
...`:n;return t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:5},children:e}),t.jsx("pre",{style:{fontSize:11,color:r?"var(--danger)":"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--font-mono)",padding:"9px 11px",borderRadius:7,boxSizing:"border-box",maxWidth:"100%",background:r?"rgba(220,38,38,0.04)":"var(--bg-surface)",border:r?"1px solid rgba(220,38,38,0.15)":"1px solid var(--border-subtle)",borderLeft:r?"3px solid var(--danger)":"3px solid var(--success)",maxHeight:l?o:i,overflow:"auto",margin:0,lineHeight:1.6},children:h}),g&&t.jsx("button",{onClick:()=>u(!l),style:{marginTop:4,padding:"2px 10px",borderRadius:5,border:"1px solid var(--border-subtle)",background:"var(--bg-deep)",color:"var(--text-muted)",fontSize:10,cursor:"pointer",fontWeight:500},children:l?"收起":`展开全部 (${d.length} 行)`})]})}function wx({arguments:e}){var r;const n=e.task??"";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"6px 0"},children:[t.jsxs("div",{style:{display:"flex",gap:8,fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",flexWrap:"wrap"},children:[t.jsx(fo,{label:`agent: ${e.agentName}`,color:"var(--accent)",bg:"var(--accent-dim)"}),t.jsx(fo,{label:`sid: ${(r=e.subSessionId)==null?void 0:r.slice(0,8)}…`,color:"var(--text-muted)",bg:"var(--bg-surface)"})]}),n&&t.jsx(ki,{label:"任务",content:n,error:!1,maxPreviewLines:3,maxPreviewHeight:80,maxExpandedHeight:2e3})]})}function jx({raw:e}){const[n,r]=c.useState(!1);let s;try{const d=JSON.parse(e);delete d.subAgentProgress,delete d.subAgentStatus,delete d.subAgentDetail,s=JSON.stringify(d,null,2)}catch{s=e}const i=8,o=s.split(`
|
|
150
|
+
`),l=o.length>i,u=l&&!n?o.slice(0,i).join(`
|
|
151
|
+
`)+`
|
|
152
|
+
...`:s;return t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:5},children:"参数"}),t.jsx("pre",{style:{fontSize:11,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--font-mono)",padding:"9px 11px",borderRadius:7,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",maxHeight:n?2e3:200,overflow:"auto",margin:0,lineHeight:1.6,boxSizing:"border-box",maxWidth:"100%"},children:u}),l&&t.jsx("button",{onClick:()=>r(!n),style:{marginTop:4,padding:"2px 10px",borderRadius:5,border:"1px solid var(--border-subtle)",background:"var(--bg-deep)",color:"var(--text-muted)",fontSize:10,cursor:"pointer",fontWeight:500},children:n?"收起":`展开全部 (${o.length} 行)`})]})}function Sx({activity:e,workspacePath:n,onOpenArtifact:r}){const s=new Map(e.messages.flatMap(i=>i.role==="tool"&&i.toolCallId?[[i.toolCallId,{content:i.content,isError:i.name==="error"}]]:[]));return t.jsxs("div",{className:"native-subagent-activity",children:[t.jsxs("div",{className:"native-subagent-activity__meta",children:[e.elapsedSeconds!==void 0&&t.jsxs("span",{children:[e.elapsedSeconds," 秒"]}),e.toolUses!==void 0&&t.jsxs("span",{children:[e.toolUses," 次工具调用"]}),e.lastToolName&&t.jsxs("span",{children:["正在使用 ",e.lastToolName]})]}),e.messages.map((i,o)=>{var l;return t.jsxs("div",{className:"native-subagent-activity__entry",children:[i.role==="assistant"&&i.content&&t.jsx("pre",{className:"native-subagent-activity__text",children:i.content}),i.role==="assistant"&&((l=i.toolCalls)==null?void 0:l.map(u=>{const d=s.get(u.id);return t.jsxs("div",{className:"native-subagent-activity__tool",children:[t.jsx(ya,{toolCall:{...u,...d?{result:d.content,isError:d.isError}:{}},workspacePath:n,onOpenArtifact:r}),d&&t.jsx("pre",{className:`native-subagent-activity__tool-result${d.isError?" native-subagent-activity__tool-result--error":""}`,children:d.content})]},u.id)})),i.role==="tool"&&i.toolCallId&&!e.messages.some(u=>{var d;return(d=u.toolCalls)==null?void 0:d.some(g=>g.id===i.toolCallId)})&&t.jsx(ki,{label:"工具结果",content:i.content,error:i.name==="error",maxPreviewHeight:180})]},`${i.role}-${o}`)}),e.summary&&t.jsx(ki,{label:e.status==="failed"?"错误信息":"执行摘要",content:e.summary,error:e.status==="failed",maxPreviewHeight:180}),e.status==="running"&&e.messages.length===0&&!e.summary&&t.jsxs("div",{className:"native-subagent-activity__waiting",children:[t.jsx(Ri,{isDone:!1,color:"var(--accent)",size:10}),"子 agent 正在工作"]})]})}function kx({toolCall:e,onSelectSession:n,nativeSubagent:r,previewPaths:s,workspacePath:i,onOpenArtifact:o,onLoadResult:l}){const u=Re(K=>K.runningSessionId),d=xa(e,l,!!r),{expanded:g,setExpanded:h}=d,p=e.name==="dispatch_agent",k=e.name==="Agent"&&!!r,x=e.arguments.subAgentStatus,y=e.arguments.subAgentDetail,S=e.arguments.subAgentProgress,v=Ei(e);c.useEffect(()=>{p&&!x&&S&&h(!0),k&&(r.messages.length>0||r.summary)&&h(!0)},[p,k,r,x,S]);const w=p?x==="failed":k?r.status==="failed":e.isError,j=p?!!x||v&&!u:k?r.status!=="running":v,C=j?w?"var(--danger)":"var(--success)":"var(--accent)",A=w?"var(--danger)":j?"var(--text-muted)":"var(--accent)",L=p?null:Jl(e.name),z=w?"错误":L?"":k?r.status==="stopped"?"已停止":j?"已完成":"运行中":p?x==="failed"?"失败":j?"已完成":"运行中":j?"完成":"执行中",R=k?r.description:p?(()=>{const Q=(e.arguments.task??"").split(`
|
|
153
|
+
`)[0];return Q.length>80?Q.slice(0,80)+"…":Q})():ux(e.name,e.arguments),N=c.useMemo(()=>e.name==="apply_patch"?fx(e.arguments,e.result):null,[e.name,e.arguments,e.result]),T=c.useMemo(()=>e.name==="apply_patch"?Xl(e.arguments,e.result):[],[e.name,e.arguments,e.result]),F=c.useRef(null),O=e.name==="apply_patch"&&!(N!=null&&N.lineStats)&&!!(e.resultRef&&e.result===void 0&&l)&&!w&&!d.loadingResult&&!d.resultError;c.useEffect(()=>{if(!O||!F.current)return;const K=new IntersectionObserver(Q=>{Q.some(Se=>Se.isIntersecting)&&(K.disconnect(),d.loadResult())});return K.observe(F.current),()=>K.disconnect()},[O,e.id,e.resultRef,l]);const q=e.name==="apply_patch"?(N==null?void 0:N.lineStats)??null:e.name==="MultiEdit"?hx(e.arguments):null,ae=k?`@${r.agentName??"agent"}`:p?`@${e.arguments.agentName??"agent"}`:e.name==="apply_patch"?gx(N):ip(e.name)??e.name,se=Kl(e.name),we=!j||!!w||!!z,Y=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"tool-call-shell__icon",children:t.jsx(ho,{name:e.name,color:A})}),t.jsx("span",{className:"tool-call-shell__label",title:L?e.name:void 0,style:{fontFamily:L?"var(--font-body)":"var(--font-mono)",fontSize:11.5,color:"var(--text-primary)",fontWeight:600,flexShrink:0},children:ae}),R&&t.jsx("span",{className:"tool-call-shell__preview",style:{fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-muted)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R}),!R&&t.jsx("span",{style:{flex:1}}),!w&&t.jsx(ca,{stats:q,pending:!j}),e.name==="apply_patch"&&!q&&d.loadingResult&&t.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",flexShrink:0},children:"行数加载中"}),we&&t.jsxs("span",{className:"tool-call-shell__state",style:{color:C},children:[t.jsx(Ri,{isDone:j,isError:!!w,color:C}),z&&t.jsx("span",{children:z})]})]});return t.jsxs(ma,{visibilityRef:F,statusColor:C,isDone:j,expanded:g,onToggle:d.toggle,header:Y,maxBodyHeight:800,primaryAction:s.length===1&&o?()=>o(s[0]):void 0,primaryActionLabel:s.length===1?`预览文件 ${Ar(s[0])}`:void 0,primaryActionTitle:s.length===1?`预览 ${s[0]}`:void 0,children:[t.jsx(ba,{toolCall:e,loading:d.loadingResult,error:d.resultError,retry:d.loadResult}),s.length>1&&t.jsx("div",{className:"tool-call-file-list","aria-label":"改动文件",children:s.map(K=>t.jsxs("button",{type:"button",onClick:()=>o==null?void 0:o(K),"aria-label":`预览文件 ${Ar(K)}`,title:`预览 ${K}`,children:[t.jsx(Ml,{size:12,strokeWidth:1.8,"aria-hidden":"true"}),t.jsx("span",{style:{flex:1},children:Ar(K)}),(()=>{const Q=T.find(Pe=>pa(String(Pe.path??""),i)===K);if(!Q)return null;const Se=Vl(Q);return t.jsxs(t.Fragment,{children:[t.jsx("span",{children:Se==="add"?"写入":Se==="delete"?"删除":"编辑"}),!w&&t.jsx(ca,{stats:tp(Q),pending:!j})]})})()]},K))}),k?t.jsx(Sx,{activity:r,workspacePath:i,onOpenArtifact:o}):p?t.jsx(wx,{arguments:e.arguments}):se==="command"&&typeof e.arguments.command=="string"?t.jsxs(t.Fragment,{children:[typeof e.arguments.cwd=="string"&&e.arguments.cwd&&t.jsxs("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:["工作目录 ",e.arguments.cwd]}),t.jsx(ki,{label:"命令",content:e.arguments.command,maxPreviewLines:6,maxPreviewHeight:160})]}):t.jsx(jx,{raw:JSON.stringify(e.arguments,null,2)}),e.result&&!p&&!k&&t.jsx(ki,{label:e.isError?"错误信息":"返回结果",content:e.result,error:e.isError,maxPreviewHeight:240}),p&&x&&y&&t.jsx(ki,{label:x==="failed"?"错误信息":"执行摘要",content:y,error:x==="failed",maxPreviewHeight:180}),p&&!x&&S&&(!!u||!v)&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:5},children:"实时输出"}),t.jsxs("pre",{style:{fontSize:11,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--font-mono)",padding:"9px 11px",borderRadius:7,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderLeft:"3px solid var(--accent)",maxHeight:240,overflow:"auto",margin:0,lineHeight:1.6,boxSizing:"border-box",maxWidth:"100%"},children:[S,t.jsx("span",{style:{display:"inline-block",width:"0.5em",height:"1em",background:"var(--accent)",verticalAlign:"text-bottom",animation:"blink 1s step-end infinite"},children:""})]})]}),p&&!x&&!S&&!!u&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 0",fontSize:11,color:"var(--text-muted)",fontStyle:"italic"},children:[[0,1,2].map(K=>t.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--accent)",display:"inline-block",animation:"wave 1.1s ease-in-out infinite",animationDelay:`${K*.16}s`}},K)),"等待子 agent 响应..."]}),p&&e.arguments.subSessionId&&n&&t.jsxs("button",{onClick:()=>n(e.arguments.subSessionId),style:{alignSelf:"flex-start",padding:"4px 10px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--accent-dim)",color:"var(--accent)",fontSize:11,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,transition:"background 0.15s"},onMouseEnter:K=>{K.currentTarget.style.background="var(--accent)",K.currentTarget.style.color="white"},onMouseLeave:K=>{K.currentTarget.style.background="var(--accent-dim)",K.currentTarget.style.color="var(--accent)"},children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M12 2a5 5 0 1 0 0 10A5 5 0 0 0 12 2z"}),t.jsx("path",{d:"M12 12c-5.33 0-8 2.67-8 4v2h16v-2c0-1.33-2.67-4-8-4z"})]}),"查看子会话"]})]})}function dp({items:e,onSelectSession:n,workspacePath:r,onOpenArtifact:s,onLoadResult:i}){var y;const[o,l]=c.useState(!1),u=(y=e[0])==null?void 0:y.toolCall,d=u?Jl(u.name):null;if(!u||!d||e.length<2)return null;const g=e.every(({toolCall:S})=>Ei(S)),h=e.filter(({toolCall:S})=>S.isError).length,p=h>0?"var(--danger)":g?"var(--text-muted)":"var(--accent)",k=ip(u.name)??d.done,x=`${k},${e.length} 项,${o?"收起":"展开"}`;return t.jsxs("div",{className:"tool-call-group",children:[t.jsxs("button",{type:"button",className:"tool-call-group__summary","aria-expanded":o,"aria-label":x,onClick:()=>l(S=>!S),children:[t.jsx("span",{className:"tool-call-group__icon","aria-hidden":"true",children:t.jsx(ho,{name:u.name,color:p})}),t.jsx("span",{className:"tool-call-group__label",children:k}),t.jsxs("span",{className:"tool-call-group__count",children:[e.length," 项"]}),t.jsx("span",{className:"tool-call-group__spacer"}),h>0&&t.jsxs("span",{className:"tool-call-group__error",children:[h," 项失败"]}),!g&&t.jsx(Ri,{isDone:!1,color:p,size:11}),t.jsx(Ii,{className:"tool-call-group__chevron",size:13,strokeWidth:2.2,"aria-hidden":"true"})]}),o&&t.jsx("div",{className:"tool-call-group__items",children:e.map(({toolCall:S,beforeContent:v,progress:w,nativeSubagent:j})=>t.jsx(ya,{toolCall:S,beforeContent:v,progress:w,nativeSubagent:j,onSelectSession:n,workspacePath:r,onOpenArtifact:s,onLoadResult:i},S.id))})]})}function Ix(e,n){if(Kl(e.name)!=="file")return[];const r=e.name==="apply_patch"?Xl(e.arguments,e.result).map(s=>s.path):[e.arguments.file_path??e.arguments.path??e.arguments.notebook_path];return[...new Set(r.filter(s=>typeof s=="string").map(s=>pa(s,n)).filter(s=>!!s))]}function ya({toolCall:e,onSelectSession:n,beforeContent:r,progress:s,nativeSubagent:i,workspacePath:o,onOpenArtifact:l,onLoadResult:u}){const d=l?Ix(e,o):[],g=e.name==="write_file"||e.name==="Write"?t.jsx(bx,{toolCall:e,beforeContent:r,previewPath:d[0],onOpenArtifact:l,onLoadResult:u}):e.name==="read_file"?t.jsx(yx,{toolCall:e,previewPath:d[0],onOpenArtifact:l,onLoadResult:u}):e.name==="str_replace"||e.name==="Edit"?t.jsx(vx,{toolCall:e,previewPath:d[0],onOpenArtifact:l,onLoadResult:u}):t.jsx(kx,{toolCall:e,onSelectSession:n,nativeSubagent:i,previewPaths:d,workspacePath:o,onOpenArtifact:l,onLoadResult:u});return t.jsxs("div",{className:"tool-call-with-progress",children:[g,s&&t.jsx(Yl,{progress:s,compact:!0})]})}function Cx({question:e,options:n,fields:r,multiSelect:s,answered:i,cancelled:o,answer:l,onAnswer:u}){const d=i||o,[g,h]=c.useState(new Set),[p,k]=c.useState(""),[x,y]=c.useState({}),S=c.useRef(!1),[v,w]=c.useState(!1),[j,C]=c.useState(""),A=async(O,q)=>{if(!(d||S.current)){S.current=!0,w(!0),C("");try{await u(O,q)}catch(ae){C(ae instanceof Error?ae.message:"回答发送失败,请重试。")}finally{S.current=!1,w(!1)}}},L=!!(n!=null&&n.length),z=!!(r!=null&&r.length),R=O=>{d||h(q=>{const ae=new Set(q);return s?ae.has(O)?ae.delete(O):ae.add(O):(ae.clear(),ae.add(O)),ae})},N=()=>{if(g.size===0)return;const O=Array.from(g).map(q=>n[q].label);A(O.join(", "),Array.from(g))},T=()=>{const O=Array.from(g).map(ae=>n[ae].label),q=Object.fromEntries((r??[]).map(ae=>{var se;return[ae.name,((se=x[ae.name])==null?void 0:se.trim())??""]}));!q.model&&O.length>0&&(q.model=O[0]),!(!Object.values(q).some(Boolean)&&O.length===0)&&A(JSON.stringify({fields:q,selectedOptions:O}),Array.from(g))},F=()=>{p.trim()&&A(p.trim())};return t.jsxs("div",{style:{marginBottom:12},children:[j&&!d&&t.jsx("div",{role:"alert",style:{color:"var(--danger)",marginBottom:8},children:j}),v&&t.jsx("div",{role:"status",children:"正在发送回答…"}),t.jsxs("div",{style:{borderRadius:12,border:"1px solid",borderColor:d?"var(--border-subtle)":"rgba(79,110,247,0.35)",background:d?"var(--bg-deep)":"linear-gradient(135deg, rgba(79,110,247,0.04) 0%, var(--bg-deep) 100%)",overflow:"hidden",transition:"border-color 0.2s ease"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:d?"1px solid var(--border-subtle)":"1px solid rgba(79,110,247,0.15)"},children:[t.jsx("div",{style:{width:24,height:24,borderRadius:6,background:d?"var(--bg-surface)":"rgba(79,110,247,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:o?t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("path",{d:"M6 6l12 12M6 18L18 6"})}):i?t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),t.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:d?"var(--text-muted)":"var(--accent)",flex:1},children:o?"已中断":i?"已回答":"向你提问"}),s&&!d&&t.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:10,background:"var(--accent-dim)",color:"var(--accent)",fontWeight:500},children:"可多选"})]}),t.jsx("div",{style:{padding:"12px 14px 8px",fontSize:13,color:"var(--text-primary)",lineHeight:1.6,fontWeight:500,whiteSpace:"pre-wrap"},children:e}),i&&t.jsxs("div",{style:{padding:"6px 14px 12px",fontSize:12,color:"var(--text-secondary)",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:[t.jsx("span",{style:{fontWeight:500},children:"回答:"}),z?"配置已提交(敏感字段已隐藏)":l]}),o&&t.jsxs("div",{style:{padding:"4px 14px 12px",fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:[n==null?void 0:n.map((O,q)=>t.jsx("div",{children:O.label},q)),t.jsx("div",{style:{marginTop:6},children:"提问已中断,请让助手重新提问。"})]}),L&&!d&&t.jsxs("div",{style:{padding:"4px 14px 6px",display:"flex",flexDirection:"column",gap:6},children:[n.map((O,q)=>{const ae=g.has(q);return t.jsxs("button",{onClick:()=>R(q),style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 12px",borderRadius:8,border:"1px solid",borderColor:ae?"var(--accent)":"var(--border-subtle)",background:ae?"rgba(79,110,247,0.06)":"var(--bg-surface)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-body)",transition:"all 0.15s ease",width:"100%"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:s?4:8,border:`2px solid ${ae?"var(--accent)":"var(--border-subtle)"}`,background:ae?"var(--accent)":"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:1,transition:"all 0.15s ease"},children:ae&&t.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:12.5,fontWeight:ae?600:500,color:ae?"var(--text-primary)":"var(--text-secondary)"},children:O.label}),O.description&&t.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,lineHeight:1.4},children:O.description})]})]},q)}),!z&&t.jsx("button",{onClick:N,disabled:v||g.size===0,style:{marginTop:2,padding:"7px 16px",borderRadius:8,border:"none",background:g.size>0?"var(--accent)":"var(--bg-surface)",color:g.size>0?"white":"var(--text-muted)",cursor:g.size>0?"pointer":"default",fontSize:12,fontWeight:600,fontFamily:"var(--font-body)",alignSelf:"flex-end",transition:"all 0.15s ease"},children:"确认选择"})]}),z&&!d&&t.jsxs("div",{style:{padding:"6px 14px 12px",display:"flex",flexDirection:"column",gap:10},children:[r.map(O=>t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--text-secondary)"},children:O.label}),t.jsx("input",{type:O.type==="secret"?"password":"text",value:x[O.name]??"",onChange:q=>y(ae=>({...ae,[O.name]:q.target.value})),placeholder:O.description,autoComplete:O.type==="secret"?"off":void 0,style:{padding:"8px 12px",borderRadius:8,border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none"}}),O.description&&t.jsx("span",{style:{fontSize:10.5,color:"var(--text-muted)",lineHeight:1.4},children:O.description})]},O.name)),t.jsx("button",{onClick:T,disabled:v,style:{padding:"8px 16px",borderRadius:8,border:"none",background:"var(--accent)",color:"white",cursor:"pointer",fontSize:12,fontWeight:600,fontFamily:"var(--font-body)",alignSelf:"flex-end"},children:"确认配置"})]}),!d&&!z&&t.jsxs("div",{style:{padding:"4px 14px 12px",display:"flex",gap:8,borderTop:L?"1px solid var(--border-subtle)":"none",marginTop:L?2:0},children:[t.jsx("input",{type:"text",value:p,onChange:O=>k(O.target.value),onKeyDown:O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),F())},placeholder:L?"或输入自定义回答…":"输入你的回答…",style:{flex:1,padding:"8px 12px",borderRadius:8,border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none",transition:"border-color 0.15s ease"},onFocus:O=>{O.currentTarget.style.borderColor="var(--accent)"},onBlur:O=>{O.currentTarget.style.borderColor="var(--border-subtle)"}}),t.jsx("button",{onClick:F,disabled:v||!p.trim(),style:{padding:"8px 16px",borderRadius:8,border:"none",background:p.trim()?"var(--accent)":"var(--bg-surface)",color:p.trim()?"white":"var(--text-muted)",cursor:p.trim()?"pointer":"default",fontSize:12,fontWeight:600,fontFamily:"var(--font-body)",transition:"all 0.15s ease"},children:"发送"})]})]})]})}function Ex({sessionId:e,mode:n,prepareSession:r,onSessionPrepared:s}){var L,z,R;const[i,o]=c.useState(!1),[l,u]=c.useState(n==null?void 0:n.currentValue),[d,g]=c.useState(!1),[h,p]=c.useState(null),k=c.useRef(null),x=c.useRef(!1),y=c.useRef(null),S=e??((L=y.current)==null?void 0:L.id)??null,v=n??((z=y.current)==null?void 0:z.nativeMode),w=c.useRef(e);w.current=S,c.useEffect(()=>{var T;const N=((T=y.current)==null?void 0:T.id)===e;y.current=null,u(n==null?void 0:n.currentValue),N||o(!1),p(null)},[e,n==null?void 0:n.currentValue]),c.useEffect(()=>{if(!i)return;const N=F=>{var O;(O=k.current)!=null&&O.contains(F.target)||o(!1)},T=F=>{F.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",N),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",T)}},[i]);const j=async()=>{var N;if(!x.current){if(S||!r){o(T=>!T);return}x.current=!0,g(!0),p(null);try{const T=await r();y.current=T,w.current=T.id,u((N=T.nativeMode)==null?void 0:N.currentValue),o(!0),await(s==null?void 0:s(T))}catch(T){p(T instanceof Error?T.message:"模式加载失败"),o(!0)}finally{x.current=!1,g(!1)}}},C=async N=>{var F,O;if(!S||!(v!=null&&v.canChange)||!((F=window.agentApi)!=null&&F.setSessionNativeMode)||x.current)return;const T=S;x.current=!0,g(!0),p(null);try{const q=await window.agentApi.setSessionNativeMode(T,N);w.current===T&&(u((O=q.nativeMode)==null?void 0:O.currentValue),o(!1))}catch(q){w.current===T&&p(q instanceof Error?q.message:"模式切换失败")}finally{x.current=!1,g(!1)}},A=((R=v==null?void 0:v.options.find(N=>N.value===l))==null?void 0:R.label)??"模式";return t.jsxs("div",{ref:k,className:"harness-mode-control",children:[t.jsx("button",{type:"button",className:"ui-icon-button","aria-label":`运行模式:${A}`,title:`运行模式:${A}`,"aria-haspopup":"menu","aria-expanded":i,disabled:d,onClick:()=>void j(),children:t.jsx(_f,{size:17,"aria-hidden":"true"})}),i&&t.jsxs("div",{className:"web-native-permission-menu",role:"menu","aria-label":"DeepSeek Harness 模式",children:[((v==null?void 0:v.options)??[]).map(N=>{var T;return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":l===N.value,className:l===N.value?"is-active":"",disabled:d||!(v!=null&&v.canChange)||!((T=window.agentApi)!=null&&T.setSessionNativeMode),title:N.description,onClick:()=>void C(N.value),children:[t.jsx("span",{className:"web-native-permission-check","aria-hidden":"true",children:l===N.value?"✓":""}),t.jsx("span",{children:N.label})]},N.value)}),S&&(v==null?void 0:v.canChange)===!1&&t.jsx("p",{className:"harness-mode-note",children:"请在新会话的第一条消息前选择模式"}),(v==null?void 0:v.options.length)===0&&t.jsx("p",{className:"harness-mode-note",children:"运行时未提供模式列表"}),h&&t.jsx("p",{className:"harness-mode-note",role:"alert",children:h})]})]})}function Rx({startedAt:e}){return t.jsxs("div",{className:"agent-activity-indicator",role:"status","aria-live":"polite",children:[t.jsx("span",{className:"agent-activity-icon","aria-hidden":"true",children:t.jsx(Pl,{size:17,strokeWidth:1.8})}),t.jsxs("span",{children:["思考中",t.jsx(ha,{startedAt:e})]})]})}function Nx({running:e,progress:n,startedAt:r}){if(!e)return null;const s=(n==null?void 0:n.status)&&!["running","stopping"].includes(n.status);return t.jsxs(t.Fragment,{children:[n&&t.jsx(Yl,{progress:n,startedAt:r}),(!n||s)&&t.jsx("div",{className:"chat-message-activity",style:{display:"flex",alignItems:"flex-start",padding:"4px 0 4px"},children:t.jsx(Rx,{startedAt:r})})]})}function Tx(e,n,r){return[...new Map([...e,...n].filter(s=>s.agentType===r).map(s=>[s.id,s])).values()]}function Ax(e,n,r,s){return s?null:e||(n?n.startsWith("runtime:")?n.startsWith(`runtime:${r}:`)?n:null:r==="customer-agent"?n:null:null)}function up({sections:e,streaming:n=!1,startedAt:r,renderContent:s}){const i=c.useMemo(()=>[...e].sort((g,h)=>g.sectionIndex-h.sectionIndex).map(g=>g.text.trim()).filter(Boolean).join(`
|
|
154
|
+
|
|
155
|
+
`),[e]),o=c.useMemo(()=>(i.split(`
|
|
156
|
+
`).find(h=>h.trim())??"").replace(/^#{1,6}\s+/,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1"),[i]),[l,u]=c.useState(n);if(c.useEffect(()=>{u(n)},[n]),!i)return null;const d=n?"思考中":"思考";return t.jsxs("div",{className:"reasoning-summary",children:[t.jsxs("button",{type:"button",className:"reasoning-summary__toggle","aria-expanded":l,"aria-label":`${d},${l?"收起":"展开"}`,onClick:()=>u(g=>!g),children:[t.jsx("span",{className:"reasoning-summary__brain","aria-hidden":"true",children:t.jsx(Pl,{size:17,strokeWidth:1.8})}),t.jsxs("span",{className:"reasoning-summary__label",children:[d,n&&r!==void 0&&t.jsx(ha,{startedAt:r})]}),!l&&t.jsx("span",{className:"reasoning-summary__preview",children:o}),t.jsx("span",{className:"reasoning-summary__spacer"}),n&&t.jsx(bt,{className:"reasoning-summary__spinner",size:13,strokeWidth:2,"aria-hidden":"true"}),t.jsx(Ii,{className:"reasoning-summary__chevron",size:13,strokeWidth:2,"aria-hidden":"true"})]}),l&&t.jsx("div",{className:"reasoning-summary__content",children:s(i)})]})}function pp(e){var r,s;const n=Object.keys(e.presentation??{});return e.role==="assistant"&&!!((r=e.toolCalls)!=null&&r.length)&&!e.isCompactionSummary&&!e.widget&&!e.askUser&&!((s=e.images)!=null&&s.length)&&n.every(i=>i==="executionTrace")}function _x(e){return pp(e)&&e.content.trim().length===0}function fp(e){const n=[];for(const r of e){const s=n[n.length-1];if(s&&pp(s)&&_x(r)){n[n.length-1]={...s,toolCalls:[...s.toolCalls,...r.toolCalls],timestamp:r.timestamp};continue}n.push(r)}return n}function gp(e){const n=[];for(const r of e){const s=dx(r.toolCall.name),i=n[n.length-1];s&&(i==null?void 0:i.action)===s?i.items.push(r):n.push({action:s,items:[r]})}return n}function Mx({trace:e,loadTrace:n,loadToolResult:r,renderContent:s,runtimeProgress:i,nativeSubagents:o,onSelectSession:l,workspacePath:u,onOpenArtifact:d,refreshSignal:g=0,autoLoad:h=!1}){const p=e.segmentIndex??0,k=`${e.turnId}:${p}`,x=c.useRef(k),y=c.useRef(e.revision),S=c.useRef(g),v=c.useRef(null),[w,j]=c.useState(!1),[C,A]=c.useState(null),[L,z]=c.useState(null);c.useEffect(()=>{x.current=k,v.current=null,j(!1),A(null),z(null),S.current=g},[k]),c.useEffect(()=>{y.current=e.revision,v.current=null,j(!1),A(we=>(we==null?void 0:we.map(Y=>{var K;return{...Y,toolCalls:(K=Y.toolCalls)==null?void 0:K.map(Q=>Q.resultRef?{...Q,resultRef:{...Q.resultRef,revision:e.revision}}:Q)}}))??null)},[e.revision]);const R=e.liveMessages??[],N=c.useMemo(()=>Fg(C??[],p),[C,p]),T=c.useMemo(()=>Gg(N,R),[R,N]),F=C!==null||R.length>0,O=h&&C===null&&!e.revision.startsWith("live:"),q=c.useCallback(async(we=!1)=>{if(!we&&C)return C;if(!we&&R.length>0)return R;if(v.current)return v.current;const Y=k,K=e.revision;j(!0),z(null);const Q=n(e);v.current=Q;try{const Se=await Q;return x.current===Y&&y.current===K&&A(Se),Se}catch(Se){throw x.current===Y&&y.current===K&&z(Se instanceof Error?Se.message:"执行过程加载失败"),Se}finally{x.current===Y&&y.current===K&&(v.current=null,j(!1))}},[R,n,C,k,e]);c.useEffect(()=>{O&&q(!0).catch(()=>{})},[q,O]),c.useEffect(()=>{!F&&!h||g===0||S.current!==g&&(S.current=g,q(!0).catch(()=>{}))},[h,q,F,g]);const ae=c.useCallback(async we=>{const Y=await r(we);x.current===k&&A(K=>K&&Nu(K,we.itemId,Y.content,Y.isError))},[r,k]),se=w?"正在加载执行过程":L?"重新加载执行过程":"查看执行过程";return t.jsxs("div",{className:"codex-execution-trace","data-turn-id":e.turnId,children:[F&&O&&!L&&t.jsxs("div",{className:"codex-execution-trace__status",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx(bt,{size:14,strokeWidth:2,"aria-hidden":"true"}),t.jsx("span",{className:"codex-execution-trace__label",children:"正在加载执行过程"})]}),F?t.jsx(Lx,{messages:T,renderContent:s,runtimeProgress:i,nativeSubagents:o,onSelectSession:l,workspacePath:u,onOpenArtifact:d,onLoadResult:ae}):h&&!L?t.jsxs("div",{className:"codex-execution-trace__status",role:"status","aria-live":"polite","aria-busy":"true",children:[t.jsx("span",{className:"codex-execution-trace__icon","aria-hidden":"true",children:t.jsx(bt,{size:14,strokeWidth:2})}),t.jsx("span",{className:"codex-execution-trace__label",children:"正在加载会话"})]}):t.jsxs("button",{type:"button",className:"codex-execution-trace__load","aria-busy":w||void 0,disabled:w,onClick:()=>void q().catch(()=>{}),children:[t.jsx("span",{className:"codex-execution-trace__icon","aria-hidden":"true",children:w?t.jsx(bt,{size:14,strokeWidth:2}):L?t.jsx(Ci,{size:14,strokeWidth:2}):t.jsx(Ig,{size:14,strokeWidth:1.8})}),t.jsx("span",{className:"codex-execution-trace__label",children:se}),L&&t.jsx("span",{className:"codex-execution-trace__error",children:"加载失败"})]})]})}function Lx({messages:e,renderContent:n,runtimeProgress:r,nativeSubagents:s,onSelectSession:i,workspacePath:o,onOpenArtifact:l,onLoadResult:u}){const d=c.useMemo(()=>{const g=new Map;return fp(e).map(h=>{const p=(h.toolCalls??[]).map(k=>{const x=typeof k.arguments.file_path=="string"?k.arguments.file_path:void 0,y=k.name==="write_file"&&x?g.get(x):void 0;return k.name==="read_file"&&x&&k.result!==void 0&&!k.isError&&g.set(x,k.result),{toolCall:k,beforeContent:y,progress:Eu(r,k.id),nativeSubagent:s[k.id]}});return{message:h,toolGroups:gp(p)}})},[e,s,r]);return d.length===0?t.jsx("div",{className:"codex-execution-trace__empty",children:"这一轮没有可显示的执行过程"}):t.jsx("div",{className:"codex-execution-trace__timeline",children:d.map(({message:g,toolGroups:h})=>{var p,k,x;return t.jsxs("div",{className:"codex-execution-trace__item",children:[(k=(p=g.presentation)==null?void 0:p.reasoning)!=null&&k.length?t.jsx(up,{sections:g.presentation.reasoning,renderContent:n}):null,((x=g.presentation)==null?void 0:x.agentMessagePhase)==="commentary"&&g.content?t.jsx("div",{className:"codex-execution-trace__commentary",children:n(g.content)}):null,h.map(y=>y.action&&y.items.length>1?t.jsx(dp,{items:y.items,onSelectSession:i,workspacePath:o,onOpenArtifact:l,onLoadResult:u},`group-${y.items[0].toolCall.id}`):t.jsx(ya,{toolCall:y.items[0].toolCall,beforeContent:y.items[0].beforeContent,progress:y.items[0].progress,nativeSubagent:y.items[0].nativeSubagent,onSelectSession:i,workspacePath:o,onOpenArtifact:l,onLoadResult:u},y.items[0].toolCall.id))]},g.id)})})}function zx(e){const[n,r]=c.useState([]),[s,i]=c.useState(!0),[o,l]=c.useState(null),[u,d]=c.useState(null),[g,h]=c.useState(new Set),p=c.useRef(e),k=c.useRef(0),x=c.useRef(new Set);p.current=e;const y=c.useCallback(async()=>{const v=++k.current;try{const w=window.agentApi;if(!(w!=null&&w.listSessionBackgroundJobs))throw new Error("当前服务未提供后台任务接口,请更新服务");const j=await w.listSessionBackgroundJobs(e);if(p.current!==e||k.current!==v)return;r(j),l(null),h(C=>new Set([...C].filter(A=>j.some(L=>L.id===A&&L.status==="running"))))}catch(w){p.current===e&&k.current===v&&l(w instanceof Error?w.message:"后台任务读取失败")}finally{p.current===e&&k.current===v&&i(!1)}},[e]);c.useEffect(()=>{p.current=e;let v=!1,w=!1;r([]),l(null),d(null),i(!0),h(new Set),x.current.clear();const j=async()=>{if(!(v||w||!Dt())){w=!0;try{await y()}finally{w=!1}}};j();const C=window.setInterval(()=>{j()},3e3);return document.addEventListener("visibilitychange",j),()=>{v=!0,++k.current,p.current="",window.clearInterval(C),document.removeEventListener("visibilitychange",j)}},[e,y]);const S=c.useCallback(async v=>{if(x.current.has(v))return;const w=p.current;x.current.add(v),h(j=>new Set([...j,v])),d(null),++k.current;try{const j=window.agentApi;if(!(j!=null&&j.stopSessionBackgroundJob))throw new Error("当前服务未提供后台任务停止接口,请更新服务");await j.stopSessionBackgroundJob(e,v),p.current===w&&await y()}catch(j){p.current===w&&(d(j instanceof Error?j.message:"后台任务停止失败"),h(C=>{const A=new Set(C);return A.delete(v),A}))}finally{x.current.delete(v)}},[e,y]);return{jobs:n,loading:s,error:o,actionError:u,stopping:g,refresh:y,stop:S}}const Px={running:"运行中",stopping:"正在停止",completed:"已完成",killed:"已终止",failed:"失败"};function Dx({sessionId:e,jobId:n}){const[r,s]=c.useState(null),[i,o]=c.useState(null);return c.useEffect(()=>{let l=!1,u=!1;const d=async()=>{if(!(l||u||!Dt())){u=!0;try{const h=window.agentApi;if(!(h!=null&&h.getSessionBackgroundJobOutput))throw new Error("当前服务未提供任务输出接口,请更新服务");const p=await h.getSessionBackgroundJobOutput(e,n);l||(s(p),o(null))}catch(h){l||o(h instanceof Error?h.message:"任务输出读取失败")}finally{u=!1}}};d();const g=window.setInterval(()=>{d()},3e3);return document.addEventListener("visibilitychange",d),()=>{l=!0,window.clearInterval(g),document.removeEventListener("visibilitychange",d)}},[e,n]),t.jsxs("div",{className:"background-jobs__output",children:[i&&t.jsx("p",{className:"background-jobs__error",role:"alert",children:i}),(r==null?void 0:r.truncated)&&t.jsx("p",{children:"仅展示最近的输出"}),t.jsx("pre",{"aria-label":"任务实时输出",children:r?r.output||"暂无输出,任务可能正在等待或未输出进度。":i?"暂时无法读取输出":"正在读取输出…"})]})}function Wx({sessionId:e}){const n=zx(e),[r,s]=c.useState(!1),[i,o]=c.useState(null),l=c.useRef(null),u=c.useId(),d=`${u}-panel`,g=n.jobs.filter(p=>p.status==="running"||p.status==="stopping").length,h=()=>{var p;s(!1),o(null),(p=l.current)==null||p.focus({preventScroll:!0})};return t.jsxs("div",{className:"background-jobs",onKeyDown:p=>{r&&p.key==="Escape"&&(p.stopPropagation(),h())},children:[t.jsxs("button",{ref:l,type:"button",className:"background-jobs__trigger",onClick:()=>{r?h():s(!0)},"aria-expanded":r,"aria-controls":d,children:[t.jsx(Sg,{size:14,"aria-hidden":"true"}),"后台任务",t.jsx("span",{"aria-live":"polite",children:n.error?"连接异常":n.loading?"读取中":g?`${g} 个运行中`:`${n.jobs.length} 个任务`})]}),r&&t.jsxs("section",{id:d,className:"background-jobs__panel","aria-labelledby":u,children:[t.jsxs("header",{children:[t.jsx("h2",{id:u,children:"后台任务"}),t.jsx("button",{type:"button","aria-label":"刷新后台任务",title:"刷新",onClick:()=>{n.refresh()},children:t.jsx(go,{size:17})}),t.jsx("button",{type:"button","aria-label":"关闭后台任务",onClick:h,children:t.jsx(tr,{size:20})})]}),t.jsx("p",{className:"background-jobs__hint",children:"当前会话可见的任务。终止单个任务后,DeepSeek 会收到任务结束通知。"}),t.jsxs("div",{className:"background-jobs__list",children:[(n.error||n.actionError)&&t.jsx("p",{className:"background-jobs__error",role:"alert",children:n.actionError||n.error}),!n.jobs.length&&!n.error&&t.jsx("p",{className:"background-jobs__empty",children:n.loading?"正在读取后台任务…":"当前没有后台任务"}),n.jobs.map(p=>t.jsxs("article",{className:"background-jobs__item","data-status":p.status,children:[t.jsxs("div",{className:"background-jobs__meta",children:[t.jsx("span",{className:"background-jobs__status",children:Px[p.status]}),p.scope==="shared"&&t.jsx("span",{children:"共享任务"}),p.status==="running"||p.status==="stopping"?t.jsx(ha,{startedAt:p.startedAt}):p.finishedAt!==void 0&&t.jsxs("span",{children:[Math.max(0,Math.round((p.finishedAt-p.startedAt)/1e3))," 秒"]}),(p.canStop||p.status==="stopping"||n.stopping.has(p.id))&&t.jsxs("button",{type:"button",className:"background-jobs__stop",disabled:!p.canStop||n.stopping.has(p.id),"aria-label":`终止任务:${p.label}`,onClick:()=>{n.stop(p.id)},children:[t.jsx(no,{size:12,"aria-hidden":"true"}),p.status==="stopping"?"正在停止":n.stopping.has(p.id)?"停止已请求":"终止任务"]})]}),t.jsx("p",{className:"background-jobs__command",children:p.label}),p.detail&&t.jsx("p",{className:"background-jobs__detail",children:p.detail}),t.jsx("button",{type:"button",className:"background-jobs__output-toggle","aria-expanded":i===p.id,onClick:()=>o(i===p.id?null:p.id),children:i===p.id?"收起输出":"查看输出"}),i===p.id&&t.jsx(Dx,{sessionId:e,jobId:p.id},`${e}:${p.id}`)]},p.id))]})]})]})}function $x(e){return e.supported?e.needsSetup||e.status.enabled&&(e.status.permissionScreen!=="granted"||e.status.accessibilityTrusted!==!0):!1}function Bx(e,n){const[r,s]=c.useState(null),[i,o]=c.useState(""),[l,u]=c.useState(!1),d=c.useRef(n);d.current=n;const g=c.useRef(),h=c.useRef(!1),p=c.useRef(!1),k=c.useRef(0),x=S=>{if(s(S),o(""),!S.accessUrl||S.phase==="unsupported")return;const v=new URL(S.accessUrl).origin;v===d.current.origin?g.current=v:!d.current.busy&&g.current!==v&&(S.mode!=="local"||d.current.origin)&&(g.current=v,d.current.onAddressChanged())};return c.useEffect(()=>{p.current=!0;let S=!0,v;const w=async()=>{const j=k.current;try{const C=await e.tunnelStatus();S&&!h.current&&j===k.current&&x(C)}catch{S&&!h.current&&j===k.current&&o("无法读取公网连接状态,请检查后台服务。")}S&&(v=setTimeout(()=>void w(),1e3))};return w(),()=>{S=!1,p.current=!1,clearTimeout(v)}},[e]),{status:r,failure:i,requesting:l,connect:async()=>{if(!(h.current||(r==null?void 0:r.phase)==="connecting"||(r==null?void 0:r.phase)==="ready"||(r==null?void 0:r.phase)==="unsupported")){h.current=!0,k.current++,u(!0),o("");try{const S=await e.connectTunnel();p.current&&x(S)}catch{p.current&&o("无法发起公网连接,请检查后台服务后重试。")}finally{k.current++,h.current=!1,p.current&&u(!1)}}}}}function Ox({connection:e}){const{status:n,failure:r,requesting:s,connect:i}=e,o=s||(n==null?void 0:n.phase)==="connecting",l=(n==null?void 0:n.mode)==="public"&&n.phase==="ready",u=o?"正在连接公网":l?"公网已连接":(n==null?void 0:n.phase)==="unsupported"?"公网控制不可用":(n==null?void 0:n.mode)==="lan"?"仅局域网":n?"仅本机":"正在读取连接状态";return t.jsxs("section",{className:"tunnel-connection","aria-label":"公网连接",children:[t.jsxs("div",{className:"tunnel-connection-heading",children:[t.jsxs("span",{role:"status",className:l?"tunnel-connected":"",children:[o?t.jsx(bt,{size:15,className:"tunnel-spin","aria-hidden":"true"}):t.jsx(Mf,{size:15,"aria-hidden":"true"}),u]}),!l&&t.jsx("button",{type:"button",disabled:!n||o||n.phase==="unsupported",onClick:()=>void i(),children:o?"连接中…":(n==null?void 0:n.phase)==="error"||r?"重试连接":"开启公网连接"})]}),o&&t.jsx("p",{children:(n==null?void 0:n.stage)==="checking"?"正在检查公网地址是否可用…":"正在建立公网隧道,最多等待 30 秒…"}),(r||(n==null?void 0:n.error))&&t.jsx("p",{role:"alert",children:r||(n==null?void 0:n.error)}),!o&&!l&&(n==null?void 0:n.mode)==="lan"&&t.jsx("p",{children:"当前二维码仅支持同一网络,请让手机与电脑连接同一 Wi-Fi。"}),!o&&!l&&(n==null?void 0:n.mode)==="local"&&n.phase!=="unsupported"&&t.jsx("p",{children:"当前地址仅限这台电脑访问,请开启公网连接或连接可用的局域网。"})]})}function Fx(){const[e,n]=c.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"ui-icon-button desktop-app-action",title:"手机扫码连接","aria-label":"手机扫码连接","aria-haspopup":"dialog","aria-expanded":e,onClick:()=>n(!0),children:t.jsx(Lf,{size:17,"aria-hidden":"true"})}),e&&Wt.createPortal(t.jsx(qx,{onClose:()=>n(!1)}),document.body)]})}function qx({onClose:e}){const[n,r]=c.useState(null),[s,i]=c.useState(""),[o,l]=c.useState(0),[u,d]=c.useState(Date.now),g=c.useRef(null),h=Bx(window.sharedServiceApi,{origin:n==null?void 0:n.origin,busy:!n&&!s,onAddressChanged:()=>{r(null),l(k=>k+1)}});c.useEffect(()=>{let k=!0;return r(null),i(""),window.sharedServiceApi.mobilePairing().then(x=>{k&&r(x)},x=>{k&&i(x instanceof Error?x.message:"生成二维码失败,请重试。")}),()=>{k=!1}},[o]),c.useEffect(()=>{var S,v;const k=document.activeElement;(v=(S=g.current)==null?void 0:S.querySelector("button"))==null||v.focus();const x=w=>{var L;if(w.key==="Escape"&&e(),w.key!=="Tab")return;const j=(L=g.current)==null?void 0:L.querySelectorAll("button");if(!(j!=null&&j.length))return;const C=j[0],A=j[j.length-1];w.shiftKey&&document.activeElement===C?(w.preventDefault(),A.focus()):!w.shiftKey&&document.activeElement===A&&(w.preventDefault(),C.focus())};document.addEventListener("keydown",x);const y=setInterval(()=>d(Date.now()),1e3);return()=>{document.removeEventListener("keydown",x),clearInterval(y),k==null||k.focus()}},[e]);const p=n&&n.expiresAt<=u;return t.jsx("div",{className:"mobile-pairing-backdrop",onClick:k=>{k.currentTarget===k.target&&e()},children:t.jsxs("section",{ref:g,className:"mobile-pairing-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-pairing-title",children:[t.jsxs("header",{children:[t.jsx("h2",{id:"mobile-pairing-title",children:"手机扫码连接"}),t.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"关闭二维码",onClick:e,children:t.jsx(tr,{size:18})})]}),t.jsx("p",{children:"打开 AgentRoam App,点击右上角扫码按钮,扫描下方二维码。"}),t.jsx(Ox,{connection:h}),t.jsx("div",{className:"mobile-pairing-code","aria-busy":!n&&!s,children:n&&!p?t.jsx("img",{src:`data:image/svg+xml,${encodeURIComponent(n.svg)}`,alt:"AgentRoam 手机授权二维码"}):s?t.jsx("p",{role:"alert",children:s}):p?t.jsx("p",{children:"二维码已过期,请刷新"}):t.jsx(bt,{className:"spin",size:28,"aria-label":"正在生成二维码"})}),n&&t.jsx("small",{"aria-label":"手机配对链接",children:n.pairingUrl}),t.jsx("p",{children:"二维码仅可使用一次,5 分钟内有效。也可使用手机相机扫码进入网页版。"}),t.jsxs("button",{type:"button",className:"mobile-pairing-refresh",onClick:()=>l(k=>k+1),children:[t.jsx(go,{size:15}),"刷新二维码"]})]})})}function Ux({children:e}){const[n,r]=c.useState(!1),[s,i]=c.useState(null),[o,l]=c.useState({top:0,left:0}),u=c.useRef(null),d=c.useRef(null),g=c.useId();c.useEffect(()=>{i(document.body)},[]),c.useLayoutEffect(()=>{if(!n)return;const p=()=>{var v,w,j;const x=(v=u.current)==null?void 0:v.getBoundingClientRect();if(!x)return;const y=((w=d.current)==null?void 0:w.offsetWidth)??248,S=((j=d.current)==null?void 0:j.offsetHeight)??0;l({top:Math.max(8,Math.min(x.bottom+8,window.innerHeight-S-8)),left:Math.max(8,Math.min(x.right-y,window.innerWidth-y-8))})};p();const k=new ResizeObserver(p);return d.current&&k.observe(d.current),window.addEventListener("resize",p),window.addEventListener("scroll",p,!0),()=>{k.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0)}},[n,s]),c.useEffect(()=>{if(!n)return;const p=x=>{var S,v;const y=x.target;!((S=u.current)!=null&&S.contains(y))&&!((v=d.current)!=null&&v.contains(y))&&r(!1)},k=x=>{var y;x.key==="Escape"&&(x.preventDefault(),r(!1),(y=u.current)==null||y.focus())};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",k),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",k)}},[n]);const h=t.jsx("div",{ref:d,id:g,className:"header-action-menu-panel",role:"dialog","aria-label":"更多功能",hidden:!n,style:{position:"fixed",...o},children:e});return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:u,type:"button",className:"ui-icon-button header-action-menu-trigger",title:"更多功能","aria-label":"更多功能","aria-haspopup":"dialog","aria-expanded":n,"aria-controls":g,onClick:()=>r(p=>!p),onKeyDown:p=>{p.key==="ArrowDown"&&(p.preventDefault(),r(!0),requestAnimationFrame(()=>{var k,x;return(x=Array.from(((k=d.current)==null?void 0:k.querySelectorAll("button:not(:disabled)"))??[]).find(y=>y.getClientRects().length>0))==null?void 0:x.focus()}))},children:t.jsx(mf,{size:20,"aria-hidden":"true"})}),s?Wt.createPortal(h,s):h]})}function Hx(e){const[n,r]=c.useState(!1);return c.useEffect(()=>{if(!e)return;const s=window.agentApi;if(!(s!=null&&s.desktopLiveSetup)||!(s!=null&&s.onDesktopLiveStatus))return;let i=!0,o=null,l=null;const u=()=>{i&&o&&l&&r($x({...o,status:l}))},d=()=>void s.desktopLiveSetup().then(h=>{i&&(o={supported:h.supported,needsSetup:h.needsSetup},u())}).catch(()=>{});d();const g=s.onDesktopLiveStatus(h=>{l=h,o!=null&&o.needsSetup&&h.enabled&&h.permissionScreen==="granted"&&h.accessibilityTrusted===!0&&d(),u()});return()=>{i=!1,g()}},[e]),n}function Gx({appActions:e,appearanceOpen:n,settingsOpen:r,showSettings:s=!0,hideToBackgroundTitle:i="隐藏到后台",codexReleaseState:o="idle",onHideToBackground:l,onReleaseCodex:u,onOpenHub:d,onOpenCollaborationDashboard:g,onOpenSessionDashboard:h,onOpenMessaging:p,onOpenDesktopLive:k,desktopLiveOpen:x=!1,filesOpen:y=!1,onToggleFiles:S,onToggleAppearance:v,onOpenSettings:w}){var z;const j=Hx(!!k),C=xt(R=>R.navigationLayout),A=o==="releasing"?"正在停止 AgentRoam 使用此会话":o==="released"?"已停止在 AgentRoam 中使用;Codex Desktop 最长约 30 分钟后可用":"停止在 AgentRoam 中使用(Codex Desktop 最长约 30 分钟后可用)",L=t.jsxs("div",{className:"chat-header-actions",style:{WebkitAppRegion:"no-drag"},children:[e,typeof window<"u"&&((z=window.sharedServiceApi)==null?void 0:z.mobilePairing)&&t.jsx(Fx,{}),h&&t.jsx("button",{type:"button",onClick:h,title:"进行中的 Agent 会话","aria-label":"打开进行中的 Agent 会话",className:"ui-icon-button chat-header-action",children:t.jsx(zf,{size:17,"aria-hidden":"true"})}),p&&t.jsx("button",{type:"button",onClick:p,title:"消息接入 · 监听与路由","aria-label":"打开消息接入",className:"ui-icon-button chat-header-action",children:t.jsx(Hf,{size:17,"aria-hidden":"true"})}),g&&t.jsx("button",{type:"button",onClick:g,title:"群聊列表","aria-label":"打开群聊列表",className:"ui-icon-button chat-header-action chat-header-action--collaboration",children:t.jsx(xf,{size:17,"aria-hidden":"true"})}),k&&t.jsxs("button",{type:"button",onClick:k,title:j?"桌面直播与远程控制(待授权)":"桌面直播与远程控制","aria-label":"桌面直播与远程控制","aria-expanded":x,className:`ui-icon-button chat-header-action ${x?"is-active":""}`,style:{position:"relative"},children:[t.jsx(Pf,{size:15,"aria-hidden":"true"}),j&&t.jsx("span",{"data-desktop-live-pending":"","aria-hidden":"true",style:{position:"absolute",top:5,right:5,width:7,height:7,borderRadius:"50%",background:"var(--warning, #f59e0b)",border:"1px solid var(--bg-surface, #fff)"}})]}),d&&t.jsx("button",{type:"button",onClick:d,title:"AI Hub · 多模型网页对比","aria-label":"打开 AI Hub",className:"ui-icon-button chat-header-action chat-header-action--ai-hub",children:t.jsx(bf,{size:15,"aria-hidden":"true"})}),S&&t.jsx("button",{type:"button",onClick:S,title:"我的文件","aria-label":"我的文件","aria-expanded":y,className:`ui-icon-button chat-header-action chat-header-action--files ${y?"is-active":""}`,children:t.jsx(pu,{size:15,"aria-hidden":"true"})}),u&&t.jsx("button",{type:"button",onClick:u,title:A,"aria-label":A,disabled:o!=="idle",className:`ui-icon-button chat-header-action chat-header-action--codex-release is-${o}`,children:o==="releasing"?t.jsx(bt,{size:15,className:"spin","aria-hidden":"true"}):o==="released"?t.jsx(er,{size:15,"aria-hidden":"true"}):t.jsx(yu,{size:15,"aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:l,title:i,"aria-label":"隐藏后台",className:"ui-icon-button chat-header-action chat-header-action--background",children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"14",rx:"2"}),t.jsx("path",{d:"m9 11 3 3 3-3M12 7v7M8 21h8"})]})}),t.jsx("button",{type:"button",onClick:R=>v(R.currentTarget.getBoundingClientRect()),title:"皮肤与布局","aria-label":"皮肤与布局","aria-expanded":n,className:`ui-icon-button chat-header-action chat-header-action--appearance ${n?"is-active":""}`,children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),t.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),t.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),t.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),t.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})]})}),s&&t.jsx("button",{type:"button",onClick:w,title:"设置","aria-label":"设置","aria-expanded":r,className:`ui-icon-button chat-header-action chat-header-action--settings ${r?"is-active":""}`,children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]});return C!=="classic"&&!ns()?t.jsx(Ux,{children:L}):L}const Vx={pending:"⏳",image_generating:"🎨",video_generating:"🎬",done:"✅",error:"❌"};function Qx(e){const{title:n="视频工作台",shots:r=[],status:s="generating",composedVideoUrl:i,isAgentRunning:o}=e,[l,u]=c.useState(!1),[d,g]=c.useState(null);return t.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",background:"var(--bg-surface)",overflow:"hidden",maxWidth:600},children:[t.jsxs("div",{onClick:()=>u(!l),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",background:"var(--bg-deep)",cursor:"pointer",userSelect:"none",borderBottom:l?"none":"1px solid var(--border-subtle)"},children:[t.jsxs("span",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:["🎬 ",n]}),t.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:[r.filter(h=>h.status==="done").length,"/",r.length," 完成",t.jsx("span",{style:{marginLeft:6,transform:l?"rotate(-90deg)":"none",display:"inline-block",transition:"transform 0.2s"},children:"▼"})]})]}),!l&&t.jsxs("div",{style:{padding:"12px 16px"},children:[t.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:13,marginBottom:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"var(--bg-deep)"},children:[t.jsx("th",{style:Ji,children:"#"}),t.jsx("th",{style:{...Ji,textAlign:"left",minWidth:120},children:"画面描述"}),t.jsx("th",{style:Ji,children:"时长"}),t.jsx("th",{style:Ji,children:"状态"}),t.jsx("th",{style:Ji,children:"预览"})]})}),t.jsx("tbody",{children:r.map(h=>t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("td",{style:Yi,children:h.index}),t.jsx("td",{style:{...Yi,textAlign:"left",maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.description,children:h.description}),t.jsxs("td",{style:Yi,children:[h.duration,"s"]}),t.jsxs("td",{style:Yi,children:[Vx[h.status]??"⏳",h.error&&t.jsx("span",{style:{color:"var(--danger)",fontSize:11,marginLeft:4},title:h.error,children:"!"})]}),t.jsx("td",{style:Yi,children:h.videoUrl?t.jsx("button",{onClick:()=>g(h.videoUrl),style:{background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid rgba(79,110,247,0.22)",borderRadius:6,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"▶ 播放"}):h.previewImageUrl?t.jsx("img",{src:h.previewImageUrl,alt:`shot-${h.index}`,style:{width:48,height:32,objectFit:"cover",borderRadius:4,border:"1px solid var(--border-subtle)"}}):t.jsx("span",{style:{color:"var(--text-muted)",fontSize:11},children:"—"})})]},h.index))})]}),d&&t.jsx("video",{src:d,controls:!0,autoPlay:!0,style:{width:"100%",borderRadius:8,marginBottom:12,border:"1px solid var(--border-subtle)"}}),i&&t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",marginBottom:6},children:"完整视频"}),t.jsx("video",{src:i,controls:!0,style:{width:"100%",borderRadius:8,border:"1px solid var(--border-subtle)"}})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-muted)"},children:[s==="generating"&&t.jsx("span",{children:o===!1?"本轮已结束":"🔄 生成中..."}),s==="preview_ready"&&t.jsx("span",{children:"📷 预览图已就绪"}),s==="video_ready"&&t.jsx("span",{children:"🎬 视频片段已就绪"}),s==="composed"&&t.jsx("span",{children:"✅ 合成完成"})]})]})]})}const Ji={padding:"6px 10px",textAlign:"center",fontWeight:600,fontSize:12,color:"var(--text-muted)",borderBottom:"1px solid var(--border-subtle)"},Yi={padding:"6px 10px",textAlign:"center",fontSize:13,color:"var(--text-secondary)"},Kx={storyboard_workbench:Qx};function Jx(e,n,r,s=!0){return!e||n!==e?!1:r===e||r===null&&s}function Yx(e,n,r=Date.now()){return!e||e.sessionId!==n?e:{...e,until:r+9e4}}async function Xx(e){const{text:n,projectId:r,createSession:s,activateSession:i,showUserMessage:o,onSessionCreated:l,isCancelled:u}=e,d=!e.sessionId;let g=e.sessionId??null;if(!g){const h=await s(n.slice(0,60)||"语音任务",r||void 0);if(u!=null&&u())return null;g=h.id}return i(g),o(n,g),d&&l&&await l(g),g}async function Ad(e){var o,l,u;const n=((o=e.sessionId)==null?void 0:o.trim())||null,r=!n,s=r?await e.createSession(e.text.slice(0,60)||"New Session",e.projectId||void 0):void 0,i=n??(s==null?void 0:s.id.trim());if(!i)throw new Error("创建会话失败:服务端未返回会话 ID");return e.activateSession(i),e.showUserMessage(e.text,i),await((l=e.afterUserMessageShown)==null?void 0:l.call(e)),r&&await((u=e.onSessionCreated)==null?void 0:u.call(e,i,s)),i}function Zx(e=window){return new Promise(n=>{let r=!1,s;const i=()=>{r||(r=!0,s!==void 0&&e.clearTimeout(s),n())};s=e.setTimeout(i,100),e.requestAnimationFrame(()=>{e.setTimeout(i,0)})})}function eb(e){const n=e.trim().match(/^<heartbeat>([\s\S]*)<\/heartbeat>$/);if(!n)return null;const r=n[1],s=r.indexOf("<instructions>"),i=r.lastIndexOf("</instructions>");if(s<0||i<s)return null;const o=r.slice(0,s)+r.slice(i+15);return!/<automation_id>[^<>]+<\/automation_id>/.test(o)||o.replace(/<(automation_id|current_time_iso)>[^<>]*<\/\1>/g,"").trim()?null:r.slice(s+14,i).trim()}function tb(e){var u;const n="<oai-mem-citation>",r="</oai-mem-citation>",s=[],i=e.split(`
|
|
157
|
+
`),o=[];let l=null;for(let d=0;d<i.length;d++){const g=i[d],h=g.trim(),p=h.match(/^(`{3,}|~{3,})/);if(p){l?p[1][0]===l[0]&&p[1].length>=l.length&&(l=null):l=p[1],o.push(g);continue}if(!l&&h.startsWith(n)){const k=[h.slice(n.length)];for(;!k[k.length-1].includes(r)&&d+1<i.length;)k.push(i[++d]);const x=k.join(`
|
|
158
|
+
`),y=x.indexOf(r);if(y<0)break;const S=(u=x.slice(0,y).match(/<citation_entries>([\s\S]*?)<\/citation_entries>/))==null?void 0:u[1];for(const w of(S==null?void 0:S.split(`
|
|
159
|
+
`))??[]){const j=w.trim().match(/^(.+?):(\d+)(?:-(\d+))?\|note=\[(.*)\]$/);j&&s.push({source:`${j[1]}:${j[2]}${j[3]?`–${j[3]}`:""}`,note:j[4]})}const v=x.slice(y+r.length);v&&o.push(v);continue}if(!l&&d===i.length-1&&h.length>=2&&n.startsWith(h))break;o.push(g)}return{text:o.join(`
|
|
160
|
+
`).trimEnd(),citations:s}}function yi(e,n){return n?e[n]:void 0}function nb(e,n){const r=Object.fromEntries(Object.entries(e).filter(([,s])=>s.token!==n.token&&s.sourceSessionId!==n.sourceSessionId));return r[n.sourceSessionId]=n,n.forkSessionId&&(r[n.forkSessionId]=n),r}function rb(e,n){const r=e[n];return r?Object.fromEntries(Object.entries(e).filter(([,s])=>s.token!==r.token)):e}function sb(e,n,r=crypto.randomUUID()){return{token:r,sourceSessionId:e,payload:{...n,images:n.images?[...n.images]:void 0,agentIds:n.agentIds?[...n.agentIds]:void 0,restoreDraftOnFailure:n.restoreDraftOnFailure},sendAttempted:!1}}function _d(e,n){return e.forkSessionId===n&&e.sendAttempted?e:{...e,forkSessionId:n,sendAttempted:!0}}function Md(e){return`occupied-recovery:${e.token}`}function ib(e,n){return!!(e&&n&&(e.sourceSessionId===n||e.forkSessionId===n))}async function Ld(e){const n=await e.forkSession(e.sourceSessionId);return e.activateSession(n.id),await e.refreshAndSelect(n),n}function ob({goal:e,pending:n,error:r,onMutate:s}){const[i,o]=c.useState(!1),[l,u]=c.useState(""),[d,g]=c.useState(""),[h,p]=c.useState(null);if(c.useEffect(()=>{o(!1)},[e==null?void 0:e.id]),!e)return r?t.jsx("div",{className:"native-goal-error",role:"alert",children:r}):null;const k={id:e.id,revision:e.revision},x=e.phase==="active"&&e.activation==="armed",y=e.phase==="active"?x?"推进中":"待恢复":{paused:"已暂停",blocked:"已受阻",complete:"已完成"}[e.phase],S=async v=>{try{await s(v),v.action==="edit"&&o(!1)}catch{}};return t.jsxs("div",{className:`goal-queue thread-goal is-${e.phase}`,"aria-label":"DeepSeek Harness 目标",children:[t.jsxs("div",{className:"goal-queue__header",children:[t.jsx(eo,{size:14,"aria-hidden":"true"}),t.jsx("span",{children:"目标"}),t.jsx("span",{className:"goal-queue__count",children:y}),t.jsxs("span",{className:"thread-goal__usage",children:[e.roundsStarted,"/",e.maxGoalRounds," 轮"]})]}),i?t.jsxs("form",{className:"native-goal-edit",onSubmit:v=>{v.preventDefault(),!n&&h&&l.trim()&&Number.isSafeInteger(Number(d))&&Number(d)>0&&S({action:"edit",ref:h,objective:l,maxGoalRounds:Number(d)})},children:[t.jsx("input",{"aria-label":"目标内容",value:l,onChange:v=>u(v.target.value),disabled:n}),t.jsxs("label",{children:["轮数上限",t.jsx("input",{type:"number",min:"1",step:"1","aria-label":"目标轮数上限",value:d,onChange:v=>g(v.target.value),disabled:n})]}),t.jsx("button",{className:"goal-queue__action",type:"submit","aria-label":"保存目标",title:"保存目标",disabled:n||!l.trim()||!Number.isSafeInteger(Number(d))||Number(d)<1,children:t.jsx(er,{size:14})}),t.jsx("button",{className:"goal-queue__action",type:"button","aria-label":"取消编辑目标",title:"取消编辑",disabled:n,onClick:()=>o(!1),children:t.jsx(tr,{size:14})})]}):t.jsxs("div",{className:"goal-queue__row is-active",children:[t.jsx("span",{className:"goal-queue__objective",title:e.objective,children:e.objective}),x&&t.jsx("button",{className:"goal-queue__action",type:"button",disabled:n,"aria-label":"暂停目标续跑",title:"暂停目标续跑",onClick:()=>{S({action:"pause",ref:k})},children:"⏸"}),!x&&e.phase!=="complete"&&t.jsx("button",{className:"goal-queue__action",type:"button",disabled:n,"aria-label":"恢复目标续跑",title:"恢复目标续跑",onClick:()=>{S({action:"resume",ref:k})},children:t.jsx(hu,{size:12})}),t.jsx("button",{className:"goal-queue__action",type:"button",disabled:n,"aria-label":"编辑目标",title:"编辑目标",onClick:()=>{u(e.objective),g(String(e.maxGoalRounds)),p(k),o(!0)},children:t.jsx(Ll,{size:12})}),e.phase!=="complete"&&t.jsx("button",{className:"goal-queue__action",type:"button",disabled:n,"aria-label":"标记目标完成",title:"标记目标完成",onClick:()=>{S({action:"complete",ref:k})},children:t.jsx(er,{size:12})}),t.jsx("button",{className:"goal-queue__action",type:"button",disabled:n,"aria-label":"清除目标,停止续跑",title:"清除目标,停止续跑",onClick:()=>{S({action:"clear",ref:k})},children:t.jsx(Bs,{size:12})})]}),e.blockedReason&&t.jsx("div",{className:"native-goal-error",children:e.blockedReason.message}),r&&t.jsx("div",{className:"native-goal-error",role:"alert",children:r})]})}function ab(e,n){const[r,s]=c.useState(null),[i,o]=c.useState(null),[l,u]=c.useState(!1),d=c.useRef(e);d.current=e;const g=c.useRef(0),h=c.useRef(!1),p=c.useCallback(async(x,y=!0)=>{var w;if(!((w=window.agentApi)!=null&&w.getSessionNativeGoal))throw new Error("当前服务未提供原生目标接口,请更新服务");const S=++g.current,v=await window.agentApi.getSessionNativeGoal(x);return d.current===x&&g.current===S&&(s(v),y&&o(null)),v},[]);c.useEffect(()=>{if(++g.current,s(null),o(null),!n||!e)return;let x=!1,y=!1;const S=async()=>{if(!(x||y||h.current||!Dt())){y=!0;try{await p(e)}catch(w){!x&&d.current===e&&o(w instanceof Error?w.message:"目标读取失败")}finally{y=!1}}};S();const v=window.setInterval(()=>{S()},3e3);return document.addEventListener("visibilitychange",S),()=>{x=!0,++g.current,window.clearInterval(v),document.removeEventListener("visibilitychange",S)}},[e,n,p]);const k=c.useCallback(async(x,y)=>{var v;if(!((v=window.agentApi)!=null&&v.mutateSessionNativeGoal))throw new Error("当前服务未提供原生目标接口,请更新服务");if(h.current)throw new Error("目标正在更新,请稍候");h.current=!0;const S=++g.current;u(!0),o(null);try{const w=await window.agentApi.mutateSessionNativeGoal(x,y);return d.current===x&&g.current===S&&s(w),w}catch(w){throw d.current===x&&(o(w instanceof Error?w.message:"目标操作失败"),p(x,!1).catch(()=>{})),w}finally{h.current=!1,u(!1)}},[p]);return{goal:r,error:i,pending:l,refresh:p,mutate:k}}function lb(e,n){var l;const r=e.match(/^\/goal(?:\s+([\s\S]+))?$/i),s=r?((l=r[1])==null?void 0:l.trim())??"":e.trim();if(r&&!s)return"show";const i=r?s.toLowerCase():"",o=n?{id:n.id,revision:n.revision}:null;if(["pause","resume","clear","complete"].includes(i)){if(!o)throw new Error("当前没有目标");return{action:i,ref:o}}if(r&&/^edit(?:\s|$)/i.test(s)){if(!o)throw new Error("当前没有可编辑的目标");const u=s.slice(4).trim();if(!u)throw new Error("请输入新的目标内容");return{action:"edit",ref:o,objective:u}}if(!s)throw new Error("请输入目标内容");return{action:"create",objective:s}}const Za=1,Xi=1,zd=160;function Pd(e){return e.trim().replace(/^\/goal\s+/i,"").replace(/^\$([\w-]+)/,"/$1").trim()}function el(e){const r=e.trim().replace(/^每(?:隔)?/,"").match(/^(\d+(?:\.\d+)?)\s*(s|sec|秒|m|min|分钟?|h|hr|小时)$/i);if(r){const o=parseFloat(r[1]),l=r[2].toLowerCase(),u=l==="s"||l==="sec"||l==="秒"?o*1e3:l==="m"||l==="min"||l==="分"||l==="分钟"?o*6e4:o*36e5;return u>=36e5&&u%36e5===0?`每 ${u/36e5} 小时`:u>=6e4&&u%6e4===0?`每 ${u/6e4} 分钟`:`每 ${u/1e3} 秒`}const[s,i]=e.trim().split(/\s+/);return s==="0"&&i&&i!=="*"&&!i.includes("/")&&!i.includes(",")?`每天 ${i.padStart(2,"0")}:00`:`cron: ${e}`}function cb(e){const n=e.split(/(`[^`\n]+`)/g);return n.length<=1?e:t.jsx(t.Fragment,{children:n.map((r,s)=>s%2===1?t.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:"0.84em",background:"var(--chat-inline-code-bg, rgba(17,24,39,0.06))",padding:"1px 5px",borderRadius:4,color:"var(--accent)",border:"1px solid var(--border-subtle)"},children:r.slice(1,-1)},s):t.jsx("span",{children:r},s))})}function hp(e,n){return e.split(/(\*\*[^*]+\*\*|\*[^*]+\*)/g).map((s,i)=>{const o=`${n}-${i}`;return s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{style:{fontWeight:600,color:"var(--text-primary)"},children:s.slice(2,-2)},o):s.startsWith("*")&&s.endsWith("*")&&s.length>2?t.jsx("em",{children:s.slice(1,-1)},o):t.jsx("span",{children:s},o)})}function Dd(e,n){return e.split(/(`[^`\n]+`)/g).map((s,i)=>i%2===1?t.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:"0.84em",background:"var(--chat-inline-code-bg, rgba(17,24,39,0.06))",padding:"1px 5px",borderRadius:4,color:"var(--accent)",border:"1px solid var(--border-subtle)"},children:s.slice(1,-1)},`${n}-${i}`):hp(s,`${n}-${i}`))}function kl(e,n){return Nf(e).map((r,s)=>{if(r.type==="code"){const i=t.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:"0.84em",background:"var(--chat-inline-code-bg, rgba(17,24,39,0.06))",padding:"1px 5px",borderRadius:4,color:"var(--accent)",border:"1px solid var(--border-subtle)"},children:r.value},s);return/^https?:\/\/\S+$/i.test(r.value)?t.jsx(cd,{href:r.value,code:!0,children:i},s):i}if(r.type==="link")return t.jsx(cd,{href:r.href,children:Dd(r.label,`${s}-label`)},s);if(r.type==="artifact"){const i=!r.line&&Wu(r.path);if(i)return t.jsx(Rh,{path:r.path,label:r.label,kind:i,onOpenArtifact:n},s);if(!n)return t.jsx("span",{children:r.raw},s);const o=r.line?`${r.path}:${r.line}`:r.path,l=r.label.replace(/^`([^`\n]+)`$/,"$1");return t.jsxs("button",{type:"button",className:"chat-message-artifact-link",title:o,"aria-label":`打开交付物 ${l}`,onClick:()=>n(r.path),children:[t.jsx(Ml,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),t.jsx("span",{children:Dd(r.label,`${s}-label`)})]},s)}return hp(r.value,`${s}`)})}function db(e){if(e.length<2)return null;const n=o=>o.replace(/^\|/,"").replace(/\|$/,"").split("|").map(l=>l.trim()),r=n(e[0]),s=e[1].replace(/^\|/,"").replace(/\|$/,"");if(!/^[\s\-:|]+$/.test(s))return null;const i=e.slice(2).map(n);return{headers:r,rows:i}}function ub(e,n,r){const s=i=>({padding:"6px 14px",textAlign:"left",fontSize:13,fontWeight:i?600:400,color:i?"var(--text-primary)":"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",whiteSpace:"pre-wrap",wordBreak:"break-word"});return t.jsx("div",{style:{margin:"8px 0",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",overflow:"auto",background:"var(--bg-surface)"},children:t.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:13},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"var(--bg-deep)"},children:e.map((i,o)=>t.jsx("th",{style:s(!0),children:kl(i,r)},o))})}),t.jsx("tbody",{children:n.map((i,o)=>t.jsx("tr",{style:{background:o%2===0?"transparent":"rgba(0,0,0,0.015)"},children:i.map((l,u)=>t.jsx("td",{style:s(!1),children:kl(l,r)},u))},o))})]})})}function pb(e,n,r){return e.toLowerCase()==="mermaid"?t.jsx(zh,{code:n,complete:r}):t.jsxs("div",{style:{margin:"8px 0",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",overflow:"hidden",background:"var(--bg-surface)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 10px",background:"var(--bg-deep)",borderBottom:"1px solid var(--border-subtle)",fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em"},children:[e||"code",t.jsx(fb,{code:n})]}),t.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:12,lineHeight:1.6,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"auto",maxHeight:420},children:n})]})}function fb({code:e}){const[n,r]=c.useState("idle");c.useEffect(()=>{if(n==="idle")return;const i=window.setTimeout(()=>r("idle"),2e3);return()=>window.clearTimeout(i)},[n]);const s=n==="copied"?"已复制":n==="failed"?"复制失败,请重试":"复制代码";return t.jsx("button",{type:"button",className:"ui-icon-button","aria-label":s,title:s,onClick:async()=>r(await ji(e)?"copied":"failed"),children:n==="copied"?t.jsx(er,{size:14,"aria-hidden":"true"}):t.jsx(Si,{size:14,"aria-hidden":"true"})})}function mp(e,n){const r=tb(e),s=r.text.replace(/(^|\n)(?:[a-z][\w+#.-]{0,20}\n)?(?:复制|copy)\n(?:下载|download)(?:\n|$)/gi,"$1"),i=Rf(s).split(`
|
|
161
|
+
`),o=[];let l=0,u=0;const d=h=>h.trimStart().startsWith("```"),g=h=>i[h].trimStart().startsWith("|")&&h+1<i.length&&/^\|[\s\-:|]+\|$/.test(i[h+1].trim());for(;l<i.length;){if(d(i[l])){const h=i[l].trim().slice(3).trim();l++;const p=[];for(;l<i.length&&!d(i[l]);)p.push(i[l]),l++;const k=l<i.length;l++,o.push(t.jsx("div",{children:pb(h,p.join(`
|
|
162
|
+
`),k)},`code-${u++}`));continue}if(g(l)){const h=[];for(;l<i.length&&i[l].trimStart().startsWith("|");)h.push(i[l].trim()),l++;const p=db(h);p?o.push(t.jsx("div",{children:ub(p.headers,p.rows,n)},`tbl-${u++}`)):o.push(t.jsx("span",{children:h.map((k,x)=>t.jsxs("span",{children:[cb(k),x<h.length-1?`
|
|
163
|
+
`:null]},x))},`tbl-fb-${u++}`))}else{const h=[];for(;l<i.length&&!g(l)&&!d(i[l]);)h.push(i[l]),l++;h.length>0&&o.push(t.jsx("span",{children:h.map((p,k)=>t.jsxs("span",{children:[kl(p,n),k<h.length-1?`
|
|
164
|
+
`:null]},k))},`txt-${u++}`))}}return t.jsxs(t.Fragment,{children:[o,r.citations.length>0&&t.jsxs("details",{className:"memory-citations",children:[t.jsxs("summary",{children:["历史记忆引用 · ",r.citations.length]}),t.jsx("ul",{children:r.citations.map((h,p)=>t.jsxs("li",{children:[t.jsx("span",{children:h.source}),h.note&&t.jsxs("span",{children:[" — ",h.note]})]},p))})]})]})}const Il=[{value:"off",label:"关"},{value:"low",label:"低"},{value:"medium",label:"中"},{value:"high",label:"高"}],Wd=Object.fromEntries(Il.map(e=>[e.value,e.label])),gb=750,tl={low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},$d=qt,Cl=[{value:"request-approval",label:"请求批准",description:"编辑外部文件和使用互联网时始终询问"},{value:"auto-approval",label:"帮我批准",description:"仅对检测到的风险操作请求批准"},{value:"full-access",label:"完全访问权限",description:"可不受限制地访问互联网和你电脑上的任何文件"}];function Bd(e){return Cl.some(n=>n.value===e)?e:"full-access"}function Od(e,n=e){return n!==e?n:{"read-only":"只读","workspace-write":"工作区写入","danger-full-access":"完全访问权限",auto:"自动审核",custom:"自定义权限"}[e]??n}function hb({activeAgentType:e="customer-agent",selectedProjectId:n=null,selectedSessionId:r=null,onSessionCreated:s,onMessageSent:i,onSubSessionCreated:o,onSelectSession:l,onParallelSessionSelected:u,onSubAgentEvent:d,onRunComplete:g,sessionTitle:h,sessionSummary:p,initialSessionHistory:k,onSessionHistorySettled:x,workspacePath:y=null,workspaceSource:S,onOpenSettings:v,sidebarCollapsed:w=!1,onToggleSidebar:j,onOpenCollaborationDashboard:C,onOpenSessionDashboard:A,onOpenMessaging:L,settingsOpen:z=!1,onHideToBackground:R,onOpenHub:N,headerAppActions:T,onOpenDesktopLive:F,desktopLiveOpen:O=!1,fileDrawerOpen:q=!1,onToggleFiles:ae,onOpenArtifact:se,onToggleAppearance:we,appearanceOpen:Y=!1,hideToBackgroundTitle:K,voiceCommand:Q=null,runtimeHealth:Se,onSelectAgent:Pe,workspaces:oe,onSelectWorkspace:Ne,onPickWorkspaceFolder:at,focusComposerNonce:W}){var Cc,Ec,Rc,Nc,Tc,Ac,_c,Mc,Lc,zc,Pc;const X=_l(),ke=c.useRef(x);ke.current=x;const[_e,Je]=c.useState(null);c.useLayoutEffect(()=>{var a;(_e==null?void 0:_e.sessionId)===r&&_e.seed===k&&((a=ke.current)==null||a.call(ke,_e.sessionId,_e.seed))},[k,r,_e]);const it=c.useCallback(a=>mp(a,se),[se]),{messages:pt,messagesBySession:Ye,runningSessionId:$t,appendText:nr,addMessage:Te,setRunningSession:Ue,setSessionId:lt,updateToolResult:fr,updateSubAgentStatus:os,updateSubAgentProgress:U,updateMessage:Z,setMessages:G,getMessagesForSession:J,getSessionHistoryWindow:be,contextUsageBySession:Xe,runtimeProgressBySession:rr,nativeSubagentsBySession:Yt,setContextUsage:un,applyRunResult:dt,applyRuntimeProgress:gr,setRuntimeProgress:ut,clearRuntimeProgress:kn,applyNativeSubagentActivity:hr,setNativeSubagentActivities:Mr,applyReasoningSummary:Ut,applyCodexExecutionEvent:Nt,sessionId:In,todos:as,setTodos:Cn,cronTasks:pn,setCronTasks:gt}=Re(),[ft,mr]=c.useState({active:null,queued:[],history:[]}),[It,sr]=c.useState(null),[mo,xo]=c.useState(0),Tt=c.useMemo(()=>rh(pt,Ye,In,r),[pt,Ye,In,r]),En=c.useMemo(()=>fp(Sm(Fm(Tt.filter(a=>!a.isQueued),ft.queued),((p==null?void 0:p.agentType)??e)==="codex")),[e,p==null?void 0:p.agentType,ft.queued,Tt]),qs=c.useMemo(()=>{var a,b;return(b=(a=En.findLast(m=>m.executionTrace))==null?void 0:a.executionTrace)==null?void 0:b.turnId},[En]),{isConfigured:ir,profiles:yt,activeProfileId:Rn,switchActiveProfile:Ht,loadFromSystem:bo,contextWindow:Us,reasoningEffort:or,taskNotifications:Xt,setField:Ni,saveToSystem:ls}=ga(),xr=n!==null&&r===null,H=Ax(r,In,e,xr),fn=c.useRef(H);fn.current=H;const gn=!r&&!H,[cs,yo]=c.useState([e]),[ds,Lr]=c.useState(e);c.useEffect(()=>{gn&&(yo([e]),Lr(e))},[e,W,gn]);const Ce=gh({sessionId:H,onSelect:u,profileId:Rn||void 0,onQueueState:(a,b)=>Ct(a,b)});c.useEffect(()=>{if(!H||(p==null?void 0:p.id)===H||!Ce.group||!u)return;const a=Ce.group.members.find(b=>b.id===H);a&&u(a)},[H,p==null?void 0:p.id,Ce.group,u]);const At=!!Ce.group||gn&&cs.length>1,[us,va]=c.useState({}),On=c.useRef({}),_t=c.useCallback((a,b)=>{const m=a?nb(On.current,a):b?rb(On.current,b):On.current;On.current=m,va(m)},[]),nt=yi(us,H),[Mt,zr]=c.useState(!1),[vo,Hs]=c.useState(null),ps=c.useRef(!1),[ar,Pr]=c.useState("idle"),[wa,Gs]=c.useState(!1);c.useEffect(()=>{if(!ns()||!window.browserLiveApi)return;const a=()=>{window.parent!==window?window.parent.postMessage({type:vf},location.origin):Gs(!0)};return window.addEventListener(Wc,a),()=>window.removeEventListener(Wc,a)},[]);const[wo,Vs]=c.useState(null),[fs,Fn]=c.useState(null),Dr=Jm(r,p,gn?ds:e),Me=Dr.agentType,ht=Dr.ready&&Zm(p,Dr.agentType),Gt=yh(Me,ht,H),Zt=Gt.models,[Lt,Nn]=c.useState(()=>ro(Me)),[Tn,gs]=c.useState(!1),br=c.useRef(null),jo=c.useRef(null);c.useEffect(()=>{Nn(ro(Me)),gs(!1)},[Me]),c.useEffect(()=>{if(!Tn)return;const a=b=>{br.current&&!br.current.contains(b.target)&&gs(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[Tn]);const Ti=c.useCallback(a=>{Nn(b=>{const m={...b,...a};return hl(Me,m),m})},[Me]),Qs=c.useMemo(()=>ht?Zt.map(a=>({key:Sn(a),label:a.displayName||a.id,model:{id:a.id,...a.providerID?{providerID:a.providerID}:{}},reasoningEfforts:a.reasoningEfforts})):[],[ht,Zt]),So=c.useMemo(()=>Me==="opencode"?Pg(Zt):[],[Me,Zt]),hn=Gt.catalogReady,mn=c.useMemo(()=>Wl(Lt,Zt,hn),[Zt,hn,Lt]);c.useEffect(()=>{mn!==Lt&&(Nn(mn),hl(Me,mn))},[Me,mn,Lt]);const Ks=(Cc=mn.model)!=null&&Cc.id?Sn(mn.model):"",hs=c.useMemo(()=>{if(!ht)return[];const a=Qs.find(b=>b.key===Ks);return Dl(Me,a==null?void 0:a.reasoningEfforts)},[ht,Qs,Ks,Me]),en=mn.reasoningEffort&&hs.includes(mn.reasoningEffort)?mn.reasoningEffort:void 0,Wr=Qs.length>0,qn=(p==null?void 0:p.messageQueueVersion)===1,Js=zm(p==null?void 0:p.agentType),An=wo===H?"direct":fs?"incompatible":(Ec=p==null?void 0:p.compatibility)==null?void 0:Ec.status,ms=An!==void 0&&An!=="direct",ko=(p==null?void 0:p.readOnly)===!0||ms||(p==null?void 0:p.occupancy)==="owned-externally"&&p.agentType!=="codex"&&!Sd(p),Io=ib(nt,H),rt=Io&&(nt==null?void 0:nt.forkSessionId)!==H,Ai=ir||ht,Ze=Dr.ready&&Ai&&!ko&&!Io&&ar!=="released",xn=c.useRef(new Set),[tn,$r]=c.useState("idle"),Ys=c.useRef("idle"),xs=c.useRef(null),[Xs,_i]=c.useState(()=>Date.now()),bs=c.useCallback(a=>{xs.current=a,Ys.current="thinking",_i(Date.now()),$r("thinking")},[]),[ja,Co]=c.useState(null),nn=c.useCallback((a,b)=>{if(!(b!=null&&b.agentType)||b.agentType==="customer-agent"||!b.status)return;const m=Gl(b);Co(I=>(I==null?void 0:I.sessionId)===a&&I.running===m?I:{sessionId:a,running:m})},[]),ys=!!(H&&($t===H||xn.current.has(H)||Ce.isRunning(H))),lr=nx(p,ys),_n=Ce.group?Ce.isRunning(H):ex(p,H,ys,ja),yr=H?rr[H]??[]:[],Mi=H?Yt[H]??{}:{},Sa=yr.filter(a=>a.kind==="background-job"),Eo=Dg(yr.filter(a=>a.kind!=="background-job"));c.useEffect(()=>{bo()},[]),c.useEffect(()=>{window.agentApi&&window.agentApi.cronList().then(a=>gt(a))},[]);const[rn,vt]=c.useState(""),[Vt,bn]=c.useState(!1),Br=c.useRef(!1),[vr,Un]=c.useState(null),[vs,Qt]=c.useState(""),[Zs,Hn]=c.useState(null),[wt,Or]=c.useState(()=>new Set),cr=c.useRef(new Set),[ws,Fr]=c.useState(null),js=c.useRef(null),[Ro,ei]=c.useState(!1),[wr,Li]=c.useState(!1),[qr,Ur]=c.useState(!1),[Hr,yn]=c.useState("full-access"),[jt,Mn]=c.useState(p==null?void 0:p.nativePermissions),ti=kd(Me),Gr=ti?jt?Od(jt.currentValue,(Rc=jt.options.find(a=>a.value===jt.currentValue))==null?void 0:Rc.label):"原生权限":(Nc=Cl.find(a=>a.value===Hr))==null?void 0:Nc.label,[sn,No]=c.useState(!1),Gn=Me==="deepseek-harness"&&(p==null?void 0:p.nativeGoalSupported)!==!1,Vn=(p==null?void 0:p.nativeModelSelectionSupported)!==!1,Kt=ab(H,Gn),Ss=Gn&&Dr.ready&&Ai&&!ms;c.useEffect(()=>{(p==null?void 0:p.nativeGoalSupported)===!1&&No(!1)},[p==null?void 0:p.nativeGoalSupported]);const jr=At?Dr.ready&&!Ce.submitting:Ze||Ss&&sn,Bt=c.useRef("");Bt.current=JSON.stringify([Me,n,H]);const Qn=c.useRef(!1),[To,Oe]=c.useState(null),[Ao,ct]=c.useState(!1),Ln=c.useRef(null),ni=c.useRef(null),Ct=c.useCallback((a,b)=>{var _;const m=Ve.current||Ke.current;if(b===m&&(mr(Cd(a)),((_=a.active)==null?void 0:_.kind)==="message"&&xs.current!==b&&bs(b),vn.current==="anchored"))return;const I=J(b);G(Ka(I,a),b)},[bs,J,G]);c.useEffect(()=>{if(!wr)return;const a=b=>{Ln.current&&!Ln.current.contains(b.target)&&Li(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[wr]),c.useEffect(()=>{if(!qr)return;const a=b=>{ni.current&&!ni.current.contains(b.target)&&Ur(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[qr]),c.useEffect(()=>{Ur(!1)},[Me,H]),c.useEffect(()=>{yn(Bd(p==null?void 0:p.permissionMode)),Mn(p==null?void 0:p.nativePermissions)},[ht,r,p==null?void 0:p.permissionMode,p==null?void 0:p.nativePermissions]);const[ri,ge]=c.useState(null),[St,on]=c.useState(null),[zn,dr]=c.useState(null),[Vr,si]=c.useState(null),ks=(St==null?void 0:St.sessionId)===H?St.message:null,ii=Vr||ri||ks,[Pn,an]=c.useState(0),[_o,oi]=c.useState([]),[Dn,Et]=c.useState([]),[ai,Is]=c.useState(0),[ka,Cs]=c.useState(null),zt=c.useRef(null),Qr=c.useRef(null),li=c.useRef(()=>{}),ci=c.useRef(new Tg),Mo=c.useRef(()=>{}),Jt=c.useRef(null),Wn=c.useRef(null);Wn.current||(Wn.current=new bm);const Kn=c.useRef(null),vn=c.useRef("latest"),Jn=c.useRef(null),f=c.useRef(!1),E=c.useRef(null),M=c.useRef(0),D=c.useRef(0),$=c.useRef(null),ee=c.useRef(!1),te=c.useRef(!1),Ie=c.useRef(null),Le=c.useRef(!1),We=c.useRef(!1),Ge=c.useRef(null),de=c.useRef(null),ot=c.useRef(0),Qe=c.useRef(null),ln=c.useRef(new Map),Yn=c.useRef(new Set),Sr=c.useRef(new Map),Es=c.useRef(null),kr=c.useRef(null),Rt=c.useRef({text:rn,images:Dn});Rt.current={text:rn,images:Dn};const Ir=c.useRef(!1),kt=c.useRef(null),Xn=c.useRef(null),He=c.useRef(null);He.current||(He.current=new fh(new Du));const De=He.current,di=c.useRef(!1),Ia=c.useRef(null),ur=c.useRef(null),Ca=c.useRef(new vm),zi=c.useRef(Qm(zd)),[ec,tc]=c.useState(!1),[Ea,Lo]=c.useState(null),[Ra,Na]=c.useState(null),[Pi,Np]=c.useState("latest"),[Tp,ui]=c.useState(null),[Ap,pi]=c.useState(null),[_p,fi]=c.useState(!1),[Mp,nc]=c.useState(!1),[Ta,zo]=c.useState(!1),[Lp,Aa]=c.useState(!1),[gi,Po]=c.useState(!1),Do=c.useRef(null),[zp,Wo]=c.useState(!1),rc=c.useRef(null),Cr=c.useRef(null),sc=c.useRef(0);c.useEffect(()=>{var a;!W||W===sc.current||(sc.current=W,(a=Cr.current)==null||a.focus())},[W]);const _a=c.useRef(null),[Kr,ic]=c.useState(null),[Pp,oc]=c.useState([]),[Dp,ac]=c.useState([]),[Di,$o]=c.useState([]),[Wi,Rs]=c.useState(null),[Ns,Ts]=c.useState(null),$e=c.useCallback(a=>Ve.current===a?p==null?void 0:p.agentType:a.startsWith("runtime:codex:")?"codex":void 0,[p==null?void 0:p.agentType]),Ot=c.useCallback((a,b)=>{if(!b)return;const m=`${a}:${b}`;Qe.current!==m&&(Qe.current=m,ln.current.clear())},[]),Ma=c.useCallback(async a=>{const b=window.agentApi,m=Ve.current;if(!b||!m)throw new Error("当前会话不可用");Ot(m,a.revision);const I=`${a.turnId}:${a.itemId}`;let _=ln.current.get(I);_||(_=b.getSessionToolResult(m,a),ln.current.set(I,_),_.catch(()=>{ln.current.get(I)===_&&ln.current.delete(I)}));const P=await _;return Ve.current!==m||Qe.current!==`${m}:${a.revision}`,P},[Ot]),lc=c.useCallback(async a=>{const b=Ve.current;if(!b)throw new Error("当前会话不可用");const m=await Ma(a);Ve.current===b&&fr(a.itemId,m.content,m.isError,b)},[Ma,fr]),$n=c.useCallback((a,b)=>{const m=window.agentApi;if(!b||!m)return;const I=()=>{Ve.current===a&&Wn.current.prefetch(a,b,()=>m.getSession(a,{before:b,limit:$e(a)==="codex"?Xi:pr,...$e(a)==="codex"?{view:"core"}:{}})).catch(P=>{console.warn("[chat] failed to prefetch older history",{sessionId:a,error:P})})},_=[...qi.current.values()];_.length?Promise.allSettled(_).then(I):I()},[$e]),Wp=c.useCallback(async a=>{const b=window.agentApi,m=Ve.current;if(!b||!m)throw new Error("当前会话不可用");const I=JSON.stringify([m,a.turnId,a.revision]),_=qi.current.get(I);if(_)return _;const P=(async()=>{var re;const ie=await am(b,m,a,pr),B=ie.detail;if(Ve.current!==m)throw new DOMException("Session selection changed","AbortError");if(((re=B==null?void 0:B.history)==null?void 0:re.revision)!==ie.revision)throw new Error("会话内容已更新,请重新展开执行过程");ie.recovered&&G(J(m).map(Be=>Be.executionTrace?{...Be,executionTrace:{...Be.executionTrace,revision:ie.revision}}:Be),m),Ot(m,ie.revision);const me=um(B),ue=J(m),pe=Ru(ue,me);return(pe.some((Be,V)=>Be!==ue[V])||pe.length!==ue.length)&&G(pe,m),$n(m,Jt.current),me})();return qi.current.set(I,P),P.finally(()=>{qi.current.get(I)===P&&qi.current.delete(I)}).catch(()=>{}),P},[J,$n,G,Ot]);c.useEffect(()=>{Qe.current=null,ln.current.clear()},[r]);const As=c.useCallback(a=>{vn.current=a,Np(a)},[]);c.useEffect(()=>{const a=Es.current,b=$m(a,H,rn);if(Es.current=b.ownerSessionId,b.type==="inactive"){a&&(Xn.current=null,De.restore(null),Et([]));return}if(b.type==="restore"){if(kr.current===b.ownerSessionId){kr.current=null,dn(b.ownerSessionId,rn),Xn.current=null,De.adopt(b.ownerSessionId,Rt.current.images);return}kr.current=null;const I=b.ownerSessionId.startsWith("runtime:")?yi(On.current,b.ownerSessionId):void 0;vt((I==null?void 0:I.payload.content)??Ko(b.ownerSessionId)),Et([]),Xn.current=b.ownerSessionId,De.restore(b.ownerSessionId).then(_=>{if(!_||Es.current!==_.sessionId)return;Xn.current===_.sessionId&&(Xn.current=null);const P=(I==null?void 0:I.payload.images)??_.images;Et(P),I&&De.save(_.sessionId,P)});return}if(Ir.current&&rn===""){Ir.current=!1;return}dn(b.ownerSessionId,b.value)},[De,rn,H]),c.useEffect(()=>{if(!(!H||Es.current!==H)&&Xn.current!==H){if(kt.current===H&&Dn.length===0){kt.current=null;return}De.saveSelected(H,Dn)}},[De,Dn,H]);const $p=()=>{const a=zt.current;if(!a)return;const b=a.scrollHeight-a.scrollTop-a.clientHeight;a.scrollTop<=240&&li.current(),vn.current==="anchored"&&b<=240&&Mo.current(),Aa(zi.current.onScroll(b)),a.classList.add("is-scrolling"),Qr.current!==null&&window.clearTimeout(Qr.current),Qr.current=window.setTimeout(()=>{a.classList.remove("is-scrolling"),Qr.current=null},700)};c.useEffect(()=>()=>{Qr.current!==null&&window.clearTimeout(Qr.current)},[]);const Bp=c.useCallback(()=>{const a=zt.current;if(!a)return;zi.current.requestReturn();const b=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;a.scrollTo({top:a.scrollHeight,behavior:b?"auto":"smooth"})},[]);c.useEffect(()=>{zi.current.reset(),Aa(!1)},[r]),c.useLayoutEffect(()=>{const a=Ia.current,b=zt.current;!a||!b||(b.scrollTop=a.scrollTop+(b.scrollHeight-a.scrollHeight),Ia.current=null)},[Tt]),c.useLayoutEffect(()=>{const a=$.current,b=zt.current;if(!a||!b)return;const m=Array.from(b.querySelectorAll("[data-message-id]")).find(I=>I.dataset.messageId===a);m&&(nl(b,m),$.current=null,ui(a))},[Tt]),c.useLayoutEffect(()=>{const a=zt.current;!ee.current||!a||Pi!=="latest"||(ee.current=!1,a.scrollTop=a.scrollHeight)},[Pi,Tt]),c.useLayoutEffect(()=>{if(ur.current!=="skip")return;const a=zt.current;a&&Aa(a.scrollHeight-a.scrollTop-a.clientHeight>zd)},[Tt]);const[Bn,Bo]=c.useState(!1),[Oo,hi]=c.useState(!1),[_s,Fo]=c.useState(!1),[La,qo]=c.useState(null),[$i,Bi]=c.useState(null),Ms=c.useRef(null),Jr=c.useRef(0),Oi=c.useRef(null);c.useEffect(()=>{if(!La)return;const a=window.setTimeout(()=>qo(null),4e3);return()=>window.clearTimeout(a)},[La]),c.useEffect(()=>(Bo(!1),hi(!1),Fo(!1),qo(null),()=>{Jr.current+=1;const a=Ms.current;Ms.current=null,a!=null&&a.cancel?a.cancel():a==null||a.stop()}),[r,n]),c.useEffect(()=>{const a=window.agentApi;if(!(a!=null&&a.onTtsStart)||!a.onTtsPcm||!a.onTtsStreamEnd||!a.onTtsFlush)return;const b=new om(a);Oi.current=b;const m=[a.onTtsStart(I=>b.start(I)),a.onTtsPcm(({generation:I,pcm:_})=>b.enqueue(I,_)),a.onTtsStreamEnd(({generation:I})=>b.finish(I)),a.onTtsFlush(({generation:I})=>b.flush(I)),a.onTtsEnd(()=>Bi(null))];return()=>{for(const I of m)I();b.dispose(),Oi.current===b&&(Oi.current=null)}},[]);const cc=()=>{var I,_;if(_s)return;if(Bn){Fo(!0),(I=Ms.current)==null||I.stop();return}ns()&&((_=Oi.current)==null||_.prepare().catch(()=>{})),Qo(window.agentApi,Ki);const a=rn?`${rn.trimEnd()} `:"",b=++Jr.current;qo(null),hi(!0);const m=tm({onStart:()=>{b===Jr.current&&hi(!1)},onInterim:P=>{b===Jr.current&&vt(a+P)},onFinal:P=>{var ie;b===Jr.current&&(vt(a+P),(ie=Cr.current)==null||ie.focus())},onError:P=>{b===Jr.current&&qo(P)},onEnd:()=>{b===Jr.current&&(Bo(!1),hi(!1),Fo(!1),Ms.current=null)}});m?(Ms.current=m,Bo(!0)):hi(!1)},Op=async(a,b)=>{var I,_;const m=(I=Oi.current)==null?void 0:I.prepare();if(m==null||m.catch(()=>{}),$i===a){await Qo(window.agentApi,Ki),Bi(null);return}if(await Qo(window.agentApi,Ki),!((_=window.agentApi)!=null&&_.ttsSpeak)){ge("TTS 模型服务不可用");return}Bi(a);try{await m,(await window.agentApi.ttsSpeak(b)).ok||(Bi(null),ge("TTS 模型播报失败"))}catch(P){Bi(null),ge(P instanceof Error?P.message:"TTS 模型播报失败")}},et=c.useRef(null),Ls=c.useRef(!1),Er=c.useRef(new Set),Fi=c.useRef(new Map),dc=c.useRef(new Set),wn=c.useRef(new Map),Yr=c.useRef(null),Ve=c.useRef(r??null),uc=c.useRef({onRunComplete:g,selectedProjectId:n}),Ke=c.useRef(null),cn=c.useRef(0),pc=c.useRef(),qi=c.useRef(new Map);c.useEffect(()=>{Ve.current=r??null},[r]),c.useEffect(()=>{uc.current={onRunComplete:g,selectedProjectId:n}},[g,n]),c.useEffect(()=>{Ke.current=In},[In]),c.useEffect(()=>()=>{for(const a of Fi.current.values())window.clearTimeout(a);Fi.current.clear()},[]);const Uo=c.useCallback(async a=>{var m;const b=a||Ve.current||Ke.current;if(!b||!((m=window.agentApi)!=null&&m.getSessionGoals)){mr({active:null,queued:[],history:[]});return}try{const I=await window.agentApi.getSessionGoals(b);Ct(I,b),I.active&&(et.current=b,Ue(b))}catch(I){ge(I instanceof Error?I.message:"目标状态加载失败")}},[Ct,Ue]);c.useEffect(()=>{Uo(H)},[H,Uo]);const Ui=c.useCallback(async a=>{var m;const b=a||Ve.current||Ke.current;if(!b||typeof((m=window.agentApi)==null?void 0:m.getThreadGoal)!="function"){sr(null);return}try{sr(await window.agentApi.getThreadGoal(b))}catch{sr(null)}},[]);c.useEffect(()=>{Ui(H)},[H,Ui]);const za=c.useCallback(async a=>{var m;const b=Ve.current||Ke.current;if(!(!b||typeof((m=window.agentApi)==null?void 0:m.clearThreadGoal)!="function"))try{a==="clear"?(await window.agentApi.clearThreadGoal(b),sr(null)):typeof window.agentApi.updateThreadGoal=="function"&&sr(await window.agentApi.updateThreadGoal(b,a))}catch(I){ge(I instanceof Error?I.message:"目标模式操作失败")}},[ge]),Pt=c.useCallback(a=>{const b=Ve.current||Ke.current;a!=="idle"&&xs.current!==b?(xs.current=b,_i(Date.now())):a==="idle"&&(xs.current=null),Ys.current=a,$r(a)},[]);c.useEffect(()=>{zr(!1),Pr("idle"),dr(null),Cs(null)},[r]),c.useEffect(()=>{window.agentApi&&(window.agentApi.listAgentDefs().then(a=>oc(a)),window.agentApi.listSkills().then(a=>ac(a.filter(b=>b.name))).catch(a=>console.error("[listSkills] mount error:",a)))},[]);const fc=Wi===null?[]:Pp.filter(a=>Wi===""||a.name.toLowerCase().includes(Wi.toLowerCase())),Pa=Ns===null?[]:[...[{name:"goal",description:"目标模式:持续推进当前目标,后续目标自动排队"},{name:"compact",description:"主动压缩当前会话上下文,并在下轮重新注入环境"},{name:"loop",description:"定时任务:/loop 5m 任务 | list | pause/resume/delete <id> | stop"}].filter(a=>Ns===""||a.name.toLowerCase().includes(Ns.toLowerCase())),...Dp.filter(a=>Ns===""||a.name.toLowerCase().includes(Ns.toLowerCase()))],Fp=a=>{$o(b=>b.find(m=>m.id===a.id)?b:[...b,a]),vt(b=>b.replace(/@[\w\u4e00-\u9fff]*$/,"")),Rs(null),setTimeout(()=>{var b;return(b=Cr.current)==null?void 0:b.focus()},0)},qp=a=>{$o(b=>b.filter(m=>m.id!==a))},Up=a=>{vt(b=>b.replace(/\/[\w\u4e00-\u9fff\-_]*$/,`/${a.name} `)),Ts(null),setTimeout(()=>{var b;return(b=Cr.current)==null?void 0:b.focus()},0)},gc=a=>{var I,_;vt(a);const b=a.match(/@([\w\u4e00-\u9fff]*)$/);if(b){window.agentApi&&window.agentApi.listAgentDefs().then(P=>oc(P)),ic(((I=_a.current)==null?void 0:I.getBoundingClientRect())??null),Rs(b[1]),Ts(null);return}const m=a.match(/\/([-\w\u4e00-\u9fff]*)$/);if(m){window.agentApi&&window.agentApi.listSkills().then(P=>ac(P.filter(ie=>ie.name))).catch(P=>console.error("[listSkills] slash error:",P)),ic(((_=_a.current)==null?void 0:_.getBoundingClientRect())??null),Ts(m[1]),Rs(null);return}Rs(null),Ts(null)},Hp=a=>{gc(a),Rs(null),Ts(null),requestAnimationFrame(()=>{var b;return(b=Cr.current)==null?void 0:b.focus()})},Gp=a=>{if(Bn){a.preventDefault();return}const b=Vm(a,{pickerOpen:Wi!==null||Ns!==null,running:ys});b&&(b==="dismiss-picker"?(a.preventDefault(),Rs(null),Ts(null)):b==="abort"?(a.preventDefault(),Ba("keyboard")):b==="send"&&(a.preventDefault(),Ic()))},Vp=async a=>{const b=Array.from(a.target.files??[]);if(a.target.value="",b.length===0)return;const m=b.filter(I=>I.type.toLowerCase().startsWith("image/")).length;m>0&&Is(I=>I+1);try{const I=await Ef(b,async P=>hc(await $c(P)));I.attachments.length>0&&oi(P=>[...P,...I.attachments]),I.images.length>0&&(Et(P=>[...P,...I.images]),ht||Jp());const _=[...I.unsupportedImages,...I.failedImages];_.length>0&&ge(`无法添加图片:${_.map(P=>P.name).join("、")}。仅支持 JPG、PNG、GIF 和 WebP。`)}finally{m>0&&Is(I=>Math.max(0,I-1))}},Qp=a=>{oi(b=>b.filter((m,I)=>I!==a))},Kp=/claude-3|gpt-4-vision|gpt-4o|gpt-4-turbo|gemini|deepseek-vl/i,Da=a=>Kp.test(a),Jp=()=>{const a=yt.find(m=>m.id===Rn);if(a&&Da(a.modelId))return;const b=yt.find(m=>Da(m.modelId));b&&Ht(b.id)},Yp=a=>{Et(b=>[...b,a])},Xp=a=>{Et(b=>b.filter((m,I)=>I!==a))},hc=a=>new Promise((b,m)=>{const I=new FileReader;I.onload=()=>b(I.result),I.onerror=m,I.readAsDataURL(a)});c.useEffect(()=>{const a=async b=>{if(!b.clipboardData)return;const m=Array.from(b.clipboardData.items).find(_=>_.type.startsWith("image/"));if(!m)return;b.preventDefault();const I=m.getAsFile();if(I){Is(_=>_+1);try{Yp(await hc(await $c(I)))}catch{ge("无法添加图片。仅支持 JPG、PNG、GIF 和 WebP。")}finally{Is(_=>Math.max(0,_-1))}}};return window.addEventListener("paste",a),()=>window.removeEventListener("paste",a)},[yt,Rn]),c.useEffect(()=>{const a=ur.current;if(ur.current=null,!zi.current.shouldFollow(a))return;const b=zt.current;b==null||b.scrollTo({top:b.scrollHeight,behavior:"auto"})},[Tt]),c.useEffect(()=>window.agentApi?window.agentApi.onEvent(b=>Zp(b)):void 0,[In]),c.useEffect(()=>{const a=++cn.current,b=r,m=()=>cn.current===a&&Ve.current===b;return(async()=>{var ie,B,me;const _=window.agentApi;if(!_)return;if(Jx(et.current,Ke.current,b,!xr&&H!==null)){b&&m()&&Je({sessionId:b,seed:k});return}if(!b){if(!m())return;(ie=Wn.current)==null||ie.invalidate(),ge(null),on(null),si(null),Vs(null),Fn(null),Jt.current=null,Jn.current=null,M.current+=1,E.current=null,Na(null),As("latest"),ui(null),pi(null),te.current=!1,zo(!1),fi(!1),Lo(null),Po(!1),Wo(!1),Kn.current=null,Ke.current=null,lt(""),yn("full-access");return}ge(null),on(null),si(null),Vs(null),Fn(null),Lo(null),(B=Wn.current)==null||B.invalidate(),D.current+=1,Jt.current=null,Jn.current=null,As("latest"),fi(!1),ui(null),pi(null),te.current=!1,zo(!1),((me=E.current)==null?void 0:me.sessionId)!==b&&(M.current+=1,E.current=null,Na(null)),Po(!0),Wo(!0),Kn.current=b,Ke.current=b,lt(b);const P=J(b);G(P,b),Do.current=b;try{await Lm(async()=>{if(!m())throw new DOMException("Session selection changed","AbortError");const ue=Ca.current.capture(b),pe=(k==null?void 0:k.sessionId)===b&&pc.current!==k?k:void 0;return await bi(_,b,$e(b),{limit:$e(b)==="codex"?Za:pr},(re,Be)=>{var qe,Ee,ne;if(!m()||!ue())return;nn(b,re);const V=re,le=Kc((re==null?void 0:re.events)??[]),ce=Gc((re==null?void 0:re.events)??[]),ze=Jc((re==null?void 0:re.events)??[]),xe=Ds(re);Ot(b,(qe=re==null?void 0:re.history)==null?void 0:qe.revision),p!=null&&p.compatibility&&Vs(b),yn(Bd((V==null?void 0:V.permissionMode)??((Ee=V==null?void 0:V.metadata)==null?void 0:Ee.permissionMode))),Mn(V==null?void 0:V.nativePermissions),Jn.current=null;const Fe=J(b),Ae=md(Fe,xe,Be,re==null?void 0:re.history,be(b)),mt=re!=null&&re.goalState?Ka(Ae.messages,re.goalState):Ae.messages;Jt.current=Ae.window.olderCursor,ur.current="instant",G(mt,b,Ae.window),($e(b)!=="codex"||!mt.some(he=>he.executionTrace))&&$n(b,Ae.window.olderCursor),ut(ce,b),Mr(ze,b),Yu(re)||tx(re)?(et.current=b,Ue(b)):et.current===b&&(et.current=null,Ue(null));const je=ld(re);on(je?{sessionId:b,message:je}:null),le&&un(le,b);const fe=mt[mt.length-1];(fe==null?void 0:fe.role)==="assistant"&&((ne=fe.toolCalls)!=null&&ne.length)?Pt(Nd(fe.toolCalls)?"thinking":"tools"):Pt((re==null?void 0:re.agentType)!=="customer-agent"&&(re==null?void 0:re.status)==="running"?"thinking":"idle"),Po(!1),Wo(!1)},()=>m()&&ue(),pe?async()=>(pc.current=pe,pe.detail):void 0),!0})}catch(ue){if(!m())return;console.error("[chat] failed to restore session",{sessionId:b,error:ue});const pe=Mm(ue);si(pe),p!=null&&p.compatibility&&Fn(pe)}finally{m()&&(Do.current=null,Po(!1),Wo(!1),Je({sessionId:b,seed:k}))}})(),()=>{cn.current===a&&(cn.current+=1,Do.current=null)}},[e,J,be,$e,k,xr,nn,$n,r,Pn,un,As,G,lt,Ot,Pt]);const Xr=c.useCallback(async a=>{const b=window.agentApi;if(!(b!=null&&b.getSessionQueryIndex))return null;const m=++M.current;try{const I=await b.getSessionQueryIndex(a);return M.current!==m||Ve.current!==a||I.sessionId!==a?null:(E.current=I,Na(I),I)}catch(I){return M.current===m&&console.warn("[chat] failed to load query index",{sessionId:a,error:I}),null}},[]),Ho=c.useCallback(a=>{if(!Dt()||(de.current!==a&&(Ge.current!==null&&window.clearTimeout(Ge.current),de.current=a,Ge.current=null,ot.current=0),Ge.current!==null))return;const b=Math.max(0,gb-(Date.now()-ot.current));Ge.current=window.setTimeout(()=>{Ge.current=null,ot.current=Date.now(),Dt()&&Ve.current===a&&xo(m=>m+1)},b)},[]);c.useEffect(()=>{var P;const a=r;if(!a||gi||!((P=window.agentApi)!=null&&P.getSessionQueryIndex))return;let b=!1;const m=()=>{!b&&Ve.current===a&&Xr(a)},I=window,_=I.requestIdleCallback?I.requestIdleCallback(m,{timeout:1e3}):window.setTimeout(m,0);return()=>{b=!0,I.cancelIdleCallback&&I.requestIdleCallback?I.cancelIdleCallback(_):window.clearTimeout(_)}},[gi,Xr,r,Pn]);const zs=c.useCallback(async a=>{if(!window.agentApi||!Dt())return;if(yd($e(a),a,Re.getState().runningSessionId)){$e(a)==="codex"&&Ho(a);return}if(vn.current==="anchored"){fi(!0);return}if(Ie.current!==a&&(Ie.current=a,Le.current=!1,We.current=!1),Le.current){We.current=!0;return}const b=cn.current,m=D.current;Le.current=!0;try{do{We.current=!1;const I=Ca.current.capture(a);await bi(window.agentApi,a,$e(a),{limit:$e(a)==="codex"?Za:pr},(_,P)=>{var le,ce,ze,xe,Fe;if(!I())return;if(yd($e(a),a,Re.getState().runningSessionId)){$e(a)==="codex"&&Ho(a);return}nn(a,_);const ie=Ds(_),B=J(a),me=md(B,ie,P,_==null?void 0:_.history,be(a)),ue=_!=null&&_.goalState?Ka(me.messages,_.goalState):me.messages,pe=zt.current,re=!pe||pe.scrollHeight-pe.scrollTop-pe.clientHeight<80;ur.current=re?null:"skip",G(ue,a,me.window),Ot(a,(le=_==null?void 0:_.history)==null?void 0:le.revision),kd(_==null?void 0:_.agentType)&&Mn(_==null?void 0:_.nativePermissions),_!=null&&_.goalState&&mr(Cd(_.goalState)),Jt.current!==me.window.olderCursor&&((ce=Wn.current)==null||ce.invalidate(),Jt.current=me.window.olderCursor,$n(a,me.window.olderCursor)),(ze=_==null?void 0:_.history)!=null&&ze.revision&&_.history.revision!==((xe=E.current)==null?void 0:xe.revision)&&Xr(a);const Be=Kc((_==null?void 0:_.events)??[]);if(ut(Gc((_==null?void 0:_.events)??[]),a),Mr(Jc((_==null?void 0:_.events)??[]),a),Be&&un(Be,a),et.current!==a){const Ae=ld(_);on(Ae?{sessionId:a,message:Ae}:null)}const V=ue[ue.length-1];(V==null?void 0:V.role)==="assistant"&&((Fe=V.toolCalls)!=null&&Fe.length)?Pt(Nd(V.toolCalls)?"thinking":"tools"):Pt(Hl(_)?"thinking":"idle")},()=>Ve.current===a&&Kn.current===a&&cn.current===b&&D.current===m&&vn.current==="latest"&&I()),$e(a)==="codex"&&Ho(a)}while(We.current)}catch(I){console.error("[chat] failed to refresh native session history",{sessionId:a,error:I})}finally{Ie.current===a&&(Le.current=!1)}},[J,be,$e,Xr,nn,$n,Ho,un,G,Ot,Pt]);c.useEffect(()=>{const a=r,b=(p==null?void 0:p.agentType)==="deepseek-harness"||rx(p,a)||(p==null?void 0:p.agentType)==="customer-agent"&&a!==$t,m=sx(p);if(!X||!a||!b||!window.agentApi)return;let I=null,_=null,P=!1;const ie=()=>{!P&&Dt()&&zs(a)},B=()=>{I==null||I(),I=null,_==null||_(),_=null},me=()=>{P||_!==null||!Dt()||(_=ym(ie,()=>Do.current!==a))},ue=()=>{if(!(P||!Dt())){if(Xu(p)||typeof window.agentApi.observeSession!="function"){m&&me();return}try{I=window.agentApi.observeSession(a,ie,()=>{I=null,m&&me()})}catch{m&&me()}}},pe=()=>{B(),Dt()&&(ie(),ue())};return ue(),document.addEventListener("visibilitychange",pe),()=>{P=!0,document.removeEventListener("visibilitychange",pe),B(),Ie.current===a&&(Ie.current=null,We.current=!1),de.current===a&&(Ge.current!==null&&window.clearTimeout(Ge.current),de.current=null,Ge.current=null,ot.current=0)}},[X,zs,r,$t,p==null?void 0:p.agentType,p==null?void 0:p.occupancy,p==null?void 0:p.status]);const Wa=c.useCallback(async()=>{const a=Kn.current,b=Jt.current,m=window.agentApi;if(!m||!a||!b||gi||di.current)return;const I=cn.current,_=D.current,P=()=>Kn.current===a&&Ve.current===a&&cn.current===I&&D.current===_&&Jt.current===b;di.current=!0,Lo(null);const ie=window.setTimeout(()=>{P()&&di.current&&tc(!0)},500);try{await bi(m,a,$e(a),{before:b,limit:$e(a)==="codex"?Xi:pr},(B,me)=>{var ze;const ue=Ds(B),pe=J(a),re=new Set(pe.map(xe=>xe.id)),Be=ue.filter(xe=>!re.has(xe.id)).length,V=xd(pe,ue,"older"),le=zt.current;me!=="trace"&&le&&Be>0&&(Ia.current={scrollHeight:le.scrollHeight,scrollTop:le.scrollTop},ur.current="skip");const ce=lm(b,B,Be);Jt.current=ce,Ot(a,(ze=B==null?void 0:B.history)==null?void 0:ze.revision),G(V,a,{kind:vn.current,olderCursor:ce}),me!=="trace"&&$n(a,ce)},P,()=>Wn.current.consume(a,b,()=>m.getSession(a,{before:b,limit:$e(a)==="codex"?Xi:pr,...$e(a)==="codex"?{view:"core"}:{}})))}catch(B){if(!P())return;console.error("[chat] failed to load older history",{sessionId:a,error:B}),Lo(B instanceof Error?B.message:"历史消息加载失败")}finally{window.clearTimeout(ie),di.current=!1,Kn.current===a&&tc(!1)}},[J,$e,gi,$n,G,Ot]);c.useEffect(()=>{li.current=()=>{Wa()}},[Wa]);const mc=c.useCallback(async()=>{const a=Kn.current,b=Jn.current;if(!window.agentApi||!a||!b||vn.current!=="anchored"||f.current)return;const m=cn.current,I=D.current,_=()=>Ve.current===a&&Kn.current===a&&vn.current==="anchored"&&cn.current===m&&D.current===I&&Jn.current===b;f.current=!0,nc(!0);try{await bi(window.agentApi,a,$e(a),{after:b,limit:$e(a)==="codex"?Xi:pr},P=>{var me,ue;const ie=J(a),B=xd(ie,Ds(P),"newer");Jn.current=((me=P==null?void 0:P.history)==null?void 0:me.newerCursor)??null,Ot(a,(ue=P==null?void 0:P.history)==null?void 0:ue.revision),B!==ie&&(ur.current="skip",G(B,a,{kind:"anchored",olderCursor:Jt.current}))},_)}catch(P){if(!_())return;console.error("[chat] failed to load newer anchored history",{sessionId:a,error:P})}finally{f.current=!1,nc(!1)}},[J,$e,G,Ot]);c.useEffect(()=>{Mo.current=()=>{mc()}},[mc]);const xc=c.useCallback(async()=>{const a=Ve.current;if(!window.agentApi||!a||te.current)return!1;const b=++D.current;te.current=!0,zo(!0),pi(null);try{let m=!1;return await bi(window.agentApi,a,$e(a),{limit:$e(a)==="codex"?Za:pr},(I,_)=>{var B,me,ue,pe,re,Be,V;m=!0;const P=Ds(I),ie=((B=I==null?void 0:I.history)==null?void 0:B.nextCursor)??null;_!=="trace"&&((me=Wn.current)==null||me.invalidate()),Jt.current=ie,Jn.current=null,Ot(a,(ue=I==null?void 0:I.history)==null?void 0:ue.revision),As("latest"),fi(!1),ui(((re=(pe=E.current)==null?void 0:pe.entries.at(-1))==null?void 0:re.messageId)??null),ee.current=!0,ur.current="skip",G(P,a,{kind:"latest",olderCursor:ie}),_!=="trace"&&$n(a,ie),((Be=I==null?void 0:I.history)==null?void 0:Be.revision)!==((V=E.current)==null?void 0:V.revision)&&Xr(a)},()=>D.current===b&&Ve.current===a),m}catch(m){return ge(m instanceof Error?m.message:"返回最新消息失败"),!1}finally{te.current=!1,zo(!1)}},[$e,Xr,$n,As,G,Ot]),bc=c.useCallback(async(a,b=!0)=>{var ie;const m=Ve.current,I=zt.current;if(!window.agentApi||!m||!I)return;const _=++D.current;ui(a.messageId);const P=Array.from(I.querySelectorAll("[data-message-id]")).find(B=>B.dataset.messageId===a.messageId);if(P){pi(null),nl(I,P,"smooth");return}pi(a.messageId),(ie=Wn.current)==null||ie.invalidate();try{await bi(window.agentApi,m,$e(m),{anchor:a.pageToken,limit:$e(m)==="codex"?Xi:pr},(B,me)=>{var re,Be,V,le,ce,ze;if(((re=E.current)==null?void 0:re.revision)!==((Be=B==null?void 0:B.history)==null?void 0:Be.revision))return;const ue=Ds(B),pe=((V=B==null?void 0:B.history)==null?void 0:V.olderCursor)??((le=B==null?void 0:B.history)==null?void 0:le.nextCursor)??null;Jt.current=pe,Jn.current=((ce=B==null?void 0:B.history)==null?void 0:ce.newerCursor)??null,Ot(m,(ze=B==null?void 0:B.history)==null?void 0:ze.revision),As("anchored"),fi(!1),$.current=a.messageId,ur.current="skip",G(ue,m,{kind:"anchored",olderCursor:pe}),me!=="trace"&&(window.requestAnimationFrame(()=>{if(D.current!==_||Ve.current!==m)return;const xe=zt.current,Fe=Array.from((xe==null?void 0:xe.querySelectorAll("[data-message-id]"))??[]).find(Ae=>Ae.dataset.messageId===a.messageId);!xe||!Fe||(nl(xe,Fe),$.current=null,ui(a.messageId))}),$n(m,pe))},()=>D.current===_&&Ve.current===m)}catch(B){if(B.code==="STALE_SESSION_ANCHOR"&&b){const ue=await Xr(m),pe=ue==null?void 0:ue.entries.find(re=>re.ordinal===a.ordinal);pe&&await bc(pe,!1);return}console.error("[chat] failed to open indexed query",{sessionId:m,error:B}),ge(B instanceof Error?B.message:"无法打开这条消息")}finally{D.current===_&&pi(null)}},[$e,Xr,$n,As,G,Ot]),yc=a=>{if(Er.current.has(a)||Fi.current.has(a))return;const b=window.setTimeout(()=>{Fi.current.delete(a),(async()=>{var m;if(!Er.current.has(a))try{const I=await((m=window.agentApi)==null?void 0:m.getSessionGoals(a));if(Er.current.has(a))return;const _=Ve.current||Ke.current;if(I&&a===_&&Ct(I,a),I!=null&&I.active){et.current=a,a===_&&(Ls.current=!1,ge(null),Ue(a));return}if(Ls.current)return;const P=Re.getState().getMessagesForSession(a).find(ie=>ie.isQueued&&!ie.queueItemId);if(!P){et.current===a&&(et.current=null),Re.getState().runningSessionId===a&&Ue(null);return}Z(P.id,ie=>({...ie,isQueued:!1}),a),mi(P,a)}catch(I){ge(I instanceof Error?I.message:"排队消息自动发送失败")}})()},150);Fi.current.set(a,b)},Go=(a,b)=>{const m=Re.getState().getMessagesForSession(a),I=Om(m);I&&Z(I,_=>({..._,sendState:b}),a)},$a=(a,b)=>{const m=Md(b),I=Re.getState().getMessagesForSession(a);G(I.filter(_=>_.id!==m),a),dn(a,b.payload.content),De.save(a,b.payload.images??[]),(Ve.current||Ke.current)===a&&(vt(b.payload.content),Et(b.payload.images??[])),wn.current.delete(a),kt.current===a&&(kt.current=null),_t(void 0,a)},Zp=a=>{var B,me,ue,pe,re,Be;const b=Ve.current||Ke.current,m=Ym(a._sid)??void 0;if(!m&&a.type!=="cron_update")return;if(a._nativeRunId&&Number.isSafeInteger(a._nativeSequence)){const V=`${a._nativeRunId}:${a._nativeSequence}`;if(Yn.current.has(V))return;Yn.current.add(V),Yn.current.size>2e3&&(Yn.current=new Set([...Yn.current].slice(-1e3)))}const I=!m||m===b,_=I&&vn.current==="anchored",P=(m==null?void 0:m.startsWith("runtime:"))&&(a.type==="run_admitted"||a.type==="done")&&J(m).some(V=>V.role==="user"&&!V.isQueued&&V.sendState==="failed");m&&I&&(a._nativeRecoveredFromSnapshot||P)&&zs(m);let ie;if(m&&Ol(a)){let V=Sr.current.get(m);const le=ss(a),ce=le?(me=(B=J(m).find(ze=>{var xe,Fe;return((Fe=(xe=ze.presentation)==null?void 0:xe.runResult)==null?void 0:Fe.runId)===le}))==null?void 0:B.presentation)==null?void 0:me.runResult:void 0;if(!V&&ce&&(V={type:ce.status==="failed"||ce.status==="interrupted"?"error":"done",result:ce}),ie=eh(V,a),Sr.current.set(m,ie),!_){const ze=Zg(ie,a);dt(ze,m)}}if(!(_&&(fi(!0),Xm(a.type)))){if(m&&["run_admitted","thinking","text_chunk","reasoning_summary_delta","runtime_progress","tool_call","todo_update","done"].includes(a.type)&&Go(m),m&&I&&!a._preserveActiveRun&&["done","error","turn_aborted"].includes(a.type)&&!Er.current.has(m)){const V=uc.current;(ue=V.onRunComplete)==null||ue.call(V,V.selectedProjectId??null,m)}switch(a.type){case"run_admitted":if(m&&Sr.current.delete(m),I&&(on(null),Pt("thinking")),m&&$e(m)==="codex"&&gr({progressId:"codex:status",phase:"thinking",label:"正在思考"},m),m&&zn===m&&(dr(null),I&&ge(null)),m){wn.current.delete(m);const V=yi(On.current,m);if(V&&(Yr.current===V.token&&(Yr.current=null),_t(void 0,m)),I&&Es.current===m){const le=Rt.current;dn(m,le.text),De.save(m,le.images)}else Zr(m),De.clear(m);kt.current===m&&(kt.current=null)}break;case"context_usage":if(a.usage&&"segments"in a.usage&&(un(a.usage,m),m&&!m.startsWith("runtime:"))){const V=(Re.getState().runtimeProgressBySession[m]??[]).filter(le=>le.progressId!==Iu);ut(V,m)}break;case"text_chunk":if(a.text){const V=m&&$e(m)==="copilot"?Ja(J(m),{type:"text_chunk",text:a.text,turnId:a.turnId,itemId:a.itemId}):null;if(V)G(V,m);else if(m&&a.turnId&&a.messagePhase==="commentary"&&$e(m)==="codex")Nt(a.turnId,{type:"text_chunk",text:a.text,turnId:a.turnId,itemId:a.itemId,messagePhase:"commentary"},m);else if(m&&a.turnId&&a.itemId&&!a.messagePhase&&$e(m)==="codex"){const le=`codex-trace:${a.turnId}:agent:${a.itemId}`,ce=J(m);ce.some(xe=>{var Fe,Ae;return(Ae=(Fe=xe.executionTrace)==null?void 0:Fe.liveMessages)==null?void 0:Ae.some(mt=>mt.id===le)})?Nt(a.turnId,{type:"text_chunk",text:a.text,turnId:a.turnId,itemId:a.itemId,messagePhase:"commentary"},m):ce.some(xe=>xe.id===le)?Z(le,xe=>({...xe,content:xe.content+a.text}),m):Te({id:le,role:"assistant",content:a.text,timestamp:Date.now()},m)}else nr(a.text,m);I&&Pt("thinking")}break;case"reasoning_summary_delta":if(typeof a.itemId=="string"&&Number.isSafeInteger(a.sectionIndex)&&typeof a.delta=="string"){const V={type:"reasoning_summary_delta",itemId:a.itemId,sectionIndex:a.sectionIndex,delta:a.delta,...a.turnId?{turnId:a.turnId}:{}},le=m&&$e(m)==="copilot"?Ja(J(m),V):null;le?G(le,m):m&&a.turnId&&$e(m)==="codex"?Nt(a.turnId,V,m):Ut(V,m),I&&Pt("thinking")}break;case"runtime_progress":if(typeof a.progressId=="string"&&typeof a.label=="string"&&["thinking","tool","retry","status"].includes(a.phase??"")){const V={progressId:a.progressId,...a.kind==="background-job"?{kind:a.kind}:{},phase:a.phase,label:a.label,...a.detail===void 0?{}:{detail:a.detail},...a.toolCallId===void 0?{}:{toolCallId:a.toolCallId},...a.elapsedSeconds===void 0?{}:{elapsedSeconds:a.elapsedSeconds},...a.current===void 0?{}:{current:a.current},...a.total===void 0?{}:{total:a.total},...a.output===void 0?{}:{output:a.output},...["running","stopping","completed","killed","failed"].includes(a.status??"")?{status:a.status}:{},...a.startedAt===void 0?{}:{startedAt:a.startedAt}};gr(V,m),I&&Pt(V.phase==="tool"?"tools":"thinking")}break;case"native_subagent_update":(pe=a.activity)!=null&&pe.parentToolCallId&&(hr(a.activity,m),I&&a.activity.status==="running"&&Pt("tools"));break;case"tool_call":if(I&&Pt("tools"),a.toolCall&&a.toolCall.name!=="dispatch_agent"&&a.toolCall.name!=="ask_user"&&a.toolCall.name!=="show_widget"){const V=m&&$e(m)==="copilot"?Ja(J(m),{type:"tool_call",toolCall:a.toolCall,turnId:a.turnId}):null;V?G(V,m):m&&a.turnId&&$e(m)==="codex"?Nt(a.turnId,{type:"tool_call",toolCall:a.toolCall,turnId:a.turnId},m):Te({id:crypto.randomUUID(),role:"assistant",content:"",toolCalls:[{id:a.toolCall.id,name:a.toolCall.name,arguments:a.toolCall.arguments}],timestamp:Date.now()},m)}break;case"tool_result":a.result&&"toolCallId"in a.result&&(m&&a.turnId&&$e(m)==="codex"?Nt(a.turnId,{type:"tool_result",result:a.result,turnId:a.turnId},m):fr(a.result.toolCallId,a.result.content,a.result.isError,m));break;case"todo_update":a.todos&&Cn(a.todos);break;case"cron_update":a.tasks&>(a.tasks);break;case"agent_dispatch":if(Te({id:crypto.randomUUID(),role:"assistant",content:"",toolCalls:[{id:crypto.randomUUID(),name:"dispatch_agent",arguments:{agentName:a.agentName,task:a.task??"",subSessionId:a.subSessionId}}],timestamp:Date.now()},m),a.subSessionId){xn.current.add(a.subSessionId);const V=et.current||In;V&&o&&o(V)}d==null||d({type:"started",agentName:a.agentName??"",task:a.task??"",subSessionId:a.subSessionId});break;case"agent_done":a.subSessionId&&(xn.current.delete(a.subSessionId),os(a.subSessionId,a.status??"completed",a.status==="failed"?a.error:a.summary,m)),d==null||d({type:a.status==="failed"?"failed":"completed",agentName:a.agentName??"",task:a.task??"",subSessionId:a.subSessionId});break;case"agent_progress":a.subSessionId&&a.text&&U(a.subSessionId,a.text,m);break;case"compacted":Te({id:crypto.randomUUID(),role:"assistant",content:a.summary??"",isCompactionSummary:!0,timestamp:Date.now()},m);break;case"show_widget":{const V=a.data??a.widgetData,le={widgetId:a.widgetId,widgetType:a.widgetType,data:V??{}},ze=(m?Re.getState().getMessagesForSession(m):Re.getState().messages).find(xe=>{var Fe;return((Fe=xe.widget)==null?void 0:Fe.widgetId)===le.widgetId});ze?Z(ze.id,xe=>({...xe,widget:le}),m):Te({id:crypto.randomUUID(),role:"assistant",content:"",widget:le,timestamp:Date.now()},m);break}case"ask_user":if(a.questionId&&(m?Re.getState().getMessagesForSession(m):Re.getState().messages).some(le=>{var ce;return((ce=le.askUser)==null?void 0:ce.questionId)===a.questionId}))break;Te({id:`question:${a.questionId}`,role:"assistant",content:"",askUser:{questionId:a.questionId??"",question:a.question??"",options:a.options,fields:a.fields,multiSelect:a.multiSelect},timestamp:Date.now()},m);break;case"approval_resolved":{if(!a.questionId)break;const le=(m?Re.getState().getMessagesForSession(m):Re.getState().messages).find(ce=>{var ze;return((ze=ce.askUser)==null?void 0:ze.questionId)===a.questionId});le&&Z(le.id,ce=>({...ce,askUser:ce.askUser?{...ce.askUser,answered:!0,answer:ce.askUser.answer??"已处理"}:ce.askUser}),m);break}case"text_done":break;case"thinking":I&&Pt("thinking");break;case"done":if(I){const V=ie?oa(ie):null;on(V&&m?{sessionId:m,message:V}:null),V||ge(null)}if(m&&zn===m&&(dr(null),I&&ge(null)),m&&!_){const V=$l(a.durationMs);if(V!==void 0||a.forkPoint){const le=Lu(J(m),ss(a));le&&Z(le.id,ce=>({...ce,presentation:{...ce.presentation,...V!==void 0?{completionDurationMs:V}:{},...a.forkPoint?{forkPoint:a.forkPoint}:{}}}),m)}}if(kn(m),m&&!J(m).some(V=>V.isQueued)&&(et.current===m&&(et.current=null),Re.getState().runningSessionId===m&&Ue(null)),I&&(Pt("idle"),!_&&!oa(ie??a)&&xt.getState().autoSpeak)){const le=[...Re.getState().messages].reverse().find(ce=>ce.role==="assistant"&&ce.content&&!ce.isCompactionSummary);le!=null&&le.content&&(re=window.agentApi)!=null&&re.ttsSpeak&&(Ki(),window.agentApi.ttsSpeak(le.content.slice(0,600)).then(ce=>{ce.ok||ge("TTS 模型播报失败")}).catch(ce=>{ge(ce instanceof Error?ce.message:"TTS 模型播报失败")}))}m&&(Er.current.has(m)?window.setTimeout(()=>{Uo(m)},150):yc(m),Ui(m),["deepseek-harness","codex"].includes($e(m)??"")&&zs(m));break;case"error":if(ie&&ie!==a)break;if(a._preserveActiveRun||kn(m),m&&a.code==="SESSION_OCCUPIED"&&!_){const V=Re.getState().getMessagesForSession(m),le=wn.current.get(m),ce=yi(On.current,m),ze=(ce==null?void 0:ce.forkSessionId)===m?ce:void 0,xe=le??(ce==null?void 0:ce.payload),Fe=xe?[...V].reverse().find(mt=>mt.role==="user"&&!mt.isQueued&&mt.content===xe.content):I?[...V].reverse().find(mt=>mt.role==="user"&&!mt.isQueued):void 0,Ae=xe??(Fe?{content:Fe.content,images:Fe.images,agentName:Fe.agentName}:void 0);ze?$a(m,ze):(Fe&&G(V.filter(mt=>mt.id!==Fe.id),m),wn.current.delete(m),Ae!=null&&Ae.content&&(_t(ce??sb(m,Ae)),dn(m,Ae.content),De.save(m,Ae.images??[]),I&&(vt(Ae.content),Et(Ae.images??[]))),kt.current===m&&(kt.current=null)),I&&ge(null)}if(m&&(m.startsWith("runtime:")||wn.current.has(m))&&a.code!=="SESSION_OCCUPIED"&&a.code!=="SESSION_ALREADY_RUNNING"&&a.code!=="CANCEL_CONFIRMATION_TIMEOUT"&&!_){const V=Re.getState().getMessagesForSession(m),le=wn.current.get(m),ce=yi(On.current,m),ze=(ce==null?void 0:ce.forkSessionId)===m?ce:void 0,xe=le?[...V].reverse().find(Ae=>Ae.role==="user"&&!Ae.isQueued&&Ae.content===le.content):[...V].reverse().find(Ae=>Ae.role==="user"&&!Ae.isQueued),Fe=le??(xe?{content:xe.content,images:xe.images,agentName:xe.agentName}:void 0);if(ze)$a(m,ze);else if(Fe!=null&&Fe.content&&(le==null?void 0:le.restoreDraftOnFailure)!==!1){const Ae=Qa(I?Rt.current:{text:Ko(m),images:[]},Fe);dn(m,Ae.text),De.save(m,Ae.images),I&&(Rt.current=Ae,vt(Ae.text),Et(Ae.images))}wn.current.delete(m),kt.current===m&&(kt.current=null)}if(I)if(a._preserveActiveRun&&m&&(dc.current.add(m),et.current=m,Ue(m),Pt("thinking")),a.code==="SESSION_ALREADY_RUNNING"&&!_){const V=m?wn.current.get(m):void 0,le=m?Re.getState().getMessagesForSession(m):Re.getState().messages,ce=Bm(le);if(ce){const ze=le.find(xe=>xe.id===ce);Z(ce,xe=>({...xe,isQueued:!0,sendState:void 0}),m),qn&&m&&ze&&((Be=window.agentApi)!=null&&Be.enqueueSessionMessage)?window.agentApi.enqueueSessionMessage(m,{sourceMessageId:ze.id,content:ze.content,images:ze.images,agentName:ze.agentName}).then(xe=>{Ct(xe,m),Zr(m),De.clear(m)}).catch(xe=>{const Fe=(V==null?void 0:V.content)??ze.content,Ae=(V==null?void 0:V.images)??ze.images??[];dn(m,Fe),De.save(m,Ae),(Ve.current||Ke.current)===m&&(vt(Fe),Et(Ae)),ge(xe instanceof Error?xe.message:"排队消息保存失败")}):m&&(Zr(m),De.clear(m))}m&&wn.current.delete(m),m&&kt.current===m&&(kt.current=null),m&&_t(void 0,m),ge(null)}else a.code!=="SESSION_OCCUPIED"&&(ge(a.message??"Unknown error"),dr(a.code==="CANCEL_CONFIRMATION_TIMEOUT"?m??null:null),m&&a.code==="CANCEL_CONFIRMATION_TIMEOUT"&&(wn.current.delete(m),kt.current===m&&(kt.current=null)),m&&a.code!=="CANCEL_CONFIRMATION_TIMEOUT"&&Go(m,"failed"));if(!a._preserveActiveRun){const V=m??b;(!V||et.current===V)&&(et.current=null),(!V||Re.getState().runningSessionId===V)&&Ue(null),I&&Pt("idle")}m&&!a._preserveActiveRun&&(Er.current.has(m)?window.setTimeout(()=>{Uo(m)},150):yc(m),Ui(m));break;case"turn_aborted":m&&zn===m&&(dr(null),I&&ge(null)),kn(m),et.current===m&&(et.current=null),Re.getState().runningSessionId===m&&Ue(null),I&&Pt("idle"),Ui(m);break;case"goal_updated":m===(Ve.current||Ke.current)&&sr(a.goal??null);break;case"goal_cleared":m===(Ve.current||Ke.current)&&sr(null);break}}},ef=async a=>{var m;if(!H||!((m=window.agentApi)!=null&&m.setSessionPermissionMode)||Ao)return;const b=Hr;yn(a),Ur(!1),ct(!0);try{await window.agentApi.setSessionPermissionMode(H,a)}catch(I){yn(b),ge(I instanceof Error?I.message:"权限模式更新失败")}finally{ct(!1)}},tf=async a=>{var m;if(!H||!((m=window.agentApi)!=null&&m.setSessionNativePermissionPreset)||Qn.current)return;Qn.current=!0;const b=H;Ur(!1),ct(!0);try{const I=await window.agentApi.setSessionNativePermissionPreset(b,a);fn.current===b&&Mn(I.nativePermissions)}catch(I){fn.current===b&&ge(I instanceof Error?I.message:"原生权限更新失败")}finally{Qn.current=!1,ct(!1)}},vc=async()=>{var a;if(!(!H||(p==null?void 0:p.agentType)!=="codex"||!((a=window.agentApi)!=null&&a.releaseCodexSession)||ar!=="idle")&&!(_n&&!window.confirm("停止当前执行并退出此会话?Codex Desktop 最长约 30 分钟后可用。"))){Pr("releasing");try{await window.agentApi.releaseCodexSession(H),Ls.current=!0,cn.current+=1,et.current=null,Ue(null),xn.current.clear(),mr(b=>({...b,active:null,queued:[]})),$r("idle"),ge(null),dr(null),Pr("released")}catch(b){Pr("idle"),ge(b instanceof Error?b.message:"释放 Codex 会话失败")}}},nf=c.useCallback(async a=>{var P;const b=Ke.current;if(!b||!((P=window.agentApi)!=null&&P.forkSession)||ps.current||Mt)return;let m=Ha(a,b);ps.current=!0,Hs(a.id),ge(null);let I=!1;const _=cn.current;try{if(!m){const B=await window.agentApi.getSession(b,{limit:100,view:"core"}),me=Ds(B).filter(ue=>{var pe;return ue.role==="assistant"&&!((pe=ue.toolCalls)!=null&&pe.length)&&ue.content===a.content});if(me.length===1&&(m=Ha(me[0],b)),!m)throw zs(b),new Error("轮次正在同步,请刷新会话后重试 Fork")}const ie=m;await Ld({sourceSessionId:b,forkSession:B=>window.agentApi.forkSession(B,ie),activateSession:B=>{Ke.current!==b||cn.current!==_||(I=!0,Ke.current=B,lt(B))},refreshAndSelect:async B=>{!I||Ke.current!==B.id||(s?await s(B.id,B):l==null||l(B.id))}})}catch(ie){(Ke.current===b||I)&&ge(ie instanceof Error?ie.message:"Fork 失败,请重试")}finally{ps.current=!1,Hs(null)}},[Mt,s,l,zs,lt]),rf=async()=>{var m;const a=nt;if(!a||!H||Mt||ps.current||Yr.current===a.token)return;Yr.current=a.token;const b=(I,_)=>{const P=Md(I);if(J(_).some(B=>B.id===P)){Z(P,B=>({...B,sendState:"pending"}),_);return}Te({id:P,role:"user",content:I.payload.content,timestamp:Date.now(),agentName:I.payload.agentName,images:I.payload.images,sendState:"pending",awaitingHistory:!0},_)};if(a.forkSessionId){zr(!0);const I=_d(a,a.forkSessionId);_t(I),b(I,I.forkSessionId),mi(I.payload,I.forkSessionId,I.payload.agentIds).finally(()=>{Yr.current=null,zr(!1)});return}if(!((m=window.agentApi)!=null&&m.forkSession)){Yr.current=null;return}zr(!0);try{const I=await Ld({sourceSessionId:a.sourceSessionId,forkSession:P=>window.agentApi.forkSession(P),activateSession:P=>{Ke.current=P,lt(P)},refreshAndSelect:async P=>{s?await s(P.id,P):l==null||l(P.id)}}),_=_d(a,I.id);_t(_),b(_,I.id),mi(_.payload,I.id,_.payload.agentIds).finally(()=>{Yr.current=null,zr(!1)}),ge(null)}catch(I){Yr.current=null,ge(I instanceof Error?I.message:"创建会话副本失败"),zr(!1)}},Ba=(a="button")=>{Ls.current=!0,cn.current+=1,window.agentApi&&window.agentApi.abort(H||void 0,a).catch(b=>{ge(b instanceof Error?b.message:"停止执行失败")}),Me!=="codex"&&(et.current=null,Ue(null),xn.current.clear())},wc=async a=>{const b=r||In;if(!b||!window.agentApi||cr.current.has(a))return;const m=J(b).find(I=>I.id===a);if(!(!m||!to(m,qn))){cr.current.add(a),Or(new Set(cr.current)),Z(a,I=>({...I,isSteering:!0}),b);try{const I=await Gm(m,b,qn,window.agentApi);G(qm(J(b),a,Date.now()),b),I&&Ct(I,b),vr===a&&(Un(null),Qt(""))}catch(I){ge(I instanceof Error?I.message:"引导失败")}finally{Z(a,I=>I.isSteering?{...I,isSteering:void 0}:I,b),cr.current.delete(a),Or(new Set(cr.current))}}},sf=a=>{const b=Re.getState().messages.find(m=>m.id===a&&m.isQueued);b&&(Un(a),Qt(b.content))},Oa=()=>{Un(null),Qt("")},jc=async a=>{const b=vs.trim(),m=Re.getState().messages.find(I=>I.id===a&&I.isQueued);if(!(!m||!b))try{m.queueItemId&&H?Ct(await window.agentApi.updateSessionMessage(H,m.queueItemId,b),H):Z(a,I=>I.isQueued?{...I,content:b}:I,H||void 0),Oa()}catch(I){ge(I instanceof Error?I.message:"排队消息保存失败")}},of=async a=>{const b=Re.getState().messages.find(m=>m.id===a&&m.isQueued);if(b){if(!await ji(b.content)){ge("复制排队消息失败");return}Hn(a),window.setTimeout(()=>Hn(m=>m===a?null:m),1200)}},af=async a=>{const b=Re.getState().messages,m=b.find(I=>I.id===a&&I.isQueued);if(m)try{m.queueItemId&&H?Ct(await window.agentApi.cancelSessionMessage(H,m.queueItemId),H):G(b.filter(I=>I.id!==a),H||void 0),vr===a&&Oa()}catch(I){ge(I instanceof Error?I.message:"排队消息删除失败")}},Fa=async(a,b)=>{const m=Re.getState().messages,I=Hm(m,a,b);if(I!==m){G(I,H||void 0);const _=I.filter(P=>P.isQueued&&P.queueItemId);if(H&&_.length>0)try{Ct(await window.agentApi.reorderSessionMessages(H,_.map(P=>P.queueItemId)),H)}catch(P){G(m,H),ge(P instanceof Error?P.message:"排队消息排序保存失败")}}},lf=(a,b)=>{const m=Re.getState().messages.filter(P=>P.isQueued),I=m.findIndex(P=>P.id===a),_=m[I+b];_&&Fa(a,_.id)},cf=async a=>{const b=To;if(Oe(null),!H||!b||b===a)return;const m=ft.queued.map(B=>B.id),I=m.indexOf(b),_=m.indexOf(a);if(I<0||_<0)return;const P=[...m];P.splice(_,0,P.splice(I,1)[0]);const ie=ft;mr({...ft,queued:P.map((B,me)=>({...ft.queued.find(ue=>ue.id===B),position:me}))});try{Ct(await window.agentApi.reorderSessionGoals(H,P),H)}catch(B){mr(ie),ge(B instanceof Error?B.message:"目标排序保存失败")}},Sc=async a=>{if(!H)return;const b=ft.queued.find(m=>m.id===a);try{const m=await window.agentApi.cancelSessionGoal(H,a);if(Ct(m,H),b!=null&&b.sourceMessageId){const I=Re.getState().getMessagesForSession(H);G(I.filter(_=>_.id!==b.sourceMessageId),H)}m.active||Ue(null)}catch(m){ge(m instanceof Error?m.message:"目标删除失败")}};c.useEffect(()=>{vr&&(pt.some(a=>a.id===vr&&a.isQueued)||(Un(null),Qt("")))},[vr,pt]);async function mi(a,b,m){var P,ie,B,me;const I=crypto.randomUUID();Sr.current.delete(b);let _=!1;fn.current===b&&on(null),wn.current.set(b,{content:a.content,images:a.images?[...a.images]:void 0,agentIds:m?[...m]:void 0,agentName:a.agentName,restoreDraftOnFailure:a.restoreDraftOnFailure}),Ls.current=!1,Er.current.add(b),bs(b),et.current=b,Ue(b);try{if(window.agentApi){const ue=ht&&Fs(Me)?{...Vn&&hn&&((P=mn.model)!=null&&P.id)?{model:mn.model}:{},...Vn&&en?{reasoningEffort:en}:{}}:Rn?{profileId:Rn}:void 0;await window.agentApi.run(a.content,b,m,a.agentName,a.images,ue),_=!0}}catch(ue){const pe=yi(On.current,b);if((pe==null?void 0:pe.forkSessionId)===b)$a(b,pe);else{Go(b,"failed");const re=b.startsWith("runtime:")?wn.current.get(b):a;if(re!=null&&re.content){if(re.restoreDraftOnFailure!==!1){const Be=fn.current===b||a.restoreDraftScope!==void 0&&Bt.current===a.restoreDraftScope,V=Qa(Be?Rt.current:{text:Ko(b),images:[]},re);dn(b,V.text),De.save(b,V.images),Be&&(Rt.current=V,vt(V.text),Et(V.images))}wn.current.delete(b),kt.current===b&&(kt.current=null)}}ge(ue instanceof Error?ue.message:"Agent run failed")}finally{if(Er.current.delete(b),dc.current.delete(b)){et.current=b,Ue(b);return}const pe=(ie=window.agentApi)!=null&&ie.getSessionGoals?await window.agentApi.getSessionGoals(b).catch(()=>{}):void 0;if(Er.current.has(b))return;if(pe&&b===(Ve.current||Ke.current)&&Ct(pe,b),pe!=null&&pe.active){et.current=b,Ue(b),g&&g(n,b);return}const re=Ls.current?void 0:Re.getState().getMessagesForSession(b).find(Be=>Be.isQueued&&!Be.queueItemId);if(re)Z(re.id,Be=>({...Be,isQueued:!1}),b),g&&g(n,b),mi(re,b);else{if(_&&((B=window.agentApi)!=null&&B.notifyTaskCompletion)){const Be=(me=[...Re.getState().getMessagesForSession(b)].reverse().find(le=>le.role==="assistant"&&le.content.trim()&&!le.isCompactionSummary))==null?void 0:me.content,V=_g({sessionId:b,runId:I,title:"任务已完成",finalText:Be,outcome:"completed"},Xt);V&&window.agentApi.notifyTaskCompletion(V,Xt)}et.current===b&&(et.current=null),Re.getState().runningSessionId===b&&Ue(null),g&&g(n,b)}}}const Vo=async(a,b)=>{if(!window.agentApi)throw new Error("agentApi 未就绪");const m=Bt.current;Br.current=!0,bn(!0);try{const I=await Km(window.agentApi,a,{projectId:b,agentType:Me,workspaceSource:S,workspacePath:y});return Bt.current===m&&(kr.current=I.id),I}finally{Br.current=!1,bn(!1)}},df=async()=>{if(Br.current)throw new Error("正在创建会话,请稍候");if(!n&&!(y!=null&&y.trim()))throw new Error("请先选择会话目录,再选择模式");const a=Bt.current,b=await Vo(rn.trim().slice(0,60)||"新会话",n||void 0);if(Bt.current!==a)throw new Error("会话目录已切换,请重新选择模式");return b},kc=async a=>{var ze,xe,Fe,Ae,mt;const b=Me==="deepseek-harness"&&/^\/goal(?:\s|$)/i.test(a.text);if(Br.current||!a.text||!(jr||Ss&&b)||ai>0||vn.current==="anchored"&&!await xc())return;Qo(window.agentApi,Ki);const m=a.applyGoalMode&&sn||/^\/(?:loop|goal)(?:\s|$)/i.test(a.text),I=Ce.group&&Ce.recipients.length===1&&Ce.recipients[0]===H;if(At&&!(m&&I)){if(m){ge("目标和定时任务请先选择只发送给当前查看的 Agent");return}Br.current=!0,bn(!Ce.group),ge(null);const je=Bt.current;try{const fe=Ce.group,qe=fe??await Ce.create({title:a.text.slice(0,60)||"新会话",cwd:(y==null?void 0:y.trim())||"",agentTypes:[...cs]}),Ee=fe?qe.members.filter(ve=>Ce.recipients.includes(ve.id)):qe.members;if(!Ee.length)throw new Error("请选择至少一位接收消息的 Agent");if(!fe&&Bt.current===je){Ce.activate(qe);const ve=qe.members.find(jn=>jn.agentType===ds)??qe.members[0];kr.current=ve.id,Ke.current=ve.id,et.current=ve.id,lt(ve.id),u?await u(ve):await(s==null?void 0:s(ve.id,ve))}bn(!1);const ne=crypto.randomUUID(),he=await Ce.submit(Ee.map(ve=>({member:ve,message:{sourceMessageId:ne,content:a.text,images:a.images,agentIds:a.agentIds,agentName:a.agentName}}))),tt=Bt.current===je||qe.members.some(ve=>ve.id===fn.current),ye=a.clearComposer&&((ze=Cr.current)==null?void 0:ze.value.trim())===a.text.trim();for(const ve of he.accepted)ve===fn.current&&!ye?(dn(ve,Rt.current.text),De.save(ve,Rt.current.images)):a.clearComposer&&(Zr(ve),De.clear(ve)),i==null||i(ve,a.text);for(const ve of he.failed)dn(ve.member.id,a.text),De.save(ve.member.id,a.images??[]);tt&&he.accepted.length&&ye&&(Rt.current={text:"",images:[]},vt(""),oi([]),Et([]),$o([]))}catch(fe){ge(fe instanceof Error?fe.message:"发送多 Agent 消息失败")}finally{Br.current=!1,bn(!1)}return}(!zn||zn!==H)&&ge(null);const _=a.text,P=()=>{a.clearComposer&&(Rt.current={text:"",images:[]},vt(""),oi([]),Et([]))};if(/^\/loop\b/i.test(_)){const je=_.slice(5).trim();if(P(),Te({id:crypto.randomUUID(),role:"user",content:_,timestamp:Date.now()}),/^stop$/i.test(je)){window.agentApi&&(await window.agentApi.cronDeleteAll(),gt([]),Te({id:crypto.randomUUID(),role:"assistant",content:"✅ 所有定时任务已删除。",timestamp:Date.now()}));return}if(/^(?:list|status|查看|列表)$/i.test(je)||je===""){if(window.agentApi){const he=await window.agentApi.cronList();gt(he);const tt=he.length===0?"当前没有定时任务。":he.map((ye,ve)=>`**${ve+1}.** \`${ye.id.slice(0,6)}\` · ${el(ye.cron)} · ${ye.enabled?"▶ 启用":"⏸ 已暂停"}
|
|
165
|
+
${ye.prompt}`).join(`
|
|
166
|
+
|
|
167
|
+
`);Te({id:crypto.randomUUID(),role:"assistant",content:tt,timestamp:Date.now()})}return}const fe=je.match(/^(?:pause|暂停)\s+(\S+)$/i);if(fe){if(window.agentApi){const he=pn.find(ye=>ye.id.startsWith(fe[1])),tt=await window.agentApi.cronPause((he==null?void 0:he.id)??fe[1]);if(tt){const ye=await window.agentApi.cronList();gt(ye),Te({id:crypto.randomUUID(),role:"assistant",content:`⏸ 定时任务 \`${tt.id.slice(0,6)}\` 已暂停。`,timestamp:Date.now()})}else Te({id:crypto.randomUUID(),role:"assistant",content:`未找到 ID 以 \`${fe[1]}\` 开头的定时任务。`,timestamp:Date.now()})}return}const qe=je.match(/^(?:resume|恢复)\s+(\S+)$/i);if(qe){if(window.agentApi){const he=pn.find(ye=>ye.id.startsWith(qe[1])),tt=await window.agentApi.cronResume((he==null?void 0:he.id)??qe[1]);if(tt){const ye=await window.agentApi.cronList();gt(ye),Te({id:crypto.randomUUID(),role:"assistant",content:`▶ 定时任务 \`${tt.id.slice(0,6)}\` 已恢复。`,timestamp:Date.now()})}else Te({id:crypto.randomUUID(),role:"assistant",content:`未找到 ID 以 \`${qe[1]}\` 开头的定时任务。`,timestamp:Date.now()})}return}const Ee=je.match(/^(?:delete|del|删除|stop)\s+(\S+)$/i);if(Ee){if(window.agentApi){const he=pn.find(ye=>ye.id.startsWith(Ee[1]));if(await window.agentApi.cronDelete((he==null?void 0:he.id)??Ee[1])){const ye=await window.agentApi.cronList();gt(ye),Te({id:crypto.randomUUID(),role:"assistant",content:`🗑 定时任务 \`${Ee[1]}\` 已删除。`,timestamp:Date.now()})}else Te({id:crypto.randomUUID(),role:"assistant",content:`未找到 ID 以 \`${Ee[1]}\` 开头的定时任务。`,timestamp:Date.now()})}return}const ne=je.match(/^(\S+)\s+(.+)$/s);if(ne){const he=ne[1],tt=ne[2].trim();if(window.agentApi){let ye=r||In;if(!ye){const ve=await window.agentApi.createSession(tt.slice(0,60)||"定时任务",n||void 0);ye=ve.id,lt(ve.id),s&&await s(ve.id)}try{const ve=await window.agentApi.cronCreate(he,tt,{sessionId:ye}),jn=await window.agentApi.cronList();gt(jn),Te({id:crypto.randomUUID(),role:"assistant",content:`⏰ 定时任务已创建(ID: \`${ve.id.slice(0,6)}\`),${el(he)}执行:${tt}`,timestamp:Date.now()})}catch(ve){Te({id:crypto.randomUUID(),role:"assistant",content:`❌ 创建失败:${ve instanceof Error?ve.message:String(ve)}`,timestamp:Date.now()})}}return}Te({id:crypto.randomUUID(),role:"assistant",content:"**定时任务用法:**\n- `/loop <间隔/cron> <任务>` — 创建,如 `/loop 5m 检查系统状态` 或 `/loop 0 9 * * * 早报`\n- `/loop list` — 查看所有定时任务\n- `/loop pause <id>` — 暂停\n- `/loop resume <id>` — 恢复\n- `/loop delete <id>` — 删除\n- `/loop stop` — 删除全部\n\n间隔支持:`30s`、`5m`、`2h`;也支持 5 字段 cron 表达式。",timestamp:Date.now()});return}const ie=_.match(/(?:每(?:隔)?|定时每)\s*(\d+(?:\.\d+)?)\s*(分钟|秒|小时|min|sec|h)\s*(.+)/is);if(ie){const je=ie[1]+ie[2],fe=ie[3].trim();if(fe&&window.agentApi){let qe=r||In;if(!qe){const Ee=await window.agentApi.createSession(fe.slice(0,60)||"定时任务",n||void 0,Me,Me!=="customer-agent"?y??void 0:void 0);qe=Ee.id,lt(Ee.id),s&&await s(Ee.id)}try{const Ee=await window.agentApi.cronCreate(je,fe,{sessionId:qe}),ne=await window.agentApi.cronList();gt(ne),P(),Te({id:crypto.randomUUID(),role:"user",content:_,timestamp:Date.now()}),Te({id:crypto.randomUUID(),role:"assistant",content:`⏰ 定时任务已创建(ID: \`${Ee.id.slice(0,6)}\`),${el(je)}执行:${fe}`,timestamp:Date.now()})}catch(Ee){Te({id:crypto.randomUUID(),role:"assistant",content:`❌ 创建失败:${Ee instanceof Error?Ee.message:String(Ee)}`,timestamp:Date.now()})}return}}const B=a.text,me=B.match(/^\/goal(?:\s+([\s\S]+))?$/i),ue=me?((xe=me[1])==null?void 0:xe.trim())??"":a.applyGoalMode&&sn?B:null;if(ue!==null&&Me==="deepseek-harness"){const je=Bt.current;let fe=H;const qe=()=>Bt.current===je||fe!==null&&fn.current===fe;try{if((Fe=a.images)!=null&&Fe.length)throw new Error("Harness 原生目标暂不接收附件,请先发送附件,再设置目标");const Ee=lb(B,Kt.goal);if(Ee==="show"){H&&await Kt.refresh(H);return}if(!fe){if(Ee.action!=="create")throw new Error("请先选择已有目标的会话");const ne=await Vo(Ee.objective.slice(0,60),n||void 0);fe=ne.id,Bt.current===je&&(Ke.current=ne.id,lt(ne.id),s&&await s(ne.id,ne))}await Kt.mutate(fe,Ee),qe()&&((Ae=Cr.current)==null?void 0:Ae.value.trim())===B.trim()&&(P(),a.clearComposer&&(Zr(fe),De.clear(fe))),i&&i(fe,ue),fn.current===fe&&zs(fe)}catch(Ee){qe()&&ge(Ee instanceof Error?Ee.message:"Harness 目标操作失败")}return}if(ue!==null&&!ue){ge("请输入目标内容");return}const pe=a.agentName,re=a.images,Be=a.agentIds??[];if(a.clearComposer&&$o([]),ue!==null){const je=crypto.randomUUID();let fe=null,qe=null;Ls.current=!1,a.clearComposer&&H&&(Zr(H),De.clear(H)),P();try{const Ee=await Ad({text:ue,projectId:n??null,sessionId:H,createSession:Vo,activateSession:he=>{Ke.current=he,lt(he),et.current=he,Ue(he)},showUserMessage:(he,tt)=>{fe=tt,Te({id:je,role:"user",content:he,timestamp:Date.now(),agentName:pe,images:re,isGoal:!0,goalId:je},tt)},onSessionCreated:s});qe=Ee;const ne=await window.agentApi.enqueueSessionGoal(Ee,ue,je);Ct(ne,Ee),i&&i(Ee,ue)}catch(Ee){if(fe){const tt=Re.getState().getMessagesForSession(fe);G(tt.filter(ye=>ye.id!==je),fe)}const ne=qe??fe??H;a.restoreDraftOnFailure&&ne&&(dn(ne,B),De.save(ne,re??[]));const he=Ve.current||Ke.current;a.restoreDraftOnFailure&&(ne&&he===ne||!ne&&!he)&&(vt(tt=>tt?`${B}
|
|
168
|
+
|
|
169
|
+
${tt}`:B),Et(tt=>[...new Set([...re??[],...tt])])),Ue(null),ge(Ee instanceof Error?Ee.message:"目标创建失败")}return}if(lr){const je=H,fe=crypto.randomUUID(),qe={id:fe,role:"user",content:B,timestamp:Date.now(),agentName:pe,images:re,isQueued:!0};if(a.clearComposer&&je&&(Zr(je),De.clear(je)),P(),qn&&je&&((mt=window.agentApi)!=null&&mt.enqueueSessionMessage)){Te(qe,je);try{const Ee=await window.agentApi.enqueueSessionMessage(je,{sourceMessageId:fe,content:B,images:re,agentIds:Be,agentName:pe});Ct(Ee,je)}catch(Ee){const ne=Re.getState().getMessagesForSession(je);G(ne.filter(he=>he.id!==fe),je),a.restoreDraftOnFailure&&(dn(je,B),De.save(je,re??[]),(Ve.current||Ke.current)===je&&(vt(B),Et(re??[]))),ge(Ee instanceof Error?Ee.message:"排队消息保存失败")}}else Te(qe,je??void 0);return}const V=H,le=Bt.current;a.clearComposer&&ht&&V&&(Ir.current=!0,kt.current=V),P(),Cn([]);const ce=crypto.randomUUID();try{const je=await Ad({text:B,projectId:n??null,sessionId:H,createSession:Vo,activateSession:fe=>{Ke.current=fe,lt(fe),et.current=fe},showUserMessage:(fe,qe)=>{Ca.current.invalidate(qe),ur.current="instant",zi.current.requestReturn(),Te({id:ce,role:"user",content:fe,timestamp:Date.now(),agentName:pe,images:re,sendState:"pending",awaitingHistory:!0},qe)},afterUserMessageShown:Zx,onSessionCreated:s});i&&i(je,B),await mi({content:B,agentName:pe,images:re,restoreDraftOnFailure:a.restoreDraftOnFailure,restoreDraftScope:le},je,Be.length>0?Be:void 0)}catch(je){const fe=H??Ke.current;if(fe&&Go(fe,"failed"),a.restoreDraftOnFailure&&(Bt.current===le||fe&&fn.current===fe)){const qe=Qa(Rt.current,{content:B,images:re});Rt.current=qe,vt(qe.text),Et(qe.images)}et.current===fe&&(et.current=null),ge(je instanceof Error?je.message:"Agent run failed")}},Ic=async()=>{if(Bn||Oo||_s){const a=Ms.current;Jr.current+=1,Ms.current=null,Bo(!1),hi(!1),Fo(!1),a!=null&&a.cancel?a.cancel():a==null||a.stop()}return kc(Pm({text:rn,agentIds:Di.map(a=>a.id),agentName:Di.length>0?Di.map(a=>a.name).join(", "):void 0,images:Dn}))},uf=a=>{kc(Dm(a))};return c.useEffect(()=>{if(!Q||!window.agentApi)return;const{text:a,projectId:b,sessionId:m}=Q;let I=!1;return(async()=>{try{Cn([]);const _=await Xx({text:a,projectId:b,sessionId:m,createSession:async(P,ie)=>await window.agentApi.createSession(P,ie,Me,Me!=="customer-agent"?y??void 0:void 0),activateSession:P=>{Ke.current=P,lt(P),et.current=P,Ue(P)},showUserMessage:(P,ie)=>Te({id:crypto.randomUUID(),role:"user",content:P,timestamp:Date.now()},ie),onSessionCreated:s,isCancelled:()=>I});if(!_)return;i&&i(_,a),await mi({content:a},_)}catch(_){ge(_ instanceof Error?_.message:"语音指令执行失败")}})(),()=>{I=!0}},[Q==null?void 0:Q.nonce]),t.jsx($u.Provider,{value:(p==null?void 0:p.cwd)??y??null,children:t.jsxs("div",{className:"chat-view chat-view--codex-history",style:{display:"flex",flexDirection:"column",height:"100%",maxWidth:"var(--chat-max-width)",margin:"0 auto"},children:[t.jsxs("div",{className:"chat-top-bar",style:{display:"flex",alignItems:"center",padding:"var(--chat-header-padding)",height:"var(--chat-header-height)",flexShrink:0,borderBottom:"1px solid var(--border-subtle)",WebkitAppRegion:"drag"},children:[j&&t.jsx("button",{type:"button",className:"ui-icon-button sidebar-visibility-toggle",onClick:j,"aria-label":w?"展开目录与会话列表":"收起目录与会话列表",title:w?"展开目录与会话列表":"收起目录与会话列表","aria-expanded":!w,"aria-controls":"workspace-sidebar",children:w?t.jsx(yg,{size:17,"aria-hidden":"true"}):t.jsx(bg,{size:17,"aria-hidden":"true"})}),t.jsx("span",{style:{flex:1,minWidth:0,fontSize:14,fontWeight:500,color:h?"var(--text-primary)":"var(--text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",letterSpacing:"-0.01em"},children:h||"会话"}),v&&R&&we&&t.jsx(Gx,{appActions:T,onOpenMessaging:L,appearanceOpen:Y,settingsOpen:z,showSettings:Me==="customer-agent",onOpenDesktopLive:F,desktopLiveOpen:O,filesOpen:q,onToggleFiles:ae,hideToBackgroundTitle:K,codexReleaseState:ar,onHideToBackground:R,onReleaseCodex:(p==null?void 0:p.agentType)==="codex"&&p.occupancy!=="owned-externally"?()=>{vc()}:void 0,onOpenHub:N,onOpenCollaborationDashboard:C,onOpenSessionDashboard:A,onToggleAppearance:we,onOpenSettings:v})]}),At&&t.jsx(zg,{members:Ce.group?Ce.group.members.map(a=>({id:a.id,agentType:a.agentType,status:Ce.statuses[a.id]??a.status})):cs.map(a=>({id:a,agentType:a,status:"idle"})),selectedId:Ce.group?H:ds,onSelect:a=>{if(!Ce.group){Lr(a);return}const b=Ce.group.members.find(m=>m.id===a);b&&Ce.select(b,async()=>{const m=Rt.current;dn(b.id,m.text),await De.save(b.id,m.images)})}}),t.jsx(Bf,{open:wa,agentSessionId:H,onClose:()=>Gs(!1)}),t.jsxs("div",{className:"chat-messages-frame",children:[t.jsxs("div",{ref:zt,className:"chat-messages",onScroll:$p,onWheel:a=>{Ng(a,a.currentTarget.scrollTop)&&li.current()},onTouchStart:a=>ci.current.start(a.touches),onTouchMove:a=>{ci.current.move(a.touches,a.currentTarget.scrollTop)&&li.current()},onTouchEnd:()=>ci.current.reset(),onTouchCancel:()=>ci.current.reset(),style:{overflow:"auto",position:"relative",padding:"var(--chat-messages-padding)"},children:[Tt.length>0&&(ec||Ea)&&t.jsx("div",{className:"chat-history-page-status",role:Ea?"alert":"status","aria-live":"polite",children:ec?t.jsx(t.Fragment,{children:t.jsxs("span",{className:"chat-history-loading-pill",children:[t.jsxs("span",{className:"chat-history-loading-dots","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),t.jsx("span",{children:"正在加载更早消息"})]})}):t.jsxs("button",{type:"button",onClick:()=>void Wa(),className:"chat-history-retry",style:{border:"1px solid color-mix(in srgb, var(--danger) 30%, transparent)",background:"color-mix(in srgb, var(--danger) 7%, transparent)",color:"var(--danger)",borderRadius:6,padding:"5px 10px",cursor:"pointer",fontSize:12},children:[Ea,",点击重试"]})}),Vt&&t.jsxs("div",{className:"chat-session-creating",role:"status","aria-live":"polite",children:[t.jsx(bt,{size:18,"aria-hidden":"true"}),t.jsx("span",{children:"创建会话中"})]}),!Vt&&!xr&&Tt.length===0&&gi&&zp&&t.jsx(vu,{className:"chat-history-initial-loading",label:"正在加载历史消息"}),!Vt&&(xr||Tt.length===0&&!_n&&!gi&&!ri)&&t.jsx(yf,{agentType:(p==null?void 0:p.agentType)??Me,ready:Ze,onSelectPrompt:Hp},H??"initial-empty-session"),En.map((a,b)=>{var ce,ze,xe,Fe,Ae,mt,je,fe,qe,Ee;const m=a;if(m.isQueued)return null;if(m.executionTrace)return t.jsx(Mx,{trace:m.executionTrace,loadTrace:Wp,loadToolResult:Ma,renderContent:it,runtimeProgress:yr,nativeSubagents:Mi,onSelectSession:l,workspacePath:y,onOpenArtifact:se,refreshSignal:m.executionTrace.turnId===qs?mo:0,autoLoad:Pi==="latest"&&m.executionTrace.turnId===qs},a.id);const I=a.role==="user",_=I&&(m.isGoal===!0||[ft.active,...ft.queued,...ft.history].some(ne=>!!(ne&&Pd(ne.objective)===Pd(a.content)))),P=Yg(En,b,_n),ie=_u((ce=m.presentation)==null?void 0:ce.completionDurationMs),B=(ze=m.presentation)==null?void 0:ze.runResult;if(m.isCompactionSummary)return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,margin:"20px 0",color:"var(--text-muted)",fontSize:12},children:[t.jsx("div",{style:{flex:1,height:1,background:"var(--border-subtle)"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 12px",borderRadius:20,border:"1px solid var(--border-subtle)",background:"var(--bg-deep)",color:"var(--text-muted)",fontSize:11,cursor:"default",userSelect:"none"},children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"17 1 21 5 17 9"}),t.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),t.jsx("polyline",{points:"7 23 3 19 7 15"}),t.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]}),"上下文已压缩"]}),t.jsx("div",{style:{flex:1,height:1,background:"var(--border-subtle)"}})]},a.id);if(m.widget){const ne=Kx[m.widget.widgetType];return ne?t.jsx("div",{style:{marginBottom:16,display:"flex",justifyContent:"flex-start"},children:t.jsx(ne,{...m.widget.data,widgetId:m.widget.widgetId,isAgentRunning:_n&&!En.slice(b+1).some(he=>he.role==="user"&&!he.isQueued&&!he.isSteered)})},a.id):t.jsx("div",{style:{marginBottom:16,padding:12,borderRadius:8,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono, monospace)",fontSize:12,whiteSpace:"pre-wrap",maxHeight:300,overflow:"auto"},children:JSON.stringify(m.widget.data,null,2)},a.id)}if(m.askUser)return t.jsx(Cx,{questionId:m.askUser.questionId,question:m.askUser.question,options:m.askUser.options,fields:m.askUser.fields,multiSelect:m.askUser.multiSelect,answered:m.askUser.answered,cancelled:m.askUser.cancelled,answer:m.askUser.answer,onAnswer:async(ne,he)=>{var ye;if(!await((ye=window.agentApi)==null?void 0:ye.answerQuestion(m.askUser.questionId,ne,he)))throw new Error("回答未发送成功,请重试;若问题已结束,请刷新会话。");Z(a.id,ve=>({...ve,askUser:{...ve.askUser,answered:!0,answer:ne}}),H??void 0)}},a.id);const me=I&&(p==null?void 0:p.agentType)==="codex"?eb(a.content):null,ue=m.agentName?m.agentName.charAt(0).toUpperCase():"你",pe=!I&&b===En.length-1,re=En[b+1],Be=re&&re.role!==a.role&&!re.isCompactionSummary,V=(a.toolCalls??[]).map((ne,he)=>{let tt;if(ne.name==="write_file"&&ne.arguments.file_path){const ye=ne.arguments.file_path;e:for(let ve=b;ve>=0;ve--){const jn=En[ve].toolCalls;if(!jn)continue;const Hi=ve===b?he-1:jn.length-1;for(let Ps=Hi;Ps>=0;Ps--){const Rr=jn[Ps];if(Rr.name==="read_file"&&Rr.arguments.file_path===ye&&Rr.result&&!Rr.isError){tt=Rr.result;break e}}}}return{toolCall:ne,beforeContent:tt,progress:Eu(yr,ne.id),nativeSubagent:Mi[ne.id]}}),le=gp(V);return t.jsx("div",{"data-message-id":a.id,className:`chat-message-group${P.compact?" chat-message-group--intermediate":""}`,style:{marginBottom:P.compact?0:Be?"var(--chat-turn-gap)":"var(--chat-message-gap)"},children:t.jsxs("div",{className:`chat-message-row chat-message-row--${I?"user":"assistant"}`,style:{display:"flex",flexDirection:I?"row-reverse":"row",alignItems:"flex-start",gap:"var(--chat-row-gap)",animation:"fadeInUp 0.3s var(--ease-out) both"},children:[I?t.jsx("div",{className:"chat-message-avatar",style:{width:"var(--chat-avatar-size)",height:"var(--chat-avatar-size)",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--accent)",color:"#fff",fontSize:12,fontWeight:700,letterSpacing:0,userSelect:"none"},children:ue}):t.jsx("div",{className:"chat-message-avatar",style:{width:"var(--chat-avatar-size)",height:"var(--chat-avatar-size)",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),t.jsx("path",{d:"M12 11V7"}),t.jsx("circle",{cx:"12",cy:"5",r:"2"}),t.jsx("circle",{cx:"8",cy:"16",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"16",cy:"16",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M8 20h8"})]})}),t.jsxs("div",{className:`chat-message-content chat-message-content--${I?"user":"assistant"}`,style:{maxWidth:"var(--chat-content-max-width)",display:"flex",flexDirection:"column",gap:4,alignItems:I?"flex-end":"flex-start",minWidth:0},children:[me!==null&&t.jsx("span",{className:"scheduled-message-icon",role:"img","aria-label":"定时任务",title:"定时任务",children:t.jsx(ag,{size:15,"aria-hidden":"true"})}),t.jsxs("div",{className:`chat-message-bubble chat-message-bubble--${I?"user":"assistant"} ${a.role==="assistant"&&a.content?"message-card":""}`,style:{padding:a.content||I&&((xe=m.images)!=null&&xe.length)?I?"var(--chat-user-bubble-padding)":"var(--chat-assistant-bubble-padding)":0,borderRadius:I?"14px 4px 14px 14px":"4px 14px 14px 14px",background:a.content||I&&((Fe=m.images)!=null&&Fe.length)?I?"var(--chat-user-bg, rgba(79, 110, 247, 0.08))":void 0:"transparent",border:a.content||I&&((Ae=m.images)!=null&&Ae.length)?I?"1px solid var(--chat-user-border, rgba(79, 110, 247, 0.18))":void 0:"none",fontSize:"var(--chat-bubble-font-size)",lineHeight:"var(--chat-bubble-line-height)",color:"var(--chat-history-text)",letterSpacing:"0.01em"},children:[a.role==="assistant"&&((mt=a.presentation)==null?void 0:mt.reasoning)&&t.jsx(up,{sections:a.presentation.reasoning,streaming:_n&&pe&&tn==="thinking",startedAt:Xs,renderContent:it}),I&&m.agentName?t.jsxs("div",{children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:700,color:"var(--accent)",background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.22)",borderRadius:10,padding:"1px 7px 1px 5px",letterSpacing:"0.04em",marginRight:7,verticalAlign:"middle"},children:[t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M20 21a8 8 0 1 0-16 0"})]}),m.agentName]}),t.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",verticalAlign:"middle"},children:a.content})]}):a.role==="assistant"&&a.content?t.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.jsx(Zh,{text:a.content,complete:!(_n&&pe),renderText:it,suggestionsEnabled:Ze&&ai===0,onSuggestionSend:uf,onCopyFailed:()=>ge("复制失败,请选择文字后复制")})}):a.content&&t.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:I?me??a.content:it(a.content)}),I&&m.images&&m.images.length>0&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:a.content?8:0},children:m.images.map((ne,he)=>t.jsx("button",{type:"button",className:"chat-message-image-button","aria-label":"放大查看图片",onClick:()=>Cs({src:ne,alt:`用户发送的图片 ${he+1}`}),children:t.jsx("img",{className:"chat-message-attachment-image",src:ne,alt:`用户发送的图片 ${he+1}`})},he))}),I&&!((je=m.images)!=null&&je.length)&&((fe=m.presentation)==null?void 0:fe.attachments)&&m.presentation.attachments.length>0&&t.jsx("div",{className:"chat-message-attachments",children:m.presentation.attachments.map((ne,he)=>ne.dataUrl?t.jsx("button",{type:"button",className:"chat-message-image-button","aria-label":`放大查看图片:${ne.name}`,onClick:()=>Cs({src:ne.dataUrl,alt:ne.name}),children:t.jsx("img",{className:"chat-message-attachment-image",src:ne.dataUrl,alt:ne.name,title:ne.name})},`${ne.name}-${he}`):t.jsxs("div",{className:"chat-message-attachment-unavailable","aria-label":`${ne.name},${ne.omitted&&!ne.unavailable?"图片未随页面加载":"图片已失效"}`,children:[t.jsx("span",{className:"chat-message-attachment-name",children:ne.name}),t.jsx("span",{children:ne.omitted&&!ne.unavailable?"图片未随页面加载":"图片已失效"})]},`${ne.name}-${he}`))}),I&&((qe=m.presentation)==null?void 0:qe.rawContent)&&t.jsxs("details",{className:"chat-message-raw-content",children:[t.jsx("summary",{children:"查看原始内容"}),t.jsx("pre",{children:m.presentation.rawContent})]}),le.map(ne=>ne.action&&ne.items.length>1?t.jsx(dp,{items:ne.items,onSelectSession:l,workspacePath:y,onOpenArtifact:se,onLoadResult:lc},`group-${ne.items[0].toolCall.id}`):t.jsx(ya,{toolCall:ne.items[0].toolCall,beforeContent:ne.items[0].beforeContent,progress:ne.items[0].progress,nativeSubagent:ne.items[0].nativeSubagent,onSelectSession:l,workspacePath:y,onOpenArtifact:se,onLoadResult:lc},ne.items[0].toolCall.id)),(()=>{const ne=(a.toolCalls??[]).filter(ye=>ye.name==="write_file"&&ye.result&&!ye.isError);if(ne.length===0)return null;const he=new Map;for(const ye of ne){const ve=ye.arguments.file_path??"",jn=ye.arguments.content??"",Hi=jn?jn.split(`
|
|
170
|
+
`).length:0;let Ps=0;e:for(let Rr=b;Rr>=0;Rr--){const Dc=En[Rr].toolCalls??[];for(let qa=Dc.length-1;qa>=0;qa--){const Gi=Dc[qa];if(Gi.name==="read_file"&&Gi.arguments.file_path===ve&&Gi.result&&!Gi.isError){Ps=Gi.result.split(`
|
|
171
|
+
`).length;break e}}}he.set(ve,{path:ve,lines:Hi,added:Math.max(0,Hi-Ps),removed:Math.max(0,Ps-Hi)})}const tt=[...he.values()];return t.jsxs("div",{style:{marginTop:10,padding:"8px 12px",borderRadius:8,background:"var(--bg-deep)",border:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[t.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",flexShrink:0},children:"变更汇总"}),tt.map(ye=>{const ve=pa(ye.path,y),jn=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--text-secondary)",maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:ye.path,children:ye.path.replace(/\\/g,"/").split("/").pop()}),ye.added>0&&t.jsxs("span",{style:{color:"var(--success)",fontWeight:600},children:["+",ye.added]}),ye.removed>0&&t.jsxs("span",{style:{color:"var(--danger)",fontWeight:600},children:["−",ye.removed]}),ye.added===0&&ye.removed===0&&t.jsxs("span",{style:{color:"var(--text-muted)"},children:[ye.lines,"行"]})]});return se&&ve?t.jsx("button",{type:"button",className:"chat-file-change-link",onClick:()=>se(ve),title:`预览 ${ve}`,"aria-label":`预览改动文件 ${ye.path.replace(/\\/g,"/").split("/").pop()}`,children:jn},ye.path):t.jsx("span",{className:"chat-file-change-link chat-file-change-link--static",children:jn},ye.path)})]})})(),I&&(m.sendState||m.isSteered)&&t.jsxs("div",{className:`msg-send-status${m.sendState?` is-${m.sendState}`:""}`,role:"status","aria-label":m.sendState==="pending"?"正在发送":m.sendState==="failed"?"发送失败":m.name==="__native_steering_pending"?"等待 Copilot 读取":"已引导",children:[m.sendState==="pending"&&t.jsxs("span",{className:"msg-send-status__dots","aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),m.sendState==="failed"&&t.jsx("span",{title:"发送失败",style:{color:"var(--danger)"},children:t.jsx(Ci,{size:16,strokeWidth:2,"aria-hidden":"true"})}),m.isSteered&&t.jsxs("span",{className:"msg-steered-status",title:m.name==="__native_steering_pending"?"等待 Copilot 读取":"已引导","aria-label":m.name==="__native_steering_pending"?"等待 Copilot 读取":"已引导",role:"img",children:[t.jsx(qc,{size:13,strokeWidth:2,"aria-hidden":"true"}),m.name==="__native_steering_pending"&&t.jsx("span",{children:"等待 Copilot 读取"})]})]})]}),(B||P.showCompletion)&&t.jsxs("div",{className:"msg-completion-footer",children:[B?t.jsx(Ch,{result:B}):t.jsx("span",{className:"msg-completion-status",children:ie&&t.jsxs("span",{children:["总耗时 ",ie]})}),P.showCompletion&&t.jsxs("span",{className:"msg-completion-actions",children:[H&&(Ha(a,H)||!H.startsWith("runtime:"))&&t.jsx("button",{type:"button",onClick:()=>{nf(a)},disabled:!!vo||Mt,title:"从此轮 Fork 为新会话","aria-label":"从此轮 Fork 为新会话",className:"ui-icon-button ui-icon-button--small msg-action-button",children:vo===a.id?t.jsx(bt,{size:13,className:"animate-spin","aria-hidden":"true"}):t.jsx(fg,{size:13,strokeWidth:1.8,"aria-hidden":"true"})}),P.showSpeak&&typeof((Ee=window.agentApi)==null?void 0:Ee.ttsSpeak)=="function"&&t.jsx("button",{type:"button",onClick:()=>Op(a.id,a.content),title:$i===a.id?"停止播报":"语音播报","aria-label":$i===a.id?"停止播报":"语音播报",className:`ui-icon-button ui-icon-button--small msg-action-button ${$i===a.id?"is-active":""}`,children:$i===a.id?t.jsx(no,{size:12,fill:"currentColor","aria-hidden":"true"}):t.jsx(Of,{size:13,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:()=>{ji(a.content)},title:"复制内容","aria-label":"复制内容",className:"ui-icon-button ui-icon-button--small msg-action-button",children:t.jsx(Si,{size:13,strokeWidth:1.8,"aria-hidden":"true"})})]})]}),!P.showCompletion&&(P.showCopy||_)&&t.jsxs("div",{className:"msg-actions",style:{display:"flex",alignItems:"center",gap:4},children:[_&&t.jsx("span",{className:"ui-icon-button ui-icon-button--small msg-action-button msg-goal-marker",title:"目标消息","aria-label":"目标消息",role:"img",children:t.jsx(eo,{size:13,strokeWidth:1.9,"aria-hidden":"true"})}),P.showCopy&&t.jsx("button",{type:"button",onClick:()=>{ji(a.content)},title:"复制内容","aria-label":"复制内容",className:"ui-icon-button ui-icon-button--small msg-action-button",children:t.jsx(Si,{size:13,strokeWidth:1.8,"aria-hidden":"true"})})]}),I&&m.isQueued&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:4},children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,color:"var(--text-muted)",padding:"2px 8px",borderRadius:20,background:"var(--bg-deep)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"排队中"]}),Js&&t.jsxs("button",{onClick:()=>void wc(a.id),disabled:wt.has(a.id)||!to(m,qn),title:to(m,qn)?wt.has(a.id)?"正在引导":"将此消息引导到当前对话":"正在保存排队消息",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:"var(--accent)",padding:"2px 10px",borderRadius:20,border:"1px solid rgba(79,110,247,0.3)",background:"var(--accent-dim)",cursor:wt.has(a.id)?"wait":"pointer",opacity:wt.has(a.id)?.6:1,transition:"all 0.15s",fontFamily:"var(--font-body)"},onMouseEnter:ne=>{ne.currentTarget.style.background="rgba(79,110,247,0.18)",ne.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:ne=>{ne.currentTarget.style.background="var(--accent-dim)",ne.currentTarget.style.borderColor="rgba(79,110,247,0.3)"},children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3 12h18M3 6h18M3 18h18"}),t.jsx("path",{d:"M12 3v18",opacity:"0.3"})]}),wt.has(a.id)?"引导中":"引导"]})]})]})]})},a.id)}),Sa.map(a=>t.jsx(Yl,{progress:a},a.progressId)),t.jsx(Nx,{running:_n,progress:Eo,startedAt:Xs}),ii&&t.jsxs(Ih,{message:ii,historical:!Vr&&!ri&&!!ks,onSwitchModel:!Vr&&Ze&&!_n&&Vn&&hn&&Wr?()=>{kh(jo.current)}:void 0,children:[!Vr&&zn&&zn===H&&t.jsxs("div",{style:{display:"inline-flex",gap:6,flexShrink:0},children:[t.jsx("button",{type:"button",onClick:()=>Ba("button"),"aria-label":"再次停止",title:"再次停止",className:"ui-icon-button",children:t.jsx(no,{size:14,fill:"currentColor","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:()=>{vc()},"aria-label":"释放会话",title:"释放会话",className:"ui-icon-button",disabled:ar!=="idle",children:ar==="releasing"?t.jsx(bt,{size:14,className:"spin","aria-hidden":"true"}):t.jsx(yu,{size:14,"aria-hidden":"true"})})]}),Vr&&t.jsxs("button",{type:"button",onClick:()=>an(a=>a+1),"aria-label":"重新加载会话",title:"重新加载会话",style:{flexShrink:0,minHeight:30,display:"inline-flex",alignItems:"center",gap:5,padding:"5px 9px",border:"1px solid rgba(248,113,113,0.35)",borderRadius:5,background:"var(--bg-workspace)",color:"var(--danger)",cursor:"pointer",fontSize:12},children:[t.jsx(go,{size:14,"aria-hidden":"true"}),"重新加载"]})]})]},H??"new-session"),t.jsx(Am,{entries:(Ra==null?void 0:Ra.entries)??[],activeMessageId:Tp,loadingMessageId:Ap,onActivate:a=>{bc(a)}}),Pi==="anchored"&&t.jsx("button",{type:"button",className:"chat-history-return-latest","data-has-updates":_p,"data-loading-newer":Mp,"aria-busy":Ta||void 0,"aria-label":"回到最新消息",title:"回到最新消息",disabled:Ta,onClick:()=>{xc()},children:Ta?t.jsx(bt,{className:"chat-history-return-latest__spinner",size:16,"aria-hidden":"true"}):t.jsx(Fc,{size:16,"aria-hidden":"true"})}),Pi!=="anchored"&&Lp&&t.jsx("button",{type:"button",className:"chat-jump-to-bottom","aria-label":"回到底部",title:"回到底部",onClick:Bp,children:t.jsx(Fc,{size:16,"aria-hidden":"true"})})]}),t.jsxs("div",{className:"chat-input-area",style:{padding:"var(--chat-input-padding)",background:"var(--bg-workspace)"},children:[ms&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9,padding:"8px 10px",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-surface)",color:An==="incompatible"?"var(--danger)":"var(--text-muted)",fontSize:12},children:t.jsx("span",{style:{flex:1},children:An==="incompatible"?fs||((Tc=p==null?void 0:p.compatibility)==null?void 0:Tc.reason)||`Codex ${((Ac=p==null?void 0:p.compatibility)==null?void 0:Ac.producerVersion)??"未知版本"} 与当前 ${((_c=p==null?void 0:p.compatibility)==null?void 0:_c.readerVersion)??"运行时"} 不兼容`:`正在使用 Codex ${((Mc=p==null?void 0:p.compatibility)==null?void 0:Mc.readerVersion)??"当前版本"} 验证此会话`})}),rt&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9,padding:"8px 10px",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-surface)",color:"var(--text-muted)",fontSize:12},children:[t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"5",y:"11",width:"14",height:"10",rx:"2"}),t.jsx("path",{d:"M8 11V7a4 4 0 0 1 8 0v4"})]}),t.jsx("span",{style:{flex:1},children:nt!=null&&nt.forkSessionId?"副本已创建,但消息尚未发送成功。":"此会话仍由原客户端持有,可创建副本继续。"}),rt&&t.jsx("button",{type:"button",onClick:()=>void rf(),disabled:Mt,style:{flexShrink:0,border:"1px solid var(--border-default)",borderRadius:5,padding:"5px 9px",background:"var(--bg-workspace)",color:"var(--text-primary)",fontSize:12,fontWeight:600,cursor:Mt?"wait":"pointer",opacity:Mt?.65:1},children:Mt?nt!=null&&nt.forkSessionId?"正在发送…":"正在创建…":nt!=null&&nt.forkSessionId?"重新发送":"以副本继续"})]}),as.length>0&&t.jsxs("div",{style:{marginBottom:10,padding:"8px 12px",borderRadius:10,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",boxShadow:"var(--shadow-sm)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6,fontSize:10,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:[t.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),"任务列表"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(()=>{const a=new Set(as.filter(b=>b.status==="completed").map(b=>b.title.toLowerCase()));return as.map(b=>{const m=b.status==="pending",I=b.status==="in-progress",_=b.status==="completed",P=m&&(b.dependsOn??[]).some(ie=>!a.has(ie.toLowerCase()));return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,opacity:_?.65:1,transition:"opacity 0.3s"},children:[t.jsxs("div",{style:{width:16,height:16,borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:_?"rgba(52,211,153,0.15)":I?"var(--accent-dim)":P?"rgba(239,68,68,0.08)":"rgba(0,0,0,0.04)",border:_?"1.5px solid rgba(52,211,153,0.6)":I?"1.5px solid var(--accent)":P?"1.5px solid rgba(239,68,68,0.5)":"1.5px solid var(--border-default)"},children:[_&&t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"rgba(52,211,153,0.9)",strokeWidth:"3",strokeLinecap:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),I&&t.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"var(--accent)",animation:"pulse 1.2s ease-in-out infinite"}}),P&&t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"rgba(239,68,68,0.8)",strokeWidth:"3",strokeLinecap:"round",children:t.jsx("path",{d:"M18 6L6 18M6 6l12 12"})}),m&&!P&&t.jsx("div",{style:{width:5,height:5,borderRadius:"50%",background:"var(--border-default)"}})]}),t.jsx("span",{style:{fontSize:12,color:_?"var(--text-muted)":P?"rgba(239,68,68,0.8)":"var(--text-primary)",textDecoration:_?"line-through":"none",flex:1},children:b.title}),P&&t.jsx("span",{title:`等待: ${(b.dependsOn??[]).join(", ")}`,style:{fontSize:10,color:"rgba(239,68,68,0.9)",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:8,padding:"1px 6px",flexShrink:0},children:"等待前置"}),b.agentName&&t.jsxs("span",{style:{fontSize:10,color:"var(--accent)",background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.2)",borderRadius:8,padding:"1px 6px",flexShrink:0},children:["@",b.agentName]})]},b.id)})})()})]}),pn.length>0&&t.jsxs("div",{style:{marginBottom:10,borderRadius:10,background:"var(--bg-surface)",border:"1px solid rgba(251,191,36,0.25)",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid rgba(251,191,36,0.15)",background:"rgba(251,191,36,0.06)"},children:[t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"#d97706",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#d97706",textTransform:"uppercase",letterSpacing:"0.07em",flex:1},children:"定时任务"}),t.jsx("button",{onClick:async()=>{window.agentApi&&(await window.agentApi.cronDeleteAll(),gt([]),Te({id:crypto.randomUUID(),role:"assistant",content:"✅ 所有定时任务已删除。",timestamp:Date.now()}))},title:"删除全部",style:{background:"none",border:"1px solid rgba(251,191,36,0.35)",borderRadius:6,color:"#d97706",cursor:"pointer",padding:"1px 7px",fontSize:10},children:"全部删除"})]}),pn.map(a=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 12px",borderBottom:"1px solid var(--border-subtle)",opacity:a.enabled?1:.7},children:[t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",flexShrink:0,background:a.enabled?"#22c55e":"#9ca3af",boxShadow:a.enabled?"0 0 5px rgba(34,197,94,0.55)":"none",animation:a.enabled?"pulse 2s ease-in-out infinite":"none"}}),t.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#d97706",background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.25)",borderRadius:6,padding:"1px 6px",flexShrink:0,fontFamily:"var(--font-mono)"},children:a.cron}),t.jsx("span",{style:{fontSize:12,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.label||a.prompt}),t.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",flexShrink:0},children:a.id.slice(0,6)}),t.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[a.enabled?t.jsx("button",{title:"暂停",onClick:async()=>{if(window.agentApi){await window.agentApi.cronPause(a.id);const b=await window.agentApi.cronList();gt(b)}},style:{background:"none",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",padding:"2px 7px",fontSize:11},onMouseEnter:b=>{b.currentTarget.style.borderColor="#d97706",b.currentTarget.style.color="#d97706"},onMouseLeave:b=>{b.currentTarget.style.borderColor="var(--border-default)",b.currentTarget.style.color="var(--text-muted)"},children:"⏸"}):t.jsx("button",{title:"恢复",onClick:async()=>{if(window.agentApi){await window.agentApi.cronResume(a.id);const b=await window.agentApi.cronList();gt(b)}},style:{background:"none",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",padding:"2px 7px",fontSize:11},onMouseEnter:b=>{b.currentTarget.style.borderColor="#22c55e",b.currentTarget.style.color="#22c55e"},onMouseLeave:b=>{b.currentTarget.style.borderColor="var(--border-default)",b.currentTarget.style.color="var(--text-muted)"},children:"▶"}),t.jsx("button",{title:"删除",onClick:async()=>{if(window.agentApi){await window.agentApi.cronDelete(a.id);const b=await window.agentApi.cronList();gt(b)}},style:{background:"none",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",padding:"2px 7px",fontSize:11},onMouseEnter:b=>{b.currentTarget.style.borderColor="var(--danger)",b.currentTarget.style.color="var(--danger)"},onMouseLeave:b=>{b.currentTarget.style.borderColor="var(--border-default)",b.currentTarget.style.color="var(--text-muted)"},children:"🗑"})]})]},a.id))]}),_o.length>0&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:10},children:_o.map((a,b)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,padding:"3px 10px 3px 8px",borderRadius:20,background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.18)",fontSize:12,color:"var(--accent)",maxWidth:220},children:[t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.name}),t.jsx("button",{onClick:()=>Qp(b),style:{background:"none",border:"none",color:"rgba(79,110,247,0.55)",cursor:"pointer",padding:0,marginLeft:2,fontSize:13,lineHeight:1,display:"flex"},children:"✕"})]},b))}),Dn.length>0&&(()=>{const a=yt.find(m=>m.id===Rn),b=!ht&&(!a||!Da(a.modelId));return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:10},children:[b&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:8,background:"rgba(234,179,8,0.1)",border:"1px solid rgba(234,179,8,0.4)",color:"rgba(202,138,4,1)",fontSize:12},children:[t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),"当前模型(",(a==null?void 0:a.modelId)??"未配置",")不支持图片,发送前请切换到支持视觉的模型(如 claude-3、gpt-4o)"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:Dn.map((m,I)=>t.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[t.jsx("button",{type:"button",className:"chat-message-image-button pending-image-preview-button","aria-label":`预览待发送图片 ${I+1}`,onClick:()=>Cs({src:m,alt:`待发送图片 ${I+1}`}),children:t.jsx("img",{src:m,alt:`待发送图片 ${I+1}`,style:{width:72,height:72,objectFit:"cover",borderRadius:8,border:"1.5px solid var(--border-default)",display:"block"}})}),t.jsx("button",{type:"button","aria-label":`删除待发送图片 ${I+1}`,onClick:()=>Xp(I),style:{position:"absolute",top:-6,right:-6,width:18,height:18,borderRadius:"50%",background:"var(--danger, #e53e3e)",border:"none",color:"#fff",fontSize:11,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},children:"✕"})]},I))})]})})(),Me==="deepseek-harness"&&H&&((Lc=window.agentApi)==null?void 0:Lc.listSessionBackgroundJobs)&&t.jsx(Wx,{sessionId:H},H),Gn&&t.jsx(ob,{goal:Kt.goal,pending:Kt.pending,error:Kt.error,onMutate:a=>H?Kt.mutate(H,a):Promise.reject(new Error("请先选择会话"))}),It&&(()=>{const a={active:"推进中",paused:"已暂停",blocked:"已受阻",usage_limited:"用量受限",budget_limited:"预算耗尽",complete:"已完成"},b=It.status!=="active"&&It.status!=="complete";return t.jsxs("div",{className:`goal-queue thread-goal is-${It.status}`,"aria-label":"目标模式",children:[t.jsxs("div",{className:"goal-queue__header",children:[t.jsx(eo,{size:14,strokeWidth:1.9,"aria-hidden":"true"}),t.jsx("span",{children:"目标模式"}),t.jsx("span",{className:"goal-queue__count",children:a[It.status]}),t.jsx("span",{className:"thread-goal__usage",children:It.tokenBudget!==null?`${It.tokensUsed}/${It.tokenBudget} tokens · ${It.turnCount} 轮`:`${It.tokensUsed} tokens · ${It.turnCount} 轮`})]}),t.jsxs("div",{className:"goal-queue__row is-active",children:[t.jsx("span",{className:"goal-queue__objective",title:It.objective,children:It.objective}),It.status==="active"&&t.jsx("button",{type:"button",className:"goal-queue__action",onClick:()=>{za("pause")},title:"暂停目标续跑","aria-label":"暂停目标续跑",children:"⏸"}),b&&t.jsx("button",{type:"button",className:"goal-queue__action",onClick:()=>{za("resume")},title:"恢复目标续跑","aria-label":"恢复目标续跑",children:t.jsx(hu,{size:12,strokeWidth:2,"aria-hidden":"true"})}),t.jsx("button",{type:"button",className:"goal-queue__action",onClick:()=>{za("clear")},title:"清除目标,停止续跑","aria-label":"清除目标,停止续跑",children:t.jsx(Bs,{size:12,strokeWidth:2,"aria-hidden":"true"})})]})]})})(),(ft.active||ft.queued.length>0)&&t.jsxs("div",{className:"goal-queue","aria-label":"目标队列",children:[t.jsxs("div",{className:"goal-queue__header",children:[t.jsx(eo,{size:14,strokeWidth:1.9,"aria-hidden":"true"}),t.jsx("span",{children:"目标"}),t.jsx("span",{className:"goal-queue__count",children:ft.queued.length+(ft.active?1:0)})]}),ft.active&&t.jsxs("div",{className:"goal-queue__row is-active",children:[t.jsx("span",{className:"goal-queue__state",children:"进行中"}),t.jsx("span",{className:"goal-queue__objective",title:ft.active.objective,children:ft.active.objective}),t.jsx("button",{type:"button",className:"goal-queue__action",onClick:()=>{Sc(ft.active.id)},title:"停止当前目标","aria-label":"停止当前目标",children:t.jsx(Bs,{size:14,strokeWidth:1.8,"aria-hidden":"true"})})]}),ft.queued.map((a,b)=>t.jsxs("div",{className:`goal-queue__row is-queued${To===a.id?" is-dragging":""}`,draggable:!0,onDragStart:()=>Oe(a.id),onDragEnd:()=>Oe(null),onDragOver:m=>m.preventDefault(),onDrop:()=>{cf(a.id)},children:[t.jsx(Bc,{className:"goal-queue__grip",size:14,strokeWidth:1.8,"aria-hidden":"true"}),t.jsxs("span",{className:"goal-queue__state",children:["#",b+1]}),t.jsx("span",{className:"goal-queue__objective",title:a.objective,children:a.objective}),t.jsx("button",{type:"button",className:"goal-queue__action",onClick:()=>{Sc(a.id)},title:"移出目标队列","aria-label":"移出目标队列",children:t.jsx(Bs,{size:14,strokeWidth:1.8,"aria-hidden":"true"})})]},a.id))]}),(()=>{const a=Tt.filter(b=>b.isQueued);return a.length===0?null:t.jsx("div",{className:"queued-message-list",children:a.map(b=>{const m=b,I=vr===b.id,_=!to(m,qn),P=wt.has(b.id),ie=m.content.length>80?m.content.slice(0,80)+"…":m.content;return t.jsxs("div",{className:`queued-message-row${ws===b.id?" is-dragging":""}`,"data-queued-message-id":b.id,onDragOver:B=>{!ws||ws===b.id||(B.preventDefault(),B.dataTransfer.dropEffect="move")},onDrop:B=>{B.preventDefault(),ws&&Fa(ws,b.id),Fr(null)},children:[t.jsx("button",{type:"button",className:"queued-message-grip",draggable:!I,"aria-label":"拖动调整排队顺序",title:"拖动调整顺序",onDragStart:B=>{Fr(b.id),B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",b.id)},onDragEnd:()=>Fr(null),onKeyDown:B=>{(B.key==="ArrowUp"||B.key==="ArrowDown")&&(B.preventDefault(),lf(b.id,B.key==="ArrowUp"?-1:1))},onPointerDown:B=>{B.pointerType==="mouse"||I||(js.current={id:b.id,pointerId:B.pointerId},B.currentTarget.setPointerCapture(B.pointerId),Fr(b.id))},onPointerMove:B=>{var re;const me=js.current;if(!me||me.pointerId!==B.pointerId)return;B.preventDefault();const ue=(re=document.elementFromPoint(B.clientX,B.clientY))==null?void 0:re.closest("[data-queued-message-id]"),pe=ue==null?void 0:ue.dataset.queuedMessageId;pe&&pe!==me.id&&Fa(me.id,pe)},onPointerUp:B=>{var me;((me=js.current)==null?void 0:me.pointerId)===B.pointerId&&(js.current=null,Fr(null))},onPointerCancel:()=>{js.current=null,Fr(null)},children:t.jsx(Bc,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsxs("div",{className:"queued-message-content",children:[m.agentName&&t.jsxs("span",{className:"queued-message-agent",children:["@",m.agentName]}),I?t.jsx("input",{autoFocus:!0,className:"queued-message-edit-input",value:vs,onChange:B=>Qt(B.target.value),onKeyDown:B=>{B.key==="Enter"&&!B.nativeEvent.isComposing?(B.preventDefault(),jc(b.id)):B.key==="Escape"&&(B.preventDefault(),Oa())},"aria-label":"编辑排队消息内容"}):t.jsx("span",{className:"queued-message-text",title:m.content,children:ie})]}),t.jsxs("div",{className:"queued-message-actions",children:[Js&&t.jsx("button",{type:"button",className:"queued-message-action queued-message-action--accent",onClick:()=>void wc(b.id),disabled:_||P,title:_?"正在保存排队消息":P?"正在引导":"引导到当前对话","aria-label":_?"正在保存排队消息":P?"正在引导排队消息":"引导排队消息到当前对话",children:_||P?t.jsx(bt,{className:"spin",size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(qc,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",className:"queued-message-action",onClick:()=>void of(b.id),title:Zs===b.id?"已复制":"复制","aria-label":"复制排队消息",children:Zs===b.id?t.jsx(er,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(Si,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",className:"queued-message-action",onClick:()=>I?jc(b.id):sf(b.id),disabled:I&&!vs.trim(),title:I?"保存":"编辑","aria-label":I?"保存排队消息":"编辑排队消息",children:I?t.jsx(er,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(Ll,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",className:"queued-message-action queued-message-action--danger",onClick:()=>af(b.id),title:"删除","aria-label":"删除排队消息",children:t.jsx(Bs,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]})]},b.id)})})})(),t.jsxs("div",{ref:_a,className:"composer-anchor",style:{position:"relative"},children:[Ce.error&&t.jsx("div",{className:"parallel-send-notice",role:"alert",children:Ce.error}),Ce.failed.map(a=>t.jsxs("div",{className:"parallel-send-notice",role:"alert",children:[t.jsxs("span",{children:[qt[a.member.agentType],":",a.error]}),t.jsx("button",{type:"button",disabled:Ce.submitting||a.blocked,onClick:()=>{Ce.retry(a).then(b=>{var m;b.accepted.length&&(Ko(a.member.id)===a.message.content&&(Zr(a.member.id),De.clear(a.member.id)),H===a.member.id&&((m=Cr.current)==null?void 0:m.value)===a.message.content&&(vt(""),Et([])))}).catch(b=>ge(b instanceof Error?b.message:"重试发送失败"))},children:"重试发送"})]},`${a.member.id}:${a.message.sourceMessageId}`)),t.jsxs("div",{className:`composer-shell${gn?" composer-shell--new-session":""}${At?" composer-shell--parallel":""}`,style:{display:"flex",flexDirection:"column",gap:0,background:"var(--bg-surface)",borderRadius:14,overflow:"visible"},children:[gn&&(Pe||oe!==void 0||Ne!==void 0)&&t.jsxs("div",{className:"composer-context-row",role:"group","aria-label":"新会话的 Agent 和目录",children:[Pe&&t.jsx(Hc,{value:Me,health:Se,onChange:Pe,values:cs,onValuesChange:a=>{yo(a),Lr(a.includes(ds)?ds:a[0]),a.length===1&&Pe(a[0])}}),(oe!==void 0||Ne!==void 0)&&t.jsx(jh,{value:n??null,workspaces:oe??[],onChange:a=>Ne==null?void 0:Ne(a),onPickFolder:at})]}),!gn&&Ce.group&&t.jsxs("div",{className:"composer-context-row",role:"group","aria-label":"消息发送对象",children:[t.jsx(Hc,{value:Me,health:Se,onChange:()=>{},purpose:"recipients",allowedAgentTypes:Ce.group.members.map(a=>a.agentType),values:Ce.group.members.filter(a=>Ce.recipients.includes(a.id)).map(a=>a.agentType),onValuesChange:a=>Ce.setRecipients(Ce.group.members.filter(b=>a.includes(b.agentType)).map(b=>b.id))}),t.jsx("span",{className:"parallel-composer-directory",title:Ce.group.cwd,children:Ce.group.cwd.split(/[\\/]/).filter(Boolean).at(-1)})]}),t.jsxs("div",{className:"composer-input-row",style:{display:"flex",alignItems:"center",gap:8,padding:"var(--composer-row-padding)"},children:[t.jsx("input",{ref:rc,type:"file",multiple:!0,style:{display:"none"},onChange:Vp}),Di.length>0&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,flexShrink:0,flexWrap:"nowrap",overflow:"hidden",maxWidth:300},children:Di.map(a=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,padding:"2px 7px 2px 6px",borderRadius:20,background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.25)",fontSize:12,color:"var(--accent)",flexShrink:0,whiteSpace:"nowrap"},children:[t.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M20 21a8 8 0 1 0-16 0"})]}),"@",a.name,t.jsx("button",{onClick:()=>qp(a.id),style:{background:"none",border:"none",color:"rgba(79,110,247,0.55)",cursor:"pointer",padding:0,lineHeight:1,fontSize:12,display:"flex"},children:"✕"})]},a.id))}),t.jsx("textarea",{className:"composer-text-input web-native-composer-textarea",ref:Cr,rows:3,value:rn,onChange:a=>gc(a.target.value),onBlur:()=>setTimeout(()=>{Rs(null),Ts(null)},120),onKeyDown:Gp,placeholder:At?"输入消息,选择接收的 Agent":Ss&&sn?"输入要持续推进的目标":ar==="released"?"已停止在 AgentRoam 中使用;Codex Desktop 最长约 30 分钟后可用":ms?An==="incompatible"?"Codex 版本不兼容":"正在验证会话兼容性":ko?"原客户端使用中,当前只读":Sd(p)?"补充要求会交给桌面端原会话":Ai?sn?"输入要持续推进的目标":lr?"输入下一条排队消息":gn?"描述你想做的事,第一条消息会创建会话":"提出后续修改要求":"请先在设置中配置 API Key",disabled:!jr,readOnly:Bn}),t.jsxs("div",{className:"web-native-composer-toolbar",children:[t.jsxs("div",{className:"web-native-add-wrap",children:[t.jsx("button",{type:"button",className:"web-native-add-button","aria-label":_s?"正在完成识别":Bn?"停止语音输入":"添加附件、图片或语音","aria-expanded":Bn?void 0:Ro,"aria-pressed":Bn||void 0,title:_s?"正在完成识别…":Oo?"正在连接麦克风,点击停止":Bn?"停止语音输入":"添加附件、图片或语音",disabled:_s,onClick:()=>Bn?cc():ei(a=>!a),children:_s||Oo?t.jsx(bt,{className:"web-native-dictation-spinner",size:20,"aria-hidden":"true"}):Bn?t.jsx(no,{size:18,fill:"currentColor","aria-hidden":"true"}):t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M12 5v14M5 12h14"})})}),Ro&&!Bn&&t.jsxs("div",{className:"web-native-add-menu",role:"group","aria-label":"添加附件或语音",children:[t.jsx("button",{type:"button","aria-label":"附件 / 图片",title:"附件 / 图片",onClick:()=>{var a;ei(!1),(a=rc.current)==null||a.click()},children:t.jsx(bu,{size:20,"aria-hidden":"true"})}),t.jsx("button",{type:"button","aria-label":"语音输入",title:"语音输入",disabled:!jr,onClick:()=>{ei(!1),cc()},children:t.jsx(Ff,{size:20,"aria-hidden":"true"})})]})]}),t.jsx("button",{type:"button",className:`web-native-runtime-status goal-mode-toggle${sn?" is-active":""}`,"aria-pressed":sn,"aria-label":sn?"关闭目标模式":"开启目标模式",title:(p==null?void 0:p.nativeGoalSupported)===!1?"子会话不支持单独设置目标":sn?"目标模式已开启":"目标模式",disabled:(p==null?void 0:p.nativeGoalSupported)===!1,onClick:()=>No(a=>!a),children:t.jsx(eo,{size:18,strokeWidth:1.9,"aria-hidden":"true"})}),t.jsxs("div",{className:"web-native-permission-wrap",ref:ni,children:[t.jsx("button",{type:"button",className:`web-native-runtime-status web-native-permission-button mode-${Hr}`,"aria-label":`会话权限:${Gr}`,"aria-haspopup":"menu","aria-expanded":qr,title:`会话权限:${Gr}`,disabled:!H||Ao||ti&&(!(jt!=null&&jt.options.length)||!((zc=window.agentApi)!=null&&zc.setSessionNativePermissionPreset)),onClick:()=>Ur(a=>!a),children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),t.jsx("path",{d:"M12 8v4"}),t.jsx("path",{d:"M12 16h.01"})]})}),qr&&ti&&t.jsx("div",{className:"web-native-permission-menu",role:"menu","aria-label":"DeepSeek Harness 原生权限",children:jt==null?void 0:jt.options.map(a=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":jt.currentValue===a.value,className:jt.currentValue===a.value?"is-active":"",onClick:()=>{tf(a.value)},children:[t.jsx("span",{className:"web-native-permission-check","aria-hidden":"true",children:jt.currentValue===a.value?"✓":""}),t.jsxs("span",{className:"web-native-permission-copy",children:[t.jsx("strong",{children:Od(a.value,a.label)}),a.description&&t.jsx("small",{children:a.description})]})]},a.value))}),qr&&!ti&&t.jsx("div",{className:"web-native-permission-menu",role:"menu","aria-label":"会话权限模式",children:Cl.map(a=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":Hr===a.value,className:Hr===a.value?"is-active":"",onClick:()=>{ef(a.value)},children:[t.jsx("span",{className:"web-native-permission-check","aria-hidden":"true",children:Hr===a.value?"✓":""}),t.jsxs("span",{className:"web-native-permission-copy",children:[t.jsx("strong",{children:a.label}),t.jsx("small",{children:a.description})]})]},a.value))})]}),t.jsx("div",{className:"web-native-context-control",children:Me==="deepseek-harness"?t.jsx(Ex,{sessionId:H,mode:p==null?void 0:p.nativeMode,prepareSession:gn?df:void 0,onSessionPrepared:async a=>{Ke.current=a.id,lt(a.id),s&&await s(a.id,a)}}):t.jsx(Pu,{usage:H?Xe[H]:void 0,contextWindowK:Us,compact:!0})}),At?t.jsx(ah,{contextWindowK:Us,agentTypes:Ce.group?Ce.group.members.map(a=>a.agentType):cs,sessions:(Pc=Ce.group)==null?void 0:Pc.members,customerProfiles:yt,customerProfileId:Rn,onCustomerProfileChange:a=>{Ht(a)},customerEffort:{value:or,options:Il,onChange:a=>{Ni("reasoningEffort",a),ls()}},onChange:()=>Nn(ro(Me)),onOpenSession:a=>{Ce.select(a,async()=>{dn(a.id,Rt.current.text),await De.save(a.id,Rt.current.images)})}}):t.jsx("div",{className:`web-native-model-control${ht?" web-native-model-control--native":""}`,title:"切换模型",children:ht&&Fs(Me)?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"web-native-model-agent",title:`${$d[Me]} 会话`,children:[t.jsx(_r,{agentType:Me,size:14}),t.jsx("span",{className:"web-native-model-agent-name",children:$d[Me]})]}),!Vn&&t.jsx("span",{title:"子会话沿用原生模型设置",children:"原生模型"}),Vn&&Me==="qoder"&&t.jsx(vh,{status:Gt.status,error:Gt.error,onRetry:Gt.retry}),Vn&&Wr&&t.jsx(od,{ref:jo,value:Ks,options:[{value:"",label:"默认模型"},...Me==="opencode"?So.flatMap(a=>a.models.map(b=>({value:Sn(b),label:b.optionLabel,group:a.label}))):Qs.map(a=>({value:a.key,label:a.label}))],onChange:a=>Ti({model:a?ku(a,Zt):void 0})})]}):t.jsx(od,{value:Rn,disabled:yt.length===0,options:yt.length===0?[{value:"",label:"未配置模型"}]:yt.map(a=>({value:a.id,label:a.name||a.modelId})),onChange:a=>{Ht(a)}})}),At&&!ys?null:ys?t.jsx("button",{type:"button",onClick:()=>Ba("button"),className:"web-native-stop-button","aria-label":"停止生成",title:"停止生成",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}):ht&&hs.length>0?t.jsxs("div",{className:"web-native-effort-wrap",ref:br,children:[t.jsx("button",{type:"button",className:"web-native-effort-button","aria-expanded":Tn,"aria-label":`推理强度:${en?tl[en]:"默认"}`,title:`推理强度:${en?tl[en]:"默认"}(点击切换)`,onClick:()=>gs(a=>!a),children:t.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M9.5 4.5A3.5 3.5 0 0 0 6 8v1a3 3 0 0 0-2 2.83V14a3 3 0 0 0 3 3h.25A3.75 3.75 0 0 0 11 20.75V3.25A3.75 3.75 0 0 0 9.5 4.5Z"}),t.jsx("path",{d:"M14.5 4.5A3.5 3.5 0 0 1 18 8v1a3 3 0 0 1 2 2.83V14a3 3 0 0 1-3 3h-.25A3.75 3.75 0 0 1 13 20.75V3.25a3.75 3.75 0 0 1 1.5 1.25Z"})]})}),Tn&&t.jsxs("div",{className:"web-native-effort-menu",role:"menu","aria-label":"推理强度",children:[t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":!en,className:en?void 0:"is-active",onClick:()=>{Ti({reasoningEffort:void 0}),gs(!1)},children:[t.jsx("span",{className:"web-native-effort-check","aria-hidden":"true",children:en?"":"✓"}),"默认"]}),hs.map(a=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":en===a,className:en===a?"is-active":void 0,onClick:()=>{Ti({reasoningEffort:a}),gs(!1)},children:[t.jsx("span",{className:"web-native-effort-check","aria-hidden":"true",children:en===a?"✓":""}),tl[a]]},a))]})]}):ht?t.jsxs("span",{className:"web-native-agent-status",role:"status","aria-label":"Agent 空闲",title:"Agent 空闲",children:[t.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M9.5 4.5A3.5 3.5 0 0 0 6 8v1a3 3 0 0 0-2 2.83V14a3 3 0 0 0 3 3h.25A3.75 3.75 0 0 0 11 20.75V3.25A3.75 3.75 0 0 0 9.5 4.5Z"}),t.jsx("path",{d:"M14.5 4.5A3.5 3.5 0 0 1 18 8v1a3 3 0 0 1 2 2.83V14a3 3 0 0 1-3 3h-.25A3.75 3.75 0 0 1 13 20.75V3.25a3.75 3.75 0 0 1 1.5 1.25Z"})]}),t.jsx("span",{"aria-hidden":"true"})]}):t.jsxs("div",{className:"web-native-effort-wrap",ref:Ln,children:[t.jsx("button",{type:"button",className:"web-native-effort-button","aria-expanded":wr,"aria-label":`推理强度:${Wd[or]}`,title:`推理强度:${Wd[or]}(点击切换)`,onClick:()=>Li(a=>!a),children:t.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M9.5 4.5A3.5 3.5 0 0 0 6 8v1a3 3 0 0 0-2 2.83V14a3 3 0 0 0 3 3h.25A3.75 3.75 0 0 0 11 20.75V3.25A3.75 3.75 0 0 0 9.5 4.5Z"}),t.jsx("path",{d:"M14.5 4.5A3.5 3.5 0 0 1 18 8v1a3 3 0 0 1 2 2.83V14a3 3 0 0 1-3 3h-.25A3.75 3.75 0 0 1 13 20.75V3.25a3.75 3.75 0 0 1 1.5 1.25Z"})]})}),wr&&t.jsx("div",{className:"web-native-effort-menu",role:"menu","aria-label":"推理强度",children:Il.map(a=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":or===a.value,className:or===a.value?"is-active":void 0,onClick:()=>{Ni("reasoningEffort",a.value),ls(),Li(!1)},children:[t.jsx("span",{className:"web-native-effort-check","aria-hidden":"true",children:or===a.value?"✓":""}),a.label]},a.value))})]}),t.jsx("button",{type:"button",onClick:Ic,disabled:Vt||!jr||Kt.pending||ai>0||!rn.trim()&&!Dn.length,className:"web-native-send-button","aria-busy":Vt,"aria-label":Vt?"正在创建会话":!At&&lr?"排队发送":"发送",title:!At&&lr?"排队发送":"发送",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]})]})]})]}),t.jsx(Fl,{message:La,type:"error"}),t.jsxs("div",{className:"chat-composer-hint",style:{textAlign:"center",marginTop:7,fontSize:11,color:"var(--text-muted)",letterSpacing:"0.03em",opacity:.6},children:["Enter 发送",sn?"目标":!At&&lr?"(排队)":""," · @智能体(可多选)· /技能 · Shift+Enter 换行",_s?" · 正在完成识别…":Oo?" · 正在连接麦克风…":Bn?" · 🎤 正在聆听,可直接点发送":""]})]}),t.jsx(fu,{image:ka,onClose:()=>Cs(null)}),Kr&&Wi!==null&&fc.length>0&&Wt.createPortal(t.jsxs("div",{style:{position:"fixed",bottom:window.innerHeight-Kr.top+8,left:Kr.left,width:Kr.width,background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:10,boxShadow:"var(--shadow-md)",overflow:"hidden",zIndex:99999},children:[t.jsx("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"智能体"}),fc.map(a=>t.jsxs("button",{onMouseDown:b=>{b.preventDefault(),Fp(a)},style:{display:"block",width:"100%",textAlign:"left",padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer"},onMouseEnter:b=>{b.currentTarget.style.background="var(--accent-dim)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:[t.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:["@",a.name]}),a.description&&t.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:1},children:a.description})]},a.id))]}),document.body),Kr&&Ns!==null&&Pa.length>0&&Wt.createPortal(t.jsxs("div",{style:{position:"fixed",bottom:window.innerHeight-Kr.top+8,left:Kr.left,width:Kr.width,background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:10,boxShadow:"var(--shadow-md)",zIndex:99999,display:"flex",flexDirection:"column",maxHeight:320},children:[t.jsxs("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",flexShrink:0},children:["技能 (",Pa.length,")"]}),t.jsx("div",{style:{overflowY:"auto",flex:1},children:Pa.map(a=>t.jsxs("button",{onMouseDown:b=>{b.preventDefault(),Up(a)},style:{display:"block",width:"100%",textAlign:"left",padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer"},onMouseEnter:b=>{b.currentTarget.style.background="var(--accent-dim)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:[t.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:["/",a.name]}),a.description&&t.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.description})]},a.name))})]}),document.body)]})})}function nl(e,n,r="auto"){const s=e.getBoundingClientRect(),i=n.getBoundingClientRect(),o=e.scrollTop+i.top-s.top-Math.max(0,(e.clientHeight-i.height)/2);e.scrollTo({top:Math.max(0,o),behavior:r})}async function mb(e,n,r){n.throwIfAborted();const s=await e(r);if(n.throwIfAborted(),s.nextCursor&&s.nextCursor===r)throw new Error("历史会话分页已失效,请刷新重试");return{...s,data:xp([],s.data)}}function xp(e,n){return[...new Map([...e,...n].map(r=>[r.id,r])).values()]}function xb(e,n,r){const s=new Set(n),i=new Set(r),o=l=>l.status==="running"||i.has(l.id);return[...e].sort((l,u)=>Number(o(u))-Number(o(l))||Number(s.has(u.id))-Number(s.has(l.id))||u.updated.localeCompare(l.updated)||l.id.localeCompare(u.id))}const bp="agentroam.all-sessions.v1",yp=20;function Fd(e){try{const n=e??(typeof window>"u"?void 0:window.localStorage),r=JSON.parse((n==null?void 0:n.getItem(bp))??"null");return!vp(r)||r.version!==1||!Array.isArray(r.data)||!r.data.every(yb)||typeof r.total!="number"||!Number.isSafeInteger(r.total)||r.total<r.data.length?null:{data:r.data.slice(0,yp),total:r.total}}catch{return null}}function bb(e,n){try{const r=n??(typeof window>"u"?void 0:window.localStorage);r==null||r.setItem(bp,JSON.stringify({version:1,data:e.data.slice(0,yp),total:e.total}))}catch{}}function vp(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function yb(e){return vp(e)&&typeof e.id=="string"&&fl(e.agentType)&&typeof e.title=="string"&&typeof e.cwd=="string"&&typeof e.updated=="string"&&typeof e.status=="string"&&["idle","running","completed","failed"].includes(e.status)&&typeof e.canResume=="boolean"&&(e.projectId===void 0||typeof e.projectId=="string")&&(e.readOnly===void 0||typeof e.readOnly=="boolean")&&(e.occupancy===void 0||typeof e.occupancy=="string"&&["available","owned-by-customer-agent","owned-externally"].includes(e.occupancy))}function oo({session:e,deleteLabel:n="删除会话",onSelect:r,onPin:s,onDelete:i}){var o,l;return t.jsxs("div",{className:`sidebar-row sidebar-session-row${e.child?" sidebar-session-row--child":""}${e.active?" sidebar-row-active":""}`,children:[t.jsxs("button",{type:"button",className:"sidebar-session-button",onClick:r,"aria-pressed":e.active,"aria-expanded":e.hasChildren?!!e.expanded:void 0,title:[e.title,e.workspacePath].filter(Boolean).join(`
|
|
172
|
+
`),children:[t.jsx("span",{className:`sidebar-status-dot is-${e.visualState}`,title:e.statusLabel,"aria-label":e.statusLabel}),t.jsx("span",{className:"sidebar-session-title",children:e.title}),e.agentType&&t.jsx("span",{className:"sidebar-session-agent",role:"img","aria-label":qt[e.agentType],title:qt[e.agentType],children:t.jsx(_r,{agentType:e.agentType,size:18})}),((o=e.compatibility)==null?void 0:o.status)==="checking"&&t.jsx("span",{className:"sidebar-session-compatibility",title:`Codex ${e.compatibility.producerVersion??"未知版本"} 会话兼容性待验证,打开会话时检查`,"aria-label":"会话兼容性待验证,打开会话时检查",children:t.jsx(ug,{size:13,"aria-hidden":"true"})}),((l=e.compatibility)==null?void 0:l.status)==="incompatible"&&t.jsx("span",{className:"sidebar-session-compatibility",title:e.compatibility.reason??"Codex 版本不兼容","aria-label":"Codex 版本不兼容",children:t.jsx(Ci,{size:13,"aria-hidden":"true"})}),e.occupiedExternally&&t.jsx("span",{className:"sidebar-session-lock",title:"原客户端正在使用,只读","aria-label":"原客户端正在使用,只读",children:t.jsx(hg,{size:13,"aria-hidden":"true"})}),e.hasChildren&&t.jsx(Ii,{size:13,className:`sidebar-session-disclosure${e.expanded?" is-expanded":""}`,"aria-hidden":"true"})]}),s&&!e.child&&t.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),s()},title:e.pinned?"取消置顶":"置顶会话","aria-label":`${e.pinned?"取消置顶":"置顶会话"}:${e.title}`,"aria-pressed":!!e.pinned,className:`sidebar-session-pin sidebar-row-action ui-icon-button ui-icon-button--small${e.pinned?" sidebar-row-action--accent":""}`,children:t.jsx(Df,{size:14,"aria-hidden":"true"})}),e.canDelete&&i&&t.jsx("button",{type:"button",onClick:u=>{u.stopPropagation();const d=u.currentTarget.getBoundingClientRect();i({top:d.top,left:d.left,width:d.width,height:d.height})},title:n,"aria-label":`${n}:${e.title}`,className:"sidebar-session-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",children:t.jsx(Bs,{size:14,"aria-hidden":"true"})})]})}function wp({loading:e,error:n,onRefresh:r,subject:s="目录"}){const i=e?`正在加载${s}`:n?`${s}加载失败,点击重试`:`刷新${s}`;return t.jsxs("button",{type:"button",disabled:e,onClick:r,title:n&&!e?`${i}:${n}`:i,"aria-label":i,"aria-busy":e,className:"ui-icon-button sidebar-directory-refresh",children:[t.jsx(go,{size:17,className:e?"animate-spin":void 0,"aria-hidden":"true"}),n&&!e&&t.jsx(Ci,{size:10,className:"sidebar-directory-refresh-error","aria-hidden":"true"})]})}function vb(e){const n=_l(),[r]=c.useState(()=>Fd()),[s,i]=c.useState((r==null?void 0:r.data)??[]),[o,l]=c.useState((r==null?void 0:r.total)??0),[u,d]=c.useState(r!==null),[g,h]=c.useState(""),[p,k]=c.useState(""),[x,y]=c.useState(null),[S,v]=c.useState(!1),[w,j]=c.useState(null),C=c.useRef(null),A=c.useRef(""),L=c.useRef(`${e.revision}:${e.runningSessionId}`),z=c.useRef({query:"",rows:(r==null?void 0:r.data)??[],cursor:null}),R=c.useRef(null);c.useEffect(()=>{const se=window.setTimeout(()=>k(g.trim()),250);return()=>window.clearTimeout(se)},[g]);const N=c.useCallback(async se=>{var K;if(!Dt()||!se&&(C.current||!z.current.cursor)||C.current&&!C.current.signal.aborted&&A.current===p)return;se&&((K=C.current)==null||K.abort());const we=new AbortController;C.current=we,A.current=p;const Y=z.current;if(v(!0),j(null),se&&Y.query!==p){const Q=p?null:Fd();z.current={query:p,rows:(Q==null?void 0:Q.data)??[],cursor:null},i((Q==null?void 0:Q.data)??[]),l((Q==null?void 0:Q.total)??0),y(null),d(Q!==null)}try{const Q=await mb(Pe=>lo({action:"sessionCatalog",query:p,limit:20,cursor:Pe}),we.signal,se?void 0:Y.cursor??void 0),Se=se?Q.data:xp(Y.rows,Q.data);z.current={query:p,rows:Se,cursor:Q.nextCursor},i(Se),l(Q.total),y(Q.nextCursor),d(!1),se&&!p&&bb(Q),se&&Y.query!==p&&R.current&&(R.current.scrollTop=0)}catch(Q){we.signal.aborted||j(Q instanceof Error?Q.message:"会话加载失败")}finally{C.current===we&&(C.current=null,v(!1))}},[p]);c.useEffect(()=>{if(!n)return;const se=`${e.revision}:${e.runningSessionId}`,we=L.current!==se;L.current=se,(we||z.current.query!==p||z.current.rows.length<=20)&&N(!0);const Y=()=>{Dt()&&!C.current&&z.current.rows.length<=20&&N(!0)},K=window.setInterval(Y,15e3);return window.addEventListener("focus",Y),()=>{var Q;(Q=C.current)==null||Q.abort(),window.clearInterval(K),window.removeEventListener("focus",Y)}},[n,N,p,e.revision,e.runningSessionId]);const T=[...e.needsInput,...e.runningSessionId?[e.runningSessionId]:[]],F=xb(s,e.pinnedIds,T),O=g.trim().toLocaleLowerCase(),q=F,ae=c.useMemo(()=>new Set(e.pinnedIds),[e.pinnedIds]);return t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"sidebar-search-field all-sessions-search",children:[t.jsx(fa,{size:15,"aria-hidden":"true"}),t.jsx("input",{"aria-label":"搜索所有 Agent 的会话",placeholder:"搜索会话或目录",value:g,onChange:se=>{h(se.target.value)}})]}),t.jsxs("div",{className:"sidebar-project-toolbar",children:[t.jsxs("div",{className:"sidebar-project-heading",children:[t.jsx("span",{className:"sidebar-project-title",children:"所有会话"}),t.jsx("span",{className:"sidebar-project-count",children:o})]}),t.jsxs("div",{className:"sidebar-project-actions",children:[t.jsx("span",{className:"all-sessions-sort-label",children:"进行中优先"}),t.jsx(wp,{loading:S,error:w,subject:"所有会话",onRefresh:()=>void N(!0)})]})]}),t.jsxs("div",{ref:R,className:"app-sidebar-scroll all-sessions-list","aria-label":"所有 Agent 会话","aria-busy":S&&!u&&!s.length,onScroll:se=>{const we=se.currentTarget;we.scrollTop>0&&we.scrollHeight-we.scrollTop-we.clientHeight<120&&N(!1)},children:[w&&t.jsxs("div",{role:"alert",className:"sidebar-load-error",children:[t.jsx("span",{children:w}),t.jsx("button",{onClick:()=>void N(!0),children:"重试"})]}),u&&t.jsx("p",{className:"sidebar-cache-state",role:"status",children:S?"显示缓存,正在后台更新…":"当前显示缓存"}),S&&!s.length&&!u&&t.jsx("p",{className:"all-sessions-empty",role:"status",children:"正在加载所有会话…"}),(!S||u)&&!w&&!q.length&&t.jsx("p",{className:"all-sessions-empty",children:O?"没有匹配的会话":"暂无会话,开始一个新任务吧"}),q.map(se=>{const we=e.needsInput.includes(se.id)?"needs-input":e.runningSessionId===se.id?"running":se.status==="failed"?"error":se.status,Y=so(we);return t.jsx(oo,{session:{id:se.id,title:se.title,agentType:se.agentType,workspacePath:se.cwd,visualState:Y,statusLabel:io[Y],active:e.selectedSessionId===se.id,pinned:ae.has(se.id),occupiedExternally:se.agentType!=="codex"&&se.occupancy==="owned-externally",canDelete:we!=="running"&&we!=="needs-input"},onSelect:()=>e.onSelect(se),onPin:()=>e.onPin(se.id),onDelete:K=>e.onDelete(se,K)},se.id)}),x&&t.jsx("button",{className:"all-sessions-more",disabled:S,onClick:()=>void N(!1),children:S?"正在加载…":"加载更早的会话"})]})]})}function wb({cursor:e,expanded:n,loading:r,error:s,nestedScroll:i,projectName:o,onLoadMore:l}){const u=c.useRef(null),d=c.useRef(null),g=c.useRef(l);if(g.current=l,c.useEffect(()=>{const p=u.current;if(!p||!e||!n||r||s||typeof IntersectionObserver>"u")return;const k=p.closest(i?".sidebar-project-sessions":".app-sidebar-scroll");if(!k)return;const x=new IntersectionObserver(y=>{!y.some(S=>S.isIntersecting)||d.current===e||(d.current=e,g.current())},{root:k,rootMargin:"0px 0px 80px 0px"});return x.observe(p),()=>x.disconnect()},[e,n,r,s,i]),!e)return null;const h=r?"正在加载历史会话...":s?"重试加载历史会话":"加载更早的会话";return t.jsxs("button",{ref:u,type:"button",className:"sidebar-session-load-more","aria-label":`${o}:${h}`,"aria-busy":r,disabled:r,title:s,onClick:()=>{d.current=e,l()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,flexShrink:0,minHeight:36,padding:"6px 10px",border:0,background:"transparent",color:s?"var(--danger)":"var(--text-muted)",fontSize:11,cursor:r?"default":"pointer"},children:[r&&t.jsx(bt,{size:12,className:"animate-spin","aria-hidden":"true"}),h]})}function jb({refreshKey:e,onOpen:n}){const[r,s]=c.useState([]),i=c.useCallback(()=>{lo({action:"groups"}).then(s).catch(()=>{})},[]);return c.useEffect(()=>{i()},[i,e]),t.jsx(t.Fragment,{children:r.length>0&&t.jsxs("div",{className:"collab-group-list","aria-label":"协作群",children:[t.jsx("span",{className:"collab-eyebrow",children:"协作群"}),r.map(o=>t.jsxs("button",{title:o.name,onClick:()=>n(o),children:[t.jsx(Vf,{size:15}),t.jsx("span",{children:o.name}),t.jsx(Ii,{size:14})]},o.id))]})})}let Zi;function Sb(){if(Zi)return Zi;const e=window.parent,n=window.location.origin;return Zi=new Promise((r,s)=>{let i;const o=()=>{i==null||i.disconnect(),clearTimeout(u)},l=()=>{try{if(!e.document.querySelector('.terminal-tab.active[data-terminal-id="messaging"]'))return!1}catch{return!1}try{const d=new URL(e.location.href);d.searchParams.get(na)==="messaging"&&(d.searchParams.delete(na),e.history.replaceState(e.history.state,"",d.href))}catch{}return o(),r(),!0},u=setTimeout(()=>{if(!l()){o();try{const d=new URL(e.location.href);d.searchParams.set(na,"messaging"),e.location.assign(d.href),r()}catch{s(new Error("消息接入未打开,请刷新页面后重试"))}}},1500);try{i=new MutationObserver(l),i.observe(e.document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),e.postMessage({type:Gf},n),l()}catch{o(),s(new Error("消息接入未打开,请刷新页面后重试"))}}).finally(()=>{Zi=void 0}),Zi}function kb({onOpen:e}){var h,p,k;const n=_l(),[r,s]=c.useState(0),[i,o]=c.useState(""),[l,u]=c.useState(null),d=c.useRef(async()=>{}),g=c.useRef(new Set);return c.useEffect(()=>{if(!n)return;let x=!0,y=!1;try{g.current=new Set(JSON.parse(localStorage.getItem("agentroam:supervision-notifications")??"[]"))}catch{}const S=async()=>{if(!(y||!Dt())){y=!0;try{const w=await lo({action:"supervisionAlerts"});if(!x)return;s(w.filter(C=>C.incident.status==="waiting").length),u(C=>C?w.find(A=>A.incident.id===C.incident.id&&A.incident.status==="waiting")??null:null);const j=w.filter(C=>!g.current.has(`${C.incident.id}:${C.incident.status}`));if(j.length){const C=j.at(-1);o(`${C.groupName} · ${C.incident.status==="waiting"?"需要你决策":C.incident.kind==="handoff"?"交接已衔接":C.incident.kind==="delivery"?"交付已确认":"异常已恢复"}`);const A=j.find(L=>L.incident.status==="waiting"&&L.target);A&&u(L=>L??A);for(const L of j)g.current.add(`${L.incident.id}:${L.incident.status}`);g.current=new Set([...g.current].slice(-300));try{localStorage.setItem("agentroam:supervision-notifications",JSON.stringify([...g.current]))}catch{}}}catch{}finally{y=!1}}};d.current=S,S();const v=setInterval(()=>{S()},7e3);return()=>{x=!1,clearInterval(v)}},[n]),c.useEffect(()=>{if(!i||r)return;const x=setTimeout(()=>o(""),1e4);return()=>clearTimeout(x)},[i,r]),!r&&!i?null:t.jsxs("aside",{className:`supervision-notice${l?" is-expanded":""}`,"aria-label":"监工提醒",role:"status",children:[t.jsxs("div",{className:"supervision-notice-heading",children:[t.jsxs("button",{onClick:e,children:[t.jsx(lg,{size:16}),t.jsx("span",{children:r?`监工有 ${r} 项待你决策`:i})]}),t.jsx("button",{"aria-label":l?"收起决策提醒":"关闭监工提醒",onClick:()=>{u(null),o("")},children:t.jsx(tr,{size:14})})]}),(l==null?void 0:l.target)&&t.jsxs("div",{className:"session-dashboard supervision-notice-content",children:[t.jsxs("strong",{children:[l.groupName," · ",l.incident.sessionTitle]}),t.jsx(Yf,{text:l.incident.message,options:((h=l.incident.question)==null?void 0:h.options)??l.incident.options,recommendation:l.incident.recommendation,multiSelect:(p=l.incident.question)==null?void 0:p.multiSelect,sourceOnly:(k=l.incident.question)==null?void 0:k.requiresSource,onSource:()=>mu({kind:"session",session:l.target}),onAnswer:async(x,y)=>{await lo({action:"answerSupervision",groupId:l.incident.groupId,incidentId:l.incident.id,answer:x,selectedIndices:y}),u(null),o(""),await d.current()}})]})]})}function Ib(e,n){const r=n==null?void 0:n.sessions.find(o=>o.id===e.id&&o.agentType===e.agentType);if(!r||!n)return;const s=n.workspaces.find(o=>o.agentType===e.agentType&&(o.workspaceId===r.projectId||o.roots.includes(r.cwd)));if(!s)return;const i={...r,title:e.title||r.title,projectId:s.workspaceId};return{session:i,snapshot:{workspaces:n.workspaces.filter(o=>o.agentType===e.agentType),sessions:[...n.sessions.filter(o=>o.agentType===e.agentType&&o.id!==e.id),i]}}}async function Cb(e,n,r,s){r.throwIfAborted();const i=await e.getSession(n.id,n.agentType==="codex"?{limit:1,view:"core"}:{limit:pr});if(r.throwIfAborted(),!(i!=null&&i.id)||i.id!==n.id||i.agentType!==n.agentType)throw new Error("原会话身份不匹配,请刷新看板后重试");const o={workspaces:(s==null?void 0:s.workspaces.filter(j=>j.agentType===n.agentType))??[],sessions:(s==null?void 0:s.sessions.filter(j=>j.agentType===n.agentType&&j.id!==n.id))??[]},l=s==null?void 0:s.sessions.find(j=>j.id===n.id),u=i.projectId??(l==null?void 0:l.projectId)??n.projectId,d=()=>o.workspaces.find(j=>j.workspaceId===u)??o.workspaces.find(j=>j.roots.includes(i.cwd||n.cwd));let g=d(),h=null;const p=new Set;for(;!g;){const j=await e.listAgentWorkspaces(n.agentType,{cursor:h,limit:200});if(r.throwIfAborted(),j.stale)throw new Error("会话目录待刷新,请重试");if(o.workspaces=[...new Map([...o.workspaces,...j.data].map(C=>[C.workspaceId,C])).values()],g=d(),h=j.nextCursor,g||!h)break;if(p.has(h))throw new Error("会话目录加载中断,请重试");p.add(h)}const k=(g==null?void 0:g.workspaceId)??u??`session-${i.id}`;g||o.workspaces.push({agentType:n.agentType,workspaceId:k,roots:[i.cwd||n.cwd],name:(i.cwd||n.cwd).split(/[\\/]/).filter(Boolean).at(-1)||"会话工作区",order:o.workspaces.length,source:"derived",canCreateSession:!1});const{messages:x,events:y,history:S,...v}=i,w={...v,cwd:i.cwd||n.cwd,projectId:k};return o.sessions.push(w),{session:w,snapshot:o,initialHistory:{sessionId:w.id,detail:i}}}function Eb({groups:e,dashboardVisible:n,sessionDashboardVisible:r,messagingVisible:s,activeId:i,onSelect:o,onClose:l}){const u=[{id:"assistant",name:"智能助手",closable:!1},...r?[{id:"sessions",name:"Dashboard",closable:!0}]:[],...n?[{id:"dashboard",name:"群聊列表",closable:!0}]:[],...s?[{id:"messaging",name:"消息接入",closable:!0}]:[],...e.map(d=>({id:d.id,name:d.name,closable:!0}))];return t.jsxs("nav",{className:"collab-desktop-tabs","aria-label":"工作页签",children:[u.map(d=>t.jsxs("div",{className:`collab-desktop-tab${i===d.id?" is-active":""}`,children:[t.jsx("button",{type:"button","aria-current":i===d.id?"page":void 0,onClick:()=>o(d.id),children:d.name}),d.closable&&t.jsx("button",{type:"button",className:"collab-desktop-tab-close","aria-label":`关闭${d.name}`,title:`关闭${d.name}页签`,onClick:()=>l(d.id),children:t.jsx(tr,{size:13,"aria-hidden":"true"})})]},d.id)),t.jsx("div",{className:"collab-desktop-tabs-drag-space","aria-hidden":"true"})]})}const Yo=4,Rb=4e6,Nb=8,Tb=.12;function Ab(e,n,r=Tb){if(n<=0)return[];const s=Array.from({length:n},(d,g)=>{const h=Number(e[g]);return Number.isFinite(h)&&h>0?h:1}),i=s.reduce((d,g)=>d+g,0),l=s.map(d=>d/i).map(d=>Math.max(d,r)),u=l.reduce((d,g)=>d+g,0);return l.map(d=>d/u)}function _b(e,n,r,s=Nb){if(n<=1||e.width<=0||e.height<=0)return e.width<=0||e.height<=0?[]:[{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}];const i=Math.min(n,6),o=s*(i-1),l=e.width-o;if(l<=0)return[];const u=Ab(r,i),d=[];let g=e.x;for(let h=0;h<i;h+=1){const k=h===i-1?e.x+e.width-g:Math.floor(l*u[h]);d.push({x:Math.round(g),y:Math.round(e.y),width:Math.round(k),height:Math.round(e.height)}),g+=k+s}return d}function Mb({siteId:e,name:n,onSetup:r}){const s=window.agentApi,[i,o]=c.useState(null),[l,u]=c.useState({connected:!1,tabs:[]}),[d,g]=c.useState(""),[h,p]=c.useState(!1),[k,x]=c.useState(Date.now()),[y,S]=c.useState(!0),v=c.useRef(null),w=!l.paused&&l.compatible!==!1&&l.tabs.some(A=>A.siteId===e);c.useEffect(()=>{let A=!1,L=!1,z=!1;s.hubChromeStatus().then(T=>{!A&&!L&&u(T)}),typeof s.hubChromeConversation!="function"?g("请重启 AI Hub 桌面端以启用消息面板"):s.hubChromeConversation(e).then(T=>{!A&&!z&&o(T)});const R=s.onHubChromeEvent(T=>{T.type==="chrome-conversation"&&T.conversation.siteId===e&&(z=!0,o(F=>!F||T.conversation.revision>F.revision?T.conversation:F),g("")),T.type==="chrome-status"&&(L=!0,u(T.status),T.status.tabs.some(F=>F.siteId===e)||(o(null),g(""))),T.type==="chrome-page-error"&&T.siteId===e&&g(T.error)}),N=setInterval(()=>x(Date.now()),1e3);return()=>{A=!0,R(),clearInterval(N)}},[s,e]),c.useLayoutEffect(()=>{y&&v.current&&(v.current.scrollTop=v.current.scrollHeight)},[i==null?void 0:i.revision,y]);const j=w&&!!i&&k-i.receivedAt>6e3,C=l.paused?"Chrome 网页连接已暂停,点击下方按钮即可恢复。":l.connected&&l.compatible===!1?"请从「连接 Chrome」加载新版自动连接扩展。":w?i?i.generating?"正在回复…":i.composerAvailable?"已同步 · 从下方输入框发送消息":"未找到输入框,请在 Chrome 检查页面":"正在读取网页对话…":"在日常 Chrome 中打开并登录此站点,扩展会自动接入;若已暂停,请在扩展中恢复自动连接。";return t.jsxs("div",{"data-aihub-native-pane":e,style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{role:"status",style:{padding:"10px 16px",fontSize:12,lineHeight:1.6,color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:C}),t.jsx("div",{ref:v,onScroll:()=>{const A=v.current;A&&S(A.scrollHeight-A.scrollTop-A.clientHeight<60)},style:{flex:1,minHeight:0,overflow:"auto",padding:"18px 16px",overflowWrap:"anywhere"},children:w?i!=null&&i.messages.length?i.messages.map(A=>t.jsxs("article",{"data-message-id":A.id,style:{marginBottom:24,padding:A.role==="user"?"12px 14px":"0 2px",borderRadius:12,background:A.role==="user"?"var(--bg-deep)":"transparent"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,fontSize:12,color:"var(--text-muted)"},children:[t.jsx("strong",{children:A.role==="user"?"你":n}),t.jsx("button",{className:"ui-icon-button ui-icon-button--auto","aria-label":`复制 ${A.role==="user"?"消息":n+" 回复"}`,style:{padding:"2px 5px",fontSize:11},onClick:()=>{navigator.clipboard.writeText(A.content).catch(()=>g("未能复制,请选择文字复制"))},children:"复制"})]}),t.jsx("div",{style:{fontSize:15,lineHeight:1.8,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:mp(A.content)})]},`${i.conversationId}:${A.id}`)):t.jsx("p",{style:{margin:"32px 0",color:"var(--text-muted)",fontSize:15,lineHeight:1.8},children:"连接后会显示当前网页对话。可以在下方输入消息,也可以在 Chrome 中继续聊天。"}):t.jsxs("div",{style:{display:"grid",gap:14,paddingTop:36,textAlign:"center",justifyItems:"center"},children:[t.jsx("strong",{style:{fontSize:18},children:l.paused?`${n} 已暂停`:`连接 ${n}`}),t.jsx("span",{style:{fontSize:14,color:"var(--text-secondary)",lineHeight:1.7},children:l.paused?"取消 Chrome 的调试提示也会暂停连接,无需重新登录。":"登录态保留在 Chrome,回复会以文字显示在这里。"}),l.paused&&t.jsx("button",{className:"ui-icon-button ui-icon-button--auto",disabled:h,style:{padding:"8px 12px",color:"var(--accent)"},onClick:async()=>{p(!0),g("");try{u(await s.hubChromeResume())}catch(A){g(A instanceof Error?A.message:"恢复连接失败,请检查 Chrome 扩展")}finally{p(!1)}},children:h?"正在恢复…":"恢复全部 Chrome 连接"}),t.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{padding:"8px 12px"},onClick:()=>{s.hubOpenChrome(e).catch(()=>g("无法打开 Chrome,请检查是否已安装"))},children:"登录 / 打开原网页"}),t.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{padding:"8px 12px"},onClick:r,children:"连接设置"})]})}),!y&&t.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{alignSelf:"center",padding:"7px 12px",margin:8},onClick:()=>S(!0),children:"回到最新回复 ↓"}),(d||j)&&t.jsx("div",{role:d?"alert":"status",title:d||"暂未收到网页更新,请检查 Chrome 标签页或扩展连接;不代表 AI 已停止回答",style:{padding:"6px 16px",fontSize:12,lineHeight:1.6,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:d?"var(--danger)":"var(--text-muted)"},children:d||"同步暂未更新"})]})}function Lb({onClose:e}){const n=window.agentApi,[r,s]=c.useState(""),[i,o]=c.useState(!1),[l,u]=c.useState(""),[d,g]=c.useState(!1);c.useEffect(()=>{let p=!0;n.hubChromeStatus().then(x=>{p&&g(x.connected&&x.compatible!==!1)}).catch(()=>{p&&s("暂时无法检测插件连接,请稍后重试")});const k=n.onHubChromeEvent(x=>{x.type==="chrome-status"&&g(x.status.connected&&x.status.compatible!==!1)});return()=>{p=!1,k()}},[n]);const h=async()=>{o(!0),s("");try{const p=await n.hubChromeInstallExtension();u(p.path),s(p.browserOpened?"已打开 Chrome 扩展管理页,插件目录路径已复制。":"未能打开 Chrome。请先安装或打开 Google Chrome,再进入 chrome://extensions;插件目录路径已复制。")}catch{s("未能准备插件,请确认桌面端已启动,稍后重试。")}finally{o(!1)}};return t.jsxs("div",{"data-aihub-chrome-setup":"",style:{flexShrink:0,padding:"12px 18px",background:"var(--bg-elevated)",borderBottom:"1px solid var(--border-subtle)",fontSize:12},children:[t.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:8},children:[t.jsx("strong",{children:"连接日常 Google Chrome"}),t.jsx("span",{role:"status",children:d?"扩展已连接":"等待扩展连接"}),t.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{marginLeft:"auto"},onClick:e,children:"收起"})]}),t.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.7},children:"插件已随桌面端附带,无需另行下载。首次加载需要在 Chrome 中确认;加载后自动连接,连接成功后此引导会自动收起。已安装时刷新 AI Hub 扩展即可更新。"}),t.jsxs("ol",{style:{margin:0,paddingLeft:20,lineHeight:1.9},children:[t.jsx("li",{children:"点击「安装浏览器插件」,在打开的 Chrome 扩展管理页开启「开发者模式」。"}),t.jsx("li",{children:"选择「加载已解压的扩展程序」,选中 ai-hub-chrome-extension 文件夹。macOS 文件选择窗口可按 ⌘⇧G,粘贴已复制的路径并打开。"}),t.jsx("li",{children:"在同一个 Chrome 中完成网站登录,即可回到 AI Hub 查看回复并同步发送。取消 Chrome 顶部的调试提示会暂停连接;在 AI Hub 点击「恢复全部 Chrome 连接」即可继续。"})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:8},children:[t.jsx("button",{type:"button",disabled:i,className:"ui-icon-button ui-icon-button--auto",onClick:()=>void h(),style:{padding:"5px 10px"},children:i?"正在打开…":"安装浏览器插件"}),t.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",onClick:()=>{n.hubChromeRevealExtension().catch(()=>s("未能打开扩展目录"))},style:{padding:"5px 10px"},children:"打开插件文件夹"}),r&&t.jsx("span",{role:"status",children:r})]}),l&&t.jsxs("p",{style:{margin:"8px 0 0",overflowWrap:"anywhere",userSelect:"text"},children:["插件目录:",l]})]})}const zb=["chatgpt","gemini","grok"];function Xo(e){return zb.includes(e)}const Pb=52,rl=30,Db=4;function Wb(e,n){return e.includes(n)?e.length>1?e.filter(r=>r!==n):e:e.length<Db?[...e,n]:e}function $b(e){return(e.trim()[0]||"?").toUpperCase()}function qd(e){try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}}function Bb({onExit:e,conversationId:n}){const r=typeof window<"u"?window.agentApi:void 0,s=typeof(r==null?void 0:r.hubGetConfig)=="function",[i,o]=c.useState([]),[l,u]=c.useState([]),[d,g]=c.useState([]),[h,p]=c.useState(null),[k,x]=c.useState({}),[y,S]=c.useState({}),[v,w]=c.useState({}),[j,C]=c.useState(""),[A,L]=c.useState([]),[z,R]=c.useState(""),[N,T]=c.useState(!1),F=c.useRef(null),O=c.useRef(null),[q,ae]=c.useState(!1),[se,we]=c.useState([]),[Y,K]=c.useState(!1),[Q,Se]=c.useState(!1),[Pe,oe]=c.useState(""),[Ne,at]=c.useState(""),[W,X]=c.useState(!1),[ke,_e]=c.useState([]);c.useEffect(()=>{if(!(r!=null&&r.hubChromeStatus))return;let U=!1,Z=!1;const G=be=>{if(U)return;const Xe=be.connected&&be.compatible!==!1;_e(Xe?be.tabs.map(rr=>rr.siteId):[]),Xe?X(!1):Z||X(!0),Z=!0};r.hubChromeStatus().then(G).catch(()=>{!U&&!Z&&(Z=!0,X(!0))});const J=r.onHubChromeEvent(be=>{be.type==="chrome-status"&&G(be.status)});return()=>{U=!0,J()}},[r]);const Je=c.useRef(null),it=c.useRef(null);c.useRef(0),c.useLayoutEffect(()=>{const U=O.current;U&&(U.style.height="32px",j&&(U.style.height=`${Math.max(32,Math.min(U.scrollHeight,120))}px`))},[j,l.length]);const pt=async U=>{if(!(q||N)){T(!0),R("");try{if(U.length+A.length>Yo)throw new Error(`最多添加 ${Yo} 张图片`);const Z=await Promise.all(U.map(async G=>{if(!/^image\/(png|jpeg|webp)$/.test(G.type))throw new Error("请选择 PNG、JPEG 或 WebP 图片");if(G.size*4/3+32>Rb)throw new Error("单张图片不能超过约 3 MB");return new Promise((J,be)=>{const Xe=new FileReader;Xe.onload=()=>J(String(Xe.result)),Xe.onerror=()=>be(new Error("图片读取失败,请重试")),Xe.readAsDataURL(G)})}));L(G=>[...G,...Z].slice(0,Yo))}catch(Z){R(Z instanceof Error?Z.message:"图片读取失败")}finally{T(!1)}}},Ye=c.useMemo(()=>h?_b(h,l.length,d):[],[h,l.length,d]);c.useEffect(()=>{if(!s||Ye.length===0)return;const U=l.map((Z,G)=>{const J=Ye[G];return{siteId:Z,...n?{conversationId:n}:{},x:J.x,y:J.y+rl,width:J.width,height:Math.max(J.height-rl,0)}});r==null||r.hubSetBounds(U)},[s,r,Ye,l,n]),c.useEffect(()=>{if(s)for(const U of l)r==null||r.hubOpenSite(U,n??void 0)},[s,r,l,n]),c.useEffect(()=>{if(!s)return;const U=Je.current;if(!U)return;const Z=()=>{const be=U.getBoundingClientRect();p(Xe=>Xe&&Math.abs(Xe.x-be.x)<.5&&Math.abs(Xe.y-be.y)<.5&&Math.abs(Xe.width-be.width)<.5&&Math.abs(Xe.height-be.height)<.5?Xe:{x:be.x,y:be.y,width:be.width,height:be.height})},G={current:0},J=new ResizeObserver(()=>{cancelAnimationFrame(G.current),G.current=requestAnimationFrame(Z)});return J.observe(U),Z(),()=>{J.disconnect(),cancelAnimationFrame(G.current)}},[s,Q]),c.useEffect(()=>{if(!Y)return;const U=G=>{var J;(J=it.current)!=null&&J.contains(G.target)||K(!1)},Z=()=>K(!1);return document.addEventListener("pointerdown",U),window.addEventListener("blur",Z),()=>{document.removeEventListener("pointerdown",U),window.removeEventListener("blur",Z)}},[Y]),c.useEffect(()=>{if(!s||!r)return;let U=!1;r.hubGetConfig().then(G=>{U||(o(G.sites),u(J=>J.length>0?J:G.sites.slice(0,1).map(be=>be.id)))});const Z=r.onHubEvent(G=>{G.type==="load-failed"?(x(J=>({...J,[G.siteId]:G.errorCode??-1})),S(J=>({...J,[G.siteId]:!1}))):G.type==="loaded"?(x(J=>{if(!(G.siteId in J))return J;const be={...J};return delete be[G.siteId],be}),S(J=>({...J,[G.siteId]:!1}))):G.type==="loading"?(S(J=>({...J,[G.siteId]:!0})),w(J=>{if(!(G.siteId in J))return J;const be={...J};return delete be[G.siteId],be})):G.type==="google-auth-external"&&w(J=>({...J,[G.siteId]:!0}))});return()=>{U=!0,Z(),r.hubHideAll()}},[s,r]),c.useEffect(()=>{const U=Math.max(l.length,0);g(Z=>Z.length===U?Z:Array.from({length:U},()=>U>0?1/U:0))},[l.length]);const $t=c.useCallback(U=>{u(Z=>Wb(Z,U))},[]),nr=c.useCallback(U=>{x(Z=>{const G={...Z};return delete G[U],G}),r==null||r.hubReload(U,n??void 0),r==null||r.hubOpenSite(U,n??void 0)},[r,n]),Te=c.useCallback(U=>{l.length<=1||(r==null||r.hubCloseSite(U,n??void 0),u(Z=>Z.filter(G=>G!==U)))},[r,l.length,n]),Ue=c.useCallback(async()=>{const U=j.trim();if(!(!U&&A.length===0||!r||q||N||l.length===0)){ae(!0);try{const Z=await r.hubBroadcast(U,l,A),G=Z.map(J=>({...J,at:Date.now()}));we(G),Z.length>0&&Z.every(J=>J.ok)&&(C(""),L([]),R("")),setTimeout(()=>{we(J=>J.filter(be=>!be.ok||Date.now()-be.at<8e3))},8200)}catch(Z){R(Z instanceof Error?Z.message:"发送失败,请重试")}finally{ae(!1)}}},[r,j,A,N,q,l]),lt=c.useCallback(async()=>{if(!r||!qd(Ne))return;const U=Ne.trim(),Z=Pe.trim()||new URL(U).hostname,G={id:`custom-${Math.random().toString(36).slice(2,10)}`,name:Z,url:U,adapter:"generic"},J=await r.hubSetConfig({version:1,sites:[...i,G]});o(J.sites),oe(""),at(""),Se(!1)},[r,Pe,Ne,i]),fr=c.useCallback(async U=>{if(!r||i.length<=1)return;r.hubCloseSite(U,n??void 0);const Z=await r.hubSetConfig({version:1,sites:i.filter(G=>G.id!==U)});o(Z.sites),u(G=>{const J=G.filter(be=>be!==U);return J.length>0?J:Z.sites.slice(0,1).map(be=>be.id)})},[r,i,n]),os=c.useCallback((U,Z)=>{Z.preventDefault();const G=Ye.length,J=G>1?8:0,be=((h==null?void 0:h.width)??0)-J*(G-1);if(be<=0)return;const Xe=Z.clientX,rr=[...d],Yt=Ye[U].width,un=rr[U]+rr[U+1],dt=ut=>{const kn=ut.clientX-Xe,hr=80,Mr=un*be,Ut=Math.min(Math.max(Yt+kn,hr),Mr-hr),Nt=[...rr];Nt[U]=Ut/be,Nt[U+1]=(Mr-Ut)/be,g(Nt)},gr=()=>{window.removeEventListener("pointermove",dt),window.removeEventListener("pointerup",gr)};window.addEventListener("pointermove",dt),window.addEventListener("pointerup",gr)},[d,Ye,h]);return s?t.jsxs("div",{style:{position:"absolute",inset:0,zIndex:30,display:"flex",flexDirection:"column",background:"var(--bg-workspace)"},children:[t.jsxs("div",{className:"aihub-topbar",style:{height:Pb,display:"flex",alignItems:"center",gap:10,padding:"0 14px",borderBottom:"1px solid var(--border-subtle)",WebkitAppRegion:"drag"},children:[t.jsx("button",{type:"button",onClick:e,title:"返回会话列表","aria-label":"返回会话列表",className:"ui-icon-button",style:{WebkitAppRegion:"no-drag",width:34,height:34,flexShrink:0},children:t.jsx(xu,{size:18,"aria-hidden":"true"})}),t.jsx("strong",{style:{fontSize:14,color:"var(--text-secondary)"},children:"AI Hub"}),t.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",onClick:()=>X(U=>!U),style:{WebkitAppRegion:"no-drag",marginLeft:"auto",padding:"5px 10px"},children:"连接 Chrome"})]}),W&&t.jsx(Lb,{onClose:()=>X(!1)}),t.jsxs("div",{ref:Je,style:{flex:1,position:"relative",overflow:"hidden",minHeight:0},children:[Ye.map((U,Z)=>{const G=l[Z],J=i.find(Xe=>Xe.id===G),be=G in k;return t.jsxs("div",{"data-aihub-pane":G,style:{position:"absolute",left:U.x-((h==null?void 0:h.x)??0),top:U.y-((h==null?void 0:h.y)??0),width:U.width,height:U.height,display:"flex",flexDirection:"column",borderRight:Z<Ye.length-1?"1px solid var(--border-subtle)":void 0},children:[t.jsxs("div",{style:{height:rl,display:"flex",alignItems:"center",gap:6,padding:"0 8px",borderBottom:"1px solid var(--border-subtle)",fontSize:12,color:"var(--text-secondary)"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:8,height:8,borderRadius:"50%",background:Xo(G)?ke.includes(G)?"var(--success)":"var(--text-muted)":be?"#f7768e":y[G]?"var(--accent-glow)":"#9ece6a",flexShrink:0}}),t.jsx("span",{style:{flex:1,minWidth:40,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(J==null?void 0:J.name)??G}),v[G]&&t.jsx("span",{title:"Google 登录已在系统浏览器打开,登录状态不会同步回 AI Hub。如需继续内嵌使用,请选择邮箱登录。","aria-label":"Google 登录受限",style:{flexShrink:0,fontSize:10,padding:"1px 6px",borderRadius:999,color:"#f7768e",border:"1px solid currentColor",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:180},children:"Google 登录已转至浏览器,内嵌请用邮箱"}),Xo(G)&&t.jsx("button",{type:"button","aria-label":`打开 ${(J==null?void 0:J.name)??G} Chrome 页面`,title:"在日常 Chrome 中登录或查看页面",className:"ui-icon-button ui-icon-button--auto",onClick:()=>{r.hubOpenChrome(G).catch(()=>X(!0))},style:{padding:"2px 6px",fontSize:11},children:"Chrome ↗"}),t.jsx("button",{type:"button",title:"刷新","aria-label":`刷新 ${(J==null?void 0:J.name)??G}`,onClick:()=>nr(G),className:"ui-icon-button",style:{padding:2},children:"⟳"}),l.length>1&&t.jsx("button",{type:"button",title:"关闭页面","aria-label":`关闭 ${(J==null?void 0:J.name)??G}`,onClick:()=>Te(G),className:"ui-icon-button",style:{padding:2},children:"×"})]}),t.jsxs("div",{style:{flex:1,position:"relative",background:"var(--bg-surface)"},children:[Xo(G)&&t.jsx(Mb,{siteId:G,name:(J==null?void 0:J.name)??G,onSetup:()=>X(!0)}),!Xo(G)&&be&&t.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:t.jsxs("div",{style:{textAlign:"center",display:"grid",gap:10,color:"var(--text-muted)",fontSize:12},children:[t.jsxs("span",{children:["页面加载失败(",k[G],")"]}),t.jsx("button",{type:"button",onClick:()=>nr(G),className:"ui-icon-button ui-icon-button--auto",style:{justifySelf:"center",padding:"5px 12px"},children:"重试"})]})})]}),Z<Ye.length-1&&t.jsx("div",{"data-aihub-divider":Z,onPointerDown:Xe=>os(Z,Xe),title:"拖动调整宽度",style:{position:"absolute",top:0,bottom:0,right:-5,width:10,cursor:"col-resize",zIndex:5}})]},G)}),Ye.length===0&&t.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center",color:"var(--text-muted)",fontSize:13},children:"从输入框选择一个 AI 站点"})]}),t.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",padding:"8px 12px 10px",display:"flex",flexDirection:"column",gap:8,background:"var(--bg-surface)"},children:[t.jsxs("div",{ref:it,style:{position:"relative",display:"flex",flexDirection:"column",gap:8},children:[Y&&t.jsxs("div",{role:"listbox","aria-label":"选择要发送的 AI 站点","data-aihub-site-picker":"",style:{width:"min(320px, 100%)",maxHeight:280,overflowY:"auto",padding:4,border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-workspace)",boxShadow:"0 -8px 24px rgba(0, 0, 0, 0.12)"},children:[i.map(U=>{const Z=l.includes(U.id),G=U.id.startsWith("custom-");return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsxs("button",{type:"button",role:"option","aria-selected":Z,onClick:()=>$t(U.id),style:{minWidth:0,flex:1,display:"flex",alignItems:"center",gap:8,padding:"8px 9px",border:0,borderRadius:6,background:Z?"var(--bg-glass)":"transparent",color:"var(--text-secondary)",cursor:"pointer",textAlign:"left"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:20,height:20,display:"grid",placeItems:"center",borderRadius:"50%",border:`1px solid ${Z?"var(--accent)":"var(--border-default)"}`,background:Z?"var(--accent)":"transparent",color:Z?"var(--bg-workspace)":"transparent",flexShrink:0},children:t.jsx(er,{size:13,strokeWidth:2.5})}),t.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"grid",placeItems:"center",borderRadius:6,background:"var(--accent-glow)",fontSize:12,fontWeight:600,flexShrink:0},children:$b(U.name)}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13},children:U.name})]}),G&&t.jsx("button",{type:"button",title:`删除站点 ${U.name}`,"aria-label":`删除站点 ${U.name}`,onClick:()=>void fr(U.id),className:"ui-icon-button",style:{width:30,height:30,padding:0,flexShrink:0},children:t.jsx(Bs,{size:14,"aria-hidden":"true"})})]},U.id)}),t.jsx("div",{style:{height:1,margin:"4px 6px",background:"var(--border-subtle)"}}),Q?t.jsxs("div",{style:{display:"grid",gap:6,padding:6},children:[t.jsx("input",{value:Pe,onChange:U=>oe(U.target.value),placeholder:"名称(可选)",style:{minWidth:0,padding:"7px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-secondary)",fontSize:12}}),t.jsx("input",{value:Ne,onChange:U=>at(U.target.value),placeholder:"https://...",style:{minWidth:0,padding:"7px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-secondary)",fontSize:12}}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{type:"button",onClick:()=>void lt(),disabled:!qd(Ne),className:"ui-icon-button ui-icon-button--auto",style:{padding:"5px 10px",fontSize:12},children:"添加"}),t.jsx("button",{type:"button",onClick:()=>Se(!1),className:"ui-icon-button ui-icon-button--auto",style:{padding:"5px 10px",fontSize:12},children:"取消"})]})]}):t.jsxs("button",{type:"button",onClick:()=>Se(!0),className:"ui-icon-button ui-icon-button--auto",style:{width:"100%",justifyContent:"flex-start",gap:7,padding:"7px 9px",fontSize:12},children:[t.jsx(gl,{size:14,"aria-hidden":"true"}),"添加站点"]})]}),t.jsxs("div",{"data-aihub-composer":"",style:{display:"flex",alignItems:"center",gap:8,minHeight:48,padding:"6px 8px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-workspace)"},children:[t.jsxs("button",{type:"button",onClick:()=>K(U=>!U),"aria-haspopup":"listbox","aria-expanded":Y,"aria-label":"选择 AI 站点",title:"选择 AI 站点",className:"ui-icon-button ui-icon-button--auto",style:{height:34,gap:5,padding:"0 10px",fontSize:12,whiteSpace:"nowrap",flexShrink:0},children:[l.length," 个 AI",t.jsx(ua,{size:14,"aria-hidden":"true",style:{transform:Y?"rotate(180deg)":void 0}})]}),t.jsx("input",{ref:F,type:"file",accept:"image/png,image/jpeg,image/webp",multiple:!0,hidden:!0,onChange:U=>{const Z=Array.from(U.target.files??[]);U.target.value="",pt(Z)}}),t.jsx("button",{type:"button","aria-label":"添加图片附件",title:"添加图片附件(也可粘贴截图)",disabled:q||N||A.length>=Yo,onClick:()=>{var U;return(U=F.current)==null?void 0:U.click()},className:"ui-icon-button",style:{width:34,height:34,padding:0,flexShrink:0},children:t.jsx(bu,{size:17,"aria-hidden":"true"})}),t.jsx("textarea",{ref:O,"aria-label":"发送给选中的 AI",disabled:q,value:j,onChange:U=>C(U.target.value),onPaste:U=>{const Z=Array.from(U.clipboardData.files);Z.length!==0&&(U.preventDefault(),pt(Z))},onKeyDown:U=>{U.nativeEvent.isComposing||U.nativeEvent.keyCode===229||(U.key==="Enter"&&(!U.shiftKey||U.metaKey||U.ctrlKey)?(U.preventDefault(),Ue()):U.key==="Escape"&&Y&&(U.preventDefault(),K(!1)))},rows:1,placeholder:`一次输入,发到 ${l.length} 个选中的 AI(Enter 发送,Shift+Enter 换行)`,style:{flex:1,minWidth:0,height:32,minHeight:32,maxHeight:120,boxSizing:"border-box",resize:"none",padding:"4px 2px",border:0,outline:"none",boxShadow:"none",background:"transparent",color:"var(--text-primary)",fontSize:13,lineHeight:1.5,textAlign:j?"left":"center"}}),t.jsx("button",{type:"button",onClick:()=>void Ue(),disabled:!j.trim()&&A.length===0||q||N||l.length===0,title:"同步发送(Enter)","aria-label":"同步发送",className:"ui-icon-button",style:{width:36,height:36,padding:0,borderRadius:"50%",background:(j.trim()||A.length>0)&&!q?"var(--accent)":"var(--bg-glass)",color:(j.trim()||A.length>0)&&!q?"var(--bg-workspace)":"var(--text-muted)",flexShrink:0},children:t.jsx(sg,{size:16,"aria-hidden":"true"})})]})]}),A.length>0&&t.jsx("div",{"aria-label":"待发送图片",style:{display:"flex",gap:8,flexWrap:"wrap"},children:A.map((U,Z)=>t.jsxs("div",{style:{position:"relative",width:56,height:56},children:[t.jsx("img",{src:U,alt:`附件 ${Z+1}`,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:6}}),t.jsx("button",{type:"button","aria-label":`移除附件 ${Z+1}`,disabled:q,onClick:()=>L(G=>G.filter((J,be)=>be!==Z)),className:"ui-icon-button",style:{position:"absolute",top:0,right:0,padding:2,background:"var(--bg-workspace)"},children:t.jsx(tr,{size:12})})]},`${Z}-${U.length}`))}),z&&t.jsx("div",{role:"alert",style:{fontSize:12,color:"var(--text-secondary)",textAlign:"center"},children:z}),se.length>0&&t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center",minHeight:18},children:se.map(U=>{var Z;return t.jsx("span",{role:"status",style:{fontSize:11,padding:"3px 10px",borderRadius:999,color:U.ok?"#9ece6a":"#f7768e",background:"var(--bg-glass)",whiteSpace:"normal",overflowWrap:"anywhere"},children:(((Z=i.find(G=>G.id===U.siteId))==null?void 0:Z.name)??U.siteId)+(U.ok?" ✓":` ✕ ${U.reason??"失败"}`)},U.siteId)})})]})]}):t.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center",background:"var(--bg-workspace)",zIndex:30},children:t.jsxs("div",{style:{textAlign:"center",color:"var(--text-muted)",fontSize:13,display:"grid",gap:12},children:[t.jsx("span",{children:"AI Hub 仅在桌面端可用"}),t.jsx("button",{type:"button",onClick:e,className:"ui-icon-button ui-icon-button--auto",style:{justifySelf:"center",padding:"6px 14px"},children:"返回"})]})})}const jp=new Set(["downloading","installing","reconnecting"]),Ob=new Set(["checking",...jp]),Fb=6e3,qb=24e3;function Ub(){const[e,n]=c.useState(null),[r,s]=c.useState(()=>sessionStorage.getItem("agentroam.dismissed-update"));if(c.useEffect(()=>{var y;let h=!0;const p=window.agentApi,k=((y=p.onUpdateStatus)==null?void 0:y.call(p,S=>{h&&n(S)}))??(()=>{});p.getUpdateStatus().then(S=>{h&&n(S)}).catch(()=>{});const x=window.setTimeout(()=>{p.checkForUpdate().then(S=>{h&&n(S)}).catch(()=>{})},Fb+Math.floor(Math.random()*(qb+1)));return()=>{h=!1,window.clearTimeout(x),k()}},[]),c.useEffect(()=>{if(!e||!Ob.has(e.phase))return;const h=window.setInterval(()=>{window.agentApi.getUpdateStatus().then(n).catch(()=>{})},1500);return()=>window.clearInterval(h)},[e==null?void 0:e.phase]),!e||["idle","checking","up-to-date","unavailable"].includes(e.phase)||e.phase==="available"&&e.targetVersion===r)return null;const i=jp.has(e.phase),o=e.phase==="failed",l=e.phase==="complete",u=i?e.phase==="downloading"?`正在下载${e.progress!==void 0?` ${e.progress}%`:""}`:e.phase==="installing"?"正在安装":"正在重连":o?"更新失败,重试":l?e.message??"更新已就绪":`发现 AgentRoam ${e.targetVersion}`,d=async()=>{try{n(await window.agentApi.installUpdate())}catch(h){n({...e,phase:"failed",message:h instanceof Error?h.message:"更新失败"})}},g=()=>{e.targetVersion&&(sessionStorage.setItem("agentroam.dismissed-update",e.targetVersion),s(e.targetVersion))};return t.jsxs("aside",{className:`update-notice${o?" update-notice--failed":""}`,"aria-live":"polite",children:[t.jsxs("div",{className:"update-notice__content",children:[t.jsx("strong",{children:u}),!i&&!l&&t.jsx("span",{children:"点击后才会下载安装文件"}),o&&e.message&&t.jsx("span",{children:e.message})]}),!i&&!l&&t.jsxs("button",{className:"update-notice__action",type:"button",onClick:()=>void d(),title:o?"重试更新":"下载更新",children:[o?t.jsx(go,{size:16}):t.jsx(gu,{size:16}),t.jsx("span",{children:o?"重试":"更新"})]}),!i&&t.jsx("button",{className:"update-notice__close",type:"button",onClick:g,title:"关闭更新提醒","aria-label":"关闭更新提醒",children:t.jsx(tr,{size:16})})]})}function Hb(){const[e,n]=c.useState(null);c.useEffect(()=>{const o=window.agentApi;if(!(o!=null&&o.desktopLiveGetStatus)||!(o!=null&&o.onDesktopLiveStatus))return;let l=!0;o.desktopLiveGetStatus().then(d=>{l&&n(d)}).catch(()=>{});const u=o.onDesktopLiveStatus(d=>n(d));return()=>{l=!1,u()}},[]);const r=e==null?void 0:e.controlState;if(!((e==null?void 0:e.enabled)&&r!==null&&r!==void 0&&r!=="agent-controlled"))return null;const i=r==="return-requested"||r==="resyncing";return t.jsxs("div",{className:"desktop-live-control-banner",role:"status",style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 10px)",left:"50%",transform:"translateX(-50%)",zIndex:1300,display:"flex",alignItems:"center",gap:8,padding:"7px 14px",borderRadius:999,border:"1px solid rgba(251,191,36,0.45)",background:"rgba(69,49,10,0.92)",color:"#fcd34d",fontSize:13,fontWeight:600,backdropFilter:"blur(8px)",pointerEvents:"none"},children:[t.jsx("span",{"aria-hidden":"true",children:"●"}),i?"正在结束远程控制":"正在被远程控制"]})}function Zl(e,n){return e.map((r,s)=>({session:r,index:s})).sort((r,s)=>n(r.session,s.session)||r.index-s.index).map(({session:r})=>r)}function Gb(e){return Zl(e,(n,r)=>r.created.localeCompare(n.created))}function El(e,n){return n==="codex"?[...e]:Gb(e)}function Rl(e,n){return Zl(e,(r,s)=>Number(n(s))-Number(n(r)))}function Vb(e,n){return Zl(e,(r,s)=>Number(n(s))-Number(n(r)))}const sl={projectId:null,sessionId:null};function Nl(e){return typeof e=="string"&&e.trim()?e.trim():null}function Zo(e){return{projectId:Nl(e),sessionId:null}}function il(e,n){return{projectId:Nl(e),sessionId:Nl(n)}}function Qb(e){return e.agentType==="customer-agent"?`确定永久删除会话“${e.title}”吗?此操作不可恢复。`:e.agentType==="codex"?`确定归档 Codex 会话“${e.title}”并从 AgentRoam 中移除吗?可在 Codex 的已归档会话中恢复。`:`确定从 AgentRoam 中移除会话“${e.title}”吗?原生客户端中的历史记录会保留。`}function Kb(e,n){const r=new Set(n);return{...e,selectedSessionId:e.selectedSessionId&&r.has(e.selectedSessionId)?null:e.selectedSessionId,sessions:Object.fromEntries(Object.entries(e.sessions).map(([s,i])=>[s,{...i,data:i.data.filter(o=>!r.has(o.id))}]))}}function Jb(e,n){const r=new Set(n);let s=!1;const i=Object.fromEntries(Object.entries(e).map(([o,l])=>{const u=l.filter(d=>!r.has(d.id));return u.length!==l.length&&(s=!0),[o,u.length===l.length?l:u]}));return s?i:e}function Yb(e,n,r,s){const i=[s,...(n[s]??[]).map(u=>u.id)],o=new Set(i),l=Object.fromEntries(Object.entries(n).flatMap(([u,d])=>{if(o.has(u))return[];const g=d.filter(h=>!o.has(h.id));return[[u,g.length===d.length?d:g]]}));return{sessionsByProject:Jb(e,i),childSessionsByParent:l,otherLocalSessions:r.filter(u=>!o.has(u.id)),removedIds:i}}function Xb(e){if(!e.trim())return null;const n=Number(e);return Number.isSafeInteger(n)&&n>=0?n:null}const Zb=()=>({id:"",name:"",enabled:!0,allowedTools:[],filesystem:{readRoots:[],writeRoots:[],followSymlinks:!1},commands:{mode:"deny",programs:[],inheritedEnvironment:[]},network:"deny",limits:{timeoutMs:12e4,maxOutputBytes:1048576}});function ey({onNotice:e}){const[n,r]=c.useState([]),[s,i]=c.useState([]),[o,l]=c.useState(null),[u,d]=c.useState(!1),g=c.useMemo(()=>[...s].sort(),[s]),h=async()=>{var y;if(!((y=window.agentApi)!=null&&y.listToolPolicies))return;const x=await window.agentApi.listToolPolicies();r(x.policies),i(x.tools)};c.useEffect(()=>{h().catch(x=>e(String(x),"error"))},[]);const p=async()=>{var x;if(!(!o||!((x=window.agentApi)!=null&&x.saveToolPolicy)))try{await window.agentApi.saveToolPolicy(o,u),await h(),l(null),e("工具策略已保存","success")}catch(y){e(y instanceof Error?y.message:"工具策略保存失败","error")}},k=async x=>{var y;if((y=window.agentApi)!=null&&y.deleteToolPolicy)try{await window.agentApi.deleteToolPolicy(x),await h(),(o==null?void 0:o.id)===x&&l(null),e("工具策略已删除","success")}catch(S){e(S instanceof Error?S.message:"工具策略删除失败","error")}};return t.jsxs("section",{className:"tool-policy-manager",children:[t.jsxs("div",{className:"settings-head-row",children:[t.jsx("h3",{children:"工具执行策略"}),t.jsx("button",{type:"button",className:"tool-policy-button",onClick:()=>{l(Zb()),d(!1)},children:"+ 添加"})]}),t.jsxs("div",{className:"tool-policy-list",children:[n.map(x=>t.jsxs("div",{className:"tool-policy-row",children:[t.jsxs("div",{children:[t.jsx("strong",{children:x.name}),t.jsxs("small",{children:[x.id," · ",x.enabled?"已启用":"已停用"]})]}),t.jsxs("div",{className:"tool-policy-actions",children:[t.jsx("button",{type:"button",onClick:()=>{l(structuredClone(x)),d(!0)},children:"编辑"}),t.jsx("button",{type:"button",className:"is-danger",onClick:()=>void k(x.id),children:"删除"})]})]},x.id)),n.length===0&&t.jsx("div",{className:"tool-policy-empty",children:"暂无工具执行策略"})]}),o&&t.jsxs("div",{className:"tool-policy-form",children:[t.jsxs("div",{className:"tool-policy-grid two",children:[t.jsx(Ft,{label:"策略 ID",children:t.jsx("input",{value:o.id,disabled:u,onChange:x=>l({...o,id:x.target.value})})}),t.jsx(Ft,{label:"名称",children:t.jsx("input",{value:o.name,onChange:x=>l({...o,name:x.target.value})})})]}),t.jsxs("label",{className:"tool-policy-check",children:[t.jsx("input",{type:"checkbox",checked:o.enabled,onChange:x=>l({...o,enabled:x.target.checked})}),"启用"]}),t.jsx(Ft,{label:"允许的工具",children:t.jsx("div",{className:"tool-policy-tools",children:g.map(x=>t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:o.allowedTools.includes(x),onChange:()=>l({...o,allowedTools:ny(o.allowedTools,x)})}),x]},x))})}),t.jsxs("div",{className:"tool-policy-grid two",children:[t.jsx(Ft,{label:"只读根目录(每行一个)",children:t.jsx("textarea",{value:o.filesystem.readRoots.join(`
|
|
173
|
+
`),onChange:x=>l({...o,filesystem:{...o.filesystem,readRoots:Ud(x.target.value)}})})}),t.jsx(Ft,{label:"可写根目录(每行一个)",children:t.jsx("textarea",{value:o.filesystem.writeRoots.join(`
|
|
174
|
+
`),onChange:x=>l({...o,filesystem:{...o.filesystem,writeRoots:Ud(x.target.value)}})})})]}),t.jsxs("label",{className:"tool-policy-check",children:[t.jsx("input",{type:"checkbox",checked:o.filesystem.followSymlinks,onChange:x=>l({...o,filesystem:{...o.filesystem,followSymlinks:x.target.checked}})}),"允许根目录内符号链接"]}),t.jsxs("div",{className:"tool-policy-grid three",children:[t.jsx(Ft,{label:"命令模式",children:t.jsxs("select",{value:o.commands.mode,onChange:x=>l({...o,commands:{...o.commands,mode:x.target.value}}),children:[t.jsx("option",{value:"deny",children:"禁止"}),t.jsx("option",{value:"allowlist",children:"白名单"}),t.jsx("option",{value:"unrestricted",children:"不限制"})]})}),t.jsx(Ft,{label:"网络模式",children:t.jsxs("select",{value:o.network,onChange:x=>l({...o,network:x.target.value}),children:[t.jsx("option",{value:"deny",children:"禁止"}),t.jsx("option",{value:"read-only",children:"只读"}),t.jsx("option",{value:"allow",children:"允许"})]})}),t.jsx(Ft,{label:"继承环境变量",children:t.jsx("input",{value:o.commands.inheritedEnvironment.join(", "),onChange:x=>l({...o,commands:{...o.commands,inheritedEnvironment:wi(x.target.value)}})})})]}),o.commands.mode==="allowlist"&&t.jsxs("div",{className:"tool-policy-programs",children:[t.jsxs("div",{className:"settings-head-row",children:[t.jsx("h4",{children:"允许的程序"}),t.jsx("button",{type:"button",onClick:()=>l({...o,commands:{...o.commands,programs:[...o.commands.programs,{executable:""}]}}),children:"+ 程序"})]}),o.commands.programs.map((x,y)=>t.jsx(ty,{program:x,onChange:S=>l({...o,commands:{...o.commands,programs:ry(o.commands.programs,y,S)}}),onDelete:()=>l({...o,commands:{...o.commands,programs:o.commands.programs.filter((S,v)=>v!==y)}})},y))]}),t.jsxs("div",{className:"tool-policy-grid two",children:[t.jsx(Ft,{label:"超时(毫秒)",children:t.jsx("input",{type:"number",min:100,max:6e5,value:o.limits.timeoutMs,onChange:x=>l({...o,limits:{...o.limits,timeoutMs:Number(x.target.value)}})})}),t.jsx(Ft,{label:"最大输出(字节)",children:t.jsx("input",{type:"number",min:1024,max:10485760,value:o.limits.maxOutputBytes,onChange:x=>l({...o,limits:{...o.limits,maxOutputBytes:Number(x.target.value)}})})})]}),t.jsxs("div",{className:"tool-policy-actions",children:[t.jsx("button",{type:"button",className:"is-primary",onClick:()=>void p(),children:"保存策略"}),t.jsx("button",{type:"button",onClick:()=>l(null),children:"取消"})]})]})]})}function ty({program:e,onChange:n,onDelete:r}){return t.jsxs("div",{className:"tool-policy-program",children:[t.jsxs("div",{className:"tool-policy-grid two",children:[t.jsx(Ft,{label:"可执行文件",children:t.jsx("input",{value:e.executable,onChange:s=>n({...e,executable:s.target.value})})}),t.jsx(Ft,{label:"子命令",children:t.jsx("input",{value:(e.subcommands??[]).join(", "),onChange:s=>n({...e,subcommands:wi(s.target.value)})})})]}),t.jsxs("div",{className:"tool-policy-grid three",children:[t.jsx(Ft,{label:"允许参数",children:t.jsx("input",{value:(e.allowedFlags??[]).join(", "),onChange:s=>n({...e,allowedFlags:wi(s.target.value)})})}),t.jsx(Ft,{label:"禁止参数",children:t.jsx("input",{value:(e.deniedFlags??[]).join(", "),onChange:s=>n({...e,deniedFlags:wi(s.target.value)})})}),t.jsx(Ft,{label:"路径参数",children:t.jsx("input",{value:(e.pathFlags??[]).join(", "),onChange:s=>n({...e,pathFlags:wi(s.target.value)})})})]}),t.jsxs("div",{className:"tool-policy-program-footer",children:[t.jsx(Ft,{label:"位置路径索引",children:t.jsx("input",{value:(e.positionalPathIndexes??[]).join(", "),onChange:s=>n({...e,positionalPathIndexes:wi(s.target.value).map(Number)})})}),t.jsx("button",{type:"button",className:"is-danger",onClick:r,children:"删除程序"})]})]})}function Ft({label:e,children:n}){return t.jsxs("label",{className:"tool-policy-field",children:[t.jsx("span",{children:e}),n]})}function Ud(e){return e.split(`
|
|
175
|
+
`).map(n=>n.trim()).filter(Boolean)}function wi(e){return e.split(",").map(n=>n.trim()).filter(Boolean)}function ny(e,n){return e.includes(n)?e.filter(r=>r!==n):[...e,n]}function ry(e,n,r){return e.map((s,i)=>i===n?r:s)}const sy=[{value:"anthropic",label:"Anthropic"},{value:"openai",label:"OpenAI"},{value:"deepseek",label:"DeepSeek"},{value:"aihub",label:"AI Hub(网页版)"}],Hd={anthropic:"claude-sonnet-4-6",openai:"gpt-4o",deepseek:"deepseek-chat",aihub:"deepseek"},da={anthropic:120,openai:300,deepseek:300,aihub:240};function Gd(){return{name:"",provider:"anthropic",modelId:"claude-sonnet-4-6",apiKey:"",baseUrl:"",maxOutputTokens:16384,requestTimeoutSeconds:da.anthropic}}function iy(){const{maxIterations:e,contextWindow:n,isConfigured:r,profiles:s,activeProfileId:i,taskNotifications:o,setField:l,loadFromSystem:u,saveToSystem:d,addProfile:g,updateProfile:h,deleteProfile:p,switchActiveProfile:k}=ga(),[x,y]=c.useState(null),[S,v]=c.useState("success"),[w,j]=c.useState(null),[C,A]=c.useState(String(e)),[L,z]=c.useState(String(Math.round((n??100)*1e3)));c.useEffect(()=>{A(String(e))},[e]),c.useEffect(()=>{z(String(Math.round((n??100)*1e3)))},[n]);const[R,N]=c.useState(null),[T,F]=c.useState(!1),[O,q]=c.useState(Gd());c.useEffect(()=>{u()},[]),c.useEffect(()=>{if(!w)return;const oe=window.setTimeout(()=>j(null),w.type==="error"?4e3:2500);return()=>window.clearTimeout(oe)},[w]);const ae=()=>{F(!0),N(null),q(Gd())},se=oe=>{F(!1),N(oe.id),q({name:oe.name,provider:oe.provider,modelId:oe.modelId,apiKey:["managed","__agentroam_stored_secret__"].includes(oe.apiKey)?"":oe.apiKey,baseUrl:oe.baseUrl,maxOutputTokens:oe.maxOutputTokens??16384,requestTimeoutSeconds:oe.requestTimeoutSeconds??da[oe.provider]??300})},we=()=>{N(null),F(!1)},Y=async()=>{const oe=O.provider!=="aihub",Ne=R?s.find(W=>W.id===R):void 0,at=Ne?["managed","__agentroam_stored_secret__"].includes(Ne.apiKey):!1;if(!O.name.trim()||oe&&!O.apiKey.trim()&&!at||!O.modelId.trim()){y(oe?"名称、API Key 和模型 ID 为必填项":"名称和模型 ID(AI Hub 站点 ID)为必填项"),v("error");return}if(O.maxOutputTokens!==void 0&&(!Number.isInteger(O.maxOutputTokens)||O.maxOutputTokens<256||O.maxOutputTokens>131072)){y("单轮最大输出请输入 256 到 131072 之间的整数 tokens"),v("error");return}if(O.requestTimeoutSeconds!==void 0&&(!Number.isInteger(O.requestTimeoutSeconds)||O.requestTimeoutSeconds<30||O.requestTimeoutSeconds>1800)){y("单次请求超时请输入 30 到 1800 之间的整数秒"),v("error");return}try{T?g(O):R&&h(R,O),await d(),N(null),F(!1),y(null),j({message:"模型配置保存成功",type:"success"})}catch(W){j({message:W instanceof Error?W.message:"模型配置保存失败",type:"error"})}},K=async oe=>{p(oe),setTimeout(()=>d(),0)},Q=async oe=>{await k(oe),y("已切换模型"),v("success"),setTimeout(()=>y(null),1500)},Se=async()=>{y(null);const oe=Xb(C);if(oe===null){y("最大迭代次数不能为空,请输入非负整数;0 表示无限制。"),v("error");return}const Ne=Number(L);if(!Number.isInteger(Ne)||Ne<1024||Ne>2e6){y("上下文窗口请输入 1024 到 2000000 之间的整数 tokens,例如 8192。"),v("error");return}l("maxIterations",oe),l("contextWindow",Ne/1e3);try{await d(),y(null),j({message:"设置保存成功",type:"success"})}catch(at){j({message:at instanceof Error?at.message:"设置保存失败",type:"error"})}},Pe=T||R!==null;return t.jsxs("div",{style:{padding:"40px 48px",maxWidth:640,animation:"fadeInUp 0.4s var(--ease-out)"},children:[t.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,marginBottom:8,letterSpacing:"-0.02em"},children:"设置"}),t.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginBottom:36},children:"管理模型提供商和运行参数。工作目录在项目设置中配置。"}),t.jsxs("section",{style:{marginBottom:40},children:[t.jsxs("div",{className:"settings-head-row",style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14},children:[t.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",margin:0},children:"模型提供商"}),t.jsx("button",{onClick:ae,style:ay,children:"+ 添加"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.length===0&&!Pe&&t.jsx("div",{style:{padding:"20px 16px",borderRadius:"var(--radius-sm)",border:"1px dashed var(--border-subtle)",textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"暂无配置,点击「+ 添加」创建第一个模型提供商"}),s.map(oe=>{const Ne=oe.id===i,at=oe.id===R,W=["managed","__agentroam_stored_secret__"].includes(oe.apiKey);return t.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:`1px solid ${Ne?"var(--accent)":"var(--border-default)"}`,background:Ne?"var(--accent-dim)":"var(--bg-surface)",overflow:"hidden",transition:"border-color 0.2s"},children:[t.jsxs("div",{className:"profile-row",style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px"},children:[t.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",padding:"2px 7px",borderRadius:4,background:Ne?"var(--accent)":"var(--bg-deep)",color:Ne?"#fff":"var(--text-muted)",flexShrink:0},children:oe.provider}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:oe.name||oe.modelId}),t.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:oe.modelId})]}),Ne&&t.jsx("span",{style:{fontSize:11,color:"var(--accent)",fontWeight:600,flexShrink:0},children:"● 使用中"}),t.jsxs("div",{className:"profile-row-actions",style:{display:"flex",gap:6,flexShrink:0},children:[!Ne&&t.jsx("button",{onClick:()=>Q(oe.id),style:ol,children:"切换"}),t.jsx("button",{onClick:()=>at?we():se(oe),style:ol,children:at?"收起":"编辑"}),t.jsx("button",{onClick:()=>K(oe.id),style:{...ol,color:"var(--danger)",borderColor:"rgba(244,63,94,0.25)"},children:"删除"})]})]}),at&&t.jsx(Vd,{draft:O,setDraft:q,hasStoredApiKey:W,onSave:Y,onCancel:we})]},oe.id)}),T&&t.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:"1px solid var(--accent)",background:"var(--bg-surface)"},children:[t.jsx("div",{style:{padding:"10px 14px 0",fontSize:13,fontWeight:600,color:"var(--accent)"},children:"新建提供商"}),t.jsx(Vd,{draft:O,setDraft:q,hasStoredApiKey:!1,onSave:Y,onCancel:we})]})]})]}),t.jsxs("section",{children:[t.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},children:"常规"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs(Nr,{label:"最大迭代次数",children:[t.jsx("input",{type:"number",value:C,onChange:oe=>A(oe.target.value),min:0,step:1,style:Tr}),t.jsx("div",{style:{fontSize:12,opacity:.65},children:"输入 0 表示不限制迭代次数。"})]}),t.jsxs(Nr,{label:"上下文窗口(tokens,输入与输出合计)",children:[t.jsx("input",{type:"number",value:L,onChange:oe=>z(oe.target.value),min:1024,max:2e6,step:1,style:Tr}),t.jsx("div",{style:{fontSize:12,opacity:.65},children:"8K 模型填 8192;不能超过模型服务实际启动的上下文大小。"})]})]})]}),t.jsxs("section",{style:{marginTop:40},children:[t.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},children:"任务完成提醒"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[["completionEnabled","任务完成通知"],["soundEnabled","播放提示音"],["notifyWhileForeground","前台运行时也通知"]].map(([oe,Ne])=>t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,color:"var(--text-primary)",fontSize:14},children:[t.jsx("input",{type:"checkbox",checked:o[oe],onChange:at=>l("taskNotifications",{...o,[oe]:at.target.checked})}),Ne]},oe))})]}),t.jsx(ey,{onNotice:(oe,Ne)=>j({message:oe,type:Ne})}),t.jsxs("div",{style:{marginTop:28,display:"flex",gap:14,alignItems:"center"},children:[t.jsx("button",{onClick:Se,style:Sp,children:"保存"}),t.jsx("span",{style:{padding:"7px 14px",borderRadius:"var(--radius-sm)",fontSize:12,fontWeight:500,background:r?"rgba(52,211,153,0.1)":"rgba(255,255,255,0.04)",color:r?"var(--success)":"var(--text-muted)",border:`1px solid ${r?"rgba(52,211,153,0.2)":"var(--border-subtle)"}`},children:r?"● 已连接":"○ 未配置"})]}),x&&t.jsx("div",{style:{marginTop:12,padding:"10px 12px",borderRadius:"var(--radius-sm)",border:S==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:S==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:S==="success"?"var(--success)":"var(--danger)",fontSize:13},children:x}),t.jsx(Fl,{message:(w==null?void 0:w.message)??null,type:(w==null?void 0:w.type)??"success"})]})}function Vd({draft:e,setDraft:n,hasStoredApiKey:r,onSave:s,onCancel:i}){const o=(l,u)=>n(d=>{const g={...d,[l]:u};return l==="provider"&&!d.modelId&&(g.modelId=Hd[u]??""),g});return t.jsxs("div",{style:{padding:"12px 14px 14px",display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[t.jsx(Nr,{label:"名称",children:t.jsx("input",{value:e.name,onChange:l=>o("name",l.target.value),placeholder:"我的 Claude",style:Tr})}),t.jsx(Nr,{label:"提供商",children:t.jsx("select",{value:e.provider,onChange:l=>{const u=l.target.value;n(d=>({...d,provider:u,modelId:Hd[u]??"",requestTimeoutSeconds:da[u]??300}))},style:Tr,children:sy.map(l=>t.jsx("option",{value:l.value,children:l.label},l.value))})})]}),t.jsx(Nr,{label:"模型 ID",children:t.jsx("input",{value:e.modelId,onChange:l=>o("modelId",l.target.value),placeholder:e.provider==="aihub"?"deepseek":"claude-sonnet-4-6",style:Tr})}),t.jsx(Nr,{label:"单轮最大输出(tokens)",children:t.jsx("input",{type:"number",value:e.maxOutputTokens??16384,onChange:l=>n(u=>({...u,maxOutputTokens:Number(l.target.value)})),min:256,max:131072,step:1024,style:Tr})}),t.jsx(Nr,{label:"单次请求超时(秒)",children:t.jsx("input",{type:"number",value:e.requestTimeoutSeconds??da[e.provider]??300,onChange:l=>n(u=>({...u,requestTimeoutSeconds:Number(l.target.value)})),min:30,max:1800,step:30,style:Tr})}),e.provider==="aihub"?t.jsx("div",{style:{padding:"8px 10px",background:"rgba(96,165,250,0.08)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8,fontSize:12,lineHeight:1.6},children:"AI Hub 网页模型来源:模型 ID 填 AI Hub 站点 ID(deepseek / chatgpt / gemini / grok 或自定义站点),无需 API Key。 运行时由桌面端 AI Hub 把上下文模拟人为发送给该站点并抓取回复;支持通过受控 JSON 协议调用 Agent 工具。需要桌面 App 在线且站点已登录。"}):t.jsxs(t.Fragment,{children:[t.jsx(Nr,{label:"API 密钥",children:t.jsx("input",{type:"password",value:e.apiKey,onChange:l=>o("apiKey",l.target.value),placeholder:r?"••••••••••••":"sk-...","aria-label":r?"API 密钥(已保存)":"API 密钥",style:Tr})}),t.jsx(Nr,{label:"接口地址(可选)",children:t.jsx("input",{value:e.baseUrl,onChange:l=>o("baseUrl",l.target.value),placeholder:"https://api.anthropic.com",style:Tr})})]}),t.jsxs("div",{style:{display:"flex",gap:8,marginTop:2},children:[t.jsx("button",{onClick:s,style:Sp,children:"保存"}),t.jsx("button",{onClick:i,style:oy,children:"取消"})]})]})}function Nr({label:e,children:n}){return t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",fontSize:12,color:"var(--text-secondary)",marginBottom:6,fontWeight:500,textTransform:"uppercase",letterSpacing:"0.06em"},children:e}),n]})}const Tr={width:"100%",padding:"9px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",boxSizing:"border-box"},Sp={padding:"11px 28px",borderRadius:"var(--radius-sm)",border:"1px solid transparent",background:"var(--accent)",color:"var(--text-inverse)",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)",boxShadow:"0 2px 16px var(--accent-glow)",transition:"transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out)"},oy={padding:"11px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-secondary)",fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)",whiteSpace:"nowrap",transition:"all 0.15s var(--ease-out)"},ay={padding:"6px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-secondary)",fontSize:13,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)"},ol={padding:"4px 10px",borderRadius:6,border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-muted)",fontSize:12,cursor:"pointer",fontFamily:"var(--font-body)"},ly={fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},Qd={display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"8px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",fontSize:13};function cy({onboarding:e=!1}){const n=typeof window>"u"?void 0:window.agentApi,r=!!(n!=null&&n.desktopLiveGetStatus),[s,i]=c.useState(null),[o,l]=c.useState(!1),[u,d]=c.useState(null),[g,h]=c.useState(!0);c.useEffect(()=>{if(!(n!=null&&n.desktopLiveGetStatus)||!(n!=null&&n.onDesktopLiveStatus))return;let v=!0;n.desktopLiveSetup().then(j=>{v&&(i(j.status),h(j.supported))}).catch(()=>{});const w=n.onDesktopLiveStatus(j=>i(j));return()=>{v=!1,w()}},[n]);const p=async()=>{if(n!=null&&n.desktopLiveRecheck)try{i(await n.desktopLiveRecheck()),d(null)}catch(v){d(v instanceof Error?v.message:String(v))}};c.useEffect(()=>{if(!r||!g)return;let v=!0,w=!1;const j=async()=>{if(!w){w=!0;try{const A=await n.desktopLiveRecheck();v&&i(A)}catch{}finally{w=!1}}};window.addEventListener("focus",j);const C=s!=null&&s.enabled&&(s.permissionScreen!=="granted"||s.accessibilityTrusted!==!0)?window.setInterval(j,3e3):void 0;return()=>{v=!1,window.removeEventListener("focus",j),C&&window.clearInterval(C)}},[n,r,g,s==null?void 0:s.enabled,s==null?void 0:s.permissionScreen,s==null?void 0:s.accessibilityTrusted]);const k=async v=>{if(n){l(!0);try{i(await n.desktopLiveSetEnabled(!0)),await n.desktopLiveOpenPermission(v),d(null)}catch(w){d(w instanceof Error?w.message:String(w))}finally{l(!1)}}};if(!r)return null;const x=async()=>{if(n!=null&&n.desktopLiveSetEnabled){l(!0);try{i(await n.desktopLiveSetEnabled(!(s!=null&&s.enabled))),d(null)}catch(v){d(v instanceof Error?v.message:String(v))}finally{l(!1)}}},y=(s==null?void 0:s.permissionScreen)==="granted",S=(s==null?void 0:s.accessibilityTrusted)===!0;return t.jsxs("section",{className:"desktop-permission-settings",children:[t.jsx("h3",{style:ly,children:e?"设置桌面端权限":"桌面直播与远程控制"}),t.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"0 0 14px",lineHeight:1.6},children:e?"欢迎使用 AgentRoam。请为桌面端开启以下系统权限,完成后手机即可查看电脑画面;允许辅助功能后还可操作鼠标和键盘。":"开启后,已配对手机可查看电脑画面,并在授予辅助功能权限后操作鼠标和键盘。"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[t.jsx("button",{type:"button",onClick:()=>void x(),disabled:o||!g,style:{padding:"7px 16px",borderRadius:"var(--radius-sm)",border:`1px solid ${s!=null&&s.enabled?"rgba(244,63,94,0.35)":"var(--accent)"}`,background:s!=null&&s.enabled?"rgba(244,63,94,0.1)":"var(--accent-dim)",color:s!=null&&s.enabled?"var(--danger)":"var(--accent)",fontSize:13,fontWeight:600,cursor:"pointer"},children:o?"处理中…":s!=null&&s.enabled?e?"暂停手机查看":"关闭桌面直播":e?"开启手机查看":"开启桌面直播"}),(s==null?void 0:s.enabled)&&t.jsx("span",{style:{fontSize:12,color:s.sessionOnline?"var(--success)":"var(--text-muted)"},children:s.sessionOnline?"● 已连接,可从手机查看":"○ 未连接"})]}),!g&&t.jsx("p",{role:"status",children:"当前远程桌面仅支持 macOS,其他桌面功能可正常使用。"}),g&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{className:"desktop-permission-row",style:Qd,children:[t.jsx("span",{children:"屏幕录制(画面采集)"}),t.jsx("span",{style:{color:y?"var(--success)":"var(--danger)",fontWeight:600},children:y?"已授权":"未授权"}),!y&&t.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:o,onClick:()=>void k("screen"),children:"去授权"})]}),t.jsxs("div",{className:"desktop-permission-row",style:Qd,children:[t.jsx("span",{children:"辅助功能(键鼠控制)"}),t.jsx("span",{style:{color:S?"var(--success)":"var(--danger)",fontWeight:600},children:(s==null?void 0:s.accessibilityTrusted)===null?"待检测":S?"已授权":"未授权"}),!S&&t.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:o,onClick:()=>void k("accessibility"),children:"去授权"})]})]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("p",{style:{marginTop:14,fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:"点击对应权限的「去授权」,在系统设置中允许 AgentRoam,返回后自动检测。"}),t.jsxs("details",{className:"desktop-permission-more",children:[t.jsx("summary",{children:"更多操作"}),t.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[t.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void p(),children:"重新检测"}),!y&&t.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void(n==null?void 0:n.desktopLiveRestart()),children:"重启桌面端"})]})]})]}),u&&t.jsx("p",{role:"alert",style:{color:"var(--danger)"},children:u}),(s==null?void 0:s.error)&&t.jsx("div",{style:{marginTop:10,fontSize:12,color:"var(--danger)"},role:"alert",children:s.error})]})}function dy({onClose:e}){const n=c.useRef(null);return c.useEffect(()=>{var r;(r=n.current)==null||r.showModal()},[]),Wt.createPortal(t.jsx("dialog",{ref:n,"aria-label":"桌面直播与远程控制",onCancel:e,onClick:r=>{r.target===r.currentTarget&&e()},style:{width:"min(680px, calc(100vw - 48px))",maxHeight:"calc(100vh - 48px)",padding:0,margin:"auto",inset:0,overflowY:"auto",color:"var(--text-primary)",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)"},children:t.jsxs("div",{style:{padding:24},children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:t.jsx("button",{type:"button",onClick:e,"aria-label":"关闭桌面直播设置",className:"ui-icon-button ui-icon-button--close",children:"×"})}),t.jsx(cy,{}),t.jsx("div",{className:"desktop-permission-footer",children:t.jsx("button",{type:"button",className:"ui-quiet-button",onClick:e,children:"关闭"})})]})}),document.body)}const al={id:"",name:"",command:"",args:"",url:"",headersRaw:""};function uy(){const[e,n]=c.useState([]),[r,s]=c.useState("stdio"),[i,o]=c.useState(al),[l,u]=c.useState(!1),[d,g]=c.useState({id:!1,command:!1,url:!1}),[h,p]=c.useState({}),[k,x]=c.useState({}),[y,S]=c.useState(new Set),[v,w]=c.useState(null),[j,C]=c.useState(""),[A,L]=c.useState(!1),z=async W=>{var ke;if(!((ke=window.agentApi)!=null&&ke.mcpProbe))return;S(_e=>new Set([..._e,W.id])),x(_e=>{const Je={..._e};return delete Je[W.id],Je});const X=new Promise((_e,Je)=>setTimeout(()=>Je(new Error("连接超时(15s)")),15e3));try{const _e=await Promise.race([window.agentApi.mcpProbe(W),X]);p(Je=>({...Je,[W.id]:_e}))}catch(_e){const Je=_e instanceof Error?_e.message:String(_e);console.warn(`[MCP] probe failed for ${W.id}:`,Je),p(it=>{const pt={...it};return delete pt[W.id],pt}),x(it=>({...it,[W.id]:Je})),(W.transport==="sse"||/401|403|unauthorized|forbidden|需要认证|访问被拒绝/i.test(Je))&&(C(""),w({server:W}))}finally{S(_e=>{const Je=new Set(_e);return Je.delete(W.id),Je})}};c.useEffect(()=>{window.agentApi&&window.agentApi.mcpList().then(W=>{n(W),W.filter(X=>X.enabled!==!1).forEach(X=>z(X))}).catch(console.error)},[]);const[R,N]=c.useState(""),[T,F]=c.useState(""),[O,q]=c.useState(!1),ae=async()=>{F("");let W;try{W=JSON.parse(R.trim());const X=W.mcpServers??W,ke=Object.entries(X);if(ke.length===0){F("未找到任何服务器");return}q(!0);const _e=[];for(const[it,pt]of ke){const Ye=pt,$t=Ye.name||it,Te=Ye.disabled!==!0;let Ue;if(Ye.url||Ye.type==="streamableHttp"||Ye.type==="sse"){const lt=Ye.type==="sse"?"sse":"streamableHttp";Ue={id:it,name:$t,transport:lt,url:Ye.url,headers:Ye.headers??{},env:Ye.env??{},enabled:Te}}else Ue={id:it,name:$t,transport:"stdio",command:Ye.command,args:Ye.args??[],env:Ye.env??{},enabled:Te};await window.agentApi.mcpSave(Ue),_e.push(Ue)}const Je=await window.agentApi.mcpList();n(Je),N(""),_e.filter(it=>it.enabled!==!1).forEach(it=>z(it))}catch(X){F(X instanceof Error?X.message:"JSON 解析失败")}finally{q(!1)}},se=()=>i.id.trim()!==""&&i.command.trim()!=="",we=()=>i.id.trim()!==""&&i.url.trim()!=="",Y=W=>{const X={};for(const ke of W.split(`
|
|
176
|
+
`)){const _e=ke.indexOf(":");if(_e<1)continue;const Je=ke.slice(0,_e).trim(),it=ke.slice(_e+1).trim();Je&&(X[Je]=it)}return X},K=async()=>{if(g({id:!0,command:!0,url:!0}),!(r==="stdio"&&!se())&&!((r==="sse"||r==="streamableHttp")&&!we())){u(!0);try{const W=r==="sse"||r==="streamableHttp"?Y(i.headersRaw):{},X=r==="stdio"?{id:i.id,name:i.name||i.id,transport:"stdio",command:i.command,args:i.args.split(" ").filter(Boolean),enabled:!0}:{id:i.id,name:i.name||i.id,transport:r,url:i.url,headers:W,enabled:!0};await window.agentApi.mcpSave(X);const ke=await window.agentApi.mcpList();n(ke),o(al),g({id:!1,command:!1,url:!1}),z(X)}catch(W){console.error("Failed to save MCP server",W)}finally{u(!1)}}},Q=async W=>{await window.agentApi.mcpDelete(W),n(e.filter(X=>X.id!==W))},Se=async(W,X)=>{await window.agentApi.mcpSetEnabled(W,X),n(e.map(ke=>ke.id===W?{...ke,enabled:X}:ke))},Pe=async()=>{if(!(!v||!j.trim())){L(!0);try{const W=v.server.transport==="streamableHttp"?{...v.server,headers:{...v.server.headers??{},Authorization:`Bearer ${j.trim()}`}}:{...v.server,env:{...v.server.env??{},Authorization:`Bearer ${j.trim()}`}};await window.agentApi.mcpSave(W);const X=await window.agentApi.mcpList();n(X),w(null),C("");const ke=X.find(_e=>_e.id===W.id)??W;z(ke)}finally{L(!1)}}},oe=W=>W==="stdio"?"本地":W==="streamableHttp"?"HTTP":"SSE",Ne=W=>W==="stdio"?"#68d391":W==="streamableHttp"?"#f6ad55":"#63b3ed",at=W=>W==="stdio"?"rgba(154,230,180,0.15)":W==="streamableHttp"?"rgba(246,173,85,0.15)":"rgba(99,179,237,0.15)";return t.jsxs("div",{style:{padding:"40px 48px",maxWidth:660,animation:"fadeInUp 0.4s var(--ease-out)"},children:[t.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,marginBottom:8,letterSpacing:"-0.02em"},children:"MCP 服务器"}),t.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginBottom:32},children:"通过模型上下文协议连接外部工具。"}),t.jsxs("div",{style:{padding:20,background:"var(--bg-glass)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-subtle)",marginBottom:28,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[t.jsx("h3",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",margin:0},children:"添加服务器"}),t.jsx("div",{style:{display:"flex",background:"var(--bg-surface)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",overflow:"hidden"},children:["stdio","sse","streamableHttp"].map(W=>t.jsx("button",{onClick:()=>{s(W),g({id:!1,command:!1,url:!1}),o(X=>({...al,id:X.id,name:X.name}))},style:{padding:"5px 14px",border:"none",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)",transition:"background 0.15s",background:r===W?"var(--accent)":"transparent",color:r===W?"var(--text-inverse)":"var(--text-muted)"},children:W==="stdio"?"本地 stdio":W==="sse"?"远程 SSE":"HTTP"},W))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[t.jsx("input",{value:i.id,onChange:W=>o(X=>({...X,id:W.target.value})),onBlur:()=>g(W=>({...W,id:!0})),placeholder:"服务器 ID *",style:{...es,...d.id&&!i.id?ll:{}}}),d.id&&!i.id&&t.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:"必填"})]}),t.jsx("input",{value:i.name,onChange:W=>o(X=>({...X,name:W.target.value})),placeholder:"显示名称",style:{...es,flex:1}})]}),r==="stdio"?t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[t.jsx("input",{value:i.command,onChange:W=>o(X=>({...X,command:W.target.value})),onBlur:()=>g(W=>({...W,command:!0})),placeholder:"命令(如 npx)*",style:{...es,...d.command&&!i.command?ll:{}}}),d.command&&!i.command&&t.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:"必填"})]}),t.jsx("input",{value:i.args,onChange:W=>o(X=>({...X,args:W.target.value})),placeholder:"参数(如 -y @anthropic/mcp-server)",style:{...es,flex:2}})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("input",{value:i.url,onChange:W=>o(X=>({...X,url:W.target.value})),onBlur:()=>g(W=>({...W,url:!0})),placeholder:r==="streamableHttp"?"HTTP URL(如 http://host/mcp)*":"SSE URL(如 https://mcp.example.com/sse)*",style:{...es,...d.url&&!i.url?ll:{}}}),d.url&&!i.url&&t.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:"必填"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("label",{style:{fontSize:12,color:"var(--text-muted)"},children:"请求头(每行 key: value)"}),t.jsx("textarea",{value:i.headersRaw,onChange:W=>o(X=>({...X,headersRaw:W.target.value})),placeholder:`access_token: abc123
|
|
177
|
+
Authorization: Bearer sk-...`,rows:3,style:{...es,fontFamily:"var(--font-mono)",fontSize:12,resize:"vertical"}})]})]}),t.jsx("button",{onClick:K,disabled:l,style:{alignSelf:"flex-start",padding:"10px 22px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:l?"not-allowed":"pointer",fontFamily:"var(--font-body)"},children:l?"保存中…":"添加服务器"})]})]}),t.jsxs("div",{style:{marginBottom:28,padding:20,background:"var(--bg-glass)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-subtle)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[t.jsx("h3",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:"导入 JSON 配置"}),t.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",margin:"0 0 10px"},children:"兼容 Claude Desktop / Cursor 格式,粘贴后点导入。"}),t.jsx("textarea",{value:R,onChange:W=>{N(W.target.value),F("")},placeholder:`{
|
|
178
|
+
"my-server": {
|
|
179
|
+
"command": "npx",
|
|
180
|
+
"args": ["-y", "some-mcp"]
|
|
181
|
+
}
|
|
182
|
+
}`,rows:5,style:{...es,width:"100%",boxSizing:"border-box",fontFamily:"var(--font-mono)",fontSize:12,resize:"vertical",marginBottom:8}}),T&&t.jsx("div",{style:{fontSize:12,color:"var(--danger)",marginBottom:8},children:T}),t.jsx("button",{onClick:ae,disabled:!R.trim()||O,style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:R.trim()&&!O?"pointer":"not-allowed",fontFamily:"var(--font-body)",opacity:R.trim()&&!O?1:.5},children:O?"导入中…":"导入"})]}),e.filter(W=>W.transport===r).length===0?t.jsxs("div",{style:{color:"var(--text-muted)",fontSize:14,padding:"40px 0",textAlign:"center"},children:["暂无",r==="stdio"?"本地 stdio":r==="sse"?"远程 SSE":"HTTP"," 服务器,点击上方添加。"]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.filter(W=>W.transport===r).map(W=>t.jsxs("div",{style:{padding:"14px 16px",background:"var(--bg-glass)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",transition:"border-color 0.2s"},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:W.name||W.id}),t.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:at(W.transport),color:Ne(W.transport),fontWeight:600},children:oe(W.transport)})]}),t.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2,fontFamily:"var(--font-mono)"},children:[W.transport==="stdio"?`${W.command} ${(W.args??[]).join(" ")}`:W.url,W.transport!=="stdio"&&W.headers&&Object.keys(W.headers).length>0&&t.jsxs("span",{style:{marginLeft:6,fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-body)"},children:["· ",Object.keys(W.headers).length," 个请求头"]})]}),y.has(W.id)?t.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:6,display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",border:"2px solid var(--accent)",borderTopColor:"transparent",animation:"spin 0.8s linear infinite"}}),"探测工具中…"]}):k[W.id]?t.jsxs("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:k[W.id]}),W.transport==="sse"||/401|403|unauthorized|forbidden|需要认证|访问被拒绝/i.test(k[W.id])?t.jsx("button",{onClick:()=>{C(""),w({server:W})},style:{fontSize:11,padding:"2px 8px",borderRadius:4,border:"1px solid rgba(251,191,36,0.4)",background:"rgba(251,191,36,0.1)",color:"#fbbf24",cursor:"pointer",fontFamily:"var(--font-body)"},children:"输入 Token"}):null,t.jsx("button",{onClick:()=>z(W),style:{fontSize:11,padding:"2px 8px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-body)"},children:"重试"})]}):h[W.id]&&h[W.id].length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:6},children:h[W.id].map(X=>t.jsx("span",{title:X.description,style:{fontSize:11,padding:"2px 8px",borderRadius:10,background:"rgba(168,85,247,0.12)",color:"#c084fc",border:"1px solid rgba(168,85,247,0.2)",fontFamily:"var(--font-mono)",cursor:"default"},children:X.name},X.name))}):h[W.id]!==void 0?t.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:6},children:"无可用工具"}):null]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsxs("label",{style:{fontSize:12,color:"var(--text-muted)",cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[t.jsx("input",{type:"checkbox",checked:W.enabled!==!1,onChange:X=>Se(W.id,X.target.checked),style:{cursor:"pointer"}}),"启用"]}),t.jsx("button",{onClick:()=>Q(W.id),style:{padding:"5px 12px",borderRadius:"var(--radius-sm)",border:"1px solid rgba(248,113,113,0.2)",background:"transparent",color:"var(--danger)",fontSize:12,cursor:"pointer",fontFamily:"var(--font-body)",fontWeight:500,transition:"background 0.15s"},onMouseEnter:X=>{X.currentTarget.style.background="rgba(248,113,113,0.1)"},onMouseLeave:X=>{X.currentTarget.style.background="transparent"},children:"移除"})]})]},W.id))}),v&&t.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},onClick:W=>{W.target===W.currentTarget&&w(null)},children:t.jsxs("div",{style:{width:420,background:"var(--bg-surface)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-default)",padding:28,boxShadow:"0 24px 48px rgba(0,0,0,0.4)"},children:[t.jsx("h3",{style:{margin:"0 0 6px",fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:"需要认证"}),t.jsxs("p",{style:{margin:"0 0 20px",fontSize:13,color:"var(--text-muted)"},children:["服务器 ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:v.server.name||v.server.id})," 返回了 401/403,请输入访问令牌(Bearer Token)。"]}),t.jsx("input",{autoFocus:!0,type:"password",value:j,onChange:W=>C(W.target.value),onKeyDown:W=>{W.key==="Enter"&&Pe(),W.key==="Escape"&&w(null)},placeholder:"sk-… 或 Bearer token",style:{...es,width:"100%",boxSizing:"border-box",marginBottom:16}}),t.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end"},children:[t.jsx("button",{onClick:()=>w(null),style:{padding:"8px 18px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-muted)",fontSize:13,cursor:"pointer",fontFamily:"var(--font-body)"},children:"取消"}),t.jsx("button",{onClick:Pe,disabled:!j.trim()||A,style:{padding:"8px 18px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:j.trim()&&!A?"pointer":"not-allowed",fontFamily:"var(--font-body)",opacity:j.trim()&&!A?1:.5},children:A?"保存中…":"保存并重试"})]})]})}),t.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]})}const es={padding:"10px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"var(--font-body)"},ll={border:"1px solid var(--danger)",boxShadow:"0 0 0 2px rgba(248,113,113,0.15)"};function py(){const[e,n]=c.useState([]),[r,s]=c.useState(""),[i,o]=c.useState(null),[l,u]=c.useState(!1),[d,g]=c.useState(""),[h,p]=c.useState(""),[k,x]=c.useState("user"),[y,S]=c.useState(""),[v,w]=c.useState(null),[j,C]=c.useState("success"),A=async()=>{if(window.agentApi){const N=await window.agentApi.listMemories();n(N)}};c.useEffect(()=>{A()},[]);const L=async()=>{if(!r.trim()){A();return}if(window.agentApi){const N=await window.agentApi.searchMemories(r);n(N.map(T=>T.entry))}},z=async()=>{if(!(!d.trim()||!window.agentApi))try{await window.agentApi.setMemory({name:d.trim(),description:h,type:k,content:y,created:(i==null?void 0:i.created)??new Date().toISOString(),updated:new Date().toISOString()}),u(!1),o(null),g(""),p(""),S(""),x("user"),w("保存成功"),C("success"),await A()}catch(N){w(N instanceof Error?N.message:"保存失败"),C("error")}},R=N=>{o(N),g(N.name),p(N.description),x(N.type),S(N.content),u(!0)};return t.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:24},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,letterSpacing:"-0.02em"},children:"记忆"}),t.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginTop:4},children:"跨会话的持久化知识库。"})]}),t.jsx("button",{onClick:()=>{u(!0),o(null),g(""),p(""),S(""),x("user")},style:{padding:"10px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)"},children:"+ 新建"})]}),t.jsxs("div",{style:{display:"flex",gap:8,marginBottom:24},children:[t.jsx("input",{value:r,onChange:N=>s(N.target.value),onKeyDown:N=>N.key==="Enter"&&L(),placeholder:"搜索记忆...",style:{flex:1,padding:"10px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"}}),t.jsx("button",{onClick:L,style:Kd,children:"搜索"})]}),v&&t.jsx("div",{style:{padding:"10px 12px",borderRadius:"var(--radius-sm)",border:j==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:j==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:j==="success"?"var(--success)":"var(--danger)",fontSize:13,marginBottom:16},children:v}),l&&t.jsxs("div",{style:{padding:20,marginBottom:24,background:"var(--bg-glass)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-subtle)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[t.jsx("input",{value:d,onChange:N=>g(N.target.value),placeholder:"名称",style:{...ea,marginBottom:10},disabled:!!i}),t.jsx("input",{value:h,onChange:N=>p(N.target.value),placeholder:"描述",style:{...ea,marginBottom:10}}),t.jsxs("select",{value:k,onChange:N=>x(N.target.value),style:{...ea,marginBottom:10},children:[t.jsx("option",{value:"user",children:"用户"}),t.jsx("option",{value:"feedback",children:"反馈"}),t.jsx("option",{value:"project",children:"项目"}),t.jsx("option",{value:"reference",children:"参考"})]}),t.jsx("textarea",{value:y,onChange:N=>S(N.target.value),placeholder:"内容",rows:5,style:{...ea,marginBottom:12,resize:"vertical"}}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{onClick:z,style:{padding:"9px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--success)",color:"#000",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)"},children:"保存"}),t.jsx("button",{onClick:()=>u(!1),style:Kd,children:"取消"})]})]}),e.map(N=>t.jsxs("div",{style:{padding:"14px 16px",marginBottom:8,background:"var(--bg-glass)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",transition:"border-color 0.2s"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontSize:14},children:N.name}),t.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:10,background:"rgba(255,255,255,0.04)",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:500},children:N.type})]}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>R(N),style:Jd,children:"编辑"}),t.jsx("button",{onClick:async()=>{if(window.agentApi)try{await window.agentApi.deleteMemory(N.name),w("删除成功"),C("success"),await A()}catch(T){w(T instanceof Error?T.message:"删除失败"),C("error")}},style:{...Jd,color:"var(--danger)"},children:"删除"})]})]}),N.description&&t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:4},children:N.description}),t.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4,lineHeight:1.5},children:[N.content.slice(0,180),N.content.length>180?"…":""]})]},N.name)),e.length===0&&!l&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:14,padding:"60px 0",textAlign:"center"},children:"暂无记忆,点击「新建」创建一条。"})]})}const ea={width:"100%",padding:"11px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",boxSizing:"border-box"},Kd={padding:"10px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-secondary)",fontSize:13,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)"},Jd={padding:"4px 10px",borderRadius:6,fontSize:11,border:"none",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-body)",fontWeight:500},fy=()=>({name:"",description:"",triggers:[],prompt:"",filePath:"",enabled:!0});function gy(){const[e,n]=c.useState([]),[r,s]=c.useState(null),[i,o]=c.useState(!1),[l,u]=c.useState(null),[d,g]=c.useState("success"),[h,p]=c.useState(""),k=(R,N="success")=>{u(R),g(N),setTimeout(()=>u(null),3e3)},x=async()=>{if(!window.agentApi)return;const R=await window.agentApi.listSkills();n(R)};c.useEffect(()=>{x()},[]);const y=R=>{s({...R}),p((R.triggers??[]).join(", ")),o(!1)},S=()=>{s(fy()),p(""),o(!0)},v=()=>{s(null),o(!1)},w=async()=>{if(!r||!window.agentApi)return;if(!r.name.trim()){k("名称不能为空","error");return}const R=h.split(",").map(N=>N.trim()).filter(Boolean);try{await window.agentApi.saveSkill({name:r.name.trim(),description:r.description,triggers:R,prompt:r.prompt,filePath:r.filePath??""}),k(i?"技能已创建":"技能已保存"),s(null),await x()}catch(N){k(N instanceof Error?N.message:"保存失败","error")}},j=async R=>{if(window.agentApi)try{await window.agentApi.deleteSkill(R),k("已删除"),(r==null?void 0:r.name)===R&&s(null),await x()}catch(N){k(N instanceof Error?N.message:"删除失败","error")}},C=async R=>{if(!window.agentApi)return;const N=!R.enabled;await window.agentApi.setSkillEnabled(R.name,N),await x()},A=async()=>{if(window.agentApi)try{const R=await window.agentApi.importSkill();if(!R)return;k(`已导入技能「${R.name}」,本次会话立即生效`),await x()}catch(R){k(R instanceof Error?R.message:"导入失败","error")}},L={width:"100%",padding:"8px 10px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none",boxSizing:"border-box"},z={fontSize:11,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:4,display:"block"};return t.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:24},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:0},children:"技能管理"}),t.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"4px 0 0"},children:"配置触发词和提示词,让 Agent 自动激活专属技能"})]}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{onClick:A,style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:13,fontWeight:600,cursor:"pointer"},children:"↓ 导入技能"}),t.jsx("button",{onClick:S,style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer"},children:"+ 新建技能"})]})]}),l&&t.jsx("div",{style:{marginBottom:16,padding:"8px 12px",borderRadius:"var(--radius-sm)",border:d==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:d==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:d==="success"?"var(--success)":"var(--danger)",fontSize:13},children:l}),r&&t.jsxs("div",{style:{marginBottom:24,padding:"20px 24px",borderRadius:"var(--radius-md)",border:"1px solid var(--border-glow)",background:"var(--bg-glass)"},children:[t.jsx("h3",{style:{margin:"0 0 16px",fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:i?"新建技能":`编辑:${r.name}`}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:z,children:"名称"}),t.jsx("input",{style:L,value:r.name,disabled:!i,onChange:R=>s({...r,name:R.target.value}),placeholder:"技能唯一标识,如 code-review"})]}),t.jsxs("div",{children:[t.jsx("label",{style:z,children:"描述"}),t.jsx("input",{style:L,value:r.description,onChange:R=>s({...r,description:R.target.value}),placeholder:"简短说明这个技能的用途"})]}),t.jsxs("div",{children:[t.jsx("label",{style:z,children:"触发词(逗号分隔)"}),t.jsx("input",{style:L,value:h,onChange:R=>p(R.target.value),placeholder:"代码审查, review, 审查代码"})]}),t.jsxs("div",{children:[t.jsx("label",{style:z,children:"提示词"}),t.jsx("textarea",{style:{...L,minHeight:120,resize:"vertical"},value:r.prompt,onChange:R=>s({...r,prompt:R.target.value}),placeholder:"当触发词匹配时,注入到系统提示的内容..."})]})]}),t.jsxs("div",{style:{display:"flex",gap:8,marginTop:16},children:[t.jsx("button",{onClick:w,style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer"},children:"保存"}),t.jsx("button",{onClick:v,style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:13,cursor:"pointer"},children:"取消"})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.length===0&&!r&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:13,padding:"20px 0",textAlign:"center"},children:"暂无技能,点击「新建技能」创建第一个"}),e.map(R=>{var N;return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:"14px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",background:"var(--bg-glass)",opacity:R.enabled===!1?.5:1},children:[t.jsx("button",{onClick:()=>C(R),title:R.enabled===!1?"已禁用,点击启用":"点击禁用",style:{flexShrink:0,marginTop:2,width:32,height:18,borderRadius:9,border:"none",background:R.enabled===!1?"var(--border-default)":"var(--accent)",cursor:"pointer",position:"relative",transition:"background 0.2s"},children:t.jsx("span",{style:{position:"absolute",top:2,left:R.enabled===!1?2:14,width:14,height:14,borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:2},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:R.name}),((N=R.triggers)==null?void 0:N.length)>0&&t.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["触发词:",R.triggers.slice(0,3).join(" · "),R.triggers.length>3?" ...":""]})]}),R.description&&t.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:R.description}),R.prompt&&t.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",opacity:.7},children:[R.prompt.slice(0,80),R.prompt.length>80?"...":""]})]}),t.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[t.jsx("button",{onClick:()=>y(R),style:{padding:"5px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,cursor:"pointer"},children:"编辑"}),t.jsx("button",{onClick:()=>j(R.name),style:{padding:"5px 12px",borderRadius:"var(--radius-sm)",border:"1px solid rgba(244,63,94,0.3)",background:"transparent",color:"var(--danger)",fontSize:12,cursor:"pointer"},children:"删除"})]})]},R.name)})]})]})}const ta=[{name:"read_file",label:"读取文件"},{name:"write_file",label:"写入文件"},{name:"bash",label:"执行命令"},{name:"web_fetch",label:"网页抓取"},{name:"web_search",label:"网络搜索"},{name:"grep",label:"文件搜索"}];function kp(){return{profileId:"",enabledTools:[],enabledSkills:[],enabledMCPServers:[]}}function hy(){return{name:"",description:"",systemPrompt:"",contextPlaceholders:[],capabilities:kp(),maxIterations:0,isDefault:!1}}const Tl={padding:"5px 12px",borderRadius:7,border:"1px solid var(--border-default)",background:"var(--bg-deep)",color:"var(--text-secondary)",fontSize:12,fontWeight:500,cursor:"pointer"},ao={padding:"3px 9px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-muted)",fontSize:11,cursor:"pointer"},rs={width:"100%",padding:"7px 10px",borderRadius:7,border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,outline:"none",boxSizing:"border-box"},ts={fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:5,display:"block"};function my({ph:e,onChange:n,onDelete:r}){return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.5fr 1fr auto",gap:6,alignItems:"center"},children:[t.jsx("input",{style:rs,placeholder:"变量名 (e.g. project)",value:e.key,onChange:s=>n({...e,key:s.target.value})}),t.jsx("input",{style:rs,placeholder:"说明",value:e.description,onChange:s=>n({...e,description:s.target.value})}),t.jsx("input",{style:rs,placeholder:"默认值",value:e.defaultValue,onChange:s=>n({...e,defaultValue:s.target.value})}),t.jsx("button",{onClick:r,style:{...ao,color:"var(--danger)",borderColor:"rgba(244,63,94,0.25)",flexShrink:0},children:"✕"})]})}function Yd({initial:e,activeAgentId:n,onSave:r,onCancel:s}){const{profiles:i}=ga(),[o,l]=c.useState([]),[u,d]=c.useState([]),[g,h]=c.useState({...hy(),...e,capabilities:{...kp(),...e.capabilities??{}}}),[p,k]=c.useState(null),[x,y]=c.useState(!1);c.useEffect(()=>{var T,F;window.agentApi&&(window.agentApi.listSkills().then(O=>{l(O.filter(q=>q.name))}),(F=(T=window.agentApi).listMCPServers)==null||F.call(T).then(O=>{d(O??[])}).catch(()=>{}))},[]);const S=T=>h(F=>({...F,capabilities:{...F.capabilities,...T}})),v=T=>{const F=g.capabilities.enabledTools;if(F.length===0){const O=ta.map(q=>q.name).filter(q=>q!==T);S({enabledTools:O})}else if(F.includes(T)){const O=F.filter(q=>q!==T);S({enabledTools:O})}else{const O=[...F,T];O.length===ta.length?S({enabledTools:[]}):S({enabledTools:O})}},w=T=>{const F=g.capabilities.enabledSkills;S({enabledSkills:F.includes(T)?F.filter(O=>O!==T):[...F,T]})},j=T=>{const F=g.capabilities.enabledMCPServers;S({enabledMCPServers:F.includes(T)?F.filter(O=>O!==T):[...F,T]})},C=()=>h(T=>({...T,contextPlaceholders:[...T.contextPlaceholders,{key:"",description:"",defaultValue:""}]})),A=(T,F)=>h(O=>{const q=[...O.contextPlaceholders];return q[T]=F,{...O,contextPlaceholders:q}}),L=T=>h(F=>({...F,contextPlaceholders:F.contextPlaceholders.filter((O,q)=>q!==T)})),z=async()=>{if(!g.name.trim()){k("名称为必填项");return}y(!0);try{await r(g)}catch(T){k(T instanceof Error?T.message:"保存失败")}finally{y(!1)}},R=T=>g.capabilities.enabledTools.length===0||g.capabilities.enabledTools.includes(T),N={fontSize:11,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:10,marginTop:22,paddingBottom:5,borderBottom:"1px solid var(--border-subtle)"};return t.jsxs("div",{style:{padding:"24px 28px",background:"transparent",borderTop:"1px solid var(--border-subtle)"},children:[p&&t.jsx("div",{style:{marginBottom:12,padding:"8px 12px",borderRadius:7,background:"rgba(244,63,94,0.08)",border:"1px solid rgba(244,63,94,0.25)",color:"var(--danger)",fontSize:12},children:p}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:ts,children:"名称 *"}),t.jsx("input",{style:rs,value:g.name,onChange:T=>h(F=>({...F,name:T.target.value})),placeholder:"智能体名称"})]}),t.jsxs("div",{children:[t.jsx("label",{style:ts,children:"描述"}),t.jsx("input",{style:rs,value:g.description,onChange:T=>h(F=>({...F,description:T.target.value})),placeholder:"一句话描述"})]})]}),t.jsxs("div",{style:{marginTop:14},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:5},children:[t.jsx("label",{style:{...ts,marginBottom:0},children:"角色设定 / 工作指令"}),t.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)",opacity:.6},children:["支持 ","{{变量名}}"," 占位符"]})]}),t.jsx("textarea",{value:g.systemPrompt,onChange:T=>h(F=>({...F,systemPrompt:T.target.value})),placeholder:`你是一名专业的代码审查助手,请用中文回复所有问题。
|
|
183
|
+
|
|
184
|
+
当前项目:{{project_name}}`,rows:6,style:{...rs,resize:"vertical",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.6}})]}),t.jsx("p",{style:N,children:"上下文占位符"}),g.contextPlaceholders.length>0&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.5fr 1fr auto",gap:6},children:["变量名","说明","默认值",""].map(T=>t.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",letterSpacing:"0.05em"},children:T},T))}),g.contextPlaceholders.map((T,F)=>t.jsx(my,{ph:T,onChange:O=>A(F,O),onDelete:()=>L(F)},F))]}),t.jsx("button",{onClick:C,style:{...ao,color:"var(--accent)",borderColor:"rgba(79,110,247,0.25)"},children:"+ 添加占位符"}),t.jsx("p",{style:N,children:"能力配置"}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsx("label",{style:ts,children:"模型"}),t.jsxs("select",{value:g.capabilities.profileId,onChange:T=>S({profileId:T.target.value}),style:{...rs,cursor:"pointer"},children:[t.jsx("option",{value:"",children:"使用全局活跃模型"}),i.map(T=>t.jsxs("option",{value:T.id,children:[T.name||T.modelId," (",T.provider,")"]},T.id))]})]}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsxs("label",{style:ts,children:["内置工具 ",g.capabilities.enabledTools.length===0?"(全部启用)":`(${g.capabilities.enabledTools.length}/${ta.length})`]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:ta.map(T=>{const F=R(T.name);return t.jsx("button",{onClick:()=>v(T.name),style:{padding:"4px 10px",borderRadius:20,border:F?"1px solid var(--accent)":"1px solid var(--border-subtle)",background:F?"var(--accent-dim)":"transparent",color:F?"var(--accent)":"var(--text-muted)",fontSize:12,cursor:"pointer",transition:"all 0.12s"},children:T.label},T.name)})}),t.jsx("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:5,opacity:.7},children:'点击切换;全选时恢复为"全部启用"'})]}),o.length>0&&t.jsxs("div",{style:{marginBottom:14},children:[t.jsxs("label",{style:ts,children:["技能 ",g.capabilities.enabledSkills.length===0?"(全部)":`(${g.capabilities.enabledSkills.length}/${o.length})`]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:o.map(T=>{const F=g.capabilities.enabledSkills.length===0||g.capabilities.enabledSkills.includes(T.name);return t.jsx("button",{onClick:()=>w(T.name),title:T.description,style:{padding:"4px 10px",borderRadius:20,border:F?"1px solid var(--accent)":"1px solid var(--border-subtle)",background:F?"var(--accent-dim)":"transparent",color:F?"var(--accent)":"var(--text-muted)",fontSize:12,cursor:"pointer",transition:"all 0.12s"},children:T.name},T.name)})})]}),u.length>0&&t.jsxs("div",{style:{marginBottom:14},children:[t.jsxs("label",{style:ts,children:["MCP 服务器 ",g.capabilities.enabledMCPServers.length===0?"(全部)":`(${g.capabilities.enabledMCPServers.length}/${u.length})`]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:u.map(T=>{const F=g.capabilities.enabledMCPServers.length===0||g.capabilities.enabledMCPServers.includes(T.id);return t.jsx("button",{onClick:()=>j(T.id),style:{padding:"4px 10px",borderRadius:20,border:F?"1px solid var(--accent)":"1px solid var(--border-subtle)",background:F?"var(--accent-dim)":"transparent",color:F?"var(--accent)":"var(--text-muted)",fontSize:12,cursor:"pointer",transition:"all 0.12s"},children:T.name},T.id)})})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:ts,children:"最大迭代次数(0 = 全局)"}),t.jsx("input",{type:"number",style:rs,value:g.maxIterations,min:0,max:100,onChange:T=>h(F=>({...F,maxIterations:Number(T.target.value)}))})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end",paddingBottom:2},children:t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:g.isDefault,onChange:T=>h(F=>({...F,isDefault:T.target.checked})),style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),"新会话默认使用此智能体"]})})]}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{onClick:z,disabled:x,style:{...Tl,background:"var(--accent)",color:"#fff",border:"none",fontWeight:600,opacity:x?.6:1},children:x?"保存中…":"保存"}),t.jsx("button",{onClick:s,style:Tl,children:"取消"})]})]})}function xy(){const[e,n]=c.useState([]),[r,s]=c.useState([]),[i,o]=c.useState(null),[l,u]=c.useState(!1),[d,g]=c.useState(null),[h,p]=c.useState("success"),k=(j,C="success")=>{g(j),p(C),setTimeout(()=>g(null),2e3)},x=async()=>{if(!window.agentApi)return;const j=await window.agentApi.listAgentDefs();n(j);const C=await window.agentApi.getSettings();s(C.activeAgentIds??[])};c.useEffect(()=>{x()},[]);const y=async j=>{await window.agentApi.createAgentDef(j),u(!1),k("智能体已创建"),await x()},S=async(j,C)=>{await window.agentApi.updateAgentDef(j,C),o(null),k("保存成功"),await x()},v=async j=>{await window.agentApi.deleteAgentDef(j),i===j&&o(null),k("已删除"),await x()},w=async j=>{const A=(await window.agentApi.setActiveAgentDef(j)).activeAgentIds??[];s(A),k(A.includes(j)?"已激活":"已取消激活")};return t.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[t.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,marginBottom:8,letterSpacing:"-0.02em"},children:"智能体"}),t.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginBottom:28},children:"配置具有自定义角色、工具和模型的智能体,在消息框中按需切换。"}),d&&t.jsx("div",{style:{marginBottom:16,padding:"8px 14px",borderRadius:8,border:h==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:h==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:h==="success"?"var(--success)":"var(--danger)",fontSize:13},children:d}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:14},children:t.jsx("button",{onClick:()=>{u(!0),o(null)},style:{...Tl,background:"var(--accent)",color:"#fff",border:"none",fontWeight:600},children:"+ 新建智能体"})}),l&&t.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",overflow:"hidden",marginBottom:16},children:[t.jsx("div",{style:{padding:"10px 16px",background:"var(--bg-surface)",display:"flex",alignItems:"center",gap:8},children:t.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)"},children:"新建智能体"})}),t.jsx(Yd,{initial:{},activeAgentId:r[0]??"",onSave:y,onCancel:()=>u(!1)})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.length===0&&!l&&t.jsx("div",{style:{padding:"28px 20px",borderRadius:"var(--radius-sm)",border:"1px dashed var(--border-subtle)",textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"暂无智能体配置,点击「新建智能体」开始创建"}),e.map(j=>{const C=r.includes(j.id),A=j.id===i;return t.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:`1px solid ${C?"var(--accent)":"var(--border-default)"}`,background:C?"var(--accent-dim)":"var(--bg-surface)",overflow:"hidden",transition:"border-color 0.2s, background 0.2s"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 16px"},children:[t.jsx("div",{style:{width:34,height:34,borderRadius:8,flexShrink:0,background:C?"var(--accent)":"var(--bg-deep)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:C?"#fff":"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M20 21a8 8 0 1 0-16 0"})]})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:j.name}),C&&t.jsx("span",{style:{fontSize:10,fontWeight:700,color:"var(--accent)",background:"rgba(79,110,247,0.12)",padding:"1px 6px",borderRadius:4,letterSpacing:"0.05em"},children:"激活"}),j.isDefault&&t.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",background:"var(--bg-deep)",padding:"1px 6px",borderRadius:4},children:"默认"})]}),j.description&&t.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.description}),t.jsxs("div",{style:{display:"flex",gap:5,marginTop:5,flexWrap:"wrap"},children:[j.capabilities.profileId&&t.jsx("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"rgba(79,110,247,0.08)",color:"var(--accent)",border:"1px solid rgba(79,110,247,0.15)"},children:"自定义模型"}),j.capabilities.enabledTools.length>0&&t.jsxs("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:[j.capabilities.enabledTools.length," 工具"]}),j.capabilities.enabledSkills.length>0&&t.jsxs("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:[j.capabilities.enabledSkills.length," 技能"]}),j.contextPlaceholders.length>0&&t.jsxs("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:[j.contextPlaceholders.length," 变量"]})]})]}),t.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[t.jsx("button",{onClick:()=>w(j.id),style:{...ao,color:C?"var(--accent)":"var(--text-muted)",borderColor:C?"var(--accent)":"var(--border-default)",background:C?"var(--accent-dim)":"transparent"},children:C?"取消激活":"激活"}),t.jsx("button",{onClick:()=>o(A?null:j.id),style:ao,children:A?"收起":"编辑"}),t.jsx("button",{onClick:()=>v(j.id),style:{...ao,color:"var(--danger)",borderColor:"rgba(244,63,94,0.25)"},children:"删除"})]})]}),A&&t.jsx(Yd,{initial:j,activeAgentId:r[0]??"",onSave:L=>S(j.id,L),onCancel:()=>o(null)})]},j.id)})]})]})}const by=[{label:"TypeScript / JavaScript",language:"typescript",fileTypes:".ts,.tsx,.js,.jsx",command:"typescript-language-server",args:"--stdio"},{label:"Python (pylsp)",language:"python",fileTypes:".py",command:"pylsp",args:""},{label:"Python (pyright)",language:"python",fileTypes:".py",command:"pyright-langserver",args:"--stdio"},{label:"Rust (rust-analyzer)",language:"rust",fileTypes:".rs",command:"rust-analyzer",args:""},{label:"Go (gopls)",language:"go",fileTypes:".go",command:"gopls",args:""},{label:"C/C++ (clangd)",language:"cpp",fileTypes:".c,.cpp,.cc,.h,.hpp",command:"clangd",args:""},{label:"Java (jdtls via brew)",language:"java",fileTypes:".java",command:"jdtls",args:"--data /tmp/jdtls-workspace"}],cl={id:"",name:"",language:"",fileTypes:"",command:"",args:"",envRaw:""};function yy(){const[e,n]=c.useState([]),[r,s]=c.useState(cl),[i,o]=c.useState(!1),[l,u]=c.useState(null),[d,g]=c.useState(null),h=async()=>{var j;if((j=window.agentApi)!=null&&j.lspList)try{const C=await window.agentApi.lspList();n(C)}catch(C){console.error("[LSP] load error",C)}};c.useEffect(()=>{h()},[]);const p=j=>{s(C=>({...C,name:j.label,language:j.language,fileTypes:j.fileTypes,command:j.command,args:j.args}))},k=j=>{u(j.id),s({id:j.id,name:j.name,language:j.language,fileTypes:j.fileTypes.join(","),command:j.command,args:j.args.join(" "),envRaw:j.env?Object.entries(j.env).map(([C,A])=>`${C}=${A}`).join(`
|
|
185
|
+
`):""}),g(null)},x=()=>{u(null),s(cl)},y=async()=>{var z;if(!((z=window.agentApi)!=null&&z.lspSave))return;const j=r.name.trim(),C=r.command.trim();if(!j||!C)return;let A;if(r.envRaw.trim()){A={};for(const R of r.envRaw.split(`
|
|
186
|
+
`)){const N=R.indexOf("=");N>0&&(A[R.slice(0,N).trim()]=R.slice(N+1).trim())}}const L={id:l??crypto.randomUUID(),name:j,language:r.language.trim(),fileTypes:r.fileTypes.split(",").map(R=>R.trim()).filter(Boolean),command:C,args:r.args.trim()?r.args.trim().split(/\s+/):[],env:A,enabled:!0};o(!0);try{await window.agentApi.lspSave(L),await h(),x()}finally{o(!1)}},S=async j=>{var C;(C=window.agentApi)!=null&&C.lspDelete&&confirm("删除此 LSP 服务器配置?")&&(await window.agentApi.lspDelete(j),await h())},v=async j=>{var C;(C=window.agentApi)!=null&&C.lspSetEnabled&&(await window.agentApi.lspSetEnabled(j.id,!j.enabled),await h())},w=l!==null;return w&&l===null||!l&&r.name,t.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:24},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:0},children:"LSP 服务器"}),t.jsxs("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"4px 0 0"},children:["配置 Language Server Protocol 服务器,让 Agent 可通过"," ",t.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:"lsp_diagnostics"}),"、",t.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:"lsp_hover"}),"、",t.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:"lsp_definition"})," ","等工具进行代码分析。"]})]}),!w&&t.jsx("button",{onClick:()=>{u(""),s(cl)},style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer",flexShrink:0},children:"+ 添加服务器"})]}),e.length===0&&!w&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:14,padding:"40px 0",textAlign:"center"},children:"尚未配置任何 LSP 服务器"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:w?24:0},children:e.map(j=>t.jsxs("div",{style:{background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",cursor:"pointer"},onClick:()=>g(d===j.id?null:j.id),children:[t.jsx("div",{onClick:C=>{C.stopPropagation(),v(j)},style:{width:32,height:18,borderRadius:9,background:j.enabled?"var(--success, #34d399)":"var(--border-default)",position:"relative",cursor:"pointer",flexShrink:0,transition:"background 0.2s"},children:t.jsx("div",{style:{position:"absolute",top:2,left:j.enabled?16:2,width:14,height:14,borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontWeight:500,fontSize:13,color:"var(--text-primary)"},children:j.name}),t.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:[j.language,j.fileTypes.length>0?` · ${j.fileTypes.join(", ")}`:""]})]}),t.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono, monospace)",flexShrink:0},children:[j.command,j.args.length?" "+j.args.join(" "):""]}),t.jsx("button",{onClick:C=>{C.stopPropagation(),k(j)},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:13,padding:"2px 8px",fontFamily:"var(--font-body)"},children:"编辑"}),t.jsx("button",{onClick:C=>{C.stopPropagation(),S(j.id)},style:{background:"none",border:"none",cursor:"pointer",color:"var(--danger, #f43f5e)",fontSize:13,padding:"2px 8px",fontFamily:"var(--font-body)"},children:"删除"}),t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2.5",strokeLinecap:"round",style:{flexShrink:0,transition:"transform 0.2s",transform:d===j.id?"rotate(180deg)":"none"},children:t.jsx("path",{d:"M6 9l6 6 6-6"})})]}),d===j.id&&t.jsxs("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-muted)",borderTop:"1px solid var(--border-subtle)",display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{children:[t.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:"命令:"}),t.jsxs("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:[j.command," ",j.args.join(" ")]})]}),j.fileTypes.length>0&&t.jsxs("div",{children:[t.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:"文件类型:"}),j.fileTypes.join(", ")]}),j.env&&Object.keys(j.env).length>0&&t.jsxs("div",{children:[t.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:"环境变量:"}),Object.entries(j.env).map(([C,A])=>`${C}=${A}`).join(", ")]})]})]},j.id))}),w&&t.jsxs("div",{style:{padding:"20px 24px",borderRadius:"var(--radius-md)",border:"1px solid var(--border-glow)",background:"var(--bg-glass)"},children:[t.jsx("h3",{style:{margin:"0 0 16px",fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:l?"编辑 LSP 服务器":"添加 LSP 服务器"}),t.jsxs("div",{style:{marginBottom:16},children:[t.jsx("label",{style:Ws,children:"快速预设"}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:by.map(j=>t.jsx("button",{onClick:()=>p(j),style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",padding:"4px 10px",fontSize:11,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"var(--font-body)"},children:j.label},j.label))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[t.jsxs("div",{children:[t.jsxs("label",{style:Ws,children:["名称 ",t.jsx("span",{style:{color:"var(--danger, #f43f5e)",textTransform:"none"},children:"*"})]}),t.jsx("input",{value:r.name,onChange:j=>s(C=>({...C,name:j.target.value})),placeholder:"TypeScript Language Server",style:vi})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ws,children:"语言"}),t.jsx("input",{value:r.language,onChange:j=>s(C=>({...C,language:j.target.value})),placeholder:"typescript",style:vi})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Ws,children:["文件类型",t.jsx("span",{style:{textTransform:"none",letterSpacing:0,fontWeight:400,marginLeft:6,color:"var(--text-muted)"},children:"逗号分隔,如 .ts,.tsx"})]}),t.jsx("input",{value:r.fileTypes,onChange:j=>s(C=>({...C,fileTypes:j.target.value})),placeholder:".ts,.tsx,.js,.jsx",style:vi})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[t.jsxs("div",{children:[t.jsxs("label",{style:Ws,children:["命令 ",t.jsx("span",{style:{color:"var(--danger, #f43f5e)",textTransform:"none"},children:"*"})]}),t.jsx("input",{value:r.command,onChange:j=>s(C=>({...C,command:j.target.value})),placeholder:"typescript-language-server",style:{...vi,fontFamily:"var(--font-mono, monospace)"}})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Ws,children:["参数",t.jsx("span",{style:{textTransform:"none",letterSpacing:0,fontWeight:400,marginLeft:6,color:"var(--text-muted)"},children:"空格分隔"})]}),t.jsx("input",{value:r.args,onChange:j=>s(C=>({...C,args:j.target.value})),placeholder:"--stdio",style:{...vi,fontFamily:"var(--font-mono, monospace)"}})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Ws,children:["环境变量",t.jsx("span",{style:{textTransform:"none",letterSpacing:0,fontWeight:400,marginLeft:6,color:"var(--text-muted)"},children:"每行 KEY=VALUE"})]}),t.jsx("textarea",{value:r.envRaw,onChange:j=>s(C=>({...C,envRaw:j.target.value})),placeholder:`NODE_ENV=production
|
|
187
|
+
TSPROTOCOL_LOG=verbose`,rows:3,style:{...vi,fontFamily:"var(--font-mono, monospace)",resize:"vertical"}})]}),r.language==="java"&&t.jsxs("div",{style:{background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.3)",borderRadius:"var(--radius-sm)",padding:"10px 14px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.65},children:[t.jsx("strong",{style:{color:"rgba(202,138,4,1)"},children:"Java 提示:"})," ","使用 ",t.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"jdtls"})," 预设需先通过"," ",t.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"brew install jdtls"})," ","安装包装脚本。若手动安装,请将命令改为"," ",t.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"java"}),", 并在参数中填入完整的 JVM 参数和"," ",t.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"-jar .../launcher.jar -data /path/to/workspace"}),"。"]})]}),t.jsxs("div",{style:{display:"flex",gap:8,marginTop:20},children:[t.jsx("button",{onClick:()=>void y(),disabled:i||!r.name.trim()||!r.command.trim(),style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer",opacity:i||!r.name.trim()||!r.command.trim()?.45:1,fontFamily:"var(--font-body)"},children:i?"保存中…":"保存"}),t.jsx("button",{onClick:x,style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)"},children:"取消"})]})]})]})}const vi={width:"100%",padding:"8px 10px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none",boxSizing:"border-box"},Ws={fontSize:11,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:4,display:"block"};function vy({trigger:e,heardText:n}){const[r,s]=c.useState(!1);return c.useEffect(()=>{if(e<=0)return;s(!0);const i=setTimeout(()=>s(!1),2400);return()=>clearTimeout(i)},[e]),r?Wt.createPortal(t.jsxs("div",{style:{position:"fixed",inset:0,zIndex:3e4,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:22,background:"radial-gradient(circle at 50% 50%, var(--accent-glow), transparent 60%)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",animation:"fadeIn 0.3s var(--ease-out)",pointerEvents:"none",WebkitAppRegion:"no-drag"},children:[t.jsxs("div",{style:{position:"relative",width:120,height:120},children:[[0,.45,.9].map(i=>t.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",border:"2px solid var(--accent)",animation:`wakeRing 1.6s ${i}s var(--ease-out) infinite`}},i)),t.jsx("div",{style:{position:"absolute",inset:30,borderRadius:"50%",background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",animation:"wakeCore 1.6s var(--ease-out) infinite"},children:t.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-inverse)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),t.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),t.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})]}),t.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",letterSpacing:"0.12em",animation:"wakeText 0.9s var(--ease-out) both",fontFamily:"var(--font-display)"},children:"已唤醒 · 随时待命"}),n&&t.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",maxWidth:320,textAlign:"center",animation:"fadeIn 0.6s var(--ease-out) 0.3s both"},children:["“",n.slice(0,40),"”"]})]},e),document.body):null}const wy=[{value:"classic",description:"横向切换 Agent,按目录浏览"},{value:"agent-rail",description:"竖向 Agent 栏,聚焦当前工作区"},{value:"all-sessions",description:"汇总所有 Agent 的会话"}],jy=typeof window>"u"?c.useEffect:c.useLayoutEffect;function Sy({value:e}){return t.jsxs("svg",{className:"sidebar-layout-preview",viewBox:"0 0 48 36",fill:"none","aria-hidden":"true",children:[t.jsx("rect",{x:"1",y:"1",width:"46",height:"34",rx:"5",stroke:"currentColor",strokeOpacity:".3"}),e==="classic"?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6 8h16M6 20h13M6 25h10M6 30h12",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"}),[7,13,19,25,31,37].map(n=>t.jsx("rect",{x:n,y:"12",width:"4",height:"4",rx:"1",fill:"currentColor",opacity:".7"},n))]}):e==="agent-rail"?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6 8h28M14 13v21",stroke:"currentColor",strokeOpacity:".3",strokeWidth:"2",strokeLinecap:"round"}),[16,22,28].map(n=>t.jsx("rect",{x:"6",y:n,width:"4",height:"4",rx:"1",fill:"currentColor",opacity:".7"},n)),t.jsx("path",{d:"M20 17h18M20 23h12M20 29h15",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"})]}):t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6 8h22",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"}),[16,22,28].map((n,r)=>t.jsxs("g",{children:[t.jsx("circle",{cx:"7",cy:n,r:"1.5",fill:"currentColor",opacity:".7"}),t.jsx("path",{d:`M12 ${n}h${r===1?18:25}`,stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"})]},n))]})]})}function Ip(){const e=xt(h=>h.navigationLayout),n=xt(h=>h.setNavigationLayout),[r,s]=c.useState(!1),[i,o]=c.useState({top:0,left:0}),l=c.useRef(null),u=c.useRef(null),d=c.useId();jy(()=>{var p,k;if(!r)return;const h=()=>{var v;const x=(v=l.current)==null?void 0:v.getBoundingClientRect();if(!x||!u.current)return;const{offsetWidth:y,offsetHeight:S}=u.current;o({top:Math.max(8,Math.min(x.bottom+8,window.innerHeight-S-8)),left:Math.max(8,Math.min(x.right-y,window.innerWidth-y-8))})};return h(),(k=(p=u.current)==null?void 0:p.querySelector('[aria-checked="true"]'))==null||k.focus(),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[r]),c.useEffect(()=>{if(!r)return;const h=p=>{var x,y;const k=p.target;!((x=l.current)!=null&&x.contains(k))&&!((y=u.current)!=null&&y.contains(k))&&s(!1)};return document.addEventListener("pointerdown",h),()=>document.removeEventListener("pointerdown",h)},[r]);const g=h=>{var y,S,v;h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s(!1),(y=l.current)==null||y.focus());const p=Array.from(((S=u.current)==null?void 0:S.querySelectorAll('[role="menuitemradio"]'))??[]),k=p.indexOf(document.activeElement),x=h.key==="ArrowDown"?(k+1)%p.length:h.key==="ArrowUp"?(k+p.length-1)%p.length:h.key==="Home"?0:h.key==="End"?p.length-1:null;x!==null&&(h.preventDefault(),(v=p[x])==null||v.focus())};return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:l,type:"button",className:"sidebar-layout-trigger","aria-label":"切换侧栏布局",title:`切换布局 · 当前:${Ua[e]}`,"aria-haspopup":"menu","aria-expanded":r,"aria-controls":r?d:void 0,onClick:()=>s(h=>!h),onKeyDown:h=>{(h.key==="ArrowDown"||h.key==="ArrowUp")&&(h.preventDefault(),s(!0))},children:t.jsx(vg,{size:18,"aria-hidden":"true"})}),r&&Wt.createPortal(t.jsxs("div",{ref:u,id:d,role:"menu","aria-label":"侧栏布局",className:"sidebar-layout-menu",style:{position:"fixed",...i},onKeyDown:g,onBlur:h=>{var k;const p=h.relatedTarget;p&&!h.currentTarget.contains(p)&&!((k=l.current)!=null&&k.contains(p))&&s(!1)},children:[t.jsx("div",{className:"sidebar-layout-menu-title","aria-hidden":"true",children:"侧栏布局"}),wy.map(h=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-label":Ua[h.value],"aria-checked":e===h.value,className:"sidebar-layout-option",onClick:()=>{s(!1),n(h.value),requestAnimationFrame(()=>{var p;return(p=document.querySelector(".sidebar-layout-trigger"))==null?void 0:p.focus()})},children:[t.jsx(Sy,{value:h.value}),t.jsxs("span",{className:"sidebar-layout-option-copy",children:[t.jsx("span",{children:Ua[h.value]}),t.jsx("small",{children:h.description})]}),e===h.value&&t.jsx(er,{size:16,"aria-hidden":"true"})]},h.value))]}),document.body)]})}function ky({value:e,health:n,onClose:r}){const s=n.find(l=>l.agentType===e),i=(s==null?void 0:s.available)===!1?"unavailable":s!=null&&s.available||e==="customer-agent"?"ready":"checking",o=i==="ready"?"本机已连接":i==="checking"?"正在检查运行时":"运行时暂不可用";return t.jsxs("header",{className:"sidebar-agent-header",children:[t.jsx("span",{className:"sidebar-agent-header-icon",children:t.jsx(_r,{agentType:e,size:23})}),t.jsxs("div",{className:"sidebar-agent-header-identity",children:[t.jsx("span",{className:"sidebar-agent-header-name",title:qt[e],children:qt[e]}),t.jsxs("span",{className:`sidebar-agent-header-status is-${i}`,title:s==null?void 0:s.error,children:[t.jsx("i",{"aria-hidden":"true"}),o]})]}),t.jsxs("div",{className:"sidebar-agent-header-actions",children:[t.jsx(Ip,{}),t.jsx("button",{type:"button",className:"ui-icon-button sidebar-agent-header-close",onClick:r,"aria-label":"收起会话列表",title:"收起会话列表",children:t.jsx(tr,{size:18,"aria-hidden":"true"})})]})]})}async function Iy(e,n,r){async function s(h){const p=[],k=new Set;let x=null;do{r.throwIfAborted();const y=await h(x);if(r.throwIfAborted(),y.stale)throw new Error("会话列表待刷新,请重试");if(p.push(...y.data),x=y.nextCursor,x&&k.has(x))throw new Error("会话列表加载中断,请重试");x&&k.add(x)}while(x);return p}const i=await s(h=>e.listAgentWorkspaces(n,{cursor:h,limit:200})),o=[...new Map(i.map(h=>[h.workspaceId,h])).values()],l=new Array(o.length);let u=0;await Promise.all(Array.from({length:Math.min(4,o.length)},async()=>{for(;u<o.length;){const h=u++,p=o[h];l[h]=(await s(k=>e.listAgentWorkspaceSessions(n,p.workspaceId,{cursor:k,limit:200}))).map(k=>({...k,projectId:p.workspaceId}))}}));const d=new Set,g=l.flat().filter(h=>d.has(h.id)?!1:(d.add(h.id),!0));return{workspaces:o,sessions:g}}function Cy({hidden:e,value:n,health:r,selectedSessionId:s,getActivity:i,onChange:o,onUnavailable:l,onSelect:u}){const[d,g]=c.useState(null),[h,p]=c.useState(null),[k,x]=c.useState(!1),[y,S]=c.useState(null),[v,w]=c.useState(""),[j,C]=c.useState(0),A=c.useRef(),L=c.useRef(null),z=c.useRef(new Map),R=()=>clearTimeout(A.current),N=()=>{R(),g(null)},T=()=>{R(),A.current=setTimeout(()=>g(null),180)};c.useEffect(()=>()=>clearTimeout(A.current),[]),c.useEffect(()=>{e&&g(null)},[e]),c.useEffect(()=>{if(!d||e)return;const q=new AbortController;return w(""),p(d.unavailableMessage?null:z.current.get(d.agentType)??null),S(d.unavailableMessage??null),x(!d.unavailableMessage),d.unavailableMessage||Iy(window.agentApi,d.agentType,q.signal).then(ae=>{q.signal.aborted||(z.current.set(d.agentType,ae),p(ae))}).catch(ae=>{q.signal.aborted||S(ae instanceof Error?ae.message:"会话加载失败,请重试")}).finally(()=>{q.signal.aborted||x(!1)}),()=>q.abort()},[d==null?void 0:d.agentType,d==null?void 0:d.unavailableMessage,e,j]);const F=Rl((h==null?void 0:h.sessions)??[],q=>{const ae=i(q);return ae==="running"||ae==="needs-input"}).filter(q=>q.title.toLocaleLowerCase().includes(v.trim().toLocaleLowerCase())),O=q=>{var se;const ae=q.relatedTarget;!q.currentTarget.contains(ae)&&!((se=L.current)!=null&&se.contains(ae))&&T()};return t.jsxs(t.Fragment,{children:[t.jsx("aside",{className:"sidebar-agent-rail","aria-label":"Agent 快捷栏","aria-hidden":e,ref:q=>{q&&(q.inert=e)},onPointerEnter:R,onPointerLeave:T,onBlur:O,onKeyDown:q=>{q.key==="Escape"&&N()},children:t.jsx(uu,{vertical:!0,value:n,health:r,onChange:o,onUnavailable:l,onPreview:(q,ae,se,we)=>{R(),(d==null?void 0:d.agentType)!==q&&p(null),g({agentType:q,label:ae,top:Math.max(56,Math.min(se.top,window.innerHeight-380)),unavailableMessage:we})}})}),!e&&d&&Wt.createPortal(t.jsxs("div",{ref:L,className:"agent-session-flyout",style:{top:d.top,maxHeight:Math.min(600,window.innerHeight-d.top-12)},role:"dialog","aria-label":`${d.label} 会话`,onPointerEnter:R,onPointerLeave:T,onFocus:R,onBlur:O,onKeyDown:q=>{q.key==="Escape"&&N()},children:[t.jsxs("header",{children:[t.jsx(_r,{agentType:d.agentType,size:20}),t.jsx("strong",{children:d.label}),t.jsxs("span",{children:["会话 ",(h==null?void 0:h.sessions.length)??""]})]}),t.jsxs("label",{className:"agent-session-flyout-search",children:[t.jsx(fa,{size:15,"aria-hidden":"true"}),t.jsx("input",{"aria-label":`搜索 ${d.label} 会话`,placeholder:"搜索会话",value:v,onChange:q=>w(q.target.value)})]}),t.jsxs("div",{className:"agent-session-flyout-list","aria-busy":k,children:[F.map(q=>{const ae=so(i(q));return t.jsx(oo,{session:{id:q.id,title:q.title,visualState:ae,statusLabel:io[ae],occupiedExternally:q.occupancy==="owned-externally",canDelete:!1,active:n===d.agentType&&s===q.id,compatibility:q.compatibility},onSelect:()=>{h&&u(q,h),N()}},q.id)}),k&&t.jsxs("p",{className:"agent-session-flyout-message",role:"status",children:[t.jsx(bt,{size:15,className:"spin"}),"正在加载会话…"]}),y&&t.jsxs("p",{className:"agent-session-flyout-message",role:"alert",children:[y,!d.unavailableMessage&&t.jsx("button",{type:"button",onClick:()=>C(q=>q+1),children:"重试"})]}),!k&&!y&&!F.length&&t.jsx("p",{className:"agent-session-flyout-message",children:v?"没有匹配的会话":"暂无会话"})]})]}),document.body)]})}function Xd({onOpenFlowStudio:e,openingFlowStudio:n=!1}){return t.jsx("div",{className:"desktop-app-actions",role:"toolbar","aria-label":"应用快捷操作",children:t.jsx("button",{type:"button",className:"ui-icon-button desktop-app-action desktop-app-action--flow-studio",onClick:e,disabled:n,title:"数字人 · Flow Studio","aria-label":"打开 Flow Studio","aria-busy":n,children:n?t.jsx(bt,{className:"desktop-app-action-spinner",size:17,"aria-hidden":"true"}):t.jsx(wf,{size:17,"aria-hidden":"true"})})})}function Ey({entryUrl:e,onBack:n}){const r=typeof window<"u"?window.agentApi:void 0,s=typeof(r==null?void 0:r.flowStudioOpen)=="function",i=c.useRef(null),o=c.useRef(null),[l,u]=c.useState("loading"),d=c.useCallback(()=>{o.current&&(r==null||r.flowStudioSetBounds(o.current))},[r]),g=c.useCallback(async()=>{if(!s||!r){u("error");return}if(u("loading"),!(await r.flowStudioOpen(e).catch(()=>({ok:!1}))).ok){u("error");return}d()},[r,s,e,d]);return c.useEffect(()=>{if(!s||!r){u("error");return}const h=r.onFlowStudioEvent(p=>{p.siteId==="flow-studio"&&(p.type==="loading"&&u("loading"),p.type==="loaded"&&(u("ready"),d()),p.type==="load-failed"&&u("error"))});return g(),()=>{h(),r.flowStudioSetBounds(null)}},[r,s,g,d]),c.useEffect(()=>{if(!s||!r)return;const h=i.current;if(!h)return;let p=0;const k=()=>{const y=h.getBoundingClientRect(),S={x:y.x,y:y.y,width:y.width,height:y.height};o.current=S,r.flowStudioSetBounds(S)},x=new ResizeObserver(()=>{cancelAnimationFrame(p),p=requestAnimationFrame(k)});return x.observe(h),k(),()=>{x.disconnect(),cancelAnimationFrame(p)}},[r,s]),t.jsxs("section",{className:"desktop-flow-studio-view","aria-label":"Flow Studio","aria-busy":l==="loading",children:[t.jsx("header",{className:"desktop-flow-studio-topbar",children:t.jsx("button",{type:"button",className:"desktop-flow-studio-back ui-icon-button",onClick:n,title:"返回 AgentRoam","aria-label":"返回 AgentRoam",children:t.jsx(xu,{size:18,"aria-hidden":"true"})})}),t.jsx("div",{ref:i,className:"desktop-flow-studio-content",children:l!=="ready"&&t.jsxs("div",{className:"desktop-flow-studio-status",role:l==="error"?"alert":"status","aria-live":"polite",children:[l==="loading"?t.jsx(bt,{className:"desktop-flow-studio-spinner",size:20,"aria-hidden":"true"}):null,t.jsx("strong",{children:l==="error"?"无法打开 Flow Studio":"正在打开 Flow Studio"}),l==="error"&&t.jsxs("button",{type:"button",className:"desktop-flow-studio-retry",onClick:()=>void g(),children:[t.jsx(ig,{size:16,"aria-hidden":"true"}),t.jsx("span",{children:"重试"})]})]})})]})}const dl=264,Zd=126;function Ry(e){const n=typeof window>"u"?1024:window.innerWidth,r=typeof window>"u"?768:window.innerHeight,s=Math.max(8,Math.min(e.left+e.width-dl,n-dl-8)),i=e.top+e.height+7,o=i+Zd<=r-8?i:Math.max(8,e.top-Zd-7);return{left:s,top:o,width:dl}}function eu({title:e,message:n,anchor:r,mobile:s,pending:i,onCancel:o,onConfirm:l}){const u=d=>d.stopPropagation();return t.jsx("div",{className:`sidebar-delete-confirmation-layer${s?" is-mobile":""}`,onClick:i?void 0:o,children:t.jsxs("div",{className:"sidebar-delete-confirmation",role:"alertdialog","aria-modal":"true","aria-labelledby":"sidebar-delete-confirmation-title","aria-describedby":"sidebar-delete-confirmation-message",style:s?void 0:Ry(r),onClick:u,children:[t.jsx("strong",{id:"sidebar-delete-confirmation-title",children:e??"删除会话"}),t.jsx("p",{id:"sidebar-delete-confirmation-message",children:n}),t.jsxs("div",{className:"sidebar-delete-confirmation-actions",children:[t.jsx("button",{type:"button",onClick:o,disabled:i,children:"取消"}),t.jsx("button",{type:"button",className:"is-danger",onClick:l,disabled:i,children:i?"正在删除...":"删除"})]})]})})}function Ny({open:e,tab:n,gateway:r,cwd:s,selectedPath:i,revealRequest:o,onTabChange:l,onSelectPath:u,onClose:d}){return e?t.jsxs("section",{className:`desktop-file-workspace${i?" has-preview":""}`,"aria-label":"我的文件",children:[t.jsxs("aside",{className:"desktop-file-drawer",children:[t.jsxs("header",{className:"desktop-file-drawer-header",children:[t.jsxs("div",{className:"desktop-file-drawer-tabs",role:"tablist","aria-label":"文件工作区视图",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":n==="files",className:n==="files"?"is-active":"",onClick:()=>l("files"),children:"文件"}),t.jsx("button",{type:"button",role:"tab","aria-selected":n==="history",className:n==="history"?"is-active":"",onClick:()=>l("history"),children:"历史"})]}),t.jsx("button",{type:"button",className:"desktop-file-workspace-close ui-icon-button ui-icon-button--small",onClick:d,"aria-label":"关闭我的文件",title:"关闭",children:t.jsx(tr,{size:15,"aria-hidden":"true"})})]}),n==="files"?s?t.jsx(og,{gateway:r,ready:!0,followCwd:!0,cwd:s,onOpenFile:g=>u(g),selectedPath:i,revealRequest:o}):t.jsx("div",{className:"desktop-file-workspace-empty",children:"请先选择一个项目目录"}):t.jsxs("div",{className:"desktop-file-workspace-empty",children:[t.jsx("strong",{children:"终端历史在 Web 控制台中可用"}),t.jsx("span",{children:"Electron 当前没有终端上下文,因此不会提供填入或执行操作。"})]}),t.jsxs("footer",{className:"desktop-file-drawer-footer",children:[t.jsx("span",{}),"实时同步"]})]}),i&&t.jsx("div",{className:"desktop-file-preview",children:t.jsx(Uf,{path:i,gateway:r,onClose:()=>u(null)})})]}):null}const Cp="agentroam.agent-workspaces.v2",Ty=2;function tu(){return{version:2,activeAgent:"customer-agent",agents:{}}}function ul(){return{workspaces:[],nextCursor:null,watermark:null,expandedWorkspaceIds:[],selectedWorkspaceId:null,selectedSessionId:null,sidebarScrollTop:0,sessions:{}}}function Ay(e=localStorage){try{const n=JSON.parse(e.getItem(Cp)??"null");if(!$s(n)||n.version!==Ty)return tu();const r=Dy(n.activeAgent)?n.activeAgent:"customer-agent",s=$s(n.agents)?n.agents:{},i={};for(const o of Al){const l=Py(s[o],o);l&&(i[o]=l)}return{version:2,activeAgent:r,agents:i}}catch{return tu()}}function nu(e,n=localStorage){try{n.setItem(Cp,JSON.stringify(e))}catch{}}function Ep(e){return(e==null?void 0:e.source)==="derived"&&e.canCreateSession===!1&&e.roots.length>0}function _y(e,n,r,s){const i=new Set(n.data.map(u=>u.workspaceId)),o=r?n.nextCursor?[...n.data,...e.filter(u=>!i.has(u.workspaceId))]:[...n.data,...e.filter(u=>u.workspaceId===s&&Ep(u)&&!i.has(u.workspaceId))]:[...e,...n.data],l=new Set;return o.filter(u=>l.has(u.workspaceId)?!1:(l.add(u.workspaceId),!0))}function My(e,n,r,s){if(n.stale&&s!==void 0)return s;if(!r||!n.nextCursor||s===void 0)return n.nextCursor;const i=new Set(n.data.map(o=>o.id));return e.some(o=>!i.has(o.id))?s:n.nextCursor}function Rp(e,n,r,s){const i=new Set(n.data.map(g=>g.id)),o=new Map(n.data.map(g=>[g.id,g])),l=new Set(e.map(g=>g.id)),u=r?n.nextCursor?[...n.data,...e.filter(g=>!i.has(g.id))]:[...n.data,...e.filter(g=>g.id===s&&!i.has(g.id))]:[...e.map(g=>o.get(g.id)??g),...n.data.filter(g=>!l.has(g.id))],d=new Set;return u.filter(g=>d.has(g.id)?!1:(d.add(g.id),!0))}async function Ly(e,n,r,s){if(n.stale)return n;const i=new Set(n.data.map(h=>h.id)),o=new Set(e.filter(h=>h.status==="running"&&h.id!==s&&!i.has(h.id)).map(h=>h.id));if(o.size===0||!n.nextCursor)return n;let l=[...n.data],u=n.nextCursor,d=n.watermark;const g=new Set;for(;u&&o.size>0;){const h=u;if(g.has(h))return{data:l,nextCursor:h,watermark:d,stale:!0};g.add(h);const p=await r(h);if(p.stale)return{data:l,nextCursor:h,watermark:d,stale:!0};l=Rp(l,p,!1);for(const k of p.data)o.delete(k.id);u=p.nextCursor,d=p.watermark??d}return{data:l,nextCursor:u,watermark:d}}function zy(e,n){return!n||e.some(r=>r.id===n.id)?[...e]:[n,...e]}function Py(e,n){if(!$s(e))return null;const r=Array.isArray(e.workspaces)?e.workspaces.filter(i=>$s(i)&&i.agentType===n&&typeof i.workspaceId=="string"&&typeof i.name=="string"&&Array.isArray(i.roots)&&i.roots.every(o=>typeof o=="string")&&typeof i.order=="number"&&(i.canCreateSession===void 0||typeof i.canCreateSession=="boolean")):[],s={};if($s(e.sessions))for(const[i,o]of Object.entries(e.sessions))!$s(o)||!Array.isArray(o.data)||(s[i]={data:o.data.filter(l=>$s(l)&&l.agentType===n&&typeof l.id=="string"),nextCursor:typeof o.nextCursor=="string"?o.nextCursor:null,loaded:o.loaded===!0});return{workspaces:r,nextCursor:typeof e.nextCursor=="string"?e.nextCursor:null,watermark:typeof e.watermark=="string"?e.watermark:null,expandedWorkspaceIds:Array.isArray(e.expandedWorkspaceIds)?e.expandedWorkspaceIds.filter(i=>typeof i=="string"):[],selectedWorkspaceId:typeof e.selectedWorkspaceId=="string"?e.selectedWorkspaceId:null,selectedSessionId:typeof e.selectedSessionId=="string"?e.selectedSessionId:null,sidebarScrollTop:typeof e.sidebarScrollTop=="number"&&e.sidebarScrollTop>=0?e.sidebarScrollTop:0,sessions:s}}function Dy(e){return typeof e=="string"&&Al.includes(e)}function $s(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Wy(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(e)}function $y(e,n){if(n.webShell||n.isInvalid||!n.supported)return null;const r=e.description;return!r||/[\0\r\n]/.test(r)||!Wy(r)?null:r}function By(e){return{request:(n,r)=>e.fileWorkspaceRequest(n,r),subscribe:(n,r)=>n!=="fs:event"?()=>{}:e.onFileWorkspaceEvent(r)}}function Oy(e){try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.toString()}catch{return null}}async function Fy(){var e;try{const n=window.sharedServiceApi;if(!(n!=null&&n.request))return null;const r=await n.request("/api/flow-studio/config","GET");if(r.status!==200)return null;const s=(e=JSON.parse(r.body).entryUrl)==null?void 0:e.trim();return s?Oy(s):null}catch{return null}}function qy({authoritativeStatus:e,locallyRunning:n,needsInput:r,stale:s}){return e==="failed"||e==="error"?"error":s&&!n?"stale":n||e==="running"?r?"needs-input":"running":"idle"}function Uy(e,n){const r=new Set;e&&r.add(e);for(const s of n)s&&r.add(s);return[...r]}function Hy(e,n,r){return[...e].filter(s=>!n.has(s)&&!r.has(s))}const ru=220,su=480,Gy=180;function Vy(){const[e,n]=c.useState(300),[r,s]=c.useState(!1),[i,o]=c.useState(!1),l=c.useRef(null),u=c.useCallback(y=>{y.button!==0||!y.isPrimary||(y.preventDefault(),y.currentTarget.setPointerCapture(y.pointerId),l.current={pointerId:y.pointerId,startX:y.clientX,startWidth:e,target:y.currentTarget},o(!0))},[e]),d=c.useCallback(y=>{const S=l.current;if(!S||y.pointerId!==S.pointerId)return;const v=S.startWidth+y.clientX-S.startX,w=v<=Gy;s(w),n(w?S.startWidth:Math.min(su,Math.max(ru,v)))},[]),g=c.useCallback(()=>{const y=l.current;y&&(l.current=null,o(!1),y.target.hasPointerCapture(y.pointerId)&&y.target.releasePointerCapture(y.pointerId))},[]),h=c.useCallback(y=>{var S;y.pointerId===((S=l.current)==null?void 0:S.pointerId)&&g()},[g]),p=c.useCallback(y=>{d(y),h(y)},[d,h]);c.useEffect(()=>{if(i)return window.addEventListener("pointerup",p),window.addEventListener("pointercancel",h),window.addEventListener("blur",g),()=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",h),window.removeEventListener("blur",g)}},[i,p,h,g]);const k=c.useCallback(y=>{y.key==="Enter"?(y.preventDefault(),s(!0)):(y.key==="ArrowLeft"||y.key==="ArrowRight")&&(y.preventDefault(),n(S=>Math.min(su,Math.max(ru,S+(y.key==="ArrowLeft"?-20:20)))))},[]),x=c.useCallback(()=>s(y=>!y),[]);return{width:e,collapsed:r,dragging:i,toggle:x,resizeProps:{onPointerDown:u,onPointerMove:d,onPointerUp:p,onPointerCancel:h,onLostPointerCapture:h,onKeyDown:k}}}function iu(e,n){var i;const r={},s={};for(const[o,l]of Object.entries(e)){const u=l.data;r[o]=El(u.filter(d=>!d.parentSessionId),n);for(const d of u.filter(g=>g.parentSessionId))(s[i=d.parentSessionId]??(s[i]=[])).push(d)}for(const o of Object.values(s))o.sort((l,u)=>l.created.localeCompare(u.created));return{roots:r,children:s,projectIds:new Set(Object.entries(e).filter(([,o])=>o.loaded).map(([o])=>o))}}function ou(e,n,r){return e==="codex"&&(n==null?void 0:n.canCreateSession)!==!1?!0:r}function pl(e){return{id:e.workspaceId,name:e.name,description:e.roots[0]??"",created:e.updatedAt??"",updated:e.updatedAt??"",agentType:e.agentType,source:e.source,canCreateSession:e.canCreateSession}}function au(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M8 6V4h8v2"}),t.jsx("path",{d:"M19 6l-1 14H6L5 6"}),t.jsx("path",{d:"M10 11v5M14 11v5"})]})}function lu(e,n){n&&e.detail>0&&e.currentTarget.blur()}function Qy(){const e=document.activeElement;e instanceof HTMLElement&&(e.matches("input, textarea, select")||e.isContentEditable)&&e.blur()}function Ev(){var Wn,Kn,vn,Jn;const[e]=c.useState(Ay),n=e.activeAgent,r=e.agents[n]??ul(),[s]=c.useState(()=>iu(r.sessions,n)),i=c.useRef(e),[o,l]=c.useState(n),u=c.useRef(o);u.current=o;const[d,g]=c.useState(r.workspaces.map(pl)),[h,p]=c.useState(r.nextCursor),[k,x]=c.useState(r.watermark),[y,S]=c.useState(!1),[v,w]=c.useState(!1),[j,C]=c.useState(null),[A,L]=c.useState(!1),[z,R]=c.useState(s.roots),[N,T]=c.useState(""),[F,O]=c.useState(!1),[q,ae]=c.useState(null),[se,we]=c.useState(!1),[Y,K]=c.useState(null);c.useEffect(()=>{if(!F||!window.agentApi)return;let f=!1;return we(!0),K(null),window.agentApi.listSessions().then(E=>{f||ae({agentType:o,sessions:E})}).catch(E=>{f||K(E instanceof Error?E.message:"会话搜索加载失败")}).finally(()=>{f||we(!1)}),()=>{f=!0}},[F,o]);const[Q,Se]=c.useState(10),[Pe,oe]=c.useState(null),[Ne,at]=c.useState(!1),[W,X]=c.useState(null),[ke,_e]=c.useState(!1),[Je,it]=c.useState(0),[pt,Ye]=c.useState([]),[$t,nr]=c.useState(s.children),Te=c.useRef(z),Ue=c.useRef($t);Te.current=z,Ue.current=$t;const[lt,fr]=c.useState(s.projectIds),[os,U]=c.useState(new Set),[Z,G]=c.useState({}),[J,be]=c.useState(new Set),[Xe,rr]=c.useState(Object.fromEntries(Object.entries(r.sessions).map(([f,E])=>[f,E.nextCursor]))),Yt=c.useRef(new Map),un=c.useRef(new Map),[dt,gr]=c.useState(r.selectedWorkspaceId),[ut,kn]=c.useState(()=>xt.getState().navigationLayout==="all-sessions"?null:r.selectedSessionId),[hr,Mr]=c.useState(null),Ut=c.useRef(dt),Nt=c.useRef(ut);Ut.current=dt,Nt.current=ut;const[In,as]=c.useState(new Set),[Cn,pn]=c.useState(new Set(r.expandedWorkspaceIds)),[gt,ft]=c.useState(new Set),[mr,It]=c.useState(!1),[sr,mo]=c.useState(!1),[xo,Tt]=c.useState(!1),[En,qs]=c.useState([]),[ir,yt]=c.useState(null),[Rn,Ht]=c.useState(!1),[bo,Us]=c.useState(!1),[or,Xt]=c.useState(!1),[Ni,ls]=c.useState(!1),[xr,H]=c.useState(!1),[fn,gn]=c.useState(!1),[cs,yo]=c.useState(0),[ds,Lr]=c.useState(),[Ce,At]=c.useState(null),us=c.useRef(null),[va,On]=c.useState({}),_t=c.useRef(()=>{}),nt=c.useRef(null),Mt=c.useRef(null),zr=c.useCallback((f,E)=>{const M=Mt.current;!M||M.sessionId!==f||M.seed!==E||nt.current!==M.controller||M.controller.signal.aborted||(Mt.current=null,nt.current=null,At(null),window.parent!==window&&window.parent.postMessage({type:eg,sessionId:f},window.location.origin))},[]),vo=c.useRef(`${Date.now()}-${Math.random().toString(36).slice(2)}`),Hs=fn||Ni||bo||En.length>0,ps=()=>{if(tn(!1),ns()&&window.parent!==window){Sb().catch(f=>{Oe(f instanceof Error?f.message:"消息接入打开失败"),ct("error")});return}gn(!0),H(!0),Xt(!1),Ht(!1),yt(null)};c.useEffect(()=>{if(!(!ns()||window.parent===window))try{new URL(window.parent.location.href).searchParams.get(na)==="messaging"&&ps()}catch{}},[]);const ar=()=>{if(H(!1),ns()&&window.parent!==window){window.parent.postMessage({type:Vi,intent:{kind:"dashboard"}},window.location.origin);return}ls(!0),Xt(!0),Ht(!1),yt(null)},Pr=()=>{H(!1),Us(!0),Ht(!0),yt(null),Xt(!1)},[wa,Gs]=c.useState(!1),[wo,Vs]=c.useState(0),fs=f=>{H(!1),ns()&&window.parent!==window?window.parent.postMessage({type:ng,groupId:f.id,title:f.name},window.location.origin):(Xt(!1),Ht(!1),qs(E=>E.some(M=>M.id===f.id)?E:[...E,f]),yt(f.id))},[Fn,Dr]=c.useState("settings"),Me=Re(f=>f.setTodos),ht=xt(f=>f.skin),Gt=xt(f=>f.layout),Zt=xt(f=>f.navigationLayout),Lt=Zt==="all-sessions",Nn=xt(f=>f.wakeEnabled),Tn=xt(f=>f.wakeWord),gs=xt(f=>f.setSkin),br=xt(f=>f.setLayout),jo=xt(f=>f.setWakeEnabled),Ti=xt(f=>f.setWakeWord),Qs=xt(f=>f.autoSpeak),So=xt(f=>f.setAutoSpeak),hn=xt(f=>f.runningFirst),mn=xt(f=>f.setRunningFirst),Ks=xt(f=>f.pinnedSessionIds),hs=xt(f=>f.togglePinnedSession),en=xt(f=>f.removePinnedSessions),Wr=new Set(Ks),qn=Re(f=>f.runningSessionId),Js=Re(Rg(f=>Object.entries(f.messagesBySession).filter(([,E])=>yl(E)).map(([E])=>E))),An=c.useCallback((f,E=f.projectId)=>qy({authoritativeStatus:f.status,locallyRunning:qn===f.id,needsInput:Js.includes(f.id),stale:!!(f.agentType===o&&E&&(J.has(E)||Z[E]))}),[o,Z,qn,Js,J]),ms=c.useCallback(f=>{const E=An(f);return E==="running"||E==="needs-input"},[An]),ko=()=>{pn(new Set),as(new Set(Object.keys($t)))},Io=()=>{const f=d.filter(M=>!gt.has(M.id)),E=f.map(M=>M.id);pn(new Set(E)),as(new Set);for(const M of f){const D=M.id;if(wt.current.has(D))continue;const $=Hn.current.has(D),ee=ou(u.current,M,$);an(D,{refresh:ee,background:$})}},rt=ns();c.useEffect(()=>{if(!rt||window.parent===window)return;const f=E=>{rg(E,window.location.origin,window.parent)&&Gs(!0)};return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[rt]);const Ai=jf(),Ze=rt&&Ai,[xn,tn]=c.useState(!1),[$r,Ys]=c.useState(!1),[xs,Xs]=c.useState("files"),[_i,bs]=c.useState(null),[ja,Co]=c.useState(null),nn=c.useMemo(()=>{var f;return!rt&&typeof((f=window.agentApi)==null?void 0:f.fileWorkspaceRequest)=="function"?By(window.agentApi):null},[rt]),ys=c.useCallback(async f=>{if(rt){Cf(f);return}if(nn){if(f.startsWith("~/")){const{home:E}=await nn.request("hello"),M=pa(f,null,E);if(!M)return;f=M}Xs("files"),Ys(!0),bs(f),Co(E=>zl(f)?null:{path:f,requestId:((E==null?void 0:E.requestId)??0)+1})}},[nn,rt]);c.useEffect(()=>{bs(null),Co(null)},[dt]);const[lr,_n]=c.useState(!1),[yr,Mi]=c.useState(null),[Sa,Eo]=c.useState(0),[rn,vt]=c.useState(void 0),Vt=c.useRef(null),bn=c.useRef(!1),[Br,vr]=c.useState(null),Un=c.useRef(null),vs=c.useRef(!1),Qt=c.useRef(d);Qt.current=d;const Zs=c.useRef(gt);Zs.current=gt;const Hn=c.useRef(lt);Hn.current=lt;const wt=c.useRef(os);wt.current=os;const Or=c.useRef(null);c.useEffect(()=>{document.documentElement.setAttribute("data-skin",ht)},[ht]),c.useEffect(()=>{document.body.classList.toggle("layout-compact",Gt==="compact")},[Gt]),c.useEffect(()=>{var D;const f=d.map(($,ee)=>({agentType:o,workspaceId:$.id,name:$.name,roots:$.description?[$.description]:[],order:ee,updatedAt:$.updated||void 0,source:$.source??($.agentType==="claude-code"?"derived":"native"),canCreateSession:$.canCreateSession})),E=Object.fromEntries(d.map($=>[$.id,{data:[...z[$.id]??[],...Object.values($t).flat().filter(ee=>(z[$.id]??[]).some(te=>te.id===ee.parentSessionId))],nextCursor:Xe[$.id]??null,loaded:lt.has($.id)}])),M={...i.current,version:2,activeAgent:o,agents:{...i.current.agents,[o]:{workspaces:f,nextCursor:h,watermark:k,expandedWorkspaceIds:[...Cn],selectedWorkspaceId:dt,selectedSessionId:ut,sidebarScrollTop:((D=Or.current)==null?void 0:D.scrollTop)??0,sessions:E}}};i.current=M,nu(M)},[o,$t,Cn,lt,d,dt,ut,Xe,z,h,k]);const cr=c.useCallback(()=>{if(!window.agentApi||!Nn||bn.current||Vt.current)return;const f=()=>{em()&&!Vt.current&&(Vt.current=nm({wakeWord:Tn,onWake:E=>{var M;vt(E),Eo(D=>D+1),(M=window.agentApi)==null||M.showWindow()},onError:E=>console.warn("[wake]",E)}))};typeof window.agentApi.wakeStart=="function"?(bn.current=!0,window.agentApi.wakeStart(Tn).then(E=>{E.ok||(bn.current=!1,f())}).catch(()=>{bn.current=!1,f()})):f()},[Nn,Tn]);c.useEffect(()=>{var f;if((f=window.agentApi)!=null&&f.onWake)return window.agentApi.onWake(E=>{bn.current=!1,vt(E),Eo(M=>M+1)})},[]),c.useEffect(()=>{var f;if((f=window.agentApi)!=null&&f.onWakeAiHub)return window.agentApi.onWakeAiHub(()=>{Tt(!0),br("focus")})},[]),c.useEffect(()=>{var f;if((f=window.agentApi)!=null&&f.onWakeCommand)return window.agentApi.onWakeCommand(E=>{var ee;const M=((E==null?void 0:E.text)||"").trim();if(!M)return;const D=Un.current&&Date.now()<Un.current.until?Un.current:null;if(D){D.until=Date.now()+9e4,kn(D.sessionId),(ee=window.agentApi)==null||ee.wakeConversation(!0),vr({text:M,projectId:null,sessionId:D.sessionId,nonce:Date.now()}),Oe(`语音追问:${M.length>40?M.slice(0,40)+"…":M}`),ct("success"),setTimeout(()=>Oe(null),4e3);return}const $=Qt.current.find(te=>te.name&&M.includes(te.name)&&!Zs.current.has(te.id));$&&(gr($.id),pn(te=>{const Ie=new Set(te);return Ie.add($.id),Ie})),kn(null),vs.current=!0,So(!0),vr({text:M,projectId:($==null?void 0:$.id)??null,nonce:Date.now()}),Oe(`语音指令:${M.length>40?M.slice(0,40)+"…":M}${$?`(项目:${$.name})`:""}`),ct("success"),setTimeout(()=>Oe(null),4e3)})},[]);const ws=c.useCallback(async()=>{window.agentApi&&(cr(),await window.agentApi.hideWindow())},[cr]),Fr=c.useCallback(f=>{It(!1),Mi({right:f.right,bottom:f.bottom}),_n(E=>!E)},[]),js=c.useCallback(()=>{_n(!1),It(f=>!f)},[]);c.useEffect(()=>{if(!lr)return;const f=()=>{const M=document.querySelector(".chat-header-action--appearance");if(!M)return;const D=M.getBoundingClientRect();Mi($=>($==null?void 0:$.right)===D.right&&$.bottom===D.bottom?$:{right:D.right,bottom:D.bottom})},E=window.requestAnimationFrame(f);return window.addEventListener("resize",f),()=>{window.cancelAnimationFrame(E),window.removeEventListener("resize",f)}},[Gt,lr]),c.useEffect(()=>{window.agentApi&&cr()},[cr]),c.useEffect(()=>{const f=()=>{var E;(E=Vt.current)==null||E.stop(),Vt.current=null};return window.addEventListener("focus",f),()=>window.removeEventListener("focus",f)},[]),c.useEffect(()=>{var f,E;Nn||((f=Vt.current)==null||f.stop(),Vt.current=null,bn.current=!1,(E=window.agentApi)==null||E.wakeStop())},[Nn]),c.useEffect(()=>{!Nn||!window.agentApi||bn.current&&window.agentApi.wakeStart(Tn)},[Tn]),c.useEffect(()=>()=>{var f;(f=Vt.current)==null||f.stop()},[]);const Ro=[...Object.values(z).flat(),...Object.values($t).flat()],ei=Tx((q==null?void 0:q.agentType)===o?q.sessions:[],Ro,o).map(f=>{var E;return{...f,projectId:f.projectId??((E=d.find(M=>M.description===f.cwd))==null?void 0:E.id)}}),wr=Vb(ei,f=>Wr.has(f.id)),Li=Object.entries(z).flatMap(([f,E])=>E.filter(M=>Wr.has(M.id)).map(M=>({projectId:f,session:M,created:M.created}))),qr=El(Li,o),Ur=hn?Rl(qr,({session:f})=>ms(f)):qr,Hr=ei,yn=N.trim().toLowerCase(),jt=yn?wr.filter(f=>f.title.toLowerCase().includes(yn)||(f.cwd||"").toLowerCase().includes(yn)):null,Mn=ut?Hr.find(f=>f.id===ut)??((hr==null?void 0:hr.id)===ut?hr:void 0):void 0,ti=Mn==null?void 0:Mn.title,Gr=(Mn==null?void 0:Mn.cwd)||((Wn=d.find(f=>f.id===dt))==null?void 0:Wn.description)||null,sn=d.filter(f=>!gt.has(f.id)).map(f=>f.id),No=[...d.filter(f=>!gt.has(f.id)),...d.filter(f=>gt.has(f.id))],Gn=sn.length>0&&sn.every(f=>!Cn.has(f)),{width:Vn,collapsed:Kt,dragging:Ss,toggle:jr,resizeProps:Bt}=Vy(),Qn=!Ze&&(Kt||Gt==="focus"),[To,Oe]=c.useState(null),[Ao,ct]=c.useState("success"),[Ln,ni]=c.useState(null),[Ct,ri]=c.useState(!1),ge=c.useCallback(async()=>{if(!Ct){ri(!0);try{const f=await Fy();if(f){Tt(!1),tn(!1),ni(f);return}Oe("Flow Studio 入口不可用,请检查服务配置"),ct("error"),setTimeout(()=>Oe(null),4e3)}finally{ri(!1)}}},[Ct]),St=f=>{Ut.current=f.projectId,Nt.current=f.sessionId,gr(f.projectId),kn(f.sessionId),f.sessionId||Me([])},on=(f,E=!1)=>{var Ie;if(f===u.current&&!E)return;const M=u.current,D=i.current.agents[M];D&&(i.current={...i.current,agents:{...i.current.agents,[M]:{...D,sidebarScrollTop:((Ie=Or.current)==null?void 0:Ie.scrollTop)??D.sidebarScrollTop}}});const $=i.current.agents[f]??ul(),ee=iu($.sessions,f),te=$.workspaces.map(pl);u.current=f,Qt.current=te,l(f),g(te),p($.nextCursor),x($.watermark),S(!1),w(!1),C(null),Te.current=ee.roots,Ue.current=ee.children,R(ee.roots),nr(ee.children),fr(ee.projectIds),Hn.current=ee.projectIds,U(new Set),wt.current=new Set,G({}),be(new Set),rr(Object.fromEntries(Object.entries($.sessions).map(([Le,We])=>[Le,We.nextCursor]))),pn(new Set($.expandedWorkspaceIds)),ft(new Set),St({projectId:$.selectedWorkspaceId,sessionId:$.selectedSessionId}),window.requestAnimationFrame(()=>{Or.current&&(Or.current.scrollTop=$.sidebarScrollTop)}),Lt||Pn(f,{refresh:$.workspaces.length>0,since:$.watermark,refreshLoadedSessions:!Lt})},zn=(f,E)=>{var We,Ge;(We=nt.current)==null||We.abort(),nt.current=null,Mt.current=null,At(null),Lr(void 0);const M=f??u.current,D=Gr;M!==u.current&&on(M);const $=i.current.agents[M],ee=($==null?void 0:$.workspaces)??[],te=D?ee.find(de=>{var ot;return de.canCreateSession!==!1&&((ot=de.roots)==null?void 0:ot.includes(D))}):void 0,Ie=$!=null&&$.selectedWorkspaceId&&ee.some(de=>de.canCreateSession!==!1&&de.workspaceId===$.selectedWorkspaceId)?$.selectedWorkspaceId:void 0,Le=E??(te==null?void 0:te.workspaceId)??Ie??((Ge=ee.find(de=>de.canCreateSession!==!1))==null?void 0:Ge.workspaceId)??null;us.current=E||te||!D?null:{agentType:M,preferredPath:D},St({projectId:Le,sessionId:null}),Re.setState({sessionId:null,messages:[]}),Xt(!1),ls(!1),H(!1),Ht(!1),yt(null),Tt(!1),Gt==="focus"&&br("standard"),yo(de=>de+1),Ze&&tn(!1)};c.useEffect(()=>{const f=us.current;if(!f)return;if(ut!==null){us.current=null;return}if(o!==f.agentType)return;const E=f.preferredPath?d.find(M=>M.canCreateSession!==!1&&M.description===f.preferredPath):void 0;E&&(us.current=null,E.id!==dt&&St(Zo(E.id)))},[o,d,dt,ut]);const dr=(f,E,M=!1)=>{H(!1);const D=i.current.agents[f.agentType]??ul();i.current={...i.current,agents:{...i.current.agents,[f.agentType]:{...D,workspaces:E.workspaces,nextCursor:M?D.nextCursor:null,selectedWorkspaceId:f.projectId??null,selectedSessionId:f.id,expandedWorkspaceIds:[...new Set([...D.expandedWorkspaceIds,...f.projectId?[f.projectId]:[]])],sessions:Object.fromEntries(E.workspaces.map($=>{var ee,te;return[$.workspaceId,{data:E.sessions.filter(Ie=>Ie.projectId===$.workspaceId),loaded:M?((ee=D.sessions[$.workspaceId])==null?void 0:ee.loaded)??!1:!0,nextCursor:M?((te=D.sessions[$.workspaceId])==null?void 0:te.nextCursor)??null:null}]}))}}},on(f.agentType,!0),Xt(!1),Ht(!1),yt(null),Ze&&tn(!1)};_t.current=f=>{var M;if(H(!1),rt&&window.parent!==window&&["dashboard","groups","group"].includes(f.kind)){window.parent.postMessage({type:Vi,intent:f},window.location.origin);return}(M=nt.current)==null||M.abort(),Mt.current=null;const E=new AbortController;nt.current=E,At(f.kind==="session"?f.session:null),f.kind==="session"&&(Xt(!1),Ht(!1),yt(null),Tt(!1),Ze&&tn(!1)),(async()=>{if(f.kind==="dashboard"){ar();return}if(f.kind==="groups"){Pr();return}if(f.kind==="new-session"){zn();return}if(f.kind==="group"){const Ge=await lo({action:"group",groupId:f.groupId});On(de=>({...de,[Ge.id]:f.discussionId})),fs(Ge);return}const D=f.kind==="agent"?f.agentType:f.session.agentType,$=pt.some(Ge=>Ge.agentType===D)?pt:await window.agentApi.getRuntimeHealth();if(E.signal.aborted)return;$!==pt&&Ye($);const ee=cu(D,$);if(ee)throw new Error(ee);if(f.kind==="agent"){on(f.agentType),Xt(!1),Ht(!1),yt(null),T(""),O(!1),Gt==="focus"&&br("standard"),Kt&&jr(),Ze&&tn(!0);return}const te=i.current.agents[f.session.agentType],Ie=te?{workspaces:te.workspaces,sessions:Object.values(te.sessions).flatMap(Ge=>Ge.data)}:void 0,Le=Nt.current!==f.session.id&&Re.getState().getMessagesForSession(f.session.id).length>0?Ib(f.session,Ie):void 0;if(Le){Lr(void 0),Mt.current={controller:E,sessionId:Le.session.id},dr(Le.session,Le.snapshot,!0),At(null);return}const We=await Cb(window.agentApi,f.session,E.signal,Ie);E.signal.aborted||(Lr(We.initialHistory),dr(We.session,We.snapshot,!0),Mt.current={controller:E,sessionId:We.session.id,seed:We.initialHistory})})().catch(D=>{E.signal.aborted||D instanceof Error&&D.name==="AbortError"||(Oe(D instanceof Error?D.message:"打开会话失败"),ct("error"),setTimeout(()=>Oe(null),5e3))}).finally(()=>{var D;nt.current===E&&((D=Mt.current)==null?void 0:D.controller)!==E&&(nt.current=null,At(null))})},c.useEffect(()=>{document.body.dataset.agentroamChatNavigation="ready";const f=ee=>{const te=Oc({data:{type:Vi,intent:ee.detail},origin:window.location.origin,source:window},window.location.origin,window);te&&_t.current(te)},E=ee=>{const te=Oc(ee,window.location.origin,window.parent!==window?window.parent:null);te&&_t.current(te)};window.addEventListener(Vi,f),window.addEventListener("message",E),window.parent!==window&&window.parent.postMessage({type:tg,instanceId:vo.current},window.location.origin);const M=new URLSearchParams(location.search),D=M.get("session"),$=M.get("agent");return D?window.agentApi.getSession(D,{limit:1}).then(ee=>{const te=ee;te.id&&fl(te.agentType)&&_t.current({kind:"session",session:te})}).catch(ee=>{Oe(ee instanceof Error?ee.message:"原会话不可访问"),ct("error")}):M.get("newSession")==="1"?zn():fl($)&&_t.current({kind:"agent",agentType:$}),()=>{var ee;delete document.body.dataset.agentroamChatNavigation,(ee=nt.current)==null||ee.abort(),window.removeEventListener(Vi,f),window.removeEventListener("message",E)}},[]);const[Vr,si]=c.useState([]),ks=c.useCallback(f=>{si(E=>E.filter(M=>M.id!==f))},[]),ii=c.useCallback(f=>{const E=crypto.randomUUID();si(M=>[...M,{...f,id:E}]),setTimeout(()=>ks(E),12e3)},[ks]);async function Pn(f=u.current,E={}){if(!window.agentApi)return;const M=(un.current.get(f)??0)+1;un.current.set(f,M),S(!0),C(null);try{const D=await window.agentApi.listAgentWorkspaces(f,{cursor:E.cursor,limit:50,refresh:E.refresh,since:E.refresh?E.since??k:null});if(u.current!==f||un.current.get(f)!==M)return;const $=Qt.current.map((de,ot)=>({agentType:f,workspaceId:de.id,name:de.name,roots:de.description?[de.description]:[],order:ot,updatedAt:de.updated,source:de.source??(f==="claude-code"?"derived":"native"),canCreateSession:de.canCreateSession})),te=_y($,D,!E.cursor,Nt.current?Ut.current:null).map(pl);Qt.current=te,g(te),p(D.nextCursor),x(D.watermark),w(D.stale===!0);const Ie=new Set(te.map(de=>de.id)),Le=Ut.current;Le&&!Ie.has(Le)&&St(sl);const We=new Set([...Hn.current].filter(de=>Ie.has(de)));if(Le&&Ie.has(Le)&&We.add(Le),R(de=>Object.fromEntries(Object.entries(de).filter(([ot])=>Ie.has(ot)))),fr(de=>{const ot=new Set([...de].filter(Qe=>Ie.has(Qe)));return Hn.current=ot,ot}),U(de=>{const ot=new Set([...de].filter(Qe=>Ie.has(Qe)));return wt.current=ot,ot}),G(de=>Object.fromEntries(Object.entries(de).filter(([ot])=>Ie.has(ot)))),Lt)return;const Ge=new Set;if(await Promise.all(te.map(async de=>{de.description&&!await window.agentApi.checkProjectPath(de.description)&&Ge.add(de.id)})),u.current!==f||un.current.get(f)!==M)return;if(ft(Ge),E.refreshLoadedSessions!==!1&&!Lt)for(const de of We)Ge.has(de)||wt.current.has(de)||an(de,{refresh:!0,background:!0})}catch(D){u.current===f&&(Qt.current.length>0&&w(!0),C(D instanceof Error?D.message:"目录加载失败"))}finally{u.current===f&&un.current.get(f)===M&&S(!1)}}async function an(f,E={}){var te,Ie;const M=window.agentApi;if(!M||Ep((te=i.current.agents[u.current])==null?void 0:te.workspaces.find(Le=>Le.workspaceId===f))||(E.cursor||E.background)&&wt.current.has(f))return;const D=u.current,$=`${D}:${f}`,ee=(Yt.current.get($)??0)+1;Yt.current.set($,ee),U(Le=>{const We=new Set(Le).add(f);return wt.current=We,We}),G(Le=>{if(!(f in Le))return Le;const We={...Le};return delete We[f],We});try{const Le=await M.listAgentWorkspaceSessions(D,f,{cursor:E.cursor,limit:20,refresh:E.refresh});if(u.current!==D||Yt.current.get($)!==ee)return;const We=Te.current[f]??[],Ge=E.pendingSession?{...E.pendingSession,projectId:f}:void 0,de=Ge?[Ge,...We.filter(He=>He.id!==Ge.id)]:We,ot=new Set(de.map(He=>He.id)),Qe=[...de,...[...ot].flatMap(He=>Ue.current[He]??[])],ln=E.refresh&&!E.cursor?await Ly(Qe,Le,He=>M.listAgentWorkspaceSessions(D,f,{cursor:He,limit:200,refresh:!1}),Ge==null?void 0:Ge.id):Le;if(u.current!==D||Yt.current.get($)!==ee)return;const Yn=Rp(Qe,ln,!E.cursor,Ut.current===f?Nt.current:null).map(He=>({...He,projectId:He.projectId??f})),Sr=El(Yn.filter(He=>!He.parentSessionId),D),Es=Ut.current,kr=Nt.current,Rt=zy(Sr,Ge);Es===f&&kr&&!Yn.some(He=>He.id===kr)&&!Rt.some(He=>He.id===kr)&&St(sl);const Ir={};for(const He of Yn.filter(De=>De.parentSessionId))(Ir[Ie=He.parentSessionId]??(Ir[Ie]=[])).push(He);for(const He of Object.values(Ir))He.sort((De,di)=>De.created.localeCompare(di.created));rr(He=>({...He,[f]:My(Qe,ln,!E.cursor,He[f])})),be(He=>{const De=new Set(He);return ln.stale?De.add(f):De.delete(f),De});const kt={...Te.current,[f]:Rt},Xn={...Ue.current};for(const He of ot)delete Xn[He];for(const[He,De]of Object.entries(Ir))Xn[He]=De;Te.current=kt,Ue.current=Xn,R(kt),nr(Xn),fr(He=>{const De=new Set(He).add(f);return Hn.current=De,De})}catch(Le){if(Yt.current.get($)!==ee)return;be(We=>new Set(We).add(f)),G(We=>({...We,[f]:Le instanceof Error?Le.message:"会话加载失败"}))}finally{Yt.current.get($)===ee&&U(Le=>{const We=new Set(Le);return We.delete(f),wt.current=We,We})}}const _o=async f=>{if(!window.agentApi)return;const E=await window.agentApi.listChildSessions(f);nr(M=>({...M,[f]:E.sort((D,$)=>D.created<$.created?-1:1)}))},oi=(f,E)=>{const M=Qt.current.find(D=>D.id===f);!M||M.canCreateSession===!1||zn(E,f)},Dn=()=>mu({kind:"new-session"});c.useEffect(()=>{var f;window.agentApi&&(Pn(u.current,{refresh:(((f=i.current.agents[u.current])==null?void 0:f.workspaces.length)??0)>0}),ga.getState().loadFromSystem(),window.agentApi.getRuntimeHealth().then(Ye).catch(()=>{}))},[]),c.useEffect(()=>{if(Lt)return;const f=window.setInterval(()=>{!Dt()||y||Pn(o,{refresh:!0,since:k,refreshLoadedSessions:!1})},15e3);return()=>window.clearInterval(f)},[o,Lt,y,k]),c.useEffect(()=>{if(!window.agentApi||Lt)return;let f=!1;const E=()=>{if(f||!Dt())return;const ee=Uy(dt,Cn),te=Hy(ee,Zs.current,wt.current);for(const Ie of te)an(Ie,{refresh:!0,background:Hn.current.has(Ie)})},M=()=>{Dt()&&E()};Ze&&xn&&E();const D=window.setInterval(E,1e4);window.addEventListener("focus",E),window.addEventListener("pageshow",E),document.addEventListener("visibilitychange",M);const $=rt&&window.parent!==window?window.parent:null;return $==null||$.addEventListener("focus",E),$==null||$.addEventListener("pageshow",E),()=>{f=!0,window.clearInterval(D),window.removeEventListener("focus",E),window.removeEventListener("pageshow",E),document.removeEventListener("visibilitychange",M),$==null||$.removeEventListener("focus",E),$==null||$.removeEventListener("pageshow",E)}},[o,Lt,Cn,dt,Ze,xn,rt]),c.useEffect(()=>{if(!dt||!window.agentApi)return;const f=d.find(M=>M.id===dt),E=f==null?void 0:f.description;E&&window.agentApi.setProjectWorkingDir(E)},[dt,d]);const Et=f=>{St(Zo(f));const E=!Cn.has(f);if(pn(M=>{const D=new Set(M);return E?D.add(f):D.delete(f),D}),E&&!wt.current.has(f)){const M=Hn.current.has(f),D=Qt.current.find(ee=>ee.id===f),$=ou(u.current,D,M);an(f,{refresh:$,background:M})}},ai=async f=>{if(!window.agentApi)throw new Error("agentApi 未就绪,请重启应用");const E=f.replace(/\\/g,"/"),M=E.split("/").filter(Boolean),D=M[M.length-1]||E||"导入的项目",$=await window.agentApi.importAgentWorkspace(u.current,E,D);await Pn(u.current,{refresh:!0,refreshLoadedSessions:!1}),St(Zo($.workspace.workspaceId)),await an($.workspace.workspaceId,{refresh:!0}),pn(ee=>{const te=new Set(ee);return te.add($.workspace.workspaceId),te}),Oe($.existing?"该文件夹已在当前 Agent 的目录中":`已导入:${$.workspace.name}`),ct($.existing?"info":"success"),setTimeout(()=>Oe(null),3e3)},Is=async()=>{try{if(!window.agentApi){Oe("agentApi 未就绪,请重启应用"),ct("error");return}if(rt){L(!0);return}const f=await window.agentApi.openFileDialog();if(console.log("[import] selectedPath:",f),!f)return;await ai(f)}catch(f){console.error("[import] error:",f),Oe(f instanceof Error?f.message:String(f)),ct("error"),setTimeout(()=>Oe(null),5e3)}},ka=async f=>{if(window.agentApi)try{await window.agentApi.deleteProject(f),dt===f&&(gr(null),kn(null),Me([])),Oe("项目删除成功"),ct("success"),setTimeout(()=>Oe(null),2500),await Pn()}catch(E){Oe(E instanceof Error?E.message:"项目删除失败"),ct("error"),setTimeout(()=>Oe(null),4e3)}},Cs=(f,E,M)=>{var ee;const D=(ee=window.agentApi)==null?void 0:ee.showDirectoryContextMenu,$=$y(E,{isInvalid:M,supported:typeof D=="function",webShell:rt});!$||!D||(f.preventDefault(),D($).catch(te=>{Oe(te instanceof Error?te.message:"无法打开当前文件夹"),ct("error"),setTimeout(()=>Oe(null),4e3)}))},zt=(f,E)=>{oe({session:f,anchor:E})},Qr=(f,E)=>{const M=E.getBoundingClientRect();X({project:f,agentType:u.current,anchor:{top:M.top,left:M.left,width:M.width,height:M.height}})},li=async()=>{if(!window.agentApi||!W||ke)return;const{project:f,agentType:E}=W;_e(!0);try{await window.agentApi.removeInvalidAgentWorkspace(E,f.id),u.current===E&&Ut.current===f.id&&St(sl),Oe(`已移除失效目录「${f.name}」`),ct("success"),setTimeout(()=>Oe(null),2500),u.current===E&&await Pn(E,{refresh:!0})}catch(M){Oe(M instanceof Error?M.message:"目录删除失败"),ct("error"),setTimeout(()=>Oe(null),4e3)}finally{_e(!1),X(null)}},ci=async()=>{if(!window.agentApi||!Pe||Ne)return;const{session:f}=Pe;at(!0);try{await window.agentApi.deleteSession(f.id);const E=f.projectId??Ut.current,M=f.agentType;if(E){const ee=`${M}:${E}`;Yt.current.set(ee,(Yt.current.get(ee)??0)+1)}const D=Yb(Te.current,Ue.current,[],f.id);Te.current=D.sessionsByProject,Ue.current=D.childSessionsByParent,R(D.sessionsByProject),nr(D.childSessionsByParent),en(D.removedIds);const $=i.current.agents[M];if($){const ee={...i.current,agents:{...i.current.agents,[M]:Kb($,D.removedIds)}};i.current=ee,nu(ee)}Nt.current&&D.removedIds.includes(Nt.current)&&St({projectId:Ut.current,sessionId:null}),Oe("会话删除成功"),ct("success"),setTimeout(()=>Oe(null),2500),oe(null),it(ee=>ee+1),E&&M===u.current&&an(E,{refresh:!0,background:!0})}catch(E){Oe(E instanceof Error?E.message:"会话删除失败"),ct("error"),setTimeout(()=>Oe(null),4e3)}finally{at(!1)}},Mo=[{id:"settings",label:"设置"},{id:"mcp",label:"MCP"},{id:"memory",label:"记忆"},{id:"skill",label:"技能"},{id:"agent",label:"智能体"},{id:"lsp",label:"LSP"}],Jt=(f,E)=>{const M=ut===f.id,D=so(An(f,E)),$=$t[f.id]??[],ee=!In.has(f.id);return t.jsxs("div",{className:"sidebar-session-tree",children:[t.jsx(oo,{session:{id:f.id,title:f.title,visualState:D,statusLabel:io[D],occupiedExternally:f.agentType!=="codex"&&f.occupancy==="owned-externally",canDelete:f.canDelete,active:M,hasChildren:$.length>0,expanded:ee,compatibility:f.compatibility,pinned:Wr.has(f.id)},onSelect:()=>{Ze&&tn(!1),H(!1),St(il(E,f.id)),$.length>0&&as(te=>{const Ie=new Set(te);return Ie.has(f.id)?Ie.delete(f.id):Ie.add(f.id),Ie})},onPin:()=>hs(f.id),onDelete:te=>zt(f,te)}),t.jsx("div",{className:"sidebar-child-sessions",style:{maxHeight:ee?$.length*40:0,opacity:ee?1:0},children:$.map(te=>{const Ie=so(An(te,E));return t.jsx(oo,{session:{id:te.id,title:te.title,visualState:Ie,statusLabel:io[Ie],occupiedExternally:te.agentType!=="codex"&&te.occupancy==="owned-externally",canDelete:te.canDelete,active:ut===te.id,child:!0,compatibility:te.compatibility},deleteLabel:"删除子会话",onSelect:()=>{Ze&&tn(!1),H(!1),St(il(E,te.id))},onDelete:Le=>zt(te,Le)},te.id)})})]},f.id)};return t.jsxs("div",{className:`app-shell${Qn?" is-sidebar-collapsed":""}${Ss?" is-sidebar-dragging":""}${Hs?" has-workspace-tabs":""}`,"data-desktop-platform":!rt&&/Mac/.test(navigator.platform)?"darwin":void 0,style:{display:"flex",height:rt?"100dvh":"100vh",width:"100vw",background:"var(--bg-deepest)",position:"relative",overflow:"hidden",boxSizing:"border-box",paddingTop:Hs?52:0},children:[t.jsx(Ub,{}),t.jsx(kb,{onOpen:ar}),wa&&Wt.createPortal(t.jsx(Qf,{cwd:Gr||void 0,health:pt,onClose:()=>Gs(!1),onCreated:f=>{Gs(!1),Vs(E=>E+1),fs(f)}}),document.body),Hs&&t.jsx(Eb,{groups:En,dashboardVisible:bo,sessionDashboardVisible:Ni,messagingVisible:fn,activeId:xr?"messaging":or?"sessions":Rn?"dashboard":ir??"assistant",onSelect:f=>{H(f==="messaging"),Xt(f==="sessions"),Ht(f==="dashboard"),yt(["assistant","dashboard","sessions","messaging"].includes(f)?null:f)},onClose:f=>{f==="messaging"?(H(!1),gn(!1)):f==="sessions"?(ls(!1),Xt(!1)):f==="dashboard"?(Us(!1),Ht(!1)):(qs(E=>E.filter(M=>M.id!==f)),ir===f&&yt(null))}}),(xr||ir||Rn||or)&&t.jsx("div",{className:"collab-desktop-overlay",children:t.jsx("div",{className:"collab-desktop-body",children:xr?t.jsx(Zf,{onClose:()=>{H(!1),gn(!1)},onOpenSession:f=>{var D;const E=f.routing.decision,M=(D=f.routing.candidates)==null?void 0:D.find($=>$.projectId===(E==null?void 0:E.projectId));f.execution.sessionId&&(E!=null&&E.agentType)&&M&&(H(!1),_t.current({kind:"session",session:{id:f.execution.sessionId,agentType:E.agentType,title:f.source.conversationName,cwd:M.description,projectId:E.projectId}}))}}):or?t.jsx(Xf,{onNewSession:Dn,onOpenGroup:f=>_t.current({kind:"group",groupId:f.group.id,title:f.group.name,discussionId:f.discussionId}),onOpenSession:f=>_t.current({kind:"session",session:f}),onViewAgent:f=>_t.current({kind:"agent",agentType:f}),onViewGroups:Pr,onClose:()=>{Xt(!1),ls(!1)}}):Rn?t.jsx(Kf,{cwd:Gr||void 0,onOpen:fs,onClose:()=>{Ht(!1),Us(!1)},onChanged:(f,E)=>{Vs(M=>M+1),qs(M=>E?M.map(D=>D.id===f?E:D):M.filter(D=>D.id!==f)),!E&&ir===f&&yt(null)}}):ir&&t.jsx(Tf,{groupId:ir,initialDiscussionId:va[ir]},`${ir}-${wo}`)})}),t.jsx(Hb,{}),!Lt&&!Ze&&!Ln&&t.jsx(Cy,{hidden:!Qn,value:o,health:pt,selectedSessionId:ut,getActivity:An,onChange:on,onUnavailable:f=>{Oe(f),ct("info"),setTimeout(()=>Oe(null),3e3)},onSelect:dr}),!Ln&&Ze&&xn&&t.jsx("div",{className:"mobile-drawer-scrim",onClick:()=>tn(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,.45)",zIndex:1150}}),!Ln&&Ze&&!xn&&t.jsx("button",{className:"mobile-drawer-toggle",onClick:()=>tn(!0),"aria-label":"会话列表","aria-expanded":!1,style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 8px)",left:10,zIndex:1250,width:34,height:34,borderRadius:9,border:"1px solid var(--border-default)",background:"var(--bg-glass, rgba(18,20,28,.82))",color:"var(--text-secondary)",display:"grid",placeItems:"center",backdropFilter:"blur(8px)",WebkitAppRegion:"no-drag",cursor:"pointer"},children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("path",{d:"M3 6h18M3 12h18M3 18h18"})})}),t.jsx("div",{className:"app-accent-glow",style:{position:"absolute",top:"-120px",left:"-80px",width:320,height:320,borderRadius:"50%",background:"radial-gradient(circle, var(--accent-glow) 0%, transparent 70%)",pointerEvents:"none",zIndex:0}}),Gt!=="focus"&&!Ln&&t.jsxs(t.Fragment,{children:[t.jsxs("aside",{className:`app-sidebar${Zt==="agent-rail"?" has-agent-navigation":""}${Lt?" has-all-sessions":""}`,id:"workspace-sidebar","aria-hidden":Qn||Ze&&!xn,ref:f=>{f&&(f.inert=Qn||Ze&&!xn)},style:{width:Vn,flexShrink:0,marginLeft:Qn?-Vn:0,display:"flex",flexDirection:"column",background:"var(--bg-surface)",borderRight:"1px solid var(--border-subtle)",padding:rt?"12px 0 0":"56px 0 0",position:"relative",zIndex:10,overflow:"hidden",...Ze?{position:"fixed",top:0,bottom:0,left:0,width:"min(82vw, 320px)",zIndex:1200,transform:xn?"translateX(0)":"translateX(-103%)",transition:"transform .24s ease",boxShadow:"12px 0 32px rgba(0,0,0,.5)",padding:"calc(env(safe-area-inset-top) + 12px) 0 0"}:{}},children:[!rt&&t.jsx("div",{className:"sidebar-window-drag-region","aria-hidden":"true"}),Zt==="agent-rail"?t.jsx(ky,{value:o,health:pt,onClose:()=>{Ze?tn(!1):jr()}}):t.jsx("div",{className:"app-sidebar-brand",style:{padding:"0 20px 10px"},children:t.jsxs("div",{className:"sidebar-brand-row",children:[t.jsx("div",{className:"sidebar-brand-mark","aria-hidden":"true",children:t.jsx(_r,{agentType:"customer-agent",size:24})}),t.jsx("span",{className:"sidebar-brand-name",children:"AgentRoam"}),t.jsxs("div",{className:"sidebar-brand-actions",children:[t.jsx(Ip,{}),!rt&&Zt==="classic"&&t.jsx(Xd,{onOpenFlowStudio:ge,openingFlowStudio:Ct})]})]})}),Lt?t.jsx(vb,{selectedSessionId:ut,runningSessionId:qn,needsInput:Js,pinnedIds:Ks,revision:Je,onSelect:f=>_t.current({kind:"session",session:f}),onPin:hs,onDelete:(f,E)=>{window.agentApi.getSession(f.id,{limit:1}).then(M=>{const D=M;if(D.id!==f.id||D.agentType!==f.agentType)throw new Error("会话身份已变化,请刷新重试");if(!D.canDelete)throw new Error("当前会话暂不可删除");zt(D,E)}).catch(M=>{Oe(M instanceof Error?M.message:"无法读取会话"),ct("error")})}}):t.jsxs(t.Fragment,{children:[t.jsx(uu,{vertical:Zt==="agent-rail",value:o,health:pt,onChange:on,onUnavailable:f=>{Oe(f),ct("info"),setTimeout(()=>Oe(null),3e3),window.agentApi.getRuntimeHealth().then(Ye).catch(()=>{})}}),t.jsxs("button",{type:"button",className:"sidebar-search-field",onClick:()=>{O(!0),Se(10)},title:"搜索会话","aria-label":"搜索会话",children:[t.jsx(fa,{size:15,"aria-hidden":"true"}),t.jsx("span",{children:"搜索会话"}),t.jsx("kbd",{children:"⌘ K"})]}),t.jsxs("div",{className:"sidebar-project-toolbar",children:[t.jsxs("div",{className:"sidebar-project-heading",children:[t.jsx("span",{className:"sidebar-project-title",children:"目录"}),t.jsx("span",{className:"sidebar-project-count","aria-label":`${d.length} 个目录`,children:d.length})]}),t.jsxs("div",{className:"sidebar-project-actions",children:[t.jsx("button",{type:"button",onClick:f=>{Gn?Io():ko(),lu(f,Gn)},title:Gn?"展开全部会话":"折叠全部会话","aria-label":Gn?"展开全部会话":"折叠全部会话","aria-pressed":Gn,disabled:sn.length===0,className:`ui-icon-button sidebar-collapse-all${Gn?" is-active":""}`,children:t.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Gn?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"m7 6 5 5 5-5"}),t.jsx("path",{d:"m7 13 5 5 5-5"})]}):t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"m17 11-5-5-5 5"}),t.jsx("path",{d:"m17 18-5-5-5 5"})]})})}),t.jsx("button",{type:"button",onClick:f=>{mn(!hn),lu(f,hn)},title:hn?"按新建时间排序":"进行中会话优先","aria-label":hn?"按新建时间排序":"进行中会话优先","aria-pressed":hn,className:`ui-icon-button sidebar-session-sort${hn?" is-active":""}`,children:t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M3 6h10M3 12h7M3 18h4"}),t.jsx("path",{d:"m15 9 3-3 3 3M18 6v12"})]})}),t.jsx(wp,{loading:y,error:j,onRefresh:()=>void Pn(o,{refresh:!0})}),t.jsx("button",{type:"button",onClick:()=>void Is(),title:"导入目录","aria-label":"导入目录",className:"ui-icon-button",children:t.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M12 5v14M5 12h14"})})})]})]}),t.jsx("div",{ref:Or,className:"app-sidebar-scroll",onPointerDownCapture:Qy,onScroll:f=>{const E=f.currentTarget;if(E.scrollHeight-E.scrollTop-E.clientHeight<120&&h&&!y&&Pn(o,{cursor:h}),Ze){const D=E.getBoundingClientRect(),$=E.querySelectorAll("[data-sidebar-project-id]");for(const ee of $){const te=ee.dataset.sidebarProjectId;if(!te||!Cn.has(te))continue;const Ie=ee.getBoundingClientRect();if(Ie.bottom<D.top||Ie.bottom>D.bottom+120)continue;const Le=Xe[te];Le&&!wt.current.has(te)&&an(te,{cursor:Le})}}},style:{minHeight:0,flex:1,overflow:"auto",padding:"0 10px"},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,marginBottom:12},children:[Ur.length>0&&t.jsxs("section",{className:"sidebar-pinned-section","aria-label":"置顶会话",children:[t.jsx("div",{className:"sidebar-pinned-heading",children:"置顶"}),Ur.map(({projectId:f,session:E})=>Jt(E,f))]}),No.map(f=>{var ot;const E=dt===f.id&&ut===null,M=Cn.has(f.id),D=lt.has(f.id),$=os.has(f.id),ee=Z[f.id],te=z[f.id]??[],Ie=te.filter(Qe=>!Wr.has(Qe.id)),We=hn?Rl(Ie,ms):Ie,Ge=We.length>10,de=gt.has(f.id);return t.jsxs("div",{className:"sidebar-project-block","data-sidebar-project-id":f.id,"aria-busy":$,children:[t.jsxs("div",{className:`sidebar-row sidebar-project-row${de?" sidebar-project-row--invalid":""} ${E&&!de?"sidebar-row-active":""}`,onContextMenu:Qe=>Cs(Qe,f,de),style:{paddingRight:4},children:[t.jsxs("button",{className:"sidebar-project-button",onClick:()=>{de||Et(f.id)},disabled:de,"aria-expanded":M,"aria-pressed":E,title:de?`路径不存在:${f.description}`:f.name,style:{flex:1,display:"flex",alignItems:"center",gap:8,minWidth:0,padding:"8px 10px",border:"none",background:"transparent",color:de?"var(--text-muted)":E?"var(--accent)":"var(--text-secondary)",fontSize:13,fontWeight:E&&!de?600:400,cursor:de?"not-allowed":"pointer",textAlign:"left",transition:"color 0.15s"},children:[de?t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:.6},children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):f.canCreateSession===!1?t.jsx(Af,{size:13,"aria-hidden":"true",style:{flexShrink:0,opacity:E?1:.5}}):t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:E?1:.5},children:M?t.jsx("path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6A2 2 0 0 1 18.46 20H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}):t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),t.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.name})]}),o==="customer-agent"&&!rt&&!de&&f.canCreateSession!==!1?t.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),ka(f.id)},title:"删除目录","aria-label":`删除目录:${f.name}`,className:"sidebar-project-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",style:{flexShrink:0},children:t.jsx(au,{})}):de?t.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),Qr(f,Qe.currentTarget)},title:"删除失效目录","aria-label":`删除失效目录:${f.name}`,className:"sidebar-project-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",style:{flexShrink:0},children:t.jsx(au,{})}):null,!de&&f.canCreateSession!==!1&&t.jsx("button",{type:"button",onClick:Qe=>{Qe.stopPropagation(),oi(f.id,o)},title:`在 ${f.name} 中新建会话`,"aria-label":`在 ${f.name} 中新建会话`,disabled:de||((ot=pt.find(Qe=>Qe.agentType===o))==null?void 0:ot.available)===!1,className:"sidebar-runtime-create sidebar-project-add-action ui-icon-button ui-icon-button--small",children:t.jsx(gl,{size:13,"aria-hidden":"true"})})]}),t.jsx("div",{style:{overflow:"hidden",maxHeight:M?Ze?1e5:Ge?300:800:0,opacity:M?1:0,transition:"max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease"},children:t.jsxs("div",{className:"sidebar-project-sessions",onScroll:Qe=>{const ln=Qe.currentTarget,Yn=ln.scrollHeight-ln.scrollTop-ln.clientHeight<80,Sr=Xe[f.id];Yn&&Sr&&!$&&an(f.id,{cursor:Sr})},style:{display:"flex",flexDirection:"column",gap:1,marginTop:2,paddingLeft:10,paddingBottom:4,...Ge&&!Ze?{maxHeight:280,overflowY:"auto"}:{}},children:[We.map(Qe=>Jt(Qe,f.id)),$&&!D&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"正在加载会话..."}),ee&&!Xe[f.id]&&t.jsxs("div",{title:ee,style:{display:"flex",alignItems:"center",gap:8,color:"var(--danger)",fontSize:11,padding:"4px 10px"},children:[t.jsx("span",{style:{flex:1},children:"会话加载失败"}),t.jsx("button",{type:"button",onClick:()=>void an(f.id,{refresh:D,background:D}),style:{border:0,background:"transparent",color:"inherit",fontSize:11,cursor:"pointer",padding:0},children:"重试"})]}),J.has(f.id)&&!ee&&t.jsx("div",{className:"sidebar-cache-state",children:"显示缓存,会话将在下次刷新时更新"}),te.length===0&&D&&!$&&!ee&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"暂无会话"}),t.jsx(wb,{cursor:Xe[f.id]??null,expanded:M&&D&&!de,loading:$,error:ee,nestedScroll:Ge&&!Ze,projectName:f.name,onLoadMore:()=>{const Qe=Xe[f.id];Qe&&an(f.id,{cursor:Qe})}})]})})]},f.id)}),d.length===0&&y&&t.jsx("div",{className:"sidebar-directory-skeleton","aria-hidden":"true",children:[0,1,2].map(f=>t.jsxs("div",{children:[t.jsx("span",{}),t.jsx("span",{})]},f))}),d.length===0&&!y&&!j&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"24px 10px",textAlign:"center",opacity:.7},children:"暂无目录"}),v&&!j&&t.jsx("div",{className:"sidebar-cache-state",children:"当前显示缓存目录"}),j&&t.jsxs("div",{className:"sidebar-load-error",title:j,children:[t.jsx("span",{children:d.length>0?"目录刷新失败,当前显示缓存":"目录加载失败"}),t.jsx("button",{type:"button",onClick:()=>void Pn(o,{refresh:d.length>0}),children:"重试"})]})]})})]}),t.jsxs("div",{className:"sidebar-bottom-action",children:[!Lt&&t.jsx(jb,{refreshKey:wo,onOpen:fs}),t.jsxs("button",{type:"button",className:"sidebar-new-session-primary",title:"新建会话",onClick:Dn,children:[t.jsx(gl,{size:16,"aria-hidden":"true"}),t.jsx("span",{children:"新建会话"})]})]})]}),Pe&&t.jsx(eu,{message:Qb(Pe.session),anchor:Pe.anchor,mobile:Ze,pending:Ne,onCancel:()=>oe(null),onConfirm:()=>void ci()}),W&&t.jsx(eu,{title:"删除失效目录",message:`目录「${W.project.name}」的路径(${W.project.description||"未知"})已不存在。确定从目录列表移除?历史会话记录会保留。`,anchor:W.anchor,mobile:Ze,pending:ke,onCancel:()=>X(null),onConfirm:()=>void li()}),!Ze&&t.jsx("div",{className:`app-sidebar-resizer${Ss?" is-dragging":""}`,...Bt,role:"separator","aria-label":"调整目录与会话列表宽度","aria-controls":"workspace-sidebar","aria-orientation":"vertical","aria-valuemin":220,"aria-valuemax":480,"aria-valuenow":Vn,tabIndex:Kt?-1:0,hidden:Kt&&!Ss,style:{left:Kt?0:Vn}}),F&&t.jsx("div",{onClick:()=>O(!1),style:{position:"fixed",inset:0,zIndex:1300,background:"rgba(17,24,39,0.34)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"12vh 16px 16px"},children:t.jsxs("div",{onClick:f=>f.stopPropagation(),style:{width:"min(560px, 100%)",maxHeight:"64vh",display:"flex",flexDirection:"column",borderRadius:12,border:"1px solid var(--border-default)",background:"var(--bg-surface)",boxShadow:"0 18px 48px rgba(17,24,39,0.28)",overflow:"hidden"},children:[t.jsx("div",{style:{padding:10,borderBottom:"1px solid var(--border-subtle)"},children:t.jsx("input",{autoFocus:!0,value:N,onChange:f=>T(f.target.value),onKeyDown:f=>{f.key==="Escape"&&O(!1)},placeholder:"搜索所有会话(标题或目录)…","aria-label":"搜索所有会话",style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",boxSizing:"border-box"}})}),t.jsxs("div",{style:{overflowY:"auto",padding:8},children:[se&&t.jsx("div",{role:"status",children:"正在加载所有会话"}),Y&&t.jsx("div",{role:"alert",children:Y}),yn&&jt&&jt.length>0&&t.jsxs("div",{style:{padding:"4px 10px 3px",fontSize:9,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-muted)"},children:[jt.length," 个结果"]}),!se&&!Y&&yn&&jt&&jt.length===0&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"无匹配会话"}),!se&&!Y&&!yn&&wr.length===0&&t.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"暂无会话"}),(jt??wr.slice(0,Q)).map(f=>{const E=ut===f.id,M=so(An(f));return t.jsx(oo,{session:{id:f.id,title:f.title,visualState:M,statusLabel:io[M],occupiedExternally:f.agentType!=="codex"&&f.occupancy==="owned-externally",canDelete:f.canDelete,active:E,child:!!f.parentSessionId,compatibility:f.compatibility,pinned:Wr.has(f.id)},onSelect:()=>{const D=f.projectId&&d.some($=>$.id===f.projectId)?f.projectId:null;H(!1),St(il(D,f.id)),O(!1),Ze&&tn(!1)},onPin:f.parentSessionId?void 0:()=>hs(f.id),onDelete:D=>zt(f,D)},f.id)}),!yn&&wr.length>Q&&t.jsx("button",{type:"button",onClick:()=>Se(f=>f+10),style:{width:"100%",padding:"8px 10px",border:0,borderTop:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-muted)",fontSize:12,cursor:"pointer",textAlign:"center"},children:"更多…"})]})]})})]}),t.jsx(Fl,{message:To,type:Ao}),t.jsxs("main",{className:`app-main${nn?" file-workspace-capable":""}${$r&&nn?" file-workspace-open":""}${$r&&nn&&_i?" file-workspace-preview-open":""}`,style:{flex:1,minWidth:0,marginLeft:Qn&&!Ln?56:0,overflow:"hidden",background:"var(--bg-workspace)",position:"relative",zIndex:5},children:[t.jsx("div",{className:"app-chat-surface","aria-hidden":Ce?!0:void 0,ref:f=>{f&&(f.inert=!!Ce)},style:{height:"100%",paddingTop:0,display:xo?"none":void 0,background:"var(--chat-history-bg)"},children:t.jsx(hb,{sidebarCollapsed:Qn,onToggleSidebar:!Ze&&!Ln?()=>{Gt==="focus"?(br("standard"),Kt&&jr()):jr()}:void 0,onOpenCollaborationDashboard:rt?void 0:Pr,onOpenSessionDashboard:rt?void 0:ar,onOpenMessaging:rt?void 0:ps,activeAgentType:o,selectedProjectId:dt,selectedSessionId:ut,sessionTitle:ti,sessionSummary:Mn,initialSessionHistory:ds,onSessionHistorySettled:zr,workspacePath:Gr,workspaceSource:(Kn=d.find(f=>f.id===dt))==null?void 0:Kn.source,runtimeHealth:pt,onSelectAgent:zn,workspaces:d.map(f=>({id:f.id,name:f.name,path:f.description,canCreateSession:f.canCreateSession})),onSelectWorkspace:f=>{us.current=null,St(Zo(f)),pn(E=>new Set(E).add(f))},onPickWorkspaceFolder:()=>void Is(),focusComposerNonce:cs,voiceCommand:Br,onOpenSettings:js,settingsOpen:mr,desktopLiveOpen:sr,fileDrawerOpen:$r,onOpenArtifact:ys,onToggleFiles:nn?()=>{Ys(f=>!f),Xs("files")}:void 0,onOpenDesktopLive:!rt&&((vn=window.agentApi)!=null&&vn.desktopLiveGetStatus)?()=>mo(!0):void 0,onHideToBackground:()=>void ws(),onOpenHub:(Jn=window.agentApi)!=null&&Jn.hubGetConfig?()=>Tt(!0):void 0,headerAppActions:!rt&&Zt!=="classic"?t.jsx(Xd,{onOpenFlowStudio:ge,openingFlowStudio:Ct}):void 0,onToggleAppearance:Fr,appearanceOpen:lr,hideToBackgroundTitle:Nn?`隐藏到后台(说“${Tn}”唤醒)`:"隐藏到后台",onSessionCreated:(f,E)=>{var D;Mr(E??null);const M=Ut.current;if(M&&E){const $=`${E.agentType}:${M}`;Yt.current.set($,(Yt.current.get($)??0)+1),wt.current.delete(M),U(new Set(wt.current));const ee={...Te.current,[M]:[{...E,projectId:M},...(Te.current[M]??[]).filter(te=>te.id!==f)]};Te.current=ee,R(ee)}St({projectId:M,sessionId:f}),it($=>$+1),vs.current&&(vs.current=!1,Un.current={sessionId:f,until:Date.now()+9e4},(D=window.agentApi)==null||D.wakeConversation(!0)),M&&u.current==="customer-agent"&&an(M,{pendingSession:E,background:!0})},onSubSessionCreated:async f=>{await _o(f)},onSelectSession:f=>{kn(f)},onParallelSessionSelected:f=>{var M;(M=nt.current)==null||M.abort(),nt.current=null,Mt.current=null,At(null),Lr(void 0),u.current!==f.agentType&&on(f.agentType),Mr(f);const E=f.projectId&&Qt.current.some(D=>D.id===f.projectId)?f.projectId:null;St({projectId:E,sessionId:f.id}),Re.getState().setSessionId(f.id),it(D=>D+1)},onSubAgentEvent:f=>{f.type==="started"?ii({type:"info",title:"子会话已启动",body:`${f.agentName}:${f.task.slice(0,60)}`,sessionId:f.subSessionId}):f.type==="completed"?ii({type:"success",title:"子会话已完成",body:`${f.agentName}:${f.task.slice(0,60)}`,sessionId:f.subSessionId}):ii({type:"error",title:"子会话出错",body:`${f.agentName}:${f.task.slice(0,60)}`,sessionId:f.subSessionId})},onMessageSent:(f,E)=>{R(M=>{const D={};for(const[$,ee]of Object.entries(M))D[$]=ee.map(te=>te.id===f?{...te,title:E.slice(0,60)||te.title}:te);return D})},onRunComplete:async(f,E)=>{var ee;const M=Un.current,D=Yx(M,E);Un.current=D,D!==M&&((ee=window.agentApi)==null||ee.wakeConversation(!0));const $=f||dt;$&&await an($,{refresh:!0,background:!0})}})}),Ce&&t.jsx(vu,{className:"session-navigation-loading"}),xo&&t.jsx(Bb,{conversationId:ut,onExit:()=>Tt(!1)}),nn&&t.jsx(Ny,{open:$r,tab:xs,gateway:nn,cwd:Gr,selectedPath:_i,revealRequest:ja,onTabChange:Xs,onSelectPath:bs,onClose:()=>Ys(!1)}),Ln&&t.jsx(Ey,{entryUrl:Ln,onBack:()=>ni(null)})]}),sr&&t.jsx(dy,{onClose:()=>mo(!1)}),mr&&Wt.createPortal(t.jsx("div",{onClick:()=>It(!1),style:{position:"fixed",inset:0,zIndex:10001,background:"rgba(17,24,39,0.18)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s var(--ease-out)",WebkitAppRegion:"no-drag"},children:t.jsxs("div",{onClick:f=>f.stopPropagation(),style:{width:"min(920px, calc(100vw - 48px))",height:"min(760px, calc(100vh - 48px))",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"var(--shadow-md)",overflow:"hidden",display:"flex",flexDirection:"column",animation:"fadeInUp 0.25s var(--ease-out)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)",padding:"8px 10px",background:"var(--bg-deepest)"},children:[t.jsx("div",{style:{display:"flex",gap:6},children:Mo.map(f=>t.jsx("button",{onClick:()=>Dr(f.id),className:`settings-tab ${Fn===f.id?"settings-tab-active":""}`,children:f.label},f.id))}),t.jsx("button",{onClick:()=>It(!1),title:"关闭",className:"ui-icon-button ui-icon-button--close ui-icon-button--danger",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[Fn==="settings"&&t.jsx(iy,{}),Fn==="mcp"&&t.jsx(uy,{}),Fn==="memory"&&t.jsx(py,{}),Fn==="skill"&&t.jsx(gy,{}),Fn==="agent"&&t.jsx(xy,{}),Fn==="lsp"&&t.jsx(yy,{})]})]})}),document.body),t.jsx("div",{className:"noise-overlay"}),lr&&yr&&Wt.createPortal(t.jsx("div",{onClick:()=>_n(!1),style:{position:"fixed",inset:0,zIndex:1e4,WebkitAppRegion:"no-drag"},children:t.jsxs("div",{onClick:f=>f.stopPropagation(),className:"appearance-panel",style:{position:"absolute",left:Math.max(12,Math.min(yr.right-320,window.innerWidth-332)),top:yr.bottom+8,width:320,maxHeight:`calc(100vh - ${yr.bottom+20}px)`,overflowY:"auto",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"16px",display:"flex",flexDirection:"column",gap:16,animation:"fadeInUp 0.2s var(--ease-out)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"皮肤"}),t.jsx("div",{className:"appearance-choices",children:Sf.map(f=>t.jsxs("button",{onClick:()=>gs(f.id),className:`appearance-choice ${ht===f.id?"appearance-choice-active":""}`,children:[t.jsx("span",{className:"appearance-swatch",style:{background:`linear-gradient(135deg, ${f.preview[0]} 55%, ${f.preview[1]} 55%)`}}),t.jsx("span",{className:"appearance-choice-label",style:{fontWeight:ht===f.id?600:400},children:f.label}),ht===f.id&&t.jsx("svg",{className:"appearance-choice-check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"m5 12 4 4L19 6"})})]},f.id))})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"布局"}),t.jsx("div",{className:"appearance-segmented",children:kf.map(f=>t.jsx("button",{onClick:()=>br(f.id),title:f.description,className:`appearance-segment ${Gt===f.id?"appearance-segment-active":""}`,children:f.label},f.id))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,borderTop:"1px solid var(--border-subtle)",paddingTop:12},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em"},children:"语音"}),t.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--text-secondary)",cursor:"pointer"},children:["助手回复自动播报",t.jsx("input",{className:"appearance-switch",type:"checkbox",checked:Qs,onChange:f=>So(f.target.checked)})]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--text-secondary)",cursor:"pointer"},children:["隐藏后语音唤醒",t.jsx("input",{className:"appearance-switch",type:"checkbox",checked:Nn,onChange:f=>jo(f.target.checked)})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-secondary)"},children:[t.jsx("span",{style:{flexShrink:0},children:"唤醒词"}),t.jsx("input",{value:Tn,onChange:f=>Ti(f.target.value||"小智"),style:{flex:1,padding:"4px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-deep)",color:"var(--text-primary)",fontSize:12}})]})]})]})}),document.body),t.jsx(Jf,{open:A,onCancel:()=>L(!1),onConfirm:async f=>{await ai(f),L(!1)}}),t.jsx(vy,{trigger:Sa,heardText:rn}),Vr.length>0&&Wt.createPortal(t.jsx("div",{style:{position:"fixed",bottom:24,right:24,zIndex:2e4,display:"flex",flexDirection:"column",gap:10,alignItems:"flex-end",pointerEvents:"none"},children:Vr.map(f=>t.jsxs("div",{style:{pointerEvents:"auto",width:320,background:"var(--bg-surface)",border:`1px solid ${f.type==="error"?"rgba(220,38,38,0.25)":f.type==="success"?"rgba(5,150,105,0.25)":"var(--border-default)"}`,borderLeft:`3px solid ${f.type==="error"?"var(--danger)":f.type==="success"?"var(--success)":"var(--accent)"}`,borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"12px 14px",animation:"fadeInUp 0.22s var(--ease-out)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[t.jsxs("span",{style:{fontSize:12,fontWeight:600,color:f.type==="error"?"var(--danger)":f.type==="success"?"var(--success)":"var(--accent)",display:"flex",alignItems:"center",gap:5},children:[f.type==="error"?"✕":f.type==="success"?"✓":"◎"," ",f.title]}),t.jsx("button",{onClick:()=>ks(f.id),title:"关闭",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:14,lineHeight:1,padding:"2px 4px",borderRadius:4,transition:"color 0.15s"},onMouseEnter:E=>E.currentTarget.style.color="var(--text-primary)",onMouseLeave:E=>E.currentTarget.style.color="var(--text-muted)",children:"×"})]}),t.jsx("p",{style:{margin:0,fontSize:12,color:"var(--text-secondary)",lineHeight:1.5,wordBreak:"break-all"},children:f.body}),f.sessionId&&t.jsx("button",{onClick:()=>{kn(f.sessionId),ks(f.id)},style:{marginTop:8,padding:"4px 10px",fontSize:11,fontWeight:500,background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--border-glow)",borderRadius:6,cursor:"pointer",transition:"background 0.15s",WebkitAppRegion:"no-drag"},onMouseEnter:E=>E.currentTarget.style.background="var(--accent-glow)",onMouseLeave:E=>E.currentTarget.style.background="var(--accent-dim)",children:"进入会话 →"})]},f.id))}),document.body)]})}export{Ev as default};
|