@jingyi0605/codingns4dsh 0.2.1-beta.9 → 0.2.1-rc.2
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 +8 -6
- package/README.md +11 -8
- package/assets/provider-icons/magpie.png +0 -0
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +1 -1
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts.map +1 -1
- package/data/build/dist/bootstrap/index.d.ts +1 -1
- package/data/build/dist/bootstrap/index.d.ts.map +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 +10 -2
- package/data/build/dist/client/adapter-catalog-watch.d.ts.map +1 -1
- package/data/build/dist/client/adapter-catalog-watch.js +16 -4
- package/data/build/dist/client/adapter-catalog-watch.js.map +1 -1
- package/data/build/dist/client/bundle.js +54516 -35293
- 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 +17 -3
- package/data/build/dist/client/cli-slots.d.ts.map +1 -1
- package/data/build/dist/client/cli-slots.js +300 -41
- package/data/build/dist/client/cli-slots.js.map +1 -1
- package/data/build/dist/client/client.assistant-configuration-view.js +4 -3
- package/data/build/dist/client/client.assistant-configuration-view.js.map +1 -1
- package/data/build/dist/client/client.delegate-command.js +44 -26
- package/data/build/dist/client/client.delegate-command.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.model-catalog-cache.js → client.magpie-model-tag.js} +241 -12
- package/data/build/dist/client/client.magpie-model-tag.js.map +1 -0
- package/data/build/dist/client/client.moss-voice-output.js +415 -0
- package/data/build/dist/client/client.moss-voice-output.js.map +1 -0
- package/data/build/dist/client/client.native-workspace-store.js +65 -15
- package/data/build/dist/client/client.native-workspace-store.js.map +1 -1
- package/data/build/dist/client/client.primitives-adapter.js +128 -0
- package/data/build/dist/client/client.primitives-adapter.js.map +1 -1
- package/data/build/dist/client/client.react-dom.js +0 -404
- package/data/build/dist/client/client.react-dom.js.map +1 -1
- package/data/build/dist/client/client.session-translation.js +121 -2
- package/data/build/dist/client/client.session-translation.js.map +1 -1
- package/data/build/dist/client/client.transport.js +738 -57
- 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/delegate-command.d.ts.map +1 -1
- package/data/build/dist/client/delegate-command.js +36 -7
- package/data/build/dist/client/delegate-command.js.map +1 -1
- package/data/build/dist/client/desktop-assistant.js +1202 -494
- 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 +207 -112
- 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 +18 -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/lan-access-panel.d.ts.map +1 -1
- package/data/build/dist/client/features/lan-access-panel.js +1 -0
- package/data/build/dist/client/features/lan-access-panel.js.map +1 -1
- package/data/build/dist/client/features/mobile-access.d.ts.map +1 -1
- package/data/build/dist/client/features/mobile-access.js +7 -0
- package/data/build/dist/client/features/mobile-access.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 +6 -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 +50 -49
- package/data/build/dist/client/features/session-translation.js.map +1 -1
- package/data/build/dist/client/features/workspace-session-enhancement.d.ts.map +1 -1
- package/data/build/dist/client/features/workspace-session-enhancement.js +6 -0
- package/data/build/dist/client/features/workspace-session-enhancement.js.map +1 -1
- package/data/build/dist/client/file-management-dom.d.ts +20 -1
- package/data/build/dist/client/file-management-dom.d.ts.map +1 -1
- package/data/build/dist/client/file-management-dom.js +94 -18
- package/data/build/dist/client/file-management-dom.js.map +1 -1
- package/data/build/dist/client/file-viewer-copy-path-menu.d.ts +27 -0
- package/data/build/dist/client/file-viewer-copy-path-menu.d.ts.map +1 -0
- package/data/build/dist/client/file-viewer-copy-path-menu.js +101 -0
- package/data/build/dist/client/file-viewer-copy-path-menu.js.map +1 -0
- package/data/build/dist/client/git-management-settings.d.ts +4 -0
- package/data/build/dist/client/git-management-settings.d.ts.map +1 -0
- package/data/build/dist/client/git-management-settings.js +73 -0
- package/data/build/dist/client/git-management-settings.js.map +1 -0
- package/data/build/dist/client/git-management.d.ts +2 -1
- package/data/build/dist/client/git-management.d.ts.map +1 -1
- package/data/build/dist/client/git-management.js +55 -34
- package/data/build/dist/client/git-management.js.map +1 -1
- package/data/build/dist/client/git-panel-styles.d.ts +4 -0
- package/data/build/dist/client/git-panel-styles.d.ts.map +1 -1
- package/data/build/dist/client/git-panel-styles.js +14 -0
- package/data/build/dist/client/git-panel-styles.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 +22 -2
- 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 +155 -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 +8 -0
- package/data/build/dist/client/locales/fileWorkspace.js.map +1 -1
- package/data/build/dist/client/locales/git.d.ts.map +1 -1
- package/data/build/dist/client/locales/git.js +30 -2
- package/data/build/dist/client/locales/git.js.map +1 -1
- package/data/build/dist/client/locales/panels.d.ts.map +1 -1
- package/data/build/dist/client/locales/panels.js +103 -11
- package/data/build/dist/client/locales/panels.js.map +1 -1
- package/data/build/dist/client/locales/peerHost.d.ts.map +1 -1
- package/data/build/dist/client/locales/peerHost.js +2 -0
- package/data/build/dist/client/locales/peerHost.js.map +1 -1
- package/data/build/dist/client/locales/quickApps.d.ts +136 -0
- package/data/build/dist/client/locales/quickApps.d.ts.map +1 -0
- package/data/build/dist/client/locales/quickApps.js +162 -0
- package/data/build/dist/client/locales/quickApps.js.map +1 -0
- package/data/build/dist/client/locales/usage.d.ts.map +1 -1
- package/data/build/dist/client/locales/usage.js +98 -0
- package/data/build/dist/client/locales/usage.js.map +1 -1
- package/data/build/dist/client/magpie-model-tag.d.ts +8 -0
- package/data/build/dist/client/magpie-model-tag.d.ts.map +1 -0
- package/data/build/dist/client/magpie-model-tag.js +50 -0
- package/data/build/dist/client/magpie-model-tag.js.map +1 -0
- package/data/build/dist/client/mobile-team-panel-dom.d.ts +14 -0
- package/data/build/dist/client/mobile-team-panel-dom.d.ts.map +1 -0
- package/data/build/dist/client/mobile-team-panel-dom.js +164 -0
- package/data/build/dist/client/mobile-team-panel-dom.js.map +1 -0
- package/data/build/dist/client/model-catalog-cache.d.ts.map +1 -1
- package/data/build/dist/client/model-catalog-cache.js +66 -12
- package/data/build/dist/client/model-catalog-cache.js.map +1 -1
- package/data/build/dist/client/model-priority-pool.d.ts +23 -0
- package/data/build/dist/client/model-priority-pool.d.ts.map +1 -0
- package/data/build/dist/client/model-priority-pool.js +245 -0
- package/data/build/dist/client/model-priority-pool.js.map +1 -0
- package/data/build/dist/client/native-model-translation-menu.d.ts +13 -0
- package/data/build/dist/client/native-model-translation-menu.d.ts.map +1 -0
- package/data/build/dist/client/native-model-translation-menu.js +159 -0
- package/data/build/dist/client/native-model-translation-menu.js.map +1 -0
- package/data/build/dist/client/native-translation-default.d.ts +6 -0
- package/data/build/dist/client/native-translation-default.d.ts.map +1 -0
- package/data/build/dist/client/native-translation-default.js +30 -0
- package/data/build/dist/client/native-translation-default.js.map +1 -0
- package/data/build/dist/client/provider-icons.d.ts.map +1 -1
- package/data/build/dist/client/provider-icons.js +3 -1
- package/data/build/dist/client/provider-icons.js.map +1 -1
- package/data/build/dist/client/quick-apps/browser-storage.d.ts +24 -0
- package/data/build/dist/client/quick-apps/browser-storage.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/browser-storage.js +114 -0
- package/data/build/dist/client/quick-apps/browser-storage.js.map +1 -0
- package/data/build/dist/client/quick-apps/client.d.ts +31 -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 +267 -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 +47 -0
- package/data/build/dist/client/quick-apps/presentation.js.map +1 -0
- package/data/build/dist/client/quick-apps/rail-preference.d.ts +5 -0
- package/data/build/dist/client/quick-apps/rail-preference.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/rail-preference.js +19 -0
- package/data/build/dist/client/quick-apps/rail-preference.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 +153 -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 +165 -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 +68 -2
- package/data/build/dist/client/session-translation-chat.d.ts.map +1 -1
- package/data/build/dist/client/session-translation-chat.js +297 -109
- package/data/build/dist/client/session-translation-chat.js.map +1 -1
- package/data/build/dist/client/session-translation-interactions.d.ts +31 -0
- package/data/build/dist/client/session-translation-interactions.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-interactions.js +158 -0
- package/data/build/dist/client/session-translation-interactions.js.map +1 -0
- package/data/build/dist/client/session-translation-pending-dom.d.ts +8 -0
- package/data/build/dist/client/session-translation-pending-dom.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-pending-dom.js +58 -0
- package/data/build/dist/client/session-translation-pending-dom.js.map +1 -0
- 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/subscription-slot.d.ts +6 -2
- package/data/build/dist/client/subscription-slot.d.ts.map +1 -1
- package/data/build/dist/client/subscription-slot.js +373 -21
- package/data/build/dist/client/subscription-slot.js.map +1 -1
- 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/client/workspace-session-archive-dom.d.ts +1 -0
- package/data/build/dist/client/workspace-session-archive-dom.d.ts.map +1 -1
- package/data/build/dist/client/workspace-session-archive-dom.js +68 -8
- package/data/build/dist/client/workspace-session-archive-dom.js.map +1 -1
- package/data/build/dist/client/workspace-session-rightbar-dom.d.ts.map +1 -1
- package/data/build/dist/client/workspace-session-rightbar-dom.js +12 -21
- package/data/build/dist/client/workspace-session-rightbar-dom.js.map +1 -1
- package/data/build/dist/client/workspace-session-visibility-dom.d.ts +3 -0
- package/data/build/dist/client/workspace-session-visibility-dom.d.ts.map +1 -1
- package/data/build/dist/client/workspace-session-visibility-dom.js +43 -10
- package/data/build/dist/client/workspace-session-visibility-dom.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.d.ts +8 -0
- package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.js +71 -0
- package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.js.map +1 -0
- 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 +30 -0
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js +93 -0
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.d.ts +12 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js +181 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js.map +1 -0
- 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/peer-host-attachment-adapter.d.ts +3 -0
- package/data/build/dist/dsh-capabilities/client/peer-host-attachment-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/peer-host-attachment-adapter.js +27 -0
- package/data/build/dist/dsh-capabilities/client/peer-host-attachment-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts +36 -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 +88 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.d.ts +20 -0
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.js +65 -0
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.js.map +1 -0
- 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 +9 -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 +75 -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 +32 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js +90 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.d.ts +52 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.js +109 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.js.map +1 -0
- 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 +22 -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 +47 -3
- 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/acp-cli-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/acp-cli-driver.js +6 -3
- package/data/build/dist/host/cli-adapters/acp-cli-driver.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 +184 -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 +126 -21
- 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-acp-loader.d.ts +4 -1
- package/data/build/dist/host/cli-adapters/command-code-acp-loader.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/command-code-acp-loader.js +137 -25
- package/data/build/dist/host/cli-adapters/command-code-acp-loader.js.map +1 -1
- package/data/build/dist/host/cli-adapters/command-code-driver.js +7 -4
- package/data/build/dist/host/cli-adapters/command-code-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts +3 -1
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.js +41 -4
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.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 +5 -1
- 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 +51 -16
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-tool-history.js +3 -2
- package/data/build/dist/host/cli-adapters/dsh-tool-history.js.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-virtual-providers.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js +3 -2
- package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.d.ts +4 -0
- package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.js +587 -101
- package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.js +5 -3
- package/data/build/dist/host/cli-adapters/gemini-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts +7 -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 +458 -59
- 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 +48 -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/legacy-session-adapter.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/legacy-session-adapter.js +20 -3
- package/data/build/dist/host/cli-adapters/legacy-session-adapter.js.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-session-routing.d.ts +9 -0
- package/data/build/dist/host/cli-adapters/magpie-session-routing.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/magpie-session-routing.js +90 -0
- package/data/build/dist/host/cli-adapters/magpie-session-routing.js.map +1 -0
- package/data/build/dist/host/cli-adapters/magpie-usage.d.ts +90 -0
- package/data/build/dist/host/cli-adapters/magpie-usage.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/magpie-usage.js +986 -0
- package/data/build/dist/host/cli-adapters/magpie-usage.js.map +1 -0
- 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 +37 -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 +144 -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 +62 -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 +177 -0
- package/data/build/dist/host/cli-adapters/management.js.map +1 -0
- package/data/build/dist/host/cli-adapters/mcode-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/mcode-driver.js +12 -5
- 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 +70 -7
- package/data/build/dist/host/cli-adapters/model-catalog.js.map +1 -1
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts +1 -1
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js +13 -5
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js.map +1 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts +7 -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 +6 -3
- 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/opencode-v2-protocol.js +4 -1
- package/data/build/dist/host/cli-adapters/opencode-v2-protocol.js.map +1 -1
- package/data/build/dist/host/cli-adapters/pi-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/pi-driver.js +45 -11
- 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 +7 -1
- package/data/build/dist/host/cli-adapters/registry.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/registry.js +141 -51
- 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/standard-stream-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/standard-stream-driver.js +4 -0
- package/data/build/dist/host/cli-adapters/standard-stream-driver.js.map +1 -1
- 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/subagent-tool-descriptions.d.ts +26 -0
- package/data/build/dist/host/cli-adapters/subagent-tool-descriptions.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/subagent-tool-descriptions.js +30 -0
- package/data/build/dist/host/cli-adapters/subagent-tool-descriptions.js.map +1 -0
- package/data/build/dist/host/cli-adapters/subagent-tool.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/subagent-tool.js +7 -6
- package/data/build/dist/host/cli-adapters/subagent-tool.js.map +1 -1
- package/data/build/dist/host/cli-adapters/team-input.d.ts +17 -0
- package/data/build/dist/host/cli-adapters/team-input.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/team-input.js +67 -0
- package/data/build/dist/host/cli-adapters/team-input.js.map +1 -0
- 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.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/zcode-driver.js +7 -2
- package/data/build/dist/host/cli-adapters/zcode-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/zcode-update.d.ts +8 -0
- package/data/build/dist/host/cli-adapters/zcode-update.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/zcode-update.js +149 -0
- package/data/build/dist/host/cli-adapters/zcode-update.js.map +1 -0
- package/data/build/dist/host/cli-bridge/bridge-holder.d.ts +14 -0
- package/data/build/dist/host/cli-bridge/bridge-holder.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/bridge-holder.js +53 -6
- package/data/build/dist/host/cli-bridge/bridge-holder.js.map +1 -1
- package/data/build/dist/host/cli-bridge/bridge-server.d.ts +8 -0
- package/data/build/dist/host/cli-bridge/bridge-server.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/bridge-server.js +63 -6
- package/data/build/dist/host/cli-bridge/bridge-server.js.map +1 -1
- package/data/build/dist/host/cli-bridge/command-code-mod.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/command-code-mod.js +128 -0
- package/data/build/dist/host/cli-bridge/command-code-mod.js.map +1 -1
- package/data/build/dist/host/cli-bridge/dispatch.js +1 -1
- package/data/build/dist/host/cli-bridge/dispatch.js.map +1 -1
- package/data/build/dist/host/cli-bridge/fetch-dispatch.d.ts +23 -0
- package/data/build/dist/host/cli-bridge/fetch-dispatch.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/fetch-dispatch.js +73 -0
- package/data/build/dist/host/cli-bridge/fetch-dispatch.js.map +1 -0
- package/data/build/dist/host/cli-bridge/injections.d.ts +14 -0
- package/data/build/dist/host/cli-bridge/injections.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/injections.js +69 -7
- package/data/build/dist/host/cli-bridge/injections.js.map +1 -1
- package/data/build/dist/host/cli-bridge/mcp-stdio-entry.d.ts +1 -1
- package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js +102 -7
- package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js.map +1 -1
- package/data/build/dist/host/cli-bridge/pi-extension-entry.d.ts +3 -0
- package/data/build/dist/host/cli-bridge/pi-extension-entry.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/pi-extension-entry.js +9 -0
- package/data/build/dist/host/cli-bridge/pi-extension-entry.js.map +1 -0
- package/data/build/dist/host/cli-bridge/pi-extension.d.ts +52 -0
- package/data/build/dist/host/cli-bridge/pi-extension.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/pi-extension.js +311 -0
- package/data/build/dist/host/cli-bridge/pi-extension.js.map +1 -0
- package/data/build/dist/host/cli-bridge/search-dispatch.d.ts +20 -0
- package/data/build/dist/host/cli-bridge/search-dispatch.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/search-dispatch.js +61 -0
- package/data/build/dist/host/cli-bridge/search-dispatch.js.map +1 -0
- package/data/build/dist/host/cli-bridge/team-adapters.d.ts +11 -0
- package/data/build/dist/host/cli-bridge/team-adapters.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/team-adapters.js +23 -0
- package/data/build/dist/host/cli-bridge/team-adapters.js.map +1 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.d.ts +28 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.js +208 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.js.map +1 -0
- package/data/build/dist/host/cli-bridge/team-tool.d.ts +3 -0
- package/data/build/dist/host/cli-bridge/team-tool.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/team-tool.js +18 -0
- package/data/build/dist/host/cli-bridge/team-tool.js.map +1 -0
- package/data/build/dist/host/features/file-management.d.ts.map +1 -1
- package/data/build/dist/host/features/file-management.js +10 -1
- package/data/build/dist/host/features/file-management.js.map +1 -1
- package/data/build/dist/host/features/git-commit-message.d.ts +5 -0
- package/data/build/dist/host/features/git-commit-message.d.ts.map +1 -0
- package/data/build/dist/host/features/git-commit-message.js +66 -0
- package/data/build/dist/host/features/git-commit-message.js.map +1 -0
- package/data/build/dist/host/features/git-management.d.ts +11 -2
- package/data/build/dist/host/features/git-management.d.ts.map +1 -1
- package/data/build/dist/host/features/git-management.js +61 -7
- package/data/build/dist/host/features/git-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/interaction-translation.d.ts +10 -0
- package/data/build/dist/host/features/interaction-translation.d.ts.map +1 -0
- package/data/build/dist/host/features/interaction-translation.js +219 -0
- package/data/build/dist/host/features/interaction-translation.js.map +1 -0
- package/data/build/dist/host/features/lan-access-dsh.d.ts.map +1 -1
- package/data/build/dist/host/features/lan-access-dsh.js +3 -3
- 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 +227 -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 +22 -0
- package/data/build/dist/host/features/session-translation-protection.d.ts.map +1 -0
- package/data/build/dist/host/features/session-translation-protection.js +204 -0
- package/data/build/dist/host/features/session-translation-protection.js.map +1 -0
- 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-runtime.d.ts +16 -0
- package/data/build/dist/host/features/session-translation-runtime.d.ts.map +1 -0
- package/data/build/dist/host/features/session-translation-runtime.js +85 -0
- package/data/build/dist/host/features/session-translation-runtime.js.map +1 -0
- package/data/build/dist/host/features/session-translation-service.d.ts +19 -4
- package/data/build/dist/host/features/session-translation-service.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation-service.js +249 -210
- 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 +6 -3
- 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 +32 -39
- package/data/build/dist/host/index.js.map +1 -1
- package/data/build/dist/host/lan-access-dsh.d.ts +14 -2
- package/data/build/dist/host/lan-access-dsh.d.ts.map +1 -1
- package/data/build/dist/host/lan-access-dsh.js +81 -13
- 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/egress.d.ts +35 -0
- package/data/build/dist/host/modules/quick-apps/egress.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/egress.js +244 -0
- package/data/build/dist/host/modules/quick-apps/egress.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 +195 -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 +238 -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 +174 -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 +213 -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 +10 -15
- 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 +23 -12
- package/data/build/dist/host/rpc.js.map +1 -1
- package/data/build/dist/host/session-changes.d.ts.map +1 -1
- package/data/build/dist/host/session-changes.js +6 -2
- package/data/build/dist/host/session-changes.js.map +1 -1
- package/data/build/dist/host/session-migration-repair.js +48 -35
- package/data/build/dist/host/session-migration-repair.js.map +1 -1
- package/data/build/dist/host/settings.d.ts.map +1 -1
- package/data/build/dist/host/settings.js +31 -2
- 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/host/workspace-root.d.ts +14 -0
- package/data/build/dist/host/workspace-root.d.ts.map +1 -0
- package/data/build/dist/host/workspace-root.js +99 -0
- package/data/build/dist/host/workspace-root.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/cli-provider-route.d.ts +7 -0
- package/data/build/dist/shared/cli-provider-route.d.ts.map +1 -0
- package/data/build/dist/shared/cli-provider-route.js +13 -0
- package/data/build/dist/shared/cli-provider-route.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/agent-team.d.ts +14 -0
- package/data/build/dist/shared/contracts/agent-team.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/agent-team.js +48 -0
- package/data/build/dist/shared/contracts/agent-team.js.map +1 -0
- package/data/build/dist/shared/contracts/cli-adapter.d.ts +62 -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 +7 -1
- package/data/build/dist/shared/contracts/config.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/config.js +3 -0
- 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/errors.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/git.d.ts +17 -0
- package/data/build/dist/shared/contracts/git.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/git.js +27 -1
- package/data/build/dist/shared/contracts/git.js.map +1 -1
- package/data/build/dist/shared/contracts/interaction-presentation.d.ts +32 -0
- package/data/build/dist/shared/contracts/interaction-presentation.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/interaction-presentation.js +2 -0
- package/data/build/dist/shared/contracts/interaction-presentation.js.map +1 -0
- package/data/build/dist/shared/contracts/interaction-translation.d.ts +53 -0
- package/data/build/dist/shared/contracts/interaction-translation.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/interaction-translation.js +44 -0
- package/data/build/dist/shared/contracts/interaction-translation.js.map +1 -0
- package/data/build/dist/shared/contracts/quick-apps.d.ts +70 -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 +82 -9
- package/data/build/dist/shared/contracts/session-translation.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/session-translation.js +146 -2
- package/data/build/dist/shared/contracts/session-translation.js.map +1 -1
- package/data/build/dist/shared/contracts/subscription.d.ts +87 -0
- package/data/build/dist/shared/contracts/subscription.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/subscription.js.map +1 -1
- package/data/build/dist/shared/contracts/version.d.ts +9 -15
- package/data/build/dist/shared/contracts/version.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/version.js +8 -14
- package/data/build/dist/shared/contracts/version.js.map +1 -1
- package/data/build/dist/shared/index.d.ts +3 -2
- package/data/build/dist/shared/index.d.ts.map +1 -1
- package/data/build/dist/shared/index.js +3 -2
- package/data/build/dist/shared/index.js.map +1 -1
- 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/provider-icon-resources.d.ts.map +1 -1
- package/data/build/dist/shared/provider-icon-resources.js +1 -0
- package/data/build/dist/shared/provider-icon-resources.js.map +1 -1
- package/data/build/dist/shared/quick-app-browser-storage.d.ts +33 -0
- package/data/build/dist/shared/quick-app-browser-storage.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-browser-storage.js +33 -0
- package/data/build/dist/shared/quick-app-browser-storage.js.map +1 -0
- package/data/build/dist/shared/quick-app-network-allow.d.ts +8 -0
- package/data/build/dist/shared/quick-app-network-allow.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-network-allow.js +192 -0
- package/data/build/dist/shared/quick-app-network-allow.js.map +1 -0
- package/data/build/dist/shared/quick-app-network-bootstrap.d.ts +9 -0
- package/data/build/dist/shared/quick-app-network-bootstrap.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-network-bootstrap.js +134 -0
- package/data/build/dist/shared/quick-app-network-bootstrap.js.map +1 -0
- 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-app-storage-bootstrap.d.ts +9 -0
- package/data/build/dist/shared/quick-app-storage-bootstrap.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-storage-bootstrap.js +189 -0
- package/data/build/dist/shared/quick-app-storage-bootstrap.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/data/build/dist/shared/translation-indicator.d.ts +26 -0
- package/data/build/dist/shared/translation-indicator.d.ts.map +1 -0
- package/data/build/dist/shared/translation-indicator.js +29 -0
- package/data/build/dist/shared/translation-indicator.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
- package/data/build/dist/client/client.model-catalog-cache.js.map +0 -1
|
@@ -0,0 +1,986 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { commandEnvironment, resolveCommandPath, runAsyncCommand, WINDOWS, withCommandSignal } from './process-utils.js';
|
|
3
|
+
const MAGPIE_CATALOG_TTL_MS = 60_000;
|
|
4
|
+
const MAGPIE_MODEL_METADATA_TTL_MS = 60_000;
|
|
5
|
+
const MAGPIE_FAILURE_CACHE_TTL_MS = 5_000;
|
|
6
|
+
const MAX_MAGPIE_MODEL_METADATA_CACHE_ENTRIES = 4;
|
|
7
|
+
const MAGPIE_MINIMUM_CLI_VERSION = [0, 1, 1295];
|
|
8
|
+
const MAGPIE_CLI_TIMEOUT_MS = 10_000;
|
|
9
|
+
const MAGPIE_HTTP_TIMEOUT_MS = 3_000;
|
|
10
|
+
const MAX_MAGPIE_CLI_OUTPUT_BYTES = 512 * 1024;
|
|
11
|
+
const MAX_MAGPIE_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
12
|
+
const MAX_MAGPIE_MODELS = 10_000;
|
|
13
|
+
const MAX_MODEL_TOKEN_LIMIT = 1_000_000_000;
|
|
14
|
+
const MAGPIE_MODEL_ID_PATTERN = '[A-Za-z0-9][A-Za-z0-9._-]*(?:/[A-Za-z0-9][A-Za-z0-9._:/-]*)+';
|
|
15
|
+
const MAGPIE_AGENT_BY_ADAPTER = {
|
|
16
|
+
'claude-code': 'claude',
|
|
17
|
+
codex: 'codex',
|
|
18
|
+
'command-code': 'commandcode',
|
|
19
|
+
kimi: 'kimi',
|
|
20
|
+
gemini: 'gemini',
|
|
21
|
+
pi: 'pi',
|
|
22
|
+
opencode: 'opencode',
|
|
23
|
+
grok: 'grok',
|
|
24
|
+
mcode: 'minimax-code',
|
|
25
|
+
zcode: 'zcode',
|
|
26
|
+
codebuddy: 'codebuddy',
|
|
27
|
+
workbuddy: 'workbuddy',
|
|
28
|
+
'cursor-cli': 'cursor',
|
|
29
|
+
qoder: 'qoder',
|
|
30
|
+
'qoder-cn': 'qoder-cn',
|
|
31
|
+
antigravity: 'agy',
|
|
32
|
+
dsh: 'dsh',
|
|
33
|
+
};
|
|
34
|
+
// The DSH catalog uses `dsh`, while its gateway requests are recorded under
|
|
35
|
+
// the public client identity `codingns4dsh` in Magpie usage and trace data.
|
|
36
|
+
const MAGPIE_USAGE_AGENT_ALIASES = {
|
|
37
|
+
dsh: ['dsh', 'codingns4dsh'],
|
|
38
|
+
// Command Code ACP identifies its client as `codingns4dsh` in Magpie's
|
|
39
|
+
// usage ledger, while its verified model catalog uses `commandcode`.
|
|
40
|
+
commandcode: ['commandcode', 'codingns4dsh'],
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Reads Magpie's public local Gateway API only after its CLI confirms that the
|
|
44
|
+
* current Agent model is in that Agent's catalog. No Agent or Magpie config
|
|
45
|
+
* files are opened here; the provider session ID is supplied by the Host.
|
|
46
|
+
*/
|
|
47
|
+
export class MagpieUsageService {
|
|
48
|
+
readModels;
|
|
49
|
+
readVersion;
|
|
50
|
+
request;
|
|
51
|
+
now;
|
|
52
|
+
timeoutMs;
|
|
53
|
+
lifetimeSignal;
|
|
54
|
+
/** Agent CLI verification remains isolated; model metadata below is Gateway-wide and shared. */
|
|
55
|
+
catalogs = new Map();
|
|
56
|
+
catalogLoads = new Map();
|
|
57
|
+
/** `/v1/models` is Gateway-wide, so adapters with the same model set share one normalized response. */
|
|
58
|
+
modelMetadata = new Map();
|
|
59
|
+
modelMetadataLoads = new Map();
|
|
60
|
+
versionCheck;
|
|
61
|
+
versionLoad;
|
|
62
|
+
constructor(options = {}) {
|
|
63
|
+
this.readModels = options.readModels ?? readMagpieModels;
|
|
64
|
+
// An injected catalog reader represents the whole fake CLI boundary in
|
|
65
|
+
// unit tests; tests that exercise version handling inject readVersion too.
|
|
66
|
+
this.readVersion = options.readVersion ?? (options.readModels === undefined
|
|
67
|
+
? readMagpieVersion
|
|
68
|
+
: async () => 'magpie 0.1.1295');
|
|
69
|
+
this.request = options.fetch ?? fetch;
|
|
70
|
+
this.now = options.now ?? Date.now;
|
|
71
|
+
this.timeoutMs = options.timeoutMs ?? MAGPIE_HTTP_TIMEOUT_MS;
|
|
72
|
+
this.lifetimeSignal = options.lifetimeSignal;
|
|
73
|
+
}
|
|
74
|
+
async read(session, signal, includeRoute = false, dshSessionId) {
|
|
75
|
+
signal?.throwIfAborted();
|
|
76
|
+
const agent = magpieAgentForAdapter(session.adapterId);
|
|
77
|
+
const requestedModelId = cleanText(session.modelId);
|
|
78
|
+
if (agent === null || requestedModelId === null)
|
|
79
|
+
return null;
|
|
80
|
+
const catalog = await this.loadCatalog(agent, signal);
|
|
81
|
+
const modelId = resolveCatalogModelId(agent, requestedModelId, catalog, requestedModelId);
|
|
82
|
+
if (catalog === null || modelId === null)
|
|
83
|
+
return null;
|
|
84
|
+
const providerSessionId = cleanText(session.providerSessionId);
|
|
85
|
+
const nativeSessionId = cleanText(dshSessionId);
|
|
86
|
+
// Native DSH requests use the DSH session ID as their Magpie session
|
|
87
|
+
// identity. Other drivers must never treat that fallback as a provider ID.
|
|
88
|
+
const sessionId = providerSessionId !== null && providerSessionId !== nativeSessionId
|
|
89
|
+
? providerSessionId
|
|
90
|
+
: agent === 'dsh' ? nativeSessionId : null;
|
|
91
|
+
return this.readFromGateway(agent, requestedModelId, catalog.gatewayOrigin, sessionId, signal, includeRoute);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Mark Magpie models and enrich their public metadata. The marker is
|
|
95
|
+
* transient catalog data used by model-list UIs, not session provenance.
|
|
96
|
+
*/
|
|
97
|
+
async enrichModelCatalog(adapterId, catalog, signal) {
|
|
98
|
+
const agent = magpieAgentForAdapter(adapterId);
|
|
99
|
+
const [resolvedCatalog, agentCatalog] = await Promise.all([
|
|
100
|
+
Promise.resolve(catalog),
|
|
101
|
+
agent === null ? Promise.resolve(null) : this.loadCatalog(agent, signal),
|
|
102
|
+
]);
|
|
103
|
+
if (agent === null || agentCatalog === null)
|
|
104
|
+
return resolvedCatalog;
|
|
105
|
+
const hasMatch = resolvedCatalog.groups.some((group) => group.models.some((model) => resolveCatalogModelId(agent, model.id, agentCatalog, model.name) !== null));
|
|
106
|
+
const exposeMissingCodexModels = adapterId === 'codex';
|
|
107
|
+
if (!hasMatch && !exposeMissingCodexModels)
|
|
108
|
+
return resolvedCatalog;
|
|
109
|
+
const metadata = await this.loadModelMetadata(agentCatalog, signal);
|
|
110
|
+
let changed = false;
|
|
111
|
+
let groups = resolvedCatalog.groups.map((group) => {
|
|
112
|
+
let groupChanged = false;
|
|
113
|
+
const models = group.models.map((model) => {
|
|
114
|
+
const id = resolveCatalogModelId(agent, model.id, agentCatalog, model.name);
|
|
115
|
+
if (id === null)
|
|
116
|
+
return model;
|
|
117
|
+
const record = metadata?.get(id);
|
|
118
|
+
const enriched = record === undefined
|
|
119
|
+
? model.source === 'magpie' ? model : { ...model, source: 'magpie' }
|
|
120
|
+
: mergeMagpieModelMetadata(model, record);
|
|
121
|
+
if (enriched === model)
|
|
122
|
+
return model;
|
|
123
|
+
groupChanged = true;
|
|
124
|
+
return enriched;
|
|
125
|
+
});
|
|
126
|
+
if (!groupChanged)
|
|
127
|
+
return group;
|
|
128
|
+
changed = true;
|
|
129
|
+
return { ...group, models };
|
|
130
|
+
});
|
|
131
|
+
if (exposeMissingCodexModels) {
|
|
132
|
+
const existingModelIds = new Set(groups.flatMap((group) => group.models.map((model) => model.id)));
|
|
133
|
+
const missingModels = [...agentCatalog.models]
|
|
134
|
+
.filter((id) => !existingModelIds.has(id))
|
|
135
|
+
.map((id) => {
|
|
136
|
+
const record = metadata?.get(id);
|
|
137
|
+
const model = {
|
|
138
|
+
id,
|
|
139
|
+
name: record?.name ?? agentCatalog.displayNames.get(id) ?? id,
|
|
140
|
+
efforts: record?.efforts ?? [],
|
|
141
|
+
source: 'magpie',
|
|
142
|
+
};
|
|
143
|
+
return record === undefined ? model : mergeMagpieModelMetadata(model, record);
|
|
144
|
+
});
|
|
145
|
+
if (missingModels.length > 0) {
|
|
146
|
+
const codexGroupIndex = groups.findIndex((group) => group.id === 'codex');
|
|
147
|
+
const targetIndex = codexGroupIndex >= 0 ? codexGroupIndex : groups.length > 0 ? 0 : -1;
|
|
148
|
+
if (targetIndex >= 0) {
|
|
149
|
+
groups = groups.map((group, index) => index === targetIndex
|
|
150
|
+
? { ...group, models: [...group.models, ...missingModels] }
|
|
151
|
+
: group);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
groups = [{ id: 'codex', name: 'Codex', models: missingModels }];
|
|
155
|
+
}
|
|
156
|
+
changed = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return changed ? { ...resolvedCatalog, groups } : resolvedCatalog;
|
|
160
|
+
}
|
|
161
|
+
/** Return an exact, CLI-confirmed Magpie model record for trusted Host use. */
|
|
162
|
+
async readModelMetadata(adapterId, modelId, signal) {
|
|
163
|
+
signal?.throwIfAborted();
|
|
164
|
+
const agent = magpieAgentForAdapter(adapterId);
|
|
165
|
+
const requestedModelId = cleanText(modelId);
|
|
166
|
+
if (agent === null || requestedModelId === null)
|
|
167
|
+
return null;
|
|
168
|
+
const catalog = await this.loadCatalog(agent, signal);
|
|
169
|
+
if (catalog === null)
|
|
170
|
+
return null;
|
|
171
|
+
const id = resolveCatalogModelId(agent, requestedModelId, catalog, requestedModelId);
|
|
172
|
+
if (id === null)
|
|
173
|
+
return null;
|
|
174
|
+
const metadata = await this.loadModelMetadata(catalog, signal);
|
|
175
|
+
return metadata?.get(id) ?? null;
|
|
176
|
+
}
|
|
177
|
+
async readFromGateway(agent, modelId, gatewayOrigin, sessionId, signal, includeRoute) {
|
|
178
|
+
const capturedAt = new Date(this.now()).toISOString();
|
|
179
|
+
if (gatewayOrigin === null)
|
|
180
|
+
return unavailableMagpieSnapshot(agent, modelId, sessionId, this.now(), capturedAt);
|
|
181
|
+
const [usageResult, quotaResult] = await Promise.all([
|
|
182
|
+
this.readGatewayJson(gatewayOrigin, '/v1/magpie/usage?period=today', signal),
|
|
183
|
+
this.readGatewayJson(gatewayOrigin, '/v1/magpie/quotas', signal),
|
|
184
|
+
]);
|
|
185
|
+
const aggregate = usageResult.ok ? readTotals(usageResult.value) : null;
|
|
186
|
+
const sessionUsage = usageResult.ok && sessionId !== null
|
|
187
|
+
? readSession(usageResult.value, agent, sessionId)
|
|
188
|
+
: null;
|
|
189
|
+
// A providerSessionId is not enough to prove that Magpie knows this Agent
|
|
190
|
+
// session. Require the exact Agent + ID pair in Magpie's own usage result
|
|
191
|
+
// before asking the route endpoint, and then verify its echoed identity.
|
|
192
|
+
const canReadRoute = includeRoute && sessionId !== null && sessionId.length <= 128 && sessionUsage !== null;
|
|
193
|
+
const routeResultPromise = canReadRoute
|
|
194
|
+
? this.readGatewayJson(gatewayOrigin, `/v1/magpie/route?session=${encodeURIComponent(sessionId)}`, signal)
|
|
195
|
+
: Promise.resolve({ ok: false });
|
|
196
|
+
const routeHistoryResultPromise = canReadRoute
|
|
197
|
+
? this.readGatewayJson(gatewayOrigin, `/v1/magpie/usage/requests?period=today&q=${encodeURIComponent(sessionId)}&limit=100`, signal)
|
|
198
|
+
: Promise.resolve({ ok: false });
|
|
199
|
+
const [routeResult, routeHistoryResult] = await Promise.all([routeResultPromise, routeHistoryResultPromise]);
|
|
200
|
+
const routeRead = sessionId === null
|
|
201
|
+
? { status: 'session-unavailable', route: null }
|
|
202
|
+
: !includeRoute
|
|
203
|
+
? { status: 'not-requested', route: null }
|
|
204
|
+
: !canReadRoute
|
|
205
|
+
? { status: 'unavailable', route: null }
|
|
206
|
+
: !routeResult.ok
|
|
207
|
+
? { status: 'unavailable', route: null }
|
|
208
|
+
: readRoute(routeResult.value, sessionId);
|
|
209
|
+
const routeHistory = routeHistoryResult.ok && sessionId !== null && sessionUsage !== null
|
|
210
|
+
? readSessionRouteHistory(routeHistoryResult.value, agent, sessionId)
|
|
211
|
+
: [];
|
|
212
|
+
const route = routeRead.route === null
|
|
213
|
+
? routeHistory[0]?.route ?? null
|
|
214
|
+
: enrichRouteWithHistory(routeRead.route, routeHistory);
|
|
215
|
+
const routeStatus = route !== null
|
|
216
|
+
? 'available'
|
|
217
|
+
: routeRead.status;
|
|
218
|
+
const allQuotas = quotaResult.ok ? parseMagpieQuotas(quotaResult.value) : null;
|
|
219
|
+
const routeProviders = [...new Set([
|
|
220
|
+
providerFromRoute(route),
|
|
221
|
+
...routeHistory.map((record) => record.provider),
|
|
222
|
+
].filter((provider) => provider !== null))];
|
|
223
|
+
const upstreamProviders = routeProviders.length > 0
|
|
224
|
+
? routeProviders
|
|
225
|
+
: [providerFromModelId(modelId, agent)].filter((provider) => provider !== null);
|
|
226
|
+
const upstreamProvider = upstreamProviders[0] ?? null;
|
|
227
|
+
const quotas = allQuotas === null
|
|
228
|
+
? []
|
|
229
|
+
: filterSessionQuotas(allQuotas, upstreamProviders, routeHistory);
|
|
230
|
+
return {
|
|
231
|
+
agent,
|
|
232
|
+
modelId,
|
|
233
|
+
capturedAt,
|
|
234
|
+
usageStatus: aggregate === null ? 'unavailable' : 'available',
|
|
235
|
+
aggregate,
|
|
236
|
+
sessionId,
|
|
237
|
+
session: sessionUsage,
|
|
238
|
+
routeStatus,
|
|
239
|
+
route,
|
|
240
|
+
upstreamProvider,
|
|
241
|
+
upstreamProviders,
|
|
242
|
+
quotaStatus: allQuotas === null ? 'unavailable' : upstreamProviders.length === 0 ? 'provider-unavailable' : 'available',
|
|
243
|
+
quotas,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
async loadCatalog(agent, signal) {
|
|
247
|
+
const cached = this.catalogs.get(agent);
|
|
248
|
+
const cacheTtl = cached?.catalog === null ? MAGPIE_FAILURE_CACHE_TTL_MS : MAGPIE_CATALOG_TTL_MS;
|
|
249
|
+
if (cached !== undefined && this.now() - cached.loadedAt < cacheTtl) {
|
|
250
|
+
return awaitWithSignal(Promise.resolve(cached.catalog), signal);
|
|
251
|
+
}
|
|
252
|
+
const pending = this.catalogLoads.get(agent);
|
|
253
|
+
if (pending !== undefined)
|
|
254
|
+
return awaitWithSignal(pending, signal);
|
|
255
|
+
const request = Promise.resolve().then(async () => {
|
|
256
|
+
// These checks are independent. Do not make every cold model-catalog
|
|
257
|
+
// request wait for the version subprocess before starting Magpie's
|
|
258
|
+
// model-list subprocess.
|
|
259
|
+
const supportedRequest = this.supportedCli(this.lifetimeSignal);
|
|
260
|
+
const catalogRequest = this.hasFreshUnsupportedVersion()
|
|
261
|
+
? Promise.resolve(null)
|
|
262
|
+
: Promise.resolve().then(() => this.readModels(agent, this.lifetimeSignal))
|
|
263
|
+
.then((output) => output === null ? null : parseMagpieModelOutput(output, agent))
|
|
264
|
+
.catch(() => null);
|
|
265
|
+
const [supported, catalog] = await Promise.all([supportedRequest, catalogRequest]);
|
|
266
|
+
const result = supported ? catalog : null;
|
|
267
|
+
this.catalogs.set(agent, { catalog: result, loadedAt: this.now() });
|
|
268
|
+
return result;
|
|
269
|
+
})
|
|
270
|
+
.catch(() => null)
|
|
271
|
+
.finally(() => { if (this.catalogLoads.get(agent) === request)
|
|
272
|
+
this.catalogLoads.delete(agent); });
|
|
273
|
+
this.catalogLoads.set(agent, request);
|
|
274
|
+
return awaitWithSignal(request, signal);
|
|
275
|
+
}
|
|
276
|
+
async loadModelMetadata(catalog, signal) {
|
|
277
|
+
signal?.throwIfAborted();
|
|
278
|
+
if (catalog.gatewayOrigin === null)
|
|
279
|
+
return null;
|
|
280
|
+
const catalogFingerprint = [...catalog.models].sort().join('\u0000');
|
|
281
|
+
const loadKey = `${catalog.gatewayOrigin}\u0000${catalogFingerprint}`;
|
|
282
|
+
const cached = this.modelMetadata.get(loadKey);
|
|
283
|
+
if (cached !== undefined
|
|
284
|
+
&& cached.origin === catalog.gatewayOrigin
|
|
285
|
+
&& cached.catalogFingerprint === catalogFingerprint
|
|
286
|
+
&& this.now() - cached.loadedAt < (cached.models === null ? MAGPIE_FAILURE_CACHE_TTL_MS : MAGPIE_MODEL_METADATA_TTL_MS)) {
|
|
287
|
+
return awaitWithSignal(Promise.resolve(cached.models), signal);
|
|
288
|
+
}
|
|
289
|
+
const pending = this.modelMetadataLoads.get(loadKey);
|
|
290
|
+
if (pending !== undefined)
|
|
291
|
+
return awaitWithSignal(pending, signal);
|
|
292
|
+
const request = this.readGatewayJson(catalog.gatewayOrigin, '/v1/models', this.lifetimeSignal)
|
|
293
|
+
.then((response) => response.ok ? parseMagpieModelMetadata(response.value) : null)
|
|
294
|
+
.then((models) => {
|
|
295
|
+
this.modelMetadata.delete(loadKey);
|
|
296
|
+
this.modelMetadata.set(loadKey, {
|
|
297
|
+
origin: catalog.gatewayOrigin,
|
|
298
|
+
catalogFingerprint,
|
|
299
|
+
models,
|
|
300
|
+
loadedAt: this.now(),
|
|
301
|
+
});
|
|
302
|
+
while (this.modelMetadata.size > MAX_MAGPIE_MODEL_METADATA_CACHE_ENTRIES) {
|
|
303
|
+
const oldest = this.modelMetadata.keys().next().value;
|
|
304
|
+
if (oldest === undefined)
|
|
305
|
+
break;
|
|
306
|
+
this.modelMetadata.delete(oldest);
|
|
307
|
+
}
|
|
308
|
+
return models;
|
|
309
|
+
})
|
|
310
|
+
.catch(() => null)
|
|
311
|
+
.finally(() => { if (this.modelMetadataLoads.get(loadKey) === request)
|
|
312
|
+
this.modelMetadataLoads.delete(loadKey); });
|
|
313
|
+
this.modelMetadataLoads.set(loadKey, request);
|
|
314
|
+
return awaitWithSignal(request, signal);
|
|
315
|
+
}
|
|
316
|
+
async supportedCli(signal) {
|
|
317
|
+
if (this.versionCheck !== undefined && this.now() - this.versionCheck.checkedAt < MAGPIE_CATALOG_TTL_MS) {
|
|
318
|
+
return awaitWithSignal(Promise.resolve(this.versionCheck.supported), signal);
|
|
319
|
+
}
|
|
320
|
+
if (this.versionLoad !== undefined)
|
|
321
|
+
return awaitWithSignal(this.versionLoad, signal);
|
|
322
|
+
const load = this.readVersion(this.lifetimeSignal)
|
|
323
|
+
.then((value) => parseMagpieCliVersion(value))
|
|
324
|
+
.then((supported) => {
|
|
325
|
+
this.versionCheck = { supported, checkedAt: this.now() };
|
|
326
|
+
return supported;
|
|
327
|
+
})
|
|
328
|
+
.catch(() => {
|
|
329
|
+
this.versionCheck = { supported: false, checkedAt: this.now() };
|
|
330
|
+
return false;
|
|
331
|
+
})
|
|
332
|
+
.finally(() => { if (this.versionLoad === load)
|
|
333
|
+
this.versionLoad = undefined; });
|
|
334
|
+
this.versionLoad = load;
|
|
335
|
+
return awaitWithSignal(load, signal);
|
|
336
|
+
}
|
|
337
|
+
hasFreshUnsupportedVersion() {
|
|
338
|
+
return this.versionCheck !== undefined
|
|
339
|
+
&& !this.versionCheck.supported
|
|
340
|
+
&& this.now() - this.versionCheck.checkedAt < MAGPIE_CATALOG_TTL_MS;
|
|
341
|
+
}
|
|
342
|
+
async readGatewayJson(origin, path, signal) {
|
|
343
|
+
const abort = AbortSignal.timeout(this.timeoutMs);
|
|
344
|
+
const requestSignal = signal === undefined ? abort : AbortSignal.any([signal, abort]);
|
|
345
|
+
try {
|
|
346
|
+
const response = await this.request(new URL(path, origin), {
|
|
347
|
+
method: 'GET',
|
|
348
|
+
headers: { Accept: 'application/json', Authorization: 'Bearer magpie' },
|
|
349
|
+
redirect: 'error',
|
|
350
|
+
cache: 'no-store',
|
|
351
|
+
signal: requestSignal,
|
|
352
|
+
});
|
|
353
|
+
if (!response.ok) {
|
|
354
|
+
await response.body?.cancel().catch(() => undefined);
|
|
355
|
+
return { ok: false };
|
|
356
|
+
}
|
|
357
|
+
const value = await readBoundedJson(response);
|
|
358
|
+
if (value === null)
|
|
359
|
+
await response.body?.cancel().catch(() => undefined);
|
|
360
|
+
return value === null ? { ok: false } : { ok: true, value };
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
return { ok: false };
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function unavailableMagpieSnapshot(agent, modelId, sessionId, now, capturedAt = new Date(now).toISOString()) {
|
|
368
|
+
return {
|
|
369
|
+
agent,
|
|
370
|
+
modelId,
|
|
371
|
+
capturedAt,
|
|
372
|
+
usageStatus: 'unavailable',
|
|
373
|
+
aggregate: null,
|
|
374
|
+
sessionId,
|
|
375
|
+
session: null,
|
|
376
|
+
routeStatus: sessionId === null ? 'session-unavailable' : 'unavailable',
|
|
377
|
+
route: null,
|
|
378
|
+
upstreamProvider: providerFromModelId(modelId, agent),
|
|
379
|
+
quotaStatus: 'unavailable',
|
|
380
|
+
quotas: [],
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function awaitWithSignal(task, signal) {
|
|
384
|
+
if (signal === undefined)
|
|
385
|
+
return task;
|
|
386
|
+
if (signal.aborted)
|
|
387
|
+
return Promise.reject(signal.reason ?? new DOMException('The operation was aborted', 'AbortError'));
|
|
388
|
+
return new Promise((resolve, reject) => {
|
|
389
|
+
const cleanup = () => signal.removeEventListener('abort', onAbort);
|
|
390
|
+
const onAbort = () => {
|
|
391
|
+
cleanup();
|
|
392
|
+
reject(signal.reason ?? new DOMException('The operation was aborted', 'AbortError'));
|
|
393
|
+
};
|
|
394
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
395
|
+
task.then((value) => { cleanup(); resolve(value); }, (error) => { cleanup(); reject(error); });
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
/** Strict parser for the human-readable Magpie catalog; unknown formats fail closed. */
|
|
399
|
+
export function parseMagpieModelOutput(output, agent) {
|
|
400
|
+
if (!isMagpieAgentId(agent) || Buffer.byteLength(output, 'utf8') > MAX_MAGPIE_CLI_OUTPUT_BYTES)
|
|
401
|
+
return null;
|
|
402
|
+
const models = new Set();
|
|
403
|
+
const displayNames = new Map();
|
|
404
|
+
const nameCandidates = new Map();
|
|
405
|
+
const gatewayUrls = [];
|
|
406
|
+
const lines = output.split(/\r?\n/u);
|
|
407
|
+
const expectedFooter = `${agent} is shown every provider's models`;
|
|
408
|
+
const hasExpectedAgentFooter = lines.some((line) => {
|
|
409
|
+
const footer = line.trim();
|
|
410
|
+
return footer === expectedFooter || footer.startsWith(`${expectedFooter} ·`);
|
|
411
|
+
});
|
|
412
|
+
for (const line of lines) {
|
|
413
|
+
const text = line.trim();
|
|
414
|
+
const columns = text.split(/\s{2,}/u);
|
|
415
|
+
const model = columns[0];
|
|
416
|
+
const label = columns[1]?.trim();
|
|
417
|
+
if (model !== undefined
|
|
418
|
+
&& new RegExp(`^${MAGPIE_MODEL_ID_PATTERN}$`, 'u').test(model)
|
|
419
|
+
&& model.length <= 512 && models.size < 10_000) {
|
|
420
|
+
models.add(model);
|
|
421
|
+
const displayName = label === undefined || !safeMetadataText(label, 200)
|
|
422
|
+
? null
|
|
423
|
+
: label.trim().replace(/\s+/gu, ' ');
|
|
424
|
+
if (displayName !== null && !displayNames.has(model))
|
|
425
|
+
displayNames.set(model, displayName);
|
|
426
|
+
const name = displayName === null ? null : normalizeMagpieModelName(displayName);
|
|
427
|
+
if (name !== null) {
|
|
428
|
+
const candidates = nameCandidates.get(name) ?? [];
|
|
429
|
+
if (!candidates.includes(model))
|
|
430
|
+
candidates.push(model);
|
|
431
|
+
nameCandidates.set(name, candidates);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const url = text.match(/https?:\/\/[^\s]+/u)?.[0]?.replace(/[),.;]+$/u, '');
|
|
435
|
+
if (url !== undefined && gatewayUrls.length < 4)
|
|
436
|
+
gatewayUrls.push(url);
|
|
437
|
+
}
|
|
438
|
+
if (!hasExpectedAgentFooter || models.size === 0 || gatewayUrls.length !== 1)
|
|
439
|
+
return null;
|
|
440
|
+
const origins = [...new Set(gatewayUrls.map(normalizeLoopbackGatewayOrigin).filter((origin) => origin !== null))];
|
|
441
|
+
if (origins.length !== 1)
|
|
442
|
+
return null;
|
|
443
|
+
const names = new Map();
|
|
444
|
+
for (const [name, candidates] of nameCandidates) {
|
|
445
|
+
if (candidates.length === 1)
|
|
446
|
+
names.set(name, candidates[0]);
|
|
447
|
+
}
|
|
448
|
+
return { models, displayNames, names, gatewayOrigin: origins[0] };
|
|
449
|
+
}
|
|
450
|
+
/** Parse a bounded OpenAI-compatible `/v1/models` response into a safe allowlist. */
|
|
451
|
+
export function parseMagpieModelMetadata(value) {
|
|
452
|
+
const root = asRecord(value);
|
|
453
|
+
const rows = Array.isArray(value) ? value : Array.isArray(root?.data) ? root.data : null;
|
|
454
|
+
if (rows === null || rows.length === 0 || rows.length > MAX_MAGPIE_MODELS)
|
|
455
|
+
return null;
|
|
456
|
+
const models = new Map();
|
|
457
|
+
for (const row of rows) {
|
|
458
|
+
const record = asRecord(row);
|
|
459
|
+
const id = cleanModelId(record?.id);
|
|
460
|
+
if (record === null || id === null || models.has(id))
|
|
461
|
+
return null;
|
|
462
|
+
const modalities = asRecord(record.modalities);
|
|
463
|
+
const reasoningLevels = readReasoningLevels(record);
|
|
464
|
+
const serviceTiers = readMagpieServiceTiers(record.service_tiers);
|
|
465
|
+
const capabilities = readStringList(record.capabilities, 64, 128);
|
|
466
|
+
const metadata = {
|
|
467
|
+
id,
|
|
468
|
+
...optionalText(record.display_name ?? record.magpie_label ?? record.name, 200, 'name'),
|
|
469
|
+
...optionalText(record.description, 2_000, 'description'),
|
|
470
|
+
...optionalPositiveLimit(record.context_window ?? record.context_length, 'contextWindow'),
|
|
471
|
+
...optionalPositiveLimit(record.max_input_tokens, 'maxInputTokens'),
|
|
472
|
+
...optionalPositiveLimit(record.max_output_tokens ?? record.max_completion_tokens, 'maxOutputTokens'),
|
|
473
|
+
...optionalStringList(modalities?.input ?? record.input_modalities, 16, 64, 'inputModalities'),
|
|
474
|
+
...optionalStringList(modalities?.output ?? record.output_modalities, 16, 64, 'outputModalities'),
|
|
475
|
+
...(typeof record.reasoning === 'boolean' ? { reasoningSupported: record.reasoning } : {}),
|
|
476
|
+
...(reasoningLevels === undefined ? {} : { efforts: reasoningLevels }),
|
|
477
|
+
...(serviceTiers === undefined ? {} : { serviceTiers }),
|
|
478
|
+
...(capabilities === undefined ? {} : { capabilities }),
|
|
479
|
+
...optionalText(record.owned_by, 200, 'ownedBy'),
|
|
480
|
+
};
|
|
481
|
+
if (metadata.reasoningSupported === false && metadata.efforts === undefined) {
|
|
482
|
+
models.set(id, { ...metadata, efforts: [] });
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
models.set(id, metadata);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return models;
|
|
489
|
+
}
|
|
490
|
+
function mergeMagpieModelMetadata(model, metadata) {
|
|
491
|
+
return {
|
|
492
|
+
...model,
|
|
493
|
+
source: 'magpie',
|
|
494
|
+
...(metadata.name === undefined ? {} : { name: metadata.name }),
|
|
495
|
+
...(metadata.description === undefined ? {} : { description: metadata.description }),
|
|
496
|
+
...(metadata.contextWindow === undefined ? {} : { contextWindow: metadata.contextWindow }),
|
|
497
|
+
...(metadata.maxInputTokens === undefined ? {} : { maxInputTokens: metadata.maxInputTokens }),
|
|
498
|
+
...(metadata.maxOutputTokens === undefined ? {} : { maxOutputTokens: metadata.maxOutputTokens }),
|
|
499
|
+
...(metadata.inputModalities === undefined ? {} : { inputModalities: metadata.inputModalities }),
|
|
500
|
+
...(metadata.outputModalities === undefined ? {} : { outputModalities: metadata.outputModalities }),
|
|
501
|
+
...(metadata.reasoningSupported === undefined ? {} : { reasoningSupported: metadata.reasoningSupported }),
|
|
502
|
+
...(metadata.reasoningSupported === false ? { efforts: [] } : metadata.efforts === undefined ? {} : { efforts: metadata.efforts }),
|
|
503
|
+
...(metadata.serviceTiers === undefined ? {} : { serviceTiers: metadata.serviceTiers }),
|
|
504
|
+
...(metadata.capabilities === undefined ? {} : { capabilities: metadata.capabilities }),
|
|
505
|
+
...(metadata.ownedBy === undefined ? {} : { ownedBy: metadata.ownedBy }),
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function readReasoningLevels(record) {
|
|
509
|
+
for (const key of ['reasoning_levels', 'supported_reasoning_levels']) {
|
|
510
|
+
if (!(key in record))
|
|
511
|
+
continue;
|
|
512
|
+
const value = record[key];
|
|
513
|
+
if (!Array.isArray(value))
|
|
514
|
+
return undefined;
|
|
515
|
+
const levels = value.flatMap((item) => {
|
|
516
|
+
const level = typeof item === 'string'
|
|
517
|
+
? item
|
|
518
|
+
: asRecord(item)?.effort ?? asRecord(item)?.reasoning_effort ?? asRecord(item)?.id;
|
|
519
|
+
return typeof level === 'string' && isSafeModelToken(level, 64) ? [level.trim()] : [];
|
|
520
|
+
});
|
|
521
|
+
return [...new Set(levels)];
|
|
522
|
+
}
|
|
523
|
+
return undefined;
|
|
524
|
+
}
|
|
525
|
+
function readMagpieServiceTiers(value) {
|
|
526
|
+
if (value === undefined)
|
|
527
|
+
return undefined;
|
|
528
|
+
if (!Array.isArray(value) || value.length > 32)
|
|
529
|
+
return undefined;
|
|
530
|
+
const tiers = value.flatMap((item) => {
|
|
531
|
+
const record = asRecord(item);
|
|
532
|
+
if (record === null)
|
|
533
|
+
return [];
|
|
534
|
+
const id = typeof record.id === 'string' && isSafeModelToken(record.id, 64) ? record.id.trim() : '';
|
|
535
|
+
if (id === '')
|
|
536
|
+
return [];
|
|
537
|
+
const name = typeof record.name === 'string' && safeMetadataText(record.name, 128) ? record.name.trim() : id;
|
|
538
|
+
const description = typeof record.description === 'string' && safeMetadataText(record.description, 512) ? record.description.trim() : undefined;
|
|
539
|
+
return [{ id, name, ...(description === undefined ? {} : { description }) }];
|
|
540
|
+
});
|
|
541
|
+
return tiers;
|
|
542
|
+
}
|
|
543
|
+
function optionalText(value, maxLength, key) {
|
|
544
|
+
return typeof value === 'string' && safeMetadataText(value, maxLength) ? { [key]: value.trim() } : {};
|
|
545
|
+
}
|
|
546
|
+
function optionalPositiveLimit(value, key) {
|
|
547
|
+
const parsed = positiveModelTokenLimit(value);
|
|
548
|
+
return parsed === undefined ? {} : { [key]: parsed };
|
|
549
|
+
}
|
|
550
|
+
function optionalStringList(value, maxItems, maxLength, key) {
|
|
551
|
+
const parsed = readStringList(value, maxItems, maxLength);
|
|
552
|
+
return parsed === undefined ? {} : { [key]: parsed };
|
|
553
|
+
}
|
|
554
|
+
function readStringList(value, maxItems, maxLength) {
|
|
555
|
+
if (!Array.isArray(value) || value.length > maxItems)
|
|
556
|
+
return undefined;
|
|
557
|
+
const items = value.flatMap((item) => typeof item === 'string' && isSafeModelToken(item, maxLength) ? [item.trim()] : []);
|
|
558
|
+
return [...new Set(items)];
|
|
559
|
+
}
|
|
560
|
+
function cleanModelId(value) {
|
|
561
|
+
if (typeof value !== 'string')
|
|
562
|
+
return null;
|
|
563
|
+
const id = value.trim();
|
|
564
|
+
return id.length <= 512 && new RegExp(`^${MAGPIE_MODEL_ID_PATTERN}$`, 'u').test(id) ? id : null;
|
|
565
|
+
}
|
|
566
|
+
function positiveModelTokenLimit(value) {
|
|
567
|
+
return typeof value === 'number'
|
|
568
|
+
&& Number.isSafeInteger(value)
|
|
569
|
+
&& value > 0
|
|
570
|
+
&& value <= MAX_MODEL_TOKEN_LIMIT
|
|
571
|
+
? value
|
|
572
|
+
: undefined;
|
|
573
|
+
}
|
|
574
|
+
function safeMetadataText(value, maxLength) {
|
|
575
|
+
const text = value.trim();
|
|
576
|
+
return text !== '' && text.length <= maxLength && !/[\u0000-\u001f\u007f]/u.test(text);
|
|
577
|
+
}
|
|
578
|
+
function isSafeModelToken(value, maxLength) {
|
|
579
|
+
const text = value.trim();
|
|
580
|
+
return text !== '' && text.length <= maxLength && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(text);
|
|
581
|
+
}
|
|
582
|
+
/** Fail closed until the human-readable catalog format is known to match. */
|
|
583
|
+
export function parseMagpieCliVersion(output) {
|
|
584
|
+
if (output === null || Buffer.byteLength(output, 'utf8') > 256)
|
|
585
|
+
return false;
|
|
586
|
+
const match = output.trim().match(/^magpie\s+(\d+)\.(\d+)\.(\d+)$/u);
|
|
587
|
+
if (match === null)
|
|
588
|
+
return false;
|
|
589
|
+
const version = match.slice(1).map(Number);
|
|
590
|
+
for (let index = 0; index < MAGPIE_MINIMUM_CLI_VERSION.length; index += 1) {
|
|
591
|
+
if (version[index] !== MAGPIE_MINIMUM_CLI_VERSION[index]) {
|
|
592
|
+
return version[index] > MAGPIE_MINIMUM_CLI_VERSION[index];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return true;
|
|
596
|
+
}
|
|
597
|
+
async function readMagpieModels(agent, signal) {
|
|
598
|
+
const result = await runMagpieCommand(['models', agent], signal);
|
|
599
|
+
return result?.status === 0 ? result.stdout : null;
|
|
600
|
+
}
|
|
601
|
+
async function readMagpieVersion(signal) {
|
|
602
|
+
const result = await runMagpieCommand(['--version'], signal);
|
|
603
|
+
return result?.status === 0 ? result.stdout : null;
|
|
604
|
+
}
|
|
605
|
+
async function runMagpieCommand(args, signal) {
|
|
606
|
+
const command = await resolveCommandPath('magpie');
|
|
607
|
+
if (command === null)
|
|
608
|
+
return null;
|
|
609
|
+
const environment = commandEnvironment(command);
|
|
610
|
+
// An inherited flag must not silently hide account-backed catalog entries;
|
|
611
|
+
// this integration reads the complete Magpie catalog but never writes it.
|
|
612
|
+
delete environment.MAGPIE_NO_ACCOUNTS;
|
|
613
|
+
const run = () => runAsyncCommand(spawnSync, command, args, {
|
|
614
|
+
timeout: MAGPIE_CLI_TIMEOUT_MS,
|
|
615
|
+
maxBuffer: MAX_MAGPIE_CLI_OUTPUT_BYTES,
|
|
616
|
+
shell: WINDOWS && /\.(?:cmd|bat)$/iu.test(command),
|
|
617
|
+
env: {
|
|
618
|
+
...environment,
|
|
619
|
+
// Account-backed providers are part of Magpie's model catalog. Filtering
|
|
620
|
+
// them out makes the CLI catalog disagree with /v1/models and hides valid
|
|
621
|
+
// models such as the WorkBuddy-backed Auto entries.
|
|
622
|
+
NO_COLOR: '1',
|
|
623
|
+
FORCE_COLOR: '0',
|
|
624
|
+
},
|
|
625
|
+
}).then((result) => ({
|
|
626
|
+
status: result.status,
|
|
627
|
+
stdout: Buffer.byteLength(result.stdout, 'utf8') <= MAX_MAGPIE_CLI_OUTPUT_BYTES ? result.stdout : '',
|
|
628
|
+
}));
|
|
629
|
+
try {
|
|
630
|
+
return signal === undefined ? await run() : await withCommandSignal(signal, run);
|
|
631
|
+
}
|
|
632
|
+
catch {
|
|
633
|
+
return null;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Magpie IDs normally match adapter IDs. Keep naming differences explicit;
|
|
638
|
+
* every result is still checked against Magpie's own catalog output before
|
|
639
|
+
* any Gateway request is made.
|
|
640
|
+
*/
|
|
641
|
+
export function magpieAgentForAdapter(adapterId) {
|
|
642
|
+
const agent = MAGPIE_AGENT_BY_ADAPTER[adapterId];
|
|
643
|
+
return agent !== undefined && isMagpieAgentId(agent) ? agent : null;
|
|
644
|
+
}
|
|
645
|
+
function isMagpieAgentId(value) {
|
|
646
|
+
return value.length <= 64 && /^[a-z0-9][a-z0-9-]*$/u.test(value);
|
|
647
|
+
}
|
|
648
|
+
function normalizeLoopbackGatewayOrigin(value) {
|
|
649
|
+
try {
|
|
650
|
+
const url = new URL(value);
|
|
651
|
+
const hostname = url.hostname.toLowerCase();
|
|
652
|
+
if (url.protocol !== 'http:'
|
|
653
|
+
|| (hostname !== '127.0.0.1' && hostname !== 'localhost' && hostname !== '[::1]' && hostname !== '::1')
|
|
654
|
+
|| url.username !== '' || url.password !== '' || url.search !== '' || url.hash !== ''
|
|
655
|
+
|| url.pathname.replace(/\/$/u, '') !== '/v1')
|
|
656
|
+
return null;
|
|
657
|
+
return url.origin;
|
|
658
|
+
}
|
|
659
|
+
catch {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
async function readBoundedJson(response) {
|
|
664
|
+
const contentLength = Number(response.headers.get('content-length'));
|
|
665
|
+
if (Number.isFinite(contentLength) && contentLength > MAX_MAGPIE_RESPONSE_BYTES)
|
|
666
|
+
return null;
|
|
667
|
+
const reader = response.body?.getReader();
|
|
668
|
+
if (reader === undefined)
|
|
669
|
+
return null;
|
|
670
|
+
const chunks = [];
|
|
671
|
+
let total = 0;
|
|
672
|
+
try {
|
|
673
|
+
while (true) {
|
|
674
|
+
const { done, value } = await reader.read();
|
|
675
|
+
if (done)
|
|
676
|
+
break;
|
|
677
|
+
total += value.byteLength;
|
|
678
|
+
if (total > MAX_MAGPIE_RESPONSE_BYTES) {
|
|
679
|
+
await reader.cancel();
|
|
680
|
+
return null;
|
|
681
|
+
}
|
|
682
|
+
chunks.push(value);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
finally {
|
|
686
|
+
reader.releaseLock();
|
|
687
|
+
}
|
|
688
|
+
try {
|
|
689
|
+
const bytes = new Uint8Array(total);
|
|
690
|
+
let offset = 0;
|
|
691
|
+
for (const chunk of chunks) {
|
|
692
|
+
bytes.set(chunk, offset);
|
|
693
|
+
offset += chunk.byteLength;
|
|
694
|
+
}
|
|
695
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
696
|
+
}
|
|
697
|
+
catch {
|
|
698
|
+
return null;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function readTotals(value) {
|
|
702
|
+
const record = asRecord(value);
|
|
703
|
+
if (record === null)
|
|
704
|
+
return null;
|
|
705
|
+
const calls = safeCount(record.calls);
|
|
706
|
+
const errors = safeCount(record.errors);
|
|
707
|
+
const inputTokens = safeCount(record.input);
|
|
708
|
+
const outputTokens = safeCount(record.output);
|
|
709
|
+
const cacheReadTokens = safeCount(record.cache_read);
|
|
710
|
+
const cacheWriteTokens = safeCount(record.cache_write);
|
|
711
|
+
const costUsd = safeCost(record.cost);
|
|
712
|
+
if ([calls, errors, inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens, costUsd].every((item) => item === null))
|
|
713
|
+
return null;
|
|
714
|
+
return { calls, errors, inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens, costUsd };
|
|
715
|
+
}
|
|
716
|
+
function readSession(value, agent, sessionId) {
|
|
717
|
+
const sessions = asRecord(value)?.sessions;
|
|
718
|
+
if (!Array.isArray(sessions))
|
|
719
|
+
return null;
|
|
720
|
+
const usageAgents = MAGPIE_USAGE_AGENT_ALIASES[agent] ?? [agent];
|
|
721
|
+
const row = sessions.find((item) => {
|
|
722
|
+
const record = asRecord(item);
|
|
723
|
+
const usageAgent = cleanText(record?.agent);
|
|
724
|
+
return cleanText(record?.id) === sessionId && usageAgent !== null && usageAgents.includes(usageAgent);
|
|
725
|
+
});
|
|
726
|
+
const record = asRecord(row);
|
|
727
|
+
const totals = readTotals(record);
|
|
728
|
+
const usageAgent = cleanText(record?.agent);
|
|
729
|
+
return record !== null && usageAgent !== null && totals !== null ? { id: sessionId, agent: usageAgent, ...totals } : null;
|
|
730
|
+
}
|
|
731
|
+
function readRoute(value, expectedSessionId) {
|
|
732
|
+
const envelope = asRecord(value);
|
|
733
|
+
if (envelope === null || cleanText(envelope.session) !== expectedSessionId || !('route' in envelope))
|
|
734
|
+
return { status: 'unavailable', route: null };
|
|
735
|
+
if (envelope.route === null)
|
|
736
|
+
return { status: 'no-route', route: null };
|
|
737
|
+
const record = asRecord(envelope.route);
|
|
738
|
+
if (record === null)
|
|
739
|
+
return { status: 'unavailable', route: null };
|
|
740
|
+
const tries = Array.isArray(record.tries)
|
|
741
|
+
? record.tries.slice(0, 20).flatMap((item) => {
|
|
742
|
+
const attempt = asRecord(item);
|
|
743
|
+
if (attempt === null)
|
|
744
|
+
return [];
|
|
745
|
+
const model = routeText(attempt.model);
|
|
746
|
+
const provider = routeText(attempt.provider);
|
|
747
|
+
return [{
|
|
748
|
+
model: model !== null && provider !== null && !model.includes('/') ? `${provider}/${model}` : model ?? provider,
|
|
749
|
+
failed: routeText(attempt.fail) !== null,
|
|
750
|
+
}];
|
|
751
|
+
})
|
|
752
|
+
: [];
|
|
753
|
+
return {
|
|
754
|
+
status: 'available',
|
|
755
|
+
route: {
|
|
756
|
+
asked: routeText(record.asked),
|
|
757
|
+
group: routeText(record.group),
|
|
758
|
+
rule: readRule(record.rule),
|
|
759
|
+
model: routeText(record.model),
|
|
760
|
+
effort: routeText(record.effort),
|
|
761
|
+
tries,
|
|
762
|
+
done: typeof record.done === 'boolean' ? record.done : null,
|
|
763
|
+
status: routeStatusText(record.status),
|
|
764
|
+
served: routeText(record.served),
|
|
765
|
+
routeId: safeRouteId(record.id),
|
|
766
|
+
time: routeText(record.time),
|
|
767
|
+
providerAccount: routeText(record.providerAccount),
|
|
768
|
+
},
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
/** Read the durable request ledger when Magpie's short in-memory trace has expired. */
|
|
772
|
+
function readSessionRouteHistory(value, agent, sessionId) {
|
|
773
|
+
const rows = asRecord(value)?.rows;
|
|
774
|
+
if (!Array.isArray(rows) || rows.length > 500)
|
|
775
|
+
return [];
|
|
776
|
+
const usageAgents = MAGPIE_USAGE_AGENT_ALIASES[agent] ?? [agent];
|
|
777
|
+
return rows.slice(0, 100).flatMap((item) => {
|
|
778
|
+
const record = asRecord(item);
|
|
779
|
+
const rowAgent = cleanText(record?.agent);
|
|
780
|
+
const session = cleanText(record?.session);
|
|
781
|
+
const nativeSession = cleanText(record?.native_session);
|
|
782
|
+
const provider = routeText(record?.provider);
|
|
783
|
+
if (record === null || rowAgent === null || !usageAgents.includes(rowAgent)
|
|
784
|
+
|| (session !== sessionId && nativeSession !== sessionId) || provider === null)
|
|
785
|
+
return [];
|
|
786
|
+
const requested = routeText(record.req);
|
|
787
|
+
const model = routeText(record.model);
|
|
788
|
+
const served = routeText(record.served);
|
|
789
|
+
const status = routeStatusText(record.status);
|
|
790
|
+
const rowModel = model === null
|
|
791
|
+
? null
|
|
792
|
+
: model.startsWith(`${provider}/`) ? model : `${provider}/${model}`;
|
|
793
|
+
const group = routeText(record.group) ?? (requested?.startsWith('group/') ? requested.slice('group/'.length) : null);
|
|
794
|
+
const route = {
|
|
795
|
+
asked: requested,
|
|
796
|
+
group,
|
|
797
|
+
rule: readRule(record.rule),
|
|
798
|
+
model: rowModel,
|
|
799
|
+
effort: routeText(record.effort),
|
|
800
|
+
tries: [],
|
|
801
|
+
done: true,
|
|
802
|
+
status,
|
|
803
|
+
served,
|
|
804
|
+
routeId: safeRouteId(record.route_id),
|
|
805
|
+
time: routeText(record.t),
|
|
806
|
+
providerAccount: routeText(record.providerAccount),
|
|
807
|
+
};
|
|
808
|
+
return [{ route, provider, account: routeText(record.providerAccount) }];
|
|
809
|
+
}).sort((left, right) => routeTime(right.route.time) - routeTime(left.route.time));
|
|
810
|
+
}
|
|
811
|
+
function routeTime(value) {
|
|
812
|
+
if (value === null || value === undefined)
|
|
813
|
+
return 0;
|
|
814
|
+
const time = Date.parse(value);
|
|
815
|
+
return Number.isFinite(time) ? time : 0;
|
|
816
|
+
}
|
|
817
|
+
function enrichRouteWithHistory(route, history) {
|
|
818
|
+
if (route.routeId === undefined || route.routeId === null)
|
|
819
|
+
return route;
|
|
820
|
+
const record = history.find((item) => item.route.routeId === route.routeId);
|
|
821
|
+
if (record === undefined)
|
|
822
|
+
return route;
|
|
823
|
+
return {
|
|
824
|
+
...route,
|
|
825
|
+
time: route.time ?? record.route.time ?? null,
|
|
826
|
+
providerAccount: route.providerAccount ?? record.account,
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function filterSessionQuotas(quotas, providers, history) {
|
|
830
|
+
return providers.flatMap((provider) => {
|
|
831
|
+
const candidates = quotas.filter((quota) => quota.provider === provider);
|
|
832
|
+
const accounts = new Set(history
|
|
833
|
+
.filter((record) => record.provider === provider && record.account !== null)
|
|
834
|
+
.map((record) => record.account));
|
|
835
|
+
if (accounts.size === 0)
|
|
836
|
+
return candidates;
|
|
837
|
+
return candidates.filter((quota) => quota.user !== null && accounts.has(quota.user));
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
function safeRouteId(value) {
|
|
841
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? value : null;
|
|
842
|
+
}
|
|
843
|
+
/** Parse the bounded `/v1/magpie/quotas` envelope without exposing raw provider records. */
|
|
844
|
+
export function parseMagpieQuotas(value) {
|
|
845
|
+
const root = asRecord(value);
|
|
846
|
+
const rows = Array.isArray(value) ? value : Array.isArray(root?.data) ? root.data : null;
|
|
847
|
+
if (rows === null || rows.length > 512)
|
|
848
|
+
return null;
|
|
849
|
+
const quotas = [];
|
|
850
|
+
for (const row of rows) {
|
|
851
|
+
const record = asRecord(row);
|
|
852
|
+
const provider = routeText(record?.provider);
|
|
853
|
+
const name = routeText(record?.name);
|
|
854
|
+
if (record === null || provider === null || name === null)
|
|
855
|
+
return null;
|
|
856
|
+
const windowsValue = record.windows;
|
|
857
|
+
if (!Array.isArray(windowsValue) || windowsValue.length > 64)
|
|
858
|
+
return null;
|
|
859
|
+
const windows = windowsValue.flatMap((item) => {
|
|
860
|
+
const window = asRecord(item);
|
|
861
|
+
const windowName = routeText(window?.name);
|
|
862
|
+
return window === null || windowName === null ? [] : [readQuotaWindow(window, windowName)];
|
|
863
|
+
});
|
|
864
|
+
if (windows.length !== windowsValue.length)
|
|
865
|
+
return null;
|
|
866
|
+
quotas.push({
|
|
867
|
+
provider,
|
|
868
|
+
name,
|
|
869
|
+
kind: routeText(record.kind),
|
|
870
|
+
user: routeText(record.user),
|
|
871
|
+
plan: routeText(record.plan),
|
|
872
|
+
alias: routeText(record.alias),
|
|
873
|
+
balance: routeText(record.balance),
|
|
874
|
+
readAt: routeText(record.readAt),
|
|
875
|
+
windows,
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
return quotas;
|
|
879
|
+
}
|
|
880
|
+
function readQuotaWindow(record, name) {
|
|
881
|
+
return {
|
|
882
|
+
name,
|
|
883
|
+
usedPercent: safePercent(record.used),
|
|
884
|
+
remainingPercent: safePercent(record.remaining),
|
|
885
|
+
resetsAt: routeText(record.resetsAt),
|
|
886
|
+
display: routeText(record.display),
|
|
887
|
+
amount: safeDecimal(record.amount),
|
|
888
|
+
limit: safeDecimal(record.limit),
|
|
889
|
+
unit: routeText(record.unit),
|
|
890
|
+
holdsWhy: routeText(record.holdsWhy),
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
function providerFromRoute(route) {
|
|
894
|
+
if (route === null)
|
|
895
|
+
return null;
|
|
896
|
+
const models = [route.model, route.served, ...route.tries.map((attempt) => attempt.model)];
|
|
897
|
+
for (const model of models) {
|
|
898
|
+
const provider = providerFromModel(model);
|
|
899
|
+
if (provider !== null)
|
|
900
|
+
return provider;
|
|
901
|
+
}
|
|
902
|
+
return null;
|
|
903
|
+
}
|
|
904
|
+
function providerFromModelId(modelId, agent) {
|
|
905
|
+
const normalized = stripMagpieProviderPrefix(agent, modelId);
|
|
906
|
+
return providerFromModel(normalized);
|
|
907
|
+
}
|
|
908
|
+
function providerFromModel(value) {
|
|
909
|
+
if (value === null)
|
|
910
|
+
return null;
|
|
911
|
+
const slash = value.indexOf('/');
|
|
912
|
+
if (slash <= 0)
|
|
913
|
+
return null;
|
|
914
|
+
const provider = value.slice(0, slash);
|
|
915
|
+
return provider === 'group' || provider === 'auto'
|
|
916
|
+
? null
|
|
917
|
+
: /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u.test(provider) ? provider : null;
|
|
918
|
+
}
|
|
919
|
+
function readRule(value) {
|
|
920
|
+
const text = routeText(value);
|
|
921
|
+
if (text !== null)
|
|
922
|
+
return text;
|
|
923
|
+
const record = asRecord(value);
|
|
924
|
+
return routeText(record?.name) ?? routeText(record?.id);
|
|
925
|
+
}
|
|
926
|
+
function routeStatusText(value) {
|
|
927
|
+
if (typeof value === 'number' && Number.isInteger(value) && value >= 100 && value <= 599)
|
|
928
|
+
return String(value);
|
|
929
|
+
const text = routeText(value);
|
|
930
|
+
return text !== null && /^[A-Za-z0-9_-]{1,32}$/u.test(text) ? text : null;
|
|
931
|
+
}
|
|
932
|
+
function routeText(value) {
|
|
933
|
+
if (typeof value !== 'string')
|
|
934
|
+
return null;
|
|
935
|
+
const text = value.trim().replace(/[\u0000-\u001f\u007f]/gu, '').slice(0, 240);
|
|
936
|
+
return text === '' ? null : text;
|
|
937
|
+
}
|
|
938
|
+
function safePercent(value) {
|
|
939
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 100 ? value : null;
|
|
940
|
+
}
|
|
941
|
+
function safeDecimal(value) {
|
|
942
|
+
return typeof value === 'number' && Number.isFinite(value) && Math.abs(value) <= Number.MAX_SAFE_INTEGER ? value : null;
|
|
943
|
+
}
|
|
944
|
+
function cleanText(value) {
|
|
945
|
+
if (typeof value !== 'string')
|
|
946
|
+
return null;
|
|
947
|
+
const text = value.trim();
|
|
948
|
+
return text === '' || text.length > 512 || /[\u0000-\u001f\u007f]/u.test(text) ? null : text;
|
|
949
|
+
}
|
|
950
|
+
/** Pi and Command Code store Magpie selections with a local `magpie/` provider prefix. */
|
|
951
|
+
function resolveCatalogModelId(agent, requestedModelId, catalog, modelName) {
|
|
952
|
+
if (catalog === null)
|
|
953
|
+
return null;
|
|
954
|
+
const catalogModelId = catalogModelIdForRequested(agent, requestedModelId);
|
|
955
|
+
if (catalogModelId !== null && catalog.models.has(catalogModelId))
|
|
956
|
+
return catalogModelId;
|
|
957
|
+
const normalizedName = normalizeMagpieModelName(modelName);
|
|
958
|
+
return normalizedName === null ? null : catalog.names.get(normalizedName) ?? null;
|
|
959
|
+
}
|
|
960
|
+
function catalogModelIdForRequested(agent, requestedModelId) {
|
|
961
|
+
const normalized = stripMagpieProviderPrefix(agent, requestedModelId);
|
|
962
|
+
// Claude appends this context-window marker to model IDs returned by its
|
|
963
|
+
// initialize protocol; Magpie's verified catalog keeps the canonical ID.
|
|
964
|
+
return agent === 'claude' ? normalized.replace(/\[1m\]$/u, '') : normalized;
|
|
965
|
+
}
|
|
966
|
+
function stripMagpieProviderPrefix(agent, modelId) {
|
|
967
|
+
return (agent === 'commandcode' || agent === 'pi') && modelId.startsWith('magpie/')
|
|
968
|
+
? modelId.slice('magpie/'.length)
|
|
969
|
+
: modelId;
|
|
970
|
+
}
|
|
971
|
+
function normalizeMagpieModelName(value) {
|
|
972
|
+
if (typeof value !== 'string')
|
|
973
|
+
return null;
|
|
974
|
+
const name = value.trim().replace(/\s+/gu, ' ').toLocaleLowerCase('en-US');
|
|
975
|
+
return name === '' || name.length > 200 ? null : name;
|
|
976
|
+
}
|
|
977
|
+
function safeCount(value) {
|
|
978
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
979
|
+
}
|
|
980
|
+
function safeCost(value) {
|
|
981
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null;
|
|
982
|
+
}
|
|
983
|
+
function asRecord(value) {
|
|
984
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
|
|
985
|
+
}
|
|
986
|
+
//# sourceMappingURL=magpie-usage.js.map
|