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
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Claude delivery watchdog. Only an unanswered foreground turn is replayable.
|
|
2
|
+
function attachResponseRecovery(ctx) {
|
|
3
|
+
var states = new Map();
|
|
4
|
+
var schedule = ctx.setTimeout || setTimeout;
|
|
5
|
+
var unschedule = ctx.clearTimeout || clearTimeout;
|
|
6
|
+
var waitMs = ctx.waitMs || 180000;
|
|
7
|
+
var stopMs = ctx.stopMs || 10000;
|
|
8
|
+
|
|
9
|
+
function live(session, state) {
|
|
10
|
+
return (!ctx.isCurrentProvider || ctx.isCurrentProvider(session)) && states.get(session) === state && !session.destroying && !session.taskStopRequested
|
|
11
|
+
&& state.ownerId === session.ownerId && state.vendor === session.vendor
|
|
12
|
+
&& (!ctx.sessions || ctx.sessions.get(session.localId) === session);
|
|
13
|
+
}
|
|
14
|
+
function clearTimer(state) {
|
|
15
|
+
if (state.timer) unschedule(state.timer);
|
|
16
|
+
state.timer = null;
|
|
17
|
+
}
|
|
18
|
+
function cancel(session, expected) {
|
|
19
|
+
var state = states.get(session);
|
|
20
|
+
if (expected && state !== expected) return;
|
|
21
|
+
if (state) clearTimer(state);
|
|
22
|
+
states.delete(session);
|
|
23
|
+
}
|
|
24
|
+
function protectedWait(session) {
|
|
25
|
+
return [session.pendingPermissions, session.pendingAskUser, session.pendingElicitations,
|
|
26
|
+
session.pendingUserDialogs, session.activeTaskToolIds].some(function(map) {
|
|
27
|
+
return map && Object.keys(map).length > 0;
|
|
28
|
+
}) || (session.activeBackgroundTasks && session.activeBackgroundTasks.length > 0);
|
|
29
|
+
}
|
|
30
|
+
function arm(session, state) {
|
|
31
|
+
clearTimer(state);
|
|
32
|
+
if (!state.turns.length || state.turns[0].progress || state.stopping) return;
|
|
33
|
+
state.timer = schedule(function() { expire(session, state); }, waitMs);
|
|
34
|
+
if (state.timer && state.timer.unref) state.timer.unref();
|
|
35
|
+
}
|
|
36
|
+
function snapshot(payload) {
|
|
37
|
+
return Object.assign({}, payload, { images: payload.images ? JSON.parse(JSON.stringify(payload.images)) : payload.images });
|
|
38
|
+
}
|
|
39
|
+
function begin(session, payload, retryState) {
|
|
40
|
+
if (retryState) return retryState;
|
|
41
|
+
cancel(session);
|
|
42
|
+
var state = { turns: [snapshot(payload)], timer: null, stopping: false, retried: false, ownerId: session.ownerId, vendor: session.vendor };
|
|
43
|
+
states.set(session, state);
|
|
44
|
+
arm(session, state);
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
47
|
+
function enqueue(session, payload) {
|
|
48
|
+
var state = states.get(session);
|
|
49
|
+
if (!state) return begin(session, payload);
|
|
50
|
+
state.turns.push(snapshot(payload));
|
|
51
|
+
return state;
|
|
52
|
+
}
|
|
53
|
+
function progress(session) {
|
|
54
|
+
var state = states.get(session);
|
|
55
|
+
if (!state || state.stopping || !state.turns.length) return;
|
|
56
|
+
state.turns[0].progress = true;
|
|
57
|
+
clearTimer(state);
|
|
58
|
+
}
|
|
59
|
+
function event(session, msg) {
|
|
60
|
+
var state = states.get(session);
|
|
61
|
+
if (!state || state.stopping || !msg) return;
|
|
62
|
+
var type = msg.yokeType;
|
|
63
|
+
if (type === 'error' || type === 'interrupted') { cancel(session); return; }
|
|
64
|
+
if (type === 'result') {
|
|
65
|
+
if (msg.subtype === 'success' && !msg.is_error && msg.numTurns === 0
|
|
66
|
+
&& msg.origin && msg.origin.kind === 'task-notification'
|
|
67
|
+
&& !msg.localCommand && msg.resultText === '') return;
|
|
68
|
+
var remaining = require('../sdk-turn-queue').pendingSends(session, msg);
|
|
69
|
+
state.turns = remaining ? state.turns.slice(-remaining) : [];
|
|
70
|
+
state.retried = false;
|
|
71
|
+
arm(session, state);
|
|
72
|
+
if (!state.turns.length) cancel(session);
|
|
73
|
+
} else if ((type === 'text_delta' || type === 'thinking_delta') && (msg.text || msg.delta)
|
|
74
|
+
|| type === 'tool_start' || type === 'tool_input_delta' || type === 'tool_progress'
|
|
75
|
+
|| type === 'task_started' || type === 'task_progress' || type === 'subagent_message'
|
|
76
|
+
|| type === 'message' && msg.messageRole === 'assistant' && msg.content && msg.content.length) {
|
|
77
|
+
progress(session);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function finish(session, state, text) {
|
|
81
|
+
if (!live(session, state)) { cancel(session, state); return; }
|
|
82
|
+
cancel(session);
|
|
83
|
+
// Fence late output when a transport cannot confirm termination.
|
|
84
|
+
session._sdkQueryGeneration = Number(session._sdkQueryGeneration || 0) + 1;
|
|
85
|
+
session.isProcessing = false;
|
|
86
|
+
session._awaitingTurnResult = false;
|
|
87
|
+
session._queuedTurnCount = 0;
|
|
88
|
+
ctx.changed();
|
|
89
|
+
ctx.record(session, { type: 'thinking_stop' });
|
|
90
|
+
ctx.record(session, { type: 'error', text: text });
|
|
91
|
+
ctx.record(session, { type: 'done', code: 1 });
|
|
92
|
+
ctx.broadcast();
|
|
93
|
+
}
|
|
94
|
+
async function expire(session, state) {
|
|
95
|
+
clearTimer(state);
|
|
96
|
+
if (!live(session, state)) { cancel(session, state); return; }
|
|
97
|
+
// Never stop a known tool or a human decision because prose is absent.
|
|
98
|
+
if (protectedWait(session)) { progress(session); return; }
|
|
99
|
+
state.stopping = true;
|
|
100
|
+
ctx.record(session, { type: 'info', text: 'Claude has not responded for three minutes. Stopping this attempt safely before retrying.' });
|
|
101
|
+
var timeout;
|
|
102
|
+
var stopped = false;
|
|
103
|
+
try {
|
|
104
|
+
var stopAttempt = (async function() {
|
|
105
|
+
var handle = session.queryInstance || state.handle;
|
|
106
|
+
if (!handle && session.abortController) session.abortController.abort();
|
|
107
|
+
if (!handle && state.starting) await state.starting;
|
|
108
|
+
handle = handle || session.queryInstance || state.handle;
|
|
109
|
+
if (handle) {
|
|
110
|
+
if (typeof handle.stopAndWait !== 'function') return false;
|
|
111
|
+
await handle.stopAndWait();
|
|
112
|
+
if (session.streamPromise) await session.streamPromise;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
})();
|
|
116
|
+
session._responseRecoveryStopPending = stopAttempt;
|
|
117
|
+
stopAttempt.then(function(confirmed) {
|
|
118
|
+
if (confirmed && session._responseRecoveryStopPending === stopAttempt) session._responseRecoveryStopPending = null;
|
|
119
|
+
}, function() {});
|
|
120
|
+
stopped = await Promise.race([
|
|
121
|
+
stopAttempt,
|
|
122
|
+
new Promise(function(resolve) { timeout = schedule(function() { resolve(false); }, stopMs); }),
|
|
123
|
+
]);
|
|
124
|
+
} catch (e) { stopped = false; }
|
|
125
|
+
if (timeout) unschedule(timeout);
|
|
126
|
+
if (!live(session, state)) { cancel(session, state); return; }
|
|
127
|
+
if (!stopped) {
|
|
128
|
+
finish(session, state, 'Claude could not be confirmed stopped. Automatic retry was cancelled to avoid running your request twice. Check your Claude connection before trying again.');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (state.retried || state.turns.length !== 1) {
|
|
132
|
+
finish(session, state, state.retried
|
|
133
|
+
? 'Claude still has not responded after one automatic retry. Please send your message again or check your Claude connection.'
|
|
134
|
+
: 'Claude did not respond. Several messages were queued, so automatic replay was cancelled to avoid duplicating work. Please send the unanswered messages again.');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
state.retried = true;
|
|
138
|
+
state.stopping = false;
|
|
139
|
+
session.isProcessing = true;
|
|
140
|
+
ctx.changed();
|
|
141
|
+
ctx.record(session, { type: 'info', text: 'The previous attempt has stopped. Retrying your original message once.' });
|
|
142
|
+
ctx.send(session, { type: 'status', status: 'processing' });
|
|
143
|
+
arm(session, state);
|
|
144
|
+
var payload = state.turns[0];
|
|
145
|
+
await ctx.restart(session, payload, state);
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
begin: begin, enqueue: enqueue, event: event, progress: progress, cancel: cancel,
|
|
149
|
+
current: function(session) { return states.get(session); },
|
|
150
|
+
valid: live,
|
|
151
|
+
stopping: function(session) { var state = states.get(session); return !!(state && state.stopping); },
|
|
152
|
+
dispose: function() { states.forEach(function(state) { clearTimer(state); }); states.clear(); },
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
module.exports = { attachResponseRecovery: attachResponseRecovery };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var CLAUDE_INTERRUPTED_TEXT = "[Request interrupted by user]";
|
|
2
|
+
function extractClaudeUserText(event) {
|
|
3
|
+
var content = event && event.message && event.message.content;
|
|
4
|
+
if (typeof content === "string") return content;
|
|
5
|
+
if (!Array.isArray(content)) return "";
|
|
6
|
+
var parts = [];
|
|
7
|
+
for (var i = 0; i < content.length; i++) {
|
|
8
|
+
if (content[i] && content[i].type === "text" && typeof content[i].text === "string") {
|
|
9
|
+
parts.push(content[i].text);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return parts.join("");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// SDK capability probes create a real Claude transcript with a single "hi"
|
|
16
|
+
// prompt. Newer Claude Code versions append an interruption record when Clay
|
|
17
|
+
// aborts the probe, so that bookkeeping record must not make the transcript
|
|
18
|
+
// look like a real two-turn conversation.
|
|
19
|
+
function isClaudeWarmupTranscript(events) {
|
|
20
|
+
var promptCount = 0;
|
|
21
|
+
for (var i = 0; i < events.length; i++) {
|
|
22
|
+
var event = events[i];
|
|
23
|
+
if (!event || typeof event !== "object") continue;
|
|
24
|
+
if (event.type === "assistant") return false;
|
|
25
|
+
if (event.type !== "user" || !event.message || event.message.role !== "user") continue;
|
|
26
|
+
var text = extractClaudeUserText(event);
|
|
27
|
+
if (text === CLAUDE_INTERRUPTED_TEXT) continue;
|
|
28
|
+
if (text !== "hi") return false;
|
|
29
|
+
promptCount++;
|
|
30
|
+
}
|
|
31
|
+
return promptCount === 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = { extractClaudeUserText: extractClaudeUserText, isClaudeWarmupTranscript: isClaudeWarmupTranscript };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// A transport error must settle startup even before a query iterator exists.
|
|
2
|
+
function attachWorkerStartup(worker, options) {
|
|
3
|
+
options = options || {};
|
|
4
|
+
var schedule = options.setTimeout || setTimeout;
|
|
5
|
+
var cancel = options.clearTimeout || clearTimeout;
|
|
6
|
+
var timer;
|
|
7
|
+
var settled = false;
|
|
8
|
+
worker.readyPromise = new Promise(function(resolve, reject) {
|
|
9
|
+
worker._readyResolve = function() { settle(null, resolve, reject); };
|
|
10
|
+
worker._readyReject = function(error) { settle(error, resolve, reject); };
|
|
11
|
+
});
|
|
12
|
+
// Warmup and cancellation may abandon startup before their await is installed.
|
|
13
|
+
worker.readyPromise.catch(function() {});
|
|
14
|
+
function settle(error, resolve, reject) {
|
|
15
|
+
if (settled) return;
|
|
16
|
+
settled = true;
|
|
17
|
+
if (timer) cancel(timer);
|
|
18
|
+
worker._readyResolve = null;
|
|
19
|
+
worker._readyReject = null;
|
|
20
|
+
if (error) reject(error); else resolve();
|
|
21
|
+
}
|
|
22
|
+
timer = schedule(function() {
|
|
23
|
+
if (worker._readyReject) worker._readyReject(new Error("Claude worker did not become ready before the startup deadline."));
|
|
24
|
+
if (typeof worker.kill === "function") worker.kill();
|
|
25
|
+
}, options.timeoutMs || 180000);
|
|
26
|
+
if (timer && typeof timer.unref === "function") timer.unref();
|
|
27
|
+
}
|
|
28
|
+
module.exports = { attachWorkerStartup: attachWorkerStartup };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Runs under the requesting OS identity. The installer only sees a private staging project.
|
|
2
|
+
var fs = require('fs');
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var spawn = require('child_process').spawn;
|
|
5
|
+
var storage = require('../clay-skill-storage');
|
|
6
|
+
var base = process.argv[2];
|
|
7
|
+
var name = process.argv[3];
|
|
8
|
+
var url = process.argv[4];
|
|
9
|
+
if (!storage.isClaySkill(name) || !/^https:\/\//i.test(url)) throw new Error('Invalid Clay skill install request');
|
|
10
|
+
storage.directory(path.join(base, '.clay'));
|
|
11
|
+
var stage = fs.mkdtempSync(path.join(base, '.clay', 'skill-install-'));
|
|
12
|
+
var child = spawn(process.platform === 'win32' ? 'npx.cmd' : 'npx', ['skills', 'add', url, '--skill', name, '--yes', '--agent', 'claude-code'], { cwd: stage, stdio: 'inherit', env: process.env });
|
|
13
|
+
function cleanup() { fs.rmSync(stage, { recursive: true, force: true }); }
|
|
14
|
+
child.on('error', function (error) { console.error(error.message); cleanup(); process.exitCode = 1; });
|
|
15
|
+
process.on('SIGTERM', function () { child.kill('SIGTERM'); });
|
|
16
|
+
child.on('close', function (code) {
|
|
17
|
+
try {
|
|
18
|
+
if (code !== 0) throw new Error('Skill installer exited with code ' + code);
|
|
19
|
+
var candidates = ['.agents', '.claude'].map(function (vendor) { return path.join(stage, vendor, 'skills', name); });
|
|
20
|
+
var source = candidates.find(function (dir) { return fs.existsSync(path.join(dir, 'SKILL.md')); });
|
|
21
|
+
if (!source) throw new Error('Installer did not create the requested skill in the private staging project');
|
|
22
|
+
var root = storage.privateRoot(base); storage.directory(root);
|
|
23
|
+
var destination = path.join(root, name);
|
|
24
|
+
var pending = path.join(root, '.' + name + '-' + process.pid);
|
|
25
|
+
fs.cpSync(source, pending, { recursive: true, dereference: true });
|
|
26
|
+
if (fs.existsSync(destination)) {
|
|
27
|
+
var backups = path.join(base, '.clay', 'skill-backups'); storage.directory(backups);
|
|
28
|
+
fs.renameSync(destination, path.join(backups, name + '-' + Date.now()));
|
|
29
|
+
}
|
|
30
|
+
fs.renameSync(pending, destination);
|
|
31
|
+
} catch (error) { console.error(error.message); process.exitCode = 1; }
|
|
32
|
+
finally { cleanup(); }
|
|
33
|
+
});
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
var fs = require("fs");
|
|
2
|
+
var path = require("path");
|
|
3
|
+
var readline = require("readline");
|
|
4
|
+
var utils = require("../utils");
|
|
5
|
+
var { REAL_HOME } = require("../config");
|
|
6
|
+
|
|
7
|
+
var encodeCwd = utils.encodeCwd;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parse the first ~20 lines of a CLI session JSONL file to extract metadata.
|
|
11
|
+
* Returns null if the file can't be parsed or has no user messages.
|
|
12
|
+
*/
|
|
13
|
+
function parseSessionFile(filePath, maxLines) {
|
|
14
|
+
if (maxLines == null) maxLines = 20;
|
|
15
|
+
return new Promise(function (resolve) {
|
|
16
|
+
var sessionId = path.basename(filePath, ".jsonl");
|
|
17
|
+
var result = {
|
|
18
|
+
sessionId: sessionId,
|
|
19
|
+
firstPrompt: "",
|
|
20
|
+
model: null,
|
|
21
|
+
gitBranch: null,
|
|
22
|
+
startTime: null,
|
|
23
|
+
lastActivity: null,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var lineCount = 0;
|
|
27
|
+
var foundUser = false;
|
|
28
|
+
var stream;
|
|
29
|
+
try {
|
|
30
|
+
stream = fs.createReadStream(filePath, { encoding: "utf8" });
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return resolve(null);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
36
|
+
|
|
37
|
+
rl.on("line", function (line) {
|
|
38
|
+
lineCount++;
|
|
39
|
+
if (lineCount > maxLines) {
|
|
40
|
+
rl.close();
|
|
41
|
+
stream.destroy();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var obj;
|
|
46
|
+
try { obj = JSON.parse(line); } catch (e) { return; }
|
|
47
|
+
|
|
48
|
+
// Skip file-history-snapshot, queue-operation, and other non-message records
|
|
49
|
+
if (obj.type === "user" && obj.message && obj.message.role === "user") {
|
|
50
|
+
if (!foundUser) {
|
|
51
|
+
foundUser = true;
|
|
52
|
+
result.sessionId = obj.sessionId || sessionId;
|
|
53
|
+
result.gitBranch = obj.gitBranch || null;
|
|
54
|
+
if (obj.timestamp) result.startTime = obj.timestamp;
|
|
55
|
+
var content = obj.message.content || "";
|
|
56
|
+
if (typeof content === "string") {
|
|
57
|
+
result.firstPrompt = content.substring(0, 100);
|
|
58
|
+
} else if (Array.isArray(content)) {
|
|
59
|
+
for (var i = 0; i < content.length; i++) {
|
|
60
|
+
if (content[i].type === "text" && content[i].text) {
|
|
61
|
+
result.firstPrompt = content[i].text.substring(0, 100);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Track latest user timestamp for lastActivity
|
|
68
|
+
if (obj.timestamp) result.lastActivity = obj.timestamp;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Extract model from first assistant message
|
|
72
|
+
if (!result.model && obj.message && obj.message.role === "assistant" && obj.message.model) {
|
|
73
|
+
result.model = obj.message.model;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
rl.on("close", function () {
|
|
78
|
+
if (!foundUser) return resolve(null);
|
|
79
|
+
|
|
80
|
+
// Use file mtime as fallback for lastActivity, or as a better proxy
|
|
81
|
+
// since we only read the first ~20 lines
|
|
82
|
+
try {
|
|
83
|
+
var stat = fs.statSync(filePath);
|
|
84
|
+
var mtime = stat.mtime.toISOString();
|
|
85
|
+
// File mtime is always more accurate for "last activity" since we
|
|
86
|
+
// don't read the entire file
|
|
87
|
+
result.lastActivity = mtime;
|
|
88
|
+
} catch (e) {}
|
|
89
|
+
|
|
90
|
+
resolve(result);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
rl.on("error", function () {
|
|
94
|
+
resolve(null);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
stream.on("error", function () {
|
|
98
|
+
rl.close();
|
|
99
|
+
resolve(null);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* List CLI sessions for a given project directory.
|
|
106
|
+
* Reads ~/.claude/projects/{encoded-cwd}/ and parses JSONL metadata.
|
|
107
|
+
* Returns array sorted by lastActivity descending (most recent first).
|
|
108
|
+
*/
|
|
109
|
+
function listCliSessions(cwd) {
|
|
110
|
+
var encoded = encodeCwd(cwd);
|
|
111
|
+
var projectDir = path.join(REAL_HOME, ".claude", "projects", encoded);
|
|
112
|
+
|
|
113
|
+
return new Promise(function (resolve) {
|
|
114
|
+
fs.readdir(projectDir, { withFileTypes: true }, function (err, entries) {
|
|
115
|
+
if (err) return resolve([]);
|
|
116
|
+
|
|
117
|
+
var jsonlFiles = [];
|
|
118
|
+
for (var i = 0; i < entries.length; i++) {
|
|
119
|
+
if (entries[i].isFile() && entries[i].name.endsWith(".jsonl")) {
|
|
120
|
+
jsonlFiles.push(path.join(projectDir, entries[i].name));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (jsonlFiles.length === 0) return resolve([]);
|
|
125
|
+
|
|
126
|
+
var pending = jsonlFiles.length;
|
|
127
|
+
var results = [];
|
|
128
|
+
|
|
129
|
+
for (var j = 0; j < jsonlFiles.length; j++) {
|
|
130
|
+
parseSessionFile(jsonlFiles[j]).then(function (session) {
|
|
131
|
+
if (session) results.push(session);
|
|
132
|
+
pending--;
|
|
133
|
+
if (pending === 0) {
|
|
134
|
+
results.sort(function (a, b) {
|
|
135
|
+
var ta = a.lastActivity || "";
|
|
136
|
+
var tb = b.lastActivity || "";
|
|
137
|
+
return ta < tb ? 1 : ta > tb ? -1 : 0;
|
|
138
|
+
});
|
|
139
|
+
resolve(results);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get the most recent CLI session for a given project directory.
|
|
149
|
+
* Returns the session object or null if none found.
|
|
150
|
+
*/
|
|
151
|
+
function getMostRecentCliSession(cwd) {
|
|
152
|
+
return listCliSessions(cwd).then(function (sessions) {
|
|
153
|
+
return sessions.length > 0 ? sessions[0] : null;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Extract user message text from a CLI JSONL content field.
|
|
159
|
+
* Content can be a string or an array of content blocks.
|
|
160
|
+
*/
|
|
161
|
+
function extractText(content) {
|
|
162
|
+
if (typeof content === "string") return content;
|
|
163
|
+
if (!Array.isArray(content)) return "";
|
|
164
|
+
var parts = [];
|
|
165
|
+
for (var i = 0; i < content.length; i++) {
|
|
166
|
+
if (content[i].type === "text" && content[i].text) {
|
|
167
|
+
parts.push(content[i].text);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return parts.join("");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Read a full CLI session JSONL file and convert it to relay-compatible
|
|
175
|
+
* history entries (user_message, delta, tool_start, tool_executing, tool_result).
|
|
176
|
+
* Returns a Promise that resolves to an array of history entries.
|
|
177
|
+
*/
|
|
178
|
+
// Convert one parsed CLI jsonl record into client history entries. Shared by
|
|
179
|
+
// the streaming (async) and synchronous readers so the format stays in lockstep.
|
|
180
|
+
// `state.toolCounter` carries across lines to mint unique tool ids.
|
|
181
|
+
function appendCliRecord(obj, state, history) {
|
|
182
|
+
if (!obj || !obj.message) return;
|
|
183
|
+
|
|
184
|
+
// User prompt
|
|
185
|
+
if (obj.type === "user" && obj.message.role === "user") {
|
|
186
|
+
// Skip tool_result records (they have type "user" but content is tool results)
|
|
187
|
+
var content = obj.message.content;
|
|
188
|
+
if (Array.isArray(content) && content.length > 0 && content[0].type === "tool_result") {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
var text = extractText(content);
|
|
192
|
+
if (text) history.push({ type: "user_message", text: text });
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Assistant message
|
|
197
|
+
if (obj.message.role === "assistant" && Array.isArray(obj.message.content)) {
|
|
198
|
+
for (var i = 0; i < obj.message.content.length; i++) {
|
|
199
|
+
var block = obj.message.content[i];
|
|
200
|
+
|
|
201
|
+
if (block.type === "text" && block.text) {
|
|
202
|
+
history.push({ type: "delta", text: block.text });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (block.type === "tool_use") {
|
|
206
|
+
var toolId = "cli-tool-" + (++state.toolCounter);
|
|
207
|
+
var toolName = block.name || "Tool";
|
|
208
|
+
history.push({ type: "tool_start", id: toolId, name: toolName });
|
|
209
|
+
history.push({
|
|
210
|
+
type: "tool_executing",
|
|
211
|
+
id: toolId,
|
|
212
|
+
name: toolName,
|
|
213
|
+
input: block.input || {},
|
|
214
|
+
});
|
|
215
|
+
// Emit ask_user_answered so the client re-enables input after replaying AskUserQuestion
|
|
216
|
+
if (toolName === "AskUserQuestion") {
|
|
217
|
+
history.push({ type: "ask_user_answered", toolId: toolId });
|
|
218
|
+
}
|
|
219
|
+
history.push({ type: "tool_result", id: toolId, content: "" });
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function readCliSessionHistory(home, cwd, sessionId) {
|
|
226
|
+
var encoded = encodeCwd(cwd);
|
|
227
|
+
var filePath = path.join(home || REAL_HOME, ".claude", "projects", encoded, sessionId + ".jsonl");
|
|
228
|
+
|
|
229
|
+
return new Promise(function (resolve) {
|
|
230
|
+
var history = [];
|
|
231
|
+
var stream;
|
|
232
|
+
try {
|
|
233
|
+
stream = fs.createReadStream(filePath, { encoding: "utf8" });
|
|
234
|
+
} catch (e) {
|
|
235
|
+
return resolve([]);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
var rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
239
|
+
var state = { toolCounter: 0 };
|
|
240
|
+
|
|
241
|
+
rl.on("line", function (line) {
|
|
242
|
+
var obj;
|
|
243
|
+
try { obj = JSON.parse(line); } catch (e) { return; }
|
|
244
|
+
appendCliRecord(obj, state, history);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
rl.on("close", function () {
|
|
248
|
+
resolve(history);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
rl.on("error", function () {
|
|
252
|
+
resolve([]);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
stream.on("error", function () {
|
|
256
|
+
rl.close();
|
|
257
|
+
resolve([]);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Synchronous variant for callers that run inside a synchronous request
|
|
263
|
+
// handler (e.g. switch_session, which must populate session.history before
|
|
264
|
+
// the session_switched broadcast). Reads the whole jsonl - these transcripts
|
|
265
|
+
// are small enough that blocking on a local read is fine.
|
|
266
|
+
// Modified-time (ms) of a CLI session's jsonl, or 0 if missing. Lets callers
|
|
267
|
+
// cheaply detect that the transcript grew (e.g. after a TUI turn) and re-read.
|
|
268
|
+
function cliSessionFileMtime(home, cwd, sessionId) {
|
|
269
|
+
var encoded = encodeCwd(cwd);
|
|
270
|
+
var filePath = path.join(home || REAL_HOME, ".claude", "projects", encoded, sessionId + ".jsonl");
|
|
271
|
+
try { return fs.statSync(filePath).mtimeMs; } catch (e) { return 0; }
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function readCliSessionHistorySync(home, cwd, sessionId) {
|
|
275
|
+
var encoded = encodeCwd(cwd);
|
|
276
|
+
var filePath = path.join(home || REAL_HOME, ".claude", "projects", encoded, sessionId + ".jsonl");
|
|
277
|
+
var raw;
|
|
278
|
+
try { raw = fs.readFileSync(filePath, "utf8"); } catch (e) { return []; }
|
|
279
|
+
var history = [];
|
|
280
|
+
var state = { toolCounter: 0 };
|
|
281
|
+
var lines = raw.split("\n");
|
|
282
|
+
for (var i = 0; i < lines.length; i++) {
|
|
283
|
+
if (!lines[i]) continue;
|
|
284
|
+
var obj;
|
|
285
|
+
try { obj = JSON.parse(lines[i]); } catch (e) { continue; }
|
|
286
|
+
appendCliRecord(obj, state, history);
|
|
287
|
+
}
|
|
288
|
+
return history;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
module.exports = {
|
|
292
|
+
listCliSessions: listCliSessions,
|
|
293
|
+
getMostRecentCliSession: getMostRecentCliSession,
|
|
294
|
+
readCliSessionHistory: readCliSessionHistory,
|
|
295
|
+
readCliSessionHistorySync: readCliSessionHistorySync,
|
|
296
|
+
cliSessionFileMtime: cliSessionFileMtime,
|
|
297
|
+
parseSessionFile: parseSessionFile,
|
|
298
|
+
encodeCwd: encodeCwd,
|
|
299
|
+
extractText: extractText,
|
|
300
|
+
};
|
|
@@ -17,9 +17,9 @@ var { wrapSpawnAsUser } = require("../os-users");
|
|
|
17
17
|
//
|
|
18
18
|
// The bundled @openai/codex platform package is the default. Set the
|
|
19
19
|
// CLAY_CODEX_PATH env var to an existing executable to run a different codex
|
|
20
|
-
// build (local dev build, system install, pinned older release)
|
|
21
|
-
//
|
|
22
|
-
//
|
|
20
|
+
// build (local dev build, system install, pinned older release). An unset
|
|
21
|
+
// override uses bundled resolution; an explicitly invalid override fails
|
|
22
|
+
// closed without selecting a different installation.
|
|
23
23
|
|
|
24
24
|
var PLATFORM_PACKAGE_BY_TARGET = {
|
|
25
25
|
"aarch64-apple-darwin": "@openai/codex-darwin-arm64",
|
|
@@ -45,14 +45,9 @@ function getTargetTriple() {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function findCodexPath() {
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log("[codex-app-server] Using CLAY_CODEX_PATH binary:", override);
|
|
52
|
-
return override;
|
|
53
|
-
}
|
|
54
|
-
console.warn("[codex-app-server] CLAY_CODEX_PATH does not exist, falling back to bundled codex:", override);
|
|
55
|
-
}
|
|
48
|
+
var discovery = require("./discovery");
|
|
49
|
+
var override = discovery.explicitEntry(process.env, "CLAY_CODEX_PATH", false);
|
|
50
|
+
if (override !== undefined) return override;
|
|
56
51
|
|
|
57
52
|
var triple = getTargetTriple();
|
|
58
53
|
if (!triple) throw new Error("Unsupported platform: " + process.platform + "/" + process.arch);
|
|
@@ -74,7 +69,7 @@ function findCodexPath() {
|
|
|
74
69
|
path.join(vendorRoot, triple, "codex", binaryName),
|
|
75
70
|
];
|
|
76
71
|
for (var i = 0; i < candidates.length; i++) {
|
|
77
|
-
if (
|
|
72
|
+
if (discovery.validEntry(candidates[i], false)) {
|
|
78
73
|
console.log("[codex-app-server] Using bundled codex binary:", candidates[i]);
|
|
79
74
|
return candidates[i];
|
|
80
75
|
}
|
|
@@ -49,4 +49,84 @@ async function retireIdleQueries(entries, server, checkCurrent) {
|
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
// A separate process may resume a different thread only after the shared
|
|
53
|
+
// process proves it has no writer for that thread. Never infer this from the
|
|
54
|
+
// number of query handles: Codex can retain a loaded thread after input ends.
|
|
55
|
+
async function loadedThreads(server, checkCurrent) {
|
|
56
|
+
var cursor = null;
|
|
57
|
+
var threads = [];
|
|
58
|
+
var deadline = Date.now() + 5000;
|
|
59
|
+
for (var page = 0; page < 20; page++) {
|
|
60
|
+
var remaining = deadline - Date.now();
|
|
61
|
+
if (remaining <= 0) return null;
|
|
62
|
+
var result;
|
|
63
|
+
try {
|
|
64
|
+
result = await server.send('thread/loaded/list', { cursor: cursor, limit: 100 }, remaining);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
checkCurrent();
|
|
67
|
+
if (!server.started) throw error;
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
checkCurrent();
|
|
71
|
+
if (!result || !Array.isArray(result.data) || !result.data.every(function(id) { return typeof id === 'string'; })) return null;
|
|
72
|
+
threads = threads.concat(result.data);
|
|
73
|
+
if (!result.nextCursor) return threads;
|
|
74
|
+
if (result.nextCursor === cursor) return null;
|
|
75
|
+
cursor = result.nextCursor;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function threadIsAbsent(server, threadId, checkCurrent) {
|
|
81
|
+
var threads = await loadedThreads(server, checkCurrent);
|
|
82
|
+
return !!threads && threads.indexOf(threadId) === -1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function runtimeCanStop(server, retiredThreads, checkCurrent) {
|
|
86
|
+
var threads = await loadedThreads(server, checkCurrent);
|
|
87
|
+
return !!threads && threads.every(function(threadId) { return retiredThreads.indexOf(threadId) !== -1; });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function releaseThread(entries, server, threadId, checkCurrent) {
|
|
91
|
+
if (!server || !server.started) throw new Error('Codex disconnected while checking recovery admission');
|
|
92
|
+
var matching = entries.filter(function(entry) {
|
|
93
|
+
return entry.handle && entry.handle.getRecoveryThreadId() === threadId;
|
|
94
|
+
});
|
|
95
|
+
if (!matching.length && await threadIsAbsent(server, threadId, checkCurrent)) return true;
|
|
96
|
+
if (matching.length) {
|
|
97
|
+
if (!await retireIdleQueries(matching, server, checkCurrent)) return false;
|
|
98
|
+
checkCurrent();
|
|
99
|
+
} else {
|
|
100
|
+
// A closed SDK handle can leave a loaded provider thread behind. Only an
|
|
101
|
+
// explicitly idle provider thread with verified terminal state may unload.
|
|
102
|
+
try {
|
|
103
|
+
var status = await server.send('thread/read', { threadId: threadId, includeTurns: false }, 5000);
|
|
104
|
+
checkCurrent();
|
|
105
|
+
if (!status || !status.thread || status.thread.id !== threadId
|
|
106
|
+
|| !status.thread.status || status.thread.status.type !== 'idle') return false;
|
|
107
|
+
var terminals = await server.send('thread/backgroundTerminals/list', { threadId: threadId }, 5000);
|
|
108
|
+
checkCurrent();
|
|
109
|
+
if (!terminalsAreIdle(terminals)) return false;
|
|
110
|
+
} catch (error) { checkCurrent(); if (!server.started) throw error; return false; }
|
|
111
|
+
}
|
|
112
|
+
try { await server.send('thread/unsubscribe', { threadId: threadId }, 5000); }
|
|
113
|
+
catch (error) { checkCurrent(); if (!server.started) throw error; return false; }
|
|
114
|
+
return threadIsAbsent(server, threadId, checkCurrent);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Poll the lifecycle without holding the admission lock. Also check Stop and
|
|
118
|
+
// shutdown while a provider probe, initialization, or process exit is pending.
|
|
119
|
+
function wait(promise, checkCurrent) {
|
|
120
|
+
return new Promise(function(resolve, reject) {
|
|
121
|
+
var timer = setInterval(function() {
|
|
122
|
+
try { checkCurrent(); } catch (error) { clearInterval(timer); reject(error); }
|
|
123
|
+
}, 25);
|
|
124
|
+
Promise.resolve(promise).then(function(value) {
|
|
125
|
+
clearInterval(timer);
|
|
126
|
+
try { checkCurrent(); resolve(value); } catch (error) { reject(error); }
|
|
127
|
+
}, function(error) { clearInterval(timer); reject(error); });
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = { retireIdleQueries: retireIdleQueries, checkAbort: checkAbort,
|
|
132
|
+
releaseThread: releaseThread, runtimeCanStop: runtimeCanStop, wait: wait };
|