Files
clawtap/server/ws-types.ts
T
kuannnn 0fcf66fc22 feat: ClawTap v0.2.0
Interactive Prompts:
- Unified InteractivePrompt type across all 3 adapters (Claude/Codex/Gemini)
- InteractivePromptOverlay component with options, text input, countdown
- Gemini + Codex pane monitors detect tool confirmation, ask user, plan approval
- respondInteractivePrompt routing: permission → respondPermission, options → _selectOption
- Claude AskUserQuestion nested questions[0] structure parsing

Cross-AI Review:
- Client-generated reviewId, removed pendingReview state
- FloatingReviewPanel uses CSS display:none instead of unmount (keeps hooks alive)
- Child review sessions default to YOLO/bypass permission mode
- Send back to parent, send to existing/new review, tab switching, end review
- Collapsed review cards with read-only panel for ended reviews
- Full reconnect support: active + ended reviews restore correctly

AskUserQuestion Tool Card UI:
- Dedicated renderer replaces raw JSON display
- Options shown with selected (green) / unselected (gray) indicators
- Free text answers shown in quoted format with green border
- Collapsed summary: question → answer
- Shared parseAskQuestionInput utility (client + server)
- Historical tool results attached via _result on tool_use blocks

Adapter Fixes:
- Session→adapter mapping persisted in SQLite (survives server restart)
- SESSION_CREATED deferred for pendingRekey adapters (Codex/Gemini)
- session-rekeyed handler sends complete SESSION_CREATED with adapter + cwd
- Gemini: auto-accept folder trust, privacy notice, IDE nudge, YOLO * prompt
- Claude: auto-accept bypass permissions confirmation (v2.1.85+)
- Port fallback (EADDRINUSE → try +1), statusLine shell script wrapper

Other:
- Desktop Enter sends / Shift+Enter newline; Mobile Enter newline
- Strip CLAWTAP_REF marker from session list
- Active sessions tab shows adapter badge
- Rename CLAUDE_UI_PASSWORD → CLAWTAP_PASSWORD

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 14:46:00 +08:00

56 lines
1.7 KiB
TypeScript

export const WS = {
// Client → Server
QUERY: 'query',
PERMISSION_RESPONSE: 'permission-response',
ASK_RESPONSE: 'ask-response',
ABORT: 'abort',
RECONNECT: 'reconnect',
SET_PERMISSION_MODE: 'set-permission-mode',
SET_MODEL: 'set-model',
PLAN_RESPONSE: 'plan-response',
// Server → Client
SESSION_STATE: 'session-state',
SESSION_CREATED: 'session-created',
TEXT_DELTA: 'text-delta',
THINKING: 'thinking',
TOOL_START: 'tool-start',
TOOL_DONE: 'tool-done',
MESSAGE_COMPLETE: 'message-complete',
TOOL_UPDATES: 'tool-updates',
TURN_COMPLETE: 'turn-complete',
PERMISSION_REQUEST: 'permission-request',
PERMISSION_DISMISSED: 'permission-dismissed',
HISTORY_LOAD: 'history-load',
STATUS_UPDATE: 'status-update',
MODE_UPDATED: 'mode-updated',
COMPACTING: 'compacting',
COMPACT_DONE: 'compact-done',
SESSION_ERROR: 'session-error',
SESSION_ENDED: 'session-ended',
CLIENT_ID: 'client-id',
PENDING_NOTIFICATIONS: 'pending-notifications',
ERROR: 'error',
// Interactive Prompts (unified permission/question/plan overlay)
INTERACTIVE_PROMPT: 'interactive-prompt',
PROMPT_RESPONSE: 'prompt-response',
PROMPT_DISMISSED: 'prompt-dismissed',
// Cross-AI Review
REVIEW_STARTED: 'review-started',
REVIEW_ENDED: 'review-ended',
} as const;
export type WsType = typeof WS[keyof typeof WS];
/**
* CLI plan approval selector option indices (ExitPlanMode).
* Claude Code v2.1.x shows 3 options:
* 0: "Yes, auto-accept edits" → BYPASS
* 1: "Yes, manually approve edits" → MANUALLY_APPROVE
* 2: "Type here to tell Claude what to change" → TEXT_FEEDBACK
*/
export const PLAN_OPTION = {
BYPASS: 0,
MANUALLY_APPROVE: 1,
TEXT_FEEDBACK: 2,
} as const;