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

Function uJK

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

Source from the content-addressed store, hash-verified

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
3446## When to Use This Tool
3447
3448Use this tool proactively in these scenarios:
3449
3450- Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
3451- Non-trivial and complex tasks - Tasks that require careful planning or multiple operations${q}
3452- Plan mode - When using plan mode, create a task list to track the work
3453- User explicitly requests todo list - When the user directly asks you to use the todo list
3454- User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
3455- After receiving new instructions - Immediately capture user requirements as tasks
3456- When you start working on a task - Mark it as in_progress BEFORE beginning work
3457- After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
3458
3459## When NOT to Use This Tool
3460
3461Skip using this tool when:
3462- There is only a single, straightforward task
3463- The task is trivial and tracking it provides no organizational benefit
3464- The task can be completed in less than 3 trivial steps
3465- The task is purely conversational or informational
3466
3467NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
3468
3469## Task Fields
3470
3471- **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
3472- **description**: What needs to be done
3473- **activeForm** (optional): Present continuous form shown in the spinner when the task is in_progress (e.g., "Fixing authentication bug"). If omitted, the spinner shows the subject instead.
3474
3475All tasks are created with status \`pending\`.
3476
3477## Tips
3478
3479- Create tasks with clear, specific subjects that describe the outcome
3480- After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
3481${K}- Check TaskList first to avoid creating duplicate tasks
3482`}var IJK="Create a new task in the task list";var mJK=y(()=>{i$()});var YqY,$qY,pJK;var BJK=y(()=>{x7();Bq();y$();gj();AY();mJK();YqY=B6(()=>L.strictObject({subject:L.string().describe("A brief title for the task"),description:L.string().describe("What needs to be done"),activeForm:L.string().optional().describe('Present continuous form shown in spinner when in_progress (e.g., "Running tests")'),metadata:L.record(L.string(),L.unknown()).optional().describe("Arbitrary metadata to attach to the task")})),$qY=B6(()=>L.object({task:L.object({id:L.string(),subject:L.string()})})),pJK=sq({name:TN,searchHint:"create a task in the task list",maxResultSizeChars:1e5,async description(){return IJK},async prompt(){return uJK()},get inputSchema(){return YqY()},get outputSchema(){return $qY()},userFacingName(){return"TaskCreate"},shouldDefer:!0,isEnabled(){return IH()},isConcurrencySafe(){return!0},toAutoClassifierInput(q){return q.subject},renderToolUseMessage(){return null},async call({subject:q,description:K,activeForm:_,metadata:z},Y){let $=await u1K(cG(),{subject:q,description:K,activeForm:_,status:"pending",owner:void 0,blocks:[],blockedBy:[],metadata:z}),A=[],O=$67($,q,K,M_(),$9(),void 0,Y?.abortController?.signal,void 0,Y);for await(let w of O)if(w.blockingError)A.push(Y67(w.blockingError));if(A.length>0)throw await vC8(cG(),$),Error(A.join(`
3483`));return Y.setAppState((w)=>{if(w.expandedView==="tasks")return w;return{...w,expandedView:"tasks"}}),{data:{task:{id:$,subject:q}}}},mapToolResultToToolResultBlockParam(q,K){let{task:_}=q;return{tool_use_id:K,type:"tool_result",content:`Task #${_.id} created successfully: ${_.subject}`}}})});var gJK="Get a task by ID from the task list",FJK=`Use this tool to retrieve a task by its ID from the task list.
3484

Callers 1

promptFunction · 0.85

Calls 1

nqFunction · 0.85

Tested by

no test coverage detected