MCPcopy Create free account
hub / github.com/ChinaSiro/claude-code-sourcemap / e7Y

Function e7Y

package/cli.js:3435–3442  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3433- model - Override the default model. Available options:
3434${BK6().map((_)=>{return` - ${_.value===null?'null/"default"':`"${_.value}"`}: ${_.descriptionForModel??_.description}`}).join(`
3435`)}`}catch{return`## Model
3436- model - Override the default model (sonnet, opus, haiku, best, or full model ID)`}}var XJK="Get or set Claude Code configuration settings.";var WJK=y(()=>{I88();FK6();re1()});function DJK(q){if(!q.setting)return null;if(q.value===void 0)return OR.default.createElement(k,{dimColor:!0},"Getting ",q.setting);return OR.default.createElement(k,{dimColor:!0},"Setting ",q.setting," to ",g6(q.value))}function fJK(q){if(!q.success)return OR.default.createElement(s8,null,OR.default.createElement(k,{color:"error"},"Failed: ",q.error));if(q.operation==="get")return OR.default.createElement(s8,null,OR.default.createElement(k,null,OR.default.createElement(k,{bold:!0},q.setting)," = ",g6(q.value)));return OR.default.createElement(s8,null,OR.default.createElement(k,null,"Set ",OR.default.createElement(k,{bold:!0},q.setting)," to"," ",OR.default.createElement(k,{bold:!0},g6(q.newValue))))}function ZJK(){return OR.default.createElement(k,{color:"warning"},"Config change rejected")}var OR;var GJK=y(()=>{gK();s6();l8();OR=O6(D6(),1)});var se1={};T8(se1,{isVoiceStreamAvailable:()=>ae1,connectVoiceStream:()=>Sm8,FINALIZE_TIMEOUTS_MS:()=>oe1});function ae1(){if(!WJ())return!1;let q=Kq();return q!==null&&q.accessToken!==null}async function Sm8(q,K){await k$();let _=Kq();if(!_?.accessToken)return N("[voice_stream] No OAuth token available"),null;let z=process.env.VOICE_STREAM_BASE_URL||u7().BASE_API_URL.replace("https://","wss://").replace("http://","ws://");if(process.env.VOICE_STREAM_BASE_URL)N(`[voice_stream] Using VOICE_STREAM_BASE_URL override: ${process.env.VOICE_STREAM_BASE_URL}`);let Y=new URLSearchParams({encoding:"linear16",sample_rate:"16000",channels:"1",endpointing_ms:"300",utterance_end_ms:"1000",language:K?.language??"en"}),$=g8("tengu_cobalt_frost",!1);if($)Y.set("use_conversation_engine","true"),Y.set("stt_provider","deepgram-nova3"),N("[voice_stream] Nova 3 gate enabled (tengu_cobalt_frost)");if(K?.keyterms?.length)for(let T of K.keyterms)Y.append("keyterms",T);let A=`${z}${I7Y}?${Y.toString()}`;N(`[voice_stream] Connecting to ${A}`);let O={Authorization:`Bearer ${_.accessToken}`,"User-Agent":hS(),"x-app":"cli"},w=YV(),j=typeof Bun<"u"?{headers:O,proxy:NI(A),tls:w||void 0}:{headers:O,agent:VI(A),...w},H=new jf(A,j),J=null,M=!1,X=!1,P=!1,W=!1,D=null,f=null,G={send(T){if(H.readyState!==jf.OPEN)return;if(X){N(`[voice_stream] Dropping audio chunk after CloseStream: ${String(T.length)} bytes`);return}N(`[voice_stream] Sending audio chunk: ${String(T.length)} bytes`),H.send(Buffer.from(T))},finalize(){if(P||X)return Promise.resolve("ws_already_closed");return P=!0,new Promise((T)=>{let v=setTimeout(()=>D?.("safety_timeout"),oe1.safety),V=setTimeout(()=>D?.("no_data_timeout"),oe1.noData);if(f=()=>{clearTimeout(V),f=null},D=(E)=>{if(clearTimeout(v),clearTimeout(V),D=null,f=null,Z){N(`[voice_stream] Promoting unreported interim before ${E} resolve`);let S=Z;Z="",q.onTranscript(S,!0)}N(`[voice_stream] Finalize resolved via ${E}`),T(E)},H.readyState===jf.CLOSED||H.readyState===jf.CLOSING){D("ws_already_closed");return}setTimeout(()=>{if(X=!0,H.readyState===jf.OPEN)N("[voice_stream] Sending CloseStream (finalize)"),H.send(x7Y)},0)})},close(){if(X=!0,J)clearInterval(J),J=null;if(M=!1,H.readyState===jf.OPEN)H.close()},isConnected(){return M&&H.readyState===jf.OPEN}};H.on("open",()=>{N("[voice_stream] WebSocket connected"),M=!0,N("[voice_stream] Sending initial KeepAlive"),H.send(TJK),J=setInterval((T)=>{if(T.readyState===jf.OPEN)N("[voice_stream] Sending periodic KeepAlive"),T.send(TJK)},u7Y,H),q.onReady(G)});let Z="";return H.on("message",(T)=>{let v=T.toString();N(`[voice_stream] Message received (${String(v.length)} chars): ${v.slice(0,200)}`);let V;try{V=r8(v)}catch{return}switch(V.type){case"TranscriptText":{let E=V.data;if(N(`[voice_stream] TranscriptText: "${E??""}"`),X)f?.();if(E){if(!$&&Z){let S=Z.trimStart(),R=E.trimStart();if(S&&R&&!R.startsWith(S)&&!S.startsWith(R))N(`[voice_stream] Auto-finalizing previous segment (new segment detected): "${Z}"`),q.onTranscript(Z,!0)}Z=E,q.onTranscript(E,!1)}break}case"TranscriptEndpoint":{N(`[voice_stream] TranscriptEndpoint received, lastTranscriptText="${Z}"`);let E=Z;if(Z="",E)q.onTranscript(E,!0);if(X)D?.("post_closestream_endpoint");break}case"TranscriptError":{let E=V.description??V.error_code??"unknown transcription error";if(N(`[voice_stream] TranscriptError: ${E}`),!P)q.onError(E);break}case"error":{let E=V.message??g6(V);if(N(`[voice_stream] Server error: ${E}`),!P)q.onError(E);break}default:break}}),H.on("close",(T,v)=>{let V=v?.toString()??"";if(N(`[voice_stream] WebSocket closed: code=${String(T)} reason="${V}"`),M=!1,J)clearInterval(J),J=null;if(Z){N("[voice_stream] Promoting unreported interim transcript to final on close");let E=Z;Z="",q.onTranscript(E,!0)}if(D?.("ws_close"),!P&&!W&&T!==1000&&T!==1005)q.onError(`Connection closed: code ${String(T)}${V?` — ${V}`:""}`);q.onClose()}),H.on("unexpected-response",(T,v)=>{let V=v.statusCode??0;if(V===101){N("[voice_stream] unexpected-response fired with 101; ignoring");return}if(N(`[voice_stream] Upgrade rejected: status=${String(V)} cf-mitigated=${String(v.headers["cf-mitigated"])} cf-ray=${String(v.headers["cf-ray"])}`),W=!0,v.resume(),T.destroy(),P)return;q.onError(`WebSocket upgrade rejected with HTTP ${String(V)}`,{fatal:V>=400&&V<500})}),H.on("error",(T)=>{if(H6(T),N(`[voice_stream] WebSocket error: ${T.message}`),!P)q.onError(`Voice stream connection error: ${T.message}`)}),G}var TJK='{"type":"KeepAlive"}',x7Y='{"type":"CloseStream"}',I7Y="/api/ws/speech_to_text/voice_stream",u7Y=8000,oe1;var Cm8=y(()=>{W96();H3();G7();_8();jG();E8();PI();qv();l8();o1();oe1={safety:5000,noData:1500}});var kJK={};T8(kJK,{writeNativePlaybackData:()=>U7Y,stopNativeRecording:()=>B7Y,stopNativePlayback:()=>Q7Y,startNativeRecording:()=>p7Y,startNativePlayback:()=>F7Y,microphoneAuthorizationStatus:()=>c7Y,isNativeRecordingActive:()=>g7Y,isNativePlaying:()=>d7Y,isNativeAudioAvailable:()=>m7Y});function ha(){if(vJK)return m88;vJK=!0;let q=process.platform;if(q!=="darwin"&&q!=="linux"&&q!=="win32")return null;if(process.env.AUDIO_CAPTURE_NODE_PATH)try{return m88=U6(process.env.AUDIO_CAPTURE_NODE_PATH),m88}catch{}let K=`${process.arch}-${q}`,_=[`./vendor/audio-capture/${K}/audio-capture.node`,`../audio-capture/${K}/audio-capture.node`];for(let z of _)try{return m88=U6(z),m88}catch{}return null}function m7Y(){return ha()!==null}function p7Y(q,K){let _=ha();if(!_)return!1;return _.startRecording(q,K)}function B7Y(){let q=ha();if(!q)return;q.stopRecording()}function g7Y(){let q=ha();if(!q)return!1;return q.isRecording()}function F7Y(q,K){let _=ha();if(!_)return!1;return _.startPlayback(q,K)}function U7Y(q){let K=ha();if(!K)return;K.writePlaybackData(q)}function Q7Y(){let q=ha();if(!q)return;q.stopPlayback()}function d7Y(){let q=ha();if(!q)return!1;return q.isPlaying()}function c7Y(){let q=ha();if(!q||!q.microphoneAuthorizationStatus)return 0;return q.microphoneAuthorizationStatus()}var m88=null,vJK=!1;var VJK=()=>{};var SR6={};T8(SR6,{stopRecording:()=>hJK,startRecording:()=>RJK,requestMicrophonePermission:()=>t7Y,checkVoiceDependencies:()=>s7Y,checkRecordingAvailability:()=>e7Y,_resetArecordProbeForTesting:()=>r7Y,_resetAlsaCardsForTesting:()=>a7Y});import{spawn as K67,spawnSync as l7Y}from"child_process";import{readFile as n7Y}from"fs/promises";function bm8(){return NJK??=(async()=>{let q=Date.now(),K=await Promise.resolve().then(() => (VJK(),kJK));return K.isNativeAudioAvailable(),te1=K,N(`[voice] audio-capture-napi loaded in ${Date.now()-q}ms`),K})(),NJK}function Sa(q){return l7Y(q,["--version"],{stdio:"ignore",timeout:3000}).error===void 0}function EJK(){return ee1??=new Promise((q)=>{let K=K67("arecord",["-f","S16_LE","-r",String(_67),"-c",String(z67),"-t","raw","/dev/null"],{stdio:["ignore","ignore","pipe"]}),_="";K.stderr?.on("data",(Y)=>{_+=Y.toString()});let z=setTimeout((Y,$)=>{Y.kill("SIGTERM"),$({ok:!0,stderr:""})},150,K,q);K.once("close",(Y)=>{clearTimeout(z),q({ok:Y===0,stderr:_.trim()})}),K.once("error",()=>{clearTimeout(z),q({ok:!1,stderr:"arecord: command not found"})})}),ee1}function r7Y(){ee1=null}function o7Y(){return q67??=n7Y("/proc/asound/cards","utf8").then((q)=>{let K=q.trim();return K!==""&&!K.includes("no soundcards")},()=>!1),q67}function a7Y(){q67=null}function LJK(){if(process.platform==="darwin"){if(Sa("brew"))return{cmd:"brew",args:["install","sox"],displayCommand:"brew install sox"};return null}if(process.platform==="linux"){if(Sa("apt-get"))return{cmd:"sudo",args:["apt-get","install","-y","sox"],displayCommand:"sudo apt-get install sox"};if(Sa("dnf"))return{cmd:"sudo",args:["dnf","install","-y","sox"],displayCommand:"sudo dnf install sox"};if(Sa("pacman"))return{cmd:"sudo",args:["pacman","-S","--noconfirm","sox"],displayCommand:"sudo pacman -S sox"}}return null}async function s7Y(){if((await bm8()).isNativeAudioAvailable())return{available:!0,missing:[],installCommand:null};if(process.platform==="win32")return{available:!1,missing:["Voice mode requires the native audio module (not loaded)"],installCommand:null};if(process.platform==="linux"&&Sa("arecord"))return{available:!0,missing:[],installCommand:null};let K=[];if(!Sa("rec"))K.push("sox (rec command)");let _=K.length>0?LJK():null;return{available:K.length===0,missing:K,installCommand:_?.displayCommand??null}}async function t7Y(){if(!(await bm8()).isNativeAudioAvailable())return!0;if(await RJK((_)=>{},()=>{},{silenceDetection:!1}))return hJK(),!0;return!1}async function e7Y(){if(LT()||i6(process.env.CLAUDE_CODE_REMOTE))return{available:!1,reason:`Voice mode requires microphone access, but no audio device is available in this environment.
3437
3438To use voice mode, run Claude Code locally instead.`};if((await bm8()).isNativeAudioAvailable())return{available:!0,reason:null};if(process.platform==="win32")return{available:!1,reason:"Voice recording requires the native audio module, which could not be loaded."};let K=`Voice mode could not access an audio device in WSL.
3439
3440WSL2 with WSLg (Windows 11) provides audio via PulseAudio — if you are on Windows 10 or WSL1, run Claude Code in native Windows instead.`;if(process.platform==="linux"&&Sa("arecord")){let _=await EJK();if(_.ok)return{available:!0,reason:null};if(Z1()==="wsl")return{available:!1,reason:K};N(`[voice] arecord probe failed: ${_.stderr}`)}if(!Sa("rec")){if(Z1()==="wsl")return{available:!1,reason:K};let _=LJK();return{available:!1,reason:_?`Voice mode requires SoX for audio recording. Install it with: ${_.displayCommand}`:`Voice mode requires SoX for audio recording. Install SoX manually:
3441 macOS: brew install sox
3442 Ubuntu/Debian: sudo apt-get install sox
3443 Fedora: sudo dnf install sox`}}return{available:!0,reason:null}}async function RJK(q,K,_){N(`[voice] startRecording called, platform=${process.platform}`);let z=await bm8(),Y=z.isNativeAudioAvailable()&&(process.platform!=="linux"||await o7Y()),$=_?.silenceDetection!==!1;if(Y){if(hR6||z.isNativeRecordingActive())z.stopNativeRecording(),hR6=!1;if(z.startNativeRecording((O)=>{q(O)},()=>{if($)hR6=!1,K()}))return hR6=!0,!0}if(process.platform==="win32")return N("[voice] Windows native recording unavailable, no fallback"),!1;if(process.platform==="linux"&&Sa("arecord")&&(await EJK()).ok)return KqY(q,K);return qqY(q,K,_)}function qqY(q,K,_){let z=_?.silenceDetection!==!1,Y=["-q","--buffer","1024","-t","raw","-r",String(_67),"-e","signed","-b","16","-c",String(z67),"-"];if(z)Y.push("silence","1","0.1",yJK,"1",i7Y,yJK);let $=K67("rec",Y,{stdio:["pipe","pipe","pipe"]});return Ca=$,$.stdout?.on("data",(A)=>{q(A)}),$.stderr?.on("data",()=>{}),$.on("close",()=>{Ca=null,K()}),$.on("error",(A)=>{H6(A),Ca=null,K()}),!0}function KqY(q,K){let _=["-f","S16_LE","-r",String(_67),"-c",String(z67),"-t","raw","-q","-"],z=K67("arecord",_,{stdio:["pipe","pipe","pipe"]});return Ca=z,z.stdout?.on("data",(Y)=>{q(Y)}),z.stderr?.on("data",()=>{}),z.on("close",()=>{Ca=null,K()}),z.on("error",(Y)=>{H6(Y),Ca=null,K()}),!0}function hJK(){if(hR6&&te1){te1.stopNativeRecording(),hR6=!1;return}if(Ca)Ca.kill("SIGTERM"),Ca=null}var te1=null,NJK=null,_67=16000,z67=1,i7Y="2.0",yJK="3%",ee1=null,q67=null,Ca=null,hR6=!1;var CR6=y(()=>{_8();m8();E8();vK()});function CJK(q,K){if(q==="global"){let Y=j8(),$=K[0];if(!$)return;return Y[$]}let z=N7();for(let Y of K)if(z&&typeof z==="object"&&Y in z)z=z[Y];else return;return z}function bJK(q,K){if(q.length===0)return{};let _=q[0];if(q.length===1)return{[_]:K};return{[_]:bJK(q.slice(1),K)}}var _qY,zqY,xfw;var xJK=y(()=>{x7();k8();Bq();V1();y8();E8();U1();l8();WJK();re1();GJK();_qY=B6(()=>L.strictObject({setting:L.string().describe('The setting key (e.g., "theme", "model", "permissions.defaultMode")'),value:L.union([L.string(),L.boolean(),L.number()]).optional().describe("The new value. Omit to get current value.")})),zqY=B6(()=>L.object({success:L.boolean(),operation:L.enum(["get","set"]).optional(),setting:L.string().optional(),value:L.unknown().optional(),previousValue:L.unknown().optional(),newValue:L.unknown().optional(),error:L.string().optional()})),xfw=sq({name:qJK,searchHint:"get or set Claude Code settings (theme, model)",maxResultSizeChars:1e5,async description(){return XJK},async prompt(){return PJK()},get inputSchema(){return _qY()},get outputSchema(){return zqY()},userFacingName(){return"Config"},shouldDefer:!0,isConcurrencySafe(){return!0},isReadOnly(q){return q.value===void 0},toAutoClassifierInput(q){return q.value===void 0?q.setting:`${q.setting} = ${q.value}`},async checkPermissions(q){if(q.value===void 0)return{behavior:"allow",updatedInput:q};return{behavior:"ask",message:`Set ${q.setting} to ${g6(q.value)}`}},renderToolUseMessage:DJK,renderToolResultMessage:fJK,renderToolUseRejectedMessage:ZJK,async call({setting:q,value:K},_){if(q==="voiceEnabled"){let{isVoiceGrowthBookEnabled:w}=await Promise.resolve().then(() => (FK6(),ie1));if(!w())return{data:{success:!1,error:`Unknown setting: "${q}"`}}}if(!HJK(q))return{data:{success:!1,error:`Unknown setting: "${q}"`}};let z=JJK(q),Y=MJK(q);if(K===void 0){let w=CJK(z.source,Y),j=z.formatOnRead?z.formatOnRead(w):w;return{data:{success:!0,operation:"get",setting:q,value:j}}}if(q==="remoteControlAtStartup"&&typeof K==="string"&&K.toLowerCase().trim()==="default"){b8((j)=>{if(j.remoteControlAtStartup===void 0)return j;let H={...j};return delete H.remoteControlAtStartup,H});let w=$F();return _.setAppState((j)=>{if(j.replBridgeEnabled===w&&!j.replBridgeOutboundOnly)return j;return{...j,replBridgeEnabled:w,replBridgeOutboundOnly:!1}}),{data:{success:!0,operation:"set",setting:q,value:w}}}let $=K;if(z.type==="boolean"){if(typeof K==="string"){let w=K.toLowerCase().trim();if(w==="true")$=!0;else if(w==="false")$=!1}if(typeof $!=="boolean")return{data:{success:!1,operation:"set",setting:q,error:`${q} requires true or false.`}}}let A=hm8(q);if(A&&!A.includes(String($)))return{data:{success:!1,operation:"set",setting:q,error:`Invalid value "${K}". Options: ${A.join(", ")}`}};if(z.validateOnWrite){let w=await z.validateOnWrite($);if(!w.valid)return{data:{success:!1,operation:"set",setting:q,error:w.error}}}if(q==="voiceEnabled"&&$===!0){let{isVoiceModeEnabled:w}=await Promise.resolve().then(() => (FK6(),ie1));if(!w()){let{isAnthropicAuthEnabled:W}=await Promise.resolve().then(() => (G7(),_L));return{data:{success:!1,error:!W()?"Voice mode requires a Claude.ai account. Please run /login to sign in.":"Voice mode is not available."}}}let{isVoiceStreamAvailable:j}=await Promise.resolve().then(() => (Cm8(),se1)),{checkRecordingAvailability:H,checkVoiceDependencies:J,requestMicrophonePermission:M}=await Promise.resolve().then(() => (CR6(),SR6)),X=await H();if(!X.available)return{data:{success:!1,error:X.reason??"Voice mode is not available in this environment."}};if(!j())return{data:{success:!1,error:"Voice mode requires a Claude.ai account. Please run /login to sign in."}};let P=await J();if(!P.available)return{data:{success:!1,error:"No audio recording tool found."+(P.installCommand?` Run: ${P.installCommand}`:"")}};if(!await M()){let W;if(process.platform==="win32")W="Settings → Privacy → Microphone";else if(process.platform==="linux")W="your system's audio settings";else W="System Settings → Privacy & Security → Microphone";return{data:{success:!1,error:`Microphone access is denied. To enable it, go to ${W}, then try again.`}}}}let O=CJK(z.source,Y);try{if(z.source==="global"){let w=Y[0];if(!w)return{data:{success:!1,operation:"set",setting:q,error:"Invalid setting path"}};b8((j)=>{if(j[w]===$)return j;return{...j,[w]:$}})}else{let w=bJK(Y,$),j=W7("userSettings",w);if(j.error)return{data:{success:!1,operation:"set",setting:q,error:j.error.message}}}if(q==="voiceEnabled"){let{settingsChangeDetector:w}=await Promise.resolve().then(() => (NF(),m74));w.notifyChange("userSettings")}if(z.appStateKey){let w=z.appStateKey;_.setAppState((j)=>{if(j[w]===$)return j;return{...j,[w]:$}})}if(q==="remoteControlAtStartup"){let w=$F();_.setAppState((j)=>{if(j.replBridgeEnabled===w&&!j.replBridgeOutboundOnly)return j;return{...j,replBridgeEnabled:w,replBridgeOutboundOnly:!1}})}return d("tengu_config_tool_changed",{setting:q,value:String($)}),{data:{success:!0,operation:"set",setting:q,previousValue:O,newValue:$}}}catch(w){return H6(w),{data:{success:!1,operation:"set",setting:q,error:d6(w)}}}},mapToolResultToToolResultBlockParam(q,K){if(q.success){if(q.operation==="get")return{tool_use_id:K,type:"tool_result",content:`${q.setting} = ${g6(q.value)}`};return{tool_use_id:K,type:"tool_result",content:`Set ${q.setting} to ${g6(q.newValue)}`}}return{tool_use_id:K,type:"tool_result",content:`Error: ${q.error}`,is_error:!0}}})});function uJK(){let q=nq()?" and potentially assigned to teammates":"",K=nq()?"- Include enough detail in the description for another agent to understand and complete the task\n- New tasks are created with status 'pending' and no owner - use TaskUpdate with the `owner` parameter to assign them\n":"";return`Use this tool to create a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
3444It also helps the user understand the progress of the task and overall progress of their requests.
3445

Callers

nothing calls this directly

Calls 7

LTFunction · 0.85
i6Function · 0.85
bm8Function · 0.85
SaFunction · 0.85
EJKFunction · 0.85
NFunction · 0.85
LJKFunction · 0.85

Tested by

no test coverage detected