@vandeepunk/pi-coding-agent 0.0.1
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 +2564 -0
- package/README.md +555 -0
- package/dist/cli/args.d.ts +47 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +286 -0
- 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 +31 -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 +79 -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 +92 -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 +34 -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 +11 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +68 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +203 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +574 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2260 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +102 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +282 -0
- 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 +212 -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 +242 -0
- 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 +607 -0
- 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 +7 -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 +138 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.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 +2 -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 +25 -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 +71 -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 +249 -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 +222 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +909 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1549 -0
- 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 +57 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -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 +400 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +129 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +576 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +928 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +35 -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 +102 -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 +134 -0
- 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 +9 -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 +153 -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 +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +100 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +419 -0
- 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 +313 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +131 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1290 -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 +251 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +184 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +673 -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 +234 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1091 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +187 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +552 -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 +310 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +21 -0
- package/dist/core/slash-commands.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 +137 -0
- 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 +25 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +55 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +242 -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 +243 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +39 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +146 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +206 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +239 -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 +61 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +40 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +118 -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 +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +166 -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 +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +29 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +78 -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 +42 -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 +623 -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 +261 -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 +8 -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 +333 -0
- 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 +91 -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 +162 -0
- 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 +51 -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 +44 -0
- 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 +45 -0
- 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 +479 -0
- 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 +33 -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 +70 -0
- 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 +79 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/daxnuts.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 +133 -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 +21 -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 +102 -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 +61 -0
- 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 +78 -0
- 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 +220 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +32 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +33 -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 +61 -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 +145 -0
- 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 +266 -0
- 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 +97 -0
- 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 +270 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +851 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +53 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +277 -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 +35 -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 +47 -0
- 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 +46 -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 +47 -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 +621 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +68 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +934 -0
- 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 +113 -0
- 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 +16 -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 +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +313 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +3664 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- 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 +944 -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 +98 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +405 -0
- 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 +500 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -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 +87 -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 +162 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.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 +67 -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 +26 -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 +6 -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 +35 -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 +181 -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 +26 -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 +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +186 -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 +17 -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 +201 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +390 -0
- package/docs/custom-provider.md +539 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +1827 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +79 -0
- package/docs/keybindings.md +174 -0
- package/docs/models.md +254 -0
- package/docs/packages.md +191 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +168 -0
- package/docs/rpc.md +1311 -0
- package/docs/sdk.md +957 -0
- package/docs/session.md +412 -0
- package/docs/settings.md +221 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +227 -0
- package/docs/terminal-setup.md +70 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tree.md +219 -0
- package/docs/tui.md +887 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +202 -0
- package/examples/extensions/antigravity-image-gen.ts +413 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +114 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/custom-provider-qwen-cli/index.ts +345 -0
- package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +150 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +881 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +398 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/qna.ts +119 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/rpc-demo.ts +124 -0
- package/examples/extensions/sandbox/index.ts +318 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +127 -0
- package/examples/extensions/subagent/index.ts +963 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +195 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +299 -0
- package/examples/extensions/tool-override.ts +143 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +192 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +38 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +97 -0
package/docs/windows.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Windows Setup
|
|
2
|
+
|
|
3
|
+
Pi requires a bash shell on Windows. Checked locations (in order):
|
|
4
|
+
|
|
5
|
+
1. Custom path from `~/.pi/agent/settings.json`
|
|
6
|
+
2. Git Bash (`C:\Program Files\Git\bin\bash.exe`)
|
|
7
|
+
3. `bash.exe` on PATH (Cygwin, MSYS2, WSL)
|
|
8
|
+
|
|
9
|
+
For most users, [Git for Windows](https://git-scm.com/download/win) is sufficient.
|
|
10
|
+
|
|
11
|
+
## Custom Shell Path
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"shellPath": "C:\\cygwin64\\bin\\bash.exe"
|
|
16
|
+
}
|
|
17
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
Example code for pi-coding-agent SDK and extensions.
|
|
4
|
+
|
|
5
|
+
## Directories
|
|
6
|
+
|
|
7
|
+
### [sdk/](sdk/)
|
|
8
|
+
Programmatic usage via `createAgentSession()`. Shows how to customize models, prompts, tools, extensions, and session management.
|
|
9
|
+
|
|
10
|
+
### [extensions/](extensions/)
|
|
11
|
+
Example extensions demonstrating:
|
|
12
|
+
- Lifecycle event handlers (tool interception, safety gates, context modifications)
|
|
13
|
+
- Custom tools (todo lists, questions, subagents, output truncation)
|
|
14
|
+
- Commands and keyboard shortcuts
|
|
15
|
+
- Custom UI (footers, headers, editors, overlays)
|
|
16
|
+
- Git integration (checkpoints, auto-commit)
|
|
17
|
+
- System prompt modifications and custom compaction
|
|
18
|
+
- External integrations (SSH, file watchers, system theme sync)
|
|
19
|
+
- Custom providers (Anthropic with custom streaming, GitLab Duo)
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
|
|
23
|
+
- [SDK Reference](sdk/README.md)
|
|
24
|
+
- [Extensions Documentation](../docs/extensions.md)
|
|
25
|
+
- [Skills Documentation](../docs/skills.md)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Extension Examples
|
|
2
|
+
|
|
3
|
+
Example extensions for pi-coding-agent.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Load an extension with --extension flag
|
|
9
|
+
pi --extension examples/extensions/permission-gate.ts
|
|
10
|
+
|
|
11
|
+
# Or copy to extensions directory for auto-discovery
|
|
12
|
+
cp permission-gate.ts ~/.pi/agent/extensions/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Lifecycle & Safety
|
|
18
|
+
|
|
19
|
+
| Extension | Description |
|
|
20
|
+
|-----------|-------------|
|
|
21
|
+
| `permission-gate.ts` | Prompts for confirmation before dangerous bash commands (rm -rf, sudo, etc.) |
|
|
22
|
+
| `protected-paths.ts` | Blocks writes to protected paths (.env, .git/, node_modules/) |
|
|
23
|
+
| `confirm-destructive.ts` | Confirms before destructive session actions (clear, switch, fork) |
|
|
24
|
+
| `dirty-repo-guard.ts` | Prevents session changes with uncommitted git changes |
|
|
25
|
+
| `sandbox/` | OS-level sandboxing using `@anthropic-ai/sandbox-runtime` with per-project config |
|
|
26
|
+
|
|
27
|
+
### Custom Tools
|
|
28
|
+
|
|
29
|
+
| Extension | Description |
|
|
30
|
+
|-----------|-------------|
|
|
31
|
+
| `todo.ts` | Todo list tool + `/todos` command with custom rendering and state persistence |
|
|
32
|
+
| `hello.ts` | Minimal custom tool example |
|
|
33
|
+
| `question.ts` | Demonstrates `ctx.ui.select()` for asking the user questions with custom UI |
|
|
34
|
+
| `questionnaire.ts` | Multi-question input with tab bar navigation between questions |
|
|
35
|
+
| `tool-override.ts` | Override built-in tools (e.g., add logging/access control to `read`) |
|
|
36
|
+
| `minimal-mode.ts` | Override built-in tool rendering for minimal display (only tool calls, no output in collapsed mode) |
|
|
37
|
+
| `truncated-tool.ts` | Wraps ripgrep with proper output truncation (50KB/2000 lines) |
|
|
38
|
+
| `antigravity-image-gen.ts` | Generate images via Google Antigravity with optional save-to-disk modes |
|
|
39
|
+
| `ssh.ts` | Delegate all tools to a remote machine via SSH using pluggable operations |
|
|
40
|
+
| `subagent/` | Delegate tasks to specialized subagents with isolated context windows |
|
|
41
|
+
|
|
42
|
+
### Commands & UI
|
|
43
|
+
|
|
44
|
+
| Extension | Description |
|
|
45
|
+
|-----------|-------------|
|
|
46
|
+
| `preset.ts` | Named presets for model, thinking level, tools, and instructions via `--preset` flag and `/preset` command |
|
|
47
|
+
| `plan-mode/` | Claude Code-style plan mode for read-only exploration with `/plan` command and step tracking |
|
|
48
|
+
| `tools.ts` | Interactive `/tools` command to enable/disable tools with session persistence |
|
|
49
|
+
| `handoff.ts` | Transfer context to a new focused session via `/handoff <goal>` |
|
|
50
|
+
| `qna.ts` | Extracts questions from last response into editor via `ctx.ui.setEditorText()` |
|
|
51
|
+
| `status-line.ts` | Shows turn progress in footer via `ctx.ui.setStatus()` with themed colors |
|
|
52
|
+
| `widget-placement.ts` | Shows widgets above and below the editor via `ctx.ui.setWidget()` placement |
|
|
53
|
+
| `model-status.ts` | Shows model changes in status bar via `model_select` hook |
|
|
54
|
+
| `snake.ts` | Snake game with custom UI, keyboard handling, and session persistence |
|
|
55
|
+
| `send-user-message.ts` | Demonstrates `pi.sendUserMessage()` for sending user messages from extensions |
|
|
56
|
+
| `timed-confirm.ts` | Demonstrates AbortSignal for auto-dismissing `ctx.ui.confirm()` and `ctx.ui.select()` dialogs |
|
|
57
|
+
| `rpc-demo.ts` | Exercises all RPC-supported extension UI methods; pair with [`examples/rpc-extension-ui.ts`](../rpc-extension-ui.ts) |
|
|
58
|
+
| `modal-editor.ts` | Custom vim-like modal editor via `ctx.ui.setEditorComponent()` |
|
|
59
|
+
| `rainbow-editor.ts` | Animated rainbow text effect via custom editor |
|
|
60
|
+
| `notify.ts` | Desktop notifications via OSC 777 when agent finishes (Ghostty, iTerm2, WezTerm) |
|
|
61
|
+
| `titlebar-spinner.ts` | Braille spinner animation in terminal title while the agent is working |
|
|
62
|
+
| `summarize.ts` | Summarize conversation with GPT-5.2 and show in transient UI |
|
|
63
|
+
| `custom-footer.ts` | Custom footer with git branch and token stats via `ctx.ui.setFooter()` |
|
|
64
|
+
| `custom-header.ts` | Custom header via `ctx.ui.setHeader()` |
|
|
65
|
+
| `overlay-test.ts` | Test overlay compositing with inline text inputs and edge cases |
|
|
66
|
+
| `overlay-qa-tests.ts` | Comprehensive overlay QA tests: anchors, margins, stacking, overflow, animation |
|
|
67
|
+
| `doom-overlay/` | DOOM game running as an overlay at 35 FPS (demonstrates real-time game rendering) |
|
|
68
|
+
| `shutdown-command.ts` | Adds `/quit` command demonstrating `ctx.shutdown()` |
|
|
69
|
+
| `interactive-shell.ts` | Run interactive commands (vim, htop) with full terminal via `user_bash` hook |
|
|
70
|
+
| `inline-bash.ts` | Expands `!{command}` patterns in prompts via `input` event transformation |
|
|
71
|
+
|
|
72
|
+
### Git Integration
|
|
73
|
+
|
|
74
|
+
| Extension | Description |
|
|
75
|
+
|-----------|-------------|
|
|
76
|
+
| `git-checkpoint.ts` | Creates git stash checkpoints at each turn for code restoration on fork |
|
|
77
|
+
| `auto-commit-on-exit.ts` | Auto-commits on exit using last assistant message for commit message |
|
|
78
|
+
|
|
79
|
+
### System Prompt & Compaction
|
|
80
|
+
|
|
81
|
+
| Extension | Description |
|
|
82
|
+
|-----------|-------------|
|
|
83
|
+
| `pirate.ts` | Demonstrates `systemPromptAppend` to dynamically modify system prompt |
|
|
84
|
+
| `claude-rules.ts` | Scans `.claude/rules/` folder and lists rules in system prompt |
|
|
85
|
+
| `custom-compaction.ts` | Custom compaction that summarizes entire conversation |
|
|
86
|
+
| `trigger-compact.ts` | Triggers compaction when context usage exceeds 100k tokens and adds `/trigger-compact` command |
|
|
87
|
+
|
|
88
|
+
### System Integration
|
|
89
|
+
|
|
90
|
+
| Extension | Description |
|
|
91
|
+
|-----------|-------------|
|
|
92
|
+
| `mac-system-theme.ts` | Syncs pi theme with macOS dark/light mode |
|
|
93
|
+
|
|
94
|
+
### Resources
|
|
95
|
+
|
|
96
|
+
| Extension | Description |
|
|
97
|
+
|-----------|-------------|
|
|
98
|
+
| `dynamic-resources/` | Loads skills, prompts, and themes using `resources_discover` |
|
|
99
|
+
|
|
100
|
+
### Messages & Communication
|
|
101
|
+
|
|
102
|
+
| Extension | Description |
|
|
103
|
+
|-----------|-------------|
|
|
104
|
+
| `message-renderer.ts` | Custom message rendering with colors and expandable details via `registerMessageRenderer` |
|
|
105
|
+
| `event-bus.ts` | Inter-extension communication via `pi.events` |
|
|
106
|
+
|
|
107
|
+
### Session Metadata
|
|
108
|
+
|
|
109
|
+
| Extension | Description |
|
|
110
|
+
|-----------|-------------|
|
|
111
|
+
| `session-name.ts` | Name sessions for the session selector via `setSessionName` |
|
|
112
|
+
| `bookmark.ts` | Bookmark entries with labels for `/tree` navigation via `setLabel` |
|
|
113
|
+
|
|
114
|
+
### Custom Providers
|
|
115
|
+
|
|
116
|
+
| Extension | Description |
|
|
117
|
+
|-----------|-------------|
|
|
118
|
+
| `custom-provider-anthropic/` | Custom Anthropic provider with OAuth support and custom streaming implementation |
|
|
119
|
+
| `custom-provider-gitlab-duo/` | GitLab Duo provider using pi-ai's built-in Anthropic/OpenAI streaming via proxy |
|
|
120
|
+
| `custom-provider-qwen-cli/` | Qwen CLI provider with OAuth device flow and OpenAI-compatible models |
|
|
121
|
+
|
|
122
|
+
### External Dependencies
|
|
123
|
+
|
|
124
|
+
| Extension | Description |
|
|
125
|
+
|-----------|-------------|
|
|
126
|
+
| `with-deps/` | Extension with its own package.json and dependencies (demonstrates jiti module resolution) |
|
|
127
|
+
| `file-trigger.ts` | Watches a trigger file and injects contents into conversation |
|
|
128
|
+
|
|
129
|
+
## Writing Extensions
|
|
130
|
+
|
|
131
|
+
See [docs/extensions.md](../../docs/extensions.md) for full documentation.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
135
|
+
import { Type } from "@sinclair/typebox";
|
|
136
|
+
|
|
137
|
+
export default function (pi: ExtensionAPI) {
|
|
138
|
+
// Subscribe to lifecycle events
|
|
139
|
+
pi.on("tool_call", async (event, ctx) => {
|
|
140
|
+
if (event.toolName === "bash" && event.input.command?.includes("rm -rf")) {
|
|
141
|
+
const ok = await ctx.ui.confirm("Dangerous!", "Allow rm -rf?");
|
|
142
|
+
if (!ok) return { block: true, reason: "Blocked by user" };
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Register custom tools
|
|
147
|
+
pi.registerTool({
|
|
148
|
+
name: "greet",
|
|
149
|
+
label: "Greeting",
|
|
150
|
+
description: "Generate a greeting",
|
|
151
|
+
parameters: Type.Object({
|
|
152
|
+
name: Type.String({ description: "Name to greet" }),
|
|
153
|
+
}),
|
|
154
|
+
async execute(toolCallId, params, onUpdate, ctx, signal) {
|
|
155
|
+
return {
|
|
156
|
+
content: [{ type: "text", text: `Hello, ${params.name}!` }],
|
|
157
|
+
details: {},
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Register commands
|
|
163
|
+
pi.registerCommand("hello", {
|
|
164
|
+
description: "Say hello",
|
|
165
|
+
handler: async (args, ctx) => {
|
|
166
|
+
ctx.ui.notify("Hello!", "info");
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Key Patterns
|
|
173
|
+
|
|
174
|
+
**Use StringEnum for string parameters** (required for Google API compatibility):
|
|
175
|
+
```typescript
|
|
176
|
+
import { StringEnum } from "@mariozechner/pi-ai";
|
|
177
|
+
|
|
178
|
+
// Good
|
|
179
|
+
action: StringEnum(["list", "add"] as const)
|
|
180
|
+
|
|
181
|
+
// Bad - doesn't work with Google
|
|
182
|
+
action: Type.Union([Type.Literal("list"), Type.Literal("add")])
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**State persistence via details:**
|
|
186
|
+
```typescript
|
|
187
|
+
// Store state in tool result details for proper forking support
|
|
188
|
+
return {
|
|
189
|
+
content: [{ type: "text", text: "Done" }],
|
|
190
|
+
details: { todos: [...todos], nextId }, // Persisted in session
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// Reconstruct on session events
|
|
194
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
195
|
+
for (const entry of ctx.sessionManager.getBranch()) {
|
|
196
|
+
if (entry.type === "message" && entry.message.toolName === "my_tool") {
|
|
197
|
+
const details = entry.message.details;
|
|
198
|
+
// Reconstruct state from details
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
```
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Antigravity Image Generation
|
|
3
|
+
*
|
|
4
|
+
* Generates images via Google Antigravity's image models (gemini-3-pro-image, imagen-3).
|
|
5
|
+
* Returns images as tool result attachments for inline terminal rendering.
|
|
6
|
+
* Requires OAuth login via /login for google-antigravity.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* "Generate an image of a sunset over mountains"
|
|
10
|
+
* "Create a 16:9 wallpaper of a cyberpunk city"
|
|
11
|
+
*
|
|
12
|
+
* Save modes (tool param, env var, or config file):
|
|
13
|
+
* save=none - Don't save to disk (default)
|
|
14
|
+
* save=project - Save to <repo>/.pi/generated-images/
|
|
15
|
+
* save=global - Save to ~/.pi/agent/generated-images/
|
|
16
|
+
* save=custom - Save to saveDir param or PI_IMAGE_SAVE_DIR
|
|
17
|
+
*
|
|
18
|
+
* Environment variables:
|
|
19
|
+
* PI_IMAGE_SAVE_MODE - Default save mode (none|project|global|custom)
|
|
20
|
+
* PI_IMAGE_SAVE_DIR - Directory for custom save mode
|
|
21
|
+
*
|
|
22
|
+
* Config files (project overrides global):
|
|
23
|
+
* ~/.pi/agent/extensions/antigravity-image-gen.json
|
|
24
|
+
* <repo>/.pi/extensions/antigravity-image-gen.json
|
|
25
|
+
* Example: { "save": "global" }
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { randomUUID } from "node:crypto";
|
|
29
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
30
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
31
|
+
import { homedir } from "node:os";
|
|
32
|
+
import { join } from "node:path";
|
|
33
|
+
import { StringEnum } from "@mariozechner/pi-ai";
|
|
34
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
35
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
36
|
+
|
|
37
|
+
const PROVIDER = "google-antigravity";
|
|
38
|
+
|
|
39
|
+
const ASPECT_RATIOS = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"] as const;
|
|
40
|
+
|
|
41
|
+
type AspectRatio = (typeof ASPECT_RATIOS)[number];
|
|
42
|
+
|
|
43
|
+
const DEFAULT_MODEL = "gemini-3-pro-image";
|
|
44
|
+
const DEFAULT_ASPECT_RATIO: AspectRatio = "1:1";
|
|
45
|
+
const DEFAULT_SAVE_MODE = "none";
|
|
46
|
+
|
|
47
|
+
const SAVE_MODES = ["none", "project", "global", "custom"] as const;
|
|
48
|
+
type SaveMode = (typeof SAVE_MODES)[number];
|
|
49
|
+
|
|
50
|
+
const ANTIGRAVITY_ENDPOINT = "https://daily-cloudcode-pa.sandbox.googleapis.com";
|
|
51
|
+
|
|
52
|
+
const ANTIGRAVITY_HEADERS = {
|
|
53
|
+
"User-Agent": "antigravity/1.15.8 darwin/arm64",
|
|
54
|
+
"X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
|
|
55
|
+
"Client-Metadata": JSON.stringify({
|
|
56
|
+
ideType: "IDE_UNSPECIFIED",
|
|
57
|
+
platform: "PLATFORM_UNSPECIFIED",
|
|
58
|
+
pluginType: "GEMINI",
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const IMAGE_SYSTEM_INSTRUCTION =
|
|
63
|
+
"You are an AI image generator. Generate images based on user descriptions. Focus on creating high-quality, visually appealing images that match the user's request.";
|
|
64
|
+
|
|
65
|
+
const TOOL_PARAMS = Type.Object({
|
|
66
|
+
prompt: Type.String({ description: "Image description." }),
|
|
67
|
+
model: Type.Optional(
|
|
68
|
+
Type.String({
|
|
69
|
+
description: "Image model id (e.g., gemini-3-pro-image, imagen-3). Default: gemini-3-pro-image.",
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
aspectRatio: Type.Optional(StringEnum(ASPECT_RATIOS)),
|
|
73
|
+
save: Type.Optional(StringEnum(SAVE_MODES)),
|
|
74
|
+
saveDir: Type.Optional(
|
|
75
|
+
Type.String({
|
|
76
|
+
description: "Directory to save image when save=custom. Defaults to PI_IMAGE_SAVE_DIR if set.",
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
type ToolParams = Static<typeof TOOL_PARAMS>;
|
|
82
|
+
|
|
83
|
+
interface CloudCodeAssistRequest {
|
|
84
|
+
project: string;
|
|
85
|
+
model: string;
|
|
86
|
+
request: {
|
|
87
|
+
contents: Content[];
|
|
88
|
+
sessionId?: string;
|
|
89
|
+
systemInstruction?: { role?: string; parts: { text: string }[] };
|
|
90
|
+
generationConfig?: {
|
|
91
|
+
maxOutputTokens?: number;
|
|
92
|
+
temperature?: number;
|
|
93
|
+
imageConfig?: { aspectRatio?: string };
|
|
94
|
+
candidateCount?: number;
|
|
95
|
+
};
|
|
96
|
+
safetySettings?: Array<{ category: string; threshold: string }>;
|
|
97
|
+
};
|
|
98
|
+
requestType?: string;
|
|
99
|
+
userAgent?: string;
|
|
100
|
+
requestId?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface CloudCodeAssistResponseChunk {
|
|
104
|
+
response?: {
|
|
105
|
+
candidates?: Array<{
|
|
106
|
+
content?: {
|
|
107
|
+
role: string;
|
|
108
|
+
parts?: Array<{
|
|
109
|
+
text?: string;
|
|
110
|
+
inlineData?: {
|
|
111
|
+
mimeType?: string;
|
|
112
|
+
data?: string;
|
|
113
|
+
};
|
|
114
|
+
}>;
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
usageMetadata?: {
|
|
118
|
+
promptTokenCount?: number;
|
|
119
|
+
candidatesTokenCount?: number;
|
|
120
|
+
thoughtsTokenCount?: number;
|
|
121
|
+
totalTokenCount?: number;
|
|
122
|
+
cachedContentTokenCount?: number;
|
|
123
|
+
};
|
|
124
|
+
modelVersion?: string;
|
|
125
|
+
responseId?: string;
|
|
126
|
+
};
|
|
127
|
+
traceId?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface Content {
|
|
131
|
+
role: "user" | "model";
|
|
132
|
+
parts: Part[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface Part {
|
|
136
|
+
text?: string;
|
|
137
|
+
inlineData?: {
|
|
138
|
+
mimeType?: string;
|
|
139
|
+
data?: string;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface ParsedCredentials {
|
|
144
|
+
accessToken: string;
|
|
145
|
+
projectId: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface ExtensionConfig {
|
|
149
|
+
save?: SaveMode;
|
|
150
|
+
saveDir?: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface SaveConfig {
|
|
154
|
+
mode: SaveMode;
|
|
155
|
+
outputDir?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseOAuthCredentials(raw: string): ParsedCredentials {
|
|
159
|
+
let parsed: { token?: string; projectId?: string };
|
|
160
|
+
try {
|
|
161
|
+
parsed = JSON.parse(raw) as { token?: string; projectId?: string };
|
|
162
|
+
} catch {
|
|
163
|
+
throw new Error("Invalid Google OAuth credentials. Run /login to re-authenticate.");
|
|
164
|
+
}
|
|
165
|
+
if (!parsed.token || !parsed.projectId) {
|
|
166
|
+
throw new Error("Missing token or projectId in Google OAuth credentials. Run /login.");
|
|
167
|
+
}
|
|
168
|
+
return { accessToken: parsed.token, projectId: parsed.projectId };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function readConfigFile(path: string): ExtensionConfig {
|
|
172
|
+
if (!existsSync(path)) {
|
|
173
|
+
return {};
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
const content = readFileSync(path, "utf-8");
|
|
177
|
+
const parsed = JSON.parse(content) as ExtensionConfig;
|
|
178
|
+
return parsed ?? {};
|
|
179
|
+
} catch {
|
|
180
|
+
return {};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function loadConfig(cwd: string): ExtensionConfig {
|
|
185
|
+
const globalConfig = readConfigFile(join(homedir(), ".pi", "agent", "extensions", "antigravity-image-gen.json"));
|
|
186
|
+
const projectConfig = readConfigFile(join(cwd, ".pi", "extensions", "antigravity-image-gen.json"));
|
|
187
|
+
return { ...globalConfig, ...projectConfig };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function resolveSaveConfig(params: ToolParams, cwd: string): SaveConfig {
|
|
191
|
+
const config = loadConfig(cwd);
|
|
192
|
+
const envMode = (process.env.PI_IMAGE_SAVE_MODE || "").toLowerCase();
|
|
193
|
+
const paramMode = params.save;
|
|
194
|
+
const mode = (paramMode || envMode || config.save || DEFAULT_SAVE_MODE) as SaveMode;
|
|
195
|
+
|
|
196
|
+
if (!SAVE_MODES.includes(mode)) {
|
|
197
|
+
return { mode: DEFAULT_SAVE_MODE as SaveMode };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (mode === "project") {
|
|
201
|
+
return { mode, outputDir: join(cwd, ".pi", "generated-images") };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (mode === "global") {
|
|
205
|
+
return { mode, outputDir: join(homedir(), ".pi", "agent", "generated-images") };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (mode === "custom") {
|
|
209
|
+
const dir = params.saveDir || process.env.PI_IMAGE_SAVE_DIR || config.saveDir;
|
|
210
|
+
if (!dir || !dir.trim()) {
|
|
211
|
+
throw new Error("save=custom requires saveDir or PI_IMAGE_SAVE_DIR.");
|
|
212
|
+
}
|
|
213
|
+
return { mode, outputDir: dir };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return { mode };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function imageExtension(mimeType: string): string {
|
|
220
|
+
const lower = mimeType.toLowerCase();
|
|
221
|
+
if (lower.includes("jpeg") || lower.includes("jpg")) return "jpg";
|
|
222
|
+
if (lower.includes("gif")) return "gif";
|
|
223
|
+
if (lower.includes("webp")) return "webp";
|
|
224
|
+
return "png";
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async function saveImage(base64Data: string, mimeType: string, outputDir: string): Promise<string> {
|
|
228
|
+
await mkdir(outputDir, { recursive: true });
|
|
229
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
230
|
+
const ext = imageExtension(mimeType);
|
|
231
|
+
const filename = `image-${timestamp}-${randomUUID().slice(0, 8)}.${ext}`;
|
|
232
|
+
const filePath = join(outputDir, filename);
|
|
233
|
+
await writeFile(filePath, Buffer.from(base64Data, "base64"));
|
|
234
|
+
return filePath;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function buildRequest(prompt: string, model: string, projectId: string, aspectRatio: string): CloudCodeAssistRequest {
|
|
238
|
+
return {
|
|
239
|
+
project: projectId,
|
|
240
|
+
model,
|
|
241
|
+
request: {
|
|
242
|
+
contents: [
|
|
243
|
+
{
|
|
244
|
+
role: "user",
|
|
245
|
+
parts: [{ text: prompt }],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
systemInstruction: {
|
|
249
|
+
parts: [{ text: IMAGE_SYSTEM_INSTRUCTION }],
|
|
250
|
+
},
|
|
251
|
+
generationConfig: {
|
|
252
|
+
imageConfig: { aspectRatio },
|
|
253
|
+
candidateCount: 1,
|
|
254
|
+
},
|
|
255
|
+
safetySettings: [
|
|
256
|
+
{ category: "HARM_CATEGORY_HARASSMENT", threshold: "BLOCK_ONLY_HIGH" },
|
|
257
|
+
{ category: "HARM_CATEGORY_HATE_SPEECH", threshold: "BLOCK_ONLY_HIGH" },
|
|
258
|
+
{ category: "HARM_CATEGORY_SEXUALLY_EXPLICIT", threshold: "BLOCK_ONLY_HIGH" },
|
|
259
|
+
{ category: "HARM_CATEGORY_DANGEROUS_CONTENT", threshold: "BLOCK_ONLY_HIGH" },
|
|
260
|
+
{ category: "HARM_CATEGORY_CIVIC_INTEGRITY", threshold: "BLOCK_ONLY_HIGH" },
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
requestType: "agent",
|
|
264
|
+
requestId: `agent-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`,
|
|
265
|
+
userAgent: "antigravity",
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function parseSseForImage(
|
|
270
|
+
response: Response,
|
|
271
|
+
signal?: AbortSignal,
|
|
272
|
+
): Promise<{ image: { data: string; mimeType: string }; text: string[] }> {
|
|
273
|
+
if (!response.body) {
|
|
274
|
+
throw new Error("No response body");
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const reader = response.body.getReader();
|
|
278
|
+
const decoder = new TextDecoder();
|
|
279
|
+
let buffer = "";
|
|
280
|
+
const textParts: string[] = [];
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
while (true) {
|
|
284
|
+
if (signal?.aborted) {
|
|
285
|
+
throw new Error("Request was aborted");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const { done, value } = await reader.read();
|
|
289
|
+
if (done) break;
|
|
290
|
+
|
|
291
|
+
buffer += decoder.decode(value, { stream: true });
|
|
292
|
+
const lines = buffer.split("\n");
|
|
293
|
+
buffer = lines.pop() || "";
|
|
294
|
+
|
|
295
|
+
for (const line of lines) {
|
|
296
|
+
if (!line.startsWith("data:")) continue;
|
|
297
|
+
const jsonStr = line.slice(5).trim();
|
|
298
|
+
if (!jsonStr) continue;
|
|
299
|
+
|
|
300
|
+
let chunk: CloudCodeAssistResponseChunk;
|
|
301
|
+
try {
|
|
302
|
+
chunk = JSON.parse(jsonStr) as CloudCodeAssistResponseChunk;
|
|
303
|
+
} catch {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const responseData = chunk.response;
|
|
308
|
+
if (!responseData?.candidates) continue;
|
|
309
|
+
|
|
310
|
+
for (const candidate of responseData.candidates) {
|
|
311
|
+
const parts = candidate.content?.parts;
|
|
312
|
+
if (!parts) continue;
|
|
313
|
+
for (const part of parts) {
|
|
314
|
+
if (part.text) {
|
|
315
|
+
textParts.push(part.text);
|
|
316
|
+
}
|
|
317
|
+
if (part.inlineData?.data) {
|
|
318
|
+
await reader.cancel();
|
|
319
|
+
return {
|
|
320
|
+
image: {
|
|
321
|
+
data: part.inlineData.data,
|
|
322
|
+
mimeType: part.inlineData.mimeType || "image/png",
|
|
323
|
+
},
|
|
324
|
+
text: textParts,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} finally {
|
|
332
|
+
reader.releaseLock();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
throw new Error("No image data returned by the model");
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async function getCredentials(ctx: {
|
|
339
|
+
modelRegistry: { getApiKeyForProvider: (provider: string) => Promise<string | undefined> };
|
|
340
|
+
}): Promise<ParsedCredentials> {
|
|
341
|
+
const apiKey = await ctx.modelRegistry.getApiKeyForProvider(PROVIDER);
|
|
342
|
+
if (!apiKey) {
|
|
343
|
+
throw new Error("Missing Google Antigravity OAuth credentials. Run /login for google-antigravity.");
|
|
344
|
+
}
|
|
345
|
+
return parseOAuthCredentials(apiKey);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export default function antigravityImageGen(pi: ExtensionAPI) {
|
|
349
|
+
pi.registerTool({
|
|
350
|
+
name: "generate_image",
|
|
351
|
+
label: "Generate image",
|
|
352
|
+
description:
|
|
353
|
+
"Generate an image via Google Antigravity image models. Returns the image as a tool result attachment. Optional saving via save=project|global|custom|none, or PI_IMAGE_SAVE_MODE/PI_IMAGE_SAVE_DIR.",
|
|
354
|
+
parameters: TOOL_PARAMS,
|
|
355
|
+
async execute(_toolCallId, params: ToolParams, signal, onUpdate, ctx) {
|
|
356
|
+
const { accessToken, projectId } = await getCredentials(ctx);
|
|
357
|
+
const model = params.model || DEFAULT_MODEL;
|
|
358
|
+
const aspectRatio = params.aspectRatio || DEFAULT_ASPECT_RATIO;
|
|
359
|
+
|
|
360
|
+
const requestBody = buildRequest(params.prompt, model, projectId, aspectRatio);
|
|
361
|
+
onUpdate?.({
|
|
362
|
+
content: [{ type: "text", text: `Requesting image from ${PROVIDER}/${model}...` }],
|
|
363
|
+
details: { provider: PROVIDER, model, aspectRatio },
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const response = await fetch(`${ANTIGRAVITY_ENDPOINT}/v1internal:streamGenerateContent?alt=sse`, {
|
|
367
|
+
method: "POST",
|
|
368
|
+
headers: {
|
|
369
|
+
Authorization: `Bearer ${accessToken}`,
|
|
370
|
+
"Content-Type": "application/json",
|
|
371
|
+
Accept: "text/event-stream",
|
|
372
|
+
...ANTIGRAVITY_HEADERS,
|
|
373
|
+
},
|
|
374
|
+
body: JSON.stringify(requestBody),
|
|
375
|
+
signal,
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
if (!response.ok) {
|
|
379
|
+
const errorText = await response.text();
|
|
380
|
+
throw new Error(`Image request failed (${response.status}): ${errorText}`);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const parsed = await parseSseForImage(response, signal);
|
|
384
|
+
const saveConfig = resolveSaveConfig(params, ctx.cwd);
|
|
385
|
+
let savedPath: string | undefined;
|
|
386
|
+
let saveError: string | undefined;
|
|
387
|
+
if (saveConfig.mode !== "none" && saveConfig.outputDir) {
|
|
388
|
+
try {
|
|
389
|
+
savedPath = await saveImage(parsed.image.data, parsed.image.mimeType, saveConfig.outputDir);
|
|
390
|
+
} catch (error) {
|
|
391
|
+
saveError = error instanceof Error ? error.message : String(error);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const summaryParts = [`Generated image via ${PROVIDER}/${model}.`, `Aspect ratio: ${aspectRatio}.`];
|
|
395
|
+
if (savedPath) {
|
|
396
|
+
summaryParts.push(`Saved image to: ${savedPath}`);
|
|
397
|
+
} else if (saveError) {
|
|
398
|
+
summaryParts.push(`Failed to save image: ${saveError}`);
|
|
399
|
+
}
|
|
400
|
+
if (parsed.text.length > 0) {
|
|
401
|
+
summaryParts.push(`Model notes: ${parsed.text.join(" ")}`);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return {
|
|
405
|
+
content: [
|
|
406
|
+
{ type: "text", text: summaryParts.join(" ") },
|
|
407
|
+
{ type: "image", data: parsed.image.data, mimeType: parsed.image.mimeType },
|
|
408
|
+
],
|
|
409
|
+
details: { provider: PROVIDER, model, aspectRatio, savedPath, saveMode: saveConfig.mode },
|
|
410
|
+
};
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
}
|