@linzumi/cli 1.0.210 → 1.0.212

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.
@@ -1556,7 +1556,7 @@ To kick the agent off:
1556
1556
  `,M=Buffer.byteLength(I,"utf8");if(M>s)return l("runner_diagnostics.spool_entry_dropped",{reason:"entry_too_large",entry_bytes:M,max_entry_bytes:s}),!1;M1e(n,{recursive:!0}),f(u)+M>i&&h(),_(M);let E=b()?`
1557
1557
  `:"";return R1e(u,`${E}${I}`,"utf8"),!0}catch(T){return l("runner_diagnostics.spool_failed",{error:T instanceof Error?T.message:String(T)}),!1}},v=S=>{let T=[],I=O1e(S,"utf8");for(let M of I.split(`
1558
1558
  `))if(M.trim()!=="")try{let E=JSON.parse(M);E!==null&&typeof E=="object"&&T.push({parsed:E,raw:M})}catch{}return T};return{append:w,drain:async S=>{if(c)return{uploadedBatches:0,uploadedEntries:0,remainingBatches:p().length,skipped:!0};c=!0;let T=0,I=0;try{h(),_(0);let M=a()-o;for(let E of p()){let $;try{$=v(E)}catch(V){l("runner_diagnostics.spool_batch_unreadable",{file:E,error:V instanceof Error?V.message:String(V)}),m(E,"unreadable");continue}let K=$.filter(V=>{let Z=Q1e(V.parsed);return Z===void 0||Z>=M});if(K.length===0){m(E,"empty_or_expired");continue}let G=IA(E,".jsonl"),H=K.map(V=>V.raw).join(`
1559
- `),ee=K.map(V=>V.parsed.spooled_at).filter(V=>typeof V=="string"),q={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:G,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:G,entry_count:K.length,...ee.length===0?{}:{first_spooled_at:ee[0],last_spooled_at:ee[ee.length-1]}},telemetry_ndjson:H};try{await S(q)}catch(V){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:V instanceof Error?V.message:String(V)});break}T+=1,I+=K.length;try{TW(E)}catch(V){l("runner_diagnostics.spool_delete_failed",{file:E,error:V instanceof Error?V.message:String(V)})}}}catch(M){l("runner_diagnostics.spool_drain_failed",{error:M instanceof Error?M.message:String(M)})}finally{c=!1}return{uploadedBatches:T,uploadedEntries:I,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var N1e,z1e,U1e,B1e,J1e,PW,V1e,W1e,RW=z(()=>{"use strict";Yb();N1e=32*1024*1024,z1e=10080*60*1e3,U1e=4*1024*1024,B1e=1024*1024,J1e="spool.jsonl",PW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;V1e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,W1e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var sr,EA,od=z(()=>{"use strict";sr="1.0.210",EA=`linzumi ${sr}`});import{closeSync as AW,existsSync as MA,mkdirSync as X1e,openSync as MW,readFileSync as DW,renameSync as Y1e,unlinkSync as Fu,writeFileSync as e2e,writeSync as OW}from"node:fs";import{dirname as $W,join as n2e}from"node:path";function DA(e){return e instanceof ua||e instanceof Error&&e.name===jW&&"lockPath"in e&&"heldBy"in e}function OA(e,n=pt(),t){let r=t===void 0?encodeURIComponent(e):Ru(t);return n2e($W(n),"runners",`${r}.lock`)}function gw(e){let n=OA(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??JW,r=e.now??(()=>new Date),o=e.killPid??m2e,i=r().toISOString(),s={version:1,machineId:e.machineId,runnerId:e.runnerId,pid:e.pid??process.pid,cwd:e.cwd,workspace:e.workspace,...e.linzumiUrl===void 0?{}:{linzumiUrl:nt(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??sr,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};i2e(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),s2e(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>FW(n,s,r),d=setInterval(a,qW);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),UW(n,s)}}}function FW(e,n,t){try{let r=_w(e);if(r===void 0||r.machineId!==n.machineId||r.runnerId!==n.runnerId||r.pid!==n.pid||r.startedAt!==n.startedAt)return;let o={...r,heartbeatAt:t().toISOString()},i=`${e}.tmp`;e2e(i,`${JSON.stringify(o,null,2)}
1559
+ `),ee=K.map(V=>V.parsed.spooled_at).filter(V=>typeof V=="string"),q={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:G,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:G,entry_count:K.length,...ee.length===0?{}:{first_spooled_at:ee[0],last_spooled_at:ee[ee.length-1]}},telemetry_ndjson:H};try{await S(q)}catch(V){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:V instanceof Error?V.message:String(V)});break}T+=1,I+=K.length;try{TW(E)}catch(V){l("runner_diagnostics.spool_delete_failed",{file:E,error:V instanceof Error?V.message:String(V)})}}}catch(M){l("runner_diagnostics.spool_drain_failed",{error:M instanceof Error?M.message:String(M)})}finally{c=!1}return{uploadedBatches:T,uploadedEntries:I,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var N1e,z1e,U1e,B1e,J1e,PW,V1e,W1e,RW=z(()=>{"use strict";Yb();N1e=32*1024*1024,z1e=10080*60*1e3,U1e=4*1024*1024,B1e=1024*1024,J1e="spool.jsonl",PW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;V1e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,W1e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var sr,EA,od=z(()=>{"use strict";sr="1.0.212",EA=`linzumi ${sr}`});import{closeSync as AW,existsSync as MA,mkdirSync as X1e,openSync as MW,readFileSync as DW,renameSync as Y1e,unlinkSync as Fu,writeFileSync as e2e,writeSync as OW}from"node:fs";import{dirname as $W,join as n2e}from"node:path";function DA(e){return e instanceof ua||e instanceof Error&&e.name===jW&&"lockPath"in e&&"heldBy"in e}function OA(e,n=pt(),t){let r=t===void 0?encodeURIComponent(e):Ru(t);return n2e($W(n),"runners",`${r}.lock`)}function gw(e){let n=OA(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??JW,r=e.now??(()=>new Date),o=e.killPid??m2e,i=r().toISOString(),s={version:1,machineId:e.machineId,runnerId:e.runnerId,pid:e.pid??process.pid,cwd:e.cwd,workspace:e.workspace,...e.linzumiUrl===void 0?{}:{linzumiUrl:nt(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??sr,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};i2e(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),s2e(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>FW(n,s,r),d=setInterval(a,qW);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),UW(n,s)}}}function FW(e,n,t){try{let r=_w(e);if(r===void 0||r.machineId!==n.machineId||r.runnerId!==n.runnerId||r.pid!==n.pid||r.startedAt!==n.startedAt)return;let o={...r,heartbeatAt:t().toISOString()},i=`${e}.tmp`;e2e(i,`${JSON.stringify(o,null,2)}
1560
1560
  `,"utf8"),Y1e(i,e)}catch{}}function Lu(e,n,t){if(!n(e.pid))return{state:"dead"};let r=e.heartbeatAt??e.startedAt,o=Date.parse(r);return Number.isNaN(o)||t().getTime()-o>t2e?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function LW(e,n,t,r){return t!==yw||e.launchSource!==yw?!1:r.state!=="live"?!0:r2e(n,e.cliVersion)>0}function r2e(e,n){let t=EW(e),r=EW(n);for(let o=0;o<3;o++){let i=t.core[o],s=r.core[o];if(i===void 0||s===void 0)throw new Error(`compareCliVersions: unexpected undefined at core index ${o}`);if(i!==s)return i>s?1:-1}return t.prerelease.length===0&&r.prerelease.length===0?0:t.prerelease.length===0?1:r.prerelease.length===0?-1:o2e(t.prerelease,r.prerelease)}function EW(e){let n=e.trim().replace(/^v/i,"").split("+",1)[0]??"",t=n.indexOf("-"),r=t===-1?n:n.slice(0,t),o=t===-1?"":n.slice(t+1),i=r.split("."),s=[AA(i[0]),AA(i[1]),AA(i[2])],a=o===""?[]:o.split(".").filter(d=>d!=="");return{core:s,prerelease:a}}function AA(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function o2e(e,n){let t=Math.max(e.length,n.length);for(let r=0;r<t;r++){let o=e[r],i=n[r];if(o===void 0)return-1;if(i===void 0)return 1;let s=Number.parseInt(o,10),a=Number.parseInt(i,10),d=s.toString()===o,u=a.toString()===i;if(d&&u){if(s!==a)return s>a?1:-1}else{if(d!==u)return d?-1:1;if(o!==i)return o>i?1:-1}}return 0}function NW(e,n,t,r,o){try{r(n.pid)}catch(i){let s=i!==null&&typeof i=="object"&&"code"in i?i.code:void 0;if(s!=="ESRCH")throw s==="EPERM"||s==="EACCES"?new Error(`Cannot take over the runner lock at ${e}: its holder process (pid ${n.pid}) is owned by another user and cannot be stopped. Stop that process, or remove the lock file, then retry.`):i}o?.({lockPath:e,holderPid:n.pid,holderRunnerId:n.runnerId,reason:t})}function i2e(e,n,t,r,o,i,s){if(t===void 0||zr(t)!==zr(yr))return;let a=OA(e,n),d=_w(a);if(d!==void 0){if(Lu(d,r,o).state==="live")throw new ua(a,d);zW(a,r,()=>{let u=MA(a)?$A(a):void 0;if(u===void 0)return;let c=Lu(u,r,o);if(c.state==="live")throw new ua(a,u);c.state==="wedged"&&NW(a,u,c.reason,i,s),Fu(a)})}}function s2e(e,n,t,r,o,i,s,a){if(hw(e,n))return;s?.();let d=_w(e);if(d===void 0){if(hw(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(Lu(d,t,r).state==="live")throw new ua(e,d);a?.(),zW(e,t,()=>{let u=MA(e)?$A(e):void 0;if(u!==void 0){let c=Lu(u,t,r);if(c.state==="live")throw new ua(e,u);c.state==="wedged"&&NW(e,u,c.reason,o,i),Fu(e)}if(!hw(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function hw(e,n){X1e($W(e),{recursive:!0});try{let t=MW(e,"wx");try{OW(t,`${JSON.stringify(n,null,2)}
1561
1561
  `)}finally{AW(t)}return!0}catch(t){if(Tp(t,"EEXIST"))return!1;throw t}}function zW(e,n,t){let r=`${e}.replace`;for(;;)try{let o=MW(r,"wx");try{OW(o,`${process.pid}
1562
1562
  `),t()}finally{AW(o),Fu(r)}return}catch(o){if(Tp(o,"EEXIST")){let i=a2e(r);if(i===void 0)continue;if(n(i))throw new Error(["another Linzumi runner is already replacing a stale runner lock",`lock: ${e}`,"Wait for that startup to finish, then retry."].join(`
@@ -2179,7 +2179,7 @@ Tools:
2179
2179
  Auth:
2180
2180
  Uses --token, LINZUMI_MCP_ACCESS_TOKEN, or cached local runner OAuth from linzumi auth.
2181
2181
  Hosted personal agents use --delegation-auth-file with a signed delegation grant.
