@yeshwanthyk/coding-agent 0.3.0 → 0.3.3
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/README.md +8 -6
- package/dist/adapters/acp/index.d.ts +10 -0
- package/dist/adapters/acp/index.d.ts.map +1 -0
- package/dist/adapters/acp/index.js +250 -0
- package/dist/adapters/acp/index.js.map +1 -0
- package/dist/adapters/acp/protocol.d.ts +171 -0
- package/dist/adapters/acp/protocol.d.ts.map +1 -0
- package/dist/adapters/acp/protocol.js +25 -0
- package/dist/adapters/acp/protocol.js.map +1 -0
- package/dist/adapters/acp/session.d.ts +33 -0
- package/dist/adapters/acp/session.d.ts.map +1 -0
- package/dist/adapters/acp/session.js +216 -0
- package/dist/adapters/acp/session.js.map +1 -0
- package/dist/adapters/acp/updates.d.ts +17 -0
- package/dist/adapters/acp/updates.d.ts.map +1 -0
- package/dist/adapters/acp/updates.js +62 -0
- package/dist/adapters/acp/updates.js.map +1 -0
- package/dist/adapters/cli/headless.d.ts +7 -0
- package/dist/adapters/cli/headless.d.ts.map +1 -0
- package/dist/adapters/cli/headless.js +93 -0
- package/dist/adapters/cli/headless.js.map +1 -0
- package/dist/adapters/cli/validate.d.ts +3 -0
- package/dist/adapters/cli/validate.d.ts.map +1 -0
- package/dist/adapters/cli/validate.js +40 -0
- package/dist/adapters/cli/validate.js.map +1 -0
- package/dist/adapters/tui/app.d.ts +8 -0
- package/dist/adapters/tui/app.d.ts.map +1 -0
- package/dist/adapters/tui/app.jsx +25 -0
- package/dist/adapters/tui/app.jsx.map +1 -0
- package/dist/agent-events.d.ts +63 -0
- package/dist/agent-events.d.ts.map +1 -0
- package/dist/agent-events.js +510 -0
- package/dist/agent-events.js.map +1 -0
- package/dist/args.d.ts +18 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +87 -0
- package/dist/args.js.map +1 -0
- package/dist/autocomplete-commands.d.ts +26 -0
- package/dist/autocomplete-commands.d.ts.map +1 -0
- package/dist/autocomplete-commands.js +82 -0
- package/dist/autocomplete-commands.js.map +1 -0
- package/dist/commands.d.ts +10 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +17 -0
- package/dist/commands.js.map +1 -0
- package/dist/compact-handler.d.ts +42 -0
- package/dist/compact-handler.d.ts.map +1 -0
- package/dist/compact-handler.js +211 -0
- package/dist/compact-handler.js.map +1 -0
- package/dist/components/Footer.d.ts +9 -0
- package/dist/components/Footer.d.ts.map +1 -0
- package/dist/components/Footer.jsx +36 -0
- package/dist/components/Footer.jsx.map +1 -0
- package/dist/components/Header.d.ts +23 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.jsx +174 -0
- package/dist/components/Header.jsx.map +1 -0
- package/dist/components/MessageList.d.ts +19 -0
- package/dist/components/MessageList.d.ts.map +1 -0
- package/dist/components/MessageList.jsx +237 -0
- package/dist/components/MessageList.jsx.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/domain/commands/builtin/clear.d.ts +3 -0
- package/dist/domain/commands/builtin/clear.d.ts.map +1 -0
- package/dist/domain/commands/builtin/clear.js +13 -0
- package/dist/domain/commands/builtin/clear.js.map +1 -0
- package/dist/domain/commands/builtin/compact.d.ts +3 -0
- package/dist/domain/commands/builtin/compact.d.ts.map +1 -0
- package/dist/domain/commands/builtin/compact.js +84 -0
- package/dist/domain/commands/builtin/compact.js.map +1 -0
- package/dist/domain/commands/builtin/conceal.d.ts +3 -0
- package/dist/domain/commands/builtin/conceal.d.ts.map +1 -0
- package/dist/domain/commands/builtin/conceal.js +8 -0
- package/dist/domain/commands/builtin/conceal.js.map +1 -0
- package/dist/domain/commands/builtin/diffwrap.d.ts +3 -0
- package/dist/domain/commands/builtin/diffwrap.d.ts.map +1 -0
- package/dist/domain/commands/builtin/diffwrap.js +8 -0
- package/dist/domain/commands/builtin/diffwrap.js.map +1 -0
- package/dist/domain/commands/builtin/editor.d.ts +3 -0
- package/dist/domain/commands/builtin/editor.d.ts.map +1 -0
- package/dist/domain/commands/builtin/editor.js +22 -0
- package/dist/domain/commands/builtin/editor.js.map +1 -0
- package/dist/domain/commands/builtin/exit.d.ts +3 -0
- package/dist/domain/commands/builtin/exit.d.ts.map +1 -0
- package/dist/domain/commands/builtin/exit.js +14 -0
- package/dist/domain/commands/builtin/exit.js.map +1 -0
- package/dist/domain/commands/builtin/followup.d.ts +3 -0
- package/dist/domain/commands/builtin/followup.d.ts.map +1 -0
- package/dist/domain/commands/builtin/followup.js +20 -0
- package/dist/domain/commands/builtin/followup.js.map +1 -0
- package/dist/domain/commands/builtin/index.d.ts +2 -0
- package/dist/domain/commands/builtin/index.d.ts.map +1 -0
- package/dist/domain/commands/builtin/index.js +29 -0
- package/dist/domain/commands/builtin/index.js.map +1 -0
- package/dist/domain/commands/builtin/login.d.ts +3 -0
- package/dist/domain/commands/builtin/login.d.ts.map +1 -0
- package/dist/domain/commands/builtin/login.js +92 -0
- package/dist/domain/commands/builtin/login.js.map +1 -0
- package/dist/domain/commands/builtin/model.d.ts +3 -0
- package/dist/domain/commands/builtin/model.d.ts.map +1 -0
- package/dist/domain/commands/builtin/model.js +53 -0
- package/dist/domain/commands/builtin/model.js.map +1 -0
- package/dist/domain/commands/builtin/status.d.ts +3 -0
- package/dist/domain/commands/builtin/status.d.ts.map +1 -0
- package/dist/domain/commands/builtin/status.js +30 -0
- package/dist/domain/commands/builtin/status.js.map +1 -0
- package/dist/domain/commands/builtin/steer.d.ts +3 -0
- package/dist/domain/commands/builtin/steer.d.ts.map +1 -0
- package/dist/domain/commands/builtin/steer.js +20 -0
- package/dist/domain/commands/builtin/steer.js.map +1 -0
- package/dist/domain/commands/builtin/theme.d.ts +3 -0
- package/dist/domain/commands/builtin/theme.d.ts.map +1 -0
- package/dist/domain/commands/builtin/theme.js +19 -0
- package/dist/domain/commands/builtin/theme.js.map +1 -0
- package/dist/domain/commands/builtin/thinking.d.ts +3 -0
- package/dist/domain/commands/builtin/thinking.d.ts.map +1 -0
- package/dist/domain/commands/builtin/thinking.js +16 -0
- package/dist/domain/commands/builtin/thinking.js.map +1 -0
- package/dist/domain/commands/helpers.d.ts +7 -0
- package/dist/domain/commands/helpers.d.ts.map +1 -0
- package/dist/domain/commands/helpers.js +34 -0
- package/dist/domain/commands/helpers.js.map +1 -0
- package/dist/domain/commands/registry.d.ts +10 -0
- package/dist/domain/commands/registry.d.ts.map +1 -0
- package/dist/domain/commands/registry.js +36 -0
- package/dist/domain/commands/registry.js.map +1 -0
- package/dist/domain/commands/types.d.ts +62 -0
- package/dist/domain/commands/types.d.ts.map +1 -0
- package/dist/domain/commands/types.js +2 -0
- package/dist/domain/commands/types.js.map +1 -0
- package/dist/domain/messaging/content.d.ts +37 -0
- package/dist/domain/messaging/content.d.ts.map +1 -0
- package/dist/domain/messaging/content.js +103 -0
- package/dist/domain/messaging/content.js.map +1 -0
- package/dist/editor.d.ts +26 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +81 -0
- package/dist/editor.js.map +1 -0
- package/dist/extensibility/schema.d.ts +2 -0
- package/dist/extensibility/schema.d.ts.map +1 -0
- package/{src/extensibility/schema.ts → dist/extensibility/schema.js} +2 -1
- package/dist/extensibility/schema.js.map +1 -0
- package/dist/extensibility/validation.d.ts +2 -0
- package/dist/extensibility/validation.d.ts.map +1 -0
- package/{src/extensibility/validation.ts → dist/extensibility/validation.js} +2 -1
- package/dist/extensibility/validation.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAgentEvents.d.ts +8 -0
- package/dist/hooks/useAgentEvents.d.ts.map +1 -0
- package/dist/hooks/useAgentEvents.js +22 -0
- package/dist/hooks/useAgentEvents.js.map +1 -0
- package/dist/hooks/useEditorBridge.d.ts +20 -0
- package/dist/hooks/useEditorBridge.d.ts.map +1 -0
- package/dist/hooks/useEditorBridge.js +80 -0
- package/dist/hooks/useEditorBridge.js.map +1 -0
- package/dist/hooks/useGitStatus.d.ts +2 -0
- package/dist/hooks/useGitStatus.d.ts.map +1 -0
- package/dist/hooks/useGitStatus.js +26 -0
- package/dist/hooks/useGitStatus.js.map +1 -0
- package/dist/hooks/usePromptQueue.d.ts +2 -0
- package/dist/hooks/usePromptQueue.d.ts.map +1 -0
- package/dist/hooks/usePromptQueue.js +2 -0
- package/dist/hooks/usePromptQueue.js.map +1 -0
- package/dist/hooks/useSessionController.d.ts +2 -0
- package/dist/hooks/useSessionController.d.ts.map +1 -0
- package/dist/hooks/useSessionController.js +2 -0
- package/dist/hooks/useSessionController.js.map +1 -0
- package/dist/hooks/useSpinner.d.ts +4 -0
- package/dist/hooks/useSpinner.d.ts.map +1 -0
- package/dist/hooks/useSpinner.js +25 -0
- package/dist/hooks/useSpinner.js.map +1 -0
- package/dist/hooks/useToastManager.d.ts +6 -0
- package/dist/hooks/useToastManager.d.ts.map +1 -0
- package/dist/hooks/useToastManager.js +22 -0
- package/dist/hooks/useToastManager.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +156 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-handler.d.ts +30 -0
- package/dist/keyboard-handler.d.ts.map +1 -0
- package/dist/keyboard-handler.js +96 -0
- package/dist/keyboard-handler.js.map +1 -0
- package/dist/profiler.d.ts +2 -0
- package/dist/profiler.d.ts.map +1 -0
- package/dist/profiler.js +41 -0
- package/dist/profiler.js.map +1 -0
- package/dist/runtime/context.d.ts +8 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.jsx +11 -0
- package/dist/runtime/context.jsx.map +1 -0
- package/dist/runtime/factory.d.ts +12 -0
- package/dist/runtime/factory.d.ts.map +1 -0
- package/dist/runtime/factory.js +37 -0
- package/dist/runtime/factory.js.map +1 -0
- package/dist/runtime/git/git-info.d.ts +3 -0
- package/dist/runtime/git/git-info.d.ts.map +1 -0
- package/dist/runtime/git/git-info.js +29 -0
- package/dist/runtime/git/git-info.js.map +1 -0
- package/dist/runtime/session/session-controller.d.ts +48 -0
- package/dist/runtime/session/session-controller.d.ts.map +1 -0
- package/dist/runtime/session/session-controller.js +159 -0
- package/dist/runtime/session/session-controller.js.map +1 -0
- package/dist/session-manager.d.ts +2 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +2 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/session-picker.d.ts +6 -0
- package/dist/session-picker.d.ts.map +1 -0
- package/dist/session-picker.jsx +96 -0
- package/dist/session-picker.jsx.map +1 -0
- package/dist/shell-runner.d.ts +21 -0
- package/dist/shell-runner.d.ts.map +1 -0
- package/dist/shell-runner.js +106 -0
- package/dist/shell-runner.js.map +1 -0
- package/dist/syntax-highlighting.d.ts +4 -0
- package/dist/syntax-highlighting.d.ts.map +1 -0
- package/dist/syntax-highlighting.js +108 -0
- package/dist/syntax-highlighting.js.map +1 -0
- package/dist/theme-names.d.ts +7 -0
- package/dist/theme-names.d.ts.map +1 -0
- package/dist/theme-names.js +38 -0
- package/dist/theme-names.js.map +1 -0
- package/dist/tool-ui-contracts.d.ts +30 -0
- package/dist/tool-ui-contracts.d.ts.map +1 -0
- package/dist/tool-ui-contracts.js +53 -0
- package/dist/tool-ui-contracts.js.map +1 -0
- package/dist/tui-open-rendering.d.ts +37 -0
- package/dist/tui-open-rendering.d.ts.map +1 -0
- package/dist/tui-open-rendering.jsx +462 -0
- package/dist/tui-open-rendering.jsx.map +1 -0
- package/dist/types.d.ts +117 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/app-shell/TuiApp.d.ts +6 -0
- package/dist/ui/app-shell/TuiApp.d.ts.map +1 -0
- package/dist/ui/app-shell/TuiApp.jsx +480 -0
- package/dist/ui/app-shell/TuiApp.jsx.map +1 -0
- package/dist/ui/clipboard/osc52.d.ts +2 -0
- package/dist/ui/clipboard/osc52.d.ts.map +1 -0
- package/dist/ui/clipboard/osc52.js +19 -0
- package/dist/ui/clipboard/osc52.js.map +1 -0
- package/dist/ui/components/modals/ConfirmModal.d.ts +8 -0
- package/dist/ui/components/modals/ConfirmModal.d.ts.map +1 -0
- package/dist/ui/components/modals/ConfirmModal.jsx +39 -0
- package/dist/ui/components/modals/ConfirmModal.jsx.map +1 -0
- package/dist/ui/components/modals/EditorModal.d.ts +8 -0
- package/dist/ui/components/modals/EditorModal.d.ts.map +1 -0
- package/dist/ui/components/modals/EditorModal.jsx +23 -0
- package/dist/ui/components/modals/EditorModal.jsx.map +1 -0
- package/dist/ui/components/modals/InputModal.d.ts +8 -0
- package/dist/ui/components/modals/InputModal.d.ts.map +1 -0
- package/dist/ui/components/modals/InputModal.jsx +15 -0
- package/dist/ui/components/modals/InputModal.jsx.map +1 -0
- package/dist/ui/components/modals/ModalContainer.d.ts +8 -0
- package/dist/ui/components/modals/ModalContainer.d.ts.map +1 -0
- package/dist/ui/components/modals/ModalContainer.jsx +34 -0
- package/dist/ui/components/modals/ModalContainer.jsx.map +1 -0
- package/dist/ui/components/modals/SelectModal.d.ts +8 -0
- package/dist/ui/components/modals/SelectModal.d.ts.map +1 -0
- package/dist/ui/components/modals/SelectModal.jsx +32 -0
- package/dist/ui/components/modals/SelectModal.jsx.map +1 -0
- package/{src/ui/components/modals/index.ts → dist/ui/components/modals/index.d.ts} +5 -4
- package/dist/ui/components/modals/index.d.ts.map +1 -0
- package/dist/ui/components/modals/index.js +5 -0
- package/dist/ui/components/modals/index.js.map +1 -0
- package/dist/ui/features/composer/Composer.d.ts +16 -0
- package/dist/ui/features/composer/Composer.d.ts.map +1 -0
- package/dist/ui/features/composer/Composer.jsx +39 -0
- package/dist/ui/features/composer/Composer.jsx.map +1 -0
- package/dist/ui/features/composer/SlashCommandHandler.d.ts +14 -0
- package/dist/ui/features/composer/SlashCommandHandler.d.ts.map +1 -0
- package/dist/ui/features/composer/SlashCommandHandler.js +43 -0
- package/dist/ui/features/composer/SlashCommandHandler.js.map +1 -0
- package/dist/ui/features/composer/keyboard.d.ts +3 -0
- package/dist/ui/features/composer/keyboard.d.ts.map +1 -0
- package/dist/ui/features/composer/keyboard.js +3 -0
- package/dist/ui/features/composer/keyboard.js.map +1 -0
- package/dist/ui/features/main-view/MainView.d.ts +52 -0
- package/dist/ui/features/main-view/MainView.d.ts.map +1 -0
- package/dist/ui/features/main-view/MainView.jsx +269 -0
- package/dist/ui/features/main-view/MainView.jsx.map +1 -0
- package/dist/ui/features/message-pane/MessagePane.d.ts +15 -0
- package/dist/ui/features/message-pane/MessagePane.d.ts.map +1 -0
- package/dist/ui/features/message-pane/MessagePane.jsx +7 -0
- package/dist/ui/features/message-pane/MessagePane.jsx.map +1 -0
- package/dist/ui/hooks/useModals.d.ts +35 -0
- package/dist/ui/hooks/useModals.d.ts.map +1 -0
- package/dist/ui/hooks/useModals.js +36 -0
- package/dist/ui/hooks/useModals.js.map +1 -0
- package/dist/ui/state/app-store.d.ts +42 -0
- package/dist/ui/state/app-store.d.ts.map +1 -0
- package/dist/ui/state/app-store.js +28 -0
- package/dist/ui/state/app-store.js.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +3 -0
- package/dist/utils.js.map +1 -0
- package/package.json +20 -7
- package/src/adapters/acp/index.ts +0 -305
- package/src/adapters/acp/protocol.ts +0 -191
- package/src/adapters/acp/session.ts +0 -289
- package/src/adapters/acp/updates.ts +0 -96
- package/src/adapters/cli/headless.ts +0 -112
- package/src/adapters/cli/validate.ts +0 -50
- package/src/adapters/tui/app.tsx +0 -39
- package/src/agent-events.ts +0 -671
- package/src/args.ts +0 -102
- package/src/autocomplete-commands.ts +0 -102
- package/src/commands.ts +0 -23
- package/src/compact-handler.ts +0 -272
- package/src/components/Footer.tsx +0 -49
- package/src/components/Header.tsx +0 -218
- package/src/components/MessageList.tsx +0 -380
- package/src/config.ts +0 -1
- package/src/domain/commands/builtin/clear.ts +0 -14
- package/src/domain/commands/builtin/compact.ts +0 -96
- package/src/domain/commands/builtin/conceal.ts +0 -9
- package/src/domain/commands/builtin/diffwrap.ts +0 -9
- package/src/domain/commands/builtin/editor.ts +0 -24
- package/src/domain/commands/builtin/exit.ts +0 -14
- package/src/domain/commands/builtin/followup.ts +0 -24
- package/src/domain/commands/builtin/index.ts +0 -29
- package/src/domain/commands/builtin/login.ts +0 -118
- package/src/domain/commands/builtin/model.ts +0 -66
- package/src/domain/commands/builtin/status.ts +0 -32
- package/src/domain/commands/builtin/steer.ts +0 -24
- package/src/domain/commands/builtin/theme.ts +0 -23
- package/src/domain/commands/builtin/thinking.ts +0 -16
- package/src/domain/commands/helpers.ts +0 -41
- package/src/domain/commands/registry.ts +0 -42
- package/src/domain/commands/types.ts +0 -69
- package/src/domain/messaging/content.ts +0 -117
- package/src/editor.ts +0 -103
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useAgentEvents.ts +0 -28
- package/src/hooks/useEditorBridge.ts +0 -101
- package/src/hooks/useGitStatus.ts +0 -28
- package/src/hooks/usePromptQueue.ts +0 -7
- package/src/hooks/useSessionController.ts +0 -5
- package/src/hooks/useSpinner.ts +0 -28
- package/src/hooks/useToastManager.ts +0 -26
- package/src/index.ts +0 -188
- package/src/keyboard-handler.ts +0 -134
- package/src/profiler.ts +0 -40
- package/src/runtime/context.tsx +0 -16
- package/src/runtime/factory.ts +0 -63
- package/src/runtime/git/git-info.ts +0 -25
- package/src/runtime/session/session-controller.ts +0 -208
- package/src/session-manager.ts +0 -1
- package/src/session-picker.tsx +0 -134
- package/src/shell-runner.ts +0 -134
- package/src/syntax-highlighting.ts +0 -114
- package/src/theme-names.ts +0 -37
- package/src/tool-ui-contracts.ts +0 -77
- package/src/tui-open-rendering.tsx +0 -565
- package/src/types.ts +0 -89
- package/src/ui/app-shell/TuiApp.tsx +0 -586
- package/src/ui/clipboard/osc52.ts +0 -18
- package/src/ui/components/modals/ConfirmModal.tsx +0 -52
- package/src/ui/components/modals/EditorModal.tsx +0 -39
- package/src/ui/components/modals/InputModal.tsx +0 -30
- package/src/ui/components/modals/ModalContainer.tsx +0 -67
- package/src/ui/components/modals/SelectModal.tsx +0 -48
- package/src/ui/features/composer/Composer.tsx +0 -73
- package/src/ui/features/composer/SlashCommandHandler.ts +0 -58
- package/src/ui/features/composer/keyboard.ts +0 -3
- package/src/ui/features/main-view/MainView.tsx +0 -367
- package/src/ui/features/message-pane/MessagePane.tsx +0 -34
- package/src/ui/hooks/useModals.ts +0 -74
- package/src/ui/state/app-store.ts +0 -67
- package/src/utils.ts +0 -14
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ACP Session - wraps Agent and emits ACP updates
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { Agent, AgentEvent, Attachment } from "@yeshwanthyk/agent-core"
|
|
6
|
-
import type { UpdateEmitter } from "./updates.js"
|
|
7
|
-
import type { ContentBlock, SlashCommand, ModelOption, StopReason } from "./protocol.js"
|
|
8
|
-
import { textChunk, thoughtChunk, toolCall, toolCallUpdate, toolNameToKind } from "./updates.js"
|
|
9
|
-
import type { SessionOrchestratorService } from "@yeshwanthyk/runtime-effect/session/orchestrator.js"
|
|
10
|
-
import { Effect } from "effect"
|
|
11
|
-
|
|
12
|
-
export interface AcpSessionConfig {
|
|
13
|
-
sessionId: string
|
|
14
|
-
cwd: string
|
|
15
|
-
agent: Agent
|
|
16
|
-
sessionOrchestrator: SessionOrchestratorService
|
|
17
|
-
emitter: UpdateEmitter
|
|
18
|
-
models: ModelOption[]
|
|
19
|
-
currentModelId: string
|
|
20
|
-
contextWindow: number
|
|
21
|
-
thinkingLevel: string
|
|
22
|
-
setModel: (modelId: string) => boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface AcpSession {
|
|
26
|
-
id: string
|
|
27
|
-
cwd: string
|
|
28
|
-
prompt(content: ContentBlock[]): Promise<StopReason>
|
|
29
|
-
cancel(): void
|
|
30
|
-
getAvailableCommands(): SlashCommand[]
|
|
31
|
-
getModels(): { options: ModelOption[]; currentModelId: string }
|
|
32
|
-
setModel(modelId: string): boolean
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Slash commands exposed to Zed
|
|
36
|
-
const AVAILABLE_COMMANDS: SlashCommand[] = [
|
|
37
|
-
{ name: "model", description: "Switch model: /model <modelId>" },
|
|
38
|
-
{ name: "thinking", description: "Set thinking: /thinking off|minimal|low|medium|high|xhigh" },
|
|
39
|
-
{ name: "status", description: "Show session status" },
|
|
40
|
-
{ name: "compact", description: "Compact conversation context" },
|
|
41
|
-
{ name: "clear", description: "Clear conversation" },
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
export function createAcpSession(config: AcpSessionConfig): AcpSession {
|
|
45
|
-
const { sessionId, cwd, agent, emitter, models, contextWindow, sessionOrchestrator } = config
|
|
46
|
-
let currentModelId = config.currentModelId
|
|
47
|
-
let thinkingLevel = config.thinkingLevel
|
|
48
|
-
let cancelled = false
|
|
49
|
-
let unsubscribe: (() => void) | null = null
|
|
50
|
-
|
|
51
|
-
// Track session stats
|
|
52
|
-
let turnCount = 0
|
|
53
|
-
let lastUsage: { totalTokens: number; cacheRead?: number; cacheWrite?: number } | null = null
|
|
54
|
-
|
|
55
|
-
// Track emitted content to avoid duplicate chunks
|
|
56
|
-
let lastEmittedTextLen = 0
|
|
57
|
-
let lastEmittedThinkingLen = 0
|
|
58
|
-
|
|
59
|
-
// Subscribe to agent events and emit ACP updates
|
|
60
|
-
function subscribeToEvents(): () => void {
|
|
61
|
-
lastEmittedTextLen = 0
|
|
62
|
-
lastEmittedThinkingLen = 0
|
|
63
|
-
|
|
64
|
-
return agent.subscribe((event: AgentEvent) => {
|
|
65
|
-
if (cancelled) return
|
|
66
|
-
|
|
67
|
-
switch (event.type) {
|
|
68
|
-
case "message_update":
|
|
69
|
-
if (event.message.role === "assistant") {
|
|
70
|
-
// Extract text and thinking from content
|
|
71
|
-
const content = event.message.content as unknown[]
|
|
72
|
-
let totalText = ""
|
|
73
|
-
let totalThinking = ""
|
|
74
|
-
|
|
75
|
-
for (const block of content) {
|
|
76
|
-
if (typeof block !== "object" || block === null) continue
|
|
77
|
-
const b = block as Record<string, unknown>
|
|
78
|
-
if (b.type === "text" && typeof b.text === "string") {
|
|
79
|
-
totalText += b.text
|
|
80
|
-
} else if (b.type === "thinking" && typeof b.thinking === "string") {
|
|
81
|
-
totalThinking += b.thinking
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Emit only new content (delta)
|
|
86
|
-
if (totalText.length > lastEmittedTextLen) {
|
|
87
|
-
const delta = totalText.slice(lastEmittedTextLen)
|
|
88
|
-
lastEmittedTextLen = totalText.length
|
|
89
|
-
emitter.emit(textChunk(delta))
|
|
90
|
-
}
|
|
91
|
-
if (totalThinking.length > lastEmittedThinkingLen) {
|
|
92
|
-
const delta = totalThinking.slice(lastEmittedThinkingLen)
|
|
93
|
-
lastEmittedThinkingLen = totalThinking.length
|
|
94
|
-
emitter.emit(thoughtChunk(delta))
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
break
|
|
98
|
-
|
|
99
|
-
case "tool_execution_start":
|
|
100
|
-
emitter.emit(
|
|
101
|
-
toolCall(
|
|
102
|
-
event.toolCallId,
|
|
103
|
-
event.toolName,
|
|
104
|
-
toolNameToKind(event.toolName),
|
|
105
|
-
event.args
|
|
106
|
-
)
|
|
107
|
-
)
|
|
108
|
-
break
|
|
109
|
-
|
|
110
|
-
case "tool_execution_update":
|
|
111
|
-
emitter.emit(
|
|
112
|
-
toolCallUpdate(
|
|
113
|
-
event.toolCallId,
|
|
114
|
-
"in_progress",
|
|
115
|
-
event.partialResult ? JSON.stringify(event.partialResult) : undefined
|
|
116
|
-
)
|
|
117
|
-
)
|
|
118
|
-
break
|
|
119
|
-
|
|
120
|
-
case "tool_execution_end":
|
|
121
|
-
emitter.emit(
|
|
122
|
-
toolCallUpdate(
|
|
123
|
-
event.toolCallId,
|
|
124
|
-
event.isError ? "failed" : "completed",
|
|
125
|
-
event.result ? JSON.stringify(event.result) : undefined
|
|
126
|
-
)
|
|
127
|
-
)
|
|
128
|
-
break
|
|
129
|
-
|
|
130
|
-
case "message_end":
|
|
131
|
-
// Capture usage from assistant messages
|
|
132
|
-
if (event.message.role === "assistant") {
|
|
133
|
-
const msg = event.message as { usage?: { totalTokens?: number; cacheRead?: number; cacheWrite?: number } }
|
|
134
|
-
if (msg.usage?.totalTokens) {
|
|
135
|
-
lastUsage = {
|
|
136
|
-
totalTokens: msg.usage.totalTokens,
|
|
137
|
-
cacheRead: msg.usage.cacheRead,
|
|
138
|
-
cacheWrite: msg.usage.cacheWrite,
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
break
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function prompt(content: ContentBlock[]): Promise<StopReason> {
|
|
148
|
-
cancelled = false
|
|
149
|
-
turnCount++
|
|
150
|
-
unsubscribe = subscribeToEvents()
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
// Check for slash command
|
|
154
|
-
const firstText = content.find((b) => b.type === "text")?.text?.trim()
|
|
155
|
-
if (firstText?.startsWith("/")) {
|
|
156
|
-
return handleSlashCommand(firstText)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Extract text and images
|
|
160
|
-
let textContent = ""
|
|
161
|
-
const images: Array<{ data: string; mimeType: string }> = []
|
|
162
|
-
|
|
163
|
-
for (const block of content) {
|
|
164
|
-
if (block.type === "text" && block.text) {
|
|
165
|
-
textContent += block.text
|
|
166
|
-
} else if (block.type === "image" && block.data && block.mimeType) {
|
|
167
|
-
images.push({ data: block.data, mimeType: block.mimeType })
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (!textContent && images.length === 0) {
|
|
172
|
-
return "end_turn"
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Convert images to attachment format
|
|
176
|
-
const attachments: Attachment[] = images.map((img, idx) => ({
|
|
177
|
-
id: `acp-img-${idx}`,
|
|
178
|
-
type: "image",
|
|
179
|
-
content: img.data,
|
|
180
|
-
mimeType: img.mimeType,
|
|
181
|
-
fileName: `image-${idx}`,
|
|
182
|
-
size: Math.ceil(img.data.length * 0.75),
|
|
183
|
-
}))
|
|
184
|
-
|
|
185
|
-
await Effect.runPromise(
|
|
186
|
-
sessionOrchestrator.submitPromptAndWait(textContent, {
|
|
187
|
-
mode: "followUp",
|
|
188
|
-
attachments: attachments.length > 0 ? attachments : undefined,
|
|
189
|
-
}),
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
return cancelled ? "cancelled" : "end_turn"
|
|
193
|
-
} finally {
|
|
194
|
-
unsubscribe?.()
|
|
195
|
-
unsubscribe = null
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function handleSlashCommand(line: string): StopReason {
|
|
200
|
-
const parts = line.slice(1).split(/\s+/)
|
|
201
|
-
const cmd = parts[0]?.toLowerCase()
|
|
202
|
-
const args = parts.slice(1).join(" ")
|
|
203
|
-
|
|
204
|
-
switch (cmd) {
|
|
205
|
-
case "model":
|
|
206
|
-
if (args && setModel(args)) {
|
|
207
|
-
emitter.emit(textChunk(`Model switched to ${args}`))
|
|
208
|
-
} else if (args) {
|
|
209
|
-
emitter.emit(textChunk(`Unknown model: ${args}. Available: ${models.map((m) => m.modelId).join(", ")}`))
|
|
210
|
-
} else {
|
|
211
|
-
emitter.emit(textChunk(`Current model: ${currentModelId}\nAvailable: ${models.map((m) => m.modelId).join(", ")}`))
|
|
212
|
-
}
|
|
213
|
-
break
|
|
214
|
-
|
|
215
|
-
case "thinking": {
|
|
216
|
-
const levels = ["off", "minimal", "low", "medium", "high", "xhigh"]
|
|
217
|
-
if (levels.includes(args)) {
|
|
218
|
-
agent.setThinkingLevel(args as "off" | "minimal" | "low" | "medium" | "high" | "xhigh")
|
|
219
|
-
thinkingLevel = args
|
|
220
|
-
emitter.emit(textChunk(`Thinking level set to ${args}`))
|
|
221
|
-
} else {
|
|
222
|
-
emitter.emit(textChunk(`Invalid thinking level. Use: ${levels.join(", ")}`))
|
|
223
|
-
}
|
|
224
|
-
break
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
case "status": {
|
|
228
|
-
const provider = currentModelId.includes("/") ? currentModelId.split("/")[0] : "anthropic"
|
|
229
|
-
const fmt = (n: number) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n)
|
|
230
|
-
let ctx = `0/${fmt(contextWindow)}`
|
|
231
|
-
let cache = ""
|
|
232
|
-
if (lastUsage && contextWindow > 0) {
|
|
233
|
-
const pct = ((lastUsage.totalTokens / contextWindow) * 100).toFixed(1)
|
|
234
|
-
ctx = `${fmt(lastUsage.totalTokens)}/${fmt(contextWindow)} (${pct}%)`
|
|
235
|
-
if (lastUsage.cacheRead) cache = ` | cache: ${fmt(lastUsage.cacheRead)} read`
|
|
236
|
-
}
|
|
237
|
-
const status = `${currentModelId} (${provider}) | ${thinkingLevel} | ${ctx}${cache} | turns: ${turnCount}`
|
|
238
|
-
emitter.emit(textChunk(status))
|
|
239
|
-
break
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
case "clear":
|
|
243
|
-
agent.reset()
|
|
244
|
-
emitter.emit(textChunk("Conversation cleared"))
|
|
245
|
-
break
|
|
246
|
-
|
|
247
|
-
case "compact":
|
|
248
|
-
emitter.emit(textChunk("Compact not yet implemented in ACP mode"))
|
|
249
|
-
break
|
|
250
|
-
|
|
251
|
-
default:
|
|
252
|
-
emitter.emit(textChunk(`Unknown command: /${cmd}`))
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return "end_turn"
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function cancel(): void {
|
|
259
|
-
cancelled = true
|
|
260
|
-
agent.abort()
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function getAvailableCommands(): SlashCommand[] {
|
|
264
|
-
return AVAILABLE_COMMANDS
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function getModels(): { options: ModelOption[]; currentModelId: string } {
|
|
268
|
-
return { options: models, currentModelId }
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function setModel(modelId: string): boolean {
|
|
272
|
-
const success = config.setModel(modelId)
|
|
273
|
-
if (success) {
|
|
274
|
-
currentModelId = modelId
|
|
275
|
-
emitter.emitModels(models, currentModelId)
|
|
276
|
-
}
|
|
277
|
-
return success
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return {
|
|
281
|
-
id: sessionId,
|
|
282
|
-
cwd,
|
|
283
|
-
prompt,
|
|
284
|
-
cancel,
|
|
285
|
-
getAvailableCommands,
|
|
286
|
-
getModels,
|
|
287
|
-
setModel,
|
|
288
|
-
}
|
|
289
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ACP session/update notification emitter
|
|
3
|
-
* Bridges agent events to ACP protocol notifications
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
SessionUpdate,
|
|
8
|
-
SessionUpdateParams,
|
|
9
|
-
SlashCommand,
|
|
10
|
-
ModelOption,
|
|
11
|
-
ToolCallKind,
|
|
12
|
-
ToolCallStatus,
|
|
13
|
-
JsonRpcNotification,
|
|
14
|
-
} from "./protocol.js"
|
|
15
|
-
import { makeNotification } from "./protocol.js"
|
|
16
|
-
|
|
17
|
-
export interface UpdateEmitter {
|
|
18
|
-
emit(update: SessionUpdate): void
|
|
19
|
-
emitCommands(commands: SlashCommand[]): void
|
|
20
|
-
emitModels(availableModels: ModelOption[], currentModelId: string): void
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function createUpdateEmitter(
|
|
24
|
-
sessionId: string,
|
|
25
|
-
write: (notification: JsonRpcNotification) => void
|
|
26
|
-
): UpdateEmitter {
|
|
27
|
-
const emit = (update: SessionUpdate): void => {
|
|
28
|
-
const params: SessionUpdateParams = { sessionId, update }
|
|
29
|
-
write(makeNotification("session/update", params))
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
emit,
|
|
34
|
-
|
|
35
|
-
emitCommands(commands: SlashCommand[]): void {
|
|
36
|
-
emit({ sessionUpdate: "available_commands_update", availableCommands: commands })
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
emitModels(availableModels: ModelOption[], currentModelId: string): void {
|
|
40
|
-
emit({ sessionUpdate: "models_update", models: { availableModels, currentModelId } })
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ============================================================================
|
|
46
|
-
// Convenience builders for common updates
|
|
47
|
-
// ============================================================================
|
|
48
|
-
|
|
49
|
-
export function textChunk(text: string): SessionUpdate {
|
|
50
|
-
return { sessionUpdate: "agent_message_chunk", content: { type: "text", text } }
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function thoughtChunk(text: string): SessionUpdate {
|
|
54
|
-
return { sessionUpdate: "agent_thought_chunk", content: { type: "text", text } }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function toolCall(
|
|
58
|
-
toolCallId: string,
|
|
59
|
-
title: string,
|
|
60
|
-
kind: ToolCallKind,
|
|
61
|
-
rawInput?: unknown
|
|
62
|
-
): SessionUpdate {
|
|
63
|
-
return {
|
|
64
|
-
sessionUpdate: "tool_call",
|
|
65
|
-
toolCallId,
|
|
66
|
-
title,
|
|
67
|
-
kind,
|
|
68
|
-
status: "pending",
|
|
69
|
-
rawInput,
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function toolCallUpdate(
|
|
74
|
-
toolCallId: string,
|
|
75
|
-
status: ToolCallStatus,
|
|
76
|
-
content?: string,
|
|
77
|
-
title?: string
|
|
78
|
-
): SessionUpdate {
|
|
79
|
-
return {
|
|
80
|
-
sessionUpdate: "tool_call_update",
|
|
81
|
-
toolCallId,
|
|
82
|
-
status,
|
|
83
|
-
title,
|
|
84
|
-
content: content ? [{ type: "text" as const, text: content }] : undefined,
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Map tool names to ACP kinds
|
|
89
|
-
export function toolNameToKind(name: string): ToolCallKind {
|
|
90
|
-
const lower = name.toLowerCase()
|
|
91
|
-
if (lower === "read" || lower.includes("read")) return "read"
|
|
92
|
-
if (lower === "write" || lower.includes("write")) return "write"
|
|
93
|
-
if (lower === "edit" || lower.includes("edit")) return "edit"
|
|
94
|
-
if (lower === "bash" || lower === "command" || lower.includes("terminal")) return "command"
|
|
95
|
-
return "other"
|
|
96
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { Message, TextContent } from "@yeshwanthyk/ai"
|
|
2
|
-
import { Effect } from "effect"
|
|
3
|
-
import { createRuntime, type RuntimeInitArgs } from "@runtime/factory.js"
|
|
4
|
-
|
|
5
|
-
const readStdin = async (): Promise<string> => {
|
|
6
|
-
const chunks: Buffer[] = []
|
|
7
|
-
for await (const chunk of process.stdin) chunks.push(Buffer.from(chunk))
|
|
8
|
-
return Buffer.concat(chunks).toString("utf8")
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const textFromBlocks = (blocks: Array<{ type: string }>): string => {
|
|
12
|
-
const parts: string[] = []
|
|
13
|
-
for (const block of blocks) {
|
|
14
|
-
if (block.type === "text") parts.push((block as TextContent).text)
|
|
15
|
-
}
|
|
16
|
-
return parts.join("")
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const renderMessage = (message: Message): string => {
|
|
20
|
-
if (message.role === "user") {
|
|
21
|
-
if (typeof message.content === "string") return message.content
|
|
22
|
-
return textFromBlocks(message.content)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (message.role === "assistant") {
|
|
26
|
-
const parts: string[] = []
|
|
27
|
-
for (const block of message.content) {
|
|
28
|
-
if (block.type === "text") parts.push(block.text)
|
|
29
|
-
}
|
|
30
|
-
return parts.join("")
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return textFromBlocks(message.content)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface HeadlessArgs extends RuntimeInitArgs {
|
|
37
|
-
prompt?: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const runHeadless = async (args: HeadlessArgs) => {
|
|
41
|
-
const runtime = await createRuntime(
|
|
42
|
-
{
|
|
43
|
-
configDir: args.configDir,
|
|
44
|
-
configPath: args.configPath,
|
|
45
|
-
provider: args.provider,
|
|
46
|
-
model: args.model,
|
|
47
|
-
thinking: args.thinking,
|
|
48
|
-
},
|
|
49
|
-
"headless",
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
// Initialize hooks with no-op handlers for headless mode (single-shot, no UI)
|
|
53
|
-
runtime.hookRunner.initialize({
|
|
54
|
-
sendHandler: () => {},
|
|
55
|
-
sendMessageHandler: () => {},
|
|
56
|
-
sendUserMessageHandler: async () => {},
|
|
57
|
-
steerHandler: async () => {},
|
|
58
|
-
followUpHandler: async () => {},
|
|
59
|
-
isIdleHandler: () => true,
|
|
60
|
-
appendEntryHandler: (customType, data) => runtime.sessionManager.appendEntry(customType, data),
|
|
61
|
-
getSessionId: () => runtime.sessionManager.sessionId,
|
|
62
|
-
getModel: () => runtime.agent.state.model,
|
|
63
|
-
hasUI: false,
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const prompt = (args.prompt ?? (await readStdin())).trim()
|
|
67
|
-
if (!prompt) {
|
|
68
|
-
process.stdout.write(JSON.stringify({ ok: false, error: "Empty prompt" }) + "\n")
|
|
69
|
-
process.exitCode = 2
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
await Effect.runPromise(
|
|
75
|
-
runtime.sessionOrchestrator.submitPromptAndWait(prompt, { mode: "followUp" }),
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
const conversation = runtime.agent.state.messages.filter((m): m is Message => {
|
|
79
|
-
const role = (m as { role?: unknown }).role
|
|
80
|
-
return role === "user" || role === "assistant" || role === "toolResult"
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
const lastAssistant = [...conversation].reverse().find((m) => m.role === "assistant")
|
|
84
|
-
const assistant = lastAssistant ? renderMessage(lastAssistant) : ""
|
|
85
|
-
|
|
86
|
-
process.stdout.write(
|
|
87
|
-
JSON.stringify({
|
|
88
|
-
ok: true,
|
|
89
|
-
provider: runtime.config.provider,
|
|
90
|
-
model: runtime.config.modelId,
|
|
91
|
-
prompt,
|
|
92
|
-
assistant,
|
|
93
|
-
validationIssues: runtime.validationIssues,
|
|
94
|
-
}) + "\n",
|
|
95
|
-
)
|
|
96
|
-
} catch (err) {
|
|
97
|
-
process.stdout.write(
|
|
98
|
-
JSON.stringify({
|
|
99
|
-
ok: false,
|
|
100
|
-
provider: runtime.config.provider,
|
|
101
|
-
model: runtime.config.modelId,
|
|
102
|
-
prompt,
|
|
103
|
-
assistant: "",
|
|
104
|
-
error: err instanceof Error ? err.message : String(err),
|
|
105
|
-
validationIssues: runtime.validationIssues,
|
|
106
|
-
}) + "\n",
|
|
107
|
-
)
|
|
108
|
-
process.exitCode = 1
|
|
109
|
-
} finally {
|
|
110
|
-
await runtime.close().catch(() => {})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { createToolRegistry } from "@yeshwanthyk/base-tools"
|
|
2
|
-
import { loadAppConfig } from "../../config.js"
|
|
3
|
-
import { loadCustomCommands } from "@yeshwanthyk/runtime-effect/extensibility/custom-commands.js"
|
|
4
|
-
import type { RuntimeInitArgs } from "@runtime/factory.js"
|
|
5
|
-
import { loadExtensibility } from "@yeshwanthyk/runtime-effect/extensibility/index.js"
|
|
6
|
-
import { formatValidationIssue, hasBlockingIssues } from "@ext/validation.js"
|
|
7
|
-
import type { ValidationIssue } from "@ext/schema.js"
|
|
8
|
-
import type { SendRef } from "@yeshwanthyk/runtime-effect/extensibility/custom-tools/types.js"
|
|
9
|
-
import { SessionManager } from "../../session-manager.js"
|
|
10
|
-
|
|
11
|
-
export const runValidate = async (args: RuntimeInitArgs = {}): Promise<void> => {
|
|
12
|
-
const loaded = await loadAppConfig({
|
|
13
|
-
configDir: args.configDir,
|
|
14
|
-
configPath: args.configPath,
|
|
15
|
-
provider: args.provider,
|
|
16
|
-
model: args.model,
|
|
17
|
-
thinking: args.thinking,
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const { issues: commandIssues } = loadCustomCommands(loaded.configDir)
|
|
21
|
-
const sendRef: SendRef = { current: () => {} }
|
|
22
|
-
const sessionManager = new SessionManager(loaded.configDir)
|
|
23
|
-
|
|
24
|
-
const builtinToolNames = Object.keys(createToolRegistry(process.cwd()))
|
|
25
|
-
|
|
26
|
-
const extensibility = await loadExtensibility({
|
|
27
|
-
configDir: loaded.configDir,
|
|
28
|
-
cwd: process.cwd(),
|
|
29
|
-
sendRef,
|
|
30
|
-
builtinToolNames,
|
|
31
|
-
hasUI: false,
|
|
32
|
-
sessionManager,
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const issues: ValidationIssue[] = [...commandIssues, ...extensibility.validationIssues]
|
|
36
|
-
|
|
37
|
-
if (issues.length === 0) {
|
|
38
|
-
process.stdout.write("No validation issues found.\n")
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
process.stdout.write(`Found ${issues.length} validation issue${issues.length === 1 ? "" : "s"}:\n`)
|
|
43
|
-
for (const issue of issues) {
|
|
44
|
-
process.stdout.write(`${formatValidationIssue(issue)}\n`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (hasBlockingIssues(issues)) {
|
|
48
|
-
process.exitCode = 1
|
|
49
|
-
}
|
|
50
|
-
}
|
package/src/adapters/tui/app.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { render } from "@opentui/solid"
|
|
2
|
-
import { RuntimeProvider } from "../../runtime/context.js"
|
|
3
|
-
import { createRuntime, type RuntimeInitArgs } from "@runtime/factory.js"
|
|
4
|
-
import type { LoadedSession } from "../../session-manager.js"
|
|
5
|
-
import { selectSession as selectSessionOpen } from "../../session-picker.js"
|
|
6
|
-
import { TuiApp } from "@ui/app-shell/TuiApp.js"
|
|
7
|
-
|
|
8
|
-
interface RunTuiArgs extends RuntimeInitArgs {
|
|
9
|
-
continueSession?: boolean
|
|
10
|
-
resumeSession?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const runTuiOpen = async (args?: RunTuiArgs) => {
|
|
14
|
-
const runtime = await createRuntime(args, "tui")
|
|
15
|
-
const { sessionManager } = runtime
|
|
16
|
-
let initialSession: LoadedSession | null = null
|
|
17
|
-
|
|
18
|
-
if (args?.resumeSession) {
|
|
19
|
-
const selectedPath = await selectSessionOpen(sessionManager)
|
|
20
|
-
if (selectedPath === null) {
|
|
21
|
-
process.stdout.write("No session selected\n")
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
initialSession = sessionManager.loadSession(selectedPath)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (args?.continueSession && !initialSession) {
|
|
28
|
-
initialSession = sessionManager.loadLatest()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
render(
|
|
32
|
-
() => (
|
|
33
|
-
<RuntimeProvider runtime={runtime}>
|
|
34
|
-
<TuiApp initialSession={initialSession} />
|
|
35
|
-
</RuntimeProvider>
|
|
36
|
-
),
|
|
37
|
-
{ targetFps: 30, exitOnCtrlC: false, useKittyKeyboard: {} },
|
|
38
|
-
)
|
|
39
|
-
}
|