@linzumi/cli 1.0.45 → 1.0.47

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.
@@ -148,7 +148,7 @@ Open: ${r.verificationUri}
148
148
  </main>
149
149
  </body>
150
150
  </html>`}function Ql(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function dT(t){return t.replace(/[&^|<>()%"]/g,e=>`^${e}`)}function pT(t){let e=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",r=process.platform==="win32"?["/c","start","",dT(t)]:[t];return new Promise(n=>{Xl("process.spawn",{command:e,args:r,purpose:"oauth.open_browser"});let o=Kz(e,r,{stdio:"ignore",detached:!0});Xl("process.spawned",{command:e,args:r,pid:o.pid,purpose:"oauth.open_browser"}),o.on("error",()=>n()),o.on("spawn",()=>{o.unref(),n()})})}function gy(){return yT(hT(),".linzumi","auth.json")}function ga(t,e=gy()){if(!ed(e))return;let r=rd(td(e,"utf8")),n=xt(t),o=r.local_codex_runner?.[n];if(!(o===void 0||o.access_token.trim()==="")&&!(o.expires_at!==void 0&&Date.parse(o.expires_at)<=Date.now()))return{accessToken:o.access_token,kandanBaseUrl:n,issuedAt:o.issued_at,expiresAt:o.expires_at}}function yy(t){if(!ed(t))throw new Error(`missing personal-agent delegation auth file: ${t}`);let r=rd(td(t,"utf8")).personal_agent_delegation;if(r===void 0||r.access_token.trim()==="")throw new Error("personal-agent delegation auth file is missing access_token");if(r.expires_at!==void 0&&Date.parse(r.expires_at)<=Date.now())throw new Error("personal-agent delegation auth file token is expired");return{accessToken:r.access_token,issuedAt:r.issued_at,expiresAt:r.expires_at}}function _y(t){let e=t.authFilePath??gy(),r=ed(e)?rd(td(e,"utf8")):{version:1},n=xt(t.kandanUrl),o=new Date,s=t.expiresInSeconds===void 0?void 0:new Date(o.getTime()+t.expiresInSeconds*1e3).toISOString(),a={...r,version:1,local_codex_runner:{...r.local_codex_runner??{},[n]:{access_token:t.accessToken,issued_at:o.toISOString(),expires_at:s}}};return mT(gT(e),{recursive:!0}),fT(e,`${JSON.stringify(a,null,2)}
