@jingyi0605/codingns4dsh 0.2.1-beta.11 → 0.2.1-beta.13
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/README.en.md +7 -5
- package/README.md +9 -5
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +1 -1
- package/data/build/dist/bootstrap/index.d.ts +1 -1
- package/data/build/dist/client/account-bar.d.ts.map +1 -1
- package/data/build/dist/client/account-bar.js +24 -70
- package/data/build/dist/client/account-bar.js.map +1 -1
- package/data/build/dist/client/adapter-catalog-watch.d.ts +1 -1
- package/data/build/dist/client/adapter-catalog-watch.d.ts.map +1 -1
- package/data/build/dist/client/adapter-catalog-watch.js +2 -2
- package/data/build/dist/client/adapter-catalog-watch.js.map +1 -1
- package/data/build/dist/client/bundle.js +35978 -21117
- package/data/build/dist/client/bundle.js.map +1 -1
- package/data/build/dist/client/cli-management-dialog.d.ts +21 -0
- package/data/build/dist/client/cli-management-dialog.d.ts.map +1 -0
- package/data/build/dist/client/cli-management-dialog.js +215 -0
- package/data/build/dist/client/cli-management-dialog.js.map +1 -0
- package/data/build/dist/client/cli-management-terminal.d.ts +9 -0
- package/data/build/dist/client/cli-management-terminal.d.ts.map +1 -0
- package/data/build/dist/client/cli-management-terminal.js +30 -0
- package/data/build/dist/client/cli-management-terminal.js.map +1 -0
- package/data/build/dist/client/cli-settings-dialog.d.ts +9 -0
- package/data/build/dist/client/cli-settings-dialog.d.ts.map +1 -0
- package/data/build/dist/client/cli-settings-dialog.js +45 -0
- package/data/build/dist/client/cli-settings-dialog.js.map +1 -0
- package/data/build/dist/client/cli-settings-rpc.js +1 -1
- package/data/build/dist/client/cli-settings-rpc.js.map +1 -1
- package/data/build/dist/client/cli-slots.d.ts +7 -2
- package/data/build/dist/client/cli-slots.d.ts.map +1 -1
- package/data/build/dist/client/cli-slots.js +44 -12
- package/data/build/dist/client/cli-slots.js.map +1 -1
- package/data/build/dist/client/client.assistant-configuration-view.js +5 -5
- package/data/build/dist/client/client.assistant-configuration-view.js.map +1 -1
- package/data/build/dist/client/client.editor-engine.js +4 -1
- package/data/build/dist/client/client.editor-engine.js.map +1 -1
- package/data/build/dist/client/client.moss-voice-output.js +0 -166
- package/data/build/dist/client/client.moss-voice-output.js.map +1 -1
- package/data/build/dist/client/client.native-workspace-store.js +4 -4
- package/data/build/dist/client/client.native-workspace-store.js.map +1 -1
- package/data/build/dist/client/client.primitives-adapter.js +53 -0
- package/data/build/dist/client/client.primitives-adapter.js.map +1 -1
- package/data/build/dist/client/client.react-dom.js +166 -0
- package/data/build/dist/client/client.react-dom.js.map +1 -1
- package/data/build/dist/client/client.session-translation.js +25 -1
- package/data/build/dist/client/client.session-translation.js.map +1 -1
- package/data/build/dist/client/client.transport.js +503 -42
- package/data/build/dist/client/client.transport.js.map +1 -1
- package/data/build/dist/client/conversation-translation-settings.d.ts +11 -0
- package/data/build/dist/client/conversation-translation-settings.d.ts.map +1 -0
- package/data/build/dist/client/conversation-translation-settings.js +54 -0
- package/data/build/dist/client/conversation-translation-settings.js.map +1 -0
- package/data/build/dist/client/desktop-assistant.js +967 -479
- package/data/build/dist/client/editor-engine.d.ts +1 -1
- package/data/build/dist/client/editor-engine.d.ts.map +1 -1
- package/data/build/dist/client/editor-engine.js +4 -1
- package/data/build/dist/client/editor-engine.js.map +1 -1
- package/data/build/dist/client/features/cli-adapters.d.ts +3 -1
- package/data/build/dist/client/features/cli-adapters.d.ts.map +1 -1
- package/data/build/dist/client/features/cli-adapters.js +182 -106
- package/data/build/dist/client/features/cli-adapters.js.map +1 -1
- package/data/build/dist/client/features/file-management.d.ts.map +1 -1
- package/data/build/dist/client/features/file-management.js +2 -0
- package/data/build/dist/client/features/file-management.js.map +1 -1
- package/data/build/dist/client/features/index.d.ts.map +1 -1
- package/data/build/dist/client/features/index.js +2 -0
- package/data/build/dist/client/features/index.js.map +1 -1
- package/data/build/dist/client/features/peer-host.d.ts.map +1 -1
- package/data/build/dist/client/features/peer-host.js +3 -0
- package/data/build/dist/client/features/peer-host.js.map +1 -1
- package/data/build/dist/client/features/quick-apps.d.ts +3 -0
- package/data/build/dist/client/features/quick-apps.d.ts.map +1 -0
- package/data/build/dist/client/features/quick-apps.js +14 -0
- package/data/build/dist/client/features/quick-apps.js.map +1 -0
- package/data/build/dist/client/features/session-translation.d.ts.map +1 -1
- package/data/build/dist/client/features/session-translation.js +7 -1
- package/data/build/dist/client/features/session-translation.js.map +1 -1
- package/data/build/dist/client/html-workspace-files.d.ts +4 -0
- package/data/build/dist/client/html-workspace-files.d.ts.map +1 -0
- package/data/build/dist/client/html-workspace-files.js +114 -0
- package/data/build/dist/client/html-workspace-files.js.map +1 -0
- package/data/build/dist/client/locale.d.ts.map +1 -1
- package/data/build/dist/client/locale.js +6 -0
- package/data/build/dist/client/locale.js.map +1 -1
- package/data/build/dist/client/locales/cliManagement.d.ts +3 -0
- package/data/build/dist/client/locales/cliManagement.d.ts.map +1 -0
- package/data/build/dist/client/locales/cliManagement.js +139 -0
- package/data/build/dist/client/locales/cliManagement.js.map +1 -0
- package/data/build/dist/client/locales/fileWorkspace.d.ts.map +1 -1
- package/data/build/dist/client/locales/fileWorkspace.js +4 -0
- package/data/build/dist/client/locales/fileWorkspace.js.map +1 -1
- package/data/build/dist/client/locales/panels.d.ts.map +1 -1
- package/data/build/dist/client/locales/panels.js +46 -0
- package/data/build/dist/client/locales/panels.js.map +1 -1
- package/data/build/dist/client/locales/quickApps.d.ts +130 -0
- package/data/build/dist/client/locales/quickApps.d.ts.map +1 -0
- package/data/build/dist/client/locales/quickApps.js +150 -0
- package/data/build/dist/client/locales/quickApps.js.map +1 -0
- package/data/build/dist/client/native-model-translation-menu.d.ts.map +1 -1
- package/data/build/dist/client/native-model-translation-menu.js +3 -1
- package/data/build/dist/client/native-model-translation-menu.js.map +1 -1
- package/data/build/dist/client/quick-apps/client.d.ts +29 -0
- package/data/build/dist/client/quick-apps/client.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/client.js +68 -0
- package/data/build/dist/client/quick-apps/client.js.map +1 -0
- package/data/build/dist/client/quick-apps/document.d.ts +26 -0
- package/data/build/dist/client/quick-apps/document.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/document.js +110 -0
- package/data/build/dist/client/quick-apps/document.js.map +1 -0
- package/data/build/dist/client/quick-apps/file-picker.d.ts +14 -0
- package/data/build/dist/client/quick-apps/file-picker.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/file-picker.js +51 -0
- package/data/build/dist/client/quick-apps/file-picker.js.map +1 -0
- package/data/build/dist/client/quick-apps/launcher.d.ts +7 -0
- package/data/build/dist/client/quick-apps/launcher.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/launcher.js +252 -0
- package/data/build/dist/client/quick-apps/launcher.js.map +1 -0
- package/data/build/dist/client/quick-apps/presentation.d.ts +16 -0
- package/data/build/dist/client/quick-apps/presentation.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/presentation.js +31 -0
- package/data/build/dist/client/quick-apps/presentation.js.map +1 -0
- package/data/build/dist/client/quick-apps/reorder-animation.d.ts +6 -0
- package/data/build/dist/client/quick-apps/reorder-animation.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/reorder-animation.js +50 -0
- package/data/build/dist/client/quick-apps/reorder-animation.js.map +1 -0
- package/data/build/dist/client/quick-apps/reorder.d.ts +26 -0
- package/data/build/dist/client/quick-apps/reorder.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/reorder.js +128 -0
- package/data/build/dist/client/quick-apps/reorder.js.map +1 -0
- package/data/build/dist/client/quick-apps/styles.d.ts +3 -0
- package/data/build/dist/client/quick-apps/styles.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/styles.js +143 -0
- package/data/build/dist/client/quick-apps/styles.js.map +1 -0
- package/data/build/dist/client/quick-apps/ui.d.ts +20 -0
- package/data/build/dist/client/quick-apps/ui.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/ui.js +21 -0
- package/data/build/dist/client/quick-apps/ui.js.map +1 -0
- package/data/build/dist/client/quick-apps/viewer.d.ts +16 -0
- package/data/build/dist/client/quick-apps/viewer.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/viewer.js +155 -0
- package/data/build/dist/client/quick-apps/viewer.js.map +1 -0
- package/data/build/dist/client/quick-apps/workspace-picker.d.ts +19 -0
- package/data/build/dist/client/quick-apps/workspace-picker.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/workspace-picker.js +30 -0
- package/data/build/dist/client/quick-apps/workspace-picker.js.map +1 -0
- package/data/build/dist/client/session-translation-chat.d.ts +10 -4
- package/data/build/dist/client/session-translation-chat.d.ts.map +1 -1
- package/data/build/dist/client/session-translation-chat.js +154 -52
- package/data/build/dist/client/session-translation-chat.js.map +1 -1
- package/data/build/dist/client/session-translation-pending-dom.d.ts +1 -1
- package/data/build/dist/client/session-translation-pending-dom.d.ts.map +1 -1
- package/data/build/dist/client/session-translation-pending-dom.js +4 -4
- package/data/build/dist/client/session-translation-pending-dom.js.map +1 -1
- package/data/build/dist/client/session-translation-retry.d.ts +16 -0
- package/data/build/dist/client/session-translation-retry.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-retry.js +66 -0
- package/data/build/dist/client/session-translation-retry.js.map +1 -0
- package/data/build/dist/client/session-translation-rules.d.ts +13 -0
- package/data/build/dist/client/session-translation-rules.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-rules.js +58 -0
- package/data/build/dist/client/session-translation-rules.js.map +1 -0
- package/data/build/dist/client/sidebar-footer-style.d.ts +13 -0
- package/data/build/dist/client/sidebar-footer-style.d.ts.map +1 -0
- package/data/build/dist/client/sidebar-footer-style.js +54 -0
- package/data/build/dist/client/sidebar-footer-style.js.map +1 -0
- package/data/build/dist/client/style.css +276 -276
- package/data/build/dist/client/terminal/model.d.ts.map +1 -1
- package/data/build/dist/client/terminal/model.js +2 -1
- package/data/build/dist/client/terminal/model.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.d.ts +4 -0
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.js +8 -0
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js +4 -13
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js +1 -1
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.d.ts +19 -0
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.js +39 -0
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts +18 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.js +21 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.d.ts +18 -0
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.js +11 -0
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.d.ts +8 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.js +100 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.d.ts +3 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.js +22 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.d.ts +2 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js +28 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js.map +1 -1
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.d.ts +10 -0
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.js +34 -0
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.d.ts +21 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.js +11 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.d.ts +11 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.js +97 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.d.ts +36 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.js +164 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.d.ts +44 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.js +240 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.d.ts +37 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.js +35 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.d.ts +13 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.js +30 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.d.ts +21 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.js +132 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.d.ts +10 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.js +33 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.d.ts +17 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.js +37 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.d.ts +17 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.js +45 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.d.ts +7 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.js +18 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.d.ts +28 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.js +31 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.d.ts +13 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.js +24 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/matrix.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/matrix.js +19 -5
- package/data/build/dist/dsh-capabilities/matrix.js.map +1 -1
- package/data/build/dist/dsh-capabilities/routes.d.ts +1 -0
- package/data/build/dist/dsh-capabilities/routes.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/routes.js +41 -5
- package/data/build/dist/dsh-capabilities/routes.js.map +1 -1
- package/data/build/dist/dsh-capabilities/types.d.ts +1 -1
- package/data/build/dist/dsh-capabilities/types.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/types.js.map +1 -1
- package/data/build/dist/host/cli-adapters/antigravity-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/antigravity-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/attachment-utils.d.ts +4 -3
- package/data/build/dist/host/cli-adapters/attachment-utils.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/attachment-utils.js +9 -8
- package/data/build/dist/host/cli-adapters/attachment-utils.js.map +1 -1
- package/data/build/dist/host/cli-adapters/binary-detection.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/binary-detection.js +7 -3
- package/data/build/dist/host/cli-adapters/binary-detection.js.map +1 -1
- package/data/build/dist/host/cli-adapters/claude-driver.d.ts +1 -0
- package/data/build/dist/host/cli-adapters/claude-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/claude-driver.js +180 -21
- package/data/build/dist/host/cli-adapters/claude-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/codex-driver.d.ts +18 -0
- package/data/build/dist/host/cli-adapters/codex-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/codex-driver.js +97 -5
- package/data/build/dist/host/cli-adapters/codex-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/codex-performance-projection.d.ts +91 -0
- package/data/build/dist/host/cli-adapters/codex-performance-projection.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/codex-performance-projection.js +8 -0
- package/data/build/dist/host/cli-adapters/codex-performance-projection.js.map +1 -0
- package/data/build/dist/host/cli-adapters/codex-performance.d.ts +16 -0
- package/data/build/dist/host/cli-adapters/codex-performance.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/codex-performance.js +81 -0
- package/data/build/dist/host/cli-adapters/codex-performance.js.map +1 -0
- package/data/build/dist/host/cli-adapters/command-code-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/command-code-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/driver.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js +28 -7
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.js +186 -71
- package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts +3 -0
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-driver.js +277 -53
- package/data/build/dist/host/cli-adapters/grok-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-performance-projection.d.ts +123 -0
- package/data/build/dist/host/cli-adapters/grok-performance-projection.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/grok-performance-projection.js +47 -0
- package/data/build/dist/host/cli-adapters/grok-performance-projection.js.map +1 -0
- package/data/build/dist/host/cli-adapters/grok-usage.d.ts +45 -0
- package/data/build/dist/host/cli-adapters/grok-usage.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/grok-usage.js +197 -0
- package/data/build/dist/host/cli-adapters/grok-usage.js.map +1 -0
- package/data/build/dist/host/cli-adapters/kimi-driver.js +2 -2
- package/data/build/dist/host/cli-adapters/kimi-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/management-installation.d.ts +5 -0
- package/data/build/dist/host/cli-adapters/management-installation.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management-installation.js +131 -0
- package/data/build/dist/host/cli-adapters/management-installation.js.map +1 -0
- package/data/build/dist/host/cli-adapters/management-methods.d.ts +32 -0
- package/data/build/dist/host/cli-adapters/management-methods.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management-methods.js +135 -0
- package/data/build/dist/host/cli-adapters/management-methods.js.map +1 -0
- package/data/build/dist/host/cli-adapters/management-process.d.ts +7 -0
- package/data/build/dist/host/cli-adapters/management-process.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management-process.js +51 -0
- package/data/build/dist/host/cli-adapters/management-process.js.map +1 -0
- package/data/build/dist/host/cli-adapters/management.d.ts +32 -0
- package/data/build/dist/host/cli-adapters/management.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management.js +172 -0
- package/data/build/dist/host/cli-adapters/management.js.map +1 -0
- package/data/build/dist/host/cli-adapters/mcode-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/mcode-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/model-catalog.d.ts +1 -0
- package/data/build/dist/host/cli-adapters/model-catalog.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/model-catalog.js +62 -0
- package/data/build/dist/host/cli-adapters/model-catalog.js.map +1 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.js +2 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.js.map +1 -1
- package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +22 -0
- package/data/build/dist/host/cli-adapters/opencode-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/opencode-driver.js +105 -17
- package/data/build/dist/host/cli-adapters/opencode-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/pi-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/pi-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/process-utils.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/process-utils.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/process-utils.js +16 -11
- package/data/build/dist/host/cli-adapters/process-utils.js.map +1 -1
- package/data/build/dist/host/cli-adapters/registry.d.ts +3 -0
- package/data/build/dist/host/cli-adapters/registry.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/registry.js +56 -21
- package/data/build/dist/host/cli-adapters/registry.js.map +1 -1
- package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts +74 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.js +83 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.js.map +1 -0
- package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +3 -1
- package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/stream-normalizer.js +2 -0
- package/data/build/dist/host/cli-adapters/stream-normalizer.js.map +1 -1
- package/data/build/dist/host/cli-adapters/update-check.d.ts +34 -0
- package/data/build/dist/host/cli-adapters/update-check.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/update-check.js +263 -0
- package/data/build/dist/host/cli-adapters/update-check.js.map +1 -0
- package/data/build/dist/host/cli-adapters/zcode-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/zcode-driver.js.map +1 -1
- package/data/build/dist/host/features/file-management.d.ts.map +1 -1
- package/data/build/dist/host/features/file-management.js +8 -0
- package/data/build/dist/host/features/file-management.js.map +1 -1
- package/data/build/dist/host/features/global-voice-rpc.d.ts.map +1 -1
- package/data/build/dist/host/features/global-voice-rpc.js +2 -3
- package/data/build/dist/host/features/global-voice-rpc.js.map +1 -1
- package/data/build/dist/host/features/index.d.ts.map +1 -1
- package/data/build/dist/host/features/index.js +2 -0
- package/data/build/dist/host/features/index.js.map +1 -1
- package/data/build/dist/host/features/lan-access-dsh.js +1 -1
- package/data/build/dist/host/features/lan-access-dsh.js.map +1 -1
- package/data/build/dist/host/features/peer-host.d.ts.map +1 -1
- package/data/build/dist/host/features/peer-host.js +13 -6
- package/data/build/dist/host/features/peer-host.js.map +1 -1
- package/data/build/dist/host/features/quick-apps.d.ts +4 -0
- package/data/build/dist/host/features/quick-apps.d.ts.map +1 -0
- package/data/build/dist/host/features/quick-apps.js +158 -0
- package/data/build/dist/host/features/quick-apps.js.map +1 -0
- package/data/build/dist/host/features/session-prompt-translation.d.ts +10 -0
- package/data/build/dist/host/features/session-prompt-translation.d.ts.map +1 -0
- package/data/build/dist/host/features/session-prompt-translation.js +198 -0
- package/data/build/dist/host/features/session-prompt-translation.js.map +1 -0
- package/data/build/dist/host/features/session-translation-protection.d.ts +12 -1
- package/data/build/dist/host/features/session-translation-protection.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation-protection.js +44 -5
- package/data/build/dist/host/features/session-translation-protection.js.map +1 -1
- package/data/build/dist/host/features/session-translation-recovery.d.ts +21 -0
- package/data/build/dist/host/features/session-translation-recovery.d.ts.map +1 -0
- package/data/build/dist/host/features/session-translation-recovery.js +125 -0
- package/data/build/dist/host/features/session-translation-recovery.js.map +1 -0
- package/data/build/dist/host/features/session-translation-service.d.ts +8 -2
- package/data/build/dist/host/features/session-translation-service.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation-service.js +69 -19
- package/data/build/dist/host/features/session-translation-service.js.map +1 -1
- package/data/build/dist/host/features/session-translation.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation.js +4 -1
- package/data/build/dist/host/features/session-translation.js.map +1 -1
- package/data/build/dist/host/features/types.d.ts +10 -0
- package/data/build/dist/host/features/types.d.ts.map +1 -1
- package/data/build/dist/host/html-workspace-files.d.ts +3 -0
- package/data/build/dist/host/html-workspace-files.d.ts.map +1 -0
- package/data/build/dist/host/html-workspace-files.js +135 -0
- package/data/build/dist/host/html-workspace-files.js.map +1 -0
- package/data/build/dist/host/index.d.ts.map +1 -1
- package/data/build/dist/host/index.js +27 -2
- package/data/build/dist/host/index.js.map +1 -1
- package/data/build/dist/host/lan-access-dsh.d.ts +5 -1
- package/data/build/dist/host/lan-access-dsh.d.ts.map +1 -1
- package/data/build/dist/host/lan-access-dsh.js +43 -2
- package/data/build/dist/host/lan-access-dsh.js.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts +2 -2
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js +10 -9
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.d.ts +3 -3
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.d.ts.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.js +26 -14
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.js.map +1 -1
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.d.ts +5 -0
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.d.ts.map +1 -0
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.js +27 -0
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/browse.d.ts +5 -0
- package/data/build/dist/host/modules/quick-apps/browse.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/browse.js +37 -0
- package/data/build/dist/host/modules/quick-apps/browse.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.d.ts +4 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.js +39 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/documents.d.ts +14 -0
- package/data/build/dist/host/modules/quick-apps/documents.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/documents.js +87 -0
- package/data/build/dist/host/modules/quick-apps/documents.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/errors.d.ts +8 -0
- package/data/build/dist/host/modules/quick-apps/errors.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/errors.js +15 -0
- package/data/build/dist/host/modules/quick-apps/errors.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/file-api.d.ts +30 -0
- package/data/build/dist/host/modules/quick-apps/file-api.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/file-api.js +149 -0
- package/data/build/dist/host/modules/quick-apps/file-api.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/launches.d.ts +35 -0
- package/data/build/dist/host/modules/quick-apps/launches.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/launches.js +80 -0
- package/data/build/dist/host/modules/quick-apps/launches.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/paths.d.ts +14 -0
- package/data/build/dist/host/modules/quick-apps/paths.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/paths.js +72 -0
- package/data/build/dist/host/modules/quick-apps/paths.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/registry.d.ts +30 -0
- package/data/build/dist/host/modules/quick-apps/registry.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/registry.js +186 -0
- package/data/build/dist/host/modules/quick-apps/registry.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/remote.d.ts +38 -0
- package/data/build/dist/host/modules/quick-apps/remote.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/remote.js +237 -0
- package/data/build/dist/host/modules/quick-apps/remote.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/service.d.ts +27 -0
- package/data/build/dist/host/modules/quick-apps/service.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/service.js +170 -0
- package/data/build/dist/host/modules/quick-apps/service.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.d.ts +8 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.js +181 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.js.map +1 -0
- package/data/build/dist/host/native-session-bridge.d.ts +7 -1
- package/data/build/dist/host/native-session-bridge.d.ts.map +1 -1
- package/data/build/dist/host/native-session-bridge.js +8 -13
- package/data/build/dist/host/native-session-bridge.js.map +1 -1
- package/data/build/dist/host/rpc.d.ts.map +1 -1
- package/data/build/dist/host/rpc.js +21 -10
- package/data/build/dist/host/rpc.js.map +1 -1
- package/data/build/dist/host/settings.d.ts.map +1 -1
- package/data/build/dist/host/settings.js +18 -1
- package/data/build/dist/host/settings.js.map +1 -1
- package/data/build/dist/host/workspace-file-mutations.d.ts +2 -0
- package/data/build/dist/host/workspace-file-mutations.d.ts.map +1 -0
- package/data/build/dist/host/workspace-file-mutations.js +15 -0
- package/data/build/dist/host/workspace-file-mutations.js.map +1 -0
- package/data/build/dist/shared/attachment-prompts.d.ts +11 -0
- package/data/build/dist/shared/attachment-prompts.d.ts.map +1 -0
- package/data/build/dist/shared/attachment-prompts.js +17 -0
- package/data/build/dist/shared/attachment-prompts.js.map +1 -0
- package/data/build/dist/shared/codex-performance.d.ts +3 -0
- package/data/build/dist/shared/codex-performance.d.ts.map +1 -0
- package/data/build/dist/shared/codex-performance.js +2 -0
- package/data/build/dist/shared/codex-performance.js.map +1 -0
- package/data/build/dist/shared/contracts/cli-adapter.d.ts +33 -1
- package/data/build/dist/shared/contracts/cli-adapter.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/cli-management.d.ts +29 -0
- package/data/build/dist/shared/contracts/cli-management.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/cli-management.js +2 -0
- package/data/build/dist/shared/contracts/cli-management.js.map +1 -0
- package/data/build/dist/shared/contracts/config.d.ts +2 -0
- package/data/build/dist/shared/contracts/config.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/config.js.map +1 -1
- package/data/build/dist/shared/contracts/errors.d.ts +2 -2
- package/data/build/dist/shared/contracts/quick-apps.d.ts +68 -0
- package/data/build/dist/shared/contracts/quick-apps.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/quick-apps.js +4 -0
- package/data/build/dist/shared/contracts/quick-apps.js.map +1 -0
- package/data/build/dist/shared/contracts/session-translation.d.ts +20 -2
- package/data/build/dist/shared/contracts/session-translation.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/session-translation.js +24 -0
- package/data/build/dist/shared/contracts/session-translation.js.map +1 -1
- package/data/build/dist/shared/contracts/version.d.ts +4 -4
- package/data/build/dist/shared/contracts/version.js +3 -3
- package/data/build/dist/shared/peer-host-http-routes.d.ts +4 -0
- package/data/build/dist/shared/peer-host-http-routes.d.ts.map +1 -1
- package/data/build/dist/shared/peer-host-http-routes.js +4 -0
- package/data/build/dist/shared/peer-host-http-routes.js.map +1 -1
- package/data/build/dist/shared/quick-app-proxy-path.d.ts +6 -0
- package/data/build/dist/shared/quick-app-proxy-path.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-proxy-path.js +18 -0
- package/data/build/dist/shared/quick-app-proxy-path.js.map +1 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.d.ts +7 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.d.ts.map +1 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.js +10 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.js.map +1 -0
- package/data/build/dist/shared/request-performance.d.ts +15 -0
- package/data/build/dist/shared/request-performance.d.ts.map +1 -0
- package/data/build/dist/shared/request-performance.js +3 -0
- package/data/build/dist/shared/request-performance.js.map +1 -0
- package/package.json +35 -34
- package/profile/README.md +2 -2
- package/profile/package.json +3 -3
- package/profile/version.json +3 -3
- package/version.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { runAsyncCommand } from './process-utils.js';
|
|
2
2
|
import { spawn, spawnSync } from 'node:child_process';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
3
4
|
import { homedir } from 'node:os';
|
|
4
5
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
6
|
import { JsonRpcProcess } from './json-rpc-process.js';
|
|
@@ -14,13 +15,17 @@ import { ACP_FORM_CLIENT_CAPABILITIES, acpElicitationResponse, readAcpElicitatio
|
|
|
14
15
|
import { readAgentQuestions } from './interaction-events.js';
|
|
15
16
|
import { commandEnvironment, WINDOWS } from './process-utils.js';
|
|
16
17
|
import { imageArtifactPathsFromValue, stripImageMarkdown } from '../image-artifact-store.js';
|
|
18
|
+
import { advanceCodingNsSegment, createCodingNsSegmentState, decorateCodingNsSegmentEvent } from './stream-normalizer.js';
|
|
19
|
+
import { GrokContextUsage, GrokPromptUsage } from './grok-usage.js';
|
|
17
20
|
/** Grok Build 的 ACP stdio 驱动。ACP 会话和权限细节只在 Host 进程内处理。 */
|
|
18
21
|
export class GrokBuildDriver {
|
|
19
22
|
descriptor = { id: 'grok', name: 'Grok Build', protocol: 'acp', capabilities: ['models', 'skills', 'stream', 'tool-events', 'reasoning', 'usage', 'permission', 'questions'] };
|
|
23
|
+
supportsStreamStepSplitting = true;
|
|
20
24
|
binaries;
|
|
21
25
|
runSpawnSync;
|
|
22
26
|
runSpawn;
|
|
23
27
|
sessionRoots;
|
|
28
|
+
now;
|
|
24
29
|
cachedBinary = null;
|
|
25
30
|
processes = new Set();
|
|
26
31
|
sessions = new Map();
|
|
@@ -28,6 +33,7 @@ export class GrokBuildDriver {
|
|
|
28
33
|
this.binaries = options.binaries ?? ['grok', 'grok-build'];
|
|
29
34
|
this.runSpawnSync = options.spawnSync ?? spawnSync;
|
|
30
35
|
this.runSpawn = options.spawn ?? spawn;
|
|
36
|
+
this.now = options.now ?? Date.now;
|
|
31
37
|
this.sessionRoots = options.sessionRoots ?? [join(process.env.GROK_HOME ?? join(homedir(), '.grok'), 'sessions')];
|
|
32
38
|
}
|
|
33
39
|
async detect() {
|
|
@@ -106,26 +112,45 @@ export class GrokBuildDriver {
|
|
|
106
112
|
const rpc = state.rpc;
|
|
107
113
|
let providerSessionId = state.providerSessionId;
|
|
108
114
|
let stream;
|
|
115
|
+
let reusable = false;
|
|
116
|
+
const promptId = randomUUID();
|
|
117
|
+
const segmentState = createCodingNsSegmentState();
|
|
118
|
+
let stepPhase;
|
|
119
|
+
let stepStreamId;
|
|
120
|
+
const activeTools = new Map();
|
|
121
|
+
const streamedToolInputs = new Map();
|
|
109
122
|
try {
|
|
110
123
|
if (providerSessionId === '') {
|
|
111
124
|
const session = await rpc.request('session/new', {
|
|
112
125
|
cwd: input.cwd ?? process.cwd(),
|
|
113
126
|
mcpServers: acpBridgeMcpServers(input.sessionId, this.descriptor.id),
|
|
114
|
-
...(!isProviderDefaultModel(input.modelId) ? { model: input.modelId } : {}),
|
|
115
127
|
}, { signal: input.signal });
|
|
116
128
|
providerSessionId = readSessionId(session) ?? input.sessionId;
|
|
129
|
+
state.contextUsage.observe(session);
|
|
117
130
|
state.providerSessionId = providerSessionId;
|
|
118
131
|
this.sessions.set(input.sessionId, state);
|
|
119
132
|
this.sessions.set(providerSessionId, state);
|
|
120
133
|
}
|
|
121
134
|
yield { type: 'session-binding', providerSessionId };
|
|
135
|
+
// Grok 1.0.52 ignores the model field on session/new. Apply explicit
|
|
136
|
+
// selections after both creation and restoration, including reused sessions.
|
|
137
|
+
if (input.modelId && !isProviderDefaultModel(input.modelId)) {
|
|
138
|
+
const selected = await rpc.request('session/set_model', { sessionId: providerSessionId, modelId: input.modelId }, { signal: input.signal });
|
|
139
|
+
state.contextUsage.modelId = input.modelId;
|
|
140
|
+
state.contextUsage.observe(selected);
|
|
141
|
+
}
|
|
142
|
+
if (input.effortId) {
|
|
143
|
+
await rpc.request('session/set_config_option', { sessionId: providerSessionId, configId: 'reasoning_effort', value: input.effortId }, { signal: input.signal });
|
|
144
|
+
}
|
|
122
145
|
// Skill 斜杠命令由 Grok 在用户输入开头解析,不能把普通提示插到命令前。
|
|
123
146
|
const nativeCommand = /^\s*\/[A-Za-z0-9][A-Za-z0-9._:-]*(?:\s|$)/u.test(input.prompt);
|
|
124
147
|
const prompt = [
|
|
125
148
|
...(nativeCommand ? [] : [{ type: 'text', text: GROK_QUESTION_GUIDANCE }]),
|
|
126
149
|
...await buildAcpPromptBlocks(input.prompt, input.attachments ?? []),
|
|
127
150
|
];
|
|
128
|
-
|
|
151
|
+
const usage = new GrokPromptUsage(promptId, state.contextUsage, this.now);
|
|
152
|
+
stream = streamGrokPrompt(rpc, providerSessionId, promptId, prompt, input.signal, (notification) => {
|
|
153
|
+
usage.observe(notification);
|
|
129
154
|
const elicitation = readAcpElicitationRequest(notification);
|
|
130
155
|
if (elicitation !== null)
|
|
131
156
|
state.questions.set(elicitation.requestId, elicitation);
|
|
@@ -136,8 +161,9 @@ export class GrokBuildDriver {
|
|
|
136
161
|
// 已回答的问题被重新登记。tool_call 可以先显示问题卡并暂存用户答案。
|
|
137
162
|
const requestId = interactionRequestId(notification);
|
|
138
163
|
if (requestId !== null && notification.id !== undefined && notification.id !== null)
|
|
139
|
-
state.requests.set(requestId, { rpcId: notification.id, ...permissionOptions(notification) });
|
|
140
|
-
|
|
164
|
+
state.requests.set(requestId, { rpcId: notification.id, callId: permissionCallId(notification), ...permissionOptions(notification) });
|
|
165
|
+
return usage.takeObservation();
|
|
166
|
+
}, response => { usage.observeResponse(response); return usage.takeObservation(); });
|
|
141
167
|
let finishResult;
|
|
142
168
|
while (true) {
|
|
143
169
|
const item = await stream.next();
|
|
@@ -145,12 +171,25 @@ export class GrokBuildDriver {
|
|
|
145
171
|
finishResult = item.value;
|
|
146
172
|
break;
|
|
147
173
|
}
|
|
148
|
-
|
|
149
|
-
|
|
174
|
+
if (item.value.codingnsGrokObservation !== undefined)
|
|
175
|
+
yield item.value.codingnsGrokObservation;
|
|
176
|
+
const streamId = grokStreamId(item.value);
|
|
177
|
+
for (const rawChunk of grokToolInputChunks(item.value, streamedToolInputs) ?? acpMessageToChunks(item.value)) {
|
|
178
|
+
// Settle native turn accounting once, after the terminal drain. Per-call
|
|
179
|
+
// usage is retained by the RPC observer solely for timing and fallback.
|
|
180
|
+
if (rawChunk.type === 'usage')
|
|
181
|
+
continue;
|
|
182
|
+
let resolved = rawChunk.type === 'image-artifact'
|
|
150
183
|
? await resolveGrokImageArtifact(rawChunk, state, this.sessionRoots)
|
|
151
184
|
: rawChunk;
|
|
152
|
-
if (
|
|
185
|
+
if (resolved === null)
|
|
153
186
|
continue;
|
|
187
|
+
if (resolved.type === 'tool-event' && resolved.status === 'failed' && resolved.callId) {
|
|
188
|
+
const denial = state.permissionDenials.get(resolved.callId);
|
|
189
|
+
if (denial !== undefined)
|
|
190
|
+
resolved = { ...resolved, error: denial, output: denial, outputMode: 'snapshot' };
|
|
191
|
+
}
|
|
192
|
+
const chunk = decorateCodingNsSegmentEvent(resolved, input, segmentState, this.descriptor.id);
|
|
154
193
|
if (chunk.type === 'question-request' && state.grokQuestionCallIds.has(chunk.requestId)) {
|
|
155
194
|
if (state.grokQuestionEventIds.has(chunk.requestId))
|
|
156
195
|
continue;
|
|
@@ -160,15 +199,56 @@ export class GrokBuildDriver {
|
|
|
160
199
|
// 工具记录,否则历史里会重新出现空参数或重复的问题调用。
|
|
161
200
|
if (chunk.type === 'tool-event' && chunk.callId !== undefined && state.grokQuestionCallIds.has(chunk.callId))
|
|
162
201
|
continue;
|
|
202
|
+
const phase = grokStepPhase(chunk);
|
|
203
|
+
if (phase !== undefined) {
|
|
204
|
+
// DSH persists assistant content only at step settlement. End the content
|
|
205
|
+
// step before native tools are appended, and keep unfinished parallel calls
|
|
206
|
+
// together so their results cannot be finalized by an intermediate step.
|
|
207
|
+
if (input.splitToolSteps && stepPhase !== undefined && activeTools.size === 0
|
|
208
|
+
&& (phase !== stepPhase || (streamId !== undefined && stepStreamId !== undefined && streamId !== stepStreamId))) {
|
|
209
|
+
yield { type: 'step-boundary' };
|
|
210
|
+
}
|
|
211
|
+
stepPhase = phase;
|
|
212
|
+
if (streamId !== undefined)
|
|
213
|
+
stepStreamId = streamId;
|
|
214
|
+
}
|
|
215
|
+
if (chunk.type === 'tool-event') {
|
|
216
|
+
const callId = chunk.callId ?? chunk.toolName;
|
|
217
|
+
if (chunk.status === 'completed' || chunk.status === 'failed')
|
|
218
|
+
activeTools.delete(callId);
|
|
219
|
+
else
|
|
220
|
+
activeTools.set(callId, chunk.toolName === 'tool' ? activeTools.get(callId) ?? chunk.toolName : chunk.toolName);
|
|
221
|
+
}
|
|
163
222
|
yield chunk;
|
|
223
|
+
advanceCodingNsSegment(chunk, segmentState);
|
|
224
|
+
if (chunk.type === 'question-request')
|
|
225
|
+
segmentState.segment += 1;
|
|
164
226
|
}
|
|
165
227
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
228
|
+
const settledUsage = usage.finish();
|
|
229
|
+
if (settledUsage !== undefined) {
|
|
230
|
+
const { requestPerformance: _observed, ...accounting } = settledUsage;
|
|
231
|
+
yield accounting;
|
|
232
|
+
}
|
|
233
|
+
if (finishResult.failure?.code === 'PERMISSION_DENIED') {
|
|
234
|
+
const denial = [...state.permissionDenials.values()].at(-1);
|
|
235
|
+
if (denial !== undefined)
|
|
236
|
+
finishResult = { ...finishResult, failure: { message: denial, code: 'PERMISSION_DENIED' } };
|
|
237
|
+
}
|
|
238
|
+
// A normal prompt stop does not confirm pending tool execution. Keep the
|
|
239
|
+
// observed arguments and make the unknown outcome explicit without retrying.
|
|
240
|
+
if (activeTools.size > 0) {
|
|
241
|
+
for (const [callId, toolName] of activeTools) {
|
|
242
|
+
const error = 'Grok ended the turn without reporting a final result for this tool; its outcome is unconfirmed.';
|
|
243
|
+
yield decorateCodingNsSegmentEvent({ type: 'tool-event', callId, toolName, status: 'failed', error, output: error, outputMode: 'snapshot' }, input, segmentState, this.descriptor.id);
|
|
169
244
|
}
|
|
170
|
-
|
|
245
|
+
if (finishResult.reason === 'stop')
|
|
246
|
+
finishResult = {
|
|
247
|
+
reason: 'error',
|
|
248
|
+
failure: { message: 'Grok ended the turn before all tool results were confirmed.', code: 'INCOMPLETE_TOOL_RESULT' },
|
|
249
|
+
};
|
|
171
250
|
}
|
|
251
|
+
reusable = finishResult.reason === 'stop' && !input.signal?.aborted;
|
|
172
252
|
yield { type: 'finish', reason: finishResult.reason, ...(finishResult.failure === undefined ? {} : { failure: finishResult.failure }) };
|
|
173
253
|
}
|
|
174
254
|
finally {
|
|
@@ -182,7 +262,15 @@ export class GrokBuildDriver {
|
|
|
182
262
|
state.grokQuestions.clear();
|
|
183
263
|
state.grokQuestionCallIds.clear();
|
|
184
264
|
state.grokQuestionEventIds.clear();
|
|
185
|
-
|
|
265
|
+
state.questions.clear();
|
|
266
|
+
state.requests.clear();
|
|
267
|
+
state.permissionDenials.clear();
|
|
268
|
+
if (!reusable) {
|
|
269
|
+
// An abandoned prompt can keep producing updates without prompt metadata.
|
|
270
|
+
// Reload its persisted session on a fresh transport before accepting new input.
|
|
271
|
+
await rpc.disposeAndWait();
|
|
272
|
+
this.processes.delete(rpc);
|
|
273
|
+
}
|
|
186
274
|
}
|
|
187
275
|
}
|
|
188
276
|
respondPermission(sessionId, response) {
|
|
@@ -194,7 +282,10 @@ export class GrokBuildDriver {
|
|
|
194
282
|
throw new Error('The Grok permission request does not exist');
|
|
195
283
|
state.requests.delete(response.requestId);
|
|
196
284
|
const optionId = response.approved ? pending.allowOptionId : pending.rejectOptionId;
|
|
197
|
-
|
|
285
|
+
if (!response.approved || optionId === undefined) {
|
|
286
|
+
state.permissionDenials.set(pending.callId ?? response.requestId, response.reason ?? (response.approved ? 'Grok did not offer a one-time approval option.' : 'Grok tool execution was denied.'));
|
|
287
|
+
}
|
|
288
|
+
state.rpc.respond(pending.rpcId, { outcome: optionId === undefined ? { outcome: 'cancelled' } : { outcome: 'selected', optionId } });
|
|
198
289
|
}
|
|
199
290
|
respondQuestion(sessionId, response) {
|
|
200
291
|
const state = this.sessions.get(sessionId);
|
|
@@ -216,25 +307,39 @@ export class GrokBuildDriver {
|
|
|
216
307
|
dispose() { for (const process of this.processes)
|
|
217
308
|
process.dispose(); this.processes.clear(); this.sessions.clear(); this.cachedBinary = null; }
|
|
218
309
|
async getSession(input, command) {
|
|
310
|
+
const alwaysApprove = input.permission?.sandboxMode === 'danger-full-access' && input.permission.approvalPolicy === 'never';
|
|
219
311
|
const previous = this.sessions.get(input.sessionId);
|
|
220
|
-
if (previous !== undefined && previous.cwd === input.cwd)
|
|
312
|
+
if (previous !== undefined && previous.cwd === input.cwd && previous.alwaysApprove === alwaysApprove && !previous.rpc.isClosed)
|
|
221
313
|
return previous;
|
|
222
|
-
previous
|
|
223
|
-
|
|
314
|
+
if (previous !== undefined) {
|
|
315
|
+
await previous.rpc.disposeAndWait();
|
|
316
|
+
this.processes.delete(previous.rpc);
|
|
317
|
+
}
|
|
318
|
+
const resumeId = input.providerSessionId ?? (previous?.cwd === input.cwd ? previous?.providerSessionId : undefined);
|
|
319
|
+
const rpc = new JsonRpcProcess({ command, args: ['agent', '--no-leader', ...(alwaysApprove ? ['--always-approve'] : []), 'stdio'], cwd: input.cwd, env: grokRuntimeEnvironment(), spawn: this.runSpawn });
|
|
224
320
|
this.processes.add(rpc);
|
|
225
|
-
const state = { rpc, cwd: input.cwd, rawStoreRef: input.rawStoreRef, providerSessionId: '', requests: new Map(), questions: new Map(), grokQuestions: new Map(), grokQuestionCallIds: new Set(), grokQuestionEventIds: new Set() };
|
|
226
|
-
|
|
321
|
+
const state = { rpc, contextUsage: new GrokContextUsage(), cwd: input.cwd, rawStoreRef: input.rawStoreRef, alwaysApprove, providerSessionId: '', requests: new Map(), permissionDenials: new Map(), questions: new Map(), grokQuestions: new Map(), grokQuestionCallIds: new Set(), grokQuestionEventIds: new Set() };
|
|
322
|
+
rpc.addNotificationListener(message => {
|
|
323
|
+
const params = isRecord(message.params) ? message.params : {};
|
|
324
|
+
const owner = state.providerSessionId || resumeId;
|
|
325
|
+
if (owner && typeof params.sessionId === 'string' && params.sessionId !== owner)
|
|
326
|
+
return;
|
|
327
|
+
state.contextUsage.observe(message);
|
|
328
|
+
});
|
|
329
|
+
const initialized = await rpc.request('initialize', {
|
|
227
330
|
protocolVersion: 1,
|
|
228
331
|
clientInfo: { name: 'codingns4dsh', version: '0.1.1' },
|
|
229
332
|
// 旧版 Grok 读取 capabilities;标准 ACP 读取 clientCapabilities。
|
|
230
333
|
capabilities: ACP_FORM_CLIENT_CAPABILITIES,
|
|
231
334
|
clientCapabilities: ACP_FORM_CLIENT_CAPABILITIES,
|
|
232
335
|
});
|
|
336
|
+
state.contextUsage.observe(initialized);
|
|
233
337
|
rpc.notify('initialized', {});
|
|
234
|
-
if (
|
|
338
|
+
if (resumeId) {
|
|
235
339
|
try {
|
|
236
|
-
const loaded = await rpc.request('session/load', { sessionId:
|
|
237
|
-
state.
|
|
340
|
+
const loaded = await rpc.request('session/load', { sessionId: resumeId, cwd: input.cwd ?? process.cwd(), mcpServers: acpBridgeMcpServers(input.sessionId, this.descriptor.id) });
|
|
341
|
+
state.contextUsage.observe(loaded);
|
|
342
|
+
state.providerSessionId = readSessionId(loaded) ?? resumeId;
|
|
238
343
|
}
|
|
239
344
|
catch { /* 旧版 ACP 没有 load,下一轮在同一进程创建新会话 */ }
|
|
240
345
|
}
|
|
@@ -263,7 +368,7 @@ export class GrokBuildDriver {
|
|
|
263
368
|
const requestId = interactionRequestId(message);
|
|
264
369
|
if (requestId === null || message.id === undefined || message.id === null)
|
|
265
370
|
return { outcome: { outcome: 'cancelled' } };
|
|
266
|
-
state.requests.set(requestId, { rpcId: message.id, ...permissionOptions(message) });
|
|
371
|
+
state.requests.set(requestId, { rpcId: message.id, callId: permissionCallId(message), ...permissionOptions(message) });
|
|
267
372
|
return new Promise(() => undefined);
|
|
268
373
|
});
|
|
269
374
|
this.sessions.set(input.sessionId, state);
|
|
@@ -293,13 +398,14 @@ const GROK_QUESTION_GUIDANCE = [
|
|
|
293
398
|
* Grok 可能先返回 prompt 响应,再补发最后一批 session/update。
|
|
294
399
|
* 响应或终态任一先到都会启动固定排空窗口,窗口内的文本和错误仍会被消费。
|
|
295
400
|
*/
|
|
296
|
-
async function* streamGrokPrompt(rpc, sessionId, prompt, signal, onNotification) {
|
|
401
|
+
async function* streamGrokPrompt(rpc, sessionId, promptId, prompt, signal, onNotification, onResponse) {
|
|
297
402
|
const queue = [];
|
|
298
403
|
const requestController = new AbortController();
|
|
299
404
|
let wake;
|
|
300
405
|
let drainDeadline = null;
|
|
301
406
|
let terminalReason = null;
|
|
302
407
|
let failure;
|
|
408
|
+
let completed = false;
|
|
303
409
|
const notify = () => { wake?.(); wake = undefined; };
|
|
304
410
|
const beginDrain = () => {
|
|
305
411
|
if (drainDeadline === null)
|
|
@@ -307,8 +413,10 @@ async function* streamGrokPrompt(rpc, sessionId, prompt, signal, onNotification)
|
|
|
307
413
|
notify();
|
|
308
414
|
};
|
|
309
415
|
const listener = (message) => {
|
|
310
|
-
|
|
311
|
-
|
|
416
|
+
if (!isGrokPromptMessage(message, sessionId, promptId))
|
|
417
|
+
return;
|
|
418
|
+
const observation = onNotification(message);
|
|
419
|
+
queue.push(observation === undefined ? message : { ...message, codingnsGrokObservation: observation });
|
|
312
420
|
const notificationReason = grokNotificationReason(message);
|
|
313
421
|
if (notificationReason === null) {
|
|
314
422
|
notify();
|
|
@@ -320,8 +428,6 @@ async function* streamGrokPrompt(rpc, sessionId, prompt, signal, onNotification)
|
|
|
320
428
|
if (detail !== undefined)
|
|
321
429
|
failure = detail;
|
|
322
430
|
}
|
|
323
|
-
// 部分 Grok 版本只发终态通知而不回复 prompt,主动取消可清理待处理请求。
|
|
324
|
-
requestController.abort();
|
|
325
431
|
beginDrain();
|
|
326
432
|
};
|
|
327
433
|
const removeListener = rpc.addNotificationListener(listener);
|
|
@@ -336,19 +442,29 @@ async function* streamGrokPrompt(rpc, sessionId, prompt, signal, onNotification)
|
|
|
336
442
|
onAbort();
|
|
337
443
|
else
|
|
338
444
|
signal?.addEventListener('abort', onAbort, { once: true });
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
445
|
+
if (!signal?.aborted)
|
|
446
|
+
void rpc.request('session/prompt', {
|
|
447
|
+
sessionId,
|
|
448
|
+
prompt,
|
|
449
|
+
_meta: { promptId },
|
|
450
|
+
}, { signal: requestController.signal, killOnAbort: false }).then((response) => {
|
|
451
|
+
if (signal?.aborted)
|
|
452
|
+
return;
|
|
453
|
+
const observation = onResponse(response);
|
|
454
|
+
if (observation !== undefined)
|
|
455
|
+
queue.push({ method: 'codingns/grok-observation', codingnsGrokObservation: observation });
|
|
456
|
+
const responseReason = grokPromptReason(response);
|
|
457
|
+
if (responseReason !== null)
|
|
458
|
+
terminalReason = mergeGrokReason(terminalReason, responseReason);
|
|
459
|
+
failure ??= grokPermissionFailure(response);
|
|
460
|
+
beginDrain();
|
|
461
|
+
}, () => {
|
|
462
|
+
if (requestController.signal.aborted)
|
|
463
|
+
return;
|
|
464
|
+
if (terminalReason === null)
|
|
465
|
+
terminalReason = signal?.aborted ? 'cancel' : 'error';
|
|
466
|
+
beginDrain();
|
|
467
|
+
});
|
|
352
468
|
try {
|
|
353
469
|
while (true) {
|
|
354
470
|
if (queue.length > 0) {
|
|
@@ -368,18 +484,81 @@ async function* streamGrokPrompt(rpc, sessionId, prompt, signal, onNotification)
|
|
|
368
484
|
]);
|
|
369
485
|
wake = undefined;
|
|
370
486
|
}
|
|
487
|
+
completed = true;
|
|
371
488
|
return { reason: terminalReason ?? 'stop', ...(failure === undefined ? {} : { failure }) };
|
|
372
489
|
}
|
|
373
490
|
finally {
|
|
374
491
|
signal?.removeEventListener('abort', onAbort);
|
|
375
492
|
removeListener();
|
|
493
|
+
if (!completed || signal?.aborted) {
|
|
494
|
+
// ACP cancellation is a notification; waiting for an RPC response can hang.
|
|
495
|
+
try {
|
|
496
|
+
rpc.notify('session/cancel', { sessionId });
|
|
497
|
+
}
|
|
498
|
+
catch { /* The process may already have exited. */ }
|
|
499
|
+
}
|
|
500
|
+
// Terminal-only providers and consumers that close the iterator both need cleanup.
|
|
501
|
+
requestController.abort();
|
|
376
502
|
}
|
|
377
503
|
}
|
|
504
|
+
function isGrokPromptMessage(message, sessionId, promptId) {
|
|
505
|
+
const params = isRecord(message.params) ? message.params : message;
|
|
506
|
+
if (typeof params.sessionId === 'string' && params.sessionId !== sessionId)
|
|
507
|
+
return false;
|
|
508
|
+
const update = isRecord(params.update) ? params.update : params;
|
|
509
|
+
const meta = isRecord(params._meta) ? params._meta : {};
|
|
510
|
+
if (meta.isReplay === true)
|
|
511
|
+
return false;
|
|
512
|
+
const owner = firstToolText(update.prompt_id, update.promptId, meta.promptId);
|
|
513
|
+
return owner === undefined || owner === promptId;
|
|
514
|
+
}
|
|
515
|
+
function grokToolInputChunks(message, inputs) {
|
|
516
|
+
const params = isRecord(message.params) ? message.params : message;
|
|
517
|
+
const update = isRecord(params.update) ? params.update : params;
|
|
518
|
+
if (update.sessionUpdate !== 'tool_call_delta_chunk' || !Number.isInteger(update.tool_index))
|
|
519
|
+
return null;
|
|
520
|
+
const index = update.tool_index;
|
|
521
|
+
const callId = firstToolText(update.tool_call_id, update.toolCallId);
|
|
522
|
+
// Argument fragments omit the call id; a new id resets a reused model-call index.
|
|
523
|
+
let pending = inputs.get(index);
|
|
524
|
+
const started = callId !== undefined && pending?.callId !== callId;
|
|
525
|
+
if (started) {
|
|
526
|
+
pending = { callId, toolName: firstToolText(update.name, update.title) ?? 'tool', arguments: '' };
|
|
527
|
+
inputs.set(index, pending);
|
|
528
|
+
}
|
|
529
|
+
if (pending === undefined)
|
|
530
|
+
return [];
|
|
531
|
+
if (typeof update.arguments_delta === 'string')
|
|
532
|
+
pending.arguments += update.arguments_delta;
|
|
533
|
+
let input;
|
|
534
|
+
try {
|
|
535
|
+
const parsed = JSON.parse(pending.arguments);
|
|
536
|
+
if (isRecord(parsed))
|
|
537
|
+
input = JSON.stringify(parsed);
|
|
538
|
+
}
|
|
539
|
+
catch { /* Do not persist incomplete JSON as a tool's final arguments. */ }
|
|
540
|
+
if (!started && input === undefined)
|
|
541
|
+
return [];
|
|
542
|
+
return [{
|
|
543
|
+
type: 'tool-event', callId: pending.callId, toolName: pending.toolName, status: 'running',
|
|
544
|
+
...(input === undefined ? {} : { input }),
|
|
545
|
+
}];
|
|
546
|
+
}
|
|
378
547
|
function grokPromptReason(value) {
|
|
379
|
-
if (!isRecord(value)
|
|
548
|
+
if (!isRecord(value))
|
|
380
549
|
return null;
|
|
381
|
-
const reason = value.stopReason.toLowerCase();
|
|
382
|
-
|
|
550
|
+
const reason = firstToolText(value.stopReason, value.stop_reason)?.toLowerCase();
|
|
551
|
+
if (reason === undefined)
|
|
552
|
+
return null;
|
|
553
|
+
if (reason === 'cancelled' || reason === 'canceled')
|
|
554
|
+
return grokPermissionFailure(value) === undefined ? 'cancel' : 'error';
|
|
555
|
+
return reason === 'error' || reason === 'failed' ? 'error' : 'stop';
|
|
556
|
+
}
|
|
557
|
+
function grokPermissionFailure(value) {
|
|
558
|
+
if (!isRecord(value) || !isRecord(value._meta) || value._meta.cancellationCategory !== 'PermissionRejected')
|
|
559
|
+
return undefined;
|
|
560
|
+
const context = isRecord(value._meta.cancellationContext) ? value._meta.cancellationContext : {};
|
|
561
|
+
return { message: firstToolText(context.reason) ?? 'Grok tool execution was denied.', code: 'PERMISSION_DENIED' };
|
|
383
562
|
}
|
|
384
563
|
function mergeGrokReason(current, next) {
|
|
385
564
|
if (current === 'error' || next === 'error')
|
|
@@ -396,15 +575,20 @@ function grokNotificationReason(message) {
|
|
|
396
575
|
: typeof update.type === 'string'
|
|
397
576
|
? update.type.toLowerCase()
|
|
398
577
|
: '';
|
|
399
|
-
if (
|
|
578
|
+
if (['turn_error', 'turn_failed', 'error', 'failed'].includes(type))
|
|
400
579
|
return 'error';
|
|
401
|
-
if (
|
|
402
|
-
|
|
580
|
+
if (['turn_completed', 'turn_complete', 'prompt_complete', 'completed', 'done'].includes(type)) {
|
|
581
|
+
const reason = grokPromptReason(update) ?? 'stop';
|
|
582
|
+
return reason === 'cancel' && grokPermissionFailure(params) !== undefined ? 'error' : reason;
|
|
583
|
+
}
|
|
403
584
|
return null;
|
|
404
585
|
}
|
|
405
586
|
function grokFailure(message) {
|
|
406
587
|
const params = isRecord(message.params) ? message.params : message;
|
|
407
588
|
const update = isRecord(params.update) ? params.update : params;
|
|
589
|
+
const permissionFailure = grokPermissionFailure(update) ?? grokPermissionFailure(params);
|
|
590
|
+
if (permissionFailure !== undefined)
|
|
591
|
+
return permissionFailure;
|
|
408
592
|
const error = isRecord(update.error) ? update.error : update;
|
|
409
593
|
const detail = firstToolText(error.message, error.errorMessage, error.error_message, error.detail, error.reason);
|
|
410
594
|
if (detail === undefined)
|
|
@@ -481,6 +665,23 @@ function grokQuestionResponse(pending, response) {
|
|
|
481
665
|
...(Object.keys(annotations).length === 0 ? {} : { annotations }),
|
|
482
666
|
};
|
|
483
667
|
}
|
|
668
|
+
function grokStreamId(message) {
|
|
669
|
+
const params = isRecord(message.params) ? message.params : message;
|
|
670
|
+
const meta = isRecord(params._meta) ? params._meta : {};
|
|
671
|
+
return typeof meta.streamStartMs === 'number' && Number.isFinite(meta.streamStartMs)
|
|
672
|
+
? `grok-stream-${meta.streamStartMs}` : undefined;
|
|
673
|
+
}
|
|
674
|
+
function grokStepPhase(event) {
|
|
675
|
+
switch (event.type) {
|
|
676
|
+
case 'text-delta':
|
|
677
|
+
case 'reasoning-delta': return event.text.length > 0 ? 'message' : undefined;
|
|
678
|
+
case 'image-artifact': return 'message';
|
|
679
|
+
case 'tool-event':
|
|
680
|
+
case 'question-request':
|
|
681
|
+
case 'permission-request': return 'tools';
|
|
682
|
+
default: return undefined;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
484
685
|
function acpMessageToChunks(message) {
|
|
485
686
|
const params = isRecord(message.params) ? message.params : message;
|
|
486
687
|
const update = isRecord(params.update) ? params.update : params;
|
|
@@ -506,9 +707,12 @@ function acpMessageToChunks(message) {
|
|
|
506
707
|
const markdownPaths = imageArtifactPathsFromValue(text ?? '');
|
|
507
708
|
const imagePaths = [...new Set([...artifactPaths, ...markdownPaths])];
|
|
508
709
|
const imageEvents = imagePaths.map((path) => ({ type: 'image-artifact', path }));
|
|
710
|
+
// Grok identifies each model call independently of the enclosing user prompt.
|
|
711
|
+
const messageId = grokStreamId(message);
|
|
712
|
+
const identity = messageId === undefined ? {} : { messageId };
|
|
509
713
|
const reasoning = reasoningText(update);
|
|
510
714
|
if (reasoning !== null)
|
|
511
|
-
return [...imageEvents, { type: 'reasoning-delta', text: reasoning }];
|
|
715
|
+
return [...imageEvents, { type: 'reasoning-delta', text: reasoning, ...identity }];
|
|
512
716
|
if (type.includes('permission')) {
|
|
513
717
|
const requestId = permissionRequestId(message) ?? (typeof update.requestId === 'string' ? update.requestId : typeof update.id === 'string' ? update.id : null);
|
|
514
718
|
if (requestId !== null) {
|
|
@@ -520,13 +724,13 @@ function acpMessageToChunks(message) {
|
|
|
520
724
|
}
|
|
521
725
|
if (type.includes('agent_message') || type.includes('text') || type === 'message') {
|
|
522
726
|
const visible = text === null ? '' : stripImageMarkdown(text, markdownPaths);
|
|
523
|
-
const textEvent = visible === '' ? undefined : { type: 'text-delta', text: visible };
|
|
727
|
+
const textEvent = visible === '' ? undefined : { type: 'text-delta', text: visible, ...identity };
|
|
524
728
|
return [...imageEvents, ...(textEvent === undefined ? [] : [textEvent])];
|
|
525
729
|
}
|
|
526
730
|
if (type.includes('image') || type.includes('artifact') || type.includes('generated'))
|
|
527
731
|
return imageEvents;
|
|
528
732
|
if (type.includes('thought') || type.includes('reason'))
|
|
529
|
-
return text ? [{ type: 'reasoning-delta', text }] : [];
|
|
733
|
+
return text ? [{ type: 'reasoning-delta', text, ...identity }] : [];
|
|
530
734
|
if (type.includes('tool') || type.includes('command')) {
|
|
531
735
|
const tool = isToolRecord(update.toolCall) ? update.toolCall : isToolRecord(update.tool_call) ? update.tool_call : update;
|
|
532
736
|
const name = firstToolText(tool.name, tool.toolName, tool.tool_name, tool.title, update.name, update.toolName, update.title);
|
|
@@ -534,13 +738,19 @@ function acpMessageToChunks(message) {
|
|
|
534
738
|
if (!name && !callId)
|
|
535
739
|
return [];
|
|
536
740
|
const input = serializeToolValue(tool.rawInput ?? tool.input ?? tool.arguments ?? tool.args ?? update.rawInput);
|
|
537
|
-
|
|
741
|
+
// ACP tool results can contain nested text blocks without a rawOutput field.
|
|
742
|
+
const content = tool.content ?? update.content;
|
|
743
|
+
const contentText = Array.isArray(content)
|
|
744
|
+
? content.flatMap((block) => isRecord(block) ? textValue(block.content ?? block) ?? [] : []).join('\n') || undefined
|
|
745
|
+
: undefined;
|
|
746
|
+
const rawOutput = serializeToolValue(tool.rawOutput ?? tool.output ?? tool.result ?? update.rawOutput);
|
|
747
|
+
const output = rawOutput ?? contentText;
|
|
538
748
|
const error = serializeToolValue(tool.error ?? update.error);
|
|
539
749
|
const agentId = firstToolText(tool.agentId, tool.agent_id, update.agentId, update.agent_id);
|
|
540
750
|
const detail = serializeToolValue(tool.detail ?? update.detail ?? update.content);
|
|
541
751
|
const fallback = error !== undefined || type.includes('error') || type.includes('fail')
|
|
542
752
|
? 'failed'
|
|
543
|
-
:
|
|
753
|
+
: rawOutput !== undefined || type.includes('result') || type.includes('complete')
|
|
544
754
|
? 'completed'
|
|
545
755
|
: 'running';
|
|
546
756
|
return [...imageEvents, {
|
|
@@ -599,6 +809,12 @@ function permissionRequestId(message) {
|
|
|
599
809
|
function interactionRequestId(message) {
|
|
600
810
|
return permissionRequestId(message);
|
|
601
811
|
}
|
|
812
|
+
function permissionCallId(message) {
|
|
813
|
+
const params = isRecord(message.params) ? message.params : message;
|
|
814
|
+
const update = isRecord(params.update) ? params.update : params;
|
|
815
|
+
const tool = isRecord(update.toolCall) ? update.toolCall : isRecord(update.tool_call) ? update.tool_call : update;
|
|
816
|
+
return firstToolText(tool.toolCallId, tool.tool_call_id, tool.callId, tool.call_id);
|
|
817
|
+
}
|
|
602
818
|
function permissionOptions(message) {
|
|
603
819
|
const params = isRecord(message.params) ? message.params : {};
|
|
604
820
|
const options = Array.isArray(params.options) ? params.options : [];
|
|
@@ -610,9 +826,17 @@ function permissionOptions(message) {
|
|
|
610
826
|
return [];
|
|
611
827
|
return [{ id, kind: firstToolText(option.kind, option.type)?.toLowerCase() ?? '' }];
|
|
612
828
|
});
|
|
829
|
+
if (ids.length === 0)
|
|
830
|
+
return { allowOptionId: 'allow-once', rejectOptionId: 'reject-once' };
|
|
831
|
+
// Grok lists allow_always before allow_once. A DSH one-time approval must
|
|
832
|
+
// never become a persistent grant merely because of provider option order.
|
|
613
833
|
return {
|
|
614
|
-
allowOptionId: ids.find((option) =>
|
|
615
|
-
|
|
834
|
+
allowOptionId: ids.find((option) => option.kind === 'allow_once')?.id
|
|
835
|
+
?? ids.find((option) => /^(allow|approve|accept)$/u.test(option.kind))?.id
|
|
836
|
+
?? (ids[0]?.kind === '' ? ids[0].id : undefined),
|
|
837
|
+
rejectOptionId: ids.find((option) => option.kind === 'reject_once')?.id
|
|
838
|
+
?? ids.find((option) => /^(reject|deny|decline|cancel)$/u.test(option.kind))?.id
|
|
839
|
+
?? (ids[1]?.kind === '' ? ids[1].id : undefined),
|
|
616
840
|
};
|
|
617
841
|
}
|
|
618
842
|
function readSessionId(value) {
|