@getpaseo/server 0.1.16 → 0.1.17
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/dist/scripts/daemon-runner.js +53 -14
- package/dist/scripts/daemon-runner.js.map +1 -1
- package/dist/scripts/dev-runner.js +9 -16
- package/dist/scripts/dev-runner.js.map +1 -1
- package/dist/scripts/supervisor.js +40 -13
- package/dist/scripts/supervisor.js.map +1 -1
- package/dist/server/client/daemon-client.d.ts +23 -3
- package/dist/server/client/daemon-client.d.ts.map +1 -1
- package/dist/server/client/daemon-client.js +81 -8
- package/dist/server/client/daemon-client.js.map +1 -1
- package/dist/server/server/agent/agent-manager.d.ts +3 -1
- package/dist/server/server/agent/agent-manager.d.ts.map +1 -1
- package/dist/server/server/agent/agent-manager.js +146 -24
- package/dist/server/server/agent/agent-manager.js.map +1 -1
- package/dist/server/server/agent/agent-metadata-generator.d.ts.map +1 -1
- package/dist/server/server/agent/agent-metadata-generator.js +13 -4
- package/dist/server/server/agent/agent-metadata-generator.js.map +1 -1
- package/dist/server/server/agent/agent-response-loop.js +1 -1
- package/dist/server/server/agent/agent-response-loop.js.map +1 -1
- package/dist/server/server/agent/agent-sdk-types.d.ts +9 -0
- package/dist/server/server/agent/agent-sdk-types.d.ts.map +1 -1
- package/dist/server/server/agent/agent-sdk-types.js +11 -1
- package/dist/server/server/agent/agent-sdk-types.js.map +1 -1
- package/dist/server/server/agent/agent-storage.d.ts +5 -1
- package/dist/server/server/agent/agent-storage.d.ts.map +1 -1
- package/dist/server/server/agent/agent-storage.js +41 -72
- package/dist/server/server/agent/agent-storage.js.map +1 -1
- package/dist/server/server/agent/agent-title-limits.d.ts +3 -0
- package/dist/server/server/agent/agent-title-limits.d.ts.map +1 -0
- package/dist/server/server/agent/agent-title-limits.js +3 -0
- package/dist/server/server/agent/agent-title-limits.js.map +1 -0
- package/dist/server/server/agent/providers/claude/model-catalog.d.ts +29 -0
- package/dist/server/server/agent/providers/claude/model-catalog.d.ts.map +1 -0
- package/dist/server/server/agent/providers/claude/model-catalog.js +70 -0
- package/dist/server/server/agent/providers/claude/model-catalog.js.map +1 -0
- package/dist/server/server/agent/providers/claude/task-notification-tool-call.d.ts +44 -0
- package/dist/server/server/agent/providers/claude/task-notification-tool-call.d.ts.map +1 -0
- package/dist/server/server/agent/providers/claude/task-notification-tool-call.js +250 -0
- package/dist/server/server/agent/providers/claude/task-notification-tool-call.js.map +1 -0
- package/dist/server/server/agent/providers/claude/tool-call-detail-parser.d.ts.map +1 -1
- package/dist/server/server/agent/providers/claude/tool-call-detail-parser.js +15 -0
- package/dist/server/server/agent/providers/claude/tool-call-detail-parser.js.map +1 -1
- package/dist/server/server/agent/providers/claude-agent.d.ts +3 -2
- package/dist/server/server/agent/providers/claude-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/claude-agent.js +240 -106
- package/dist/server/server/agent/providers/claude-agent.js.map +1 -1
- package/dist/server/server/agent/providers/codex/tool-call-mapper.d.ts.map +1 -1
- package/dist/server/server/agent/providers/codex/tool-call-mapper.js +81 -28
- package/dist/server/server/agent/providers/codex/tool-call-mapper.js.map +1 -1
- package/dist/server/server/agent/providers/codex-app-server-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/codex-app-server-agent.js +31 -5
- package/dist/server/server/agent/providers/codex-app-server-agent.js.map +1 -1
- package/dist/server/server/agent/providers/opencode-agent.d.ts +10 -1
- package/dist/server/server/agent/providers/opencode-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/opencode-agent.js +207 -176
- package/dist/server/server/agent/providers/opencode-agent.js.map +1 -1
- package/dist/server/server/agent/providers/tool-call-detail-primitives.d.ts +15 -0
- package/dist/server/server/agent/providers/tool-call-detail-primitives.d.ts.map +1 -1
- package/dist/server/server/agent/timeline-projection.d.ts +20 -0
- package/dist/server/server/agent/timeline-projection.d.ts.map +1 -1
- package/dist/server/server/agent/timeline-projection.js +73 -0
- package/dist/server/server/agent/timeline-projection.js.map +1 -1
- package/dist/server/server/bootstrap.d.ts +15 -0
- package/dist/server/server/bootstrap.d.ts.map +1 -1
- package/dist/server/server/bootstrap.js +27 -4
- package/dist/server/server/bootstrap.js.map +1 -1
- package/dist/server/server/file-download/token-store.d.ts +0 -1
- package/dist/server/server/file-download/token-store.d.ts.map +1 -1
- package/dist/server/server/file-download/token-store.js.map +1 -1
- package/dist/server/server/file-explorer/service.d.ts.map +1 -1
- package/dist/server/server/file-explorer/service.js +56 -36
- package/dist/server/server/file-explorer/service.js.map +1 -1
- package/dist/server/server/index.js +85 -29
- package/dist/server/server/index.js.map +1 -1
- package/dist/server/server/logger.d.ts +24 -3
- package/dist/server/server/logger.d.ts.map +1 -1
- package/dist/server/server/logger.js +157 -21
- package/dist/server/server/logger.js.map +1 -1
- package/dist/server/server/persisted-config.d.ts +86 -0
- package/dist/server/server/persisted-config.d.ts.map +1 -1
- package/dist/server/server/persisted-config.js +25 -3
- package/dist/server/server/persisted-config.js.map +1 -1
- package/dist/server/server/pid-lock.d.ts +6 -2
- package/dist/server/server/pid-lock.d.ts.map +1 -1
- package/dist/server/server/pid-lock.js +7 -10
- package/dist/server/server/pid-lock.js.map +1 -1
- package/dist/server/server/relay-transport.d.ts.map +1 -1
- package/dist/server/server/relay-transport.js +1 -0
- package/dist/server/server/relay-transport.js.map +1 -1
- package/dist/server/server/session.d.ts +57 -3
- package/dist/server/server/session.d.ts.map +1 -1
- package/dist/server/server/session.js +755 -182
- package/dist/server/server/session.js.map +1 -1
- package/dist/server/server/websocket-server.d.ts +16 -1
- package/dist/server/server/websocket-server.d.ts.map +1 -1
- package/dist/server/server/websocket-server.js +135 -9
- package/dist/server/server/websocket-server.js.map +1 -1
- package/dist/server/server/worktree-bootstrap.d.ts.map +1 -1
- package/dist/server/server/worktree-bootstrap.js +45 -2
- package/dist/server/server/worktree-bootstrap.js.map +1 -1
- package/dist/server/shared/messages.d.ts +2841 -541
- package/dist/server/shared/messages.d.ts.map +1 -1
- package/dist/server/shared/messages.js +99 -5
- package/dist/server/shared/messages.js.map +1 -1
- package/dist/server/shared/tool-call-display.d.ts.map +1 -1
- package/dist/server/shared/tool-call-display.js +3 -0
- package/dist/server/shared/tool-call-display.js.map +1 -1
- package/dist/server/terminal/terminal-manager.d.ts.map +1 -1
- package/dist/server/terminal/terminal-manager.js +1 -13
- package/dist/server/terminal/terminal-manager.js.map +1 -1
- package/dist/server/terminal/terminal.d.ts.map +1 -1
- package/dist/server/terminal/terminal.js +29 -5
- package/dist/server/terminal/terminal.js.map +1 -1
- package/dist/server/utils/worktree.d.ts +1 -0
- package/dist/server/utils/worktree.d.ts.map +1 -1
- package/dist/server/utils/worktree.js +17 -2
- package/dist/server/utils/worktree.js.map +1 -1
- package/dist/src/server/agent/activity-curator.js +228 -0
- package/dist/src/server/agent/activity-curator.js.map +1 -0
- package/dist/src/server/agent/agent-manager.js +1712 -0
- package/dist/src/server/agent/agent-manager.js.map +1 -0
- package/dist/src/server/agent/agent-metadata-generator.js +163 -0
- package/dist/src/server/agent/agent-metadata-generator.js.map +1 -0
- package/dist/src/server/agent/agent-projections.js +262 -0
- package/dist/src/server/agent/agent-projections.js.map +1 -0
- package/dist/src/server/agent/agent-response-loop.js +304 -0
- package/dist/src/server/agent/agent-response-loop.js.map +1 -0
- package/dist/src/server/agent/agent-sdk-types.js +12 -0
- package/dist/src/server/agent/agent-sdk-types.js.map +1 -0
- package/dist/src/server/agent/agent-storage.js +299 -0
- package/dist/src/server/agent/agent-storage.js.map +1 -0
- package/dist/src/server/agent/agent-title-limits.js +3 -0
- package/dist/src/server/agent/agent-title-limits.js.map +1 -0
- package/dist/src/server/agent/audio-utils.js +19 -0
- package/dist/src/server/agent/audio-utils.js.map +1 -0
- package/dist/src/server/agent/dictation-debug.js +50 -0
- package/dist/src/server/agent/dictation-debug.js.map +1 -0
- package/dist/src/server/agent/mcp-server.js +787 -0
- package/dist/src/server/agent/mcp-server.js.map +1 -0
- package/dist/src/server/agent/orchestrator-instructions.js +51 -0
- package/dist/src/server/agent/orchestrator-instructions.js.map +1 -0
- package/dist/src/server/agent/pcm16-resampler.js +63 -0
- package/dist/src/server/agent/pcm16-resampler.js.map +1 -0
- package/dist/src/server/agent/provider-launch-config.js +83 -0
- package/dist/src/server/agent/provider-launch-config.js.map +1 -0
- package/dist/src/server/agent/provider-manifest.js +97 -0
- package/dist/src/server/agent/provider-manifest.js.map +1 -0
- package/dist/src/server/agent/provider-registry.js +45 -0
- package/dist/src/server/agent/provider-registry.js.map +1 -0
- package/dist/src/server/agent/providers/claude/model-catalog.js +70 -0
- package/dist/src/server/agent/providers/claude/model-catalog.js.map +1 -0
- package/dist/src/server/agent/providers/claude/task-notification-tool-call.js +250 -0
- package/dist/src/server/agent/providers/claude/task-notification-tool-call.js.map +1 -0
- package/dist/src/server/agent/providers/claude/tool-call-detail-parser.js +109 -0
- package/dist/src/server/agent/providers/claude/tool-call-detail-parser.js.map +1 -0
- package/dist/src/server/agent/providers/claude/tool-call-mapper.js +238 -0
- package/dist/src/server/agent/providers/claude/tool-call-mapper.js.map +1 -0
- package/dist/src/server/agent/providers/claude-agent.js +3747 -0
- package/dist/src/server/agent/providers/claude-agent.js.map +1 -0
- package/dist/src/server/agent/providers/codex/tool-call-detail-parser.js +104 -0
- package/dist/src/server/agent/providers/codex/tool-call-detail-parser.js.map +1 -0
- package/dist/src/server/agent/providers/codex/tool-call-mapper.js +720 -0
- package/dist/src/server/agent/providers/codex/tool-call-mapper.js.map +1 -0
- package/dist/src/server/agent/providers/codex-app-server-agent.js +2601 -0
- package/dist/src/server/agent/providers/codex-app-server-agent.js.map +1 -0
- package/dist/src/server/agent/providers/codex-rollout-timeline.js +487 -0
- package/dist/src/server/agent/providers/codex-rollout-timeline.js.map +1 -0
- package/dist/src/server/agent/providers/opencode/tool-call-detail-parser.js +39 -0
- package/dist/src/server/agent/providers/opencode/tool-call-detail-parser.js.map +1 -0
- package/dist/src/server/agent/providers/opencode/tool-call-mapper.js +151 -0
- package/dist/src/server/agent/providers/opencode/tool-call-mapper.js.map +1 -0
- package/dist/src/server/agent/providers/opencode-agent.js +905 -0
- package/dist/src/server/agent/providers/opencode-agent.js.map +1 -0
- package/dist/src/server/agent/providers/tool-call-detail-primitives.js +552 -0
- package/dist/src/server/agent/providers/tool-call-detail-primitives.js.map +1 -0
- package/dist/src/server/agent/providers/tool-call-mapper-utils.js +109 -0
- package/dist/src/server/agent/providers/tool-call-mapper-utils.js.map +1 -0
- package/dist/src/server/agent/recordings-debug.js +19 -0
- package/dist/src/server/agent/recordings-debug.js.map +1 -0
- package/dist/src/server/agent/stt-debug.js +33 -0
- package/dist/src/server/agent/stt-debug.js.map +1 -0
- package/dist/src/server/agent/stt-manager.js +233 -0
- package/dist/src/server/agent/stt-manager.js.map +1 -0
- package/dist/src/server/agent/timeline-append.js +27 -0
- package/dist/src/server/agent/timeline-append.js.map +1 -0
- package/dist/src/server/agent/timeline-projection.js +215 -0
- package/dist/src/server/agent/timeline-projection.js.map +1 -0
- package/dist/src/server/agent/tool-name-normalization.js +45 -0
- package/dist/src/server/agent/tool-name-normalization.js.map +1 -0
- package/dist/src/server/agent/tts-debug.js +24 -0
- package/dist/src/server/agent/tts-debug.js.map +1 -0
- package/dist/src/server/agent/tts-manager.js +249 -0
- package/dist/src/server/agent/tts-manager.js.map +1 -0
- package/dist/src/server/agent/wait-for-agent-tracker.js +53 -0
- package/dist/src/server/agent/wait-for-agent-tracker.js.map +1 -0
- package/dist/src/server/agent-attention-policy.js +40 -0
- package/dist/src/server/agent-attention-policy.js.map +1 -0
- package/dist/src/server/allowed-hosts.js +94 -0
- package/dist/src/server/allowed-hosts.js.map +1 -0
- package/dist/src/server/bootstrap.js +498 -0
- package/dist/src/server/bootstrap.js.map +1 -0
- package/dist/src/server/client-message-id.js +12 -0
- package/dist/src/server/client-message-id.js.map +1 -0
- package/dist/src/server/config.js +84 -0
- package/dist/src/server/config.js.map +1 -0
- package/dist/src/server/connection-offer.js +60 -0
- package/dist/src/server/connection-offer.js.map +1 -0
- package/dist/src/server/daemon-keypair.js +40 -0
- package/dist/src/server/daemon-keypair.js.map +1 -0
- package/dist/src/server/daemon-version.js +22 -0
- package/dist/src/server/daemon-version.js.map +1 -0
- package/dist/src/server/dictation/dictation-stream-manager.js +568 -0
- package/dist/src/server/dictation/dictation-stream-manager.js.map +1 -0
- package/dist/src/server/file-download/token-store.js +40 -0
- package/dist/src/server/file-download/token-store.js.map +1 -0
- package/dist/src/server/file-explorer/service.js +183 -0
- package/dist/src/server/file-explorer/service.js.map +1 -0
- package/dist/src/server/json-utils.js +45 -0
- package/dist/src/server/json-utils.js.map +1 -0
- package/dist/src/server/messages.js +29 -0
- package/dist/src/server/messages.js.map +1 -0
- package/dist/src/server/package-version.js +47 -0
- package/dist/src/server/package-version.js.map +1 -0
- package/dist/src/server/paseo-home.js +19 -0
- package/dist/src/server/paseo-home.js.map +1 -0
- package/dist/src/server/path-utils.js +20 -0
- package/dist/src/server/path-utils.js.map +1 -0
- package/dist/src/server/persisted-config.js +259 -0
- package/dist/src/server/persisted-config.js.map +1 -0
- package/dist/src/server/persistence-hooks.js +60 -0
- package/dist/src/server/persistence-hooks.js.map +1 -0
- package/dist/src/server/pid-lock.js +126 -0
- package/dist/src/server/pid-lock.js.map +1 -0
- package/dist/src/server/push/push-service.js +68 -0
- package/dist/src/server/push/push-service.js.map +1 -0
- package/dist/src/server/push/token-store.js +70 -0
- package/dist/src/server/push/token-store.js.map +1 -0
- package/dist/src/server/relay-transport.js +457 -0
- package/dist/src/server/relay-transport.js.map +1 -0
- package/dist/src/server/server-id.js +63 -0
- package/dist/src/server/server-id.js.map +1 -0
- package/dist/src/server/session.js +5947 -0
- package/dist/src/server/session.js.map +1 -0
- package/dist/src/server/speech/audio.js +101 -0
- package/dist/src/server/speech/audio.js.map +1 -0
- package/dist/src/server/speech/provider-resolver.js +7 -0
- package/dist/src/server/speech/provider-resolver.js.map +1 -0
- package/dist/src/server/speech/providers/local/config.js +83 -0
- package/dist/src/server/speech/providers/local/config.js.map +1 -0
- package/dist/src/server/speech/providers/local/models.js +17 -0
- package/dist/src/server/speech/providers/local/models.js.map +1 -0
- package/dist/src/server/speech/providers/local/pocket/pocket-tts-onnx.js +422 -0
- package/dist/src/server/speech/providers/local/pocket/pocket-tts-onnx.js.map +1 -0
- package/dist/src/server/speech/providers/local/runtime.js +253 -0
- package/dist/src/server/speech/providers/local/runtime.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/model-catalog.js +166 -0
- package/dist/src/server/speech/providers/local/sherpa/model-catalog.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/model-downloader.js +165 -0
- package/dist/src/server/speech/providers/local/sherpa/model-downloader.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-offline-recognizer.js +68 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-offline-recognizer.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-online-recognizer.js +79 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-online-recognizer.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-onnx-loader.js +11 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-onnx-loader.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-onnx-node-loader.js +102 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-onnx-node-loader.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-parakeet-realtime-session.js +131 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-parakeet-realtime-session.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-parakeet-stt.js +132 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-parakeet-stt.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-realtime-session.js +112 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-realtime-session.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-stt.js +140 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-stt.js.map +1 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-tts.js +95 -0
- package/dist/src/server/speech/providers/local/sherpa/sherpa-tts.js.map +1 -0
- package/dist/src/server/speech/providers/openai/config.js +99 -0
- package/dist/src/server/speech/providers/openai/config.js.map +1 -0
- package/dist/src/server/speech/providers/openai/realtime-transcription-session.js +165 -0
- package/dist/src/server/speech/providers/openai/realtime-transcription-session.js.map +1 -0
- package/dist/src/server/speech/providers/openai/runtime.js +114 -0
- package/dist/src/server/speech/providers/openai/runtime.js.map +1 -0
- package/dist/src/server/speech/providers/openai/stt.js +208 -0
- package/dist/src/server/speech/providers/openai/stt.js.map +1 -0
- package/dist/src/server/speech/providers/openai/tts.js +46 -0
- package/dist/src/server/speech/providers/openai/tts.js.map +1 -0
- package/dist/src/server/speech/speech-config-resolver.js +85 -0
- package/dist/src/server/speech/speech-config-resolver.js.map +1 -0
- package/dist/src/server/speech/speech-provider.js +2 -0
- package/dist/src/server/speech/speech-provider.js.map +1 -0
- package/dist/src/server/speech/speech-runtime.js +497 -0
- package/dist/src/server/speech/speech-runtime.js.map +1 -0
- package/dist/src/server/speech/speech-types.js +8 -0
- package/dist/src/server/speech/speech-types.js.map +1 -0
- package/dist/src/server/utils/diff-highlighter.js +244 -0
- package/dist/src/server/utils/diff-highlighter.js.map +1 -0
- package/dist/src/server/utils/syntax-highlighter.js +145 -0
- package/dist/src/server/utils/syntax-highlighter.js.map +1 -0
- package/dist/src/server/voice-config.js +51 -0
- package/dist/src/server/voice-config.js.map +1 -0
- package/dist/src/server/voice-mcp-bridge-command.js +31 -0
- package/dist/src/server/voice-mcp-bridge-command.js.map +1 -0
- package/dist/src/server/voice-mcp-bridge.js +109 -0
- package/dist/src/server/voice-mcp-bridge.js.map +1 -0
- package/dist/src/server/voice-permission-policy.js +13 -0
- package/dist/src/server/voice-permission-policy.js.map +1 -0
- package/dist/src/server/voice-types.js +2 -0
- package/dist/src/server/voice-types.js.map +1 -0
- package/dist/src/server/websocket-server.js +967 -0
- package/dist/src/server/websocket-server.js.map +1 -0
- package/dist/src/server/worktree-bootstrap.js +497 -0
- package/dist/src/server/worktree-bootstrap.js.map +1 -0
- package/dist/src/shared/agent-attention-notification.js +130 -0
- package/dist/src/shared/agent-attention-notification.js.map +1 -0
- package/dist/src/shared/agent-lifecycle.js +8 -0
- package/dist/src/shared/agent-lifecycle.js.map +1 -0
- package/dist/src/shared/binary-mux.js +114 -0
- package/dist/src/shared/binary-mux.js.map +1 -0
- package/dist/src/shared/connection-offer.js +17 -0
- package/dist/src/shared/connection-offer.js.map +1 -0
- package/dist/src/shared/daemon-endpoints.js +113 -0
- package/dist/src/shared/daemon-endpoints.js.map +1 -0
- package/dist/src/shared/messages.js +2001 -0
- package/dist/src/shared/messages.js.map +1 -0
- package/dist/src/shared/path-utils.js +16 -0
- package/dist/src/shared/path-utils.js.map +1 -0
- package/dist/src/shared/tool-call-display.js +93 -0
- package/dist/src/shared/tool-call-display.js.map +1 -0
- package/dist/src/terminal/terminal-manager.js +136 -0
- package/dist/src/terminal/terminal-manager.js.map +1 -0
- package/dist/src/terminal/terminal.js +410 -0
- package/dist/src/terminal/terminal.js.map +1 -0
- package/dist/src/utils/checkout-git.js +1397 -0
- package/dist/src/utils/checkout-git.js.map +1 -0
- package/dist/src/utils/directory-suggestions.js +655 -0
- package/dist/src/utils/directory-suggestions.js.map +1 -0
- package/dist/src/utils/path.js +15 -0
- package/dist/src/utils/path.js.map +1 -0
- package/dist/src/utils/project-icon.js +391 -0
- package/dist/src/utils/project-icon.js.map +1 -0
- package/dist/src/utils/worktree-metadata.js +116 -0
- package/dist/src/utils/worktree-metadata.js.map +1 -0
- package/dist/src/utils/worktree.js +741 -0
- package/dist/src/utils/worktree.js.map +1 -0
- package/package.json +14 -6
|
@@ -0,0 +1,2001 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AGENT_LIFECYCLE_STATUSES } from './agent-lifecycle.js';
|
|
3
|
+
import { MAX_EXPLICIT_AGENT_TITLE_CHARS } from '../server/agent/agent-title-limits.js';
|
|
4
|
+
import { AgentProviderSchema } from '../server/agent/provider-manifest.js';
|
|
5
|
+
import { TOOL_CALL_ICON_NAMES } from '../server/agent/agent-sdk-types.js';
|
|
6
|
+
export const AgentStatusSchema = z.enum(AGENT_LIFECYCLE_STATUSES);
|
|
7
|
+
const AgentModeSchema = z.object({
|
|
8
|
+
id: z.string(),
|
|
9
|
+
label: z.string(),
|
|
10
|
+
description: z.string().optional(),
|
|
11
|
+
});
|
|
12
|
+
const AgentSelectOptionSchema = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
label: z.string(),
|
|
15
|
+
description: z.string().optional(),
|
|
16
|
+
isDefault: z.boolean().optional(),
|
|
17
|
+
metadata: z.record(z.unknown()).optional(),
|
|
18
|
+
});
|
|
19
|
+
const AgentModelDefinitionSchema = z.object({
|
|
20
|
+
provider: AgentProviderSchema,
|
|
21
|
+
id: z.string(),
|
|
22
|
+
label: z.string(),
|
|
23
|
+
description: z.string().optional(),
|
|
24
|
+
isDefault: z.boolean().optional(),
|
|
25
|
+
metadata: z.record(z.unknown()).optional(),
|
|
26
|
+
thinkingOptions: z.array(AgentSelectOptionSchema).optional(),
|
|
27
|
+
defaultThinkingOptionId: z.string().optional(),
|
|
28
|
+
});
|
|
29
|
+
const AgentCapabilityFlagsSchema = z.object({
|
|
30
|
+
supportsStreaming: z.boolean(),
|
|
31
|
+
supportsSessionPersistence: z.boolean(),
|
|
32
|
+
supportsDynamicModes: z.boolean(),
|
|
33
|
+
supportsMcpServers: z.boolean(),
|
|
34
|
+
supportsReasoningStream: z.boolean(),
|
|
35
|
+
supportsToolInvocations: z.boolean(),
|
|
36
|
+
});
|
|
37
|
+
const AgentUsageSchema = z.object({
|
|
38
|
+
inputTokens: z.number().optional(),
|
|
39
|
+
cachedInputTokens: z.number().optional(),
|
|
40
|
+
outputTokens: z.number().optional(),
|
|
41
|
+
totalCostUsd: z.number().optional(),
|
|
42
|
+
});
|
|
43
|
+
const McpStdioServerConfigSchema = z.object({
|
|
44
|
+
type: z.literal('stdio'),
|
|
45
|
+
command: z.string(),
|
|
46
|
+
args: z.array(z.string()).optional(),
|
|
47
|
+
env: z.record(z.string()).optional(),
|
|
48
|
+
});
|
|
49
|
+
const McpHttpServerConfigSchema = z.object({
|
|
50
|
+
type: z.literal('http'),
|
|
51
|
+
url: z.string(),
|
|
52
|
+
headers: z.record(z.string()).optional(),
|
|
53
|
+
});
|
|
54
|
+
const McpSseServerConfigSchema = z.object({
|
|
55
|
+
type: z.literal('sse'),
|
|
56
|
+
url: z.string(),
|
|
57
|
+
headers: z.record(z.string()).optional(),
|
|
58
|
+
});
|
|
59
|
+
const McpServerConfigSchema = z.discriminatedUnion('type', [
|
|
60
|
+
McpStdioServerConfigSchema,
|
|
61
|
+
McpHttpServerConfigSchema,
|
|
62
|
+
McpSseServerConfigSchema,
|
|
63
|
+
]);
|
|
64
|
+
const AgentSessionConfigSchema = z.object({
|
|
65
|
+
provider: AgentProviderSchema,
|
|
66
|
+
cwd: z.string(),
|
|
67
|
+
modeId: z.string().optional(),
|
|
68
|
+
model: z.string().optional(),
|
|
69
|
+
thinkingOptionId: z.string().optional(),
|
|
70
|
+
title: z.string().trim().min(1).max(MAX_EXPLICIT_AGENT_TITLE_CHARS).optional().nullable(),
|
|
71
|
+
approvalPolicy: z.string().optional(),
|
|
72
|
+
sandboxMode: z.string().optional(),
|
|
73
|
+
networkAccess: z.boolean().optional(),
|
|
74
|
+
webSearch: z.boolean().optional(),
|
|
75
|
+
extra: z
|
|
76
|
+
.object({
|
|
77
|
+
codex: z.record(z.unknown()).optional(),
|
|
78
|
+
claude: z.record(z.unknown()).optional(),
|
|
79
|
+
})
|
|
80
|
+
.partial()
|
|
81
|
+
.optional(),
|
|
82
|
+
systemPrompt: z.string().optional(),
|
|
83
|
+
mcpServers: z.record(McpServerConfigSchema).optional(),
|
|
84
|
+
});
|
|
85
|
+
const AgentPermissionUpdateSchema = z.record(z.unknown());
|
|
86
|
+
export const AgentPermissionResponseSchema = z.union([
|
|
87
|
+
z.object({
|
|
88
|
+
behavior: z.literal('allow'),
|
|
89
|
+
updatedInput: z.record(z.unknown()).optional(),
|
|
90
|
+
updatedPermissions: z.array(AgentPermissionUpdateSchema).optional(),
|
|
91
|
+
}),
|
|
92
|
+
z.object({
|
|
93
|
+
behavior: z.literal('deny'),
|
|
94
|
+
message: z.string().optional(),
|
|
95
|
+
interrupt: z.boolean().optional(),
|
|
96
|
+
}),
|
|
97
|
+
]);
|
|
98
|
+
export const AgentPermissionRequestPayloadSchema = z.object({
|
|
99
|
+
id: z.string(),
|
|
100
|
+
provider: AgentProviderSchema,
|
|
101
|
+
name: z.string(),
|
|
102
|
+
kind: z.enum(['tool', 'plan', 'question', 'mode', 'other']),
|
|
103
|
+
title: z.string().optional(),
|
|
104
|
+
description: z.string().optional(),
|
|
105
|
+
input: z.record(z.unknown()).optional(),
|
|
106
|
+
suggestions: z.array(AgentPermissionUpdateSchema).optional(),
|
|
107
|
+
metadata: z.record(z.unknown()).optional(),
|
|
108
|
+
});
|
|
109
|
+
const UnknownValueSchema = z.union([
|
|
110
|
+
z.null(),
|
|
111
|
+
z.boolean(),
|
|
112
|
+
z.number(),
|
|
113
|
+
z.string(),
|
|
114
|
+
z.array(z.unknown()),
|
|
115
|
+
z.object({}).passthrough(),
|
|
116
|
+
]);
|
|
117
|
+
const NonNullUnknownSchema = z.union([
|
|
118
|
+
z.boolean(),
|
|
119
|
+
z.number(),
|
|
120
|
+
z.string(),
|
|
121
|
+
z.array(z.unknown()),
|
|
122
|
+
z.object({}).passthrough(),
|
|
123
|
+
]);
|
|
124
|
+
const ToolCallDetailPayloadSchema = z.discriminatedUnion('type', [
|
|
125
|
+
z.object({
|
|
126
|
+
type: z.literal('shell'),
|
|
127
|
+
command: z.string(),
|
|
128
|
+
cwd: z.string().optional(),
|
|
129
|
+
output: z.string().optional(),
|
|
130
|
+
exitCode: z.number().nullable().optional(),
|
|
131
|
+
}),
|
|
132
|
+
z.object({
|
|
133
|
+
type: z.literal('read'),
|
|
134
|
+
filePath: z.string(),
|
|
135
|
+
content: z.string().optional(),
|
|
136
|
+
offset: z.number().optional(),
|
|
137
|
+
limit: z.number().optional(),
|
|
138
|
+
}),
|
|
139
|
+
z.object({
|
|
140
|
+
type: z.literal('edit'),
|
|
141
|
+
filePath: z.string(),
|
|
142
|
+
oldString: z.string().optional(),
|
|
143
|
+
newString: z.string().optional(),
|
|
144
|
+
unifiedDiff: z.string().optional(),
|
|
145
|
+
}),
|
|
146
|
+
z.object({
|
|
147
|
+
type: z.literal('write'),
|
|
148
|
+
filePath: z.string(),
|
|
149
|
+
content: z.string().optional(),
|
|
150
|
+
}),
|
|
151
|
+
z.object({
|
|
152
|
+
type: z.literal('search'),
|
|
153
|
+
query: z.string(),
|
|
154
|
+
}),
|
|
155
|
+
z.object({
|
|
156
|
+
type: z.literal('worktree_setup'),
|
|
157
|
+
worktreePath: z.string(),
|
|
158
|
+
branchName: z.string(),
|
|
159
|
+
log: z.string(),
|
|
160
|
+
commands: z.array(z.object({
|
|
161
|
+
index: z.number().int().positive(),
|
|
162
|
+
command: z.string(),
|
|
163
|
+
cwd: z.string(),
|
|
164
|
+
status: z.enum(['running', 'completed', 'failed']),
|
|
165
|
+
exitCode: z.number().nullable(),
|
|
166
|
+
durationMs: z.number().nonnegative().optional(),
|
|
167
|
+
})),
|
|
168
|
+
truncated: z.boolean().optional(),
|
|
169
|
+
}),
|
|
170
|
+
z.object({
|
|
171
|
+
type: z.literal('sub_agent'),
|
|
172
|
+
subAgentType: z.string().optional(),
|
|
173
|
+
description: z.string().optional(),
|
|
174
|
+
log: z.string(),
|
|
175
|
+
actions: z.array(z.object({
|
|
176
|
+
index: z.number().int().positive(),
|
|
177
|
+
toolName: z.string(),
|
|
178
|
+
summary: z.string().optional(),
|
|
179
|
+
})),
|
|
180
|
+
}),
|
|
181
|
+
z.object({
|
|
182
|
+
type: z.literal('plain_text'),
|
|
183
|
+
label: z.string().optional(),
|
|
184
|
+
text: z.string().optional(),
|
|
185
|
+
icon: z.enum(TOOL_CALL_ICON_NAMES).optional(),
|
|
186
|
+
}),
|
|
187
|
+
z.object({
|
|
188
|
+
type: z.literal('unknown'),
|
|
189
|
+
input: UnknownValueSchema,
|
|
190
|
+
output: UnknownValueSchema,
|
|
191
|
+
}),
|
|
192
|
+
]);
|
|
193
|
+
const ToolCallBasePayloadSchema = z
|
|
194
|
+
.object({
|
|
195
|
+
type: z.literal('tool_call'),
|
|
196
|
+
callId: z.string(),
|
|
197
|
+
name: z.string(),
|
|
198
|
+
detail: ToolCallDetailPayloadSchema,
|
|
199
|
+
metadata: z.record(z.unknown()).optional(),
|
|
200
|
+
})
|
|
201
|
+
.strict();
|
|
202
|
+
const ToolCallRunningPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
203
|
+
status: z.literal('running'),
|
|
204
|
+
error: z.null(),
|
|
205
|
+
});
|
|
206
|
+
const ToolCallCompletedPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
207
|
+
status: z.literal('completed'),
|
|
208
|
+
error: z.null(),
|
|
209
|
+
});
|
|
210
|
+
const ToolCallFailedPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
211
|
+
status: z.literal('failed'),
|
|
212
|
+
error: NonNullUnknownSchema,
|
|
213
|
+
});
|
|
214
|
+
const ToolCallCanceledPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
215
|
+
status: z.literal('canceled'),
|
|
216
|
+
error: z.null(),
|
|
217
|
+
});
|
|
218
|
+
const ToolCallTimelineItemPayloadSchema = z.union([
|
|
219
|
+
ToolCallRunningPayloadSchema,
|
|
220
|
+
ToolCallCompletedPayloadSchema,
|
|
221
|
+
ToolCallFailedPayloadSchema,
|
|
222
|
+
ToolCallCanceledPayloadSchema,
|
|
223
|
+
]);
|
|
224
|
+
export const AgentTimelineItemPayloadSchema = z.union([
|
|
225
|
+
z.object({
|
|
226
|
+
type: z.literal('user_message'),
|
|
227
|
+
text: z.string(),
|
|
228
|
+
messageId: z.string().optional(),
|
|
229
|
+
}),
|
|
230
|
+
z.object({
|
|
231
|
+
type: z.literal('assistant_message'),
|
|
232
|
+
text: z.string(),
|
|
233
|
+
}),
|
|
234
|
+
z.object({
|
|
235
|
+
type: z.literal('reasoning'),
|
|
236
|
+
text: z.string(),
|
|
237
|
+
}),
|
|
238
|
+
ToolCallTimelineItemPayloadSchema,
|
|
239
|
+
z.object({
|
|
240
|
+
type: z.literal('todo'),
|
|
241
|
+
items: z.array(z.object({
|
|
242
|
+
text: z.string(),
|
|
243
|
+
completed: z.boolean(),
|
|
244
|
+
})),
|
|
245
|
+
}),
|
|
246
|
+
z.object({
|
|
247
|
+
type: z.literal('error'),
|
|
248
|
+
message: z.string(),
|
|
249
|
+
}),
|
|
250
|
+
z.object({
|
|
251
|
+
type: z.literal('compaction'),
|
|
252
|
+
status: z.enum(['loading', 'completed']),
|
|
253
|
+
trigger: z.enum(['auto', 'manual']).optional(),
|
|
254
|
+
preTokens: z.number().optional(),
|
|
255
|
+
}),
|
|
256
|
+
]);
|
|
257
|
+
export const AgentStreamEventPayloadSchema = z.discriminatedUnion('type', [
|
|
258
|
+
z.object({
|
|
259
|
+
type: z.literal('thread_started'),
|
|
260
|
+
sessionId: z.string(),
|
|
261
|
+
provider: AgentProviderSchema,
|
|
262
|
+
}),
|
|
263
|
+
z.object({
|
|
264
|
+
type: z.literal('turn_started'),
|
|
265
|
+
provider: AgentProviderSchema,
|
|
266
|
+
}),
|
|
267
|
+
z.object({
|
|
268
|
+
type: z.literal('turn_completed'),
|
|
269
|
+
provider: AgentProviderSchema,
|
|
270
|
+
usage: AgentUsageSchema.optional(),
|
|
271
|
+
}),
|
|
272
|
+
z.object({
|
|
273
|
+
type: z.literal('turn_failed'),
|
|
274
|
+
provider: AgentProviderSchema,
|
|
275
|
+
error: z.string(),
|
|
276
|
+
code: z.string().optional(),
|
|
277
|
+
diagnostic: z.string().optional(),
|
|
278
|
+
}),
|
|
279
|
+
z.object({
|
|
280
|
+
type: z.literal('turn_canceled'),
|
|
281
|
+
provider: AgentProviderSchema,
|
|
282
|
+
reason: z.string(),
|
|
283
|
+
}),
|
|
284
|
+
z.object({
|
|
285
|
+
type: z.literal('timeline'),
|
|
286
|
+
provider: AgentProviderSchema,
|
|
287
|
+
item: AgentTimelineItemPayloadSchema,
|
|
288
|
+
}),
|
|
289
|
+
z.object({
|
|
290
|
+
type: z.literal('permission_requested'),
|
|
291
|
+
provider: AgentProviderSchema,
|
|
292
|
+
request: AgentPermissionRequestPayloadSchema,
|
|
293
|
+
}),
|
|
294
|
+
z.object({
|
|
295
|
+
type: z.literal('permission_resolved'),
|
|
296
|
+
provider: AgentProviderSchema,
|
|
297
|
+
requestId: z.string(),
|
|
298
|
+
resolution: AgentPermissionResponseSchema,
|
|
299
|
+
}),
|
|
300
|
+
z.object({
|
|
301
|
+
type: z.literal('attention_required'),
|
|
302
|
+
provider: AgentProviderSchema,
|
|
303
|
+
reason: z.enum(['finished', 'error', 'permission']),
|
|
304
|
+
timestamp: z.string(),
|
|
305
|
+
shouldNotify: z.boolean(),
|
|
306
|
+
notification: z
|
|
307
|
+
.object({
|
|
308
|
+
title: z.string(),
|
|
309
|
+
body: z.string(),
|
|
310
|
+
data: z.object({
|
|
311
|
+
serverId: z.string(),
|
|
312
|
+
agentId: z.string(),
|
|
313
|
+
reason: z.enum(['finished', 'error', 'permission']),
|
|
314
|
+
}),
|
|
315
|
+
})
|
|
316
|
+
.optional(),
|
|
317
|
+
}),
|
|
318
|
+
]);
|
|
319
|
+
const AgentPersistenceHandleSchema = z
|
|
320
|
+
.object({
|
|
321
|
+
provider: AgentProviderSchema,
|
|
322
|
+
sessionId: z.string(),
|
|
323
|
+
nativeHandle: z.string().optional(),
|
|
324
|
+
metadata: z.record(z.unknown()).optional(),
|
|
325
|
+
})
|
|
326
|
+
.nullable();
|
|
327
|
+
const AgentRuntimeInfoSchema = z.object({
|
|
328
|
+
provider: AgentProviderSchema,
|
|
329
|
+
sessionId: z.string().nullable(),
|
|
330
|
+
model: z.string().nullable().optional(),
|
|
331
|
+
thinkingOptionId: z.string().nullable().optional(),
|
|
332
|
+
modeId: z.string().nullable().optional(),
|
|
333
|
+
extra: z.record(z.unknown()).optional(),
|
|
334
|
+
});
|
|
335
|
+
export const AgentSnapshotPayloadSchema = z.object({
|
|
336
|
+
id: z.string(),
|
|
337
|
+
provider: AgentProviderSchema,
|
|
338
|
+
cwd: z.string(),
|
|
339
|
+
model: z.string().nullable(),
|
|
340
|
+
thinkingOptionId: z.string().nullable().optional(),
|
|
341
|
+
effectiveThinkingOptionId: z.string().nullable().optional(),
|
|
342
|
+
createdAt: z.string(),
|
|
343
|
+
updatedAt: z.string(),
|
|
344
|
+
lastUserMessageAt: z.string().nullable(),
|
|
345
|
+
status: AgentStatusSchema,
|
|
346
|
+
capabilities: AgentCapabilityFlagsSchema,
|
|
347
|
+
currentModeId: z.string().nullable(),
|
|
348
|
+
availableModes: z.array(AgentModeSchema),
|
|
349
|
+
pendingPermissions: z.array(AgentPermissionRequestPayloadSchema),
|
|
350
|
+
persistence: AgentPersistenceHandleSchema.nullable(),
|
|
351
|
+
runtimeInfo: AgentRuntimeInfoSchema.optional(),
|
|
352
|
+
lastUsage: AgentUsageSchema.optional(),
|
|
353
|
+
lastError: z.string().optional(),
|
|
354
|
+
title: z.string().nullable(),
|
|
355
|
+
labels: z.record(z.string()).default({}),
|
|
356
|
+
requiresAttention: z.boolean().optional(),
|
|
357
|
+
attentionReason: z.enum(['finished', 'error', 'permission']).nullable().optional(),
|
|
358
|
+
attentionTimestamp: z.string().nullable().optional(),
|
|
359
|
+
archivedAt: z.string().nullable().optional(),
|
|
360
|
+
});
|
|
361
|
+
// ============================================================================
|
|
362
|
+
// Session Inbound Messages (Session receives these)
|
|
363
|
+
// ============================================================================
|
|
364
|
+
export const VoiceAudioChunkMessageSchema = z.object({
|
|
365
|
+
type: z.literal('voice_audio_chunk'),
|
|
366
|
+
audio: z.string(), // base64 encoded
|
|
367
|
+
format: z.string(),
|
|
368
|
+
isLast: z.boolean(),
|
|
369
|
+
});
|
|
370
|
+
export const AbortRequestMessageSchema = z.object({
|
|
371
|
+
type: z.literal('abort_request'),
|
|
372
|
+
});
|
|
373
|
+
export const AudioPlayedMessageSchema = z.object({
|
|
374
|
+
type: z.literal('audio_played'),
|
|
375
|
+
id: z.string(),
|
|
376
|
+
});
|
|
377
|
+
const AgentDirectoryFilterSchema = z.object({
|
|
378
|
+
labels: z.record(z.string()).optional(),
|
|
379
|
+
projectKeys: z.array(z.string()).optional(),
|
|
380
|
+
statuses: z.array(AgentStatusSchema).optional(),
|
|
381
|
+
includeArchived: z.boolean().optional(),
|
|
382
|
+
requiresAttention: z.boolean().optional(),
|
|
383
|
+
thinkingOptionId: z.string().nullable().optional(),
|
|
384
|
+
});
|
|
385
|
+
export const DeleteAgentRequestMessageSchema = z.object({
|
|
386
|
+
type: z.literal('delete_agent_request'),
|
|
387
|
+
agentId: z.string(),
|
|
388
|
+
requestId: z.string(),
|
|
389
|
+
});
|
|
390
|
+
export const ArchiveAgentRequestMessageSchema = z.object({
|
|
391
|
+
type: z.literal('archive_agent_request'),
|
|
392
|
+
agentId: z.string(),
|
|
393
|
+
requestId: z.string(),
|
|
394
|
+
});
|
|
395
|
+
export const UpdateAgentRequestMessageSchema = z.object({
|
|
396
|
+
type: z.literal('update_agent_request'),
|
|
397
|
+
agentId: z.string(),
|
|
398
|
+
name: z.string().optional(),
|
|
399
|
+
labels: z.record(z.string()).optional(),
|
|
400
|
+
requestId: z.string(),
|
|
401
|
+
});
|
|
402
|
+
export const SetVoiceModeMessageSchema = z.object({
|
|
403
|
+
type: z.literal('set_voice_mode'),
|
|
404
|
+
enabled: z.boolean(),
|
|
405
|
+
agentId: z.string().optional(),
|
|
406
|
+
requestId: z.string().optional(),
|
|
407
|
+
});
|
|
408
|
+
export const SendAgentMessageSchema = z.object({
|
|
409
|
+
type: z.literal('send_agent_message'),
|
|
410
|
+
agentId: z.string(),
|
|
411
|
+
text: z.string(),
|
|
412
|
+
messageId: z.string().optional(), // Client-provided ID for deduplication
|
|
413
|
+
images: z
|
|
414
|
+
.array(z.object({
|
|
415
|
+
data: z.string(), // base64 encoded image
|
|
416
|
+
mimeType: z.string(), // e.g., "image/jpeg", "image/png"
|
|
417
|
+
}))
|
|
418
|
+
.optional(),
|
|
419
|
+
});
|
|
420
|
+
// ============================================================================
|
|
421
|
+
// Agent RPCs (requestId-correlated)
|
|
422
|
+
// ============================================================================
|
|
423
|
+
export const FetchAgentsRequestMessageSchema = z.object({
|
|
424
|
+
type: z.literal('fetch_agents_request'),
|
|
425
|
+
requestId: z.string(),
|
|
426
|
+
filter: AgentDirectoryFilterSchema.optional(),
|
|
427
|
+
sort: z
|
|
428
|
+
.array(z.object({
|
|
429
|
+
key: z.enum(['status_priority', 'created_at', 'updated_at', 'title']),
|
|
430
|
+
direction: z.enum(['asc', 'desc']),
|
|
431
|
+
}))
|
|
432
|
+
.optional(),
|
|
433
|
+
page: z
|
|
434
|
+
.object({
|
|
435
|
+
limit: z.number().int().positive().max(200),
|
|
436
|
+
cursor: z.string().min(1).optional(),
|
|
437
|
+
})
|
|
438
|
+
.optional(),
|
|
439
|
+
subscribe: z
|
|
440
|
+
.object({
|
|
441
|
+
subscriptionId: z.string().optional(),
|
|
442
|
+
})
|
|
443
|
+
.optional(),
|
|
444
|
+
});
|
|
445
|
+
const WorkspaceStateBucketSchema = z.enum([
|
|
446
|
+
'needs_input',
|
|
447
|
+
'failed',
|
|
448
|
+
'running',
|
|
449
|
+
'attention',
|
|
450
|
+
'done',
|
|
451
|
+
]);
|
|
452
|
+
export const FetchWorkspacesRequestMessageSchema = z.object({
|
|
453
|
+
type: z.literal('fetch_workspaces_request'),
|
|
454
|
+
requestId: z.string(),
|
|
455
|
+
filter: z
|
|
456
|
+
.object({
|
|
457
|
+
query: z.string().optional(),
|
|
458
|
+
projectId: z.string().optional(),
|
|
459
|
+
idPrefix: z.string().optional(),
|
|
460
|
+
})
|
|
461
|
+
.optional(),
|
|
462
|
+
sort: z
|
|
463
|
+
.array(z.object({
|
|
464
|
+
key: z.enum(['status_priority', 'activity_at', 'name', 'project_id']),
|
|
465
|
+
direction: z.enum(['asc', 'desc']),
|
|
466
|
+
}))
|
|
467
|
+
.optional(),
|
|
468
|
+
page: z
|
|
469
|
+
.object({
|
|
470
|
+
limit: z.number().int().positive().max(200),
|
|
471
|
+
cursor: z.string().min(1).optional(),
|
|
472
|
+
})
|
|
473
|
+
.optional(),
|
|
474
|
+
subscribe: z
|
|
475
|
+
.object({
|
|
476
|
+
subscriptionId: z.string().optional(),
|
|
477
|
+
})
|
|
478
|
+
.optional(),
|
|
479
|
+
});
|
|
480
|
+
export const FetchAgentRequestMessageSchema = z.object({
|
|
481
|
+
type: z.literal('fetch_agent_request'),
|
|
482
|
+
requestId: z.string(),
|
|
483
|
+
/** Accepts full ID, unique prefix, or exact full title (server resolves). */
|
|
484
|
+
agentId: z.string(),
|
|
485
|
+
});
|
|
486
|
+
export const SendAgentMessageRequestSchema = z.object({
|
|
487
|
+
type: z.literal('send_agent_message_request'),
|
|
488
|
+
requestId: z.string(),
|
|
489
|
+
/** Accepts full ID, unique prefix, or exact full title (server resolves). */
|
|
490
|
+
agentId: z.string(),
|
|
491
|
+
text: z.string(),
|
|
492
|
+
messageId: z.string().optional(), // Client-provided ID for deduplication
|
|
493
|
+
images: z
|
|
494
|
+
.array(z.object({
|
|
495
|
+
data: z.string(), // base64 encoded image
|
|
496
|
+
mimeType: z.string(), // e.g., "image/jpeg", "image/png"
|
|
497
|
+
}))
|
|
498
|
+
.optional(),
|
|
499
|
+
});
|
|
500
|
+
export const WaitForFinishRequestSchema = z.object({
|
|
501
|
+
type: z.literal('wait_for_finish_request'),
|
|
502
|
+
requestId: z.string(),
|
|
503
|
+
/** Accepts full ID, unique prefix, or exact full title (server resolves). */
|
|
504
|
+
agentId: z.string(),
|
|
505
|
+
timeoutMs: z.number().int().positive().optional(),
|
|
506
|
+
});
|
|
507
|
+
// ============================================================================
|
|
508
|
+
// Dictation Streaming (lossless, resumable)
|
|
509
|
+
// ============================================================================
|
|
510
|
+
export const DictationStreamStartMessageSchema = z.object({
|
|
511
|
+
type: z.literal('dictation_stream_start'),
|
|
512
|
+
dictationId: z.string(),
|
|
513
|
+
format: z.string(), // e.g. "audio/pcm;rate=16000;bits=16"
|
|
514
|
+
});
|
|
515
|
+
export const DictationStreamChunkMessageSchema = z.object({
|
|
516
|
+
type: z.literal('dictation_stream_chunk'),
|
|
517
|
+
dictationId: z.string(),
|
|
518
|
+
seq: z.number().int().nonnegative(),
|
|
519
|
+
audio: z.string(), // base64 encoded chunk
|
|
520
|
+
format: z.string(), // e.g. "audio/pcm;rate=16000;bits=16"
|
|
521
|
+
});
|
|
522
|
+
export const DictationStreamFinishMessageSchema = z.object({
|
|
523
|
+
type: z.literal('dictation_stream_finish'),
|
|
524
|
+
dictationId: z.string(),
|
|
525
|
+
finalSeq: z.number().int().nonnegative(),
|
|
526
|
+
});
|
|
527
|
+
export const DictationStreamCancelMessageSchema = z.object({
|
|
528
|
+
type: z.literal('dictation_stream_cancel'),
|
|
529
|
+
dictationId: z.string(),
|
|
530
|
+
});
|
|
531
|
+
const GitSetupOptionsSchema = z.object({
|
|
532
|
+
baseBranch: z.string().optional(),
|
|
533
|
+
createNewBranch: z.boolean().optional(),
|
|
534
|
+
newBranchName: z.string().optional(),
|
|
535
|
+
createWorktree: z.boolean().optional(),
|
|
536
|
+
worktreeSlug: z.string().optional(),
|
|
537
|
+
});
|
|
538
|
+
export const CreateAgentRequestMessageSchema = z.object({
|
|
539
|
+
type: z.literal('create_agent_request'),
|
|
540
|
+
config: AgentSessionConfigSchema,
|
|
541
|
+
worktreeName: z.string().optional(),
|
|
542
|
+
initialPrompt: z.string().optional(),
|
|
543
|
+
clientMessageId: z.string().optional(),
|
|
544
|
+
outputSchema: z.record(z.unknown()).optional(),
|
|
545
|
+
images: z
|
|
546
|
+
.array(z.object({
|
|
547
|
+
data: z.string(), // base64 encoded image
|
|
548
|
+
mimeType: z.string(), // e.g., "image/jpeg", "image/png"
|
|
549
|
+
}))
|
|
550
|
+
.optional(),
|
|
551
|
+
git: GitSetupOptionsSchema.optional(),
|
|
552
|
+
labels: z.record(z.string()).default({}),
|
|
553
|
+
requestId: z.string(),
|
|
554
|
+
});
|
|
555
|
+
export const ListProviderModelsRequestMessageSchema = z.object({
|
|
556
|
+
type: z.literal('list_provider_models_request'),
|
|
557
|
+
provider: AgentProviderSchema,
|
|
558
|
+
cwd: z.string().optional(),
|
|
559
|
+
requestId: z.string(),
|
|
560
|
+
});
|
|
561
|
+
export const ListAvailableProvidersRequestMessageSchema = z.object({
|
|
562
|
+
type: z.literal('list_available_providers_request'),
|
|
563
|
+
requestId: z.string(),
|
|
564
|
+
});
|
|
565
|
+
export const SpeechModelsListRequestSchema = z.object({
|
|
566
|
+
type: z.literal('speech_models_list_request'),
|
|
567
|
+
requestId: z.string(),
|
|
568
|
+
});
|
|
569
|
+
export const SpeechModelsDownloadRequestSchema = z.object({
|
|
570
|
+
type: z.literal('speech_models_download_request'),
|
|
571
|
+
modelIds: z.array(z.string()).optional(),
|
|
572
|
+
requestId: z.string(),
|
|
573
|
+
});
|
|
574
|
+
export const ResumeAgentRequestMessageSchema = z.object({
|
|
575
|
+
type: z.literal('resume_agent_request'),
|
|
576
|
+
handle: AgentPersistenceHandleSchema,
|
|
577
|
+
overrides: AgentSessionConfigSchema.partial().optional(),
|
|
578
|
+
requestId: z.string(),
|
|
579
|
+
});
|
|
580
|
+
export const RefreshAgentRequestMessageSchema = z.object({
|
|
581
|
+
type: z.literal('refresh_agent_request'),
|
|
582
|
+
agentId: z.string(),
|
|
583
|
+
requestId: z.string(),
|
|
584
|
+
});
|
|
585
|
+
export const CancelAgentRequestMessageSchema = z.object({
|
|
586
|
+
type: z.literal('cancel_agent_request'),
|
|
587
|
+
agentId: z.string(),
|
|
588
|
+
});
|
|
589
|
+
export const RestartServerRequestMessageSchema = z.object({
|
|
590
|
+
type: z.literal('restart_server_request'),
|
|
591
|
+
reason: z.string().optional(),
|
|
592
|
+
requestId: z.string(),
|
|
593
|
+
});
|
|
594
|
+
export const ShutdownServerRequestMessageSchema = z.object({
|
|
595
|
+
type: z.literal('shutdown_server_request'),
|
|
596
|
+
requestId: z.string(),
|
|
597
|
+
});
|
|
598
|
+
export const AgentTimelineCursorSchema = z.object({
|
|
599
|
+
epoch: z.string(),
|
|
600
|
+
seq: z.number().int().nonnegative(),
|
|
601
|
+
});
|
|
602
|
+
export const FetchAgentTimelineRequestMessageSchema = z.object({
|
|
603
|
+
type: z.literal('fetch_agent_timeline_request'),
|
|
604
|
+
agentId: z.string(),
|
|
605
|
+
requestId: z.string(),
|
|
606
|
+
direction: z.enum(['tail', 'before', 'after']).optional(),
|
|
607
|
+
cursor: AgentTimelineCursorSchema.optional(),
|
|
608
|
+
// 0 means "all matching rows for this query window".
|
|
609
|
+
limit: z.number().int().nonnegative().optional(),
|
|
610
|
+
// Default should be projected for app timeline loading.
|
|
611
|
+
projection: z.enum(['projected', 'canonical']).optional(),
|
|
612
|
+
});
|
|
613
|
+
export const SetAgentModeRequestMessageSchema = z.object({
|
|
614
|
+
type: z.literal('set_agent_mode_request'),
|
|
615
|
+
agentId: z.string(),
|
|
616
|
+
modeId: z.string(),
|
|
617
|
+
requestId: z.string(),
|
|
618
|
+
});
|
|
619
|
+
export const SetAgentModeResponseMessageSchema = z.object({
|
|
620
|
+
type: z.literal('set_agent_mode_response'),
|
|
621
|
+
payload: z.object({
|
|
622
|
+
requestId: z.string(),
|
|
623
|
+
agentId: z.string(),
|
|
624
|
+
accepted: z.boolean(),
|
|
625
|
+
error: z.string().nullable(),
|
|
626
|
+
}),
|
|
627
|
+
});
|
|
628
|
+
export const SetAgentModelRequestMessageSchema = z.object({
|
|
629
|
+
type: z.literal('set_agent_model_request'),
|
|
630
|
+
agentId: z.string(),
|
|
631
|
+
modelId: z.string().nullable(),
|
|
632
|
+
requestId: z.string(),
|
|
633
|
+
});
|
|
634
|
+
export const SetAgentModelResponseMessageSchema = z.object({
|
|
635
|
+
type: z.literal('set_agent_model_response'),
|
|
636
|
+
payload: z.object({
|
|
637
|
+
requestId: z.string(),
|
|
638
|
+
agentId: z.string(),
|
|
639
|
+
accepted: z.boolean(),
|
|
640
|
+
error: z.string().nullable(),
|
|
641
|
+
}),
|
|
642
|
+
});
|
|
643
|
+
export const SetAgentThinkingRequestMessageSchema = z.object({
|
|
644
|
+
type: z.literal('set_agent_thinking_request'),
|
|
645
|
+
agentId: z.string(),
|
|
646
|
+
thinkingOptionId: z.string().nullable(),
|
|
647
|
+
requestId: z.string(),
|
|
648
|
+
});
|
|
649
|
+
export const SetAgentThinkingResponseMessageSchema = z.object({
|
|
650
|
+
type: z.literal('set_agent_thinking_response'),
|
|
651
|
+
payload: z.object({
|
|
652
|
+
requestId: z.string(),
|
|
653
|
+
agentId: z.string(),
|
|
654
|
+
accepted: z.boolean(),
|
|
655
|
+
error: z.string().nullable(),
|
|
656
|
+
}),
|
|
657
|
+
});
|
|
658
|
+
export const UpdateAgentResponseMessageSchema = z.object({
|
|
659
|
+
type: z.literal('update_agent_response'),
|
|
660
|
+
payload: z.object({
|
|
661
|
+
requestId: z.string(),
|
|
662
|
+
agentId: z.string(),
|
|
663
|
+
accepted: z.boolean(),
|
|
664
|
+
error: z.string().nullable(),
|
|
665
|
+
}),
|
|
666
|
+
});
|
|
667
|
+
export const SetVoiceModeResponseMessageSchema = z.object({
|
|
668
|
+
type: z.literal('set_voice_mode_response'),
|
|
669
|
+
payload: z.object({
|
|
670
|
+
requestId: z.string(),
|
|
671
|
+
enabled: z.boolean(),
|
|
672
|
+
agentId: z.string().nullable(),
|
|
673
|
+
accepted: z.boolean(),
|
|
674
|
+
error: z.string().nullable(),
|
|
675
|
+
reasonCode: z.string().optional(),
|
|
676
|
+
retryable: z.boolean().optional(),
|
|
677
|
+
missingModelIds: z.array(z.string()).optional(),
|
|
678
|
+
}),
|
|
679
|
+
});
|
|
680
|
+
export const AgentPermissionResponseMessageSchema = z.object({
|
|
681
|
+
type: z.literal('agent_permission_response'),
|
|
682
|
+
agentId: z.string(),
|
|
683
|
+
requestId: z.string(),
|
|
684
|
+
response: AgentPermissionResponseSchema,
|
|
685
|
+
});
|
|
686
|
+
const CheckoutErrorCodeSchema = z.enum(['NOT_GIT_REPO', 'NOT_ALLOWED', 'MERGE_CONFLICT', 'UNKNOWN']);
|
|
687
|
+
const CheckoutErrorSchema = z.object({
|
|
688
|
+
code: CheckoutErrorCodeSchema,
|
|
689
|
+
message: z.string(),
|
|
690
|
+
});
|
|
691
|
+
const CheckoutDiffCompareSchema = z.object({
|
|
692
|
+
mode: z.enum(['uncommitted', 'base']),
|
|
693
|
+
baseRef: z.string().optional(),
|
|
694
|
+
});
|
|
695
|
+
export const CheckoutStatusRequestSchema = z.object({
|
|
696
|
+
type: z.literal('checkout_status_request'),
|
|
697
|
+
cwd: z.string(),
|
|
698
|
+
requestId: z.string(),
|
|
699
|
+
});
|
|
700
|
+
export const SubscribeCheckoutDiffRequestSchema = z.object({
|
|
701
|
+
type: z.literal('subscribe_checkout_diff_request'),
|
|
702
|
+
subscriptionId: z.string(),
|
|
703
|
+
cwd: z.string(),
|
|
704
|
+
compare: CheckoutDiffCompareSchema,
|
|
705
|
+
requestId: z.string(),
|
|
706
|
+
});
|
|
707
|
+
export const UnsubscribeCheckoutDiffRequestSchema = z.object({
|
|
708
|
+
type: z.literal('unsubscribe_checkout_diff_request'),
|
|
709
|
+
subscriptionId: z.string(),
|
|
710
|
+
});
|
|
711
|
+
export const CheckoutCommitRequestSchema = z.object({
|
|
712
|
+
type: z.literal('checkout_commit_request'),
|
|
713
|
+
cwd: z.string(),
|
|
714
|
+
message: z.string().optional(),
|
|
715
|
+
addAll: z.boolean().optional(),
|
|
716
|
+
requestId: z.string(),
|
|
717
|
+
});
|
|
718
|
+
export const CheckoutMergeRequestSchema = z.object({
|
|
719
|
+
type: z.literal('checkout_merge_request'),
|
|
720
|
+
cwd: z.string(),
|
|
721
|
+
baseRef: z.string().optional(),
|
|
722
|
+
strategy: z.enum(['merge', 'squash']).optional(),
|
|
723
|
+
requireCleanTarget: z.boolean().optional(),
|
|
724
|
+
requestId: z.string(),
|
|
725
|
+
});
|
|
726
|
+
export const CheckoutMergeFromBaseRequestSchema = z.object({
|
|
727
|
+
type: z.literal('checkout_merge_from_base_request'),
|
|
728
|
+
cwd: z.string(),
|
|
729
|
+
baseRef: z.string().optional(),
|
|
730
|
+
requireCleanTarget: z.boolean().optional(),
|
|
731
|
+
requestId: z.string(),
|
|
732
|
+
});
|
|
733
|
+
export const CheckoutPushRequestSchema = z.object({
|
|
734
|
+
type: z.literal('checkout_push_request'),
|
|
735
|
+
cwd: z.string(),
|
|
736
|
+
requestId: z.string(),
|
|
737
|
+
});
|
|
738
|
+
export const CheckoutPrCreateRequestSchema = z.object({
|
|
739
|
+
type: z.literal('checkout_pr_create_request'),
|
|
740
|
+
cwd: z.string(),
|
|
741
|
+
title: z.string().optional(),
|
|
742
|
+
body: z.string().optional(),
|
|
743
|
+
baseRef: z.string().optional(),
|
|
744
|
+
requestId: z.string(),
|
|
745
|
+
});
|
|
746
|
+
export const CheckoutPrStatusRequestSchema = z.object({
|
|
747
|
+
type: z.literal('checkout_pr_status_request'),
|
|
748
|
+
cwd: z.string(),
|
|
749
|
+
requestId: z.string(),
|
|
750
|
+
});
|
|
751
|
+
export const ValidateBranchRequestSchema = z.object({
|
|
752
|
+
type: z.literal('validate_branch_request'),
|
|
753
|
+
cwd: z.string(),
|
|
754
|
+
branchName: z.string(),
|
|
755
|
+
requestId: z.string(),
|
|
756
|
+
});
|
|
757
|
+
export const BranchSuggestionsRequestSchema = z.object({
|
|
758
|
+
type: z.literal('branch_suggestions_request'),
|
|
759
|
+
cwd: z.string(),
|
|
760
|
+
query: z.string().optional(),
|
|
761
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
762
|
+
requestId: z.string(),
|
|
763
|
+
});
|
|
764
|
+
export const DirectorySuggestionsRequestSchema = z.object({
|
|
765
|
+
type: z.literal('directory_suggestions_request'),
|
|
766
|
+
query: z.string(),
|
|
767
|
+
cwd: z.string().optional(),
|
|
768
|
+
includeFiles: z.boolean().optional(),
|
|
769
|
+
includeDirectories: z.boolean().optional(),
|
|
770
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
771
|
+
requestId: z.string(),
|
|
772
|
+
});
|
|
773
|
+
export const PaseoWorktreeListRequestSchema = z.object({
|
|
774
|
+
type: z.literal('paseo_worktree_list_request'),
|
|
775
|
+
cwd: z.string().optional(),
|
|
776
|
+
repoRoot: z.string().optional(),
|
|
777
|
+
requestId: z.string(),
|
|
778
|
+
});
|
|
779
|
+
export const PaseoWorktreeArchiveRequestSchema = z.object({
|
|
780
|
+
type: z.literal('paseo_worktree_archive_request'),
|
|
781
|
+
worktreePath: z.string().optional(),
|
|
782
|
+
repoRoot: z.string().optional(),
|
|
783
|
+
branchName: z.string().optional(),
|
|
784
|
+
requestId: z.string(),
|
|
785
|
+
});
|
|
786
|
+
// Highlighted diff token schema
|
|
787
|
+
// Note: style can be a compound class name (e.g., "heading meta") from the syntax highlighter
|
|
788
|
+
const HighlightTokenSchema = z.object({
|
|
789
|
+
text: z.string(),
|
|
790
|
+
style: z.string().nullable(),
|
|
791
|
+
});
|
|
792
|
+
const DiffLineSchema = z.object({
|
|
793
|
+
type: z.enum(['add', 'remove', 'context', 'header']),
|
|
794
|
+
content: z.string(),
|
|
795
|
+
tokens: z.array(HighlightTokenSchema).optional(),
|
|
796
|
+
});
|
|
797
|
+
const DiffHunkSchema = z.object({
|
|
798
|
+
oldStart: z.number(),
|
|
799
|
+
oldCount: z.number(),
|
|
800
|
+
newStart: z.number(),
|
|
801
|
+
newCount: z.number(),
|
|
802
|
+
lines: z.array(DiffLineSchema),
|
|
803
|
+
});
|
|
804
|
+
const ParsedDiffFileSchema = z.object({
|
|
805
|
+
path: z.string(),
|
|
806
|
+
isNew: z.boolean(),
|
|
807
|
+
isDeleted: z.boolean(),
|
|
808
|
+
additions: z.number(),
|
|
809
|
+
deletions: z.number(),
|
|
810
|
+
hunks: z.array(DiffHunkSchema),
|
|
811
|
+
status: z.enum(['ok', 'too_large', 'binary']).optional(),
|
|
812
|
+
});
|
|
813
|
+
const FileExplorerEntrySchema = z.object({
|
|
814
|
+
name: z.string(),
|
|
815
|
+
path: z.string(),
|
|
816
|
+
kind: z.enum(['file', 'directory']),
|
|
817
|
+
size: z.number(),
|
|
818
|
+
modifiedAt: z.string(),
|
|
819
|
+
});
|
|
820
|
+
const FileExplorerFileSchema = z.object({
|
|
821
|
+
path: z.string(),
|
|
822
|
+
kind: z.enum(['text', 'image', 'binary']),
|
|
823
|
+
encoding: z.enum(['utf-8', 'base64', 'none']),
|
|
824
|
+
content: z.string().optional(),
|
|
825
|
+
mimeType: z.string().optional(),
|
|
826
|
+
size: z.number(),
|
|
827
|
+
modifiedAt: z.string(),
|
|
828
|
+
});
|
|
829
|
+
const FileExplorerDirectorySchema = z.object({
|
|
830
|
+
path: z.string(),
|
|
831
|
+
entries: z.array(FileExplorerEntrySchema),
|
|
832
|
+
});
|
|
833
|
+
export const FileExplorerRequestSchema = z.object({
|
|
834
|
+
type: z.literal('file_explorer_request'),
|
|
835
|
+
cwd: z.string(),
|
|
836
|
+
path: z.string().optional(),
|
|
837
|
+
mode: z.enum(['list', 'file']),
|
|
838
|
+
requestId: z.string(),
|
|
839
|
+
});
|
|
840
|
+
export const ProjectIconRequestSchema = z.object({
|
|
841
|
+
type: z.literal('project_icon_request'),
|
|
842
|
+
cwd: z.string(),
|
|
843
|
+
requestId: z.string(),
|
|
844
|
+
});
|
|
845
|
+
export const FileDownloadTokenRequestSchema = z.object({
|
|
846
|
+
type: z.literal('file_download_token_request'),
|
|
847
|
+
cwd: z.string(),
|
|
848
|
+
path: z.string(),
|
|
849
|
+
requestId: z.string(),
|
|
850
|
+
});
|
|
851
|
+
export const ClearAgentAttentionMessageSchema = z.object({
|
|
852
|
+
type: z.literal('clear_agent_attention'),
|
|
853
|
+
agentId: z.union([z.string(), z.array(z.string())]),
|
|
854
|
+
});
|
|
855
|
+
export const ClientHeartbeatMessageSchema = z.object({
|
|
856
|
+
type: z.literal('client_heartbeat'),
|
|
857
|
+
deviceType: z.enum(['web', 'mobile']),
|
|
858
|
+
focusedAgentId: z.string().nullable(),
|
|
859
|
+
lastActivityAt: z.string(),
|
|
860
|
+
appVisible: z.boolean(),
|
|
861
|
+
appVisibilityChangedAt: z.string().optional(),
|
|
862
|
+
});
|
|
863
|
+
export const PingMessageSchema = z.object({
|
|
864
|
+
type: z.literal('ping'),
|
|
865
|
+
requestId: z.string(),
|
|
866
|
+
clientSentAt: z.number().int().optional(),
|
|
867
|
+
});
|
|
868
|
+
const ListCommandsDraftConfigSchema = z.object({
|
|
869
|
+
provider: AgentProviderSchema,
|
|
870
|
+
cwd: z.string(),
|
|
871
|
+
modeId: z.string().optional(),
|
|
872
|
+
model: z.string().optional(),
|
|
873
|
+
thinkingOptionId: z.string().optional(),
|
|
874
|
+
});
|
|
875
|
+
export const ListCommandsRequestSchema = z.object({
|
|
876
|
+
type: z.literal('list_commands_request'),
|
|
877
|
+
agentId: z.string(),
|
|
878
|
+
draftConfig: ListCommandsDraftConfigSchema.optional(),
|
|
879
|
+
requestId: z.string(),
|
|
880
|
+
});
|
|
881
|
+
export const RegisterPushTokenMessageSchema = z.object({
|
|
882
|
+
type: z.literal('register_push_token'),
|
|
883
|
+
token: z.string(),
|
|
884
|
+
});
|
|
885
|
+
// ============================================================================
|
|
886
|
+
// Terminal Messages
|
|
887
|
+
// ============================================================================
|
|
888
|
+
export const ListTerminalsRequestSchema = z.object({
|
|
889
|
+
type: z.literal('list_terminals_request'),
|
|
890
|
+
cwd: z.string(),
|
|
891
|
+
requestId: z.string(),
|
|
892
|
+
});
|
|
893
|
+
export const SubscribeTerminalsRequestSchema = z.object({
|
|
894
|
+
type: z.literal('subscribe_terminals_request'),
|
|
895
|
+
cwd: z.string(),
|
|
896
|
+
});
|
|
897
|
+
export const UnsubscribeTerminalsRequestSchema = z.object({
|
|
898
|
+
type: z.literal('unsubscribe_terminals_request'),
|
|
899
|
+
cwd: z.string(),
|
|
900
|
+
});
|
|
901
|
+
export const CreateTerminalRequestSchema = z.object({
|
|
902
|
+
type: z.literal('create_terminal_request'),
|
|
903
|
+
cwd: z.string(),
|
|
904
|
+
name: z.string().optional(),
|
|
905
|
+
requestId: z.string(),
|
|
906
|
+
});
|
|
907
|
+
export const SubscribeTerminalRequestSchema = z.object({
|
|
908
|
+
type: z.literal('subscribe_terminal_request'),
|
|
909
|
+
terminalId: z.string(),
|
|
910
|
+
requestId: z.string(),
|
|
911
|
+
});
|
|
912
|
+
export const UnsubscribeTerminalRequestSchema = z.object({
|
|
913
|
+
type: z.literal('unsubscribe_terminal_request'),
|
|
914
|
+
terminalId: z.string(),
|
|
915
|
+
});
|
|
916
|
+
const TerminalClientMessageSchema = z.discriminatedUnion('type', [
|
|
917
|
+
z.object({ type: z.literal('input'), data: z.string() }),
|
|
918
|
+
z.object({ type: z.literal('resize'), rows: z.number(), cols: z.number() }),
|
|
919
|
+
z.object({
|
|
920
|
+
type: z.literal('mouse'),
|
|
921
|
+
row: z.number(),
|
|
922
|
+
col: z.number(),
|
|
923
|
+
button: z.number(),
|
|
924
|
+
action: z.enum(['down', 'up', 'move']),
|
|
925
|
+
}),
|
|
926
|
+
]);
|
|
927
|
+
export const TerminalInputSchema = z.object({
|
|
928
|
+
type: z.literal('terminal_input'),
|
|
929
|
+
terminalId: z.string(),
|
|
930
|
+
message: TerminalClientMessageSchema,
|
|
931
|
+
});
|
|
932
|
+
export const KillTerminalRequestSchema = z.object({
|
|
933
|
+
type: z.literal('kill_terminal_request'),
|
|
934
|
+
terminalId: z.string(),
|
|
935
|
+
requestId: z.string(),
|
|
936
|
+
});
|
|
937
|
+
export const AttachTerminalStreamRequestSchema = z.object({
|
|
938
|
+
type: z.literal('attach_terminal_stream_request'),
|
|
939
|
+
terminalId: z.string(),
|
|
940
|
+
resumeOffset: z.number().int().nonnegative().optional(),
|
|
941
|
+
rows: z.number().int().positive().optional(),
|
|
942
|
+
cols: z.number().int().positive().optional(),
|
|
943
|
+
requestId: z.string(),
|
|
944
|
+
});
|
|
945
|
+
export const DetachTerminalStreamRequestSchema = z.object({
|
|
946
|
+
type: z.literal('detach_terminal_stream_request'),
|
|
947
|
+
streamId: z.number().int().nonnegative(),
|
|
948
|
+
requestId: z.string(),
|
|
949
|
+
});
|
|
950
|
+
export const SessionInboundMessageSchema = z.discriminatedUnion('type', [
|
|
951
|
+
VoiceAudioChunkMessageSchema,
|
|
952
|
+
AbortRequestMessageSchema,
|
|
953
|
+
AudioPlayedMessageSchema,
|
|
954
|
+
FetchAgentsRequestMessageSchema,
|
|
955
|
+
FetchWorkspacesRequestMessageSchema,
|
|
956
|
+
FetchAgentRequestMessageSchema,
|
|
957
|
+
DeleteAgentRequestMessageSchema,
|
|
958
|
+
ArchiveAgentRequestMessageSchema,
|
|
959
|
+
UpdateAgentRequestMessageSchema,
|
|
960
|
+
SetVoiceModeMessageSchema,
|
|
961
|
+
SendAgentMessageRequestSchema,
|
|
962
|
+
WaitForFinishRequestSchema,
|
|
963
|
+
DictationStreamStartMessageSchema,
|
|
964
|
+
DictationStreamChunkMessageSchema,
|
|
965
|
+
DictationStreamFinishMessageSchema,
|
|
966
|
+
DictationStreamCancelMessageSchema,
|
|
967
|
+
CreateAgentRequestMessageSchema,
|
|
968
|
+
ListProviderModelsRequestMessageSchema,
|
|
969
|
+
ListAvailableProvidersRequestMessageSchema,
|
|
970
|
+
SpeechModelsListRequestSchema,
|
|
971
|
+
SpeechModelsDownloadRequestSchema,
|
|
972
|
+
ResumeAgentRequestMessageSchema,
|
|
973
|
+
RefreshAgentRequestMessageSchema,
|
|
974
|
+
CancelAgentRequestMessageSchema,
|
|
975
|
+
ShutdownServerRequestMessageSchema,
|
|
976
|
+
RestartServerRequestMessageSchema,
|
|
977
|
+
FetchAgentTimelineRequestMessageSchema,
|
|
978
|
+
SetAgentModeRequestMessageSchema,
|
|
979
|
+
SetAgentModelRequestMessageSchema,
|
|
980
|
+
SetAgentThinkingRequestMessageSchema,
|
|
981
|
+
AgentPermissionResponseMessageSchema,
|
|
982
|
+
CheckoutStatusRequestSchema,
|
|
983
|
+
SubscribeCheckoutDiffRequestSchema,
|
|
984
|
+
UnsubscribeCheckoutDiffRequestSchema,
|
|
985
|
+
CheckoutCommitRequestSchema,
|
|
986
|
+
CheckoutMergeRequestSchema,
|
|
987
|
+
CheckoutMergeFromBaseRequestSchema,
|
|
988
|
+
CheckoutPushRequestSchema,
|
|
989
|
+
CheckoutPrCreateRequestSchema,
|
|
990
|
+
CheckoutPrStatusRequestSchema,
|
|
991
|
+
ValidateBranchRequestSchema,
|
|
992
|
+
BranchSuggestionsRequestSchema,
|
|
993
|
+
DirectorySuggestionsRequestSchema,
|
|
994
|
+
PaseoWorktreeListRequestSchema,
|
|
995
|
+
PaseoWorktreeArchiveRequestSchema,
|
|
996
|
+
FileExplorerRequestSchema,
|
|
997
|
+
ProjectIconRequestSchema,
|
|
998
|
+
FileDownloadTokenRequestSchema,
|
|
999
|
+
ClearAgentAttentionMessageSchema,
|
|
1000
|
+
ClientHeartbeatMessageSchema,
|
|
1001
|
+
PingMessageSchema,
|
|
1002
|
+
ListCommandsRequestSchema,
|
|
1003
|
+
RegisterPushTokenMessageSchema,
|
|
1004
|
+
ListTerminalsRequestSchema,
|
|
1005
|
+
SubscribeTerminalsRequestSchema,
|
|
1006
|
+
UnsubscribeTerminalsRequestSchema,
|
|
1007
|
+
CreateTerminalRequestSchema,
|
|
1008
|
+
SubscribeTerminalRequestSchema,
|
|
1009
|
+
UnsubscribeTerminalRequestSchema,
|
|
1010
|
+
TerminalInputSchema,
|
|
1011
|
+
KillTerminalRequestSchema,
|
|
1012
|
+
AttachTerminalStreamRequestSchema,
|
|
1013
|
+
DetachTerminalStreamRequestSchema,
|
|
1014
|
+
]);
|
|
1015
|
+
// ============================================================================
|
|
1016
|
+
// Session Outbound Messages (Session emits these)
|
|
1017
|
+
// ============================================================================
|
|
1018
|
+
export const ActivityLogPayloadSchema = z.object({
|
|
1019
|
+
id: z.string(),
|
|
1020
|
+
timestamp: z.coerce.date(),
|
|
1021
|
+
type: z.enum(['transcript', 'assistant', 'tool_call', 'tool_result', 'error', 'system']),
|
|
1022
|
+
content: z.string(),
|
|
1023
|
+
metadata: z.record(z.unknown()).optional(),
|
|
1024
|
+
});
|
|
1025
|
+
export const ActivityLogMessageSchema = z.object({
|
|
1026
|
+
type: z.literal('activity_log'),
|
|
1027
|
+
payload: ActivityLogPayloadSchema,
|
|
1028
|
+
});
|
|
1029
|
+
export const AssistantChunkMessageSchema = z.object({
|
|
1030
|
+
type: z.literal('assistant_chunk'),
|
|
1031
|
+
payload: z.object({
|
|
1032
|
+
chunk: z.string(),
|
|
1033
|
+
}),
|
|
1034
|
+
});
|
|
1035
|
+
export const AudioOutputMessageSchema = z.object({
|
|
1036
|
+
type: z.literal('audio_output'),
|
|
1037
|
+
payload: z.object({
|
|
1038
|
+
audio: z.string(), // base64 encoded
|
|
1039
|
+
format: z.string(),
|
|
1040
|
+
id: z.string(),
|
|
1041
|
+
isVoiceMode: z.boolean(), // Mode when audio was generated (for drift protection)
|
|
1042
|
+
groupId: z.string().optional(), // Logical utterance id
|
|
1043
|
+
chunkIndex: z.number().int().nonnegative().optional(),
|
|
1044
|
+
isLastChunk: z.boolean().optional(),
|
|
1045
|
+
}),
|
|
1046
|
+
});
|
|
1047
|
+
export const TranscriptionResultMessageSchema = z.object({
|
|
1048
|
+
type: z.literal('transcription_result'),
|
|
1049
|
+
payload: z.object({
|
|
1050
|
+
text: z.string(),
|
|
1051
|
+
language: z.string().optional(),
|
|
1052
|
+
duration: z.number().optional(),
|
|
1053
|
+
requestId: z.string(), // Echoed back from request for tracking
|
|
1054
|
+
avgLogprob: z.number().optional(),
|
|
1055
|
+
isLowConfidence: z.boolean().optional(),
|
|
1056
|
+
byteLength: z.number().optional(),
|
|
1057
|
+
format: z.string().optional(),
|
|
1058
|
+
debugRecordingPath: z.string().optional(),
|
|
1059
|
+
}),
|
|
1060
|
+
});
|
|
1061
|
+
export const DictationStreamAckMessageSchema = z.object({
|
|
1062
|
+
type: z.literal('dictation_stream_ack'),
|
|
1063
|
+
payload: z.object({
|
|
1064
|
+
dictationId: z.string(),
|
|
1065
|
+
ackSeq: z.number().int(),
|
|
1066
|
+
}),
|
|
1067
|
+
});
|
|
1068
|
+
export const DictationStreamFinishAcceptedMessageSchema = z.object({
|
|
1069
|
+
type: z.literal('dictation_stream_finish_accepted'),
|
|
1070
|
+
payload: z.object({
|
|
1071
|
+
dictationId: z.string(),
|
|
1072
|
+
timeoutMs: z.number().int().positive(),
|
|
1073
|
+
}),
|
|
1074
|
+
});
|
|
1075
|
+
export const DictationStreamPartialMessageSchema = z.object({
|
|
1076
|
+
type: z.literal('dictation_stream_partial'),
|
|
1077
|
+
payload: z.object({
|
|
1078
|
+
dictationId: z.string(),
|
|
1079
|
+
text: z.string(),
|
|
1080
|
+
}),
|
|
1081
|
+
});
|
|
1082
|
+
export const DictationStreamFinalMessageSchema = z.object({
|
|
1083
|
+
type: z.literal('dictation_stream_final'),
|
|
1084
|
+
payload: z.object({
|
|
1085
|
+
dictationId: z.string(),
|
|
1086
|
+
text: z.string(),
|
|
1087
|
+
debugRecordingPath: z.string().optional(),
|
|
1088
|
+
}),
|
|
1089
|
+
});
|
|
1090
|
+
export const DictationStreamErrorMessageSchema = z.object({
|
|
1091
|
+
type: z.literal('dictation_stream_error'),
|
|
1092
|
+
payload: z.object({
|
|
1093
|
+
dictationId: z.string(),
|
|
1094
|
+
error: z.string(),
|
|
1095
|
+
retryable: z.boolean(),
|
|
1096
|
+
reasonCode: z.string().optional(),
|
|
1097
|
+
missingModelIds: z.array(z.string()).optional(),
|
|
1098
|
+
debugRecordingPath: z.string().optional(),
|
|
1099
|
+
}),
|
|
1100
|
+
});
|
|
1101
|
+
export const ServerCapabilityStateSchema = z.object({
|
|
1102
|
+
enabled: z.boolean(),
|
|
1103
|
+
reason: z.string(),
|
|
1104
|
+
});
|
|
1105
|
+
export const ServerVoiceCapabilitiesSchema = z.object({
|
|
1106
|
+
dictation: ServerCapabilityStateSchema,
|
|
1107
|
+
voice: ServerCapabilityStateSchema,
|
|
1108
|
+
});
|
|
1109
|
+
export const ServerCapabilitiesSchema = z
|
|
1110
|
+
.object({
|
|
1111
|
+
voice: ServerVoiceCapabilitiesSchema.optional(),
|
|
1112
|
+
})
|
|
1113
|
+
.passthrough();
|
|
1114
|
+
const ServerInfoHostnameSchema = z.unknown().transform((value) => {
|
|
1115
|
+
if (typeof value !== 'string') {
|
|
1116
|
+
return null;
|
|
1117
|
+
}
|
|
1118
|
+
const trimmed = value.trim();
|
|
1119
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1120
|
+
});
|
|
1121
|
+
const ServerInfoVersionSchema = z.unknown().transform((value) => {
|
|
1122
|
+
if (typeof value !== 'string') {
|
|
1123
|
+
return null;
|
|
1124
|
+
}
|
|
1125
|
+
const trimmed = value.trim();
|
|
1126
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1127
|
+
});
|
|
1128
|
+
const ServerCapabilitiesFromUnknownSchema = z
|
|
1129
|
+
.unknown()
|
|
1130
|
+
.optional()
|
|
1131
|
+
.transform((value) => {
|
|
1132
|
+
if (value === undefined) {
|
|
1133
|
+
return undefined;
|
|
1134
|
+
}
|
|
1135
|
+
const parsed = ServerCapabilitiesSchema.safeParse(value);
|
|
1136
|
+
if (!parsed.success) {
|
|
1137
|
+
return undefined;
|
|
1138
|
+
}
|
|
1139
|
+
return parsed.data;
|
|
1140
|
+
});
|
|
1141
|
+
export const ServerInfoStatusPayloadSchema = z
|
|
1142
|
+
.object({
|
|
1143
|
+
status: z.literal('server_info'),
|
|
1144
|
+
serverId: z.string().trim().min(1),
|
|
1145
|
+
hostname: ServerInfoHostnameSchema.optional(),
|
|
1146
|
+
version: ServerInfoVersionSchema.optional(),
|
|
1147
|
+
capabilities: ServerCapabilitiesFromUnknownSchema,
|
|
1148
|
+
})
|
|
1149
|
+
.passthrough()
|
|
1150
|
+
.transform((payload) => ({
|
|
1151
|
+
...payload,
|
|
1152
|
+
hostname: payload.hostname ?? null,
|
|
1153
|
+
version: payload.version ?? null,
|
|
1154
|
+
}));
|
|
1155
|
+
export const StatusMessageSchema = z.object({
|
|
1156
|
+
type: z.literal('status'),
|
|
1157
|
+
payload: z
|
|
1158
|
+
.object({
|
|
1159
|
+
status: z.string(),
|
|
1160
|
+
})
|
|
1161
|
+
.passthrough(), // Allow additional fields
|
|
1162
|
+
});
|
|
1163
|
+
export const PongMessageSchema = z.object({
|
|
1164
|
+
type: z.literal('pong'),
|
|
1165
|
+
payload: z.object({
|
|
1166
|
+
requestId: z.string(),
|
|
1167
|
+
clientSentAt: z.number().int().optional(),
|
|
1168
|
+
serverReceivedAt: z.number().int(),
|
|
1169
|
+
serverSentAt: z.number().int(),
|
|
1170
|
+
}),
|
|
1171
|
+
});
|
|
1172
|
+
export const RpcErrorMessageSchema = z.object({
|
|
1173
|
+
type: z.literal('rpc_error'),
|
|
1174
|
+
payload: z.object({
|
|
1175
|
+
requestId: z.string(),
|
|
1176
|
+
requestType: z.string().optional(),
|
|
1177
|
+
error: z.string(),
|
|
1178
|
+
code: z.string().optional(),
|
|
1179
|
+
}),
|
|
1180
|
+
});
|
|
1181
|
+
const AgentStatusWithRequestSchema = z.object({
|
|
1182
|
+
agentId: z.string(),
|
|
1183
|
+
requestId: z.string(),
|
|
1184
|
+
});
|
|
1185
|
+
const AgentStatusWithTimelineSchema = AgentStatusWithRequestSchema.extend({
|
|
1186
|
+
timelineSize: z.number().optional(),
|
|
1187
|
+
});
|
|
1188
|
+
export const AgentCreatedStatusPayloadSchema = z
|
|
1189
|
+
.object({
|
|
1190
|
+
status: z.literal('agent_created'),
|
|
1191
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1192
|
+
})
|
|
1193
|
+
.extend(AgentStatusWithRequestSchema.shape);
|
|
1194
|
+
export const AgentCreateFailedStatusPayloadSchema = z.object({
|
|
1195
|
+
status: z.literal('agent_create_failed'),
|
|
1196
|
+
requestId: z.string(),
|
|
1197
|
+
error: z.string(),
|
|
1198
|
+
});
|
|
1199
|
+
export const AgentResumedStatusPayloadSchema = z
|
|
1200
|
+
.object({
|
|
1201
|
+
status: z.literal('agent_resumed'),
|
|
1202
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1203
|
+
})
|
|
1204
|
+
.extend(AgentStatusWithTimelineSchema.shape);
|
|
1205
|
+
export const AgentRefreshedStatusPayloadSchema = z
|
|
1206
|
+
.object({
|
|
1207
|
+
status: z.literal('agent_refreshed'),
|
|
1208
|
+
})
|
|
1209
|
+
.extend(AgentStatusWithTimelineSchema.shape);
|
|
1210
|
+
export const RestartRequestedStatusPayloadSchema = z.object({
|
|
1211
|
+
status: z.literal('restart_requested'),
|
|
1212
|
+
clientId: z.string(),
|
|
1213
|
+
reason: z.string().optional(),
|
|
1214
|
+
requestId: z.string(),
|
|
1215
|
+
});
|
|
1216
|
+
export const ShutdownRequestedStatusPayloadSchema = z.object({
|
|
1217
|
+
status: z.literal('shutdown_requested'),
|
|
1218
|
+
clientId: z.string(),
|
|
1219
|
+
requestId: z.string(),
|
|
1220
|
+
});
|
|
1221
|
+
export const KnownStatusPayloadSchema = z.discriminatedUnion('status', [
|
|
1222
|
+
AgentCreatedStatusPayloadSchema,
|
|
1223
|
+
AgentCreateFailedStatusPayloadSchema,
|
|
1224
|
+
AgentResumedStatusPayloadSchema,
|
|
1225
|
+
AgentRefreshedStatusPayloadSchema,
|
|
1226
|
+
ShutdownRequestedStatusPayloadSchema,
|
|
1227
|
+
RestartRequestedStatusPayloadSchema,
|
|
1228
|
+
]);
|
|
1229
|
+
export const ArtifactMessageSchema = z.object({
|
|
1230
|
+
type: z.literal('artifact'),
|
|
1231
|
+
payload: z.object({
|
|
1232
|
+
type: z.enum(['markdown', 'diff', 'image', 'code']),
|
|
1233
|
+
id: z.string(),
|
|
1234
|
+
title: z.string(),
|
|
1235
|
+
content: z.string(),
|
|
1236
|
+
isBase64: z.boolean(),
|
|
1237
|
+
}),
|
|
1238
|
+
});
|
|
1239
|
+
export const ProjectCheckoutLiteNotGitPayloadSchema = z.object({
|
|
1240
|
+
cwd: z.string(),
|
|
1241
|
+
isGit: z.literal(false),
|
|
1242
|
+
currentBranch: z.null(),
|
|
1243
|
+
remoteUrl: z.null(),
|
|
1244
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
1245
|
+
mainRepoRoot: z.null(),
|
|
1246
|
+
});
|
|
1247
|
+
export const ProjectCheckoutLiteGitNonPaseoPayloadSchema = z.object({
|
|
1248
|
+
cwd: z.string(),
|
|
1249
|
+
isGit: z.literal(true),
|
|
1250
|
+
currentBranch: z.string().nullable(),
|
|
1251
|
+
remoteUrl: z.string().nullable(),
|
|
1252
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
1253
|
+
mainRepoRoot: z.null(),
|
|
1254
|
+
});
|
|
1255
|
+
export const ProjectCheckoutLiteGitPaseoPayloadSchema = z.object({
|
|
1256
|
+
cwd: z.string(),
|
|
1257
|
+
isGit: z.literal(true),
|
|
1258
|
+
currentBranch: z.string().nullable(),
|
|
1259
|
+
remoteUrl: z.string().nullable(),
|
|
1260
|
+
isPaseoOwnedWorktree: z.literal(true),
|
|
1261
|
+
mainRepoRoot: z.string(),
|
|
1262
|
+
});
|
|
1263
|
+
export const ProjectCheckoutLitePayloadSchema = z.union([
|
|
1264
|
+
ProjectCheckoutLiteNotGitPayloadSchema,
|
|
1265
|
+
ProjectCheckoutLiteGitNonPaseoPayloadSchema,
|
|
1266
|
+
ProjectCheckoutLiteGitPaseoPayloadSchema,
|
|
1267
|
+
]);
|
|
1268
|
+
export const ProjectPlacementPayloadSchema = z.object({
|
|
1269
|
+
projectKey: z.string(),
|
|
1270
|
+
projectName: z.string(),
|
|
1271
|
+
checkout: ProjectCheckoutLitePayloadSchema,
|
|
1272
|
+
});
|
|
1273
|
+
export const WorkspaceDescriptorPayloadSchema = z.object({
|
|
1274
|
+
id: z.string(),
|
|
1275
|
+
projectId: z.string(),
|
|
1276
|
+
name: z.string(),
|
|
1277
|
+
status: WorkspaceStateBucketSchema,
|
|
1278
|
+
activityAt: z.string().nullable(),
|
|
1279
|
+
});
|
|
1280
|
+
export const AgentUpdateMessageSchema = z.object({
|
|
1281
|
+
type: z.literal('agent_update'),
|
|
1282
|
+
payload: z.discriminatedUnion('kind', [
|
|
1283
|
+
z.object({
|
|
1284
|
+
kind: z.literal('upsert'),
|
|
1285
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1286
|
+
project: ProjectPlacementPayloadSchema,
|
|
1287
|
+
}),
|
|
1288
|
+
z.object({
|
|
1289
|
+
kind: z.literal('remove'),
|
|
1290
|
+
agentId: z.string(),
|
|
1291
|
+
}),
|
|
1292
|
+
]),
|
|
1293
|
+
});
|
|
1294
|
+
export const AgentStreamMessageSchema = z.object({
|
|
1295
|
+
type: z.literal('agent_stream'),
|
|
1296
|
+
payload: z.object({
|
|
1297
|
+
agentId: z.string(),
|
|
1298
|
+
event: AgentStreamEventPayloadSchema,
|
|
1299
|
+
timestamp: z.string(),
|
|
1300
|
+
// Present for timeline events. Maps 1:1 to canonical in-memory timeline rows.
|
|
1301
|
+
seq: z.number().int().nonnegative().optional(),
|
|
1302
|
+
epoch: z.string().optional(),
|
|
1303
|
+
}),
|
|
1304
|
+
});
|
|
1305
|
+
export const AgentStatusMessageSchema = z.object({
|
|
1306
|
+
type: z.literal('agent_status'),
|
|
1307
|
+
payload: z.object({
|
|
1308
|
+
agentId: z.string(),
|
|
1309
|
+
status: z.string(),
|
|
1310
|
+
info: AgentSnapshotPayloadSchema,
|
|
1311
|
+
}),
|
|
1312
|
+
});
|
|
1313
|
+
export const AgentListMessageSchema = z.object({
|
|
1314
|
+
type: z.literal('agent_list'),
|
|
1315
|
+
payload: z.object({
|
|
1316
|
+
agents: z.array(AgentSnapshotPayloadSchema),
|
|
1317
|
+
}),
|
|
1318
|
+
});
|
|
1319
|
+
export const FetchAgentsResponseMessageSchema = z.object({
|
|
1320
|
+
type: z.literal('fetch_agents_response'),
|
|
1321
|
+
payload: z.object({
|
|
1322
|
+
requestId: z.string(),
|
|
1323
|
+
subscriptionId: z.string().nullable().optional(),
|
|
1324
|
+
entries: z.array(z.object({
|
|
1325
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1326
|
+
project: ProjectPlacementPayloadSchema,
|
|
1327
|
+
})),
|
|
1328
|
+
pageInfo: z.object({
|
|
1329
|
+
nextCursor: z.string().nullable(),
|
|
1330
|
+
prevCursor: z.string().nullable(),
|
|
1331
|
+
hasMore: z.boolean(),
|
|
1332
|
+
}),
|
|
1333
|
+
}),
|
|
1334
|
+
});
|
|
1335
|
+
export const FetchWorkspacesResponseMessageSchema = z.object({
|
|
1336
|
+
type: z.literal('fetch_workspaces_response'),
|
|
1337
|
+
payload: z.object({
|
|
1338
|
+
requestId: z.string(),
|
|
1339
|
+
subscriptionId: z.string().nullable().optional(),
|
|
1340
|
+
entries: z.array(WorkspaceDescriptorPayloadSchema),
|
|
1341
|
+
pageInfo: z.object({
|
|
1342
|
+
nextCursor: z.string().nullable(),
|
|
1343
|
+
prevCursor: z.string().nullable(),
|
|
1344
|
+
hasMore: z.boolean(),
|
|
1345
|
+
}),
|
|
1346
|
+
}),
|
|
1347
|
+
});
|
|
1348
|
+
export const WorkspaceUpdateMessageSchema = z.object({
|
|
1349
|
+
type: z.literal('workspace_update'),
|
|
1350
|
+
payload: z.discriminatedUnion('kind', [
|
|
1351
|
+
z.object({
|
|
1352
|
+
kind: z.literal('upsert'),
|
|
1353
|
+
workspace: WorkspaceDescriptorPayloadSchema,
|
|
1354
|
+
}),
|
|
1355
|
+
z.object({
|
|
1356
|
+
kind: z.literal('remove'),
|
|
1357
|
+
id: z.string(),
|
|
1358
|
+
}),
|
|
1359
|
+
]),
|
|
1360
|
+
});
|
|
1361
|
+
export const FetchAgentResponseMessageSchema = z.object({
|
|
1362
|
+
type: z.literal('fetch_agent_response'),
|
|
1363
|
+
payload: z.object({
|
|
1364
|
+
requestId: z.string(),
|
|
1365
|
+
agent: AgentSnapshotPayloadSchema.nullable(),
|
|
1366
|
+
project: ProjectPlacementPayloadSchema.nullable().optional(),
|
|
1367
|
+
error: z.string().nullable(),
|
|
1368
|
+
}),
|
|
1369
|
+
});
|
|
1370
|
+
const AgentTimelineSeqRangeSchema = z.object({
|
|
1371
|
+
startSeq: z.number().int().nonnegative(),
|
|
1372
|
+
endSeq: z.number().int().nonnegative(),
|
|
1373
|
+
});
|
|
1374
|
+
export const AgentTimelineEntryPayloadSchema = z.object({
|
|
1375
|
+
provider: AgentProviderSchema,
|
|
1376
|
+
item: AgentTimelineItemPayloadSchema,
|
|
1377
|
+
timestamp: z.string(),
|
|
1378
|
+
seqStart: z.number().int().nonnegative(),
|
|
1379
|
+
seqEnd: z.number().int().nonnegative(),
|
|
1380
|
+
sourceSeqRanges: z.array(AgentTimelineSeqRangeSchema),
|
|
1381
|
+
collapsed: z.array(z.enum(['assistant_merge', 'tool_lifecycle'])),
|
|
1382
|
+
});
|
|
1383
|
+
export const FetchAgentTimelineResponseMessageSchema = z.object({
|
|
1384
|
+
type: z.literal('fetch_agent_timeline_response'),
|
|
1385
|
+
payload: z.object({
|
|
1386
|
+
requestId: z.string(),
|
|
1387
|
+
agentId: z.string(),
|
|
1388
|
+
agent: AgentSnapshotPayloadSchema.nullable(),
|
|
1389
|
+
direction: z.enum(['tail', 'before', 'after']),
|
|
1390
|
+
projection: z.enum(['projected', 'canonical']),
|
|
1391
|
+
epoch: z.string(),
|
|
1392
|
+
reset: z.boolean(),
|
|
1393
|
+
staleCursor: z.boolean(),
|
|
1394
|
+
gap: z.boolean(),
|
|
1395
|
+
window: z.object({
|
|
1396
|
+
minSeq: z.number().int().nonnegative(),
|
|
1397
|
+
maxSeq: z.number().int().nonnegative(),
|
|
1398
|
+
nextSeq: z.number().int().nonnegative(),
|
|
1399
|
+
}),
|
|
1400
|
+
startCursor: AgentTimelineCursorSchema.nullable(),
|
|
1401
|
+
endCursor: AgentTimelineCursorSchema.nullable(),
|
|
1402
|
+
hasOlder: z.boolean(),
|
|
1403
|
+
hasNewer: z.boolean(),
|
|
1404
|
+
entries: z.array(AgentTimelineEntryPayloadSchema),
|
|
1405
|
+
error: z.string().nullable(),
|
|
1406
|
+
}),
|
|
1407
|
+
});
|
|
1408
|
+
export const SendAgentMessageResponseMessageSchema = z.object({
|
|
1409
|
+
type: z.literal('send_agent_message_response'),
|
|
1410
|
+
payload: z.object({
|
|
1411
|
+
requestId: z.string(),
|
|
1412
|
+
agentId: z.string(),
|
|
1413
|
+
accepted: z.boolean(),
|
|
1414
|
+
error: z.string().nullable(),
|
|
1415
|
+
}),
|
|
1416
|
+
});
|
|
1417
|
+
export const WaitForFinishResponseMessageSchema = z.object({
|
|
1418
|
+
type: z.literal('wait_for_finish_response'),
|
|
1419
|
+
payload: z.object({
|
|
1420
|
+
requestId: z.string(),
|
|
1421
|
+
status: z.enum(['idle', 'error', 'permission', 'timeout']),
|
|
1422
|
+
final: AgentSnapshotPayloadSchema.nullable(),
|
|
1423
|
+
error: z.string().nullable(),
|
|
1424
|
+
lastMessage: z.string().nullable(),
|
|
1425
|
+
}),
|
|
1426
|
+
});
|
|
1427
|
+
export const AgentPermissionRequestMessageSchema = z.object({
|
|
1428
|
+
type: z.literal('agent_permission_request'),
|
|
1429
|
+
payload: z.object({
|
|
1430
|
+
agentId: z.string(),
|
|
1431
|
+
request: AgentPermissionRequestPayloadSchema,
|
|
1432
|
+
}),
|
|
1433
|
+
});
|
|
1434
|
+
export const AgentPermissionResolvedMessageSchema = z.object({
|
|
1435
|
+
type: z.literal('agent_permission_resolved'),
|
|
1436
|
+
payload: z.object({
|
|
1437
|
+
agentId: z.string(),
|
|
1438
|
+
requestId: z.string(),
|
|
1439
|
+
resolution: AgentPermissionResponseSchema,
|
|
1440
|
+
}),
|
|
1441
|
+
});
|
|
1442
|
+
export const AgentDeletedMessageSchema = z.object({
|
|
1443
|
+
type: z.literal('agent_deleted'),
|
|
1444
|
+
payload: z.object({
|
|
1445
|
+
agentId: z.string(),
|
|
1446
|
+
requestId: z.string(),
|
|
1447
|
+
}),
|
|
1448
|
+
});
|
|
1449
|
+
export const AgentArchivedMessageSchema = z.object({
|
|
1450
|
+
type: z.literal('agent_archived'),
|
|
1451
|
+
payload: z.object({
|
|
1452
|
+
agentId: z.string(),
|
|
1453
|
+
archivedAt: z.string(),
|
|
1454
|
+
requestId: z.string(),
|
|
1455
|
+
}),
|
|
1456
|
+
});
|
|
1457
|
+
const AheadBehindSchema = z.object({
|
|
1458
|
+
ahead: z.number(),
|
|
1459
|
+
behind: z.number(),
|
|
1460
|
+
});
|
|
1461
|
+
const CheckoutStatusCommonSchema = z.object({
|
|
1462
|
+
cwd: z.string(),
|
|
1463
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1464
|
+
requestId: z.string(),
|
|
1465
|
+
});
|
|
1466
|
+
const CheckoutStatusNotGitSchema = CheckoutStatusCommonSchema.extend({
|
|
1467
|
+
isGit: z.literal(false),
|
|
1468
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
1469
|
+
repoRoot: z.null(),
|
|
1470
|
+
currentBranch: z.null(),
|
|
1471
|
+
isDirty: z.null(),
|
|
1472
|
+
baseRef: z.null(),
|
|
1473
|
+
aheadBehind: z.null(),
|
|
1474
|
+
aheadOfOrigin: z.null(),
|
|
1475
|
+
behindOfOrigin: z.null(),
|
|
1476
|
+
hasRemote: z.boolean(),
|
|
1477
|
+
remoteUrl: z.null(),
|
|
1478
|
+
});
|
|
1479
|
+
const CheckoutStatusGitNonPaseoSchema = CheckoutStatusCommonSchema.extend({
|
|
1480
|
+
isGit: z.literal(true),
|
|
1481
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
1482
|
+
repoRoot: z.string(),
|
|
1483
|
+
currentBranch: z.string().nullable(),
|
|
1484
|
+
isDirty: z.boolean(),
|
|
1485
|
+
baseRef: z.string().nullable(),
|
|
1486
|
+
aheadBehind: AheadBehindSchema.nullable(),
|
|
1487
|
+
aheadOfOrigin: z.number().nullable(),
|
|
1488
|
+
behindOfOrigin: z.number().nullable(),
|
|
1489
|
+
hasRemote: z.boolean(),
|
|
1490
|
+
remoteUrl: z.string().nullable(),
|
|
1491
|
+
});
|
|
1492
|
+
const CheckoutStatusGitPaseoSchema = CheckoutStatusCommonSchema.extend({
|
|
1493
|
+
isGit: z.literal(true),
|
|
1494
|
+
isPaseoOwnedWorktree: z.literal(true),
|
|
1495
|
+
repoRoot: z.string(),
|
|
1496
|
+
mainRepoRoot: z.string(),
|
|
1497
|
+
currentBranch: z.string().nullable(),
|
|
1498
|
+
isDirty: z.boolean(),
|
|
1499
|
+
baseRef: z.string(),
|
|
1500
|
+
aheadBehind: AheadBehindSchema.nullable(),
|
|
1501
|
+
aheadOfOrigin: z.number().nullable(),
|
|
1502
|
+
behindOfOrigin: z.number().nullable(),
|
|
1503
|
+
hasRemote: z.boolean(),
|
|
1504
|
+
remoteUrl: z.string().nullable(),
|
|
1505
|
+
});
|
|
1506
|
+
export const CheckoutStatusResponseSchema = z.object({
|
|
1507
|
+
type: z.literal('checkout_status_response'),
|
|
1508
|
+
payload: z.union([
|
|
1509
|
+
CheckoutStatusNotGitSchema,
|
|
1510
|
+
CheckoutStatusGitNonPaseoSchema,
|
|
1511
|
+
CheckoutStatusGitPaseoSchema,
|
|
1512
|
+
]),
|
|
1513
|
+
});
|
|
1514
|
+
const CheckoutDiffSubscriptionPayloadSchema = z.object({
|
|
1515
|
+
subscriptionId: z.string(),
|
|
1516
|
+
cwd: z.string(),
|
|
1517
|
+
files: z.array(ParsedDiffFileSchema),
|
|
1518
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1519
|
+
});
|
|
1520
|
+
export const SubscribeCheckoutDiffResponseSchema = z.object({
|
|
1521
|
+
type: z.literal('subscribe_checkout_diff_response'),
|
|
1522
|
+
payload: CheckoutDiffSubscriptionPayloadSchema.extend({
|
|
1523
|
+
requestId: z.string(),
|
|
1524
|
+
}),
|
|
1525
|
+
});
|
|
1526
|
+
export const CheckoutDiffUpdateSchema = z.object({
|
|
1527
|
+
type: z.literal('checkout_diff_update'),
|
|
1528
|
+
payload: CheckoutDiffSubscriptionPayloadSchema,
|
|
1529
|
+
});
|
|
1530
|
+
export const CheckoutCommitResponseSchema = z.object({
|
|
1531
|
+
type: z.literal('checkout_commit_response'),
|
|
1532
|
+
payload: z.object({
|
|
1533
|
+
cwd: z.string(),
|
|
1534
|
+
success: z.boolean(),
|
|
1535
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1536
|
+
requestId: z.string(),
|
|
1537
|
+
}),
|
|
1538
|
+
});
|
|
1539
|
+
export const CheckoutMergeResponseSchema = z.object({
|
|
1540
|
+
type: z.literal('checkout_merge_response'),
|
|
1541
|
+
payload: z.object({
|
|
1542
|
+
cwd: z.string(),
|
|
1543
|
+
success: z.boolean(),
|
|
1544
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1545
|
+
requestId: z.string(),
|
|
1546
|
+
}),
|
|
1547
|
+
});
|
|
1548
|
+
export const CheckoutMergeFromBaseResponseSchema = z.object({
|
|
1549
|
+
type: z.literal('checkout_merge_from_base_response'),
|
|
1550
|
+
payload: z.object({
|
|
1551
|
+
cwd: z.string(),
|
|
1552
|
+
success: z.boolean(),
|
|
1553
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1554
|
+
requestId: z.string(),
|
|
1555
|
+
}),
|
|
1556
|
+
});
|
|
1557
|
+
export const CheckoutPushResponseSchema = z.object({
|
|
1558
|
+
type: z.literal('checkout_push_response'),
|
|
1559
|
+
payload: z.object({
|
|
1560
|
+
cwd: z.string(),
|
|
1561
|
+
success: z.boolean(),
|
|
1562
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1563
|
+
requestId: z.string(),
|
|
1564
|
+
}),
|
|
1565
|
+
});
|
|
1566
|
+
export const CheckoutPrCreateResponseSchema = z.object({
|
|
1567
|
+
type: z.literal('checkout_pr_create_response'),
|
|
1568
|
+
payload: z.object({
|
|
1569
|
+
cwd: z.string(),
|
|
1570
|
+
url: z.string().nullable(),
|
|
1571
|
+
number: z.number().nullable(),
|
|
1572
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1573
|
+
requestId: z.string(),
|
|
1574
|
+
}),
|
|
1575
|
+
});
|
|
1576
|
+
const CheckoutPrStatusSchema = z.object({
|
|
1577
|
+
url: z.string(),
|
|
1578
|
+
title: z.string(),
|
|
1579
|
+
state: z.string(),
|
|
1580
|
+
baseRefName: z.string(),
|
|
1581
|
+
headRefName: z.string(),
|
|
1582
|
+
isMerged: z.boolean(),
|
|
1583
|
+
});
|
|
1584
|
+
export const CheckoutPrStatusResponseSchema = z.object({
|
|
1585
|
+
type: z.literal('checkout_pr_status_response'),
|
|
1586
|
+
payload: z.object({
|
|
1587
|
+
cwd: z.string(),
|
|
1588
|
+
status: CheckoutPrStatusSchema.nullable(),
|
|
1589
|
+
githubFeaturesEnabled: z.boolean(),
|
|
1590
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1591
|
+
requestId: z.string(),
|
|
1592
|
+
}),
|
|
1593
|
+
});
|
|
1594
|
+
export const ValidateBranchResponseSchema = z.object({
|
|
1595
|
+
type: z.literal('validate_branch_response'),
|
|
1596
|
+
payload: z.object({
|
|
1597
|
+
exists: z.boolean(),
|
|
1598
|
+
resolvedRef: z.string().nullable(),
|
|
1599
|
+
isRemote: z.boolean(),
|
|
1600
|
+
error: z.string().nullable(),
|
|
1601
|
+
requestId: z.string(),
|
|
1602
|
+
}),
|
|
1603
|
+
});
|
|
1604
|
+
export const BranchSuggestionsResponseSchema = z.object({
|
|
1605
|
+
type: z.literal('branch_suggestions_response'),
|
|
1606
|
+
payload: z.object({
|
|
1607
|
+
branches: z.array(z.string()),
|
|
1608
|
+
error: z.string().nullable(),
|
|
1609
|
+
requestId: z.string(),
|
|
1610
|
+
}),
|
|
1611
|
+
});
|
|
1612
|
+
export const DirectorySuggestionsResponseSchema = z.object({
|
|
1613
|
+
type: z.literal('directory_suggestions_response'),
|
|
1614
|
+
payload: z.object({
|
|
1615
|
+
directories: z.array(z.string()),
|
|
1616
|
+
entries: z
|
|
1617
|
+
.array(z.object({
|
|
1618
|
+
path: z.string(),
|
|
1619
|
+
kind: z.enum(['file', 'directory']),
|
|
1620
|
+
}))
|
|
1621
|
+
.optional()
|
|
1622
|
+
.default([]),
|
|
1623
|
+
error: z.string().nullable(),
|
|
1624
|
+
requestId: z.string(),
|
|
1625
|
+
}),
|
|
1626
|
+
});
|
|
1627
|
+
const PaseoWorktreeSchema = z.object({
|
|
1628
|
+
worktreePath: z.string(),
|
|
1629
|
+
createdAt: z.string(),
|
|
1630
|
+
branchName: z.string().nullable().optional(),
|
|
1631
|
+
head: z.string().nullable().optional(),
|
|
1632
|
+
});
|
|
1633
|
+
export const PaseoWorktreeListResponseSchema = z.object({
|
|
1634
|
+
type: z.literal('paseo_worktree_list_response'),
|
|
1635
|
+
payload: z.object({
|
|
1636
|
+
worktrees: z.array(PaseoWorktreeSchema),
|
|
1637
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1638
|
+
requestId: z.string(),
|
|
1639
|
+
}),
|
|
1640
|
+
});
|
|
1641
|
+
export const PaseoWorktreeArchiveResponseSchema = z.object({
|
|
1642
|
+
type: z.literal('paseo_worktree_archive_response'),
|
|
1643
|
+
payload: z.object({
|
|
1644
|
+
success: z.boolean(),
|
|
1645
|
+
removedAgents: z.array(z.string()).optional(),
|
|
1646
|
+
error: CheckoutErrorSchema.nullable(),
|
|
1647
|
+
requestId: z.string(),
|
|
1648
|
+
}),
|
|
1649
|
+
});
|
|
1650
|
+
export const FileExplorerResponseSchema = z.object({
|
|
1651
|
+
type: z.literal('file_explorer_response'),
|
|
1652
|
+
payload: z.object({
|
|
1653
|
+
cwd: z.string(),
|
|
1654
|
+
path: z.string(),
|
|
1655
|
+
mode: z.enum(['list', 'file']),
|
|
1656
|
+
directory: FileExplorerDirectorySchema.nullable(),
|
|
1657
|
+
file: FileExplorerFileSchema.nullable(),
|
|
1658
|
+
error: z.string().nullable(),
|
|
1659
|
+
requestId: z.string(),
|
|
1660
|
+
}),
|
|
1661
|
+
});
|
|
1662
|
+
const ProjectIconSchema = z.object({
|
|
1663
|
+
data: z.string(),
|
|
1664
|
+
mimeType: z.string(),
|
|
1665
|
+
});
|
|
1666
|
+
export const ProjectIconResponseSchema = z.object({
|
|
1667
|
+
type: z.literal('project_icon_response'),
|
|
1668
|
+
payload: z.object({
|
|
1669
|
+
cwd: z.string(),
|
|
1670
|
+
icon: ProjectIconSchema.nullable(),
|
|
1671
|
+
error: z.string().nullable(),
|
|
1672
|
+
requestId: z.string(),
|
|
1673
|
+
}),
|
|
1674
|
+
});
|
|
1675
|
+
export const FileDownloadTokenResponseSchema = z.object({
|
|
1676
|
+
type: z.literal('file_download_token_response'),
|
|
1677
|
+
payload: z.object({
|
|
1678
|
+
cwd: z.string(),
|
|
1679
|
+
path: z.string(),
|
|
1680
|
+
token: z.string().nullable(),
|
|
1681
|
+
fileName: z.string().nullable(),
|
|
1682
|
+
mimeType: z.string().nullable(),
|
|
1683
|
+
size: z.number().nullable(),
|
|
1684
|
+
error: z.string().nullable(),
|
|
1685
|
+
requestId: z.string(),
|
|
1686
|
+
}),
|
|
1687
|
+
});
|
|
1688
|
+
export const ListProviderModelsResponseMessageSchema = z.object({
|
|
1689
|
+
type: z.literal('list_provider_models_response'),
|
|
1690
|
+
payload: z.object({
|
|
1691
|
+
provider: AgentProviderSchema,
|
|
1692
|
+
models: z.array(AgentModelDefinitionSchema).optional(),
|
|
1693
|
+
error: z.string().nullable().optional(),
|
|
1694
|
+
fetchedAt: z.string(),
|
|
1695
|
+
requestId: z.string(),
|
|
1696
|
+
}),
|
|
1697
|
+
});
|
|
1698
|
+
const ProviderAvailabilitySchema = z.object({
|
|
1699
|
+
provider: AgentProviderSchema,
|
|
1700
|
+
available: z.boolean(),
|
|
1701
|
+
error: z.string().nullable().optional(),
|
|
1702
|
+
});
|
|
1703
|
+
export const ListAvailableProvidersResponseSchema = z.object({
|
|
1704
|
+
type: z.literal('list_available_providers_response'),
|
|
1705
|
+
payload: z.object({
|
|
1706
|
+
providers: z.array(ProviderAvailabilitySchema),
|
|
1707
|
+
error: z.string().nullable().optional(),
|
|
1708
|
+
fetchedAt: z.string(),
|
|
1709
|
+
requestId: z.string(),
|
|
1710
|
+
}),
|
|
1711
|
+
});
|
|
1712
|
+
export const SpeechModelsListResponseSchema = z.object({
|
|
1713
|
+
type: z.literal('speech_models_list_response'),
|
|
1714
|
+
payload: z.object({
|
|
1715
|
+
modelsDir: z.string(),
|
|
1716
|
+
models: z.array(z.object({
|
|
1717
|
+
id: z.string(),
|
|
1718
|
+
kind: z.string(),
|
|
1719
|
+
description: z.string(),
|
|
1720
|
+
modelDir: z.string(),
|
|
1721
|
+
isDownloaded: z.boolean(),
|
|
1722
|
+
missingFiles: z.array(z.string()).optional(),
|
|
1723
|
+
})),
|
|
1724
|
+
requestId: z.string(),
|
|
1725
|
+
}),
|
|
1726
|
+
});
|
|
1727
|
+
export const SpeechModelsDownloadResponseSchema = z.object({
|
|
1728
|
+
type: z.literal('speech_models_download_response'),
|
|
1729
|
+
payload: z.object({
|
|
1730
|
+
modelsDir: z.string(),
|
|
1731
|
+
downloadedModelIds: z.array(z.string()),
|
|
1732
|
+
error: z.string().nullable(),
|
|
1733
|
+
requestId: z.string(),
|
|
1734
|
+
}),
|
|
1735
|
+
});
|
|
1736
|
+
const AgentSlashCommandSchema = z.object({
|
|
1737
|
+
name: z.string(),
|
|
1738
|
+
description: z.string(),
|
|
1739
|
+
argumentHint: z.string(),
|
|
1740
|
+
});
|
|
1741
|
+
export const ListCommandsResponseSchema = z.object({
|
|
1742
|
+
type: z.literal('list_commands_response'),
|
|
1743
|
+
payload: z.object({
|
|
1744
|
+
agentId: z.string(),
|
|
1745
|
+
commands: z.array(AgentSlashCommandSchema),
|
|
1746
|
+
error: z.string().nullable(),
|
|
1747
|
+
requestId: z.string(),
|
|
1748
|
+
}),
|
|
1749
|
+
});
|
|
1750
|
+
// ============================================================================
|
|
1751
|
+
// Terminal Outbound Messages
|
|
1752
|
+
// ============================================================================
|
|
1753
|
+
const TerminalInfoSchema = z.object({
|
|
1754
|
+
id: z.string(),
|
|
1755
|
+
name: z.string(),
|
|
1756
|
+
cwd: z.string(),
|
|
1757
|
+
});
|
|
1758
|
+
const TerminalCellSchema = z.object({
|
|
1759
|
+
char: z.string(),
|
|
1760
|
+
fg: z.number().optional(),
|
|
1761
|
+
bg: z.number().optional(),
|
|
1762
|
+
fgMode: z.number().optional(),
|
|
1763
|
+
bgMode: z.number().optional(),
|
|
1764
|
+
bold: z.boolean().optional(),
|
|
1765
|
+
italic: z.boolean().optional(),
|
|
1766
|
+
underline: z.boolean().optional(),
|
|
1767
|
+
});
|
|
1768
|
+
const TerminalStateSchema = z.object({
|
|
1769
|
+
rows: z.number(),
|
|
1770
|
+
cols: z.number(),
|
|
1771
|
+
grid: z.array(z.array(TerminalCellSchema)),
|
|
1772
|
+
scrollback: z.array(z.array(TerminalCellSchema)),
|
|
1773
|
+
cursor: z.object({ row: z.number(), col: z.number() }),
|
|
1774
|
+
});
|
|
1775
|
+
export const ListTerminalsResponseSchema = z.object({
|
|
1776
|
+
type: z.literal('list_terminals_response'),
|
|
1777
|
+
payload: z.object({
|
|
1778
|
+
cwd: z.string(),
|
|
1779
|
+
terminals: z.array(TerminalInfoSchema.omit({ cwd: true })),
|
|
1780
|
+
requestId: z.string(),
|
|
1781
|
+
}),
|
|
1782
|
+
});
|
|
1783
|
+
export const TerminalsChangedSchema = z.object({
|
|
1784
|
+
type: z.literal('terminals_changed'),
|
|
1785
|
+
payload: z.object({
|
|
1786
|
+
cwd: z.string(),
|
|
1787
|
+
terminals: z.array(TerminalInfoSchema.omit({ cwd: true })),
|
|
1788
|
+
}),
|
|
1789
|
+
});
|
|
1790
|
+
export const CreateTerminalResponseSchema = z.object({
|
|
1791
|
+
type: z.literal('create_terminal_response'),
|
|
1792
|
+
payload: z.object({
|
|
1793
|
+
terminal: TerminalInfoSchema.nullable(),
|
|
1794
|
+
error: z.string().nullable(),
|
|
1795
|
+
requestId: z.string(),
|
|
1796
|
+
}),
|
|
1797
|
+
});
|
|
1798
|
+
export const SubscribeTerminalResponseSchema = z.object({
|
|
1799
|
+
type: z.literal('subscribe_terminal_response'),
|
|
1800
|
+
payload: z.object({
|
|
1801
|
+
terminalId: z.string(),
|
|
1802
|
+
state: TerminalStateSchema.nullable(),
|
|
1803
|
+
error: z.string().nullable(),
|
|
1804
|
+
requestId: z.string(),
|
|
1805
|
+
}),
|
|
1806
|
+
});
|
|
1807
|
+
export const TerminalOutputSchema = z.object({
|
|
1808
|
+
type: z.literal('terminal_output'),
|
|
1809
|
+
payload: z.object({
|
|
1810
|
+
terminalId: z.string(),
|
|
1811
|
+
state: TerminalStateSchema,
|
|
1812
|
+
}),
|
|
1813
|
+
});
|
|
1814
|
+
export const KillTerminalResponseSchema = z.object({
|
|
1815
|
+
type: z.literal('kill_terminal_response'),
|
|
1816
|
+
payload: z.object({
|
|
1817
|
+
terminalId: z.string(),
|
|
1818
|
+
success: z.boolean(),
|
|
1819
|
+
requestId: z.string(),
|
|
1820
|
+
}),
|
|
1821
|
+
});
|
|
1822
|
+
export const AttachTerminalStreamResponseSchema = z.object({
|
|
1823
|
+
type: z.literal('attach_terminal_stream_response'),
|
|
1824
|
+
payload: z.object({
|
|
1825
|
+
terminalId: z.string(),
|
|
1826
|
+
streamId: z.number().int().nonnegative().nullable(),
|
|
1827
|
+
replayedFrom: z.number().int().nonnegative(),
|
|
1828
|
+
currentOffset: z.number().int().nonnegative(),
|
|
1829
|
+
earliestAvailableOffset: z.number().int().nonnegative(),
|
|
1830
|
+
reset: z.boolean(),
|
|
1831
|
+
error: z.string().nullable(),
|
|
1832
|
+
requestId: z.string(),
|
|
1833
|
+
}),
|
|
1834
|
+
});
|
|
1835
|
+
export const DetachTerminalStreamResponseSchema = z.object({
|
|
1836
|
+
type: z.literal('detach_terminal_stream_response'),
|
|
1837
|
+
payload: z.object({
|
|
1838
|
+
streamId: z.number().int().nonnegative(),
|
|
1839
|
+
success: z.boolean(),
|
|
1840
|
+
requestId: z.string(),
|
|
1841
|
+
}),
|
|
1842
|
+
});
|
|
1843
|
+
export const TerminalStreamExitSchema = z.object({
|
|
1844
|
+
type: z.literal('terminal_stream_exit'),
|
|
1845
|
+
payload: z.object({
|
|
1846
|
+
streamId: z.number().int().nonnegative(),
|
|
1847
|
+
terminalId: z.string(),
|
|
1848
|
+
}),
|
|
1849
|
+
});
|
|
1850
|
+
export const SessionOutboundMessageSchema = z.discriminatedUnion('type', [
|
|
1851
|
+
ActivityLogMessageSchema,
|
|
1852
|
+
AssistantChunkMessageSchema,
|
|
1853
|
+
AudioOutputMessageSchema,
|
|
1854
|
+
TranscriptionResultMessageSchema,
|
|
1855
|
+
DictationStreamAckMessageSchema,
|
|
1856
|
+
DictationStreamFinishAcceptedMessageSchema,
|
|
1857
|
+
DictationStreamPartialMessageSchema,
|
|
1858
|
+
DictationStreamFinalMessageSchema,
|
|
1859
|
+
DictationStreamErrorMessageSchema,
|
|
1860
|
+
StatusMessageSchema,
|
|
1861
|
+
PongMessageSchema,
|
|
1862
|
+
RpcErrorMessageSchema,
|
|
1863
|
+
ArtifactMessageSchema,
|
|
1864
|
+
AgentUpdateMessageSchema,
|
|
1865
|
+
WorkspaceUpdateMessageSchema,
|
|
1866
|
+
AgentStreamMessageSchema,
|
|
1867
|
+
AgentStatusMessageSchema,
|
|
1868
|
+
FetchAgentsResponseMessageSchema,
|
|
1869
|
+
FetchWorkspacesResponseMessageSchema,
|
|
1870
|
+
FetchAgentResponseMessageSchema,
|
|
1871
|
+
FetchAgentTimelineResponseMessageSchema,
|
|
1872
|
+
SendAgentMessageResponseMessageSchema,
|
|
1873
|
+
SetVoiceModeResponseMessageSchema,
|
|
1874
|
+
SetAgentModeResponseMessageSchema,
|
|
1875
|
+
SetAgentModelResponseMessageSchema,
|
|
1876
|
+
SetAgentThinkingResponseMessageSchema,
|
|
1877
|
+
UpdateAgentResponseMessageSchema,
|
|
1878
|
+
WaitForFinishResponseMessageSchema,
|
|
1879
|
+
AgentPermissionRequestMessageSchema,
|
|
1880
|
+
AgentPermissionResolvedMessageSchema,
|
|
1881
|
+
AgentDeletedMessageSchema,
|
|
1882
|
+
AgentArchivedMessageSchema,
|
|
1883
|
+
CheckoutStatusResponseSchema,
|
|
1884
|
+
SubscribeCheckoutDiffResponseSchema,
|
|
1885
|
+
CheckoutDiffUpdateSchema,
|
|
1886
|
+
CheckoutCommitResponseSchema,
|
|
1887
|
+
CheckoutMergeResponseSchema,
|
|
1888
|
+
CheckoutMergeFromBaseResponseSchema,
|
|
1889
|
+
CheckoutPushResponseSchema,
|
|
1890
|
+
CheckoutPrCreateResponseSchema,
|
|
1891
|
+
CheckoutPrStatusResponseSchema,
|
|
1892
|
+
ValidateBranchResponseSchema,
|
|
1893
|
+
BranchSuggestionsResponseSchema,
|
|
1894
|
+
DirectorySuggestionsResponseSchema,
|
|
1895
|
+
PaseoWorktreeListResponseSchema,
|
|
1896
|
+
PaseoWorktreeArchiveResponseSchema,
|
|
1897
|
+
FileExplorerResponseSchema,
|
|
1898
|
+
ProjectIconResponseSchema,
|
|
1899
|
+
FileDownloadTokenResponseSchema,
|
|
1900
|
+
ListProviderModelsResponseMessageSchema,
|
|
1901
|
+
ListAvailableProvidersResponseSchema,
|
|
1902
|
+
SpeechModelsListResponseSchema,
|
|
1903
|
+
SpeechModelsDownloadResponseSchema,
|
|
1904
|
+
ListCommandsResponseSchema,
|
|
1905
|
+
ListTerminalsResponseSchema,
|
|
1906
|
+
TerminalsChangedSchema,
|
|
1907
|
+
CreateTerminalResponseSchema,
|
|
1908
|
+
SubscribeTerminalResponseSchema,
|
|
1909
|
+
TerminalOutputSchema,
|
|
1910
|
+
KillTerminalResponseSchema,
|
|
1911
|
+
AttachTerminalStreamResponseSchema,
|
|
1912
|
+
DetachTerminalStreamResponseSchema,
|
|
1913
|
+
TerminalStreamExitSchema,
|
|
1914
|
+
]);
|
|
1915
|
+
// ============================================================================
|
|
1916
|
+
// WebSocket Level Messages (wraps session messages)
|
|
1917
|
+
// ============================================================================
|
|
1918
|
+
// WebSocket-only messages (not session messages)
|
|
1919
|
+
export const WSPingMessageSchema = z.object({
|
|
1920
|
+
type: z.literal('ping'),
|
|
1921
|
+
});
|
|
1922
|
+
export const WSPongMessageSchema = z.object({
|
|
1923
|
+
type: z.literal('pong'),
|
|
1924
|
+
});
|
|
1925
|
+
export const WSHelloMessageSchema = z.object({
|
|
1926
|
+
type: z.literal('hello'),
|
|
1927
|
+
clientId: z.string().min(1),
|
|
1928
|
+
clientType: z.enum(['mobile', 'browser', 'cli', 'mcp']),
|
|
1929
|
+
protocolVersion: z.number().int(),
|
|
1930
|
+
capabilities: z
|
|
1931
|
+
.object({
|
|
1932
|
+
voice: z.boolean().optional(),
|
|
1933
|
+
pushNotifications: z.boolean().optional(),
|
|
1934
|
+
})
|
|
1935
|
+
.passthrough()
|
|
1936
|
+
.optional(),
|
|
1937
|
+
});
|
|
1938
|
+
export const WSWelcomeMessageSchema = z.object({
|
|
1939
|
+
type: z.literal('welcome'),
|
|
1940
|
+
serverId: z.string(),
|
|
1941
|
+
hostname: z.string().nullable(),
|
|
1942
|
+
version: z.string().nullable(),
|
|
1943
|
+
resumed: z.boolean(),
|
|
1944
|
+
capabilities: ServerCapabilitiesSchema.optional(),
|
|
1945
|
+
});
|
|
1946
|
+
export const WSRecordingStateMessageSchema = z.object({
|
|
1947
|
+
type: z.literal('recording_state'),
|
|
1948
|
+
isRecording: z.boolean(),
|
|
1949
|
+
});
|
|
1950
|
+
// Wrapped session message
|
|
1951
|
+
export const WSSessionInboundSchema = z.object({
|
|
1952
|
+
type: z.literal('session'),
|
|
1953
|
+
message: SessionInboundMessageSchema,
|
|
1954
|
+
});
|
|
1955
|
+
export const WSSessionOutboundSchema = z.object({
|
|
1956
|
+
type: z.literal('session'),
|
|
1957
|
+
message: SessionOutboundMessageSchema,
|
|
1958
|
+
});
|
|
1959
|
+
// Complete WebSocket message schemas
|
|
1960
|
+
export const WSInboundMessageSchema = z.discriminatedUnion('type', [
|
|
1961
|
+
WSPingMessageSchema,
|
|
1962
|
+
WSHelloMessageSchema,
|
|
1963
|
+
WSRecordingStateMessageSchema,
|
|
1964
|
+
WSSessionInboundSchema,
|
|
1965
|
+
]);
|
|
1966
|
+
export const WSOutboundMessageSchema = z.discriminatedUnion('type', [
|
|
1967
|
+
WSPongMessageSchema,
|
|
1968
|
+
WSWelcomeMessageSchema,
|
|
1969
|
+
WSSessionOutboundSchema,
|
|
1970
|
+
]);
|
|
1971
|
+
// ============================================================================
|
|
1972
|
+
// Helper functions for message conversion
|
|
1973
|
+
// ============================================================================
|
|
1974
|
+
/**
|
|
1975
|
+
* Extract session message from WebSocket message
|
|
1976
|
+
* Returns null if message should be handled at WS level only
|
|
1977
|
+
*/
|
|
1978
|
+
export function extractSessionMessage(wsMsg) {
|
|
1979
|
+
if (wsMsg.type === 'session') {
|
|
1980
|
+
return wsMsg.message;
|
|
1981
|
+
}
|
|
1982
|
+
// Ping and recording_state are WS-level only
|
|
1983
|
+
return null;
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Wrap session message in WebSocket envelope
|
|
1987
|
+
*/
|
|
1988
|
+
export function wrapSessionMessage(sessionMsg) {
|
|
1989
|
+
return {
|
|
1990
|
+
type: 'session',
|
|
1991
|
+
message: sessionMsg,
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
export function parseServerInfoStatusPayload(payload) {
|
|
1995
|
+
const parsed = ServerInfoStatusPayloadSchema.safeParse(payload);
|
|
1996
|
+
if (!parsed.success) {
|
|
1997
|
+
return null;
|
|
1998
|
+
}
|
|
1999
|
+
return parsed.data;
|
|
2000
|
+
}
|
|
2001
|
+
//# sourceMappingURL=messages.js.map
|