151
- `,"utf8"),{accessToken:t.accessToken,kandanBaseUrl:n,issuedAt:o.toISOString(),expiresAt:s}}function rd(t){let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("Kandan auth cache must contain a JSON object");let r=e,n=r.local_codex_runner,o=r.personal_agent_delegation;if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw new Error("Kandan auth cache local_codex_runner must be an object");if(o!==void 0&&(typeof o!="object"||o===null||Array.isArray(o)))throw new Error("Kandan auth cache personal_agent_delegation must be an object");return{version:1,local_codex_runner:bT(n),personal_agent_delegation:_T(o)}}function _T(t){if(typeof t!="object"||t===null||Array.isArray(t))return;let e=t.access_token,r=t.issued_at,n=t.expires_at;if(!(typeof e!="string"||typeof r!="string"))return{access_token:e,issued_at:r,expires_at:typeof n=="string"?n:void 0}}function bT(t){if(!(typeof t!="object"||t===null||Array.isArray(t)))return Object.fromEntries(Object.entries(t).flatMap(([e,r])=>{if(typeof r!="object"||r===null||Array.isArray(r))return[];let n=r.access_token,o=r.issued_at,s=r.expires_at;return typeof n!="string"||typeof o!="string"?[]:[[e,{access_token:n,issued_at:o,expires_at:typeof s=="string"?s:void 0}]]}))}async function by(t,e={readCachedToken:ga,validateToken:zo,acquireAndCacheToken:kT}){if(t.explicitToken!==void 0)return t.explicitToken;let r=e.readCachedToken(t.kandanUrl,t.authFilePath);if(r!==void 0){let o=await e.validateToken({kandanUrl:t.kandanUrl,accessToken:r.accessToken,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,requiredScopes:t.requiredScopes});if(o==="usable")return r.accessToken;t.reportRejectedCachedToken?.(o)}let n=await e.acquireAndCacheToken(t);return t.workspaceSlug!==void 0&&await vT(t,e,n),n}async function vT(t,e,r){let n;try{n=await e.validateToken({kandanUrl:t.kandanUrl,accessToken:r,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,requiredScopes:t.requiredScopes})}catch{return}if(n==="not_found")throw new Error(wT(t))}function wT(t){let e=new URL(xt(t.kandanUrl)).host;return`Workspace '${t.workspaceSlug}' was not found on ${e}. Sign in to the web app to create it, then re-run connect.`}async function kT(t){let e=t.authMode??{kind:"browser",callbackHost:t.callbackHost},r=e.kind==="device"?await fy({kandanUrl:t.kandanUrl,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,onboarding:t.onboarding}):await my({kandanUrl:t.kandanUrl,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,onboarding:t.onboarding,callbackHost:e.callbackHost??t.callbackHost});return _y({kandanUrl:t.kandanUrl,accessToken:r.accessToken,expiresInSeconds:r.expiresInSeconds,authFilePath:t.authFilePath}),r.accessToken}import{readFile as _C,realpath as od,stat as xT,writeFile as bC,mkdir as vC}from"node:fs/promises";import{homedir as $T}from"node:os";import{basename as ST,extname as zT,isAbsolute as wy,join as xC,relative as ky,resolve as nd}from"node:path";function tr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $t(t){return t!==void 0&&tr(t)?t:void 0}function ya(t){return Array.isArray(t)?t:void 0}function Te(t){return typeof t=="string"&&t.trim()!==""?t.trim():void 0}function vy(t){return typeof t=="number"&&Number.isInteger(t)?t:void 0}var TT=new Set([".csv",".diff",".gif",".htm",".html",".jpeg",".jpg",".json",".jsonl",".log",".md",".mp4",".patch",".pdf",".png",".svg",".txt",".webm",".webp",".xml",".zip"]);async function sd(t,e){let r=await od(t),n=await RT(r),o=await PT(r,e);jT(n,o);let s=await xT(o);if(!s.isFile())throw new Error(`Linzumi upload path is not a file: ${o}`);return{path:o,fileName:ST(o),contentType:ET(o),sizeBytes:s.size}}async function PT(t,e){if(e==="")throw new Error("Kandan attachment path must not be empty");let r=wy(e)?nd(e):nd(t,e);return await od(r)}function jT(t,e){let r=t.find(a=>OT(a.path,e));if(r===void 0){let a=t.map(i=>i.label).join(", ");throw new Error(`Kandan attachment path must resolve inside an allowed upload root (${a}): ${e}`)}if(ky(r.path,e).split(/[\\/]+/).find(a=>a.startsWith("."))!==void 0)throw new Error(`Kandan attachment upload path must not include hidden path segments: ${e}`);let s=zT(e).toLowerCase();if(!TT.has(s))throw new Error(`Kandan attachment upload path extension is not allowed: ${e}`)}async function RT(t){let e=[{path:t,label:"runner cwd"}],r=process.env.HOME?.trim(),n=nd(r===void 0||r===""?$T():r,"Downloads");try{let o=await od(n);e.some(s=>s.path===o)||e.push({path:o,label:"~/Downloads"})}catch{return e}return e}function OT(t,e){let r=ky(t,e);return r===""||!r.startsWith("..")&&!wy(r)}function ET(t){let e=t.toLowerCase();return e.endsWith(".png")?"image/png":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".gif")?"image/gif":e.endsWith(".webp")?"image/webp":e.endsWith(".csv")?"text/csv":e.endsWith(".json")?"application/json":e.endsWith(".md")||e.endsWith(".txt")||e.endsWith(".log")?"text/plain":"application/octet-stream"}function ad(t){let e=t.fetchImpl??fetch,r=xt(t.kandanUrl),n=t.authMode==="personal-agent-delegation"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",o=t.operatingMode??"text",s=async(a,i,u,l={})=>{let c=new URL(i,r),d={...u,operating_mode:o},h={method:a,headers:{authorization:`Bearer ${t.accessToken}`},...l.signal===void 0?{}:{signal:l.signal}};if(a==="GET")for(let[w,x]of Object.entries(d))x!=null&&c.searchParams.set(w,String(x));else h.headers={...h.headers,"content-type":"application/json"},h.body=JSON.stringify(d);let f=await e(c,h),m=await f.json(),g=tr(m)?m:void 0;if(g===void 0)throw new Error(`Linzumi MCP API returned non-object JSON from ${i}`);if(f.ok&&g.ok===!0)return g;let y=typeof g.error=="string"?g.error:`HTTP ${f.status}`,v=typeof g.detail=="string"?g.detail:void 0;throw new Error(`Linzumi MCP API ${i} failed: ${y}${v===void 0?"":` detail=${v}`}`)};return{validateAuth:()=>s("GET",`${n}/validate`,{}),issueOnboardingDiscoveryToken:a=>s("POST",`${n}/onboarding-discovery-token`,a),getMessage:a=>s("GET",`${n}/message`,a),getThread:a=>s("GET",`${n}/thread`,a),getChannel:a=>s("GET",`${n}/channel`,a),searchWorkspace:a=>s("GET",`${n}/search`,a),askWorkspace:a=>s("POST",`${n}/ask`,a),webSearch:a=>s("GET",`${n}/web-search`,a),fetchUrl:a=>s("GET",`${n}/fetch-url`,a),listUiTargets:a=>s("GET",`${n}/ui-targets`,a),openUi:a=>s("POST",`${n}/open-ui`,a),getCodingJobMetadata:a=>s("GET",`${n}/coding-job-metadata`,a),listProjects:a=>s("GET",`${n}/projects`,a),getProjectTasks:a=>s("GET",`${n}/project-tasks`,a),createProjectTask:a=>s("POST",`${n}/project-tasks/create`,a),updateProjectTask:a=>s("POST",`${n}/project-tasks/update`,a),deleteProjectTask:a=>s("POST",`${n}/project-tasks/delete`,a),addProjectTaskDependency:a=>s("POST",`${n}/project-tasks/add-dependency`,a),removeProjectTaskDependency:a=>s("POST",`${n}/project-tasks/remove-dependency`,a),getCallTranscript:a=>s("GET",`${n}/call-transcript`,a),renameCodingJob:a=>s("POST",`${n}/coding-job-title`,a),upsertCodingJobPlan:(a,i)=>s("POST",`${n}/coding-job-plan`,a,i),replaceCodingJobPlanSteps:a=>s("POST",`${n}/coding-job-plan/steps`,a),updateCodingJobPlanStep:a=>s("POST",`${n}/coding-job-plan/step`,a),linkCodingJobPullRequest:a=>s("POST",`${n}/coding-job-primary-pr`,a),listVaultSecrets:a=>s("GET",`${n}/vault-secrets`,a),noteProjectDirectory:a=>s("POST",`${n}/discovered-project`,a),noteAgentConversation:a=>s("POST",`${n}/discovered-conversation`,a),noteOnboardingDiscoveryStatus:a=>s("POST",`${n}/discovery-status`,a),sendChannelMessage:a=>s("POST",`${n}/channel-message`,a),editMessage:a=>s("POST",`${n}/message/edit`,a),agentReply:a=>s("POST",`${n}/agent-reply`,a),agentTurnProgress:a=>s("POST",`${n}/agent-turn-progress`,a),agentListCodingJobs:a=>s("GET",`${n}/agent/coding-jobs`,a),agentStartCodingJob:a=>s("POST",`${n}/agent/start-coding-job`,a),agentInterruptCodingJob:a=>s("POST",`${n}/agent/interrupt-coding-job`,a),agentSendCodingJobMessage:a=>s("POST",`${n}/agent/send-coding-job-message`,a),agentReadCodingJobThread:a=>s("GET",`${n}/agent/coding-job-thread`,a),agentResolveJobApproval:a=>s("POST",`${n}/agent/resolve-job-approval`,a),agentArchiveCodingJob:a=>s("POST",`${n}/agent/archive-coding-job`,a),agentUnarchiveCodingJob:a=>s("POST",`${n}/agent/unarchive-coding-job`,a),agentSetThreadStatus:a=>s("POST",`${n}/agent/set-thread-status`,a),agentCreateChannel:a=>s("POST",`${n}/agent/create-channel`,a),agentRenameChannel:a=>s("POST",`${n}/agent/rename-channel`,a),agentArchiveChannel:a=>s("POST",`${n}/agent/archive-channel`,a),agentUnarchiveChannel:a=>s("POST",`${n}/agent/unarchive-channel`,a),agentAddReaction:a=>s("POST",`${n}/agent/add-reaction`,a),agentRemoveReaction:a=>s("POST",`${n}/agent/remove-reaction`,a),agentPinMessage:a=>s("POST",`${n}/agent/pin-message`,a),agentUnpinMessage:a=>s("POST",`${n}/agent/unpin-message`,a),prepareMessageUploads:a=>s("POST",`${n}/message-uploads/prepare`,a),attachMessageFiles:a=>s("POST",`${n}/message-files/attach`,a),prepareCustomEmoji:a=>s("POST",`${n}/custom-emoji/prepare`,a),renameCustomEmoji:a=>s("POST",`${n}/custom-emoji/rename`,a),sendThreadReply:a=>s("POST",`${n}/thread-reply`,a),sendDm:a=>s("POST",`${n}/dm`,a),dmOwner:a=>s("POST",`${n}/dm-owner`,a),getVaultValues:a=>s("POST",`${n}/vault-values`,a)}}function xy(t){return{name:"linzumi",command:t.command??"linzumi",args:[...t.argsPrefix??[],"mcp","server","--api-url",t.kandanUrl,...t.authFilePath===void 0?[]:["--auth-file",t.authFilePath],...t.delegationAuthFilePath===void 0?[]:["--delegation-auth-file",t.delegationAuthFilePath],...t.ownerUsername===void 0?[]:["--owner-username",t.ownerUsername],...t.cwd===void 0?[]:["--cwd",t.cwd],...t.threadId===void 0?[]:["--thread-id",t.threadId],"--mode",t.operatingMode??"text",...t.toolScope===void 0||t.toolScope==="all"?[]:["--tool-scope",t.toolScope],...t.agentSession===!0?["--agent-session"]:[]],env:{...t.accessToken===void 0?{}:{LINZUMI_MCP_ACCESS_TOKEN:t.accessToken},ELECTRON_RUN_AS_NODE:"1"}}}function $y(t){return`${JSON.stringify({mcpServers:{[t.name]:{command:t.command,args:t.args,env:t.env}}},null,2)}
151
+ `,"utf8"),{accessToken:t.accessToken,kandanBaseUrl:n,issuedAt:o.toISOString(),expiresAt:s}}function rd(t){let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("Kandan auth cache must contain a JSON object");let r=e,n=r.local_codex_runner,o=r.personal_agent_delegation;if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw new Error("Kandan auth cache local_codex_runner must be an object");if(o!==void 0&&(typeof o!="object"||o===null||Array.isArray(o)))throw new Error("Kandan auth cache personal_agent_delegation must be an object");return{version:1,local_codex_runner:bT(n),personal_agent_delegation:_T(o)}}function _T(t){if(typeof t!="object"||t===null||Array.isArray(t))return;let e=t.access_token,r=t.issued_at,n=t.expires_at;if(!(typeof e!="string"||typeof r!="string"))return{access_token:e,issued_at:r,expires_at:typeof n=="string"?n:void 0}}function bT(t){if(!(typeof t!="object"||t===null||Array.isArray(t)))return Object.fromEntries(Object.entries(t).flatMap(([e,r])=>{if(typeof r!="object"||r===null||Array.isArray(r))return[];let n=r.access_token,o=r.issued_at,s=r.expires_at;return typeof n!="string"||typeof o!="string"?[]:[[e,{access_token:n,issued_at:o,expires_at:typeof s=="string"?s:void 0}]]}))}async function by(t,e={readCachedToken:ga,validateToken:zo,acquireAndCacheToken:kT}){if(t.explicitToken!==void 0)return t.explicitToken;let r=e.readCachedToken(t.kandanUrl,t.authFilePath);if(r!==void 0){let o=await e.validateToken({kandanUrl:t.kandanUrl,accessToken:r.accessToken,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,requiredScopes:t.requiredScopes});if(o==="usable")return r.accessToken;t.reportRejectedCachedToken?.(o)}let n=await e.acquireAndCacheToken(t);return t.workspaceSlug!==void 0&&await vT(t,e,n),n}async function vT(t,e,r){let n;try{n=await e.validateToken({kandanUrl:t.kandanUrl,accessToken:r,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,requiredScopes:t.requiredScopes})}catch{return}if(n==="not_found")throw new Error(wT(t))}function wT(t){let e=new URL(xt(t.kandanUrl)).host;return`Workspace '${t.workspaceSlug}' was not found on ${e}. Sign in to the web app to create it, then re-run connect.`}async function kT(t){let e=t.authMode??{kind:"browser",callbackHost:t.callbackHost},r=e.kind==="device"?await fy({kandanUrl:t.kandanUrl,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,onboarding:t.onboarding}):await my({kandanUrl:t.kandanUrl,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,onboarding:t.onboarding,callbackHost:e.callbackHost??t.callbackHost});return _y({kandanUrl:t.kandanUrl,accessToken:r.accessToken,expiresInSeconds:r.expiresInSeconds,authFilePath:t.authFilePath}),r.accessToken}import{readFile as _C,realpath as od,stat as xT,writeFile as bC,mkdir as vC}from"node:fs/promises";import{homedir as $T}from"node:os";import{basename as ST,extname as zT,isAbsolute as wy,join as xC,relative as ky,resolve as nd}from"node:path";function tr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $t(t){return t!==void 0&&tr(t)?t:void 0}function ya(t){return Array.isArray(t)?t:void 0}function Te(t){return typeof t=="string"&&t.trim()!==""?t.trim():void 0}function vy(t){return typeof t=="number"&&Number.isInteger(t)?t:void 0}var TT=new Set([".csv",".diff",".gif",".htm",".html",".jpeg",".jpg",".json",".jsonl",".log",".md",".mp4",".patch",".pdf",".png",".svg",".txt",".webm",".webp",".xml",".zip"]);async function sd(t,e){let r=await od(t),n=await RT(r),o=await PT(r,e);jT(n,o);let s=await xT(o);if(!s.isFile())throw new Error(`Linzumi upload path is not a file: ${o}`);return{path:o,fileName:ST(o),contentType:ET(o),sizeBytes:s.size}}async function PT(t,e){if(e==="")throw new Error("Kandan attachment path must not be empty");let r=wy(e)?nd(e):nd(t,e);return await od(r)}function jT(t,e){let r=t.find(a=>OT(a.path,e));if(r===void 0){let a=t.map(i=>i.label).join(", ");throw new Error(`Kandan attachment path must resolve inside an allowed upload root (${a}): ${e}`)}if(ky(r.path,e).split(/[\\/]+/).find(a=>a.startsWith("."))!==void 0)throw new Error(`Kandan attachment upload path must not include hidden path segments: ${e}`);let s=zT(e).toLowerCase();if(!TT.has(s))throw new Error(`Kandan attachment upload path extension is not allowed: ${e}`)}async function RT(t){let e=[{path:t,label:"runner cwd"}],r=process.env.HOME?.trim(),n=nd(r===void 0||r===""?$T():r,"Downloads");try{let o=await od(n);e.some(s=>s.path===o)||e.push({path:o,label:"~/Downloads"})}catch{return e}return e}function OT(t,e){let r=ky(t,e);return r===""||!r.startsWith("..")&&!wy(r)}function ET(t){let e=t.toLowerCase();return e.endsWith(".png")?"image/png":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".gif")?"image/gif":e.endsWith(".webp")?"image/webp":e.endsWith(".csv")?"text/csv":e.endsWith(".json")?"application/json":e.endsWith(".md")||e.endsWith(".txt")||e.endsWith(".log")?"text/plain":"application/octet-stream"}function ad(t){let e=t.fetchImpl??fetch,r=xt(t.kandanUrl),n=t.authMode==="personal-agent-delegation"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",o=t.operatingMode??"text",s=async(a,i,u,l={})=>{let c=new URL(i,r),d={...u,operating_mode:o},h={method:a,headers:{authorization:`Bearer ${t.accessToken}`},...l.signal===void 0?{}:{signal:l.signal}};if(a==="GET")for(let[w,x]of Object.entries(d))x!=null&&c.searchParams.set(w,String(x));else h.headers={...h.headers,"content-type":"application/json"},h.body=JSON.stringify(d);let f=await e(c,h),m=await f.json(),g=tr(m)?m:void 0;if(g===void 0)throw new Error(`Linzumi MCP API returned non-object JSON from ${i}`);if(f.ok&&g.ok===!0)return g;let y=typeof g.error=="string"?g.error:`HTTP ${f.status}`,v=typeof g.detail=="string"?g.detail:void 0;throw new Error(`Linzumi MCP API ${i} failed: ${y}${v===void 0?"":` detail=${v}`}`)};return{validateAuth:()=>s("GET",`${n}/validate`,{}),issueOnboardingDiscoveryToken:a=>s("POST",`${n}/onboarding-discovery-token`,a),getMessage:a=>s("GET",`${n}/message`,a),getThread:a=>s("GET",`${n}/thread`,a),getThreadTranscript:a=>s("GET",`${n}/thread-transcript`,a),getChannel:a=>s("GET",`${n}/channel`,a),searchWorkspace:a=>s("GET",`${n}/search`,a),askWorkspace:a=>s("POST",`${n}/ask`,a),webSearch:a=>s("GET",`${n}/web-search`,a),fetchUrl:a=>s("GET",`${n}/fetch-url`,a),listUiTargets:a=>s("GET",`${n}/ui-targets`,a),openUi:a=>s("POST",`${n}/open-ui`,a),getCodingJobMetadata:a=>s("GET",`${n}/coding-job-metadata`,a),listProjects:a=>s("GET",`${n}/projects`,a),getProjectTasks:a=>s("GET",`${n}/project-tasks`,a),createProjectTask:a=>s("POST",`${n}/project-tasks/create`,a),updateProjectTask:a=>s("POST",`${n}/project-tasks/update`,a),deleteProjectTask:a=>s("POST",`${n}/project-tasks/delete`,a),addProjectTaskDependency:a=>s("POST",`${n}/project-tasks/add-dependency`,a),removeProjectTaskDependency:a=>s("POST",`${n}/project-tasks/remove-dependency`,a),getCallTranscript:a=>s("GET",`${n}/call-transcript`,a),renameCodingJob:a=>s("POST",`${n}/coding-job-title`,a),upsertCodingJobPlan:(a,i)=>s("POST",`${n}/coding-job-plan`,a,i),replaceCodingJobPlanSteps:a=>s("POST",`${n}/coding-job-plan/steps`,a),updateCodingJobPlanStep:a=>s("POST",`${n}/coding-job-plan/step`,a),linkCodingJobPullRequest:a=>s("POST",`${n}/coding-job-primary-pr`,a),listVaultSecrets:a=>s("GET",`${n}/vault-secrets`,a),noteProjectDirectory:a=>s("POST",`${n}/discovered-project`,a),noteAgentConversation:a=>s("POST",`${n}/discovered-conversation`,a),noteOnboardingDiscoveryStatus:a=>s("POST",`${n}/discovery-status`,a),sendChannelMessage:a=>s("POST",`${n}/channel-message`,a),editMessage:a=>s("POST",`${n}/message/edit`,a),agentReply:a=>s("POST",`${n}/agent-reply`,a),agentTurnProgress:a=>s("POST",`${n}/agent-turn-progress`,a),agentListCodingJobs:a=>s("GET",`${n}/agent/coding-jobs`,a),agentStartCodingJob:a=>s("POST",`${n}/agent/start-coding-job`,a),agentInterruptCodingJob:a=>s("POST",`${n}/agent/interrupt-coding-job`,a),agentSendCodingJobMessage:a=>s("POST",`${n}/agent/send-coding-job-message`,a),agentReadCodingJobThread:a=>s("GET",`${n}/agent/coding-job-thread`,a),agentResolveJobApproval:a=>s("POST",`${n}/agent/resolve-job-approval`,a),agentArchiveCodingJob:a=>s("POST",`${n}/agent/archive-coding-job`,a),agentUnarchiveCodingJob:a=>s("POST",`${n}/agent/unarchive-coding-job`,a),agentSetThreadStatus:a=>s("POST",`${n}/agent/set-thread-status`,a),agentCreateChannel:a=>s("POST",`${n}/agent/create-channel`,a),agentRenameChannel:a=>s("POST",`${n}/agent/rename-channel`,a),agentArchiveChannel:a=>s("POST",`${n}/agent/archive-channel`,a),agentUnarchiveChannel:a=>s("POST",`${n}/agent/unarchive-channel`,a),agentAddReaction:a=>s("POST",`${n}/agent/add-reaction`,a),agentRemoveReaction:a=>s("POST",`${n}/agent/remove-reaction`,a),agentPinMessage:a=>s("POST",`${n}/agent/pin-message`,a),agentUnpinMessage:a=>s("POST",`${n}/agent/unpin-message`,a),prepareMessageUploads:a=>s("POST",`${n}/message-uploads/prepare`,a),attachMessageFiles:a=>s("POST",`${n}/message-files/attach`,a),prepareCustomEmoji:a=>s("POST",`${n}/custom-emoji/prepare`,a),renameCustomEmoji:a=>s("POST",`${n}/custom-emoji/rename`,a),sendThreadReply:a=>s("POST",`${n}/thread-reply`,a),sendDm:a=>s("POST",`${n}/dm`,a),dmOwner:a=>s("POST",`${n}/dm-owner`,a),getVaultValues:a=>s("POST",`${n}/vault-values`,a)}}function xy(t){return{name:"linzumi",command:t.command??"linzumi",args:[...t.argsPrefix??[],"mcp","server","--api-url",t.kandanUrl,...t.authFilePath===void 0?[]:["--auth-file",t.authFilePath],...t.delegationAuthFilePath===void 0?[]:["--delegation-auth-file",t.delegationAuthFilePath],...t.ownerUsername===void 0?[]:["--owner-username",t.ownerUsername],...t.cwd===void 0?[]:["--cwd",t.cwd],...t.threadId===void 0?[]:["--thread-id",t.threadId],"--mode",t.operatingMode??"text",...t.toolScope===void 0||t.toolScope==="all"?[]:["--tool-scope",t.toolScope],...t.agentSession===!0?["--agent-session"]:[]],env:{...t.accessToken===void 0?{}:{LINZUMI_MCP_ACCESS_TOKEN:t.accessToken},ELECTRON_RUN_AS_NODE:"1"}}}function $y(t){return`${JSON.stringify({mcpServers:{[t.name]:{command:t.command,args:t.args,env:t.env}}},null,2)}
152
152
  `}function Sy(t){return`[mcp_servers.${t.name}]
