apex-code 0.5.0 → 0.5.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 +257 -5
- package/README.md +624 -0
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +3 -9
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/runtime-setup.d.ts +2 -0
- package/dist/bun/runtime-setup.d.ts.map +1 -0
- package/dist/bun/runtime-setup.js +9 -0
- package/dist/bun/runtime-setup.js.map +1 -0
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +16 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +13 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +16 -8
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +85 -15
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +685 -266
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +55 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +291 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +103 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +356 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +163 -66
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/context/pipeline.d.ts +8 -8
- package/dist/core/context/pipeline.d.ts.map +1 -1
- package/dist/core/context/pipeline.js +21 -12
- package/dist/core/context/pipeline.js.map +1 -1
- package/dist/core/crash-log.d.ts +27 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +139 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/export-html/template.js +6 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +4 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +4 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +40 -59
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +24 -8
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +195 -72
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +142 -55
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +41 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +1 -20
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +6 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +5 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +168 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +44 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +4 -3
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +12 -6
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/permissions/store.d.ts.map +1 -1
- package/dist/core/permissions/store.js +11 -8
- package/dist/core/permissions/store.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +61 -35
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +4 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +29 -2
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +3 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +6 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +6 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +63 -42
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +6 -2
- package/dist/core/session-export.d.ts.map +1 -1
- package/dist/core/session-export.js +14 -13
- package/dist/core/session-export.js.map +1 -1
- package/dist/core/session-manager.d.ts +66 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +295 -115
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +27 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +55 -7
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +5 -4
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +140 -79
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +7 -8
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +20 -115
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +6 -204
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +4 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +10 -125
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +18 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +126 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +207 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +34 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +132 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +152 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +6 -146
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-totals.d.ts +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +5 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -3
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +20 -5
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +21 -13
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +16 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +167 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +7 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +63 -17
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +12 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +38 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/error-summary.d.ts +11 -0
- package/dist/modes/interactive/components/error-summary.d.ts.map +1 -0
- package/dist/modes/interactive/components/error-summary.js +31 -0
- package/dist/modes/interactive/components/error-summary.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +6 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +4 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +3 -3
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +13 -15
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +74 -48
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +5 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +35 -10
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +6 -6
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +27 -5
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +64 -42
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +9 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +43 -29
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +431 -166
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +84 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +130 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +6 -2
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +21 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +66 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/testing/replay/recorded-provider.d.ts +2 -2
- package/dist/testing/replay/recorded-provider.d.ts.map +1 -1
- package/dist/testing/replay/recorded-provider.js +2 -5
- package/dist/testing/replay/recorded-provider.js.map +1 -1
- package/dist/testing/replay/runner.d.ts.map +1 -1
- package/dist/testing/replay/runner.js +0 -1
- package/dist/testing/replay/runner.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +53 -81
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +111 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +21 -21
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +3 -1
- package/dist/utils/tool-result-images.d.ts.map +1 -1
- package/dist/utils/tool-result-images.js +4 -1
- package/dist/utils/tool-result-images.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +11 -2
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/cli-integration.md +107 -0
- package/docs/cli.md +269 -0
- package/docs/compaction.md +73 -24
- package/docs/configuration.md +45 -0
- package/docs/containerization.md +22 -21
- package/docs/custom-provider.md +21 -12
- package/docs/development.md +19 -0
- package/docs/docs.json +139 -95
- package/docs/extensions.md +243 -371
- package/docs/how-pi-works.md +49 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/index.md +3 -3
- package/docs/json.md +7 -3
- package/docs/keybindings.md +57 -54
- package/docs/llama-cpp.md +2 -2
- package/docs/message-types.md +261 -0
- package/docs/models.md +103 -49
- package/docs/packages.md +49 -47
- package/docs/prompt-templates.md +29 -56
- package/docs/providers.md +91 -139
- package/docs/quickstart.md +42 -14
- package/docs/rpc-commands.md +854 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +121 -223
- package/docs/sdk.md +99 -124
- package/docs/security.md +7 -7
- package/docs/session-format.md +85 -82
- package/docs/sessions.md +41 -57
- package/docs/settings.md +94 -87
- package/docs/shell-aliases.md +68 -3
- package/docs/skills.md +62 -49
- package/docs/slash-commands.md +60 -0
- package/docs/terminal-setup.md +86 -55
- package/docs/termux.md +65 -75
- package/docs/themes.md +64 -86
- package/docs/tmux.md +29 -7
- package/docs/tui.md +67 -122
- package/docs/usage.md +31 -42
- package/docs/windows.md +41 -13
- package/examples/README.md +16 -2
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +2 -0
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/README.md +38 -0
- package/examples/plugins/pi-example-plugin/package.json +10 -0
- package/examples/plugins/pi-example-plugin/src/contract.ts +13 -0
- package/examples/plugins/pi-example-plugin/src/session.ts +24 -0
- package/examples/plugins/pi-example-plugin/src/tui.ts +31 -0
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +25 -5
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +861 -513
- package/package.json +27 -18
- package/dist/bun/register-bedrock.d.ts +0 -2
- package/dist/bun/register-bedrock.d.ts.map +0 -1
- package/dist/bun/register-bedrock.js +0 -4
- package/dist/bun/register-bedrock.js.map +0 -1
- package/dist/cli/experimental/auth.d.ts +0 -16
- package/dist/cli/experimental/auth.d.ts.map +0 -1
- package/dist/cli/experimental/auth.js +0 -13
- package/dist/cli/experimental/auth.js.map +0 -1
- package/dist/cli/experimental/cli.d.ts +0 -6
- package/dist/cli/experimental/cli.d.ts.map +0 -1
- package/dist/cli/experimental/cli.js +0 -5
- package/dist/cli/experimental/cli.js.map +0 -1
- package/dist/cli/experimental/command-options.d.ts +0 -17
- package/dist/cli/experimental/command-options.d.ts.map +0 -1
- package/dist/cli/experimental/command-options.js +0 -35
- package/dist/cli/experimental/command-options.js.map +0 -1
- package/dist/cli/experimental/command.d.ts +0 -63
- package/dist/cli/experimental/command.d.ts.map +0 -1
- package/dist/cli/experimental/command.js +0 -130
- package/dist/cli/experimental/command.js.map +0 -1
- package/dist/cli/experimental/commands/client.d.ts +0 -13
- package/dist/cli/experimental/commands/client.d.ts.map +0 -1
- package/dist/cli/experimental/commands/client.js +0 -25
- package/dist/cli/experimental/commands/client.js.map +0 -1
- package/dist/cli/experimental/commands/pi.d.ts +0 -15
- package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
- package/dist/cli/experimental/commands/pi.js +0 -28
- package/dist/cli/experimental/commands/pi.js.map +0 -1
- package/dist/cli/experimental/commands/server.d.ts +0 -13
- package/dist/cli/experimental/commands/server.d.ts.map +0 -1
- package/dist/cli/experimental/commands/server.js +0 -25
- package/dist/cli/experimental/commands/server.js.map +0 -1
- package/dist/cli/experimental/transport-address.d.ts +0 -10
- package/dist/cli/experimental/transport-address.d.ts.map +0 -1
- package/dist/cli/experimental/transport-address.js +0 -38
- package/dist/cli/experimental/transport-address.js.map +0 -1
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -3
- package/dist/client/index.js.map +0 -1
- package/dist/client/remote-session.d.ts +0 -53
- package/dist/client/remote-session.d.ts.map +0 -1
- package/dist/client/remote-session.js +0 -340
- package/dist/client/remote-session.js.map +0 -1
- package/dist/client/transcript.d.ts +0 -12
- package/dist/client/transcript.d.ts.map +0 -1
- package/dist/client/transcript.js +0 -98
- package/dist/client/transcript.js.map +0 -1
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
|
@@ -27,9 +27,11 @@ import {
|
|
|
27
27
|
type Api,
|
|
28
28
|
type AssistantMessage,
|
|
29
29
|
type AssistantMessageEventStream,
|
|
30
|
-
type Context,
|
|
31
30
|
calculateCost,
|
|
31
|
+
collapseSystemMessages,
|
|
32
32
|
createAssistantMessageEventStream,
|
|
33
|
+
getCurrentSystemPrompt,
|
|
34
|
+
getCurrentTools,
|
|
33
35
|
type ImageContent,
|
|
34
36
|
type Message,
|
|
35
37
|
type Model,
|
|
@@ -42,6 +44,7 @@ import {
|
|
|
42
44
|
type Tool,
|
|
43
45
|
type ToolCall,
|
|
44
46
|
type ToolResultMessage,
|
|
47
|
+
type TranscriptContext,
|
|
45
48
|
} from "@earendil-works/pi-ai";
|
|
46
49
|
import type { ExtensionAPI } from "apex-code";
|
|
47
50
|
|
|
@@ -334,10 +337,15 @@ function mapStopReason(reason: string): StopReason {
|
|
|
334
337
|
|
|
335
338
|
function streamCustomAnthropic(
|
|
336
339
|
model: Model<Api>,
|
|
337
|
-
context:
|
|
340
|
+
context: TranscriptContext,
|
|
338
341
|
options?: SimpleStreamOptions,
|
|
339
342
|
): AssistantMessageEventStream {
|
|
340
343
|
const stream = createAssistantMessageEventStream();
|
|
344
|
+
// The transcript carries the prompt and tools in its system messages. This provider sends
|
|
345
|
+
// one top-level system prompt, so fold later system messages into the leading one first.
|
|
346
|
+
const transcript = collapseSystemMessages(context);
|
|
347
|
+
const systemPrompt = getCurrentSystemPrompt(transcript.messages);
|
|
348
|
+
const tools = getCurrentTools(transcript.messages);
|
|
341
349
|
|
|
342
350
|
(async () => {
|
|
343
351
|
const output: AssistantMessage = {
|
|
@@ -393,7 +401,7 @@ function streamCustomAnthropic(
|
|
|
393
401
|
// Build request params
|
|
394
402
|
const params: MessageCreateParamsStreaming = {
|
|
395
403
|
model: model.id,
|
|
396
|
-
messages: convertMessages(
|
|
404
|
+
messages: convertMessages(transcript.messages, isOAuth, tools),
|
|
397
405
|
max_tokens: options?.maxTokens || Math.floor(model.maxTokens / 3),
|
|
398
406
|
stream: true,
|
|
399
407
|
};
|
|
@@ -407,25 +415,25 @@ function streamCustomAnthropic(
|
|
|
407
415
|
cache_control: { type: "ephemeral" },
|
|
408
416
|
},
|
|
409
417
|
];
|
|
410
|
-
if (
|
|
418
|
+
if (systemPrompt) {
|
|
411
419
|
params.system.push({
|
|
412
420
|
type: "text",
|
|
413
|
-
text: sanitizeSurrogates(
|
|
421
|
+
text: sanitizeSurrogates(systemPrompt),
|
|
414
422
|
cache_control: { type: "ephemeral" },
|
|
415
423
|
});
|
|
416
424
|
}
|
|
417
|
-
} else if (
|
|
425
|
+
} else if (systemPrompt) {
|
|
418
426
|
params.system = [
|
|
419
427
|
{
|
|
420
428
|
type: "text",
|
|
421
|
-
text: sanitizeSurrogates(
|
|
429
|
+
text: sanitizeSurrogates(systemPrompt),
|
|
422
430
|
cache_control: { type: "ephemeral" },
|
|
423
431
|
},
|
|
424
432
|
];
|
|
425
433
|
}
|
|
426
434
|
|
|
427
|
-
if (
|
|
428
|
-
params.tools = convertTools(
|
|
435
|
+
if (tools.length > 0) {
|
|
436
|
+
params.tools = convertTools(tools, isOAuth);
|
|
429
437
|
}
|
|
430
438
|
|
|
431
439
|
// Handle thinking/reasoning
|
|
@@ -474,9 +482,7 @@ function streamCustomAnthropic(
|
|
|
474
482
|
output.content.push({
|
|
475
483
|
type: "toolCall",
|
|
476
484
|
id: event.content_block.id,
|
|
477
|
-
name: isOAuth
|
|
478
|
-
? fromClaudeCodeName(event.content_block.name, context.tools)
|
|
479
|
-
: event.content_block.name,
|
|
485
|
+
name: isOAuth ? fromClaudeCodeName(event.content_block.name, tools) : event.content_block.name,
|
|
480
486
|
arguments: {},
|
|
481
487
|
partialJson: "",
|
|
482
488
|
index: event.index,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.87.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.87.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
type Api,
|
|
14
14
|
type AssistantMessageEventStream,
|
|
15
15
|
anthropicMessagesApi,
|
|
16
|
-
type Context,
|
|
17
16
|
createAssistantMessageEventStream,
|
|
18
17
|
type Model,
|
|
19
18
|
type OAuthCredentials,
|
|
@@ -21,6 +20,7 @@ import {
|
|
|
21
20
|
openAIResponsesApi,
|
|
22
21
|
type SimpleStreamOptions,
|
|
23
22
|
type ThinkingLevelMap,
|
|
23
|
+
type TranscriptContext,
|
|
24
24
|
} from "@earendil-works/pi-ai/compat";
|
|
25
25
|
import type { ExtensionAPI } from "apex-code";
|
|
26
26
|
|
|
@@ -306,7 +306,7 @@ async function refreshGitLabToken(credentials: OAuthCredentials, signal: AbortSi
|
|
|
306
306
|
|
|
307
307
|
export function streamGitLabDuo(
|
|
308
308
|
model: Model<Api>,
|
|
309
|
-
context:
|
|
309
|
+
context: TranscriptContext,
|
|
310
310
|
options?: SimpleStreamOptions,
|
|
311
311
|
): AssistantMessageEventStream {
|
|
312
312
|
const stream = createAssistantMessageEventStream();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-gondolin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.87.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-gondolin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.87.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Prompt Customizer Extension
|
|
3
3
|
*
|
|
4
|
-
* Demonstrates using systemPromptOptions to
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* This extension adds tool-specific guidance based on what tools and skills
|
|
8
|
-
* are currently active, respecting whatever the user has configured.
|
|
4
|
+
* Demonstrates using systemPromptOptions to add context-aware prompt sections
|
|
5
|
+
* without replacing or reparsing the complete rendered prompt.
|
|
9
6
|
*
|
|
10
7
|
* Usage:
|
|
11
8
|
* 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
|
|
@@ -14,84 +11,39 @@
|
|
|
14
11
|
|
|
15
12
|
import type { BuildSystemPromptOptions, ExtensionAPI } from "apex-code";
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
* Adds tool-specific guidance that adapts to the active tool set.
|
|
19
|
-
* Instead of appending one-size-fits-all instructions, this reads what's
|
|
20
|
-
* actually loaded and tailors the guidance accordingly.
|
|
21
|
-
*/
|
|
22
|
-
function addToolGuidance(options: BuildSystemPromptOptions, basePrompt: string): string {
|
|
14
|
+
function buildToolGuidance(options: BuildSystemPromptOptions): string {
|
|
23
15
|
const hasTool = (name: string) => options.selectedTools?.includes(name) ?? false;
|
|
24
|
-
|
|
25
|
-
const parts: string[] = [];
|
|
16
|
+
const rules: string[] = [];
|
|
26
17
|
|
|
27
18
|
if (hasTool("read")) {
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
19
|
+
rules.push(
|
|
20
|
+
"- Use `read` for file contents; it supports text and images.",
|
|
21
|
+
"- For large files, use `offset` and `limit` to read in chunks.",
|
|
31
22
|
);
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
if (hasTool("bash")) {
|
|
35
|
-
|
|
25
|
+
rules.push("- Use `bash` for file operations such as `ls`, `find`, and `grep`.");
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
if (hasTool("edit")) {
|
|
39
|
-
|
|
40
|
-
"• Use the `edit` tool for precise text replacements in files. Match exact content including whitespace.",
|
|
41
|
-
);
|
|
28
|
+
rules.push("- Use `edit` for precise text replacements that match existing content exactly.");
|
|
42
29
|
}
|
|
43
|
-
|
|
44
30
|
if (hasTool("write")) {
|
|
45
|
-
|
|
31
|
+
rules.push("- Use `write` to create new files or replace existing files completely.");
|
|
46
32
|
}
|
|
47
|
-
|
|
48
33
|
if (options.skills && options.skills.length > 0) {
|
|
49
|
-
|
|
50
|
-
parts.push(`\nAvailable skills: ${skillNames}`, "Use skill documentation for best practices on specific tools.");
|
|
34
|
+
rules.push(`- Available skills: ${options.skills.map((skill) => skill.name).join(", ")}.`);
|
|
51
35
|
}
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
return basePrompt;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return `${basePrompt}
|
|
58
|
-
|
|
59
|
-
## Tool Guidance
|
|
60
|
-
|
|
61
|
-
${parts.join("\n")}
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Merges extension instructions with user-provided append prompts.
|
|
67
|
-
* This respects whatever the user configured via --append-system-prompt
|
|
68
|
-
* flags or files, rather than duplicating that work.
|
|
69
|
-
*/
|
|
70
|
-
function mergeWithUserAppend(options: BuildSystemPromptOptions): string {
|
|
71
|
-
const userAppend = options.appendSystemPrompt;
|
|
72
|
-
const extensionSpecific = `
|
|
73
|
-
## Extension-Added Context
|
|
74
|
-
|
|
75
|
-
This prompt includes tool guidance and skill information loaded dynamically.
|
|
76
|
-
If you have additional requirements, configure them via --append-system-prompt or project context files.
|
|
77
|
-
`;
|
|
78
|
-
|
|
79
|
-
if (userAppend) {
|
|
80
|
-
return `${userAppend}\n\n${extensionSpecific}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return extensionSpecific;
|
|
37
|
+
return rules.join("\n");
|
|
84
38
|
}
|
|
85
39
|
|
|
86
40
|
export default function promptCustomizer(pi: ExtensionAPI) {
|
|
87
|
-
pi.on("before_agent_start",
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
systemPrompt: `${customPrompt}${appendSection}`,
|
|
95
|
-
};
|
|
41
|
+
pi.on("before_agent_start", (event) => {
|
|
42
|
+
const guidance = buildToolGuidance(event.systemPromptOptions);
|
|
43
|
+
if (guidance) {
|
|
44
|
+
event.systemPromptOptions.sections.tool_guidance = guidance;
|
|
45
|
+
} else {
|
|
46
|
+
delete event.systemPromptOptions.sections.tool_guidance;
|
|
47
|
+
}
|
|
96
48
|
});
|
|
97
49
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.17.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.87.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.87.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# `@earendil-works/pi-example-plugin`
|
|
2
|
+
|
|
3
|
+
This package provides conventional `session` and `tui` Chord facets. The Session-worker facet provides a remote greeting service. The TUI facet contributes `/hello` and calls that service.
|
|
4
|
+
|
|
5
|
+
The package needs no build script. Pi asks Chord to discover `src/session.ts` and `src/tui.ts`, builds both entries into its server-owned plugin cache, and sends the TUI artifact to clients.
|
|
6
|
+
|
|
7
|
+
From the repository root:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
PI_EXPERIMENTAL=1 ./pi-test.sh server \
|
|
11
|
+
-e "$PWD/packages/coding-agent/examples/plugins/pi-example-plugin"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Alternatively, a client can select the plugin for the Session it creates or resumes on one local server:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
PI_EXPERIMENTAL=1 ./pi-test.sh client \
|
|
18
|
+
-e "$PWD/packages/coding-agent/examples/plugins/pi-example-plugin"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Repeat `-e` to select multiple plugin packages. Client paths are resolved locally and sent only to a Unix server; Radius clients cannot select server filesystem paths. The Session and matching TUI facets are stored with that Session, so later server generations and clients can resume it without plugin arguments. Other Sessions and their workers are unaffected. An active Session rejects a different package selection instead of being restarted.
|
|
22
|
+
|
|
23
|
+
`server -e` establishes the server profile's default Session and TUI facets. Starting an explicit foreground server without `-e` clears that default. Client selection never changes the server's root facet generation.
|
|
24
|
+
|
|
25
|
+
Run `/hello Armin` in the TUI. After editing a facet, run `/reload`. The server atomically rebuilds the package, reloads the attached Session-worker generation, updates the current TUI generation, and serves the new artifact to future clients.
|
|
26
|
+
|
|
27
|
+
Package metadata can override or disable conventional entries:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"chord": {
|
|
32
|
+
"facets": {
|
|
33
|
+
"session": "./src/worker.ts",
|
|
34
|
+
"tui": false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Context, defineService, type ReplicatedState } from "@earendil-works/chord";
|
|
2
|
+
|
|
3
|
+
export interface ExampleFacetReply {
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly workerActivations: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ExampleFacetService {
|
|
9
|
+
readonly workerActivations: ReplicatedState<{ count: number }>;
|
|
10
|
+
greet(input: { readonly name: string }, context: Context): Promise<ExampleFacetReply>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const ExampleFacetService = defineService<ExampleFacetService>("pi.example-plugin.greeting");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineFacet } from "@earendil-works/chord";
|
|
2
|
+
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
3
|
+
import { ExampleFacetService } from "./contract.ts";
|
|
4
|
+
|
|
5
|
+
export default defineFacet({
|
|
6
|
+
id: "@earendil-works/pi-example-plugin/session",
|
|
7
|
+
setup(env) {
|
|
8
|
+
const workerActivations = env.replicatedState({ count: 0 });
|
|
9
|
+
env.provide(ExampleFacetService, {
|
|
10
|
+
workerActivations,
|
|
11
|
+
async greet({ name }) {
|
|
12
|
+
return {
|
|
13
|
+
message: `Hello ${name} from the bundled Session worker facet!!!`,
|
|
14
|
+
workerActivations: workerActivations.value.count,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
env.onActivate(() => {
|
|
19
|
+
workerActivations.change(BACKGROUND_CONTEXT, (draft) => {
|
|
20
|
+
draft.count += 1;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineFacet } from "@earendil-works/chord";
|
|
2
|
+
import { AgentController, PresentationUI, SlashCommands } from "apex-code/experimental/plugin";
|
|
3
|
+
import { ExampleFacetService } from "./contract.ts";
|
|
4
|
+
|
|
5
|
+
export default defineFacet({
|
|
6
|
+
id: "@earendil-works/pi-example-plugin/tui",
|
|
7
|
+
setup(env) {
|
|
8
|
+
const example = env.use(ExampleFacetService);
|
|
9
|
+
const commands = env.use(SlashCommands);
|
|
10
|
+
const controller = env.use(AgentController);
|
|
11
|
+
const ui = env.use(PresentationUI);
|
|
12
|
+
env.onActivate(() => {
|
|
13
|
+
env.own(
|
|
14
|
+
commands.replace({
|
|
15
|
+
name: "hello",
|
|
16
|
+
description: "Call the bundled Session worker facet",
|
|
17
|
+
argumentHint: "<name>",
|
|
18
|
+
async run(args, context) {
|
|
19
|
+
const message = args.length === 0 ? "from the TUI" : args;
|
|
20
|
+
const reply = await example.greet({ name: message }, context);
|
|
21
|
+
ui.showStatus(
|
|
22
|
+
`We got this: ${reply.message} Worker activations: ${reply.workerActivations}.`,
|
|
23
|
+
context,
|
|
24
|
+
);
|
|
25
|
+
return controller.prompt({ message: `pong: ${message}`, images: null }, context);
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run one prompt through an Apex Code RPC child process.
|
|
3
|
+
*
|
|
4
|
+
* Build the coding-agent package first, then run:
|
|
5
|
+
* npx tsx examples/rpc-client.ts "Explain this repository"
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { RpcClient } from "apex-code";
|
|
11
|
+
|
|
12
|
+
const exampleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const prompt = process.argv.slice(2).join(" ") || "Explain this repository in one paragraph.";
|
|
14
|
+
|
|
15
|
+
const client = new RpcClient({
|
|
16
|
+
cliPath: join(exampleDirectory, "../dist/cli.js"),
|
|
17
|
+
args: ["--no-session"],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const unsubscribe = client.onEvent((event) => {
|
|
21
|
+
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
22
|
+
process.stdout.write(event.assistantMessageEvent.delta);
|
|
23
|
+
} else if (event.type === "tool_execution_start") {
|
|
24
|
+
process.stderr.write(`\n[tool: ${event.toolName}]\n`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await client.start();
|
|
30
|
+
await client.promptAndWait(prompt);
|
|
31
|
+
process.stdout.write("\n");
|
|
32
|
+
} finally {
|
|
33
|
+
unsubscribe();
|
|
34
|
+
await client.stop();
|
|
35
|
+
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { spawn } from "node:child_process";
|
|
18
18
|
import { dirname, join } from "node:path";
|
|
19
|
-
import
|
|
19
|
+
import { StringDecoder } from "node:string_decoder";
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
21
21
|
import {
|
|
22
22
|
type Component,
|
|
@@ -258,7 +258,7 @@ async function main() {
|
|
|
258
258
|
|
|
259
259
|
const agent = spawn(
|
|
260
260
|
"node",
|
|
261
|
-
[cliPath, "--mode", "rpc", "--no-session", "--no-
|
|
261
|
+
[cliPath, "--mode", "rpc", "--no-session", "--no-extensions", "--extension", extensionPath],
|
|
262
262
|
{ stdio: ["pipe", "pipe", "pipe"] },
|
|
263
263
|
);
|
|
264
264
|
|
|
@@ -518,9 +518,7 @@ async function main() {
|
|
|
518
518
|
|
|
519
519
|
// -- Process agent stdout --
|
|
520
520
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
stdoutRl.on("line", (line) => {
|
|
521
|
+
function handleAgentLine(line: string): void {
|
|
524
522
|
let data: Record<string, unknown>;
|
|
525
523
|
try {
|
|
526
524
|
data = JSON.parse(line);
|
|
@@ -583,6 +581,28 @@ async function main() {
|
|
|
583
581
|
tui.requestRender();
|
|
584
582
|
return;
|
|
585
583
|
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const stdoutDecoder = new StringDecoder("utf8");
|
|
587
|
+
let stdoutBuffer = "";
|
|
588
|
+
|
|
589
|
+
agent.stdout!.on("data", (chunk: Buffer) => {
|
|
590
|
+
stdoutBuffer += stdoutDecoder.write(chunk);
|
|
591
|
+
while (true) {
|
|
592
|
+
const newlineIndex = stdoutBuffer.indexOf("\n");
|
|
593
|
+
if (newlineIndex === -1) break;
|
|
594
|
+
|
|
595
|
+
const line = stdoutBuffer.slice(0, newlineIndex);
|
|
596
|
+
stdoutBuffer = stdoutBuffer.slice(newlineIndex + 1);
|
|
597
|
+
handleAgentLine(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
agent.stdout!.on("end", () => {
|
|
602
|
+
stdoutBuffer += stdoutDecoder.end();
|
|
603
|
+
if (stdoutBuffer.length > 0) {
|
|
604
|
+
handleAgentLine(stdoutBuffer.endsWith("\r") ? stdoutBuffer.slice(0, -1) : stdoutBuffer);
|
|
605
|
+
}
|
|
586
606
|
});
|
|
587
607
|
|
|
588
608
|
// -- User input --
|
package/examples/sdk/README.md
CHANGED
|
@@ -15,7 +15,7 @@ The runtime example shows how to build a recreate function that closes over proc
|
|
|
15
15
|
| `05-tools.ts` | Built-in tool allowlists |
|
|
16
16
|
| `06-extensions.ts` | Logging, blocking, result modification |
|
|
17
17
|
| `07-context-files.ts` | AGENTS.md context files |
|
|
18
|
-
| `08-
|
|
18
|
+
| `08-prompt-templates.ts` | File-based prompt templates |
|
|
19
19
|
| `09-api-keys-and-oauth.ts` | API key resolution, OAuth config |
|
|
20
20
|
| `10-settings.ts` | Override compaction, retry, terminal settings |
|
|
21
21
|
| `11-sessions.ts` | In-memory, persistent, continue, list sessions |
|