2182
- `}async function dWe(e){let n=fq(e);if(n.get("help")===!0){process.stdout.write(Pie());return}let t=hq(n,"api-url"),r=await pq({kandanUrl:t,explicitToken:ot(n,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:ot(n,"auth-file"),delegationAuthFilePath:ot(n,"delegation-auth-file"),workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")}),o=ot(n,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,i=mq(ot(n,"mode")),s=Iie(ot(n,"tool-scope")),a=ot(n,"cwd")??process.cwd(),d=ot(n,"thread-id")??process.env.LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID,u=ms({kandanUrl:t,accessToken:r.accessToken,authMode:r.mode,operatingMode:i}),c=new WS({name:"linzumi",version:"0.1.0"});_We(c),lWe(c,{client:u,toolScope:s,operatingMode:i,cwd:a,kandanUrl:t,defaultThreadId:d,ownerUsername:o,agentSession:n.get("agent-session")===!0,documentSurfaces:im(r.accessToken),askUserQuestionTool:n.get("ask-user-question-tool")===!0,devServices:cWe(process.env),multiAgentJobs:n.get("multi-agent-jobs")===!0}),await c.connect(new HS)}var xie="One or two sentences a teammate skimming the board would want: what changed, and what happens next. Standup register, present tense, name agents and lanes plainly. No thread ids or UUIDs unless needed for lookup; proofs and evidence belong in the thread, not here. Good: 'Retired the silent watchdog and spawned Thorne to replace it \u2014 running lean at three children.' Bad: 'Broken 67f1d639 archived abandoned; board claim preceded spawn; children verified at exactly 3.'",uWe=new Intl.Segmenter("en",{granularity:"grapheme"}),bie=R.string().min(1).refine(e=>Array.from(uWe.segment(e)).length<=240,{message:"status_note over 240 chars \u2014 trim to what a reader needs; put evidence in the thread."});function cWe(e){let n=e.LINZUMI_DEV_SERVICES_SCOPE?.trim(),t=Number.parseInt(e.LINZUMI_DEV_SERVICES_OWNER_PID??"",10);if(!(n===void 0||n===""||!Number.isInteger(t)||t<=0))return{scopeDir:lu(n),ownerPid:t}}function lWe(e,n){let{client:t,toolScope:r,operatingMode:o,cwd:i,kandanUrl:s,defaultThreadId:a,ownerUsername:d,agentSession:u,devServices:c}=n,l=r==="all"||r==="coding";if(n.askUserQuestionTool===!0&&e.tool(oU,`Ask the user up to ${Fm} structured multiple-choice questions and BLOCK until they answer in the Linzumi thread. Use this whenever you need a decision or clarification mid-task. Each question needs a short header (max ${Lm} chars) and ${Nm}-${zm} options {label, description}; a built-in "${Bm}" free-text choice is always shown in addition to your options, so never add one yourself. Set multiSelect true to allow choosing several options. Returns {answers} keyed by question text: a single label string, an array of labels for multiSelect, and {"other": "<typed text>"} for a free-text reply.`,{questions:R.array(R.object({question:R.string().describe("The question to ask the user."),header:R.string().describe(`Short category header shown above the question (max ${Lm} chars, e.g. "Auth", "Scope").`),options:R.array(R.object({label:R.string().describe("Option label the user taps."),description:R.string().optional().describe("One-line explanation of the option.")})).describe(`${Nm}-${zm} options for this question.`),multiSelect:R.boolean().optional().describe("True lets the user select several options; the answer becomes an array.")})).describe(`1-${Fm} questions to ask atomically.`)},async p=>wWe((f,h)=>e.server.elicitInput(f,h),p)),n.documentSurfaces===!0){let p=async(f,h)=>je(await t.agentDocumentTool({...h,tool:f}));e.tool("linzumi_lookup_documents","Search document titles and content within the controlling human's visibility ceiling. Returns authorized results in canonical search order; zero, one, and multiple matches carry the rule-03 ambiguity meaning.",{query:R.string().min(1).describe("Document title or content search query.")},async f=>p("lookup_documents",f)),e.tool("linzumi_read_document","Read one in-scope document as full AST and metadata, including pending proposals and required-agent-context comments. Both controlling-human visibility and agent delegation are required.",{document_id:R.string().uuid().describe("Document UUID.")},async f=>p("read_document",f)),u?(e.tool("linzumi_append_document_section","Use this tool for append-shaped document requests: add or append a new section, or add or update a tracker row as new section content, including parent-delegated work. After resolving exactly one patch target document and reading it, call this tool in the same turn; do not merely reply with suggested prose. Other authorized context documents do not make the patch target ambiguous. Supply only the heading and body Markdown: the server composes the closed structural operations. Every change is proposal-always.",{document_id:R.string().uuid().describe("Document UUID."),heading:R.string().trim().min(1).describe("Section heading."),body_markdown:R.string().trim().min(1).describe("Section body as Markdown authored by the model.")},async f=>p("append_document_section",f)),e.tool("linzumi_replace_section","Use this tool for targeted section rewrites, fixes, and tightening. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply the replacement body Markdown. The server rejects missing and ambiguous headings with actionable typed errors and composes the closed structural operations. Every change is proposal-always.",{document_id:R.string().uuid().describe("Document UUID."),heading_or_section_ref:R.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document."),body_markdown:R.string().trim().min(1).describe("Replacement section body as Markdown.")},async f=>p("replace_section",f)),e.tool("linzumi_decline_document_action","Decline the current document action when neither advertised document intent can express it. Give a clear reason; the server relays it verbatim with an honest decline prefix and satisfies the action binding.",{reason:R.string().refine(f=>f.trim().length>0,{message:"Reason must contain non-whitespace text."}).describe("Clear reason the available document intents cannot express the request.")},async f=>je(await t.declineDocumentAction({reason:f.reason})))):e.tool("linzumi_propose_document_patch","Submit a raw revisioned structural document patch. This power/API surface requires the caller to compose the closed operation vocabulary. Create a native data-bound table with the atomic create_bound_table operation containing bindingId, block, and binding; rows remain source data and must not be copied into the block. Every change is proposal-always.",{document_id:R.string().uuid().describe("Document UUID."),patch:R.object({baseRevision:R.number().int().nonnegative(),operations:R.array(R.record(R.unknown())),title:R.string().min(1).optional()}).describe("Revisioned structural document patch."),rationale:R.string().min(1).describe("Why this change is proposed.")},async f=>p("propose_document_patch",f)),u||e.tool("linzumi_create_document","Create an agent-attributed document through an atomic bootstrap proposal and apply transaction in the named folder or workspace default folder.",{title:R.string().min(1).describe("Document title."),initial_patch:R.record(R.unknown()).describe("Bootstrap structural patch."),folder_id:R.string().uuid().optional().describe("Destination folder UUID.")},async f=>p("create_document",f))}if(u){e.tool("linzumi_agent_reply","Post your single @linzumi reply for the current turn into the surface where you were mentioned. Call EXACTLY ONCE per turn with your final answer; the reply links to this working session automatically. Fails with already_replied on a second call and no_active_asker_binding when no turn is active.",{body:R.string().min(1).describe("Plain-text reply body to post."),tokens:Oc.optional()},async f=>je(await t.agentReply({body:f.body,...f.tokens===void 0?{}:{tokens:f.tokens}})));let p=async(f,h)=>je(await t.agentTopicTool({...h,tool:f}));e.tool("linzumi_create_topic_wake_subscription","Create or update a standing subscription that wakes @linzumi when new entries land on an existing workspace topic. Use this when the user asks you to watch a topic and perform an ongoing job. The server stores the instruction, derives the creator from the current asker, and targets this conversation; do not claim success without calling this tool.",{topic_slug:R.string().min(1).describe("Existing workspace topic slug to watch."),instruction:R.string().min(1).max(4e3).describe("Standing job to execute whenever a matching topic entry wakes the agent.")},async f=>p("create_topic_wake_subscription",f)),e.tool("linzumi_disable_topic_wake_subscription","Disable the current asker's standing @linzumi wake subscription for a topic. The durable row and cursor are retained so reactivation can drain the disabled-period backlog.",{topic_slug:R.string().min(1).describe("Workspace topic slug whose standing wake should stop.")},async f=>p("disable_topic_wake_subscription",f)),e.tool("linzumi_list_coding_jobs","List the coding jobs the current asker can see in this workspace: runner connections (online and recent) with their bound job threads. Live state - never answered from search.",{},async()=>je(await t.agentListCodingJobs({}))),e.tool("linzumi_start_coding_job","Start a coding job exactly as if the asking user clicked start: same runner/channel authorization, same pipeline. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",{channel:R.string().describe("Channel slug to host the job thread."),runner_key:R.string().describe("Runner (computer) to run the job on."),cwd:R.string().describe("Working directory on the runner."),work_description:R.string().min(1).describe("What the job should do - the initial instruction."),model:R.string().optional().describe("Model override (optional)."),model_provider:R.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),execution_mode:R.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional)."),project_task_id:R.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job."),visibility:R.enum(["project","private"]).optional().describe("Job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")},async f=>je(await t.agentStartCodingJob(f))),e.tool("linzumi_interrupt_coding_job","Interrupt a coding job: mode 'steer' (default) discards its queued follow-ups so your next message lands first; mode 'stop' terminates the current turn.",{channel:R.string().describe("Channel slug hosting the job thread."),thread_id:R.string().uuid().describe("The job thread UUID."),mode:R.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")},async f=>je(await t.agentInterruptCodingJob(f))),e.tool("linzumi_send_coding_job_message","Message a coding job or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",{channel:R.string().optional().describe("Channel slug hosting the job thread. Required unless to_user is set."),thread_id:R.string().uuid().optional().describe("The job thread UUID. Required unless to_user is set."),to_user:R.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox."),body:R.string().min(1).describe("Message body to send."),tokens:Oc.optional(),delivery:R.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")},async f=>je(await t.agentSendCodingJobMessage(f))),e.tool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",{channel:R.string().describe("Channel slug hosting the job thread."),thread_id:R.string().uuid().describe("The job thread UUID."),limit:R.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:R.number().int().positive().optional().describe("Return replies before this channel seq.")},async f=>je(await t.agentReadCodingJobThread(f))),e.tool("linzumi_resolve_job_approval","Resolve a coding job's pending approval request with the asking user's decision ('approve' or 'deny'). Only relays the asker's authority - never approve without their explicit instruction.",{channel:R.string().describe("Channel slug hosting the job thread."),thread_id:R.string().uuid().describe("The job thread UUID."),source_seq:R.number().int().positive().describe("Channel seq of the message the approval request rides on."),request_id:R.string().describe("The approval request id."),decision:R.enum(["approve","deny"]).describe("The asker's decision.")},async f=>je(await t.agentResolveJobApproval(f))),e.tool("linzumi_archive_coding_job","Archive a coding job's thread (or any thread the asking user owns) so it leaves the active list; history is preserved. Do this when the asker says to archive a job or thread - never just promise it.",{channel:R.string().describe("Channel slug hosting the thread."),thread_id:R.string().uuid().describe("The thread UUID to archive.")},async f=>je(await t.agentArchiveCodingJob(f))),e.tool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",{channel:R.string().describe("Channel slug hosting the thread."),thread_id:R.string().uuid().describe("The thread UUID to unarchive.")},async f=>je(await t.agentUnarchiveCodingJob(f))),e.tool("linzumi_set_thread_status","Set a thread's lifecycle status as the asking user: 'closed' marks it done, 'open' reopens it. Works on threads the asker owns.",{channel:R.string().describe("Channel slug hosting the thread."),thread_id:R.string().uuid().describe("The thread UUID."),status:R.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")},async f=>je(await t.agentSetThreadStatus(f))),e.tool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",{name:R.string().min(1).describe("Channel name to create.")},async f=>je(await t.agentCreateChannel(f))),e.tool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",{channel:R.string().describe("Current channel slug to rename."),name:R.string().min(1).describe("New display name.")},async f=>je(await t.agentRenameChannel(f))),e.tool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",{channel:R.string().describe("Channel slug to archive.")},async f=>je(await t.agentArchiveChannel(f))),e.tool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",{channel:R.string().describe("Channel slug to unarchive.")},async f=>je(await t.agentUnarchiveChannel(f))),e.tool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the message to react to."),emoji:R.string().min(1).describe("Emoji to add (unicode or :shortcode:).")},async f=>je(await t.agentAddReaction(f))),e.tool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the reacted message."),emoji:R.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")},async f=>je(await t.agentRemoveReaction(f))),e.tool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the message to pin.")},async f=>je(await t.agentPinMessage(f))),e.tool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the pinned message.")},async f=>je(await t.agentUnpinMessage(f)))}r==="all"&&(e.tool("linzumi_get_message","Read one Linzumi message by scoped message_seq/message_id or a Linzumi message URL, with optional bounded before/after context.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),message_id:R.union([R.string(),R.number()]).optional().describe("Message seq inside the scoped channel."),message_seq:R.union([R.string(),R.number()]).optional().describe("Alias for message_id."),message_url:R.string().optional().describe("Full Linzumi message URL with #message-<seq>."),before:R.number().int().min(0).max(100).optional().describe("Number of visible messages before the target."),after:R.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")},async p=>je(await t.getMessage(p))),e.tool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().describe("Linzumi thread UUID."),limit:R.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:R.number().int().positive().optional().describe("Return replies before this channel seq.")},async p=>je(await t.getThread(p))),e.tool("linzumi_get_thread_transcript","Read a Linzumi thread's full transcript as canonical IR nodes (user/assistant messages, command executions, file changes, tool calls, statuses), cursor-paginated over the complete history. Use the returned cursor with has_more to walk older pages.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().describe("Linzumi thread UUID."),limit:R.number().int().min(1).max(500).optional().describe("Maximum transcript nodes per page (default 200)."),cursor:R.number().int().positive().optional().describe("Return nodes below this seq (the previous page reply cursor).")},async p=>je(await t.getThreadTranscript(p))),e.tool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),limit:R.number().int().min(1).max(100).optional().describe("Maximum messages to return."),before_seq:R.number().int().positive().optional().describe("Return messages before this channel seq.")},async p=>je(await t.getChannel(p))),e.tool("linzumi_search_workspace","Search the Linzumi workspace with hybrid lexical+semantic retrieval, scoped to what the authorizing user can access. Returns scored content chunks with provenance (channel, thread, authored time) and a permalink to cite.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),query:R.string().min(1).describe("Natural-language or keyword query to retrieve against."),limit:R.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped)."),source_types:R.array(R.enum(["message","coding_job","github_pr","github_pr_review","github_check_run","github_workflow_run","github_diff","dictation","file"])).optional().describe("Restrict results to these corpora; omit for all."),authored_after:R.string().optional().describe("ISO8601 instant; only content authored at or after this time."),authored_before:R.string().optional().describe("ISO8601 instant; only content authored at or before this time."),repo:R.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name)."),check_status:R.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")},async p=>je(await t.searchWorkspace(p))),e.tool("linzumi_ask_workspace",'Ask the Linzumi workspace a natural-language question and get a synthesized, citation-backed answer over what the authorizing user can access. Costs an LLM call on cache misses, so prefer linzumi_search_workspace for simple lookups. A "refused" status means there was not enough accessible evidence - treat it as "the workspace does not know", never retry verbatim.',{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),question:R.string().min(1).max(2e3).describe("Natural-language question to answer with citations."),channel:R.string().optional().describe("Optional channel slug providing conversational context; never widens access."),allow_cached:R.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")},async p=>je(await t.askWorkspace(p))),e.tool("linzumi_about_me","Read what the authorizing user has told Linzumi about themselves: their profile facts (homes, unit preferences, and other self-maintained attributes) plus their derived current timezone. Use it to personalize answers (e.g. pick the right city for weather, use their preferred units). Predicates may have multiple active values; prefer the one consistent with the derived timezone.",{},async p=>je(await t.aboutMe(p)))),l&&(e.tool("linzumi_web_search","Search the public web for live or external information: news, current events, weather, prices, third-party API docs, research. Returns result titles, URLs, and snippets. Use this whenever the answer lives outside the Linzumi workspace; follow up with linzumi_fetch_url to read a result page.",{query:R.string().min(1).describe("Web search query (natural language or keywords)."),limit:R.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")},async p=>je(await t.webSearch(p))),e.tool("linzumi_fetch_url","Fetch one public http(s) URL and return its readable text content (HTML is reduced to plain text; large pages are truncated). Use it to read pages found via linzumi_web_search or any public docs/API reference. Only public addresses are reachable - private/internal hosts are rejected with url_not_allowed.",{url:R.string().min(1).describe("Absolute public http(s) URL to fetch.")},async p=>je(await t.fetchUrl(p)))),r==="all"&&(e.tool("linzumi_list_ui_targets","List every UI surface you can ask the user to open in their own Linzumi window (channels, DMs, threads, projects, coding jobs, computers, catch-up, activity, settings tabs, pane layouts) with the structured args each kind takes. Use UI control only when the user asks for help or asks to be shown something.",{},async()=>await Cie(t.listUiTargets({}))),e.tool("linzumi_open_ui","Ask the user to open one whitelisted UI surface in their own already-open Linzumi window. A consent toast appears in THEIR session; navigation happens only if they tap Open. The call blocks until they decide and returns status opened/dismissed/expired - or error no_active_ui_session when they have no Linzumi window open (tell them to open Linzumi), or invalid_target with a detail. Use it only when the user asks for help or asks to be shown something; kinds and per-kind args come from linzumi_list_ui_targets.",{kind:R.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout)."),args:R.record(R.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path)."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>await Cie(t.openUi(Wi(p,a))))),l&&(e.tool("linzumi_get_coding_job_metadata","Read the active coding job workflow metadata for a thread, including the agent-owned goal, ordered plan steps, step lock versions, and workflow status.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread.")},async p=>je(await t.getCodingJobMetadata(Wi(p,a)))),e.tool("linzumi_rename_coding_job","Update the current coding job thread title and workflow-facing title. Use this when the job scope changes materially so the Linzumi thread list and metadata overview stay accurate.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),title:R.string().min(1).max(100).describe("Concise user-visible title for this coding job.")},async p=>je(await t.renameCodingJob(Wi(p,a)))),e.tool("linzumi_upsert_coding_job_plan","Set or update the current coding job goal. Use this at job start and whenever the goal changes materially.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:R.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")},async p=>je(await t.upsertCodingJobPlan(Wi(p,a)))),e.tool("linzumi_replace_coding_job_plan_steps","Replace the ordered coding job plan steps. Use this for the initial plan and for substantial rewrites when the old plan no longer fits the work.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:R.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal."),steps:R.array(R.object({title:R.string().min(1).max(255),description:R.string().min(1).max(1e4),status:R.enum(["pending","active","completed","blocked","canceled"]),status_note:bie.optional().describe(xie),completed_debrief:R.string().min(1).max(2e4).optional().describe("Required for completed steps. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")})).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")},async p=>je(await t.replaceCodingJobPlanSteps(Wi(p,a)))),e.tool("linzumi_update_coding_job_plan_step","Update one coding job plan step status or note. Read metadata first and pass the current step lock_version.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),step_id:R.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata."),lock_version:R.number().int().positive().describe("Current step lock_version from metadata."),status:R.enum(["pending","active","completed","blocked","canceled"]),status_note:bie.optional().describe(xie),completed_debrief:R.string().min(1).max(2e4).optional().describe("Required when marking a step completed. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")},async p=>je(await t.updateCodingJobPlanStep(Wi(p,a)))),e.tool("linzumi_link_coding_job_pull_request","Link the active coding job to its primary GitHub pull request so PR comments, files, commits, checks, deployments, and reviews can flow into the metadata view.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),github_repo_owner:R.string().min(1).max(255),github_repo_name:R.string().min(1).max(255),github_pr_number:R.number().int().positive(),github_pr_url:R.string().url(),title:R.string().min(1).max(255),body:R.string().min(1).max(1e5).optional(),head_branch:R.string().min(1).max(255),head_sha:R.string().min(7).max(64),base_branch:R.string().min(1).max(255),base_sha:R.string().min(7).max(64),state:R.enum(["draft","open","closed","merged"]).optional(),is_draft:R.boolean().optional(),review_status:R.enum(["unknown","review_required","approved","changes_requested"]).optional(),source_remote_url:R.string().min(1).max(1e3).describe("Git remote URL for the local job worktree; required when this job has no repo workspace yet."),runtime_worktree_root:R.string().min(1).max(1e3).describe("Absolute local worktree path for the coding job; required when this job has no repo workspace yet."),dirty_status:R.enum(["unknown","clean","dirty"]).optional(),dirty_summary:R.string().min(1).max(2e3).optional()},async p=>je(await t.linkCodingJobPullRequest(Wi(p,a)))),e.tool("linzumi_upload_files",["Upload local files to Linzumi and attach them to a new, exact, or latest assistant message. Use silently; do not mention this tool in the visible reply.","The JSON result includes message.attachments[].url as an absolute URL. Use those returned URLs when writing rich media directives such as ::audio, ::video, ::image, or Markdown images. Do not guess attachment URLs before upload.","For a message that should both attach files and show inline rich media, use a two-step flow: first upload/attach the files to create or target the message, then edit the same target message with body text that references the returned absolute URLs. When the result has target_seq, use target.kind=message_seq and message_seq=target_seq for that follow-up edit; result.message is the edit event that carries the new attachments, and target_message is the original target."].join(" "),{target:R.object({kind:R.enum(["new_message","message_seq","latest_assistant_message"]).describe("new_message creates a message; message_seq edits an exact message; latest_assistant_message edits the latest assistant message in the scoped thread/channel."),message_seq:R.union([R.string(),R.number()]).optional().describe("Required when kind is message_seq."),thread_id:R.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")}).describe("Attachment target. Prefer latest_assistant_message to attach files to the reply you already posted; use new_message ONLY when no assistant message exists yet in the scoped thread. Never re-use your visible reply text as a new_message body - that posts the reply twice. To reference uploaded files in the message body, upload first, then edit message_seq/latest_assistant_message with the returned absolute attachment URLs. If the upload result includes target_seq, use message_seq=target_seq for that follow-up edit."),files:R.array(R.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden files inside the approved workspace or Downloads; source/text files of any language are supported, plus common document, image, patch, archive, and video types."),body:R.string().min(1).max(2e4).optional().describe("Required for new_message: a SHORT file-share caption (for example: Attached the generated report), never a copy of your visible reply - that would post the reply twice. Optional replacement body for message_seq/latest_assistant_message; when omitted, the existing message body is preserved. Rich media directives in body must use Linzumi attachment download URLs returned by this tool."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the target thread's channel (when the thread is known) or the authenticated token scope.")},async p=>{let f=wie(p.target,a);try{let h=await mWe({client:t,cwd:i,kandanUrl:s,target:f,files:p.files,workspace:p.workspace,channel:p.channel,body:p.body});return je(Sie(s,h))}catch(h){throw fWe(h)}}),e.tool("linzumi_edit_message","Edit an exact scoped Linzumi message by message_seq. Use after linzumi_upload_files when you need a body-only follow-up edit that embeds returned attachment URLs. Requires channel.write, and thread.write when target.thread_id is set. Rich media src/poster values must be Linzumi attachment download URLs.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),target:R.object({message_seq:R.union([R.string(),R.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here."),thread_id:R.string().optional().describe("Thread UUID when editing a thread message. Use the upload result target_message.thread_id when present.")}).describe("Exact message target for the body edit."),body:R.string().min(1).max(2e4).describe("Replacement Markdown body. Rich media src/poster values must be Linzumi attachment download URLs returned by linzumi_upload_files.")},async p=>je(Sie(s,await t.editMessage({...p,target:wie(p.target,a)}))))),r==="all"&&(e.tool("linzumi_list_vault_secrets","List vault secret names, descriptions, and whether each secret is personal or workspace-owned. Does not return secret values.",{},async p=>je(await t.listVaultSecrets(p))),e.tool("linzumi_list_projects","List the projects in the current workspace with their project_id (needed by the other project task tools), slug, title, description, and state.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>je(await t.listProjects(p))),e.tool("linzumi_get_project_tasks",`Read a project's full task graph: task GROUPS (kind "group", organizational containers, exactly one level deep) and ISSUES (kind "issue", the executable work items), each with status (todo/active/blocked/review/done/canceled), DERIVED work_state readiness (ready = todo with every dependency satisfied; blocked = todo with unsatisfied dependencies; running/stalled = active with/without a connected job), parent group, assignee, lock_version, and dependency edges (depends_on_task_ids / unblocks_task_ids). Always read this before reorganizing. Inside a project-bound coding job the project is inferred automatically; otherwise pass project_id from linzumi_list_projects.`,{project_id:R.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")},async p=>je(await t.getProjectTasks(Wi(p,a)))),e.tool("linzumi_create_project_task",'Create a task group (kind "group") or issue (kind "issue", the default) in a project. Groups organize issues and are exactly one level deep: a parent_id must name a GROUP, and groups themselves can never have a parent. New tasks default to status "todo" and append to the end unless position is given. Inside a project-bound coding job the project is inferred; otherwise pass project_id.',{project_id:R.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project."),title:R.string().min(1).describe("Task title."),kind:R.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).'),description:R.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it."),status:R.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".'),parent_id:R.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent."),assignee:R.string().optional().describe("Username of a workspace member to assign."),position:R.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")},async p=>je(await t.createProjectTask(Wi(p,a)))),e.tool("linzumi_update_project_task",'Update a task group or issue: retitle, edit description/status_note, transition status (todo/active/blocked/review/done/canceled), reassign, reorder (position), or reorganize (parent_id moves an issue into a group; clear_parent moves it to top level). Only the fields you pass change; description and status_note accept null to clear. Prefer updating existing tasks over delete-and-recreate. Pass the lock_version from your last read to fail loudly ("stale") instead of overwriting a concurrent edit.',{task_id:R.string().describe("task_id of the group or issue to update."),title:R.string().min(1).optional().describe("New title."),description:R.string().nullable().optional().describe("New description. Pass null to clear it."),status:R.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.'),status_note:R.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it."),position:R.number().int().min(0).optional().describe("New sort position among siblings."),parent_id:R.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent."),clear_parent:R.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id."),assignee:R.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee."),clear_assignee:R.boolean().optional().describe("true removes the assignee. Do not combine with assignee."),lock_version:R.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")},async p=>je(await t.updateProjectTask(p))),e.tool("linzumi_delete_project_task",`Permanently delete a task group or issue. Dependency edges on the task are removed with it (dependents may become ready). Deletion is normally the USER's call - prefer status "canceled" or an update unless you are certain the entry is obsolete.`,{task_id:R.string().describe("task_id of the group or issue to delete.")},async p=>je(await t.deleteProjectTask(p))),e.tool("linzumi_add_project_task_dependency",'Add the dependency edge "task_id is blocked by depends_on_task_id" between two ISSUES in the same project (groups cannot have dependencies). The dependent stays blocked until the prerequisite reaches done or canceled. The graph must stay acyclic: an edge that would create a cycle is refused with reason "would_create_cycle" and the offending cycle_path so you can restructure. Duplicate and self edges are rejected.',{task_id:R.string().describe("task_id of the DEPENDENT issue (the one that must wait)."),depends_on_task_id:R.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")},async p=>je(await t.addProjectTaskDependency(p))),e.tool("linzumi_remove_project_task_dependency",'Remove the dependency edge "task_id is blocked by depends_on_task_id". The dependent issue may become ready if that was its last unsatisfied dependency.',{task_id:R.string().describe("task_id of the DEPENDENT issue."),depends_on_task_id:R.string().describe("task_id of the PREREQUISITE issue the edge points at.")},async p=>je(await t.removeProjectTaskDependency(p))),e.tool("linzumi_get_call_transcript","Read the full transcript of a completed Linzumi notetaker call: call metadata (title, platform, started/ended/transcribed times), participants, and every spoken segment in order with speaker names and millisecond offsets. Pass the call_id embedded in the request (or copied from the call card). Errors: call_not_found (missing or not visible to you), call_transcript_not_ready (call still connecting, in progress, or transcribing - retry later).",{call_id:R.string().describe("The call id from the call card or the launching message (a CallRecording id - the opaque GraphQL id and the bare uuid both work).")},async p=>je(await t.getCallTranscript(p))),u||(e.tool("linzumi_start_coding_job","Start a coding job as the invoking user (same authorization and pipeline as clicking start). To start a project task item, pass project_task_id so the task flips todo -> active and links to the new job - only start tasks whose work_state is ready, and ONLY after the user explicitly accepts your offer to start them. Omit channel, runner_key, and cwd to reuse this job's own channel, computer, and folder. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",{work_description:R.string().min(1).describe("What the job should do - the initial instruction. For a task item, write it from the task title and description."),project_task_id:R.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job."),visibility:R.enum(["project","private"]).optional().describe("Child-job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants."),channel:R.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel."),runner_key:R.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer."),cwd:R.string().optional().describe("Working directory on the runner. Omit to use this job's own folder."),model:R.string().optional().describe("Model override (optional)."),model_provider:R.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),agent_provider:R.string().optional().describe("Agent provider override, e.g. 'codex' (optional)."),reasoning_effort:R.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional)."),approval_policy:R.enum(["default","on-request","on-failure","never"]).optional().describe("Approval policy override (optional)."),sandbox:R.enum(["default","workspace-write","read-only","danger-full-access"]).optional().describe("Sandbox override (optional)."),fast:R.boolean().optional().describe("Fast-mode override (optional)."),allow_port_forwarding_by_default:R.boolean().optional().describe("Default port-forwarding override (optional)."),execution_mode:R.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional)."),egress_mode:R.enum(["open","hardened"]).optional().describe("Local-VM egress override (optional).")},async p=>je(await t.agentStartCodingJob(Wi(p,a)))),n.multiAgentJobs===!0&&(e.tool("linzumi_spawn_child_job","Spawn a durable child coding job under YOUR OWN job, on any harness or model - plan a DAG and delegate its legs to workers you then coordinate through discovery and messaging. The child lands on this job's channel, computer, and folder; it inherits this job's project and visibility (a private parent's children stay private), human roles cascade to it, and a human manages its lifecycle. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",{work_description:R.string().min(1).describe("What the child job should do - the initial instruction, written to stand alone."),agent_provider:R.string().optional().describe("Harness for the child, e.g. 'codex' or 'claude-code'. Omit to reuse this job's own harness. A different harness is fine: a cross-harness child is always a child job."),model:R.string().optional().describe("Model override for the child (optional)."),model_provider:R.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),reasoning_effort:R.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional)."),project_task_id:R.string().optional().describe("Project task item to bind the child to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job."),visibility:R.enum(["project","private"]).optional().describe("Child visibility. Defaults to this job's own visibility; a private parent's children must stay private.")},async p=>je(await t.agentSpawnChildJob(Wi(p,a)))),e.tool("linzumi_archive_child_job","Archive a coding job that is YOUR OWN job or one beneath it in your job tree, retiring it from the active lists, the org map and the needs-you deck; history is preserved and it can be unarchived. Use this to clean up child jobs you spawned that are finished or dead - do it in the current turn, never just promise it. Refused for sibling, parent or unrelated jobs, and for jobs that do not belong to the human you are working for. When the job still has live descendants the call returns confirmation_required with their exact count and ids; call again with descendant_action 'keep' (archive only this job, re-parenting its children) or 'cascade' (archive the whole subtree) plus those expected values.",{job_id:R.string().describe("The coding job id to archive: your own job, or any job beneath it in your tree."),outcome:R.enum(["completed","abandoned","superseded"]).describe("Why the job is being archived."),descendant_action:R.enum(["keep","cascade"]).optional().describe("Phase-2 choice when the job has live descendants. 'keep' archives only this job and re-parents its children; 'cascade' archives the whole subtree."),expected_descendant_count:R.number().int().optional().describe("The descendant_count returned by the phase-1 call."),expected_descendant_job_ids:R.array(R.string()).optional().describe("The descendant_job_ids returned by the phase-1 call; the call is refused if the subtree changed."),expected_descendant_fingerprint:R.string().optional().describe("The descendant_fingerprint returned by the phase-1 call.")},async p=>je(await t.agentArchiveChildJob(p))),e.tool("linzumi_unarchive_child_job","Unarchive a previously archived coding job that is YOUR OWN job or one beneath it in your job tree. It returns as hibernating and wakes when messaged. Same ownership scope as linzumi_archive_child_job. Refused when the job is not archived, or when its home thread already holds a live job.",{job_id:R.string().describe("The archived coding job id to bring back: your own job, or any job beneath it in your tree.")},async p=>je(await t.agentUnarchiveChildJob(p))),e.tool("linzumi_discover_coding_jobs","Search current sitreps inside this coding job project for overlapping files, modules, objectives, or blockers. Results include durable job addresses for coordination. Private jobs outside your visible set never appear.",{query:R.string().min(1).describe("Free-text clash-surface query, such as a file path, module, migration, or objective.")},async p=>je(await t.agentDiscoverCodingJobs({...p,source_thread_id:a}))),e.tool("linzumi_send_coding_job_message","Message a visible coding job in this project, or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",{channel:R.string().optional().describe("Channel slug hosting the target job. Required unless to_user is set."),thread_id:R.string().uuid().optional().describe("Target job thread UUID. Required unless to_user is set."),to_user:R.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox."),body:R.string().min(1).describe("Coordination message to send."),tokens:Oc.optional(),delivery:R.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")},async p=>je(await t.agentSendCodingJobMessage({...p,source_thread_id:a})))))),oWe(r)&&(e.tool("linzumi_upload_custom_emoji","Upload a local image as a workspace custom emoji. For generated emoji art, create a transparent PNG with a simple centered subject, crisp edges, strong contrast, minimal tiny details, and enough outline/highlight separation to read at 16-24px on both dark and light backgrounds. Use lowercase shortcode names without colons unless preserving a user-provided :name:.",{name:_ie.describe("Custom emoji shortcode name, with or without surrounding colons."),file:R.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>je(await hWe({client:t,cwd:i,kandanUrl:s,name:p.name,file:p.file,workspace:p.workspace}))),e.tool("linzumi_rename_custom_emoji","Rename an existing workspace custom emoji. The new name may include surrounding colons; Linzumi stores the normalized shortcode without colons.",{emoji_id:R.union([R.string(),R.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings."),name:_ie.describe("New shortcode name, with or without surrounding colons."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>je(await t.renameCustomEmoji(p)))),e.tool("linzumi_media_guide","Return the full Linzumi rich-media authoring guide (audio/video/image directives, URL rules, upload-then-embed flow, examples). Call once BEFORE writing any ::audio/::video/::image directive or Markdown image into a Linzumi message.",{},async()=>({content:[{type:"text",text:Q_}]})),e.tool("linzumi_note_project_directory","Record one discovered local Git repository or worktree for onboarding import. Call once per project as soon as it is found.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:R.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),path:R.string().min(1).describe("Absolute local path to the repository worktree root."),display_name:R.string().optional().describe("Short project label. Defaults to the path basename."),activity_at:R.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),import_key:R.string().optional().describe("Stable dedupe key. Defaults to path."),metadata:R.record(R.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")},async p=>je(await t.noteProjectDirectory(p))),e.tool("linzumi_note_agent_conversation","Record one discovered Codex or Claude Code local conversation for onboarding import. Call once per conversation as soon as it is found.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:R.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),source:R.enum(["codex","claude_code"]).describe("Conversation source."),import_key:R.string().min(1).describe("Stable dedupe key, such as a session id or file path."),path:R.string().optional().describe("Absolute local path to the conversation file or directory."),display_name:R.string().optional().describe("Short label for the discovered conversation."),activity_at:R.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),metadata:R.record(R.unknown()).optional().describe("Small structured metadata such as session id or project path.")},async p=>je(await t.noteAgentConversation(p))),e.tool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:R.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),phase:R.enum(["projects","conversations"]).describe("Discovery phase being reported."),status:R.enum(["starting","running","completed","failed"]).describe("Current phase status."),places_searched:R.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far."),message:R.string().optional().describe("Short user-facing status note."),current_place:R.string().optional().describe("Current folder, file, Git command target, or known location being checked."),current_source:R.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code."),last_error:R.string().optional().describe("Short failure detail when status is failed."),metadata:R.record(R.unknown()).optional().describe("Small structured status metadata.")},async p=>je(await t.noteOnboardingDiscoveryStatus(p))),r==="all"&&iWe(o)&&(e.tool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",{owner_username:R.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Source channel slug used to verify owner visibility."),body:R.string().min(1).max(2e4).describe("Plain-text message body to DM."),tokens:Oc.optional()},async p=>{let f=p.owner_username??d;if(f===void 0)throw new Error("owner_username is required for linzumi_dm_owner");return je(await t.dmOwner({...p,owner_username:f}))}),e.tool("linzumi_send_channel_message","Post a NEW standalone Markdown message into the scoped Linzumi channel as the authenticated local-runner user. This is NOT how you respond to the user: your turn output is already relayed into the thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to proactively post a separate channel message. Requires channel.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),body:R.string().min(1).max(2e4).describe("Markdown message body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths."),tokens:Oc.optional()},async p=>je(await t.sendChannelMessage(p))),e.tool("linzumi_send_thread_reply","Post a Markdown reply into some OTHER existing Linzumi thread as the authenticated local-runner user. This is NOT how you respond to the user in your current thread: your turn output is already relayed into this thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to post into a different, explicitly identified thread. Requires thread.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().describe("Existing Linzumi thread UUID."),body:R.string().min(1).max(2e4).describe("Markdown reply body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths."),tokens:Oc.optional()},async p=>je(await t.sendThreadReply(p))),e.tool("linzumi_send_dm","Send a plain-text DM as the authenticated local-runner user to a visible user in the scoped workspace/channel. Requires dm.write.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Source channel slug used to verify target visibility."),username:R.string().describe("Visible Linzumi username to DM."),body:R.string().min(1).max(2e4).describe("Plain-text message body to DM."),tokens:Oc.optional()},async p=>je(await t.sendDm(p)))),r==="all"&&e.tool("linzumi_get_vault_values","Request values for explicit vault env var names after a thread-scoped human approval. Requires vault.read; thread_id resolves the approval thread.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug used to disambiguate the approval thread when needed."),thread_id:R.string().uuid().describe("Existing Linzumi thread UUID for the inline approval."),env_var_names:R.array(R.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/)).min(1).max(20).describe("Explicit vault env var names to request. This tool cannot list all vault keys."),description:R.string().min(1).max(500).describe("Human-readable reason shown in the approval request."),justification:R.string().min(10).max(1e3).describe("Agent justification shown to the approver.")},async p=>je(await t.getVaultValues(p))),r==="all"&&!u&&c!==void 0&&pWe(e,i,c)}function vie(e){return{name:e.record.name,command:e.record.command,cwd:e.record.cwd,ports:[...e.record.ports],restart_on_branch_change:e.record.restartOnBranchChange,desired_state:e.record.desiredState,liveness:e.liveness,port_health:e.portProbes.map(n=>({port:n.port,listening:n.listening})),started_at_ms:e.record.startedAtMs??null,last_exit:e.lastExit===void 0?null:{code:e.lastExit.code,signal:e.lastExit.signal,at_ms:e.lastExit.atMs},log_path:e.record.logPath,failure:e.failure===void 0?null:{reason:e.failure.reason,at_ms:e.failure.atMs}}}function pWe(e,n,t){e.tool("linzumi_dev_service_start","Start a long-running local dev server (npm run dev, storybook, docker compose up, ...) as a MANAGED SERVICE owned by the Linzumi runner. Use this instead of running dev servers in your own shell: a managed service survives the end of your turn and branch switches, is auto-restarted if it crashes, and its declared ports are health-probed and surfaced in the product. Calling start for an existing name declaratively RESTARTS it (e.g. after a checkout). Declare EVERY port the app serves from (primary plus HMR/asset/bundle sibling ports).",{name:R.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/).describe("Stable service name (slug), e.g. 'web' or 'storybook'. Reusing a name restarts that service."),command:R.string().min(1).describe("Shell command that runs the server in the foreground (never daemonize/screen/nohup it yourself), e.g. 'npm run dev'. Runs via the user's login shell."),cwd:R.string().optional().describe("Working directory for the service. Defaults to the session cwd."),ports:R.array(R.number().int().min(1).max(65535)).max(16).default([]).describe("Every TCP port this service listens on (primary AND related ports such as the Vite/HMR bundle port). Used for health probes and product visibility."),restart_on_branch_change:R.boolean().optional().describe("Restart the service automatically when the git branch of its cwd changes (for servers that go stale across checkouts)."),wait_for_ports_ms:R.number().int().min(0).max(6e4).optional().describe("How long to wait for the declared ports to accept connections before returning (default 15000).")},async r=>{let o=await Xx({scopeDir:t.scopeDir,definition:{name:r.name,command:r.command,cwd:r.cwd??n,ports:r.ports,restartOnBranchChange:r.restart_on_branch_change===!0},ownerPid:t.ownerPid});if(!o.ok)return je({ok:!1,error:o.error});let i=Date.now()+(r.wait_for_ports_ms??15e3),s=o.record.ports.length===0;for(;!s&&Date.now()<i;)s=(await Promise.all(o.record.ports.map(c=>BP(c)))).every(c=>c),s||await new Promise(c=>setTimeout(c,250));let d=(await oh(t.scopeDir)).find(u=>u.record.name===o.record.name);return je({ok:!0,service:d===void 0?{name:o.record.name}:vie(d),...d!==void 0&&d.liveness!=="running"?{hint:"The service is not (fully) serving its declared ports yet. Check linzumi_dev_service_logs before assuming it works."}:{}})}),e.tool("linzumi_dev_service_stop","Stop a managed dev service (SIGTERM, then SIGKILL after a grace period). The registration is kept so linzumi_dev_service_start can bring it back.",{name:R.string().min(1).describe("Service name to stop.")},async r=>{let o=await ih({scopeDir:t.scopeDir,name:r.name});return je(o.ok?{ok:!0,name:o.record.name,desired_state:"stopped"}:{ok:!1,error:o.error})}),e.tool("linzumi_dev_service_status","List every managed dev service with liveness (running / unhealthy / exited / failed / stopped), per-port health probes, last exit, and any terminal failure reason. Live state - always check this before concluding a dev server is up or down.",{},async()=>{let r=await oh(t.scopeDir);return je({services:r.map(o=>vie(o))})}),e.tool("linzumi_dev_service_logs","Read the tail of a managed dev service's combined stdout/stderr log.",{name:R.string().min(1).describe("Service name."),max_bytes:R.number().int().min(256).max(65536).optional().describe("Tail size in bytes (default 16384).")},async r=>{let o=eb(t.scopeDir,r.name,r.max_bytes??16384);return je(o===void 0?{ok:!1,error:`no log for service: ${r.name}`}:{ok:!0,name:r.name,log_tail:o})}),e.tool("linzumi_dev_service_remove","Stop a managed dev service AND delete its registration (it will not be resurrected on runner restart). Use stop instead when the user may want it back.",{name:R.string().min(1).describe("Service name to remove.")},async r=>{let o=await Yx({scopeDir:t.scopeDir,name:r.name});return je(o.ok?{ok:!0,name:o.record.name,removed:!0}:{ok:!1,error:o.error})})}function fWe(e){return!(e instanceof Error)||!e.message.includes("channel_required")?e:new Error(`${e.message}. Remediation: pass the channel slug in the \`channel\` parameter, or set target.thread_id to a Linzumi thread you can access (the server resolves the thread's channel). The files were NOT attached; retry with a channel or thread instead of leaving them on disk.`,{cause:e})}async function mWe(e){let n=await Promise.all(e.files.map(s=>cT(e.cwd,s))),t=y(e.target.thread_id),r=await e.client.prepareMessageUploads({...e.workspace===void 0?{}:{workspace:e.workspace},...e.channel===void 0?{}:{channel:e.channel},...t===void 0?{}:{thread_id:t},files:n.map(s=>({file_name:s.fileName,content_type:s.contentType,size_bytes:s.sizeBytes}))}),o=ze(r.uploads)??[];if(o.length!==n.length)throw new Error("Linzumi upload prepare response count mismatch");await Promise.all(n.map(async(s,a)=>{let d=D(o[a]),u=y(d?.upload_url),c=y(d?.upload_method)??"PUT";if(u===void 0)throw new Error("Linzumi upload prepare response missing upload_url");let l=s.bytes,p=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength),f=await fetch(Fy(e.kandanUrl,u),{method:c,headers:{"content-type":s.contentType},body:p});if(!f.ok)throw new Error(`Linzumi upload failed for ${s.fileName}: ${f.status} ${f.statusText}`)}));let i=o.map(s=>{let a=y(D(s)?.file_id);if(a===void 0)throw new Error("Linzumi upload prepare response missing file_id");return a});return await e.client.attachMessageFiles({...e.workspace===void 0?{}:{workspace:e.workspace},...e.channel===void 0?{}:{channel:e.channel},...t===void 0?{}:{thread_id:t},target:e.target,...e.body===void 0?{}:{body:e.body},uploaded_file_ids:i})}async function hWe(e){let n=await cT(e.cwd,e.file),t=await e.client.prepareCustomEmoji({...e.workspace===void 0?{}:{workspace:e.workspace},name:e.name,file_name:n.fileName,content_type:n.contentType,size_bytes:n.sizeBytes}),r=D(t.upload),o=y(r?.upload_url),i=y(r?.upload_method)??"PUT";if(o===void 0)throw new Error("Linzumi custom emoji prepare response missing upload_url");let s=n.bytes,a=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),d=await fetch(Fy(e.kandanUrl,o),{method:i,headers:{"content-type":n.contentType},body:a});if(!d.ok){let l=`${d.status} ${d.statusText}`,f=(await d.text()).trim(),h=f===""?l:(()=>{try{let m=JSON.parse(f);return X(m)&&typeof m.error=="string"?m.error:f}catch{return f}})();throw new Error(`Linzumi custom emoji upload failed: ${h}`)}let u=await d.json();if(!X(u))throw new Error("Linzumi custom emoji upload returned non-object JSON");let c=D(u.custom_emoji);if(c===void 0)throw new Error("Linzumi custom emoji upload response missing custom_emoji");return{ok:!0,workspace:t.workspace,emoji:c,asset_id:y(u.asset_id),id:Q(c?.id),name:y(c?.name),shortcode:y(c?.shortcode),image_url:y(c?.image_url)}}function wie(e,n){if(y(e.thread_id)!==void 0||n===void 0)return e;switch(e.message_seq===void 0){case!1:return{...e,thread_id:n};case!0:switch(y(e.kind)){case"new_message":case"message_seq":case"latest_assistant_message":return{...e,thread_id:n};default:return e}}}function Wi(e,n){return y(e.thread_id)!==void 0||n===void 0?e:{...e,thread_id:n}}function Fy(e,n){try{return new URL(n).toString()}catch{let r=e.replace(/^wss:\/\//,"https://").replace(/^ws:\/\//,"http://");return new URL(n,r).toString()}}function Sie(e,n){let t=D(n.message),r=D(n.target_message);return t===void 0&&r===void 0?n:{...n,...t===void 0?{}:{message:kie(e,t)},...r===void 0?{}:{target_message:kie(e,r)}}}function kie(e,n){let t=ze(n.attachments);return t===void 0?n:{...n,attachments:t.map(r=>gWe(e,r))}}function gWe(e,n){let t=D(n);if(t===void 0)return n;let r=y(t.url),o=D(t.image_variants);return{...t,...r===void 0?{}:{url:Fy(e,r)},...o===void 0?{}:{image_variants:yWe(e,o)}}}function yWe(e,n){let t=y(n.inline_url),r=y(n.carousel_url);return{...n,...t===void 0?{}:{inline_url:Fy(e,t)},...r===void 0?{}:{carousel_url:Fy(e,r)}}}function _We(e){e.server.registerCapabilities({resources:{listChanged:!1}}),e.server.setRequestHandler(af,()=>({resources:[]})),e.server.setRequestHandler(df,()=>({resourceTemplates:[]}))}async function xWe(e){let n=fq(e),t=hq(n,"api-url"),r=ot(n,"format")??"codex",o=mq(ot(n,"mode")),i=n.get("include-token")===!0?(await pq({kandanUrl:t,explicitToken:ot(n,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:ot(n,"auth-file"),delegationAuthFilePath:ot(n,"delegation-auth-file"),workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")})).accessToken:void 0,s=as({command:ot(n,"command"),kandanUrl:t,accessToken:i,delegationAuthFilePath:ot(n,"delegation-auth-file"),ownerUsername:ot(n,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:o,toolScope:Iie(ot(n,"tool-scope")),multiAgentJobs:n.get("multi-agent-jobs")===!0});switch(r){case"codex":process.stdout.write(tU(s));return;case"claude-code":process.stdout.write(nU(s));return;default:throw new Error("--format must be codex or claude-code")}}async function bWe(e){let n=fq(e),t=hq(n,"api-url"),r=await pq({kandanUrl:t,explicitToken:ot(n,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:ot(n,"auth-file"),delegationAuthFilePath:ot(n,"delegation-auth-file"),workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")});switch(r.mode){case"local-runner":{if(!await Rv({kandanUrl:t,accessToken:r.accessToken,workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")}))throw new Error("Linzumi MCP auth validation failed");break}case"personal-agent-delegation":{await ms({kandanUrl:t,accessToken:r.accessToken,authMode:r.mode,operatingMode:mq(ot(n,"mode"))}).validateAuth();break}}process.stdout.write(`Linzumi MCP auth OK
2182
+ `}async function dWe(e){let n=fq(e);if(n.get("help")===!0){process.stdout.write(Pie());return}let t=hq(n,"api-url"),r=await pq({kandanUrl:t,explicitToken:ot(n,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:ot(n,"auth-file"),delegationAuthFilePath:ot(n,"delegation-auth-file"),workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")}),o=ot(n,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,i=mq(ot(n,"mode")),s=Iie(ot(n,"tool-scope")),a=ot(n,"cwd")??process.cwd(),d=ot(n,"thread-id")??process.env.LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID,u=ms({kandanUrl:t,accessToken:r.accessToken,authMode:r.mode,operatingMode:i}),c=new WS({name:"linzumi",version:"0.1.0"});_We(c),lWe(c,{client:u,toolScope:s,operatingMode:i,cwd:a,kandanUrl:t,defaultThreadId:d,ownerUsername:o,agentSession:n.get("agent-session")===!0,documentSurfaces:im(r.accessToken),askUserQuestionTool:n.get("ask-user-question-tool")===!0,devServices:cWe(process.env),multiAgentJobs:n.get("multi-agent-jobs")===!0}),await c.connect(new HS)}var xie="One or two sentences a teammate skimming the board would want: what changed, and what happens next. Standup register, present tense, name agents and lanes plainly. No thread ids or UUIDs unless needed for lookup; proofs and evidence belong in the thread, not here. Good: 'Retired the silent watchdog and spawned Thorne to replace it \u2014 running lean at three children.' Bad: 'Broken 67f1d639 archived abandoned; board claim preceded spawn; children verified at exactly 3.'",uWe=new Intl.Segmenter("en",{granularity:"grapheme"}),bie=R.string().min(1).refine(e=>Array.from(uWe.segment(e)).length<=240,{message:"status_note over 240 chars \u2014 trim to what a reader needs; put evidence in the thread."});function cWe(e){let n=e.LINZUMI_DEV_SERVICES_SCOPE?.trim(),t=Number.parseInt(e.LINZUMI_DEV_SERVICES_OWNER_PID??"",10);if(!(n===void 0||n===""||!Number.isInteger(t)||t<=0))return{scopeDir:lu(n),ownerPid:t}}function lWe(e,n){let{client:t,toolScope:r,operatingMode:o,cwd:i,kandanUrl:s,defaultThreadId:a,ownerUsername:d,agentSession:u,devServices:c}=n,l=r==="all"||r==="coding";if(n.askUserQuestionTool===!0&&e.tool(oU,`Ask the user up to ${Fm} structured multiple-choice questions and BLOCK until they answer in the Linzumi thread. Use this whenever you need a decision or clarification mid-task. Each question needs a short header (max ${Lm} chars) and ${Nm}-${zm} options {label, description}; a built-in "${Bm}" free-text choice is always shown in addition to your options, so never add one yourself. Set multiSelect true to allow choosing several options. Returns {answers} keyed by question text: a single label string, an array of labels for multiSelect, and {"other": "<typed text>"} for a free-text reply.`,{questions:R.array(R.object({question:R.string().describe("The question to ask the user."),header:R.string().describe(`Short category header shown above the question (max ${Lm} chars, e.g. "Auth", "Scope").`),options:R.array(R.object({label:R.string().describe("Option label the user taps."),description:R.string().optional().describe("One-line explanation of the option.")})).describe(`${Nm}-${zm} options for this question.`),multiSelect:R.boolean().optional().describe("True lets the user select several options; the answer becomes an array.")})).describe(`1-${Fm} questions to ask atomically.`)},async p=>wWe((f,h)=>e.server.elicitInput(f,h),p)),n.documentSurfaces===!0){let p=async(f,h)=>je(await t.agentDocumentTool({...h,tool:f}));e.tool("linzumi_lookup_documents","Search document titles and content within the controlling human's visibility ceiling. Returns authorized results in canonical search order; zero, one, and multiple matches carry the rule-03 ambiguity meaning.",{query:R.string().min(1).describe("Document title or content search query.")},async f=>p("lookup_documents",f)),e.tool("linzumi_read_document","Read one in-scope document as full AST and metadata, including pending proposals and required-agent-context comments. Both controlling-human visibility and agent delegation are required.",{document_id:R.string().uuid().describe("Document UUID.")},async f=>p("read_document",f)),u?(e.tool("linzumi_append_document_section","Use this tool for append-shaped document requests: add or append a new section, or add or update a tracker row as new section content, including parent-delegated work. After resolving exactly one patch target document and reading it, call this tool in the same turn; do not merely reply with suggested prose. Other authorized context documents do not make the patch target ambiguous. Supply only the heading and body Markdown: the server composes the closed structural operations. Every change is proposal-always.",{document_id:R.string().uuid().describe("Document UUID."),heading:R.string().trim().min(1).describe("Section heading."),body_markdown:R.string().trim().min(1).describe("Section body as Markdown authored by the model.")},async f=>p("append_document_section",f)),e.tool("linzumi_replace_section","Use this tool for targeted section rewrites, fixes, and tightening. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply the replacement body Markdown. The server rejects missing and ambiguous headings with actionable typed errors and composes the closed structural operations. Every change is proposal-always.",{document_id:R.string().uuid().describe("Document UUID."),heading_or_section_ref:R.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document."),body_markdown:R.string().trim().min(1).describe("Replacement section body as Markdown.")},async f=>p("replace_section",f)),e.tool("linzumi_annotate_document_section","Use this tool to add a durable note to one existing heading-delimited document section without rewriting its content. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply only the note Markdown. The server rejects missing and ambiguous headings, composes the anchored comment, and persists a proposal before any authorized auto-apply.",{document_id:R.string().uuid().describe("Document UUID."),heading_or_section_ref:R.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document."),note_markdown:R.string().trim().min(1).describe("Durable section note as Markdown.")},async f=>p("annotate_document_section",f)),e.tool("linzumi_decline_document_action","Decline the current document action when no advertised document intent can express it. Give a clear reason; the server relays it verbatim with an honest decline prefix and satisfies the action binding.",{reason:R.string().refine(f=>f.trim().length>0,{message:"Reason must contain non-whitespace text."}).describe("Clear reason the available document intents cannot express the request.")},async f=>je(await t.declineDocumentAction({reason:f.reason})))):e.tool("linzumi_propose_document_patch","Submit a raw revisioned structural document patch. This power/API surface requires the caller to compose the closed operation vocabulary. Create a native data-bound table with the atomic create_bound_table operation containing bindingId, block, and binding; rows remain source data and must not be copied into the block. Every change is proposal-always.",{document_id:R.string().uuid().describe("Document UUID."),patch:R.object({baseRevision:R.number().int().nonnegative(),operations:R.array(R.record(R.unknown())),title:R.string().min(1).optional()}).describe("Revisioned structural document patch."),rationale:R.string().min(1).describe("Why this change is proposed.")},async f=>p("propose_document_patch",f)),u||e.tool("linzumi_create_document","Create an agent-attributed document through an atomic bootstrap proposal and apply transaction in the named folder or workspace default folder.",{title:R.string().min(1).describe("Document title."),initial_patch:R.record(R.unknown()).describe("Bootstrap structural patch."),folder_id:R.string().uuid().optional().describe("Destination folder UUID.")},async f=>p("create_document",f))}if(u){e.tool("linzumi_agent_reply","Post your single @linzumi reply for the current turn into the surface where you were mentioned. Call EXACTLY ONCE per turn with your final answer; the reply links to this working session automatically. Fails with already_replied on a second call and no_active_asker_binding when no turn is active.",{body:R.string().min(1).describe("Plain-text reply body to post."),tokens:Oc.optional()},async f=>je(await t.agentReply({body:f.body,...f.tokens===void 0?{}:{tokens:f.tokens}})));let p=async(f,h)=>je(await t.agentTopicTool({...h,tool:f}));e.tool("linzumi_create_topic_wake_subscription","Create or update a standing subscription that wakes @linzumi when new entries land on an existing workspace topic. Use this when the user asks you to watch a topic and perform an ongoing job. The server stores the instruction, derives the creator from the current asker, and targets this conversation; do not claim success without calling this tool.",{topic_slug:R.string().min(1).describe("Existing workspace topic slug to watch."),instruction:R.string().min(1).max(4e3).describe("Standing job to execute whenever a matching topic entry wakes the agent.")},async f=>p("create_topic_wake_subscription",f)),e.tool("linzumi_disable_topic_wake_subscription","Disable the current asker's standing @linzumi wake subscription for a topic. The durable row and cursor are retained so reactivation can drain the disabled-period backlog.",{topic_slug:R.string().min(1).describe("Workspace topic slug whose standing wake should stop.")},async f=>p("disable_topic_wake_subscription",f)),e.tool("linzumi_list_coding_jobs","List the coding jobs the current asker can see in this workspace: runner connections (online and recent) with their bound job threads. Live state - never answered from search.",{},async()=>je(await t.agentListCodingJobs({}))),e.tool("linzumi_start_coding_job","Start a coding job exactly as if the asking user clicked start: same runner/channel authorization, same pipeline. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",{channel:R.string().describe("Channel slug to host the job thread."),runner_key:R.string().describe("Runner (computer) to run the job on."),cwd:R.string().describe("Working directory on the runner."),work_description:R.string().min(1).describe("What the job should do - the initial instruction."),model:R.string().optional().describe("Model override (optional)."),model_provider:R.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),execution_mode:R.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional)."),project_task_id:R.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job."),visibility:R.enum(["project","private"]).optional().describe("Job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")},async f=>je(await t.agentStartCodingJob(f))),e.tool("linzumi_interrupt_coding_job","Interrupt a coding job: mode 'steer' (default) discards its queued follow-ups so your next message lands first; mode 'stop' terminates the current turn.",{channel:R.string().describe("Channel slug hosting the job thread."),thread_id:R.string().uuid().describe("The job thread UUID."),mode:R.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")},async f=>je(await t.agentInterruptCodingJob(f))),e.tool("linzumi_send_coding_job_message","Message a coding job or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",{channel:R.string().optional().describe("Channel slug hosting the job thread. Required unless to_user is set."),thread_id:R.string().uuid().optional().describe("The job thread UUID. Required unless to_user is set."),to_user:R.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox."),body:R.string().min(1).describe("Message body to send."),tokens:Oc.optional(),delivery:R.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")},async f=>je(await t.agentSendCodingJobMessage(f))),e.tool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",{channel:R.string().describe("Channel slug hosting the job thread."),thread_id:R.string().uuid().describe("The job thread UUID."),limit:R.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:R.number().int().positive().optional().describe("Return replies before this channel seq.")},async f=>je(await t.agentReadCodingJobThread(f))),e.tool("linzumi_resolve_job_approval","Resolve a coding job's pending approval request with the asking user's decision ('approve' or 'deny'). Only relays the asker's authority - never approve without their explicit instruction.",{channel:R.string().describe("Channel slug hosting the job thread."),thread_id:R.string().uuid().describe("The job thread UUID."),source_seq:R.number().int().positive().describe("Channel seq of the message the approval request rides on."),request_id:R.string().describe("The approval request id."),decision:R.enum(["approve","deny"]).describe("The asker's decision.")},async f=>je(await t.agentResolveJobApproval(f))),e.tool("linzumi_archive_coding_job","Archive a coding job's thread (or any thread the asking user owns) so it leaves the active list; history is preserved. Do this when the asker says to archive a job or thread - never just promise it.",{channel:R.string().describe("Channel slug hosting the thread."),thread_id:R.string().uuid().describe("The thread UUID to archive.")},async f=>je(await t.agentArchiveCodingJob(f))),e.tool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",{channel:R.string().describe("Channel slug hosting the thread."),thread_id:R.string().uuid().describe("The thread UUID to unarchive.")},async f=>je(await t.agentUnarchiveCodingJob(f))),e.tool("linzumi_set_thread_status","Set a thread's lifecycle status as the asking user: 'closed' marks it done, 'open' reopens it. Works on threads the asker owns.",{channel:R.string().describe("Channel slug hosting the thread."),thread_id:R.string().uuid().describe("The thread UUID."),status:R.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")},async f=>je(await t.agentSetThreadStatus(f))),e.tool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",{name:R.string().min(1).describe("Channel name to create.")},async f=>je(await t.agentCreateChannel(f))),e.tool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",{channel:R.string().describe("Current channel slug to rename."),name:R.string().min(1).describe("New display name.")},async f=>je(await t.agentRenameChannel(f))),e.tool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",{channel:R.string().describe("Channel slug to archive.")},async f=>je(await t.agentArchiveChannel(f))),e.tool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",{channel:R.string().describe("Channel slug to unarchive.")},async f=>je(await t.agentUnarchiveChannel(f))),e.tool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the message to react to."),emoji:R.string().min(1).describe("Emoji to add (unicode or :shortcode:).")},async f=>je(await t.agentAddReaction(f))),e.tool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the reacted message."),emoji:R.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")},async f=>je(await t.agentRemoveReaction(f))),e.tool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the message to pin.")},async f=>je(await t.agentPinMessage(f))),e.tool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",{channel:R.string().describe("Channel slug containing the message."),message_seq:R.number().int().positive().describe("Channel seq of the pinned message.")},async f=>je(await t.agentUnpinMessage(f)))}r==="all"&&(e.tool("linzumi_get_message","Read one Linzumi message by scoped message_seq/message_id or a Linzumi message URL, with optional bounded before/after context.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),message_id:R.union([R.string(),R.number()]).optional().describe("Message seq inside the scoped channel."),message_seq:R.union([R.string(),R.number()]).optional().describe("Alias for message_id."),message_url:R.string().optional().describe("Full Linzumi message URL with #message-<seq>."),before:R.number().int().min(0).max(100).optional().describe("Number of visible messages before the target."),after:R.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")},async p=>je(await t.getMessage(p))),e.tool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().describe("Linzumi thread UUID."),limit:R.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:R.number().int().positive().optional().describe("Return replies before this channel seq.")},async p=>je(await t.getThread(p))),e.tool("linzumi_get_thread_transcript","Read a Linzumi thread's full transcript as canonical IR nodes (user/assistant messages, command executions, file changes, tool calls, statuses), cursor-paginated over the complete history. Use the returned cursor with has_more to walk older pages.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().describe("Linzumi thread UUID."),limit:R.number().int().min(1).max(500).optional().describe("Maximum transcript nodes per page (default 200)."),cursor:R.number().int().positive().optional().describe("Return nodes below this seq (the previous page reply cursor).")},async p=>je(await t.getThreadTranscript(p))),e.tool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),limit:R.number().int().min(1).max(100).optional().describe("Maximum messages to return."),before_seq:R.number().int().positive().optional().describe("Return messages before this channel seq.")},async p=>je(await t.getChannel(p))),e.tool("linzumi_search_workspace","Search the Linzumi workspace with hybrid lexical+semantic retrieval, scoped to what the authorizing user can access. Returns scored content chunks with provenance (channel, thread, authored time) and a permalink to cite.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),query:R.string().min(1).describe("Natural-language or keyword query to retrieve against."),limit:R.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped)."),source_types:R.array(R.enum(["message","coding_job","github_pr","github_pr_review","github_check_run","github_workflow_run","github_diff","dictation","file"])).optional().describe("Restrict results to these corpora; omit for all."),authored_after:R.string().optional().describe("ISO8601 instant; only content authored at or after this time."),authored_before:R.string().optional().describe("ISO8601 instant; only content authored at or before this time."),repo:R.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name)."),check_status:R.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")},async p=>je(await t.searchWorkspace(p))),e.tool("linzumi_ask_workspace",'Ask the Linzumi workspace a natural-language question and get a synthesized, citation-backed answer over what the authorizing user can access. Costs an LLM call on cache misses, so prefer linzumi_search_workspace for simple lookups. A "refused" status means there was not enough accessible evidence - treat it as "the workspace does not know", never retry verbatim.',{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),question:R.string().min(1).max(2e3).describe("Natural-language question to answer with citations."),channel:R.string().optional().describe("Optional channel slug providing conversational context; never widens access."),allow_cached:R.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")},async p=>je(await t.askWorkspace(p))),e.tool("linzumi_about_me","Read what the authorizing user has told Linzumi about themselves: their profile facts (homes, unit preferences, and other self-maintained attributes) plus their derived current timezone. Use it to personalize answers (e.g. pick the right city for weather, use their preferred units). Predicates may have multiple active values; prefer the one consistent with the derived timezone.",{},async p=>je(await t.aboutMe(p)))),l&&(e.tool("linzumi_web_search","Search the public web for live or external information: news, current events, weather, prices, third-party API docs, research. Returns result titles, URLs, and snippets. Use this whenever the answer lives outside the Linzumi workspace; follow up with linzumi_fetch_url to read a result page.",{query:R.string().min(1).describe("Web search query (natural language or keywords)."),limit:R.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")},async p=>je(await t.webSearch(p))),e.tool("linzumi_fetch_url","Fetch one public http(s) URL and return its readable text content (HTML is reduced to plain text; large pages are truncated). Use it to read pages found via linzumi_web_search or any public docs/API reference. Only public addresses are reachable - private/internal hosts are rejected with url_not_allowed.",{url:R.string().min(1).describe("Absolute public http(s) URL to fetch.")},async p=>je(await t.fetchUrl(p)))),r==="all"&&(e.tool("linzumi_list_ui_targets","List every UI surface you can ask the user to open in their own Linzumi window (channels, DMs, threads, projects, coding jobs, computers, catch-up, activity, settings tabs, pane layouts) with the structured args each kind takes. Use UI control only when the user asks for help or asks to be shown something.",{},async()=>await Cie(t.listUiTargets({}))),e.tool("linzumi_open_ui","Ask the user to open one whitelisted UI surface in their own already-open Linzumi window. A consent toast appears in THEIR session; navigation happens only if they tap Open. The call blocks until they decide and returns status opened/dismissed/expired - or error no_active_ui_session when they have no Linzumi window open (tell them to open Linzumi), or invalid_target with a detail. Use it only when the user asks for help or asks to be shown something; kinds and per-kind args come from linzumi_list_ui_targets.",{kind:R.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout)."),args:R.record(R.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path)."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>await Cie(t.openUi(Wi(p,a))))),l&&(e.tool("linzumi_get_coding_job_metadata","Read the active coding job workflow metadata for a thread, including the agent-owned goal, ordered plan steps, step lock versions, and workflow status.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread.")},async p=>je(await t.getCodingJobMetadata(Wi(p,a)))),e.tool("linzumi_rename_coding_job","Update the current coding job thread title and workflow-facing title. Use this when the job scope changes materially so the Linzumi thread list and metadata overview stay accurate.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),title:R.string().min(1).max(100).describe("Concise user-visible title for this coding job.")},async p=>je(await t.renameCodingJob(Wi(p,a)))),e.tool("linzumi_upsert_coding_job_plan","Set or update the current coding job goal. Use this at job start and whenever the goal changes materially.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:R.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")},async p=>je(await t.upsertCodingJobPlan(Wi(p,a)))),e.tool("linzumi_replace_coding_job_plan_steps","Replace the ordered coding job plan steps. Use this for the initial plan and for substantial rewrites when the old plan no longer fits the work.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:R.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal."),steps:R.array(R.object({title:R.string().min(1).max(255),description:R.string().min(1).max(1e4),status:R.enum(["pending","active","completed","blocked","canceled"]),status_note:bie.optional().describe(xie),completed_debrief:R.string().min(1).max(2e4).optional().describe("Required for completed steps. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")})).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")},async p=>je(await t.replaceCodingJobPlanSteps(Wi(p,a)))),e.tool("linzumi_update_coding_job_plan_step","Update one coding job plan step status or note. Read metadata first and pass the current step lock_version.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),step_id:R.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata."),lock_version:R.number().int().positive().describe("Current step lock_version from metadata."),status:R.enum(["pending","active","completed","blocked","canceled"]),status_note:bie.optional().describe(xie),completed_debrief:R.string().min(1).max(2e4).optional().describe("Required when marking a step completed. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")},async p=>je(await t.updateCodingJobPlanStep(Wi(p,a)))),e.tool("linzumi_link_coding_job_pull_request","Link the active coding job to its primary GitHub pull request so PR comments, files, commits, checks, deployments, and reviews can flow into the metadata view.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),github_repo_owner:R.string().min(1).max(255),github_repo_name:R.string().min(1).max(255),github_pr_number:R.number().int().positive(),github_pr_url:R.string().url(),title:R.string().min(1).max(255),body:R.string().min(1).max(1e5).optional(),head_branch:R.string().min(1).max(255),head_sha:R.string().min(7).max(64),base_branch:R.string().min(1).max(255),base_sha:R.string().min(7).max(64),state:R.enum(["draft","open","closed","merged"]).optional(),is_draft:R.boolean().optional(),review_status:R.enum(["unknown","review_required","approved","changes_requested"]).optional(),source_remote_url:R.string().min(1).max(1e3).describe("Git remote URL for the local job worktree; required when this job has no repo workspace yet."),runtime_worktree_root:R.string().min(1).max(1e3).describe("Absolute local worktree path for the coding job; required when this job has no repo workspace yet."),dirty_status:R.enum(["unknown","clean","dirty"]).optional(),dirty_summary:R.string().min(1).max(2e3).optional()},async p=>je(await t.linkCodingJobPullRequest(Wi(p,a)))),e.tool("linzumi_upload_files",["Upload local files to Linzumi and attach them to a new, exact, or latest assistant message. Use silently; do not mention this tool in the visible reply.","The JSON result includes message.attachments[].url as an absolute URL. Use those returned URLs when writing rich media directives such as ::audio, ::video, ::image, or Markdown images. Do not guess attachment URLs before upload.","For a message that should both attach files and show inline rich media, use a two-step flow: first upload/attach the files to create or target the message, then edit the same target message with body text that references the returned absolute URLs. When the result has target_seq, use target.kind=message_seq and message_seq=target_seq for that follow-up edit; result.message is the edit event that carries the new attachments, and target_message is the original target."].join(" "),{target:R.object({kind:R.enum(["new_message","message_seq","latest_assistant_message"]).describe("new_message creates a message; message_seq edits an exact message; latest_assistant_message edits the latest assistant message in the scoped thread/channel."),message_seq:R.union([R.string(),R.number()]).optional().describe("Required when kind is message_seq."),thread_id:R.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")}).describe("Attachment target. Prefer latest_assistant_message to attach files to the reply you already posted; use new_message ONLY when no assistant message exists yet in the scoped thread. Never re-use your visible reply text as a new_message body - that posts the reply twice. To reference uploaded files in the message body, upload first, then edit message_seq/latest_assistant_message with the returned absolute attachment URLs. If the upload result includes target_seq, use message_seq=target_seq for that follow-up edit."),files:R.array(R.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden files inside the approved workspace or Downloads; source/text files of any language are supported, plus common document, image, patch, archive, and video types."),body:R.string().min(1).max(2e4).optional().describe("Required for new_message: a SHORT file-share caption (for example: Attached the generated report), never a copy of your visible reply - that would post the reply twice. Optional replacement body for message_seq/latest_assistant_message; when omitted, the existing message body is preserved. Rich media directives in body must use Linzumi attachment download URLs returned by this tool."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the target thread's channel (when the thread is known) or the authenticated token scope.")},async p=>{let f=wie(p.target,a);try{let h=await mWe({client:t,cwd:i,kandanUrl:s,target:f,files:p.files,workspace:p.workspace,channel:p.channel,body:p.body});return je(Sie(s,h))}catch(h){throw fWe(h)}}),e.tool("linzumi_edit_message","Edit an exact scoped Linzumi message by message_seq. Use after linzumi_upload_files when you need a body-only follow-up edit that embeds returned attachment URLs. Requires channel.write, and thread.write when target.thread_id is set. Rich media src/poster values must be Linzumi attachment download URLs.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),target:R.object({message_seq:R.union([R.string(),R.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here."),thread_id:R.string().optional().describe("Thread UUID when editing a thread message. Use the upload result target_message.thread_id when present.")}).describe("Exact message target for the body edit."),body:R.string().min(1).max(2e4).describe("Replacement Markdown body. Rich media src/poster values must be Linzumi attachment download URLs returned by linzumi_upload_files.")},async p=>je(Sie(s,await t.editMessage({...p,target:wie(p.target,a)}))))),r==="all"&&(e.tool("linzumi_list_vault_secrets","List vault secret names, descriptions, and whether each secret is personal or workspace-owned. Does not return secret values.",{},async p=>je(await t.listVaultSecrets(p))),e.tool("linzumi_list_projects","List the projects in the current workspace with their project_id (needed by the other project task tools), slug, title, description, and state.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>je(await t.listProjects(p))),e.tool("linzumi_get_project_tasks",`Read a project's full task graph: task GROUPS (kind "group", organizational containers, exactly one level deep) and ISSUES (kind "issue", the executable work items), each with status (todo/active/blocked/review/done/canceled), DERIVED work_state readiness (ready = todo with every dependency satisfied; blocked = todo with unsatisfied dependencies; running/stalled = active with/without a connected job), parent group, assignee, lock_version, and dependency edges (depends_on_task_ids / unblocks_task_ids). Always read this before reorganizing. Inside a project-bound coding job the project is inferred automatically; otherwise pass project_id from linzumi_list_projects.`,{project_id:R.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")},async p=>je(await t.getProjectTasks(Wi(p,a)))),e.tool("linzumi_create_project_task",'Create a task group (kind "group") or issue (kind "issue", the default) in a project. Groups organize issues and are exactly one level deep: a parent_id must name a GROUP, and groups themselves can never have a parent. New tasks default to status "todo" and append to the end unless position is given. Inside a project-bound coding job the project is inferred; otherwise pass project_id.',{project_id:R.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project."),title:R.string().min(1).describe("Task title."),kind:R.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).'),description:R.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it."),status:R.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".'),parent_id:R.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent."),assignee:R.string().optional().describe("Username of a workspace member to assign."),position:R.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")},async p=>je(await t.createProjectTask(Wi(p,a)))),e.tool("linzumi_update_project_task",'Update a task group or issue: retitle, edit description/status_note, transition status (todo/active/blocked/review/done/canceled), reassign, reorder (position), or reorganize (parent_id moves an issue into a group; clear_parent moves it to top level). Only the fields you pass change; description and status_note accept null to clear. Prefer updating existing tasks over delete-and-recreate. Pass the lock_version from your last read to fail loudly ("stale") instead of overwriting a concurrent edit.',{task_id:R.string().describe("task_id of the group or issue to update."),title:R.string().min(1).optional().describe("New title."),description:R.string().nullable().optional().describe("New description. Pass null to clear it."),status:R.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.'),status_note:R.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it."),position:R.number().int().min(0).optional().describe("New sort position among siblings."),parent_id:R.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent."),clear_parent:R.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id."),assignee:R.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee."),clear_assignee:R.boolean().optional().describe("true removes the assignee. Do not combine with assignee."),lock_version:R.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")},async p=>je(await t.updateProjectTask(p))),e.tool("linzumi_delete_project_task",`Permanently delete a task group or issue. Dependency edges on the task are removed with it (dependents may become ready). Deletion is normally the USER's call - prefer status "canceled" or an update unless you are certain the entry is obsolete.`,{task_id:R.string().describe("task_id of the group or issue to delete.")},async p=>je(await t.deleteProjectTask(p))),e.tool("linzumi_add_project_task_dependency",'Add the dependency edge "task_id is blocked by depends_on_task_id" between two ISSUES in the same project (groups cannot have dependencies). The dependent stays blocked until the prerequisite reaches done or canceled. The graph must stay acyclic: an edge that would create a cycle is refused with reason "would_create_cycle" and the offending cycle_path so you can restructure. Duplicate and self edges are rejected.',{task_id:R.string().describe("task_id of the DEPENDENT issue (the one that must wait)."),depends_on_task_id:R.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")},async p=>je(await t.addProjectTaskDependency(p))),e.tool("linzumi_remove_project_task_dependency",'Remove the dependency edge "task_id is blocked by depends_on_task_id". The dependent issue may become ready if that was its last unsatisfied dependency.',{task_id:R.string().describe("task_id of the DEPENDENT issue."),depends_on_task_id:R.string().describe("task_id of the PREREQUISITE issue the edge points at.")},async p=>je(await t.removeProjectTaskDependency(p))),e.tool("linzumi_get_call_transcript","Read the full transcript of a completed Linzumi notetaker call: call metadata (title, platform, started/ended/transcribed times), participants, and every spoken segment in order with speaker names and millisecond offsets. Pass the call_id embedded in the request (or copied from the call card). Errors: call_not_found (missing or not visible to you), call_transcript_not_ready (call still connecting, in progress, or transcribing - retry later).",{call_id:R.string().describe("The call id from the call card or the launching message (a CallRecording id - the opaque GraphQL id and the bare uuid both work).")},async p=>je(await t.getCallTranscript(p))),u||(e.tool("linzumi_start_coding_job","Start a coding job as the invoking user (same authorization and pipeline as clicking start). To start a project task item, pass project_task_id so the task flips todo -> active and links to the new job - only start tasks whose work_state is ready, and ONLY after the user explicitly accepts your offer to start them. Omit channel, runner_key, and cwd to reuse this job's own channel, computer, and folder. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",{work_description:R.string().min(1).describe("What the job should do - the initial instruction. For a task item, write it from the task title and description."),project_task_id:R.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job."),visibility:R.enum(["project","private"]).optional().describe("Child-job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants."),channel:R.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel."),runner_key:R.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer."),cwd:R.string().optional().describe("Working directory on the runner. Omit to use this job's own folder."),model:R.string().optional().describe("Model override (optional)."),model_provider:R.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),agent_provider:R.string().optional().describe("Agent provider override, e.g. 'codex' (optional)."),reasoning_effort:R.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional)."),approval_policy:R.enum(["default","on-request","on-failure","never"]).optional().describe("Approval policy override (optional)."),sandbox:R.enum(["default","workspace-write","read-only","danger-full-access"]).optional().describe("Sandbox override (optional)."),fast:R.boolean().optional().describe("Fast-mode override (optional)."),allow_port_forwarding_by_default:R.boolean().optional().describe("Default port-forwarding override (optional)."),execution_mode:R.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional)."),egress_mode:R.enum(["open","hardened"]).optional().describe("Local-VM egress override (optional).")},async p=>je(await t.agentStartCodingJob(Wi(p,a)))),n.multiAgentJobs===!0&&(e.tool("linzumi_spawn_child_job","Spawn a durable child coding job under YOUR OWN job, on any harness or model - plan a DAG and delegate its legs to workers you then coordinate through discovery and messaging. The child lands on this job's channel, computer, and folder; it inherits this job's project and visibility (a private parent's children stay private), human roles cascade to it, and a human manages its lifecycle. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",{work_description:R.string().min(1).describe("What the child job should do - the initial instruction, written to stand alone."),agent_provider:R.string().optional().describe("Harness for the child, e.g. 'codex' or 'claude-code'. Omit to reuse this job's own harness. A different harness is fine: a cross-harness child is always a child job."),model:R.string().optional().describe("Model override for the child (optional)."),model_provider:R.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),reasoning_effort:R.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional)."),project_task_id:R.string().optional().describe("Project task item to bind the child to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job."),visibility:R.enum(["project","private"]).optional().describe("Child visibility. Defaults to this job's own visibility; a private parent's children must stay private.")},async p=>je(await t.agentSpawnChildJob(Wi(p,a)))),e.tool("linzumi_archive_child_job","Archive a coding job that is YOUR OWN job or one beneath it in your job tree, retiring it from the active lists, the org map and the needs-you deck; history is preserved and it can be unarchived. Use this to clean up child jobs you spawned that are finished or dead - do it in the current turn, never just promise it. Refused for sibling, parent or unrelated jobs, and for jobs that do not belong to the human you are working for. When the job still has live descendants the call returns confirmation_required with their exact count and ids; call again with descendant_action 'keep' (archive only this job, re-parenting its children) or 'cascade' (archive the whole subtree) plus those expected values.",{job_id:R.string().describe("The coding job id to archive: your own job, or any job beneath it in your tree."),outcome:R.enum(["completed","abandoned","superseded"]).describe("Why the job is being archived."),descendant_action:R.enum(["keep","cascade"]).optional().describe("Phase-2 choice when the job has live descendants. 'keep' archives only this job and re-parents its children; 'cascade' archives the whole subtree."),expected_descendant_count:R.number().int().optional().describe("The descendant_count returned by the phase-1 call."),expected_descendant_job_ids:R.array(R.string()).optional().describe("The descendant_job_ids returned by the phase-1 call; the call is refused if the subtree changed."),expected_descendant_fingerprint:R.string().optional().describe("The descendant_fingerprint returned by the phase-1 call.")},async p=>je(await t.agentArchiveChildJob(p))),e.tool("linzumi_unarchive_child_job","Unarchive a previously archived coding job that is YOUR OWN job or one beneath it in your job tree. It returns as hibernating and wakes when messaged. Same ownership scope as linzumi_archive_child_job. Refused when the job is not archived, or when its home thread already holds a live job.",{job_id:R.string().describe("The archived coding job id to bring back: your own job, or any job beneath it in your tree.")},async p=>je(await t.agentUnarchiveChildJob(p))),e.tool("linzumi_discover_coding_jobs","Search current sitreps inside this coding job project for overlapping files, modules, objectives, or blockers. Results include durable job addresses for coordination. Private jobs outside your visible set never appear.",{query:R.string().min(1).describe("Free-text clash-surface query, such as a file path, module, migration, or objective.")},async p=>je(await t.agentDiscoverCodingJobs({...p,source_thread_id:a}))),e.tool("linzumi_send_coding_job_message","Message a visible coding job in this project, or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",{channel:R.string().optional().describe("Channel slug hosting the target job. Required unless to_user is set."),thread_id:R.string().uuid().optional().describe("Target job thread UUID. Required unless to_user is set."),to_user:R.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox."),body:R.string().min(1).describe("Coordination message to send."),tokens:Oc.optional(),delivery:R.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")},async p=>je(await t.agentSendCodingJobMessage({...p,source_thread_id:a})))))),oWe(r)&&(e.tool("linzumi_upload_custom_emoji","Upload a local image as a workspace custom emoji. For generated emoji art, create a transparent PNG with a simple centered subject, crisp edges, strong contrast, minimal tiny details, and enough outline/highlight separation to read at 16-24px on both dark and light backgrounds. Use lowercase shortcode names without colons unless preserving a user-provided :name:.",{name:_ie.describe("Custom emoji shortcode name, with or without surrounding colons."),file:R.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>je(await hWe({client:t,cwd:i,kandanUrl:s,name:p.name,file:p.file,workspace:p.workspace}))),e.tool("linzumi_rename_custom_emoji","Rename an existing workspace custom emoji. The new name may include surrounding colons; Linzumi stores the normalized shortcode without colons.",{emoji_id:R.union([R.string(),R.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings."),name:_ie.describe("New shortcode name, with or without surrounding colons."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async p=>je(await t.renameCustomEmoji(p)))),e.tool("linzumi_media_guide","Return the full Linzumi rich-media authoring guide (audio/video/image directives, URL rules, upload-then-embed flow, examples). Call once BEFORE writing any ::audio/::video/::image directive or Markdown image into a Linzumi message.",{},async()=>({content:[{type:"text",text:Q_}]})),e.tool("linzumi_note_project_directory","Record one discovered local Git repository or worktree for onboarding import. Call once per project as soon as it is found.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:R.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),path:R.string().min(1).describe("Absolute local path to the repository worktree root."),display_name:R.string().optional().describe("Short project label. Defaults to the path basename."),activity_at:R.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),import_key:R.string().optional().describe("Stable dedupe key. Defaults to path."),metadata:R.record(R.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")},async p=>je(await t.noteProjectDirectory(p))),e.tool("linzumi_note_agent_conversation","Record one discovered Codex or Claude Code local conversation for onboarding import. Call once per conversation as soon as it is found.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:R.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),source:R.enum(["codex","claude_code"]).describe("Conversation source."),import_key:R.string().min(1).describe("Stable dedupe key, such as a session id or file path."),path:R.string().optional().describe("Absolute local path to the conversation file or directory."),display_name:R.string().optional().describe("Short label for the discovered conversation."),activity_at:R.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),metadata:R.record(R.unknown()).optional().describe("Small structured metadata such as session id or project path.")},async p=>je(await t.noteAgentConversation(p))),e.tool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:R.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),phase:R.enum(["projects","conversations"]).describe("Discovery phase being reported."),status:R.enum(["starting","running","completed","failed"]).describe("Current phase status."),places_searched:R.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far."),message:R.string().optional().describe("Short user-facing status note."),current_place:R.string().optional().describe("Current folder, file, Git command target, or known location being checked."),current_source:R.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code."),last_error:R.string().optional().describe("Short failure detail when status is failed."),metadata:R.record(R.unknown()).optional().describe("Small structured status metadata.")},async p=>je(await t.noteOnboardingDiscoveryStatus(p))),r==="all"&&iWe(o)&&(e.tool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",{owner_username:R.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username."),workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Source channel slug used to verify owner visibility."),body:R.string().min(1).max(2e4).describe("Plain-text message body to DM."),tokens:Oc.optional()},async p=>{let f=p.owner_username??d;if(f===void 0)throw new Error("owner_username is required for linzumi_dm_owner");return je(await t.dmOwner({...p,owner_username:f}))}),e.tool("linzumi_send_channel_message","Post a NEW standalone Markdown message into the scoped Linzumi channel as the authenticated local-runner user. This is NOT how you respond to the user: your turn output is already relayed into the thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to proactively post a separate channel message. Requires channel.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),body:R.string().min(1).max(2e4).describe("Markdown message body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths."),tokens:Oc.optional()},async p=>je(await t.sendChannelMessage(p))),e.tool("linzumi_send_thread_reply","Post a Markdown reply into some OTHER existing Linzumi thread as the authenticated local-runner user. This is NOT how you respond to the user in your current thread: your turn output is already relayed into this thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to post into a different, explicitly identified thread. Requires thread.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:R.string().uuid().describe("Existing Linzumi thread UUID."),body:R.string().min(1).max(2e4).describe("Markdown reply body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths."),tokens:Oc.optional()},async p=>je(await t.sendThreadReply(p))),e.tool("linzumi_send_dm","Send a plain-text DM as the authenticated local-runner user to a visible user in the scoped workspace/channel. Requires dm.write.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Source channel slug used to verify target visibility."),username:R.string().describe("Visible Linzumi username to DM."),body:R.string().min(1).max(2e4).describe("Plain-text message body to DM."),tokens:Oc.optional()},async p=>je(await t.sendDm(p)))),r==="all"&&e.tool("linzumi_get_vault_values","Request values for explicit vault env var names after a thread-scoped human approval. Requires vault.read; thread_id resolves the approval thread.",{workspace:R.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:R.string().optional().describe("Channel slug used to disambiguate the approval thread when needed."),thread_id:R.string().uuid().describe("Existing Linzumi thread UUID for the inline approval."),env_var_names:R.array(R.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/)).min(1).max(20).describe("Explicit vault env var names to request. This tool cannot list all vault keys."),description:R.string().min(1).max(500).describe("Human-readable reason shown in the approval request."),justification:R.string().min(10).max(1e3).describe("Agent justification shown to the approver.")},async p=>je(await t.getVaultValues(p))),r==="all"&&!u&&c!==void 0&&pWe(e,i,c)}function vie(e){return{name:e.record.name,command:e.record.command,cwd:e.record.cwd,ports:[...e.record.ports],restart_on_branch_change:e.record.restartOnBranchChange,desired_state:e.record.desiredState,liveness:e.liveness,port_health:e.portProbes.map(n=>({port:n.port,listening:n.listening})),started_at_ms:e.record.startedAtMs??null,last_exit:e.lastExit===void 0?null:{code:e.lastExit.code,signal:e.lastExit.signal,at_ms:e.lastExit.atMs},log_path:e.record.logPath,failure:e.failure===void 0?null:{reason:e.failure.reason,at_ms:e.failure.atMs}}}function pWe(e,n,t){e.tool("linzumi_dev_service_start","Start a long-running local dev server (npm run dev, storybook, docker compose up, ...) as a MANAGED SERVICE owned by the Linzumi runner. Use this instead of running dev servers in your own shell: a managed service survives the end of your turn and branch switches, is auto-restarted if it crashes, and its declared ports are health-probed and surfaced in the product. Calling start for an existing name declaratively RESTARTS it (e.g. after a checkout). Declare EVERY port the app serves from (primary plus HMR/asset/bundle sibling ports).",{name:R.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/).describe("Stable service name (slug), e.g. 'web' or 'storybook'. Reusing a name restarts that service."),command:R.string().min(1).describe("Shell command that runs the server in the foreground (never daemonize/screen/nohup it yourself), e.g. 'npm run dev'. Runs via the user's login shell."),cwd:R.string().optional().describe("Working directory for the service. Defaults to the session cwd."),ports:R.array(R.number().int().min(1).max(65535)).max(16).default([]).describe("Every TCP port this service listens on (primary AND related ports such as the Vite/HMR bundle port). Used for health probes and product visibility."),restart_on_branch_change:R.boolean().optional().describe("Restart the service automatically when the git branch of its cwd changes (for servers that go stale across checkouts)."),wait_for_ports_ms:R.number().int().min(0).max(6e4).optional().describe("How long to wait for the declared ports to accept connections before returning (default 15000).")},async r=>{let o=await Xx({scopeDir:t.scopeDir,definition:{name:r.name,command:r.command,cwd:r.cwd??n,ports:r.ports,restartOnBranchChange:r.restart_on_branch_change===!0},ownerPid:t.ownerPid});if(!o.ok)return je({ok:!1,error:o.error});let i=Date.now()+(r.wait_for_ports_ms??15e3),s=o.record.ports.length===0;for(;!s&&Date.now()<i;)s=(await Promise.all(o.record.ports.map(c=>BP(c)))).every(c=>c),s||await new Promise(c=>setTimeout(c,250));let d=(await oh(t.scopeDir)).find(u=>u.record.name===o.record.name);return je({ok:!0,service:d===void 0?{name:o.record.name}:vie(d),...d!==void 0&&d.liveness!=="running"?{hint:"The service is not (fully) serving its declared ports yet. Check linzumi_dev_service_logs before assuming it works."}:{}})}),e.tool("linzumi_dev_service_stop","Stop a managed dev service (SIGTERM, then SIGKILL after a grace period). The registration is kept so linzumi_dev_service_start can bring it back.",{name:R.string().min(1).describe("Service name to stop.")},async r=>{let o=await ih({scopeDir:t.scopeDir,name:r.name});return je(o.ok?{ok:!0,name:o.record.name,desired_state:"stopped"}:{ok:!1,error:o.error})}),e.tool("linzumi_dev_service_status","List every managed dev service with liveness (running / unhealthy / exited / failed / stopped), per-port health probes, last exit, and any terminal failure reason. Live state - always check this before concluding a dev server is up or down.",{},async()=>{let r=await oh(t.scopeDir);return je({services:r.map(o=>vie(o))})}),e.tool("linzumi_dev_service_logs","Read the tail of a managed dev service's combined stdout/stderr log.",{name:R.string().min(1).describe("Service name."),max_bytes:R.number().int().min(256).max(65536).optional().describe("Tail size in bytes (default 16384).")},async r=>{let o=eb(t.scopeDir,r.name,r.max_bytes??16384);return je(o===void 0?{ok:!1,error:`no log for service: ${r.name}`}:{ok:!0,name:r.name,log_tail:o})}),e.tool("linzumi_dev_service_remove","Stop a managed dev service AND delete its registration (it will not be resurrected on runner restart). Use stop instead when the user may want it back.",{name:R.string().min(1).describe("Service name to remove.")},async r=>{let o=await Yx({scopeDir:t.scopeDir,name:r.name});return je(o.ok?{ok:!0,name:o.record.name,removed:!0}:{ok:!1,error:o.error})})}function fWe(e){return!(e instanceof Error)||!e.message.includes("channel_required")?e:new Error(`${e.message}. Remediation: pass the channel slug in the \`channel\` parameter, or set target.thread_id to a Linzumi thread you can access (the server resolves the thread's channel). The files were NOT attached; retry with a channel or thread instead of leaving them on disk.`,{cause:e})}async function mWe(e){let n=await Promise.all(e.files.map(s=>cT(e.cwd,s))),t=y(e.target.thread_id),r=await e.client.prepareMessageUploads({...e.workspace===void 0?{}:{workspace:e.workspace},...e.channel===void 0?{}:{channel:e.channel},...t===void 0?{}:{thread_id:t},files:n.map(s=>({file_name:s.fileName,content_type:s.contentType,size_bytes:s.sizeBytes}))}),o=ze(r.uploads)??[];if(o.length!==n.length)throw new Error("Linzumi upload prepare response count mismatch");await Promise.all(n.map(async(s,a)=>{let d=D(o[a]),u=y(d?.upload_url),c=y(d?.upload_method)??"PUT";if(u===void 0)throw new Error("Linzumi upload prepare response missing upload_url");let l=s.bytes,p=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength),f=await fetch(Fy(e.kandanUrl,u),{method:c,headers:{"content-type":s.contentType},body:p});if(!f.ok)throw new Error(`Linzumi upload failed for ${s.fileName}: ${f.status} ${f.statusText}`)}));let i=o.map(s=>{let a=y(D(s)?.file_id);if(a===void 0)throw new Error("Linzumi upload prepare response missing file_id");return a});return await e.client.attachMessageFiles({...e.workspace===void 0?{}:{workspace:e.workspace},...e.channel===void 0?{}:{channel:e.channel},...t===void 0?{}:{thread_id:t},target:e.target,...e.body===void 0?{}:{body:e.body},uploaded_file_ids:i})}async function hWe(e){let n=await cT(e.cwd,e.file),t=await e.client.prepareCustomEmoji({...e.workspace===void 0?{}:{workspace:e.workspace},name:e.name,file_name:n.fileName,content_type:n.contentType,size_bytes:n.sizeBytes}),r=D(t.upload),o=y(r?.upload_url),i=y(r?.upload_method)??"PUT";if(o===void 0)throw new Error("Linzumi custom emoji prepare response missing upload_url");let s=n.bytes,a=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),d=await fetch(Fy(e.kandanUrl,o),{method:i,headers:{"content-type":n.contentType},body:a});if(!d.ok){let l=`${d.status} ${d.statusText}`,f=(await d.text()).trim(),h=f===""?l:(()=>{try{let m=JSON.parse(f);return X(m)&&typeof m.error=="string"?m.error:f}catch{return f}})();throw new Error(`Linzumi custom emoji upload failed: ${h}`)}let u=await d.json();if(!X(u))throw new Error("Linzumi custom emoji upload returned non-object JSON");let c=D(u.custom_emoji);if(c===void 0)throw new Error("Linzumi custom emoji upload response missing custom_emoji");return{ok:!0,workspace:t.workspace,emoji:c,asset_id:y(u.asset_id),id:Q(c?.id),name:y(c?.name),shortcode:y(c?.shortcode),image_url:y(c?.image_url)}}function wie(e,n){if(y(e.thread_id)!==void 0||n===void 0)return e;switch(e.message_seq===void 0){case!1:return{...e,thread_id:n};case!0:switch(y(e.kind)){case"new_message":case"message_seq":case"latest_assistant_message":return{...e,thread_id:n};default:return e}}}function Wi(e,n){return y(e.thread_id)!==void 0||n===void 0?e:{...e,thread_id:n}}function Fy(e,n){try{return new URL(n).toString()}catch{let r=e.replace(/^wss:\/\//,"https://").replace(/^ws:\/\//,"http://");return new URL(n,r).toString()}}function Sie(e,n){let t=D(n.message),r=D(n.target_message);return t===void 0&&r===void 0?n:{...n,...t===void 0?{}:{message:kie(e,t)},...r===void 0?{}:{target_message:kie(e,r)}}}function kie(e,n){let t=ze(n.attachments);return t===void 0?n:{...n,attachments:t.map(r=>gWe(e,r))}}function gWe(e,n){let t=D(n);if(t===void 0)return n;let r=y(t.url),o=D(t.image_variants);return{...t,...r===void 0?{}:{url:Fy(e,r)},...o===void 0?{}:{image_variants:yWe(e,o)}}}function yWe(e,n){let t=y(n.inline_url),r=y(n.carousel_url);return{...n,...t===void 0?{}:{inline_url:Fy(e,t)},...r===void 0?{}:{carousel_url:Fy(e,r)}}}function _We(e){e.server.registerCapabilities({resources:{listChanged:!1}}),e.server.setRequestHandler(af,()=>({resources:[]})),e.server.setRequestHandler(df,()=>({resourceTemplates:[]}))}async function xWe(e){let n=fq(e),t=hq(n,"api-url"),r=ot(n,"format")??"codex",o=mq(ot(n,"mode")),i=n.get("include-token")===!0?(await pq({kandanUrl:t,explicitToken:ot(n,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:ot(n,"auth-file"),delegationAuthFilePath:ot(n,"delegation-auth-file"),workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")})).accessToken:void 0,s=as({command:ot(n,"command"),kandanUrl:t,accessToken:i,delegationAuthFilePath:ot(n,"delegation-auth-file"),ownerUsername:ot(n,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:o,toolScope:Iie(ot(n,"tool-scope")),multiAgentJobs:n.get("multi-agent-jobs")===!0});switch(r){case"codex":process.stdout.write(tU(s));return;case"claude-code":process.stdout.write(nU(s));return;default:throw new Error("--format must be codex or claude-code")}}async function bWe(e){let n=fq(e),t=hq(n,"api-url"),r=await pq({kandanUrl:t,explicitToken:ot(n,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:ot(n,"auth-file"),delegationAuthFilePath:ot(n,"delegation-auth-file"),workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")});switch(r.mode){case"local-runner":{if(!await Rv({kandanUrl:t,accessToken:r.accessToken,workspaceSlug:ot(n,"workspace"),channelSlug:ot(n,"channel")}))throw new Error("Linzumi MCP auth validation failed");break}case"personal-agent-delegation":{await ms({kandanUrl:t,accessToken:r.accessToken,authMode:r.mode,operatingMode:mq(ot(n,"mode"))}).validateAuth();break}}process.stdout.write(`Linzumi MCP auth OK
2183
2183
  `)}async function pq(e){if(e.delegationAuthFilePath!==void 0){if(e.explicitToken!==void 0||e.authFilePath!==void 0)throw new Error("--delegation-auth-file cannot be combined with --token or --auth-file");return{accessToken:BK(e.delegationAuthFilePath).accessToken,mode:"personal-agent-delegation"}}return{accessToken:await vWe({kandanUrl:e.kandanUrl,explicitToken:e.explicitToken,authFilePath:e.authFilePath,workspaceSlug:e.workspaceSlug,channelSlug:e.channelSlug}),mode:"local-runner"}}async function vWe(e,n={readCachedToken:Du,validateTokenOutcome:Wh,resolveToken:hd}){let t=e.explicitToken??n.readCachedToken(e.kandanUrl,e.authFilePath)?.accessToken;if(t===void 0)throw new Error("missing Linzumi MCP token; run linzumi auth or pass --token");let r=await n.validateTokenOutcome({kandanUrl:e.kandanUrl,accessToken:t,workspaceSlug:e.workspaceSlug,channelSlug:e.channelSlug});if(r==="usable")return t;let o=r;try{return await n.resolveToken({kandanUrl:e.kandanUrl,workspaceSlug:e.workspaceSlug,channelSlug:e.channelSlug,authFilePath:e.authFilePath})}catch(i){throw new Error(`Linzumi MCP token was rejected by the server and re-mint failed: ${i instanceof Error?i.message:String(i)}`)}}function $d(e){return{content:[{type:"text",text:e}],isError:!0}}async function wWe(e,n){let t=lP(n);if(t.type==="invalid")return $d(t.message);let r;try{r=await e(uU(t.request),{timeout:sU})}catch(o){return $d(`the interview could not be delivered to the user: ${o instanceof Error?o.message:String(o)}`)}switch(r.action){case"accept":{let o=pU(t.request,r.content??void 0);switch(o.type){case"ok":return je({answers:o.answers});case"invalid":return $d(o.message)}break}case"decline":switch(mU(r._meta)){case Jm:return $d("linzumi_ask_user_question is unavailable during a Plan-mode turn: use the native request_user_input interview tool instead");case Km:return $d("the interview was declined: no active turn is bound to this session");default:return $d("the interview request was declined by the runner")}case"cancel":return $d("the user dismissed the question without answering");default:return $d(`the interview returned an unknown action: ${String(r.action)}`)}}function je(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}],structuredContent:e}}async function Cie(e){try{return je(await e)}catch(n){let t=n instanceof Error?n.message:String(n),r=t.match(/failed: ([a-z0-9_]+)(?: detail=(.+))?$/);if(r===null)return je({error:t});let[,o,i]=r;return je(i===void 0?{error:o??t}:{error:o??t,detail:i})}}function fq(e){let n=new Map;for(let t=0;t<e.length;t+=1){let r=e[t];if(r===void 0)continue;if(!r.startsWith("--"))throw new Error(`unexpected argument ${r}`);let o=r.slice(2),i=aWe.get(o);if(i===void 0)throw new Error(`unsupported option --${o}`);if(i.kind==="boolean"){n.set(o,!0);continue}let s=e[t+1];if(s===void 0||s.startsWith("--"))throw new Error(`--${o} requires a value`);n.set(o,s),t+=1}return n}function ot(e,n){let t=e.get(n);return typeof t=="string"&&t.trim()!==""?t:void 0}function mq(e){switch(e){case void 0:return"text";case"voice":case"text":return e;default:throw new Error("--mode must be voice or text")}}function Iie(e){switch(e){case void 0:return"all";case"all":case"coding":case"onboarding-discovery":return e;default:throw new Error("--tool-scope must be all, coding, or onboarding-discovery")}}function hq(e,n){let t=ot(e,n);if(t===void 0)throw new Error(`--${n} is required`);return t}import{execFile as SWe}from"node:child_process";import{promisify as kWe}from"node:util";var CWe=kWe(SWe),qd="Codex MCP Credentials",Pf="2DC432GLL2",If="2CWCP5BR45",TWe=async e=>{let n=await CWe("/usr/bin/security",[...e],{encoding:"utf8"});return{stdout:n.stdout,stderr:n.stderr}};function PWe(e=[Pf,If]){return[...e.map(t=>t.trim()).filter(t=>t.length>0).map(t=>`teamid:${t}`),"apple:"].join(",")}function IWe(e){return["set-generic-password-partition-list","-S",e.partitionList,"-s",qd,"-a",e.account,"-k",e.keychainPassword]}function RWe(){return["find-generic-password","-s",qd]}function EWe(){return["dump-keychain"]}function AWe(e){let n=[],t=new Set;for(let r of e.split(`