153
153
  command = ${JSON.stringify(t.command)}
154
154
  args = ${IT(t.args)}
@@ -164,6 +164,9 @@ Usage:
164
164
  Tools:
165
165
  linzumi_get_message Read one message by scoped seq or Linzumi message URL.
166
166
  linzumi_get_thread Read one bounded thread by ID.
167
+ linzumi_get_thread_transcript
168
+ Read a thread's FULL transcript (tool calls, commands,
169
+ diffs) as canonical IR nodes, cursor-paginated.
167
170
  linzumi_get_channel Read bounded recent messages and channel metadata.
168
171
  linzumi_web_search Search the public web (news, docs, live info).
169
172
  linzumi_fetch_url Fetch a public http(s) URL as readable text.
@@ -233,6 +236,6 @@ Tools:
233
236
  Auth:
234
237
  Uses --token, LINZUMI_MCP_ACCESS_TOKEN, or cached local runner OAuth from linzumi auth.
235
238
  Hosted personal agents use --delegation-auth-file with a signed delegation grant.
236
- `}async function LT(t){let e=cd(t);if(e.get("help")===!0){process.stdout.write(Cy());return}let r=ld(e,"api-url"),n=await id({kandanUrl:r,explicitToken:re(e,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:re(e,"auth-file"),delegationAuthFilePath:re(e,"delegation-auth-file"),workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")}),o=re(e,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,s=ud(re(e,"mode")),a=Ay(re(e,"tool-scope")),i=re(e,"cwd")??process.cwd(),u=re(e,"thread-id")??process.env.LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID,l=ad({kandanUrl:r,accessToken:n.accessToken,authMode:n.mode,operatingMode:s}),c=new pa({name:"linzumi",version:"0.1.0"});VT(c),qT(c,{client:l,toolScope:a,operatingMode:s,cwd:i,kandanUrl:r,defaultThreadId:u,ownerUsername:o,agentSession:e.get("agent-session")===!0}),await c.connect(new fa)}function qT(t,e){let{client:r,toolScope:n,operatingMode:o,cwd:s,kandanUrl:a,defaultThreadId:i,ownerUsername:u,agentSession:l}=e;l&&(t.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:p.string().min(1).describe("Plain-text reply body to post.")},async c=>C(await r.agentReply({body:c.body}))),t.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()=>C(await r.agentListCodingJobs({}))),t.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:p.string().describe("Channel slug to host the job thread."),runner_key:p.string().describe("Runner (computer) to run the job on."),cwd:p.string().describe("Working directory on the runner."),work_description:p.string().min(1).describe("What the job should do - the initial instruction."),model:p.string().optional().describe("Model override (optional)."),model_provider:p.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),execution_mode:p.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional)."),project_task_id:p.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.")},async c=>C(await r.agentStartCodingJob(c))),t.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:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),mode:p.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")},async c=>C(await r.agentInterruptCodingJob(c))),t.tool("linzumi_send_coding_job_message","Send a message into a coding job thread as the asking user (the job processes it like any human follow-up).",{channel:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),body:p.string().min(1).describe("Message body to send.")},async c=>C(await r.agentSendCodingJobMessage(c))),t.tool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",{channel:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),limit:p.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:p.number().int().positive().optional().describe("Return replies before this channel seq.")},async c=>C(await r.agentReadCodingJobThread(c))),t.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:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),source_seq:p.number().int().positive().describe("Channel seq of the message the approval request rides on."),request_id:p.string().describe("The approval request id."),decision:p.enum(["approve","deny"]).describe("The asker's decision.")},async c=>C(await r.agentResolveJobApproval(c))),t.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:p.string().describe("Channel slug hosting the thread."),thread_id:p.string().uuid().describe("The thread UUID to archive.")},async c=>C(await r.agentArchiveCodingJob(c))),t.tool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",{channel:p.string().describe("Channel slug hosting the thread."),thread_id:p.string().uuid().describe("The thread UUID to unarchive.")},async c=>C(await r.agentUnarchiveCodingJob(c))),t.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:p.string().describe("Channel slug hosting the thread."),thread_id:p.string().uuid().describe("The thread UUID."),status:p.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")},async c=>C(await r.agentSetThreadStatus(c))),t.tool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",{name:p.string().min(1).describe("Channel name to create.")},async c=>C(await r.agentCreateChannel(c))),t.tool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",{channel:p.string().describe("Current channel slug to rename."),name:p.string().min(1).describe("New display name.")},async c=>C(await r.agentRenameChannel(c))),t.tool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",{channel:p.string().describe("Channel slug to archive.")},async c=>C(await r.agentArchiveChannel(c))),t.tool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",{channel:p.string().describe("Channel slug to unarchive.")},async c=>C(await r.agentUnarchiveChannel(c))),t.tool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the message to react to."),emoji:p.string().min(1).describe("Emoji to add (unicode or :shortcode:).")},async c=>C(await r.agentAddReaction(c))),t.tool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the reacted message."),emoji:p.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")},async c=>C(await r.agentRemoveReaction(c))),t.tool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the message to pin.")},async c=>C(await r.agentPinMessage(c))),t.tool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the pinned message.")},async c=>C(await r.agentUnpinMessage(c)))),n==="all"&&(t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),message_id:p.union([p.string(),p.number()]).optional().describe("Message seq inside the scoped channel."),message_seq:p.union([p.string(),p.number()]).optional().describe("Alias for message_id."),message_url:p.string().optional().describe("Full Linzumi message URL with #message-<seq>."),before:p.number().int().min(0).max(100).optional().describe("Number of visible messages before the target."),after:p.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")},async c=>C(await r.getMessage(c))),t.tool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",{workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().describe("Linzumi thread UUID."),limit:p.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:p.number().int().positive().optional().describe("Return replies before this channel seq.")},async c=>C(await r.getThread(c))),t.tool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",{workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),limit:p.number().int().min(1).max(100).optional().describe("Maximum messages to return."),before_seq:p.number().int().positive().optional().describe("Return messages before this channel seq.")},async c=>C(await r.getChannel(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),query:p.string().min(1).describe("Natural-language or keyword query to retrieve against."),limit:p.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped)."),source_types:p.array(p.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:p.string().optional().describe("ISO8601 instant; only content authored at or after this time."),authored_before:p.string().optional().describe("ISO8601 instant; only content authored at or before this time."),repo:p.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name)."),check_status:p.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")},async c=>C(await r.searchWorkspace(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),question:p.string().min(1).max(2e3).describe("Natural-language question to answer with citations."),channel:p.string().optional().describe("Optional channel slug providing conversational context; never widens access."),allow_cached:p.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")},async c=>C(await r.askWorkspace(c))),t.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:p.string().min(1).describe("Web search query (natural language or keywords)."),limit:p.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")},async c=>C(await r.webSearch(c))),t.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:p.string().min(1).describe("Absolute public http(s) URL to fetch.")},async c=>C(await r.fetchUrl(c))),t.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 Oy(r.listUiTargets({}))),t.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:p.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout)."),args:p.record(p.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path)."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>await Oy(r.openUi(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread.")},async c=>C(await r.getCodingJobMetadata(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),title:p.string().min(1).max(100).describe("Concise user-visible title for this coding job.")},async c=>C(await r.renameCodingJob(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:p.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")},async c=>C(await r.upsertCodingJobPlan(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:p.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal."),steps:p.array(p.object({title:p.string().min(1).max(255),description:p.string().min(1).max(1e4),status:p.enum(["pending","active","completed","blocked","canceled"]),status_note:p.string().min(1).max(4e3).optional(),completed_debrief:p.string().min(1).max(2e4).optional()})).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")},async c=>C(await r.replaceCodingJobPlanSteps(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),step_id:p.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata."),lock_version:p.number().int().positive().describe("Current step lock_version from metadata."),status:p.enum(["pending","active","completed","blocked","canceled"]),status_note:p.string().min(1).max(4e3).optional(),completed_debrief:p.string().min(1).max(2e4).optional().describe("Required when marking a step completed.")},async c=>C(await r.updateCodingJobPlanStep(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),github_repo_owner:p.string().min(1).max(255),github_repo_name:p.string().min(1).max(255),github_pr_number:p.number().int().positive(),github_pr_url:p.string().url(),title:p.string().min(1).max(255),body:p.string().min(1).max(1e5).optional(),head_branch:p.string().min(1).max(255),head_sha:p.string().min(7).max(64),base_branch:p.string().min(1).max(255),base_sha:p.string().min(7).max(64),state:p.enum(["draft","open","closed","merged"]).optional(),is_draft:p.boolean().optional(),review_status:p.enum(["unknown","review_required","approved","changes_requested"]).optional(),source_remote_url:p.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:p.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:p.enum(["unknown","clean","dirty"]).optional(),dirty_summary:p.string().min(1).max(2e3).optional()},async c=>C(await r.linkCodingJobPullRequest(St(c,i)))),t.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:p.object({kind:p.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:p.union([p.string(),p.number()]).optional().describe("Required when kind is message_seq."),thread_id:p.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")}).describe("Attachment target. Do not guess; use new_message when there is no previous assistant message. 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:p.array(p.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden supported file types inside the approved workspace or Downloads."),body:p.string().min(1).max(2e4).optional().describe("Required for new_message. 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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope.")},async c=>{let d=Py(c.target,i),h=await DT({client:r,cwd:s,kandanUrl:a,target:d,files:c.files,workspace:c.workspace,channel:c.channel,body:c.body});return C(jy(a,h))}),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),target:p.object({message_seq:p.union([p.string(),p.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here."),thread_id:p.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:p.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 c=>C(jy(a,await r.editMessage({...c,target:Py(c.target,i)})))),t.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 c=>C(await r.listVaultSecrets(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>C(await r.listProjects(c))),t.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:p.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")},async c=>C(await r.getProjectTasks(St(c,i)))),t.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:p.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project."),title:p.string().min(1).describe("Task title."),kind:p.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).'),description:p.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it."),status:p.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".'),parent_id:p.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent."),assignee:p.string().optional().describe("Username of a workspace member to assign."),position:p.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")},async c=>C(await r.createProjectTask(St(c,i)))),t.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:p.string().describe("task_id of the group or issue to update."),title:p.string().min(1).optional().describe("New title."),description:p.string().nullable().optional().describe("New description. Pass null to clear it."),status:p.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.'),status_note:p.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it."),position:p.number().int().min(0).optional().describe("New sort position among siblings."),parent_id:p.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent."),clear_parent:p.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id."),assignee:p.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee."),clear_assignee:p.boolean().optional().describe("true removes the assignee. Do not combine with assignee."),lock_version:p.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")},async c=>C(await r.updateProjectTask(c))),t.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:p.string().describe("task_id of the group or issue to delete.")},async c=>C(await r.deleteProjectTask(c))),t.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:p.string().describe("task_id of the DEPENDENT issue (the one that must wait)."),depends_on_task_id:p.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")},async c=>C(await r.addProjectTaskDependency(c))),t.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:p.string().describe("task_id of the DEPENDENT issue."),depends_on_task_id:p.string().describe("task_id of the PREREQUISITE issue the edge points at.")},async c=>C(await r.removeProjectTaskDependency(c))),t.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:p.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 c=>C(await r.getCallTranscript(c))),l||t.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:p.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:p.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."),channel:p.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel."),runner_key:p.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer."),cwd:p.string().optional().describe("Working directory on the runner. Omit to use this job's own folder."),model:p.string().optional().describe("Model override (optional)."),model_provider:p.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),execution_mode:p.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")},async c=>C(await r.agentStartCodingJob(St(c,i))))),AT(n)&&(t.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:Ty.describe("Custom emoji shortcode name, with or without surrounding colons."),file:p.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>C(await UT({client:r,cwd:s,kandanUrl:a,name:c.name,file:c.file,workspace:c.workspace}))),t.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:p.union([p.string(),p.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings."),name:Ty.describe("New shortcode name, with or without surrounding colons."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>C(await r.renameCustomEmoji(c)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:p.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),path:p.string().min(1).describe("Absolute local path to the repository worktree root."),display_name:p.string().optional().describe("Short project label. Defaults to the path basename."),activity_at:p.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),import_key:p.string().optional().describe("Stable dedupe key. Defaults to path."),metadata:p.record(p.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")},async c=>C(await r.noteProjectDirectory(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:p.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),source:p.enum(["codex","claude_code"]).describe("Conversation source."),import_key:p.string().min(1).describe("Stable dedupe key, such as a session id or file path."),path:p.string().optional().describe("Absolute local path to the conversation file or directory."),display_name:p.string().optional().describe("Short label for the discovered conversation."),activity_at:p.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),metadata:p.record(p.unknown()).optional().describe("Small structured metadata such as session id or project path.")},async c=>C(await r.noteAgentConversation(c))),t.tool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",{workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:p.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),phase:p.enum(["projects","conversations"]).describe("Discovery phase being reported."),status:p.enum(["starting","running","completed","failed"]).describe("Current phase status."),places_searched:p.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far."),message:p.string().optional().describe("Short user-facing status note."),current_place:p.string().optional().describe("Current folder, file, Git command target, or known location being checked."),current_source:p.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code."),last_error:p.string().optional().describe("Short failure detail when status is failed."),metadata:p.record(p.unknown()).optional().describe("Small structured status metadata.")},async c=>C(await r.noteOnboardingDiscoveryStatus(c))),n==="all"&&NT(o)&&(t.tool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",{owner_username:p.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Source channel slug used to verify owner visibility."),body:p.string().min(1).max(2e4).describe("Plain-text message body to DM.")},async c=>{let d=c.owner_username??u;if(d===void 0)throw new Error("owner_username is required for linzumi_dm_owner");return C(await r.dmOwner({...c,owner_username:d}))}),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),body:p.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.")},async c=>C(await r.sendChannelMessage(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().describe("Existing Linzumi thread UUID."),body:p.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.")},async c=>C(await r.sendThreadReply(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Source channel slug used to verify target visibility."),username:p.string().describe("Visible Linzumi username to DM."),body:p.string().min(1).max(2e4).describe("Plain-text message body to DM.")},async c=>C(await r.sendDm(c)))),n==="all"&&t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug used to disambiguate the approval thread when needed."),thread_id:p.string().uuid().describe("Existing Linzumi thread UUID for the inline approval."),env_var_names:p.array(p.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:p.string().min(1).max(500).describe("Human-readable reason shown in the approval request."),justification:p.string().min(10).max(1e3).describe("Agent justification shown to the approver.")},async c=>C(await r.getVaultValues(c)))}async function DT(t){let e=await Promise.all(t.files.map(s=>sd(t.cwd,s))),r=await t.client.prepareMessageUploads({...t.workspace===void 0?{}:{workspace:t.workspace},...t.channel===void 0?{}:{channel:t.channel},files:e.map(s=>({file_name:s.fileName,content_type:s.contentType,size_bytes:s.sizeBytes}))}),n=ya(r.uploads)??[];if(n.length!==e.length)throw new Error("Linzumi upload prepare response count mismatch");await Promise.all(e.map(async(s,a)=>{let i=$t(n[a]),u=Te(i?.upload_url),l=Te(i?.upload_method)??"PUT";if(u===void 0)throw new Error("Linzumi upload prepare response missing upload_url");let c=await Ey(s.path),d=c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength),h=await fetch(To(t.kandanUrl,u),{method:l,headers:{"content-type":s.contentType},body:d});if(!h.ok)throw new Error(`Linzumi upload failed for ${s.fileName}: ${h.status} ${h.statusText}`)}));let o=n.map(s=>{let a=Te($t(s)?.file_id);if(a===void 0)throw new Error("Linzumi upload prepare response missing file_id");return a});return await t.client.attachMessageFiles({...t.workspace===void 0?{}:{workspace:t.workspace},...t.channel===void 0?{}:{channel:t.channel},target:t.target,...t.body===void 0?{}:{body:t.body},uploaded_file_ids:o})}async function UT(t){let e=await sd(t.cwd,t.file),r=await t.client.prepareCustomEmoji({...t.workspace===void 0?{}:{workspace:t.workspace},name:t.name,file_name:e.fileName,content_type:e.contentType,size_bytes:e.sizeBytes}),n=$t(r.upload),o=Te(n?.upload_url),s=Te(n?.upload_method)??"PUT";if(o===void 0)throw new Error("Linzumi custom emoji prepare response missing upload_url");let a=await Ey(e.path),i=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),u=await fetch(To(t.kandanUrl,o),{method:s,headers:{"content-type":e.contentType},body:i});if(!u.ok){let d=`${u.status} ${u.statusText}`,f=(await u.text()).trim(),m=f===""?d:(()=>{try{let g=JSON.parse(f);return tr(g)&&typeof g.error=="string"?g.error:f}catch{return f}})();throw new Error(`Linzumi custom emoji upload failed: ${m}`)}let l=await u.json();if(!tr(l))throw new Error("Linzumi custom emoji upload returned non-object JSON");let c=$t(l.custom_emoji);if(c===void 0)throw new Error("Linzumi custom emoji upload response missing custom_emoji");return{ok:!0,workspace:r.workspace,emoji:c,asset_id:Te(l.asset_id),id:vy(c?.id),name:Te(c?.name),shortcode:Te(c?.shortcode),image_url:Te(c?.image_url)}}function Py(t,e){if(Te(t.thread_id)!==void 0||e===void 0)return t;switch(t.message_seq===void 0){case!1:return{...t,thread_id:e};case!0:switch(Te(t.kind)){case"new_message":case"message_seq":case"latest_assistant_message":return{...t,thread_id:e};default:return t}}}function St(t,e){return Te(t.thread_id)!==void 0||e===void 0?t:{...t,thread_id:e}}function To(t,e){try{return new URL(e).toString()}catch{let n=t.replace(/^wss:\/\//,"https://").replace(/^ws:\/\//,"http://");return new URL(e,n).toString()}}function jy(t,e){let r=$t(e.message),n=$t(e.target_message);return r===void 0&&n===void 0?e:{...e,...r===void 0?{}:{message:Ry(t,r)},...n===void 0?{}:{target_message:Ry(t,n)}}}function Ry(t,e){let r=ya(e.attachments);return r===void 0?e:{...e,attachments:r.map(n=>JT(t,n))}}function JT(t,e){let r=$t(e);if(r===void 0)return e;let n=Te(r.url),o=$t(r.image_variants);return{...r,...n===void 0?{}:{url:To(t,n)},...o===void 0?{}:{image_variants:FT(t,o)}}}function FT(t,e){let r=Te(e.inline_url),n=Te(e.carousel_url);return{...e,...r===void 0?{}:{inline_url:To(t,r)},...n===void 0?{}:{carousel_url:To(t,n)}}}function VT(t){t.server.registerCapabilities({resources:{listChanged:!1}}),t.server.setRequestHandler(Yr,()=>({resources:[]})),t.server.setRequestHandler(Qr,()=>({resourceTemplates:[]}))}async function HT(t){let e=cd(t),r=ld(e,"api-url"),n=re(e,"format")??"codex",o=ud(re(e,"mode")),s=e.get("include-token")===!0?(await id({kandanUrl:r,explicitToken:re(e,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:re(e,"auth-file"),delegationAuthFilePath:re(e,"delegation-auth-file"),workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")})).accessToken:void 0,a=xy({command:re(e,"command"),kandanUrl:r,accessToken:s,delegationAuthFilePath:re(e,"delegation-auth-file"),ownerUsername:re(e,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:o,toolScope:Ay(re(e,"tool-scope"))});switch(n){case"codex":process.stdout.write(Sy(a));return;case"claude-code":process.stdout.write($y(a));return;default:throw new Error("--format must be codex or claude-code")}}async function BT(t){let e=cd(t),r=ld(e,"api-url"),n=await id({kandanUrl:r,explicitToken:re(e,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:re(e,"auth-file"),delegationAuthFilePath:re(e,"delegation-auth-file"),workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")});switch(n.mode){case"local-runner":{if(!await hy({kandanUrl:r,accessToken:n.accessToken,workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")}))throw new Error("Linzumi MCP auth validation failed");break}case"personal-agent-delegation":{await ad({kandanUrl:r,accessToken:n.accessToken,authMode:n.mode,operatingMode:ud(re(e,"mode"))}).validateAuth();break}}process.stdout.write(`Linzumi MCP auth OK
239
+ `}async function LT(t){let e=cd(t);if(e.get("help")===!0){process.stdout.write(Cy());return}let r=ld(e,"api-url"),n=await id({kandanUrl:r,explicitToken:re(e,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:re(e,"auth-file"),delegationAuthFilePath:re(e,"delegation-auth-file"),workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")}),o=re(e,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,s=ud(re(e,"mode")),a=Ay(re(e,"tool-scope")),i=re(e,"cwd")??process.cwd(),u=re(e,"thread-id")??process.env.LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID,l=ad({kandanUrl:r,accessToken:n.accessToken,authMode:n.mode,operatingMode:s}),c=new pa({name:"linzumi",version:"0.1.0"});VT(c),qT(c,{client:l,toolScope:a,operatingMode:s,cwd:i,kandanUrl:r,defaultThreadId:u,ownerUsername:o,agentSession:e.get("agent-session")===!0}),await c.connect(new fa)}function qT(t,e){let{client:r,toolScope:n,operatingMode:o,cwd:s,kandanUrl:a,defaultThreadId:i,ownerUsername:u,agentSession:l}=e;l&&(t.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:p.string().min(1).describe("Plain-text reply body to post.")},async c=>C(await r.agentReply({body:c.body}))),t.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()=>C(await r.agentListCodingJobs({}))),t.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:p.string().describe("Channel slug to host the job thread."),runner_key:p.string().describe("Runner (computer) to run the job on."),cwd:p.string().describe("Working directory on the runner."),work_description:p.string().min(1).describe("What the job should do - the initial instruction."),model:p.string().optional().describe("Model override (optional)."),model_provider:p.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),execution_mode:p.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional)."),project_task_id:p.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.")},async c=>C(await r.agentStartCodingJob(c))),t.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:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),mode:p.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")},async c=>C(await r.agentInterruptCodingJob(c))),t.tool("linzumi_send_coding_job_message","Send a message into a coding job thread as the asking user (the job processes it like any human follow-up).",{channel:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),body:p.string().min(1).describe("Message body to send.")},async c=>C(await r.agentSendCodingJobMessage(c))),t.tool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",{channel:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),limit:p.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:p.number().int().positive().optional().describe("Return replies before this channel seq.")},async c=>C(await r.agentReadCodingJobThread(c))),t.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:p.string().describe("Channel slug hosting the job thread."),thread_id:p.string().uuid().describe("The job thread UUID."),source_seq:p.number().int().positive().describe("Channel seq of the message the approval request rides on."),request_id:p.string().describe("The approval request id."),decision:p.enum(["approve","deny"]).describe("The asker's decision.")},async c=>C(await r.agentResolveJobApproval(c))),t.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:p.string().describe("Channel slug hosting the thread."),thread_id:p.string().uuid().describe("The thread UUID to archive.")},async c=>C(await r.agentArchiveCodingJob(c))),t.tool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",{channel:p.string().describe("Channel slug hosting the thread."),thread_id:p.string().uuid().describe("The thread UUID to unarchive.")},async c=>C(await r.agentUnarchiveCodingJob(c))),t.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:p.string().describe("Channel slug hosting the thread."),thread_id:p.string().uuid().describe("The thread UUID."),status:p.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")},async c=>C(await r.agentSetThreadStatus(c))),t.tool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",{name:p.string().min(1).describe("Channel name to create.")},async c=>C(await r.agentCreateChannel(c))),t.tool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",{channel:p.string().describe("Current channel slug to rename."),name:p.string().min(1).describe("New display name.")},async c=>C(await r.agentRenameChannel(c))),t.tool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",{channel:p.string().describe("Channel slug to archive.")},async c=>C(await r.agentArchiveChannel(c))),t.tool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",{channel:p.string().describe("Channel slug to unarchive.")},async c=>C(await r.agentUnarchiveChannel(c))),t.tool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the message to react to."),emoji:p.string().min(1).describe("Emoji to add (unicode or :shortcode:).")},async c=>C(await r.agentAddReaction(c))),t.tool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the reacted message."),emoji:p.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")},async c=>C(await r.agentRemoveReaction(c))),t.tool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the message to pin.")},async c=>C(await r.agentPinMessage(c))),t.tool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",{channel:p.string().describe("Channel slug containing the message."),message_seq:p.number().int().positive().describe("Channel seq of the pinned message.")},async c=>C(await r.agentUnpinMessage(c)))),n==="all"&&(t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),message_id:p.union([p.string(),p.number()]).optional().describe("Message seq inside the scoped channel."),message_seq:p.union([p.string(),p.number()]).optional().describe("Alias for message_id."),message_url:p.string().optional().describe("Full Linzumi message URL with #message-<seq>."),before:p.number().int().min(0).max(100).optional().describe("Number of visible messages before the target."),after:p.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")},async c=>C(await r.getMessage(c))),t.tool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",{workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().describe("Linzumi thread UUID."),limit:p.number().int().min(1).max(100).optional().describe("Maximum replies to return."),before_seq:p.number().int().positive().optional().describe("Return replies before this channel seq.")},async c=>C(await r.getThread(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().describe("Linzumi thread UUID."),limit:p.number().int().min(1).max(500).optional().describe("Maximum transcript nodes per page (default 200)."),cursor:p.number().int().positive().optional().describe("Return nodes below this seq (the previous page reply cursor).")},async c=>C(await r.getThreadTranscript(c))),t.tool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",{workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),limit:p.number().int().min(1).max(100).optional().describe("Maximum messages to return."),before_seq:p.number().int().positive().optional().describe("Return messages before this channel seq.")},async c=>C(await r.getChannel(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),query:p.string().min(1).describe("Natural-language or keyword query to retrieve against."),limit:p.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped)."),source_types:p.array(p.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:p.string().optional().describe("ISO8601 instant; only content authored at or after this time."),authored_before:p.string().optional().describe("ISO8601 instant; only content authored at or before this time."),repo:p.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name)."),check_status:p.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")},async c=>C(await r.searchWorkspace(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),question:p.string().min(1).max(2e3).describe("Natural-language question to answer with citations."),channel:p.string().optional().describe("Optional channel slug providing conversational context; never widens access."),allow_cached:p.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")},async c=>C(await r.askWorkspace(c))),t.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:p.string().min(1).describe("Web search query (natural language or keywords)."),limit:p.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")},async c=>C(await r.webSearch(c))),t.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:p.string().min(1).describe("Absolute public http(s) URL to fetch.")},async c=>C(await r.fetchUrl(c))),t.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 Oy(r.listUiTargets({}))),t.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:p.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout)."),args:p.record(p.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path)."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>await Oy(r.openUi(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread.")},async c=>C(await r.getCodingJobMetadata(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),title:p.string().min(1).max(100).describe("Concise user-visible title for this coding job.")},async c=>C(await r.renameCodingJob(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:p.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")},async c=>C(await r.upsertCodingJobPlan(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),goal:p.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal."),steps:p.array(p.object({title:p.string().min(1).max(255),description:p.string().min(1).max(1e4),status:p.enum(["pending","active","completed","blocked","canceled"]),status_note:p.string().min(1).max(4e3).optional(),completed_debrief:p.string().min(1).max(2e4).optional()})).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")},async c=>C(await r.replaceCodingJobPlanSteps(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),step_id:p.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata."),lock_version:p.number().int().positive().describe("Current step lock_version from metadata."),status:p.enum(["pending","active","completed","blocked","canceled"]),status_note:p.string().min(1).max(4e3).optional(),completed_debrief:p.string().min(1).max(2e4).optional().describe("Required when marking a step completed.")},async c=>C(await r.updateCodingJobPlanStep(St(c,i)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),github_repo_owner:p.string().min(1).max(255),github_repo_name:p.string().min(1).max(255),github_pr_number:p.number().int().positive(),github_pr_url:p.string().url(),title:p.string().min(1).max(255),body:p.string().min(1).max(1e5).optional(),head_branch:p.string().min(1).max(255),head_sha:p.string().min(7).max(64),base_branch:p.string().min(1).max(255),base_sha:p.string().min(7).max(64),state:p.enum(["draft","open","closed","merged"]).optional(),is_draft:p.boolean().optional(),review_status:p.enum(["unknown","review_required","approved","changes_requested"]).optional(),source_remote_url:p.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:p.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:p.enum(["unknown","clean","dirty"]).optional(),dirty_summary:p.string().min(1).max(2e3).optional()},async c=>C(await r.linkCodingJobPullRequest(St(c,i)))),t.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:p.object({kind:p.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:p.union([p.string(),p.number()]).optional().describe("Required when kind is message_seq."),thread_id:p.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")}).describe("Attachment target. Do not guess; use new_message when there is no previous assistant message. 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:p.array(p.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden supported file types inside the approved workspace or Downloads."),body:p.string().min(1).max(2e4).optional().describe("Required for new_message. 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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope.")},async c=>{let d=Py(c.target,i),h=await DT({client:r,cwd:s,kandanUrl:a,target:d,files:c.files,workspace:c.workspace,channel:c.channel,body:c.body});return C(jy(a,h))}),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),target:p.object({message_seq:p.union([p.string(),p.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here."),thread_id:p.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:p.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 c=>C(jy(a,await r.editMessage({...c,target:Py(c.target,i)})))),t.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 c=>C(await r.listVaultSecrets(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>C(await r.listProjects(c))),t.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:p.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")},async c=>C(await r.getProjectTasks(St(c,i)))),t.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:p.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project."),title:p.string().min(1).describe("Task title."),kind:p.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).'),description:p.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it."),status:p.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".'),parent_id:p.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent."),assignee:p.string().optional().describe("Username of a workspace member to assign."),position:p.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")},async c=>C(await r.createProjectTask(St(c,i)))),t.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:p.string().describe("task_id of the group or issue to update."),title:p.string().min(1).optional().describe("New title."),description:p.string().nullable().optional().describe("New description. Pass null to clear it."),status:p.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.'),status_note:p.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it."),position:p.number().int().min(0).optional().describe("New sort position among siblings."),parent_id:p.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent."),clear_parent:p.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id."),assignee:p.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee."),clear_assignee:p.boolean().optional().describe("true removes the assignee. Do not combine with assignee."),lock_version:p.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")},async c=>C(await r.updateProjectTask(c))),t.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:p.string().describe("task_id of the group or issue to delete.")},async c=>C(await r.deleteProjectTask(c))),t.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:p.string().describe("task_id of the DEPENDENT issue (the one that must wait)."),depends_on_task_id:p.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")},async c=>C(await r.addProjectTaskDependency(c))),t.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:p.string().describe("task_id of the DEPENDENT issue."),depends_on_task_id:p.string().describe("task_id of the PREREQUISITE issue the edge points at.")},async c=>C(await r.removeProjectTaskDependency(c))),t.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:p.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 c=>C(await r.getCallTranscript(c))),l||t.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:p.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:p.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."),channel:p.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel."),runner_key:p.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer."),cwd:p.string().optional().describe("Working directory on the runner. Omit to use this job's own folder."),model:p.string().optional().describe("Model override (optional)."),model_provider:p.string().optional().describe("Model provider override, e.g. 'wafer' (optional)."),execution_mode:p.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")},async c=>C(await r.agentStartCodingJob(St(c,i))))),AT(n)&&(t.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:Ty.describe("Custom emoji shortcode name, with or without surrounding colons."),file:p.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>C(await UT({client:r,cwd:s,kandanUrl:a,name:c.name,file:c.file,workspace:c.workspace}))),t.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:p.union([p.string(),p.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings."),name:Ty.describe("New shortcode name, with or without surrounding colons."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")},async c=>C(await r.renameCustomEmoji(c)))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:p.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),path:p.string().min(1).describe("Absolute local path to the repository worktree root."),display_name:p.string().optional().describe("Short project label. Defaults to the path basename."),activity_at:p.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),import_key:p.string().optional().describe("Stable dedupe key. Defaults to path."),metadata:p.record(p.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")},async c=>C(await r.noteProjectDirectory(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:p.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),source:p.enum(["codex","claude_code"]).describe("Conversation source."),import_key:p.string().min(1).describe("Stable dedupe key, such as a session id or file path."),path:p.string().optional().describe("Absolute local path to the conversation file or directory."),display_name:p.string().optional().describe("Short label for the discovered conversation."),activity_at:p.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp."),metadata:p.record(p.unknown()).optional().describe("Small structured metadata such as session id or project path.")},async c=>C(await r.noteAgentConversation(c))),t.tool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",{workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),runner_id:p.string().min(1).describe("Local runner/computer id provided in the discovery prompt."),phase:p.enum(["projects","conversations"]).describe("Discovery phase being reported."),status:p.enum(["starting","running","completed","failed"]).describe("Current phase status."),places_searched:p.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far."),message:p.string().optional().describe("Short user-facing status note."),current_place:p.string().optional().describe("Current folder, file, Git command target, or known location being checked."),current_source:p.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code."),last_error:p.string().optional().describe("Short failure detail when status is failed."),metadata:p.record(p.unknown()).optional().describe("Small structured status metadata.")},async c=>C(await r.noteOnboardingDiscoveryStatus(c))),n==="all"&&NT(o)&&(t.tool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",{owner_username:p.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username."),workspace:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Source channel slug used to verify owner visibility."),body:p.string().min(1).max(2e4).describe("Plain-text message body to DM.")},async c=>{let d=c.owner_username??u;if(d===void 0)throw new Error("owner_username is required for linzumi_dm_owner");return C(await r.dmOwner({...c,owner_username:d}))}),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),body:p.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.")},async c=>C(await r.sendChannelMessage(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug. Omit to use the authenticated token scope."),thread_id:p.string().uuid().describe("Existing Linzumi thread UUID."),body:p.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.")},async c=>C(await r.sendThreadReply(c))),t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Source channel slug used to verify target visibility."),username:p.string().describe("Visible Linzumi username to DM."),body:p.string().min(1).max(2e4).describe("Plain-text message body to DM.")},async c=>C(await r.sendDm(c)))),n==="all"&&t.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:p.string().optional().describe("Workspace slug. Omit to use the authenticated token scope."),channel:p.string().optional().describe("Channel slug used to disambiguate the approval thread when needed."),thread_id:p.string().uuid().describe("Existing Linzumi thread UUID for the inline approval."),env_var_names:p.array(p.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:p.string().min(1).max(500).describe("Human-readable reason shown in the approval request."),justification:p.string().min(10).max(1e3).describe("Agent justification shown to the approver.")},async c=>C(await r.getVaultValues(c)))}async function DT(t){let e=await Promise.all(t.files.map(s=>sd(t.cwd,s))),r=await t.client.prepareMessageUploads({...t.workspace===void 0?{}:{workspace:t.workspace},...t.channel===void 0?{}:{channel:t.channel},files:e.map(s=>({file_name:s.fileName,content_type:s.contentType,size_bytes:s.sizeBytes}))}),n=ya(r.uploads)??[];if(n.length!==e.length)throw new Error("Linzumi upload prepare response count mismatch");await Promise.all(e.map(async(s,a)=>{let i=$t(n[a]),u=Te(i?.upload_url),l=Te(i?.upload_method)??"PUT";if(u===void 0)throw new Error("Linzumi upload prepare response missing upload_url");let c=await Ey(s.path),d=c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength),h=await fetch(To(t.kandanUrl,u),{method:l,headers:{"content-type":s.contentType},body:d});if(!h.ok)throw new Error(`Linzumi upload failed for ${s.fileName}: ${h.status} ${h.statusText}`)}));let o=n.map(s=>{let a=Te($t(s)?.file_id);if(a===void 0)throw new Error("Linzumi upload prepare response missing file_id");return a});return await t.client.attachMessageFiles({...t.workspace===void 0?{}:{workspace:t.workspace},...t.channel===void 0?{}:{channel:t.channel},target:t.target,...t.body===void 0?{}:{body:t.body},uploaded_file_ids:o})}async function UT(t){let e=await sd(t.cwd,t.file),r=await t.client.prepareCustomEmoji({...t.workspace===void 0?{}:{workspace:t.workspace},name:t.name,file_name:e.fileName,content_type:e.contentType,size_bytes:e.sizeBytes}),n=$t(r.upload),o=Te(n?.upload_url),s=Te(n?.upload_method)??"PUT";if(o===void 0)throw new Error("Linzumi custom emoji prepare response missing upload_url");let a=await Ey(e.path),i=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),u=await fetch(To(t.kandanUrl,o),{method:s,headers:{"content-type":e.contentType},body:i});if(!u.ok){let d=`${u.status} ${u.statusText}`,f=(await u.text()).trim(),m=f===""?d:(()=>{try{let g=JSON.parse(f);return tr(g)&&typeof g.error=="string"?g.error:f}catch{return f}})();throw new Error(`Linzumi custom emoji upload failed: ${m}`)}let l=await u.json();if(!tr(l))throw new Error("Linzumi custom emoji upload returned non-object JSON");let c=$t(l.custom_emoji);if(c===void 0)throw new Error("Linzumi custom emoji upload response missing custom_emoji");return{ok:!0,workspace:r.workspace,emoji:c,asset_id:Te(l.asset_id),id:vy(c?.id),name:Te(c?.name),shortcode:Te(c?.shortcode),image_url:Te(c?.image_url)}}function Py(t,e){if(Te(t.thread_id)!==void 0||e===void 0)return t;switch(t.message_seq===void 0){case!1:return{...t,thread_id:e};case!0:switch(Te(t.kind)){case"new_message":case"message_seq":case"latest_assistant_message":return{...t,thread_id:e};default:return t}}}function St(t,e){return Te(t.thread_id)!==void 0||e===void 0?t:{...t,thread_id:e}}function To(t,e){try{return new URL(e).toString()}catch{let n=t.replace(/^wss:\/\//,"https://").replace(/^ws:\/\//,"http://");return new URL(e,n).toString()}}function jy(t,e){let r=$t(e.message),n=$t(e.target_message);return r===void 0&&n===void 0?e:{...e,...r===void 0?{}:{message:Ry(t,r)},...n===void 0?{}:{target_message:Ry(t,n)}}}function Ry(t,e){let r=ya(e.attachments);return r===void 0?e:{...e,attachments:r.map(n=>JT(t,n))}}function JT(t,e){let r=$t(e);if(r===void 0)return e;let n=Te(r.url),o=$t(r.image_variants);return{...r,...n===void 0?{}:{url:To(t,n)},...o===void 0?{}:{image_variants:FT(t,o)}}}function FT(t,e){let r=Te(e.inline_url),n=Te(e.carousel_url);return{...e,...r===void 0?{}:{inline_url:To(t,r)},...n===void 0?{}:{carousel_url:To(t,n)}}}function VT(t){t.server.registerCapabilities({resources:{listChanged:!1}}),t.server.setRequestHandler(Yr,()=>({resources:[]})),t.server.setRequestHandler(Qr,()=>({resourceTemplates:[]}))}async function HT(t){let e=cd(t),r=ld(e,"api-url"),n=re(e,"format")??"codex",o=ud(re(e,"mode")),s=e.get("include-token")===!0?(await id({kandanUrl:r,explicitToken:re(e,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:re(e,"auth-file"),delegationAuthFilePath:re(e,"delegation-auth-file"),workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")})).accessToken:void 0,a=xy({command:re(e,"command"),kandanUrl:r,accessToken:s,delegationAuthFilePath:re(e,"delegation-auth-file"),ownerUsername:re(e,"owner-username")??process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:o,toolScope:Ay(re(e,"tool-scope"))});switch(n){case"codex":process.stdout.write(Sy(a));return;case"claude-code":process.stdout.write($y(a));return;default:throw new Error("--format must be codex or claude-code")}}async function BT(t){let e=cd(t),r=ld(e,"api-url"),n=await id({kandanUrl:r,explicitToken:re(e,"token")??process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:re(e,"auth-file"),delegationAuthFilePath:re(e,"delegation-auth-file"),workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")});switch(n.mode){case"local-runner":{if(!await hy({kandanUrl:r,accessToken:n.accessToken,workspaceSlug:re(e,"workspace"),channelSlug:re(e,"channel")}))throw new Error("Linzumi MCP auth validation failed");break}case"personal-agent-delegation":{await ad({kandanUrl:r,accessToken:n.accessToken,authMode:n.mode,operatingMode:ud(re(e,"mode"))}).validateAuth();break}}process.stdout.write(`Linzumi MCP auth OK
237
240
  `)}async function id(t){if(t.delegationAuthFilePath!==void 0){if(t.explicitToken!==void 0||t.authFilePath!==void 0)throw new Error("--delegation-auth-file cannot be combined with --token or --auth-file");return{accessToken:yy(t.delegationAuthFilePath).accessToken,mode:"personal-agent-delegation"}}return{accessToken:await WT({kandanUrl:t.kandanUrl,explicitToken:t.explicitToken,authFilePath:t.authFilePath,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug}),mode:"local-runner"}}async function WT(t,e={readCachedToken:ga,validateTokenOutcome:zo,resolveToken:by}){let r=t.explicitToken??e.readCachedToken(t.kandanUrl,t.authFilePath)?.accessToken;if(r===void 0)throw new Error("missing Linzumi MCP token; run linzumi auth or pass --token");let n=await e.validateTokenOutcome({kandanUrl:t.kandanUrl,accessToken:r,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug});if(n==="usable")return r;let o=n;try{return await e.resolveToken({kandanUrl:t.kandanUrl,workspaceSlug:t.workspaceSlug,channelSlug:t.channelSlug,authFilePath:t.authFilePath})}catch(s){throw new Error(`Linzumi MCP token was rejected by the server and re-mint failed: ${s instanceof Error?s.message:String(s)}`)}}function C(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}}async function Oy(t){try{return C(await t)}catch(e){let r=e instanceof Error?e.message:String(e),n=r.match(/failed: ([a-z0-9_]+)(?: detail=(.+))?$/);if(n===null)return C({error:r});let[,o,s]=n;return C(s===void 0?{error:o??r}:{error:o??r,detail:s})}}function cd(t){let e=new Map;for(let r=0;r<t.length;r+=1){let n=t[r];if(n===void 0)continue;if(!n.startsWith("--"))throw new Error(`unexpected argument ${n}`);let o=n.slice(2),s=ZT.get(o);if(s===void 0)throw new Error(`unsupported option --${o}`);if(s.kind==="boolean"){e.set(o,!0);continue}let a=t[r+1];if(a===void 0||a.startsWith("--"))throw new Error(`--${o} requires a value`);e.set(o,a),r+=1}return e}function re(t,e){let r=t.get(e);return typeof r=="string"&&r.trim()!==""?r:void 0}function ud(t){switch(t){case void 0:return"text";case"voice":case"text":return t;default:throw new Error("--mode must be voice or text")}}function Ay(t){switch(t){case void 0:return"all";case"all":case"onboarding-discovery":return t;default:throw new Error("--tool-scope must be all or onboarding-discovery")}}function ld(t,e){let r=re(t,e);if(r===void 0)throw new Error(`--${e} is required`);return r}function GT(t){return t[0]==="mcp"?t.slice(1):t}async function XT(t){try{await Iy(GT(t))}catch(e){process.stderr.write(`linzumi mcp server failed: ${e instanceof Error?e.message:String(e)}
238
241
  `),process.exitCode=1}}var YT=process.argv[1]!==void 0&&import.meta.url===KT(process.argv[1]).href;YT&&XT(process.argv.slice(2));export{GT as mcpServerEntryArgs,XT as runMcpServerEntry};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linzumi/cli",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",
5
5
  "type": "module",
6
6
  "bin": {