clay-server 5.2.0-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-socket.js +1 -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 +78 -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/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-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-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/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/index.html +11 -5
- 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/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 +115 -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/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 +3 -0
- 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/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-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.js +3 -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/muse-avatar.svg +4 -0
- package/lib/public/style.css +5 -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-admin.js +63 -16
- package/lib/server-appearance-settings.js +13 -1
- 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 +6 -1
- package/lib/server.js +163 -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/users-contextual-clay-preferences.js +31 -0
- package/lib/users-permissions.js +2 -8
- package/lib/users.js +7 -0
- 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 +10 -4
|
@@ -154,6 +154,21 @@ function attachNotifications(ctx) {
|
|
|
154
154
|
return notifications.length;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
function controlProjection(item) { var value = Object.assign({}, item); delete value.controlRevision; return Object.assign(value, { controlRevision: require('./clay-control-target-projection').digest(value) }); }
|
|
158
|
+
function visible(ws) {
|
|
159
|
+
return notifications.filter(function (notification) { return !ctx.canView || ctx.canView(ws, notification); }).map(controlProjection);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function publish(payload) {
|
|
163
|
+
if (!ctx.forEachClient) return broadcastAll(payload);
|
|
164
|
+
ctx.forEachClient(function (ws) {
|
|
165
|
+
if (ws.readyState !== 1) return;
|
|
166
|
+
if (payload.notification && !ctx.canView(ws, payload.notification)) return;
|
|
167
|
+
var list = visible(ws);
|
|
168
|
+
ws.send(JSON.stringify(Object.assign({}, payload, { notification: payload.notification ? controlProjection(payload.notification) : undefined, unreadCount: list.length })));
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
157
172
|
// --- Core API ---
|
|
158
173
|
|
|
159
174
|
function notify(event, data) {
|
|
@@ -183,12 +198,13 @@ function attachNotifications(ctx) {
|
|
|
183
198
|
saveNotifications();
|
|
184
199
|
var payload = {
|
|
185
200
|
type: "notification_created",
|
|
186
|
-
notification: notif,
|
|
201
|
+
notification: controlProjection(notif),
|
|
187
202
|
unreadCount: getUnreadCount(),
|
|
188
203
|
};
|
|
189
|
-
//
|
|
190
|
-
|
|
191
|
-
|
|
204
|
+
// Project/session previews are projected for each authenticated viewer.
|
|
205
|
+
if (ctx.forEachClient) {
|
|
206
|
+
publish(payload);
|
|
207
|
+
} else if (notif.targetUserId && typeof sendToUser === "function") {
|
|
192
208
|
sendToUser(notif.targetUserId, payload);
|
|
193
209
|
} else {
|
|
194
210
|
broadcastAll(payload);
|
|
@@ -196,12 +212,14 @@ function attachNotifications(ctx) {
|
|
|
196
212
|
return notif;
|
|
197
213
|
}
|
|
198
214
|
|
|
199
|
-
function dismiss(ids) {
|
|
215
|
+
function dismiss(ids, ws) {
|
|
216
|
+
var permitted = visible(ws).map(function (notification) { return notification.id; });
|
|
217
|
+
ids = ids.filter(function (id) { return permitted.indexOf(id) !== -1; });
|
|
200
218
|
var before = notifications.length;
|
|
201
219
|
notifications = notifications.filter(function(n) { return ids.indexOf(n.id) === -1; });
|
|
202
220
|
if (notifications.length !== before) {
|
|
203
221
|
saveNotifications();
|
|
204
|
-
|
|
222
|
+
publish({
|
|
205
223
|
type: "notification_dismissed",
|
|
206
224
|
ids: ids,
|
|
207
225
|
unreadCount: getUnreadCount(),
|
|
@@ -209,12 +227,41 @@ function attachNotifications(ctx) {
|
|
|
209
227
|
}
|
|
210
228
|
}
|
|
211
229
|
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
230
|
+
function canReadOwned(principal, item) {
|
|
231
|
+
var owner = principal.userId || null;
|
|
232
|
+
return (owner ? (item.targetUserId === owner || item.ownerId === owner) && (!item.targetUserId || item.targetUserId === owner) : !item.ownerId && !item.targetUserId) &&
|
|
233
|
+
(!ctx.canViewPrincipal || ctx.canViewPrincipal(principal, item));
|
|
234
|
+
}
|
|
235
|
+
function authorizeOwned(principal, items) {
|
|
236
|
+
if (items.some(function (item) { return !canReadOwned(principal, item); })) throw new Error('Owned notification access changed.');
|
|
237
|
+
}
|
|
238
|
+
function listOwned(principal) {
|
|
239
|
+
return notifications.filter(function (item) { return canReadOwned(principal, item); }).slice(0, 100).map(function (item) { return JSON.parse(JSON.stringify(controlProjection(item))); });
|
|
240
|
+
}
|
|
241
|
+
function inspectOwned(principal, ids) {
|
|
242
|
+
var owned = listOwned(principal);
|
|
243
|
+
return ids.map(function (id) {
|
|
244
|
+
var item = owned.find(function (entry) { return entry.id === id; });
|
|
245
|
+
if (!item) throw new Error('The exact owned notification is absent or inaccessible.');
|
|
246
|
+
return item;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function dismissOwned(principal, ids, revalidate) {
|
|
250
|
+
revalidate(); inspectOwned(principal, ids);
|
|
251
|
+
var previous = notifications;
|
|
252
|
+
notifications = notifications.filter(function (item) { return ids.indexOf(item.id) < 0; });
|
|
253
|
+
var tmp = NOTIF_FILE + '.tmp';
|
|
254
|
+
try { fs.writeFileSync(tmp, JSON.stringify(notifications, null, 2)); fs.renameSync(tmp, NOTIF_FILE); }
|
|
255
|
+
catch (error) { notifications = previous; throw error; }
|
|
256
|
+
// Use the ordinary per-viewer notification state; no private IDs are broadcast.
|
|
257
|
+
var published = true;
|
|
258
|
+
if (ctx.forEachClient) ctx.forEachClient(function (ws) { try { sendConnectionState(ws, function (client, payload) { if (client.readyState === 1) client.send(JSON.stringify(payload)); }); } catch (error) { published = false; } });
|
|
259
|
+
try { revalidate(); } catch (error) { return { status: 'failed', persisted: true, dismissedIds: ids, error: error.message, retrySafe: false }; }
|
|
260
|
+
return { status: published ? 'completed' : 'failed', persisted: true, dismissedIds: ids, viewerPublication: published ? 'sent' : 'partial', retrySafe: false };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function dismissAll(ws) {
|
|
264
|
+
dismiss(visible(ws).map(function (notification) { return notification.id; }), ws);
|
|
218
265
|
}
|
|
219
266
|
|
|
220
267
|
// --- Periodic reminder ---
|
|
@@ -222,8 +269,15 @@ function attachNotifications(ctx) {
|
|
|
222
269
|
function startReminder() {
|
|
223
270
|
if (reminderTimer) return;
|
|
224
271
|
reminderTimer = setInterval(function () {
|
|
272
|
+
if (ctx.canView && ctx.getUsers && pushModule && pushModule.sendPushToUser) {
|
|
273
|
+
ctx.getUsers().forEach(function (user) {
|
|
274
|
+
var count = visible({ _clayUser: user }).length;
|
|
275
|
+
if (count) pushModule.sendPushToUser(user.id, { type: "reminder", title: "Clay", body: count + " unread notification" + (count > 1 ? "s" : ""), tag: "clay-notif-reminder" });
|
|
276
|
+
});
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
225
279
|
var count = getUnreadCount();
|
|
226
|
-
if (count > 0 && pushModule) {
|
|
280
|
+
if (count > 0 && pushModule && !ctx.canView) {
|
|
227
281
|
pushModule.sendPush({
|
|
228
282
|
type: "reminder",
|
|
229
283
|
title: "Clay",
|
|
@@ -244,10 +298,11 @@ function attachNotifications(ctx) {
|
|
|
244
298
|
|
|
245
299
|
function sendConnectionState(ws, sendTo) {
|
|
246
300
|
if (!sendTo) return;
|
|
301
|
+
var list = visible(ws);
|
|
247
302
|
sendTo(ws, {
|
|
248
303
|
type: "notifications_state",
|
|
249
|
-
notifications:
|
|
250
|
-
unreadCount:
|
|
304
|
+
notifications: list,
|
|
305
|
+
unreadCount: list.length,
|
|
251
306
|
});
|
|
252
307
|
}
|
|
253
308
|
|
|
@@ -255,17 +310,21 @@ function attachNotifications(ctx) {
|
|
|
255
310
|
|
|
256
311
|
function handleNotificationMessage(ws, msg) {
|
|
257
312
|
if (msg.type === "notification_dismiss") {
|
|
258
|
-
dismiss(msg.ids || []);
|
|
313
|
+
dismiss(msg.ids || [], ws);
|
|
259
314
|
return true;
|
|
260
315
|
}
|
|
261
316
|
if (msg.type === "notification_dismiss_all") {
|
|
262
|
-
dismissAll();
|
|
317
|
+
dismissAll(ws);
|
|
263
318
|
return true;
|
|
264
319
|
}
|
|
265
320
|
return false;
|
|
266
321
|
}
|
|
267
322
|
|
|
268
323
|
return {
|
|
324
|
+
authorizeOwned: authorizeOwned,
|
|
325
|
+
listOwned: listOwned,
|
|
326
|
+
inspectOwned: inspectOwned,
|
|
327
|
+
dismissOwned: dismissOwned,
|
|
269
328
|
notify: notify,
|
|
270
329
|
getUnreadCount: getUnreadCount,
|
|
271
330
|
sendConnectionState: sendConnectionState,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Ownership recovery changes project metadata only; session owners stay intact.
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
var path = require("path");
|
|
4
|
+
|
|
5
|
+
function isPersonal(project) {
|
|
6
|
+
return project.isMate === true || /^mate-/.test(project.slug || "");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function verifiedPrivateOwner(project, accounts, resolveIdentity) {
|
|
10
|
+
var root;
|
|
11
|
+
var stat;
|
|
12
|
+
try {
|
|
13
|
+
root = fs.realpathSync(project.path);
|
|
14
|
+
if (root !== path.resolve(project.path)) return null;
|
|
15
|
+
stat = fs.statSync(root);
|
|
16
|
+
} catch (e) { return null; }
|
|
17
|
+
var matches = [];
|
|
18
|
+
var identities = [];
|
|
19
|
+
for (var i = 0; i < accounts.length; i++) {
|
|
20
|
+
var account = accounts[i];
|
|
21
|
+
if (!account.linuxUser) continue;
|
|
22
|
+
try {
|
|
23
|
+
var identity = resolveIdentity(account.linuxUser);
|
|
24
|
+
var home = fs.realpathSync(identity.home);
|
|
25
|
+
if (!Number.isInteger(identity.uid) || identity.uid < 0 || fs.statSync(home).uid !== identity.uid || home !== path.resolve(identity.home) || home === path.parse(home).root) continue;
|
|
26
|
+
identities.push({ account: account, uid: identity.uid, home: home });
|
|
27
|
+
} catch (e) { return null; }
|
|
28
|
+
}
|
|
29
|
+
for (var j = 0; j < identities.length; j++) {
|
|
30
|
+
var candidate = identities[j];
|
|
31
|
+
var relative = path.relative(candidate.home, root);
|
|
32
|
+
if (candidate.uid !== stat.uid || relative === ".." || relative.indexOf(".." + path.sep) === 0 || path.isAbsolute(relative)) continue;
|
|
33
|
+
// A shared UID or overlapping home is never authoritative evidence.
|
|
34
|
+
var ambiguous = identities.some(function (other) {
|
|
35
|
+
if (other === candidate) return false;
|
|
36
|
+
var overlap = path.relative(other.home, root);
|
|
37
|
+
return other.uid === candidate.uid || (!path.isAbsolute(overlap) && overlap !== ".." && overlap.indexOf(".." + path.sep) !== 0);
|
|
38
|
+
});
|
|
39
|
+
if (!ambiguous) matches.push(candidate.account.id);
|
|
40
|
+
}
|
|
41
|
+
return matches.length === 1 ? matches[0] : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function repair(config, accounts, persist, resolveIdentity) {
|
|
45
|
+
var next = JSON.parse(JSON.stringify(config));
|
|
46
|
+
var valid = Object.create(null);
|
|
47
|
+
accounts.forEach(function (user) { if (typeof user.id === "string" && user.id) valid[user.id] = user; });
|
|
48
|
+
if (!accounts.length) return config; // Pre-account setup is repaired after bootstrap.
|
|
49
|
+
var admins = accounts.filter(function (user) { return user.role === "admin" && valid[user.id]; }).sort(function (a, b) { return a.id.localeCompare(b.id); });
|
|
50
|
+
var preferred = next.ownershipRecoveryAdminId || next.singleUserMigratedUserId;
|
|
51
|
+
var designated = valid[preferred] && valid[preferred].role === "admin" ? preferred : (admins[0] && admins[0].id);
|
|
52
|
+
if (designated) next.ownershipRecoveryAdminId = designated;
|
|
53
|
+
(next.projects || []).forEach(function (project) {
|
|
54
|
+
if (isPersonal(project) || project.slug.indexOf("--") !== -1) return;
|
|
55
|
+
if (valid[project.ownerId]) { delete project.ownershipRecovery; return; }
|
|
56
|
+
var visibility = project.visibility || (next.osUsers ? "private" : "public");
|
|
57
|
+
var recovered = visibility === "public" ? designated : verifiedPrivateOwner(project, accounts, resolveIdentity);
|
|
58
|
+
if (recovered) {
|
|
59
|
+
project.ownerId = recovered;
|
|
60
|
+
delete project.ownershipRecovery;
|
|
61
|
+
} else project.ownershipRecovery = "required";
|
|
62
|
+
});
|
|
63
|
+
if (JSON.stringify(next) === JSON.stringify(config)) return config;
|
|
64
|
+
persist(next); // Publish only after atomic persistence succeeds; failures abort boot.
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function register(config, project, accounts, persist, resolveIdentity) {
|
|
69
|
+
var next = JSON.parse(JSON.stringify(config));
|
|
70
|
+
if (!next.projects) next.projects = [];
|
|
71
|
+
next.projects.push(project);
|
|
72
|
+
next = repair(next, accounts, function () {}, resolveIdentity);
|
|
73
|
+
persist(next);
|
|
74
|
+
return next;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { repair: repair, register: register, verifiedPrivateOwner: verifiedPrivateOwner, isPersonal: isPersonal };
|
|
@@ -113,15 +113,26 @@ function attachPairResultDelivery(ctx) {
|
|
|
113
113
|
if (sdk.pushMessage(caller, message) === true) {
|
|
114
114
|
return accepted(caller, partner, token, attemptId);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
// The production bridge clears a stale input on false. Resume in this
|
|
117
|
+
// attempt instead of spending the bounded retries on a dead handle.
|
|
118
|
+
if (caller.queryInstance || caller._queryStarting) return retry(caller, partner, token, attemptId, "Driver query rejected the result");
|
|
117
119
|
}
|
|
118
120
|
token._deliveryStartupAttemptId = attemptId;
|
|
119
121
|
var beforePush = function () { return token._deliveryStartupAttemptId === attemptId && currentAttempt(caller, partner, token, attemptId); };
|
|
120
122
|
var onAccepted = function () { accepted(caller, partner, token, attemptId); };
|
|
121
123
|
var timeoutMs = Number(ctx.acceptanceTimeoutMs || DEFAULT_ACCEPTANCE_TIMEOUT_MS);
|
|
122
|
-
|
|
124
|
+
function acceptanceTimeout() {
|
|
125
|
+
if (!currentAttempt(caller, partner, token, attemptId)) return;
|
|
126
|
+
// A known, cancellable provider admission wait has not sent input.
|
|
127
|
+
// Keep the correlated completion eligible until admission or Stop.
|
|
128
|
+
if (caller._queryStarting && Number(caller._providerRecoveryWaiting) > 0
|
|
129
|
+
&& caller._providerRecoveryWaiting === caller._sdkQueryGeneration) {
|
|
130
|
+
token._deliveryTimer = { attemptId: attemptId, timer: setTimeout(acceptanceTimeout, timeoutMs) };
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
123
133
|
uncertain(caller, partner, token, attemptId, "delivery acceptance timed out");
|
|
124
|
-
}
|
|
134
|
+
}
|
|
135
|
+
token._deliveryTimer = { attemptId: attemptId, timer: setTimeout(acceptanceTimeout, timeoutMs) };
|
|
125
136
|
var startup = sdk.startQuery(caller, message, undefined, ctx.getLinuxUserForSession(caller), beforePush, onAccepted);
|
|
126
137
|
Promise.resolve(startup).then(function (result) {
|
|
127
138
|
if (!currentAttempt(caller, partner, token, attemptId)) return;
|
|
@@ -16,16 +16,14 @@ function contextStatus(session) {
|
|
|
16
16
|
var used = null;
|
|
17
17
|
var window = null;
|
|
18
18
|
var source = "unavailable";
|
|
19
|
+
var measurement = "unavailable";
|
|
19
20
|
if (snapshot && typeof snapshot === "object") {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
window = firstNumber(snapshot.contextWindow);
|
|
27
|
-
if (used !== null || window !== null) source = "adapter_context_usage";
|
|
28
|
-
}
|
|
21
|
+
var current = require("./yoke/usage").context(snapshot, session.vendor || "claude").context;
|
|
22
|
+
measurement = current.measurement;
|
|
23
|
+
used = firstNumber(current.usedTokens);
|
|
24
|
+
window = firstNumber(current.windowTokens);
|
|
25
|
+
if (used !== null || window !== null) source = current.source;
|
|
26
|
+
|
|
29
27
|
}
|
|
30
28
|
var history = session.history || [];
|
|
31
29
|
var cumulativeInput = 0;
|
|
@@ -46,9 +44,9 @@ function contextStatus(session) {
|
|
|
46
44
|
if (typeof item._ts === "number") lastCompactionAt = item._ts;
|
|
47
45
|
}
|
|
48
46
|
if (item.type !== "result") continue;
|
|
49
|
-
var usage = item.usage || {};
|
|
50
|
-
var input = firstNumber(usage.
|
|
51
|
-
var output = firstNumber(usage.
|
|
47
|
+
var usage = require("./yoke/usage").accounting(item.usage) || {};
|
|
48
|
+
var input = firstNumber(usage.inputTokens);
|
|
49
|
+
var output = firstNumber(usage.outputTokens);
|
|
52
50
|
if (input !== null) { cumulativeInput += input; observedInput = true; }
|
|
53
51
|
if (output !== null) { cumulativeOutput += output; observedOutput = true; }
|
|
54
52
|
results++;
|
|
@@ -59,13 +57,14 @@ function contextStatus(session) {
|
|
|
59
57
|
if (used !== null && window !== null && used > window) {
|
|
60
58
|
used = null;
|
|
61
59
|
source = "unavailable";
|
|
60
|
+
measurement = "unavailable";
|
|
62
61
|
}
|
|
63
62
|
// Older result records contain lastStreamInputTokens, but that field was
|
|
64
63
|
// populated from adapter snapshots that could be cumulative or inflated by
|
|
65
64
|
// cache accounting. It is not safe evidence of current context occupancy.
|
|
66
65
|
var ratio = used !== null && window !== null && window > 0 ? Math.min(1, Math.round((used / window) * 1000) / 1000) : null;
|
|
67
66
|
return {
|
|
68
|
-
current: { source: source, usedTokens: used, windowTokens: window, usedRatio: ratio,
|
|
67
|
+
current: { source: source, measurement: measurement, usedTokens: used, windowTokens: window, usedRatio: ratio,
|
|
69
68
|
scope: used === null && window === null ? "unknown" : (used !== null && window !== null ? "current_context" : "partial_current_context") },
|
|
70
69
|
cumulative: { inputTokens: observedInput ? cumulativeInput : null, outputTokens: observedOutput ? cumulativeOutput : null, tasksObserved: results, scope: "loaded_session_history", complete: false },
|
|
71
70
|
lastTask: lastTask,
|
|
@@ -141,6 +141,7 @@ function createPendingMessageQueue(opts) {
|
|
|
141
141
|
delete item.message._scheduledJobId;
|
|
142
142
|
delete item.message._scheduledRevision;
|
|
143
143
|
delete item.message._scheduledNotBefore;
|
|
144
|
+
if (session._pendingMessageDrainPaused || session.taskStopRequested) data.paused[targetKey(session)] = true;
|
|
144
145
|
data.items.push(item);
|
|
145
146
|
data.revision++;
|
|
146
147
|
try { persist(); } catch (e) { restore(before); return result(false, "Queue storage failed", session, actor); }
|
|
@@ -248,7 +249,8 @@ function createPendingMessageQueue(opts) {
|
|
|
248
249
|
return true;
|
|
249
250
|
}
|
|
250
251
|
function consumeOne(session, dispatch) {
|
|
251
|
-
|
|
252
|
+
var foreground = require('./sdk-foreground-admission');
|
|
253
|
+
if (loadError || !session || session._pendingMessageClaimId || isPaused(session) || session._pendingMessageDrainPaused || session.taskStopRequested || session._queryStarting || (session._awaitingTurnResult || session.isProcessing) && !foreground.available(session)) return null;
|
|
252
254
|
if (session.rateLimitResetsAt && session.rateLimitResetsAt > Date.now()) return null;
|
|
253
255
|
for (var i = 0; i < data.items.length; i++) {
|
|
254
256
|
var item = data.items[i];
|
|
@@ -261,6 +263,7 @@ function createPendingMessageQueue(opts) {
|
|
|
261
263
|
data.revision++;
|
|
262
264
|
try { persist(); } catch (e) { restore(before); return null; }
|
|
263
265
|
session._pendingMessageClaimId = item.id;
|
|
266
|
+
foreground.take(session);
|
|
264
267
|
broadcast(session, { type: "pending_message_claimed", sessionId: session.localId, projectSlug: opts.slug, paused: isPaused(session), id: item.id, revision: data.revision });
|
|
265
268
|
var completed = false;
|
|
266
269
|
function complete(ok, error) { if (completed) return false; completed = true; return finishClaim(session, item.id, ok, error); }
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var userInput = require("./yoke/user-input");
|
|
2
|
+
var provenance = require("./session-provenance");
|
|
3
|
+
var deletion = require("./project-session-delete");
|
|
4
|
+
function attachProjectProductControl(ctx) {
|
|
5
|
+
var queues = require("./project-product-session-queue").attachProductSessionQueue({ queue: ctx.queue, sm: ctx.sm, users: ctx.users, requestDrain: ctx.requestQueueDrain });
|
|
6
|
+
function inspectQueue(principal, session) {
|
|
7
|
+
owned(principal, session);
|
|
8
|
+
if (ctx.isMate || provenance.isWorker(session) || session.spawn || ctx.isDriverOperatedSession(session)) throw new Error("Queues are controlled through their project Driver.");
|
|
9
|
+
return queues.inspect(principal, session);
|
|
10
|
+
}
|
|
11
|
+
function owned(principal, session) {
|
|
12
|
+
if (!session || ctx.sm.sessions.get(session.localId) !== session) throw new Error("Target session was deleted or replaced.");
|
|
13
|
+
if (ctx.users.isMultiUser()) {
|
|
14
|
+
var user = ctx.users.findUserById(principal.userId);
|
|
15
|
+
if (!user || session.ownerId !== user.id || !ctx.users.canAccessProject(user.id, ctx.getProjectAccess())) throw new Error("Live target ownership or access denied.");
|
|
16
|
+
return user;
|
|
17
|
+
}
|
|
18
|
+
if (session.ownerId && session.ownerId !== principal.singleUserOwnerId) throw new Error("Live target ownership denied.");
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function review(session, question, revalidate, presentation) {
|
|
22
|
+
var owner = session.ownerId || null;
|
|
23
|
+
return userInput.dispatchUserInput(function (request, respond) {
|
|
24
|
+
// Presentation comes only from the bound product service, after normalization.
|
|
25
|
+
if (presentation) request.questions[0].review = presentation;
|
|
26
|
+
request.authorizeResponse = function (ws) {
|
|
27
|
+
try {
|
|
28
|
+
revalidate();
|
|
29
|
+
if (ctx.users.isMultiUser() && (!ws || !ws._clayUser || ws._clayUser.id !== owner || !ctx.users.findUserById(owner))) return false;
|
|
30
|
+
var tap = ws && ws._homeChatTap;
|
|
31
|
+
return !!ws && ((ctx.clients.has(ws) && ws._clayActiveSession === session.localId) || (tap && tap.mateSlug === ctx.slug && tap.sessionId === session.localId));
|
|
32
|
+
} catch (error) { return false; }
|
|
33
|
+
};
|
|
34
|
+
ctx.userInput(session)(request, respond);
|
|
35
|
+
}, { questions: [{ id: "control", header: "Review change", question: question, options: [{ label: "Keep unchanged" }, { label: "Apply exact change" }], allowOther: false }] }, { source: "product-control", signal: session.abortController && session.abortController.signal });
|
|
36
|
+
}
|
|
37
|
+
async function apply(principal, session, action, value, revalidate, control) {
|
|
38
|
+
var user = owned(principal, session);
|
|
39
|
+
function current() {
|
|
40
|
+
owned(principal, session);
|
|
41
|
+
if (typeof revalidate !== "function") throw new Error("An exact product control revision is required.");
|
|
42
|
+
revalidate();
|
|
43
|
+
}
|
|
44
|
+
current();
|
|
45
|
+
if (ctx.isMate || provenance.isWorker(session) || session.spawn || ctx.isDriverOperatedSession(session)) throw new Error("This target is not a project Driver.");
|
|
46
|
+
if (action.indexOf("queue_") === 0) return queues.apply(principal, session, control.args, current, control.requestKey);
|
|
47
|
+
if (action === "vendor") return ctx.vendor.setVendor(session, value, current);
|
|
48
|
+
if (action === "vendor_new_session") return ctx.vendor.newSession(session, value, current);
|
|
49
|
+
if (action === "runtime") return ctx.runtime.change(session, value, current);
|
|
50
|
+
if (action === "rename") return ctx.actions.rename(session, value);
|
|
51
|
+
if (action === "stop") return ctx.actions.stop(session, user);
|
|
52
|
+
if (session.taskStopRequested && action !== "delete") throw new Error("Target was stopped; explicit Driver resumption is required.");
|
|
53
|
+
if (action === "model") {
|
|
54
|
+
var models = (ctx.sm.modelsByVendor || {})[session.vendor || ctx.sm.defaultVendor || "claude"] || [];
|
|
55
|
+
if (!models.length) throw new Error("Provider model catalog is unavailable; no model was changed.");
|
|
56
|
+
var result = await ctx.selectModel(session, value, { revalidate: current });
|
|
57
|
+
if (!result) throw new Error("Model change failed.");
|
|
58
|
+
if (result.ok !== true && result.status !== "failed") throw new Error(result.error || "Model change failed.");
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
if (action === "effort") return ctx.actions.effort(session, value, current);
|
|
62
|
+
if (action === "permission") return ctx.actions.permission(session, value, null, current);
|
|
63
|
+
if (action === "fork" || action === "rewind") {
|
|
64
|
+
if (session.isProcessing || session._queryStarting || Object.keys(session.pendingPermissions || {}).length || Object.keys(session.pendingAskUser || {}).length) throw new Error("History changes require an idle Driver without pending approvals.");
|
|
65
|
+
if (!session.cliSessionId || !(session.messageUUIDs || []).some(function (entry) { return entry.uuid === value; })) throw new Error("Choose an exact recorded checkpoint from inspection.");
|
|
66
|
+
var vendor = session.vendor || ctx.sm.defaultVendor || "claude";
|
|
67
|
+
var caps = (ctx.sm.capabilitiesByVendor || {})[vendor] || {};
|
|
68
|
+
if (action === "fork" && !caps.fork || action === "rewind" && !caps.rollback && !caps.rewind) throw new Error("This provider does not support that history operation.");
|
|
69
|
+
if (action === "fork") {
|
|
70
|
+
var forked = await ctx.history.fork(session, value, null, revalidate);
|
|
71
|
+
if (!forked) throw new Error("The provider did not produce a forked session.");
|
|
72
|
+
return { forkedSessionRef: require("./workspace-query-service").sessionRef(ctx.slug, forked) };
|
|
73
|
+
}
|
|
74
|
+
return ctx.history.rewind(session, value, "chat", null, revalidate);
|
|
75
|
+
}
|
|
76
|
+
if (action === "delete") {
|
|
77
|
+
if (user && !ctx.users.getEffectivePermissions(user, ctx.osUsers).sessionDelete) throw new Error("You do not have permission to delete sessions.");
|
|
78
|
+
var plan = deletion.resolveDeletionScope(ctx.sm.sessions, [session], function (candidate) { return (candidate.ownerId || null) === (session.ownerId || null); });
|
|
79
|
+
if (!plan.ok) throw new Error(plan.error);
|
|
80
|
+
// A live Driver or Worker must be stopped and settled before deletion.
|
|
81
|
+
if (plan.ids.some(function (id) { var item = ctx.sm.sessions.get(id); return item.isProcessing || item._queryStarting; })) throw new Error("Stop the Driver and its Workers and wait for completion before deleting them.");
|
|
82
|
+
ctx.deletePlan(plan);
|
|
83
|
+
return { deletedCount: plan.ids.length };
|
|
84
|
+
}
|
|
85
|
+
throw new Error("Unsupported product control action.");
|
|
86
|
+
}
|
|
87
|
+
return { requestProductControlReview: review, applyProductSessionAction: apply, inspectProductSessionQueue: inspectQueue };
|
|
88
|
+
}
|
|
89
|
+
module.exports = { attachProjectProductControl: attachProjectProductControl };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var crypto = require('crypto');
|
|
2
|
+
function attachProductSessionQueue(ctx) {
|
|
3
|
+
var queue = ctx.queue;
|
|
4
|
+
function actor(principal) {
|
|
5
|
+
if (!ctx.users.isMultiUser()) return null;
|
|
6
|
+
var user = ctx.users.findUserById(principal.userId);
|
|
7
|
+
if (!user) throw new Error('Queue owner is no longer available.');
|
|
8
|
+
return user;
|
|
9
|
+
}
|
|
10
|
+
function inspect(principal, session) {
|
|
11
|
+
var user = actor(principal), state = queue.hydrate(session, user);
|
|
12
|
+
if (!state.ok) throw new Error(state.error || 'Queue inspection failed.');
|
|
13
|
+
return { revision: state.revision, paused: state.paused || !!session._pendingMessageDrainPaused || !!session.taskStopRequested,
|
|
14
|
+
items: state.items.filter(function (item) { return item.actorId === (user ? user.id : 'default'); }).filter(function (item, index, all) { return item.state === 'pending' || item.state === 'claimed' || index >= all.length - 20; }).map(function (item) {
|
|
15
|
+
return { id: item.id, state: item.state, text: String(item.message.text || '').slice(0, 1600), textTruncated: String(item.message.text || '').length > 1600,
|
|
16
|
+
imageCount: (item.message.images || []).length, pasteCount: (item.message.pastes || []).length, scheduled: !!item.schedule, failure: item.failure ? String(item.failure).slice(0, 500) : null };
|
|
17
|
+
}) };
|
|
18
|
+
}
|
|
19
|
+
function apply(principal, session, args, revalidate, requestKey) {
|
|
20
|
+
revalidate();
|
|
21
|
+
var user = actor(principal), before = queue.getRevision(), result;
|
|
22
|
+
try {
|
|
23
|
+
if (args.action === 'queue_add') {
|
|
24
|
+
var clientId = 'clay-control:' + crypto.createHash('sha256').update(requestKey).digest('hex');
|
|
25
|
+
var existing = queue.inspect(session, user, clientId);
|
|
26
|
+
var digest = crypto.createHash('sha256').update(args.text).digest('hex');
|
|
27
|
+
if (existing && (existing.message._clayControlDigest || crypto.createHash('sha256').update(existing.message.text).digest('hex')) !== digest) throw new Error('This requestId already identifies a different durable queue message.');
|
|
28
|
+
result = queue.admit(session, { type: 'message', text: args.text, clientMessageId: clientId, _clayControlDigest: digest }, user);
|
|
29
|
+
} else if (args.action === 'queue_edit') result = queue.edit(session, user, args.messageId, before, session.localId, { text: args.text });
|
|
30
|
+
else if (args.action === 'queue_cancel') result = queue.cancel(session, user, args.messageId, before, session.localId);
|
|
31
|
+
else if (args.action === 'queue_reorder') result = queue.reorder(session, user, args.ids, before, session.localId);
|
|
32
|
+
else throw new Error('Unsupported queue action.');
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return { status: 'failed', outcome: queue.getRevision() !== before ? 'partial' : 'failed', persisted: queue.getRevision() !== before, error: error.message, queue: inspect(principal, session) };
|
|
35
|
+
}
|
|
36
|
+
if (!result || !result.ok) return { status: 'failed', persisted: false, error: result && result.error || 'Queue operation failed.', messageId: result && result.item && result.item.id, deliveryState: result && result.item && result.item.state, queue: inspect(principal, session) };
|
|
37
|
+
var state = inspect(principal, session);
|
|
38
|
+
if (args.action === 'queue_add') {
|
|
39
|
+
if (result.item && result.item.state === 'pending' && !state.paused) setImmediate(function () { if (ctx.sm.sessions.get(session.localId) === session) ctx.requestDrain(session); });
|
|
40
|
+
return { status: result.item && result.item.state === 'consumed' ? 'completed' : 'queued', persisted: true, messageId: result.item && result.item.id, deliveryState: result.item && result.item.state, queue: state };
|
|
41
|
+
}
|
|
42
|
+
return { status: 'completed', persisted: true, queue: state };
|
|
43
|
+
}
|
|
44
|
+
return { inspect: inspect, apply: apply };
|
|
45
|
+
}
|
|
46
|
+
module.exports = { attachProductSessionQueue: attachProductSessionQueue };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Project push payloads carry session content and use the same live authority
|
|
2
|
+
// as HTTP and WebSocket snapshots. Unscoped account/system pushes stay separate.
|
|
3
|
+
function scopedPush(push, ctx) {
|
|
4
|
+
if (!push) return null;
|
|
5
|
+
function permitted(userId, payload) {
|
|
6
|
+
var data = payload.data || payload;
|
|
7
|
+
var slug = data.slug || ctx.slug;
|
|
8
|
+
var project = ctx.getProject(slug);
|
|
9
|
+
if (!project || !data.sessionId || !ctx.canAccessProject(userId, slug)) return false;
|
|
10
|
+
var session = project.getSessionManager().sessions.get(data.sessionId);
|
|
11
|
+
var status = project.getStatus();
|
|
12
|
+
var access = status.isMate ? { isMate: true, visibility: "private", ownerId: status.projectOwnerId } : ctx.getAccess(slug);
|
|
13
|
+
return !!session && ctx.users.canAccessSession(userId, session, access);
|
|
14
|
+
}
|
|
15
|
+
return Object.assign({}, push, {
|
|
16
|
+
sendPush: function (payload) {
|
|
17
|
+
if (!ctx.users.isMultiUser()) return push.sendPush(payload);
|
|
18
|
+
if (!push.sendPushToUser) return;
|
|
19
|
+
ctx.users.getAllUsers().forEach(function (user) {
|
|
20
|
+
if (permitted(user.id, payload)) push.sendPushToUser(user.id, payload);
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
sendPushToUser: function (userId, payload) {
|
|
24
|
+
if ((!ctx.users.isMultiUser() || permitted(userId, payload)) && push.sendPushToUser) push.sendPushToUser(userId, payload);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
module.exports = { scopedPush: scopedPush };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function attachScheduledMessageQueue(ctx) {
|
|
2
|
+
var users = ctx.users;
|
|
3
|
+
var pendingMessageQueue = ctx.pendingMessageQueue;
|
|
4
|
+
function queueActor(actorId) {
|
|
5
|
+
return users.isMultiUser() ? users.findUserById(actorId) : { id: "default" };
|
|
6
|
+
}
|
|
7
|
+
function queueItemForJob(session, job, actorId) {
|
|
8
|
+
if (!pendingMessageQueue || !session || !job) return null;
|
|
9
|
+
var actor = queueActor(actorId || (job.payload && job.payload.actorId));
|
|
10
|
+
var items = pendingMessageQueue.list(session, actor);
|
|
11
|
+
for (var i = 0; i < items.length; i++) {
|
|
12
|
+
if (items[i].schedule && items[i].schedule.jobId === job.id && items[i].schedule.revision === job.payload.revision) return items[i];
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function validateQueueControl(session, job, actorId, correlation, requireQueueRevision) {
|
|
17
|
+
if (!pendingMessageQueue) return null;
|
|
18
|
+
if (requireQueueRevision && (!correlation || correlation.queueRevision == null || Number(correlation.queueRevision) !== pendingMessageQueue.getRevision())) {
|
|
19
|
+
throw new Error("The scheduled-message queue is stale.");
|
|
20
|
+
}
|
|
21
|
+
var actor = queueActor(actorId || (job.payload && job.payload.actorId));
|
|
22
|
+
var item = queueItemForJob(session, job, actorId);
|
|
23
|
+
if (!item || item.actorId !== actor.id || ["cancelled", "consumed", "failed"].indexOf(item.state) >= 0) {
|
|
24
|
+
throw new Error("The scheduled queue item is no longer available.");
|
|
25
|
+
}
|
|
26
|
+
return item;
|
|
27
|
+
}
|
|
28
|
+
return { actor: queueActor, item: queueItemForJob, validate: validateQueueControl };
|
|
29
|
+
}
|
|
30
|
+
module.exports = { attachScheduledMessageQueue: attachScheduledMessageQueue };
|