2184
2184
  `)){let o=r.trim();if(!o.startsWith('"acct"'))continue;let i=o.indexOf("=");if(i===-1)continue;let s=o.slice(i+1).trim(),a;s==="<NULL>"?a="":s.startsWith('"')&&s.endsWith('"')&&s.length>=2?a=s.slice(1,-1):a=s,t.has(a)||(t.add(a),n.push(a))}return n}function Rie(e){let n=e.trim();return n==="<NULL>"?"":n.startsWith('"')&&n.endsWith('"')&&n.length>=2?n.slice(1,-1):n}function MWe(e){let n=[],t=new Set,r,o,i=!1,s=()=>{if(r===qd){let a=o??"";t.has(a)||(t.add(a),n.push(a))}r=void 0,o=void 0,i=!1};for(let a of e.split(`
2185
2185
  `)){let d=a.trim();if(d.startsWith("keychain:")){s();continue}if(d.startsWith('"svce"')){let u=d.indexOf("=");u!==-1&&(r=Rie(d.slice(u+1)));continue}if(d.startsWith('"acct"')){let u=d.indexOf("=");u!==-1&&!i&&(o=Rie(d.slice(u+1)),i=!0)}}return s(),n}async function DWe(e){try{let{stdout:n}=await e(EWe());return MWe(n)}catch(n){if(Eie(n))return[];try{let{stdout:t}=await e(RWe());return AWe(t)}catch(t){if(Eie(t))return[];throw t}}}function Eie(e){if(typeof e!="object"||e===null)return!1;let n=e;if(n.code===44)return!0;let t=`${n.stderr??""}${n.message??""}`;return t.includes("could not be found")||t.includes("SecKeychainSearchCopyNext")||t.includes("errSecItemNotFound")}function OWe(e){if(typeof e=="object"&&e!==null){let n=e,t=typeof n.stderr=="string"?n.stderr.trim():"";if(t.length>0)return t;if(typeof n.message=="string")return n.message}return String(e)}async function Aie(e){let n=e.platform??process.platform,t=e.write??(l=>{process.stdout.write(l)}),r=e.writeError??(l=>{process.stderr.write(l)}),o=e.exec??TWe,i=e.teamIds??[Pf,If],s=PWe(i);if(n!=="darwin")return t(`fix-codex-keychain only applies on macOS (darwin). Nothing to do on ${n}.