indusagi-coding-agent 0.1.0 → 0.1.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/CHANGELOG.md +2249 -2249
- package/README.md +540 -546
- package/dist/cli/args.d.ts +47 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +122 -121
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +1 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +1 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +1 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +1 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +66 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +588 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +118 -98
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +107 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +5 -2
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +47 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +1 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +31 -30
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +82 -81
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +35 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +3 -2
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +1 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +1 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +1 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +1 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +1 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +905 -905
- package/dist/core/export-html/template.html +54 -54
- package/dist/core/export-html/template.js +1549 -1549
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +1 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1212 -1212
- package/dist/core/export-html/vendor/marked.min.js +6 -6
- package/dist/core/extensions/index.d.ts +10 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +1 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +1 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +104 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +20 -13
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +834 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +1 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +1 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +6 -5
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +3 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +8 -7
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +99 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +7 -4
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +76 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +1 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +134 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +6 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +1 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/resource-loader.d.ts +160 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +35 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +90 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +321 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +11 -6
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +173 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +7 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +1 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/system-prompt.d.ts +24 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +17 -16
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +1 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +44 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +1 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +1 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +37 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +1 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +37 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +1 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +43 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +1 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +73 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +38 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +1 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +1 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +37 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +1 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +1 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +27 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +1 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +1 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +1 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +11 -6
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +5 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +11 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +4 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +4 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +4 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +16 -6
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +6 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +9 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +7 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +1 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +2 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +17 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +6 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +9 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +9 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +26 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +31 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +10 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +21 -8
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +8 -2
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +14 -9
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +21 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +1 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +85 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +53 -31
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +49 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +3 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +2 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +4 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +3 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +2 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +70 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +19 -6
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +62 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +28 -13
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +7 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +8 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +1 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +1 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +323 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +124 -101
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +85 -85
- package/dist/modes/interactive/theme/light.json +84 -84
- package/dist/modes/interactive/theme/theme-schema.json +335 -335
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +6 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +1 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +209 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +8 -6
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +373 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +1 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +1 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +1 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +1 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +1 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/git.d.ts +2 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +1 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +1 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +1 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +1 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +1 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +27 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +1 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +1 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +1 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +390 -390
- package/docs/custom-provider.md +538 -538
- package/docs/development.md +69 -69
- package/docs/extensions.md +1733 -1733
- package/docs/json.md +79 -79
- package/docs/keybindings.md +162 -162
- package/docs/models.md +193 -193
- package/docs/packages.md +163 -163
- package/docs/prompt-templates.md +67 -67
- package/docs/providers.md +147 -147
- package/docs/rpc.md +1048 -1048
- package/docs/sdk.md +957 -957
- package/docs/session.md +412 -412
- package/docs/settings.md +216 -216
- package/docs/shell-aliases.md +13 -13
- package/docs/skills.md +226 -226
- package/docs/terminal-setup.md +65 -65
- package/docs/themes.md +295 -295
- package/docs/tree.md +219 -219
- package/docs/tui.md +887 -887
- package/docs/windows.md +17 -17
- package/examples/README.md +25 -25
- package/examples/extensions/README.md +192 -192
- package/examples/extensions/antigravity-image-gen.ts +414 -414
- package/examples/extensions/auto-commit-on-exit.ts +49 -49
- package/examples/extensions/bookmark.ts +50 -50
- package/examples/extensions/claude-rules.ts +86 -86
- package/examples/extensions/confirm-destructive.ts +59 -59
- package/examples/extensions/custom-compaction.ts +115 -115
- package/examples/extensions/custom-footer.ts +65 -65
- package/examples/extensions/custom-header.ts +73 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +605 -605
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -24
- package/examples/extensions/custom-provider-anthropic/package.json +19 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +350 -350
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +83 -83
- package/examples/extensions/dirty-repo-guard.ts +56 -56
- package/examples/extensions/doom-overlay/README.md +46 -46
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -72
- package/examples/extensions/doom-overlay/doom-component.ts +133 -133
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +105 -105
- package/examples/extensions/doom-overlay/index.ts +74 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -51
- package/examples/extensions/event-bus.ts +43 -43
- package/examples/extensions/file-trigger.ts +41 -41
- package/examples/extensions/git-checkpoint.ts +53 -53
- package/examples/extensions/handoff.ts +151 -151
- package/examples/extensions/hello.ts +25 -25
- package/examples/extensions/inline-bash.ts +94 -94
- package/examples/extensions/input-transform.ts +43 -43
- package/examples/extensions/interactive-shell.ts +196 -196
- package/examples/extensions/mac-system-theme.ts +47 -47
- package/examples/extensions/message-renderer.ts +60 -60
- package/examples/extensions/modal-editor.ts +86 -86
- package/examples/extensions/model-status.ts +31 -31
- package/examples/extensions/notify.ts +25 -25
- package/examples/extensions/overlay-qa-tests.ts +882 -882
- package/examples/extensions/overlay-test.ts +151 -151
- package/examples/extensions/permission-gate.ts +34 -34
- package/examples/extensions/pirate.ts +47 -47
- package/examples/extensions/plan-mode/README.md +65 -65
- package/examples/extensions/plan-mode/index.ts +341 -341
- package/examples/extensions/plan-mode/utils.ts +168 -168
- package/examples/extensions/preset.ts +399 -399
- package/examples/extensions/protected-paths.ts +30 -30
- package/examples/extensions/qna.ts +120 -120
- package/examples/extensions/question.ts +265 -265
- package/examples/extensions/questionnaire.ts +428 -428
- package/examples/extensions/rainbow-editor.ts +88 -88
- package/examples/extensions/sandbox/index.ts +318 -318
- package/examples/extensions/sandbox/package-lock.json +92 -92
- package/examples/extensions/sandbox/package.json +19 -19
- package/examples/extensions/send-user-message.ts +97 -97
- package/examples/extensions/session-name.ts +27 -27
- package/examples/extensions/shutdown-command.ts +63 -63
- package/examples/extensions/snake.ts +344 -344
- package/examples/extensions/space-invaders.ts +561 -561
- package/examples/extensions/ssh.ts +220 -220
- package/examples/extensions/status-line.ts +40 -40
- package/examples/extensions/subagent/README.md +172 -172
- package/examples/extensions/subagent/agents/planner.md +37 -37
- package/examples/extensions/subagent/agents/reviewer.md +35 -35
- package/examples/extensions/subagent/agents/scout.md +50 -50
- package/examples/extensions/subagent/agents/worker.md +24 -24
- package/examples/extensions/subagent/agents.ts +127 -127
- package/examples/extensions/subagent/index.ts +964 -964
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -10
- package/examples/extensions/subagent/prompts/implement.md +10 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -9
- package/examples/extensions/summarize.ts +196 -196
- package/examples/extensions/timed-confirm.ts +70 -70
- package/examples/extensions/todo.ts +300 -300
- package/examples/extensions/tool-override.ts +144 -144
- package/examples/extensions/tools.ts +147 -147
- package/examples/extensions/trigger-compact.ts +40 -40
- package/examples/extensions/truncated-tool.ts +193 -193
- package/examples/extensions/widget-placement.ts +17 -17
- package/examples/extensions/with-deps/index.ts +36 -36
- package/examples/extensions/with-deps/package-lock.json +31 -31
- package/examples/extensions/with-deps/package.json +22 -22
- package/examples/sdk/01-minimal.ts +22 -22
- package/examples/sdk/02-custom-model.ts +50 -50
- package/examples/sdk/03-custom-prompt.ts +55 -55
- package/examples/sdk/04-skills.ts +46 -46
- package/examples/sdk/05-tools.ts +56 -56
- package/examples/sdk/06-extensions.ts +88 -88
- package/examples/sdk/07-context-files.ts +40 -40
- package/examples/sdk/08-prompt-templates.ts +47 -47
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -48
- package/examples/sdk/10-settings.ts +38 -38
- package/examples/sdk/11-sessions.ts +48 -48
- package/examples/sdk/12-full-control.ts +82 -82
- package/examples/sdk/13-codex-oauth.ts +37 -37
- package/examples/sdk/README.md +144 -144
- package/package.json +86 -85
|
@@ -1,605 +1,605 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom Provider Example
|
|
3
|
-
*
|
|
4
|
-
* Demonstrates registering a custom provider with:
|
|
5
|
-
* - Custom API identifier ("custom-anthropic-api")
|
|
6
|
-
* - Custom streamSimple implementation
|
|
7
|
-
* - OAuth support for /login
|
|
8
|
-
* - API key support via environment variable
|
|
9
|
-
* - Two model definitions
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* # First install dependencies
|
|
13
|
-
* cd packages/coding-agent/examples/extensions/custom-provider && npm install
|
|
14
|
-
*
|
|
15
|
-
* # With OAuth (run /login custom-anthropic first)
|
|
16
|
-
* indusagi -e ./packages/coding-agent/examples/extensions/custom-provider
|
|
17
|
-
*
|
|
18
|
-
* # With API key
|
|
19
|
-
* CUSTOM_ANTHROPIC_AINDUSAGI_KEY=sk-ant-... indusagi -e ./packages/coding-agent/examples/extensions/custom-provider
|
|
20
|
-
*
|
|
21
|
-
* Then use /model to select custom-anthropic/claude-sonnet-4-5
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
25
|
-
import type { ContentBlockParam, MessageCreateParamsStreaming } from "@anthropic-ai/sdk/resources/messages.js";
|
|
26
|
-
import {
|
|
27
|
-
type Api,
|
|
28
|
-
type AssistantMessage,
|
|
29
|
-
type AssistantMessageEventStream,
|
|
30
|
-
type Context,
|
|
31
|
-
calculateCost,
|
|
32
|
-
createAssistantMessageEventStream,
|
|
33
|
-
type ImageContent,
|
|
34
|
-
type Message,
|
|
35
|
-
type Model,
|
|
36
|
-
type OAuthCredentials,
|
|
37
|
-
type OAuthLoginCallbacks,
|
|
38
|
-
type SimpleStreamOptions,
|
|
39
|
-
type StopReason,
|
|
40
|
-
type TextContent,
|
|
41
|
-
type ThinkingContent,
|
|
42
|
-
type Tool,
|
|
43
|
-
type ToolCall,
|
|
44
|
-
type ToolResultMessage,
|
|
45
|
-
} from "indusagi/ai";
|
|
46
|
-
import type { ExtensionAPI } from "indusagi-coding-agent";
|
|
47
|
-
|
|
48
|
-
// =============================================================================
|
|
49
|
-
// OAuth Implementation (copied from packages/ai/src/utils/oauth/anthropic.ts)
|
|
50
|
-
// =============================================================================
|
|
51
|
-
|
|
52
|
-
const decode = (s: string) => atob(s);
|
|
53
|
-
const CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
|
|
54
|
-
const AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
|
|
55
|
-
const TOKEN_URL = "https://console.anthropic.com/v1/oauth/token";
|
|
56
|
-
const REDIRECT_URI = "https://console.anthropic.com/oauth/code/callback";
|
|
57
|
-
const SCOPES = "org:create_api_key user:profile user:inference";
|
|
58
|
-
|
|
59
|
-
async function generatePKCE(): Promise<{ verifier: string; challenge: string }> {
|
|
60
|
-
const array = new Uint8Array(32);
|
|
61
|
-
crypto.getRandomValues(array);
|
|
62
|
-
const verifier = btoa(String.fromCharCode(...array))
|
|
63
|
-
.replace(/\+/g, "-")
|
|
64
|
-
.replace(/\//g, "_")
|
|
65
|
-
.replace(/=+$/, "");
|
|
66
|
-
|
|
67
|
-
const encoder = new TextEncoder();
|
|
68
|
-
const data = encoder.encode(verifier);
|
|
69
|
-
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
70
|
-
const challenge = btoa(String.fromCharCode(...new Uint8Array(hash)))
|
|
71
|
-
.replace(/\+/g, "-")
|
|
72
|
-
.replace(/\//g, "_")
|
|
73
|
-
.replace(/=+$/, "");
|
|
74
|
-
|
|
75
|
-
return { verifier, challenge };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function loginAnthropic(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
|
|
79
|
-
const { verifier, challenge } = await generatePKCE();
|
|
80
|
-
|
|
81
|
-
const authParams = new URLSearchParams({
|
|
82
|
-
code: "true",
|
|
83
|
-
client_id: CLIENT_ID,
|
|
84
|
-
response_type: "code",
|
|
85
|
-
redirect_uri: REDIRECT_URI,
|
|
86
|
-
scope: SCOPES,
|
|
87
|
-
code_challenge: challenge,
|
|
88
|
-
code_challenge_method: "S256",
|
|
89
|
-
state: verifier,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
callbacks.onAuth({ url: `${AUTHORIZE_URL}?${authParams.toString()}` });
|
|
93
|
-
|
|
94
|
-
const authCode = await callbacks.onPrompt({ message: "Paste the authorization code:" });
|
|
95
|
-
const [code, state] = authCode.split("#");
|
|
96
|
-
|
|
97
|
-
const tokenResponse = await fetch(TOKEN_URL, {
|
|
98
|
-
method: "POST",
|
|
99
|
-
headers: { "Content-Type": "application/json" },
|
|
100
|
-
body: JSON.stringify({
|
|
101
|
-
grant_type: "authorization_code",
|
|
102
|
-
client_id: CLIENT_ID,
|
|
103
|
-
code,
|
|
104
|
-
state,
|
|
105
|
-
redirect_uri: REDIRECT_URI,
|
|
106
|
-
code_verifier: verifier,
|
|
107
|
-
}),
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (!tokenResponse.ok) {
|
|
111
|
-
throw new Error(`Token exchange failed: ${await tokenResponse.text()}`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const data = (await tokenResponse.json()) as {
|
|
115
|
-
access_token: string;
|
|
116
|
-
refresh_token: string;
|
|
117
|
-
expires_in: number;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
refresh: data.refresh_token,
|
|
122
|
-
access: data.access_token,
|
|
123
|
-
expires: Date.now() + data.expires_in * 1000 - 5 * 60 * 1000,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function refreshAnthropicToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {
|
|
128
|
-
const response = await fetch(TOKEN_URL, {
|
|
129
|
-
method: "POST",
|
|
130
|
-
headers: { "Content-Type": "application/json" },
|
|
131
|
-
body: JSON.stringify({
|
|
132
|
-
grant_type: "refresh_token",
|
|
133
|
-
client_id: CLIENT_ID,
|
|
134
|
-
refresh_token: credentials.refresh,
|
|
135
|
-
}),
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
throw new Error(`Token refresh failed: ${await response.text()}`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const data = (await response.json()) as {
|
|
143
|
-
access_token: string;
|
|
144
|
-
refresh_token: string;
|
|
145
|
-
expires_in: number;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
refresh: data.refresh_token,
|
|
150
|
-
access: data.access_token,
|
|
151
|
-
expires: Date.now() + data.expires_in * 1000 - 5 * 60 * 1000,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// =============================================================================
|
|
156
|
-
// Streaming Implementation (simplified from packages/ai/src/providers/anthropic.ts)
|
|
157
|
-
// =============================================================================
|
|
158
|
-
|
|
159
|
-
// Claude Code tool names for OAuth stealth mode
|
|
160
|
-
const claudeCodeTools = [
|
|
161
|
-
"Read",
|
|
162
|
-
"Write",
|
|
163
|
-
"Edit",
|
|
164
|
-
"Bash",
|
|
165
|
-
"Grep",
|
|
166
|
-
"Glob",
|
|
167
|
-
"AskUserQuestion",
|
|
168
|
-
"TodoWrite",
|
|
169
|
-
"WebFetch",
|
|
170
|
-
"WebSearch",
|
|
171
|
-
];
|
|
172
|
-
const ccToolLookup = new Map(claudeCodeTools.map((t) => [t.toLowerCase(), t]));
|
|
173
|
-
const toClaudeCodeName = (name: string) => ccToolLookup.get(name.toLowerCase()) ?? name;
|
|
174
|
-
const fromClaudeCodeName = (name: string, tools?: Tool[]) => {
|
|
175
|
-
const lowerName = name.toLowerCase();
|
|
176
|
-
const matched = tools?.find((t) => t.name.toLowerCase() === lowerName);
|
|
177
|
-
return matched?.name ?? name;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
function isOAuthToken(apiKey: string): boolean {
|
|
181
|
-
return apiKey.includes("sk-ant-oat");
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function sanitizeSurrogates(text: string): string {
|
|
185
|
-
return text.replace(/[\uD800-\uDFFF]/g, "\uFFFD");
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function convertContentBlocks(
|
|
189
|
-
content: (TextContent | ImageContent)[],
|
|
190
|
-
): string | Array<{ type: "text"; text: string } | { type: "image"; source: any }> {
|
|
191
|
-
const hasImages = content.some((c) => c.type === "image");
|
|
192
|
-
if (!hasImages) {
|
|
193
|
-
return sanitizeSurrogates(content.map((c) => (c as TextContent).text).join("\n"));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const blocks = content.map((block) => {
|
|
197
|
-
if (block.type === "text") {
|
|
198
|
-
return { type: "text" as const, text: sanitizeSurrogates(block.text) };
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
type: "image" as const,
|
|
202
|
-
source: {
|
|
203
|
-
type: "base64" as const,
|
|
204
|
-
media_type: block.mimeType,
|
|
205
|
-
data: block.data,
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
if (!blocks.some((b) => b.type === "text")) {
|
|
211
|
-
blocks.unshift({ type: "text" as const, text: "(see attached image)" });
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return blocks;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function convertMessages(messages: Message[], isOAuth: boolean, _tools?: Tool[]): any[] {
|
|
218
|
-
const params: any[] = [];
|
|
219
|
-
|
|
220
|
-
for (let i = 0; i < messages.length; i++) {
|
|
221
|
-
const msg = messages[i];
|
|
222
|
-
|
|
223
|
-
if (msg.role === "user") {
|
|
224
|
-
if (typeof msg.content === "string") {
|
|
225
|
-
if (msg.content.trim()) {
|
|
226
|
-
params.push({ role: "user", content: sanitizeSurrogates(msg.content) });
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
const blocks: ContentBlockParam[] = msg.content.map((item) =>
|
|
230
|
-
item.type === "text"
|
|
231
|
-
? { type: "text" as const, text: sanitizeSurrogates(item.text) }
|
|
232
|
-
: {
|
|
233
|
-
type: "image" as const,
|
|
234
|
-
source: { type: "base64" as const, media_type: item.mimeType as any, data: item.data },
|
|
235
|
-
},
|
|
236
|
-
);
|
|
237
|
-
if (blocks.length > 0) {
|
|
238
|
-
params.push({ role: "user", content: blocks });
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
} else if (msg.role === "assistant") {
|
|
242
|
-
const blocks: ContentBlockParam[] = [];
|
|
243
|
-
for (const block of msg.content) {
|
|
244
|
-
if (block.type === "text" && block.text.trim()) {
|
|
245
|
-
blocks.push({ type: "text", text: sanitizeSurrogates(block.text) });
|
|
246
|
-
} else if (block.type === "thinking" && block.thinking.trim()) {
|
|
247
|
-
if ((block as ThinkingContent).thinkingSignature) {
|
|
248
|
-
blocks.push({
|
|
249
|
-
type: "thinking" as any,
|
|
250
|
-
thinking: sanitizeSurrogates(block.thinking),
|
|
251
|
-
signature: (block as ThinkingContent).thinkingSignature!,
|
|
252
|
-
});
|
|
253
|
-
} else {
|
|
254
|
-
blocks.push({ type: "text", text: sanitizeSurrogates(block.thinking) });
|
|
255
|
-
}
|
|
256
|
-
} else if (block.type === "toolCall") {
|
|
257
|
-
blocks.push({
|
|
258
|
-
type: "tool_use",
|
|
259
|
-
id: block.id,
|
|
260
|
-
name: isOAuth ? toClaudeCodeName(block.name) : block.name,
|
|
261
|
-
input: block.arguments,
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if (blocks.length > 0) {
|
|
266
|
-
params.push({ role: "assistant", content: blocks });
|
|
267
|
-
}
|
|
268
|
-
} else if (msg.role === "toolResult") {
|
|
269
|
-
const toolResults: any[] = [];
|
|
270
|
-
toolResults.push({
|
|
271
|
-
type: "tool_result",
|
|
272
|
-
tool_use_id: msg.toolCallId,
|
|
273
|
-
content: convertContentBlocks(msg.content),
|
|
274
|
-
is_error: msg.isError,
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
let j = i + 1;
|
|
278
|
-
while (j < messages.length && messages[j].role === "toolResult") {
|
|
279
|
-
const nextMsg = messages[j] as ToolResultMessage;
|
|
280
|
-
toolResults.push({
|
|
281
|
-
type: "tool_result",
|
|
282
|
-
tool_use_id: nextMsg.toolCallId,
|
|
283
|
-
content: convertContentBlocks(nextMsg.content),
|
|
284
|
-
is_error: nextMsg.isError,
|
|
285
|
-
});
|
|
286
|
-
j++;
|
|
287
|
-
}
|
|
288
|
-
i = j - 1;
|
|
289
|
-
params.push({ role: "user", content: toolResults });
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Add cache control to last user message
|
|
294
|
-
if (params.length > 0) {
|
|
295
|
-
const last = params[params.length - 1];
|
|
296
|
-
if (last.role === "user" && Array.isArray(last.content)) {
|
|
297
|
-
const lastBlock = last.content[last.content.length - 1];
|
|
298
|
-
if (lastBlock) {
|
|
299
|
-
lastBlock.cache_control = { type: "ephemeral" };
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return params;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function convertTools(tools: Tool[], isOAuth: boolean): any[] {
|
|
308
|
-
return tools.map((tool) => ({
|
|
309
|
-
name: isOAuth ? toClaudeCodeName(tool.name) : tool.name,
|
|
310
|
-
description: tool.description,
|
|
311
|
-
input_schema: {
|
|
312
|
-
type: "object",
|
|
313
|
-
properties: (tool.parameters as any).properties || {},
|
|
314
|
-
required: (tool.parameters as any).required || [],
|
|
315
|
-
},
|
|
316
|
-
}));
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function mapStopReason(reason: string): StopReason {
|
|
320
|
-
switch (reason) {
|
|
321
|
-
case "end_turn":
|
|
322
|
-
case "pause_turn":
|
|
323
|
-
case "stop_sequence":
|
|
324
|
-
return "stop";
|
|
325
|
-
case "max_tokens":
|
|
326
|
-
return "length";
|
|
327
|
-
case "tool_use":
|
|
328
|
-
return "toolUse";
|
|
329
|
-
default:
|
|
330
|
-
return "error";
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function streamCustomAnthropic(
|
|
335
|
-
model: Model<Api>,
|
|
336
|
-
context: Context,
|
|
337
|
-
options?: SimpleStreamOptions,
|
|
338
|
-
): AssistantMessageEventStream {
|
|
339
|
-
const stream = createAssistantMessageEventStream();
|
|
340
|
-
|
|
341
|
-
(async () => {
|
|
342
|
-
const output: AssistantMessage = {
|
|
343
|
-
role: "assistant",
|
|
344
|
-
content: [],
|
|
345
|
-
api: model.api,
|
|
346
|
-
provider: model.provider,
|
|
347
|
-
model: model.id,
|
|
348
|
-
usage: {
|
|
349
|
-
input: 0,
|
|
350
|
-
output: 0,
|
|
351
|
-
cacheRead: 0,
|
|
352
|
-
cacheWrite: 0,
|
|
353
|
-
totalTokens: 0,
|
|
354
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
355
|
-
},
|
|
356
|
-
stopReason: "stop",
|
|
357
|
-
timestamp: Date.now(),
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
try {
|
|
361
|
-
const apiKey = options?.apiKey ?? "";
|
|
362
|
-
const isOAuth = isOAuthToken(apiKey);
|
|
363
|
-
|
|
364
|
-
// Configure client based on auth type
|
|
365
|
-
const betaFeatures = ["fine-grained-tool-streaming-2025-05-14", "interleaved-thinking-2025-05-14"];
|
|
366
|
-
const clientOptions: any = {
|
|
367
|
-
baseURL: model.baseUrl,
|
|
368
|
-
dangerouslyAllowBrowser: true,
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
if (isOAuth) {
|
|
372
|
-
clientOptions.apiKey = null;
|
|
373
|
-
clientOptions.authToken = apiKey;
|
|
374
|
-
clientOptions.defaultHeaders = {
|
|
375
|
-
accept: "application/json",
|
|
376
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
377
|
-
"anthropic-beta": `claude-code-20250219,oauth-2025-04-20,${betaFeatures.join(",")}`,
|
|
378
|
-
"user-agent": "claude-cli/2.1.2 (external, cli)",
|
|
379
|
-
"x-app": "cli",
|
|
380
|
-
};
|
|
381
|
-
} else {
|
|
382
|
-
clientOptions.apiKey = apiKey;
|
|
383
|
-
clientOptions.defaultHeaders = {
|
|
384
|
-
accept: "application/json",
|
|
385
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
386
|
-
"anthropic-beta": betaFeatures.join(","),
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const client = new Anthropic(clientOptions);
|
|
391
|
-
|
|
392
|
-
// Build request params
|
|
393
|
-
const params: MessageCreateParamsStreaming = {
|
|
394
|
-
model: model.id,
|
|
395
|
-
messages: convertMessages(context.messages, isOAuth, context.tools),
|
|
396
|
-
max_tokens: options?.maxTokens || Math.floor(model.maxTokens / 3),
|
|
397
|
-
stream: true,
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
// System prompt with Claude Code identity for OAuth
|
|
401
|
-
if (isOAuth) {
|
|
402
|
-
params.system = [
|
|
403
|
-
{
|
|
404
|
-
type: "text",
|
|
405
|
-
text: "You are Claude Code, Anthropic's official CLI for Claude.",
|
|
406
|
-
cache_control: { type: "ephemeral" },
|
|
407
|
-
},
|
|
408
|
-
];
|
|
409
|
-
if (context.systemPrompt) {
|
|
410
|
-
params.system.push({
|
|
411
|
-
type: "text",
|
|
412
|
-
text: sanitizeSurrogates(context.systemPrompt),
|
|
413
|
-
cache_control: { type: "ephemeral" },
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
} else if (context.systemPrompt) {
|
|
417
|
-
params.system = [
|
|
418
|
-
{
|
|
419
|
-
type: "text",
|
|
420
|
-
text: sanitizeSurrogates(context.systemPrompt),
|
|
421
|
-
cache_control: { type: "ephemeral" },
|
|
422
|
-
},
|
|
423
|
-
];
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (context.tools) {
|
|
427
|
-
params.tools = convertTools(context.tools, isOAuth);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// Handle thinking/reasoning
|
|
431
|
-
if (options?.reasoning && model.reasoning) {
|
|
432
|
-
const defaultBudgets: Record<string, number> = {
|
|
433
|
-
minimal: 1024,
|
|
434
|
-
low: 4096,
|
|
435
|
-
medium: 10240,
|
|
436
|
-
high: 20480,
|
|
437
|
-
};
|
|
438
|
-
const customBudget = options.thinkingBudgets?.[options.reasoning as keyof typeof options.thinkingBudgets];
|
|
439
|
-
params.thinking = {
|
|
440
|
-
type: "enabled",
|
|
441
|
-
budget_tokens: customBudget ?? defaultBudgets[options.reasoning] ?? 10240,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const anthropicStream = client.messages.stream({ ...params }, { signal: options?.signal });
|
|
446
|
-
stream.push({ type: "start", partial: output });
|
|
447
|
-
|
|
448
|
-
type Block = (ThinkingContent | TextContent | (ToolCall & { partialJson: string })) & { index: number };
|
|
449
|
-
const blocks = output.content as Block[];
|
|
450
|
-
|
|
451
|
-
for await (const event of anthropicStream) {
|
|
452
|
-
if (event.type === "message_start") {
|
|
453
|
-
output.usage.input = event.message.usage.input_tokens || 0;
|
|
454
|
-
output.usage.output = event.message.usage.output_tokens || 0;
|
|
455
|
-
output.usage.cacheRead = (event.message.usage as any).cache_read_input_tokens || 0;
|
|
456
|
-
output.usage.cacheWrite = (event.message.usage as any).cache_creation_input_tokens || 0;
|
|
457
|
-
output.usage.totalTokens =
|
|
458
|
-
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
459
|
-
calculateCost(model, output.usage);
|
|
460
|
-
} else if (event.type === "content_block_start") {
|
|
461
|
-
if (event.content_block.type === "text") {
|
|
462
|
-
output.content.push({ type: "text", text: "", index: event.index } as any);
|
|
463
|
-
stream.push({ type: "text_start", contentIndex: output.content.length - 1, partial: output });
|
|
464
|
-
} else if (event.content_block.type === "thinking") {
|
|
465
|
-
output.content.push({
|
|
466
|
-
type: "thinking",
|
|
467
|
-
thinking: "",
|
|
468
|
-
thinkingSignature: "",
|
|
469
|
-
index: event.index,
|
|
470
|
-
} as any);
|
|
471
|
-
stream.push({ type: "thinking_start", contentIndex: output.content.length - 1, partial: output });
|
|
472
|
-
} else if (event.content_block.type === "tool_use") {
|
|
473
|
-
output.content.push({
|
|
474
|
-
type: "toolCall",
|
|
475
|
-
id: event.content_block.id,
|
|
476
|
-
name: isOAuth
|
|
477
|
-
? fromClaudeCodeName(event.content_block.name, context.tools)
|
|
478
|
-
: event.content_block.name,
|
|
479
|
-
arguments: {},
|
|
480
|
-
partialJson: "",
|
|
481
|
-
index: event.index,
|
|
482
|
-
} as any);
|
|
483
|
-
stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
|
|
484
|
-
}
|
|
485
|
-
} else if (event.type === "content_block_delta") {
|
|
486
|
-
const index = blocks.findIndex((b) => b.index === event.index);
|
|
487
|
-
const block = blocks[index];
|
|
488
|
-
if (!block) continue;
|
|
489
|
-
|
|
490
|
-
if (event.delta.type === "text_delta" && block.type === "text") {
|
|
491
|
-
block.text += event.delta.text;
|
|
492
|
-
stream.push({ type: "text_delta", contentIndex: index, delta: event.delta.text, partial: output });
|
|
493
|
-
} else if (event.delta.type === "thinking_delta" && block.type === "thinking") {
|
|
494
|
-
block.thinking += event.delta.thinking;
|
|
495
|
-
stream.push({
|
|
496
|
-
type: "thinking_delta",
|
|
497
|
-
contentIndex: index,
|
|
498
|
-
delta: event.delta.thinking,
|
|
499
|
-
partial: output,
|
|
500
|
-
});
|
|
501
|
-
} else if (event.delta.type === "input_json_delta" && block.type === "toolCall") {
|
|
502
|
-
(block as any).partialJson += event.delta.partial_json;
|
|
503
|
-
try {
|
|
504
|
-
block.arguments = JSON.parse((block as any).partialJson);
|
|
505
|
-
} catch {}
|
|
506
|
-
stream.push({
|
|
507
|
-
type: "toolcall_delta",
|
|
508
|
-
contentIndex: index,
|
|
509
|
-
delta: event.delta.partial_json,
|
|
510
|
-
partial: output,
|
|
511
|
-
});
|
|
512
|
-
} else if (event.delta.type === "signature_delta" && block.type === "thinking") {
|
|
513
|
-
block.thinkingSignature = (block.thinkingSignature || "") + (event.delta as any).signature;
|
|
514
|
-
}
|
|
515
|
-
} else if (event.type === "content_block_stop") {
|
|
516
|
-
const index = blocks.findIndex((b) => b.index === event.index);
|
|
517
|
-
const block = blocks[index];
|
|
518
|
-
if (!block) continue;
|
|
519
|
-
|
|
520
|
-
delete (block as any).index;
|
|
521
|
-
if (block.type === "text") {
|
|
522
|
-
stream.push({ type: "text_end", contentIndex: index, content: block.text, partial: output });
|
|
523
|
-
} else if (block.type === "thinking") {
|
|
524
|
-
stream.push({ type: "thinking_end", contentIndex: index, content: block.thinking, partial: output });
|
|
525
|
-
} else if (block.type === "toolCall") {
|
|
526
|
-
try {
|
|
527
|
-
block.arguments = JSON.parse((block as any).partialJson);
|
|
528
|
-
} catch {}
|
|
529
|
-
delete (block as any).partialJson;
|
|
530
|
-
stream.push({ type: "toolcall_end", contentIndex: index, toolCall: block, partial: output });
|
|
531
|
-
}
|
|
532
|
-
} else if (event.type === "message_delta") {
|
|
533
|
-
if ((event.delta as any).stop_reason) {
|
|
534
|
-
output.stopReason = mapStopReason((event.delta as any).stop_reason);
|
|
535
|
-
}
|
|
536
|
-
output.usage.input = (event.usage as any).input_tokens || 0;
|
|
537
|
-
output.usage.output = (event.usage as any).output_tokens || 0;
|
|
538
|
-
output.usage.cacheRead = (event.usage as any).cache_read_input_tokens || 0;
|
|
539
|
-
output.usage.cacheWrite = (event.usage as any).cache_creation_input_tokens || 0;
|
|
540
|
-
output.usage.totalTokens =
|
|
541
|
-
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
542
|
-
calculateCost(model, output.usage);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
if (options?.signal?.aborted) {
|
|
547
|
-
throw new Error("Request was aborted");
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
stream.push({ type: "done", reason: output.stopReason as "stop" | "length" | "toolUse", message: output });
|
|
551
|
-
stream.end();
|
|
552
|
-
} catch (error) {
|
|
553
|
-
for (const block of output.content) delete (block as any).index;
|
|
554
|
-
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
555
|
-
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
556
|
-
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
557
|
-
stream.end();
|
|
558
|
-
}
|
|
559
|
-
})();
|
|
560
|
-
|
|
561
|
-
return stream;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// =============================================================================
|
|
565
|
-
// Extension Entry Point
|
|
566
|
-
// =============================================================================
|
|
567
|
-
|
|
568
|
-
export default function (indusagi: ExtensionAPI) {
|
|
569
|
-
indusagi.registerProvider("custom-anthropic", {
|
|
570
|
-
baseUrl: "https://api.anthropic.com",
|
|
571
|
-
apiKey: "CUSTOM_ANTHROPIC_AINDUSAGI_KEY",
|
|
572
|
-
api: "custom-anthropic-api",
|
|
573
|
-
|
|
574
|
-
models: [
|
|
575
|
-
{
|
|
576
|
-
id: "claude-opus-4-5",
|
|
577
|
-
name: "Claude Opus 4.5 (Custom)",
|
|
578
|
-
reasoning: true,
|
|
579
|
-
input: ["text", "image"],
|
|
580
|
-
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
581
|
-
contextWindow: 200000,
|
|
582
|
-
maxTokens: 64000,
|
|
583
|
-
},
|
|
584
|
-
{
|
|
585
|
-
id: "claude-sonnet-4-5",
|
|
586
|
-
name: "Claude Sonnet 4.5 (Custom)",
|
|
587
|
-
reasoning: true,
|
|
588
|
-
input: ["text", "image"],
|
|
589
|
-
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
590
|
-
contextWindow: 200000,
|
|
591
|
-
maxTokens: 64000,
|
|
592
|
-
},
|
|
593
|
-
],
|
|
594
|
-
|
|
595
|
-
oauth: {
|
|
596
|
-
name: "Custom Anthropic (Claude Pro/Max)",
|
|
597
|
-
login: loginAnthropic,
|
|
598
|
-
refreshToken: refreshAnthropicToken,
|
|
599
|
-
getApiKey: (cred) => cred.access,
|
|
600
|
-
},
|
|
601
|
-
|
|
602
|
-
streamSimple: streamCustomAnthropic,
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Custom Provider Example
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates registering a custom provider with:
|
|
5
|
+
* - Custom API identifier ("custom-anthropic-api")
|
|
6
|
+
* - Custom streamSimple implementation
|
|
7
|
+
* - OAuth support for /login
|
|
8
|
+
* - API key support via environment variable
|
|
9
|
+
* - Two model definitions
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* # First install dependencies
|
|
13
|
+
* cd packages/coding-agent/examples/extensions/custom-provider && npm install
|
|
14
|
+
*
|
|
15
|
+
* # With OAuth (run /login custom-anthropic first)
|
|
16
|
+
* indusagi -e ./packages/coding-agent/examples/extensions/custom-provider
|
|
17
|
+
*
|
|
18
|
+
* # With API key
|
|
19
|
+
* CUSTOM_ANTHROPIC_AINDUSAGI_KEY=sk-ant-... indusagi -e ./packages/coding-agent/examples/extensions/custom-provider
|
|
20
|
+
*
|
|
21
|
+
* Then use /model to select custom-anthropic/claude-sonnet-4-5
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
25
|
+
import type { ContentBlockParam, MessageCreateParamsStreaming } from "@anthropic-ai/sdk/resources/messages.js";
|
|
26
|
+
import {
|
|
27
|
+
type Api,
|
|
28
|
+
type AssistantMessage,
|
|
29
|
+
type AssistantMessageEventStream,
|
|
30
|
+
type Context,
|
|
31
|
+
calculateCost,
|
|
32
|
+
createAssistantMessageEventStream,
|
|
33
|
+
type ImageContent,
|
|
34
|
+
type Message,
|
|
35
|
+
type Model,
|
|
36
|
+
type OAuthCredentials,
|
|
37
|
+
type OAuthLoginCallbacks,
|
|
38
|
+
type SimpleStreamOptions,
|
|
39
|
+
type StopReason,
|
|
40
|
+
type TextContent,
|
|
41
|
+
type ThinkingContent,
|
|
42
|
+
type Tool,
|
|
43
|
+
type ToolCall,
|
|
44
|
+
type ToolResultMessage,
|
|
45
|
+
} from "indusagi/ai";
|
|
46
|
+
import type { ExtensionAPI } from "indusagi-coding-agent";
|
|
47
|
+
|
|
48
|
+
// =============================================================================
|
|
49
|
+
// OAuth Implementation (copied from packages/ai/src/utils/oauth/anthropic.ts)
|
|
50
|
+
// =============================================================================
|
|
51
|
+
|
|
52
|
+
const decode = (s: string) => atob(s);
|
|
53
|
+
const CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
|
|
54
|
+
const AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
|
|
55
|
+
const TOKEN_URL = "https://console.anthropic.com/v1/oauth/token";
|
|
56
|
+
const REDIRECT_URI = "https://console.anthropic.com/oauth/code/callback";
|
|
57
|
+
const SCOPES = "org:create_api_key user:profile user:inference";
|
|
58
|
+
|
|
59
|
+
async function generatePKCE(): Promise<{ verifier: string; challenge: string }> {
|
|
60
|
+
const array = new Uint8Array(32);
|
|
61
|
+
crypto.getRandomValues(array);
|
|
62
|
+
const verifier = btoa(String.fromCharCode(...array))
|
|
63
|
+
.replace(/\+/g, "-")
|
|
64
|
+
.replace(/\//g, "_")
|
|
65
|
+
.replace(/=+$/, "");
|
|
66
|
+
|
|
67
|
+
const encoder = new TextEncoder();
|
|
68
|
+
const data = encoder.encode(verifier);
|
|
69
|
+
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
70
|
+
const challenge = btoa(String.fromCharCode(...new Uint8Array(hash)))
|
|
71
|
+
.replace(/\+/g, "-")
|
|
72
|
+
.replace(/\//g, "_")
|
|
73
|
+
.replace(/=+$/, "");
|
|
74
|
+
|
|
75
|
+
return { verifier, challenge };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function loginAnthropic(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
|
|
79
|
+
const { verifier, challenge } = await generatePKCE();
|
|
80
|
+
|
|
81
|
+
const authParams = new URLSearchParams({
|
|
82
|
+
code: "true",
|
|
83
|
+
client_id: CLIENT_ID,
|
|
84
|
+
response_type: "code",
|
|
85
|
+
redirect_uri: REDIRECT_URI,
|
|
86
|
+
scope: SCOPES,
|
|
87
|
+
code_challenge: challenge,
|
|
88
|
+
code_challenge_method: "S256",
|
|
89
|
+
state: verifier,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
callbacks.onAuth({ url: `${AUTHORIZE_URL}?${authParams.toString()}` });
|
|
93
|
+
|
|
94
|
+
const authCode = await callbacks.onPrompt({ message: "Paste the authorization code:" });
|
|
95
|
+
const [code, state] = authCode.split("#");
|
|
96
|
+
|
|
97
|
+
const tokenResponse = await fetch(TOKEN_URL, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: { "Content-Type": "application/json" },
|
|
100
|
+
body: JSON.stringify({
|
|
101
|
+
grant_type: "authorization_code",
|
|
102
|
+
client_id: CLIENT_ID,
|
|
103
|
+
code,
|
|
104
|
+
state,
|
|
105
|
+
redirect_uri: REDIRECT_URI,
|
|
106
|
+
code_verifier: verifier,
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (!tokenResponse.ok) {
|
|
111
|
+
throw new Error(`Token exchange failed: ${await tokenResponse.text()}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const data = (await tokenResponse.json()) as {
|
|
115
|
+
access_token: string;
|
|
116
|
+
refresh_token: string;
|
|
117
|
+
expires_in: number;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
refresh: data.refresh_token,
|
|
122
|
+
access: data.access_token,
|
|
123
|
+
expires: Date.now() + data.expires_in * 1000 - 5 * 60 * 1000,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function refreshAnthropicToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {
|
|
128
|
+
const response = await fetch(TOKEN_URL, {
|
|
129
|
+
method: "POST",
|
|
130
|
+
headers: { "Content-Type": "application/json" },
|
|
131
|
+
body: JSON.stringify({
|
|
132
|
+
grant_type: "refresh_token",
|
|
133
|
+
client_id: CLIENT_ID,
|
|
134
|
+
refresh_token: credentials.refresh,
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (!response.ok) {
|
|
139
|
+
throw new Error(`Token refresh failed: ${await response.text()}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const data = (await response.json()) as {
|
|
143
|
+
access_token: string;
|
|
144
|
+
refresh_token: string;
|
|
145
|
+
expires_in: number;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
refresh: data.refresh_token,
|
|
150
|
+
access: data.access_token,
|
|
151
|
+
expires: Date.now() + data.expires_in * 1000 - 5 * 60 * 1000,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// =============================================================================
|
|
156
|
+
// Streaming Implementation (simplified from packages/ai/src/providers/anthropic.ts)
|
|
157
|
+
// =============================================================================
|
|
158
|
+
|
|
159
|
+
// Claude Code tool names for OAuth stealth mode
|
|
160
|
+
const claudeCodeTools = [
|
|
161
|
+
"Read",
|
|
162
|
+
"Write",
|
|
163
|
+
"Edit",
|
|
164
|
+
"Bash",
|
|
165
|
+
"Grep",
|
|
166
|
+
"Glob",
|
|
167
|
+
"AskUserQuestion",
|
|
168
|
+
"TodoWrite",
|
|
169
|
+
"WebFetch",
|
|
170
|
+
"WebSearch",
|
|
171
|
+
];
|
|
172
|
+
const ccToolLookup = new Map(claudeCodeTools.map((t) => [t.toLowerCase(), t]));
|
|
173
|
+
const toClaudeCodeName = (name: string) => ccToolLookup.get(name.toLowerCase()) ?? name;
|
|
174
|
+
const fromClaudeCodeName = (name: string, tools?: Tool[]) => {
|
|
175
|
+
const lowerName = name.toLowerCase();
|
|
176
|
+
const matched = tools?.find((t) => t.name.toLowerCase() === lowerName);
|
|
177
|
+
return matched?.name ?? name;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
function isOAuthToken(apiKey: string): boolean {
|
|
181
|
+
return apiKey.includes("sk-ant-oat");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function sanitizeSurrogates(text: string): string {
|
|
185
|
+
return text.replace(/[\uD800-\uDFFF]/g, "\uFFFD");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function convertContentBlocks(
|
|
189
|
+
content: (TextContent | ImageContent)[],
|
|
190
|
+
): string | Array<{ type: "text"; text: string } | { type: "image"; source: any }> {
|
|
191
|
+
const hasImages = content.some((c) => c.type === "image");
|
|
192
|
+
if (!hasImages) {
|
|
193
|
+
return sanitizeSurrogates(content.map((c) => (c as TextContent).text).join("\n"));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const blocks = content.map((block) => {
|
|
197
|
+
if (block.type === "text") {
|
|
198
|
+
return { type: "text" as const, text: sanitizeSurrogates(block.text) };
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
type: "image" as const,
|
|
202
|
+
source: {
|
|
203
|
+
type: "base64" as const,
|
|
204
|
+
media_type: block.mimeType,
|
|
205
|
+
data: block.data,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (!blocks.some((b) => b.type === "text")) {
|
|
211
|
+
blocks.unshift({ type: "text" as const, text: "(see attached image)" });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return blocks;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function convertMessages(messages: Message[], isOAuth: boolean, _tools?: Tool[]): any[] {
|
|
218
|
+
const params: any[] = [];
|
|
219
|
+
|
|
220
|
+
for (let i = 0; i < messages.length; i++) {
|
|
221
|
+
const msg = messages[i];
|
|
222
|
+
|
|
223
|
+
if (msg.role === "user") {
|
|
224
|
+
if (typeof msg.content === "string") {
|
|
225
|
+
if (msg.content.trim()) {
|
|
226
|
+
params.push({ role: "user", content: sanitizeSurrogates(msg.content) });
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
const blocks: ContentBlockParam[] = msg.content.map((item) =>
|
|
230
|
+
item.type === "text"
|
|
231
|
+
? { type: "text" as const, text: sanitizeSurrogates(item.text) }
|
|
232
|
+
: {
|
|
233
|
+
type: "image" as const,
|
|
234
|
+
source: { type: "base64" as const, media_type: item.mimeType as any, data: item.data },
|
|
235
|
+
},
|
|
236
|
+
);
|
|
237
|
+
if (blocks.length > 0) {
|
|
238
|
+
params.push({ role: "user", content: blocks });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
} else if (msg.role === "assistant") {
|
|
242
|
+
const blocks: ContentBlockParam[] = [];
|
|
243
|
+
for (const block of msg.content) {
|
|
244
|
+
if (block.type === "text" && block.text.trim()) {
|
|
245
|
+
blocks.push({ type: "text", text: sanitizeSurrogates(block.text) });
|
|
246
|
+
} else if (block.type === "thinking" && block.thinking.trim()) {
|
|
247
|
+
if ((block as ThinkingContent).thinkingSignature) {
|
|
248
|
+
blocks.push({
|
|
249
|
+
type: "thinking" as any,
|
|
250
|
+
thinking: sanitizeSurrogates(block.thinking),
|
|
251
|
+
signature: (block as ThinkingContent).thinkingSignature!,
|
|
252
|
+
});
|
|
253
|
+
} else {
|
|
254
|
+
blocks.push({ type: "text", text: sanitizeSurrogates(block.thinking) });
|
|
255
|
+
}
|
|
256
|
+
} else if (block.type === "toolCall") {
|
|
257
|
+
blocks.push({
|
|
258
|
+
type: "tool_use",
|
|
259
|
+
id: block.id,
|
|
260
|
+
name: isOAuth ? toClaudeCodeName(block.name) : block.name,
|
|
261
|
+
input: block.arguments,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (blocks.length > 0) {
|
|
266
|
+
params.push({ role: "assistant", content: blocks });
|
|
267
|
+
}
|
|
268
|
+
} else if (msg.role === "toolResult") {
|
|
269
|
+
const toolResults: any[] = [];
|
|
270
|
+
toolResults.push({
|
|
271
|
+
type: "tool_result",
|
|
272
|
+
tool_use_id: msg.toolCallId,
|
|
273
|
+
content: convertContentBlocks(msg.content),
|
|
274
|
+
is_error: msg.isError,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
let j = i + 1;
|
|
278
|
+
while (j < messages.length && messages[j].role === "toolResult") {
|
|
279
|
+
const nextMsg = messages[j] as ToolResultMessage;
|
|
280
|
+
toolResults.push({
|
|
281
|
+
type: "tool_result",
|
|
282
|
+
tool_use_id: nextMsg.toolCallId,
|
|
283
|
+
content: convertContentBlocks(nextMsg.content),
|
|
284
|
+
is_error: nextMsg.isError,
|
|
285
|
+
});
|
|
286
|
+
j++;
|
|
287
|
+
}
|
|
288
|
+
i = j - 1;
|
|
289
|
+
params.push({ role: "user", content: toolResults });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Add cache control to last user message
|
|
294
|
+
if (params.length > 0) {
|
|
295
|
+
const last = params[params.length - 1];
|
|
296
|
+
if (last.role === "user" && Array.isArray(last.content)) {
|
|
297
|
+
const lastBlock = last.content[last.content.length - 1];
|
|
298
|
+
if (lastBlock) {
|
|
299
|
+
lastBlock.cache_control = { type: "ephemeral" };
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return params;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function convertTools(tools: Tool[], isOAuth: boolean): any[] {
|
|
308
|
+
return tools.map((tool) => ({
|
|
309
|
+
name: isOAuth ? toClaudeCodeName(tool.name) : tool.name,
|
|
310
|
+
description: tool.description,
|
|
311
|
+
input_schema: {
|
|
312
|
+
type: "object",
|
|
313
|
+
properties: (tool.parameters as any).properties || {},
|
|
314
|
+
required: (tool.parameters as any).required || [],
|
|
315
|
+
},
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function mapStopReason(reason: string): StopReason {
|
|
320
|
+
switch (reason) {
|
|
321
|
+
case "end_turn":
|
|
322
|
+
case "pause_turn":
|
|
323
|
+
case "stop_sequence":
|
|
324
|
+
return "stop";
|
|
325
|
+
case "max_tokens":
|
|
326
|
+
return "length";
|
|
327
|
+
case "tool_use":
|
|
328
|
+
return "toolUse";
|
|
329
|
+
default:
|
|
330
|
+
return "error";
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function streamCustomAnthropic(
|
|
335
|
+
model: Model<Api>,
|
|
336
|
+
context: Context,
|
|
337
|
+
options?: SimpleStreamOptions,
|
|
338
|
+
): AssistantMessageEventStream {
|
|
339
|
+
const stream = createAssistantMessageEventStream();
|
|
340
|
+
|
|
341
|
+
(async () => {
|
|
342
|
+
const output: AssistantMessage = {
|
|
343
|
+
role: "assistant",
|
|
344
|
+
content: [],
|
|
345
|
+
api: model.api,
|
|
346
|
+
provider: model.provider,
|
|
347
|
+
model: model.id,
|
|
348
|
+
usage: {
|
|
349
|
+
input: 0,
|
|
350
|
+
output: 0,
|
|
351
|
+
cacheRead: 0,
|
|
352
|
+
cacheWrite: 0,
|
|
353
|
+
totalTokens: 0,
|
|
354
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
355
|
+
},
|
|
356
|
+
stopReason: "stop",
|
|
357
|
+
timestamp: Date.now(),
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
try {
|
|
361
|
+
const apiKey = options?.apiKey ?? "";
|
|
362
|
+
const isOAuth = isOAuthToken(apiKey);
|
|
363
|
+
|
|
364
|
+
// Configure client based on auth type
|
|
365
|
+
const betaFeatures = ["fine-grained-tool-streaming-2025-05-14", "interleaved-thinking-2025-05-14"];
|
|
366
|
+
const clientOptions: any = {
|
|
367
|
+
baseURL: model.baseUrl,
|
|
368
|
+
dangerouslyAllowBrowser: true,
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
if (isOAuth) {
|
|
372
|
+
clientOptions.apiKey = null;
|
|
373
|
+
clientOptions.authToken = apiKey;
|
|
374
|
+
clientOptions.defaultHeaders = {
|
|
375
|
+
accept: "application/json",
|
|
376
|
+
"anthropic-dangerous-direct-browser-access": "true",
|
|
377
|
+
"anthropic-beta": `claude-code-20250219,oauth-2025-04-20,${betaFeatures.join(",")}`,
|
|
378
|
+
"user-agent": "claude-cli/2.1.2 (external, cli)",
|
|
379
|
+
"x-app": "cli",
|
|
380
|
+
};
|
|
381
|
+
} else {
|
|
382
|
+
clientOptions.apiKey = apiKey;
|
|
383
|
+
clientOptions.defaultHeaders = {
|
|
384
|
+
accept: "application/json",
|
|
385
|
+
"anthropic-dangerous-direct-browser-access": "true",
|
|
386
|
+
"anthropic-beta": betaFeatures.join(","),
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const client = new Anthropic(clientOptions);
|
|
391
|
+
|
|
392
|
+
// Build request params
|
|
393
|
+
const params: MessageCreateParamsStreaming = {
|
|
394
|
+
model: model.id,
|
|
395
|
+
messages: convertMessages(context.messages, isOAuth, context.tools),
|
|
396
|
+
max_tokens: options?.maxTokens || Math.floor(model.maxTokens / 3),
|
|
397
|
+
stream: true,
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
// System prompt with Claude Code identity for OAuth
|
|
401
|
+
if (isOAuth) {
|
|
402
|
+
params.system = [
|
|
403
|
+
{
|
|
404
|
+
type: "text",
|
|
405
|
+
text: "You are Claude Code, Anthropic's official CLI for Claude.",
|
|
406
|
+
cache_control: { type: "ephemeral" },
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
if (context.systemPrompt) {
|
|
410
|
+
params.system.push({
|
|
411
|
+
type: "text",
|
|
412
|
+
text: sanitizeSurrogates(context.systemPrompt),
|
|
413
|
+
cache_control: { type: "ephemeral" },
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
} else if (context.systemPrompt) {
|
|
417
|
+
params.system = [
|
|
418
|
+
{
|
|
419
|
+
type: "text",
|
|
420
|
+
text: sanitizeSurrogates(context.systemPrompt),
|
|
421
|
+
cache_control: { type: "ephemeral" },
|
|
422
|
+
},
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (context.tools) {
|
|
427
|
+
params.tools = convertTools(context.tools, isOAuth);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Handle thinking/reasoning
|
|
431
|
+
if (options?.reasoning && model.reasoning) {
|
|
432
|
+
const defaultBudgets: Record<string, number> = {
|
|
433
|
+
minimal: 1024,
|
|
434
|
+
low: 4096,
|
|
435
|
+
medium: 10240,
|
|
436
|
+
high: 20480,
|
|
437
|
+
};
|
|
438
|
+
const customBudget = options.thinkingBudgets?.[options.reasoning as keyof typeof options.thinkingBudgets];
|
|
439
|
+
params.thinking = {
|
|
440
|
+
type: "enabled",
|
|
441
|
+
budget_tokens: customBudget ?? defaultBudgets[options.reasoning] ?? 10240,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const anthropicStream = client.messages.stream({ ...params }, { signal: options?.signal });
|
|
446
|
+
stream.push({ type: "start", partial: output });
|
|
447
|
+
|
|
448
|
+
type Block = (ThinkingContent | TextContent | (ToolCall & { partialJson: string })) & { index: number };
|
|
449
|
+
const blocks = output.content as Block[];
|
|
450
|
+
|
|
451
|
+
for await (const event of anthropicStream) {
|
|
452
|
+
if (event.type === "message_start") {
|
|
453
|
+
output.usage.input = event.message.usage.input_tokens || 0;
|
|
454
|
+
output.usage.output = event.message.usage.output_tokens || 0;
|
|
455
|
+
output.usage.cacheRead = (event.message.usage as any).cache_read_input_tokens || 0;
|
|
456
|
+
output.usage.cacheWrite = (event.message.usage as any).cache_creation_input_tokens || 0;
|
|
457
|
+
output.usage.totalTokens =
|
|
458
|
+
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
459
|
+
calculateCost(model, output.usage);
|
|
460
|
+
} else if (event.type === "content_block_start") {
|
|
461
|
+
if (event.content_block.type === "text") {
|
|
462
|
+
output.content.push({ type: "text", text: "", index: event.index } as any);
|
|
463
|
+
stream.push({ type: "text_start", contentIndex: output.content.length - 1, partial: output });
|
|
464
|
+
} else if (event.content_block.type === "thinking") {
|
|
465
|
+
output.content.push({
|
|
466
|
+
type: "thinking",
|
|
467
|
+
thinking: "",
|
|
468
|
+
thinkingSignature: "",
|
|
469
|
+
index: event.index,
|
|
470
|
+
} as any);
|
|
471
|
+
stream.push({ type: "thinking_start", contentIndex: output.content.length - 1, partial: output });
|
|
472
|
+
} else if (event.content_block.type === "tool_use") {
|
|
473
|
+
output.content.push({
|
|
474
|
+
type: "toolCall",
|
|
475
|
+
id: event.content_block.id,
|
|
476
|
+
name: isOAuth
|
|
477
|
+
? fromClaudeCodeName(event.content_block.name, context.tools)
|
|
478
|
+
: event.content_block.name,
|
|
479
|
+
arguments: {},
|
|
480
|
+
partialJson: "",
|
|
481
|
+
index: event.index,
|
|
482
|
+
} as any);
|
|
483
|
+
stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
|
|
484
|
+
}
|
|
485
|
+
} else if (event.type === "content_block_delta") {
|
|
486
|
+
const index = blocks.findIndex((b) => b.index === event.index);
|
|
487
|
+
const block = blocks[index];
|
|
488
|
+
if (!block) continue;
|
|
489
|
+
|
|
490
|
+
if (event.delta.type === "text_delta" && block.type === "text") {
|
|
491
|
+
block.text += event.delta.text;
|
|
492
|
+
stream.push({ type: "text_delta", contentIndex: index, delta: event.delta.text, partial: output });
|
|
493
|
+
} else if (event.delta.type === "thinking_delta" && block.type === "thinking") {
|
|
494
|
+
block.thinking += event.delta.thinking;
|
|
495
|
+
stream.push({
|
|
496
|
+
type: "thinking_delta",
|
|
497
|
+
contentIndex: index,
|
|
498
|
+
delta: event.delta.thinking,
|
|
499
|
+
partial: output,
|
|
500
|
+
});
|
|
501
|
+
} else if (event.delta.type === "input_json_delta" && block.type === "toolCall") {
|
|
502
|
+
(block as any).partialJson += event.delta.partial_json;
|
|
503
|
+
try {
|
|
504
|
+
block.arguments = JSON.parse((block as any).partialJson);
|
|
505
|
+
} catch {}
|
|
506
|
+
stream.push({
|
|
507
|
+
type: "toolcall_delta",
|
|
508
|
+
contentIndex: index,
|
|
509
|
+
delta: event.delta.partial_json,
|
|
510
|
+
partial: output,
|
|
511
|
+
});
|
|
512
|
+
} else if (event.delta.type === "signature_delta" && block.type === "thinking") {
|
|
513
|
+
block.thinkingSignature = (block.thinkingSignature || "") + (event.delta as any).signature;
|
|
514
|
+
}
|
|
515
|
+
} else if (event.type === "content_block_stop") {
|
|
516
|
+
const index = blocks.findIndex((b) => b.index === event.index);
|
|
517
|
+
const block = blocks[index];
|
|
518
|
+
if (!block) continue;
|
|
519
|
+
|
|
520
|
+
delete (block as any).index;
|
|
521
|
+
if (block.type === "text") {
|
|
522
|
+
stream.push({ type: "text_end", contentIndex: index, content: block.text, partial: output });
|
|
523
|
+
} else if (block.type === "thinking") {
|
|
524
|
+
stream.push({ type: "thinking_end", contentIndex: index, content: block.thinking, partial: output });
|
|
525
|
+
} else if (block.type === "toolCall") {
|
|
526
|
+
try {
|
|
527
|
+
block.arguments = JSON.parse((block as any).partialJson);
|
|
528
|
+
} catch {}
|
|
529
|
+
delete (block as any).partialJson;
|
|
530
|
+
stream.push({ type: "toolcall_end", contentIndex: index, toolCall: block, partial: output });
|
|
531
|
+
}
|
|
532
|
+
} else if (event.type === "message_delta") {
|
|
533
|
+
if ((event.delta as any).stop_reason) {
|
|
534
|
+
output.stopReason = mapStopReason((event.delta as any).stop_reason);
|
|
535
|
+
}
|
|
536
|
+
output.usage.input = (event.usage as any).input_tokens || 0;
|
|
537
|
+
output.usage.output = (event.usage as any).output_tokens || 0;
|
|
538
|
+
output.usage.cacheRead = (event.usage as any).cache_read_input_tokens || 0;
|
|
539
|
+
output.usage.cacheWrite = (event.usage as any).cache_creation_input_tokens || 0;
|
|
540
|
+
output.usage.totalTokens =
|
|
541
|
+
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
542
|
+
calculateCost(model, output.usage);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (options?.signal?.aborted) {
|
|
547
|
+
throw new Error("Request was aborted");
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
stream.push({ type: "done", reason: output.stopReason as "stop" | "length" | "toolUse", message: output });
|
|
551
|
+
stream.end();
|
|
552
|
+
} catch (error) {
|
|
553
|
+
for (const block of output.content) delete (block as any).index;
|
|
554
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
555
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
556
|
+
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
557
|
+
stream.end();
|
|
558
|
+
}
|
|
559
|
+
})();
|
|
560
|
+
|
|
561
|
+
return stream;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// =============================================================================
|
|
565
|
+
// Extension Entry Point
|
|
566
|
+
// =============================================================================
|
|
567
|
+
|
|
568
|
+
export default function (indusagi: ExtensionAPI) {
|
|
569
|
+
indusagi.registerProvider("custom-anthropic", {
|
|
570
|
+
baseUrl: "https://api.anthropic.com",
|
|
571
|
+
apiKey: "CUSTOM_ANTHROPIC_AINDUSAGI_KEY",
|
|
572
|
+
api: "custom-anthropic-api",
|
|
573
|
+
|
|
574
|
+
models: [
|
|
575
|
+
{
|
|
576
|
+
id: "claude-opus-4-5",
|
|
577
|
+
name: "Claude Opus 4.5 (Custom)",
|
|
578
|
+
reasoning: true,
|
|
579
|
+
input: ["text", "image"],
|
|
580
|
+
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
581
|
+
contextWindow: 200000,
|
|
582
|
+
maxTokens: 64000,
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
id: "claude-sonnet-4-5",
|
|
586
|
+
name: "Claude Sonnet 4.5 (Custom)",
|
|
587
|
+
reasoning: true,
|
|
588
|
+
input: ["text", "image"],
|
|
589
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
590
|
+
contextWindow: 200000,
|
|
591
|
+
maxTokens: 64000,
|
|
592
|
+
},
|
|
593
|
+
],
|
|
594
|
+
|
|
595
|
+
oauth: {
|
|
596
|
+
name: "Custom Anthropic (Claude Pro/Max)",
|
|
597
|
+
login: loginAnthropic,
|
|
598
|
+
refreshToken: refreshAnthropicToken,
|
|
599
|
+
getApiKey: (cred) => cred.access,
|
|
600
|
+
},
|
|
601
|
+
|
|
602
|
+
streamSimple: streamCustomAnthropic,
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
|