indusagi 0.12.32 → 0.12.34
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 +340 -0
- package/CREDITS.md +22 -0
- package/NOTICE +17 -0
- package/README.md +47 -388
- package/dist/agent.js +27512 -0
- package/dist/ai.js +19758 -0
- package/dist/capabilities.js +2663 -0
- package/dist/cli.js +11653 -0
- package/dist/connectors-saas.js +3289 -0
- package/dist/index.js +16533 -0
- package/dist/interop.js +3181 -0
- package/dist/knowledge/guides/authoring-an-agent.md +53 -0
- package/dist/knowledge/guides/choosing-tools.md +49 -0
- package/dist/knowledge/guides/model-selection.md +51 -0
- package/dist/knowledge/guides/writing-system-prompts.md +53 -0
- package/dist/knowledge/index.ts +19 -0
- package/dist/knowledge/loader.ts +200 -0
- package/dist/knowledge/manifest.json +29 -0
- package/dist/llmgateway.js +3209 -0
- package/dist/mcp.js +1732 -0
- package/dist/memory.js +0 -0
- package/dist/react-host/index.js +101 -0
- package/dist/react-host/ink.js +97 -0
- package/dist/react-host/jsx-runtime.js +95 -0
- package/dist/react-ink.js +3821 -0
- package/dist/runtime.js +4387 -0
- package/dist/shell-app.js +12222 -0
- package/dist/smithy.js +7932 -0
- package/dist/swarm.js +8717 -0
- package/dist/tracing.js +724 -0
- package/dist/tui.js +2213 -0
- package/dist/types/capabilities/backends/index.d.ts +10 -0
- package/dist/types/capabilities/backends/node-backends.d.ts +28 -0
- package/dist/types/capabilities/capabilities.test.d.ts +14 -0
- package/dist/types/capabilities/files/diff.d.ts +49 -0
- package/dist/types/capabilities/files/edit.d.ts +21 -0
- package/dist/types/capabilities/files/ls.d.ts +16 -0
- package/dist/types/capabilities/files/read.d.ts +15 -0
- package/dist/types/capabilities/files/write.d.ts +16 -0
- package/dist/types/capabilities/index.d.ts +29 -0
- package/dist/types/capabilities/kernel/backends.d.ts +119 -0
- package/dist/types/capabilities/kernel/context.d.ts +48 -0
- package/dist/types/capabilities/kernel/index.d.ts +24 -0
- package/dist/types/capabilities/kernel/output.d.ts +40 -0
- package/dist/types/capabilities/kernel/registry.d.ts +61 -0
- package/dist/types/capabilities/kernel/spec.d.ts +113 -0
- package/dist/types/capabilities/planning/todo.d.ts +62 -0
- package/dist/types/capabilities/registry.d.ts +44 -0
- package/dist/types/capabilities/search/find.d.ts +33 -0
- package/dist/types/capabilities/search/grep.d.ts +30 -0
- package/dist/types/capabilities/shell/bash.d.ts +18 -0
- package/dist/types/capabilities/shell/process.d.ts +33 -0
- package/dist/types/capabilities/web/webfetch.d.ts +25 -0
- package/dist/types/capabilities/web/websearch.d.ts +23 -0
- package/dist/types/connectors-saas/connectors-saas.test.d.ts +12 -0
- package/dist/types/connectors-saas/index.d.ts +16 -0
- package/dist/types/connectors-saas/saas/adapter/composio-backend.d.ts +60 -0
- package/dist/types/connectors-saas/saas/control/connect.d.ts +114 -0
- package/dist/types/connectors-saas/saas/control/tools.d.ts +67 -0
- package/dist/types/connectors-saas/saas/core/builder.d.ts +86 -0
- package/dist/types/connectors-saas/saas/core/cache.d.ts +53 -0
- package/dist/types/connectors-saas/saas/core/index.d.ts +14 -0
- package/dist/types/connectors-saas/saas/core/port.d.ts +157 -0
- package/dist/types/connectors-saas/saas/core/scope-planner.d.ts +74 -0
- package/dist/types/connectors-saas/saas/gateway.d.ts +133 -0
- package/dist/types/connectors-saas/saas/render/format.d.ts +54 -0
- package/dist/types/connectors-saas/saas/render/index.d.ts +19 -0
- package/dist/types/connectors-saas/saas/render/summarizers.d.ts +58 -0
- package/dist/types/facade/agent.d.ts +1 -0
- package/dist/types/facade/ai.d.ts +1 -0
- package/dist/types/facade/bot/actions/bash.d.ts +56 -0
- package/dist/types/facade/bot/actions/composio/accounts.d.ts +22 -0
- package/dist/types/facade/bot/actions/composio/client.d.ts +39 -0
- package/dist/types/facade/bot/actions/composio/connect.d.ts +19 -0
- package/dist/types/facade/bot/actions/composio/enable.d.ts +25 -0
- package/dist/types/facade/bot/actions/composio/execute.d.ts +26 -0
- package/dist/types/facade/bot/actions/composio/helpers.d.ts +16 -0
- package/dist/types/facade/bot/actions/composio/index.d.ts +9 -0
- package/dist/types/facade/bot/actions/composio/provider.d.ts +8 -0
- package/dist/types/facade/bot/actions/composio/toolkits.d.ts +22 -0
- package/dist/types/facade/bot/actions/composio/tools.d.ts +28 -0
- package/dist/types/facade/bot/actions/composio/types.d.ts +137 -0
- package/dist/types/facade/bot/actions/crew/activity-tracker.d.ts +65 -0
- package/dist/types/facade/bot/actions/crew/cleanup.d.ts +50 -0
- package/dist/types/facade/bot/actions/crew/fs-lock.d.ts +11 -0
- package/dist/types/facade/bot/actions/crew/index.d.ts +11 -0
- package/dist/types/facade/bot/actions/crew/mailbox.d.ts +20 -0
- package/dist/types/facade/bot/actions/crew/model-policy.d.ts +22 -0
- package/dist/types/facade/bot/actions/crew/names.d.ts +27 -0
- package/dist/types/facade/bot/actions/crew/protocol.d.ts +74 -0
- package/dist/types/facade/bot/actions/crew/task-store.d.ts +88 -0
- package/dist/types/facade/bot/actions/crew/team-attach-claim.d.ts +35 -0
- package/dist/types/facade/bot/actions/crew/team-config.d.ts +54 -0
- package/dist/types/facade/bot/actions/crew/worktree.d.ts +39 -0
- package/dist/types/facade/bot/actions/edit-diff.d.ts +66 -0
- package/dist/types/facade/bot/actions/edit.d.ts +41 -0
- package/dist/types/facade/bot/actions/find.d.ts +25 -0
- package/dist/types/facade/bot/actions/grep.d.ts +43 -0
- package/dist/types/facade/bot/actions/index.d.ts +300 -0
- package/dist/types/facade/bot/actions/kit/hook-runner.d.ts +12 -0
- package/dist/types/facade/bot/actions/kit/image-resize.d.ts +19 -0
- package/dist/types/facade/bot/actions/kit/mime.d.ts +1 -0
- package/dist/types/facade/bot/actions/kit/shell.d.ts +12 -0
- package/dist/types/facade/bot/actions/ls.d.ts +41 -0
- package/dist/types/facade/bot/actions/path-utils.d.ts +8 -0
- package/dist/types/facade/bot/actions/process-controller.d.ts +14 -0
- package/dist/types/facade/bot/actions/process-manager.d.ts +59 -0
- package/dist/types/facade/bot/actions/process-types.d.ts +73 -0
- package/dist/types/facade/bot/actions/process.d.ts +37 -0
- package/dist/types/facade/bot/actions/read.d.ts +36 -0
- package/dist/types/facade/bot/actions/registry.d.ts +20 -0
- package/dist/types/facade/bot/actions/todo-store.d.ts +76 -0
- package/dist/types/facade/bot/actions/todo-types.d.ts +72 -0
- package/dist/types/facade/bot/actions/todo.d.ts +76 -0
- package/dist/types/facade/bot/actions/truncate.d.ts +78 -0
- package/dist/types/facade/bot/actions/webfetch.d.ts +35 -0
- package/dist/types/facade/bot/actions/websearch.d.ts +34 -0
- package/dist/types/facade/bot/actions/write.d.ts +30 -0
- package/dist/types/facade/bot/agent-loop.d.ts +20 -0
- package/dist/types/facade/bot/agent.d.ts +132 -0
- package/dist/types/facade/bot/error-handler.d.ts +7 -0
- package/dist/types/facade/bot/event-bus.d.ts +8 -0
- package/dist/types/facade/bot/index.d.ts +7 -0
- package/dist/types/facade/bot/messages.d.ts +83 -0
- package/dist/types/facade/bot/proxy.d.ts +70 -0
- package/dist/types/facade/bot/session-manager.d.ts +409 -0
- package/dist/types/facade/bot/state-manager.d.ts +21 -0
- package/dist/types/facade/bot/telemetry.d.ts +6 -0
- package/dist/types/facade/bot/types.d.ts +207 -0
- package/dist/types/facade/mcp-core/client-pool.d.ts +105 -0
- package/dist/types/facade/mcp-core/client.d.ts +157 -0
- package/dist/types/facade/mcp-core/config.d.ts +60 -0
- package/dist/types/facade/mcp-core/errors.d.ts +103 -0
- package/dist/types/facade/mcp-core/index.d.ts +55 -0
- package/dist/types/facade/mcp-core/schema-converter.d.ts +67 -0
- package/dist/types/facade/mcp-core/server.d.ts +110 -0
- package/dist/types/facade/mcp-core/tool-factory.d.ts +62 -0
- package/dist/types/facade/mcp-core/types.d.ts +288 -0
- package/dist/types/facade/mcp.d.ts +1 -0
- package/dist/types/facade/memory.d.ts +1 -0
- package/dist/types/facade/ml/adapters/amazon-bedrock.d.ts +32 -0
- package/dist/types/facade/ml/adapters/anthropic.d.ts +61 -0
- package/dist/types/facade/ml/adapters/azure-openai-responses.d.ts +14 -0
- package/dist/types/facade/ml/adapters/google-shared.d.ts +99 -0
- package/dist/types/facade/ml/adapters/google-vertex.d.ts +14 -0
- package/dist/types/facade/ml/adapters/google.d.ts +15 -0
- package/dist/types/facade/ml/adapters/kimi.d.ts +21 -0
- package/dist/types/facade/ml/adapters/mock.d.ts +9 -0
- package/dist/types/facade/ml/adapters/nvidia.d.ts +12 -0
- package/dist/types/facade/ml/adapters/openai-codex-responses.d.ts +8 -0
- package/dist/types/facade/ml/adapters/openai-completions.d.ts +24 -0
- package/dist/types/facade/ml/adapters/openai-responses-shared.d.ts +25 -0
- package/dist/types/facade/ml/adapters/openai-responses.d.ts +12 -0
- package/dist/types/facade/ml/adapters/openai-scaffold.d.ts +3 -0
- package/dist/types/facade/ml/adapters/register-builtins.d.ts +2 -0
- package/dist/types/facade/ml/adapters/simple-options.d.ts +26 -0
- package/dist/types/facade/ml/adapters/transform-messages.d.ts +23 -0
- package/dist/types/facade/ml/api-registry.d.ts +49 -0
- package/dist/types/facade/ml/cli.d.ts +2 -0
- package/dist/types/facade/ml/env-api-keys.d.ts +19 -0
- package/dist/types/facade/ml/index.d.ts +27 -0
- package/dist/types/facade/ml/kit/auth/anthropic.d.ts +17 -0
- package/dist/types/facade/ml/kit/auth/github-copilot.d.ts +22 -0
- package/dist/types/facade/ml/kit/auth/index.d.ts +50 -0
- package/dist/types/facade/ml/kit/auth/kimi.d.ts +23 -0
- package/dist/types/facade/ml/kit/auth/oauth-page.d.ts +2 -0
- package/dist/types/facade/ml/kit/auth/openai-codex.d.ts +36 -0
- package/dist/types/facade/ml/kit/auth/pkce.d.ts +12 -0
- package/dist/types/facade/ml/kit/auth/types.d.ts +67 -0
- package/dist/types/facade/ml/kit/base-stream-handler.d.ts +30 -0
- package/dist/types/facade/ml/kit/event-stream.d.ts +63 -0
- package/dist/types/facade/ml/kit/index.d.ts +14 -0
- package/dist/types/facade/ml/kit/json-parse.d.ts +23 -0
- package/dist/types/facade/ml/kit/message-transform.d.ts +32 -0
- package/dist/types/facade/ml/kit/output-factory.d.ts +8 -0
- package/dist/types/facade/ml/kit/overflow.d.ts +9 -0
- package/dist/types/facade/ml/kit/provider-adapter.d.ts +56 -0
- package/dist/types/facade/ml/kit/provider-client-builder.d.ts +36 -0
- package/dist/types/facade/ml/kit/provider-consolidation.d.ts +3 -0
- package/dist/types/facade/ml/kit/provider-constants.d.ts +34 -0
- package/dist/types/facade/ml/kit/provider-errors.d.ts +52 -0
- package/dist/types/facade/ml/kit/sanitize-unicode.d.ts +2 -0
- package/dist/types/facade/ml/kit/stream-event-helper.d.ts +38 -0
- package/dist/types/facade/ml/kit/stream-handler-types.d.ts +46 -0
- package/dist/types/facade/ml/kit/streaming-state-manager.d.ts +42 -0
- package/dist/types/facade/ml/kit/tool-converter.d.ts +49 -0
- package/dist/types/facade/ml/kit/typebox-helpers.d.ts +24 -0
- package/dist/types/facade/ml/kit/validation.d.ts +26 -0
- package/dist/types/facade/ml/models.d.ts +41 -0
- package/dist/types/facade/ml/models.generated.d.ts +12261 -0
- package/dist/types/facade/ml/stream.d.ts +27 -0
- package/dist/types/facade/ml/types.d.ts +269 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/interop/index.d.ts +12 -0
- package/dist/types/interop/interop.test.d.ts +19 -0
- package/dist/types/interop/protocol-bridge/bridge.d.ts +52 -0
- package/dist/types/interop/protocol-bridge/contract.d.ts +249 -0
- package/dist/types/interop/protocol-bridge/endpoint.d.ts +124 -0
- package/dist/types/interop/protocol-bridge/fleet.d.ts +92 -0
- package/dist/types/interop/protocol-bridge/host.d.ts +61 -0
- package/dist/types/interop/protocol-bridge/index.d.ts +16 -0
- package/dist/types/interop/protocol-bridge/schema.d.ts +29 -0
- package/dist/types/llmgateway/catalog/cards.d.ts +18 -0
- package/dist/types/llmgateway/catalog/cost.d.ts +15 -0
- package/dist/types/llmgateway/catalog/index.d.ts +7 -0
- package/dist/types/llmgateway/catalog/query.d.ts +40 -0
- package/dist/types/llmgateway/connectors/anthropic.d.ts +35 -0
- package/dist/types/llmgateway/connectors/azure-openai.d.ts +33 -0
- package/dist/types/llmgateway/connectors/bedrock.d.ts +113 -0
- package/dist/types/llmgateway/connectors/google-vertex.d.ts +38 -0
- package/dist/types/llmgateway/connectors/google.d.ts +40 -0
- package/dist/types/llmgateway/connectors/index.d.ts +26 -0
- package/dist/types/llmgateway/connectors/kimi.d.ts +28 -0
- package/dist/types/llmgateway/connectors/mock.d.ts +37 -0
- package/dist/types/llmgateway/connectors/nvidia.d.ts +27 -0
- package/dist/types/llmgateway/connectors/ollama.d.ts +45 -0
- package/dist/types/llmgateway/connectors/openai-chat.d.ts +25 -0
- package/dist/types/llmgateway/connectors/openai-responses.d.ts +49 -0
- package/dist/types/llmgateway/contract/connector.d.ts +32 -0
- package/dist/types/llmgateway/contract/conversation.d.ts +86 -0
- package/dist/types/llmgateway/contract/emission.d.ts +55 -0
- package/dist/types/llmgateway/contract/errors.d.ts +27 -0
- package/dist/types/llmgateway/contract/index.d.ts +13 -0
- package/dist/types/llmgateway/contract/model-card.d.ts +42 -0
- package/dist/types/llmgateway/contract/options.d.ts +31 -0
- package/dist/types/llmgateway/contract/reply.d.ts +33 -0
- package/dist/types/llmgateway/conversion/index.d.ts +10 -0
- package/dist/types/llmgateway/conversion/mappers.d.ts +65 -0
- package/dist/types/llmgateway/conversion/openai-compatible.d.ts +46 -0
- package/dist/types/llmgateway/conversion/reduce.d.ts +20 -0
- package/dist/types/llmgateway/credentials/oauth.d.ts +73 -0
- package/dist/types/llmgateway/credentials/pkce.d.ts +52 -0
- package/dist/types/llmgateway/credentials/secrets.d.ts +74 -0
- package/dist/types/llmgateway/gateway.d.ts +34 -0
- package/dist/types/llmgateway/gateway.test.d.ts +14 -0
- package/dist/types/llmgateway/index.d.ts +11 -0
- package/dist/types/llmgateway/streaming/channel.d.ts +24 -0
- package/dist/types/llmgateway/streaming/index.d.ts +10 -0
- package/dist/types/llmgateway/streaming/ndjson.d.ts +17 -0
- package/dist/types/llmgateway/streaming/sse.d.ts +31 -0
- package/dist/types/react-host/index.d.ts +9 -0
- package/dist/types/react-host/ink.d.ts +5 -0
- package/dist/types/react-host/jsx-runtime.d.ts +4 -0
- package/dist/types/react-host/loader.d.ts +3 -0
- package/dist/types/react-ink/components/ChangelogBlock.d.ts +8 -0
- package/dist/types/react-ink/components/DisplayBlockView.d.ts +8 -0
- package/dist/types/react-ink/components/Footer.d.ts +11 -0
- package/dist/types/react-ink/components/MessageList.d.ts +14 -0
- package/dist/types/react-ink/components/MessageRow.d.ts +13 -0
- package/dist/types/react-ink/components/StatusLine.d.ts +9 -0
- package/dist/types/react-ink/components/TaskPanel.d.ts +11 -0
- package/dist/types/react-ink/components/ToolEventBlock.d.ts +24 -0
- package/dist/types/react-ink/components/dialogs/DialogFrame.d.ts +8 -0
- package/dist/types/react-ink/components/dialogs/LoginDialog.d.ts +14 -0
- package/dist/types/react-ink/components/dialogs/ModelDialog.d.ts +9 -0
- package/dist/types/react-ink/components/dialogs/OAuthDialog.d.ts +9 -0
- package/dist/types/react-ink/components/dialogs/ScopedModelsDialog.d.ts +9 -0
- package/dist/types/react-ink/components/dialogs/SelectableDialog.d.ts +22 -0
- package/dist/types/react-ink/components/dialogs/SessionDialog.d.ts +13 -0
- package/dist/types/react-ink/components/dialogs/SettingsDialog.d.ts +14 -0
- package/dist/types/react-ink/components/dialogs/StartupSessionPicker.d.ts +9 -0
- package/dist/types/react-ink/components/dialogs/ThemeDialog.d.ts +26 -0
- package/dist/types/react-ink/components/dialogs/TreeDialog.d.ts +8 -0
- package/dist/types/react-ink/components/dialogs/UserMessageDialog.d.ts +8 -0
- package/dist/types/react-ink/components/messages/AssistantMessage.d.ts +12 -0
- package/dist/types/react-ink/components/messages/BashMessage.d.ts +8 -0
- package/dist/types/react-ink/components/messages/BranchSummaryMessage.d.ts +8 -0
- package/dist/types/react-ink/components/messages/CompactionMessage.d.ts +8 -0
- package/dist/types/react-ink/components/messages/CustomMessage.d.ts +9 -0
- package/dist/types/react-ink/components/messages/SkillInvocationMessage.d.ts +7 -0
- package/dist/types/react-ink/components/messages/ToolCallMessage.d.ts +8 -0
- package/dist/types/react-ink/components/messages/ToolResultBlock.d.ts +12 -0
- package/dist/types/react-ink/components/messages/UserMessage.d.ts +9 -0
- package/dist/types/react-ink/diff/Diff.d.ts +22 -0
- package/dist/types/react-ink/diff/diff.test.d.ts +1 -0
- package/dist/types/react-ink/diff/structured.d.ts +41 -0
- package/dist/types/react-ink/diff/word-diff.d.ts +27 -0
- package/dist/types/react-ink/index.d.ts +42 -0
- package/dist/types/react-ink/markdown/Markdown.d.ts +23 -0
- package/dist/types/react-ink/markdown/MarkdownTable.d.ts +19 -0
- package/dist/types/react-ink/markdown/StreamingMarkdown.d.ts +34 -0
- package/dist/types/react-ink/markdown/format-token.d.ts +39 -0
- package/dist/types/react-ink/markdown/highlight.d.ts +31 -0
- package/dist/types/react-ink/theme-adapter.d.ts +66 -0
- package/dist/types/react-ink/types.d.ts +133 -0
- package/dist/types/react-ink/utils/message-groups.d.ts +25 -0
- package/dist/types/react-ink/utils/selection-dialog.d.ts +2 -0
- package/dist/types/react-ink/utils/session-browser.d.ts +27 -0
- package/dist/types/react-ink/utils/tool-display.d.ts +37 -0
- package/dist/types/runtime/cadence/cadence.test.d.ts +6 -0
- package/dist/types/runtime/cadence/fold.d.ts +48 -0
- package/dist/types/runtime/cadence/index.d.ts +12 -0
- package/dist/types/runtime/cadence/reducer.d.ts +44 -0
- package/dist/types/runtime/conductor/agent.d.ts +71 -0
- package/dist/types/runtime/conductor/index.d.ts +11 -0
- package/dist/types/runtime/contract/config.d.ts +44 -0
- package/dist/types/runtime/contract/effect.d.ts +41 -0
- package/dist/types/runtime/contract/errors.d.ts +22 -0
- package/dist/types/runtime/contract/events.d.ts +63 -0
- package/dist/types/runtime/contract/index.d.ts +18 -0
- package/dist/types/runtime/contract/run-state.d.ts +57 -0
- package/dist/types/runtime/contract/session.d.ts +42 -0
- package/dist/types/runtime/contract/signal.d.ts +49 -0
- package/dist/types/runtime/contract/tools.d.ts +45 -0
- package/dist/types/runtime/dispatch/index.d.ts +9 -0
- package/dist/types/runtime/dispatch/scheduler.d.ts +53 -0
- package/dist/types/runtime/index.d.ts +22 -0
- package/dist/types/runtime/ledger/accumulator.d.ts +44 -0
- package/dist/types/runtime/ledger/bus.d.ts +50 -0
- package/dist/types/runtime/ledger/index.d.ts +11 -0
- package/dist/types/runtime/memory/compactor.d.ts +56 -0
- package/dist/types/runtime/memory/estimate.d.ts +21 -0
- package/dist/types/runtime/memory/index.d.ts +8 -0
- package/dist/types/runtime/runtime.test.d.ts +15 -0
- package/dist/types/runtime/store/dag.d.ts +72 -0
- package/dist/types/runtime/store/hash.d.ts +18 -0
- package/dist/types/runtime/store/index.d.ts +12 -0
- package/dist/types/runtime/store/persist.d.ts +49 -0
- package/dist/types/runtime/turn/driver.d.ts +32 -0
- package/dist/types/runtime/turn/index.d.ts +8 -0
- package/dist/types/runtime/wire/index.d.ts +10 -0
- package/dist/types/runtime/wire/projectors.d.ts +53 -0
- package/dist/types/shell-app/auth-cli/index.d.ts +9 -0
- package/dist/types/shell-app/auth-cli/oauth-cli.d.ts +73 -0
- package/dist/types/shell-app/boot/context.d.ts +108 -0
- package/dist/types/shell-app/boot/index.d.ts +13 -0
- package/dist/types/shell-app/boot/pipeline.d.ts +66 -0
- package/dist/types/shell-app/boot/stages.d.ts +77 -0
- package/dist/types/shell-app/cli.d.ts +75 -0
- package/dist/types/shell-app/config/index.d.ts +11 -0
- package/dist/types/shell-app/config/locator.d.ts +85 -0
- package/dist/types/shell-app/config/settings.d.ts +91 -0
- package/dist/types/shell-app/index.d.ts +26 -0
- package/dist/types/shell-app/invocation/flags.d.ts +89 -0
- package/dist/types/shell-app/invocation/parse.d.ts +89 -0
- package/dist/types/shell-app/locate/brand.d.ts +71 -0
- package/dist/types/shell-app/locate/index.d.ts +12 -0
- package/dist/types/shell-app/locate/locator.d.ts +122 -0
- package/dist/types/shell-app/runners/contract.d.ts +116 -0
- package/dist/types/shell-app/runners/index.d.ts +15 -0
- package/dist/types/shell-app/runners/one-shot.d.ts +21 -0
- package/dist/types/shell-app/runners/registry.d.ts +34 -0
- package/dist/types/shell-app/runners/repl.d.ts +51 -0
- package/dist/types/shell-app/runners/wire.d.ts +34 -0
- package/dist/types/shell-app/shell-app.test.d.ts +14 -0
- package/dist/types/shell-app/upgrade/index.d.ts +9 -0
- package/dist/types/shell-app/upgrade/upgrades.d.ts +62 -0
- package/dist/types/smithy/config/flag-reader.d.ts +128 -0
- package/dist/types/smithy/config/index.d.ts +9 -0
- package/dist/types/smithy/forge.d.ts +135 -0
- package/dist/types/smithy/index.d.ts +36 -0
- package/dist/types/smithy/knowledge/index.d.ts +10 -0
- package/dist/types/smithy/knowledge/loader.d.ts +64 -0
- package/dist/types/smithy/persona/blueprint.d.ts +75 -0
- package/dist/types/smithy/persona/define-agent.d.ts +51 -0
- package/dist/types/smithy/persona/index.d.ts +14 -0
- package/dist/types/smithy/persona/profiles.d.ts +44 -0
- package/dist/types/smithy/runtime/index.d.ts +9 -0
- package/dist/types/smithy/runtime/tool-ledger.d.ts +130 -0
- package/dist/types/smithy/smithy.test.d.ts +20 -0
- package/dist/types/smithy/ui/index.d.ts +11 -0
- package/dist/types/smithy/ui/transcript.d.ts +183 -0
- package/dist/types/swarm/coordinator.d.ts +192 -0
- package/dist/types/swarm/index.d.ts +33 -0
- package/dist/types/swarm/isolation/index.d.ts +14 -0
- package/dist/types/swarm/isolation/runner.d.ts +61 -0
- package/dist/types/swarm/isolation/worktree.d.ts +142 -0
- package/dist/types/swarm/kernel/faults.d.ts +52 -0
- package/dist/types/swarm/kernel/ids.d.ts +25 -0
- package/dist/types/swarm/kernel/index.d.ts +26 -0
- package/dist/types/swarm/kernel/json-cell.d.ts +113 -0
- package/dist/types/swarm/kernel/jsonl-log.d.ts +81 -0
- package/dist/types/swarm/postbox/channel.d.ts +88 -0
- package/dist/types/swarm/postbox/codecs.d.ts +253 -0
- package/dist/types/swarm/postbox/index.d.ts +16 -0
- package/dist/types/swarm/roster/index.d.ts +16 -0
- package/dist/types/swarm/roster/manifest.d.ts +185 -0
- package/dist/types/swarm/swarm.test.d.ts +24 -0
- package/dist/types/swarm/telemetry/activity.d.ts +143 -0
- package/dist/types/swarm/workboard/board.d.ts +174 -0
- package/dist/types/swarm/workboard/dep-graph.d.ts +77 -0
- package/dist/types/swarm/workboard/index.d.ts +12 -0
- package/dist/types/tracing/adapter/index.d.ts +12 -0
- package/dist/types/tracing/adapter/runtime-trace.d.ts +54 -0
- package/dist/types/tracing/channel/index.d.ts +9 -0
- package/dist/types/tracing/channel/signal.d.ts +93 -0
- package/dist/types/tracing/index.d.ts +25 -0
- package/dist/types/tracing/recorder/index.d.ts +12 -0
- package/dist/types/tracing/recorder/recorder.d.ts +75 -0
- package/dist/types/tracing/recorder/sampling.d.ts +55 -0
- package/dist/types/tracing/redaction/index.d.ts +8 -0
- package/dist/types/tracing/redaction/secret-scrubber.d.ts +95 -0
- package/dist/types/tracing/registry/hub.d.ts +57 -0
- package/dist/types/tracing/registry/index.d.ts +7 -0
- package/dist/types/tracing/signal/handle.d.ts +73 -0
- package/dist/types/tracing/signal/index.d.ts +12 -0
- package/dist/types/tracing/signal/segment.d.ts +124 -0
- package/dist/types/tracing/sinks/base.d.ts +51 -0
- package/dist/types/tracing/sinks/console.d.ts +44 -0
- package/dist/types/tracing/sinks/file.d.ts +47 -0
- package/dist/types/tracing/sinks/index.d.ts +16 -0
- package/dist/types/tracing/sinks/stream.d.ts +46 -0
- package/dist/types/tracing/tracing.test.d.ts +7 -0
- package/dist/types/ui/autocomplete.d.ts +59 -0
- package/dist/types/ui/contracts.d.ts +38 -0
- package/dist/types/ui/editor-component.d.ts +100 -0
- package/dist/types/ui/fuzzy.d.ts +29 -0
- package/dist/types/ui/index.d.ts +8 -0
- package/dist/types/ui/keybindings.d.ts +62 -0
- package/dist/types/ui/keys.d.ts +171 -0
- package/dist/types/ui/theme-types.d.ts +36 -0
- package/dist/types/ui/utils.d.ts +101 -0
- package/dist/types/ui-bridge/InteractiveApp.d.ts +38 -0
- package/dist/types/ui-bridge/adapter.d.ts +90 -0
- package/dist/types/ui-bridge/index.d.ts +37 -0
- package/package.json +120 -107
- package/LICENSE +0 -8
- package/LICENSE-THIRD-PARTY.txt +0 -30
- package/local-dist-new/IndusForge/examples/research-agent.d.ts +0 -3
- package/local-dist-new/IndusForge/examples/research-agent.d.ts.map +0 -1
- package/local-dist-new/IndusForge/examples/research-agent.js +0 -18
- package/local-dist-new/IndusForge/examples/research-agent.js.map +0 -1
- package/local-dist-new/IndusForge/examples/review-agent.d.ts +0 -3
- package/local-dist-new/IndusForge/examples/review-agent.d.ts.map +0 -1
- package/local-dist-new/IndusForge/examples/review-agent.js +0 -18
- package/local-dist-new/IndusForge/examples/review-agent.js.map +0 -1
- package/local-dist-new/IndusForge/examples/terminal-builder-agent.d.ts +0 -3
- package/local-dist-new/IndusForge/examples/terminal-builder-agent.d.ts.map +0 -1
- package/local-dist-new/IndusForge/examples/terminal-builder-agent.js +0 -18
- package/local-dist-new/IndusForge/examples/terminal-builder-agent.js.map +0 -1
- package/local-dist-new/IndusForge/terminal-chat.d.ts +0 -2
- package/local-dist-new/IndusForge/terminal-chat.d.ts.map +0 -1
- package/local-dist-new/IndusForge/terminal-chat.js +0 -557
- package/local-dist-new/IndusForge/terminal-chat.js.map +0 -1
- package/local-dist-new/agent.d.ts +0 -6
- package/local-dist-new/agent.d.ts.map +0 -1
- package/local-dist-new/agent.js +0 -6
- package/local-dist-new/agent.js.map +0 -1
- package/local-dist-new/ai.d.ts +0 -6
- package/local-dist-new/ai.d.ts.map +0 -1
- package/local-dist-new/ai.js +0 -6
- package/local-dist-new/ai.js.map +0 -1
- package/local-dist-new/bot/actions/bash.d.ts +0 -56
- package/local-dist-new/bot/actions/bash.d.ts.map +0 -1
- package/local-dist-new/bot/actions/bash.js +0 -275
- package/local-dist-new/bot/actions/bash.js.map +0 -1
- package/local-dist-new/bot/actions/composio/accounts.d.ts +0 -23
- package/local-dist-new/bot/actions/composio/accounts.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/accounts.js +0 -40
- package/local-dist-new/bot/actions/composio/accounts.js.map +0 -1
- package/local-dist-new/bot/actions/composio/client.d.ts +0 -40
- package/local-dist-new/bot/actions/composio/client.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/client.js +0 -361
- package/local-dist-new/bot/actions/composio/client.js.map +0 -1
- package/local-dist-new/bot/actions/composio/connect.d.ts +0 -20
- package/local-dist-new/bot/actions/composio/connect.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/connect.js +0 -41
- package/local-dist-new/bot/actions/composio/connect.js.map +0 -1
- package/local-dist-new/bot/actions/composio/enable.d.ts +0 -26
- package/local-dist-new/bot/actions/composio/enable.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/enable.js +0 -66
- package/local-dist-new/bot/actions/composio/enable.js.map +0 -1
- package/local-dist-new/bot/actions/composio/execute.d.ts +0 -27
- package/local-dist-new/bot/actions/composio/execute.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/execute.js +0 -46
- package/local-dist-new/bot/actions/composio/execute.js.map +0 -1
- package/local-dist-new/bot/actions/composio/helpers.d.ts +0 -17
- package/local-dist-new/bot/actions/composio/helpers.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/helpers.js +0 -533
- package/local-dist-new/bot/actions/composio/helpers.js.map +0 -1
- package/local-dist-new/bot/actions/composio/index.d.ts +0 -10
- package/local-dist-new/bot/actions/composio/index.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/index.js +0 -9
- package/local-dist-new/bot/actions/composio/index.js.map +0 -1
- package/local-dist-new/bot/actions/composio/provider.d.ts +0 -9
- package/local-dist-new/bot/actions/composio/provider.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/provider.js +0 -54
- package/local-dist-new/bot/actions/composio/provider.js.map +0 -1
- package/local-dist-new/bot/actions/composio/toolkits.d.ts +0 -23
- package/local-dist-new/bot/actions/composio/toolkits.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/toolkits.js +0 -40
- package/local-dist-new/bot/actions/composio/toolkits.js.map +0 -1
- package/local-dist-new/bot/actions/composio/tools.d.ts +0 -29
- package/local-dist-new/bot/actions/composio/tools.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/tools.js +0 -72
- package/local-dist-new/bot/actions/composio/tools.js.map +0 -1
- package/local-dist-new/bot/actions/composio/types.d.ts +0 -138
- package/local-dist-new/bot/actions/composio/types.d.ts.map +0 -1
- package/local-dist-new/bot/actions/composio/types.js +0 -2
- package/local-dist-new/bot/actions/composio/types.js.map +0 -1
- package/local-dist-new/bot/actions/crew/activity-tracker.d.ts +0 -66
- package/local-dist-new/bot/actions/crew/activity-tracker.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/activity-tracker.js +0 -480
- package/local-dist-new/bot/actions/crew/activity-tracker.js.map +0 -1
- package/local-dist-new/bot/actions/crew/cleanup.d.ts +0 -51
- package/local-dist-new/bot/actions/crew/cleanup.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/cleanup.js +0 -219
- package/local-dist-new/bot/actions/crew/cleanup.js.map +0 -1
- package/local-dist-new/bot/actions/crew/fs-lock.d.ts +0 -12
- package/local-dist-new/bot/actions/crew/fs-lock.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/fs-lock.js +0 -74
- package/local-dist-new/bot/actions/crew/fs-lock.js.map +0 -1
- package/local-dist-new/bot/actions/crew/index.d.ts +0 -12
- package/local-dist-new/bot/actions/crew/index.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/index.js +0 -12
- package/local-dist-new/bot/actions/crew/index.js.map +0 -1
- package/local-dist-new/bot/actions/crew/mailbox.d.ts +0 -21
- package/local-dist-new/bot/actions/crew/mailbox.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/mailbox.js +0 -106
- package/local-dist-new/bot/actions/crew/mailbox.js.map +0 -1
- package/local-dist-new/bot/actions/crew/model-policy.d.ts +0 -23
- package/local-dist-new/bot/actions/crew/model-policy.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/model-policy.js +0 -113
- package/local-dist-new/bot/actions/crew/model-policy.js.map +0 -1
- package/local-dist-new/bot/actions/crew/names.d.ts +0 -28
- package/local-dist-new/bot/actions/crew/names.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/names.js +0 -109
- package/local-dist-new/bot/actions/crew/names.js.map +0 -1
- package/local-dist-new/bot/actions/crew/protocol.d.ts +0 -75
- package/local-dist-new/bot/actions/crew/protocol.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/protocol.js +0 -205
- package/local-dist-new/bot/actions/crew/protocol.js.map +0 -1
- package/local-dist-new/bot/actions/crew/task-store.d.ts +0 -89
- package/local-dist-new/bot/actions/crew/task-store.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/task-store.js +0 -445
- package/local-dist-new/bot/actions/crew/task-store.js.map +0 -1
- package/local-dist-new/bot/actions/crew/team-attach-claim.d.ts +0 -36
- package/local-dist-new/bot/actions/crew/team-attach-claim.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/team-attach-claim.js +0 -144
- package/local-dist-new/bot/actions/crew/team-attach-claim.js.map +0 -1
- package/local-dist-new/bot/actions/crew/team-config.d.ts +0 -55
- package/local-dist-new/bot/actions/crew/team-config.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/team-config.js +0 -252
- package/local-dist-new/bot/actions/crew/team-config.js.map +0 -1
- package/local-dist-new/bot/actions/crew/worktree.d.ts +0 -40
- package/local-dist-new/bot/actions/crew/worktree.d.ts.map +0 -1
- package/local-dist-new/bot/actions/crew/worktree.js +0 -213
- package/local-dist-new/bot/actions/crew/worktree.js.map +0 -1
- package/local-dist-new/bot/actions/edit-diff.d.ts +0 -63
- package/local-dist-new/bot/actions/edit-diff.d.ts.map +0 -1
- package/local-dist-new/bot/actions/edit-diff.js +0 -255
- package/local-dist-new/bot/actions/edit-diff.js.map +0 -1
- package/local-dist-new/bot/actions/edit.d.ts +0 -42
- package/local-dist-new/bot/actions/edit.d.ts.map +0 -1
- package/local-dist-new/bot/actions/edit.js +0 -176
- package/local-dist-new/bot/actions/edit.js.map +0 -1
- package/local-dist-new/bot/actions/find.d.ts +0 -26
- package/local-dist-new/bot/actions/find.d.ts.map +0 -1
- package/local-dist-new/bot/actions/find.js +0 -170
- package/local-dist-new/bot/actions/find.js.map +0 -1
- package/local-dist-new/bot/actions/grep.d.ts +0 -43
- package/local-dist-new/bot/actions/grep.d.ts.map +0 -1
- package/local-dist-new/bot/actions/grep.js +0 -218
- package/local-dist-new/bot/actions/grep.js.map +0 -1
- package/local-dist-new/bot/actions/index.d.ts +0 -301
- package/local-dist-new/bot/actions/index.d.ts.map +0 -1
- package/local-dist-new/bot/actions/index.js +0 -255
- package/local-dist-new/bot/actions/index.js.map +0 -1
- package/local-dist-new/bot/actions/kit/hook-runner.d.ts +0 -13
- package/local-dist-new/bot/actions/kit/hook-runner.d.ts.map +0 -1
- package/local-dist-new/bot/actions/kit/hook-runner.js +0 -33
- package/local-dist-new/bot/actions/kit/hook-runner.js.map +0 -1
- package/local-dist-new/bot/actions/kit/image-resize.d.ts +0 -20
- package/local-dist-new/bot/actions/kit/image-resize.d.ts.map +0 -1
- package/local-dist-new/bot/actions/kit/image-resize.js +0 -93
- package/local-dist-new/bot/actions/kit/image-resize.js.map +0 -1
- package/local-dist-new/bot/actions/kit/mime.d.ts +0 -2
- package/local-dist-new/bot/actions/kit/mime.d.ts.map +0 -1
- package/local-dist-new/bot/actions/kit/mime.js +0 -65
- package/local-dist-new/bot/actions/kit/mime.js.map +0 -1
- package/local-dist-new/bot/actions/kit/shell.d.ts +0 -13
- package/local-dist-new/bot/actions/kit/shell.d.ts.map +0 -1
- package/local-dist-new/bot/actions/kit/shell.js +0 -103
- package/local-dist-new/bot/actions/kit/shell.js.map +0 -1
- package/local-dist-new/bot/actions/ls.d.ts +0 -41
- package/local-dist-new/bot/actions/ls.d.ts.map +0 -1
- package/local-dist-new/bot/actions/ls.js +0 -174
- package/local-dist-new/bot/actions/ls.js.map +0 -1
- package/local-dist-new/bot/actions/path-utils.d.ts +0 -8
- package/local-dist-new/bot/actions/path-utils.d.ts.map +0 -1
- package/local-dist-new/bot/actions/path-utils.js +0 -75
- package/local-dist-new/bot/actions/path-utils.js.map +0 -1
- package/local-dist-new/bot/actions/process-controller.d.ts +0 -15
- package/local-dist-new/bot/actions/process-controller.d.ts.map +0 -1
- package/local-dist-new/bot/actions/process-controller.js +0 -39
- package/local-dist-new/bot/actions/process-controller.js.map +0 -1
- package/local-dist-new/bot/actions/process-manager.d.ts +0 -60
- package/local-dist-new/bot/actions/process-manager.d.ts.map +0 -1
- package/local-dist-new/bot/actions/process-manager.js +0 -485
- package/local-dist-new/bot/actions/process-manager.js.map +0 -1
- package/local-dist-new/bot/actions/process-types.d.ts +0 -74
- package/local-dist-new/bot/actions/process-types.d.ts.map +0 -1
- package/local-dist-new/bot/actions/process-types.js +0 -7
- package/local-dist-new/bot/actions/process-types.js.map +0 -1
- package/local-dist-new/bot/actions/process.d.ts +0 -38
- package/local-dist-new/bot/actions/process.d.ts.map +0 -1
- package/local-dist-new/bot/actions/process.js +0 -360
- package/local-dist-new/bot/actions/process.js.map +0 -1
- package/local-dist-new/bot/actions/read.d.ts +0 -37
- package/local-dist-new/bot/actions/read.d.ts.map +0 -1
- package/local-dist-new/bot/actions/read.js +0 -190
- package/local-dist-new/bot/actions/read.js.map +0 -1
- package/local-dist-new/bot/actions/registry.d.ts +0 -21
- package/local-dist-new/bot/actions/registry.d.ts.map +0 -1
- package/local-dist-new/bot/actions/registry.js +0 -23
- package/local-dist-new/bot/actions/registry.js.map +0 -1
- package/local-dist-new/bot/actions/todo-store.d.ts +0 -77
- package/local-dist-new/bot/actions/todo-store.d.ts.map +0 -1
- package/local-dist-new/bot/actions/todo-store.js +0 -137
- package/local-dist-new/bot/actions/todo-store.js.map +0 -1
- package/local-dist-new/bot/actions/todo-types.d.ts +0 -73
- package/local-dist-new/bot/actions/todo-types.d.ts.map +0 -1
- package/local-dist-new/bot/actions/todo-types.js +0 -8
- package/local-dist-new/bot/actions/todo-types.js.map +0 -1
- package/local-dist-new/bot/actions/todo.d.ts +0 -77
- package/local-dist-new/bot/actions/todo.d.ts.map +0 -1
- package/local-dist-new/bot/actions/todo.js +0 -122
- package/local-dist-new/bot/actions/todo.js.map +0 -1
- package/local-dist-new/bot/actions/truncate.d.ts +0 -73
- package/local-dist-new/bot/actions/truncate.d.ts.map +0 -1
- package/local-dist-new/bot/actions/truncate.js +0 -221
- package/local-dist-new/bot/actions/truncate.js.map +0 -1
- package/local-dist-new/bot/actions/webfetch.d.ts +0 -36
- package/local-dist-new/bot/actions/webfetch.d.ts.map +0 -1
- package/local-dist-new/bot/actions/webfetch.js +0 -247
- package/local-dist-new/bot/actions/webfetch.js.map +0 -1
- package/local-dist-new/bot/actions/websearch.d.ts +0 -35
- package/local-dist-new/bot/actions/websearch.d.ts.map +0 -1
- package/local-dist-new/bot/actions/websearch.js +0 -132
- package/local-dist-new/bot/actions/websearch.js.map +0 -1
- package/local-dist-new/bot/actions/write.d.ts +0 -31
- package/local-dist-new/bot/actions/write.d.ts.map +0 -1
- package/local-dist-new/bot/actions/write.js +0 -139
- package/local-dist-new/bot/actions/write.js.map +0 -1
- package/local-dist-new/bot/agent-loop.d.ts +0 -15
- package/local-dist-new/bot/agent-loop.d.ts.map +0 -1
- package/local-dist-new/bot/agent-loop.js +0 -293
- package/local-dist-new/bot/agent-loop.js.map +0 -1
- package/local-dist-new/bot/agent.d.ts +0 -122
- package/local-dist-new/bot/agent.d.ts.map +0 -1
- package/local-dist-new/bot/agent.js +0 -393
- package/local-dist-new/bot/agent.js.map +0 -1
- package/local-dist-new/bot/error-handler.d.ts +0 -8
- package/local-dist-new/bot/error-handler.d.ts.map +0 -1
- package/local-dist-new/bot/error-handler.js +0 -8
- package/local-dist-new/bot/error-handler.js.map +0 -1
- package/local-dist-new/bot/event-bus.d.ts +0 -9
- package/local-dist-new/bot/event-bus.d.ts.map +0 -1
- package/local-dist-new/bot/event-bus.js +0 -15
- package/local-dist-new/bot/event-bus.js.map +0 -1
- package/local-dist-new/bot/index.d.ts +0 -8
- package/local-dist-new/bot/index.d.ts.map +0 -1
- package/local-dist-new/bot/index.js +0 -8
- package/local-dist-new/bot/index.js.map +0 -1
- package/local-dist-new/bot/messages.d.ts +0 -77
- package/local-dist-new/bot/messages.d.ts.map +0 -1
- package/local-dist-new/bot/messages.js +0 -116
- package/local-dist-new/bot/messages.js.map +0 -1
- package/local-dist-new/bot/proxy.d.ts +0 -66
- package/local-dist-new/bot/proxy.d.ts.map +0 -1
- package/local-dist-new/bot/proxy.js +0 -228
- package/local-dist-new/bot/proxy.js.map +0 -1
- package/local-dist-new/bot/session-manager.d.ts +0 -448
- package/local-dist-new/bot/session-manager.d.ts.map +0 -1
- package/local-dist-new/bot/session-manager.js +0 -1232
- package/local-dist-new/bot/session-manager.js.map +0 -1
- package/local-dist-new/bot/state-manager.d.ts +0 -22
- package/local-dist-new/bot/state-manager.d.ts.map +0 -1
- package/local-dist-new/bot/state-manager.js +0 -60
- package/local-dist-new/bot/state-manager.js.map +0 -1
- package/local-dist-new/bot/telemetry.d.ts +0 -7
- package/local-dist-new/bot/telemetry.d.ts.map +0 -1
- package/local-dist-new/bot/telemetry.js +0 -18
- package/local-dist-new/bot/telemetry.js.map +0 -1
- package/local-dist-new/bot/types.d.ts +0 -205
- package/local-dist-new/bot/types.d.ts.map +0 -1
- package/local-dist-new/bot/types.js +0 -60
- package/local-dist-new/bot/types.js.map +0 -1
- package/local-dist-new/cli.d.ts +0 -3
- package/local-dist-new/cli.d.ts.map +0 -1
- package/local-dist-new/cli.js +0 -3
- package/local-dist-new/cli.js.map +0 -1
- package/local-dist-new/index.d.ts +0 -7
- package/local-dist-new/index.d.ts.map +0 -1
- package/local-dist-new/index.js +0 -7
- package/local-dist-new/index.js.map +0 -1
- package/local-dist-new/mcp/client-pool.d.ts +0 -106
- package/local-dist-new/mcp/client-pool.d.ts.map +0 -1
- package/local-dist-new/mcp/client-pool.js +0 -234
- package/local-dist-new/mcp/client-pool.js.map +0 -1
- package/local-dist-new/mcp/client.d.ts +0 -158
- package/local-dist-new/mcp/client.d.ts.map +0 -1
- package/local-dist-new/mcp/client.js +0 -611
- package/local-dist-new/mcp/client.js.map +0 -1
- package/local-dist-new/mcp/config.d.ts +0 -61
- package/local-dist-new/mcp/config.d.ts.map +0 -1
- package/local-dist-new/mcp/config.js +0 -250
- package/local-dist-new/mcp/config.js.map +0 -1
- package/local-dist-new/mcp/errors.d.ts +0 -104
- package/local-dist-new/mcp/errors.d.ts.map +0 -1
- package/local-dist-new/mcp/errors.js +0 -146
- package/local-dist-new/mcp/errors.js.map +0 -1
- package/local-dist-new/mcp/index.d.ts +0 -56
- package/local-dist-new/mcp/index.d.ts.map +0 -1
- package/local-dist-new/mcp/index.js +0 -83
- package/local-dist-new/mcp/index.js.map +0 -1
- package/local-dist-new/mcp/schema-converter.d.ts +0 -68
- package/local-dist-new/mcp/schema-converter.d.ts.map +0 -1
- package/local-dist-new/mcp/schema-converter.js +0 -230
- package/local-dist-new/mcp/schema-converter.js.map +0 -1
- package/local-dist-new/mcp/server.d.ts +0 -111
- package/local-dist-new/mcp/server.d.ts.map +0 -1
- package/local-dist-new/mcp/server.js +0 -305
- package/local-dist-new/mcp/server.js.map +0 -1
- package/local-dist-new/mcp/tool-factory.d.ts +0 -63
- package/local-dist-new/mcp/tool-factory.d.ts.map +0 -1
- package/local-dist-new/mcp/tool-factory.js +0 -228
- package/local-dist-new/mcp/tool-factory.js.map +0 -1
- package/local-dist-new/mcp/types.d.ts +0 -289
- package/local-dist-new/mcp/types.d.ts.map +0 -1
- package/local-dist-new/mcp/types.js +0 -8
- package/local-dist-new/mcp/types.js.map +0 -1
- package/local-dist-new/mcp.d.ts +0 -2
- package/local-dist-new/mcp.d.ts.map +0 -1
- package/local-dist-new/mcp.js +0 -2
- package/local-dist-new/mcp.js.map +0 -1
- package/local-dist-new/ml/adapters/amazon-bedrock.d.ts +0 -33
- package/local-dist-new/ml/adapters/amazon-bedrock.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/amazon-bedrock.js +0 -610
- package/local-dist-new/ml/adapters/amazon-bedrock.js.map +0 -1
- package/local-dist-new/ml/adapters/anthropic.d.ts +0 -62
- package/local-dist-new/ml/adapters/anthropic.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/anthropic.js +0 -682
- package/local-dist-new/ml/adapters/anthropic.js.map +0 -1
- package/local-dist-new/ml/adapters/azure-openai-responses.d.ts +0 -15
- package/local-dist-new/ml/adapters/azure-openai-responses.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/azure-openai-responses.js +0 -233
- package/local-dist-new/ml/adapters/azure-openai-responses.js.map +0 -1
- package/local-dist-new/ml/adapters/google-shared.d.ts +0 -60
- package/local-dist-new/ml/adapters/google-shared.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/google-shared.js +0 -316
- package/local-dist-new/ml/adapters/google-shared.js.map +0 -1
- package/local-dist-new/ml/adapters/google-vertex.d.ts +0 -15
- package/local-dist-new/ml/adapters/google-vertex.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/google-vertex.js +0 -396
- package/local-dist-new/ml/adapters/google-vertex.js.map +0 -1
- package/local-dist-new/ml/adapters/google.d.ts +0 -16
- package/local-dist-new/ml/adapters/google.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/google.js +0 -381
- package/local-dist-new/ml/adapters/google.js.map +0 -1
- package/local-dist-new/ml/adapters/kimi.d.ts +0 -22
- package/local-dist-new/ml/adapters/kimi.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/kimi.js +0 -249
- package/local-dist-new/ml/adapters/kimi.js.map +0 -1
- package/local-dist-new/ml/adapters/mock.d.ts +0 -10
- package/local-dist-new/ml/adapters/mock.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/mock.js +0 -64
- package/local-dist-new/ml/adapters/mock.js.map +0 -1
- package/local-dist-new/ml/adapters/nvidia.d.ts +0 -14
- package/local-dist-new/ml/adapters/nvidia.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/nvidia.js +0 -377
- package/local-dist-new/ml/adapters/nvidia.js.map +0 -1
- package/local-dist-new/ml/adapters/openai-codex-responses.d.ts +0 -9
- package/local-dist-new/ml/adapters/openai-codex-responses.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/openai-codex-responses.js +0 -397
- package/local-dist-new/ml/adapters/openai-codex-responses.js.map +0 -1
- package/local-dist-new/ml/adapters/openai-completions.d.ts +0 -25
- package/local-dist-new/ml/adapters/openai-completions.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/openai-completions.js +0 -831
- package/local-dist-new/ml/adapters/openai-completions.js.map +0 -1
- package/local-dist-new/ml/adapters/openai-responses-shared.d.ts +0 -26
- package/local-dist-new/ml/adapters/openai-responses-shared.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/openai-responses-shared.js +0 -461
- package/local-dist-new/ml/adapters/openai-responses-shared.js.map +0 -1
- package/local-dist-new/ml/adapters/openai-responses.d.ts +0 -13
- package/local-dist-new/ml/adapters/openai-responses.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/openai-responses.js +0 -209
- package/local-dist-new/ml/adapters/openai-responses.js.map +0 -1
- package/local-dist-new/ml/adapters/openai-scaffold.d.ts +0 -4
- package/local-dist-new/ml/adapters/openai-scaffold.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/openai-scaffold.js +0 -33
- package/local-dist-new/ml/adapters/openai-scaffold.js.map +0 -1
- package/local-dist-new/ml/adapters/register-builtins.d.ts +0 -3
- package/local-dist-new/ml/adapters/register-builtins.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/register-builtins.js +0 -143
- package/local-dist-new/ml/adapters/register-builtins.js.map +0 -1
- package/local-dist-new/ml/adapters/simple-options.d.ts +0 -27
- package/local-dist-new/ml/adapters/simple-options.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/simple-options.js +0 -96
- package/local-dist-new/ml/adapters/simple-options.js.map +0 -1
- package/local-dist-new/ml/adapters/transform-messages.d.ts +0 -22
- package/local-dist-new/ml/adapters/transform-messages.d.ts.map +0 -1
- package/local-dist-new/ml/adapters/transform-messages.js +0 -147
- package/local-dist-new/ml/adapters/transform-messages.js.map +0 -1
- package/local-dist-new/ml/api-registry.d.ts +0 -50
- package/local-dist-new/ml/api-registry.d.ts.map +0 -1
- package/local-dist-new/ml/api-registry.js +0 -121
- package/local-dist-new/ml/api-registry.js.map +0 -1
- package/local-dist-new/ml/cli.d.ts +0 -3
- package/local-dist-new/ml/cli.d.ts.map +0 -1
- package/local-dist-new/ml/cli.js +0 -117
- package/local-dist-new/ml/cli.js.map +0 -1
- package/local-dist-new/ml/env-api-keys.d.ts +0 -18
- package/local-dist-new/ml/env-api-keys.d.ts.map +0 -1
- package/local-dist-new/ml/env-api-keys.js +0 -122
- package/local-dist-new/ml/env-api-keys.js.map +0 -1
- package/local-dist-new/ml/index.d.ts +0 -28
- package/local-dist-new/ml/index.d.ts.map +0 -1
- package/local-dist-new/ml/index.js +0 -28
- package/local-dist-new/ml/index.js.map +0 -1
- package/local-dist-new/ml/kit/auth/anthropic.d.ts +0 -18
- package/local-dist-new/ml/kit/auth/anthropic.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/anthropic.js +0 -152
- package/local-dist-new/ml/kit/auth/anthropic.js.map +0 -1
- package/local-dist-new/ml/kit/auth/github-copilot.d.ts +0 -23
- package/local-dist-new/ml/kit/auth/github-copilot.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/github-copilot.js +0 -275
- package/local-dist-new/ml/kit/auth/github-copilot.js.map +0 -1
- package/local-dist-new/ml/kit/auth/index.d.ts +0 -50
- package/local-dist-new/ml/kit/auth/index.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/index.js +0 -112
- package/local-dist-new/ml/kit/auth/index.js.map +0 -1
- package/local-dist-new/ml/kit/auth/kimi.d.ts +0 -24
- package/local-dist-new/ml/kit/auth/kimi.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/kimi.js +0 -30
- package/local-dist-new/ml/kit/auth/kimi.js.map +0 -1
- package/local-dist-new/ml/kit/auth/oauth-page.d.ts +0 -3
- package/local-dist-new/ml/kit/auth/oauth-page.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/oauth-page.js +0 -105
- package/local-dist-new/ml/kit/auth/oauth-page.js.map +0 -1
- package/local-dist-new/ml/kit/auth/openai-codex.d.ts +0 -34
- package/local-dist-new/ml/kit/auth/openai-codex.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/openai-codex.js +0 -373
- package/local-dist-new/ml/kit/auth/openai-codex.js.map +0 -1
- package/local-dist-new/ml/kit/auth/pkce.d.ts +0 -13
- package/local-dist-new/ml/kit/auth/pkce.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/pkce.js +0 -31
- package/local-dist-new/ml/kit/auth/pkce.js.map +0 -1
- package/local-dist-new/ml/kit/auth/types.d.ts +0 -72
- package/local-dist-new/ml/kit/auth/types.d.ts.map +0 -1
- package/local-dist-new/ml/kit/auth/types.js +0 -11
- package/local-dist-new/ml/kit/auth/types.js.map +0 -1
- package/local-dist-new/ml/kit/base-stream-handler.d.ts +0 -16
- package/local-dist-new/ml/kit/base-stream-handler.d.ts.map +0 -1
- package/local-dist-new/ml/kit/base-stream-handler.js +0 -25
- package/local-dist-new/ml/kit/base-stream-handler.js.map +0 -1
- package/local-dist-new/ml/kit/event-stream.d.ts +0 -45
- package/local-dist-new/ml/kit/event-stream.d.ts.map +0 -1
- package/local-dist-new/ml/kit/event-stream.js +0 -178
- package/local-dist-new/ml/kit/event-stream.js.map +0 -1
- package/local-dist-new/ml/kit/index.d.ts +0 -15
- package/local-dist-new/ml/kit/index.d.ts.map +0 -1
- package/local-dist-new/ml/kit/index.js +0 -15
- package/local-dist-new/ml/kit/index.js.map +0 -1
- package/local-dist-new/ml/kit/json-parse.d.ts +0 -21
- package/local-dist-new/ml/kit/json-parse.d.ts.map +0 -1
- package/local-dist-new/ml/kit/json-parse.js +0 -44
- package/local-dist-new/ml/kit/json-parse.js.map +0 -1
- package/local-dist-new/ml/kit/message-transform.d.ts +0 -29
- package/local-dist-new/ml/kit/message-transform.d.ts.map +0 -1
- package/local-dist-new/ml/kit/message-transform.js +0 -55
- package/local-dist-new/ml/kit/message-transform.js.map +0 -1
- package/local-dist-new/ml/kit/output-factory.d.ts +0 -3
- package/local-dist-new/ml/kit/output-factory.d.ts.map +0 -1
- package/local-dist-new/ml/kit/output-factory.js +0 -23
- package/local-dist-new/ml/kit/output-factory.js.map +0 -1
- package/local-dist-new/ml/kit/overflow.d.ts +0 -10
- package/local-dist-new/ml/kit/overflow.d.ts.map +0 -1
- package/local-dist-new/ml/kit/overflow.js +0 -76
- package/local-dist-new/ml/kit/overflow.js.map +0 -1
- package/local-dist-new/ml/kit/provider-adapter.d.ts +0 -57
- package/local-dist-new/ml/kit/provider-adapter.d.ts.map +0 -1
- package/local-dist-new/ml/kit/provider-adapter.js +0 -37
- package/local-dist-new/ml/kit/provider-adapter.js.map +0 -1
- package/local-dist-new/ml/kit/provider-client-builder.d.ts +0 -37
- package/local-dist-new/ml/kit/provider-client-builder.d.ts.map +0 -1
- package/local-dist-new/ml/kit/provider-client-builder.js +0 -50
- package/local-dist-new/ml/kit/provider-client-builder.js.map +0 -1
- package/local-dist-new/ml/kit/provider-consolidation.d.ts +0 -4
- package/local-dist-new/ml/kit/provider-consolidation.d.ts.map +0 -1
- package/local-dist-new/ml/kit/provider-consolidation.js +0 -33
- package/local-dist-new/ml/kit/provider-consolidation.js.map +0 -1
- package/local-dist-new/ml/kit/provider-constants.d.ts +0 -35
- package/local-dist-new/ml/kit/provider-constants.d.ts.map +0 -1
- package/local-dist-new/ml/kit/provider-constants.js +0 -35
- package/local-dist-new/ml/kit/provider-constants.js.map +0 -1
- package/local-dist-new/ml/kit/provider-errors.d.ts +0 -46
- package/local-dist-new/ml/kit/provider-errors.d.ts.map +0 -1
- package/local-dist-new/ml/kit/provider-errors.js +0 -103
- package/local-dist-new/ml/kit/provider-errors.js.map +0 -1
- package/local-dist-new/ml/kit/sanitize-unicode.d.ts +0 -3
- package/local-dist-new/ml/kit/sanitize-unicode.d.ts.map +0 -1
- package/local-dist-new/ml/kit/sanitize-unicode.js +0 -60
- package/local-dist-new/ml/kit/sanitize-unicode.js.map +0 -1
- package/local-dist-new/ml/kit/stream-event-helper.d.ts +0 -28
- package/local-dist-new/ml/kit/stream-event-helper.d.ts.map +0 -1
- package/local-dist-new/ml/kit/stream-event-helper.js +0 -52
- package/local-dist-new/ml/kit/stream-event-helper.js.map +0 -1
- package/local-dist-new/ml/kit/stream-handler-types.d.ts +0 -43
- package/local-dist-new/ml/kit/stream-handler-types.d.ts.map +0 -1
- package/local-dist-new/ml/kit/stream-handler-types.js +0 -23
- package/local-dist-new/ml/kit/stream-handler-types.js.map +0 -1
- package/local-dist-new/ml/kit/streaming-state-manager.d.ts +0 -50
- package/local-dist-new/ml/kit/streaming-state-manager.d.ts.map +0 -1
- package/local-dist-new/ml/kit/streaming-state-manager.js +0 -67
- package/local-dist-new/ml/kit/streaming-state-manager.js.map +0 -1
- package/local-dist-new/ml/kit/tool-converter.d.ts +0 -50
- package/local-dist-new/ml/kit/tool-converter.d.ts.map +0 -1
- package/local-dist-new/ml/kit/tool-converter.js +0 -54
- package/local-dist-new/ml/kit/tool-converter.js.map +0 -1
- package/local-dist-new/ml/kit/typebox-helpers.d.ts +0 -24
- package/local-dist-new/ml/kit/typebox-helpers.d.ts.map +0 -1
- package/local-dist-new/ml/kit/typebox-helpers.js +0 -46
- package/local-dist-new/ml/kit/typebox-helpers.js.map +0 -1
- package/local-dist-new/ml/kit/validation.d.ts +0 -24
- package/local-dist-new/ml/kit/validation.d.ts.map +0 -1
- package/local-dist-new/ml/kit/validation.js +0 -119
- package/local-dist-new/ml/kit/validation.js.map +0 -1
- package/local-dist-new/ml/models.d.ts +0 -41
- package/local-dist-new/ml/models.d.ts.map +0 -1
- package/local-dist-new/ml/models.generated.d.ts +0 -12245
- package/local-dist-new/ml/models.generated.d.ts.map +0 -1
- package/local-dist-new/ml/models.generated.js +0 -12080
- package/local-dist-new/ml/models.generated.js.map +0 -1
- package/local-dist-new/ml/models.js +0 -126
- package/local-dist-new/ml/models.js.map +0 -1
- package/local-dist-new/ml/stream.d.ts +0 -12
- package/local-dist-new/ml/stream.d.ts.map +0 -1
- package/local-dist-new/ml/stream.js +0 -54
- package/local-dist-new/ml/stream.js.map +0 -1
- package/local-dist-new/ml/types.d.ts +0 -270
- package/local-dist-new/ml/types.d.ts.map +0 -1
- package/local-dist-new/ml/types.js +0 -169
- package/local-dist-new/ml/types.js.map +0 -1
- package/local-dist-new/observability.d.ts +0 -2
- package/local-dist-new/observability.d.ts.map +0 -1
- package/local-dist-new/observability.js +0 -2
- package/local-dist-new/observability.js.map +0 -1
- package/local-dist-new/react-host/index.d.ts +0 -10
- package/local-dist-new/react-host/index.d.ts.map +0 -1
- package/local-dist-new/react-host/index.js +0 -9
- package/local-dist-new/react-host/index.js.map +0 -1
- package/local-dist-new/react-host/ink.d.ts +0 -6
- package/local-dist-new/react-host/ink.d.ts.map +0 -1
- package/local-dist-new/react-host/ink.js +0 -7
- package/local-dist-new/react-host/ink.js.map +0 -1
- package/local-dist-new/react-host/jsx-runtime.d.ts +0 -5
- package/local-dist-new/react-host/jsx-runtime.d.ts.map +0 -1
- package/local-dist-new/react-host/jsx-runtime.js +0 -6
- package/local-dist-new/react-host/jsx-runtime.js.map +0 -1
- package/local-dist-new/react-host/loader.d.ts +0 -4
- package/local-dist-new/react-host/loader.d.ts.map +0 -1
- package/local-dist-new/react-host/loader.js +0 -108
- package/local-dist-new/react-host/loader.js.map +0 -1
- package/local-dist-new/react-ink/components/ChangelogBlock.d.ts +0 -9
- package/local-dist-new/react-ink/components/ChangelogBlock.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/ChangelogBlock.js +0 -58
- package/local-dist-new/react-ink/components/ChangelogBlock.js.map +0 -1
- package/local-dist-new/react-ink/components/DisplayBlockView.d.ts +0 -9
- package/local-dist-new/react-ink/components/DisplayBlockView.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/DisplayBlockView.js +0 -11
- package/local-dist-new/react-ink/components/DisplayBlockView.js.map +0 -1
- package/local-dist-new/react-ink/components/Footer.d.ts +0 -12
- package/local-dist-new/react-ink/components/Footer.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/Footer.js +0 -113
- package/local-dist-new/react-ink/components/Footer.js.map +0 -1
- package/local-dist-new/react-ink/components/MessageList.d.ts +0 -15
- package/local-dist-new/react-ink/components/MessageList.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/MessageList.js +0 -43
- package/local-dist-new/react-ink/components/MessageList.js.map +0 -1
- package/local-dist-new/react-ink/components/MessageRow.d.ts +0 -14
- package/local-dist-new/react-ink/components/MessageRow.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/MessageRow.js +0 -35
- package/local-dist-new/react-ink/components/MessageRow.js.map +0 -1
- package/local-dist-new/react-ink/components/StatusLine.d.ts +0 -10
- package/local-dist-new/react-ink/components/StatusLine.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/StatusLine.js +0 -39
- package/local-dist-new/react-ink/components/StatusLine.js.map +0 -1
- package/local-dist-new/react-ink/components/TaskPanel.d.ts +0 -12
- package/local-dist-new/react-ink/components/TaskPanel.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/TaskPanel.js +0 -23
- package/local-dist-new/react-ink/components/TaskPanel.js.map +0 -1
- package/local-dist-new/react-ink/components/ToolEventBlock.d.ts +0 -18
- package/local-dist-new/react-ink/components/ToolEventBlock.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/ToolEventBlock.js +0 -61
- package/local-dist-new/react-ink/components/ToolEventBlock.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/DialogFrame.d.ts +0 -9
- package/local-dist-new/react-ink/components/dialogs/DialogFrame.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/DialogFrame.js +0 -6
- package/local-dist-new/react-ink/components/dialogs/DialogFrame.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/LoginDialog.d.ts +0 -15
- package/local-dist-new/react-ink/components/dialogs/LoginDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/LoginDialog.js +0 -10
- package/local-dist-new/react-ink/components/dialogs/LoginDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/ModelDialog.d.ts +0 -10
- package/local-dist-new/react-ink/components/dialogs/ModelDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/ModelDialog.js +0 -64
- package/local-dist-new/react-ink/components/dialogs/ModelDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/OAuthDialog.d.ts +0 -10
- package/local-dist-new/react-ink/components/dialogs/OAuthDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/OAuthDialog.js +0 -24
- package/local-dist-new/react-ink/components/dialogs/OAuthDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.d.ts +0 -10
- package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.js +0 -95
- package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/SelectableDialog.d.ts +0 -17
- package/local-dist-new/react-ink/components/dialogs/SelectableDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/SelectableDialog.js +0 -66
- package/local-dist-new/react-ink/components/dialogs/SelectableDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/SessionDialog.d.ts +0 -14
- package/local-dist-new/react-ink/components/dialogs/SessionDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/SessionDialog.js +0 -201
- package/local-dist-new/react-ink/components/dialogs/SessionDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/SettingsDialog.d.ts +0 -15
- package/local-dist-new/react-ink/components/dialogs/SettingsDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/SettingsDialog.js +0 -79
- package/local-dist-new/react-ink/components/dialogs/SettingsDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.d.ts +0 -10
- package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.js +0 -100
- package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/ThemeDialog.d.ts +0 -8
- package/local-dist-new/react-ink/components/dialogs/ThemeDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/ThemeDialog.js +0 -7
- package/local-dist-new/react-ink/components/dialogs/ThemeDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/TreeDialog.d.ts +0 -9
- package/local-dist-new/react-ink/components/dialogs/TreeDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/TreeDialog.js +0 -7
- package/local-dist-new/react-ink/components/dialogs/TreeDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.d.ts +0 -9
- package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.js +0 -7
- package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/AssistantMessage.d.ts +0 -13
- package/local-dist-new/react-ink/components/messages/AssistantMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/AssistantMessage.js +0 -20
- package/local-dist-new/react-ink/components/messages/AssistantMessage.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/BashMessage.d.ts +0 -9
- package/local-dist-new/react-ink/components/messages/BashMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/BashMessage.js +0 -11
- package/local-dist-new/react-ink/components/messages/BashMessage.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.d.ts +0 -9
- package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.js +0 -6
- package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/CompactionMessage.d.ts +0 -9
- package/local-dist-new/react-ink/components/messages/CompactionMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/CompactionMessage.js +0 -6
- package/local-dist-new/react-ink/components/messages/CompactionMessage.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/CustomMessage.d.ts +0 -10
- package/local-dist-new/react-ink/components/messages/CustomMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/CustomMessage.js +0 -9
- package/local-dist-new/react-ink/components/messages/CustomMessage.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.d.ts +0 -8
- package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.js +0 -10
- package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/ToolCallMessage.d.ts +0 -9
- package/local-dist-new/react-ink/components/messages/ToolCallMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/ToolCallMessage.js +0 -8
- package/local-dist-new/react-ink/components/messages/ToolCallMessage.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/ToolResultBlock.d.ts +0 -13
- package/local-dist-new/react-ink/components/messages/ToolResultBlock.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/ToolResultBlock.js +0 -8
- package/local-dist-new/react-ink/components/messages/ToolResultBlock.js.map +0 -1
- package/local-dist-new/react-ink/components/messages/UserMessage.d.ts +0 -10
- package/local-dist-new/react-ink/components/messages/UserMessage.d.ts.map +0 -1
- package/local-dist-new/react-ink/components/messages/UserMessage.js +0 -9
- package/local-dist-new/react-ink/components/messages/UserMessage.js.map +0 -1
- package/local-dist-new/react-ink/index.d.ts +0 -35
- package/local-dist-new/react-ink/index.d.ts.map +0 -1
- package/local-dist-new/react-ink/index.js +0 -35
- package/local-dist-new/react-ink/index.js.map +0 -1
- package/local-dist-new/react-ink/theme-adapter.d.ts +0 -10
- package/local-dist-new/react-ink/theme-adapter.d.ts.map +0 -1
- package/local-dist-new/react-ink/theme-adapter.js +0 -44
- package/local-dist-new/react-ink/theme-adapter.js.map +0 -1
- package/local-dist-new/react-ink/types.d.ts +0 -134
- package/local-dist-new/react-ink/types.d.ts.map +0 -1
- package/local-dist-new/react-ink/types.js +0 -2
- package/local-dist-new/react-ink/types.js.map +0 -1
- package/local-dist-new/react-ink/utils/message-groups.d.ts +0 -26
- package/local-dist-new/react-ink/utils/message-groups.d.ts.map +0 -1
- package/local-dist-new/react-ink/utils/message-groups.js +0 -240
- package/local-dist-new/react-ink/utils/message-groups.js.map +0 -1
- package/local-dist-new/react-ink/utils/selection-dialog.d.ts +0 -3
- package/local-dist-new/react-ink/utils/selection-dialog.d.ts.map +0 -1
- package/local-dist-new/react-ink/utils/selection-dialog.js +0 -18
- package/local-dist-new/react-ink/utils/selection-dialog.js.map +0 -1
- package/local-dist-new/react-ink/utils/session-browser.d.ts +0 -28
- package/local-dist-new/react-ink/utils/session-browser.d.ts.map +0 -1
- package/local-dist-new/react-ink/utils/session-browser.js +0 -191
- package/local-dist-new/react-ink/utils/session-browser.js.map +0 -1
- package/local-dist-new/react-ink/utils/tool-display.d.ts +0 -22
- package/local-dist-new/react-ink/utils/tool-display.d.ts.map +0 -1
- package/local-dist-new/react-ink/utils/tool-display.js +0 -349
- package/local-dist-new/react-ink/utils/tool-display.js.map +0 -1
- package/local-dist-new/react-ink.d.ts +0 -3
- package/local-dist-new/react-ink.d.ts.map +0 -1
- package/local-dist-new/react-ink.js +0 -2
- package/local-dist-new/react-ink.js.map +0 -1
- package/local-dist-new/tui.d.ts +0 -9
- package/local-dist-new/tui.d.ts.map +0 -1
- package/local-dist-new/tui.js +0 -8
- package/local-dist-new/tui.js.map +0 -1
- package/local-dist-new/ui/autocomplete.d.ts +0 -60
- package/local-dist-new/ui/autocomplete.d.ts.map +0 -1
- package/local-dist-new/ui/autocomplete.js +0 -393
- package/local-dist-new/ui/autocomplete.js.map +0 -1
- package/local-dist-new/ui/contracts.d.ts +0 -39
- package/local-dist-new/ui/contracts.d.ts.map +0 -1
- package/local-dist-new/ui/contracts.js +0 -2
- package/local-dist-new/ui/contracts.js.map +0 -1
- package/local-dist-new/ui/editor-component.d.ts +0 -101
- package/local-dist-new/ui/editor-component.d.ts.map +0 -1
- package/local-dist-new/ui/editor-component.js +0 -2
- package/local-dist-new/ui/editor-component.js.map +0 -1
- package/local-dist-new/ui/fuzzy.d.ts +0 -26
- package/local-dist-new/ui/fuzzy.d.ts.map +0 -1
- package/local-dist-new/ui/fuzzy.js +0 -177
- package/local-dist-new/ui/fuzzy.js.map +0 -1
- package/local-dist-new/ui/index.d.ts +0 -9
- package/local-dist-new/ui/index.d.ts.map +0 -1
- package/local-dist-new/ui/index.js +0 -6
- package/local-dist-new/ui/index.js.map +0 -1
- package/local-dist-new/ui/keybindings.d.ts +0 -52
- package/local-dist-new/ui/keybindings.d.ts.map +0 -1
- package/local-dist-new/ui/keybindings.js +0 -193
- package/local-dist-new/ui/keybindings.js.map +0 -1
- package/local-dist-new/ui/keys.d.ts +0 -168
- package/local-dist-new/ui/keys.d.ts.map +0 -1
- package/local-dist-new/ui/keys.js +0 -1093
- package/local-dist-new/ui/keys.js.map +0 -1
- package/local-dist-new/ui/theme-types.d.ts +0 -37
- package/local-dist-new/ui/theme-types.d.ts.map +0 -1
- package/local-dist-new/ui/theme-types.js +0 -2
- package/local-dist-new/ui/theme-types.js.map +0 -1
- package/local-dist-new/ui/utils.d.ts +0 -97
- package/local-dist-new/ui/utils.d.ts.map +0 -1
- package/local-dist-new/ui/utils.js +0 -860
- package/local-dist-new/ui/utils.js.map +0 -1
- package/observe.d.ts +0 -1
- package/observe.js +0 -1
|
@@ -0,0 +1,3821 @@
|
|
|
1
|
+
// src/react-ink/theme-adapter.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import stripAnsi from "strip-ansi";
|
|
4
|
+
var DEFAULT_ROLE_KEYS = {
|
|
5
|
+
codeInline: "codeInline",
|
|
6
|
+
heading: "heading",
|
|
7
|
+
blockquoteBar: "blockquoteBar",
|
|
8
|
+
diffAddedBg: "diffAddedBg",
|
|
9
|
+
diffRemovedBg: "diffRemovedBg",
|
|
10
|
+
diffAddedText: "diffAddedText",
|
|
11
|
+
diffRemovedText: "diffRemovedText",
|
|
12
|
+
synKeyword: "synKeyword",
|
|
13
|
+
synString: "synString",
|
|
14
|
+
synNumber: "synNumber",
|
|
15
|
+
synComment: "synComment",
|
|
16
|
+
synType: "synType"
|
|
17
|
+
};
|
|
18
|
+
var ROLE_FALLBACK_KEYS = {
|
|
19
|
+
codeInline: "accent",
|
|
20
|
+
heading: "accent",
|
|
21
|
+
blockquoteBar: "muted",
|
|
22
|
+
diffAddedBg: "success",
|
|
23
|
+
diffRemovedBg: "error",
|
|
24
|
+
diffAddedText: "success",
|
|
25
|
+
diffRemovedText: "error",
|
|
26
|
+
synKeyword: "accent",
|
|
27
|
+
synString: "success",
|
|
28
|
+
synNumber: "warning",
|
|
29
|
+
synComment: "muted",
|
|
30
|
+
synType: "info"
|
|
31
|
+
};
|
|
32
|
+
function applyForeground(color, text) {
|
|
33
|
+
if (!color) return text;
|
|
34
|
+
try {
|
|
35
|
+
return chalk.hex(color)(text);
|
|
36
|
+
} catch {
|
|
37
|
+
return text;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function resolveColorToken(value, fallback) {
|
|
41
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
46
|
+
function applyBackground(background, foreground, text) {
|
|
47
|
+
if (!background) return applyForeground(foreground, text);
|
|
48
|
+
try {
|
|
49
|
+
let styled = chalk.bgHex(background);
|
|
50
|
+
if (foreground) {
|
|
51
|
+
styled = styled.hex(foreground);
|
|
52
|
+
}
|
|
53
|
+
return styled(text);
|
|
54
|
+
} catch {
|
|
55
|
+
return applyForeground(foreground, text);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function createThemeAdapter(themeName, colors, roleOverrides) {
|
|
59
|
+
const fallback = colors.text ?? "#e5e5e7";
|
|
60
|
+
const roles = { ...DEFAULT_ROLE_KEYS, ...roleOverrides };
|
|
61
|
+
const resolveRoleColor = (role) => resolveColorToken(
|
|
62
|
+
colors[roles[role]],
|
|
63
|
+
resolveColorToken(colors[ROLE_FALLBACK_KEYS[role]], fallback)
|
|
64
|
+
);
|
|
65
|
+
return {
|
|
66
|
+
name: themeName,
|
|
67
|
+
colors,
|
|
68
|
+
roles,
|
|
69
|
+
color: (key, text) => applyForeground(resolveColorToken(colors[key], fallback), text),
|
|
70
|
+
background: (key, text, textKey = "text") => applyBackground(resolveColorToken(colors[key]), resolveColorToken(colors[textKey], fallback), ` ${stripAnsi(text)} `),
|
|
71
|
+
dim: (text) => applyForeground(resolveColorToken(colors.dim, "#666666"), text),
|
|
72
|
+
muted: (text) => applyForeground(resolveColorToken(colors.muted, "#808080"), text),
|
|
73
|
+
role: (role, text) => applyForeground(resolveRoleColor(role), text),
|
|
74
|
+
roleBackground: (role, text, foregroundRole) => applyBackground(
|
|
75
|
+
resolveRoleColor(role),
|
|
76
|
+
foregroundRole ? resolveRoleColor(foregroundRole) : void 0,
|
|
77
|
+
text
|
|
78
|
+
)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/react-host/loader.ts
|
|
83
|
+
import { createRequire } from "node:module";
|
|
84
|
+
import fs from "node:fs";
|
|
85
|
+
import path from "node:path";
|
|
86
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
87
|
+
function findPackageRoot(start) {
|
|
88
|
+
let current = path.resolve(start);
|
|
89
|
+
while (true) {
|
|
90
|
+
const packageJson = path.join(current, "package.json");
|
|
91
|
+
if (fs.existsSync(packageJson)) {
|
|
92
|
+
return current;
|
|
93
|
+
}
|
|
94
|
+
const parent = path.dirname(current);
|
|
95
|
+
if (parent === current) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
current = parent;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function createPackageRequire(packageRoot) {
|
|
102
|
+
return createRequire(path.join(packageRoot, "package.json"));
|
|
103
|
+
}
|
|
104
|
+
function candidatePackageRoots() {
|
|
105
|
+
const roots = /* @__PURE__ */ new Set();
|
|
106
|
+
const addCandidate = (candidate) => {
|
|
107
|
+
if (!candidate) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const root = findPackageRoot(candidate);
|
|
111
|
+
if (root) {
|
|
112
|
+
roots.add(root);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const argv1 = process.argv[1];
|
|
116
|
+
let argv1Real;
|
|
117
|
+
if (argv1) {
|
|
118
|
+
try {
|
|
119
|
+
argv1Real = fs.realpathSync(argv1);
|
|
120
|
+
} catch {
|
|
121
|
+
argv1Real = argv1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const packageRoot = fileURLToPath(new URL("../../..", import.meta.url));
|
|
125
|
+
addCandidate(process.env.INDUSAGI_REACT_HOST_ROOT);
|
|
126
|
+
addCandidate(argv1Real ? path.dirname(argv1Real) : void 0);
|
|
127
|
+
addCandidate(argv1 ? path.dirname(argv1) : void 0);
|
|
128
|
+
addCandidate(process.env.INIT_CWD);
|
|
129
|
+
addCandidate(process.cwd());
|
|
130
|
+
addCandidate(packageRoot);
|
|
131
|
+
return [...roots];
|
|
132
|
+
}
|
|
133
|
+
function resolveHostModule(specifier) {
|
|
134
|
+
const failures = [];
|
|
135
|
+
for (const packageRoot of candidatePackageRoots()) {
|
|
136
|
+
try {
|
|
137
|
+
return createPackageRequire(packageRoot).resolve(specifier);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
failures.push(`${packageRoot}: ${String(error.message ?? error)}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
throw new Error(
|
|
143
|
+
`Unable to resolve host module "${specifier}" from any detected package root.
|
|
144
|
+
${failures.join("\n")}`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
function normalizeModuleNamespace(moduleNamespace) {
|
|
148
|
+
const defaultExport = moduleNamespace.default;
|
|
149
|
+
if (defaultExport && typeof defaultExport === "object") {
|
|
150
|
+
return { ...defaultExport, ...moduleNamespace };
|
|
151
|
+
}
|
|
152
|
+
return moduleNamespace;
|
|
153
|
+
}
|
|
154
|
+
async function importHostModule(specifier) {
|
|
155
|
+
const resolved = resolveHostModule(specifier);
|
|
156
|
+
const moduleNamespace = await import(pathToFileURL(resolved).href);
|
|
157
|
+
return normalizeModuleNamespace(moduleNamespace);
|
|
158
|
+
}
|
|
159
|
+
var reactInstance = null;
|
|
160
|
+
var jsxRuntimeInstance = null;
|
|
161
|
+
var inkInstance = null;
|
|
162
|
+
function loadHostReact() {
|
|
163
|
+
if (!reactInstance) {
|
|
164
|
+
reactInstance = importHostModule("react");
|
|
165
|
+
}
|
|
166
|
+
return reactInstance;
|
|
167
|
+
}
|
|
168
|
+
function loadHostJsxRuntime() {
|
|
169
|
+
if (!jsxRuntimeInstance) {
|
|
170
|
+
jsxRuntimeInstance = importHostModule("react/jsx-runtime");
|
|
171
|
+
}
|
|
172
|
+
return jsxRuntimeInstance;
|
|
173
|
+
}
|
|
174
|
+
function loadHostInk() {
|
|
175
|
+
if (!inkInstance) {
|
|
176
|
+
inkInstance = importHostModule("ink");
|
|
177
|
+
}
|
|
178
|
+
return inkInstance;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/react-host/ink.ts
|
|
182
|
+
var ink = await loadHostInk();
|
|
183
|
+
var Box = ink.Box;
|
|
184
|
+
var Text = ink.Text;
|
|
185
|
+
var render = ink.render;
|
|
186
|
+
var useInput = ink.useInput;
|
|
187
|
+
|
|
188
|
+
// src/react-host/jsx-runtime.ts
|
|
189
|
+
var jsxRuntime = await loadHostJsxRuntime();
|
|
190
|
+
var Fragment = jsxRuntime.Fragment;
|
|
191
|
+
var jsx = jsxRuntime.jsx;
|
|
192
|
+
var jsxs = jsxRuntime.jsxs;
|
|
193
|
+
|
|
194
|
+
// src/react-ink/components/ChangelogBlock.tsx
|
|
195
|
+
function renderInline(text, theme, keyPrefix) {
|
|
196
|
+
const nodes = [];
|
|
197
|
+
const tokenPattern = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
198
|
+
let cursor = 0;
|
|
199
|
+
let tokenIndex = 0;
|
|
200
|
+
for (const match of text.matchAll(tokenPattern)) {
|
|
201
|
+
const matchedText = match[0];
|
|
202
|
+
const start = match.index ?? cursor;
|
|
203
|
+
if (start > cursor) {
|
|
204
|
+
nodes.push(text.slice(cursor, start));
|
|
205
|
+
}
|
|
206
|
+
if (matchedText.startsWith("**")) {
|
|
207
|
+
nodes.push(
|
|
208
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("accent", matchedText.slice(2, -2)) }, `${keyPrefix}-bold-${tokenIndex}`)
|
|
209
|
+
);
|
|
210
|
+
} else {
|
|
211
|
+
nodes.push(
|
|
212
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("accent", matchedText.slice(1, -1)) }, `${keyPrefix}-code-${tokenIndex}`)
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
cursor = start + matchedText.length;
|
|
216
|
+
tokenIndex += 1;
|
|
217
|
+
}
|
|
218
|
+
if (cursor < text.length) {
|
|
219
|
+
nodes.push(text.slice(cursor));
|
|
220
|
+
}
|
|
221
|
+
return nodes.length > 0 ? nodes : [text];
|
|
222
|
+
}
|
|
223
|
+
function renderMarkdownLine(line, theme, key) {
|
|
224
|
+
const trimmed = line.trim();
|
|
225
|
+
if (trimmed.length === 0) {
|
|
226
|
+
return /* @__PURE__ */ jsx(Text, { children: " " }, key);
|
|
227
|
+
}
|
|
228
|
+
if (/^-{3,}$/.test(trimmed)) {
|
|
229
|
+
const width = Math.max(20, (process.stdout.columns ?? 80) - 4);
|
|
230
|
+
return /* @__PURE__ */ jsx(Text, { children: theme.color("borderMuted", "\u2500".repeat(width)) }, key);
|
|
231
|
+
}
|
|
232
|
+
if (trimmed.startsWith("## ")) {
|
|
233
|
+
return /* @__PURE__ */ jsx(Text, { children: theme.color("accent", trimmed.slice(3)) }, key);
|
|
234
|
+
}
|
|
235
|
+
if (trimmed.startsWith("### ")) {
|
|
236
|
+
return /* @__PURE__ */ jsx(Text, { children: theme.color("warning", trimmed.slice(4)) }, key);
|
|
237
|
+
}
|
|
238
|
+
const bulletMatch = line.match(/^(\s*)-\s+(.*)$/);
|
|
239
|
+
if (bulletMatch) {
|
|
240
|
+
const indent = " ".repeat(bulletMatch[1]?.length ?? 0);
|
|
241
|
+
const content = bulletMatch[2] ?? "";
|
|
242
|
+
const bulletColor = indent.length > 0 ? "muted" : "accent";
|
|
243
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
244
|
+
indent,
|
|
245
|
+
theme.color(bulletColor, "\u2022"),
|
|
246
|
+
" ",
|
|
247
|
+
renderInline(content, theme, key)
|
|
248
|
+
] }, key);
|
|
249
|
+
}
|
|
250
|
+
return /* @__PURE__ */ jsx(Text, { children: renderInline(line, theme, key) }, key);
|
|
251
|
+
}
|
|
252
|
+
function ChangelogBlock({ markdown, theme, title }) {
|
|
253
|
+
const dividerWidth = Math.max(20, (process.stdout.columns ?? 80) - 2);
|
|
254
|
+
const divider = "\u2500".repeat(dividerWidth);
|
|
255
|
+
const lines = markdown.trim().length > 0 ? markdown.trim().split("\n") : ["No changelog entries found."];
|
|
256
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
257
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("borderMuted", divider) }),
|
|
258
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("accent", title) }),
|
|
259
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
260
|
+
lines.map((line, index) => renderMarkdownLine(line, theme, `${title}-${index}`)),
|
|
261
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("borderMuted", divider) })
|
|
262
|
+
] });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/react-ink/components/DisplayBlockView.tsx
|
|
266
|
+
function DisplayBlockView({ block, theme }) {
|
|
267
|
+
switch (block.kind) {
|
|
268
|
+
case "changelog":
|
|
269
|
+
return /* @__PURE__ */ jsx(ChangelogBlock, { markdown: block.markdown, theme, title: block.title });
|
|
270
|
+
default:
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// src/react-ink/components/Footer.tsx
|
|
276
|
+
import stripAnsi2 from "strip-ansi";
|
|
277
|
+
function toDisplayText(value) {
|
|
278
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
279
|
+
return String(value);
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(value)) {
|
|
282
|
+
return value.map((entry) => toDisplayText(entry)).join("");
|
|
283
|
+
}
|
|
284
|
+
if (!value || typeof value !== "object") {
|
|
285
|
+
return "";
|
|
286
|
+
}
|
|
287
|
+
if ("props" in value) {
|
|
288
|
+
return toDisplayText(value.props?.children);
|
|
289
|
+
}
|
|
290
|
+
return "";
|
|
291
|
+
}
|
|
292
|
+
function sanitizeStatusText(value) {
|
|
293
|
+
return value.replace(/\s+/g, " ").trim();
|
|
294
|
+
}
|
|
295
|
+
function formatTokens(count) {
|
|
296
|
+
if (count < 1e3) return count.toString();
|
|
297
|
+
if (count < 1e4) return `${(count / 1e3).toFixed(1)}k`;
|
|
298
|
+
if (count < 1e6) return `${Math.round(count / 1e3)}k`;
|
|
299
|
+
if (count < 1e7) return `${(count / 1e6).toFixed(1)}M`;
|
|
300
|
+
return `${Math.round(count / 1e6)}M`;
|
|
301
|
+
}
|
|
302
|
+
function shortenPath(path2) {
|
|
303
|
+
const home = process.env.HOME || process.env.USERPROFILE;
|
|
304
|
+
if (home && path2.startsWith(home)) {
|
|
305
|
+
return `~${path2.slice(home.length)}`;
|
|
306
|
+
}
|
|
307
|
+
return path2;
|
|
308
|
+
}
|
|
309
|
+
function chunkLines(values, width) {
|
|
310
|
+
const lines = [];
|
|
311
|
+
let current = "";
|
|
312
|
+
for (const value of values) {
|
|
313
|
+
const next = current ? `${current} ${value}` : value;
|
|
314
|
+
if (stripAnsi2(next).length > width && current) {
|
|
315
|
+
lines.push(current);
|
|
316
|
+
current = value;
|
|
317
|
+
} else {
|
|
318
|
+
current = next;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (current) {
|
|
322
|
+
lines.push(current);
|
|
323
|
+
}
|
|
324
|
+
return lines;
|
|
325
|
+
}
|
|
326
|
+
function Footer({ availableProviderCount, branch, extensionStatuses, snapshot, theme }) {
|
|
327
|
+
const cwdLineParts = [shortenPath(snapshot.cwd)];
|
|
328
|
+
if (branch) {
|
|
329
|
+
cwdLineParts.push(`(${toDisplayText(branch)})`);
|
|
330
|
+
}
|
|
331
|
+
if (snapshot.sessionName) {
|
|
332
|
+
cwdLineParts.push(`\u2022 ${snapshot.sessionName}`);
|
|
333
|
+
}
|
|
334
|
+
const statsParts = [];
|
|
335
|
+
if (snapshot.stats.tokens.input > 0) statsParts.push(`\u2191${formatTokens(snapshot.stats.tokens.input)}`);
|
|
336
|
+
if (snapshot.stats.tokens.output > 0) statsParts.push(`\u2193${formatTokens(snapshot.stats.tokens.output)}`);
|
|
337
|
+
if (snapshot.stats.tokens.cacheRead > 0) statsParts.push(`R${formatTokens(snapshot.stats.tokens.cacheRead)}`);
|
|
338
|
+
if (snapshot.stats.tokens.cacheWrite > 0) statsParts.push(`W${formatTokens(snapshot.stats.tokens.cacheWrite)}`);
|
|
339
|
+
if (snapshot.stats.cost > 0) statsParts.push(`$${snapshot.stats.cost.toFixed(3)}`);
|
|
340
|
+
let contextPart = snapshot.contextUsage ? `ctx:${snapshot.contextUsage.percent.toFixed(1)}%/${formatTokens(snapshot.contextUsage.contextWindow)}` : void 0;
|
|
341
|
+
if (contextPart && snapshot.autoCompactEnabled) {
|
|
342
|
+
contextPart += " (auto)";
|
|
343
|
+
}
|
|
344
|
+
if (contextPart) {
|
|
345
|
+
if ((snapshot.contextUsage?.percent ?? 0) > 90) {
|
|
346
|
+
statsParts.push(toDisplayText(theme.color("error", contextPart)));
|
|
347
|
+
} else if ((snapshot.contextUsage?.percent ?? 0) > 70) {
|
|
348
|
+
statsParts.push(toDisplayText(theme.color("warning", contextPart)));
|
|
349
|
+
} else {
|
|
350
|
+
statsParts.push(contextPart);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
const modelParts = [
|
|
354
|
+
snapshot.model ? `${toDisplayText(snapshot.model.provider)}/${toDisplayText(snapshot.model.id)}` : "no-model",
|
|
355
|
+
`thinking:${toDisplayText(snapshot.thinkingLevel)}`,
|
|
356
|
+
snapshot.pendingMessageCount > 0 ? `pending:${snapshot.pendingMessageCount}` : void 0,
|
|
357
|
+
snapshot.pendingToolCallCount > 0 ? `tools:${snapshot.pendingToolCallCount}` : void 0,
|
|
358
|
+
availableProviderCount > 1 ? `providers:${availableProviderCount}` : void 0
|
|
359
|
+
];
|
|
360
|
+
const statusValues = Array.from(extensionStatuses?.entries() ?? []).sort(([left], [right]) => left.localeCompare(right)).map(([key, text]) => sanitizeStatusText(`${key}: ${text}`)).filter(Boolean);
|
|
361
|
+
const width = Math.max(40, (process.stdout.columns ?? 80) - 2);
|
|
362
|
+
const cwdLine = cwdLineParts.join(" ");
|
|
363
|
+
const statsLine = statsParts.join(" ");
|
|
364
|
+
const modelLine = modelParts.filter(Boolean).join(" | ");
|
|
365
|
+
const statusLines = chunkLines(statusValues, width);
|
|
366
|
+
const mutedColor = typeof theme.colors.muted === "string" && theme.colors.muted.trim().length > 0 ? theme.colors.muted : "gray";
|
|
367
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
368
|
+
/* @__PURE__ */ jsx(Text, { color: mutedColor, children: cwdLine }),
|
|
369
|
+
/* @__PURE__ */ jsxs(Box, { justifyContent: "space-between", children: [
|
|
370
|
+
/* @__PURE__ */ jsx(Text, { color: mutedColor, children: statsLine }),
|
|
371
|
+
/* @__PURE__ */ jsx(Text, { color: mutedColor, children: modelLine })
|
|
372
|
+
] }),
|
|
373
|
+
statusLines.map((line, index) => /* @__PURE__ */ jsx(Text, { color: mutedColor, children: line }, `footer-status:${index}`))
|
|
374
|
+
] });
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// src/react-ink/utils/message-groups.ts
|
|
378
|
+
function parseSkillBlock(text) {
|
|
379
|
+
const match = text.match(/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/);
|
|
380
|
+
if (!match) return null;
|
|
381
|
+
return {
|
|
382
|
+
name: match[1] ?? "",
|
|
383
|
+
location: match[2] ?? "",
|
|
384
|
+
content: match[3] ?? "",
|
|
385
|
+
userMessage: match[4]?.trim() || void 0
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function isTextContent(value) {
|
|
389
|
+
return typeof value === "object" && value !== null && value.type === "text";
|
|
390
|
+
}
|
|
391
|
+
function isImageContent(value) {
|
|
392
|
+
return typeof value === "object" && value !== null && value.type === "image";
|
|
393
|
+
}
|
|
394
|
+
function isThinkingContent(value) {
|
|
395
|
+
return typeof value === "object" && value !== null && value.type === "thinking";
|
|
396
|
+
}
|
|
397
|
+
function isToolCall(value) {
|
|
398
|
+
return typeof value === "object" && value !== null && value.type === "toolCall";
|
|
399
|
+
}
|
|
400
|
+
function previewText(value, maxLength = 88) {
|
|
401
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
402
|
+
if (normalized.length <= maxLength) return normalized;
|
|
403
|
+
return `${normalized.slice(0, maxLength - 1)}...`;
|
|
404
|
+
}
|
|
405
|
+
function safeStringify(value) {
|
|
406
|
+
if (value === void 0) return "";
|
|
407
|
+
if (typeof value === "string") return value;
|
|
408
|
+
try {
|
|
409
|
+
const serialized = JSON.stringify(value, null, 2);
|
|
410
|
+
return typeof serialized === "string" ? serialized : "";
|
|
411
|
+
} catch {
|
|
412
|
+
return String(value);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
function parseJsonString(value) {
|
|
416
|
+
const trimmed = value.trim();
|
|
417
|
+
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
418
|
+
return void 0;
|
|
419
|
+
}
|
|
420
|
+
try {
|
|
421
|
+
return JSON.parse(trimmed);
|
|
422
|
+
} catch {
|
|
423
|
+
return void 0;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function extractStructuredText(value, showImages, seen = /* @__PURE__ */ new WeakSet()) {
|
|
427
|
+
if (value == null) {
|
|
428
|
+
return [];
|
|
429
|
+
}
|
|
430
|
+
if (typeof value === "string") {
|
|
431
|
+
const parsed = parseJsonString(value);
|
|
432
|
+
if (parsed !== void 0) {
|
|
433
|
+
const extracted = extractStructuredText(parsed, showImages, seen);
|
|
434
|
+
if (extracted.length > 0) {
|
|
435
|
+
return extracted;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return value.trim() ? [value] : [];
|
|
439
|
+
}
|
|
440
|
+
if (Array.isArray(value)) {
|
|
441
|
+
return value.flatMap((item) => extractStructuredText(item, showImages, seen));
|
|
442
|
+
}
|
|
443
|
+
if (typeof value !== "object") {
|
|
444
|
+
return [];
|
|
445
|
+
}
|
|
446
|
+
const record = value;
|
|
447
|
+
if (seen.has(record)) {
|
|
448
|
+
return [];
|
|
449
|
+
}
|
|
450
|
+
seen.add(record);
|
|
451
|
+
if (isTextContent(record)) {
|
|
452
|
+
return extractStructuredText(record.text, showImages, seen);
|
|
453
|
+
}
|
|
454
|
+
if (isImageContent(record)) {
|
|
455
|
+
return showImages ? [`[image: ${record.mimeType}]`] : [];
|
|
456
|
+
}
|
|
457
|
+
if ("content" in record) {
|
|
458
|
+
const extracted = extractStructuredText(record.content, showImages, seen);
|
|
459
|
+
if (extracted.length > 0) {
|
|
460
|
+
return extracted;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if ("details" in record) {
|
|
464
|
+
const extracted = extractStructuredText(record.details, showImages, seen);
|
|
465
|
+
if (extracted.length > 0) {
|
|
466
|
+
return extracted;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
for (const key of ["text", "output", "stdout", "stderr", "message", "summary"]) {
|
|
470
|
+
if (!(key in record)) {
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
const extracted = extractStructuredText(record[key], showImages, seen);
|
|
474
|
+
if (extracted.length > 0) {
|
|
475
|
+
return extracted;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return [];
|
|
479
|
+
}
|
|
480
|
+
function extractToolText(value, showImages) {
|
|
481
|
+
if (value == null) {
|
|
482
|
+
return "";
|
|
483
|
+
}
|
|
484
|
+
const extracted = extractStructuredText(value, showImages).map((part) => part.trimEnd()).filter((part) => part.length > 0);
|
|
485
|
+
if (extracted.length > 0) {
|
|
486
|
+
return extracted.join("\n").trim();
|
|
487
|
+
}
|
|
488
|
+
const fallback = safeStringify(value).trim();
|
|
489
|
+
return fallback === "{}" ? "" : fallback;
|
|
490
|
+
}
|
|
491
|
+
function previewMultiline(value, options = {}) {
|
|
492
|
+
const { maxChars = 800, maxLines = 6 } = options;
|
|
493
|
+
const normalized = value.replace(/\r\n/g, "\n").trim();
|
|
494
|
+
if (!normalized) {
|
|
495
|
+
return "";
|
|
496
|
+
}
|
|
497
|
+
const lines = normalized.split("\n");
|
|
498
|
+
const clippedLines = lines.slice(0, maxLines);
|
|
499
|
+
let preview = clippedLines.join("\n");
|
|
500
|
+
let truncated = lines.length > maxLines;
|
|
501
|
+
if (preview.length > maxChars) {
|
|
502
|
+
preview = `${preview.slice(0, Math.max(0, maxChars - 1)).trimEnd()}\u2026`;
|
|
503
|
+
truncated = true;
|
|
504
|
+
}
|
|
505
|
+
if (truncated) {
|
|
506
|
+
return `${preview}
|
|
507
|
+
...`;
|
|
508
|
+
}
|
|
509
|
+
return preview;
|
|
510
|
+
}
|
|
511
|
+
function formatUserContent(content, showImages) {
|
|
512
|
+
if (typeof content === "string") {
|
|
513
|
+
return content;
|
|
514
|
+
}
|
|
515
|
+
const lines = [];
|
|
516
|
+
for (const part of content) {
|
|
517
|
+
if (isTextContent(part)) lines.push(part.text);
|
|
518
|
+
if (showImages && isImageContent(part)) lines.push(`[image: ${part.mimeType}]`);
|
|
519
|
+
}
|
|
520
|
+
return lines.join("\n").trim();
|
|
521
|
+
}
|
|
522
|
+
function splitAssistantMessage(message, showThinking) {
|
|
523
|
+
const textParts = [];
|
|
524
|
+
const thinkingParts = [];
|
|
525
|
+
const toolCalls = [];
|
|
526
|
+
for (const part of message.content) {
|
|
527
|
+
if (isTextContent(part)) {
|
|
528
|
+
textParts.push(part.text);
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
if (showThinking && isThinkingContent(part)) {
|
|
532
|
+
thinkingParts.push(part.thinking);
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
if (isToolCall(part)) {
|
|
536
|
+
toolCalls.push(part);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
text: textParts.join(""),
|
|
541
|
+
thinking: thinkingParts,
|
|
542
|
+
toolCalls
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
function formatToolCall(toolCall) {
|
|
546
|
+
const args = Object.keys(toolCall.arguments ?? {}).length > 0 ? safeStringify(toolCall.arguments) : "{}";
|
|
547
|
+
return `${toolCall.name}
|
|
548
|
+
${previewMultiline(args, { maxLines: 8, maxChars: 1600 })}`;
|
|
549
|
+
}
|
|
550
|
+
function formatToolResult(message, showImages) {
|
|
551
|
+
const contentText = extractToolText(message.content, showImages);
|
|
552
|
+
if (contentText) {
|
|
553
|
+
return contentText;
|
|
554
|
+
}
|
|
555
|
+
if (message.details !== void 0) {
|
|
556
|
+
return extractToolText(message.details, showImages);
|
|
557
|
+
}
|
|
558
|
+
return "";
|
|
559
|
+
}
|
|
560
|
+
function formatCustomContent(content, showImages) {
|
|
561
|
+
if (typeof content === "string") return content;
|
|
562
|
+
return content.map((part) => {
|
|
563
|
+
if (isTextContent(part)) return part.text;
|
|
564
|
+
if (showImages && isImageContent(part)) return `[image: ${part.mimeType}]`;
|
|
565
|
+
return "";
|
|
566
|
+
}).filter(Boolean).join("\n");
|
|
567
|
+
}
|
|
568
|
+
function formatMessageTimestamp(timestamp) {
|
|
569
|
+
return new Date(timestamp).toLocaleTimeString([], {
|
|
570
|
+
hour: "2-digit",
|
|
571
|
+
minute: "2-digit"
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function extractMessagePreview(message) {
|
|
575
|
+
switch (message.role) {
|
|
576
|
+
case "user":
|
|
577
|
+
return previewText(formatUserContent(message.content, true));
|
|
578
|
+
case "assistant":
|
|
579
|
+
return previewText(splitAssistantMessage(message, false).text);
|
|
580
|
+
case "toolResult":
|
|
581
|
+
return previewText(formatToolResult(message, true));
|
|
582
|
+
case "bashExecution":
|
|
583
|
+
return previewText(`${message.command} ${message.output}`.trim());
|
|
584
|
+
case "branchSummary":
|
|
585
|
+
case "compactionSummary":
|
|
586
|
+
return previewText(message.summary);
|
|
587
|
+
case "custom":
|
|
588
|
+
return previewText(formatCustomContent(message.content, true));
|
|
589
|
+
default:
|
|
590
|
+
return previewText(safeStringify(message));
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
function parseSkillInvocation(content) {
|
|
594
|
+
const parsed = parseSkillBlock(content);
|
|
595
|
+
if (!parsed) return null;
|
|
596
|
+
return {
|
|
597
|
+
name: parsed.name,
|
|
598
|
+
location: parsed.location,
|
|
599
|
+
userMessage: parsed.userMessage
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// src/react-host/index.ts
|
|
604
|
+
var React = await loadHostReact();
|
|
605
|
+
var Fragment2 = React.Fragment;
|
|
606
|
+
var createElement = React.createElement;
|
|
607
|
+
var useEffect = React.useEffect;
|
|
608
|
+
var useMemo = React.useMemo;
|
|
609
|
+
var useState = React.useState;
|
|
610
|
+
|
|
611
|
+
// src/react-ink/markdown/format-token.ts
|
|
612
|
+
import chalk2 from "chalk";
|
|
613
|
+
import { marked } from "marked";
|
|
614
|
+
import stripAnsi3 from "strip-ansi";
|
|
615
|
+
|
|
616
|
+
// src/ui/utils.ts
|
|
617
|
+
import { eastAsianWidth } from "get-east-asian-width";
|
|
618
|
+
var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
619
|
+
var TextWidthCalculator = class {
|
|
620
|
+
getWidth(text) {
|
|
621
|
+
return visibleWidth(text);
|
|
622
|
+
}
|
|
623
|
+
clearCache() {
|
|
624
|
+
widthCache.clear();
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
var textWidthCalculator = new TextWidthCalculator();
|
|
628
|
+
function looksLikeEmojiCandidate(segment) {
|
|
629
|
+
const cp = segment.codePointAt(0);
|
|
630
|
+
return cp >= 126976 && cp <= 130047 || // pictographs and emoji proper
|
|
631
|
+
cp >= 8960 && cp <= 9215 || // miscellaneous technical glyphs
|
|
632
|
+
cp >= 9728 && cp <= 10175 || // assorted symbols and dingbats
|
|
633
|
+
cp >= 11088 && cp <= 11093 || // a few star/circle characters
|
|
634
|
+
segment.includes("\uFE0F") || // carries VS16, the emoji-presentation selector
|
|
635
|
+
segment.length > 2;
|
|
636
|
+
}
|
|
637
|
+
function createUnicodeRegex(vPattern, uFallback) {
|
|
638
|
+
try {
|
|
639
|
+
return new RegExp(vPattern, "v");
|
|
640
|
+
} catch {
|
|
641
|
+
return new RegExp(uFallback, "u");
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
var zeroWidthRegex = createUnicodeRegex(
|
|
645
|
+
"^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark}|\\p{Surrogate})+$",
|
|
646
|
+
"^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark}|\\p{Surrogate})+$"
|
|
647
|
+
);
|
|
648
|
+
var leadingNonPrintingRegex = createUnicodeRegex(
|
|
649
|
+
"^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+",
|
|
650
|
+
"^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+"
|
|
651
|
+
);
|
|
652
|
+
var rgiEmojiRegex = createUnicodeRegex("^\\p{RGI_Emoji}$", "^\\p{Extended_Pictographic}$");
|
|
653
|
+
var AnsiStripper = {
|
|
654
|
+
strip(text) {
|
|
655
|
+
if (!text.includes("\x1B")) {
|
|
656
|
+
return text;
|
|
657
|
+
}
|
|
658
|
+
let cleaned = text;
|
|
659
|
+
cleaned = cleaned.replace(/\x1b\[[0-9;]*[mGKHJ]/g, "");
|
|
660
|
+
cleaned = cleaned.replace(/\x1b\]8;;[^\x07]*\x07/g, "");
|
|
661
|
+
cleaned = cleaned.replace(/\x1b_[^\x07\x1b]*(?:\x07|\x1b\\)/g, "");
|
|
662
|
+
return cleaned;
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
var WIDTH_CACHE_SIZE = 512;
|
|
666
|
+
var widthCache = /* @__PURE__ */ new Map();
|
|
667
|
+
function measureClusterWidth(segment) {
|
|
668
|
+
if (zeroWidthRegex.test(segment)) {
|
|
669
|
+
return 0;
|
|
670
|
+
}
|
|
671
|
+
if (looksLikeEmojiCandidate(segment) && rgiEmojiRegex.test(segment)) {
|
|
672
|
+
return 2;
|
|
673
|
+
}
|
|
674
|
+
const base = segment.replace(leadingNonPrintingRegex, "");
|
|
675
|
+
const cp = base.codePointAt(0);
|
|
676
|
+
if (cp === void 0) {
|
|
677
|
+
return 0;
|
|
678
|
+
}
|
|
679
|
+
let width = eastAsianWidth(cp);
|
|
680
|
+
if (segment.length > 1) {
|
|
681
|
+
for (const char of segment.slice(1)) {
|
|
682
|
+
const c = char.codePointAt(0);
|
|
683
|
+
if (c >= 65280 && c <= 65519) {
|
|
684
|
+
width += eastAsianWidth(c);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
return width;
|
|
689
|
+
}
|
|
690
|
+
function visibleWidth(str) {
|
|
691
|
+
if (str.length === 0) {
|
|
692
|
+
return 0;
|
|
693
|
+
}
|
|
694
|
+
let isPureAscii = true;
|
|
695
|
+
for (let i = 0; i < str.length; i++) {
|
|
696
|
+
const code = str.charCodeAt(i);
|
|
697
|
+
if (code < 32 || code > 126) {
|
|
698
|
+
isPureAscii = false;
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if (isPureAscii) {
|
|
703
|
+
return str.length;
|
|
704
|
+
}
|
|
705
|
+
const cached = widthCache.get(str);
|
|
706
|
+
if (cached !== void 0) {
|
|
707
|
+
return cached;
|
|
708
|
+
}
|
|
709
|
+
let clean = str;
|
|
710
|
+
if (str.includes(" ")) {
|
|
711
|
+
clean = clean.replace(/\t/g, " ");
|
|
712
|
+
}
|
|
713
|
+
clean = AnsiStripper.strip(clean);
|
|
714
|
+
let width = 0;
|
|
715
|
+
for (const { segment } of segmenter.segment(clean)) {
|
|
716
|
+
width += measureClusterWidth(segment);
|
|
717
|
+
}
|
|
718
|
+
if (widthCache.size >= WIDTH_CACHE_SIZE) {
|
|
719
|
+
const firstKey = widthCache.keys().next().value;
|
|
720
|
+
if (firstKey !== void 0) {
|
|
721
|
+
widthCache.delete(firstKey);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
widthCache.set(str, width);
|
|
725
|
+
return width;
|
|
726
|
+
}
|
|
727
|
+
function extractAnsiCode(str, pos) {
|
|
728
|
+
if (pos >= str.length || str[pos] !== "\x1B") return null;
|
|
729
|
+
const next = str[pos + 1];
|
|
730
|
+
if (next === "[") {
|
|
731
|
+
let j = pos + 2;
|
|
732
|
+
while (j < str.length && !/[mGKHJ]/.test(str[j])) j++;
|
|
733
|
+
if (j < str.length) return { code: str.substring(pos, j + 1), length: j + 1 - pos };
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
if (next === "]") {
|
|
737
|
+
let j = pos + 2;
|
|
738
|
+
while (j < str.length) {
|
|
739
|
+
if (str[j] === "\x07") return { code: str.substring(pos, j + 1), length: j + 1 - pos };
|
|
740
|
+
if (str[j] === "\x1B" && str[j + 1] === "\\") return { code: str.substring(pos, j + 2), length: j + 2 - pos };
|
|
741
|
+
j++;
|
|
742
|
+
}
|
|
743
|
+
return null;
|
|
744
|
+
}
|
|
745
|
+
if (next === "_") {
|
|
746
|
+
let j = pos + 2;
|
|
747
|
+
while (j < str.length) {
|
|
748
|
+
if (str[j] === "\x07") return { code: str.substring(pos, j + 1), length: j + 1 - pos };
|
|
749
|
+
if (str[j] === "\x1B" && str[j + 1] === "\\") return { code: str.substring(pos, j + 2), length: j + 2 - pos };
|
|
750
|
+
j++;
|
|
751
|
+
}
|
|
752
|
+
return null;
|
|
753
|
+
}
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
var AnsiStateTracker = class {
|
|
757
|
+
// Each attribute is kept on its own flag, which lets us clear them one at a time.
|
|
758
|
+
_bold = false;
|
|
759
|
+
_dim = false;
|
|
760
|
+
italic = false;
|
|
761
|
+
underline = false;
|
|
762
|
+
blink = false;
|
|
763
|
+
inverse = false;
|
|
764
|
+
hidden = false;
|
|
765
|
+
strikethrough = false;
|
|
766
|
+
_colors = { fg: null, bg: null };
|
|
767
|
+
process(ansiCode) {
|
|
768
|
+
if (!ansiCode.endsWith("m")) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
const match = ansiCode.match(/\x1b\[([\d;]*)m/);
|
|
772
|
+
if (!match) return;
|
|
773
|
+
const params = match[1];
|
|
774
|
+
if (params === "" || params === "0") {
|
|
775
|
+
this.reset();
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const parts = params.split(";");
|
|
779
|
+
let i = 0;
|
|
780
|
+
while (i < parts.length) {
|
|
781
|
+
const code = Number.parseInt(parts[i] ?? "", 10);
|
|
782
|
+
if (Number.isNaN(code)) {
|
|
783
|
+
i++;
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
const consumed = this.tryConsumeColorCode(parts, i, code);
|
|
787
|
+
if (consumed > 0) {
|
|
788
|
+
i += consumed;
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
this.applyStandardCode(code);
|
|
792
|
+
i++;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
tryConsumeColorCode(parts, index, code) {
|
|
796
|
+
if (code !== 38 && code !== 48) {
|
|
797
|
+
return 0;
|
|
798
|
+
}
|
|
799
|
+
if (parts[index + 1] === "5" && parts[index + 2] !== void 0) {
|
|
800
|
+
const colorCode = `${parts[index]};${parts[index + 1]};${parts[index + 2]}`;
|
|
801
|
+
if (code === 38) {
|
|
802
|
+
this._colors.fg = colorCode;
|
|
803
|
+
} else {
|
|
804
|
+
this._colors.bg = colorCode;
|
|
805
|
+
}
|
|
806
|
+
return 3;
|
|
807
|
+
}
|
|
808
|
+
if (parts[index + 1] === "2" && parts[index + 4] !== void 0) {
|
|
809
|
+
const colorCode = `${parts[index]};${parts[index + 1]};${parts[index + 2]};${parts[index + 3]};${parts[index + 4]}`;
|
|
810
|
+
if (code === 38) {
|
|
811
|
+
this._colors.fg = colorCode;
|
|
812
|
+
} else {
|
|
813
|
+
this._colors.bg = colorCode;
|
|
814
|
+
}
|
|
815
|
+
return 5;
|
|
816
|
+
}
|
|
817
|
+
return 0;
|
|
818
|
+
}
|
|
819
|
+
applyStandardCode(code) {
|
|
820
|
+
switch (code) {
|
|
821
|
+
case 0:
|
|
822
|
+
this.reset();
|
|
823
|
+
return;
|
|
824
|
+
case 1:
|
|
825
|
+
this._bold = true;
|
|
826
|
+
return;
|
|
827
|
+
case 2:
|
|
828
|
+
this._dim = true;
|
|
829
|
+
return;
|
|
830
|
+
case 3:
|
|
831
|
+
this.italic = true;
|
|
832
|
+
return;
|
|
833
|
+
case 4:
|
|
834
|
+
this.underline = true;
|
|
835
|
+
return;
|
|
836
|
+
case 5:
|
|
837
|
+
this.blink = true;
|
|
838
|
+
return;
|
|
839
|
+
case 7:
|
|
840
|
+
this.inverse = true;
|
|
841
|
+
return;
|
|
842
|
+
case 8:
|
|
843
|
+
this.hidden = true;
|
|
844
|
+
return;
|
|
845
|
+
case 9:
|
|
846
|
+
this.strikethrough = true;
|
|
847
|
+
return;
|
|
848
|
+
case 21:
|
|
849
|
+
this._bold = false;
|
|
850
|
+
return;
|
|
851
|
+
case 22:
|
|
852
|
+
this._bold = false;
|
|
853
|
+
this._dim = false;
|
|
854
|
+
return;
|
|
855
|
+
case 23:
|
|
856
|
+
this.italic = false;
|
|
857
|
+
return;
|
|
858
|
+
case 24:
|
|
859
|
+
this.underline = false;
|
|
860
|
+
return;
|
|
861
|
+
case 25:
|
|
862
|
+
this.blink = false;
|
|
863
|
+
return;
|
|
864
|
+
case 27:
|
|
865
|
+
this.inverse = false;
|
|
866
|
+
return;
|
|
867
|
+
case 28:
|
|
868
|
+
this.hidden = false;
|
|
869
|
+
return;
|
|
870
|
+
case 29:
|
|
871
|
+
this.strikethrough = false;
|
|
872
|
+
return;
|
|
873
|
+
case 39:
|
|
874
|
+
this._colors.fg = null;
|
|
875
|
+
return;
|
|
876
|
+
case 49:
|
|
877
|
+
this._colors.bg = null;
|
|
878
|
+
return;
|
|
879
|
+
default:
|
|
880
|
+
if (code >= 30 && code <= 37 || code >= 90 && code <= 97) {
|
|
881
|
+
this._colors.fg = String(code);
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
if (code >= 40 && code <= 47 || code >= 100 && code <= 107) {
|
|
885
|
+
this._colors.bg = String(code);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
reset() {
|
|
890
|
+
this._bold = false;
|
|
891
|
+
this._dim = false;
|
|
892
|
+
this.italic = false;
|
|
893
|
+
this.underline = false;
|
|
894
|
+
this.blink = false;
|
|
895
|
+
this.inverse = false;
|
|
896
|
+
this.hidden = false;
|
|
897
|
+
this.strikethrough = false;
|
|
898
|
+
this._colors.fg = null;
|
|
899
|
+
this._colors.bg = null;
|
|
900
|
+
}
|
|
901
|
+
/** Wipe all tracked state so the instance can be reused. */
|
|
902
|
+
clear() {
|
|
903
|
+
this.reset();
|
|
904
|
+
}
|
|
905
|
+
getActiveCodes() {
|
|
906
|
+
const codes = [];
|
|
907
|
+
if (this._bold) codes.push("1");
|
|
908
|
+
if (this._dim) codes.push("2");
|
|
909
|
+
if (this.italic) codes.push("3");
|
|
910
|
+
if (this.underline) codes.push("4");
|
|
911
|
+
if (this.blink) codes.push("5");
|
|
912
|
+
if (this.inverse) codes.push("7");
|
|
913
|
+
if (this.hidden) codes.push("8");
|
|
914
|
+
if (this.strikethrough) codes.push("9");
|
|
915
|
+
if (this._colors.fg) codes.push(this._colors.fg);
|
|
916
|
+
if (this._colors.bg) codes.push(this._colors.bg);
|
|
917
|
+
if (codes.length === 0) return "";
|
|
918
|
+
return `\x1B[${codes.join(";")}m`;
|
|
919
|
+
}
|
|
920
|
+
hasActiveCodes() {
|
|
921
|
+
return this._bold || this._dim || this.italic || this.underline || this.blink || this.inverse || this.hidden || this.strikethrough || this._colors.fg !== null || this._colors.bg !== null;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Produce the escape code needed to switch off any attribute that would
|
|
925
|
+
* otherwise smear into the padding at the end of a line. In practice that
|
|
926
|
+
* is just underline. Yields an empty string when nothing needs disabling.
|
|
927
|
+
*/
|
|
928
|
+
getLineEndReset() {
|
|
929
|
+
if (this.underline) {
|
|
930
|
+
return "\x1B[24m";
|
|
931
|
+
}
|
|
932
|
+
return "";
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
function mergeTextIntoTracker(text, tracker) {
|
|
936
|
+
let i = 0;
|
|
937
|
+
while (i < text.length) {
|
|
938
|
+
const ansiResult = extractAnsiCode(text, i);
|
|
939
|
+
if (ansiResult) {
|
|
940
|
+
tracker.process(ansiResult.code);
|
|
941
|
+
i += ansiResult.length;
|
|
942
|
+
} else {
|
|
943
|
+
i++;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
function tokenizeTextWithAnsi(text) {
|
|
948
|
+
const tokens = [];
|
|
949
|
+
let current = "";
|
|
950
|
+
let pendingAnsi = "";
|
|
951
|
+
let inWhitespace = false;
|
|
952
|
+
let i = 0;
|
|
953
|
+
while (i < text.length) {
|
|
954
|
+
const ansiResult = extractAnsiCode(text, i);
|
|
955
|
+
if (ansiResult) {
|
|
956
|
+
pendingAnsi += ansiResult.code;
|
|
957
|
+
i += ansiResult.length;
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
960
|
+
const char = text[i];
|
|
961
|
+
const charIsSpace = char === " ";
|
|
962
|
+
if (charIsSpace !== inWhitespace && current) {
|
|
963
|
+
tokens.push(current);
|
|
964
|
+
current = "";
|
|
965
|
+
}
|
|
966
|
+
if (pendingAnsi) {
|
|
967
|
+
current += pendingAnsi;
|
|
968
|
+
pendingAnsi = "";
|
|
969
|
+
}
|
|
970
|
+
inWhitespace = charIsSpace;
|
|
971
|
+
current += char;
|
|
972
|
+
i++;
|
|
973
|
+
}
|
|
974
|
+
if (pendingAnsi) {
|
|
975
|
+
current += pendingAnsi;
|
|
976
|
+
}
|
|
977
|
+
if (current) {
|
|
978
|
+
tokens.push(current);
|
|
979
|
+
}
|
|
980
|
+
return tokens;
|
|
981
|
+
}
|
|
982
|
+
var TextWrapper = class {
|
|
983
|
+
wrap(text, width) {
|
|
984
|
+
return wrapTextWithAnsi(text, width);
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
var textWrapper = new TextWrapper();
|
|
988
|
+
var TokenWrapEngine = {
|
|
989
|
+
wrap(tokens, width, tracker) {
|
|
990
|
+
const wrapped = [];
|
|
991
|
+
let currentLine = "";
|
|
992
|
+
let currentVisibleLength = 0;
|
|
993
|
+
for (const token of tokens) {
|
|
994
|
+
const tokenVisibleLength = visibleWidth(token);
|
|
995
|
+
const isWhitespace = token.trim() === "";
|
|
996
|
+
if (tokenVisibleLength > width && !isWhitespace) {
|
|
997
|
+
if (currentLine) {
|
|
998
|
+
const lineEndReset = tracker.getLineEndReset();
|
|
999
|
+
if (lineEndReset) {
|
|
1000
|
+
currentLine += lineEndReset;
|
|
1001
|
+
}
|
|
1002
|
+
wrapped.push(currentLine);
|
|
1003
|
+
currentLine = "";
|
|
1004
|
+
currentVisibleLength = 0;
|
|
1005
|
+
}
|
|
1006
|
+
const broken = splitLongToken(token, width, tracker);
|
|
1007
|
+
wrapped.push(...broken.slice(0, -1));
|
|
1008
|
+
currentLine = broken[broken.length - 1];
|
|
1009
|
+
currentVisibleLength = visibleWidth(currentLine);
|
|
1010
|
+
continue;
|
|
1011
|
+
}
|
|
1012
|
+
const totalNeeded = currentVisibleLength + tokenVisibleLength;
|
|
1013
|
+
if (totalNeeded > width && currentVisibleLength > 0) {
|
|
1014
|
+
let lineToWrap = currentLine.trimEnd();
|
|
1015
|
+
const lineEndReset = tracker.getLineEndReset();
|
|
1016
|
+
if (lineEndReset) {
|
|
1017
|
+
lineToWrap += lineEndReset;
|
|
1018
|
+
}
|
|
1019
|
+
wrapped.push(lineToWrap);
|
|
1020
|
+
if (isWhitespace) {
|
|
1021
|
+
currentLine = tracker.getActiveCodes();
|
|
1022
|
+
currentVisibleLength = 0;
|
|
1023
|
+
} else {
|
|
1024
|
+
currentLine = tracker.getActiveCodes() + token;
|
|
1025
|
+
currentVisibleLength = tokenVisibleLength;
|
|
1026
|
+
}
|
|
1027
|
+
} else {
|
|
1028
|
+
currentLine += token;
|
|
1029
|
+
currentVisibleLength += tokenVisibleLength;
|
|
1030
|
+
}
|
|
1031
|
+
mergeTextIntoTracker(token, tracker);
|
|
1032
|
+
}
|
|
1033
|
+
return { wrapped, currentLine, currentVisibleLength };
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
function wrapTextWithAnsi(text, width) {
|
|
1037
|
+
if (!text) {
|
|
1038
|
+
return [""];
|
|
1039
|
+
}
|
|
1040
|
+
const inputLines = text.split("\n");
|
|
1041
|
+
const result = [];
|
|
1042
|
+
const tracker = new AnsiStateTracker();
|
|
1043
|
+
for (const inputLine of inputLines) {
|
|
1044
|
+
const prefix = result.length > 0 ? tracker.getActiveCodes() : "";
|
|
1045
|
+
result.push(...wrapLinePreservingAnsi(prefix + inputLine, width));
|
|
1046
|
+
mergeTextIntoTracker(inputLine, tracker);
|
|
1047
|
+
}
|
|
1048
|
+
return result.length > 0 ? result : [""];
|
|
1049
|
+
}
|
|
1050
|
+
function wrapLinePreservingAnsi(line, width) {
|
|
1051
|
+
if (!line) {
|
|
1052
|
+
return [""];
|
|
1053
|
+
}
|
|
1054
|
+
const visibleLength = visibleWidth(line);
|
|
1055
|
+
if (visibleLength <= width) {
|
|
1056
|
+
return [line];
|
|
1057
|
+
}
|
|
1058
|
+
const tracker = new AnsiStateTracker();
|
|
1059
|
+
const tokens = tokenizeTextWithAnsi(line);
|
|
1060
|
+
const { wrapped, currentLine } = TokenWrapEngine.wrap(tokens, width, tracker);
|
|
1061
|
+
if (currentLine) {
|
|
1062
|
+
wrapped.push(currentLine);
|
|
1063
|
+
}
|
|
1064
|
+
return wrapped.length > 0 ? wrapped.map((segmentLine) => segmentLine.trimEnd()) : [""];
|
|
1065
|
+
}
|
|
1066
|
+
function splitLongToken(word, width, tracker) {
|
|
1067
|
+
const lines = [];
|
|
1068
|
+
let currentLine = tracker.getActiveCodes();
|
|
1069
|
+
let currentWidth = 0;
|
|
1070
|
+
let i = 0;
|
|
1071
|
+
const segments = [];
|
|
1072
|
+
while (i < word.length) {
|
|
1073
|
+
const ansiResult = extractAnsiCode(word, i);
|
|
1074
|
+
if (ansiResult) {
|
|
1075
|
+
segments.push({ type: "ansi", value: ansiResult.code });
|
|
1076
|
+
i += ansiResult.length;
|
|
1077
|
+
} else {
|
|
1078
|
+
let end = i;
|
|
1079
|
+
while (end < word.length) {
|
|
1080
|
+
const nextAnsi = extractAnsiCode(word, end);
|
|
1081
|
+
if (nextAnsi) break;
|
|
1082
|
+
end++;
|
|
1083
|
+
}
|
|
1084
|
+
const textPortion = word.slice(i, end);
|
|
1085
|
+
for (const seg of segmenter.segment(textPortion)) {
|
|
1086
|
+
segments.push({ type: "grapheme", value: seg.segment });
|
|
1087
|
+
}
|
|
1088
|
+
i = end;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
for (const seg of segments) {
|
|
1092
|
+
if (seg.type === "ansi") {
|
|
1093
|
+
currentLine += seg.value;
|
|
1094
|
+
tracker.process(seg.value);
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
const grapheme = seg.value;
|
|
1098
|
+
if (!grapheme) continue;
|
|
1099
|
+
const clusterWidth = visibleWidth(grapheme);
|
|
1100
|
+
if (currentWidth + clusterWidth > width) {
|
|
1101
|
+
const lineEndReset = tracker.getLineEndReset();
|
|
1102
|
+
if (lineEndReset) {
|
|
1103
|
+
currentLine += lineEndReset;
|
|
1104
|
+
}
|
|
1105
|
+
lines.push(currentLine);
|
|
1106
|
+
currentLine = tracker.getActiveCodes();
|
|
1107
|
+
currentWidth = 0;
|
|
1108
|
+
}
|
|
1109
|
+
currentLine += grapheme;
|
|
1110
|
+
currentWidth += clusterWidth;
|
|
1111
|
+
}
|
|
1112
|
+
if (currentLine) {
|
|
1113
|
+
lines.push(currentLine);
|
|
1114
|
+
}
|
|
1115
|
+
return lines.length > 0 ? lines : [""];
|
|
1116
|
+
}
|
|
1117
|
+
var pooledStyleTracker = new AnsiStateTracker();
|
|
1118
|
+
|
|
1119
|
+
// src/react-ink/markdown/format-token.ts
|
|
1120
|
+
var EOL = "\n";
|
|
1121
|
+
var BLOCKQUOTE_BAR = "\u2502";
|
|
1122
|
+
var markedConfigured = false;
|
|
1123
|
+
function configureMarked() {
|
|
1124
|
+
if (markedConfigured) {
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
markedConfigured = true;
|
|
1128
|
+
marked.use({
|
|
1129
|
+
tokenizer: {
|
|
1130
|
+
del() {
|
|
1131
|
+
return void 0;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
var TOKEN_CACHE_MAX = 500;
|
|
1137
|
+
var tokenCache = /* @__PURE__ */ new Map();
|
|
1138
|
+
var MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
|
|
1139
|
+
function hasMarkdownSyntax(text) {
|
|
1140
|
+
return MD_SYNTAX_RE.test(text.length > 500 ? text.slice(0, 500) : text);
|
|
1141
|
+
}
|
|
1142
|
+
function hashContent(content) {
|
|
1143
|
+
let hash = 2166136261;
|
|
1144
|
+
for (let i = 0; i < content.length; i++) {
|
|
1145
|
+
hash ^= content.charCodeAt(i);
|
|
1146
|
+
hash = Math.imul(hash, 16777619);
|
|
1147
|
+
}
|
|
1148
|
+
return (hash >>> 0).toString(36) + ":" + content.length.toString(36);
|
|
1149
|
+
}
|
|
1150
|
+
function cachedLexer(content) {
|
|
1151
|
+
configureMarked();
|
|
1152
|
+
if (!hasMarkdownSyntax(content)) {
|
|
1153
|
+
return [
|
|
1154
|
+
{
|
|
1155
|
+
type: "paragraph",
|
|
1156
|
+
raw: content,
|
|
1157
|
+
text: content,
|
|
1158
|
+
tokens: [{ type: "text", raw: content, text: content }]
|
|
1159
|
+
}
|
|
1160
|
+
];
|
|
1161
|
+
}
|
|
1162
|
+
const key = hashContent(content);
|
|
1163
|
+
const hit = tokenCache.get(key);
|
|
1164
|
+
if (hit) {
|
|
1165
|
+
tokenCache.delete(key);
|
|
1166
|
+
tokenCache.set(key, hit);
|
|
1167
|
+
return hit;
|
|
1168
|
+
}
|
|
1169
|
+
const tokens = marked.lexer(content);
|
|
1170
|
+
if (tokenCache.size >= TOKEN_CACHE_MAX) {
|
|
1171
|
+
const first = tokenCache.keys().next().value;
|
|
1172
|
+
if (first !== void 0) {
|
|
1173
|
+
tokenCache.delete(first);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
tokenCache.set(key, tokens);
|
|
1177
|
+
return tokens;
|
|
1178
|
+
}
|
|
1179
|
+
function formatToken(token, theme, highlight = null, listDepth = 0, orderedListNumber = null, parent = null) {
|
|
1180
|
+
switch (token.type) {
|
|
1181
|
+
case "blockquote": {
|
|
1182
|
+
const inner = (token.tokens ?? []).map((child) => formatToken(child, theme, highlight)).join("");
|
|
1183
|
+
const bar = theme.dim(BLOCKQUOTE_BAR);
|
|
1184
|
+
return inner.split(EOL).map((line) => stripAnsi3(line).trim() ? `${bar} ${chalk2.italic(line)}` : line).join(EOL);
|
|
1185
|
+
}
|
|
1186
|
+
case "code": {
|
|
1187
|
+
const codeToken = token;
|
|
1188
|
+
if (!highlight) {
|
|
1189
|
+
return codeToken.text + EOL;
|
|
1190
|
+
}
|
|
1191
|
+
let language = "plaintext";
|
|
1192
|
+
if (codeToken.lang && highlight.supportsLanguage(codeToken.lang)) {
|
|
1193
|
+
language = codeToken.lang;
|
|
1194
|
+
}
|
|
1195
|
+
return highlight.highlight(codeToken.text, { language }) + EOL;
|
|
1196
|
+
}
|
|
1197
|
+
case "codespan":
|
|
1198
|
+
return theme.role("codeInline", token.text);
|
|
1199
|
+
case "em":
|
|
1200
|
+
return chalk2.italic(
|
|
1201
|
+
(token.tokens ?? []).map((child) => formatToken(child, theme, highlight, 0, null, parent)).join("")
|
|
1202
|
+
);
|
|
1203
|
+
case "strong":
|
|
1204
|
+
return chalk2.bold(
|
|
1205
|
+
(token.tokens ?? []).map((child) => formatToken(child, theme, highlight, 0, null, parent)).join("")
|
|
1206
|
+
);
|
|
1207
|
+
case "heading": {
|
|
1208
|
+
const headingToken = token;
|
|
1209
|
+
const inner = (headingToken.tokens ?? []).map((child) => formatToken(child, theme, highlight)).join("");
|
|
1210
|
+
const colored = theme.role("heading", inner);
|
|
1211
|
+
if (headingToken.depth === 1) {
|
|
1212
|
+
return chalk2.bold.italic.underline(colored) + EOL + EOL;
|
|
1213
|
+
}
|
|
1214
|
+
return chalk2.bold(colored) + EOL + EOL;
|
|
1215
|
+
}
|
|
1216
|
+
case "hr":
|
|
1217
|
+
return "---";
|
|
1218
|
+
case "image":
|
|
1219
|
+
return token.href;
|
|
1220
|
+
case "link": {
|
|
1221
|
+
const linkToken = token;
|
|
1222
|
+
if (linkToken.href.startsWith("mailto:")) {
|
|
1223
|
+
return linkToken.href.replace(/^mailto:/, "");
|
|
1224
|
+
}
|
|
1225
|
+
const linkText = (linkToken.tokens ?? []).map((child) => formatToken(child, theme, highlight, 0, null, linkToken)).join("");
|
|
1226
|
+
const plainLinkText = stripAnsi3(linkText);
|
|
1227
|
+
const display = plainLinkText && plainLinkText !== linkToken.href ? linkText : linkToken.href;
|
|
1228
|
+
return `\x1B]8;;${linkToken.href}\x07${display}\x1B]8;;\x07`;
|
|
1229
|
+
}
|
|
1230
|
+
case "list": {
|
|
1231
|
+
const listToken = token;
|
|
1232
|
+
const start = typeof listToken.start === "number" ? listToken.start : Number(listToken.start) || 1;
|
|
1233
|
+
return listToken.items.map(
|
|
1234
|
+
(item, index) => formatToken(
|
|
1235
|
+
item,
|
|
1236
|
+
theme,
|
|
1237
|
+
highlight,
|
|
1238
|
+
listDepth,
|
|
1239
|
+
listToken.ordered ? start + index : null,
|
|
1240
|
+
listToken
|
|
1241
|
+
)
|
|
1242
|
+
).join("");
|
|
1243
|
+
}
|
|
1244
|
+
case "list_item":
|
|
1245
|
+
return (token.tokens ?? []).map(
|
|
1246
|
+
(child) => `${" ".repeat(listDepth)}${formatToken(child, theme, highlight, listDepth + 1, orderedListNumber, token)}`
|
|
1247
|
+
).join("");
|
|
1248
|
+
case "paragraph":
|
|
1249
|
+
return (token.tokens ?? []).map((child) => formatToken(child, theme, highlight)).join("") + EOL;
|
|
1250
|
+
case "space":
|
|
1251
|
+
case "br":
|
|
1252
|
+
return EOL;
|
|
1253
|
+
case "text": {
|
|
1254
|
+
const textToken = token;
|
|
1255
|
+
if (parent?.type === "link") {
|
|
1256
|
+
return textToken.text;
|
|
1257
|
+
}
|
|
1258
|
+
if (parent?.type === "list_item") {
|
|
1259
|
+
const marker = orderedListNumber === null ? "-" : `${getListNumber(listDepth, orderedListNumber)}.`;
|
|
1260
|
+
const body = textToken.tokens ? textToken.tokens.map((child) => formatToken(child, theme, highlight, listDepth, orderedListNumber, token)).join("") : textToken.text;
|
|
1261
|
+
return `${marker} ${body}${EOL}`;
|
|
1262
|
+
}
|
|
1263
|
+
return textToken.text;
|
|
1264
|
+
}
|
|
1265
|
+
case "escape":
|
|
1266
|
+
return token.text;
|
|
1267
|
+
case "table":
|
|
1268
|
+
case "def":
|
|
1269
|
+
case "del":
|
|
1270
|
+
case "html":
|
|
1271
|
+
return "";
|
|
1272
|
+
default:
|
|
1273
|
+
return "";
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
function numberToLetter(n) {
|
|
1277
|
+
let result = "";
|
|
1278
|
+
while (n > 0) {
|
|
1279
|
+
n--;
|
|
1280
|
+
result = String.fromCharCode(97 + n % 26) + result;
|
|
1281
|
+
n = Math.floor(n / 26);
|
|
1282
|
+
}
|
|
1283
|
+
return result;
|
|
1284
|
+
}
|
|
1285
|
+
var ROMAN_VALUES = [
|
|
1286
|
+
[1e3, "m"],
|
|
1287
|
+
[900, "cm"],
|
|
1288
|
+
[500, "d"],
|
|
1289
|
+
[400, "cd"],
|
|
1290
|
+
[100, "c"],
|
|
1291
|
+
[90, "xc"],
|
|
1292
|
+
[50, "l"],
|
|
1293
|
+
[40, "xl"],
|
|
1294
|
+
[10, "x"],
|
|
1295
|
+
[9, "ix"],
|
|
1296
|
+
[5, "v"],
|
|
1297
|
+
[4, "iv"],
|
|
1298
|
+
[1, "i"]
|
|
1299
|
+
];
|
|
1300
|
+
function numberToRoman(n) {
|
|
1301
|
+
let result = "";
|
|
1302
|
+
for (const [value, numeral] of ROMAN_VALUES) {
|
|
1303
|
+
while (n >= value) {
|
|
1304
|
+
result += numeral;
|
|
1305
|
+
n -= value;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
return result;
|
|
1309
|
+
}
|
|
1310
|
+
function getListNumber(listDepth, orderedListNumber) {
|
|
1311
|
+
switch (listDepth) {
|
|
1312
|
+
case 0:
|
|
1313
|
+
case 1:
|
|
1314
|
+
return orderedListNumber.toString();
|
|
1315
|
+
case 2:
|
|
1316
|
+
return numberToLetter(orderedListNumber);
|
|
1317
|
+
case 3:
|
|
1318
|
+
return numberToRoman(orderedListNumber);
|
|
1319
|
+
default:
|
|
1320
|
+
return orderedListNumber.toString();
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
function padAligned(content, displayWidth, targetWidth, align) {
|
|
1324
|
+
const padding = Math.max(0, targetWidth - displayWidth);
|
|
1325
|
+
if (align === "center") {
|
|
1326
|
+
const leftPad = Math.floor(padding / 2);
|
|
1327
|
+
return " ".repeat(leftPad) + content + " ".repeat(padding - leftPad);
|
|
1328
|
+
}
|
|
1329
|
+
if (align === "right") {
|
|
1330
|
+
return " ".repeat(padding) + content;
|
|
1331
|
+
}
|
|
1332
|
+
return content + " ".repeat(padding);
|
|
1333
|
+
}
|
|
1334
|
+
function stringWidth(text) {
|
|
1335
|
+
return visibleWidth(text);
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// src/react-ink/markdown/highlight.ts
|
|
1339
|
+
import { extname } from "node:path";
|
|
1340
|
+
import hljs from "highlight.js";
|
|
1341
|
+
function scopeToRole(scope) {
|
|
1342
|
+
const head = scope.split(".")[0] ?? scope;
|
|
1343
|
+
switch (head) {
|
|
1344
|
+
case "keyword":
|
|
1345
|
+
case "built_in":
|
|
1346
|
+
case "literal":
|
|
1347
|
+
case "operator":
|
|
1348
|
+
return "synKeyword";
|
|
1349
|
+
case "string":
|
|
1350
|
+
case "regexp":
|
|
1351
|
+
case "symbol":
|
|
1352
|
+
case "char":
|
|
1353
|
+
case "meta":
|
|
1354
|
+
return "synString";
|
|
1355
|
+
case "number":
|
|
1356
|
+
return "synNumber";
|
|
1357
|
+
case "comment":
|
|
1358
|
+
case "quote":
|
|
1359
|
+
return "synComment";
|
|
1360
|
+
case "type":
|
|
1361
|
+
case "class":
|
|
1362
|
+
case "title":
|
|
1363
|
+
case "tag":
|
|
1364
|
+
case "name":
|
|
1365
|
+
case "attr":
|
|
1366
|
+
case "attribute":
|
|
1367
|
+
case "selector":
|
|
1368
|
+
return "synType";
|
|
1369
|
+
default:
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
var HTML_ENTITIES = {
|
|
1374
|
+
"&": "&",
|
|
1375
|
+
"<": "<",
|
|
1376
|
+
">": ">",
|
|
1377
|
+
""": '"',
|
|
1378
|
+
"'": "'",
|
|
1379
|
+
"'": "'"
|
|
1380
|
+
};
|
|
1381
|
+
function decodeEntities(text) {
|
|
1382
|
+
return text.replace(/&(?:amp|lt|gt|quot|#x27|#39);/g, (match) => HTML_ENTITIES[match] ?? match);
|
|
1383
|
+
}
|
|
1384
|
+
function parseHljsHtml(html) {
|
|
1385
|
+
const nodes = [];
|
|
1386
|
+
const scopeStack = [];
|
|
1387
|
+
const tagRe = /<span class="hljs-([^"]+)">|<\/span>/g;
|
|
1388
|
+
let lastIndex = 0;
|
|
1389
|
+
let match;
|
|
1390
|
+
const pushText = (raw) => {
|
|
1391
|
+
if (!raw) return;
|
|
1392
|
+
const currentScope = scopeStack.length > 0 ? scopeStack[scopeStack.length - 1] : null;
|
|
1393
|
+
const scope = currentScope ? currentScope.split(/\s+/)[0].replace(/_$/, "") : null;
|
|
1394
|
+
nodes.push({ text: decodeEntities(raw), scope });
|
|
1395
|
+
};
|
|
1396
|
+
while ((match = tagRe.exec(html)) !== null) {
|
|
1397
|
+
pushText(html.slice(lastIndex, match.index));
|
|
1398
|
+
lastIndex = tagRe.lastIndex;
|
|
1399
|
+
if (match[0] === "</span>") {
|
|
1400
|
+
scopeStack.pop();
|
|
1401
|
+
} else if (match[1]) {
|
|
1402
|
+
scopeStack.push(match[1]);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
pushText(html.slice(lastIndex));
|
|
1406
|
+
return nodes;
|
|
1407
|
+
}
|
|
1408
|
+
function createHighlighter(theme) {
|
|
1409
|
+
return {
|
|
1410
|
+
supportsLanguage: (language) => {
|
|
1411
|
+
if (!language || language === "plaintext" || language === "text") {
|
|
1412
|
+
return false;
|
|
1413
|
+
}
|
|
1414
|
+
try {
|
|
1415
|
+
return hljs.getLanguage(language) !== void 0;
|
|
1416
|
+
} catch {
|
|
1417
|
+
return false;
|
|
1418
|
+
}
|
|
1419
|
+
},
|
|
1420
|
+
highlight: (code, options) => {
|
|
1421
|
+
const language = options.language;
|
|
1422
|
+
if (!language || language === "plaintext" || language === "text") {
|
|
1423
|
+
return code;
|
|
1424
|
+
}
|
|
1425
|
+
try {
|
|
1426
|
+
if (hljs.getLanguage(language) === void 0) {
|
|
1427
|
+
return code;
|
|
1428
|
+
}
|
|
1429
|
+
const { value } = hljs.highlight(code, { language, ignoreIllegals: true });
|
|
1430
|
+
return parseHljsHtml(value).map((node) => {
|
|
1431
|
+
const role = node.scope ? scopeToRole(node.scope) : null;
|
|
1432
|
+
return role ? theme.role(role, node.text) : node.text;
|
|
1433
|
+
}).join("");
|
|
1434
|
+
} catch {
|
|
1435
|
+
return code;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
function highlightByPath(code, filePath, theme) {
|
|
1441
|
+
const language = languageFromPath(filePath);
|
|
1442
|
+
if (!language) {
|
|
1443
|
+
return code;
|
|
1444
|
+
}
|
|
1445
|
+
const highlighter = createHighlighter(theme);
|
|
1446
|
+
if (!highlighter.supportsLanguage(language)) {
|
|
1447
|
+
return code;
|
|
1448
|
+
}
|
|
1449
|
+
return highlighter.highlight(code, { language });
|
|
1450
|
+
}
|
|
1451
|
+
var EXTENSION_LANGUAGES = {
|
|
1452
|
+
ts: "typescript",
|
|
1453
|
+
tsx: "typescript",
|
|
1454
|
+
mts: "typescript",
|
|
1455
|
+
cts: "typescript",
|
|
1456
|
+
js: "javascript",
|
|
1457
|
+
jsx: "javascript",
|
|
1458
|
+
mjs: "javascript",
|
|
1459
|
+
cjs: "javascript",
|
|
1460
|
+
py: "python",
|
|
1461
|
+
rb: "ruby",
|
|
1462
|
+
rs: "rust",
|
|
1463
|
+
go: "go",
|
|
1464
|
+
java: "java",
|
|
1465
|
+
kt: "kotlin",
|
|
1466
|
+
c: "c",
|
|
1467
|
+
h: "c",
|
|
1468
|
+
cc: "cpp",
|
|
1469
|
+
cpp: "cpp",
|
|
1470
|
+
hpp: "cpp",
|
|
1471
|
+
cs: "csharp",
|
|
1472
|
+
sh: "bash",
|
|
1473
|
+
bash: "bash",
|
|
1474
|
+
zsh: "bash",
|
|
1475
|
+
yml: "yaml",
|
|
1476
|
+
yaml: "yaml",
|
|
1477
|
+
json: "json",
|
|
1478
|
+
md: "markdown",
|
|
1479
|
+
html: "xml",
|
|
1480
|
+
xml: "xml",
|
|
1481
|
+
css: "css",
|
|
1482
|
+
scss: "scss",
|
|
1483
|
+
sql: "sql",
|
|
1484
|
+
toml: "ini",
|
|
1485
|
+
ini: "ini",
|
|
1486
|
+
php: "php",
|
|
1487
|
+
swift: "swift"
|
|
1488
|
+
};
|
|
1489
|
+
function languageFromPath(filePath) {
|
|
1490
|
+
const ext = extname(filePath).slice(1).toLowerCase();
|
|
1491
|
+
if (!ext) {
|
|
1492
|
+
return null;
|
|
1493
|
+
}
|
|
1494
|
+
const mapped = EXTENSION_LANGUAGES[ext];
|
|
1495
|
+
if (mapped) {
|
|
1496
|
+
return mapped;
|
|
1497
|
+
}
|
|
1498
|
+
try {
|
|
1499
|
+
return hljs.getLanguage(ext) !== void 0 ? ext : null;
|
|
1500
|
+
} catch {
|
|
1501
|
+
return null;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// src/react-ink/markdown/MarkdownTable.tsx
|
|
1506
|
+
import chalk3 from "chalk";
|
|
1507
|
+
import stripAnsi4 from "strip-ansi";
|
|
1508
|
+
var MIN_COLUMN_WIDTH = 3;
|
|
1509
|
+
var COLUMN_GAP = 2;
|
|
1510
|
+
function MarkdownTable({ token, theme, highlight = null }) {
|
|
1511
|
+
const formatCell = (tokens) => (tokens ?? []).map((child) => formatToken(child, theme, highlight)).join("");
|
|
1512
|
+
const displayWidth = (tokens) => stringWidth(stripAnsi4(formatCell(tokens)));
|
|
1513
|
+
const columnCount = token.header.length;
|
|
1514
|
+
const columnWidths = token.header.map((header, index) => {
|
|
1515
|
+
let max = displayWidth(header.tokens);
|
|
1516
|
+
for (const row of token.rows) {
|
|
1517
|
+
max = Math.max(max, displayWidth(row[index]?.tokens));
|
|
1518
|
+
}
|
|
1519
|
+
return Math.max(max, MIN_COLUMN_WIDTH);
|
|
1520
|
+
});
|
|
1521
|
+
const renderRow = (cells, key, bold) => /* @__PURE__ */ jsx(Box, { flexDirection: "row", children: columnWidths.map((width, index) => {
|
|
1522
|
+
const cell = cells[index];
|
|
1523
|
+
const content = formatCell(cell?.tokens);
|
|
1524
|
+
const visible = stringWidth(stripAnsi4(content));
|
|
1525
|
+
const align = token.align?.[index];
|
|
1526
|
+
const padded = padAligned(content, visible, width, align ?? "left");
|
|
1527
|
+
const styled = bold ? chalk3.bold(padded) : padded;
|
|
1528
|
+
const gap = index < columnCount - 1 ? " ".repeat(COLUMN_GAP) : "";
|
|
1529
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
1530
|
+
styled,
|
|
1531
|
+
gap
|
|
1532
|
+
] }, index);
|
|
1533
|
+
}) }, key);
|
|
1534
|
+
const separator = /* @__PURE__ */ jsx(Box, { flexDirection: "row", children: columnWidths.map((width, index) => {
|
|
1535
|
+
const gap = index < columnCount - 1 ? " ".repeat(COLUMN_GAP) : "";
|
|
1536
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
1537
|
+
theme.dim("-".repeat(width)),
|
|
1538
|
+
gap
|
|
1539
|
+
] }, index);
|
|
1540
|
+
}) });
|
|
1541
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
1542
|
+
renderRow(token.header, "header", true),
|
|
1543
|
+
separator,
|
|
1544
|
+
token.rows.map((row, rowIndex) => renderRow(row, `row-${rowIndex}`, false))
|
|
1545
|
+
] });
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
// src/react-ink/markdown/Markdown.tsx
|
|
1549
|
+
function stripPromptXMLTags(text) {
|
|
1550
|
+
return text.replace(/<\/?(?:system-reminder|prompt|context)[^>]*>/g, "");
|
|
1551
|
+
}
|
|
1552
|
+
function Markdown({ children, theme, highlightCode = true, dim = false }) {
|
|
1553
|
+
const highlight = useMemo(
|
|
1554
|
+
() => highlightCode ? createHighlighter(theme) : null,
|
|
1555
|
+
[highlightCode, theme]
|
|
1556
|
+
);
|
|
1557
|
+
const elements = useMemo(() => {
|
|
1558
|
+
configureMarked();
|
|
1559
|
+
const tokens = cachedLexer(stripPromptXMLTags(children));
|
|
1560
|
+
const out = [];
|
|
1561
|
+
let buffer = "";
|
|
1562
|
+
const flush = () => {
|
|
1563
|
+
if (buffer) {
|
|
1564
|
+
const text = buffer.replace(/\n+$/, "");
|
|
1565
|
+
if (text) {
|
|
1566
|
+
out.push(
|
|
1567
|
+
/* @__PURE__ */ jsx(Text, { children: dim ? theme.dim(text) : text }, out.length)
|
|
1568
|
+
);
|
|
1569
|
+
}
|
|
1570
|
+
buffer = "";
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
for (const token of tokens) {
|
|
1574
|
+
if (token.type === "table") {
|
|
1575
|
+
flush();
|
|
1576
|
+
out.push(
|
|
1577
|
+
/* @__PURE__ */ jsx(
|
|
1578
|
+
MarkdownTable,
|
|
1579
|
+
{
|
|
1580
|
+
token,
|
|
1581
|
+
theme,
|
|
1582
|
+
highlight
|
|
1583
|
+
},
|
|
1584
|
+
out.length
|
|
1585
|
+
)
|
|
1586
|
+
);
|
|
1587
|
+
} else {
|
|
1588
|
+
buffer += formatToken(token, theme, highlight);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
flush();
|
|
1592
|
+
return out;
|
|
1593
|
+
}, [children, dim, highlight, theme]);
|
|
1594
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: elements });
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// src/react-ink/utils/tool-display.ts
|
|
1598
|
+
import { homedir } from "node:os";
|
|
1599
|
+
|
|
1600
|
+
// src/react-ink/diff/structured.ts
|
|
1601
|
+
import { structuredPatch } from "diff";
|
|
1602
|
+
|
|
1603
|
+
// src/react-ink/diff/word-diff.ts
|
|
1604
|
+
import { diffWordsWithSpace } from "diff";
|
|
1605
|
+
var CHANGE_THRESHOLD = 0.4;
|
|
1606
|
+
function wordDiffLine(oldLine, newLine, side) {
|
|
1607
|
+
const lineText = side === "removed" ? oldLine : newLine;
|
|
1608
|
+
if (oldLine.length === 0 || newLine.length === 0) {
|
|
1609
|
+
return [{ text: lineText, changed: true }];
|
|
1610
|
+
}
|
|
1611
|
+
let changes;
|
|
1612
|
+
try {
|
|
1613
|
+
changes = diffWordsWithSpace(oldLine, newLine);
|
|
1614
|
+
} catch {
|
|
1615
|
+
return [{ text: lineText, changed: true }];
|
|
1616
|
+
}
|
|
1617
|
+
let changedChars = 0;
|
|
1618
|
+
let totalChars = 0;
|
|
1619
|
+
for (const change of changes) {
|
|
1620
|
+
totalChars += change.value.length;
|
|
1621
|
+
if (change.added || change.removed) {
|
|
1622
|
+
changedChars += change.value.length;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
const fraction = totalChars === 0 ? 0 : changedChars / totalChars;
|
|
1626
|
+
if (fraction > CHANGE_THRESHOLD) {
|
|
1627
|
+
return [{ text: lineText, changed: true }];
|
|
1628
|
+
}
|
|
1629
|
+
const spans = [];
|
|
1630
|
+
for (const change of changes) {
|
|
1631
|
+
const belongs = side === "removed" ? !change.added : !change.removed;
|
|
1632
|
+
if (!belongs) {
|
|
1633
|
+
continue;
|
|
1634
|
+
}
|
|
1635
|
+
spans.push({ text: change.value, changed: Boolean(change.added || change.removed) });
|
|
1636
|
+
}
|
|
1637
|
+
return spans.length > 0 ? spans : [{ text: lineText, changed: false }];
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/react-ink/diff/structured.ts
|
|
1641
|
+
var CONTEXT_LINES = 3;
|
|
1642
|
+
function buildStructuredDiff(oldStr, newStr, filePath = "") {
|
|
1643
|
+
if (oldStr === newStr) {
|
|
1644
|
+
return null;
|
|
1645
|
+
}
|
|
1646
|
+
let patch;
|
|
1647
|
+
try {
|
|
1648
|
+
patch = structuredPatch(filePath, filePath, oldStr, newStr, "", "", { context: CONTEXT_LINES });
|
|
1649
|
+
} catch {
|
|
1650
|
+
return null;
|
|
1651
|
+
}
|
|
1652
|
+
const hunks = [];
|
|
1653
|
+
let addedCount = 0;
|
|
1654
|
+
let removedCount = 0;
|
|
1655
|
+
for (const hunk of patch.hunks) {
|
|
1656
|
+
const lines = classifyHunkLines(hunk);
|
|
1657
|
+
for (const line of lines) {
|
|
1658
|
+
if (line.kind === "added") addedCount += 1;
|
|
1659
|
+
else if (line.kind === "removed") removedCount += 1;
|
|
1660
|
+
}
|
|
1661
|
+
if (lines.length > 0) {
|
|
1662
|
+
hunks.push({ oldStart: hunk.oldStart, newStart: hunk.newStart, lines });
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
if (hunks.length === 0) {
|
|
1666
|
+
return null;
|
|
1667
|
+
}
|
|
1668
|
+
return { hunks, addedCount, removedCount };
|
|
1669
|
+
}
|
|
1670
|
+
function classifyHunkLines(hunk) {
|
|
1671
|
+
const out = [];
|
|
1672
|
+
let oldNum = hunk.oldStart;
|
|
1673
|
+
let newNum = hunk.newStart;
|
|
1674
|
+
const rawLines = hunk.lines.filter((line) => !line.startsWith("\\"));
|
|
1675
|
+
let removedRun = [];
|
|
1676
|
+
let removedRunStart = -1;
|
|
1677
|
+
const flushPairing = (addedRun2) => {
|
|
1678
|
+
const pairs = Math.min(removedRun.length, addedRun2.length);
|
|
1679
|
+
for (let i = 0; i < pairs; i += 1) {
|
|
1680
|
+
const removed = removedRun[i];
|
|
1681
|
+
const added = addedRun2[i];
|
|
1682
|
+
removed.spans = wordDiffLine(removed.text, added.text, "removed");
|
|
1683
|
+
added.spans = wordDiffLine(removed.text, added.text, "added");
|
|
1684
|
+
}
|
|
1685
|
+
removedRun = [];
|
|
1686
|
+
removedRunStart = -1;
|
|
1687
|
+
};
|
|
1688
|
+
let addedRun = [];
|
|
1689
|
+
for (const raw of rawLines) {
|
|
1690
|
+
const marker = raw[0];
|
|
1691
|
+
const text = raw.slice(1);
|
|
1692
|
+
if (marker === "-") {
|
|
1693
|
+
if (addedRun.length > 0) {
|
|
1694
|
+
addedRun = [];
|
|
1695
|
+
}
|
|
1696
|
+
const line = { kind: "removed", oldLine: oldNum, text };
|
|
1697
|
+
out.push(line);
|
|
1698
|
+
if (removedRunStart === -1) removedRunStart = out.length - 1;
|
|
1699
|
+
removedRun.push(line);
|
|
1700
|
+
oldNum += 1;
|
|
1701
|
+
} else if (marker === "+") {
|
|
1702
|
+
const line = { kind: "added", newLine: newNum, text };
|
|
1703
|
+
out.push(line);
|
|
1704
|
+
addedRun.push(line);
|
|
1705
|
+
newNum += 1;
|
|
1706
|
+
} else {
|
|
1707
|
+
if (removedRun.length > 0 && addedRun.length > 0) {
|
|
1708
|
+
flushPairing(addedRun);
|
|
1709
|
+
}
|
|
1710
|
+
removedRun = [];
|
|
1711
|
+
removedRunStart = -1;
|
|
1712
|
+
addedRun = [];
|
|
1713
|
+
out.push({ kind: "context", oldLine: oldNum, newLine: newNum, text });
|
|
1714
|
+
oldNum += 1;
|
|
1715
|
+
newNum += 1;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
if (removedRun.length > 0 && addedRun.length > 0) {
|
|
1719
|
+
flushPairing(addedRun);
|
|
1720
|
+
}
|
|
1721
|
+
return out;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
// src/react-ink/utils/tool-display.ts
|
|
1725
|
+
function asRecord(value) {
|
|
1726
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
1727
|
+
}
|
|
1728
|
+
function asString(value) {
|
|
1729
|
+
return typeof value === "string" ? value : void 0;
|
|
1730
|
+
}
|
|
1731
|
+
function asNumber(value) {
|
|
1732
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1733
|
+
}
|
|
1734
|
+
function hasOutput(value) {
|
|
1735
|
+
return value !== void 0;
|
|
1736
|
+
}
|
|
1737
|
+
function shortenPath2(path2) {
|
|
1738
|
+
const home = homedir();
|
|
1739
|
+
return path2.startsWith(home) ? `~${path2.slice(home.length)}` : path2;
|
|
1740
|
+
}
|
|
1741
|
+
function titleCase(value) {
|
|
1742
|
+
return value.split(/[\s_-]+/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ");
|
|
1743
|
+
}
|
|
1744
|
+
function friendlyToolName(toolName) {
|
|
1745
|
+
switch (toolName) {
|
|
1746
|
+
case "ls":
|
|
1747
|
+
return "LS";
|
|
1748
|
+
case "read":
|
|
1749
|
+
return "Read";
|
|
1750
|
+
case "write":
|
|
1751
|
+
return "Write";
|
|
1752
|
+
case "edit":
|
|
1753
|
+
return "Edit";
|
|
1754
|
+
case "find":
|
|
1755
|
+
return "Find";
|
|
1756
|
+
case "grep":
|
|
1757
|
+
return "Grep";
|
|
1758
|
+
case "bash":
|
|
1759
|
+
return "Bash";
|
|
1760
|
+
case "task":
|
|
1761
|
+
return "Task";
|
|
1762
|
+
case "todoread":
|
|
1763
|
+
return "Todo Read";
|
|
1764
|
+
case "todowrite":
|
|
1765
|
+
return "Todo Write";
|
|
1766
|
+
default:
|
|
1767
|
+
return titleCase(toolName.replace(/^composio__/, "composio "));
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
function summarizeCommand(command) {
|
|
1771
|
+
return command ? previewText(command.replace(/\s+/g, " "), 88) : void 0;
|
|
1772
|
+
}
|
|
1773
|
+
function toolText(value, showImages = false) {
|
|
1774
|
+
return extractToolText(value, showImages).trim();
|
|
1775
|
+
}
|
|
1776
|
+
function containsImage(value) {
|
|
1777
|
+
if (Array.isArray(value)) {
|
|
1778
|
+
return value.some((item) => containsImage(item));
|
|
1779
|
+
}
|
|
1780
|
+
const record = asRecord(value);
|
|
1781
|
+
if (!record) {
|
|
1782
|
+
return false;
|
|
1783
|
+
}
|
|
1784
|
+
if (record.type === "image") {
|
|
1785
|
+
return true;
|
|
1786
|
+
}
|
|
1787
|
+
return Object.values(record).some((item) => containsImage(item));
|
|
1788
|
+
}
|
|
1789
|
+
function countMeaningfulLines(value) {
|
|
1790
|
+
if (!value?.trim()) {
|
|
1791
|
+
return 0;
|
|
1792
|
+
}
|
|
1793
|
+
return value.split(/\r?\n/).filter((line) => line.trim().length > 0).length;
|
|
1794
|
+
}
|
|
1795
|
+
function firstMeaningfulLine(value) {
|
|
1796
|
+
if (!value?.trim()) {
|
|
1797
|
+
return void 0;
|
|
1798
|
+
}
|
|
1799
|
+
return value.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
1800
|
+
}
|
|
1801
|
+
function clipBody(value, maxLines = 8, maxChars = 1400) {
|
|
1802
|
+
if (!value?.trim()) {
|
|
1803
|
+
return void 0;
|
|
1804
|
+
}
|
|
1805
|
+
return previewMultiline(value, { maxLines, maxChars });
|
|
1806
|
+
}
|
|
1807
|
+
function highlightedBody(body, filePath, theme) {
|
|
1808
|
+
if (!body || !theme || !filePath || languageFromPath(filePath) === null) {
|
|
1809
|
+
return { body };
|
|
1810
|
+
}
|
|
1811
|
+
return { body: highlightByPath(body, filePath, theme), preformatted: true };
|
|
1812
|
+
}
|
|
1813
|
+
function extractDetails(value) {
|
|
1814
|
+
return asRecord(asRecord(value)?.details);
|
|
1815
|
+
}
|
|
1816
|
+
function normalizeTodoStatus(value) {
|
|
1817
|
+
switch (value) {
|
|
1818
|
+
case "completed":
|
|
1819
|
+
case "in_progress":
|
|
1820
|
+
case "cancelled":
|
|
1821
|
+
case "pending":
|
|
1822
|
+
return value;
|
|
1823
|
+
default:
|
|
1824
|
+
return "pending";
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function normalizeTodoPriority(value) {
|
|
1828
|
+
switch (value) {
|
|
1829
|
+
case "high":
|
|
1830
|
+
case "medium":
|
|
1831
|
+
case "low":
|
|
1832
|
+
return value;
|
|
1833
|
+
default:
|
|
1834
|
+
return "medium";
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
function extractTodos(args, output) {
|
|
1838
|
+
const detailTodos = extractDetails(output)?.todos;
|
|
1839
|
+
const argTodos = asRecord(args)?.todos;
|
|
1840
|
+
const source = Array.isArray(detailTodos) ? detailTodos : Array.isArray(argTodos) ? argTodos : [];
|
|
1841
|
+
return source.map((todo) => {
|
|
1842
|
+
const record = asRecord(todo);
|
|
1843
|
+
const content = asString(record?.content)?.trim();
|
|
1844
|
+
if (!content) return void 0;
|
|
1845
|
+
return {
|
|
1846
|
+
content,
|
|
1847
|
+
priority: normalizeTodoPriority(record?.priority),
|
|
1848
|
+
status: normalizeTodoStatus(record?.status)
|
|
1849
|
+
};
|
|
1850
|
+
}).filter((todo) => Boolean(todo));
|
|
1851
|
+
}
|
|
1852
|
+
function formatTodos(todos) {
|
|
1853
|
+
if (todos.length === 0) return void 0;
|
|
1854
|
+
const lines = todos.slice(0, 6).map((todo) => {
|
|
1855
|
+
const statusLabel = todo.status === "completed" ? "[done]" : todo.status === "in_progress" ? "[doing]" : todo.status === "cancelled" ? "[skip]" : "[todo]";
|
|
1856
|
+
return `${statusLabel} ${todo.priority} ${todo.content}`;
|
|
1857
|
+
});
|
|
1858
|
+
if (todos.length > lines.length) {
|
|
1859
|
+
lines.push(`... ${todos.length - lines.length} more item(s)`);
|
|
1860
|
+
}
|
|
1861
|
+
return lines.join("\n");
|
|
1862
|
+
}
|
|
1863
|
+
function fallbackSummary(args, fallbackArgsText) {
|
|
1864
|
+
if (fallbackArgsText?.trim()) {
|
|
1865
|
+
return previewText(fallbackArgsText, 88);
|
|
1866
|
+
}
|
|
1867
|
+
const record = asRecord(args);
|
|
1868
|
+
if (!record) return void 0;
|
|
1869
|
+
return previewText(safeStringify(record), 88);
|
|
1870
|
+
}
|
|
1871
|
+
function fallbackBody(output, fallbackOutputText, showImages = false) {
|
|
1872
|
+
const extracted = toolText(output, showImages);
|
|
1873
|
+
if (extracted) {
|
|
1874
|
+
return clipBody(extracted);
|
|
1875
|
+
}
|
|
1876
|
+
return clipBody(fallbackOutputText);
|
|
1877
|
+
}
|
|
1878
|
+
function describeToolSource(source) {
|
|
1879
|
+
const { args, fallbackArgsText, fallbackOutputText, output, showImages = false, theme, toolName } = source;
|
|
1880
|
+
const argsRecord = asRecord(args);
|
|
1881
|
+
const details = extractDetails(output);
|
|
1882
|
+
const outputText = toolText(output, showImages);
|
|
1883
|
+
const hasResult = hasOutput(output);
|
|
1884
|
+
const title = friendlyToolName(toolName);
|
|
1885
|
+
switch (toolName) {
|
|
1886
|
+
case "read": {
|
|
1887
|
+
const rawPath = asString(argsRecord?.file_path) ?? asString(argsRecord?.path) ?? "";
|
|
1888
|
+
const offset = asNumber(argsRecord?.offset);
|
|
1889
|
+
const limit = asNumber(argsRecord?.limit);
|
|
1890
|
+
let summary = rawPath ? shortenPath2(rawPath) : void 0;
|
|
1891
|
+
if (summary && (offset !== void 0 || limit !== void 0)) {
|
|
1892
|
+
const start = offset ?? 1;
|
|
1893
|
+
const end = limit !== void 0 ? start + limit - 1 : void 0;
|
|
1894
|
+
summary += `:${start}${end ? `-${end}` : ""}`;
|
|
1895
|
+
}
|
|
1896
|
+
const responseSummary = containsImage(output) ? firstMeaningfulLine(outputText) ?? "Read image" : /unchanged/i.test(outputText) ? "Unchanged since last read" : countMeaningfulLines(outputText) > 0 ? `Read ${countMeaningfulLines(outputText)} ${countMeaningfulLines(outputText) === 1 ? "line" : "lines"}` : "Read file";
|
|
1897
|
+
const readBody = hasResult && !containsImage(output) ? highlightedBody(clipBody(outputText, 10, 1800), rawPath, theme) : { body: hasResult ? clipBody(outputText, 10, 1800) : void 0 };
|
|
1898
|
+
return {
|
|
1899
|
+
title,
|
|
1900
|
+
summary: hasResult ? responseSummary : summary,
|
|
1901
|
+
body: readBody.body,
|
|
1902
|
+
preformatted: readBody.preformatted,
|
|
1903
|
+
emptyText: "Reading file..."
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
case "write": {
|
|
1907
|
+
const rawPath = asString(argsRecord?.file_path) ?? asString(argsRecord?.path) ?? "";
|
|
1908
|
+
const content = asString(argsRecord?.content);
|
|
1909
|
+
const responseSummary = firstMeaningfulLine(outputText) ?? "Wrote file";
|
|
1910
|
+
const writeDiff = !hasResult && content !== void 0 && content.length > 0 ? buildStructuredDiff("", content, rawPath) ?? void 0 : void 0;
|
|
1911
|
+
const writeBody = hasResult ? { body: clipBody(outputText, 8, 1500) } : highlightedBody(clipBody(content, 8, 1500), rawPath, theme);
|
|
1912
|
+
return {
|
|
1913
|
+
title,
|
|
1914
|
+
summary: hasResult ? responseSummary : rawPath ? shortenPath2(rawPath) : void 0,
|
|
1915
|
+
body: writeDiff ? void 0 : writeBody.body,
|
|
1916
|
+
preformatted: writeDiff ? void 0 : writeBody.preformatted,
|
|
1917
|
+
diff: writeDiff,
|
|
1918
|
+
emptyText: "Preparing file write..."
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
case "edit": {
|
|
1922
|
+
const rawPath = asString(argsRecord?.file_path) ?? asString(argsRecord?.path) ?? "";
|
|
1923
|
+
const oldText = asString(argsRecord?.oldText);
|
|
1924
|
+
const newText = asString(argsRecord?.newText);
|
|
1925
|
+
const replacementPreview = oldText || newText ? clipBody(
|
|
1926
|
+
[
|
|
1927
|
+
oldText ? `- ${previewText(oldText, 90)}` : void 0,
|
|
1928
|
+
newText ? `+ ${previewText(newText, 90)}` : void 0
|
|
1929
|
+
].filter(Boolean).join("\n"),
|
|
1930
|
+
4,
|
|
1931
|
+
400
|
|
1932
|
+
) : void 0;
|
|
1933
|
+
const responseSummary = firstMeaningfulLine(outputText) ?? "Applied edit";
|
|
1934
|
+
const editDiff = oldText !== void 0 && newText !== void 0 ? buildStructuredDiff(oldText, newText, rawPath) ?? void 0 : void 0;
|
|
1935
|
+
const editBody = hasResult ? highlightedBody(clipBody(outputText, 8, 1500), rawPath, theme) : { body: replacementPreview };
|
|
1936
|
+
const editChangeSummary = editDiff ? `+${editDiff.addedCount} -${editDiff.removedCount}` : void 0;
|
|
1937
|
+
return {
|
|
1938
|
+
title,
|
|
1939
|
+
summary: hasResult ? editChangeSummary ?? responseSummary : editChangeSummary ?? (rawPath ? shortenPath2(rawPath) : void 0),
|
|
1940
|
+
body: editDiff ? void 0 : editBody.body,
|
|
1941
|
+
preformatted: editDiff ? void 0 : editBody.preformatted,
|
|
1942
|
+
diff: editDiff,
|
|
1943
|
+
emptyText: "Applying edit..."
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
case "ls": {
|
|
1947
|
+
const rawPath = asString(argsRecord?.path) ?? ".";
|
|
1948
|
+
const entryCount = countMeaningfulLines(outputText);
|
|
1949
|
+
return {
|
|
1950
|
+
title,
|
|
1951
|
+
summary: hasResult ? `Listed ${entryCount} ${entryCount === 1 ? "entry" : "entries"}` : shortenPath2(rawPath),
|
|
1952
|
+
body: hasResult ? clipBody(outputText, 10, 1400) : void 0,
|
|
1953
|
+
emptyText: "Listing files..."
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
case "find": {
|
|
1957
|
+
const pattern = asString(argsRecord?.pattern);
|
|
1958
|
+
const rawPath = asString(argsRecord?.path) ?? ".";
|
|
1959
|
+
const matchCount = countMeaningfulLines(outputText);
|
|
1960
|
+
return {
|
|
1961
|
+
title,
|
|
1962
|
+
summary: hasResult ? `Found ${matchCount} ${matchCount === 1 ? "path" : "paths"}` : pattern ? `${pattern} in ${shortenPath2(rawPath)}` : shortenPath2(rawPath),
|
|
1963
|
+
body: hasResult ? clipBody(outputText, 10, 1400) : void 0,
|
|
1964
|
+
emptyText: "Searching files..."
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
case "grep": {
|
|
1968
|
+
const pattern = asString(argsRecord?.pattern);
|
|
1969
|
+
const rawPath = asString(argsRecord?.path) ?? ".";
|
|
1970
|
+
const responseSummary = /no matches found/i.test(outputText) ? "Found 0 matches" : firstMeaningfulLine(outputText) ? "Search results" : "Search complete";
|
|
1971
|
+
return {
|
|
1972
|
+
title,
|
|
1973
|
+
summary: hasResult ? responseSummary : pattern ? `/${pattern}/ in ${shortenPath2(rawPath)}` : shortenPath2(rawPath),
|
|
1974
|
+
body: hasResult ? clipBody(outputText, 10, 1400) : void 0,
|
|
1975
|
+
emptyText: "Searching text..."
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
case "bash": {
|
|
1979
|
+
const command = summarizeCommand(asString(argsRecord?.command));
|
|
1980
|
+
const firstLine = firstMeaningfulLine(outputText);
|
|
1981
|
+
const responseSummary = firstLine ? previewText(firstLine, 88) : "Command finished";
|
|
1982
|
+
return {
|
|
1983
|
+
title,
|
|
1984
|
+
summary: hasResult ? responseSummary : command,
|
|
1985
|
+
body: clipBody(outputText, 8, 1800),
|
|
1986
|
+
emptyText: "Running shell command..."
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1989
|
+
case "task": {
|
|
1990
|
+
const subagentType = asString(details?.subagentType) ?? asString(argsRecord?.subagent_type) ?? "subagent";
|
|
1991
|
+
const description = asString(details?.description) ?? asString(argsRecord?.description);
|
|
1992
|
+
const responseSummary = firstMeaningfulLine(outputText || asString(details?.result)) ?? "Task finished";
|
|
1993
|
+
return {
|
|
1994
|
+
title,
|
|
1995
|
+
summary: hasResult ? responseSummary : [subagentType, description].filter(Boolean).join(" - "),
|
|
1996
|
+
body: hasResult ? clipBody(outputText || asString(details?.result), 8, 1400) : void 0,
|
|
1997
|
+
emptyText: "Delegating to subagent..."
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
case "todoread":
|
|
2001
|
+
case "todowrite": {
|
|
2002
|
+
const todos = extractTodos(args, output);
|
|
2003
|
+
const incompleteCount = asNumber(details?.incompleteCount) ?? todos.filter((todo) => todo.status !== "completed").length;
|
|
2004
|
+
const summary = todos.length > 0 ? `${todos.length} item(s) | ${incompleteCount} open` : fallbackSummary(args, fallbackArgsText);
|
|
2005
|
+
return {
|
|
2006
|
+
title,
|
|
2007
|
+
summary: summary ?? (toolName === "todoread" ? "Read todo list" : "Updated todo list"),
|
|
2008
|
+
body: hasResult ? formatTodos(todos) ?? fallbackBody(output, fallbackOutputText, showImages) : void 0,
|
|
2009
|
+
emptyText: toolName === "todoread" ? "Reading todo list..." : "Updating todo list..."
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
default:
|
|
2013
|
+
return {
|
|
2014
|
+
title,
|
|
2015
|
+
summary: hasResult ? firstMeaningfulLine(outputText) ?? "Completed" : fallbackSummary(args, fallbackArgsText),
|
|
2016
|
+
body: fallbackBody(output, fallbackOutputText, showImages),
|
|
2017
|
+
emptyText: "Working..."
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
function describeToolExecution(tool) {
|
|
2022
|
+
const callDescriptor = describeToolSource({
|
|
2023
|
+
toolName: tool.toolName,
|
|
2024
|
+
args: tool.args,
|
|
2025
|
+
fallbackArgsText: tool.argsText
|
|
2026
|
+
});
|
|
2027
|
+
return {
|
|
2028
|
+
...callDescriptor,
|
|
2029
|
+
body: clipBody(tool.outputText, 8, 1800),
|
|
2030
|
+
emptyText: tool.status === "running" ? callDescriptor.emptyText : tool.status === "error" ? "Tool failed." : "Tool finished."
|
|
2031
|
+
};
|
|
2032
|
+
}
|
|
2033
|
+
function describeToolCall(toolCall) {
|
|
2034
|
+
return describeToolSource({
|
|
2035
|
+
toolName: toolCall.name,
|
|
2036
|
+
args: toolCall.arguments
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
function describeToolResult(message, showImages, args, theme) {
|
|
2040
|
+
return describeToolSource({
|
|
2041
|
+
args,
|
|
2042
|
+
toolName: message.toolName,
|
|
2043
|
+
output: {
|
|
2044
|
+
content: message.content,
|
|
2045
|
+
details: message.details
|
|
2046
|
+
},
|
|
2047
|
+
showImages,
|
|
2048
|
+
theme
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
// src/react-ink/components/ToolEventBlock.tsx
|
|
2053
|
+
import stripAnsi5 from "strip-ansi";
|
|
2054
|
+
function statusMarker(status) {
|
|
2055
|
+
switch (status) {
|
|
2056
|
+
case "error":
|
|
2057
|
+
return "!";
|
|
2058
|
+
case "success":
|
|
2059
|
+
return "=";
|
|
2060
|
+
default:
|
|
2061
|
+
return ">";
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
function plainToolText(text) {
|
|
2065
|
+
return stripAnsi5(text);
|
|
2066
|
+
}
|
|
2067
|
+
function splitVisibleLines(text) {
|
|
2068
|
+
return (text ?? "").split(/\r?\n/).map((line) => line.trimEnd()).filter((line, index, lines) => {
|
|
2069
|
+
if (stripAnsi5(line).length > 0) {
|
|
2070
|
+
return true;
|
|
2071
|
+
}
|
|
2072
|
+
return index !== 0 && index !== lines.length - 1;
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
function clampContentLines(lines, maxContentLines) {
|
|
2076
|
+
if (maxContentLines <= 0) {
|
|
2077
|
+
return {
|
|
2078
|
+
visibleLines: [],
|
|
2079
|
+
hiddenLineCount: lines.length
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
if (lines.length <= maxContentLines) {
|
|
2083
|
+
return {
|
|
2084
|
+
visibleLines: lines,
|
|
2085
|
+
hiddenLineCount: 0
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
const visibleLimit = Math.max(0, maxContentLines - 1);
|
|
2089
|
+
return {
|
|
2090
|
+
visibleLines: lines.slice(0, visibleLimit),
|
|
2091
|
+
hiddenLineCount: lines.length - visibleLimit
|
|
2092
|
+
};
|
|
2093
|
+
}
|
|
2094
|
+
function ToolEventBlock({
|
|
2095
|
+
detail,
|
|
2096
|
+
emptyText,
|
|
2097
|
+
indent = 0,
|
|
2098
|
+
marginBottom = 1,
|
|
2099
|
+
maxContentLines = 10,
|
|
2100
|
+
preformatted = false,
|
|
2101
|
+
showSummaryInline = false,
|
|
2102
|
+
showTitle = true,
|
|
2103
|
+
status,
|
|
2104
|
+
summary,
|
|
2105
|
+
theme: _theme,
|
|
2106
|
+
title
|
|
2107
|
+
}) {
|
|
2108
|
+
const normalizedSummary = summary?.trim();
|
|
2109
|
+
const normalizedDetail = detail?.trim();
|
|
2110
|
+
const responseText = showSummaryInline ? void 0 : normalizedSummary ?? emptyText?.trim();
|
|
2111
|
+
const detailText = showSummaryInline ? normalizedDetail ?? emptyText?.trim() : normalizedDetail;
|
|
2112
|
+
const responseLines = splitVisibleLines(responseText);
|
|
2113
|
+
const detailLines = splitVisibleLines(detailText).filter((line) => !responseLines.includes(line));
|
|
2114
|
+
const combinedLines = [
|
|
2115
|
+
...responseLines.map((text) => ({ kind: "response", text })),
|
|
2116
|
+
...detailLines.map((text) => ({ kind: "detail", text }))
|
|
2117
|
+
];
|
|
2118
|
+
const { visibleLines, hiddenLineCount } = clampContentLines(combinedLines, maxContentLines);
|
|
2119
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom, marginLeft: indent, children: [
|
|
2120
|
+
showTitle ? /* @__PURE__ */ jsxs(Box, { children: [
|
|
2121
|
+
/* @__PURE__ */ jsx(Text, { color: "white", children: plainToolText(`${statusMarker(status)} `) }),
|
|
2122
|
+
/* @__PURE__ */ jsx(Text, { color: "white", children: plainToolText(title) }),
|
|
2123
|
+
showSummaryInline && normalizedSummary ? /* @__PURE__ */ jsx(Text, { color: "white", children: plainToolText(` (${normalizedSummary})`) }) : null
|
|
2124
|
+
] }) : null,
|
|
2125
|
+
visibleLines.map((line, index) => /* @__PURE__ */ jsx(
|
|
2126
|
+
Box,
|
|
2127
|
+
{
|
|
2128
|
+
marginLeft: line.kind === "response" ? showTitle ? 2 : 0 : showTitle ? 4 : 2,
|
|
2129
|
+
children: preformatted ? /* @__PURE__ */ jsx(Text, { children: line.text }) : /* @__PURE__ */ jsx(Text, { color: "white", children: plainToolText(line.text) })
|
|
2130
|
+
},
|
|
2131
|
+
`${line.kind}:${index}:${stripAnsi5(line.text)}`
|
|
2132
|
+
)),
|
|
2133
|
+
hiddenLineCount > 0 ? /* @__PURE__ */ jsx(Box, { marginLeft: showTitle ? 4 : 2, children: /* @__PURE__ */ jsx(Text, { color: "white", children: plainToolText(`... ${hiddenLineCount} more line(s)`) }) }) : null
|
|
2134
|
+
] });
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
// src/react-ink/components/messages/ToolCallMessage.tsx
|
|
2138
|
+
function ToolCallMessage({ theme, toolCall }) {
|
|
2139
|
+
const descriptor = describeToolCall(toolCall);
|
|
2140
|
+
return /* @__PURE__ */ jsx(
|
|
2141
|
+
ToolEventBlock,
|
|
2142
|
+
{
|
|
2143
|
+
detail: void 0,
|
|
2144
|
+
emptyText: void 0,
|
|
2145
|
+
indent: 2,
|
|
2146
|
+
marginBottom: 0,
|
|
2147
|
+
showSummaryInline: true,
|
|
2148
|
+
status: "running",
|
|
2149
|
+
summary: descriptor.summary,
|
|
2150
|
+
theme,
|
|
2151
|
+
title: descriptor.title
|
|
2152
|
+
}
|
|
2153
|
+
);
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
// src/react-ink/diff/Diff.tsx
|
|
2157
|
+
import chalk4 from "chalk";
|
|
2158
|
+
function lineMarker(kind) {
|
|
2159
|
+
switch (kind) {
|
|
2160
|
+
case "added":
|
|
2161
|
+
return "+";
|
|
2162
|
+
case "removed":
|
|
2163
|
+
return "-";
|
|
2164
|
+
default:
|
|
2165
|
+
return " ";
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
function gutterWidth(diff) {
|
|
2169
|
+
let max = 1;
|
|
2170
|
+
for (const hunk of diff.hunks) {
|
|
2171
|
+
for (const line of hunk.lines) {
|
|
2172
|
+
const num = line.kind === "removed" ? line.oldLine : line.newLine;
|
|
2173
|
+
if (num !== void 0) {
|
|
2174
|
+
max = Math.max(max, stringWidth(String(num)));
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
return max;
|
|
2179
|
+
}
|
|
2180
|
+
function renderLineText(line, theme, bgRole, fgRole) {
|
|
2181
|
+
const paintSpan = (text, changed) => {
|
|
2182
|
+
const fg = theme.role(fgRole, text);
|
|
2183
|
+
return changed ? chalk4.bold(fg) : fg;
|
|
2184
|
+
};
|
|
2185
|
+
let body;
|
|
2186
|
+
if (line.spans && line.spans.length > 0) {
|
|
2187
|
+
body = line.spans.map((span) => paintSpan(span.text, span.changed)).join("");
|
|
2188
|
+
} else {
|
|
2189
|
+
body = theme.role(fgRole, line.text);
|
|
2190
|
+
}
|
|
2191
|
+
return bgRole ? theme.roleBackground(bgRole, body) : body;
|
|
2192
|
+
}
|
|
2193
|
+
function Diff({ diff, theme, indent = 0, marginBottom = 0 }) {
|
|
2194
|
+
const gutter = gutterWidth(diff);
|
|
2195
|
+
const renderLine = (line, key) => {
|
|
2196
|
+
const num = line.kind === "removed" ? line.oldLine : line.newLine;
|
|
2197
|
+
const gutterText = (num !== void 0 ? String(num) : "").padStart(gutter);
|
|
2198
|
+
const marker = lineMarker(line.kind);
|
|
2199
|
+
const bgRole = line.kind === "added" ? "diffAddedBg" : line.kind === "removed" ? "diffRemovedBg" : null;
|
|
2200
|
+
const fgRole = line.kind === "added" ? "diffAddedText" : line.kind === "removed" ? "diffRemovedText" : "blockquoteBar";
|
|
2201
|
+
const gutterStyled = theme.dim(`${gutterText} `);
|
|
2202
|
+
const markerStyled = line.kind === "context" ? theme.dim(`${marker} `) : theme.role(fgRole, `${marker} `);
|
|
2203
|
+
const text = renderLineText(line, theme, bgRole, fgRole);
|
|
2204
|
+
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
2205
|
+
gutterStyled,
|
|
2206
|
+
markerStyled,
|
|
2207
|
+
text
|
|
2208
|
+
] }) }, key);
|
|
2209
|
+
};
|
|
2210
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginLeft: indent, marginBottom, children: diff.hunks.map((hunk, hunkIndex) => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
2211
|
+
hunkIndex > 0 ? /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: theme.dim("...") }) }) : null,
|
|
2212
|
+
hunk.lines.map((line, lineIndex) => renderLine(line, `${hunkIndex}-${lineIndex}`))
|
|
2213
|
+
] }, `hunk-${hunkIndex}`)) });
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
// src/react-ink/components/messages/ToolResultBlock.tsx
|
|
2217
|
+
function ToolResultBlock({ expanded = false, message, nested = false, showImages, theme, toolCall }) {
|
|
2218
|
+
const descriptor = describeToolResult(message, showImages, toolCall?.arguments, theme);
|
|
2219
|
+
const indent = nested ? 4 : 2;
|
|
2220
|
+
if (descriptor.diff) {
|
|
2221
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 0, children: [
|
|
2222
|
+
/* @__PURE__ */ jsx(
|
|
2223
|
+
ToolEventBlock,
|
|
2224
|
+
{
|
|
2225
|
+
detail: void 0,
|
|
2226
|
+
emptyText: descriptor.emptyText,
|
|
2227
|
+
indent,
|
|
2228
|
+
marginBottom: 0,
|
|
2229
|
+
maxContentLines: 0,
|
|
2230
|
+
showSummaryInline: false,
|
|
2231
|
+
showTitle: !nested,
|
|
2232
|
+
status: message.isError ? "error" : "success",
|
|
2233
|
+
summary: descriptor.summary,
|
|
2234
|
+
theme,
|
|
2235
|
+
title: descriptor.title
|
|
2236
|
+
}
|
|
2237
|
+
),
|
|
2238
|
+
/* @__PURE__ */ jsx(Diff, { diff: descriptor.diff, theme, indent: indent + 2 })
|
|
2239
|
+
] });
|
|
2240
|
+
}
|
|
2241
|
+
return /* @__PURE__ */ jsx(
|
|
2242
|
+
ToolEventBlock,
|
|
2243
|
+
{
|
|
2244
|
+
detail: descriptor.body,
|
|
2245
|
+
emptyText: descriptor.emptyText,
|
|
2246
|
+
indent,
|
|
2247
|
+
marginBottom: 0,
|
|
2248
|
+
maxContentLines: expanded ? Number.MAX_SAFE_INTEGER : 10,
|
|
2249
|
+
preformatted: descriptor.preformatted,
|
|
2250
|
+
showSummaryInline: false,
|
|
2251
|
+
showTitle: !nested,
|
|
2252
|
+
status: message.isError ? "error" : "success",
|
|
2253
|
+
summary: descriptor.summary,
|
|
2254
|
+
theme,
|
|
2255
|
+
title: descriptor.title
|
|
2256
|
+
}
|
|
2257
|
+
);
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
// src/react-ink/components/messages/AssistantMessage.tsx
|
|
2261
|
+
function AssistantMessageView({
|
|
2262
|
+
expandToolOutputs = false,
|
|
2263
|
+
message,
|
|
2264
|
+
showImages,
|
|
2265
|
+
showThinking,
|
|
2266
|
+
theme,
|
|
2267
|
+
toolResults = []
|
|
2268
|
+
}) {
|
|
2269
|
+
const parts = splitAssistantMessage(message, showThinking);
|
|
2270
|
+
const toolResultsByCallId = new Map(toolResults.map((toolResult) => [toolResult.toolCallId, toolResult]));
|
|
2271
|
+
const matchedToolResultIds = /* @__PURE__ */ new Set();
|
|
2272
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
2273
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("accent", `Assistant ${message.provider}/${message.model} ${formatMessageTimestamp(message.timestamp)}`) }),
|
|
2274
|
+
parts.text ? /* @__PURE__ */ jsx(Markdown, { theme, children: parts.text }) : null,
|
|
2275
|
+
parts.thinking.map((thinking, index) => /* @__PURE__ */ jsx(Text, { children: theme.muted(`[thinking] ${thinking}`) }, index)),
|
|
2276
|
+
parts.toolCalls.map((toolCall) => {
|
|
2277
|
+
const toolResult = toolResultsByCallId.get(toolCall.id);
|
|
2278
|
+
if (toolResult) {
|
|
2279
|
+
matchedToolResultIds.add(toolResult.toolCallId);
|
|
2280
|
+
}
|
|
2281
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
2282
|
+
/* @__PURE__ */ jsx(ToolCallMessage, { toolCall, theme }),
|
|
2283
|
+
toolResult ? /* @__PURE__ */ jsx(
|
|
2284
|
+
ToolResultBlock,
|
|
2285
|
+
{
|
|
2286
|
+
expanded: expandToolOutputs,
|
|
2287
|
+
message: toolResult,
|
|
2288
|
+
nested: true,
|
|
2289
|
+
showImages,
|
|
2290
|
+
theme,
|
|
2291
|
+
toolCall
|
|
2292
|
+
}
|
|
2293
|
+
) : null
|
|
2294
|
+
] }, toolCall.id);
|
|
2295
|
+
}),
|
|
2296
|
+
toolResults.filter((toolResult) => !matchedToolResultIds.has(toolResult.toolCallId)).map((toolResult) => /* @__PURE__ */ jsx(
|
|
2297
|
+
ToolResultBlock,
|
|
2298
|
+
{
|
|
2299
|
+
expanded: expandToolOutputs,
|
|
2300
|
+
message: toolResult,
|
|
2301
|
+
nested: true,
|
|
2302
|
+
showImages,
|
|
2303
|
+
theme
|
|
2304
|
+
},
|
|
2305
|
+
toolResult.toolCallId
|
|
2306
|
+
)),
|
|
2307
|
+
message.stopReason === "error" && message.errorMessage ? /* @__PURE__ */ jsx(Text, { children: theme.color("error", message.errorMessage) }) : null
|
|
2308
|
+
] });
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// src/react-ink/components/messages/BashMessage.tsx
|
|
2312
|
+
function BashMessageView({ message, theme }) {
|
|
2313
|
+
const status = message.cancelled ? "cancelled" : message.exitCode === void 0 ? "running" : `exit ${message.exitCode}`;
|
|
2314
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
2315
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("bashBorder", `Bash ${status} ${message.command}`) }),
|
|
2316
|
+
message.output ? /* @__PURE__ */ jsx(Text, { children: message.output }) : /* @__PURE__ */ jsx(Text, { children: theme.muted("(no output)") })
|
|
2317
|
+
] });
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
// src/react-ink/components/messages/BranchSummaryMessage.tsx
|
|
2321
|
+
function BranchSummaryMessageView({ message, theme }) {
|
|
2322
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
2323
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("warning", "Branch Summary") }),
|
|
2324
|
+
/* @__PURE__ */ jsx(Text, { children: message.summary })
|
|
2325
|
+
] });
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
// src/react-ink/components/messages/CompactionMessage.tsx
|
|
2329
|
+
function CompactionMessageView({ message, theme }) {
|
|
2330
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
2331
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("success", `Compaction Summary ${message.tokensBefore} tokens before`) }),
|
|
2332
|
+
/* @__PURE__ */ jsx(Text, { children: message.summary })
|
|
2333
|
+
] });
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
// src/react-ink/components/messages/CustomMessage.tsx
|
|
2337
|
+
function CustomMessageView({ message, showImages, theme }) {
|
|
2338
|
+
if (!message.display) return null;
|
|
2339
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
2340
|
+
/* @__PURE__ */ jsx(Text, { children: theme.background("customMessage", ` ${message.customType} `, "customMessageText") }),
|
|
2341
|
+
/* @__PURE__ */ jsx(Text, { children: formatCustomContent(message.content, showImages) })
|
|
2342
|
+
] });
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
// src/react-ink/components/messages/SkillInvocationMessage.tsx
|
|
2346
|
+
function SkillInvocationMessage({ content, theme }) {
|
|
2347
|
+
const parsed = parseSkillInvocation(content);
|
|
2348
|
+
if (!parsed) return null;
|
|
2349
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
2350
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("accent", `Skill ${parsed.name}`) }),
|
|
2351
|
+
/* @__PURE__ */ jsx(Text, { children: parsed.location }),
|
|
2352
|
+
parsed.userMessage ? /* @__PURE__ */ jsx(Text, { children: parsed.userMessage }) : null
|
|
2353
|
+
] });
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
// src/react-ink/components/messages/UserMessage.tsx
|
|
2357
|
+
function UserMessageView({ message, showImages, theme }) {
|
|
2358
|
+
const content = formatUserContent(message.content, showImages);
|
|
2359
|
+
const lines = content.length > 0 ? content.split("\n") : [""];
|
|
2360
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
2361
|
+
/* @__PURE__ */ jsx(Text, { children: theme.background("userMessage", `You ${formatMessageTimestamp(message.timestamp)}`, "userMessageText") }),
|
|
2362
|
+
lines.map((line, index) => /* @__PURE__ */ jsx(Text, { children: theme.background("userMessage", line.length > 0 ? line : " ", "userMessageText") }, `user-message:${message.timestamp}:${index}`))
|
|
2363
|
+
] });
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
// src/react-ink/components/MessageRow.tsx
|
|
2367
|
+
function MessageRow({
|
|
2368
|
+
message,
|
|
2369
|
+
expandToolOutputs = false,
|
|
2370
|
+
showImages,
|
|
2371
|
+
showThinking,
|
|
2372
|
+
theme,
|
|
2373
|
+
toolResults = []
|
|
2374
|
+
}) {
|
|
2375
|
+
switch (message.role) {
|
|
2376
|
+
case "user": {
|
|
2377
|
+
const content = typeof message.content === "string" ? message.content : formatUserContent(message.content, showImages);
|
|
2378
|
+
const skill = typeof content === "string" ? parseSkillInvocation(content) : null;
|
|
2379
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
2380
|
+
skill ? /* @__PURE__ */ jsx(SkillInvocationMessage, { content, theme }) : null,
|
|
2381
|
+
/* @__PURE__ */ jsx(UserMessageView, { message, showImages, theme })
|
|
2382
|
+
] });
|
|
2383
|
+
}
|
|
2384
|
+
case "assistant":
|
|
2385
|
+
return /* @__PURE__ */ jsx(
|
|
2386
|
+
AssistantMessageView,
|
|
2387
|
+
{
|
|
2388
|
+
expandToolOutputs,
|
|
2389
|
+
message,
|
|
2390
|
+
showImages,
|
|
2391
|
+
showThinking,
|
|
2392
|
+
theme,
|
|
2393
|
+
toolResults
|
|
2394
|
+
}
|
|
2395
|
+
);
|
|
2396
|
+
case "toolResult":
|
|
2397
|
+
return /* @__PURE__ */ jsx(ToolResultBlock, { expanded: expandToolOutputs, message, showImages, theme });
|
|
2398
|
+
case "bashExecution":
|
|
2399
|
+
return /* @__PURE__ */ jsx(BashMessageView, { message, theme });
|
|
2400
|
+
case "branchSummary":
|
|
2401
|
+
return /* @__PURE__ */ jsx(BranchSummaryMessageView, { message, theme });
|
|
2402
|
+
case "compactionSummary":
|
|
2403
|
+
return /* @__PURE__ */ jsx(CompactionMessageView, { message, theme });
|
|
2404
|
+
case "custom":
|
|
2405
|
+
return /* @__PURE__ */ jsx(CustomMessageView, { message, showImages, theme });
|
|
2406
|
+
default:
|
|
2407
|
+
return /* @__PURE__ */ jsx(Text, { children: String(message.role ?? "message") });
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
// src/react-ink/components/MessageList.tsx
|
|
2412
|
+
function hasToolCalls(message) {
|
|
2413
|
+
return message.role === "assistant" && message.content.some((part) => part.type === "toolCall");
|
|
2414
|
+
}
|
|
2415
|
+
function groupMessages(messages) {
|
|
2416
|
+
const entries = [];
|
|
2417
|
+
for (let index = 0; index < messages.length; index++) {
|
|
2418
|
+
const message = messages[index];
|
|
2419
|
+
if (hasToolCalls(message)) {
|
|
2420
|
+
const toolResults = [];
|
|
2421
|
+
let nextIndex = index + 1;
|
|
2422
|
+
while (nextIndex < messages.length && messages[nextIndex]?.role === "toolResult") {
|
|
2423
|
+
toolResults.push(messages[nextIndex]);
|
|
2424
|
+
nextIndex += 1;
|
|
2425
|
+
}
|
|
2426
|
+
entries.push({ type: "message", message, toolResults });
|
|
2427
|
+
index = nextIndex - 1;
|
|
2428
|
+
continue;
|
|
2429
|
+
}
|
|
2430
|
+
if (message.role === "toolResult") {
|
|
2431
|
+
entries.push({ type: "message", message, toolResults: [message] });
|
|
2432
|
+
continue;
|
|
2433
|
+
}
|
|
2434
|
+
entries.push({ type: "message", message, toolResults: [] });
|
|
2435
|
+
}
|
|
2436
|
+
return entries;
|
|
2437
|
+
}
|
|
2438
|
+
function getEntryTimestamp(entry) {
|
|
2439
|
+
return entry.type === "message" ? entry.message.timestamp : entry.block.timestamp;
|
|
2440
|
+
}
|
|
2441
|
+
function MessageList({
|
|
2442
|
+
displayBlocks = [],
|
|
2443
|
+
expandToolOutputs = false,
|
|
2444
|
+
maxItems,
|
|
2445
|
+
messages,
|
|
2446
|
+
showImages,
|
|
2447
|
+
showThinking,
|
|
2448
|
+
theme
|
|
2449
|
+
}) {
|
|
2450
|
+
const visible = [
|
|
2451
|
+
...groupMessages(messages),
|
|
2452
|
+
...displayBlocks.map((block) => ({ type: "displayBlock", block }))
|
|
2453
|
+
].sort((left, right) => getEntryTimestamp(left) - getEntryTimestamp(right)).slice(-maxItems);
|
|
2454
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: visible.map((entry, index) => entry.type === "message" ? /* @__PURE__ */ jsx(
|
|
2455
|
+
MessageRow,
|
|
2456
|
+
{
|
|
2457
|
+
message: entry.message,
|
|
2458
|
+
expandToolOutputs,
|
|
2459
|
+
showImages,
|
|
2460
|
+
showThinking,
|
|
2461
|
+
theme,
|
|
2462
|
+
toolResults: entry.toolResults
|
|
2463
|
+
},
|
|
2464
|
+
`${entry.message.role}:${entry.message.timestamp}:${index}`
|
|
2465
|
+
) : /* @__PURE__ */ jsx(
|
|
2466
|
+
DisplayBlockView,
|
|
2467
|
+
{
|
|
2468
|
+
block: entry.block,
|
|
2469
|
+
theme
|
|
2470
|
+
},
|
|
2471
|
+
`${entry.block.kind}:${entry.block.timestamp}:${entry.block.id}`
|
|
2472
|
+
)) });
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
// src/react-ink/components/StatusLine.tsx
|
|
2476
|
+
function StatusLine({ snapshot, status, theme }) {
|
|
2477
|
+
let text = status?.text;
|
|
2478
|
+
let tone = status?.kind ?? "info";
|
|
2479
|
+
if (!text) {
|
|
2480
|
+
if (snapshot.isCompacting) {
|
|
2481
|
+
text = "Compacting conversation context...";
|
|
2482
|
+
tone = "busy";
|
|
2483
|
+
} else if (snapshot.isBashRunning) {
|
|
2484
|
+
text = "Running bash command...";
|
|
2485
|
+
tone = "busy";
|
|
2486
|
+
} else if (snapshot.pendingToolCallCount > 0 || snapshot.pendingMessageCount > 0) {
|
|
2487
|
+
text = "Agent working...";
|
|
2488
|
+
tone = "busy";
|
|
2489
|
+
} else if (snapshot.isStreaming) {
|
|
2490
|
+
text = "Agent working...";
|
|
2491
|
+
tone = "busy";
|
|
2492
|
+
} else if (snapshot.error) {
|
|
2493
|
+
text = snapshot.error;
|
|
2494
|
+
tone = "error";
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
if (!text) return null;
|
|
2498
|
+
const styled = tone === "error" ? theme.color("error", text) : tone === "warning" ? theme.color("warning", text) : tone === "success" ? theme.color("success", text) : theme.muted(text);
|
|
2499
|
+
return /* @__PURE__ */ jsx(Text, { children: styled });
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
// src/react-ink/components/TaskPanel.tsx
|
|
2503
|
+
function TaskPanel({ expandToolOutputs = false, pendingMessages = [], snapshot, theme, toolExecutions }) {
|
|
2504
|
+
const recent = Object.values(toolExecutions).sort((left, right) => {
|
|
2505
|
+
if (left.status === "running" && right.status !== "running") return -1;
|
|
2506
|
+
if (left.status !== "running" && right.status === "running") return 1;
|
|
2507
|
+
return right.updatedAt - left.updatedAt;
|
|
2508
|
+
}).slice(0, 6);
|
|
2509
|
+
if (recent.length === 0 && pendingMessages.length === 0 && snapshot.pendingMessageCount === 0) {
|
|
2510
|
+
return null;
|
|
2511
|
+
}
|
|
2512
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, marginTop: 1, children: [
|
|
2513
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("accent", `Tool Activity${recent.length > 0 ? ` ${recent.length}` : ""}`) }),
|
|
2514
|
+
recent.map((tool) => {
|
|
2515
|
+
const descriptor = describeToolExecution(tool);
|
|
2516
|
+
return /* @__PURE__ */ jsx(
|
|
2517
|
+
ToolEventBlock,
|
|
2518
|
+
{
|
|
2519
|
+
detail: descriptor.body,
|
|
2520
|
+
emptyText: descriptor.emptyText,
|
|
2521
|
+
indent: 1,
|
|
2522
|
+
marginBottom: 0,
|
|
2523
|
+
maxContentLines: expandToolOutputs ? Number.MAX_SAFE_INTEGER : 10,
|
|
2524
|
+
showSummaryInline: true,
|
|
2525
|
+
status: tool.status,
|
|
2526
|
+
summary: descriptor.summary,
|
|
2527
|
+
theme,
|
|
2528
|
+
title: descriptor.title
|
|
2529
|
+
},
|
|
2530
|
+
tool.toolCallId
|
|
2531
|
+
);
|
|
2532
|
+
}),
|
|
2533
|
+
pendingMessages.length > 0 ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: recent.length > 0 ? 1 : 0, children: [
|
|
2534
|
+
/* @__PURE__ */ jsx(Text, { children: theme.color("accent", `Queued Messages ${pendingMessages.length}`) }),
|
|
2535
|
+
pendingMessages.slice(0, 6).map((message) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
2536
|
+
theme.muted(` ${message.mode === "steer" ? "Steering" : "Follow-up"}: `),
|
|
2537
|
+
message.text.length > 90 ? `${message.text.slice(0, 87)}...` : message.text
|
|
2538
|
+
] }, message.id)),
|
|
2539
|
+
/* @__PURE__ */ jsx(Text, { children: theme.muted(" Alt+Up restores queued messages to the prompt") })
|
|
2540
|
+
] }) : snapshot.pendingMessageCount > 0 ? /* @__PURE__ */ jsx(Text, { children: theme.muted(`${snapshot.pendingMessageCount} queued message(s) waiting for the next turn`) }) : null
|
|
2541
|
+
] });
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
// src/react-ink/components/dialogs/DialogFrame.tsx
|
|
2545
|
+
function DialogFrame({ children, footer, subtitle, title }) {
|
|
2546
|
+
return /* @__PURE__ */ jsxs(Box, { borderStyle: "round", flexDirection: "column", marginTop: 1, paddingX: 1, paddingY: 0, children: [
|
|
2547
|
+
/* @__PURE__ */ jsx(Text, { children: title }),
|
|
2548
|
+
subtitle ? /* @__PURE__ */ jsx(Text, { children: subtitle }) : null,
|
|
2549
|
+
/* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: 1, children }),
|
|
2550
|
+
footer ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: footer }) : null
|
|
2551
|
+
] });
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
// src/react-ink/utils/selection-dialog.ts
|
|
2555
|
+
function matchesSearchQuery(value, query) {
|
|
2556
|
+
if (!query.trim()) {
|
|
2557
|
+
return true;
|
|
2558
|
+
}
|
|
2559
|
+
const haystack = value.toLowerCase();
|
|
2560
|
+
return query.toLowerCase().split(/\s+/).filter(Boolean).every((term) => haystack.includes(term));
|
|
2561
|
+
}
|
|
2562
|
+
function wrapSelectionIndex(current, direction, length) {
|
|
2563
|
+
if (length <= 0) {
|
|
2564
|
+
return 0;
|
|
2565
|
+
}
|
|
2566
|
+
return (current + direction + length) % length;
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
// src/react-ink/components/dialogs/SelectableDialog.tsx
|
|
2570
|
+
function SelectableDialog({
|
|
2571
|
+
title,
|
|
2572
|
+
subtitle,
|
|
2573
|
+
items,
|
|
2574
|
+
isActive = true,
|
|
2575
|
+
searchEnabled = true,
|
|
2576
|
+
emptyText,
|
|
2577
|
+
noSearchResultsText = "No options matched the current search.",
|
|
2578
|
+
onClose,
|
|
2579
|
+
onSelect,
|
|
2580
|
+
onHighlight,
|
|
2581
|
+
getSearchText,
|
|
2582
|
+
renderItem
|
|
2583
|
+
}) {
|
|
2584
|
+
const [query, setQuery] = useState("");
|
|
2585
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
2586
|
+
const filteredItems = useMemo(() => {
|
|
2587
|
+
if (!searchEnabled) {
|
|
2588
|
+
return items;
|
|
2589
|
+
}
|
|
2590
|
+
return items.filter((item) => matchesSearchQuery(getSearchText ? getSearchText(item) : String(item), query));
|
|
2591
|
+
}, [getSearchText, items, query, searchEnabled]);
|
|
2592
|
+
useEffect(() => {
|
|
2593
|
+
setSelectedIndex(0);
|
|
2594
|
+
}, [query]);
|
|
2595
|
+
useEffect(() => {
|
|
2596
|
+
if (selectedIndex >= filteredItems.length) {
|
|
2597
|
+
setSelectedIndex(0);
|
|
2598
|
+
}
|
|
2599
|
+
}, [filteredItems.length, selectedIndex]);
|
|
2600
|
+
const highlighted = filteredItems[selectedIndex];
|
|
2601
|
+
useEffect(() => {
|
|
2602
|
+
if (isActive && onHighlight && highlighted !== void 0) {
|
|
2603
|
+
onHighlight(highlighted, selectedIndex);
|
|
2604
|
+
}
|
|
2605
|
+
}, [highlighted, isActive]);
|
|
2606
|
+
const maxVisible = useMemo(() => Math.max(8, (process.stdout.rows ?? 24) - 16), []);
|
|
2607
|
+
const windowStart = Math.max(
|
|
2608
|
+
0,
|
|
2609
|
+
Math.min(selectedIndex - Math.floor(maxVisible / 2), Math.max(0, filteredItems.length - maxVisible))
|
|
2610
|
+
);
|
|
2611
|
+
const visibleItems = filteredItems.slice(windowStart, windowStart + maxVisible);
|
|
2612
|
+
const showSearch = searchEnabled && items.length > 0;
|
|
2613
|
+
useInput(
|
|
2614
|
+
(input, key) => {
|
|
2615
|
+
if (key.escape) {
|
|
2616
|
+
onClose();
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
if (key.upArrow) {
|
|
2620
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, -1, filteredItems.length));
|
|
2621
|
+
return;
|
|
2622
|
+
}
|
|
2623
|
+
if (key.downArrow) {
|
|
2624
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, 1, filteredItems.length));
|
|
2625
|
+
return;
|
|
2626
|
+
}
|
|
2627
|
+
if (searchEnabled && (key.backspace || key.delete)) {
|
|
2628
|
+
setQuery((current) => current.slice(0, -1));
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2631
|
+
if (searchEnabled && key.ctrl && input === "u") {
|
|
2632
|
+
setQuery("");
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
if (key.return) {
|
|
2636
|
+
const item = filteredItems[selectedIndex];
|
|
2637
|
+
if (item) {
|
|
2638
|
+
void onSelect(item);
|
|
2639
|
+
}
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
if (searchEnabled && !key.ctrl && !key.meta && input) {
|
|
2643
|
+
setQuery((current) => current + input);
|
|
2644
|
+
}
|
|
2645
|
+
},
|
|
2646
|
+
{ isActive }
|
|
2647
|
+
);
|
|
2648
|
+
return /* @__PURE__ */ jsxs(
|
|
2649
|
+
DialogFrame,
|
|
2650
|
+
{
|
|
2651
|
+
title,
|
|
2652
|
+
subtitle,
|
|
2653
|
+
footer: /* @__PURE__ */ jsx(Text, { children: searchEnabled ? "Type to filter, Up/Down wraps, Enter selects, Ctrl+U clears, Esc closes" : "Up/Down wraps, Enter selects, Esc closes" }),
|
|
2654
|
+
children: [
|
|
2655
|
+
showSearch ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
2656
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
2657
|
+
"Search: ",
|
|
2658
|
+
query || " "
|
|
2659
|
+
] }),
|
|
2660
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
2661
|
+
filteredItems.length,
|
|
2662
|
+
" match",
|
|
2663
|
+
filteredItems.length === 1 ? "" : "es"
|
|
2664
|
+
] })
|
|
2665
|
+
] }) : null,
|
|
2666
|
+
items.length === 0 ? /* @__PURE__ */ jsx(Box, { marginTop: showSearch ? 1 : 0, children: /* @__PURE__ */ jsx(Text, { children: emptyText }) }) : filteredItems.length === 0 ? /* @__PURE__ */ jsx(Box, { marginTop: showSearch ? 1 : 0, children: /* @__PURE__ */ jsx(Text, { children: noSearchResultsText }) }) : /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: showSearch ? 1 : 0, children: visibleItems.map((item, index) => {
|
|
2667
|
+
const actualIndex = windowStart + index;
|
|
2668
|
+
return /* @__PURE__ */ jsx(Box, { children: renderItem(item, actualIndex === selectedIndex, actualIndex) }, actualIndex);
|
|
2669
|
+
}) })
|
|
2670
|
+
]
|
|
2671
|
+
}
|
|
2672
|
+
);
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
// src/react-ink/components/dialogs/LoginDialog.tsx
|
|
2676
|
+
function LoginDialog(props) {
|
|
2677
|
+
if (props.mode === "logout") {
|
|
2678
|
+
return /* @__PURE__ */ jsx(
|
|
2679
|
+
SelectableDialog,
|
|
2680
|
+
{
|
|
2681
|
+
title: "Saved Credentials",
|
|
2682
|
+
items: props.accounts,
|
|
2683
|
+
emptyText: "No saved credentials were found.",
|
|
2684
|
+
onClose: props.onClose,
|
|
2685
|
+
onSelect: props.onSelect,
|
|
2686
|
+
getSearchText: (account) => account.label,
|
|
2687
|
+
renderItem: (account, selected) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
2688
|
+
selected ? "> " : " ",
|
|
2689
|
+
account.label
|
|
2690
|
+
] })
|
|
2691
|
+
}
|
|
2692
|
+
);
|
|
2693
|
+
}
|
|
2694
|
+
return /* @__PURE__ */ jsx(
|
|
2695
|
+
SelectableDialog,
|
|
2696
|
+
{
|
|
2697
|
+
title: "Login Providers",
|
|
2698
|
+
items: props.providers,
|
|
2699
|
+
emptyText: "No authenticated providers are configured.",
|
|
2700
|
+
onClose: props.onClose,
|
|
2701
|
+
onSelect: props.onSelect,
|
|
2702
|
+
getSearchText: (provider) => `${provider.label} ${provider.authKind}`,
|
|
2703
|
+
renderItem: (provider, selected) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
2704
|
+
selected ? "> " : " ",
|
|
2705
|
+
provider.label,
|
|
2706
|
+
" (",
|
|
2707
|
+
provider.authKind,
|
|
2708
|
+
")"
|
|
2709
|
+
] })
|
|
2710
|
+
}
|
|
2711
|
+
);
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
// src/react-ink/components/dialogs/ModelDialog.tsx
|
|
2715
|
+
function matchesModel(model, search) {
|
|
2716
|
+
return matchesSearchQuery(`${model.provider} ${model.id} ${model.name ?? ""}`, search);
|
|
2717
|
+
}
|
|
2718
|
+
function ModelDialog({ models, onClose, onSelect, search }) {
|
|
2719
|
+
const [query, setQuery] = useState(search ?? "");
|
|
2720
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
2721
|
+
useEffect(() => {
|
|
2722
|
+
setQuery(search ?? "");
|
|
2723
|
+
}, [search]);
|
|
2724
|
+
const filtered = useMemo(
|
|
2725
|
+
() => models.filter((model) => matchesModel(model, query)),
|
|
2726
|
+
[models, query]
|
|
2727
|
+
);
|
|
2728
|
+
useEffect(() => {
|
|
2729
|
+
setSelectedIndex(0);
|
|
2730
|
+
}, [query]);
|
|
2731
|
+
useEffect(() => {
|
|
2732
|
+
if (selectedIndex >= filtered.length) {
|
|
2733
|
+
setSelectedIndex(0);
|
|
2734
|
+
}
|
|
2735
|
+
}, [filtered.length, selectedIndex]);
|
|
2736
|
+
const maxVisible = Math.max(8, (process.stdout.rows ?? 24) - 16);
|
|
2737
|
+
const windowStart = Math.max(
|
|
2738
|
+
0,
|
|
2739
|
+
Math.min(selectedIndex - Math.floor(maxVisible / 2), Math.max(0, filtered.length - maxVisible))
|
|
2740
|
+
);
|
|
2741
|
+
const visibleModels = filtered.slice(windowStart, windowStart + maxVisible);
|
|
2742
|
+
useInput((input, key) => {
|
|
2743
|
+
if (key.escape) {
|
|
2744
|
+
onClose();
|
|
2745
|
+
return;
|
|
2746
|
+
}
|
|
2747
|
+
if (key.upArrow) {
|
|
2748
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, -1, filtered.length));
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
if (key.downArrow) {
|
|
2752
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, 1, filtered.length));
|
|
2753
|
+
return;
|
|
2754
|
+
}
|
|
2755
|
+
if (key.backspace || key.delete) {
|
|
2756
|
+
setQuery((current) => current.slice(0, -1));
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
if (key.ctrl && input === "u") {
|
|
2760
|
+
setQuery("");
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
if (key.return) {
|
|
2764
|
+
const selected = filtered[selectedIndex];
|
|
2765
|
+
if (selected) {
|
|
2766
|
+
void onSelect(selected);
|
|
2767
|
+
}
|
|
2768
|
+
return;
|
|
2769
|
+
}
|
|
2770
|
+
if (!key.ctrl && !key.meta && input) {
|
|
2771
|
+
setQuery((current) => current + input);
|
|
2772
|
+
}
|
|
2773
|
+
});
|
|
2774
|
+
return /* @__PURE__ */ jsxs(
|
|
2775
|
+
DialogFrame,
|
|
2776
|
+
{
|
|
2777
|
+
title: "Models",
|
|
2778
|
+
subtitle: "Type to search models by provider, id, or name",
|
|
2779
|
+
footer: /* @__PURE__ */ jsx(Text, { children: "Type to filter, Up/Down to move, Enter to select, Ctrl+U clears, Esc closes" }),
|
|
2780
|
+
children: [
|
|
2781
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
2782
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
2783
|
+
"Search: ",
|
|
2784
|
+
query || " "
|
|
2785
|
+
] }),
|
|
2786
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
2787
|
+
filtered.length,
|
|
2788
|
+
" match",
|
|
2789
|
+
filtered.length === 1 ? "" : "es"
|
|
2790
|
+
] })
|
|
2791
|
+
] }),
|
|
2792
|
+
/* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: 1, children: filtered.length === 0 ? /* @__PURE__ */ jsx(Text, { children: "No models matched the current search." }) : visibleModels.map((model, index) => {
|
|
2793
|
+
const actualIndex = windowStart + index;
|
|
2794
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
2795
|
+
actualIndex === selectedIndex ? "> " : " ",
|
|
2796
|
+
model.provider,
|
|
2797
|
+
"/",
|
|
2798
|
+
model.id,
|
|
2799
|
+
model.name ? ` (${model.name})` : ""
|
|
2800
|
+
] }, `${model.provider}/${model.id}`);
|
|
2801
|
+
}) })
|
|
2802
|
+
]
|
|
2803
|
+
}
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
// src/react-ink/components/dialogs/OAuthDialog.tsx
|
|
2808
|
+
function OAuthDialog({ onChange, onClose, onSubmit, state }) {
|
|
2809
|
+
useInput((input, key) => {
|
|
2810
|
+
if (key.escape) {
|
|
2811
|
+
onClose();
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
if (key.return) {
|
|
2815
|
+
void onSubmit();
|
|
2816
|
+
return;
|
|
2817
|
+
}
|
|
2818
|
+
if (key.backspace || key.delete) {
|
|
2819
|
+
onChange({ inputValue: state.inputValue.slice(0, -1) });
|
|
2820
|
+
return;
|
|
2821
|
+
}
|
|
2822
|
+
if (input && !key.ctrl && !key.meta) {
|
|
2823
|
+
onChange({ inputValue: state.inputValue + input });
|
|
2824
|
+
}
|
|
2825
|
+
});
|
|
2826
|
+
return /* @__PURE__ */ jsxs(
|
|
2827
|
+
DialogFrame,
|
|
2828
|
+
{
|
|
2829
|
+
title: `${state.mode === "oauth" ? "OAuth Login" : "API Key Login"}: ${state.providerName}`,
|
|
2830
|
+
footer: /* @__PURE__ */ jsx(Text, { children: "Type to edit, Enter to submit, Esc to cancel" }),
|
|
2831
|
+
children: [
|
|
2832
|
+
state.progress ? /* @__PURE__ */ jsx(Text, { children: state.progress }) : null,
|
|
2833
|
+
state.authInfo ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
2834
|
+
/* @__PURE__ */ jsx(Text, { children: state.authInfo.instructions ?? "Open this URL in your browser to continue:" }),
|
|
2835
|
+
/* @__PURE__ */ jsx(Text, { children: state.authInfo.url })
|
|
2836
|
+
] }) : null,
|
|
2837
|
+
state.prompt ? /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: state.prompt.message }) }) : null,
|
|
2838
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
2839
|
+
/* @__PURE__ */ jsx(Text, { children: state.inputLabel }),
|
|
2840
|
+
/* @__PURE__ */ jsx(Text, { children: state.inputValue || " " })
|
|
2841
|
+
] })
|
|
2842
|
+
]
|
|
2843
|
+
}
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
// src/react-ink/components/dialogs/ScopedModelsDialog.tsx
|
|
2848
|
+
function modelKey(model) {
|
|
2849
|
+
return `${model.provider}/${model.id}`;
|
|
2850
|
+
}
|
|
2851
|
+
function ScopedModelsDialog({ models, onClose, onSave, selectedIds }) {
|
|
2852
|
+
const [query, setQuery] = useState("");
|
|
2853
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
2854
|
+
const [enabledIds, setEnabledIds] = useState(() => new Set(selectedIds));
|
|
2855
|
+
useEffect(() => {
|
|
2856
|
+
setSelectedIndex(0);
|
|
2857
|
+
setQuery("");
|
|
2858
|
+
setEnabledIds(new Set(selectedIds));
|
|
2859
|
+
}, [selectedIds]);
|
|
2860
|
+
const filteredModels = useMemo(
|
|
2861
|
+
() => models.filter((model) => matchesSearchQuery(`${model.provider} ${model.id} ${model.name ?? ""}`, query)),
|
|
2862
|
+
[models, query]
|
|
2863
|
+
);
|
|
2864
|
+
useEffect(() => {
|
|
2865
|
+
setSelectedIndex(0);
|
|
2866
|
+
}, [query]);
|
|
2867
|
+
useEffect(() => {
|
|
2868
|
+
if (selectedIndex >= filteredModels.length) {
|
|
2869
|
+
setSelectedIndex(0);
|
|
2870
|
+
}
|
|
2871
|
+
}, [filteredModels.length, selectedIndex]);
|
|
2872
|
+
const maxVisible = useMemo(() => Math.max(8, (process.stdout.rows ?? 24) - 18), []);
|
|
2873
|
+
const windowStart = Math.max(
|
|
2874
|
+
0,
|
|
2875
|
+
Math.min(selectedIndex - Math.floor(maxVisible / 2), Math.max(0, filteredModels.length - maxVisible))
|
|
2876
|
+
);
|
|
2877
|
+
const visibleModels = filteredModels.slice(windowStart, windowStart + maxVisible);
|
|
2878
|
+
const toggleSelectedModel = () => {
|
|
2879
|
+
const model = filteredModels[selectedIndex];
|
|
2880
|
+
if (!model) {
|
|
2881
|
+
return;
|
|
2882
|
+
}
|
|
2883
|
+
const id = modelKey(model);
|
|
2884
|
+
setEnabledIds((current) => {
|
|
2885
|
+
const next = new Set(current);
|
|
2886
|
+
if (next.has(id)) {
|
|
2887
|
+
next.delete(id);
|
|
2888
|
+
} else {
|
|
2889
|
+
next.add(id);
|
|
2890
|
+
}
|
|
2891
|
+
return next;
|
|
2892
|
+
});
|
|
2893
|
+
};
|
|
2894
|
+
useInput((input, key) => {
|
|
2895
|
+
if (key.escape) {
|
|
2896
|
+
onClose();
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
if (key.upArrow) {
|
|
2900
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, -1, filteredModels.length));
|
|
2901
|
+
return;
|
|
2902
|
+
}
|
|
2903
|
+
if (key.downArrow) {
|
|
2904
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, 1, filteredModels.length));
|
|
2905
|
+
return;
|
|
2906
|
+
}
|
|
2907
|
+
if (key.backspace || key.delete) {
|
|
2908
|
+
setQuery((current) => current.slice(0, -1));
|
|
2909
|
+
return;
|
|
2910
|
+
}
|
|
2911
|
+
if (key.ctrl && input === "u") {
|
|
2912
|
+
setQuery("");
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
if (key.ctrl && input === "a") {
|
|
2916
|
+
setEnabledIds(new Set(models.map(modelKey)));
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2919
|
+
if (key.ctrl && input === "k") {
|
|
2920
|
+
setEnabledIds(/* @__PURE__ */ new Set());
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2923
|
+
if (input === " ") {
|
|
2924
|
+
toggleSelectedModel();
|
|
2925
|
+
return;
|
|
2926
|
+
}
|
|
2927
|
+
if (key.return) {
|
|
2928
|
+
void onSave([...enabledIds].sort());
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
if (!key.ctrl && !key.meta && input && input !== " ") {
|
|
2932
|
+
setQuery((current) => current + input);
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
return /* @__PURE__ */ jsx(
|
|
2936
|
+
DialogFrame,
|
|
2937
|
+
{
|
|
2938
|
+
title: "Scoped Models",
|
|
2939
|
+
subtitle: "Choose which models Ctrl+P cycles through",
|
|
2940
|
+
footer: /* @__PURE__ */ jsxs(Text, { children: [
|
|
2941
|
+
"Type to filter, Up/Down wraps, Space toggles, Ctrl+A selects all, Ctrl+K clears,",
|
|
2942
|
+
" ",
|
|
2943
|
+
"Ctrl+U clears search, Enter saves, Esc closes"
|
|
2944
|
+
] }),
|
|
2945
|
+
children: models.length === 0 ? /* @__PURE__ */ jsx(Text, { children: "No authenticated models are currently available." }) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
2946
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
2947
|
+
"Search: ",
|
|
2948
|
+
query || " "
|
|
2949
|
+
] }),
|
|
2950
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
2951
|
+
filteredModels.length,
|
|
2952
|
+
" match",
|
|
2953
|
+
filteredModels.length === 1 ? "" : "es"
|
|
2954
|
+
] }),
|
|
2955
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
2956
|
+
"Selected: ",
|
|
2957
|
+
enabledIds.size === 0 ? "all available models" : `${enabledIds.size} model(s)`
|
|
2958
|
+
] }),
|
|
2959
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "column", children: filteredModels.length === 0 ? /* @__PURE__ */ jsx(Text, { children: "No models matched the current search." }) : visibleModels.map((model, index) => {
|
|
2960
|
+
const actualIndex = windowStart + index;
|
|
2961
|
+
const id = modelKey(model);
|
|
2962
|
+
const checked = enabledIds.has(id);
|
|
2963
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
2964
|
+
actualIndex === selectedIndex ? "> " : " ",
|
|
2965
|
+
"[",
|
|
2966
|
+
checked ? "x" : " ",
|
|
2967
|
+
"] ",
|
|
2968
|
+
id
|
|
2969
|
+
] }, id);
|
|
2970
|
+
}) })
|
|
2971
|
+
] })
|
|
2972
|
+
}
|
|
2973
|
+
);
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
// src/react-ink/utils/session-browser.ts
|
|
2977
|
+
function wrapSelectionIndex2(current, direction, length) {
|
|
2978
|
+
if (length <= 0) {
|
|
2979
|
+
return 0;
|
|
2980
|
+
}
|
|
2981
|
+
return (current + direction + length) % length;
|
|
2982
|
+
}
|
|
2983
|
+
function normalizeQueryText(text) {
|
|
2984
|
+
return text.toLowerCase().replace(/\s+/g, " ").trim();
|
|
2985
|
+
}
|
|
2986
|
+
function fuzzyScore(needle, haystack) {
|
|
2987
|
+
const query = needle.toLowerCase().trim();
|
|
2988
|
+
const text = haystack.toLowerCase();
|
|
2989
|
+
if (!query) {
|
|
2990
|
+
return { matches: true, score: 0 };
|
|
2991
|
+
}
|
|
2992
|
+
let score = 0;
|
|
2993
|
+
let searchIndex = 0;
|
|
2994
|
+
let firstMatch = -1;
|
|
2995
|
+
for (const char of query) {
|
|
2996
|
+
const index = text.indexOf(char, searchIndex);
|
|
2997
|
+
if (index < 0) {
|
|
2998
|
+
return { matches: false, score: 0 };
|
|
2999
|
+
}
|
|
3000
|
+
if (firstMatch < 0) {
|
|
3001
|
+
firstMatch = index;
|
|
3002
|
+
}
|
|
3003
|
+
score += index - searchIndex;
|
|
3004
|
+
searchIndex = index + 1;
|
|
3005
|
+
}
|
|
3006
|
+
return { matches: true, score: score + Math.max(firstMatch, 0) * 0.1 };
|
|
3007
|
+
}
|
|
3008
|
+
function buildSearchText(session) {
|
|
3009
|
+
return [
|
|
3010
|
+
session.id,
|
|
3011
|
+
session.name ?? "",
|
|
3012
|
+
session.firstMessage ?? "",
|
|
3013
|
+
session.allMessagesText ?? "",
|
|
3014
|
+
session.cwd ?? "",
|
|
3015
|
+
session.path,
|
|
3016
|
+
new Date(session.lastModified).toLocaleString()
|
|
3017
|
+
].join(" ").trim();
|
|
3018
|
+
}
|
|
3019
|
+
function tokenizeQuotedQuery(query) {
|
|
3020
|
+
const tokens = [];
|
|
3021
|
+
let buffer = "";
|
|
3022
|
+
let inQuote = false;
|
|
3023
|
+
const pushBuffer = (kind) => {
|
|
3024
|
+
const value = buffer.trim();
|
|
3025
|
+
buffer = "";
|
|
3026
|
+
if (value) {
|
|
3027
|
+
tokens.push({ kind, value });
|
|
3028
|
+
}
|
|
3029
|
+
};
|
|
3030
|
+
for (const char of query) {
|
|
3031
|
+
if (char === '"') {
|
|
3032
|
+
pushBuffer(inQuote ? "phrase" : "fuzzy");
|
|
3033
|
+
inQuote = !inQuote;
|
|
3034
|
+
continue;
|
|
3035
|
+
}
|
|
3036
|
+
if (!inQuote && /\s/.test(char)) {
|
|
3037
|
+
pushBuffer("fuzzy");
|
|
3038
|
+
continue;
|
|
3039
|
+
}
|
|
3040
|
+
buffer += char;
|
|
3041
|
+
}
|
|
3042
|
+
if (!inQuote) {
|
|
3043
|
+
pushBuffer("fuzzy");
|
|
3044
|
+
}
|
|
3045
|
+
return { tokens, hadUnclosedQuote: inQuote };
|
|
3046
|
+
}
|
|
3047
|
+
function fallbackWhitespaceTokens(query) {
|
|
3048
|
+
return query.split(/\s+/).map((token) => token.trim()).filter(Boolean).map((value) => ({ kind: "fuzzy", value }));
|
|
3049
|
+
}
|
|
3050
|
+
function createRegexQuery(query) {
|
|
3051
|
+
const pattern = query.slice(3).trim();
|
|
3052
|
+
if (!pattern) {
|
|
3053
|
+
return { mode: "regex", tokens: [], regex: null, error: "Empty regex" };
|
|
3054
|
+
}
|
|
3055
|
+
try {
|
|
3056
|
+
return { mode: "regex", tokens: [], regex: new RegExp(pattern, "i") };
|
|
3057
|
+
} catch (error) {
|
|
3058
|
+
return {
|
|
3059
|
+
mode: "regex",
|
|
3060
|
+
tokens: [],
|
|
3061
|
+
regex: null,
|
|
3062
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3063
|
+
};
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
function parseSessionSearchQuery(query) {
|
|
3067
|
+
const trimmed = query.trim();
|
|
3068
|
+
if (!trimmed) {
|
|
3069
|
+
return { mode: "tokens", tokens: [], regex: null };
|
|
3070
|
+
}
|
|
3071
|
+
if (trimmed.startsWith("re:")) {
|
|
3072
|
+
return createRegexQuery(trimmed);
|
|
3073
|
+
}
|
|
3074
|
+
const tokenized = tokenizeQuotedQuery(trimmed);
|
|
3075
|
+
return {
|
|
3076
|
+
mode: "tokens",
|
|
3077
|
+
tokens: tokenized.hadUnclosedQuote ? fallbackWhitespaceTokens(trimmed) : tokenized.tokens,
|
|
3078
|
+
regex: null
|
|
3079
|
+
};
|
|
3080
|
+
}
|
|
3081
|
+
function scoreRegexMatch(text, regex) {
|
|
3082
|
+
if (!regex) {
|
|
3083
|
+
return { matches: false, score: 0 };
|
|
3084
|
+
}
|
|
3085
|
+
const index = text.search(regex);
|
|
3086
|
+
return index < 0 ? { matches: false, score: 0 } : { matches: true, score: index * 0.1 };
|
|
3087
|
+
}
|
|
3088
|
+
function scoreTokenMatch(text, parsed) {
|
|
3089
|
+
if (parsed.tokens.length === 0) {
|
|
3090
|
+
return { matches: true, score: 0 };
|
|
3091
|
+
}
|
|
3092
|
+
let totalScore = 0;
|
|
3093
|
+
let normalizedText;
|
|
3094
|
+
for (const token of parsed.tokens) {
|
|
3095
|
+
if (token.kind === "phrase") {
|
|
3096
|
+
normalizedText ??= normalizeQueryText(text);
|
|
3097
|
+
const phraseIndex = normalizedText.indexOf(normalizeQueryText(token.value));
|
|
3098
|
+
if (phraseIndex < 0) {
|
|
3099
|
+
return { matches: false, score: 0 };
|
|
3100
|
+
}
|
|
3101
|
+
totalScore += phraseIndex * 0.1;
|
|
3102
|
+
continue;
|
|
3103
|
+
}
|
|
3104
|
+
const fuzzy = fuzzyScore(token.value, text);
|
|
3105
|
+
if (!fuzzy.matches) {
|
|
3106
|
+
return { matches: false, score: 0 };
|
|
3107
|
+
}
|
|
3108
|
+
totalScore += fuzzy.score;
|
|
3109
|
+
}
|
|
3110
|
+
return { matches: true, score: totalScore };
|
|
3111
|
+
}
|
|
3112
|
+
function filterAndSortSessions(sessions, query, sortMode) {
|
|
3113
|
+
const parsed = parseSessionSearchQuery(query);
|
|
3114
|
+
if (parsed.error) {
|
|
3115
|
+
return { items: [], error: parsed.error };
|
|
3116
|
+
}
|
|
3117
|
+
if (!query.trim()) {
|
|
3118
|
+
const items = [...sessions].sort((left, right) => right.lastModified - left.lastModified);
|
|
3119
|
+
return { items };
|
|
3120
|
+
}
|
|
3121
|
+
const scored = sessions.map((session) => {
|
|
3122
|
+
const text = buildSearchText(session);
|
|
3123
|
+
const match = parsed.mode === "regex" ? scoreRegexMatch(text, parsed.regex) : scoreTokenMatch(text, parsed);
|
|
3124
|
+
return { session, match };
|
|
3125
|
+
}).filter((entry) => entry.match.matches);
|
|
3126
|
+
scored.sort((left, right) => {
|
|
3127
|
+
if (sortMode === "relevance" && left.match.score !== right.match.score) {
|
|
3128
|
+
return left.match.score - right.match.score;
|
|
3129
|
+
}
|
|
3130
|
+
return right.session.lastModified - left.session.lastModified;
|
|
3131
|
+
});
|
|
3132
|
+
return { items: scored.map((entry) => entry.session) };
|
|
3133
|
+
}
|
|
3134
|
+
function formatSessionAge(lastModified) {
|
|
3135
|
+
const ageMs = Date.now() - lastModified;
|
|
3136
|
+
const seconds = ageMs / 1e3;
|
|
3137
|
+
const minutes = seconds / 60;
|
|
3138
|
+
const hours = minutes / 60;
|
|
3139
|
+
const days = hours / 24;
|
|
3140
|
+
if (days >= 1) return `${Math.floor(days)}d ago`;
|
|
3141
|
+
if (hours >= 1) return `${Math.floor(hours)}h ago`;
|
|
3142
|
+
if (minutes >= 1) return `${Math.floor(minutes)}m ago`;
|
|
3143
|
+
return `${Math.max(0, Math.floor(seconds))}s ago`;
|
|
3144
|
+
}
|
|
3145
|
+
function formatSessionSize(bytes) {
|
|
3146
|
+
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
3147
|
+
if (bytes >= 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
3148
|
+
return `${bytes} B`;
|
|
3149
|
+
}
|
|
3150
|
+
function shrinkSessionId(id) {
|
|
3151
|
+
return id.length > 16 ? `${id.slice(0, 8)}...${id.slice(-4)}` : id;
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
// src/react-ink/components/dialogs/SessionDialog.tsx
|
|
3155
|
+
var VISIBLE_SESSION_COUNT = 5;
|
|
3156
|
+
function buildMetadata(session, showPath) {
|
|
3157
|
+
const parts = [
|
|
3158
|
+
formatSessionAge(session.lastModified),
|
|
3159
|
+
typeof session.messageCount === "number" ? `${session.messageCount} msg` : void 0,
|
|
3160
|
+
typeof session.size === "number" ? formatSessionSize(session.size) : void 0,
|
|
3161
|
+
session.cwd || void 0
|
|
3162
|
+
];
|
|
3163
|
+
if (showPath) {
|
|
3164
|
+
parts.push(session.path);
|
|
3165
|
+
}
|
|
3166
|
+
return parts.filter(Boolean).join(" | ");
|
|
3167
|
+
}
|
|
3168
|
+
function SessionDialog({
|
|
3169
|
+
currentSessionPath,
|
|
3170
|
+
currentSessions,
|
|
3171
|
+
onClose,
|
|
3172
|
+
onDeleteSession,
|
|
3173
|
+
onLoadAllSessions,
|
|
3174
|
+
onRenameSession,
|
|
3175
|
+
onSelect
|
|
3176
|
+
}) {
|
|
3177
|
+
const [scope, setScope] = useState("current");
|
|
3178
|
+
const [sortMode, setSortMode] = useState("relevance");
|
|
3179
|
+
const [showPath, setShowPath] = useState(false);
|
|
3180
|
+
const [query, setQuery] = useState("");
|
|
3181
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
3182
|
+
const [allSessions, setAllSessions] = useState(null);
|
|
3183
|
+
const [loadingAll, setLoadingAll] = useState(false);
|
|
3184
|
+
const [progress, setProgress] = useState(null);
|
|
3185
|
+
const [loadError, setLoadError] = useState();
|
|
3186
|
+
const [confirmDeletePath, setConfirmDeletePath] = useState(null);
|
|
3187
|
+
const [renamePath, setRenamePath] = useState(null);
|
|
3188
|
+
const [renameValue, setRenameValue] = useState("");
|
|
3189
|
+
useEffect(() => {
|
|
3190
|
+
if (scope !== "all" || allSessions || loadingAll) {
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
let cancelled = false;
|
|
3194
|
+
setLoadingAll(true);
|
|
3195
|
+
setLoadError(void 0);
|
|
3196
|
+
setProgress(null);
|
|
3197
|
+
void onLoadAllSessions((next) => {
|
|
3198
|
+
if (!cancelled) {
|
|
3199
|
+
setProgress(next);
|
|
3200
|
+
}
|
|
3201
|
+
}).then((sessions) => {
|
|
3202
|
+
if (!cancelled) {
|
|
3203
|
+
setAllSessions(sessions);
|
|
3204
|
+
}
|
|
3205
|
+
}).catch((error) => {
|
|
3206
|
+
if (!cancelled) {
|
|
3207
|
+
setLoadError(error instanceof Error ? error.message : String(error));
|
|
3208
|
+
}
|
|
3209
|
+
}).finally(() => {
|
|
3210
|
+
if (!cancelled) {
|
|
3211
|
+
setLoadingAll(false);
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
return () => {
|
|
3215
|
+
cancelled = true;
|
|
3216
|
+
};
|
|
3217
|
+
}, [allSessions, loadingAll, onLoadAllSessions, scope]);
|
|
3218
|
+
const sourceSessions = scope === "all" ? allSessions ?? [] : currentSessions;
|
|
3219
|
+
const filtered = useMemo(() => filterAndSortSessions(sourceSessions, query, sortMode), [query, sortMode, sourceSessions]);
|
|
3220
|
+
useEffect(() => {
|
|
3221
|
+
setSelectedIndex(0);
|
|
3222
|
+
setConfirmDeletePath(null);
|
|
3223
|
+
}, [query, scope, sortMode]);
|
|
3224
|
+
useEffect(() => {
|
|
3225
|
+
if (selectedIndex >= filtered.items.length) {
|
|
3226
|
+
setSelectedIndex(0);
|
|
3227
|
+
}
|
|
3228
|
+
}, [filtered.items.length, selectedIndex]);
|
|
3229
|
+
const selectedSession = filtered.items[selectedIndex];
|
|
3230
|
+
const windowStart = Math.max(
|
|
3231
|
+
0,
|
|
3232
|
+
Math.min(selectedIndex - Math.floor(VISIBLE_SESSION_COUNT / 2), Math.max(0, filtered.items.length - VISIBLE_SESSION_COUNT))
|
|
3233
|
+
);
|
|
3234
|
+
const visibleSessions = filtered.items.slice(windowStart, windowStart + VISIBLE_SESSION_COUNT);
|
|
3235
|
+
const statusLine = scope === "all" && loadingAll ? progress ? `Loading all sessions ${progress.loaded}/${progress.total}` : "Loading all sessions..." : loadError ? loadError : filtered.error ? `Search error: ${filtered.error}` : filtered.items.length === 0 ? "0 matches" : `Showing ${windowStart + 1}-${windowStart + visibleSessions.length} of ${filtered.items.length} matches`;
|
|
3236
|
+
const beginRename = () => {
|
|
3237
|
+
if (!selectedSession || !onRenameSession) {
|
|
3238
|
+
return;
|
|
3239
|
+
}
|
|
3240
|
+
setRenamePath(selectedSession.path);
|
|
3241
|
+
setRenameValue(selectedSession.name ?? "");
|
|
3242
|
+
};
|
|
3243
|
+
const confirmRename = async () => {
|
|
3244
|
+
if (!selectedSession || !onRenameSession || renamePath !== selectedSession.path) {
|
|
3245
|
+
setRenamePath(null);
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
3248
|
+
await onRenameSession(selectedSession, renameValue.trim());
|
|
3249
|
+
setRenamePath(null);
|
|
3250
|
+
};
|
|
3251
|
+
useInput((input, key) => {
|
|
3252
|
+
if (renamePath) {
|
|
3253
|
+
if (key.escape || key.ctrl && input === "c") {
|
|
3254
|
+
setRenamePath(null);
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
3257
|
+
if (key.return) {
|
|
3258
|
+
void confirmRename();
|
|
3259
|
+
return;
|
|
3260
|
+
}
|
|
3261
|
+
if (key.backspace || key.delete) {
|
|
3262
|
+
setRenameValue((current) => current.slice(0, -1));
|
|
3263
|
+
return;
|
|
3264
|
+
}
|
|
3265
|
+
if (!key.ctrl && !key.meta && input) {
|
|
3266
|
+
setRenameValue((current) => current + input);
|
|
3267
|
+
}
|
|
3268
|
+
return;
|
|
3269
|
+
}
|
|
3270
|
+
if (confirmDeletePath) {
|
|
3271
|
+
if (key.escape || key.ctrl && input === "c") {
|
|
3272
|
+
setConfirmDeletePath(null);
|
|
3273
|
+
return;
|
|
3274
|
+
}
|
|
3275
|
+
if (key.return && selectedSession && onDeleteSession && confirmDeletePath === selectedSession.path) {
|
|
3276
|
+
void onDeleteSession(selectedSession);
|
|
3277
|
+
setConfirmDeletePath(null);
|
|
3278
|
+
}
|
|
3279
|
+
return;
|
|
3280
|
+
}
|
|
3281
|
+
if (key.escape || key.ctrl && input === "c") {
|
|
3282
|
+
onClose();
|
|
3283
|
+
return;
|
|
3284
|
+
}
|
|
3285
|
+
if (key.tab) {
|
|
3286
|
+
setScope((current) => current === "current" ? "all" : "current");
|
|
3287
|
+
return;
|
|
3288
|
+
}
|
|
3289
|
+
if (key.ctrl && input === "s") {
|
|
3290
|
+
setSortMode((current) => current === "recent" ? "relevance" : "recent");
|
|
3291
|
+
return;
|
|
3292
|
+
}
|
|
3293
|
+
if (key.ctrl && input === "p") {
|
|
3294
|
+
setShowPath((current) => !current);
|
|
3295
|
+
return;
|
|
3296
|
+
}
|
|
3297
|
+
if (key.ctrl && input === "r") {
|
|
3298
|
+
beginRename();
|
|
3299
|
+
return;
|
|
3300
|
+
}
|
|
3301
|
+
if (key.ctrl && input === "d") {
|
|
3302
|
+
if (selectedSession && selectedSession.path !== currentSessionPath && onDeleteSession) {
|
|
3303
|
+
setConfirmDeletePath(selectedSession.path);
|
|
3304
|
+
}
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
if (key.upArrow) {
|
|
3308
|
+
setSelectedIndex((current) => wrapSelectionIndex2(current, -1, filtered.items.length));
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
if (key.downArrow) {
|
|
3312
|
+
setSelectedIndex((current) => wrapSelectionIndex2(current, 1, filtered.items.length));
|
|
3313
|
+
return;
|
|
3314
|
+
}
|
|
3315
|
+
if (key.pageUp) {
|
|
3316
|
+
setSelectedIndex((current) => Math.max(0, current - VISIBLE_SESSION_COUNT));
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
if (key.pageDown) {
|
|
3320
|
+
setSelectedIndex((current) => Math.min(filtered.items.length - 1, current + VISIBLE_SESSION_COUNT));
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
if (key.return) {
|
|
3324
|
+
if (selectedSession) {
|
|
3325
|
+
void onSelect(selectedSession);
|
|
3326
|
+
}
|
|
3327
|
+
return;
|
|
3328
|
+
}
|
|
3329
|
+
if (key.backspace || key.delete) {
|
|
3330
|
+
setQuery((current) => current.slice(0, -1));
|
|
3331
|
+
return;
|
|
3332
|
+
}
|
|
3333
|
+
if (key.ctrl && input === "u") {
|
|
3334
|
+
setQuery("");
|
|
3335
|
+
return;
|
|
3336
|
+
}
|
|
3337
|
+
if (!key.ctrl && !key.meta && input) {
|
|
3338
|
+
setQuery((current) => current + input);
|
|
3339
|
+
}
|
|
3340
|
+
});
|
|
3341
|
+
return /* @__PURE__ */ jsxs(
|
|
3342
|
+
DialogFrame,
|
|
3343
|
+
{
|
|
3344
|
+
title: scope === "current" ? "Resume Session (Current Folder)" : "Resume Session (All)",
|
|
3345
|
+
subtitle: statusLine,
|
|
3346
|
+
footer: /* @__PURE__ */ jsx(Text, { children: 'Tab scope, Ctrl+S sort, Ctrl+P path, Ctrl+R rename, Ctrl+D delete, re:pattern regex, "phrase" exact' }),
|
|
3347
|
+
children: [
|
|
3348
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
3349
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3350
|
+
"Search: ",
|
|
3351
|
+
renamePath ? "(rename active)" : query || " "
|
|
3352
|
+
] }),
|
|
3353
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
3354
|
+
"Scope: ",
|
|
3355
|
+
scope,
|
|
3356
|
+
" | Sort: ",
|
|
3357
|
+
sortMode,
|
|
3358
|
+
" | Path: ",
|
|
3359
|
+
showPath ? "on" : "off"
|
|
3360
|
+
] })
|
|
3361
|
+
] }),
|
|
3362
|
+
renamePath ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
3363
|
+
/* @__PURE__ */ jsx(Text, { children: "Rename session" }),
|
|
3364
|
+
/* @__PURE__ */ jsx(Text, { children: renameValue || " " }),
|
|
3365
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "Enter saves, Esc cancels" })
|
|
3366
|
+
] }) : confirmDeletePath ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: "Delete this session? Enter confirms, Esc cancels." }) }) : filtered.items.length === 0 ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: scope === "current" ? "No sessions matched in the current folder." : "No sessions matched." }) }) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
3367
|
+
windowStart > 0 ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: " ..." }) : null,
|
|
3368
|
+
visibleSessions.map((session, index) => {
|
|
3369
|
+
const actualIndex = windowStart + index;
|
|
3370
|
+
const selected = actualIndex === selectedIndex;
|
|
3371
|
+
const locked = session.path === currentSessionPath;
|
|
3372
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
3373
|
+
/* @__PURE__ */ jsxs(Text, { color: selected ? "cyan" : "white", children: [
|
|
3374
|
+
selected ? "> " : " ",
|
|
3375
|
+
session.name ? `${session.name} ` : "",
|
|
3376
|
+
shrinkSessionId(session.id),
|
|
3377
|
+
locked ? " (current)" : ""
|
|
3378
|
+
] }),
|
|
3379
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
3380
|
+
selected ? " " : " ",
|
|
3381
|
+
buildMetadata(session, showPath)
|
|
3382
|
+
] })
|
|
3383
|
+
] }, session.path);
|
|
3384
|
+
}),
|
|
3385
|
+
windowStart + visibleSessions.length < filtered.items.length ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: " ..." }) : null
|
|
3386
|
+
] })
|
|
3387
|
+
]
|
|
3388
|
+
}
|
|
3389
|
+
);
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
// src/react-ink/components/dialogs/SettingsDialog.tsx
|
|
3393
|
+
function getNextValue(values, currentValue, direction) {
|
|
3394
|
+
if (values.length === 0) {
|
|
3395
|
+
return void 0;
|
|
3396
|
+
}
|
|
3397
|
+
const currentIndex = Math.max(0, values.indexOf(currentValue));
|
|
3398
|
+
const nextIndex = (currentIndex + direction + values.length) % values.length;
|
|
3399
|
+
return values[nextIndex];
|
|
3400
|
+
}
|
|
3401
|
+
function SettingsDialog({ items, onClose }) {
|
|
3402
|
+
const [query, setQuery] = useState("");
|
|
3403
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
3404
|
+
const filteredItems = useMemo(
|
|
3405
|
+
() => items.filter(
|
|
3406
|
+
(item) => matchesSearchQuery(`${item.label} ${item.description} ${item.value} ${item.values.join(" ")}`, query)
|
|
3407
|
+
),
|
|
3408
|
+
[items, query]
|
|
3409
|
+
);
|
|
3410
|
+
useEffect(() => {
|
|
3411
|
+
setSelectedIndex(0);
|
|
3412
|
+
}, [query]);
|
|
3413
|
+
useEffect(() => {
|
|
3414
|
+
if (selectedIndex >= filteredItems.length) {
|
|
3415
|
+
setSelectedIndex(0);
|
|
3416
|
+
}
|
|
3417
|
+
}, [filteredItems.length, selectedIndex]);
|
|
3418
|
+
const maxVisible = useMemo(() => Math.max(8, (process.stdout.rows ?? 24) - 18), []);
|
|
3419
|
+
const selectedItem = filteredItems[selectedIndex];
|
|
3420
|
+
const windowStart = Math.max(
|
|
3421
|
+
0,
|
|
3422
|
+
Math.min(selectedIndex - Math.floor(maxVisible / 2), Math.max(0, filteredItems.length - maxVisible))
|
|
3423
|
+
);
|
|
3424
|
+
const visibleItems = filteredItems.slice(windowStart, windowStart + maxVisible);
|
|
3425
|
+
const cycleValue = (direction) => {
|
|
3426
|
+
const item = filteredItems[selectedIndex];
|
|
3427
|
+
if (!item) {
|
|
3428
|
+
return;
|
|
3429
|
+
}
|
|
3430
|
+
const nextValue = getNextValue(item.values, item.value, direction);
|
|
3431
|
+
if (!nextValue || nextValue === item.value) {
|
|
3432
|
+
return;
|
|
3433
|
+
}
|
|
3434
|
+
void item.onChange(nextValue);
|
|
3435
|
+
};
|
|
3436
|
+
useInput((input, key) => {
|
|
3437
|
+
if (key.escape) {
|
|
3438
|
+
onClose();
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
if (key.upArrow) {
|
|
3442
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, -1, filteredItems.length));
|
|
3443
|
+
return;
|
|
3444
|
+
}
|
|
3445
|
+
if (key.downArrow) {
|
|
3446
|
+
setSelectedIndex((current) => wrapSelectionIndex(current, 1, filteredItems.length));
|
|
3447
|
+
return;
|
|
3448
|
+
}
|
|
3449
|
+
if (key.backspace || key.delete) {
|
|
3450
|
+
setQuery((current) => current.slice(0, -1));
|
|
3451
|
+
return;
|
|
3452
|
+
}
|
|
3453
|
+
if (key.ctrl && input === "u") {
|
|
3454
|
+
setQuery("");
|
|
3455
|
+
return;
|
|
3456
|
+
}
|
|
3457
|
+
if (key.leftArrow) {
|
|
3458
|
+
cycleValue(-1);
|
|
3459
|
+
return;
|
|
3460
|
+
}
|
|
3461
|
+
if (key.rightArrow || key.return) {
|
|
3462
|
+
cycleValue(1);
|
|
3463
|
+
return;
|
|
3464
|
+
}
|
|
3465
|
+
if (!key.ctrl && !key.meta && input) {
|
|
3466
|
+
setQuery((current) => current + input);
|
|
3467
|
+
}
|
|
3468
|
+
});
|
|
3469
|
+
return /* @__PURE__ */ jsx(
|
|
3470
|
+
DialogFrame,
|
|
3471
|
+
{
|
|
3472
|
+
title: "Settings",
|
|
3473
|
+
footer: /* @__PURE__ */ jsx(Text, { children: "Type to filter, Up/Down wraps, Left/Right or Enter changes, Ctrl+U clears, Esc closes" }),
|
|
3474
|
+
children: items.length === 0 ? /* @__PURE__ */ jsx(Text, { children: "No settings are available." }) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
3475
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3476
|
+
"Search: ",
|
|
3477
|
+
query || " "
|
|
3478
|
+
] }),
|
|
3479
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
3480
|
+
filteredItems.length,
|
|
3481
|
+
" match",
|
|
3482
|
+
filteredItems.length === 1 ? "" : "es"
|
|
3483
|
+
] }),
|
|
3484
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "column", children: filteredItems.length === 0 ? /* @__PURE__ */ jsx(Text, { children: "No settings matched the current search." }) : visibleItems.map((item, index) => {
|
|
3485
|
+
const actualIndex = windowStart + index;
|
|
3486
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
3487
|
+
actualIndex === selectedIndex ? "> " : " ",
|
|
3488
|
+
item.label,
|
|
3489
|
+
": ",
|
|
3490
|
+
item.value
|
|
3491
|
+
] }, item.id);
|
|
3492
|
+
}) }),
|
|
3493
|
+
selectedItem ? /* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
3494
|
+
/* @__PURE__ */ jsx(Text, { children: selectedItem.description }),
|
|
3495
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
3496
|
+
"Choices: ",
|
|
3497
|
+
selectedItem.values.join(" \xB7 ")
|
|
3498
|
+
] })
|
|
3499
|
+
] }) : null
|
|
3500
|
+
] })
|
|
3501
|
+
}
|
|
3502
|
+
);
|
|
3503
|
+
}
|
|
3504
|
+
|
|
3505
|
+
// src/react-ink/components/dialogs/StartupSessionPicker.tsx
|
|
3506
|
+
var VISIBLE_SESSION_COUNT2 = 5;
|
|
3507
|
+
function metadata(session, showPath) {
|
|
3508
|
+
const parts = [
|
|
3509
|
+
formatSessionAge(session.lastModified),
|
|
3510
|
+
typeof session.messageCount === "number" ? `${session.messageCount} msg` : void 0,
|
|
3511
|
+
typeof session.size === "number" ? formatSessionSize(session.size) : void 0,
|
|
3512
|
+
session.cwd || void 0
|
|
3513
|
+
];
|
|
3514
|
+
if (showPath) {
|
|
3515
|
+
parts.push(session.path);
|
|
3516
|
+
}
|
|
3517
|
+
return parts.filter(Boolean).join(" | ");
|
|
3518
|
+
}
|
|
3519
|
+
function StartupSessionPicker({ onClose, onSelect, sessions, totalCount }) {
|
|
3520
|
+
const [query, setQuery] = useState("");
|
|
3521
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
3522
|
+
const [sortMode, setSortMode] = useState("relevance");
|
|
3523
|
+
const [showPath, setShowPath] = useState(false);
|
|
3524
|
+
const filtered = useMemo(() => filterAndSortSessions(sessions, query, sortMode), [query, sessions, sortMode]);
|
|
3525
|
+
useEffect(() => {
|
|
3526
|
+
setSelectedIndex(0);
|
|
3527
|
+
}, [query, sortMode]);
|
|
3528
|
+
useEffect(() => {
|
|
3529
|
+
if (selectedIndex >= filtered.items.length) {
|
|
3530
|
+
setSelectedIndex(0);
|
|
3531
|
+
}
|
|
3532
|
+
}, [filtered.items.length, selectedIndex]);
|
|
3533
|
+
const windowStart = Math.max(
|
|
3534
|
+
0,
|
|
3535
|
+
Math.min(selectedIndex - Math.floor(VISIBLE_SESSION_COUNT2 / 2), Math.max(0, filtered.items.length - VISIBLE_SESSION_COUNT2))
|
|
3536
|
+
);
|
|
3537
|
+
const visibleSessions = filtered.items.slice(windowStart, windowStart + VISIBLE_SESSION_COUNT2);
|
|
3538
|
+
const visibleRangeStart = filtered.items.length === 0 ? 0 : windowStart + 1;
|
|
3539
|
+
const visibleRangeEnd = filtered.items.length === 0 ? 0 : windowStart + visibleSessions.length;
|
|
3540
|
+
useInput((input, key) => {
|
|
3541
|
+
if (key.ctrl && input === "c") {
|
|
3542
|
+
onClose();
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
if (key.escape) {
|
|
3546
|
+
onClose();
|
|
3547
|
+
return;
|
|
3548
|
+
}
|
|
3549
|
+
if (key.ctrl && input === "s") {
|
|
3550
|
+
setSortMode((current) => current === "recent" ? "relevance" : "recent");
|
|
3551
|
+
return;
|
|
3552
|
+
}
|
|
3553
|
+
if (key.ctrl && input === "p") {
|
|
3554
|
+
setShowPath((current) => !current);
|
|
3555
|
+
return;
|
|
3556
|
+
}
|
|
3557
|
+
if (key.upArrow) {
|
|
3558
|
+
setSelectedIndex((current) => wrapSelectionIndex2(current, -1, filtered.items.length));
|
|
3559
|
+
return;
|
|
3560
|
+
}
|
|
3561
|
+
if (key.downArrow) {
|
|
3562
|
+
setSelectedIndex((current) => wrapSelectionIndex2(current, 1, filtered.items.length));
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3565
|
+
if (key.pageUp) {
|
|
3566
|
+
setSelectedIndex((current) => Math.max(0, current - VISIBLE_SESSION_COUNT2));
|
|
3567
|
+
return;
|
|
3568
|
+
}
|
|
3569
|
+
if (key.pageDown) {
|
|
3570
|
+
setSelectedIndex((current) => Math.min(filtered.items.length - 1, current + VISIBLE_SESSION_COUNT2));
|
|
3571
|
+
return;
|
|
3572
|
+
}
|
|
3573
|
+
if (key.return) {
|
|
3574
|
+
const session = filtered.items[selectedIndex];
|
|
3575
|
+
if (session) {
|
|
3576
|
+
void onSelect(session);
|
|
3577
|
+
}
|
|
3578
|
+
return;
|
|
3579
|
+
}
|
|
3580
|
+
if (key.backspace || key.delete) {
|
|
3581
|
+
setQuery((current) => current.slice(0, -1));
|
|
3582
|
+
return;
|
|
3583
|
+
}
|
|
3584
|
+
if (key.ctrl && input === "u") {
|
|
3585
|
+
setQuery("");
|
|
3586
|
+
return;
|
|
3587
|
+
}
|
|
3588
|
+
if (!key.ctrl && !key.meta && input) {
|
|
3589
|
+
setQuery((current) => current + input);
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
const subtitle = totalCount > 0 ? `${totalCount} session${totalCount === 1 ? "" : "s"} available` : void 0;
|
|
3593
|
+
return /* @__PURE__ */ jsxs(
|
|
3594
|
+
DialogFrame,
|
|
3595
|
+
{
|
|
3596
|
+
title: "Resume Session",
|
|
3597
|
+
subtitle,
|
|
3598
|
+
footer: /* @__PURE__ */ jsx(Text, { children: "Type to filter, Ctrl+S sort, Ctrl+P path, Up/Down wraps, Enter selects, Ctrl+U clears, Esc closes" }),
|
|
3599
|
+
children: [
|
|
3600
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
3601
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3602
|
+
"Search: ",
|
|
3603
|
+
query || " "
|
|
3604
|
+
] }),
|
|
3605
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: filtered.error ? `Search error: ${filtered.error}` : filtered.items.length === 0 ? "0 matches" : `Showing ${visibleRangeStart}-${visibleRangeEnd} of ${filtered.items.length} matches | sort:${sortMode} path:${showPath ? "on" : "off"}` })
|
|
3606
|
+
] }),
|
|
3607
|
+
filtered.items.length === 0 ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: sessions.length === 0 ? "No saved sessions were found." : "No sessions matched the current search." }) }) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
3608
|
+
windowStart > 0 ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: " ..." }) : null,
|
|
3609
|
+
visibleSessions.map((session, index) => {
|
|
3610
|
+
const actualIndex = windowStart + index;
|
|
3611
|
+
const selected = actualIndex === selectedIndex;
|
|
3612
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
3613
|
+
/* @__PURE__ */ jsxs(Text, { color: selected ? "cyan" : "white", children: [
|
|
3614
|
+
selected ? "> " : " ",
|
|
3615
|
+
session.name ? `${session.name} ` : "",
|
|
3616
|
+
shrinkSessionId(session.id)
|
|
3617
|
+
] }),
|
|
3618
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
3619
|
+
selected ? " " : " ",
|
|
3620
|
+
metadata(session, showPath)
|
|
3621
|
+
] })
|
|
3622
|
+
] }, session.path);
|
|
3623
|
+
}),
|
|
3624
|
+
windowStart + visibleSessions.length < filtered.items.length ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: " ..." }) : null
|
|
3625
|
+
] })
|
|
3626
|
+
]
|
|
3627
|
+
}
|
|
3628
|
+
);
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
// src/react-ink/components/dialogs/ThemeDialog.tsx
|
|
3632
|
+
function toItem(entry) {
|
|
3633
|
+
return typeof entry === "string" ? { id: entry, label: entry } : entry;
|
|
3634
|
+
}
|
|
3635
|
+
function ThemeDialog({ themes, onClose, onSelect, onHighlight }) {
|
|
3636
|
+
const items = themes.map(toItem);
|
|
3637
|
+
return /* @__PURE__ */ jsx(
|
|
3638
|
+
SelectableDialog,
|
|
3639
|
+
{
|
|
3640
|
+
title: "Themes",
|
|
3641
|
+
items,
|
|
3642
|
+
emptyText: "No themes are available.",
|
|
3643
|
+
onClose,
|
|
3644
|
+
onSelect: (item) => onSelect(item.id),
|
|
3645
|
+
onHighlight: onHighlight ? (item) => onHighlight(item.id) : void 0,
|
|
3646
|
+
getSearchText: (item) => `${item.label} ${item.description ?? ""}`,
|
|
3647
|
+
renderItem: (item, selected) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
3648
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3649
|
+
selected ? "> " : " ",
|
|
3650
|
+
item.label
|
|
3651
|
+
] }),
|
|
3652
|
+
item.description ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
3653
|
+
" ",
|
|
3654
|
+
item.description
|
|
3655
|
+
] }) : null
|
|
3656
|
+
] })
|
|
3657
|
+
}
|
|
3658
|
+
);
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
// src/react-ink/components/dialogs/TreeDialog.tsx
|
|
3662
|
+
function TreeDialog({ items, onClose, onSelect }) {
|
|
3663
|
+
return /* @__PURE__ */ jsx(
|
|
3664
|
+
SelectableDialog,
|
|
3665
|
+
{
|
|
3666
|
+
title: "Session Tree",
|
|
3667
|
+
items,
|
|
3668
|
+
emptyText: "This session does not have any navigable entries yet.",
|
|
3669
|
+
onClose,
|
|
3670
|
+
onSelect,
|
|
3671
|
+
getSearchText: (item) => item.label,
|
|
3672
|
+
renderItem: (item, selected) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
3673
|
+
selected ? "> " : " ",
|
|
3674
|
+
item.isCurrent ? "* " : "",
|
|
3675
|
+
item.label
|
|
3676
|
+
] })
|
|
3677
|
+
}
|
|
3678
|
+
);
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
// src/react-ink/components/dialogs/UserMessageDialog.tsx
|
|
3682
|
+
function UserMessageDialog({ items, onClose, onSelect }) {
|
|
3683
|
+
return /* @__PURE__ */ jsx(
|
|
3684
|
+
SelectableDialog,
|
|
3685
|
+
{
|
|
3686
|
+
title: "Fork From Message",
|
|
3687
|
+
items,
|
|
3688
|
+
emptyText: "No user messages are available for forking.",
|
|
3689
|
+
onClose,
|
|
3690
|
+
onSelect,
|
|
3691
|
+
getSearchText: (item) => item.preview,
|
|
3692
|
+
renderItem: (item, selected) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
3693
|
+
selected ? "> " : " ",
|
|
3694
|
+
item.preview
|
|
3695
|
+
] })
|
|
3696
|
+
}
|
|
3697
|
+
);
|
|
3698
|
+
}
|
|
3699
|
+
|
|
3700
|
+
// src/react-ink/markdown/StreamingMarkdown.tsx
|
|
3701
|
+
function lastStableBoundary(content) {
|
|
3702
|
+
let boundary = 0;
|
|
3703
|
+
let inFence = false;
|
|
3704
|
+
let lineStart = 0;
|
|
3705
|
+
let sawBlankRun = false;
|
|
3706
|
+
for (let i = 0; i <= content.length; i++) {
|
|
3707
|
+
const atEnd = i === content.length;
|
|
3708
|
+
const ch = atEnd ? "\n" : content[i];
|
|
3709
|
+
if (ch !== "\n" && !atEnd) {
|
|
3710
|
+
continue;
|
|
3711
|
+
}
|
|
3712
|
+
const line = content.slice(lineStart, i);
|
|
3713
|
+
if (line.trimStart().startsWith("```")) {
|
|
3714
|
+
inFence = !inFence;
|
|
3715
|
+
sawBlankRun = false;
|
|
3716
|
+
} else if (line.trim() === "") {
|
|
3717
|
+
if (!inFence) {
|
|
3718
|
+
sawBlankRun = true;
|
|
3719
|
+
}
|
|
3720
|
+
} else {
|
|
3721
|
+
if (sawBlankRun && !inFence) {
|
|
3722
|
+
boundary = lineStart;
|
|
3723
|
+
}
|
|
3724
|
+
sawBlankRun = false;
|
|
3725
|
+
}
|
|
3726
|
+
lineStart = i + 1;
|
|
3727
|
+
if (atEnd) {
|
|
3728
|
+
break;
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
return boundary;
|
|
3732
|
+
}
|
|
3733
|
+
function StreamingMarkdown({
|
|
3734
|
+
children,
|
|
3735
|
+
theme,
|
|
3736
|
+
highlightCode = true,
|
|
3737
|
+
dim = false
|
|
3738
|
+
}) {
|
|
3739
|
+
const boundary = useMemo(() => lastStableBoundary(children), [children]);
|
|
3740
|
+
const stablePrefix = useMemo(
|
|
3741
|
+
() => children.slice(0, boundary).replace(/\n+$/, ""),
|
|
3742
|
+
[children, boundary]
|
|
3743
|
+
);
|
|
3744
|
+
const unstableSuffix = useMemo(() => children.slice(boundary), [children, boundary]);
|
|
3745
|
+
const stableNode = useMemo(
|
|
3746
|
+
() => stablePrefix ? /* @__PURE__ */ jsx(Markdown, { theme, highlightCode, dim, children: stablePrefix }) : null,
|
|
3747
|
+
[stablePrefix, theme, highlightCode, dim]
|
|
3748
|
+
);
|
|
3749
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
3750
|
+
stableNode,
|
|
3751
|
+
unstableSuffix ? /* @__PURE__ */ jsx(Markdown, { theme, highlightCode, dim, children: unstableSuffix }) : null
|
|
3752
|
+
] });
|
|
3753
|
+
}
|
|
3754
|
+
export {
|
|
3755
|
+
AssistantMessageView,
|
|
3756
|
+
BashMessageView,
|
|
3757
|
+
BranchSummaryMessageView,
|
|
3758
|
+
CHANGE_THRESHOLD,
|
|
3759
|
+
CONTEXT_LINES,
|
|
3760
|
+
ChangelogBlock,
|
|
3761
|
+
CompactionMessageView,
|
|
3762
|
+
CustomMessageView,
|
|
3763
|
+
DialogFrame,
|
|
3764
|
+
Diff,
|
|
3765
|
+
DisplayBlockView,
|
|
3766
|
+
Footer,
|
|
3767
|
+
LoginDialog,
|
|
3768
|
+
Markdown,
|
|
3769
|
+
MarkdownTable,
|
|
3770
|
+
MessageList,
|
|
3771
|
+
MessageRow,
|
|
3772
|
+
ModelDialog,
|
|
3773
|
+
OAuthDialog,
|
|
3774
|
+
ScopedModelsDialog,
|
|
3775
|
+
SelectableDialog,
|
|
3776
|
+
SessionDialog,
|
|
3777
|
+
SettingsDialog,
|
|
3778
|
+
SkillInvocationMessage,
|
|
3779
|
+
StartupSessionPicker,
|
|
3780
|
+
StatusLine,
|
|
3781
|
+
StreamingMarkdown,
|
|
3782
|
+
TaskPanel,
|
|
3783
|
+
ThemeDialog,
|
|
3784
|
+
ToolCallMessage,
|
|
3785
|
+
ToolEventBlock,
|
|
3786
|
+
ToolResultBlock,
|
|
3787
|
+
TreeDialog,
|
|
3788
|
+
UserMessageDialog,
|
|
3789
|
+
UserMessageView,
|
|
3790
|
+
buildStructuredDiff,
|
|
3791
|
+
cachedLexer,
|
|
3792
|
+
configureMarked,
|
|
3793
|
+
createHighlighter,
|
|
3794
|
+
createThemeAdapter,
|
|
3795
|
+
describeToolCall,
|
|
3796
|
+
describeToolExecution,
|
|
3797
|
+
describeToolResult,
|
|
3798
|
+
describeToolSource,
|
|
3799
|
+
extractMessagePreview,
|
|
3800
|
+
extractToolText,
|
|
3801
|
+
formatCustomContent,
|
|
3802
|
+
formatMessageTimestamp,
|
|
3803
|
+
formatToken,
|
|
3804
|
+
formatToolCall,
|
|
3805
|
+
formatToolResult,
|
|
3806
|
+
formatUserContent,
|
|
3807
|
+
getListNumber,
|
|
3808
|
+
hasMarkdownSyntax,
|
|
3809
|
+
highlightByPath,
|
|
3810
|
+
languageFromPath,
|
|
3811
|
+
matchesSearchQuery,
|
|
3812
|
+
padAligned,
|
|
3813
|
+
parseSkillInvocation,
|
|
3814
|
+
previewMultiline,
|
|
3815
|
+
previewText,
|
|
3816
|
+
safeStringify,
|
|
3817
|
+
splitAssistantMessage,
|
|
3818
|
+
stringWidth,
|
|
3819
|
+
wordDiffLine,
|
|
3820
|
+
wrapSelectionIndex
|
|
3821
|
+
};
|