@xopcai/xopc 0.0.373 → 0.0.375
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear--kDkSTqC.js → agent-avatar-dicebear-B2Popl59.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-z4_2-Kn2.js → agent-defaults-settings-panel-BnF3HrHY.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BYndK83K.js → agent-plugin-dialog-CwP6OrUs.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-CVo96cx1.js → agents-n3IremKl.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D9oOJKiH.js → app-management-settings-panel-DNkXIPxK.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B0-8Cdyv.js → appearance-settings-p1_NpH8a.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DasVc6i4.js → apps-page-CP2u5iEh.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BlCNqy2i.js → automations-page-CjYiGOov.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-C8ipDP05.js → automations-workspace-BAHiUQbe.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Cktlez6g.js → block-editor-DiOou1HO.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-KRfDl8ej.js → browser-automations-page-nArl2uwX.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BraQ4wnh.js → browser-settings-page-Bd8tF-gg.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-B3m8xGzd.js → capabilities-page-Cx4cdgse.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-VQ4fHuBV.js → capabilities-settings-panel-DpWceNd0.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-f5Ido4Eg.js → capability-header-actions-AeBubNQK.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-N4Vc2nEG.js → channels-Cd1Rf0Vk.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BwvTKwsn.js → chat-terminal-dock-DrVlbq_P.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CAwUsKpw.js → computer-settings-page-TUzZnurj.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-C0HuAMuH.js → connector-service-page-BlpwjGW7.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BcBmW8JT.js → connectors-page-j8VFMD4o.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DiQxRpe-.js → date-picker-CjKRpA8X.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Ds0_BJbN.js → dependency-picker-J9_0obij.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-ZMEOYwrR.js → desktop-pet-DySwgreF.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DkyTqD07.js → desktop-pet-settings-B1-oyKBG.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-CvaI5ZJZ.js → device-pairing-wizard-C5rjPAyc.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Bfv93eK1.js → directory-picker-path-field-BY7MwiZd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-JXKGtIdM.js → extension-page-JoSFhfb6.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-lsQ2xvbr.js → extension-settings-page-B7LtTNx7.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-7bG0AND1.js → fallback-models-DKSWcBt_.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BpbcoPx9.js → gateway-settings-CGm-lbsX.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BxctC0aJ.js → home-page-CX3uWkyH.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-Bq8CazCb.js → imports-page-DS_RFtWf.js} +1 -1
- package/dist/gateway/static/root/assets/{index-B40-KDN8.js → index-CgvOIDy_.js} +6 -6
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-kkAevkl2.js → keyboard-shortcuts-settings-BxwXR2qA.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-abLaf1hW.js → local-app-workbench-page-BWd4RMBE.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-nwsnwYjK.js → local-apps-page-BsgcA6-N.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BEgYS-Xg.js → logs-page-CLP5pu2j.js} +1 -1
- package/dist/gateway/static/root/assets/management-settings-CZAZwCpE.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-CCnfurBR.js → note-detail-panel-BeAHgdtw.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-D9u_znxM.js → notes-page-MP21Zf_R.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BO3FoRej.js → page-context-capture-button-BZADmKcV.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-BbaTGmE-.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-Dso2_hyl.js → product-open-page-CBnKsW4p.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-CkvVb3EA.js → product-preview-content-B0gGexdG.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-UjrrzE3H.js → project-detail-page-ZjQSv_NG.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-C1h63P2M.js → projects-page-Bf7Sd_Ck.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BJifH8AB.js → remote-access-hub-Bl8aPuXU.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-vG1wqcEb.js → runtime-tools-settings-panel-CQZ1c-re.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-CwoAoYMX.js → scenes-page-1xGRBOJO.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BIsHdyz7.js → schema-form-BYqugMox.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BcCLp3yU.js → sessions-page-DjMSVXU3.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BJuMTtyI.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-z9Jlk0BL.js → settings-page-CSqi5fmN.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-CrpXECqe.js → setup-status-panel-D5bM0TvA.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-D9XpTJXP.js → shares-settings-C-V9WllF.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-DtPOf1aW.js → skill-api-CFtEHy5e.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Bq9-2b9U.js → skills-page-B-olXUVH.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-P7T729uD.js → system-settings-panel-DBMR9ks_.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-CsB9AFx6.js → task-detail-page-CGe34vxR.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CuowqIZ7.js → tunnel-api-CzNIlgdJ.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-avX3msoZ.js → usage-page-O3abwewp.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-Bx2JlCpj.js +2 -0
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BgJNz2tH.js → work-discovery-overlay-D967-fVj.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-1I2q2J_U.js → workflow-run-setup-panel-BJ945m7G.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DhJl9pnO.js → workflows-page-DUpVeIuw.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CnPBP1V_.js → xopc-cloud-account-card-Bq9ubffP.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/realtime-protocol/src/voice.js +11 -0
- package/dist/src/agent/agent-manager.d.ts +2 -7
- package/dist/src/agent/agent-manager.js +21 -50
- package/dist/src/agent/background-review/coordinator.js +1 -1
- package/dist/src/agent/background-review/prompts.d.ts +6 -0
- package/dist/src/agent/background-review/prompts.js +7 -1
- package/dist/src/agent/background-review/run-background-review.d.ts +3 -0
- package/dist/src/agent/background-review/run-background-review.js +185 -17
- package/dist/src/agent/context/coordinator.d.ts +1 -0
- package/dist/src/agent/context/coordinator.js +11 -2
- package/dist/src/agent/context/execution-context.js +40 -4
- package/dist/src/agent/context/project-context.js +11 -3
- package/dist/src/agent/embedded/run-for-session.js +2 -2
- package/dist/src/agent/embedded/run-turn.js +4 -4
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
- package/dist/src/agent/memory/compaction-promotion.d.ts +2 -0
- package/dist/src/agent/memory/compaction-promotion.js +33 -2
- package/dist/src/agent/service/process-direct-streaming.js +1 -1
- package/dist/src/agent/service.js +5 -5
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +2 -2
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/knowledge-memory-tool.js +14 -6
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent/workspace-runtime/registry.js +1 -1
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-config/schema.d.ts +9 -0
- package/dist/src/agent-config/schema.js +1 -0
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/draft/automation-draft-service.js +1 -1
- package/dist/src/automations/service/action-executor.js +1 -1
- package/dist/src/bootstrap/application-state.js +2 -2
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/agent.js +2 -2
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/gateway/shared.js +2 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/runtime.js +1 -1
- package/dist/src/config/agent-model-intents.js +1 -1
- package/dist/src/config/agent-profile.js +2 -2
- package/dist/src/config/gateway-bind.js +2 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.d.ts +8 -8
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.d.ts +18 -12
- package/dist/src/config/schema.js +12 -8
- package/dist/src/connectors/connected-source-ingestion.js +45 -7
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
- package/dist/src/connectors/connected-source-understanding.js +59 -67
- package/dist/src/connectors/content-enrichment.js +1 -1
- package/dist/src/connectors/learning-coordinator.js +2 -2
- package/dist/src/daemon/constants.js +14 -9
- package/dist/src/daemon/index.js +4 -1
- package/dist/src/daemon/install-plan.js +2 -1
- package/dist/src/daemon/launchd.js +2 -1
- package/dist/src/daemon/schtasks.js +2 -1
- package/dist/src/daemon/service-audit.js +2 -1
- package/dist/src/daemon/service.js +2 -1
- package/dist/src/daemon/systemd.js +2 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/client-ip.js +2 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/app.js +2 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +5 -0
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/middleware/auth.d.ts +3 -5
- package/dist/src/gateway/hono/middleware/auth.js +56 -14
- package/dist/src/gateway/hono/middleware/logger.js +2 -1
- package/dist/src/gateway/hono/middleware/public-device-rate-limit.d.ts +16 -0
- package/dist/src/gateway/hono/middleware/public-device-rate-limit.js +43 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +3 -2
- package/dist/src/gateway/hono/oauth-async.js +2 -1
- package/dist/src/gateway/hono/routes/browser.js +2 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +5 -5
- package/dist/src/gateway/hono/routes/config.js +2 -1
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/context-sources.js +2 -2
- package/dist/src/gateway/hono/routes/device-pairing-approval.d.ts +3 -8
- package/dist/src/gateway/hono/routes/device-pairing-approval.js +5 -20
- package/dist/src/gateway/hono/routes/devices.js +25 -9
- package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -0
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/memory-learning.d.ts +3 -0
- package/dist/src/gateway/hono/routes/memory-learning.js +76 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/personal-agent.js +3 -2
- package/dist/src/gateway/hono/routes/projects.js +3 -3
- package/dist/src/gateway/hono/routes/public-gateway.js +6 -6
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/shares.js +2 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
- package/dist/src/gateway/hono/routes/user-model.js +5 -3
- package/dist/src/gateway/hono/routes/voice.js +1 -0
- package/dist/src/gateway/host.js +9 -4
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/index.js +8 -4
- package/dist/src/gateway/listen.js +2 -1
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/rate-limit/auth-policy.js +7 -11
- package/dist/src/gateway/rate-limit/buckets.d.ts +6 -0
- package/dist/src/gateway/rate-limit/buckets.js +211 -189
- package/dist/src/gateway/rate-limit/env-flags.js +4 -1
- package/dist/src/gateway/rate-limit/index.js +13 -4
- package/dist/src/gateway/runtime-config.js +5 -3
- package/dist/src/gateway/security/audit.js +3 -2
- package/dist/src/gateway/security/browser-session.js +2 -1
- package/dist/src/gateway/security/device-request-proof.d.ts +28 -0
- package/dist/src/gateway/security/device-request-proof.js +122 -0
- package/dist/src/gateway/security/loopback.js +7 -6
- package/dist/src/gateway/service/session-command-service.js +1 -1
- package/dist/src/gateway/service.js +18 -16
- package/dist/src/gateway/tailscale-auth.js +2 -1
- package/dist/src/gateway/ws-security.js +2 -1
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.js +2 -2
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/imports/inventory.js +1 -1
- package/dist/src/infra/rate-limit/failure-limiter.js +78 -90
- package/dist/src/infra/rate-limit/index.js +11 -3
- package/dist/src/infra/rate-limit/keyed-store.js +52 -47
- package/dist/src/infra/rate-limit/rate-limiter.js +55 -58
- package/dist/src/infra/update-service-refresh.js +2 -1
- package/dist/src/knowledge/chunks.d.ts +10 -0
- package/dist/src/knowledge/chunks.js +28 -0
- package/dist/src/knowledge/connected-knowledge-pipeline.js +67 -33
- package/dist/src/knowledge/index.js +1 -1
- package/dist/src/knowledge/ingestion-service.js +5 -1
- package/dist/src/knowledge/local-folder-adapter.d.ts +2 -1
- package/dist/src/knowledge/local-folder-adapter.js +22 -13
- package/dist/src/knowledge-memory/domain.d.ts +4 -0
- package/dist/src/knowledge-memory/index.d.ts +1 -0
- package/dist/src/knowledge-memory/index.js +2 -1
- package/dist/src/knowledge-memory/repair-evidence.d.ts +2 -0
- package/dist/src/knowledge-memory/repair-evidence.js +57 -0
- package/dist/src/knowledge-memory/repository.d.ts +8 -0
- package/dist/src/knowledge-memory/repository.js +48 -27
- package/dist/src/knowledge-memory/search-text.d.ts +3 -0
- package/dist/src/knowledge-memory/search-text.js +32 -0
- package/dist/src/knowledge-memory/usage-policy.d.ts +6 -0
- package/dist/src/knowledge-memory/usage-policy.js +61 -0
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/memory-learning/repository.d.ts +24 -0
- package/dist/src/memory-learning/repository.js +96 -0
- package/dist/src/memory-learning/service.d.ts +17 -0
- package/dist/src/memory-learning/service.js +105 -0
- package/dist/src/memory-learning/source-learning.d.ts +7 -0
- package/dist/src/memory-learning/source-learning.js +235 -0
- package/dist/src/memory-learning/task-receipts.d.ts +3 -0
- package/dist/src/memory-learning/task-receipts.js +95 -0
- package/dist/src/memory-learning/work-capture.d.ts +51 -0
- package/dist/src/memory-learning/work-capture.js +140 -0
- package/dist/src/memory-maintenance/service.js +5 -5
- package/dist/src/personal-agent/proactivity/service.js +2 -2
- package/dist/src/personal-agent/prompt-context.js +4 -4
- package/dist/src/personal-agent/reply-composer.js +1 -1
- package/dist/src/personal-agent/repository.d.ts +3 -0
- package/dist/src/personal-agent/repository.js +1 -0
- package/dist/src/personal-agent/service.d.ts +6 -2
- package/dist/src/personal-agent/service.js +6 -5
- package/dist/src/platform/client.d.ts +1 -1
- package/dist/src/platform/contracts.d.ts +1 -1
- package/dist/src/providers/local-model.d.ts +2 -0
- package/dist/src/providers/local-model.js +16 -0
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/realtime/runtime.js +6 -0
- package/dist/src/realtime/tickets.d.ts +1 -0
- package/dist/src/realtime/tickets.js +4 -0
- package/dist/src/remote-access/exposure-guards.js +2 -1
- package/dist/src/routing/resolve-route.js +1 -1
- package/dist/src/routing/resolve-tui-session-key.js +1 -1
- package/dist/src/scenes/taskFollowUp/service.js +1 -1
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.js +2 -1
- package/dist/src/share/share-rate-limit.js +2 -1
- package/dist/src/share/share-url.js +2 -1
- package/dist/src/share/site-share-router.js +2 -1
- package/dist/src/storage/sqlite/device-access-repository.d.ts +7 -0
- package/dist/src/storage/sqlite/device-access-repository.js +22 -4
- package/dist/src/storage/sqlite/knowledge-repository.js +6 -0
- package/dist/src/storage/sqlite/migrations/243_voice_opening_greetings.sql +12 -0
- package/dist/src/storage/sqlite/migrations/244_device_request_proofs.sql +8 -0
- package/dist/src/storage/sqlite/migrations/245_memory_learning.sql +125 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +6 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tasks/task-main-update-decision-service.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +4 -4
- package/dist/src/tui/extension-host/load-extensions.js +1 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-skills-autocomplete.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +2 -2
- package/dist/src/tui/tui.js +2 -2
- package/dist/src/tunnel/broker-client.js +2 -0
- package/dist/src/tunnel/tunnel-config.js +2 -2
- package/dist/src/tunnel/tunnel-rate-limit.js +2 -1
- package/dist/src/user-context/access-policy.js +2 -1
- package/dist/src/user-context/config.d.ts +10 -0
- package/dist/src/user-context/config.js +5 -0
- package/dist/src/user-context/extraction/registry.d.ts +1 -1
- package/dist/src/user-context/extraction/registry.js +10 -0
- package/dist/src/user-context/identity-bindings.d.ts +10 -0
- package/dist/src/user-context/identity-bindings.js +24 -0
- package/dist/src/user-context/sources/consent-fields.d.ts +2 -0
- package/dist/src/user-context/sources/consent-fields.js +66 -0
- package/dist/src/user-model/bootstrap.js +1 -1
- package/dist/src/user-model/capture/executor.js +1 -1
- package/dist/src/user-model/capture/semantic.d.ts +3 -1
- package/dist/src/user-model/capture/semantic.js +14 -6
- package/dist/src/user-model/index.js +1 -1
- package/dist/src/user-model/usage-policy.js +34 -0
- package/dist/src/utils/logger/redact.js +4 -1
- package/dist/src/voice/platform-streams.d.ts +6 -0
- package/dist/src/voice/platform-streams.js +44 -4
- package/dist/src/voice/realtime/agentEngine.js +138 -83
- package/dist/src/voice/realtime/engine.d.ts +6 -0
- package/dist/src/voice/realtime/memory-context.js +19 -5
- package/dist/src/voice/realtime/opening-greeting.d.ts +12 -0
- package/dist/src/voice/realtime/opening-greeting.js +22 -0
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/realtime/runtime.js +90 -1
- package/dist/src/voice/realtime/runtime.types.d.ts +4 -0
- package/dist/src/work-discovery/incremental-repository.js +1 -1
- package/dist/src/work-discovery/service.js +6 -6
- package/dist/src/workflows/service/workflow-run-service.js +2 -2
- package/dist/src/workflows/service/workflow-session-bridge.js +38 -10
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/management-settings-D_JQ6_X0.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-BJn6UHAF.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-D114UdRI.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-DGDBWw7P.js +0 -2
|
@@ -5,19 +5,19 @@ import { createContextEvidence, init_context_evidence_repository } from "../stor
|
|
|
5
5
|
import { ensureSessionRecord, patchSessionMetadata } from "../storage/sqlite/session-repository.js";
|
|
6
6
|
import { init_sqlite } from "../storage/sqlite/index.js";
|
|
7
7
|
import { ActivityService } from "../activity/service.js";
|
|
8
|
-
import {
|
|
8
|
+
import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
|
|
9
|
+
import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
|
|
9
10
|
import { init_session_key, resolveConversationId } from "../routing/session-key.js";
|
|
11
|
+
import "../knowledge-memory/index.js";
|
|
10
12
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
13
|
+
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
14
|
+
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
11
15
|
import { init_providers, resolveModel } from "../providers/index.js";
|
|
12
16
|
import { isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
13
|
-
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
14
|
-
import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
|
|
15
|
-
import "../knowledge-memory/index.js";
|
|
16
|
-
import { linkAssertionEvidence, reconcileAssertion } from "../user-model/repository.js";
|
|
17
17
|
import { createPriorityWindow, createUserGoal } from "../user-model/goals.js";
|
|
18
|
+
import { linkAssertionEvidence, reconcileAssertion } from "../user-model/repository.js";
|
|
18
19
|
import "../user-model/index.js";
|
|
19
20
|
import { createWorkDiscoveryRun, getProjectUnderstandingRun, getWorkDiscoveryOnboardingState, getWorkDiscoveryRun, getWorkDiscoveryRunByIdempotencyKey, listPendingProjectUnderstandingRuns, setWorkDiscoveryFeedback, setWorkDiscoveryOnboardingState, updateWorkDiscoveryRun } from "./repository.js";
|
|
20
|
-
import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
|
|
21
21
|
import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
|
|
22
22
|
import { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown } from "./analyzer.js";
|
|
23
23
|
import { clusterActivityTopics } from "../user-context/sources/activity-clustering.js";
|
|
@@ -2,8 +2,9 @@ import { TaskRepository, init_task_repository } from "../../tasks/task-repositor
|
|
|
2
2
|
import { TaskRunRepository, init_task_run_repository } from "../../tasks/task-run-repository.js";
|
|
3
3
|
import { init_conversation_repository, resolveRoutedConversation } from "../../storage/sqlite/conversation-repository.js";
|
|
4
4
|
import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-route.js";
|
|
5
|
-
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
6
5
|
import { extractProfileAgentId, resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
|
+
import { resolveModelSelector } from "../../config/agent-model-intents.js";
|
|
7
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
7
8
|
import { getProjectWorkspacePathForSession } from "../../projects/workspace.js";
|
|
8
9
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
9
10
|
import { automationEventPublisher, getAutomationEventForRun } from "../../automations/events/event-repository.js";
|
|
@@ -12,7 +13,6 @@ import { validateWorkflowJsonSchema } from "../domain/schema-validation.js";
|
|
|
12
13
|
import "../domain/index.js";
|
|
13
14
|
import { TaskContextRepository } from "../../tasks/task-context-repository.js";
|
|
14
15
|
import { TaskApplicationService } from "../../tasks/task-application-service.js";
|
|
15
|
-
import { resolveModelSelector } from "../../config/agent-model-intents.js";
|
|
16
16
|
import { DelegateSubagentRunner } from "../../agent/workflow/subagent-runner.js";
|
|
17
17
|
import { preflightWorkflowConnectors } from "../../connectors/workflow-preflight.js";
|
|
18
18
|
import { CatalogWorkflowDefinitionRegistry } from "../registry/catalog-workflow-definition-registry.js";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { createContextEvidence, init_context_evidence_repository } from "../../storage/sqlite/context-evidence-repository.js";
|
|
1
2
|
import "../../session/types.js";
|
|
3
|
+
import { inferMemorySensitivity } from "../../agent/memory/sensitivity.js";
|
|
2
4
|
import { writeKnowledgeItem } from "../../knowledge-memory/repository.js";
|
|
5
|
+
import { resolveUserContextSessionAccess } from "../../user-context/access-policy.js";
|
|
3
6
|
import "../../knowledge-memory/index.js";
|
|
4
7
|
import { isTerminalWorkflowRunStatus } from "../domain/run.js";
|
|
5
8
|
import "../domain/index.js";
|
|
@@ -7,8 +10,9 @@ import { TaskWorkflowCoordinator } from "../../tasks/task-workflow-coordinator.j
|
|
|
7
10
|
import { renderWorkflowText } from "../../agent/workflow/snapshot.js";
|
|
8
11
|
import { runViewToSnapshot } from "./run-view-to-snapshot.js";
|
|
9
12
|
import { buildWorkflowRunConversationId } from "./workflow-session-key.js";
|
|
10
|
-
import { randomUUID } from "node:crypto";
|
|
13
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
11
14
|
//#region src/workflows/service/workflow-session-bridge.ts
|
|
15
|
+
init_context_evidence_repository();
|
|
12
16
|
const WORKFLOW_SESSION_TYPE = "workflow-run";
|
|
13
17
|
const WORKFLOW_RUN_LINK_CONTEXT_KIND = "workflow-run-link";
|
|
14
18
|
var WorkflowSessionBridge = class {
|
|
@@ -94,7 +98,7 @@ var WorkflowSessionBridge = class {
|
|
|
94
98
|
goal: view.run.goal,
|
|
95
99
|
status: view.run.status
|
|
96
100
|
});
|
|
97
|
-
this.recordProjectWorkflowMemory(
|
|
101
|
+
this.recordProjectWorkflowMemory(view);
|
|
98
102
|
new TaskWorkflowCoordinator().handleTerminalRun(view);
|
|
99
103
|
}
|
|
100
104
|
async persistTerminalTranscript(conversationId, view) {
|
|
@@ -154,11 +158,32 @@ var WorkflowSessionBridge = class {
|
|
|
154
158
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
|
-
recordProjectWorkflowMemory(
|
|
161
|
+
recordProjectWorkflowMemory(view) {
|
|
158
162
|
const projectId = view.run.metadata?.projectId?.trim();
|
|
159
163
|
const agentId = view.run.metadata?.agentId?.trim();
|
|
160
164
|
if (!projectId || !agentId) return;
|
|
165
|
+
const ownerConversationId = readParentConversationId(view);
|
|
166
|
+
if (!ownerConversationId) return;
|
|
167
|
+
const config = this.gateway.currentConfig;
|
|
168
|
+
const access = resolveUserContextSessionAccess(config, ownerConversationId);
|
|
169
|
+
if (!access.knowledge || config.userContext.knowledgeMemory.writePolicy !== "allow" || !access.knowledgePolicy.scopes.includes("project") || !access.knowledgePolicy.contentSources.includes("memory")) return;
|
|
161
170
|
const resultText = view.run.result?.summary.trim() || renderWorkflowText(runViewToSnapshot(view), view.run.status === "succeeded", { showResultPreviews: true });
|
|
171
|
+
const content = [
|
|
172
|
+
`Workflow ${view.run.definitionId} reports status ${view.run.status}.`,
|
|
173
|
+
view.run.goal ? `Goal: ${view.run.goal}` : void 0,
|
|
174
|
+
compactMemoryLine(resultText)
|
|
175
|
+
].filter((line) => Boolean(line)).join("\n");
|
|
176
|
+
const sensitivity = inferMemorySensitivity(content);
|
|
177
|
+
if (sensitivity === "secret" || sensitivity === "regulated") return;
|
|
178
|
+
const hash = createHash("sha256").update(content).digest("hex");
|
|
179
|
+
const evidence = createContextEvidence({
|
|
180
|
+
sourceType: "runtime",
|
|
181
|
+
sourceRef: `workflow-run:${view.run.id}`,
|
|
182
|
+
conversationId: ownerConversationId,
|
|
183
|
+
contentHash: hash,
|
|
184
|
+
trustLevel: "trusted",
|
|
185
|
+
observedAt: Date.now()
|
|
186
|
+
});
|
|
162
187
|
writeKnowledgeItem({
|
|
163
188
|
kind: "task_lesson",
|
|
164
189
|
scope: {
|
|
@@ -166,17 +191,20 @@ var WorkflowSessionBridge = class {
|
|
|
166
191
|
id: projectId
|
|
167
192
|
},
|
|
168
193
|
sourceAgentId: agentId,
|
|
169
|
-
sourceConversationId:
|
|
170
|
-
content
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
]
|
|
194
|
+
sourceConversationId: ownerConversationId,
|
|
195
|
+
content,
|
|
196
|
+
evidence: [{
|
|
197
|
+
id: evidence.id,
|
|
198
|
+
contentHash: hash
|
|
199
|
+
}],
|
|
200
|
+
claimMode: "reported",
|
|
201
|
+
verification: "supported",
|
|
202
|
+
sensitivity,
|
|
175
203
|
canonicalKey: `workflow-run:${view.run.id}`,
|
|
176
204
|
source: { provider: "workflow-run" },
|
|
177
205
|
confidence: view.run.status === "succeeded" ? .7 : .82,
|
|
178
206
|
importance: .65,
|
|
179
|
-
status:
|
|
207
|
+
status: "active",
|
|
180
208
|
originClass: "agent",
|
|
181
209
|
replaceExisting: true
|
|
182
210
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xopcai/xopc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.375",
|
|
4
4
|
"description": "Local-first personal AI with Ada, task delegation, files, projects, workflows, and automations. Use cloud or local models.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -167,10 +167,10 @@
|
|
|
167
167
|
"vue": "^3.5.35",
|
|
168
168
|
"@xopcai/browser-control-contract": "0.1.0",
|
|
169
169
|
"@xopcai/computer-control-contract": "0.1.0",
|
|
170
|
-
"@xopcai/endpoint-tools-client": "0.0.0",
|
|
171
170
|
"@xopcai/endpoint-tools-protocol": "0.0.0",
|
|
172
|
-
"@xopcai/gateway-contract": "0.0.0",
|
|
173
171
|
"@xopcai/image-providers": "0.1.0",
|
|
172
|
+
"@xopcai/gateway-contract": "0.0.0",
|
|
173
|
+
"@xopcai/endpoint-tools-client": "0.0.0",
|
|
174
174
|
"@xopcai/realtime-client": "0.0.0",
|
|
175
175
|
"@xopcai/realtime-protocol": "0.0.0"
|
|
176
176
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./activity-YogQEteU.js";import{t as o}from"./chevron-left-DqFhpbvK.js";import{t as s}from"./chevron-right-BweFrslA.js";import{t as c}from"./popover-select-BgSdSbCL.js";import{t as l}from"./plus-Q2yW6OE7.js";import{t as u}from"./search-DA7gz22f.js";import{t as d}from"./x-B_N4OPjy.js";import{t as ee}from"./messages-C1SUo4gG.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p,n as m,r as h}from"./locale-store-rWFLl-p4.js";import{a as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{s as S}from"./session-api-u_4_kFQt.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CS04eWY9.js";import{t as T}from"./skeleton-BwbyijEw.js";import{i as te,o as ne}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as E}from"./index.module-Cd9ENXfk.js";import{Ao as D,No as re,ci as O,ds as ie,js as k,li as A}from"./index-B40-KDN8.js";import{t as j}from"./page-tabs-D2xpUV26.js";import{n as M,r as N,t as P}from"./settings-page-layout-X1x-2Cp9.js";import{t as F}from"./device-pairing-wizard-CvaI5ZJZ.js";import{n as I}from"./settings-loading-skeleton-CAmWMaOT.js";var L=n(),R=e(t(),1),z=r();async function B(e=`GET`,t,n){let r=await p(h(`/api/endpoint-tools/target-authorizations`+(n?`/`+encodeURIComponent(n):``)),{method:e,...t?{body:JSON.stringify(t)}:{}});if(!r.ok)throw Error(r.status===403?`owner`:`unavailable`);return(await r.json()).payload}function ae({devices:e,zh:t}){let n=C(`device-single-call-grants`,()=>B(),{refreshInterval:5e3,shouldRetryOnError:!1}),r=C(n.error?null:`device-grant-conversations`,()=>S({limit:100}),{shouldRetryOnError:!1}),[i,a]=(0,R.useState)(``),[o,s]=(0,R.useState)(``),[l,u]=(0,R.useState)(``),[d,ee]=(0,R.useState)(`weather`),[f,p]=(0,R.useState)(`approximate`),[m,h]=(0,R.useState)(`restaurant`),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(!1);if(n.error)return null;let b=e.flatMap(e=>e.endpoints.map(t=>({...t,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))),x=b.find(e=>e.endpointId===l)?.tools.find(e=>e.descriptor.name.endsWith(`.device.get_location`))?.descriptor.name,te=async()=>{if(!(!x||!i||!o)){_(!0),y(!1);try{await B(`POST`,{conversationId:i,requestorPrincipalId:o,targetEndpointId:l,toolName:x,arguments:{purpose:d,precision:f,...d===`nearby`?{category:m}:{}}}),await n.mutate()}catch{y(!0)}finally{_(!1)}}};return(0,z.jsxs)(`section`,{className:`mb-5 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,z.jsx)(`h3`,{className:`font-semibold text-fg`,children:t?`跨设备单次授权`:`Single-call device authorization`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t?`为指定会话和来源设备授权一次定位查询,60 秒后失效。目标设备仍需确认;授权后请在来源设备继续请求。`:`Authorize one location query for a conversation and source device. Expires in 60 seconds; target-device consent is still required. Continue the request from the source device.`}),n.isLoading||r.isLoading?(0,z.jsx)(T,{className:`mt-3 h-28`}):(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(c,{value:i,onChange:a,placeholder:t?`选择会话`:`Conversation`,ariaLabel:t?`会话`:`Conversation`,options:(r.data?.items??[]).map(e=>({value:e.key,label:e.name||e.key}))}),(0,z.jsx)(c,{value:o,onChange:s,placeholder:t?`消息来源设备`:`Source device`,ariaLabel:t?`消息来源设备`:`Source device`,options:e.filter(e=>e.endpoints.length>0).map(e=>({value:e.id,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))}),(0,z.jsx)(c,{value:l,onChange:u,placeholder:t?`使用哪台设备的位置`:`Location device`,ariaLabel:t?`目标设备`:`Target device`,options:b.filter(e=>e.tools.some(e=>e.descriptor.name.endsWith(`.device.get_location`))).map(e=>({value:e.endpointId,label:e.label}))}),(0,z.jsx)(c,{placeholder:t?`用途`:`Purpose`,value:d,onChange:e=>ee(e),ariaLabel:t?`用途`:`Purpose`,options:[{value:`weather`,label:t?`查询天气`:`Weather`},{value:`nearby`,label:t?`附近地点`:`Nearby places`}],allowEmpty:!1}),(0,z.jsx)(c,{placeholder:t?`精度`:`Precision`,value:f,onChange:e=>p(e),ariaLabel:t?`精度`:`Precision`,options:[{value:`approximate`,label:t?`大致位置`:`Approximate`},{value:`precise`,label:t?`精确位置`:`Precise`}],allowEmpty:!1}),d===`nearby`?(0,z.jsx)(c,{placeholder:t?`地点类型`:`Category`,value:m,onChange:h,ariaLabel:t?`附近地点类型`:`Place category`,options:[`restaurant`,`cafe`,`pharmacy`,`park`].map((e,n)=>({value:e,label:t?[`餐厅`,`咖啡馆`,`药店`,`公园`][n]:e})),allowEmpty:!1}):null,(0,z.jsx)(w,{variant:`primary`,disabled:g||!i||!o||!x,onClick:()=>void te(),children:t?`允许一次`:`Allow once`})]}),v?(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-fg-muted`,children:t?`授权失败,请检查设备连接后重试。`:`Authorization failed. Check the device connection.`}):null,(0,z.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.data?.map(r=>(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm text-fg-muted`,children:[(0,z.jsxs)(`span`,{children:[e.find(e=>e.endpoints.some(e=>e.endpointId===r.targetEndpointId))?.displayName??(t?`设备`:`Device`),` · `,r.state===`running`?t?`执行中`:`Running`:t?`等待本次调用`:`Awaiting one call`]}),(0,z.jsx)(w,{disabled:g,onClick:()=>{_(!0),B(`DELETE`,void 0,r.id).then(()=>n.mutate()).catch(()=>y(!0)).finally(()=>_(!1))},children:t?`撤销`:`Revoke`})]},r.id))})]})}var V=720*60*60*1e3;function H(e){let t=[e.access,e.principal].filter(e=>e!==null);return t.length>0&&t.every(e=>e.revokedAt!==void 0)}function U(e){return H(e)?`revoked`:e.endpoints.length>0?`online`:`offline`}function oe(e){return new Set(e.endpoints.flatMap(e=>e.tools.map(({descriptor:e})=>e.name))).size}function se(e,t=Date.now()){return U(e)===`offline`?(e.lastSeenAt??e.createdAt)<t-V:!1}function ce(e,t,n=Date.now()){let r=t.query.trim().toLocaleLowerCase();return e.filter(e=>{let i=U(e),a=t.status===`all`||(t.status===`active`?i!==`revoked`:t.status===`stale`?se(e,n):i===t.status),o=!t.platform||e.platform===t.platform,s=!r||[e.displayName,e.id,e.kind,e.platform].some(e=>e.toLocaleLowerCase().includes(r));return a&&o&&s})}function le(e){return e.length>8?e.slice(-8):e}function ue(e){let t=(0,L.c)(61),{device:n,busy:r,onClose:i,onRevoke:a,onRename:o}=e,s=m(de),c;t[0]===s?c=t[1]:(c=ee(s),t[0]=s,t[1]=c);let l=c.endpointToolsSettings,u=s===`zh`?`zh-CN`:`en`,p;t[2]===u?p=t[3]:(p=new Intl.DateTimeFormat(u,{dateStyle:`medium`,timeStyle:`short`}),t[2]=u,t[3]=p);let h=p,S;t[4]===n?S=t[5]:(S=n?U(n):`offline`,t[4]=n,t[5]=S);let C=S,T=n!==null,E;t[6]===i?E=t[7]:(E=e=>!e&&i(),t[6]=i,t[7]=E);let D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,z.jsx)(g,{className:f(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ne)}),t[8]=D):D=t[8];let O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(O=f(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,te),t[9]=O):O=t[9];let ie=n?.displayName??l.deviceDetails,k;t[10]===ie?k=t[11]:(k=(0,z.jsx)(b,{className:`truncate text-base font-semibold text-fg`,children:ie}),t[10]=ie,t[11]=k);let A;t[12]===n?A=t[13]:(A=n?(0,z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[n.kind,` · `,n.platform,` · `,le(n.id)]}):null,t[12]=n,t[13]=A);let j;t[14]!==k||t[15]!==A?(j=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[k,A]}),t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,z.jsx)(d,{className:`size-5`,"aria-hidden":!0}),t[17]=M):M=t[17];let N;t[18]===l.close?N=t[19]:(N=(0,z.jsx)(_,{asChild:!0,children:(0,z.jsx)(w,{variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l.close,children:M})}),t[18]=l.close,t[19]=N);let P;t[20]!==j||t[21]!==N?(P=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[j,N]}),t[20]=j,t[21]=N,t[22]=P):P=t[22];let F;t[23]!==l.accessActive||t[24]!==l.accessRevoked||t[25]!==l.accessTitle||t[26]!==l.createdAt||t[27]!==l.endpointCount||t[28]!==l.endpointsTitle||t[29]!==l.identityId||t[30]!==l.identityTitle||t[31]!==l.lastSeen||t[32]!==l.never||t[33]!==l.noAccessIdentity||t[34]!==l.noOnlineEndpoints||t[35]!==l.noPermissions||t[36]!==l.permissions||t[37]!==l.status||t[38]!==l.statusLabel||t[39]!==l.toolCount||t[40]!==n||t[41]!==h||t[42]!==s||t[43]!==o||t[44]!==C?(F=n?(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4`,children:[n.principal&&C!==`revoked`&&o?(0,z.jsx)(fe,{device:n,zh:s===`zh`,onRename:o},`${n.id}:${n.settingsRevision??0}`):null,(0,z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 rounded-xl bg-surface-hover/40 p-4`,children:[(0,z.jsx)(W,{label:l.statusLabel,value:l.status[C]}),(0,z.jsx)(W,{label:l.lastSeen,value:n.lastSeenAt?h.format(n.lastSeenAt):l.never}),(0,z.jsx)(W,{label:l.endpointCount,value:String(n.endpoints.length)}),(0,z.jsx)(W,{label:l.toolCount,value:String(oe(n))})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.accessTitle}),(0,z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs text-fg-muted`,children:n.access?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{children:n.access.revokedAt?l.accessRevoked:l.accessActive}),(0,z.jsxs)(`p`,{className:`mt-1 break-words`,children:[l.permissions,`: `,n.access.scopes.join(`, `)||l.noPermissions]})]}):(0,z.jsx)(`p`,{children:l.noAccessIdentity})})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.endpointsTitle}),(0,z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[n.endpoints.length===0?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.noOnlineEndpoints}):null,n.endpoints.map(e=>(0,z.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,z.jsx)(`p`,{className:`min-w-0 break-all text-xs font-medium text-fg`,children:e.endpointId}),(0,z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[l.status[e.availability],` · v`,e.appVersion]})]}),(0,z.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.tools.map(e=>{let{descriptor:t}=e;return(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-hover/50 px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`break-all text-xs font-medium text-fg`,children:t.title}),(0,z.jsxs)(`p`,{className:`mt-0.5 break-words text-xs text-fg-subtle`,children:[t.requiresForeground?s===`zh`?`需要设备在前台 · `:`Requires foreground · `:``,t.confirmation===`always`?s===`zh`?`每次确认`:`Confirm each time`:s===`zh`?`按已授权范围调用`:`Uses the authorized scope`]})]},t.name)})})]},e.connectionId))]})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.identityTitle}),n.principal&&C!==`revoked`&&o?(0,z.jsx)(fe,{device:n,zh:s===`zh`,onRename:o},`${n.id}:${n.settingsRevision??0}`):null,(0,z.jsxs)(`dl`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs`,children:[(0,z.jsx)(W,{label:l.identityId,value:n.id,breakAll:!0}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(W,{label:l.createdAt,value:h.format(n.createdAt)})})]})]})]}):null,t[23]=l.accessActive,t[24]=l.accessRevoked,t[25]=l.accessTitle,t[26]=l.createdAt,t[27]=l.endpointCount,t[28]=l.endpointsTitle,t[29]=l.identityId,t[30]=l.identityTitle,t[31]=l.lastSeen,t[32]=l.never,t[33]=l.noAccessIdentity,t[34]=l.noOnlineEndpoints,t[35]=l.noPermissions,t[36]=l.permissions,t[37]=l.status,t[38]=l.statusLabel,t[39]=l.toolCount,t[40]=n,t[41]=h,t[42]=s,t[43]=o,t[44]=C,t[45]=F):F=t[45];let I;t[46]!==r||t[47]!==l.removeDevice||t[48]!==l.revoking||t[49]!==n||t[50]!==a||t[51]!==C?(I=n&&C!==`revoked`?(0,z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,z.jsxs)(w,{variant:`secondary`,className:`w-full text-danger`,disabled:r,onClick:()=>a(n),children:[(0,z.jsx)(re,{className:`size-4`,"aria-hidden":!0}),r?l.revoking:l.removeDevice]})}):null,t[46]=r,t[47]=l.removeDevice,t[48]=l.revoking,t[49]=n,t[50]=a,t[51]=C,t[52]=I):I=t[52];let R;t[53]!==P||t[54]!==F||t[55]!==I?(R=(0,z.jsxs)(v,{children:[D,(0,z.jsxs)(y,{className:O,"aria-describedby":void 0,children:[P,F,I]})]}),t[53]=P,t[54]=F,t[55]=I,t[56]=R):R=t[56];let B;return t[57]!==R||t[58]!==T||t[59]!==E?(B=(0,z.jsx)(x,{open:T,onOpenChange:E,children:R}),t[57]=R,t[58]=T,t[59]=E,t[60]=B):B=t[60],B}function de(e){return e.language}function W(e){let t=(0,L.c)(10),{label:n,value:r,breakAll:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`break-all font-mono text-xs`,c;t[2]===s?c=t[3]:(c=f(`mt-1 text-sm text-fg`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,z.jsx)(`dd`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function fe({device:e,zh:t,onRename:n}){let[r,i]=(0,R.useState)(e.displayName),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(!1);return(0,z.jsxs)(`form`,{className:`space-y-2`,onSubmit:async t=>{if(t.preventDefault(),!(a||!r.trim())){o(!0),c(!1);try{await n(e,r.trim())}catch{c(!0)}finally{o(!1)}}},children:[(0,z.jsxs)(`label`,{className:`block text-sm text-fg`,children:[t?`设备名称`:`Device name`,(0,z.jsx)(`input`,{value:r,maxLength:80,onChange:e=>i(e.target.value),className:`mt-2 h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-fg`})]}),(0,z.jsx)(w,{type:`submit`,variant:`secondary`,disabled:a||!r.trim()||r.trim()===e.displayName,children:a?t?`保存中…`:`Saving…`:t?`保存名称`:`Save name`}),s?(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`保存失败,请刷新设备信息后重试。`:`Unable to save. Refresh device information and retry.`}):null]})}function pe(e){let t=(0,L.c)(19),{onPaired:n}=e,[r,a]=i(),o=m(he),s;t[0]===o?s=t[1]:(s=ee(o),t[0]=o,t[1]=s);let c=s.endpointToolsSettings.deviceAccess,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u={open:!1},t[2]=u):u=t[2];let[d,f]=(0,R.useState)(u),p,h;t[3]!==r||t[4]!==a?(p=()=>{let e=r.get(`startDevicePairing`);e!==`mobile`&&e!==`browser`||(f({open:!0,target:e}),a(me,{replace:!0}))},h=[r,a],t[3]=r,t[4]=a,t[5]=p,t[6]=h):(p=t[5],h=t[6]),(0,R.useEffect)(p,h);let g,_;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>f({open:!0}),_=(0,z.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t[7]=g,t[8]=_):(g=t[7],_=t[8]);let v;t[9]===c.addDevice?v=t[10]:(v=(0,z.jsxs)(w,{variant:`primary`,onClick:g,children:[_,c.addDevice]}),t[9]=c.addDevice,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>f(t=>({...t,open:e})),t[11]=y):y=t[11];let b;t[12]!==d.open||t[13]!==d.target||t[14]!==n?(b=(0,z.jsx)(F,{open:d.open,onOpenChange:y,onPaired:n,targetKind:d.target}),t[12]=d.open,t[13]=d.target,t[14]=n,t[15]=b):b=t[15];let x;return t[16]!==v||t[17]!==b?(x=(0,z.jsxs)(z.Fragment,{children:[v,b]}),t[16]=v,t[17]=b,t[18]=x):x=t[18],x}function me(e){let t=new URLSearchParams(e);return t.delete(`startDevicePairing`),t}function he(e){return e.language}async function G(e){let t=await e.json().catch(()=>null);if(!e.ok||t?.payload===void 0)throw Error(t?.error?.message??`Endpoint management request failed: ${e.status}`);return t.payload}function ge(){return h(`/api/endpoint-tools/devices`)}function _e(e){let t=new URLSearchParams({page:String(e.page),pageSize:String(e.pageSize)});return e.query.trim()&&t.set(`query`,e.query.trim()),e.principalId&&t.set(`principalId`,e.principalId),e.status&&t.set(`status`,e.status),e.effect&&t.set(`effect`,e.effect),h(`/api/endpoint-tools/invocations?${t}`)}async function ve(){return G(await p(ge()))}async function ye(e){let t=Array.from({length:Math.ceil(e.length/100)},(t,n)=>e.slice(n*100,(n+1)*100));await Promise.all(t.map(async e=>{await G(await p(h(`/api/endpoint-tools/devices/revoke`),{method:`POST`,body:JSON.stringify({ids:e})}))}))}async function be(e){return G(await p(_e(e)))}async function xe(e,t,n){await G(await p(h(`/api/endpoint-tools/devices/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({nickname:t,expectedRevision:n})}))}var Se=5e3,K=20,Ce=20;function we(e){return e===`online`||e===`succeeded`?`bg-success-soft text-success`:e===`running`?`bg-accent-soft text-accent-fg`:e===`failed`||e===`revoked`?`bg-danger-soft text-danger`:`bg-surface-hover text-fg-muted`}function Te(e){let t=(0,L.c)(5),{status:n,label:r}=e,i;t[0]===n?i=t[1]:(i=f(`rounded-full px-2 py-0.5 text-xs font-medium`,we(n)),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`span`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Ee(){let e=m(e=>e.language),t=ee(e).endpointToolsSettings,[n,r]=i(),l=n.get(`view`)===`activity`?`activity`:`devices`,[d,p]=(0,R.useState)(null),[h,g]=(0,R.useState)([]),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(``),[T,te]=(0,R.useState)(`active`),[ne,F]=(0,R.useState)(``),[L,B]=(0,R.useState)(1),[V,H]=(0,R.useState)(()=>new Set),[de,W]=(0,R.useState)(``),[fe]=E(de,250),[me,he]=(0,R.useState)(``),[G,we]=(0,R.useState)(``),[Ee,De]=(0,R.useState)(``),[Oe,q]=(0,R.useState)(1),ke={page:Oe,pageSize:Ce,query:fe,principalId:me,status:G,effect:Ee},J=C(ge(),ve,{refreshInterval:Se}),Y=C(l===`activity`?_e(ke):null,()=>be(ke),{refreshInterval:Se,keepPreviousData:!0}),Ae=(0,R.useMemo)(()=>new Intl.DateTimeFormat(e===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),[e]);if(J.isLoading&&!J.data)return(0,z.jsx)(N,{children:(0,z.jsx)(I,{sections:2})});let X=J.data??[],je=Y.data?.items??[],Me=X.filter(e=>U(e)===`online`).length,Ne=X.filter(e=>U(e)!==`revoked`).length,Pe=X.filter(e=>se(e)).length,Fe=[...new Set(X.map(e=>e.platform))].toSorted(),Z=ce(X,{query:x,status:T,platform:ne}),Ie=Math.max(1,Math.ceil(Z.length/K)),Q=Math.min(L,Ie),Le=Z.slice((Q-1)*K,Q*K),$=Le.reduce((e,t)=>(U(t)!==`revoked`&&e.push(t.id),e),[]),Re=$.length>0&&$.every(e=>V.has(e)),ze=e=>{r(t=>{let n=new URLSearchParams(t);return e===`devices`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})},Be=async()=>{await Promise.all([J.mutate(),l===`activity`?Y.mutate():Promise.resolve()])},Ve=async()=>{if(!(h.length===0||_)){v(!0),b(!1);try{await ye(h.map(e=>e.id)),g([]),H(new Set),await J.mutate()}catch{b(!0)}finally{v(!1)}}},He=e=>{e(),B(1),H(new Set)};return(0,z.jsxs)(N,{children:[(0,z.jsx)(M,{title:t.title,subtitle:t.subtitle,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(O,{className:`size-9 shrink-0 p-0`,label:t.refresh,onClick:Be}),(0,z.jsx)(pe,{onPaired:()=>void J.mutate()})]})}),J.error||Y.error?(0,z.jsx)(`div`,{className:`rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger`,children:t.loadError}):null,(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{label:t.activeDevices,value:Ne,filter:`active`},{label:t.onlineDevices,value:Me,filter:`online`},{label:t.staleDevices,value:Pe,filter:`stale`}].map(({label:e,value:t,filter:n})=>(0,z.jsxs)(`button`,{type:`button`,className:f(`touch-target rounded-xl px-4 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,T===n?`bg-surface-active`:`bg-surface-hover/20 hover:bg-surface-hover/50`),"aria-pressed":T===n,onClick:()=>{He(()=>te(n)),ze(`devices`)},children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e}),(0,z.jsx)(`span`,{className:`mt-1 block text-2xl font-semibold text-fg`,children:t})]},n))}),(0,z.jsx)(j,{items:[{id:`devices`,label:t.devicesTab,icon:ie,count:Ne},{id:`activity`,label:t.activityTab,icon:a,count:Y.data?.total}],activeTab:l,onChange:ze,ariaLabel:t.viewsAria,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`}),(0,z.jsxs)(P,{id:`devices`,activeTab:l,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.devicesTitle,hint:t.devicesHint,children:[(0,z.jsx)(ae,{devices:X,zh:e===`zh`}),(0,z.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-[minmax(0,1fr)_11rem_11rem]`,children:[(0,z.jsxs)(`label`,{className:`relative block`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:t.searchDevices}),(0,z.jsx)(u,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`input`,{type:`search`,"aria-label":t.searchDevices,value:x,placeholder:t.searchDevices,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>He(()=>S(e.target.value))})]}),(0,z.jsx)(c,{value:T,options:[{value:`active`,label:t.filterActive},{value:`online`,label:t.status.online},{value:`offline`,label:t.status.offline},{value:`stale`,label:t.filterStale},{value:`revoked`,label:t.status.revoked},{value:`all`,label:t.filterAll}],placeholder:t.statusLabel,allowEmpty:!1,ariaLabel:t.statusLabel,onChange:e=>He(()=>te(e))}),(0,z.jsx)(c,{value:ne,options:Fe.map(e=>({value:e,label:e})),placeholder:t.allPlatforms,emptyLabel:t.allPlatforms,ariaLabel:t.platformLabel,onChange:e=>He(()=>F(e))})]}),V.size>0?(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-accent-fg`,children:t.selectedCount.replace(`{{count}}`,String(V.size))}),(0,z.jsxs)(w,{variant:`secondary`,className:`text-danger`,onClick:()=>{b(!1),g(X.filter(e=>V.has(e.id)))},children:[(0,z.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t.removeSelected]})]}):null,X.length===0?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noDevices}):Z.length===0?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingDevices}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-edge-subtle px-1`,children:(0,z.jsxs)(`label`,{className:f(`touch-target flex items-center gap-2 text-xs text-fg-muted`,$.length>0?`cursor-pointer`:`cursor-not-allowed opacity-50`),children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":t.selectPage,checked:Re,disabled:$.length===0,className:`size-4 accent-accent`,onChange:e=>{H(t=>{let n=new Set(t);for(let t of $)e.target.checked?n.add(t):n.delete(t);return n})}}),t.selectPage]})}),(0,z.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:Le.map(e=>{let n=U(e),r=e.kind===`mobile`?D:k;return(0,z.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`label`,{className:f(`touch-target flex size-10 shrink-0 items-center justify-center`,n===`revoked`?`cursor-not-allowed opacity-40`:`cursor-pointer`),children:(0,z.jsx)(`input`,{type:`checkbox`,checked:V.has(e.id),disabled:n===`revoked`,"aria-label":t.selectDevice.replace(`{{name}}`,e.displayName),className:`size-4 accent-accent`,onChange:t=>{H(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}})}),(0,z.jsxs)(`button`,{type:`button`,className:`touch-target flex min-w-0 flex-1 items-center gap-3 py-3 text-left hover:bg-surface-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>p(e),children:[(0,z.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-inset text-fg-muted`,children:(0,z.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),(0,z.jsx)(Te,{status:n,label:t.status[n]})]}),(0,z.jsxs)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:[e.platform,` · `,le(e.id),` · `,t.lastSeen,`: `,e.lastSeenAt?Ae.format(e.lastSeenAt):t.never]})]}),(0,z.jsx)(`span`,{className:`hidden shrink-0 text-right text-xs text-fg-muted sm:block`,children:t.endpointSummary.replace(`{{endpoints}}`,String(e.endpoints.length)).replace(`{{tools}}`,String(oe(e)))}),(0,z.jsx)(s,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})]},e.id)})}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((Q-1)*K+1)).replace(`{{to}}`,String(Math.min(Q*K,Z.length))).replace(`{{total}}`,String(Z.length))}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:Q<=1,onClick:()=>B(e=>Math.max(1,e-1)),children:(0,z.jsx)(o,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:Q>=Ie,onClick:()=>B(e=>Math.min(Ie,e+1)),children:(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0})})]})]})]})]}),(0,z.jsxs)(P,{id:`activity`,activeTab:l,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.callsTitle,hint:t.callsHint,children:[(0,z.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,z.jsxs)(`label`,{className:`relative block sm:col-span-2 lg:col-span-1`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:t.searchActivity}),(0,z.jsx)(u,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`input`,{type:`search`,"aria-label":t.searchActivity,value:de,placeholder:t.searchActivity,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>{W(e.target.value),q(1)}})]}),(0,z.jsx)(c,{value:me,options:X.map(e=>({value:e.id,label:`${e.displayName} · ${le(e.id)}`})),placeholder:t.allDevices,emptyLabel:t.allDevices,ariaLabel:t.deviceLabel,onChange:e=>{he(e),q(1)}}),(0,z.jsx)(c,{value:G,options:[{value:`running`,label:t.status.running},{value:`succeeded`,label:t.status.succeeded},{value:`failed`,label:t.status.failed}],placeholder:t.allStatuses,emptyLabel:t.allStatuses,ariaLabel:t.statusLabel,onChange:e=>{we(e),q(1)}}),(0,z.jsx)(c,{value:Ee,options:[{value:`read`,label:t.effects.read},{value:`write`,label:t.effects.write},{value:`destructive`,label:t.effects.destructive}],placeholder:t.allEffects,emptyLabel:t.allEffects,ariaLabel:t.effectLabel,onChange:e=>{De(e),q(1)}})]}),Y.isLoading&&!Y.data?(0,z.jsx)(I,{sections:1}):null,je.length===0&&!Y.isLoading?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingCalls}):null,(0,z.jsx)(`div`,{className:`space-y-2`,children:je.map(e=>(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`break-all text-sm font-medium text-fg`,children:e.toolName}),(0,z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[Ae.format(e.startedAt),` · `,t.effects[e.effect],` · `,e.endpointId]}),e.errorMessage?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e.errorMessage}):null]}),(0,z.jsx)(Te,{status:e.status,label:t.status[e.status]})]},e.id))}),Y.data&&Y.data.total>0?(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((Y.data.page-1)*Y.data.pageSize+1)).replace(`{{to}}`,String(Math.min(Y.data.page*Y.data.pageSize,Y.data.total))).replace(`{{total}}`,String(Y.data.total))}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:Y.data.page<=1,onClick:()=>q(e=>Math.max(1,e-1)),children:(0,z.jsx)(o,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:Y.data.page>=Y.data.totalPages,onClick:()=>q(e=>Math.min(Y.data.totalPages,e+1)),children:(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0})})]})]}):null]}),(0,z.jsx)(ue,{device:d,busy:_,onRename:async(e,t)=>{await xe(e.id,t,e.settingsRevision??0),p((await J.mutate())?.find(t=>t.id===e.id)??null)},onClose:()=>p(null),onRevoke:e=>{p(null),b(!1),g([e])}}),(0,z.jsx)(A,{open:h.length>0,title:h.length>1?t.removeManyTitle:t.removeTitle,description:`${h.length>1?t.removeManyDescription.replace(`{{count}}`,String(h.length)):t.removeDescription.replace(`{{name}}`,h[0]?.displayName??``)}${y?`\n\n${t.revokeError}`:``}`,confirmLabel:_?t.revoking:t.removeDevice,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void Ve(),onCancel:()=>{_||g([])}})]})}export{Ee as EndpointToolsManagementSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./popover-select-BgSdSbCL.js";import{x as s}from"./markdown-view-BHFFusQs.js";import{t as c}from"./play-kxZvpBg8.js";import{t as l}from"./settings-2-D-csvaET.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./messages-C1SUo4gG.js";import{a as f,n as p,r as m}from"./locale-store-rWFLl-p4.js";import{rt as h,t as g,u as _,w as v}from"./session-manager-B06ZCie_.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./dist-C3DSFZCi.js";import{t as T}from"./skeleton-BwbyijEw.js";import{t as E}from"./date-formatters-CUZAyDEg.js";import{$i as ee,$o as D,Eo as O,Ji as k,Jr as A,K as j,Lc as M,Q as te,Rc as ne,Sa as re,bs as ie,da as N,do as ae,ea as P,ha as oe,n as se,q as ce,wa as F,zc as le}from"./index-B40-KDN8.js";import{l as I,n as ue,t as de}from"./voice-config-api-6MINytQl.js";var L=n(),R=e(t(),1),z=r();function B(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var fe=B();function pe({zh:e}){let[t,n]=(0,R.useState)(),[r,i]=(0,R.useState)(``),[a,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=c.trim().toLowerCase().replaceAll(`_`,` `),d=[...new Set([...fe,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(u)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,R.useEffect)(()=>{let e=!0;return f(m(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(h.parse(t.payload))}).catch(t=>{e&&i(String(t))}),()=>{e=!1}},[]);async function p(e){if(!(!t||a)){s(!0),i(``);try{let r=await f(m(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(h.parse(r.payload))}catch(e){i(String(e));let t=await f(m(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(h.parse(t.payload))}finally{s(!1)}}}return(0,z.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,z.jsx)(T,{className:`h-9 w-full`}):t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(o,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:a,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void p({mode:e})}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默开始`:`Quiet from`,(0,z.jsx)(o,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietStart:Number(e)})})]}),(0,z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默结束`:`Quiet until`,(0,z.jsx)(o,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietEnd:Number(e)})})]})]}),(0,z.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,z.jsx)(o,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:d,disabled:a,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:c,onSearchChange:l,statusMessage:d.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{l(``),e!==t.timezone&&p({timezone:e})}})]}),(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}var V=[`intro`,`identity`,`voice`,`connections`],me=[{id:`loopi`,zh:`小环`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function he(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function ge(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await f(m(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),ee(e)}function _e({modelsAvailable:e,onCreated:t}){let n=p(e=>e.language)===`zh`,r=p(e=>e.language),[o,s]=(0,R.useState)(`intro`),[l,u]=(0,R.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[h,g]=(0,R.useState)(!1),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(null),[x,S]=(0,R.useState)(null),[C,w]=(0,R.useState)(null),[E,ee]=(0,R.useState)(null),[D,O]=(0,R.useState)(!0),[A,M]=(0,R.useState)([]),[ie,N]=(0,R.useState)(null),P=(0,R.useRef)(null),se=(0,R.useRef)(null),[L,B]=(0,R.useState)([]),[fe,pe]=(0,R.useState)(!0),[_e,ve]=(0,R.useState)([]),[H,U]=(0,R.useState)(null);(0,R.useEffect)(()=>{let e=!1;return f(m(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),u(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||g(!0)}),()=>{e=!0}},[]),(0,R.useEffect)(()=>{if(!h)return;let e=window.setTimeout(()=>{f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:l})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[l,h,o]),(0,R.useEffect)(()=>{let e=!1;return de().then(t=>{e||(t.tts&&t.enabled?ee({provider:t.tts.provider,model:t.tts.model,enabled:!0}):O(!1))}).catch(()=>{e||O(!1)}),()=>{e=!0}},[]),(0,R.useEffect)(()=>{if(!E?.enabled)return;let e=!1;return ue(E.provider,E.model,`realtime`).then(t=>{e||M(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||O(!1)}),()=>{e=!0}},[E]),(0,R.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return pe(!0),Promise.allSettled([re({page:1,pageSize:24,verification:`verified`}),F()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];B(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&ve(n.value),pe(!1)}}),()=>{e=!0}},[o]),(0,R.useEffect)(()=>()=>{se.current?.abort(),P.current?.close()},[]),(0,R.useEffect)(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);let W=async(e,t=l)=>{await f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},ye=async e=>{b(null);let t=V[Math.max(0,Math.min(V.length-1,V.indexOf(o)+e))];try{await W(t)}catch(e){b(e instanceof Error?e.message:String(e))}},G=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:l,r=e.voice&&E?.enabled&&A.some(t=>t.id===e.voice)?{provider:E.provider,model:E.model,voice:e.voice}:void 0,i=(await f(m(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&x)try{await ge(i.agentId,x),i=(await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`,preferences:i.preferences})})).payload}catch{a=!0}t(i,a)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}}},be=(0,R.useCallback)(async e=>{se.current?.abort(),P.current?.close();let t=new AbortController;se.current=t,N(e),b(null);try{let n=new oe;P.current=n,await n.start();let r=await I(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>N(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),N(null)}},[]);if(!h)return(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,z.jsx)(T,{className:`h-10 w-2/3`}),(0,z.jsx)(T,{className:`h-64 w-full rounded-2xl`}),(0,z.jsx)(T,{className:`h-12 w-full rounded-xl`})]});let K=V.indexOf(o),xe={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[o];return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,z.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[K>0?(0,z.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void ye(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,z.jsx)(le,{className:`size-4`}),n?`上一步`:`Back`]}):(0,z.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,z.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,z.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":K+1,"aria-valuemin":1,"aria-valuemax":V.length,children:V.map((e,t)=>(0,z.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=K?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,z.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,z.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,z.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,z.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:C?(0,z.jsx)(`img`,{src:C,alt:``,className:`size-14 rounded-xl object-cover`}):(0,z.jsx)(k,{appearance:l.appearance,className:`size-14`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,z.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:l.displayName||`Ada`})]})]}),(0,z.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${K+1} 步 · 共 ${V.length} 步`:`Step ${K+1} of ${V.length}`}),(0,z.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:xe}),o===`intro`&&(0,z.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,z.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,z.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,z.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,z.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,z.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,z.jsx)(`input`,{value:l.displayName,maxLength:60,onChange:e=>u(t=>({...t,displayName:e.target.value})),onBlur:()=>u(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[me.map(e=>(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&l.appearance===e.id,onClick:()=>{S(null),w(null),u(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!x&&l.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,z.jsx)(k,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,z.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${x?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,z.jsx)(ae,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,z.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){b(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}S(t),w(URL.createObjectURL(t))}}})]})]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),o===`voice`&&(0,z.jsxs)(`div`,{className:`mt-5`,children:[(0,z.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),D?(0,z.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(T,{className:`h-20 rounded-xl`}),(0,z.jsx)(T,{className:`h-20 rounded-xl`})]}):E?.enabled&&A.length>0?(0,z.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-pressed":!l.voice,onClick:()=>u(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${l.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),A.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${l.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":l.voice===e.id,onClick:()=>u(t=>({...t,voice:e.id})),children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void be(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,z.jsx)(c,{className:`size-4 ${ie===e.id?`text-accent`:``}`})})]},e.id))]}):(0,z.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,z.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,z.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,z.jsxs)(`div`,{className:`mt-5`,children:[(0,z.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),fe?(0,z.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,z.jsx)(T,{className:`h-18 rounded-xl`}),(0,z.jsx)(T,{className:`h-18 rounded-xl`})]}):(0,z.jsx)(`div`,{className:`mt-5 space-y-2`,children:L.length?L.map(e=>{let t=he(_e.find(t=>t.connectorId===e.id));return(0,z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,z.jsx)(te,{connector:e,size:`sm`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,z.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,z.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,z.jsx)(`button`,{type:`button`,onClick:()=>U(j(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,z.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,z.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,z.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,z.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,z.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void G(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),o===`voice`&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>{let e={...l,voice:null};u(e),b(null),W(`connections`,e).catch(e=>b(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,z.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void G():void ye(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[_?n?`正在创建…`:`Creating…`:o===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!_&&(0,z.jsx)(ne,{className:`size-4`})]})]})]})}),H&&(0,z.jsx)(ce,{draft:H,onChange:U,onClose:()=>U(null),t:d(r).connectorsSettings,onInstalled:async()=>{ve(await F()),U(null)}})]})}function ve({record:e,zh:t,onSelectVoice:n}){let[r,a]=(0,R.useState)(!0),[s,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(null),[f,p]=(0,R.useState)([]),[m,h]=(0,R.useState)(e.voicePreference?.voice??``),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(null),[b,x]=(0,R.useState)(null),S=(0,R.useRef)(null),C=(0,R.useRef)(null);(0,R.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await de();if(e||!t.enabled||!t.tts)return;let n={provider:t.tts.provider,model:t.tts.model};d(n);let r=await ue(n.provider,n.model,`realtime`);e||p(r)}catch(t){e||y(t instanceof Error?t.message:String(t))}finally{e||a(!1)}})(),()=>{e=!0}},[]),(0,R.useEffect)(()=>()=>{C.current?.abort(),S.current?.close()},[]);let w=()=>{C.current?.abort(),C.current=null,S.current?.close(),S.current=null,x(null)},E=async e=>{if(b!==null){w();return}w(),y(null);let t=new AbortController;C.current=t,x(e);try{let n=new oe;S.current=n,await n.start();let r=await I(t.signal,e);t.signal.aborted||n.enqueue(r,()=>{C.current===t&&(x(null),C.current=null,S.current=null,n.close())})}catch(e){t.signal.aborted||y(e instanceof Error?e.message:String(e)),C.current===t&&w()}},ee=async e=>{if(g||e===m)return;w();let t=m;h(e),l(``),_(!0),y(null);try{await n(e&&u?{provider:u.provider,model:u.model,voice:e}:null)||h(t)}catch(e){h(t),y(e instanceof Error?e.message:String(e))}finally{_(!1)}},D=f.find(e=>e.id===m),k=t?`默认声音`:`Default voice`,A=D?.name||(m?t?`当前音色不可用`:`Current voice unavailable`:k),j=s.trim().toLocaleLowerCase(),M=f.filter(e=>!j||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(j)).map(e=>({value:e.id,label:e.name}));return(0,z.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),r?(0,z.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,z.jsx)(T,{className:`h-10 w-full`})}):u&&f.length?(0,z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(o,{value:m,selectedLabel:A,options:M,placeholder:k,emptyLabel:k,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:g,onChange:e=>void ee(e),searchPlaceholder:f.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:s,onSearchChange:l,statusMessage:j&&!M.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,z.jsxs)(`button`,{type:`button`,disabled:g||!!(m&&!D),onClick:()=>void E(m),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:b===null?t?`试听${A}`:`Preview ${A}`:t?`停止试听`:`Stop preview`,"aria-label":b===null?t?`试听${A}`:`Preview ${A}`:t?`停止试听`:`Stop preview`,children:[b===null?(0,z.jsx)(c,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),b===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:D?.description||D?.style||(m?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,z.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,z.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),v&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:v})]})}var H=new g;function U({conversationId:e,zh:t,onSaved:n}){let r=v(t=>t.sessions[e]),[i,a]=(0,R.useState)(!0),[o,s]=(0,R.useState)(``);(0,R.useEffect)(()=>{let t=!0;return H.loadSessionAgentConfig(e).then(n=>{t&&_(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let c=!!(r?.sending||r?.streaming||r?.modelConfigSaving);async function l(t,i){v.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{_(e,await H.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await H.loadSessionAgentConfig(e).catch(()=>null);throw n&&_(e,n),t}finally{v.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,z.jsx)(T,{className:`h-9 w-full`}):(0,z.jsx)(A,{chat:d(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:c,thinkingDisabled:c,onModelChange:l,onThinkingChange:e=>l(r?.model??``,e)}),o&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var W=5;function ye(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function G(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function be(e){let t=(0,L.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=G(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,c;t[3]===n.id?c=t[4]:(c=s(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,u;t[5]===l?u=t[6]:(u=(0,z.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=ye(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,z.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:d}),t[9]=d,t[10]=f);let p;t[11]===o.label?p=t[12]:(p=(0,z.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=E(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,z.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,z.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,_]}),t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==f?(y=(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,v]}),t[22]=v,t[23]=f,t[24]=y):y=t[24];let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,z.jsx)(M,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==c||t[28]!==u?(x=(0,z.jsxs)(i,{to:c,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,y,b]}),t[26]=y,t[27]=c,t[28]=u,t[29]=x):x=t[29],x}var K=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],xe=[{id:`loopi`,zh:`小环`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function Se(e,t){return e.warmth===`reserved`?t?`你可以直接说目标或问题。我会先给结论,需要时再展开。`:`Tell me the goal or question. I’ll lead with the answer and expand when useful.`:e.warmth===`gentle`?t?`想聊一件事,或让我帮你推进工作,都可以从这里开始。我会认真听,也会把下一步说清楚。`:`You can talk something through or ask me to move work forward. I’ll listen carefully and make the next step clear.`:t?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`}function Ce(e){return K.find(t=>t.warmth===e.warmth)?.id??`natural`}function we(){let e=N(),t=(0,R.useRef)(e);t.current=e;let n=p(e=>e.language)===`zh`,r=P(e=>e.setPageHeader),i=P(e=>e.clearPageHeader),[a,s]=(0,R.useState)(null),c=(0,R.useRef)(null),d=(0,R.useRef)(Promise.resolve()),[h,g]=(0,R.useState)([]),[_,v]=(0,R.useState)(!0),[E,O]=(0,R.useState)(0),[A,j]=(0,R.useState)(null),[M,te]=(0,R.useState)(!0),[ne,re]=(0,R.useState)(!1),[oe,ce]=(0,R.useState)(`natural`),[F,le]=(0,R.useState)(`loopi`),[I,ue]=(0,R.useState)(!1),de=(0,R.useRef)(null),L=(0,R.useRef)(null),B=(0,R.useRef)(null),[fe,V]=(0,R.useState)(``),[me,he]=(0,R.useState)(`untangle`),[ge,H]=(0,R.useState)(`none`),[ye,G]=(0,R.useState)(`balanced`),[we,Te]=(0,R.useState)(`decisions`),[Ee,De]=(0,R.useState)(!1),[Oe,q]=(0,R.useState)(!1),[J,ke]=(0,R.useState)(!1),[Y,Ae]=(0,R.useState)(null),[je,Me]=(0,R.useState)(!1),[X,Ne]=(0,R.useState)(!1),[Pe,Fe]=(0,R.useState)(!1),[Z,Ie]=(0,R.useState)(0),Q=(0,R.useRef)(0),Le=(0,R.useCallback)(()=>{ke(!1),q(!1),De(!0)},[]),Re=(0,R.useCallback)(()=>{ke(!1),q(!1),De(e=>!e)},[]),ze=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([f(m(`/api/personal-agent`)),f(m(`/api/personal-agent/models`))]);if(c.current=e.payload,s(e.payload),e.payload?.state===`ready`){let e=await f(m(`/api/personal-agent/onboarding`));te(!e.payload.completed||e.payload.welcomeDone)}window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),g(t.payload),e.payload&&(V(e.payload.displayName),le(e.payload.appearance),ce(Ce(e.payload.preferences)),he(e.payload.preferences.supportMode??`untangle`),H(e.payload.preferences.humor??`none`),G(e.payload.preferences.detailLevel??`balanced`),Te(e.payload.preferences.proactivity??`decisions`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{v(!1)}},[]);(0,R.useEffect)(()=>{ze()},[ze]);let $=(0,R.useCallback)(e=>{O(e=>e+1),j(null);let t=d.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i={...t.preferences,...e.preferences},a=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.preferences)&&JSON.stringify(a)===JSON.stringify(t.voicePreference))return!0;try{let o=await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,preferences:i,...e.voicePreference===void 0?{}:{voicePreference:a}})});return c.current=o.payload,s(o.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:o.payload})),!0}catch(e){return j(e instanceof Error?e.message:String(e)),!1}}).finally(()=>O(e=>e-1));return d.current=t,t},[]),Be=async e=>{if(a){j(null);try{if(e){let t=await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:a.revision,displayName:a.displayName,appearance:a.appearance,preferences:{...a.preferences,supportMode:e}})});c.current=t.payload,s(t.payload)}await f(m(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),te(!0)}catch(e){j(e instanceof Error?e.message:String(e))}}},Ve=(0,R.useCallback)(async()=>{let e=++Q.current;ke(!0),Ae(null),Me(!1),Ne(!1),Fe(!1),Ie(0);try{let t=await f(m(`/api/personal-agent/activity?limit=${W}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(t.payload.items.length)}catch{e===Q.current&&Me(!0)}},[]),He=(0,R.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Ne(!0),Fe(!1);try{let t=await f(m(`/api/personal-agent/activity?limit=${W}&offset=${Z}`));if(e!==Q.current)return;Ae(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Ie(e=>e+t.payload.items.length)}catch{e===Q.current&&Fe(!0)}finally{e===Q.current&&Ne(!1)}},[Y,Z,X]);(0,R.useEffect)(()=>{if(!J||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await f(m(`/api/personal-agent/activity?limit=${Math.max(W,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[Y,Z,X,J]);let Ue=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){j(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){j(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}ue(!0),j(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await f(m(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),ee(a.agentId),le(`custom`),q(!1),await $({appearance:`custom`})}catch(e){j(e instanceof Error?e.message:String(e))}finally{ue(!1)}};(0,R.useLayoutEffect)(()=>{let o=a?.state===`ready`,s=o?a.appearance:F,c=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,z.jsx)(`button`,{ref:B,type:`button`,onClick:Re,"aria-expanded":Ee,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${c}的资料`:`Edit ${c}'s profile`,title:n?`资料`:`Profile`,children:(0,z.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,z.jsx)(k,{appearance:s,agentId:a?.agentId,className:`size-8`})})}):(0,z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,z.jsx)(k,{appearance:s,agentId:a?.agentId,className:`size-8`})}),(0,z.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:c})]}),end:o?(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{a?.state===`ready`&&t.current.open({conversationId:a.conversationId,name:a.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,z.jsx)(D,{className:`size-5`})}),(0,z.jsxs)(x,{open:J,onOpenChange:e=>{e?Ve():ke(!1)},children:[(0,z.jsx)(C,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,"aria-pressed":J,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,z.jsx)(ie,{className:`size-5`})})}),(0,z.jsx)(y,{children:(0,z.jsxs)(b,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(25rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-inset shadow-xl focus:outline-none`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y?n?`最近更新 · 共 ${Y.total} 项`:`Recently updated · ${Y.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,z.jsx)(S,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,z.jsx)(u,{className:`size-4`})})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!je&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(T,{className:`h-18 rounded-2xl`}),(0,z.jsx)(T,{className:`h-18 rounded-2xl`}),(0,z.jsx)(T,{className:`h-18 rounded-2xl`})]}),je&&(0,z.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void Ve(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),Y?.items.length===0&&(0,z.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,z.jsx)(ie,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),Y&&Y.items.length>0&&(0,z.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,z.jsx)(be,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,z.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void He(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),Pe&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,z.jsx)(`button`,{ref:L,type:`button`,onClick:Re,"aria-expanded":Ee,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,z.jsx)(l,{className:`size-5`})})]}):null}),()=>i()},[Y,je,Z,X,Pe,F,i,He,Ve,a,r,J,Ee,Re,e.active,n]);function We(){return a?(0,z.jsxs)(x,{open:Ee,onOpenChange:e=>{De(e),e||q(!1)},children:[(0,z.jsx)(w,{virtualRef:L}),(0,z.jsx)(y,{children:(0,z.jsxs)(b,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(L.current?.contains(e.target)||B.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex h-[min(38rem,calc(100dvh-6rem))] w-[min(28rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,z.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>q(e=>!e),"aria-expanded":Oe,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,z.jsx)(k,{appearance:F,agentId:a.agentId,className:`size-20`})}),(0,z.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:fe,onChange:e=>V(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(V(t),$({displayName:t})):V(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,V(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-3 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),E>0&&(0,z.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[A&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:A}),Oe&&(0,z.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[xe.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{le(e.id),q(!1),$({appearance:e.id})},"aria-pressed":F===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${F===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,z.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,z.jsx)(k,{appearance:e.id,className:`size-8`})}),(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,z.jsx)(`input`,{ref:de,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&Ue(t),e.currentTarget.value=``}}),(0,z.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>de.current?.click(),"aria-pressed":F===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${F===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,z.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:F===`custom`?(0,z.jsx)(k,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,z.jsx)(ae,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:I?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,z.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:K.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>{ce(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":oe===e.id,className:`min-h-10 rounded-xl px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${oe===e.id?`bg-accent/10 font-medium text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:n?e.zh:e.en},e.id))})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":me===e,onClick:()=>{he(e),$({preferences:{supportMode:e}})},className:`min-h-9 rounded-full px-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${me===e?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:t},e))})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,z.jsx)(o,{value:ye??`balanced`,options:[{value:`brief`,label:n?`简短`:`Brief`},{value:`balanced`,label:n?`适中`:`Balanced`},{value:`detailed`,label:n?`详细`:`Detailed`}],placeholder:n?`选择长度`:`Choose length`,allowEmpty:!1,onChange:e=>{let t=e;G(t),$({preferences:{detailLevel:t}})}})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,z.jsx)(o,{value:we??`decisions`,options:[{value:`decisions`,label:n?`结果与决定`:`Results only`},{value:`important`,label:n?`重要进展`:`Milestones`},{value:`open`,label:n?`多提建议`:`Suggestions`}],placeholder:n?`选择频率`:`Choose frequency`,allowEmpty:!1,onChange:e=>{let t=e;Te(t),$({preferences:{proactivity:t}})}})]})]}),(0,z.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,z.jsx)(o,{value:ge??`none`,options:[{value:`none`,label:n?`不加玩笑`:`None`},{value:`occasional`,label:n?`偶尔轻松`:`Sometimes`},{value:`playful`,label:n?`活泼`:`Playful`}],placeholder:n?`选择程度`:`Choose level`,allowEmpty:!1,onChange:e=>{let t=e;H(t),$({preferences:{humor:t}})}})]})]}),(0,z.jsx)(pe,{zh:n}),(0,z.jsx)(ve,{record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,z.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,z.jsx)(U,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await f(m(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,s(e.payload))}})})]})]})})]}):null}return _?(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,z.jsx)(T,{className:`h-20 w-20 rounded-full`}),(0,z.jsx)(T,{className:`h-9 w-72`}),(0,z.jsx)(T,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ne&&(0,z.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,z.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{re(!1),Le()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(se,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,z.jsx)(k,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:Se(a.preferences,n),showSupportChoice:!M,onChooseSupport:e=>void Be(e),onSkipSupport:()=>void Be(),supportChoiceError:A},conversationId:a.conversationId})})}),We()]}):(0,z.jsx)(_e,{modelsAvailable:h.length>0,onCreated:(e,t)=>{c.current=e,s(e),V(e.displayName),te(!1),re(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{we as PersonalPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Sn as e}from"./index-B40-KDN8.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i,t as a,u as o}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as s}from"./bot-DjLkhyZL.js";import{t as c}from"./check-DUBLcKHA.js";import{t as l}from"./chevron-right-BweFrslA.js";import{n as u,r as d,t as f}from"./popover-select-BgSdSbCL.js";import{t as p}from"./circle-alert-BEjgurr2.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./clock-3-DnrAnuyZ.js";import{t as g}from"./download-Dk-ZjtO6.js";import{t as _}from"./ellipsis-0k4rZLoy.js";import{t as v}from"./folder-open-CyzJ19I9.js";import{t as y}from"./git-branch-Dh9uxTot.js";import{t as b}from"./loader-circle-CifKLtgG.js";import{t as x}from"./pencil-DmIY3Oa-.js";import{t as S}from"./plus-Q2yW6OE7.js";import{t as C}from"./search-DA7gz22f.js";import{t as w}from"./sparkles-DHlfQFAF.js";import{t as T}from"./x-B_N4OPjy.js";import{t as ee}from"./cn-JdwAhgNB.js";import{n as E}from"./locale-store-rWFLl-p4.js";import{a as D,c as O,i as te,n as k,o as A,r as j,s as M,t as N}from"./dist-BGTk37IG.js";import{i as P}from"./vendor-swr-BIWyz7Rc.js";import{t as F}from"./button-CS04eWY9.js";import{r as I}from"./app-chrome-BeB4KgOf.js";import{t as L}from"./skeleton-BwbyijEw.js";import{t as R}from"./loopi-Djb8XU3l.js";import{$ as z,Cc as B,Co as V,Dc as H,Ec as U,Fn as W,Gs as G,Ho as K,In as ne,Ln as re,Mc as ie,Ms as ae,Pn as oe,Po as se,W as q,_s as ce,ac as le,at as J,bs as Y,ct as ue,do as de,dt as fe,ea as pe,et as me,ft as he,ho as ge,hs as _e,it as ve,jo as ye,lc as be,lo as xe,lt as Se,ms as Ce,mt as we,nt as Te,oc as Ee,ot as De,ps as Oe,pt as ke,rt as Ae,st as je,tc as Me,tt as Ne,uo as Pe,ut as Fe,wc as Ie,zn as Le}from"./index-B40-KDN8.js";import{t as Re}from"./page-tabs-D2xpUV26.js";import{t as ze}from"./date-picker-DiQxRpe-.js";var X=e(t(),1),Z=n(),Q=r();function Be(e){let t=(0,Z.c)(15),{sourceId:n,disabled:r}=e,i=r===void 0?!1:r,a=E(Ue)===`zh`,{sources:o,starting:s,start:c}=q(),l;t[0]!==n||t[1]!==o?(l=n?o.filter(e=>e.grantId===n):o,t[0]=n,t[1]=o,t[2]=l):l=t[2];let u=l,d;t[3]===u?d=t[4]:(d=u.some(He),t[3]=u,t[4]=d);let f=d,p=n&&u.some(Ve),m=f?a?`更新中`:`Updating`:p?a?`重试`:`Retry`:n?a?`更新理解`:`Update understanding`:a?`更新全部`:`Update all`,h=i||s||f,g;t[5]!==n||t[6]!==c?(g=()=>void c(n),t[5]=n,t[6]=c,t[7]=g):g=t[7];let _;t[8]===f?_=t[9]:(_=f?(0,Q.jsx)(b,{className:`size-3.5 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(K,{className:`size-3.5`}),t[8]=f,t[9]=_);let v;return t[10]!==m||t[11]!==h||t[12]!==g||t[13]!==_?(v=(0,Q.jsxs)(F,{variant:`ghost`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs`,disabled:h,onClick:g,children:[_,m]}),t[10]=m,t[11]=h,t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function Ve(e){return e.status===`failed`||e.status===`partial`||e.status===`canceled`}function He(e){return e.status===`queued`||e.status===`running`}function Ue(e){return e.language}function We(e){let t=(0,Z.c)(22),{sourceId:n,lastCollectedAt:r}=e,i=E(Ge),a=i===`zh`,o;t[0]===n?o=t[1]:(o=e=>e.sources.find(e=>e.grantId===n),t[0]=n,t[1]=o);let s=q(o);if(!s){let e;t[2]!==i||t[3]!==r||t[4]!==a?(e=r?`${a?`上次更新:`:`Last updated: `}${new Date(r).toLocaleString(i)}`:a?`尚未分析`:`Not analyzed yet`,t[2]=i,t[3]=r,t[4]=a,t[5]=e):e=t[5];let n;return t[6]===e?n=t[7]:(n=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e}),t[6]=e,t[7]=n),n}let c;t[8]===a?c=t[9]:(c=a?{queued:`等待更新`,waiting_desktop:`等待桌面端读取资料`,reading:`正在读取资料`,analyzing:`正在更新理解`}:{queued:`Queued`,waiting_desktop:`Waiting for desktop collection`,reading:`Reading source`,analyzing:`Updating understanding`},t[8]=a,t[9]=c);let l=c,u=s.status===`running`||s.status===`queued`,d=s.status===`failed`||s.status===`partial`||s.status===`canceled`,f=s.metadata.added,p=u?l[s.metadata.phase??`queued`]??l.queued:d?a?`更新未完成,可重试`:`Update incomplete; retry available`:f===0?a?`更新完成,暂无新增理解`:`Updated; no new understanding`:f===void 0?a?`更新完成`:`Updated`:a?`更新完成,新增 ${f} 条`:`Updated; ${f} added`,m;t[10]===p?m=t[11]:(m=(0,Q.jsx)(`p`,{children:p}),t[10]=p,t[11]=m);let h;t[12]!==i||t[13]!==s.completedAt?(h=s.completedAt?(0,Q.jsx)(`p`,{children:new Date(s.completedAt).toLocaleString(i)}):null,t[12]=i,t[13]=s.completedAt,t[14]=h):h=t[14];let g;t[15]!==d||t[16]!==s.errorMessage?(g=d&&s.errorMessage?(0,Q.jsx)(`p`,{className:`text-danger`,children:s.errorMessage}):null,t[15]=d,t[16]=s.errorMessage,t[17]=g):g=t[17];let _;return t[18]!==m||t[19]!==h||t[20]!==g?(_=(0,Q.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,"aria-live":`polite`,children:[m,h,g]}),t[18]=m,t[19]=h,t[20]=g,t[21]=_):_=t[21],_}function Ge(e){return e.language}function Ke(e){let t=(0,Z.c)(64),{language:n,busy:r,statement:i,scope:a,onEdit:o,onDelete:c,onScopeChange:l}=e,[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),m=n===`zh`,h=m?`修改或删除这条内容`:`Edit or delete this item`,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(_,{className:`size-4`,"aria-hidden":`true`}),t[0]=g):g=t[0];let v;t[1]!==r||t[2]!==h?(v=(0,Q.jsx)(Le,{asChild:!0,children:(0,Q.jsx)(F,{variant:`ghost`,className:`size-11 shrink-0 p-0`,disabled:r,"aria-label":h,children:g})}),t[1]=r,t[2]=h,t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":`true`}),t[4]=y):y=t[4];let b=m?`修改`:`Edit`,S;t[5]!==r||t[6]!==o||t[7]!==b?(S=(0,Q.jsxs)(W,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:o,children:[y,b]}),t[5]=r,t[6]=o,t[7]=b,t[8]=S):S=t[8];let C;t[9]!==r||t[10]!==l||t[11]!==a||t[12]!==m?(C=a&&l?(0,Q.jsxs)(W,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:()=>p(!0),children:[(0,Q.jsx)(ye,{className:`size-4`,"aria-hidden":`true`}),m?`作用范围`:`Where it applies`]}):null,t[9]=r,t[10]=l,t[11]=a,t[12]=m,t[13]=C):C=t[13];let w,T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>d(!0),T=(0,Q.jsx)(ge,{className:`size-4`,"aria-hidden":`true`}),t[14]=w,t[15]=T):(w=t[14],T=t[15]);let ee=m?`删除`:`Delete`,E;t[16]!==r||t[17]!==ee?(E=(0,Q.jsxs)(W,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:w,children:[T,ee]}),t[16]=r,t[17]=ee,t[18]=E):E=t[18];let O;t[19]!==E||t[20]!==S||t[21]!==C?(O=(0,Q.jsx)(ne,{children:(0,Q.jsxs)(oe,{align:`end`,sideOffset:4,className:`z-[100] min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[S,C,E]})}),t[19]=E,t[20]=S,t[21]=C,t[22]=O):O=t[22];let P;t[23]!==O||t[24]!==v?(P=(0,Q.jsxs)(re,{modal:!1,children:[v,O]}),t[23]=O,t[24]=v,t[25]=P):P=t[25];let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(D,{className:`fixed inset-0 z-[110] bg-scrim`}),t[26]=I):I=t[26];let L=m?`删除这条内容?`:`Delete this item?`,R;t[27]===L?R=t[28]:(R=(0,Q.jsx)(M,{className:`font-semibold text-fg`,children:L}),t[27]=L,t[28]=R);let z=m?`删除后将不再使用这条记忆,原始对话和文件会保留。`:`This memory will no longer be used. Original conversations and files are kept.`,B;t[29]===z?B=t[30]:(B=(0,Q.jsx)(te,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:z}),t[29]=z,t[30]=B);let V;t[31]!==R||t[32]!==B?(V=(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[R,B]}),t[31]=R,t[32]=B,t[33]=V):V=t[33];let H;t[34]===i?H=t[35]:(H=(0,Q.jsx)(`p`,{className:`min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words px-5 py-4 text-sm leading-6 text-fg`,children:i}),t[34]=i,t[35]=H);let U=m?`取消`:`Cancel`,G;t[36]===U?G=t[37]:(G=(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(F,{variant:`ghost`,children:U})}),t[36]=U,t[37]=G);let K;t[38]===c?K=t[39]:(K=()=>{d(!1),c()},t[38]=c,t[39]=K);let ie=m?`删除`:`Delete`,ae;t[40]!==r||t[41]!==K||t[42]!==ie?(ae=(0,Q.jsx)(F,{disabled:r,onClick:K,children:ie}),t[40]=r,t[41]=K,t[42]=ie,t[43]=ae):ae=t[43];let se;t[44]!==G||t[45]!==ae?(se=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3`,children:[G,ae]}),t[44]=G,t[45]=ae,t[46]=se):se=t[46];let q;t[47]!==V||t[48]!==H||t[49]!==se?(q=(0,Q.jsxs)(A,{children:[I,(0,Q.jsxs)(j,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(22rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[V,H,se]})]}),t[47]=V,t[48]=H,t[49]=se,t[50]=q):q=t[50];let ce;t[51]!==u||t[52]!==P||t[53]!==q?(ce=(0,Q.jsxs)(N,{open:u,onOpenChange:d,children:[P,q]}),t[51]=u,t[52]=P,t[53]=q,t[54]=ce):ce=t[54];let J;t[55]!==r||t[56]!==l||t[57]!==a||t[58]!==f||t[59]!==m?(J=a&&l?(0,Q.jsx)(N,{open:f,onOpenChange:p,children:(0,Q.jsxs)(A,{children:[(0,Q.jsx)(D,{className:`fixed inset-0 z-[110] bg-scrim`}),(0,Q.jsxs)(j,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(25rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(M,{className:`font-semibold text-fg`,children:m?`这条记忆在哪里生效?`:`Where should this memory apply?`}),(0,Q.jsx)(te,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m?`你可以让它用于所有协作,或只用于当前助手。`:`Use it across all work, or keep it only for this assistant.`})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-4`,children:[{value:{type:`global`},icon:le,title:m?`所有协作`:`All work`,detail:m?`任何助手和对话都可按需使用`:`Available when relevant in any assistant or conversation`},{value:{type:`agent`,id:a.type===`agent`?a.id??`main`:`main`},icon:s,title:m?`仅当前助手`:`This assistant only`,detail:m?`不会分享给其他助手`:`Not shared with other assistants`}].map(e=>{let{value:t,icon:n,title:i,detail:o}=e,s=a.type===t.type&&(a.id??``)===(t.id??``);return(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full items-center gap-3 rounded-xl px-4 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${s?`bg-surface-active`:`hover:bg-surface-hover`}`,disabled:r,onClick:()=>{p(!1),l(t)},children:[(0,Q.jsx)(n,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:o})]}),s?(0,Q.jsx)(`span`,{className:`text-xs font-medium text-accent-fg`,children:m?`当前`:`Current`}):null]},t.type)})}),(0,Q.jsx)(`footer`,{className:`flex shrink-0 justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(F,{variant:`ghost`,children:m?`取消`:`Cancel`})})})]})]})}):null,t[55]=r,t[56]=l,t[57]=a,t[58]=f,t[59]=m,t[60]=J):J=t[60];let Y;return t[61]!==ce||t[62]!==J?(Y=(0,Q.jsxs)(Q.Fragment,{children:[ce,J]}),t[61]=ce,t[62]=J,t[63]=Y):Y=t[63],Y}function qe(e,t){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}).format(e):null}function Je(e,t,n=new Date){let r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r);i.setDate(r.getDate()-1);let a=new Map;for(let n of[...e].sort((e,t)=>t.recordedAt-e.recordedAt)){let e=n.recordedAt>=r.getTime()?t===`zh`?`今天`:`Today`:n.recordedAt>=i.getTime()?t===`zh`?`昨天`:`Yesterday`:qe(n.recordedAt,t)??(t===`zh`?`更早`:`Earlier`),o=a.get(e)??[];o.push(n),a.set(e,o)}return[...a].map(([e,t])=>({label:e,items:t}))}function Ye(e,t){return(t===`zh`?{user_explicit:`你告诉我的`,user_observed:`从协作中观察到`,system_inferred:`我形成的判断`,external_untrusted:`来自连接的信息`}:{user_explicit:`You told me`,user_observed:`Observed while working together`,system_inferred:`My current read`,external_untrusted:`From connected information`})[e.authority]}function Xe(e,t){if(e.validTo){let n=qe(e.validTo,t);return t===`zh`?`适用至 ${n}`:`Applies until ${n}`}return(t===`zh`?{stable:`相对稳定`,slow:`会随时间复核`,dynamic:`近期状态`,event:`特定阶段`}:{stable:`Relatively stable`,slow:`Reviewed over time`,dynamic:`Current context`,event:`Specific period`})[e.volatility]}function Ze(e,t){return e.authority===`user_explicit`?null:e.confidence>=.85?t===`zh`?`把握较高`:`High confidence`:e.confidence>=.65?t===`zh`?`把握中等`:`Medium confidence`:t===`zh`?`证据较少`:`Limited evidence`}function Qe(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function $e(e){let t=(0,Z.c)(24),{item:n,language:r,busy:i,editing:a,draft:o,onDraftChange:s,onEdit:c,onCancel:l,onDelete:u,onCorrect:d,onScopeChange:f}=e,p=(0,X.useId)(),m=r===`zh`,h;t[0]!==n||t[1]!==r?(h=Ze(n,r),t[0]=n,t[1]=r,t[2]=h):h=t[2];let g=h,_;t[3]===n.sources?_=t[4]:(_=new Set(n.sources?.map(tt).filter(Boolean)),t[3]=n.sources,t[4]=_);let v;t[5]===_?v=t[6]:(v=[..._],t[5]=_,t[6]=v);let y=v,b=m?`修改`:`Edit`,x;return t[7]!==i||t[8]!==g||t[9]!==o||t[10]!==b||t[11]!==a||t[12]!==p||t[13]!==n||t[14]!==r||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==c||t[20]!==f||t[21]!==y||t[22]!==m?(x=(0,Q.jsx)(`article`,{className:`border-t border-edge-subtle px-4 py-3 first:border-t-0 sm:px-5 [content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:a?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:p,children:m?`修改这条理解`:`Edit this understanding`}),(0,Q.jsx)(`textarea`,{id:p,value:o,disabled:i,onChange:e=>s(e.target.value),className:`mt-2 min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-base leading-7 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,disabled:i,onClick:l,children:m?`取消`:`Cancel`}),(0,Q.jsx)(F,{variant:`primary`,disabled:!o.trim()||i,onClick:d,children:i?m?`保存中…`:`Saving…`:m?`保存修改`:`Save changes`})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 pt-1.5`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-base leading-7 text-fg`,children:n.statement}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Ye(n,r)}),n.usable===!1?(0,Q.jsx)(`span`,{children:m?`暂不使用`:`Not in use`}):null,n.validTo?(0,Q.jsx)(`span`,{children:Xe(n,r)}):null,n.authority!==`user_explicit`&&n.confidence<.65?(0,Q.jsx)(`span`,{children:g}):null,(0,Q.jsxs)(`details`,{className:`open:basis-full`,children:[(0,Q.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m?`查看依据`:`View sources`}),(0,Q.jsxs)(`div`,{className:`my-2 space-y-1 border-l-2 border-edge pl-3 text-sm leading-6`,children:[(0,Q.jsx)(`p`,{children:n.usable?m?`按需用于当前协作`:`Used when relevant`:m?`暂不使用,后台继续复核`:`Not in use; reviewed automatically`}),(0,Q.jsxs)(`p`,{children:[Xe(n,r),` · `,Qe(n.scope,r),g?` · ${g}`:``]}),(0,Q.jsxs)(`p`,{children:[m?`最近观察:`:`Last observed: `,qe(n.observedAt,r)]}),(0,Q.jsxs)(`p`,{children:[m?`模型层:`:`Model layer: `,m?{fact:`事实`,pattern:`模式`,interpretation:`解释`}[n.layer]:n.layer,` · `,m?`${n.independentSourceCount} 个独立来源`:`${n.independentSourceCount} independent sources`]}),y.length?y.map(et):(0,Q.jsx)(`p`,{children:m?`暂无更详细的来源记录`:`No further source details available`}),(0,Q.jsx)(F,{variant:`ghost`,className:`-ml-2 px-2`,disabled:i,onClick:c,children:b})]})]})]})]}),(0,Q.jsx)(Ke,{language:r,busy:i,statement:n.statement,scope:n.scope,onEdit:c,onDelete:u,onScopeChange:f})]})}),t[7]=i,t[8]=g,t[9]=o,t[10]=b,t[11]=a,t[12]=p,t[13]=n,t[14]=r,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=c,t[20]=f,t[21]=y,t[22]=m,t[23]=x):x=t[23],x}function et(e){return(0,Q.jsx)(`p`,{className:`break-words`,children:e},e)}function tt(e){return e.label}var nt={zh:{eyebrow:`全局用户理解`,title:`xopc 如何形成对你的理解`,subtitle:`这里汇总跨项目、跨对话形成的认识,并说明它们来自哪些渠道。项目事实不会混入你的个人画像。`,channels:`理解渠道`,channelHint:`查看来源及其最近更新。`,noChannels:`尚未通过任何渠道形成可展示的全局理解。`,activeCount:`{{count}} 条已在使用`,pendingCount:`{{count}} 条暂不使用`,noUnderstanding:`暂无来自此渠道的全局理解`,pending:`最近更新`,pendingHint:`自动整理并按需使用,你可以随时修改或删除。`,nothingPending:`尚未形成全局理解。`,showAll:`查看全部 {{count}} 条`,showLess:`收起`,done:`完成`,updating:`正在从已授权渠道更新理解;你可以先查看已有内容。`,sourceKinds:{user:`你明确告诉我的`,conversation:`对话与协作`,connector:`连接的服务`,work_folder:`工作目录`,local_source:`本机来源`,inference:`综合整理`}},en:{eyebrow:`Global user understanding`,title:`How xopc forms its understanding of you`,subtitle:`This brings together understanding formed across projects and conversations, with the channel behind each item. Project facts stay out of your personal portrait.`,channels:`Understanding channels`,channelHint:`View sources and their latest updates.`,noChannels:`No channel has formed displayable global understanding yet.`,activeCount:`{{count}} in use`,pendingCount:`{{count}} not in use`,noUnderstanding:`No usable global understanding has formed from this channel yet`,pending:`Recent updates`,pendingHint:`Organized automatically and used when relevant. Edit or delete anytime.`,nothingPending:`No understanding has formed yet.`,showAll:`View all {{count}}`,showLess:`Show less`,done:`Done`,updating:`Updating from authorized channels. You can review existing understanding now.`,sourceKinds:{user:`You told me`,conversation:`Conversations and work`,connector:`Connected services`,work_folder:`Work folders`,local_source:`On-device sources`,inference:`Synthesized understanding`}}},rt={"local-recent-files":{en:`Recent files`,zh:`最近文件`},"chromium-bookmarks":{en:`Recent bookmarks`,zh:`最近书签`},"apple-notes":{en:`Apple Notes`,zh:`Apple 备忘录`},"apple-mail":{en:`Apple Mail`,zh:`Apple 邮件`},"apple-calendar":{en:`Apple Calendar`,zh:`Apple 日历`},"apple-reminders":{en:`Apple Reminders`,zh:`Apple 提醒事项`},"windows-recent-documents":{en:`Recent documents`,zh:`最近文档`},"linux-recent-documents":{en:`Recent documents`,zh:`最近文档`}},it={user:xe,conversation:Oe,connector:Ee,work_folder:v,local_source:Me,inference:Ee},$={files:v,recent_documents:Me,calendar:Ie,tasks:Y,notes:V,mail:_e,messages:Oe,code_activity:y};function at(e){let t=e.authority===`user_explicit`?`user`:e.authority===`user_observed`?`conversation`:e.authority===`external_untrusted`?`connector`:`inference`;return{id:t,kind:t,observedAt:e.observedAt}}function ot(e,t){return e.kind===`local_source`&&e.label?rt[e.label]?.[t]??e.label:e.kind===`work_folder`&&e.label?t===`zh`?`工作目录 · ${e.label}`:`Work folder · ${e.label}`:e.label?e.label:nt[t].sourceKinds[e.kind]}function st(e){return`${e.kind}:${e.adapterId}:${e.displayName}`}function ct(e){let t=(0,Z.c)(91),{assertions:n,configuredSources:r,activityRunning:i,language:a,busy:o,error:s,onReviewAssertion:l,onCompleted:u}=e,d=nt[a],[f,p]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(``),y;t[0]===n?y=t[1]:(y=n.filter(ht),t[0]=n,t[1]=y);let x=y,S;t[2]===x?S=t[3]:(S=[...x].sort(mt),t[2]=x,t[3]=S);let C=S,w;if(t[4]!==r||t[5]!==x||t[6]!==a){let e=new Map;for(let t of r){let n=t.kind===`local_source`?rt[t.adapterId]?.[a]??t.displayName:t.displayName,r=st(t);e.set(r,{key:r,grantId:t.id,kind:t.kind,category:t.category,label:t.kind===`work_folder`?a===`zh`?`工作目录 · ${n}`:`Work folder · ${n}`:n,assertions:[],lastObservedAt:t.lastCollectedAt})}for(let t of x)for(let n of t.sources?.length?t.sources:[at(t)]){let r=ot(n,a),i=[...e.values()].find(e=>e.kind===n.kind&&e.label===r),o=i?.key??`${n.kind}:${r}`,s=i??e.get(o)??{key:o,kind:n.kind,category:n.category,label:r,assertions:[],lastObservedAt:n.observedAt};s.assertions.some(e=>e.id===t.id)||s.assertions.push(t),s.lastObservedAt=Math.max(s.lastObservedAt??0,n.observedAt),e.set(o,s)}w=[...e.values()].sort(pt),t[4]=r,t[5]=x,t[6]=a,t[7]=w}else w=t[7];let T=w,E;t[8]===l?E=t[9]:(E=async(e,t,n)=>{await l(e,t,n)&&g(null)},t[8]=l,t[9]=E);let D=E,O,te,k,A,j,M,N,P,I;if(t[10]!==i||t[11]!==o||t[12]!==_||t[13]!==h||t[14]!==a||t[15]!==C||t[16]!==D||t[17]!==f||t[18]!==d.eyebrow||t[19]!==d.nothingPending||t[20]!==d.pending||t[21]!==d.pendingHint||t[22]!==d.showAll||t[23]!==d.showLess||t[24]!==d.subtitle||t[25]!==d.title||t[26]!==d.updating){let e=f?C:C.slice(0,5);O=`mx-auto w-full max-w-[42rem] pb-2`,te=`polite`;let n;t[36]===d.eyebrow?n=t[37]:(n=(0,Q.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-accent-fg`,children:d.eyebrow}),t[36]=d.eyebrow,t[37]=n);let r;t[38]===d.title?r=t[39]:(r=(0,Q.jsx)(`h2`,{className:`mt-3 text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:d.title}),t[38]=d.title,t[39]=r);let s;t[40]===d.subtitle?s=t[41]:(s=(0,Q.jsx)(`p`,{className:`mx-auto mt-3 max-w-[38rem] text-sm leading-6 text-fg-muted`,children:d.subtitle}),t[40]=d.subtitle,t[41]=s),t[42]!==n||t[43]!==r||t[44]!==s?(k=(0,Q.jsxs)(`div`,{className:`text-center`,children:[n,r,s]}),t[42]=n,t[43]=r,t[44]=s,t[45]=k):k=t[45],t[46]!==i||t[47]!==d.updating?(A=i?(0,Q.jsxs)(`div`,{className:`mt-6 flex items-center gap-3 rounded-xl border border-accent/20 bg-accent-soft/55 px-4 py-3 text-sm text-accent-fg`,children:[(0,Q.jsx)(b,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`}),(0,Q.jsx)(`p`,{children:d.updating})]}):null,t[46]=i,t[47]=d.updating,t[48]=A):A=t[48],j=`mt-8`,M=`understanding-updates-title`;let c=C.length?` · ${C.length}`:``;t[49]!==d.pending||t[50]!==c?(N=(0,Q.jsxs)(`h3`,{id:`understanding-updates-title`,className:`text-sm font-semibold text-fg`,children:[d.pending,c]}),t[49]=d.pending,t[50]=c,t[51]=N):N=t[51],t[52]===d.pendingHint?P=t[53]:(P=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.pendingHint}),t[52]=d.pendingHint,t[53]=P),I=C.length?(0,Q.jsxs)(`div`,{className:`mt-3`,children:[Je(e,a).map(e=>{let{label:t,items:n}=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`border-b border-edge-subtle px-4 pb-2 pt-3 text-xs font-medium text-fg-muted`,children:t}),(0,Q.jsx)(`div`,{children:n.map(e=>(0,Q.jsx)($e,{item:e,language:a,busy:o,editing:h===e.id,draft:_,onDraftChange:v,onEdit:()=>{g(e.id),v(e.statement)},onCancel:()=>g(null),onCorrect:()=>void D(e,`edited`,_.trim()),onDelete:()=>void D(e,`deleted`)},e.id))})]},t)}),C.length>5?(0,Q.jsxs)(`button`,{type:`button`,className:`mx-auto flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>p(ft),children:[f?d.showLess:d.showAll.replace(`{{count}}`,String(C.length)),(0,Q.jsx)(B,{className:ee(`size-3.5 transition-transform`,f&&`rotate-180`)})]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-3 rounded-xl border border-edge bg-surface-base/55 p-4`,children:[(0,Q.jsx)(m,{className:`mt-0.5 size-5 shrink-0 text-success`}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:d.nothingPending})]}),t[10]=i,t[11]=o,t[12]=_,t[13]=h,t[14]=a,t[15]=C,t[16]=D,t[17]=f,t[18]=d.eyebrow,t[19]=d.nothingPending,t[20]=d.pending,t[21]=d.pendingHint,t[22]=d.showAll,t[23]=d.showLess,t[24]=d.subtitle,t[25]=d.title,t[26]=d.updating,t[27]=O,t[28]=te,t[29]=k,t[30]=A,t[31]=j,t[32]=M,t[33]=N,t[34]=P,t[35]=I}else O=t[27],te=t[28],k=t[29],A=t[30],j=t[31],M=t[32],N=t[33],P=t[34],I=t[35];let L;t[54]!==j||t[55]!==M||t[56]!==N||t[57]!==P||t[58]!==I?(L=(0,Q.jsxs)(`section`,{className:j,"aria-labelledby":M,children:[N,P,I]}),t[54]=j,t[55]=M,t[56]=N,t[57]=P,t[58]=I,t[59]=L):L=t[59];let R;t[60]!==T.length||t[61]!==d.channels?(R=(0,Q.jsxs)(`summary`,{className:`w-fit cursor-pointer rounded-md py-2 text-sm font-medium text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[d.channels,` · `,T.length]}),t[60]=T.length,t[61]=d.channels,t[62]=R):R=t[62];let z;t[63]===d.channelHint?z=t[64]:(z=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.channelHint}),t[63]=d.channelHint,t[64]=z);let V;t[65]!==T||t[66]!==d.activeCount||t[67]!==d.noChannels||t[68]!==d.noUnderstanding||t[69]!==d.pendingCount?(V=T.length?(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:T.map(e=>{let t=e.category?$[e.category]??it[e.kind]:it[e.kind],n=e.assertions.filter(dt).length,r=e.assertions.filter(ut).length;return(0,Q.jsxs)(`article`,{className:`rounded-xl border border-edge bg-surface-base/55 px-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),e.grantId?(0,Q.jsx)(We,{sourceId:e.grantId,lastCollectedAt:e.lastObservedAt}):null,e.assertions.length?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?d.activeCount.replace(`{{count}}`,String(n)):``,r?d.pendingCount.replace(`{{count}}`,String(r)):``].filter(Boolean).join(` · `)}):(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:d.noUnderstanding})]}),e.grantId?(0,Q.jsx)(Be,{sourceId:e.grantId}):null]}),e.assertions.length?(0,Q.jsx)(`ul`,{className:`ml-12 mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,children:e.assertions.slice(0,5).map(lt)}):null]},e.key)})}):(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl border border-edge bg-surface-base/55 p-4 text-sm text-fg-muted`,children:d.noChannels}),t[65]=T,t[66]=d.activeCount,t[67]=d.noChannels,t[68]=d.noUnderstanding,t[69]=d.pendingCount,t[70]=V):V=t[70];let H;t[71]!==R||t[72]!==z||t[73]!==V?(H=(0,Q.jsxs)(`details`,{className:`mt-6 border-t border-edge pt-4`,children:[R,z,V]}),t[71]=R,t[72]=z,t[73]=V,t[74]=H):H=t[74];let U;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(c,{className:`size-4`}),t[75]=U):U=t[75];let W;t[76]!==o||t[77]!==u||t[78]!==d.done?(W=(0,Q.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,Q.jsxs)(F,{variant:`primary`,disabled:o,onClick:u,children:[U,d.done]})}),t[76]=o,t[77]=u,t[78]=d.done,t[79]=W):W=t[79];let G;t[80]===s?G=t[81]:(G=s?(0,Q.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:s}):null,t[80]=s,t[81]=G);let K;return t[82]!==O||t[83]!==te||t[84]!==k||t[85]!==A||t[86]!==L||t[87]!==H||t[88]!==W||t[89]!==G?(K=(0,Q.jsxs)(`section`,{className:O,"aria-live":te,children:[k,A,L,H,W,G]}),t[82]=O,t[83]=te,t[84]=k,t[85]=A,t[86]=L,t[87]=H,t[88]=W,t[89]=G,t[90]=K):K=t[90],K}function lt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent/60`}),(0,Q.jsx)(`span`,{children:e.statement})]},e.id)}function ut(e){return!e.usable}function dt(e){return e.usable}function ft(e){return!e}function pt(e,t){return t.assertions.length-e.assertions.length||(t.lastObservedAt??0)-(e.lastObservedAt??0)}function mt(e,t){return t.recordedAt-e.recordedAt}function ht(e){return e.scope.type===`global`&&e.status!==`archived`&&e.status!==`rejected`}function gt(){let{pathname:e,search:t}=o(),n=E(e=>e.language),r=z(),[i,a]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),l=e===`/user-model`,{data:u,mutate:d}=P(l?`/api/user-model`:null,je),f=q(e=>e.error),p=q(e=>e.sources.some(e=>e.status===`running`||e.status===`queued`)),m=n===`zh`;if((0,X.useEffect)(()=>{l&&new URLSearchParams(t).get(`workDiscovery`)===`review`&&z.getState().setDrawerOpen(!0)},[l,t]),(0,X.useEffect)(()=>{l&&r.status!==`running`&&d()},[d,l,r.directoryRun?.id,r.status]),!l)return null;let h=r.status===`running`||p,g=async(e,t,n)=>{a(!0),c(null);try{return t===`edited`&&n?await me(e.id,n):t===`deleted`&&await Ae(e.id),await d(),!0}catch(e){return c(e instanceof Error?e.message:String(e)),!1}finally{a(!1)}},_=e=>{if(!e&&u&&r.status!==`running`){r.finish();return}r.setDrawerOpen(e)};return(0,Q.jsxs)(N,{open:r.drawerOpen,onOpenChange:_,children:[(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(F,{type:`button`,variant:`ghost`,className:ee(`relative size-8 rounded-xl p-0`,I),title:m?`查看 xopc 对你的理解`:`Review what xopc understands`,"aria-label":m?`查看 xopc 对你的理解`:`Review what xopc understands`,children:h?(0,Q.jsx)(b,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(w,{className:`size-4 text-accent-fg`})})}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(D,{className:`fixed inset-0 z-[60] bg-scrim backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:backdrop-blur-none`}),(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] flex items-center justify-center p-3 sm:p-6`,children:(0,Q.jsxs)(j,{className:`xopc-understanding-center pointer-events-auto flex h-[min(42rem,calc(100dvh-1.5rem))] w-[min(44rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float outline-none sm:h-[min(42rem,calc(100dvh-3rem))] sm:w-[min(44rem,calc(100vw-3rem))]`,children:[(0,Q.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-edge-subtle px-5 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(M,{className:`text-sm font-semibold text-fg`,children:h?m?`正在更新用户理解`:`Updating user understanding`:m?`用户理解`:`User understanding`}),(0,Q.jsx)(te,{className:`mt-0.5 text-xs text-fg-muted`,children:h?m?`关闭窗口也会在后台继续`:`You can close this window; work continues in the background`:m?`自动更新,可随时修改或删除`:`Updated automatically. Edit or delete anytime`})]}),(0,Q.jsx)(Be,{disabled:!u?.sources?.length}),(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(F,{variant:`ghost`,className:`size-8 rounded-xl p-0`,"aria-label":m?`关闭`:`Close`,children:(0,Q.jsx)(T,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-7 sm:px-9 sm:py-9`,children:u?(0,Q.jsx)(ct,{assertions:u.assertions,configuredSources:u.sources??[],activityRunning:h,language:n,busy:i,error:s??f??null,onReviewAssertion:g,onCompleted:()=>{_(!1)}}):(0,Q.jsxs)(`section`,{className:`space-y-4`,"aria-label":m?`正在加载用户理解`:`Loading user understanding`,children:[(0,Q.jsx)(L,{className:`h-8 w-2/3`}),(0,Q.jsx)(L,{className:`h-32 w-full`}),(0,Q.jsx)(L,{className:`h-32 w-full`})]})})]})})]})]})}function _t(e){let t=e.get(`tab`);return t===`understanding`||t===`privacy`?t:`overview`}var vt={en:{pageTitle:`Me`,overview:`Overview`,understanding:`What xopc knows`,privacy:`Data & privacy`,knowledge:`Work memory`,editProfile:`Edit basics`,callName:`What should xopc call you?`,callNamePlaceholder:`For example: Alex, Joyce, or Dr. Chen`,role:`Your role`,rolePlaceholder:`For example: founder, designer, or engineer`,pronouns:`Pronouns (optional)`,pronounsPlaceholder:`For example: she/her, he/him, they/them`,timezone:`Timezone`,timezoneSearch:`Search timezones…`,timezoneNoMatch:`No matching timezone`,locale:`Language / locale`,useDeviceTimezone:`Use this device`,notProvided:`Not provided`,editProfileHint:`These are facts you provide directly. They remain separate from xopc’s observations and inferences.`,saveProfile:`Save`,saving:`Saving…`,explicit:`You told me`,explicitHint:`Facts and preferences you stated directly`,learned:`Learned together`,learnedHint:`Patterns formed from our work`,allUnderstanding:`All understanding`,understandingFilterHint:`Filter this view by how each item was formed.`,importantNow:`What matters now`,prioritySourceGoal:`From a goal you confirmed`,prioritySourceWork:`From your current work`,editPriority:`Edit focus`,addPriority:`Set current focus`,priorityTitle:`Current focus`,priorityTitlePlaceholder:`What matters most right now?`,priorityOutcome:`What a good outcome looks like`,priorityOutcomePlaceholder:`Describe the result you want…`,priorityUntil:`Focus through`,savePriority:`Save focus`,endPriority:`End focus`,endingPriority:`Ending…`,priorityHint:`This is used to keep xopc aligned with what deserves attention now.`,otherGoals:`Other active outcomes`,howWeWork:`How we work together`,noRules:`No collaboration preferences yet.`,seeAll:`See all`,workMemory:`What I remember from the work`,items:`items`,refresh:`Refresh`,refreshing:`Refreshing…`,refreshComplete:`Refreshed`,refreshFailed:`Refresh failed`,aboutYouTitle:`A view you can correct`,aboutYouHint:`xopc quietly maintains this working context from collaboration. You can edit or retire any item.`,identity:`Who you are`,preferences:`Preferences and working rhythm`,relationships:`People and relationships`,currentState:`Current context`,insights:`My current read`,emptyGroup:`No understanding has formed here yet.`,correct:`Correct`,save:`Save correction`,cancel:`Cancel`,correctionPlaceholder:`Write the accurate version…`,searchPlaceholder:`Search work memory…`,allMemory:`All work memory`,memoryFilterHint:`Filter by memory type`,memoryLibraryHint:`Only distilled facts, decisions, lessons, commitments, and open questions appear here. Source records stay with their connector.`,noKnowledge:`No work memory has formed yet.`,noKnowledgeMatch:`No work memory matches this search.`,showMore:`Show more`,expand:`Show details`,collapse:`Hide details`,disable:`Disable`,disabled:`Not in use`,enable:`Enable`,loadFailed:`Could not load your understanding.`,tryAgain:`Try again`,actionFailed:`The change could not be saved. Please try again.`},zh:{pageTitle:`我的`,overview:`总览`,understanding:`对我的了解`,privacy:`数据与隐私`,knowledge:`工作记忆`,editProfile:`编辑基本信息`,callName:`希望 xopc 如何称呼你?`,callNamePlaceholder:`例如:Mic、Joyce、张老师`,role:`你的角色`,rolePlaceholder:`例如:创业者、产品设计师、工程师`,pronouns:`代词(可选)`,pronounsPlaceholder:`例如:she/her、he/him、they/them`,timezone:`时区`,timezoneSearch:`搜索时区…`,timezoneNoMatch:`没有匹配的时区`,locale:`语言 / 地区`,useDeviceTimezone:`使用本机时区`,notProvided:`未填写`,editProfileHint:`这些是由你直接提供的事实,与 xopc 的观察和推断分开维护。`,saveProfile:`保存`,saving:`正在保存…`,explicit:`你告诉我的`,explicitHint:`你明确表达的事实与偏好`,learned:`协作中学到的`,learnedHint:`从实际协作中形成的认识`,allUnderstanding:`全部理解`,understandingFilterHint:`按内容来源筛选这份理解。`,importantNow:`此刻重要`,prioritySourceGoal:`来自你确认的当前目标`,prioritySourceWork:`来自当前工作上下文`,editPriority:`编辑`,addPriority:`设置当前关注`,priorityTitle:`当前关注`,priorityTitlePlaceholder:`现在最重要的是什么?`,priorityOutcome:`期待结果`,priorityOutcomePlaceholder:`描述你希望达成的结果…`,priorityUntil:`关注至`,savePriority:`保存关注`,endPriority:`结束关注`,endingPriority:`正在结束…`,priorityHint:`这项内容会帮助 xopc 在协作中优先关注当前最重要的事情。`,otherGoals:`其他进行中的目标`,howWeWork:`我们怎样协作`,noRules:`还没有形成协作偏好。`,seeAll:`查看全部`,workMemory:`我在工作中记住的`,items:`条`,refresh:`刷新`,refreshing:`正在刷新…`,refreshComplete:`已刷新`,refreshFailed:`刷新失败`,aboutYouTitle:`一份可以共同修正的理解`,aboutYouHint:`xopc 会在协作中安静地维护这份工作认知。你仍可随时修改或停止使用任何一条。`,identity:`关于你是谁`,preferences:`偏好与工作节奏`,relationships:`重要的人与关系`,currentState:`当前状态`,insights:`我形成的判断`,emptyGroup:`这里还没有形成理解。`,correct:`修正`,save:`保存修正`,cancel:`取消`,correctionPlaceholder:`写下更准确的说法…`,searchPlaceholder:`搜索工作记忆…`,allMemory:`全部工作记忆`,memoryFilterHint:`按记忆类型筛选`,memoryLibraryHint:`这里只显示提炼后的事实、决定、经验、承诺和待解问题;邮件、日历与文档原文保留在对应来源中。`,noKnowledge:`还没有形成工作记忆。`,noKnowledgeMatch:`没有符合搜索条件的工作记忆。`,showMore:`显示更多`,expand:`查看详情`,collapse:`收起详情`,disable:`停用`,disabled:`已停用`,enable:`启用`,loadFailed:`无法载入对你的理解。`,tryAgain:`重试`,actionFailed:`修改没有保存,请重试。`}},yt=new Set([`identity.call_name`,`identity.role`,`identity.pronouns`,`preference.timezone`,`preference.locale`]),bt=[`work_thread`,`project_fact`,`workspace_fact`,`decision`,`task_lesson`,`commitment`,`open_question`,`episode`,`note`],xt=`UTC.Africa/Cairo.Africa/Johannesburg.America/Chicago.America/Denver.America/Los_Angeles.America/Mexico_City.America/New_York.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Kolkata.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Berlin.Europe/London.Europe/Madrid.Europe/Paris.Europe/Rome.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function St(){try{let e=Intl.supportedValuesOf(`timeZone`);return[...new Set([`UTC`,...e])]}catch{return[...xt]}}var Ct=St();function wt(e){return e.map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.includes(`/`)?e.split(`/`)[0]:`UTC`}))}function Tt(e,t,n=!1){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,...n?{timeStyle:`short`}:{}}).format(e):null}function Et(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Dt(e){return{callName:Et(e.profile.callName)??``,role:Et(e.profile.role)??``,pronouns:Et(e.profile.pronouns)??``,timezone:Et(e.profile.timezone)??``,locale:Et(e.profile.locale)??``}}function Ot(e,t){return{"zh-CN":{en:`Simplified Chinese`,zh:`简体中文`},"zh-TW":{en:`Traditional Chinese`,zh:`繁体中文`},"en-US":{en:`English (US)`,zh:`英语(美国)`},"en-GB":{en:`English (UK)`,zh:`英语(英国)`},"ja-JP":{en:`Japanese`,zh:`日语`}}[e]?.[t]??e}function kt(e,t){let n=Tt(e,t);return t===`zh`?`当前安排至 ${n}`:`Current plan through ${n}`}function At(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function jt(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function Mt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function Nt(e,t){return(t===`zh`?{work_thread:`工作主线`,project_fact:`项目事实`,workspace_fact:`工作区事实`,decision:`已经决定`,task_lesson:`工作经验`,commitment:`承诺与约定`,open_question:`待解问题`,episode:`重要经历`,note:`其他记录`}:{work_thread:`Work threads`,project_fact:`Project facts`,workspace_fact:`Workspace facts`,decision:`Decisions`,task_lesson:`Lessons`,commitment:`Commitments`,open_question:`Open questions`,episode:`Episodes`,note:`Notes`})[e]}function Pt(e,t,n){if(e)return e.targetType===`goal`?t.find(t=>t.id===e.targetId)?.title:/^[0-9a-f]{8}-[0-9a-f-]{20,}$/i.test(e.targetId)?(n===`zh`?{project:`当前项目`,task:`当前任务`,assertion:`一项待处理的理解`,topic:`当前主题`}:{project:`Current project`,task:`Current task`,assertion:`An understanding to address`,topic:`Current topic`})[e.targetType]:e.targetId}function Ft(e){let t=(0,Z.c)(16),{title:n,hint:r,action:i,children:a,className:o}=e,s=o===void 0?``:o,c;t[0]===n?c=t[1]:(c=(0,Q.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=r?(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:r}):null,t[2]=r,t[3]=l);let u;t[4]!==c||t[5]!==l?(u=(0,Q.jsxs)(`div`,{children:[c,l]}),t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==u?(d=(0,Q.jsxs)(`header`,{className:`flex items-end justify-between gap-4 px-1 pb-3`,children:[u,i]}),t[7]=i,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:a}),t[10]=a,t[11]=f);let p;return t[12]!==s||t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`section`,{className:s,children:[d,f]}),t[12]=s,t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function It(e){let t=(0,Z.c)(7),{icon:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`p`,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-5 text-sm text-fg-muted`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Lt({open:e,profile:t,language:n,saving:r,onOpenChange:i,onSave:a}){let o=vt[n],[s,c]=(0,X.useState)(t),[l,p]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&(c(t),p(``))},[e,t]);let m=e=>{e.preventDefault(),a({callName:s.callName.trim(),role:s.role.trim(),pronouns:s.pronouns.trim(),timezone:s.timezone.trim(),locale:s.locale.trim()})},h=(e,t,n)=>(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Q.jsx)(`input`,{value:s[e],onChange:t=>c(n=>({...n,[e]:t.target.value})),placeholder:n,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),g=[`zh-CN`,`zh-TW`,`en-US`,`en-GB`,`ja-JP`];s.locale&&!g.includes(s.locale)&&g.push(s.locale);let _=J(),v=(0,X.useMemo)(()=>[...new Set([...Ct,_,s.timezone].filter(Boolean))].sort(),[_,s.timezone]),y=l.trim().toLocaleLowerCase(),x=(0,X.useMemo)(()=>wt(v.filter(e=>!y||e.toLocaleLowerCase().includes(y)||e.replaceAll(`_`,` `).toLocaleLowerCase().includes(y))),[v,y]);return(0,Q.jsx)(N,{open:e,onOpenChange:i,children:(0,Q.jsxs)(A,{children:[(0,Q.jsx)(D,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsx)(j,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(40rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:m,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(M,{className:`font-semibold text-fg`,children:o.editProfile}),(0,Q.jsx)(te,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.editProfileHint})]}),(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(F,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o.cancel,children:(0,Q.jsx)(T,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[h(`callName`,o.callName,o.callNamePlaceholder),h(`role`,o.role,o.rolePlaceholder),h(`pronouns`,o.pronouns,o.pronounsPlaceholder),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.locale}),(0,Q.jsxs)(u,{value:s.locale,onChange:e=>c(t=>({...t,locale:e.target.value})),children:[(0,Q.jsx)(d,{value:``,children:o.notProvided}),g.map(e=>(0,Q.jsx)(d,{value:e,children:Ot(e,n)},e))]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.timezone}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(f,{value:s.timezone,options:x,placeholder:J(),emptyLabel:o.notProvided,ariaLabel:o.timezone,selectedLabel:s.timezone||o.notProvided,searchPlaceholder:o.timezoneSearch,searchValue:l,onSearchChange:p,statusMessage:x.length?void 0:o.timezoneNoMatch,triggerClassName:`min-w-0 flex-1 rounded-xl bg-surface-base`,onChange:e=>{c(t=>({...t,timezone:e})),p(``)}}),(0,Q.jsx)(F,{className:`shrink-0 whitespace-nowrap`,onClick:()=>c(e=>({...e,timezone:_})),children:o.useDeviceTimezone})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(F,{disabled:r,children:o.cancel})}),(0,Q.jsxs)(F,{type:`submit`,variant:`primary`,disabled:r,children:[r?(0,Q.jsx)(b,{className:`size-4 animate-spin`}):null,r?o.saving:o.saveProfile]})]})]})})]})})}function Rt(e){let t=(0,Z.c)(94),{open:n,priority:r,title:i,outcome:a,language:o,saving:s,onOpenChange:c,onSave:l,onEnd:u}=e,d=vt[o],[f,p]=(0,X.useState)(i),[m,h]=(0,X.useState)(a??``),g=r?.validTo??Date.now()+6048e5,_;t[0]===g?_=t[1]:(_=At(g),t[0]=g,t[1]=_);let v=_,[y,x]=(0,X.useState)(v),S,C;t[2]!==v||t[3]!==n||t[4]!==a||t[5]!==i?(S=()=>{n&&(p(i),h(a??``),x(v))},C=[v,n,a,i],t[2]=v,t[3]=n,t[4]=a,t[5]=i,t[6]=S,t[7]=C):(S=t[6],C=t[7]),(0,X.useEffect)(S,C);let w;t[8]!==m||t[9]!==f||t[10]!==y||t[11]!==l||t[12]!==r?.targetType?(w=e=>{e.preventDefault(),l({title:f.trim(),...r?.targetType===`goal`?{desiredOutcome:m.trim()}:{},validTo:jt(y)})},t[8]=m,t[9]=f,t[10]=y,t[11]=l,t[12]=r?.targetType,t[13]=w):w=t[13];let ee=w,E;t[14]!==m||t[15]!==f||t[16]!==y||t[17]!==r?.targetType?(E=f.trim()&&y&&(r?.targetType!==`goal`||m.trim()),t[14]=m,t[15]=f,t[16]=y,t[17]=r?.targetType,t[18]=E):E=t[18];let O=!!E,P;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(D,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[19]=P):P=t[19];let I=r?d.editPriority:d.addPriority,L;t[20]===I?L=t[21]:(L=(0,Q.jsx)(M,{className:`font-semibold text-fg`,children:I}),t[20]=I,t[21]=L);let R;t[22]===d.priorityHint?R=t[23]:(R=(0,Q.jsx)(te,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.priorityHint}),t[22]=d.priorityHint,t[23]=R);let z;t[24]!==R||t[25]!==L?(z=(0,Q.jsxs)(`div`,{children:[L,R]}),t[24]=R,t[25]=L,t[26]=z):z=t[26];let B;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(T,{className:`size-4`}),t[27]=B):B=t[27];let V;t[28]===d.cancel?V=t[29]:(V=(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(F,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":d.cancel,children:B})}),t[28]=d.cancel,t[29]=V);let H;t[30]!==z||t[31]!==V?(H=(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[z,V]}),t[30]=z,t[31]=V,t[32]=H):H=t[32];let U;t[33]===d.priorityTitle?U=t[34]:(U=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:d.priorityTitle}),t[33]=d.priorityTitle,t[34]=U);let W;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>p(e.target.value),t[35]=W):W=t[35];let G;t[36]!==f||t[37]!==d.priorityTitlePlaceholder?(G=(0,Q.jsx)(`input`,{autoFocus:!0,value:f,onChange:W,placeholder:d.priorityTitlePlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[36]=f,t[37]=d.priorityTitlePlaceholder,t[38]=G):G=t[38];let K;t[39]!==U||t[40]!==G?(K=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[U,G]}),t[39]=U,t[40]=G,t[41]=K):K=t[41];let ne;t[42]!==m||t[43]!==r?.targetType||t[44]!==d.priorityOutcome||t[45]!==d.priorityOutcomePlaceholder?(ne=r?.targetType===`goal`?(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:d.priorityOutcome}),(0,Q.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),placeholder:d.priorityOutcomePlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}):null,t[42]=m,t[43]=r?.targetType,t[44]=d.priorityOutcome,t[45]=d.priorityOutcomePlaceholder,t[46]=ne):ne=t[46];let re;t[47]===d.priorityUntil?re=t[48]:(re=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:d.priorityUntil}),t[47]=d.priorityUntil,t[48]=re);let ie;t[49]===r?.validFrom?ie=t[50]:(ie=r?.validFrom??Date.now(),t[49]=r?.validFrom,t[50]=ie);let ae;t[51]===ie?ae=t[52]:(ae=At(ie),t[51]=ie,t[52]=ae);let oe;t[53]!==y||t[54]!==d.priorityUntil||t[55]!==ae?(oe=(0,Q.jsx)(ze,{min:ae,value:y,onChange:x,ariaLabel:d.priorityUntil,className:`rounded-xl border border-edge bg-surface-base hover:border-edge-strong hover:bg-surface-base`}),t[53]=y,t[54]=d.priorityUntil,t[55]=ae,t[56]=oe):oe=t[56];let se;t[57]!==re||t[58]!==oe?(se=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[re,oe]}),t[57]=re,t[58]=oe,t[59]=se):se=t[59];let q;t[60]!==K||t[61]!==ne||t[62]!==se?(q=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5 sm:p-6`,children:[K,ne,se]}),t[60]=K,t[61]=ne,t[62]=se,t[63]=q):q=t[63];let ce;t[64]!==u||t[65]!==r||t[66]!==s||t[67]!==d.endPriority||t[68]!==d.endingPriority?(ce=r&&u?(0,Q.jsxs)(F,{variant:`ghost`,className:`text-danger hover:text-danger`,disabled:s,onClick:u,children:[s?(0,Q.jsx)(b,{className:`size-4 animate-spin`}):null,s?d.endingPriority:d.endPriority]}):(0,Q.jsx)(`span`,{}),t[64]=u,t[65]=r,t[66]=s,t[67]=d.endPriority,t[68]=d.endingPriority,t[69]=ce):ce=t[69];let le;t[70]!==s||t[71]!==d.cancel?(le=(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(F,{disabled:s,children:d.cancel})}),t[70]=s,t[71]=d.cancel,t[72]=le):le=t[72];let J=!O||s,Y;t[73]===s?Y=t[74]:(Y=s?(0,Q.jsx)(b,{className:`size-4 animate-spin`}):null,t[73]=s,t[74]=Y);let ue;t[75]!==d.savePriority||t[76]!==J||t[77]!==Y?(ue=(0,Q.jsxs)(F,{type:`submit`,variant:`primary`,disabled:J,children:[Y,d.savePriority]}),t[75]=d.savePriority,t[76]=J,t[77]=Y,t[78]=ue):ue=t[78];let de;t[79]!==le||t[80]!==ue?(de=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[le,ue]}),t[79]=le,t[80]=ue,t[81]=de):de=t[81];let fe;t[82]!==ce||t[83]!==de?(fe=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[ce,de]}),t[82]=ce,t[83]=de,t[84]=fe):fe=t[84];let pe;t[85]!==ee||t[86]!==H||t[87]!==q||t[88]!==fe?(pe=(0,Q.jsxs)(A,{children:[P,(0,Q.jsx)(j,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:ee,children:[H,q,fe]})})]}),t[85]=ee,t[86]=H,t[87]=q,t[88]=fe,t[89]=pe):pe=t[89];let me;return t[90]!==c||t[91]!==n||t[92]!==pe?(me=(0,Q.jsx)(N,{open:n,onOpenChange:c,children:pe}),t[90]=c,t[91]=n,t[92]=pe,t[93]=me):me=t[93],me}function zt(e){let t=(0,Z.c)(16),{rule:n,language:r,busy:i,onToggle:a}=e,o=vt[r],s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(G,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l;t[3]!==n.status||t[4]!==o.disabled?(l=n.status===`disabled`?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.disabled}):null,t[3]=n.status,t[4]=o.disabled,t[5]=l):l=t[5];let u=n.status===`active`?o.disable:o.enable,d;t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,Q.jsx)(F,{variant:`ghost`,className:`h-8`,disabled:i,onClick:a,children:u}),t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==l||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,c,f]}),t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function Bt(e){let t=(0,Z.c)(15),{suggestion:n,language:r,busy:i,onConfirm:a}=e,o=r===`zh`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l=o?`根据你已确认的模式生成;确认前不会生效`:`Suggested from a pattern you confirmed; inactive until you approve`,u;t[3]===l?u=t[4]:(u=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:l}),t[3]=l,t[4]=u);let d;t[5]!==c||t[6]!==u?(d=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c,u]}),t[5]=c,t[6]=u,t[7]=d):d=t[7];let f=i?o?`启用中…`:`Enabling…`:o?`确认启用`:`Approve`,p;t[8]!==i||t[9]!==a||t[10]!==f?(p=(0,Q.jsx)(F,{variant:`secondary`,className:`h-8 shrink-0`,disabled:i,onClick:a,children:f}),t[8]=i,t[9]=a,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14],m}function Vt(e){let t=(0,Z.c)(22),{item:n,language:r,busy:i,expanded:a,onToggle:o,editing:s,draft:c,onDraftChange:l,onEdit:u,onCancel:d,onReview:f,onDelete:p}=e,m=vt[r],h=n.updatedAt??n.createdAt,g;t[0]!==r||t[1]!==h?(g=Tt(h,r),t[0]=r,t[1]=h,t[2]=g):g=t[2];let _=g,v;t[3]===n.content?v=t[4]:(v=n.content.length>96||n.content.includes(`
|
|
2
|
-
`),t[3]=n.content,t[4]=v);let y=v,b;return t[5]!==i||t[6]!==y||t[7]!==_||t[8]!==c||t[9]!==s||t[10]!==a||t[11]!==n.content||t[12]!==n.scope||t[13]!==r||t[14]!==d||t[15]!==p||t[16]!==l||t[17]!==u||t[18]!==f||t[19]!==o||t[20]!==m?(b=(0,Q.jsx)(`article`,{className:`group border-t border-edge-subtle px-5 py-4 first:border-t-0 sm:px-6`,children:s?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`textarea`,{"aria-label":m.correctionPlaceholder,disabled:i,value:c,onChange:e=>l(e.target.value),className:`min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,className:`h-8`,onClick:d,children:m.cancel}),(0,Q.jsx)(F,{variant:`primary`,className:`h-8`,disabled:!c.trim()||i,onClick:()=>f(`edit_and_approve`,c.trim()),children:m.save})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(ie,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-base leading-7 text-fg ${a?``:`line-clamp-2`}`,children:n.content}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`span`,{children:Mt(n.scope,r)}),_?(0,Q.jsx)(`span`,{children:_}):null]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[y?(0,Q.jsx)(F,{variant:`ghost`,className:`size-11 p-0`,"aria-expanded":a,"aria-label":a?m.collapse:m.expand,onClick:o,children:(0,Q.jsx)(B,{className:`size-3.5 transition-transform ${a?`rotate-180`:``}`})}):null,(0,Q.jsx)(Ke,{language:r,busy:i,statement:n.content,onEdit:u,onDelete:p})]})]})}),t[5]=i,t[6]=y,t[7]=_,t[8]=c,t[9]=s,t[10]=a,t[11]=n.content,t[12]=n.scope,t[13]=r,t[14]=d,t[15]=p,t[16]=l,t[17]=u,t[18]=f,t[19]=o,t[20]=m,t[21]=b):b=t[21],b}function Ht(){let e=E(e=>e.language),t=vt[e],n=pe(e=>e.setPageHeader),r=pe(e=>e.clearPageHeader),[o,s]=i(),{data:f,error:m,isLoading:_,isValidating:v,mutate:y}=P(`/api/user-model`,je),ee=_t(o),[D,O]=(0,X.useState)(),[te,k]=(0,X.useState)(),[A,j]=(0,X.useState)(``),[M,N]=(0,X.useState)(),[I,z]=(0,X.useState)(``),[B,V]=(0,X.useState)(``),[W,ne]=(0,X.useState)(24),[re,ie]=(0,X.useState)(),[oe,q]=(0,X.useState)(!1),[le,J]=(0,X.useState)(!1),[Y,ge]=(0,X.useState)(`all`),[_e,ye]=(0,X.useState)(`personal`),[Oe,Me]=(0,X.useState)(`all`),[Le,ze]=(0,X.useState)(`idle`),Z=(0,X.useRef)(void 0),Be=e=>{if(e===ee)return;let t=document.getElementById(`app-main-content`);typeof t?.scrollTo==`function`&&t.scrollTo({top:0,behavior:`auto`}),s(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n})},Ve=(0,X.useCallback)(async()=>{if(!(Le===`refreshing`||v)){Z.current&&window.clearTimeout(Z.current),ze(`refreshing`),k(void 0),j(t.refreshing);try{await y(),ze(`success`),j(t.refreshComplete)}catch{ze(`error`),j(``),k(t.refreshFailed)}finally{Z.current=window.setTimeout(()=>ze(`idle`),1600)}}},[v,y,Le,t]);(0,X.useEffect)(()=>()=>{Z.current&&window.clearTimeout(Z.current)},[]);let He=v||Le===`refreshing`,Ue=He?t.refreshing:Le===`success`?t.refreshComplete:Le===`error`?t.refreshFailed:t.refresh;(0,X.useEffect)(()=>(n({startExtra:null,main:(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:t.pageTitle}),end:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(gt,{}),(0,Q.jsx)(F,{variant:`secondary`,className:`size-9 p-0 ${Le===`success`?`text-success`:Le===`error`?`text-danger`:``}`,disabled:He,"aria-label":Ue,title:Ue,onClick:()=>void Ve(),children:He?(0,Q.jsx)(b,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}):Le===`success`?(0,Q.jsx)(c,{className:`size-4`,"aria-hidden":`true`}):Le===`error`?(0,Q.jsx)(p,{className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(K,{className:`size-4`,"aria-hidden":`true`})})]})}),r),[r,He,Le,Ue,Ve,n,t]);let We=async(n,r)=>{O(n),k(void 0),j(``);try{await r(),await y(),j(e===`zh`?`已更新`:`Updated`)}catch{k(t.actionFailed)}finally{O(void 0)}},Ge=e=>{We(e.id,async()=>{await me(e.id,I.trim()),N(void 0),z(``)})},Ke=async e=>{O(`profile`),k(void 0),j(``);try{await we(e),await y(),q(!1)}catch{k(t.actionFailed)}finally{O(void 0)}},qe=async(n,r)=>{O(`priority:${n.id}`),k(void 0),j(``);try{await ke(n.id,r),await y(),J(!1),j(e===`zh`?`当前关注已更新`:`Current focus updated`)}catch{k(t.actionFailed)}finally{O(void 0)}},Je=async n=>{O(`priority:create`),k(void 0),j(``);try{await Ne(n),await y(),J(!1),j(e===`zh`?`当前关注已设置`:`Current focus set`)}catch{k(t.actionFailed)}finally{O(void 0)}},Ye=async n=>{O(`priority:${n.id}`),k(void 0),j(``);try{await ke(n.id,{status:`completed`}),await y(),J(!1),j(e===`zh`?`当前关注已结束`:`Current focus ended`)}catch{k(t.actionFailed)}finally{O(void 0)}};if(_)return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl space-y-5 px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`,children:[(0,Q.jsx)(L,{className:`h-10 w-72 rounded-xl`}),(0,Q.jsx)(L,{className:`h-72 rounded-xl`}),(0,Q.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,Q.jsx)(L,{className:`h-80 rounded-xl`}),(0,Q.jsx)(L,{className:`h-80 rounded-xl`})]})]});if(m||!f)return(0,Q.jsxs)(`div`,{className:`mx-auto flex min-h-72 max-w-xl flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(H,{className:`size-6 text-fg-subtle`}),(0,Q.jsx)(`p`,{className:`text-sm text-danger`,children:t.loadFailed}),(0,Q.jsx)(F,{onClick:()=>void y(),children:t.tryAgain})]});let Xe=f.assertions.filter(e=>e.usable&&!yt.has(e.predicate)).sort((e,t)=>{let n=e.declaredImportance??e.inferredImportance;return(t.declaredImportance??t.inferredImportance)-n||t.recordedAt-e.recordedAt}),Ze=f.assertions.filter(e=>[`candidate`,`needs_review`,`conflicted`].includes(e.status)).sort((e,t)=>t.recordedAt-e.recordedAt),Qe=Dt(f),et=Qe.callName||(e===`zh`?`你`:`You`),tt=Xe.filter(e=>e.authority===`user_explicit`).length,nt=Xe.length-tt,rt=Xe.filter(e=>Y===`explicit`?e.authority===`user_explicit`:Y===`learned`?e.authority!==`user_explicit`:!0),it=f.priorities.filter(e=>e.status===`active`&&e.validTo>Date.now()),$=it.find(e=>e.rank===`primary`)??it[0],at=Pt($,f.goals,e),ot=$?.targetType===`goal`?f.goals.find(e=>e.id===$.targetId):void 0,st=f.goals.filter(e=>e.status===`active`||e.status===`paused`),ct=st.filter(e=>$?.targetType!==`goal`||e.id!==$.targetId),lt=f.rules.filter(e=>e.status!==`archived`),ut=f.ruleSuggestions??[],dt=f.knowledge.filter(e=>e.status!==`archived`&&e.status!==`rejected`),ft=B.trim().toLocaleLowerCase(),pt=dt.filter(e=>Oe===`all`||e.kind===Oe),mt=pt.filter(t=>!ft||t.content.toLocaleLowerCase().includes(ft)||Nt(t.kind,e).toLocaleLowerCase().includes(ft)),ht=[{key:`identity`,title:t.identity,icon:xe,items:rt.filter(e=>e.kind===`identity`)},{key:`preferences`,title:t.preferences,icon:be,items:rt.filter(e=>[`preference`,`value`,`routine`,`capability`].includes(e.kind))},{key:`relationships`,title:t.relationships,icon:G,items:rt.filter(e=>e.kind===`relationship`)},{key:`current`,title:t.currentState,icon:h,items:rt.filter(e=>e.kind===`current_state`)},{key:`insights`,title:t.insights,icon:w,items:rt.filter(e=>e.kind===`derived_insight`)}].filter(e=>e.items.length>0),xt=[{key:`about`,icon:xe,label:e===`zh`?`关于我`:`About me`,hint:e===`zh`?`身份、背景与能力`:`Identity, background, and capabilities`,count:Xe.filter(e=>[`identity`,`capability`].includes(e.kind)).length},{key:`preferences`,icon:be,label:e===`zh`?`偏好与习惯`:`Preferences & habits`,hint:e===`zh`?`沟通方式与日常习惯`:`Communication and routines`,count:Xe.filter(e=>[`preference`,`value`,`routine`].includes(e.kind)).length},{key:`people`,icon:G,label:e===`zh`?`重要的人`:`Important people`,hint:e===`zh`?`与你有关的人和关系`:`People and relationships`,count:Xe.filter(e=>e.kind===`relationship`).length},{key:`goals`,icon:w,label:e===`zh`?`目标与计划`:`Goals & plans`,hint:e===`zh`?`正在推进的长期目标`:`Long-term outcomes in progress`,count:st.length}],St=bt.map(e=>({kind:e,count:dt.filter(t=>t.kind===e).length})).filter(e=>e.count>0),Ct=St.slice(0,4),wt=Ct.length===1?`grid-cols-1`:`sm:grid-cols-2`,Tt=mt.slice(0,W),Et=bt.map(e=>({kind:e,items:Tt.filter(t=>t.kind===e),totalCount:mt.filter(t=>t.kind===e).length})).filter(e=>e.items.length>0),At=[{id:`all`,label:t.allUnderstanding,count:Xe.length},{id:`explicit`,label:t.explicit,count:tt},{id:`learned`,label:t.learned,count:nt}],jt=e=>{ge(e),ye(`personal`),Be(`understanding`)},Mt=e=>{Me(e),V(``),ne(24),ye(`work`),Be(`understanding`)},Ht=t=>(0,Q.jsx)($e,{item:t,language:e,busy:!!D,editing:M===t.id,draft:M===t.id?I:``,onDraftChange:z,onEdit:()=>{N(t.id),z(t.statement)},onCancel:()=>{N(void 0),z(``)},onDelete:()=>void We(t.id,()=>Ae(t.id)),onCorrect:()=>Ge(t),onScopeChange:e=>void We(t.id,()=>Se(t.id,e))},t.id);return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-6 px-4 pb-4 pt-3 sm:space-y-8 sm:px-6 sm:pb-7 lg:px-8 lg:pb-10 lg:pt-4`,children:[(0,Q.jsx)(Re,{items:[{id:`overview`,label:t.overview,icon:w},{id:`understanding`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`记忆`:`Memory`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.understanding})]}),icon:xe,count:Xe.length},{id:`privacy`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`隐私`:`Privacy`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.privacy})]}),icon:se}],activeTab:ee,onChange:Be,ariaLabel:t.pageTitle,tabIdPrefix:`understanding-tab`,panelIdPrefix:`understanding-panel`,className:`w-full max-w-full gap-1 rounded-full bg-surface-panel p-1 shadow-surface sm:w-fit`,buttonClassName:`min-w-0 flex-1 justify-center rounded-full px-2 py-2 sm:flex-none sm:px-3.5`,selectedClassName:`bg-surface-active text-fg`,unselectedClassName:`text-fg-muted hover:bg-surface-hover hover:text-fg`}),(0,Q.jsx)(`p`,{role:`status`,className:`sr-only`,children:A}),te?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-3 rounded-xl border border-danger bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,Q.jsx)(`span`,{children:te}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>k(void 0),"aria-label":t.cancel,children:(0,Q.jsx)(T,{className:`size-4`})})]}):null,ee===`overview`?(0,Q.jsxs)(`div`,{id:`understanding-panel-overview`,role:`tabpanel`,"aria-labelledby":`understanding-tab-overview`,className:`space-y-8 sm:space-y-10`,children:[(0,Q.jsxs)(`section`,{"data-testid":`overview-hero`,className:`grid gap-5 sm:gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,24rem)] lg:gap-12`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 px-1 sm:py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:flex-wrap sm:gap-5`,children:[(0,Q.jsx)(R,{className:`size-16 sm:size-20`,mood:te?`care`:He||D?`work`:`listen`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight text-fg sm:text-3xl`,children:et}),(0,Q.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg-muted`,children:Qe.role||t.notProvided})]}),(0,Q.jsxs)(F,{variant:`ghost`,className:`size-11 shrink-0 px-0 sm:h-9 sm:w-auto sm:px-3`,onClick:()=>q(!0),children:[(0,Q.jsx)(Pe,{className:`size-4`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:t.editProfile})]})]}),(0,Q.jsx)(`dl`,{className:`mt-6 hidden gap-x-8 gap-y-5 sm:grid sm:grid-cols-3`,children:[{icon:ae,label:t.locale,value:Qe.locale?Ot(Qe.locale,e):t.notProvided},{icon:Ce,label:t.timezone,value:Qe.timezone||t.notProvided},{icon:xe,label:t.pronouns,value:Qe.pronouns||t.notProvided}].map(({icon:e,label:t,value:n})=>(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`dt`,{className:`flex items-center gap-1.5 text-xs text-fg-subtle`,children:[(0,Q.jsx)(e,{className:`size-3.5`,"aria-hidden":`true`}),t]}),(0,Q.jsx)(`dd`,{className:`mt-1.5 truncate text-sm font-medium text-fg`,children:n})]},t))})]}),(0,Q.jsxs)(`aside`,{"data-testid":`priority-panel`,className:`flex min-h-0 flex-col rounded-[1.4rem] bg-surface-panel p-5 shadow-surface sm:min-h-64 sm:p-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-fg-subtle`,children:t.importantNow}),$?(0,Q.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Q.jsx)(U,{className:`size-3.5`,"aria-hidden":`true`}),$.targetType===`goal`?t.prioritySourceGoal:t.prioritySourceWork]}):null]}),$&&at?(0,Q.jsxs)(F,{variant:`ghost`,className:`h-8 shrink-0 px-2.5`,onClick:()=>J(!0),children:[(0,Q.jsx)(x,{className:`size-3.5`,"aria-hidden":`true`}),t.editPriority]}):null]}),at?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`mt-3 text-lg font-semibold leading-7 tracking-tight text-fg`,children:at}),ot?.desiredOutcome?(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:ot.desiredOutcome}):null,$?(0,Q.jsxs)(`p`,{className:`mt-auto flex items-center gap-1.5 pt-4 text-xs text-fg-subtle`,children:[(0,Q.jsx)(Ie,{className:`size-3.5`,"aria-hidden":`true`}),kt($.validTo,e)]}):null]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-6 text-center text-sm text-fg-muted`,children:[(0,Q.jsx)(U,{className:`size-5 text-fg-subtle`}),(0,Q.jsxs)(F,{variant:`primary`,onClick:()=>J(!0),children:[(0,Q.jsx)(S,{className:`size-4`,"aria-hidden":`true`}),t.addPriority]})]}),ct.length?(0,Q.jsxs)(`div`,{className:`mt-5 hidden border-t border-edge-subtle pt-4 sm:block`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.otherGoals}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-2`,children:ct.slice(0,3).map(e=>(0,Q.jsx)(`p`,{className:`text-sm text-fg`,children:e.title},e.id))})]}):null]})]}),Ze.length?(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-accent-soft/70 shadow-surface`,"aria-label":e===`zh`?`需要你确认`:`Needs your review`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-panel text-accent-fg`,children:(0,Q.jsx)(w,{className:`size-4`,"aria-hidden":`true`})}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e===`zh`?`需要你确认`:`Needs your review`})})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 text-xs font-medium tabular-nums text-accent-fg`,children:Ze.length})]}),(0,Q.jsxs)(`div`,{className:`border-t border-accent/10 bg-surface-panel px-5 py-4 sm:flex sm:items-center sm:gap-4 sm:px-6`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:Ze[0].statement}),(0,Q.jsxs)(`div`,{className:`mt-3 flex shrink-0 gap-2 sm:mt-0`,children:[(0,Q.jsx)(F,{variant:`ghost`,className:`min-h-11 flex-1 sm:flex-none`,disabled:D===Ze[0].id,onClick:()=>void We(Ze[0].id,()=>Fe(Ze[0].id,`rejected`)),children:e===`zh`?`不是`:`No`}),(0,Q.jsx)(F,{variant:`primary`,className:`min-h-11 flex-1 sm:flex-none`,disabled:D===Ze[0].id,onClick:()=>void We(Ze[0].id,()=>Fe(Ze[0].id,`active`)),children:e===`zh`?`是的`:`That’s right`})]})]})]}):null,(0,Q.jsx)(Ft,{title:e===`zh`?`xopc 对我的了解`:`What xopc knows about me`,action:(0,Q.jsx)(F,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>Be(`understanding`),children:t.seeAll}),children:(0,Q.jsx)(`div`,{className:`grid sm:grid-cols-2`,children:xt.map(({key:e,icon:t,label:n,hint:r,count:i})=>(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-24 w-full items-center gap-4 border-t border-edge-subtle px-5 py-4 text-left first:border-t-0 hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent sm:[&:nth-child(-n+2)]:border-t-0 sm:[&:nth-child(even)]:border-l`,onClick:()=>jt(`all`),"aria-label":`${n}: ${i}`,children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,Q.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-subtle`,children:r})]}),(0,Q.jsx)(`span`,{className:`text-sm tabular-nums text-fg-muted`,children:i}),(0,Q.jsx)(l,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":`true`})]},e))})}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-2`,children:[(0,Q.jsx)(Ft,{title:t.howWeWork,className:`min-w-0`,children:lt.length||ut.length?(0,Q.jsxs)(Q.Fragment,{children:[lt.slice(0,3).map(t=>(0,Q.jsx)(zt,{rule:t,language:e,busy:D===t.id,onToggle:()=>void We(t.id,()=>fe(t.id,t.status===`active`?`disabled`:`active`))},t.id)),ut.slice(0,2).map(t=>(0,Q.jsx)(Bt,{suggestion:t,language:e,busy:D===t.id,onConfirm:()=>void We(t.id,()=>Te(t))},t.id))]}):(0,Q.jsx)(It,{icon:(0,Q.jsx)(G,{className:`size-5`}),children:t.noRules})}),(0,Q.jsx)(Ft,{title:t.workMemory,className:`min-w-0`,action:(0,Q.jsx)(F,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>Mt(`all`),children:t.seeAll}),children:St.length?(0,Q.jsx)(`div`,{"data-testid":`memory-summary-grid`,className:`grid gap-3 bg-surface-base ${wt}`,children:Ct.map(({kind:t,count:n})=>(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-28 cursor-pointer items-start justify-between rounded-2xl bg-surface-panel px-5 py-5 text-left transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Mt(t),"aria-label":`${Nt(t,e)}: ${n}`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-2xl font-semibold tabular-nums text-fg`,children:n}),(0,Q.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:Nt(t,e)})]}),(0,Q.jsx)(l,{className:`mt-1 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted motion-reduce:transform-none`,"aria-hidden":`true`})]},t))}):(0,Q.jsx)(It,{icon:(0,Q.jsx)(Ee,{className:`size-5`}),children:t.noKnowledge})})]})]}):null,ee===`understanding`?(0,Q.jsxs)(`div`,{id:`understanding-panel-understanding`,role:`tabpanel`,"aria-labelledby":`understanding-tab-understanding`,className:`space-y-10`,children:[(0,Q.jsx)(`div`,{className:`flex w-full gap-1 rounded-xl bg-surface-panel p-1 sm:w-fit`,role:`group`,"aria-label":e===`zh`?`记忆分类`:`Memory category`,children:[{id:`personal`,label:e===`zh`?`关于我`:`About me`,icon:xe,count:Xe.length},{id:`work`,label:e===`zh`?`工作记忆`:`Work memory`,icon:U,count:dt.length}].map(({id:e,label:t,icon:n,count:r})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":_e===e,className:`touch-target flex min-h-10 flex-1 items-center justify-center gap-2 rounded-lg px-3 text-sm font-medium transition-colors sm:flex-none ${_e===e?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>ye(e),children:[(0,Q.jsx)(n,{className:`size-4`,"aria-hidden":`true`}),t,(0,Q.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:r})]},e))}),_e===`personal`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(H,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.aboutYouTitle}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:t.aboutYouHint})]})]}),(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":t.understandingFilterHint,children:At.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Y===e.id,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Y===e.id?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>ge(e.id),children:[e.label,(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:e.count})]},e.id))})]}),ht.length?ht.map(({key:e,title:t,icon:n,items:r})=>(0,Q.jsx)(Ft,{title:t,action:(0,Q.jsx)(n,{className:`size-4 text-fg-subtle`,"aria-hidden":`true`}),children:(0,Q.jsx)(`div`,{children:r.map(Ht)})},e)):(0,Q.jsx)(`div`,{className:`rounded-2xl bg-surface-panel`,children:(0,Q.jsx)(It,{icon:(0,Q.jsx)(H,{className:`size-5`}),children:t.emptyGroup})})]}):(0,Q.jsxs)(`div`,{className:`space-y-8`,children:[(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:Oe===`all`?t.allMemory:Nt(Oe,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:[pt.length,` `,t.items,` · `,t.memoryLibraryHint]})]}),(0,Q.jsxs)(`label`,{className:`relative block sm:w-80`,children:[(0,Q.jsx)(C,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:t.searchPlaceholder}),(0,Q.jsx)(`input`,{type:`search`,value:B,onChange:e=>{V(e.target.value),ne(24)},placeholder:t.searchPlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":t.memoryFilterHint,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Oe===`all`,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Oe===`all`?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>Me(`all`),children:[t.allMemory,(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:dt.length})]}),St.map(({kind:t,count:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Oe===t,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Oe===t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>Me(t),children:[Nt(t,e),(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:n})]},t))]})]}),mt.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`space-y-8`,children:Et.map(({kind:t,items:n,totalCount:r})=>(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between px-5 pb-1 pt-4 sm:px-6`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Nt(t,e)}),(0,Q.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:r})]}),(0,Q.jsx)(`div`,{children:n.map(t=>(0,Q.jsx)(Vt,{item:t,language:e,busy:!!D,expanded:re===t.id,onToggle:()=>ie(e=>e===t.id?void 0:t.id),editing:M===`knowledge:${t.id}`,draft:I,onDraftChange:z,onEdit:()=>{N(`knowledge:${t.id}`),z(t.content)},onCancel:()=>{N(void 0),z(``)},onDelete:()=>void We(t.id,()=>ve(t.id)),onReview:(e,n)=>void We(t.id,async()=>{await ue(t,e,n),N(void 0),z(``)})},t.id))})]},t))}),mt.length>W?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(F,{onClick:()=>ne(e=>e+24),children:t.showMore})}):null]}):(0,Q.jsx)(`div`,{className:`rounded-2xl bg-surface-panel`,children:(0,Q.jsx)(It,{icon:(0,Q.jsx)(C,{className:`size-5`}),children:B.trim()?t.noKnowledgeMatch:t.noKnowledge})})]})]}):null,ee===`privacy`?(0,Q.jsxs)(`div`,{id:`understanding-panel-privacy`,role:`tabpanel`,"aria-labelledby":`understanding-tab-privacy`,className:`space-y-8`,children:[(0,Q.jsx)(`div`,{className:`px-1 pt-1`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(se,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:e===`zh`?`你的信息,由你掌控`:`Your information, under your control`}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:e===`zh`?`决定 xopc 可以记住什么、从哪里了解你,以及如何迁移你的数据。`:`Decide what xopc can remember, where it learns from, and how your data moves.`})]})]})}),(0,Q.jsx)(Ft,{title:e===`zh`?`记忆与使用`:`Memory & use`,children:(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle`,children:[[{key:`memory`,icon:H,title:e===`zh`?`长期记忆`:`Long-term memory`,detail:e===`zh`?`记住长期有用的信息,减少重复说明。`:`Remember useful information so you do not have to repeat yourself.`,enabled:f.settings.memoryEnabled},{key:`references`,icon:w,title:e===`zh`?`回答中的记忆引用`:`Memory references in answers`,detail:e===`zh`?`当个人信息影响回答时,显示本次参考内容。`:`Show what personal context was referenced when it shapes an answer.`,enabled:f.settings.showMemoryReferences}].map(({key:e,icon:t,title:n,detail:r,enabled:i})=>(0,Q.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":i,disabled:!!D,className:`flex min-h-20 w-full items-center gap-4 px-5 py-4 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent disabled:opacity-60 sm:px-6`,onClick:()=>void We(`setting:${e}`,()=>he(e===`memory`?{memoryEnabled:!i}:{showMemoryReferences:!i})),children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:r})]}),(0,Q.jsx)(`span`,{className:`relative h-6 w-11 shrink-0 rounded-full transition-colors ${i?`bg-accent`:`bg-surface-active`}`,"aria-hidden":`true`,children:(0,Q.jsx)(`span`,{className:`absolute top-0.5 size-5 rounded-full bg-white shadow-sm transition-transform ${i?`translate-x-5`:`translate-x-0.5`}`})})]},e)),(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center gap-4 px-5 py-4 sm:px-6`,children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(ce,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`敏感信息`:`Sensitive information`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`控制健康、财务等信息是否可以保存。`:`Control whether health, financial, and similar information can be saved.`})]}),(0,Q.jsxs)(u,{"aria-label":e===`zh`?`敏感信息策略`:`Sensitive information policy`,value:f.settings.sensitiveWritePolicy,disabled:!!D,onChange:e=>void We(`setting:sensitive`,()=>he({sensitiveWritePolicy:e.target.value})),children:[(0,Q.jsx)(d,{value:`confirm`,children:e===`zh`?`先询问`:`Ask first`}),(0,Q.jsx)(d,{value:`deny`,children:e===`zh`?`不保存`:`Never save`}),(0,Q.jsx)(d,{value:`allow`,children:e===`zh`?`允许`:`Allow`})]})]})]})}),(0,Q.jsx)(Ft,{title:e===`zh`?`数据管理`:`Data management`,children:(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle`,children:[(0,Q.jsxs)(a,{to:`/settings/imports`,className:`flex min-h-20 items-center gap-4 px-5 py-4 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent sm:px-6`,children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(de,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`从其他 AI 导入`:`Import from another AI`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`导入前预览新增、重复和冲突内容。`:`Preview new, duplicate, and conflicting items before import.`})]}),(0,Q.jsx)(l,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`})]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:!!D,className:`flex min-h-20 w-full items-center gap-4 px-5 py-4 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent disabled:opacity-60 sm:px-6`,onClick:()=>void We(`export`,De),children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(g,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`下载我的记忆`:`Download my memory`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`导出为可阅读、可迁移的数据包。`:`Export a readable, portable archive.`})]}),(0,Q.jsx)(l,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`})]})]})}),(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel px-5 py-5 sm:px-6`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e===`zh`?`纠正与忘记`:`Correct and forget`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e===`zh`?`在“记忆”中打开任意一条内容的菜单,即可修改、调整作用范围或彻底删除。`:`Open any item in Memory to edit it, change where it applies, or delete it permanently.`}),(0,Q.jsx)(F,{variant:`ghost`,className:`mt-3`,onClick:()=>{ye(`personal`),Be(`understanding`)},children:e===`zh`?`管理记忆`:`Manage memory`})]})]}):null,(0,Q.jsx)(Lt,{open:oe,profile:Qe,language:e,saving:D===`profile`,onOpenChange:q,onSave:e=>void Ke(e)}),(0,Q.jsx)(Rt,{open:le,priority:$,title:at??``,outcome:ot?.desiredOutcome,language:e,saving:D===($?`priority:${$.id}`:`priority:create`),onOpenChange:J,onSave:e=>$?void qe($,e):void Je(e),onEnd:$?()=>void Ye($):void 0})]})}export{Ht as UserModelPage};
|