@code-yeongyu/senpi 2026.7.17 → 2026.7.20-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -0
- package/README.md +5 -2
- package/dist/cli/neo/build-argv.d.ts.map +1 -1
- package/dist/cli/neo/build-argv.js +2 -0
- package/dist/cli/neo/build-argv.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +11 -4
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +37 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +395 -73
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +59 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/dynamic-prompt/build.d.ts +7 -0
- package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/build.js +5 -0
- package/dist/core/dynamic-prompt/build.js.map +1 -1
- package/dist/core/dynamic-prompt/workstation.d.ts +35 -0
- package/dist/core/dynamic-prompt/workstation.d.ts.map +1 -0
- package/dist/core/dynamic-prompt/workstation.js +81 -0
- package/dist/core/dynamic-prompt/workstation.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +68 -10
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts +1 -0
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js +20 -2
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.d.ts +7 -1
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +29 -11
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts +9 -7
- package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/todo-bridge.js +34 -9
- package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
- package/dist/core/extensions/builtin/goal/command-registration.d.ts +2 -2
- package/dist/core/extensions/builtin/goal/command-registration.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/command-registration.js +3 -4
- package/dist/core/extensions/builtin/goal/command-registration.js.map +1 -1
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +11 -27
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.d.ts +2 -2
- package/dist/core/extensions/builtin/goal/tool-registration.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.js +2 -3
- package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
- package/dist/core/extensions/builtin/goal/turn-usage.d.ts +20 -0
- package/dist/core/extensions/builtin/goal/turn-usage.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal/turn-usage.js +61 -0
- package/dist/core/extensions/builtin/goal/turn-usage.js.map +1 -0
- package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts +1 -0
- package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/constants.js +5 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/constants.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts +2 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +48 -29
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +2 -2
- package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/index.js +2 -2
- package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +5 -3
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts +7 -6
- package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/types.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/matcher.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/matcher.js +1 -0
- package/dist/core/extensions/builtin/hooks/matcher.js.map +1 -1
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +4 -0
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts +8 -1
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.js +23 -0
- package/dist/core/extensions/builtin/mcp/config-schema.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config.d.ts +13 -0
- package/dist/core/extensions/builtin/mcp/config.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/config.js +36 -0
- package/dist/core/extensions/builtin/mcp/config.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/policy.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/policy.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/status.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/status.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts +3 -3
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js +10 -10
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts +3 -3
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js +14 -14
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.js +5 -5
- package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-snapshot.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-snapshot.js +1 -0
- package/dist/core/extensions/builtin/mcp/service-snapshot.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.d.ts +12 -0
- package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts +2 -2
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +4 -3
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/status.js +1 -0
- package/dist/core/extensions/builtin/mcp/status.js.map +1 -1
- package/dist/core/extensions/builtin/model-fallback/index.d.ts +4 -0
- package/dist/core/extensions/builtin/model-fallback/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/model-fallback/index.js +55 -0
- package/dist/core/extensions/builtin/model-fallback/index.js.map +1 -0
- package/dist/core/extensions/builtin/model-fallback/settings.d.ts +6 -0
- package/dist/core/extensions/builtin/model-fallback/settings.d.ts.map +1 -0
- package/dist/core/extensions/builtin/model-fallback/settings.js +11 -0
- package/dist/core/extensions/builtin/model-fallback/settings.js.map +1 -0
- package/dist/core/extensions/builtin/model-fallback/ui.d.ts +12 -0
- package/dist/core/extensions/builtin/model-fallback/ui.d.ts.map +1 -0
- package/dist/core/extensions/builtin/model-fallback/ui.js +72 -0
- package/dist/core/extensions/builtin/model-fallback/ui.js.map +1 -0
- package/dist/core/extensions/builtin/nested-agents-md/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/nested-agents-md/index.js +4 -1
- package/dist/core/extensions/builtin/nested-agents-md/index.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +5 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +5 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +5 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +5 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +5 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js +2 -2
- package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +3 -3
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +3 -3
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js +80 -0
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +5 -7
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js +14 -0
- package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
- package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
- package/dist/core/extensions/builtin/rules/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/index.js +4 -1
- package/dist/core/extensions/builtin/rules/index.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/shared.d.ts +7 -0
- package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/shared.js +7 -0
- package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.js +68 -6
- package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/commands.d.ts +18 -0
- package/dist/core/extensions/builtin/todotools/commands.d.ts.map +1 -0
- package/dist/core/extensions/builtin/todotools/commands.js +395 -0
- package/dist/core/extensions/builtin/todotools/commands.js.map +1 -0
- package/dist/core/extensions/builtin/todotools/index.d.ts +4 -1
- package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/index.js +17 -14
- package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/markdown.d.ts +13 -0
- package/dist/core/extensions/builtin/todotools/markdown.d.ts.map +1 -0
- package/dist/core/extensions/builtin/todotools/markdown.js +82 -0
- package/dist/core/extensions/builtin/todotools/markdown.js.map +1 -0
- package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -1
- package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/prompt.js +50 -153
- package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/state.d.ts +67 -14
- package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/state.js +400 -35
- package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.d.ts +22 -0
- package/dist/core/extensions/builtin/todotools/tools/todo.d.ts.map +1 -0
- package/dist/core/extensions/builtin/todotools/tools/todo.js +229 -0
- package/dist/core/extensions/builtin/todotools/tools/todo.js.map +1 -0
- package/dist/core/extensions/builtin/video-in/index.d.ts +3 -0
- package/dist/core/extensions/builtin/video-in/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/video-in/index.js +111 -0
- package/dist/core/extensions/builtin/video-in/index.js.map +1 -0
- package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/index.js +20 -3
- package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/renderers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/renderers.js +13 -4
- package/dist/core/extensions/builtin/websearch/websearch/renderers.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/search.d.ts +3 -2
- package/dist/core/extensions/builtin/websearch/websearch/search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/search.js +2 -1
- package/dist/core/extensions/builtin/websearch/websearch/search.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/tool.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/tool.js +17 -1
- package/dist/core/extensions/builtin/websearch/websearch/tool.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/types.d.ts +2 -0
- package/dist/core/extensions/builtin/websearch/websearch/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +10 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +64 -7
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +80 -8
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +116 -18
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.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 +17 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts +12 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +51 -9
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +4 -4
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +8 -1
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +16 -3
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +6 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +27 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/retry-fallback/chains.d.ts +29 -0
- package/dist/core/retry-fallback/chains.d.ts.map +1 -0
- package/dist/core/retry-fallback/chains.js +109 -0
- package/dist/core/retry-fallback/chains.js.map +1 -0
- package/dist/core/retry-fallback/controller.d.ts +77 -0
- package/dist/core/retry-fallback/controller.d.ts.map +1 -0
- package/dist/core/retry-fallback/controller.js +157 -0
- package/dist/core/retry-fallback/controller.js.map +1 -0
- package/dist/core/retry-fallback/cooldown.d.ts +21 -0
- package/dist/core/retry-fallback/cooldown.d.ts.map +1 -0
- package/dist/core/retry-fallback/cooldown.js +49 -0
- package/dist/core/retry-fallback/cooldown.js.map +1 -0
- package/dist/core/retry-fallback/log.d.ts +10 -0
- package/dist/core/retry-fallback/log.d.ts.map +1 -0
- package/dist/core/retry-fallback/log.js +128 -0
- package/dist/core/retry-fallback/log.js.map +1 -0
- package/dist/core/retry-fallback/validate.d.ts +8 -0
- package/dist/core/retry-fallback/validate.d.ts.map +1 -0
- package/dist/core/retry-fallback/validate.js +63 -0
- package/dist/core/retry-fallback/validate.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +6 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +19 -3
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +21 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +100 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +20 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +3 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/llama/client.d.ts.map +1 -0
- package/dist/extensions/llama/client.js +298 -0
- package/dist/extensions/llama/client.js.map +1 -0
- package/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/llama/huggingface.d.ts.map +1 -0
- package/dist/extensions/llama/huggingface.js +139 -0
- package/dist/extensions/llama/huggingface.js.map +1 -0
- package/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/llama/index.d.ts.map +1 -0
- package/dist/extensions/llama/index.js +208 -0
- package/dist/extensions/llama/index.js.map +1 -0
- package/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/llama/provider.d.ts.map +1 -0
- package/dist/extensions/llama/provider.js +106 -0
- package/dist/extensions/llama/provider.js.map +1 -0
- package/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/llama/ui.d.ts.map +1 -0
- package/dist/extensions/llama/ui.js +400 -0
- package/dist/extensions/llama/ui.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -4
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -7
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +154 -114
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +2 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +25 -4
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +165 -13
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/streaming-reveal.d.ts +35 -0
- package/dist/modes/interactive/streaming-reveal.d.ts.map +1 -0
- package/dist/modes/interactive/streaming-reveal.js +268 -0
- package/dist/modes/interactive/streaming-reveal.js.map +1 -0
- package/dist/modes/interactive/tool-args-reveal.d.ts +20 -0
- package/dist/modes/interactive/tool-args-reveal.d.ts.map +1 -0
- package/dist/modes/interactive/tool-args-reveal.js +153 -0
- package/dist/modes/interactive/tool-args-reveal.js.map +1 -0
- package/dist/utils/child-process.d.ts +17 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +41 -1
- package/dist/utils/child-process.js.map +1 -1
- package/docs/AGENTS.md +70 -0
- package/docs/custom-provider.md +28 -0
- package/docs/extensions.md +111 -5
- package/docs/index.md +1 -0
- package/docs/llama-cpp.md +99 -0
- package/docs/mcp.md +21 -5
- package/docs/neo.md +2 -1
- package/docs/prompt-templates.md +1 -0
- package/docs/providers.md +7 -0
- package/docs/settings.md +35 -0
- package/docs/tui.md +41 -26
- package/docs/usage.md +1 -0
- package/examples/AGENTS.md +3 -0
- package/examples/extensions/README.md +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +74 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +59 -19
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +0 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +69 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +6 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +95 -12
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +26 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +24 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +3 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +4 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +5 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/README.md +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +92 -29
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +25 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +105 -61
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4263 -22314
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +436 -1988
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +2 -1892
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +10 -80
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +2 -57
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +43 -267
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +2 -252
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +184 -883
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +2 -811
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +10 -60
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +2 -56
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +168 -884
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +2 -755
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +40 -286
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +2 -236
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/ant-ling.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +7 -58
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -40
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +49 -362
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -292
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +85 -760
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +2 -538
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +31 -189
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js +2 -179
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +49 -309
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js +2 -285
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +22 -118
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +2 -122
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +196 -979
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +2 -884
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +13 -122
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +2 -98
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +10 -48
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +2 -53
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +10 -48
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +2 -53
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +91 -480
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +2 -512
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +31 -257
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +2 -185
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +31 -257
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +2 -185
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +58 -541
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +2 -382
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +22 -196
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +2 -139
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +184 -954
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +2 -825
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +46 -335
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +2 -273
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +163 -1185
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +2 -996
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +1076 -5750
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +2 -4910
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +49 -579
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +2 -377
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +752 -3336
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +2 -3263
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +10 -65
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +2 -57
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +10 -63
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +2 -56
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +10 -63
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +2 -56
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +10 -63
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +2 -56
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +19 -126
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +2 -110
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +19 -144
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +2 -111
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +19 -144
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +2 -111
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.d.ts +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.js +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts +11 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js +40 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js +7 -4
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js +104 -15
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.d.ts +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.js +198 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.js +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.js +33 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.d.ts +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.js +46 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts +8 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +129 -27
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js +140 -6
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js +28 -6
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js +51 -18
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js +70 -9
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +6 -2
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +31 -3
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js +4 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +6 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/stop-details.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js +19 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js +215 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/dist/registry-session.d.ts +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry-session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry-session.js +25 -6
- package/node_modules/@earendil-works/pi-pty/dist/registry-session.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry-types.d.ts +6 -0
- package/node_modules/@earendil-works/pi-pty/dist/registry-types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry-types.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry.d.ts +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/registry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry.js +9 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +6 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +14 -2
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +6 -6
- package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts +0 -4
- package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts.map +0 -1
- package/dist/core/extensions/builtin/todotools/tools/todoread.js +0 -37
- package/dist/core/extensions/builtin/todotools/tools/todoread.js.map +0 -1
- package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts +0 -10
- package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +0 -1
- package/dist/core/extensions/builtin/todotools/tools/todowrite.js +0 -95
- package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Ported and adapted from oh-my-pi's todo tool (MIT License).
|
|
2
|
+
// Copyright (c) 2025 Mario Zechner
|
|
3
|
+
// Copyright (c) 2025-2026 Can Bölük
|
|
4
|
+
// https://github.com/can1357/oh-my-pi
|
|
5
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
6
|
+
import { Type } from "typebox";
|
|
7
|
+
import { TODO_TOOL_DESCRIPTION } from "../prompt.js";
|
|
8
|
+
import { applyParams, clonePhases, findTaskByContent, formatSummary, getCompletionTransitions, getTodoMarker, nextActionableTask, sanitizeTodoText, TODO_STATE_ENTRY_TYPE, } from "../state.js";
|
|
9
|
+
const TodoOperationSchema = Type.Union([
|
|
10
|
+
Type.Literal("init"),
|
|
11
|
+
Type.Literal("start"),
|
|
12
|
+
Type.Literal("done"),
|
|
13
|
+
Type.Literal("rm"),
|
|
14
|
+
Type.Literal("drop"),
|
|
15
|
+
Type.Literal("append"),
|
|
16
|
+
Type.Literal("view"),
|
|
17
|
+
]);
|
|
18
|
+
const TodoPhaseInputSchema = Type.Object({
|
|
19
|
+
phase: Type.String({ description: "Phase name" }),
|
|
20
|
+
items: Type.Array(Type.String({ description: "Task content" }), {
|
|
21
|
+
description: "Tasks for this phase",
|
|
22
|
+
minItems: 1,
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
export const TODO_PARAMS_SCHEMA = Type.Object({
|
|
26
|
+
op: TodoOperationSchema,
|
|
27
|
+
list: Type.Optional(Type.Array(TodoPhaseInputSchema, { description: "Phased task list for init" })),
|
|
28
|
+
task: Type.Optional(Type.String({ description: "Task content" })),
|
|
29
|
+
phase: Type.Optional(Type.String({ description: "Phase name" })),
|
|
30
|
+
// Keep this unconstrained at the schema boundary. init and append return
|
|
31
|
+
// operation-specific errors, while unrelated operations may ignore it.
|
|
32
|
+
items: Type.Optional(Type.Array(Type.String({ description: "Task content" }), { description: "Tasks to append" })),
|
|
33
|
+
});
|
|
34
|
+
function countInitItems(params) {
|
|
35
|
+
if (params.list) {
|
|
36
|
+
return {
|
|
37
|
+
phases: params.list.length,
|
|
38
|
+
tasks: params.list.reduce((total, phase) => total + phase.items.length, 0),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (params.items)
|
|
42
|
+
return { phases: params.items.length > 0 ? 1 : 0, tasks: params.items.length };
|
|
43
|
+
return { phases: 0, tasks: 0 };
|
|
44
|
+
}
|
|
45
|
+
function countLabel(count, singular) {
|
|
46
|
+
return `${count} ${singular}${count === 1 ? "" : "s"}`;
|
|
47
|
+
}
|
|
48
|
+
function renderCallLabel(params) {
|
|
49
|
+
switch (params.op) {
|
|
50
|
+
case "init": {
|
|
51
|
+
const counts = countInitItems(params);
|
|
52
|
+
return `todo init (${countLabel(counts.phases, "phase")}, ${countLabel(counts.tasks, "task")})`;
|
|
53
|
+
}
|
|
54
|
+
case "append":
|
|
55
|
+
return `todo append: ${sanitizeTodoText(params.phase ?? "") || "(missing phase)"} (${countLabel(params.items?.length ?? 0, "item")})`;
|
|
56
|
+
case "start":
|
|
57
|
+
case "done":
|
|
58
|
+
case "drop":
|
|
59
|
+
return `todo ${params.op}: ${sanitizeTodoText(params.task ?? params.phase ?? "") || "(missing target)"}`;
|
|
60
|
+
case "rm":
|
|
61
|
+
return `todo rm: ${sanitizeTodoText(params.task ?? params.phase ?? "all") || "all"}`;
|
|
62
|
+
case "view":
|
|
63
|
+
return "todo view";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function phaseRomanNumeral(oneBasedIndex) {
|
|
67
|
+
if (oneBasedIndex <= 0)
|
|
68
|
+
return "";
|
|
69
|
+
const pairs = [
|
|
70
|
+
[1000, "M"],
|
|
71
|
+
[900, "CM"],
|
|
72
|
+
[500, "D"],
|
|
73
|
+
[400, "CD"],
|
|
74
|
+
[100, "C"],
|
|
75
|
+
[90, "XC"],
|
|
76
|
+
[50, "L"],
|
|
77
|
+
[40, "XL"],
|
|
78
|
+
[10, "X"],
|
|
79
|
+
[9, "IX"],
|
|
80
|
+
[5, "V"],
|
|
81
|
+
[4, "IV"],
|
|
82
|
+
[1, "I"],
|
|
83
|
+
];
|
|
84
|
+
let remaining = oneBasedIndex;
|
|
85
|
+
let output = "";
|
|
86
|
+
for (const [value, symbol] of pairs) {
|
|
87
|
+
while (remaining >= value) {
|
|
88
|
+
output += symbol;
|
|
89
|
+
remaining -= value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return output;
|
|
93
|
+
}
|
|
94
|
+
function formatPhaseHeader(name, index, theme) {
|
|
95
|
+
return theme.fg("accent", theme.bold(`${phaseRomanNumeral(index)}. ${sanitizeTodoText(name)}`));
|
|
96
|
+
}
|
|
97
|
+
function formatPhaseSummary(phase, index, theme) {
|
|
98
|
+
const closed = phase.tasks.filter((task) => task.status === "completed" || task.status === "abandoned").length;
|
|
99
|
+
return theme.fg("dim", `${phaseRomanNumeral(index)}. ${sanitizeTodoText(phase.name)} — ${closed}/${phase.tasks.length} done`);
|
|
100
|
+
}
|
|
101
|
+
function formatTaskLine(task, theme) {
|
|
102
|
+
const content = sanitizeTodoText(task.content);
|
|
103
|
+
const line = `${getTodoMarker(task.status)} ${content}`;
|
|
104
|
+
switch (task.status) {
|
|
105
|
+
case "completed":
|
|
106
|
+
return theme.fg("dim", theme.strikethrough(line));
|
|
107
|
+
case "in_progress":
|
|
108
|
+
return theme.fg("accent", theme.bold(line));
|
|
109
|
+
case "abandoned":
|
|
110
|
+
return theme.fg("dim", line);
|
|
111
|
+
case "pending":
|
|
112
|
+
return line;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function computeTouchedPhases(args, phases, completedTasks) {
|
|
116
|
+
const touched = new Set();
|
|
117
|
+
const activeTask = nextActionableTask(phases);
|
|
118
|
+
if (activeTask) {
|
|
119
|
+
const activePhase = phases.find((phase) => phase.tasks.includes(activeTask));
|
|
120
|
+
if (activePhase)
|
|
121
|
+
touched.add(activePhase.name);
|
|
122
|
+
}
|
|
123
|
+
for (const transition of completedTasks)
|
|
124
|
+
touched.add(transition.phase);
|
|
125
|
+
if (args.op === "init") {
|
|
126
|
+
for (const phase of phases)
|
|
127
|
+
touched.add(phase.name);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (args.phase) {
|
|
131
|
+
const phase = phases.find((candidate) => candidate.name === args.phase);
|
|
132
|
+
if (phase)
|
|
133
|
+
touched.add(phase.name);
|
|
134
|
+
}
|
|
135
|
+
if (args.task) {
|
|
136
|
+
const hit = findTaskByContent([...phases], args.task);
|
|
137
|
+
if (hit)
|
|
138
|
+
touched.add(hit.phase.name);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return touched.size > 0 ? touched : null;
|
|
142
|
+
}
|
|
143
|
+
function renderTodoPhases(phases, completedTasks, options, args, theme) {
|
|
144
|
+
const visiblePhases = phases.filter((phase) => phase.tasks.length > 0);
|
|
145
|
+
if (visiblePhases.length === 0)
|
|
146
|
+
return "";
|
|
147
|
+
const touched = options.expanded || visiblePhases.length === 1 ? null : computeTouchedPhases(args, visiblePhases, completedTasks);
|
|
148
|
+
const lines = [];
|
|
149
|
+
for (let index = 0; index < visiblePhases.length; index += 1) {
|
|
150
|
+
const phase = visiblePhases[index];
|
|
151
|
+
const oneBasedIndex = index + 1;
|
|
152
|
+
if (touched && !touched.has(phase.name)) {
|
|
153
|
+
lines.push(formatPhaseSummary(phase, oneBasedIndex, theme));
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
lines.push(formatPhaseHeader(phase.name, oneBasedIndex, theme));
|
|
157
|
+
for (const task of phase.tasks)
|
|
158
|
+
lines.push(` ${formatTaskLine(task, theme)}`);
|
|
159
|
+
}
|
|
160
|
+
return lines.join("\n");
|
|
161
|
+
}
|
|
162
|
+
function getTextContent(result) {
|
|
163
|
+
return result.content
|
|
164
|
+
.filter((content) => content.type === "text" && typeof content.text === "string")
|
|
165
|
+
.map((content) => content.text)
|
|
166
|
+
.join("\n");
|
|
167
|
+
}
|
|
168
|
+
export function registerTodoTool(pi, accessors) {
|
|
169
|
+
const tool = {
|
|
170
|
+
name: "todo",
|
|
171
|
+
label: "Todo",
|
|
172
|
+
description: TODO_TOOL_DESCRIPTION,
|
|
173
|
+
promptSnippet: "Track phased tasks with one op-based todo tool; reference tasks by their exact content.",
|
|
174
|
+
promptGuidelines: [
|
|
175
|
+
"Use one todo operation at a time; batch it with the real work rather than making a solo todo turn.",
|
|
176
|
+
"Reference tasks and phases by their exact content/name; use view when the text is uncertain.",
|
|
177
|
+
"Mark work done immediately and use drop for tasks that are no longer needed.",
|
|
178
|
+
],
|
|
179
|
+
parameters: TODO_PARAMS_SCHEMA,
|
|
180
|
+
executionMode: "sequential",
|
|
181
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
182
|
+
const previousPhases = clonePhases(accessors.getCurrentPhases());
|
|
183
|
+
const readOnly = params.op === "view";
|
|
184
|
+
const applied = readOnly
|
|
185
|
+
? { phases: previousPhases, errors: [] }
|
|
186
|
+
: applyParams(clonePhases(previousPhases), params);
|
|
187
|
+
const failed = applied.errors.length > 0;
|
|
188
|
+
const effective = failed ? previousPhases : applied.phases;
|
|
189
|
+
const completedTasks = readOnly || failed ? [] : getCompletionTransitions(previousPhases, applied.phases);
|
|
190
|
+
if (!readOnly && !failed) {
|
|
191
|
+
pi.appendEntry(TODO_STATE_ENTRY_TYPE, {
|
|
192
|
+
schema: "v2",
|
|
193
|
+
phases: clonePhases(applied.phases),
|
|
194
|
+
});
|
|
195
|
+
accessors.setCurrentPhases(clonePhases(applied.phases));
|
|
196
|
+
accessors.syncWidget(ctx);
|
|
197
|
+
}
|
|
198
|
+
const details = {
|
|
199
|
+
op: params.op,
|
|
200
|
+
phases: clonePhases(effective),
|
|
201
|
+
storage: ctx.sessionManager.getSessionFile() ? "session" : "memory",
|
|
202
|
+
};
|
|
203
|
+
if (completedTasks.length > 0)
|
|
204
|
+
details.completedTasks = completedTasks;
|
|
205
|
+
return {
|
|
206
|
+
content: [{ type: "text", text: formatSummary(effective, applied.errors, readOnly) }],
|
|
207
|
+
details,
|
|
208
|
+
isError: failed ? true : undefined,
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
renderCall(args, theme) {
|
|
212
|
+
return new Text(theme.fg("toolTitle", theme.bold(renderCallLabel(args))), 0, 0);
|
|
213
|
+
},
|
|
214
|
+
renderResult(result, options, theme, context) {
|
|
215
|
+
if (isTodoToolError(result) || context.isError) {
|
|
216
|
+
return new Text(theme.fg("toolOutput", getTextContent(result)), 0, 0);
|
|
217
|
+
}
|
|
218
|
+
const phases = result.details?.phases ?? [];
|
|
219
|
+
const rendered = renderTodoPhases(phases, result.details?.completedTasks ?? [], options, context.args, theme);
|
|
220
|
+
const text = rendered || getTextContent(result) || "Todo list is empty.";
|
|
221
|
+
return new Text(text, 0, 0);
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
pi.registerTool(tool);
|
|
225
|
+
}
|
|
226
|
+
function isTodoToolError(result) {
|
|
227
|
+
return "isError" in result && result.isError === true;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=todo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/todotools/tools/todo.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,mCAAmC;AACnC,oCAAoC;AACpC,sCAAsC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB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I,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,CAAC;KACD,CAAC;IAEF,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,eAAe,CAAC,MAAwC;IAChE,OAAO,SAAS,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC;AACvD,CAAC","sourcesContent":["// Ported and adapted from oh-my-pi's todo tool (MIT License).\n// Copyright (c) 2025 Mario Zechner\n// Copyright (c) 2025-2026 Can Bölük\n// https://github.com/can1357/oh-my-pi\n\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport type { Theme } from \"../../../../../modes/interactive/theme/theme.ts\";\nimport type {\n\tAgentToolResult,\n\tExtensionAPI,\n\tExtensionContext,\n\tToolDefinition,\n\tToolRenderContext,\n\tToolRenderResultOptions,\n} from \"../../../types.ts\";\nimport { TODO_TOOL_DESCRIPTION } from \"../prompt.ts\";\nimport {\n\tapplyParams,\n\tclonePhases,\n\tfindTaskByContent,\n\tformatSummary,\n\tgetCompletionTransitions,\n\tgetTodoMarker,\n\tnextActionableTask,\n\tsanitizeTodoText,\n\tTODO_STATE_ENTRY_TYPE,\n\ttype TodoCompletionTransition,\n\ttype TodoPhase,\n\ttype TodoStateEntry,\n\ttype TodoToolDetails,\n} from \"../state.ts\";\n\nconst TodoOperationSchema = Type.Union([\n\tType.Literal(\"init\"),\n\tType.Literal(\"start\"),\n\tType.Literal(\"done\"),\n\tType.Literal(\"rm\"),\n\tType.Literal(\"drop\"),\n\tType.Literal(\"append\"),\n\tType.Literal(\"view\"),\n]);\n\nconst TodoPhaseInputSchema = Type.Object({\n\tphase: Type.String({ description: \"Phase name\" }),\n\titems: Type.Array(Type.String({ description: \"Task content\" }), {\n\t\tdescription: \"Tasks for this phase\",\n\t\tminItems: 1,\n\t}),\n});\n\nexport const TODO_PARAMS_SCHEMA = Type.Object({\n\top: TodoOperationSchema,\n\tlist: Type.Optional(Type.Array(TodoPhaseInputSchema, { description: \"Phased task list for init\" })),\n\ttask: Type.Optional(Type.String({ description: \"Task content\" })),\n\tphase: Type.Optional(Type.String({ description: \"Phase name\" })),\n\t// Keep this unconstrained at the schema boundary. init and append return\n\t// operation-specific errors, while unrelated operations may ignore it.\n\titems: Type.Optional(Type.Array(Type.String({ description: \"Task content\" }), { description: \"Tasks to append\" })),\n});\n\ntype TodoParams = Static<typeof TODO_PARAMS_SCHEMA>;\n\ntype TodoAccessors = {\n\tgetCurrentPhases: () => TodoPhase[];\n\tsetCurrentPhases: (phases: TodoPhase[]) => void;\n\tsyncWidget: (ctx: ExtensionContext) => void;\n};\n\ntype TodoToolResult = AgentToolResult<TodoToolDetails> & {\n\tisError?: boolean;\n};\n\nfunction countInitItems(params: TodoParams): { phases: number; tasks: number } {\n\tif (params.list) {\n\t\treturn {\n\t\t\tphases: params.list.length,\n\t\t\ttasks: params.list.reduce((total, phase) => total + phase.items.length, 0),\n\t\t};\n\t}\n\tif (params.items) return { phases: params.items.length > 0 ? 1 : 0, tasks: params.items.length };\n\treturn { phases: 0, tasks: 0 };\n}\n\nfunction countLabel(count: number, singular: string): string {\n\treturn `${count} ${singular}${count === 1 ? \"\" : \"s\"}`;\n}\n\nfunction renderCallLabel(params: TodoParams): string {\n\tswitch (params.op) {\n\t\tcase \"init\": {\n\t\t\tconst counts = countInitItems(params);\n\t\t\treturn `todo init (${countLabel(counts.phases, \"phase\")}, ${countLabel(counts.tasks, \"task\")})`;\n\t\t}\n\t\tcase \"append\":\n\t\t\treturn `todo append: ${sanitizeTodoText(params.phase ?? \"\") || \"(missing phase)\"} (${countLabel(\n\t\t\t\tparams.items?.length ?? 0,\n\t\t\t\t\"item\",\n\t\t\t)})`;\n\t\tcase \"start\":\n\t\tcase \"done\":\n\t\tcase \"drop\":\n\t\t\treturn `todo ${params.op}: ${sanitizeTodoText(params.task ?? params.phase ?? \"\") || \"(missing target)\"}`;\n\t\tcase \"rm\":\n\t\t\treturn `todo rm: ${sanitizeTodoText(params.task ?? params.phase ?? \"all\") || \"all\"}`;\n\t\tcase \"view\":\n\t\t\treturn \"todo view\";\n\t}\n}\n\nexport function phaseRomanNumeral(oneBasedIndex: number): string {\n\tif (oneBasedIndex <= 0) return \"\";\n\tconst pairs: ReadonlyArray<readonly [number, string]> = [\n\t\t[1000, \"M\"],\n\t\t[900, \"CM\"],\n\t\t[500, \"D\"],\n\t\t[400, \"CD\"],\n\t\t[100, \"C\"],\n\t\t[90, \"XC\"],\n\t\t[50, \"L\"],\n\t\t[40, \"XL\"],\n\t\t[10, \"X\"],\n\t\t[9, \"IX\"],\n\t\t[5, \"V\"],\n\t\t[4, \"IV\"],\n\t\t[1, \"I\"],\n\t];\n\tlet remaining = oneBasedIndex;\n\tlet output = \"\";\n\tfor (const [value, symbol] of pairs) {\n\t\twhile (remaining >= value) {\n\t\t\toutput += symbol;\n\t\t\tremaining -= value;\n\t\t}\n\t}\n\treturn output;\n}\n\nfunction formatPhaseHeader(name: string, index: number, theme: Theme): string {\n\treturn theme.fg(\"accent\", theme.bold(`${phaseRomanNumeral(index)}. ${sanitizeTodoText(name)}`));\n}\n\nfunction formatPhaseSummary(phase: TodoPhase, index: number, theme: Theme): string {\n\tconst closed = phase.tasks.filter((task) => task.status === \"completed\" || task.status === \"abandoned\").length;\n\treturn theme.fg(\n\t\t\"dim\",\n\t\t`${phaseRomanNumeral(index)}. ${sanitizeTodoText(phase.name)} — ${closed}/${phase.tasks.length} done`,\n\t);\n}\n\nfunction formatTaskLine(task: TodoPhase[\"tasks\"][number], theme: Theme): string {\n\tconst content = sanitizeTodoText(task.content);\n\tconst line = `${getTodoMarker(task.status)} ${content}`;\n\tswitch (task.status) {\n\t\tcase \"completed\":\n\t\t\treturn theme.fg(\"dim\", theme.strikethrough(line));\n\t\tcase \"in_progress\":\n\t\t\treturn theme.fg(\"accent\", theme.bold(line));\n\t\tcase \"abandoned\":\n\t\t\treturn theme.fg(\"dim\", line);\n\t\tcase \"pending\":\n\t\t\treturn line;\n\t}\n}\n\nfunction computeTouchedPhases(\n\targs: TodoParams,\n\tphases: readonly TodoPhase[],\n\tcompletedTasks: readonly TodoCompletionTransition[],\n): Set<string> | null {\n\tconst touched = new Set<string>();\n\tconst activeTask = nextActionableTask(phases);\n\tif (activeTask) {\n\t\tconst activePhase = phases.find((phase) => phase.tasks.includes(activeTask));\n\t\tif (activePhase) touched.add(activePhase.name);\n\t}\n\tfor (const transition of completedTasks) touched.add(transition.phase);\n\tif (args.op === \"init\") {\n\t\tfor (const phase of phases) touched.add(phase.name);\n\t} else {\n\t\tif (args.phase) {\n\t\t\tconst phase = phases.find((candidate) => candidate.name === args.phase);\n\t\t\tif (phase) touched.add(phase.name);\n\t\t}\n\t\tif (args.task) {\n\t\t\tconst hit = findTaskByContent([...phases], args.task);\n\t\t\tif (hit) touched.add(hit.phase.name);\n\t\t}\n\t}\n\treturn touched.size > 0 ? touched : null;\n}\n\nfunction renderTodoPhases(\n\tphases: readonly TodoPhase[],\n\tcompletedTasks: readonly TodoCompletionTransition[],\n\toptions: ToolRenderResultOptions,\n\targs: TodoParams,\n\ttheme: Theme,\n): string {\n\tconst visiblePhases = phases.filter((phase) => phase.tasks.length > 0);\n\tif (visiblePhases.length === 0) return \"\";\n\n\tconst touched =\n\t\toptions.expanded || visiblePhases.length === 1 ? null : computeTouchedPhases(args, visiblePhases, completedTasks);\n\tconst lines: string[] = [];\n\tfor (let index = 0; index < visiblePhases.length; index += 1) {\n\t\tconst phase = visiblePhases[index];\n\t\tconst oneBasedIndex = index + 1;\n\t\tif (touched && !touched.has(phase.name)) {\n\t\t\tlines.push(formatPhaseSummary(phase, oneBasedIndex, theme));\n\t\t\tcontinue;\n\t\t}\n\t\tlines.push(formatPhaseHeader(phase.name, oneBasedIndex, theme));\n\t\tfor (const task of phase.tasks) lines.push(` ${formatTaskLine(task, theme)}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nfunction getTextContent(result: AgentToolResult<TodoToolDetails>): string {\n\treturn result.content\n\t\t.filter(\n\t\t\t(content): content is { type: \"text\"; text: string } =>\n\t\t\t\tcontent.type === \"text\" && typeof content.text === \"string\",\n\t\t)\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\");\n}\n\nexport function registerTodoTool(pi: ExtensionAPI, accessors: TodoAccessors): void {\n\tconst tool: ToolDefinition<typeof TODO_PARAMS_SCHEMA, TodoToolDetails, unknown> = {\n\t\tname: \"todo\",\n\t\tlabel: \"Todo\",\n\t\tdescription: TODO_TOOL_DESCRIPTION,\n\t\tpromptSnippet: \"Track phased tasks with one op-based todo tool; reference tasks by their exact content.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use one todo operation at a time; batch it with the real work rather than making a solo todo turn.\",\n\t\t\t\"Reference tasks and phases by their exact content/name; use view when the text is uncertain.\",\n\t\t\t\"Mark work done immediately and use drop for tasks that are no longer needed.\",\n\t\t],\n\t\tparameters: TODO_PARAMS_SCHEMA,\n\t\texecutionMode: \"sequential\",\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx): Promise<TodoToolResult> {\n\t\t\tconst previousPhases = clonePhases(accessors.getCurrentPhases());\n\t\t\tconst readOnly = params.op === \"view\";\n\t\t\tconst applied = readOnly\n\t\t\t\t? { phases: previousPhases, errors: [] as string[] }\n\t\t\t\t: applyParams(clonePhases(previousPhases), params);\n\t\t\tconst failed = applied.errors.length > 0;\n\t\t\tconst effective = failed ? previousPhases : applied.phases;\n\t\t\tconst completedTasks = readOnly || failed ? [] : getCompletionTransitions(previousPhases, applied.phases);\n\t\t\tif (!readOnly && !failed) {\n\t\t\t\tpi.appendEntry(TODO_STATE_ENTRY_TYPE, {\n\t\t\t\t\tschema: \"v2\",\n\t\t\t\t\tphases: clonePhases(applied.phases),\n\t\t\t\t} satisfies TodoStateEntry);\n\t\t\t\taccessors.setCurrentPhases(clonePhases(applied.phases));\n\t\t\t\taccessors.syncWidget(ctx);\n\t\t\t}\n\n\t\t\tconst details: TodoToolDetails = {\n\t\t\t\top: params.op,\n\t\t\t\tphases: clonePhases(effective),\n\t\t\t\tstorage: ctx.sessionManager.getSessionFile() ? \"session\" : \"memory\",\n\t\t\t};\n\t\t\tif (completedTasks.length > 0) details.completedTasks = completedTasks;\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatSummary(effective, applied.errors, readOnly) }],\n\t\t\t\tdetails,\n\t\t\t\tisError: failed ? true : undefined,\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme) {\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(renderCallLabel(args))), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme, context: ToolRenderContext<unknown, TodoParams>) {\n\t\t\tif (isTodoToolError(result) || context.isError) {\n\t\t\t\treturn new Text(theme.fg(\"toolOutput\", getTextContent(result)), 0, 0);\n\t\t\t}\n\t\t\tconst phases = result.details?.phases ?? [];\n\t\t\tconst rendered = renderTodoPhases(phases, result.details?.completedTasks ?? [], options, context.args, theme);\n\t\t\tconst text = rendered || getTextContent(result) || \"Todo list is empty.\";\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\t};\n\n\tpi.registerTool(tool);\n}\n\nfunction isTodoToolError(result: AgentToolResult<TodoToolDetails>): result is TodoToolResult {\n\treturn \"isError\" in result && result.isError === true;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/video-in/index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAkCnD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAsE/D"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* video-in — model-gated video file input (kimi-code `ReadMediaFile` parity).
|
|
3
|
+
*
|
|
4
|
+
* Registers a `read_video` tool that reads a local video file and attaches it
|
|
5
|
+
* to the conversation as a base64 video payload. The tool is only active when
|
|
6
|
+
* the current model declares the "video" input modality (currently only
|
|
7
|
+
* kimi-coding `k3`); on `session_start` and `model_select` it is added to or
|
|
8
|
+
* removed from the active tool set accordingly.
|
|
9
|
+
*
|
|
10
|
+
* Wire behavior: the payload rides an ImageContent block with a `video/*`
|
|
11
|
+
* mimeType. The anthropic-messages API serializes such blocks as
|
|
12
|
+
* `{type:"video", source:{type:"base64", media_type, data}}`, which the Kimi
|
|
13
|
+
* Anthropic-compatible endpoint accepts (verified against MoonshotAI/kimi-code
|
|
14
|
+
* kosong anthropic provider). transform-messages downgrades the block to a
|
|
15
|
+
* placeholder for models without the "video" modality, so switching models
|
|
16
|
+
* mid-session cannot wedge the request.
|
|
17
|
+
*/
|
|
18
|
+
import { readFile as fsReadFile, stat as fsStat } from "node:fs/promises";
|
|
19
|
+
import { basename, extname, isAbsolute, resolve as resolvePath } from "node:path";
|
|
20
|
+
import { Type } from "typebox";
|
|
21
|
+
const TOOL_NAME = "read_video";
|
|
22
|
+
/** Same cap as kimi-code's ReadMediaFile (base64 inflates ~4/3 on the wire). */
|
|
23
|
+
const MAX_VIDEO_MEGABYTES = 100;
|
|
24
|
+
const MAX_VIDEO_BYTES = MAX_VIDEO_MEGABYTES * 1024 * 1024;
|
|
25
|
+
/** Extension -> mime map mirrored from kimi-code's supported video set. */
|
|
26
|
+
const EXT_TO_MIME = {
|
|
27
|
+
mp4: "video/mp4",
|
|
28
|
+
mpeg: "video/mpeg",
|
|
29
|
+
mpg: "video/mpeg",
|
|
30
|
+
mov: "video/quicktime",
|
|
31
|
+
webm: "video/webm",
|
|
32
|
+
mkv: "video/x-matroska",
|
|
33
|
+
avi: "video/x-msvideo",
|
|
34
|
+
flv: "video/x-flv",
|
|
35
|
+
"3gp": "video/3gpp",
|
|
36
|
+
};
|
|
37
|
+
function detectVideoMimeType(path) {
|
|
38
|
+
const ext = extname(path).slice(1).toLowerCase();
|
|
39
|
+
return EXT_TO_MIME[ext];
|
|
40
|
+
}
|
|
41
|
+
function modelSupportsVideo(model) {
|
|
42
|
+
return model?.input?.includes("video") === true;
|
|
43
|
+
}
|
|
44
|
+
const readVideoSchema = Type.Object({
|
|
45
|
+
path: Type.String({ description: "Path to a video file (relative or absolute). Max 100MB." }),
|
|
46
|
+
});
|
|
47
|
+
export default function videoInExtension(pi) {
|
|
48
|
+
pi.registerTool({
|
|
49
|
+
name: TOOL_NAME,
|
|
50
|
+
label: "Read Video",
|
|
51
|
+
description: `Read a video file (${Object.keys(EXT_TO_MIME).join(", ")}) and attach it to the conversation so you can watch it. ` +
|
|
52
|
+
`Maximum file size ${MAX_VIDEO_MEGABYTES}MB. ` +
|
|
53
|
+
"Use this to understand screen recordings, demo clips, or any behavior that is hard to describe in text. " +
|
|
54
|
+
"If you generate or edit a video via commands or scripts, read the result back before continuing.",
|
|
55
|
+
promptSnippet: "Attach a video file so the model can watch it (video-capable models only)",
|
|
56
|
+
parameters: readVideoSchema,
|
|
57
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
58
|
+
if (signal?.aborted)
|
|
59
|
+
throw new Error("Operation aborted");
|
|
60
|
+
if (!modelSupportsVideo(ctx.model)) {
|
|
61
|
+
throw new Error("The current model does not support video input. Tell the user to switch to a model with video input capability (e.g. kimi-coding/k3).");
|
|
62
|
+
}
|
|
63
|
+
const absolutePath = isAbsolute(params.path) ? params.path : resolvePath(ctx.cwd, params.path);
|
|
64
|
+
const mimeType = detectVideoMimeType(absolutePath);
|
|
65
|
+
if (!mimeType) {
|
|
66
|
+
throw new Error(`"${params.path}" is not a supported video file. Supported extensions: ${Object.keys(EXT_TO_MIME).join(", ")}.`);
|
|
67
|
+
}
|
|
68
|
+
const stats = await fsStat(absolutePath);
|
|
69
|
+
if (!stats.isFile()) {
|
|
70
|
+
throw new Error(`"${params.path}" is not a regular file.`);
|
|
71
|
+
}
|
|
72
|
+
if (stats.size === 0) {
|
|
73
|
+
throw new Error(`"${params.path}" is empty.`);
|
|
74
|
+
}
|
|
75
|
+
if (stats.size > MAX_VIDEO_BYTES) {
|
|
76
|
+
throw new Error(`"${params.path}" is ${stats.size} bytes, which exceeds the maximum ${MAX_VIDEO_MEGABYTES}MB for video files. Create a smaller clip (e.g. with ffmpeg) and read that instead.`);
|
|
77
|
+
}
|
|
78
|
+
const data = await fsReadFile(absolutePath);
|
|
79
|
+
if (signal?.aborted)
|
|
80
|
+
throw new Error("Operation aborted");
|
|
81
|
+
return {
|
|
82
|
+
content: [
|
|
83
|
+
{
|
|
84
|
+
type: "text",
|
|
85
|
+
text: `Read video file "${basename(absolutePath)}" [${mimeType}, ${stats.size} bytes]. The video is attached below.`,
|
|
86
|
+
},
|
|
87
|
+
{ type: "image", data: data.toString("base64"), mimeType },
|
|
88
|
+
],
|
|
89
|
+
details: undefined,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
function syncToolActivation(model) {
|
|
94
|
+
const active = pi.getActiveTools();
|
|
95
|
+
const isActive = active.includes(TOOL_NAME);
|
|
96
|
+
const shouldBeActive = modelSupportsVideo(model);
|
|
97
|
+
if (shouldBeActive && !isActive) {
|
|
98
|
+
pi.setActiveTools([...active, TOOL_NAME]);
|
|
99
|
+
}
|
|
100
|
+
else if (!shouldBeActive && isActive) {
|
|
101
|
+
pi.setActiveTools(active.filter((name) => name !== TOOL_NAME));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
105
|
+
syncToolActivation(ctx.model);
|
|
106
|
+
});
|
|
107
|
+
pi.on("model_select", async (event) => {
|
|
108
|
+
syncToolActivation(event.model);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/video-in/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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E,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC;QAChE,CAAC;IACF,CAAC;IAED,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * video-in — model-gated video file input (kimi-code `ReadMediaFile` parity).\n *\n * Registers a `read_video` tool that reads a local video file and attaches it\n * to the conversation as a base64 video payload. The tool is only active when\n * the current model declares the \"video\" input modality (currently only\n * kimi-coding `k3`); on `session_start` and `model_select` it is added to or\n * removed from the active tool set accordingly.\n *\n * Wire behavior: the payload rides an ImageContent block with a `video/*`\n * mimeType. The anthropic-messages API serializes such blocks as\n * `{type:\"video\", source:{type:\"base64\", media_type, data}}`, which the Kimi\n * Anthropic-compatible endpoint accepts (verified against MoonshotAI/kimi-code\n * kosong anthropic provider). transform-messages downgrades the block to a\n * placeholder for models without the \"video\" modality, so switching models\n * mid-session cannot wedge the request.\n */\nimport { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { basename, extname, isAbsolute, resolve as resolvePath } from \"node:path\";\nimport type { Model } from \"@earendil-works/pi-ai\";\nimport { Type } from \"typebox\";\nimport type { ExtensionAPI } from \"../../types.ts\";\n\nconst TOOL_NAME = \"read_video\";\n\n/** Same cap as kimi-code's ReadMediaFile (base64 inflates ~4/3 on the wire). */\nconst MAX_VIDEO_MEGABYTES = 100;\nconst MAX_VIDEO_BYTES = MAX_VIDEO_MEGABYTES * 1024 * 1024;\n\n/** Extension -> mime map mirrored from kimi-code's supported video set. */\nconst EXT_TO_MIME: Record<string, string> = {\n\tmp4: \"video/mp4\",\n\tmpeg: \"video/mpeg\",\n\tmpg: \"video/mpeg\",\n\tmov: \"video/quicktime\",\n\twebm: \"video/webm\",\n\tmkv: \"video/x-matroska\",\n\tavi: \"video/x-msvideo\",\n\tflv: \"video/x-flv\",\n\t\"3gp\": \"video/3gpp\",\n};\n\nfunction detectVideoMimeType(path: string): string | undefined {\n\tconst ext = extname(path).slice(1).toLowerCase();\n\treturn EXT_TO_MIME[ext];\n}\n\nfunction modelSupportsVideo(model: Model<any> | undefined): boolean {\n\treturn model?.input?.includes(\"video\") === true;\n}\n\nconst readVideoSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to a video file (relative or absolute). Max 100MB.\" }),\n});\n\nexport default function videoInExtension(pi: ExtensionAPI): void {\n\tpi.registerTool({\n\t\tname: TOOL_NAME,\n\t\tlabel: \"Read Video\",\n\t\tdescription:\n\t\t\t`Read a video file (${Object.keys(EXT_TO_MIME).join(\", \")}) and attach it to the conversation so you can watch it. ` +\n\t\t\t`Maximum file size ${MAX_VIDEO_MEGABYTES}MB. ` +\n\t\t\t\"Use this to understand screen recordings, demo clips, or any behavior that is hard to describe in text. \" +\n\t\t\t\"If you generate or edit a video via commands or scripts, read the result back before continuing.\",\n\t\tpromptSnippet: \"Attach a video file so the model can watch it (video-capable models only)\",\n\t\tparameters: readVideoSchema,\n\t\tasync execute(_toolCallId, params, signal, _onUpdate, ctx) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tif (!modelSupportsVideo(ctx.model)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"The current model does not support video input. Tell the user to switch to a model with video input capability (e.g. kimi-coding/k3).\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst absolutePath = isAbsolute(params.path) ? params.path : resolvePath(ctx.cwd, params.path);\n\t\t\tconst mimeType = detectVideoMimeType(absolutePath);\n\t\t\tif (!mimeType) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`\"${params.path}\" is not a supported video file. Supported extensions: ${Object.keys(EXT_TO_MIME).join(\", \")}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst stats = await fsStat(absolutePath);\n\t\t\tif (!stats.isFile()) {\n\t\t\t\tthrow new Error(`\"${params.path}\" is not a regular file.`);\n\t\t\t}\n\t\t\tif (stats.size === 0) {\n\t\t\t\tthrow new Error(`\"${params.path}\" is empty.`);\n\t\t\t}\n\t\t\tif (stats.size > MAX_VIDEO_BYTES) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`\"${params.path}\" is ${stats.size} bytes, which exceeds the maximum ${MAX_VIDEO_MEGABYTES}MB for video files. Create a smaller clip (e.g. with ffmpeg) and read that instead.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await fsReadFile(absolutePath);\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Read video file \"${basename(absolutePath)}\" [${mimeType}, ${stats.size} bytes]. The video is attached below.`,\n\t\t\t\t\t},\n\t\t\t\t\t{ type: \"image\", data: data.toString(\"base64\"), mimeType },\n\t\t\t\t],\n\t\t\t\tdetails: undefined,\n\t\t\t};\n\t\t},\n\t});\n\n\tfunction syncToolActivation(model: Model<any> | undefined): void {\n\t\tconst active = pi.getActiveTools();\n\t\tconst isActive = active.includes(TOOL_NAME);\n\t\tconst shouldBeActive = modelSupportsVideo(model);\n\t\tif (shouldBeActive && !isActive) {\n\t\t\tpi.setActiveTools([...active, TOOL_NAME]);\n\t\t} else if (!shouldBeActive && isActive) {\n\t\t\tpi.setActiveTools(active.filter((name) => name !== TOOL_NAME));\n\t\t}\n\t}\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolActivation(ctx.model);\n\t});\n\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolActivation(event.model);\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/websearch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/websearch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AA0BrE,MAAM,CAAC,OAAO,WAAW,EAAE,EAAE,YAAY,GAAG,IAAI,CA+E/C"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import { isAnthropicWebSearchEnabled, supportsNativeAnthropicWebSearch } from "../anthropic-web-search/index.js";
|
|
2
|
+
import { isOpenaiWebSearchEnabled, supportsNativeOpenAiWebSearch } from "../openai-web-search/index.js";
|
|
1
3
|
import { loadWebsearchConfig } from "./websearch/config.js";
|
|
2
4
|
import { createWebSearchTool } from "./websearch/tool.js";
|
|
3
5
|
const STATUS_KEY = "pi-websearch";
|
|
4
6
|
const WIDGET_KEY = "pi-websearch";
|
|
5
7
|
const NATIVE_BYPASS_MESSAGE = "Native provider web search is handled by the built-in provider extension.";
|
|
8
|
+
// Defer to the provider-native server-side web_search only when the builtin
|
|
9
|
+
// injecting extension will actually add it for this exact model (first-party
|
|
10
|
+
// endpoint or explicit compat opt-in, and not disabled via env). A provider id
|
|
11
|
+
// of "anthropic"/"openai" alone is not enough: proxied baseUrls (ccapi, quotio,
|
|
12
|
+
// …) never receive the native tool, so bypassing there leaves no web search.
|
|
6
13
|
function isProviderNativeBypass(model) {
|
|
7
|
-
|
|
14
|
+
if (supportsNativeAnthropicWebSearch(model))
|
|
15
|
+
return isAnthropicWebSearchEnabled();
|
|
16
|
+
if (supportsNativeOpenAiWebSearch(model))
|
|
17
|
+
return isOpenaiWebSearchEnabled();
|
|
18
|
+
return false;
|
|
8
19
|
}
|
|
9
20
|
export default function (pi) {
|
|
10
21
|
let state = {
|
|
@@ -39,11 +50,17 @@ export default function (pi) {
|
|
|
39
50
|
ctx.ui.notify(state.message, "error");
|
|
40
51
|
}
|
|
41
52
|
pi.registerTool(createWebSearchTool(() => state));
|
|
42
|
-
|
|
43
|
-
state = isProviderNativeBypass(
|
|
53
|
+
async function refreshState(model, ctx) {
|
|
54
|
+
state = isProviderNativeBypass(model)
|
|
44
55
|
? { ok: false, reason: "provider_native_bypass", message: NATIVE_BYPASS_MESSAGE }
|
|
45
56
|
: await loadWebsearchConfig({ cwd: ctx.cwd });
|
|
46
57
|
updateUi(ctx);
|
|
58
|
+
}
|
|
59
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
60
|
+
await refreshState(ctx.model, ctx);
|
|
61
|
+
});
|
|
62
|
+
pi.on("model_select", async (event, ctx) => {
|
|
63
|
+
await refreshState(event.model, ctx);
|
|
47
64
|
});
|
|
48
65
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
49
66
|
clearUi(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/websearch/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/websearch/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACjH,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAExG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,MAAM,UAAU,GAAG,cAAc,CAAC;AAClC,MAAM,UAAU,GAAG,cAAc,CAAC;AAClC,MAAM,qBAAqB,GAAG,2EAA2E,CAAC;AAK1G,4EAA4E;AAC5E,6EAA6E;AAC7E,+EAA+E;A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AAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAC;gBACrD,OAAO;YACR,CAAC;YACD,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;gBACd,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,+BAA+B,KAAK,CAAC,MAAM,CAAC,QAAQ,UAAU,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,eAAe,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EACnJ,MAAM,CACN,CAAC;gBACF,OAAO;YACR,CAAC;YACD,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,KAAK,CAAC,MAAM,KAAK,wBAAwB;gBACxC,CAAC,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE;gBACzC,CAAC,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,EAC1C,KAAK,CAAC,MAAM,KAAK,wBAAwB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAC5D,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { isAnthropicWebSearchEnabled, supportsNativeAnthropicWebSearch } from \"../anthropic-web-search/index.ts\";\nimport { isOpenaiWebSearchEnabled, supportsNativeOpenAiWebSearch } from \"../openai-web-search/index.ts\";\n\nimport { loadWebsearchConfig } from \"./websearch/config.ts\";\nimport { createWebSearchTool } from \"./websearch/tool.ts\";\nimport type { ConfigLoadResult, WebsearchConfig } from \"./websearch/types.ts\";\n\nconst STATUS_KEY = \"pi-websearch\";\nconst WIDGET_KEY = \"pi-websearch\";\nconst NATIVE_BYPASS_MESSAGE = \"Native provider web search is handled by the built-in provider extension.\";\n\ntype NativeCapableModel = Parameters<typeof supportsNativeAnthropicWebSearch>[0] &\n\tParameters<typeof supportsNativeOpenAiWebSearch>[0];\n\n// Defer to the provider-native server-side web_search only when the builtin\n// injecting extension will actually add it for this exact model (first-party\n// endpoint or explicit compat opt-in, and not disabled via env). A provider id\n// of \"anthropic\"/\"openai\" alone is not enough: proxied baseUrls (ccapi, quotio,\n// …) never receive the native tool, so bypassing there leaves no web search.\nfunction isProviderNativeBypass(model: NativeCapableModel): boolean {\n\tif (supportsNativeAnthropicWebSearch(model)) return isAnthropicWebSearchEnabled();\n\tif (supportsNativeOpenAiWebSearch(model)) return isOpenaiWebSearchEnabled();\n\treturn false;\n}\n\nexport default function (pi: ExtensionAPI): void {\n\tlet state: ConfigLoadResult = {\n\t\tok: false,\n\t\treason: \"missing_config\",\n\t\tmessage: \"Missing websearch config. Create .pi/websearch.json or ~/.pi/websearch.json before starting pi.\",\n\t};\n\n\tfunction providerLabel(provider: WebsearchConfig[\"providers\"][number]): string {\n\t\treturn provider.id ? `${provider.id}/${provider.provider}` : provider.provider;\n\t}\n\n\tfunction providerList(config: WebsearchConfig): string {\n\t\treturn config.providers.map(providerLabel).join(\", \");\n\t}\n\n\tfunction clearUi(ctx: ExtensionContext): void {\n\t\tif (ctx.hasUI === false) return;\n\t\tctx.ui.setStatus(STATUS_KEY, undefined);\n\t\tctx.ui.setWidget(WIDGET_KEY, undefined);\n\t}\n\n\tfunction updateUi(ctx: ExtensionContext): void {\n\t\tif (ctx.hasUI === false) return;\n\t\tif (state.ok) {\n\t\t\tclearUi(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (state.reason === \"provider_native_bypass\") {\n\t\t\tclearUi(ctx);\n\t\t\treturn;\n\t\t}\n\t\tclearUi(ctx);\n\t\tctx.ui.notify(state.message, \"error\");\n\t}\n\n\tpi.registerTool(createWebSearchTool(() => state));\n\n\tasync function refreshState(model: NativeCapableModel, ctx: ExtensionContext): Promise<void> {\n\t\tstate = isProviderNativeBypass(model)\n\t\t\t? { ok: false, reason: \"provider_native_bypass\", message: NATIVE_BYPASS_MESSAGE }\n\t\t\t: await loadWebsearchConfig({ cwd: ctx.cwd });\n\t\tupdateUi(ctx);\n\t}\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tawait refreshState(ctx.model, ctx);\n\t});\n\n\tpi.on(\"model_select\", async (event, ctx) => {\n\t\tawait refreshState(event.model, ctx);\n\t});\n\n\tpi.on(\"session_shutdown\", async (_event, ctx) => {\n\t\tclearUi(ctx);\n\t});\n\n\tpi.registerCommand(\"websearch\", {\n\t\tdescription: \"Show web search provider status\",\n\t\thandler: async (rawArgs, ctx) => {\n\t\t\tconst args = rawArgs.trim();\n\t\t\tif (args !== \"\" && args !== \"status\") {\n\t\t\t\tctx.ui.notify(\"Usage: /websearch status\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (state.ok) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`Web search active: strategy=${state.config.strategy}, auto=${state.config.auto ? \"enabled\" : \"disabled\"}, providers=${providerList(state.config)}`,\n\t\t\t\t\t\"info\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.ui.notify(\n\t\t\t\tstate.reason === \"provider_native_bypass\"\n\t\t\t\t\t? `Web search deferred: ${state.message}`\n\t\t\t\t\t: `Web search inactive: ${state.message}`,\n\t\t\t\tstate.reason === \"provider_native_bypass\" ? \"info\" : \"error\",\n\t\t\t);\n\t\t},\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderers.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/websearch/websearch/renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,KAAK,EAA4D,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEhH,UAAU,SAAS;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACvC;AAED,UAAU,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,UAAU,UAAU,CAAC,QAAQ;IAC5B,OAAO,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,OAAO,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED,UAAU,mBAAmB;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AA6BD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAMzE;AAED,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,EACvC,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,SAAS,GACd,IAAI,
|
|
1
|
+
{"version":3,"file":"renderers.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/websearch/websearch/renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,KAAK,EAA4D,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEhH,UAAU,SAAS;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACvC;AAED,UAAU,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,UAAU,UAAU,CAAC,QAAQ;IAC5B,OAAO,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,OAAO,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED,UAAU,mBAAmB;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AA6BD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAMzE;AAED,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,EACvC,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,SAAS,GACd,IAAI,CAuDN"}
|
|
@@ -5,9 +5,9 @@ function shorten(value, max) {
|
|
|
5
5
|
function durationText(durationMs) {
|
|
6
6
|
return durationMs >= 1000 ? `${Math.round(durationMs / 1000)}s` : `${durationMs}ms`;
|
|
7
7
|
}
|
|
8
|
-
function attemptLabel(
|
|
9
|
-
return
|
|
10
|
-
?
|
|
8
|
+
function attemptLabel(attempts) {
|
|
9
|
+
return attempts
|
|
10
|
+
? attempts
|
|
11
11
|
.map((attempt) => `${attempt.entryId ? `${attempt.provider}/${attempt.entryId}` : attempt.provider}:${attempt.error ? "failed" : attempt.resultsCount}`)
|
|
12
12
|
.join(" -> ")
|
|
13
13
|
: "";
|
|
@@ -29,6 +29,15 @@ export function renderSearchResult(result, options, theme) {
|
|
|
29
29
|
if (options.isPartial) {
|
|
30
30
|
const details = result.details;
|
|
31
31
|
if (isSearchProgressDetails(details)) {
|
|
32
|
+
if (details.currentProvider) {
|
|
33
|
+
const total = details.providerLabels.length;
|
|
34
|
+
const position = Math.min((details.attempts?.length ?? 0) + 1, Math.max(total, 1));
|
|
35
|
+
const step = total > 1 ? ` [${position}/${total}]` : "";
|
|
36
|
+
const line = theme.fg("warning", `Searching "${shorten(details.query, 80)}" via ${details.currentProvider}${step} (max ${details.maxResults})`);
|
|
37
|
+
const attempts = attemptLabel(details.attempts);
|
|
38
|
+
const rows = options.expanded && attempts ? [line, theme.fg("muted", `route ${attempts}`)] : [line];
|
|
39
|
+
return new Text(rows.join("\n"), 0, 0);
|
|
40
|
+
}
|
|
32
41
|
const route = details.providerLabels.length > 0 ? details.providerLabels.join(" -> ") : "configured providers";
|
|
33
42
|
return new Text(theme.fg("warning", `Searching "${shorten(details.query, 80)}" via ${route} (max ${details.maxResults})`), 0, 0);
|
|
34
43
|
}
|
|
@@ -50,7 +59,7 @@ export function renderSearchResult(result, options, theme) {
|
|
|
50
59
|
(details.truncated ? theme.fg("warning", " (truncated)") : "");
|
|
51
60
|
if (count === 0)
|
|
52
61
|
return new Text(summary, 0, 0);
|
|
53
|
-
const attempts = attemptLabel(details);
|
|
62
|
+
const attempts = attemptLabel(details.attempts);
|
|
54
63
|
const rows = options.expanded && attempts ? [summary, theme.fg("muted", `route ${attempts}`)] : [summary];
|
|
55
64
|
const visibleLimit = options.expanded ? 8 : 3;
|
|
56
65
|
for (const item of details.results.slice(0, visibleLimit)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/websearch/websearch/renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAyB9C,SAAS,OAAO,CAAC,KAAa,EAAE,GAAW;IAC1C,OAAO,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;AACpE,CAAC;AAED,SAAS,YAAY,CAAC,UAAkB;IACvC,OAAO,UAAU,IAAI,IAAI,CAAC,CAAC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,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { Text } from \"@earendil-works/pi-tui\";\n\nimport type { SearchDetails, SearchErrorDetails, SearchProgressDetails, SearchRenderDetails } from \"./types.ts\";\n\ninterface ThemeLike {\n\tbold(value: string): string;\n\tfg(key: string, value: string): string;\n}\n\ninterface SearchArgs {\n\tquery: string;\n\tallowed_domains?: string[];\n\tblocked_domains?: string[];\n}\n\ninterface ResultLike<TDetails> {\n\tcontent: ReadonlyArray<{ type: string; text?: string }>;\n\tdetails?: TDetails;\n}\n\ninterface RenderResultOptions {\n\texpanded?: boolean;\n\tisPartial?: boolean;\n}\n\nfunction shorten(value: string, max: number): string {\n\treturn value.length <= max ? value : `${value.slice(0, max - 1)}…`;\n}\n\nfunction durationText(durationMs: number): string {\n\treturn durationMs >= 1000 ? `${Math.round(durationMs / 1000)}s` : `${durationMs}ms`;\n}\n\nfunction attemptLabel(details: SearchDetails): string {\n\treturn details.attempts\n\t\t? details.attempts\n\t\t\t\t.map(\n\t\t\t\t\t(attempt) =>\n\t\t\t\t\t\t`${attempt.entryId ? `${attempt.provider}/${attempt.entryId}` : attempt.provider}:${attempt.error ? \"failed\" : attempt.resultsCount}`,\n\t\t\t\t)\n\t\t\t\t.join(\" -> \")\n\t\t: \"\";\n}\n\nfunction isSearchProgressDetails(details: SearchRenderDetails | undefined): details is SearchProgressDetails {\n\treturn details !== undefined && \"phase\" in details && details.phase === \"searching\";\n}\n\nfunction isSearchErrorDetails(details: SearchRenderDetails): details is SearchErrorDetails {\n\treturn \"phase\" in details && details.phase === \"error\";\n}\n\nexport function renderSearchCall(args: SearchArgs, theme: ThemeLike): Text {\n\tconst head = theme.fg(\"toolTitle\", theme.bold(\"web_search \"));\n\tconst query = theme.fg(\"accent\", `\"${shorten(args.query, 90)}\"`);\n\tconst domains = args.allowed_domains ?? args.blocked_domains;\n\tconst filter = domains?.length ? theme.fg(\"muted\", ` domains:${domains.length}`) : \"\";\n\treturn new Text(head + query + filter, 0, 0);\n}\n\nexport function renderSearchResult(\n\tresult: ResultLike<SearchRenderDetails>,\n\toptions: RenderResultOptions,\n\ttheme: ThemeLike,\n): Text {\n\tif (options.isPartial) {\n\t\tconst details = result.details;\n\t\tif (isSearchProgressDetails(details)) {\n\t\t\tconst route = details.providerLabels.length > 0 ? details.providerLabels.join(\" -> \") : \"configured providers\";\n\t\t\treturn new Text(\n\t\t\t\ttheme.fg(\"warning\", `Searching \"${shorten(details.query, 80)}\" via ${route} (max ${details.maxResults})`),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t);\n\t\t}\n\t\treturn new Text(theme.fg(\"warning\", result.content[0]?.text ?? \"Searching the web...\"), 0, 0);\n\t}\n\n\tconst details = result.details;\n\tif (!details) return new Text(theme.fg(\"muted\", result.content[0]?.text ?? \"\"), 0, 0);\n\tif (isSearchProgressDetails(details)) return new Text(theme.fg(\"muted\", result.content[0]?.text ?? \"\"), 0, 0);\n\tif (isSearchErrorDetails(details)) return new Text(theme.fg(\"error\", details.error), 0, 0);\n\tif (details.error) return new Text(theme.fg(\"error\", details.error), 0, 0);\n\n\tconst count = details.results.length;\n\tconst provider = details.entryId ? `${details.provider}/${details.entryId}` : details.provider;\n\tconst summary =\n\t\ttheme.fg(\"success\", `${count} result${count === 1 ? \"\" : \"s\"}`) +\n\t\ttheme.fg(\n\t\t\t\"muted\",\n\t\t\t` via ${provider}${details.strategy ? ` (${details.strategy})` : \"\"} in ${durationText(details.durationMs)}`,\n\t\t) +\n\t\t(details.truncated ? theme.fg(\"warning\", \" (truncated)\") : \"\");\n\n\tif (count === 0) return new Text(summary, 0, 0);\n\n\tconst attempts = attemptLabel(details);\n\tconst rows = options.expanded && attempts ? [summary, theme.fg(\"muted\", `route ${attempts}`)] : [summary];\n\tconst visibleLimit = options.expanded ? 8 : 3;\n\tfor (const item of details.results.slice(0, visibleLimit)) {\n\t\trows.push(`${theme.fg(\"accent\", shorten(item.title, 80))} ${theme.fg(\"dim\", shorten(item.url, 100))}`);\n\t\tif (item.snippet) rows.push(theme.fg(\"muted\", ` ${shorten(item.snippet, 140)}`));\n\t}\n\tif (details.results.length > visibleLimit) {\n\t\trows.push(theme.fg(\"dim\", `… ${details.results.length - visibleLimit} more sources`));\n\t}\n\treturn new Text(rows.join(\"\\n\"), 0, 0);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/websearch/websearch/renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAyB9C,SAAS,OAAO,CAAC,KAAa,EAAE,GAAW;IAC1C,OAAO,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;AACpE,CAAC;AAED,SAAS,YAAY,CAAC,UAAkB;IACvC,OAAO,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,CAAC;AACrF,CAAC;AAED,SAAS,YAAY,CAAC,QAAmC;IACxD,OAAO,QAAQ;QACd,CAAC,CAAC,QAAQ;aACP,GAAG,CACH,CAAC,OAAO,EAAE,EAAE,CACX,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,CACtI;aACA,IAAI,CAAC,MAAM,CAAC;QACf,CA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AE,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACvG,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,YAAY,eAAe,CAAC,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { Text } from \"@earendil-works/pi-tui\";\n\nimport type { SearchDetails, SearchErrorDetails, SearchProgressDetails, SearchRenderDetails } from \"./types.ts\";\n\ninterface ThemeLike {\n\tbold(value: string): string;\n\tfg(key: string, value: string): string;\n}\n\ninterface SearchArgs {\n\tquery: string;\n\tallowed_domains?: string[];\n\tblocked_domains?: string[];\n}\n\ninterface ResultLike<TDetails> {\n\tcontent: ReadonlyArray<{ type: string; text?: string }>;\n\tdetails?: TDetails;\n}\n\ninterface RenderResultOptions {\n\texpanded?: boolean;\n\tisPartial?: boolean;\n}\n\nfunction shorten(value: string, max: number): string {\n\treturn value.length <= max ? value : `${value.slice(0, max - 1)}…`;\n}\n\nfunction durationText(durationMs: number): string {\n\treturn durationMs >= 1000 ? `${Math.round(durationMs / 1000)}s` : `${durationMs}ms`;\n}\n\nfunction attemptLabel(attempts: SearchDetails[\"attempts\"]): string {\n\treturn attempts\n\t\t? attempts\n\t\t\t\t.map(\n\t\t\t\t\t(attempt) =>\n\t\t\t\t\t\t`${attempt.entryId ? `${attempt.provider}/${attempt.entryId}` : attempt.provider}:${attempt.error ? \"failed\" : attempt.resultsCount}`,\n\t\t\t\t)\n\t\t\t\t.join(\" -> \")\n\t\t: \"\";\n}\n\nfunction isSearchProgressDetails(details: SearchRenderDetails | undefined): details is SearchProgressDetails {\n\treturn details !== undefined && \"phase\" in details && details.phase === \"searching\";\n}\n\nfunction isSearchErrorDetails(details: SearchRenderDetails): details is SearchErrorDetails {\n\treturn \"phase\" in details && details.phase === \"error\";\n}\n\nexport function renderSearchCall(args: SearchArgs, theme: ThemeLike): Text {\n\tconst head = theme.fg(\"toolTitle\", theme.bold(\"web_search \"));\n\tconst query = theme.fg(\"accent\", `\"${shorten(args.query, 90)}\"`);\n\tconst domains = args.allowed_domains ?? args.blocked_domains;\n\tconst filter = domains?.length ? theme.fg(\"muted\", ` domains:${domains.length}`) : \"\";\n\treturn new Text(head + query + filter, 0, 0);\n}\n\nexport function renderSearchResult(\n\tresult: ResultLike<SearchRenderDetails>,\n\toptions: RenderResultOptions,\n\ttheme: ThemeLike,\n): Text {\n\tif (options.isPartial) {\n\t\tconst details = result.details;\n\t\tif (isSearchProgressDetails(details)) {\n\t\t\tif (details.currentProvider) {\n\t\t\t\tconst total = details.providerLabels.length;\n\t\t\t\tconst position = Math.min((details.attempts?.length ?? 0) + 1, Math.max(total, 1));\n\t\t\t\tconst step = total > 1 ? ` [${position}/${total}]` : \"\";\n\t\t\t\tconst line = theme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t`Searching \"${shorten(details.query, 80)}\" via ${details.currentProvider}${step} (max ${details.maxResults})`,\n\t\t\t\t);\n\t\t\t\tconst attempts = attemptLabel(details.attempts);\n\t\t\t\tconst rows = options.expanded && attempts ? [line, theme.fg(\"muted\", `route ${attempts}`)] : [line];\n\t\t\t\treturn new Text(rows.join(\"\\n\"), 0, 0);\n\t\t\t}\n\t\t\tconst route = details.providerLabels.length > 0 ? details.providerLabels.join(\" -> \") : \"configured providers\";\n\t\t\treturn new Text(\n\t\t\t\ttheme.fg(\"warning\", `Searching \"${shorten(details.query, 80)}\" via ${route} (max ${details.maxResults})`),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t);\n\t\t}\n\t\treturn new Text(theme.fg(\"warning\", result.content[0]?.text ?? \"Searching the web...\"), 0, 0);\n\t}\n\n\tconst details = result.details;\n\tif (!details) return new Text(theme.fg(\"muted\", result.content[0]?.text ?? \"\"), 0, 0);\n\tif (isSearchProgressDetails(details)) return new Text(theme.fg(\"muted\", result.content[0]?.text ?? \"\"), 0, 0);\n\tif (isSearchErrorDetails(details)) return new Text(theme.fg(\"error\", details.error), 0, 0);\n\tif (details.error) return new Text(theme.fg(\"error\", details.error), 0, 0);\n\n\tconst count = details.results.length;\n\tconst provider = details.entryId ? `${details.provider}/${details.entryId}` : details.provider;\n\tconst summary =\n\t\ttheme.fg(\"success\", `${count} result${count === 1 ? \"\" : \"s\"}`) +\n\t\ttheme.fg(\n\t\t\t\"muted\",\n\t\t\t` via ${provider}${details.strategy ? ` (${details.strategy})` : \"\"} in ${durationText(details.durationMs)}`,\n\t\t) +\n\t\t(details.truncated ? theme.fg(\"warning\", \" (truncated)\") : \"\");\n\n\tif (count === 0) return new Text(summary, 0, 0);\n\n\tconst attempts = attemptLabel(details.attempts);\n\tconst rows = options.expanded && attempts ? [summary, theme.fg(\"muted\", `route ${attempts}`)] : [summary];\n\tconst visibleLimit = options.expanded ? 8 : 3;\n\tfor (const item of details.results.slice(0, visibleLimit)) {\n\t\trows.push(`${theme.fg(\"accent\", shorten(item.title, 80))} ${theme.fg(\"dim\", shorten(item.url, 100))}`);\n\t\tif (item.snippet) rows.push(theme.fg(\"muted\", ` ${shorten(item.snippet, 140)}`));\n\t}\n\tif (details.results.length > visibleLimit) {\n\t\trows.push(theme.fg(\"dim\", `… ${details.results.length - visibleLimit} more sources`));\n\t}\n\treturn new Text(rows.join(\"\\n\"), 0, 0);\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { SearchDetails, SearchRequest, WebsearchConfig } from "./types.ts";
|
|
1
|
+
import type { SearchAttempt, SearchDetails, SearchRequest, WebsearchConfig } from "./types.ts";
|
|
2
2
|
export interface SearchRoutingState {
|
|
3
3
|
roundRobinCursor: number;
|
|
4
4
|
successCounts: number[];
|
|
5
5
|
}
|
|
6
6
|
export declare function createSearchRoutingState(providerCount: number): SearchRoutingState;
|
|
7
|
-
export
|
|
7
|
+
export type SearchAttemptListener = (providerLabel: string, attempts: readonly SearchAttempt[]) => void;
|
|
8
|
+
export declare function performSearch(config: WebsearchConfig, request: SearchRequest, signal?: AbortSignal, routingState?: SearchRoutingState, onAttempt?: SearchAttemptListener): Promise<SearchDetails>;
|
|
8
9
|
export declare function formatSearchText(details: SearchDetails): string;
|
|
9
10
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/websearch/websearch/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/websearch/websearch/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGX,aAAa,EACb,aAAa,EAEb,aAAa,EACb,eAAe,EACf,MAAM,YAAY,CAAC;AAyEpB,MAAM,WAAW,kBAAkB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,kBAAkB,CAElF;AA6JD,MAAM,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,aAAa,EAAE,KAAK,IAAI,CAAC;AAExG,wBAAsB,aAAa,CAClC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,YAAY,CAAC,EAAE,kBAAkB,EACjC,SAAS,CAAC,EAAE,qBAAqB,GAC/B,OAAO,CAAC,aAAa,CAAC,CAiExB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA0B/D"}
|