clay-server 5.1.1-beta.1 → 5.2.0-beta.10
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/lib/account-auth-policy.js +21 -0
- package/lib/account-auth-socket.js +30 -0
- package/lib/account-auth-throttle.js +44 -0
- package/lib/account-auth-transport.js +48 -0
- package/lib/account-login-page.js +28 -0
- package/lib/account-passkey-challenges.js +31 -0
- package/lib/account-passkey-page.js +89 -0
- package/lib/account-passkey-policy.js +39 -0
- package/lib/account-password-page.js +69 -0
- package/lib/account-passwords.js +36 -0
- package/lib/account-remembered.js +77 -0
- package/lib/account-session-page.js +51 -0
- package/lib/account-session-store.js +82 -0
- package/lib/builtin-mates.js +19 -16
- package/lib/bundled-skills/clay-agent-browser/SKILL.md +6 -2
- package/lib/canonical-clay-record-authority.js +15 -0
- package/lib/canonical-clay-scheduling-authority.js +19 -0
- package/lib/claude-hook-installer.js +1 -239
- package/lib/claude-jsonl-watcher.js +1 -204
- package/lib/clay-control-presentation-binding.js +96 -0
- package/lib/clay-control-presentation.js +128 -0
- package/lib/clay-control-target-projection.js +26 -0
- package/lib/clay-mate-chat-receipts.js +26 -0
- package/lib/clay-mate-chat.js +88 -0
- package/lib/clay-mate-knowledge-input.js +26 -0
- package/lib/clay-mate-knowledge.js +95 -0
- package/lib/clay-mate-lifecycle.js +95 -0
- package/lib/clay-product-control-input.js +33 -0
- package/lib/clay-product-control-tools.js +51 -0
- package/lib/clay-product-control.js +247 -0
- package/lib/clay-project-lifecycle.js +154 -0
- package/lib/clay-project-record-input.js +44 -0
- package/lib/clay-project-records.js +84 -0
- package/lib/clay-scheduling-input.js +21 -0
- package/lib/clay-scheduling-receipts.js +26 -0
- package/lib/clay-scheduling.js +119 -0
- package/lib/clay-screen-controls.js +104 -0
- package/lib/clay-skill-install.js +1 -33
- package/lib/clay-workspace-controls.js +84 -0
- package/lib/clay-workspace-input.js +17 -0
- package/lib/clay-workspace-receipts.js +26 -0
- package/lib/cli-sessions.js +1 -300
- package/lib/codex-defaults.js +1 -28
- package/lib/context-usage.js +3 -2
- package/lib/contextual-screen-snapshot.js +38 -0
- package/lib/daemon-project-access.js +11 -0
- package/lib/daemon-project-lifecycle-callbacks.js +15 -0
- package/lib/daemon-project-lifecycle.js +262 -0
- package/lib/daemon-projects.js +1 -1
- package/lib/daemon.js +80 -276
- package/lib/default-ai-runtime.js +4 -8
- package/lib/dm-digest-cursor.js +120 -0
- package/lib/email-mcp-server.js +1 -1
- package/lib/issues-service.js +29 -15
- package/lib/kiro-defaults.js +1 -22
- package/lib/knowledge-db-import-validation.js +46 -0
- package/lib/knowledge-db-import.js +99 -0
- package/lib/knowledge-db-service.js +24 -33
- package/lib/knowledge-db-storage-nedb-maintenance.js +99 -0
- package/lib/knowledge-db-storage-nedb.js +66 -0
- package/lib/knowledge-db-storage.js +72 -0
- package/lib/knowledge-db-validation.js +0 -0
- package/lib/knowledge-document-index.js +2 -1
- package/lib/knowledge-file-store.js +7 -1
- package/lib/knowledge-product-operations.js +46 -0
- package/lib/mate-avatar-catalog.js +12 -0
- package/lib/mate-avatar-migration.js +41 -0
- package/lib/mate-context-service.js +138 -0
- package/lib/mate-context-tools.js +21 -0
- package/lib/mate-creation-mcp-server.js +2 -0
- package/lib/mate-knowledge-canonical-access.js +10 -0
- package/lib/mate-knowledge-mate-bound.js +53 -0
- package/lib/mate-knowledge-mcp-server.js +55 -8
- package/lib/mate-knowledge-service.js +16 -34
- package/lib/mate-knowledge-text-tools.js +106 -0
- package/lib/mate-lifecycle-service.js +94 -0
- package/lib/mate-message-delivery.js +43 -0
- package/lib/mate-ready-creation.js +9 -1
- package/lib/mate-schedule-input.js +29 -0
- package/lib/mate-schedule-lifecycle.js +151 -0
- package/lib/mate-scheduling.js +103 -0
- package/lib/mates.js +18 -6
- package/lib/mcp-agent-tools.js +117 -0
- package/lib/mcp-connection-store.js +119 -15
- package/lib/mcp-import-credentials.js +31 -0
- package/lib/mcp-local-transport.js +13 -0
- package/lib/mcp-oauth.js +8 -6
- package/lib/mcp-proxy.js +2 -32
- package/lib/mcp-query-bridge.js +30 -0
- package/lib/mcp-remote-connections.js +74 -20
- package/lib/mcp-source-adapters.js +1 -0
- package/lib/mcp-source-context.js +1 -0
- package/lib/mcp-source-discovery.js +1 -0
- package/lib/mcp-source-plugins.js +1 -0
- package/lib/mcp-source-restrictions.js +1 -0
- package/lib/mcp-tool-policy.js +9 -0
- package/lib/migrate-single-user.js +3 -23
- package/lib/notes-checklist.js +50 -0
- package/lib/notes.js +49 -3
- package/lib/os-user-diagnostics.js +2 -4
- package/lib/os-users.js +24 -70
- package/lib/pane-pending-interactions.js +20 -0
- package/lib/pane-session-activation.js +114 -0
- package/lib/pane-session-transport.js +26 -0
- package/lib/project-admin-overview.js +51 -0
- package/lib/project-ask-user.js +8 -4
- package/lib/project-connection.js +14 -10
- package/lib/project-control-git-view.js +12 -0
- package/lib/project-debate.js +1 -0
- package/lib/project-delegated-follow-up.js +2 -1
- package/lib/project-directory-claim.js +65 -0
- package/lib/project-file-operations.js +61 -0
- package/lib/project-filesystem.js +15 -85
- package/lib/project-full-access.js +23 -2
- package/lib/project-http.js +7 -4
- package/lib/project-knowledge.js +32 -18
- package/lib/project-lifecycle-operations.js +98 -0
- package/lib/project-lifecycle-process-witness.js +32 -0
- package/lib/project-lifecycle-runtime.js +50 -0
- package/lib/project-linux-access.js +22 -0
- package/lib/project-logs-canonical-clay.js +27 -0
- package/lib/project-logs-clay-query.js +16 -0
- package/lib/project-logs-schema.js +4 -2
- package/lib/project-logs-service.js +8 -7
- package/lib/project-logs.js +1 -0
- package/lib/project-loop.js +1 -0
- package/lib/project-mate-chat-control.js +55 -0
- package/lib/project-mate-creation-proposal.js +18 -3
- package/lib/project-mate-interaction.js +40 -62
- package/lib/project-mcp.js +54 -16
- package/lib/project-models.js +14 -31
- package/lib/project-notifications.js +76 -17
- package/lib/project-ownership.js +77 -0
- package/lib/project-pair-result-delivery.js +14 -3
- package/lib/project-pair-usage.js +12 -13
- package/lib/project-pending-message-queue.js +4 -1
- package/lib/project-product-control.js +89 -0
- package/lib/project-product-session-queue.js +46 -0
- package/lib/project-push-access.js +28 -0
- package/lib/project-scheduled-message-queue.js +30 -0
- package/lib/project-scheduled-messages.js +67 -68
- package/lib/project-scheduled-task-control.js +83 -0
- package/lib/project-scheduled-tasks.js +13 -2
- package/lib/project-scheduling-access.js +10 -0
- package/lib/project-server-settings.js +1 -0
- package/lib/project-session-actions.js +65 -0
- package/lib/project-session-delete.js +8 -1
- package/lib/project-session-document.js +27 -7
- package/lib/project-session-github.js +63 -19
- package/lib/project-session-history-actions.js +167 -0
- package/lib/project-session-linear.js +14 -6
- package/lib/project-session-notes.js +7 -3
- package/lib/project-session-pair.js +1 -1
- package/lib/project-session-runtime-actions.js +64 -0
- package/lib/project-session-spawn.js +2 -3
- package/lib/project-session-vendor.js +55 -0
- package/lib/project-sessions.js +103 -272
- package/lib/project-shared-browser.js +78 -17
- package/lib/project-studio-presentation.js +58 -0
- package/lib/project-user-knowledge.js +2 -1
- package/lib/project-user-message.js +67 -1
- package/lib/project-vendor-login.js +6 -36
- package/lib/project-workspace-operations.js +126 -0
- package/lib/project-workspace-query.js +19 -2
- package/lib/project.js +178 -45
- package/lib/public/app.js +46 -0
- package/lib/public/appearance-bootstrap.js +16 -0
- package/lib/public/auth/account-login.css +98 -0
- package/lib/public/auth/account-login.js +104 -0
- package/lib/public/css/clay-tool-activity.css +51 -0
- package/lib/public/css/clay-workspace.css +29 -0
- package/lib/public/css/command-palette.css +12 -33
- package/lib/public/css/contextual-clay.css +240 -0
- package/lib/public/css/home-debate-planning.css +2 -0
- package/lib/public/css/home-mate-creation.css +5 -0
- package/lib/public/css/input.css +6 -0
- package/lib/public/css/mate-avatar-gallery.css +12 -0
- package/lib/public/css/mate-conversation.css +10 -5
- package/lib/public/css/messages.css +6 -2
- package/lib/public/css/overlays.css +4 -2
- package/lib/public/css/project-admin-overview.css +13 -0
- package/lib/public/css/session-folders.css +11 -0
- package/lib/public/css/session-github.css +46 -1
- package/lib/public/css/shared-browser.css +35 -1
- package/lib/public/css/sticky-notes.css +87 -1
- package/lib/public/css/user-settings-sessions.css +42 -0
- package/lib/public/index.html +28 -10
- package/lib/public/mate-avatars/B01.png +0 -0
- package/lib/public/mate-avatars/B02.png +0 -0
- package/lib/public/mate-avatars/B03.png +0 -0
- package/lib/public/mate-avatars/B04.png +0 -0
- package/lib/public/mate-avatars/B05.png +0 -0
- package/lib/public/mate-avatars/B06.png +0 -0
- package/lib/public/mate-avatars/B07.png +0 -0
- package/lib/public/mate-avatars/B08.png +0 -0
- package/lib/public/mate-avatars/B09.png +0 -0
- package/lib/public/mate-avatars/B10.png +0 -0
- package/lib/public/mate-avatars/B11.png +0 -0
- package/lib/public/mate-avatars/B12.png +0 -0
- package/lib/public/mate-avatars/B13.png +0 -0
- package/lib/public/mate-avatars/B14.png +0 -0
- package/lib/public/mate-avatars/B15.png +0 -0
- package/lib/public/mate-avatars/B16.png +0 -0
- package/lib/public/mate-avatars/B17.png +0 -0
- package/lib/public/mate-avatars/B18.png +0 -0
- package/lib/public/mate-avatars/B19.png +0 -0
- package/lib/public/mate-avatars/B20.png +0 -0
- package/lib/public/mate-avatars/B21.png +0 -0
- package/lib/public/mate-avatars/B22.png +0 -0
- package/lib/public/mate-avatars/B23.png +0 -0
- package/lib/public/mate-avatars/B24.png +0 -0
- package/lib/public/mate-avatars/B25.png +0 -0
- package/lib/public/mate-avatars/B26.png +0 -0
- package/lib/public/mate-avatars/B27.png +0 -0
- package/lib/public/mate-avatars/B28.png +0 -0
- package/lib/public/mate-avatars/B29.png +0 -0
- package/lib/public/mate-avatars/B30.png +0 -0
- package/lib/public/mate-avatars/B31.png +0 -0
- package/lib/public/mate-avatars/B32.png +0 -0
- package/lib/public/mate-avatars/B33.png +0 -0
- package/lib/public/mate-avatars/B34.png +0 -0
- package/lib/public/mate-avatars/B35.png +0 -0
- package/lib/public/mate-avatars/B36.png +0 -0
- package/lib/public/mate-avatars/B37.png +0 -0
- package/lib/public/mate-avatars/B38.png +0 -0
- package/lib/public/mate-avatars/B39.png +0 -0
- package/lib/public/mate-avatars/B40.png +0 -0
- package/lib/public/mate-avatars/B41.png +0 -0
- package/lib/public/mate-avatars/B42.png +0 -0
- package/lib/public/mate-avatars/B43.png +0 -0
- package/lib/public/mate-avatars/B44.png +0 -0
- package/lib/public/mate-avatars/B45.png +0 -0
- package/lib/public/mate-avatars/B46.png +0 -0
- package/lib/public/mate-avatars/B47.png +0 -0
- package/lib/public/mate-avatars/B48.png +0 -0
- package/lib/public/mate-avatars/C01.png +0 -0
- package/lib/public/mate-avatars/C02.png +0 -0
- package/lib/public/mate-avatars/C03.png +0 -0
- package/lib/public/mate-avatars/C04.png +0 -0
- package/lib/public/mate-avatars/C05.png +0 -0
- package/lib/public/mate-avatars/C06.png +0 -0
- package/lib/public/mate-avatars/C07.png +0 -0
- package/lib/public/mate-avatars/C08.png +0 -0
- package/lib/public/mate-avatars/C09.png +0 -0
- package/lib/public/mate-avatars/C10.png +0 -0
- package/lib/public/mate-avatars/C11.png +0 -0
- package/lib/public/mate-avatars/C12.png +0 -0
- package/lib/public/mate-avatars/C13.png +0 -0
- package/lib/public/mate-avatars/C14.png +0 -0
- package/lib/public/mate-avatars/C15.png +0 -0
- package/lib/public/mate-avatars/C16.png +0 -0
- package/lib/public/mate-avatars/C17.png +0 -0
- package/lib/public/mate-avatars/C18.png +0 -0
- package/lib/public/mate-avatars/C19.png +0 -0
- package/lib/public/mate-avatars/C20.png +0 -0
- package/lib/public/mate-avatars/C21.png +0 -0
- package/lib/public/mate-avatars/C22.png +0 -0
- package/lib/public/mate-avatars/C23.png +0 -0
- package/lib/public/mate-avatars/C24.png +0 -0
- package/lib/public/mate-avatars/C25.png +0 -0
- package/lib/public/mate-avatars/C26.png +0 -0
- package/lib/public/mate-avatars/C27.png +0 -0
- package/lib/public/mate-avatars/C28.png +0 -0
- package/lib/public/mate-avatars/C29.png +0 -0
- package/lib/public/mate-avatars/C30.png +0 -0
- package/lib/public/mate-avatars/C31.png +0 -0
- package/lib/public/mate-avatars/C32.png +0 -0
- package/lib/public/mate-avatars/C33.png +0 -0
- package/lib/public/mate-avatars/C34.png +0 -0
- package/lib/public/mate-avatars/C35.png +0 -0
- package/lib/public/mate-avatars/C36.png +0 -0
- package/lib/public/mate-avatars/C37.png +0 -0
- package/lib/public/mate-avatars/C38.png +0 -0
- package/lib/public/mate-avatars/C39.png +0 -0
- package/lib/public/mate-avatars/C40.png +0 -0
- package/lib/public/mate-avatars/C41.png +0 -0
- package/lib/public/mate-avatars/C42.png +0 -0
- package/lib/public/mate-avatars/C43.png +0 -0
- package/lib/public/mate-avatars/C44.png +0 -0
- package/lib/public/mate-avatars/C45.png +0 -0
- package/lib/public/mate-avatars/C46.png +0 -0
- package/lib/public/mate-avatars/C47.png +0 -0
- package/lib/public/mate-avatars/C48.png +0 -0
- package/lib/public/mate-avatars/catalog.json +482 -0
- package/lib/public/mate-avatars/lead-clay.png +0 -0
- package/lib/public/modules/account-auth-settings.js +71 -0
- package/lib/public/modules/account-transport-settings.js +51 -0
- package/lib/public/modules/admin-settings-projects.js +6 -2
- package/lib/public/modules/app-connection.js +11 -1
- package/lib/public/modules/app-favicon.js +18 -9
- package/lib/public/modules/app-header.js +7 -4
- package/lib/public/modules/app-loop-ui.js +2 -0
- package/lib/public/modules/app-message-router.js +22 -1
- package/lib/public/modules/app-messages.js +119 -17
- package/lib/public/modules/app-misc.js +3 -1
- package/lib/public/modules/app-notifications.js +11 -5
- package/lib/public/modules/app-panels.js +61 -123
- package/lib/public/modules/app-projects.js +13 -0
- package/lib/public/modules/app-rate-limit.js +7 -27
- package/lib/public/modules/app-rendering.js +4 -3
- package/lib/public/modules/avatar.js +15 -41
- package/lib/public/modules/chat-render-runtime.js +20 -0
- package/lib/public/modules/clay-browser-links.js +47 -0
- package/lib/public/modules/clay-control-activity.js +214 -0
- package/lib/public/modules/clay-control-copy.js +36 -0
- package/lib/public/modules/clay-control-detail-targets.js +44 -0
- package/lib/public/modules/clay-control-object-targets.js +52 -0
- package/lib/public/modules/clay-control-target-visibility.js +12 -0
- package/lib/public/modules/clay-control-targets.js +44 -0
- package/lib/public/modules/clay-log-links.js +23 -0
- package/lib/public/modules/clay-navigation-render.js +52 -0
- package/lib/public/modules/clay-owner-navigation.js +33 -0
- package/lib/public/modules/clay-session-links.js +31 -0
- package/lib/public/modules/clay-studio-bridge.js +20 -0
- package/lib/public/modules/clay-studio-document.js +67 -0
- package/lib/public/modules/clay-studio-render.js +146 -0
- package/lib/public/modules/clay-tool-activity.js +140 -0
- package/lib/public/modules/clay-tool-presentation.js +342 -0
- package/lib/public/modules/command-palette.js +162 -40
- package/lib/public/modules/contextual-ask-session.js +26 -0
- package/lib/public/modules/contextual-clay-geometry.js +155 -0
- package/lib/public/modules/contextual-clay-session.js +130 -0
- package/lib/public/modules/contextual-clay-workspace.js +169 -0
- package/lib/public/modules/contextual-clay.js +250 -0
- package/lib/public/modules/contextual-composer.js +91 -0
- package/lib/public/modules/contextual-mate-context.js +117 -0
- package/lib/public/modules/contextual-mate-hint.js +40 -0
- package/lib/public/modules/contextual-mate-identity.js +23 -0
- package/lib/public/modules/contextual-mate-sessions.js +134 -0
- package/lib/public/modules/contextual-search.js +137 -0
- package/lib/public/modules/contextual-session-citations.js +58 -0
- package/lib/public/modules/debate.js +1 -0
- package/lib/public/modules/default-ai.js +11 -3
- package/lib/public/modules/elicitation-form.js +5 -0
- package/lib/public/modules/filebrowser.js +20 -1
- package/lib/public/modules/generation-stop.js +8 -5
- package/lib/public/modules/git-panel.js +3 -1
- package/lib/public/modules/history-replay-batch.js +13 -1
- package/lib/public/modules/home-debate-live.js +2 -0
- package/lib/public/modules/home-debate-planning.js +7 -7
- package/lib/public/modules/home-mate-avatar-editor.js +127 -208
- package/lib/public/modules/home-mate-chat.js +8 -6
- package/lib/public/modules/home-mate-creation.js +73 -1
- package/lib/public/modules/home-mate-settings.js +19 -12
- package/lib/public/modules/icon-strip-tooltip.js +2 -1
- package/lib/public/modules/input.js +88 -10
- package/lib/public/modules/issues-render.js +3 -2
- package/lib/public/modules/knowledge-db-workbench.js +4 -4
- package/lib/public/modules/markdown.js +6 -34
- package/lib/public/modules/mate-avatar-catalog.js +97 -0
- package/lib/public/modules/mate-knowledge-workbench.js +1 -1
- package/lib/public/modules/mate-management.js +40 -7
- package/lib/public/modules/mcp-connection-view.js +31 -13
- package/lib/public/modules/mcp-discovery-view.js +31 -0
- package/lib/public/modules/mcp-ui.js +23 -4
- package/lib/public/modules/mention.js +3 -0
- package/lib/public/modules/message-delivery.js +20 -2
- package/lib/public/modules/model-picker.js +2 -0
- package/lib/public/modules/pane-activation.js +214 -0
- package/lib/public/modules/pane-binding.js +82 -0
- package/lib/public/modules/pane-bridge.js +7 -4
- package/lib/public/modules/pane-browser-bridge.js +22 -0
- package/lib/public/modules/pane-file-bridge.js +4 -0
- package/lib/public/modules/pane-issue-bridge.js +4 -1
- package/lib/public/modules/passkey-browser.js +69 -0
- package/lib/public/modules/passkey-server-settings.js +57 -0
- package/lib/public/modules/pending-message-queue.js +1 -0
- package/lib/public/modules/permission-control.js +5 -4
- package/lib/public/modules/personal-settings-dialog.js +7 -1
- package/lib/public/modules/product-review.js +26 -0
- package/lib/public/modules/profile.js +1 -238
- package/lib/public/modules/project-access-recovery.js +17 -0
- package/lib/public/modules/project-admin-overview.js +21 -0
- package/lib/public/modules/project-chat-identity.js +13 -4
- package/lib/public/modules/project-logs-render.js +6 -2
- package/lib/public/modules/project-mate-navigation.js +144 -22
- package/lib/public/modules/rewind.js +5 -0
- package/lib/public/modules/scheduled-tasks.js +2 -0
- package/lib/public/modules/scheduler.js +2 -0
- package/lib/public/modules/search-clay-chat.js +5 -440
- package/lib/public/modules/server-settings-controls.js +10 -0
- package/lib/public/modules/server-settings.js +7 -2
- package/lib/public/modules/session-actions.js +5 -2
- package/lib/public/modules/session-context-menu.js +5 -0
- package/lib/public/modules/session-create-form.js +10 -10
- package/lib/public/modules/session-folder-layout.js +1 -1
- package/lib/public/modules/session-folder-view-menu.js +9 -0
- package/lib/public/modules/session-github.js +85 -14
- package/lib/public/modules/session-rich-drafts.js +21 -0
- package/lib/public/modules/session-switch-defer.js +67 -0
- package/lib/public/modules/session-work-primary.js +51 -0
- package/lib/public/modules/settings-defaults.js +27 -28
- package/lib/public/modules/shared-browser-settings.js +112 -0
- package/lib/public/modules/shared-browser-tabs.js +13 -3
- package/lib/public/modules/shared-browser.js +29 -6
- package/lib/public/modules/sidebar-mobile.js +4 -3
- package/lib/public/modules/sidebar-projects.js +1 -0
- package/lib/public/modules/sidebar-session-folders-ui.js +1 -1
- package/lib/public/modules/sidebar-sessions.js +1 -0
- package/lib/public/modules/split-group-restore.js +68 -0
- package/lib/public/modules/split-pair-ui.js +1 -0
- package/lib/public/modules/split-pane-reconciler.js +15 -0
- package/lib/public/modules/split-pane-renderer.js +87 -6
- package/lib/public/modules/split-session-boundary.js +1 -1
- package/lib/public/modules/split-view.js +60 -68
- package/lib/public/modules/sticky-note-markdown.js +72 -6
- package/lib/public/modules/sticky-notes-actions.js +30 -0
- package/lib/public/modules/sticky-notes-browser.js +9 -2
- package/lib/public/modules/sticky-notes-card.js +23 -7
- package/lib/public/modules/sticky-notes-checklist.js +116 -0
- package/lib/public/modules/sticky-notes-editor.js +108 -44
- package/lib/public/modules/sticky-notes-shared.js +50 -2
- package/lib/public/modules/sticky-notes-state.js +66 -0
- package/lib/public/modules/sticky-notes.js +34 -51
- package/lib/public/modules/stt-controller.js +4 -1
- package/lib/public/modules/stt-recording.js +1 -1
- package/lib/public/modules/stt.js +7 -2
- package/lib/public/modules/terminal.js +9 -0
- package/lib/public/modules/theme.js +8 -1
- package/lib/public/modules/thinking-lifecycle.js +33 -3
- package/lib/public/modules/thinking-view.js +23 -1
- package/lib/public/modules/tools.js +60 -11
- package/lib/public/modules/tui-grab.js +1 -2
- package/lib/public/modules/user-settings-account.js +14 -1
- package/lib/public/modules/user-settings-appearance.js +10 -3
- package/lib/public/modules/user-settings-editors.js +1 -1
- package/lib/public/modules/user-settings-layout.js +11 -2
- package/lib/public/modules/user-settings-preferences.js +6 -2
- package/lib/public/modules/user-settings-profile.js +12 -2
- package/lib/public/modules/user-settings-sessions.js +120 -0
- package/lib/public/modules/user-settings.js +6 -2
- package/lib/public/modules/vendor-login-browser.js +5 -3
- package/lib/public/modules/vendor-login.js +2 -2
- package/lib/public/modules/vendor-priority.js +15 -1
- package/lib/public/modules/wireframe-workbench.js +5 -2
- package/lib/public/modules/you-activity.js +3 -1
- package/lib/public/modules/you.js +91 -6
- package/lib/public/muse-avatar.svg +4 -0
- package/lib/public/style.css +6 -0
- package/lib/public/sw.js +3 -1
- package/lib/safe-bash-commands.js +3 -45
- package/lib/scheduled-task-records.js +3 -1
- package/lib/scheduler.js +2 -0
- package/lib/sdk-bridge.js +342 -401
- package/lib/sdk-foreground-admission.js +16 -0
- package/lib/sdk-mcp-descriptors.js +2 -37
- package/lib/sdk-message-processor.js +52 -17
- package/lib/sdk-quota-snapshot.js +1 -1
- package/lib/sdk-response-recovery.js +1 -0
- package/lib/sdk-worker.js +2 -677
- package/lib/server-account-passkeys.js +186 -0
- package/lib/server-account-passwords.js +127 -0
- package/lib/server-account-security.js +53 -0
- package/lib/server-admin.js +63 -16
- package/lib/server-appearance-settings.js +13 -1
- package/lib/server-auth.js +107 -79
- package/lib/server-contextual-clay-settings.js +40 -0
- package/lib/server-contextual-mate-sessions.js +70 -0
- package/lib/server-dm.js +2 -1
- package/lib/server-global-ws.js +10 -20
- package/lib/server-home-chat-events.js +18 -4
- package/lib/server-home-chat.js +22 -20
- package/lib/server-home-clay-entry.js +23 -4
- package/lib/server-home-clay-session-links.js +29 -9
- package/lib/server-home-mate-creation.js +1 -0
- package/lib/server-home-mcp-consent.js +14 -0
- package/lib/server-mates.js +25 -62
- package/lib/server-owner-ui.js +118 -0
- package/lib/server-path-access.js +38 -0
- package/lib/server-project-removal.js +22 -0
- package/lib/server-settings.js +8 -2
- package/lib/server.js +165 -43
- package/lib/session-config-transition.js +45 -0
- package/lib/session-folders.js +7 -2
- package/lib/session-fork-history.js +21 -0
- package/lib/session-github.js +9 -2
- package/lib/session-hygiene.js +3 -35
- package/lib/session-permission-mode.js +4 -3
- package/lib/session-skill-scope.js +11 -0
- package/lib/session-visibility.js +5 -2
- package/lib/session-work-primary.js +50 -0
- package/lib/sessions.js +64 -99
- package/lib/shared-browser-cookie-sync.js +32 -0
- package/lib/shared-browser-cookies.js +79 -0
- package/lib/shared-browser-runtime.js +25 -9
- package/lib/shared-browser-storage-sync.js +43 -0
- package/lib/shared-browser-storage.js +101 -0
- package/lib/shared-browser-tools.js +2 -1
- package/lib/shared-browser-worker.js +46 -10
- package/lib/terminal-manager.js +65 -6
- package/lib/tool-llm.js +1 -1
- package/lib/tui-transcript-index.js +1 -132
- package/lib/user-knowledge-service.js +23 -1
- package/lib/users-auth.js +38 -3
- package/lib/users-contextual-clay-preferences.js +31 -0
- package/lib/users-create.js +97 -0
- package/lib/users-permissions.js +2 -8
- package/lib/users-server-pin.js +37 -0
- package/lib/users.js +18 -84
- package/lib/vendor-login-browser.js +1 -11
- package/lib/workspace-assignment-service.js +25 -0
- package/lib/workspace-query-access.js +4 -1
- package/lib/workspace-query-mcp-server.js +1 -1
- package/lib/workspace-query-service.js +13 -2
- package/lib/ws-request.js +1 -0
- package/lib/ws-schema.js +18 -2
- package/lib/yoke/acp-agent-profiles.js +7 -5
- package/lib/yoke/adapters/antigravity.js +3 -14
- package/lib/yoke/adapters/claude-query-contract.js +9 -0
- package/lib/yoke/adapters/claude.js +54 -50
- package/lib/yoke/adapters/codex-query-contract.js +24 -0
- package/lib/yoke/adapters/codex.js +53 -111
- package/lib/yoke/adapters/kiro.js +3 -1
- package/lib/yoke/adapters/muse-query-contract.js +7 -0
- package/lib/yoke/adapters/muse.js +122 -0
- package/lib/yoke/auth-events.js +17 -0
- package/lib/yoke/claude-hook-installer.js +271 -0
- package/lib/yoke/claude-jsonl-watcher.js +204 -0
- package/lib/yoke/claude-maintenance.js +55 -0
- package/lib/yoke/claude-permission-patterns.js +53 -0
- package/lib/yoke/claude-response-recovery.js +155 -0
- package/lib/yoke/claude-transcript-hygiene.js +34 -0
- package/lib/yoke/claude-worker-startup.js +28 -0
- package/lib/yoke/clay-skill-install.js +33 -0
- package/lib/yoke/cli-sessions.js +300 -0
- package/lib/yoke/codex-app-server.js +7 -12
- package/lib/yoke/codex-idle-recovery.js +81 -1
- package/lib/yoke/codex-recovery-admission.js +164 -0
- package/lib/yoke/configuration.js +13 -0
- package/lib/yoke/discovery.js +70 -0
- package/lib/yoke/errors.js +8 -0
- package/lib/yoke/host-environment.js +7 -0
- package/lib/yoke/index.js +9 -51
- package/lib/yoke/interface.js +116 -0
- package/lib/yoke/kiro-acp-server.js +5 -5
- package/lib/yoke/legacy-sessions.js +89 -0
- package/lib/yoke/login-protocol.js +25 -0
- package/lib/yoke/maintenance.js +12 -0
- package/lib/yoke/mcp-proxy.js +32 -0
- package/lib/yoke/mcp-source-adapters.js +91 -0
- package/lib/yoke/mcp-source-context.js +42 -0
- package/lib/yoke/mcp-source-discovery.js +169 -0
- package/lib/yoke/mcp-source-plugins.js +68 -0
- package/lib/yoke/mcp-source-restrictions.js +47 -0
- package/lib/yoke/mcp-tool-policy-normalize.js +28 -0
- package/lib/yoke/model-preferences.js +6 -0
- package/lib/yoke/muse-artifacts.js +36 -0
- package/lib/yoke/muse-controls.js +50 -0
- package/lib/yoke/muse-input.js +64 -0
- package/lib/yoke/muse-items.js +157 -0
- package/lib/yoke/muse-policy.js +52 -0
- package/lib/yoke/muse-query.js +428 -0
- package/lib/yoke/muse-runtime.js +211 -0
- package/lib/yoke/muse-services.js +79 -0
- package/lib/yoke/muse-skills.js +79 -0
- package/lib/yoke/muse-turns.js +71 -0
- package/lib/yoke/options/acp.js +2 -0
- package/lib/yoke/options/antigravity.js +2 -0
- package/lib/yoke/options/claude.js +21 -0
- package/lib/yoke/options/codex-defaults.js +29 -0
- package/lib/yoke/options/codex-settings.js +21 -0
- package/lib/yoke/options/codex.js +6 -0
- package/lib/yoke/options/kiro-defaults.js +22 -0
- package/lib/yoke/options/kiro.js +5 -0
- package/lib/yoke/options/muse.js +5 -0
- package/lib/yoke/provider-contract.js +5 -0
- package/lib/yoke/providers/antigravity-executable.js +8 -0
- package/lib/yoke/providers/claude-executable.js +40 -0
- package/lib/yoke/providers/claude-model-descriptions.js +14 -0
- package/lib/yoke/providers/claude-process.js +97 -0
- package/lib/yoke/providers/claude-provision.js +75 -0
- package/lib/yoke/providers/codex-errors.js +8 -0
- package/lib/yoke/providers/muse-executable.js +17 -0
- package/lib/yoke/provisioning.js +6 -0
- package/lib/yoke/query-options.js +10 -0
- package/lib/yoke/response-recovery.js +41 -0
- package/lib/yoke/sdk-mcp-descriptors.js +37 -0
- package/lib/yoke/sdk-server-factory.js +7 -0
- package/lib/yoke/session-history.js +8 -0
- package/lib/yoke/session-tool-transport.js +34 -13
- package/lib/yoke/settings.js +23 -0
- package/lib/yoke/source-locations.js +4 -0
- package/lib/yoke/title-query.js +18 -7
- package/lib/yoke/tui-transcript-index.js +132 -0
- package/lib/yoke/usage.js +48 -0
- package/lib/yoke/user-input.js +13 -0
- package/lib/yoke/vendor-registry.js +81 -1
- package/package.json +11 -4
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { contextualFrame, contextualMate } from './contextual-mate-identity.js';
|
|
2
|
+
import { store } from './store.js';
|
|
3
|
+
import { openMateWorkspace, returnFromClay } from './project-mate-navigation.js';
|
|
4
|
+
import { takeComposerDraft, restoreComposerDraft, autoResize } from './input.js';
|
|
5
|
+
import { showToast } from './utils.js';
|
|
6
|
+
import { iconHtml, refreshIcons } from './icons.js';
|
|
7
|
+
import { getHomeMateName } from './home-mate-selection.js';
|
|
8
|
+
|
|
9
|
+
function bridge(mateId, sessionId) {
|
|
10
|
+
var surface = document.getElementById('contextual-clay');
|
|
11
|
+
var frame = contextualFrame(mateId, sessionId);
|
|
12
|
+
var connection = surface && frame && frame.conversation;
|
|
13
|
+
if (!connection || !contextualMate(frame.dataset.mateId) || connection.source !== frame.contentWindow) return null;
|
|
14
|
+
var identity = connection.identity();
|
|
15
|
+
return identity.ownerId === store.get('myUserId') && identity.mateId === frame.dataset.mateId ? connection : null;
|
|
16
|
+
}
|
|
17
|
+
function lockNative(value) {
|
|
18
|
+
['messages', 'input-wrapper'].forEach(function (id) { var element = document.getElementById(id); if (element) element.inert = value; });
|
|
19
|
+
}
|
|
20
|
+
// A direct/native Mate entry also lends its composer to one pane at a time.
|
|
21
|
+
export function beginContextualNativeOrigin(mate) {
|
|
22
|
+
if (store.get('currentSlug') !== 'mate-' + mate.id) return true;
|
|
23
|
+
var existing = contextualFrame(mate.id);
|
|
24
|
+
if (existing && existing.dataset.sessionId && Number(existing.dataset.sessionId) !== store.get('activeSessionId')) return true;
|
|
25
|
+
if (existing && existing.conversation && existing.conversation.identity().sessionId !== store.get('activeSessionId')) return true;
|
|
26
|
+
try {
|
|
27
|
+
var draft = takeComposerDraft();
|
|
28
|
+
store.set({ contextualNativeOrigin: { mateId: mate.id, slug: store.get('currentSlug'), sessionId: store.get('activeSessionId'), draft: draft, stage: 'waiting' } });
|
|
29
|
+
lockNative(true); return true;
|
|
30
|
+
} catch (error) { showToast(error.message, 'error'); return false; }
|
|
31
|
+
}
|
|
32
|
+
export function syncContextualNativeOrigin() {
|
|
33
|
+
var origin = store.get('contextualNativeOrigin'); var connection = origin && bridge(origin.mateId, origin.sessionId);
|
|
34
|
+
if (!origin || origin.stage !== 'waiting' || !connection || !connection.identity().ready || connection.identity().mateId !== origin.mateId || connection.identity().sessionId !== origin.sessionId) return;
|
|
35
|
+
store.set({ contextualNativeOrigin: Object.assign({}, origin, { draft: null, stage: 'pane' }) });
|
|
36
|
+
connection.suspend(false); connection.restore(origin.draft);
|
|
37
|
+
}
|
|
38
|
+
export function abandonContextualNativeOrigin(mateId) {
|
|
39
|
+
var origin = store.get('contextualNativeOrigin');
|
|
40
|
+
if (!origin || origin.mateId !== mateId) return;
|
|
41
|
+
// A removed/revoked identity cannot receive a draft or trap later navigation.
|
|
42
|
+
store.set({ contextualNativeOrigin: null }); lockNative(false);
|
|
43
|
+
showToast('This Mate conversation is no longer available.', 'warn');
|
|
44
|
+
}
|
|
45
|
+
export function finishContextualNativeOrigin() {
|
|
46
|
+
var origin = store.get('contextualNativeOrigin');
|
|
47
|
+
if (!origin) return true;
|
|
48
|
+
try {
|
|
49
|
+
var connection = bridge(origin.mateId, origin.sessionId);
|
|
50
|
+
var draft = origin.stage === 'waiting' ? origin.draft : connection && connection.take();
|
|
51
|
+
if (!draft) throw new Error('Wait for this Mate conversation to reconnect.');
|
|
52
|
+
if (connection) connection.suspend(true);
|
|
53
|
+
restoreComposerDraft(draft); store.set({ contextualNativeOrigin: null }); lockNative(false); return true;
|
|
54
|
+
} catch (error) { showToast(error.message, 'error'); return false; }
|
|
55
|
+
}
|
|
56
|
+
export function openContextualWorkspace(clay) {
|
|
57
|
+
var connection = bridge();
|
|
58
|
+
var identity = connection && connection.identity();
|
|
59
|
+
if (!contextualMate(clay.id) || !identity || identity.mateId !== clay.id || !identity.ready) { showToast('Wait for this Mate conversation to reconnect.', 'error'); return; }
|
|
60
|
+
var origin = store.get('contextualNativeOrigin');
|
|
61
|
+
if (origin && origin.mateId === clay.id && origin.sessionId === identity.sessionId) {
|
|
62
|
+
if (!finishContextualNativeOrigin()) return;
|
|
63
|
+
var existingHandoff = store.get('contextualWorkspace');
|
|
64
|
+
if (existingHandoff && existingHandoff.slug === origin.slug && existingHandoff.sessionId === origin.sessionId) { store.set({ contextualClay: { mode: 'workspace', mateId: clay.id, sessionId: origin.sessionId } }); return; }
|
|
65
|
+
var target = store.get('clayReturnTarget');
|
|
66
|
+
store.set({ contextualWorkspace: { slug: origin.slug, sessionId: origin.sessionId, stage: 'workspace', projectDraft: null, returnSlug: target && target.projectSlug, returnSessionId: target && target.sessionId }, contextualClay: { mode: 'workspace', mateId: clay.id } });
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (origin && !finishContextualNativeOrigin()) return;
|
|
70
|
+
try {
|
|
71
|
+
var projectDraft = takeComposerDraft();
|
|
72
|
+
var draft;
|
|
73
|
+
try { draft = connection.take(); } catch (error) { restoreComposerDraft(projectDraft); throw error; }
|
|
74
|
+
connection.suspend(true);
|
|
75
|
+
store.set({ contextualWorkspace: { slug: 'mate-' + clay.id, sessionId: identity.sessionId, draft: draft, projectDraft: projectDraft, stage: 'opening', returnSlug: store.get('currentSlug'), returnSessionId: store.get('activeSessionId'), returnWorkspace: store.get('contextualWorkspace') }, contextualClay: { mode: 'opening', mateId: clay.id } });
|
|
76
|
+
lockNative(true);
|
|
77
|
+
openMateWorkspace(clay.id, identity.sessionId);
|
|
78
|
+
} catch (error) { showToast(error.message, 'error'); }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Called by the existing return service before it changes the route/session.
|
|
82
|
+
export function finishContextualWorkspace() {
|
|
83
|
+
var handoff = store.get('contextualWorkspace');
|
|
84
|
+
if (!handoff || handoff.stage === 'returning') return;
|
|
85
|
+
var connection = bridge(handoff.slug.slice(5), handoff.sessionId);
|
|
86
|
+
if (!connection) { store.set({ contextualWorkspace: null, contextualClay: { mode: 'closed' } }); lockNative(false); return true; }
|
|
87
|
+
try {
|
|
88
|
+
var draft = handoff.draft;
|
|
89
|
+
if (handoff.stage === 'workspace' && store.get('currentSlug') === handoff.slug && store.get('activeSessionId') === handoff.sessionId) draft = takeComposerDraft();
|
|
90
|
+
connection.restore(draft);
|
|
91
|
+
connection.suspend(false);
|
|
92
|
+
var presentation = store.get('contextualClay') || {};
|
|
93
|
+
var keepOverlay = presentation.mode === 'popover' && connection !== bridge();
|
|
94
|
+
store.set({ contextualWorkspace: Object.assign({}, handoff, { draft: null, stage: 'returning' }), contextualClay: keepOverlay ? presentation : Object.assign({}, presentation, { mode: 'closed' }) });
|
|
95
|
+
lockNative(true);
|
|
96
|
+
return true;
|
|
97
|
+
} catch (error) { showToast(error.message, 'error'); return false; }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function handleContextualWorkspaceMessage(msg) {
|
|
101
|
+
var handoff = store.get('contextualWorkspace');
|
|
102
|
+
if (!handoff || store.get('paneMode')) return;
|
|
103
|
+
if (msg.type === 'session_switched' && handoff.stage.indexOf('workspace') === 0 && store.get('currentSlug') === handoff.slug) {
|
|
104
|
+
var saved = handoff.draft;
|
|
105
|
+
if (store.get('activeSessionId') === handoff.sessionId) saved = takeComposerDraft();
|
|
106
|
+
var exact = msg.id === handoff.sessionId;
|
|
107
|
+
store.set({ contextualWorkspace: Object.assign({}, handoff, { draft: saved, stage: exact ? 'opening' : 'workspace-other' }) });
|
|
108
|
+
if (exact) lockNative(true);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (msg.type !== 'history_done') return;
|
|
112
|
+
if (handoff.stage === 'opening' && store.get('currentSlug') === handoff.slug && store.get('activeSessionId') === handoff.sessionId) {
|
|
113
|
+
restoreComposerDraft(handoff.draft);
|
|
114
|
+
store.set({ contextualWorkspace: Object.assign({}, handoff, { draft: null, stage: 'workspace' }), contextualClay: Object.assign({}, store.get('contextualClay'), { mode: 'workspace' }) });
|
|
115
|
+
lockNative(false);
|
|
116
|
+
} else if (handoff.stage === 'returning' && (store.get('currentSlug') !== handoff.slug || store.get('activeSessionId') !== handoff.sessionId)) {
|
|
117
|
+
if (handoff.projectDraft && store.get('currentSlug') === handoff.returnSlug && store.get('activeSessionId') === handoff.returnSessionId) restoreComposerDraft(handoff.projectDraft);
|
|
118
|
+
var restored = handoff.returnWorkspace && store.get('currentSlug') === handoff.returnSlug && store.get('activeSessionId') === handoff.returnSessionId ? handoff.returnWorkspace : null;
|
|
119
|
+
store.set({ contextualWorkspace: restored, contextualClay: restored ? { mode: 'workspace', mateId: restored.slug.slice(5), sessionId: restored.sessionId } : store.get('contextualClay') });
|
|
120
|
+
lockNative(false);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export function renderContextualWorkspaceBack() {
|
|
124
|
+
var handoff = store.get('contextualWorkspace');
|
|
125
|
+
document.body.classList.toggle('contextual-clay-native', !!handoff && handoff.stage === 'workspace' && store.get('currentSlug') === handoff.slug);
|
|
126
|
+
var button = document.getElementById('contextual-workspace-back');
|
|
127
|
+
if (!button) {
|
|
128
|
+
button = document.createElement('button'); button.id = 'contextual-workspace-back'; button.type = 'button';
|
|
129
|
+
button.innerHTML = iconHtml('arrow-left') + '<span>Back to project</span>';
|
|
130
|
+
button.addEventListener('click', returnFromClay);
|
|
131
|
+
document.getElementById('header-left').prepend(button);
|
|
132
|
+
refreshIcons();
|
|
133
|
+
}
|
|
134
|
+
var returnMate = handoff && handoff.returnSlug && handoff.returnSlug.indexOf('mate-') === 0 && contextualMate(handoff.returnSlug.slice(5));
|
|
135
|
+
button.querySelector('span').textContent = returnMate ? 'Back to ' + getHomeMateName(returnMate) : 'Back to project';
|
|
136
|
+
button.hidden = !handoff || handoff.stage.indexOf('workspace') !== 0 || store.get('currentSlug') !== handoff.slug;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function prepareContextualWorkspaceDeparture(slug) {
|
|
140
|
+
var origin = store.get('contextualNativeOrigin');
|
|
141
|
+
if (origin && slug !== origin.slug) {
|
|
142
|
+
if ((store.get('contextualClay') || {}).mode === 'popover') {
|
|
143
|
+
var connection = bridge(origin.mateId, origin.sessionId);
|
|
144
|
+
try {
|
|
145
|
+
if (origin.stage !== 'pane' || !connection || !connection.identity().ready) throw new Error('Wait for this Mate conversation to reconnect.');
|
|
146
|
+
// The pane keeps its composer when its former native parent changes.
|
|
147
|
+
connection.checkDraft();
|
|
148
|
+
store.set({ contextualNativeOrigin: null }); lockNative(false);
|
|
149
|
+
} catch (error) { showToast(error.message, 'error'); return false; }
|
|
150
|
+
} else if (!finishContextualNativeOrigin()) return false;
|
|
151
|
+
}
|
|
152
|
+
var handoff = store.get('contextualWorkspace');
|
|
153
|
+
if (handoff && handoff.stage.indexOf('workspace') === 0 && slug !== handoff.slug) return finishContextualWorkspace();
|
|
154
|
+
}
|
|
155
|
+
export function initContextualWorkspace() {
|
|
156
|
+
var width = 0;
|
|
157
|
+
new ResizeObserver(function (entries) {
|
|
158
|
+
var next = entries[0].contentRect.width;
|
|
159
|
+
if (next === width || !next || !store.get('contextualWorkspace')) return;
|
|
160
|
+
width = next; autoResize();
|
|
161
|
+
}).observe(document.getElementById('input-textarea-wrap'));
|
|
162
|
+
store.subscribe(function (value, previous) {
|
|
163
|
+
var handoff = value.contextualWorkspace;
|
|
164
|
+
if (!handoff || handoff.stage !== 'workspace' || !previous.connected || value.connected || value.currentSlug !== handoff.slug) return;
|
|
165
|
+
var draft = takeComposerDraft();
|
|
166
|
+
store.set({ contextualWorkspace: Object.assign({}, handoff, { draft: draft, stage: 'opening' }), pendingProjectSessionNavigation: { projectSlug: handoff.slug, sessionId: handoff.sessionId } });
|
|
167
|
+
lockNative(true);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { attachContextualSessionCitations } from './contextual-session-citations.js';
|
|
2
|
+
import { attachContextualConversations } from './contextual-mate-sessions.js';
|
|
3
|
+
import { getCachedSessions } from './sidebar-sessions.js';
|
|
4
|
+
import { updateMateContext, recordMateContextSubmission } from './contextual-mate-context.js';
|
|
5
|
+
import { contextualMate, contextualMateStamp, contextualFrame, contextualTrigger } from './contextual-mate-identity.js';
|
|
6
|
+
import { initContextualMateHint } from './contextual-mate-hint.js';
|
|
7
|
+
import { getHomeMateName } from './home-mate-selection.js';
|
|
8
|
+
import { attachContextualGeometry, initContextualGeometry, positionContextualClay } from './contextual-clay-geometry.js';
|
|
9
|
+
import { abandonContextualNativeOrigin, beginContextualNativeOrigin, syncContextualNativeOrigin, finishContextualNativeOrigin, openContextualWorkspace, renderContextualWorkspaceBack, initContextualWorkspace } from './contextual-clay-workspace.js';
|
|
10
|
+
import { mateAvatarUrl } from './avatar.js';
|
|
11
|
+
import { iconHtml, refreshIcons } from './icons.js';
|
|
12
|
+
import { activateContextualMate, returnFromClay } from './project-mate-navigation.js';
|
|
13
|
+
import { initContextualSession } from './contextual-clay-session.js';
|
|
14
|
+
import { initClayControlActivity, clearClayControlActivity } from './clay-control-activity.js';
|
|
15
|
+
// The compact pane stays mounted; native navigation transfers draft ownership.
|
|
16
|
+
import { store } from './store.js';
|
|
17
|
+
|
|
18
|
+
function state() { return store.get('contextualClay') || { mode: 'closed' }; }
|
|
19
|
+
export function contextualClayMode() { return state().mode; }
|
|
20
|
+
function host() { return document.getElementById('contextual-clay'); }
|
|
21
|
+
function trigger() { return contextualTrigger(); }
|
|
22
|
+
export function enterComposer() {
|
|
23
|
+
var surface = host();
|
|
24
|
+
if (!surface || surface.dataset.focusEntry !== 'true') return;
|
|
25
|
+
var frame = contextualFrame();
|
|
26
|
+
if (!frame || frame.inert || !frame.conversation || !frame.conversation.identity().ready) return;
|
|
27
|
+
var input = frame.contentDocument && frame.contentDocument.getElementById('input');
|
|
28
|
+
if (contextualClayMode() !== 'popover' || document.activeElement !== trigger()) { delete surface.dataset.focusEntry; return; }
|
|
29
|
+
if (input && !input.closest('[inert]')) { delete surface.dataset.focusEntry; input.focus({ preventScroll: true }); }
|
|
30
|
+
}
|
|
31
|
+
function escapePopover(event) {
|
|
32
|
+
// Run after native inner menus have had their own Escape handler.
|
|
33
|
+
queueMicrotask(function () {
|
|
34
|
+
if (event.defaultPrevented || contextualClayMode() !== 'popover') return;
|
|
35
|
+
var context = host().querySelector('details[open]');
|
|
36
|
+
if (context) { context.open = false; context.querySelector('summary').focus(); return; }
|
|
37
|
+
var focused = document.activeElement;
|
|
38
|
+
if (!host().contains(focused) && focused !== trigger()) return;
|
|
39
|
+
event.preventDefault(); dismissContextualClay(true);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function dismissContextualClay(restoreFocus) {
|
|
44
|
+
if (!finishContextualNativeOrigin()) return;
|
|
45
|
+
if (contextualClayMode() === 'opening') { returnFromClay(); return; }
|
|
46
|
+
var surface = host();
|
|
47
|
+
var ownedFocus = surface && (surface.contains(document.activeElement) || document.activeElement === surface);
|
|
48
|
+
var target = store.get('clayReturnTarget');
|
|
49
|
+
var missing = target && target.projectSlug === store.get('currentSlug') && !(store.get('projectsHubList') || []).some(function (project) { return project.slug === target.projectSlug && project.contentAccess !== false; });
|
|
50
|
+
store.set({ contextualClay: Object.assign({}, state(), { mode: 'closed' }) });
|
|
51
|
+
if (missing) returnFromClay();
|
|
52
|
+
// The return context survives a temporary popover dismissal.
|
|
53
|
+
if (restoreFocus && ownedFocus && trigger()) trigger().focus({ preventScroll: true });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
function render() {
|
|
58
|
+
var surface = host();
|
|
59
|
+
var mode = contextualClayMode();
|
|
60
|
+
renderContextualWorkspaceBack();
|
|
61
|
+
if (!surface) return;
|
|
62
|
+
surface.hidden = mode === 'closed' || mode === 'workspace';
|
|
63
|
+
surface.dataset.mode = mode;
|
|
64
|
+
positionContextualClay();
|
|
65
|
+
surface.querySelector('[data-clay-expand]').hidden = mode !== 'popover';
|
|
66
|
+
surface.querySelector('[data-clay-close]').hidden = mode !== 'popover' && mode !== 'opening';
|
|
67
|
+
var mate = contextualMate(state().mateId);
|
|
68
|
+
if (mate) {
|
|
69
|
+
var name = getHomeMateName(mate);
|
|
70
|
+
surface.setAttribute('aria-label', name + ' conversation');
|
|
71
|
+
surface.querySelector('strong').textContent = name;
|
|
72
|
+
var header = surface.querySelector('header');
|
|
73
|
+
var mobile = window.matchMedia('(max-width: 768px)').matches;
|
|
74
|
+
header.tabIndex = mobile ? -1 : 0;
|
|
75
|
+
header.setAttribute('aria-label', mobile ? name + ' conversation' : 'Move ' + name + ' conversation. Use arrow keys; hold Shift for larger steps.');
|
|
76
|
+
header.title = mobile ? name : 'Drag to move · Arrow keys when focused';
|
|
77
|
+
surface.querySelectorAll('[data-clay-resize]').forEach(function (handle) { handle.setAttribute('aria-label', 'Resize ' + name + ' conversation. Use arrow keys; hold Shift for larger steps.'); });
|
|
78
|
+
surface.querySelector('.contextual-clay-avatar').src = mateAvatarUrl(mate, 28);
|
|
79
|
+
var expand = surface.querySelector('[data-clay-expand]');
|
|
80
|
+
expand.querySelector('span').textContent = 'Open ' + name;
|
|
81
|
+
expand.setAttribute('aria-label', 'Open ' + name); expand.title = 'Open ' + name + ' workspace';
|
|
82
|
+
surface.querySelector('[data-clay-close]').setAttribute('aria-label', 'Close ' + name + ' conversation');
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
var projectContext = (store.get('projectsHubList') || []).find(function (item) { return item.slug === store.get('currentSlug'); });
|
|
86
|
+
var contextSession = getCachedSessions().find(function (item) { return item.id === store.get('activeSessionId'); });
|
|
87
|
+
var screen = store.get('homeShellVisible') || store.get('projectsHubVisible') ? 'Home' : store.get('dmMode') ? 'Direct message' : 'Project';
|
|
88
|
+
var projectView = screen === 'Project';
|
|
89
|
+
var parentReady = store.get('activeProjectSlug') === store.get('currentSlug') && store.get('sessionActivatedProjectSlug') === store.get('currentSlug') && !store.get('replayingHistory');
|
|
90
|
+
updateMateContext(surface, mate, contextualFrame(), {
|
|
91
|
+
projectTitle: projectView ? projectContext && (projectContext.title || projectContext.project || projectContext.slug) : store.get('projectsHubVisible') ? 'Projects' : screen,
|
|
92
|
+
conversationTitle: projectView && parentReady && contextSession ? contextSession.title : null,
|
|
93
|
+
projectSlug: projectView && parentReady ? store.get('currentSlug') : null,
|
|
94
|
+
sessionId: projectView && parentReady ? store.get('activeSessionId') : null,
|
|
95
|
+
screen: screen, ownerId: store.get('myUserId') || null
|
|
96
|
+
});
|
|
97
|
+
if (trigger()) trigger().setAttribute('aria-expanded', String(mode === 'popover'));
|
|
98
|
+
var selectedFrame = contextualFrame();
|
|
99
|
+
var connection = selectedFrame && selectedFrame.conversation;
|
|
100
|
+
surface.querySelector('[data-clay-loading]').hidden = !!(connection && connection.identity().ready) || surface.dataset.askPending === 'true';
|
|
101
|
+
surface.querySelectorAll('iframe').forEach(function (frame) { frame.hidden = frame !== selectedFrame; });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createFrame(mate, sessionId) {
|
|
105
|
+
var surface = host();
|
|
106
|
+
var frame = document.createElement('iframe');
|
|
107
|
+
frame.title = getHomeMateName(mate) + ' conversation';
|
|
108
|
+
frame.dataset.mateId = mate.id;
|
|
109
|
+
frame.dataset.ownerId = store.get('myUserId') || '';
|
|
110
|
+
frame.dataset.identityStamp = contextualMateStamp(mate);
|
|
111
|
+
frame.dataset.canonical = String(mate.builtinKey === 'clay');
|
|
112
|
+
frame.hidden = true;
|
|
113
|
+
if (sessionId) frame.dataset.sessionId = String(sessionId);
|
|
114
|
+
var origin = store.get('contextualNativeOrigin');
|
|
115
|
+
frame.src = '/p/' + encodeURIComponent('mate-' + mate.id) + '/?pane=1&contextual=1' + (sessionId ? '&session=' + sessionId : origin && origin.mateId === mate.id ? '&session=' + origin.sessionId : '');
|
|
116
|
+
frame.addEventListener('load', function () {
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
if (frame.contentWindow.location.pathname !== '/p/' + encodeURIComponent('mate-' + mate.id) + '/') return;
|
|
120
|
+
frame.contentDocument.addEventListener('click', function (event) {
|
|
121
|
+
if (frame === contextualFrame() && event.target.closest('#generation-stop, #autonomous-run-stop, #send-btn.stop')) clearClayControlActivity();
|
|
122
|
+
}, true);
|
|
123
|
+
} catch (error) { /* Authentication owns its document. */ }
|
|
124
|
+
if (frame === contextualFrame()) enterComposer();
|
|
125
|
+
});
|
|
126
|
+
surface.querySelector('.contextual-clay-body').appendChild(frame);
|
|
127
|
+
return frame;
|
|
128
|
+
}
|
|
129
|
+
function ensureSurface() {
|
|
130
|
+
if (!host()) {
|
|
131
|
+
var surface = document.createElement('section');
|
|
132
|
+
surface.id = 'contextual-clay'; surface.setAttribute('role', 'dialog');
|
|
133
|
+
surface.innerHTML = '<header><img class="contextual-clay-avatar" alt=""><div class="contextual-clay-identity"><strong></strong><div class="contextual-context-line"><span data-clay-context></span><details class="contextual-clay-context"><summary aria-label="What this Mate can see" title="What this Mate can see">' + iconHtml('circle-help') + '</summary><p></p></details></div></div><div class="contextual-clay-actions"><button type="button" data-clay-expand>' + iconHtml('arrow-up-right') + '<span></span></button><button type="button" data-clay-close title="Close">' + iconHtml('x') + '</button></div></header><p class="contextual-capabilities" role="note" aria-label="Conversation capabilities"></p><div class="contextual-clay-body"><p data-clay-loading role="status">Opening conversation…</p></div>';
|
|
134
|
+
surface.addEventListener('contextual-clay-keydown', function (event) {
|
|
135
|
+
var detail = event.detail; var frame = contextualFrame();
|
|
136
|
+
if (!detail || !frame || detail.source !== frame.contentWindow) return;
|
|
137
|
+
if (detail.keyboardEvent.key === 'Escape' && !detail.keyboardEvent.defaultPrevented && contextualClayMode() === 'popover') escapePopover(detail.keyboardEvent);
|
|
138
|
+
});
|
|
139
|
+
surface.addEventListener('contextual-clay-ready', function () {
|
|
140
|
+
var frame = contextualFrame(), current = state();
|
|
141
|
+
var identity = frame && frame.conversation && frame.conversation.identity();
|
|
142
|
+
if (identity && identity.ready && identity.ownerId === store.get('myUserId') && identity.mateId === current.mateId && !current.sessionId && !current.startingAsk) {
|
|
143
|
+
var selections = Object.assign({}, store.get('contextualSessionSelection')); selections[current.mateId] = identity.sessionId;
|
|
144
|
+
store.set({ contextualSessionSelection: selections, contextualClay: Object.assign({}, current, { sessionId: identity.sessionId }) });
|
|
145
|
+
}
|
|
146
|
+
syncContextualNativeOrigin(); render();
|
|
147
|
+
});
|
|
148
|
+
surface.addEventListener('contextual-clay-availability', render);
|
|
149
|
+
surface.addEventListener('contextual-context-submitted', function (event) { recordMateContextSubmission(surface, event); });
|
|
150
|
+
document.body.appendChild(surface); attachContextualConversations(surface); attachContextualSessionCitations(surface); attachContextualGeometry(surface); refreshIcons();
|
|
151
|
+
surface.querySelector('[data-clay-close]').addEventListener('click', function () { dismissContextualClay(true); });
|
|
152
|
+
surface.querySelector('[data-clay-expand]').addEventListener('click', function () { var mate = contextualMate(state().mateId); if (mate) openContextualWorkspace(mate); });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function showContextualAsk(mate, requestId, sessionId) {
|
|
157
|
+
if (!mate || !contextualMate(mate.id) || store.get('paneMode') || !finishContextualNativeOrigin()) return false;
|
|
158
|
+
ensureSurface();
|
|
159
|
+
if (sessionId && !contextualFrame(mate.id, sessionId)) createFrame(mate, sessionId);
|
|
160
|
+
var selections = Object.assign({}, store.get('contextualSessionSelection'));
|
|
161
|
+
if (sessionId) selections[mate.id] = sessionId;
|
|
162
|
+
store.set({ contextualSessionSelection: selections, contextualClay: { mode: 'popover', mateId: mate.id, sessionId: sessionId || null, startingAsk: sessionId ? null : requestId } });
|
|
163
|
+
host().querySelector('[data-clay-loading]').hidden = !!sessionId;
|
|
164
|
+
if (sessionId && contextualFrame()) contextualFrame().hidden = false;
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function selectContextualConversation(mate, sessionId, sessionOriginId) {
|
|
169
|
+
var existing = contextualFrame(mate.id, sessionId);
|
|
170
|
+
if (existing && existing.conversation && existing.conversation.identity().sessionOriginId !== sessionOriginId) return false;
|
|
171
|
+
var previous = state(), selections = store.get('contextualSessionSelection');
|
|
172
|
+
if (!showContextualAsk(mate, 'conversation-selection', sessionId)) return false;
|
|
173
|
+
var frame = contextualFrame(mate.id, sessionId);
|
|
174
|
+
if (!frame) return false;
|
|
175
|
+
frame.dataset.expectedSessionOrigin = sessionOriginId;
|
|
176
|
+
if (!beginContextualNativeOrigin(mate)) { store.set({ contextualClay: previous, contextualSessionSelection: selections }); return false; }
|
|
177
|
+
if (frame.conversation) frame.conversation.suspend(false);
|
|
178
|
+
syncContextualNativeOrigin();
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function cycleContextualClay(mate) {
|
|
183
|
+
if (store.get('paneMode') || !mate || !contextualMate(mate.id)) return;
|
|
184
|
+
var current = state();
|
|
185
|
+
if (current.mode === 'opening') return;
|
|
186
|
+
if (current.mode === 'closed') store.set({ contextualPrepared: null });
|
|
187
|
+
if (current.mode === 'popover' && current.mateId === mate.id) { openContextualWorkspace(mate); return; }
|
|
188
|
+
if (store.get('contextualNativeOrigin') && current.mateId !== mate.id && !finishContextualNativeOrigin()) return;
|
|
189
|
+
if (!store.get('contextualNativeOrigin') && !beginContextualNativeOrigin(mate)) return;
|
|
190
|
+
ensureSurface();
|
|
191
|
+
var frame = contextualFrame(mate.id) || createFrame(mate);
|
|
192
|
+
store.set({ contextualClay: { mode: 'popover', mateId: mate.id, sessionId: frame.dataset.sessionId ? Number(frame.dataset.sessionId) : null } });
|
|
193
|
+
if (frame.conversation) frame.conversation.suspend(false);
|
|
194
|
+
host().dataset.focusEntry = 'true'; syncContextualNativeOrigin(); enterComposer();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function initContextualClay() {
|
|
198
|
+
if (store.get('paneMode')) {
|
|
199
|
+
initContextualSession();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
initContextualMateHint(activateContextualMate);
|
|
203
|
+
initContextualGeometry();
|
|
204
|
+
initClayControlActivity();
|
|
205
|
+
initContextualWorkspace();
|
|
206
|
+
document.addEventListener('pointerdown', function (event) {
|
|
207
|
+
if (host() && !host().contains(event.target)) host().querySelectorAll('details[open]').forEach(function (menu) { menu.open = false; });
|
|
208
|
+
});
|
|
209
|
+
document.addEventListener('keydown', function (event) {
|
|
210
|
+
if (event.key === 'Escape' && !event.defaultPrevented && contextualClayMode() === 'popover') {
|
|
211
|
+
escapePopover(event);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
// Keep the same trigger accessible when the desktop rail is hidden.
|
|
215
|
+
var entry = document.querySelector('.icon-strip-brand');
|
|
216
|
+
var rail = entry && entry.parentNode;
|
|
217
|
+
var next = entry && entry.nextSibling;
|
|
218
|
+
var mobile = window.matchMedia('(max-width: 768px)');
|
|
219
|
+
function placeTrigger() {
|
|
220
|
+
if (!entry) return;
|
|
221
|
+
document.body.classList.toggle('contextual-clay-mobile', mobile.matches);
|
|
222
|
+
entry.classList.toggle('contextual-clay-mobile-trigger', mobile.matches);
|
|
223
|
+
if (mobile.matches) document.body.prepend(entry);
|
|
224
|
+
else rail.insertBefore(entry, next && next.parentNode === rail ? next : rail.firstChild);
|
|
225
|
+
render();
|
|
226
|
+
}
|
|
227
|
+
mobile.addEventListener('change', placeTrigger);
|
|
228
|
+
window.addEventListener('resize', function () { if (host()) positionContextualClay(); });
|
|
229
|
+
placeTrigger();
|
|
230
|
+
store.subscribe(function (value, previous) {
|
|
231
|
+
var current = state();
|
|
232
|
+
if (host()) host().querySelectorAll('iframe').forEach(function (frame) {
|
|
233
|
+
var mate = contextualMate(frame.dataset.mateId);
|
|
234
|
+
if (frame.dataset.discarding === 'true') return;
|
|
235
|
+
if (frame.dataset.ownerId !== (value.myUserId || '') || !mate || frame.dataset.identityStamp !== contextualMateStamp(mate)) { frame.dataset.discarding = 'true'; frame.remove(); abandonContextualNativeOrigin(frame.dataset.mateId); }
|
|
236
|
+
else frame.title = getHomeMateName(mate) + ' conversation';
|
|
237
|
+
});
|
|
238
|
+
if (current.mateId && !current.startingAsk && !contextualFrame(current.mateId)) {
|
|
239
|
+
store.set({ contextualClay: { mode: 'closed', mateId: null } }); render(); return;
|
|
240
|
+
}
|
|
241
|
+
if (value.contextualMatePending && !value.contextualWorkspace && !value.pendingProjectSessionNavigation) {
|
|
242
|
+
var pending = value.contextualMatePending;
|
|
243
|
+
store.set({ contextualMatePending: null }); activateContextualMate(pending); return;
|
|
244
|
+
}
|
|
245
|
+
// Ordinary navigation refreshes context without replacing the conversation.
|
|
246
|
+
// Direct navigation into a native Mate workspace ends the floating surface.
|
|
247
|
+
if (current.mode === 'popover' && value.currentSlug !== previous.currentSlug && (value.currentSlug || '').indexOf('mate-') === 0) dismissContextualClay(false);
|
|
248
|
+
render();
|
|
249
|
+
});
|
|
250
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { store } from './store.js';
|
|
2
|
+
import { iconHtml, refreshIcons } from './icons.js';
|
|
3
|
+
|
|
4
|
+
// Reparent the live controls: their permissions, upload and model handlers stay
|
|
5
|
+
// with the production composer. Only contextual panes use this presentation.
|
|
6
|
+
export function initContextualComposer() {
|
|
7
|
+
var row = document.getElementById('input-row');
|
|
8
|
+
var tools = document.getElementById('attach-wrap');
|
|
9
|
+
var config = document.getElementById('config-chip-wrap');
|
|
10
|
+
var model = document.getElementById('config-chip');
|
|
11
|
+
var modelPopover = document.getElementById('config-popover');
|
|
12
|
+
var button = document.createElement('button');
|
|
13
|
+
button.id = 'contextual-attach-btn'; button.type = 'button';
|
|
14
|
+
button.setAttribute('aria-label', 'Add attachments and context');
|
|
15
|
+
button.setAttribute('aria-haspopup', 'dialog');
|
|
16
|
+
button.setAttribute('aria-controls', 'contextual-attach-popover');
|
|
17
|
+
button.innerHTML = iconHtml('plus');
|
|
18
|
+
var menu = document.createElement('div');
|
|
19
|
+
menu.id = 'contextual-attach-popover'; menu.hidden = true;
|
|
20
|
+
menu.setAttribute('role', 'dialog'); menu.setAttribute('aria-label', 'Attachments and context');
|
|
21
|
+
menu.appendChild(tools); row.append(button, config, menu);
|
|
22
|
+
['attach-file-btn', 'attach-image-btn'].forEach(function (id) {
|
|
23
|
+
var control = document.getElementById(id);
|
|
24
|
+
var label = document.createElement('span');
|
|
25
|
+
label.textContent = id === 'attach-file-btn' ? 'File' : 'Image'; control.appendChild(label);
|
|
26
|
+
control.addEventListener('click', function () { close(true); });
|
|
27
|
+
});
|
|
28
|
+
var contextLabel = document.createElement('span'); contextLabel.textContent = 'Context sources';
|
|
29
|
+
document.getElementById('context-sources-add').appendChild(contextLabel);
|
|
30
|
+
model.setAttribute('aria-label', 'Model and session settings');
|
|
31
|
+
model.setAttribute('aria-haspopup', 'dialog'); model.setAttribute('aria-controls', 'config-popover');
|
|
32
|
+
model.setAttribute('aria-expanded', 'false');
|
|
33
|
+
modelPopover.setAttribute('role', 'dialog'); modelPopover.setAttribute('aria-label', 'Model and session settings');
|
|
34
|
+
function position(popover, anchor) {
|
|
35
|
+
var rect = anchor.getBoundingClientRect();
|
|
36
|
+
popover.style.width = Math.min(280, window.innerWidth - 16) + 'px';
|
|
37
|
+
popover.style.left = Math.max(8, Math.min(rect.left, window.innerWidth - Math.min(280, window.innerWidth - 16) - 8)) + 'px';
|
|
38
|
+
popover.style.bottom = Math.max(8, window.innerHeight - rect.top + 6) + 'px';
|
|
39
|
+
popover.style.maxHeight = Math.max(40, rect.top - 14) + 'px';
|
|
40
|
+
}
|
|
41
|
+
function close(restoreFocus) {
|
|
42
|
+
store.set({ contextualAttachmentMenuOpen: false });
|
|
43
|
+
if (restoreFocus) button.focus({ preventScroll: true });
|
|
44
|
+
}
|
|
45
|
+
function actions() { return Array.from(menu.querySelectorAll('button:not(:disabled)')).filter(function (item) { return item.getClientRects().length; }); }
|
|
46
|
+
button.addEventListener('click', function () {
|
|
47
|
+
var open = !store.get('contextualAttachmentMenuOpen');
|
|
48
|
+
modelPopover.classList.add('hidden'); model.classList.remove('active');
|
|
49
|
+
store.set({ contextualAttachmentMenuOpen: open });
|
|
50
|
+
if (open && actions()[0]) actions()[0].focus({ preventScroll: true });
|
|
51
|
+
});
|
|
52
|
+
document.addEventListener('pointerdown', function (event) {
|
|
53
|
+
if (!menu.contains(event.target) && !button.contains(event.target) && store.get('contextualAttachmentMenuOpen')) close(false);
|
|
54
|
+
});
|
|
55
|
+
document.addEventListener('keydown', function (event) {
|
|
56
|
+
if (event.key === 'Escape' && (!menu.hidden || !modelPopover.classList.contains('hidden'))) {
|
|
57
|
+
event.preventDefault(); event.stopImmediatePropagation();
|
|
58
|
+
var sources = document.getElementById('context-sources-picker');
|
|
59
|
+
if (!menu.hidden && !sources.classList.contains('hidden')) { sources.classList.add('hidden'); document.getElementById('context-sources-add').focus(); }
|
|
60
|
+
else if (!menu.hidden) close(true);
|
|
61
|
+
else { modelPopover.classList.add('hidden'); model.classList.remove('active'); model.focus({ preventScroll: true }); }
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (menu.hidden || !menu.contains(event.target) || !/^(ArrowDown|ArrowUp|Home|End)$/.test(event.key)) return;
|
|
65
|
+
var items = actions(), index = items.indexOf(document.activeElement);
|
|
66
|
+
if (!items.length) return;
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
items[event.key === 'Home' ? 0 : event.key === 'End' ? items.length - 1 : (index + (event.key === 'ArrowUp' ? items.length - 1 : 1)) % items.length].focus();
|
|
69
|
+
}, true);
|
|
70
|
+
menu.addEventListener('focusout', function (event) {
|
|
71
|
+
if (menu.contains(event.relatedTarget) || event.relatedTarget === button) return;
|
|
72
|
+
setTimeout(function () { if (!menu.contains(document.activeElement) && document.activeElement !== button && !menu.hidden) close(false); }, 0);
|
|
73
|
+
});
|
|
74
|
+
model.addEventListener('click', function () { close(false); });
|
|
75
|
+
function placeMenus() { if (!menu.hidden) position(menu, button); if (!modelPopover.classList.contains('hidden')) position(modelPopover, model); }
|
|
76
|
+
new MutationObserver(function () {
|
|
77
|
+
model.setAttribute('aria-expanded', String(!modelPopover.classList.contains('hidden')));
|
|
78
|
+
placeMenus();
|
|
79
|
+
}).observe(modelPopover, { attributes: true, attributeFilter: ['class'] });
|
|
80
|
+
new ResizeObserver(placeMenus).observe(row);
|
|
81
|
+
window.addEventListener('resize', placeMenus);
|
|
82
|
+
store.subscribe(function (value) {
|
|
83
|
+
var open = !!value.contextualAttachmentMenuOpen && value.contextualSessionReady && !value.contextualWriterSuspended;
|
|
84
|
+
menu.hidden = !open; button.setAttribute('aria-expanded', String(open));
|
|
85
|
+
button.disabled = !value.contextualSessionReady || !!value.contextualWriterSuspended;
|
|
86
|
+
if (button.disabled) { modelPopover.classList.add('hidden'); model.classList.remove('active'); }
|
|
87
|
+
placeMenus();
|
|
88
|
+
});
|
|
89
|
+
store.set({ contextualAttachmentMenuOpen: false });
|
|
90
|
+
refreshIcons();
|
|
91
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { store } from './store.js';
|
|
2
|
+
import { getWs } from './ws-ref.js';
|
|
3
|
+
import { contextualFrame } from './contextual-mate-identity.js';
|
|
4
|
+
|
|
5
|
+
function identity(frame) {
|
|
6
|
+
try { return frame && frame.conversation && frame.conversation.identity(); } catch (error) { return null; }
|
|
7
|
+
}
|
|
8
|
+
function contextKey(frame, canonical) {
|
|
9
|
+
var current = identity(frame);
|
|
10
|
+
return JSON.stringify([store.get('currentSlug'), store.get('activeSessionId'), store.get('sessionOriginId'), store.get('activeProjectSlug'), store.get('sessionActivatedProjectSlug'), store.get('replayingHistory'), (store.get('contextualClay') || {}).mode, store.get('homeShellVisible'), store.get('projectsHubVisible'), store.get('dmMode'), store.get('rightWorkbenchOwner'), store.get('homeSubSurface'), store.get('rightWorkbenchRevision'), store.get('myUserId'), store.get('connected'), current && current.mateId, current && current.sessionId, current && (canonical ? current.connected : current.ready), canonical && current && current.sessionOriginId]);
|
|
11
|
+
}
|
|
12
|
+
export function updateMateContext(surface, mate, frame, snapshot) {
|
|
13
|
+
var current = identity(frame), ws = getWs(), key = contextKey(frame, mate && mate.builtinKey === 'clay'), prepared = store.get('contextualPrepared');
|
|
14
|
+
var canonical = mate && mate.builtinKey === 'clay';
|
|
15
|
+
var capabilities = surface.querySelector('.contextual-capabilities');
|
|
16
|
+
capabilities.hidden = !canonical;
|
|
17
|
+
capabilities.setAttribute('aria-label', 'Clay capabilities');
|
|
18
|
+
capabilities.textContent = "I can control Clay Studio for you—manage projects, coordinate work, set up schedules, and navigate your workspace. Just tell me what you’d like done.";
|
|
19
|
+
var privateWorkspace = (store.get('currentSlug') || '').indexOf('mate-') === 0;
|
|
20
|
+
var parentReady = store.get('activeProjectSlug') === store.get('currentSlug') && store.get('sessionActivatedProjectSlug') === store.get('currentSlug') && !store.get('replayingHistory');
|
|
21
|
+
var available = (store.get('contextualClay') || {}).mode === 'popover' && parentReady && !canonical && !privateWorkspace && current && current.ready && store.get('connected') && !store.get('homeShellVisible') && !store.get('projectsHubVisible') && !store.get('dmMode') && !store.get('rightWorkbenchOwner') && ws && ws.readyState === 1;
|
|
22
|
+
var changed = !prepared || prepared.key !== key || prepared.socket !== ws;
|
|
23
|
+
if (changed) {
|
|
24
|
+
var requestId = 'context-' + crypto.randomUUID();
|
|
25
|
+
prepared = { key: key, requestId: requestId, socket: ws, mateId: current && current.mateId, canonical: !!canonical, status: available ? 'preparing' : 'unavailable' };
|
|
26
|
+
}
|
|
27
|
+
// Stamp the reference before publishing a new preparation: store subscribers
|
|
28
|
+
// may render synchronously, and the composer must never see the prior view ID.
|
|
29
|
+
snapshot = Object.assign({}, snapshot, { viewId: prepared.requestId });
|
|
30
|
+
surface.dataset.screenReference = JSON.stringify(snapshot);
|
|
31
|
+
if (changed) {
|
|
32
|
+
store.set({ contextualPrepared: prepared });
|
|
33
|
+
if (ws && ws.readyState === 1) ws.send(JSON.stringify({ type: 'mate_context_prepare', requestId: requestId, available: !!available, mateId: current && current.mateId, sessionId: current && current.sessionId }));
|
|
34
|
+
}
|
|
35
|
+
var shared = ((store.get('contextualSubmitted') || {})[mate && mate.id]);
|
|
36
|
+
var ready = prepared.status === 'ready' && prepared.expiresAt > Date.now();
|
|
37
|
+
var label = surface.querySelector('[data-clay-context]');
|
|
38
|
+
var detail = surface.querySelector('.contextual-clay-context p');
|
|
39
|
+
var summary = ready ? prepared.summary.project + ' / ' + prepared.summary.conversation : null;
|
|
40
|
+
var projectName = (ready && prepared.summary.project) || snapshot.projectTitle || snapshot.screen || 'Current view';
|
|
41
|
+
if (canonical) {
|
|
42
|
+
var currentSummary = (snapshot.projectTitle || snapshot.screen || 'Current view') + (snapshot.conversationTitle ? ' / ' + snapshot.conversationTitle : '');
|
|
43
|
+
var disconnected = !store.get('connected') || current && current.connected === false;
|
|
44
|
+
var sameSnapshot = shared && shared.viewId === prepared.requestId && shared.summary.project + (snapshot.conversationTitle ? ' / ' + shared.summary.conversation : '') === currentSummary;
|
|
45
|
+
var contextStatus = disconnected ? 'Disconnected' : current && current.available === false ? 'Unavailable' : !current || !current.ready ? 'Preparing' : sameSnapshot ? 'Shared' : shared ? 'New view' : 'Next message';
|
|
46
|
+
detail.textContent = "I can help manage your projects, coordinate work with Drivers, and use Studio’s tools. I’ll ask you to review actions when needed.\n"
|
|
47
|
+
+ 'Current view: ' + currentSummary + '. ' + (disconnected ? 'Reconnect before sharing a new snapshot. ' : !current || !current.ready ? 'Wait for this conversation before sharing a new snapshot. ' : sameSnapshot ? 'This metadata snapshot was shared with your last message. Your next message captures the current view again. ' : 'Your next message includes this metadata snapshot. ')
|
|
48
|
+
+ 'Clay receives project and conversation metadata, not continuous screen capture. Its authenticated product tools inspect supported objects separately; changes require their existing review.';
|
|
49
|
+
} else {
|
|
50
|
+
contextStatus = !store.get('connected') || current && current.connected === false ? 'Disconnected' : current && current.available === false ? 'Unavailable' : current && !current.ready || prepared.status === 'preparing' ? 'Preparing' : ready ? (shared && shared.viewId === prepared.requestId ? 'Shared' : shared ? 'New view' : 'Next message') : 'Unavailable';
|
|
51
|
+
detail.textContent = ready ? (shared && shared.viewId === prepared.requestId ? 'Shared with your last message: ' : 'With your next message: ') + summary + '. This Mate can read up to 20 text turns from this selected conversation and request to open it in this window after your review. Tool results, attachments and hidden entries are excluded.' : 'Current view: ' + projectName + '. This view has no supported conversation context. Open an accessible project conversation to share it with your next message.';
|
|
52
|
+
detail.textContent += '\nNo continuous screen capture. Issues, documents, other tabs, files and settings are unavailable through this context.';
|
|
53
|
+
}
|
|
54
|
+
if (prepared.status === 'expired' && !canonical) { contextStatus = 'Expired'; detail.textContent = 'This five-minute context has expired. Close and reopen this Mate to prepare a fresh snapshot. No previous navigation request will replay.'; }
|
|
55
|
+
if (shared) detail.textContent += '\nLast submitted: ' + shared.summary.project + ' / ' + shared.summary.conversation + ((canonical ? sameSnapshot : shared.viewId === prepared.requestId) ? '.' : canonical ? '. The view or connection has changed; that snapshot is stale.' : '. Your view has changed; that context is stale.');
|
|
56
|
+
var projectLabel = label.querySelector('[data-context-project]');
|
|
57
|
+
if (!projectLabel) { projectLabel = document.createElement('span'); projectLabel.dataset.contextProject = ''; var statusLabel = document.createElement('span'); statusLabel.dataset.contextStatus = ''; label.replaceChildren(projectLabel, statusLabel); }
|
|
58
|
+
projectLabel.textContent = projectName;
|
|
59
|
+
label.querySelector('[data-context-status]').textContent = ' · ' + contextStatus;
|
|
60
|
+
label.title = label.textContent;
|
|
61
|
+
surface.contextReference = function (source, session) {
|
|
62
|
+
var live = store.get('contextualPrepared');
|
|
63
|
+
if (!frame || frame.hidden || frame.contentWindow !== source || !session || !current || session.mateId !== current.mateId || session.sessionId !== current.sessionId || !session.ready || !live || live.key !== contextKey(frame, canonical) || live.socket !== getWs() || live.status !== 'ready' || live.expiresAt <= Date.now()) return null;
|
|
64
|
+
return live.contextRef;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function handleMateContextMessage(msg) {
|
|
68
|
+
if (msg.type === 'mate_context_prepared') {
|
|
69
|
+
var pending = store.get('contextualPrepared');
|
|
70
|
+
if (pending && pending.requestId === msg.requestId && pending.socket === getWs() && pending.key === contextKey(contextualFrame(), pending.canonical)) {
|
|
71
|
+
store.set({ contextualPrepared: Object.assign({}, pending, msg, { status: msg.contextRef ? 'ready' : 'unavailable' }) });
|
|
72
|
+
if (msg.contextRef) setTimeout(function () {
|
|
73
|
+
var current = store.get('contextualPrepared');
|
|
74
|
+
if (current && current.contextRef === msg.contextRef) store.set({ contextualPrepared: Object.assign({}, current, { status: 'expired' }) });
|
|
75
|
+
}, Math.max(0, msg.expiresAt - Date.now()));
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if ((msg.type === 'message_ack' || msg.type === 'user_message') && window.parent !== window && window.frameElement && window.frameElement.dataset.canonical === 'true') {
|
|
80
|
+
var recorded = msg.type === 'message_ack' ? msg.message : msg;
|
|
81
|
+
var outbound = (store.get('contextualSnapshotSubmissions') || []).find(function (item) { return item.clientMessageId === msg.clientMessageId; });
|
|
82
|
+
if (!outbound || outbound.confirmed || outbound.accountId !== (store.get('myUserId') || '_default') || !recorded || recorded.clientMessageId !== outbound.clientMessageId || !recorded.contextualSnapshot || msg.type === 'message_ack' && (msg.projectSlug !== outbound.projectSlug || String(msg.sessionId) !== String(outbound.sessionId)) || recorded.projectSlug !== outbound.projectSlug || String(recorded.sessionId) !== String(outbound.sessionId) || recorded.sessionOriginId !== outbound.sessionOriginId || recorded.from && recorded.from !== outbound.accountId || JSON.stringify(recorded.contextualSnapshot) !== JSON.stringify(outbound.snapshot)) return false;
|
|
83
|
+
var snapshot = recorded.contextualSnapshot;
|
|
84
|
+
store.set({ contextualSnapshotSubmissions: store.get('contextualSnapshotSubmissions').map(function (item) { return item === outbound ? Object.assign({}, item, { confirmed: true }) : item; }) });
|
|
85
|
+
try {
|
|
86
|
+
var host = window.parent.document.getElementById('contextual-clay');
|
|
87
|
+
if (host) host.dispatchEvent(new window.parent.CustomEvent('contextual-context-submitted', { detail: { source: window, message: { status: 'submitted', canonical: true, clientMessageId: msg.clientMessageId, viewId: snapshot.viewId, summary: { project: snapshot.projectTitle || snapshot.projectSlug || 'Home', conversation: snapshot.conversationTitle || snapshot.screen } } } }));
|
|
88
|
+
} catch (error) { /* A disconnected authentication view cannot share metadata. */ }
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (msg.type !== 'mate_context_shared') return false;
|
|
92
|
+
try {
|
|
93
|
+
var surface = window.parent.document.getElementById('contextual-clay');
|
|
94
|
+
if (surface && window.frameElement && surface.contains(window.frameElement)) surface.dispatchEvent(new window.parent.CustomEvent('contextual-context-submitted', { detail: { source: window, message: msg } }));
|
|
95
|
+
} catch (error) { /* A disconnected authentication view cannot share context. */ }
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
export function recordMateContextSubmission(surface, event) {
|
|
99
|
+
var frame = Array.from(surface.querySelectorAll('iframe')).find(function (item) { return item.contentWindow === event.detail.source; });
|
|
100
|
+
var pending = store.get('contextualPrepared'), msg = event.detail.message;
|
|
101
|
+
if (!frame || frame.dataset.ownerId !== (store.get('myUserId') || '') || (!msg.canonical && frame.hidden) || !pending) return;
|
|
102
|
+
if (msg.status === 'unavailable') {
|
|
103
|
+
if (pending.mateId === frame.dataset.mateId) store.set({ contextualPrepared: Object.assign({}, pending, { status: 'unavailable' }) });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (msg.status !== 'submitted' || !msg.summary || (msg.canonical ? frame.dataset.canonical !== 'true' || typeof msg.viewId !== 'string' : msg.contextRef !== pending.contextRef)) return;
|
|
107
|
+
var submitted = Object.assign({}, store.get('contextualSubmitted'));
|
|
108
|
+
submitted[frame.dataset.mateId] = { key: msg.canonical ? null : pending.key, viewId: msg.canonical ? msg.viewId : pending.requestId, summary: msg.summary };
|
|
109
|
+
store.set({ contextualSubmitted: submitted });
|
|
110
|
+
}
|
|
111
|
+
export function contextualAccessReference() {
|
|
112
|
+
if (window.parent === window || !store.get('paneMode')) return null;
|
|
113
|
+
try {
|
|
114
|
+
var surface = window.parent.document.getElementById('contextual-clay');
|
|
115
|
+
return surface && surface.contextReference && surface.contextReference(window, { mateId: window.frameElement.dataset.mateId, sessionId: store.get('paneSessionId'), ready: store.get('contextualSessionReady') && store.get('connected') });
|
|
116
|
+
} catch (error) { return null; }
|
|
117
|
+
}
|